Skip to content

Commit

Permalink
Merge branch 'develop' into dice_cplhist
Browse files Browse the repository at this point in the history
  • Loading branch information
NickSzapiro-NOAA authored Apr 19, 2024
2 parents 5b4bff3 + 47c0099 commit 69852d8
Show file tree
Hide file tree
Showing 27 changed files with 5,137 additions and 4,712 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/superlinter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
name: Super-Linter

on:
push: null
pull_request: null

jobs:
build:
name: Lint
runs-on: ubuntu-latest

permissions:
contents: read
packages: read
statuses: write

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Super-Linter
uses: super-linter/[email protected]
env:
LINTER_RULES_PATH: /
DEFAULT_BRANCH: origin/develop
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FILTER_REGEX_EXCLUDE: .*(tests/fv3_conf/.*|tests/ci/.*|tests/auto/.*|tests/auto-jenkins/.*|tests/opnReqTests/.*|tests/opnReqTest|tests/atparse.bash).*
VALIDATE_BASH: true
BASH_SEVERITY: style
#VALIDATE_GITHUB_ACTIONS: true
#VALIDATE_LUA: true
#VALIDATE_MARKDOWN: true
#VALIDATE_PYTHON_PYLINT: true
#VALIDATE_YAML: true
16 changes: 16 additions & 0 deletions .shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Global settings for Shellcheck (https://github.com/koalaman/shellcheck)
enable=all

external-sources=true

# Disable variable referenced but not assigned
disable=SC2154

# Disable following non-constant source
disable=SC1090

# Disable non-existent binary
disable=SC1091

# Disable -p -m only applies to deepest directory
disable=SC2174
2 changes: 1 addition & 1 deletion FV3
24 changes: 16 additions & 8 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
#!/bin/bash
set -eu

if [[ $(uname -s) == Darwin ]]; then
readonly UFS_MODEL_DIR=$(cd "$(dirname "$(greadlink -f -n "${BASH_SOURCE[0]}" )" )" && pwd -P)
uname_s=$(uname -s)
if [[ ${uname_s} == Darwin ]]; then
UFS_MODEL_DIR=$(greadlink -f -n "${BASH_SOURCE[0]}")
UFS_MODEL_DIR=$(dirname "${UFS_MODEL_DIR}")
UFS_MODEL_DIR=$(cd "${UFS_MODEL_DIR}" && pwd -P)
else
readonly UFS_MODEL_DIR=$(cd "$(dirname "$(readlink -f -n "${BASH_SOURCE[0]}" )" )" && pwd -P)
UFS_MODEL_DIR=$(readlink -f -n "${BASH_SOURCE[0]}")
UFS_MODEL_DIR=$(dirname "${UFS_MODEL_DIR}")
UFS_MODEL_DIR=$(cd "${UFS_MODEL_DIR}" && pwd -P)
fi
echo "UFS MODEL DIR: ${UFS_MODEL_DIR}"
readonly UFS_MODEL_DIR

export CC=${CC:-mpicc}
export CXX=${CXX:-mpicxx}
export FC=${FC:-mpif90}

BUILD_DIR=${BUILD_DIR:-${UFS_MODEL_DIR}/build}
mkdir -p ${BUILD_DIR}
mkdir -p "${BUILD_DIR}"

cd ${BUILD_DIR}
cmake ${UFS_MODEL_DIR} ${CMAKE_FLAGS}
cd "${BUILD_DIR}"
ARR_CMAKE_FLAGS=()
for i in ${CMAKE_FLAGS}; do ARR_CMAKE_FLAGS+=("${i}") ; done
cmake "${UFS_MODEL_DIR}" "${ARR_CMAKE_FLAGS[@]}"
# Turn off OpenMP threading for parallel builds
# to avoid exhausting the number of user processes
OMP_NUM_THREADS=1 make -j ${BUILD_JOBS:-4} VERBOSE=${BUILD_VERBOSE:-}
OMP_NUM_THREADS=1 make -j "${BUILD_JOBS:-4}" "VERBOSE=${BUILD_VERBOSE:-1}"
8 changes: 7 additions & 1 deletion cmake/Intel.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -traceback -fpp -fno-alias -auto -safe-cray-ptr -ftz -assume byterecl -nowarn -sox -align array64byte -qno-opt-dynamic-align")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -traceback -fpp -fno-alias -auto -safe-cray-ptr -ftz -assume byterecl -sox -align array64byte -qno-opt-dynamic-align")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -qno-opt-dynamic-align -sox -fp-model source")

