I encountered an issue in Grid_tools.py related to importing the toolsf module.
Problem
The following import statement throws an error:
import Modules.toolsf as toolsf
Workaround / Observation
However, replacing it with:
import Modules.tools_fort_routines as toolsf
works correctly.
This seems to be because the actual folder/module name is:
Modules/tools_fort_routines
and not toolsf.
Code Context
Below is the relevant portion of the script:
#!/usr/bin/env python3
# -- coding: utf-8 --
import numpy as np
import xarray as xr
import Modules.readers as readers
# import Modules.toolsf as toolsf # ❌ This fails
import Modules.tools_fort_routines as toolsf # ✅ This works
import scipy.interpolate as itp
import regionmask
import geopandas as gp
import pandas as pd
from itertools import product
import sys
from Modules.crocogrid import CrocoGrid
from Modules.easygrid import EasyGrid, Inputs_curv, Inputs_rect, InputsAGRIF
import glob
import os
Suggestion
It looks like:
Either the import statement is outdated (toolsf no longer exists),
Or a symbolic alias / backward compatibility is missing
On our side, the grid_tools.py file has been tested with the import:
import Modules.toolsf as toolsf
and we are not able to reproduce the issue you are encountering.
Since your workaround using:
import Modules.tools_fort_routines as toolsf
works, it suggests that the Python interface to the Fortran routines may not have been built or exposed under the expected module name (toolsf ).
Could this be related to a compilation step with f2py ? In particular, if the Fortran sources were not compiled (or not installed in the expected location), the toolsf module might be missing, while the raw Python package (tools_fort_routines ) remains accessible.
You might want to check:
whether the f2py compilation step completed successfully
Thank you for your response and for looking into this.
I appreciate your suggestion regarding the possible issue with the f2py compilation. I will check whether the compilation step completed successfully and verify if the toolsf The module has been properly generated and installed in the environment.
Since the workaround Modules.tools_fort_routines It is currently functioning, I agree that it likely indicates the compiled module is not available or properly exposed.
I will follow the installation steps again (as per Section 2.2 of the documentation) and update you if the issue persists after these checks.