Skip to content
Draft
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
8 changes: 5 additions & 3 deletions datm/atm_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
integer :: current_mon ! model month
integer :: current_day ! model day
integer :: current_tod ! model sec into model date
logical :: is_scol ! true if this is a single-column run
integer(i8) :: stepno ! step number
real(r8) :: nextsw_cday ! calendar of next atm sw
character(CL) :: cvalue ! character string for input config
Expand All @@ -450,16 +451,17 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)

! Initialize mesh, restart flag, compid, and logunit
call ESMF_TraceRegionEnter('datm_strdata_init')
call dshr_mesh_init(gcomp, sdat, nullstr, logunit, 'ATM', nx_global, ny_global, &
model_meshfile, model_maskfile, model_mesh, model_mask, model_frac, restart_read, rc=rc)
call dshr_mesh_init(gcomp, sdat, nullstr, logunit, 'ATM', &
model_meshfile, model_maskfile, model_mesh, model_mask, model_frac, restart_read, is_scol, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! Initialize stream data type
streamfilename = 'datm.streams'//trim(inst_suffix)
#ifndef DISABLE_FoX
streamfilename = trim(streamfilename)//'.xml'
#endif
call shr_strdata_init_from_config(sdat, streamfilename, model_mesh, clock, 'ATM', logunit, rc=rc)
call shr_strdata_init_from_config(sdat, streamfilename, model_mesh, nx_global, ny_global, is_scol, &
clock, 'ATM', logunit, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call ESMF_TraceRegionExit('datm_strdata_init')

Expand Down
3 changes: 2 additions & 1 deletion dglc/glc_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,8 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)

! Initialize stream data type
if (trim(datamode) /= 'noevolve') then
call shr_strdata_init_from_config(sdat(ns), streamfilename, model_meshes(ns), clock, 'GLC', logunit, rc=rc)
call shr_strdata_init_from_config(sdat(ns), streamfilename, model_meshes(ns), nx_global(ns), ny_global(ns), &
is_scol=.false., clock=clock, compname='GLC', logunit=logunit, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if

Expand Down
8 changes: 5 additions & 3 deletions dice/ice_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
integer :: current_mon ! model month
integer :: current_day ! model day
integer :: current_tod ! model sec into model date
logical :: is_scol ! true if this is a single-column run
real(R8) :: cosarg ! for setting ice temp pattern
real(R8) :: jday, jday0 ! elapsed day counters
integer :: model_dt ! integer model timestep
Expand All @@ -326,16 +327,17 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)

! Initialize mesh, restart flag, logunit
call ESMF_TraceRegionEnter('dice_strdata_init')
call dshr_mesh_init(gcomp, sdat, nullstr, logunit, 'ICE', nx_global, ny_global, &
model_meshfile, model_maskfile, model_mesh, model_mask, model_frac, restart_read, rc=rc)
call dshr_mesh_init(gcomp, sdat, nullstr, logunit, 'ICE', &
model_meshfile, model_maskfile, model_mesh, model_mask, model_frac, restart_read, is_scol, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! Initialize stream data type
streamfilename = 'dice.streams'//trim(inst_suffix)
#ifndef DISABLE_FoX
streamfilename = trim(streamfilename)//'.xml'
#endif
call shr_strdata_init_from_config(sdat, streamfilename, model_mesh, clock, 'ICE', logunit, rc=rc)
call shr_strdata_init_from_config(sdat, streamfilename, model_mesh, nx_global, ny_global, is_scol, &
clock, 'ICE', logunit, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call ESMF_TraceRegionExit('dice_strdata_init')

Expand Down
8 changes: 5 additions & 3 deletions dlnd/lnd_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
integer :: current_mon ! model month
integer :: current_day ! model day
integer :: current_tod ! model sec into model date
logical :: is_scol ! true if this is a single-column run
character(len=cl) :: rpfile ! restart pointer file name
character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize) '
!-------------------------------------------------------------------------------
Expand All @@ -288,15 +289,16 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)

! Initialize sdat
call ESMF_TraceRegionEnter('dlnd_strdata_init')
call dshr_mesh_init(gcomp, sdat, nullstr, logunit, 'LND', nx_global, ny_global, &
model_meshfile, model_maskfile, model_mesh, model_mask, model_frac, restart_read, rc=rc)
call dshr_mesh_init(gcomp, sdat, nullstr, logunit, 'LND', &
model_meshfile, model_maskfile, model_mesh, model_mask, model_frac, restart_read, is_scol, rc=rc)

! Initialize stream data type
streamfilename = 'dlnd.streams'//trim(inst_suffix)
#ifndef DISABLE_FoX
streamfilename = trim(streamfilename)//'.xml'
#endif
call shr_strdata_init_from_config(sdat, streamfilename, model_mesh, clock, 'LND', logunit, rc=rc)
call shr_strdata_init_from_config(sdat, streamfilename, model_mesh, nx_global, ny_global, is_scol, &
clock, 'LND', logunit, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call ESMF_TraceRegionExit('dlnd_strdata_init')

Expand Down
8 changes: 5 additions & 3 deletions docn/ocn_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
integer :: current_mon ! model month
integer :: current_day ! model day
integer :: current_tod ! model sec into model date
logical :: is_scol ! true if this is a single-column run
type(ESMF_Field) :: lfield
character(CL) ,pointer :: lfieldnamelist(:) => null()
integer :: fieldcount
Expand Down Expand Up @@ -398,8 +399,8 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if

call dshr_mesh_init(gcomp, sdat, nullstr, logunit, 'OCN', nx_global, ny_global, &
model_meshfile, model_maskfile, model_mesh, model_mask, model_frac, restart_read, rc=rc)
call dshr_mesh_init(gcomp, sdat, nullstr, logunit, 'OCN', &
model_meshfile, model_maskfile, model_mesh, model_mask, model_frac, restart_read, is_scol, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! Initialize stream data type if not aqua planet
Expand All @@ -408,7 +409,8 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
#ifndef DISABLE_FoX
streamfilename = trim(streamfilename)//'.xml'
#endif
call shr_strdata_init_from_config(sdat, streamfilename, model_mesh, clock, 'OCN', logunit, rc=rc)
call shr_strdata_init_from_config(sdat, streamfilename, model_mesh, nx_global, ny_global, is_scol, &
clock, 'OCN', logunit, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if
call ESMF_TraceRegionExit('docn_strdata_init')
Expand Down
8 changes: 5 additions & 3 deletions drof/rof_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -280,23 +280,25 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
integer :: current_mon ! model month
integer :: current_day ! model day
integer :: current_tod ! model sec into model date
logical :: is_scol ! true if this is a single-column run
character(len=*), parameter :: subname=trim(modName)//':(InitializeRealize) '
!--------------------------------

rc = ESMF_SUCCESS

! Initialize mesh, restart flag, logunit
call ESMF_TraceRegionEnter('drof_strdata_init')
call dshr_mesh_init(gcomp, sdat, nullstr, logunit, 'ROF', nx_global, ny_global, &
model_meshfile, model_maskfile, model_mesh, model_mask, model_frac, restart_read, rc=rc)
call dshr_mesh_init(gcomp, sdat, nullstr, logunit, 'ROF', &
model_meshfile, model_maskfile, model_mesh, model_mask, model_frac, restart_read, is_scol, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! Initialize stream data type
streamfilename = 'drof.streams'//trim(inst_suffix)
#ifndef DISABLE_FOX
streamfilename = trim(streamfilename)//'.xml'
#endif
call shr_strdata_init_from_config(sdat, streamfilename, model_mesh, clock, 'ROF', logunit, rc=rc)
call shr_strdata_init_from_config(sdat, streamfilename, model_mesh, nx_global, ny_global, is_scol, &
clock, 'ROF', logunit, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call ESMF_TraceRegionExit('drof_strdata_init')

Expand Down
10 changes: 6 additions & 4 deletions dshr/dshr_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ subroutine dshr_init(gcomp, compname, mpicom, my_task, inst_index, inst_suffix,
end subroutine dshr_init

!===============================================================================
subroutine dshr_mesh_init(gcomp, sdat, nullstr, logunit, compname, model_nxg, model_nyg, &
model_meshfile, model_maskfile, model_mesh, model_mask, model_frac, read_restart, rc)
subroutine dshr_mesh_init(gcomp, sdat, nullstr, logunit, compname, &
model_meshfile, model_maskfile, model_mesh, model_mask, model_frac, read_restart, is_scol, rc)

! ----------------------------------------------
! Initialize model mesh
Expand All @@ -248,14 +248,13 @@ subroutine dshr_mesh_init(gcomp, sdat, nullstr, logunit, compname, model_nxg, mo
integer , intent(in) :: logunit
character(len=*) , intent(in) :: compname !e.g. ATM, OCN, ...
character(len=*) , intent(in) :: nullstr
integer , intent(in) :: model_nxg
integer , intent(in) :: model_nyg
character(len=*) , intent(in) :: model_meshfile
character(len=*) , intent(in) :: model_maskfile
type(ESMF_Mesh) , intent(out) :: model_mesh
integer , pointer , intent(out) :: model_mask(:)
real(r8), pointer , intent(out) :: model_frac(:)
logical , intent(out) :: read_restart
logical , intent(out) :: is_scol ! true if this is a single-column run
integer , intent(out) :: rc

! local variables
Expand Down Expand Up @@ -322,11 +321,14 @@ subroutine dshr_mesh_init(gcomp, sdat, nullstr, logunit, compname, model_nxg, mo
if (scol_lon > scol_spval .and. scol_lat > scol_spval) then

! This is simply a single point run
is_scol = .true.
call dshr_mesh_create_scol(gcomp, compname, scol_lon, scol_lat, model_mesh, model_mask, model_frac, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

else

is_scol = .false.

! check that model_meshfile and model_maskfile exists
if (my_task == main_task) then
inquire(file=trim(model_meshfile), exist=exists)
Expand Down
8 changes: 5 additions & 3 deletions dwav/wav_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
integer :: current_mon ! model month
integer :: current_day ! model day
integer :: current_tod ! model sec into model date
logical :: is_scol ! true if this is a single-column run
character(len=CL):: rpfile
character(len=*), parameter :: subname=trim(modName)//':(InitializeRealize) '
!-------------------------------------------------------------------------------
Expand All @@ -279,16 +280,17 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)

! Initialize sdat - create the model domain mesh and intialize the sdat clock
call ESMF_TraceRegionEnter('dwav_strdata_init')
call dshr_mesh_init(gcomp, sdat, nullstr, logunit, 'WAV', nx_global, ny_global, &
model_meshfile, model_maskfile, model_mesh, model_mask, model_frac, restart_read, rc=rc)
call dshr_mesh_init(gcomp, sdat, nullstr, logunit, 'WAV', &
model_meshfile, model_maskfile, model_mesh, model_mask, model_frac, restart_read, is_scol, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! Initialize stream data type if not aqua planet
streamfilename = 'dwav.streams'//trim(inst_suffix)
#ifndef DISABLE_FoX
streamfilename = trim(streamfilename)//'.xml'
#endif
call shr_strdata_init_from_config(sdat, streamfilename, model_mesh, clock, 'WAV', logunit, rc=rc)
call shr_strdata_init_from_config(sdat, streamfilename, model_mesh, nx_global, ny_global, is_scol, &
clock, 'WAV', logunit, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call ESMF_TraceRegionExit('dwav_strdata_init')

Expand Down
29 changes: 26 additions & 3 deletions streams/dshr_strdata_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ module dshr_strdata_mod
type(ESMF_Mesh) :: model_mesh ! model mesh
real(r8), pointer :: model_lon(:) => null() ! model longitudes
real(r8), pointer :: model_lat(:) => null() ! model latitudes
integer :: model_nxg ! model global domain lon size
integer :: model_nyg ! model global domain lat size
integer :: model_nzg ! model global domain vertical size
integer :: model_lsize ! model local domain size
integer, pointer :: model_gindex(:) ! model global index spzce
Expand Down Expand Up @@ -188,12 +186,16 @@ type(ESMF_FieldBundle) function shr_strdata_get_stream_fieldbundle(sdat, ns, nam
end function shr_strdata_get_stream_fieldbundle

!===============================================================================
subroutine shr_strdata_init_from_config(sdat, streamfilename, model_mesh, clock, compname, logunit, rc)
subroutine shr_strdata_init_from_config(sdat, streamfilename, model_mesh, model_nxg, model_nyg, is_scol, &
clock, compname, logunit, rc)

! input/output variables
type(shr_strdata_type) , intent(inout) :: sdat
character(len=*) , intent(in) :: streamfilename
type(ESMF_Mesh) , intent(in) :: model_mesh
integer , intent(in) :: model_nxg ! model global domain lon size
integer , intent(in) :: model_nyg ! model global domain lat size
logical , intent(in) :: is_scol ! true if this is a single-column run
type(ESMF_Clock) , intent(in) :: clock
character(len=*) , intent(in) :: compname
integer , intent(in) :: logunit
Expand Down Expand Up @@ -250,6 +252,27 @@ subroutine shr_strdata_init_from_config(sdat, streamfilename, model_mesh, clock,
call shr_strdata_init_model_domain(sdat, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! Verify that the declared global grid dimensions are consistent with the total number
! of points in the model mesh (model_gsize was just computed by
! shr_strdata_init_model_domain).
!
! This check is bypassed for single-column runs as a workaround for a bug in the
! single-column logic (https://github.com/ESCOMP/CDEPS/issues/419): in single-column
! runs, model_nxg and model_nyg incorrectly keep their full global grid sizes while
! the single-column mesh has exactly 1 point.
!
! TODO: remove the is_scol bypass (and possibly the is_scol argument) once
! single-column runs set nx_global and ny_global correctly (i.e., to 1).
if (.not. is_scol) then
if (model_nxg * model_nyg /= sdat%model_gsize) then
Comment on lines +266 to +267

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you replace is_col with model_gsize==1? Then there's no is_col flag that needs to be passed through

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I had considered that, but I prefer the current logic because it limits the error check bypass to the specific "single column" scenario, which follows special-purpose logic (which is currently broken, hence this bypass - see #419). I believe this is more specific than simply checking if model_gsize == 1. I wanted to keep this check active for other single-point cases if they were not subject to the broken single column logic - both so that errors could be reported in this case and to make the code more explicit that this bypass is just temporary until #419 is resolved.

Does that seem reasonable to you or do you have other reasons for preferring that this logic be changed?

An alternative is that we could wait for #419 to be resolved before merging this PR at all - at which point this single column bypass could be removed entirely... I'm just not sure when #419 can realistically be resolved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ah, ok. whatever you think is best

call shr_log_error(subname//' ERROR: for component '//trim(compname)// &
', nx*ny ('//toString(model_nxg*model_nyg)// &
') does not equal the total number of points in the model mesh ('// &
toString(sdat%model_gsize)//')', rc=rc)
return
end if
end if

! Now finish initializing sdat
call shr_strdata_init(sdat, clock, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
Expand Down
Loading