From a9c2bf082b8bd1632c61bf7873b42a08b09c04aa Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Thu, 11 Jan 2024 08:08:58 -0700 Subject: [PATCH 001/126] change to README --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index fa2c1df63..bff5e35c7 100644 --- a/README.md +++ b/README.md @@ -35,4 +35,3 @@ endorsement, recommendation or favoring by the Department of Commerce. The Department of Commerce seal and logo, or the seal and logo of a DOC bureau, shall not be used in any manner to imply endorsement of any commercial product or activity by DOC or the United States Government. - From 845dad521cd3d7ce5d7f699ffecd75ae417bb0b2 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Thu, 11 Jan 2024 08:15:38 -0700 Subject: [PATCH 002/126] adding w3iopomd --- README.md | 1 + model/src/w3iopomd.F90 | 559 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 559 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bff5e35c7..fa2c1df63 100644 --- a/README.md +++ b/README.md @@ -35,3 +35,4 @@ endorsement, recommendation or favoring by the Department of Commerce. The Department of Commerce seal and logo, or the seal and logo of a DOC bureau, shall not be used in any manner to imply endorsement of any commercial product or activity by DOC or the United States Government. + diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index 0c15ea8c6..552ef06ed 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -118,6 +118,115 @@ MODULE W3IOPOMD CHARACTER(LEN=10), PARAMETER, PRIVATE :: VEROPT = '2021-04-06' CHARACTER(LEN=31), PARAMETER, PRIVATE :: & IDSTR = 'WAVEWATCH III POINT OUTPUT FILE' + + !> Dimension name for the netCDF point output file, for NOPTS, the + !> Number of Output Points. + character(*), parameter, private :: DNAME_NOPTS = 'NOPTS' + + !> Dimension name for the netCDF point output file, for NSPEC. + character(*), parameter, private :: DNAME_NSPEC = 'NSPEC' + + !> Dimension name for the netCDF point output file, for VSIZE. This + !> is for the vector size for points, which is 2. + character(*), parameter, private :: DNAME_VSIZE = 'VSIZE' + + !> Dimension name for the netCDF point output file, for + !> NAMELEN. This is the length of the PTNME strings, which contains + !> the names of the points. + character(*), parameter, private :: DNAME_NAMELEN = 'NAMELEN' + + !> Dimension name for the netCDF point output file, for GRDIDLEN, + !> this is the length of the GRDID character array. + character(*), parameter, private :: DNAME_GRDIDLEN = 'GRDIDLEN' + + !> Variable name for the netCDF point output file, for NK. + character(*), parameter, private :: VNAME_NK = 'NK' + + !> Variable name for the netCDF point output file, for MTH. + character(*), parameter, private :: VNAME_MTH = 'MTH' + + !> Variable name for the netCDF point output file, for PTLOC. + character(*), parameter, private :: VNAME_PTLOC = 'PTLOC' + + !> Variable name for the netCDF point output file, for PTNME. + character(*), parameter, private :: VNAME_PTNME = 'PTNME' + + !> Variable name for the netCDF point output file, for IW. + character(*), parameter, private :: VNAME_IW = 'IW' + + !> Variable name for the netCDF point output file, for II. + character(*), parameter, private :: VNAME_II = 'II' + + !> Variable name for the netCDF point output file, for IL. + character(*), parameter, private :: VNAME_IL = 'IL' + + !> Variable name for the netCDF point output file, for DPO. + character(*), parameter, private :: VNAME_DPO = 'DPO' + + !> Variable name for the netCDF point output file, for WAO. + character(*), parameter, private :: VNAME_WAO = 'WAO' + + !> Variable name for the netCDF point output file, for WDO. + character(*), parameter, private :: VNAME_WDO = 'WDO' + + !> Variable name for the netCDF point output file, for TAUAO. + character(*), parameter, private :: VNAME_TAUAO = 'TAUAO' + + !> Variable name for the netCDF point output file, for TAIDO. + character(*), parameter, private :: VNAME_TAIDO = 'TAIDO' + + !> Variable name for the netCDF point output file, for DAIRO. + character(*), parameter, private :: VNAME_DAIRO = 'DAIRO' + + !> Variable name for the netCDF point output file, for ZET_SETO. + character(*), parameter, private :: VNAME_ZET_SETO = 'ZET_SETO' + + !> Variable name for the netCDF point output file, for ASO. + character(*), parameter, private :: VNAME_ASO = 'ASO' + + !> Variable name for the netCDF point output file, for CAO. + character(*), parameter, private :: VNAME_CAO = 'CAO' + + !> Variable name for the netCDF point output file, for CDO. + character(*), parameter, private :: VNAME_CDO = 'CDO' + + !> Variable name for the netCDF point output file, for ICEO. + character(*), parameter, private :: VNAME_ICEO = 'ICEO' + + !> Variable name for the netCDF point output file, for ICEHO. + character(*), parameter, private :: VNAME_ICEHO = 'ICEHO' + + !> Variable name for the netCDF point output file, for ICEFO. + character(*), parameter, private :: VNAME_ICEFO = 'ICEFO' + + !> Variable name for the netCDF point output file, for GRDID. + character(*), parameter, private :: VNAME_GRDID = 'GRDID' + + !> Variable name for the netCDF point output file, for SPCO. + character(*), parameter, private :: VNAME_SPCO = 'SPCO' + + + + + + + + + + + + + + + + + + + + + + + !/ CONTAINS !/ ------------------------------------------------------------------- / @@ -1024,6 +1133,454 @@ SUBROUTINE W3IOPE ( A ) !/ END SUBROUTINE W3IOPE + !> Read point output in netCDF format. + !> + !> @param[out] IOTST Test indictor for reading. + !> @param[in] IMOD Model number for W3GDAT etc. + !> @param[in] filename Name of file to read. + !> @param[inout] ncerr Error code, 0 for success, netCDF error code + !> otherwise. + !> + !> @author Edward Hartnett @date 1-Nov-2023 + !> + SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr) + use netcdf + USE W3GDATMD, ONLY: NTH, NK, NSPEC, FILEXT + USE W3ODATMD, ONLY: NDST, NDSE, IPASS => IPASS2, NOPTS, IPTINT, & + IL, IW, II, PTLOC, PTIFAC, DPO, WAO, WDO, & + ASO, CAO, CDO, SPCO, PTNME, O2INIT, FNMPRE, & + GRDID, ICEO, ICEHO, ICEFO +#ifdef W3_FLX5 + USE W3ODATMD, ONLY: TAUAO, TAUDO, DAIRO +#endif +#ifdef W3_SETUP + USE W3ODATMD, ONLY: ZET_SETO +#endif + IMPLICIT NONE + + INTEGER, INTENT(OUT) :: IOTST + INTEGER, INTENT(IN), OPTIONAL :: IMOD + character(*), intent(in) :: filename + integer, intent(inout) :: ncerr + integer :: fh + integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen + integer :: d_nopts_len, d_nspec_len, d_vsize_len, d_namelen_len, d_grdidlen_len + integer :: v_idtst, v_vertst, v_nk, v_mth, v_ptloc, v_ptnme + integer :: v_iw, v_ii, v_il, v_dpo, v_wao, v_wdo, v_tauao + integer :: v_taido, v_dairo, v_zet_seto, v_aso, v_cao, v_cdo, v_iceo + integer :: v_iceho, v_icefo, v_grdid, v_spco + + print *,filename + IOTST = 0 + + ! Open the netCDF file. + ncerr = nf90_open(filename, NF90_NOWRITE, fh) + if (ncerr .ne. 0) return + + ! Read the dimension information for NOPTS. + ncerr = nf90_inq_dimid(fh, DNAME_NOPTS, d_nopts) + if (ncerr .ne. 0) return + ncerr = nf90_inquire_dimension(fh, d_nopts, len = d_nopts_len) + if (ncerr .ne. 0) return + + ! Read the dimension information for NSPEC. + ncerr = nf90_inq_dimid(fh, DNAME_NSPEC, d_nspec) + if (ncerr .ne. 0) return + ncerr = nf90_inquire_dimension(fh, d_nspec, len = d_nspec_len) + if (ncerr .ne. 0) return + + ! Read the dimension information for VSIZE. + ncerr = nf90_inq_dimid(fh, DNAME_VSIZE, d_vsize) + if (ncerr .ne. 0) return + ncerr = nf90_inquire_dimension(fh, d_vsize, len = d_vsize_len) + if (ncerr .ne. 0) return + + ! Read the dimension information for NAMELEN. + ncerr = nf90_inq_dimid(fh, DNAME_NAMELEN, d_namelen) + if (ncerr .ne. 0) return + ncerr = nf90_inquire_dimension(fh, d_namelen, len = d_namelen_len) + if (ncerr .ne. 0) return + + ! Read the dimension information for GRDIDLEN. + ncerr = nf90_inq_dimid(fh, DNAME_GRDIDLEN, d_grdidlen) + if (ncerr .ne. 0) return + ncerr = nf90_inquire_dimension(fh, d_grdidlen, len = d_grdidlen_len) + if (ncerr .ne. 0) return + + ! Read scalar variables. + ncerr = nf90_inq_varid(fh, VNAME_NK, v_nk) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_nk, NK) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_MTH, v_mth) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_mth, NTH) + if (ncerr .ne. 0) return + + ! Read vars with nopts as a dimension. + ncerr = nf90_inq_varid(fh, VNAME_PTLOC, v_ptloc) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_ptloc, PTLOC) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_PTNME, v_ptnme) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_ptnme, PTNME) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_IW, v_iw) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_iw, IW) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_II, v_ii) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_ii, II) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_IL, v_il) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_il, IL) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_DPO, v_dpo) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_dpo, DPO) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_WAO, v_wao) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_wao, WAO) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_WDO, v_wdo) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_wdo, WDO) + if (ncerr .ne. 0) return +#ifdef W3_FLX5 + ncerr = nf90_inq_varid(fh, VNAME_TAUAO, v_tauao) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_tauao, TAUAO) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_TAIDO, v_taido) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_taido, TAIDO) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_DAIRO, v_dairo) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_dairo, DAIRO) + if (ncerr .ne. 0) return +#endif +#ifdef W3_SETUP + ncerr = nf90_inq_varid(fh, ZET_SETO, v_zet_seto) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_zet_seto, ZET_SETO) + if (ncerr .ne. 0) return +#endif + ncerr = nf90_inq_varid(fh, VNAME_ASO, v_aso) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_aso, ASO) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_CAO, v_cao) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_cao, CAO) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_CDO, v_cdo) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_cdo, CDO) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_ICEO, v_iceo) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_iceo, ICEO) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_ICEHO, v_iceho) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_iceho, ICEHO) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_ICEFO, v_icefo) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_icefo, ICEFO) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_GRDID, v_grdid) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_grdid, GRDID) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_SPCO, v_spco) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_spco, SPCO) + if (ncerr .ne. 0) return + + ! Close the file. + ncerr = nf90_close(fh) + if (ncerr .ne. 0) return + + END SUBROUTINE W3IOPON_READ + + !/ ------------------------------------------------------------------- / + !> + !> @brief Write point output in netCDF format. + !> + !> @param[in] IMOD Model number for W3GDAT etc. + !> @param[in] filename Name of file to write. + !> @param[in] timestep_only Will be 0 if whole model run should be + !> written, 1 if only one timestep should be written. + !> @param[inout] ncerr Error code, 0 for success, netCDF error code + !> otherwise. + !> + !> @author Edward Hartnett @date 1-Nov-2023 + !> + SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) + use netcdf + USE W3GDATMD, ONLY: NTH, NK, NSPEC, FILEXT + USE W3ODATMD, ONLY: NDST, NDSE, IPASS => IPASS2, NOPTS, IPTINT, & + IL, IW, II, PTLOC, PTIFAC, DPO, WAO, WDO, & + ASO, CAO, CDO, SPCO, PTNME, O2INIT, FNMPRE, & + GRDID, ICEO, ICEHO, ICEFO +#ifdef W3_FLX5 + USE W3ODATMD, ONLY: TAUAO, TAUDO, DAIRO +#endif +#ifdef W3_SETUP + USE W3ODATMD, ONLY: ZET_SETO +#endif + + IMPLICIT NONE + integer, intent(in) :: timestep_only ! 1 if only timestep should be written. + INTEGER, INTENT(IN) :: IMOD + character(*), intent(in) :: filename + integer, intent(inout) :: ncerr + integer :: fh, ndim, nvar, fmt + integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen + integer :: v_idtst, v_vertst, v_nk, v_mth, v_ptloc, v_ptnme + integer :: v_iw, v_ii, v_il, v_dpo, v_wao, v_wdo, v_tauao + integer :: v_taido, v_dairo, v_zet_seto, v_aso, v_cao, v_cdo, v_iceo + integer :: v_iceho, v_icefo, v_grdid, v_spco + character (len = *), parameter :: FILE_NAME = "f90tst_nc4.nc" + CHARACTER(LEN=31), PARAMETER :: IDSTR = 'WAVEWATCH III POINT OUTPUT FILE' + CHARACTER(LEN=10), PARAMETER :: VEROPT = '2021-04-06' + + print *, 'WRITE ',filename, len(filename) + + ! Create the netCDF file. + ncerr = nf90_create(filename, NF90_NETCDF4, fh) + if (ncerr .ne. 0) return + + ! Define dimensions. + ncerr = nf90_def_dim(fh, DNAME_NOPTS, NOPTS, d_nopts) + if (ncerr .ne. 0) return + ncerr = nf90_def_dim(fh, DNAME_NSPEC, NSPEC, d_nspec) + if (ncerr .ne. 0) return + ncerr = nf90_def_dim(fh, DNAME_VSIZE, 2, d_vsize) + if (ncerr .ne. 0) return + ncerr = nf90_def_dim(fh, DNAME_NAMELEN, 40, d_namelen) + if (ncerr .ne. 0) return + ncerr = nf90_def_dim(fh, DNAME_GRDIDLEN, 13, d_grdidlen) + if (ncerr .ne. 0) return + + ! Define global attributes. + ncerr = nf90_put_att(fh, NF90_GLOBAL, 'title', IDSTR) + if (ncerr .ne. 0) return + ncerr = nf90_put_att(fh, NF90_GLOBAL, 'version', VEROPT) + if (ncerr .ne. 0) return + + ! Define scalar variables. + ncerr = nf90_def_var(fh, VNAME_NK, NF90_INT, v_nk) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_MTH, NF90_INT, v_mth) + if (ncerr .ne. 0) return + + ! Define vars with nopts as a dimension. + ncerr = nf90_def_var(fh, VNAME_PTLOC, NF90_INT, (/d_vsize, d_nopts/), v_ptloc) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_PTNME, NF90_CHAR, (/d_namelen, d_nopts/), v_ptnme) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_IW, NF90_INT, (/d_nopts/), v_iw) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_II, NF90_INT, (/d_nopts/), v_ii) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_IL, NF90_INT, (/d_nopts/), v_il) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_DPO, NF90_INT, (/d_nopts/), v_dpo) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_WAO, NF90_INT, (/d_nopts/), v_wao) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_WDO, NF90_INT, (/d_nopts/), v_wdo) + if (ncerr .ne. 0) return +#ifdef W3_FLX5 + ncerr = nf90_def_var(fh, VNAME_TAUAO, NF90_INT, (/d_nopts/), v_tauao) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_TAIDO, NF90_INT, (/d_nopts/), v_taido) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_DAIRO, NF90_INT, (/d_nopts/), v_dairo) + if (ncerr .ne. 0) return +#endif +#ifdef W3_SETUP + ncerr = nf90_def_var(fh, VNAME_ZET_SETO, NF90_INT, (/d_nopts/), v_zet_seto) + if (ncerr .ne. 0) return +#endif + ncerr = nf90_def_var(fh, VNAME_ASO, NF90_INT, (/d_nopts/), v_aso) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_CAO, NF90_INT, (/d_nopts/), v_cao) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_CDO, NF90_INT, (/d_nopts/), v_cdo) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_ICEO, NF90_INT, (/d_nopts/), v_iceo) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_ICEHO, NF90_INT, (/d_nopts/), v_iceho) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_ICEFO, NF90_INT, (/d_nopts/), v_icefo) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_GRDID, NF90_CHAR, (/d_grdidlen, d_nopts/), v_grdid) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_SPCO, NF90_INT, (/d_nspec, d_nopts/), v_spco) + if (ncerr .ne. 0) return + + ! Write the scalar data. + ncerr = nf90_put_var(fh, v_nk, NK) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_mth, NTH) + if (ncerr .ne. 0) return + + ! Write the data with NOPTS as a dimension. + ncerr = nf90_put_var(fh, v_ptloc, PTLOC) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_ptnme, PTNME) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_iw, IW) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_ii, II) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_il, IL) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_dpo, DPO) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_wao, WAO) + if (ncerr .ne. 0) return +#ifdef W3_FLX5 + ncerr = nf90_put_var(fh, v_tauao, TAUAO) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_taido, TAIDO) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_dairo, DAIRO) + if (ncerr .ne. 0) return +#endif +#ifdef W3_SETUP + ncerr = nf90_put_var(fh, v_zet_seto, ZET_SETO) + if (ncerr .ne. 0) return +#endif + ncerr = nf90_put_var(fh, v_aso, ASO) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_cao, CAO) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_iceo, ICEO) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_iceho, ICEHO) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_icefo, ICEFO) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_grdid, GRDID) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_spco, SPCO) + if (ncerr .ne. 0) return + + ! Close the file. + ncerr = nf90_close(fh) + if (ncerr .ne. 0) return + + END SUBROUTINE W3IOPON_WRITE + + !> Read/write point output in netCDF format. + !> + !> @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 Edward Hartnett @date 1-Nov-2023 + SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD & +#ifdef W3_ASCII + ,NDSOA & +#endif + ) + USE W3GDATMD, ONLY: W3SETG + USE W3WDATMD, ONLY: W3SETW + USE W3ODATMD, ONLY: W3SETO, W3DMO2 + !/ + USE W3GDATMD, ONLY: NTH, NK, NSPEC, FILEXT + USE W3WDATMD, ONLY: TIME + USE W3ODATMD, ONLY: NDST, NDSE, IPASS => IPASS2, NOPTS, IPTINT, & + IW, PTLOC, PTIFAC, WAO, WDO, & + SPCO, PTNME, O2INIT, FNMPRE +#ifdef W3_FLX5 + USE W3ODATMD, ONLY: TAUAO, TAUDO, DAIRO +#endif + USE W3ODATMD, ONLY : OFILES + !/ +#ifdef W3_SETUP + USE W3ODATMD, ONLY: ZET_SETO +#endif + !/ + USE W3SERVMD, ONLY: EXTCDE +#ifdef W3_S + USE W3SERVMD, ONLY: STRACE +#endif + use netcdf + IMPLICIT NONE + + CHARACTER, INTENT(IN) :: INXOUT*(*) + INTEGER, INTENT(IN) :: NDSOP + INTEGER, INTENT(OUT) :: IOTST + INTEGER, INTENT(IN), OPTIONAL :: IMOD +#ifdef W3_ASCII + INTEGER, INTENT(IN), OPTIONAL :: NDSOA +#endif + + INTEGER :: IGRD, MK, MTH + character(len = 124) :: filename + integer :: ncerr + + ! Optimistically assume success. + IOTST = 0 + + ! Has a model number been specified? + IF (PRESENT(IMOD)) THEN + IGRD = IMOD + ELSE + IGRD = 1 + END IF + + CALL W3SETO(IGRD, NDSE, NDST) + CALL W3SETG(IGRD, NDSE, NDST) + CALL W3SETW(IGRD, NDSE, NDST) + + ! INXOUT must be 'READ' or 'WRITE'. + IF (INXOUT .NE. 'READ' .AND. INXOUT .NE. 'WRITE') THEN + WRITE (NDSE, 900) INXOUT + CALL EXTCDE(1) + END IF + + ! Determine filename. + filename = '' + filename = transfer(FNMPRE(:LEN_TRIM(FNMPRE))//'out_pnt_nc.'//FILEXT(:LEN_TRIM(FILEXT)), filename) + !print *, filename + + ! Do a read or a write of the point file. + IF (INXOUT .EQ. 'READ') THEN + CALL W3IOPON_READ(IOTST, IMOD, filename, ncerr) + ELSE + CALL W3IOPON_WRITE(OFILES(2), IMOD, filename, ncerr) + ENDIF + if (ncerr .ne. 0) then + print *, nf90_strerror(ncerr) + CALL EXTCDE(21) + endif + + !/ + !/ End of W3IOPON ----------------------------------------------------- / + !/ + +900 FORMAT (/' *** WAVEWATCH III ERROR IN W3IOPO :'/ & + ' ILEGAL INXOUT VALUE: ',A/) + END SUBROUTINE W3IOPON + !/ ------------------------------------------------------------------- / !> Read or write point output. !> !> This subroutine can either read or write the point output file, @@ -1495,7 +2052,7 @@ SUBROUTINE W3IOPO ( INXOUT, NDSOP, IOTST, IMOD & #endif 'ASO(I), CAO(I), CDO(I), ICEO(I), ICEHO(I):', & ASO(I), CAO(I), CDO(I), ICEO(I), ICEHO(I), & - 'ICEFO(I), GRDID(I), (SPCO(J,I),J=1,NSPEC):', & + 'ICEFO(I), GRDID(I), (SPCO(J,I),J=1,NSPEC):', & ICEFO(I), GRDID(I), (SPCO(J,I),J=1,NSPEC) #endif ELSE From b8c7f62f950c1531ba046f4b3b6eef763a5d0dda Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Thu, 11 Jan 2024 08:26:16 -0700 Subject: [PATCH 003/126] cmake changes --- regtests/unittests/CMakeLists.txt | 17 ++--- regtests/unittests/test_io.F90 | 114 ++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+), 12 deletions(-) create mode 100644 regtests/unittests/test_io.F90 diff --git a/regtests/unittests/CMakeLists.txt b/regtests/unittests/CMakeLists.txt index 69445bfb7..d2dbb6daa 100644 --- a/regtests/unittests/CMakeLists.txt +++ b/regtests/unittests/CMakeLists.txt @@ -12,28 +12,21 @@ function(copy_test_data name) FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) endfunction() -# Some very small test files may be committed to the repo. This -# function copies such a data file to the build directory. -function(copy_test_data_2 srcname destname) - message(STATUS "Copying ${srcname} to ${CMAKE_CURRENT_BINARY_DIR}/${destname}") - file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/data/${srcname}" - DESTINATION "${CMAKE_BINARY_DIR}" - FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) - file(RENAME "${CMAKE_BINARY_DIR}/${srcname}" "${CMAKE_BINARY_DIR}/${destname}") -endfunction() - # Function to build and run a test. function(unit_test name) - add_executable(${name} ${name}.F90) + add_executable(${name} ${name}.F90 util.F90) target_link_libraries(${name} PRIVATE ww3_lib) add_test(NAME ${name} COMMAND ${name}) endfunction() +add_custom_target(create_mod_def ALL ../../bin/ww3_grid COMMENT "Creating mod_def.ww3 file for testing") + # Copy test data files that are in the repo to the build directory. copy_test_data(switch.io) -copy_test_data_2(ww3_grid.inp ww3_grid.inp) +copy_test_data(ww3_grid.inp) # Build and run the tests. unit_test(test_io_points_bin) +#unit_test(test_io) diff --git a/regtests/unittests/test_io.F90 b/regtests/unittests/test_io.F90 new file mode 100644 index 000000000..a4cd52fd8 --- /dev/null +++ b/regtests/unittests/test_io.F90 @@ -0,0 +1,114 @@ +! This is a test for model IO for WW3. +! +! Ed Hartnett 10/14/23 +program test_io + use w3iopomd + use w3gdatmd + use w3wdatmd + use w3odatmd + use w3iogrmd + use w3adatmd + implicit none + + integer, target :: i, j, k, l + integer :: ndsop, iotest, imod, ndstst, ierr, ndsbul, ndsm + integer :: ndstrc, ntrace + real :: m2km + character*7 expected_ptnme + character*6 my_fmt + real :: expected_loc_1 + integer :: write_test_file + + print *, 'Testing WW3 netCDF point file code.' + + ! These are mysterious but have to be called or else the IPASS + ! variable does not exist and w3iopo() crashes. + call w3nmod(1, 6, 6) + call w3setg(1, 6, 6) + call w3ndat(6, 6) + call w3setw(1, 6, 6) + call w3nout(6, 6) + call w3seto(1, 6, 6) + + ndsm = 20 + ndsop = 20 + ndsbul = 0 + ndstrc = 6 + ntrace = 10 + + write (ndso,900) +900 FORMAT (/15X,' *** WAVEWATCH III Point output post.*** '/ & + 15X,'==============================================='/) + + ! Open the file with the output settings for WW3. It is not needed actually. + ! open(ndsi, file = 'ww3_outp.inp', status='old', iostat = ierr) + ! if (ierr .ne. 0) stop 10 + + ! Create a point output file needed for this test. + print *, 'Creating point output test file for this test...' + if (write_test_file() .ne. 0) stop 1 + + ! 2. Read model definition file. + CALL W3IOGR('READ', NDSM) + WRITE (NDSO,920) GNAME +920 FORMAT (' Grid name : ',A/) + + ! IF (FLAGLL) THEN + ! M2KM = 1. + ! ELSE + ! M2KM = 1.E-3 + ! END IF + + ! Read the file out_pnt.ww3 from the model/tests/data directory. + print *, 'OK!' + print *, 'Reading the point output test file for this test...' + call w3iopo('READ', ndsop, iotest) + if (iotest .ne. 0) stop 10 + close(ndsop) + + ! Make sure we got the values we expected. + if (nopts .ne. 11) stop 11 + expected_loc_1 = 0.0 + do i = 1, nopts + ! Check ptnme and ptloc arrays. + print *, ptnme(i), ptloc(1, i), ptloc(2, i) + if (i .lt. 10) then + my_fmt = '(a,i1)' + else + my_fmt = '(a,i2)' + endif + write(fmt = my_fmt, unit=expected_ptnme) 'Point', i + if (ptnme(i) .ne. expected_ptnme) stop 20 + print *, expected_loc_1 + if (ptloc(1, i) .ne. expected_loc_1) stop 21 + expected_loc_1 = expected_loc_1 + 5000.0 + if (ptloc(2, i) .ne. 0) stop 22 + end do + + print *, 'OK!' + print *, 'initializing some data...' + do i = 1, nopts + do j = 1, nspec + spco(j, i) = 0.0 + end do + end do + + print *, 'OK!' + print *, 'testing writing the WW3 binary point file in netCDF...' + + ! Write in netCDF. + call w3iopon('WRITE', ndsop, iotest) + if (iotest .ne. 0) stop 100 + print *, 'OK!' + + print *, 'testing reading the WW3 binary point file in netCDF...' + call w3iopon('READ', ndsop, iotest) + print *, iotest + if (iotest .ne. 0) stop 100 + print *, 'OK!' + + print *, 'OK!' + + print *, 'SUCCESS!' +end program test_io + From a49486f6626ac1f30b2af3a9f976ae5b016a4ad9 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Thu, 11 Jan 2024 08:27:00 -0700 Subject: [PATCH 004/126] cmake changes --- regtests/unittests/util.F90 | 75 +++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 regtests/unittests/util.F90 diff --git a/regtests/unittests/util.F90 b/regtests/unittests/util.F90 new file mode 100644 index 000000000..fe20ddb30 --- /dev/null +++ b/regtests/unittests/util.F90 @@ -0,0 +1,75 @@ +! This is test code for the WW3 I/O unit tests. +! +! This file holds a function used by multiple tests. +! +! Ed Hartnett, 1/11/24 +integer function write_test_file() + implicit none + + integer :: ntlu, nk, nth, nopts + character(len=10), parameter :: veropt = '2021-04-06' + character(len=31), parameter :: idstr = 'WAVEWATCH III POINT OUTPUT FILE' + real :: ptloc(2,11) = reshape((/ 0., 0., 5000., 0., 10000., 0., 15000., 0., & + 20000., 0., 25000., 0., 30000., 0., 35000., 0., 40000., 0., 45000., 0., 50000., 0. /), & + (/ 2, 11 /)) + character*40 ptnme(11) + integer :: time(2) = (/ 19680606, 0 /) + integer :: nspec = 72 + integer :: iw(11) = (/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /) + integer :: ii(11) = (/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /) + integer :: il(11) = (/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /) + real :: iceo(11) = (/ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. /) + real :: iceho(11) = (/ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. /) + real :: icefo(11) = (/ 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000. /) + real :: dpo(11) = (/ 50., 50., 45., 40., 35., 30., 25., 20., 15., 10., 5. /) + real :: wao(11) = (/ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. /) + real :: wdo(11) = (/ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. /) + real :: aso(11) = (/ -999.900024, -999.900024, -999.900024, -999.900024, -999.900024, & + -999.900024, -999.900024, -999.900024, -999.900024, -999.900024, -999.900024 /) + real :: cao(11) = (/ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. /) + real :: cdo(11) = (/ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. /) + character*13 :: grdid(11) + real :: spco(72, 11) + integer :: i, j + integer :: ierr + + ! Initialize some values. + ntlu = 21 + nk = 3 + nth = 24 + nopts = 11 + do i = 1, nopts + if (i .le. 9) then + write(ptnme(i), '(a,i1)') 'Point', i + else + write(ptnme(i), '(a,i2)') 'Point', i + endif + grdid(i) = 'ww3 ' + end do + + ! Open the file. + open(ntlu, file="out_pnt.ww3", form="unformatted", status="replace", & + action="write", convert="big_endian", iostat=ierr) + if (ierr .ne. 0) stop 111 + + ! Write our values. + write (ntlu, iostat=ierr) idstr, veropt, nk, nth, nopts + if (ierr .ne. 0) stop 112 + write (ntlu, iostat=ierr) ((ptloc(j,i),j=1,2),i=1,nopts), (ptnme(i),i=1,nopts) + if (ierr .ne. 0) stop 113 + write (ntlu, iostat=ierr) time + if (ierr .ne. 0) stop 114 + do i=1, nopts + write (ntlu, iostat=ierr) iw(i), ii(i), il(i), dpo(i), wao(i), wdo(i), & + aso(i), cao(i), cdo(i), iceo(i), iceho(i), & + icefo(i), grdid(i), (spco(j,i),j=1,nspec) + if (ierr .ne. 0) stop 115 + enddo + + ! Close the file. + close(ntlu) + + ! We're done! + write_test_file = 0 +end function write_test_file + From 051a773c3a43a9d34809ab6ea0b0e20d1ea11b30 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Thu, 11 Jan 2024 08:35:31 -0700 Subject: [PATCH 005/126] cmake changes --- .github/workflows/io_gnu_yml.old | 2 -- regtests/unittests/CMakeLists.txt | 5 ++++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/io_gnu_yml.old b/.github/workflows/io_gnu_yml.old index def5a1402..0f89e4ad4 100644 --- a/.github/workflows/io_gnu_yml.old +++ b/.github/workflows/io_gnu_yml.old @@ -106,8 +106,6 @@ jobs: 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 diff --git a/regtests/unittests/CMakeLists.txt b/regtests/unittests/CMakeLists.txt index d2dbb6daa..4210f0b11 100644 --- a/regtests/unittests/CMakeLists.txt +++ b/regtests/unittests/CMakeLists.txt @@ -19,7 +19,10 @@ function(unit_test name) add_test(NAME ${name} COMMAND ${name}) endfunction() -add_custom_target(create_mod_def ALL ../../bin/ww3_grid COMMENT "Creating mod_def.ww3 file for testing") +# The binary file mod_def.ww3 is needed for testing. It's created by +# the ww3_grid utility. +add_custom_target(create_mod_def ALL ../../bin/ww3_grid + COMMENT "Creating mod_def.ww3 file for testing") # Copy test data files that are in the repo to the build directory. copy_test_data(switch.io) From b199a1f68a3d7034a4f16d0c1f76c78bbd168b8d Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Thu, 11 Jan 2024 08:47:37 -0700 Subject: [PATCH 006/126] cmake changes --- regtests/unittests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/regtests/unittests/CMakeLists.txt b/regtests/unittests/CMakeLists.txt index 4210f0b11..cf14179d6 100644 --- a/regtests/unittests/CMakeLists.txt +++ b/regtests/unittests/CMakeLists.txt @@ -21,7 +21,7 @@ endfunction() # The binary file mod_def.ww3 is needed for testing. It's created by # the ww3_grid utility. -add_custom_target(create_mod_def ALL ../../bin/ww3_grid +add_custom_target(create_mod_def TEST ../../bin/ww3_grid COMMENT "Creating mod_def.ww3 file for testing") # Copy test data files that are in the repo to the build directory. From cd3430ac933776289acce8410a6a7d23bb9ebe88 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Thu, 11 Jan 2024 09:34:04 -0700 Subject: [PATCH 007/126] cmake changes --- .github/workflows/io_gnu_yml.old | 2 ++ regtests/unittests/CMakeLists.txt | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/io_gnu_yml.old b/.github/workflows/io_gnu_yml.old index 0f89e4ad4..def5a1402 100644 --- a/.github/workflows/io_gnu_yml.old +++ b/.github/workflows/io_gnu_yml.old @@ -106,6 +106,8 @@ jobs: 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 diff --git a/regtests/unittests/CMakeLists.txt b/regtests/unittests/CMakeLists.txt index cf14179d6..d9b20afeb 100644 --- a/regtests/unittests/CMakeLists.txt +++ b/regtests/unittests/CMakeLists.txt @@ -21,8 +21,8 @@ endfunction() # The binary file mod_def.ww3 is needed for testing. It's created by # the ww3_grid utility. -add_custom_target(create_mod_def TEST ../../bin/ww3_grid - COMMENT "Creating mod_def.ww3 file for testing") +#add_custom_target(create_mod_def TEST ../../bin/ww3_grid +# COMMENT "Creating mod_def.ww3 file for testing") # Copy test data files that are in the repo to the build directory. copy_test_data(switch.io) From 735e15d2175c7653587c6096180ec85bf3f615f3 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Thu, 11 Jan 2024 10:22:07 -0700 Subject: [PATCH 008/126] cmake changes --- regtests/unittests/test_io_points_bin.F90 | 71 ----------------------- 1 file changed, 71 deletions(-) diff --git a/regtests/unittests/test_io_points_bin.F90 b/regtests/unittests/test_io_points_bin.F90 index 69c197bce..4093b24ba 100644 --- a/regtests/unittests/test_io_points_bin.F90 +++ b/regtests/unittests/test_io_points_bin.F90 @@ -79,74 +79,3 @@ program test_io_points_bin print *, 'OK!' print *, 'SUCCESS!' end program test_io_points_bin - -integer function write_test_file() - implicit none - - integer :: ntlu, nk, nth, nopts - character(len=10), parameter :: veropt = '2021-04-06' - character(len=31), parameter :: idstr = 'WAVEWATCH III POINT OUTPUT FILE' - real :: ptloc(2,11) = reshape((/ 0., 0., 5000., 0., 10000., 0., 15000., 0., & - 20000., 0., 25000., 0., 30000., 0., 35000., 0., 40000., 0., 45000., 0., 50000., 0. /), & - (/ 2, 11 /)) - character*40 ptnme(11) - integer :: time(2) = (/ 19680606, 0 /) - integer :: nspec = 72 - integer :: iw(11) = (/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /) - integer :: ii(11) = (/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /) - integer :: il(11) = (/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /) - real :: iceo(11) = (/ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. /) - real :: iceho(11) = (/ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. /) - real :: icefo(11) = (/ 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000. /) - real :: dpo(11) = (/ 50., 50., 45., 40., 35., 30., 25., 20., 15., 10., 5. /) - real :: wao(11) = (/ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. /) - real :: wdo(11) = (/ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. /) - real :: aso(11) = (/ -999.900024, -999.900024, -999.900024, -999.900024, -999.900024, & - -999.900024, -999.900024, -999.900024, -999.900024, -999.900024, -999.900024 /) - real :: cao(11) = (/ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. /) - real :: cdo(11) = (/ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. /) - character*13 :: grdid(11) - real :: spco(72, 11) - integer :: i, j - integer :: ierr - - ! Initialize some values. - ntlu = 21 - nk = 3 - nth = 24 - nopts = 11 - do i = 1, nopts - if (i .le. 9) then - write(ptnme(i), '(a,i1)') 'Point', i - else - write(ptnme(i), '(a,i2)') 'Point', i - endif - grdid(i) = 'ww3 ' - end do - - ! Open the file. - open(ntlu, file="out_pnt.ww3", form="unformatted", status="replace", & - action="write", convert="big_endian", iostat=ierr) - if (ierr .ne. 0) stop 111 - - ! Write our values. - write (ntlu, iostat=ierr) idstr, veropt, nk, nth, nopts - if (ierr .ne. 0) stop 112 - write (ntlu, iostat=ierr) ((ptloc(j,i),j=1,2),i=1,nopts), (ptnme(i),i=1,nopts) - if (ierr .ne. 0) stop 113 - write (ntlu, iostat=ierr) time - if (ierr .ne. 0) stop 114 - do i=1, nopts - write (ntlu, iostat=ierr) iw(i), ii(i), il(i), dpo(i), wao(i), wdo(i), & - aso(i), cao(i), cdo(i), iceo(i), iceho(i), & - icefo(i), grdid(i), (spco(j,i),j=1,nspec) - if (ierr .ne. 0) stop 115 - enddo - - ! Close the file. - close(ntlu) - - ! We're done! - write_test_file = 0 -end function write_test_file - From 330ad8eb7b4098c4f640493067fbcc771666372e Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Thu, 11 Jan 2024 10:57:24 -0700 Subject: [PATCH 009/126] clean up --- model/src/w3iopomd.F90 | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index 552ef06ed..f32f4a89f 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -204,28 +204,6 @@ MODULE W3IOPOMD !> Variable name for the netCDF point output file, for SPCO. character(*), parameter, private :: VNAME_SPCO = 'SPCO' - - - - - - - - - - - - - - - - - - - - - - !/ CONTAINS @@ -1580,6 +1558,7 @@ SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD & 900 FORMAT (/' *** WAVEWATCH III ERROR IN W3IOPO :'/ & ' ILEGAL INXOUT VALUE: ',A/) END SUBROUTINE W3IOPON + !/ ------------------------------------------------------------------- / !> Read or write point output. !> From 4cc5ef257052eb3f12114312adaf5910abf1f115 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Sat, 13 Jan 2024 13:09:22 -0700 Subject: [PATCH 010/126] adding testing for binary restart file --- regtests/unittests/CMakeLists.txt | 1 + regtests/unittests/test_io_restart_bin.F90 | 58 ++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 regtests/unittests/test_io_restart_bin.F90 diff --git a/regtests/unittests/CMakeLists.txt b/regtests/unittests/CMakeLists.txt index 69445bfb7..706441408 100644 --- a/regtests/unittests/CMakeLists.txt +++ b/regtests/unittests/CMakeLists.txt @@ -35,5 +35,6 @@ copy_test_data_2(ww3_grid.inp ww3_grid.inp) # Build and run the tests. unit_test(test_io_points_bin) +unit_test(test_io_restart_bin) diff --git a/regtests/unittests/test_io_restart_bin.F90 b/regtests/unittests/test_io_restart_bin.F90 new file mode 100644 index 000000000..f8dc393a3 --- /dev/null +++ b/regtests/unittests/test_io_restart_bin.F90 @@ -0,0 +1,58 @@ +! This is a test for model IO for WW3. This tests the legacy (binary) +! output of restart data, done by function W3IORS(). +! +! Ed Hartnett 1/13/24 +program test_io_restart_bin + use w3iopomd + use w3gdatmd + use w3wdatmd + use w3odatmd + use w3iogrmd + use w3adatmd + implicit none + + integer, target :: i + integer :: ndsop, iotest, ndsbul, ndsm + integer :: ndstrc, ntrace + character*7 expected_ptnme + character*6 my_fmt + real :: expected_loc_1 + integer :: ndsr = 11 + real :: dumfpi = 99.9 + + print *, 'Testing WW3 binary restart file code.' + + ! These are mysterious but have to be called or else the IPASS + ! variable does not exist and w3iopo() crashes. + call w3nmod(1, 6, 6) + call w3setg(1, 6, 6) + call w3ndat(6, 6) + call w3setw(1, 6, 6) + call w3nout(6, 6) + call w3seto(1, 6, 6) + + ndsm = 20 + ndsop = 20 + ndsbul = 0 + ndstrc = 6 + ntrace = 10 + + write (ndso,900) +900 FORMAT (/15X,' *** WAVEWATCH III Point output post.*** '/ & + 15X,'==============================================='/) + + ! 2. Read model definition file. + CALL W3IOGR('READ', NDSM) + WRITE (NDSO,920) GNAME +920 FORMAT (' Grid name : ',A/) + + ! Read the file out_pnt.ww3 from the model/tests/data directory. + call w3iors('WRITE', ndsr, dumfpi) + if (iotest .ne. 0) stop 10 + close(ndsop) + + + print *, 'OK!' + print *, 'SUCCESS!' +end program test_io_restart_bin + From 431e8c58ac45deca6d00c44c75dc1517064dc82d Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Sat, 13 Jan 2024 13:13:18 -0700 Subject: [PATCH 011/126] working on test --- .github/workflows/{io_gnu_yml.old => io_gnu.yml} | 0 regtests/unittests/test_io_restart_bin.F90 | 3 ++- 2 files changed, 2 insertions(+), 1 deletion(-) rename .github/workflows/{io_gnu_yml.old => io_gnu.yml} (100%) diff --git a/.github/workflows/io_gnu_yml.old b/.github/workflows/io_gnu.yml similarity index 100% rename from .github/workflows/io_gnu_yml.old rename to .github/workflows/io_gnu.yml diff --git a/regtests/unittests/test_io_restart_bin.F90 b/regtests/unittests/test_io_restart_bin.F90 index f8dc393a3..f5cfc42fc 100644 --- a/regtests/unittests/test_io_restart_bin.F90 +++ b/regtests/unittests/test_io_restart_bin.F90 @@ -3,6 +3,7 @@ ! ! Ed Hartnett 1/13/24 program test_io_restart_bin + use w3iorsmd use w3iopomd use w3gdatmd use w3wdatmd @@ -47,7 +48,7 @@ program test_io_restart_bin 920 FORMAT (' Grid name : ',A/) ! Read the file out_pnt.ww3 from the model/tests/data directory. - call w3iors('WRITE', ndsr, dumfpi) + call w3iors('HOT', ndsr, dumfpi) if (iotest .ne. 0) stop 10 close(ndsop) From 5a3c0b970c094c05aebd4f6ce27286dda46a0041 Mon Sep 17 00:00:00 2001 From: Matthew Masarik Date: Thu, 8 Feb 2024 22:22:55 +0000 Subject: [PATCH 012/126] ww3_outp.F90: hard-coded new subroutine (W3IOPON) --- model/src/ww3_outp.F90 | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/model/src/ww3_outp.F90 b/model/src/ww3_outp.F90 index 6d750687a..54c3fc130 100644 --- a/model/src/ww3_outp.F90 +++ b/model/src/ww3_outp.F90 @@ -208,7 +208,9 @@ PROGRAM W3OUTP #endif USE W3ODATMD, ONLY: W3SETO, W3NOUT USE W3IOGRMD, ONLY: W3IOGR - USE W3IOPOMD, ONLY: W3IOPO + !!!MTM + !!! USE W3IOPOMD, ONLY: W3IOPO + USE W3IOPOMD, ONLY: W3IOPO, W3IOPON USE W3SERVMD, ONLY : ITRACE, NEXTLN, EXTCDE #ifdef W3_S USE W3SERVMD, ONLY : STRACE @@ -359,7 +361,9 @@ PROGRAM W3OUTP !--- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! 3. Read general data and first fields from file ! - CALL W3IOPO ( 'READ', NDSOP, IOTEST ) + !!!MTM + !!!CALL W3IOPO ( 'READ', NDSOP, IOTEST ) + CALL W3IOPON ( 'READ', NDSOP, IOTEST ) ! WRITE (NDSO,930) DO I=1, NOPTS @@ -457,7 +461,9 @@ PROGRAM W3OUTP DO CALL STME21 ( TIME , IDTIME ) WRITE (NDSO,948) IDTIME - CALL W3IOPO ( 'READ', NDSOP, IOTEST ) + !!!MTM + !!! CALL W3IOPO ( 'READ', NDSOP, IOTEST ) + CALL W3IOPON ( 'READ', NDSOP, IOTEST ) IF ( IOTEST .EQ. -1 ) THEN WRITE (NDSO,949) GOTO 888 @@ -777,7 +783,9 @@ PROGRAM W3OUTP DO DTEST = DSEC21 ( TIME , TOUT ) IF ( DTEST .GT. 0. ) THEN - CALL W3IOPO ( 'READ', NDSOP, IOTEST ) + !!!MTM + !!! CALL W3IOPO ( 'READ', NDSOP, IOTEST ) + CALL W3IOPON ( 'READ', NDSOP, IOTEST ) IF ( IOTEST .EQ. -1 ) THEN WRITE (NDSO,949) EXIT From edaf3f794cdc9360b7c3578ee290a8ed9bf419d6 Mon Sep 17 00:00:00 2001 From: Matthew Masarik Date: Wed, 14 Feb 2024 18:27:59 +0000 Subject: [PATCH 013/126] gx_outp.F90 - W3IOPON --- model/src/gx_outp.F90 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/model/src/gx_outp.F90 b/model/src/gx_outp.F90 index d34fdbaa7..dacfa69db 100644 --- a/model/src/gx_outp.F90 +++ b/model/src/gx_outp.F90 @@ -165,7 +165,11 @@ PROGRAM GXOUTP #endif USE W3ODATMD, ONLY: W3SETO, W3NOUT USE W3IOGRMD, ONLY: W3IOGR - USE W3IOPOMD, ONLY: W3IOPO + !!!MTM + !!!USE W3IOPOMD, ONLY: W3IOPO + USE W3IOPOMD + USE netcdf + USE W3SERVMD, ONLY : ITRACE, NEXTLN, EXTCDE #ifdef W3_S USE W3SERVMD, ONLY : STRACE @@ -277,7 +281,7 @@ PROGRAM GXOUTP !--- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! 3. Read general data and first fields from file ! - CALL W3IOPO ( 'READ', NDSOP, IOTEST ) + CALL W3IOPON ( 'READ', NDSOP, IOTEST ) ALLOCATE ( FLREQ(NOPTS) ) ! WRITE (NDSO,930) @@ -369,7 +373,7 @@ PROGRAM GXOUTP DO DTEST = DSEC21 ( TIME , TOUT ) IF ( DTEST .GT. 0. ) THEN - CALL W3IOPO ( 'READ', NDSOP, IOTEST ) + CALL W3IOPON ( 'READ', NDSOP, IOTEST ) IF ( IOTEST .EQ. -1 ) THEN WRITE (NDSO,998) EXIT From faaa0c731d674801ad97ec9c4b6dd5ca98739215 Mon Sep 17 00:00:00 2001 From: Matthew Masarik Date: Wed, 14 Feb 2024 18:28:30 +0000 Subject: [PATCH 014/126] w3wavemd.F90: W3IOPON --- model/src/w3wavemd.F90 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/model/src/w3wavemd.F90 b/model/src/w3wavemd.F90 index c144ab8d8..095e800de 100644 --- a/model/src/w3wavemd.F90 +++ b/model/src/w3wavemd.F90 @@ -442,6 +442,8 @@ SUBROUTINE W3WAVE ( IMOD, ODAT, TEND, STAMP, NO_OUT & USE W3IOGRMD USE W3IOGOMD USE W3IOPOMD + USE netcdf + !!!MTM USE W3IOTRMD USE W3IORSMD USE W3IOBCMD @@ -2601,7 +2603,7 @@ SUBROUTINE W3WAVE ( IMOD, ODAT, TEND, STAMP, NO_OUT & ! Gets the necessary spectral data ! CALL W3IOPE ( VA ) - CALL W3IOPO ( 'WRITE', NDS(8), ITEST, IMOD & + CALL W3IOPON ( 'WRITE', NDS(8), ITEST, IMOD & #ifdef W3_ASCII ,NDS(15) & #endif From 86a5233aafb1dde459c8cf6ce58e87c5e61afbc0 Mon Sep 17 00:00:00 2001 From: Matthew Masarik Date: Wed, 14 Feb 2024 18:28:56 +0000 Subject: [PATCH 015/126] wmiopomd.F90: W3IOPON --- model/src/wmiopomd.F90 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/model/src/wmiopomd.F90 b/model/src/wmiopomd.F90 index 73e036535..6de789165 100644 --- a/model/src/wmiopomd.F90 +++ b/model/src/wmiopomd.F90 @@ -714,7 +714,9 @@ SUBROUTINE WMIOPO ( TOUT ) USE W3ODATMD, ONLY: W3SETO USE WMMDATMD, ONLY: WMSETM USE W3CSPCMD, ONLY: W3CSPC - USE W3IOPOMD, ONLY: W3IOPO + USE W3IOPOMD + USE netcdf + !!! MTM ! USE W3GDATMD, ONLY: NK, NTH, NSPEC, XFR, FR1, TH, SGRDS USE W3WDATMD, ONLY: TIME @@ -1176,9 +1178,9 @@ SUBROUTINE WMIOPO ( TOUT ) ! TIME = TOUT ! - CALL W3IOPO ( 'WRITE', MDSUP, II, 0 & + CALL W3IOPON ( 'WRITE', MDSUP, II, 0 & #ifdef W3_ASCII - ,MDSUPA & + ,MDSUPA & #endif ) ! From bafe7ea2f9f1d023230edabbb82d54ac1dfae7ae Mon Sep 17 00:00:00 2001 From: Matthew Masarik Date: Wed, 14 Feb 2024 18:29:18 +0000 Subject: [PATCH 016/126] ww3_ounp.F90: W3IOPON --- model/src/ww3_ounp.F90 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/model/src/ww3_ounp.F90 b/model/src/ww3_ounp.F90 index c35ff6e98..68426d004 100644 --- a/model/src/ww3_ounp.F90 +++ b/model/src/ww3_ounp.F90 @@ -184,7 +184,9 @@ PROGRAM W3OUNP USE W3ODATMD, ONLY: W3SETO, W3NOUT USE W3ODATMD, ONLY: IAPROC, NAPROC, NAPERR, NAPOUT, DIMP USE W3IOGRMD, ONLY: W3IOGR - USE W3IOPOMD, ONLY: W3IOPO + USE W3IOPOMD + USE netcdf + !!!MTM USE W3SERVMD, ONLY : ITRACE, NEXTLN, EXTCDE, STRSPLIT #ifdef W3_S USE W3SERVMD, ONLY : STRACE @@ -387,7 +389,7 @@ PROGRAM W3OUNP !--- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! 3. Read general data and first fields from file ! - CALL W3IOPO ( 'READ', NDSOP, IOTEST ) + CALL W3IOPON ( 'READ', NDSOP, IOTEST ) ! IF ( IAPROC .EQ. NAPOUT ) WRITE (NDSO,930) DO I=1, NOPTS @@ -604,7 +606,7 @@ PROGRAM W3OUNP DO WHILE (DTEST.NE.0) DTEST = DSEC21 ( TIME , TOUT ) IF ( DTEST .GT. 0. ) THEN - CALL W3IOPO ( 'READ', NDSOP, IOTEST ) + CALL W3IOPON ( 'READ', NDSOP, IOTEST ) IF ( IOTEST .EQ. -1 ) THEN IF ( IAPROC .EQ. NAPOUT ) WRITE (NDSO,949) GOTO 888 @@ -1070,7 +1072,7 @@ PROGRAM W3OUNP DTEST = DSEC21 ( TIME , TOUT ) IF ( DTEST .GT. 0. ) THEN ! reads TIME from out_pnt.ww3 - CALL W3IOPO ( 'READ', NDSOP, IOTEST ) + CALL W3IOPON ( 'READ', NDSOP, IOTEST ) IF ( IOTEST .EQ. -1 ) THEN IF ( IAPROC .EQ. NAPOUT ) WRITE (NDSO,949) GOTO 700 @@ -1215,7 +1217,7 @@ PROGRAM W3OUNP ! 7.3 Reinitiazes TIME (close open out_pnt.ww3) and TOUT to process a new bunch of stations CLOSE(NDSOP) ! closes binary file out_pnt* IPASS = 0 ! resets time counter for binary file out_pnt* - CALL W3IOPO ( 'READ', NDSOP, IOTEST ) + CALL W3IOPON ( 'READ', NDSOP, IOTEST ) #ifdef W3_T WRITE(NDSE,*) 'out_pnt* closed and reopened' #endif @@ -1228,7 +1230,7 @@ PROGRAM W3OUNP DO WHILE (DTEST.NE.0) DTEST = DSEC21 ( TIME , TOUT ) IF ( DTEST .GT. 0. ) THEN - CALL W3IOPO ( 'READ', NDSOP, IOTEST ) + CALL W3IOPON ( 'READ', NDSOP, IOTEST ) IF ( IOTEST .EQ. -1 ) THEN IF ( IAPROC .EQ. NAPOUT ) WRITE (NDSO,949) GOTO 700 From a65e4a8d49c8e15739564f77b4963046956df989 Mon Sep 17 00:00:00 2001 From: Matthew Masarik Date: Wed, 14 Feb 2024 18:30:12 +0000 Subject: [PATCH 017/126] ww3_outp.F90: W3IOPON --- model/src/ww3_outp.F90 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/model/src/ww3_outp.F90 b/model/src/ww3_outp.F90 index 54c3fc130..8313f3516 100644 --- a/model/src/ww3_outp.F90 +++ b/model/src/ww3_outp.F90 @@ -210,7 +210,9 @@ PROGRAM W3OUTP USE W3IOGRMD, ONLY: W3IOGR !!!MTM !!! USE W3IOPOMD, ONLY: W3IOPO - USE W3IOPOMD, ONLY: W3IOPO, W3IOPON + USE W3IOPOMD, ONLY: W3IOPO, W3IOPON, W3IOPON_READ, W3IOPON_WRITE + USE netcdf + !!!MTM USE W3SERVMD, ONLY : ITRACE, NEXTLN, EXTCDE #ifdef W3_S USE W3SERVMD, ONLY : STRACE From 2ef2d5115cbc3e70642cf543b6d292f15fe17c54 Mon Sep 17 00:00:00 2001 From: Matthew Masarik Date: Wed, 14 Feb 2024 18:59:12 +0000 Subject: [PATCH 018/126] w3iopomd.F90: print statement --- model/src/w3iopomd.F90 | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index f32f4a89f..ff1e086b0 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -122,19 +122,19 @@ MODULE W3IOPOMD !> Dimension name for the netCDF point output file, for NOPTS, the !> Number of Output Points. character(*), parameter, private :: DNAME_NOPTS = 'NOPTS' - + !> Dimension name for the netCDF point output file, for NSPEC. character(*), parameter, private :: DNAME_NSPEC = 'NSPEC' - + !> Dimension name for the netCDF point output file, for VSIZE. This !> is for the vector size for points, which is 2. character(*), parameter, private :: DNAME_VSIZE = 'VSIZE' - + !> Dimension name for the netCDF point output file, for !> NAMELEN. This is the length of the PTNME strings, which contains !> the names of the points. character(*), parameter, private :: DNAME_NAMELEN = 'NAMELEN' - + !> Dimension name for the netCDF point output file, for GRDIDLEN, !> this is the length of the GRDID character array. character(*), parameter, private :: DNAME_GRDIDLEN = 'GRDIDLEN' @@ -204,7 +204,7 @@ MODULE W3IOPOMD !> Variable name for the netCDF point output file, for SPCO. character(*), parameter, private :: VNAME_SPCO = 'SPCO' - + !/ CONTAINS !/ ------------------------------------------------------------------- / @@ -1141,8 +1141,8 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr) character(*), intent(in) :: filename integer, intent(inout) :: ncerr integer :: fh - integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen - integer :: d_nopts_len, d_nspec_len, d_vsize_len, d_namelen_len, d_grdidlen_len + integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen + integer :: d_nopts_len, d_nspec_len, d_vsize_len, d_namelen_len, d_grdidlen_len integer :: v_idtst, v_vertst, v_nk, v_mth, v_ptloc, v_ptnme integer :: v_iw, v_ii, v_il, v_dpo, v_wao, v_wdo, v_tauao integer :: v_taido, v_dairo, v_zet_seto, v_aso, v_cao, v_cdo, v_iceo @@ -1150,7 +1150,7 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr) print *,filename IOTST = 0 - + ! Open the netCDF file. ncerr = nf90_open(filename, NF90_NOWRITE, fh) if (ncerr .ne. 0) return @@ -1241,13 +1241,13 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr) if (ncerr .ne. 0) return ncerr = nf90_get_var(fh, v_dairo, DAIRO) if (ncerr .ne. 0) return -#endif +#endif #ifdef W3_SETUP ncerr = nf90_inq_varid(fh, ZET_SETO, v_zet_seto) if (ncerr .ne. 0) return ncerr = nf90_get_var(fh, v_zet_seto, ZET_SETO) if (ncerr .ne. 0) return -#endif +#endif ncerr = nf90_inq_varid(fh, VNAME_ASO, v_aso) if (ncerr .ne. 0) return ncerr = nf90_get_var(fh, v_aso, ASO) @@ -1280,11 +1280,11 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr) if (ncerr .ne. 0) return ncerr = nf90_get_var(fh, v_spco, SPCO) if (ncerr .ne. 0) return - + ! Close the file. ncerr = nf90_close(fh) if (ncerr .ne. 0) return - + END SUBROUTINE W3IOPON_READ !/ ------------------------------------------------------------------- / @@ -1313,7 +1313,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) #ifdef W3_SETUP USE W3ODATMD, ONLY: ZET_SETO #endif - + IMPLICIT NONE integer, intent(in) :: timestep_only ! 1 if only timestep should be written. INTEGER, INTENT(IN) :: IMOD @@ -1329,7 +1329,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) CHARACTER(LEN=31), PARAMETER :: IDSTR = 'WAVEWATCH III POINT OUTPUT FILE' CHARACTER(LEN=10), PARAMETER :: VEROPT = '2021-04-06' - print *, 'WRITE ',filename, len(filename) +!!!MTM print *, 'WRITE ',filename, len(filename) ! Create the netCDF file. ncerr = nf90_create(filename, NF90_NETCDF4, fh) @@ -1352,7 +1352,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) if (ncerr .ne. 0) return ncerr = nf90_put_att(fh, NF90_GLOBAL, 'version', VEROPT) if (ncerr .ne. 0) return - + ! Define scalar variables. ncerr = nf90_def_var(fh, VNAME_NK, NF90_INT, v_nk) if (ncerr .ne. 0) return @@ -1383,11 +1383,11 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) if (ncerr .ne. 0) return ncerr = nf90_def_var(fh, VNAME_DAIRO, NF90_INT, (/d_nopts/), v_dairo) if (ncerr .ne. 0) return -#endif +#endif #ifdef W3_SETUP ncerr = nf90_def_var(fh, VNAME_ZET_SETO, NF90_INT, (/d_nopts/), v_zet_seto) if (ncerr .ne. 0) return -#endif +#endif ncerr = nf90_def_var(fh, VNAME_ASO, NF90_INT, (/d_nopts/), v_aso) if (ncerr .ne. 0) return ncerr = nf90_def_var(fh, VNAME_CAO, NF90_INT, (/d_nopts/), v_cao) @@ -1539,7 +1539,7 @@ SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD & filename = '' filename = transfer(FNMPRE(:LEN_TRIM(FNMPRE))//'out_pnt_nc.'//FILEXT(:LEN_TRIM(FILEXT)), filename) !print *, filename - + ! Do a read or a write of the point file. IF (INXOUT .EQ. 'READ') THEN CALL W3IOPON_READ(IOTST, IMOD, filename, ncerr) @@ -1548,9 +1548,9 @@ SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD & ENDIF if (ncerr .ne. 0) then print *, nf90_strerror(ncerr) - CALL EXTCDE(21) + CALL EXTCDE(21) endif - + !/ !/ End of W3IOPON ----------------------------------------------------- / !/ @@ -1558,7 +1558,7 @@ SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD & 900 FORMAT (/' *** WAVEWATCH III ERROR IN W3IOPO :'/ & ' ILEGAL INXOUT VALUE: ',A/) END SUBROUTINE W3IOPON - + !/ ------------------------------------------------------------------- / !> Read or write point output. !> From e7e176b423e0eef6e482fb782c4a3cc0f699c7db Mon Sep 17 00:00:00 2001 From: Jessica Meixner Date: Wed, 21 Feb 2024 16:41:35 +0000 Subject: [PATCH 019/126] small modifications to w3iopo for netcdf file name and removing print --- model/src/w3iopomd.F90 | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index ff1e086b0..39fbc7b79 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -1122,7 +1122,7 @@ END SUBROUTINE W3IOPE !> @author Edward Hartnett @date 1-Nov-2023 !> SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr) - use netcdf + USE NetCDF USE W3GDATMD, ONLY: NTH, NK, NSPEC, FILEXT USE W3ODATMD, ONLY: NDST, NDSE, IPASS => IPASS2, NOPTS, IPTINT, & IL, IW, II, PTLOC, PTIFAC, DPO, WAO, WDO, & @@ -1148,7 +1148,6 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr) integer :: v_taido, v_dairo, v_zet_seto, v_aso, v_cao, v_cdo, v_iceo integer :: v_iceho, v_icefo, v_grdid, v_spco - print *,filename IOTST = 0 ! Open the netCDF file. @@ -1325,12 +1324,9 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) integer :: v_iw, v_ii, v_il, v_dpo, v_wao, v_wdo, v_tauao integer :: v_taido, v_dairo, v_zet_seto, v_aso, v_cao, v_cdo, v_iceo integer :: v_iceho, v_icefo, v_grdid, v_spco - character (len = *), parameter :: FILE_NAME = "f90tst_nc4.nc" CHARACTER(LEN=31), PARAMETER :: IDSTR = 'WAVEWATCH III POINT OUTPUT FILE' CHARACTER(LEN=10), PARAMETER :: VEROPT = '2021-04-06' -!!!MTM print *, 'WRITE ',filename, len(filename) - ! Create the netCDF file. ncerr = nf90_create(filename, NF90_NETCDF4, fh) if (ncerr .ne. 0) return @@ -1537,8 +1533,7 @@ SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD & ! Determine filename. filename = '' - filename = transfer(FNMPRE(:LEN_TRIM(FNMPRE))//'out_pnt_nc.'//FILEXT(:LEN_TRIM(FILEXT)), filename) - !print *, filename + filename = transfer(FNMPRE(:LEN_TRIM(FNMPRE))//'out_pnt.'//FILEXT(:LEN_TRIM(FILEXT))//'.nc', filename) ! Do a read or a write of the point file. IF (INXOUT .EQ. 'READ') THEN From 24c9e9fe0fe653c22e17ec10c3484e594554a1fb Mon Sep 17 00:00:00 2001 From: Jessica Meixner Date: Thu, 22 Feb 2024 15:37:12 +0000 Subject: [PATCH 020/126] updates to documentation --- model/src/w3iopomd.F90 | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index 39fbc7b79..660d400fb 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -65,7 +65,7 @@ MODULE W3IOPOMD ! Name Type Scope Description ! ---------------------------------------------------------------- ! VEROPT C*10 Private Point output file version number. - ! IDSTR C*32 Private Point output file ID string. + ! IDSTR C*31 Private Point output file ID string. ! ---------------------------------------------------------------- ! ! 3. Subroutines and functions : @@ -1324,8 +1324,8 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) integer :: v_iw, v_ii, v_il, v_dpo, v_wao, v_wdo, v_tauao integer :: v_taido, v_dairo, v_zet_seto, v_aso, v_cao, v_cdo, v_iceo integer :: v_iceho, v_icefo, v_grdid, v_spco - CHARACTER(LEN=31), PARAMETER :: IDSTR = 'WAVEWATCH III POINT OUTPUT FILE' - CHARACTER(LEN=10), PARAMETER :: VEROPT = '2021-04-06' +!!JDM - defined in module above CHARACTER(LEN=31), PARAMETER :: IDSTR = 'WAVEWATCH III POINT OUTPUT FILE' +!!JDM - defined in module above CHARACTER(LEN=10), PARAMETER :: VEROPT = '2021-04-06' ! Create the netCDF file. ncerr = nf90_create(filename, NF90_NETCDF4, fh) @@ -1576,8 +1576,8 @@ END SUBROUTINE W3IOPON !> -------------|------|----------|-------- !> 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 | NK | Number of discrete wavenumbers + !> 4 | integer | NTH | Number of discrete directions. !> 4 | integer | NOPTS | Number of output points. !> 8*NOPTS | integer(2,NOPTS) | PTLOC | Point locations !> 7*NOPTS | character*7 | PTNME | Point names @@ -1785,7 +1785,7 @@ SUBROUTINE W3IOPO ( INXOUT, NDSOP, IOTST, IMOD & CALL EXTCDE ( 1 ) END IF ! - ! IF ( IPASS.EQ.1 ) THEN + ! First pass to this file and we are only writing 1 file for all time IF ( IPASS.EQ.1 .AND. OFILES(2) .EQ. 0) THEN WRITE = INXOUT.EQ.'WRITE' ELSE @@ -1798,10 +1798,10 @@ SUBROUTINE W3IOPO ( INXOUT, NDSOP, IOTST, IMOD & ! open file ---------------------------------------------------------- * ! IF ( IPASS.EQ.1 .AND. OFILES(2) .EQ. 0 ) THEN - ! + I = LEN_TRIM(FILEXT) J = LEN_TRIM(FNMPRE) - ! + #ifdef W3_T WRITE (NDST,9001) FNMPRE(:J)//'out_pnt.'//FILEXT(:I) #endif @@ -1920,7 +1920,7 @@ SUBROUTINE W3IOPO ( INXOUT, NDSOP, IOTST, IMOD & ! IF ( WRITE ) THEN WRITE (NDSOP) & - IDSTR, VEROPT, NK, NTH, NOPTS + eDSTR, VEROPT, NK, NTH, NOPTS #ifdef W3_ASCII WRITE (NDSOA,*) & 'IDSTR, VEROPT, NK, NTH, NOPTS:', & @@ -1942,6 +1942,7 @@ SUBROUTINE W3IOPO ( INXOUT, NDSOP, IOTST, IMOD & WRITE (NDSE,904) MK, MTH, NK, NTH CALL EXTCDE ( 12 ) END IF + !JDM: what is this???? IF ( .NOT. O2INIT ) & CALL W3DMO2 ( IGRD, NDSE, NDST, NOPTS ) END IF From 3b244cbc8a7baeb383792dd254ebe362a73ac185 Mon Sep 17 00:00:00 2001 From: Jessica Meixner Date: Tue, 12 Mar 2024 20:45:45 +0000 Subject: [PATCH 021/126] added notes for where time should be added and examined how things varied from binary version to add warnings etc --- model/src/w3iopomd.F90 | 364 ++++++++++++++++++++++++----------------- 1 file changed, 218 insertions(+), 146 deletions(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index 660d400fb..3f2044dde 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -1143,66 +1143,91 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr) integer :: fh integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen integer :: d_nopts_len, d_nspec_len, d_vsize_len, d_namelen_len, d_grdidlen_len - integer :: v_idtst, v_vertst, v_nk, v_mth, v_ptloc, v_ptnme + integer :: v_idtst, v_vertst, v_nk, v_nth, v_ptloc, v_ptnme integer :: v_iw, v_ii, v_il, v_dpo, v_wao, v_wdo, v_tauao integer :: v_taido, v_dairo, v_zet_seto, v_aso, v_cao, v_cdo, v_iceo integer :: v_iceho, v_icefo, v_grdid, v_spco IOTST = 0 + IF ( IPASS.EQ.1 ) THEN + ! Open the netCDF file. + ncerr = nf90_open(filename, NF90_NOWRITE, fh) + if (ncerr .ne. 0) return + + ! Read and check the version: + ! TO DO add reading of IDTST and VERTST and make checks: + ! IF ( IDTST .NE. IDSTR ) THEN + ! WRITE (NDSE,902) IDTST, IDSTR + ! CALL EXTCDE ( 10 ) + ! END IF + ! IF ( VERTST .NE. VEROPT ) THEN + ! WRITE (NDSE,903) VERTST, VEROPT + ! CALL EXTCDE ( 11 ) + ! END IF + + + ! Read the dimension information for NOPTS. + ncerr = nf90_inq_dimid(fh, DNAME_NOPTS, d_nopts) + if (ncerr .ne. 0) return + ncerr = nf90_inquire_dimension(fh, d_nopts, len = d_nopts_len) + if (ncerr .ne. 0) return + + ! Read the dimension information for NSPEC. + ncerr = nf90_inq_dimid(fh, DNAME_NSPEC, d_nspec) + if (ncerr .ne. 0) return + ncerr = nf90_inquire_dimension(fh, d_nspec, len = d_nspec_len) + if (ncerr .ne. 0) return + + ! Read the dimension information for VSIZE. + ncerr = nf90_inq_dimid(fh, DNAME_VSIZE, d_vsize) + if (ncerr .ne. 0) return + ncerr = nf90_inquire_dimension(fh, d_vsize, len = d_vsize_len) + if (ncerr .ne. 0) return + + ! Read the dimension information for NAMELEN. + ncerr = nf90_inq_dimid(fh, DNAME_NAMELEN, d_namelen) + if (ncerr .ne. 0) return + ncerr = nf90_inquire_dimension(fh, d_namelen, len = d_namelen_len) + if (ncerr .ne. 0) return + + ! Read the dimension information for GRDIDLEN. + ncerr = nf90_inq_dimid(fh, DNAME_GRDIDLEN, d_grdidlen) + if (ncerr .ne. 0) return + ncerr = nf90_inquire_dimension(fh, d_grdidlen, len = d_grdidlen_len) + if (ncerr .ne. 0) return + + ! Read scalar variables. + ncerr = nf90_inq_varid(fh, VNAME_NK, v_nk) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_nk, MK) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_NTH, v_nth) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_nth, MTH) + if (ncerr .ne. 0) return + + !read in written variables NK, NTH as MK and MTH + !and ensure they match + IF (NK.NE.MK .OR. NTH.NE.MTH) THEN + WRITE (NDSE,904) MK, MTH, NK, NTH + CALL EXTCDE ( 12 ) + END IF - ! Open the netCDF file. - ncerr = nf90_open(filename, NF90_NOWRITE, fh) - if (ncerr .ne. 0) return - - ! Read the dimension information for NOPTS. - ncerr = nf90_inq_dimid(fh, DNAME_NOPTS, d_nopts) - if (ncerr .ne. 0) return - ncerr = nf90_inquire_dimension(fh, d_nopts, len = d_nopts_len) - if (ncerr .ne. 0) return - - ! Read the dimension information for NSPEC. - ncerr = nf90_inq_dimid(fh, DNAME_NSPEC, d_nspec) - if (ncerr .ne. 0) return - ncerr = nf90_inquire_dimension(fh, d_nspec, len = d_nspec_len) - if (ncerr .ne. 0) return - - ! Read the dimension information for VSIZE. - ncerr = nf90_inq_dimid(fh, DNAME_VSIZE, d_vsize) - if (ncerr .ne. 0) return - ncerr = nf90_inquire_dimension(fh, d_vsize, len = d_vsize_len) - if (ncerr .ne. 0) return - - ! Read the dimension information for NAMELEN. - ncerr = nf90_inq_dimid(fh, DNAME_NAMELEN, d_namelen) - if (ncerr .ne. 0) return - ncerr = nf90_inquire_dimension(fh, d_namelen, len = d_namelen_len) - if (ncerr .ne. 0) return - - ! Read the dimension information for GRDIDLEN. - ncerr = nf90_inq_dimid(fh, DNAME_GRDIDLEN, d_grdidlen) - if (ncerr .ne. 0) return - ncerr = nf90_inquire_dimension(fh, d_grdidlen, len = d_grdidlen_len) - if (ncerr .ne. 0) return + ! Read vars with nopts as a dimension. + ncerr = nf90_inq_varid(fh, VNAME_PTLOC, v_ptloc) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_ptloc, PTLOC) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_PTNME, v_ptnme) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_ptnme, PTNME) + if (ncerr .ne. 0) return + END IF - ! Read scalar variables. - ncerr = nf90_inq_varid(fh, VNAME_NK, v_nk) - if (ncerr .ne. 0) return - ncerr = nf90_get_var(fh, v_nk, NK) - if (ncerr .ne. 0) return - ncerr = nf90_inq_varid(fh, VNAME_MTH, v_mth) - if (ncerr .ne. 0) return - ncerr = nf90_get_var(fh, v_mth, NTH) - if (ncerr .ne. 0) return + !missing variable TIME??? - ! Read vars with nopts as a dimension. - ncerr = nf90_inq_varid(fh, VNAME_PTLOC, v_ptloc) - if (ncerr .ne. 0) return - ncerr = nf90_get_var(fh, v_ptloc, PTLOC) - if (ncerr .ne. 0) return - ncerr = nf90_inq_varid(fh, VNAME_PTNME, v_ptnme) - if (ncerr .ne. 0) return - ncerr = nf90_get_var(fh, v_ptnme, PTNME) - if (ncerr .ne. 0) return + ! All of the below variables are missing the "time" dimension... + ! the time dimension being read should be for "IPASS" ncerr = nf90_inq_varid(fh, VNAME_IW, v_iw) if (ncerr .ne. 0) return ncerr = nf90_get_var(fh, v_iw, IW) @@ -1284,6 +1309,14 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr) ncerr = nf90_close(fh) if (ncerr .ne. 0) return +902 FORMAT (/' *** WAVEWATCH III ERROR IN W3IOPON :'/ & + ' ILEGAL IDSTR, READ : ',A/ & + ' CHECK : ',A/) +903 FORMAT (/' *** WAVEWATCH III ERROR IN W3IOPON :'/ & + ' ILEGAL VEROPT, READ : ',A/ & + ' CHECK : ',A/) + + END SUBROUTINE W3IOPON_READ !/ ------------------------------------------------------------------- / @@ -1320,98 +1353,109 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) integer, intent(inout) :: ncerr integer :: fh, ndim, nvar, fmt integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen - integer :: v_idtst, v_vertst, v_nk, v_mth, v_ptloc, v_ptnme + integer :: v_idtst, v_vertst, v_nk, v_nth, v_ptloc, v_ptnme integer :: v_iw, v_ii, v_il, v_dpo, v_wao, v_wdo, v_tauao integer :: v_taido, v_dairo, v_zet_seto, v_aso, v_cao, v_cdo, v_iceo integer :: v_iceho, v_icefo, v_grdid, v_spco !!JDM - defined in module above CHARACTER(LEN=31), PARAMETER :: IDSTR = 'WAVEWATCH III POINT OUTPUT FILE' !!JDM - defined in module above CHARACTER(LEN=10), PARAMETER :: VEROPT = '2021-04-06' - ! Create the netCDF file. - ncerr = nf90_create(filename, NF90_NETCDF4, fh) - if (ncerr .ne. 0) return - - ! Define dimensions. - ncerr = nf90_def_dim(fh, DNAME_NOPTS, NOPTS, d_nopts) - if (ncerr .ne. 0) return - ncerr = nf90_def_dim(fh, DNAME_NSPEC, NSPEC, d_nspec) - if (ncerr .ne. 0) return - ncerr = nf90_def_dim(fh, DNAME_VSIZE, 2, d_vsize) - if (ncerr .ne. 0) return - ncerr = nf90_def_dim(fh, DNAME_NAMELEN, 40, d_namelen) - if (ncerr .ne. 0) return - ncerr = nf90_def_dim(fh, DNAME_GRDIDLEN, 13, d_grdidlen) - if (ncerr .ne. 0) return - - ! Define global attributes. - ncerr = nf90_put_att(fh, NF90_GLOBAL, 'title', IDSTR) - if (ncerr .ne. 0) return - ncerr = nf90_put_att(fh, NF90_GLOBAL, 'version', VEROPT) - if (ncerr .ne. 0) return - - ! Define scalar variables. - ncerr = nf90_def_var(fh, VNAME_NK, NF90_INT, v_nk) - if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_MTH, NF90_INT, v_mth) - if (ncerr .ne. 0) return - - ! Define vars with nopts as a dimension. - ncerr = nf90_def_var(fh, VNAME_PTLOC, NF90_INT, (/d_vsize, d_nopts/), v_ptloc) - if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_PTNME, NF90_CHAR, (/d_namelen, d_nopts/), v_ptnme) - if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_IW, NF90_INT, (/d_nopts/), v_iw) - if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_II, NF90_INT, (/d_nopts/), v_ii) - if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_IL, NF90_INT, (/d_nopts/), v_il) - if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_DPO, NF90_INT, (/d_nopts/), v_dpo) - if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_WAO, NF90_INT, (/d_nopts/), v_wao) - if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_WDO, NF90_INT, (/d_nopts/), v_wdo) - if (ncerr .ne. 0) return + !If first pass, or if you are writting a file for every time-step: + IF ( IPASS.EQ.1 .OR. timestep_only.EQ.1 ) THEN + ! Create the netCDF file. + ncerr = nf90_create(filename, NF90_NETCDF4, fh) + if (ncerr .ne. 0) return + + ! Define dimensions. + ncerr = nf90_def_dim(fh, DNAME_NOPTS, NOPTS, d_nopts) + if (ncerr .ne. 0) return + ncerr = nf90_def_dim(fh, DNAME_NSPEC, NSPEC, d_nspec) + if (ncerr .ne. 0) return + ncerr = nf90_def_dim(fh, DNAME_VSIZE, 2, d_vsize) + if (ncerr .ne. 0) return + ncerr = nf90_def_dim(fh, DNAME_NAMELEN, 40, d_namelen) + if (ncerr .ne. 0) return + ncerr = nf90_def_dim(fh, DNAME_GRDIDLEN, 13, d_grdidlen) + if (ncerr .ne. 0) return + !TO DO: Missing dimension, time! + + ! Define global attributes. + ncerr = nf90_put_att(fh, NF90_GLOBAL, 'title', IDSTR) + if (ncerr .ne. 0) return + ncerr = nf90_put_att(fh, NF90_GLOBAL, 'version', VEROPT) + if (ncerr .ne. 0) return + + ! Define scalar variables. + ncerr = nf90_def_var(fh, VNAME_NK, NF90_INT, v_nk) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_NTH, NF90_INT, v_nth) + if (ncerr .ne. 0) return + + ! Define vars with nopts as a dimension. + ncerr = nf90_def_var(fh, VNAME_PTLOC, NF90_INT, (/d_vsize, d_nopts/), v_ptloc) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_PTNME, NF90_CHAR, (/d_namelen, d_nopts/), v_ptnme) + if (ncerr .ne. 0) return + + !TO DO : Starting here all the varibles below should have a time + !dimension: + ncerr = nf90_def_var(fh, VNAME_IW, NF90_INT, (/d_nopts/), v_iw) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_II, NF90_INT, (/d_nopts/), v_ii) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_IL, NF90_INT, (/d_nopts/), v_il) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_DPO, NF90_INT, (/d_nopts/), v_dpo) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_WAO, NF90_INT, (/d_nopts/), v_wao) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_WDO, NF90_INT, (/d_nopts/), v_wdo) + if (ncerr .ne. 0) return #ifdef W3_FLX5 - ncerr = nf90_def_var(fh, VNAME_TAUAO, NF90_INT, (/d_nopts/), v_tauao) - if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_TAIDO, NF90_INT, (/d_nopts/), v_taido) - if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_DAIRO, NF90_INT, (/d_nopts/), v_dairo) - if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_TAUAO, NF90_INT, (/d_nopts/), v_tauao) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_TAIDO, NF90_INT, (/d_nopts/), v_taido) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_DAIRO, NF90_INT, (/d_nopts/), v_dairo) + if (ncerr .ne. 0) return #endif #ifdef W3_SETUP - ncerr = nf90_def_var(fh, VNAME_ZET_SETO, NF90_INT, (/d_nopts/), v_zet_seto) - if (ncerr .ne. 0) return -#endif - ncerr = nf90_def_var(fh, VNAME_ASO, NF90_INT, (/d_nopts/), v_aso) - if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_CAO, NF90_INT, (/d_nopts/), v_cao) - if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_CDO, NF90_INT, (/d_nopts/), v_cdo) - if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_ICEO, NF90_INT, (/d_nopts/), v_iceo) - if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_ICEHO, NF90_INT, (/d_nopts/), v_iceho) - if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_ICEFO, NF90_INT, (/d_nopts/), v_icefo) - if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_GRDID, NF90_CHAR, (/d_grdidlen, d_nopts/), v_grdid) - if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_SPCO, NF90_INT, (/d_nspec, d_nopts/), v_spco) - if (ncerr .ne. 0) return - - ! Write the scalar data. - ncerr = nf90_put_var(fh, v_nk, NK) - if (ncerr .ne. 0) return - ncerr = nf90_put_var(fh, v_mth, NTH) - if (ncerr .ne. 0) return - - ! Write the data with NOPTS as a dimension. - ncerr = nf90_put_var(fh, v_ptloc, PTLOC) - if (ncerr .ne. 0) return - ncerr = nf90_put_var(fh, v_ptnme, PTNME) - if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_ZET_SETO, NF90_INT, (/d_nopts/), v_zet_seto) + if (ncerr .ne. 0) return +#endif + ncerr = nf90_def_var(fh, VNAME_ASO, NF90_INT, (/d_nopts/), v_aso) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_CAO, NF90_INT, (/d_nopts/), v_cao) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_CDO, NF90_INT, (/d_nopts/), v_cdo) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_ICEO, NF90_INT, (/d_nopts/), v_iceo) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_ICEHO, NF90_INT, (/d_nopts/), v_iceho) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_ICEFO, NF90_INT, (/d_nopts/), v_icefo) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_GRDID, NF90_CHAR, (/d_grdidlen, d_nopts/), v_grdid) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_SPCO, NF90_INT, (/d_nspec, d_nopts/), v_spco) + if (ncerr .ne. 0) return + + ! Write the scalar data. + ncerr = nf90_put_var(fh, v_nk, NK) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_nth, NTH) + if (ncerr .ne. 0) return + + ! Write the data with NOPTS as a dimension. + ncerr = nf90_put_var(fh, v_ptloc, PTLOC) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_ptnme, PTNME) + if (ncerr .ne. 0) return + + END IF + + !!! TO DO: Add variable time and add time as a dimension to all the + !variables below ncerr = nf90_put_var(fh, v_iw, IW) if (ncerr .ne. 0) return ncerr = nf90_put_var(fh, v_ii, II) @@ -1507,10 +1551,17 @@ SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD & INTEGER, INTENT(IN), OPTIONAL :: NDSOA #endif + CHARACTER(LEN=15) :: TIMETAG INTEGER :: IGRD, MK, MTH character(len = 124) :: filename integer :: ncerr +#ifdef W3_S + CALL STRACE (IENT, 'W3IOPON') +#endif + ! IPASS essentially is the time variable dimension + IPASS = IPASS + 1 + ! Optimistically assume success. IOTST = 0 @@ -1529,22 +1580,41 @@ SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD & IF (INXOUT .NE. 'READ' .AND. INXOUT .NE. 'WRITE') THEN WRITE (NDSE, 900) INXOUT CALL EXTCDE(1) - END IF + END IF - ! Determine filename. - filename = '' - filename = transfer(FNMPRE(:LEN_TRIM(FNMPRE))//'out_pnt.'//FILEXT(:LEN_TRIM(FILEXT))//'.nc', filename) +!JDM Not sure this next section is really needed in the necdf context, +!commenting out but leaving it as a placeholder for now + +! ! Ensure read/write are not mixed +! IF ( IPASS.EQ.1 .AND. OFILES(2) .EQ. 0 ) THEN +! WRITE = INXOUT.EQ.'WRITE' +! ELSE +! IF ( WRITE .AND. INXOUT.EQ.'READ' ) THEN +! WRITE (NDSE,901) INXOUT +! CALL EXTCDE ( 2 ) +! END IF +! END IF + + ! Determine filename. + filename = '' + IF ( OFILES(2) .EQ. 1 ) THEN + ! Create TIMETAG for file name using YYYYMMDD.HHMMS prefix + WRITE(TIMETAG,"(i8.8,'.'i6.6)")TIME(1),TIME(2) + filename = transfer(FNMPRE(:LEN_TRIM(FNMPRE))//TIMETAG//'out_pnt.'//FILEXT(:LEN_TRIM(FILEXT))//'.nc', filename) + ELSE + filename = transfer(FNMPRE(:LEN_TRIM(FNMPRE))//'out_pnt.'//FILEXT(:LEN_TRIM(FILEXT))//'.nc', filename) + END IF - ! Do a read or a write of the point file. - IF (INXOUT .EQ. 'READ') THEN + ! Do a read or a write of the point file. + IF (INXOUT .EQ. 'READ') THEN CALL W3IOPON_READ(IOTST, IMOD, filename, ncerr) - ELSE + ELSE CALL W3IOPON_WRITE(OFILES(2), IMOD, filename, ncerr) - ENDIF - if (ncerr .ne. 0) then + ENDIF + if (ncerr .ne. 0) then print *, nf90_strerror(ncerr) CALL EXTCDE(21) - endif + endif !/ !/ End of W3IOPON ----------------------------------------------------- / @@ -1552,6 +1622,8 @@ SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD & 900 FORMAT (/' *** WAVEWATCH III ERROR IN W3IOPO :'/ & ' ILEGAL INXOUT VALUE: ',A/) +901 FORMAT (/' *** WAVEWATCH III ERROR IN W3IOPO :'/ & + ' MIXED READ/WRITE, LAST REQUEST: ',A/) END SUBROUTINE W3IOPON !/ ------------------------------------------------------------------- / @@ -1581,7 +1653,7 @@ END SUBROUTINE W3IOPON !> 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 + !> 8 | integer(2) | TIME | Valid time !> reclen*NOPTS | * | * | records !> !> Each record contains: From f0c8aa923d89c03ce752ad28f20acb6752717066 Mon Sep 17 00:00:00 2001 From: Jessica Meixner Date: Wed, 13 Mar 2024 16:04:12 +0000 Subject: [PATCH 022/126] a first try at adding time dimension --- model/src/w3iopomd.F90 | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index 3f2044dde..218d31a02 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -139,6 +139,10 @@ MODULE W3IOPOMD !> this is the length of the GRDID character array. character(*), parameter, private :: DNAME_GRDIDLEN = 'GRDIDLEN' + !> Dimension name for the netCDF point output file, for TIME. This + !> is unlimited dimensions. + character(*), parameter, private :: DNAME_TIME = 'TIME' + !> Variable name for the netCDF point output file, for NK. character(*), parameter, private :: VNAME_NK = 'NK' @@ -151,6 +155,9 @@ MODULE W3IOPOMD !> Variable name for the netCDF point output file, for PTNME. character(*), parameter, private :: VNAME_PTNME = 'PTNME' + !> Variable name for the netCDF point output file, for TIME. + character(*), parameter, private :: VNAME_TIME = 'TIME' + !> Variable name for the netCDF point output file, for IW. character(*), parameter, private :: VNAME_IW = 'IW' @@ -1352,7 +1359,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) character(*), intent(in) :: filename integer, intent(inout) :: ncerr integer :: fh, ndim, nvar, fmt - integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen + integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen, d_time integer :: v_idtst, v_vertst, v_nk, v_nth, v_ptloc, v_ptnme integer :: v_iw, v_ii, v_il, v_dpo, v_wao, v_wdo, v_tauao integer :: v_taido, v_dairo, v_zet_seto, v_aso, v_cao, v_cdo, v_iceo @@ -1377,7 +1384,8 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) if (ncerr .ne. 0) return ncerr = nf90_def_dim(fh, DNAME_GRDIDLEN, 13, d_grdidlen) if (ncerr .ne. 0) return - !TO DO: Missing dimension, time! + ncerr = nf90_def_dim(fh, DNAME_TIME, NF90_UNLIMITED, d_time) + if (ncerr .ne. 0) return ! Define global attributes. ncerr = nf90_put_att(fh, NF90_GLOBAL, 'title', IDSTR) @@ -1399,7 +1407,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) !TO DO : Starting here all the varibles below should have a time !dimension: - ncerr = nf90_def_var(fh, VNAME_IW, NF90_INT, (/d_nopts/), v_iw) + ncerr = nf90_def_var(fh, VNAME_IW, NF90_INT, (/d_nopts, d_time/), v_iw) if (ncerr .ne. 0) return ncerr = nf90_def_var(fh, VNAME_II, NF90_INT, (/d_nopts/), v_ii) if (ncerr .ne. 0) return From 0307f60c7574f85367d7d285246352bae5cc656a Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Wed, 27 Mar 2024 12:26:09 -0600 Subject: [PATCH 023/126] adding time dimension --- model/src/w3iopomd.F90 | 43 +++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index f32f4a89f..246ab4b71 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -139,6 +139,9 @@ MODULE W3IOPOMD !> this is the length of the GRDID character array. character(*), parameter, private :: DNAME_GRDIDLEN = 'GRDIDLEN' + !> Dimension name for the netCDF point output file, for TIME. + character(*), parameter, private :: DNAME_TIME = 'TIME' + !> Variable name for the netCDF point output file, for NK. character(*), parameter, private :: VNAME_NK = 'NK' @@ -1320,7 +1323,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) character(*), intent(in) :: filename integer, intent(inout) :: ncerr integer :: fh, ndim, nvar, fmt - integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen + integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen, d_time integer :: v_idtst, v_vertst, v_nk, v_mth, v_ptloc, v_ptnme integer :: v_iw, v_ii, v_il, v_dpo, v_wao, v_wdo, v_tauao integer :: v_taido, v_dairo, v_zet_seto, v_aso, v_cao, v_cdo, v_iceo @@ -1346,6 +1349,8 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) if (ncerr .ne. 0) return ncerr = nf90_def_dim(fh, DNAME_GRDIDLEN, 13, d_grdidlen) if (ncerr .ne. 0) return + ncerr = nf90_def_dim(fh, DNAME_TIME, NF90_UNLIMITED, d_time) + if (ncerr .ne. 0) return ! Define global attributes. ncerr = nf90_put_att(fh, NF90_GLOBAL, 'title', IDSTR) @@ -1364,45 +1369,45 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) if (ncerr .ne. 0) return ncerr = nf90_def_var(fh, VNAME_PTNME, NF90_CHAR, (/d_namelen, d_nopts/), v_ptnme) if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_IW, NF90_INT, (/d_nopts/), v_iw) + ncerr = nf90_def_var(fh, VNAME_IW, NF90_INT, (/d_nopts, d_time/), v_iw) if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_II, NF90_INT, (/d_nopts/), v_ii) + ncerr = nf90_def_var(fh, VNAME_II, NF90_INT, (/d_nopts, d_time/), v_ii) if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_IL, NF90_INT, (/d_nopts/), v_il) + ncerr = nf90_def_var(fh, VNAME_IL, NF90_INT, (/d_nopts, d_time/), v_il) if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_DPO, NF90_INT, (/d_nopts/), v_dpo) + ncerr = nf90_def_var(fh, VNAME_DPO, NF90_INT, (/d_nopts, d_time/), v_dpo) if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_WAO, NF90_INT, (/d_nopts/), v_wao) + ncerr = nf90_def_var(fh, VNAME_WAO, NF90_INT, (/d_nopts, d_time/), v_wao) if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_WDO, NF90_INT, (/d_nopts/), v_wdo) + ncerr = nf90_def_var(fh, VNAME_WDO, NF90_INT, (/d_nopts, d_time/), v_wdo) if (ncerr .ne. 0) return #ifdef W3_FLX5 - ncerr = nf90_def_var(fh, VNAME_TAUAO, NF90_INT, (/d_nopts/), v_tauao) + ncerr = nf90_def_var(fh, VNAME_TAUAO, NF90_INT, (/d_nopts, d_time/), v_tauao) if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_TAIDO, NF90_INT, (/d_nopts/), v_taido) + ncerr = nf90_def_var(fh, VNAME_TAIDO, NF90_INT, (/d_nopts, d_time/), v_taido) if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_DAIRO, NF90_INT, (/d_nopts/), v_dairo) + ncerr = nf90_def_var(fh, VNAME_DAIRO, NF90_INT, (/d_nopts, d_time/), v_dairo) if (ncerr .ne. 0) return #endif #ifdef W3_SETUP - ncerr = nf90_def_var(fh, VNAME_ZET_SETO, NF90_INT, (/d_nopts/), v_zet_seto) + ncerr = nf90_def_var(fh, VNAME_ZET_SETO, NF90_INT, (/d_nopts, d_time/), v_zet_seto) if (ncerr .ne. 0) return #endif - ncerr = nf90_def_var(fh, VNAME_ASO, NF90_INT, (/d_nopts/), v_aso) + ncerr = nf90_def_var(fh, VNAME_ASO, NF90_INT, (/d_nopts, d_time/), v_aso) if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_CAO, NF90_INT, (/d_nopts/), v_cao) + ncerr = nf90_def_var(fh, VNAME_CAO, NF90_INT, (/d_nopts, d_time/), v_cao) if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_CDO, NF90_INT, (/d_nopts/), v_cdo) + ncerr = nf90_def_var(fh, VNAME_CDO, NF90_INT, (/d_nopts, d_time/), v_cdo) if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_ICEO, NF90_INT, (/d_nopts/), v_iceo) + ncerr = nf90_def_var(fh, VNAME_ICEO, NF90_INT, (/d_nopts, d_time/), v_iceo) if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_ICEHO, NF90_INT, (/d_nopts/), v_iceho) + ncerr = nf90_def_var(fh, VNAME_ICEHO, NF90_INT, (/d_nopts, d_time/), v_iceho) if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_ICEFO, NF90_INT, (/d_nopts/), v_icefo) + ncerr = nf90_def_var(fh, VNAME_ICEFO, NF90_INT, (/d_nopts, d_time/), v_icefo) if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_GRDID, NF90_CHAR, (/d_grdidlen, d_nopts/), v_grdid) + ncerr = nf90_def_var(fh, VNAME_GRDID, NF90_CHAR, (/d_grdidlen, d_nopts, d_time/), v_grdid) if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_SPCO, NF90_INT, (/d_nspec, d_nopts/), v_spco) + ncerr = nf90_def_var(fh, VNAME_SPCO, NF90_INT, (/d_nspec, d_nopts, d_time/), v_spco) if (ncerr .ne. 0) return ! Write the scalar data. From df4d393ee5f6cf49edc878dd397b44bb7d2c19b2 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Sat, 30 Mar 2024 10:39:26 -0600 Subject: [PATCH 024/126] turning on tests --- .github/workflows/{io_gnu_yml.old => io_gnu.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{io_gnu_yml.old => io_gnu.yml} (100%) diff --git a/.github/workflows/io_gnu_yml.old b/.github/workflows/io_gnu.yml similarity index 100% rename from .github/workflows/io_gnu_yml.old rename to .github/workflows/io_gnu.yml From a24fb35ec93159e611dedc446709e085e315241c Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Sun, 31 Mar 2024 08:25:13 -0600 Subject: [PATCH 025/126] more testing --- regtests/unittests/test_io.F90 | 114 +++++++++++++++++++++ regtests/unittests/test_io_points_bin.F90 | 71 ------------- regtests/unittests/test_io_restart_bin.F90 | 59 +++++++++++ regtests/unittests/util.F90 | 75 ++++++++++++++ 4 files changed, 248 insertions(+), 71 deletions(-) create mode 100644 regtests/unittests/test_io.F90 create mode 100644 regtests/unittests/test_io_restart_bin.F90 create mode 100644 regtests/unittests/util.F90 diff --git a/regtests/unittests/test_io.F90 b/regtests/unittests/test_io.F90 new file mode 100644 index 000000000..a4cd52fd8 --- /dev/null +++ b/regtests/unittests/test_io.F90 @@ -0,0 +1,114 @@ +! This is a test for model IO for WW3. +! +! Ed Hartnett 10/14/23 +program test_io + use w3iopomd + use w3gdatmd + use w3wdatmd + use w3odatmd + use w3iogrmd + use w3adatmd + implicit none + + integer, target :: i, j, k, l + integer :: ndsop, iotest, imod, ndstst, ierr, ndsbul, ndsm + integer :: ndstrc, ntrace + real :: m2km + character*7 expected_ptnme + character*6 my_fmt + real :: expected_loc_1 + integer :: write_test_file + + print *, 'Testing WW3 netCDF point file code.' + + ! These are mysterious but have to be called or else the IPASS + ! variable does not exist and w3iopo() crashes. + call w3nmod(1, 6, 6) + call w3setg(1, 6, 6) + call w3ndat(6, 6) + call w3setw(1, 6, 6) + call w3nout(6, 6) + call w3seto(1, 6, 6) + + ndsm = 20 + ndsop = 20 + ndsbul = 0 + ndstrc = 6 + ntrace = 10 + + write (ndso,900) +900 FORMAT (/15X,' *** WAVEWATCH III Point output post.*** '/ & + 15X,'==============================================='/) + + ! Open the file with the output settings for WW3. It is not needed actually. + ! open(ndsi, file = 'ww3_outp.inp', status='old', iostat = ierr) + ! if (ierr .ne. 0) stop 10 + + ! Create a point output file needed for this test. + print *, 'Creating point output test file for this test...' + if (write_test_file() .ne. 0) stop 1 + + ! 2. Read model definition file. + CALL W3IOGR('READ', NDSM) + WRITE (NDSO,920) GNAME +920 FORMAT (' Grid name : ',A/) + + ! IF (FLAGLL) THEN + ! M2KM = 1. + ! ELSE + ! M2KM = 1.E-3 + ! END IF + + ! Read the file out_pnt.ww3 from the model/tests/data directory. + print *, 'OK!' + print *, 'Reading the point output test file for this test...' + call w3iopo('READ', ndsop, iotest) + if (iotest .ne. 0) stop 10 + close(ndsop) + + ! Make sure we got the values we expected. + if (nopts .ne. 11) stop 11 + expected_loc_1 = 0.0 + do i = 1, nopts + ! Check ptnme and ptloc arrays. + print *, ptnme(i), ptloc(1, i), ptloc(2, i) + if (i .lt. 10) then + my_fmt = '(a,i1)' + else + my_fmt = '(a,i2)' + endif + write(fmt = my_fmt, unit=expected_ptnme) 'Point', i + if (ptnme(i) .ne. expected_ptnme) stop 20 + print *, expected_loc_1 + if (ptloc(1, i) .ne. expected_loc_1) stop 21 + expected_loc_1 = expected_loc_1 + 5000.0 + if (ptloc(2, i) .ne. 0) stop 22 + end do + + print *, 'OK!' + print *, 'initializing some data...' + do i = 1, nopts + do j = 1, nspec + spco(j, i) = 0.0 + end do + end do + + print *, 'OK!' + print *, 'testing writing the WW3 binary point file in netCDF...' + + ! Write in netCDF. + call w3iopon('WRITE', ndsop, iotest) + if (iotest .ne. 0) stop 100 + print *, 'OK!' + + print *, 'testing reading the WW3 binary point file in netCDF...' + call w3iopon('READ', ndsop, iotest) + print *, iotest + if (iotest .ne. 0) stop 100 + print *, 'OK!' + + print *, 'OK!' + + print *, 'SUCCESS!' +end program test_io + diff --git a/regtests/unittests/test_io_points_bin.F90 b/regtests/unittests/test_io_points_bin.F90 index 69c197bce..4093b24ba 100644 --- a/regtests/unittests/test_io_points_bin.F90 +++ b/regtests/unittests/test_io_points_bin.F90 @@ -79,74 +79,3 @@ program test_io_points_bin print *, 'OK!' print *, 'SUCCESS!' end program test_io_points_bin - -integer function write_test_file() - implicit none - - integer :: ntlu, nk, nth, nopts - character(len=10), parameter :: veropt = '2021-04-06' - character(len=31), parameter :: idstr = 'WAVEWATCH III POINT OUTPUT FILE' - real :: ptloc(2,11) = reshape((/ 0., 0., 5000., 0., 10000., 0., 15000., 0., & - 20000., 0., 25000., 0., 30000., 0., 35000., 0., 40000., 0., 45000., 0., 50000., 0. /), & - (/ 2, 11 /)) - character*40 ptnme(11) - integer :: time(2) = (/ 19680606, 0 /) - integer :: nspec = 72 - integer :: iw(11) = (/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /) - integer :: ii(11) = (/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /) - integer :: il(11) = (/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /) - real :: iceo(11) = (/ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. /) - real :: iceho(11) = (/ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. /) - real :: icefo(11) = (/ 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000. /) - real :: dpo(11) = (/ 50., 50., 45., 40., 35., 30., 25., 20., 15., 10., 5. /) - real :: wao(11) = (/ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. /) - real :: wdo(11) = (/ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. /) - real :: aso(11) = (/ -999.900024, -999.900024, -999.900024, -999.900024, -999.900024, & - -999.900024, -999.900024, -999.900024, -999.900024, -999.900024, -999.900024 /) - real :: cao(11) = (/ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. /) - real :: cdo(11) = (/ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. /) - character*13 :: grdid(11) - real :: spco(72, 11) - integer :: i, j - integer :: ierr - - ! Initialize some values. - ntlu = 21 - nk = 3 - nth = 24 - nopts = 11 - do i = 1, nopts - if (i .le. 9) then - write(ptnme(i), '(a,i1)') 'Point', i - else - write(ptnme(i), '(a,i2)') 'Point', i - endif - grdid(i) = 'ww3 ' - end do - - ! Open the file. - open(ntlu, file="out_pnt.ww3", form="unformatted", status="replace", & - action="write", convert="big_endian", iostat=ierr) - if (ierr .ne. 0) stop 111 - - ! Write our values. - write (ntlu, iostat=ierr) idstr, veropt, nk, nth, nopts - if (ierr .ne. 0) stop 112 - write (ntlu, iostat=ierr) ((ptloc(j,i),j=1,2),i=1,nopts), (ptnme(i),i=1,nopts) - if (ierr .ne. 0) stop 113 - write (ntlu, iostat=ierr) time - if (ierr .ne. 0) stop 114 - do i=1, nopts - write (ntlu, iostat=ierr) iw(i), ii(i), il(i), dpo(i), wao(i), wdo(i), & - aso(i), cao(i), cdo(i), iceo(i), iceho(i), & - icefo(i), grdid(i), (spco(j,i),j=1,nspec) - if (ierr .ne. 0) stop 115 - enddo - - ! Close the file. - close(ntlu) - - ! We're done! - write_test_file = 0 -end function write_test_file - diff --git a/regtests/unittests/test_io_restart_bin.F90 b/regtests/unittests/test_io_restart_bin.F90 new file mode 100644 index 000000000..f5cfc42fc --- /dev/null +++ b/regtests/unittests/test_io_restart_bin.F90 @@ -0,0 +1,59 @@ +! This is a test for model IO for WW3. This tests the legacy (binary) +! output of restart data, done by function W3IORS(). +! +! Ed Hartnett 1/13/24 +program test_io_restart_bin + use w3iorsmd + use w3iopomd + use w3gdatmd + use w3wdatmd + use w3odatmd + use w3iogrmd + use w3adatmd + implicit none + + integer, target :: i + integer :: ndsop, iotest, ndsbul, ndsm + integer :: ndstrc, ntrace + character*7 expected_ptnme + character*6 my_fmt + real :: expected_loc_1 + integer :: ndsr = 11 + real :: dumfpi = 99.9 + + print *, 'Testing WW3 binary restart file code.' + + ! These are mysterious but have to be called or else the IPASS + ! variable does not exist and w3iopo() crashes. + call w3nmod(1, 6, 6) + call w3setg(1, 6, 6) + call w3ndat(6, 6) + call w3setw(1, 6, 6) + call w3nout(6, 6) + call w3seto(1, 6, 6) + + ndsm = 20 + ndsop = 20 + ndsbul = 0 + ndstrc = 6 + ntrace = 10 + + write (ndso,900) +900 FORMAT (/15X,' *** WAVEWATCH III Point output post.*** '/ & + 15X,'==============================================='/) + + ! 2. Read model definition file. + CALL W3IOGR('READ', NDSM) + WRITE (NDSO,920) GNAME +920 FORMAT (' Grid name : ',A/) + + ! Read the file out_pnt.ww3 from the model/tests/data directory. + call w3iors('HOT', ndsr, dumfpi) + if (iotest .ne. 0) stop 10 + close(ndsop) + + + print *, 'OK!' + print *, 'SUCCESS!' +end program test_io_restart_bin + diff --git a/regtests/unittests/util.F90 b/regtests/unittests/util.F90 new file mode 100644 index 000000000..fe20ddb30 --- /dev/null +++ b/regtests/unittests/util.F90 @@ -0,0 +1,75 @@ +! This is test code for the WW3 I/O unit tests. +! +! This file holds a function used by multiple tests. +! +! Ed Hartnett, 1/11/24 +integer function write_test_file() + implicit none + + integer :: ntlu, nk, nth, nopts + character(len=10), parameter :: veropt = '2021-04-06' + character(len=31), parameter :: idstr = 'WAVEWATCH III POINT OUTPUT FILE' + real :: ptloc(2,11) = reshape((/ 0., 0., 5000., 0., 10000., 0., 15000., 0., & + 20000., 0., 25000., 0., 30000., 0., 35000., 0., 40000., 0., 45000., 0., 50000., 0. /), & + (/ 2, 11 /)) + character*40 ptnme(11) + integer :: time(2) = (/ 19680606, 0 /) + integer :: nspec = 72 + integer :: iw(11) = (/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /) + integer :: ii(11) = (/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /) + integer :: il(11) = (/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /) + real :: iceo(11) = (/ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. /) + real :: iceho(11) = (/ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. /) + real :: icefo(11) = (/ 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000. /) + real :: dpo(11) = (/ 50., 50., 45., 40., 35., 30., 25., 20., 15., 10., 5. /) + real :: wao(11) = (/ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. /) + real :: wdo(11) = (/ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. /) + real :: aso(11) = (/ -999.900024, -999.900024, -999.900024, -999.900024, -999.900024, & + -999.900024, -999.900024, -999.900024, -999.900024, -999.900024, -999.900024 /) + real :: cao(11) = (/ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. /) + real :: cdo(11) = (/ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. /) + character*13 :: grdid(11) + real :: spco(72, 11) + integer :: i, j + integer :: ierr + + ! Initialize some values. + ntlu = 21 + nk = 3 + nth = 24 + nopts = 11 + do i = 1, nopts + if (i .le. 9) then + write(ptnme(i), '(a,i1)') 'Point', i + else + write(ptnme(i), '(a,i2)') 'Point', i + endif + grdid(i) = 'ww3 ' + end do + + ! Open the file. + open(ntlu, file="out_pnt.ww3", form="unformatted", status="replace", & + action="write", convert="big_endian", iostat=ierr) + if (ierr .ne. 0) stop 111 + + ! Write our values. + write (ntlu, iostat=ierr) idstr, veropt, nk, nth, nopts + if (ierr .ne. 0) stop 112 + write (ntlu, iostat=ierr) ((ptloc(j,i),j=1,2),i=1,nopts), (ptnme(i),i=1,nopts) + if (ierr .ne. 0) stop 113 + write (ntlu, iostat=ierr) time + if (ierr .ne. 0) stop 114 + do i=1, nopts + write (ntlu, iostat=ierr) iw(i), ii(i), il(i), dpo(i), wao(i), wdo(i), & + aso(i), cao(i), cdo(i), iceo(i), iceho(i), & + icefo(i), grdid(i), (spco(j,i),j=1,nspec) + if (ierr .ne. 0) stop 115 + enddo + + ! Close the file. + close(ntlu) + + ! We're done! + write_test_file = 0 +end function write_test_file + From b2b7129983cdb5bbd2505bb0a19a81c102a59b32 Mon Sep 17 00:00:00 2001 From: Ed Date: Mon, 1 Apr 2024 07:44:14 -0600 Subject: [PATCH 026/126] renamed file --- regtests/unittests/CMakeLists.txt | 2 +- regtests/unittests/{util.F90 => ww3_unittest_util.F90} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename regtests/unittests/{util.F90 => ww3_unittest_util.F90} (100%) diff --git a/regtests/unittests/CMakeLists.txt b/regtests/unittests/CMakeLists.txt index 69445bfb7..5ebf1e325 100644 --- a/regtests/unittests/CMakeLists.txt +++ b/regtests/unittests/CMakeLists.txt @@ -24,7 +24,7 @@ endfunction() # Function to build and run a test. function(unit_test name) - add_executable(${name} ${name}.F90) + add_executable(${name} ${name}.F90 ww3_unittest_util.F90) target_link_libraries(${name} PRIVATE ww3_lib) add_test(NAME ${name} COMMAND ${name}) endfunction() diff --git a/regtests/unittests/util.F90 b/regtests/unittests/ww3_unittest_util.F90 similarity index 100% rename from regtests/unittests/util.F90 rename to regtests/unittests/ww3_unittest_util.F90 From d06cdd43b903830149e1c33b1ba475a9c1e05c9a Mon Sep 17 00:00:00 2001 From: Ed Date: Mon, 1 Apr 2024 08:05:38 -0600 Subject: [PATCH 027/126] adding regtest document --- docs/regtests.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 docs/regtests.md diff --git a/docs/regtests.md b/docs/regtests.md new file mode 100644 index 000000000..2d68b2ddc --- /dev/null +++ b/docs/regtests.md @@ -0,0 +1,7 @@ +# How to Run the Regtests + +## Compile WW3 + +## Download Test Data + +## What Next? \ No newline at end of file From ab960edde9bacca262569cf6feef3acaaf004b59 Mon Sep 17 00:00:00 2001 From: Ed Date: Mon, 1 Apr 2024 08:24:41 -0600 Subject: [PATCH 028/126] adding detail --- docs/regtests.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/regtests.md b/docs/regtests.md index 2d68b2ddc..746a67387 100644 --- a/docs/regtests.md +++ b/docs/regtests.md @@ -2,6 +2,16 @@ ## Compile WW3 +Install dependencies with spack as shown in .github/workflow/io_gnu.yml. + +Build WW3 binaries like this: + +cmake -DSWITCH=/home/ed/ww3/regtests/unittests/data/switch.io -DCMAKE_BUILD_TYPE=Debug -DCMAKE_Fortran_FLAGS="-g" -DCMAKE_C_FLAGS="-g" .. +make VERBOSE=1 -j2 +make test + ## Download Test Data +Download the test data by running the shell script: model/bin/ww3_from_ftp.sh. + ## What Next? \ No newline at end of file From f26541e859067b7986f2b74986623ab363d51e63 Mon Sep 17 00:00:00 2001 From: Ed Date: Mon, 1 Apr 2024 09:14:25 -0600 Subject: [PATCH 029/126] more info --- docs/regtests.md | 54 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/docs/regtests.md b/docs/regtests.md index 746a67387..ac5a4e880 100644 --- a/docs/regtests.md +++ b/docs/regtests.md @@ -1,5 +1,52 @@ # How to Run the Regtests +## Set Up Model Environment + +Copy and rename the switch file: +cp /home/ed/WW3/regtests/unittests/data/switch.io model/switch_IO + +Run this command: + +./model/bin/w3_setup /home/ed/WW3/model -c tmpl -s IO + + ***************************** + *** WAVEWATCH III setup *** + ***************************** + + +[INFO] local env file wwatch3.env found in /home/ed/WW3/model/bin/wwatch3.env + Setup file /home/ed/WW3/model/bin/wwatch3.env found + Source directory : /home/ed/WW3/model + Scratch directory : /home/ed/WW3/model/tmp + Save source code : yes + Save listings : yes + Update settings ? [y/n] y + + Creating new set-up : + + Scratch space [/home/ed/WW3/model/tmp] : + Save source code files (*.f) [yes] : + Save listing files [yes] : + + Modified set up : + Scratch directory : /home/ed/WW3/model/tmp + Save sources : yes + Save listings : yes + New settings OK ? [y/n] y + + Setup comp & link files + copy /home/ed/WW3/model/bin/comp.tmpl => /home/ed/WW3/model/bin/comp + copy /home/ed/WW3/model/bin/link.tmpl => /home/ed/WW3/model/bin/link + copy /home/ed/WW3/model/bin/ad3.tmpl => /home/ed/WW3/model/bin/ad3 + + Setup switch file + /home/ed/WW3/model/bin/switch_IO => /home/ed/WW3/model/bin/switch + + Create required model subdirectories + +Finished setting up WAVEWATCH III + + ## Compile WW3 Install dependencies with spack as shown in .github/workflow/io_gnu.yml. @@ -14,4 +61,9 @@ make test Download the test data by running the shell script: model/bin/ww3_from_ftp.sh. -## What Next? \ No newline at end of file + +## What Next? + +## References + +https://github.com/NOAA-EMC/WW3/wiki/Developer-Guide#regression-testing-in-wavewatch-iii \ No newline at end of file From 9366dcaca5b5b7cddc1372b4dd6adf0967ff0988 Mon Sep 17 00:00:00 2001 From: Ed Date: Mon, 1 Apr 2024 11:43:26 -0600 Subject: [PATCH 030/126] added tests to cmake file --- regtests/unittests/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/regtests/unittests/CMakeLists.txt b/regtests/unittests/CMakeLists.txt index 5ebf1e325..34c9a0add 100644 --- a/regtests/unittests/CMakeLists.txt +++ b/regtests/unittests/CMakeLists.txt @@ -35,5 +35,7 @@ copy_test_data_2(ww3_grid.inp ww3_grid.inp) # Build and run the tests. unit_test(test_io_points_bin) +unit_test(test_io) +unit_test(test_io_restart_bin) From 22e0bf4a0ba3a275e92c18a65963f44f9b09e3dd Mon Sep 17 00:00:00 2001 From: Ed Date: Mon, 1 Apr 2024 11:52:59 -0600 Subject: [PATCH 031/126] commenting out some of test --- regtests/unittests/test_io.F90 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/regtests/unittests/test_io.F90 b/regtests/unittests/test_io.F90 index a4cd52fd8..86e333679 100644 --- a/regtests/unittests/test_io.F90 +++ b/regtests/unittests/test_io.F90 @@ -97,15 +97,15 @@ program test_io print *, 'testing writing the WW3 binary point file in netCDF...' ! Write in netCDF. - call w3iopon('WRITE', ndsop, iotest) - if (iotest .ne. 0) stop 100 - print *, 'OK!' + ! call w3iopon('WRITE', ndsop, iotest) + ! if (iotest .ne. 0) stop 100 + ! print *, 'OK!' - print *, 'testing reading the WW3 binary point file in netCDF...' - call w3iopon('READ', ndsop, iotest) - print *, iotest - if (iotest .ne. 0) stop 100 - print *, 'OK!' + ! print *, 'testing reading the WW3 binary point file in netCDF...' + ! call w3iopon('READ', ndsop, iotest) + ! print *, iotest + ! if (iotest .ne. 0) stop 100 + ! print *, 'OK!' print *, 'OK!' From 44c54094ad1f23a4a9924183908e3e983bd94113 Mon Sep 17 00:00:00 2001 From: Ed Date: Mon, 1 Apr 2024 12:00:15 -0600 Subject: [PATCH 032/126] commenting out some of test --- regtests/unittests/test_io_restart_bin.F90 | 66 +++++++++++----------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/regtests/unittests/test_io_restart_bin.F90 b/regtests/unittests/test_io_restart_bin.F90 index f5cfc42fc..026e8d3d2 100644 --- a/regtests/unittests/test_io_restart_bin.F90 +++ b/regtests/unittests/test_io_restart_bin.F90 @@ -12,45 +12,45 @@ program test_io_restart_bin use w3adatmd implicit none - integer, target :: i - integer :: ndsop, iotest, ndsbul, ndsm - integer :: ndstrc, ntrace - character*7 expected_ptnme - character*6 my_fmt - real :: expected_loc_1 - integer :: ndsr = 11 - real :: dumfpi = 99.9 +! integer, target :: i +! integer :: ndsop, iotest, ndsbul, ndsm +! integer :: ndstrc, ntrace +! character*7 expected_ptnme +! character*6 my_fmt +! real :: expected_loc_1 +! integer :: ndsr = 11 +! real :: dumfpi = 99.9 - print *, 'Testing WW3 binary restart file code.' +! print *, 'Testing WW3 binary restart file code.' - ! These are mysterious but have to be called or else the IPASS - ! variable does not exist and w3iopo() crashes. - call w3nmod(1, 6, 6) - call w3setg(1, 6, 6) - call w3ndat(6, 6) - call w3setw(1, 6, 6) - call w3nout(6, 6) - call w3seto(1, 6, 6) +! ! These are mysterious but have to be called or else the IPASS +! ! variable does not exist and w3iopo() crashes. +! call w3nmod(1, 6, 6) +! call w3setg(1, 6, 6) +! call w3ndat(6, 6) +! call w3setw(1, 6, 6) +! call w3nout(6, 6) +! call w3seto(1, 6, 6) - ndsm = 20 - ndsop = 20 - ndsbul = 0 - ndstrc = 6 - ntrace = 10 +! ndsm = 20 +! ndsop = 20 +! ndsbul = 0 +! ndstrc = 6 +! ntrace = 10 - write (ndso,900) -900 FORMAT (/15X,' *** WAVEWATCH III Point output post.*** '/ & - 15X,'==============================================='/) +! write (ndso,900) +! 900 FORMAT (/15X,' *** WAVEWATCH III Point output post.*** '/ & +! 15X,'==============================================='/) - ! 2. Read model definition file. - CALL W3IOGR('READ', NDSM) - WRITE (NDSO,920) GNAME -920 FORMAT (' Grid name : ',A/) +! ! 2. Read model definition file. +! CALL W3IOGR('READ', NDSM) +! WRITE (NDSO,920) GNAME +! 920 FORMAT (' Grid name : ',A/) - ! Read the file out_pnt.ww3 from the model/tests/data directory. - call w3iors('HOT', ndsr, dumfpi) - if (iotest .ne. 0) stop 10 - close(ndsop) +! ! Read the file out_pnt.ww3 from the model/tests/data directory. +! call w3iors('HOT', ndsr, dumfpi) +! if (iotest .ne. 0) stop 10 +! close(ndsop) print *, 'OK!' From 3c44e61cfd732368fd5bd8b98e5b1691b948758b Mon Sep 17 00:00:00 2001 From: Ed Date: Mon, 1 Apr 2024 12:27:28 -0600 Subject: [PATCH 033/126] added netCDF code --- model/src/w3iopomd.F90 | 543 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 542 insertions(+), 1 deletion(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index 0c15ea8c6..246ab4b71 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -118,6 +118,96 @@ MODULE W3IOPOMD CHARACTER(LEN=10), PARAMETER, PRIVATE :: VEROPT = '2021-04-06' CHARACTER(LEN=31), PARAMETER, PRIVATE :: & IDSTR = 'WAVEWATCH III POINT OUTPUT FILE' + + !> Dimension name for the netCDF point output file, for NOPTS, the + !> Number of Output Points. + character(*), parameter, private :: DNAME_NOPTS = 'NOPTS' + + !> Dimension name for the netCDF point output file, for NSPEC. + character(*), parameter, private :: DNAME_NSPEC = 'NSPEC' + + !> Dimension name for the netCDF point output file, for VSIZE. This + !> is for the vector size for points, which is 2. + character(*), parameter, private :: DNAME_VSIZE = 'VSIZE' + + !> Dimension name for the netCDF point output file, for + !> NAMELEN. This is the length of the PTNME strings, which contains + !> the names of the points. + character(*), parameter, private :: DNAME_NAMELEN = 'NAMELEN' + + !> Dimension name for the netCDF point output file, for GRDIDLEN, + !> this is the length of the GRDID character array. + character(*), parameter, private :: DNAME_GRDIDLEN = 'GRDIDLEN' + + !> Dimension name for the netCDF point output file, for TIME. + character(*), parameter, private :: DNAME_TIME = 'TIME' + + !> Variable name for the netCDF point output file, for NK. + character(*), parameter, private :: VNAME_NK = 'NK' + + !> Variable name for the netCDF point output file, for MTH. + character(*), parameter, private :: VNAME_MTH = 'MTH' + + !> Variable name for the netCDF point output file, for PTLOC. + character(*), parameter, private :: VNAME_PTLOC = 'PTLOC' + + !> Variable name for the netCDF point output file, for PTNME. + character(*), parameter, private :: VNAME_PTNME = 'PTNME' + + !> Variable name for the netCDF point output file, for IW. + character(*), parameter, private :: VNAME_IW = 'IW' + + !> Variable name for the netCDF point output file, for II. + character(*), parameter, private :: VNAME_II = 'II' + + !> Variable name for the netCDF point output file, for IL. + character(*), parameter, private :: VNAME_IL = 'IL' + + !> Variable name for the netCDF point output file, for DPO. + character(*), parameter, private :: VNAME_DPO = 'DPO' + + !> Variable name for the netCDF point output file, for WAO. + character(*), parameter, private :: VNAME_WAO = 'WAO' + + !> Variable name for the netCDF point output file, for WDO. + character(*), parameter, private :: VNAME_WDO = 'WDO' + + !> Variable name for the netCDF point output file, for TAUAO. + character(*), parameter, private :: VNAME_TAUAO = 'TAUAO' + + !> Variable name for the netCDF point output file, for TAIDO. + character(*), parameter, private :: VNAME_TAIDO = 'TAIDO' + + !> Variable name for the netCDF point output file, for DAIRO. + character(*), parameter, private :: VNAME_DAIRO = 'DAIRO' + + !> Variable name for the netCDF point output file, for ZET_SETO. + character(*), parameter, private :: VNAME_ZET_SETO = 'ZET_SETO' + + !> Variable name for the netCDF point output file, for ASO. + character(*), parameter, private :: VNAME_ASO = 'ASO' + + !> Variable name for the netCDF point output file, for CAO. + character(*), parameter, private :: VNAME_CAO = 'CAO' + + !> Variable name for the netCDF point output file, for CDO. + character(*), parameter, private :: VNAME_CDO = 'CDO' + + !> Variable name for the netCDF point output file, for ICEO. + character(*), parameter, private :: VNAME_ICEO = 'ICEO' + + !> Variable name for the netCDF point output file, for ICEHO. + character(*), parameter, private :: VNAME_ICEHO = 'ICEHO' + + !> Variable name for the netCDF point output file, for ICEFO. + character(*), parameter, private :: VNAME_ICEFO = 'ICEFO' + + !> Variable name for the netCDF point output file, for GRDID. + character(*), parameter, private :: VNAME_GRDID = 'GRDID' + + !> Variable name for the netCDF point output file, for SPCO. + character(*), parameter, private :: VNAME_SPCO = 'SPCO' + !/ CONTAINS !/ ------------------------------------------------------------------- / @@ -1024,6 +1114,457 @@ SUBROUTINE W3IOPE ( A ) !/ END SUBROUTINE W3IOPE + !> Read point output in netCDF format. + !> + !> @param[out] IOTST Test indictor for reading. + !> @param[in] IMOD Model number for W3GDAT etc. + !> @param[in] filename Name of file to read. + !> @param[inout] ncerr Error code, 0 for success, netCDF error code + !> otherwise. + !> + !> @author Edward Hartnett @date 1-Nov-2023 + !> + SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr) + use netcdf + USE W3GDATMD, ONLY: NTH, NK, NSPEC, FILEXT + USE W3ODATMD, ONLY: NDST, NDSE, IPASS => IPASS2, NOPTS, IPTINT, & + IL, IW, II, PTLOC, PTIFAC, DPO, WAO, WDO, & + ASO, CAO, CDO, SPCO, PTNME, O2INIT, FNMPRE, & + GRDID, ICEO, ICEHO, ICEFO +#ifdef W3_FLX5 + USE W3ODATMD, ONLY: TAUAO, TAUDO, DAIRO +#endif +#ifdef W3_SETUP + USE W3ODATMD, ONLY: ZET_SETO +#endif + IMPLICIT NONE + + INTEGER, INTENT(OUT) :: IOTST + INTEGER, INTENT(IN), OPTIONAL :: IMOD + character(*), intent(in) :: filename + integer, intent(inout) :: ncerr + integer :: fh + integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen + integer :: d_nopts_len, d_nspec_len, d_vsize_len, d_namelen_len, d_grdidlen_len + integer :: v_idtst, v_vertst, v_nk, v_mth, v_ptloc, v_ptnme + integer :: v_iw, v_ii, v_il, v_dpo, v_wao, v_wdo, v_tauao + integer :: v_taido, v_dairo, v_zet_seto, v_aso, v_cao, v_cdo, v_iceo + integer :: v_iceho, v_icefo, v_grdid, v_spco + + print *,filename + IOTST = 0 + + ! Open the netCDF file. + ncerr = nf90_open(filename, NF90_NOWRITE, fh) + if (ncerr .ne. 0) return + + ! Read the dimension information for NOPTS. + ncerr = nf90_inq_dimid(fh, DNAME_NOPTS, d_nopts) + if (ncerr .ne. 0) return + ncerr = nf90_inquire_dimension(fh, d_nopts, len = d_nopts_len) + if (ncerr .ne. 0) return + + ! Read the dimension information for NSPEC. + ncerr = nf90_inq_dimid(fh, DNAME_NSPEC, d_nspec) + if (ncerr .ne. 0) return + ncerr = nf90_inquire_dimension(fh, d_nspec, len = d_nspec_len) + if (ncerr .ne. 0) return + + ! Read the dimension information for VSIZE. + ncerr = nf90_inq_dimid(fh, DNAME_VSIZE, d_vsize) + if (ncerr .ne. 0) return + ncerr = nf90_inquire_dimension(fh, d_vsize, len = d_vsize_len) + if (ncerr .ne. 0) return + + ! Read the dimension information for NAMELEN. + ncerr = nf90_inq_dimid(fh, DNAME_NAMELEN, d_namelen) + if (ncerr .ne. 0) return + ncerr = nf90_inquire_dimension(fh, d_namelen, len = d_namelen_len) + if (ncerr .ne. 0) return + + ! Read the dimension information for GRDIDLEN. + ncerr = nf90_inq_dimid(fh, DNAME_GRDIDLEN, d_grdidlen) + if (ncerr .ne. 0) return + ncerr = nf90_inquire_dimension(fh, d_grdidlen, len = d_grdidlen_len) + if (ncerr .ne. 0) return + + ! Read scalar variables. + ncerr = nf90_inq_varid(fh, VNAME_NK, v_nk) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_nk, NK) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_MTH, v_mth) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_mth, NTH) + if (ncerr .ne. 0) return + + ! Read vars with nopts as a dimension. + ncerr = nf90_inq_varid(fh, VNAME_PTLOC, v_ptloc) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_ptloc, PTLOC) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_PTNME, v_ptnme) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_ptnme, PTNME) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_IW, v_iw) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_iw, IW) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_II, v_ii) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_ii, II) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_IL, v_il) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_il, IL) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_DPO, v_dpo) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_dpo, DPO) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_WAO, v_wao) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_wao, WAO) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_WDO, v_wdo) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_wdo, WDO) + if (ncerr .ne. 0) return +#ifdef W3_FLX5 + ncerr = nf90_inq_varid(fh, VNAME_TAUAO, v_tauao) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_tauao, TAUAO) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_TAIDO, v_taido) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_taido, TAIDO) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_DAIRO, v_dairo) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_dairo, DAIRO) + if (ncerr .ne. 0) return +#endif +#ifdef W3_SETUP + ncerr = nf90_inq_varid(fh, ZET_SETO, v_zet_seto) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_zet_seto, ZET_SETO) + if (ncerr .ne. 0) return +#endif + ncerr = nf90_inq_varid(fh, VNAME_ASO, v_aso) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_aso, ASO) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_CAO, v_cao) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_cao, CAO) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_CDO, v_cdo) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_cdo, CDO) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_ICEO, v_iceo) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_iceo, ICEO) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_ICEHO, v_iceho) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_iceho, ICEHO) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_ICEFO, v_icefo) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_icefo, ICEFO) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_GRDID, v_grdid) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_grdid, GRDID) + if (ncerr .ne. 0) return + ncerr = nf90_inq_varid(fh, VNAME_SPCO, v_spco) + if (ncerr .ne. 0) return + ncerr = nf90_get_var(fh, v_spco, SPCO) + if (ncerr .ne. 0) return + + ! Close the file. + ncerr = nf90_close(fh) + if (ncerr .ne. 0) return + + END SUBROUTINE W3IOPON_READ + + !/ ------------------------------------------------------------------- / + !> + !> @brief Write point output in netCDF format. + !> + !> @param[in] IMOD Model number for W3GDAT etc. + !> @param[in] filename Name of file to write. + !> @param[in] timestep_only Will be 0 if whole model run should be + !> written, 1 if only one timestep should be written. + !> @param[inout] ncerr Error code, 0 for success, netCDF error code + !> otherwise. + !> + !> @author Edward Hartnett @date 1-Nov-2023 + !> + SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) + use netcdf + USE W3GDATMD, ONLY: NTH, NK, NSPEC, FILEXT + USE W3ODATMD, ONLY: NDST, NDSE, IPASS => IPASS2, NOPTS, IPTINT, & + IL, IW, II, PTLOC, PTIFAC, DPO, WAO, WDO, & + ASO, CAO, CDO, SPCO, PTNME, O2INIT, FNMPRE, & + GRDID, ICEO, ICEHO, ICEFO +#ifdef W3_FLX5 + USE W3ODATMD, ONLY: TAUAO, TAUDO, DAIRO +#endif +#ifdef W3_SETUP + USE W3ODATMD, ONLY: ZET_SETO +#endif + + IMPLICIT NONE + integer, intent(in) :: timestep_only ! 1 if only timestep should be written. + INTEGER, INTENT(IN) :: IMOD + character(*), intent(in) :: filename + integer, intent(inout) :: ncerr + integer :: fh, ndim, nvar, fmt + integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen, d_time + integer :: v_idtst, v_vertst, v_nk, v_mth, v_ptloc, v_ptnme + integer :: v_iw, v_ii, v_il, v_dpo, v_wao, v_wdo, v_tauao + integer :: v_taido, v_dairo, v_zet_seto, v_aso, v_cao, v_cdo, v_iceo + integer :: v_iceho, v_icefo, v_grdid, v_spco + character (len = *), parameter :: FILE_NAME = "f90tst_nc4.nc" + CHARACTER(LEN=31), PARAMETER :: IDSTR = 'WAVEWATCH III POINT OUTPUT FILE' + CHARACTER(LEN=10), PARAMETER :: VEROPT = '2021-04-06' + + print *, 'WRITE ',filename, len(filename) + + ! Create the netCDF file. + ncerr = nf90_create(filename, NF90_NETCDF4, fh) + if (ncerr .ne. 0) return + + ! Define dimensions. + ncerr = nf90_def_dim(fh, DNAME_NOPTS, NOPTS, d_nopts) + if (ncerr .ne. 0) return + ncerr = nf90_def_dim(fh, DNAME_NSPEC, NSPEC, d_nspec) + if (ncerr .ne. 0) return + ncerr = nf90_def_dim(fh, DNAME_VSIZE, 2, d_vsize) + if (ncerr .ne. 0) return + ncerr = nf90_def_dim(fh, DNAME_NAMELEN, 40, d_namelen) + if (ncerr .ne. 0) return + ncerr = nf90_def_dim(fh, DNAME_GRDIDLEN, 13, d_grdidlen) + if (ncerr .ne. 0) return + ncerr = nf90_def_dim(fh, DNAME_TIME, NF90_UNLIMITED, d_time) + if (ncerr .ne. 0) return + + ! Define global attributes. + ncerr = nf90_put_att(fh, NF90_GLOBAL, 'title', IDSTR) + if (ncerr .ne. 0) return + ncerr = nf90_put_att(fh, NF90_GLOBAL, 'version', VEROPT) + if (ncerr .ne. 0) return + + ! Define scalar variables. + ncerr = nf90_def_var(fh, VNAME_NK, NF90_INT, v_nk) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_MTH, NF90_INT, v_mth) + if (ncerr .ne. 0) return + + ! Define vars with nopts as a dimension. + ncerr = nf90_def_var(fh, VNAME_PTLOC, NF90_INT, (/d_vsize, d_nopts/), v_ptloc) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_PTNME, NF90_CHAR, (/d_namelen, d_nopts/), v_ptnme) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_IW, NF90_INT, (/d_nopts, d_time/), v_iw) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_II, NF90_INT, (/d_nopts, d_time/), v_ii) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_IL, NF90_INT, (/d_nopts, d_time/), v_il) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_DPO, NF90_INT, (/d_nopts, d_time/), v_dpo) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_WAO, NF90_INT, (/d_nopts, d_time/), v_wao) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_WDO, NF90_INT, (/d_nopts, d_time/), v_wdo) + if (ncerr .ne. 0) return +#ifdef W3_FLX5 + ncerr = nf90_def_var(fh, VNAME_TAUAO, NF90_INT, (/d_nopts, d_time/), v_tauao) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_TAIDO, NF90_INT, (/d_nopts, d_time/), v_taido) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_DAIRO, NF90_INT, (/d_nopts, d_time/), v_dairo) + if (ncerr .ne. 0) return +#endif +#ifdef W3_SETUP + ncerr = nf90_def_var(fh, VNAME_ZET_SETO, NF90_INT, (/d_nopts, d_time/), v_zet_seto) + if (ncerr .ne. 0) return +#endif + ncerr = nf90_def_var(fh, VNAME_ASO, NF90_INT, (/d_nopts, d_time/), v_aso) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_CAO, NF90_INT, (/d_nopts, d_time/), v_cao) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_CDO, NF90_INT, (/d_nopts, d_time/), v_cdo) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_ICEO, NF90_INT, (/d_nopts, d_time/), v_iceo) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_ICEHO, NF90_INT, (/d_nopts, d_time/), v_iceho) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_ICEFO, NF90_INT, (/d_nopts, d_time/), v_icefo) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_GRDID, NF90_CHAR, (/d_grdidlen, d_nopts, d_time/), v_grdid) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, VNAME_SPCO, NF90_INT, (/d_nspec, d_nopts, d_time/), v_spco) + if (ncerr .ne. 0) return + + ! Write the scalar data. + ncerr = nf90_put_var(fh, v_nk, NK) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_mth, NTH) + if (ncerr .ne. 0) return + + ! Write the data with NOPTS as a dimension. + ncerr = nf90_put_var(fh, v_ptloc, PTLOC) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_ptnme, PTNME) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_iw, IW) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_ii, II) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_il, IL) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_dpo, DPO) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_wao, WAO) + if (ncerr .ne. 0) return +#ifdef W3_FLX5 + ncerr = nf90_put_var(fh, v_tauao, TAUAO) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_taido, TAIDO) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_dairo, DAIRO) + if (ncerr .ne. 0) return +#endif +#ifdef W3_SETUP + ncerr = nf90_put_var(fh, v_zet_seto, ZET_SETO) + if (ncerr .ne. 0) return +#endif + ncerr = nf90_put_var(fh, v_aso, ASO) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_cao, CAO) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_iceo, ICEO) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_iceho, ICEHO) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_icefo, ICEFO) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_grdid, GRDID) + if (ncerr .ne. 0) return + ncerr = nf90_put_var(fh, v_spco, SPCO) + if (ncerr .ne. 0) return + + ! Close the file. + ncerr = nf90_close(fh) + if (ncerr .ne. 0) return + + END SUBROUTINE W3IOPON_WRITE + + !> Read/write point output in netCDF format. + !> + !> @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 Edward Hartnett @date 1-Nov-2023 + SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD & +#ifdef W3_ASCII + ,NDSOA & +#endif + ) + USE W3GDATMD, ONLY: W3SETG + USE W3WDATMD, ONLY: W3SETW + USE W3ODATMD, ONLY: W3SETO, W3DMO2 + !/ + USE W3GDATMD, ONLY: NTH, NK, NSPEC, FILEXT + USE W3WDATMD, ONLY: TIME + USE W3ODATMD, ONLY: NDST, NDSE, IPASS => IPASS2, NOPTS, IPTINT, & + IW, PTLOC, PTIFAC, WAO, WDO, & + SPCO, PTNME, O2INIT, FNMPRE +#ifdef W3_FLX5 + USE W3ODATMD, ONLY: TAUAO, TAUDO, DAIRO +#endif + USE W3ODATMD, ONLY : OFILES + !/ +#ifdef W3_SETUP + USE W3ODATMD, ONLY: ZET_SETO +#endif + !/ + USE W3SERVMD, ONLY: EXTCDE +#ifdef W3_S + USE W3SERVMD, ONLY: STRACE +#endif + use netcdf + IMPLICIT NONE + + CHARACTER, INTENT(IN) :: INXOUT*(*) + INTEGER, INTENT(IN) :: NDSOP + INTEGER, INTENT(OUT) :: IOTST + INTEGER, INTENT(IN), OPTIONAL :: IMOD +#ifdef W3_ASCII + INTEGER, INTENT(IN), OPTIONAL :: NDSOA +#endif + + INTEGER :: IGRD, MK, MTH + character(len = 124) :: filename + integer :: ncerr + + ! Optimistically assume success. + IOTST = 0 + + ! Has a model number been specified? + IF (PRESENT(IMOD)) THEN + IGRD = IMOD + ELSE + IGRD = 1 + END IF + + CALL W3SETO(IGRD, NDSE, NDST) + CALL W3SETG(IGRD, NDSE, NDST) + CALL W3SETW(IGRD, NDSE, NDST) + + ! INXOUT must be 'READ' or 'WRITE'. + IF (INXOUT .NE. 'READ' .AND. INXOUT .NE. 'WRITE') THEN + WRITE (NDSE, 900) INXOUT + CALL EXTCDE(1) + END IF + + ! Determine filename. + filename = '' + filename = transfer(FNMPRE(:LEN_TRIM(FNMPRE))//'out_pnt_nc.'//FILEXT(:LEN_TRIM(FILEXT)), filename) + !print *, filename + + ! Do a read or a write of the point file. + IF (INXOUT .EQ. 'READ') THEN + CALL W3IOPON_READ(IOTST, IMOD, filename, ncerr) + ELSE + CALL W3IOPON_WRITE(OFILES(2), IMOD, filename, ncerr) + ENDIF + if (ncerr .ne. 0) then + print *, nf90_strerror(ncerr) + CALL EXTCDE(21) + endif + + !/ + !/ End of W3IOPON ----------------------------------------------------- / + !/ + +900 FORMAT (/' *** WAVEWATCH III ERROR IN W3IOPO :'/ & + ' ILEGAL INXOUT VALUE: ',A/) + END SUBROUTINE W3IOPON + + !/ ------------------------------------------------------------------- / !> Read or write point output. !> !> This subroutine can either read or write the point output file, @@ -1495,7 +2036,7 @@ SUBROUTINE W3IOPO ( INXOUT, NDSOP, IOTST, IMOD & #endif 'ASO(I), CAO(I), CDO(I), ICEO(I), ICEHO(I):', & ASO(I), CAO(I), CDO(I), ICEO(I), ICEHO(I), & - 'ICEFO(I), GRDID(I), (SPCO(J,I),J=1,NSPEC):', & + 'ICEFO(I), GRDID(I), (SPCO(J,I),J=1,NSPEC):', & ICEFO(I), GRDID(I), (SPCO(J,I),J=1,NSPEC) #endif ELSE From 17e6ee689feefeaad67d1dcd0d0d83a214157ecb Mon Sep 17 00:00:00 2001 From: Ed Date: Mon, 1 Apr 2024 13:27:22 -0600 Subject: [PATCH 034/126] uncommenting test code --- regtests/unittests/test_io.F90 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/regtests/unittests/test_io.F90 b/regtests/unittests/test_io.F90 index 86e333679..ce89d5df6 100644 --- a/regtests/unittests/test_io.F90 +++ b/regtests/unittests/test_io.F90 @@ -97,9 +97,9 @@ program test_io print *, 'testing writing the WW3 binary point file in netCDF...' ! Write in netCDF. - ! call w3iopon('WRITE', ndsop, iotest) - ! if (iotest .ne. 0) stop 100 - ! print *, 'OK!' + call w3iopon('WRITE', ndsop, iotest) + if (iotest .ne. 0) stop 100 + print *, 'OK!' ! print *, 'testing reading the WW3 binary point file in netCDF...' ! call w3iopon('READ', ndsop, iotest) From 3d2c19e9e2b8c4c403e680d8f5910f7e8916a81c Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Tue, 2 Apr 2024 02:58:10 -0600 Subject: [PATCH 035/126] added reference --- docs/regtests.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/regtests.md b/docs/regtests.md index ac5a4e880..76a67d0bc 100644 --- a/docs/regtests.md +++ b/docs/regtests.md @@ -66,4 +66,8 @@ Download the test data by running the shell script: model/bin/ww3_from_ftp.sh. ## References -https://github.com/NOAA-EMC/WW3/wiki/Developer-Guide#regression-testing-in-wavewatch-iii \ No newline at end of file +https://github.com/NOAA-EMC/WW3/wiki/Developer-Guide#regression-testing-in-wavewatch-iii + +WaveWatch III Installation, retrieved from https://www.youtube.com/watch?v=cyyIKqm9R2s&t=1s on Apr 2, 2024. + +file:///home/ed/Downloads/10.WAVEWATCHIII_install.Tolman.pdf \ No newline at end of file From 7af89cc600aeb1149aef0eb8abad51fcc6013d21 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Tue, 2 Apr 2024 04:09:25 -0600 Subject: [PATCH 036/126] more detail --- docs/regtests.md | 555 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 554 insertions(+), 1 deletion(-) diff --git a/docs/regtests.md b/docs/regtests.md index 76a67d0bc..b71125d43 100644 --- a/docs/regtests.md +++ b/docs/regtests.md @@ -61,8 +61,561 @@ make test Download the test data by running the shell script: model/bin/ww3_from_ftp.sh. +## Run Some Stuff -## What Next? +In the build directory there is a file ww3_grid.inp. In the build directory execute: +
+./bin/ww3_grid
+
+ +Expect the following output: + +
+
+                   *** WAVEWATCH III Grid preprocessor ***    
+               ===============================================
+
+  Comment character is '$'
+
+  Grid name : 1-D REFRACTION X              
+
+
+  Spectral discretization : 
+ --------------------------------------------------
+       Number of directions        :  24
+       Directional increment (deg.):  15.0
+       First direction       (deg.):   0.0
+       Number of frequencies       :   3
+       Frequency range        (Hz) :   0.0800-0.1250
+       Increment factor            :   1.250
+
+
+  Model definition :
+ --------------------------------------------------
+       Dry run (no calculations)   :  ---/NO
+       Propagation in X-direction  :  YES/--
+       Propagation in Y-direction  :  ---/NO
+       Refraction                  :  YES/--
+       Current-induced k-shift     :  ---/NO
+       Source term calc. and int.  :  ---/NO
+
+
+  Time steps : 
+ --------------------------------------------------
+       Maximum global time step      (s) :  300.00
+       Maximum CFL time step X-Y     (s) :  300.00
+       Maximum CFL time step k-theta (s) :  150.00
+       Minimum source term time step (s) :  300.00
+
+  Preprocessing namelists ...
+  Preprocessing namelists finished.
+
+
+  Stresses (T&C 96)
+ --------------------------------------------------
+
+
+  Linear input not defined.
+
+
+  Wind input not defined.
+
+
+  Nonlinear interactions not defined.
+
+
+  Dissipation not defined.
+
+
+  Bottom friction not defined.
+
+
+  Surf breaking not defined.
+
+
+  Triad interactions not defined.
+
+
+  Bottom scattering not defined.
+
+
+  Propagation scheme : 
+ --------------------------------------------------
+       Type of scheme (structured) : First order upstream          
+                                     (user def. values)
+       CFLmax depth refraction     :    0.750
+
+
+  Ice scattering not defined.
+
+
+  Spectral output on full grid (default values) :  
+ --------------------------------------------------
+       Second order pressure at K=0:   0   1   3
+       Spectrum of Uss             :   0   1   3
+       Frequency spectrum          :   0   1   3
+       Partions of Uss             :   0   1
+       Partition wavenumber # 1   :  0.063
+
+  Miscellaneous (default values) :  
+ --------------------------------------------------
+       Ice concentration cut-offs  :    0.50  0.50
+       Wind input reduction factor in presence of 
+         ice :  1.00
+         (0.0==> no reduction and 1.0==> no wind
+         input with 100% ice cover)
+       Space-time extremes DX-Y set to default 1000 m
+       Space-time extremes Dt set to default 1200 s
+       Compression of track output  :   T
+
+    Dynamic source term integration scheme :
+       Xp                      (-) :    0.150
+       Xr                      (-) :    0.100
+       Xfilt                   (-) :    0.050
+
+    Wave field partitioning :
+       Levels                  (-) :  100
+       Minimum wave height     (m) :    0.050
+       Wind area multiplier    (-) :    1.700
+       Cut-off wind sea fract. (-) :    0.333
+       Combine wind seas           :  YES/--
+       Number of swells in fld out :    5
+       Partitioning method         :  WW3 default                                  
+
+    Miche-style limiting wave height :
+       Hs,max/d factor         (-) :    1.600
+       Hrms,max/d factor       (-) :    1.131
+       Limiter activated           :  ---/NO
+
+    Calendar type                  :  standard
+
+
+  Equivalent namelists ...
+
+  &PRO1 CFLTM = 0.75 /
+  &UNST UGBCCFL =  T, UGOBCAUTO =  T, UGOBCDEPTH = -10.000, UGOBCFILE=unset,
+,  EXPFSN =  T,EXPFSPSI =  F,  EXPFSFCT =  F,IMPFSN =  F,EXPTOTAL=  F,  IMPTOTAL=  F,IMPREFRACTION=  F,  IMPFREQSHIFT=  F, IMPSOURCE=  F,  SETUP_APPLY_WLV=  T,  JGS_TERMINATE_MAXITER=  T,  JGS_TERMINATE_DIFFERENCE=  T,  JGS_TERMINATE_NORM=  F,  JGS_LIMITER=  F,  JGS_LIMITER_FUNC=  1,  JGS_USE_JACOBI=  T,  JGS_BLOCK_GAUSS_SEIDEL=  T,  JGS_MAXITER=  100,  JGS_PMIN=   1.000,  JGS_DIFF_THR=   0.000,  JGS_NORM_THR=   0.000,  JGS_NLEVEL=  0,  JGS_SOURCE_NONLINEAR=  F
+
+  &OUTS P2SF  = 0, I1P2SF = 1, I2P2SF = 15,
+        US3D  = 0, I1US3D =  1, I2US3D =  3,
+        USSP  = 0, IUSSP  =  1,
+        E3D   = 0, I1E3D  =  1, I2E3D  =  3,
+        TH1MF = 0, I1TH1M =  1, I2TH1M =  3,
+        STH1MF= 0, I1STH1M=  1, I2STH1M=  3,
+        TH2MF = 0, I1TH2M =  1, I2TH2M =  3,
+        STH2MF= 0, I1STH2M=  1, I2STH2M=  3 /
+  &MISC CICE0 = 0.500, CICEN = 0.500, LICE =      0.0, PMOVE = 0.500,
+        XSEED = 1.000, FLAGTR = 0, XP = 0.150, XR = 0.100, XFILT = 0.050
+        IHM =  100, HSPM = 0.050, WSM = 1.700, WSC = 0.333, FLC = .TRUE.
+        NOSW =  5, FMICHE = 1.600, RWNDC = 1.000, WCOR1 = 99.00, WCOR2 =  0.00,
+        FACBERG = 1.0, GSHIFT =   0.000E+00, STDX =   -1.00, STDY =  -1.00,
+        STDT =   -1.00, ICEHMIN = 0.20, ICEHFAC = 1.00,
+        ICEHINIT = 0.50, ICEDISP =  F, ICEHDISP = 0.60,
+        ICESLN =   1.00, ICEWIND =   1.00, ICESNL =   1.00, ICESDS =  1.00,
+        ICEDDISP = 80.00, ICEFDISP =  2.00, CALTYPE = standard , TRCKCMPR =   T,
+        BTBET  =   1.20 /
+
+  Equivalent namelists finished.
+
+
+  The spatial grid: 
+ --------------------------------------------------
+
+       Grid type                   : rectilinear
+       Coordinate system           : Cartesian
+       Index closure type          : none
+       Dimensions                  :     13       3
+       Increments             (km) :    5.00    5.00
+       X range                (km) :   -5.00   55.00
+       Y range                (km) :   -5.00    5.00
+
+       Bottom level unit           :    10
+       Limiting depth          (m) :   -1.00
+       Minimum depth           (m) :    1.00
+       Scale factor                :   -1.00
+       Layout indicator            :     2
+       Format indicator            :     1
+
+       Sub-grid information        : Not available.
+  Processing boundary points
+  Processing excluded points
+
+  Input boundary points : 
+ --------------------------------------------------
+       Number of boundary points   :     1
+
+         Nr.|   IX  |   IY  |     X     |     Y     
+       -----|-------|-------|-----------|-----------
+          1 |     2 |     2 |     0.0E3 |     0.0E3
+
+  Excluded points : 
+ --------------------------------------------------
+       Number of excluded points   :    25
+
+
+  Status map, printed in     1 part(s) 
+ -----------------------------------
+
+   3 3 3 3 3 3 3 3 3 3 3 3 0
+   3 2 1 1 1 1 1 1 1 1 1 1 0
+   3 3 3 3 3 3 3 3 3 3 3 3 0
+  
+  Legend : 
+ -----------------------------
+    0 : Land point            
+    1 : Sea point             
+    2 : Active boundary point 
+    3 : Excluded point        
+
+
+  Output boundary points : 
+ --------------------------------------------------
+       No boundary points.
+
+
+  Writing model definition file ...
+
+
+  Summary grid statistics : 
+ --------------------------------------------------
+       Number of longitudes      :        13
+       Number of latitudes       :         3
+       Number of grid points     :        39
+       Number of sea points      :        11 (28.2%)
+       Number of input b. points :         1
+       Number of land points     :         3
+       Number of excluded points :        25
+
+
+  End of program 
+ ========================================
+         WAVEWATCH III Grid preprocessor 
+
+ + +## Running a Regtest + +
+
+ed@Pooh-Bah:~/ww3/regtests/ww3_tp1.1/input$ ../../../build/bin/ww3_grid 
+
+                   *** WAVEWATCH III Grid preprocessor ***    
+               ===============================================
+
+  Grid name : 1-D PROPAGATION EQUATOR       
+
+
+  Spectral discretization : 
+ --------------------------------------------------
+       Number of directions        :   4
+       Directional increment (deg.):  90.0
+       First direction       (deg.):   0.0
+       Number of frequencies       :   3
+       Frequency range        (Hz) :   0.0368-0.0445
+       Increment factor            :   1.100
+
+
+  Model definition :
+ --------------------------------------------------
+       Dry run (no calculations)   :  ---/NO
+       Propagation in X-direction  :  YES/--
+       Propagation in Y-direction  :  ---/NO
+       Refraction                  :  ---/NO
+       Current-induced k-shift     :  ---/NO
+       Source term calc. and int.  :  ---/NO
+
+
+  Time steps : 
+ --------------------------------------------------
+       Maximum global time step      (s) : 3600.00
+       Maximum CFL time step X-Y     (s) : 3600.00
+       Maximum CFL time step k-theta (s) : 3600.00
+       Minimum source term time step (s) : 3600.00
+
+  Preprocessing namelists ...
+  Preprocessing namelists finished.
+
+
+  Stresses (T&C 96)
+ --------------------------------------------------
+
+
+  Linear input not defined.
+
+
+  Wind input not defined.
+
+
+  Nonlinear interactions not defined.
+
+
+  Dissipation not defined.
+
+
+  Bottom friction not defined.
+
+
+  Surf breaking not defined.
+
+
+  Triad interactions not defined.
+
+
+  Bottom scattering not defined.
+
+
+  Propagation scheme : 
+ --------------------------------------------------
+       Type of scheme (structured) : First order upstream          
+                                     (default values)  
+       CFLmax depth refraction     :    0.700
+
+
+  Ice scattering not defined.
+
+
+  Spectral output on full grid (default values) :  
+ --------------------------------------------------
+       Second order pressure at K=0:   0   1   3
+       Spectrum of Uss             :   0   1   3
+       Frequency spectrum          :   0   1   3
+       Partions of Uss             :   0   1
+       Partition wavenumber # 1   :  0.063
+
+  Miscellaneous (default values) :  
+ --------------------------------------------------
+       Ice concentration cut-offs  :    0.50  0.50
+       Wind input reduction factor in presence of 
+         ice :  1.00
+         (0.0==> no reduction and 1.0==> no wind
+         input with 100% ice cover)
+       Space-time extremes DX-Y set to default 1000 m
+       Space-time extremes Dt set to default 1200 s
+       Compression of track output  :   T
+
+    Dynamic source term integration scheme :
+       Xp                      (-) :    0.150
+       Xr                      (-) :    0.100
+       Xfilt                   (-) :    0.050
+
+    Wave field partitioning :
+       Levels                  (-) :  100
+       Minimum wave height     (m) :    0.050
+       Wind area multiplier    (-) :    1.700
+       Cut-off wind sea fract. (-) :    0.333
+       Combine wind seas           :  YES/--
+       Number of swells in fld out :    5
+       Partitioning method         :  WW3 default                                  
+
+    Miche-style limiting wave height :
+       Hs,max/d factor         (-) :    1.600
+       Hrms,max/d factor       (-) :    1.131
+       Limiter activated           :  ---/NO
+
+    Calendar type                  :  standard
+
+
+  Equivalent namelists ...
+
+  &PRO1 CFLTM = 0.70 /
+  &UNST UGBCCFL =  T, UGOBCAUTO =  T, UGOBCDEPTH = -10.000, UGOBCFILE=unset,
+,  EXPFSN =  T,EXPFSPSI =  F,  EXPFSFCT =  F,IMPFSN =  F,EXPTOTAL=  F,  IMPTOTAL=  F,IMPREFRACTION=  F,  IMPFREQSHIFT=  F, IMPSOURCE=  F,  SETUP_APPLY_WLV=  T,  JGS_TERMINATE_MAXITER=  T,  JGS_TERMINATE_DIFFERENCE=  T,  JGS_TERMINATE_NORM=  F,  JGS_LIMITER=  F,  JGS_LIMITER_FUNC=  1,  JGS_USE_JACOBI=  T,  JGS_BLOCK_GAUSS_SEIDEL=  T,  JGS_MAXITER=  100,  JGS_PMIN=   1.000,  JGS_DIFF_THR=   0.000,  JGS_NORM_THR=   0.000,  JGS_NLEVEL=  0,  JGS_SOURCE_NONLINEAR=  F
+
+  &OUTS P2SF  = 0, I1P2SF = 1, I2P2SF = 15,
+        US3D  = 0, I1US3D =  1, I2US3D =  3,
+        USSP  = 0, IUSSP  =  1,
+        E3D   = 0, I1E3D  =  1, I2E3D  =  3,
+        TH1MF = 0, I1TH1M =  1, I2TH1M =  3,
+        STH1MF= 0, I1STH1M=  1, I2STH1M=  3,
+        TH2MF = 0, I1TH2M =  1, I2TH2M =  3,
+        STH2MF= 0, I1STH2M=  1, I2STH2M=  3 /
+  &MISC CICE0 = 0.500, CICEN = 0.500, LICE =      0.0, PMOVE = 0.500,
+        XSEED = 1.000, FLAGTR = 0, XP = 0.150, XR = 0.100, XFILT = 0.050
+        IHM =  100, HSPM = 0.050, WSM = 1.700, WSC = 0.333, FLC = .TRUE.
+        NOSW =  5, FMICHE = 1.600, RWNDC = 1.000, WCOR1 = 99.00, WCOR2 =  0.00,
+        FACBERG = 1.0, GSHIFT =   0.000E+00, STDX =   -1.00, STDY =  -1.00,
+        STDT =   -1.00, ICEHMIN = 0.20, ICEHFAC = 1.00,
+        ICEHINIT = 0.50, ICEDISP =  F, ICEHDISP = 0.60,
+        ICESLN =   1.00, ICEWIND =   1.00, ICESNL =   1.00, ICESDS =  1.00,
+        ICEDDISP = 80.00, ICEFDISP =  2.00, CALTYPE = standard , TRCKCMPR =   T,
+        BTBET  =   1.20 /
+
+  Equivalent namelists finished.
+
+
+  The spatial grid: 
+ --------------------------------------------------
+
+       Grid type                   : rectilinear
+       Coordinate system           : spherical
+       Index closure type          : simple
+       Dimensions                  :    360       3
+
+       Increments           (deg.) :    1.0000    1.0000
+       Longitude range      (deg.) : -180.0000  179.0000
+       Latitude range       (deg.) :   -1.0000    1.0000
+
+       Bottom level unit           :    50
+       Limiting depth          (m) :   -5.00
+       Minimum depth           (m) :    5.75
+       Scale factor                :-2500.00
+       Layout indicator            :     2
+       Format indicator            :     1
+       File name                   : ../input/1-D.depth
+
+       Sub-grid information        : Not available.
+  Processing boundary points
+  Processing excluded points
+
+  Input boundary points : 
+ --------------------------------------------------
+       No boundary points.
+
+
+  Excluded points : 
+ --------------------------------------------------
+       Number of excluded points   :   720
+
+
+  Status map, printed in     5 part(s) 
+ -----------------------------------
+
+   3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
+   1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+   3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
+  
+   3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
+   1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+   3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
+  
+   3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
+   1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+   3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
+  
+   3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
+   1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+   3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
+  
+   3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
+   1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+   3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
+  
+  Legend : 
+ -----------------------------
+    0 : Land point            
+    1 : Sea point             
+    2 : Active boundary point 
+    3 : Excluded point        
+
+
+  Output boundary points : 
+ --------------------------------------------------
+       No boundary points.
+
+
+  Writing model definition file ...
+
+
+  Summary grid statistics : 
+ --------------------------------------------------
+       Number of longitudes      :       360
+       Number of latitudes       :         3
+       Number of grid points     :      1080
+       Number of sea points      :       360 (33.3%)
+       Number of input b. points :         0
+       Number of land points     :         0
+       Number of excluded points :       720
+
+
+  End of program 
+ ========================================
+         WAVEWATCH III Grid preprocessor 
+
+ed@Pooh-Bah:~/ww3/regtests/ww3_tp1.1/input$ ../../../build/bin/ww3_strt 
+
+                  *** WAVEWATCH III  Initial conditions ***   
+               ===============================================
+
+  Comment character is '$'
+
+  Grid name : 1-D PROPAGATION EQUATOR       
+
+
+  Initial field ITYPE = 1
+ --------------------------------------------------
+  Negative SIX was provided by user.         
+  WW3 will create a gaussian distribution    
+  that is circular in real space. 
+       Gaussian / cosine power spectrum 
+
+       Peak frequency and spread (Hz)    :    0.0405  0.0001
+       Mean direction (Naut., degr.)     :  270.0
+       Cosine power of dir. distribution :  200
+       Mean longitude and spread (degr.) :    0.00    0.01
+       Mean latitude and spread (degr.)  :    0.00    2.00
+       Maximum wave height               :    2.50
+
+
+  Location : TEST E(f)
+  Spectrum : Unscaled 1-D  Extreme value :  0.100E+01  
+
+           +-------+
+ 0.990E+00 +   *   |
+           |       |
+ 0.770E+00 +       |
+           |       |
+ 0.550E+00 +       |
+           |       |
+ 0.330E+00 +       |
+           |       |
+ 0.110E+00 +       |
+           +-*-|-*-+
+             0.040
+ 
+
+  Location : TEST 2-D
+  Spectrum : Energy (Normalized)   Maximum value :  0.706E+01 m2s
+
+       ang.|  frequencies (Hz) 
+       deg.| 0.040
+       ----+---|---+
+         N |       |
+         E |       |
+         S |       |
+         W |   *   |
+       ----+-------+
+ 
+
+       Converting energy to action ... 
+
+ Variable: Hs Max.:  0.250E+01 m
+ 
+             1      23      45      67      89     111     133     155     177     199     221     243     265     287     309     331     353
+       +-------------------------------------------------------------------+
+     3 |                                                                   |
+       | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
+       |                                                                   |
+       +-------------------------------------------------------------------+
+             1      23      45      67      89     111     133     155     177     199     221     243     265     287     309     331     353
+ 
+
+       Writing restart file  ... 
+
+
+  End of program 
+ =========================================
+         WAVEWATCH III Initial conditions 
+
+ed@Pooh-Bah:~/ww3/regtests/ww3_tp1.1/input$ ../../../build/bin/ww3_prep 
+
+                 *** WAVEWATCH III  Input pre-processing ***  
+               ===============================================
+
+
+ *** WAVEWATCH III ERROR IN W3PREP : 
+     ERROR IN OPENING INPUT FILE
+     IOSTAT =    2
+
## References From 16339bbabbb639635a3fe3395c414841f297041a Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Tue, 2 Apr 2024 04:11:20 -0600 Subject: [PATCH 037/126] more detail --- docs/regtests.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/regtests.md b/docs/regtests.md index b71125d43..b2e5038a6 100644 --- a/docs/regtests.md +++ b/docs/regtests.md @@ -617,6 +617,16 @@ ed@Pooh-Bah:~/ww3/regtests/ww3_tp1.1/input$ ../../../build/bin/ww3_prep IOSTAT = 2 +## Running WW3 + +These are the steps: +* ww3_grid (generate mod_def.ww3 file). +* ww3_strt (generate initial conditions). +* ww3_prep (generate ice.ww3 file). +* ww3_shel (run the model). +* ww3_outf (print out wave heights). +* ww3_outp (print out some spectra). + ## References https://github.com/NOAA-EMC/WW3/wiki/Developer-Guide#regression-testing-in-wavewatch-iii From ba26fd80e77bca0004f24c7c033ad111738ee521 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Tue, 2 Apr 2024 04:17:21 -0600 Subject: [PATCH 038/126] adding regtest CI --- .github/workflows/regtest_gnu.yml | 122 ++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 .github/workflows/regtest_gnu.yml diff --git a/.github/workflows/regtest_gnu.yml b/.github/workflows/regtest_gnu.yml new file mode 100644 index 000000000..5b2e72a54 --- /dev/null +++ b/.github/workflows/regtest_gnu.yml @@ -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 .. + make -j2 VERBOSE=1 + cd ../regtests/ww3_tp1.1 + pwd + ls -l + #${GITHUB_WORKSPACE}/ww3/build/bin/ww3_grid + + - name: upload-test-coverage + uses: actions/upload-artifact@v3 + with: + name: ww3-test-coverage + path: | + ww3/build/*.html + ww3/build/*.css + + From d65d63d66d814e997ef33431d4211769b935f729 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Tue, 2 Apr 2024 04:20:35 -0600 Subject: [PATCH 039/126] working on regtest CI --- .github/workflows/regtest_gnu.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/regtest_gnu.yml b/.github/workflows/regtest_gnu.yml index 5b2e72a54..a30f5e89e 100644 --- a/.github/workflows/regtest_gnu.yml +++ b/.github/workflows/regtest_gnu.yml @@ -1,4 +1,4 @@ -name: io_gnu +name: regtest_gnu on: [push, pull_request, workflow_dispatch] # Cancel in-progress workflows when pushing to a branch @@ -68,7 +68,7 @@ jobs: make VERBOSE=1 cp -r ${GITHUB_WORKSPACE}/ww3/regtests/ww3_tp2.14/input/work_oasis3-mct ${GITHUB_WORKSPACE} - io_gnu: + regtest_gnu: needs: setup runs-on: ubuntu-latest @@ -106,9 +106,9 @@ jobs: 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 ../regtests/ww3_tp1.1 +# cd ../regtests/ww3_tp1.1 pwd - ls -l +# ls -l #${GITHUB_WORKSPACE}/ww3/build/bin/ww3_grid - name: upload-test-coverage From b4893d265623d36d0d68badd44dc0372056125a5 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Tue, 2 Apr 2024 04:21:49 -0600 Subject: [PATCH 040/126] working on regtest CI --- .github/workflows/regtest_gnu.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/regtest_gnu.yml b/.github/workflows/regtest_gnu.yml index a30f5e89e..7b8ded6fa 100644 --- a/.github/workflows/regtest_gnu.yml +++ b/.github/workflows/regtest_gnu.yml @@ -106,10 +106,6 @@ jobs: 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 ../regtests/ww3_tp1.1 - pwd -# ls -l - #${GITHUB_WORKSPACE}/ww3/build/bin/ww3_grid - name: upload-test-coverage uses: actions/upload-artifact@v3 From 3b424f8672507a3c3968ec1a56241abf38c85fa6 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Tue, 2 Apr 2024 04:37:27 -0600 Subject: [PATCH 041/126] working on regtest CI --- .github/workflows/regtest_gnu.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/regtest_gnu.yml b/.github/workflows/regtest_gnu.yml index 7b8ded6fa..6eaf67aed 100644 --- a/.github/workflows/regtest_gnu.yml +++ b/.github/workflows/regtest_gnu.yml @@ -106,13 +106,11 @@ jobs: 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/regtests/ww3_tp1.1 + pwd + ls -l + - - name: upload-test-coverage - uses: actions/upload-artifact@v3 - with: - name: ww3-test-coverage - path: | - ww3/build/*.html - ww3/build/*.css - + + From 8270389dca89571ca7e3aea7149e3045820dab68 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Tue, 2 Apr 2024 05:46:15 -0600 Subject: [PATCH 042/126] more regtest work --- .github/workflows/regtest_gnu.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/regtest_gnu.yml b/.github/workflows/regtest_gnu.yml index 6eaf67aed..fdca743d5 100644 --- a/.github/workflows/regtest_gnu.yml +++ b/.github/workflows/regtest_gnu.yml @@ -106,10 +106,11 @@ jobs: 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 + ${GITHUB_WORKSPACE}/ww3/model/bin/ww3_from_ftp.sh cd ${GITHUB_WORKSPACE}/ww3/regtests/ww3_tp1.1 pwd ls -l - + ${GITHUB_WORKSPACE}/ww3/build/bin/ww3_grid From 9f2e25f281d114addf6f108cde714abbca6a70fe Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Tue, 2 Apr 2024 06:04:11 -0600 Subject: [PATCH 043/126] more detail --- docs/regtests.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/regtests.md b/docs/regtests.md index b2e5038a6..e73e0ce84 100644 --- a/docs/regtests.md +++ b/docs/regtests.md @@ -627,6 +627,19 @@ These are the steps: * ww3_outf (print out wave heights). * ww3_outp (print out some spectra). +## run_cmake_test + +There is a script called run_cmake_test. It seems relevant: + +
+ed@Pooh-Bah:~/ww3/regtests$ ./bin/run_cmake_test ~/ww3 ww3_tp1.1
+ 
+ Running now options: run_cmake_test /home/ed/ww3 ww3_tp1.1
+ 
+
+ERROR: /home/ed/ww3/tools not found
+
+ ## References https://github.com/NOAA-EMC/WW3/wiki/Developer-Guide#regression-testing-in-wavewatch-iii From f35a1964807933237ff1b4e68a320f13506fb68c Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Tue, 2 Apr 2024 06:10:17 -0600 Subject: [PATCH 044/126] more details --- docs/regtests.md | 312 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 308 insertions(+), 4 deletions(-) diff --git a/docs/regtests.md b/docs/regtests.md index e73e0ce84..8b92d13e7 100644 --- a/docs/regtests.md +++ b/docs/regtests.md @@ -632,13 +632,317 @@ These are the steps: There is a script called run_cmake_test. It seems relevant:
-ed@Pooh-Bah:~/ww3/regtests$ ./bin/run_cmake_test ~/ww3 ww3_tp1.1
+
+ed@Pooh-Bah:~/ww3/regtests$ ./bin/run_cmake_test -o all -S -T -s PR1_MPI -w work_PR1_MPI              -f -p mpirun -n 24 ../model ww3_tp2.1
+ 
+ Running now options: run_cmake_test -o all -S -T -s PR1_MPI -w work_PR1_MPI -f -p mpirun -n 24 ../model ww3_tp2.1
+ 
+   Building WW3, exes will be in /home/ed/ww3/regtests/ww3_tp2.1/work_PR1_MPI/exe
+   Build log is in /home/ed/ww3/regtests/ww3_tp2.1/work_PR1_MPI/build.log
+ 
+ 
+                    ==================================   
+                  ======> TEST RUN WAVEWATCH III <====== 
+                    ==================================   
+ 
+#############################################################################
+#                                                                           #
+# ww3_tp2.1 Test script for WW-III, two-dimensional propagation.            #
+#           Propagation under angle with grid.                              #
+#                                                                           #
+# Model should be compiled with the switches :                              #
+#                                                                           #
+#   !/LN0 !/ST0 !/NL0 !/BT0 !/DB0 !/TR0 !/BS0                               #
+#                        Select the 'no source terms' option.               #
+#   !/PRn                Selecting one of the propagation schemes.          #
+#                         1: First order.                                   #
+#                         2: UQ with diffusion term.                        #
+#                         3: UQ with averaging.                             #
+#   !/WNX1 !/WNT1 !/CRX1 !/CRT1      Wind and current interpolation.        #
+#   !/O0 !/O1 !/O2 !/O3 !/O4 !/O5 !/O6 !/O7   Sdt out output options.       #
+#                                                                           #
+# Remarks :                                                                 #
+#                                                                           #
+# - Test case input (default):                                              #
+#   * ww3_grid.inp : (default)                                              #
+#     + Spatial grid: 43 x 43 rectilinear Cartesian grid                    #
+#       - dx = 1 km, dy = 1 km                                              #
+#       - Xrange = -60:360 km, Yrange = -60:360 km                          #
+#       - land mask defined                                                 #
+#     + Spectral grid: ntheta = 24, nf =  3, f1 = 0.03679, fgamma = 1.1     #
+#   * ww3_grid_b.inp :                                                      #
+#     + Spatial grid: 273 x 274 rectilinear Cartesian grid                  #
+#       - dx = 16 km, dy = 16 km                                            #
+#       - Xrange = 0:4352 km, Yrange = 0:4368 km                            #
+#       - no land mask defined                                              #
+#     + Spectral grid: ntheta = 12, nf =  3, f1 = 0.03679, fgamma = 1.1     #
+#   * ww3_grid_c.inp :                                                      #
+#     + Spatial grid: 226 x 331 curvilinear Cartesian grid                  #
+#       - dx and dy are variable                                            #
+#       - Xrange = 1040.39:7000.00 km, Yrange = 2000.00:7959.61 km          #
+#       - input grid coordinates: grd.IDLA1.dat                        #
+#       - no land mask defined                                              #
+#     + Spectral grid: ntheta = 12, nf =  3, f1 = 0.03679, fgamma = 1.1     #
+#   * map2_1.gs: GrADS script for the default grid.                         #
+#   * switch options (mostly self-explanatory).                             #
+#     + switch_PR1      : First order scheme                                #
+#     + switch_PR2_UNO  : UNO scheme with diffusion (off)                   #
+#     + switch_PR2_UQ   : UQ scheme with diffusion (off)                    #
+#     + switch_PR3_UNO  : UNO scheme with averaging (off)                   #
+#     + switch_PR3_UQ   : UQ scheme with averaging (off) (default)          #
+#     + switch_PR1_MPI                                                      #
+#     + switch_PR2_UNO_MPI                                                  #
+#     + switch_PR2_UQ_MPI                                                   #
+#     + switch_PR3_UNO_MPI                                                  #
+#     + switch_PR3_UQ_MPI                                                   #
+#                                                                           #
+#  Sample run_test commands :                                               #
+#   (Note: mpirun commands differ by local system)                          #
+#  ./bin/run_test                             -s PR1   ../model ww3_tp2.1   #
+#  ./bin/run_test -n 3 -p mpirun -f           -s PR1   ../model ww3_tp2.1   # 
+#  ./bin/run_test -g c        -n 3 -p mpirun -s PR3_UQ_MPI \                #          
+#       -w work_c_curv ../model ww3_tp2.1                                   #
+#  ./bin/run_test -g b_pseudo -n 3 -p mpirun -s PR3_UQ_MPI \                #          
+#       -w work_b_curv ../model ww3_tp2.1                                   #
+#                                                                           #
+#                                              Hendrik Tolman, Jun 2002     #
+#                                                   Last Mod : Dec 2013     #
+#                                                                           #
+#    Copyright 2009-2013 National Weather Service (NWS),                    #
+#       National Oceanic and Atmospheric Administration.  All rights        #
+#       reserved.  WAVEWATCH III is a trademark of the NWS.                 #
+#       No unauthorized use without permission.                             #
+#                                                                           #
+#############################################################################
+ 
+ Input directory: /home/ed/ww3/regtests/ww3_tp2.1/input
+ Switch file: /home/ed/ww3/regtests/ww3_tp2.1/input/switch_PR1_MPI
+ 
+ 
++--------------------+
+|  Grid preprocessor |
++--------------------+
+ 
+   Processing /home/ed/ww3/regtests/ww3_tp2.1/input/ww3_grid.inp
+   Screen output routed to /home/ed/ww3/regtests/ww3_tp2.1/work_PR1_MPI/ww3_grid.out
+ 
++--------------------+
+| Initial conditions |
++--------------------+
  
- Running now options: run_cmake_test /home/ed/ww3 ww3_tp1.1
+   Processing /home/ed/ww3/regtests/ww3_tp2.1/input/ww3_strt.inp
+   Screen output routed to /home/ed/ww3/regtests/ww3_tp2.1/work_PR1_MPI/ww3_strt.out
  
++--------------------+
+|    Main program    |
++--------------------+
+ 
+   Processing /home/ed/ww3/regtests/ww3_tp2.1/input/ww3_shel.inp
+   Screen output copied to /home/ed/ww3/regtests/ww3_tp2.1/work_PR1_MPI/ww3_shel.out
 
-ERROR: /home/ed/ww3/tools not found
-
+ *** WAVEWATCH III Program shell *** + =============================================== + + Comment character is '$' + + + Input fields : + -------------------------------------------------- + water levels ---/NO + currents ---/NO + winds ---/NO + ice fields ---/NO + momentum ---/NO + air density ---/NO + mean param. ---/NO + 1D spectra ---/NO + 2D spectra ---/NO + + Fields : Wave height + Peak frequency + Mean wave dir. a1b1 + Peak direction + Fields : no fields defined + + Initializations : + -------------------------------------------------- + + Time interval : + -------------------------------------------------- + Starting time : 1968/06/06 00:00:00 UTC + Ending time : 1968/06/06 05:00:00 UTC + + + Output requests : + -------------------------------------------------- + No dedicated output process, any file system. + + Type 1 : Fields of mean wave parameters + ----------------------------------------- + From : 1968/06/06 00:00:00 UTC + To : 1968/06/08 00:00:00 UTC + Interval : 00:06:00 + + output dates out of run dates : Restart files second request deactivated + Wave model ... + + Running model without input fields + -------------------------------------------------- + + WAVEWATCH III calculating for 1968/06/06 00:00:00 UTC at 06:08:54 + + *** WAVEWATCH III WARNING IN W3IOBC : + INPUT FILE WITH BOUNDARY CONDITIONS NOT FOUND + BOUNDARY CONDITIONS WILL NOT BE UPDATED 1 + + WAVEWATCH III calculating for 1968/06/06 00:06:00 UTC at 06:08:54 + WAVEWATCH III calculating for 1968/06/06 00:12:00 UTC at 06:08:54 + WAVEWATCH III calculating for 1968/06/06 00:18:00 UTC at 06:08:54 + WAVEWATCH III calculating for 1968/06/06 00:24:00 UTC at 06:08:54 + WAVEWATCH III calculating for 1968/06/06 00:30:00 UTC at 06:08:54 + WAVEWATCH III calculating for 1968/06/06 00:36:00 UTC at 06:08:54 + WAVEWATCH III calculating for 1968/06/06 00:42:00 UTC at 06:08:54 + WAVEWATCH III calculating for 1968/06/06 00:48:00 UTC at 06:08:54 + WAVEWATCH III calculating for 1968/06/06 00:54:00 UTC at 06:08:54 + WAVEWATCH III calculating for 1968/06/06 01:00:00 UTC at 06:08:54 + WAVEWATCH III calculating for 1968/06/06 01:06:00 UTC at 06:08:55 + WAVEWATCH III calculating for 1968/06/06 01:12:00 UTC at 06:08:55 + WAVEWATCH III calculating for 1968/06/06 01:18:00 UTC at 06:08:55 + WAVEWATCH III calculating for 1968/06/06 01:24:00 UTC at 06:08:55 + WAVEWATCH III calculating for 1968/06/06 01:30:00 UTC at 06:08:55 + WAVEWATCH III calculating for 1968/06/06 01:36:00 UTC at 06:08:55 + WAVEWATCH III calculating for 1968/06/06 01:42:00 UTC at 06:08:55 + WAVEWATCH III calculating for 1968/06/06 01:48:00 UTC at 06:08:55 + WAVEWATCH III calculating for 1968/06/06 01:54:00 UTC at 06:08:55 + WAVEWATCH III calculating for 1968/06/06 02:00:00 UTC at 06:08:55 + WAVEWATCH III calculating for 1968/06/06 02:06:00 UTC at 06:08:55 + WAVEWATCH III calculating for 1968/06/06 02:12:00 UTC at 06:08:55 + WAVEWATCH III calculating for 1968/06/06 02:18:00 UTC at 06:08:55 + WAVEWATCH III calculating for 1968/06/06 02:24:00 UTC at 06:08:55 + WAVEWATCH III calculating for 1968/06/06 02:30:00 UTC at 06:08:55 + WAVEWATCH III calculating for 1968/06/06 02:36:00 UTC at 06:08:55 + WAVEWATCH III calculating for 1968/06/06 02:42:00 UTC at 06:08:55 + WAVEWATCH III calculating for 1968/06/06 02:48:00 UTC at 06:08:55 + WAVEWATCH III calculating for 1968/06/06 02:54:00 UTC at 06:08:55 + WAVEWATCH III calculating for 1968/06/06 03:00:00 UTC at 06:08:55 + WAVEWATCH III calculating for 1968/06/06 03:06:00 UTC at 06:08:56 + WAVEWATCH III calculating for 1968/06/06 03:12:00 UTC at 06:08:56 + WAVEWATCH III calculating for 1968/06/06 03:18:00 UTC at 06:08:56 + WAVEWATCH III calculating for 1968/06/06 03:24:00 UTC at 06:08:56 + WAVEWATCH III calculating for 1968/06/06 03:30:00 UTC at 06:08:56 + WAVEWATCH III calculating for 1968/06/06 03:36:00 UTC at 06:08:56 + WAVEWATCH III calculating for 1968/06/06 03:42:00 UTC at 06:08:56 + WAVEWATCH III calculating for 1968/06/06 03:48:00 UTC at 06:08:56 + WAVEWATCH III calculating for 1968/06/06 03:54:00 UTC at 06:08:56 + WAVEWATCH III calculating for 1968/06/06 04:00:00 UTC at 06:08:56 + WAVEWATCH III calculating for 1968/06/06 04:06:00 UTC at 06:08:56 + WAVEWATCH III calculating for 1968/06/06 04:12:00 UTC at 06:08:56 + WAVEWATCH III calculating for 1968/06/06 04:18:00 UTC at 06:08:56 + WAVEWATCH III calculating for 1968/06/06 04:24:00 UTC at 06:08:56 + WAVEWATCH III calculating for 1968/06/06 04:30:00 UTC at 06:08:56 + WAVEWATCH III calculating for 1968/06/06 04:36:00 UTC at 06:08:56 + WAVEWATCH III calculating for 1968/06/06 04:42:00 UTC at 06:08:56 + WAVEWATCH III calculating for 1968/06/06 04:48:00 UTC at 06:08:56 + WAVEWATCH III calculating for 1968/06/06 04:54:00 UTC at 06:08:56 + WAVEWATCH III calculating for 1968/06/06 05:00:00 UTC at 06:08:56 + WAVEWATCH III reached the end of a computation loop at 06:08:56 + + Initialization time : 0.79 s + Elapsed time : 3.09 s + + End of program + ==================================== + WAVEWATCH III Program shell + +[WARNING] yaksa: 2 leaked handle pool objects +[WARNING] yaksa: 2 leaked handle pool objects +[WARNING] yaksa: 2 leaked handle pool objects +[WARNING] yaksa: 2 leaked handle pool objects +[WARNING] yaksa: 2 leaked handle pool objects +[WARNING] yaksa: 2 leaked handle pool objects +[WARNING] yaksa: 2 leaked handle pool objects +[WARNING] yaksa: 2 leaked handle pool objects +[WARNING] yaksa: 2 leaked handle pool objects +[WARNING] yaksa: 2 leaked handle pool objects +[WARNING] yaksa: 2 leaked handle pool objects +[WARNING] yaksa: 2 leaked handle pool objects +[WARNING] yaksa: 2 leaked handle pool objects +[WARNING] yaksa: 2 leaked handle pool objects +[WARNING] yaksa: 2 leaked handle pool objects +[WARNING] yaksa: 2 leaked handle pool objects +[WARNING] yaksa: 2 leaked handle pool objects +[WARNING] yaksa: 2 leaked handle pool objects +[WARNING] yaksa: 2 leaked handle pool objects +[WARNING] yaksa: 2 leaked handle pool objects +[WARNING] yaksa: 2 leaked handle pool objects +[WARNING] yaksa: 2 leaked handle pool objects +[WARNING] yaksa: 2 leaked handle pool objects +[WARNING] yaksa: 2 leaked handle pool objects + ++--------------------+ +| Gridded output | ++--------------------+ + + Processing /home/ed/ww3/regtests/ww3_tp2.1/input/ww3_outf_flds_hrly.inp + Screen output routed to /home/ed/ww3/regtests/ww3_tp2.1/work_PR1_MPI/ww3_outf_flds_hrly.out + Processing /home/ed/ww3/regtests/ww3_tp2.1/input/ww3_outf.inp + Screen output routed to /home/ed/ww3/regtests/ww3_tp2.1/work_PR1_MPI/ww3_outf.out + ++--------------------+ +| NC Gridded output | ++--------------------+ + + Processing /home/ed/ww3/regtests/ww3_tp2.1/input/ww3_ounf_flds_hrly.inp + Screen output routed to /home/ed/ww3/regtests/ww3_tp2.1/work_PR1_MPI/ww3_ounf_flds_hrly.out + Processing /home/ed/ww3/regtests/ww3_tp2.1/input/ww3_ounf.inp + Screen output routed to /home/ed/ww3/regtests/ww3_tp2.1/work_PR1_MPI/ww3_ounf.out + + +Files in /home/ed/ww3/regtests/ww3_tp2.1/work_PR1_MPI : + +total 3024 +drwxrwxr-x 9 ed ed 4096 Apr 2 06:08 build +-rw-rw-r-- 1 ed ed 395213 Apr 2 06:08 build.log +drwxrwxr-x 9 ed ed 4096 Apr 2 06:07 build_SHRD +drwxrwxr-x 2 ed ed 4096 Apr 2 06:07 exe +-rw-rw-r-- 1 ed ed 32 Apr 2 06:08 finished +-rw-rw-r-- 1 ed ed 5649 Apr 2 06:08 log.ww3 +-rw-rw-r-- 1 ed ed 47737 Apr 2 06:08 mod_def.ww3 +-rw-rw-r-- 1 ed ed 1214926 Apr 2 06:08 out_grd.ww3 +-rw-rw-r-- 1 ed ed 280800 Apr 2 06:08 restart.ww3 +-rw-rw-r-- 1 ed ed 443 Apr 2 06:08 time_count.txt +-rw-rw-r-- 1 ed ed 384096 Apr 2 06:08 ww3.196806.nc +-rw-rw-r-- 1 ed ed 22358 Apr 2 06:08 ww3.68060600.dir +-rw-rw-r-- 1 ed ed 22358 Apr 2 06:08 ww3.68060600.fp +-rw-rw-r-- 1 ed ed 22358 Apr 2 06:08 ww3.68060600.hs +-rw-rw-r-- 1 ed ed 22358 Apr 2 06:08 ww3.68060601.dir +-rw-rw-r-- 1 ed ed 22358 Apr 2 06:08 ww3.68060601.fp +-rw-rw-r-- 1 ed ed 22358 Apr 2 06:08 ww3.68060601.hs +-rw-rw-r-- 1 ed ed 22358 Apr 2 06:08 ww3.68060602.dir +-rw-rw-r-- 1 ed ed 22358 Apr 2 06:08 ww3.68060602.fp +-rw-rw-r-- 1 ed ed 22358 Apr 2 06:08 ww3.68060602.hs +-rw-rw-r-- 1 ed ed 22358 Apr 2 06:08 ww3.68060603.dir +-rw-rw-r-- 1 ed ed 22358 Apr 2 06:08 ww3.68060603.fp +-rw-rw-r-- 1 ed ed 22358 Apr 2 06:08 ww3.68060603.hs +-rw-rw-r-- 1 ed ed 22358 Apr 2 06:08 ww3.68060604.dir +-rw-rw-r-- 1 ed ed 22358 Apr 2 06:08 ww3.68060604.fp +-rw-rw-r-- 1 ed ed 22358 Apr 2 06:08 ww3.68060604.hs +-rw-rw-r-- 1 ed ed 22358 Apr 2 06:08 ww3.68060605.dir +-rw-rw-r-- 1 ed ed 22358 Apr 2 06:08 ww3.68060605.fp +-rw-rw-r-- 1 ed ed 22358 Apr 2 06:08 ww3.68060605.hs +-rw-rw-r-- 1 ed ed 13246 Apr 2 06:08 ww3_grid.out +-rw-rw-r-- 1 ed ed 3040 Apr 2 06:08 ww3_ounf_flds_hrly.out +-rw-rw-r-- 1 ed ed 6355 Apr 2 06:08 ww3_ounf.out +-rw-rw-r-- 1 ed ed 1776 Apr 2 06:08 ww3_outf_flds_hrly.out +-rw-rw-r-- 1 ed ed 247323 Apr 2 06:08 ww3_outf.out +-rw-rw-r-- 1 ed ed 5551 Apr 2 06:08 ww3_shel.out +-rw-rw-r-- 1 ed ed 3405 Apr 2 06:08 ww3_strt.out + + + ================================== + ======> END OF WAVEWATCH III <====== + ================================== + ## References From fdbb2b8477390862e976cd60a5740baff4753e15 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Tue, 2 Apr 2024 06:11:52 -0600 Subject: [PATCH 045/126] trying a regtest --- .github/workflows/regtest_gnu.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/regtest_gnu.yml b/.github/workflows/regtest_gnu.yml index fdca743d5..b423199b7 100644 --- a/.github/workflows/regtest_gnu.yml +++ b/.github/workflows/regtest_gnu.yml @@ -107,10 +107,8 @@ jobs: cmake -DSWITCH=${GITHUB_WORKSPACE}/ww3/regtests/unittests/data/switch.io -DCMAKE_BUILD_TYPE=Debug .. make -j2 VERBOSE=1 ${GITHUB_WORKSPACE}/ww3/model/bin/ww3_from_ftp.sh - cd ${GITHUB_WORKSPACE}/ww3/regtests/ww3_tp1.1 - pwd - ls -l - ${GITHUB_WORKSPACE}/ww3/build/bin/ww3_grid + cd ${GITHUB_WORKSPACE}/ww3/regtests + ./bin/run_cmake_test -o all -S -T -s PR1_MPI -w work_PR1_MPI -f -p mpirun -n 24 ../model ww3_tp2.1 From 1dd3e754d32a204366620b652e2debe5645dbc74 Mon Sep 17 00:00:00 2001 From: JessicaMeixner-NOAA Date: Tue, 2 Apr 2024 08:48:51 -0500 Subject: [PATCH 046/126] fix typo --- model/src/w3iopomd.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index 4e5727bdb..7eec2b615 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -1998,7 +1998,7 @@ SUBROUTINE W3IOPO ( INXOUT, NDSOP, IOTST, IMOD & ! IF ( WRITE ) THEN WRITE (NDSOP) & - eDSTR, VEROPT, NK, NTH, NOPTS + DSTR, VEROPT, NK, NTH, NOPTS #ifdef W3_ASCII WRITE (NDSOA,*) & 'IDSTR, VEROPT, NK, NTH, NOPTS:', & From ea46887b5ecc09b0a7eb13470cb12f124dfa0ab7 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Tue, 2 Apr 2024 07:54:27 -0600 Subject: [PATCH 047/126] regtest progress --- .github/workflows/regtest_gnu.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/regtest_gnu.yml b/.github/workflows/regtest_gnu.yml index b423199b7..56fb8447a 100644 --- a/.github/workflows/regtest_gnu.yml +++ b/.github/workflows/regtest_gnu.yml @@ -108,7 +108,10 @@ jobs: make -j2 VERBOSE=1 ${GITHUB_WORKSPACE}/ww3/model/bin/ww3_from_ftp.sh cd ${GITHUB_WORKSPACE}/ww3/regtests - ./bin/run_cmake_test -o all -S -T -s PR1_MPI -w work_PR1_MPI -f -p mpirun -n 24 ../model ww3_tp2.1 + ./bin/run_cmake_test -o all -S -T -s PR1_MPI -w work_PR1_MPI -f -p mpirun -n 24 ../model ww3_tp1.1 + cd ww3_tp1.1 + ls -l + From 0ff57b79db4650f3295f76dcb3e8c8d8aac0707d Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Tue, 2 Apr 2024 07:57:54 -0600 Subject: [PATCH 048/126] regtest progress --- .github/workflows/regtest_gnu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/regtest_gnu.yml b/.github/workflows/regtest_gnu.yml index 56fb8447a..859e4583f 100644 --- a/.github/workflows/regtest_gnu.yml +++ b/.github/workflows/regtest_gnu.yml @@ -108,7 +108,7 @@ jobs: make -j2 VERBOSE=1 ${GITHUB_WORKSPACE}/ww3/model/bin/ww3_from_ftp.sh cd ${GITHUB_WORKSPACE}/ww3/regtests - ./bin/run_cmake_test -o all -S -T -s PR1_MPI -w work_PR1_MPI -f -p mpirun -n 24 ../model ww3_tp1.1 + ./bin/run_cmake_test -o all -S -T -s PR1_MPI -w work_PR1_MPI -f -p mpirun -n 24 ../model ww3_tp2.1 cd ww3_tp1.1 ls -l From 6ec78a9aa033d39b2dcbf7969b45d35d32ea7b00 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Tue, 2 Apr 2024 08:10:49 -0600 Subject: [PATCH 049/126] regtest progress --- .github/workflows/regtest_gnu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/regtest_gnu.yml b/.github/workflows/regtest_gnu.yml index 859e4583f..0233ea788 100644 --- a/.github/workflows/regtest_gnu.yml +++ b/.github/workflows/regtest_gnu.yml @@ -108,7 +108,7 @@ jobs: make -j2 VERBOSE=1 ${GITHUB_WORKSPACE}/ww3/model/bin/ww3_from_ftp.sh cd ${GITHUB_WORKSPACE}/ww3/regtests - ./bin/run_cmake_test -o all -S -T -s PR1_MPI -w work_PR1_MPI -f -p mpirun -n 24 ../model ww3_tp2.1 + ./bin/run_cmake_test -o all -S -T -s PR1_MPI -w work_PR1_MPI -f -p mpirun -n 24 ../model ww3_tp1.2 cd ww3_tp1.1 ls -l From a70ed47f81b9580c0cd2f823cbed864ff4962f3b Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Tue, 2 Apr 2024 08:34:03 -0600 Subject: [PATCH 050/126] more regtest --- .github/workflows/regtest_gnu.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/regtest_gnu.yml b/.github/workflows/regtest_gnu.yml index 0233ea788..fe99a6f5e 100644 --- a/.github/workflows/regtest_gnu.yml +++ b/.github/workflows/regtest_gnu.yml @@ -108,8 +108,8 @@ jobs: make -j2 VERBOSE=1 ${GITHUB_WORKSPACE}/ww3/model/bin/ww3_from_ftp.sh cd ${GITHUB_WORKSPACE}/ww3/regtests - ./bin/run_cmake_test -o all -S -T -s PR1_MPI -w work_PR1_MPI -f -p mpirun -n 24 ../model ww3_tp1.2 - cd ww3_tp1.1 + ./bin/run_cmake_test -o all -S -T -s PR1_MPI -w work_PR1_MPI -f -p mpirun -n 24 ../model ww3_tp2.3 + cd ww3_tp2.3 ls -l From 57deae144e5bdb829a75f134911ede01b957285c Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Tue, 2 Apr 2024 09:37:11 -0600 Subject: [PATCH 051/126] more regtest --- .github/workflows/regtest_gnu.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/regtest_gnu.yml b/.github/workflows/regtest_gnu.yml index fe99a6f5e..11b176975 100644 --- a/.github/workflows/regtest_gnu.yml +++ b/.github/workflows/regtest_gnu.yml @@ -108,8 +108,10 @@ jobs: make -j2 VERBOSE=1 ${GITHUB_WORKSPACE}/ww3/model/bin/ww3_from_ftp.sh cd ${GITHUB_WORKSPACE}/ww3/regtests - ./bin/run_cmake_test -o all -S -T -s PR1_MPI -w work_PR1_MPI -f -p mpirun -n 24 ../model ww3_tp2.3 - cd ww3_tp2.3 + ./bin/run_cmake_test -o all -S -T -s PR1_MPI -w work_PR1_MPI -f -p mpirun -n 24 ../model ww3_tp2.4 + cd ww3_tp2.4 + ./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 From 34c3f8c1b13b1a9a0867386dc3531b5e52932ee4 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Tue, 2 Apr 2024 10:06:15 -0600 Subject: [PATCH 052/126] more regtest --- .github/workflows/regtest_gnu.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/regtest_gnu.yml b/.github/workflows/regtest_gnu.yml index 11b176975..58f8b8401 100644 --- a/.github/workflows/regtest_gnu.yml +++ b/.github/workflows/regtest_gnu.yml @@ -110,6 +110,7 @@ jobs: cd ${GITHUB_WORKSPACE}/ww3/regtests ./bin/run_cmake_test -o all -S -T -s PR1_MPI -w work_PR1_MPI -f -p mpirun -n 24 ../model ww3_tp2.4 cd ww3_tp2.4 + cd .. ./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 From 14f771d1807ba16405137aa51deb08be3f26a9d0 Mon Sep 17 00:00:00 2001 From: JessicaMeixner-NOAA Date: Tue, 2 Apr 2024 12:17:31 -0500 Subject: [PATCH 053/126] fixes errors for successful build --- model/src/w3iopomd.F90 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index 7eec2b615..ce05234d1 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -146,7 +146,7 @@ MODULE W3IOPOMD character(*), parameter, private :: VNAME_NK = 'NK' !> Variable name for the netCDF point output file, for MTH. - character(*), parameter, private :: VNAME_MTH = 'MTH' + character(*), parameter, private :: VNAME_NTH = 'NTH' !> Variable name for the netCDF point output file, for PTLOC. character(*), parameter, private :: VNAME_PTLOC = 'PTLOC' @@ -1134,6 +1134,7 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr) IL, IW, II, PTLOC, PTIFAC, DPO, WAO, WDO, & ASO, CAO, CDO, SPCO, PTNME, O2INIT, FNMPRE, & GRDID, ICEO, ICEHO, ICEFO + USE W3SERVMD, ONLY: EXTCDE #ifdef W3_FLX5 USE W3ODATMD, ONLY: TAUAO, TAUDO, DAIRO #endif @@ -1146,6 +1147,7 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr) INTEGER, INTENT(IN), OPTIONAL :: IMOD character(*), intent(in) :: filename integer, intent(inout) :: ncerr + INTEGER :: MK,MTH integer :: fh integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen integer :: d_nopts_len, d_nspec_len, d_vsize_len, d_namelen_len, d_grdidlen_len @@ -1321,6 +1323,9 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr) 903 FORMAT (/' *** WAVEWATCH III ERROR IN W3IOPON :'/ & ' ILEGAL VEROPT, READ : ',A/ & ' CHECK : ',A/) +904 FORMAT (/' *** WAVEWATCH III ERROR IN W3IOPO :'/ & + ' ERROR IN SPECTRA, MK, MTH : ',2I8/ & + ' ARRAY DIMENSIONS : ',2I8/) END SUBROUTINE W3IOPON_READ @@ -1998,7 +2003,7 @@ SUBROUTINE W3IOPO ( INXOUT, NDSOP, IOTST, IMOD & ! IF ( WRITE ) THEN WRITE (NDSOP) & - DSTR, VEROPT, NK, NTH, NOPTS + IDSTR, VEROPT, NK, NTH, NOPTS #ifdef W3_ASCII WRITE (NDSOA,*) & 'IDSTR, VEROPT, NK, NTH, NOPTS:', & From 6cfc1c123d187042832a3cefd76f0fa44d97a6ce Mon Sep 17 00:00:00 2001 From: JessicaMeixner-NOAA Date: Tue, 2 Apr 2024 13:25:14 -0500 Subject: [PATCH 054/126] save debug temporarily --- model/src/w3iopomd.F90 | 49 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index ce05234d1..662a873ad 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -1371,12 +1371,14 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) !!JDM - defined in module above CHARACTER(LEN=31), PARAMETER :: IDSTR = 'WAVEWATCH III POINT OUTPUT FILE' !!JDM - defined in module above CHARACTER(LEN=10), PARAMETER :: VEROPT = '2021-04-06' + write(*,*) 'JDM in write', IPASS, timestep_only !If first pass, or if you are writting a file for every time-step: IF ( IPASS.EQ.1 .OR. timestep_only.EQ.1 ) THEN ! Create the netCDF file. ncerr = nf90_create(filename, NF90_NETCDF4, fh) if (ncerr .ne. 0) return - + + write(*,*)'JDM a' ! Define dimensions. ncerr = nf90_def_dim(fh, DNAME_NOPTS, NOPTS, d_nopts) if (ncerr .ne. 0) return @@ -1391,26 +1393,26 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) ncerr = nf90_def_dim(fh, DNAME_TIME, NF90_UNLIMITED, d_time) if (ncerr .ne. 0) return + write(*,*) 'JDM b' ! Define global attributes. ncerr = nf90_put_att(fh, NF90_GLOBAL, 'title', IDSTR) if (ncerr .ne. 0) return ncerr = nf90_put_att(fh, NF90_GLOBAL, 'version', VEROPT) if (ncerr .ne. 0) return + write(*,*) 'JDM c' ! Define scalar variables. ncerr = nf90_def_var(fh, VNAME_NK, NF90_INT, v_nk) if (ncerr .ne. 0) return ncerr = nf90_def_var(fh, VNAME_NTH, NF90_INT, v_nth) if (ncerr .ne. 0) return + write(*,*) 'JDM d' ! Define vars with nopts as a dimension. ncerr = nf90_def_var(fh, VNAME_PTLOC, NF90_INT, (/d_vsize, d_nopts/), v_ptloc) if (ncerr .ne. 0) return ncerr = nf90_def_var(fh, VNAME_PTNME, NF90_CHAR, (/d_namelen, d_nopts/), v_ptnme) if (ncerr .ne. 0) return - - -!ed's code: ncerr = nf90_def_var(fh, VNAME_IW, NF90_INT, (/d_nopts, d_time/), v_iw) if (ncerr .ne. 0) return ncerr = nf90_def_var(fh, VNAME_II, NF90_INT, (/d_nopts, d_time/), v_ii) @@ -1452,58 +1454,95 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) if (ncerr .ne. 0) return ncerr = nf90_def_var(fh, VNAME_SPCO, NF90_INT, (/d_nspec, d_nopts, d_time/), v_spco) if (ncerr .ne. 0) return - + write(*,*) 'JDM c' ! Write the scalar data. ncerr = nf90_put_var(fh, v_nk, NK) if (ncerr .ne. 0) return ncerr = nf90_put_var(fh, v_nth, NTH) if (ncerr .ne. 0) return + write(*,*) 'JDM e' ! Write the data with NOPTS as a dimension. ncerr = nf90_put_var(fh, v_ptloc, PTLOC) if (ncerr .ne. 0) return ncerr = nf90_put_var(fh, v_ptnme, PTNME) if (ncerr .ne. 0) return + ELSE + write(*,*) 'JDM else' + ncerr = nf90_open(filename, nf90_write, fh) + if (ncerr .ne. 0) return END IF + write(*,*) 'JDM f 1' ncerr = nf90_put_var(fh, v_iw, IW) if (ncerr .ne. 0) return + write(*,*) 'JDM f 2' + ncerr = nf90_put_var(fh, v_ii, II) if (ncerr .ne. 0) return + write(*,*) 'JDM f 3' + ncerr = nf90_put_var(fh, v_il, IL) if (ncerr .ne. 0) return + write(*,*) 'JDM f 4' + ncerr = nf90_put_var(fh, v_dpo, DPO) if (ncerr .ne. 0) return + write(*,*) 'JDM f 5' + ncerr = nf90_put_var(fh, v_wao, WAO) if (ncerr .ne. 0) return #ifdef W3_FLX5 + write(*,*) 'JDM f 6' + ncerr = nf90_put_var(fh, v_tauao, TAUAO) if (ncerr .ne. 0) return + write(*,*) 'JDM f 7' + ncerr = nf90_put_var(fh, v_taido, TAIDO) if (ncerr .ne. 0) return + write(*,*) 'JDM f 8' + ncerr = nf90_put_var(fh, v_dairo, DAIRO) if (ncerr .ne. 0) return #endif #ifdef W3_SETUP + write(*,*) 'JDM f 9' + ncerr = nf90_put_var(fh, v_zet_seto, ZET_SETO) if (ncerr .ne. 0) return #endif + write(*,*) 'JDM f 10' + ncerr = nf90_put_var(fh, v_aso, ASO) if (ncerr .ne. 0) return + write(*,*) 'JDM f 11' + ncerr = nf90_put_var(fh, v_cao, CAO) if (ncerr .ne. 0) return + write(*,*) 'JDM f 12' + ncerr = nf90_put_var(fh, v_iceo, ICEO) if (ncerr .ne. 0) return + write(*,*) 'JDM f 13' + ncerr = nf90_put_var(fh, v_iceho, ICEHO) if (ncerr .ne. 0) return + write(*,*) 'JDM f 14' + ncerr = nf90_put_var(fh, v_icefo, ICEFO) if (ncerr .ne. 0) return + write(*,*) 'JDM f 15' + ncerr = nf90_put_var(fh, v_grdid, GRDID) if (ncerr .ne. 0) return + write(*,*) 'JDM f 16' + ncerr = nf90_put_var(fh, v_spco, SPCO) if (ncerr .ne. 0) return + write(*,*) 'JDM g' ! Close the file. ncerr = nf90_close(fh) if (ncerr .ne. 0) return From ec1dc8446bddf15c62ce8978bb0269d2ee92493e Mon Sep 17 00:00:00 2001 From: JessicaMeixner-NOAA Date: Tue, 2 Apr 2024 13:57:31 -0500 Subject: [PATCH 055/126] attempt to add start/count to netcdf putvar --- model/src/w3iopomd.F90 | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index 662a873ad..ebbd96766 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -1362,7 +1362,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) INTEGER, INTENT(IN) :: IMOD character(*), intent(in) :: filename integer, intent(inout) :: ncerr - integer :: fh, ndim, nvar, fmt + integer :: fh, ndim, nvar, fmt, itime integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen, d_time integer :: v_idtst, v_vertst, v_nk, v_nth, v_ptloc, v_ptnme integer :: v_iw, v_ii, v_il, v_dpo, v_wao, v_wdo, v_tauao @@ -1467,15 +1467,22 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) if (ncerr .ne. 0) return ncerr = nf90_put_var(fh, v_ptnme, PTNME) if (ncerr .ne. 0) return - + ELSE write(*,*) 'JDM else' ncerr = nf90_open(filename, nf90_write, fh) if (ncerr .ne. 0) return END IF + IF ( timestep_only.EQ.1 ) THEN + itime=1 + ELSE + itime=IPASS + END IF + write(*,*) 'JDM f 1' - ncerr = nf90_put_var(fh, v_iw, IW) + ncerr = nf90_put_var(fh, v_iw, IW, start = (/ 1, IPASS/), & + count = (/ d_nopts, 1 /)) if (ncerr .ne. 0) return write(*,*) 'JDM f 2' From 10d81871f4e05d6d3bd756dd5c0bc9ef21a09b04 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Tue, 2 Apr 2024 13:48:44 -0600 Subject: [PATCH 056/126] fixed merge problem --- model/src/w3iopomd.F90 | 2 -- 1 file changed, 2 deletions(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index 0f3fe6fd4..f58adeb49 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -1327,8 +1327,6 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr) ' ERROR IN SPECTRA, MK, MTH : ',2I8/ & ' ARRAY DIMENSIONS : ',2I8/) - ->>>>>>> ec1dc8446bddf15c62ce8978bb0269d2ee92493e END SUBROUTINE W3IOPON_READ !/ ------------------------------------------------------------------- / From b8057a729b49d6da91581c27380479c236833c98 Mon Sep 17 00:00:00 2001 From: JessicaMeixner-NOAA Date: Tue, 2 Apr 2024 15:07:48 -0500 Subject: [PATCH 057/126] try to add enddef to see if that fixes issue --- model/src/w3iopomd.F90 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index ebbd96766..5c6e6db9a 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -1393,6 +1393,9 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) ncerr = nf90_def_dim(fh, DNAME_TIME, NF90_UNLIMITED, d_time) if (ncerr .ne. 0) return + ncerr = nf90_enddef(fh) + if (ncerr .ne. 0) return + write(*,*) 'JDM b' ! Define global attributes. ncerr = nf90_put_att(fh, NF90_GLOBAL, 'title', IDSTR) From af3dcd14e0c8e735dc2c2c32da47483ea4f2a940 Mon Sep 17 00:00:00 2001 From: JessicaMeixner-NOAA Date: Tue, 2 Apr 2024 15:15:57 -0500 Subject: [PATCH 058/126] put enddef in correct location --- model/src/w3iopomd.F90 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index 5c6e6db9a..890ce8925 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -1393,9 +1393,6 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) ncerr = nf90_def_dim(fh, DNAME_TIME, NF90_UNLIMITED, d_time) if (ncerr .ne. 0) return - ncerr = nf90_enddef(fh) - if (ncerr .ne. 0) return - write(*,*) 'JDM b' ! Define global attributes. ncerr = nf90_put_att(fh, NF90_GLOBAL, 'title', IDSTR) @@ -1457,6 +1454,11 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) if (ncerr .ne. 0) return ncerr = nf90_def_var(fh, VNAME_SPCO, NF90_INT, (/d_nspec, d_nopts, d_time/), v_spco) if (ncerr .ne. 0) return + + write(*,*) 'JDM bb' + ncerr = nf90_enddef(fh) + if (ncerr .ne. 0) return + write(*,*) 'JDM c' ! Write the scalar data. ncerr = nf90_put_var(fh, v_nk, NK) From bcd43800116851f5865676589b533d9b726b36bd Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Tue, 2 Apr 2024 14:32:46 -0600 Subject: [PATCH 059/126] fixed merge problem --- model/src/w3iopomd.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index f58adeb49..72e9c8290 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -146,7 +146,7 @@ MODULE W3IOPOMD character(*), parameter, private :: VNAME_NK = 'NK' !> Variable name for the netCDF point output file, for MTH. - character(*), parameter, private :: VNAME_MTH = 'MTH' + character(*), parameter, private :: VNAME_NTH = 'NTH' !> Variable name for the netCDF point output file, for PTLOC. character(*), parameter, private :: VNAME_PTLOC = 'PTLOC' From 15ee016c4cf82cf023447c2a1ff5b8bc1c6d448d Mon Sep 17 00:00:00 2001 From: JessicaMeixner-NOAA Date: Tue, 2 Apr 2024 15:44:50 -0500 Subject: [PATCH 060/126] inquire variable IDs if it's not the first time through the file --- model/src/w3iopomd.F90 | 131 +++++++++++++++++++++++++++++++---------- 1 file changed, 100 insertions(+), 31 deletions(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index 890ce8925..b18a448f3 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -1486,72 +1486,141 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) END IF write(*,*) 'JDM f 1' - ncerr = nf90_put_var(fh, v_iw, IW, start = (/ 1, IPASS/), & - count = (/ d_nopts, 1 /)) + IF ( itime > 1 ) THEN + ncerr = nf90_inq_varid(fh, VNAME_IW, v_iw) + if (ncerr .ne. 0) return + END IF + + ! TO DO ADD TIME VARIABLE + ncerr = nf90_put_var(fh, v_iw, IW, start = (/ 1, itime/), & + count = (/ d_nopts, 1 /)) if (ncerr .ne. 0) return write(*,*) 'JDM f 2' - - ncerr = nf90_put_var(fh, v_ii, II) + IF ( itime > 1 ) THEN + ncerr = nf90_inq_varid(fh, VNAME_II, v_ii) + if (ncerr .ne. 0) return + END IF + ncerr = nf90_put_var(fh, v_ii, II, start = (/ 1, itime/), & + count = (/ d_nopts, 1 /)) if (ncerr .ne. 0) return write(*,*) 'JDM f 3' - - ncerr = nf90_put_var(fh, v_il, IL) + IF ( itime > 1 ) THEN + ncerr = nf90_inq_varid(fh, VNAME_IL, v_il) + if (ncerr .ne. 0) return + END IF + ncerr = nf90_put_var(fh, v_il, IL, start = (/ 1, itime/), & + count = (/ d_nopts, 1 /)) if (ncerr .ne. 0) return write(*,*) 'JDM f 4' - - ncerr = nf90_put_var(fh, v_dpo, DPO) +!HERE + IF ( itime > 1 ) THEN + ncerr = nf90_inq_varid(fh, VNAME_DPO, v_dpo) + if (ncerr .ne. 0) return + END IF + ncerr = nf90_put_var(fh, v_dpo, DPO, start = (/ 1, itime/), & + count = (/ d_nopts, 1 /)) if (ncerr .ne. 0) return write(*,*) 'JDM f 5' - - ncerr = nf90_put_var(fh, v_wao, WAO) + IF ( itime > 1 ) THEN + ncerr = nf90_inq_varid(fh, VNAME_WAO, v_wao) + if (ncerr .ne. 0) return + END IF + ncerr = nf90_put_var(fh, v_wao, WAO, start = (/ 1, itime/), & + count = (/ d_nopts, 1 /)) if (ncerr .ne. 0) return #ifdef W3_FLX5 write(*,*) 'JDM f 6' - - ncerr = nf90_put_var(fh, v_tauao, TAUAO) + IF ( itime > 1 ) THEN + ncerr = nf90_inq_varid(fh, VNAME_TAUAO, v_tauao) + if (ncerr .ne. 0) return + END IF + ncerr = nf90_put_var(fh, v_tauao, TAUAO, start = (/ 1, itime/), & + count = (/ d_nopts, 1 /)) if (ncerr .ne. 0) return write(*,*) 'JDM f 7' - - ncerr = nf90_put_var(fh, v_taido, TAIDO) + IF ( itime > 1 ) THEN + ncerr = nf90_inq_varid(fh, VNAME_TAIDO, v_taido) + if (ncerr .ne. 0) return + END IF + ncerr = nf90_put_var(fh, v_taido, TAIDO, start = (/ 1, itime/), & + count = (/ d_nopts, 1 /)) if (ncerr .ne. 0) return write(*,*) 'JDM f 8' - - ncerr = nf90_put_var(fh, v_dairo, DAIRO) + IF ( itime > 1 ) THEN + ncerr = nf90_inq_varid(fh, VNAME_DAIRO, v_dairo) + if (ncerr .ne. 0) return + END IF + ncerr = nf90_put_var(fh, v_dairo, DAIRO, start = (/ 1, itime/), & + count = (/ d_nopts, 1 /)) if (ncerr .ne. 0) return #endif #ifdef W3_SETUP write(*,*) 'JDM f 9' - - ncerr = nf90_put_var(fh, v_zet_seto, ZET_SETO) + IF ( itime > 1 ) THEN + ncerr = nf90_inq_varid(fh, VNAME_ZET_SETO, v_zet_seto) + if (ncerr .ne. 0) return + END IF + ncerr = nf90_put_var(fh, v_zet_seto, ZET_SETO, start = (/ 1, itime/), & + count = (/ d_nopts, 1 /)) if (ncerr .ne. 0) return #endif write(*,*) 'JDM f 10' - - ncerr = nf90_put_var(fh, v_aso, ASO) + IF ( itime > 1 ) THEN + ncerr = nf90_inq_varid(fh, VNAME_ASO, v_aso) + if (ncerr .ne. 0) return + END IF + ncerr = nf90_put_var(fh, v_aso, ASO, start = (/ 1, itime/), & + count = (/ d_nopts, 1 /)) if (ncerr .ne. 0) return write(*,*) 'JDM f 11' - - ncerr = nf90_put_var(fh, v_cao, CAO) + IF ( itime > 1 ) THEN + ncerr = nf90_inq_varid(fh, VNAME_CAO, v_cao) + if (ncerr .ne. 0) return + END IF + ncerr = nf90_put_var(fh, v_cao, CAO, start = (/ 1, itime/), & + count = (/ d_nopts, 1 /)) if (ncerr .ne. 0) return write(*,*) 'JDM f 12' - - ncerr = nf90_put_var(fh, v_iceo, ICEO) + IF ( itime > 1 ) THEN + ncerr = nf90_inq_varid(fh, VNAME_ICEO, v_iceo) + if (ncerr .ne. 0) return + END IF + ncerr = nf90_put_var(fh, v_iceo, ICEO, start = (/ 1, itime/), & + count = (/ d_nopts, 1 /)) if (ncerr .ne. 0) return write(*,*) 'JDM f 13' - - ncerr = nf90_put_var(fh, v_iceho, ICEHO) + IF ( itime > 1 ) THEN + ncerr = nf90_inq_varid(fh, VNAME_ICEHO, v_iceho) + if (ncerr .ne. 0) return + END IF + ncerr = nf90_put_var(fh, v_iceho, ICEHO, start = (/ 1, itime/), & + count = (/ d_nopts, 1 /)) if (ncerr .ne. 0) return write(*,*) 'JDM f 14' - - ncerr = nf90_put_var(fh, v_icefo, ICEFO) + IF ( itime > 1 ) THEN + ncerr = nf90_inq_varid(fh, VNAME_ICEFO, v_icefo) + if (ncerr .ne. 0) return + END IF + ncerr = nf90_put_var(fh, v_icefo, ICEFO, start = (/ 1, itime/), & + count = (/ d_nopts, 1 /)) if (ncerr .ne. 0) return write(*,*) 'JDM f 15' - ncerr = nf90_put_var(fh, v_grdid, GRDID) + IF ( itime > 1 ) THEN + ncerr = nf90_inq_varid(fh, VNAME_GRDID, v_grdid) + if (ncerr .ne. 0) return + END IF +!!! TO DO ADD GRIDLENTH? + ncerr = nf90_put_var(fh, v_grdid, GRDID, start = (/ 1, itime/), & + count = (/ d_nopts, 1 /)) if (ncerr .ne. 0) return write(*,*) 'JDM f 16' - - ncerr = nf90_put_var(fh, v_spco, SPCO) + IF ( itime > 1 ) THEN + ncerr = nf90_inq_varid(fh, VNAME_SPCO, v_spco) + if (ncerr .ne. 0) return + END IF + ncerr = nf90_put_var(fh, v_spco, SPCO, start = (/ 1, 1, itime/), & + count = (/d_nspec, d_nopts, 1 /)) if (ncerr .ne. 0) return write(*,*) 'JDM g' From 402d16a280f9a66be0278ccb377d18360197efea Mon Sep 17 00:00:00 2001 From: JessicaMeixner-NOAA Date: Tue, 2 Apr 2024 15:47:06 -0500 Subject: [PATCH 061/126] fix for grdid --- model/src/w3iopomd.F90 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index b18a448f3..5e4e4edf7 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -1610,9 +1610,8 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) ncerr = nf90_inq_varid(fh, VNAME_GRDID, v_grdid) if (ncerr .ne. 0) return END IF -!!! TO DO ADD GRIDLENTH? - ncerr = nf90_put_var(fh, v_grdid, GRDID, start = (/ 1, itime/), & - count = (/ d_nopts, 1 /)) + ncerr = nf90_put_var(fh, v_grdid, GRDID, start = (/ 1, 1, itime/), & + count = (/ d_grdidlen, d_nopts, 1 /)) if (ncerr .ne. 0) return write(*,*) 'JDM f 16' IF ( itime > 1 ) THEN From 7331db1d84e5ebfd545bfc27148730e612f4a952 Mon Sep 17 00:00:00 2001 From: JessicaMeixner-NOAA Date: Tue, 2 Apr 2024 15:55:41 -0500 Subject: [PATCH 062/126] can write file, adding write to check content --- model/src/w3iopomd.F90 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index 5e4e4edf7..8a424b2f2 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -1485,16 +1485,17 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) itime=IPASS END IF + ! TO DO ADD TIME VARIABLE + write(*,*) 'JDM f 1' IF ( itime > 1 ) THEN ncerr = nf90_inq_varid(fh, VNAME_IW, v_iw) if (ncerr .ne. 0) return END IF - - ! TO DO ADD TIME VARIABLE ncerr = nf90_put_var(fh, v_iw, IW, start = (/ 1, itime/), & count = (/ d_nopts, 1 /)) if (ncerr .ne. 0) return + write(*,*) 'IW:', IW write(*,*) 'JDM f 2' IF ( itime > 1 ) THEN ncerr = nf90_inq_varid(fh, VNAME_II, v_ii) @@ -1512,7 +1513,6 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) count = (/ d_nopts, 1 /)) if (ncerr .ne. 0) return write(*,*) 'JDM f 4' -!HERE IF ( itime > 1 ) THEN ncerr = nf90_inq_varid(fh, VNAME_DPO, v_dpo) if (ncerr .ne. 0) return @@ -1605,7 +1605,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) count = (/ d_nopts, 1 /)) if (ncerr .ne. 0) return write(*,*) 'JDM f 15' - + write(*,*) 'GRDID:',GRDID IF ( itime > 1 ) THEN ncerr = nf90_inq_varid(fh, VNAME_GRDID, v_grdid) if (ncerr .ne. 0) return From 46a9ff8a317373c20874e3c37dbf50e8f842cb60 Mon Sep 17 00:00:00 2001 From: JessicaMeixner-NOAA Date: Tue, 2 Apr 2024 21:24:33 -0500 Subject: [PATCH 063/126] fix output in write for dimensions --- model/src/w3iopomd.F90 | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index 8a424b2f2..93d7d018b 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -1493,7 +1493,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) if (ncerr .ne. 0) return END IF ncerr = nf90_put_var(fh, v_iw, IW, start = (/ 1, itime/), & - count = (/ d_nopts, 1 /)) + count = (/ NOPTS, 1 /)) if (ncerr .ne. 0) return write(*,*) 'IW:', IW write(*,*) 'JDM f 2' @@ -1502,7 +1502,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) if (ncerr .ne. 0) return END IF ncerr = nf90_put_var(fh, v_ii, II, start = (/ 1, itime/), & - count = (/ d_nopts, 1 /)) + count = (/ nopts, 1 /)) if (ncerr .ne. 0) return write(*,*) 'JDM f 3' IF ( itime > 1 ) THEN @@ -1510,7 +1510,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) if (ncerr .ne. 0) return END IF ncerr = nf90_put_var(fh, v_il, IL, start = (/ 1, itime/), & - count = (/ d_nopts, 1 /)) + count = (/ nopts, 1 /)) if (ncerr .ne. 0) return write(*,*) 'JDM f 4' IF ( itime > 1 ) THEN @@ -1518,7 +1518,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) if (ncerr .ne. 0) return END IF ncerr = nf90_put_var(fh, v_dpo, DPO, start = (/ 1, itime/), & - count = (/ d_nopts, 1 /)) + count = (/ nopts, 1 /)) if (ncerr .ne. 0) return write(*,*) 'JDM f 5' IF ( itime > 1 ) THEN @@ -1526,7 +1526,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) if (ncerr .ne. 0) return END IF ncerr = nf90_put_var(fh, v_wao, WAO, start = (/ 1, itime/), & - count = (/ d_nopts, 1 /)) + count = (/ nopts, 1 /)) if (ncerr .ne. 0) return #ifdef W3_FLX5 write(*,*) 'JDM f 6' @@ -1535,7 +1535,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) if (ncerr .ne. 0) return END IF ncerr = nf90_put_var(fh, v_tauao, TAUAO, start = (/ 1, itime/), & - count = (/ d_nopts, 1 /)) + count = (/ nopts, 1 /)) if (ncerr .ne. 0) return write(*,*) 'JDM f 7' IF ( itime > 1 ) THEN @@ -1543,7 +1543,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) if (ncerr .ne. 0) return END IF ncerr = nf90_put_var(fh, v_taido, TAIDO, start = (/ 1, itime/), & - count = (/ d_nopts, 1 /)) + count = (/ nopts, 1 /)) if (ncerr .ne. 0) return write(*,*) 'JDM f 8' IF ( itime > 1 ) THEN @@ -1551,7 +1551,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) if (ncerr .ne. 0) return END IF ncerr = nf90_put_var(fh, v_dairo, DAIRO, start = (/ 1, itime/), & - count = (/ d_nopts, 1 /)) + count = (/ nopts, 1 /)) if (ncerr .ne. 0) return #endif #ifdef W3_SETUP @@ -1561,7 +1561,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) if (ncerr .ne. 0) return END IF ncerr = nf90_put_var(fh, v_zet_seto, ZET_SETO, start = (/ 1, itime/), & - count = (/ d_nopts, 1 /)) + count = (/ nopts, 1 /)) if (ncerr .ne. 0) return #endif write(*,*) 'JDM f 10' @@ -1570,7 +1570,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) if (ncerr .ne. 0) return END IF ncerr = nf90_put_var(fh, v_aso, ASO, start = (/ 1, itime/), & - count = (/ d_nopts, 1 /)) + count = (/ nopts, 1 /)) if (ncerr .ne. 0) return write(*,*) 'JDM f 11' IF ( itime > 1 ) THEN @@ -1578,7 +1578,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) if (ncerr .ne. 0) return END IF ncerr = nf90_put_var(fh, v_cao, CAO, start = (/ 1, itime/), & - count = (/ d_nopts, 1 /)) + count = (/ nopts, 1 /)) if (ncerr .ne. 0) return write(*,*) 'JDM f 12' IF ( itime > 1 ) THEN @@ -1586,7 +1586,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) if (ncerr .ne. 0) return END IF ncerr = nf90_put_var(fh, v_iceo, ICEO, start = (/ 1, itime/), & - count = (/ d_nopts, 1 /)) + count = (/ nopts, 1 /)) if (ncerr .ne. 0) return write(*,*) 'JDM f 13' IF ( itime > 1 ) THEN @@ -1594,7 +1594,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) if (ncerr .ne. 0) return END IF ncerr = nf90_put_var(fh, v_iceho, ICEHO, start = (/ 1, itime/), & - count = (/ d_nopts, 1 /)) + count = (/ nopts, 1 /)) if (ncerr .ne. 0) return write(*,*) 'JDM f 14' IF ( itime > 1 ) THEN @@ -1602,7 +1602,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) if (ncerr .ne. 0) return END IF ncerr = nf90_put_var(fh, v_icefo, ICEFO, start = (/ 1, itime/), & - count = (/ d_nopts, 1 /)) + count = (/ nopts, 1 /)) if (ncerr .ne. 0) return write(*,*) 'JDM f 15' write(*,*) 'GRDID:',GRDID @@ -1611,7 +1611,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) if (ncerr .ne. 0) return END IF ncerr = nf90_put_var(fh, v_grdid, GRDID, start = (/ 1, 1, itime/), & - count = (/ d_grdidlen, d_nopts, 1 /)) + count = (/ 13, nopts, 1 /)) if (ncerr .ne. 0) return write(*,*) 'JDM f 16' IF ( itime > 1 ) THEN @@ -1619,7 +1619,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) if (ncerr .ne. 0) return END IF ncerr = nf90_put_var(fh, v_spco, SPCO, start = (/ 1, 1, itime/), & - count = (/d_nspec, d_nopts, 1 /)) + count = (/nspec, nopts, 1 /)) if (ncerr .ne. 0) return write(*,*) 'JDM g' From 3fcec440070f61895a10dd4d5046e8fb73824ab3 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Wed, 3 Apr 2024 06:29:34 -0600 Subject: [PATCH 064/126] fixing --- regtests/unittests/util.F90 | 75 ------------------------------------- 1 file changed, 75 deletions(-) delete mode 100644 regtests/unittests/util.F90 diff --git a/regtests/unittests/util.F90 b/regtests/unittests/util.F90 deleted file mode 100644 index fe20ddb30..000000000 --- a/regtests/unittests/util.F90 +++ /dev/null @@ -1,75 +0,0 @@ -! This is test code for the WW3 I/O unit tests. -! -! This file holds a function used by multiple tests. -! -! Ed Hartnett, 1/11/24 -integer function write_test_file() - implicit none - - integer :: ntlu, nk, nth, nopts - character(len=10), parameter :: veropt = '2021-04-06' - character(len=31), parameter :: idstr = 'WAVEWATCH III POINT OUTPUT FILE' - real :: ptloc(2,11) = reshape((/ 0., 0., 5000., 0., 10000., 0., 15000., 0., & - 20000., 0., 25000., 0., 30000., 0., 35000., 0., 40000., 0., 45000., 0., 50000., 0. /), & - (/ 2, 11 /)) - character*40 ptnme(11) - integer :: time(2) = (/ 19680606, 0 /) - integer :: nspec = 72 - integer :: iw(11) = (/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /) - integer :: ii(11) = (/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /) - integer :: il(11) = (/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /) - real :: iceo(11) = (/ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. /) - real :: iceho(11) = (/ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. /) - real :: icefo(11) = (/ 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000. /) - real :: dpo(11) = (/ 50., 50., 45., 40., 35., 30., 25., 20., 15., 10., 5. /) - real :: wao(11) = (/ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. /) - real :: wdo(11) = (/ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. /) - real :: aso(11) = (/ -999.900024, -999.900024, -999.900024, -999.900024, -999.900024, & - -999.900024, -999.900024, -999.900024, -999.900024, -999.900024, -999.900024 /) - real :: cao(11) = (/ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. /) - real :: cdo(11) = (/ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. /) - character*13 :: grdid(11) - real :: spco(72, 11) - integer :: i, j - integer :: ierr - - ! Initialize some values. - ntlu = 21 - nk = 3 - nth = 24 - nopts = 11 - do i = 1, nopts - if (i .le. 9) then - write(ptnme(i), '(a,i1)') 'Point', i - else - write(ptnme(i), '(a,i2)') 'Point', i - endif - grdid(i) = 'ww3 ' - end do - - ! Open the file. - open(ntlu, file="out_pnt.ww3", form="unformatted", status="replace", & - action="write", convert="big_endian", iostat=ierr) - if (ierr .ne. 0) stop 111 - - ! Write our values. - write (ntlu, iostat=ierr) idstr, veropt, nk, nth, nopts - if (ierr .ne. 0) stop 112 - write (ntlu, iostat=ierr) ((ptloc(j,i),j=1,2),i=1,nopts), (ptnme(i),i=1,nopts) - if (ierr .ne. 0) stop 113 - write (ntlu, iostat=ierr) time - if (ierr .ne. 0) stop 114 - do i=1, nopts - write (ntlu, iostat=ierr) iw(i), ii(i), il(i), dpo(i), wao(i), wdo(i), & - aso(i), cao(i), cdo(i), iceo(i), iceho(i), & - icefo(i), grdid(i), (spco(j,i),j=1,nspec) - if (ierr .ne. 0) stop 115 - enddo - - ! Close the file. - close(ntlu) - - ! We're done! - write_test_file = 0 -end function write_test_file - From ca3825026c54d62b52bb8042bd9c89213d379fed Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Wed, 3 Apr 2024 06:30:03 -0600 Subject: [PATCH 065/126] more detail --- docs/regtests.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/regtests.md b/docs/regtests.md index 8b92d13e7..21df2da01 100644 --- a/docs/regtests.md +++ b/docs/regtests.md @@ -633,7 +633,7 @@ There is a script called run_cmake_test. It seems relevant:
 
-ed@Pooh-Bah:~/ww3/regtests$ ./bin/run_cmake_test -o all -S -T -s PR1_MPI -w work_PR1_MPI              -f -p mpirun -n 24 ../model ww3_tp2.1
+ed@Pooh-Bah:~/ww3/regtests$ ./bin/run_cmake_test -o all -S -T -s PR1_MPI -w work_PR1_MPI              -f -p mpirun -n 24 ../model ww3_tp1.1
  
  Running now options: run_cmake_test -o all -S -T -s PR1_MPI -w work_PR1_MPI -f -p mpirun -n 24 ../model ww3_tp2.1
  

From 9ce71d87457e4c50afe59db2b95a50b6626955b3 Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Wed, 3 Apr 2024 07:47:10 -0600
Subject: [PATCH 066/126] reverted file

---
 regtests/unittests/test_io_restart_bin.F90 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/regtests/unittests/test_io_restart_bin.F90 b/regtests/unittests/test_io_restart_bin.F90
index d5986b770..026e8d3d2 100644
--- a/regtests/unittests/test_io_restart_bin.F90
+++ b/regtests/unittests/test_io_restart_bin.F90
@@ -51,8 +51,9 @@ program test_io_restart_bin
 !   call w3iors('HOT', ndsr, dumfpi)
 !   if (iotest .ne. 0) stop 10
 !   close(ndsop)
+
   
-!   print *, 'OK!'
+  print *, 'OK!'
   print *, 'SUCCESS!'
 end program test_io_restart_bin
 

From 7fe0922795b53eab79d5590c49414560c4485f4c Mon Sep 17 00:00:00 2001
From: JessicaMeixner-NOAA 
Date: Wed, 3 Apr 2024 09:41:10 -0500
Subject: [PATCH 067/126] add wdo to write and zero out II, IL, IW as in binary
 output

---
 model/src/w3iopomd.F90 | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index 93d7d018b..77db195f2 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -1486,6 +1486,11 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
      END IF
 
     ! TO DO ADD TIME VARIABLE 
+    ! set IW, II and IL to 0 because it is not used and gives &
+    ! outlier values in out_pnt.points - TODO: REMOVE???
+    IW = 0
+    II = 0
+    IL = 0
 
     write(*,*) 'JDM f 1'
     IF ( itime > 1 ) THEN 
@@ -1528,6 +1533,17 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
     ncerr = nf90_put_var(fh, v_wao, WAO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
     if (ncerr .ne. 0) return
+
+    write(*,*) 'JDM f 5b'
+    IF ( itime > 1 ) THEN
+       ncerr = nf90_inq_varid(fh, VNAME_WDO, v_wdo)
+       if (ncerr .ne. 0) return
+    END IF
+    ncerr = nf90_put_var(fh, v_wdo, WDO, start = (/ 1, itime/), &
+       count = (/ nopts, 1 /))
+    if (ncerr .ne. 0) return
+
+
 #ifdef W3_FLX5
     write(*,*) 'JDM f 6'
     IF ( itime > 1 ) THEN

From b1bcf910439121b6d540478613536142517c40b7 Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Wed, 3 Apr 2024 08:41:39 -0600
Subject: [PATCH 068/126] fixed cmake

---
 regtests/unittests/CMakeLists.txt | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/regtests/unittests/CMakeLists.txt b/regtests/unittests/CMakeLists.txt
index 766c7f89c..8a11d2ad8 100644
--- a/regtests/unittests/CMakeLists.txt
+++ b/regtests/unittests/CMakeLists.txt
@@ -12,6 +12,16 @@ function(copy_test_data name)
     FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
 endfunction()
 
+# Some very small test files may be committed to the repo. This
+# function copies such a data file to the build directory.
+function(copy_test_data_2 srcname destname)
+  message(STATUS "Copying ${srcname} to ${CMAKE_CURRENT_BINARY_DIR}/${destname}")
+  file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/data/${srcname}"
+    DESTINATION "${CMAKE_BINARY_DIR}"
+    FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+  file(RENAME "${CMAKE_BINARY_DIR}/${srcname}" "${CMAKE_BINARY_DIR}/${destname}")
+endfunction()
+
 # Function to build and run a test.
 function(unit_test name)
   add_executable(${name} ${name}.F90 ww3_unittest_util.F90)
@@ -26,7 +36,7 @@ endfunction()
 
 # Copy test data files that are in the repo to the build directory.
 copy_test_data(switch.io)
-copy_test_data(ww3_grid.inp)
+copy_test_data_2(ww3_grid.inp ww3_grid.inp)
 
 # Build and run the tests.
 unit_test(test_io_points_bin)

From 3b729b2f896e5221a801a9c72f12f72d196df62b Mon Sep 17 00:00:00 2001
From: JessicaMeixner-NOAA 
Date: Wed, 3 Apr 2024 09:42:50 -0500
Subject: [PATCH 069/126] add writing of cdo

---
 model/src/w3iopomd.F90 | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index 77db195f2..e904d73f1 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -1596,6 +1596,16 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
     ncerr = nf90_put_var(fh, v_cao, CAO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
     if (ncerr .ne. 0) return
+    write(*,*) 'JDM f 11 b'
+    IF ( itime > 1 ) THEN
+       ncerr = nf90_inq_varid(fh, VNAME_CDO, v_cdo)
+       if (ncerr .ne. 0) return
+    END IF
+    ncerr = nf90_put_var(fh, v_cdo, CDO, start = (/ 1, itime/), &
+       count = (/ nopts, 1 /))
+    if (ncerr .ne. 0) return
+
+
     write(*,*) 'JDM f 12'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_ICEO, v_iceo)

From d439be78bdd734e67b6fdc9c0d36e8cddc9485d7 Mon Sep 17 00:00:00 2001
From: JessicaMeixner-NOAA 
Date: Wed, 3 Apr 2024 09:53:56 -0500
Subject: [PATCH 070/126] int -> float for appropriate variables

---
 model/src/w3iopomd.F90 | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index e904d73f1..706b03042 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -1409,7 +1409,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
 
       write(*,*) 'JDM d'
       ! Define vars with nopts as a dimension.
-      ncerr = nf90_def_var(fh, VNAME_PTLOC, NF90_INT, (/d_vsize, d_nopts/), v_ptloc)
+      ncerr = nf90_def_var(fh, VNAME_PTLOC, NF90_FLOAT, (/d_vsize, d_nopts/), v_ptloc)
       if (ncerr .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_PTNME, NF90_CHAR, (/d_namelen, d_nopts/), v_ptnme)
       if (ncerr .ne. 0) return
@@ -1419,40 +1419,40 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
       if (ncerr .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_IL, NF90_INT, (/d_nopts, d_time/), v_il)
       if (ncerr .ne. 0) return
-      ncerr = nf90_def_var(fh, VNAME_DPO, NF90_INT, (/d_nopts, d_time/), v_dpo)
+      ncerr = nf90_def_var(fh, VNAME_DPO, NF90_FLOAT, (/d_nopts, d_time/), v_dpo)
       if (ncerr .ne. 0) return
-      ncerr = nf90_def_var(fh, VNAME_WAO, NF90_INT, (/d_nopts, d_time/), v_wao)
+      ncerr = nf90_def_var(fh, VNAME_WAO, NF90_FLOAT, (/d_nopts, d_time/), v_wao)
       if (ncerr .ne. 0) return
-      ncerr = nf90_def_var(fh, VNAME_WDO, NF90_INT, (/d_nopts, d_time/), v_wdo)
+      ncerr = nf90_def_var(fh, VNAME_WDO, NF90_FLOAT, (/d_nopts, d_time/), v_wdo)
       if (ncerr .ne. 0) return
 
 #ifdef W3_FLX5
-      ncerr = nf90_def_var(fh, VNAME_TAUAO, NF90_INT, (/d_nopts, d_time/), v_tauao)
+      ncerr = nf90_def_var(fh, VNAME_TAUAO, NF90_FLOAT, (/d_nopts, d_time/), v_tauao)
       if (ncerr .ne. 0) return
-      ncerr = nf90_def_var(fh, VNAME_TAIDO, NF90_INT, (/d_nopts, d_time/), v_taido)
+      ncerr = nf90_def_var(fh, VNAME_TAIDO, NF90_FLOAT, (/d_nopts, d_time/), v_taido)
       if (ncerr .ne. 0) return
-      ncerr = nf90_def_var(fh, VNAME_DAIRO, NF90_INT, (/d_nopts, d_time/), v_dairo)
+      ncerr = nf90_def_var(fh, VNAME_DAIRO, NF90_FLOAT, (/d_nopts, d_time/), v_dairo)
       if (ncerr .ne. 0) return
 #endif    
 #ifdef W3_SETUP
-      ncerr = nf90_def_var(fh, VNAME_ZET_SETO, NF90_INT, (/d_nopts, d_time/), v_zet_seto)
+      ncerr = nf90_def_var(fh, VNAME_ZET_SETO, NF90_FLOAT, (/d_nopts, d_time/), v_zet_seto)
       if (ncerr .ne. 0) return
 #endif    
-      ncerr = nf90_def_var(fh, VNAME_ASO, NF90_INT, (/d_nopts, d_time/), v_aso)
+      ncerr = nf90_def_var(fh, VNAME_ASO, NF90_FLOAT, (/d_nopts, d_time/), v_aso)
       if (ncerr .ne. 0) return
-      ncerr = nf90_def_var(fh, VNAME_CAO, NF90_INT, (/d_nopts, d_time/), v_cao)
+      ncerr = nf90_def_var(fh, VNAME_CAO, NF90_FLOAT, (/d_nopts, d_time/), v_cao)
       if (ncerr .ne. 0) return
-      ncerr = nf90_def_var(fh, VNAME_CDO, NF90_INT, (/d_nopts, d_time/), v_cdo)
+      ncerr = nf90_def_var(fh, VNAME_CDO, NF90_FLOAT, (/d_nopts, d_time/), v_cdo)
       if (ncerr .ne. 0) return
-      ncerr = nf90_def_var(fh, VNAME_ICEO, NF90_INT, (/d_nopts, d_time/), v_iceo)
+      ncerr = nf90_def_var(fh, VNAME_ICEO, NF90_FLOAT, (/d_nopts, d_time/), v_iceo)
       if (ncerr .ne. 0) return
-      ncerr = nf90_def_var(fh, VNAME_ICEHO, NF90_INT, (/d_nopts, d_time/), v_iceho)
+      ncerr = nf90_def_var(fh, VNAME_ICEHO, NF90_FLOAT, (/d_nopts, d_time/), v_iceho)
       if (ncerr .ne. 0) return
-      ncerr = nf90_def_var(fh, VNAME_ICEFO, NF90_INT, (/d_nopts, d_time/), v_icefo)
+      ncerr = nf90_def_var(fh, VNAME_ICEFO, NF90_FLOAT, (/d_nopts, d_time/), v_icefo)
       if (ncerr .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_GRDID, NF90_CHAR, (/d_grdidlen, d_nopts, d_time/), v_grdid)
       if (ncerr .ne. 0) return
-      ncerr = nf90_def_var(fh, VNAME_SPCO, NF90_INT, (/d_nspec, d_nopts, d_time/), v_spco)
+      ncerr = nf90_def_var(fh, VNAME_SPCO, NF90_FLOAT, (/d_nspec, d_nopts, d_time/), v_spco)
       if (ncerr .ne. 0) return
   
       write(*,*) 'JDM bb'

From a9f4f0ff2fee9efc6116d3dd354e7f8b6997113f Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Wed, 3 Apr 2024 08:56:32 -0600
Subject: [PATCH 071/126] pass tests

---
 model/src/w3iopomd.F90 | 473 +++++++++++++++--------------------------
 1 file changed, 177 insertions(+), 296 deletions(-)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index 72e9c8290..246ab4b71 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -65,7 +65,7 @@ MODULE W3IOPOMD
   !      Name      Type  Scope    Description
   !     ----------------------------------------------------------------
   !      VEROPT    C*10  Private  Point output file version number.
-  !      IDSTR     C*31  Private  Point output file ID string.
+  !      IDSTR     C*32  Private  Point output file ID string.
   !     ----------------------------------------------------------------
   !
   !  3. Subroutines and functions :
@@ -134,7 +134,7 @@ MODULE W3IOPOMD
   !> NAMELEN. This is the length of the PTNME strings, which contains
   !> the names of the points.
   character(*), parameter, private :: DNAME_NAMELEN = 'NAMELEN'
-
+  
   !> Dimension name for the netCDF point output file, for GRDIDLEN,
   !> this is the length of the GRDID character array.
   character(*), parameter, private :: DNAME_GRDIDLEN = 'GRDIDLEN'
@@ -146,7 +146,7 @@ MODULE W3IOPOMD
   character(*), parameter, private :: VNAME_NK = 'NK'
 
   !> Variable name for the netCDF point output file, for MTH.
-  character(*), parameter, private :: VNAME_NTH = 'NTH'
+  character(*), parameter, private :: VNAME_MTH = 'MTH'
 
   !> Variable name for the netCDF point output file, for PTLOC.
   character(*), parameter, private :: VNAME_PTLOC = 'PTLOC'
@@ -154,9 +154,6 @@ MODULE W3IOPOMD
   !> Variable name for the netCDF point output file, for PTNME.
   character(*), parameter, private :: VNAME_PTNME = 'PTNME'
 
-  !> Variable name for the netCDF point output file, for TIME. 
-  character(*), parameter, private :: VNAME_TIME = 'TIME'
-
   !> Variable name for the netCDF point output file, for IW.
   character(*), parameter, private :: VNAME_IW = 'IW'
 
@@ -210,7 +207,7 @@ MODULE W3IOPOMD
 
   !> Variable name for the netCDF point output file, for SPCO.
   character(*), parameter, private :: VNAME_SPCO = 'SPCO'
-
+  
   !/
 CONTAINS
   !/ ------------------------------------------------------------------- /
@@ -1134,7 +1131,6 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
          IL, IW, II, PTLOC, PTIFAC, DPO, WAO, WDO,   &
          ASO, CAO, CDO, SPCO, PTNME, O2INIT, FNMPRE, &
          GRDID, ICEO, ICEHO, ICEFO
-    USE W3SERVMD, ONLY: EXTCDE
 #ifdef W3_FLX5
     USE W3ODATMD, ONLY: TAUAO, TAUDO, DAIRO
 #endif
@@ -1147,95 +1143,70 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
     INTEGER, INTENT(IN), OPTIONAL :: IMOD
     character(*), intent(in) :: filename
     integer, intent(inout) :: ncerr
-    INTEGER :: MK,MTH
     integer :: fh
-    integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen
-    integer :: d_nopts_len, d_nspec_len, d_vsize_len, d_namelen_len, d_grdidlen_len
-    integer :: v_idtst, v_vertst, v_nk, v_nth, v_ptloc, v_ptnme
+    integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen    
+    integer :: d_nopts_len, d_nspec_len, d_vsize_len, d_namelen_len, d_grdidlen_len    
+    integer :: v_idtst, v_vertst, v_nk, v_mth, v_ptloc, v_ptnme
     integer :: v_iw, v_ii, v_il, v_dpo, v_wao, v_wdo, v_tauao
     integer :: v_taido, v_dairo, v_zet_seto, v_aso, v_cao, v_cdo, v_iceo
     integer :: v_iceho, v_icefo, v_grdid, v_spco
 
+    print *,filename
     IOTST = 0
-    IF ( IPASS.EQ.1 ) THEN 
-      ! Open the netCDF file.
-      ncerr = nf90_open(filename, NF90_NOWRITE, fh)
-      if (ncerr .ne. 0) return
-
-      ! Read and check the version: 
-      ! TO DO add reading of IDTST and VERTST and make checks: 
-      !  IF ( IDTST .NE. IDSTR ) THEN
-      !    WRITE (NDSE,902) IDTST, IDSTR
-      !    CALL EXTCDE ( 10 )
-      !  END IF
-      !  IF ( VERTST .NE. VEROPT ) THEN
-      !    WRITE (NDSE,903) VERTST, VEROPT
-      !    CALL EXTCDE ( 11 )
-      !  END IF
-
-
-      ! Read the dimension information for NOPTS.
-      ncerr = nf90_inq_dimid(fh, DNAME_NOPTS, d_nopts)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_inquire_dimension(fh, d_nopts, len = d_nopts_len)
-      if (ncerr .ne. 0) return
-
-      ! Read the dimension information for NSPEC.
-      ncerr = nf90_inq_dimid(fh, DNAME_NSPEC, d_nspec)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_inquire_dimension(fh, d_nspec, len = d_nspec_len)
-      if (ncerr .ne. 0) return
-
-      ! Read the dimension information for VSIZE.
-      ncerr = nf90_inq_dimid(fh, DNAME_VSIZE, d_vsize)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_inquire_dimension(fh, d_vsize, len = d_vsize_len)
-      if (ncerr .ne. 0) return
-
-      ! Read the dimension information for NAMELEN.
-      ncerr = nf90_inq_dimid(fh, DNAME_NAMELEN, d_namelen)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_inquire_dimension(fh, d_namelen, len = d_namelen_len)
-      if (ncerr .ne. 0) return
-
-      ! Read the dimension information for GRDIDLEN.
-      ncerr = nf90_inq_dimid(fh, DNAME_GRDIDLEN, d_grdidlen)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_inquire_dimension(fh, d_grdidlen, len = d_grdidlen_len)
-      if (ncerr .ne. 0) return
-
-      ! Read scalar variables.
-      ncerr = nf90_inq_varid(fh, VNAME_NK, v_nk)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_get_var(fh, v_nk, MK)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_inq_varid(fh, VNAME_NTH, v_nth)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_get_var(fh, v_nth, MTH)
-      if (ncerr .ne. 0) return
-
-      !read in written variables NK, NTH as MK and MTH
-      !and ensure they match 
-      IF (NK.NE.MK .OR. NTH.NE.MTH) THEN
-        WRITE (NDSE,904) MK, MTH, NK, NTH
-        CALL EXTCDE ( 12 )
-      END IF
+    
+    ! Open the netCDF file.
+    ncerr = nf90_open(filename, NF90_NOWRITE, fh)
+    if (ncerr .ne. 0) return
 
-      ! Read vars with nopts as a dimension.
-      ncerr = nf90_inq_varid(fh, VNAME_PTLOC, v_ptloc)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_get_var(fh, v_ptloc, PTLOC)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_inq_varid(fh, VNAME_PTNME, v_ptnme)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_get_var(fh, v_ptnme, PTNME)
-      if (ncerr .ne. 0) return
-    END IF
+    ! Read the dimension information for NOPTS.
+    ncerr = nf90_inq_dimid(fh, DNAME_NOPTS, d_nopts)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_inquire_dimension(fh, d_nopts, len = d_nopts_len)
+    if (ncerr .ne. 0) return
+
+    ! Read the dimension information for NSPEC.
+    ncerr = nf90_inq_dimid(fh, DNAME_NSPEC, d_nspec)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_inquire_dimension(fh, d_nspec, len = d_nspec_len)
+    if (ncerr .ne. 0) return
 
-    !missing variable TIME??? 
+    ! Read the dimension information for VSIZE.
+    ncerr = nf90_inq_dimid(fh, DNAME_VSIZE, d_vsize)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_inquire_dimension(fh, d_vsize, len = d_vsize_len)
+    if (ncerr .ne. 0) return
 
-    ! All of the below variables are missing the "time" dimension... 
-    ! the time dimension being read should be for "IPASS" 
+    ! Read the dimension information for NAMELEN.
+    ncerr = nf90_inq_dimid(fh, DNAME_NAMELEN, d_namelen)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_inquire_dimension(fh, d_namelen, len = d_namelen_len)
+    if (ncerr .ne. 0) return
+
+    ! Read the dimension information for GRDIDLEN.
+    ncerr = nf90_inq_dimid(fh, DNAME_GRDIDLEN, d_grdidlen)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_inquire_dimension(fh, d_grdidlen, len = d_grdidlen_len)
+    if (ncerr .ne. 0) return
+
+    ! Read scalar variables.
+    ncerr = nf90_inq_varid(fh, VNAME_NK, v_nk)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_get_var(fh, v_nk, NK)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_inq_varid(fh, VNAME_MTH, v_mth)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_get_var(fh, v_mth, NTH)
+    if (ncerr .ne. 0) return
+
+    ! Read vars with nopts as a dimension.
+    ncerr = nf90_inq_varid(fh, VNAME_PTLOC, v_ptloc)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_get_var(fh, v_ptloc, PTLOC)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_inq_varid(fh, VNAME_PTNME, v_ptnme)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_get_var(fh, v_ptnme, PTNME)
+    if (ncerr .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_IW, v_iw)
     if (ncerr .ne. 0) return
     ncerr = nf90_get_var(fh, v_iw, IW)
@@ -1273,7 +1244,7 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
     if (ncerr .ne. 0) return
     ncerr = nf90_get_var(fh, v_dairo, DAIRO)
     if (ncerr .ne. 0) return
-#endif
+#endif    
 #ifdef W3_SETUP
     ncerr = nf90_inq_varid(fh, ZET_SETO, v_zet_seto)
     if (ncerr .ne. 0) return
@@ -1312,21 +1283,11 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
     if (ncerr .ne. 0) return
     ncerr = nf90_get_var(fh, v_spco, SPCO)
     if (ncerr .ne. 0) return
-
+    
     ! Close the file.
     ncerr = nf90_close(fh)
     if (ncerr .ne. 0) return
-
-902 FORMAT (/' *** WAVEWATCH III ERROR IN W3IOPON :'/               &
-         '     ILEGAL IDSTR, READ : ',A/                        &
-         '                  CHECK : ',A/)
-903 FORMAT (/' *** WAVEWATCH III ERROR IN W3IOPON :'/               &
-         '     ILEGAL VEROPT, READ : ',A/                       &
-         '                   CHECK : ',A/)
-904 FORMAT (/' *** WAVEWATCH III ERROR IN W3IOPO :'/                &
-         '     ERROR IN SPECTRA, MK, MTH : ',2I8/               &
-         '              ARRAY DIMENSIONS : ',2I8/)
-
+    
   END SUBROUTINE W3IOPON_READ
 
   !/ ------------------------------------------------------------------- /
@@ -1355,200 +1316,148 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
 #ifdef W3_SETUP
     USE W3ODATMD, ONLY: ZET_SETO
 #endif
+    
     IMPLICIT NONE
     integer, intent(in) :: timestep_only ! 1 if only timestep should be written.
     INTEGER, INTENT(IN) :: IMOD
     character(*), intent(in) :: filename
     integer, intent(inout) :: ncerr
-    integer :: fh, ndim, nvar, fmt, itime 
+    integer :: fh, ndim, nvar, fmt
     integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen, d_time
-    integer :: v_idtst, v_vertst, v_nk, v_nth, v_ptloc, v_ptnme
+    integer :: v_idtst, v_vertst, v_nk, v_mth, v_ptloc, v_ptnme
     integer :: v_iw, v_ii, v_il, v_dpo, v_wao, v_wdo, v_tauao
     integer :: v_taido, v_dairo, v_zet_seto, v_aso, v_cao, v_cdo, v_iceo
     integer :: v_iceho, v_icefo, v_grdid, v_spco
-!!JDM - defined in module above    CHARACTER(LEN=31), PARAMETER :: IDSTR = 'WAVEWATCH III POINT OUTPUT FILE'
-!!JDM - defined in module above    CHARACTER(LEN=10), PARAMETER :: VEROPT = '2021-04-06'
-
-    write(*,*) 'JDM in write', IPASS, timestep_only
-    !If first pass, or if you are writting a file for every time-step: 
-    IF ( IPASS.EQ.1  .OR. timestep_only.EQ.1 ) THEN 
-      ! Create the netCDF file.
-      ncerr = nf90_create(filename, NF90_NETCDF4, fh)
-      if (ncerr .ne. 0) return
- 
-      write(*,*)'JDM a'
-      ! Define dimensions.
-      ncerr = nf90_def_dim(fh, DNAME_NOPTS, NOPTS, d_nopts)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_def_dim(fh, DNAME_NSPEC, NSPEC, d_nspec)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_def_dim(fh, DNAME_VSIZE, 2, d_vsize)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_def_dim(fh, DNAME_NAMELEN, 40, d_namelen)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_def_dim(fh, DNAME_GRDIDLEN, 13, d_grdidlen)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_def_dim(fh, DNAME_TIME, NF90_UNLIMITED, d_time)
-      if (ncerr .ne. 0) return
-
-      write(*,*) 'JDM b'
-      ! Define global attributes.
-      ncerr = nf90_put_att(fh, NF90_GLOBAL, 'title', IDSTR)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_put_att(fh, NF90_GLOBAL, 'version', VEROPT)
-      if (ncerr .ne. 0) return
-
-      write(*,*) 'JDM c'
-      ! Define scalar variables.
-      ncerr = nf90_def_var(fh, VNAME_NK, NF90_INT, v_nk)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_def_var(fh, VNAME_NTH, NF90_INT, v_nth)
-      if (ncerr .ne. 0) return
-
-      write(*,*) 'JDM d'
-      ! Define vars with nopts as a dimension.
-      ncerr = nf90_def_var(fh, VNAME_PTLOC, NF90_INT, (/d_vsize, d_nopts/), v_ptloc)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_def_var(fh, VNAME_PTNME, NF90_CHAR, (/d_namelen, d_nopts/), v_ptnme)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_def_var(fh, VNAME_IW, NF90_INT, (/d_nopts, d_time/), v_iw)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_def_var(fh, VNAME_II, NF90_INT, (/d_nopts, d_time/), v_ii)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_def_var(fh, VNAME_IL, NF90_INT, (/d_nopts, d_time/), v_il)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_def_var(fh, VNAME_DPO, NF90_INT, (/d_nopts, d_time/), v_dpo)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_def_var(fh, VNAME_WAO, NF90_INT, (/d_nopts, d_time/), v_wao)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_def_var(fh, VNAME_WDO, NF90_INT, (/d_nopts, d_time/), v_wdo)
-      if (ncerr .ne. 0) return
+    character (len = *), parameter :: FILE_NAME = "f90tst_nc4.nc"
+    CHARACTER(LEN=31), PARAMETER :: IDSTR = 'WAVEWATCH III POINT OUTPUT FILE'
+    CHARACTER(LEN=10), PARAMETER :: VEROPT = '2021-04-06'
+
+    print *, 'WRITE ',filename, len(filename)
+
+    ! Create the netCDF file.
+    ncerr = nf90_create(filename, NF90_NETCDF4, fh)
+    if (ncerr .ne. 0) return
+
+    ! Define dimensions.
+    ncerr = nf90_def_dim(fh, DNAME_NOPTS, NOPTS, d_nopts)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_def_dim(fh, DNAME_NSPEC, NSPEC, d_nspec)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_def_dim(fh, DNAME_VSIZE, 2, d_vsize)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_def_dim(fh, DNAME_NAMELEN, 40, d_namelen)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_def_dim(fh, DNAME_GRDIDLEN, 13, d_grdidlen)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_def_dim(fh, DNAME_TIME, NF90_UNLIMITED, d_time)
+    if (ncerr .ne. 0) return
 
+    ! Define global attributes.
+    ncerr = nf90_put_att(fh, NF90_GLOBAL, 'title', IDSTR)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_put_att(fh, NF90_GLOBAL, 'version', VEROPT)
+    if (ncerr .ne. 0) return
+    
+    ! Define scalar variables.
+    ncerr = nf90_def_var(fh, VNAME_NK, NF90_INT, v_nk)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_def_var(fh, VNAME_MTH, NF90_INT, v_mth)
+    if (ncerr .ne. 0) return
+
+    ! Define vars with nopts as a dimension.
+    ncerr = nf90_def_var(fh, VNAME_PTLOC, NF90_INT, (/d_vsize, d_nopts/), v_ptloc)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_def_var(fh, VNAME_PTNME, NF90_CHAR, (/d_namelen, d_nopts/), v_ptnme)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_def_var(fh, VNAME_IW, NF90_INT, (/d_nopts, d_time/), v_iw)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_def_var(fh, VNAME_II, NF90_INT, (/d_nopts, d_time/), v_ii)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_def_var(fh, VNAME_IL, NF90_INT, (/d_nopts, d_time/), v_il)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_def_var(fh, VNAME_DPO, NF90_INT, (/d_nopts, d_time/), v_dpo)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_def_var(fh, VNAME_WAO, NF90_INT, (/d_nopts, d_time/), v_wao)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_def_var(fh, VNAME_WDO, NF90_INT, (/d_nopts, d_time/), v_wdo)
+    if (ncerr .ne. 0) return
 #ifdef W3_FLX5
-      ncerr = nf90_def_var(fh, VNAME_TAUAO, NF90_INT, (/d_nopts, d_time/), v_tauao)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_def_var(fh, VNAME_TAIDO, NF90_INT, (/d_nopts, d_time/), v_taido)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_def_var(fh, VNAME_DAIRO, NF90_INT, (/d_nopts, d_time/), v_dairo)
-      if (ncerr .ne. 0) return
+    ncerr = nf90_def_var(fh, VNAME_TAUAO, NF90_INT, (/d_nopts, d_time/), v_tauao)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_def_var(fh, VNAME_TAIDO, NF90_INT, (/d_nopts, d_time/), v_taido)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_def_var(fh, VNAME_DAIRO, NF90_INT, (/d_nopts, d_time/), v_dairo)
+    if (ncerr .ne. 0) return
 #endif    
 #ifdef W3_SETUP
-      ncerr = nf90_def_var(fh, VNAME_ZET_SETO, NF90_INT, (/d_nopts, d_time/), v_zet_seto)
-      if (ncerr .ne. 0) return
+    ncerr = nf90_def_var(fh, VNAME_ZET_SETO, NF90_INT, (/d_nopts, d_time/), v_zet_seto)
+    if (ncerr .ne. 0) return
 #endif    
-      ncerr = nf90_def_var(fh, VNAME_ASO, NF90_INT, (/d_nopts, d_time/), v_aso)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_def_var(fh, VNAME_CAO, NF90_INT, (/d_nopts, d_time/), v_cao)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_def_var(fh, VNAME_CDO, NF90_INT, (/d_nopts, d_time/), v_cdo)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_def_var(fh, VNAME_ICEO, NF90_INT, (/d_nopts, d_time/), v_iceo)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_def_var(fh, VNAME_ICEHO, NF90_INT, (/d_nopts, d_time/), v_iceho)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_def_var(fh, VNAME_ICEFO, NF90_INT, (/d_nopts, d_time/), v_icefo)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_def_var(fh, VNAME_GRDID, NF90_CHAR, (/d_grdidlen, d_nopts, d_time/), v_grdid)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_def_var(fh, VNAME_SPCO, NF90_INT, (/d_nspec, d_nopts, d_time/), v_spco)
-      if (ncerr .ne. 0) return
-      write(*,*) 'JDM c'
-      ! Write the scalar data.
-      ncerr = nf90_put_var(fh, v_nk, NK)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_put_var(fh, v_nth, NTH)
-      if (ncerr .ne. 0) return
-
-      write(*,*) 'JDM e' 
-      ! Write the data with NOPTS as a dimension.
-      ncerr = nf90_put_var(fh, v_ptloc, PTLOC)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_put_var(fh, v_ptnme, PTNME)
-      if (ncerr .ne. 0) return
-      
-    ELSE 
-      write(*,*) 'JDM else'
-      ncerr = nf90_open(filename, nf90_write, fh)
-      if (ncerr .ne. 0) return
-    END IF 
-
-     IF ( timestep_only.EQ.1 ) THEN
-        itime=1
-     ELSE 
-        itime=IPASS
-     END IF
-
-    write(*,*) 'JDM f 1'
-    ncerr = nf90_put_var(fh, v_iw, IW, start = (/ 1, IPASS/), &
-                      count = (/ d_nopts, 1 /))
-    if (ncerr .ne. 0) return
-    write(*,*) 'JDM f 2'
+    ncerr = nf90_def_var(fh, VNAME_ASO, NF90_INT, (/d_nopts, d_time/), v_aso)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_def_var(fh, VNAME_CAO, NF90_INT, (/d_nopts, d_time/), v_cao)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_def_var(fh, VNAME_CDO, NF90_INT, (/d_nopts, d_time/), v_cdo)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_def_var(fh, VNAME_ICEO, NF90_INT, (/d_nopts, d_time/), v_iceo)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_def_var(fh, VNAME_ICEHO, NF90_INT, (/d_nopts, d_time/), v_iceho)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_def_var(fh, VNAME_ICEFO, NF90_INT, (/d_nopts, d_time/), v_icefo)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_def_var(fh, VNAME_GRDID, NF90_CHAR, (/d_grdidlen, d_nopts, d_time/), v_grdid)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_def_var(fh, VNAME_SPCO, NF90_INT, (/d_nspec, d_nopts, d_time/), v_spco)
+    if (ncerr .ne. 0) return
 
-    ncerr = nf90_put_var(fh, v_ii, II)
+    ! Write the scalar data.
+    ncerr = nf90_put_var(fh, v_nk, NK)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_put_var(fh, v_mth, NTH)
     if (ncerr .ne. 0) return
-    write(*,*) 'JDM f 3'
 
+    ! Write the data with NOPTS as a dimension.
+    ncerr = nf90_put_var(fh, v_ptloc, PTLOC)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_put_var(fh, v_ptnme, PTNME)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_put_var(fh, v_iw, IW)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_put_var(fh, v_ii, II)
+    if (ncerr .ne. 0) return
     ncerr = nf90_put_var(fh, v_il, IL)
     if (ncerr .ne. 0) return
-    write(*,*) 'JDM f 4'
-
     ncerr = nf90_put_var(fh, v_dpo, DPO)
     if (ncerr .ne. 0) return
-    write(*,*) 'JDM f 5'
-
     ncerr = nf90_put_var(fh, v_wao, WAO)
     if (ncerr .ne. 0) return
 #ifdef W3_FLX5
-    write(*,*) 'JDM f 6'
-
     ncerr = nf90_put_var(fh, v_tauao, TAUAO)
     if (ncerr .ne. 0) return
-    write(*,*) 'JDM f 7'
-
     ncerr = nf90_put_var(fh, v_taido, TAIDO)
     if (ncerr .ne. 0) return
-    write(*,*) 'JDM f 8'
-
     ncerr = nf90_put_var(fh, v_dairo, DAIRO)
     if (ncerr .ne. 0) return
 #endif
 #ifdef W3_SETUP
-    write(*,*) 'JDM f 9'
-
     ncerr = nf90_put_var(fh, v_zet_seto, ZET_SETO)
     if (ncerr .ne. 0) return
 #endif
-    write(*,*) 'JDM f 10'
-
     ncerr = nf90_put_var(fh, v_aso, ASO)
     if (ncerr .ne. 0) return
-    write(*,*) 'JDM f 11'
-
     ncerr = nf90_put_var(fh, v_cao, CAO)
     if (ncerr .ne. 0) return
-    write(*,*) 'JDM f 12'
-
     ncerr = nf90_put_var(fh, v_iceo, ICEO)
     if (ncerr .ne. 0) return
-    write(*,*) 'JDM f 13'
-
     ncerr = nf90_put_var(fh, v_iceho, ICEHO)
     if (ncerr .ne. 0) return
-    write(*,*) 'JDM f 14'
-
     ncerr = nf90_put_var(fh, v_icefo, ICEFO)
     if (ncerr .ne. 0) return
-    write(*,*) 'JDM f 15'
-
     ncerr = nf90_put_var(fh, v_grdid, GRDID)
     if (ncerr .ne. 0) return
-    write(*,*) 'JDM f 16'
-
     ncerr = nf90_put_var(fh, v_spco, SPCO)
     if (ncerr .ne. 0) return
 
-    write(*,*) 'JDM g'
-
     ! Close the file.
     ncerr = nf90_close(fh)
     if (ncerr .ne. 0) return
@@ -1607,17 +1516,10 @@ SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD &
     INTEGER, INTENT(IN), OPTIONAL :: NDSOA
 #endif
 
-    CHARACTER(LEN=15) :: TIMETAG
     INTEGER :: IGRD, MK, MTH
     character(len = 124) :: filename
     integer :: ncerr
 
-#ifdef W3_S
-    CALL STRACE (IENT, 'W3IOPON')
-#endif
-    ! IPASS essentially is the time variable dimension 
-    IPASS  = IPASS + 1
-
     ! Optimistically assume success.
     IOTST = 0
 
@@ -1636,52 +1538,32 @@ SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD &
     IF (INXOUT .NE. 'READ' .AND. INXOUT .NE. 'WRITE') THEN
       WRITE (NDSE, 900) INXOUT
       CALL EXTCDE(1)
-    END IF
-
-!JDM Not sure this next section is really needed in the necdf context,
-!commenting out but leaving it as a placeholder for now 
-
-!    ! Ensure read/write are not mixed 
-!    IF ( IPASS.EQ.1  .AND. OFILES(2) .EQ. 0 ) THEN
-!      WRITE  = INXOUT.EQ.'WRITE'
-!    ELSE
-!      IF ( WRITE .AND. INXOUT.EQ.'READ' ) THEN
-!        WRITE (NDSE,901) INXOUT
-!        CALL EXTCDE ( 2 )
-!      END IF
-!    END IF
-
-    ! Determine filename.
-    filename = ''
-    IF ( OFILES(2) .EQ. 1 ) THEN 
-      ! Create TIMETAG for file name using YYYYMMDD.HHMMS prefix
-      WRITE(TIMETAG,"(i8.8,'.'i6.6)")TIME(1),TIME(2)
-      filename = transfer(FNMPRE(:LEN_TRIM(FNMPRE))//TIMETAG//'out_pnt.'//FILEXT(:LEN_TRIM(FILEXT))//'.nc', filename)
-    ELSE 
-      filename = transfer(FNMPRE(:LEN_TRIM(FNMPRE))//'out_pnt.'//FILEXT(:LEN_TRIM(FILEXT))//'.nc', filename)
-    END IF 
-
-    ! Do a read or a write of the point file.
-    IF (INXOUT .EQ. 'READ') THEN
+   END IF
+
+   ! Determine filename.
+   filename = ''
+   filename = transfer(FNMPRE(:LEN_TRIM(FNMPRE))//'out_pnt_nc.'//FILEXT(:LEN_TRIM(FILEXT)), filename)
+   !print *, filename
+   
+   ! Do a read or a write of the point file.
+   IF (INXOUT .EQ. 'READ') THEN
       CALL W3IOPON_READ(IOTST, IMOD, filename, ncerr)
-    ELSE
+   ELSE
       CALL W3IOPON_WRITE(OFILES(2), IMOD, filename, ncerr)
-    ENDIF
-    if (ncerr .ne. 0) then
+   ENDIF
+   if (ncerr .ne. 0) then
       print *, nf90_strerror(ncerr)
-      CALL EXTCDE(21)
-    endif
-
+      CALL EXTCDE(21)      
+   endif
+   
     !/
     !/ End of W3IOPON ----------------------------------------------------- /
     !/
 
 900 FORMAT (/' *** WAVEWATCH III ERROR IN W3IOPO :'/                &
          '     ILEGAL INXOUT VALUE: ',A/)
-901 FORMAT (/' *** WAVEWATCH III ERROR IN W3IOPO :'/                &
-         '     MIXED READ/WRITE, LAST REQUEST: ',A/)
   END SUBROUTINE W3IOPON
-
+ 
   !/ ------------------------------------------------------------------- /
   !> Read or write point output.
   !>
@@ -1704,12 +1586,12 @@ END SUBROUTINE W3IOPON
   !> -------------|------|----------|--------
   !> 40 | character*40 | IDTST | ID string
   !> 4 | integer | VERTST | Model definition file version number
-  !> 4 | integer | NK | Number of discrete wavenumbers  
-  !> 4 | integer | NTH | Number of discrete directions. 
+  !> 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 | Valid time
+  !> 8 | integer(2) | TIME | Time
   !> reclen*NOPTS | * | * | records
   !>
   !> Each record contains:
@@ -1913,7 +1795,7 @@ SUBROUTINE W3IOPO ( INXOUT, NDSOP, IOTST, IMOD &
       CALL EXTCDE ( 1 )
     END IF
     !
-    ! First pass to this file and we are only writing 1 file for all time     
+    !      IF ( IPASS.EQ.1 ) THEN
     IF ( IPASS.EQ.1  .AND. OFILES(2) .EQ. 0) THEN
       WRITE  = INXOUT.EQ.'WRITE'
     ELSE
@@ -1926,10 +1808,10 @@ SUBROUTINE W3IOPO ( INXOUT, NDSOP, IOTST, IMOD &
     ! open file ---------------------------------------------------------- *
     !
     IF ( IPASS.EQ.1 .AND. OFILES(2) .EQ. 0 ) THEN
-
+      !
       I      = LEN_TRIM(FILEXT)
       J      = LEN_TRIM(FNMPRE)
-
+      !
 #ifdef W3_T
       WRITE (NDST,9001) FNMPRE(:J)//'out_pnt.'//FILEXT(:I)
 #endif
@@ -2048,7 +1930,7 @@ SUBROUTINE W3IOPO ( INXOUT, NDSOP, IOTST, IMOD &
       !
       IF ( WRITE ) THEN
         WRITE (NDSOP)                                           &
-            IDSTR, VEROPT, NK, NTH, NOPTS
+             IDSTR, VEROPT, NK, NTH, NOPTS
 #ifdef W3_ASCII
         WRITE (NDSOA,*)                                           &
              'IDSTR, VEROPT, NK, NTH, NOPTS:',                  &
@@ -2070,7 +1952,6 @@ SUBROUTINE W3IOPO ( INXOUT, NDSOP, IOTST, IMOD &
           WRITE (NDSE,904) MK, MTH, NK, NTH
           CALL EXTCDE ( 12 )
         END IF
-        !JDM: what is this???? 
         IF ( .NOT. O2INIT )                                     &
              CALL W3DMO2 ( IGRD, NDSE, NDST, NOPTS )
       END IF

From 7b2c63667f8f48c70e3093f1dd101a7de2ba8c34 Mon Sep 17 00:00:00 2001
From: JessicaMeixner-NOAA 
Date: Wed, 3 Apr 2024 10:18:07 -0500
Subject: [PATCH 072/126] add time variable to output

---
 model/src/w3iopomd.F90 | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index 706b03042..b7f84df89 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -1346,6 +1346,7 @@ END SUBROUTINE W3IOPON_READ
   SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
     use netcdf
     USE W3GDATMD, ONLY: NTH, NK, NSPEC, FILEXT
+    USE W3WDATMD, ONLY: TIME
     USE W3ODATMD, ONLY: NDST, NDSE, IPASS => IPASS2, NOPTS, IPTINT, &
          IL, IW, II, PTLOC, PTIFAC, DPO, WAO, WDO,   &
          ASO, CAO, CDO, SPCO, PTNME, O2INIT, FNMPRE, &
@@ -1364,7 +1365,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
     integer, intent(inout) :: ncerr
     integer :: fh, ndim, nvar, fmt, itime 
     integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen, d_time
-    integer :: v_idtst, v_vertst, v_nk, v_nth, v_ptloc, v_ptnme
+    integer :: v_idtst, v_vertst, v_nk, v_nth, v_ptloc, v_ptnme, v_time
     integer :: v_iw, v_ii, v_il, v_dpo, v_wao, v_wdo, v_tauao
     integer :: v_taido, v_dairo, v_zet_seto, v_aso, v_cao, v_cdo, v_iceo
     integer :: v_iceho, v_icefo, v_grdid, v_spco
@@ -1413,6 +1414,8 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
       if (ncerr .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_PTNME, NF90_CHAR, (/d_namelen, d_nopts/), v_ptnme)
       if (ncerr .ne. 0) return
+      ncerr = nf90_def_var(fh, VNAME_TIME, NF90_INT, (/d_vsize, d_time/),v_time)
+      if (ncerr .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_IW, NF90_INT, (/d_nopts, d_time/), v_iw)
       if (ncerr .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_II, NF90_INT, (/d_nopts, d_time/), v_ii)
@@ -1485,7 +1488,19 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
         itime=IPASS
      END IF
 
+    
+
     ! TO DO ADD TIME VARIABLE 
+    write(*,*) 'JDM f 0', TIME
+    IF ( itime > 1 ) THEN
+       ncerr = nf90_inq_varid(fh, VNAME_TIME, v_time)
+       if (ncerr .ne. 0) return
+    END IF
+    ncerr = nf90_put_var(fh, v_time, TIME, start = (/ 1, itime/), &
+       count = (/ 2, 1 /))
+    if (ncerr .ne. 0) return
+
+
     ! set IW, II and IL to 0 because it is not used and gives &
     ! outlier values in out_pnt.points - TODO: REMOVE???
     IW = 0

From ccfae367016b52b41b28520da450bff48589ba35 Mon Sep 17 00:00:00 2001
From: JessicaMeixner-NOAA 
Date: Wed, 3 Apr 2024 10:29:40 -0500
Subject: [PATCH 073/126] clean up of write debug statements and add a few
 comments

---
 model/src/w3iopomd.F90 | 77 ++++++++++++++++--------------------------
 1 file changed, 30 insertions(+), 47 deletions(-)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index b7f84df89..40edc1e5a 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -1369,17 +1369,13 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
     integer :: v_iw, v_ii, v_il, v_dpo, v_wao, v_wdo, v_tauao
     integer :: v_taido, v_dairo, v_zet_seto, v_aso, v_cao, v_cdo, v_iceo
     integer :: v_iceho, v_icefo, v_grdid, v_spco
-!!JDM - defined in module above    CHARACTER(LEN=31), PARAMETER :: IDSTR = 'WAVEWATCH III POINT OUTPUT FILE'
-!!JDM - defined in module above    CHARACTER(LEN=10), PARAMETER :: VEROPT = '2021-04-06'
 
-    write(*,*) 'JDM in write', IPASS, timestep_only
     !If first pass, or if you are writting a file for every time-step: 
     IF ( IPASS.EQ.1  .OR. timestep_only.EQ.1 ) THEN 
       ! Create the netCDF file.
       ncerr = nf90_create(filename, NF90_NETCDF4, fh)
       if (ncerr .ne. 0) return
  
-      write(*,*)'JDM a'
       ! Define dimensions.
       ncerr = nf90_def_dim(fh, DNAME_NOPTS, NOPTS, d_nopts)
       if (ncerr .ne. 0) return
@@ -1394,28 +1390,29 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
       ncerr = nf90_def_dim(fh, DNAME_TIME, NF90_UNLIMITED, d_time)
       if (ncerr .ne. 0) return
 
-      write(*,*) 'JDM b'
       ! Define global attributes.
       ncerr = nf90_put_att(fh, NF90_GLOBAL, 'title', IDSTR)
       if (ncerr .ne. 0) return
       ncerr = nf90_put_att(fh, NF90_GLOBAL, 'version', VEROPT)
       if (ncerr .ne. 0) return
 
-      write(*,*) 'JDM c'
       ! Define scalar variables.
       ncerr = nf90_def_var(fh, VNAME_NK, NF90_INT, v_nk)
       if (ncerr .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_NTH, NF90_INT, v_nth)
       if (ncerr .ne. 0) return
 
-      write(*,*) 'JDM d'
-      ! Define vars with nopts as a dimension.
+      ! Define vars with nopts as a dimension. Point location and name
       ncerr = nf90_def_var(fh, VNAME_PTLOC, NF90_FLOAT, (/d_vsize, d_nopts/), v_ptloc)
       if (ncerr .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_PTNME, NF90_CHAR, (/d_namelen, d_nopts/), v_ptnme)
       if (ncerr .ne. 0) return
+ 
+      ! Define time for each time step 
       ncerr = nf90_def_var(fh, VNAME_TIME, NF90_INT, (/d_vsize, d_time/),v_time)
       if (ncerr .ne. 0) return
+
+      ! Define vars with nopts and time as dimensions 
       ncerr = nf90_def_var(fh, VNAME_IW, NF90_INT, (/d_nopts, d_time/), v_iw)
       if (ncerr .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_II, NF90_INT, (/d_nopts, d_time/), v_ii)
@@ -1428,7 +1425,6 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
       if (ncerr .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_WDO, NF90_FLOAT, (/d_nopts, d_time/), v_wdo)
       if (ncerr .ne. 0) return
-
 #ifdef W3_FLX5
       ncerr = nf90_def_var(fh, VNAME_TAUAO, NF90_FLOAT, (/d_nopts, d_time/), v_tauao)
       if (ncerr .ne. 0) return
@@ -1455,43 +1451,41 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
       if (ncerr .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_GRDID, NF90_CHAR, (/d_grdidlen, d_nopts, d_time/), v_grdid)
       if (ncerr .ne. 0) return
+      
+      ! Define spectral output with dimensions nspec, nopts and time
       ncerr = nf90_def_var(fh, VNAME_SPCO, NF90_FLOAT, (/d_nspec, d_nopts, d_time/), v_spco)
       if (ncerr .ne. 0) return
   
-      write(*,*) 'JDM bb'
+      ! End of all variable definitions 
       ncerr = nf90_enddef(fh)
       if (ncerr .ne. 0) return
 
-      write(*,*) 'JDM c'
       ! Write the scalar data.
       ncerr = nf90_put_var(fh, v_nk, NK)
       if (ncerr .ne. 0) return
       ncerr = nf90_put_var(fh, v_nth, NTH)
       if (ncerr .ne. 0) return
 
-      write(*,*) 'JDM e' 
-      ! Write the data with NOPTS as a dimension.
+      ! Write the data with NOPTS as a dimension. (no time dimension)
       ncerr = nf90_put_var(fh, v_ptloc, PTLOC)
       if (ncerr .ne. 0) return
       ncerr = nf90_put_var(fh, v_ptnme, PTNME)
       if (ncerr .ne. 0) return
       
     ELSE 
-      write(*,*) 'JDM else'
+      ! If we are writing to the same file, re-open the file 
       ncerr = nf90_open(filename, nf90_write, fh)
       if (ncerr .ne. 0) return
     END IF 
 
-     IF ( timestep_only.EQ.1 ) THEN
-        itime=1
-     ELSE 
-        itime=IPASS
-     END IF
-
-    
+    !Determine the start for the time dimension 
+    IF ( timestep_only.EQ.1 ) THEN
+       itime=1
+    ELSE 
+       itime=IPASS
+    END IF
 
-    ! TO DO ADD TIME VARIABLE 
-    write(*,*) 'JDM f 0', TIME
+    ! Write Time
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_TIME, v_time)
        if (ncerr .ne. 0) return
@@ -1500,14 +1494,12 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
        count = (/ 2, 1 /))
     if (ncerr .ne. 0) return
 
-
     ! set IW, II and IL to 0 because it is not used and gives &
     ! outlier values in out_pnt.points - TODO: REMOVE???
     IW = 0
     II = 0
     IL = 0
 
-    write(*,*) 'JDM f 1'
     IF ( itime > 1 ) THEN 
        ncerr = nf90_inq_varid(fh, VNAME_IW, v_iw)
        if (ncerr .ne. 0) return
@@ -1515,8 +1507,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
     ncerr = nf90_put_var(fh, v_iw, IW, start = (/ 1, itime/), &
        count = (/ NOPTS, 1 /))
     if (ncerr .ne. 0) return
-    write(*,*) 'IW:', IW 
-    write(*,*) 'JDM f 2'
+
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_II, v_ii)
        if (ncerr .ne. 0) return
@@ -1524,7 +1515,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
     ncerr = nf90_put_var(fh, v_ii, II, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
     if (ncerr .ne. 0) return
-    write(*,*) 'JDM f 3'
+
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_IL, v_il)
        if (ncerr .ne. 0) return
@@ -1532,7 +1523,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
     ncerr = nf90_put_var(fh, v_il, IL, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
     if (ncerr .ne. 0) return
-    write(*,*) 'JDM f 4'
+
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_DPO, v_dpo)
        if (ncerr .ne. 0) return
@@ -1540,7 +1531,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
     ncerr = nf90_put_var(fh, v_dpo, DPO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
     if (ncerr .ne. 0) return
-    write(*,*) 'JDM f 5'
+
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_WAO, v_wao)
        if (ncerr .ne. 0) return
@@ -1549,7 +1540,6 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
        count = (/ nopts, 1 /))
     if (ncerr .ne. 0) return
 
-    write(*,*) 'JDM f 5b'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_WDO, v_wdo)
        if (ncerr .ne. 0) return
@@ -1558,9 +1548,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
        count = (/ nopts, 1 /))
     if (ncerr .ne. 0) return
 
-
 #ifdef W3_FLX5
-    write(*,*) 'JDM f 6'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_TAUAO, v_tauao)
        if (ncerr .ne. 0) return
@@ -1568,7 +1556,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
     ncerr = nf90_put_var(fh, v_tauao, TAUAO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
     if (ncerr .ne. 0) return
-    write(*,*) 'JDM f 7'
+
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_TAIDO, v_taido)
        if (ncerr .ne. 0) return
@@ -1576,7 +1564,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
     ncerr = nf90_put_var(fh, v_taido, TAIDO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
     if (ncerr .ne. 0) return
-    write(*,*) 'JDM f 8'
+
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_DAIRO, v_dairo)
        if (ncerr .ne. 0) return
@@ -1586,7 +1574,6 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
     if (ncerr .ne. 0) return
 #endif
 #ifdef W3_SETUP
-    write(*,*) 'JDM f 9'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_ZET_SETO, v_zet_seto)
        if (ncerr .ne. 0) return
@@ -1595,7 +1582,6 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
        count = (/ nopts, 1 /))
     if (ncerr .ne. 0) return
 #endif
-    write(*,*) 'JDM f 10'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_ASO, v_aso)
        if (ncerr .ne. 0) return
@@ -1603,7 +1589,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
     ncerr = nf90_put_var(fh, v_aso, ASO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
     if (ncerr .ne. 0) return
-    write(*,*) 'JDM f 11'
+
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_CAO, v_cao)
        if (ncerr .ne. 0) return
@@ -1611,7 +1597,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
     ncerr = nf90_put_var(fh, v_cao, CAO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
     if (ncerr .ne. 0) return
-    write(*,*) 'JDM f 11 b'
+
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_CDO, v_cdo)
        if (ncerr .ne. 0) return
@@ -1620,8 +1606,6 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
        count = (/ nopts, 1 /))
     if (ncerr .ne. 0) return
 
-
-    write(*,*) 'JDM f 12'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_ICEO, v_iceo)
        if (ncerr .ne. 0) return
@@ -1629,7 +1613,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
     ncerr = nf90_put_var(fh, v_iceo, ICEO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
     if (ncerr .ne. 0) return
-    write(*,*) 'JDM f 13'
+
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_ICEHO, v_iceho)
        if (ncerr .ne. 0) return
@@ -1637,7 +1621,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
     ncerr = nf90_put_var(fh, v_iceho, ICEHO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
     if (ncerr .ne. 0) return
-    write(*,*) 'JDM f 14'
+
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_ICEFO, v_icefo)
        if (ncerr .ne. 0) return
@@ -1645,8 +1629,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
     ncerr = nf90_put_var(fh, v_icefo, ICEFO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
     if (ncerr .ne. 0) return
-    write(*,*) 'JDM f 15'
-    write(*,*) 'GRDID:',GRDID
+
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_GRDID, v_grdid)
        if (ncerr .ne. 0) return
@@ -1654,7 +1637,8 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
     ncerr = nf90_put_var(fh, v_grdid, GRDID, start = (/ 1, 1, itime/), &
        count = (/ 13, nopts, 1 /))
     if (ncerr .ne. 0) return
-    write(*,*) 'JDM f 16'
+
+    !write spectral output
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_SPCO, v_spco)
        if (ncerr .ne. 0) return
@@ -1663,7 +1647,6 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
        count = (/nspec, nopts, 1 /))
     if (ncerr .ne. 0) return
 
-    write(*,*) 'JDM g'
     ! Close the file.
     ncerr = nf90_close(fh)
     if (ncerr .ne. 0) return

From 3502b6d69ea057042b1d071cbdacf3b4af58bf4f Mon Sep 17 00:00:00 2001
From: JessicaMeixner-NOAA 
Date: Wed, 3 Apr 2024 11:27:16 -0500
Subject: [PATCH 074/126] remove the open and inquiries from the ipass=1
 section of the read -- we need to do this every time we enter this routine

---
 model/src/w3iopomd.F90 | 91 ++++++++++++++++++++++--------------------
 1 file changed, 48 insertions(+), 43 deletions(-)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index 40edc1e5a..8b4aa9575 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -1157,52 +1157,55 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
     integer :: v_iceho, v_icefo, v_grdid, v_spco
 
     IOTST = 0
-    IF ( IPASS.EQ.1 ) THEN 
-      ! Open the netCDF file.
-      ncerr = nf90_open(filename, NF90_NOWRITE, fh)
-      if (ncerr .ne. 0) return
 
-      ! Read and check the version: 
-      ! TO DO add reading of IDTST and VERTST and make checks: 
-      !  IF ( IDTST .NE. IDSTR ) THEN
-      !    WRITE (NDSE,902) IDTST, IDSTR
-      !    CALL EXTCDE ( 10 )
-      !  END IF
-      !  IF ( VERTST .NE. VEROPT ) THEN
-      !    WRITE (NDSE,903) VERTST, VEROPT
-      !    CALL EXTCDE ( 11 )
-      !  END IF
+    ! Open the netCDF file.
+    ncerr = nf90_open(filename, NF90_NOWRITE, fh)
+    if (ncerr .ne. 0) return
 
 
-      ! Read the dimension information for NOPTS.
-      ncerr = nf90_inq_dimid(fh, DNAME_NOPTS, d_nopts)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_inquire_dimension(fh, d_nopts, len = d_nopts_len)
-      if (ncerr .ne. 0) return
+    ! Read and check the version: 
+    ! TO DO add reading of IDTST and VERTST and make checks: 
+    !  IF ( IDTST .NE. IDSTR ) THEN
+    !    WRITE (NDSE,902) IDTST, IDSTR
+    !    CALL EXTCDE ( 10 )
+    !  END IF
+    !  IF ( VERTST .NE. VEROPT ) THEN
+    !    WRITE (NDSE,903) VERTST, VEROPT
+    !    CALL EXTCDE ( 11 )
+    !  END IF
 
-      ! Read the dimension information for NSPEC.
-      ncerr = nf90_inq_dimid(fh, DNAME_NSPEC, d_nspec)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_inquire_dimension(fh, d_nspec, len = d_nspec_len)
-      if (ncerr .ne. 0) return
 
-      ! Read the dimension information for VSIZE.
-      ncerr = nf90_inq_dimid(fh, DNAME_VSIZE, d_vsize)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_inquire_dimension(fh, d_vsize, len = d_vsize_len)
-      if (ncerr .ne. 0) return
+    ! Read the dimension information for NOPTS.
+    ncerr = nf90_inq_dimid(fh, DNAME_NOPTS, d_nopts)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_inquire_dimension(fh, d_nopts, len = d_nopts_len)
+    if (ncerr .ne. 0) return
 
-      ! Read the dimension information for NAMELEN.
-      ncerr = nf90_inq_dimid(fh, DNAME_NAMELEN, d_namelen)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_inquire_dimension(fh, d_namelen, len = d_namelen_len)
-      if (ncerr .ne. 0) return
+    ! Read the dimension information for NSPEC.
+    ncerr = nf90_inq_dimid(fh, DNAME_NSPEC, d_nspec)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_inquire_dimension(fh, d_nspec, len = d_nspec_len)
+    if (ncerr .ne. 0) return
 
-      ! Read the dimension information for GRDIDLEN.
-      ncerr = nf90_inq_dimid(fh, DNAME_GRDIDLEN, d_grdidlen)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_inquire_dimension(fh, d_grdidlen, len = d_grdidlen_len)
-      if (ncerr .ne. 0) return
+    ! Read the dimension information for VSIZE.
+    ncerr = nf90_inq_dimid(fh, DNAME_VSIZE, d_vsize)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_inquire_dimension(fh, d_vsize, len = d_vsize_len)
+    if (ncerr .ne. 0) return
+
+    ! Read the dimension information for NAMELEN.
+    ncerr = nf90_inq_dimid(fh, DNAME_NAMELEN, d_namelen)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_inquire_dimension(fh, d_namelen, len = d_namelen_len)
+    if (ncerr .ne. 0) return
+
+    ! Read the dimension information for GRDIDLEN.
+    ncerr = nf90_inq_dimid(fh, DNAME_GRDIDLEN, d_grdidlen)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_inquire_dimension(fh, d_grdidlen, len = d_grdidlen_len)
+    if (ncerr .ne. 0) return
+
+    IF ( IPASS.EQ.1 ) THEN
 
       ! Read scalar variables.
       ncerr = nf90_inq_varid(fh, VNAME_NK, v_nk)
@@ -1228,8 +1231,9 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
       if (ncerr .ne. 0) return
       ncerr = nf90_inq_varid(fh, VNAME_PTNME, v_ptnme)
       if (ncerr .ne. 0) return
-      ncerr = nf90_get_var(fh, v_ptnme, PTNME)
-      if (ncerr .ne. 0) return
+      !code segfaults reading this, skipping for now to see other issues
+      !ncerr = nf90_get_var(fh, v_ptnme, PTNME)
+      !if (ncerr .ne. 0) return
     END IF
 
     !missing variable TIME??? 
@@ -1306,8 +1310,9 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
     if (ncerr .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_GRDID, v_grdid)
     if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_grdid, GRDID)
-    if (ncerr .ne. 0) return
+    !skipping because we get a segfault
+    !ncerr = nf90_get_var(fh, v_grdid, GRDID)
+    !if (ncerr .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_SPCO, v_spco)
     if (ncerr .ne. 0) return
     ncerr = nf90_get_var(fh, v_spco, SPCO)

From 792999827088e3e68f8ced208a5937687d95eef0 Mon Sep 17 00:00:00 2001
From: JessicaMeixner-NOAA 
Date: Wed, 3 Apr 2024 11:58:25 -0500
Subject: [PATCH 075/126] debugging tries for read routine

---
 model/src/w3iopomd.F90 | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index 8b4aa9575..87d29f718 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -1224,11 +1224,18 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
         CALL EXTCDE ( 12 )
       END IF
 
+      !check reading: 
+      write(*,*) 'MK,MTH', MK, MTH
+      write(*,*) 'dimensions:', d_nopts_len,d_grdidlen_len, d_namelen_len,d_vsize_len,d_nspec_len
+
+
       ! Read vars with nopts as a dimension.
       ncerr = nf90_inq_varid(fh, VNAME_PTLOC, v_ptloc)
       if (ncerr .ne. 0) return
-      ncerr = nf90_get_var(fh, v_ptloc, PTLOC)
+      ncerr = nf90_get_var(fh, v_ptloc, PTLOC, start = (/ 1, 1/), &
+       count = (/ d_vsize_len, d_nopts_len /)) 
       if (ncerr .ne. 0) return
+      write(*,*) 'PTLOC', PTLOC
       ncerr = nf90_inq_varid(fh, VNAME_PTNME, v_ptnme)
       if (ncerr .ne. 0) return
       !code segfaults reading this, skipping for now to see other issues

From 1ede4e0f1adf95ab09c20f3097509305e9332478 Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Thu, 4 Apr 2024 05:10:37 -0600
Subject: [PATCH 076/126] porting changes

---
 model/src/w3iopomd.F90 | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index 246ab4b71..4f58d62e4 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -65,7 +65,7 @@ MODULE W3IOPOMD
   !      Name      Type  Scope    Description
   !     ----------------------------------------------------------------
   !      VEROPT    C*10  Private  Point output file version number.
-  !      IDSTR     C*32  Private  Point output file ID string.
+  !      IDSTR     C*31  Private  Point output file ID string.
   !     ----------------------------------------------------------------
   !
   !  3. Subroutines and functions :
@@ -1131,6 +1131,7 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
          IL, IW, II, PTLOC, PTIFAC, DPO, WAO, WDO,   &
          ASO, CAO, CDO, SPCO, PTNME, O2INIT, FNMPRE, &
          GRDID, ICEO, ICEHO, ICEFO
+    USE W3SERVMD, ONLY: EXTCDE
 #ifdef W3_FLX5
     USE W3ODATMD, ONLY: TAUAO, TAUDO, DAIRO
 #endif
@@ -1143,6 +1144,7 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
     INTEGER, INTENT(IN), OPTIONAL :: IMOD
     character(*), intent(in) :: filename
     integer, intent(inout) :: ncerr
+    INTEGER :: MK,MTH
     integer :: fh
     integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen    
     integer :: d_nopts_len, d_nspec_len, d_vsize_len, d_namelen_len, d_grdidlen_len    

From 759470109e6a6519538b306e99a2ebdd6d229f20 Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Thu, 4 Apr 2024 05:49:21 -0600
Subject: [PATCH 077/126] merged Jessica's changes

---
 model/src/w3iopomd.F90         | 618 +++++++++++++++++++++++----------
 regtests/unittests/test_io.F90 |  11 +-
 2 files changed, 431 insertions(+), 198 deletions(-)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index 4f58d62e4..b7f84df89 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -122,19 +122,19 @@ MODULE W3IOPOMD
   !> Dimension name for the netCDF point output file, for NOPTS, the
   !> Number of Output Points.
   character(*), parameter, private :: DNAME_NOPTS = 'NOPTS'
-  
+
   !> Dimension name for the netCDF point output file, for NSPEC.
   character(*), parameter, private :: DNAME_NSPEC = 'NSPEC'
-  
+
   !> Dimension name for the netCDF point output file, for VSIZE. This
   !> is for the vector size for points, which is 2.
   character(*), parameter, private :: DNAME_VSIZE = 'VSIZE'
-  
+
   !> Dimension name for the netCDF point output file, for
   !> NAMELEN. This is the length of the PTNME strings, which contains
   !> the names of the points.
   character(*), parameter, private :: DNAME_NAMELEN = 'NAMELEN'
-  
+
   !> Dimension name for the netCDF point output file, for GRDIDLEN,
   !> this is the length of the GRDID character array.
   character(*), parameter, private :: DNAME_GRDIDLEN = 'GRDIDLEN'
@@ -146,7 +146,7 @@ MODULE W3IOPOMD
   character(*), parameter, private :: VNAME_NK = 'NK'
 
   !> Variable name for the netCDF point output file, for MTH.
-  character(*), parameter, private :: VNAME_MTH = 'MTH'
+  character(*), parameter, private :: VNAME_NTH = 'NTH'
 
   !> Variable name for the netCDF point output file, for PTLOC.
   character(*), parameter, private :: VNAME_PTLOC = 'PTLOC'
@@ -154,6 +154,9 @@ MODULE W3IOPOMD
   !> Variable name for the netCDF point output file, for PTNME.
   character(*), parameter, private :: VNAME_PTNME = 'PTNME'
 
+  !> Variable name for the netCDF point output file, for TIME. 
+  character(*), parameter, private :: VNAME_TIME = 'TIME'
+
   !> Variable name for the netCDF point output file, for IW.
   character(*), parameter, private :: VNAME_IW = 'IW'
 
@@ -207,7 +210,7 @@ MODULE W3IOPOMD
 
   !> Variable name for the netCDF point output file, for SPCO.
   character(*), parameter, private :: VNAME_SPCO = 'SPCO'
-  
+
   !/
 CONTAINS
   !/ ------------------------------------------------------------------- /
@@ -1125,7 +1128,7 @@ END SUBROUTINE W3IOPE
   !> @author Edward Hartnett  @date 1-Nov-2023
   !>
   SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
-    use netcdf
+    USE NetCDF
     USE W3GDATMD, ONLY: NTH, NK, NSPEC, FILEXT
     USE W3ODATMD, ONLY: NDST, NDSE, IPASS => IPASS2, NOPTS, IPTINT, &
          IL, IW, II, PTLOC, PTIFAC, DPO, WAO, WDO,   &
@@ -1146,69 +1149,93 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
     integer, intent(inout) :: ncerr
     INTEGER :: MK,MTH
     integer :: fh
-    integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen    
-    integer :: d_nopts_len, d_nspec_len, d_vsize_len, d_namelen_len, d_grdidlen_len    
-    integer :: v_idtst, v_vertst, v_nk, v_mth, v_ptloc, v_ptnme
+    integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen
+    integer :: d_nopts_len, d_nspec_len, d_vsize_len, d_namelen_len, d_grdidlen_len
+    integer :: v_idtst, v_vertst, v_nk, v_nth, v_ptloc, v_ptnme
     integer :: v_iw, v_ii, v_il, v_dpo, v_wao, v_wdo, v_tauao
     integer :: v_taido, v_dairo, v_zet_seto, v_aso, v_cao, v_cdo, v_iceo
     integer :: v_iceho, v_icefo, v_grdid, v_spco
 
-    print *,filename
     IOTST = 0
-    
-    ! Open the netCDF file.
-    ncerr = nf90_open(filename, NF90_NOWRITE, fh)
-    if (ncerr .ne. 0) return
-
-    ! Read the dimension information for NOPTS.
-    ncerr = nf90_inq_dimid(fh, DNAME_NOPTS, d_nopts)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_inquire_dimension(fh, d_nopts, len = d_nopts_len)
-    if (ncerr .ne. 0) return
-
-    ! Read the dimension information for NSPEC.
-    ncerr = nf90_inq_dimid(fh, DNAME_NSPEC, d_nspec)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_inquire_dimension(fh, d_nspec, len = d_nspec_len)
-    if (ncerr .ne. 0) return
-
-    ! Read the dimension information for VSIZE.
-    ncerr = nf90_inq_dimid(fh, DNAME_VSIZE, d_vsize)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_inquire_dimension(fh, d_vsize, len = d_vsize_len)
-    if (ncerr .ne. 0) return
-
-    ! Read the dimension information for NAMELEN.
-    ncerr = nf90_inq_dimid(fh, DNAME_NAMELEN, d_namelen)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_inquire_dimension(fh, d_namelen, len = d_namelen_len)
-    if (ncerr .ne. 0) return
+    IF ( IPASS.EQ.1 ) THEN 
+      ! Open the netCDF file.
+      ncerr = nf90_open(filename, NF90_NOWRITE, fh)
+      if (ncerr .ne. 0) return
+
+      ! Read and check the version: 
+      ! TO DO add reading of IDTST and VERTST and make checks: 
+      !  IF ( IDTST .NE. IDSTR ) THEN
+      !    WRITE (NDSE,902) IDTST, IDSTR
+      !    CALL EXTCDE ( 10 )
+      !  END IF
+      !  IF ( VERTST .NE. VEROPT ) THEN
+      !    WRITE (NDSE,903) VERTST, VEROPT
+      !    CALL EXTCDE ( 11 )
+      !  END IF
+
+
+      ! Read the dimension information for NOPTS.
+      ncerr = nf90_inq_dimid(fh, DNAME_NOPTS, d_nopts)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_inquire_dimension(fh, d_nopts, len = d_nopts_len)
+      if (ncerr .ne. 0) return
+
+      ! Read the dimension information for NSPEC.
+      ncerr = nf90_inq_dimid(fh, DNAME_NSPEC, d_nspec)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_inquire_dimension(fh, d_nspec, len = d_nspec_len)
+      if (ncerr .ne. 0) return
+
+      ! Read the dimension information for VSIZE.
+      ncerr = nf90_inq_dimid(fh, DNAME_VSIZE, d_vsize)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_inquire_dimension(fh, d_vsize, len = d_vsize_len)
+      if (ncerr .ne. 0) return
+
+      ! Read the dimension information for NAMELEN.
+      ncerr = nf90_inq_dimid(fh, DNAME_NAMELEN, d_namelen)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_inquire_dimension(fh, d_namelen, len = d_namelen_len)
+      if (ncerr .ne. 0) return
+
+      ! Read the dimension information for GRDIDLEN.
+      ncerr = nf90_inq_dimid(fh, DNAME_GRDIDLEN, d_grdidlen)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_inquire_dimension(fh, d_grdidlen, len = d_grdidlen_len)
+      if (ncerr .ne. 0) return
+
+      ! Read scalar variables.
+      ncerr = nf90_inq_varid(fh, VNAME_NK, v_nk)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_get_var(fh, v_nk, MK)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_inq_varid(fh, VNAME_NTH, v_nth)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_get_var(fh, v_nth, MTH)
+      if (ncerr .ne. 0) return
+
+      !read in written variables NK, NTH as MK and MTH
+      !and ensure they match 
+      IF (NK.NE.MK .OR. NTH.NE.MTH) THEN
+        WRITE (NDSE,904) MK, MTH, NK, NTH
+        CALL EXTCDE ( 12 )
+      END IF
 
-    ! Read the dimension information for GRDIDLEN.
-    ncerr = nf90_inq_dimid(fh, DNAME_GRDIDLEN, d_grdidlen)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_inquire_dimension(fh, d_grdidlen, len = d_grdidlen_len)
-    if (ncerr .ne. 0) return
+      ! Read vars with nopts as a dimension.
+      ncerr = nf90_inq_varid(fh, VNAME_PTLOC, v_ptloc)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_get_var(fh, v_ptloc, PTLOC)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_inq_varid(fh, VNAME_PTNME, v_ptnme)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_get_var(fh, v_ptnme, PTNME)
+      if (ncerr .ne. 0) return
+    END IF
 
-    ! Read scalar variables.
-    ncerr = nf90_inq_varid(fh, VNAME_NK, v_nk)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_nk, NK)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_inq_varid(fh, VNAME_MTH, v_mth)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_mth, NTH)
-    if (ncerr .ne. 0) return
+    !missing variable TIME??? 
 
-    ! Read vars with nopts as a dimension.
-    ncerr = nf90_inq_varid(fh, VNAME_PTLOC, v_ptloc)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_ptloc, PTLOC)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_inq_varid(fh, VNAME_PTNME, v_ptnme)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_ptnme, PTNME)
-    if (ncerr .ne. 0) return
+    ! All of the below variables are missing the "time" dimension... 
+    ! the time dimension being read should be for "IPASS" 
     ncerr = nf90_inq_varid(fh, VNAME_IW, v_iw)
     if (ncerr .ne. 0) return
     ncerr = nf90_get_var(fh, v_iw, IW)
@@ -1246,13 +1273,13 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
     if (ncerr .ne. 0) return
     ncerr = nf90_get_var(fh, v_dairo, DAIRO)
     if (ncerr .ne. 0) return
-#endif    
+#endif
 #ifdef W3_SETUP
     ncerr = nf90_inq_varid(fh, ZET_SETO, v_zet_seto)
     if (ncerr .ne. 0) return
     ncerr = nf90_get_var(fh, v_zet_seto, ZET_SETO)
     if (ncerr .ne. 0) return
-#endif    
+#endif
     ncerr = nf90_inq_varid(fh, VNAME_ASO, v_aso)
     if (ncerr .ne. 0) return
     ncerr = nf90_get_var(fh, v_aso, ASO)
@@ -1285,11 +1312,22 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
     if (ncerr .ne. 0) return
     ncerr = nf90_get_var(fh, v_spco, SPCO)
     if (ncerr .ne. 0) return
-    
+
     ! Close the file.
     ncerr = nf90_close(fh)
     if (ncerr .ne. 0) return
-    
+
+902 FORMAT (/' *** WAVEWATCH III ERROR IN W3IOPON :'/               &
+         '     ILEGAL IDSTR, READ : ',A/                        &
+         '                  CHECK : ',A/)
+903 FORMAT (/' *** WAVEWATCH III ERROR IN W3IOPON :'/               &
+         '     ILEGAL VEROPT, READ : ',A/                       &
+         '                   CHECK : ',A/)
+904 FORMAT (/' *** WAVEWATCH III ERROR IN W3IOPO :'/                &
+         '     ERROR IN SPECTRA, MK, MTH : ',2I8/               &
+         '              ARRAY DIMENSIONS : ',2I8/)
+
+
   END SUBROUTINE W3IOPON_READ
 
   !/ ------------------------------------------------------------------- /
@@ -1308,6 +1346,7 @@ END SUBROUTINE W3IOPON_READ
   SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
     use netcdf
     USE W3GDATMD, ONLY: NTH, NK, NSPEC, FILEXT
+    USE W3WDATMD, ONLY: TIME
     USE W3ODATMD, ONLY: NDST, NDSE, IPASS => IPASS2, NOPTS, IPTINT, &
          IL, IW, II, PTLOC, PTIFAC, DPO, WAO, WDO,   &
          ASO, CAO, CDO, SPCO, PTNME, O2INIT, FNMPRE, &
@@ -1318,148 +1357,313 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
 #ifdef W3_SETUP
     USE W3ODATMD, ONLY: ZET_SETO
 #endif
-    
+
     IMPLICIT NONE
     integer, intent(in) :: timestep_only ! 1 if only timestep should be written.
     INTEGER, INTENT(IN) :: IMOD
     character(*), intent(in) :: filename
     integer, intent(inout) :: ncerr
-    integer :: fh, ndim, nvar, fmt
+    integer :: fh, ndim, nvar, fmt, itime 
     integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen, d_time
-    integer :: v_idtst, v_vertst, v_nk, v_mth, v_ptloc, v_ptnme
+    integer :: v_idtst, v_vertst, v_nk, v_nth, v_ptloc, v_ptnme, v_time
     integer :: v_iw, v_ii, v_il, v_dpo, v_wao, v_wdo, v_tauao
     integer :: v_taido, v_dairo, v_zet_seto, v_aso, v_cao, v_cdo, v_iceo
     integer :: v_iceho, v_icefo, v_grdid, v_spco
-    character (len = *), parameter :: FILE_NAME = "f90tst_nc4.nc"
-    CHARACTER(LEN=31), PARAMETER :: IDSTR = 'WAVEWATCH III POINT OUTPUT FILE'
-    CHARACTER(LEN=10), PARAMETER :: VEROPT = '2021-04-06'
-
-    print *, 'WRITE ',filename, len(filename)
-
-    ! Create the netCDF file.
-    ncerr = nf90_create(filename, NF90_NETCDF4, fh)
-    if (ncerr .ne. 0) return
-
-    ! Define dimensions.
-    ncerr = nf90_def_dim(fh, DNAME_NOPTS, NOPTS, d_nopts)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_def_dim(fh, DNAME_NSPEC, NSPEC, d_nspec)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_def_dim(fh, DNAME_VSIZE, 2, d_vsize)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_def_dim(fh, DNAME_NAMELEN, 40, d_namelen)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_def_dim(fh, DNAME_GRDIDLEN, 13, d_grdidlen)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_def_dim(fh, DNAME_TIME, NF90_UNLIMITED, d_time)
-    if (ncerr .ne. 0) return
-
-    ! Define global attributes.
-    ncerr = nf90_put_att(fh, NF90_GLOBAL, 'title', IDSTR)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_put_att(fh, NF90_GLOBAL, 'version', VEROPT)
-    if (ncerr .ne. 0) return
-    
-    ! Define scalar variables.
-    ncerr = nf90_def_var(fh, VNAME_NK, NF90_INT, v_nk)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_def_var(fh, VNAME_MTH, NF90_INT, v_mth)
-    if (ncerr .ne. 0) return
+!!JDM - defined in module above    CHARACTER(LEN=31), PARAMETER :: IDSTR = 'WAVEWATCH III POINT OUTPUT FILE'
+!!JDM - defined in module above    CHARACTER(LEN=10), PARAMETER :: VEROPT = '2021-04-06'
+
+    write(*,*) 'JDM in write', IPASS, timestep_only
+    !If first pass, or if you are writting a file for every time-step: 
+    IF ( IPASS.EQ.1  .OR. timestep_only.EQ.1 ) THEN 
+      ! Create the netCDF file.
+      ncerr = nf90_create(filename, NF90_NETCDF4, fh)
+      if (ncerr .ne. 0) return
+ 
+      write(*,*)'JDM a'
+      ! Define dimensions.
+      ncerr = nf90_def_dim(fh, DNAME_NOPTS, NOPTS, d_nopts)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_def_dim(fh, DNAME_NSPEC, NSPEC, d_nspec)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_def_dim(fh, DNAME_VSIZE, 2, d_vsize)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_def_dim(fh, DNAME_NAMELEN, 40, d_namelen)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_def_dim(fh, DNAME_GRDIDLEN, 13, d_grdidlen)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_def_dim(fh, DNAME_TIME, NF90_UNLIMITED, d_time)
+      if (ncerr .ne. 0) return
+
+      write(*,*) 'JDM b'
+      ! Define global attributes.
+      ncerr = nf90_put_att(fh, NF90_GLOBAL, 'title', IDSTR)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_put_att(fh, NF90_GLOBAL, 'version', VEROPT)
+      if (ncerr .ne. 0) return
+
+      write(*,*) 'JDM c'
+      ! Define scalar variables.
+      ncerr = nf90_def_var(fh, VNAME_NK, NF90_INT, v_nk)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_def_var(fh, VNAME_NTH, NF90_INT, v_nth)
+      if (ncerr .ne. 0) return
+
+      write(*,*) 'JDM d'
+      ! Define vars with nopts as a dimension.
+      ncerr = nf90_def_var(fh, VNAME_PTLOC, NF90_FLOAT, (/d_vsize, d_nopts/), v_ptloc)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_def_var(fh, VNAME_PTNME, NF90_CHAR, (/d_namelen, d_nopts/), v_ptnme)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_def_var(fh, VNAME_TIME, NF90_INT, (/d_vsize, d_time/),v_time)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_def_var(fh, VNAME_IW, NF90_INT, (/d_nopts, d_time/), v_iw)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_def_var(fh, VNAME_II, NF90_INT, (/d_nopts, d_time/), v_ii)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_def_var(fh, VNAME_IL, NF90_INT, (/d_nopts, d_time/), v_il)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_def_var(fh, VNAME_DPO, NF90_FLOAT, (/d_nopts, d_time/), v_dpo)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_def_var(fh, VNAME_WAO, NF90_FLOAT, (/d_nopts, d_time/), v_wao)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_def_var(fh, VNAME_WDO, NF90_FLOAT, (/d_nopts, d_time/), v_wdo)
+      if (ncerr .ne. 0) return
 
-    ! Define vars with nopts as a dimension.
-    ncerr = nf90_def_var(fh, VNAME_PTLOC, NF90_INT, (/d_vsize, d_nopts/), v_ptloc)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_def_var(fh, VNAME_PTNME, NF90_CHAR, (/d_namelen, d_nopts/), v_ptnme)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_def_var(fh, VNAME_IW, NF90_INT, (/d_nopts, d_time/), v_iw)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_def_var(fh, VNAME_II, NF90_INT, (/d_nopts, d_time/), v_ii)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_def_var(fh, VNAME_IL, NF90_INT, (/d_nopts, d_time/), v_il)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_def_var(fh, VNAME_DPO, NF90_INT, (/d_nopts, d_time/), v_dpo)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_def_var(fh, VNAME_WAO, NF90_INT, (/d_nopts, d_time/), v_wao)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_def_var(fh, VNAME_WDO, NF90_INT, (/d_nopts, d_time/), v_wdo)
-    if (ncerr .ne. 0) return
 #ifdef W3_FLX5
-    ncerr = nf90_def_var(fh, VNAME_TAUAO, NF90_INT, (/d_nopts, d_time/), v_tauao)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_def_var(fh, VNAME_TAIDO, NF90_INT, (/d_nopts, d_time/), v_taido)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_def_var(fh, VNAME_DAIRO, NF90_INT, (/d_nopts, d_time/), v_dairo)
-    if (ncerr .ne. 0) return
+      ncerr = nf90_def_var(fh, VNAME_TAUAO, NF90_FLOAT, (/d_nopts, d_time/), v_tauao)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_def_var(fh, VNAME_TAIDO, NF90_FLOAT, (/d_nopts, d_time/), v_taido)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_def_var(fh, VNAME_DAIRO, NF90_FLOAT, (/d_nopts, d_time/), v_dairo)
+      if (ncerr .ne. 0) return
 #endif    
 #ifdef W3_SETUP
-    ncerr = nf90_def_var(fh, VNAME_ZET_SETO, NF90_INT, (/d_nopts, d_time/), v_zet_seto)
-    if (ncerr .ne. 0) return
+      ncerr = nf90_def_var(fh, VNAME_ZET_SETO, NF90_FLOAT, (/d_nopts, d_time/), v_zet_seto)
+      if (ncerr .ne. 0) return
 #endif    
-    ncerr = nf90_def_var(fh, VNAME_ASO, NF90_INT, (/d_nopts, d_time/), v_aso)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_def_var(fh, VNAME_CAO, NF90_INT, (/d_nopts, d_time/), v_cao)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_def_var(fh, VNAME_CDO, NF90_INT, (/d_nopts, d_time/), v_cdo)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_def_var(fh, VNAME_ICEO, NF90_INT, (/d_nopts, d_time/), v_iceo)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_def_var(fh, VNAME_ICEHO, NF90_INT, (/d_nopts, d_time/), v_iceho)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_def_var(fh, VNAME_ICEFO, NF90_INT, (/d_nopts, d_time/), v_icefo)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_def_var(fh, VNAME_GRDID, NF90_CHAR, (/d_grdidlen, d_nopts, d_time/), v_grdid)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_def_var(fh, VNAME_SPCO, NF90_INT, (/d_nspec, d_nopts, d_time/), v_spco)
-    if (ncerr .ne. 0) return
+      ncerr = nf90_def_var(fh, VNAME_ASO, NF90_FLOAT, (/d_nopts, d_time/), v_aso)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_def_var(fh, VNAME_CAO, NF90_FLOAT, (/d_nopts, d_time/), v_cao)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_def_var(fh, VNAME_CDO, NF90_FLOAT, (/d_nopts, d_time/), v_cdo)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_def_var(fh, VNAME_ICEO, NF90_FLOAT, (/d_nopts, d_time/), v_iceo)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_def_var(fh, VNAME_ICEHO, NF90_FLOAT, (/d_nopts, d_time/), v_iceho)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_def_var(fh, VNAME_ICEFO, NF90_FLOAT, (/d_nopts, d_time/), v_icefo)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_def_var(fh, VNAME_GRDID, NF90_CHAR, (/d_grdidlen, d_nopts, d_time/), v_grdid)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_def_var(fh, VNAME_SPCO, NF90_FLOAT, (/d_nspec, d_nopts, d_time/), v_spco)
+      if (ncerr .ne. 0) return
+  
+      write(*,*) 'JDM bb'
+      ncerr = nf90_enddef(fh)
+      if (ncerr .ne. 0) return
+
+      write(*,*) 'JDM c'
+      ! Write the scalar data.
+      ncerr = nf90_put_var(fh, v_nk, NK)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_put_var(fh, v_nth, NTH)
+      if (ncerr .ne. 0) return
+
+      write(*,*) 'JDM e' 
+      ! Write the data with NOPTS as a dimension.
+      ncerr = nf90_put_var(fh, v_ptloc, PTLOC)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_put_var(fh, v_ptnme, PTNME)
+      if (ncerr .ne. 0) return
+      
+    ELSE 
+      write(*,*) 'JDM else'
+      ncerr = nf90_open(filename, nf90_write, fh)
+      if (ncerr .ne. 0) return
+    END IF 
+
+     IF ( timestep_only.EQ.1 ) THEN
+        itime=1
+     ELSE 
+        itime=IPASS
+     END IF
 
-    ! Write the scalar data.
-    ncerr = nf90_put_var(fh, v_nk, NK)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_put_var(fh, v_mth, NTH)
-    if (ncerr .ne. 0) return
+    
 
-    ! Write the data with NOPTS as a dimension.
-    ncerr = nf90_put_var(fh, v_ptloc, PTLOC)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_put_var(fh, v_ptnme, PTNME)
+    ! TO DO ADD TIME VARIABLE 
+    write(*,*) 'JDM f 0', TIME
+    IF ( itime > 1 ) THEN
+       ncerr = nf90_inq_varid(fh, VNAME_TIME, v_time)
+       if (ncerr .ne. 0) return
+    END IF
+    ncerr = nf90_put_var(fh, v_time, TIME, start = (/ 1, itime/), &
+       count = (/ 2, 1 /))
     if (ncerr .ne. 0) return
-    ncerr = nf90_put_var(fh, v_iw, IW)
+
+
+    ! set IW, II and IL to 0 because it is not used and gives &
+    ! outlier values in out_pnt.points - TODO: REMOVE???
+    IW = 0
+    II = 0
+    IL = 0
+
+    write(*,*) 'JDM f 1'
+    IF ( itime > 1 ) THEN 
+       ncerr = nf90_inq_varid(fh, VNAME_IW, v_iw)
+       if (ncerr .ne. 0) return
+    END IF
+    ncerr = nf90_put_var(fh, v_iw, IW, start = (/ 1, itime/), &
+       count = (/ NOPTS, 1 /))
+    if (ncerr .ne. 0) return
+    write(*,*) 'IW:', IW 
+    write(*,*) 'JDM f 2'
+    IF ( itime > 1 ) THEN
+       ncerr = nf90_inq_varid(fh, VNAME_II, v_ii)
+       if (ncerr .ne. 0) return
+    END IF
+    ncerr = nf90_put_var(fh, v_ii, II, start = (/ 1, itime/), &
+       count = (/ nopts, 1 /))
     if (ncerr .ne. 0) return
-    ncerr = nf90_put_var(fh, v_ii, II)
+    write(*,*) 'JDM f 3'
+    IF ( itime > 1 ) THEN
+       ncerr = nf90_inq_varid(fh, VNAME_IL, v_il)
+       if (ncerr .ne. 0) return
+    END IF
+    ncerr = nf90_put_var(fh, v_il, IL, start = (/ 1, itime/), &
+       count = (/ nopts, 1 /))
     if (ncerr .ne. 0) return
-    ncerr = nf90_put_var(fh, v_il, IL)
+    write(*,*) 'JDM f 4'
+    IF ( itime > 1 ) THEN
+       ncerr = nf90_inq_varid(fh, VNAME_DPO, v_dpo)
+       if (ncerr .ne. 0) return
+    END IF
+    ncerr = nf90_put_var(fh, v_dpo, DPO, start = (/ 1, itime/), &
+       count = (/ nopts, 1 /))
     if (ncerr .ne. 0) return
-    ncerr = nf90_put_var(fh, v_dpo, DPO)
+    write(*,*) 'JDM f 5'
+    IF ( itime > 1 ) THEN
+       ncerr = nf90_inq_varid(fh, VNAME_WAO, v_wao)
+       if (ncerr .ne. 0) return
+    END IF
+    ncerr = nf90_put_var(fh, v_wao, WAO, start = (/ 1, itime/), &
+       count = (/ nopts, 1 /))
     if (ncerr .ne. 0) return
-    ncerr = nf90_put_var(fh, v_wao, WAO)
+
+    write(*,*) 'JDM f 5b'
+    IF ( itime > 1 ) THEN
+       ncerr = nf90_inq_varid(fh, VNAME_WDO, v_wdo)
+       if (ncerr .ne. 0) return
+    END IF
+    ncerr = nf90_put_var(fh, v_wdo, WDO, start = (/ 1, itime/), &
+       count = (/ nopts, 1 /))
     if (ncerr .ne. 0) return
+
+
 #ifdef W3_FLX5
-    ncerr = nf90_put_var(fh, v_tauao, TAUAO)
+    write(*,*) 'JDM f 6'
+    IF ( itime > 1 ) THEN
+       ncerr = nf90_inq_varid(fh, VNAME_TAUAO, v_tauao)
+       if (ncerr .ne. 0) return
+    END IF
+    ncerr = nf90_put_var(fh, v_tauao, TAUAO, start = (/ 1, itime/), &
+       count = (/ nopts, 1 /))
     if (ncerr .ne. 0) return
-    ncerr = nf90_put_var(fh, v_taido, TAIDO)
+    write(*,*) 'JDM f 7'
+    IF ( itime > 1 ) THEN
+       ncerr = nf90_inq_varid(fh, VNAME_TAIDO, v_taido)
+       if (ncerr .ne. 0) return
+    END IF
+    ncerr = nf90_put_var(fh, v_taido, TAIDO, start = (/ 1, itime/), &
+       count = (/ nopts, 1 /))
     if (ncerr .ne. 0) return
-    ncerr = nf90_put_var(fh, v_dairo, DAIRO)
+    write(*,*) 'JDM f 8'
+    IF ( itime > 1 ) THEN
+       ncerr = nf90_inq_varid(fh, VNAME_DAIRO, v_dairo)
+       if (ncerr .ne. 0) return
+    END IF
+    ncerr = nf90_put_var(fh, v_dairo, DAIRO, start = (/ 1, itime/), &
+       count = (/ nopts, 1 /))
     if (ncerr .ne. 0) return
 #endif
 #ifdef W3_SETUP
-    ncerr = nf90_put_var(fh, v_zet_seto, ZET_SETO)
+    write(*,*) 'JDM f 9'
+    IF ( itime > 1 ) THEN
+       ncerr = nf90_inq_varid(fh, VNAME_ZET_SETO, v_zet_seto)
+       if (ncerr .ne. 0) return
+    END IF
+    ncerr = nf90_put_var(fh, v_zet_seto, ZET_SETO, start = (/ 1, itime/), &
+       count = (/ nopts, 1 /))
     if (ncerr .ne. 0) return
 #endif
-    ncerr = nf90_put_var(fh, v_aso, ASO)
+    write(*,*) 'JDM f 10'
+    IF ( itime > 1 ) THEN
+       ncerr = nf90_inq_varid(fh, VNAME_ASO, v_aso)
+       if (ncerr .ne. 0) return
+    END IF
+    ncerr = nf90_put_var(fh, v_aso, ASO, start = (/ 1, itime/), &
+       count = (/ nopts, 1 /))
     if (ncerr .ne. 0) return
-    ncerr = nf90_put_var(fh, v_cao, CAO)
+    write(*,*) 'JDM f 11'
+    IF ( itime > 1 ) THEN
+       ncerr = nf90_inq_varid(fh, VNAME_CAO, v_cao)
+       if (ncerr .ne. 0) return
+    END IF
+    ncerr = nf90_put_var(fh, v_cao, CAO, start = (/ 1, itime/), &
+       count = (/ nopts, 1 /))
     if (ncerr .ne. 0) return
-    ncerr = nf90_put_var(fh, v_iceo, ICEO)
+    write(*,*) 'JDM f 11 b'
+    IF ( itime > 1 ) THEN
+       ncerr = nf90_inq_varid(fh, VNAME_CDO, v_cdo)
+       if (ncerr .ne. 0) return
+    END IF
+    ncerr = nf90_put_var(fh, v_cdo, CDO, start = (/ 1, itime/), &
+       count = (/ nopts, 1 /))
     if (ncerr .ne. 0) return
-    ncerr = nf90_put_var(fh, v_iceho, ICEHO)
+
+
+    write(*,*) 'JDM f 12'
+    IF ( itime > 1 ) THEN
+       ncerr = nf90_inq_varid(fh, VNAME_ICEO, v_iceo)
+       if (ncerr .ne. 0) return
+    END IF
+    ncerr = nf90_put_var(fh, v_iceo, ICEO, start = (/ 1, itime/), &
+       count = (/ nopts, 1 /))
     if (ncerr .ne. 0) return
-    ncerr = nf90_put_var(fh, v_icefo, ICEFO)
+    write(*,*) 'JDM f 13'
+    IF ( itime > 1 ) THEN
+       ncerr = nf90_inq_varid(fh, VNAME_ICEHO, v_iceho)
+       if (ncerr .ne. 0) return
+    END IF
+    ncerr = nf90_put_var(fh, v_iceho, ICEHO, start = (/ 1, itime/), &
+       count = (/ nopts, 1 /))
     if (ncerr .ne. 0) return
-    ncerr = nf90_put_var(fh, v_grdid, GRDID)
+    write(*,*) 'JDM f 14'
+    IF ( itime > 1 ) THEN
+       ncerr = nf90_inq_varid(fh, VNAME_ICEFO, v_icefo)
+       if (ncerr .ne. 0) return
+    END IF
+    ncerr = nf90_put_var(fh, v_icefo, ICEFO, start = (/ 1, itime/), &
+       count = (/ nopts, 1 /))
+    if (ncerr .ne. 0) return
+    write(*,*) 'JDM f 15'
+    write(*,*) 'GRDID:',GRDID
+    IF ( itime > 1 ) THEN
+       ncerr = nf90_inq_varid(fh, VNAME_GRDID, v_grdid)
+       if (ncerr .ne. 0) return
+    END IF
+    ncerr = nf90_put_var(fh, v_grdid, GRDID, start = (/ 1, 1, itime/), &
+       count = (/ 13, nopts, 1 /))
     if (ncerr .ne. 0) return
-    ncerr = nf90_put_var(fh, v_spco, SPCO)
+    write(*,*) 'JDM f 16'
+    IF ( itime > 1 ) THEN
+       ncerr = nf90_inq_varid(fh, VNAME_SPCO, v_spco)
+       if (ncerr .ne. 0) return
+    END IF
+    ncerr = nf90_put_var(fh, v_spco, SPCO, start = (/ 1, 1, itime/), &
+       count = (/nspec, nopts, 1 /))
     if (ncerr .ne. 0) return
 
+    write(*,*) 'JDM g'
     ! Close the file.
     ncerr = nf90_close(fh)
     if (ncerr .ne. 0) return
@@ -1518,10 +1722,17 @@ SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD &
     INTEGER, INTENT(IN), OPTIONAL :: NDSOA
 #endif
 
+    CHARACTER(LEN=15) :: TIMETAG
     INTEGER :: IGRD, MK, MTH
     character(len = 124) :: filename
     integer :: ncerr
 
+#ifdef W3_S
+    CALL STRACE (IENT, 'W3IOPON')
+#endif
+    ! IPASS essentially is the time variable dimension 
+    IPASS  = IPASS + 1
+
     ! Optimistically assume success.
     IOTST = 0
 
@@ -1540,32 +1751,52 @@ SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD &
     IF (INXOUT .NE. 'READ' .AND. INXOUT .NE. 'WRITE') THEN
       WRITE (NDSE, 900) INXOUT
       CALL EXTCDE(1)
-   END IF
-
-   ! Determine filename.
-   filename = ''
-   filename = transfer(FNMPRE(:LEN_TRIM(FNMPRE))//'out_pnt_nc.'//FILEXT(:LEN_TRIM(FILEXT)), filename)
-   !print *, filename
-   
-   ! Do a read or a write of the point file.
-   IF (INXOUT .EQ. 'READ') THEN
+    END IF
+
+!JDM Not sure this next section is really needed in the necdf context,
+!commenting out but leaving it as a placeholder for now 
+
+!    ! Ensure read/write are not mixed 
+!    IF ( IPASS.EQ.1  .AND. OFILES(2) .EQ. 0 ) THEN
+!      WRITE  = INXOUT.EQ.'WRITE'
+!    ELSE
+!      IF ( WRITE .AND. INXOUT.EQ.'READ' ) THEN
+!        WRITE (NDSE,901) INXOUT
+!        CALL EXTCDE ( 2 )
+!      END IF
+!    END IF
+
+    ! Determine filename.
+    filename = ''
+    IF ( OFILES(2) .EQ. 1 ) THEN 
+      ! Create TIMETAG for file name using YYYYMMDD.HHMMS prefix
+      WRITE(TIMETAG,"(i8.8,'.'i6.6)")TIME(1),TIME(2)
+      filename = transfer(FNMPRE(:LEN_TRIM(FNMPRE))//TIMETAG//'out_pnt.'//FILEXT(:LEN_TRIM(FILEXT))//'.nc', filename)
+    ELSE 
+      filename = transfer(FNMPRE(:LEN_TRIM(FNMPRE))//'out_pnt.'//FILEXT(:LEN_TRIM(FILEXT))//'.nc', filename)
+    END IF 
+
+    ! Do a read or a write of the point file.
+    IF (INXOUT .EQ. 'READ') THEN
       CALL W3IOPON_READ(IOTST, IMOD, filename, ncerr)
-   ELSE
+    ELSE
       CALL W3IOPON_WRITE(OFILES(2), IMOD, filename, ncerr)
-   ENDIF
-   if (ncerr .ne. 0) then
+    ENDIF
+    if (ncerr .ne. 0) then
       print *, nf90_strerror(ncerr)
-      CALL EXTCDE(21)      
-   endif
-   
+      CALL EXTCDE(21)
+    endif
+
     !/
     !/ End of W3IOPON ----------------------------------------------------- /
     !/
 
 900 FORMAT (/' *** WAVEWATCH III ERROR IN W3IOPO :'/                &
          '     ILEGAL INXOUT VALUE: ',A/)
+901 FORMAT (/' *** WAVEWATCH III ERROR IN W3IOPO :'/                &
+         '     MIXED READ/WRITE, LAST REQUEST: ',A/)
   END SUBROUTINE W3IOPON
- 
+
   !/ ------------------------------------------------------------------- /
   !> Read or write point output.
   !>
@@ -1588,12 +1819,12 @@ END SUBROUTINE W3IOPON
   !> -------------|------|----------|--------
   !> 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 | NK | Number of discrete wavenumbers  
+  !> 4 | integer | NTH | Number of discrete directions. 
   !> 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
+  !> 8 | integer(2) | TIME | Valid time
   !> reclen*NOPTS | * | * | records
   !>
   !> Each record contains:
@@ -1797,7 +2028,7 @@ SUBROUTINE W3IOPO ( INXOUT, NDSOP, IOTST, IMOD &
       CALL EXTCDE ( 1 )
     END IF
     !
-    !      IF ( IPASS.EQ.1 ) THEN
+    ! First pass to this file and we are only writing 1 file for all time     
     IF ( IPASS.EQ.1  .AND. OFILES(2) .EQ. 0) THEN
       WRITE  = INXOUT.EQ.'WRITE'
     ELSE
@@ -1810,10 +2041,10 @@ SUBROUTINE W3IOPO ( INXOUT, NDSOP, IOTST, IMOD &
     ! open file ---------------------------------------------------------- *
     !
     IF ( IPASS.EQ.1 .AND. OFILES(2) .EQ. 0 ) THEN
-      !
+
       I      = LEN_TRIM(FILEXT)
       J      = LEN_TRIM(FNMPRE)
-      !
+
 #ifdef W3_T
       WRITE (NDST,9001) FNMPRE(:J)//'out_pnt.'//FILEXT(:I)
 #endif
@@ -1932,7 +2163,7 @@ SUBROUTINE W3IOPO ( INXOUT, NDSOP, IOTST, IMOD &
       !
       IF ( WRITE ) THEN
         WRITE (NDSOP)                                           &
-             IDSTR, VEROPT, NK, NTH, NOPTS
+            IDSTR, VEROPT, NK, NTH, NOPTS
 #ifdef W3_ASCII
         WRITE (NDSOA,*)                                           &
              'IDSTR, VEROPT, NK, NTH, NOPTS:',                  &
@@ -1954,6 +2185,7 @@ SUBROUTINE W3IOPO ( INXOUT, NDSOP, IOTST, IMOD &
           WRITE (NDSE,904) MK, MTH, NK, NTH
           CALL EXTCDE ( 12 )
         END IF
+        !JDM: what is this???? 
         IF ( .NOT. O2INIT )                                     &
              CALL W3DMO2 ( IGRD, NDSE, NDST, NOPTS )
       END IF
diff --git a/regtests/unittests/test_io.F90 b/regtests/unittests/test_io.F90
index ce89d5df6..0f1a0d4e9 100644
--- a/regtests/unittests/test_io.F90
+++ b/regtests/unittests/test_io.F90
@@ -94,18 +94,19 @@ program test_io
   end do
   
   print *, 'OK!'
-  print *, 'testing writing the WW3 binary point file in netCDF...'
+  ! print *, 'testing writing the WW3 binary point file in netCDF...'
 
-  ! Write in netCDF.
-  call w3iopon('WRITE', ndsop, iotest)
-  if (iotest .ne. 0) stop 100
-  print *, 'OK!'
+  ! ! Write in netCDF.
+  ! call w3iopon('WRITE', ndsop, iotest)
+  ! if (iotest .ne. 0) stop 100
+  ! print *, 'OK!'
   
   ! print *, 'testing reading the WW3 binary point file in netCDF...'
   ! call w3iopon('READ', ndsop, iotest)
   ! print *, iotest
   ! if (iotest .ne. 0) stop 100
   ! print *, 'OK!'
+
   
   print *, 'OK!'
   

From 30fafe3207bd6a0d031cceb8cfeb64de08008955 Mon Sep 17 00:00:00 2001
From: JessicaMeixner-NOAA 
Date: Thu, 4 Apr 2024 07:24:36 -0500
Subject: [PATCH 078/126] update documentation PTLOC is a real not int

---
 model/src/w3iopomd.F90 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index 87d29f718..a2eb6266a 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -1817,7 +1817,7 @@ END SUBROUTINE W3IOPON
   !> 4 | integer | NK | Number of discrete wavenumbers  
   !> 4 | integer | NTH | Number of discrete directions. 
   !> 4 | integer | NOPTS | Number of output points.
-  !> 8*NOPTS | integer(2,NOPTS) | PTLOC | Point locations
+  !> 8*NOPTS | real(2,NOPTS) | PTLOC | Point locations
   !> 7*NOPTS | character*7 | PTNME | Point names
   !> 8 | integer(2) | TIME | Valid time
   !> reclen*NOPTS | * | * | records

From 131a917495e3b1729bf080150ced4359a2ea9a24 Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Thu, 4 Apr 2024 07:55:55 -0600
Subject: [PATCH 079/126] test writes netCDF file

---
 regtests/unittests/test_io.F90 | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/regtests/unittests/test_io.F90 b/regtests/unittests/test_io.F90
index 0f1a0d4e9..160f07eff 100644
--- a/regtests/unittests/test_io.F90
+++ b/regtests/unittests/test_io.F90
@@ -67,7 +67,7 @@ program test_io
   close(ndsop)
 
   ! Make sure we got the values we expected.
-  if (nopts .ne. 11) stop 11
+ if (nopts .ne. 11) stop 11
   expected_loc_1 = 0.0
   do i = 1, nopts
      ! Check ptnme and ptloc arrays.
@@ -87,6 +87,7 @@ program test_io
 
   print *, 'OK!'
   print *, 'initializing some data...'
+  ipass2 = 0
   do i = 1, nopts
      do j = 1, nspec
         spco(j, i) = 0.0
@@ -94,12 +95,12 @@ program test_io
   end do
   
   print *, 'OK!'
-  ! print *, 'testing writing the WW3 binary point file in netCDF...'
+  print *, 'testing writing the WW3 binary point file in netCDF...'
 
-  ! ! Write in netCDF.
-  ! call w3iopon('WRITE', ndsop, iotest)
-  ! if (iotest .ne. 0) stop 100
-  ! print *, 'OK!'
+  ! Write in netCDF.
+  call w3iopon('WRITE', ndsop, iotest)
+  if (iotest .ne. 0) stop 100
+  print *, 'OK!'
   
   ! print *, 'testing reading the WW3 binary point file in netCDF...'
   ! call w3iopon('READ', ndsop, iotest)

From 8b158fee00271ee3063632daace2a31bb1c79d31 Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Fri, 5 Apr 2024 09:27:43 -0600
Subject: [PATCH 080/126] minor change

---
 regtests/unittests/test_io.F90 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/regtests/unittests/test_io.F90 b/regtests/unittests/test_io.F90
index 160f07eff..46d46b404 100644
--- a/regtests/unittests/test_io.F90
+++ b/regtests/unittests/test_io.F90
@@ -102,7 +102,7 @@ program test_io
   if (iotest .ne. 0) stop 100
   print *, 'OK!'
   
-  ! print *, 'testing reading the WW3 binary point file in netCDF...'
+  print *, 'testing reading the WW3 binary point file in netCDF...'
   ! call w3iopon('READ', ndsop, iotest)
   ! print *, iotest
   ! if (iotest .ne. 0) stop 100

From 15f7a59df5a0d595ee193dc954bc4941db4e0c87 Mon Sep 17 00:00:00 2001
From: JessicaMeixner-NOAA 
Date: Mon, 8 Apr 2024 09:30:22 -0500
Subject: [PATCH 081/126] saving debug output write

---
 model/src/w3iopomd.F90 | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index a2eb6266a..63e76c169 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -1156,6 +1156,7 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
     integer :: v_taido, v_dairo, v_zet_seto, v_aso, v_cao, v_cdo, v_iceo
     integer :: v_iceho, v_icefo, v_grdid, v_spco
 
+
     IOTST = 0
 
     ! Open the netCDF file.
@@ -1250,27 +1251,33 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
     ncerr = nf90_inq_varid(fh, VNAME_IW, v_iw)
     if (ncerr .ne. 0) return
     ncerr = nf90_get_var(fh, v_iw, IW)
+    write(*,*) 'IW', IW 
     if (ncerr .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_II, v_ii)
     if (ncerr .ne. 0) return
     ncerr = nf90_get_var(fh, v_ii, II)
     if (ncerr .ne. 0) return
+    !wite(*,*) 'JDM II:', II
     ncerr = nf90_inq_varid(fh, VNAME_IL, v_il)
     if (ncerr .ne. 0) return
     ncerr = nf90_get_var(fh, v_il, IL)
     if (ncerr .ne. 0) return
+    write(*,*) 'IL', IL
     ncerr = nf90_inq_varid(fh, VNAME_DPO, v_dpo)
     if (ncerr .ne. 0) return
     ncerr = nf90_get_var(fh, v_dpo, DPO)
     if (ncerr .ne. 0) return
+    write(*,*) 'DPO', DPO
     ncerr = nf90_inq_varid(fh, VNAME_WAO, v_wao)
     if (ncerr .ne. 0) return
     ncerr = nf90_get_var(fh, v_wao, WAO)
+    write(*,*) 'WAO', WAO
     if (ncerr .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_WDO, v_wdo)
     if (ncerr .ne. 0) return
     ncerr = nf90_get_var(fh, v_wdo, WDO)
     if (ncerr .ne. 0) return
+    write(*,*) 'WDO', WDO 
 #ifdef W3_FLX5
     ncerr = nf90_inq_varid(fh, VNAME_TAUAO, v_tauao)
     if (ncerr .ne. 0) return
@@ -1295,22 +1302,27 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
     if (ncerr .ne. 0) return
     ncerr = nf90_get_var(fh, v_aso, ASO)
     if (ncerr .ne. 0) return
+    write(*,*) 'ASO', ASO
     ncerr = nf90_inq_varid(fh, VNAME_CAO, v_cao)
     if (ncerr .ne. 0) return
     ncerr = nf90_get_var(fh, v_cao, CAO)
     if (ncerr .ne. 0) return
+    write(*,*) 'CAO', CAO
     ncerr = nf90_inq_varid(fh, VNAME_CDO, v_cdo)
     if (ncerr .ne. 0) return
     ncerr = nf90_get_var(fh, v_cdo, CDO)
     if (ncerr .ne. 0) return
+    write(*,*) 'CDO', CDO
     ncerr = nf90_inq_varid(fh, VNAME_ICEO, v_iceo)
     if (ncerr .ne. 0) return
     ncerr = nf90_get_var(fh, v_iceo, ICEO)
     if (ncerr .ne. 0) return
+    write(*,*) 'ICEO', ICEO
     ncerr = nf90_inq_varid(fh, VNAME_ICEHO, v_iceho)
     if (ncerr .ne. 0) return
     ncerr = nf90_get_var(fh, v_iceho, ICEHO)
     if (ncerr .ne. 0) return
+    write(*,*) 'ICEHO', ICEHO
     ncerr = nf90_inq_varid(fh, VNAME_ICEFO, v_icefo)
     if (ncerr .ne. 0) return
     ncerr = nf90_get_var(fh, v_icefo, ICEFO)
@@ -1324,6 +1336,7 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
     if (ncerr .ne. 0) return
     ncerr = nf90_get_var(fh, v_spco, SPCO)
     if (ncerr .ne. 0) return
+    write(*,*) 'SPCO', SPCO 
 
     ! Close the file.
     ncerr = nf90_close(fh)

From 3bb3a1faedc7fcb257552959001eed4372d96218 Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Tue, 9 Apr 2024 08:09:26 -0600
Subject: [PATCH 082/126] added expected output for regtest

---
 regtests/ww3_tp2.5/out_pnt_ncdump.txt | 33 +++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 regtests/ww3_tp2.5/out_pnt_ncdump.txt

diff --git a/regtests/ww3_tp2.5/out_pnt_ncdump.txt b/regtests/ww3_tp2.5/out_pnt_ncdump.txt
new file mode 100644
index 000000000..3747eb8e4
--- /dev/null
+++ b/regtests/ww3_tp2.5/out_pnt_ncdump.txt
@@ -0,0 +1,33 @@
+netcdf out_pnt.ww3 {
+dimensions:
+	NOPTS = 1 ;
+	NSPEC = 36 ;
+	VSIZE = 2 ;
+	NAMELEN = 40 ;
+	GRDIDLEN = 13 ;
+	TIME = UNLIMITED ; // (13 currently)
+variables:
+	int NK ;
+	int NTH ;
+	float PTLOC(NOPTS, VSIZE) ;
+	char PTNME(NOPTS, NAMELEN) ;
+	int TIME(TIME, VSIZE) ;
+	int IW(TIME, NOPTS) ;
+	int II(TIME, NOPTS) ;
+	int IL(TIME, NOPTS) ;
+	float DPO(TIME, NOPTS) ;
+	float WAO(TIME, NOPTS) ;
+	float WDO(TIME, NOPTS) ;
+	float ASO(TIME, NOPTS) ;
+	float CAO(TIME, NOPTS) ;
+	float CDO(TIME, NOPTS) ;
+	float ICEO(TIME, NOPTS) ;
+	float ICEHO(TIME, NOPTS) ;
+	float ICEFO(TIME, NOPTS) ;
+	char GRDID(TIME, NOPTS, GRDIDLEN) ;
+	float SPCO(TIME, NOPTS, NSPEC) ;
+
+// global attributes:
+		:title = "WAVEWATCH III POINT OUTPUT FILE" ;
+		:version = "2021-04-06" ;
+}

From 59d7d7f915625f374e41719e106acbbc82ed8bad Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Tue, 9 Apr 2024 08:31:04 -0600
Subject: [PATCH 083/126] updated workflow

---
 .github/workflows/regtest_gnu.yml | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/regtest_gnu.yml b/.github/workflows/regtest_gnu.yml
index 58f8b8401..088f28811 100644
--- a/.github/workflows/regtest_gnu.yml
+++ b/.github/workflows/regtest_gnu.yml
@@ -108,13 +108,19 @@ jobs:
           make -j2 VERBOSE=1
           ${GITHUB_WORKSPACE}/ww3/model/bin/ww3_from_ftp.sh          
           cd ${GITHUB_WORKSPACE}/ww3/regtests
-          ./bin/run_cmake_test -o all -S -T -s PR1_MPI -w work_PR1_MPI -f -p mpirun -n 24 ../model ww3_tp2.4
-          cd ww3_tp2.4
-          cd ..
           ./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 ww3_tp2.5
+          ls -l
+          cd work_PR1_MPI
+          pwd
+          ls -l
+          /usr/local/netcdf-c-4.9.3-dev/bin/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          
         
 
 

From fbfccedc6c8358424c1f856f808a881d897593a9 Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Tue, 9 Apr 2024 09:39:59 -0600
Subject: [PATCH 084/126] updated workflow

---
 .github/workflows/regtest_gnu.yml | 2 --
 1 file changed, 2 deletions(-)

diff --git a/.github/workflows/regtest_gnu.yml b/.github/workflows/regtest_gnu.yml
index 088f28811..8461a648e 100644
--- a/.github/workflows/regtest_gnu.yml
+++ b/.github/workflows/regtest_gnu.yml
@@ -111,8 +111,6 @@ jobs:
           ./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 ww3_tp2.5
-          ls -l
           cd work_PR1_MPI
           pwd
           ls -l

From b17dfc2e21173718e119287fb714ce0a9fd24bb4 Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Tue, 9 Apr 2024 10:03:22 -0600
Subject: [PATCH 085/126] updated workflow

---
 .github/workflows/regtest_gnu.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/regtest_gnu.yml b/.github/workflows/regtest_gnu.yml
index 8461a648e..3dd5f6d62 100644
--- a/.github/workflows/regtest_gnu.yml
+++ b/.github/workflows/regtest_gnu.yml
@@ -114,7 +114,7 @@ jobs:
           cd work_PR1_MPI
           pwd
           ls -l
-          /usr/local/netcdf-c-4.9.3-dev/bin/ncdump -h out_pnt.ww3.nc > ncdump_out.txt
+          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

From 8d9e5723211a405d6cba49879f711fb935f69ed1 Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Tue, 9 Apr 2024 10:50:35 -0600
Subject: [PATCH 086/126] working on read code

---
 regtests/unittests/test_io.F90 | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/regtests/unittests/test_io.F90 b/regtests/unittests/test_io.F90
index 46d46b404..ccd7243e1 100644
--- a/regtests/unittests/test_io.F90
+++ b/regtests/unittests/test_io.F90
@@ -103,12 +103,11 @@ program test_io
   print *, 'OK!'
   
   print *, 'testing reading the WW3 binary point file in netCDF...'
-  ! call w3iopon('READ', ndsop, iotest)
-  ! print *, iotest
-  ! if (iotest .ne. 0) stop 100
-  ! print *, 'OK!'
+  call w3iopon('READ', ndsop, iotest)
+  print *, iotest
+  if (iotest .ne. 0) stop 100
+  print *, 'OK!'
 
-  
   print *, 'OK!'
   
   print *, 'SUCCESS!'

From c944bef63731f46db56f7a0920e6e695c2874805 Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Wed, 10 Apr 2024 09:09:17 -0600
Subject: [PATCH 087/126] fixed test_io call of read

---
 regtests/unittests/test_io.F90 | 1 +
 1 file changed, 1 insertion(+)

diff --git a/regtests/unittests/test_io.F90 b/regtests/unittests/test_io.F90
index ccd7243e1..e94e1a5d3 100644
--- a/regtests/unittests/test_io.F90
+++ b/regtests/unittests/test_io.F90
@@ -103,6 +103,7 @@ program test_io
   print *, 'OK!'
   
   print *, 'testing reading the WW3 binary point file in netCDF...'
+  ipass2 = 0
   call w3iopon('READ', ndsop, iotest)
   print *, iotest
   if (iotest .ne. 0) stop 100

From a2f44554adb3ddf1e623d62f0010964e227b8186 Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Fri, 12 Apr 2024 15:25:37 -0600
Subject: [PATCH 088/126] testing

---
 model/bin/ww3_from_ftp.sh             |  9 +++++---
 regtests/ww3_tp1.1/out_pnt_ncdump.txt | 33 +++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 3 deletions(-)
 create mode 100644 regtests/ww3_tp1.1/out_pnt_ncdump.txt

diff --git a/model/bin/ww3_from_ftp.sh b/model/bin/ww3_from_ftp.sh
index 67efc9284..4ab231e54 100755
--- a/model/bin/ww3_from_ftp.sh
+++ b/model/bin/ww3_from_ftp.sh
@@ -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/
diff --git a/regtests/ww3_tp1.1/out_pnt_ncdump.txt b/regtests/ww3_tp1.1/out_pnt_ncdump.txt
new file mode 100644
index 000000000..bb8e3ffb9
--- /dev/null
+++ b/regtests/ww3_tp1.1/out_pnt_ncdump.txt
@@ -0,0 +1,33 @@
+netcdf out_pnt.ww3 {
+dimensions:
+	NOPTS = 21 ;
+	NSPEC = 12 ;
+	VSIZE = 2 ;
+	NAMELEN = 40 ;
+	GRDIDLEN = 13 ;
+	TIME = UNLIMITED ; // (25 currently)
+variables:
+	int NK ;
+	int NTH ;
+	float PTLOC(NOPTS, VSIZE) ;
+	char PTNME(NOPTS, NAMELEN) ;
+	int TIME(TIME, VSIZE) ;
+	int IW(TIME, NOPTS) ;
+	int II(TIME, NOPTS) ;
+	int IL(TIME, NOPTS) ;
+	float DPO(TIME, NOPTS) ;
+	float WAO(TIME, NOPTS) ;
+	float WDO(TIME, NOPTS) ;
+	float ASO(TIME, NOPTS) ;
+	float CAO(TIME, NOPTS) ;
+	float CDO(TIME, NOPTS) ;
+	float ICEO(TIME, NOPTS) ;
+	float ICEHO(TIME, NOPTS) ;
+	float ICEFO(TIME, NOPTS) ;
+	char GRDID(TIME, NOPTS, GRDIDLEN) ;
+	float SPCO(TIME, NOPTS, NSPEC) ;
+
+// global attributes:
+		:title = "WAVEWATCH III POINT OUTPUT FILE" ;
+		:version = "2021-04-06" ;
+}

From 23bcebc61ed9463f6c9053d1bce51f5af424cf63 Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Fri, 12 Apr 2024 16:24:19 -0600
Subject: [PATCH 089/126] trying to cache regtest data

---
 .github/workflows/regtest_gnu.yml | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/regtest_gnu.yml b/.github/workflows/regtest_gnu.yml
index 3dd5f6d62..8598fe690 100644
--- a/.github/workflows/regtest_gnu.yml
+++ b/.github/workflows/regtest_gnu.yml
@@ -106,8 +106,10 @@ jobs:
           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
-          ${GITHUB_WORKSPACE}/ww3/model/bin/ww3_from_ftp.sh          
-          cd ${GITHUB_WORKSPACE}/ww3/regtests
+          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
@@ -120,6 +122,12 @@ jobs:
           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-env
+        id: cache-env
+        uses: actions/cache@v3
+        with:
+          path: ww3/ww3_from_ftp.v7.14.1.tar.gz
+          key: ww3_from_ftp.v7.14.1
 
 
       

From 2a5998d3da8ff2468aaf5d18754e50dcaad79c9f Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Fri, 12 Apr 2024 16:30:18 -0600
Subject: [PATCH 090/126] fixing cache

---
 .github/workflows/regtest_gnu.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/regtest_gnu.yml b/.github/workflows/regtest_gnu.yml
index 8598fe690..42d7fe8c1 100644
--- a/.github/workflows/regtest_gnu.yml
+++ b/.github/workflows/regtest_gnu.yml
@@ -122,8 +122,8 @@ jobs:
           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-env
-        id: cache-env
+      - name: cache-data
+        id: cache-data
         uses: actions/cache@v3
         with:
           path: ww3/ww3_from_ftp.v7.14.1.tar.gz

From 2e7e05498049b6701ab5e30a01619c3a0aa8e331 Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Fri, 12 Apr 2024 17:39:11 -0600
Subject: [PATCH 091/126] porting work

---
 model/src/w3iopomd.F90 | 60 +++++++++++++++++++++++++++++++++---------
 1 file changed, 48 insertions(+), 12 deletions(-)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index b7f84df89..e5126699b 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -211,6 +211,10 @@ MODULE W3IOPOMD
   !> Variable name for the netCDF point output file, for SPCO.
   character(*), parameter, private :: VNAME_SPCO = 'SPCO'
 
+  !> Error code returned by netCDF I/O function.
+  integer, parameter, private :: ERROR_NETCDF = 99
+  
+
   !/
 CONTAINS
   !/ ------------------------------------------------------------------- /
@@ -1117,6 +1121,23 @@ SUBROUTINE W3IOPE ( A )
     !/
   END SUBROUTINE W3IOPE
 
+  !> Call a netCDF function and handle return code.
+  !>
+  !> @param errcode NetCDF error code. 0 for no error.
+  !>
+  !> @author Edward Hartnett  @date 1-Nov-2023
+  !>
+  integer function nf90(errcode)
+    use netcdf
+    implicit none
+    integer, intent(in) :: errcode
+    
+    if(errcode /= nf90_noerr) then
+       print *, 'Error: ', trim(nf90_strerror(errcode))
+       return ERROR_NETCDF
+    endif
+  end function nf90
+
   !> Read point output in netCDF format.
   !>
   !> @param[out] IOTST Test indictor for reading.
@@ -1159,8 +1180,7 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
     IOTST = 0
     IF ( IPASS.EQ.1 ) THEN 
       ! Open the netCDF file.
-      ncerr = nf90_open(filename, NF90_NOWRITE, fh)
-      if (ncerr .ne. 0) return
+      if (nf90(nf90_open(filename, NF90_NOWRITE, fh)) .ne. 0) return
 
       ! Read and check the version: 
       ! TO DO add reading of IDTST and VERTST and make checks: 
@@ -1224,12 +1244,16 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
       ! Read vars with nopts as a dimension.
       ncerr = nf90_inq_varid(fh, VNAME_PTLOC, v_ptloc)
       if (ncerr .ne. 0) return
-      ncerr = nf90_get_var(fh, v_ptloc, PTLOC)
-      if (ncerr .ne. 0) return
+      if (associated(PTLOC)) then
+         ncerr = nf90_get_var(fh, v_ptloc, PTLOC)
+         if (ncerr .ne. 0) return
+      endif
       ncerr = nf90_inq_varid(fh, VNAME_PTNME, v_ptnme)
       if (ncerr .ne. 0) return
-      ncerr = nf90_get_var(fh, v_ptnme, PTNME)
-      if (ncerr .ne. 0) return
+      if (associated(PTNME)) then
+         ncerr = nf90_get_var(fh, v_ptnme, PTNME)
+         if (ncerr .ne. 0) return
+      endif
     END IF
 
     !missing variable TIME??? 
@@ -1363,14 +1387,12 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
     INTEGER, INTENT(IN) :: IMOD
     character(*), intent(in) :: filename
     integer, intent(inout) :: ncerr
-    integer :: fh, ndim, nvar, fmt, itime 
+    integer :: ndim, nvar, fmt, itime, fh
     integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen, d_time
     integer :: v_idtst, v_vertst, v_nk, v_nth, v_ptloc, v_ptnme, v_time
     integer :: v_iw, v_ii, v_il, v_dpo, v_wao, v_wdo, v_tauao
     integer :: v_taido, v_dairo, v_zet_seto, v_aso, v_cao, v_cdo, v_iceo
     integer :: v_iceho, v_icefo, v_grdid, v_spco
-!!JDM - defined in module above    CHARACTER(LEN=31), PARAMETER :: IDSTR = 'WAVEWATCH III POINT OUTPUT FILE'
-!!JDM - defined in module above    CHARACTER(LEN=10), PARAMETER :: VEROPT = '2021-04-06'
 
     write(*,*) 'JDM in write', IPASS, timestep_only
     !If first pass, or if you are writting a file for every time-step: 
@@ -1670,7 +1692,19 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
 
   END SUBROUTINE W3IOPON_WRITE
 
-  !> Read/write point output in netCDF format.
+  !> Read or write the netCDF point output file,
+  !> depending on the value of the first parameter.
+  !>
+  !> When reading, the entire file is read with one call to this
+  !> subroutine.
+  !>
+  !> 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.
   !>
   !> @param[in] INXOUT String indicating read/write. Must be 'READ' or
   !> 'WRITE'.
@@ -1715,7 +1749,7 @@ SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD &
     IMPLICIT NONE
 
     CHARACTER, INTENT(IN)         :: INXOUT*(*)
-    INTEGER, INTENT(IN)           :: NDSOP
+    INTEGER, INTENT(INOUT)           :: NDSOP
     INTEGER, INTENT(OUT)          :: IOTST
     INTEGER, INTENT(IN), OPTIONAL :: IMOD
 #ifdef W3_ASCII
@@ -1862,7 +1896,9 @@ END SUBROUTINE W3IOPON
   !>
   !> @param[in] INXOUT String indicating read/write. Must be 'READ' or
   !> 'WRITE'.
-  !> @param[in] NDSOP File unit number.
+  !> @param[in] NDSOP This is set by this subroutine to the netCDF
+  !> file ID (ncid) of the opened file. User does not have to
+  !> initialize this value, and should not change it.
   !> @param[out] IOTST Error code:
   !> - 0 No error.
   !> - -1 Unexpected end of file when reading.

From 58d1184ba75d346a4e2e2b91f844319e79145016 Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Fri, 12 Apr 2024 17:49:29 -0600
Subject: [PATCH 092/126] fixed code

---
 model/src/w3iopomd.F90 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index e5126699b..c945ecd48 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -1134,7 +1134,8 @@ integer function nf90(errcode)
     
     if(errcode /= nf90_noerr) then
        print *, 'Error: ', trim(nf90_strerror(errcode))
-       return ERROR_NETCDF
+       nf90 = ERROR_NETCDF
+       return 
     endif
   end function nf90
 

From 4bf279fbd0e4278c5a96944040877e12106ac46b Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Fri, 12 Apr 2024 17:54:53 -0600
Subject: [PATCH 093/126] more unit tests

---
 regtests/unittests/CMakeLists.txt |   1 +
 regtests/unittests/test_io.F90    |   5 +-
 regtests/unittests/test_io2.F90   | 123 ++++++++++++++++++++++++++++++
 3 files changed, 127 insertions(+), 2 deletions(-)
 create mode 100644 regtests/unittests/test_io2.F90

diff --git a/regtests/unittests/CMakeLists.txt b/regtests/unittests/CMakeLists.txt
index 8a11d2ad8..eb5969f08 100644
--- a/regtests/unittests/CMakeLists.txt
+++ b/regtests/unittests/CMakeLists.txt
@@ -41,6 +41,7 @@ copy_test_data_2(ww3_grid.inp ww3_grid.inp)
 # Build and run the tests.
 unit_test(test_io_points_bin)
 unit_test(test_io)
+unit_test(test_io2)
 unit_test(test_io_restart_bin)
 
 
diff --git a/regtests/unittests/test_io.F90 b/regtests/unittests/test_io.F90
index e94e1a5d3..ebe4e2385 100644
--- a/regtests/unittests/test_io.F90
+++ b/regtests/unittests/test_io.F90
@@ -35,6 +35,7 @@ program test_io
   ndsbul = 0
   ndstrc =  6
   ntrace = 10
+  imod = 1
 
   write (ndso,900)
 900 FORMAT (/15X,'    *** WAVEWATCH III Point output post.***    '/ &
@@ -98,13 +99,13 @@ program test_io
   print *, 'testing writing the WW3 binary point file in netCDF...'
 
   ! Write in netCDF.
-  call w3iopon('WRITE', ndsop, iotest)
+  call w3iopon('WRITE', ndsop, iotest, imod)
   if (iotest .ne. 0) stop 100
   print *, 'OK!'
   
   print *, 'testing reading the WW3 binary point file in netCDF...'
   ipass2 = 0
-  call w3iopon('READ', ndsop, iotest)
+  call w3iopon('READ', ndsop, iotest, imod)
   print *, iotest
   if (iotest .ne. 0) stop 100
   print *, 'OK!'
diff --git a/regtests/unittests/test_io2.F90 b/regtests/unittests/test_io2.F90
new file mode 100644
index 000000000..bba445458
--- /dev/null
+++ b/regtests/unittests/test_io2.F90
@@ -0,0 +1,123 @@
+! This is a test for model IO for WW3.
+!
+! Ed Hartnett 10/14/23
+program test_io
+  use w3iopomd
+  use w3gdatmd
+  use w3wdatmd
+  use w3odatmd
+  use w3iogrmd
+  use w3adatmd  
+  implicit none
+  
+  integer, target :: i, j, k, l
+  integer :: ndsop, iotest, imod, ndstst, ierr, ndsbul, ndsm
+  integer :: ndstrc, ntrace
+  real :: m2km
+  character*7 expected_ptnme
+  character*6 my_fmt
+  real :: expected_loc_1
+  integer :: write_test_file
+  
+  print *, 'Testing WW3 netCDF point file code.'
+
+  ! These are mysterious but have to be called or else the IPASS
+  ! variable does not exist and w3iopo() crashes.
+  call w3nmod(1, 6, 6)
+  call w3setg(1, 6, 6)
+  call w3ndat(6, 6)
+  call w3setw(1, 6, 6)
+  call w3nout(6, 6)
+  call w3seto(1, 6, 6)
+
+  ndsm   = 20
+  ndsop  = 20
+  ndsbul = 0
+  ndstrc =  6
+  ntrace = 10
+  imod = 1
+
+  write (ndso,900)
+900 FORMAT (/15X,'    *** WAVEWATCH III Point output post.***    '/ &
+       15X,'==============================================='/)
+
+  ! Open the file with the output settings for WW3. It is not needed actually.
+  ! open(ndsi, file = 'ww3_outp.inp', status='old', iostat = ierr)
+  ! if (ierr .ne. 0) stop 10
+
+  ! Create a point output file needed for this test.
+  print *, 'Creating point output test file for this test...'
+  if (write_test_file() .ne. 0) stop 1
+
+  ! 2.  Read model definition file.
+  CALL W3IOGR('READ', NDSM)
+  WRITE (NDSO,920) GNAME
+920 FORMAT ('  Grid name : ',A/)  
+
+  ! IF (FLAGLL) THEN
+  !   M2KM = 1.
+  ! ELSE
+  !   M2KM = 1.E-3
+  ! END IF
+
+  ! Read the file out_pnt.ww3 from the model/tests/data directory.
+  print *, 'OK!'
+  print *, 'Reading the point output test file for this test...'
+  call w3iopo('READ', ndsop, iotest)
+  if (iotest .ne. 0) stop 10
+  close(ndsop)
+
+  ! Make sure we got the values we expected.
+ if (nopts .ne. 11) stop 11
+  expected_loc_1 = 0.0
+  do i = 1, nopts
+     ! Check ptnme and ptloc arrays.
+     print *, ptnme(i), ptloc(1, i), ptloc(2, i)
+     if (i .lt. 10) then
+        my_fmt = '(a,i1)'
+     else
+        my_fmt = '(a,i2)'
+     endif
+     write(fmt = my_fmt, unit=expected_ptnme) 'Point', i
+     if (ptnme(i) .ne. expected_ptnme) stop 20
+     print *, expected_loc_1
+     if (ptloc(1, i) .ne. expected_loc_1) stop 21
+     expected_loc_1 = expected_loc_1 + 5000.0
+     if (ptloc(2, i) .ne. 0) stop 22
+  end do
+
+  print *, 'OK!'
+  print *, 'initializing some data...'
+  ipass2 = 0
+  do i = 1, nopts
+     do j = 1, nspec
+        spco(j, i) = 0.0
+     end do
+  end do
+  
+  print *, 'OK!'
+  print *, 'testing writing the WW3 binary point file in netCDF...'
+
+  ! Write in netCDF.
+  ofiles(2) = 1
+  call w3iopon('WRITE', ndsop, iotest, imod)
+  if (iotest .ne. 0) stop 100
+  print *, 'OK!'
+  
+  ! Another timestep in netCDF.
+  call w3iopon('WRITE', ndsop, iotest, imod)
+  if (iotest .ne. 0) stop 100
+  print *, 'OK!'
+  
+  print *, 'testing reading the WW3 binary point file in netCDF...'
+  ipass2 = 0
+  call w3iopon('READ', ndsop, iotest)
+  print *, iotest
+  if (iotest .ne. 0) stop 100
+  print *, 'OK!'
+
+  print *, 'OK!'
+  
+  print *, 'SUCCESS!'
+end program test_io
+  

From c24877fcdfbc0417f47d9e88bd0000b8b0d366b5 Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Fri, 12 Apr 2024 18:03:40 -0600
Subject: [PATCH 094/126] better error handling

---
 model/src/w3iopomd.F90 | 273 +++++++++++++++++++++--------------------
 1 file changed, 137 insertions(+), 136 deletions(-)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index c945ecd48..51927ea6f 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -1127,7 +1127,7 @@ END SUBROUTINE W3IOPE
   !>
   !> @author Edward Hartnett  @date 1-Nov-2023
   !>
-  integer function nf90(errcode)
+  integer function nf90_err(errcode)
     use netcdf
     implicit none
     integer, intent(in) :: errcode
@@ -1137,7 +1137,7 @@ integer function nf90(errcode)
        nf90 = ERROR_NETCDF
        return 
     endif
-  end function nf90
+  end function nf90_err
 
   !> Read point output in netCDF format.
   !>
@@ -1181,7 +1181,8 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
     IOTST = 0
     IF ( IPASS.EQ.1 ) THEN 
       ! Open the netCDF file.
-      if (nf90(nf90_open(filename, NF90_NOWRITE, fh)) .ne. 0) return
+      ncerr = nf90_open(filename, NF90_NOWRITE, fh)
+      if (nf90_err(ncerr) .ne. 0) return
 
       ! Read and check the version: 
       ! TO DO add reading of IDTST and VERTST and make checks: 
@@ -1197,43 +1198,43 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
 
       ! Read the dimension information for NOPTS.
       ncerr = nf90_inq_dimid(fh, DNAME_NOPTS, d_nopts)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_inquire_dimension(fh, d_nopts, len = d_nopts_len)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
 
       ! Read the dimension information for NSPEC.
       ncerr = nf90_inq_dimid(fh, DNAME_NSPEC, d_nspec)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_inquire_dimension(fh, d_nspec, len = d_nspec_len)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
 
       ! Read the dimension information for VSIZE.
       ncerr = nf90_inq_dimid(fh, DNAME_VSIZE, d_vsize)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_inquire_dimension(fh, d_vsize, len = d_vsize_len)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
 
       ! Read the dimension information for NAMELEN.
       ncerr = nf90_inq_dimid(fh, DNAME_NAMELEN, d_namelen)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_inquire_dimension(fh, d_namelen, len = d_namelen_len)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
 
       ! Read the dimension information for GRDIDLEN.
       ncerr = nf90_inq_dimid(fh, DNAME_GRDIDLEN, d_grdidlen)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_inquire_dimension(fh, d_grdidlen, len = d_grdidlen_len)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
 
       ! Read scalar variables.
       ncerr = nf90_inq_varid(fh, VNAME_NK, v_nk)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_get_var(fh, v_nk, MK)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_inq_varid(fh, VNAME_NTH, v_nth)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_get_var(fh, v_nth, MTH)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
 
       !read in written variables NK, NTH as MK and MTH
       !and ensure they match 
@@ -1244,16 +1245,16 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
 
       ! Read vars with nopts as a dimension.
       ncerr = nf90_inq_varid(fh, VNAME_PTLOC, v_ptloc)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       if (associated(PTLOC)) then
          ncerr = nf90_get_var(fh, v_ptloc, PTLOC)
-         if (ncerr .ne. 0) return
+         if (nf90(ncerr) .ne. 0) return
       endif
       ncerr = nf90_inq_varid(fh, VNAME_PTNME, v_ptnme)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       if (associated(PTNME)) then
          ncerr = nf90_get_var(fh, v_ptnme, PTNME)
-         if (ncerr .ne. 0) return
+         if (nf90(ncerr) .ne. 0) return
       endif
     END IF
 
@@ -1262,85 +1263,85 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
     ! All of the below variables are missing the "time" dimension... 
     ! the time dimension being read should be for "IPASS" 
     ncerr = nf90_inq_varid(fh, VNAME_IW, v_iw)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_iw, IW)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_II, v_ii)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_ii, II)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_IL, v_il)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_il, IL)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_DPO, v_dpo)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_dpo, DPO)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_WAO, v_wao)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_wao, WAO)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_WDO, v_wdo)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_wdo, WDO)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
 #ifdef W3_FLX5
     ncerr = nf90_inq_varid(fh, VNAME_TAUAO, v_tauao)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_tauao, TAUAO)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_TAIDO, v_taido)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_taido, TAIDO)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_DAIRO, v_dairo)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_dairo, DAIRO)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
 #endif
 #ifdef W3_SETUP
     ncerr = nf90_inq_varid(fh, ZET_SETO, v_zet_seto)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_zet_seto, ZET_SETO)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
 #endif
     ncerr = nf90_inq_varid(fh, VNAME_ASO, v_aso)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_aso, ASO)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_CAO, v_cao)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_cao, CAO)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_CDO, v_cdo)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_cdo, CDO)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_ICEO, v_iceo)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_iceo, ICEO)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_ICEHO, v_iceho)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_iceho, ICEHO)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_ICEFO, v_icefo)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_icefo, ICEFO)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_GRDID, v_grdid)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_grdid, GRDID)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_SPCO, v_spco)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_spco, SPCO)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
 
     ! Close the file.
     ncerr = nf90_close(fh)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
 
 902 FORMAT (/' *** WAVEWATCH III ERROR IN W3IOPON :'/               &
          '     ILEGAL IDSTR, READ : ',A/                        &
@@ -1400,109 +1401,109 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
     IF ( IPASS.EQ.1  .OR. timestep_only.EQ.1 ) THEN 
       ! Create the netCDF file.
       ncerr = nf90_create(filename, NF90_NETCDF4, fh)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
  
       write(*,*)'JDM a'
       ! Define dimensions.
       ncerr = nf90_def_dim(fh, DNAME_NOPTS, NOPTS, d_nopts)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_def_dim(fh, DNAME_NSPEC, NSPEC, d_nspec)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_def_dim(fh, DNAME_VSIZE, 2, d_vsize)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_def_dim(fh, DNAME_NAMELEN, 40, d_namelen)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_def_dim(fh, DNAME_GRDIDLEN, 13, d_grdidlen)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_def_dim(fh, DNAME_TIME, NF90_UNLIMITED, d_time)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
 
       write(*,*) 'JDM b'
       ! Define global attributes.
       ncerr = nf90_put_att(fh, NF90_GLOBAL, 'title', IDSTR)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_put_att(fh, NF90_GLOBAL, 'version', VEROPT)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
 
       write(*,*) 'JDM c'
       ! Define scalar variables.
       ncerr = nf90_def_var(fh, VNAME_NK, NF90_INT, v_nk)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_NTH, NF90_INT, v_nth)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
 
       write(*,*) 'JDM d'
       ! Define vars with nopts as a dimension.
       ncerr = nf90_def_var(fh, VNAME_PTLOC, NF90_FLOAT, (/d_vsize, d_nopts/), v_ptloc)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_PTNME, NF90_CHAR, (/d_namelen, d_nopts/), v_ptnme)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_TIME, NF90_INT, (/d_vsize, d_time/),v_time)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_IW, NF90_INT, (/d_nopts, d_time/), v_iw)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_II, NF90_INT, (/d_nopts, d_time/), v_ii)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_IL, NF90_INT, (/d_nopts, d_time/), v_il)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_DPO, NF90_FLOAT, (/d_nopts, d_time/), v_dpo)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_WAO, NF90_FLOAT, (/d_nopts, d_time/), v_wao)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_WDO, NF90_FLOAT, (/d_nopts, d_time/), v_wdo)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
 
 #ifdef W3_FLX5
       ncerr = nf90_def_var(fh, VNAME_TAUAO, NF90_FLOAT, (/d_nopts, d_time/), v_tauao)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_TAIDO, NF90_FLOAT, (/d_nopts, d_time/), v_taido)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_DAIRO, NF90_FLOAT, (/d_nopts, d_time/), v_dairo)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
 #endif    
 #ifdef W3_SETUP
       ncerr = nf90_def_var(fh, VNAME_ZET_SETO, NF90_FLOAT, (/d_nopts, d_time/), v_zet_seto)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
 #endif    
       ncerr = nf90_def_var(fh, VNAME_ASO, NF90_FLOAT, (/d_nopts, d_time/), v_aso)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_CAO, NF90_FLOAT, (/d_nopts, d_time/), v_cao)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_CDO, NF90_FLOAT, (/d_nopts, d_time/), v_cdo)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_ICEO, NF90_FLOAT, (/d_nopts, d_time/), v_iceo)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_ICEHO, NF90_FLOAT, (/d_nopts, d_time/), v_iceho)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_ICEFO, NF90_FLOAT, (/d_nopts, d_time/), v_icefo)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_GRDID, NF90_CHAR, (/d_grdidlen, d_nopts, d_time/), v_grdid)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_SPCO, NF90_FLOAT, (/d_nspec, d_nopts, d_time/), v_spco)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
   
       write(*,*) 'JDM bb'
       ncerr = nf90_enddef(fh)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
 
       write(*,*) 'JDM c'
       ! Write the scalar data.
       ncerr = nf90_put_var(fh, v_nk, NK)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_put_var(fh, v_nth, NTH)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
 
       write(*,*) 'JDM e' 
       ! Write the data with NOPTS as a dimension.
       ncerr = nf90_put_var(fh, v_ptloc, PTLOC)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       ncerr = nf90_put_var(fh, v_ptnme, PTNME)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
       
     ELSE 
       write(*,*) 'JDM else'
       ncerr = nf90_open(filename, nf90_write, fh)
-      if (ncerr .ne. 0) return
+      if (nf90(ncerr) .ne. 0) return
     END IF 
 
      IF ( timestep_only.EQ.1 ) THEN
@@ -1517,11 +1518,11 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
     write(*,*) 'JDM f 0', TIME
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_TIME, v_time)
-       if (ncerr .ne. 0) return
+       if (nf90(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_time, TIME, start = (/ 1, itime/), &
        count = (/ 2, 1 /))
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
 
 
     ! set IW, II and IL to 0 because it is not used and gives &
@@ -1533,163 +1534,163 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
     write(*,*) 'JDM f 1'
     IF ( itime > 1 ) THEN 
        ncerr = nf90_inq_varid(fh, VNAME_IW, v_iw)
-       if (ncerr .ne. 0) return
+       if (nf90(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_iw, IW, start = (/ 1, itime/), &
        count = (/ NOPTS, 1 /))
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     write(*,*) 'IW:', IW 
     write(*,*) 'JDM f 2'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_II, v_ii)
-       if (ncerr .ne. 0) return
+       if (nf90(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_ii, II, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     write(*,*) 'JDM f 3'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_IL, v_il)
-       if (ncerr .ne. 0) return
+       if (nf90(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_il, IL, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     write(*,*) 'JDM f 4'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_DPO, v_dpo)
-       if (ncerr .ne. 0) return
+       if (nf90(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_dpo, DPO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     write(*,*) 'JDM f 5'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_WAO, v_wao)
-       if (ncerr .ne. 0) return
+       if (nf90(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_wao, WAO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
 
     write(*,*) 'JDM f 5b'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_WDO, v_wdo)
-       if (ncerr .ne. 0) return
+       if (nf90(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_wdo, WDO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
 
 
 #ifdef W3_FLX5
     write(*,*) 'JDM f 6'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_TAUAO, v_tauao)
-       if (ncerr .ne. 0) return
+       if (nf90(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_tauao, TAUAO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     write(*,*) 'JDM f 7'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_TAIDO, v_taido)
-       if (ncerr .ne. 0) return
+       if (nf90(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_taido, TAIDO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     write(*,*) 'JDM f 8'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_DAIRO, v_dairo)
-       if (ncerr .ne. 0) return
+       if (nf90(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_dairo, DAIRO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
 #endif
 #ifdef W3_SETUP
     write(*,*) 'JDM f 9'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_ZET_SETO, v_zet_seto)
-       if (ncerr .ne. 0) return
+       if (nf90(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_zet_seto, ZET_SETO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
 #endif
     write(*,*) 'JDM f 10'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_ASO, v_aso)
-       if (ncerr .ne. 0) return
+       if (nf90(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_aso, ASO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     write(*,*) 'JDM f 11'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_CAO, v_cao)
-       if (ncerr .ne. 0) return
+       if (nf90(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_cao, CAO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     write(*,*) 'JDM f 11 b'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_CDO, v_cdo)
-       if (ncerr .ne. 0) return
+       if (nf90(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_cdo, CDO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
 
 
     write(*,*) 'JDM f 12'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_ICEO, v_iceo)
-       if (ncerr .ne. 0) return
+       if (nf90(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_iceo, ICEO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     write(*,*) 'JDM f 13'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_ICEHO, v_iceho)
-       if (ncerr .ne. 0) return
+       if (nf90(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_iceho, ICEHO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     write(*,*) 'JDM f 14'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_ICEFO, v_icefo)
-       if (ncerr .ne. 0) return
+       if (nf90(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_icefo, ICEFO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     write(*,*) 'JDM f 15'
     write(*,*) 'GRDID:',GRDID
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_GRDID, v_grdid)
-       if (ncerr .ne. 0) return
+       if (nf90(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_grdid, GRDID, start = (/ 1, 1, itime/), &
        count = (/ 13, nopts, 1 /))
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
     write(*,*) 'JDM f 16'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_SPCO, v_spco)
-       if (ncerr .ne. 0) return
+       if (nf90(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_spco, SPCO, start = (/ 1, 1, itime/), &
        count = (/nspec, nopts, 1 /))
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
 
     write(*,*) 'JDM g'
     ! Close the file.
     ncerr = nf90_close(fh)
-    if (ncerr .ne. 0) return
+    if (nf90(ncerr) .ne. 0) return
 
   END SUBROUTINE W3IOPON_WRITE
 
@@ -1817,7 +1818,7 @@ SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD &
     ELSE
       CALL W3IOPON_WRITE(OFILES(2), IMOD, filename, ncerr)
     ENDIF
-    if (ncerr .ne. 0) then
+    if (nf90(ncerr) .ne. 0) then
       print *, nf90_strerror(ncerr)
       CALL EXTCDE(21)
     endif

From d3a9b0541515940e689fe4d96ef8e1f79d64aefb Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Fri, 12 Apr 2024 18:04:42 -0600
Subject: [PATCH 095/126] better error handling

---
 model/src/w3iopomd.F90 | 272 ++++++++++++++++++++---------------------
 1 file changed, 134 insertions(+), 138 deletions(-)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index 51927ea6f..0048c471d 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -211,10 +211,6 @@ MODULE W3IOPOMD
   !> Variable name for the netCDF point output file, for SPCO.
   character(*), parameter, private :: VNAME_SPCO = 'SPCO'
 
-  !> Error code returned by netCDF I/O function.
-  integer, parameter, private :: ERROR_NETCDF = 99
-  
-
   !/
 CONTAINS
   !/ ------------------------------------------------------------------- /
@@ -1134,7 +1130,7 @@ integer function nf90_err(errcode)
     
     if(errcode /= nf90_noerr) then
        print *, 'Error: ', trim(nf90_strerror(errcode))
-       nf90 = ERROR_NETCDF
+       nf90 = errcode
        return 
     endif
   end function nf90_err
@@ -1198,43 +1194,43 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
 
       ! Read the dimension information for NOPTS.
       ncerr = nf90_inq_dimid(fh, DNAME_NOPTS, d_nopts)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_inquire_dimension(fh, d_nopts, len = d_nopts_len)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
 
       ! Read the dimension information for NSPEC.
       ncerr = nf90_inq_dimid(fh, DNAME_NSPEC, d_nspec)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_inquire_dimension(fh, d_nspec, len = d_nspec_len)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
 
       ! Read the dimension information for VSIZE.
       ncerr = nf90_inq_dimid(fh, DNAME_VSIZE, d_vsize)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_inquire_dimension(fh, d_vsize, len = d_vsize_len)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
 
       ! Read the dimension information for NAMELEN.
       ncerr = nf90_inq_dimid(fh, DNAME_NAMELEN, d_namelen)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_inquire_dimension(fh, d_namelen, len = d_namelen_len)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
 
       ! Read the dimension information for GRDIDLEN.
       ncerr = nf90_inq_dimid(fh, DNAME_GRDIDLEN, d_grdidlen)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_inquire_dimension(fh, d_grdidlen, len = d_grdidlen_len)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
 
       ! Read scalar variables.
       ncerr = nf90_inq_varid(fh, VNAME_NK, v_nk)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_get_var(fh, v_nk, MK)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_inq_varid(fh, VNAME_NTH, v_nth)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_get_var(fh, v_nth, MTH)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
 
       !read in written variables NK, NTH as MK and MTH
       !and ensure they match 
@@ -1245,16 +1241,16 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
 
       ! Read vars with nopts as a dimension.
       ncerr = nf90_inq_varid(fh, VNAME_PTLOC, v_ptloc)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       if (associated(PTLOC)) then
          ncerr = nf90_get_var(fh, v_ptloc, PTLOC)
-         if (nf90(ncerr) .ne. 0) return
+         if (nf90_err(ncerr) .ne. 0) return
       endif
       ncerr = nf90_inq_varid(fh, VNAME_PTNME, v_ptnme)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       if (associated(PTNME)) then
          ncerr = nf90_get_var(fh, v_ptnme, PTNME)
-         if (nf90(ncerr) .ne. 0) return
+         if (nf90_err(ncerr) .ne. 0) return
       endif
     END IF
 
@@ -1263,85 +1259,85 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
     ! All of the below variables are missing the "time" dimension... 
     ! the time dimension being read should be for "IPASS" 
     ncerr = nf90_inq_varid(fh, VNAME_IW, v_iw)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_iw, IW)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_II, v_ii)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_ii, II)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_IL, v_il)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_il, IL)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_DPO, v_dpo)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_dpo, DPO)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_WAO, v_wao)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_wao, WAO)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_WDO, v_wdo)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_wdo, WDO)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
 #ifdef W3_FLX5
     ncerr = nf90_inq_varid(fh, VNAME_TAUAO, v_tauao)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_tauao, TAUAO)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_TAIDO, v_taido)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_taido, TAIDO)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_DAIRO, v_dairo)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_dairo, DAIRO)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
 #endif
 #ifdef W3_SETUP
     ncerr = nf90_inq_varid(fh, ZET_SETO, v_zet_seto)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_zet_seto, ZET_SETO)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
 #endif
     ncerr = nf90_inq_varid(fh, VNAME_ASO, v_aso)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_aso, ASO)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_CAO, v_cao)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_cao, CAO)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_CDO, v_cdo)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_cdo, CDO)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_ICEO, v_iceo)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_iceo, ICEO)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_ICEHO, v_iceho)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_iceho, ICEHO)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_ICEFO, v_icefo)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_icefo, ICEFO)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_GRDID, v_grdid)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_grdid, GRDID)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_SPCO, v_spco)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_get_var(fh, v_spco, SPCO)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
 
     ! Close the file.
     ncerr = nf90_close(fh)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
 
 902 FORMAT (/' *** WAVEWATCH III ERROR IN W3IOPON :'/               &
          '     ILEGAL IDSTR, READ : ',A/                        &
@@ -1401,109 +1397,109 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
     IF ( IPASS.EQ.1  .OR. timestep_only.EQ.1 ) THEN 
       ! Create the netCDF file.
       ncerr = nf90_create(filename, NF90_NETCDF4, fh)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
  
       write(*,*)'JDM a'
       ! Define dimensions.
       ncerr = nf90_def_dim(fh, DNAME_NOPTS, NOPTS, d_nopts)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_def_dim(fh, DNAME_NSPEC, NSPEC, d_nspec)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_def_dim(fh, DNAME_VSIZE, 2, d_vsize)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_def_dim(fh, DNAME_NAMELEN, 40, d_namelen)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_def_dim(fh, DNAME_GRDIDLEN, 13, d_grdidlen)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_def_dim(fh, DNAME_TIME, NF90_UNLIMITED, d_time)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
 
       write(*,*) 'JDM b'
       ! Define global attributes.
       ncerr = nf90_put_att(fh, NF90_GLOBAL, 'title', IDSTR)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_put_att(fh, NF90_GLOBAL, 'version', VEROPT)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
 
       write(*,*) 'JDM c'
       ! Define scalar variables.
       ncerr = nf90_def_var(fh, VNAME_NK, NF90_INT, v_nk)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_NTH, NF90_INT, v_nth)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
 
       write(*,*) 'JDM d'
       ! Define vars with nopts as a dimension.
       ncerr = nf90_def_var(fh, VNAME_PTLOC, NF90_FLOAT, (/d_vsize, d_nopts/), v_ptloc)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_PTNME, NF90_CHAR, (/d_namelen, d_nopts/), v_ptnme)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_TIME, NF90_INT, (/d_vsize, d_time/),v_time)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_IW, NF90_INT, (/d_nopts, d_time/), v_iw)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_II, NF90_INT, (/d_nopts, d_time/), v_ii)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_IL, NF90_INT, (/d_nopts, d_time/), v_il)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_DPO, NF90_FLOAT, (/d_nopts, d_time/), v_dpo)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_WAO, NF90_FLOAT, (/d_nopts, d_time/), v_wao)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_WDO, NF90_FLOAT, (/d_nopts, d_time/), v_wdo)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
 
 #ifdef W3_FLX5
       ncerr = nf90_def_var(fh, VNAME_TAUAO, NF90_FLOAT, (/d_nopts, d_time/), v_tauao)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_TAIDO, NF90_FLOAT, (/d_nopts, d_time/), v_taido)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_DAIRO, NF90_FLOAT, (/d_nopts, d_time/), v_dairo)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
 #endif    
 #ifdef W3_SETUP
       ncerr = nf90_def_var(fh, VNAME_ZET_SETO, NF90_FLOAT, (/d_nopts, d_time/), v_zet_seto)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
 #endif    
       ncerr = nf90_def_var(fh, VNAME_ASO, NF90_FLOAT, (/d_nopts, d_time/), v_aso)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_CAO, NF90_FLOAT, (/d_nopts, d_time/), v_cao)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_CDO, NF90_FLOAT, (/d_nopts, d_time/), v_cdo)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_ICEO, NF90_FLOAT, (/d_nopts, d_time/), v_iceo)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_ICEHO, NF90_FLOAT, (/d_nopts, d_time/), v_iceho)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_ICEFO, NF90_FLOAT, (/d_nopts, d_time/), v_icefo)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_GRDID, NF90_CHAR, (/d_grdidlen, d_nopts, d_time/), v_grdid)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_SPCO, NF90_FLOAT, (/d_nspec, d_nopts, d_time/), v_spco)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
   
       write(*,*) 'JDM bb'
       ncerr = nf90_enddef(fh)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
 
       write(*,*) 'JDM c'
       ! Write the scalar data.
       ncerr = nf90_put_var(fh, v_nk, NK)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_put_var(fh, v_nth, NTH)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
 
       write(*,*) 'JDM e' 
       ! Write the data with NOPTS as a dimension.
       ncerr = nf90_put_var(fh, v_ptloc, PTLOC)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_put_var(fh, v_ptnme, PTNME)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
       
     ELSE 
       write(*,*) 'JDM else'
       ncerr = nf90_open(filename, nf90_write, fh)
-      if (nf90(ncerr) .ne. 0) return
+      if (nf90_err(ncerr) .ne. 0) return
     END IF 
 
      IF ( timestep_only.EQ.1 ) THEN
@@ -1518,11 +1514,11 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
     write(*,*) 'JDM f 0', TIME
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_TIME, v_time)
-       if (nf90(ncerr) .ne. 0) return
+       if (nf90_err(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_time, TIME, start = (/ 1, itime/), &
        count = (/ 2, 1 /))
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
 
 
     ! set IW, II and IL to 0 because it is not used and gives &
@@ -1534,163 +1530,163 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
     write(*,*) 'JDM f 1'
     IF ( itime > 1 ) THEN 
        ncerr = nf90_inq_varid(fh, VNAME_IW, v_iw)
-       if (nf90(ncerr) .ne. 0) return
+       if (nf90_err(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_iw, IW, start = (/ 1, itime/), &
        count = (/ NOPTS, 1 /))
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     write(*,*) 'IW:', IW 
     write(*,*) 'JDM f 2'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_II, v_ii)
-       if (nf90(ncerr) .ne. 0) return
+       if (nf90_err(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_ii, II, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     write(*,*) 'JDM f 3'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_IL, v_il)
-       if (nf90(ncerr) .ne. 0) return
+       if (nf90_err(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_il, IL, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     write(*,*) 'JDM f 4'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_DPO, v_dpo)
-       if (nf90(ncerr) .ne. 0) return
+       if (nf90_err(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_dpo, DPO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     write(*,*) 'JDM f 5'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_WAO, v_wao)
-       if (nf90(ncerr) .ne. 0) return
+       if (nf90_err(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_wao, WAO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
 
     write(*,*) 'JDM f 5b'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_WDO, v_wdo)
-       if (nf90(ncerr) .ne. 0) return
+       if (nf90_err(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_wdo, WDO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
 
 
 #ifdef W3_FLX5
     write(*,*) 'JDM f 6'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_TAUAO, v_tauao)
-       if (nf90(ncerr) .ne. 0) return
+       if (nf90_err(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_tauao, TAUAO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     write(*,*) 'JDM f 7'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_TAIDO, v_taido)
-       if (nf90(ncerr) .ne. 0) return
+       if (nf90_err(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_taido, TAIDO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     write(*,*) 'JDM f 8'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_DAIRO, v_dairo)
-       if (nf90(ncerr) .ne. 0) return
+       if (nf90_err(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_dairo, DAIRO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
 #endif
 #ifdef W3_SETUP
     write(*,*) 'JDM f 9'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_ZET_SETO, v_zet_seto)
-       if (nf90(ncerr) .ne. 0) return
+       if (nf90_err(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_zet_seto, ZET_SETO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
 #endif
     write(*,*) 'JDM f 10'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_ASO, v_aso)
-       if (nf90(ncerr) .ne. 0) return
+       if (nf90_err(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_aso, ASO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     write(*,*) 'JDM f 11'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_CAO, v_cao)
-       if (nf90(ncerr) .ne. 0) return
+       if (nf90_err(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_cao, CAO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     write(*,*) 'JDM f 11 b'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_CDO, v_cdo)
-       if (nf90(ncerr) .ne. 0) return
+       if (nf90_err(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_cdo, CDO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
 
 
     write(*,*) 'JDM f 12'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_ICEO, v_iceo)
-       if (nf90(ncerr) .ne. 0) return
+       if (nf90_err(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_iceo, ICEO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     write(*,*) 'JDM f 13'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_ICEHO, v_iceho)
-       if (nf90(ncerr) .ne. 0) return
+       if (nf90_err(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_iceho, ICEHO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     write(*,*) 'JDM f 14'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_ICEFO, v_icefo)
-       if (nf90(ncerr) .ne. 0) return
+       if (nf90_err(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_icefo, ICEFO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     write(*,*) 'JDM f 15'
     write(*,*) 'GRDID:',GRDID
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_GRDID, v_grdid)
-       if (nf90(ncerr) .ne. 0) return
+       if (nf90_err(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_grdid, GRDID, start = (/ 1, 1, itime/), &
        count = (/ 13, nopts, 1 /))
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
     write(*,*) 'JDM f 16'
     IF ( itime > 1 ) THEN
        ncerr = nf90_inq_varid(fh, VNAME_SPCO, v_spco)
-       if (nf90(ncerr) .ne. 0) return
+       if (nf90_err(ncerr) .ne. 0) return
     END IF
     ncerr = nf90_put_var(fh, v_spco, SPCO, start = (/ 1, 1, itime/), &
        count = (/nspec, nopts, 1 /))
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
 
     write(*,*) 'JDM g'
     ! Close the file.
     ncerr = nf90_close(fh)
-    if (nf90(ncerr) .ne. 0) return
+    if (nf90_err(ncerr) .ne. 0) return
 
   END SUBROUTINE W3IOPON_WRITE
 
@@ -1818,7 +1814,7 @@ SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD &
     ELSE
       CALL W3IOPON_WRITE(OFILES(2), IMOD, filename, ncerr)
     ENDIF
-    if (nf90(ncerr) .ne. 0) then
+    if (nf90_err(ncerr) .ne. 0) then
       print *, nf90_strerror(ncerr)
       CALL EXTCDE(21)
     endif

From 35fb4e166bcbd0584211c209cfaa7346b648a52c Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Sat, 13 Apr 2024 08:16:02 -0600
Subject: [PATCH 096/126] better error handling

---
 model/src/w3iopomd.F90 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index 0048c471d..f950b4beb 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -1130,7 +1130,7 @@ integer function nf90_err(errcode)
     
     if(errcode /= nf90_noerr) then
        print *, 'Error: ', trim(nf90_strerror(errcode))
-       nf90 = errcode
+       nf90_err = errcode
        return 
     endif
   end function nf90_err

From 1f9e8c8aec2fa9712098092a360b0504e85a0885 Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Sat, 13 Apr 2024 08:26:24 -0600
Subject: [PATCH 097/126] clean up regtest CI, revert change

---
 .github/workflows/regtest_gnu.yml | 6 +++---
 model/src/w3iopomd.F90            | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/regtest_gnu.yml b/.github/workflows/regtest_gnu.yml
index 42d7fe8c1..977a2bddc 100644
--- a/.github/workflows/regtest_gnu.yml
+++ b/.github/workflows/regtest_gnu.yml
@@ -102,10 +102,10 @@ jobs:
           export CC=mpicc
           export FC=mpif90
           export OASISDIR=${GITHUB_WORKSPACE}/work_oasis3-mct
-          mkdir build && cd build
+#          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
+#          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
diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index f950b4beb..fc50e63fb 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -1747,7 +1747,7 @@ SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD &
     IMPLICIT NONE
 
     CHARACTER, INTENT(IN)         :: INXOUT*(*)
-    INTEGER, INTENT(INOUT)           :: NDSOP
+    INTEGER, INTENT(IN)           :: NDSOP
     INTEGER, INTENT(OUT)          :: IOTST
     INTEGER, INTENT(IN), OPTIONAL :: IMOD
 #ifdef W3_ASCII

From c196ee84effa18eaf01f5cbf155c91fd0278b5de Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Sat, 13 Apr 2024 08:57:36 -0600
Subject: [PATCH 098/126] fixed error handling

---
 model/src/w3iopomd.F90 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index fc50e63fb..9ba56ab28 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -1128,9 +1128,9 @@ integer function nf90_err(errcode)
     implicit none
     integer, intent(in) :: errcode
     
+    nf90_err = errcode
     if(errcode /= nf90_noerr) then
        print *, 'Error: ', trim(nf90_strerror(errcode))
-       nf90_err = errcode
        return 
     endif
   end function nf90_err

From 5fe8c3e810d0ed091a590f78c89f209915dc3c8d Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Sat, 13 Apr 2024 09:21:08 -0600
Subject: [PATCH 099/126] fixed comment

---
 model/src/w3iopomd.F90 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index 9ba56ab28..951ca435e 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -1117,7 +1117,7 @@ SUBROUTINE W3IOPE ( A )
     !/
   END SUBROUTINE W3IOPE
 
-  !> Call a netCDF function and handle return code.
+  !> Handle netCDF return code.
   !>
   !> @param errcode NetCDF error code. 0 for no error.
   !>

From 54fb61ea7efe579f844fb59c216718c1d2ff76e4 Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Sat, 13 Apr 2024 10:14:38 -0600
Subject: [PATCH 100/126] cause run_cmake_test to return error if there is an
 error

---
 regtests/bin/run_cmake_test | 1 +
 1 file changed, 1 insertion(+)

diff --git a/regtests/bin/run_cmake_test b/regtests/bin/run_cmake_test
index 07ade5a8b..d6f43f265 100755
--- a/regtests/bin/run_cmake_test
+++ b/regtests/bin/run_cmake_test
@@ -39,6 +39,7 @@ errmsg ()
     shift
   done
   echo "" 2>&1
+  exit 99
 }
 
 # 1.b Usage function

From 4c3030e3d6cedb1a9f9458ee1b1d75bcfb8328a9 Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Sun, 14 Apr 2024 04:20:55 -0600
Subject: [PATCH 101/126] cause run_cmake_test to return error if there is an
 error

---
 regtests/bin/run_cmake_test | 1 -
 1 file changed, 1 deletion(-)

diff --git a/regtests/bin/run_cmake_test b/regtests/bin/run_cmake_test
index d6f43f265..07ade5a8b 100755
--- a/regtests/bin/run_cmake_test
+++ b/regtests/bin/run_cmake_test
@@ -39,7 +39,6 @@ errmsg ()
     shift
   done
   echo "" 2>&1
-  exit 99
 }
 
 # 1.b Usage function

From b092daa2436d26350a4b1ba94792ebffa4ea6ffd Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Sun, 14 Apr 2024 04:42:53 -0600
Subject: [PATCH 102/126] adding test_io3

---
 regtests/unittests/CMakeLists.txt |   1 +
 regtests/unittests/test_io2.F90   |   6 +-
 regtests/unittests/test_io3.F90   | 109 ++++++++++++++++++++++++++++++
 3 files changed, 113 insertions(+), 3 deletions(-)
 create mode 100644 regtests/unittests/test_io3.F90

diff --git a/regtests/unittests/CMakeLists.txt b/regtests/unittests/CMakeLists.txt
index eb5969f08..1d3d81f60 100644
--- a/regtests/unittests/CMakeLists.txt
+++ b/regtests/unittests/CMakeLists.txt
@@ -42,6 +42,7 @@ copy_test_data_2(ww3_grid.inp ww3_grid.inp)
 unit_test(test_io_points_bin)
 unit_test(test_io)
 unit_test(test_io2)
+unit_test(test_io3)
 unit_test(test_io_restart_bin)
 
 
diff --git a/regtests/unittests/test_io2.F90 b/regtests/unittests/test_io2.F90
index bba445458..b7fe5092d 100644
--- a/regtests/unittests/test_io2.F90
+++ b/regtests/unittests/test_io2.F90
@@ -1,7 +1,7 @@
 ! This is a test for model IO for WW3.
 !
 ! Ed Hartnett 10/14/23
-program test_io
+program test_io2
   use w3iopomd
   use w3gdatmd
   use w3wdatmd
@@ -19,7 +19,7 @@ program test_io
   real :: expected_loc_1
   integer :: write_test_file
   
-  print *, 'Testing WW3 netCDF point file code.'
+  print *, 'Testing WW3 netCDF point file code some more.'
 
   ! These are mysterious but have to be called or else the IPASS
   ! variable does not exist and w3iopo() crashes.
@@ -119,5 +119,5 @@ program test_io
   print *, 'OK!'
   
   print *, 'SUCCESS!'
-end program test_io
+end program test_io2
   
diff --git a/regtests/unittests/test_io3.F90 b/regtests/unittests/test_io3.F90
new file mode 100644
index 000000000..0e5a0d015
--- /dev/null
+++ b/regtests/unittests/test_io3.F90
@@ -0,0 +1,109 @@
+! This is a test for model IO for WW3.
+!
+! Ed Hartnett 10/14/23
+program test_io3
+  use w3iopomd
+  use w3gdatmd
+  use w3wdatmd
+  use w3odatmd
+  use w3iogrmd
+  use w3adatmd  
+  implicit none
+  
+  integer, target :: i, j, k, l
+  integer :: ndsop, iotest, imod, ndstst, ierr, ndsbul, ndsm
+  integer :: ndstrc, ntrace
+  real :: m2km
+  character*7 expected_ptnme
+  character*6 my_fmt
+  real :: expected_loc_1
+  integer :: write_test_file
+  
+  print *, 'Testing WW3 netCDF point file code even more.'
+
+  ! These are mysterious but have to be called or else the IPASS
+  ! variable does not exist and w3iopo() crashes.
+  call w3nmod(1, 6, 6)
+  call w3setg(1, 6, 6)
+  call w3ndat(6, 6)
+  call w3setw(1, 6, 6)
+  call w3nout(6, 6)
+  call w3seto(1, 6, 6)
+
+  ndsm   = 20
+  ndsop  = 20
+  ndsbul = 0
+  ndstrc =  6
+  ntrace = 10
+  imod = 1
+
+  ! Create a point output file needed for this test.
+  print *, 'Creating point output test file for this test...'
+  if (write_test_file() .ne. 0) stop 1
+
+  ! 2.  Read model definition file.
+  CALL W3IOGR('READ', NDSM)
+  WRITE (NDSO,920) GNAME
+920 FORMAT ('  Grid name : ',A/)  
+
+  ! Read the file out_pnt.ww3 from the model/tests/data directory.
+  print *, 'OK!'
+  print *, 'Reading the point output test file for this test...'
+  call w3iopo('READ', ndsop, iotest)
+  if (iotest .ne. 0) stop 10
+  close(ndsop)
+
+  ! ! Make sure we got the values we expected.
+  ! if (nopts .ne. 11) stop 11
+  ! expected_loc_1 = 0.0
+  ! do i = 1, nopts
+  !    ! Check ptnme and ptloc arrays.
+  !    print *, ptnme(i), ptloc(1, i), ptloc(2, i)
+  !    if (i .lt. 10) then
+  !       my_fmt = '(a,i1)'
+  !    else
+  !       my_fmt = '(a,i2)'
+  !    endif
+  !    write(fmt = my_fmt, unit=expected_ptnme) 'Point', i
+  !    if (ptnme(i) .ne. expected_ptnme) stop 20
+  !    print *, expected_loc_1
+  !    if (ptloc(1, i) .ne. expected_loc_1) stop 21
+  !    expected_loc_1 = expected_loc_1 + 5000.0
+  !    if (ptloc(2, i) .ne. 0) stop 22
+  ! end do
+
+  print *, 'OK!'
+  print *, 'initializing some data...'
+  ipass2 = 0
+  do i = 1, nopts
+     do j = 1, nspec
+        spco(j, i) = 0.0
+     end do
+  end do
+  
+  print *, 'OK!'
+  print *, 'testing writing the WW3 binary point file in netCDF...'
+
+  ! Write in netCDF.
+  ofiles(2) = 1
+  call w3iopon('WRITE', ndsop, iotest, imod)
+  if (iotest .ne. 0) stop 100
+  print *, 'OK!'
+  
+  ! Another timestep in netCDF.
+  call w3iopon('WRITE', ndsop, iotest, imod)
+  if (iotest .ne. 0) stop 100
+  print *, 'OK!'
+  
+  print *, 'testing reading the WW3 binary point file in netCDF...'
+  ipass2 = 0
+  call w3iopon('READ', ndsop, iotest)
+  print *, iotest
+  if (iotest .ne. 0) stop 100
+  print *, 'OK!'
+
+  print *, 'OK!'
+  
+  print *, 'SUCCESS!'
+end program test_io3
+

From 3aa1eb77e4141ce3d54ae3b8fb3e8054ab82f1d5 Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Sun, 14 Apr 2024 05:35:03 -0600
Subject: [PATCH 103/126] adding time dimension to read

---
 model/src/w3iopomd.F90          | 75 ++++++++++++++++++++++-----------
 regtests/unittests/test_io3.F90 | 33 ++++++++-------
 2 files changed, 67 insertions(+), 41 deletions(-)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index 951ca435e..7a19cb925 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -1258,81 +1258,102 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
 
     ! All of the below variables are missing the "time" dimension... 
     ! the time dimension being read should be for "IPASS" 
-    ncerr = nf90_inq_varid(fh, VNAME_IW, v_iw)
+    ncerr = nf90_inq_varid(fh, VNAME_IW, v_iw, start = (/ 1, ipass/), &
+       count = (/ NOPTS, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_iw, IW)
+    ncerr = nf90_get_var(fh, v_iw, IW, start = (/ 1, ipass/), &
+       count = (/ NOPTS, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_inq_varid(fh, VNAME_II, v_ii)
+    ncerr = nf90_inq_varid(fh, VNAME_II, v_ii, start = (/ 1, ipass/), &
+       count = (/ NOPTS, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_ii, II)
+    ncerr = nf90_get_var(fh, v_ii, II, start = (/ 1, ipass/), &
+       count = (/ NOPTS, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_IL, v_il)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_il, IL)
+    ncerr = nf90_get_var(fh, v_il, IL, start = (/ 1, ipass/), &
+       count = (/ NOPTS, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_DPO, v_dpo)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_dpo, DPO)
+    ncerr = nf90_get_var(fh, v_dpo, DPO, start = (/ 1, ipass/), &
+       count = (/ NOPTS, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_WAO, v_wao)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_wao, WAO)
+    ncerr = nf90_get_var(fh, v_wao, WAO, start = (/ 1, ipass/), &
+       count = (/ NOPTS, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_WDO, v_wdo)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_wdo, WDO)
+    ncerr = nf90_get_var(fh, v_wdo, WDO, start = (/ 1, ipass/), &
+       count = (/ NOPTS, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
 #ifdef W3_FLX5
     ncerr = nf90_inq_varid(fh, VNAME_TAUAO, v_tauao)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_tauao, TAUAO)
+    ncerr = nf90_get_var(fh, v_tauao, TAUAO, start = (/ 1, ipass/), &
+       count = (/ NOPTS, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_TAIDO, v_taido)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_taido, TAIDO)
+    ncerr = nf90_get_var(fh, v_taido, TAIDO, start = (/ 1, ipass/), &
+       count = (/ NOPTS, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_DAIRO, v_dairo)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_dairo, DAIRO)
+    ncerr = nf90_get_var(fh, v_dairo, DAIRO, start = (/ 1, ipass/), &
+       count = (/ NOPTS, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
 #endif
 #ifdef W3_SETUP
     ncerr = nf90_inq_varid(fh, ZET_SETO, v_zet_seto)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_zet_seto, ZET_SETO)
+    ncerr = nf90_get_var(fh, v_zet_seto, ZET_SETO, start = (/ 1, ipass/), &
+       count = (/ NOPTS, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
 #endif
     ncerr = nf90_inq_varid(fh, VNAME_ASO, v_aso)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_aso, ASO)
+    ncerr = nf90_get_var(fh, v_aso, ASO, start = (/ 1, ipass/), &
+       count = (/ NOPTS, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_CAO, v_cao)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_cao, CAO)
+    ncerr = nf90_get_var(fh, v_cao, CAO, start = (/ 1, ipass/), &
+       count = (/ NOPTS, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_CDO, v_cdo)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_cdo, CDO)
+    ncerr = nf90_get_var(fh, v_cdo, CDO, start = (/ 1, ipass/), &
+       count = (/ NOPTS, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_ICEO, v_iceo)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_iceo, ICEO)
+    ncerr = nf90_get_var(fh, v_iceo, ICEO, start = (/ 1, ipass/), &
+       count = (/ NOPTS, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_ICEHO, v_iceho)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_iceho, ICEHO)
+    ncerr = nf90_get_var(fh, v_iceho, ICEHO, start = (/ 1, ipass/), &
+       count = (/ NOPTS, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_ICEFO, v_icefo)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_icefo, ICEFO)
+    ncerr = nf90_get_var(fh, v_icefo, ICEFO, start = (/ 1, ipass/), &
+       count = (/ NOPTS, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_GRDID, v_grdid)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_grdid, GRDID)
+    ncerr = nf90_get_var(fh, v_grdid, GRDID, start = (/ 1, ipass/), &
+       count = (/ NOPTS, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_inq_varid(fh, VNAME_SPCO, v_spco)
+    ncerr = nf90_inq_varid(fh, VNAME_SPCO, v_spco, start = (/ 1, ipass/), &
+       count = (/ NOPTS, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_spco, SPCO)
+    ncerr = nf90_get_var(fh, v_spco, SPCO, start = (/ 1, ipass/), &
+       count = (/ NOPTS, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
 
     ! Close the file.
@@ -1491,10 +1512,14 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
 
       write(*,*) 'JDM e' 
       ! Write the data with NOPTS as a dimension.
-      ncerr = nf90_put_var(fh, v_ptloc, PTLOC)
-      if (nf90_err(ncerr) .ne. 0) return
-      ncerr = nf90_put_var(fh, v_ptnme, PTNME)
-      if (nf90_err(ncerr) .ne. 0) return
+      if (associated(PTLOC)) then
+         ncerr = nf90_put_var(fh, v_ptloc, PTLOC)
+         if (nf90_err(ncerr) .ne. 0) return
+      endif
+      if (associated(PTNME)) then
+         ncerr = nf90_put_var(fh, v_ptnme, PTNME)
+         if (nf90_err(ncerr) .ne. 0) return
+      endif
       
     ELSE 
       write(*,*) 'JDM else'
diff --git a/regtests/unittests/test_io3.F90 b/regtests/unittests/test_io3.F90
index 0e5a0d015..b5f65849c 100644
--- a/regtests/unittests/test_io3.F90
+++ b/regtests/unittests/test_io3.F90
@@ -30,6 +30,7 @@ program test_io3
   call w3nout(6, 6)
   call w3seto(1, 6, 6)
 
+  nth = 4
   ndsm   = 20
   ndsop  = 20
   ndsbul = 0
@@ -37,18 +38,18 @@ program test_io3
   ntrace = 10
   imod = 1
 
-  ! Create a point output file needed for this test.
-  print *, 'Creating point output test file for this test...'
-  if (write_test_file() .ne. 0) stop 1
-
   ! 2.  Read model definition file.
   CALL W3IOGR('READ', NDSM)
   WRITE (NDSO,920) GNAME
-920 FORMAT ('  Grid name : ',A/)  
+920 FORMAT ('  Grid name : ',A/)
+
+  ! Create a point output file needed for this test.
+  print *, 'Creating point output test file for this test...'
+  if (write_test_file() .ne. 0) stop 1
 
   ! Read the file out_pnt.ww3 from the model/tests/data directory.
-  print *, 'OK!'
-  print *, 'Reading the point output test file for this test...'
+  ! print *, 'OK!'
+  ! print *, 'Reading the point output test file for this test...'
   call w3iopo('READ', ndsop, iotest)
   if (iotest .ne. 0) stop 10
   close(ndsop)
@@ -84,16 +85,16 @@ program test_io3
   print *, 'OK!'
   print *, 'testing writing the WW3 binary point file in netCDF...'
 
-  ! Write in netCDF.
-  ofiles(2) = 1
-  call w3iopon('WRITE', ndsop, iotest, imod)
-  if (iotest .ne. 0) stop 100
-  print *, 'OK!'
+  ! ! Write in netCDF.
+  ! ofiles(2) = 1
+  ! call w3iopon('WRITE', ndsop, iotest, imod)
+  ! if (iotest .ne. 0) stop 100
+  ! print *, 'OK!'
   
-  ! Another timestep in netCDF.
-  call w3iopon('WRITE', ndsop, iotest, imod)
-  if (iotest .ne. 0) stop 100
-  print *, 'OK!'
+  ! ! Another timestep in netCDF.
+  ! call w3iopon('WRITE', ndsop, iotest, imod)
+  ! if (iotest .ne. 0) stop 100
+  ! print *, 'OK!'
   
   print *, 'testing reading the WW3 binary point file in netCDF...'
   ipass2 = 0

From 743a0e83e1524980fe176b67af6bde2c50a43ae1 Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Sun, 14 Apr 2024 06:39:33 -0600
Subject: [PATCH 104/126] removing time dimension to read

---
 model/src/w3iopomd.F90 | 63 ++++++++++++++----------------------------
 1 file changed, 21 insertions(+), 42 deletions(-)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index 7a19cb925..6cda60ea4 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -1258,102 +1258,81 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
 
     ! All of the below variables are missing the "time" dimension... 
     ! the time dimension being read should be for "IPASS" 
-    ncerr = nf90_inq_varid(fh, VNAME_IW, v_iw, start = (/ 1, ipass/), &
-       count = (/ NOPTS, 1 /))
+    ncerr = nf90_inq_varid(fh, VNAME_IW, v_iw)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_iw, IW, start = (/ 1, ipass/), &
-       count = (/ NOPTS, 1 /))
+    ncerr = nf90_get_var(fh, v_iw, IW)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_inq_varid(fh, VNAME_II, v_ii, start = (/ 1, ipass/), &
-       count = (/ NOPTS, 1 /))
+    ncerr = nf90_inq_varid(fh, VNAME_II, v_ii)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_ii, II, start = (/ 1, ipass/), &
-       count = (/ NOPTS, 1 /))
+    ncerr = nf90_get_var(fh, v_ii, II)
     if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_IL, v_il)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_il, IL, start = (/ 1, ipass/), &
-       count = (/ NOPTS, 1 /))
+    ncerr = nf90_get_var(fh, v_il, IL)
     if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_DPO, v_dpo)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_dpo, DPO, start = (/ 1, ipass/), &
-       count = (/ NOPTS, 1 /))
+    ncerr = nf90_get_var(fh, v_dpo, DPO)
     if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_WAO, v_wao)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_wao, WAO, start = (/ 1, ipass/), &
-       count = (/ NOPTS, 1 /))
+    ncerr = nf90_get_var(fh, v_wao, WAO)
     if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_WDO, v_wdo)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_wdo, WDO, start = (/ 1, ipass/), &
-       count = (/ NOPTS, 1 /))
+    ncerr = nf90_get_var(fh, v_wdo, WDO)
     if (nf90_err(ncerr) .ne. 0) return
 #ifdef W3_FLX5
     ncerr = nf90_inq_varid(fh, VNAME_TAUAO, v_tauao)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_tauao, TAUAO, start = (/ 1, ipass/), &
-       count = (/ NOPTS, 1 /))
+    ncerr = nf90_get_var(fh, v_tauao, TAUAO)
     if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_TAIDO, v_taido)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_taido, TAIDO, start = (/ 1, ipass/), &
-       count = (/ NOPTS, 1 /))
+    ncerr = nf90_get_var(fh, v_taido, TAIDO)
     if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_DAIRO, v_dairo)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_dairo, DAIRO, start = (/ 1, ipass/), &
-       count = (/ NOPTS, 1 /))
+    ncerr = nf90_get_var(fh, v_dairo, DAIRO)
     if (nf90_err(ncerr) .ne. 0) return
 #endif
 #ifdef W3_SETUP
     ncerr = nf90_inq_varid(fh, ZET_SETO, v_zet_seto)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_zet_seto, ZET_SETO, start = (/ 1, ipass/), &
-       count = (/ NOPTS, 1 /))
+    ncerr = nf90_get_var(fh, v_zet_seto, ZET_SETO)
     if (nf90_err(ncerr) .ne. 0) return
 #endif
     ncerr = nf90_inq_varid(fh, VNAME_ASO, v_aso)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_aso, ASO, start = (/ 1, ipass/), &
-       count = (/ NOPTS, 1 /))
+    ncerr = nf90_get_var(fh, v_aso, ASO)
     if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_CAO, v_cao)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_cao, CAO, start = (/ 1, ipass/), &
-       count = (/ NOPTS, 1 /))
+    ncerr = nf90_get_var(fh, v_cao, CAO)
     if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_CDO, v_cdo)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_cdo, CDO, start = (/ 1, ipass/), &
-       count = (/ NOPTS, 1 /))
+    ncerr = nf90_get_var(fh, v_cdo, CDO)
     if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_ICEO, v_iceo)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_iceo, ICEO, start = (/ 1, ipass/), &
-       count = (/ NOPTS, 1 /))
+    ncerr = nf90_get_var(fh, v_iceo, ICEO)
     if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_ICEHO, v_iceho)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_iceho, ICEHO, start = (/ 1, ipass/), &
-       count = (/ NOPTS, 1 /))
+    ncerr = nf90_get_var(fh, v_iceho, ICEHO)
     if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_ICEFO, v_icefo)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_icefo, ICEFO, start = (/ 1, ipass/), &
-       count = (/ NOPTS, 1 /))
+    ncerr = nf90_get_var(fh, v_icefo, ICEFO)
     if (nf90_err(ncerr) .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_GRDID, v_grdid)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_grdid, GRDID, start = (/ 1, ipass/), &
-       count = (/ NOPTS, 1 /))
+    ncerr = nf90_get_var(fh, v_grdid, GRDID)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_inq_varid(fh, VNAME_SPCO, v_spco, start = (/ 1, ipass/), &
-       count = (/ NOPTS, 1 /))
+    ncerr = nf90_inq_varid(fh, VNAME_SPCO, v_spco)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_spco, SPCO, start = (/ 1, ipass/), &
-       count = (/ NOPTS, 1 /))
+    ncerr = nf90_get_var(fh, v_spco, SPCO)
     if (nf90_err(ncerr) .ne. 0) return
 
     ! Close the file.

From 5b611d60cfd83cec0ff7edbf68b203141403922e Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Sun, 14 Apr 2024 06:47:03 -0600
Subject: [PATCH 105/126] check for associated memory when reading

---
 .github/workflows/io_gnu.yml |   2 +-
 model/src/w3iopomd.F90       | 108 +++++++++++++++++++++++------------
 2 files changed, 73 insertions(+), 37 deletions(-)

diff --git a/.github/workflows/io_gnu.yml b/.github/workflows/io_gnu.yml
index def5a1402..b5ef97402 100644
--- a/.github/workflows/io_gnu.yml
+++ b/.github/workflows/io_gnu.yml
@@ -107,7 +107,7 @@ jobs:
           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
+          mv mod_def.ww3 regtests/unittestso
           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
         
diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index 6cda60ea4..5b7801d9b 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -1260,80 +1260,116 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
     ! the time dimension being read should be for "IPASS" 
     ncerr = nf90_inq_varid(fh, VNAME_IW, v_iw)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_iw, IW)
-    if (nf90_err(ncerr) .ne. 0) return
+    if (associated(IW)) then
+       ncerr = nf90_get_var(fh, v_iw, IW)
+       if (nf90_err(ncerr) .ne. 0) return
+    endif
     ncerr = nf90_inq_varid(fh, VNAME_II, v_ii)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_ii, II)
-    if (nf90_err(ncerr) .ne. 0) return
+    if (associated(II)) then
+       ncerr = nf90_get_var(fh, v_ii, II)
+       if (nf90_err(ncerr) .ne. 0) return
+    endif
     ncerr = nf90_inq_varid(fh, VNAME_IL, v_il)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_il, IL)
-    if (nf90_err(ncerr) .ne. 0) return
+    if (associated(IL)) then
+       ncerr = nf90_get_var(fh, v_il, IL)
+       if (nf90_err(ncerr) .ne. 0) return
+    endif
     ncerr = nf90_inq_varid(fh, VNAME_DPO, v_dpo)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_dpo, DPO)
-    if (nf90_err(ncerr) .ne. 0) return
+    if (associated(DPO)) then
+       ncerr = nf90_get_var(fh, v_dpo, DPO)
+       if (nf90_err(ncerr) .ne. 0) return
+    endif
     ncerr = nf90_inq_varid(fh, VNAME_WAO, v_wao)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_wao, WAO)
-    if (nf90_err(ncerr) .ne. 0) return
+    if (associated(WAO)) then
+       ncerr = nf90_get_var(fh, v_wao, WAO)
+       if (nf90_err(ncerr) .ne. 0) return
+    endif
     ncerr = nf90_inq_varid(fh, VNAME_WDO, v_wdo)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_wdo, WDO)
-    if (nf90_err(ncerr) .ne. 0) return
+    if (associated(WDO)) then
+       ncerr = nf90_get_var(fh, v_wdo, WDO)
+       if (nf90_err(ncerr) .ne. 0) return
+    endif
 #ifdef W3_FLX5
     ncerr = nf90_inq_varid(fh, VNAME_TAUAO, v_tauao)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_tauao, TAUAO)
-    if (nf90_err(ncerr) .ne. 0) return
+    if (associated(TAUAO)) then
+       ncerr = nf90_get_var(fh, v_tauao, TAUAO)
+       if (nf90_err(ncerr) .ne. 0) return
+    endif
     ncerr = nf90_inq_varid(fh, VNAME_TAIDO, v_taido)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_taido, TAIDO)
-    if (nf90_err(ncerr) .ne. 0) return
+    if (associated(TAIDO)) then
+       ncerr = nf90_get_var(fh, v_taido, TAIDO)
+       if (nf90_err(ncerr) .ne. 0) return
+    endif
     ncerr = nf90_inq_varid(fh, VNAME_DAIRO, v_dairo)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_dairo, DAIRO)
-    if (nf90_err(ncerr) .ne. 0) return
+    if (associated(DAIRO)) then
+       ncerr = nf90_get_var(fh, v_dairo, DAIRO)
+       if (nf90_err(ncerr) .ne. 0) return
+    endif
 #endif
 #ifdef W3_SETUP
     ncerr = nf90_inq_varid(fh, ZET_SETO, v_zet_seto)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_zet_seto, ZET_SETO)
-    if (nf90_err(ncerr) .ne. 0) return
+    if (associated(ZET_SETO)) then
+       ncerr = nf90_get_var(fh, v_zet_seto, ZET_SETO)
+       if (nf90_err(ncerr) .ne. 0) return
+    endif
 #endif
     ncerr = nf90_inq_varid(fh, VNAME_ASO, v_aso)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_aso, ASO)
-    if (nf90_err(ncerr) .ne. 0) return
+    if (associated(ASO)) then
+       ncerr = nf90_get_var(fh, v_aso, ASO)
+       if (nf90_err(ncerr) .ne. 0) return
+    endif
     ncerr = nf90_inq_varid(fh, VNAME_CAO, v_cao)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_cao, CAO)
-    if (nf90_err(ncerr) .ne. 0) return
+    if (associated(CAO)) then
+       ncerr = nf90_get_var(fh, v_cao, CAO)
+       if (nf90_err(ncerr) .ne. 0) return
+    endif
     ncerr = nf90_inq_varid(fh, VNAME_CDO, v_cdo)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_cdo, CDO)
-    if (nf90_err(ncerr) .ne. 0) return
+    if (associated(CDO)) then
+       ncerr = nf90_get_var(fh, v_cdo, CDO)
+       if (nf90_err(ncerr) .ne. 0) return
+    endif
     ncerr = nf90_inq_varid(fh, VNAME_ICEO, v_iceo)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_iceo, ICEO)
-    if (nf90_err(ncerr) .ne. 0) return
+    if (associated(ICEO)) then
+       ncerr = nf90_get_var(fh, v_iceo, ICEO)
+       if (nf90_err(ncerr) .ne. 0) return
+    endif
     ncerr = nf90_inq_varid(fh, VNAME_ICEHO, v_iceho)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_iceho, ICEHO)
-    if (nf90_err(ncerr) .ne. 0) return
+    if (associated(ICEHO)) then
+       ncerr = nf90_get_var(fh, v_iceho, ICEHO)
+       if (nf90_err(ncerr) .ne. 0) return
+    endif
     ncerr = nf90_inq_varid(fh, VNAME_ICEFO, v_icefo)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_icefo, ICEFO)
-    if (nf90_err(ncerr) .ne. 0) return
+    if (associated(ICEFO)) then
+       ncerr = nf90_get_var(fh, v_icefo, ICEFO)
+       if (nf90_err(ncerr) .ne. 0) return
+    endif
     ncerr = nf90_inq_varid(fh, VNAME_GRDID, v_grdid)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_grdid, GRDID)
-    if (nf90_err(ncerr) .ne. 0) return
+    if (associated(GRDID)) then
+       ncerr = nf90_get_var(fh, v_grdid, GRDID)
+       if (nf90_err(ncerr) .ne. 0) return
+    endif
     ncerr = nf90_inq_varid(fh, VNAME_SPCO, v_spco)
     if (nf90_err(ncerr) .ne. 0) return
-    ncerr = nf90_get_var(fh, v_spco, SPCO)
-    if (nf90_err(ncerr) .ne. 0) return
+    if (associated(SPCO)) then
+       ncerr = nf90_get_var(fh, v_spco, SPCO)
+       if (nf90_err(ncerr) .ne. 0) return
+    endif
 
     ! Close the file.
     ncerr = nf90_close(fh)

From a816d941bd3c45fcaa4d9ffdc7b5dce889f6550a Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Mon, 15 Apr 2024 06:39:47 -0600
Subject: [PATCH 106/126] initializing point data arrays on read

---
 model/src/w3iopomd.F90 | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index 5b7801d9b..b416b5aae 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -1151,7 +1151,7 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
     USE W3ODATMD, ONLY: NDST, NDSE, IPASS => IPASS2, NOPTS, IPTINT, &
          IL, IW, II, PTLOC, PTIFAC, DPO, WAO, WDO,   &
          ASO, CAO, CDO, SPCO, PTNME, O2INIT, FNMPRE, &
-         GRDID, ICEO, ICEHO, ICEFO
+         GRDID, ICEO, ICEHO, ICEFO, W3DMO2
     USE W3SERVMD, ONLY: EXTCDE
 #ifdef W3_FLX5
     USE W3ODATMD, ONLY: TAUAO, TAUDO, DAIRO
@@ -1197,6 +1197,7 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
       if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_inquire_dimension(fh, d_nopts, len = d_nopts_len)
       if (nf90_err(ncerr) .ne. 0) return
+      nopts = d_nopts_len
 
       ! Read the dimension information for NSPEC.
       ncerr = nf90_inq_dimid(fh, DNAME_NSPEC, d_nspec)
@@ -1239,6 +1240,9 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
         CALL EXTCDE ( 12 )
       END IF
 
+      ! Initialize an individual data storage for point output.
+      if (.not. o2init) call w3dmo2(imod, ndse, ndst, nopts)
+
       ! Read vars with nopts as a dimension.
       ncerr = nf90_inq_varid(fh, VNAME_PTLOC, v_ptloc)
       if (nf90_err(ncerr) .ne. 0) return
@@ -1865,8 +1869,8 @@ SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD &
 
 900 FORMAT (/' *** WAVEWATCH III ERROR IN W3IOPO :'/                &
          '     ILEGAL INXOUT VALUE: ',A/)
-901 FORMAT (/' *** WAVEWATCH III ERROR IN W3IOPO :'/                &
-         '     MIXED READ/WRITE, LAST REQUEST: ',A/)
+! 901 FORMAT (/' *** WAVEWATCH III ERROR IN W3IOPO :'/                &
+!          '     MIXED READ/WRITE, LAST REQUEST: ',A/)
   END SUBROUTINE W3IOPON
 
   !/ ------------------------------------------------------------------- /

From 4a2c184e07689e413828ad04d34d0ad4a79e736e Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Mon, 15 Apr 2024 07:20:51 -0600
Subject: [PATCH 107/126] more changes

---
 model/src/w3iopomd.F90 | 152 ++++++++++++++++++++++-------------------
 1 file changed, 80 insertions(+), 72 deletions(-)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index b416b5aae..7c1cbd634 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -1145,7 +1145,7 @@ end function nf90_err
   !>
   !> @author Edward Hartnett  @date 1-Nov-2023
   !>
-  SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
+  SUBROUTINE W3IOPON_READ(IOTST, IMOD_IN, filename, ncerr)
     USE NetCDF
     USE W3GDATMD, ONLY: NTH, NK, NSPEC, FILEXT
     USE W3ODATMD, ONLY: NDST, NDSE, IPASS => IPASS2, NOPTS, IPTINT, &
@@ -1162,7 +1162,7 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
     IMPLICIT NONE
 
     INTEGER, INTENT(OUT)          :: IOTST
-    INTEGER, INTENT(IN), OPTIONAL :: IMOD
+    INTEGER, INTENT(IN), OPTIONAL :: IMOD_IN
     character(*), intent(in) :: filename
     integer, intent(inout) :: ncerr
     INTEGER :: MK,MTH
@@ -1173,91 +1173,99 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
     integer :: v_iw, v_ii, v_il, v_dpo, v_wao, v_wdo, v_tauao
     integer :: v_taido, v_dairo, v_zet_seto, v_aso, v_cao, v_cdo, v_iceo
     integer :: v_iceho, v_icefo, v_grdid, v_spco
+    integer :: imod
+
+    if (present(IMOD_IN)) then
+       imod = imod_in
+    else
+       imod = 1
+    endif
 
     IOTST = 0
-    IF ( IPASS.EQ.1 ) THEN 
-      ! Open the netCDF file.
-      ncerr = nf90_open(filename, NF90_NOWRITE, fh)
-      if (nf90_err(ncerr) .ne. 0) return
 
-      ! Read and check the version: 
-      ! TO DO add reading of IDTST and VERTST and make checks: 
-      !  IF ( IDTST .NE. IDSTR ) THEN
-      !    WRITE (NDSE,902) IDTST, IDSTR
-      !    CALL EXTCDE ( 10 )
-      !  END IF
-      !  IF ( VERTST .NE. VEROPT ) THEN
-      !    WRITE (NDSE,903) VERTST, VEROPT
-      !    CALL EXTCDE ( 11 )
-      !  END IF
+    print *, 'w3iopon_read'
 
+    ! Open the netCDF file.
+    ncerr = nf90_open(filename, NF90_NOWRITE, fh)
+    if (nf90_err(ncerr) .ne. 0) return
 
-      ! Read the dimension information for NOPTS.
-      ncerr = nf90_inq_dimid(fh, DNAME_NOPTS, d_nopts)
-      if (nf90_err(ncerr) .ne. 0) return
-      ncerr = nf90_inquire_dimension(fh, d_nopts, len = d_nopts_len)
-      if (nf90_err(ncerr) .ne. 0) return
-      nopts = d_nopts_len
+    ! Read and check the version: 
+    ! TO DO add reading of IDTST and VERTST and make checks: 
+    !  IF ( IDTST .NE. IDSTR ) THEN
+    !    WRITE (NDSE,902) IDTST, IDSTR
+    !    CALL EXTCDE ( 10 )
+    !  END IF
+    !  IF ( VERTST .NE. VEROPT ) THEN
+    !    WRITE (NDSE,903) VERTST, VEROPT
+    !    CALL EXTCDE ( 11 )
+    !  END IF
 
-      ! Read the dimension information for NSPEC.
-      ncerr = nf90_inq_dimid(fh, DNAME_NSPEC, d_nspec)
-      if (nf90_err(ncerr) .ne. 0) return
-      ncerr = nf90_inquire_dimension(fh, d_nspec, len = d_nspec_len)
-      if (nf90_err(ncerr) .ne. 0) return
 
-      ! Read the dimension information for VSIZE.
-      ncerr = nf90_inq_dimid(fh, DNAME_VSIZE, d_vsize)
-      if (nf90_err(ncerr) .ne. 0) return
-      ncerr = nf90_inquire_dimension(fh, d_vsize, len = d_vsize_len)
-      if (nf90_err(ncerr) .ne. 0) return
+    ! Read the dimension information for NOPTS.
+    ncerr = nf90_inq_dimid(fh, DNAME_NOPTS, d_nopts)
+    if (nf90_err(ncerr) .ne. 0) return
+    ncerr = nf90_inquire_dimension(fh, d_nopts, len = d_nopts_len)
+    if (nf90_err(ncerr) .ne. 0) return
+    nopts = d_nopts_len
 
-      ! Read the dimension information for NAMELEN.
-      ncerr = nf90_inq_dimid(fh, DNAME_NAMELEN, d_namelen)
-      if (nf90_err(ncerr) .ne. 0) return
-      ncerr = nf90_inquire_dimension(fh, d_namelen, len = d_namelen_len)
-      if (nf90_err(ncerr) .ne. 0) return
+    ! Read the dimension information for NSPEC.
+    ncerr = nf90_inq_dimid(fh, DNAME_NSPEC, d_nspec)
+    if (nf90_err(ncerr) .ne. 0) return
+    ncerr = nf90_inquire_dimension(fh, d_nspec, len = d_nspec_len)
+    if (nf90_err(ncerr) .ne. 0) return
 
-      ! Read the dimension information for GRDIDLEN.
-      ncerr = nf90_inq_dimid(fh, DNAME_GRDIDLEN, d_grdidlen)
-      if (nf90_err(ncerr) .ne. 0) return
-      ncerr = nf90_inquire_dimension(fh, d_grdidlen, len = d_grdidlen_len)
-      if (nf90_err(ncerr) .ne. 0) return
+    ! Read the dimension information for VSIZE.
+    ncerr = nf90_inq_dimid(fh, DNAME_VSIZE, d_vsize)
+    if (nf90_err(ncerr) .ne. 0) return
+    ncerr = nf90_inquire_dimension(fh, d_vsize, len = d_vsize_len)
+    if (nf90_err(ncerr) .ne. 0) return
 
-      ! Read scalar variables.
-      ncerr = nf90_inq_varid(fh, VNAME_NK, v_nk)
-      if (nf90_err(ncerr) .ne. 0) return
-      ncerr = nf90_get_var(fh, v_nk, MK)
-      if (nf90_err(ncerr) .ne. 0) return
-      ncerr = nf90_inq_varid(fh, VNAME_NTH, v_nth)
-      if (nf90_err(ncerr) .ne. 0) return
-      ncerr = nf90_get_var(fh, v_nth, MTH)
-      if (nf90_err(ncerr) .ne. 0) return
+    ! Read the dimension information for NAMELEN.
+    ncerr = nf90_inq_dimid(fh, DNAME_NAMELEN, d_namelen)
+    if (nf90_err(ncerr) .ne. 0) return
+    ncerr = nf90_inquire_dimension(fh, d_namelen, len = d_namelen_len)
+    if (nf90_err(ncerr) .ne. 0) return
 
-      !read in written variables NK, NTH as MK and MTH
-      !and ensure they match 
-      IF (NK.NE.MK .OR. NTH.NE.MTH) THEN
-        WRITE (NDSE,904) MK, MTH, NK, NTH
-        CALL EXTCDE ( 12 )
-      END IF
+    ! Read the dimension information for GRDIDLEN.
+    ncerr = nf90_inq_dimid(fh, DNAME_GRDIDLEN, d_grdidlen)
+    if (nf90_err(ncerr) .ne. 0) return
+    ncerr = nf90_inquire_dimension(fh, d_grdidlen, len = d_grdidlen_len)
+    if (nf90_err(ncerr) .ne. 0) return
 
-      ! Initialize an individual data storage for point output.
-      if (.not. o2init) call w3dmo2(imod, ndse, ndst, nopts)
+    ! Read scalar variables.
+    ncerr = nf90_inq_varid(fh, VNAME_NK, v_nk)
+    if (nf90_err(ncerr) .ne. 0) return
+    ncerr = nf90_get_var(fh, v_nk, MK)
+    if (nf90_err(ncerr) .ne. 0) return
+    ncerr = nf90_inq_varid(fh, VNAME_NTH, v_nth)
+    if (nf90_err(ncerr) .ne. 0) return
+    ncerr = nf90_get_var(fh, v_nth, MTH)
+    if (nf90_err(ncerr) .ne. 0) return
 
-      ! Read vars with nopts as a dimension.
-      ncerr = nf90_inq_varid(fh, VNAME_PTLOC, v_ptloc)
-      if (nf90_err(ncerr) .ne. 0) return
-      if (associated(PTLOC)) then
-         ncerr = nf90_get_var(fh, v_ptloc, PTLOC)
-         if (nf90_err(ncerr) .ne. 0) return
-      endif
-      ncerr = nf90_inq_varid(fh, VNAME_PTNME, v_ptnme)
-      if (nf90_err(ncerr) .ne. 0) return
-      if (associated(PTNME)) then
-         ncerr = nf90_get_var(fh, v_ptnme, PTNME)
-         if (nf90_err(ncerr) .ne. 0) return
-      endif
+    !read in written variables NK, NTH as MK and MTH
+    !and ensure they match 
+    IF (NK.NE.MK .OR. NTH.NE.MTH) THEN
+       WRITE (NDSE,904) MK, MTH, NK, NTH
+       CALL EXTCDE ( 12 )
     END IF
 
+    ! Initialize an individual data storage for point output.
+    if (.not. o2init) call w3dmo2(imod, ndse, ndst, nopts)
+
+    ! Read vars with nopts as a dimension.
+    ncerr = nf90_inq_varid(fh, VNAME_PTLOC, v_ptloc)
+    if (nf90_err(ncerr) .ne. 0) return
+    if (associated(PTLOC)) then
+       ncerr = nf90_get_var(fh, v_ptloc, PTLOC)
+       if (nf90_err(ncerr) .ne. 0) return
+    endif
+    ncerr = nf90_inq_varid(fh, VNAME_PTNME, v_ptnme)
+    if (nf90_err(ncerr) .ne. 0) return
+    if (associated(PTNME)) then
+       ncerr = nf90_get_var(fh, v_ptnme, PTNME)
+       if (nf90_err(ncerr) .ne. 0) return
+    endif
+
     !missing variable TIME??? 
 
     ! All of the below variables are missing the "time" dimension... 

From 7d9894f01ed5db8dcb30844c530816f4214e730f Mon Sep 17 00:00:00 2001
From: JessicaMeixner-NOAA 
Date: Mon, 15 Apr 2024 16:05:37 -0500
Subject: [PATCH 108/126] successfully reading in variables now!

---
 model/src/w3iopomd.F90 | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index 63e76c169..aef1b5b6e 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -1129,6 +1129,7 @@ END SUBROUTINE W3IOPE
   !>
   SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
     USE NetCDF
+    USE W3ODATMD, ONLY: W3DMO2
     USE W3GDATMD, ONLY: NTH, NK, NSPEC, FILEXT
     USE W3ODATMD, ONLY: NDST, NDSE, IPASS => IPASS2, NOPTS, IPTINT, &
          IL, IW, II, PTLOC, PTIFAC, DPO, WAO, WDO,   &
@@ -1147,7 +1148,7 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
     INTEGER, INTENT(IN), OPTIONAL :: IMOD
     character(*), intent(in) :: filename
     integer, intent(inout) :: ncerr
-    INTEGER :: MK,MTH
+    INTEGER :: IGRD,MK,MTH
     integer :: fh
     integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen
     integer :: d_nopts_len, d_nspec_len, d_vsize_len, d_namelen_len, d_grdidlen_len
@@ -1159,6 +1160,13 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
 
     IOTST = 0
 
+    IF (PRESENT(IMOD)) THEN
+      IGRD = IMOD
+    ELSE
+      IGRD = 1
+    END IF
+
+
     ! Open the netCDF file.
     ncerr = nf90_open(filename, NF90_NOWRITE, fh)
     if (ncerr .ne. 0) return
@@ -1181,6 +1189,7 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
     if (ncerr .ne. 0) return
     ncerr = nf90_inquire_dimension(fh, d_nopts, len = d_nopts_len)
     if (ncerr .ne. 0) return
+    NOPTS=d_nopts_len
 
     ! Read the dimension information for NSPEC.
     ncerr = nf90_inq_dimid(fh, DNAME_NSPEC, d_nspec)
@@ -1225,10 +1234,15 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
         CALL EXTCDE ( 12 )
       END IF
 
+      !JDM TO DO: Missing check and reading of IDSTR, VEROPT 
+
       !check reading: 
       write(*,*) 'MK,MTH', MK, MTH
       write(*,*) 'dimensions:', d_nopts_len,d_grdidlen_len, d_namelen_len,d_vsize_len,d_nspec_len
 
+      ! Allocate variables: 
+      IF ( .NOT. O2INIT )                                     &
+             CALL W3DMO2 ( IGRD, NDSE, NDST, NOPTS )
 
       ! Read vars with nopts as a dimension.
       ncerr = nf90_inq_varid(fh, VNAME_PTLOC, v_ptloc)
@@ -1240,11 +1254,11 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
       ncerr = nf90_inq_varid(fh, VNAME_PTNME, v_ptnme)
       if (ncerr .ne. 0) return
       !code segfaults reading this, skipping for now to see other issues
-      !ncerr = nf90_get_var(fh, v_ptnme, PTNME)
-      !if (ncerr .ne. 0) return
+      ncerr = nf90_get_var(fh, v_ptnme, PTNME)
+      if (ncerr .ne. 0) return
     END IF
 
-    !missing variable TIME??? 
+    !JDM TO DO missing variable TIME??? 
 
     ! All of the below variables are missing the "time" dimension... 
     ! the time dimension being read should be for "IPASS" 

From a5dad0b23000e80cb85484acef2534851c029b52 Mon Sep 17 00:00:00 2001
From: JessicaMeixner-NOAA 
Date: Mon, 15 Apr 2024 20:10:20 -0500
Subject: [PATCH 109/126] update read for time

---
 model/src/w3iopomd.F90 | 85 ++++++++++++++++++++++++------------------
 1 file changed, 49 insertions(+), 36 deletions(-)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index aef1b5b6e..7c7300bf7 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -1130,6 +1130,7 @@ END SUBROUTINE W3IOPE
   SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
     USE NetCDF
     USE W3ODATMD, ONLY: W3DMO2
+    USE W3WDATMD, ONLY: TIME
     USE W3GDATMD, ONLY: NTH, NK, NSPEC, FILEXT
     USE W3ODATMD, ONLY: NDST, NDSE, IPASS => IPASS2, NOPTS, IPTINT, &
          IL, IW, II, PTLOC, PTIFAC, DPO, WAO, WDO,   &
@@ -1152,7 +1153,7 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
     integer :: fh
     integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen
     integer :: d_nopts_len, d_nspec_len, d_vsize_len, d_namelen_len, d_grdidlen_len
-    integer :: v_idtst, v_vertst, v_nk, v_nth, v_ptloc, v_ptnme
+    integer :: v_idtst, v_vertst, v_nk, v_nth, v_ptloc, v_ptnme, v_time
     integer :: v_iw, v_ii, v_il, v_dpo, v_wao, v_wdo, v_tauao
     integer :: v_taido, v_dairo, v_zet_seto, v_aso, v_cao, v_cdo, v_iceo
     integer :: v_iceho, v_icefo, v_grdid, v_spco
@@ -1253,104 +1254,117 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
       write(*,*) 'PTLOC', PTLOC
       ncerr = nf90_inq_varid(fh, VNAME_PTNME, v_ptnme)
       if (ncerr .ne. 0) return
-      !code segfaults reading this, skipping for now to see other issues
       ncerr = nf90_get_var(fh, v_ptnme, PTNME)
       if (ncerr .ne. 0) return
     END IF
-
+    write(*,*) 'IPASS=', IPASS
     !JDM TO DO missing variable TIME??? 
+    ncerr = nf90_inq_varid(fh, VNAME_TIME, v_time)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_get_var(fh, v_time, TIME, start = (/ 1, IPASS/), &
+       count = (/ d_vsize_len, 1 /))
+    if (ncerr .ne. 0) return
+    write(*,*) 'TIME', TIME
+    !JDM TO DO!! need to find out if IPASS is a valid time value, if not set flag to -1
+    !and exit
+
 
     ! All of the below variables are missing the "time" dimension... 
     ! the time dimension being read should be for "IPASS" 
     ncerr = nf90_inq_varid(fh, VNAME_IW, v_iw)
     if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_iw, IW)
-    write(*,*) 'IW', IW 
+    ncerr = nf90_get_var(fh, v_iw, IW, start = (/ 1, IPASS/), &
+       count = (/ NOPTS, 1 /))
     if (ncerr .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_II, v_ii)
     if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_ii, II)
+    ncerr = nf90_get_var(fh, v_ii, II, start = (/ 1, IPASS/), &
+       count = (/ NOPTS, 1 /))
     if (ncerr .ne. 0) return
-    !wite(*,*) 'JDM II:', II
     ncerr = nf90_inq_varid(fh, VNAME_IL, v_il)
     if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_il, IL)
+    ncerr = nf90_get_var(fh, v_il, IL, start = (/ 1, IPASS/), &
+       count = (/ NOPTS, 1 /))
     if (ncerr .ne. 0) return
-    write(*,*) 'IL', IL
     ncerr = nf90_inq_varid(fh, VNAME_DPO, v_dpo)
     if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_dpo, DPO)
+    ncerr = nf90_get_var(fh, v_dpo, DPO, start = (/ 1, IPASS/), &
+       count = (/ NOPTS, 1 /))
     if (ncerr .ne. 0) return
-    write(*,*) 'DPO', DPO
     ncerr = nf90_inq_varid(fh, VNAME_WAO, v_wao)
     if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_wao, WAO)
-    write(*,*) 'WAO', WAO
+    ncerr = nf90_get_var(fh, v_wao, WAO, start = (/ 1, IPASS/), &
+       count = (/ NOPTS, 1 /))
     if (ncerr .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_WDO, v_wdo)
     if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_wdo, WDO)
+    ncerr = nf90_get_var(fh, v_wdo, WDO, start = (/ 1, IPASS/), &
+       count = (/ NOPTS, 1 /))
     if (ncerr .ne. 0) return
-    write(*,*) 'WDO', WDO 
 #ifdef W3_FLX5
     ncerr = nf90_inq_varid(fh, VNAME_TAUAO, v_tauao)
     if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_tauao, TAUAO)
+    ncerr = nf90_get_var(fh, v_tauao, TAUAO, start = (/ 1, IPASS/), &
+       count = (/ NOPTS, 1 /))
     if (ncerr .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_TAIDO, v_taido)
     if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_taido, TAIDO)
+    ncerr = nf90_get_var(fh, v_taido, TAIDO, start = (/ 1, IPASS/), &
+       count = (/ NOPTS, 1 /))
     if (ncerr .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_DAIRO, v_dairo)
     if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_dairo, DAIRO)
+    ncerr = nf90_get_var(fh, v_dairo, DAIRO, start = (/ 1, IPASS/), &
+       count = (/ NOPTS, 1 /))
     if (ncerr .ne. 0) return
 #endif
 #ifdef W3_SETUP
     ncerr = nf90_inq_varid(fh, ZET_SETO, v_zet_seto)
     if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_zet_seto, ZET_SETO)
+    ncerr = nf90_get_var(fh, v_zet_seto, ZET_SETO, start = (/ 1, IPASS/), &
+       count = (/ NOPTS, 1 /))
     if (ncerr .ne. 0) return
 #endif
     ncerr = nf90_inq_varid(fh, VNAME_ASO, v_aso)
     if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_aso, ASO)
+    ncerr = nf90_get_var(fh, v_aso, ASO, start = (/ 1, IPASS/), &
+       count = (/ NOPTS, 1 /))
     if (ncerr .ne. 0) return
-    write(*,*) 'ASO', ASO
     ncerr = nf90_inq_varid(fh, VNAME_CAO, v_cao)
     if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_cao, CAO)
+    ncerr = nf90_get_var(fh, v_cao, CAO, start = (/ 1, IPASS/), &
+       count = (/ NOPTS, 1 /))
     if (ncerr .ne. 0) return
-    write(*,*) 'CAO', CAO
     ncerr = nf90_inq_varid(fh, VNAME_CDO, v_cdo)
     if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_cdo, CDO)
+    ncerr = nf90_get_var(fh, v_cdo, CDO, start = (/ 1, IPASS/), &
+       count = (/ NOPTS, 1 /))
     if (ncerr .ne. 0) return
-    write(*,*) 'CDO', CDO
     ncerr = nf90_inq_varid(fh, VNAME_ICEO, v_iceo)
     if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_iceo, ICEO)
+    ncerr = nf90_get_var(fh, v_iceo, ICEO, start = (/ 1, IPASS/), &
+       count = (/ NOPTS, 1 /))
     if (ncerr .ne. 0) return
-    write(*,*) 'ICEO', ICEO
     ncerr = nf90_inq_varid(fh, VNAME_ICEHO, v_iceho)
     if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_iceho, ICEHO)
+    ncerr = nf90_get_var(fh, v_iceho, ICEHO, start = (/ 1, IPASS/), &
+       count = (/ NOPTS, 1 /))
     if (ncerr .ne. 0) return
-    write(*,*) 'ICEHO', ICEHO
     ncerr = nf90_inq_varid(fh, VNAME_ICEFO, v_icefo)
     if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_icefo, ICEFO)
+    ncerr = nf90_get_var(fh, v_icefo, ICEFO, start = (/ 1, IPASS/), &
+       count = (/ NOPTS, 1 /))
     if (ncerr .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_GRDID, v_grdid)
     if (ncerr .ne. 0) return
-    !skipping because we get a segfault
-    !ncerr = nf90_get_var(fh, v_grdid, GRDID)
-    !if (ncerr .ne. 0) return
+    ncerr = nf90_get_var(fh, v_grdid, GRDID, start = (/ 1, 1, IPASS/), &
+       count = (/ 13, nopts, 1 /))
+    if (ncerr .ne. 0) return
     ncerr = nf90_inq_varid(fh, VNAME_SPCO, v_spco)
     if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_spco, SPCO)
+    ncerr = nf90_get_var(fh, v_spco, SPCO, start = (/ 1, 1, IPASS/), &
+       count = (/nspec, nopts, 1 /))
     if (ncerr .ne. 0) return
-    write(*,*) 'SPCO', SPCO 
 
     ! Close the file.
     ncerr = nf90_close(fh)
@@ -2207,7 +2221,6 @@ SUBROUTINE W3IOPO ( INXOUT, NDSOP, IOTST, IMOD &
           WRITE (NDSE,904) MK, MTH, NK, NTH
           CALL EXTCDE ( 12 )
         END IF
-        !JDM: what is this???? 
         IF ( .NOT. O2INIT )                                     &
              CALL W3DMO2 ( IGRD, NDSE, NDST, NOPTS )
       END IF

From 99f9e85a0596f9fe66896078e94d369fb8544cc2 Mon Sep 17 00:00:00 2001
From: Edward Hartnett 
Date: Tue, 16 Apr 2024 06:25:35 -0600
Subject: [PATCH 110/126] fixed inadvertant change

---
 .github/workflows/io_gnu.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/io_gnu.yml b/.github/workflows/io_gnu.yml
index b5ef97402..def5a1402 100644
--- a/.github/workflows/io_gnu.yml
+++ b/.github/workflows/io_gnu.yml
@@ -107,7 +107,7 @@ jobs:
           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/unittestso
+          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
         

From 8fdf76f5f9950b9ec9881e702b9e98c8714deb5c Mon Sep 17 00:00:00 2001
From: JessicaMeixner-NOAA 
Date: Tue, 16 Apr 2024 07:53:38 -0500
Subject: [PATCH 111/126] add a flag to stop at end of file for netcdf point
 read

---
 model/src/w3iopomd.F90 | 285 +++++++++++++++++++++--------------------
 1 file changed, 148 insertions(+), 137 deletions(-)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index 7c7300bf7..2c873baa9 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -1151,8 +1151,8 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
     integer, intent(inout) :: ncerr
     INTEGER :: IGRD,MK,MTH
     integer :: fh
-    integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen
-    integer :: d_nopts_len, d_nspec_len, d_vsize_len, d_namelen_len, d_grdidlen_len
+    integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen, d_time
+    integer :: d_nopts_len, d_nspec_len, d_vsize_len, d_namelen_len, d_grdidlen_len, d_time_len
     integer :: v_idtst, v_vertst, v_nk, v_nth, v_ptloc, v_ptnme, v_time
     integer :: v_iw, v_ii, v_il, v_dpo, v_wao, v_wdo, v_tauao
     integer :: v_taido, v_dairo, v_zet_seto, v_aso, v_cao, v_cdo, v_iceo
@@ -1216,155 +1216,166 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
     ncerr = nf90_inquire_dimension(fh, d_grdidlen, len = d_grdidlen_len)
     if (ncerr .ne. 0) return
 
-    IF ( IPASS.EQ.1 ) THEN
+    ! Read the dimention information from time
 
-      ! Read scalar variables.
-      ncerr = nf90_inq_varid(fh, VNAME_NK, v_nk)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_get_var(fh, v_nk, MK)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_inq_varid(fh, VNAME_NTH, v_nth)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_get_var(fh, v_nth, MTH)
-      if (ncerr .ne. 0) return
 
-      !read in written variables NK, NTH as MK and MTH
-      !and ensure they match 
-      IF (NK.NE.MK .OR. NTH.NE.MTH) THEN
-        WRITE (NDSE,904) MK, MTH, NK, NTH
-        CALL EXTCDE ( 12 )
-      END IF
+    ncerr = nf90_inq_dimid(fh, DNAME_TIME, d_time)
+    if (ncerr .ne. 0) return
+    ncerr = nf90_inquire_dimension(fh, d_time, len = d_time_len)
+    if (ncerr .ne. 0) return
 
-      !JDM TO DO: Missing check and reading of IDSTR, VEROPT 
+    write(*,*) 'd_time_len', d_time_len
 
-      !check reading: 
-      write(*,*) 'MK,MTH', MK, MTH
-      write(*,*) 'dimensions:', d_nopts_len,d_grdidlen_len, d_namelen_len,d_vsize_len,d_nspec_len
+    IF ( IPASS < d_time_len ) THEN 
 
-      ! Allocate variables: 
-      IF ( .NOT. O2INIT )                                     &
-             CALL W3DMO2 ( IGRD, NDSE, NDST, NOPTS )
+      IF ( IPASS.EQ.1 ) THEN
 
-      ! Read vars with nopts as a dimension.
-      ncerr = nf90_inq_varid(fh, VNAME_PTLOC, v_ptloc)
-      if (ncerr .ne. 0) return
-      ncerr = nf90_get_var(fh, v_ptloc, PTLOC, start = (/ 1, 1/), &
-       count = (/ d_vsize_len, d_nopts_len /)) 
-      if (ncerr .ne. 0) return
-      write(*,*) 'PTLOC', PTLOC
-      ncerr = nf90_inq_varid(fh, VNAME_PTNME, v_ptnme)
+        ! Read scalar variables.
+        ncerr = nf90_inq_varid(fh, VNAME_NK, v_nk)
+        if (ncerr .ne. 0) return
+        ncerr = nf90_get_var(fh, v_nk, MK)
+        if (ncerr .ne. 0) return
+        ncerr = nf90_inq_varid(fh, VNAME_NTH, v_nth)
+        if (ncerr .ne. 0) return
+        ncerr = nf90_get_var(fh, v_nth, MTH)
+        if (ncerr .ne. 0) return
+
+        !read in written variables NK, NTH as MK and MTH
+        !and ensure they match 
+        IF (NK.NE.MK .OR. NTH.NE.MTH) THEN
+          WRITE (NDSE,904) MK, MTH, NK, NTH
+          CALL EXTCDE ( 12 )
+        END IF
+
+        !JDM TO DO: Missing check and reading of IDSTR, VEROPT 
+
+
+        ! Allocate variables: 
+        IF ( .NOT. O2INIT )                                     &
+           CALL W3DMO2 ( IGRD, NDSE, NDST, NOPTS )
+
+        ! Read vars with nopts as a dimension.
+        ncerr = nf90_inq_varid(fh, VNAME_PTLOC, v_ptloc)
+        if (ncerr .ne. 0) return
+        ncerr = nf90_get_var(fh, v_ptloc, PTLOC, start = (/ 1, 1/), &
+          count = (/ d_vsize_len, d_nopts_len /)) 
+        if (ncerr .ne. 0) return
+        ncerr = nf90_inq_varid(fh, VNAME_PTNME, v_ptnme)
+        if (ncerr .ne. 0) return
+        ncerr = nf90_get_var(fh, v_ptnme, PTNME)
+        if (ncerr .ne. 0) return
+      END IF
+      write(*,*) 'IPASS=', IPASS
+      !JDM TO DO missing variable TIME??? 
+      ncerr = nf90_inq_varid(fh, VNAME_TIME, v_time)
       if (ncerr .ne. 0) return
-      ncerr = nf90_get_var(fh, v_ptnme, PTNME)
+      ncerr = nf90_get_var(fh, v_time, TIME, start = (/ 1, IPASS/), &
+          count = (/ d_vsize_len, 1 /))
       if (ncerr .ne. 0) return
-    END IF
-    write(*,*) 'IPASS=', IPASS
-    !JDM TO DO missing variable TIME??? 
-    ncerr = nf90_inq_varid(fh, VNAME_TIME, v_time)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_time, TIME, start = (/ 1, IPASS/), &
-       count = (/ d_vsize_len, 1 /))
-    if (ncerr .ne. 0) return
-    write(*,*) 'TIME', TIME
-    !JDM TO DO!! need to find out if IPASS is a valid time value, if not set flag to -1
-    !and exit
 
 
-    ! All of the below variables are missing the "time" dimension... 
-    ! the time dimension being read should be for "IPASS" 
-    ncerr = nf90_inq_varid(fh, VNAME_IW, v_iw)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_iw, IW, start = (/ 1, IPASS/), &
-       count = (/ NOPTS, 1 /))
-    if (ncerr .ne. 0) return
-    ncerr = nf90_inq_varid(fh, VNAME_II, v_ii)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_ii, II, start = (/ 1, IPASS/), &
-       count = (/ NOPTS, 1 /))
-    if (ncerr .ne. 0) return
-    ncerr = nf90_inq_varid(fh, VNAME_IL, v_il)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_il, IL, start = (/ 1, IPASS/), &
-       count = (/ NOPTS, 1 /))
-    if (ncerr .ne. 0) return
-    ncerr = nf90_inq_varid(fh, VNAME_DPO, v_dpo)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_dpo, DPO, start = (/ 1, IPASS/), &
-       count = (/ NOPTS, 1 /))
-    if (ncerr .ne. 0) return
-    ncerr = nf90_inq_varid(fh, VNAME_WAO, v_wao)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_wao, WAO, start = (/ 1, IPASS/), &
-       count = (/ NOPTS, 1 /))
-    if (ncerr .ne. 0) return
-    ncerr = nf90_inq_varid(fh, VNAME_WDO, v_wdo)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_wdo, WDO, start = (/ 1, IPASS/), &
-       count = (/ NOPTS, 1 /))
-    if (ncerr .ne. 0) return
+      ! All of the below variables are missing the "time" dimension... 
+      ! the time dimension being read should be for "IPASS" 
+      ncerr = nf90_inq_varid(fh, VNAME_IW, v_iw)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_get_var(fh, v_iw, IW, start = (/ 1, IPASS/), &
+          count = (/ NOPTS, 1 /))
+      if (ncerr .ne. 0) return
+      ncerr = nf90_inq_varid(fh, VNAME_II, v_ii)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_get_var(fh, v_ii, II, start = (/ 1, IPASS/), &
+          count = (/ NOPTS, 1 /))
+      if (ncerr .ne. 0) return
+      ncerr = nf90_inq_varid(fh, VNAME_IL, v_il)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_get_var(fh, v_il, IL, start = (/ 1, IPASS/), &
+          count = (/ NOPTS, 1 /))
+      if (ncerr .ne. 0) return
+      ncerr = nf90_inq_varid(fh, VNAME_DPO, v_dpo)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_get_var(fh, v_dpo, DPO, start = (/ 1, IPASS/), &
+          count = (/ NOPTS, 1 /))
+      if (ncerr .ne. 0) return
+      ncerr = nf90_inq_varid(fh, VNAME_WAO, v_wao)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_get_var(fh, v_wao, WAO, start = (/ 1, IPASS/), &
+          count = (/ NOPTS, 1 /))
+      if (ncerr .ne. 0) return
+      ncerr = nf90_inq_varid(fh, VNAME_WDO, v_wdo)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_get_var(fh, v_wdo, WDO, start = (/ 1, IPASS/), &
+          count = (/ NOPTS, 1 /))
+      if (ncerr .ne. 0) return
 #ifdef W3_FLX5
-    ncerr = nf90_inq_varid(fh, VNAME_TAUAO, v_tauao)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_tauao, TAUAO, start = (/ 1, IPASS/), &
-       count = (/ NOPTS, 1 /))
-    if (ncerr .ne. 0) return
-    ncerr = nf90_inq_varid(fh, VNAME_TAIDO, v_taido)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_taido, TAIDO, start = (/ 1, IPASS/), &
-       count = (/ NOPTS, 1 /))
-    if (ncerr .ne. 0) return
-    ncerr = nf90_inq_varid(fh, VNAME_DAIRO, v_dairo)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_dairo, DAIRO, start = (/ 1, IPASS/), &
-       count = (/ NOPTS, 1 /))
-    if (ncerr .ne. 0) return
+      ncerr = nf90_inq_varid(fh, VNAME_TAUAO, v_tauao)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_get_var(fh, v_tauao, TAUAO, start = (/ 1, IPASS/), &
+          count = (/ NOPTS, 1 /))
+      if (ncerr .ne. 0) return
+      ncerr = nf90_inq_varid(fh, VNAME_TAIDO, v_taido)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_get_var(fh, v_taido, TAIDO, start = (/ 1, IPASS/), &
+          count = (/ NOPTS, 1 /))
+      if (ncerr .ne. 0) return
+      ncerr = nf90_inq_varid(fh, VNAME_DAIRO, v_dairo)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_get_var(fh, v_dairo, DAIRO, start = (/ 1, IPASS/), &
+          count = (/ NOPTS, 1 /))
+      if (ncerr .ne. 0) return
 #endif
 #ifdef W3_SETUP
-    ncerr = nf90_inq_varid(fh, ZET_SETO, v_zet_seto)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_zet_seto, ZET_SETO, start = (/ 1, IPASS/), &
-       count = (/ NOPTS, 1 /))
-    if (ncerr .ne. 0) return
+      ncerr = nf90_inq_varid(fh, ZET_SETO, v_zet_seto)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_get_var(fh, v_zet_seto, ZET_SETO, start = (/ 1, IPASS/), &
+          count = (/ NOPTS, 1 /))
+      if (ncerr .ne. 0) return
 #endif
-    ncerr = nf90_inq_varid(fh, VNAME_ASO, v_aso)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_aso, ASO, start = (/ 1, IPASS/), &
-       count = (/ NOPTS, 1 /))
-    if (ncerr .ne. 0) return
-    ncerr = nf90_inq_varid(fh, VNAME_CAO, v_cao)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_cao, CAO, start = (/ 1, IPASS/), &
-       count = (/ NOPTS, 1 /))
-    if (ncerr .ne. 0) return
-    ncerr = nf90_inq_varid(fh, VNAME_CDO, v_cdo)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_cdo, CDO, start = (/ 1, IPASS/), &
-       count = (/ NOPTS, 1 /))
-    if (ncerr .ne. 0) return
-    ncerr = nf90_inq_varid(fh, VNAME_ICEO, v_iceo)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_iceo, ICEO, start = (/ 1, IPASS/), &
-       count = (/ NOPTS, 1 /))
-    if (ncerr .ne. 0) return
-    ncerr = nf90_inq_varid(fh, VNAME_ICEHO, v_iceho)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_iceho, ICEHO, start = (/ 1, IPASS/), &
-       count = (/ NOPTS, 1 /))
-    if (ncerr .ne. 0) return
-    ncerr = nf90_inq_varid(fh, VNAME_ICEFO, v_icefo)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_icefo, ICEFO, start = (/ 1, IPASS/), &
-       count = (/ NOPTS, 1 /))
-    if (ncerr .ne. 0) return
-    ncerr = nf90_inq_varid(fh, VNAME_GRDID, v_grdid)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_grdid, GRDID, start = (/ 1, 1, IPASS/), &
-       count = (/ 13, nopts, 1 /))
-    if (ncerr .ne. 0) return
-    ncerr = nf90_inq_varid(fh, VNAME_SPCO, v_spco)
-    if (ncerr .ne. 0) return
-    ncerr = nf90_get_var(fh, v_spco, SPCO, start = (/ 1, 1, IPASS/), &
-       count = (/nspec, nopts, 1 /))
-    if (ncerr .ne. 0) return
+      ncerr = nf90_inq_varid(fh, VNAME_ASO, v_aso)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_get_var(fh, v_aso, ASO, start = (/ 1, IPASS/), &
+          count = (/ NOPTS, 1 /))
+      if (ncerr .ne. 0) return
+      ncerr = nf90_inq_varid(fh, VNAME_CAO, v_cao)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_get_var(fh, v_cao, CAO, start = (/ 1, IPASS/), &
+          count = (/ NOPTS, 1 /))
+      if (ncerr .ne. 0) return
+      ncerr = nf90_inq_varid(fh, VNAME_CDO, v_cdo)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_get_var(fh, v_cdo, CDO, start = (/ 1, IPASS/), &
+          count = (/ NOPTS, 1 /))
+      if (ncerr .ne. 0) return
+      ncerr = nf90_inq_varid(fh, VNAME_ICEO, v_iceo)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_get_var(fh, v_iceo, ICEO, start = (/ 1, IPASS/), &
+          count = (/ NOPTS, 1 /))
+      if (ncerr .ne. 0) return
+      ncerr = nf90_inq_varid(fh, VNAME_ICEHO, v_iceho)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_get_var(fh, v_iceho, ICEHO, start = (/ 1, IPASS/), &
+          count = (/ NOPTS, 1 /))
+      if (ncerr .ne. 0) return
+      ncerr = nf90_inq_varid(fh, VNAME_ICEFO, v_icefo)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_get_var(fh, v_icefo, ICEFO, start = (/ 1, IPASS/), &
+          count = (/ NOPTS, 1 /))
+      if (ncerr .ne. 0) return
+      ncerr = nf90_inq_varid(fh, VNAME_GRDID, v_grdid)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_get_var(fh, v_grdid, GRDID, start = (/ 1, 1, IPASS/), &
+          count = (/ 13, nopts, 1 /))
+      if (ncerr .ne. 0) return
+      ncerr = nf90_inq_varid(fh, VNAME_SPCO, v_spco)
+      if (ncerr .ne. 0) return
+      ncerr = nf90_get_var(fh, v_spco, SPCO, start = (/ 1, 1, IPASS/), &
+          count = (/nspec, nopts, 1 /))
+      if (ncerr .ne. 0) return
+
+    ELSE 
+      ! Set flag to indicate IPASS > d_time_len 
+      ! and are at the end of the
+      IOTST  = -1
+    END IF 
 
     ! Close the file.
     ncerr = nf90_close(fh)

From 19daa8eb2647996bb3ae0a76eddcba20cd52a028 Mon Sep 17 00:00:00 2001
From: JessicaMeixner-NOAA 
Date: Tue, 16 Apr 2024 09:05:02 -0500
Subject: [PATCH 112/126] small fix to make tp1.1 match develop

---
 model/src/w3iopomd.F90 | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index 2c873baa9..321aa2dfb 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -1224,9 +1224,9 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
     ncerr = nf90_inquire_dimension(fh, d_time, len = d_time_len)
     if (ncerr .ne. 0) return
 
-    write(*,*) 'd_time_len', d_time_len
+    write(*,*) 'IPASS, d_time_len', IPASS, d_time_len
 
-    IF ( IPASS < d_time_len ) THEN 
+    IF ( IPASS .LE. d_time_len ) THEN 
 
       IF ( IPASS.EQ.1 ) THEN
 
@@ -1265,17 +1265,15 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
         ncerr = nf90_get_var(fh, v_ptnme, PTNME)
         if (ncerr .ne. 0) return
       END IF
-      write(*,*) 'IPASS=', IPASS
-      !JDM TO DO missing variable TIME??? 
+
+      !Variables read based on time (IPASS): 
+
       ncerr = nf90_inq_varid(fh, VNAME_TIME, v_time)
       if (ncerr .ne. 0) return
       ncerr = nf90_get_var(fh, v_time, TIME, start = (/ 1, IPASS/), &
           count = (/ d_vsize_len, 1 /))
       if (ncerr .ne. 0) return
 
-
-      ! All of the below variables are missing the "time" dimension... 
-      ! the time dimension being read should be for "IPASS" 
       ncerr = nf90_inq_varid(fh, VNAME_IW, v_iw)
       if (ncerr .ne. 0) return
       ncerr = nf90_get_var(fh, v_iw, IW, start = (/ 1, IPASS/), &

From 9887cfca4dc307101cda898a8550e717cecf6319 Mon Sep 17 00:00:00 2001
From: JessicaMeixner-NOAA 
Date: Tue, 16 Apr 2024 09:07:06 -0500
Subject: [PATCH 113/126] clean up comments and print statements

---
 model/src/w3iopomd.F90 | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index 321aa2dfb..349eebbc7 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -1217,15 +1217,11 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
     if (ncerr .ne. 0) return
 
     ! Read the dimention information from time
-
-
     ncerr = nf90_inq_dimid(fh, DNAME_TIME, d_time)
     if (ncerr .ne. 0) return
     ncerr = nf90_inquire_dimension(fh, d_time, len = d_time_len)
     if (ncerr .ne. 0) return
 
-    write(*,*) 'IPASS, d_time_len', IPASS, d_time_len
-
     IF ( IPASS .LE. d_time_len ) THEN 
 
       IF ( IPASS.EQ.1 ) THEN
@@ -1247,9 +1243,6 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)
           CALL EXTCDE ( 12 )
         END IF
 
-        !JDM TO DO: Missing check and reading of IDSTR, VEROPT 
-
-
         ! Allocate variables: 
         IF ( .NOT. O2INIT )                                     &
            CALL W3DMO2 ( IGRD, NDSE, NDST, NOPTS )

From aed792dd09fc27ed1ac6ea5aecc23a48b7cc996d Mon Sep 17 00:00:00 2001
From: JessicaMeixner-NOAA 
Date: Wed, 17 Apr 2024 14:50:01 -0500
Subject: [PATCH 114/126] fix bug from merge

---
 model/src/w3iopomd.F90 | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index 72a83ff2f..4c5b6c988 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -1175,24 +1175,15 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD_IN, filename, ncerr)
     integer :: v_iw, v_ii, v_il, v_dpo, v_wao, v_wdo, v_tauao
     integer :: v_taido, v_dairo, v_zet_seto, v_aso, v_cao, v_cdo, v_iceo
     integer :: v_iceho, v_icefo, v_grdid, v_spco
-    integer :: imod
-
-    if (present(IMOD_IN)) then
-       imod = imod_in
-    else
-       imod = 1
-    endif
-
 
     IOTST = 0
 
-    IF (PRESENT(IMOD)) THEN
-      IGRD = IMOD
+    IF (PRESENT(IMOD_IN)) THEN
+      IGRD = IMOD_IN
     ELSE
       IGRD = 1
     END IF
 
-
     ! Open the netCDF file.
     ncerr = nf90_open(filename, NF90_NOWRITE, fh)
     if (nf90_err(ncerr) .ne. 0) return

From f48d69cd16b994bade2560bd20da9ae236ee24a8 Mon Sep 17 00:00:00 2001
From: JessicaMeixner-NOAA 
Date: Wed, 17 Apr 2024 15:16:52 -0500
Subject: [PATCH 115/126] updates for FLX5 and SETUP

---
 model/src/w3iopomd.F90 | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index 4c5b6c988..db5d2971b 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -1175,6 +1175,12 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD_IN, filename, ncerr)
     integer :: v_iw, v_ii, v_il, v_dpo, v_wao, v_wdo, v_tauao
     integer :: v_taido, v_dairo, v_zet_seto, v_aso, v_cao, v_cdo, v_iceo
     integer :: v_iceho, v_icefo, v_grdid, v_spco
+#ifdef W3_FLX5
+    integer :: v_tauao,v_taido, v_dairo 
+#endif
+#ifdef W3_SETUP
+    integer :: v_zet_seto
+#endif
 
     IOTST = 0
 
@@ -1439,6 +1445,12 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
     integer :: v_iw, v_ii, v_il, v_dpo, v_wao, v_wdo, v_tauao
     integer :: v_taido, v_dairo, v_zet_seto, v_aso, v_cao, v_cdo, v_iceo
     integer :: v_iceho, v_icefo, v_grdid, v_spco
+#ifdef W3_FLX5
+    integer :: v_tauao, v_taido, v_dairo
+#endif    
+#ifdef W3_SETUP
+    integer :: v_zet_seto
+#endif  
 
     !If first pass, or if you are writting a file for every time-step: 
     IF ( IPASS.EQ.1  .OR. timestep_only.EQ.1 ) THEN 

From eb4bd3041794de1b79df3aa583b1bb88e0c3c6f5 Mon Sep 17 00:00:00 2001
From: JessicaMeixner-NOAA 
Date: Wed, 17 Apr 2024 15:33:42 -0500
Subject: [PATCH 116/126] fix build errors and a typo

---
 model/src/w3iopomd.F90 | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index db5d2971b..6329faeba 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -178,8 +178,8 @@ MODULE W3IOPOMD
   !> Variable name for the netCDF point output file, for TAUAO.
   character(*), parameter, private :: VNAME_TAUAO = 'TAUAO'
 
-  !> Variable name for the netCDF point output file, for TAIDO.
-  character(*), parameter, private :: VNAME_TAIDO = 'TAIDO'
+  !> Variable name for the netCDF point output file, for TAUDO.
+  character(*), parameter, private :: VNAME_TAUDO = 'TAUDO'
 
   !> Variable name for the netCDF point output file, for DAIRO.
   character(*), parameter, private :: VNAME_DAIRO = 'DAIRO'
@@ -1172,15 +1172,15 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD_IN, filename, ncerr)
     integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen, d_time
     integer :: d_nopts_len, d_nspec_len, d_vsize_len, d_namelen_len, d_grdidlen_len, d_time_len
     integer :: v_idtst, v_vertst, v_nk, v_nth, v_ptloc, v_ptnme, v_time
-    integer :: v_iw, v_ii, v_il, v_dpo, v_wao, v_wdo, v_tauao
-    integer :: v_taido, v_dairo, v_zet_seto, v_aso, v_cao, v_cdo, v_iceo
-    integer :: v_iceho, v_icefo, v_grdid, v_spco
+    integer :: v_iw, v_ii, v_il, v_dpo, v_wao, v_wdo
 #ifdef W3_FLX5
-    integer :: v_tauao,v_taido, v_dairo 
+    integer :: v_tauao,v_taudo, v_dairo
 #endif
 #ifdef W3_SETUP
     integer :: v_zet_seto
 #endif
+    integer :: v_aso, v_cao, v_cdo, v_iceo
+    integer :: v_iceho, v_icefo, v_grdid, v_spco
 
     IOTST = 0
 
@@ -1324,9 +1324,9 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD_IN, filename, ncerr)
       ncerr = nf90_get_var(fh, v_tauao, TAUAO, start = (/ 1, IPASS/), &
           count = (/ NOPTS, 1 /))
       if (nf90_err(ncerr) .ne. 0) return
-      ncerr = nf90_inq_varid(fh, VNAME_TAIDO, v_taido)
+      ncerr = nf90_inq_varid(fh, VNAME_TAUDO, v_taudo)
       if (nf90_err(ncerr) .ne. 0) return
-      ncerr = nf90_get_var(fh, v_taido, TAIDO, start = (/ 1, IPASS/), &
+      ncerr = nf90_get_var(fh, v_taudo, TAUDO, start = (/ 1, IPASS/), &
           count = (/ NOPTS, 1 /))
       if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_inq_varid(fh, VNAME_DAIRO, v_dairo)
@@ -1442,15 +1442,15 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
     integer :: ndim, nvar, fmt, itime, fh
     integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen, d_time
     integer :: v_idtst, v_vertst, v_nk, v_nth, v_ptloc, v_ptnme, v_time
-    integer :: v_iw, v_ii, v_il, v_dpo, v_wao, v_wdo, v_tauao
-    integer :: v_taido, v_dairo, v_zet_seto, v_aso, v_cao, v_cdo, v_iceo
-    integer :: v_iceho, v_icefo, v_grdid, v_spco
+    integer :: v_iw, v_ii, v_il, v_dpo, v_wao, v_wdo
 #ifdef W3_FLX5
-    integer :: v_tauao, v_taido, v_dairo
+    integer :: v_tauao, v_taudo, v_dairo
 #endif    
 #ifdef W3_SETUP
     integer :: v_zet_seto
 #endif  
+    integer :: v_aso, v_cao, v_cdo, v_iceo
+    integer :: v_iceho, v_icefo, v_grdid, v_spco
 
     !If first pass, or if you are writting a file for every time-step: 
     IF ( IPASS.EQ.1  .OR. timestep_only.EQ.1 ) THEN 
@@ -1510,7 +1510,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
 #ifdef W3_FLX5
       ncerr = nf90_def_var(fh, VNAME_TAUAO, NF90_FLOAT, (/d_nopts, d_time/), v_tauao)
       if (nf90_err(ncerr) .ne. 0) return
-      ncerr = nf90_def_var(fh, VNAME_TAIDO, NF90_FLOAT, (/d_nopts, d_time/), v_taido)
+      ncerr = nf90_def_var(fh, VNAME_TAUDO, NF90_FLOAT, (/d_nopts, d_time/), v_taudo)
       if (nf90_err(ncerr) .ne. 0) return
       ncerr = nf90_def_var(fh, VNAME_DAIRO, NF90_FLOAT, (/d_nopts, d_time/), v_dairo)
       if (nf90_err(ncerr) .ne. 0) return
@@ -1644,10 +1644,10 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
     if (nf90_err(ncerr) .ne. 0) return
 
     IF ( itime > 1 ) THEN
-       ncerr = nf90_inq_varid(fh, VNAME_TAIDO, v_taido)
+       ncerr = nf90_inq_varid(fh, VNAME_TAUDO, v_taudo)
        if (nf90_err(ncerr) .ne. 0) return
     END IF
-    ncerr = nf90_put_var(fh, v_taido, TAIDO, start = (/ 1, itime/), &
+    ncerr = nf90_put_var(fh, v_taudo, TAUDO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
 

From 1e487756e7d574b08d5c56f10b8d5a46c29826e4 Mon Sep 17 00:00:00 2001
From: Jessica Meixner 
Date: Wed, 17 Apr 2024 20:51:43 +0000
Subject: [PATCH 117/126] clean up if statements

---
 model/src/w3iopomd.F90 | 108 +++++++++++++++--------------------------
 1 file changed, 40 insertions(+), 68 deletions(-)

diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90
index 6329faeba..6c4c04cc9 100644
--- a/model/src/w3iopomd.F90
+++ b/model/src/w3iopomd.F90
@@ -1586,149 +1586,121 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)
     II = 0
     IL = 0
 
+    ! If itime > 1 need to inquire varid 
     IF ( itime > 1 ) THEN 
        ncerr = nf90_inq_varid(fh, VNAME_IW, v_iw)
        if (nf90_err(ncerr) .ne. 0) return 
+       ncerr = nf90_inq_varid(fh, VNAME_II, v_ii)
+       if (nf90_err(ncerr) .ne. 0) return
+       ncerr = nf90_inq_varid(fh, VNAME_IL, v_il)
+       if (ncerr .ne. 0) return
+       ncerr = nf90_inq_varid(fh, VNAME_DPO, v_dpo)
+       if (nf90_err(ncerr) .ne. 0) return
+       ncerr = nf90_inq_varid(fh, VNAME_WAO, v_wao)
+       if (nf90_err(ncerr) .ne. 0) return
+       ncerr = nf90_inq_varid(fh, VNAME_WDO, v_wdo)
+       if (nf90_err(ncerr) .ne. 0) return
+#ifdef W3_FLX5
+       ncerr = nf90_inq_varid(fh, VNAME_TAUAO, v_tauao)
+       if (nf90_err(ncerr) .ne. 0) return
+       ncerr = nf90_inq_varid(fh, VNAME_TAUDO, v_taudo)
+       if (nf90_err(ncerr) .ne. 0) return
+       ncerr = nf90_inq_varid(fh, VNAME_DAIRO, v_dairo)
+       if (nf90_err(ncerr) .ne. 0) return
+#endif
+#ifdef W3_SETUP
+       ncerr = nf90_inq_varid(fh, VNAME_ZET_SETO, v_zet_seto)
+       if (nf90_err(ncerr) .ne. 0) return
+#endif
+       ncerr = nf90_inq_varid(fh, VNAME_ASO, v_aso)
+       if (nf90_err(ncerr) .ne. 0) return
+       ncerr = nf90_inq_varid(fh, VNAME_CAO, v_cao)
+       if (nf90_err(ncerr) .ne. 0) return
+       ncerr = nf90_inq_varid(fh, VNAME_CDO, v_cdo)
+       if (nf90_err(ncerr) .ne. 0) return
+       ncerr = nf90_inq_varid(fh, VNAME_ICEO, v_iceo)
+       if (nf90_err(ncerr) .ne. 0) return
+       ncerr = nf90_inq_varid(fh, VNAME_ICEHO, v_iceho)
+       if (nf90_err(ncerr) .ne. 0) return
+       ncerr = nf90_inq_varid(fh, VNAME_ICEFO, v_icefo)
+       if (nf90_err(ncerr) .ne. 0) return
+       ncerr = nf90_inq_varid(fh, VNAME_GRDID, v_grdid)
+       if (nf90_err(ncerr) .ne. 0) return
+       ncerr = nf90_inq_varid(fh, VNAME_SPCO, v_spco)
+       if (nf90_err(ncerr) .ne. 0) return
     END IF
+
     ncerr = nf90_put_var(fh, v_iw, IW, start = (/ 1, itime/), &
        count = (/ NOPTS, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
 
-    IF ( itime > 1 ) THEN
-       ncerr = nf90_inq_varid(fh, VNAME_II, v_ii)
-       if (nf90_err(ncerr) .ne. 0) return
-    END IF
     ncerr = nf90_put_var(fh, v_ii, II, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
 
-    IF ( itime > 1 ) THEN
-       ncerr = nf90_inq_varid(fh, VNAME_IL, v_il)
-       if (ncerr .ne. 0) return
-    END IF
     ncerr = nf90_put_var(fh, v_il, IL, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
 
-    IF ( itime > 1 ) THEN
-       ncerr = nf90_inq_varid(fh, VNAME_DPO, v_dpo)
-       if (nf90_err(ncerr) .ne. 0) return
-    END IF
     ncerr = nf90_put_var(fh, v_dpo, DPO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
 
-    IF ( itime > 1 ) THEN
-       ncerr = nf90_inq_varid(fh, VNAME_WAO, v_wao)
-       if (nf90_err(ncerr) .ne. 0) return
-    END IF
     ncerr = nf90_put_var(fh, v_wao, WAO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
 
-    IF ( itime > 1 ) THEN
-       ncerr = nf90_inq_varid(fh, VNAME_WDO, v_wdo)
-       if (nf90_err(ncerr) .ne. 0) return
-    END IF
     ncerr = nf90_put_var(fh, v_wdo, WDO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
 
 #ifdef W3_FLX5
-    IF ( itime > 1 ) THEN
-       ncerr = nf90_inq_varid(fh, VNAME_TAUAO, v_tauao)
-       if (nf90_err(ncerr) .ne. 0) return
-    END IF
     ncerr = nf90_put_var(fh, v_tauao, TAUAO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
 
-    IF ( itime > 1 ) THEN
-       ncerr = nf90_inq_varid(fh, VNAME_TAUDO, v_taudo)
-       if (nf90_err(ncerr) .ne. 0) return
-    END IF
     ncerr = nf90_put_var(fh, v_taudo, TAUDO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
 
-    IF ( itime > 1 ) THEN
-       ncerr = nf90_inq_varid(fh, VNAME_DAIRO, v_dairo)
-       if (nf90_err(ncerr) .ne. 0) return
-    END IF
     ncerr = nf90_put_var(fh, v_dairo, DAIRO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
 #endif
 #ifdef W3_SETUP
-    IF ( itime > 1 ) THEN
-       ncerr = nf90_inq_varid(fh, VNAME_ZET_SETO, v_zet_seto)
-       if (nf90_err(ncerr) .ne. 0) return
-    END IF
     ncerr = nf90_put_var(fh, v_zet_seto, ZET_SETO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
 #endif
-    IF ( itime > 1 ) THEN
-       ncerr = nf90_inq_varid(fh, VNAME_ASO, v_aso)
-       if (nf90_err(ncerr) .ne. 0) return
-    END IF
     ncerr = nf90_put_var(fh, v_aso, ASO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
 
-    IF ( itime > 1 ) THEN
-       ncerr = nf90_inq_varid(fh, VNAME_CAO, v_cao)
-       if (nf90_err(ncerr) .ne. 0) return
-    END IF
     ncerr = nf90_put_var(fh, v_cao, CAO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
 
-    IF ( itime > 1 ) THEN
-       ncerr = nf90_inq_varid(fh, VNAME_CDO, v_cdo)
-       if (nf90_err(ncerr) .ne. 0) return
-    END IF
     ncerr = nf90_put_var(fh, v_cdo, CDO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
 
-    IF ( itime > 1 ) THEN
-       ncerr = nf90_inq_varid(fh, VNAME_ICEO, v_iceo)
-       if (nf90_err(ncerr) .ne. 0) return
-    END IF
     ncerr = nf90_put_var(fh, v_iceo, ICEO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
 
-    IF ( itime > 1 ) THEN
-       ncerr = nf90_inq_varid(fh, VNAME_ICEHO, v_iceho)
-       if (nf90_err(ncerr) .ne. 0) return
-    END IF
     ncerr = nf90_put_var(fh, v_iceho, ICEHO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
 
-    IF ( itime > 1 ) THEN
-       ncerr = nf90_inq_varid(fh, VNAME_ICEFO, v_icefo)
-       if (nf90_err(ncerr) .ne. 0) return
-    END IF
     ncerr = nf90_put_var(fh, v_icefo, ICEFO, start = (/ 1, itime/), &
        count = (/ nopts, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
 
-    IF ( itime > 1 ) THEN
-       ncerr = nf90_inq_varid(fh, VNAME_GRDID, v_grdid)
-       if (nf90_err(ncerr) .ne. 0) return
-    END IF
     ncerr = nf90_put_var(fh, v_grdid, GRDID, start = (/ 1, 1, itime/), &
        count = (/ 13, nopts, 1 /))
     if (nf90_err(ncerr) .ne. 0) return
 
     !write spectral output
-    IF ( itime > 1 ) THEN
-       ncerr = nf90_inq_varid(fh, VNAME_SPCO, v_spco)
-       if (nf90_err(ncerr) .ne. 0) return
-    END IF
     ncerr = nf90_put_var(fh, v_spco, SPCO, start = (/ 1, 1, itime/), &
        count = (/nspec, nopts, 1 /))
     if (nf90_err(ncerr) .ne. 0) return

From 2d0a0da0ac775c7b0a7faddbe16f17907da6ce9d Mon Sep 17 00:00:00 2001
From: Jessica Meixner 
Date: Wed, 17 Apr 2024 20:52:07 +0000
Subject: [PATCH 118/126] clean up test files

---
 regtests/ww3_tp1.1/out_pnt_ncdump.txt | 33 ---------------------------
 regtests/ww3_tp2.5/out_pnt_ncdump.txt | 33 ---------------------------
 2 files changed, 66 deletions(-)
 delete mode 100644 regtests/ww3_tp1.1/out_pnt_ncdump.txt
 delete mode 100644 regtests/ww3_tp2.5/out_pnt_ncdump.txt

diff --git a/regtests/ww3_tp1.1/out_pnt_ncdump.txt b/regtests/ww3_tp1.1/out_pnt_ncdump.txt
deleted file mode 100644
index bb8e3ffb9..000000000
--- a/regtests/ww3_tp1.1/out_pnt_ncdump.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-netcdf out_pnt.ww3 {
-dimensions:
-	NOPTS = 21 ;
-	NSPEC = 12 ;
-	VSIZE = 2 ;
-	NAMELEN = 40 ;
-	GRDIDLEN = 13 ;
-	TIME = UNLIMITED ; // (25 currently)
-variables:
-	int NK ;
-	int NTH ;
-	float PTLOC(NOPTS, VSIZE) ;
-	char PTNME(NOPTS, NAMELEN) ;
-	int TIME(TIME, VSIZE) ;
-	int IW(TIME, NOPTS) ;
-	int II(TIME, NOPTS) ;
-	int IL(TIME, NOPTS) ;
-	float DPO(TIME, NOPTS) ;
-	float WAO(TIME, NOPTS) ;
-	float WDO(TIME, NOPTS) ;
-	float ASO(TIME, NOPTS) ;
-	float CAO(TIME, NOPTS) ;
-	float CDO(TIME, NOPTS) ;
-	float ICEO(TIME, NOPTS) ;
-	float ICEHO(TIME, NOPTS) ;
-	float ICEFO(TIME, NOPTS) ;
-	char GRDID(TIME, NOPTS, GRDIDLEN) ;
-	float SPCO(TIME, NOPTS, NSPEC) ;
-
-// global attributes:
-		:title = "WAVEWATCH III POINT OUTPUT FILE" ;
-		:version = "2021-04-06" ;
-}
diff --git a/regtests/ww3_tp2.5/out_pnt_ncdump.txt b/regtests/ww3_tp2.5/out_pnt_ncdump.txt
deleted file mode 100644
index 3747eb8e4..000000000
--- a/regtests/ww3_tp2.5/out_pnt_ncdump.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-netcdf out_pnt.ww3 {
-dimensions:
-	NOPTS = 1 ;
-	NSPEC = 36 ;
-	VSIZE = 2 ;
-	NAMELEN = 40 ;
-	GRDIDLEN = 13 ;
-	TIME = UNLIMITED ; // (13 currently)
-variables:
-	int NK ;
-	int NTH ;
-	float PTLOC(NOPTS, VSIZE) ;
-	char PTNME(NOPTS, NAMELEN) ;
-	int TIME(TIME, VSIZE) ;
-	int IW(TIME, NOPTS) ;
-	int II(TIME, NOPTS) ;
-	int IL(TIME, NOPTS) ;
-	float DPO(TIME, NOPTS) ;
-	float WAO(TIME, NOPTS) ;
-	float WDO(TIME, NOPTS) ;
-	float ASO(TIME, NOPTS) ;
-	float CAO(TIME, NOPTS) ;
-	float CDO(TIME, NOPTS) ;
-	float ICEO(TIME, NOPTS) ;
-	float ICEHO(TIME, NOPTS) ;
-	float ICEFO(TIME, NOPTS) ;
-	char GRDID(TIME, NOPTS, GRDIDLEN) ;
-	float SPCO(TIME, NOPTS, NSPEC) ;
-
-// global attributes:
-		:title = "WAVEWATCH III POINT OUTPUT FILE" ;
-		:version = "2021-04-06" ;
-}

From 8020f847f73d0a340fd34408cfd809b5f5ad79dc Mon Sep 17 00:00:00 2001
From: Jessica Meixner 
Date: Wed, 17 Apr 2024 20:52:37 +0000
Subject: [PATCH 119/126] remove duplication of wiki page

---
 docs/regtests.md | 953 -----------------------------------------------
 1 file changed, 953 deletions(-)
 delete mode 100644 docs/regtests.md

diff --git a/docs/regtests.md b/docs/regtests.md
deleted file mode 100644
index 21df2da01..000000000
--- a/docs/regtests.md
+++ /dev/null
@@ -1,953 +0,0 @@
-# How to Run the Regtests
-
-## Set Up Model Environment
-
-Copy and rename the switch file:
-cp /home/ed/WW3/regtests/unittests/data/switch.io model/switch_IO
-
-Run this command:
-
-./model/bin/w3_setup /home/ed/WW3/model -c tmpl -s IO
- 
-                *****************************
-              ***   WAVEWATCH III setup     ***
-                *****************************
- 
- 
-[INFO] local env file wwatch3.env found in /home/ed/WW3/model/bin/wwatch3.env
-   Setup file /home/ed/WW3/model/bin/wwatch3.env found
-      Source directory            : /home/ed/WW3/model
-      Scratch directory           : /home/ed/WW3/model/tmp
-      Save source code            : yes
-      Save listings               : yes
-   Update settings ? [y/n] y
- 
-   Creating new set-up :
- 
-      Scratch space [/home/ed/WW3/model/tmp] : 
-      Save source code files (*.f)  [yes] : 
-      Save listing files  [yes] : 
- 
-   Modified set up :
-      Scratch directory        : /home/ed/WW3/model/tmp
-      Save sources             : yes
-      Save listings            : yes
-   New settings OK ? [y/n] y
- 
-   Setup comp & link files
-      copy /home/ed/WW3/model/bin/comp.tmpl => /home/ed/WW3/model/bin/comp
-      copy /home/ed/WW3/model/bin/link.tmpl => /home/ed/WW3/model/bin/link
-      copy /home/ed/WW3/model/bin/ad3.tmpl => /home/ed/WW3/model/bin/ad3
- 
-   Setup switch file
-      /home/ed/WW3/model/bin/switch_IO => /home/ed/WW3/model/bin/switch
- 
-   Create required model subdirectories
- 
-Finished setting up WAVEWATCH III
- 
-
-## Compile WW3
-
-Install dependencies with spack as shown in .github/workflow/io_gnu.yml.
-
-Build WW3 binaries like this:
-
-cmake -DSWITCH=/home/ed/ww3/regtests/unittests/data/switch.io  -DCMAKE_BUILD_TYPE=Debug -DCMAKE_Fortran_FLAGS="-g" -DCMAKE_C_FLAGS="-g" ..
-make VERBOSE=1 -j2
-make test
-
-## Download Test Data
-
-Download the test data by running the shell script: model/bin/ww3_from_ftp.sh.
-
-## Run Some Stuff
-
-In the build directory there is a file ww3_grid.inp. In the build directory execute:
-
-./bin/ww3_grid
-
- -Expect the following output: - -
-
-                   *** WAVEWATCH III Grid preprocessor ***    
-               ===============================================
-
-  Comment character is '$'
-
-  Grid name : 1-D REFRACTION X              
-
-
-  Spectral discretization : 
- --------------------------------------------------
-       Number of directions        :  24
-       Directional increment (deg.):  15.0
-       First direction       (deg.):   0.0
-       Number of frequencies       :   3
-       Frequency range        (Hz) :   0.0800-0.1250
-       Increment factor            :   1.250
-
-
-  Model definition :
- --------------------------------------------------
-       Dry run (no calculations)   :  ---/NO
-       Propagation in X-direction  :  YES/--
-       Propagation in Y-direction  :  ---/NO
-       Refraction                  :  YES/--
-       Current-induced k-shift     :  ---/NO
-       Source term calc. and int.  :  ---/NO
-
-
-  Time steps : 
- --------------------------------------------------
-       Maximum global time step      (s) :  300.00
-       Maximum CFL time step X-Y     (s) :  300.00
-       Maximum CFL time step k-theta (s) :  150.00
-       Minimum source term time step (s) :  300.00
-
-  Preprocessing namelists ...
-  Preprocessing namelists finished.
-
-
-  Stresses (T&C 96)
- --------------------------------------------------
-
-
-  Linear input not defined.
-
-
-  Wind input not defined.
-
-
-  Nonlinear interactions not defined.
-
-
-  Dissipation not defined.
-
-
-  Bottom friction not defined.
-
-
-  Surf breaking not defined.
-
-
-  Triad interactions not defined.
-
-
-  Bottom scattering not defined.
-
-
-  Propagation scheme : 
- --------------------------------------------------
-       Type of scheme (structured) : First order upstream          
-                                     (user def. values)
-       CFLmax depth refraction     :    0.750
-
-
-  Ice scattering not defined.
-
-
-  Spectral output on full grid (default values) :  
- --------------------------------------------------
-       Second order pressure at K=0:   0   1   3
-       Spectrum of Uss             :   0   1   3
-       Frequency spectrum          :   0   1   3
-       Partions of Uss             :   0   1
-       Partition wavenumber # 1   :  0.063
-
-  Miscellaneous (default values) :  
- --------------------------------------------------
-       Ice concentration cut-offs  :    0.50  0.50
-       Wind input reduction factor in presence of 
-         ice :  1.00
-         (0.0==> no reduction and 1.0==> no wind
-         input with 100% ice cover)
-       Space-time extremes DX-Y set to default 1000 m
-       Space-time extremes Dt set to default 1200 s
-       Compression of track output  :   T
-
-    Dynamic source term integration scheme :
-       Xp                      (-) :    0.150
-       Xr                      (-) :    0.100
-       Xfilt                   (-) :    0.050
-
-    Wave field partitioning :
-       Levels                  (-) :  100
-       Minimum wave height     (m) :    0.050
-       Wind area multiplier    (-) :    1.700
-       Cut-off wind sea fract. (-) :    0.333
-       Combine wind seas           :  YES/--
-       Number of swells in fld out :    5
-       Partitioning method         :  WW3 default                                  
-
-    Miche-style limiting wave height :
-       Hs,max/d factor         (-) :    1.600
-       Hrms,max/d factor       (-) :    1.131
-       Limiter activated           :  ---/NO
-
-    Calendar type                  :  standard
-
-
-  Equivalent namelists ...
-
-  &PRO1 CFLTM = 0.75 /
-  &UNST UGBCCFL =  T, UGOBCAUTO =  T, UGOBCDEPTH = -10.000, UGOBCFILE=unset,
-,  EXPFSN =  T,EXPFSPSI =  F,  EXPFSFCT =  F,IMPFSN =  F,EXPTOTAL=  F,  IMPTOTAL=  F,IMPREFRACTION=  F,  IMPFREQSHIFT=  F, IMPSOURCE=  F,  SETUP_APPLY_WLV=  T,  JGS_TERMINATE_MAXITER=  T,  JGS_TERMINATE_DIFFERENCE=  T,  JGS_TERMINATE_NORM=  F,  JGS_LIMITER=  F,  JGS_LIMITER_FUNC=  1,  JGS_USE_JACOBI=  T,  JGS_BLOCK_GAUSS_SEIDEL=  T,  JGS_MAXITER=  100,  JGS_PMIN=   1.000,  JGS_DIFF_THR=   0.000,  JGS_NORM_THR=   0.000,  JGS_NLEVEL=  0,  JGS_SOURCE_NONLINEAR=  F
-
-  &OUTS P2SF  = 0, I1P2SF = 1, I2P2SF = 15,
-        US3D  = 0, I1US3D =  1, I2US3D =  3,
-        USSP  = 0, IUSSP  =  1,
-        E3D   = 0, I1E3D  =  1, I2E3D  =  3,
-        TH1MF = 0, I1TH1M =  1, I2TH1M =  3,
-        STH1MF= 0, I1STH1M=  1, I2STH1M=  3,
-        TH2MF = 0, I1TH2M =  1, I2TH2M =  3,
-        STH2MF= 0, I1STH2M=  1, I2STH2M=  3 /
-  &MISC CICE0 = 0.500, CICEN = 0.500, LICE =      0.0, PMOVE = 0.500,
-        XSEED = 1.000, FLAGTR = 0, XP = 0.150, XR = 0.100, XFILT = 0.050
-        IHM =  100, HSPM = 0.050, WSM = 1.700, WSC = 0.333, FLC = .TRUE.
-        NOSW =  5, FMICHE = 1.600, RWNDC = 1.000, WCOR1 = 99.00, WCOR2 =  0.00,
-        FACBERG = 1.0, GSHIFT =   0.000E+00, STDX =   -1.00, STDY =  -1.00,
-        STDT =   -1.00, ICEHMIN = 0.20, ICEHFAC = 1.00,
-        ICEHINIT = 0.50, ICEDISP =  F, ICEHDISP = 0.60,
-        ICESLN =   1.00, ICEWIND =   1.00, ICESNL =   1.00, ICESDS =  1.00,
-        ICEDDISP = 80.00, ICEFDISP =  2.00, CALTYPE = standard , TRCKCMPR =   T,
-        BTBET  =   1.20 /
-
-  Equivalent namelists finished.
-
-
-  The spatial grid: 
- --------------------------------------------------
-
-       Grid type                   : rectilinear
-       Coordinate system           : Cartesian
-       Index closure type          : none
-       Dimensions                  :     13       3
-       Increments             (km) :    5.00    5.00
-       X range                (km) :   -5.00   55.00
-       Y range                (km) :   -5.00    5.00
-
-       Bottom level unit           :    10
-       Limiting depth          (m) :   -1.00
-       Minimum depth           (m) :    1.00
-       Scale factor                :   -1.00
-       Layout indicator            :     2
-       Format indicator            :     1
-
-       Sub-grid information        : Not available.
-  Processing boundary points
-  Processing excluded points
-
-  Input boundary points : 
- --------------------------------------------------
-       Number of boundary points   :     1
-
-         Nr.|   IX  |   IY  |     X     |     Y     
-       -----|-------|-------|-----------|-----------
-          1 |     2 |     2 |     0.0E3 |     0.0E3
-
-  Excluded points : 
- --------------------------------------------------
-       Number of excluded points   :    25
-
-
-  Status map, printed in     1 part(s) 
- -----------------------------------
-
-   3 3 3 3 3 3 3 3 3 3 3 3 0
-   3 2 1 1 1 1 1 1 1 1 1 1 0
-   3 3 3 3 3 3 3 3 3 3 3 3 0
-  
-  Legend : 
- -----------------------------
-    0 : Land point            
-    1 : Sea point             
-    2 : Active boundary point 
-    3 : Excluded point        
-
-
-  Output boundary points : 
- --------------------------------------------------
-       No boundary points.
-
-
-  Writing model definition file ...
-
-
-  Summary grid statistics : 
- --------------------------------------------------
-       Number of longitudes      :        13
-       Number of latitudes       :         3
-       Number of grid points     :        39
-       Number of sea points      :        11 (28.2%)
-       Number of input b. points :         1
-       Number of land points     :         3
-       Number of excluded points :        25
-
-
-  End of program 
- ========================================
-         WAVEWATCH III Grid preprocessor 
-
- - -## Running a Regtest - -
-
-ed@Pooh-Bah:~/ww3/regtests/ww3_tp1.1/input$ ../../../build/bin/ww3_grid 
-
-                   *** WAVEWATCH III Grid preprocessor ***    
-               ===============================================
-
-  Grid name : 1-D PROPAGATION EQUATOR       
-
-
-  Spectral discretization : 
- --------------------------------------------------
-       Number of directions        :   4
-       Directional increment (deg.):  90.0
-       First direction       (deg.):   0.0
-       Number of frequencies       :   3
-       Frequency range        (Hz) :   0.0368-0.0445
-       Increment factor            :   1.100
-
-
-  Model definition :
- --------------------------------------------------
-       Dry run (no calculations)   :  ---/NO
-       Propagation in X-direction  :  YES/--
-       Propagation in Y-direction  :  ---/NO
-       Refraction                  :  ---/NO
-       Current-induced k-shift     :  ---/NO
-       Source term calc. and int.  :  ---/NO
-
-
-  Time steps : 
- --------------------------------------------------
-       Maximum global time step      (s) : 3600.00
-       Maximum CFL time step X-Y     (s) : 3600.00
-       Maximum CFL time step k-theta (s) : 3600.00
-       Minimum source term time step (s) : 3600.00
-
-  Preprocessing namelists ...
-  Preprocessing namelists finished.
-
-
-  Stresses (T&C 96)
- --------------------------------------------------
-
-
-  Linear input not defined.
-
-
-  Wind input not defined.
-
-
-  Nonlinear interactions not defined.
-
-
-  Dissipation not defined.
-
-
-  Bottom friction not defined.
-
-
-  Surf breaking not defined.
-
-
-  Triad interactions not defined.
-
-
-  Bottom scattering not defined.
-
-
-  Propagation scheme : 
- --------------------------------------------------
-       Type of scheme (structured) : First order upstream          
-                                     (default values)  
-       CFLmax depth refraction     :    0.700
-
-
-  Ice scattering not defined.
-
-
-  Spectral output on full grid (default values) :  
- --------------------------------------------------
-       Second order pressure at K=0:   0   1   3
-       Spectrum of Uss             :   0   1   3
-       Frequency spectrum          :   0   1   3
-       Partions of Uss             :   0   1
-       Partition wavenumber # 1   :  0.063
-
-  Miscellaneous (default values) :  
- --------------------------------------------------
-       Ice concentration cut-offs  :    0.50  0.50
-       Wind input reduction factor in presence of 
-         ice :  1.00
-         (0.0==> no reduction and 1.0==> no wind
-         input with 100% ice cover)
-       Space-time extremes DX-Y set to default 1000 m
-       Space-time extremes Dt set to default 1200 s
-       Compression of track output  :   T
-
-    Dynamic source term integration scheme :
-       Xp                      (-) :    0.150
-       Xr                      (-) :    0.100
-       Xfilt                   (-) :    0.050
-
-    Wave field partitioning :
-       Levels                  (-) :  100
-       Minimum wave height     (m) :    0.050
-       Wind area multiplier    (-) :    1.700
-       Cut-off wind sea fract. (-) :    0.333
-       Combine wind seas           :  YES/--
-       Number of swells in fld out :    5
-       Partitioning method         :  WW3 default                                  
-
-    Miche-style limiting wave height :
-       Hs,max/d factor         (-) :    1.600
-       Hrms,max/d factor       (-) :    1.131
-       Limiter activated           :  ---/NO
-
-    Calendar type                  :  standard
-
-
-  Equivalent namelists ...
-
-  &PRO1 CFLTM = 0.70 /
-  &UNST UGBCCFL =  T, UGOBCAUTO =  T, UGOBCDEPTH = -10.000, UGOBCFILE=unset,
-,  EXPFSN =  T,EXPFSPSI =  F,  EXPFSFCT =  F,IMPFSN =  F,EXPTOTAL=  F,  IMPTOTAL=  F,IMPREFRACTION=  F,  IMPFREQSHIFT=  F, IMPSOURCE=  F,  SETUP_APPLY_WLV=  T,  JGS_TERMINATE_MAXITER=  T,  JGS_TERMINATE_DIFFERENCE=  T,  JGS_TERMINATE_NORM=  F,  JGS_LIMITER=  F,  JGS_LIMITER_FUNC=  1,  JGS_USE_JACOBI=  T,  JGS_BLOCK_GAUSS_SEIDEL=  T,  JGS_MAXITER=  100,  JGS_PMIN=   1.000,  JGS_DIFF_THR=   0.000,  JGS_NORM_THR=   0.000,  JGS_NLEVEL=  0,  JGS_SOURCE_NONLINEAR=  F
-
-  &OUTS P2SF  = 0, I1P2SF = 1, I2P2SF = 15,
-        US3D  = 0, I1US3D =  1, I2US3D =  3,
-        USSP  = 0, IUSSP  =  1,
-        E3D   = 0, I1E3D  =  1, I2E3D  =  3,
-        TH1MF = 0, I1TH1M =  1, I2TH1M =  3,
-        STH1MF= 0, I1STH1M=  1, I2STH1M=  3,
-        TH2MF = 0, I1TH2M =  1, I2TH2M =  3,
-        STH2MF= 0, I1STH2M=  1, I2STH2M=  3 /
-  &MISC CICE0 = 0.500, CICEN = 0.500, LICE =      0.0, PMOVE = 0.500,
-        XSEED = 1.000, FLAGTR = 0, XP = 0.150, XR = 0.100, XFILT = 0.050
-        IHM =  100, HSPM = 0.050, WSM = 1.700, WSC = 0.333, FLC = .TRUE.
-        NOSW =  5, FMICHE = 1.600, RWNDC = 1.000, WCOR1 = 99.00, WCOR2 =  0.00,
-        FACBERG = 1.0, GSHIFT =   0.000E+00, STDX =   -1.00, STDY =  -1.00,
-        STDT =   -1.00, ICEHMIN = 0.20, ICEHFAC = 1.00,
-        ICEHINIT = 0.50, ICEDISP =  F, ICEHDISP = 0.60,
-        ICESLN =   1.00, ICEWIND =   1.00, ICESNL =   1.00, ICESDS =  1.00,
-        ICEDDISP = 80.00, ICEFDISP =  2.00, CALTYPE = standard , TRCKCMPR =   T,
-        BTBET  =   1.20 /
-
-  Equivalent namelists finished.
-
-
-  The spatial grid: 
- --------------------------------------------------
-
-       Grid type                   : rectilinear
-       Coordinate system           : spherical
-       Index closure type          : simple
-       Dimensions                  :    360       3
-
-       Increments           (deg.) :    1.0000    1.0000
-       Longitude range      (deg.) : -180.0000  179.0000
-       Latitude range       (deg.) :   -1.0000    1.0000
-
-       Bottom level unit           :    50
-       Limiting depth          (m) :   -5.00
-       Minimum depth           (m) :    5.75
-       Scale factor                :-2500.00
-       Layout indicator            :     2
-       Format indicator            :     1
-       File name                   : ../input/1-D.depth
-
-       Sub-grid information        : Not available.
-  Processing boundary points
-  Processing excluded points
-
-  Input boundary points : 
- --------------------------------------------------
-       No boundary points.
-
-
-  Excluded points : 
- --------------------------------------------------
-       Number of excluded points   :   720
-
-
-  Status map, printed in     5 part(s) 
- -----------------------------------
-
-   3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
-   1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
-   3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
-  
-   3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
-   1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
-   3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
-  
-   3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
-   1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
-   3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
-  
-   3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
-   1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
-   3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
-  
-   3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
-   1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
-   3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
-  
-  Legend : 
- -----------------------------
-    0 : Land point            
-    1 : Sea point             
-    2 : Active boundary point 
-    3 : Excluded point        
-
-
-  Output boundary points : 
- --------------------------------------------------
-       No boundary points.
-
-
-  Writing model definition file ...
-
-
-  Summary grid statistics : 
- --------------------------------------------------
-       Number of longitudes      :       360
-       Number of latitudes       :         3
-       Number of grid points     :      1080
-       Number of sea points      :       360 (33.3%)
-       Number of input b. points :         0
-       Number of land points     :         0
-       Number of excluded points :       720
-
-
-  End of program 
- ========================================
-         WAVEWATCH III Grid preprocessor 
-
-ed@Pooh-Bah:~/ww3/regtests/ww3_tp1.1/input$ ../../../build/bin/ww3_strt 
-
-                  *** WAVEWATCH III  Initial conditions ***   
-               ===============================================
-
-  Comment character is '$'
-
-  Grid name : 1-D PROPAGATION EQUATOR       
-
-
-  Initial field ITYPE = 1
- --------------------------------------------------
-  Negative SIX was provided by user.         
-  WW3 will create a gaussian distribution    
-  that is circular in real space. 
-       Gaussian / cosine power spectrum 
-
-       Peak frequency and spread (Hz)    :    0.0405  0.0001
-       Mean direction (Naut., degr.)     :  270.0
-       Cosine power of dir. distribution :  200
-       Mean longitude and spread (degr.) :    0.00    0.01
-       Mean latitude and spread (degr.)  :    0.00    2.00
-       Maximum wave height               :    2.50
-
-
-  Location : TEST E(f)
-  Spectrum : Unscaled 1-D  Extreme value :  0.100E+01  
-
-           +-------+
- 0.990E+00 +   *   |
-           |       |
- 0.770E+00 +       |
-           |       |
- 0.550E+00 +       |
-           |       |
- 0.330E+00 +       |
-           |       |
- 0.110E+00 +       |
-           +-*-|-*-+
-             0.040
- 
-
-  Location : TEST 2-D
-  Spectrum : Energy (Normalized)   Maximum value :  0.706E+01 m2s
-
-       ang.|  frequencies (Hz) 
-       deg.| 0.040
-       ----+---|---+
-         N |       |
-         E |       |
-         S |       |
-         W |   *   |
-       ----+-------+
- 
-
-       Converting energy to action ... 
-
- Variable: Hs Max.:  0.250E+01 m
- 
-             1      23      45      67      89     111     133     155     177     199     221     243     265     287     309     331     353
-       +-------------------------------------------------------------------+
-     3 |                                                                   |
-       | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
-       |                                                                   |
-       +-------------------------------------------------------------------+
-             1      23      45      67      89     111     133     155     177     199     221     243     265     287     309     331     353
- 
-
-       Writing restart file  ... 
-
-
-  End of program 
- =========================================
-         WAVEWATCH III Initial conditions 
-
-ed@Pooh-Bah:~/ww3/regtests/ww3_tp1.1/input$ ../../../build/bin/ww3_prep 
-
-                 *** WAVEWATCH III  Input pre-processing ***  
-               ===============================================
-
-
- *** WAVEWATCH III ERROR IN W3PREP : 
-     ERROR IN OPENING INPUT FILE
-     IOSTAT =    2
-
- -## Running WW3 - -These are the steps: -* ww3_grid (generate mod_def.ww3 file). -* ww3_strt (generate initial conditions). -* ww3_prep (generate ice.ww3 file). -* ww3_shel (run the model). -* ww3_outf (print out wave heights). -* ww3_outp (print out some spectra). - -## run_cmake_test - -There is a script called run_cmake_test. It seems relevant: - -
-
-ed@Pooh-Bah:~/ww3/regtests$ ./bin/run_cmake_test -o all -S -T -s PR1_MPI -w work_PR1_MPI              -f -p mpirun -n 24 ../model ww3_tp1.1
- 
- Running now options: run_cmake_test -o all -S -T -s PR1_MPI -w work_PR1_MPI -f -p mpirun -n 24 ../model ww3_tp2.1
- 
-   Building WW3, exes will be in /home/ed/ww3/regtests/ww3_tp2.1/work_PR1_MPI/exe
-   Build log is in /home/ed/ww3/regtests/ww3_tp2.1/work_PR1_MPI/build.log
- 
- 
-                    ==================================   
-                  ======> TEST RUN WAVEWATCH III <====== 
-                    ==================================   
- 
-#############################################################################
-#                                                                           #
-# ww3_tp2.1 Test script for WW-III, two-dimensional propagation.            #
-#           Propagation under angle with grid.                              #
-#                                                                           #
-# Model should be compiled with the switches :                              #
-#                                                                           #
-#   !/LN0 !/ST0 !/NL0 !/BT0 !/DB0 !/TR0 !/BS0                               #
-#                        Select the 'no source terms' option.               #
-#   !/PRn                Selecting one of the propagation schemes.          #
-#                         1: First order.                                   #
-#                         2: UQ with diffusion term.                        #
-#                         3: UQ with averaging.                             #
-#   !/WNX1 !/WNT1 !/CRX1 !/CRT1      Wind and current interpolation.        #
-#   !/O0 !/O1 !/O2 !/O3 !/O4 !/O5 !/O6 !/O7   Sdt out output options.       #
-#                                                                           #
-# Remarks :                                                                 #
-#                                                                           #
-# - Test case input (default):                                              #
-#   * ww3_grid.inp : (default)                                              #
-#     + Spatial grid: 43 x 43 rectilinear Cartesian grid                    #
-#       - dx = 1 km, dy = 1 km                                              #
-#       - Xrange = -60:360 km, Yrange = -60:360 km                          #
-#       - land mask defined                                                 #
-#     + Spectral grid: ntheta = 24, nf =  3, f1 = 0.03679, fgamma = 1.1     #
-#   * ww3_grid_b.inp :                                                      #
-#     + Spatial grid: 273 x 274 rectilinear Cartesian grid                  #
-#       - dx = 16 km, dy = 16 km                                            #
-#       - Xrange = 0:4352 km, Yrange = 0:4368 km                            #
-#       - no land mask defined                                              #
-#     + Spectral grid: ntheta = 12, nf =  3, f1 = 0.03679, fgamma = 1.1     #
-#   * ww3_grid_c.inp :                                                      #
-#     + Spatial grid: 226 x 331 curvilinear Cartesian grid                  #
-#       - dx and dy are variable                                            #
-#       - Xrange = 1040.39:7000.00 km, Yrange = 2000.00:7959.61 km          #
-#       - input grid coordinates: grd.IDLA1.dat                        #
-#       - no land mask defined                                              #
-#     + Spectral grid: ntheta = 12, nf =  3, f1 = 0.03679, fgamma = 1.1     #
-#   * map2_1.gs: GrADS script for the default grid.                         #
-#   * switch options (mostly self-explanatory).                             #
-#     + switch_PR1      : First order scheme                                #
-#     + switch_PR2_UNO  : UNO scheme with diffusion (off)                   #
-#     + switch_PR2_UQ   : UQ scheme with diffusion (off)                    #
-#     + switch_PR3_UNO  : UNO scheme with averaging (off)                   #
-#     + switch_PR3_UQ   : UQ scheme with averaging (off) (default)          #
-#     + switch_PR1_MPI                                                      #
-#     + switch_PR2_UNO_MPI                                                  #
-#     + switch_PR2_UQ_MPI                                                   #
-#     + switch_PR3_UNO_MPI                                                  #
-#     + switch_PR3_UQ_MPI                                                   #
-#                                                                           #
-#  Sample run_test commands :                                               #
-#   (Note: mpirun commands differ by local system)                          #
-#  ./bin/run_test                             -s PR1   ../model ww3_tp2.1   #
-#  ./bin/run_test -n 3 -p mpirun -f           -s PR1   ../model ww3_tp2.1   # 
-#  ./bin/run_test -g c        -n 3 -p mpirun -s PR3_UQ_MPI \                #          
-#       -w work_c_curv ../model ww3_tp2.1                                   #
-#  ./bin/run_test -g b_pseudo -n 3 -p mpirun -s PR3_UQ_MPI \                #          
-#       -w work_b_curv ../model ww3_tp2.1                                   #
-#                                                                           #
-#                                              Hendrik Tolman, Jun 2002     #
-#                                                   Last Mod : Dec 2013     #
-#                                                                           #
-#    Copyright 2009-2013 National Weather Service (NWS),                    #
-#       National Oceanic and Atmospheric Administration.  All rights        #
-#       reserved.  WAVEWATCH III is a trademark of the NWS.                 #
-#       No unauthorized use without permission.                             #
-#                                                                           #
-#############################################################################
- 
- Input directory: /home/ed/ww3/regtests/ww3_tp2.1/input
- Switch file: /home/ed/ww3/regtests/ww3_tp2.1/input/switch_PR1_MPI
- 
- 
-+--------------------+
-|  Grid preprocessor |
-+--------------------+
- 
-   Processing /home/ed/ww3/regtests/ww3_tp2.1/input/ww3_grid.inp
-   Screen output routed to /home/ed/ww3/regtests/ww3_tp2.1/work_PR1_MPI/ww3_grid.out
- 
-+--------------------+
-| Initial conditions |
-+--------------------+
- 
-   Processing /home/ed/ww3/regtests/ww3_tp2.1/input/ww3_strt.inp
-   Screen output routed to /home/ed/ww3/regtests/ww3_tp2.1/work_PR1_MPI/ww3_strt.out
- 
-+--------------------+
-|    Main program    |
-+--------------------+
- 
-   Processing /home/ed/ww3/regtests/ww3_tp2.1/input/ww3_shel.inp
-   Screen output copied to /home/ed/ww3/regtests/ww3_tp2.1/work_PR1_MPI/ww3_shel.out
-
-                     *** WAVEWATCH III Program shell ***      
-               ===============================================
-
-  Comment character is '$'
-
-
-  Input fields : 
- --------------------------------------------------
-       water levels   ---/NO                      
-       currents       ---/NO                      
-       winds          ---/NO                      
-       ice fields     ---/NO                      
-       momentum       ---/NO                      
-       air density    ---/NO                      
-       mean param.    ---/NO                      
-       1D spectra     ---/NO                      
-       2D spectra     ---/NO                      
- 
-            Fields   : Wave height         
-                       Peak frequency      
-                       Mean wave dir. a1b1 
-                       Peak direction      
-            Fields   : no fields defined
-
-  Initializations :
- --------------------------------------------------
-
-  Time interval : 
- --------------------------------------------------
-       Starting time : 1968/06/06 00:00:00 UTC
-       Ending time   : 1968/06/06 05:00:00 UTC
-
-
-  Output requests : 
- --------------------------------------------------
-       No dedicated output process, any file system.
-
-       Type 1 : Fields of mean wave parameters
-      -----------------------------------------
-            From     : 1968/06/06 00:00:00 UTC
-            To       : 1968/06/08 00:00:00 UTC
-            Interval :            00:06:00
-
-            output dates out of run dates : Restart files second request deactivated
-       Wave model ...
-
-  Running model without input fields
- --------------------------------------------------
-
-  WAVEWATCH III calculating for 1968/06/06 00:00:00 UTC at 06:08:54
-
- *** WAVEWATCH III WARNING IN W3IOBC : 
-     INPUT FILE WITH BOUNDARY CONDITIONS NOT FOUND
-     BOUNDARY CONDITIONS WILL NOT BE UPDATED     1
-
-  WAVEWATCH III calculating for 1968/06/06 00:06:00 UTC at 06:08:54
-  WAVEWATCH III calculating for 1968/06/06 00:12:00 UTC at 06:08:54
-  WAVEWATCH III calculating for 1968/06/06 00:18:00 UTC at 06:08:54
-  WAVEWATCH III calculating for 1968/06/06 00:24:00 UTC at 06:08:54
-  WAVEWATCH III calculating for 1968/06/06 00:30:00 UTC at 06:08:54
-  WAVEWATCH III calculating for 1968/06/06 00:36:00 UTC at 06:08:54
-  WAVEWATCH III calculating for 1968/06/06 00:42:00 UTC at 06:08:54
-  WAVEWATCH III calculating for 1968/06/06 00:48:00 UTC at 06:08:54
-  WAVEWATCH III calculating for 1968/06/06 00:54:00 UTC at 06:08:54
-  WAVEWATCH III calculating for 1968/06/06 01:00:00 UTC at 06:08:54
-  WAVEWATCH III calculating for 1968/06/06 01:06:00 UTC at 06:08:55
-  WAVEWATCH III calculating for 1968/06/06 01:12:00 UTC at 06:08:55
-  WAVEWATCH III calculating for 1968/06/06 01:18:00 UTC at 06:08:55
-  WAVEWATCH III calculating for 1968/06/06 01:24:00 UTC at 06:08:55
-  WAVEWATCH III calculating for 1968/06/06 01:30:00 UTC at 06:08:55
-  WAVEWATCH III calculating for 1968/06/06 01:36:00 UTC at 06:08:55
-  WAVEWATCH III calculating for 1968/06/06 01:42:00 UTC at 06:08:55
-  WAVEWATCH III calculating for 1968/06/06 01:48:00 UTC at 06:08:55
-  WAVEWATCH III calculating for 1968/06/06 01:54:00 UTC at 06:08:55
-  WAVEWATCH III calculating for 1968/06/06 02:00:00 UTC at 06:08:55
-  WAVEWATCH III calculating for 1968/06/06 02:06:00 UTC at 06:08:55
-  WAVEWATCH III calculating for 1968/06/06 02:12:00 UTC at 06:08:55
-  WAVEWATCH III calculating for 1968/06/06 02:18:00 UTC at 06:08:55
-  WAVEWATCH III calculating for 1968/06/06 02:24:00 UTC at 06:08:55
-  WAVEWATCH III calculating for 1968/06/06 02:30:00 UTC at 06:08:55
-  WAVEWATCH III calculating for 1968/06/06 02:36:00 UTC at 06:08:55
-  WAVEWATCH III calculating for 1968/06/06 02:42:00 UTC at 06:08:55
-  WAVEWATCH III calculating for 1968/06/06 02:48:00 UTC at 06:08:55
-  WAVEWATCH III calculating for 1968/06/06 02:54:00 UTC at 06:08:55
-  WAVEWATCH III calculating for 1968/06/06 03:00:00 UTC at 06:08:55
-  WAVEWATCH III calculating for 1968/06/06 03:06:00 UTC at 06:08:56
-  WAVEWATCH III calculating for 1968/06/06 03:12:00 UTC at 06:08:56
-  WAVEWATCH III calculating for 1968/06/06 03:18:00 UTC at 06:08:56
-  WAVEWATCH III calculating for 1968/06/06 03:24:00 UTC at 06:08:56
-  WAVEWATCH III calculating for 1968/06/06 03:30:00 UTC at 06:08:56
-  WAVEWATCH III calculating for 1968/06/06 03:36:00 UTC at 06:08:56
-  WAVEWATCH III calculating for 1968/06/06 03:42:00 UTC at 06:08:56
-  WAVEWATCH III calculating for 1968/06/06 03:48:00 UTC at 06:08:56
-  WAVEWATCH III calculating for 1968/06/06 03:54:00 UTC at 06:08:56
-  WAVEWATCH III calculating for 1968/06/06 04:00:00 UTC at 06:08:56
-  WAVEWATCH III calculating for 1968/06/06 04:06:00 UTC at 06:08:56
-  WAVEWATCH III calculating for 1968/06/06 04:12:00 UTC at 06:08:56
-  WAVEWATCH III calculating for 1968/06/06 04:18:00 UTC at 06:08:56
-  WAVEWATCH III calculating for 1968/06/06 04:24:00 UTC at 06:08:56
-  WAVEWATCH III calculating for 1968/06/06 04:30:00 UTC at 06:08:56
-  WAVEWATCH III calculating for 1968/06/06 04:36:00 UTC at 06:08:56
-  WAVEWATCH III calculating for 1968/06/06 04:42:00 UTC at 06:08:56
-  WAVEWATCH III calculating for 1968/06/06 04:48:00 UTC at 06:08:56
-  WAVEWATCH III calculating for 1968/06/06 04:54:00 UTC at 06:08:56
-  WAVEWATCH III calculating for 1968/06/06 05:00:00 UTC at 06:08:56
-  WAVEWATCH III reached the end of a computation loop at 06:08:56
-
-  Initialization time :      0.79 s
-  Elapsed time        :      3.09 s
-
-  End of program 
- ====================================
-         WAVEWATCH III Program shell 
-
-[WARNING] yaksa: 2 leaked handle pool objects
-[WARNING] yaksa: 2 leaked handle pool objects
-[WARNING] yaksa: 2 leaked handle pool objects
-[WARNING] yaksa: 2 leaked handle pool objects
-[WARNING] yaksa: 2 leaked handle pool objects
-[WARNING] yaksa: 2 leaked handle pool objects
-[WARNING] yaksa: 2 leaked handle pool objects
-[WARNING] yaksa: 2 leaked handle pool objects
-[WARNING] yaksa: 2 leaked handle pool objects
-[WARNING] yaksa: 2 leaked handle pool objects
-[WARNING] yaksa: 2 leaked handle pool objects
-[WARNING] yaksa: 2 leaked handle pool objects
-[WARNING] yaksa: 2 leaked handle pool objects
-[WARNING] yaksa: 2 leaked handle pool objects
-[WARNING] yaksa: 2 leaked handle pool objects
-[WARNING] yaksa: 2 leaked handle pool objects
-[WARNING] yaksa: 2 leaked handle pool objects
-[WARNING] yaksa: 2 leaked handle pool objects
-[WARNING] yaksa: 2 leaked handle pool objects
-[WARNING] yaksa: 2 leaked handle pool objects
-[WARNING] yaksa: 2 leaked handle pool objects
-[WARNING] yaksa: 2 leaked handle pool objects
-[WARNING] yaksa: 2 leaked handle pool objects
-[WARNING] yaksa: 2 leaked handle pool objects
- 
-+--------------------+
-|   Gridded output   |
-+--------------------+
- 
-   Processing /home/ed/ww3/regtests/ww3_tp2.1/input/ww3_outf_flds_hrly.inp
-   Screen output routed to /home/ed/ww3/regtests/ww3_tp2.1/work_PR1_MPI/ww3_outf_flds_hrly.out
-   Processing /home/ed/ww3/regtests/ww3_tp2.1/input/ww3_outf.inp
-   Screen output routed to /home/ed/ww3/regtests/ww3_tp2.1/work_PR1_MPI/ww3_outf.out
- 
-+--------------------+
-| NC Gridded output  |
-+--------------------+
- 
-   Processing /home/ed/ww3/regtests/ww3_tp2.1/input/ww3_ounf_flds_hrly.inp
-   Screen output routed to /home/ed/ww3/regtests/ww3_tp2.1/work_PR1_MPI/ww3_ounf_flds_hrly.out
-   Processing /home/ed/ww3/regtests/ww3_tp2.1/input/ww3_ounf.inp
-   Screen output routed to /home/ed/ww3/regtests/ww3_tp2.1/work_PR1_MPI/ww3_ounf.out
- 
- 
-Files in /home/ed/ww3/regtests/ww3_tp2.1/work_PR1_MPI :
- 
-total 3024
-drwxrwxr-x 9 ed ed    4096 Apr  2 06:08 build
--rw-rw-r-- 1 ed ed  395213 Apr  2 06:08 build.log
-drwxrwxr-x 9 ed ed    4096 Apr  2 06:07 build_SHRD
-drwxrwxr-x 2 ed ed    4096 Apr  2 06:07 exe
--rw-rw-r-- 1 ed ed      32 Apr  2 06:08 finished
--rw-rw-r-- 1 ed ed    5649 Apr  2 06:08 log.ww3
--rw-rw-r-- 1 ed ed   47737 Apr  2 06:08 mod_def.ww3
--rw-rw-r-- 1 ed ed 1214926 Apr  2 06:08 out_grd.ww3
--rw-rw-r-- 1 ed ed  280800 Apr  2 06:08 restart.ww3
--rw-rw-r-- 1 ed ed     443 Apr  2 06:08 time_count.txt
--rw-rw-r-- 1 ed ed  384096 Apr  2 06:08 ww3.196806.nc
--rw-rw-r-- 1 ed ed   22358 Apr  2 06:08 ww3.68060600.dir
--rw-rw-r-- 1 ed ed   22358 Apr  2 06:08 ww3.68060600.fp
--rw-rw-r-- 1 ed ed   22358 Apr  2 06:08 ww3.68060600.hs
--rw-rw-r-- 1 ed ed   22358 Apr  2 06:08 ww3.68060601.dir
--rw-rw-r-- 1 ed ed   22358 Apr  2 06:08 ww3.68060601.fp
--rw-rw-r-- 1 ed ed   22358 Apr  2 06:08 ww3.68060601.hs
--rw-rw-r-- 1 ed ed   22358 Apr  2 06:08 ww3.68060602.dir
--rw-rw-r-- 1 ed ed   22358 Apr  2 06:08 ww3.68060602.fp
--rw-rw-r-- 1 ed ed   22358 Apr  2 06:08 ww3.68060602.hs
--rw-rw-r-- 1 ed ed   22358 Apr  2 06:08 ww3.68060603.dir
--rw-rw-r-- 1 ed ed   22358 Apr  2 06:08 ww3.68060603.fp
--rw-rw-r-- 1 ed ed   22358 Apr  2 06:08 ww3.68060603.hs
--rw-rw-r-- 1 ed ed   22358 Apr  2 06:08 ww3.68060604.dir
--rw-rw-r-- 1 ed ed   22358 Apr  2 06:08 ww3.68060604.fp
--rw-rw-r-- 1 ed ed   22358 Apr  2 06:08 ww3.68060604.hs
--rw-rw-r-- 1 ed ed   22358 Apr  2 06:08 ww3.68060605.dir
--rw-rw-r-- 1 ed ed   22358 Apr  2 06:08 ww3.68060605.fp
--rw-rw-r-- 1 ed ed   22358 Apr  2 06:08 ww3.68060605.hs
--rw-rw-r-- 1 ed ed   13246 Apr  2 06:08 ww3_grid.out
--rw-rw-r-- 1 ed ed    3040 Apr  2 06:08 ww3_ounf_flds_hrly.out
--rw-rw-r-- 1 ed ed    6355 Apr  2 06:08 ww3_ounf.out
--rw-rw-r-- 1 ed ed    1776 Apr  2 06:08 ww3_outf_flds_hrly.out
--rw-rw-r-- 1 ed ed  247323 Apr  2 06:08 ww3_outf.out
--rw-rw-r-- 1 ed ed    5551 Apr  2 06:08 ww3_shel.out
--rw-rw-r-- 1 ed ed    3405 Apr  2 06:08 ww3_strt.out
- 
- 
-                    ==================================   
-                  ======>  END OF WAVEWATCH III  <====== 
-                    ==================================   
- 
- -## References - -https://github.com/NOAA-EMC/WW3/wiki/Developer-Guide#regression-testing-in-wavewatch-iii - -WaveWatch III Installation, retrieved from https://www.youtube.com/watch?v=cyyIKqm9R2s&t=1s on Apr 2, 2024. - -file:///home/ed/Downloads/10.WAVEWATCHIII_install.Tolman.pdf \ No newline at end of file From a8741f3d40024d0df1d61bbb522119095d2ed386 Mon Sep 17 00:00:00 2001 From: Jessica Meixner Date: Thu, 18 Apr 2024 12:27:34 +0000 Subject: [PATCH 120/126] update error messages to use write statements and add line numbers --- model/src/w3iopomd.F90 | 69 ++++++++++++------------------------------ 1 file changed, 20 insertions(+), 49 deletions(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index 6c4c04cc9..74d0ce1a4 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -5,6 +5,8 @@ !> #include "w3macros.h" +#define CHECK_ERR(I) CHECK_ERROR(I, __LINE__) +#define nf90_err(errcode) nf90_err(errcode, __LINE__) !/ ------------------------------------------------------------------- / !> !> @brief Process point output. @@ -1123,18 +1125,23 @@ END SUBROUTINE W3IOPE !> !> @author Edward Hartnett @date 1-Nov-2023 !> - integer function nf90_err(errcode) + integer function nf90_err(errcode, ILINE) use netcdf + USE W3ODATMD, ONLY: NDSE implicit none integer, intent(in) :: errcode nf90_err = errcode if(errcode /= nf90_noerr) then - print *, 'Error: ', trim(nf90_strerror(errcode)) - return + WRITE(NDSE,*) ' *** WAVEWATCH III ERROR IN W3IOPO :' + WRITE(NDSE,*) ' LINE NUMBER ', ILINE + WRITE(NDSE,*) ' NETCDF ERROR MESSAGE: ' + WRITE(NDSE,*) 'Error: ', trim(nf90_strerror(errcode)) + return endif end function nf90_err + !> Read point output in netCDF format. !> !> @param[out] IOTST Test indictor for reading. @@ -1288,21 +1295,13 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD_IN, filename, ncerr) count = (/ d_vsize_len, 1 /)) if (nf90_err(ncerr) .ne. 0) return - ncerr = nf90_inq_varid(fh, VNAME_IW, v_iw) - if (nf90_err(ncerr) .ne. 0) return - ncerr = nf90_get_var(fh, v_iw, IW, start = (/ 1, IPASS/), & - count = (/ NOPTS, 1 /)) - if (nf90_err(ncerr) .ne. 0) return - ncerr = nf90_inq_varid(fh, VNAME_II, v_ii) - if (nf90_err(ncerr) .ne. 0) return - ncerr = nf90_get_var(fh, v_ii, II, start = (/ 1, IPASS/), & - count = (/ NOPTS, 1 /)) - if (nf90_err(ncerr) .ne. 0) return - ncerr = nf90_inq_varid(fh, VNAME_IL, v_il) - if (nf90_err(ncerr) .ne. 0) return - ncerr = nf90_get_var(fh, v_il, IL, start = (/ 1, IPASS/), & - count = (/ NOPTS, 1 /)) - if (nf90_err(ncerr) .ne. 0) return + ! set IW, II and IL to 0, + ! These values are set to 0 in binary file and have been removed + ! from netcdf file. Possible can be completely removed. + IW = 0 + II = 0 + IL = 0 + ncerr = nf90_inq_varid(fh, VNAME_DPO, v_dpo) if (nf90_err(ncerr) .ne. 0) return ncerr = nf90_get_var(fh, v_dpo, DPO, start = (/ 1, IPASS/), & @@ -1495,12 +1494,6 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) if (nf90_err(ncerr) .ne. 0) return ! Define vars with nopts and time as dimensions - ncerr = nf90_def_var(fh, VNAME_IW, NF90_INT, (/d_nopts, d_time/), v_iw) - if (nf90_err(ncerr) .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_II, NF90_INT, (/d_nopts, d_time/), v_ii) - if (nf90_err(ncerr) .ne. 0) return - ncerr = nf90_def_var(fh, VNAME_IL, NF90_INT, (/d_nopts, d_time/), v_il) - if (nf90_err(ncerr) .ne. 0) return ncerr = nf90_def_var(fh, VNAME_DPO, NF90_FLOAT, (/d_nopts, d_time/), v_dpo) if (nf90_err(ncerr) .ne. 0) return ncerr = nf90_def_var(fh, VNAME_WAO, NF90_FLOAT, (/d_nopts, d_time/), v_wao) @@ -1580,20 +1573,8 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) count = (/ 2, 1 /)) if (nf90_err(ncerr) .ne. 0) return - ! set IW, II and IL to 0 because it is not used and gives & - ! outlier values in out_pnt.points - TODO: REMOVE??? - IW = 0 - II = 0 - IL = 0 - ! If itime > 1 need to inquire varid IF ( itime > 1 ) THEN - ncerr = nf90_inq_varid(fh, VNAME_IW, v_iw) - if (nf90_err(ncerr) .ne. 0) return - ncerr = nf90_inq_varid(fh, VNAME_II, v_ii) - if (nf90_err(ncerr) .ne. 0) return - ncerr = nf90_inq_varid(fh, VNAME_IL, v_il) - if (ncerr .ne. 0) return ncerr = nf90_inq_varid(fh, VNAME_DPO, v_dpo) if (nf90_err(ncerr) .ne. 0) return ncerr = nf90_inq_varid(fh, VNAME_WAO, v_wao) @@ -1630,18 +1611,6 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) if (nf90_err(ncerr) .ne. 0) return END IF - ncerr = nf90_put_var(fh, v_iw, IW, start = (/ 1, itime/), & - count = (/ NOPTS, 1 /)) - if (nf90_err(ncerr) .ne. 0) return - - ncerr = nf90_put_var(fh, v_ii, II, start = (/ 1, itime/), & - count = (/ nopts, 1 /)) - if (nf90_err(ncerr) .ne. 0) return - - ncerr = nf90_put_var(fh, v_il, IL, start = (/ 1, itime/), & - count = (/ nopts, 1 /)) - if (nf90_err(ncerr) .ne. 0) return - ncerr = nf90_put_var(fh, v_dpo, DPO, start = (/ 1, itime/), & count = (/ nopts, 1 /)) if (nf90_err(ncerr) .ne. 0) return @@ -1836,7 +1805,9 @@ SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD & CALL W3IOPON_WRITE(OFILES(2), IMOD, filename, ncerr) ENDIF if (nf90_err(ncerr) .ne. 0) then - print *, nf90_strerror(ncerr) + WRITE(NDSE,*) ' *** WAVEWATCH III ERROR IN W3IOPO :' + WRITE(NDSE,*) 'Nonzero return at end of W3IOPON' + WRITE(NDSE,*) 'Error: ', trim(nf90_strerror(ncerr)) CALL EXTCDE(21) endif From 2e7105ffea71b2d58d3084a42146a82867204857 Mon Sep 17 00:00:00 2001 From: Jessica Meixner Date: Thu, 18 Apr 2024 14:12:15 +0000 Subject: [PATCH 121/126] update error messages to show line number for easier debugging following the updates from ww3_prnc --- model/src/w3iopomd.F90 | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index 74d0ce1a4..a859f6fb0 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -5,8 +5,7 @@ !> #include "w3macros.h" -#define CHECK_ERR(I) CHECK_ERROR(I, __LINE__) -#define nf90_err(errcode) nf90_err(errcode, __LINE__) +#define nf90_err(ncerr) nf90_err_check(ncerr, __LINE__) !/ ------------------------------------------------------------------- / !> !> @brief Process point output. @@ -1125,13 +1124,13 @@ END SUBROUTINE W3IOPE !> !> @author Edward Hartnett @date 1-Nov-2023 !> - integer function nf90_err(errcode, ILINE) + integer function nf90_err_check(errcode, ILINE) use netcdf USE W3ODATMD, ONLY: NDSE implicit none - integer, intent(in) :: errcode + integer, intent(in) :: errcode, ILINE - nf90_err = errcode + nf90_err_check = errcode if(errcode /= nf90_noerr) then WRITE(NDSE,*) ' *** WAVEWATCH III ERROR IN W3IOPO :' WRITE(NDSE,*) ' LINE NUMBER ', ILINE @@ -1139,7 +1138,7 @@ integer function nf90_err(errcode, ILINE) WRITE(NDSE,*) 'Error: ', trim(nf90_strerror(errcode)) return endif - end function nf90_err + end function nf90_err_check !> Read point output in netCDF format. From fa4509bc0edc5e1803f46d51a9da0731913fc1e1 Mon Sep 17 00:00:00 2001 From: Jessica Meixner Date: Thu, 18 Apr 2024 20:45:58 +0000 Subject: [PATCH 122/126] fix for a few multi tests to run --- model/src/w3iopomd.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index a859f6fb0..63d364f7f 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -1542,11 +1542,11 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) ! Write the data with NOPTS as a dimension. (no time dimension) if (associated(PTLOC)) then - ncerr = nf90_put_var(fh, v_ptloc, PTLOC) + ncerr = nf90_put_var(fh, v_ptloc, PTLOC(:,1:NOPTS)) if (nf90_err(ncerr) .ne. 0) return endif if (associated(PTNME)) then - ncerr = nf90_put_var(fh, v_ptnme, PTNME) + ncerr = nf90_put_var(fh, v_ptnme, PTNME(1:NOPTS)) if (nf90_err(ncerr) .ne. 0) return endif From 40fa41985a2a5e26e6a512a3b320790b25ba480c Mon Sep 17 00:00:00 2001 From: Jessica Meixner Date: Thu, 2 May 2024 12:29:21 +0000 Subject: [PATCH 123/126] some clean up --- model/src/w3iopomd.F90 | 76 +++++++++--------------------------------- model/src/w3wavemd.F90 | 6 ++-- 2 files changed, 18 insertions(+), 64 deletions(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index 63d364f7f..7bc1f0ef6 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -158,15 +158,6 @@ MODULE W3IOPOMD !> Variable name for the netCDF point output file, for TIME. character(*), parameter, private :: VNAME_TIME = 'TIME' - !> Variable name for the netCDF point output file, for IW. - character(*), parameter, private :: VNAME_IW = 'IW' - - !> Variable name for the netCDF point output file, for II. - character(*), parameter, private :: VNAME_II = 'II' - - !> Variable name for the netCDF point output file, for IL. - character(*), parameter, private :: VNAME_IL = 'IL' - !> Variable name for the netCDF point output file, for DPO. character(*), parameter, private :: VNAME_DPO = 'DPO' @@ -1144,7 +1135,7 @@ end function nf90_err_check !> Read point output in netCDF format. !> !> @param[out] IOTST Test indictor for reading. - !> @param[in] IMOD Model number for W3GDAT etc. + !> @param[in] IMOD_IN Model number for W3GDAT etc. !> @param[in] filename Name of file to read. !> @param[inout] ncerr Error code, 0 for success, netCDF error code !> otherwise. @@ -1178,7 +1169,7 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD_IN, filename, ncerr) integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen, d_time integer :: d_nopts_len, d_nspec_len, d_vsize_len, d_namelen_len, d_grdidlen_len, d_time_len integer :: v_idtst, v_vertst, v_nk, v_nth, v_ptloc, v_ptnme, v_time - integer :: v_iw, v_ii, v_il, v_dpo, v_wao, v_wdo + integer :: v_dpo, v_wao, v_wdo #ifdef W3_FLX5 integer :: v_tauao,v_taudo, v_dairo #endif @@ -1408,7 +1399,6 @@ END SUBROUTINE W3IOPON_READ !> !> @brief Write point output in netCDF format. !> - !> @param[in] IMOD Model number for W3GDAT etc. !> @param[in] filename Name of file to write. !> @param[in] timestep_only Will be 0 if whole model run should be !> written, 1 if only one timestep should be written. @@ -1417,12 +1407,12 @@ END SUBROUTINE W3IOPON_READ !> !> @author Edward Hartnett @date 1-Nov-2023 !> - SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) - use netcdf - USE W3GDATMD, ONLY: NTH, NK, NSPEC, FILEXT + SUBROUTINE W3IOPON_WRITE(timestep_only,filename, ncerr) + USE NETCDF + USE W3GDATMD, ONLY: NTH, NK, NSPEC USE W3WDATMD, ONLY: TIME USE W3ODATMD, ONLY: NDST, NDSE, IPASS => IPASS2, NOPTS, IPTINT, & - IL, IW, II, PTLOC, PTIFAC, DPO, WAO, WDO, & + PTLOC, PTIFAC, DPO, WAO, WDO, & ASO, CAO, CDO, SPCO, PTNME, O2INIT, FNMPRE, & GRDID, ICEO, ICEHO, ICEFO #ifdef W3_FLX5 @@ -1434,13 +1424,12 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr) IMPLICIT NONE integer, intent(in) :: timestep_only ! 1 if only timestep should be written. - INTEGER, INTENT(IN) :: IMOD character(*), intent(in) :: filename integer, intent(inout) :: ncerr integer :: ndim, nvar, fmt, itime, fh integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen, d_time integer :: v_idtst, v_vertst, v_nk, v_nth, v_ptloc, v_ptnme, v_time - integer :: v_iw, v_ii, v_il, v_dpo, v_wao, v_wdo + integer :: v_dpo, v_wao, v_wdo #ifdef W3_FLX5 integer :: v_tauao, v_taudo, v_dairo #endif @@ -1700,34 +1689,16 @@ END SUBROUTINE W3IOPON_WRITE !> - 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 Edward Hartnett @date 1-Nov-2023 - SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD & -#ifdef W3_ASCII - ,NDSOA & -#endif - ) + SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD) USE W3GDATMD, ONLY: W3SETG USE W3WDATMD, ONLY: W3SETW - USE W3ODATMD, ONLY: W3SETO, W3DMO2 - !/ - USE W3GDATMD, ONLY: NTH, NK, NSPEC, FILEXT + USE W3ODATMD, ONLY: W3SETO + USE W3GDATMD, ONLY: FILEXT USE W3WDATMD, ONLY: TIME - USE W3ODATMD, ONLY: NDST, NDSE, IPASS => IPASS2, NOPTS, IPTINT, & - IW, PTLOC, PTIFAC, WAO, WDO, & - SPCO, PTNME, O2INIT, FNMPRE -#ifdef W3_FLX5 - USE W3ODATMD, ONLY: TAUAO, TAUDO, DAIRO -#endif - USE W3ODATMD, ONLY : OFILES - !/ -#ifdef W3_SETUP - USE W3ODATMD, ONLY: ZET_SETO -#endif - !/ + USE W3ODATMD, ONLY: NDST, NDSE, IPASS => IPASS2, FNMPRE + USE W3ODATMD, ONLY: OFILES USE W3SERVMD, ONLY: EXTCDE #ifdef W3_S USE W3SERVMD, ONLY: STRACE @@ -1739,18 +1710,16 @@ SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD & INTEGER, INTENT(IN) :: NDSOP INTEGER, INTENT(OUT) :: IOTST INTEGER, INTENT(IN), OPTIONAL :: IMOD -#ifdef W3_ASCII - INTEGER, INTENT(IN), OPTIONAL :: NDSOA -#endif CHARACTER(LEN=15) :: TIMETAG - INTEGER :: IGRD, MK, MTH + INTEGER :: IGRD character(len = 124) :: filename integer :: ncerr #ifdef W3_S CALL STRACE (IENT, 'W3IOPON') #endif + ! IPASS essentially is the time variable dimension IPASS = IPASS + 1 @@ -1774,19 +1743,6 @@ SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD & CALL EXTCDE(1) END IF -!JDM Not sure this next section is really needed in the necdf context, -!commenting out but leaving it as a placeholder for now - -! ! Ensure read/write are not mixed -! IF ( IPASS.EQ.1 .AND. OFILES(2) .EQ. 0 ) THEN -! WRITE = INXOUT.EQ.'WRITE' -! ELSE -! IF ( WRITE .AND. INXOUT.EQ.'READ' ) THEN -! WRITE (NDSE,901) INXOUT -! CALL EXTCDE ( 2 ) -! END IF -! END IF - ! Determine filename. filename = '' IF ( OFILES(2) .EQ. 1 ) THEN @@ -1801,7 +1757,7 @@ SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD & IF (INXOUT .EQ. 'READ') THEN CALL W3IOPON_READ(IOTST, IMOD, filename, ncerr) ELSE - CALL W3IOPON_WRITE(OFILES(2), IMOD, filename, ncerr) + CALL W3IOPON_WRITE(OFILES(2), filename, ncerr) ENDIF if (nf90_err(ncerr) .ne. 0) then WRITE(NDSE,*) ' *** WAVEWATCH III ERROR IN W3IOPO :' @@ -1816,8 +1772,6 @@ SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD & 900 FORMAT (/' *** WAVEWATCH III ERROR IN W3IOPO :'/ & ' ILEGAL INXOUT VALUE: ',A/) -! 901 FORMAT (/' *** WAVEWATCH III ERROR IN W3IOPO :'/ & -! ' MIXED READ/WRITE, LAST REQUEST: ',A/) END SUBROUTINE W3IOPON !/ ------------------------------------------------------------------- / diff --git a/model/src/w3wavemd.F90 b/model/src/w3wavemd.F90 index 095e800de..e8c7112e8 100644 --- a/model/src/w3wavemd.F90 +++ b/model/src/w3wavemd.F90 @@ -2604,9 +2604,9 @@ SUBROUTINE W3WAVE ( IMOD, ODAT, TEND, STAMP, NO_OUT & ! CALL W3IOPE ( VA ) CALL W3IOPON ( 'WRITE', NDS(8), ITEST, IMOD & -#ifdef W3_ASCII - ,NDS(15) & -#endif +!#ifdef W3_ASCII +! ,NDS(15) & +!#endif ) END IF ! From 4566f92823b227e4a3651202a021b129a2eb2498 Mon Sep 17 00:00:00 2001 From: JessicaMeixner-NOAA Date: Tue, 7 May 2024 13:44:49 -0500 Subject: [PATCH 124/126] add a check on version numbers --- model/src/w3iopomd.F90 | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index 7bc1f0ef6..2c5ad3110 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -1178,6 +1178,8 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD_IN, filename, ncerr) #endif integer :: v_aso, v_cao, v_cdo, v_iceo integer :: v_iceho, v_icefo, v_grdid, v_spco + CHARACTER(LEN=31) :: IDTST + CHARACTER(LEN=10) :: VERTST IOTST = 0 @@ -1192,16 +1194,19 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD_IN, filename, ncerr) if (nf90_err(ncerr) .ne. 0) return ! Read and check the version: - ! TO DO add reading of IDTST and VERTST and make checks: - ! IF ( IDTST .NE. IDSTR ) THEN - ! WRITE (NDSE,902) IDTST, IDSTR - ! CALL EXTCDE ( 10 ) - ! END IF - ! IF ( VERTST .NE. VEROPT ) THEN - ! WRITE (NDSE,903) VERTST, VEROPT - ! CALL EXTCDE ( 11 ) - ! END IF + ncerr = nf90_get_att(fh, 'title', IDTST) + if (nf90_err(ncerr) .ne. 0) return + ncerr = nf90_put_att(fh, 'version', VERTST) + if (nf90_err(ncerr) .ne. 0) return + IF ( IDTST .NE. IDSTR ) THEN + WRITE (NDSE,902) IDTST, IDSTR + CALL EXTCDE ( 10 ) + END IF + IF ( VERTST .NE. VEROPT ) THEN + WRITE (NDSE,903) VERTST, VEROPT + CALL EXTCDE ( 11 ) + END IF ! Read the dimension information for NOPTS. ncerr = nf90_inq_dimid(fh, DNAME_NOPTS, d_nopts) @@ -1439,6 +1444,7 @@ SUBROUTINE W3IOPON_WRITE(timestep_only,filename, ncerr) integer :: v_aso, v_cao, v_cdo, v_iceo integer :: v_iceho, v_icefo, v_grdid, v_spco + !If first pass, or if you are writting a file for every time-step: IF ( IPASS.EQ.1 .OR. timestep_only.EQ.1 ) THEN ! Create the netCDF file. From 3f1db349105bf905b104e67f16adfd5f2e8da460 Mon Sep 17 00:00:00 2001 From: JessicaMeixner-NOAA Date: Wed, 8 May 2024 07:53:16 -0500 Subject: [PATCH 125/126] minor update --- model/src/w3iopomd.F90 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index 2c5ad3110..d16a1f7b3 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -1116,7 +1116,7 @@ END SUBROUTINE W3IOPE !> @author Edward Hartnett @date 1-Nov-2023 !> integer function nf90_err_check(errcode, ILINE) - use netcdf + USE NetCDF USE W3ODATMD, ONLY: NDSE implicit none integer, intent(in) :: errcode, ILINE @@ -1131,7 +1131,6 @@ integer function nf90_err_check(errcode, ILINE) endif end function nf90_err_check - !> Read point output in netCDF format. !> !> @param[out] IOTST Test indictor for reading. From bd4dbb3f5bc0295b192a2f21a4b715acc040b16f Mon Sep 17 00:00:00 2001 From: JessicaMeixner-NOAA Date: Wed, 8 May 2024 07:58:31 -0500 Subject: [PATCH 126/126] test update to ci --- .github/workflows/regtest_gnu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/regtest_gnu.yml b/.github/workflows/regtest_gnu.yml index 977a2bddc..81d1317a3 100644 --- a/.github/workflows/regtest_gnu.yml +++ b/.github/workflows/regtest_gnu.yml @@ -91,7 +91,7 @@ jobs: spack ~/.spack work_oasis3-mct - key: spack-${{ runner.os }}-${{ env.cache_key }}-${{ hashFiles('ww3/model/ci/spack_gnu.yaml') }} + key: spack2-${{ runner.os }}-${{ env.cache_key }}-${{ hashFiles('ww3/model/ci/spack_gnu.yaml') }} - name: build-ww3 run: |