From 40fa6b4da54ca94482df191e17fac67597130894 Mon Sep 17 00:00:00 2001 From: Jessica Meixner Date: Wed, 20 Nov 2024 21:24:30 +0000 Subject: [PATCH 1/4] add PIO switch --- model/bin/switch_meshcap | 2 +- model/bin/switch_meshcap_pdlib | 2 +- model/src/CMakeLists.txt | 4 ++++ model/src/cmake/src_list.cmake | 5 ++++- model/src/cmake/switches.json | 11 +++++++++++ model/src/w3initmd.F90 | 6 ++++++ model/src/w3wavemd.F90 | 8 +++++++- 7 files changed, 34 insertions(+), 4 deletions(-) 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..e5b30c9c0 100644 --- a/model/src/cmake/src_list.cmake +++ b/model/src/cmake/src_list.cmake @@ -55,10 +55,13 @@ set(ftn_src wmupdtmd.F90 wmwavemd.F90 w3tidemd.F90 - wav_history_mod.F90 wav_shr_flags.F90 ) +set(pio_src + wav_history_mod.F90 + ) + set(nuopc_mesh_cap_src wav_kind_mod.F90 wav_shr_mod.F90 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..68643ea20 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" @@ -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_PIO 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_PIO 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..fb83b54cd 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 @@ -2361,7 +2363,9 @@ SUBROUTINE W3WAVE ( IMOD, ODAT, TEND, STAMP, NO_OUT & if (histwr) then call w3cprt (imod) call w3outg (va, flpfld, .true., .false. ) +#ifdef W3_PIO call write_history(tend) +#endif end if end if @@ -2369,7 +2373,9 @@ SUBROUTINE W3WAVE ( IMOD, ODAT, TEND, STAMP, NO_OUT & if (rstwr) then call set_user_timestring(tend,user_timestring) fname = trim(user_restfname)//trim(user_timestring)//'.nc' +#ifdef W3_PIO call write_restart(trim(fname), va, mapsta+8*mapst2) +#endif end if end if end if @@ -2524,8 +2530,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 From 9517df78cfcec3e0f4764fc39950c57f14edddca Mon Sep 17 00:00:00 2001 From: Jessica Meixner Date: Wed, 20 Nov 2024 21:49:32 +0000 Subject: [PATCH 2/4] update cmake source list for future day of pio being used by other standalone ww3 systems. It doesn't completely work yet though --- model/src/cmake/src_list.cmake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/model/src/cmake/src_list.cmake b/model/src/cmake/src_list.cmake index e5b30c9c0..00fb33cad 100644 --- a/model/src/cmake/src_list.cmake +++ b/model/src/cmake/src_list.cmake @@ -60,17 +60,17 @@ set(ftn_src set(pio_src wav_history_mod.F90 + wav_pio_mod.F90 + wav_restart_mod.F90 + wav_shr_mod.F90 + wav_kind_mod.F90 + wav_import_export.F90 ) set(nuopc_mesh_cap_src - wav_kind_mod.F90 - wav_shr_mod.F90 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 From f5280035d1ece97b1a0318de15210f6d85e339e0 Mon Sep 17 00:00:00 2001 From: Jessica Meixner Date: Thu, 21 Nov 2024 15:32:56 +0000 Subject: [PATCH 3/4] change location of PIO ifdefs to skip larger block --- model/src/w3wavemd.F90 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/model/src/w3wavemd.F90 b/model/src/w3wavemd.F90 index fb83b54cd..f635c2369 100644 --- a/model/src/w3wavemd.F90 +++ b/model/src/w3wavemd.F90 @@ -2356,16 +2356,16 @@ 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. if (histwr) then call w3cprt (imod) call w3outg (va, flpfld, .true., .false. ) -#ifdef W3_PIO call write_history(tend) -#endif end if end if @@ -2373,12 +2373,13 @@ SUBROUTINE W3WAVE ( IMOD, ODAT, TEND, STAMP, NO_OUT & if (rstwr) then call set_user_timestring(tend,user_timestring) fname = trim(user_restfname)//trim(user_timestring)//'.nc' -#ifdef W3_PIO call write_restart(trim(fname), va, mapsta+8*mapst2) -#endif end if end if + end if +#endif + IF ( TOFRST(1) .EQ. -1 ) THEN DTTST = 1. From 615236be21904e180c12c4babfde89fdb448a2cf Mon Sep 17 00:00:00 2001 From: Jessica Meixner Date: Fri, 22 Nov 2024 18:33:33 +0000 Subject: [PATCH 4/4] update w3init to expand section in PIO switches --- model/src/w3initmd.F90 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/model/src/w3initmd.F90 b/model/src/w3initmd.F90 index 68643ea20..da95068b3 100644 --- a/model/src/w3initmd.F90 +++ b/model/src/w3initmd.F90 @@ -961,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) @@ -974,21 +975,19 @@ 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_PIO 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_PIO 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 else +#endif + #ifdef W3_DEBUGCOH CALL ALL_VA_INTEGRAL_PRINT(IMOD, "Before W3IORS call", 1) #endif @@ -1022,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 !