Skip to content

Commit

Permalink
Merge pull request ESCOMP#194 from jedwards4b/initialize_mask_field
Browse files Browse the repository at this point in the history
initialize this field so that debug doesnt fail here
  • Loading branch information
jedwards4b authored Nov 17, 2022
2 parents 3a5ef9e + abecf3e commit 767ef56
Showing 1 changed file with 8 additions and 4 deletions.
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

0 comments on commit 767ef56

Please sign in to comment.