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

Setup for building GCClassic #67

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from
Draft
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
8 changes: 4 additions & 4 deletions .dev/config/HEMCO_Config.rc
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ VerboseOnCores: root # Accepted values: root all
--> GMI_OH : false # 2005
--> GMI_PROD_LOSS : false # 2005
--> OMOC_RATIO : false # 2010
--> GMD_SFC_CH4 : false # 1979-2020
--> CMIP6_SFC_CH4 : false # 1750-1978
--> OLSON_LANDMAP : false # 1985
--> YUAN_MODIS_LAI : false # 2000-2020
--> GMD_SFC_CH4 : true # 1979-2020
--> CMIP6_SFC_CH4 : true # 1750-1978
--> OLSON_LANDMAP : true # 1985
--> YUAN_MODIS_LAI : true # 2000-2020
--> RRTMG : false # 2002
--> SfcVMR : false # 1750-2014
--> OCEAN_O3_DRYDEP : false # 1985
Expand Down
83 changes: 62 additions & 21 deletions .dev/utils/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,23 @@
set -e

# Default values
FRESH=false
OPENMP=false
GISS_ONLY=false
CLASSIC=false
DEBUG=false
FRESH=false

# Function to display help text
show_help() {
echo "Usage: $0 [MP=YES|NO] [--openmp] [--giss-only] [-f] [--debug]"
echo "Usage: $0 [MP=YES|NO] [--openmp] [--giss-only] [--classic] [--debug] [-f]"
echo
echo "Options:"
echo " --help Show this help message and exit."
echo " --openmp Compile with OpenMP enabled."
echo " --giss-only Build without GEOS-Chem coupling."
echo " -f Fresh rebuild of the model."
echo " --classic Build without GCClassic as the driver, rather than Model E."
echo " --debug Run with debugging turned on."
echo " -f Fresh rebuild of the model."
}

# Check for --help option
Expand All @@ -39,18 +41,22 @@ for arg in "$@"; do
OPENMP=true
shift
;;
-f)
FRESH=true
shift
;;
--giss-only)
GISS_ONLY=true
shift
;;
--classic)
CLASSIC=true
shift
;;
--debug)
DEBUG=true
shift
;;
-f)
FRESH=true
shift
;;
*)
echo "Unknown argument: $arg"
show_help
Expand All @@ -60,6 +66,10 @@ for arg in "$@"; do
done

if [ "${GISS_ONLY}" = true ]; then
if [ "${CLASSIC}" = true ]; then
echo "--giss-only and --classic are mutually exclusive"
exit 1
fi
GC=NO
RUNID=GISS_ONLY
else
Expand All @@ -71,6 +81,8 @@ fi
echo "NP=${NP}"
echo "OPENMP=${OPENMP}"
echo "GC=${GC}"
echo "GISS_ONLY=${GISS_ONLY}"
echo "CLASSIC=${CLASSIC}"
echo "FRESH=${FRESH}"
echo "DEBUG=${DEBUG}"

Expand All @@ -83,33 +95,62 @@ if [ "${FRESH}" = true ]; then
fi

# Compile
if [ "${DEBUG}" = true ]; then
ln -s -f $(pwd)/${RUNID}.R $(pwd)/${RUNID}_DEBUG.R
RUNID="${RUNID}_DEBUG"
git apply ${GISS_HOME}/.dev/utils/DEBUGGING_FLAGS.patch
make -j setup RUN=${RUNID} F90=mpif90 GC=${GC} MP=${OPENMP} MPI=YES MECH=carbon \
TYPE=Debug DEBUG=YES COMPILE_WITH_TRAPS=YES TRACEBACK=YES OVERWRITE=YES
git apply -R ${GISS_HOME}/.dev/utils/DEBUGGING_FLAGS.patch
if [ "${CLASSIC}" = true ]; then
# TODO: GCCLASSIC_RUNDIR needs setting up first time?
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cd ${GCCLASSIC_RUNDIR}
BUILD_DIR=build
if [ "${DEBUG}" = true ]; then
BUILD_DIR=${BUILD_DIR}_debug
fi
if [ "${FRESH}" = true ]; then
rm -rf ${BUILD_DIR}
fi
mkdir -p ${BUILD_DIR}
cd ${BUILD_DIR}
if [ "${DEBUG}" = true ]; then
cmake ../CodeDir -DRUNDIR=.. -DCMAKE_BUILD_TYPE=Debug -DMECH=carbon
else
cmake ../CodeDir -DRUNDIR=.. -DCMAKE_BUILD_TYPE=Release -DMECH=carbon
fi
make -j10
cd -
RUNDIR=${GCCLASSIC_RUNDIR}
else
make -j setup RUN=${RUNID} F90=mpif90 GC=${GC} MP=${OPENMP} MPI=YES MECH=carbon \
TYPE=Release OVERWRITE=YES
if [ "${DEBUG}" = true ]; then
ln -s -f $(pwd)/${RUNID}.R $(pwd)/${RUNID}_DEBUG.R
RUNID="${RUNID}_DEBUG"
git apply ${GISS_HOME}/.dev/utils/DEBUGGING_FLAGS.patch
make -j setup RUN=${RUNID} F90=mpif90 GC=${GC} MP=${OPENMP} MPI=YES MECH=carbon \
TYPE=Debug DEBUG=YES COMPILE_WITH_TRAPS=YES TRACEBACK=YES OVERWRITE=YES
git apply -R ${GISS_HOME}/.dev/utils/DEBUGGING_FLAGS.patch
else
make -j setup RUN=${RUNID} F90=mpif90 GC=${GC} MP=${OPENMP} MPI=YES MECH=carbon \
TYPE=Release OVERWRITE=YES
fi
RUNDIR=${ModelE_Support}/huge_space/${RUNID}
fi

# Configuration
if [ "${GISS_ONLY}" = false ]; then
# Copy over configuration files
HUGE_SPACE=${ModelE_Support}/huge_space/${RUNID}
CONFIG=${GISS_HOME}/.dev/config
for DIR in ${GISS_HOME} ${HUGE_SPACE}; do
for DIR in ${GISS_HOME} ${RUNDIR}; do
ln -s -f ${CONFIG}/geoschem_config.yml ${DIR}/geoschem_config.yml
ln -s -f ${CONFIG}/HEMCO_Config.rc ${DIR}/HEMCO_Config.rc
ln -s -f ${CONFIG}/HEMCO_Diagn.rc ${DIR}/HEMCO_Diagn.rc
ln -s -f ${CONFIG}/HISTORY.rc ${DIR}/HISTORY.rc
ln -s -f ${CONFIG}/species_database.yml ${DIR}/species_database.yml
done
# Create output directories
mkdir -p ${HUGE_SPACE}/OutputDir
mkdir -p ${RUNDIR}/OutputDir
# Setup restarts
mkdir -p ${HUGE_SPACE}/Restarts
mkdir -p ${RUNDIR}/Restarts
ln -s -f ${GC_INPUTS}/ExtData/GEOSCHEM_RESTARTS/GC_14.3.0/GEOSChem.Restart.fullchem.20190701_0000z.nc4 \
${HUGE_SPACE}/Restarts/GEOSChem.Restart.20190701_0000z.nc4
${RUNDIR}/Restarts/GEOSChem.Restart.20190701_0000z.nc4
# Edit HEMCO_Config to say whether we are running with or without meteorology
if [ "${CLASSIC}" = true ]; then
sed -i "s/METEOROLOGY : false/METEOROLOGY : true /" ${CONFIG}/HEMCO_Config.rc
else
sed -i "s/METEOROLOGY : true /METEOROLOGY : false/" ${CONFIG}/HEMCO_Config.rc
fi
fi
45 changes: 32 additions & 13 deletions .dev/utils/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ set -e
# Default values
NP=1
GISS_ONLY=false
CLASSIC=false
DEBUG=false

# Function to display help text
Expand All @@ -20,6 +21,7 @@ show_help() {
echo "Options:"
echo " --help Show this help message and exit."
echo " --giss-only Build without GEOS-Chem coupling."
echo " --classic Build without GCClassic as the driver, rather than Model E."
echo " --debug Run with debugging turned on."
}

Expand All @@ -39,6 +41,10 @@ for arg in "$@"; do
GISS_ONLY=true
shift
;;
--classic)
CLASSIC=true
shift
;;
--debug)
DEBUG=true
shift
Expand All @@ -51,18 +57,31 @@ for arg in "$@"; do
esac
done

