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

Merged changes from master (2023.11.24-2024.03.22) #30

Merged
merged 4 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 136 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
name: CI

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [ main, master, ubuntu2204]
pull_request:
branches: [ main, master, ubuntu2204]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
env:
CC: mpicc
FC: mpifort
CXX: mpicxx
CPPFLAGS: "-I/usr/include -I/usr/local/include"
CIME_TEST_PLATFORM: ubuntu-latest
# Versions of all dependencies can be updated here
PNETCDF_VERSION: pnetcdf-1.12.3
NETCDF_FORTRAN_VERSION: v4.6.0
MCT_VERSION: MCT_2.11.0
PARALLELIO_VERSION: pio2_5_10
NETCDF_C_PATH: /usr
NETCDF_FORTRAN_PATH: ${HOME}/netcdf-fortran
PNETCDF_PATH: ${HOME}/pnetcdf
CIME_MODEL: cesm
CIME_DRIVER: mct

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it

- id: load-env
run: |
sudo apt-get update
sudo apt-get install libxml2-utils pylint wget gfortran openmpi-bin netcdf-bin libopenmpi-dev cmake libnetcdf-dev

# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v4
# with:
# python-version: ${{ matrix.python-version }}
# cache: 'pip'

# - name: pip install
# run: pip install PyYAML

- name: cache pnetcdf
id: cache-pnetcdf
uses: actions/cache@v3
with:
path: ~/pnetcdf
key: ${{ runner.os }}-${{ env.PNETCDF_VERSION}}-pnetcdf-redo

- name: pnetcdf build
if: steps.cache-pnetcdf.outputs.cache-hit != 'true'
run: |
wget https://parallel-netcdf.github.io/Release/${{ env.PNETCDF_VERSION }}.tar.gz
tar -xzvf ${{ env.PNETCDF_VERSION }}.tar.gz
ls -l
pushd ${{ env.PNETCDF_VERSION }}
./configure --prefix=$HOME/pnetcdf --enable-shared --disable-cxx
make
make install
popd

- name: Cache netcdf-fortran
id: cache-netcdf-fortran
uses: actions/cache@v3
with:
path: ~/netcdf-fortran
key: ${{ runner.os }}-${{ env.NETCDF_FORTRAN_VERSION }}-netcdf-fortran-redo

- name: netcdf fortran build
if: steps.cache-netcdf-fortran.outputs.cache-hit != 'true'
run: |
wget https://github.com/Unidata/netcdf-fortran/archive/${{ env.NETCDF_FORTRAN_VERSION }}.tar.gz
tar -xzvf ${{ env.NETCDF_FORTRAN_VERSION }}.tar.gz
ls -l
pushd netcdf-fortran-*
./configure --prefix=$HOME/netcdf-fortran
make
make install

