Skip to content

Commit

Permalink
Functional CMake build scripts (PR #1)
Browse files Browse the repository at this point in the history
  • Loading branch information
AGonzalezNicolas committed Jun 27, 2024
2 parents 1e9193c + 5014d75 commit 9eaa4d4
Show file tree
Hide file tree
Showing 27 changed files with 3,782 additions and 44 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
outputs/*
src/externals/mct/*/*.o
src/externals/mct/*/*.mod
src/externals/mct/*/*.a
src/externals/mct/Makefile.conf
src/externals/mct/config.h
src/externals/mct/config.log
src/externals/mct/config.status
91 changes: 91 additions & 0 deletions bootstrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/usr/bin/env bash

set -Eeo pipefail

# Clone CLM5
git clone -b release-clm5.0 https://github.com/ESCOMP/CTSM.git clm5.0
(
cd clm5.0
git checkout dc5ea974c3 # most recent commit as of 2020-03-04
./manage_externals/checkout_externals
)

# Create src dirs
CLM5_ROOT=`realpath clm5.0`
SRC_ROOT=src
mkdir $SRC_ROOT
cd $SRC_ROOT
mkdir -p externals/{gptl,mct,pio1} csm_share \
clm5 stub_comps datm mosart cesm

# GPTL
cp $CLM5_ROOT/cime/src/share/timing/* externals/gptl
echo "Imported GPTL source files"

# MCT
cp -rf $CLM5_ROOT/cime/src/externals/mct/* externals/mct
echo "Imported MCT source files"

# PIO
cp -rf $CLM5_ROOT/cime/src/externals/pio1/pio/* externals/pio1
echo "Imported PIO1 source files"

# CSM share
(
cd csm_share
mkdir esmf_wrf_timemgr mct streams util
cp -rf $CLM5_ROOT/cime/src/share/esmf_wrf_timemgr/* esmf_wrf_timemgr
cp -rf $CLM5_ROOT/cime/src/drivers/mct/shr/* mct
cp -rf $CLM5_ROOT/cime/src/share/streams/* streams
cp -rf $CLM5_ROOT/cime/src/share/util/* util
)
echo "Imported CSM share source files"

# CLM5
clm_dirs=(
main
biogeophys
biogeochem
soilbiogeochem
dyn_subgrid
init_interp
fates/main
fates/biogeophys
fates/biogeochem
fates/fire
fates/parteh
utils
cpl
)
for src_dir in ${clm_dirs[*]}; do
dest_dir=clm5/$src_dir
mkdir -p $dest_dir
cp -rf $CLM5_ROOT/src/$src_dir/* $dest_dir
done
echo "Imported CLM source files"

# Stub components
cp $CLM5_ROOT/cime/src/components/stub_comps/sglc/cpl/glc_comp_mct.F90 stub_comps
cp $CLM5_ROOT/cime/src/components/stub_comps/socn/cpl/ocn_comp_mct.F90 stub_comps
cp $CLM5_ROOT/cime/src/components/stub_comps/sesp/cpl/esp_comp_mct.F90 stub_comps
cp $CLM5_ROOT/cime/src/components/stub_comps/sice/cpl/ice_comp_mct.F90 stub_comps
cp $CLM5_ROOT/cime/src/components/stub_comps/swav/cpl/wav_comp_mct.F90 stub_comps
echo "Imported stub components source files"

# DATM
cp $CLM5_ROOT/cime/src/components/data_comps/datm/datm_shr_mod.F90 datm
cp $CLM5_ROOT/cime/src/components/data_comps/datm/datm_comp_mod.F90 datm
cp $CLM5_ROOT/cime/src/components/data_comps/datm/mct/atm_comp_mct.F90 datm
echo "Imported DATM source files"

# MOSART
cp -rf $CLM5_ROOT/components/mosart/* mosart
rm -rf mosart/cime_config
echo "Imported MOSART source files"

# CESM
cp $CLM5_ROOT/cime/src/drivers/mct/main/* cesm
echo "Imported CESM source files"

# Copy LICENSE file
cp $CLM5_ROOT/LICENSE .
40 changes: 40 additions & 0 deletions build_tools/build.juwels-centos8
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash

# ------- User-specified variables ------------
ARCH="juwels-centos8"
CLM5_TSMP_ROOT=$(git rev-parse --show-toplevel)
BUILD_FOLDER="$CLM5_TSMP_ROOT/outputs/$ARCH/build"
INSTALL_PATH="$CLM5_TSMP_ROOT/outputs/$ARCH/run"
# ---------------------------------------------

module purge
module use $OTHERSTAGES
module load Stages/2020
module load Intel
module load ParaStationMPI
module load ESMF
module load NCO
module load Perl
module load CMake
module load parallel-netcdf
module load imkl
module load NCL
module load Python
module li

echo "NetCDF_C_PATH=$EBROOTNETCDF"
echo "NetCDF_Fortran_PATH=$EBROOTNETCDFMINFORTRAN"
echo "PnetCDF_C_PATH=$EBROOTPARALLELMINNETCDF"
GENF90_PATH=$(pwd)
rm -rf $BUILD_FOLDER
cmake -S "$CLM5_TSMP_ROOT/src" \
-B "$BUILD_FOLDER" \
-DCMAKE_MODULE_PATH="$(pwd)/cmake" \
-DCMAKE_C_COMPILER=mpicc \
-DCMAKE_Fortran_COMPILER=mpifort \
-DGENF90_PATH=$GENF90_PATH \
-DNetCDF_C_PATH=$EBROOTNETCDF \
-DNetCDF_Fortran_PATH=$EBROOTNETCDFMINFORTRAN \
-DPnetCDF_PATH=$EBROOTPARALLELMINNETCDF
cmake --build "$BUILD_FOLDER" --clean-first
cmake --install "$BUILD_FOLDER"
23 changes: 23 additions & 0 deletions build_tools/build.ubuntu-20.04LTS
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

# ------- User-specified variables ------------
ARCH="ubuntu-20.04LTS"
CLM5_TSMP_ROOT=$(git rev-parse --show-toplevel)
BUILD_FOLDER="$CLM5_TSMP_ROOT/outputs/$ARCH/build"
INSTALL_PATH="$CLM5_TSMP_ROOT/outputs/$ARCH/run"
# ---------------------------------------------

NetCDF_ROOT=/opt/custom
GENF90_PATH=$(pwd)
rm -rf $BUILD_FOLDER
cmake -S "$CLM5_TSMP_ROOT/src" \
-B "$BUILD_FOLDER" \
-DCMAKE_INSTALL_PREFIX="$INSTALL_PATH" \
-DCMAKE_MODULE_PATH="$(pwd)/cmake" \
-DCMAKE_C_COMPILER=mpicc \
-DCMAKE_Fortran_COMPILER=mpifort \
-DGENF90_PATH=$GENF90_PATH \
-DNetCDF_PATH=$NetCDF_ROOT \
-DPnetCDF_PATH=$NetCDF_ROOT
cmake --build "$BUILD_FOLDER" --clean-first
cmake --install "$BUILD_FOLDER"
Loading

0 comments on commit 9eaa4d4

Please sign in to comment.