diff --git a/model/bin/switch_meshcap b/model/bin/switch_meshcap index 97d635b69..7a11c569b 100644 --- a/model/bin/switch_meshcap +++ b/model/bin/switch_meshcap @@ -1 +1 @@ -NCO NOGRB DIST MPI OMPG OMPH PR3 UQ FLX0 SEED ST4 STAB0 NL1 BT1 DB1 MLIM FLD2 TR0 BS0 RWND WNX1 WNT1 CRX1 CRT1 O0 O1 O2 O3 O4 O5 O6 O7 O14 O15 IC0 IS0 REF0 +NCO NOGRB DIST MPI OMPG OMPH PIO PR3 UQ FLX0 SEED ST4 STAB0 NL1 BT1 DB1 MLIM FLD2 TR0 BS0 RWND WNX1 WNT1 CRX1 CRT1 O0 O1 O2 O3 O4 O5 O6 O7 O14 O15 IC0 IS0 REF0 diff --git a/model/bin/switch_meshcap_pdlib b/model/bin/switch_meshcap_pdlib index 3b43c7146..6be94e6d0 100644 --- a/model/bin/switch_meshcap_pdlib +++ b/model/bin/switch_meshcap_pdlib @@ -1 +1 @@ -NCO PDLIB SCOTCH NOGRB DIST MPI PR3 UQ FLX0 SEED ST4 STAB0 NL1 BT1 DB1 MLIM FLD2 TR0 BS0 RWND WNX1 WNT1 CRX1 CRT1 O0 O1 O2 O3 O4 O5 O6 O7 O14 O15 IC0 IS0 REF0 +NCO PDLIB SCOTCH NOGRB DIST MPI PIO PR3 UQ FLX0 SEED ST4 STAB0 NL1 BT1 DB1 MLIM FLD2 TR0 BS0 RWND WNX1 WNT1 CRX1 CRT1 O0 O1 O2 O3 O4 O5 O6 O7 O14 O15 IC0 IS0 REF0 diff --git a/model/src/CMakeLists.txt b/model/src/CMakeLists.txt index 9eaa67441..75f3abe97 100644 --- a/model/src/CMakeLists.txt +++ b/model/src/CMakeLists.txt @@ -174,6 +174,10 @@ if("MPI" IN_LIST switches) target_link_libraries(ww3_lib PUBLIC MPI::MPI_Fortran) endif() +if("PIO" IN_LIST switches) + target_sources(ww3_lib PRIVATE ${pio_src}) +endif() + # Handle PDLIB, SCRIP, SCRIPNC build files directly instead of through configuration file if("PDLIB" IN_LIST switches) if("SCOTCH" IN_LIST switches) diff --git a/model/src/cmake/src_list.cmake b/model/src/cmake/src_list.cmake index 825f5d637..eaa5c26d7 100644 --- a/model/src/cmake/src_list.cmake +++ b/model/src/cmake/src_list.cmake @@ -55,19 +55,23 @@ set(ftn_src wmupdtmd.F90 wmwavemd.F90 w3tidemd.F90 - wav_history_mod.F90 wav_shr_flags.F90 ) -set(nuopc_mesh_cap_src - wav_kind_mod.F90 +set(pio_src + wav_history_mod.F90 + wav_pio_mod.F90 + wav_restart_mod.F90 + ${PROJECT_SOURCE_DIR}/../CDEPS-interface/ufs/cdeps_share/shr_is_restart_fh_mod.F90 wav_shr_mod.F90 + wav_kind_mod.F90 + wav_import_export.F90 + ) + +set(nuopc_mesh_cap_src wav_shel_inp.F90 wav_comp_nuopc.F90 - wav_import_export.F90 wav_wrapper_mod.F90 - wav_pio_mod.F90 - wav_restart_mod.F90 ) set(esmf_multi_cap_src diff --git a/model/src/cmake/switches.json b/model/src/cmake/switches.json index ca01708af..120da73ef 100644 --- a/model/src/cmake/switches.json +++ b/model/src/cmake/switches.json @@ -745,6 +745,17 @@ } ] }, + { + "name": "pio", + "num_switches": "upto1", + "description": "use pio library", + "valid-options":[ + { + "name": "PIO", + "requires": ["MPI"] + } + ] + }, { "name": "pdlib", "num_switches": "upto1", diff --git a/model/src/w3initmd.F90 b/model/src/w3initmd.F90 index 0f1362277..da95068b3 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_PIO use wav_restart_mod, only : read_restart +#endif !/ #ifdef W3_MPI INCLUDE "mpif.h" @@ -959,6 +961,7 @@ SUBROUTINE W3INIT ( IMOD, IsMulti, FEXT, MDS, MTRACE, ODAT, FLGRD, FLGR2, FLGD, ! 3.a Read restart file ! VA(:,:) = 0. +#ifdef W3_PIO if (use_restartnc) then if (runtype == 'continue' )then call set_user_timestring(time,user_timestring) @@ -983,6 +986,8 @@ SUBROUTINE W3INIT ( IMOD, IsMulti, FEXT, MDS, MTRACE, ODAT, FLGRD, FLGR2, FLGD, flcold = .true. end if else +#endif + #ifdef W3_DEBUGCOH CALL ALL_VA_INTEGRAL_PRINT(IMOD, "Before W3IORS call", 1) #endif @@ -1016,7 +1021,9 @@ SUBROUTINE W3INIT ( IMOD, IsMulti, FEXT, MDS, MTRACE, ODAT, FLGRD, FLGR2, FLGD, #ifdef W3_TIMINGS CALL PRINT_MY_TIME("After restart inits") #endif +#ifdef W3_PIO end if ! if (use_restartnc) +#endif ! ! 3.b Compare MAPSTA from grid and restart ! diff --git a/model/src/w3wavemd.F90 b/model/src/w3wavemd.F90 index c6b5520d6..f635c2369 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_PIO 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 @@ -2354,7 +2356,9 @@ SUBROUTINE W3WAVE ( IMOD, ODAT, TEND, STAMP, NO_OUT & ! Delay if data assimilation time. ! ! +#ifdef W3_PIO 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. @@ -2372,7 +2376,10 @@ SUBROUTINE W3WAVE ( IMOD, ODAT, TEND, STAMP, NO_OUT & call write_restart(trim(fname), va, mapsta+8*mapst2) end if end if + end if +#endif + IF ( TOFRST(1) .EQ. -1 ) THEN DTTST = 1. @@ -2524,8 +2531,8 @@ SUBROUTINE W3WAVE ( IMOD, ODAT, TEND, STAMP, NO_OUT & #ifdef W3_MPI END IF END IF -#endif end if ! if (.not. use_restartnc) +#endif ! #ifdef W3_MPI IF ( FLOUT(5) .AND. NRQBP.NE.0 ) THEN diff --git a/model/src/wav_comp_nuopc.F90 b/model/src/wav_comp_nuopc.F90 index 4280b3b14..544b40817 100644 --- a/model/src/wav_comp_nuopc.F90 +++ b/model/src/wav_comp_nuopc.F90 @@ -56,6 +56,7 @@ module wav_comp_nuopc use wmmdatmd , only : nmpscr use w3updtmd , only : w3uini use w3adatmd , only : flcold, fliwnd + use shr_is_restart_fh_mod , only : init_is_restart_fh, is_restart_fh, is_restart_fh_type #endif use constants , only : is_esmf_component @@ -89,6 +90,7 @@ module wav_comp_nuopc logical :: cesmcoupled = .true. !< logical to indicate CESM use case #else logical :: cesmcoupled = .false. !< logical to indicate non-CESM use case + type(is_restart_fh_type) :: restartfh_info ! For flexible restarts in UFS #endif integer, allocatable :: tend(:,:) !< the ending time of ModelAdvance when !! run with multigrid=true @@ -1126,6 +1128,7 @@ subroutine ModelAdvance(gcomp, rc) type(ESMF_Time) :: currTime, nextTime, startTime, stopTime integer :: yy,mm,dd,hh,ss integer :: imod + logical :: write_restartfh !integer :: shrlogunit ! original log unit and level character(ESMF_MAXSTR) :: msgString character(len=*),parameter :: subname = '(wav_comp_nuopc:ModelAdvance) ' @@ -1219,6 +1222,10 @@ subroutine ModelAdvance(gcomp, rc) else rstwr = .false. endif +#ifndef W3_CESMCOUPLED + call is_restart_fh(clock, restartfh_info, write_restartfh) + if (write_restartfh) rstwr = .true. +#endif ! Determine if time to write ww3 history files call ESMF_ClockGetAlarm(clock, alarmname='alarm_history', alarm=alarm, rc=rc) @@ -1295,7 +1302,7 @@ subroutine ModelSetRunClock(gcomp, rc) integer :: history_ymd ! History date (YYYYMMDD) type(ESMF_ALARM) :: history_alarm character(len=128) :: name - integer :: alarmcount + integer :: alarmcount, dt_cpl character(len=*),parameter :: subname=trim(modName)//':(ModelSetRunClock) ' !------------------------------------------------------------------------------- @@ -1363,6 +1370,12 @@ subroutine ModelSetRunClock(gcomp, rc) call ESMF_AlarmSet(restart_alarm, clock=mclock, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return +#ifndef W3_CESMCOUPLED + call ESMF_TimeIntervalGet( dtimestep, s=dt_cpl, rc=rc ) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call init_is_restart_fh(mcurrTime, dt_cpl, root_task, restartfh_info) +#endif + end if !----------------