#!/bin/csh

#SBATCH -J O3Sonde 
#SBATCH -p singlepe
#SBATCH -t 12:00:00
#SBATCH -n 1
#SBATCH -o /work/MOD3EVAL/dkj/LTNG/Aanl_Sond2011/jobs/Sonde.log
#SBATCH -e /work/MOD3EVAL/dkj/LTNG/Aanl_Sond2011/jobs/Sonde.log

set echo
setenv Identifier AllSchemes
set wkdir = /work/MOD3EVAL/dkj/LTNG/Aanl_Sond2011/jobs
setenv YEAR "2011"
setenv MONTH "07"
setenv MNAME July 
setenv MODEL "CMAQv52"
setenv MOD_CASES  "Base,mNLDN,hNLDN,pNLDN"
#setenv MOD_CASES  "Base,hNLDN"
setenv MOD_dir /work/MOD3EVAL/dkj/LTNG/Aanl_Sond2011/data/
setenv MET_dir /work/MOD3EVAL/dkj/LTNG/Aanl_Sond2011/data/
setenv plotdir /work/MOD3EVAL/dkj/LTNG/Aanl_Sond2011/plots/
setenv MET_FILE $MET_dir/mcip/METCRO3D_20110711
setenv MOD_VAR O3
setenv modfac 1000
setenv OBS_VAR Ozone_ppb
setenv time_vars "Start_UTC"
#foreach site ("BELTSVILLE" "EDGEWOOD" "Boulder" "Huntsville")
foreach site ("Wallops")
  setenv Loc $site  
  if($Loc == "EDGEWOOD") then
    setenv FileType ICARTT #Sonde   #or ICARTT   #the file format for sonde data 
    setenv OBS_dir /work/MOD3DEV/dkj/Aircraft/$Loc/
    setenv S_pattern "R0_L"  # for Edgewood format
    setenv loc_vars "Latitude_deg,Longitude_deg,Altitude_km"
    setenv par_vars "Ozone_ppmv"
    setenv obsfac 1000
    setenv Plot_days "21,22,28,29,30"  #EDGEWOOD
  endif
  if($Loc == "BELTSVILLE") then
    setenv FileType ICARTT #Sonde   #or ICARTT   #the file format for sonde data 
    setenv OBS_dir /work/MOD3DEV/dkj/Aircraft/$Loc/
    setenv S_pattern "R1.ict"  # for Huntsville format
    setenv loc_vars "Latitude_deg,Longitude_deg,Height_km"
    setenv par_vars "Ozone_ppb"
    setenv obsfac 1.0
    setenv Plot_days "21,22,28,29"  #BELTSVILLE
  endif
  if($Loc == "Boulder") then
    setenv S_pattern ${YEAR}_${MONTH}
    setenv FileType Sonde   #or ICARTT   #the file format for sonde data 
    setenv OBS_dir /work/MOD3EVAL/css/noaa/esrl/Ozonesonde/$Loc/1SecondDataFiles/
    setenv Plot_days "06,13,20,28"  #Boulder-July
    setenv Plot_days "03,11,17,24"  #Boulder-July
  endif
  if($Loc == "Huntsville") then
    setenv S_pattern ${YEAR}_${MONTH}
    setenv FileType Sonde   #or ICARTT   #the file format for sonde data 
    setenv OBS_dir /work/MOD3EVAL/css/noaa/esrl/Ozonesonde/$Loc/1SecondDataFiles/
    setenv Plot_days "02,09,16,23,30" #Huntsville-July
    setenv Plot_days "06,13,20,27" #Huntsville-August
  endif
  if($Loc == "Wallops") then
    setenv obsfac 1000
    setenv S_pattern "ECC" 
    setenv FileType Woudc   #or ICARTT   #the file format for sonde data 
    setenv OBS_dir "/work/MOD3EVAL/dkj/LTNG/Aanl_Sond2011/data/STN107/"
    setenv Plot_days "07,18,25" #wallops, July
#    setenv Plot_days "17,24" #wallops, August
  endif
  set mod_inf1 = 2011ek_cb6cmaq5.2_wrf3.8_zero_lnox.CONC.
  set mod_inf2 = 2011ek_cb6cmaq5.2_wrf3.8_nldn_lnox.CONC.
  set mod_inf3 = CCTM_CONC.CMAQ_v52_Aug112016_
  set mod_inf4 = 2011ek_cb6cmaq5.2_wrf3.8_hnldn_lnox.CONC.
setenv MOD_FILES "$mod_inf1,$mod_inf2,$mod_inf3,$mod_inf4"
#  setenv MOD_FILES "$mod_inf1,$mod_inf2"
  setenv isMean TRUE
  setenv byLayer TRUE

  cd $wkdir
 /usr/local/apps/R-3.4.0/intel-17.0/bin/R CMD BATCH --slave /work/MOD3EVAL/dkj/LTNG/Aanl_Sond2011/R-scripts/jbDaily_O3Sonde_AllCases_plot.R
 end
exit
