Skip to content

Commit

Permalink
Refactor fv3atm history & restart to reduce redundant code. Add rrfs-…
Browse files Browse the repository at this point in the history
…sd and clm lake to quilt restart. (#660)

* move utility routines, data structures, and name generation out of FV3GFS_io.F90

* move RRFS SD state restart io to separate file and rename clm_lake_io.F90

* sfc array indices are calculated in FV3GFS_sfc_io.F90

* move rrfs sd emissions input code to FV3GFS_rrfs_sd_io.F90

* allocate sfc arrays in FV3GFS_sfc_io.F90

* define and write axes in FV3GFS_sfc_io.F90

* register sfc fields in FV3GFS_sfc_io.F90

* move sfc read loop to FV3GFS_sfc_io.F90

* Put post-read safeguards in FV3GFS_sfc_io.F90

* copy to grid in FV3GFS_sfc_io.F90 and make things private

* move oro reading to FV3GFS_oro_io.F90

* gwd I/O in FV3GFS_oro_io.F90

* store quilt restart data structures in FV3GFS_sfc_io types

* remove copy_from_GFS_Data calls from FV3GFS_restart_io.F90

* consistent naming and clm lake quilt restart
  • Loading branch information
SamuelTrahanNOAA authored Jun 20, 2023
1 parent 606cb31 commit f9d68ad
Show file tree
Hide file tree
Showing 16 changed files with 6,106 additions and 5,708 deletions.
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,13 @@ add_library(fv3atm
cpl/module_block_data.F90
cpl/module_cplfields.F90
cpl/module_cap_cpl.F90
io/clm_lake_io.F90
io/FV3GFS_io.F90
io/FV3GFS_restart_io.F90
io/fv3atm_common_io.F90
io/fv3atm_clm_lake_io.F90
io/fv3atm_rrfs_sd_io.F90
io/fv3atm_sfc_io.F90
io/fv3atm_oro_io.F90
io/fv3atm_history_io.F90
io/fv3atm_restart_io.F90
io/module_write_netcdf.F90
io/module_write_restart_netcdf.F90
io/module_fv3_io_def.F90
Expand Down
29 changes: 15 additions & 14 deletions atmos_model.F90
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,14 @@ module atmos_model_mod

use stochastic_physics_wrapper_mod, only: stochastic_physics_wrapper,stochastic_physics_wrapper_end

use FV3GFS_io_mod, only: FV3GFS_restart_read, FV3GFS_restart_write, &
FV3GFS_GFS_checksum, &
FV3GFS_diag_register, FV3GFS_diag_output, &
use fv3atm_history_io_mod, only: fv3atm_diag_register, fv3atm_diag_output, &
DIAG_SIZE
use FV3GFS_restart_io_mod, only: FV3GFS_restart_register, &
use fv3atm_restart_io_mod, only: fv3atm_restart_register, &
fv3atm_checksum, &
fv_phy_restart_output, &
fv_sfc_restart_output
fv_sfc_restart_output, &
fv3atm_restart_read, &
fv3atm_restart_write
use fv_ufs_restart_io_mod, only: fv_dyn_restart_register, &
fv_dyn_restart_output
use fv_iau_mod, only: iau_external_data_type,getiauforcing,iau_initialize
Expand Down Expand Up @@ -369,7 +370,7 @@ subroutine update_atmos_radiation_physics (Atmos)

if (chksum_debug) then
if (mpp_pe() == mpp_root_pe()) print *,'RADIATION STEP ', GFS_control%kdt, GFS_control%fhour
call FV3GFS_GFS_checksum(GFS_control, GFS_data, Atm_block)
call fv3atm_checksum(GFS_control, GFS_data, Atm_block)
endif

if (mpp_pe() == mpp_root_pe() .and. debug) write(6,*) "physics driver"
Expand All @@ -383,7 +384,7 @@ subroutine update_atmos_radiation_physics (Atmos)

if (chksum_debug) then
if (mpp_pe() == mpp_root_pe()) print *,'PHYSICS STEP1 ', GFS_control%kdt, GFS_control%fhour
call FV3GFS_GFS_checksum(GFS_control, GFS_data, Atm_block)
call fv3atm_checksum(GFS_control, GFS_data, Atm_block)
endif

if (GFS_Control%do_sppt .or. GFS_Control%do_shum .or. GFS_Control%do_skeb .or. &
Expand All @@ -402,7 +403,7 @@ subroutine update_atmos_radiation_physics (Atmos)

if (chksum_debug) then
if (mpp_pe() == mpp_root_pe()) print *,'PHYSICS STEP2 ', GFS_control%kdt, GFS_control%fhour
call FV3GFS_GFS_checksum(GFS_control, GFS_data, Atm_block)
call fv3atm_checksum(GFS_control, GFS_data, Atm_block)
endif
call getiauforcing(GFS_control,IAU_data)
if (mpp_pe() == mpp_root_pe() .and. debug) write(6,*) "end of radiation and physics step"
Expand Down Expand Up @@ -736,15 +737,15 @@ subroutine atmos_model_init (Atmos, Time_init, Time, Time_step)
!rab call atmosphere_tracer_postinit (GFS_data, Atm_block)

call atmosphere_nggps_diag (Time, init=.true.)
call FV3GFS_diag_register (GFS_Diag, Time, Atm_block, GFS_control, Atmos%lon, Atmos%lat, Atmos%axes)
call fv3atm_diag_register (GFS_Diag, Time, Atm_block, GFS_control, Atmos%lon, Atmos%lat, Atmos%axes)
call GFS_restart_populate (GFS_restart_var, GFS_control, GFS_data%Statein, GFS_data%Stateout, GFS_data%Sfcprop, &
GFS_data%Coupling, GFS_data%Grid, GFS_data%Tbd, GFS_data%Cldprop, GFS_data%Radtend, &
GFS_data%IntDiag, Init_parm, GFS_Diag)
if (quilting_restart) then
call fv_dyn_restart_register (Atm(mygrid))
call FV3GFS_restart_register (GFS_data%Sfcprop, GFS_restart_var, Atm_block, GFS_control)
call fv3atm_restart_register (GFS_data%Sfcprop, GFS_restart_var, Atm_block, GFS_control)
endif
call FV3GFS_restart_read (GFS_data, GFS_restart_var, Atm_block, GFS_control, Atmos%domain_for_read, &
call fv3atm_restart_read (GFS_data, GFS_restart_var, Atm_block, GFS_control, Atmos%domain_for_read, &
Atm(mygrid)%flagstruct%warm_start, ignore_rst_cksum)
if(GFS_control%do_ca .and. Atm(mygrid)%flagstruct%warm_start)then
call read_ca_restart (Atmos%domain,GFS_control%ncells,GFS_control%nca,GFS_control%ncells_g,GFS_control%nca_g)
Expand Down Expand Up @@ -966,7 +967,7 @@ subroutine update_atmos_model_state (Atmos, rc)
if (chksum_debug) then
if (mpp_pe() == mpp_root_pe()) print *,'UPDATE STATE ', GFS_control%kdt, GFS_control%fhour
if (mpp_pe() == mpp_root_pe()) print *,'in UPDATE STATE ', size(GFS_data(1)%SfcProp%tsfc),'nblks=',Atm_block%nblks
call FV3GFS_GFS_checksum(GFS_control, GFS_data, Atm_block)
call fv3atm_checksum(GFS_control, GFS_data, Atm_block)
endif

!--- advance time ---
Expand Down Expand Up @@ -995,7 +996,7 @@ subroutine update_atmos_model_state (Atmos, rc)
endif
if (mpp_pe() == mpp_root_pe()) write(6,*) ' gfs diags time since last bucket empty: ',time_int/3600.,'hrs'
call atmosphere_nggps_diag(Atmos%Time)
call FV3GFS_diag_output(Atmos%Time, GFS_Diag, Atm_block, GFS_control%nx, GFS_control%ny, &
call fv3atm_diag_output(Atmos%Time, GFS_Diag, Atm_block, GFS_control%nx, GFS_control%ny, &
GFS_control%levs, 1, 1, 1.0_GFS_kind_phys, time_int, time_intfull, &
GFS_control%fhswr, GFS_control%fhlwr)
endif
Expand Down Expand Up @@ -1109,7 +1110,7 @@ subroutine atmos_model_restart(Atmos, timestamp)
call fv_dyn_restart_output(Atm(mygrid), timestamp)
else
call atmosphere_restart(timestamp)
call FV3GFS_restart_write (GFS_data, GFS_restart_var, Atm_block, &
call fv3atm_restart_write (GFS_data, GFS_restart_var, Atm_block, &
GFS_control, Atmos%domain, timestamp)
endif
if(GFS_control%do_ca)then
Expand Down
18 changes: 9 additions & 9 deletions fv3_cap.F90
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
!--------------- FV3GFS solo model -----------------
!--------------- FV3 ATM solo model ----------------
!
!*** The FV3 atmosphere grid component nuopc cap
!
Expand All @@ -11,7 +11,7 @@
! 02 Nov 2017: J. Wang Use Gerhard's transferable RouteHandle
!

module fv3gfs_cap_mod
module fv3atm_cap_mod

use ESMF
use NUOPC
Expand Down Expand Up @@ -80,14 +80,14 @@ module fv3gfs_cap_mod
contains

!-----------------------------------------------------------------------
!------------------- Solo fv3gfs code starts here ----------------------
!------------------- Solo fv3atm code starts here ----------------------
!-----------------------------------------------------------------------

subroutine SetServices(gcomp, rc)

type(ESMF_GridComp) :: gcomp
integer, intent(out) :: rc
character(len=*),parameter :: subname='(fv3gfs_cap:SetServices)'
character(len=*),parameter :: subname='(fv3atm_cap:SetServices)'

rc = ESMF_SUCCESS

Expand Down Expand Up @@ -983,7 +983,7 @@ subroutine InitializeRealize(gcomp, rc)
integer, intent(out) :: rc

! local variables
character(len=*),parameter :: subname='(fv3gfs_cap:InitializeRealize)'
character(len=*),parameter :: subname='(fv3atm_cap:InitializeRealize)'
type(ESMF_Clock) :: clock
type(ESMF_State) :: importState, exportState
integer :: urc
Expand Down Expand Up @@ -1248,7 +1248,7 @@ subroutine fv3_checkimport(gcomp, rc)
integer, intent(out) :: rc

! local variables
character(len=*),parameter :: subname='(fv3gfs_cap:fv3_checkimport)'
character(len=*),parameter :: subname='(fv3atm_cap:fv3_checkimport)'
integer :: n, nf
type(ESMF_Clock) :: clock
type(ESMF_Time) :: currTime, invalidTime
Expand Down Expand Up @@ -1335,7 +1335,7 @@ subroutine TimestampExport_phase1(gcomp, rc)
integer, intent(out) :: rc

! local variables
character(len=*),parameter :: subname='(fv3gfs_cap:TimestampExport_phase1)'
character(len=*),parameter :: subname='(fv3atm_cap:TimestampExport_phase1)'
type(ESMF_Clock) :: driverClock, modelClock
type(ESMF_State) :: exportState

Expand Down Expand Up @@ -1365,7 +1365,7 @@ subroutine ModelFinalize(gcomp, rc)
integer, intent(out) :: rc

! local variables
character(len=*),parameter :: subname='(fv3gfs_cap:ModelFinalize)'
character(len=*),parameter :: subname='(fv3atm_cap:ModelFinalize)'
integer :: i, urc
type(ESMF_VM) :: vm
real(kind=8) :: MPI_Wtime, timeffs
Expand Down Expand Up @@ -1413,4 +1413,4 @@ end subroutine ModelFinalize
!
!-----------------------------------------------------------------------------

end module fv3gfs_cap_mod
end module fv3atm_cap_mod
Loading

0 comments on commit f9d68ad

Please sign in to comment.