CEMPD / SMOKE

Create emissions inputs for multiple air quality modeling systems with unmatched speed and flexibility
https://www.cmascenter.org/smoke/
45 stars 21 forks source link

inventory error in Smkmerge when MRG_TEMPORAL_YN is N #82

Open cseppan opened 8 months ago

cseppan commented 8 months ago

After running the RWC sector using the training data, I tried to create a one-off script that would generate gridded emissions:

#!/bin/tcsh -f

source ../directory_definitions.csh

setenv MRG_SOURCE A  # type of source to be merged

setenv MRG_GRDOUT_YN    Y  # produce a gridded output file
setenv MRG_SPCMAT_YN    N  # don't produce speciated output
setenv MRG_TEMPORAL_YN  N  # don't produce temporally allocated output

setenv PROMPTFLAG N

setenv GRIDDESC "${GE_DAT}/gridding/griddesc_lambertonly_18jan2019_v7.txt"
setenv INVTABLE "${GE_DAT}/invtable_2014platform_integrate_21dec2018_v3.txt"
setenv COSTCY "${GE_DAT}/costcy_for_2017platform_20aug2020_v1.txt"

setenv IOAPI_GRIDNAME_1 $REGION_IOAPI_GRIDNAME

setenv AREA $IMD_ROOT/rwc/area_map_rwc_2018gg_18j.txt
setenv AGMAT $IMD_ROOT/rwc/agmat_rwc_12LISTOS_2018gg_18j.ncf

setenv AG $IMD_ROOT/rwc/ag.ncf

$RUNSCRIPTS/../Linux2_x86_64ifort/smkmerge

Smkmerge fails with the error

 *** ERROR ABORT in subroutine OPENMRGIN
 Number of map-formatted variables is inconsistent with header of  inventory file. 
      I/O API header has      16 variables indicated, but map-formated inventory file has      15

Looking at the RWC intermediate inventory data, the area_map_rwc_2018gg_18j.txt and area_rwc.ncf files are inconsistent.

hnqtran commented 5 months ago

Inconsistent in number of species appears to be caused by HAPS integration treatment. Depending on SMK_PROCESS_HAPS setting (e.g., "NONE" or "ALL"), area_map_rwc_2018gg_18j.txt may content map file for VOC along with VOC_INV, whereas area_rwc.ncf account for VOC.

hnqtran commented 4 months ago

The issue being isolated to the SETNONHAP subrountine ($SMOKE_HOME/src/smkinven/setnonhap.f)

The following is array of emitted species input to SETNONHAP when processing rwc source.

INVDNAME(  1) = FORMALD
INVDNAME(  5) = BENZENE
INVDNAME(  7) = ACETALD
INVDNAME(  9) = NAPHTH
INVDNAME( 11) = BUTADIE
INVDNAME( 12) = ACROLEI
INVDNAME( 22) = CO
INVDNAME( 79) = NH3
INVDNAME( 83) = NOX
INVDNAME( 88) = PM10
INVDNAME( 89) = PM2_5
INVDNAME(101) = SO2
INVDNAME(107) = VOC
INVDNAME(108) = VOC_INV

When SMK_PROCESS_HAPS is set to "ALL" or "PARTIAL", a new pollutant NONHAPVOC is calculated as the remainder of subtracting HAPs emission from VOC or TOG emission. Around code line 614 - 620, VOC is renamed to NONHAPVOC, and INVSTAT (which keeps track of which pollutants from the INTABLE are valid from input emission source) is activated for NONHAPVOC.

C.....................  Rename VOC to NONHAPVOC
C.....................  increment a number of poll for NONHAP[VOC|TOG]
                    NONVPOS = INDEX1( NONHAPNAM( K ), MXIDAT, INVDNAM )
                    IPOSCOD  ( VPOS )   = NONVPOS
                    TMPPOSCOD( NVPOS )  = NONVPOS
                    TMPPOLVAL( NVPOS,: )= POLVAL( VPOS,: )
                    INVSTAT  ( NONVPOS )= 2

Output array of emitted species from SETNONHAP when SMK_PROCESS_HAPS = 'ALL'

INVDNAME(  1) = FORMALD
INVDNAME(  5) = BENZENE
INVDNAME(  7) = ACETALD
INVDNAME(  9) = NAPHTH
INVDNAME( 11) = BUTADIE
INVDNAME( 12) = ACROLEI
INVDNAME( 22) = CO
INVDNAME( 79) = NH3
INVDNAME( 82) = NONHAPVOC
INVDNAME( 83) = NOX
INVDNAME( 88) = PM10
INVDNAME( 89) = PM2_5
INVDNAME(101) = SO2
INVDNAME(108) = VOC_INV

Note how VOC was renamed to NONHAPVOC, and the total number of species remain unchanged at 14. However, INVSTAT for VOC is still activated. This resulted in the total number of tracked pollutant increased by one (15) instead of remain unchanged (14).

Potential solution: deactivate INVSTAT for VOC when SMK_PROCESS_HAPS = 'ALL'

C  Add position index of VOC in INVSTAT
        INTEGER  VPOS_SAVE

then

                    VPOS_SAVE = IPOSCOD( VPOS )     ! UNC-IE, Feb 2024: Save location of VOC in INVSTAT
                    NONVPOS = INDEX1( NONHAPNAM( K ), MXIDAT, INVDNAM )
                    IPOSCOD  ( VPOS )   = NONVPOS
                    TMPPOSCOD( NVPOS )  = NONVPOS
                    TMPPOLVAL( NVPOS,: )= POLVAL( VPOS,: )
                    INVSTAT  ( NONVPOS )= 2
c                   UNC-IE: Feb 2024, as VOC is renamed to NONHAPVOC, 
c                           INVSTAT(NVPOS) should be set to zero when SMK_PROCESS_HAPS = 'ALL'
                    IF ( PROC_HAPS == 'ALL' ) INVSTAT ( VPOS_SAVE ) = 0