ToolsAndUtilities/CAP: CAP_interface

File CAP_interface, 5.2 KB (added by willie, 21 months ago)

CAP driver script

Line 
1#!/bin/ksh
2#
3# Provides an interface between the job script produced
4# by the CAP web server and the CAP.
5#
6# It uses the standard CAP interface i.e. AncilScr_top
7# to create each of the required ancillary files.
8#
9# This exports all variables
10
11set -a
12
13# QUEUE and nproc not used but retained so that
14# AncilScr_top works as is
15export QUEUE=short
16nproc=1
17
18LEVEL76=F
19
20ROTATE=F
21GLOBAL=F
22
23# get options
24uopts=$*
25for arg in $uopts
26do
27  case $arg in
28  '-levels') P_LEVELS=$2 ; shift 2 ;;
29  '-maskin') MASKIN=$2 ; shift 2 ;;
30  '-orogin') MASKIN=$2 ; shift 2 ;;
31  '-model') MODEL=$2 ; shift 2 ;;
32  '-nrow') NROW=$2 ; shift 2 ;;
33  '-ncol') NCOL=$2 ; shift 2 ;;
34  '-rotate') ROTATE=T ; shift ;;
35  '-latorigin') LAT_ORIGIN=$2 ; shift 2 ;;
36  '-longorigin') LONG_ORIGIN=$2 ; shift 2 ;;
37  '-latpole') ROT_LAT_POLE=$2 ; shift 2 ;;
38  '-longpole') ROT_LONG_POLE=$2 ; shift 2 ;;
39  '-latdelta') LAT_DELTA=$2 ; shift 2 ;;
40  '-longdelta') LONG_DELTA=$2 ; shift 2 ;;
41  '-global') GLOBAL=T ; shift ;;
42  '-bit64') BIT64=T ; shift ;;
43  '-vertical') VERTICAL=$2 ; shift 2 ;;
44  '-output') DDIR=$2 ; shift 2 ;;
45  '-lev76') LEVEL76=T ; shift  ;;
46  esac
47done
48
49
50if [[ $GLOBAL == F ]] ; then
51  echo INFO:: $LAT_DELTA $NROW $LAT_ORIGIN
52  #calculate latitude origin at the top from its bottom origin
53  LAT_ORIGIN=$(perl -e "print $LAT_ORIGIN + $LAT_DELTA*($NROW-1);")
54  echo INFO:: LAT_ORIGIN $LAT_ORIGIN
55fi
56
57
58MODEL=${MODEL}
59echo "MODEL: $MODEL"
60
61SCRATCH_PATH=$DATADIR/tmp
62echo "SCRATCH_PATH is $SCRATCH_PATH"
63
64if [[ $GLOBAL == T ]] ; then
65  ROTATE = F
66  ROT_LAT_POLE=90.0
67  ROT_LONG_POLE=0.0
68fi
69
70export MALLOC_CHECK_=0
71
72
73if [[ $GLOBAL == F ]] ; then
74  cat >$GRID<<eof
75 &GRID
76  POINTS_LAMBDA_TARG=${NCOL},POINTS_PHI_TARG=${NROW},
77  LAMBDA_ORIGIN_TARG=${LONG_ORIGIN},PHI_ORIGIN_TARG=${LAT_ORIGIN},
78  DELTA_LAMBDA_TARG=${LONG_DELTA},DELTA_PHI_TARG=${LAT_DELTA},
79  PHI_POLE=${ROT_LAT_POLE},LAMBDA_POLE=${ROT_LONG_POLE},ROTATED=${ROTATE},\
80  GLOBAL=${GLOBAL}
81 /
82eof
83fi
84
85if [[ $GLOBAL == T ]] ; then
86cat >$GRID<<eof
87 &GRID
88  POINTS_LAMBDA_TARG=${NCOL},POINTS_PHI_TARG=${NROW},
89  LAMBDA_ORIGIN_TARG=${LONG_ORIGIN},PHI_ORIGIN_TARG=${LAT_ORIGIN},
90  PHI_POLE=${ROT_LAT_POLE},LAMBDA_POLE=${ROT_LONG_POLE},GLOBAL=${GLOBAL},\
91  ROTATED=${ROTATE}
92 /
93eof
94fi
95
96
97if [[ $MASK_DATASET == 1 ]] ; then
98  export DATASETS="mask"
99
100  $ANCIL_PARENT/bin/AncilScr_top \
101    -model $MODEL \
102    -script cranc_mask \
103    -namelist name_mask \
104    -grid $GRID \
105    -search 40 \
106    -pack 0 \
107    -mpp $nproc \
108    -queue $QUEUE 
109  CC=$?
110  if [ $CC -ne 0 ]; then
111   print "Error $CC in $DATASETS.  Stopping"
112   exit $CC
113  fi
114fi
115
116
117cat >$OROGNML<<eof
118  &OROG
119   LFILT_SRCE_EW=F
120   LFILT_SRCE_ISO=T
121   LFILT_TARG_EW=F
122   LFILT_TARG_121=F
123   LFILT_TARG_RAYMOND=T
124   FILT_SRCE_LENGTH=6000.0
125   REMOVE_MEAN_GRAD=T
126   EPSILON=1.0
127   LFILT_TARG_SUBGRID=T
128   L_SDFROMNEWMEAN=T
129   USE_DTED_ASH=F
130   USE_GLOBE_ASH=T
131   AS_COEF_SRCE(3)=1.823310
132   L_AUTO_LAKES=T
133  /
134eof
135
136if [[ $OROG_DATASET == 1 ]] ; then
137  export DATASETS="orog"
138
139  $ANCIL_PARENT/bin/AncilScr_top \
140    -model $MODEL \
141    -script cranc_orog \
142    -namelist name_orog \
143    -grid $GRID \
144    -search 40 \
145    -pack 0 \
146    -mpp $nproc \
147    -queue $QUEUE
148  CC=$?
149  if [ $CC -ne 0 ]; then
150   print "Error $CC in $DATASETS.  Stopping"
151   exit $CC
152  fi
153fi
154
155
156if [[ $VEGFRAC_DATASET == 1 ]] ; then
157  export DATASETS="vegfrac"
158
159  $ANCIL_PARENT/bin/AncilScr_top \
160    -model $MODEL \
161    -script cranc_vegfrac \
162    -namelist name_vegfrac \
163    -grid $GRID \
164    -search 40 \
165    -pack 0 \
166    -mpp $nproc 
167  CC=$?
168  if [ $CC -ne 0 ]; then
169   print "Error $CC in $DATASETS.  Stopping"
170   exit $CC
171  fi
172fi
173
174if [[ $SSTICE_DATASET == 1 ]] ; then
175  export DATASETS="sstice"
176
177  $ANCIL_PARENT/bin/AncilScr_top \
178    -model $MODEL \
179    -script cranc_sstice \
180    -namelist name_sstice \
181    -grid $GRID \
182    -search 40 \
183    -pack 0 \
184    -mpp $nproc \
185    -queue $QUEUE
186  CC=$?
187  if [ $CC -ne 0 ]; then
188   print "Error $CC in $DATASETS.  Stopping"
189   exit $CC
190  fi
191fi
192
193if [[ $SOILTEMP_DATASET == 1 ]] ; then
194  export DATASETS="slt"
195
196  $ANCIL_PARENT/bin/AncilScr_top \
197    -model $MODEL \
198    -script cranc_slt \
199    -namelist name_slt \
200    -grid $GRID \
201    -search 40 \
202    -pack 0 \
203    -mpp $nproc \
204    -queue $QUEUE
205  CC=$?
206  if [ $CC -ne 0 ]; then
207   print "Error $CC in $DATASETS.  Stopping"
208   exit $CC
209  fi
210fi
211
212if [[ $SMOW_DATASET == 1 ]] ; then
213  export DATASETS="smow "
214
215  $ANCIL_PARENT/bin/AncilScr_top \
216    -model $MODEL \
217    -script cranc_smow \
218    -namelist name_smow \
219    -grid $GRID \
220    -search 40 \
221    -pack 0 \
222    -mpp $nproc \
223    -queue $QUEUE
224fi
225
226if [[ $OZONE_DATASET == 1 ]] ; then
227  export DATASETS="ozone"
228
229  $ANCIL_PARENT/bin/AncilScr_top \
230    -model $MODEL \
231    -script cranc_ozone \
232    -namelist name_ozone \
233    -grid $GRID \
234    -levels $P_LEVELS \
235    -pack 0 \
236    -mpp $nproc \
237    -queue $QUEUE
238  CC=$?
239  if [ $CC -ne 0 ]; then
240   print "Error $CC in $DATASETS.  Stopping"
241   exit $CC
242  fi
243fi
244
245if [[ $AEROSOL_DATASET == 1 ]] ; then
246  export DATASETS="aerosol"
247
248  $ANCIL_PARENT/bin/AncilScr_top \
249    -model $MODEL \
250    -script cranc_aerosol \
251    -namelist name_aerosol \
252    -grid $GRID \
253    -levels $P_LEVELS \
254    -pack 0 \
255    -mpp $nproc \
256    -queue $QUEUE
257  CC=$?
258  if [ $CC -ne 0 ]; then
259   print "Error $CC in $DATASETS.  Stopping"
260   exit $CC
261  fi
262fi
263
264 
265