Re: [f2py] Re: f2py and F90 compiler options

Kevin Mitchell <[email protected]>
Newsgroups gmane.comp.python.f2py.user
Message-ID <[email protected]>
That looks like the linking command to me since it has only .o files going in.
I'm not sure if that's supposed to have your flag or not. One thing
you could try is running f2py with the LDFLAGS environment variable

LDFLAGS="$LDFLAGS -shared -frecord-marker=4" f2py -m testfort -c

The reason i didn't suggest that before was that at the time, that I
didn't know that "-shared" flag needed to be included there also for
it to successfully generate the .so file. The above command should now
generate the .so file with the record marker flag on the final link.
Whether that is actually the problem or not, I still couldn't say.

What if you try compiling your "testx" executable with the "f90
compiler" command that f2py is using? Maybe some of the optimisations
are causing a problem.

Kevin

On Tue, Jun 9, 2009 at 1:10 PM, Jeremy Roberts<[email protected]> wrote:
> I tried switching the order of the compilation arguments, but that didn't
> help.  Looking at the echoes, it does seem that in the final compilation the
> flags are dropped.  The following gives the Fortran-related output:
>
> compiling Fortran 90 module sources
> Fortran f77 compiler: /usr/bin/gfortran -Wall -ffixed-form
> -fno-second-underscore -fPIC -O3 -funroll-loops -march=nocona -mmmx -msse2
> -msse -msse3 -fomit-frame-pointer -malign-double
> Fortran f90 compiler: /usr/bin/gfortran -frecord-marker=4 -fPIC -O3
> -funroll-loops -march=nocona -mmmx -msse2 -msse -msse3 -fomit-frame-pointer
> -malign-double
> Fortran fix compiler: /usr/bin/gfortran -Wall -ffixed-form
> -fno-second-underscore -frecord-marker=4 -fPIC -O3 -funroll-loops
> -march=nocona -mmmx -msse2 -msse -msse3 -fomit-frame-pointer -malign-double
> compile options: '-I/tmp/tmpf2wRWf/src.linux-x86_64-2.5
> -I/home/cnerg/opt/Python-2.5.4/lib/python2.5/site-packages/numpy/core/include
> -I/home/cnerg/opt/Python-2.5.4/include/python2.5 -c'
> extra options: '-J/tmp/tmpf2wRWf/ -I/tmp/tmpf2wRWf/'
> gfortran:f90: testfort.f90
> compiling Fortran sources
> Fortran f77 compiler: /usr/bin/gfortran -Wall -ffixed-form
> -fno-second-underscore -fPIC -O3 -funroll-loops -march=nocona -mmmx -msse2
> -msse -msse3 -fomit-frame-pointer -malign-double
> Fortran f90 compiler: /usr/bin/gfortran -frecord-marker=4 -fPIC -O3
> -funroll-loops -march=nocona -mmmx -msse2 -msse -msse3 -fomit-frame-pointer
> -malign-double
> Fortran fix compiler: /usr/bin/gfortran -Wall -ffixed-form
> -fno-second-underscore -frecord-marker=4 -fPIC -O3 -funroll-loops
> -march=nocona -mmmx -msse2 -msse -msse3 -fomit-frame-pointer -malign-double
> compile options: '-I/tmp/tmpf2wRWf/src.linux-x86_64-2.5
> -I/home/cnerg/opt/Python-2.5.4/lib/python2.5/site-packages/numpy/core/include
> -I/home/cnerg/opt/Python-2.5.4/include/python2.5 -c'
> extra options: '-J/tmp/tmpf2wRWf/ -I/tmp/tmpf2wRWf/'
> gfortran:f90: /tmp/tmpf2wRWf/src.linux-x86_64-2.5/testfort-f2pywrappers2.f90
> /usr/bin/gfortran -Wall -Wall -shared
> /tmp/tmpf2wRWf/tmp/tmpf2wRWf/src.linux-x86_64-2.5/testfortmodule.o
> /tmp/tmpf2wRWf/tmp/tmpf2wRWf/src.linux-x86_64-2.5/fortranobject.o
> /tmp/tmpf2wRWf/covmod.o
> /tmp/tmpf2wRWf/tmp/tmpf2wRWf/src.linux-x86_64-2.5/testfort-f2pywrappers2.o
> -lgfortran -o ./testfort.so
> running scons
> Removing build directory /tmp/tmpf2wRWf
>
> The yellow highlight indicates where the flags are dropped.
>
> Jeremy
>
> On Sun, Jun 7, 2009 at 4:00 AM, <[email protected]> wrote:
>>
>> Subject: Re: [f2py] f2py and F90 compiler options
>> To: For users of the f2py program <f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]>
>> Message-ID:
>>        <1ecf80920906070029n11f6e1f8g7aca30cfde7be63f-JsoAwUIsXotQFR93xxRIaA@public.gmane.orgcom>
>> Content-Type: text/plain; charset=ISO-8859-1
>>
>> Mmm, it would seem that the -frecord-marker=4 isn't ending up in all
>> the right places. I too have often found passing flags to the
>> compiler/linker through f2py to be somewhat confounding. When you
>> compile with f2py, do any of the echo'ed compile commands NOT have the
>> "-frecord-marker=4" flag in them? I've found sometimes that
>> rearranging the order of arguments to f2py can help. You could also
>> try setting the F90FLAGS
>>
>> F90FLAGS="$F90FLAGS -frecord-marker=4" f2py -m testfort -c
>> testfort.f90 --f90flags="-frecord-marker=4"
>>
>> Kevin
>>
>> On Fri, Jun 5, 2009 at 1:13 PM, Jeremy Roberts<[email protected]>
>> wrote:
>> > Hi,
>> >
>> > I'm new to f2pi, and I'm seemingly running into issues using the
>> > Fortran-90
>> > compiler options.  The issue is that I have a large Fortran unformatted
>> > file
>> > with a record marker length of 4, and default on my system is 8.  I can
>> > fix
>> > this by using "-frecord-marker = 4".  A Fortran executable works fine to
>> > read this.
>> >
>> > However, using f2pi and calling the same subroutine from Python yields
>> > an
>> > error indicating that the "-frecord-marker" assignment hasn't been
>> > properly
>> > used.
>> >
>> > Fortran 90 :
>> >
>> > terminal% gfortran -frecord-marker=4 testfort.f90 testmain.f90 -o testx
>> > terminal% testx
>> >  ** read **
>> >
>> > where my files are:
>> >
>> > module testfort ! testfort.f90
>> >     implicit none
>> >     contains
>> >     subroutine fudge(a)
>> >         integer, intent(in) :: a
>> >         integer    :: ucov=77, io
>> >         open (unit = ucov, file = "44groupcov", action = "read", status
>> > =
>> > "old", &
>> >               position = "rewind", iostat = io, form="unformatted")
>> >         read(ucov)
>> >         print *, " ** read ** "
>> >     end subroutine fudge
>> > end module testfort
>> >
>> > program testmain ! testmain.f90
>> >     use testfort
>> >     implicit none
>> >     call fudge(1)
>> > end program testmain
>> >
>> > Note, without the frecord assignment, I get:
>> > terminal% gfortran testfort.f90 testmain.f90 -o testx
>> > terminal% testx
>> > At line 9 of file testfort.f90
>> > Fortran runtime error: Invalid argument
>> >
>> > which seems to mean it's expecting a different file marker length in the
>> > unformatted file "44groupcov".
>> >
>> > Now, using f2py:
>> >
>> > terminal% f2py -m testfort -c testfort.f90
>> > --f90flags="-frecord-marker=4"
>> > --fcompiler=gfortran
>> > terminal% python test.py
>> > At line 9 of file testfort.f90
>> > Fortran runtime error: Invalid argument
>> >
>> > Where test.py is:
>> >
>> > #! /usr/bin/env python
>> > import testfort
>> > testfort.testfort.fudge(1)
>> >
>> >
>> > Any insight as to what I'm doing wrong would be greatly appreciated.
>> >
>> > I'm using f2py version 2_5972 and Python 2.5.4.
>>
>
>
> _______________________________________________
> f2py-users mailing list
> f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]
> http://cens.ioc.ee/mailman/listinfo/f2py-users
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.