Skip to content

Add river routing module for offline (GEOSldas) simulations#1143

Draft
weiyuan-jiang wants to merge 135 commits intodevelopfrom
feature/wjiang/Routing_GEOSroute_on_yujin
Draft

Add river routing module for offline (GEOSldas) simulations#1143
weiyuan-jiang wants to merge 135 commits intodevelopfrom
feature/wjiang/Routing_GEOSroute_on_yujin

Conversation

@weiyuan-jiang
Copy link
Contributor

@weiyuan-jiang weiyuan-jiang commented Aug 14, 2025

Add river routing module for offline land modeling (GEOSldas). Replaces #1023


Left for future PRs:

  • Run routing module within the AGCM and coupled model (AOGCM).
  • Run only the routing module (but not Catchment) in GEOSldas.
  • Include landice tiles in routing (GEOSldas and GCM).

Related PRs:


Testing:

  • TBD

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.

Yujin Zeng and others added 30 commits October 23, 2024 21:22
…t in GEOSgcm_GridComp/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOSroute_GridComp
Copy link
Contributor

@gmao-rreichle gmao-rreichle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zyj8881357 : I'm still struggling to understand what exactly is done in EASE_pfaf_frac.F90.

Yujin Zeng added 2 commits February 12, 2026 20:10
…also change variable pfaf_frac to subtile_area in the *_tile2pfaf.nc4 file
@zyj8881357
Copy link

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.

Copy link
Contributor

@gmao-rreichle gmao-rreichle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Comment on lines +199 to +212
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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)
Copy link
Contributor

@gmao-rreichle gmao-rreichle Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weiyuan-jiang Could you please help with this? Exit the model program when the simulation domain is not global. Thank you!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Land ice and lakes (as defined in the *.rst raster file) are excluded from the catchment area in the routing model.

…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 )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Contributor

@gmao-rreichle gmao-rreichle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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

Comment on lines +5 to +17
! 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it is hard to move this to make_bcs package

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am looking into it....

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The added documentation is correct and great.

@@ -0,0 +1,296 @@
#include "MAPL_ErrLog.h"

module EASE_pfaf_subareaMod
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about to call them sub-catchments? Because everyone of them contributes a fraction of area and runoff to the catchment.

@weiyuan-jiang
Copy link
Contributor Author

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

@zyj8881357
Copy link

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.

@gmao-rreichle
Copy link
Contributor

we have a EASE tile file which looks like a cubed-sphere tile file. Do you want to add elevation to it?

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0 diff The changes in this pull request have verified to be zero-diff with the target branch. Contingent - DNA These changes are contingent on other PRs (DNA=do not approve) enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants