forked from CICE-Consortium/CICE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate.case
executable file
·342 lines (294 loc) · 8.49 KB
/
create.case
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
#!/bin/csh -f
echo " "
echo "${0}:"
set CICE_SANDBOX = `pwd`
set CICE_SCRDIR = ${CICE_SANDBOX}/configuration/scripts
set initargv = ( $argv[*] )
set helpheader = 0
set dash = "-"
set spval = "UnDeFiNeD"
set mach = $spval
set case = $spval
set test = $spval
set grid = gx3
set pesx = 4x1
set sets = ""
set baseline = 0
set bdir = $spval
if ($#argv < 1) then
set helpheader = 1
endif
# check for -h
while (1)
if ($#argv < 1) break;
if ("$argv[1]" =~ ${dash}h* ) then
set helpheader = 1
endif
shift argv
end
#------------------------------------------------------------
# Help output
if ( $helpheader ) then
cat << EOF1
NAME
create.case - creates a CICE case directory
-h help
-c case, case directory/name (required)
-m machine, machine name (required)
-p tasks x threads, mxn (default is 4x1)
-g grid, grid (default = gx3)
-s build and namelist mod files, comma separated with no spaces (default = " ")
-- For testing purposes --
-t test, test name (cannot be selected if -c is selected)
Available tests:
- "smoke": Compiles code and performs 1 day run
- "10day": Compiles code and performs 10 day run
- "annual": Compiles code and performs annual run
- "restart": Compiles code and performs an exact restart test
-b baseline, generate baseline data
-bd baseline dir, location of baseline dataset (required if -t is used without -b)
EXAMPLES:
create.case -h
create.case -c ~/caseA -m yellowstone
create.case -p 32x4 -g gx1 -m gordon -c caseB
create.case -c ~/caseC -m spirit -s diag1,writeicf
EOF1
exit -1
endif
#------------------------------------------------------------
# Read in command line arguments
set argv = ( $initargv[*] )
while (1)
if ( $#argv < 1 ) break;
set option = $argv[1];
if ("$option" == "-b") then
set baseline = 1
shift argv
continue
endif
shift argv
if ( $#argv < 1 ) then
echo "${0}: ERROR1 in $option"
exit -1
endif
if ($argv[1] =~ $dash* ) then
echo "${0}: ERROR2 in $option"
exit -1
endif
switch ( $option )
case "-m":
set mach = $argv[1]
breaksw
case "-c":
set case = $argv[1]
breaksw
case "-t":
set test = $argv[1]
breaksw
case "-g":
set grid = $argv[1]
breaksw
case "-p":
set pesx = $argv[1]
breaksw
case "-s":
set sets = $argv[1]
breaksw
case "-bd":
set bdir = $argv[1]
breaksw
default:
echo "${0}: ERROR unknown option $option, use -h for help"
exit -1
breaksw
endsw
shift argv
end
if ($mach == $spval) then
echo "${0}: ERROR in arguments, -m required"
exit -1
endif
if ($case == $spval && $test == $spval) then
echo "${0}: ERROR in arguments, -c or -t required"
exit -1
endif
if ($case != $spval && $test != $spval) then
echo "${0}: ERROR in arguments, cannot use both -c and -t"
exit -1
endif
if ($test != $spval && $baseline == 0 && $bdir == $spval) then
echo "${0}: ERROR in arguments, when using -t either -b or -bd required"
exit -1
endif
set chck = `echo ${pesx} | sed 's/^[0-9]\+x[0-9]\+$/OK/'`
if (${chck} == OK) then
set task = `echo ${pesx} | sed s/x.\*//`
set thrd = `echo ${pesx} | sed s/.\*x//`
else
echo "${0}: ERROR in -p argument, ${pesx}, must be mxn"
exit -1
endif
if ($case != $spval) then
if (-d $case) then
echo "${0}: ERROR, case $case already exists"
exit -1
endif
mkdir -p $case
echo "`date`${0} $initargv[*]" > $case/README.case
else
if ($sets != "") then
set soptions = `echo $sets | sed 's/,/_/g'`
if ($baseline == 1) then
set testname = "${test}_baseline_${grid}_${mach}_${pesx}_$soptions"
else
set testname = "${test}_${grid}_${mach}_${pesx}_$soptions"
endif
else
if ($baseline == 1) then
set testname = "${test}_baseline_${grid}_${mach}_$pesx"
else
set testname = "${test}_${grid}_${mach}_$pesx"
endif
endif
if (-d $testname) then
echo "${0}: ERROR, test $testname already exists"
exit -1
endif
mkdir -p $testname
echo "`date`${0} $initargv[*]" > $testname/README.test
set case = $testname
endif
#------------------------------------------------------------
# Setup case directory, copy files to case directory
cd ${case}
set casedir = `pwd`
set casescr = "${casedir}/casescripts"
if !( -d ${casescr}) mkdir ${casescr}
# from basic script dir to case
foreach file (cice.build cice.settings Makefile ice_in makdep.c)
if !(-e ${CICE_SCRDIR}/$file) then
echo "${0}: ERROR, ${CICE_SCRDIR}/$file not found"
exit -1
endif
cp -f -p ${CICE_SCRDIR}/$file ${casedir}
end
# from machines dir to case
foreach file (env.${mach} Macros.${mach})
if !(-e ${CICE_SCRDIR}/machines/$file) then
echo "${0}: ERROR, ${CICE_SCRDIR}/machines/$file not found"
exit -1
endif
cp -f -p ${CICE_SCRDIR}/machines/$file ${casedir}
end
# from basic script dir to casescr
foreach file (parse_namelist.sh parse_settings.sh cice_decomp.csh cice.run.setup.csh)
if !(-e ${CICE_SCRDIR}/$file) then
echo "${0}: ERROR, ${CICE_SCRDIR}/$file not found"
exit -1
endif
cp -f -p ${CICE_SCRDIR}/$file ${casescr}
end
if ($case =~ */*) then
set casename = $case:t
else
set casename = $case
endif
cd ${casedir}
source ./env.${mach} || exit 2
echo CICE_SANDBOX = ${CICE_SANDBOX}
echo CICE_CASENAME = ${casename}
echo CICE_CASEDIR = ${casedir}
echo CICE_MACHINE = ${mach}
#------------------------------------------------------------
# Compute a default blocksize
setenv CICE_DECOMP_GRID ${grid}
setenv CICE_DECOMP_NTASK ${task}
setenv CICE_DECOMP_NTHRD ${thrd}
source ${casescr}/cice_decomp.csh
#------------------------------------------------------------
# Copy in and update cice.settings and ice_in files
set fimods = ${casescr}/ice_in.mods
set fsmods = ${casescr}/cice.settings.mods
cp ice_in ${casescr}/ice_in.base
cp cice.settings ${casescr}/cice.settings.base
if (-e ${fimods}) rm ${fimods}
if (-e ${fsmods}) rm ${fsmods}
cat >! ${fimods} << EOF1
nprocs = ${task}
atm_data_dir = '${CICE_MACHINE_INPUTDATA}/'
distribution_type = '${CICE_DECOMP_DECOMP}'
processor_shape = '${CICE_DECOMP_DSHAPE}'
ice_ic = '${CICE_DECOMP_INITFILE}'
grid_file = '${CICE_DECOMP_GRIDFILE}'
kmt_file = '${CICE_DECOMP_KMTFILE}'
EOF1
cat >! ${fsmods} << EOF1
setenv CICE_SANDBOX ${CICE_SANDBOX}
setenv CICE_CASENAME ${casename}
setenv CICE_CASEDIR ${casedir}
setenv CICE_MACHINE ${mach}
setenv CICE_RUNDIR ${CICE_MACHINE_WKDIR}/${casename}
setenv CICE_GRID ${grid}
setenv CICE_NXGLOB ${CICE_DECOMP_NXGLOB}
setenv CICE_NYGLOB ${CICE_DECOMP_NYGLOB}
setenv CICE_NTASKS ${task}
setenv CICE_NTHRDS ${thrd}
setenv CICE_DECOMP ${CICE_DECOMP_DECOMP}
setenv CICE_DSHAPE ${CICE_DECOMP_DSHAPE}
setenv CICE_MXBLCKS ${CICE_DECOMP_MXBLCKS}
setenv CICE_BLCKX ${CICE_DECOMP_BLCKX}
setenv CICE_BLCKY ${CICE_DECOMP_BLCKY}
setenv CICE_RSTPFILE ${CICE_DECOMP_RSTPFILE}
EOF1
if ($#sets > 0) then
set setssplit = `echo $sets | sed 's/,/ /g'`
foreach name ($setssplit)
set found = 0
if (-e ${CICE_SCRDIR}/options/set_nml.${name}) then
cat ${CICE_SCRDIR}/options/set_nml.${name} >> ${fimods}
echo "adding namelist mods set_nml.${name}"
set found = 1
endif
if (-e ${CICE_SCRDIR}/options/set_env.${name}) then
cat ${CICE_SCRDIR}/options/set_env.${name} >> ${fsmods}
echo "adding env mods set_env.${name}"
set found = 1
endif
if (${found} == 0) then
echo "${0}: ERROR, ${CICE_SCRDIR}/options/set_[nml,env].${name} not found"
exit -1
endif
end
endif
if ($test != $spval) then
if (-e ${CICE_SCRDIR}/options/test_nml.${test}) then
cat ${CICE_SCRDIR}/options/test_nml.${test} >> ${fimods}
echo "adding namelist mods test_nml.${test}"
set found = 1
endif
if (${found} == 0) then
echo "${0}: ERROR, ${CICE_SCRDIR}/options/test_nml.${name} not found"
exit -1
endif
endif
${casescr}/parse_settings.sh cice.settings ${fsmods}
${casescr}/parse_namelist.sh ice_in ${fimods}
#------------------------------------------------------------
# Generate run script
source ./cice.settings
source ./env.${mach} || exit 2
${casescr}/cice.run.setup.csh
#------------------------------------------------------------
if ($test != $spval) then
# Generate test script
source ./cice.settings
source ./env.${mach} || exit 2
if ($baseline == 0) then
${CICE_SCRDIR}/tests/cice.${test}.csh $bdir
else
# Generate baseline dataset
${CICE_SCRDIR}/tests/cice.${test}.csh
endif
endif
echo "${0} done"
echo " "