Skip to content

Commit 33cefde

Browse files
Deallocate unneeded memory as soon as possible in
interp2.F90 Fixes ufs-community#709.
1 parent 933af8b commit 33cefde

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

sorc/sfc_climo_gen.fd/interp2.F90

+12-5
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ subroutine interp2(localpet, input_file)
135135
if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) &
136136
call error_handler("IN FieldScatter.", rc)
137137

138+
deallocate(data_src_global2)
139+
138140
isrctermprocessing = 1
139141

140142
method = ESMF_REGRIDMETHOD_CONSERVE
@@ -166,6 +168,12 @@ subroutine interp2(localpet, input_file)
166168
if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) &
167169
call error_handler("IN FieldRegrid.", rc)
168170

171+
print*,"- CALL FieldRegridRelease."
172+
call ESMF_FieldRegridRelease(routehandle=regrid_data, rc=rc)
173+
174+
print*,"- CALL FieldDestroy."
175+
call ESMF_FieldDestroy(data_field_src, rc=rc)
176+
169177
OUTPUT_LOOP : do tile = 1, num_tiles
170178

171179
print*,"- CALL FieldGather FOR MODEL LATITUDE."
@@ -247,13 +255,12 @@ subroutine interp2(localpet, input_file)
247255

248256
status=nf90_close(ncid)
249257

250-
deallocate(data_mdl_one_tile, dom_cat_mdl_one_tile, mask_mdl_one_tile, data_src_global2)
258+
deallocate(data_mdl_one_tile, dom_cat_mdl_one_tile, mask_mdl_one_tile)
251259
deallocate(lat_mdl_one_tile, lon_mdl_one_tile, sum_mdl_one_tile, land_frac_mdl_one_tile)
252260

253-
print*,"- CALL FieldRegridRelease."
254-
call ESMF_FieldRegridRelease(routehandle=regrid_data, rc=rc)
255-
256261
print*,"- CALL FieldDestroy."
257-
call ESMF_FieldDestroy(data_field_src, rc=rc)
262+
call ESMF_FieldDestroy(data_field_mdl, rc=rc)
263+
264+
call mpi_barrier(mpi_comm_world, rc)
258265

259266
end subroutine interp2

0 commit comments

Comments
 (0)