This readme lists the scripts and programs to create O3 and PM SMAT-CE input files
from the raw CMAQ output files, along with additional notes/comments where necessary.
The example scripts provided are those used for 2016fm_16j_cb6r3_ae7_aq_nvpoa
(more simply '2016fm'), possibly with minor modifications regarding pathnames.
The internal pathnames and scenario names can be easily updated for future years.

Also, for that same consistency, I did not clean up many
of the commented-out and/or obsolete lines inside those post-processing scripts, as they
are identical to those we use.  The only changes needed should be the pathnames for the
input/output/ancillary files and the scenario information in the driver script.

-D. Ensley, GDIT, 06/02/2023

------------------------------------------------------------------------------------------

job directory:		/work/ROMO/users/hou/116.15/task17/cmaq2smat


0. The setup and driver scripts call all the model post-processing scripts prior to creating the SMAT input files.
setup script:		./scripts/wgs1.csh						### executes gendriv.csh
driver script:		./scripts/gendriv.csh						### calls the scripts for Steps 1-7 below

1. Run combine for desired hourly output species
job script:		./scripts/run_combine.csh
source code:		./src/BLD_combine_v53_intel17.0
species definitions:	./anc/SpecDef_cb6r3_ae7_aq.txt
output dir:		/asm1/ROMO/2016platform/CMAQv532/2016fm_cb6r3_ae7nvpoa_16j/12US2/extr/2016**
output files:		combine_aconc_2016fm_16j_cb6r3_ae7_aq_nvpoa.v532_m3dry.12US2_35_2016**

2. Create dailyavg aconc files with local time (LST)
job script:		./scripts/run_hr2day.csh
ancillary script:	./scripts/varas.csh						### called by job script, can list all species from combine file
ancillary input:	./anc/tz.csv							### required input file contains time zone data
source code:		./src/BLD_hr2day_v53_intel17.0
output dir:		/asm1/ROMO/2016platform/CMAQv532/2016fm_cb6r3_ae7nvpoa_16j/12US2/extr/2016**
output files:		hr2day_avg_aconc_LST_2016fm_16j_cb6r3_ae7_aq_nvpoa.v532_m3dry.12US2_35_2016**.p2	### 'p2' denotes 2 extra days

3. Create daily O3 metrics (MDA8 and MDA1) with local time (LST)
job script:		./scripts/run_hr2day.csh
ancillary script:	./scripts/varas.csh						### called by job script, can list all species from combine file
ancillary input:	./anc/tz.csv							### required input file contains time zone data
source code:		./src/BLD_hr2day_v53_intel17.0
MDA8 species def:	setenv SPECIES_1 "O3_8HRMAX,ppbV,O3,8HRMAX"			### Maximum Daily 8-hr Average Ozone
MDA1 species def:	setenv SPECIES_4 "O3_HRMAX,ppbV,O3,MAX"				### Maximum Daily 1-hr Average Ozone
output dir:		/asm1/ROMO/2016platform/CMAQv532/2016fm_cb6r3_ae7nvpoa_16j/12US2/extr/2016**
output files:		hr2day_O3_LST_2016fm_16j_cb6r3_ae7_aq_nvpoa.v532_m3dry.12US2_35_2016**.p2		### 'p2' denotes 2 extra days

4. Create daily hours 10to17 O3_AVG8 metric with local time (LST)
job script:		./scripts/run_hr2day.csh
ancillary script:	./scripts/varas.csh						### called by job script, can list all species from combine file
ancillary input:	./anc/tz.csv							### required input file contains time zone data
source code:		./src/BLD_hr2day_v53_intel17.0
AVG8 species def:	setenv SPECIES_1 "O3_AVG8,ppbV,O3,AVG"				### Daily Average Ozone between hour 10 through end of hour 17 (10a-6p LST endpoints)
output dir:		/asm1/ROMO/2016platform/CMAQv532/2016fm_cb6r3_ae7nvpoa_16j/12US2/extr/2016**
output files:		hr2day_O3_LST_10to17_2016fm_16j_cb6r3_ae7_aq_nvpoa.v532_m3dry.12US2_35_2016**.p2	### 'p2' denotes 2 extra days

5. Take off the prevday and lastday (.p2) from hr2day_avg_aconc_LST files with m3xtract
job script:		./scripts/m3xtr.csh
executable:		/usr/local/apps/ioapi-3.2/intel-17.0/bin/m3xtract
output dir:		/asm1/ROMO/2016platform/CMAQv532/2016fm_cb6r3_ae7nvpoa_16j/12US2/extr/2016**
output files:		hr2day_avg_aconc_LST_2016fm_16j_cb6r3_ae7_aq_nvpoa.v532_m3dry.12US2_35_2016**

