Skip to content

Commit

Permalink
Add p8b SDF (NCAR#491)
Browse files Browse the repository at this point in the history
* add p8 suite files
* fix 2phases intermediate restart

Co-authored-by: Raffaele Montuoro <[email protected]>
Co-authored-by: Jun Wang <[email protected]>
  • Loading branch information
3 people authored Mar 10, 2022
1 parent 47d391c commit 3bcba51
Show file tree
Hide file tree
Showing 3 changed files with 228 additions and 51 deletions.
96 changes: 96 additions & 0 deletions ccpp/suites/suite_FV3_GFS_v17_coupled_p8.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>

<suite name="FV3_GFS_v17_coupled_p8" version="1">
<!-- <init></init> -->
<group name="time_vary">
<subcycle loop="1">
<scheme>GFS_time_vary_pre</scheme>
<scheme>GFS_rrtmg_setup</scheme>
<scheme>GFS_rad_time_vary</scheme>
<scheme>GFS_phys_time_vary</scheme>
</subcycle>
</group>
<group name="radiation">
<subcycle loop="1">
<scheme>GFS_suite_interstitial_rad_reset</scheme>
<scheme>GFS_rrtmg_pre</scheme>
<scheme>GFS_radiation_surface</scheme>
<scheme>rrtmg_sw_pre</scheme>
<scheme>rrtmg_sw</scheme>
<scheme>rrtmg_sw_post</scheme>
<scheme>rrtmg_lw_pre</scheme>
<scheme>rrtmg_lw</scheme>
<scheme>rrtmg_lw_post</scheme>
<scheme>GFS_rrtmg_post</scheme>
</subcycle>
</group>
<group name="physics">
<subcycle loop="1">
<scheme>GFS_suite_interstitial_phys_reset</scheme>
<scheme>GFS_suite_stateout_reset</scheme>
<scheme>get_prs_fv3</scheme>
<scheme>GFS_suite_interstitial_1</scheme>
<scheme>GFS_surface_generic_pre</scheme>
<scheme>GFS_surface_composites_pre</scheme>
<scheme>dcyc2t3</scheme>
<scheme>GFS_surface_composites_inter</scheme>
<scheme>GFS_suite_interstitial_2</scheme>
</subcycle>
<!-- Surface iteration loop -->
<subcycle loop="2">
<scheme>sfc_diff</scheme>
<scheme>GFS_surface_loop_control_part1</scheme>
<scheme>sfc_nst_pre</scheme>
<scheme>sfc_nst</scheme>
<scheme>sfc_nst_post</scheme>
<scheme>noahmpdrv</scheme>
<scheme>sfc_cice</scheme>
<scheme>sfc_sice</scheme>
<scheme>GFS_surface_loop_control_part2</scheme>
</subcycle>
<!-- End of surface iteration loop -->
<subcycle loop="1">
<scheme>GFS_surface_composites_post</scheme>
<scheme>sfc_diag</scheme>
<scheme>sfc_diag_post</scheme>
<scheme>GFS_surface_generic_post</scheme>
<scheme>GFS_PBL_generic_pre</scheme>
<scheme>satmedmfvdifq</scheme>
<scheme>GFS_PBL_generic_post</scheme>
<scheme>GFS_GWD_generic_pre</scheme>
<scheme>unified_ugwp</scheme>
<scheme>unified_ugwp_post</scheme>
<scheme>GFS_GWD_generic_post</scheme>
<scheme>GFS_suite_stateout_update</scheme>
<scheme>ozphys_2015</scheme>
<scheme>h2ophys</scheme>
<scheme>get_phi_fv3</scheme>
<scheme>GFS_suite_interstitial_3</scheme>
<scheme>GFS_DCNV_generic_pre</scheme>
<scheme>samfdeepcnv</scheme>
<scheme>GFS_DCNV_generic_post</scheme>
<scheme>GFS_SCNV_generic_pre</scheme>
<scheme>samfshalcnv</scheme>
<scheme>GFS_SCNV_generic_post</scheme>
<scheme>GFS_suite_interstitial_4</scheme>
<scheme>cnvc90</scheme>
<scheme>GFS_MP_generic_pre</scheme>
<scheme>mp_thompson_pre</scheme>
</subcycle>
<subcycle loop="1">
<scheme>mp_thompson</scheme>
</subcycle>
<subcycle loop="1">
<scheme>mp_thompson_post</scheme>
<scheme>GFS_MP_generic_post</scheme>
<scheme>maximum_hourly_diagnostics</scheme>
</subcycle>
</group>
<group name="stochastics">
<subcycle loop="1">
<scheme>GFS_stochastics</scheme>
<scheme>phys_tend</scheme>
</subcycle>
</group>
<!-- <finalize></finalize> -->
</suite>
95 changes: 95 additions & 0 deletions ccpp/suites/suite_FV3_GFS_v17_p8.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8"?>

<suite name="FV3_GFS_v17_p8" version="1">
<!-- <init></init> -->
<group name="time_vary">
<subcycle loop="1">
<scheme>GFS_time_vary_pre</scheme>
<scheme>GFS_rrtmg_setup</scheme>
<scheme>GFS_rad_time_vary</scheme>
<scheme>GFS_phys_time_vary</scheme>
</subcycle>
</group>
<group name="radiation">
<subcycle loop="1">
<scheme>GFS_suite_interstitial_rad_reset</scheme>
<scheme>GFS_rrtmg_pre</scheme>
<scheme>GFS_radiation_surface</scheme>
<scheme>rrtmg_sw_pre</scheme>
<scheme>rrtmg_sw</scheme>
<scheme>rrtmg_sw_post</scheme>
<scheme>rrtmg_lw_pre</scheme>
<scheme>rrtmg_lw</scheme>
<scheme>rrtmg_lw_post</scheme>
<scheme>GFS_rrtmg_post</scheme>
</subcycle>
</group>
<group name="physics">
<subcycle loop="1">
<scheme>GFS_suite_interstitial_phys_reset</scheme>
<scheme>GFS_suite_stateout_reset</scheme>
<scheme>get_prs_fv3</scheme>
<scheme>GFS_suite_interstitial_1</scheme>
<scheme>GFS_surface_generic_pre</scheme>
<scheme>GFS_surface_composites_pre</scheme>
<scheme>dcyc2t3</scheme>
<scheme>GFS_surface_composites_inter</scheme>
<scheme>GFS_suite_interstitial_2</scheme>
</subcycle>
<!-- Surface iteration loop -->
<subcycle loop="2">
<scheme>sfc_diff</scheme>
<scheme>GFS_surface_loop_control_part1</scheme>
<scheme>sfc_nst_pre</scheme>
<scheme>sfc_nst</scheme>
<scheme>sfc_nst_post</scheme>
<scheme>noahmpdrv</scheme>
<scheme>sfc_sice</scheme>
<scheme>GFS_surface_loop_control_part2</scheme>
</subcycle>
<!-- End of surface iteration loop -->
<subcycle loop="1">
<scheme>GFS_surface_composites_post</scheme>
<scheme>sfc_diag</scheme>
<scheme>sfc_diag_post</scheme>
<scheme>GFS_surface_generic_post</scheme>
<scheme>GFS_PBL_generic_pre</scheme>
<scheme>satmedmfvdifq</scheme>
<scheme>GFS_PBL_generic_post</scheme>
<scheme>GFS_GWD_generic_pre</scheme>
<scheme>unified_ugwp</scheme>
<scheme>unified_ugwp_post</scheme>
<scheme>GFS_GWD_generic_post</scheme>
<scheme>GFS_suite_stateout_update</scheme>
<scheme>ozphys_2015</scheme>
<scheme>h2ophys</scheme>
<scheme>get_phi_fv3</scheme>
<scheme>GFS_suite_interstitial_3</scheme>
<scheme>GFS_DCNV_generic_pre</scheme>
<scheme>samfdeepcnv</scheme>
<scheme>GFS_DCNV_generic_post</scheme>
<scheme>GFS_SCNV_generic_pre</scheme>
<scheme>samfshalcnv</scheme>
<scheme>GFS_SCNV_generic_post</scheme>
<scheme>GFS_suite_interstitial_4</scheme>
<scheme>cnvc90</scheme>
<scheme>GFS_MP_generic_pre</scheme>
<scheme>mp_thompson_pre</scheme>
</subcycle>
<subcycle loop="1">
<scheme>mp_thompson</scheme>
</subcycle>
<subcycle loop="1">
<scheme>mp_thompson_post</scheme>
<scheme>GFS_MP_generic_post</scheme>
<scheme>maximum_hourly_diagnostics</scheme>
</subcycle>
</group>
<group name="stochastics">
<subcycle loop="1">
<scheme>GFS_stochastics</scheme>
<scheme>phys_tend</scheme>
</subcycle>
</group>
<!-- <finalize></finalize> -->
</suite>
88 changes: 37 additions & 51 deletions module_fcst_grid_comp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ module module_fcst_grid_comp
integer :: ngrids, mygrid
integer,dimension(:),allocatable :: grid_number_on_all_pets(:)

integer :: num_atmos_calls, intrm_rst
integer :: intrm_rst, n_atmsteps

!----- coupled model data -----

Expand Down Expand Up @@ -324,10 +324,8 @@ subroutine fcst_initialize(fcst_comp, importState, exportState, clock, rc)
!
type(ESMF_VM) :: VM
type(ESMF_Time) :: CurrTime, StartTime, StopTime
type(ESMF_TimeInterval) :: RunDuration
type(ESMF_Config) :: cf

integer :: Run_length
integer,dimension(6) :: date, date_end
!
character(len=9) :: month
Expand Down Expand Up @@ -523,19 +521,11 @@ subroutine fcst_initialize(fcst_comp, importState, exportState, clock, rc)
endif ! fexist
endif ! mype == 0

RunDuration = StopTime - CurrTime

CALL ESMF_TimeIntervalGet(RunDuration, S=Run_length, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
!
call diag_manager_init (TIME_INIT=date)
call diag_manager_set_time_end(Time_end)
!
Time_step = set_time (dt_atmos,0)
num_atmos_calls = Run_length / dt_atmos
if (mype == 0) write(*,*)'num_atmos_calls=',num_atmos_calls,'time_init=', &
date_init,'time=',date,'time_end=',date_end,'dt_atmos=',dt_atmos, &
'Run_length=',Run_length
if (mype == 0) write(*,*)'time_init=', date_init,'time=',date,'time_end=',date_end,'dt_atmos=',dt_atmos

! set up forecast time array that controls when to write out restart files
frestart = 0
Expand Down Expand Up @@ -588,6 +578,13 @@ subroutine fcst_initialize(fcst_comp, importState, exportState, clock, rc)
! if to write out restart at the end of forecast
restart_endfcst = .false.
if ( ANY(frestart(:) == total_inttime) ) restart_endfcst = .true.
! frestart only contains intermediate restart
do i=1,size(frestart)
if(frestart(i) == total_inttime) then
frestart(i) = 0
exit
endif
enddo
if (mype == 0) print *,'frestart=',frestart(1:10)/3600, 'restart_endfcst=',restart_endfcst, &
'total_inttime=',total_inttime
! if there is restart writing during integration
Expand Down Expand Up @@ -946,8 +943,7 @@ subroutine fcst_run_phase_1(fcst_comp, importState, exportState,clock,rc)
!
!*** local variables
!
integer :: mype, na
integer(kind=ESMF_KIND_I8) :: ntimestep_esmf
integer :: mype, seconds
real(kind=8) :: mpi_wtime, tbeg1
!
!-----------------------------------------------------------------------
Expand All @@ -961,11 +957,9 @@ subroutine fcst_run_phase_1(fcst_comp, importState, exportState,clock,rc)
!
call ESMF_GridCompGet(fcst_comp, localpet=mype, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
!
call ESMF_ClockGet(clock, advanceCount=NTIMESTEP_ESMF, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return

na = NTIMESTEP_ESMF
call get_time(Atmos%Time - Atmos%Time_init, seconds)
n_atmsteps = seconds/dt_atmos
!
!-----------------------------------------------------------------------
! *** call fcst integration subroutines
Expand All @@ -977,7 +971,7 @@ subroutine fcst_run_phase_1(fcst_comp, importState, exportState,clock,rc)
call atmos_model_exchange_phase_1 (Atmos, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return

if (mype == 0) write(*,*)"PASS: fcstRUN phase 1, na = ",na, ' time is ', mpi_wtime()-tbeg1
if (mype == 0) write(*,*)"PASS: fcstRUN phase 1, n_atmsteps = ",n_atmsteps, ' time is ', mpi_wtime()-tbeg1
!
!-----------------------------------------------------------------------
!
Expand All @@ -1000,8 +994,7 @@ subroutine fcst_run_phase_2(fcst_comp, importState, exportState,clock,rc)
!
!*** local variables
!
integer :: mype, na, date(6), seconds
integer(kind=ESMF_KIND_I8) :: ntimestep_esmf
integer :: mype, date(6), seconds
character(len=64) :: timestamp
integer :: unit
real(kind=8) :: mpi_wtime, tbeg1
Expand All @@ -1017,11 +1010,6 @@ subroutine fcst_run_phase_2(fcst_comp, importState, exportState,clock,rc)
!
call ESMF_GridCompGet(fcst_comp, localpet=mype, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return

call ESMF_ClockGet(clock, advanceCount=NTIMESTEP_ESMF, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return

na = NTIMESTEP_ESMF
!
!-----------------------------------------------------------------------
! *** call fcst integration subroutines
Expand All @@ -1034,35 +1022,33 @@ subroutine fcst_run_phase_2(fcst_comp, importState, exportState,clock,rc)

!--- intermediate restart
if (intrm_rst>0) then
if (na /= num_atmos_calls-1) then
call get_time(Atmos%Time - Atmos%Time_init, seconds)
if (ANY(frestart(:) == seconds)) then
if (mype == 0) write(*,*)'write out restart at na=',na,' seconds=',seconds, &
'integration lenght=',na*dt_atmos/3600.

timestamp = date_to_string (Atmos%Time)
call atmos_model_restart(Atmos, timestamp)
call write_stoch_restart_atm('RESTART/'//trim(timestamp)//'.atm_stoch.res.nc')

!----- write restart file ------
if (mpp_pe() == mpp_root_pe())then
call get_date (Atmos%Time, date(1), date(2), date(3), &
date(4), date(5), date(6))
call mpp_open( unit, 'RESTART/'//trim(timestamp)//'.coupler.res', nohdrs=.TRUE. )
write( unit, '(i6,8x,a)' )calendar_type, &
'(Calendar: no_calendar=0, thirty_day_months=1, julian=2, gregorian=3, noleap=4)'

write( unit, '(6i6,8x,a)' )date_init, &
'Model start time: year, month, day, hour, minute, second'
write( unit, '(6i6,8x,a)' )date, &
'Current model time: year, month, day, hour, minute, second'
call mpp_close(unit)
endif
call get_time(Atmos%Time - Atmos%Time_init, seconds)
if (ANY(frestart(:) == seconds)) then
if (mype == 0) write(*,*)'write out restart at n_atmsteps=',n_atmsteps,' seconds=',seconds, &
'integration length=',n_atmsteps*dt_atmos/3600.

timestamp = date_to_string (Atmos%Time)
call atmos_model_restart(Atmos, timestamp)
call write_stoch_restart_atm('RESTART/'//trim(timestamp)//'.atm_stoch.res.nc')

!----- write restart file ------
if (mpp_pe() == mpp_root_pe())then
call get_date (Atmos%Time, date(1), date(2), date(3), &
date(4), date(5), date(6))
call mpp_open( unit, 'RESTART/'//trim(timestamp)//'.coupler.res', nohdrs=.TRUE. )
write( unit, '(i6,8x,a)' )calendar_type, &
'(Calendar: no_calendar=0, thirty_day_months=1, julian=2, gregorian=3, noleap=4)'

write( unit, '(6i6,8x,a)' )date_init, &
'Model start time: year, month, day, hour, minute, second'
write( unit, '(6i6,8x,a)' )date, &
'Current model time: year, month, day, hour, minute, second'
call mpp_close(unit)
endif
endif
endif

if (mype == 0) write(*,*)"PASS: fcstRUN phase 2, na = ",na, ' time is ', mpi_wtime()-tbeg1
if (mype == 0) write(*,*)"PASS: fcstRUN phase 2, n_atmsteps = ",n_atmsteps, ' time is ', mpi_wtime()-tbeg1
!
!-----------------------------------------------------------------------
!
Expand Down

0 comments on commit 3bcba51

Please sign in to comment.