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

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

CHG: Cleanup

  • Property svn:executable set to *
File size: 25.8 KB
RevLine 
[25915]1#!/bin/bash
2################################################################################
[25924]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.
[25915]7#
[25924]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#
[25915]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
[25925]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.
[25924]45
[25915]46 cd ${dir}
47
48 if [ "${dir}" == "./AMR" ]; then
[25983]49 sed -i.bak -e '1 s|^.*$|try\n\n&|' $RUNME_FILE
[25915]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
[25983]55 sed -i.bak -e 's|steps=\[1\];|steps=\[1:5\];\n\ntry\n|' $RUNME_FILE
[25915]56 RUN_EXAMPLE=1
57 elif [ "${dir}" == "./EsaWahr" ]; then
[25983]58 sed -i.bak -e 's|steps=\[1\];|steps=\[1:7\];\n\ntry\n|' $RUNME_FILE
[25915]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="\
[25986]66 if any(steps==7)\n\
[25915]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\
[25986]98 end\n\
[25915]99 "
100 #}}}
101 # STEP_EIGHT #{{{
102 STEP_EIGHT="\
[25986]103 if any(steps==8)\n\
[25915]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\
[25986]150 end\n\
[25915]151 "
152 #}}}
[25983]153 sed -i.bak -e 's|steps=\[1\];|steps=\[1:8\];\n\ntry\n|' $RUNME_FILE
[25915]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
[25983]158 sed -i.bak -e 's|steps=\[1\];|steps=\[1:5\];\n\ntry\n|' $RUNME_FILE
[25915]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
[25983]162 sed -i.bak -e '1 s|^.*$|try\n\n&|' $RUNME_FILE
[25915]163 RUN_EXAMPLE=1
164 elif [ "${dir}" == "./Inversion" ]; then
[25983]165 sed -i.bak -e 's|steps=\[1\];|steps=\[1:4\];\n\ntry\n|' $RUNME_FILE
[25915]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 #
[25986]172
[25915]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\
[25986]190 if any(steps==1)\n\
[25915]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\
[25986]208 end\n\
[25915]209 \n\
210 %Masks #2\n\
[25986]211 if any(steps==2)\n\
[25915]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\
[25986]226 end\n\
[25915]227 \n\
228 %Parameterization #3\n\
[25986]229 if any(steps==3)\n\
[25915]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\
[25986]242 end\n\
[25915]243 \n\
244 %Extrusion #4\n\
[25986]245 if any(steps==4)\n\
[25915]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,9,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\
[25986]261 end\n\
[25915]262 \n\
263 %Set the flow computing method #5\n\
[25986]264 if any(steps==5)\n\
[25915]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\
[25986]277 end\n\
[25915]278 \n\
279 %Set Boundary Conditions #6\n\
[25986]280 if any(steps==6)\n\
[25915]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 % create tabs with the side of the domain\n\
305 % for x\n\
306 % create maxX #help find\n\
307 %->\n\
308 maxX=find(md.mesh.x==max(md.mesh.x));\n\
309 % create minX\n\
310 %->\n\
311 minX=find(md.mesh.x==min(md.mesh.x));\n\
312 % for y, max X and minX should be excluded\n\
313 % create maxY\n\
314 %->\n\
315 maxY=find(md.mesh.y==max(md.mesh.y) & md.mesh.x~=max(md.mesh.x) & md.mesh.x~=min(md.mesh.x));\n\
316 % create minY\n\
317 %->\n\
318 minY=find(md.mesh.y==min(md.mesh.y) & md.mesh.x~=max(md.mesh.x) & md.mesh.x~=min(md.mesh.x));\n\
319 % set the node that should be paired together\n\
320 % #md.stressbalance.vertex_pairing\n\
321 %->\n\
322 md.stressbalance.vertex_pairing=[minX,maxX;minY,maxY];\n\
323 if (ParamFile=='IsmipF.par')\n\
324 % if we are dealing with IsmipF the solution is in\n\
325 % masstransport\n\
326 md.masstransport.vertex_pairing=md.stressbalance.vertex_pairing;\n\
327 end\n\
328 % save the given model\n\
329 %->\n\
330 save ./Models/ISMIP.BoundaryCondition md;\n\
[25986]331 end\n\
[25915]332 \n\
333 %Solving #7\n\
[25986]334 if any(steps==7)\n\
[25915]335 % load the preceding step #help loadmodel\n\
336 % path is given by the organizer with the name of the given step\n\
337 %->\n\
338 md = loadmodel('./Models/ISMIP.BoundaryCondition');\n\
339 % Set cluster #md.cluster\n\
340 % generic parameters #help generic\n\
341 % set only the name and number of process\n\
342 %->\n\
343 md.cluster=generic('name',oshostname(),'np',2);\n\
344 % Set which control message you want to see #help verbose\n\
345 %->\n\
346 md.verbose=verbose('convergence',true);\n\
347 % Solve #help solve\n\
348 % we are solving a StressBalanc\n\
349 %->\n\
350 md=solve(md,'Stressbalance');\n\
351 % save the given model\n\
352 %->\n\
353 save ./Models/ISMIP.StressBalance md;\n\
354 % plot the surface velocities #plotdoc\n\
355 %->\n\
356 plotmodel(md,'data',md.results.StressbalanceSolution.Vel)\n\
[25986]357 end\n\
[25915]358 \n\
359 %Solving #8\n\
[25986]360 if any(steps==8)\n\
[25915]361 % load the preceding step #help loadmodel\n\
362 % path is given by the organizer with the name of the given step\n\
363 %->\n\
364 md = loadmodel('./Models/ISMIP.BoundaryCondition');\n\
365 % Set cluster #md.cluster\n\
366 % generic parameters #help generic\n\
367 % set only the name and number of process\n\
368 %->\n\
369 md.cluster=generic('name',oshostname(),'np',2);\n\
370 % Set which control message you want to see #help verbose\n\
371 %->\n\
372 md.verbose=verbose('convergence',true);\n\
373 % set the transient model to ignore the thermal model\n\
374 % #md.transient \n\
375 %->\n\
376 md.transient.isthermal=0;\n\
377 % define the timestepping scheme\n\
378 % everything here should be provided in years #md.timestepping\n\
379 % give the length of the time_step (4 years)\n\
380 %->\n\
381 md.timestepping.time_step=4;\n\
382 % give final_time (20*4 years time_steps)\n\
383 %->\n\
384 md.timestepping.final_time=4*20;\n\
385 % Solve #help solve\n\
386 % we are solving a TransientSolution\n\
387 %->\n\
388 md=solve(md,'Transient');\n\
389 % save the given model\n\
390 %->\n\
391 save ./Models/ISMIP.Transient md;\n\
392 % plot the surface velocities #plotdoc\n\
393 %->\n\
394 plotmodel(md,'data',md.results.TransientSolution(20).Vel)\n\
[25986]395 end\n\
[25915]396 "
397 #}}}
398 # PAR_A #{{{
399 PAR_A="\
400 %Parameterization for ISMIP A experiment\n\
401 \n\
402 %Set the Simulation generic name #md.miscellaneous\n\
403 %->\n\
404 \n\
405 %Geometry\n\
406 disp(' Constructing Geometry');\n\
407 \n\
408 %Define the geometry of the simulation #md.geometry\n\
409 %surface is [-x*tan(0.5*pi/180)] #md.mesh\n\
410 %->\n\
411 md.geometry.surface=-md.mesh.x*tan(0.5*pi/180.);\n\
412 %base is [surface-1000+500*sin(x*2*pi/L).*sin(y*2*pi/L)]\n\
413 %L is the size of the side of the square #max(md.mesh.x)-min(md.mesh.x)\n\
414 %->\n\
415 L=max(md.mesh.x)-min(md.mesh.x);\n\
416 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\
417 %thickness is the difference between surface and base #md.geometry\n\
418 %->\n\
419 md.geometry.thickness=md.geometry.surface-md.geometry.base;\n\
420 %plot the geometry to check it out\n\
421 %->\n\
422 plotmodel(md,'data',md.geometry.thickness);\n\
423 \n\
424 disp(' Defining friction parameters');\n\
425 \n\
426 %These parameters will not be used but need to be fixed #md.friction\n\
427 %one friciton coefficient per node (md.mesh.numberofvertices,1)\n\
428 %->\n\
429 md.friction.coefficient=200.0*ones(md.mesh.numberofvertices,1);\n\
430 %one friciton exponent (p,q) per element\n\
431 %->\n\
432 md.friction.p=ones(md.mesh.numberofelements,1);\n\
433 %->\n\
434 md.friction.q=ones(md.mesh.numberofelements,1);\n\
435 \n\
436 disp(' Construct ice rheological properties');\n\
437 \n\
438 %The rheology parameters sit in the material section #md.materials\n\
439 %B has one value per vertex\n\
440 %->\n\
441 md.materials.rheology_B=6.8067e7*ones(md.mesh.numberofvertices,1);\n\
442 %n has one value per element\n\
443 %->\n\
444 md.materials.rheology_n=3*ones(md.mesh.numberofelements,1);\n\
445 \n\
446 disp(' Set boundary conditions');\n\
447 \n\
448 %Set the default boundary conditions for an ice-sheet \n\
449 % #help SetIceSheetBC\n\
450 %->\n\
451 md=SetIceSheetBC(md);\n\
452 "
453 #}}}
454 # PAR_F #{{{
455 PAR_F="\
456 %Parameterization for ISMIP F experiment\n\
457 \n\
458 %Set the Simulation generic name #md.miscellaneous\n\
459 %->\n\
460 \n\
461 %Geometry\n\
462 disp(' Constructing Geometry');\n\
463 \n\
464 %Define the geometry of the simulation #md.geometry\n\
465 %surface is [-x*tan(3.0*pi/180)] #md.mesh\n\
466 %->\n\
467 md.geometry.surface=md.mesh.x*tan(3.0*pi/180.0);\n\
468 %base is [surface-1000+100*exp(-((x-L/2).^2+(y-L/2).^2)/(10000.^2))]\n\
469 %L is the size of the side of the square #max(md.mesh.x)-min(md.mesh.x)\n\
470 %->\n\
471 L=max(md.mesh.x)-min(md.mesh.x);\n\
472 %->\n\
473 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\
474 %thickness is the difference between surface and base #md.geometry\n\
475 %->\n\
476 md.geometry.thickness=md.geometry.surface-md.geometry.base;\n\
477 %plot the geometry to check it out\n\
478 %->\n\
479 plotmodel(md,'data',md.geometry.thickness);\n\
480 \n\
481 disp(' Defining friction parameters');\n\
482 \n\
483 %These parameters will not be used but need to be fixed #md.friction\n\
484 %one friciton coefficient per node (md.mesh.numberofvertices,1)\n\
485 %conversion form year to seconds with #md.constants.yts\n\
486 %->\n\
487 md.friction.coefficient=sqrt(md.constants.yts/(1000*2.140373*10^-7))*ones(md.mesh.numberofvertices,1);\n\
488 %one friciton exponent (p,q) per element\n\
489 %->\n\
490 md.friction.p=ones(md.mesh.numberofelements,1);\n\
491 %->\n\
492 md.friction.q=zeros(md.mesh.numberofelements,1);\n\
493 \n\
494 disp(' Construct ice rheological properties');\n\
495 \n\
496 %The rheology parameters sit in the material section #md.materials\n\
497 %B has one value per vertex\n\
498 %->\n\
499 md.materials.rheology_B=(1/(2.140373*10^-7/md.constants.yts))*ones(md.mesh.numberofvertices,1);\n\
500 %n has one value per element\n\
501 %->\n\
502 md.materials.rheology_n=1*ones(md.mesh.numberofelements,1);\n\
503 \n\
504 disp(' Set boundary conditions');\n\
505 \n\
506 %Set the default boundary conditions for an ice-sheet \n\
507 % #help SetIceSheetBC\n\
508 %->\n\
509 md=SetIceSheetBC(md);\n\
510 \n\
511 disp(' Initializing velocity and pressure');\n\
512 \n\
513 %initialize the velocity and pressurefields of #md.initialization\n\
514 %->\n\
515 md.initialization.vx=zeros(md.mesh.numberofvertices,1);\n\
516 %->\n\
517 md.initialization.vy=zeros(md.mesh.numberofvertices,1);\n\
518 %->\n\
519 md.initialization.vz=zeros(md.mesh.numberofvertices,1);\n\
520 %->\n\
521 md.initialization.pressure=zeros(md.mesh.numberofvertices,1);\n\
522 "
523 #}}}
524 perl -0755 -p -i'.bak' -e "s|^.*$|${RUNME}|s" $RUNME_FILE
525 perl -0755 -p -i'.bak' -e "s|^.*$|${PAR_A}|s" IsmipA.par
526 perl -0755 -p -i'.bak' -e "s|^.*$|${PAR_F}|s" IsmipF.par
527 RUN_EXAMPLE=1
528 elif [ "${dir}" == "./Jakobshavn" ]; then
[25983]529 sed -i.bak -e 's|steps=\[1\];|steps=\[1:4\];\n\ntry\n|' $RUNME_FILE
[25915]530 RUN_EXAMPLE=1
531 elif [ "${dir}" == "./LcurveAnalysis" ]; then
[25983]532 sed -i.bak -e 's|steps=\[1\];|steps=\[1:4\];\n\ntry\n|' $RUNME_FILE
[25915]533 RUN_EXAMPLE=1
534 elif [ "${dir}" == "./Mesh" ]; then
535 # NOTE: Cannot test exptool region selection without GUI
[25986]536 #
537
538 # RUNME #{{{
539 RUNME="\
540 try\n\
541 steps=[1:7];\n\
542 \n\
543 if any(steps==1) % Model\n\
544 md=model;\n\
545 end\n\
546 \n\
547 if any(steps==2) % squaremesh\n\
548 md=squaremesh(md,100,200,15,25);\n\
549 plotmodel(md,'data','mesh');\n\
550 end\n\
551 \n\
552 if any(steps==3) % roundmesh\n\
553 md=roundmesh(model,100,10);\n\
554 plotmodel(md,'data','mesh');\n\
555 end\n\
556 \n\
557 if any(steps==4) % triangle\n\
558 md=triangle(model,'Square.exp',.2);\n\
559 plotmodel(md,'data','mesh');\n\
560 end\n\
561 \n\
562 if any(steps==5) % bamg\n\
563 md=bamg(model,'domain','Square.exp','hmax',.05);\n\
564 plotmodel(md,'data','mesh');\n\
565 end\n\
566 \n\
567 if any(steps==6) % Non-Uniform mesh\n\
568 hvertices=[0.2;0.2;0.005;0.2];\n\
569 md=bamg(md,'domain','Square.exp','hvertices',hvertices);\n\
570 plotmodel(md,'data','mesh');\n\
571 end\n\
572 \n\
573 if any(steps==7) % Mesh adaptation\n\
574 md=bamg(model,'domain','Square.exp','hmax',.05);\n\
575 vel=shock(md.mesh.x,md.mesh.y);\n\
576 plotmodel(md,'data',vel,'edgecolor','w');\n\
577 \n\
578 md=bamg(model,'domain','Square.exp','hmax',.005);\n\
579 vel=shock(md.mesh.x,md.mesh.y);\n\
580 md=bamg(md,'field',vel,'err',0.05,'hmin',0.005,'hmax',0.3);\n\
581 vel=shock(md.mesh.x,md.mesh.y);\n\
582 plotmodel(md,'data',vel,'edgecolor','w');\n\
583 \n\
584 md=bamg(model,'domain','Square.exp','hmax',.005);\n\
585 vel=shock(md.mesh.x,md.mesh.y);\n\
586 md=bamg(md,'field',vel,'err',0.03,'hmin',0.005,'hmax',0.3,'gradation',3);\n\
587 vel=shock(md.mesh.x,md.mesh.y);\n\
588 plotmodel(md,'data',vel,'edgecolor','w');\n\
589 \n\
590 md=bamg(model,'domain','Square.exp','hmax',.005);\n\
591 vel=shock(md.mesh.x,md.mesh.y);\n\
592 md=bamg(md,'field',vel,'err',0.03,'hmin',0.005,'hmax',0.3,'gradation',1.3,'anisomax',1);\n\
593 vel=shock(md.mesh.x,md.mesh.y);\n\
594 plotmodel(md,'data',vel,'edgecolor','w');\n\
595 end\n\
596 \n\
597 if any(steps==8) % Mesh refinement in a specific region\n\
598 plotmodel(md,'data',vel,'edgecolor','w');\n\
599 exptool('refinement.exp');\n\
600 h=NaN*ones(md.mesh.numberofvertices,1);\n\
601 in=ContourToNodes(md.mesh.x,md.mesh.y,'refinement.exp',1);\n\
602 h(find(in))=0.02;\n\
603 plotmodel(md,'data',in,'edgecolor','w');\n\
604 \n\
605 vel=shock(md.mesh.x,md.mesh.y);\n\
606 md=bamg(md,'field',vel,'err',0.03,'hmin',0.005,'hmax',0.3,'hVertices',h);\n\
607 vel=shock(md.mesh.x,md.mesh.y);\n\
608 plotmodel(md,'data',vel,'edgecolor','w');\n\
609 end\n\
610 "
611 #}}}
612 touch $RUNME_FILE
613 perl -0755 -p -i'.bak' -e "s|^.*$|${RUNME}|s" $RUNME_FILE
[25915]614 RUN_EXAMPLE=1
615 elif [ "${dir}" == "./Pig" ]; then
616 # STEP_SIX #{{{
617 STEP_SIX="\
[25986]618 if any(steps==6)\n\
[25915]619 % Load Model\n\
620 md = loadmodel('./Models/PIG_Control_drag');\n\
621 % Disable inversion\n\
622 md.inversion.iscontrol=0;\n\
623 % Extrude Mesh\n\
624 disp(' Extruding mesh');\n\
625 number_of_layers=3;\n\
626 md=extrude(md,number_of_layers,1);\n\
627 % Set Flowequation\n\
628 disp(' Using HO Ice Flow Model');\n\
629 md=setflowequation(md,'HO','all');\n\
630 % Solve\n\
631 md=solve(md,'Stressbalance');\n\
632 % Save Model\n\
633 save ./Models/PIG_ModelHO md;\n\
[25986]634 end\n\
[25915]635 "
636 #}}}
637 mv ./DomainOutline.bkp ./DomainOutline.exp > /dev/null 2>&1
[25983]638 sed -i.bak -e 's|steps=\[1\];|steps=\[1:7\];\ntry\n|' $RUNME_FILE
[25915]639 perl -0755 -p -i -e "s|if any\(steps==6\).*% step 6 end|${STEP_SIX}|s" $RUNME_FILE
640 RUN_EXAMPLE=1
641 elif [ "${dir}" == "./Pig2" ]; then
642 STEP_NINE="\n disp('Needs work!'); exit"
[25983]643 sed -i.bak -e 's|steps=\[1\];|steps=\[1:9\];\n\ntry\n|' $RUNME_FILE
[25915]644 perl -0755 -p -i -e "s|if any\(steps==9\).*% step 9 end|${STEP_NINE}|s" $RUNME_FILE
[25984]645 RUN_EXAMPLE=0
[25915]646 elif [ "${dir}" == "./PigSensitivity" ]; then
647 # STEP_FOUR # {{{
[25925]648 STEP_FOUR="\
649 if any(steps==4)\n\
650 %Load model\n\
651 md = loadmodel('./Models/PIG_Transient');\n\
652 \n\
653 %Change external forcing basal melting rate and surface mass balance)\n\
654 md.basalforcings.groundedice_melting_rate=zeros(md.mesh.numberofvertices,1);\n\
655 md.basalforcings.floatingice_melting_rate=25*ones(md.mesh.numberofvertices,1);\n\
656 md.smb.mass_balance=2*md.smb.mass_balance;\n\
657 \n\
658 %Define time steps and time span of the simulation\n\
659 md.timestepping.time_step=0.1;\n\
660 md.timestepping.final_time=10;\n\
661 \n\
662 %Request additional outputs\n\
663 md.transient.requested_outputs={'default','IceVolume','IceVolumeAboveFloatation'};\n\
664 \n\
665 %Solve\n\
666 md=solve(md,'Transient');\n\
667 \n\
[25983]668 %Plot\n\
669 plotmodel(md, 'data', md.results.TransientSolution(1).Vel,...\n\
670 'title#1', 'Velocity t=0 years (m/yr)',...\n\
671 'data', md.results.TransientSolution(end).Vel,...\n\
672 'title#2', 'Velocity t=10 years (m/yr)',...\n\
673 'data', md.results.TransientSolution(1).MaskOceanLevelset,...\n\
674 'title#3', 'Floating ice t=0 years',...\n\
675 'data', md.results.TransientSolution(end).MaskOceanLevelset,...\n\
676 'title#4', 'Floating ice t=10 years',...\n\
677 'caxis#1',([0 4500]),'caxis#2',([0 4500]),...\n\
678 'caxis#3',([-1,1]),'caxis#4',([-1,1]));\n\
679 \n\
[25925]680 %Save model\n\
681 save ./Models/PIG_SMB md;\n\
682 end\n\
683 "
[25915]684 #}}}
[25983]685 sed -i.bak -e 's|steps=\[1\];|steps=\[1:4\];\n\ntry\n|' $RUNME_FILE
686 perl -0755 -p -i -e "s|if any\(steps==4\).*% step 4 end|${STEP_FOUR}|s" $RUNME_FILE
[25925]687 RUN_EXAMPLE=1
[25915]688 elif [ "${dir}" == "./shakti" ]; then
[25983]689 sed -i.bak -e 's|steps=\[1:3\];|steps=\[1:3\];\n\ntry\n|' $RUNME_FILE
[25915]690 RUN_EXAMPLE=1
691 elif [ "${dir}" == "./SlrFarrell" ]; then
692 # TODO: Convert from md.slr
[25983]693 sed -i.bak -e 's|steps=\[1\];|steps=\[1:5\];\n\ntry\n|' $RUNME_FILE
[25915]694 RUN_EXAMPLE=0
695 elif [ "${dir}" == "./SlrGRACE" ]; then
696 # TODO: Convert from md.slr
[25983]697 sed -i.bak -e 's|steps=\[1\];|steps=\[1:7\];\n\ntry\n|' $RUNME_FILE
[25915]698 RUN_EXAMPLE=0
699 elif [ "${dir}" == "./SlrGRACE_NIMS" ]; then
700 # TODO: Convert from md.slr
[25983]701 sed -i.bak -e 's|steps=\[1\];|steps=\[1:8\];\n\ntry\n|' $RUNME_FILE
[25915]702 RUN_EXAMPLE=0
703 elif [ "${dir}" == "./SquareIceShelf" ]; then
[25983]704 sed -i.bak -e '1 s|^.*$|try\n\n&|' $RUNME_FILE
[25915]705 RUN_EXAMPLE=1
706 elif [ "${dir}" == "./UncertaintyQuantification" ]; then
[25983]707 sed -i.bak -e 's|steps=\[1\];|steps=\[1:7\];\n\ntry\n|' $RUNME_FILE
[25930]708 RUN_EXAMPLE=1
[25915]709 else
710 echo "Not implemented yet!"
711 exit 1
712 fi
713
714 if [ $RUN_EXAMPLE -eq 1 ]; then
715 echo "Testing example: $(basename $dir)"
716 LOG_RUNME_FILE="matlab_log_$(basename $dir)_examples.log"
717 echo -e ${STATUS_HANDLING} >> ${RUNME_FILE}
718 $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
719 echo "starting: $(basename $dir)" >> $ISSM_DIR/nightlylog/matlab_log_examples.log
720 cat $ISSM_DIR/nightlylog/$LOG_RUNME_FILE >> $ISSM_DIR/nightlylog/matlab_log_examples.log
721 echo "finished: $(basename $dir)" >> $ISSM_DIR/nightlylog/matlab_log_examples.log
722 mv -f ${RUNME_FILE}.bak ${RUNME_FILE}
723 fi
724
725 # Extra clean up
726 if [ "${dir}" == "./ISMIP" ]; then
727 mv -f IsmipA.par.bak IsmipA.par
728 mv -f IsmipF.par.bak IsmipF.par
729 fi
730
[25986]731 if [ "${dir}" == "./Mesh" ]; then
732 rm -f $RUNME_FILE
733 fi
734
[25915]735 if [ "${dir}" == "./Pig" ]; then
736 mv -f DomainOutline.exp DomainOutline.bkp
737 fi
738
739 cd ..
740 fi
741done
Note: See TracBrowser for help on using the repository browser.