1 | #!/bin/bash
|
---|
2 | ################################################################################
|
---|
3 | # This script runs the examples tests (i.e. contents of examples directory,
|
---|
4 | # which are implementations of the tutorials found at
|
---|
5 | # https://issm.jpl.nasa.gov/documentation/tutorials/). It is intended to be
|
---|
6 | # called from jenkins/jenkins.sh.
|
---|
7 | #
|
---|
8 | # runme files are modified as needed to fill in statements that would otherwise
|
---|
9 | # be added by user.
|
---|
10 | #
|
---|
11 | # NOTE:
|
---|
12 | # - Indentation of replacement string literals (e.g. 'STEP_EIGHT') is set to
|
---|
13 | # nest cleanly in this file, but will result in unclean nesting in the runme
|
---|
14 | # files (which should not be an issue)
|
---|
15 | # - Single-line string replacements in runme.m can effectively be performed
|
---|
16 | # using sed. When performing multi-line replacements, perl is a better
|
---|
17 | # option.
|
---|
18 | #
|
---|
19 | # TODO:
|
---|
20 | # - Figure out how to remove \ and \n\ from multiline string variables while
|
---|
21 | # preserving formatting when value is printed to file.
|
---|
22 | ################################################################################
|
---|
23 |
|
---|
24 | ## Constants
|
---|
25 | #
|
---|
26 | RUNME_FILE='runme.m'
|
---|
27 | RUN_EXAMPLE=0
|
---|
28 | STATUS_HANDLING="\
|
---|
29 | disp('SUCCESS');\n\
|
---|
30 | catch me\n\
|
---|
31 | message=getReport(me);\n\
|
---|
32 | fprintf('%s',message);\n\
|
---|
33 | disp('FAILURE');\n\
|
---|
34 | end\n\
|
---|
35 | exit\n\
|
---|
36 | "
|
---|
37 |
|
---|
38 | cd $ISSM_DIR/examples
|
---|
39 |
|
---|
40 | for dir in ./* ; do
|
---|
41 | if [ -d "${dir}" ]; then
|
---|
42 | # # Temporary short circuit to check single example
|
---|
43 | # example="./AMR"
|
---|
44 | # if [ "${dir}" != "${example}" ]; then
|
---|
45 | # continue
|
---|
46 | # fi
|
---|
47 |
|
---|
48 | # Some of the examples are incomplete (on purpose). As such, we will
|
---|
49 | # have to populate the missing steps in order to make sure that
|
---|
50 | # everything is working.
|
---|
51 |
|
---|
52 | cd ${dir}
|
---|
53 | if [ "${dir}" == "./AMR" ]; then
|
---|
54 | sed -i.bak -e '1 s|^.*$|try\n\n&|' $RUNME_FILE
|
---|
55 | RUN_EXAMPLE=1
|
---|
56 | elif [ "${dir}" == "./Data" ]; then
|
---|
57 | echo 'Directory contains datasets only; no example to run.'
|
---|
58 | RUN_EXAMPLE=0
|
---|
59 | elif [ "${dir}" == "./EsaGRACE" ]; then
|
---|
60 | sed -i.bak -e 's|steps=\[1\];|steps=\[1:5\];\n\ntry\n|' $RUNME_FILE
|
---|
61 | RUN_EXAMPLE=1
|
---|
62 | elif [ "${dir}" == "./EsaWahr" ]; then
|
---|
63 | sed -i.bak -e 's|steps=\[1\];|steps=\[1:7\];\n\ntry\n|' $RUNME_FILE
|
---|
64 | RUN_EXAMPLE=1
|
---|
65 | elif [ "${dir}" == "./Functions" ]; then
|
---|
66 | echo "Directory contains functions only; no example to run."
|
---|
67 | RUN_EXAMPLE=0
|
---|
68 | elif [ "${dir}" == "./Greenland" ]; then
|
---|
69 | # STEP_SEVEN #{{{
|
---|
70 | STEP_SEVEN="\
|
---|
71 | if any(steps==7)\n\
|
---|
72 | disp(' Step 7: Historical Relaxation run');\n\
|
---|
73 | md = loadmodel('./Models/Greenland.Control_drag');\n\
|
---|
74 | \n\
|
---|
75 | load smbbox\n\
|
---|
76 | \n\
|
---|
77 | %convert mesh x,y into the Box projection\n\
|
---|
78 | [md.mesh.lat,md.mesh.long] = xy2ll(md.mesh.x,md.mesh.y,+1,39,71);\n\
|
---|
79 | [xi,yi]= ll2xy(md.mesh.lat,md.mesh.long,+1,45,70);\n\
|
---|
80 | \n\
|
---|
81 | %Interpolate and set surface mass balance\n\
|
---|
82 | index = BamgTriangulate(x1(:),y1(:));\n\
|
---|
83 | smb_mo = InterpFromMeshToMesh2d(index,x1(:),y1(:),smbmean(:),xi,yi);\n\
|
---|
84 | smb = smb_mo*12/1000*md.materials.rho_freshwater/md.materials.rho_ice;\n\
|
---|
85 | md.smb.mass_balance = [smb;1 ];\n\
|
---|
86 | \n\
|
---|
87 | %Set transient options, run for 20 years, saving every 5 timesteps\n\
|
---|
88 | md.timestepping.time_step=0.2;\n\
|
---|
89 | md.timestepping.final_time=200;\n\
|
---|
90 | md.settings.output_frequency=5;\n\
|
---|
91 | \n\
|
---|
92 | %Additional options\n\
|
---|
93 | md.inversion.iscontrol=0;\n\
|
---|
94 | md.transient.requested_outputs={'IceVolume','TotalSmb', ...\n\
|
---|
95 | 'SmbMassBalance'};\n\
|
---|
96 | md.verbose=verbose('solution',true,'module',true);\n\
|
---|
97 | \n\
|
---|
98 | %Go solve\n\
|
---|
99 | md.cluster=generic('name',oshostname,'np',2);\n\
|
---|
100 | md=solve(md,'Transient');\n\
|
---|
101 | \n\
|
---|
102 | save ./Models/Greenland.HistoricTransient_200yr md;\n\
|
---|
103 | end\n\
|
---|
104 | "
|
---|
105 | #}}}
|
---|
106 | # STEP_EIGHT #{{{
|
---|
107 | STEP_EIGHT="\
|
---|
108 | if any(steps==8)\n\
|
---|
109 | %Load historic transient model\n\
|
---|
110 | md=loadmodel('./Models/Greenland.HistoricTransient_200yr');\n\
|
---|
111 | \n\
|
---|
112 | %Create Line Plots of relaxation run. Create a figure.\n\
|
---|
113 | figure;\n\
|
---|
114 | \n\
|
---|
115 | %Save surface mass balance, by looping through 200 years (1000 steps)\n\
|
---|
116 | %Note, the first output will always contain output from time step 1\n\
|
---|
117 | surfmb=[];\n\
|
---|
118 | for i=2:201;\n\
|
---|
119 | surfmb=[surfmb md.results.TransientSolution(i).SmbMassBalance];\n\
|
---|
120 | end\n\
|
---|
121 | \n\
|
---|
122 | %Plot surface mass balance time series in first subplot\n\
|
---|
123 | subplot(3,1,1);\n\
|
---|
124 | plot([1:200],mean(surfmb));\n\
|
---|
125 | \n\
|
---|
126 | %Title this plot Mean surface mass balance\n\
|
---|
127 | title('Mean Surface mass balance');\n\
|
---|
128 | \n\
|
---|
129 | %Save velocity by looping through 200 years\n\
|
---|
130 | vel=[];\n\
|
---|
131 | for i=2:201;\n\
|
---|
132 | vel=[vel md.results.TransientSolution(i).Vel];\n\
|
---|
133 | end\n\
|
---|
134 | \n\
|
---|
135 | %Plot velocity time series in second subplot\n\
|
---|
136 | subplot(3,1,2);\n\
|
---|
137 | plot([1:200],mean(vel));\n\
|
---|
138 | \n\
|
---|
139 | %Title this plot Mean Velocity\n\
|
---|
140 | title('Mean Velocity');\n\
|
---|
141 | \n\
|
---|
142 | %Save Ice Volume by looping through 200 years\n\
|
---|
143 | volume=[];\n\
|
---|
144 | for i=2:201;\n\
|
---|
145 | volume=[volume md.results.TransientSolution(i).IceVolume];\n\
|
---|
146 | end\n\
|
---|
147 | \n\
|
---|
148 | %Plot volume time series in third subplot\n\
|
---|
149 | subplot(3,1,3);\n\
|
---|
150 | plot([1:200],volume);\n\
|
---|
151 | \n\
|
---|
152 | %Title this plot Mean Velocity and add an x label of years\n\
|
---|
153 | title('Ice Volume');\n\
|
---|
154 | xlabel('years');\n\
|
---|
155 | end\n\
|
---|
156 | "
|
---|
157 | #}}}
|
---|
158 | sed -i.bak -e 's|steps=\[1\];|steps=\[1:8\];\n\ntry\n|' $RUNME_FILE
|
---|
159 | perl -0755 -p -i -e "s|if any\(steps==7\).*% step 7 end|${STEP_SEVEN}|s" $RUNME_FILE
|
---|
160 | perl -0755 -p -i -e "s|if any\(steps==8\).*% step 8 end|${STEP_EIGHT}|s" $RUNME_FILE
|
---|
161 | RUN_EXAMPLE=1
|
---|
162 | elif [ "${dir}" == "./IceBridge" ]; then
|
---|
163 | sed -i.bak -e 's|steps=\[1\];|steps=\[1:5\];\n\ntry\n|' $RUNME_FILE
|
---|
164 | perl -0755 -p -i -e "s|\n\t%Mesh greenland without.*return;\n||s" $RUNME_FILE
|
---|
165 | RUN_EXAMPLE=1
|
---|
166 | elif [ "${dir}" == "./IceflowModels" ]; then
|
---|
167 | sed -i.bak -e '1 s|^.*$|try\n\n&|' $RUNME_FILE
|
---|
168 | RUN_EXAMPLE=1
|
---|
169 | elif [ "${dir}" == "./Inversion" ]; then
|
---|
170 | sed -i.bak -e 's|steps=\[1\];|steps=\[1:4\];\n\ntry\n|' $RUNME_FILE
|
---|
171 | RUN_EXAMPLE=1
|
---|
172 | elif [ "${dir}" == "./ISMIP" ]; then
|
---|
173 | # TODO:
|
---|
174 | # - Run test again with ISMIPF configuration (will likely need to
|
---|
175 | # add conditional after 'RUN_EXAMPLE -eq 1' block)
|
---|
176 | #
|
---|
177 |
|
---|
178 | # RUNME #{{{
|
---|
179 | RUNME="\
|
---|
180 | try\n\
|
---|
181 | %which steps to perform; steps are from 1 to 8\n\
|
---|
182 | %step 7 is specific to ISMIPA\n\
|
---|
183 | %step 8 is specific to ISMIPF\n\
|
---|
184 | \n\
|
---|
185 | steps=[1:7]; %ISMIPA\n\
|
---|
186 | %steps=[1:6,8]; %ISMIPF\n\
|
---|
187 | \n\
|
---|
188 | % parameter file to be used, choose between IsmipA.par or IsmipF.par\n\
|
---|
189 | ParamFile='IsmipA.par';\n\
|
---|
190 | %ParamFile='IsmipF.par';\n\
|
---|
191 | \n\
|
---|
192 | %Run Steps\n\
|
---|
193 | \n\
|
---|
194 | %Mesh Generation #1\n\
|
---|
195 | if any(steps==1)\n\
|
---|
196 | %initialize md as a new model #help model\n\
|
---|
197 | %->\n\
|
---|
198 | md=model();\n\
|
---|
199 | % generate a squaremesh #help squaremesh\n\
|
---|
200 | % Side is 80 km long with 20 points\n\
|
---|
201 | %->\n\
|
---|
202 | if(ParamFile=='IsmipA.par'),\n\
|
---|
203 | md=squaremesh(md,80000,80000,20,20);\n\
|
---|
204 | elseif(ParamFile=='IsmipF.par'),\n\
|
---|
205 | md=squaremesh(md,100000,100000,30,30);\n\
|
---|
206 | end\n\
|
---|
207 | % plot the given mesh #plotdoc\n\
|
---|
208 | %->\n\
|
---|
209 | plotmodel(md,'data','mesh')\n\
|
---|
210 | % save the given model\n\
|
---|
211 | %->\n\
|
---|
212 | save ./Models/ISMIP.Mesh_generation md;\n\
|
---|
213 | end\n\
|
---|
214 | \n\
|
---|
215 | %Masks #2\n\
|
---|
216 | if any(steps==2)\n\
|
---|
217 | % load the preceding step #help loadmodel\n\
|
---|
218 | % path is given by the organizer with the name of the given step\n\
|
---|
219 | %->\n\
|
---|
220 | md = loadmodel('./Models/ISMIP.Mesh_generation');\n\
|
---|
221 | % set the mask #help setmask\n\
|
---|
222 | % all MISMIP nodes are grounded\n\
|
---|
223 | %->\n\
|
---|
224 | md=setmask(md,'','');\n\
|
---|
225 | % plot the given mask #md.mask to locate the field\n\
|
---|
226 | %->\n\
|
---|
227 | plotmodel(md,'data',md.mask.ocean_levelset);\n\
|
---|
228 | % save the given model\n\
|
---|
229 | %->\n\
|
---|
230 | save ./Models/ISMIP.SetMask md;\n\
|
---|
231 | end\n\
|
---|
232 | \n\
|
---|
233 | %Parameterization #3\n\
|
---|
234 | if any(steps==3)\n\
|
---|
235 | % load the preceding step #help loadmodel\n\
|
---|
236 | % path is given by the organizer with the name of the given step\n\
|
---|
237 | %->\n\
|
---|
238 | md = loadmodel('./Models/ISMIP.SetMask');\n\
|
---|
239 | % parametrize the model # help parameterize\n\
|
---|
240 | % you will need to fil-up the parameter file defined by the\n\
|
---|
241 | % ParamFile variable\n\
|
---|
242 | %->\n\
|
---|
243 | md=parameterize(md,ParamFile);\n\
|
---|
244 | % save the given model\n\
|
---|
245 | %->\n\
|
---|
246 | save ./Models/ISMIP.Parameterization md;\n\
|
---|
247 | end\n\
|
---|
248 | \n\
|
---|
249 | %Extrusion #4\n\
|
---|
250 | if any(steps==4)\n\
|
---|
251 | \n\
|
---|
252 | % load the preceding step #help loadmodel\n\
|
---|
253 | % path is given by the organizer with the name of the given step\n\
|
---|
254 | %->\n\
|
---|
255 | md = loadmodel('./Models/ISMIP.Parameterization');\n\
|
---|
256 | % vertically extrude the preceding mesh #help extrude\n\
|
---|
257 | % only 5 layers exponent 1\n\
|
---|
258 | %->\n\
|
---|
259 | md=extrude(md,5,1);\n\
|
---|
260 | % plot the 3D geometry #plotdoc\n\
|
---|
261 | %->\n\
|
---|
262 | plotmodel(md,'data',md.geometry.base)\n\
|
---|
263 | % save the given model\n\
|
---|
264 | %->\n\
|
---|
265 | save ./Models/ISMIP.Extrusion md;\n\
|
---|
266 | end\n\
|
---|
267 | \n\
|
---|
268 | %Set the flow computing method #5\n\
|
---|
269 | if any(steps==5)\n\
|
---|
270 | \n\
|
---|
271 | % load the preceding step #help loadmodel\n\
|
---|
272 | % path is given by the organizer with the name of the given step\n\
|
---|
273 | %->\n\
|
---|
274 | md = loadmodel('./Models/ISMIP.Extrusion');\n\
|
---|
275 | % set the approximation for the flow computation #help setflowequation\n\
|
---|
276 | % We will be using the Higher Order Model (HO)\n\
|
---|
277 | %->\n\
|
---|
278 | md=setflowequation(md,'HO','all');\n\
|
---|
279 | % save the given model\n\
|
---|
280 | %->\n\
|
---|
281 | save ./Models/ISMIP.SetFlow md;\n\
|
---|
282 | end\n\
|
---|
283 | \n\
|
---|
284 | %Set Boundary Conditions #6\n\
|
---|
285 | if any(steps==6)\n\
|
---|
286 | \n\
|
---|
287 | % load the preceding step #help loadmodel\n\
|
---|
288 | % path is given by the organizer with the name of the given step\n\
|
---|
289 | %->\n\
|
---|
290 | md = loadmodel('./Models/ISMIP.SetFlow');\n\
|
---|
291 | % dirichlet boundary condition are known as SPCs\n\
|
---|
292 | % ice frozen to the base, no velocity #md.stressbalance\n\
|
---|
293 | % SPCs are initialized at NaN one value per vertex\n\
|
---|
294 | %->\n\
|
---|
295 | md.stressbalance.spcvx=NaN*ones(md.mesh.numberofvertices,1);\n\
|
---|
296 | %->\n\
|
---|
297 | md.stressbalance.spcvy=NaN*ones(md.mesh.numberofvertices,1);\n\
|
---|
298 | %->\n\
|
---|
299 | md.stressbalance.spcvz=NaN*ones(md.mesh.numberofvertices,1);\n\
|
---|
300 | % extract the nodenumbers at the base #md.mesh.vertexonbase\n\
|
---|
301 | %->\n\
|
---|
302 | basalnodes=find(md.mesh.vertexonbase);\n\
|
---|
303 | % set the sliding to zero on the bed\n\
|
---|
304 | %->\n\
|
---|
305 | md.stressbalance.spcvx(basalnodes)=0.0;\n\
|
---|
306 | %->\n\
|
---|
307 | md.stressbalance.spcvy(basalnodes)=0.0;\n\
|
---|
308 | % periodic boundaries have to be fixed on the sides\n\
|
---|
309 | % Find the indices of the sides of the domain, for x and then for y\n\
|
---|
310 | % for x\n\
|
---|
311 | % create maxX, list of indices where x is equal to max of x (use >> help find)\n\
|
---|
312 | %->\n\
|
---|
313 | maxX=find(md.mesh.x==max(md.mesh.x));\n\
|
---|
314 | % create minX, list of indices where x is equal to min of x\n\
|
---|
315 | %->\n\
|
---|
316 | minX=find(md.mesh.x==min(md.mesh.x));\n\
|
---|
317 | % for y\n\
|
---|
318 | % create maxY, list of indices where y is equal to max of y\n\
|
---|
319 | % but not where x is equal to max or min of x\n\
|
---|
320 | % (i.e, indices in maxX and minX should be excluded from maxY and minY)\n\
|
---|
321 | % but not where x is equal to max or min of x\n\
|
---|
322 | %->\n\
|
---|
323 | maxY=find(md.mesh.y==max(md.mesh.y) & md.mesh.x~=max(md.mesh.x) & md.mesh.x~=min(md.mesh.x));\n\
|
---|
324 | % create minY, list of indices where y is equal to max of y\n\
|
---|
325 | %->\n\
|
---|
326 | minY=find(md.mesh.y==min(md.mesh.y) & md.mesh.x~=max(md.mesh.x) & md.mesh.x~=min(md.mesh.x));\n\
|
---|
327 | % set the node that should be paired together, minX with maxX and minY with maxY\n\
|
---|
328 | % #md.stressbalance.vertex_pairing\n\
|
---|
329 | %->\n\
|
---|
330 | md.stressbalance.vertex_pairing=[minX,maxX;minY,maxY];\n\
|
---|
331 | if (ParamFile=='IsmipF.par')\n\
|
---|
332 | % if we are dealing with IsmipF the solution is in\n\
|
---|
333 | % masstransport\n\
|
---|
334 | md.masstransport.vertex_pairing=md.stressbalance.vertex_pairing;\n\
|
---|
335 | end\n\
|
---|
336 | % save the given model\n\
|
---|
337 | %->\n\
|
---|
338 | save ./Models/ISMIP.BoundaryCondition md;\n\
|
---|
339 | end\n\
|
---|
340 | \n\
|
---|
341 | %Solving #7\n\
|
---|
342 | if any(steps==7)\n\
|
---|
343 | % load the preceding step #help loadmodel\n\
|
---|
344 | % path is given by the organizer with the name of the given step\n\
|
---|
345 | %->\n\
|
---|
346 | md = loadmodel('./Models/ISMIP.BoundaryCondition');\n\
|
---|
347 | % Set cluster #md.cluster\n\
|
---|
348 | % generic parameters #help generic\n\
|
---|
349 | % set only the name and number of process\n\
|
---|
350 | %->\n\
|
---|
351 | md.cluster=generic('name',oshostname(),'np',2);\n\
|
---|
352 | % Set which control message you want to see #help verbose\n\
|
---|
353 | %->\n\
|
---|
354 | md.verbose=verbose('convergence',true);\n\
|
---|
355 | % Solve #help solve\n\
|
---|
356 | % we are solving a StressBalanc\n\
|
---|
357 | %->\n\
|
---|
358 | md=solve(md,'Stressbalance');\n\
|
---|
359 | % save the given model\n\
|
---|
360 | %->\n\
|
---|
361 | save ./Models/ISMIP.StressBalance md;\n\
|
---|
362 | % plot the surface velocities #plotdoc\n\
|
---|
363 | %->\n\
|
---|
364 | plotmodel(md,'data',md.results.StressbalanceSolution.Vel)\n\
|
---|
365 | end\n\
|
---|
366 | \n\
|
---|
367 | %Solving #8\n\
|
---|
368 | if any(steps==8)\n\
|
---|
369 | % load the preceding step #help loadmodel\n\
|
---|
370 | % path is given by the organizer with the name of the given step\n\
|
---|
371 | %->\n\
|
---|
372 | md = loadmodel('./Models/ISMIP.BoundaryCondition');\n\
|
---|
373 | % Set cluster #md.cluster\n\
|
---|
374 | % generic parameters #help generic\n\
|
---|
375 | % set only the name and number of process\n\
|
---|
376 | %->\n\
|
---|
377 | md.cluster=generic('name',oshostname(),'np',2);\n\
|
---|
378 | % Set which control message you want to see #help verbose\n\
|
---|
379 | %->\n\
|
---|
380 | md.verbose=verbose('convergence',true);\n\
|
---|
381 | % set the transient model to ignore the thermal model\n\
|
---|
382 | % #md.transient \n\
|
---|
383 | %->\n\
|
---|
384 | md.transient.isthermal=0;\n\
|
---|
385 | % define the timestepping scheme\n\
|
---|
386 | % everything here should be provided in years #md.timestepping\n\
|
---|
387 | % give the length of the time_step (4 years)\n\
|
---|
388 | %->\n\
|
---|
389 | md.timestepping.time_step=4;\n\
|
---|
390 | % give final_time (20*4 years time_steps)\n\
|
---|
391 | %->\n\
|
---|
392 | md.timestepping.final_time=4*20;\n\
|
---|
393 | % Solve #help solve\n\
|
---|
394 | % we are solving a TransientSolution\n\
|
---|
395 | %->\n\
|
---|
396 | md=solve(md,'Transient');\n\
|
---|
397 | % save the given model\n\
|
---|
398 | %->\n\
|
---|
399 | save ./Models/ISMIP.Transient md;\n\
|
---|
400 | % plot the surface velocities #plotdoc\n\
|
---|
401 | %->\n\
|
---|
402 | plotmodel(md,'data',md.results.TransientSolution(20).Vel)\n\
|
---|
403 | end\n\
|
---|
404 | "
|
---|
405 | #}}}
|
---|
406 | # PAR_A #{{{
|
---|
407 | PAR_A="\
|
---|
408 | %Parameterization for ISMIP A experiment\n\
|
---|
409 | \n\
|
---|
410 | %Set the Simulation generic name #md.miscellaneous\n\
|
---|
411 | %->\n\
|
---|
412 | \n\
|
---|
413 | %Geometry\n\
|
---|
414 | disp(' Constructing Geometry');\n\
|
---|
415 | \n\
|
---|
416 | %Define the geometry of the simulation #md.geometry\n\
|
---|
417 | %surface is [-x*tan(0.5*pi/180)] #md.mesh\n\
|
---|
418 | %->\n\
|
---|
419 | md.geometry.surface=-md.mesh.x*tan(0.5*pi/180.);\n\
|
---|
420 | %base is [surface-1000+500*sin(x*2*pi/L).*sin(y*2*pi/L)]\n\
|
---|
421 | %L is the size of the side of the square #max(md.mesh.x)-min(md.mesh.x)\n\
|
---|
422 | %->\n\
|
---|
423 | L=max(md.mesh.x)-min(md.mesh.x);\n\
|
---|
424 | md.geometry.base=md.geometry.surface-1000.0+500.0*sin(md.mesh.x*2.0*pi/L).*sin(md.mesh.y*2.0*pi/L);\n\
|
---|
425 | %thickness is the difference between surface and base #md.geometry\n\
|
---|
426 | %->\n\
|
---|
427 | md.geometry.thickness=md.geometry.surface-md.geometry.base;\n\
|
---|
428 | %plot the geometry to check it out\n\
|
---|
429 | %->\n\
|
---|
430 | plotmodel(md,'data',md.geometry.thickness);\n\
|
---|
431 | \n\
|
---|
432 | disp(' Defining friction parameters');\n\
|
---|
433 | \n\
|
---|
434 | %These parameters will not be used but need to be fixed #md.friction\n\
|
---|
435 | %one friciton coefficient per node (md.mesh.numberofvertices,1)\n\
|
---|
436 | %->\n\
|
---|
437 | md.friction.coefficient=200.0*ones(md.mesh.numberofvertices,1);\n\
|
---|
438 | %one friciton exponent (p,q) per element\n\
|
---|
439 | %->\n\
|
---|
440 | md.friction.p=ones(md.mesh.numberofelements,1);\n\
|
---|
441 | %->\n\
|
---|
442 | md.friction.q=ones(md.mesh.numberofelements,1);\n\
|
---|
443 | \n\
|
---|
444 | disp(' Construct ice rheological properties');\n\
|
---|
445 | \n\
|
---|
446 | %The rheology parameters sit in the material section #md.materials\n\
|
---|
447 | %B has one value per vertex\n\
|
---|
448 | %->\n\
|
---|
449 | md.materials.rheology_B=6.8067e7*ones(md.mesh.numberofvertices,1);\n\
|
---|
450 | %n has one value per element\n\
|
---|
451 | %->\n\
|
---|
452 | md.materials.rheology_n=3*ones(md.mesh.numberofelements,1);\n\
|
---|
453 | \n\
|
---|
454 | disp(' Set boundary conditions');\n\
|
---|
455 | \n\
|
---|
456 | %Set the default boundary conditions for an ice-sheet \n\
|
---|
457 | % #help SetIceSheetBC\n\
|
---|
458 | %->\n\
|
---|
459 | md=SetIceSheetBC(md);\n\
|
---|
460 | "
|
---|
461 | #}}}
|
---|
462 | # PAR_F #{{{
|
---|
463 | PAR_F="\
|
---|
464 | %Parameterization for ISMIP F experiment\n\
|
---|
465 | \n\
|
---|
466 | %Set the Simulation generic name #md.miscellaneous\n\
|
---|
467 | %->\n\
|
---|
468 | \n\
|
---|
469 | %Geometry\n\
|
---|
470 | disp(' Constructing Geometry');\n\
|
---|
471 | \n\
|
---|
472 | %Define the geometry of the simulation #md.geometry\n\
|
---|
473 | %surface is [-x*tan(3.0*pi/180)] #md.mesh\n\
|
---|
474 | %->\n\
|
---|
475 | md.geometry.surface=-md.mesh.x*tan(3.0*pi/180.0);\n\
|
---|
476 | %base is [surface-1000+100*exp(-((x-L/2).^2+(y-L/2).^2)/(10000.^2))]\n\
|
---|
477 | %L is the size of the side of the square #max(md.mesh.x)-min(md.mesh.x)\n\
|
---|
478 | %->\n\
|
---|
479 | L=max(md.mesh.x)-min(md.mesh.x);\n\
|
---|
480 | %->\n\
|
---|
481 | md.geometry.base=md.geometry.surface-1000.0+100.0*exp(-((md.mesh.x-L/2.0).^2.0+(md.mesh.y-L/2.0).^2.0)/(10000.^2.0));\n\
|
---|
482 | %thickness is the difference between surface and base #md.geometry\n\
|
---|
483 | %->\n\
|
---|
484 | md.geometry.thickness=md.geometry.surface-md.geometry.base;\n\
|
---|
485 | %plot the geometry to check it out\n\
|
---|
486 | %->\n\
|
---|
487 | plotmodel(md,'data',md.geometry.thickness);\n\
|
---|
488 | \n\
|
---|
489 | disp(' Defining friction parameters');\n\
|
---|
490 | \n\
|
---|
491 | %These parameters will not be used but need to be fixed #md.friction\n\
|
---|
492 | %one friciton coefficient per node (md.mesh.numberofvertices,1)\n\
|
---|
493 | %conversion from year to seconds with #md.constants.yts\n\
|
---|
494 | %->\n\
|
---|
495 | md.friction.coefficient=sqrt(md.constants.yts/(1000*2.140373*10^-7))*ones(md.mesh.numberofvertices,1);\n\
|
---|
496 | %one friciton exponent (p,q) per element\n\
|
---|
497 | %->\n\
|
---|
498 | md.friction.p=ones(md.mesh.numberofelements,1);\n\
|
---|
499 | %->\n\
|
---|
500 | md.friction.q=zeros(md.mesh.numberofelements,1);\n\
|
---|
501 | \n\
|
---|
502 | disp(' Construct ice rheological properties');\n\
|
---|
503 | \n\
|
---|
504 | %The rheology parameters sit in the material section #md.materials\n\
|
---|
505 | %B has one value per vertex\n\
|
---|
506 | %->\n\
|
---|
507 | md.materials.rheology_B=(1/(2.140373*10^-7/md.constants.yts))*ones(md.mesh.numberofvertices,1);\n\
|
---|
508 | %n has one value per element\n\
|
---|
509 | %->\n\
|
---|
510 | md.materials.rheology_n=1*ones(md.mesh.numberofelements,1);\n\
|
---|
511 | \n\
|
---|
512 | disp(' Set boundary conditions');\n\
|
---|
513 | \n\
|
---|
514 | %Set the default boundary conditions for an ice-sheet \n\
|
---|
515 | % #help SetIceSheetBC\n\
|
---|
516 | %->\n\
|
---|
517 | md=SetIceSheetBC(md);\n\
|
---|
518 | \n\
|
---|
519 | disp(' Initializing velocity and pressure');\n\
|
---|
520 | \n\
|
---|
521 | %initialize the velocity and pressurefields of #md.initialization\n\
|
---|
522 | %->\n\
|
---|
523 | md.initialization.vx=zeros(md.mesh.numberofvertices,1);\n\
|
---|
524 | %->\n\
|
---|
525 | md.initialization.vy=zeros(md.mesh.numberofvertices,1);\n\
|
---|
526 | %->\n\
|
---|
527 | md.initialization.vz=zeros(md.mesh.numberofvertices,1);\n\
|
---|
528 | %->\n\
|
---|
529 | md.initialization.pressure=zeros(md.mesh.numberofvertices,1);\n\
|
---|
530 | "
|
---|
531 | #}}}
|
---|
532 | perl -0755 -p -i'.bak' -e "s|^.*$|${RUNME}|s" $RUNME_FILE
|
---|
533 | perl -0755 -p -i'.bak' -e "s|^.*$|${PAR_A}|s" IsmipA.par
|
---|
534 | perl -0755 -p -i'.bak' -e "s|^.*$|${PAR_F}|s" IsmipF.par
|
---|
535 | RUN_EXAMPLE=1
|
---|
536 | elif [ "${dir}" == "./Jakobshavn" ]; then
|
---|
537 | sed -i.bak -e 's|steps=\[1\];|steps=\[1:4\];\n\ntry\n|' $RUNME_FILE
|
---|
538 | RUN_EXAMPLE=1
|
---|
539 | elif [ "${dir}" == "./LcurveAnalysis" ]; then
|
---|
540 | sed -i.bak -e 's|steps=\[1\];|steps=\[1:4\];\n\ntry\n|' $RUNME_FILE
|
---|
541 | RUN_EXAMPLE=1
|
---|
542 | elif [ "${dir}" == "./Mesh" ]; then
|
---|
543 | # NOTE: Cannot test exptool region selection without GUI
|
---|
544 | #
|
---|
545 |
|
---|
546 | # RUNME #{{{
|
---|
547 | RUNME="\
|
---|
548 | try\n\
|
---|
549 | steps=[1:7];\n\
|
---|
550 | \n\
|
---|
551 | if any(steps==1) % Model\n\
|
---|
552 | md=model;\n\
|
---|
553 | end\n\
|
---|
554 | \n\
|
---|
555 | if any(steps==2) % squaremesh\n\
|
---|
556 | md=squaremesh(md,100,200,15,25);\n\
|
---|
557 | plotmodel(md,'data','mesh');\n\
|
---|
558 | end\n\
|
---|
559 | \n\
|
---|
560 | if any(steps==3) % roundmesh\n\
|
---|
561 | md=roundmesh(model,100,10);\n\
|
---|
562 | plotmodel(md,'data','mesh');\n\
|
---|
563 | end\n\
|
---|
564 | \n\
|
---|
565 | if any(steps==4) % triangle\n\
|
---|
566 | md=triangle(model,'Square.exp',.2);\n\
|
---|
567 | plotmodel(md,'data','mesh');\n\
|
---|
568 | end\n\
|
---|
569 | \n\
|
---|
570 | if any(steps==5) % bamg\n\
|
---|
571 | md=bamg(model,'domain','Square.exp','hmax',.05);\n\
|
---|
572 | plotmodel(md,'data','mesh');\n\
|
---|
573 | end\n\
|
---|
574 | \n\
|
---|
575 | if any(steps==6) % Non-Uniform mesh\n\
|
---|
576 | hvertices=[0.2;0.2;0.005;0.2];\n\
|
---|
577 | md=bamg(md,'domain','Square.exp','hvertices',hvertices);\n\
|
---|
578 | plotmodel(md,'data','mesh');\n\
|
---|
579 | end\n\
|
---|
580 | \n\
|
---|
581 | if any(steps==7) % Mesh adaptation\n\
|
---|
582 | md=bamg(model,'domain','Square.exp','hmax',.05);\n\
|
---|
583 | vel=shock(md.mesh.x,md.mesh.y);\n\
|
---|
584 | plotmodel(md,'data',vel,'edgecolor','w');\n\
|
---|
585 | \n\
|
---|
586 | md=bamg(model,'domain','Square.exp','hmax',.005);\n\
|
---|
587 | vel=shock(md.mesh.x,md.mesh.y);\n\
|
---|
588 | md=bamg(md,'field',vel,'err',0.05,'hmin',0.005,'hmax',0.3);\n\
|
---|
589 | vel=shock(md.mesh.x,md.mesh.y);\n\
|
---|
590 | plotmodel(md,'data',vel,'edgecolor','w');\n\
|
---|
591 | \n\
|
---|
592 | md=bamg(model,'domain','Square.exp','hmax',.005);\n\
|
---|
593 | vel=shock(md.mesh.x,md.mesh.y);\n\
|
---|
594 | md=bamg(md,'field',vel,'err',0.03,'hmin',0.005,'hmax',0.3,'gradation',3);\n\
|
---|
595 | vel=shock(md.mesh.x,md.mesh.y);\n\
|
---|
596 | plotmodel(md,'data',vel,'edgecolor','w');\n\
|
---|
597 | \n\
|
---|
598 | md=bamg(model,'domain','Square.exp','hmax',.005);\n\
|
---|
599 | vel=shock(md.mesh.x,md.mesh.y);\n\
|
---|
600 | md=bamg(md,'field',vel,'err',0.03,'hmin',0.005,'hmax',0.3,'gradation',1.3,'anisomax',1);\n\
|
---|
601 | vel=shock(md.mesh.x,md.mesh.y);\n\
|
---|
602 | plotmodel(md,'data',vel,'edgecolor','w');\n\
|
---|
603 | end\n\
|
---|
604 | \n\
|
---|
605 | if any(steps==8) % Mesh refinement in a specific region\n\
|
---|
606 | plotmodel(md,'data',vel,'edgecolor','w');\n\
|
---|
607 | exptool('refinement.exp');\n\
|
---|
608 | h=NaN*ones(md.mesh.numberofvertices,1);\n\
|
---|
609 | in=ContourToNodes(md.mesh.x,md.mesh.y,'refinement.exp',1);\n\
|
---|
610 | h(find(in))=0.02;\n\
|
---|
611 | plotmodel(md,'data',in,'edgecolor','w');\n\
|
---|
612 | \n\
|
---|
613 | vel=shock(md.mesh.x,md.mesh.y);\n\
|
---|
614 | md=bamg(md,'field',vel,'err',0.03,'hmin',0.005,'hmax',0.3,'hVertices',h);\n\
|
---|
615 | vel=shock(md.mesh.x,md.mesh.y);\n\
|
---|
616 | plotmodel(md,'data',vel,'edgecolor','w');\n\
|
---|
617 | end\n\
|
---|
618 | "
|
---|
619 | #}}}
|
---|
620 | touch $RUNME_FILE
|
---|
621 | perl -0755 -p -i'.bak' -e "s|^.*$|${RUNME}|s" $RUNME_FILE
|
---|
622 | RUN_EXAMPLE=1
|
---|
623 | elif [ "${dir}" == "./Pig" ]; then
|
---|
624 | # STEP_SIX #{{{
|
---|
625 | STEP_SIX="\
|
---|
626 | if any(steps==6)\n\
|
---|
627 | % Load Model\n\
|
---|
628 | md = loadmodel('./Models/PIG_Control_drag');\n\
|
---|
629 | % Disable inversion\n\
|
---|
630 | md.inversion.iscontrol=0;\n\
|
---|
631 | % Extrude Mesh\n\
|
---|
632 | disp(' Extruding mesh');\n\
|
---|
633 | number_of_layers=3;\n\
|
---|
634 | md=extrude(md,number_of_layers,1);\n\
|
---|
635 | % Set Flowequation\n\
|
---|
636 | disp(' Using HO Ice Flow Model');\n\
|
---|
637 | md=setflowequation(md,'HO','all');\n\
|
---|
638 | % Solve\n\
|
---|
639 | md=solve(md,'Stressbalance');\n\
|
---|
640 | % Save Model\n\
|
---|
641 | save ./Models/PIG_ModelHO md;\n\
|
---|
642 | end\n\
|
---|
643 | "
|
---|
644 | #}}}
|
---|
645 | mv ./DomainOutline.bkp ./DomainOutline.exp > /dev/null 2>&1
|
---|
646 | sed -i.bak -e 's|steps=\[1\];|steps=\[1:7\];\ntry\n|' $RUNME_FILE
|
---|
647 | perl -0755 -p -i -e "s|if any\(steps==6\).*% step 6 end|${STEP_SIX}|s" $RUNME_FILE
|
---|
648 | RUN_EXAMPLE=1
|
---|
649 | elif [ "${dir}" == "./Pig2" ]; then
|
---|
650 | STEP_NINE="\n disp('Needs work!'); exit"
|
---|
651 | sed -i.bak -e 's|steps=\[1\];|steps=\[1:9\];\n\ntry\n|' $RUNME_FILE
|
---|
652 | perl -0755 -p -i -e "s|if any\(steps==9\).*% step 9 end|${STEP_NINE}|s" $RUNME_FILE
|
---|
653 | RUN_EXAMPLE=0
|
---|
654 | elif [ "${dir}" == "./PigSensitivity" ]; then
|
---|
655 | # STEP_FOUR # {{{
|
---|
656 | STEP_FOUR="\
|
---|
657 | if any(steps==4)\n\
|
---|
658 | %Load model\n\
|
---|
659 | md = loadmodel('./Models/PIG_Transient');\n\
|
---|
660 | \n\
|
---|
661 | %Change external forcing basal melting rate and surface mass balance)\n\
|
---|
662 | md.basalforcings.groundedice_melting_rate=zeros(md.mesh.numberofvertices,1);\n\
|
---|
663 | md.basalforcings.floatingice_melting_rate=25*ones(md.mesh.numberofvertices,1);\n\
|
---|
664 | md.smb.mass_balance=2*md.smb.mass_balance;\n\
|
---|
665 | \n\
|
---|
666 | %Define time steps and time span of the simulation\n\
|
---|
667 | md.timestepping.time_step=0.1;\n\
|
---|
668 | md.timestepping.final_time=10;\n\
|
---|
669 | \n\
|
---|
670 | %Request additional outputs\n\
|
---|
671 | md.transient.requested_outputs={'default','IceVolume','IceVolumeAboveFloatation'};\n\
|
---|
672 | \n\
|
---|
673 | %Solve\n\
|
---|
674 | md=solve(md,'Transient');\n\
|
---|
675 | \n\
|
---|
676 | %Plot\n\
|
---|
677 | plotmodel(md, 'data', md.results.TransientSolution(1).Vel,...\n\
|
---|
678 | 'title#1', 'Velocity t=0 years (m/yr)',...\n\
|
---|
679 | 'data', md.results.TransientSolution(end).Vel,...\n\
|
---|
680 | 'title#2', 'Velocity t=10 years (m/yr)',...\n\
|
---|
681 | 'data', md.results.TransientSolution(1).MaskOceanLevelset,...\n\
|
---|
682 | 'title#3', 'Floating ice t=0 years',...\n\
|
---|
683 | 'data', md.results.TransientSolution(end).MaskOceanLevelset,...\n\
|
---|
684 | 'title#4', 'Floating ice t=10 years',...\n\
|
---|
685 | 'caxis#1',([0 4500]),'caxis#2',([0 4500]),...\n\
|
---|
686 | 'caxis#3',([-1,1]),'caxis#4',([-1,1]));\n\
|
---|
687 | \n\
|
---|
688 | %Save model\n\
|
---|
689 | save ./Models/PIG_SMB md;\n\
|
---|
690 | end\n\
|
---|
691 | "
|
---|
692 | #}}}
|
---|
693 | sed -i.bak -e 's|steps=\[1\];|steps=\[1:4\];\n\ntry\n|' $RUNME_FILE
|
---|
694 | perl -0755 -p -i -e "s|if any\(steps==4\).*% step 4 end|${STEP_FOUR}|s" $RUNME_FILE
|
---|
695 | RUN_EXAMPLE=1
|
---|
696 | elif [ "${dir}" == "./shakti" ]; then
|
---|
697 | sed -i.bak -e 's|steps=\[1:3\];|steps=\[1:3\];\n\ntry\n|' $RUNME_FILE
|
---|
698 | RUN_EXAMPLE=1
|
---|
699 | elif [ "${dir}" == "./SlrFarrell" ]; then
|
---|
700 | # TODO: Convert from md.slr
|
---|
701 | sed -i.bak -e 's|steps=\[1\];|steps=\[1:5\];\n\ntry\n|' $RUNME_FILE
|
---|
702 | RUN_EXAMPLE=0
|
---|
703 | elif [ "${dir}" == "./SlrGRACE" ]; then
|
---|
704 | # TODO: Convert from md.slr
|
---|
705 | sed -i.bak -e 's|steps=\[1\];|steps=\[1:7\];\n\ntry\n|' $RUNME_FILE
|
---|
706 | RUN_EXAMPLE=0
|
---|
707 | elif [ "${dir}" == "./SlrGRACE_NIMS" ]; then
|
---|
708 | # TODO: Convert from md.slr
|
---|
709 | sed -i.bak -e 's|steps=\[1\];|steps=\[1:8\];\n\ntry\n|' $RUNME_FILE
|
---|
710 | RUN_EXAMPLE=0
|
---|
711 | elif [ "${dir}" == "./SquareIceShelf" ]; then
|
---|
712 | sed -i.bak -e '1 s|^.*$|try\n\n&|' $RUNME_FILE
|
---|
713 | RUN_EXAMPLE=1
|
---|
714 | elif [ "${dir}" == "./UncertaintyQuantification" ]; then
|
---|
715 | sed -i.bak -e 's|steps=\[1\];|steps=\[1:7\];\n\ntry\n|' $RUNME_FILE
|
---|
716 | RUN_EXAMPLE=1
|
---|
717 | else
|
---|
718 | echo "Not implemented yet!"
|
---|
719 | exit 1
|
---|
720 | fi
|
---|
721 |
|
---|
722 | if [ $RUN_EXAMPLE -eq 1 ]; then
|
---|
723 | echo "Testing example: $(basename $dir)"
|
---|
724 | LOG_RUNME_FILE="matlab_log_$(basename $dir)_examples.log"
|
---|
725 | echo -e ${STATUS_HANDLING} >> ${RUNME_FILE}
|
---|
726 | $MATLAB_PATH/bin/matlab -nodisplay -nosplash -r "addpath $ISSM_DIR/src/m/dev; devpath; addpath $ISSM_DIR/nightlylog/; runme" -logfile $ISSM_DIR/nightlylog/$LOG_RUNME_FILE
|
---|
727 | echo "starting: $(basename $dir)" >> $ISSM_DIR/nightlylog/matlab_log_examples.log
|
---|
728 | cat $ISSM_DIR/nightlylog/$LOG_RUNME_FILE >> $ISSM_DIR/nightlylog/matlab_log_examples.log
|
---|
729 | echo "finished: $(basename $dir)" >> $ISSM_DIR/nightlylog/matlab_log_examples.log
|
---|
730 | mv -f ${RUNME_FILE}.bak ${RUNME_FILE}
|
---|
731 | fi
|
---|
732 |
|
---|
733 | # Extra clean up
|
---|
734 | if [ "${dir}" == "./ISMIP" ]; then
|
---|
735 | mv -f IsmipA.par.bak IsmipA.par
|
---|
736 | mv -f IsmipF.par.bak IsmipF.par
|
---|
737 | fi
|
---|
738 |
|
---|
739 | if [ "${dir}" == "./Mesh" ]; then
|
---|
740 | rm -f $RUNME_FILE
|
---|
741 | fi
|
---|
742 |
|
---|
743 | if [ "${dir}" == "./Pig" ]; then
|
---|
744 | mv -f DomainOutline.exp DomainOutline.bkp
|
---|
745 | fi
|
---|
746 |
|
---|
747 | cd ..
|
---|
748 | fi
|
---|
749 | done
|
---|