# warning #5462: Global name too long.
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -diag-disable 5462")

# remark #7712: This variable has not been used.
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -diag-disable 7712")

if(CMAKE_Platform STREQUAL "derecho.intel")
set(CMAKE_Fortran_LINK_FLAGS "-Wl,--copy-dt-needed-entries")
endif()
Expand Down
97 changes: 49 additions & 48 deletions tests/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,73 +7,82 @@ function trim {
var="${var#"${var%%[![:space:]]*}"}"
# remove trailing whitespace characters
var="${var%"${var##*[![:space:]]}"}"
echo -n "$var"
echo -n "${var}"
}

SECONDS=0

if [[ $(uname -s) == Darwin ]]; then
readonly MYDIR=$(cd "$(dirname "$(greadlink -f -n "${BASH_SOURCE[0]}" )" )" && pwd -P)
uname_s=$(uname -s)
if [[ ${uname_s} == Darwin ]]; then
greadlnk=$(greadlink -f -n "${BASH_SOURCE[0]}" )
MYDIR=$(cd "$(dirname "${greadlnk}" )" && pwd -P)
else
readonly MYDIR=$(cd "$(dirname "$(readlink -f -n "${BASH_SOURCE[0]}" )" )" && pwd -P)
readlnk=$(readlink -f -n "${BASH_SOURCE[0]}" )
MYDIR=$(cd "$(dirname "${readlnk}" )" && pwd -P)
fi
readonly MYDIR

# ----------------------------------------------------------------------
# Parse arguments.

readonly ARGC=$#

if [[ $ARGC -lt 2 ]]; then
echo "Usage: $0 MACHINE_ID [ MAKE_OPT [ COMPILE_ID ] [ RT_COMPILER ] [ clean_before ] [ clean_after ] ]"
if [[ ${ARGC} -lt 2 ]]; then
echo "Usage: $0 MACHINE_ID [ MAKE_OPT ] [ COMPILE_ID ] [ RT_COMPILER ] [ clean_before ] [ clean_after ]"
echo Valid MACHINE_IDs:
echo $( ls -1 ../cmake/configure_* | sed s:.*configure_::g | sed s:\.cmake:: ) | fold -sw72
echostuff=$( ls -1 ../cmake/configure_* )
echostuff=${echostuff/:.*configure_::g}
echostuff=${echostuff/:\.cmake::}
echostuff=$( fold -sw72 <<< "${echostuff}" )
exit 1
else
MACHINE_ID=$1
MAKE_OPT=${2:-}
COMPILE_ID=${3:+_$3}
COMPILE_ID=${3:+$3}
RT_COMPILER=${4:-intel}
clean_before=${5:-YES}
clean_after=${6:-YES}
fi

BUILD_NAME=fv3${COMPILE_ID}
BUILD_NAME=fv3_${COMPILE_ID}

PATHTR=${PATHTR:-$( cd ${MYDIR}/.. && pwd )}
PATHTR=${PATHTR:-$( cd "${MYDIR}/.." && pwd )}
BUILD_DIR=${BUILD_DIR:-$(pwd)/build_${BUILD_NAME}}

# ----------------------------------------------------------------------
# Make sure we have reasonable number of threads.

if [[ $MACHINE_ID == derecho ]]; then
if [[ ${MACHINE_ID} == derecho ]]; then
BUILD_JOBS=${BUILD_JOBS:-3}
fi

BUILD_JOBS=${BUILD_JOBS:-8}

hostname
#hostname

set +x
if [[ $MACHINE_ID == macosx ]] || [[ $MACHINE_ID == linux ]]; then
source $PATHTR/modulefiles/ufs_${MACHINE_ID}.${RT_COMPILER}
else
# Activate lua environment for gaea c5
if [[ $MACHINE_ID == gaea ]]; then
module reset
fi
# Load fv3 module
module use $PATHTR/modulefiles
modulefile="ufs_${MACHINE_ID}.${RT_COMPILER}"
module load $modulefile
module list
fi
case ${MACHINE_ID} in
macosx|linux)
source "${PATHTR}/modulefiles/ufs_${MACHINE_ID}.${RT_COMPILER}"
;;
*)
# Activate lua environment for gaea c5
if [[ ${MACHINE_ID} == gaea ]]; then
module reset
fi
# Load fv3 module
module use "${PATHTR}/modulefiles"
modulefile="ufs_${MACHINE_ID}.${RT_COMPILER}"
module load "${modulefile}"
module list
esac
set -x

