#!/bin/csh -f
#PBS -j oe
#PBS -r n

limit stacksize unlimited

setenv SECTOR "othpt"

if ($?PBS_O_WORKDIR) then
  cd $PBS_O_WORKDIR
endif

## Definitions for case name, directory structures, etc, that are used
#  by every sector in the case
#  Anything defined in directory_definitions can be overridden here 
#  if desired
source ../directory_definitions.csh

## Months for emissions processing, and spinup duration
#  In the EPA emissions modeling platforms, the only sectors that use
#  SPINUP_DURATION are biogenics and the final sector merge (Mrggrid).
#  Elsewhere, SPINUP_DURATION = 0, and when Mrggrid runs for spinup days,
#  base year emissions are used for the spinup year for all sectors except
#  biogenics.
#  SPINUP_DURATION does not always work when the first month of the run
#  is not January. That will be a future fix.
setenv RUN_MONTHS "1 2 3 4 5 6 7 8 9 10 11 12"
setenv SPINUP_DURATION "0"

## Emissions modeling year
#  (i.e. meteorological year, not necessarily the inventory year"
setenv BASE_YEAR "2014"
setenv EPI_STDATE_TIME "${BASE_YEAR}-01-01 00:00:00.0"
setenv EPI_ENDATE_TIME "${BASE_YEAR}-12-31 23:59:00.0"

## Inventory case name, if inventories are coming from a different case (they usually aren't)
#  CASEINPUTS is defined in directory_definitions and optionally overridden here
#setenv INVENTORY_CASE "2011ek_cb6v2_v6_11g"
#setenv CASEINPUTS "$INSTALL_DIR/$INVENTORY_CASE/inputs"

## Inputs for all sectors
setenv ATPRO_HOURLY_NCF "${GE_DAT}/temporal/Gentpro_TPRO_HOUR_HOURLY_BASH_NH3.agNH3_bash_2014fa_14j_12US2.ncf"
setenv SRGPRO "${GE_DAT}/gridding/CONUS12_2014_v1_10oct2016/USA_100_NOFILL.txt"
setenv MTPRO_HOURLY "${GE_DAT}/temporal/mtpro_hourly_MOVES_2014v1_platform_06jul2016_v0"
setenv MTPRO_WEEKLY "${GE_DAT}/temporal/mtpro_weekly_moves2014_13nov2014_v2"
#setenv PTPRO_HOURLY "${GE_DAT}/temporal/amptpro_general_2011platform_tpro_hourly_20oct2016_nf_v4"
#setenv PTPRO_MONTHLY "${GE_DAT}/temporal/amptpro_general_2011platform_tpro_monthly_31oct2016_nf_v6"
#setenv PTPRO_WEEKLY "${GE_DAT}/temporal/amptpro_general_2011platform_tpro_weekly_09sep2016_v2"
setenv ATPRO_HOURLY "${GE_DAT}/temporal/amptpro_general_2011platform_tpro_hourly_20oct2016_nf_v4"
setenv ATPRO_WEEKLY "${GE_DAT}/temporal/amptpro_general_2011platform_tpro_weekly_09sep2016_v2"
setenv ATPRO_MONTHLY "${GE_DAT}/temporal/amptpro_general_2011platform_tpro_monthly_31oct2016_nf_v6"
setenv MTPRO_MONTHLY "${GE_DAT}/temporal/mtpro_monthly_MOVES_03aug2016_v1"
setenv EFTABLES "${CASEINPUTS}/onroad/eftables/rateperdistance_smoke_nata_20160916_nei2014_20160719_10003_1.csv"
setenv MRGDATE_FILES "${RUNSCRIPTS}/smk_dates/2014/smk_merge_dates_201312.txt"
setenv GSCNV "${GE_DAT}/speciation/gscnv_Create_Speciate4_5_CB6CMAQ_12oct2016_v0.txt"
setenv SECTORLIST "${CASESCRIPTS}/sectorlist_2014fa_nata_cb6cmaq_14j_10nov2016_v1"
#setenv REPCONFIG_GRID "${GE_DAT}/smkreport/repconfig/repconfig_area_invgrid_2011platform_11aug2014_v0.txt"
#setenv REPCONFIG_INV2 "${GE_DAT}/smkreport/repconfig/repconfig_area_inv2_2011platform_11aug2014_v0.txt"
setenv NAICSDESC "${GE_DAT}/smkreport/naicsdesc_02jan2008_v0.txt"
setenv MTREF "${GE_DAT}/temporal/mtref_onroad_MOVES_2014v1_platform_03aug2016_v1"
#setenv PTREF "${GE_DAT}/temporal/amptref_general_2014platform_tref_08nov2016_nf_v6"
#setenv REPCONFIG_INV "${GE_DAT}/smkreport/repconfig/repconfig_area_inv_2011platform_11aug2014_v0.txt"
setenv AGREF "${GE_DAT}/gridding/agref_us_2014platform_08nov2016_nf_v3.txt"
setenv PSTK "${GE_DAT}/point/pstk_20nov2006_v0.txt"
setenv ORISDESC "${GE_DAT}/smkreport/orisdesc_04dec2006_v0.txt"
setenv PELVCONFIG "${GE_DAT}/point/pelvconfig_inline_20m_13nov2012_v0.txt"
setenv HOLIDAYS "${GE_DAT}/temporal/holidays_04may2006_v0.txt"
setenv ARTOPNT "${GE_DAT}/artopnt_2002detroit_30mar2012_v1.txt"
setenv SRGDESC "${GE_DAT}/gridding/srgdesc_CONUS12_2014_v1_10oct2016_30nov2016_v2.txt"
setenv ATREF "${GE_DAT}/temporal/amptref_general_2014platform_tref_08nov2016_nf_v6"
setenv SCCDESC "${GE_DAT}/smkreport/sccdesc_2014platform_09sep2016_v0.txt"
setenv INVTABLE "${GE_DAT}/invtable_hapcap_NATA_2016_27oct2016_nf_v8.txt"
setenv COSTCY "${GE_DAT}/costcy_for_2007platform_02nov2016_nf_v18.txt"
setenv GRIDDESC "${GE_DAT}/gridding/griddesc_lambertonly_18sep2015_v64.txt"
#setenv GSPROTMP_A "${GE_DAT}/speciation/gspro_cmaq_cb6_2014fa_nata_cb6cmaq_14j_nointegrate.txt"
setenv GSREFTMP_A "${GE_DAT}/speciation/gsref_cmaq_cb6_2014fa_nata_cb6cmaq_14j.txt"

