This repository has been archived by the owner on Feb 1, 2024. It is now read-only.
forked from CICE-Consortium/CICE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cice.setup
executable file
·1021 lines (878 loc) · 29.9 KB
/
cice.setup
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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/csh -f
set ICE_SANDBOX = `pwd`
set ICE_VERSION = unknown
if (-e cicecore/version.txt) then
set ICE_VERSION = `head -1 cicecore/version.txt | sed -e 's/ /_/g'`
endif
set ICE_SCRIPTS = "${ICE_SANDBOX}/configuration/scripts"
set initargv = ( $argv[*] )
set helpheader = 0
set dash = "-"
set spval = "UnDeFiNeD"
set machcomp = ${spval}
set machine = ${spval}
set compilers = intel
set case = ${spval}
set test = ${spval}
set grid = gx3
set pesx = 4x1
set sets = ""
set tdir = ${spval}
set bdir = ${spval}
set testid = ${spval}
set testsuite = ${spval}
set queue = ${spval}
set acct = ${spval}
set baseCom = ${spval} # Baseline compare
set baseGen = ${spval} # Baseline generate
set bfbcomp = ${spval} # BFB compare
set report = 0 # test results reporting
set sdate = `date -u "+%y%m%d"`
set stime = `date -u "+%H%M%S"`
set docase = 0
set dotest = 0
set dosuite = 0
if ($#argv < 1) then
set helpheader = 1
endif
set argv = ( $initargv[*] )
# check for -h
while (1)
if ($#argv < 1) break;
if ("$argv[1]" =~ "-h" || "$argv[1]" =~ "--help") then
set helpheader = 2
if ("$argv[1]" == "-h") then
set helpheader = 1
endif
endif
shift argv
end
#------------------------------------------------------------
# Help output
if ( $helpheader > 0) then
cat << EOF1
NAME
cice.setup
SYNOPSIS
-h || --help
--version
--setvers versno
--case CASE -m MACH
[-e ENV][-p MxN][-g GRID][-s SET1,SET2][--acct ACCT]
--test TEST -m MACH --testid ID
[-e ENV][-p MxN][-g GRID][-s SET1,SET2][--acct ACCT]
[--diff TESTNAME][--bdir DIR][--bgen DIR][--bcmp DIR]
[--tdir PATH]
--suite SUITE[,SUITE2] -m MACH --testid ID
[-e ENV1,ENV2][--acct ACCT][--bdir DIR][--bgen DIR]
[--bcmp DIR][--tdir PATH][--report]
DESCRIPTION
--help, -h : help
--version : generates cice version number
--setvers : updates cice version number in sandbox
--case, -c : case, case directory/name (not with --test or --suite)
--mach, -m : machine, machine name (required)
--env, -e : compiler(s), comma separated (default = $compilers)
--pes, -p : tasks x threads [x blocksize_x x blocksize_y [x maxblocks]] (default is ${pesx})
--acct : account number for the batch submission
--grid, -g : grid, grid (default = ${grid})
--set, -s : case option setting(s), comma separated (default = " ")
--queue : queue for the batch submission
For testing
--test : test, test name (not with --case or --suite)
--suite : test suite, pre-defined set or sets of tests, comma separated (not with --case or --test)
--tdir : directory name where tests will be located
--bdir : baseline directory for regression testing, default ICE_MACHINE_BASELINE
--bgen : directory name where output from current tests are copied
--bcmp : directory name where output from current tests are compared
--testid : test ID, user-defined id for testing (REQUIRED with --test or --suite)
--diff : generate comparison against another case
--report : automatically post results when tests are complete
EXAMPLES
cice.setup --version
cice.setup --setvers 6.0.2
cice.setup -c caseB -m gordon -e cray -s diag1,debug
cice.setup --case ~/caseA --mach cheyenne --env intel --set diag24
cice.setup --test restart -m onyx -e gnu -s debug -testid myid -p 8x4
cice.setup --suite base_suite -m conrad --env intel,cray --testid myv1 --bgen myv1
cice.setup --suite quick_suite,decomp_suite -m cheyenne --testid myv1 --bgen myv1
cice.setup --suite quick_suite -m cheyenne --testid myv2 --bgen myv2 --bcmp myv1
SEE ALSO
cice.setup --help or
User Documentation at https://github.com/cice-consortium/cice/
EOF1
if ($helpheader > 1) then
cat << EOF1
Available --mach and --env combinations are in configuration/scripts/machines and include:
EOF1
set soptions1 = `ls -1 configuration/scripts/machines | grep Macros | sed 's/Macros.//g' `
set soptions = `echo $soptions1 | fmt -1 | sort `
foreach sopt ($soptions)
echo " $sopt"
end
cat << EOF1
Available --set options are in configuration/scripts/options and include:
EOF1
set soptions1 = `ls -1 configuration/scripts/options | grep set_ | sed 's/set_nml.//g' | sed 's/set_env.//g' | sed 's/set_files.//g' `
set soptions = `echo $soptions1 | fmt -1 | sort -u `
foreach sopt ($soptions)
echo " $sopt"
end
cat << EOF1
Available tests are in configuration/scripts/tests and include:
EOF1
set soptions1 = `ls -1 configuration/scripts/tests | grep test_ | grep script | sed 's/test_//g' | sed 's/.script//g' `
set soptions = `echo $soptions1 | fmt -1 | sort `
foreach sopt ($soptions)
echo " $sopt"
end
cat << EOF1
Available sets of predefined suites are in configurations/scripts/tests and include:
EOF1
set soptions1 = `ls -1 configuration/scripts/tests | grep "\.ts" | sed 's/\.ts//g' `
set soptions = `echo $soptions1 | fmt -1 | sort `
foreach sopt ($soptions)
echo " $sopt"
end
endif
exit -1
endif
#------------------------------------------------------------
# Read in command line arguments
echo " "
echo "${0}:"
set argv = ( $initargv[*] )
# check for --version
while (1)
if ($#argv < 1) break;
if ("$argv[1]" =~ "--version" ) then
echo "${0}: This is ${ICE_VERSION}"
exit -1
endif
shift argv
end
set argv = ( $initargv[*] )
# check for --setvers
while (1)
if ($#argv < 1) break;
if ("$argv[1]" =~ "--setvers" ) then
shift argv
if ( $#argv < 1 ) then
echo "${0}: ERROR in --setvers argument"
exit -1
endif
set versno = $argv[1]
${ICE_SCRIPTS}/set_version_number.csh $versno
if ($status != 0) then
echo "${0} ERROR in set_version_numbers.csh"
exit -1
endif
echo "Setting CICE version to ${versno} and exiting"
exit -1
endif
shift argv
end
set argv = ( $initargv[*] )
# read in all options
while (1)
if ( $#argv < 1 ) break;
set option = $argv[1];
# arguments without settings
if ("$option" == "--report") then
set report = 1
shift argv
# arguments with settings
else
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
if ("$option" == "--case" || "$option" == "-c") then
set case = $argv[1]
set docase = 1
else if ("$option" =~ --mach* || "$option" == "-m") then
set machine = $argv[1]
else if ("$option" =~ --env* || "$option" == "-e") then
set compilers = $argv[1]
else if ("$option" == "--test") then
set test = $argv[1]
set dotest = 1
else if ("$option" == "--tdir") then
set tdir = $argv[1]
else if ("$option" == "--grid" || "$option" == "-g") then
set grid = $argv[1]
else if ("$option" == "--queue") then
set queue = $argv[1]
else if ("$option" == "--pes" || "$option" == "-p") then
set pesx = $argv[1]
else if ("$option" == "--acct") then
set acct = $argv[1]
else if ("$option" =~ --set* || "$option" == "-s") then
set sets = $argv[1]
else if ("$option" == "--bdir") then
set bdir = $argv[1]
else if ("$option" == "--bcmp") then
set baseCom = $argv[1]
else if ("$option" == "--bgen") then
set baseGen = $argv[1]
else if ("$option" == "--diff") then
set bfbcomp = $argv[1]
else if ("$option" == "--suite") then
set testsuite = $argv[1]
set dosuite = 1
else if ("$option" == "--testid") then
set testid = $argv[1]
else
echo "${0}: ERROR unknown option $option, use -h for help"
exit -1
endif
shift argv
endif
end
if (${machine} == ${spval}) then
echo "${0}: ERROR in arguments, --mach required"
exit -1
endif
@ dosum = ${docase} + ${dotest} + ${dosuite}
if (${dosum} == 0) then
echo "${0}: ERROR in arguments, --case, --test, or --suite required"
exit -1
endif
if (${dosum} > 1) then
echo "${0}: ERROR in arguments, cannot use more than one of --case, --test, and --suite"
exit -1
endif
if (${dosuite} == 0) then
if ("$compilers" =~ "*,*") then
echo "${0}: ERROR in arguments, cannot set multiple compilers without --suite"
exit -1
else
set compiler = ${compilers}
set machcomp = ${machine}_${compiler}
endif
endif
# tcraig, lets find another way to validate argument
#if (${test} != ${spval} && ${test} != 'smoke' && ${test} != '10day' && ${test} != 'annual' \
# && ${test} != 'restart') then
# echo "${0}: ERROR in arguments. ${test} is not a valid test"
# exit -1
#endif
if ((${dosuite} == 1 || ${dotest} == 1) && ${testid} == ${spval}) then
echo "${0}: ERROR in arguments. --testid must be passed if using --suite or --test"
exit -1
endif
#---------------------------------------------------------------------
# Setup tsfile and test suite support stuff
set tsdir = "."
set tsfile = "caselist.${sdate}-${stime}"
if ( ${dosuite} == 1 ) then
set tsdir = "testsuite.${testid}"
set tsfile = "testsuite.${testid}.${sdate}-${stime}.list"
endif
if ( ${tdir} != ${spval} ) then
set tsdir = ${tdir}
endif
if (-e $tsfile) then
echo "${0}: ERROR in tsfile, this should never happen"
exit -1
endif
set remote = `git remote -v | grep -i origin | grep -i push | sed "s|.*\(https.*\)\s.*|\1|g"`
set branch = `git status | grep -i "on branch" | sed 's|^.*ranch\s*\(\S*\)$|\1|g'`
set hash = `git log | grep -i commit | head -1 | cut -d " " -f 2-`
set hashuser = `git log | grep -i author | head -1 | cut -d : -f 2-`
set hashdate = `git log | grep -i date | head -1 | cut -d : -f 2-`
set cdate = `date -u "+%Y-%m-%d"`
set ctime = `date -u "+%H:%M:%S"`
set vers = ${ICE_VERSION}
set shhash = `echo ${hash} | cut -c 1-10`
if ( ${dosuite} == 0 ) then
set teststring = "${test} ${grid} ${pesx} ${sets}"
if ( $bfbcomp != ${spval} ) then
if ( ${sets} == "" ) then
set teststring = "${teststring} none ${bfbcomp}"
else
set teststring = "${teststring} ${bfbcomp}"
endif
endif
echo ${teststring} >! ${tsfile}
set sets = ""
else
set tarrays = `echo ${testsuite} | sed 's/,/ /g' | fmt -1 | sort -u`
foreach tarray ( ${tarrays} )
if (-e ${tarray}) then
cat ${tarray} >> $tsfile
else if (-e ${tarray}.ts) then
cat ${tarray}.ts >> $tsfile
else
if (-e ${ICE_SCRIPTS}/tests/${tarray}.ts) then
cat ${ICE_SCRIPTS}/tests/${tarray}.ts >> $tsfile
else
echo "${0}: ERROR, cannot find testsuite file ${tarray}, also checked ${ICE_SCRIPTS}/tests/${tarray}.ts"
exit -1
endif
endif
end
if (-e ${tsdir}) then
echo "${0}: ERROR, ${tsdir} already exists"
exit -1
endif
mkdir -p ${tsdir}
if ($status != 0) then
echo "${0}: ERROR, mkdir ${tsdir} aborted"
exit -1
endif
cp -f ${ICE_SCRIPTS}/tests/report_results.csh ${tsdir}
cp -f ${ICE_SCRIPTS}/tests/poll_queue.csh ${tsdir}
foreach file (${tsdir}/suite.run ${tsdir}/suite.submit)
cat >! $file << EOF0
#!/bin/csh -f
set nonomatch && rm -f ciceexe.* && unset nonomatch
EOF0
end
cat >! ${tsdir}/results.csh << EOF0
#!/bin/csh -f
rm -f results.log
echo "#------- " >> results.log
echo "#repo = ${remote}" >> results.log
echo "#bran = ${branch}" >> results.log
echo "#hash = ${hash}" >> results.log
echo "#hshs = ${shhash}" >> results.log
echo "#hshu = ${hashuser}" >> results.log
echo "#hshd = ${hashdate}" >> results.log
echo "#date = ${cdate}" >> results.log
echo "#time = ${ctime}" >> results.log
echo "#mach = ${machine}" >> results.log
echo "#user = ${user}" >> results.log
echo "#vers = ${vers}" >> results.log
echo "#------- " >> results.log
EOF0
chmod +x ${tsdir}/suite.run
chmod +x ${tsdir}/suite.submit
chmod +x ${tsdir}/results.csh
endif
#-------------------------------------------------------------------
# Loop over cases/tests
set ncompilers = "`echo $compilers | sed -e 's/,/ /g'`"
# check that machines and compilers are valid before starting big loop
set doabort = false
foreach compiler ( $ncompilers )
set machcomp = ${machine}_${compiler}
foreach file (env.${machcomp} Macros.${machcomp})
if !(-e ${ICE_SCRIPTS}/machines/$file) then
echo "${0}: ERROR, ${ICE_SCRIPTS}/machines/$file not found"
set doabort = true
endif
end
end
if (${doabort} == true) then
exit -1
endif
# Create a new sets_base variable to store sets passed to cice.setup
set sets_base = "${sets}"
set bfbcomp_base = "$bfbcomp"
foreach compiler ( $ncompilers )
set machcomp = ${machine}_${compiler}
foreach line ( "`cat $tsfile`" )
# Check if line is a comment line
if ( $line:q =~ '#'* || $line:q =~ '$'* || $line:q =~ '!'* ) then
echo "skipping line: $line"
continue
# Check if line is a sleep line, can only happen with suites
else if ( $line:q =~ 'sleep'*) then
cat >> ${tsdir}/suite.submit << EOF
echo "-------test--------------"
echo "$line:q"
$line:q
EOF
echo "adding sleep line: $line"
echo ""
echo "---"
echo ""
continue
endif
source ${ICE_SCRIPTS}/machines/env.${machcomp} -nomodules || exit 2
# Obtain the test name, sets, grid, and PE information from .ts file
set test = `echo $line | cut -d' ' -f1`
set grid = `echo $line | cut -d' ' -f2`
set pesx = `echo $line | cut -d' ' -f3`
set sets_tmp = `echo $line | cut -d' ' -f4`
set bfbcomp_tmp = `echo $line | cut -d' ' -f5`
# Append sets from .ts file to the $sets variable
set sets = "$sets_base,$sets_tmp"
# Create a new bfbcomp_base variable to store bfbcomp passed to cice.setup
# Use bfbcomp_base or bfbcomp_tmp
if ( $bfbcomp_tmp == "" ) then
set bfbcomp = "$bfbcomp_base"
else
set bfbcomp = "$bfbcomp_tmp"
endif
set fbfbcomp = ${spval}
if ($bfbcomp != ${spval}) then
set fbfbcomp = ${machcomp}_${bfbcomp}
endif
#------------------------------------------------------------
# Parse pesx with strict checking, limit pes for machine
set chck = `echo ${pesx} | sed 's/^[0-9][0-9]*x[0-9][0-9]*x[0-9][0-9]*x[0-9][0-9]*x[0-9][0-9]*$/OK/'`
if (${chck} == OK) then
set task = `echo ${pesx} | cut -d x -f 1`
set thrd = `echo ${pesx} | cut -d x -f 2`
set blckx = `echo ${pesx} | cut -d x -f 3`
set blcky = `echo ${pesx} | cut -d x -f 4`
set mblck = `echo ${pesx} | cut -d x -f 5`
if (${task} == 0 || ${thrd} == 0 || ${blckx} == 0 || ${blcky} == 0 || ${mblck} == 0) then
echo "${0}: ERROR in -p argument, cannot have zeros"
exit -1
endif
else
set chck = `echo ${pesx} | sed 's/^[0-9][0-9]*x[0-9][0-9]*x[0-9][0-9]*x[0-9][0-9]*$/OK/'`
if (${chck} == OK) then
set task = `echo ${pesx} | cut -d x -f 1`
set thrd = `echo ${pesx} | cut -d x -f 2`
set blckx = `echo ${pesx} | cut -d x -f 3`
set blcky = `echo ${pesx} | cut -d x -f 4`
set mblck = 0
if (${task} == 0 || ${thrd} == 0 || ${blckx} == 0 || ${blcky} == 0) then
echo "${0}: ERROR in -p argument, cannot have zeros"
exit -1
endif
else
set chck = `echo ${pesx} | sed 's/^[0-9][0-9]*x[0-9][0-9]*$/OK/'`
if (${chck} == OK) then
set task = `echo ${pesx} | cut -d x -f 1`
set thrd = `echo ${pesx} | cut -d x -f 2`
set blckx = 0
set blcky = 0
set mblck = 0
if (${task} == 0 || ${thrd} == 0) then
echo "${0}: ERROR in -p argument, cannot have zeros"
exit -1
endif
else
set chck = `echo ${pesx} | sed 's/^[0-9][0-9]*$/OK/'`
if (${chck} == OK) then
set task = `echo ${pesx} | cut -d x -f 1`
set thrd = 1
set blckx = 0
set blcky = 0
set mblck = 0
if (${task} == 0) then
echo "${0}: ERROR in -p argument, cannot have zeros"
exit -1
endif
else
echo "${0}: ERROR in -p argument, ${pesx}, must be [m], [m]x[n], [m]x[n]x[bx]x[by], or [m]x[n]x[bx]x[by]x[mb] "
exit -1
endif
endif
endif
endif
@ blkreq = ${task} * ${mblck}
# check max threads, reduce threads, increase tasks
if ($?ICE_MACHINE_MAXTHREADS) then
if (${thrd} > ${ICE_MACHINE_MAXTHREADS}) then
@ pesreq = ${task} * ${thrd}
@ task = ${pesreq} / ${ICE_MACHINE_MAXTHREADS}
@ thrd = ${ICE_MACHINE_MAXTHREADS}
@ peschk = ${task} * ${thrd}
if (${pesreq} > ${peschk}) then
@ task = ${task} + 1
endif
# echo "tcx1 reset to $task $thrd $mblck"
endif
endif
# check max pes, reduce tasks
if ($?ICE_MACHINE_MAXPES) then
@ pesreq = ${task} * ${thrd}
if (${pesreq} > ${ICE_MACHINE_MAXPES}) then
@ task = ${ICE_MACHINE_MAXPES} / ${thrd}
# echo "tcx2 reset to $task $thrd $mblck"
endif
endif
# check max blocks and adjust as needed
if ($mblck > 0) then
@ mblck = ${blkreq} / ${task}
@ blkchk = ${task} * ${mblck}
if (${blkreq} > ${blkchk}) then
@ mblck = $mblck + 1
endif
# echo "tcx3 reset to $task $thrd $mblck"
endif
# update pesx based on use defined settings and machine limits to reflect actual value
set pesx = ${task}x${thrd}x${blckx}x${blcky}x${mblck}
if (${mblck} == 0) then
set pesx = ${task}x${thrd}x${blckx}x${blcky}
endif
if (${blckx} == 0 || ${blcky} == 0) then
set pesx = ${task}x${thrd}
endif
set testname_noid = ${spval}
# create case for test cases
if (${docase} == 0) then
set soptions = ""
# Create sorted array and remove duplicates and "none"
set setsarray = `echo ${sets} | sed 's/,/ /g' | fmt -1 | sort -u`
if ("${setsarray}" != "") then
foreach field (${setsarray})
if (${field} != "none") then
set soptions = ${soptions}"_"${field}
endif
end
endif
# soptions starts with _
set testname_noid = "${machcomp}_${test}_${grid}_${pesx}${soptions}"
set testname_base = "${machcomp}_${test}_${grid}_${pesx}${soptions}.${testid}"
set testname = "${tsdir}/${testname_base}"
set case = ${testname}
endif
if (-d ${case}) then
echo "${0}: ERROR, case ${case} already exists"
# exit -1
continue
endif
if (${case} =~ */*) then
set casename = $case:t
else
set casename = $case
endif
#------------------------------------------------------------
# Setup case directory, copy files to case directory
mkdir -p ${case}
echo "`date` ${0} $initargv[*]" >> ${case}/README.case
cd ${case}
set casedir = `pwd`
set casescr = "${casedir}/casescripts"
if !( -d ${casescr}) mkdir ${casescr}
# set default test output as failure
if (${docase} == 0) then
echo "#---" >! test_output
echo "FAIL ${testname_noid} build" >> test_output
echo "FAIL ${testname_noid} run" >> test_output
endif
# from basic script dir to case
foreach file (cice.build cice.settings Makefile ice_in makdep.c setup_run_dirs.csh timeseries.csh timeseries.py)
if !(-e ${ICE_SCRIPTS}/$file) then
echo "${0}: ERROR, ${ICE_SCRIPTS}/$file not found"
exit -1
endif
cp -f -p ${ICE_SCRIPTS}/$file ${casedir}
end
# from machines dir to case
foreach file (env.${machcomp} Macros.${machcomp})
if !(-e ${ICE_SCRIPTS}/machines/$file) then
echo "${0}: ERROR, ${ICE_SCRIPTS}/machines/$file not found"
exit -1
endif
cp -f -p ${ICE_SCRIPTS}/machines/$file ${casedir}
end
# from basic script dir to casescr
foreach file (parse_namelist.sh parse_settings.sh parse_namelist_from_env.sh cice_decomp.csh cice.run.setup.csh cice.test.setup.csh)
if !(-e ${ICE_SCRIPTS}/$file) then
echo "${0}: ERROR, ${ICE_SCRIPTS}/$file not found"
exit -1
endif
cp -f -p ${ICE_SCRIPTS}/$file ${casescr}
end
cd ${casedir}
set quietmode = false
if ($?ICE_MACHINE_QUIETMODE) then
set quietmode = ${ICE_MACHINE_QUIETMODE}
endif
if (${acct} == ${spval}) then
if (-e ~/.cice_proj) then
set acct = `head -1 ~/.cice_proj`
else
set acct = ${ICE_MACHINE_ACCT}
endif
endif
if (${queue} == ${spval}) then
if (-e ~/.cice_queue) then
set queue = `head -1 ~/.cice_queue`
else
set queue = ${ICE_MACHINE_QUEUE}
endif
endif
#------------------------------------------------------------
# Compute a default blocksize
setenv ICE_DECOMP_GRID ${grid}
setenv ICE_DECOMP_NTASK ${task}
setenv ICE_DECOMP_NTHRD ${thrd}
setenv ICE_DECOMP_BLCKX ${blckx}
setenv ICE_DECOMP_BLCKY ${blcky}
setenv ICE_DECOMP_MXBLCKS ${mblck}
source ${casescr}/cice_decomp.csh
if ($status != 0) then
echo "${0}: ERROR, cice_decomp.csh aborted"
exit -1
endif
echo "ICE_SANDBOX = ${ICE_SANDBOX}"
echo "ICE_CASENAME = ${casename}"
echo "ICE_CASEDIR = ${casedir}"
echo "ICE_MACHINE = ${machine}"
echo "ICE_COMPILER = ${compiler}"
echo "ICE_PES = ${task}x${thrd}"
echo "ICE_GRID = ${grid} (${ICE_DECOMP_NXGLOB}x${ICE_DECOMP_NYGLOB}) blocksize=${ICE_DECOMP_BLCKX}x${ICE_DECOMP_BLCKY}x${ICE_DECOMP_MXBLCKS}"
echo "ICE_DECOMP = ${ICE_DECOMP_DECOMP} ${ICE_DECOMP_DSHAPE}"
#------------------------------------------------------------
# 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
# cice.setup settings
nprocs = ${task}
nx_global = ${ICE_DECOMP_NXGLOB}
ny_global = ${ICE_DECOMP_NYGLOB}
block_size_x = ${ICE_DECOMP_BLCKX}
block_size_y = ${ICE_DECOMP_BLCKY}
max_blocks = ${ICE_DECOMP_MXBLCKS}
distribution_type = '${ICE_DECOMP_DECOMP}'
processor_shape = '${ICE_DECOMP_DSHAPE}'
version_name = '${ICE_VERSION}'
EOF1
# If this is a baseline-compare test, modify ICE_RUNDIR
if ($bdir != ${spval}) then
setenv basedir_tmp ${bdir}
else
setenv basedir_tmp ${ICE_MACHINE_BASELINE}
endif
if ("$baseGen" =~ "default") then
set d1 = `echo ${cdate} | cut -c 3- | sed 's/-//g'`
set t1 = `echo ${ctime} | sed 's/://g'`
set baseGen = cice.${shhash}.${d1}-${t1}
endif
if ("$baseCom" =~ "default") then
set baseCom = `ls -t $basedir_tmp | head -1`
endif
cat >! ${fsmods} << EOF1
# cice.setup settings
setenv ICE_SANDBOX ${ICE_SANDBOX}
setenv ICE_SCRIPTS ${ICE_SCRIPTS}
setenv ICE_CASENAME ${casename}
setenv ICE_CASEDIR ${casedir}
setenv ICE_MACHINE ${machine}
setenv ICE_COMPILER ${compiler}
setenv ICE_MACHCOMP ${machcomp}
setenv ICE_RUNDIR ${ICE_MACHINE_WKDIR}/${casename}
setenv ICE_GRID ${grid}
#setenv ICE_NXGLOB ${ICE_DECOMP_NXGLOB} # moved to namelist
#setenv ICE_NYGLOB ${ICE_DECOMP_NYGLOB} # moved to namelist
setenv ICE_NTASKS ${task}
setenv ICE_NTHRDS ${thrd}
#setenv ICE_MXBLCKS ${ICE_DECOMP_MXBLCKS} # moved to namelist
#setenv ICE_BLCKX ${ICE_DECOMP_BLCKX} # moved to namelist
#setenv ICE_BLCKY ${ICE_DECOMP_BLCKY} # moved to namelist
setenv ICE_BASELINE ${basedir_tmp}
setenv ICE_BASEGEN ${baseGen}
setenv ICE_BASECOM ${baseCom}
setenv ICE_SPVAL ${spval}
setenv ICE_QUIETMODE ${quietmode}
setenv ICE_TEST ${test}
setenv ICE_TESTNAME ${testname_noid}
setenv ICE_TESTID ${testid}
setenv ICE_BFBCOMP ${fbfbcomp}
setenv ICE_ACCOUNT ${acct}
setenv ICE_QUEUE ${queue}
EOF1
if (${sets} != "") then
set setsx = `echo ${sets} | sed 's/,/ /g'`
set setsxorig = "$setsx"
set setsx = ""
foreach name ($setsxorig)
if (-e ${ICE_SCRIPTS}/options/set_files.${name}) then
echo "adding options files from set_files.${name}"
echo "`date` ${0} adding options files from set_files.${name}" >> ${casedir}/README.case
set setsnew = `cat ${ICE_SCRIPTS}/options/set_files.${name}`
foreach nset ($setsnew)
if ($nset !~ "#*") then
set setsx = "$setsx $nset"
endif
end
else
set setsx = "$setsx $name"
endif
end
else
set setsx = ""
endif
if (${docase} == 0) then
# from test options to casescr in case any test time changes are applied
cp -f -p ${ICE_SCRIPTS}/tests/comparebfb.csh ${casescr}
cp -f -p ${ICE_SCRIPTS}/tests/comparelog.csh ${casescr}
if (-e ${ICE_SCRIPTS}/tests/test_${test}.files) then
cp -f -p ${ICE_SCRIPTS}/tests/test_${test}.files ${casescr}
foreach file (`cat ${casescr}/test_${test}.files`)
if (-e ${ICE_SCRIPTS}/options/$file) then
cp -f -p ${ICE_SCRIPTS}/options/$file ${casescr}
else
echo "${0}: ERROR, could not find $file from test_${test}.files"
exit -1
endif
end
endif
endif
foreach name (${grid} $setsx)
set found = 0
if (-e ${ICE_SCRIPTS}/options/set_nml.${name}) then
cat >> ${fimods} << EOF2
# set_nml.${name}
EOF2
cat ${ICE_SCRIPTS}/options/set_nml.${name} >> ${fimods}
cat >> ${fimods} << EOF2
EOF2
echo "adding namelist mods set_nml.${name}"
echo "`date` ${0} adding namelist modes set_nml.${name}" >> ${casedir}/README.case
set found = 1
endif
if (-e ${ICE_SCRIPTS}/options/set_env.${name}) then
cat >> ${fsmods} << EOF2
# set_env.${name}
EOF2
cat ${ICE_SCRIPTS}/options/set_env.${name} >> ${fsmods}
cat >> ${fsmods} << EOF2
EOF2
echo "adding env mods set_env.${name}"
echo "`date` ${0} adding namelist modes set_env.${name}" >> ${casedir}/README.case
set found = 1
endif
if (${found} == 0) then
echo "${0}: ERROR, ${ICE_SCRIPTS}/options/set_[nml,env].${name} not found"
exit -1
endif
end
${casescr}/parse_settings.sh cice.settings ${fsmods}
${casescr}/parse_namelist.sh ice_in ${fimods}
if ($status != 0) then
echo "${0}: ERROR, parse_namelist.sh aborted"
exit -1
endif
source ./cice.settings
source ./env.${machcomp} -nomodules || exit 2
${casescr}/parse_namelist_from_env.sh ice_in
#------------------------------------------------------------
# Generate run script
${casescr}/cice.run.setup.csh
if ($status != 0) then
echo "${0}: ERROR, cice.run.setup.csh aborted"
exit -1
endif
#------------------------------------------------------------
# Generate test script
if (${docase} == 0) then
# Print information to stdout
echo "Creating scripts for ${test} test"
# Generate test script
${casescr}/cice.test.setup.csh
if ($status != 0) then
echo "${0}: ERROR, cice.test.setup.csh aborted"
exit -1
endif
# # Initial test_output file
# echo "#---" >! test_output
# echo "PEND ${testname_noid} " >> test_output
endif
#------------------------------------------------------------
# Generate testsuite stuff
if ( ${dosuite} == 1 ) then
cd ${ICE_SANDBOX}
# Write build and run commands to suite.run and suite.submit
cat >> ${tsdir}/results.csh << EOF
cat ${testname_base}/test_output >> results.log
EOF
foreach file (${tsdir}/suite.run ${tsdir}/suite.submit)
cat >> $file << EOF
echo "-------test--------------"
echo "${testname_base}"
cd ${testname_base}
source ./cice.settings
set ciceexe = "../ciceexe.\${ICE_COMPILER}.\${ICE_COMMDIR}.\${ICE_BLDDEBUG}.\${ICE_THREADED}.\${ICE_IOTYPE}"
./cice.build --exe \${ciceexe}
if !(-e \${ciceexe}) cp -p \${ICE_RUNDIR}/cice \${ciceexe}
EOF
end
cat >> ${tsdir}/suite.submit << EOF
./cice.submit | tee -a ../suite.jobs
EOF
cat >> ${tsdir}/suite.run << EOF
./cice.test
EOF
foreach file (${tsdir}/suite.run ${tsdir}/suite.submit)
cat >> $file << EOF
cd ..
EOF
end
# Reset case for the next test in suite
set case = ${spval}
echo ""
echo "---"
echo ""
endif
# This is the foreach end for the testsuite
end
# This is the foreach end for the compilers
end
#-----------------------------------------------------
# more testsuite stuff
if ( ${dosuite} == 1 ) then
# Delete reused ciceexe files at the end to save space
foreach file (${tsdir}/suite.run ${tsdir}/suite.submit)
cat >> $file << EOF0
set nonomatch && rm -f ciceexe.* && unset nonomatch
EOF0
end
# Add code to results.csh to count the number of failures
cat >> ${tsdir}/results.csh << EOF
cat ./results.log
set pends = \`cat ./results.log | grep PEND | wc -l\`
set failures = \`cat ./results.log | grep FAIL | wc -l\`
set success = \`cat ./results.log | grep 'PASS\|COPY' | wc -l\`
set comments = \`cat ./results.log | grep "#" | wc -l\`
set alltotal = \`cat ./results.log | wc -l\`
@ total = \$alltotal - \$comments
echo "#------- " >> results.log
echo " " >> results.log
echo "#totl = \$total" >> results.log
echo "#pass = \$success" >> results.log
echo "#fail = \$failures" >> results.log
echo "#pend = \$pends" >> results.log
echo ""
echo "Descriptors:"
echo " PASS - successful completion"
echo " COPY - previously compiled code was copied for new test"
echo " MISS - comparison data is missing"
echo " PEND - run has been submitted to queue and is waiting or failed submission"
echo " FAIL - test is still executing, did not complete, or completed and failed"
echo ""
echo "\$success of \$total tests PASSED"
echo "\$failures of \$total tests FAILED"
echo "\$pends of \$total tests PENDING"
exit \$failures
EOF
if ($?ICE_MACHINE_QSTAT) then
cat >! ${tsdir}/poll_queue.env << EOF0
setenv ICE_MACHINE_QSTAT ${ICE_MACHINE_QSTAT}
EOF0
endif