Skip to content
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

Use integer flags to denote species units instead of strings #1796

Merged

Conversation

yantosca
Copy link
Contributor

@yantosca yantosca commented May 15, 2023

Name and Institution (Required)

Name: Bob Yantosca
Institution: Harvard + GCST

Confirm you have reviewed the following documentation

Describe the update

This update will improve how unit conversions are done in GEOS-Chem:

  • Use integer unit flags instead of strings. This will improve runtime as integer comparisons are much faster than string comparisons.

Expected changes

This should be a zero-diff update, as we do not plan to introduce any differences. However, it may be that this ends up introducing differences at the level of numerical noise.

Reference(s)

N/A

Related Github Issue(s)

These updates are the first batch of modifications for converting
species unit conversions to per-species.  This will involve keeping
track of the units of each species rather than assuming that all species
have the same unit.  This will allow us only to convert species that are
absolutely needed (e.g. only convert wetdep species before wetdep, etc.)

Headers/state_chm_mod.F90
- State_Chm%Spc_Units is now an integer instead of a character string

GeosUtil/unitconv_mod.F90
- Add public integer unit parameter flags
- Add private UNIT_STR array to convert integer unit flags to a string
- inUnit, outUnit, and origUnit variables are now all integers
- IS_Adjoint is renamed to isAdjoint
- Now set State_Chm%Spc_Units with the appropriate integer flags
- Trimmed trailing whitespace

NOTE: This update will cause type mismatch errors until we fix the
type of the outUnit and origUnit variables in routines that call
Convert_Spc_Units.  These will be fixed in upcoming commits.

Signed-off-by: Bob Yantosca <[email protected]>
@yantosca yantosca added category: Feature Request New feature or request topic: Structural Modifications Related to GEOS-Chem structural modifications (as opposed to scientific updates) no-diff-to-benchmark This update will not change the results of fullchem benchmark simulations topic: Performance Related to GEOS-Chem speed, memory, or parallelization labels May 15, 2023
@yantosca yantosca self-assigned this May 15, 2023
yantosca added 4 commits May 15, 2023 17:40
GeosUtil/unitconv_mod.F90
- UNIT_STR needs to be UNIT_STR(7) and PUBLIC
- Corrected typos
- Fixed incorrect unit conversion flag names
- Fixed issue that prevented kg/kg -> mol/mol dry conversion
  from beinmg done (i.e. using the wrong flag in the CASE statement)
- Fixed incorrect error message variable names
- Fixed instances where origUnit was character, not integer
- Use UNIT_STR to convert the integer value to a string

