From 24679ed1b2f41cf08db3d05757835c95da71deee Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Mon, 6 Nov 2023 09:51:23 -0700 Subject: [PATCH 01/17] adding code coverage --- .github/workflows/io_gnu.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/io_gnu.yml b/.github/workflows/io_gnu.yml index d7311bc20..2c4230446 100644 --- a/.github/workflows/io_gnu.yml +++ b/.github/workflows/io_gnu.yml @@ -22,6 +22,11 @@ jobs: runs-on: ubuntu-latest steps: + - name: install-dependencies + run: | + sudo apt-get update + sudo apt-get install doxygen gcovr valgrind + - name: checkout-ww3 if: steps.cache-env.outputs.cache-hit != 'true' uses: actions/checkout@v3 @@ -99,6 +104,17 @@ jobs: mkdir build && cd build pwd echo "${GITHUB_WORKSPACE}" - cmake .. -DSWITCH=${GITHUB_WORKSPACE}/ww3/model/tests/data/switch.io + cmake -DSWITCH=${GITHUB_WORKSPACE}/ww3/model/tests/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 ctest --verbose --output-on-failure --rerun-failed + gcovr --root .. -v --html-details --exclude ../tests --exclude CMakeFiles --print-summary -o test-coverage.html &> /dev/null + + - name: upload-test-coverage + uses: actions/upload-artifact@v3 + with: + name: ww3-test-coverage + path: | + ww3/build/*.html + ww3/build/*.css + + From 4c99eed00e6b12fde8892f39153f34f64cf06e04 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Mon, 6 Nov 2023 09:54:36 -0700 Subject: [PATCH 02/17] working on CI workflow --- .github/workflows/io_gnu.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/io_gnu.yml b/.github/workflows/io_gnu.yml index 2c4230446..5b3f3f3a0 100644 --- a/.github/workflows/io_gnu.yml +++ b/.github/workflows/io_gnu.yml @@ -95,6 +95,7 @@ jobs: - name: build-ww3 run: | + set -x source spack/share/spack/setup-env.sh spack env activate ww3-gnu cd ww3 @@ -104,6 +105,7 @@ jobs: mkdir build && cd build pwd echo "${GITHUB_WORKSPACE}" + which ncdump cmake -DSWITCH=${GITHUB_WORKSPACE}/ww3/model/tests/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 ctest --verbose --output-on-failure --rerun-failed From 1b7be0d18598aa45142d11dad3d3aa67dbf1273b Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Mon, 6 Nov 2023 10:00:29 -0700 Subject: [PATCH 03/17] working on CI workflow --- .github/workflows/io_gnu.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/io_gnu.yml b/.github/workflows/io_gnu.yml index 5b3f3f3a0..09796f799 100644 --- a/.github/workflows/io_gnu.yml +++ b/.github/workflows/io_gnu.yml @@ -22,11 +22,6 @@ jobs: runs-on: ubuntu-latest steps: - - name: install-dependencies - run: | - sudo apt-get update - sudo apt-get install doxygen gcovr valgrind - - name: checkout-ww3 if: steps.cache-env.outputs.cache-hit != 'true' uses: actions/checkout@v3 @@ -78,6 +73,11 @@ jobs: 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: From 57154512222850d78a7a9aa920a13cbb9cae58e6 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Mon, 6 Nov 2023 10:03:02 -0700 Subject: [PATCH 04/17] working on CI workflow --- .github/workflows/io_gnu.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/io_gnu.yml b/.github/workflows/io_gnu.yml index 09796f799..529f95caa 100644 --- a/.github/workflows/io_gnu.yml +++ b/.github/workflows/io_gnu.yml @@ -111,12 +111,12 @@ jobs: ctest --verbose --output-on-failure --rerun-failed gcovr --root .. -v --html-details --exclude ../tests --exclude CMakeFiles --print-summary -o test-coverage.html &> /dev/null - - name: upload-test-coverage - uses: actions/upload-artifact@v3 - with: - name: ww3-test-coverage - path: | - ww3/build/*.html - ww3/build/*.css + - name: upload-test-coverage + uses: actions/upload-artifact@v3 + with: + name: ww3-test-coverage + path: | + ww3/build/*.html + ww3/build/*.css From 4455938e53ba276ea91b9d83adcfe2351d36a548 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Mon, 6 Nov 2023 10:15:59 -0700 Subject: [PATCH 05/17] working on CI workflow --- .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 529f95caa..9973eb48c 100644 --- a/.github/workflows/io_gnu.yml +++ b/.github/workflows/io_gnu.yml @@ -109,7 +109,7 @@ jobs: cmake -DSWITCH=${GITHUB_WORKSPACE}/ww3/model/tests/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 ctest --verbose --output-on-failure --rerun-failed - gcovr --root .. -v --html-details --exclude ../tests --exclude CMakeFiles --print-summary -o test-coverage.html &> /dev/null + gcovr --root .. -v --html-details --exclude ../model/tests --exclude CMakeFiles --print-summary -o test-coverage.html &> /dev/null - name: upload-test-coverage uses: actions/upload-artifact@v3 From 4f7cd9381ef074edc4bd46229d9a727dc6ead913 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Mon, 6 Nov 2023 10:19:00 -0700 Subject: [PATCH 06/17] working on netcdf write code --- model/src/w3iopomd.F90 | 118 ++++++++++++++++++++--------------------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index ace363528..dcb8102b8 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -1079,67 +1079,67 @@ SUBROUTINE W3IOPON_WRITE (NDSOP, IMOD, filename, ncerr) ncerr = nf90_create("filename ", NF90_NETCDF4, fh) if (ncerr .ne. 0) return - ! ! Define dimensions. - ! ncerr = nf90_def_dim(fh, 'NOPTS', NOPTS, d_nopts) - ! if (ncerr .ne. 0) return - ! ncerr = nf90_def_dim(fh, 'NSPEC', NSPEC, d_nspec) - ! if (ncerr .ne. 0) return - ! ncerr = nf90_def_dim(fh, 'VSIZE', 2, d_vsize) - ! if (ncerr .ne. 0) return - ! ncerr = nf90_def_dim(fh, 'NAMELEN', 7, d_namelen) - ! if (ncerr .ne. 0) return + ! Define dimensions. + ncerr = nf90_def_dim(fh, 'NOPTS', NOPTS, d_nopts) + if (ncerr .ne. 0) return + ncerr = nf90_def_dim(fh, 'NSPEC', NSPEC, d_nspec) + if (ncerr .ne. 0) return + ncerr = nf90_def_dim(fh, 'VSIZE', 2, d_vsize) + if (ncerr .ne. 0) return + ncerr = nf90_def_dim(fh, 'NAMELEN', 7, d_namelen) + if (ncerr .ne. 0) return - ! ! Define variables. - ! ncerr = nf90_def_var(fh, 'IDTST', NF90_INT, v_idtst) - ! if (ncerr .ne. 0) return - ! ncerr = nf90_def_var(fh, 'VERTST', NF90_INT, v_vertst) - ! if (ncerr .ne. 0) return - ! ncerr = nf90_def_var(fh, 'NK', NF90_INT, v_nk) - ! if (ncerr .ne. 0) return - ! ncerr = nf90_def_var(fh, 'MTH', NF90_INT, v_mth) - ! if (ncerr .ne. 0) return + ! Define variables. + ncerr = nf90_def_var(fh, 'IDTST', NF90_INT, v_idtst) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, 'VERTST', NF90_INT, v_vertst) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, 'NK', NF90_INT, v_nk) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, 'MTH', NF90_INT, v_mth) + if (ncerr .ne. 0) return - ! ! Define vars with nopts as a dimension. - ! ncerr = nf90_def_var(fh, 'PTLOC', NF90_INT, (/d_vsize, d_nopts/), v_ptloc) - ! if (ncerr .ne. 0) return - ! ncerr = nf90_def_var(fh, 'PTNME', NF90_CHAR, (/d_namelen, d_nopts/), v_ptnme) - ! if (ncerr .ne. 0) return - ! ncerr = nf90_def_var(fh, 'IW', NF90_INT, (/d_nopts/), v_iw) - ! if (ncerr .ne. 0) return - ! ncerr = nf90_def_var(fh, 'II', NF90_INT, (/d_nopts/), v_ii) - ! if (ncerr .ne. 0) return - ! ncerr = nf90_def_var(fh, 'IL', NF90_INT, (/d_nopts/), v_il) - ! if (ncerr .ne. 0) return - ! ncerr = nf90_def_var(fh, 'DPO', NF90_INT, (/d_nopts/), v_dpo) - ! if (ncerr .ne. 0) return - ! ncerr = nf90_def_var(fh, 'WAO', NF90_INT, (/d_nopts/), v_wao) - ! if (ncerr .ne. 0) return - ! ncerr = nf90_def_var(fh, 'WDO', NF90_INT, (/d_nopts/), v_wdo) - ! if (ncerr .ne. 0) return - ! ncerr = nf90_def_var(fh, 'TAUAO', NF90_INT, (/d_nopts/), v_tauao) - ! if (ncerr .ne. 0) return - ! ncerr = nf90_def_var(fh, 'TAIDO', NF90_INT, (/d_nopts/), v_taido) - ! if (ncerr .ne. 0) return - ! ncerr = nf90_def_var(fh, 'DAIRO', NF90_INT, (/d_nopts/), v_dairo) - ! if (ncerr .ne. 0) return - ! ncerr = nf90_def_var(fh, 'ZET_SETO', NF90_INT, (/d_nopts/), v_zet_seto) - ! if (ncerr .ne. 0) return - ! ncerr = nf90_def_var(fh, 'ASO', NF90_INT, (/d_nopts/), v_aso) - ! if (ncerr .ne. 0) return - ! ncerr = nf90_def_var(fh, 'CAO', NF90_INT, (/d_nopts/), v_cao) - ! if (ncerr .ne. 0) return - ! ncerr = nf90_def_var(fh, 'CDO', NF90_INT, (/d_nopts/), v_cdo) - ! if (ncerr .ne. 0) return - ! ncerr = nf90_def_var(fh, 'ICEO', NF90_INT, (/d_nopts/), v_iceo) - ! if (ncerr .ne. 0) return - ! ncerr = nf90_def_var(fh, 'ICEHO', NF90_INT, (/d_nopts/), v_iceho) - ! if (ncerr .ne. 0) return - ! ncerr = nf90_def_var(fh, 'ICEFO', NF90_INT, (/d_nopts/), v_icefo) - ! if (ncerr .ne. 0) return - ! ncerr = nf90_def_var(fh, 'GRDID', NF90_INT, (/d_nopts/), v_grdid) - ! if (ncerr .ne. 0) return - ! ncerr = nf90_def_var(fh, 'SPCO', NF90_INT, (/d_nspec, d_nopts/), v_spco) - ! if (ncerr .ne. 0) return + ! Define vars with nopts as a dimension. + ncerr = nf90_def_var(fh, 'PTLOC', NF90_INT, (/d_vsize, d_nopts/), v_ptloc) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, 'PTNME', NF90_CHAR, (/d_namelen, d_nopts/), v_ptnme) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, 'IW', NF90_INT, (/d_nopts/), v_iw) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, 'II', NF90_INT, (/d_nopts/), v_ii) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, 'IL', NF90_INT, (/d_nopts/), v_il) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, 'DPO', NF90_INT, (/d_nopts/), v_dpo) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, 'WAO', NF90_INT, (/d_nopts/), v_wao) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, 'WDO', NF90_INT, (/d_nopts/), v_wdo) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, 'TAUAO', NF90_INT, (/d_nopts/), v_tauao) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, 'TAIDO', NF90_INT, (/d_nopts/), v_taido) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, 'DAIRO', NF90_INT, (/d_nopts/), v_dairo) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, 'ZET_SETO', NF90_INT, (/d_nopts/), v_zet_seto) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, 'ASO', NF90_INT, (/d_nopts/), v_aso) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, 'CAO', NF90_INT, (/d_nopts/), v_cao) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, 'CDO', NF90_INT, (/d_nopts/), v_cdo) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, 'ICEO', NF90_INT, (/d_nopts/), v_iceo) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, 'ICEHO', NF90_INT, (/d_nopts/), v_iceho) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, 'ICEFO', NF90_INT, (/d_nopts/), v_icefo) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, 'GRDID', NF90_INT, (/d_nopts/), v_grdid) + if (ncerr .ne. 0) return + ncerr = nf90_def_var(fh, 'SPCO', NF90_INT, (/d_nspec, d_nopts/), v_spco) + if (ncerr .ne. 0) return ncerr = nf90_close(fh) if (ncerr .ne. 0) return From c8b3516f14ff177453e235b7366edf845a6a3c26 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Mon, 6 Nov 2023 10:49:47 -0700 Subject: [PATCH 07/17] working on netcdf write code --- .github/workflows/io_gnu.yml | 2 +- model/src/w3iopomd.F90 | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/io_gnu.yml b/.github/workflows/io_gnu.yml index 9973eb48c..3557aac03 100644 --- a/.github/workflows/io_gnu.yml +++ b/.github/workflows/io_gnu.yml @@ -95,9 +95,9 @@ jobs: - name: build-ww3 run: | - set -x source spack/share/spack/setup-env.sh spack env activate ww3-gnu + set -x cd ww3 export CC=mpicc export FC=mpif90 diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index dcb8102b8..9ebeeb3c5 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -1235,13 +1235,16 @@ END SUBROUTINE W3IOPON !> !> @brief Read/write point output. !> + !> This can write per timestep or the whole model run. This is an + !> option in the input file. + !> !> The format of the point output file is: !> Size (bytes) | Type | Variable | Meaning !> -------------|------|----------|-------- !> 40 | character*40 | IDTST | ID string !> 4 | integer | VERTST | version of test? - !> 4 | integer | NK | ??? - !> 4 | integer | MTH | ??? + !> 4 | integer | NK | Dimension of frequency + !> 4 | integer | MTH | Directionality of the frequency !> 4 | integer | NOPTS | ??? !> 8*NOPTS | integer(2,NOPTS) | PTLOC | Point locations !> 7*NOPTS | character*7 | PTNME | Point names From d727e3619defeb31048dfa1310058f6923f05b79 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Mon, 6 Nov 2023 10:54:35 -0700 Subject: [PATCH 08/17] working on netcdf write code --- .github/workflows/io_gnu.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/io_gnu.yml b/.github/workflows/io_gnu.yml index 3557aac03..2c71c527b 100644 --- a/.github/workflows/io_gnu.yml +++ b/.github/workflows/io_gnu.yml @@ -105,6 +105,7 @@ jobs: mkdir build && cd build pwd echo "${GITHUB_WORKSPACE}" + export LD_LIBRARY_PATH="/home/runner/work/WW3/WW3/spack/var/spack/environments/ww3-gnu/.spack-env/view/:$LD_LIBRARY_PATH" which ncdump cmake -DSWITCH=${GITHUB_WORKSPACE}/ww3/model/tests/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 From 96baefbbb423374832ec0a6226d6be6034288f9e Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Mon, 6 Nov 2023 11:11:54 -0700 Subject: [PATCH 09/17] working on netcdf write code --- model/src/w3iopomd.F90 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index 9ebeeb3c5..7e3e71462 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -1074,9 +1074,10 @@ SUBROUTINE W3IOPON_WRITE (NDSOP, 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" ! ! Create the netCDF file. - ncerr = nf90_create("filename ", NF90_NETCDF4, fh) + ncerr = nf90_create(FILE_NAME, NF90_NETCDF4, fh) if (ncerr .ne. 0) return ! Define dimensions. @@ -1245,7 +1246,7 @@ END SUBROUTINE W3IOPON !> 4 | integer | VERTST | version of test? !> 4 | integer | NK | Dimension of frequency !> 4 | integer | MTH | Directionality of the frequency - !> 4 | integer | NOPTS | ??? + !> 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 From 00c434c9002e04cfe140172593b98d5c51f9e408 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Tue, 7 Nov 2023 06:23:12 -0700 Subject: [PATCH 10/17] dealing with filename passing to netcdf --- 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 7e3e71462..1cd281df0 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -1077,7 +1077,7 @@ SUBROUTINE W3IOPON_WRITE (NDSOP, IMOD, filename, ncerr) character (len = *), parameter :: FILE_NAME = "f90tst_nc4.nc" ! ! Create the netCDF file. - ncerr = nf90_create(FILE_NAME, NF90_NETCDF4, fh) + ncerr = nf90_create(filename, NF90_NETCDF4, fh) if (ncerr .ne. 0) return ! Define dimensions. From 882bd6aacadac1794405956d3ae5488c35709ece Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Wed, 8 Nov 2023 05:25:43 -0700 Subject: [PATCH 11/17] more work on netcdf out --- model/src/w3iopomd.F90 | 84 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 78 insertions(+), 6 deletions(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index 1cd281df0..efa25b25f 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -1062,6 +1062,13 @@ SUBROUTINE W3IOPON_WRITE (NDSOP, IMOD, filename, ncerr) 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) :: NDSOP @@ -1069,12 +1076,14 @@ SUBROUTINE W3IOPON_WRITE (NDSOP, 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 + 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' ! ! Create the netCDF file. ncerr = nf90_create(filename, NF90_NETCDF4, fh) @@ -1087,14 +1096,18 @@ SUBROUTINE W3IOPON_WRITE (NDSOP, IMOD, filename, ncerr) if (ncerr .ne. 0) return ncerr = nf90_def_dim(fh, 'VSIZE', 2, d_vsize) if (ncerr .ne. 0) return - ncerr = nf90_def_dim(fh, 'NAMELEN', 7, d_namelen) + ncerr = nf90_def_dim(fh, 'NAMELEN', 40, d_namelen) + if (ncerr .ne. 0) return + ncerr = nf90_def_dim(fh, 'GRDIDLEN', 13, d_grdidlen) if (ncerr .ne. 0) return - ! Define variables. - ncerr = nf90_def_var(fh, 'IDTST', NF90_INT, v_idtst) + ! Define global attributes. + ncerr = nf90_put_att(fh, NF90_GLOBAL, 'title', IDSTR) if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, 'VERTST', NF90_INT, v_vertst) + ncerr = nf90_put_att(fh, NF90_GLOBAL, 'version', VEROPT) if (ncerr .ne. 0) return + + ! Define scalar variables. ncerr = nf90_def_var(fh, 'NK', NF90_INT, v_nk) if (ncerr .ne. 0) return ncerr = nf90_def_var(fh, 'MTH', NF90_INT, v_mth) @@ -1117,14 +1130,18 @@ SUBROUTINE W3IOPON_WRITE (NDSOP, IMOD, filename, ncerr) if (ncerr .ne. 0) return ncerr = nf90_def_var(fh, 'WDO', NF90_INT, (/d_nopts/), v_wdo) if (ncerr .ne. 0) return +#ifdef W3_FLX5 ncerr = nf90_def_var(fh, 'TAUAO', NF90_INT, (/d_nopts/), v_tauao) if (ncerr .ne. 0) return ncerr = nf90_def_var(fh, 'TAIDO', NF90_INT, (/d_nopts/), v_taido) if (ncerr .ne. 0) return ncerr = nf90_def_var(fh, 'DAIRO', NF90_INT, (/d_nopts/), v_dairo) if (ncerr .ne. 0) return +#endif +#ifdef W3_SETUP ncerr = nf90_def_var(fh, 'ZET_SETO', NF90_INT, (/d_nopts/), v_zet_seto) if (ncerr .ne. 0) return +#endif ncerr = nf90_def_var(fh, 'ASO', NF90_INT, (/d_nopts/), v_aso) if (ncerr .ne. 0) return ncerr = nf90_def_var(fh, 'CAO', NF90_INT, (/d_nopts/), v_cao) @@ -1137,10 +1154,60 @@ SUBROUTINE W3IOPON_WRITE (NDSOP, IMOD, filename, ncerr) if (ncerr .ne. 0) return ncerr = nf90_def_var(fh, 'ICEFO', NF90_INT, (/d_nopts/), v_icefo) if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, 'GRDID', NF90_INT, (/d_nopts/), v_grdid) + ncerr = nf90_def_var(fh, 'GRDID', NF90_CHAR, (/d_grdidlen, d_nopts/), v_grdid) if (ncerr .ne. 0) return ncerr = nf90_def_var(fh, '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 @@ -1185,6 +1252,7 @@ SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD & #ifdef W3_S USE W3SERVMD, ONLY: STRACE #endif + use netcdf IMPLICIT NONE CHARACTER, INTENT(IN) :: INXOUT*(*) @@ -1224,6 +1292,10 @@ SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD & ELSE CALL W3IOPON_WRITE(NDSOP, IMOD, 'ww3_out_pnt.nc', ncerr) ENDIF + if (ncerr .ne. 0) then + print *, nf90_strerror(ncerr) + CALL EXTCDE(21) + endif !/ !/ End of W3IOPON ----------------------------------------------------- / From 4c6ab0b3d3aa0e3394b67b1a4ed48a8454d45354 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Wed, 8 Nov 2023 05:31:48 -0700 Subject: [PATCH 12/17] more work on netcdf out --- model/tests/test_io.F90 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/model/tests/test_io.F90 b/model/tests/test_io.F90 index 0fedfef89..7ae39f3f8 100644 --- a/model/tests/test_io.F90 +++ b/model/tests/test_io.F90 @@ -79,13 +79,21 @@ program test_io end do print *, 'OK!' - print *, 'testing WW3 binary point file write...' + print *, 'testing writing the WW3 binary point file in netCDF...' - ! This is not working yet. + ! 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 44a347b66371f5244847670718fe2c94044e9742 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Wed, 8 Nov 2023 05:34:58 -0700 Subject: [PATCH 13/17] more work on netcdf out --- model/src/w3iopomd.F90 | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index efa25b25f..35eebbd3d 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -1030,16 +1030,34 @@ END SUBROUTINE W3IOPE !> @param[in] NDSOP File unit number. !> @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 (NDSOP, IOTST, IMOD) + SUBROUTINE W3IOPON_READ (NDSOP, 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(IN) :: NDSOP INTEGER, INTENT(OUT) :: IOTST INTEGER, INTENT(IN), OPTIONAL :: IMOD + character(*), intent(in) :: filename + integer, intent(inout) :: ncerr + ncerr = 0 IOTST = 0 END SUBROUTINE W3IOPON_READ @@ -1288,7 +1306,7 @@ SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD & ! Do a read or a write of the point file. IF (INXOUT .EQ. 'READ') THEN - CALL W3IOPON_READ(NDSOP, IOTST, IMOD) + CALL W3IOPON_READ(NDSOP, IOTST, IMOD, 'ww3_out_pnt.nc', ncerr) ELSE CALL W3IOPON_WRITE(NDSOP, IMOD, 'ww3_out_pnt.nc', ncerr) ENDIF From fb90776fdd33e5982a83f3f119ed23918bdff8b5 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Wed, 8 Nov 2023 05:56:00 -0700 Subject: [PATCH 14/17] more work on netcdf out --- model/src/w3iopomd.F90 | 49 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index 35eebbd3d..f951cce5b 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -118,6 +118,27 @@ 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' + !/ CONTAINS !/ ------------------------------------------------------------------- / @@ -1056,9 +1077,23 @@ SUBROUTINE W3IOPON_READ (NDSOP, IOTST, IMOD, filename, ncerr) 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 - ncerr = 0 IOTST = 0 + + ! Open the netCDF file. + ncerr = nf90_open(filename, NF90_NOWRITE, fh) + if (ncerr .ne. 0) return + + ! Read the dimension information. +! ncerr = nc90_inq_dir( + + ! Close the file. + ncerr = nf90_close(fh) + if (ncerr .ne. 0) return + + END SUBROUTINE W3IOPON_READ !/ ------------------------------------------------------------------- / @@ -1103,20 +1138,20 @@ SUBROUTINE W3IOPON_WRITE (NDSOP, IMOD, filename, ncerr) CHARACTER(LEN=31), PARAMETER :: IDSTR = 'WAVEWATCH III POINT OUTPUT FILE' CHARACTER(LEN=10), PARAMETER :: VEROPT = '2021-04-06' - ! ! Create the netCDF file. + ! Create the netCDF file. ncerr = nf90_create(filename, NF90_NETCDF4, fh) if (ncerr .ne. 0) return ! Define dimensions. - ncerr = nf90_def_dim(fh, 'NOPTS', NOPTS, d_nopts) + ncerr = nf90_def_dim(fh, DNAME_NOPTS, NOPTS, d_nopts) if (ncerr .ne. 0) return - ncerr = nf90_def_dim(fh, 'NSPEC', NSPEC, d_nspec) + ncerr = nf90_def_dim(fh, DNAME_NSPEC, NSPEC, d_nspec) if (ncerr .ne. 0) return - ncerr = nf90_def_dim(fh, 'VSIZE', 2, d_vsize) + ncerr = nf90_def_dim(fh, DNAME_VSIZE, 2, d_vsize) if (ncerr .ne. 0) return - ncerr = nf90_def_dim(fh, 'NAMELEN', 40, d_namelen) + ncerr = nf90_def_dim(fh, DNAME_NAMELEN, 40, d_namelen) if (ncerr .ne. 0) return - ncerr = nf90_def_dim(fh, 'GRDIDLEN', 13, d_grdidlen) + ncerr = nf90_def_dim(fh, DNAME_GRDIDLEN, 13, d_grdidlen) if (ncerr .ne. 0) return ! Define global attributes. From 060519efa16f4f91227f70914751585a2440ae22 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Wed, 8 Nov 2023 06:59:57 -0700 Subject: [PATCH 15/17] more work on netcdf out --- 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 f951cce5b..e2eb6ca6f 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -1079,6 +1079,7 @@ SUBROUTINE W3IOPON_READ (NDSOP, IOTST, IMOD, filename, ncerr) 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 IOTST = 0 @@ -1087,8 +1088,12 @@ SUBROUTINE W3IOPON_READ (NDSOP, IOTST, IMOD, filename, ncerr) if (ncerr .ne. 0) return ! Read the dimension information. -! ncerr = nc90_inq_dir( - + ncerr = nc90_inq_dimid(fh, DNAME_NOPTS, d_nopts) + if (ncerr .ne. 0) return + ncerr = nc90_inquire_dimension(fh, d_nopts, len = d_nopts_len) + if (ncerr .ne. 0) return + print *, 'd_nopts_len = ', d_nopts_len + ! Close the file. ncerr = nf90_close(fh) if (ncerr .ne. 0) return From a59f6f3908fdf21ceef18bdfc76474d9fd7b5cb4 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Wed, 8 Nov 2023 07:02:08 -0700 Subject: [PATCH 16/17] more work on netcdf out --- model/src/w3iopomd.F90 | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index e2eb6ca6f..14293e28a 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -1087,12 +1087,36 @@ SUBROUTINE W3IOPON_READ (NDSOP, IOTST, IMOD, filename, ncerr) ncerr = nf90_open(filename, NF90_NOWRITE, fh) if (ncerr .ne. 0) return - ! Read the dimension information. - ncerr = nc90_inq_dimid(fh, DNAME_NOPTS, d_nopts) + ! Read the dimension information for NOPTS. + ncerr = nf90_inq_dimid(fh, DNAME_NOPTS, d_nopts) if (ncerr .ne. 0) return - ncerr = nc90_inquire_dimension(fh, d_nopts, len = d_nopts_len) + ncerr = nf90_inquire_dimension(fh, d_nopts, len = d_nopts_len) if (ncerr .ne. 0) return - print *, 'd_nopts_len = ', d_nopts_len + + ! 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 + ! Close the file. ncerr = nf90_close(fh) From 7a5ff0379ec3fd33e3e60c7d18a17cb8d6ca46de Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Wed, 8 Nov 2023 07:33:56 -0700 Subject: [PATCH 17/17] more work on netcdf out --- model/src/w3iopomd.F90 | 232 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 209 insertions(+), 23 deletions(-) diff --git a/model/src/w3iopomd.F90 b/model/src/w3iopomd.F90 index 14293e28a..7ac15ac31 100644 --- a/model/src/w3iopomd.F90 +++ b/model/src/w3iopomd.F90 @@ -138,6 +138,94 @@ MODULE W3IOPOMD !> 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 @@ -1080,6 +1168,10 @@ SUBROUTINE W3IOPON_READ (NDSOP, 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_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 @@ -1117,11 +1209,105 @@ SUBROUTINE W3IOPON_READ (NDSOP, IOTST, IMOD, filename, ncerr) 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 @@ -1190,55 +1376,55 @@ SUBROUTINE W3IOPON_WRITE (NDSOP, IMOD, filename, ncerr) if (ncerr .ne. 0) return ! Define scalar variables. - ncerr = nf90_def_var(fh, 'NK', NF90_INT, v_nk) + ncerr = nf90_def_var(fh, VNAME_NK, NF90_INT, v_nk) if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, 'MTH', NF90_INT, v_mth) + 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, 'PTLOC', NF90_INT, (/d_vsize, d_nopts/), v_ptloc) + 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, 'PTNME', NF90_CHAR, (/d_namelen, d_nopts/), v_ptnme) + 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, 'IW', NF90_INT, (/d_nopts/), v_iw) + ncerr = nf90_def_var(fh, VNAME_IW, NF90_INT, (/d_nopts/), v_iw) if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, 'II', NF90_INT, (/d_nopts/), v_ii) + ncerr = nf90_def_var(fh, VNAME_II, NF90_INT, (/d_nopts/), v_ii) if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, 'IL', NF90_INT, (/d_nopts/), v_il) + ncerr = nf90_def_var(fh, VNAME_IL, NF90_INT, (/d_nopts/), v_il) if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, 'DPO', NF90_INT, (/d_nopts/), v_dpo) + ncerr = nf90_def_var(fh, VNAME_DPO, NF90_INT, (/d_nopts/), v_dpo) if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, 'WAO', NF90_INT, (/d_nopts/), v_wao) + ncerr = nf90_def_var(fh, VNAME_WAO, NF90_INT, (/d_nopts/), v_wao) if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, 'WDO', NF90_INT, (/d_nopts/), v_wdo) + 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, 'TAUAO', NF90_INT, (/d_nopts/), v_tauao) + ncerr = nf90_def_var(fh, VNAME_TAUAO, NF90_INT, (/d_nopts/), v_tauao) if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, 'TAIDO', NF90_INT, (/d_nopts/), v_taido) + ncerr = nf90_def_var(fh, VNAME_TAIDO, NF90_INT, (/d_nopts/), v_taido) if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, 'DAIRO', NF90_INT, (/d_nopts/), v_dairo) + 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, 'ZET_SETO', NF90_INT, (/d_nopts/), v_zet_seto) + 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, 'ASO', NF90_INT, (/d_nopts/), v_aso) + ncerr = nf90_def_var(fh, VNAME_ASO, NF90_INT, (/d_nopts/), v_aso) if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, 'CAO', NF90_INT, (/d_nopts/), v_cao) + ncerr = nf90_def_var(fh, VNAME_CAO, NF90_INT, (/d_nopts/), v_cao) if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, 'CDO', NF90_INT, (/d_nopts/), v_cdo) + ncerr = nf90_def_var(fh, VNAME_CDO, NF90_INT, (/d_nopts/), v_cdo) if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, 'ICEO', NF90_INT, (/d_nopts/), v_iceo) + ncerr = nf90_def_var(fh, VNAME_ICEO, NF90_INT, (/d_nopts/), v_iceo) if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, 'ICEHO', NF90_INT, (/d_nopts/), v_iceho) + ncerr = nf90_def_var(fh, VNAME_ICEHO, NF90_INT, (/d_nopts/), v_iceho) if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, 'ICEFO', NF90_INT, (/d_nopts/), v_icefo) + ncerr = nf90_def_var(fh, VNAME_ICEFO, NF90_INT, (/d_nopts/), v_icefo) if (ncerr .ne. 0) return - ncerr = nf90_def_var(fh, 'GRDID', NF90_CHAR, (/d_grdidlen, d_nopts/), v_grdid) + 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, 'SPCO', NF90_INT, (/d_nspec, d_nopts/), v_spco) + ncerr = nf90_def_var(fh, VNAME_SPCO, NF90_INT, (/d_nspec, d_nopts/), v_spco) if (ncerr .ne. 0) return ! Write the scalar data.