Skip to content

BUG: f2py cannot compile files it used to be able to compile  #24008

Closed

Description

@kconnour

Describe the issue:

I'm attempting to use f2py to compile some fortran code. I'm able to do this using the following numpy versions:

  • 1.21.0
  • 1.22.0
  • 1.23.0
  • 1.24.0
  • 1.24.2

Starting on v1.24.3, the same compilation code no longer works using f2py. Strangely enough, if I precompile one of files (LAPACK.f), the compilation can work with v1.24.3.

Reproduce the code example:

# I don't see how I can produce runnable code using f2py, as it requires the fortran source code
# This code produces a .so file in my project's home directory on numpy <= 1.24.2 but doesn't work on numpy >= 1.24.3

from pathlib import Path
from numpy import f2py

project_path = Path(__file__).resolve().parent
disort_directory = project_path.joinpath('disort4.0.99')
module_name = 'disort'
fortran_source_filenames = ['BDREF.f', 'DISOBRDF.f', 'ERRPACK.f', 'LAPACK.f', 'LINPAK.f', 'RDI1MACH.f']
fortran_paths = [disort_directory.joinpath(f) for f in fortran_source_filenames]
with open(disort_directory.joinpath('DISORT.f')) as disort_module:
    f2py.compile(disort_module.read(), modulename=module_name, extra_args=fortran_paths)

# If I precompile LAPACK.f using:
# /usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -g -fno-second-underscore -fPIC -O3 -funroll-loops -c LAPACK.f
# then it works using numpy = 1.24.3. Note the only difference in the code is the LAPACK.f is now LAPACK.o

project_path = Path(__file__).resolve().parent
disort_directory = project_path.joinpath('disort4.0.99')
module_name = 'disort'
fortran_source_filenames = ['BDREF.f', 'DISOBRDF.f', 'ERRPACK.f', 'LAPACK.o', 'LINPAK.f', 'RDI1MACH.f']
fortran_paths = [disort_directory.joinpath(f) for f in fortran_source_filenames]
with open(disort_directory.joinpath('DISORT.f')) as disort_module:
    f2py.compile(disort_module.read(), modulename=module_name, extra_args=fortran_paths)

Error message:

There is no error message. f2py simply stops right before where it prints this line:
INFO: compiling Fortran sources

Runtime information:

Line 1 output:
1.24.0
3.10.6 (main, May 29 2023, 11:10:38) [GCC 11.3.0]

