From 59bc260aba2a55d1d4fd36bd7ba04d5431ad2085 Mon Sep 17 00:00:00 2001 From: Kyle Gerheiser <3209794+kgerheiser@users.noreply.github.com> Date: Fri, 9 Oct 2020 00:15:23 -0400 Subject: [PATCH] Add CMake build for public release (#27) - Adds a CMake build using ExternalProject_Add. - Makes modifications to build_all.sh and install_all.sh for back-compatibility with old build system. The old build system will remain in, but is now deprecated, and will be removed in the coming weeks. To build, have the necessary modules loaded and run: ``` mkdir build cd build cmake .. -DCMAKE_INSTALL_PREFIX= make ``` The docs/ directory contains README files with instructions for specific platforms/compilers - **Cheyenne**: Build and end-to-end test ("DOT_OR_USCORE" test case) was successful on Cheyenne with intel, both for the cmake build and the old build script (that will soon be deprecated). Path to tests: /glade/scratch/kavulich/UFS_CAM/testing/SRW_PR_27/expt_dirs/ - **Hera**: Build and end-to-end tests successful (aside from expected failures). Path to tests: /scratch2/BMC/det/kavulich/workdir/SRW_PR_27/expt_dirs - **Jet**: Build test was successful. Resolves #7, partially resolves #5 Co-authored-by: kgerheiser ; Michael Kavulich, Jr --- CMakeLists.txt | 5 +++- Externals.cfg | 8 ++--- docs/README_cheyenne_intel.txt | 50 +++++++++++++++++++++++++++++++ docs/README_hera_intel.txt | 50 +++++++++++++++++++++++++++++++ docs/README_jet_intel.txt | 54 ++++++++++++++++++++++++++++++++++ src/CMakeLists.txt | 31 +++++++++++++++++++ src/build_all.sh | 8 ++--- src/install_all.sh | 34 ++++++++++----------- 8 files changed, 212 insertions(+), 28 deletions(-) create mode 100644 docs/README_cheyenne_intel.txt create mode 100644 docs/README_hera_intel.txt create mode 100644 docs/README_jet_intel.txt create mode 100644 src/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e8457ce10..366e0e9d9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,9 @@ if (${CMAKE_VERSION} VERSION_LESS 3.12) endif() # Set the project name and version. -project(ufs-srweather-app VERSION 1.0) +project(ufs-srweather-app VERSION 1.0 LANGUAGES C CXX Fortran) + +find_package(MPI REQUIRED COMPONENTS C CXX Fortran) # Set extended version info. SET(SRWA_VERSION_MAJOR 1) @@ -139,3 +141,4 @@ configure_file( FILE(COPY "${CMAKE_CURRENT_BINARY_DIR}/ufs_srweather_app_meta.h" DESTINATION include) +add_subdirectory(src) diff --git a/Externals.cfg b/Externals.cfg index 88807bb364..655813a3e2 100644 --- a/Externals.cfg +++ b/Externals.cfg @@ -8,12 +8,8 @@ required = True [ufs_utils] protocol = git -#repo_url = https://github.com/JeffBeck-NOAA/UFS_UTILS -repo_url = https://github.com/NCAR/UFS_UTILS -# Specify either a branch name or a hash but not both. -#branch = feature/regional_release -branch = feature/regional_release_STRING -#hash = e5419633 +repo_url = https://github.com/JeffBeck-NOAA/UFS_UTILS +tag = v2.0alpha01 local_path = src/UFS_UTILS required = True diff --git a/docs/README_cheyenne_intel.txt b/docs/README_cheyenne_intel.txt new file mode 100644 index 0000000000..cdd8ab0c84 --- /dev/null +++ b/docs/README_cheyenne_intel.txt @@ -0,0 +1,50 @@ +#Setup instructions for CISL Cheyenne using Intel-19.1.1 (bash shell) + +module purge +module load ncarenv/1.3 +module load intel/19.1.1 +module load mpt/2.19 +module load ncarcompilers/0.5.0 +module load cmake/3.16.4 + +export CC=mpicc +export FC=mpif90 +export CXX=mpicxx + +NCEPLIBS_INSTALL=/glade/p/ral/jntp/GMTB/tools/NCEPLIBS-ufs-v2.0.0/intel-19.1.1/mpt-2.19 + +module use -a ${NCEPLIBS_INSTALL}/modules + +module load bacio/2.4.1 +module load g2/3.4.1 +module load ip/3.3.3 +module load nemsio/2.5.2 +module load sp/2.3.3 +module load w3emc/2.7.3 +module load w3nco/2.4.1 +module load sigio/2.3.2 +module load g2tmpl/1.9.1 +module load sfcio/1.4.1 +module load gfsio/1.4.1 +module load nemsiogfs/2.5.3 +module load landsfcutil/2.4.1 +module load wgrib2/2.0.8 +module load netcdf/4.7.4 +module load crtm/2.3.0 + +export ESMFMKFILE=/glade/p/ral/jntp/GMTB/tools/NCEPLIBS-ufs-v2.0.0/intel-19.1.1/mpt-2.19/lib64/esmf.mk + +export CMAKE_C_COMPILER=mpicc +export CMAKE_CXX_COMPILER=mpicxx +export CMAKE_Fortran_COMPILER=mpif90 +export CMAKE_Platform=cheyenne.intel + +git clone -b release/public-v1 git@github.com:ufs-community/ufs-srweather-app + +cd ufs-srweather-app/ +./manage_externals/checkout_externals + +mkdir build +cd build +cmake .. -DCMAKE_INSTALL_PREFIX=.. +make diff --git a/docs/README_hera_intel.txt b/docs/README_hera_intel.txt new file mode 100644 index 0000000000..41e6480651 --- /dev/null +++ b/docs/README_hera_intel.txt @@ -0,0 +1,50 @@ +#Setup instructions for NOAA RDHPC Hera using Intel-18.0.5.274 (bash shell) + +module purge +module load intel/18.0.5.274 +module load impi/2018.0.4 +module load cmake/3.16.1 + +export CC=icc +export CXX=icpc +export FC=ifort + +NCEPLIBS_INSTALL=/scratch1/BMC/gmtb/software/NCEPLIBS-ufs-v2.0.0/intel-18.0.5.274/impi-2018.0.4 + +module use ${NCEPLIBS_INSTALL}/modules + +module load libpng/1.6.35 + +module load bacio/2.4.1 +module load g2/3.4.1 +module load g2tmpl/1.9.1 +module load ip/3.3.3 +module load nemsio/2.5.2 +module load sp/2.3.3 +module load w3emc/2.7.3 +module load w3nco/2.4.1 +module load sigio/2.3.2 + +module load sfcio/1.4.1 +module load gfsio/1.4.1 +module load nemsiogfs/2.5.3 +module load landsfcutil/2.4.1 +module load wgrib2/2.0.8 +module load netcdf/4.7.4 +module load esmf/8.0.0 +module load crtm/2.3.0 + +export CMAKE_C_COMPILER=mpiicc +export CMAKE_CXX_COMPILER=mpiicpc +export CMAKE_Fortran_COMPILER=mpiifort +export CMAKE_Platform=hera.intel + +git clone -b release/public-v1 git@github.com:ufs-community/ufs-srweather-app + +cd ufs-srweather-app/ +./manage_externals/checkout_externals + +mkdir build +cd build +cmake .. -DCMAKE_INSTALL_PREFIX=.. +make diff --git a/docs/README_jet_intel.txt b/docs/README_jet_intel.txt new file mode 100644 index 0000000000..7dffb7289c --- /dev/null +++ b/docs/README_jet_intel.txt @@ -0,0 +1,54 @@ +#Setup instructions for NOAA RDHPC Jet using Intel-18.0.5.274 (bash shell) + +module purge + +module use -a /contrib/sutils/modulefiles +module load sutils + +module load intel/18.0.5.274 +module load impi/2018.4.274 +module load hdf5/1.10.4 +module load netcdf/4.6.1 +module load cmake/3.16.1 + +export CC=icc +export CXX=icpc +export FC=ifort + +NCEPLIBS_INSTALL=/lfs4/HFIP/hfv3gfs/software/NCEPLIBS-ufs-v2.0.0/intel-18.0.5.274/impi-2018.4.274 + +module use -a ${NCEPLIBS_INSTALL}/modules + +module load bacio/2.4.1 +module load crtm/2.3.0 +module load g2/3.4.1 +module load g2tmpl/1.9.1 +module load ip/3.3.3 +module load landsfcutil/2.4.1 +module load nceppost/dceca26 +module load nemsio/2.5.2 +module load nemsiogfs/2.5.3 +module load sp/2.3.3 +module load w3emc/2.7.3 +module load w3nco/2.4.1 + +module load gfsio/1.4.1 +module load sfcio/1.4.1 +module load sigio/2.3.2 +module load esmf/8.0.0 +module load wgrib2/2.0.8 + +export CMAKE_C_COMPILER=mpiicc +export CMAKE_CXX_COMPILER=mpiicpc +export CMAKE_Fortran_COMPILER=mpiifort +export CMAKE_Platform=jet.intel + +git clone -b release/public-v1 git@github.com:ufs-community/ufs-srweather-app + +cd ufs-srweather-app/ +./manage_externals/checkout_externals + +mkdir build +cd build +cmake .. -DCMAKE_INSTALL_PREFIX=.. +make diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000000..b326922f49 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,31 @@ +include(ExternalProject) + +ExternalProject_Add(UFS_UTILS + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/UFS_UTILS + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/UFS_UTILS + INSTALL_DIR ${CMAKE_INSTALL_PREFIX} + CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}" + ) + + +set(CCPP_SUITES "FV3_CPT_v0,FV3_GFS_2017_gfdlmp,FV3_GFS_2017_gfdlmp_regional,FV3_GSD_SAR,FV3_GSD_v0,FV3_GFS_v15p2,FV3_GFS_v16beta,FV3_RRFS_v1beta") + +ExternalProject_Add(ufs_weather_model + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/ufs_weather_model + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ufs_weather_model + INSTALL_DIR ${CMAKE_INSTALL_PREFIX} + CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}" + "-DCCPP_SUITES=${CCPP_SUITES}" + "-DCMAKE_C_COMPILER=${MPI_C_COMPILER}" + "-DCMAKE_CXX_COMPILER=${MPI_CXX_COMPILER}" + "-DCMAKE_Fortran_COMPILER=${MPI_Fortran_COMPILER}" + "-DNETCDF_DIR=$ENV{NETCDF}" + INSTALL_COMMAND mkdir -p ${CMAKE_INSTALL_PREFIX}/bin && cp ${CMAKE_CURRENT_BINARY_DIR}/ufs_weather_model/src/ufs_weather_model-build/NEMS.exe ${CMAKE_INSTALL_PREFIX}/bin/ + ) + +ExternalProject_Add(EMC_post + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/EMC_post + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/EMC_post + INSTALL_DIR ${CMAKE_INSTALL_PREFIX} + CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}" + ) diff --git a/src/build_all.sh b/src/build_all.sh index 2e54f5e502..7c11ec8c72 100755 --- a/src/build_all.sh +++ b/src/build_all.sh @@ -28,10 +28,10 @@ if [ ! -d $logs_dir ]; then mkdir $logs_dir fi -# Check final exec folder exists -if [ ! -d "../exec" ]; then - echo "Creating ../exec folder" - mkdir ../exec +# Check final bin folder exists +if [ ! -d "../" ]; then + echo "Creating ../bin folder" + mkdir ../bin fi #------------------------------------ diff --git a/src/install_all.sh b/src/install_all.sh index 4d545c1822..344a8518a1 100755 --- a/src/install_all.sh +++ b/src/install_all.sh @@ -5,10 +5,10 @@ build_dir=`pwd` CP='cp -rp' -# Check final exec folder exists -if [ ! -d "../exec" ]; then - echo "Creating ../exec folder" - mkdir ../exec +# Check final bin folder exists +if [ ! -d "../bin" ]; then + echo "Creating ../bin folder" + mkdir ../bin fi #------------------------------------ @@ -20,30 +20,30 @@ fi #------------------------------------ # install forecast #------------------------------------ -#${CP} NEMSfv3gfs/fv3.exe ../exec/regional_forecast.x +#${CP} NEMSfv3gfs/fv3.exe ../bin/regional_forecast.x #------------------------------------ # install post #------------------------------------ $Build_post && { - ${CP} EMC_post/exec/* ../exec/ncep_post + ${CP} EMC_post/exec/* ../bin/ncep_post } #------------------------------------ # install needed utilities from UFS_UTILS. #------------------------------------ $Build_UFS_UTILS && { -# ${CP} regional_utils.fd/exec/global_chgres ../exec/regional_chgres.x - ${CP} UFS_UTILS/exec/chgres_cube ../exec/chgres_cube.exe - ${CP} UFS_UTILS/exec/orog ../exec/orog.x - ${CP} UFS_UTILS/exec/sfc_climo_gen ../exec/sfc_climo_gen - ${CP} UFS_UTILS/exec/regional_esg_grid ../exec/regional_esg_grid - ${CP} UFS_UTILS/exec/make_hgrid ../exec/make_hgrid - ${CP} UFS_UTILS/exec/make_solo_mosaic ../exec/make_solo_mosaic - ${CP} UFS_UTILS/exec/fregrid ../exec/fregrid - ${CP} UFS_UTILS/exec/filter_topo ../exec/filter_topo - ${CP} UFS_UTILS/exec/shave ../exec/shave.x - ${CP} UFS_UTILS/exec/global_equiv_resol ../exec/global_equiv_resol +# ${CP} regional_utils.fd/exec/global_chgres ../bin/regional_chgres.x + ${CP} UFS_UTILS/exec/chgres_cube ../bin/chgres_cube + ${CP} UFS_UTILS/exec/orog ../bin/orog + ${CP} UFS_UTILS/exec/sfc_climo_gen ../bin/sfc_climo_gen + ${CP} UFS_UTILS/exec/regional_esg_grid ../bin/regional_esg_grid + ${CP} UFS_UTILS/exec/make_hgrid ../bin/make_hgrid + ${CP} UFS_UTILS/exec/make_solo_mosaic ../bin/make_solo_mosaic + ${CP} UFS_UTILS/exec/fregrid ../bin/fregrid + ${CP} UFS_UTILS/exec/filter_topo ../bin/filter_topo + ${CP} UFS_UTILS/exec/shave ../bin/shave + ${CP} UFS_UTILS/exec/global_equiv_resol ../bin/global_equiv_resol } #------------------------------------