On Sun, Nov 1, 2020 at 2:33 AM Samuel Dupree <sdup...@speakeasy.net> wrote: > > I'm attempting to build wrappers around two Fortran routines. One is a > Fortran 77 subroutine (see file gravity_derivs.f) that calls a Fortran > 90 package that performs automatic differentiation (see file > auto_deriv.f90). > > I'm running he Anaconda distribution for Python 3.7.6 on a Mac Pro > (2019) under Mac OS X Catalina (ver. 10.15.6). The version of NumPy I'm > running is 1.18.3. The commands I used to attempt the build are > contained in the file auto_deriv_build. The messages output by f2py are > captured in the file auto_derivs_build_report.txt. > > I don't understand the cause behind the error messages I got, so any > advice would be welcomed. > > Sam Dupree.
Hi Sam, I've got a partial solution. I haven't used f2py yet but at least the error from your first `f2py` call seems straightforward. Near the top: Line #119 in gravity_derivs.f:" integer * 4 degree" updatevars: no name pattern found for entity='*4degree'. Skipping. This shows that the fortran code gets parsed as `(integer) (*4degree)`. That can't be right. There might be a way to tell f2py to do this right, but anyway I could make your code compile by replacing every such declaration with `integer * 4 :: degree` etc (i.e. adding double colons everywhere). Once that's fixed your first f2py call raises another error: Fatal Error: Cannot open module file ‘deriv_class.mod’ for reading at (1): No such file or directory I could generate these mod files by manually running `gfortran -c auto_deriv.f90`. After that the .mod files appear and your first `f2py` call will succed. You can now `import gravity_derivs`, but of course this will lead to an error because `auto_deriv` is not available in python. Unfortunately your _second_` f2py` call also dies on `auto_deriv.f90`, with such offending lines: In: :auto_deriv:auto_deriv.f90:ad_auxiliary get_parameters: got "invalid syntax (<string>, line 1)" on '(/((i, i=j,n), j=1,n)/)' I'm guessing that again f2py can't parse that syntax. My hunch is that if you can get f2py to work with `auto_deriv.f90` you should first run that. This should hopefully generate the .mod files after which the second call to `f2py` with `gravity_derivs.f` should work. If `f2py` doesn't generate the .mod files you could at worst run your fortran compiler yourself between the two calls to `f2py`. Cheers, András > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@python.org > https://mail.python.org/mailman/listinfo/numpy-discussion _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion