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

[WIP] Logging updates for GCHP #846

Closed
wants to merge 74 commits into from

Conversation

LiamBindle
Copy link
Contributor

@LiamBindle LiamBindle commented Aug 26, 2021

This is a work in progress (WIP).

Objectives

1. Improve error reporting for common pitfalls

The reporting of errors related to reading config files could be improved. The config files are parsed in Chem_GridCompMod so that's the module I'm focusing on. Two updates:

  1. Replace __RC__ calls with rc=STATUS followed by _ASSERT_RC() followed by _VERIFY().
  2. Report what file is about to be parsed before it is actually read.

Details on 1.1.

__RC__ is a PP macro defined by

#define __RC__  RC=STATUS); _VERIFY(STATUS

in MAPL/include/MAPL_Exceptions.h. In places like loading config files (e.g., here) these __RC__ calls mean that errors aren't reported very well. For example, if parsing GCHP.rc fails the following non-fatal error is reported

pe=00001 FAIL at line=00573    Chem_GridCompMod.F90                     <status=8>

and there is no information about the offending file. Note that the staus is actually helpful, status=8 refers to MAPL_STRING_TOO_SHORT defined here. We just need it to be printed.

The call we want to make is

MAPL_Assert_return_code(COND, return_code, filename, line, rc)

where condition=(STATUS ==MAPL_SUCCESS), return_code=STATUS, and rc=MAPL_ERROR_PARSING_CONFIG_FILE.

Soon there will be the _ASSERT_RC() PP macro defined by

#  ifdef I_AM_MAIN
#    define __return call MAPL_abort()
#    define __rc(rc) 
#  else
#    define __return return
#    define __rc(rc) ,rc
#  endif
#    define _ASSERT_MSG_AND_LOC_AND_RC(A,msg,stat,file,line,rc)  if(MAPL_Assert(A,msg,stat,file,line __rc(rc))) __return
#    define _ASSERT_MSG_AND_LOC(A,msg,stat,file,line) _ASSERT_MSG_AND_LOC_AND_RC(A,msg,stat,file,line,rc)
#    define _ASSERT_RC(A,msg,stat) _ASSERT_MSG_AND_LOC(A,msg,stat,_FILE_,__LINE__)

which is close to what we want. It would be better to use __FILE__ though so the full path is printed, and _ASSERT_RC isn't actually available yet.

The call we want to make is _ASSERT_MSG_AND_LOC_AND_RC(STATUS==MAPL_SUCCESS, 'Error parsing GCHP.rc', __FILE__, __LINE__, MAPL_ERROR_PARSING_CONFIG_FILE).

ganluoasrc and others added 30 commits November 16, 2020 14:16
…ISTORY

This commit fulfills feature request geoschem/geos-chem #571.

GeosUtil/grid_registry_mod.F90:
- Allocate LONBND array and register as GRID_LONBND
- Allocate LATBND array and register as GRID_LATBND

