Skip to content

Commit

Permalink
adding time dimension to read
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardhartnett committed Apr 14, 2024
1 parent b092daa commit 3aa1eb7
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 41 deletions.
75 changes: 50 additions & 25 deletions model/src/w3iopomd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1258,81 +1258,102 @@ SUBROUTINE W3IOPON_READ(IOTST, IMOD, filename, ncerr)

! All of the below variables are missing the "time" dimension...
! the time dimension being read should be for "IPASS"
ncerr = nf90_inq_varid(fh, VNAME_IW, v_iw)
ncerr = nf90_inq_varid(fh, VNAME_IW, v_iw, start = (/ 1, ipass/), &
count = (/ NOPTS, 1 /))
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_get_var(fh, v_iw, IW)
ncerr = nf90_get_var(fh, v_iw, IW, start = (/ 1, ipass/), &
count = (/ NOPTS, 1 /))
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_inq_varid(fh, VNAME_II, v_ii)
ncerr = nf90_inq_varid(fh, VNAME_II, v_ii, start = (/ 1, ipass/), &
count = (/ NOPTS, 1 /))
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_get_var(fh, v_ii, II)
ncerr = nf90_get_var(fh, v_ii, II, start = (/ 1, ipass/), &
count = (/ NOPTS, 1 /))
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_inq_varid(fh, VNAME_IL, v_il)
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_get_var(fh, v_il, IL)
ncerr = nf90_get_var(fh, v_il, IL, start = (/ 1, ipass/), &
count = (/ NOPTS, 1 /))
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_inq_varid(fh, VNAME_DPO, v_dpo)
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_get_var(fh, v_dpo, DPO)
ncerr = nf90_get_var(fh, v_dpo, DPO, start = (/ 1, ipass/), &
count = (/ NOPTS, 1 /))
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_inq_varid(fh, VNAME_WAO, v_wao)
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_get_var(fh, v_wao, WAO)
ncerr = nf90_get_var(fh, v_wao, WAO, start = (/ 1, ipass/), &
count = (/ NOPTS, 1 /))
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_inq_varid(fh, VNAME_WDO, v_wdo)
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_get_var(fh, v_wdo, WDO)
ncerr = nf90_get_var(fh, v_wdo, WDO, start = (/ 1, ipass/), &
count = (/ NOPTS, 1 /))
if (nf90_err(ncerr) .ne. 0) return
#ifdef W3_FLX5
ncerr = nf90_inq_varid(fh, VNAME_TAUAO, v_tauao)
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_get_var(fh, v_tauao, TAUAO)
ncerr = nf90_get_var(fh, v_tauao, TAUAO, start = (/ 1, ipass/), &
count = (/ NOPTS, 1 /))
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_inq_varid(fh, VNAME_TAIDO, v_taido)
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_get_var(fh, v_taido, TAIDO)
ncerr = nf90_get_var(fh, v_taido, TAIDO, start = (/ 1, ipass/), &
count = (/ NOPTS, 1 /))
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_inq_varid(fh, VNAME_DAIRO, v_dairo)
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_get_var(fh, v_dairo, DAIRO)
ncerr = nf90_get_var(fh, v_dairo, DAIRO, start = (/ 1, ipass/), &
count = (/ NOPTS, 1 /))
if (nf90_err(ncerr) .ne. 0) return
#endif
#ifdef W3_SETUP
ncerr = nf90_inq_varid(fh, ZET_SETO, v_zet_seto)
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_get_var(fh, v_zet_seto, ZET_SETO)
ncerr = nf90_get_var(fh, v_zet_seto, ZET_SETO, start = (/ 1, ipass/), &
count = (/ NOPTS, 1 /))
if (nf90_err(ncerr) .ne. 0) return
#endif
ncerr = nf90_inq_varid(fh, VNAME_ASO, v_aso)
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_get_var(fh, v_aso, ASO)
ncerr = nf90_get_var(fh, v_aso, ASO, start = (/ 1, ipass/), &
count = (/ NOPTS, 1 /))
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_inq_varid(fh, VNAME_CAO, v_cao)
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_get_var(fh, v_cao, CAO)
ncerr = nf90_get_var(fh, v_cao, CAO, start = (/ 1, ipass/), &
count = (/ NOPTS, 1 /))
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_inq_varid(fh, VNAME_CDO, v_cdo)
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_get_var(fh, v_cdo, CDO)
ncerr = nf90_get_var(fh, v_cdo, CDO, start = (/ 1, ipass/), &
count = (/ NOPTS, 1 /))
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_inq_varid(fh, VNAME_ICEO, v_iceo)
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_get_var(fh, v_iceo, ICEO)
ncerr = nf90_get_var(fh, v_iceo, ICEO, start = (/ 1, ipass/), &
count = (/ NOPTS, 1 /))
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_inq_varid(fh, VNAME_ICEHO, v_iceho)
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_get_var(fh, v_iceho, ICEHO)
ncerr = nf90_get_var(fh, v_iceho, ICEHO, start = (/ 1, ipass/), &
count = (/ NOPTS, 1 /))
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_inq_varid(fh, VNAME_ICEFO, v_icefo)
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_get_var(fh, v_icefo, ICEFO)
ncerr = nf90_get_var(fh, v_icefo, ICEFO, start = (/ 1, ipass/), &
count = (/ NOPTS, 1 /))
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_inq_varid(fh, VNAME_GRDID, v_grdid)
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_get_var(fh, v_grdid, GRDID)
ncerr = nf90_get_var(fh, v_grdid, GRDID, start = (/ 1, ipass/), &
count = (/ NOPTS, 1 /))
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_inq_varid(fh, VNAME_SPCO, v_spco)
ncerr = nf90_inq_varid(fh, VNAME_SPCO, v_spco, start = (/ 1, ipass/), &
count = (/ NOPTS, 1 /))
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_get_var(fh, v_spco, SPCO)
ncerr = nf90_get_var(fh, v_spco, SPCO, start = (/ 1, ipass/), &
count = (/ NOPTS, 1 /))
if (nf90_err(ncerr) .ne. 0) return

