Skip to content

Modifications for DAcycling=true #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: gsl/develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/core_atmosphere/mpas_atm_core.F
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ function atm_core_init(domain, startTimeStamp) result(ierr)
real (kind=RKIND), pointer :: dt
type (block_type), pointer :: block

logical, pointer :: config_do_restart

logical, pointer :: config_do_restart
logical, pointer :: config_do_DAcycling
type (mpas_pool_type), pointer :: state
type (mpas_pool_type), pointer :: mesh
type (mpas_pool_type), pointer :: diag
Expand Down Expand Up @@ -116,6 +117,7 @@ function atm_core_init(domain, startTimeStamp) result(ierr)
end if

call mpas_pool_get_config(domain % blocklist % configs, 'config_do_restart', config_do_restart)
call mpas_pool_get_config(domain % blocklist % configs, 'config_do_DAcycling', config_do_DAcycling)
call mpas_pool_get_config(domain % blocklist % configs, 'config_dt', dt)

!
Expand All @@ -137,6 +139,8 @@ function atm_core_init(domain, startTimeStamp) result(ierr)
call mpas_timer_start('read_ICs')
if (config_do_restart) then
init_stream_name = 'restart'
elseif (config_do_DAcycling) then
init_stream_name = 'da_state'
Copy link
Collaborator

@barlage barlage Jun 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does there need to be an alarm reset like init/restart on lines 163/164 added below line 164?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with @barlage . We need to add one line after line 164 as follows:
call MPAS_stream_mgr_reset_alarms(domain % streamManager, streamID='da_state', direction=MPAS_STREAM_INPUT, ierr=ierr)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The line to reset the alarm for da_state is added.

else
init_stream_name = 'input'
end if
Expand All @@ -158,6 +162,7 @@ function atm_core_init(domain, startTimeStamp) result(ierr)

call MPAS_stream_mgr_reset_alarms(domain % streamManager, streamID='input', direction=MPAS_STREAM_INPUT, ierr=ierr)
call MPAS_stream_mgr_reset_alarms(domain % streamManager, streamID='restart', direction=MPAS_STREAM_INPUT, ierr=ierr)
call MPAS_stream_mgr_reset_alarms(domain % streamManager, streamID='da_state', direction=MPAS_STREAM_INPUT, ierr=ierr)
call mpas_log_write(' ----- done reading initial state -----')


Expand Down Expand Up @@ -642,6 +647,8 @@ function atm_core_run(domain) result(ierr)

! Avoid writing a restart file at the initial time
call MPAS_stream_mgr_reset_alarms(domain % streamManager, streamID='restart', direction=MPAS_STREAM_OUTPUT, ierr=ierr)
! Avoid writing a mpasout file at the initial time
call MPAS_stream_mgr_reset_alarms(domain % streamManager, streamID='da_state', direction=MPAS_STREAM_OUTPUT, ierr=ierr)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will Line 650 complain if streams.atmosphere does not define da_state?

Since da_state only applies to DAcycling, maybe we can add an if block here?

if (config_do_DAcycling) then
    call MPAS_stream_mgr_reset_alarms(domain % streamManager, streamID='da_state', direction=MPAS_STREAM_OUTPUT, ierr=ierr)
end if

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I jut copied what they do for restart, there is no 'if (restart) around it.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Then I think it is fine. Thanks!


! Also, for restart runs, avoid writing the initial history or diagnostics fields to avoid overwriting those from the preceding run
if (config_do_restart) then
Expand Down
1 change: 1 addition & 0 deletions src/core_atmosphere/physics/MYNN-EDMF
Submodule MYNN-EDMF added at 62ae65
1 change: 1 addition & 0 deletions src/core_atmosphere/physics/TEMPO
Submodule TEMPO added at eb0cbc
1 change: 1 addition & 0 deletions src/core_atmosphere/physics/UGWP
Submodule UGWP added at 114f8e
4 changes: 4 additions & 0 deletions src/core_atmosphere/physics/mpas_atmphys_driver_lsm.F
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,7 @@ subroutine driver_lsm(itimestep,configs,mesh,diag_physics,sfc_input,its,ite)

