#! /bin/csh -f

# ====================== HR2DAYv5.3.X Run Script ======================
# Usage: run.hr2day.csh >&! hr2day.log &
#
# To report problems or request help with this script/program:
#             http://www.epa.gov/cmaq    (EPA CMAQ Website)
#             http://www.cmascenter.org
# ===================================================================

# ==================================================================
#> Runtime Environment Options
# ==================================================================

#> Choose compiler and set up CMAQ environment with correct 
#> libraries using config.cmaq. Options: intel | gcc | pgi
 setenv compiler gcc

 cd ../../..
 source ./config_cmaq.csh

#> Set General Parameters for Configuring the Simulation
 set VRSN      = v532 #> Code Version
 set PROC      = mpi               #> serial or mpi
 set MECH      = cb6r3_ae7_aq      #> Mechanism ID
 set APPL      = Bench_2016_12SE1   #> Application Name (e.g. Gridname)
                                                      
#> Define RUNID as any combination of parameters above or others. By default,
#> this information will be collected into this one string, $RUNID, for easy
#> referencing in output binaries and log files as well as in other scripts.
 setenv RUNID  ${VRSN}_${compilerString}_${APPL}
 
#> Set the build directory if this was not set above 
#> (this is where the executable is located by default).
 if ( ! $?BINDIR ) then
  setenv BINDIR ${CMAQ_HOME}/POST/hr2day/scripts/BLD_hr2day_${VRSN}_pgi2018
 endif

#> Set the name of the executable.
 setenv EXEC hr2day_${VRSN}.exe

#> Set location of CMAQ repo.  This will be used to point to the time zone file
#> needed to run bldoverlay.  
 setenv REPO_HOME ${CMAQ_REPO}

#> Set output directory
 setenv POSTDIR    ${CMAQ_DATA}/POST    #> Location where hr2day file will be written

  if ( ! -e $POSTDIR ) then
	  mkdir $POSTDIR
  endif


# =====================================================================
#> HR2DAY Configuration Options
# =====================================================================

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

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

#> location of time zone data file, tz.csv (this is a required input file
#> when using USELOCAL Y to shift from GMT to local time)
 setenv TZFILE ${REPO_HOME}/POST/bldoverlay/inputs/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 0

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

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

#> Number of 8hr values to use when computing daily maximum 8hr ozone.
#> Allowed values are 24 (use all 8-hr averages with starting hours 
#> from 0 - 23 hr local time) and 17 (use only the 17 8-hr averages
#> with starting hours from 7 - 23 hr local time)
 setenv HOURS_8HRMAX 17
# setenv HOURS_8HRMAX 17

#> define species (format: "Name, units, From_species, Operation")
#>  operations : {SUM, AVG, MIN, MAX, @MAXT, MAXDIF, 8HRMAX, SUM06}
# setenv SPECIES_1 "O3,ppbV,O3,8HRMAX"
 setenv SPEICES_1 "ATOTIJ,ug/m3,ATOTIJ,AVG"
#> Optional desired first and last processing date. The program will
#> adjust the requested dates if the desired range is not covered by
#> the input file(s). If these dates are not specified, the processing
#> will be performed for the longest possible time record that can be
#> derived from the model input file(s)
 setenv START_DATE 20160701
 setenv END_DATE 20160702

#> set input and output files
 setenv INFILE /usr/apps/CMAQ/CMAQ_v5.3/data/CMAQv5.3_Benchmark_2Day_Output/POST/COMBINE_ACONC_v53_gcc_Bench_2016_12SE1_201607.nc
# setenv M3_FILE_2 ${CMAQ_DATA}/POST/COMBINE_ACONC_${RUNID}_201608.nc
          #[Add location of one or more (up to 366) input files, e.g. COMBINE_ACONC file.]
 setenv OUTFILE /usr/apps/CMAQ/CMAQ_v5.3/data/CMAQv5.3_Benchmark_2Day_Output/POST/daily_COMBINE_ACONC_v53_gcc_Bench_2016_12SE1_201607.nc

#> Executable call:
 ${BINDIR}/${EXEC}

 exit()


