Skip to content

Commit 0fc85a9

Browse files
authored
Merge pull request #443 from GEOS-ESM/develop
2 parents efdbd1c + f0976f8 commit 0fc85a9

File tree

5 files changed

+242
-4
lines changed

5 files changed

+242
-4
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717

1818
### Deprecated
1919

20+
## [4.15.0] - 2025-04-24
21+
22+
### Changed
23+
24+
- Added a timeout to `mepo status` to prevent it from hanging indefinitely. The timeout is set to 60 seconds
25+
- Modified the f2py and f2py3 codes for meson+MPT support
26+
- It was found that when an f2py code uses MPI, with meson+MPT we need to run with `LD_PRELOAD=/path/to/mpt/libmpi.so`
27+
28+
2029
## [4.14.2] - 2025-04-22
2130

2231
### Fixed

esma_support/esma_mepo_status.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ function(esma_capture_mepo_status)
2121
OUTPUT_FILE "${OUTPUT_FILE}"
2222
RESULT_VARIABLE MEPO_STATUS_RESULT
2323
ERROR_QUIET
24+
TIMEOUT 60
2425
)
2526

2627
if(NOT MEPO_STATUS_RESULT EQUAL 0)

python/.gitignore

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# UV
98+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
#uv.lock
102+
103+
# poetry
104+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105+
# This is especially recommended for binary packages to ensure reproducibility, and is more
106+
# commonly ignored for libraries.
107+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108+
#poetry.lock
109+
110+
# pdm
111+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112+
#pdm.lock
113+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114+
# in version control.
115+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116+
.pdm.toml
117+
.pdm-python
118+
.pdm-build/
119+
120+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121+
__pypackages__/
122+
123+
# Celery stuff
124+
celerybeat-schedule
125+
celerybeat.pid
126+
127+
# SageMath parsed files
128+
*.sage.py
129+
130+
# Environments
131+
.env
132+
.venv
133+
env/
134+
venv/
135+
ENV/
136+
env.bak/
137+
venv.bak/
138+
139+
# Spyder project settings
140+
.spyderproject
141+
.spyproject
142+
143+
# Rope project settings
144+
.ropeproject
145+
146+
# mkdocs documentation
147+
/site
148+
149+
# mypy
150+
.mypy_cache/
151+
.dmypy.json
152+
dmypy.json
153+
154+
# Pyre type checker
155+
.pyre/
156+
157+
# pytype static type analyzer
158+
.pytype/
159+
160+
# Cython debug symbols
161+
cython_debug/
162+
163+
# PyCharm
164+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166+
# and can be added to the global gitignore or merged into this file. For a more nuclear
167+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
168+
#.idea/
169+
170+
# Ruff stuff:
171+
.ruff_cache/
172+
173+
# PyPI configuration file
174+
.pypirc

python/f2py/esma_add_f2py_module.cmake

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,45 @@ macro (esma_add_f2py_module name)
22

33
add_f2py_module (${name} ${ARGN})
44

5+
set(options USE_MPI)
6+
cmake_parse_arguments (esma_add_f2py_module "${options}" "" "" ${ARGN})
7+
8+
# If one of the arguments is USE_MPI we need to
9+
# do something special on MPT systems.
10+
# First this only matters if we are on Python 3.12 or higher
11+
if (Python_VERSION VERSION_GREATER_EQUAL 3.12)
12+
message(DEBUG "[F2PY]: Python version is 3.12 or higher, so meson is our backend")
13+
message(DEBUG "[F2PY]: MPI_STACK: ${MPI_STACK}")
14+
# Next, check if we are using MPI and our stack is 'mpt'
15+
message(DEBUG "[F2PY]: Checking for USE_MPI and MPI_STACK=mpt")
16+
if(esma_add_f2py_module_USE_MPI AND MPI_STACK STREQUAL "mpt")
17+
message(DEBUG "[F2PY]: MPI_Fortran_LIBRARIES: ${MPI_Fortran_LIBRARIES}")
18+
# Now we need LD_PRELOAD the libmpi.so found in MPI_Fortran_LIBRARIES
19+
# But MPI_Fortran_LIBRARIES is a list, so we need to find the one
20+
# that ends with 'libmpi.so'
21+
foreach (mpi_lib ${MPI_Fortran_LIBRARIES})
22+
if (mpi_lib MATCHES "libmpi.so$")
23+
message(DEBUG "[F2PY]: Found libmpi.so: ${mpi_lib}")
24+
set(F2PY_PRELOAD "LD_PRELOAD=${mpi_lib}")
25+
message(STATUS "[F2PY3]: USE_MPI found and using MPT. Testing will add ${F2PY_PRELOAD}")
26+
break()
27+
endif()
28+
endforeach()
29+
endif()
30+
endif()
31+
532
set(UNIT_TEST test_${name})
633
add_test (
734
NAME ${UNIT_TEST}
8-
COMMAND ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH}" ${Python_EXECUTABLE} -c "import ${name}"
35+
COMMAND ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH}" "${F2PY_PRELOAD}" ${Python_EXECUTABLE} -c "import ${name}"
936
)
1037

