diff --git a/model/src/w3initmd.F90 b/model/src/w3initmd.F90 index 0f1362277..8e76c953f 100644 --- a/model/src/w3initmd.F90 +++ b/model/src/w3initmd.F90 @@ -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" @@ -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 diff --git a/model/src/w3wavemd.F90 b/model/src/w3wavemd.F90 index c6b5520d6..d73543d34 100644 --- a/model/src/w3wavemd.F90 +++ b/model/src/w3wavemd.F90 @@ -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 @@ -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) @@ -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. diff --git a/model/src/wav_history_mod.F90 b/model/src/wav_history_mod.F90 index e7a3e71a9..4e3453f1b 100644 --- a/model/src/wav_history_mod.F90 +++ b/model/src/wav_history_mod.F90 @@ -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 @@ -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 @@ -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 @@ -58,6 +64,7 @@ module wav_history_mod end type varatts type(varatts), dimension(:), allocatable :: outvars +#endif !=============================================================================== contains @@ -112,6 +119,7 @@ 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) @@ -119,6 +127,7 @@ subroutine write_history ( timen ) ! 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' @@ -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 @@ -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 @@ -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 @@ -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(:,:) @@ -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") @@ -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 @@ -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) @@ -731,6 +751,7 @@ subroutine wav_history_init(stdout) write(stdout,*) call flush (stdout) end if +#endif end subroutine wav_history_init @@ -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 = "" @@ -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