- name: link netcdf-c to netcdf-fortran path
# link netcdf c library here to simplify build
run: |
pushd ${{ env.NETCDF_FORTRAN_PATH }}/include
ln -fs /usr/include/*netcdf* .
pushd ${{ env.NETCDF_FORTRAN_PATH }}/lib
clibdir=`nc-config --libdir`
ln -fs $clibdir/lib* .

sudo ln -s $HOME/pnetcdf/lib/pkgconfig/pnetcdf.pc /usr/lib/pkgconfig
sudo ln -s $HOME/netcdf-fortran/lib/pkgconfig/netcdf-fortran.pc /usr/lib/pkgconfig

# The following can be used to ssh to the testnode for debugging
# see https://github.com/mxschmitt/action-tmate for details
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
- uses: actions/checkout@v4
- name: build eCLM
run: |
# User-specific variables
ls -al
BUILD_DIR="bld"
INSTALL_DIR="eclm"

# Run cmake
cmake -S src -B "$BUILD_DIR" \
-DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" \
-DCMAKE_C_COMPILER=mpicc \
-DCMAKE_Fortran_FLAGS="-fallow-argument-mismatch -fallow-invalid-boz" \
-DCMAKE_Fortran_COMPILER=mpifort

cd bld
make -j${nproc}

ls -al
ls -al eclm
# - name: Cache inputdata
# if: ${{ ! env.ACT }}
# uses: actions/cache@v3
# with:
# path: $HOME/cesm/inputdata
# key: inputdata

# the following can be used by developers to login to the github server in case of errors
# see https://github.com/marketplace/actions/debugging-with-tmate for further details
# - name: Setup tmate session
# if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ src/externals/mct/config.log
src/externals/mct/config.status

# Python byte-compiled / optimized / DLL files
*.py[cod]
*.py[cod]
build
bld
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# eCLM

[![CI](https://github.com/HPSCTerrSys/eCLM/actions/workflows/CI.yml/badge.svg)](https://github.com/HPSCTerrSys/eCLM/actions/workflows/CI.yml)
[![status: alpha](https://img.shields.io/badge/status-alpha-yellow)](https://github.com/HPSCTerrSys/eCLM)

eCLM is based from [Community Land Model 5.0 (CLM5.0)]. It has the same modelling capabilities as CLM5 but with a more simplified infrastructure for build and namelist generation. The build system is handled entirely by CMake and namelists are generated through a small set of Python scripts. Only Fortran source codes necessary for a functional land model simulation were imported from CLM5.
Expand Down
3 changes: 2 additions & 1 deletion cmake/SetBuildOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ endif()

# Set compiler specific flags.
if(COMPILER STREQUAL "GNU")
add_compile_options(-fallow-argument-mismatch)
add_compile_definitions(CPRGNU)
set(CMAKE_C_FLAGS "-std=gnu99 -fopenmp")
set(CMAKE_C_FLAGS_DEBUG "-fcheck=bounds")
Expand All @@ -44,4 +45,4 @@ endif()
message(STATUS " ******* ${CMAKE_PROJECT_NAME} build options ******* ")
message(STATUS " Build type = '${CMAKE_BUILD_TYPE}'")
message(STATUS " Compiler = '${COMPILER}'")
message(STATUS " ********************************** ")
message(STATUS " ********************************** ")
19 changes: 18 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
cmake_minimum_required (VERSION 3.16.3)
project (eCLM LANGUAGES C Fortran)


get_filename_component(ECLM_ROOT ${CMAKE_SOURCE_DIR} DIRECTORY)
list(APPEND CMAKE_MODULE_PATH "${ECLM_ROOT}/cmake")
set(GENF90 ${CMAKE_MODULE_PATH}/genf90.pl)

include(SetBuildOptions)

if (USE_PDAF)
set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/eCLM)
set(CMAKE_Fortran_MODULE_DIRECTORY_MCT ${CMAKE_BINARY_DIR}/externals/mct/include)
set(CMAKE_Fortran_MODULE_DIRECTORY_GPTL ${CMAKE_BINARY_DIR}/externals/gptl/include)
endif()

add_subdirectory(externals)
add_subdirectory(csm_share)
add_subdirectory(clm5)
Expand All @@ -24,4 +32,13 @@ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
endif("${isSystemDir}" STREQUAL "-1")
endif("${isSystemDir}" STREQUAL "-1")

if (USE_PDAF)
install(DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}
DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
install(DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY_MCT}
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/eCLM/externals/mct)
install(DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY_GPTL}
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/eCLM/externals/gptl)
endif()
2 changes: 1 addition & 1 deletion src/clm5/biogeochem/FireEmisFactorsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ integer function gen_hashkey(string)
integer :: i
integer :: strlen
integer, parameter :: tbl_max_idx = 15 ! 2**N - 1
integer, parameter :: gen_hash_key_offset = z'000053db'
integer, parameter :: gen_hash_key_offset = INT(z'000053db', KIND=4)
integer, dimension(0:tbl_max_idx) :: tbl_gen_hash_key = (/61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1/)

hash = gen_hash_key_offset
Expand Down
2 changes: 1 addition & 1 deletion src/clm5/biogeochem/MEGANFactorsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ integer function gen_hashkey(string)
integer :: i

integer, parameter :: tbl_max_idx = 15 ! 2**N - 1
integer, parameter :: gen_hash_key_offset = z'000053db'
integer, parameter :: gen_hash_key_offset = INT(z'000053db', KIND=4)
integer, dimension(0:tbl_max_idx) :: tbl_gen_hash_key = (/61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1/)

hash = gen_hash_key_offset
Expand Down
21 changes: 13 additions & 8 deletions src/clm5/oasis3/oas_defineMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module oas_defineMod

subroutine oas_definitions_init(bounds)
use spmdMod , only : masterproc
use domainMod , only : ldomain
use clm_varpar , only : nlevsoi, nlevgrnd
use decompMod , only : ldecomp, bounds_type
use oas_vardefMod
Expand All @@ -30,15 +31,17 @@ subroutine oas_definitions_init(bounds)
integer :: var_nodims(2) ! var dimension parameters


if (masterproc) then
call define_grid()
end if

! TODO: Fix grids.nc and masks.nc generation for 1D grid representation
!if (masterproc) then
! call define_grid()
!end if

! -----------------------------------------------------------------
! ... Define partition
! -----------------------------------------------------------------
allocate(partition(200))
! partition length = (# elements for partition info) + (max segments ORANGE partition) x (# elements per segment info)
! = 2 + 200*2 = 402
allocate(partition(402))
partition(:) = 0; k = 0

! Use ORANGE partitioning scheme. This scheme defines an ensemble
Expand All @@ -58,18 +61,18 @@ subroutine oas_definitions_init(bounds)
partition(3+k) = gcell_start - 1 ! segment global offset (0-based)
partition(4+k) = gcell_previous - gcell_start + 1 ! segment length
k = k + 2

gcell_start = ldecomp%gdc2glo(g) ! current gridcell marks the start of a new segment
partition(2) = partition(2) + 1 ! increment number of segments
partition(2) = partition(2) + 1 ! increment number of segments (limited to 200 based from OASIS3-MCT User's guide)
end if
gcell_previous = ldecomp%gdc2glo(g)
enddo

! Define partition params for last segment
partition(3+k) = gcell_start - 1
partition(4+k) = gcell_previous - gcell_start + 1
partition(2) = partition(2) + 1

call oasis_def_partition(grid_id, partition, ierror)
call oasis_def_partition(grid_id, partition, ierror, ldomain%ns)
deallocate(partition)

! -----------------------------------------------------------------
Expand Down Expand Up @@ -143,6 +146,7 @@ end subroutine oas_definitions_init
subroutine define_grid()
use shr_kind_mod , only : r8 => shr_kind_r8
use domainMod , only : ldomain

character(len=4), parameter :: grid_name='gclm'
integer, parameter :: SOUTH = 1
integer, parameter :: NORTH = 2
Expand Down Expand Up @@ -244,5 +248,6 @@ subroutine define_grid()
call oasis_terminate_grids_writing()
deallocate(oas_lon, oas_lat, oas_corner_lon, oas_corner_lat, oas_mask, corner_lon, corner_lat)
end if

end subroutine define_grid
end module oas_defineMod
5 changes: 5 additions & 0 deletions src/csm_share/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,9 @@ if (USE_OASIS)
endif()
endif()
endif()

if (USE_PDAF)
target_compile_definitions(${PROJECT_NAME} PUBLIC USE_PDAF)
endif()

install (TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
Loading
Loading