Skip to content

Commit

Permalink
Merge pull request #12 from NOAA-EMC/develop
Browse files Browse the repository at this point in the history
merge changes from NOAA develop
  • Loading branch information
mickaelaccensi authored Sep 16, 2024
2 parents 14e6bed + abc77b9 commit 077c9de
Show file tree
Hide file tree
Showing 29 changed files with 1,613 additions and 757 deletions.
130 changes: 130 additions & 0 deletions .github/workflows/regtest_gnu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
name: regtest_gnu
on: [push, pull_request, workflow_dispatch]

# Cancel in-progress workflows when pushing to a branch
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
cache_key: gnu11-1
CC: gcc-10
FC: gfortran-10
CXX: g++-10


# Split into a steup step, and a WW3 build step which
# builds multiple switches in a matrix. The setup is run once and
# the environment is cached so each build of WW3 can share the dependencies.

jobs:
setup:
runs-on: ubuntu-latest

steps:
- name: checkout-ww3
if: steps.cache-env.outputs.cache-hit != 'true'
uses: actions/checkout@v3
with:
path: ww3
# Cache spack, OASIS, and compiler
# No way to flush Action cache, so key may have # appended
- name: cache-env
id: cache-env
uses: actions/cache@v3
with:
path: |
spack
~/.spack
work_oasis3-mct
key: spack-${{ runner.os }}-${{ env.cache_key }}-${{ hashFiles('ww3/model/ci/spack_gnu.yaml') }}

# Build WW3 spack environment
- name: install-dependencies-with-spack
if: steps.cache-env.outputs.cache-hit != 'true'
run: |
# Install NetCDF, ESMF, g2, etc using Spack
sudo apt install cmake
git clone -c feature.manyFiles=true https://github.com/JCSDA/spack.git
source spack/share/spack/setup-env.sh
spack env create ww3-gnu ww3/model/ci/spack_gnu.yaml
spack env activate ww3-gnu
spack compiler find
spack external find cmake
spack add [email protected]
spack concretize
spack install --dirty -v
- name: build-oasis
if: steps.cache-env.outputs.cache-hit != 'true'
run: |
source spack/share/spack/setup-env.sh
spack env activate ww3-gnu
export WWATCH3_DIR=${GITHUB_WORKSPACE}/ww3/model
export OASIS_INPUT_PATH=${GITHUB_WORKSPACE}/ww3/regtests/ww3_tp2.14/input/oasis3-mct
export OASIS_WORK_PATH=${GITHUB_WORKSPACE}/ww3/regtests/ww3_tp2.14/input/work_oasis3-mct
cd ww3/regtests/ww3_tp2.14/input/oasis3-mct/util/make_dir
cmake .
make VERBOSE=1
cp -r ${GITHUB_WORKSPACE}/ww3/regtests/ww3_tp2.14/input/work_oasis3-mct ${GITHUB_WORKSPACE}
regtest_gnu:
needs: setup
runs-on: ubuntu-latest

steps:
- name: install-dependencies
run: |
sudo apt-get update
sudo apt-get install doxygen gcovr valgrind
- name: checkout-ww3
uses: actions/checkout@v3
with:
path: ww3

- name: cache-env
id: cache-env
uses: actions/cache@v3
with:
path: |
spack
~/.spack
work_oasis3-mct
key: spack-${{ runner.os }}-${{ env.cache_key }}-${{ hashFiles('ww3/model/ci/spack_gnu.yaml') }}

- name: build-ww3
run: |
source spack/share/spack/setup-env.sh
spack env activate ww3-gnu
set -x
cd ww3
export CC=mpicc
export FC=mpif90
export OASISDIR=${GITHUB_WORKSPACE}/work_oasis3-mct
# mkdir build && cd build
export LD_LIBRARY_PATH="/home/runner/work/WW3/WW3/spack/var/spack/environments/ww3-gnu/.spack-env/view/:$LD_LIBRARY_PATH"
# cmake -DSWITCH=${GITHUB_WORKSPACE}/ww3/regtests/unittests/data/switch.io -DCMAKE_BUILD_TYPE=Debug ..
# make -j2 VERBOSE=1
cd ${GITHUB_WORKSPACE}/ww3
ls -l
${GITHUB_WORKSPACE}/ww3/model/bin/ww3_from_ftp.sh -k
cd regtests
./bin/run_cmake_test -o all -S -T -s PR1_MPI -w work_PR1_MPI -f -p mpirun -n 24 ../model ww3_tp2.5
cd ww3_tp2.5
ls -l
cd work_PR1_MPI
pwd
ls -l
# ncdump -h out_pnt.ww3.nc > ncdump_out.txt
# cat ncdump_out.txt
# pwd
# cat ${GITHUB_WORKSPACE}/ww3/regtests/ww3_tp2.5/out_pnt_ncdump.txt
# cmp ${GITHUB_WORKSPACE}/ww3/regtests/ww3_tp2.5/out_pnt_ncdump.txt ncdump_out.txt
- name: cache-data
id: cache-data
uses: actions/cache@v3
with:
path: ww3/ww3_from_ftp.v7.14.1.tar.gz
key: ww3_from_ftp.v7.14.1
20 changes: 14 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ project(

get_directory_property(hasParent PARENT_DIRECTORY)
if(hasParent)
# Unset flags that come from Parent (ie UFS or other coupled build)
# Unset flags that come from Parent (ie UFS or other coupled build)
# for potential (-r8/-r4) conflict
set(CMAKE_Fortran_FLAGS "")
set(CMAKE_C_FLAGS "")
Expand All @@ -22,8 +22,9 @@ endif()

set(MULTI_ESMF OFF CACHE BOOL "Build ww3_multi_esmf library")
set(NETCDF ON CACHE BOOL "Build NetCDF programs (requires NetCDF)")
set(ENDIAN "BIG" CACHE STRING "Endianness of unformatted output files. Valid values are 'BIG', 'LITTLE', 'NATIVE'.")
set(ENDIAN "BIG" CACHE STRING "Endianness of unformatted output files. Valid values are 'BIG', 'LITTLE', 'NATIVE'.")
set(EXCLUDE_FIND "" CACHE STRING "Don't try and search for these libraries (assumd to be handled by the compiler/wrapper)")
set(ENABLE_DOCS OFF CACHE BOOL "Enable building of doxygen generated documentation")

# make sure all "exclude_find" entries are lower case
list(TRANSFORM EXCLUDE_FIND TOLOWER)
Expand Down Expand Up @@ -59,8 +60,15 @@ endif()

add_subdirectory(model)

# Turn on unit testing.
include(CTest)
if(BUILD_TESTING)
add_subdirectory(regtests/unittests)
# Turn on doxygen documentation
if (ENABLE_DOCS)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/docs/cmake")
include(EnableDoxygen)
add_subdirectory(docs)
endif()

# Turn on unit testing.
#include(CTest)
#if(BUILD_TESTING)
# add_subdirectory(regtests/unittests)
#endif()
1 change: 1 addition & 0 deletions docs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
EnableDoxygen(docs)
6 changes: 3 additions & 3 deletions docs/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ PROJECT_LOGO =
# entered, it will be relative to the location where doxygen was started. If
# left blank the current directory will be used.

OUTPUT_DIRECTORY = docs
OUTPUT_DIRECTORY = @doc_output@

# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
# directories (in 2 levels) under the output directory of each output format and
Expand Down Expand Up @@ -829,7 +829,7 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.

INPUT = model/src
INPUT = @src_input@

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
Expand Down Expand Up @@ -2285,7 +2285,7 @@ CLASS_DIAGRAMS = NO
# DIA_PATH tag allows you to specify the directory where the dia binary resides.
# If left empty dia is assumed to be found in the default search path.

DIA_PATH =
DIA_PATH =

# If set to YES the inheritance and collaboration graphs will hide inheritance
# and usage relations if the target is undocumented or is not a class.
Expand Down
27 changes: 27 additions & 0 deletions docs/cmake/EnableDoxygen.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Doxygen documentation- Matt Masarik 24-Jul-2024.
function(EnableDoxygen outdir)
find_package(Doxygen REQUIRED)
if (NOT DOXYGEN_FOUND)
add_custom_target(enable_docs
COMMAND false
COMMENT "Doxygen not found")
return()
endif()

set(src_input "${CMAKE_SOURCE_DIR}/model/src")
set(doc_output "${CMAKE_BINARY_DIR}/${outdir}")
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${outdir}/html)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/docs/Doxyfile.in
${CMAKE_BINARY_DIR}/${outdir}/Doxyfile @ONLY)
set(DOXYGEN_GENERATE_HTML YES)
set(DOXYGEN_QUIET YES)
add_custom_target(enable_docs
COMMAND
${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/${outdir}/Doxyfile
WORKING_DIRECTORY
${CMAKE_BINARY_DIR}/${outdir}
COMMENT
"Generate Doxygen HTML documentation")
message("-- Doxygen HTML index page: "
${CMAKE_BINARY_DIR}/${outdir}/html/index.html)
endfunction()
9 changes: 6 additions & 3 deletions model/bin/ww3_from_ftp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,14 @@ fi
#Move to top level directory of ww3:
cd $ww3dir

#Download from ftp and uptar:
echo -e "Downloading and untaring file from ftp:"
wget --no-check-certificate https://ftp.emc.ncep.noaa.gov/static_files/public/WW3/ww3_from_ftp.${ww3ver}.tar.gz
#Download from ftp (if not already present) and uptar:
echo -e "Downloading (or finding) and untaring file from ftp:"
if ! test -f ww3_from_ftp.${ww3ver}.tar.gz; then
wget --no-check-certificate https://ftp.emc.ncep.noaa.gov/static_files/public/WW3/ww3_from_ftp.${ww3ver}.tar.gz
fi
tar -xvzf ww3_from_ftp.${ww3ver}.tar.gz


#Move regtest info from data_regtests to regtests:
echo -e "Moving data from data_regtests to regtests"
cp -r data_regtests/ww3_tp2.18/input/*.nc regtests/ww3_tp2.18/input/
Expand Down
5 changes: 2 additions & 3 deletions model/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,9 @@ if("SCRIP" IN_LIST switches)
target_sources(ww3_lib PRIVATE ${scrip_src})
endif()


if("SCRIPNC" IN_LIST switches OR "OASIS" IN_LIST switches OR "TRKNC" IN_LIST switches)
if("SCRIPNC" IN_LIST switches OR "OASIS" IN_LIST switches OR "TRKNC" IN_LIST switches OR "BIN2NC" IN_LIST switches)
if(NOT NetCDF_Fortran_FOUND)
message(FATAL_ERROR "Cannot build SCRIPNC, OASIS, or TRKNC without NetCDF")
message(FATAL_ERROR "Cannot build SCRIPNC, OASIS, TRKNC, or BIN2NC without NetCDF")
endif()
endif()

Expand Down
10 changes: 10 additions & 0 deletions model/src/cmake/switches.json
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,16 @@
}
]
},
{
"name": "bin2nc",
"num_switches": "upto1",
"description": "use netcdf instead of binary model output",
"valid-options": [
{
"name": "BIN2NC"
}
]
},
{
"name": "ascii",
"num_switches": "upto1",
Expand Down
12 changes: 12 additions & 0 deletions model/src/gx_outp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,11 @@ PROGRAM GXOUTP
#endif
USE W3ODATMD, ONLY: W3SETO, W3NOUT
USE W3IOGRMD, ONLY: W3IOGR
#ifdef W3_BIN2NC
USE W3IOPOMD, ONLY: W3IOPON
#else
USE W3IOPOMD, ONLY: W3IOPO
#endif
USE W3SERVMD, ONLY : ITRACE, NEXTLN, EXTCDE
#ifdef W3_S
USE W3SERVMD, ONLY : STRACE
Expand Down Expand Up @@ -277,7 +281,11 @@ PROGRAM GXOUTP
!--- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! 3. Read general data and first fields from file
!
#ifdef W3_BIN2NC
CALL W3IOPON ( 'READ', NDSOP, IOTEST )
#else
CALL W3IOPO ( 'READ', NDSOP, IOTEST )
#endif
ALLOCATE ( FLREQ(NOPTS) )
!
WRITE (NDSO,930)
Expand Down Expand Up @@ -369,7 +377,11 @@ PROGRAM GXOUTP
DO
DTEST = DSEC21 ( TIME , TOUT )
IF ( DTEST .GT. 0. ) THEN
#ifdef W3_BIN2NC
CALL W3IOPON ( 'READ', NDSOP, IOTEST )
#else
CALL W3IOPO ( 'READ', NDSOP, IOTEST )
#endif
IF ( IOTEST .EQ. -1 ) THEN
WRITE (NDSO,998)
EXIT
Expand Down
12 changes: 7 additions & 5 deletions model/src/w3bullmd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ SUBROUTINE W3BULL &
!
CSVBLINE = BLANK2
!
IPG1 = 0
IF (IOUT .EQ. 1) THEN
IPG1 = 0
DO IP=1, NPTAB
HST(IP,1) = -99.9
TPT(IP,1) = -99.9
Expand All @@ -286,10 +286,12 @@ SUBROUTINE W3BULL &
!
HSTOT = XPART(1,0)
TP = XPART(2,0)
HSP = XPART(1,1:NPART)
TPP = XPART(2,1:NPART)
WNP = TPI / XPART(3,1:NPART)
DMP = MOD( XPART(4,1:NPART) + 180., 360.)
DO IP=1, NPART
HSP(IP) = XPART(1,IP)
TPP(IP) = XPART(2,IP)
WNP(IP) = TPI / XPART(3,IP)
DMP(IP) = MOD( XPART(4,IP) + 180., 360.)
ENDDO

NZERO = 0
NZERO = COUNT( HSP <= BHSMIN .AND. HSP /= 0. )
Expand Down
Loading

0 comments on commit 077c9de

Please sign in to comment.