(note that I have no idea why it says 1.24.0 when Pycharm assures me I'm using 1.24.2)

Line 2 output:
Exception ignored on calling ctypes callback function: <function ThreadpoolController._find_libraries_with_dl_iterate_phdr..match_library_callback at 0x7f592f9c00d0>
Traceback (most recent call last):
File "/repos/pyRT_DISORT/venv/lib/python3.10/site-packages/threadpoolctl.py", line 584, in match_library_callback
self._make_controller_from_path(filepath)
File "
/repos/pyRT_DISORT/venv/lib/python3.10/site-packages/threadpoolctl.py", line 725, in _make_controller_from_path
lib_controller = lib_controller_class(
File "/pyRT_DISORT/venv/lib/python3.10/site-packages/threadpoolctl.py", line 842, in init
super().init(**kwargs)
File "
/repos/pyRT_DISORT/venv/lib/python3.10/site-packages/threadpoolctl.py", line 810, in init
self._dynlib = ctypes.CDLL(filepath, mode=_RTLD_NOLOAD)
File "/usr/lib/python3.10/ctypes/init.py", line 374, in init
self._handle = _dlopen(self._name, mode)
OSError: dlopen() error
[{'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
'found': ['SSSE3',
'SSE41',
'POPCNT',
'SSE42',
'AVX',
'F16C',
'FMA3',
'AVX2'],
'not_found': ['AVX512F',
'AVX512CD',
'AVX512_KNL',
'AVX512_KNM',
'AVX512_SKX',
'AVX512_CLX',
'AVX512_CNL',
'AVX512_ICL']}}]
None

Context for the issue:

I believe that LAPACK.f is one of the more widely used fortran codes. If it cannot compile in conjunction with other code, that could potentially disrupt a good number of users.

Activity

  1. seberg commented on Jun 21, 2023

    @seberg
    Member

    Ping @HaoZeke, also to confirm, can you check if the issue persists on 1.25.0?

  2. kconnour commented on Jun 21, 2023

    @kconnour
    Author

    @seberg I can confirm that the issue persists on 1.25.0. It's actually why I noticed it in the first place. My code that used to run failed and then I tracked it down to the version number described above, in hopes that someone might have a better idea what caused it.

  3. HaoZeke commented on Jun 21, 2023

    @HaoZeke
    Member

    On 1.24.4 the error is:

    ❯ f2py -c --f90flags='-O3' -m disort BDREF.f DISOBRDF.f ERRPACK.f LAPACK.f LINPAK.f RDI1MACH.f
    
    running build
    running config_cc
    INFO: unifing config_cc, config, build_clib, build_ext, build commands --compiler options
    running config_fc
    INFO: unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
    running build_src
    INFO: build_src
    INFO: building extension "disort" sources
    INFO: f2py options: []
    INFO: f2py:> /tmp/tmpuul0531u/src.linux-x86_64-3.9/disortmodule.c
    creating /tmp/tmpuul0531u/src.linux-x86_64-3.9
    Reading fortran codes...
    	Reading file 'BDREF.f' (format:fix,strict)
    	Reading file 'DISOBRDF.f' (format:fix,strict)
    rmbadname1: Replacing "float" with "float_bn".
    rmbadname1: Replacing "len" with "len_bn".
    rmbadname1: Replacing "max" with "max_bn".
    rmbadname1: Replacing "float" with "float_bn".
    	Reading file 'ERRPACK.f' (format:fix,strict)
    	Reading file 'LAPACK.f' (format:fix,strict)
    rmbadname1: Replacing "max" with "max_bn".
    Line #229 in LAPACK.f:"      PARAMETER (ONE=1.0D+0,ZERO=0.0D+0)"
    	get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    rmbadname1: Replacing "max" with "max_bn".
    Line #745 in LAPACK.f:"      PARAMETER          ( ONE = 1.0D+0, ZERO = 0.0D+0 )"
    	get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    rmbadname1: Replacing "max" with "max_bn".
    rmbadname1: Replacing "min" with "min_bn".
    rmbadname1: Replacing "max" with "max_bn".
    rmbadname1: Replacing "min" with "min_bn".
    rmbadname1: Replacing "max" with "max_bn".
    Line #1363 in LAPACK.f:"      PARAMETER          ( ONE = 1.0D+0, ZERO = 0.0D+0 )"
    	get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    rmbadname1: Replacing "max" with "max_bn".
    Line #2115 in LAPACK.f:"      PARAMETER (ONE=1.0D+0,ZERO=0.0D+0)"
    	get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    rmbadname1: Replacing "char" with "char_bn".
    rmbadname1: Replacing "int" with "int_bn".
    rmbadname1: Replacing "min" with "min_bn".
    rmbadname1: Replacing "max" with "max_bn".
    Line #3999 in LAPACK.f:"      PARAMETER          ( ONE = 1.0E+0, ZERO = 0.0E+0 )"
    	get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    rmbadname1: Replacing "max" with "max_bn".
    rmbadname1: Replacing "min" with "min_bn".
    Line #4273 in LAPACK.f:"      PARAMETER          ( ONE = 1.0E+0, ZERO = 0.0E+0 )"
    	get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    Line #4277 in LAPACK.f:"      PARAMETER          ( NBMAX = 64, LDWORK = NBMAX+1 )"
    	get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    Line #4277 in LAPACK.f:"      PARAMETER          ( NBMAX = 64, LDWORK = NBMAX+1 )"
    	get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    Line #4277 in LAPACK.f:"      PARAMETER          ( NBMAX = 64, LDWORK = NBMAX+1 )"
    	get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    Line #4277 in LAPACK.f:"      PARAMETER          ( NBMAX = 64, LDWORK = NBMAX+1 )"
    	get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    rmbadname1: Replacing "max" with "max_bn".
    rmbadname1: Replacing "min" with "min_bn".
    rmbadname1: Replacing "max" with "max_bn".
    rmbadname1: Replacing "min" with "min_bn".
    rmbadname1: Replacing "max" with "max_bn".
    Line #5124 in LAPACK.f:"      PARAMETER (ONE=1.0E+0,ZERO=0.0E+0)"
    	get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    Line #5462 in LAPACK.f:"      PARAMETER (ONE=1.0E+0,ZERO=0.0E+0)"
    	get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    rmbadname1: Replacing "max" with "max_bn".
    rmbadname1: Replacing "max" with "max_bn".
    rmbadname1: Replacing "max" with "max_bn".
    rmbadname1: Replacing "min" with "min_bn".
    rmbadname1: Replacing "max" with "max_bn".
    Line #6657 in LAPACK.f:"      PARAMETER (ONE=1.0E+0,ZERO=0.0E+0)"
    	get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    	Reading file 'LINPAK.f' (format:fix,strict)
    rmbadname1: Replacing "max" with "max_bn".
    rmbadname1: Replacing "min" with "min_bn".
    rmbadname1: Replacing "max" with "max_bn".
    rmbadname1: Replacing "min" with "min_bn".
    rmbadname1: Replacing "min" with "min_bn".
    rmbadname1: Replacing "max" with "max_bn".
    	Reading file 'RDI1MACH.f' (format:fix,strict)
    Post-processing...
    	Block: disort
    			Block: bdref
    			Block: brdf_hapke
    			Block: brdf_rpv
    			Block: brdf_rossli
    			Block: oceabrdf2
    			Block: shadow_eta
    			Block: disobrdf
    {}
    In: :disort:DISOBRDF.f:surfac2
    vars2fortran: No typespec for argument "nazz".
    			Block: surfac2
    			Block: qgausn2
    			Block: zeroit2
    			Block: errmsg
    			Block: wrtbad
    			Block: wrtdim
    			Block: tstbad
    			Block: dgemm
    In: :disort:LAPACK.f:dgemm
    get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    In: :disort:LAPACK.f:dgemm
    get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    			Block: dger
    In: :disort:LAPACK.f:dger
    get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    			Block: dgetf2
    In: :disort:LAPACK.f:dgetf2
    get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    In: :disort:LAPACK.f:dgetf2
    get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    			Block: dgetrf
    In: :disort:LAPACK.f:dgetrf
    get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    			Block: dgetrs
    In: :disort:LAPACK.f:dgetrs
    get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    			Block: dlamch
    In: :disort:LAPACK.f:dlamch
    get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    In: :disort:LAPACK.f:dlamch
    get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    			Block: dlamc3
    			Block: dlaswp
    			Block: dscal
    			Block: dswap
    			Block: dtrsm
    In: :disort:LAPACK.f:dtrsm
    get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    In: :disort:LAPACK.f:dtrsm
    get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    			Block: idamax
    			Block: ieeeck
    			Block: ilaenv
    			Block: iparmq
    In: :disort:LAPACK.f:iparmq
    get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    			Block: lsame
    			Block: scopy
    			Block: sgbtf2
    In: :disort:LAPACK.f:sgbtf2
    get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    In: :disort:LAPACK.f:sgbtf2
    get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    			Block: sgbtrf
    In: :disort:LAPACK.f:sgbtrf
    get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    In: :disort:LAPACK.f:sgbtrf
    get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    			Block: sgbtrs
    In: :disort:LAPACK.f:sgbtrs
    get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    			Block: sgemm
    In: :disort:LAPACK.f:sgemm
    get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    In: :disort:LAPACK.f:sgemm
    get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    			Block: sgemv
    In: :disort:LAPACK.f:sgemv
    get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    In: :disort:LAPACK.f:sgemv
    get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    			Block: sger
    In: :disort:LAPACK.f:sger
    get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    			Block: slaswp
    			Block: stbsv
    In: :disort:LAPACK.f:stbsv
    get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    			Block: strsm
    In: :disort:LAPACK.f:strsm
    get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    In: :disort:LAPACK.f:strsm
    get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    			Block: xerbla
    			Block: sgbco
    			Block: sgbfa
    			Block: sgbsl
    			Block: sgeco
    			Block: sgefa
    			Block: sgesl
    			Block: sasum
    			Block: saxpy
    			Block: sdot
    			Block: sscal
    			Block: sswap
    			Block: isamax
    			Block: r1mach
    			Block: d1mach
    			Block: i1mach
    Applying post-processing hooks...
      character_backward_compatibility_hook
    Post-processing (stage 2)...
    Building modules...
        Building module "disort"...
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
    		Creating wrapper for Fortran function "bdref"("bdref")...
            Constructing wrapper function "bdref"...
              bdref = bdref(mu,mup,dphi,brdf_type,brdf_arg)
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "brdf_hapke"...
              brdf_hapke(mup,mu,dphi,b0,hh,w,pi,brdf)
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "brdf_rpv"...
              brdf_rpv(mu_i,mu_r,dphi,rho0,kappa,g_hg,h0,brdf)
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "brdf_rossli"...
              brdf_rossli(mu_i,mu_r,dphi,k_iso,k_vol,k_geo,alpha0,brdf)
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "oceabrdf2"...
              oceabrdf2(do_shadow,refrac_index,ws,mu_i,mu_r,dphi,brdf)
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
    		Creating wrapper for Fortran function "shadow_eta"("shadow_eta")...
            Constructing wrapper function "shadow_eta"...
              shadow_eta = shadow_eta(cos_theta,sigma_sq,pi)
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "disobrdf"...
              rhoq,rhou,emust,bemst,bdr_beam_analytic = disobrdf(usrang,umu,fbeam,umu0,lamber,albedo,onlyfl,rhoq,rhou,emust,bemst,debug,phi,phi0,bdr_beam_analytic,brdf_type,brdf_arg,nmug,[nstr,numu,nphi])
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "surfac2"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              surfac2(albedo,delm0,cmu,fbeam,lamber,mazim,onlyfl,pi,umu,umu0,usrang,bdr,emu,bem,rmu,rhoq,rhou,emust,bemst,debug,gmu,gwt,cosmp,brdf_type,brdf_arg,[mi,mxumu,nn,numu,nazz,nstr,nmug])
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "qgausn2"...
              qgausn2(gmu,gwt,[m])
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "zeroit2"...
              zeroit2(a,[length])
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "errmsg"...
              errmsg(messag,fatal)
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
    		Creating wrapper for Fortran function "wrtbad"("wrtbad")...
            Constructing wrapper function "wrtbad"...
              wrtbad = wrtbad(varnam)
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
    		Creating wrapper for Fortran function "wrtdim"("wrtdim")...
            Constructing wrapper function "wrtdim"...
              wrtdim = wrtdim(dimnam,minval)
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
    		Creating wrapper for Fortran function "tstbad"("tstbad")...
            Constructing wrapper function "tstbad"...
              tstbad = tstbad(varnam,relerr)
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "dgemm"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              dgemm(transa,transb,m,n,k,alpha,a,b,beta,c,[lda,ldb,ldc])
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "dger"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              dger(m,n,alpha,x,incx,y,incy,a,[lda])
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "dgetf2"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              dgetf2(m,n,a,ipiv,info,[lda])
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "dgetrf"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              dgetrf(m,n,a,ipiv,info,[lda])
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "dgetrs"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              dgetrs(trans,n,nrhs,a,ipiv,b,info,[lda,ldb])
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
    		Creating wrapper for Fortran function "dlamch"("dlamch")...
            Constructing wrapper function "dlamch"...
              dlamch = dlamch(cmach)
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
    		Creating wrapper for Fortran function "dlamc3"("dlamc3")...
            Constructing wrapper function "dlamc3"...
              dlamc3 = dlamc3(a,b)
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "dlaswp"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              dlaswp(n,a,k1,k2,ipiv,incx,[lda])
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "dscal"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              dscal(n,da,dx,incx)
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "dswap"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              dswap(n,dx,incx,dy,incy)
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "dtrsm"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              dtrsm(side,uplo,transa,diag,m,n,alpha,a,b,[lda,ldb])
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
    		Creating wrapper for Fortran function "idamax"("idamax")...
            Constructing wrapper function "idamax"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              idamax = idamax(n,dx,incx)
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
    		Creating wrapper for Fortran function "ieeeck"("ieeeck")...
            Constructing wrapper function "ieeeck"...
              ieeeck = ieeeck(ispec,zero,one)
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
    		Creating wrapper for Fortran function "ilaenv"("ilaenv")...
            Constructing wrapper function "ilaenv"...
              ilaenv = ilaenv(ispec,name,opts,n1,n2,n3,n4)
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
    		Creating wrapper for Fortran function "iparmq"("iparmq")...
            Constructing wrapper function "iparmq"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getstrlength: expected a signature of a string but got: {'typespec': 'character', 'charselector': {'*': ''}, 'attrspec': [], 'dimension': ['*']}
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getstrlength: expected a signature of a string but got: {'typespec': 'character', 'charselector': {'*': ''}, 'attrspec': [], 'dimension': ['*']}
              iparmq = iparmq(ispec,name,opts,n,ilo,ihi,lwork)
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
    		Creating wrapper for Fortran function "lsame"("lsame")...
            Constructing wrapper function "lsame"...
              lsame = lsame(ca,cb)
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "scopy"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              scopy(n,sx,incx,sy,incy)
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "sgbtf2"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              sgbtf2(m,n,kl,ku,ab,ipiv,info,[ldab])
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "sgbtrf"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              sgbtrf(m,n,kl,ku,ab,ipiv,info,[ldab])
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "sgbtrs"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              sgbtrs(trans,n,kl,ku,nrhs,ab,ipiv,b,info,[ldab,ldb])
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "sgemm"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              sgemm(transa,transb,m,n,k,alpha,a,b,beta,c,[lda,ldb,ldc])
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "sgemv"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              sgemv(trans,m,n,alpha,a,x,incx,beta,y,incy,[lda])
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "sger"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              sger(m,n,alpha,x,incx,y,incy,a,[lda])
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "slaswp"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              slaswp(n,a,k1,k2,ipiv,incx,[lda])
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "stbsv"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              stbsv(uplo,trans,diag,n,k,a,x,incx,[lda])
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "strsm"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              strsm(side,uplo,transa,diag,m,n,alpha,a,b,[lda,ldb])
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "xerbla"...
              xerbla(srname,info)
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "sgbco"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              sgbco(abd,n,ml,mu,ipvt,rcond,z,[lda])
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "sgbfa"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              sgbfa(abd,n,ml,mu,ipvt,info,[lda])
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "sgbsl"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              sgbsl(abd,n,ml,mu,ipvt,b,job,[lda])
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "sgeco"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              sgeco(a,n,ipvt,rcond,z,[lda])
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "sgefa"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              sgefa(a,n,ipvt,info,[lda])
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "sgesl"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              sgesl(a,n,ipvt,b,job,[lda])
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
    		Creating wrapper for Fortran function "sasum"("sasum")...
            Constructing wrapper function "sasum"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              sasum = sasum(n,sx,incx)
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "saxpy"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              saxpy(n,sa,sx,incx,sy,incy)
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
    		Creating wrapper for Fortran function "sdot"("sdot")...
            Constructing wrapper function "sdot"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              sdot = sdot(n,sx,incx,sy,incy)
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "sscal"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              sscal(n,sa,sx,incx)
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
            Constructing wrapper function "sswap"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              sswap(n,sx,incx,sy,incy)
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
    		Creating wrapper for Fortran function "isamax"("isamax")...
            Constructing wrapper function "isamax"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
              isamax = isamax(n,sx,incx)
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
    		Creating wrapper for Fortran function "r1mach"("r1mach")...
            Constructing wrapper function "r1mach"...
              r1mach = r1mach(i)
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
    		Creating wrapper for Fortran function "d1mach"("d1mach")...
            Constructing wrapper function "d1mach"...
              d1mach = d1mach(i)
        Generating possibly empty wrappers"
        Maybe empty "disort-f2pywrappers.f"
    		Creating wrapper for Fortran function "i1mach"("i1mach")...
            Constructing wrapper function "i1mach"...
              i1mach = i1mach(i)
        Wrote C/API module "disort" to file "/tmp/tmpuul0531u/src.linux-x86_64-3.9/disortmodule.c"
        Fortran 77 wrappers are saved to "/tmp/tmpuul0531u/src.linux-x86_64-3.9/disort-f2pywrappers.f"
    INFO:   adding '/tmp/tmpuul0531u/src.linux-x86_64-3.9/fortranobject.c' to sources.
    INFO:   adding '/tmp/tmpuul0531u/src.linux-x86_64-3.9' to include_dirs.
    copying /home/rgoswami/Git/Github/Quansight/f2py_envs/numpy/numpy/f2py/src/fortranobject.c -> /tmp/tmpuul0531u/src.linux-x86_64-3.9
    copying /home/rgoswami/Git/Github/Quansight/f2py_envs/numpy/numpy/f2py/src/fortranobject.h -> /tmp/tmpuul0531u/src.linux-x86_64-3.9
    INFO:   adding '/tmp/tmpuul0531u/src.linux-x86_64-3.9/disort-f2pywrappers.f' to sources.
    INFO: build_src: building npy-pkg config files
    running build_ext
    INFO: customize UnixCCompiler
    INFO: C compiler: /home/rgoswami/.micromamba/envs/numpy-dev/bin/x86_64-conda-linux-gnu-cc -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/rgoswami/.micromamba/envs/numpy-dev/include -I/home/rgoswami/.micromamba/envs/numpy-dev/include -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/rgoswami/.micromamba/envs/numpy-dev/include -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/rgoswami/.micromamba/envs/numpy-dev/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/rgoswami/.micromamba/envs/numpy-dev/include -fPIC
    
    creating /tmp/tmp27l9smg9/tmp
    creating /tmp/tmp27l9smg9/tmp/tmp27l9smg9
    INFO: compile options: '-MMD -MF /tmp/tmp27l9smg9/file.c.d -c'
    INFO: x86_64-conda-linux-gnu-cc: /tmp/tmp27l9smg9/file.c
    INFO: customize UnixCCompiler using build_ext
    INFO: get_default_fcompiler: matching types: '['arm', 'gnu95', 'intel', 'lahey', 'pg', 'nv', 'absoft', 'nag', 'vast', 'compaq', 'intele', 'intelem', 'gnu', 'g95', 'pathf95', 'nagfor', 'fujitsu']'
    INFO: customize ArmFlangCompiler
    INFO: Found executable /home/rgoswami/.micromamba/envs/numpy-dev/bin/x86_64-conda-linux-gnu-gfortran
    WARN: Could not locate executable armflang
    INFO: Found executable /home/rgoswami/.micromamba/envs/numpy-dev/bin/x86_64-conda-linux-gnu-ar
    INFO: customize Gnu95FCompiler
    INFO: Found executable /home/rgoswami/.micromamba/envs/numpy-dev/bin/x86_64-conda-linux-gnu-ld
    INFO: Found executable /home/rgoswami/.micromamba/envs/numpy-dev/bin/x86_64-conda-linux-gnu-ranlib
    INFO: customize Gnu95FCompiler
    INFO: customize Gnu95FCompiler using build_ext
    INFO: building 'disort' extension
    INFO: compiling C sources
    INFO: C compiler: /home/rgoswami/.micromamba/envs/numpy-dev/bin/x86_64-conda-linux-gnu-cc -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/rgoswami/.micromamba/envs/numpy-dev/include -I/home/rgoswami/.micromamba/envs/numpy-dev/include -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/rgoswami/.micromamba/envs/numpy-dev/include -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/rgoswami/.micromamba/envs/numpy-dev/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/rgoswami/.micromamba/envs/numpy-dev/include -fPIC
    
    creating /tmp/tmpuul0531u/tmp
    creating /tmp/tmpuul0531u/tmp/tmpuul0531u
    creating /tmp/tmpuul0531u/tmp/tmpuul0531u/src.linux-x86_64-3.9
    INFO: compile options: '-DNPY_DISABLE_OPTIMIZATION=1 -I/tmp/tmpuul0531u/src.linux-x86_64-3.9 -I/home/rgoswami/Git/Github/Quansight/f2py_envs/numpy/numpy/core/include -I/home/rgoswami/.micromamba/envs/numpy-dev/include/python3.9 -c'
    INFO: x86_64-conda-linux-gnu-cc: /tmp/tmpuul0531u/src.linux-x86_64-3.9/disortmodule.c
    INFO: x86_64-conda-linux-gnu-cc: /tmp/tmpuul0531u/src.linux-x86_64-3.9/fortranobject.c
    /tmp/tmpuul0531u/src.linux-x86_64-3.9/disortmodule.c: In function 'f2py_rout_disort_iparmq':
    /tmp/tmpuul0531u/src.linux-x86_64-3.9/disortmodule.c:4772:58: error: expected expression before ',' token
     4772 |     capi_name_as_array = ndarray_from_pyobj(  NPY_STRING,,name_Dims,name_Rank,  capi_name_intent,name_capi,capi_errmess);
          |                                                          ^
    /tmp/tmpuul0531u/src.linux-x86_64-3.9/disortmodule.c:4787:58: error: expected expression before ',' token
     4787 |     capi_opts_as_array = ndarray_from_pyobj(  NPY_STRING,,opts_Dims,opts_Rank,  capi_opts_intent,opts_capi,capi_errmess);
          |                                                          ^
    error: Command "/home/rgoswami/.micromamba/envs/numpy-dev/bin/x86_64-conda-linux-gnu-cc -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/rgoswami/.micromamba/envs/numpy-dev/include -I/home/rgoswami/.micromamba/envs/numpy-dev/include -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/rgoswami/.micromamba/envs/numpy-dev/include -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/rgoswami/.micromamba/envs/numpy-dev/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/rgoswami/.micromamba/envs/numpy-dev/include -fPIC -DNPY_DISABLE_OPTIMIZATION=1 -I/tmp/tmpuul0531u/src.linux-x86_64-3.9 -I/home/rgoswami/Git/Github/Quansight/f2py_envs/numpy/numpy/core/include -I/home/rgoswami/.micromamba/envs/numpy-dev/include/python3.9 -c /tmp/tmpuul0531u/src.linux-x86_64-3.9/disortmodule.c -o /tmp/tmpuul0531u/tmp/tmpuul0531u/src.linux-x86_64-3.9/disortmodule.o -MMD -MF /tmp/tmpuul0531u/tmp/tmpuul0531u/src.linux-x86_64-3.9/disortmodule.o.d" failed with exit status 1

    Where it seems that the relevant error is from changes to character handling:

    getstrlength: expected a signature of a string but got: {'typespec': 'character', 'charselector': {'*': ''}, 'attrspec': [], 'dimension': ['*']}
    getstrlength: expected a signature of a string but got: {'typespec': 'character', 'charselector': {'*': ''}, 'attrspec': [], 'dimension': ['*']}
    /tmp/tmp5l8spqw9/src.linux-x86_64-3.9/disortmodule.c: In function 'f2py_rout_disort_iparmq':
    /tmp/tmp5l8spqw9/src.linux-x86_64-3.9/disortmodule.c:4772:58: error: expected expression before ',' token
     4772 |     capi_name_as_array = ndarray_from_pyobj(  NPY_STRING,,name_Dims,name_Rank,  capi_name_intent,name_capi,capi_errmess);
          |                                                          ^
    /tmp/tmp5l8spqw9/src.linux-x86_64-3.9/disortmodule.c:4787:58: error: expected expression before ',' token
     4787 |     capi_opts_as_array = ndarray_from_pyobj(  NPY_STRING,,opts_Dims,opts_Rank,  capi_opts_intent,opts_capi,capi_errmess);
          |                      

    OTOH I would suspect something in the character handling of #23356 or #23194

    Diffing the outputs b/w 1.24.3 and 1.24.4 only show:

    		Creating wrapper for Fortran function "iparmq"("iparmq")...
            Constructing wrapper function "iparmq"...
    getarrdims:warning: assumed shape array, using 0 instead of '*'
    getarrdims:warning: assumed shape array, using 0 instead of '*'

    Indeed, f2py -c --f90flags='-O3' -m disort BDREF.f DISOBRDF.f ERRPACK.f LAPACK.f LINPAK.f RDI1MACH.f skip: iparmq does seem to compile as well.

    Will investigate ASAP. P.S. @kconnour the code being tested is Pythonic-Distort right?

  4. kconnour commented on Jun 21, 2023

    @kconnour
    Author

    Hi @HaoZeke, thanks for investigating! I'm really glad to see someone else is getting a similar error.

    Actually, the code I'm testing is on the api branch of my repo but it should be extremely similar to the code in the repo you linked. We're both apparently trying to make a front-end to a popular open-source fortran algorithm. Note that I coded a workaround to this problem in pyproject.toml, where I force it to install numpy==1.24.0 in order to circumvent this issue... so if you ran the installation script from my repo, it shouldn't encounter this error.

    I'm happy to provide any additional info to help diagnose this issue!

  5. Akahan12 commented on Jul 7, 2023

    @Akahan12

    We ran into similar issues with our code, and after testing, it's because of having a decimal inside of a parameter declaration. Once that happens, everything later stops processing properly. The same seems be happening in the examples above

    If you look at the error log posted, #24008 (comment), you'll see the first error message is the attached.

    Line #229 in LAPACK.f:"      PARAMETER (ONE=1.0D+0,ZERO=0.0D+0)"
    	get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 4
    

    You could confirm whether this also works for your code by modifying that parameter to just be ONE=1, ZERO=0, and recompiling. If it gets past that point, that's the problem.

    We worked around this by reverting crackfortran.py to prior to the changes introduced here: https://github.com/numpy/numpy/pull/23637/files

    As to speculation: I think that the changes to the if blocks in https://github.com/numpy/numpy/pull/23637/commits caused an issue that assumes the input is an integer. Even more speculative - I see the kind selector is in that portion, and the kind selector requires integers.
    (https://numpy.org/doc/stable/f2py/advanced.html#dealing-with-kind-specifiers) . But I'm not sure - I didn't spend enough time on understanding crackfortran.py once we discovered that reverting crackfortran.py fixed our problem.

  6. added 4 commits that reference this issue on Jul 31, 2023
    0ca5b9c
    7f89115
    c46a0ad
    b9347dc
  7. added 2 commits that reference this issue on Aug 24, 2023
    1940763
    a64d3cd
  8. added 2 commits that reference this issue on Aug 25, 2023
    16ad79a
    d29991d
  9. added 2 commits that reference this issue on Nov 11, 2023
    839112f
    0fa4431
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions