Skip to content

Commit

Permalink
Merge branch 'NOAA-EMC:develop' into init_bugs2
Browse files Browse the repository at this point in the history
  • Loading branch information
thesser1 authored Jan 11, 2024
2 parents 5482da9 + 7bec560 commit 9b0083d
Show file tree
Hide file tree
Showing 15 changed files with 525 additions and 65 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/intel.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# This is a GitHub actions workflow for WW3.
#
# This workflow builds with the Intel compilers.
#
# Matt Masarik, Alex Richert, Ed Hartnett
name: Intel Linux Build
on: [push, pull_request, workflow_dispatch]

Expand All @@ -8,7 +13,7 @@ concurrency:

# Set I_MPI_CC/F90 so Intel MPI wrapper uses icc/ifort instead of gcc/gfortran
env:
cache_key: intel10
cache_key: intel10-3
CC: icc
FC: ifort
CXX: icpc
Expand Down Expand Up @@ -51,7 +56,7 @@ jobs:
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
sudo apt-get update
sudo apt-get install intel-oneapi-dev-utilities intel-oneapi-mpi-devel intel-oneapi-openmp intel-oneapi-compiler-fortran intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic
sudo apt-get install intel-oneapi-dev-utilities intel-oneapi-mpi-devel intel-oneapi-compiler-fortran-2023.2.1 intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic-2023.2.1 intel-oneapi-openmp
# Build WW3 spack environment
- name: install-dependencies-with-spack
Expand Down
122 changes: 122 additions & 0 deletions .github/workflows/io_gnu_yml.old
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: io_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 mpich@3.4.2
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}

io_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 -DCMAKE_Fortran_FLAGS="-g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0 -Wall -fno-omit-frame-pointer -fsanitize=address" -DCMAKE_C_FLAGS="-g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0 -Wall -fno-omit-frame-pointer -fsanitize=address" ..
make -j2 VERBOSE=1
./bin/ww3_grid
mv mod_def.ww3 regtests/unittests
ctest --verbose --output-on-failure --rerun-failed
gcovr --root .. -v --html-details --exclude ../regtests/unittests --exclude CMakeFiles --print-summary -o test-coverage.html &> /dev/null

