[Numpy-discussion] f2py is not recognizing Absoft Fortran Compiler

Samuel Dupree sdupree at speakeasy.net
Sat Apr 27 21:11:43 EDT 2019


I'm attempting to build an interface between a Fortran application I 
have and Python. The problem I'm having is that f2py is not recognizing 
my Absoft Fortran compiler. Details follow.

I'm running on a iMacPro (2017) under Mac OS X Mojave (ver. 10.14.4). 
The version of the Absoft Compiler I'm running is 19.0.0. I'm using the 
Anaconda distribution of Python 3, version 3.6.8, where the version of 
NumPy used is ver. 1.16.3.

The commands I'm using to build the Python interface function and there 
results are:


f2py    -m DIVA_EphGen_f77  -h DIVA_EphGen_f77.pyf DIVA_EphGen_f77.f 
--overwrite-signature

(base) Samuels-Mac-Pro:2nd_ODE_auto_deriv_cleanup_Rev-07 user$ 
./BuildMe_Part-1.sh
Reading fortran codes...
     Reading file 'DIVA_EphGen_f77.f' (format:fix,strict)
Post-processing...
     Block: DIVA_EphGen_f77
             Block: diva_ephgen_f77
Post-processing (stage 2)...
Saving signatures to file "./DIVA_EphGen_f77.pyf"
(base) Samuels-Mac-Pro:2nd_ODE_auto_deriv_cleanup_Rev-07 user$


f2py    -c --fcompiler=absoft DIVA_EphGen_f77.pyf DIVA_EphGen_f77.f \
         --f77exec=/Applications/Absoft19.0/bin/af77 \
         -L/Users/user/2nd_ODE_auto_deriv_cleanup_Rev-07/ -lDIVA_EphGen \
-L/Volumes/Development/AstrodynamicsLib/MacOSX.NAIF.Fortran.v65/toolkit-64-bit/lib/ 
-lspicelib \
-L/Volumes/Development/AstrodynamicsLib/MacOSX.NAIF.Fortran.v65/toolkit-64-bit/lib/ 
-lsupport \
         -L/Application/Absoft19.0/lib64/ -lblas \
         -L/Application/Absoft19.0/lib64/ -lAbsoftlapack \
         --verbose

(base) Samuels-Mac-Pro:2nd_ODE_auto_deriv_cleanup_Rev-07 user$ 
./BuildMe_Part-2.sh
running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands 
--compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands 
--fcompiler options
running build_src
build_src
building extension "DIVA_EphGen_f77" sources
creating 
/var/folders/65/7cxpqns144q6wx5lyb7zcyh80000gq/T/tmpkv4x9yg7/src.macosx-10.9-x86_64-3.6
f2py options: []
f2py: DIVA_EphGen_f77.pyf
Reading fortran codes...
     Reading file 'DIVA_EphGen_f77.pyf' (format:free)
Post-processing...
     Block: DIVA_EphGen_f77
             Block: diva_ephgen_f77
Post-processing (stage 2)...
Building modules...
     Building module "DIVA_EphGen_f77"...
         Constructing wrapper function "diva_ephgen_f77"...
           diva_ephgen_f77(cmdline,scale_factor)
     Wrote C/API module "DIVA_EphGen_f77" to file 
"/var/folders/65/7cxpqns144q6wx5lyb7zcyh80000gq/T/tmpkv4x9yg7/src.macosx-10.9-x86_64-3.6/DIVA_EphGen_f77module.c"
   adding 
'/var/folders/65/7cxpqns144q6wx5lyb7zcyh80000gq/T/tmpkv4x9yg7/src.macosx-10.9-x86_64-3.6/fortranobject.c' 
to sources.
   adding 
