Skip to content

Commit

Permalink
Merge branch 'master' of github.com:fabm-model/fabm into neccton
Browse files Browse the repository at this point in the history
  • Loading branch information
jornbr committed Jul 2, 2024
2 parents 50197e5 + 565dc35 commit 0b962b4
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 31 deletions.
34 changes: 32 additions & 2 deletions .github/workflows/fabm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
matrix:
version: [9, 10, 11, 12, 13]
version: [9, 10, 11, 12]
os: [ubuntu-latest]
include:
#- version: 4.8
Expand All @@ -24,6 +24,10 @@ jobs:
- version: 8
os: ubuntu-20.04
cmake_args: -DFABM_USE_CONTIGUOUS=OFF
- version: 13
os: ubuntu-24.04
- version: 14
os: ubuntu-24.04
fail-fast: false
runs-on: ${{ matrix.os }}
env:
Expand Down Expand Up @@ -234,12 +238,22 @@ jobs:
- name: Build distribution
run: python -m build
- name: Install
run: python -m pip install .
run: python -m pip install -v .
- name: Test
run: |
python -c "import pyfabm;print('pyfabm version =', getattr(pyfabm, '__version__', None))"
for f in testcases/*.yaml; do fabm_describe_model $f; done
for f in testcases/*.yaml; do fabm_complete_yaml --add_missing $f; done
- name: Install with customization via command line arguments
run: |
rm -rf build
python -m pip install -v -C--build-option=build_ext -C--build-option="--cmake-opts=-DFABM_INSTITUTES=examples" .
- name: Install with customization via setup.cfg
run: |
rm -rf build
echo "[build_ext]" > setup.cfg
echo "cmake_opts=-DFABM_INSTITUTES=examples" >> setup.cfg
python -m pip install -v .
fabm0d:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
Expand Down Expand Up @@ -283,3 +297,19 @@ jobs:
run: |
cmake-${{ matrix.cmake-version }}.0-Linux-x86_64/bin/cmake -S . -B build
cmake-${{ matrix.cmake-version }}.0-Linux-x86_64/bin/cmake --build build --target install
ninja:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
steps:
- name: Clone FABM
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Ninja
run: |
sudo apt-get update
sudo apt-get install ninja-build
- name: Build
run: |
cmake -S . -B build -G Ninja
cmake --build build --target install
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
cmake_minimum_required(VERSION 3.13)

project(fabm
VERSION 2.0.1
VERSION 2.0.2
DESCRIPTION "Framework for Aquatic Biogeochemical Models"
HOMEPAGE_URL https://fabm.net
LANGUAGES Fortran
Expand Down Expand Up @@ -55,13 +55,13 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
endif()

# Customize compiler flags
if(${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
if("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU")
add_compile_options(-ffree-line-length-none)
elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
elseif("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "Intel")
if(WIN32)
add_compile_options("$<$<CONFIG:DEBUG>:/Od>")
endif()
elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "Cray")
elseif("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "Cray")
add_compile_options(-N 1023)
endif()

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "pyfabm"
version = "2.0.1"
version = "2.0.2"
authors = [
{name = "Jorn Bruggeman", email = "jorn@bolding-bruggeman.com"},
{name = "Karsten Bolding", email = "karsten@bolding-bruggeman.com"}
Expand Down
13 changes: 9 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ set(DEFAULT_INSTITUTES
msi # Marine Systems Institute, Tallinn University of Technology, Estonia
nersc # Nansen Environmental and Remote Sensing Center
niva # Norwegian Institute for Water Research, Norway
ogs # National Institute of Oceanography and Applied Geophysics - OGS, Italy
pclake # The PCLake model - reference implementation
pisces # Pelagic Interactions Scheme for Carbon and Ecosystem Studies, https://doi.org/10.5194/gmd-8-2465-2015
pml # Plymouth Marine Laboratory, United Kingdom
Expand All @@ -24,7 +25,7 @@ set(DEFAULT_INSTITUTES
uhh # University of Hamburg, Germany
)

set(OPTIONAL_INSTITUTES ersem mops pclake pisces ihamocc)
set(OPTIONAL_INSTITUTES ersem mops pclake pisces ihamocc ogs)

if(CMAKE_CURRENT_LIST_DIR STREQUAL CMAKE_SOURCE_DIR)
message(FATAL_ERROR "Please point cmake to the top-level directory with FABM source code, not to its src subdirectory.")
Expand Down Expand Up @@ -86,19 +87,23 @@ endforeach(institute)
configure_file(${CMAKE_CURRENT_LIST_DIR}/fabm_library.F90.in
${CMAKE_CURRENT_BINARY_DIR}/fabm_library.F90)

set(GIT_COMMIT_ID unknown)
set(GIT_BRANCH_NAME unknown)
configure_file(${CMAKE_CURRENT_LIST_DIR}/fabm_version.F90.in ${CMAKE_CURRENT_BINARY_DIR}/fabm_version.F90)
if(FABM_EMBED_VERSION)
# Use git to get description of current FABM tag/commit id and branch
set(GET_GIT_INFO_SCRIPT "${CMAKE_CURRENT_LIST_DIR}/cmake/Modules/GetGitInfo.cmake")
add_custom_target(fabm_version
${CMAKE_COMMAND} -DINFILE=${CMAKE_CURRENT_LIST_DIR}/fabm_version.F90.in -DOUTFILE=${CMAKE_CURRENT_BINARY_DIR}/fabm_version.F90 -P ${GET_GIT_INFO_SCRIPT}
BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/fabm_version.F90
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
COMMENT "Retrieving description of last FABM commit..."
SOURCES ${CMAKE_CURRENT_LIST_DIR}/fabm_version.F90.in ${GET_GIT_INFO_SCRIPT}
VERBATIM
)
set_property(TARGET fabm_version PROPERTY FOLDER fabm)
else()
# Insert dummy current FABM tag/commit id and branch
set(GIT_COMMIT_ID unknown)
set(GIT_BRANCH_NAME unknown)
configure_file(${CMAKE_CURRENT_LIST_DIR}/fabm_version.F90.in ${CMAKE_CURRENT_BINARY_DIR}/fabm_version.F90)
endif()

configure_file(${CMAKE_CURRENT_LIST_DIR}/fabm_parameters.F90.in ${CMAKE_CURRENT_BINARY_DIR}/fabm_parameters.F90)
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/0d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ find_path(GOTM_BASE
option(FABM_USE_NetCDF "Enable NetCDF output" ON)

# Specify additional compiler flags
if(${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
if("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU")
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-line-length-none")
elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
elseif("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "Intel")
if(WIN32)
set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} /Od")
endif()
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set(BUILD_SHARED_LIBS ON)
project(python_fabm Fortran)

# Customize compiler flags
if(${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
if("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "Intel")
if(WIN32)
set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} /Od")
else()
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/python/build_cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self, name, *cmake_args):

class CMakeBuild(build_ext):
user_options = build_ext.user_options + [
("cmake_opts=", None, "additional options to pass to cmake"),
("cmake-opts=", None, "additional options to pass to cmake"),
]

def run(self):
Expand Down
2 changes: 1 addition & 1 deletion src/models/nersc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ add_library(fabm_models_nersc OBJECT
ecosmo/ecosmo_operational.F90
)

add_dependencies(fabm_models_nersc fabm_base)
target_link_libraries(fabm_models_nersc PRIVATE fabm_base)

#-----------------------------------------------------------------------
# Copyright (C) 2014 - Karsten Bolding and Jorn Bruggeman (BB) !
Expand Down
27 changes: 12 additions & 15 deletions src/pyfabm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,8 @@ def value(self):
shape = self.model.interior_domain_shape
else:
shape = self.model.horizontal_domain.shape
return np.ctypeslib.as_array(pdata, shape).newbyteorder("=")
arr = np.ctypeslib.as_array(pdata, shape)
return arr.view(dtype=self.model.fabm.numpy_dtype)


class NamedObjectList(Sequence):
Expand Down Expand Up @@ -1575,22 +1576,18 @@ def process_dependencies(dependencies):
return False
for i, variable in enumerate(self.interior_diagnostic_variables):
pdata = self.fabm.get_interior_diagnostic_data(self.pmodel, i + 1)
variable.data = (
None
if not pdata
else np.ctypeslib.as_array(
pdata, self.interior_domain_shape
).newbyteorder("=")
)
if pdata:
arr = np.ctypeslib.as_array(pdata, self.interior_domain_shape)
variable.data = arr.view(dtype=self.fabm.numpy_dtype)
else:
variable.data = None
for i, variable in enumerate(self.horizontal_diagnostic_variables):
pdata = self.fabm.get_horizontal_diagnostic_data(self.pmodel, i + 1)
variable.data = (
None
if not pdata
else np.ctypeslib.as_array(
pdata, self.horizontal_domain_shape
).newbyteorder("=")
)
if pdata:
arr = np.ctypeslib.as_array(pdata, self.horizontal_domain_shape)
variable.data = arr.view(dtype=self.fabm.numpy_dtype)
else:
variable.data = None
return ready

checkReady = start
Expand Down

0 comments on commit 0b962b4

Please sign in to comment.