Signed-off-by: Bob Yantosca <[email protected]>
In all routines where Convert_Spc_Units is called:
- Pass an integer flag instead of a string via outUnit
- Use an integer variable to store origUnit
- Use the entire unitconv_mod module (i.e. "USE UnitConv_Mod)
- Use UNIT_STR parameter array to convert integer to string values

NOTE: These updates cause differences w/r/t the prior code.  We will
identify and fix these in subsequent updates.

Signed-off-by: Bob Yantosca <[email protected]>
Interfaces/GCHP/gchp_chunk_mod.F90
- Bug fix: the #elif block should set State_Chm%Spc_Units to
  MOLES_SPECIES_PER_MOLES_DRY_AIR.

Signed-off-by: Bob Yantosca <[email protected]>
GeosCore/aero_drydep_mod.F90
GeosCore/dust_mod.F90
GeosCore/tomas_mod.F90
GeosCore/wetscav_mod.F90
- Add "USE UnitConv_Mod" where it was missing
- Take State_Chm%Spc_Units out of TRIM statements as it's an integer now
- Use "UNIT_STR(State_Chm%Spc_Units)" in error messages, which will
  convert the integer unit flag to a string.

NOTE: These modifications are just to preserve the status quo before
refactoring (so that we can test for identicality).  We will eventually
be removing State_Chm%Spc_Units as we move to per-species unit variables.

Signed-off-by: Bob Yantosca <[email protected]>
This brings the GEOS-Chem 14.2.1 code into the development branch
feature/unitconv-per-species-category so that further development
can take place.

Signed-off-by: Bob Yantosca <[email protected]>
GeosCore/mercury_mod.F90
- Add missing origUnit variable

GeosCore/set_boundary_conditions_mod.F90
- Add "USE UnitConv_Mod" statement
- Changed LOC -> thisLoc
- Changed origUnit variable from CHARACTER to INTEGER
- Use KG_SPECIES_PER_KG_DRY_AIR instead of "kg/kg dry"
- Use UNIT_STR(State_Chm%SPC_UNITS) for a string representation of units
- Now save error msg in errMsg variable

GeosCore/tracer_mod.F90
- Updated call to Convert_Spc_Units, use MOLES_SPECIES_PER_MOLES_DRY_AIR
  as the units parameter
- Change origUnit from CHARACTER to INTEGER

Signed-off-by: Bob Yantosca <[email protected]>
@yantosca yantosca changed the title Optimize unit conversions and allow unit conversions for certain categories of species (instead of all species) Use integer flags to denote species units instead of strings Oct 12, 2023
@yantosca yantosca requested a review from msulprizio October 12, 2023 17:55
@yantosca yantosca changed the base branch from main to dev/no-diff-to-benchmark October 12, 2023 17:55
@yantosca yantosca marked this pull request as ready for review October 12, 2023 17:57
@yantosca
Copy link
Contributor Author

Integration tests (14.2.2_r1) now running.

@yantosca
Copy link
Contributor Author

All GCHP compilation tests failed. GEOS-Chem Classic tests are proceeding.

Compiliation tests:
------------------------------------------------------------------------------
GCHP................................................Configure & Build.....FAIL
GCHP w/ carbon gases (as a KPP mechanism)...........Configure & Build.....FAIL
GCHP with RRTMG.....................................Configure & Build.....FAIL

Interfaces/GCHP/gchp_chunk_mod.F90
- Change origUnit variable from CHARACTER to INTEGER since we now
  use integer parameters for species units

Signed-off-by: Bob Yantosca <[email protected]>
@yantosca
Copy link
Contributor Author

Fixed an issue in Interfaces/GCHP/gchp_chunk_mod.F90, where the origUnit variable was still CHARACTER. This now needs to be integer. Rerunning integration tests.

@yantosca
Copy link
Contributor Author

All GEOS-Chem Classic integration tests passed (except for TOMAS, which will be fixed soon):

==============================================================================
GEOS-Chem Classic: Execution Test Results

GCClassic #ad68c48 GEOS-Chem 14.2.1 and HEMCO 3.7.1 release
GEOS-Chem #eb803ca49 Fix several issues with integer unit parameters in newer code
HEMCO     #00aaf65 Update HEMCO 3.7.1 release date in CHANGELOG.md

Using 24 OpenMP threads
Number of execution tests: 27

Submitted as SLURM job: 4591914
=============================================================================
 
Summary of test results:
------------------------------------------------------------------------------
Execution tests passed: 25
Execution tests failed: 2
Execution tests not yet completed: 0

@yantosca
Copy link
Contributor Author

Also all GEOS-Chem Classic integration tests were zero-diff w/r/t the prior integration test (for PR #1977), except for the usual suspects:

Checking gc_4x5_merra2_fullchem_APM
   -> 2 differences found in OutputDir
      * GCC_r30//rundirs/gc_4x5_merra2_fullchem_APM/OutputDir/GEOSChem.Metrics.20190701_0000z.nc4 
        GCC_r1/rundirs/gc_4x5_merra2_fullchem_APM/OutputDir/GEOSChem.Metrics.20190701_0000z.nc4 
      * GCC_r30//rundirs/gc_4x5_merra2_fullchem_APM/OutputDir/GEOSChem.SpeciesConc.20190701_0000z.nc4 
        GCC_r1/rundirs/gc_4x5_merra2_fullchem_APM/OutputDir/GEOSChem.SpeciesConc.20190701_0000z.nc4 
   -> 1 difference found in Restarts
      * GCC_r30//rundirs/gc_4x5_merra2_fullchem_APM/Restarts/GEOSChem.Restart.20190701_0100z.nc4 
        GCC_r1/rundirs/gc_4x5_merra2_fullchem_APM/Restarts/GEOSChem.Restart.20190701_0100z.nc4 


Checking gc_4x5_merra2_fullchem_RRTMG
   -> 1 difference found in OutputDir
      * GCC_r30//rundirs/gc_4x5_merra2_fullchem_RRTMG/OutputDir/GEOSChem.RRTMG.20190701_0000z.nc4 
        GCC_r1/rundirs/gc_4x5_merra2_fullchem_RRTMG/OutputDir/GEOSChem.RRTMG.20190701_0000z.nc4 
   -> No differences in Restarts

These simulations are known to have parallelization issues.

@yantosca yantosca modified the milestones: 14.2.2, 14.2.1 Oct 12, 2023
Copy link
Contributor

@msulprizio msulprizio left a comment

Choose a reason for hiding this comment

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

This PR should be good to merge after removing the obsolete MMR_Compute_Flux routine from emissions_mod.F90.

GeosCore/emissions_mod.F90 Outdated Show resolved Hide resolved
GeosCore/emissions_mod.F90
- Removed the routine MMR_Compute_Flux, which snuck back in with a
  Git merge when we brought the feature/unitconv-per-species-category
  up to 14.2.1.

Signed-off-by: Bob Yantosca <[email protected]>
@yantosca
Copy link
Contributor Author

yantosca commented Oct 13, 2023

Good catch @msulprizio. MMR_Compute_Flux is now removed again in commit 189cc1c.

@yantosca yantosca requested a review from msulprizio October 13, 2023 14:14
@lizziel lizziel self-requested a review October 13, 2023 14:50
Copy link
Contributor

@lizziel lizziel left a comment

Choose a reason for hiding this comment

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

Looks good to me! In the future could you put formatting changes in a different PR? It was hard to hone in on the changes with so many indentation etc changes.

@yantosca
Copy link
Contributor Author

Looks good to me! In the future could you put formatting changes in a different PR? It was hard to hone in on the changes with so many indentation etc changes.

Will do @lizziel.

1 similar comment
@yantosca
Copy link
Contributor Author

Looks good to me! In the future could you put formatting changes in a different PR? It was hard to hone in on the changes with so many indentation etc changes.

Will do @lizziel.

@yantosca
Copy link
Contributor Author

After merging locally, all integration tests passed (except TOMAS) and were zero-diff w/r/t 14.2.2. (except APM and RRTMG diagnostic output).

@yantosca yantosca merged commit 5331282 into dev/no-diff-to-benchmark Oct 31, 2023
@yantosca yantosca added this to the 14.2.3 milestone Nov 30, 2023
yantosca added a commit that referenced this pull request Dec 1, 2023
This is the official release of GEOS-Chem (science codebase) 14.2.3.
Updates include:

- Use integer flags to denote species units instead of strings (PR #1796)
- Prevent POAEMISS variable from being assigned if not allocated (PR #1987)
- Add an --no-bootstrap option to integration tests (PR #1990)
- Fixed incorrect comments on static H2O option (PR #2013)
- Improve missing CH4 emissions error message (PR #2039)
- Lower GCHP timestep threshold if > C180 rather than >= C180 (PR #2040)
- Add fixes to HEMCO_Config.rc for CH4, carbon simulations (PR #2042)
- Fix typos written to GCHP integration test log files (PR #2043)
- Update GCClassic rundir scripts to read restat file paths
  from download_data.yml (PR #2050)

Signed-off-by: Bob Yantosca <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: Feature Request New feature or request no-diff-to-benchmark This update will not change the results of fullchem benchmark simulations topic: Performance Related to GEOS-Chem speed, memory, or parallelization topic: Structural Modifications Related to GEOS-Chem structural modifications (as opposed to scientific updates)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants