-
Notifications
You must be signed in to change notification settings - Fork 159
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
[PULL REQUEST] HEMCO grid feature and interface restructuring #681
Conversation
Structural changes (validated to zero diff): - Implements a new Input_Opt field LIMGRID to indicate intermediate grid functionality. - MODEL_CLASSIC: Reads HEMCO extension met fields from HEMCO state when possible - Remove FRAC_OF_PBL duplicate and read through State_Met. - Move SUMCOSZA to State_Met%SUNCOSsum. - Move Calc_SUMCOSZA to Calc_Met_Mod. - Move Read_Met_Fields to HCO_Interface_GC_Mod to avoid circular dependencies. - MODEL_CLASSIC: Add State_Grid_HCO to store HEMCO grid state in HCO_State_GC_Mod. - Modified method signatures in a few subroutines to accept Input_Opt, State_Grid. Functionality changes, all MODEL_CLASSIC: - Add intermediate grid assignment in HCOI_GC_Init. - Add intermediate grid variables and allocation in HCO_Interface_GC_Mod. - Add on-demand regridding functionality for GetHcoValDep, GetHcoValEmis in HCO_Utilities_GC_Mod. - Add on-demand regridding shim HCO_GC_GetPtr in HCO_Utilities_GC_Mod. - Add on-demand regridding shim HCO_GC_EvalFld in HCO_Utilities_GC_Mod. - Use on-demand regridding for reading met fields in FlexGrid and HCO modules. - Use on-demand regridding in a variety of modules that used HCO_GetPtr. Signed-off-by: Haipeng Lin <[email protected]>
Structural changes: NOTE That this commit has minor difference test differences in a few nitrogen species (less than 1e-6 relative change) due to a switch in precision from some GetPtr (f4) to EvalFld (fp) fields. - Add IMGRID_XSCALE, IMGRID_YSCALE HEMCO grid scaling (refinement) factors to Input_Opt. - Add InquireHco subroutine in HCO_GC_Utilities_Mod for checking if given species has Deposition/Emissions, instead of calling with I,J,L=1 to retrieve data for probing. - Moved Compute_Sflx_For_Vdiff from HCO_Utilities_GC_Mod to HCO_Interface_GC_Mod to avoid a circular dependence issue (the subroutine depends on Global_CH4 and Global_Br) Functionality changes, all MODEL_CLASSIC: - Add Compute_Scaled_Grid to compute refined grid based on State_Grid in GC_Grid_Mod. - Use on-demand regridding for various modules (TOMS_MOD, TAGGED_O3, TAGGED_CO, Sulfate_Mod, SfcVmr_Mod) - Use on-demand regridding for various modules (RPMARES_Mod, ISORROPIAII_Mod, Global_CH4_Mod, Global_Br_Mod) - Use on-demand regridding for various modules (Aerosol_Mod, Carbon_Mod) - Use HCO_GC_EvalFld for OLSON_LANDMAP_MOD and MODIS_LAI_MOD. Other fixes: - Fix my name in AUTHORS.txt :) Signed-off-by: Haipeng Lin <[email protected]>
Structural changes: VALIDATED TO ZERO DIFFERENCES against 28aa0358. - Now read PNOXLOSS_O3 and PNOXLOSS_HNO3 diagnostics in MIXING_MOD and COMPUTE_SFLX_FOR_VDIFF at every time step, in preparation of HEMCO changes. - Add HCO_GC_GetDiagn interface in HCO_Utilities_GC_Mod. It is a shim for GetHcoDiagn in HCO_Interface_Common, performing on-demand regrid when IMGrid is enabled. - Add a secondary R4 buffer for model regridded data. - Now use EmisSpec, DepSpec in Compute_Sflx_For_Vdiff which retrieves a species is emis/dep enabled or not from the InquireHco subroutine, to save CPU. - Fixed wrong output type and added extra out variables for N_/L2_L2-cutoff error in FAST_JX_Mod. Functionality changes, all MODEL_CLASSIC: - Use on-demand regridding for Global_CH4_Mod::EmissCH4, Land_Mercury_Mod::BIOMASSHg, Mercury_Mod A final batch of updates will be necessary to finalize this update. This commit serves as checkpointing for zero-diffs. Signed-off-by: Haipeng Lin <[email protected]>
Structural changes: Validated to zero diff. - Code cleanup, streamline debug messages. - Add a debug message for Compute_Sflx_for_Vdiff in MAIN.F90 Functionality changes, all MODEL_CLASSIC: - Use on-demand regridding for Sulfate_Mod HEMCO diagnostics
Performance optimizations are pending, also strat_chem_mod not updated as waiting for decision on TropChem. Signed-off-by: Haipeng Lin <[email protected]>
Signed-off-by: Haipeng Lin <[email protected]>
Hi @lizziel this should replace the original pull request #364. I've checked that it compiles and runs as-is. However I'm not sure how to do a full difference test like we did before using the GC Unit Tester. As intended, the code should yield minimal differences (there are a few minor precision switches around from r4 to r8) when the following hardcoded parameters for scaling the HEMCO Grid are set, in ! Initialize the intermediate grid descriptor.
! To disable the HEMCO intermediate grid feature, simply set this DY, DX to
! equal to State_Grid%DY, State_Grid%DX (e.g. 2x2.5, 4x5, ...)
!
! TODO: Read in the grid parameters via input.geos. For now, hardcode the scale factor.
Input_Opt%IMGRID_XSCALE = 1
Input_Opt%IMGRID_YSCALE = 1 If both scale parameters are Additionally, All modules that "save" the pointer from within HEMCO (using Please let me know what I can do to further help with this! |
Thanks @jimmielin. I will do the difference testing and some other tests. Thanks so much for dealing with the conflicts. Much appreciated! |
I am now getting zero diffs for GC-Classic benchmark simulation with this update. The only change I had to make was to revert to getting pointer rather than evaluating field when retrieving Olson land map data from HEMCO during land type initialization. This avoided triggering an error trap for PBLHEIGHT in HEMCO not yet associated. I am testing with GCHP now. I had to make several minor changes for compilation, mostly regarding placement of MODEL_CLASSIC ifdefs. It now runs but I am seeing before and after differences in mixing. For example, first day average ozone zonal mean: The differences are small but clearly not numerical noise. I am looking through the changes to see if anything pops out. @jimmielin, does anything come to mind on this? |
Hi @lizziel thanks so much for doing this! This indeed looks weird. Just to confirm, does this only run PBL mixing or there's also emissions/deposition/chemistry? Nothing immediately comes to mind however it might be useful to look at ! If using HEMCO Intermediate grid feature, then the call needs to be
! refreshed at every time step for regridding. (hplin, 6/21/20)
IF ( .NOT. Input_Opt%LNLPBL ) THEN
CALL HCO_GC_GetDiagn( Input_Opt, State_Grid, 'PARANOX_O3_DEPOSITION_FLUX', &
.FALSE., RC, Ptr2D = Ptr2D )
IF( ASSOCIATED( Ptr2D )) THEN
ALLOCATE ( PNOxLoss_O3( State_Grid%NX, State_Grid%NY ), STAT=RC )
PNOxLoss_O3(:,:) = Ptr2D(:,:)
ENDIF
Ptr2D => NULL()
CALL HCO_GC_GetDiagn( Input_Opt, State_Grid, 'PARANOX_HNO3_DEPOSITION_FLUX',&
.FALSE., RC, Ptr2D = Ptr2D )
IF( ASSOCIATED( Ptr2D )) THEN
ALLOCATE ( PNOxLoss_HNO3( State_Grid%NX, State_Grid%NY ), STAT=RC )
PNOxLoss_HNO3(:,:) = Ptr2D(:,:)
ENDIF
Ptr2D => NULL()
ENDIF It may also be useful to look at some other species that are emitted (e.g. Thanks again for looking into this! |
Diffs occur for many species, including NO and CO, with a similar signature. It only occurs if Using |
I traced the problem to the new interface I will merge this PR as is into dev and make the various fixes (change |
Hi Lizzie, thank you for the update! This sounds great. Please let me know if I can help with any other fixes. |
This is the successor to #364, which has been reposted under a new branch due to the rebase to a newer version of GEOS-Chem (13.0.0 release on the
main
branch)Please find attached the original description of the feature below:
Hi GCST,
This update includes the HEMCO 3.0 planned feature, the "HEMCO Intermediate Grid", which allows HEMCO to operate on a different grid than the GC-Classic simulation, at runtime. The update is rather hefty and here goes a quick summary of what's happening under the hood:
Changes summary
The intermediate grid feature is controlled by three new input options,
Input_Opt%IMGRID_XSCALE
,Input_Opt%IMGRID_YSCALE
, which defines the refinement scale for the HEMCO grid (setting them to 2, 2 means that HEMCO works on 1x1.25 on a 2x2.5 simulation). This number is hardcoded as 1, 1 (= do nothing) underhco_interface_gc_mod.F90
right now because the feature requires testing and validation and its best kept hidden for now. If any of the scales are not equal to 1, thenInput_Opt%LIMGRID
is enabled, which enables the intermediate grid feature. In the future these should be switches ininput.geos
but they are not implemented yet as the feature has not passed scientific validation.The HEMCO grid is described in
State_Grid_HCO
stored inhco_state_gc_mod.F90
. It reuses theGrdState
nicely. Generation of a "refined"/scaled grid is using the new subroutinegc_grid_mod.F90 : Compute_Scaled_Grid
.The main idea: Data is stored in HEMCO resolution in
HcoState
as usual, and only regridded on-demand. The regridded data lies in a single buffer (actually, two.) (TMP_MDL
inhco_utilities_gc_mod.F90
) which is updated when a new field is requested via the newHCO_GC_*
subroutines below...Everything intermediate-grid related is wrapped in
MODEL_CLASSIC
andIF ( Input_Opt%LIMGRID )
checks. There are minor changes to the code that affect all simulations, though:HCO_GetPtr
should now beHCO_GC_GetPtr
, implemented inhco_utilities_gc_mod.F90
.HCO_EvalFld
should now beHCO_GC_EvalFld
.GetHcoDiagn
should now beHCO_GC_GetDiagn
.Compute_Sflx_For_Vdiff
has been moved tohco_interface_gc_mod.F90
due to circular dependency.mixing_mod.F90 : DO_TEND
andhco_interface_gc_mod.F90 : Compute_Sflx_For_Vdiff
have been switched slightly: the species loop must be outermost, as HEMCO intermediate grid only stores up to one species in the "regridded" memory buffer, so species must be read contiguously before moving on to the next.When intermediate grid is enabled, the above
HCO_GC_*
calls retrieves data from HEMCO, compares it against the buffer, and regrids as necessary, discarding old data in the buffer. Why a buffer? Because some calls toHCO_GetPtr
expect aPOINTER
and do their own data copying. To maximize compatibility, they're given the temporary buffer to point to. Care should be taken to "update" these pointers at every time step now, as they won't be pointing to the right things if the data wasn't copied from them before the nextHCO_GC_*
call. I've checked all the places in G-C that do this and changed everywhere, exceptstrat_chem_mod.F90
, pending decision on tropchem.Detailed list of changes below. I've also fixed some debug messages as I went probing through the entire GC source.
List of changes made to the code in all commits
Structural changes (validated to "zero" diff, see below, when IMGrid is not enabled):
FRAC_OF_PBL
duplicate and read throughState_Met
.IMGRID_XSCALE
,IMGRID_YSCALE
HEMCO grid scaling (refinement) factors toInput_Opt
.SUMCOSZA
toState_Met%SUNCOSsum
.Calc_SUMCOSZA
toCalc_Met_Mod
.State_Grid_HCO
to store HEMCO grid state inHCO_State_GC_Mod
.InquireHco
subroutine inHCO_GC_Utilities_Mod
for checking if given species has Deposition/Emissions, instead of calling with I,J,L=1 to retrieve data for probing.EmisSpec
,DepSpec
inCompute_Sflx_For_Vdiff
which retrieves a species is emis/dep enabled or not from theInquireHco
subroutine, to save CPU.Compute_Sflx_For_Vdiff
fromHCO_Utilities_GC_Mod
toHCO_Interface_GC_Mod
to avoid a circular dependence issue (the subroutine depends on Global_CH4 and Global_Br)PNOXLOSS_O3
andPNOXLOSS_HNO3
diagnostics inMIXING_MOD
andCOMPUTE_SFLX_FOR_VDIFF
at every time step, in preparation of HEMCO changes.HCO_GC_GetDiagn
interface in HCO_Utilities_GC_Mod. It is a shim forGetHcoDiagn
inHCO_Interface_Common
, performing on-demand regrid when IMGrid is enabled.FAST_JX_Mod
.Compute_Sflx_for_Vdiff
inMAIN.F90
Functionality changes, all MODEL_CLASSIC:
HCOI_GC_Init
.HCO_Interface_GC_Mod
.Compute_Scaled_Grid
to compute refined grid based on State_Grid inGC_Grid_Mod
.GetHcoValDep
,GetHcoValEmis
inHCO_Utilities_GC_Mod
.HCO_GC_EvalFld
for OLSON_LANDMAP_MOD and MODIS_LAI_MOD.Difference test output
Only nonzero species attached.
Comparison was made against GEOS-Chem Classic "Wrapper", with GEOS-Chem Classic commit
28aa0358
indev/13.0.0
.Please feel free to squash the commits and let me know of any questions regarding this implementation... Apologies in advance for a 6,000 line commit in one PR. Hopefully there aren't too many merge conflicts. All changes are under the hood if the functionality isn't enabled at code level in
hco_interface_gc_mod.F90
to set theXSCALE
/YSCALE
to non-1 value, so afterwards GEOS-Chem should look and work like GEOS-Chem as usual.Have a nice day 😄
Haipeng