Skip to content

Commit

Permalink
Merge pull request #7 from chunhuazhou/Add_EnKF_build
Browse files Browse the repository at this point in the history
Changes to build EnKF for FV3reg
  • Loading branch information
chunhuazhou committed Nov 10, 2021
2 parents e3f8883 + 1dee678 commit 2c8edc5
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,38 @@ project(GSI)
option(BUILD_GLOBAL "Build GSI without WRF (regional) module " OFF)
option(BUILD_ENKF "Build the Enkf executable " ON)
option(USE_BASELINE "Use baseline control runs" ON)
SET(ENKF_MODE "GFS" CACHE STRING "EnKF build mode: GFS, WRF, NMMB")
SET(ENKF_MODE "GFS" CACHE STRING "EnKF build mode: GFS, WRF, NMMB, and FV3reg")
string(TOUPPER ${ENKF_MODE} ENKF_MODE)
if (ENKF_MODE MATCHES "^GFS$")
message("Build the EnKF with GFS module")
option(BUILD_GFS "Build the Enkf with GFS module " ON)
option(BUILD_NMMB "Build the Enkf with NMMB module " OFF)
option(BUILD_WRF "Build the Enkf with WRF module " OFF)
option(BUILD_FV3reg "Build the Enkf with FV3reg module " OFF)
elseif (ENKF_MODE MATCHES "^WRF$")
message("Build the EnKF with WRF module")
option(BUILD_GFS "Build the Enkf with GFS module " OFF)
option(BUILD_NMMB "Build the Enkf with NMMB module " OFF)
option(BUILD_WRF "Build the Enkf with WRF module " ON)
option(BUILD_FV3reg "Build the Enkf with FV3reg module " OFF)
elseif (ENKF_MODE MATCHES "^NMMB$")
message("Build the EnKF with NMMB module")
option(BUILD_GFS "Build the Enkf with GFS module " OFF)
option(BUILD_NMMB "Build the Enkf with NMMB module " ON)
option(BUILD_WRF "Build the Enkf with WRF module " OFF)
option(BUILD_FV3reg "Build the Enkf with FV3reg module " OFF)
elseif (ENKF_MODE MATCHES "^FV3REG$")
message("Build the EnKF with FV3reg module")
option(BUILD_GFS "Build the Enkf with GFS module " OFF)
option(BUILD_NMMB "Build the Enkf with NMMB module " OFF)
option(BUILD_WRF "Build the Enkf with WRF module " OFF)
option(BUILD_FV3reg "Build the Enkf with FV3reg module " ON)
else()
message("unkown ENKF_MODE: ${ENKF_MODE} !\nBuild the EnKF with GFS module by default")
option(BUILD_GFS "Build the Enkf with GFS module " ON)
option(BUILD_NMMB "Build the Enkf with NMMB module " OFF)
option(BUILD_WRF "Build the Enkf with WRF module " OFF)
option(BUILD_FV3reg "Build the Enkf with FV3reg module " OFF)
endif()
option(BUILD_UTIL "Build the Enkf utilities " OFF)

Expand Down
34 changes: 26 additions & 8 deletions ush/build.comgsi
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
# (for global: cmake -DCOMGSI=ON -DENKF_MODE=GFS path_to_GSI)
# make -j8
#

dir_root=$(pwd)
dir_root="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." &> /dev/null && pwd )"

################# Hera ####################
if [[ "`grep -i "hera" /etc/hosts | head -n1`" != "" ]] ; then
Expand Down Expand Up @@ -231,19 +230,34 @@ git status >> output.log
echo -e "\nCompiling commands:" >> output.log

BUILD_KJET=OFF
if [[ ! -z $1 ]]; then
case $1 in
ENKF_TYPE=WRF
opts[0]=$1
opts[1]=$2
for opt in ${opts[@]}; do
case $opt in
kjet|kJet|KJET|Kjet|kJET)
BUILD_KJET=ON
;;
FV3ENKF|fv3enkf|FV3enkf|FV3reg|fv3reg|fv3reg_enkf)
ENKF_TYPE=FV3reg
;;
esac
done

if [ ${ENKF_TYPE} == "FV3reg" ]; then
echo " cmake -DCOMGSI=ON -DENKF_MODE=FV3reg -DBUILD_UTIL_COM=ON .." >> output.log
else
echo " cmake -DCOMGSI=ON -DENKF_MODE=WRF -DBUILD_GSDCLOUD_ARW=ON -DBUILD_ENKF_PREPROCESS_ARW=ON -DBUILD_UTIL_COM=ON .." >> output.log
fi
echo " cmake -DCOMGSI=ON -DENKF_MODE=WRF -DBUILD_GSDCLOUD_ARW=ON -DBUILD_ENKF_PREPROCESS_ARW=ON -DBUILD_UTIL_COM=ON .." >> output.log
echo " -DBUILD_KJET=${BUILD_KJET}" >> output.log
echo " make -j8" >> output.log
cat output.log

cmake -DCOMGSI=ON -DENKF_MODE=WRF -DBUILD_GSDCLOUD_ARW=ON -DBUILD_ENKF_PREPROCESS_ARW=ON -DBUILD_UTIL_COM=ON -DBUILD_KJET=${BUILD_KJET} .. 2>&1 | tee output.cmake
if [ ${ENKF_TYPE} == "FV3reg" ]; then
cmake -DCOMGSI=ON -DENKF_MODE=FV3reg -DBUILD_UTIL_COM=ON -DBUILD_KJET=${BUILD_KJET} .. 2>&1 | tee output.cmake
else
cmake -DCOMGSI=ON -DENKF_MODE=WRF -DBUILD_GSDCLOUD_ARW=ON -DBUILD_ENKF_PREPROCESS_ARW=ON -DBUILD_UTIL_COM=ON -DBUILD_KJET=${BUILD_KJET} .. 2>&1 | tee output.cmake
fi
make -j 8 2>&1 | tee output.compile

###aftermath
Expand All @@ -253,8 +267,12 @@ repoName=${repoName//\//:}
datestamp=`date +%Y%m%d`
cd bin
ln -sf gsi.x gsi.x_${repoName}_${datestamp}_${commitID}
ln -sf enkf_wrf.x enkf_wrf.x_${repoName}_${datestamp}_${commitID}
ln -sf enspreproc.x enspreproc.x_${repoName}_${datestamp}_${commitID}
if [ ${ENKF_TYPE} == "FV3reg" ]; then
ln -sf enkf_fv3reg.x enkf_fv3reg.x_${repoName}_${datestamp}_${commitID}
else
ln -sf enkf_wrf.x enkf_wrf.x_${repoName}_${datestamp}_${commitID}
ln -sf enspreproc.x enspreproc.x_${repoName}_${datestamp}_${commitID}
fi
###mv $dir_root/build $dir_root/build_$commitID

echo -e "\n\nAll build results are at ./build/ \n\n"
Expand Down

0 comments on commit 2c8edc5

Please sign in to comment.