[f2py] Some questions about signatures
Lionel Maziere
maziere@algory.com
19 Feb 2002 19:48:06 +0100
Hi,
I have the following Fortran function :
SUBROUTINE GTNAME(NM)
CHARACTER*4 NM(9)
cf2py intent(in,out)
#include "NAME.h"
DO I =3D 1, 9
NM(I)=3DNAME(I)
END DO
END
where NAME.h is :
CHARACTER*4 NAME(9)
COMMON /NAME/ NAME
In the generated .pyf file I get :
subroutine gtname(nm) ! in :libtest:gtname.f
character*(9) intent(in,out) :: nm
character*(9) name
common /a/ name
end subroutine gtname
But 'character*4 x' isn't equivalent to 'character*4 x(9)' !
In fact, 'name' is really one string, but I am not in control of the
file NAME.h, nor the remaining of the code which use it, so I can't
change the statement to 'CHARACTER*36 NAME' which is what it actually
is.
If I edit the signature file and change all 'character*(9)' occurences
to 'character*36' and use it from python with an array of size 36, it
works just fine.
Why is this seen as 'character*(9)' in the signature ?
Why couldn't I force it with a cf2py statement as :
'cf2py character*36 intent(in,out)' ?
I wouldn't want commons to be seen from python, so I edit the signature
file to remove them, couldn't there be an option or some other way to
prevent commons to be included in signature file ?
Other problem :
If 'cf2py' directives in fortran files are insufficient to resolve above
problems, I must edit the .pyf. Then I would like to keep it and not
generate it at each build. But the Makefile-'module' is generated at the
same time than the .pyf with option --makefile. If I try to generate it
afterwards with same options except '-h module.pyf', the Makefile-module
then reference an undefined module-raw.pyf which it uses instead of my
edited module.pyf. I want to generate the Makefile-module after the .pyf
because this makefile depends on the exact installation of Python in the
system, which may vary, but not the signatures.
Example :
f2py -m test -h test.pyf *.f only: <some funcs>
-> generates test.pyf, which I modify
f2py -m test --makefile *.f only: <some funcs>
-> generates Makefile-test which relies on a 'test-raw.pyf' !
There's no option to tell 'use this signature file' and not generate as
'-h'.
Thanks for your help
--=20
=20
Lionel MAZI=C8RE
R&D Engineer Algory
maziere@algory.com http://www.algory.com