#!/bin/csh -x

setenv MP_SET_NUMTHREADS 4

set arch = `uname`
set host = `hostname`

set name = `echo $host | cut -b 1-5` ; if( $name == 'halem'    ) set host = $name
set name = `echo $host | cut -b 1-8` ; if( $name == 'columbia' ) set host = $name


# Set Paths for NAS
# -----------------
if( $host == 'columbia' || \
    $host == 'cfe1'     || \
    $host == 'cfe2'        ) then
     set BASEDIR = /u/mirvis/v1_8r1p
     set GFIODIR = /u/dao_ops/g5ncep/GEOS-5_beta3p2/g5das
endif


# Set Paths for NCCS
# ------------------
if( $host == 'palm'     ) then
     set BASEDIR = /share/ESMA/baselibs/v1_8r1p
     set GFIODIR = /gmao_ops/dao_ops/GEOS-5_beta6a/g5das
endif
if( $host == 'halem'    ) then
     set BASEDIR = /share/ESMA/baselibs/v1_8r1p
     set GFIODIR = /u1/ltakacs/Daedalus_p6/GEOSgcm
endif
if( $host == 'dirac'   || \
    $host == 'jimpf'    ) then
     set BASEDIR = /ford1/local/${arch}/hdf
     set GFIODIR = /gmao_ops/dao_ops/GEOS-3.3.9/geosdas/Core/lib
endif



/bin/rm monthly_$arch.x
if( -e test.o ) /bin/rm test.o
if( -e test.F ) /bin/rm test.F
cat monthly_hdf.F >     test.F


if( $arch == 'IRIX64' ) then
setenv hdf /ford1/local/$arch/hdf
     f90 -c -fixedform -extend_source -O3 -64 -r8 -i4 -mips4 -I $hdf/include -Dopenmpz -Ddebuz -Dgrads -mp test.F
     f90 -o monthly_$arch.x -O3 -64 -r8 -i4 -mips4 -I . -mp test.o -L/home/dao_ops/GEOS-3.3.9/geosdas/Core/lib \
                                                       -L$hdf/lib \
                                                       -lcomplib.sgimath -lblas -lgfio \
                                                       -lmfhdf -ldf -lz -lm
endif

if( $arch == 'OSF1' ) then
     f90 -o monthly_$arch.x -extend_source -convert big_endian -assume byterecl \
                          -r8 -i4 -I. -Dgrads test.F \
                          -L$GFIODIR/$arch/lib -lGMAO_cfio -lGMAO_gfio -lGMAO_mfhdf3 \
                          -L$BASEDIR/$arch/lib -lmfhdf -ldf -lhdfjpeg -lhdfz -lsz
endif

if( $arch == 'Linux' ) then
     ifort -o monthly_$arch.x -extend_source -convert big_endian -assume byterecl -O3 -I. -Dgrads test.F \
           -L$GFIODIR/$arch/lib -lGMAO_cfio -lGMAO_gfio -lGMAO_mfhdf3 \
           -L$BASEDIR/$arch/lib -lmfhdf -ldf -lhdfjpeg -lhdfz -lsz
endif

if( -e test.o ) /bin/rm test.o
if( -e test.F ) /bin/rm test.F
./monthly_$arch.x
