#!/bin/csh

set outfile = maxoutlist.txt
rm $outfile

foreach n ( 20*00 ) 
  echo ========= $n   `date`
  if ( -e $n/forecast/data/smoke_dispersion.nc ) then
    cdo -vertmax -fldmax $n/forecast/data/smoke_dispersion.nc $n/forecast/outmax.nc
    set MAXPM25 = `ncdump -v PM25 $n/forecast/outmax.nc | tail -n 49 | head -n 48 | sort -nr | head -n 1`
    echo $MAXPM25 $n >> $outfile
  endif
end

foreach n ( 20*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 49 | head -n 48 | sort -nr | head -n 1`
    echo $MAXPM25 $n >> $outfile
  endif
end
