#! /bin/csh -f

#BSUB -oo logs/hr2day.EPA-R6-2016.TX-BART.CAMxRun1.36-12.PiG-PSAT.2002001-2002365.avrg.grd01-grd02.davg.log
#BSUB -J hr2day.avrg
#BSUB -P EPA-R6-RH
#BSUB -q week

# ====================== HR2DAYv5.1 Run Script ======================
# Usage: run.hr2day >&! hr2day_V51.log &
#
# To report problems or request help with this script/program:
#             http://www.cmascenter.org
# ===================================================================

#> Source the config.cmaq file to set the run environment
 source ./config.cmaq.pgi

#> Check that M3DATA is set: 
 if ( ! -e $M3DATA ) then
    echo "   $M3DATA path does not exist"
    exit 1
    endif
 echo " "; echo " Input data path, M3DATA set to $M3DATA"; echo " "

 set APPL = DonaAna 
 set MECH = cb05e51_ae6_aq 
 set EXEC = HR2DAY_${APPL}_$EXEC_ID

#> Set the working directory
 set BASE  = $cwd      
#set BASE  = $M3HOME/scripts/combine
 set BLD   = ${BASE}/BLD_$APPL

 cd $BASE; date; set timestamp; cat $BASE/cfg.${APPL}; echo " "; set echo

 setenv IOAPI_ISPH 20

set SDATE  = 2002001
set ENDATE = 2002365
set file   = avrg

#> set to use local time (default is GMT)
 setenv USELOCAL Y

#> set to use daylight savings time (default is N)
 setenv USEDST Y

#> location of time zone data file, tz.csv (this is a required input file)
 setenv TZFILE tz.csv

#> partial day calculation (computes value for last day)
 setenv PARTIAL_DAY Y

#> constant hour offset between desired time zone and GMT (default is 0)
# setenv HROFFSET -6

#> starting hour for daily metrics (default is 0)
 setenv START_HOUR 0

#> ending hour for daily metrics (default is 23)
 setenv END_HOUR 23

#> set input directory
 setenv INDIR /nas01/depts/ie/cempd/EPA-R6-CAMx/util/dyang/model_select
 setenv OUTDIR /nas01/depts/ie/cempd/EPA-R6-CAMx/CAMx/EPA-R6-2016/CAMxRun1/post-proc/vis/output/test

#> define species (format: "Name, units, From_species, Operation")
#>  operations : {SUM, AVG, MIN, MAX, @MAXT, MAXDIF, 8HRMAX, SUM06}
 
 setenv SPECIES_1  "NO2,ppmV,NO2,AVG"
 setenv SPECIES_2  "NO3,ppmV,NO3,AVG"
 setenv SPECIES_3  "N2O5,ppmV,N2O5,AVG"
 setenv SPECIES_4  "PSO4,ug/m3,PSO4,AVG"
 setenv SPECIES_5  "PNO3,ug/m3,PNO3,AVG"
 setenv SPECIES_6  "PEC,ug/m3,PEC,AVG"
 setenv SPECIES_7  "POA,ug/m3,POA,AVG"
 setenv SPECIES_8  "FCRS,ug/m3,FCRS,AVG"
 setenv SPECIES_9  "FPRM,ug/m3,FPRM,AVG"
 setenv SPECIES_10 "CCRS,ug/m3,CCRS,AVG"
 setenv SPECIES_11 "CPRM,ug/m3,CPRM,AVG"
 setenv SPECIES_12 "NA,ug/m3,NA,AVG"
 setenv SPECIES_13 "PCL,ug/m3,PCL,AVG"   

# set scen = 25a_2xMOVES

foreach grd ( 01 02 )

#> set input and output files
  setenv INFILE $INDIR/camx_v630.EPA-R6-2016.TX-BART.CAMxRun1.36-12.PiG-PSAT.${SDATE}-${ENDATE}.${file}.grd${grd}.ncf
  setenv OUTFILE $OUTDIR/camx_v630.EPA-R6-2016.TX-BART.CAMxRun1.36-12.PiG-PSAT.${SDATE}-${ENDATE}.${file}.grd${grd}.ncf.testall.davg
#> Executable call:
 /usr/bin/time $BLD/$EXEC

end

 date
 exit()
