Skip to content

Commit

Permalink
Merge pull request NOAA-EMC#264 from NOAA-EMC/feature/cmake
Browse files Browse the repository at this point in the history
Build workflow utilities with CMake.
  • Loading branch information
KateFriedman-NOAA committed Feb 19, 2021
2 parents 2d05591 + 1d7776d commit f6aa693
Show file tree
Hide file tree
Showing 30 changed files with 1,021 additions and 108 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
#--------------------------
__pycache__
*.pyc
*.o
*.[aox]
*.mod

# Ignore exec folder
# Ignore folders
#-------------------
exec/
build*/
install*/

# Ignore fix directory symlinks
#------------------------------
Expand Down
29 changes: 29 additions & 0 deletions modulefiles/workflow_utils.hera
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#%Module#####################################################
## Workflow Utilities - hera
#############################################################

module load cmake/3.16.1

module use /scratch2/NCEPDEV/nwprod/hpc-stack/libs/hpc-stack/modulefiles/stack
module load hpc/1.1.0
module load hpc-intel/18.0.5.274
module load hpc-impi/2018.0.4

module load jasper/2.0.25
module load zlib/1.2.11
module load png/1.6.35

module load bacio/2.4.1
module load w3nco/2.4.1
module load w3emc/2.7.3
module load sp/2.3.3
module load ip/3.3.3
module load nemsio/2.5.2
module load nemsiogfs/2.5.3
#module load ncio/1.0.0
module load sigio/2.3.2
module load g2/3.4.1
module load bufr/11.4.0

module load hdf5/1.10.6
module load netcdf/4.7.4
29 changes: 29 additions & 0 deletions modulefiles/workflow_utils.orion
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#%Module#####################################################
## Workflow Utilities - orion
#############################################################

module load cmake/3.17.3

module use /apps/contrib/NCEP/libs/hpc-stack/modulefiles/stack
module load hpc/1.1.0
module load hpc-intel/2018.4
module load hpc-impi/2018.4

module load jasper/2.0.25
module load zlib/1.2.11
module load png/1.6.35

module load bacio/2.4.1
module load w3nco/2.4.1
module load w3emc/2.7.3
module load sp/2.3.3
module load ip/3.3.3
module load nemsio/2.5.2
module load nemsiogfs/2.5.3
#module load ncio/1.0.0
module load sigio/2.3.2
module load g2/3.4.1
module load bufr/11.4.0

module load hdf5/1.10.6
module load netcdf/4.7.4
29 changes: 29 additions & 0 deletions modulefiles/workflow_utils.wcoss_dell_p3
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#%Module#####################################################
## Workflow Utilities - wcoss_dell_p3
#############################################################

module load cmake/3.16.2

module use /usrx/local/nceplibs/dev/hpc-stack/libs/hpc-stack/modulefiles/stack
module load hpc/1.1.0
module load hpc-ips/18.0.1.163
module load hpc-impi/18.0.1

module load jasper/2.0.25
module load zlib/1.2.11
module load png/1.6.35

module load bacio/2.4.1
module load w3nco/2.4.1
module load w3emc/2.7.3
module load sp/2.3.3
module load ip/3.3.3
module load nemsio/2.5.2
module load nemsiogfs/2.5.3
#module load ncio/1.0.0
module load sigio/2.3.2
module load g2/3.4.1
module load bufr/11.4.0

module load hdf5/1.10.6
module load netcdf/4.7.4
72 changes: 72 additions & 0 deletions sorc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
cmake_minimum_required(VERSION 3.15)

# Get the version from the VERSION file.
#file(STRINGS "VERSION" pVersion)
set(pVersion 1.0.0)

project(
workflow_utils
VERSION ${pVersion}
LANGUAGES Fortran)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

include(GNUInstallDirs)

# User options.
option(OPENMP "use OpenMP threading" ON)

# Build type
if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$")
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE
"Release"
CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
endif()

# Set compiler flags.
if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -traceback")
set(CMAKE_Fortran_FLAGS_RELEASE "-O3")
set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -check -check noarg_temp_created -check nopointer -fp-stack-check -fstack-protector-all -fpe0 -debug -ftrapuv")
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -fbacktrace")
set(CMAKE_Fortran_FLAGS_RELEASE "-O3")
set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -ggdb -fno-unsafe-math-optimizations -frounding-math -fsignaling-nans -ffpe-trap=invalid,zero,overflow -fbounds-check")
endif()

