How to create python module from fortran program with f2py?

I am trying to read some smps files using python and found the implementation of fortran, so I thought I would give f2py. The problem is that I have no experience with fortran.

I successfully installed gfortran and f2py in my Linux block and ran the example on the f2py page, but I have problems compiling and running a large program. There are two files: one with a shell for reading files and one with all the logic. It seems they are calling each other, but when I compile and link or try f2py, I get errors that they somehow cannot find each other:

f95 -c FILEWR~1.F
f95 -c SMPSREAD.F90 
f95 -o smpsread SMPSREAD.o FILEWR~1.o 

FILEWR~1.o In function `file_wrapper_'
FILEWR~1.F(.text+0x3d) undefined reference to `chopen_'
usrlibgcci486-linux-gnu4.4.1libgfortranbegin.a(fmain.o) In function `main'
(.text+0x27) undefined reference to `MAIN__'
collect2 ld returned 1 exit status  

I also tried changing the name to FILE_WRAPPER.F, but that did not help.

f2py , , , :

f2py -c -m smpsread smpsread.f90

, :

getctype: No C-type found in "{'typespec': 'type', 'attrspec': ['allocatable'],  'typename': 'node', 'dimension': [':']}", assuming void.

fortran 90 spms reader .

.

+3
1
0

Source: https://habr.com/ru/post/1737331/


All Articles