'/var/folders/65/7cxpqns144q6wx5lyb7zcyh80000gq/T/tmpkv4x9yg7/src.macosx-10.9-x86_64-3.6' 
to include_dirs.
copying 
/Users/user/anaconda3/lib/python3.6/site-packages/numpy/f2py/src/fortranobject.c 
-> 
/var/folders/65/7cxpqns144q6wx5lyb7zcyh80000gq/T/tmpkv4x9yg7/src.macosx-10.9-x86_64-3.6
copying 
/Users/user/anaconda3/lib/python3.6/site-packages/numpy/f2py/src/fortranobject.h 
-> 
/var/folders/65/7cxpqns144q6wx5lyb7zcyh80000gq/T/tmpkv4x9yg7/src.macosx-10.9-x86_64-3.6
build_src: building npy-pkg config files
running build_ext
new_compiler returns <class 'distutils.unixccompiler.UnixCCompiler'>
customize UnixCCompiler
customize UnixCCompiler using build_ext
********************************************************************************
<class 'distutils.unixccompiler.UnixCCompiler'>
preprocessor  = ['x86_64-apple-darwin13.4.0-clang', '-E', 
'-D_FORTIFY_SOURCE=2', '-mmacosx-version-min=10.9']
compiler      = ['x86_64-apple-darwin13.4.0-clang', '-DNDEBUG', 
'-fwrapv', '-O2', '-Wall', '-Wstrict-prototypes', '-march=core2', 
'-mtune=haswell', '-mssse3', '-ftree-vectorize', '-fPIC', '-fPIE', 
'-fstack-protector-strong', '-O2', '-pipe', '-D_FORTIFY_SOURCE=2', 
'-mmacosx-version-min=10.9']
compiler_so   = ['x86_64-apple-darwin13.4.0-clang', '-DNDEBUG', 
'-fwrapv', '-O2', '-Wall', '-Wstrict-prototypes', '-march=core2', 
'-mtune=haswell', '-mssse3', '-ftree-vectorize', '-fPIC', '-fPIE', 
'-fstack-protector-strong', '-O2', '-pipe', '-D_FORTIFY_SOURCE=2', 
'-mmacosx-version-min=10.9']
compiler_cxx  = ['x86_64-apple-darwin13.4.0-clang++']
linker_so     = ['x86_64-apple-darwin13.4.0-clang', '-bundle', 
'-undefined', 'dynamic_lookup', '-Wl,-pie', 
'-Wl,-headerpad_max_install_names', 
'-Wl,-rpath,/Users/user/anaconda3/lib', '-L/Users/user/anaconda3/lib', 
'-Wl,-pie', '-Wl,-headerpad_max_install_names', 
'-Wl,-rpath,/Users/user/anaconda3/lib', '-L/Users/user/anaconda3/lib', 
'-Wl,-export_dynamic', '-Wl,-pie', '-Wl,-headerpad_max_install_names', 
'-Wl,-dead_strip_dylibs', '-march=core2', '-mtune=haswell', '-mssse3', 
'-ftree-vectorize', '-fPIC', '-fPIE', '-fstack-protector-strong', '-O2', 
'-pipe', '-D_FORTIFY_SOURCE=2', '-mmacosx-version-min=10.9']
linker_exe    = ['x86_64-apple-darwin13.4.0-clang']
archiver      = 
['/Users/user/anaconda3/bin/x86_64-apple-darwin13.4.0-ar', 'rc']
ranlib        = ['ranlib']
libraries     = []
library_dirs  = []
include_dirs  = ['/Users/user/anaconda3/include/python3.6m']
********************************************************************************
customize AbsoftFCompiler
find_executable('/Users/user/anaconda3/bin/x86_64-apple-darwin13.4.0-gfortran')
Found executable 
/Users/user/anaconda3/bin/x86_64-apple-darwin13.4.0-gfortran
find_executable('/Applications/Absoft19.0/bin/af77')
Found executable /Applications/Absoft19.0/bin/af77
find_executable('/Users/user/anaconda3/bin/x86_64-apple-darwin13.4.0-ar')
Found executable /Users/user/anaconda3/bin/x86_64-apple-darwin13.4.0-ar
find_executable('/Users/user/anaconda3/bin/x86_64-apple-darwin13.4.0-ranlib')
Found executable /Users/user/anaconda3/bin/x86_64-apple-darwin13.4.0-ranlib
x86_64-apple-darwin13.4.0-gfortran: error: unrecognized command line 
option ‘-V’
Traceback (most recent call last):
   File "/Users/user/anaconda3/bin/f2py", line 11, in <module>
     load_entry_point('numpy==1.16.3', 'console_scripts', 'f2py')()
   File 
"/Users/user/anaconda3/lib/python3.6/site-packages/numpy/f2py/f2py2e.py", 
line 683, in main
     run_compile()
   File 
