Skip to content
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

initialize this field so that debug doesnt fail here #194

Merged
merged 1 commit into from
Nov 17, 2022
Merged
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
12 changes: 8 additions & 4 deletions dshr/dshr_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,7 @@ subroutine dshr_set_modelmask(mesh_dst, meshfile_mask, compname, mask_dst, frac_
use ESMF, only : ESMF_FieldRegridStore, ESMF_FieldRegrid, ESMF_FIELDCREATE
use ESMF, only : ESMF_REGRIDMETHOD_CONSERVE, ESMF_NORMTYPE_DSTAREA, ESMF_UNMAPPEDACTION_IGNORE
use ESMF, only : ESMF_TYPEKIND_R8, ESMF_MESHLOC_ELEMENT
use ESMF, only : ESMF_RouteHandleDestroy, ESMF_FieldDestroy
use ESMF, only : ESMF_RouteHandleDestroy, ESMF_FieldDestroy, ESMF_FieldFill

! input/out variables
type(ESMF_Mesh) , intent(in) :: mesh_dst
Expand Down Expand Up @@ -1398,18 +1398,20 @@ subroutine dshr_set_modelmask(mesh_dst, meshfile_mask, compname, mask_dst, frac_
!-------------------------------------------------------------------------------

rc = ESMF_SUCCESS

mesh_mask = ESMF_MeshCreate(trim(meshfile_mask), fileformat=ESMF_FILEFORMAT_ESMFMESH, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call ESMF_MeshGet(mesh_dst, spatialDim=spatialDim, numOwnedElements=lsize_dst, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
allocate(mask_dst(lsize_dst))
allocate(frac_dst(lsize_dst))

! create fields on source and destination meshes
field_mask = ESMF_FieldCreate(mesh_mask, ESMF_TYPEKIND_R8, meshloc=ESMF_MESHLOC_ELEMENT, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! Initialize the field_mask, otherwise we sometimes get an error in the FieldRegridStore
call ESMF_FieldFill(field_mask, dataFillScheme="const", rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

field_dst = ESMF_FieldCreate(mesh_dst, ESMF_TYPEKIND_R8, meshloc=ESMF_MESHLOC_ELEMENT, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

Expand Down Expand Up @@ -1442,6 +1444,8 @@ subroutine dshr_set_modelmask(mesh_dst, meshfile_mask, compname, mask_dst, frac_
if (chkerr(rc,__LINE__,u_FILE_u)) return

! now determine mask_dst and frac_dst
allocate(mask_dst(lsize_dst))
allocate(frac_dst(lsize_dst))
call ESMF_MeshGet(mesh_dst, spatialDim=spatialDim, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call ESMF_FieldGet(field_dst, farrayptr=dataptr1d, rc=rc)
Expand Down