pyCRTM: f2py and libcrtm.a

Hi,
I’m trying to install pyCRTM on my linux maching. I have successfully installed CRTMv2.4.0. I’m running into a problem with the following line of code that is part of the sequence of commands executed by “python3 setup.py install”:

/home/dostalek/miniconda3/envs/pycrtm_env/bin/f2py -m pycrtm -h /home/dostalek/code/crtm/pycrtm/_skbuild/linux-x86_64-3.9/cmake-build/pycrtm.pyf /home/dostalek/code/crtm/pycrtm/pycrtm.f90 /home/dostalek/code/crtm/crtm_2.4.0/src/Build/crtm_v2.4.0-alpha/lib//libcrtm.a --overwrite-signature

Since pycrtm and pycrtm.pyf are output files, I’m assuming the problem is in pycrtm.f90 or in libcrtm.a. The file libcrtm.a is of course created by the CRTM install itself. Here’s the output of the command:

Reading fortran codes…
Reading file ‘/home/dostalek/code/crtm/pycrtm/pycrtm.f90’ (format:free)
Traceback (most recent call last):
File “/home/dostalek/miniconda3/envs/pycrtm_env/bin/f2py”, line 10, in
sys.exit(main())
File “/home/dostalek/miniconda3/envs/pycrtm_env/lib/python3.9/site-packages/numpy/f2py/f2py2e.py”, line 768, in main
run_main(sys.argv[1:])
File “/home/dostalek/miniconda3/envs/pycrtm_env/lib/python3.9/site-packages/numpy/f2py/f2py2e.py”, line 463, in run_main
postlist = callcrackfortran(files, options)
File “/home/dostalek/miniconda3/envs/pycrtm_env/lib/python3.9/site-packages/numpy/f2py/f2py2e.py”, line 347, in callcrackfortran
postlist = crackfortran.crackfortran(files)
File “/home/dostalek/miniconda3/envs/pycrtm_env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py”, line 3531, in crackfortran
readfortrancode(files, crackline)
File “/home/dostalek/miniconda3/envs/pycrtm_env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py”, line 392, in readfortrancode
l = fin.readline()
File “/home/dostalek/miniconda3/envs/pycrtm_env/lib/python3.9/fileinput.py”, line 305, in readline
line = self._readline()
File “/home/dostalek/miniconda3/envs/pycrtm_env/lib/python3.9/fileinput.py”, line 365, in _readline
self._file = self._openhook(self._filename, self._mode)
File “/home/dostalek/miniconda3/envs/pycrtm_env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py”, line 313, in openhook
encoding = charset_normalizer.from_path(filename).best().encoding
AttributeError: ‘NoneType’ object has no attribute ‘encoding’

Even though it is obvious, I will write explicitly that any help is appreciated.
Jack

I forgot to mention that I’m using gfortran.

I need to work on my forum skills-here’s some more information. The original command actually looks like this:

/home/dostalek/miniconda3/envs/pycrtm_env/bin/f2py -m pycrtm -h /home/dostalek/code/crtm/pycrtm/_skbuild/linux-x86_64-3.9/cmake-build/pycrtm.pyf /home/dostalek/code/crtm/pycrtm/pycrtm.f90 --overwrite-signature

That is, it does not include the reference to the CRTM library file libcrtm.a. If that is omitted, however, there is a complaint that it can’t find crtm_module for the routines wrap_forward and wrap_k_matrix, which are found in pycrtm.f90. When I include the reference to the library, the compilation finds crtm_module, but gives the original error I posted. Sorry for all of the addenda. I wouldn’t be surprised if there are more

Jack

I was correct, I do have another entry. It looks like f2py is having difficulty reading the file pycrtm.f90. I turned on f2py’s --verbose flag for the command shown in my previous post. I get many errors like this one:

Line #116 in /home/dostalek/code/crtm/pycrtm/pycrtm.f90:" sensor_id(1) = sensor_id_in "
crackline:4: No pattern for line

Also, in looking over the forum entries, it is not clear to me that anyone outside JCSDA has successfully install pyCRTM using CRTMv2.4.0. Can anyone confirm or deny that? We do have a version running using a debian container, but it does have some drawbacks, hence my desire to have a “pure” installation.

The ultimate problem I had was not using the crtm-bundle (GitHub - JCSDA/crtm-bundle: Bundle containing all the repositories that are needed to compile CRTM v2.4.0.) distribution. I downloaded it and after a few adjustments to my system and the changing of a few lines in the code the installation was successful.