echo "Compiling ${MAKE_OPT} into $BUILD_NAME.exe on $MACHINE_ID"
echo "Compiling ${MAKE_OPT} into ${BUILD_NAME}.exe on ${MACHINE_ID}"

# set CMAKE_FLAGS based on $MAKE_OPT

CMAKE_FLAGS=$MAKE_OPT
CMAKE_FLAGS=${MAKE_OPT}
CMAKE_FLAGS+=" -DMPI=ON"

if [[ ${MAKE_OPT} == *-DDEBUG=ON* ]]; then
Expand All @@ -87,15 +96,11 @@ fi

# Check if suites argument is provided or not
set +ex
TEST=$( echo $MAKE_OPT | grep -e "-DCCPP_SUITES=" )
if [[ $? -eq 0 ]]; then
SUITES=$( echo $MAKE_OPT | sed 's/.*-DCCPP_SUITES=//' | sed 's/ .*//' )
echo "Compiling suites ${SUITES}"
fi
SUITES=$(grep -Po "\-DCCPP_SUITES=\K[^ ]*" <<< "${MAKE_OPT}")
export SUITES
set -ex

# Valid applications

if [[ "${MAKE_OPT}" == *"-DAPP=S2S"* ]]; then
CMAKE_FLAGS+=" -DMOM6SOLO=ON"
fi
Expand All @@ -104,31 +109,27 @@ if [[ "${MAKE_OPT}" == *"-DAPP=NG-GODAS"* ]]; then
CMAKE_FLAGS+=" -DMOM6SOLO=ON"
fi

CMAKE_FLAGS=$(trim "${CMAKE_FLAGS}")
CMAKE_FLAGS=$(set -e; trim "${CMAKE_FLAGS}")
echo "CMAKE_FLAGS = ${CMAKE_FLAGS}"

if [ $clean_before = YES ] ; then
rm -rf ${BUILD_DIR}
fi
[[ ${clean_before} = YES ]] && rm -rf "${BUILD_DIR}"

export BUILD_VERBOSE=1
export BUILD_DIR
export BUILD_JOBS
export CMAKE_FLAGS

bash -x ${PATHTR}/build.sh
bash -x "${PATHTR}/build.sh"

mv ${BUILD_DIR}/ufs_model ${PATHTR}/tests/${BUILD_NAME}.exe
if [[ $MACHINE_ID == linux ]]; then
cp ${PATHTR}/modulefiles/ufs_${MACHINE_ID}.${RT_COMPILER} ${PATHTR}/tests/modules.${BUILD_NAME}
mv "${BUILD_DIR}/ufs_model" "${PATHTR}/tests/${BUILD_NAME}.exe"
if [[ ${MACHINE_ID} == linux ]]; then
cp "${PATHTR}/modulefiles/ufs_${MACHINE_ID}.${RT_COMPILER}" "${PATHTR}/tests/modules.${BUILD_NAME}"
else
cp ${PATHTR}/modulefiles/ufs_${MACHINE_ID}.${RT_COMPILER}.lua ${PATHTR}/tests/modules.${BUILD_NAME}.lua
cp "${PATHTR}/modulefiles/ufs_${MACHINE_ID}.${RT_COMPILER}.lua" "${PATHTR}/tests/modules.${BUILD_NAME}.lua"
fi

if [ $clean_after = YES ] ; then
rm -rf ${BUILD_DIR}
fi
[[ ${clean_after} == YES ]] && rm -rf "${BUILD_DIR}"

elapsed=$SECONDS
echo "Elapsed time $elapsed seconds. Compiling ${CMAKE_FLAGS} finished"
echo "Compile ${COMPILE_ID/#_} elapsed time $elapsed seconds. ${CMAKE_FLAGS}" > compile${COMPILE_ID}_time.log
elapsed=${SECONDS}
echo "Elapsed time ${elapsed} seconds. Compiling ${CMAKE_FLAGS} finished"
echo "Compile ${COMPILE_ID} elapsed time ${elapsed} seconds. ${CMAKE_FLAGS}" > "compile_${COMPILE_ID}_time.log"
Loading

0 comments on commit 69852d8

Please sign in to comment.