6. Take off the prevday and lastday (.p2) from hr2day_O3_LST files with m3xtract
job script:		./scripts/m3xtr.csh
executable:		/usr/local/apps/ioapi-3.2/intel-17.0/bin/m3xtract
output dir:		/asm1/ROMO/2016platform/CMAQv532/2016fm_cb6r3_ae7nvpoa_16j/12US2/extr/2016**
output files:		hr2day_O3_LST_2016fm_16j_cb6r3_ae7_aq_nvpoa.v532_m3dry.12US2_35_2016**

7. Take off the prevday and lastday (.p2) from hr2day_O3_LST_10to17 files with m3xtract
job script:		./scripts/m3xtr.csh
executable:		/usr/local/apps/ioapi-3.2/intel-17.0/bin/m3xtract
output dir:		/asm1/ROMO/2016platform/CMAQv532/2016fm_cb6r3_ae7nvpoa_16j/12US2/extr/2016**
output files:		hr2day_O3_LST_10to17_2016fm_16j_cb6r3_ae7_aq_nvpoa.v532_m3dry.12US2_35_2016**

8. Run m3xtract to concatenate different sets of months together for MDA8 (O3_8HRMAX), MDA1 (O3_HRMAX) and AVG8
executable:		/usr/local/apps/ioapi-3.2/intel-17.0/bin/m3xtract
script:			./scripts/m3xtract.O3vars.csh
output file:		hr2day_O3_LST_2016fm_16j_cb6r3_ae7_aq_nvpoa.v532_m3dry.12US2_35_2016.MaySep.O3_8HRMAX		### single O3 m3xtract file for MDA8 for May-Sep
output file:		hr2day_O3_LST_2016fm_16j_cb6r3_ae7_aq_nvpoa.v532_m3dry.12US2_35_2016.AprSep.O3_8HRMAX		### single O3 m3xtract file for MDA8 for Apr-Sep
output file:		hr2day_O3_LST_2016fm_16j_cb6r3_ae7_aq_nvpoa.v532_m3dry.12US2_35_2016.AprSep.O3_HRMAX		### single O3 m3xtract file for MDA1 for Apr-Sep
output file:		hr2day_O3_LST_10to17_2016fm_16j_cb6r3_ae7_aq_nvpoa.v532_m3dry.12US2_35_2016.JunAug.O3_AVG8      ### single O3 m3xtract file for for AVG8 for Jun-Aug (AVG8 is 8-hr average O3 from 10-18 LST)

9. Make O3 SMAT input file(s)
job script:		./scripts/make_SMAT_input.CMAQ.wo2802.O3_multi.job
source code:		./src/model2smat/model2smat.O3_MDAx.*.F				### similar but separate programs for *base year* leap year or non-leap year
ancillary input:	./anc/cells/cellcoords.12US2.csv				### lat/lon info for every grid cell in 12US2 domain (396 Cols x 246 Rows)
ancillary input:	./anc/cells/cells.12US2.O3.2002-2019.Jul2021.fj.txt		### list of grid cells (colrow) to make 'small' SMAT input files (3x3 around each monitor)
output file:		smat.O3_****.CMAQ.12US2.2016fm_16j_cb6r3_ae7_aq_nvpoa.*-*.csv		### full grid ('large') SMAT input file with each day in month range (eg, May-Sep or '5-9')
output file:		smat_small.O3_****.CMAQ.12US2.2016fm_16j_cb6r3_ae7_aq_nvpoa.*-*.csv	### 'small' SMAT input file, with only the 3x3 grid cells surrounding monitors, for Design Value (DV) SMAT runs.
QA program:		./scripts/qc.smat_inputs.O3.sas					### outputs simple metrics of the SMAT input file for QA such as N, NMISS, MIN, MAX, MEAN MEDIAN

10. Make PM SMAT input file
job script:		./scripts/make_SMAT_input.CMAQ.wo2802.PM.job
source code:		./src/model2smat/model2smat.PM.*.F				### similar but separate programs for *base year* leap year or non-leap year
ancillary input:	./anc/cells/cellcoords.12US2.csv				### lat/lon info for every grid cell in 12US2 domain (396 Cols x 246 Rows)
ancillary input:	./anc/cells/cells.12US2.PM.2002-2017.May2019.txt		### used only as placeholder to make smat_small.PM*.csv file which is deleted because unnecessary for PM SMAT processing
input files:		hr2day_avg_aconc_LST_2016fm_16j_cb6r3_ae7_aq_nvpoa.v532_m3dry.12US2_35_2016**		### monthly output files from Step 5 above 
output file:		smat.PM.CMAQ.12US2.2016fm_16j_cb6r3_ae7_aq_nvpoa.csv		### full grid 'large' SMAT input file with each day of the year (365 or 366, depending on *base year* leap year or non-leap year)
QA program:		./scripts/qc.smat_inputs.PM.sas					### outputs simple metrics of the SMAT input file for QA such as N, NMISS, MIN, MAX, MEAN MEDIAN

