Skip to content

Commit

Permalink
can now build all of ww3 in serial mode
Browse files Browse the repository at this point in the history
  • Loading branch information
JessicaMeixner-NOAA committed Nov 19, 2024
1 parent abe1e79 commit 69f9f47
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
6 changes: 6 additions & 0 deletions model/src/w3initmd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,9 @@ SUBROUTINE W3INIT ( IMOD, IsMulti, FEXT, MDS, MTRACE, ODAT, FLGRD, FLGR2, FLGD,
use w3timemd, only : set_user_timestring
use w3odatmd, only : runtype, restart_from_binary, use_restartnc, user_restfname
use w3odatmd, only : logfile_is_assigned
#ifdef W3_MPI
use wav_restart_mod, only : read_restart
#endif
!/
#ifdef W3_MPI
INCLUDE "mpif.h"
Expand Down Expand Up @@ -972,13 +974,17 @@ SUBROUTINE W3INIT ( IMOD, IsMulti, FEXT, MDS, MTRACE, ODAT, FLGRD, FLGR2, FLGD,
if (restart_from_binary) then
call w3iors('READ', nds(6), sig(nk), imod, filename=trim(fname))
else
#ifdef W3_MPI
call read_restart(trim(fname), va=va, mapsta=mapsta, mapst2=mapst2)
#endif
end if
else
call extcde (60, msg="required restart file " // trim(fname) // " does not exist")
end if
else
#ifdef W3_MPI
call read_restart('none')
#endif
! mapst2 is module variable defined in read of mod_def; maptst is from 2.b above
flcold = .true.
end if
Expand Down
8 changes: 8 additions & 0 deletions model/src/w3wavemd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,10 @@ SUBROUTINE W3WAVE ( IMOD, ODAT, TEND, STAMP, NO_OUT &
#ifdef W3_TIMINGS
USE W3PARALL, only : PRINT_MY_TIME
#endif
#ifdef W3_MPI
use wav_restart_mod , only : write_restart
use wav_history_mod , only : write_history
#endif
use w3odatmd , only : histwr, rstwr, use_historync, use_restartnc, user_restfname
use w3odatmd , only : verboselog
use w3timemd , only : set_user_timestring
Expand Down Expand Up @@ -2355,16 +2357,20 @@ SUBROUTINE W3WAVE ( IMOD, ODAT, TEND, STAMP, NO_OUT &
!
!
if (dsec21(time,tend) == 0.0) then ! req'd in case waves are running in slow loop

if (use_historync) then
floutg = .false.
floutg2 = .false.
#ifdef W3_MPI
if (histwr) then
call w3cprt (imod)
call w3outg (va, flpfld, .true., .false. )
call write_history(tend)
end if
#endif
end if

#ifdef W3_MPI
if (use_restartnc) then
if (rstwr) then
call set_user_timestring(tend,user_timestring)
Expand All @@ -2373,6 +2379,8 @@ SUBROUTINE W3WAVE ( IMOD, ODAT, TEND, STAMP, NO_OUT &
end if
end if
end if
#endif


IF ( TOFRST(1) .EQ. -1 ) THEN
DTTST = 1.
Expand Down
27 changes: 26 additions & 1 deletion model/src/wav_history_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ module wav_history_mod
use w3gdatmd , only : xgrd, ygrd
use w3gdatmd , only : nk, nx, ny, mapsf, mapsta, nsea
use w3odatmd , only : undef
#ifdef W3_MPI
use w3adatmd , only : mpi_comm_wave
use wav_import_export , only : nseal_cpl
use wav_pio_mod , only : pio_iotype, pio_ioformat, wav_pio_subsystem
use wav_pio_mod , only : handle_err, wav_pio_initdecomp
use pio
#endif
use netcdf

implicit none
Expand All @@ -24,8 +26,10 @@ module wav_history_mod

public :: wav_history_init
public :: write_history
#ifdef W3_MPI
public :: varatts
public :: outvars
#endif

! used/reused in module
integer :: isea, jsea, ix, iy, ierr
Expand All @@ -38,6 +42,8 @@ module wav_history_mod
! output variable for (nx,ny,nz) fields
real, pointer :: var3d(:,:)

#ifdef W3_MPI

type(file_desc_t) :: pioid
type(var_desc_t) :: varid
type(io_desc_t) :: iodesc2d !2d only
Expand All @@ -58,6 +64,7 @@ module wav_history_mod
end type varatts

type(varatts), dimension(:), allocatable :: outvars
#endif

!===============================================================================
contains
Expand Down Expand Up @@ -112,13 +119,15 @@ subroutine write_history ( timen )
integer :: n, xtid, ytid, xeid, ztid, stid, mtid, ptid, ktid, timid, nmode
integer :: len_s, len_m, len_p, len_k
logical :: s_axis = .false., m_axis = .false., p_axis = .false., k_axis = .false.
#ifdef W3_MPI

integer :: lmap(nseal_cpl)

! -------------------------------------------------------------
! create the netcdf file
! -------------------------------------------------------------


! native WW3 file naming
if (len_trim(user_histfname) == 0) then
write(fname,'(a,i8.8,a1,i6.6,a)')trim(fnmpre),timen(1),'.',timen(2),'.out_grd.ww3.nc'
Expand Down Expand Up @@ -445,6 +454,7 @@ subroutine write_history ( timen )
if (k_axis) call pio_freedecomp(pioid, iodesc3dk)

call pio_closefile(pioid)
#endif

end subroutine write_history

Expand Down Expand Up @@ -481,6 +491,8 @@ subroutine write_var2d(vname, var, dir, usemask, init0, init2, fldir, global)
character(len=*), optional, intent(in) :: fldir
character(len=*), optional, intent(in) :: global

#ifdef W3_MPI

! local variables
real, dimension(nseal_cpl) :: varout
logical :: lmask, linit0, linit2, lfldir, lglobal
Expand Down Expand Up @@ -556,6 +568,8 @@ subroutine write_var2d(vname, var, dir, usemask, init0, init2, fldir, global)
call pio_setframe(pioid, varid, int(1,kind=Pio_Offset_Kind))
call pio_write_darray(pioid, varid, iodesc2d, varout, ierr)
call handle_err(ierr, 'put variable '//trim(vname))

#endif

end subroutine write_var2d

Expand All @@ -574,8 +588,8 @@ end subroutine write_var2d
!!
!> author DeniseWorthen@noaa.gov
!> @date 08-26-2024
#ifdef W3_MPI
subroutine write_var3d(iodesc, vname, var, init2, fldir)

type(io_desc_t), intent(inout) :: iodesc
character(len=*), intent(in) :: vname
real , intent(in) :: var(:,:)
Expand All @@ -587,6 +601,7 @@ subroutine write_var3d(iodesc, vname, var, init2, fldir)
logical :: linit2, lfldir
integer :: lb, ub


linit2 = .false.
if (present(init2)) then
linit2 = (trim(init2) == "true")
Expand Down Expand Up @@ -624,6 +639,7 @@ subroutine write_var3d(iodesc, vname, var, init2, fldir)

deallocate(varloc)
end subroutine write_var3d
#endif

!===============================================================================
!> Scan through all possible fields to determine a list of requested variables
Expand Down Expand Up @@ -651,12 +667,16 @@ subroutine wav_history_init(stdout)

! local variables
integer, parameter :: maxvars = 25 ! maximum number of variables/group
#ifdef W3_MPI
type(varatts), dimension(nogrp,maxvars) :: gridoutdefs
#endif

character(len=100) :: inptags(100) = ''
integer :: j,k,n,nout
character(len= 12) :: ttag

#ifdef W3_MPI

! obtain all possible output variable tags and attributes
call define_fields(gridoutdefs)

Expand Down Expand Up @@ -731,6 +751,7 @@ subroutine wav_history_init(stdout)
write(stdout,*)
call flush (stdout)
end if
#endif

end subroutine wav_history_init

Expand All @@ -739,8 +760,11 @@ end subroutine wav_history_init
!!
!> @author Denise.Worthen@noaa.gov
!> @date 09-19-2022
#ifdef W3_MPI

subroutine define_fields (gridoutdefs)


type(varatts), dimension(:,:), intent(inout) :: gridoutdefs

gridoutdefs(:,:)%tag = ""
Expand Down Expand Up @@ -911,4 +935,5 @@ subroutine define_fields (gridoutdefs)
varatts( "U2 ", "U2 ", "User defined 2 ", "nd ", " ", .false.) &
]
end subroutine define_fields
#endif
end module wav_history_mod

0 comments on commit 69f9f47

Please sign in to comment.