#!/bin/csh -f
#PBS -W group_list=romo
#PBS -A sectors 
#PBS -q romo
#PBS -l walltime=24:00:00
#PBS -l nodes=1:ppn=1


set GRID = 36US3 
set YEAR = 2023
set YY = `echo $YEAR | cut -c3-4`
set NZ = 35


foreach SCEN (  base2023 base2023_0fire base2023_altVOCspec base2023_rxeqemis base2023_ember  )


set day = {$YEAR}001
set endday = {$YEAR}365


set day = $day
set enddate = $endday


#Set Directories

set INDIR = /work/ROMO/lrt/cmaq/36US3/output/$SCEN
set POSTDIR = /work/ROMO/lrt/cmaq/36US3/postp/$SCEN
set THISDIR = /work/MOD3EVAL/kbaker/projects/wfsens/combine
mkdir -p $POSTDIR

rm -rf species.temp
touch species.temp
echo "##start   YYYYSTA  000000" >> species.temp
echo "##end     YYYYEND  000000" >> species.temp
echo "##layer         1" >> species.temp
echo "/new species    ,units     ,expression" >> species.temp
echo "O3,ppb,O3[1]*1000" >> species.temp
echo "PM25,ug/m3,PM25[2]" >> species.temp
#echo "PAN,ppb,PAN[1]*1000" >> species.temp
#echo "FORM,ppb,FORM[1]*1000" >> species.temp
#echo "O3_BASE,ppb,O3[3]*1000" >> species.temp
#echo "CO2,ppb,CO2[1]*1000" >> species.temp


setenv SPECIES_DEF species.temp
setenv OUTFILE $POSTDIR/combine.$YEAR.$GRID.$SCEN.ncf
rm -f $OUTFILE

while ($day <= $enddate)

set GDAY = (`/home/kbaker/camx/dateconv/j2g $day`)

set YYYY = `echo $GDAY | cut -c1-4`
set YY = `echo $GDAY | cut -c3-4`
set MM = `echo $GDAY | cut -c5-6`
set DD = `echo $GDAY | cut -c7-8`

set G_DAY = $YYYY$MM$DD
set GS_DAY = $YY$MM$DD


setenv INFILE1 $INDIR/CMAQv55_cb6r5_ae7_aq.$GRID.35.${SCEN}.ACONC.${day}
setenv INFILE2 $INDIR/CMAQv55_cb6r5_ae7_aq.$GRID.35.${SCEN}.AELMO.${day}
setenv INFILE3 /work/ROMO/lrt/cmaq/36US3/output/base2023/CMAQv55_cb6r5_ae7_aq.$GRID.35.base2023.ACONC.${day}

/home/kappel/showard/bin/combine.exe

@ day = $day + 1

end #loop over days
end #loop over scen
end #loop over months

exit

