source: issm/trunk-jpl/jenkins/examples_tests.sh@ 26032

Last change on this file since 26032 was 26032, checked in by jdquinn, 4 years ago

CHG: Updated comments

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