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

Most of the scripts have a '2' appended to the filename, as they have evolved over the years,
and I left the '2' on those script names for consistency with those that we use
operationally for OAQPS model runs.  Also, for that same consistency, I did not clean up any
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/01/2023

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

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


0. The driver script calls all the model post-processing scripts prior to creating the SMAT input files (Steps 1-7 below).
job script:		./scripts/driver.job2_4SMAT

1. Convert CAMx output (.avrg) files to IOAPI/netCDF (.ncf)
job script:		./scripts/convert.avrg+rt.job
source code:		./src/camx2ioapi_v6/camx2ioapi.f
output dir:		/asm/ROMO/2016platform/CAMx_v7.10/2016gf_lnox_beis4_v7.10_CB6r5_GEOS_Chem/12US2/temp12/
output files:		2016***.12US2.35.2016fj_v7.10_CB6r5.cf2e.epa.camx.avrg.ncf

2. Run combine for desired hourly output species
job script:		./scripts/run_combine.aconc.extra.csh2
source code:		./src/BLD_combine_v531_intel18.0
species definitions:	./anc/SpecDef_cb6r4DMS_SOAP2.2_CAMx7.0_13May19.20XXfj_cf2e_smat.v2.txt
output dir:		/asm/ROMO/2016platform/CAMx_v7.10/2016gf_lnox_beis4_v7.10_CB6r5_GEOS_Chem/12US2/POST12/
output files:		combine.aconc.2016gf_v7.10_CB6r5.cf2e.12US2.2016**.p1.ncf	### 'p1' denotes 1 extra day needed for LST

3. Create dailyavg files with local time (LST)
job script:		./scripts/run_hr2day.Y.all.avg_24.csh2
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_v531_intel18.0
output dir:		/asm/ROMO/2016platform/CAMx_v7.10/2016gf_lnox_beis4_v7.10_CB6r5_GEOS_Chem/12US2/POST12/dailyavg/
output files:		dailyavg.LST.Y_24.2016gf_v7.10_CB6r5.cf2e.12US2.**.p1.ncf	### 'p1' denotes 1 extra day needed for LST in prior step

4. Take off extra day in each month
job script:		./scripts/m3xtract.aconc.csh2
executable:		/usr/local/apps/ioapi-3.2/intel-17.0/bin/m3xtract
output dir:		/asm/ROMO/2016platform/CAMx_v7.10/2016gf_lnox_beis4_v7.10_CB6r5_GEOS_Chem/12US2/POST12/dailyavg/
output files:		dailyavg.LST.Y_24.2016gf_v7.10_CB6r5.cf2e.12US2.**.ncf

5. Create daily O3 metrics (MDA8 and MDA1)
job script:		./scripts/run_hr2day.Y_24.O3.csh2
input files:		combine.aconc.2016gf_v7.10_CB6r5.cf2e.12US2.2016**.p1.ncf	### output of Step 2 above (combine)
MDA8 species def:	setenv SPECIES_1 "O3_8HRMAX,ppbV,O3,8HRMAX"			### Maximum Daily 8-hr Average Ozone
MDA1 species def:	setenv SPECIES_2 "O3_HRMAX,ppbV,O3,MAX"				### Maximum Daily 1-hr Average Ozone
source code:		./src/BLD_hr2day_v531_intel18.0
output dir:		/asm/ROMO/2016platform/CAMx_v7.10/2016gf_lnox_beis4_v7.10_CB6r5_GEOS_Chem/12US2/POST12/O3/
output files:		O3.LST.Y_24.2016gf_v7.10_CB6r5.cf2e.12US2.**.p1.ncf		### 'p1' denotes 1 extra day needed for LST in prior step

6. Take off extra day in each month
job script:		./scripts/m3xtract.O3.csh2
executable:		/usr/local/apps/ioapi-3.2/intel-17.0/bin/m3xtract
output dir:		/asm/ROMO/2016platform/CAMx_v7.10/2016gf_lnox_beis4_v7.10_CB6r5_GEOS_Chem/12US2/POST12/O3/
output files:		O3.LST.Y_24.2016gf_v7.10_CB6r5.cf2e.12US2.**.ncf

7. Run m3xtract to concatenate different sets of months together for MDA8 (O3_8HRMAX) and MDA1 (O3_HRMAX)
executable:		/usr/local/apps/ioapi-3.2/intel-17.0/bin/m3xtract
output dir:		/asm/ROMO/2016platform/CAMx_v7.10/2016gf_lnox_beis4_v7.10_CB6r5_GEOS_Chem/12US2/POST12/O3/
script:			./scripts/m3xtract.O3_8HRMAX.5-9.csh2				### put May-Sep together into a single file for MDA8 (O3_8HRMAX)
script:			./scripts/m3xtract.O3_8HRMAX.4-9.csh2				### put Apr-Sep together into a single file for MDA8 (O3_8HRMAX)
script:			./scripts/m3xtract.O3_HRMAX.4-9.csh2				### put Apr-Sep together into a single file for MDA1 (O3_HRMAX)
script:			./scripts/m3xtract.O3_8HRMAX.1-12.csh2				### put Jan-Dec together into a single file for MDA8 (O3_8HRMAX)
output file:		O3_8HRMAX.LST.Y_24.2016gf_v7.10_CB6r5.cf2e.12US2.5-9.ncf
output file:		O3_8HRMAX.LST.Y_24.2016gf_v7.10_CB6r5.cf2e.12US2.4-9.ncf
output file:		O3_HRMAX.LST.Y_24.2016gf_v7.10_CB6r5.cf2e.12US2.4-9.ncf		
output file:		O3_8HRMAX.LST.Y_24.2016gf_v7.10_CB6r5.cf2e.12US2.1-12.ncf	### usually in standard post-processing, but never used to make SMAT input files

8. Make O3 SMAT input file(s)
job script:		./scripts/make_SMAT-CE_input.O3_MDAx.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)
input files:		O3_*HRMAX.LST.Y_24.2016gf_v7.10_CB6r5.cf2e.12US2.*-*.ncf	### O3 SMAT input files can be made for MDA8 or MDA1, for different month ranges
output file:		smat.O3_MDA*.CAMx.12US2.2016gf_v7.10_CB6r5.*-*.csv		### full grid ('large') SMAT input file with each day in month range (eg, May-Sep or '5-9')
output file:		smat_small.O3_MDA*.CAMx.12US2.2016gf_v7.10_CB6r5.*-*.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

9. Make PM SMAT input file
job script:		./scripts/make_SMAT-CE_input.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:		dailyavg.LST.Y_24.2016gf_v7.10_CB6r5.cf2e.12US2.**.ncf		### monthly output files from Step 4 for Jan-Nov (non-p1) or Step 3 for Dec (p1) 
output file:		smat.PM.CAMx.12US2.2016gf_v7.10_CB6r5.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

