From a99a1c544ecad8cd784ba0c8fd2412f6ea0f0566 Mon Sep 17 00:00:00 2001 From: Mike Manyin Date: Tue, 19 Dec 2023 09:54:27 -0500 Subject: [PATCH 1/2] Added ExtData Boundary Conditions, with example dataset for CH4. OFF by default --- GMI_GridComp/GMI_ExtData.yaml | 4 +- .../StratTrop_HFC_S/GMI_GridComp.rc | 9 ++ .../StratTrop_Orig/GMI_GridComp.rc | 9 ++ .../GmiForcingBC_GridCompClassMod.F90 | 90 ++++++++++++++++--- GMIchem_GridCompMod.F90 | 33 ++++++- 5 files changed, 131 insertions(+), 14 deletions(-) diff --git a/GMI_GridComp/GMI_ExtData.yaml b/GMI_GridComp/GMI_ExtData.yaml index 3b8f090..f355950 100644 --- a/GMI_GridComp/GMI_ExtData.yaml +++ b/GMI_GridComp/GMI_ExtData.yaml @@ -6,7 +6,7 @@ Collections: ## Monthly values - GMI.CH4_surf_values.clim: { template: /gpfsm/dnb33/mmanyin/CCM/run/aug2_GMI/aug2_GMI.test_ch4.20500315_1200z.nc4 } + GMI.CH4_surf_values.monthly.2000-2009: { valid_range: "2000-01-16T12:00/2009-12-16T12:00", template: /discover/nobackup/mmanyin/CCM/CH4/qOHreplay2.CH4_at_surface.%y4%m2.nc4 } GMI.CMIP6_BB.emis.monthly.1950-2015: { valid_range: "1950-01-16T00:00/2015-12-16T00:00", template: ExtData/CMIP6/sfc/biomass_burning/CMIP6_BB.emis.x1440_y720_t12.%y4.nc4 } GMI.CMIP6_BB_SSP245.emis.monthly.2015-2100: { valid_range: "2015-01-16T00:00/2100-12-16T00:00", template: /discover/nobackup/projects/gmao/ccmdev/input/emissions/SSP/sfc/CMIP6_BB.ssp2_45.emis.x720_y360_t12.%y4.nc4 } @@ -259,4 +259,4 @@ Exports: du004: { variable: DU004, collection: GMI.aero_MERRA2.monthly_clim, regrid: CONSERVE, sample: GMI.daily_wrap } du005: { variable: DU005, collection: GMI.aero_MERRA2.monthly_clim, regrid: CONSERVE, sample: GMI.daily_wrap } - CH4_BC: { variable: CH4, collection: GMI.CH4_surf_values.clim, regrid: CONSERVE, sample: GMI.constant } + CH4_BC: { variable: CH4, collection: GMI.CH4_surf_values.monthly.2000-2009, regrid: CONSERVE, sample: GMI.daily_wrap } diff --git a/GMI_GridComp/GmiChemistry/StratTrop_HFC_S/GMI_GridComp.rc b/GMI_GridComp/GmiChemistry/StratTrop_HFC_S/GMI_GridComp.rc index 626197d..af23672 100644 --- a/GMI_GridComp/GmiChemistry/StratTrop_HFC_S/GMI_GridComp.rc +++ b/GMI_GridComp/GmiChemistry/StratTrop_HFC_S/GMI_GridComp.rc @@ -327,6 +327,15 @@ xxx # The xxx entries above are for SF6 and CO2 + ########################################################### + # GHG and ODS surface source gases - read with ExtData + ########################################################### +ext_bc_kmin: 1 +ext_bc_kmax: 2 +extdataBcSpeciesNames:: +#CH4 +:: + # ---------------------------------------------------- # sad_opt diff --git a/GMI_GridComp/GmiChemistry/StratTrop_Orig/GMI_GridComp.rc b/GMI_GridComp/GmiChemistry/StratTrop_Orig/GMI_GridComp.rc index b2a24a5..5b6eaf3 100644 --- a/GMI_GridComp/GmiChemistry/StratTrop_Orig/GMI_GridComp.rc +++ b/GMI_GridComp/GmiChemistry/StratTrop_Orig/GMI_GridComp.rc @@ -316,6 +316,15 @@ xxx # The xxx entries above are for HFC23 HFC32 HFC125 HFC134A HFC143A HFC152A SF6 and CO2 + ########################################################### + # GHG and ODS surface source gases - read with ExtData + ########################################################### +ext_bc_kmin: 1 +ext_bc_kmax: 2 +extdataBcSpeciesNames:: +#CH4 +:: + # ---------------------------------------------------- # sad_opt diff --git a/GMI_GridComp/GmiForcingBC_GridCompClassMod.F90 b/GMI_GridComp/GmiForcingBC_GridCompClassMod.F90 index 75e43c4..5d3de4d 100755 --- a/GMI_GridComp/GmiForcingBC_GridCompClassMod.F90 +++ b/GMI_GridComp/GmiForcingBC_GridCompClassMod.F90 @@ -17,7 +17,7 @@ MODULE GmiForcingBC_GCCMod USE ESMF USE MAPL - USE Chem_Mod ! Chemistry Base Class + USE Chem_Mod ! Chemistry Base Class USE Chem_UtilMod USE Species_BundleMod @@ -86,9 +86,13 @@ MODULE GmiForcingBC_GCCMod integer :: forc_bc_years integer :: forc_bc_start_num integer :: forc_bc_kmin + integer :: ext_bc_kmin integer :: forc_bc_kmax + integer :: ext_bc_kmax integer :: forc_bc_num + integer :: ext_bc_count integer :: forc_bc_map (MAX_NUM_CONST) + integer :: ext_bc_map (MAX_NUM_CONST) real*8 :: forc_bc_init_val real*8 :: forc_bc_incrpyr real*8 :: forc_bc_lz_val @@ -189,7 +193,8 @@ SUBROUTINE GmiForcingBC_GridCompInitialize( self, bgg, bxx, impChem, expChem, ny CHARACTER(LEN=255) :: importRestartFile CHARACTER(LEN=255) :: string character (len=MAX_LENGTH_SPECIES_NAME), pointer :: tempListNames(:) - character (len=MAX_STRING_LENGTH ) :: forcedBcSpeciesNames + character (len=MAX_STRING_LENGTH ) :: forcedBcSpeciesNames + character (len=MAX_STRING_LENGTH ) :: extdataBcSpeciesNames type (ESMF_Config) :: gmiConfigFile @@ -326,15 +331,31 @@ SUBROUTINE GmiForcingBC_GridCompInitialize( self, bgg, bxx, impChem, expChem, ny & default = 1, rc=STATUS ) VERIFY_(STATUS) + call ESMF_ConfigGetAttribute(gmiConfigFile, self%ext_bc_kmin, & + & label = "ext_bc_kmin:", & + & default = 1, rc=STATUS ) + VERIFY_(STATUS) + call ESMF_ConfigGetAttribute(gmiConfigFile, self%forc_bc_kmax, & & label = "forc_bc_kmax:", & & default = 1, rc=STATUS ) VERIFY_(STATUS) + call ESMF_ConfigGetAttribute(gmiConfigFile, self%ext_bc_kmax, & + & label = "ext_bc_kmax:", & + & default = 1, rc=STATUS ) + VERIFY_(STATUS) + self%forc_bc_map(:) = 0 + self%ext_bc_map(:) = 0 call rcEsmfReadTable(gmiConfigFile, forcedBcSpeciesNames, & & "forcedBcSpeciesNames::", rc=STATUS) + VERIFY_(STATUS) + + call rcEsmfReadTable(gmiConfigFile, extdataBcSpeciesNames, & + & "extdataBcSpeciesNames::", rc=STATUS) + VERIFY_(STATUS) call ESMF_ConfigGetAttribute(gmiConfigFile, self%forc_bc_init_val, & & label = "forc_bc_init_val:", & @@ -371,7 +392,7 @@ SUBROUTINE GmiForcingBC_GridCompInitialize( self, bgg, bxx, impChem, expChem, ny IF (rootProc) THEN PRINT *," " - PRINT *,"Number of GHG and ODP gases: ",self%forc_bc_num + PRINT *,"Number of ASCII GHG and ODP gases: ",self%forc_bc_num PRINT *," " PRINT *,"forc_bc_map:" PRINT *, self%forc_bc_map @@ -380,6 +401,34 @@ SUBROUTINE GmiForcingBC_GridCompInitialize( self, bgg, bxx, impChem, expChem, ny end if + + !! Now do ExtData (ext) same as ASCII (forc): + + ! Set the initial value of the list + ! allocate(tempListNames(NSP)) already done above + tempListNames(:) = '' + + ! Construct the list of names using the long string + call constructListNames(tempListNames, extdataBcSpeciesNames) + + + self%ext_bc_count = Count (tempListNames(:) /= '') + if (self%ext_bc_count > 0) then + do ic = 1, self%ext_bc_count + self%ext_bc_map(ic) = getSpeciesIndex(tempListNames(ic)) + end do + + IF (rootProc) THEN + PRINT *," " + PRINT *,"Number of ExtData GHG and ODP gases: ",self%ext_bc_count + PRINT *," " + PRINT *,"ext_bc_map:" + PRINT *, self%ext_bc_map + PRINT *," " + END IF + + end if + deallocate(tempListNames) ! Does the GMICHEM import restart file exist? If not, @@ -637,6 +686,8 @@ SUBROUTINE GmiForcingBC_GridCompRun ( self, bgg, bxx, impChem, expChem, nymd, nh CHARACTER(LEN=255) :: speciesName CHARACTER(LEN=255) :: importName + REAL, POINTER, DIMENSION(:,:) :: PTR2D + LOGICAL :: found, rootProc LOGICAL, PARAMETER :: doThis = .FALSE. @@ -734,16 +785,33 @@ SUBROUTINE GmiForcingBC_GridCompRun ( self, bgg, bxx, impChem, expChem, nymd, nh ! ------------------------------------------------------------------------ IF (self%gotImportRst) then + + ! ASCII if (self%forc_bc_num > 0) then - call updateForcingBC (self%forc_bc_data, & - self%SpeciesConcentration%concentration, self%jlatmd, & - & self%last_year, nymd, gmi_sec, self%fbc_j1, self%fbc_j2, & - & self%forc_bc_num, self%forc_bc_kmax, self%forc_bc_kmin, & - & self%forc_bc_opt, self%forc_bc_map, self%forc_bc_incrpyr, & - & self%forc_bc_start_num, self%forc_bc_years, self%gmiGrid%i1, & - & self%gmiGrid%i2, self%gmiGrid%ju1, self%gmiGrid%j2, & - & self%gmiGrid%k1, self%gmiGrid%k2, NSP) + call updateForcingBC (self%forc_bc_data, & + self%SpeciesConcentration%concentration, self%jlatmd, & + self%last_year, nymd, gmi_sec, self%fbc_j1, self%fbc_j2, & + self%forc_bc_num, self%forc_bc_kmax, self%forc_bc_kmin, & + self%forc_bc_opt, self%forc_bc_map, self%forc_bc_incrpyr, & + self%forc_bc_start_num, self%forc_bc_years, self%gmiGrid%i1, & + self%gmiGrid%i2, self%gmiGrid%ju1, self%gmiGrid%j2, & + self%gmiGrid%k1, self%gmiGrid%k2, NSP) + end if + + ! ExtData + if (self%ext_bc_count > 0) then + DO ic = 1,self%ext_bc_count + speciesName = TRIM(lchemvar(self%ext_bc_map(ic))) + importName = TRIM(speciesName)//'_BC' + CALL MAPL_GetPointer(impChem, PTR2D, TRIM(importName), RC=STATUS) + VERIFY_(STATUS) + + do k = self%ext_bc_kmin,self%ext_bc_kmax + self%SpeciesConcentration%concentration(self%ext_bc_map(ic))%pArray3D(:,:,k) = PTR2D(:,:) + end do + end do end if + END IF ! Return species concentrations to the chemistry bundle diff --git a/GMIchem_GridCompMod.F90 b/GMIchem_GridCompMod.F90 index 1c8e28c..ddfd28c 100644 --- a/GMIchem_GridCompMod.F90 +++ b/GMIchem_GridCompMod.F90 @@ -17,11 +17,13 @@ MODULE GMIchem_GridCompMod USE MAPL USE Runtime_RegistryMod USE Species_BundleMod - USE Chem_Mod ! Chemistry Base Class + USE Chem_Mod ! Chemistry Base Class USE GMI_GridCompMod ! ESMF parent component USE Chem_UtilMod, ONLY : Chem_UtilNegFiller ! Eliminates negative vmr USE Chem_GroupMod ! For Family Transport USE OVP, ONLY: OVP_init, OVP_end_of_timestep_hms, OVP_mask, OVP_apply_mask + USE GmiESMFrcFileReading_mod, ONLY : rcEsmfReadTable + USE GmiStringManipulation_mod, ONLY : constructListNames IMPLICIT NONE PRIVATE @@ -35,6 +37,10 @@ MODULE GMIchem_GridCompMod INTEGER, SAVE :: OVP_GC_DT INTEGER, SAVE :: OVP_MASK_DT +#include "setkin_par.h" +#include "GmiParameters.h" + + ! ! !PUBLIC MEMBER FUNCTIONS: ! @@ -150,6 +156,10 @@ SUBROUTINE SetServices ( GC, RC ) TYPE (ESMF_Config) :: gmi_config LOGICAL :: doMEGANviaHEMCO + CHARACTER (LEN=MAX_STRING_LENGTH) :: extdataBcSpeciesNames + CHARACTER (LEN=MAX_LENGTH_SPECIES_NAME), pointer :: tempListNames(:) + INTEGER :: bc_count, ic + ! Get my name and set-up traceback handle ! --------------------------------------- call ESMF_GridCompGet( GC, NAME=COMP_NAME, CONFIG=CF, RC=STATUS ) @@ -343,6 +353,27 @@ SUBROUTINE SetServices ( GC, RC ) call ESMF_ConfigLoadFile(gmiConfig, 'GMI_GridComp.rc', __RC__) + ! This duplicates the call in the Forced BC code; really should only be done once! + call rcEsmfReadTable(gmiConfig, extdataBcSpeciesNames, "extdataBcSpeciesNames::", __RC__) + + ! Set the initial value of the list + allocate(tempListNames(NSP)) + tempListNames(:) = '' + + call constructListNames(tempListNames, extdataBcSpeciesNames) + + bc_count = COUNT (tempListNames(:) /= '') + do ic = 1, bc_count + call MAPL_AddImportSpec(GC, & + SHORT_NAME = TRIM(tempListNames(ic))//'_BC', & + LONG_NAME = 'Surface BC for '//TRIM(tempListNames(ic)), & + UNITS = 'mol mol-1', & + DIMS = MAPL_DimsHorzOnly, & + VLOCATION = MAPL_VLocationNone, __RC__) + end do + + deallocate(tempListNames) + ! This duplicates the call in the Emissions code; really should only be done once! ! call rcEsmfReadLogical(gmiConfig, do_ShipEmission, "do_ShipEmission:", default=.false., __RC__) CALL ESMF_ConfigGetAttribute(gmiConfig, value= do_ShipEmission, Default=.false., & From 0e68e4b5f64c6abaa53cd45c1ada8ae94f599b87 Mon Sep 17 00:00:00 2001 From: Mike Manyin Date: Tue, 19 Dec 2023 10:02:06 -0500 Subject: [PATCH 2/2] edit CHANGELOG --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6894346..b21eaf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Fixed ### Added + +- Capability to use 2D ExtData files as Boundary Conditions + ### Changed ### Removed ### Deprecated