# Inputs specific to this sector
setenv GSPROTMP_A "${GE_DAT}/speciation/gspro_cmaq_cb6_2014fa_nata_cb6cmaq_14j_criteria.txt"
setenv PTPRO_HOURLY "${GE_DAT}/temporal/amptpro_Canada_2010_tpro_hourly_05jan2015_v1"
setenv PTPRO_MONTHLY "${GE_DAT}/temporal/amptpro_Canada_2010_tpro_monthly_06nov2014_v0"
setenv PTPRO_WEEKLY "${GE_DAT}/temporal/amptpro_Canada_2010_tpro_weekly_05jan2015_v1"
setenv REPCONFIG_GRID "${GE_DAT}/smkreport/repconfig/repconfig_point_invgrid_2011platform_11aug2014_v0.txt"
setenv REPCONFIG_INV2 "${GE_DAT}/smkreport/repconfig/repconfig_point_inv2_2011platform_11aug2014_v0.txt"
setenv GSPRO_COMBO "${GE_DAT}/speciation/gspro_combo_canadamexico2005_29jan2013_v1.txt"
setenv EMISINV_I "${CASEINPUTS}/othpt/point_oilsands_canada_2010_FF10_06aug2014_v0.csv"
setenv EMISINV_D1 "${CASEINPUTS}/othpt/Mexico_2014v1_CMV_point_27jul2016_v0.csv"
setenv EMISINV_F "${CASEINPUTS}/othpt/ptinv_eca_imo_nonUS_nonCANADA_caps_vochaps_2011_16jun2015_v1_orl.txt"
setenv EMISINV_B "${CASEINPUTS}/othpt/point_summed_VOC_canada_Future_FF10_03nov2016_v0.csv"
setenv EMISINV_E "${CASEINPUTS}/othpt/offshore_2014NEIv1_final_POINT_03nov2016_v0.csv"
setenv EMISINV_D "${CASEINPUTS}/othpt/Mexico_2014v1_point_17aug2016_v1.csv"
setenv EMISINV_C "${CASEINPUTS}/othpt/point_uog_canada_2010_FF10_06aug2014_v0.csv"
setenv EMISINV_A "${CASEINPUTS}/othpt/point_novoc_canada_Future_FF10_08dec2015_v2.csv"
setenv PTREF "${GE_DAT}/temporal/amptref_Canada_2010_tref_06nov2014_v0"
setenv REPCONFIG_INV "${GE_DAT}/smkreport/repconfig/repconfig_point_inv_2011platform_11aug2014_v1.txt"
setenv NHAPEXCLUDE "${GE_DAT}/nhapexclude/nhapexclude_othpt_with_nonUS_c3_23aug2013_v0.txt"
setenv PELVCONFIG "${GE_DAT}/point/pelvconfig_seca_c3_22jul2010_v1.txt"


# Parameters for all sectors
setenv FILL_ANNUAL "N"
setenv FULLSCC_ONLY "Y"
#setenv INLINE_MODE "both"
setenv IOAPI_ISPH "20"
setenv L_TYPE "mwdss"
setenv MRG_MARKETPEN_YN "N"
setenv MRG_REPCNY_YN "Y"
setenv MRG_REPSTA_YN "N"
setenv MTMP_OUTPUT_YN "N"
setenv M_TYPE "mwdss"
setenv NO_SPC_ZERO_EMIS "Y"
setenv OUTPUT_FORMAT "$EMF_AQM"
setenv OUTZONE "0"
setenv PLATFORM "v7"
setenv POLLUTANT_CONVERSION "Y"
setenv RAW_DUP_CHECK "N"
setenv RENORM_TPROF "Y"
setenv REPORT_DEFAULTS "Y"
#setenv RUN_HOLIDAYS "Y"
setenv RUN_PYTHON_ANNUAL "Y"
setenv SMK_AVEDAY_YN "N"
setenv SMK_DEFAULT_SRGID "100"
setenv SMKINVEN_FORMULA "PMC=PM10-PM2_5"
setenv SMK_MAXERROR "10000"
setenv SMK_MAXWARNING "10"
setenv SMKMERGE_CUSTOM_OUTPUT "Y"
setenv SMK_PING_METHOD "0"
setenv SMK_SPECELEV_YN "Y"
setenv SPC "$EMF_SPC"
setenv WEST_HSPHERE "Y"

# Sector-specific parameters
setenv RUN_HOLIDAYS "N"
setenv MRG_BYDAY "P"
setenv INLINE_MODE "only"
setenv NONHAP_TYPE "VOC"
setenv SORT_LIST_EVS "Y"
setenv SMK_PROCESS_HAPS "PARTIAL"

$RUNSCRIPTS/emf/smk_pt_annual_byday_emf.csh $REGION_ABBREV $REGION_IOAPI_GRIDNAME -m "$RUN_MONTHS" $SPINUP_DURATION daily