# Find packages.
find_package(MPI REQUIRED)
find_package(NetCDF REQUIRED Fortran)

if(OPENMP)
find_package(OpenMP REQUIRED COMPONENTS Fortran)
endif()

find_package(bacio REQUIRED)
find_package(w3nco REQUIRED)
find_package(w3emc REQUIRED)
find_package(sp REQUIRED)
find_package(ip REQUIRED)
find_package(ncio REQUIRED)
find_package(nemsio REQUIRED)
find_package(nemsiogfs REQUIRED)
find_package(sigio REQUIRED)
find_package(g2 REQUIRED)
find_package(bufr REQUIRED)

add_subdirectory(enkf_chgres_recenter.fd)
add_subdirectory(enkf_chgres_recenter_nc.fd)
add_subdirectory(fv3nc2nemsio.fd)
add_subdirectory(regrid_nemsio.fd)
add_subdirectory(gaussian_sfcanl.fd)
add_subdirectory(gfs_bufr.fd)
add_subdirectory(tocsbufr.fd)
add_subdirectory(fbwndgfs.fd)
add_subdirectory(vint.fd)
add_subdirectory(tave.fd)
add_subdirectory(syndat_qctropcy.fd)
add_subdirectory(syndat_maksynrc.fd)
add_subdirectory(syndat_getjtbul.fd)
add_subdirectory(supvit.fd)
14 changes: 14 additions & 0 deletions sorc/build_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,20 @@ fi
((err+=$rc))
}

#------------------------------------
# build workflow_utils
#------------------------------------
$Build_workflow_utils && {
echo " .... Building workflow_utils .... "
target=$target ./build_workflow_utils.sh > $logs_dir/build_workflow_utils.log 2>&1
rc=$?
if [[ $rc -ne 0 ]] ; then
echo "Fatal error in building workflow_utils."
echo "The log file is in $logs_dir/build_workflow_utils.log"
fi
((err+=$rc))
}

#------------------------------------
# build gfs_util
#------------------------------------
Expand Down
48 changes: 48 additions & 0 deletions sorc/build_workflow_utils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
set -eux

[[ $(uname -s) == Darwin ]] && cmd=$(which greadlink) || cmd=$(which readlink)
readonly UTILS_DIR=$(cd "$(dirname "$($cmd -f -n "${BASH_SOURCE[0]}" )" )" && pwd -P)

# Adapt for global-workflow structure.
target=${target:-"NULL"}
modulefile=${UTILS_DIR}/../modulefiles/workflow_utils.$target
if [[ -f $modulefile ]]; then
set +x
source ${UTILS_DIR}/machine-setup.sh > /dev/null 2>&1
source $modulefile
module list
set -x
fi
# End adaptation

# Begin hack
# In place until nceplibs-ncio is in hpc-stack and available as a module
# After nceplibs-ncio is in hpc-stack, add the following line to
# ${UTILS_DIR}/../modulefiles/workflow_utils.<platform>
# "module load ncio/<ncio-version>"
# and remove this hack

[[ -d nceplibs-ncio ]] && rm -rf nceplibs-ncio
git clone -b develop https://github.com/noaa-emc/nceplibs-ncio
cd nceplibs-ncio
mkdir -p build && cd build
cmake -DCMAKE_INSTALL_PREFIX=../install ..
make -j ${BUILD_JOBS:-4} VERBOSE=${BUILD_VERBOSE:-}
make install
cd ../..
export ncio_ROOT=$PWD/nceplibs-ncio/install
# End hack

BUILD_DIR=${BUILD_DIR:-${UTILS_DIR}/build}
[[ -d $BUILD_DIR ]] && rm -rf $BUILD_DIR
mkdir -p ${BUILD_DIR}
cd $BUILD_DIR

INSTALL_DIR=${INSTALL_DIR:-${UTILS_DIR}/install}

CMAKE_FLAGS+=" -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR"

cmake ${UTILS_DIR} ${CMAKE_FLAGS}
make -j ${BUILD_JOBS:-4} VERBOSE=${BUILD_VERBOSE:-}
make install
Loading

0 comments on commit f6aa693

Please sign in to comment.