diff --git a/datm/atm_comp_nuopc.F90 b/datm/atm_comp_nuopc.F90 index aa2801466..da37e5e49 100644 --- a/datm/atm_comp_nuopc.F90 +++ b/datm/atm_comp_nuopc.F90 @@ -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 @@ -450,8 +451,8 @@ 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 @@ -459,7 +460,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, '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') diff --git a/dglc/glc_comp_nuopc.F90 b/dglc/glc_comp_nuopc.F90 index de2f1f001..dc6de435d 100644 --- a/dglc/glc_comp_nuopc.F90 +++ b/dglc/glc_comp_nuopc.F90 @@ -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 diff --git a/dice/ice_comp_nuopc.F90 b/dice/ice_comp_nuopc.F90 index b3dd1dbe7..ab5ca3f00 100644 --- a/dice/ice_comp_nuopc.F90 +++ b/dice/ice_comp_nuopc.F90 @@ -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 @@ -326,8 +327,8 @@ 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 @@ -335,7 +336,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, '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') diff --git a/dlnd/lnd_comp_nuopc.F90 b/dlnd/lnd_comp_nuopc.F90 index 7a7d4d049..b4017d31c 100644 --- a/dlnd/lnd_comp_nuopc.F90 +++ b/dlnd/lnd_comp_nuopc.F90 @@ -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) ' !------------------------------------------------------------------------------- @@ -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') diff --git a/docn/ocn_comp_nuopc.F90 b/docn/ocn_comp_nuopc.F90 index e9d275060..973843846 100644 --- a/docn/ocn_comp_nuopc.F90 +++ b/docn/ocn_comp_nuopc.F90 @@ -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 @@ -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 @@ -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') diff --git a/drof/rof_comp_nuopc.F90 b/drof/rof_comp_nuopc.F90 index 06d837069..1b4330f35 100644 --- a/drof/rof_comp_nuopc.F90 +++ b/drof/rof_comp_nuopc.F90 @@ -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=*), parameter :: subname=trim(modName)//':(InitializeRealize) ' !-------------------------------- @@ -287,8 +288,8 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) ! 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 @@ -296,7 +297,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, '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') diff --git a/dshr/dshr_mod.F90 b/dshr/dshr_mod.F90 index c0f6afff3..a858721f6 100644 --- a/dshr/dshr_mod.F90 +++ b/dshr/dshr_mod.F90 @@ -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 @@ -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 @@ -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) diff --git a/dwav/wav_comp_nuopc.F90 b/dwav/wav_comp_nuopc.F90 index dd0e92c69..84b916fb0 100644 --- a/dwav/wav_comp_nuopc.F90 +++ b/dwav/wav_comp_nuopc.F90 @@ -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) ' !------------------------------------------------------------------------------- @@ -279,8 +280,8 @@ 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 @@ -288,7 +289,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, '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') diff --git a/streams/dshr_strdata_mod.F90 b/streams/dshr_strdata_mod.F90 index 0085a9952..99ede852c 100644 --- a/streams/dshr_strdata_mod.F90 +++ b/streams/dshr_strdata_mod.F90 @@ -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 @@ -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 @@ -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 + 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