Skip to content
Merged
Changes from 2 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
20 changes: 16 additions & 4 deletions streams/dshr_strdata_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ subroutine shr_strdata_init_from_inline(sdat, my_task, logunit, compname, &
stream_filenames, stream_fldlistFile, stream_fldListModel, &
stream_yearFirst, stream_yearLast, stream_yearAlign, &
stream_offset, stream_taxmode, stream_dtlimit, stream_tintalgo, &
stream_src_mask, stream_dst_mask, stream_name, rc)
stream_src_mask, stream_dst_mask, stream_name, stream_mesh_in, rc)

! input/output variables
type(shr_strdata_type) , intent(inout) :: sdat ! stream data type
Expand All @@ -288,6 +288,9 @@ subroutine shr_strdata_init_from_inline(sdat, my_task, logunit, compname, &
integer , optional , intent(in) :: stream_src_mask ! source mask value
integer , optional , intent(in) :: stream_dst_mask ! destination mask value
character(len=*) , optional , intent(in) :: stream_name ! name of stream
type(ESMF_Mesh) , optional , intent(in) :: stream_mesh_in ! reuse this mesh instead of reading
! stream_meshfile (e.g. model_mesh for a
! same-grid 'redist' stream)
integer , optional , intent(out) :: rc ! error code

! local variables
Expand Down Expand Up @@ -344,7 +347,7 @@ subroutine shr_strdata_init_from_inline(sdat, my_task, logunit, compname, &
sdat%logunit, trim(compname), sdat%mainproc, src_mask, dst_mask)

! Now finish initializing sdat
call shr_strdata_init(sdat, model_clock, stream_name, rc)
call shr_strdata_init(sdat, model_clock, stream_name, stream_mesh_in=stream_mesh_in, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

end subroutine shr_strdata_init_from_inline
Expand Down Expand Up @@ -446,12 +449,14 @@ subroutine shr_strdata_init_model_domain( sdat, rc)
end subroutine shr_strdata_init_model_domain

!===============================================================================
subroutine shr_strdata_init(sdat, model_clock, stream_name, rc)
subroutine shr_strdata_init(sdat, model_clock, stream_name, stream_mesh_in, rc)

! input/output variables
type(shr_strdata_type) , intent(inout), target :: sdat
type(ESMF_Clock) , intent(in) :: model_clock
character(len=*), optional , intent(in) :: stream_name
type(ESMF_Mesh) , optional , intent(in) :: stream_mesh_in ! reuse this mesh instead of reading the
! stream mesh file (same-grid 'redist' streams)
integer , intent(out) :: rc

! local variables
Expand Down Expand Up @@ -500,7 +505,14 @@ subroutine shr_strdata_init(sdat, model_clock, stream_name, rc)
endif

! We do not yet have mask information, but we are required to set it here and change it later.
if (filename /= 'none') then
if (present(stream_mesh_in)) then
! Reuse a caller-provided mesh (e.g. the model mesh for a same-grid
! 'redist' stream) instead of building a duplicate full ESMF mesh from
! file. Avoids the mesh-create cost (file read + mesh build) at high
! resolution. Safe: this routine only reads stream_mesh (no MeshSet/
! MeshDestroy), so the shared handle is never mutated or freed here.
stream_mesh = stream_mesh_in
else if (filename /= 'none') then
stream_mesh = ESMF_MeshCreate(trim(filename), fileformat=ESMF_FILEFORMAT_ESMFMESH, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
endif
Expand Down
Loading