-
Notifications
You must be signed in to change notification settings - Fork 320
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
Reduce memory usage during GWDO stats estimation #1228
Reduce memory usage during GWDO stats estimation #1228
Conversation
… statistics are checked to be correct
- box, box_landuse, dxm are now local variables - landuse changed to be of type I1KIND - cleanup
@mgduda Thanks for the review! I pushed a set of changes addressing all your comments, and it's also tested on Eris. Will try on Derecho next. |
! NB: At present, only the USGS GLCC land cover dataset is supported, so we can assume 16 == water | ||
! See the read_global_30s_landuse function | ||
integer (kind=I1KIND), parameter :: WATER = 16 | ||
|
||
integer (kind=I1KIND), dimension(:), pointer :: hlanduse ! Dominant land mask (0 or 1) | ||
real (kind=RKIND) :: hc ! critical height | ||
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove the spaces on this line.
@@ -117,14 +129,18 @@ function compute_gwd_fields(domain) result(iErr) | |||
character(len=StrKIND) :: geog_sub_path | |||
character(len=StrKIND+1) :: geog_data_path ! same as config_geog_data_path, but guaranteed to have a trailing slash | |||
|
|||
TYPE(mpas_gwd_tile_type), pointer :: tilesHead ! Pointer to linked list of tiles |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest changing TYPE(mpas_gwd_tile_type)
to type (mpas_gwd_tile_type)
.
real (kind=RKIND), dimension(:,:), pointer :: box => null() ! Subset of topography covering a grid cell | ||
real (kind=RKIND), dimension(:,:), pointer :: dxm => null() ! Size (meters) in zonal direction of a grid cell | ||
real (kind=RKIND) :: box_mean ! Mean value of topography in box | ||
integer (kind=I1KIND), dimension(:,:), pointer :: box_landuse => null() ! Subset of landuse covering a grid cell |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's more of a personal style preference, but what do you think about aligning the comments, e.g.,
real (kind=RKIND), dimension(:,:), pointer :: box => null() ! Subset of topography covering a grid cell
real (kind=RKIND), dimension(:,:), pointer :: dxm => null() ! Size (meters) in zonal direction of a grid cell
real (kind=RKIND) :: box_mean ! Mean value of topography in box
integer (kind=I1KIND), dimension(:,:), pointer :: box_landuse => null() ! Subset of landuse covering a grid cell
Otherwise, perhaps a consistent amount of whitespace between the end of the statement and the !
character would be good.
Also, I think initializing these variables will give them an implicit save
attribute, which may not be desirable.
deallocate(hlanduse) | ||
|
||
iErr = 0 | ||
iErr = remove_tiles(tilesHead) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some alternative verbs to consider for this function name that might make it clearer that we're freeing memory associated with all tiles in the linked list: delete
, free
, deallocate
. For example, what if we called this function free_tiles
? Or free_tile_list
?
Replaced by #1235. Closing. |
This PR attempts to improve the memory footprint during the computation of Gravity Wave Drag Orography statistics in the pre-processing step.
The previous approach relied on each MPI rank reading all of the topography and land use tiles, and hence would run out of memory before we could fully subscribe to all cores in a node. In the new approach, we only read in one tile at a time and when we encounter a pixel whose data is not already available in a linked list. The
get_box
subroutine is modified to callget_tile_from_box_point
to check if the current pixel in the box is present in the linked list, and if not, it appends this tile (after reading both topo and land use data) to the head of the list.This PR also changes
box, box_landuse, dxm, nx and ny
to be local variables, instead of module variables. This provides a little better readability, along with advantages of thread safety, etc.