#!/bin/csh

set outfile = maxoutlist.txt
rm $outfile

foreach n ( 201[89]*00 2020*00 20210[12]*00 )
  echo ========= $n   `date`
  if ( -e $n/combined/data/smoke_dispersion.nc ) then
    cdo -vertmax -fldmax $n/combined/data/smoke_dispersion.nc $n/combined/outmax.nc
    set MAXPM25 = `ncdump -v PM25 $n/combined/outmax.nc | tail -n 73 | head -n 72 | sort -nr | head -n 1`
    echo $MAXPM25 $n >> $outfile
  endif
end

foreach n ( 20210[3456789]*00 20211*00 202[23]*00 )
  echo ========= $n   `date`
  if ( -e $n/forecast/hysplit_conc.nc ) then
    cdo -vertmax -fldmax $n/forecast/hysplit_conc.nc $n/forecast/outmax.nc
    set MAXPM25 = `ncdump -v PM25 $n/forecast/outmax.nc | tail -n 73 | head -n 72 | sort -nr | head -n 1`
    echo $MAXPM25 $n >> $outfile
  endif
end
