Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write log files for all output to indicate it's finished #1378

Merged
merged 18 commits into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions model/src/w3iogomd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2579,7 +2579,8 @@ SUBROUTINE W3IOGO ( INXOUT, NDSOG, IOTST, IMOD &

! DEFINED A LOCAL FNMPRE TO AVOID CHANGE THE GLOBAL VALUE
CHARACTER(LEN=256) :: FNMPRE_LOCAL

!
INTEGER :: NDSOGLOG
!/
!/ ------------------------------------------------------------------- /
!/
Expand Down Expand Up @@ -2630,8 +2631,8 @@ SUBROUTINE W3IOGO ( INXOUT, NDSOG, IOTST, IMOD &
!
IF (LEN_TRIM(FNMGRD) .EQ. 0) THEN
FNMPRE_LOCAL = FNMPRE
ELSE
FNMPRE_LOCAL = FNMGRD
ELSE
FNMPRE_LOCAL = FNMGRD
END IF

IF ( IPASS.EQ.1 .AND. OFILES(1) .EQ. 0) THEN
Expand Down Expand Up @@ -4066,6 +4067,17 @@ SUBROUTINE W3IOGO ( INXOUT, NDSOG, IOTST, IMOD &
CALL W3SETA ( IGRD, NDSE, NDST )
#endif
!
! ADD INDICATOR LOG AFTER THE GRIDDED OUTPUT HAS BEEN FULLY WRITTEN
IF ( WRITE .AND. (OFILES(1).EQ.1) ) THEN
NDSOGLOG = NDSOG
OPEN (NDSOGLOG,FILE=FNMPRE_LOCAL(:J)//'log.'//TIMETAG//'.out_grd.'//FILEXT(:I)//'.txt', &
form ='FORMATTED',ERR=800,IOSTAT=IERR)
WRITE (NDSOGLOG,*) 'The '//TRIM(TIMETAG)//'.out_grd.'//TRIM(FILEXT(:I))// &
' file has been successfully written!'
CALL FLUSH (NDSOGLOG)
CLOSE (NDSOGLOG)
ENDIF

RETURN
!
! Escape locations read errors
Expand Down
35 changes: 28 additions & 7 deletions model/src/w3iopomd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1592,7 +1592,7 @@ END SUBROUTINE W3IOPON_READ
!>
!> @author Edward Hartnett @date 1-Nov-2023
!>
SUBROUTINE W3IOPON_WRITE(timestep_only,filename, ncerr)
SUBROUTINE W3IOPON_WRITE(timestep_only,filename, ncerr, NDSOP, fname, path)
USE NETCDF
USE W3GDATMD, ONLY: NTH, NK, NSPEC
USE W3WDATMD, ONLY: TIME
Expand All @@ -1612,6 +1612,11 @@ SUBROUTINE W3IOPON_WRITE(timestep_only,filename, ncerr)
integer, intent(in) :: timestep_only ! 1 if only timestep should be written.
character(*), intent(in) :: filename
integer, intent(inout) :: ncerr
!
INTEGER, INTENT(IN), OPTIONAL :: NDSOP
CHARACTER(LEN=124), INTENT(IN), OPTIONAL :: fname
CHARACTER(LEN=256), INTENT(IN), OPTIONAL :: path
!
integer :: ndim, nvar, fmt, itime, fh
integer :: d_nopts, d_nspec, d_vsize, d_namelen, d_grdidlen, d_time
integer :: v_idtst, v_vertst, v_nk, v_nth, v_ptloc, v_ptnme, v_time, v_ww3time
Expand All @@ -1627,6 +1632,10 @@ SUBROUTINE W3IOPON_WRITE(timestep_only,filename, ncerr)
integer :: curdate(8), refdate(8),ierr
double precision :: outjulday


! INDICATOR LOG
INTEGER :: NDSOPLOG

!If first pass, or if you are writting a file for every time-step:
IF ( IPASS.EQ.1 .OR. timestep_only.EQ.1 ) THEN
! Create the netCDF file.
Expand Down Expand Up @@ -1887,6 +1896,17 @@ SUBROUTINE W3IOPON_WRITE(timestep_only,filename, ncerr)
ncerr = nf90_close(fh)
if (nf90_err(ncerr) .ne. 0) return

! WRITE INDICATOR LOG AT THE END OF NETCDF OUTPUT
! RE-USE NDSOP FOR NDSOPLOG
IF (timestep_only .EQ. 1) THEN
NDSOPLOG = NDSOP
OPEN(NDSOPLOG,FILE=path(:LEN_TRIM(path))//'log.'//TRIM(fname)//'.txt', &
form ='FORMATTED')
WRITE (NDSOPLOG,*) 'The '//TRIM(fname)//' file has been successfully written!'
CALL FLUSH (NDSOPLOG)
CLOSE (NDSOPLOG)
ENDIF

END SUBROUTINE W3IOPON_WRITE

!> Read or write the netCDF point output file,
Expand Down Expand Up @@ -1934,12 +1954,12 @@ SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD)

CHARACTER(LEN=15) :: TIMETAG
INTEGER :: IGRD
character(len = 124) :: filename
character(len = 256) :: filename
integer :: ncerr

! DEFINED A LOCAL FNMPRE TO AVOID CHANGE THE GLOBAL VALUE
CHARACTER(LEN=256) :: FNMPRE_LOCAL

CHARACTER(LEN=124) :: FNAME
#ifdef W3_S
CALL STRACE (IENT, 'W3IOPON')
#endif
Expand Down Expand Up @@ -1970,15 +1990,16 @@ SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD)
! Determine filename.
IF (LEN_TRIM(FNMPNT) .EQ. 0) THEN
FNMPRE_LOCAL = FNMPRE
ELSE
FNMPRE_LOCAL = FNMPNT
ELSE
FNMPRE_LOCAL = FNMPNT
END IF
!

IF ( OFILES(2) .EQ. 1 ) THEN
! Create TIMETAG for file name using YYYYMMDD.HHMMS prefix
WRITE(TIMETAG,"(i8.8,'.'i6.6)")TIME(1),TIME(2)
filename = FNMPRE_LOCAL(:LEN_TRIM(FNMPRE_LOCAL))//TIMETAG//'.out_pnt.'//FILEXT(:LEN_TRIM(FILEXT))//'.nc'
FNAME = TIMETAG//'.out_pnt.'//FILEXT(:LEN_TRIM(FILEXT))
ELSE
filename = FNMPRE_LOCAL(:LEN_TRIM(FNMPRE_LOCAL))//'out_pnt.'//FILEXT(:LEN_TRIM(FILEXT))//'.nc'
END IF
Expand All @@ -1987,7 +2008,7 @@ SUBROUTINE W3IOPON ( INXOUT, NDSOP, IOTST, IMOD)
IF (INXOUT .EQ. 'READ') THEN
CALL W3IOPON_READ(IOTST, IMOD, filename, ncerr)
ELSE
CALL W3IOPON_WRITE(OFILES(2), filename, ncerr)
CALL W3IOPON_WRITE(OFILES(2), filename, ncerr, NDSOP=NDSOP, fname=FNAME, path=FNMPRE_LOCAL)
ENDIF
if (nf90_err(ncerr) .ne. 0) then
WRITE(NDSE,*) ' *** WAVEWATCH III ERROR IN W3IOPO :'
Expand Down Expand Up @@ -2214,7 +2235,7 @@ SUBROUTINE W3IOPO ( INXOUT, NDSOP, IOTST, IMOD &

! DEFINED A LOCAL FNMPRE TO AVOID CHANGE THE GLOBAL VALUE
CHARACTER(LEN=256) :: FNMPRE_LOCAL

!/
!/ ------------------------------------------------------------------- /
!/
Expand Down
4 changes: 2 additions & 2 deletions model/src/w3iorsmd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,8 @@ SUBROUTINE W3IORS ( INXOUT, NDSR, DUMFPI, IMOD, FLRSTRT )
!
IF (LEN_TRIM(FNMRST) .EQ. 0) THEN
FNMPRE_LOCAL = FNMPRE
ELSE
FNMPRE_LOCAL = FNMRST
ELSE
FNMPRE_LOCAL = FNMRST
END IF
!

Expand Down
8 changes: 4 additions & 4 deletions model/src/w3nmlshelmd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,10 @@ SUBROUTINE W3NMLSHEL (MPI_COMM, NDSI, INFILE, NML_DOMAIN, &
CALL READ_OUTPUT_DATE_NML (NDSI, NML_OUTPUT_DATE)
IF ( IMPROC .EQ. NMPLOG ) CALL REPORT_OUTPUT_DATE_NML (NML_OUTPUT_DATE)

! READ OUTPUT USER DEFINED PATH NAMELIST
! READ OUTPUT USER DEFINED PATH NAMELIST
CALL READ_OUTPUT_PATH_NML (NDSI, NML_OUTPUT_PATH)
IF ( IMPROC .EQ. NMPLOG ) CALL REPORT_OUTPUT_PATH_NML (NML_OUTPUT_PATH)

! read homogeneous namelist
CALL READ_HOMOGENEOUS_NML (NDSI, NML_HOMOG_COUNT, NML_HOMOG_INPUT)
IF ( IMPROC .EQ. NMPLOG ) CALL REPORT_HOMOGENEOUS_NML (NML_HOMOG_COUNT, NML_HOMOG_INPUT)
Expand Down Expand Up @@ -946,7 +946,7 @@ SUBROUTINE READ_OUTPUT_PATH_NML (NDSI, NML_OUTPUT_PATH)
'ERROR: READ_OUTPUT_PATH_NML: namelist read error', &
'ERROR: '//TRIM(MSG)
CALL EXTCDE (8)
END IF
END IF

! SAVE NAMELIST
NML_OUTPUT_PATH = PATH
Expand Down Expand Up @@ -1632,7 +1632,7 @@ SUBROUTINE REPORT_OUTPUT_PATH_NML (NML_OUTPUT_PATH)

10 FORMAT (A,2X,A,A)

END SUBROUTINE REPORT_OUTPUT_PATH_NML
END SUBROUTINE REPORT_OUTPUT_PATH_NML

!/ ------------------------------------------------------------------- /

Expand Down
2 changes: 1 addition & 1 deletion model/src/ww3_shel.F90
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ PROGRAM W3SHEL
integer :: memunit

LOGICAL :: DIR_EXISTS
INTEGER :: DIR_STATUS
INTEGER :: DIR_STATUS
!
!/
!/ ------------------------------------------------------------------- /
Expand Down
Loading