From df4d393ee5f6cf49edc878dd397b44bb7d2c19b2 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Sat, 30 Mar 2024 10:39:26 -0600 Subject: [PATCH 01/21] 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 02/21] 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 03/21] 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 9366dcaca5b5b7cddc1372b4dd6adf0967ff0988 Mon Sep 17 00:00:00 2001 From: Ed Date: Mon, 1 Apr 2024 11:43:26 -0600 Subject: [PATCH 04/21] 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 05/21] 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 06/21] 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 07/21] 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 08/21] 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 ba26fd80e77bca0004f24c7c033ad111738ee521 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Tue, 2 Apr 2024 04:17:21 -0600 Subject: [PATCH 09/21] 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 10/21] 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 11/21] 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 12/21] 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 13/21] 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 fdbb2b8477390862e976cd60a5740baff4753e15 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Tue, 2 Apr 2024 06:11:52 -0600 Subject: [PATCH 14/21] 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 ea46887b5ecc09b0a7eb13470cb12f124dfa0ab7 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Tue, 2 Apr 2024 07:54:27 -0600 Subject: [PATCH 15/21] 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 16/21] 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 17/21] 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 18/21] 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 19/21] 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 20/21] 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 a67cebe0f008759af62c6da19898589031ad0ef1 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Wed, 3 Apr 2024 06:31:41 -0600 Subject: [PATCH 21/21] minor change --- regtests/unittests/test_io_restart_bin.F90 | 1 - 1 file changed, 1 deletion(-) diff --git a/regtests/unittests/test_io_restart_bin.F90 b/regtests/unittests/test_io_restart_bin.F90 index 026e8d3d2..b88ad6c2b 100644 --- a/regtests/unittests/test_io_restart_bin.F90 +++ b/regtests/unittests/test_io_restart_bin.F90 @@ -52,7 +52,6 @@ program test_io_restart_bin ! if (iotest .ne. 0) stop 10 ! close(ndsop) - print *, 'OK!' print *, 'SUCCESS!' end program test_io_restart_bin