#!/bin/csh

# c-shell script to calculate cross spectra
# between PC1 and PC2 from combined EOF

# !!!!!! What should be modified !!!!!!
# HHH  : home directory
# TTT  : total number of time
# LNX  : whether the machine is linux or not
#  This is for the record length problem.
#  (e.g. 4 : linux machine, 1 : other machine)
# !!!!!! What should be modified !!!!!!

 setenv HHH /jdata4/cdl/kim/msd

 setenv LNX 1
 setenv TTT 9862

 foreach var (ceof)

 cd $HHH/level_2/$var

 mkdir -p src/crsp
 cd src/crsp

 cp -f $HHH/level_2/sample/ceof/crsp.f.sample .
 cp -f $HHH/level_2/sample/ceof/libfftpack.a .
 cp -f $HHH/level_2/sample/ceof/makefile.crsp .

 sed "s#homedir#$HHH#g"    crsp.f.sample > tmp1
 sed "s/mjo_var/$var/g"             tmp1 > tmp2
 sed "s/linux_recl/$LNX/g"          tmp2 > tmp1
 sed "s/num_t/$TTT/g"               tmp1 > crsp.f

 cp -f makefile.crsp makefile

 make
 crsp
 rm -f crsp crsp.f crsp.o

 end