1138
add_custom_command(
1239
TARGET ${name}
1340
COMMENT "Running Python import test on ${name}"
1441
POST_BUILD
1542
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
16-
COMMAND ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH}" ${Python_EXECUTABLE} -c "import ${name}"
43+
COMMAND ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH}" "${F2PY_PRELOAD}" ${Python_EXECUTABLE} -c "import ${name}"
1744
)
1845

1946
endmacro ()

python/f2py3/esma_add_f2py3_module.cmake

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,45 @@ macro (esma_add_f2py3_module name)
22

33
add_f2py3_module (${name} ${ARGN})
44

5+
set(options USE_MPI)
6+
cmake_parse_arguments (esma_add_f2py3_module "${options}" "" "" ${ARGN})
7+
8+
# If one of the arguments is USE_MPI we need to
9+
# do something special on MPT systems.
10+
# First this only matters if we are on Python 3.12 or higher
11+
if (Python3_VERSION VERSION_GREATER_EQUAL 3.12)
12+
message(DEBUG "[F2PY3]: Python version is 3.12 or higher, so meson is our backend")
13+
message(DEBUG "[F2PY3]: MPI_STACK: ${MPI_STACK}")
14+
# Next, check if we are using MPI and our stack is 'mpt'
15+
message(DEBUG "[F2PY3]: Checking for USE_MPI and MPI_STACK=mpt")
16+
if(esma_add_f2py3_module_USE_MPI AND MPI_STACK STREQUAL "mpt")
17+
message(DEBUG "[F2PY3]: MPI_Fortran_LIBRARIES: ${MPI_Fortran_LIBRARIES}")
18+
# Now we need LD_PRELOAD the libmpi.so found in MPI_Fortran_LIBRARIES
19+
# But MPI_Fortran_LIBRARIES is a list, so we need to find the one
20+
# that ends with 'libmpi.so'
21+
foreach (mpi_lib ${MPI_Fortran_LIBRARIES})
22+
if (mpi_lib MATCHES "libmpi.so$")
23+
message(DEBUG "[F2PY3]: Found libmpi.so: ${mpi_lib}")
24+
set(F2PY3_PRELOAD "LD_PRELOAD=${mpi_lib}")
25+
message(STATUS "[F2PY3]: USE_MPI found and using MPT. Testing will add ${F2PY3_PRELOAD}")
26+
break()
27+
endif()
28+
endforeach()
29+
endif()
30+
endif()
31+
532
set(UNIT_TEST test_${name})
633
add_test (
734
NAME ${UNIT_TEST}
8-
COMMAND ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH}" ${Python3_EXECUTABLE} -c "import ${name}"
35+
COMMAND ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH}" "${F2PY3_PRELOAD}" ${Python3_EXECUTABLE} -c "import ${name}"
936
)
1037

1138
add_custom_command(
1239
TARGET ${name}
1340
COMMENT "Running Python3 import test on ${name}"
1441
POST_BUILD
1542
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
16-
COMMAND ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH}" ${Python3_EXECUTABLE} -c "import ${name}"
43+
COMMAND ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH}" "${F2PY3_PRELOAD}" ${Python3_EXECUTABLE} -c "import ${name}"
1744
)
1845

1946
endmacro ()

0 commit comments

Comments
 (0)