! Close the file.
Expand Down Expand Up @@ -1491,10 +1512,14 @@ SUBROUTINE W3IOPON_WRITE(timestep_only, IMOD, filename, ncerr)

write(*,*) 'JDM e'
! Write the data with NOPTS as a dimension.
ncerr = nf90_put_var(fh, v_ptloc, PTLOC)
if (nf90_err(ncerr) .ne. 0) return
ncerr = nf90_put_var(fh, v_ptnme, PTNME)
if (nf90_err(ncerr) .ne. 0) return
if (associated(PTLOC)) then
ncerr = nf90_put_var(fh, v_ptloc, PTLOC)
if (nf90_err(ncerr) .ne. 0) return
endif
if (associated(PTNME)) then
ncerr = nf90_put_var(fh, v_ptnme, PTNME)
if (nf90_err(ncerr) .ne. 0) return
endif

ELSE
write(*,*) 'JDM else'
Expand Down
33 changes: 17 additions & 16 deletions regtests/unittests/test_io3.F90
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,26 @@ program test_io3
call w3nout(6, 6)
call w3seto(1, 6, 6)

nth = 4
ndsm = 20
ndsop = 20
ndsbul = 0
ndstrc = 6
ntrace = 10
imod = 1

! Create a point output file needed for this test.
print *, 'Creating point output test file for this test...'
if (write_test_file() .ne. 0) stop 1

! 2. Read model definition file.
CALL W3IOGR('READ', NDSM)
WRITE (NDSO,920) GNAME
920 FORMAT (' Grid name : ',A/)
920 FORMAT (' Grid name : ',A/)

! Create a point output file needed for this test.
print *, 'Creating point output test file for this test...'
if (write_test_file() .ne. 0) stop 1

! Read the file out_pnt.ww3 from the model/tests/data directory.
print *, 'OK!'
print *, 'Reading the point output test file for this test...'
! print *, 'OK!'
! print *, 'Reading the point output test file for this test...'
call w3iopo('READ', ndsop, iotest)
if (iotest .ne. 0) stop 10
close(ndsop)
Expand Down Expand Up @@ -84,16 +85,16 @@ program test_io3
print *, 'OK!'
print *, 'testing writing the WW3 binary point file in netCDF...'

! Write in netCDF.
ofiles(2) = 1
call w3iopon('WRITE', ndsop, iotest, imod)
if (iotest .ne. 0) stop 100
print *, 'OK!'
! ! Write in netCDF.
! ofiles(2) = 1
! call w3iopon('WRITE', ndsop, iotest, imod)
! if (iotest .ne. 0) stop 100
! print *, 'OK!'

! Another timestep in netCDF.
call w3iopon('WRITE', ndsop, iotest, imod)
if (iotest .ne. 0) stop 100
print *, 'OK!'
! ! Another timestep in netCDF.
! call w3iopon('WRITE', ndsop, iotest, imod)
! if (iotest .ne. 0) stop 100
! print *, 'OK!'

print *, 'testing reading the WW3 binary point file in netCDF...'
ipass2 = 0
Expand Down

0 comments on commit 3aa1eb7

Please sign in to comment.