- name: upload-test-coverage
uses: actions/upload-artifact@v3
with:
name: ww3-test-coverage
path: |
ww3/build/*.html
ww3/build/*.css


6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,9 @@ if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$")
endif()

add_subdirectory(model)

# Turn on unit testing.
include(CTest)
if(BUILD_TESTING)
add_subdirectory(regtests/unittests)
endif()
29 changes: 15 additions & 14 deletions manual/eqs/NL1.tex
Original file line number Diff line number Diff line change
Expand Up @@ -55,37 +55,38 @@ \subsubsection{~$S_{nl}$: Discrete Interaction Approximation (\dia)} \label{sec:
\sin(\delta_{\theta,3})&=&\sin(\delta_{\theta,2}) (1-\lambda)^2/(1+\lambda)^2.
\end{eqnarray}

For these quadruplets, each source term value
$S_{nl}(\bk)$ corresponding to each discrete $(f_r,\theta)$
we compute the three contributions that correspond to the situation in which $\bk$ takes the role of $\bk$,$\bk_{2,+}$, $\bk_{2,-}$, $\bk_{3,+}$ and $\bk_{3,-}$ in the quadruplet, namely the full source term is
Hence for any $\bk$ one quadruplet selects $\bk_{2,+}$ and $\bk_{3,+}$, and the other quadruplet selects its mirror image
$\bk_{2,-}$, $\bk_{2,-}$. Because there are 3 different components interacting in the two DIA-selected quadruplets, any discrete spectral component $(f_r,\theta)$ is actually involved in 6 quadruplets and directly exchanges energy with 12 other components $(f_r',\theta')$. Because the values of $f'_r$ and $\theta'$ do not fall exacly on other discrete components, the spectral density is interpolated using a bilinear interpolation, so that each source term value
$S_{nl}(\bk)$ contains the direct exchange of energy with 48 other discrete components.
we compute the three contributions that correspond to the situation in which $\bk$ takes the role of $\bk$,$\bk_{2,+}$, $\bk_{2,-}$, $\bk_{3,+}$ and $\bk_{3,-}$ in the quadruplet, namely the full source term is, without making explicit that bilinear interpolation,
\begin{eqnarray}
S_{\mathrm{nl}}(\bk) &=& -2 \left[\delta S_{\mathrm{nl}}(\bk,\bk_2,\bk_3,+)+\delta S_{\mathrm{nl}}(\bk,\bk_2,\bk_3,-)\right] \nonumber \\
& & + \delta S_{\mathrm{nl}}(\bk_4,\bk,\bk_5,+) + \delta S_{\mathrm{nl}}(\bk_6,\bk,\bk_7,-) \\
& & + \delta S_{\mathrm{nl}}(\bk_8,\bk_9,\bk, +) + \delta S_{\mathrm{nl}}(\bk_{10},\bk_{11},\bk, -) . \label{eq:diasum}
S_{\mathrm{nl}}(\bk) &=& -2 \left[\delta S_{\mathrm{nl}}(\bk,\bk_{2,+},\bk_{3,+})+\delta S_{\mathrm{nl}}(\bk,\bk_{2,-},\bk_{3,-})\right] \nonumber \\
& & + \delta S_{\mathrm{nl}}(\bk_4,\bk,\bk_5) + \delta S_{\mathrm{nl}}(\bk_6,\bk,\bk_7) \\
& & + \delta S_{\mathrm{nl}}(\bk_8,\bk_9,\bk) + \delta S_{\mathrm{nl}}(\bk_{10},\bk_{11},\bk) . \label{eq:diasum}
\end{eqnarray}
with elementary contributions given by
where the geometry of the quadruplet $(\bk_4,\bk_4,\bk,\bk_5)$ is obtained from that of $(\bk,\bk,\bk_{2,+},\bk_{3,+})$ by a dilation by a factor $(1+\lambda)^2$ and rotation by the angle $\delta_{\theta,2}$; $(\bk_6,\bk_6,\bk,\bk_7)$ has the same dilation but the opposite rotation; $(\bk_8,\bk_8,\bk_9,\bk)$ is dilated by a factor $(1-\lambda)^2$ and rotated by the angle $-\delta_{\theta,3}$: and $(\bk_{10},\bk_{10},\bk_{11},\bk)$ is dilated by the same factor and rotated by the opposite angle.


The elementary contributions $\delta S_{\mathrm{nl}}(\bk_l,\bk_m,\bk_n)$ are given by
%----------------------------%
% Nonlinear interactions DIA %
%----------------------------%
% eq:snl_dia

\begin{equation}
\delta S_{\mathrm{nl}}(\bk,\bk_2,\bk_3,s) = \frac{C}{g^4} f_{r,1}^{11} \left [ F^2 \left ( \frac{F_{2,s}}{(1+\lambda_{nl})^4} +
\frac{F_{3,s}}{(1-\lambda_{nl})^4} \right ) - \frac{2 F F_{2,s} F_{3,s}}{(1-\lambda_{nl}^2)^4} \right] ,
\delta S_{\mathrm{nl}}(\bk_l,\bk_m,\bk_n) = \frac{C}{g^4} f_{r,l}^{11} \left [ F_l^2 \left ( \frac{F_m}{(1+\lambda)^4} +
\frac{F_n}{(1-\lambda)^4} \right ) - \frac{2 F_l F_m F_n}{(1-\lambda^2)^4} \right] ,
\label{eq:snl_dia}
\end{equation}
where $s=+$ or $s=-$ is a sign index, and the spectral densities are $F = F(f_{r} ,\theta)$, $F_{2,+} = F(f_{r,2} ,\theta + \delta_{\theta,2})$, $F_{2,-} = F(f_{r,2} ,\theta - \delta_{\theta,2})$, etc.
where the spectral densities are $F_l = F(f_{r,l} ,\theta_l)$, etc.
$C$ is a proportionality constant that was tuned to reproduce the inverse energy cascade. Default values for different source term packages are presented in Table~\ref{tab:snl_par}.
As a result, when accounting for the two quadruplet configurations, the source term at $\bk$ includes the interactions with
10 other spectral components. Besides, because $f_{r,2}$ and $f_{r,3}$ nor $\theta_{2,\pm} $ and $\theta_{3,\pm} $ fall on discretized frequencies and directions, the spectral densities are bilinearly interpolated, which involves 4 discrete spectral components for each of these 10 components.



% tab:snl_par

\begin{table} \begin{center}
\begin{tabular}{|l|c|c|} \hline
& $\lambda_{nl}$ & $C$ \\ \hline
& $\lambda$ & $C$ \\ \hline
ST6 & 0.25 & $3.00 \; 10^7$ \\ \hline
\wam-3 & 0.25 & $2.78 \; 10^7$ \\ \hline
ST4 (Ardhuin et al.)& 0.25 & $2.50 \; 10^7$ \\ \hline
Expand Down
11 changes: 11 additions & 0 deletions manual/manual.bib
Original file line number Diff line number Diff line change
Expand Up @@ -3665,6 +3665,17 @@ @article{art:DC23
year = {2023}
}

@ARTICLE{Webb1978,
author = "D. J. Webb",
title = "Nonlinear transfer between sea waves",
journal = DSR,
volume = 25,
pages = "279--298",
year = 1978,
where="paper",
}


@ARTICLE{Lavrenov2001,
author = "Igor V. Lavrenov",
title = "Effect of wind wave parameter fluctuation on the nonlinear spectrum evolution",
Expand Down
6 changes: 5 additions & 1 deletion manual/sys/files_w3.tex
Original file line number Diff line number Diff line change
Expand Up @@ -506,11 +506,15 @@ \subsubsection{~Wave model modules} \label{sec:wave_mod}
\end{flist}

\noindent
Nonlinear interaction module (\dia) \hfill {\file w3snl1md.ftn}
Nonlinear interaction module (\dia or GQM) \hfill {\file w3snl1md.ftn}

\begin{flisti}
\fit{w3snl1}{Calculation of $S_{nl}$.}
\fit{insnl1}{Initialization for $S_{nl}$.}
\fit{w3snlgqm}{Calculation of $S_{nl}$.}
\fit{w3scouple}{Calculation of coupling coefficient.}
\fit{gauleg}{Calculation of Gauss-Legendre quadrature coefficients.}
\fit{INSNLGQM}{Initialization for $S_{nl}$ with GQ method.}
\end{flisti}

\noindent
Expand Down
78 changes: 71 additions & 7 deletions model/src/w3iopomd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1023,17 +1023,81 @@ SUBROUTINE W3IOPE ( A )
!/ End of W3IOPE ----------------------------------------------------- /
!/
END SUBROUTINE W3IOPE
!/ ------------------------------------------------------------------- /

!> Read or write point output.
!>
!> @brief Read/write point output.
!> This subroutine can either read or write the point output file,
!> depending on the value of the first parameter.
!>
!> @param[in] INXOUT Test string for read/write.
!> @param[in] NDSOP File unit number.
!> @param[out] IOTST Test indictor for reading.
!> @param[in] IMOD Model number for W3GDAT etc.
!> When reading, the entire file is read with one call to this
!> subroutine.
!>
!> @author H. L. Tolman @date 25-Jul-2006
!> When writing, this subroutine can either write one timestep or
!> the whole model run. This is an option in the input file. If the
!> entire model run is to be written, then OFILES(2) is 0. If only
!> one timestep is to be written, then OFILES(2) is 1.
!>
!> If OFILES(2) is 0, the output file is names out_pnt.ww3. If
!> OFILES(2) is 1, the output file is named TIMETAG.out_pnt.ww3.
!>
!> The format of the point output file is:
!> Size (bytes) | Type | Variable | Meaning
!> -------------|------|----------|--------
!> 40 | character*40 | IDTST | ID string
!> 4 | integer | VERTST | Model definition file version number
!> 4 | integer | NK | Dimension of frequency
!> 4 | integer | MTH | Directionality of the frequency
!> 4 | integer | NOPTS | Number of output points.
!> 8*NOPTS | integer(2,NOPTS) | PTLOC | Point locations
!> 7*NOPTS | character*7 | PTNME | Point names
!> 8 | integer(2) | TIME | Time
!> reclen*NOPTS | * | * | records
!>
!> Each record contains:
!> Size (bytes) | Type | Variable | Meaning
!> -------------|------|----------|--------
!> 4 | integer | IW | Number of water points in interpolation box for output point.
!> 4 | integer | II | Number of ice points in interpolation box for output point.
!> 4 | integer | IL | Number of land points in interpolation box for output point.
!> 4 | real | DPO | Interpolated depths.
!> 4 | real | WAO | Interpolated wind speeds.
!> 4 | real | WDO | Interpolated wind directions.
!> 4 | real | TAUAO | (W3_FLX5 only) Interpolated atmospheric stresses.
!> 4 | real | TAUDO | (W3_FLX5 only) Interpolated atmospheric stress directions.
!> 4 | real | DAIRO | (W3_FLX5 only) Interpolated rho atmosphere.
!> 4 | real | ZET_SETO | (W3_SETUP only) Used for wave setup.
!> 4 | real | ASO | Interpolated air-sea temperature difference
!> 4 | real | CAO | Interpolated current speeds.
!> 4 | real | CDO | Interpolated current directions.
!> 4 | real | ICEO | Interpolated ice concentration.
!> 4 | real | ICEHO | Interpolated ice thickness.
!> 4 | real | ICEFO | Interpolated ice floe.
!> 13 | char | GRDID | Originating grid ID
!> 4 | real | SPCO(J,I),J=1,NSPEC | Output spectra
!>
!> In the event of error, EXTCDE() will be called with the following exit codes:
!> - 1 INXOUT must be 'READ' or 'WRITE'.
!> - 2 Unexpectedly changed from WRITE to READ in subsequent call.
!> - 10 Unexpected IDSTR
!> - 11 Unexpected VEROPT
!> - 12 Unexpected MK or MTH
!> - 20 Error opening file.
!> - 21 Unexpected end of file during read.
!> - 22 Error reading file.
!> - 23 Unexpected end of file during read.
!>
!> @param[in] INXOUT String indicating read/write. Must be 'READ' or
!> 'WRITE'.
!> @param[in] NDSOP File unit number.
!> @param[out] IOTST Error code:
!> - 0 No error.
!> - -1 Unexpected end of file when reading.
!> @param[in] IMOD Model number for W3GDAT etc.
#ifdef W3_ASCII
!> @param[in] NDSOA File unit number for ASCII output.
#endif
!>
!> @author H. L. Tolman @date 25-Jul-2006
SUBROUTINE W3IOPO ( INXOUT, NDSOP, IOTST, IMOD &
#ifdef W3_ASCII
,NDSOA &
Expand Down
Loading

0 comments on commit 9b0083d

Please sign in to comment.