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

Fix errors in GCClassic dry-run simulations when Cloud-J photolysis is activated #2082

Merged
merged 3 commits into from
Jan 8, 2024

Conversation

yantosca
Copy link
Contributor

Name and Institution (Required)

Name: Bob Yantosca
Institution: Harvard + GCST

Confirm you have reviewed the following documentation

Describe the update

This PR fixes a few issues in GEOS-Chem Classic dry-run simulations when Cloud-J is used as the photolysis scheme instead of FAST-JX. Namely:

  • We have added subroutines to GeosCore/cldj_interface_mod.F90 to test whether Cloud-J configuration files are present on disk, or whether they are yet to be downloaded. This prevents us from having to add GEOS-Chem specific code deep into the Cloud-J submodule.
  • We have moved the call to RD_PROF_NC in GeosCore/photolysis_mod.F90 before the IF ( Input_Opt%DryRun ) RETURN statement. This error was causing the fastj.jv_atms_dat.nc` file to be skipped in the dry-run logfile output.
  • File paths written to log file ouptut now properly indicate whether CLOUD-J or FAST-JX is activated.
  • Updated text in source code comment headers as well as in messages that get written to the log file.

Expected changes

Dry-run simulations using using Cloud-J will now have the proper logfile output. This will allow the download_data.py script to properly download all relevant Cloud-J configuration files.

Reference(s)

N/A

Related Github Issue(s)

Ubuntu and others added 2 commits December 19, 2023 20:40
GeosCore/cldj_interface_mod.F90
- Added PRIVATE functions CloudJ_DryRun_Check and Check_File_for_DryRun,
  which check if each of the Cloud-J configuration files are present
  on disk, or need to be downloaded.

Signed-off-by: Bob Yantosca <[email protected]>
GeosCore/photolysis_mod.F90
- Move call to RD_PROF_NC before the RETURN statement when
  running GEOS-Chem in dry-run mode.  This was preventing the
  fastj.jv_atms_dat.nc file from being downloaded in the dry-run.
- Update WRITE statements in RD_AOD and RD_PROF_NC to indicate
  whether FAST-JX or CLOUD-J is activated.
- Updated typo in comment header to RD_PROF_NC
- Changed text in "ThisLoc" variable in RD_PROF_NC from
  "fjx_interface_mod.F90" to "photolysis_mod.F90"
- Changed text in "ThisLoc" variable in RD_AOD from
  "fast_jx_mod.F90" to "photolysis_mod.F90"

Signed-off-by: Bob Yantosca <[email protected]>
@yantosca yantosca added topic: Dry-Run Simulation Related to GEOS-Chem dry-run category: Bug Fix Fixes a previously-reported bug labels Dec 19, 2023
@yantosca yantosca added this to the 14.3.1 milestone Dec 19, 2023
@yantosca yantosca requested a review from lizziel December 19, 2023 21:48
@yantosca yantosca self-assigned this Dec 19, 2023
@yantosca
Copy link
Contributor Author

Integration tests are running.

NOTE: @msulprizio @lizziel: I've left the base branch as main. We can decide whether to pull this into 14.3.0 or 14.3.1 as circumstances warrant.

@yantosca
Copy link
Contributor Author

All GEOS-Chem Classic integration tests passed:

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

GCClassic #6417c08 HEMCO submodule update: Merge PR #244 containing fix for IsModelLevel check in CESM and WRF-GC
GEOS-Chem #9bacfa37b Fixes for dry-run simulations with Cloud-J
HEMCO     #f0dc3db Merge pull request #244 from branch 'hplin/update_hemco_regress_mdllev_cesm' of github.com:jimmielin/HEMCO-1 into dev/3.8.0

Using 24 OpenMP threads
Number of execution tests: 26

Submitted as SLURM job: 13129995
==============================================================================
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%  All execution tests passed!  %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

@msulprizio msulprizio changed the base branch from main to dev/14.3.0 January 5, 2024 17:58
@msulprizio msulprizio modified the milestones: 14.3.1, 14.3.0 Jan 5, 2024
CHANGELOG.md Show resolved Hide resolved
GeosCore/cldj_interface_mod.F90 Outdated Show resolved Hide resolved
GeosCore/cldj_interface_mod.F90 Outdated Show resolved Hide resolved
GeosCore/cldj_interface_mod.F90 Outdated Show resolved Hide resolved
RETURN
ENDIF

!--------------------------------------------------------------------
Copy link
Contributor

@lizziel lizziel Jan 5, 2024

Choose a reason for hiding this comment

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

I am trying to remember why we need to call this before exiting if photolysis is turned off. Was it to initialize TREF and OREF? Are these used somewhere other than photolysis? If not, maybe we need to make a change somewhere else to avoid having to call this when photolysis is off.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lizziel: I think it was to avoid an error. I can double check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

!lizziel: We have to call RD_AOD and RD_PROF_NC to print out the file names that will be opened, for the dry-run.

    !------------------------------------------------------------------------
    ! Read in AOD data even if photolysis disabled
    ! (or just print file name if in dry-run mode)
    !------------------------------------------------------------------------
    CALL RD_AOD( Input_Opt, State_Chm, RC )
    IF ( RC /= GC_SUCCESS ) THEN
       ErrMsg = 'Error encountered in routine "RD_AOD"!'
       CALL GC_Error( ErrMsg, RC, ThisLoc )
       RETURN
    ENDIF

    !--------------------------------------------------------------------
    ! Read in T & O3 climatology to fill e.g. upper layers or if O3 not calc.
    !--------------------------------------------------------------------
    ! NOTE: Cloud-J reads in an ascii file with this data during initialization
    ! and uses it prior to calling Cloud_JX within the Cloud-J standalone. In
    ! GEOS-Chem we read a netcdf file instead and use the data within
    ! subroutine Set_Prof_Fjx if using Fast-JX and Set_Prof_CloudJ if using
    ! Cloud-J. The data is stored in State_Chm%Phot%TREF/%OREF. Cloud-J
    ! globals variables TREF and OREF are only used for Cloud-J standalone.
    CALL RD_PROF_NC( Input_Opt, State_Chm, RC )
    IF ( RC /= GC_SUCCESS ) THEN
       ErrMsg = 'Error encountered in routine "Rd_Prof_Nc"!'
       CALL GC_Error( ErrMsg, RC, ThisLoc )
       RETURN
    ENDIF

    !------------------------------------------------------------------------
    ! Exit without doing any computations if we are doing a dry-run
    !------------------------------------------------------------------------
    IF ( Input_Opt%DryRun ) RETURN

In both RD_AOD and RD_PROF_NC, there are shunts to skip reading data if it is a dry-run.

RD_AOD:

    ! Loop over the array of filenames
    DO k = 1, State_Chm%Phot%NSPAA

       ! Choose different set of input files for standard (trop+strat chenm)
       ! and tropchem (trop-only chem) simulations
       THISFILE = TRIM( DATA_DIR ) // TRIM( SPECFIL(k) )

       !--------------------------------------------------------------
       ! In dry-run mode, print file path to dryrun log and cycle.
       ! Otherwise, print file path to stdout and continue.
       !--------------------------------------------------------------

       ! Test if the file exists
       INQUIRE( FILE=TRIM( ThisFile ), EXIST=FileExists )

       ! Test if the file exists and define an output string
       IF ( FileExists ) THEN
          FileMsg = 'RD_AOD: Opening'
       ELSE
          FileMsg = 'RD_AOD: REQUIRED FILE NOT FOUND'
       ENDIF

       ! Write to stdout for both regular and dry-run simulations
       IF ( Input_Opt%amIRoot ) THEN
          WRITE( 6, 300 ) TRIM( FileMsg ), TRIM( ThisFile )
300       FORMAT( a, ' ', a )
       ENDIF

       ! For dry-run simulations, cycle to next file.
       ! For regular simulations, throw an error if we can't find the file.
       IF ( Input_Opt%DryRun ) THEN
          CYCLE
       ELSE
          IF ( .not. FileExists ) THEN
             WRITE( ErrMsg, 300 ) TRIM( FileMsg ), TRIM( ThisFile )
             CALL GC_Error( ErrMsg, RC, ThisLoc )
             RETURN
          ENDIF

RD_PROF_NC:

    !=================================================================
    ! In dry-run mode, print file path to dryrun log and exit.
    ! Otherwise, print file path to stdout and continue.
    !=================================================================

    ! Test if the file exists
    INQUIRE( FILE=TRIM( nc_path ), EXIST=FileExists )

    ! Test if the file exists and define an output string
    IF ( FileExists ) THEN
       FileMsg = 'RD_PROF_NC: Opening'
    ELSE
       FileMsg = 'RD_PROF_NC: REQUIRED FILE NOT FOUND'
    ENDIF

    ! Write to stdout for both regular and dry-run simulations
    IF ( Input_Opt%amIRoot ) THEN
       WRITE( 6, 300 ) TRIM( FileMsg ), TRIM( nc_path )
300    FORMAT( a, ' ', a )
    ENDIF

    ! For dry-run simulations, return to calling program.
    ! For regular simulations, throw an error if we can't find the file.
    IF ( Input_Opt%DryRun ) THEN
       RETURN
    ELSE
       IF ( .not. FileExists ) THEN
          WRITE( ErrMsg, 300 ) TRIM( FileMsg ), TRIM( nc_path )
          CALL GC_Error( ErrMsg, RC, ThisLoc )
          RETURN
       ENDIF
    ENDIF

Copy link
Contributor

Choose a reason for hiding this comment

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

The ordering here with regards to when the routine exits when photolysis is turned off is different than before. CALC_AOD needs to be called regardless of whether J-values will be computed, but RD_PROF_NC does not need to be called if skipping Fast-JX/Cloud-J. But I can clean that up later. I think the aerosols stuff that always needs to be done should be taken out of photolysis_mod and then it will be more clear.

GeosCore/photolysis_mod.F90 Outdated Show resolved Hide resolved
GeosCore/photolysis_mod.F90 Outdated Show resolved Hide resolved
GeosCore/photolysis_mod.F90 Outdated Show resolved Hide resolved
GeosCore/photolysis_mod.F90 Outdated Show resolved Hide resolved
GeosCore/cldj_interface_mod.F90
- In routine CloudJ_DryRun_Check:
  - Change "fileName" to "filePath" to indicate that it is the
    absolute path of the file being handled.
- In routine Check_File_for_DryRun:
  - Change "fileName" to "filePath" to indicate that it is the
    absolute path of the file being handled.
  - When writing file paths to stdout, prefix with "PHOTOLYSIS (dry-run)"
    to make it clear that the files are for photolysis

GeosCore/photolysis_mod.F90
- In routine RD_AOD:
  - When writing file paths to stdout, prefix w/ "PHOTOLYSIS (RD_AOD)"
- In routine RD_PROF_NC:
  - When writing file paths to stdout, prefix w/ "PHOTOLYSIS (RD_PROF_NC)"

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

yantosca commented Jan 5, 2024

@lizziel: I've implemented your suggestions in commit 22c8094. The dry-run output now looks like:

PHOTOLYSIS (dry-run): Opening /n/holyscratch01/external_repos/GEOS-CHEM/gcgrid/data/ExtData/CHEM_INPUTS/CLOUD_J/v2023-05/CJ77_inp.dat
PHOTOLYSIS (dry-run): Opening /n/holyscratch01/external_repos/GEOS-CHEM/gcgrid/data/ExtData/CHEM_INPUTS/CLOUD_J/v2023-05/FJX_spec.dat
PHOTOLYSIS (dry-run): Opening /n/holyscratch01/external_repos/GEOS-CHEM/gcgrid/data/ExtData/CHEM_INPUTS/CLOUD_J/v2023-05/FJX_scat-aer.dat
PHOTOLYSIS (dry-run): Opening /n/holyscratch01/external_repos/GEOS-CHEM/gcgrid/data/ExtData/CHEM_INPUTS/CLOUD_J/v2023-05/FJX_scat-cld.dat
PHOTOLYSIS (dry-run): Opening /n/holyscratch01/external_repos/GEOS-CHEM/gcgrid/data/ExtData/CHEM_INPUTS/CLOUD_J/v2023-05/FJX_scat-ssa.dat
PHOTOLYSIS (dry-run): Opening /n/holyscratch01/external_repos/GEOS-CHEM/gcgrid/data/ExtData/CHEM_INPUTS/CLOUD_J/v2023-05/FJX_scat-UMa.dat
PHOTOLYSIS (dry-run): Opening /n/holyscratch01/external_repos/GEOS-CHEM/gcgrid/data/ExtData/CHEM_INPUTS/CLOUD_J/v2023-05/FJX_scat-geo.dat
PHOTOLYSIS (dry-run): Opening /n/holyscratch01/external_repos/GEOS-CHEM/gcgrid/data/ExtData/CHEM_INPUTS/CLOUD_J/v2023-05/atmos_std.dat
PHOTOLYSIS (dry-run): Opening /n/holyscratch01/external_repos/GEOS-CHEM/gcgrid/data/ExtData/CHEM_INPUTS/CLOUD_J/v2023-05/atmos_h2och4.dat
PHOTOLYSIS (dry-run): Opening /n/holyscratch01/external_repos/GEOS-CHEM/gcgrid/data/ExtData/CHEM_INPUTS/CLOUD_J/v2023-05/atmos_geomip.dat
PHOTOLYSIS (dry-run): Opening /n/holyscratch01/external_repos/GEOS-CHEM/gcgrid/data/ExtData/CHEM_INPUTS/CLOUD_J/v2023-05/FJX_j2j.dat
PHOTOLYSIS (RD_AOD): Opening /n/holyscratch01/external_repos/GEOS-CHEM/gcgrid/data/ExtData/CHEM_INPUTS/FAST_JX/v2021-10/so4.dat
PHOTOLYSIS (RD_AOD): Opening /n/holyscratch01/external_repos/GEOS-CHEM/gcgrid/data/ExtData/CHEM_INPUTS/FAST_JX/v2021-10/soot.dat
PHOTOLYSIS (RD_AOD): Opening /n/holyscratch01/external_repos/GEOS-CHEM/gcgrid/data/ExtData/CHEM_INPUTS/FAST_JX/v2021-10/org.dat
PHOTOLYSIS (RD_AOD): Opening /n/holyscratch01/external_repos/GEOS-CHEM/gcgrid/data/ExtData/CHEM_INPUTS/FAST_JX/v2021-10/ssa.dat
PHOTOLYSIS (RD_AOD): Opening /n/holyscratch01/external_repos/GEOS-CHEM/gcgrid/data/ExtData/CHEM_INPUTS/FAST_JX/v2021-10/ssc.dat
PHOTOLYSIS (RD_AOD): Opening /n/holyscratch01/external_repos/GEOS-CHEM/gcgrid/data/ExtData/CHEM_INPUTS/FAST_JX/v2021-10/h2so4.dat
PHOTOLYSIS (RD_AOD): Opening /n/holyscratch01/external_repos/GEOS-CHEM/gcgrid/data/ExtData/CHEM_INPUTS/FAST_JX/v2021-10/h2so4.dat
PHOTOLYSIS (RD_AOD): Opening /n/holyscratch01/external_repos/GEOS-CHEM/gcgrid/data/ExtData/CHEM_INPUTS/FAST_JX/v2021-10/dust.dat
PHOTOLYSIS (RD_PROF_NC): Opening /n/holyscratch01/external_repos/GEOS-CHEM/gcgrid/data/ExtData/CHEM_INPUTS/FastJ_201204/fastj.jv_atms_dat.nc

I think this iis more consistent and informative than before.

@yantosca yantosca requested a review from lizziel January 5, 2024 20:47
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 merge. Thansk @yantosca!

@msulprizio msulprizio merged commit 7aeb5f8 into dev/14.3.0 Jan 8, 2024
@msulprizio msulprizio deleted the bugfix/cloudj-dryrun branch January 8, 2024 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: Bug Fix Fixes a previously-reported bug topic: Dry-Run Simulation Related to GEOS-Chem dry-run
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants