Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move from ESMA_cmake to f2py-cmake #19

Open
mathomp4 opened this issue Dec 17, 2024 · 3 comments
Open

Move from ESMA_cmake to f2py-cmake #19

mathomp4 opened this issue Dec 17, 2024 · 3 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@mathomp4
Copy link
Member

mathomp4 commented Dec 17, 2024

Per @amdasilva, QFED (and GMAOpyobs) are pure Python compare to a lot of GEOS-ESM packages. As such, they really have no need for ESMA_cmake or ecbuild, say. However, they do use f2py a lot and our f2py CMake code is in ESMA_cmake.

But, @amdasilva pointed me to f2py-cmake by @henryiii.

I have a first rough version of the transition in the feature/mathomp4/plume-no-esma branch (which is based off of feature/#17/adasilva/plume_rise)

ETA: NOTE: The f2py-cmake code in my branch is a modified version of the stock code, see scikit-build/f2py-cmake#21 where we have some fixes to allow it to be run more than once.

@mathomp4 mathomp4 added bug Something isn't working enhancement New feature or request labels Dec 17, 2024
@mathomp4 mathomp4 self-assigned this Dec 17, 2024
@mathomp4
Copy link
Member Author

As noted by @amdasilva when he tested this, this does build but it doesn't run.

For example:

> python3 -c 'import FreitasPlume_'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: /gpfsm/dswdev/mathomp4/Models/QFED-Arlindo-f2pycmake/install/lib/Python/plumerise/FreitasPlume_.cpython-311-x86_64-linux-gnu.so: undefined symbol: plume_

and the same for LockePlume_:

> python3 -c 'import LockePlume_'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: /gpfsm/dswdev/mathomp4/Models/QFED-Arlindo-f2pycmake/install/lib/Python/plumerise/LockePlume_.cpython-311-x86_64-linux-gnu.so: undefined symbol: plumeg_

@mathomp4
Copy link
Member Author

I thought I had one fix which is that UseF2Py.cmake does not realize that our .F90 files are Fortran 90. The code has:

    foreach(file IN LISTS ALL_FILES)
        if("${file}" MATCHES "\\.f90$")
            set(HAS_F90_FILE TRUE)
            break()
        endif()
    endforeach()

this is simple enough to fix by adding a:

        if("${file}" MATCHES "\\.F90$")
            set(HAS_F90_FILE TRUE)
            break()
        endif()

in there.

But this doesn't seem to do much.

@mathomp4
Copy link
Member Author

One more thing I notice is that the f2pywrapper files are empty:

> \ls -l *wrap*
-rw-r--r-- 1 mathomp4 g0620 0 Dec 17 09:14 FreitasPlume_-f2pywrappers.f
-rw-r--r-- 1 mathomp4 g0620 0 Dec 17 09:14 FreitasPlume_-f2pywrappers2.f90
-rw-r--r-- 1 mathomp4 g0620 0 Dec 17 09:14 LockePlume_-f2pywrappers.f
-rw-r--r-- 1 mathomp4 g0620 0 Dec 17 09:14 LockePlume_-f2pywrappers2.f90

So it's almost like the code isn't actually doing what I think it should. My call sequence is pretty boring:

# Library: plumerise
# ------------------
add_library (plumerise
  LockePlume_Mod.F90
  rconstants.F90
  FreitasPlume_Mod.F90
  qsat_Mod.F90
)
install(TARGETS plumerise DESTINATION lib/Python/plumerise)

# Module: FreitasPlume
# --------------------
f2py_object_library(FreitasPlume_object OBJECT)
f2py_generate_module(FreitasPlume_ FreitasPlume_py.F90 OUTPUT_VARIABLE FreitasPlume_files)
python_add_library(FreitasPlume_ MODULE "${FreitasPlume_files}" WITH_SOABI)
target_link_libraries(FreitasPlume_ PRIVATE Python::NumPy)
target_link_libraries(FreitasPlume_ PRIVATE FreitasPlume_object)
target_link_libraries(FreitasPlume_ PRIVATE plumerise)
target_link_libraries(FreitasPlume_ PRIVATE OpenMP::OpenMP_Fortran)
install(TARGETS FreitasPlume_ DESTINATION lib/Python/plumerise)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant