#!/bin/csh

set yy = `date -u +%y`
set mm = `date -u +%m`
set dd = `date -u +%d`
set hh = `date -u +%H`
set ddm = `date +%d`
set month = `date -u +%B`
set year = `date -u +%Y`
set day = `date -u +%-d`

if (${hh} < 04) then
    set mdate = ${yy}${mm}${ddm}18
    set hour = 18
    echo ${mdate}
endif    
if (${hh} >= 22) then
    set mdate = ${yy}${mm}${ddm}18
    set hour = 18
    echo ${mdate} 
endif       
if (${hh} >= 04 && ${hh} < 10) then
    set mdate = ${yy}${mm}${dd}00
    set hour = '00'
    echo ${mdate}
endif
if (${hh} >= 10 && ${hh} < 16) then
    set mdate = ${yy}${mm}${dd}06
    set hour = '06'
    echo ${mdate}
endif
if (${hh} >= 16 && ${hh} < 22) then
    set mdate = ${yy}${mm}${dd}12
    set hour = 12
    echo ${mdate}
endif 


rm -rf /spare11/ralazear/wrf/sfc_temp_date_d.txt
mv /spare11/ralazear/wrf/sfc_temp_date_c.txt /spare11/ralazear/wrf/sfc_temp_date_d.txt
mv /spare11/ralazear/wrf/sfc_temp_date_b.txt /spare11/ralazear/wrf/sfc_temp_date_c.txt
mv /spare11/ralazear/wrf/sfc_temp_date_a.txt /spare11/ralazear/wrf/sfc_temp_date_b.txt

cat > /spare11/ralazear/wrf/sfc_temp_date_a.txt << endcat
document.write("${hour}Z ${day} ${month} ${year}");
endcat


cd /spare11/ralazear/wrf_output/sfc_temp

foreach res ( '27' '09' )

foreach filenum ( 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 )

rm -rf wrf${res}_sfc_temp_d${filenum}.gif
mv wrf${res}_sfc_temp_c${filenum}.gif wrf${res}_sfc_temp_d${filenum}.gif
mv wrf${res}_sfc_temp_b${filenum}.gif wrf${res}_sfc_temp_c${filenum}.gif
mv wrf${res}_sfc_temp_a${filenum}.gif wrf${res}_sfc_temp_b${filenum}.gif

end

end

set countb = 0

foreach fhr ( '000' '003' '006' '009' '012' '015' '018' \
'021' '024' '027' '030' '033' '036' '039' '042' '045' \
'048' '051' '054' '057' '060' '063' '066' '069' '072'  )
  
#set subhr = `echo "(${fhr}-3)"|bc`  

foreach res ( '27' '09' )

/spare11/ralazear/wrf_output/sfc_temp/sfc_temp${res}.csh ${fhr} ${mdate}
mv wrf${res}_${mdate}F${fhr}_sfc_temp.gif wrf${res}_sfc_temp_a${countb}.gif

end

set countb = `echo "(${countb}+1)"|bc`

end

exit

gpend