# Set RUNID appropriately
if [ "${GISS_ONLY}" = true ]; then
RUNID=GISS_ONLY
if [ "${CLASSIC}" = true ]; then
if [ "${NP}" != "1" ]; then
echo "GCClassic only runs in serial"
exit 1
fi
cd ${GCCLASSIC_RUNDIR}
if [ "${DEBUG}" = true ]; then
./build_debug/bin/gcclassic
else
./build/bin/gcclassic
fi
else
RUNID=GISS_GC_14
fi
if [ "${DEBUG}" = true ]; then
ln -s -f $(pwd)/${RUNID}.R $(pwd)/${RUNID}_DEBUG.R
RUNID="${RUNID}_DEBUG"
fi
# Set RUNID appropriately
if [ "${GISS_ONLY}" = true ]; then
RUNID=GISS_ONLY
else
RUNID=GISS_GC_14
fi
if [ "${DEBUG}" = true ]; then
ln -s -f $(pwd)/${RUNID}.R $(pwd)/${RUNID}_DEBUG.R
RUNID="${RUNID}_DEBUG"
fi

# Navigate to the run directory and run the model for one hour
cd ${ModelE_Support}/prod_runs/${RUNID}
./${RUNID}ln
mpiexec -np ${NP} ./${RUNID}.exe -i I -cold-restart
# Navigate to the run directory and run the model for one hour
cd ${ModelE_Support}/prod_runs/${RUNID}
./${RUNID}ln
mpiexec -np ${NP} ./${RUNID}.exe -i I -cold-restart
fi
2 changes: 2 additions & 0 deletions .dev/utils/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
export GISS_HOME=${HOME}/software/GISS-GC
# NOTE: Path may need to be edited for your system
export ModelE_Support=${HOME}/run/giss-gc
# NOTE: Path may need to be edited for your system
export GCCLASSIC_RUNDIR=${HOME}/run/gcclassic/gc_4x5_merra2_fullchem
mkdir -p ${ModelE_Support}
# Environment variables for compiler
export CC=gcc # NOTE: C compiler may need to be modified for your system
Expand Down
26 changes: 23 additions & 3 deletions .github/workflows/test_suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ jobs:
mkdir -p ${DATA}/gcclassic/ExtData/GEOSCHEM_RESTARTS/GC_14.3.0
touch ${DATA}/gcclassic/ExtData/GEOSCHEM_RESTARTS/GC_14.3.0/GEOSChem.Restart.fullchem.20190701_0000z.nc4

- name: Build GISS with GISS_ONLY rundeck
- name: Build GISS Model E without GEOS-Chem support
run: |
. /opt/spack-environment/activate.sh
# Environment variables for passing NetCDF-C and NetCDF-Fortran
Expand All @@ -130,7 +130,7 @@ jobs:
cp .dev/utils/build.sh .
./build.sh --giss-only

- name: Build GISS-GC with GISS_GC_14 rundeck
- name: Build GISS-GC with GEOS-Chem support
run: |
. /opt/spack-environment/activate.sh
# Environment variables for passing NetCDF-C paths to GEOS-Chem
Expand All @@ -152,7 +152,7 @@ jobs:
cp .dev/utils/build.sh .
./build.sh

- name: Build GISS-GC with GISS_GC_14 rundeck in debug mode
- name: Build GISS-GC with GEOS-Chem support in debug mode
run: |
. /opt/spack-environment/activate.sh
# Environment variables for passing NetCDF-C paths to GEOS-Chem
Expand All @@ -173,3 +173,23 @@ jobs:
# Build the model in debug mode
cp .dev/utils/build.sh .
./build.sh --debug

- name: Build GCClassic
run: |
. /opt/spack-environment/activate.sh
# Environment variables for passing NetCDF-C and NetCDF-Fortran
export NETCDF_HOME=$(nc-config --prefix)
export NETCDF_F_HOME=$(nf-config --prefix)
# Build the model without GEOS-Chem support
cp .dev/utils/build.sh .
./build.sh --classic

- name: Build GCClassic in debug mode
run: |
. /opt/spack-environment/activate.sh
# Environment variables for passing NetCDF-C and NetCDF-Fortran
export NETCDF_HOME=$(nc-config --prefix)
export NETCDF_F_HOME=$(nf-config --prefix)
# Build the model without GEOS-Chem support
cp .dev/utils/build.sh .
./build.sh --classic --debug
Loading