Re: [f2py] user fortran type declaration

Xavier Barthelemy <[email protected]> Fri, 3 Sep 2010 09:54:36 +1000
Newsgroups gmane.comp.python.f2py.user
Message-ID <[email protected]>
2010/9/2 Pearu Peterson <[email protected]>:
>
> Thanks for your kind words:)

I really mean it
>
>> I have wrap different subroutine and it works well in python, thanks
>> to f2py. My problem is I can't reach certain calculus precision in
>> standard fortran. So I need to use user defined type.
>> I have understood that f2py does not handle user-defined variable
>> type, and i think it doesn't do that in sense of I can't get this kind
>> of variable in or out.
>> But i would like to use user define type as inner variable of my
>> fortran program.
>>
>> I'll explain myself with an example:
>>
>> this is my fortran code:
>>
>>         SUBROUTINE InteriorField()
>>         use mpmodule
>>         implicit none
>>         integer:: NpointsIn
>>         parameter(NpointsIn=5)
>>         type (mp_real) :: FIELD(11,NpointsIn)
>> !       call mpinit(100)
>>
>>         FIELD(1,1)='1.'
>>         print*,FIELD(1,1)
>>         return
>>         end
>>
>>
>> the mpmodule comes from the arprec (arbitrary precision package) that
>> you can find here: http://crd.lbl.gov/~dhbailey/mpdist/
>> It define user type and overload standard operator so you can make
>> multiplication with as much significative digits as you wish, and you
>> don't need to stick to the classic double precision.
>> I would like to use this in my inner calculation and I can have an
>> output in double precision on the result of my calculus.
>>
>> I wrap it using
>> f2py --fcompiler=intelem -c -m Test Test.f  --opt=" -I<APPRECLIBDIR>
>> -larprecmod -larprec -larprec_f_main -mp" --no-lower
>> where  libarprecmod.a  libarprec. libarprec_f_main.a are my module
>
> Perhaps `-mp` should read `-lmp`?

nope, -mp is an intel fortran compiler option that maintain floating
point precision
>
>> It compiles, but when  I type in python
>>
>> then When I look at the ARPREC documentation, it says:
>> f ->  o : ifort Test-f -c Test.o -I<APPRECLIBDIR>  -mp
>> o ->  exec: gcc -o test Test.o -L<ARPRECLIBDIR>  -l<ARPRECLIBS>
>> -L<BunchOfLibDir>  -lifport -lifcore -limf -lsvml -lm -lipgo -lirc
>> -lirc_s -ldl
>>

I made a mistake, to link everything  have to compile with g++, not gcc
how can i force f2py to use it?
the thing is the test program is working when I compile it, but not
with f2py. I understand I have to compile it with g++.
Have you got a solution?

Xavier