Add river routing module for offline (GEOSldas) simulations#1143
Add river routing module for offline (GEOSldas) simulations#1143weiyuan-jiang wants to merge 135 commits intodevelopfrom
Conversation
…t in GEOSgcm_GridComp/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOSroute_GridComp
…ent (GEOS_RouteGridComp.F90)
gmao-rreichle
left a comment
There was a problem hiding this comment.
@zyj8881357 : I'm still struggling to understand what exactly is done in EASE_pfaf_frac.F90.
...m_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/makebcs/EASE_pfaf_frac.F90
Outdated
Show resolved
Hide resolved
…also change variable pfaf_frac to subtile_area in the *_tile2pfaf.nc4 file
|
I’ve changed pfaf_frac to subtile_area in the *_tile2pfaf.nc file. This means the model no longer needs to read the catchment area from the restart file; instead, it can be derived by summing the subtile areas during initialization. This works for non-EASE grids as well. |
…S_RouteGridComp.F90, create_river_input.py)
…UT'; added comments (GEOS_RouteGridComp.F90)
…; moved mk_RouteRestarts.F90 to dir of obsolete files (routing_model.F90, CMakeLists.txt, mk_RouteRestarts.F90)
gmao-rreichle
left a comment
There was a problem hiding this comment.
@zyj8881357 : We're getting close to being done, but I still have a few questions and suggestions, see below. Please let me know if anything is unclear.
| v = Variable(type=PFIO_INT32, dimensions='tile') | ||
| call v%add_attribute('units', '1') | ||
| call v%add_attribute('long_name', 'tile_id') | ||
| call meta%add_variable('tile_id', v) | ||
|
|
||
| v = Variable(type=pFio_INT32, dimensions='tile') | ||
| call v%add_attribute('units', '1') | ||
| call v%add_attribute('long_name', 'pfaf_index') | ||
| call meta%add_variable('pfaf_index', v) | ||
|
|
||
| v = Variable(type=pFio_REAL32, dimensions='tile') | ||
| call v%add_attribute('units', 'm+2') | ||
| call v%add_attribute('long_name', 'area_of_subtile') | ||
| call meta%add_variable('subtile_area', v) |
There was a problem hiding this comment.
@zyj8881357 : I tried some more to understand what this program is doing, and I think I got further than last time. But I'm still nowhere near understanding enough to meaningfully review this code. I'll need more time (and perhaps some help from you) to work through this.
|
|
||
| ! ---------------------------------------------------- | ||
|
|
||
| subroutine create_mapping_handler(tilegrid, pfaf_tilegrid, rc) |
There was a problem hiding this comment.
@weiyuan-jiang : Does the mapping from tile space to Pfaf catch space work when the simulation domain is not global?
And what if the tile space contains landice tiles?
There was a problem hiding this comment.
@weiyuan-jiang Could you please help with this? Exit the model program when the simulation domain is not global. Thank you!
There was a problem hiding this comment.
Land ice and lakes (as defined in the *.rst raster file) are excluded from the catchment area in the routing model.
...m_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/makebcs/make_bcs_shared.py
Outdated
Show resolved
Hide resolved
.../GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/preproc/routing_model/get_latloni.py
Show resolved
Hide resolved
...s_GridComp/GEOSsurface_GridComp/Utils/Raster/preproc/routing_model/get_num_sub_catchment.f90
Show resolved
Hide resolved
...GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSroute_GridComp/GEOS_RouteGridComp.F90
Outdated
Show resolved
Hide resolved
...GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSroute_GridComp/GEOS_RouteGridComp.F90
Outdated
Show resolved
Hide resolved
.../GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/preproc/routing_model/river_read.f90
Outdated
Show resolved
Hide resolved
...OSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/preproc/routing_model/k_module_cali.f90
Show resolved
Hide resolved
...GridComp/GEOSsurface_GridComp/Utils/Raster/preproc/routing_model/routing_model_constants.f90
Outdated
Show resolved
Hide resolved
…ld error from earlier commit (routing_model.F90)
| ! When using the program with GEOS, probably best to make sure values are consistent with those in MAPL. | ||
| ! HOWEVER: Value of PI is hardcoded a total of five times in this file, with two distinct values! | ||
| ! | ||
| real(REAL64), parameter :: PI = 3.14159265358979323846 ! ( MAPL_PI=3.14159265358979323846d0 as of Feb 2026 ) |
There was a problem hiding this comment.
| real(REAL64), parameter :: PI = 3.14159265358979323846 ! ( MAPL_PI=3.14159265358979323846d0 as of Feb 2026 ) | |
| real(REAL64), parameter :: PI = 3.14159265358979323846d0 ! ( MAPL_PI=3.14159265358979323846d0 as of Feb 2026 ) |
@gmao-rreichle et al, I think we want the d0 here. I talked with @tclune and technically Fortran says without the d0 the long constant is truncated to REAL32 and then cast to REAL64. So this is the "right" way.
NOTE: @tclune also said that in his experience, no compilers actually did this when built optimized, but might when building Debug.
gmao-rreichle
left a comment
There was a problem hiding this comment.
@zyj8881357, @weiyuan-jiang : I added a commit (93fef6e) and two comments in the hope of clarifying what is done and what we may want to do re. the EASEtile-to-Pfafcatch mapping. Please take a look, thanks
| ! Main purpose: Calculates info needed to map from EASE tile space to Pfafstetter catchment space; | ||
| ! writes information into EASEv[x]_tile2pfaf.nc4. | ||
| ! | ||
| ! Background: The standard EASE tile space is created such that there is at most one tile per EASE grid cell. | ||
| ! Each EASE tile is nominally assigned to the Pfafstetter catchment that covers the largest portion | ||
| ! of the tile. Information about other Pfafstetter catchments that intersect with the EASE grid cell | ||
| ! is lost in the process. | ||
| ! For routing, we need to know about all of the Pfafstetter catchments that intersect with the tile, | ||
| ! including the area (or fraction) of the intersect. | ||
| ! Given an EASE grid resolution, this program calculates the full mapping information from the 1-arcmin | ||
| ! raster file on which the Pfafstetter catchments are defined. | ||
| ! Note that this is essentially equivalent to creating an EASE tile space *without* the restriction of | ||
| ! at most one tile per EASE grid cell. |
There was a problem hiding this comment.
@weiyuan-jiang, @zyj8881357 : I added this documentation based on a conversation with Yujin today. Perhaps the most important bit is the last sentence, which got me thinking that there may be a better way to deal with the EASEtile_to_Pfafcatch mapping. @weiyuan-jiang, how hard would it be to modify make_bcs so that in addition to the standard EASE tile space, we also create a supplemental *til file that is processed just like the cube-sphere tile file, except that the grid is EASE instead of cube-sphere. (That is, no restriction on the number of EASE tiles per EASE grid cell.)
It's possible that running the existing routines for an overlying ("atm") EASE grid requires only minimal modification. If the routines only need to know the center and edge coordinates of cube-sphere grid cells to do their work, we should be able to the same for the EASE grid now that EASE is in MAPL. We'd also have to deal with raster grid cells near the poles that are outside of the "global" EASE grid. But the rest of the tile generation shouldn't depend on the specifics of the overlying (atm) grid.
If this works, routing should be able use the supplemental "EASE" tile file to do the mapping.
There was a problem hiding this comment.
I don't think it is hard to move this to make_bcs package
There was a problem hiding this comment.
Thanks, @weiyuan-jiang, for taking a look. Just to clarify, I didn't mean to "move" this program to make_bcs. Rather, I was wondering if we can use the existing make_bcs routines to generate a supplemental tile file (in nc4 format) with EASE tiles that respect the Pfaf catchment boundaries. Does your response apply to this latter option?
There was a problem hiding this comment.
I am looking into it....
There was a problem hiding this comment.
The added documentation is correct and great.
| @@ -0,0 +1,296 @@ | |||
| #include "MAPL_ErrLog.h" | |||
|
|
|||
| module EASE_pfaf_subareaMod | |||
There was a problem hiding this comment.
The "subarea" in the module and file name here refers to the portion of a Pfaf catchment that is within an EASE grid cell. In this sense, the "subarea" is identical to what would be a "tile" if we didn't limit the number of EASE tiles to at most one per EASE grid cell.
Within the script, the term "subtile" (or "sub-tile") is used to refer to the same thing. The term "subtile" is a bit confusing in this context because the Catchment model already has three "subtile" areas that vary dynamically ("wilting", "transpiring", "saturated").
My first instinct was to use "true tiles" instead of "subareas" because they correspond to what would be tiles in the cube-sphere or lat/lon space (i.e., tiles that respect the boudaries of Pfafstetter catchments). But "true tiles" isn't great because it's not very descriptive.
In any case, we should think about what we want to call these "subareas", and we need to make sure to use whatever term we pick consistently.
There was a problem hiding this comment.
How about to call them sub-catchments? Because everyone of them contributes a fraction of area and runoff to the catchment.
|
Now we have a EASE tile file which looks like a cubed-sphere tile file. Do you want to add elevation to it? @gmao-rreichle @zyj8881357 |
Thank you! I have changed the routing model's code to read the new tile file instead of the tile2pfaf.nc4. |
Ideally, the new EASE tile file that looks like a cs tile file should have the same format and contents. So if elevation is in the cs tile file, it should also be in the new, cs-like EASE tile file, if only for consistency. |
Add river routing module for offline land modeling (GEOSldas). Replaces #1023
Left for future PRs:
Related PRs:
Testing:
List of tasks that remain to be addressed (in no particular order):
@YujiN, I am trying to bring back some codes in develop branch. The develop branch is not working as it is but I believe it would be more efficient. The runoff and the other variables are distributed as needed, which is way more efficient than allgatherV.