!local pointers:
logical,pointer:: config_sfc_albedo
logical,pointer:: restart, cycling
character(len=StrKIND),pointer:: lsm_scheme
character(len=StrKIND),pointer:: mminlu
integer,pointer:: isice
Expand All @@ -918,6 +919,8 @@ subroutine driver_lsm(itimestep,configs,mesh,diag_physics,sfc_input,its,ite)
call mpas_pool_get_config(configs,'config_sfc_albedo' ,config_sfc_albedo )
call mpas_pool_get_config(configs,'config_lsm_scheme',lsm_scheme)
call mpas_pool_get_config(configs,'config_lakemodel',lakemodel)
call mpas_pool_get_config(configs,'config_do_restart',restart)
call mpas_pool_get_config(configs,'config_do_DAcycling',cycling)
call mpas_pool_get_array(sfc_input,'mminlu',mminlu)
call mpas_pool_get_array(sfc_input,'isice' ,isice )
call mpas_pool_get_array(sfc_input,'iswater',iswater)
Expand Down Expand Up @@ -989,6 +992,7 @@ subroutine driver_lsm(itimestep,configs,mesh,diag_physics,sfc_input,its,ite)

call mpas_log_write('--- call subroutine ruc_land:')
call ruc_land( spp_lsm = spp_lsm_loc , lakemodel = lakemodel , lakemask = lakemask_p, &
restart = restart , cycling = cycling , &
rhosnf = rhosnf_p , precipfr = precipfr_p , mosaic_lu = mosaic_lu, &
qsg = qsg_p , qvg = qvg_p , dew = dew_p, &
soilt1 = soilt1_p , tsnav = tsnav_p , acrunoff = acrunoff_p, &
Expand Down
5 changes: 5 additions & 0 deletions src/core_atmosphere/physics/mpas_atmphys_driver_seaice.F
Original file line number Diff line number Diff line change
Expand Up @@ -695,12 +695,16 @@ subroutine driver_seaice(itimestep,configs,mesh,diag_physics,sfc_input,its,ite)
integer,pointer:: isice,iswater
integer,pointer:: spp_lsm_loc
integer,pointer:: globalCells(:)
logical,pointer:: restart, cycling

!-----------------------------------------------------------------------------------------------------------------
!call mpas_log_write(' ')
!call mpas_log_write('--- enter subroutine driver_seaice: xice_threshold = $r',realArgs=(/xice_threshold/))

call mpas_pool_get_config(configs,'config_lsm_scheme',lsm_scheme)
call mpas_pool_get_config(configs,'config_do_restart',restart)
call mpas_pool_get_config(configs,'config_do_DAcycling',cycling)


!copy MPAS arrays to local arrays:
call seaice_from_MPAS(configs,mesh,diag_physics,sfc_input,its,ite)
Expand Down Expand Up @@ -778,6 +782,7 @@ subroutine driver_seaice(itimestep,configs,mesh,diag_physics,sfc_input,its,ite)

call mpas_log_write('--- call subroutine ruc_ice:')
call ruc_ice( spp_lsm = spp_lsm_loc , iswater = iswater , chklowq = chklowq_p, &
restart = restart , cycling = cycling , &
rhosnf = rhosnf_p , precipfr = precipfr_p , chs = chs_p, &
qsg = qsg_p , qvg = qvg_p , dew = dew_p, &
soilt1 = soilt1_p , tsnav = tsnav_p , acrunoff = acrunoff_p, &
Expand Down
22 changes: 15 additions & 7 deletions src/core_atmosphere/physics/mpas_atmphys_driver_sfclayer.F
Original file line number Diff line number Diff line change
Expand Up @@ -1162,6 +1162,7 @@ subroutine driver_sfclayer(itimestep,configs,mesh,diag_physics,sfc_input,its,ite

!local pointers:
logical,pointer:: config_do_restart,config_frac_seaice
logical,pointer:: config_do_DAcycling
character(len=StrKIND),pointer:: sfclayer_scheme
real(kind=RKIND),dimension(:),pointer:: areaCell

Expand All @@ -1181,10 +1182,11 @@ subroutine driver_sfclayer(itimestep,configs,mesh,diag_physics,sfc_input,its,ite
errmsg = ' '
errflg = 0

call mpas_pool_get_config(configs,'config_do_restart' ,config_do_restart )
call mpas_pool_get_config(configs,'config_frac_seaice' ,config_frac_seaice)
call mpas_pool_get_config(configs,'config_sfclayer_scheme',sfclayer_scheme )

call mpas_pool_get_config(configs,'config_do_restart' ,config_do_restart )
call mpas_pool_get_config(configs,'config_frac_seaice' ,config_frac_seaice )
call mpas_pool_get_config(configs,'config_sfclayer_scheme',sfclayer_scheme )
call mpas_pool_get_config(configs,'config_do_DAcycling' ,config_do_DAcycling)

call mpas_pool_get_array(mesh,'areaCell',areaCell)

!copy all MPAS arrays to rectanguler grid:
Expand All @@ -1193,7 +1195,7 @@ subroutine driver_sfclayer(itimestep,configs,mesh,diag_physics,sfc_input,its,ite
dx = sqrt(maxval(areaCell))

initflag = 1
if(config_do_restart .or. itimestep > 1) initflag = 0
if(config_do_restart .or. config_do_DAcycling .or. itimestep > 1) initflag = 0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tanyasmirnova Could you help me understand what initflag means?
0 means init from cold start? 1 means init from warm start? Thanks!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initflag = 1 for cold-start, and initflag=0 for restart and DAcycling.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Thanks!


sfclayer_select: select case (trim(sfclayer_scheme))

Expand Down Expand Up @@ -1413,7 +1415,10 @@ subroutine driver_sfclayer(itimestep,configs,mesh,diag_physics,sfc_input,its,ite
ustm = ustm_p , ck = ck_p , cka = cka_p , &
cd = cd_p , cda = cda_p , ch = ch_p , &
qcg = qcg_p , spp_pbl = spp_pbl , isftcflx = isftcflx , &
iz0tlnd = iz0tlnd , itimestep = initflag , &
iz0tlnd = iz0tlnd , &
itimestep= itimestep , initflag = initflag , &
restart = config_do_restart , &
cycling = config_do_DAcycling , &
errmsg = errmsg , errflg = errflg , &
ids = ids , ide = ide , jds = jds , jde = jde , kds = kds , kde = kde , &
ims = ims , ime = ime , jms = jms , jme = jme , kms = kms , kme = kme , &
Expand Down Expand Up @@ -1445,7 +1450,10 @@ subroutine driver_sfclayer(itimestep,configs,mesh,diag_physics,sfc_input,its,ite
ustm = ustm_sea , ck = ck_sea , cka = cka_sea , &
cd = cd_sea , cda = cda_sea , ch = ch_sea , &
qcg = qcg_p , spp_pbl = spp_pbl , isftcflx = isftcflx , &
iz0tlnd = iz0tlnd , itimestep = initflag , &
iz0tlnd = iz0tlnd , &
itimestep= itimestep , initflag = initflag , &
restart = config_do_restart , &
cycling = config_do_DAcycling , &
errmsg = errmsg , errflg = errflg , &
ids = ids , ide = ide , jds = jds , jde = jde , kds = kds , kde = kde , &
ims = ims , ime = ime , jms = jms , jme = jme , kms = kms , kme = kme , &
Expand Down
6 changes: 4 additions & 2 deletions src/core_atmosphere/physics/mpas_atmphys_init.F
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ subroutine physics_init(dminfo,stream_manager,clock,configs,mesh,diag,tend,state

!local pointers:
logical,pointer:: config_do_restart, &
config_do_DAcycling, &
config_o3climatology, &
config_oml1d

Expand Down Expand Up @@ -162,6 +163,7 @@ subroutine physics_init(dminfo,stream_manager,clock,configs,mesh,diag,tend,state
!call mpas_log_write('--- enter subroutine physics_init:')

call mpas_pool_get_config(configs,'config_do_restart' ,config_do_restart )
call mpas_pool_get_config(configs,'config_do_DAcycling' ,config_do_DAcycling )
call mpas_pool_get_config(configs,'config_o3climatology' ,config_o3climatology )
call mpas_pool_get_config(configs,'config_convection_scheme',config_convection_scheme)
call mpas_pool_get_config(configs,'config_lsm_scheme' ,config_lsm_scheme )
Expand Down Expand Up @@ -308,7 +310,7 @@ subroutine physics_init(dminfo,stream_manager,clock,configs,mesh,diag,tend,state
endif

!initialization of xicem:
if(.not.config_do_restart) then
if(.not.config_do_restart .and. .not. config_do_DAcycling) then
! call mpas_log_write('--- initialization of xicem:')
do iCell = 1, nCellsSolve
xicem(iCell) = xice(iCell)
Expand All @@ -318,7 +320,7 @@ subroutine physics_init(dminfo,stream_manager,clock,configs,mesh,diag,tend,state
!initialization of the local sea-surface temperature when a diurnal cycle of the
!sea-surface temperature is applied. This avoids having the array sstsk equal to
!zero over land:
if(.not. config_do_restart) then
if(.not. config_do_restart .and. .not. config_do_DAcycling) then
! call mpas_log_write('--- initialization of sstsk:')
do iCell = 1, nCellsSolve
sstsk(iCell) = sst(iCell)
Expand Down
16 changes: 14 additions & 2 deletions src/core_atmosphere/physics/mpas_atmphys_landuse.F
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ subroutine landuse_init_forMPAS(dminfo,julday,mesh,configs,diag_physics,sfc_inpu

!local pointers:
logical,pointer:: config_do_restart, &
config_do_DAcycling,&
config_frac_seaice, &
config_sfc_albedo

Expand Down Expand Up @@ -135,6 +136,7 @@ subroutine landuse_init_forMPAS(dminfo,julday,mesh,configs,diag_physics,sfc_inpu
!call mpas_log_write('--- enter subroutine landuse_init_forMPAS:')

call mpas_pool_get_config(configs,'config_do_restart' ,config_do_restart )
call mpas_pool_get_config(configs,'config_do_DAcycling' ,config_do_DAcycling )
call mpas_pool_get_config(configs,'config_frac_seaice',config_frac_seaice)
call mpas_pool_get_config(configs,'config_sfc_albedo' ,config_sfc_albedo )
call mpas_pool_get_config(configs,'config_lsm_scheme' ,config_lsm_scheme )
Expand Down Expand Up @@ -164,7 +166,8 @@ subroutine landuse_init_forMPAS(dminfo,julday,mesh,configs,diag_physics,sfc_inpu
call mpas_pool_get_array(diag_physics,'xicem' ,xicem )
call mpas_pool_get_array(diag_physics,'z0' ,z0 )
call mpas_pool_get_array(diag_physics,'znt' ,znt )
if (config_lsm_scheme .eq. 'ruc') then

if (config_lsm_scheme .eq. 'sf_ruc') then
call mpas_pooL_get_array(diag_physics,'spp_lsm_loc' , spp_lsm_loc)
spp_lsm_loc = 0 !hardcode as 0 for now
call mpas_pool_get_array(diag_physics,'mosaic_lu' , mosaic_lu )
Expand All @@ -179,6 +182,7 @@ subroutine landuse_init_forMPAS(dminfo,julday,mesh,configs,diag_physics,sfc_inpu
!call mpas_log_write('--- config_frac_seaice = $1',logicArgs=(/config_frac_seaice/))
!call mpas_log_write('--- xice_threshold = $r',realArgs=(/xice_threshold/))

if((config_lsm_scheme .ne. 'sf_ruc')) then
!reads in the landuse properties from landuse.tbl:
if(dminfo % my_proc_id == IO_NODE) then
!get a unit to open init file:
Expand Down Expand Up @@ -264,11 +268,19 @@ subroutine landuse_init_forMPAS(dminfo,julday,mesh,configs,diag_physics,sfc_inpu
!call mpas_log_write('--- isice =$i',intArgs=(/isice/))
!call mpas_log_write('--- iswater =$i',intArgs=(/iswater/))
!call mpas_log_write('--- isurban =$i',intArgs=(/isurban/))
if(config_do_restart) then
endif ! not sf_ruc

if(config_do_restart ) then
call mpas_log_write('--- config_do_restart =$l', logicArgs=(/config_do_restart/))
call mpas_log_write('--- skip the end of landuse_init_forMPAS')
return
endif
if(config_do_DAcycling) then
call mpas_log_write('--- config_do_DAcycling =$l', logicArgs=(/config_do_restart/))
call mpas_log_write('--- skip the end of landuse_init_forMPAS')
return
endif


!defines the surface properties over the entire domain:
do iCell = 1, nCells
Expand Down
7 changes: 4 additions & 3 deletions src/core_atmosphere/physics/mpas_atmphys_lsm_rucinit.F
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ subroutine ruclsminit(dminfo,mesh,configs,diag_physics,sfc_input)
type(mpas_pool_type),intent(inout):: sfc_input

!local pointers::
logical,pointer:: input_sfc_albedo,restart
logical,pointer:: input_sfc_albedo,restart,cycling

character(len=StrKIND),pointer:: mminlu,mminsl

Expand Down Expand Up @@ -122,6 +122,8 @@ subroutine ruclsminit(dminfo,mesh,configs,diag_physics,sfc_input)
call mpas_pool_get_config(configs,'input_soil_data' ,mminsl )
call mpas_pool_get_config(configs,'config_sfc_snowalbedo',input_sfc_albedo)
call mpas_pool_get_config(configs,'config_do_restart' ,restart )
call mpas_pool_get_config(configs,'config_do_DAcycling' ,cycling )


call mpas_pool_get_dimension(mesh,'nCells' ,nCells )
call mpas_pool_get_dimension(mesh,'nSoilLevels',nSoilLevels)
Expand Down Expand Up @@ -171,8 +173,7 @@ subroutine ruclsminit(dminfo,mesh,configs,diag_physics,sfc_input)
call physics_message('--- end initialize RUC LSM tables' )
call mpas_log_write('')


if(.not.restart) then
if(.not.restart .and. .not. cycling) then

errflag = 0
do iCell = 1, nCells
Expand Down
15 changes: 8 additions & 7 deletions src/core_atmosphere/physics/physics_wrf/module_mynnsfclay.F90
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ subroutine mynnsfclay( &
svp3,svpt0,ep1,ep2,karman,ch,qcg, &
itimestep,wstar,qstar,ustm,ck,cka, &
cd,cda,spp_pbl,rstoch1d,isftcflx, &
iz0tlnd,its,ite,errmsg,errflg &
iz0tlnd,its,ite,restart_or_cycle, &
errmsg,errflg &
)
implicit none
!=================================================================================================================
Expand All @@ -162,7 +163,7 @@ subroutine mynnsfclay( &
!-----------------------------
! namelist options
!-----------------------------
logical,intent(in):: spp_pbl
logical,intent(in):: spp_pbl,restart_or_cycle

integer,intent(in):: isfflx
integer,intent(in),optional:: isftcflx,iz0tlnd
Expand Down Expand Up @@ -385,7 +386,7 @@ subroutine mynnsfclay( &
! according to Akb(1976), Eq(12).
!--------------------------------------------------------
br(i)=govrth(i)*za(i)*dthvdz/(wspd(i)*wspd(i))
if (itimestep == 1) then
if (.not. restart_or_cycle .and. itimestep == 1) then
!set limits according to Li et al. (2010) boundary-layer meteorol (p.158)
br(i)=max(br(i),-2.0)
br(i)=min(br(i),2.0)
Expand Down Expand Up @@ -599,8 +600,8 @@ subroutine mynnsfclay( &
regime(i)=2.
endif

!compute z/l first guess:
if (itimestep .le. 1) then
if (.not. restart_or_cycle .or. (restart_or_cycle .and. itimestep > 1) ) then
!compute z/l first guess:
call li_etal_2010(zol(i),br(i),za(i)/zntstoch(i),zratio(i))
else
zol(i)=za(i)*karman*g*mol(i)/(th1d(i)*max(ust(i)*ust(i),0.0001))
Expand Down Expand Up @@ -684,8 +685,8 @@ subroutine mynnsfclay( &
!==========================================================
regime(i)=4.

!compute z/l first guess:
if (itimestep .le. 1) then
if (.not. restart_or_cycle .or. (restart_or_cycle .and. itimestep > 1) ) then
!compute z/l first guess:
call li_etal_2010(zol(i),br(i),za(i)/zntstoch(i),zratio(i))
else
zol(i)=za(i)*karman*g*mol(i)/(th1d(i)*max(ust(i)*ust(i),0.001))
Expand Down
Loading