#!/bin/sh

### QUICK AND DIRTY SCRIPT FOR MAKING MEANS ###
### EDIT AS YOU LIKE  
### MAKING MONTHLY MEANS ####

#month=03
#shour=6
#ehour=744

#month=04
#shour=750
#ehour=1464

month=05
shour=1470
ehour=2208

set -ax

### CREATE A LIST OF FILES FOR AVERAGE

rm tmphag.list

hour=$shour
while [ $hour -le $ehour ]; do

     if [ $hour -lt 10 ]; then hour=0$hour; fi

     ls /home/nfs1/smr1934/post/tmphag/tmphag.ft$hour >> tmphag.list

					                hour=`expr $hour + 6`

done

set -ax

#/afs/ictp/home/a/anunes/RSM/ecpc_exp/libs/etc/grmap /scratch/RSM/rruns/SouthAmerical01/2008/r_pgb.ft06

### RUN GRMEAN and CREATE MEAN

/afs/ictp/home/a/anunes/RSM/ecpc_exp/libs/etc/grmean -s tmphag.list -o sa_l01_tmphag_2008${month}01.grib

### SET THE TIME TO 2008 03 01 00
/afs/ictp/home/a/anunes/RSM/ecpc_exp/libs/etc/force_grib_date_mon sa_l01_tmphag_2008${month}01.grib 2008${month}0100

#### CREAE CTL FILE FOR GRADS
#/afs/ictp/home/a/anunes/RSM/ecpc_exp/libs/etc/grmap -g0 sa_l01_tmphag_20080301.grib