History/histcontainer_mod.F90
- Add NB (# of bounds = 2) and bDimId (netCDF dimension Id for bounds)

History/histitem_mod.F90
- Add NcBDimId (netCDF dimension for bounds)
- Set NcChunkSizes properly for LONBND (dims: bx) or LATBND (dims: by)

History/history_mod.F90:
- Assing Collection%NB=2 for all collections

History/history_netcdf_mod.F90:
- Pass Container%bDimId to Nc_Create
- Pass Container%bDimId and VarBounds to Get_Var_DimIds
- Modify Get_Var_DimIds for LONBND (dims: bx) and LATBND (dims: by)
- Pass Current%Item%NcBDimId and VarBounds to Nc_Var_Def
- Update CASE statement and Get_Var_DimIds to write out LONBND as
  "lon_bnds" and LATBND as lat_bnds"
- Give "lon" and "lat" the bounds attribute
- Update routine IndexVarListCreate to add lon & lat bounds to the list
  of netCDF index variables

NcdfUtil/ncdf_mod.F90:
- Nc_Create and Nc_Var_Def now accept nBounds, boundsId arguments

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
In history_netcdf_mod.F90, the lon:axis ="X" and lat:axis = "Y"
were inadvertently removed.  These have been restored.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
This commit fixes an issue reported by Viral Shah and Chris Holmes
in Github issue geoschem/geos-chem #743.  The terms 2*ff**2 and 2*kk**2
should have been 2*ff and 2*kk.  This corresponds to Eq 3 of Holmes
et al, GRL, 2019.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
This commit fixes the issue reported by Eloise Marais in Github
bug report geoschem/geos-chem #747.  Because ObsPack pressure
(the State_Diag%ObsPack_P field) is taken from the GEOS-Chem
State_Met%PMID field, the units should be hPa.  This is now fixed.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
Following the Pull request:
#511

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
We have updated the species_database.yml file with the metadata for
the new trace metal simulation species.  Most of this metadata
can be taken from the DST1, DST2, DST3, and DST4 properties.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
(1) Added template files in run/GCClassic
    - HEMCO_Config.rc.metals
    - HISTORY.rc.metals
    - input.geos.metals
(2) Updated run/GCClassic/createRunDir.sh to allow trace metal sims.
(3) Fixed a few issues in the species_database.yml file.
(4) Added Input_Opt%ITS_A_TRACEMETAL_SIM in Headers/input_opt_mod.F90.
(5) Added "metals" as a new simulation type in input_mod.F90.
(6) Allow tracemetal simulation in hco_interface_gc_mod.F90.
(7) Trimmed trailing whitespace.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
(1) Removed an extraneous "-" from the HEMCO_Config.rc.metals file.

(2) Updated ./createRunDir.sh to look for the metals restart file
    in GEOSCHEM_RESTARTS/v2021-06.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
In test/intTestCreate.sh, add the proper keystroke sequences to set up
the following integration tests:

- gc_2x25_metals_merra2
- gc_2x25_metals_geosfp
- gc_4x5_metals_merra2
- gc_4x5_metals_geosfp

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
Replace "_" with "." in the restart fle name for the metals simulation.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
The default global anthropogenic emissions have been updated from
CEDS GBD-MAPS (1970-2017) to CEDS v2 (1750-2019). CEDS GBD-MAPS, which
also allow for separation by fuel type are still included as an option.

This commit addresses feature request #757.

Signed-off-by: Melissa Sulprizio <mpayer@seas.harvard.edu>
The CEDS entries in HEMCO_Config.rc.tagCO were still using the sectors from
the CEDS GBD-MAPS (NRTR, ROAD, RCOR, RCOO) but should now be using those
from the CEDS v2 (TRA, RCO).

Also fix the logicals for the CHINA_MASK in that file so that it is read if
CEDSv2, CEDS_GBDMAPS, or CEDS_GBDMAPS_byFuelType is set to true.

Signed-off-by: Melissa Sulprizio <mpayer@seas.harvard.edu>
Reading in the restart file cannot handle species with a "_" in their
name, so we have renamed all trace metal species in the input.geos,
HEMOC_Config.rc, and species_database.yml templates.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
The HEMCO_Config.rc.metals template file specified the meteorology
section but the meteorology entries are now inserted automatically
by the createRunDir.sh script.  This was causing the HEMCO code

We have removed the manual entries and have left only the template.
This fixes the issue.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
The CEDS entries in ExtData.rc were still using the sectors from
the CEDS GBD-MAPS (NRTR, ROAD, RCOR, RCOO) but should now be using those
from the CEDS v2 (TRA, RCO).

Signed-off-by: Melissa Sulprizio <mpayer@seas.harvard.edu>
We have removed "_" from species names (i.e. Al_F1 is now AlF1, etc),
so we had to make the corresponding change in the HEMCO_Diagn.rc.metals
template file.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
…ullname for new trace metals

Signed-off-by: Melissa Sulprizio <mpayer@seas.harvard.edu>
Jenny Fisher provided scripts for updating to the latest MODIS LAI product
from BNU (v6). This data has been further processed to separate the MODIS
LAI field into fields for each land type (aka Yuan-processed MODIS XLAI).
The only update required for these new files is to change the file path in
HEMCO_Config.rc and ExtData.rc from Yuan_XLAI/v2019-03 to Yuan_XLAI/v2021-06.

This commit addresses feature request #717.

Signed-off-by: Melissa Sulprizio <mpayer@seas.harvard.edu>
When using the CEDS GBD-MAPS emission, HEMCO_Config.rc files with the
emissions entries are read in via >>>include statements. There was a typo
in the file name for these HEMCO_Config.rc files -- "CEDS_GBD-MAPS" should
be "CEDS_GBDMAPS".

Signed-off-by: Melissa Sulprizio <mpayer@seas.harvard.edu>
…improve run time

As part of the GEOS-Chem release proposal the GCST sent to the GEOS-Chem
Steering Committee, it was proposed that several diagnostics should be
turned off to increase benchmark run time. From that document:

   Diagnostics currently take up about 25% of run-time for full chemistry
   benchmarks. This can be reduced by limiting diagnostic output to only
   data needed for benchmarking. We propose changes to the following
   diagnostic collections in benchmark runs:

   * Budget
     - Disable for both 1-year and 1-month benchmarks
   * DryDep, ProdLoss, WetLossConv, and WetLossLS
     - Disable for 1-month benchmarks
     - Enable for 1-year benchmarks, but only output Ox species
   * CloudConvFlux, ConcAfterChem, KppDiags, LevelEdgeDiags, StateChm
     - Disable for both 1-year and 1-month benchmarks
   * StateMet
     - Limit to only output fields needed for post-processing

Signed-off-by: Melissa Sulprizio <mpayer@seas.harvard.edu>
In GeosCore/ucx_mod.F90:

(1) In routine CALC_STRAT_AER, make sure that all PRIVATE variables
    are initialized or zeroed in the !$OMP PARALLEL loop.  This will
    help to prevent numerical instability issues.

(2) In routine CALC_SLA_GAMMA, set RXNGAMMA(2), RXNGAMMA(5),
    RXNGAMMA(9), and RXNGAMMA(11) to 0.0_f8 instead of TINY(1e0_f8).
    The TINY function returns the smallest positive number representable
    by REAL*8 (which is ~1e-308), which is very close to the range
    of denormal numbers.  Using 0.0_f8 will set these elements to
    exactly zero, which should eliminate any numerical noise or
    numerical instability.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
…he AEIC emissions were still emitted in units of kgC instead of kg species. This bug fix requires the definition of two new scale factors, CtoMACR and CtoRCHO.
yantosca and others added 27 commits July 9, 2021 11:04
sulfate_mod.F90
- Add _fp or _f8 to numerical constants where missing

wetscav_mod.F90
- Add INV_T298 parameter
- Make pH an argument of Compute_L2G for both Luo_Wetdep and default
  wetdep, passing in the proper pH value in the subroutine call
- Remove string comparison tests in IF blocks where special handling
  has to be done for SO2 and NH3.  Replace with tests against the
  species index.
- Streamline Henry's law computations for SO2 and NH3, to avoid
  recomputing terms that only need to be computed once.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
run/shared/species_database.yml:
- The MW_g of EOH (methanol) should be 46.07, which matches
  https://pubchem.ncbi.nlm.nih.gov/compound/Ethanol

run/GCClassic/HEMCO_Config.rc.templates/HEMCO_Config.rc.fullchem
run/GCHP/HEMCO_Config.rc.templates/HEMCO_Config.rc.fullchem
- Scale factor CtoC3H8 should use a mol wt of 44.11
- Scale factor CtoEOH should use a mol wt of 46.07

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
The new Luo et al 2020 wet deposition scheme requires the value of
State_Chm%phCloud even for non-fullchem or aerosol routines.  We have
now moved this to the #ifdef LUO_WETDEP block where the other
Luo et al 2020-specific fields are initialized.

Also, based on a communication from Gan Luo, we make sure to set
State_Chm%pHcloud to an initial value of 5.6.  This value is appropriate
for cloud water (it accounts for dissolved CO2 in cloud water droplets).

For the fullchem and aerosol simulations, State_Chm%pHcloud will be
computed in the sulfate chemistry routines.  But for other simulations,
the default value of State_Chm%pHcloud = 5.6 will be used.

These updates are necessary to avoid an out-of-bounds error caused
by State_Chm%pHcloud not being allocated in simulations other than
fullchem or aerosol-only.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
Prior to this commit, a pH value of 5.0 was passed to Compute_Ki
in routine Compute_F.  We now pass it the value of State_Chm%pHcloud,
which by default is set to 5.6.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
The single quotes were removed from NO in commit 1abb448. This, however,
causes an issue in GCPy so that the properties for NO are no longer found.
To resolve this, we will restore the single quotes.

Signed-off-by: Melissa Sulprizio <mpayer@seas.harvard.edu>
State_Chm%pHcloud was formerly initialized & registered within an
IF block that only executed if wetdep & convection was on, and within
an #ifdef LUO_WETDEP block too.  We have now moved the init/register
for State_Chm%pHcloud out of these blocks.  This should now allocate
State_Chm%phCloud for all simulation types.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
This brings the Luo et al 2020 wet deposition algorithm into the
the dev branch, which will be released as GEOS-Chem Classic 13.2.0.

Resolved conflicts in:

(1) run/shared/species_database.yml
    - Merge LuoWd parameters into the existing species_database.yml
      containing the trace metals species

(2) test/GCClassic/intTestCreate.sh
    - Add LuoWd integration tests

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
It was brought to our attention that the Luo et al 2020 wet deposition
updates had modified some default values in the species_database.yml
file.  But these should only be applied when using the -DLUO_WETDEP=y
option at configure time.

We have added modifications to the species_database.yml file, and to
the species_database_mod.F90 so that the Luo et al 2020 modifications
will not overwrite default values.  We have added extra species
database tags:

1. DD_DvzAerSnow_Luo
2. DD_DvzMinVal_Luo
3. Henry_CR_Luo
4. Henry_K0_Luo
5. WD_ConvFacI2G_Luo
6. WD_LiqAndGas_Luo
7. WD_RetFactor_Luo

that hold values specific to the Luo et al 2020 wetdep scheme. We have
also modified the species_database_mod.F90 to apply these values
accordingly.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
The DMS entry in the species database had a bunch of extraneous
entries following the MW_g tag.  These were left over from a Git
merge.

DMS was incorrectly tagged with Is_Aerosol=true, but did not have a
KcScale tag defined.  Thus, KcScale was set to [-999, -999, -999],
which in turn caused the exponential expression in the GET_F function to
blow up.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
Br2 was removed from online seasalt in GEOS-Chem 12.9. The diagnostics
is therefore all zeros even when online seasalt is enabled.

Signed-off-by: Lizzie Lundgren <elundgren@seas.harvard.edu>
run/GCClassic/HEMCO_Config.rc.templates/HEMCO_Config.rc.metals
- Added a missing "_" in the container name NEI11_INLN_PTEGU_Si_F1,
  which caused a configuration-time error.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
Headers/species_database_mod.F90
- In the #ifdef LUO_WETDEP block, local variable wd_convfaci2g_luo
  was being assigned to ThisSpc%WD_RetFactor.  It should have been
  assigned to ThisSpc%WD_ConvFacI2g.  This error caused fullchem
  runs with Luo Wetdep turned to halt when doing wetdep of SO2
  because the ConvFacI2G field for SO2 was set to -999.  This
  has now been fixed.
- Also moved the #ifdef LUO_WETDEP block to after the SANITY CHECKS
  section to make sure we don't clobber any other species database
  values that should be assigned when Luo Wetdep is turned on.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
… in HEMCO_Config.rc

Signed-off-by: Melissa Sulprizio <mpayer@seas.harvard.edu>
The HEMCO configuration file for GCHP's CO2 simulation was actually a
modified configuration file from the TransportTracer simulation and
included entries for emissions not needed for the CO2 simulation. The
file has now been updated so it contains the same emissions options as the
GEOS-Chem Classic CO2 simulation. The CO2 CMS Flux emissions currently used
in GCHP's CO2 simulation are still included in this file and are on by
default, while the other CO2 emission options used in GEOS-Chem Classic
remain off.

The Yuan-processed MODIS LAI entries have also been updated in HEMCO_Config.rc
for the CO2 simulation, but these entries aren't used in the GCHP simulations
since those fields are read directly by ExtData.

Signed-off-by: Melissa Sulprizio <mpayer@seas.harvard.edu>
… Yuan-processed MODIS LAI by default

Signed-off-by: Melissa Sulprizio <mpayer@seas.harvard.edu>
Signed-off-by: Lizzie Lundgren <elundgren@seas.harvard.edu>
These scripts are used by GCST at Harvard for testing. They are
provided as examples for streamlining submission of multiple
consecutive GCHP runs. Changes include:

- Number of runs is now an argument passed to gchp.multirun.sh
- Monthly diag code in gchp.multirun.run is commented out; it is kept
  as an example of how to auto-update freq/dur in HISTORY.rc for
  irregular run durations, and for use of instantaneous diagnostics in
  monthly runs.

Signed-off-by: Lizzie Lundgren <elundgren@seas.harvard.edu>
Signed-off-by: Lizzie Lundgren <elundgren@seas.harvard.edu>
…cers

The suggest memory may be confusing given possible run scenarios.

Signed-off-by: Lizzie Lundgren <elundgren@seas.harvard.edu>
Previously benchmarking used 48 cores over 2 nodes. This update speeds
up the GCHP C48 benchmark runs to be closer in timing to GC-Classic
4x5 runs.

Signed-off-by: Lizzie Lundgren <elundgren@seas.harvard.edu>
GCHP integration tests now include only one run per simulation. Across
the three type of simulations are runs with different meteorology source
and grid resolution. Tests do not yet include RRTMG, but are limited
to Transport Tracers, Benchmark, and Standard simulations.

This update also includes a bug fix where sed commands in the GCHP
run script used in integration test run directories hard initial
resource allocation in runConfig.sh hard-coded. This made the integration
tests break if the defaults in runConfig.sh change, which they did
in a recent commit. The initial values are now wildcards to prevent
this in the future.

Signed-off-by: Lizzie Lundgren <elundgren@seas.harvard.edu>
Previously this was omitted from GCHP because the field was not used
in GEOS-Chem. It is not used for sea salt aerosol source from blowing
snow in the sea salt HEMCO extension.

Signed-off-by: Lizzie Lundgren <elundgren@seas.harvard.edu>
Following the benchmarking of GEOS-Chem 13.2.0 with the Luo et al. (2020)
wet deposition scheme, Gan Luo noticed a bug in the code. He wrote:

   Simulated sulfate mass concentration looks lower than what I expected.

   I checked https://github.com/geoschem/geos-chem/blob/13.2.0-beta.0/GeosCore/sulfate_mod.F90
   It seems that we missed some switches for Non-volatile aerosol
   concentration calculation:

   (1) At line 5142 D = (2.e+0_fp*SO4nss) - (TNA+2.e+0_fp*TDCA), it should be:

       #ifdef LUO_WETDEP
          D = (1.5e+0_fp*SO4nss) - (TNA+2.e+0_fp*TDCA)
       #else
          D = (2.e+0_fp*SO4nss) - (TNA+2.e+0_fp*TDCA)
       #endif

   (2) At line 5156 D = (2.e+0_fp * SO4nss) - TNA), it should be:

       #ifdef LUO_WETDEP
          D = (1.5e+0_fp * SO4nss) - TNA
       #else
          D = (2.e+0_fp * SO4nss) - TNA
       #endif

   Switching from 2.e+0_fp * SO4nss to 1.5e+0_fp * SO4nss is following the
   reasons introduced in Luo et al. (2020).

Signed-off-by: Melissa Sulprizio <mpayer@seas.harvard.edu>
@LiamBindle
Copy link
Contributor Author

LiamBindle commented Aug 26, 2021

I'll update the base when I have a commit on top of dev.

@LiamBindle
Copy link
Contributor Author

When I was looking into this I came across GEOS-ESM/MAPL#1002. After that fix the errors are quite a bit better. Closing this for now.

@LiamBindle LiamBindle closed this Aug 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants