Skip to content

Commit

Permalink
Deallocate unneeded memory as soon as possible in
Browse files Browse the repository at this point in the history
interp2.F90

Fixes ufs-community#709.
  • Loading branch information
GeorgeGayno-NOAA committed Nov 17, 2022
1 parent 933af8b commit 33cefde
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions sorc/sfc_climo_gen.fd/interp2.F90
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ subroutine interp2(localpet, input_file)
if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) &
call error_handler("IN FieldScatter.", rc)

deallocate(data_src_global2)

isrctermprocessing = 1

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

print*,"- CALL FieldRegridRelease."
call ESMF_FieldRegridRelease(routehandle=regrid_data, rc=rc)

print*,"- CALL FieldDestroy."
call ESMF_FieldDestroy(data_field_src, rc=rc)

OUTPUT_LOOP : do tile = 1, num_tiles

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

status=nf90_close(ncid)

deallocate(data_mdl_one_tile, dom_cat_mdl_one_tile, mask_mdl_one_tile, data_src_global2)
deallocate(data_mdl_one_tile, dom_cat_mdl_one_tile, mask_mdl_one_tile)
deallocate(lat_mdl_one_tile, lon_mdl_one_tile, sum_mdl_one_tile, land_frac_mdl_one_tile)

print*,"- CALL FieldRegridRelease."
call ESMF_FieldRegridRelease(routehandle=regrid_data, rc=rc)

print*,"- CALL FieldDestroy."
call ESMF_FieldDestroy(data_field_src, rc=rc)
call ESMF_FieldDestroy(data_field_mdl, rc=rc)

call mpi_barrier(mpi_comm_world, rc)

end subroutine interp2

0 comments on commit 33cefde

Please sign in to comment.