"/Users/user/anaconda3/lib/python3.6/site-packages/numpy/f2py/f2py2e.py", 
line 650, in run_compile
     setup(ext_modules=[ext])
   File 
"/Users/user/anaconda3/lib/python3.6/site-packages/numpy/distutils/core.py", 
line 171, in setup
     return old_setup(**new_attr)
   File "/Users/user/anaconda3/lib/python3.6/distutils/core.py", line 
148, in setup
     dist.run_commands()
   File "/Users/user/anaconda3/lib/python3.6/distutils/dist.py", line 
955, in run_commands
     self.run_command(cmd)
   File "/Users/user/anaconda3/lib/python3.6/distutils/dist.py", line 
974, in run_command
     cmd_obj.run()
   File 
"/Users/user/anaconda3/lib/python3.6/site-packages/numpy/distutils/command/build.py", 
line 47, in run
     old_build.run(self)
   File 
"/Users/user/anaconda3/lib/python3.6/distutils/command/build.py", line 
135, in run
     self.run_command(cmd_name)
   File "/Users/user/anaconda3/lib/python3.6/distutils/cmd.py", line 
313, in run_command
     self.distribution.run_command(command)
   File "/Users/user/anaconda3/lib/python3.6/distutils/dist.py", line 
974, in run_command
     cmd_obj.run()
   File 
"/Users/user/anaconda3/lib/python3.6/site-packages/numpy/distutils/command/build_ext.py", 
line 226, in run
     fcompiler.customize(self.distribution)
   File 
"/Users/user/anaconda3/lib/python3.6/site-packages/numpy/distutils/fcompiler/__init__.py", 
line 479, in customize
     f77flags = self.flag_vars.f77
   File 
"/Users/user/anaconda3/lib/python3.6/site-packages/numpy/distutils/fcompiler/environment.py", 
line 40, in __getattr__
     return self._get_var(name, conf_desc)
   File 
"/Users/user/anaconda3/lib/python3.6/site-packages/numpy/distutils/fcompiler/environment.py", 
line 56, in _get_var
     var = self._hook_handler(name, hook)
   File 
"/Users/user/anaconda3/lib/python3.6/site-packages/numpy/distutils/fcompiler/__init__.py", 
line 709, in _environment_hook
     return hook()
   File 
"/Users/user/anaconda3/lib/python3.6/site-packages/numpy/distutils/fcompiler/absoft.py", 
line 119, in get_flags_f77
     v = self.get_version()
   File 
"/Users/user/anaconda3/lib/python3.6/site-packages/numpy/distutils/fcompiler/__init__.py", 
line 432, in get_version
     raise CompilerNotFound()
numpy.distutils.fcompiler.CompilerNotFound
(base) Samuels-Mac-Pro:2nd_ODE_auto_deriv_cleanup_Rev-07 user$


A copy of the Fortran code and its corresponding .pyf file have been 
attached to this note.


Any suggestions as to how to fix this problem.


Sam Dupree.





-------------- next part --------------
      subroutine DIVA_EphGen_f77( cmdline, scale_factor )

      implicit none


      character (len=*)     cmdline


      double precision      scale_factor


!f2py    character (len=*)  intent(  in ) :: cmdline
!f2py    double precision   intent( out ) :: scale_fctor





c ---------------------------------------------------------------------
c ---------------------------------------------------------------------

      call DIVA_EphGen( cmdline, scale_factor)



c ---------------------------------------------------------------------
c     terminate execution
c ---------------------------------------------------------------------

      return


      end
-------------- next part --------------
!    -*- f90 -*-
! Note: the context of this file is case sensitive.

python module DIVA_EphGen_f77 ! in 
    interface  ! in :DIVA_EphGen_f77
        subroutine diva_ephgen_f77(cmdline,scale_factor) ! in :DIVA_EphGen_f77:DIVA_EphGen_f77.f
            character*(*) intent(in) :: cmdline
            double precision :: scale_factor
        end subroutine diva_ephgen_f77
    end interface 
end python module DIVA_EphGen_f77

! This file was auto-generated with f2py (version:2).
! See http://cens.ioc.ee/projects/f2py2e/


More information about the NumPy-Discussion mailing list