-
Notifications
You must be signed in to change notification settings - Fork 131
/
cice_decomp.csh
executable file
·158 lines (135 loc) · 4.11 KB
/
cice_decomp.csh
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
#!/bin/csh -f
#--- inputs ---
#echo "${0:t} input ICE_DECOMP_GRID = $ICE_DECOMP_GRID"
#echo "${0:t} input ICE_DECOMP_NTASK = $ICE_DECOMP_NTASK"
#echo "${0:t} input ICE_DECOMP_NTHRD = $ICE_DECOMP_NTHRD"
#echo "${0:t} input ICE_DECOMP_BLCKX = $ICE_DECOMP_BLCKX"
#echo "${0:t} input ICE_DECOMP_BLCKY = $ICE_DECOMP_BLCKY"
#echo "${0:t} input ICE_DECOMP_MXBLCKS = $ICE_DECOMP_MXBLCKS"
set grid = $ICE_DECOMP_GRID
set task = $ICE_DECOMP_NTASK
set thrd = $ICE_DECOMP_NTHRD
if (${task} <= 0 || ${thrd} <= 0) then
echo "${0:t}: ERROR task and thread must be gt 0"
exit -9
endif
#--- computation ---
@ cicepes = ${task} * ${thrd}
if (${grid} == 'col') then
set nxglob = 5
set nyglob = 5
if (${cicepes} <= 1) then
set blckx = 5; set blcky = 5
else
set blckx = 1; set blcky = 1
endif
else if (${grid} == 'gbox128') then
set nxglob = 128
set nyglob = 128
if (${cicepes} <= 1) then
set blckx = 128; set blcky = 128
else if (${cicepes} <= 8) then
set blckx = 32; set blcky = 32
else if (${cicepes} <= 32) then
set blckx = 16; set blcky = 16
else
set blckx = 8; set blcky = 8
endif
else if (${grid} == 'gbox80') then
set nxglob = 80
set nyglob = 80
if (${cicepes} <= 1) then
set blckx = 80; set blcky = 80
else if (${cicepes} <= 8) then
set blckx = 20; set blcky = 20
else
set blckx = 8; set blcky = 8
endif
else if (${grid} == 'gx3') then
set nxglob = 100
set nyglob = 116
if (${cicepes} <= 1) then
set blckx = 100; set blcky = 116
else if (${cicepes} <= 8) then
set blckx = 25; set blcky = 29
else if (${cicepes} <= 32) then
set blckx = 5; set blcky = 29
else
set blckx = 5; set blcky = 4
endif
else if (${grid} == 'gx1') then
set nxglob = 320
set nyglob = 384
if (${cicepes} <= 16) then
set blckx = 40; set blcky = 48
else if (${cicepes} <= 20) then
set blckx = 32; set blcky = 48
else if (${cicepes} <= 32) then
set blckx = 20; set blcky = 24
else if (${cicepes} <= 40) then
set blckx = 16; set blcky = 24
else if (${cicepes} < 80) then
set blckx = 10; set blcky = 16
else if (${cicepes} == 80) then
set blckx = 8; set blcky = 16
else
set blckx = 10; set blcky = 12
endif
else if (${grid} == 'tx1') then
set nxglob = 360
set nyglob = 240
if (${cicepes} <= 16) then
set blckx = 90; set blcky = 60
else if (${cicepes} <= 64) then
set blckx = 20; set blcky = 20
else
set blckx = 10; set blcky = 10
endif
# this is for unit testing
else if (${grid} == 'none') then
set nxglob = 1
set nyglob = 1
set blckx = 1; set blcky = 1
else
echo "${0:t}: ERROR unknown grid ${grid}"
exit -9
endif
# check and override
if (${ICE_DECOMP_BLCKX} > 0 && ${ICE_DECOMP_BLCKY} > 0) then
set blckx = ${ICE_DECOMP_BLCKX}
set blcky = ${ICE_DECOMP_BLCKY}
else if (${ICE_DECOMP_BLCKX} < 1 && ${ICE_DECOMP_BLCKY} < 1) then
# continue, use values computed above
else
echo "${0:t}: ERROR user defined blocksize illegal"
exit -9
endif
@ bx = $nxglob / ${blckx}
if ($bx * ${blckx} != $nxglob) @ bx = $bx + 1
@ by = $nyglob / ${blcky}
if ($by * ${blcky} != $nyglob) @ by = $by + 1
@ m = ($bx * $by) / ${task}
if ($m * ${task} != $bx * $by) @ m = $m + 1
set mxblcks = $m
# override
if (${ICE_DECOMP_MXBLCKS} > 0) set mxblcks = ${ICE_DECOMP_MXBLCKS}
set decomp = 'cartesian'
set dshape = 'slenderX2'
if (${nxglob} % ${cicepes} != 0) set decomp = 'roundrobin'
if (${mxblcks} * ${blcky} * 2 < ${nyglob}) set decomp = 'roundrobin'
#--- outputs ---
setenv ICE_DECOMP_NXGLOB $nxglob
setenv ICE_DECOMP_NYGLOB $nyglob
setenv ICE_DECOMP_BLCKX $blckx
setenv ICE_DECOMP_BLCKY $blcky
setenv ICE_DECOMP_MXBLCKS $mxblcks
setenv ICE_DECOMP_DECOMP $decomp
setenv ICE_DECOMP_DSHAPE $dshape
#echo "${0:t} output ICE_DECOMP_NXGLOB = $ICE_DECOMP_NXGLOB"
#echo "${0:t} output ICE_DECOMP_NYGLOB = $ICE_DECOMP_NYGLOB"
#echo "${0:t} output ICE_DECOMP_BLCKX = $ICE_DECOMP_BLCKX"
#echo "${0:t} output ICE_DECOMP_BLCKY = $ICE_DECOMP_BLCKY"
#echo "${0:t} output ICE_DECOMP_MXBLCKS = $ICE_DECOMP_MXBLCKS"
#echo "${0:t} output ICE_DECOMP_DECOMP = $ICE_DECOMP_DECOMP"
#echo "${0:t} output ICE_DECOMP_DSHAPE = $ICE_DECOMP_DSHAPE"
exit 0