diff --git a/.circleci/config.yml b/.circleci/config.yml index db67635d..f2dbef1f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,11 +1,11 @@ version: 2.1 -# Anchors to prevent forgetting to update a version -baselibs_version: &baselibs_version v7.7.0 -bcs_version: &bcs_version v10.22.3 +# Anchors in case we need to override the defaults from the orb +#baselibs_version: &baselibs_version v7.25.0 +#bcs_version: &bcs_version v11.5.0 orbs: - ci: geos-esm/circleci-tools@1 + ci: geos-esm/circleci-tools@2 workflows: build-test: @@ -18,8 +18,38 @@ workflows: matrix: parameters: compiler: [gfortran, ifort] - baselibs_version: *baselibs_version + #baselibs_version: *baselibs_version repo: GEOSgcm checkout_fixture: true mepodevelop: true - persist_workspace: false # Needs to be true to run fv3/gcm experiment, costs extra + persist_workspace: true # Needs to be true to run fv3/gcm experiment, costs extra + + # Run AMIP GCM (1 hour, no ExtData) + - ci/run_gcm: + name: run-GCM-on-<< matrix.compiler >> + context: + - docker-hub-creds + matrix: + parameters: + compiler: [gfortran, ifort] + requires: + - build-GEOSgcm-on-<< matrix.compiler >> + repo: GEOSgcm + #baselibs_version: *baselibs_version + #bcs_version: *bcs_version + + # Run Coupled GCM (1 hour, no ExtData) + - ci/run_gcm: + name: run-coupled-GCM-on-<< matrix.compiler >> + context: + - docker-hub-creds + matrix: + parameters: + compiler: [gfortran, ifort] + requires: + - build-GEOSgcm-on-<< matrix.compiler >> + repo: GEOSgcm + #baselibs_version: *baselibs_version + #bcs_version: *bcs_version + gcm_ocean_type: MOM6 + change_layout: false diff --git a/.github/workflows/enforce-labels.yml b/.github/workflows/enforce-labels.yml index 6e1720ef..ad7937eb 100644 --- a/.github/workflows/enforce-labels.yml +++ b/.github/workflows/enforce-labels.yml @@ -8,7 +8,7 @@ jobs: require-label: runs-on: ubuntu-latest steps: - - uses: mheap/github-action-required-labels@v2 + - uses: mheap/github-action-required-labels@v5 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: @@ -16,10 +16,12 @@ jobs: count: 1 labels: "0 diff,0 diff trivial,Non 0-diff,0 diff structural,0-diff trivial,Not 0-diff,0-diff,automatic,0-diff uncoupled" add_comment: true + message: "This PR is being prevented from merging because you have not added one of our required labels: {{ provided }}. Please add one so that the PR can be merged." + blocking-label: runs-on: ubuntu-latest steps: - - uses: mheap/github-action-required-labels@v2 + - uses: mheap/github-action-required-labels@v5 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: @@ -27,3 +29,4 @@ jobs: count: 0 labels: "Contingent - DNA,Needs Lead Approval,Contingent -- Do Not Approve" add_comment: true + message: "This PR is being prevented from merging because you have added one of our blocking labels: {{ provided }}. You'll need to remove it before this PR can be merged." diff --git a/.github/workflows/validate_yaml_files.yml b/.github/workflows/validate_yaml_files.yml index b87f59d9..449db6e6 100644 --- a/.github/workflows/validate_yaml_files.yml +++ b/.github/workflows/validate_yaml_files.yml @@ -1,14 +1,21 @@ --- + +# Based on code from https://github.com/marketplace/actions/yaml-lint + name: Yaml Lint on: pull_request: types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled] + +# This validation is equivalent to running on the command line: +# yamllint -d relaxed --no-warnings +# and is controlled by the .yamllint.yml file jobs: validate-YAML: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - id: yaml-lint name: yaml-lint uses: ibiqlik/action-yamllint@v3 @@ -17,7 +24,7 @@ jobs: format: colored config_file: .yamllint.yml - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 if: always() with: name: yamllint-logfile diff --git a/CARMAchem_GridComp/CARMA_GridComp.F90 b/CARMAchem_GridComp/CARMA_GridComp.F90 index f8a8c397..139d8fcb 100644 --- a/CARMAchem_GridComp/CARMA_GridComp.F90 +++ b/CARMAchem_GridComp/CARMA_GridComp.F90 @@ -977,7 +977,7 @@ SUBROUTINE CARMA_GridCompRun ( gcCARMA, qa, impChem, expChem, nymd, nhms, & ! Fill the internal state with direct gas species from GMI ! Expectation is species are in VMR and needed in MMR for CARMA ! ----------- - if(trim(reg%sulfuric_acid_source) == 'full_field' .and. reg%NGAS > 0) then + if(reg%sulfuric_acid_source(1:10) == 'full_field' .and. reg%NGAS > 0) then do igas = 1, reg%NGAS n = nCARMAbegin + reg%NBIN*reg%NELEM - 1 + igas gasname = ESMF_UtilStringUpperCase(reg%gasname(igas)) @@ -1399,7 +1399,7 @@ SUBROUTINE CARMA_GridCompRun ( gcCARMA, qa, impChem, expChem, nymd, nhms, & ! Return the updated gas species to GMI from the internal state ! Expectation is species are in MMR and needed in VMR for GMI ! ----------- - if(trim(reg%sulfuric_acid_source) == 'full_field' .and. reg%NGAS > 0) then + if(reg%sulfuric_acid_source(1:10) == 'full_field' .and. reg%NGAS > 0) then do igas = 1, reg%NGAS n = nCARMAbegin + reg%NBIN*reg%NELEM - 1 + igas gasname = ESMF_UtilStringUpperCase(reg%gasname(igas)) diff --git a/CARMAchem_GridComp/CARMA_UtilMod.F90 b/CARMAchem_GridComp/CARMA_UtilMod.F90 index 9f21582c..3d4b3a04 100644 --- a/CARMAchem_GridComp/CARMA_UtilMod.F90 +++ b/CARMAchem_GridComp/CARMA_UtilMod.F90 @@ -685,7 +685,7 @@ SUBROUTINE CARMA_Emissions ( gcCARMA, qa, impChem, expChem, nymd, nhms, cdt, & do igas = 1, reg%NGAS n = n1 + reg%NELEM*reg%NBIN - 1 + igas gasname = ESMF_UtilStringUpperCase(trim(reg%gasname(igas))) - if(trim(reg%sulfuric_acid_source) == 'tendency' .and. gasname == 'H2SO4') then + if(reg%sulfuric_acid_source(1:8) == 'tendency' .and. gasname == 'H2SO4') then qa(n)%data3d = qa(n)%data3d + pso4 * dtime endif if( gasname == 'HNO3') then ! go to MMR diff --git a/CARMAchem_GridComp/CARMAchem_GridCompMod.F90 b/CARMAchem_GridComp/CARMAchem_GridCompMod.F90 index bf0c86c0..0480d56f 100644 --- a/CARMAchem_GridComp/CARMAchem_GridCompMod.F90 +++ b/CARMAchem_GridComp/CARMAchem_GridCompMod.F90 @@ -748,7 +748,7 @@ SUBROUTINE Initialize_ ( gc, import, export, clock, rc ) end if ! attach the aerosol optics method - call ESMF_MethodAdd(aero, label='aerosol_optics', userRoutine=aerosol_optics, __RC__) + call ESMF_MethodAdd(aero, label='run_aerosol_optics', userRoutine=run_aerosol_optics, __RC__) end if @@ -1730,7 +1730,7 @@ SUBROUTINE final_(ierr) END SUBROUTINE final_ -subroutine aerosol_optics(state, rc) +subroutine run_aerosol_optics(state, rc) implicit none @@ -1774,7 +1774,7 @@ subroutine aerosol_optics(state, rc) real :: x integer :: i, j, k - Iam = 'CARMA::aerosol_optics()' + Iam = 'CARMA::run_aerosol_optics()' ! Mie Table instance/index @@ -1930,7 +1930,7 @@ subroutine mie_(mie_table, aerosol, nb, offset, q, rh, ext, ssa, asy, rc) end subroutine mie_ - end subroutine aerosol_optics + end subroutine run_aerosol_optics diff --git a/CARMAchem_GridComp/CMakeLists.txt b/CARMAchem_GridComp/CMakeLists.txt index 62c57680..fa4113d3 100644 --- a/CARMAchem_GridComp/CMakeLists.txt +++ b/CARMAchem_GridComp/CMakeLists.txt @@ -12,7 +12,7 @@ foreach (dir ${src_directories}) list (APPEND srcs ${tmpsrcs}) endforeach() -set (dependencies Chem_Shared Chem_Base GMAO_mpeu esmf) +set (dependencies Chem_Shared Chem_Base GMAO_mpeu ESMF::ESMF) esma_add_library (${this} SRCS ${srcs} DEPENDENCIES ${dependencies}) target_include_directories (${this} PUBLIC $) diff --git a/CHANGELOG.md b/CHANGELOG.md index 635c16f8..f205b28a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,19 +7,60 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] - ### Added -Connectivity added between GOCART2G and HEMCO for anthropogenic OC, BC, SO2, SO4, and NH3 in GEOS_ChemGridComp.F90. These species are now added in HEMCOgocart2g* files with diurnal and day of week scaling implemented. -ExtData2G is used to persist anthropogenic emissions for the year 2019 after the available emissions data set ends. ### Removed ### Changed + +- The file path was changed for anthropogenic CO emissions that are used by achem. Note that the previous version of the emissions have an incorrect seasonal cycle. +- Update ESMF CMake target to `ESMF::ESMF` +- Overhauled the Lopez lightning scheme, and made it the default scheme; note that lightning is used by GMI for computing NOx emissions; PCHEM does not use lightning + ### Fixed -## [1.13.1] - 2023-03-02 +- Updated GAAS_Gridcomp_Extdata.yaml in AMIP/ to avoid the model to crash when GAAS is turned on and AMIP emissions chosen. + +### Deprecated + + +## [1.14.0] - 2024-06-21 + +### Added + +- Connectivity from GMI to ACHEM (4 fields), requires GMI v1.2.0 or later to run +- Slight improvement for lightning flash rate calculation (LOPEZ and MOIST schemes). See the option UsePreconCape in ChemEnv.rc . This involves new imports from MOIST: CAPE, BYNCY and INHB. **NOTE** THIS REQUIRES GEOSgcm_GridComp develop branch (as of 12/12/23). +- Added a flag for 'strict' child timing, intended to reduce the timing bias against child GC's that employ 'gather' calls. Such calls are occasionally necessary, but can cause timers to attribute excessive time to a child, time that is actually the synchronization lag time that would eventually be spent -somewhere- in the program, but which gets attributed to the child with a 'gather' or barrier call. The new flag is for timing tests only. + +### Changed + +- Update CI to use v2 orb + +### Fixed + +- Fixed CARMA to fix radiation callback +- Fixed code in CARMA to properly check whether GMI or GOCART are providing sulfur inputs +- Fixed CARMA/GOCART2G sulfate production tendency term +- Fix a bug in GAAS where it gets the VM (global instead of the correct current) +- Fix an issue in GAAS where the `aod_?` fields were not declared as `MAPL_RestartSkip` in the Registry file. + +## [1.13.1] - 2023-04-24 ### Added - Added CO2 connectivity in GEOS_ChemGridComp for GOCART-GEOS-Chem coupling +- Added a wrapper routine for the MAPL Solar Zenith Angle call, in Chem_Shared +- Added connectivity from GOCART2G aerosols to GMI chem + +### Removed + +- Removed the GMI routines which computed Solar Zenith Angle, in Chem_Shared; but in a later commit, this was added back temporarily, so that older versions of GMI and TR don't complain. + +- Removed parallel read of PChem species file. This parallel read was causing issues at NAS at large node count, so now we just do a read-on-root followed by a broadcast + +### Fixed + +- Fixed a bug that had prevented GMI running with HEMCO ## [1.13.0] - 2023-03-01 @@ -56,7 +97,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Instead of importing a set of QQK diagnostic fields for chemical loss of stOX, TR now imports a single field: stOX_loss -- For OPS configuration: removal of links, change of QFED paths from vNRT/ to v2.5r1-nrt/ +- For OPS configuration: removal of links, change of QFED paths from vNRT/ to v2.5r1-nrt/ - For AMIP configuration: update of QFED from v2.5r1 to v2.6r1 (most recent collection) - Moved to GitHub Actions for label enforcement - Update CircleCI to use Baselibs 7.7.0 @@ -104,7 +145,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updates to emissions from galactic cosmic rays in GMI - Minor improvement to Runtime_Registry module. -- Broke away the GMI contents from Chem_Registry.rc, into a separate file +- Broke away the GMI contents from Chem_Registry.rc, into a separate file ## [1.10.1] - 2022-08-30 @@ -160,7 +201,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix YAML typo in `GEOSachem_GridComp/GEOSachem_ExtData.yaml` -## [1.9.4] - 2022-05-31 +## [1.9.4] - 2022-05-31 ### Fixed diff --git a/CMakeLists.txt b/CMakeLists.txt index 3644f147..8fb71c0a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,7 @@ set (srcs esma_add_library (${this} SRCS ${srcs} SUBCOMPONENTS ${alldirs} - DEPENDENCIES MAPL Chem_Shared Chem_Base GOCART_GridComp GOCART2G_GridComp TR GMI StratChem esmf) + DEPENDENCIES MAPL Chem_Shared Chem_Base GOCART_GridComp GOCART2G_GridComp TR GMI StratChem ESMF::ESMF) install( FILES GEOS_ChemGridComp.rc ChemEnv_ExtData.rc ChemEnv.rc ChemEnv_ExtData.yaml diff --git a/ChemEnv.rc b/ChemEnv.rc index 7cc9407f..fe747e8f 100644 --- a/ChemEnv.rc +++ b/ChemEnv.rc @@ -1,7 +1,7 @@ #----------------------- # Settings for Lightning #----------------------- -flashSource: MOIST # MOIST (default), FIT, HEMCO, LOPEZ +flashSource: LOPEZ # MOIST, FIT, HEMCO, LOPEZ (default) # for FIT only: ratioGlobalFile: ExtData/g5chem/x/lightning/RatioGlobal.asc @@ -20,9 +20,11 @@ MOIST_flashFactor_resvec_REPLAY: 2.0 2.0 2.0 1.84 1.84 FIT_flashFactor_resvec_REPLAY: 1.0 1.0 1.0 1.0 1.0 1.0 # originally called 'alpha' -LOPEZ_flashFactor_resvec_CTM: 37.5 37.5 37.5 37.5 37.5 37.5 -LOPEZ_flashFactor_resvec_FREE: 37.5 37.5 37.5 37.5 37.5 37.5 -LOPEZ_flashFactor_resvec_REPLAY: 37.5 37.5 37.5 37.5 37.5 37.5 +# 10.29.24 Manyin provided c90 and c180, FREE and REPLAY +# Assume CTM is close to REPLAY +LOPEZ_flashFactor_resvec_CTM: 6705.50 6705.50 6705.50 6941.09 6941.09 6941.09 +LOPEZ_flashFactor_resvec_FREE: 5672.30 5672.30 5672.30 6495.07 6495.07 6495.07 +LOPEZ_flashFactor_resvec_REPLAY: 6705.50 6705.50 6705.50 6941.09 6941.09 6941.09 # originally called 'otdLisScale' # NOTE: testing (Nov2020) indicated c-90 value of 9.48e-3 might be better @@ -34,3 +36,5 @@ HEMCO_flashFactor_resvec_REPLAY: 0.6 0.355 0.1 2.095e-2 7.024e- lightNOampFactor: 1.07 numberNOperFlash: 1.50e+26 minDeepCloudTop: 7.0 + +usePreconCape: TRUE diff --git a/DNA_GridComp/CMakeLists.txt b/DNA_GridComp/CMakeLists.txt index 1cce6fff..a61b548c 100644 --- a/DNA_GridComp/CMakeLists.txt +++ b/DNA_GridComp/CMakeLists.txt @@ -4,7 +4,7 @@ set (srcs DNA_GridCompMod.F90 ) -esma_add_library (${this} SRCS ${srcs} DEPENDENCIES MAPL esmf NetCDF::NetCDF_Fortran) +esma_add_library (${this} SRCS ${srcs} DEPENDENCIES MAPL ESMF::ESMF NetCDF::NetCDF_Fortran) target_compile_definitions (${this} PRIVATE MAPL_MODE GEOS5) set (resource_files diff --git a/GAAS_GridComp/AMIP/GAAS_GridComp_ExtData.yaml b/GAAS_GridComp/AMIP/GAAS_GridComp_ExtData.yaml index 8996379d..4afa1c62 100644 --- a/GAAS_GridComp/AMIP/GAAS_GridComp_ExtData.yaml +++ b/GAAS_GridComp/AMIP/GAAS_GridComp_ExtData.yaml @@ -1,29 +1,33 @@ Collections: - GAAS_d5124_m2_jan10.aod_a.sfc.%y4%m2%d2_%h2%n2z.nc4: - template: /discover/nobackup/projects/gmao/merra2/data/chem/d5124_m2_jan10/Y%y4/M%m2/d5124_m2_jan10.aod_a.sfc.%y4%m2%d2_%h2%n2z.nc4 + aod_a.sfc.%y4%m2%d2_%h2%n2z.nc4: + template: das.aod_a.sfc.%y4%m2%d2_%h2%n2z.nc4 freq: PT3H - GAAS_d5124_m2_jan10.aod_f.sfc.%y4%m2%d2_%h2%n2z.nc4: - template: /discover/nobackup/projects/gmao/merra2/data/chem/d5124_m2_jan10/Y%y4/M%m2/d5124_m2_jan10.aod_f.sfc.%y4%m2%d2_%h2%n2z.nc4 + aod_f.sfc.%y4%m2%d2_%h2%n2z.nc4: + template: das.aod_f.sfc.%y4%m2%d2_%h2%n2z.nc4 freq: PT3H - GAAS_d5124_m2_jan10.aod_k.sfc.%y4%m2%d2_%h2%n2z.nc4: - template: /discover/nobackup/projects/gmao/merra2/data/chem/d5124_m2_jan10/Y%y4/M%m2/d5124_m2_jan10.aod_k.sfc.%y4%m2%d2_%h2%n2z.nc4 + aod_k.sfc.%y4%m2%d2_%h2%n2z.nc4: + template: das.aod_k.sfc.%y4%m2%d2_%h2%n2z.nc4 freq: PT3H Samplings: GAAS_sample_0: - time_interpolation: False + update_offset: PT450S + exact: True Exports: aod_a: - collection: GAAS_d5124_m2_jan10.aod_a.sfc.%y4%m2%d2_%h2%n2z.nc4 + collection: aod_a.sfc.%y4%m2%d2_%h2%n2z.nc4 sample: GAAS_sample_0 variable: AOD + fail_on_missing_file: false aod_f: - collection: GAAS_d5124_m2_jan10.aod_f.sfc.%y4%m2%d2_%h2%n2z.nc4 + collection: aod_f.sfc.%y4%m2%d2_%h2%n2z.nc4 sample: GAAS_sample_0 variable: AOD + fail_on_missing_file: false aod_k: - collection: GAAS_d5124_m2_jan10.aod_k.sfc.%y4%m2%d2_%h2%n2z.nc4 + collection: aod_k.sfc.%y4%m2%d2_%h2%n2z.nc4 sample: GAAS_sample_0 variable: AOD + fail_on_missing_file: false diff --git a/GAAS_GridComp/GAAS_Registry.rc b/GAAS_GridComp/GAAS_Registry.rc index 33c24af6..28efd95b 100644 --- a/GAAS_GridComp/GAAS_Registry.rc +++ b/GAAS_GridComp/GAAS_Registry.rc @@ -12,23 +12,23 @@ COMP_NAME: GAAS # Only change the Registry version when major structural changes # occurs, not changes in content # -------------------------------------------------------------- - MAPL_REGISTRY_VERSION: 1.00 + MAPL_REGISTRY_VERSION: 1.00 # ------------ # Import State # ------------ - -# ---------|------------|-----|---|----|---|---|-----|------|-------------------------- -# Short | | | V |Item|Intervl| Sub | Def | Long -# Name | Units | Dim |Loc|Type| R | A |Tiles| ault | Name -# ---------|------------|-----|---|----|---|---|-----|------|-------------------------- - DELP | Pa | xyz | C | | | | | | Pressure Thickness - RH2 | 1 | xyz | C | | | | | | Relative Humidity - PLE | Pa | xyz | E | | | | | | Air Pressure - aod_a | 1 | xy | C | | | | | | AOD - aod_f | 1 | xy | C | | | | | | AOD - aod_k | 1 | xy | C | | | | | | AOD + +# ---------|------------|-----|---|----|---|---|-----|------|-----|-------------------------- +# Short | | | V |Item|Intervl| Sub | Def | No | Long +# Name | Units | Dim |Loc|Type| R | A |Tiles| ault | Rst | Name +# ---------|------------|-----|---|----|---|---|-----|------|-----|-------------------------- + DELP | Pa | xyz | C | | | | | | | Pressure Thickness + RH2 | 1 | xyz | C | | | | | | | Relative Humidity + PLE | Pa | xyz | E | | | | | | | Air Pressure + aod_a | 1 | xy | C | | | | | | x | AOD + aod_f | 1 | xy | C | | | | | | x | AOD + aod_k | 1 | xy | C | | | | | | x | AOD # ---------|------------|-----|---|----|---|---|-----|------|-------------------------- diff --git a/GAAS_GridComp/LDE_Mod.F90 b/GAAS_GridComp/LDE_Mod.F90 index e5d7f323..fd15f504 100644 --- a/GAAS_GridComp/LDE_Mod.F90 +++ b/GAAS_GridComp/LDE_Mod.F90 @@ -130,7 +130,7 @@ subroutine LDE_Create ( self, CF, Grid, rc ) ! Get VM for later ! ---------------- - call ESMF_VMGetGlobal(self%VM,__RC__) + call ESMF_VMGetCurrent(self%VM,__RC__) ! Set Ensemble indices on root PE ! ------------------------------- diff --git a/GEOSCHEMchem_GridComp/CMakeLists.txt b/GEOSCHEMchem_GridComp/CMakeLists.txt index 2be22297..d0edeeca 100644 --- a/GEOSCHEMchem_GridComp/CMakeLists.txt +++ b/GEOSCHEMchem_GridComp/CMakeLists.txt @@ -17,7 +17,7 @@ set (src_directories ${geos_chem_dir}/KPP/fullchem ${geos_chem_dir}/GeosCore ${geos_chem_dir}/Interfaces/GCHP - ${geos_chem_dir}/Interfaces/GEOS + ${geos_chem_dir}/Interfaces/GEOS ${geos_chem_dir}/ObsPack ) include_directories (${geos_chem_dir}/Headers) @@ -77,7 +77,7 @@ endif () esma_add_library (${this} SRCS ${srcs} DEPENDENCIES MAPL MAPL_cfio_r4 Chem_Base Chem_Shared HEMCO - OpenMP::OpenMP_Fortran esmf NetCDF::NetCDF_Fortran + OpenMP::OpenMP_Fortran ESMF::ESMF NetCDF::NetCDF_Fortran ) target_compile_definitions(${this} PRIVATE diff --git a/GEOS_ChemEnvGridComp.F90 b/GEOS_ChemEnvGridComp.F90 index 6369ed78..a97f48ba 100644 --- a/GEOS_ChemEnvGridComp.F90 +++ b/GEOS_ChemEnvGridComp.F90 @@ -49,6 +49,7 @@ module GEOS_ChemEnvGridCompMod real :: FIT_flashFactor real :: HEMCO_flashFactor real :: LOPEZ_flashFactor + logical :: usePreconCape ! use CAPE, INHB and BYNCY from MOIST ! May change during the course of the run: integer :: year_for_ratio = 0 @@ -250,7 +251,7 @@ subroutine SetServices ( GC, RC ) call MAPL_AddImportSpec(GC, & SHORT_NAME = 'PFI_CN', & - LONG_NAME = 'ice_convective_precipitation', & + LONG_NAME = '3D_flux_of_ice_convective_precipitation', & UNITS = 'kg m-2 s-1', & DIMS = MAPL_DimsHorzVert, & VLOCATION = MAPL_VLocationEdge, __RC__ ) @@ -369,6 +370,48 @@ subroutine SetServices ( GC, RC ) DIMS = MAPL_DimsHorzOnly, & VLOCATION = MAPL_VLocationNone, __RC__) + call MAPL_AddImportSpec(GC, & + SHORT_NAME ='BYNCY', & + LONG_NAME ='buoyancy_of surface_parcel', & + UNITS ='m s-2', & + RESTART = MAPL_RestartSkip, & + DIMS = MAPL_DimsHorzVert, & + VLOCATION = MAPL_VLocationCenter, __RC__) + + call MAPL_AddImportSpec(GC, & + SHORT_NAME ='CAPE', & + LONG_NAME ='cape_for_surface_parcel', & + UNITS ='J kg-1', & + RESTART = MAPL_RestartSkip, & + DIMS = MAPL_DimsHorzOnly, & + VLOCATION = MAPL_VLocationNone, __RC__) + + call MAPL_AddImportSpec(GC, & + SHORT_NAME ='INHB', & + LONG_NAME ='inhibition_for_surface_parcel', & + UNITS ='J kg-1', & + RESTART = MAPL_RestartSkip, & + DIMS = MAPL_DimsHorzOnly, & + VLOCATION = MAPL_VLocationNone, __RC__) + + + call MAPL_AddImportSpec(GC, & + SHORT_NAME='ZLCL', & + LONG_NAME ='lifting_condensation_level', & + UNITS ='m' , & + DIMS = MAPL_DimsHorzOnly, & + VLOCATION = MAPL_VLocationNone, RC=STATUS ) + VERIFY_(STATUS) + + call MAPL_AddImportSpec(GC, & + SHORT_NAME='ZLFC', & + LONG_NAME ='level_of_free_convection', & + UNITS ='m' , & + DIMS = MAPL_DimsHorzOnly, & + VLOCATION = MAPL_VLocationNone, RC=STATUS ) + VERIFY_(STATUS) + + ! !EXPORT STATE: @@ -734,13 +777,16 @@ subroutine Initialize_ ( GC, impChem, expChem, clock, RC ) numberNOperFlash, & MOIST_flashFactor, FIT_flashFactor, & HEMCO_flashFactor, LOPEZ_flashFactor, & + usePreconCape, & __RC__ ) IF(MAPL_AM_I_ROOT()) THEN - if ( flash_source_enum == FLASH_SOURCE_MOIST ) PRINT*,'MOIST_flashFactor is ',MOIST_flashFactor - if ( flash_source_enum == FLASH_SOURCE_FIT ) PRINT*, ' FIT_flashFactor is ', FIT_flashFactor - if ( flash_source_enum == FLASH_SOURCE_HEMCO ) PRINT*,'HEMCO_flashFactor is ',HEMCO_flashFactor - if ( flash_source_enum == FLASH_SOURCE_LOPEZ ) PRINT*,'LOPEZ_flashFactor is ',LOPEZ_flashFactor + if ( flash_source_enum == FLASH_SOURCE_MOIST ) PRINT*,'MOIST_flashFactor is ', MOIST_flashFactor + if ( flash_source_enum == FLASH_SOURCE_FIT ) PRINT*,' FIT_flashFactor is ', FIT_flashFactor + if ( flash_source_enum == FLASH_SOURCE_HEMCO ) PRINT*,'HEMCO_flashFactor is ', HEMCO_flashFactor + if ( flash_source_enum == FLASH_SOURCE_LOPEZ ) PRINT*,'LOPEZ_flashFactor is ', LOPEZ_flashFactor + + PRINT*,'usePreconCape = ', usePreconCape ENDIF RETURN_(ESMF_SUCCESS) @@ -797,6 +843,9 @@ subroutine Run1 ( GC, IMPORT, EXPORT, CLOCK, RC ) real, pointer, dimension(:,:) :: LWI => null() real, pointer, dimension(:,:) :: PBLH => null() + real, pointer, dimension(:,:) :: ZLFC => null() + real, pointer, dimension(:,:) :: ZLCL => null() + real, pointer, dimension(:,:) :: TS => null() real, pointer, dimension(:,:) :: FROCEAN => null() real, pointer, dimension(:,:) :: FRLAND => null() @@ -807,6 +856,10 @@ subroutine Run1 ( GC, IMPORT, EXPORT, CLOCK, RC ) real, pointer, dimension(:,:,:) :: PFI_CN => null() real, pointer, dimension(:,:,:) :: CNV_QC => null() + real, pointer, dimension(:,:) :: CAPE_PRECON => null() + real, pointer, dimension(:,:) :: INHB_PRECON => null() + real, pointer, dimension(:,:,:) :: BYNCY_PRECON => null() + ! Exports real, pointer, dimension(:,:,:) :: delp => null() real, pointer, dimension(:,:) :: LFR => null() @@ -904,11 +957,11 @@ subroutine Run1 ( GC, IMPORT, EXPORT, CLOCK, RC ) call MAPL_GetPointer ( IMPORT, MIDLAT_ADJ, 'MIDLAT_ADJ', __RC__ ) end if - call MAPL_GetPointer ( IMPORT, CNV_MFC, 'CNV_MFC', __RC__ ) - call MAPL_GetPointer ( IMPORT, CNV_MFD, 'CNV_MFD', __RC__ ) - call MAPL_GetPointer ( IMPORT, CN_PRCP, 'CN_PRCP', __RC__ ) - call MAPL_GetPointer ( IMPORT, PHIS, 'PHIS', __RC__ ) - call MAPL_GetPointer ( IMPORT, PFI_CN, 'PFI_CN', ALLOC=.TRUE., __RC__ ) ! ?? + call MAPL_GetPointer ( IMPORT, CNV_MFC, 'CNV_MFC', __RC__ ) + call MAPL_GetPointer ( IMPORT, CNV_MFD, 'CNV_MFD', __RC__ ) + call MAPL_GetPointer ( IMPORT, CN_PRCP, 'CN_PRCP', __RC__ ) + call MAPL_GetPointer ( IMPORT, PHIS, 'PHIS', __RC__ ) + call MAPL_GetPointer ( IMPORT, PFI_CN, 'PFI_CN', __RC__ ) call MAPL_GetPointer ( IMPORT, T, 'T', __RC__ ) call MAPL_GetPointer ( IMPORT, TH, 'TH', __RC__ ) @@ -922,6 +975,14 @@ subroutine Run1 ( GC, IMPORT, EXPORT, CLOCK, RC ) call MAPL_GetPointer ( IMPORT, CNV_QC, 'CNV_QC', __RC__ ) call MAPL_GetPointer ( IMPORT, cellArea, 'AREA', __RC__ ) + call MAPL_GetPointer ( IMPORT, CAPE_PRECON, 'CAPE', __RC__ ) + call MAPL_GetPointer ( IMPORT, INHB_PRECON, 'INHB', __RC__ ) + call MAPL_GetPointer ( IMPORT, BYNCY_PRECON, 'BYNCY', __RC__ ) + + call MAPL_GetPointer ( IMPORT, ZLFC, 'ZLFC', __RC__ ) + call MAPL_GetPointer ( IMPORT, ZLCL, 'ZLCL', __RC__ ) + + BYNCY(:,:,:) = real(0) CAPE(:,:) = real(0) LFR(:,:) = real(0) @@ -949,7 +1010,8 @@ subroutine Run1 ( GC, IMPORT, EXPORT, CLOCK, RC ) TS, CNV_MFC, CNV_QC, T, TH, PFI_CN, PLE, Q, ZLE, & minDeepCloudTop, lightNOampFactor, numberNOperFlash, & MOIST_flashFactor, FIT_flashFactor, HEMCO_flashFactor, LOPEZ_flashFactor, & - CNV_MFD, CAPE, BYNCY, LFR, LIGHT_NO_PROD, PHIS, & + CNV_MFD, usePreconCape, CAPE_PRECON, INHB_PRECON, BYNCY_PRECON, & + CAPE, BYNCY, ZLFC, ZLCL, LFR, LIGHT_NO_PROD, PHIS, & __RC__) ! call pmaxmin('LFR', LFR, flashRateMin, flashRateMax, nc, 1, 1.) diff --git a/GEOS_ChemGridComp.F90 b/GEOS_ChemGridComp.F90 index cd8879a0..0b0d9292 100644 --- a/GEOS_ChemGridComp.F90 +++ b/GEOS_ChemGridComp.F90 @@ -66,6 +66,8 @@ module GEOS_ChemGridCompMod LOGICAL :: enable_TR LOGICAL :: enable_DNA LOGICAL :: enable_HEMCO + LOGICAL :: strict_child_timing ! Call a barrier before and after each child is run + ! Only use this to test timings, not operationally INTEGER :: AERO_PROVIDER INTEGER :: RATS_PROVIDER ! WARNING: May be multiple RATS_PROVIDERs END TYPE GEOS_ChemGridComp @@ -130,7 +132,8 @@ subroutine SetServices ( GC, RC ) ! ErrLog Variables __Iam__('SetServices') ! NOTE: this macro declares STATUS - ! ALSO: Never set Iam = TRIM(Iam) // suffix + ! ALSO: Never set Iam to a string containing Iam + ! in any routine that is run more than once ! because Iam is a SAVED varaible character(len=ESMF_MAXSTR) :: COMP_NAME @@ -230,6 +233,8 @@ subroutine SetServices ( GC, RC ) call ESMF_ConfigGetAttribute(myCF, myState%enable_DNA, Default=.FALSE., Label="ENABLE_DNA:", __RC__ ) call ESMF_ConfigGetAttribute(myCF, myState%enable_HEMCO, Default=.FALSE., Label="ENABLE_HEMCO:", __RC__ ) + call ESMF_ConfigGetAttribute(myCF, myState%strict_child_timing, Default=.FALSE., Label="strict_child_timing:", __RC__ ) + !ALT: valgrind flagged a memory leak. myState%CF => myCF ! save for later call ESMF_ConfigDestroy(myCF, __RC__) @@ -243,23 +248,23 @@ subroutine SetServices ( GC, RC ) ! ----------------------------------------------------------------- CHEMENV = MAPL_AddChild(GC, NAME='CHEMENV', SS=ChemEnv_SetServices, __RC__) - if ( myState%enable_HEMCO) HEMCO = MAPL_AddChild(GC, NAME= 'HEMCO', SS=HEMCO_SetServices, __RC__) - if ( myState%enable_PCHEM) PCHEM = MAPL_AddChild(GC, NAME= 'PCHEM', SS=PChem_SetServices, __RC__) - if ( myState%enable_ACHEM) ACHEM = MAPL_AddChild(GC, NAME= 'ACHEM', SS=AChem_SetServices, __RC__) - if ( myState%enable_GOCART) GOCART = MAPL_AddChild(GC, NAME= 'GOCART', SS=GOCART_SetServices, __RC__) + if (myState%enable_HEMCO ) HEMCO = MAPL_AddChild(GC, NAME= 'HEMCO', SS=HEMCO_SetServices, __RC__) + if (myState%enable_PCHEM ) PCHEM = MAPL_AddChild(GC, NAME= 'PCHEM', SS=PChem_SetServices, __RC__) + if (myState%enable_ACHEM ) ACHEM = MAPL_AddChild(GC, NAME= 'ACHEM', SS=AChem_SetServices, __RC__) + if (myState%enable_GOCART ) GOCART = MAPL_AddChild(GC, NAME= 'GOCART', SS=GOCART_SetServices, __RC__) if (myState%enable_GOCARTdata) GOCARTdata = MAPL_AddChild(GC, NAME= 'GOCART.data', SS=GOCART_SetServices, __RC__) - if ( myState%enable_GOCART2G) GOCART2G = MAPL_AddChild(GC, NAME= 'GOCART2G', SS=GOCART2G_SetServices, __RC__) - if ( myState%enable_GAAS) GAAS = MAPL_AddChild(GC, NAME= 'GAAS', SS=GAAS_SetServices, __RC__) - if ( myState%enable_H2O) H2O = MAPL_AddChild(GC, NAME= 'H2O', SS=H2O_SetServices, __RC__) - if ( myState%enable_STRATCHEM) STRATCHEM = MAPL_AddChild(GC, NAME= 'STRATCHEM', SS=StratChem_SetServices, __RC__) - if ( myState%enable_GMICHEM) GMICHEM = MAPL_AddChild(GC, NAME= 'GMICHEM', SS=GMI_SetServices, __RC__) - if ( myState%enable_CARMA) CARMA = MAPL_AddChild(GC, NAME= 'CARMA', SS=CARMA_SetServices, __RC__) - if ( myState%enable_GEOSCHEM) GEOSCHEM = MAPL_AddChild(GC, NAME='GEOSCHEMCHEM', SS=GCChem_SetServices, __RC__) - if ( myState%enable_MATRIX) MATRIX = MAPL_AddChild(GC, NAME= 'MATRIX', SS=MATRIX_SetServices, __RC__) - if ( myState%enable_MAM) MAM = MAPL_AddChild(GC, NAME= 'MAM', SS=MAM_SetServices, __RC__) - if ( myState%enable_MAMdata) MAMdata = MAPL_AddChild(GC, NAME= 'MAM.data', SS=MAM_SetServices, __RC__) - if ( myState%enable_TR) TR = MAPL_AddChild(GC, NAME= 'TR', SS=TR_SetServices, __RC__) - if ( myState%enable_DNA) DNA = MAPL_AddChild(GC, NAME= 'DNA', SS=DNA_SetServices, __RC__) + if (myState%enable_GOCART2G ) GOCART2G = MAPL_AddChild(GC, NAME= 'GOCART2G', SS=GOCART2G_SetServices, __RC__) + if (myState%enable_GAAS ) GAAS = MAPL_AddChild(GC, NAME= 'GAAS', SS=GAAS_SetServices, __RC__) + if (myState%enable_H2O ) H2O = MAPL_AddChild(GC, NAME= 'H2O', SS=H2O_SetServices, __RC__) + if (myState%enable_STRATCHEM ) STRATCHEM = MAPL_AddChild(GC, NAME= 'STRATCHEM', SS=StratChem_SetServices, __RC__) + if (myState%enable_GMICHEM ) GMICHEM = MAPL_AddChild(GC, NAME= 'GMICHEM', SS=GMI_SetServices, __RC__) + if (myState%enable_CARMA ) CARMA = MAPL_AddChild(GC, NAME= 'CARMA', SS=CARMA_SetServices, __RC__) + if (myState%enable_GEOSCHEM ) GEOSCHEM = MAPL_AddChild(GC, NAME='GEOSCHEMCHEM', SS=GCChem_SetServices, __RC__) + if (myState%enable_MATRIX ) MATRIX = MAPL_AddChild(GC, NAME= 'MATRIX', SS=MATRIX_SetServices, __RC__) + if (myState%enable_MAM ) MAM = MAPL_AddChild(GC, NAME= 'MAM', SS=MAM_SetServices, __RC__) + if (myState%enable_MAMdata ) MAMdata = MAPL_AddChild(GC, NAME= 'MAM.data', SS=MAM_SetServices, __RC__) + if (myState%enable_TR ) TR = MAPL_AddChild(GC, NAME= 'TR', SS=TR_SetServices, __RC__) + if (myState%enable_DNA ) DNA = MAPL_AddChild(GC, NAME= 'DNA', SS=DNA_SetServices, __RC__) ! A container for the friendly tracers @@ -320,6 +325,7 @@ subroutine SetServices ( GC, RC ) IF(MAPL_AM_I_ROOT()) THEN PRINT *," " + PRINT *, TRIM(Iam)//": strict_child_timing =", myState%strict_child_timing PRINT *, TRIM(Iam)//": RATs Provider List" DO i = 1, numRATs PRINT *," "//TRIM(speciesName(i))//": "//TRIM(RATsProviderName(i)) @@ -468,7 +474,7 @@ subroutine SetServices ( GC, RC ) if(myState%enable_GOCART2G) then CALL MAPL_AddConnectivity ( GC, & - SRC_NAME = (/'PSO4TOT'/), & + SRC_NAME = (/'PSO4'/), & DST_NAME = (/'CARMA_PSO4TOT'/), & DST_ID=CARMA, SRC_ID=GOCART2G, __RC__) endif @@ -604,6 +610,13 @@ subroutine SetServices ( GC, RC ) DST_NAME = (/'O3P ', 'OHSTRAT ', 'O3 ', 'OCS_JRATE'/), & DST_ID = ACHEM, SRC_ID = STRATCHEM, __RC__ ) ENDIF + + IF(myState%enable_GMICHEM .AND. myState%enable_ACHEM) then + CALL MAPL_AddConnectivity ( GC, & + SRC_NAME = (/'O ', 'OH ', 'OX ', 'OCS_JRATE'/), & + DST_NAME = (/'O3P ', 'OHSTRAT ', 'O3 ', 'OCS_JRATE'/), & + DST_ID = ACHEM, SRC_ID = GMICHEM, __RC__ ) + ENDIF ! GOCART <=> ACHEM (OCS CHEMISTRY) @@ -650,6 +663,18 @@ subroutine SetServices ( GC, RC ) END IF +! GOCART2G <=> GMICHEM coupling ... +! --------------------------------- + IF(myState%enable_GMICHEM .AND. TRIM(providerName) == "GOCART2G") THEN + + IF(myState%enable_GOCART2G) & + + CALL MAPL_AddConnectivity ( GC, & + SHORT_NAME = (/'AERO'/), & + DST_ID = GMICHEM, SRC_ID = GOCART2G, __RC__ ) + + END IF + ! GOCART.data <=> GMICHEM coupling ... ! ------------------------------------ IF(myState%enable_GMICHEM .AND. TRIM(providerName) == "GOCART.data") THEN @@ -866,8 +891,8 @@ subroutine SetServices ( GC, RC ) END IF ! make sure we don't have inconsistent MEGAN flags - IF ( doMEGANviaHEMCO .eqv. .TRUE. .AND. & - doMEGANemission .eqv. .FALSE. ) THEN + IF ( ( doMEGANviaHEMCO .eqv. .TRUE. ) .AND. & + ( doMEGANemission .eqv. .FALSE. ) ) THEN PRINT*,'Inconsistent GMI flags: doMEGANviaHEMCO==T, doMEGANemission==F' STATUS=99 VERIFY_(STATUS) @@ -1076,6 +1101,9 @@ subroutine Run1 ( GC, IMPORT, EXPORT, CLOCK, RC ) integer :: userRC character(len=ESMF_MAXSTR) :: CHILD_NAME real, pointer :: th(:,:,:) => NULL() + type (GEOS_ChemGridComp), pointer :: myState ! private, that is + type (GEOS_ChemGridComp_Wrap) :: wrap + type (ESMF_VM) :: VM !============================================================================= @@ -1090,6 +1118,12 @@ subroutine Run1 ( GC, IMPORT, EXPORT, CLOCK, RC ) call MAPL_Get(MAPL, RUNALARM = ALARM, RC=STATUS ) VERIFY_(STATUS) +! Get my internal state +! --------------------- + call ESMF_UserCompGetInternalState(GC, 'GEOSchem_GridComp_State', WRAP, STATUS) + VERIFY_(STATUS) + myState => wrap%ptr + ! Start timers ! ------------ call MAPL_TimerOn( MAPL, "TOTAL") @@ -1139,6 +1173,12 @@ subroutine Run1 ( GC, IMPORT, EXPORT, CLOCK, RC ) ! exists. Also updated MAPL_Get to accept the output ! argument NumRunPhases (ckeller, 09/10/2014) ! -------------------------------------------------------- + + IF ( myState%strict_child_timing ) THEN + call ESMF_VMGetCurrent ( VM=VM, __RC__ ) + call ESMF_VMBarrier(VM, __RC__ ) + END IF + do I=1,NCHLD call ESMF_GridCompGet( GCS(I), NAME=CHILD_NAME, __RC__ ) call MAPL_GetObjectFromGC(GCS(I), CHLD, __RC__ ) @@ -1152,7 +1192,12 @@ subroutine Run1 ( GC, IMPORT, EXPORT, CLOCK, RC ) phase = IPHASE, & userRC = userRC, & __RC__ ) - _ASSERT(userRC==ESMF_SUCCESS,'needs informative message') + _ASSERT(userRC==ESMF_SUCCESS,'Failed running the CHEM child '//trim(CHILD_NAME)) + + IF ( myState%strict_child_timing ) THEN + call ESMF_VMBarrier(VM, __RC__ ) + END IF + call MAPL_TimerOff(MAPL,trim(CHILD_NAME)) endif enddo !I @@ -1224,6 +1269,9 @@ subroutine Run2 ( GC, IMPORT, EXPORT, CLOCK, RC ) integer :: NPHASE, IPHASE integer :: userRC character(len=ESMF_MAXSTR) :: CHILD_NAME + type (GEOS_ChemGridComp), pointer :: myState ! private, that is + type (GEOS_ChemGridComp_Wrap) :: wrap + type (ESMF_VM) :: VM !------------------------------------------------------------------- ! Begin... @@ -1235,6 +1283,12 @@ subroutine Run2 ( GC, IMPORT, EXPORT, CLOCK, RC ) VERIFY_(STATUS) call MAPL_Get(MAPL, RUNALARM = ALARM, __RC__ ) +! Get my internal state +! --------------------- + call ESMF_UserCompGetInternalState(GC, 'GEOSchem_GridComp_State', WRAP, STATUS) + VERIFY_(STATUS) + myState => wrap%ptr + ! Start timers ! ------------ call MAPL_TimerOn( MAPL, "TOTAL") @@ -1270,6 +1324,12 @@ subroutine Run2 ( GC, IMPORT, EXPORT, CLOCK, RC ) ! do for every child: get child state, determine number of ! run phases and phase to call, execute. ! -------------------------------------------------------- + + IF ( myState%strict_child_timing ) THEN + call ESMF_VMGetCurrent ( VM=VM, __RC__ ) + call ESMF_VMBarrier(VM, __RC__ ) + END IF + do I=1,NCHLD call MAPL_GetObjectFromGC(GCS(I), CHLD, __RC__ ) call ESMF_GridCompGet( GCS(I), NAME=CHILD_NAME, __RC__ ) @@ -1288,7 +1348,12 @@ subroutine Run2 ( GC, IMPORT, EXPORT, CLOCK, RC ) phase = IPHASE, & userRC = userRC, & __RC__ ) - _ASSERT(userRC==ESMF_SUCCESS,'needs informative message') + _ASSERT(userRC==ESMF_SUCCESS,'Failed running the CHEM child '//trim(CHILD_NAME)) + + IF ( myState%strict_child_timing ) THEN + call ESMF_VMBarrier(VM, __RC__ ) + END IF + call MAPL_TimerOff(MAPL,trim(CHILD_NAME)) enddo !I endif diff --git a/GEOS_ChemGridComp.rc b/GEOS_ChemGridComp.rc index d60621ba..a380266a 100644 --- a/GEOS_ChemGridComp.rc +++ b/GEOS_ChemGridComp.rc @@ -24,3 +24,7 @@ ENABLE_TR: .TRUE. ENABLE_DNA: .FALSE. ENABLE_HEMCO: .TRUE. + +# Use only for diagnostic timing tests: +# -------------------------------------------------- + strict_child_timing: .FALSE. diff --git a/GEOSachem_GridComp/AMIP.20C/GEOSachem_ExtData.rc b/GEOSachem_GridComp/AMIP.20C/GEOSachem_ExtData.rc index ff899c1d..64a04519 100644 --- a/GEOSachem_GridComp/AMIP.20C/GEOSachem_ExtData.rc +++ b/GEOSachem_GridComp/AMIP.20C/GEOSachem_ExtData.rc @@ -44,7 +44,7 @@ SOAG_EMIS 'm-2 s-1' Y N 0 # CO emissions for VOC CO_BIOMASS_VOC 'kg m-2 s-1' N Y %y4-%m2-%d2t12:00:00Z none none biomass ExtData/chemistry/HFED/v1.0/Y%y4/hfed.emis_co.x576_y361_t14.%y4.nc4 CO_BF_VOC 'kg m-2 s-1' Y Y %y4-%m2-%d2t12:00:00Z none none emcobf /dev/null -CO_FS_VOC 'kg m-2 s-1' N Y %y4-%m2-%d2t12:00:00Z none none co ExtData/chemistry/CEDS/v2021-04-21/sfc/CO-em-anthro_CMIP_CEDS_gn.x2304_y1441_t12.%y4.nc4 +CO_FS_VOC 'kg m-2 s-1' N Y %y4-%m2-%d2t12:00:00Z none none co ExtData/chemistry/CEDS/v2021-04-21-revised/sfc/CO-em-anthro_CMIP_CEDS_gn.x2304_y1441_t12.%y4.nc4 # Photolysis rates #jH2O2 's-1' Y N 0 none none jH2O2 ExtData/chemistry/GMI/v0.0.0/L72/Y2008/gmi_jh2o2.x144_y91_z72.2008%m2.nc4 diff --git a/GEOSachem_GridComp/AMIP/GEOSachem_ExtData.rc b/GEOSachem_GridComp/AMIP/GEOSachem_ExtData.rc index c82e961b..3fa2e7d3 100644 --- a/GEOSachem_GridComp/AMIP/GEOSachem_ExtData.rc +++ b/GEOSachem_GridComp/AMIP/GEOSachem_ExtData.rc @@ -44,7 +44,7 @@ SOAG_EMIS 'm-2 s-1' Y N 0 # CO emissions for VOC CO_BIOMASS_VOC 'kg m-2 s-1' N Y %y4-%m2-%d2t12:00:00Z none none biomass ExtData/chemistry/QFED/v2.6r1/sfc/0.1/Y%y4/M%m2/qfed2.emis_co.061.%y4%m2%d2.nc4 CO_BF_VOC 'kg m-2 s-1' Y Y %y4-%m2-%d2t12:00:00Z none none emcobf /dev/null -CO_FS_VOC 'kg m-2 s-1' N Y %y4-%m2-%d2t12:00:00Z none none co ExtData/chemistry/CEDS/v2021-04-21/sfc/CO-em-anthro_CMIP_CEDS_gn.x2304_y1441_t12.%y4.nc4 +CO_FS_VOC 'kg m-2 s-1' N Y %y4-%m2-%d2t12:00:00Z none none co ExtData/chemistry/CEDS/v2021-04-21-revised/sfc/CO-em-anthro_CMIP_CEDS_gn.x2304_y1441_t12.%y4.nc4 # Photolysis rates #jH2O2 's-1' Y N 0 none none jH2O2 ExtData/chemistry/GMI/v0.0.0/L72/Y2008/gmi_jh2o2.x144_y91_z72.2008%m2.nc4 diff --git a/GEOSachem_GridComp/AMIP/GEOSachem_ExtData.yaml b/GEOSachem_GridComp/AMIP/GEOSachem_ExtData.yaml index eec6aa2d..e088964b 100644 --- a/GEOSachem_GridComp/AMIP/GEOSachem_ExtData.yaml +++ b/GEOSachem_GridComp/AMIP/GEOSachem_ExtData.yaml @@ -1,6 +1,6 @@ Collections: GEOSachem_CO-em-anthro_CMIP_CEDS_gn.x2304_y1441_t12.%y4.nc4: - template: ExtData/chemistry/CEDS/v2021-04-21/sfc/CO-em-anthro_CMIP_CEDS_gn.x2304_y1441_t12.%y4.nc4 + template: ExtData/chemistry/CEDS/v2021-04-21-revised/sfc/CO-em-anthro_CMIP_CEDS_gn.x2304_y1441_t12.%y4.nc4 GEOSachem_DMSclim_sfcconcentration.x360_y181_t12.Lana2011.nc4: template: ExtData/chemistry/Lana/v2011/DMSclim_sfcconcentration.x360_y181_t12.Lana2011.nc4 GEOSachem_GEIA.emis_NH3.ocean.x576_y361.t12.20080715_12z.nc4: diff --git a/GEOSachem_GridComp/CMakeLists.txt b/GEOSachem_GridComp/CMakeLists.txt index d23106e8..9fccc9cb 100644 --- a/GEOSachem_GridComp/CMakeLists.txt +++ b/GEOSachem_GridComp/CMakeLists.txt @@ -27,7 +27,7 @@ set (srcs esma_add_library ( ${this} SRCS ${srcs} - DEPENDENCIES Chem_Shared MAPL GMAO_mpeu esmf NetCDF::NetCDF_Fortran + DEPENDENCIES Chem_Shared MAPL GMAO_mpeu ESMF::ESMF NetCDF::NetCDF_Fortran ) target_compile_definitions (${this} PRIVATE MAPL_MODE GEOS5) set_target_properties (${this} PROPERTIES COMPILE_FLAGS ${PP}) diff --git a/GEOSachem_GridComp/GEOSachem_ExtData.rc b/GEOSachem_GridComp/GEOSachem_ExtData.rc index a16aa059..ffc64d27 100755 --- a/GEOSachem_GridComp/GEOSachem_ExtData.rc +++ b/GEOSachem_GridComp/GEOSachem_ExtData.rc @@ -44,7 +44,7 @@ SOAG_EMIS 'm-2 s-1' Y N 0 # CO emissions for VOC CO_BIOMASS_VOC 'kg m-2 s-1' N Y %y4-%m2-%d2t12:00:00Z none none biomass ExtData/chemistry/QFED/v2.5r1-nrt/sfc/0.1/Y%y4/M%m2/qfed2.emis_co.006.%y4%m2%d2.nc4 CO_BF_VOC 'kg m-2 s-1' Y Y %y4-%m2-%d2t12:00:00Z none none emcobf /dev/null -CO_FS_VOC 'kg m-2 s-1' N Y %y4-%m2-%d2t12:00:00Z none none co ExtData/chemistry/CEDS/v2021-04-21/sfc/CO-em-anthro_CMIP_CEDS_gn.x2304_y1441_t12.%y4.nc4 +CO_FS_VOC 'kg m-2 s-1' N Y %y4-%m2-%d2t12:00:00Z none none co ExtData/chemistry/CEDS/v2021-04-21-revised/sfc/CO-em-anthro_CMIP_CEDS_gn.x2304_y1441_t12.%y4.nc4 # Photolysis rates #jH2O2 's-1' Y N 0 none none jH2O2 ExtData/chemistry/GMI/v0.0.0/L72/Y2008/gmi_jh2o2.x144_y91_z72.2008%m2.nc4 diff --git a/GEOSachem_GridComp/GEOSachem_ExtData.yaml b/GEOSachem_GridComp/GEOSachem_ExtData.yaml index 7bfa7d9f..6712a14e 100644 --- a/GEOSachem_GridComp/GEOSachem_ExtData.yaml +++ b/GEOSachem_GridComp/GEOSachem_ExtData.yaml @@ -1,6 +1,6 @@ Collections: GEOSachem_CO-em-anthro_CMIP_CEDS_gn.x2304_y1441_t12.%y4.nc4: - template: ExtData/chemistry/CEDS/v2021-04-21/sfc/CO-em-anthro_CMIP_CEDS_gn.x2304_y1441_t12.%y4.nc4 + template: ExtData/chemistry/CEDS/v2021-04-21-revised/sfc/CO-em-anthro_CMIP_CEDS_gn.x2304_y1441_t12.%y4.nc4 GEOSachem_DMSclim_sfcconcentration.x360_y181_t12.Lana2011.nc4: template: ExtData/chemistry/Lana/v2011/DMSclim_sfcconcentration.x360_y181_t12.Lana2011.nc4 GEOSachem_GEIA.emis_NH3.ocean.x576_y361.t12.20080715_12z.nc4: diff --git a/GEOSpchem_GridComp/CMakeLists.txt b/GEOSpchem_GridComp/CMakeLists.txt index 6f5b0ed7..44effab9 100644 --- a/GEOSpchem_GridComp/CMakeLists.txt +++ b/GEOSpchem_GridComp/CMakeLists.txt @@ -2,4 +2,4 @@ esma_set_this () esma_add_library (${this} SRCS GEOS_PChemGridComp.F90 - DEPENDENCIES MAPL MAPL_cfio_r4 Chem_Base esmf NetCDF::NetCDF_Fortran) + DEPENDENCIES MAPL MAPL_cfio_r4 Chem_Base ESMF::ESMF NetCDF::NetCDF_Fortran) diff --git a/GEOSpchem_GridComp/GEOS_PChemGridComp.F90 b/GEOSpchem_GridComp/GEOS_PChemGridComp.F90 index 9a409ffe..80247da2 100644 --- a/GEOSpchem_GridComp/GEOS_PChemGridComp.F90 +++ b/GEOSpchem_GridComp/GEOS_PChemGridComp.F90 @@ -831,103 +831,87 @@ subroutine Initialize ( GC, IMPORT, EXPORT, CLOCK, RC ) call MAPL_TimerOn (MAPL,"-Read Header" ) -#ifdef H5_HAVE_PARALLEL - call MPI_Info_create(info, STATUS) - call MPI_Info_set(info, "romio_cb_read", "automatic", STATUS) - VERIFY_(STATUS) - call ESMF_VMGet(vm, mpiCommunicator=comm, rc=STATUS) - VERIFY_(STATUS) - -#ifdef NETCDF_NEED_NF_MPIIO - STATUS = NF90_OPEN_PAR(trim(PCHEMFILE),IOR(NF90_NOWRITE,NF90_MPIIO),comm,info,UNIT) -#else - STATUS = NF90_OPEN_PAR(trim(PCHEMFILE),NF90_NOWRITE,comm,info,UNIT) -#endif - -#else if ( MAPL_am_I_root() ) then STATUS = NF90_OPEN(trim(PCHEMFILE),NF90_NOWRITE,UNIT) -#endif - if(status /= NF90_NOERR) then - print*,'Error opening file ',trim(PCHEMFILE), status - print*, NF90_STRERROR(status) - stop - endif + if(status /= NF90_NOERR) then + print*,'Error opening file ',trim(PCHEMFILE), status + print*, NF90_STRERROR(status) + stop + endif ! Read various dimension and global information including ! number of levels, and the number of species in the PCHEMFILE. !-------------------------------------------------------------- - STATUS = NF90_INQ_DIMID(UNIT, 'lat', dimid) - if(status /= NF90_NOERR) then - print*,'Error getting dimid for lat', status - print*, NF90_STRERROR(status) - stop - endif - STATUS = NF90_INQUIRE_DIMENSION(UNIT, dimid, len=PCHEM_STATE%NLATS) - if(status /= NF90_NOERR) then - print*,'Error getting dimlen for lat', status - print*, NF90_STRERROR(status) - stop - endif - STATUS = NF90_INQ_DIMID(UNIT, 'lev', dimid) - if(status /= NF90_NOERR) then - print*,'Error getting dimid for lev', status - print*, NF90_STRERROR(status) - stop - endif - STATUS = NF90_INQUIRE_DIMENSION(UNIT, dimid, len=PCHEM_STATE%NLEVS) - if(status /= NF90_NOERR) then - print*,'Error getting dimlen for lev', status - print*, NF90_STRERROR(status) - stop - endif - STATUS = NF90_GET_ATT(UNIT, NF90_GLOBAL, 'NSPECIES', NSPECIES) - if(status /= NF90_NOERR) then - print*,'Error getting NSPECIES', status - print*, NF90_STRERROR(status) - stop - endif - _ASSERT(PCHEM_STATE%NSPECIES==NSPECIES,'needs informative message') - -! If multiple climYears, the second record tells us starting and ending year and number of years -!----------------------------------------------------------------------------------------------- - - IF(PCHEM_STATE%climYears == 1) THEN - PCHEM_STATE%begClimYear = 1 - PCHEM_STATE%endClimYear = 1 - ELSE - STATUS = NF90_GET_ATT(UNIT, NF90_GLOBAL, 'begClimYear', PCHEM_STATE%begClimYear) + STATUS = NF90_INQ_DIMID(UNIT, 'lat', dimid) + if(status /= NF90_NOERR) then + print*,'Error getting dimid for lat', status + print*, NF90_STRERROR(status) + stop + endif + STATUS = NF90_INQUIRE_DIMENSION(UNIT, dimid, len=PCHEM_STATE%NLATS) if(status /= NF90_NOERR) then - print*,'Error getting begClimYear', status + print*,'Error getting dimlen for lat', status print*, NF90_STRERROR(status) stop endif - STATUS = NF90_GET_ATT(UNIT, NF90_GLOBAL, 'endClimYear', PCHEM_STATE%endClimYear) + STATUS = NF90_INQ_DIMID(UNIT, 'lev', dimid) if(status /= NF90_NOERR) then - print*,'Error getting endClimYear', status + print*,'Error getting dimid for lev', status print*, NF90_STRERROR(status) stop endif - STATUS = NF90_GET_ATT(UNIT, NF90_GLOBAL, 'climYears' , climYears) + STATUS = NF90_INQUIRE_DIMENSION(UNIT, dimid, len=PCHEM_STATE%NLEVS) if(status /= NF90_NOERR) then - print*,'Error getting climYears', status + print*,'Error getting dimlen for lev', status print*, NF90_STRERROR(status) stop endif + STATUS = NF90_GET_ATT(UNIT, NF90_GLOBAL, 'NSPECIES', NSPECIES) + if(status /= NF90_NOERR) then + print*,'Error getting NSPECIES', status + print*, NF90_STRERROR(status) + stop + endif + _ASSERT(PCHEM_STATE%NSPECIES==NSPECIES,'needs informative message') - IF(climYears /= PCHEM_STATE%climYears) THEN - PRINT *," " - PRINT *,TRIM(Iam)//": Problem with "//TRIM(PCHEMFILE) - PRINT *,"Expecting ",PCHEM_STATE%climYears," years but there are ",climYears - STATUS=1 - VERIFY_(STATUS) +! If multiple climYears, the second record tells us starting and ending year and number of years +!----------------------------------------------------------------------------------------------- + + IF(PCHEM_STATE%climYears == 1) THEN + PCHEM_STATE%begClimYear = 1 + PCHEM_STATE%endClimYear = 1 + ELSE + STATUS = NF90_GET_ATT(UNIT, NF90_GLOBAL, 'begClimYear', PCHEM_STATE%begClimYear) + if(status /= NF90_NOERR) then + print*,'Error getting begClimYear', status + print*, NF90_STRERROR(status) + stop + endif + STATUS = NF90_GET_ATT(UNIT, NF90_GLOBAL, 'endClimYear', PCHEM_STATE%endClimYear) + if(status /= NF90_NOERR) then + print*,'Error getting endClimYear', status + print*, NF90_STRERROR(status) + stop + endif + STATUS = NF90_GET_ATT(UNIT, NF90_GLOBAL, 'climYears' , climYears) + if(status /= NF90_NOERR) then + print*,'Error getting climYears', status + print*, NF90_STRERROR(status) + stop + endif + + IF(climYears /= PCHEM_STATE%climYears) THEN + PRINT *," " + PRINT *,TRIM(Iam)//": Problem with "//TRIM(PCHEMFILE) + PRINT *,"Expecting ",PCHEM_STATE%climYears," years but there are ",climYears + STATUS=1 + VERIFY_(STATUS) + END IF END IF - END IF ! Allocate and read PCHEMFILE's latitudes (radians) and pressures (Pa). !---------------------------------------------------------------------- -#ifndef H5_HAVE_PARALLEL endif ! MAPL_am_I_root call MAPL_CommsBcast (vm, PCHEM_STATE%NLATS ,1, 0, rc=status) @@ -939,45 +923,38 @@ subroutine Initialize ( GC, IMPORT, EXPORT, CLOCK, RC ) call MAPL_CommsBcast (vm, PCHEM_STATE%endClimYear ,1, 0, rc=status) VERIFY_(STATUS) -#endif allocate ( PCHEM_STATE%LATS (PCHEM_STATE%NLATS), STAT=STATUS ) VERIFY_(STATUS) allocate ( PCHEM_STATE%LEVS (PCHEM_STATE%NLEVS), STAT=STATUS ) VERIFY_(STATUS) -#ifndef H5_HAVE_PARALLEL if ( MAPL_am_I_root() ) then -#endif - STATUS = NF90_INQ_VARID(UNIT, 'lat', varid) - if(status /= NF90_NOERR) then - print*,'Error getting varid for lat', status - print*, NF90_STRERROR(status) - stop - endif - STATUS = NF90_GET_VAR(UNIT, varid, PCHEM_STATE%LATS) - if(status /= NF90_NOERR) then - print*,'Error getting values for lat', status - print*, NF90_STRERROR(status) - stop - endif - STATUS = NF90_INQ_VARID(UNIT, 'lev', varid) - if(status /= NF90_NOERR) then - print*,'Error getting varid for lev', status - print*, NF90_STRERROR(status) - stop - endif - STATUS = NF90_GET_VAR(UNIT, varid, PCHEM_STATE%LEVS) - if(status /= NF90_NOERR) then - print*,'Error getting values for lev', status - print*, NF90_STRERROR(status) - stop - endif -#ifdef H5_HAVE_PARALLEL - call MPI_Info_free(info, status) - VERIFY_(STATUS) -#else + STATUS = NF90_INQ_VARID(UNIT, 'lat', varid) + if(status /= NF90_NOERR) then + print*,'Error getting varid for lat', status + print*, NF90_STRERROR(status) + stop + endif + STATUS = NF90_GET_VAR(UNIT, varid, PCHEM_STATE%LATS) + if(status /= NF90_NOERR) then + print*,'Error getting values for lat', status + print*, NF90_STRERROR(status) + stop + endif + STATUS = NF90_INQ_VARID(UNIT, 'lev', varid) + if(status /= NF90_NOERR) then + print*,'Error getting varid for lev', status + print*, NF90_STRERROR(status) + stop + endif + STATUS = NF90_GET_VAR(UNIT, varid, PCHEM_STATE%LEVS) + if(status /= NF90_NOERR) then + print*,'Error getting values for lev', status + print*, NF90_STRERROR(status) + stop + endif endif ! MAPL_am_I_root call MAPL_CommsBcast (vm, PCHEM_STATE%LATS,size(PCHEM_STATE%LATS), 0, rc=status) @@ -985,7 +962,6 @@ subroutine Initialize ( GC, IMPORT, EXPORT, CLOCK, RC ) call MAPL_CommsBcast (vm, PCHEM_STATE%LEVS,size(PCHEM_STATE%LEVS), 0, rc=status) VERIFY_(STATUS) -#endif STATUS = NF90_CLOSE(UNIT) call MAPL_TimerOff (MAPL,"-Read Header" ) @@ -1351,172 +1327,154 @@ subroutine RUN ( GC, IMPORT, EXPORT, CLOCK, RC ) call ESMF_VMGet(vm, mpiCommunicator=comm, rc=STATUS) VERIFY_(STATUS) -#ifdef H5_HAVE_PARALLEL - call MPI_Info_create(info, STATUS) - VERIFY_(STATUS) - call MPI_Info_set(info, "romio_cb_read", "automatic", STATUS) - VERIFY_(STATUS) - -#ifdef NETCDF_NEED_NF_MPIIO - STATUS = NF90_OPEN_PAR(trim(PCHEMFILE),IOR(NF90_NOWRITE,NF90_MPIIO),comm,info,UNIT) -#else - STATUS = NF90_OPEN_PAR(trim(PCHEMFILE),NF90_NOWRITE,comm,info,UNIT) -#endif - -#else if ( MAPL_am_I_root() ) then STATUS = NF90_OPEN(trim(PCHEMFILE),NF90_NOWRITE,UNIT) -#endif - if(status /= NF90_NOERR) then - print*,'Error opening file ',trim(PCHEMFILE), status - print*, NF90_STRERROR(status) - stop - endif - - start(1) = 1 - start(2) = 1 - cnt(1) = PCHEM_STATE%NLATS - cnt(2) = PCHEM_STATE%NLEVS - cnt(3) = 1 - - DO K = 1,PCHEM_STATE%NSPECIES - FieldName = PCHEM_STATE%ITEMNAMES(K) - STATUS = NF90_INQ_VARID(UNIT, trim(FieldName), varid) if(status /= NF90_NOERR) then - print*,'Error getting varid for variable ',trim(FieldName), status + print*,'Error opening file ',trim(PCHEMFILE), status print*, NF90_STRERROR(status) stop endif + + start(1) = 1 + start(2) = 1 + cnt(1) = PCHEM_STATE%NLATS + cnt(2) = PCHEM_STATE%NLEVS + cnt(3) = 1 + + DO K = 1,PCHEM_STATE%NSPECIES + FieldName = PCHEM_STATE%ITEMNAMES(K) + STATUS = NF90_INQ_VARID(UNIT, trim(FieldName), varid) + if(status /= NF90_NOERR) then + print*,'Error getting varid for variable ',trim(FieldName), status + print*, NF90_STRERROR(status) + stop + endif ! Need two separate reads because INDX2 isn't always sequentially after INDX1, otherwise ! we could combine the reads into one - start(3) = INDX1 - STATUS = NF90_GET_VAR(UNIT, varid, PCHEM_STATE%MNCV(:,:,K,1), start, cnt) - if(status /= NF90_NOERR) then - print*,'Error reading lower bracket month ',status - print*, NF90_STRERROR(status) - stop - endif - start(3) = INDX2 - STATUS = NF90_GET_VAR(UNIT, varid, PCHEM_STATE%MNCV(:,:,K,2), start, cnt) - if(status /= NF90_NOERR) then - print*,'Error reading upper bracket month ',status - print*, NF90_STRERROR(status) - stop - endif + start(3) = INDX1 + STATUS = NF90_GET_VAR(UNIT, varid, PCHEM_STATE%MNCV(:,:,K,1), start, cnt) + if(status /= NF90_NOERR) then + print*,'Error reading lower bracket month ',status + print*, NF90_STRERROR(status) + stop + endif + start(3) = INDX2 + STATUS = NF90_GET_VAR(UNIT, varid, PCHEM_STATE%MNCV(:,:,K,2), start, cnt) + if(status /= NF90_NOERR) then + print*,'Error reading upper bracket month ',status + print*, NF90_STRERROR(status) + stop + endif ! Convert H2O to mass fraction. !------------------------------ - IF(K == PCHEM_STATE%H2O) then - PCHEM_STATE%MNCV(:,:,K,1) = PCHEM_STATE%MNCV(:,:,K,1)*(MAPL_H2OMW/MAPL_AIRMW) - PCHEM_STATE%MNCV(:,:,K,2) = PCHEM_STATE%MNCV(:,:,K,2)*(MAPL_H2OMW/MAPL_AIRMW) - endif + IF(K == PCHEM_STATE%H2O) then + PCHEM_STATE%MNCV(:,:,K,1) = PCHEM_STATE%MNCV(:,:,K,1)*(MAPL_H2OMW/MAPL_AIRMW) + PCHEM_STATE%MNCV(:,:,K,2) = PCHEM_STATE%MNCV(:,:,K,2)*(MAPL_H2OMW/MAPL_AIRMW) + endif ! Production rates and loss frequencies. If multiple climYears, simply set to zero. ! --------------------------------------------------------------------------------- - IF(PCHEM_STATE%climYears == 1) THEN + IF(PCHEM_STATE%climYears == 1) THEN + + STATUS = NF90_INQ_VARID(UNIT, trim(FieldName)//'_PROD', varid) + if(status /= NF90_NOERR) then + print*,'Error getting varid for variable ',trim(FieldName)//'_PROD', status + print*, NF90_STRERROR(status) + stop + endif + start(3) = INDX1 + STATUS = NF90_GET_VAR(UNIT, varid, PCHEM_STATE%MNPL(:,:,K,1,1), start, cnt) + if(status /= NF90_NOERR) then + print*,'Error reading lower bracket month for production ',status + print*, NF90_STRERROR(status) + stop + endif + start(3) = INDX2 + STATUS = NF90_GET_VAR(UNIT, varid, PCHEM_STATE%MNPL(:,:,K,1,2), start, cnt) + if(status /= NF90_NOERR) then + print*,'Error reading upper bracket month for production ',status + print*, NF90_STRERROR(status) + stop + endif + IF(K == PCHEM_STATE%H2O) PCHEM_STATE%MNPL(:,:,K,1,1) = PCHEM_STATE%MNPL(:,:,K,1,1)*(MAPL_H2OMW/MAPL_AIRMW) + IF(K == PCHEM_STATE%H2O) PCHEM_STATE%MNPL(:,:,K,1,2) = PCHEM_STATE%MNPL(:,:,K,1,2)*(MAPL_H2OMW/MAPL_AIRMW) +! Loss +! ---- + STATUS = NF90_INQ_VARID(UNIT, trim(FieldName)//'_LOSS', varid) + if(status /= NF90_NOERR) then + print*,'Error getting varid for variable ',trim(FieldName)//'_LOSS', status + print*, NF90_STRERROR(status) + stop + endif + start(3) = INDX1 + STATUS = NF90_GET_VAR(UNIT, varid, PCHEM_STATE%MNPL(:,:,K,2,1), start, cnt) + if(status /= NF90_NOERR) then + print*,'Error reading lower bracket month for loss ',status + print*, NF90_STRERROR(status) + stop + endif + start(3) = INDX2 + STATUS = NF90_GET_VAR(UNIT, varid, PCHEM_STATE%MNPL(:,:,K,2,2), start, cnt) + if(status /= NF90_NOERR) then + print*,'Error reading upper bracket month for loss ',status + print*, NF90_STRERROR(status) + stop + endif + ENDIF + + ENDDO - STATUS = NF90_INQ_VARID(UNIT, trim(FieldName)//'_PROD', varid) - if(status /= NF90_NOERR) then - print*,'Error getting varid for variable ',trim(FieldName)//'_PROD', status +!fli2 Read H2O production and loss rate if use_h2o_prodloss + IF (USE_H2O_ProdLoss) THEN + + STATUS = NF90_INQ_VARID(UNIT, 'H2OprRate', varid) + if(status /= nf90_noerr) then + print*,'Error getting varid for variable H2OprRate', status print*, NF90_STRERROR(status) stop endif start(3) = INDX1 - STATUS = NF90_GET_VAR(UNIT, varid, PCHEM_STATE%MNPL(:,:,K,1,1), start, cnt) - if(status /= NF90_NOERR) then - print*,'Error reading lower bracket month for production ',status + STATUS = NF90_GET_VAR(UNIT, varid, PCHEM_STATE%H2OprRate(:,:,1), start, cnt) + if(status /= nf90_noerr) then + print*,'Error reading lower bracket month ',status print*, NF90_STRERROR(status) stop endif start(3) = INDX2 - STATUS = NF90_GET_VAR(UNIT, varid, PCHEM_STATE%MNPL(:,:,K,1,2), start, cnt) - if(status /= NF90_NOERR) then - print*,'Error reading upper bracket month for production ',status + STATUS = NF90_GET_VAR(UNIT, varid, PCHEM_STATE%H2OprRate(:,:,2), start, cnt) + if(status /= nf90_noerr) then + print*,'Error reading upper bracket month ',status print*, NF90_STRERROR(status) stop endif - IF(K == PCHEM_STATE%H2O) PCHEM_STATE%MNPL(:,:,K,1,1) = PCHEM_STATE%MNPL(:,:,K,1,1)*(MAPL_H2OMW/MAPL_AIRMW) - IF(K == PCHEM_STATE%H2O) PCHEM_STATE%MNPL(:,:,K,1,2) = PCHEM_STATE%MNPL(:,:,K,1,2)*(MAPL_H2OMW/MAPL_AIRMW) -! Loss -! ---- - STATUS = NF90_INQ_VARID(UNIT, trim(FieldName)//'_LOSS', varid) - if(status /= NF90_NOERR) then - print*,'Error getting varid for variable ',trim(FieldName)//'_LOSS', status + + STATUS = NF90_INQ_VARID(UNIT, 'H2OlsRate', varid) + if(status /= nf90_noerr) then + print*,'Error getting varid for variable H2OlsRate', status print*, NF90_STRERROR(status) stop endif start(3) = INDX1 - STATUS = NF90_GET_VAR(UNIT, varid, PCHEM_STATE%MNPL(:,:,K,2,1), start, cnt) - if(status /= NF90_NOERR) then - print*,'Error reading lower bracket month for loss ',status + STATUS = NF90_GET_VAR(UNIT, varid, PCHEM_STATE%H2OlsRate(:,:,1), start, cnt) + if(status /= nf90_noerr) then + print*,'Error reading lower bracket month ',status print*, NF90_STRERROR(status) stop endif start(3) = INDX2 - STATUS = NF90_GET_VAR(UNIT, varid, PCHEM_STATE%MNPL(:,:,K,2,2), start, cnt) - if(status /= NF90_NOERR) then - print*,'Error reading upper bracket month for loss ',status + STATUS = NF90_GET_VAR(UNIT, varid, PCHEM_STATE%H2OlsRate(:,:,2), start, cnt) + if(status /= nf90_noerr) then + print*,'Error reading upper bracket month ',status print*, NF90_STRERROR(status) stop endif + ENDIF - ENDDO - -!fli2 Read H2O production and loss rate if use_h2o_prodloss - IF (USE_H2O_ProdLoss) THEN - - STATUS = NF90_INQ_VARID(UNIT, 'H2OprRate', varid) - if(status /= nf90_noerr) then - print*,'Error getting varid for variable H2OprRate', status - print*, NF90_STRERROR(status) - stop - endif - start(3) = INDX1 - STATUS = NF90_GET_VAR(UNIT, varid, PCHEM_STATE%H2OprRate(:,:,1), start, cnt) - if(status /= nf90_noerr) then - print*,'Error reading lower bracket month ',status - print*, NF90_STRERROR(status) - stop - endif - start(3) = INDX2 - STATUS = NF90_GET_VAR(UNIT, varid, PCHEM_STATE%H2OprRate(:,:,2), start, cnt) - if(status /= nf90_noerr) then - print*,'Error reading upper bracket month ',status - print*, NF90_STRERROR(status) - stop - endif - - STATUS = NF90_INQ_VARID(UNIT, 'H2OlsRate', varid) - if(status /= nf90_noerr) then - print*,'Error getting varid for variable H2OlsRate', status - print*, NF90_STRERROR(status) - stop - endif - start(3) = INDX1 - STATUS = NF90_GET_VAR(UNIT, varid, PCHEM_STATE%H2OlsRate(:,:,1), start, cnt) - if(status /= nf90_noerr) then - print*,'Error reading lower bracket month ',status - print*, NF90_STRERROR(status) - stop - endif - start(3) = INDX2 - STATUS = NF90_GET_VAR(UNIT, varid, PCHEM_STATE%H2OlsRate(:,:,2), start, cnt) - if(status /= nf90_noerr) then - print*,'Error reading upper bracket month ',status - print*, NF90_STRERROR(status) - stop - endif - - ENDIF - - STATUS = NF90_CLOSE(UNIT) - VERIFY_(STATUS) + STATUS = NF90_CLOSE(UNIT) + VERIFY_(STATUS) -#ifdef H5_HAVE_PARALLEL - call MPI_Info_free(info, status) - VERIFY_(STATUS) -#else endif ! MAPL_am_I_root call MPI_Bcast (PCHEM_STATE%MNCV, size(PCHEM_STATE%MNCV), MPI_REAL, 0, comm, STATUS) VERIFY_(STATUS) @@ -1524,7 +1482,6 @@ subroutine RUN ( GC, IMPORT, EXPORT, CLOCK, RC ) call MPI_Bcast (PCHEM_STATE%MNPL, size(PCHEM_STATE%MNPL), MPI_REAL, 0, comm, STATUS) VERIFY_(STATUS) ENDIF -#endif call MAPL_TimerOff (MAPL,"-Read Species" ) call MAPL_TimerOn (MAPL,"RUN" ) diff --git a/HEMCO_GridComp/CMakeLists.txt b/HEMCO_GridComp/CMakeLists.txt index 89079969..807f1da5 100644 --- a/HEMCO_GridComp/CMakeLists.txt +++ b/HEMCO_GridComp/CMakeLists.txt @@ -7,7 +7,7 @@ set (srcs esma_add_library ( ${this} SRCS ${srcs} - DEPENDENCIES Chem_Shared MAPL HEMCO esmf NetCDF::NetCDF_Fortran + DEPENDENCIES Chem_Shared MAPL HEMCO ESMF::ESMF NetCDF::NetCDF_Fortran ) target_compile_definitions (${this} PRIVATE ESMF_ DEVEL GEOS_FP) diff --git a/MAMchem_GridComp/CMakeLists.txt b/MAMchem_GridComp/CMakeLists.txt index 9ba6165d..ae245d58 100644 --- a/MAMchem_GridComp/CMakeLists.txt +++ b/MAMchem_GridComp/CMakeLists.txt @@ -54,7 +54,7 @@ set (srcs ) -set (dependencies MAPL Chem_Shared GMAO_mpeu esmf NetCDF::NetCDF_Fortran) +set (dependencies MAPL Chem_Shared GMAO_mpeu ESMF::ESMF NetCDF::NetCDF_Fortran) esma_add_library (${this} SRCS ${srcs} DEPENDENCIES ${dependencies} SUBDIRS optics) target_compile_definitions (${this} PRIVATE GEOS5 MODAL_AERO MODAL_AERO_7MODE GEOS5_PORT) diff --git a/MATRIXchem_GridComp/CMakeLists.txt b/MATRIXchem_GridComp/CMakeLists.txt index db36e2ab..cd2d1bf3 100644 --- a/MATRIXchem_GridComp/CMakeLists.txt +++ b/MATRIXchem_GridComp/CMakeLists.txt @@ -22,7 +22,7 @@ set (srcs MATRIXchem_GridCompMod.F90 ) -esma_add_library (${this} SRCS ${srcs} DEPENDENCIES Chem_Shared MAPL esmf) +esma_add_library (${this} SRCS ${srcs} DEPENDENCIES Chem_Shared MAPL ESMF::ESMF) if (EXTENDED_SOURCE) set_target_properties (${this} PROPERTIES COMPILE_FLAGS ${EXTENDED_SOURCE}) endif () diff --git a/Shared/Chem_Base/CMakeLists.txt b/Shared/Chem_Base/CMakeLists.txt index c39b9675..8ab8d180 100644 --- a/Shared/Chem_Base/CMakeLists.txt +++ b/Shared/Chem_Base/CMakeLists.txt @@ -14,7 +14,7 @@ set (srcs Chem_AodMod.F90 Chem_SimpleBundleMod.F90 ) -esma_add_library(${this} SRCS ${srcs} DEPENDENCIES GMAO_mpeu MAPL GMAO_gfio_r4 esmf NetCDF::NetCDF_Fortran) +esma_add_library(${this} SRCS ${srcs} DEPENDENCIES GMAO_mpeu MAPL GMAO_gfio_r4 ESMF::ESMF NetCDF::NetCDF_Fortran) target_compile_definitions (${this} PRIVATE GEOS5) ecbuild_add_executable(TARGET gogo.x SOURCES gogo.F90 LIBS ${this}) diff --git a/Shared/Chem_Shared/CMakeLists.txt b/Shared/Chem_Shared/CMakeLists.txt index 944b98dc..bd6c535a 100644 --- a/Shared/Chem_Shared/CMakeLists.txt +++ b/Shared/Chem_Shared/CMakeLists.txt @@ -22,6 +22,7 @@ set (srcs Bundle_IncrementMod.F90 Lightning_mod.F90 lightning_toolbox_mod.F90 + SZA_from_MAPL_mod.F90 ) if (DOING_GEOS5) @@ -34,7 +35,7 @@ endif () esma_add_library(${this} SRCS ${srcs} - DEPENDENCIES GMAO_mpeu MAPL Chem_Base GEOS_Shared GMAO_hermes esmf NetCDF::NetCDF_Fortran) + DEPENDENCIES GMAO_mpeu MAPL Chem_Base GEOS_Shared GMAO_hermes ESMF::ESMF NetCDF::NetCDF_Fortran) #add_definitions(-DDEBUG) add_definitions(-DSPMD -DFVCHEM) diff --git a/Shared/Chem_Shared/Lightning_mod.F90 b/Shared/Chem_Shared/Lightning_mod.F90 index 2e982eba..3afa56c9 100644 --- a/Shared/Chem_Shared/Lightning_mod.F90 +++ b/Shared/Chem_Shared/Lightning_mod.F90 @@ -132,7 +132,8 @@ subroutine getLightning (GC, ggState, CLOCK, & PFICU, PLE, Q, ZLE, & minDeepCloudTop, lightNOampFactor, numberNOperFlash, & MOIST_flashFactor, FIT_flashFactor, HEMCO_flashFactor, LOPEZ_flashFactor, & - CNV_MFD, CAPE, BYNCY, flashRate, light_NO_prod, PHIS, & + CNV_MFD, usePreconCape, CAPE_PRECON, INHB_PRECON, BYNCY_PRECON, & + CAPE, BYNCY, ZLFC, ZLCL, flashRate, light_NO_prod, PHIS, & RC) type(ESMF_GridComp), intent(inout) :: GC ! Gridded component @@ -177,7 +178,7 @@ subroutine getLightning (GC, ggState, CLOCK, & real, dimension(:,:,:), intent(in) :: PLE ! edge pressures (Pa) real, dimension(:,:,:), intent(in) :: ZLE ! geopotential height (m) [top-down] - real, dimension(:,:,:), intent(in) :: PFICU ! flux of ice convective precip (kg m-2 s-1) + real, dimension(:,:,:), intent(in) :: PFICU ! flux of ice in convective updrafts (kg m-2 s-1) real, dimension(:,:,:), intent(in) :: T ! air temperature (K) [top-down] real, dimension(:,:,:), intent(in) :: TH ! potential temperature (K) [top-down] real, dimension(:,:,:), intent(in) :: Q ! specific humidity (kg kg-1) [top-down] @@ -187,6 +188,14 @@ subroutine getLightning (GC, ggState, CLOCK, & real, intent(in) :: numberNOperFlash ! NO molecules generated by each flash real, dimension(:,:,:), intent(in) :: CNV_MFD ! detraining_mass_flux (kg m-2 s-1) [top-down] + logical, intent(in) :: usePreconCape ! Whether to use CAPE, INHB and BYNCY from MOIST + real, dimension(:,:), intent(in) :: CAPE_PRECON + real, dimension(:,:), intent(in) :: INHB_PRECON + real, dimension(:,:,:), intent(in) :: BYNCY_PRECON + + REAL, dimension(:,:), INTENT(IN) :: ZLFC ! Level of Free Convection height [m] + REAL, dimension(:,:), INTENT(IN) :: ZLCL ! Lifted Condensation Level height [m] + real, dimension(:,:), intent(out) :: CAPE ! can remove these eventually real, dimension(:,:,:), intent(out) :: BYNCY ! can remove these eventually [top-down] real, dimension(:,:), intent(out) :: flashRate ! (flashes/km2/s) @@ -233,7 +242,7 @@ subroutine getLightning (GC, ggState, CLOCK, & logical, save :: first = .TRUE. integer :: IM, JM, LM, K0, KM, nc - integer :: i, j, l, ls + integer :: i, j, L, ls integer :: modelLevel ! only used for FIT real(REAL64) :: ptop, pint @@ -346,14 +355,20 @@ subroutine getLightning (GC, ggState, CLOCK, & ! callLopezCalcuations() put above end subroutine getLightning - call BUOYANCY (T, Q, QSS, DQS, DZ, ZLO, BYNCY, CAPE, INHB) + if (usePreconCape) then + CAPE = CAPE_PRECON + INHB = INHB_PRECON + BYNCY = BYNCY_PRECON + else + call BUOYANCY (T, Q, QSS, DQS, DZ, ZLO, BYNCY, CAPE, INHB) + end if ALLOCATE( flashRateLopez(IM, JM), STAT=STATUS); VERIFY_(STATUS) flashRateLopez = real(0) ! flashRateLopez(:,:) = 0.01 - call LOPEZ_FlashRate(IM, JM, LM, FRLAND, PBLH, CAPE, ZLE2, PFICU, & - CNV_QC, T, PLO, LOPEZ_flashFactor, flashRateLopez) + call LOPEZ_FlashRate(ggState, IM, JM, LM, FROCEAN, PBLH, CAPE, ZLE2, PFICU, & + CNV_QC, T, PLO, ZLFC, ZLCL, LOPEZ_flashFactor, flashRateLopez, __RC__ ) !print*, "min/max LFR LOPEZ: ", minval(flashRateLopez), maxval(flashRateLopez) @@ -375,7 +390,13 @@ subroutine getLightning (GC, ggState, CLOCK, & else if (flash_source_enum == FLASH_SOURCE_HEMCO) then ! The HEMCO flash routine may use BYNCY in the future -! call BUOYANCY (T, Q, QSS, DQS, DZ, ZLO, BYNCY, CAPE, INHB) +! if (usePreconCape) then +! CAPE = CAPE_PRECON +! INHB = INHB_PRECON +! BYNCY = BYNCY_PRECON +! else +! call BUOYANCY (T, Q, QSS, DQS, DZ, ZLO, BYNCY, CAPE, INHB) +! end if call HEMCO_FlashRate (cellArea, LWI, LONSLOCAL, LATSLOCAL, T, PLE, & @@ -396,8 +417,31 @@ subroutine getLightning (GC, ggState, CLOCK, & DM(:,:,1:LM) = ( PLE(:,:,K0+1:KM)-PLE(:,:,K0:KM-1) ) * (1./MAPL_GRAV) ! DELP / g - call BUOYANCY (T, Q, QSS, DQS, DZ, ZLO, BYNCY, CAPE, INHB, & - DM=DM, CAPE_MERRA2=CAPE_MERRA2) + if (usePreconCape) then + + CAPE = CAPE_PRECON + INHB = INHB_PRECON + BYNCY = BYNCY_PRECON + + CAPE_MERRA2(:,:) = 0. + + do L=1,LM-1 + where(BYNCY(:,:,L)>0.) + CAPE_MERRA2 = CAPE_MERRA2 + BYNCY(:,:,L)*DM(:,:,L) + end where + end do + + where(CAPE_MERRA2 <= 0.0) + CAPE_MERRA2=MAPL_UNDEF + end where + + else + call BUOYANCY (T, Q, QSS, DQS, DZ, ZLO, BYNCY, CAPE, INHB, & + DM=DM, CAPE_MERRA2=CAPE_MERRA2) + end if + + + ! Determine the pressure at convective cloud top @@ -565,7 +609,7 @@ subroutine read_flash_source ( rcfilen, flash_source_enum, RC ) ! How to calculate flashrate call ESMF_ConfigGetAttribute( esmfConfig, flashSource, & Label = "flashSource:", & - Default = 'MOIST', __RC__ ) + Default = 'LOPEZ', __RC__ ) call identify_flash_source( flashSource, flash_source_enum ) IF ( flash_source_enum == FLASH_SOURCE_UNDEFINED ) THEN @@ -592,12 +636,13 @@ end subroutine read_flash_source !EOP !----------------------------------------------------------------------- -subroutine read_lightning_config ( im, jm, rcfilen, flash_source_enum, & - SimType, & - ratioGlobalFile, minDeepCloudTop, & - lightNOampFactor, numberNOperFlash, & - MOIST_flashFactor, FIT_flashFactor, & +subroutine read_lightning_config ( im, jm, rcfilen, flash_source_enum, & + SimType, & + ratioGlobalFile, minDeepCloudTop, & + lightNOampFactor, numberNOperFlash, & + MOIST_flashFactor, FIT_flashFactor, & HEMCO_flashFactor, LOPEZ_flashFactor, & + usePreconCape, & RC ) ! IN: @@ -615,6 +660,7 @@ subroutine read_lightning_config ( im, jm, rcfilen, flash_source_enum, & real, intent(out) :: FIT_flashFactor real, intent(out) :: HEMCO_flashFactor real, intent(out) :: LOPEZ_flashFactor + logical, intent(out) :: usePreconCape integer, optional, intent(out) :: RC ! Local vars: @@ -699,6 +745,10 @@ subroutine read_lightning_config ( im, jm, rcfilen, flash_source_enum, & Label = "numberNOperFlash:", & Default = 1.50E+26, __RC__ ) + call ESMF_ConfigGetAttribute(esmfConfig, usePreconCape, & + Label = "usePreconCape:", & + Default = .TRUE., __RC__ ) + call ESMF_ConfigDestroy(esmfConfig, __RC__) end subroutine read_lightning_config @@ -1478,78 +1528,146 @@ end subroutine HEMCO_FlashRate !----------------------------------------------------------------------- - subroutine LOPEZ_FlashRate(IM, JM, LM, FRLAND, ZKBCON, CAPE, & - ZLE, PFI_CN_GF, CNV_QC, TE, PLO, LOPEZ_flashFactor, & - LFR_Lopez) + subroutine LOPEZ_FlashRate(STATE, IM, JM, LM, FROCEAN, ZKBCON, CAPE, & + ZLE, PFI_CN_GF, CNV_QC, TE, PLO, ZLFC, ZLCL, LOPEZ_flashFactor, & + LFR_Lopez, RC) implicit none + TYPE(MAPL_MetaComp), POINTER :: STATE ! Internal MAPL_Generic state integer ,intent(in) :: im,jm,lm - real ,intent(in), dimension(im,jm,0:lm) :: & - ZLE & ! layer depths [m] - ,PFI_CN_GF ! 3d_ice_precipitation_flux_GF [kg/m2/s] + real, intent(in), dimension(im,jm,0:lm) :: ZLE ! layer depths [m] + real, intent(in), dimension(im,jm,0:lm) :: PFI_CN_GF ! 3d_ice_precipitation_flux_GF_CONVECTIVE [kg/m2/s] in updrafts + + real, intent(in), dimension(im,jm,lm) :: TE ! air temp [K] + real, intent(in), dimension(im,jm,lm) :: PLO ! press (hPa) + real, intent(in), dimension(im,jm,lm) :: CNV_QC ! grid_mean_convective_condensate [kg/kg] - real ,intent(in), dimension(im,jm,lm) :: & - TE & ! air temp [K] - ,PLO & ! press (hPa) - ,CNV_QC ! grid_mean_convective_condensate [kg/kg] + real, intent(in), dimension(im,jm) :: FROCEAN ! fraction of ocean + real, intent(in), dimension(im,jm) :: cape ! Convective available potential energy [J/kg] + real, intent(in), dimension(im,jm) :: zkbcon ! cloud_base_height_deep_GF [m] - real ,intent(in), dimension(im,jm) :: FRLAND & ! fraction of land - , cape & ! Convective available potential energy [J/kg] - , zkbcon ! cloud_base_height_deep_GF [m] + real, intent(in), dimension(im,jm) :: ZLFC ! Level of Free Convection height [m] + real, intent(in), dimension(im,jm) :: ZLCL ! Lifted Condensation Level height [m] - real ,intent(in) :: LOPEZ_flashFactor ! global scaling term + real, intent(in) :: LOPEZ_flashFactor ! global scaling term ! originally called 'alpha' - real ,intent(out), dimension(im,jm) :: & - LFR_Lopez ! lightning flash density rate (units: flashes/km2/day) + real, intent(out), dimension(im,jm):: LFR_Lopez ! lightning flash density rate (units: flashes/km2/day) + integer, intent(out), optional :: RC + !-- locals + + integer :: STATUS + character(len=*), parameter :: Iam = "LOPEZ_FlashRate" + real, parameter :: V_graup = 3.0 ! m/s real, parameter :: V_snow = 0.5 ! m/s - real, parameter :: beta_land = 0.70 ! 1 - real, parameter :: beta_ocean = 0.45 ! 1 +! real, parameter :: beta_land = 0.70 ! 1 +! real, parameter :: beta_ocean = 0.45 ! 1 +! real, parameter :: beta_land = 0.55 ! 1 +! real, parameter :: beta_ocean = 0.15 ! 1 real, parameter :: t_initial = 0.0 + 273.15 ! K real, parameter :: t_final = -25. + 273.15 ! K + +! REAL :: a_lgt ! Parameters for Lightning Flash Rate +! REAL :: v_graup +! REAL :: v_snow + REAL :: b_land + REAL :: b_marine +! REAL :: cb_exp +! REAL :: cb_max +! REAL :: cb_ref +! REAL :: t_min_ec + REAL :: f_oc_thresh + REAL :: cb_min +! REAL :: c_lfc_land +! REAL :: c_lfc_marine integer :: i,j,k, k_initial, k_final real :: tdif, td2 real :: Q_R, z_base,beta,prec_flx_fr,dz real, dimension(1:lm) :: q_graup,q_snow,rho +! REAL :: f_oc_thresh +! REAL :: cb_min + REAL :: c_lfc_land + REAL :: c_lfc_marine + +! f_oc_thresh = 0.50 +! cb_min = 0.4 + c_lfc_land = 0.4 + c_lfc_marine = 0.1 + +!!! DEBUGGING +! print*, "" +! print*, "Hello from LOPEZ_FlashRate" +! print*, "" + +! print*, "im, jm, lm: ", im, jm, lm +! print*, "FRLAND: ", minval(FRLAND), maxval(FRLAND) +! print*, "CAPE: ", minval(CAPE), maxval(CAPE) +! print*, "ZLE: ", minval(ZLE), maxval(ZLE) +! print*, "PFI_CN_GF ", minval(PFI_CN_GF), maxval(PFI_CN_GF) +! print*, "TE: ", minval(TE), maxval(TE) +! print*, "PLO: ", minval(PLO), maxval(PLO) +! print*, "CNV_QC: ", minval(CNV_QC), maxval(CNV_QC) +! print*, "zkbcon: ", minval(zkbcon), maxval(zkbcon) +!!! + + if (PRESENT(RC)) RC = ESMF_SUCCESS + +! ! Parameters for Lightning Flash Rate from Lopez et al. +! ! ------------------------------------------------ +! CALL MAPL_GetResource(STATE, a_lgt,'A_LGT:', DEFAULT= 10000.0, __RC__ ) +! CALL MAPL_GetResource(STATE, v_graup,'V_GRAUP:', DEFAULT= 3.0, __RC__ ) +! CALL MAPL_GetResource(STATE, v_snow,'V_SNOW:', DEFAULT= 0.5, __RC__ ) + CALL MAPL_GetResource(STATE, b_land,'B_LAND:', DEFAULT= 0.7, __RC__ ) + CALL MAPL_GetResource(STATE, b_marine,'B_MARINE:', DEFAULT= 0.45, __RC__ ) +! CALL MAPL_GetResource(STATE, cb_exp,'CB_EXP:', DEFAULT= 2.0, __RC__ ) +! CALL MAPL_GetResource(STATE, cb_max,'CB_MAX:', DEFAULT= 1.8, __RC__ ) +! CALL MAPL_GetResource(STATE, cb_ref,'CB_REF:', DEFAULT= 1.0, __RC__ ) +! CALL MAPL_GetResource(STATE, t_min_ec,'T_MIN_EC:', DEFAULT= 248.15, __RC__ ) + CALL MAPL_GetResource(STATE, f_oc_thresh,'F_OC_THRESH:', DEFAULT= 0.50, __RC__ ) + CALL MAPL_GetResource(STATE, cb_min,'CB_MIN:', DEFAULT= 0.35, __RC__ ) ! modified from MINDS, for better land/ocean ratio +! CALL MAPL_GetResource(STATE, c_lfc_land,'C_LFC_LAND:', DEFAULT= 0.4, __RC__ ) +! CALL MAPL_GetResource(STATE,c_lfc_marine,'C_LFC_MARINE:', DEFAULT= 0.1, __RC__ ) - print*, "" - print*, "Hello from LOPEZ_FlashRate" - print*, "" - - print*, "im, jm, lm: ", im, jm, lm - print*, "FRLAND: ", minval(FRLAND), maxval(FRLAND) - print*, "CAPE: ", minval(CAPE), maxval(CAPE) - print*, "ZLE: ", minval(ZLE), maxval(ZLE) - print*, "PFI_CN_GF ", minval(PFI_CN_GF), maxval(PFI_CN_GF) - print*, "TE: ", minval(TE), maxval(TE) - print*, "PLO: ", minval(PLO), maxval(PLO) - print*, "CNV_QC: ", minval(CNV_QC), maxval(CNV_QC) - print*, "zkbcon: ", minval(zkbcon), maxval(zkbcon) - DO j = 1, jm DO i = 1, im LFR_Lopez(i,j) = 0.0 - if(ZKBCON(i,j) <= 0. .or. CAPE(i,j) == MAPL_UNDEF) cycle !-> no convection - beta= frland(i,j)*beta_land + (1.-frland(i,j))*beta_ocean + !!! z_base - as computed in MINDS: + IF (FROCEAN(i,j) >= f_oc_thresh) THEN + z_base = c_lfc_marine * ZLFC(i,j) + (1.0 - c_lfc_marine) * ZLCL(i,j) + ELSE + z_base = c_lfc_land * ZLFC(i,j) + (1.0 - c_lfc_land ) * ZLCL(i,j) + END IF + + z_base = z_base * 0.001 - cb_min + z_base = MAX(z_base, 0.0) + + +! beta= frland(i,j)*b_land + (1.-frland(i,j))*b_marine + beta= frocean(i,j)*b_marine + (1.-frocean(i,j))*b_land + q_graup(:) = 0. q_snow (:) = 0. - do k=lm,1,-1 + do k=1,lm rho(k) = 100.*PLO(i,j,k) / (MAPL_RGAS*TE(i,j,k) ) - prec_flx_fr = PFI_CN_GF(i,j,k) / rho(k) + prec_flx_fr = (( PFI_CN_GF(i,j,k ) + & + PFI_CN_GF(i,j,k-1) ) * 0.5 ) / rho(k) q_graup(k) = beta *prec_flx_fr/V_graup ! - graupel mixing ratio (kg/kg) q_snow (k) = (1.-beta)*prec_flx_fr/V_snow ! - snow mixing ratio (kg/kg) enddo + + if(z_base <= 0. .or. CAPE(i,j) == MAPL_UNDEF) cycle !-> no convection + k_initial = minloc(abs(te(i,j,:)-t_initial),1) k_final = minloc(abs(te(i,j,:)-t_final ),1) @@ -1574,7 +1692,7 @@ subroutine LOPEZ_FlashRate(IM, JM, LM, FRLAND, ZKBCON, CAPE, & endif if ( te(i,j,k) < t_final ) exit enddo - print*,'K final, initial: ', k_final, k_initial +! print*,'K final, initial: ', k_final, k_initial Q_R = 0.0 do k = k_final, k_initial @@ -1584,7 +1702,6 @@ subroutine LOPEZ_FlashRate(IM, JM, LM, FRLAND, ZKBCON, CAPE, & Q_R = Q_R + dz*rho(k)*(q_graup(k)*(CNV_QC(i,j,k)+q_snow(k))) enddo - z_base = ZKBCON(i,j)/1000. !- convert to [km] !--- lightning flash density (units: number of flashes/km2/day) - equation 5 !--- (to compare with Lopez 2016's results, convert to per year: LFR_Lopez*365) diff --git a/Shared/Chem_Shared/SZA_from_MAPL_mod.F90 b/Shared/Chem_Shared/SZA_from_MAPL_mod.F90 new file mode 100644 index 00000000..5d37d83d --- /dev/null +++ b/Shared/Chem_Shared/SZA_from_MAPL_mod.F90 @@ -0,0 +1,209 @@ +module SZA_from_MAPL_mod + +#include "MAPL_Generic.h" + +!---------------------------------------------------------------------- +!BOP + +! !MODULE: + +! SZA_from_MAPL_mod -- Call MAPL routine for Solar Zenith Angle + +! !USES: + +use ESMF +use MAPL + +!use GEOS_UtilsMod +! +!use, intrinsic :: iso_fortran_env, only: REAL64 + + + IMPLICIT NONE + INTEGER, PARAMETER :: DBL = KIND(0.00D+00) + + PRIVATE + + +! PUBLIC MEMBER FUNCTIONS: +! + + PUBLIC :: compute_SZA + + interface compute_SZA + module procedure compute_sza_main ! args include LONS, LATS, ORBIT + module procedure compute_sza_wrapper_1 ! args include GC + end interface compute_SZA + + + +! !PARAMETERS: + + +! !DESCRIPTION: + +! This module provides a routine to determine Solar Zenith Angle +! using the MAPL routine MAPL_SunGetInsolation. +! +! !REVISION HISTORY: +! +! March 15 2023 - Mike Manyin - Adapted from GMI photolysis code +! +!EOP +!------------------------------------------------------------------------- + + +contains + + +!----------------------------------------------------------------------- +!BOP +! !IROUTINE: compute_sza_main +! +! !DESCRIPTION: +! +! ORIGIN AND CONTACT +! +! !REVISION HISTORY: +! 15 Mar 2023 Manyin First crack +!EOP +!----------------------------------------------------------------------- + +subroutine compute_sza_main ( LONS, LATS, ORBIT, CLOCK, tdt, label, SZA, RC ) + + REAL, intent(in) :: LONS (:,:) ! radians + REAL, intent(in) :: LATS (:,:) ! radians + TYPE(MAPL_SunOrbit), intent(in) :: ORBIT + TYPE(ESMF_Clock), intent(in) :: CLOCK + REAL, intent(in) :: tdt ! caller's timestep (sec) + CHARACTER(LEN=*), intent(in) :: label ! name of caller + REAL(KIND=DBL), intent(out) :: SZA (:,:) ! degrees + INTEGER, OPTIONAL, intent(out) :: RC + +! LOCAL + REAL, ALLOCATABLE :: ZTH(:,:) + REAL, ALLOCATABLE :: SLR(:,:) + REAL, ALLOCATABLE :: ZTHP(:,:) ! if SZA becomes Single Precision, we can use it as ZTHP + + INTEGER :: IM, JM ! array dimensions + + REAL :: pi,radToDeg + + TYPE (ESMF_TimeInterval) :: CALLER_timestep + TYPE (ESMF_TimeInterval) :: MAPL_timestep + TYPE (ESMF_Time) :: CURRENTTIME + TYPE (ESMF_Time) :: SZA_start_time ! compute average SZA starting at this time + TYPE (ESMF_Time) :: SZA_midpoint + + LOGICAL :: verbose_time ! To see details on SZA time averaging + + INTEGER :: STATUS + CHARACTER(LEN=*), PARAMETER :: IAm = 'compute_sza_main' + + verbose_time = .TRUE. + + + IM = SIZE(LONS,1) + JM = SIZE(LONS,2) + + ALLOCATE( ZTH(IM,JM), SLR(IM,JM), ZTHP(IM,JM), __STAT__ ) + + call ESMF_ClockGet(CLOCK, TIMESTEP=MAPL_timestep, currTIME=CURRENTTIME, __RC__ ) + + IF( verbose_time .AND. MAPL_AM_I_ROOT() ) THEN + call ESMF_TimePrint(CURRENTTIME, preString="CURRENTTIME = ", __RC__ ) + print *, "MAPL_timestep = " + call ESMF_TimeIntervalPrint(MAPL_timestep, options="string", __RC__ ) + ENDIF + + call ESMF_TimeIntervalSet(CALLER_timestep, s=INT(tdt+0.1), __RC__ ) + + IF( verbose_time .AND. MAPL_AM_I_ROOT() ) THEN + print *, TRIM(label)//" timestep = " + call ESMF_TimeIntervalPrint(CALLER_timestep, options="string", __RC__ ) + print *, "computing SZA w/ tdt = ", tdt + ENDIF + + ! We want a starting time = MAPL time + 1/2 MAPL timestep - 1/2 CALLER timestep + ! We want a time interval == CALLER timestep + + ! Position SZA_midpoint to be midpoint of MAPL_timestep + SZA_midpoint = CURRENTTIME + (MAPL_timestep/2) + + ! Position SZA_start_time to be half of a CALLER timestep earlier + SZA_start_time = SZA_midpoint - (CALLER_timestep/2) + + IF( verbose_time .AND. MAPL_AM_I_ROOT() ) THEN + call ESMF_TimePrint(SZA_start_time, preString=TRIM(label)//" SZA averaging start_time = ", __RC__ ) + call ESMF_TimePrint(SZA_start_time+CALLER_timestep, preString=TRIM(label)//" SZA averaging end_time = ", __RC__ ) + ENDIF + + + ! For more complete calling sequence, see SOLAR GridComp + + CALL MAPL_SunGetInsolation( & + LONS = LONS, & + LATS = LATS, & + ORBIT = ORBIT, & + ZTH = ZTH, & + SLR = SLR, & + CURRTIME = SZA_start_time, & + INTV = CALLER_timestep, & + ZTHP = ZTHP, & + __RC__ ) + + + pi = 4.00*ATAN(1.00) ! LATER replace with the MAPL version + radToDeg = 180.00/pi + + SZA = ACOS( ZTHP ) * radToDeg + + DEALLOCATE( ZTH, SLR, ZTHP, __STAT__ ) + + RETURN_(ESMF_SUCCESS) + +end subroutine compute_sza_main + + +!----------------------------------------------------------------------- +!BOP +! !IROUTINE: compute_sza_wrapper_1 +! +! !DESCRIPTION: +! +! ORIGIN AND CONTACT +! +! !REVISION HISTORY: +! 16 Mar 2023 Manyin First crack +!EOP +!----------------------------------------------------------------------- + +subroutine compute_sza_wrapper_1 ( GC, CLOCK, tdt, label, SZA, RC ) + + TYPE(ESMF_GridComp), intent(inout) :: GC + TYPE(ESMF_Clock), intent(in ) :: CLOCK + REAL, intent(in ) :: tdt ! caller's timestep (sec) + CHARACTER(LEN=*), intent(in ) :: label ! name of caller + REAL(KIND=DBL), intent( out) :: SZA (:,:) ! degrees + INTEGER, OPTIONAL, intent( out) :: RC + +! LOCAL + INTEGER :: STATUS + CHARACTER(LEN=*), PARAMETER :: IAm = 'compute_sza_wrapper_1' + + TYPE(MAPL_MetaComp), POINTER :: MAPLobj ! GEOS Generic State + REAL, POINTER, DIMENSION(:,:) :: LONS ! radians + REAL, POINTER, DIMENSION(:,:) :: LATS ! radians + TYPE(MAPL_SunOrbit) :: ORBIT + + CALL MAPL_GetObjectFromGC ( GC, MAPLobj, __RC__ ) + CALL MAPL_Get ( MAPLobj, LONS=LONS, LATS=LATS, ORBIT=ORBIT, __RC__ ) + + CALL compute_sza_main ( LONS=LONS, LATS=LATS, ORBIT=ORBIT, CLOCK=CLOCK, tdt=tdt, label=label, SZA=SZA, __RC__ ) + + RETURN_(ESMF_SUCCESS) + +end subroutine compute_sza_wrapper_1 + + + end module SZA_from_MAPL_mod diff --git a/Shared/HEMCO/CMakeLists.txt b/Shared/HEMCO/CMakeLists.txt index f302f6c6..39141c66 100644 --- a/Shared/HEMCO/CMakeLists.txt +++ b/Shared/HEMCO/CMakeLists.txt @@ -44,7 +44,7 @@ list (REMOVE_ITEM srcs esma_add_library (${this} SRCS ${srcs} - DEPENDENCIES MAPL esmf NetCDF::NetCDF_Fortran + DEPENDENCIES MAPL ESMF::ESMF NetCDF::NetCDF_Fortran ) target_compile_definitions (${this} PRIVATE ESMF_ USE_REAL8 MODEL_GEOS)