Skip to content

Commit

Permalink
Merge branch 'NOAA-EMC:develop' into feature/gpu/w3srce_refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ukmo-ccbunney authored Jul 25, 2024
2 parents 2df466a + b4e119e commit 6ad8078
Show file tree
Hide file tree
Showing 26 changed files with 1,572 additions and 752 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
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ endif()
add_subdirectory(model)

# Turn on unit testing.
include(CTest)
if(BUILD_TESTING)
add_subdirectory(regtests/unittests)
endif()
#include(CTest)
#if(BUILD_TESTING)
# add_subdirectory(regtests/unittests)
#endif()
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 6ad8078

Please sign in to comment.