[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 | #
|
---|
| 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
|
---|
[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
|
---|
[25946] | 49 | sed -i.bak '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
|
---|
[25946] | 55 | sed -i.bak 's|steps=\[1\];|steps=\[1:5\];\n\ntry\n|' $RUNME_FILE
|
---|
[25915] | 56 | RUN_EXAMPLE=1
|
---|
| 57 | elif [ "${dir}" == "./EsaWahr" ]; then
|
---|
[25946] | 58 | sed -i.bak '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="\
|
---|
| 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 | #}}}
|
---|
[25946] | 153 | sed -i.bak '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
|
---|
[25946] | 158 | sed -i.bak '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
|
---|
[25946] | 162 | sed -i.bak '1 s|^.*$|try\n\n&|' $RUNME_FILE
|
---|
[25915] | 163 | RUN_EXAMPLE=1
|
---|
| 164 | elif [ "${dir}" == "./Inversion" ]; then
|
---|
[25946] | 165 | sed -i.bak '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 | #
|
---|
| 172 | # RUNME #{{{
|
---|
| 173 | RUNME="\
|
---|
| 174 | try\n\
|
---|
| 175 | %which steps to perform; steps are from 1 to 8\n\
|
---|
| 176 | %step 7 is specific to ISMIPA\n\
|
---|
| 177 | %step 8 is specific to ISMIPF\n\
|
---|
| 178 | \n\
|
---|
| 179 | steps=[1:7]; %ISMIPA\n\
|
---|
| 180 | %steps=[1:6,8]; %ISMIPF\n\
|
---|
| 181 | \n\
|
---|
| 182 | % parameter file to be used, choose between IsmipA.par or IsmipF.par\n\
|
---|
| 183 | ParamFile='IsmipA.par';\n\
|
---|
| 184 | %ParamFile='IsmipF.par';\n\
|
---|
| 185 | \n\
|
---|
| 186 | %Run Steps\n\
|
---|
| 187 | \n\
|
---|
| 188 | %Mesh Generation #1\n\
|
---|
| 189 | if any(steps==1) %{{{\n\
|
---|
| 190 | %initialize md as a new model #help model\n\
|
---|
| 191 | %->\n\
|
---|
| 192 | md=model();\n\
|
---|
| 193 | % generate a squaremesh #help squaremesh\n\
|
---|
| 194 | % Side is 80 km long with 20 points\n\
|
---|
| 195 | %->\n\
|
---|
| 196 | if(ParamFile=='IsmipA.par'),\n\
|
---|
| 197 | md=squaremesh(md,80000,80000,20,20);\n\
|
---|
| 198 | elseif(ParamFile=='IsmipF.par'),\n\
|
---|
| 199 | md=squaremesh(md,100000,100000,30,30);\n\
|
---|
| 200 | end\n\
|
---|
| 201 | % plot the given mesh #plotdoc\n\
|
---|
| 202 | %->\n\
|
---|
| 203 | plotmodel(md,'data','mesh')\n\
|
---|
| 204 | % save the given model\n\
|
---|
| 205 | %->\n\
|
---|
| 206 | save ./Models/ISMIP.Mesh_generation md;\n\
|
---|
| 207 | end %}}}\n\
|
---|
| 208 | \n\
|
---|
| 209 | %Masks #2\n\
|
---|
| 210 | if any(steps==2) %{{{\n\
|
---|
| 211 | % load the preceding step #help loadmodel\n\
|
---|
| 212 | % path is given by the organizer with the name of the given step\n\
|
---|
| 213 | %->\n\
|
---|
| 214 | md = loadmodel('./Models/ISMIP.Mesh_generation');\n\
|
---|
| 215 | % set the mask #help setmask\n\
|
---|
| 216 | % all MISMIP nodes are grounded\n\
|
---|
| 217 | %->\n\
|
---|
| 218 | md=setmask(md,'','');\n\
|
---|
| 219 | % plot the given mask #md.mask to locate the field\n\
|
---|
| 220 | %->\n\
|
---|
| 221 | plotmodel(md,'data',md.mask.ocean_levelset);\n\
|
---|
| 222 | % save the given model\n\
|
---|
| 223 | %->\n\
|
---|
| 224 | save ./Models/ISMIP.SetMask md;\n\
|
---|
| 225 | end %}}}\n\
|
---|
| 226 | \n\
|
---|
| 227 | %Parameterization #3\n\
|
---|
| 228 | if any(steps==3) %{{{\n\
|
---|
| 229 | % load the preceding step #help loadmodel\n\
|
---|
| 230 | % path is given by the organizer with the name of the given step\n\
|
---|
| 231 | %->\n\
|
---|
| 232 | md = loadmodel('./Models/ISMIP.SetMask');\n\
|
---|
| 233 | % parametrize the model # help parameterize\n\
|
---|
| 234 | % you will need to fil-up the parameter file defined by the\n\
|
---|
| 235 | % ParamFile variable\n\
|
---|
| 236 | %->\n\
|
---|
| 237 | md=parameterize(md,ParamFile);\n\
|
---|
| 238 | % save the given model\n\
|
---|
| 239 | %->\n\
|
---|
| 240 | save ./Models/ISMIP.Parameterization md;\n\
|
---|
| 241 | end %}}}\n\
|
---|
| 242 | \n\
|
---|
| 243 | %Extrusion #4\n\
|
---|
| 244 | if any(steps==4) %{{{\n\
|
---|
| 245 | \n\
|
---|
| 246 | % load the preceding step #help loadmodel\n\
|
---|
| 247 | % path is given by the organizer with the name of the given step\n\
|
---|
| 248 | %->\n\
|
---|
| 249 | md = loadmodel('./Models/ISMIP.Parameterization');\n\
|
---|
| 250 | % vertically extrude the preceding mesh #help extrude\n\
|
---|
| 251 | % only 5 layers exponent 1\n\
|
---|
| 252 | %->\n\
|
---|
| 253 | md=extrude(md,9,1);\n\
|
---|
| 254 | % plot the 3D geometry #plotdoc\n\
|
---|
| 255 | %->\n\
|
---|
| 256 | plotmodel(md,'data',md.geometry.base)\n\
|
---|
| 257 | % save the given model\n\
|
---|
| 258 | %->\n\
|
---|
| 259 | save ./Models/ISMIP.Extrusion md;\n\
|
---|
| 260 | end %}}}\n\
|
---|
| 261 | \n\
|
---|
| 262 | %Set the flow computing method #5\n\
|
---|
| 263 | if any(steps==5) %{{{\n\
|
---|
| 264 | \n\
|
---|
| 265 | % load the preceding step #help loadmodel\n\
|
---|
| 266 | % path is given by the organizer with the name of the given step\n\
|
---|
| 267 | %->\n\
|
---|
| 268 | md = loadmodel('./Models/ISMIP.Extrusion');\n\
|
---|
| 269 | % set the approximation for the flow computation #help setflowequation\n\
|
---|
| 270 | % We will be using the Higher Order Model (HO)\n\
|
---|
| 271 | %->\n\
|
---|
| 272 | md=setflowequation(md,'HO','all');\n\
|
---|
| 273 | % save the given model\n\
|
---|
| 274 | %->\n\
|
---|
| 275 | save ./Models/ISMIP.SetFlow md;\n\
|
---|
| 276 | end %}}}\n\
|
---|
| 277 | \n\
|
---|
| 278 | %Set Boundary Conditions #6\n\
|
---|
| 279 | if any(steps==6) %{{{\n\
|
---|
| 280 | \n\
|
---|
| 281 | % load the preceding step #help loadmodel\n\
|
---|
| 282 | % path is given by the organizer with the name of the given step\n\
|
---|
| 283 | %->\n\
|
---|
| 284 | md = loadmodel('./Models/ISMIP.SetFlow');\n\
|
---|
| 285 | % dirichlet boundary condition are known as SPCs\n\
|
---|
| 286 | % ice frozen to the base, no velocity #md.stressbalance\n\
|
---|
| 287 | % SPCs are initialized at NaN one value per vertex\n\
|
---|
| 288 | %->\n\
|
---|
| 289 | md.stressbalance.spcvx=NaN*ones(md.mesh.numberofvertices,1);\n\
|
---|
| 290 | %->\n\
|
---|
| 291 | md.stressbalance.spcvy=NaN*ones(md.mesh.numberofvertices,1);\n\
|
---|
| 292 | %->\n\
|
---|
| 293 | md.stressbalance.spcvz=NaN*ones(md.mesh.numberofvertices,1);\n\
|
---|
| 294 | % extract the nodenumbers at the base #md.mesh.vertexonbase\n\
|
---|
| 295 | %->\n\
|
---|
| 296 | basalnodes=find(md.mesh.vertexonbase);\n\
|
---|
| 297 | % set the sliding to zero on the bed\n\
|
---|
| 298 | %->\n\
|
---|
| 299 | md.stressbalance.spcvx(basalnodes)=0.0;\n\
|
---|
| 300 | %->\n\
|
---|
| 301 | md.stressbalance.spcvy(basalnodes)=0.0;\n\
|
---|
| 302 | % periodic boundaries have to be fixed on the sides\n\
|
---|
| 303 | % create tabs with the side of the domain\n\
|
---|
| 304 | % for x\n\
|
---|
| 305 | % create maxX #help find\n\
|
---|
| 306 | %->\n\
|
---|
| 307 | maxX=find(md.mesh.x==max(md.mesh.x));\n\
|
---|
| 308 | % create minX\n\
|
---|
| 309 | %->\n\
|
---|
| 310 | minX=find(md.mesh.x==min(md.mesh.x));\n\
|
---|
| 311 | % for y, max X and minX should be excluded\n\
|
---|
| 312 | % create maxY\n\
|
---|
| 313 | %->\n\
|
---|
| 314 | maxY=find(md.mesh.y==max(md.mesh.y) & md.mesh.x~=max(md.mesh.x) & md.mesh.x~=min(md.mesh.x));\n\
|
---|
| 315 | % create minY\n\
|
---|
| 316 | %->\n\
|
---|
| 317 | minY=find(md.mesh.y==min(md.mesh.y) & md.mesh.x~=max(md.mesh.x) & md.mesh.x~=min(md.mesh.x));\n\
|
---|
| 318 | % set the node that should be paired together\n\
|
---|
| 319 | % #md.stressbalance.vertex_pairing\n\
|
---|
| 320 | %->\n\
|
---|
| 321 | md.stressbalance.vertex_pairing=[minX,maxX;minY,maxY];\n\
|
---|
| 322 | if (ParamFile=='IsmipF.par')\n\
|
---|
| 323 | % if we are dealing with IsmipF the solution is in\n\
|
---|
| 324 | % masstransport\n\
|
---|
| 325 | md.masstransport.vertex_pairing=md.stressbalance.vertex_pairing;\n\
|
---|
| 326 | end\n\
|
---|
| 327 | % save the given model\n\
|
---|
| 328 | %->\n\
|
---|
| 329 | save ./Models/ISMIP.BoundaryCondition md;\n\
|
---|
| 330 | end %}}}\n\
|
---|
| 331 | \n\
|
---|
| 332 | %Solving #7\n\
|
---|
| 333 | if any(steps==7) %{{{\n\
|
---|
| 334 | % load the preceding step #help loadmodel\n\
|
---|
| 335 | % path is given by the organizer with the name of the given step\n\
|
---|
| 336 | %->\n\
|
---|
| 337 | md = loadmodel('./Models/ISMIP.BoundaryCondition');\n\
|
---|
| 338 | % Set cluster #md.cluster\n\
|
---|
| 339 | % generic parameters #help generic\n\
|
---|
| 340 | % set only the name and number of process\n\
|
---|
| 341 | %->\n\
|
---|
| 342 | md.cluster=generic('name',oshostname(),'np',2);\n\
|
---|
| 343 | % Set which control message you want to see #help verbose\n\
|
---|
| 344 | %->\n\
|
---|
| 345 | md.verbose=verbose('convergence',true);\n\
|
---|
| 346 | % Solve #help solve\n\
|
---|
| 347 | % we are solving a StressBalanc\n\
|
---|
| 348 | %->\n\
|
---|
| 349 | md=solve(md,'Stressbalance');\n\
|
---|
| 350 | % save the given model\n\
|
---|
| 351 | %->\n\
|
---|
| 352 | save ./Models/ISMIP.StressBalance md;\n\
|
---|
| 353 | % plot the surface velocities #plotdoc\n\
|
---|
| 354 | %->\n\
|
---|
| 355 | plotmodel(md,'data',md.results.StressbalanceSolution.Vel)\n\
|
---|
| 356 | end %}}}\n\
|
---|
| 357 | \n\
|
---|
| 358 | %Solving #8\n\
|
---|
| 359 | if any(steps==8) %{{{\n\
|
---|
| 360 | % load the preceding step #help loadmodel\n\
|
---|
| 361 | % path is given by the organizer with the name of the given step\n\
|
---|
| 362 | %->\n\
|
---|
| 363 | md = loadmodel('./Models/ISMIP.BoundaryCondition');\n\
|
---|
| 364 | % Set cluster #md.cluster\n\
|
---|
| 365 | % generic parameters #help generic\n\
|
---|
| 366 | % set only the name and number of process\n\
|
---|
| 367 | %->\n\
|
---|
| 368 | md.cluster=generic('name',oshostname(),'np',2);\n\
|
---|
| 369 | % Set which control message you want to see #help verbose\n\
|
---|
| 370 | %->\n\
|
---|
| 371 | md.verbose=verbose('convergence',true);\n\
|
---|
| 372 | % set the transient model to ignore the thermal model\n\
|
---|
| 373 | % #md.transient \n\
|
---|
| 374 | %->\n\
|
---|
| 375 | md.transient.isthermal=0;\n\
|
---|
| 376 | % define the timestepping scheme\n\
|
---|
| 377 | % everything here should be provided in years #md.timestepping\n\
|
---|
| 378 | % give the length of the time_step (4 years)\n\
|
---|
| 379 | %->\n\
|
---|
| 380 | md.timestepping.time_step=4;\n\
|
---|
| 381 | % give final_time (20*4 years time_steps)\n\
|
---|
| 382 | %->\n\
|
---|
| 383 | md.timestepping.final_time=4*20;\n\
|
---|
| 384 | % Solve #help solve\n\
|
---|
| 385 | % we are solving a TransientSolution\n\
|
---|
| 386 | %->\n\
|
---|
| 387 | md=solve(md,'Transient');\n\
|
---|
| 388 | % save the given model\n\
|
---|
| 389 | %->\n\
|
---|
| 390 | save ./Models/ISMIP.Transient md;\n\
|
---|
| 391 | % plot the surface velocities #plotdoc\n\
|
---|
| 392 | %->\n\
|
---|
| 393 | plotmodel(md,'data',md.results.TransientSolution(20).Vel)\n\
|
---|
| 394 | end %}}}\n\
|
---|
| 395 | "
|
---|
| 396 | #}}}
|
---|
| 397 | # PAR_A #{{{
|
---|
| 398 | PAR_A="\
|
---|
| 399 | %Parameterization for ISMIP A experiment\n\
|
---|
| 400 | \n\
|
---|
| 401 | %Set the Simulation generic name #md.miscellaneous\n\
|
---|
| 402 | %->\n\
|
---|
| 403 | \n\
|
---|
| 404 | %Geometry\n\
|
---|
| 405 | disp(' Constructing Geometry');\n\
|
---|
| 406 | \n\
|
---|
| 407 | %Define the geometry of the simulation #md.geometry\n\
|
---|
| 408 | %surface is [-x*tan(0.5*pi/180)] #md.mesh\n\
|
---|
| 409 | %->\n\
|
---|
| 410 | md.geometry.surface=-md.mesh.x*tan(0.5*pi/180.);\n\
|
---|
| 411 | %base is [surface-1000+500*sin(x*2*pi/L).*sin(y*2*pi/L)]\n\
|
---|
| 412 | %L is the size of the side of the square #max(md.mesh.x)-min(md.mesh.x)\n\
|
---|
| 413 | %->\n\
|
---|
| 414 | L=max(md.mesh.x)-min(md.mesh.x);\n\
|
---|
| 415 | 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\
|
---|
| 416 | %thickness is the difference between surface and base #md.geometry\n\
|
---|
| 417 | %->\n\
|
---|
| 418 | md.geometry.thickness=md.geometry.surface-md.geometry.base;\n\
|
---|
| 419 | %plot the geometry to check it out\n\
|
---|
| 420 | %->\n\
|
---|
| 421 | plotmodel(md,'data',md.geometry.thickness);\n\
|
---|
| 422 | \n\
|
---|
| 423 | disp(' Defining friction parameters');\n\
|
---|
| 424 | \n\
|
---|
| 425 | %These parameters will not be used but need to be fixed #md.friction\n\
|
---|
| 426 | %one friciton coefficient per node (md.mesh.numberofvertices,1)\n\
|
---|
| 427 | %->\n\
|
---|
| 428 | md.friction.coefficient=200.0*ones(md.mesh.numberofvertices,1);\n\
|
---|
| 429 | %one friciton exponent (p,q) per element\n\
|
---|
| 430 | %->\n\
|
---|
| 431 | md.friction.p=ones(md.mesh.numberofelements,1);\n\
|
---|
| 432 | %->\n\
|
---|
| 433 | md.friction.q=ones(md.mesh.numberofelements,1);\n\
|
---|
| 434 | \n\
|
---|
| 435 | disp(' Construct ice rheological properties');\n\
|
---|
| 436 | \n\
|
---|
| 437 | %The rheology parameters sit in the material section #md.materials\n\
|
---|
| 438 | %B has one value per vertex\n\
|
---|
| 439 | %->\n\
|
---|
| 440 | md.materials.rheology_B=6.8067e7*ones(md.mesh.numberofvertices,1);\n\
|
---|
| 441 | %n has one value per element\n\
|
---|
| 442 | %->\n\
|
---|
| 443 | md.materials.rheology_n=3*ones(md.mesh.numberofelements,1);\n\
|
---|
| 444 | \n\
|
---|
| 445 | disp(' Set boundary conditions');\n\
|
---|
| 446 | \n\
|
---|
| 447 | %Set the default boundary conditions for an ice-sheet \n\
|
---|
| 448 | % #help SetIceSheetBC\n\
|
---|
| 449 | %->\n\
|
---|
| 450 | md=SetIceSheetBC(md);\n\
|
---|
| 451 | "
|
---|
| 452 | #}}}
|
---|
| 453 | # PAR_F #{{{
|
---|
| 454 | PAR_F="\
|
---|
| 455 | %Parameterization for ISMIP F experiment\n\
|
---|
| 456 | \n\
|
---|
| 457 | %Set the Simulation generic name #md.miscellaneous\n\
|
---|
| 458 | %->\n\
|
---|
| 459 | \n\
|
---|
| 460 | %Geometry\n\
|
---|
| 461 | disp(' Constructing Geometry');\n\
|
---|
| 462 | \n\
|
---|
| 463 | %Define the geometry of the simulation #md.geometry\n\
|
---|
| 464 | %surface is [-x*tan(3.0*pi/180)] #md.mesh\n\
|
---|
| 465 | %->\n\
|
---|
| 466 | md.geometry.surface=md.mesh.x*tan(3.0*pi/180.0);\n\
|
---|
| 467 | %base is [surface-1000+100*exp(-((x-L/2).^2+(y-L/2).^2)/(10000.^2))]\n\
|
---|
| 468 | %L is the size of the side of the square #max(md.mesh.x)-min(md.mesh.x)\n\
|
---|
| 469 | %->\n\
|
---|
| 470 | L=max(md.mesh.x)-min(md.mesh.x);\n\
|
---|
| 471 | %->\n\
|
---|
| 472 | 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\
|
---|
| 473 | %thickness is the difference between surface and base #md.geometry\n\
|
---|
| 474 | %->\n\
|
---|
| 475 | md.geometry.thickness=md.geometry.surface-md.geometry.base;\n\
|
---|
| 476 | %plot the geometry to check it out\n\
|
---|
| 477 | %->\n\
|
---|
| 478 | plotmodel(md,'data',md.geometry.thickness);\n\
|
---|
| 479 | \n\
|
---|
| 480 | disp(' Defining friction parameters');\n\
|
---|
| 481 | \n\
|
---|
| 482 | %These parameters will not be used but need to be fixed #md.friction\n\
|
---|
| 483 | %one friciton coefficient per node (md.mesh.numberofvertices,1)\n\
|
---|
| 484 | %conversion form year to seconds with #md.constants.yts\n\
|
---|
| 485 | %->\n\
|
---|
| 486 | md.friction.coefficient=sqrt(md.constants.yts/(1000*2.140373*10^-7))*ones(md.mesh.numberofvertices,1);\n\
|
---|
| 487 | %one friciton exponent (p,q) per element\n\
|
---|
| 488 | %->\n\
|
---|
| 489 | md.friction.p=ones(md.mesh.numberofelements,1);\n\
|
---|
| 490 | %->\n\
|
---|
| 491 | md.friction.q=zeros(md.mesh.numberofelements,1);\n\
|
---|
| 492 | \n\
|
---|
| 493 | disp(' Construct ice rheological properties');\n\
|
---|
| 494 | \n\
|
---|
| 495 | %The rheology parameters sit in the material section #md.materials\n\
|
---|
| 496 | %B has one value per vertex\n\
|
---|
| 497 | %->\n\
|
---|
| 498 | md.materials.rheology_B=(1/(2.140373*10^-7/md.constants.yts))*ones(md.mesh.numberofvertices,1);\n\
|
---|
| 499 | %n has one value per element\n\
|
---|
| 500 | %->\n\
|
---|
| 501 | md.materials.rheology_n=1*ones(md.mesh.numberofelements,1);\n\
|
---|
| 502 | \n\
|
---|
| 503 | disp(' Set boundary conditions');\n\
|
---|
| 504 | \n\
|
---|
| 505 | %Set the default boundary conditions for an ice-sheet \n\
|
---|
| 506 | % #help SetIceSheetBC\n\
|
---|
| 507 | %->\n\
|
---|
| 508 | md=SetIceSheetBC(md);\n\
|
---|
| 509 | \n\
|
---|
| 510 | disp(' Initializing velocity and pressure');\n\
|
---|
| 511 | \n\
|
---|
| 512 | %initialize the velocity and pressurefields of #md.initialization\n\
|
---|
| 513 | %->\n\
|
---|
| 514 | md.initialization.vx=zeros(md.mesh.numberofvertices,1);\n\
|
---|
| 515 | %->\n\
|
---|
| 516 | md.initialization.vy=zeros(md.mesh.numberofvertices,1);\n\
|
---|
| 517 | %->\n\
|
---|
| 518 | md.initialization.vz=zeros(md.mesh.numberofvertices,1);\n\
|
---|
| 519 | %->\n\
|
---|
| 520 | md.initialization.pressure=zeros(md.mesh.numberofvertices,1);\n\
|
---|
| 521 | "
|
---|
| 522 | #}}}
|
---|
| 523 | perl -0755 -p -i'.bak' -e "s|^.*$|${RUNME}|s" $RUNME_FILE
|
---|
| 524 | perl -0755 -p -i'.bak' -e "s|^.*$|${PAR_A}|s" IsmipA.par
|
---|
| 525 | perl -0755 -p -i'.bak' -e "s|^.*$|${PAR_F}|s" IsmipF.par
|
---|
| 526 | RUN_EXAMPLE=1
|
---|
| 527 | elif [ "${dir}" == "./Jakobshavn" ]; then
|
---|
[25946] | 528 | sed -i.bak 's|steps=\[1\];|steps=\[1:4\];\n\ntry\n|' $RUNME_FILE
|
---|
[25915] | 529 | RUN_EXAMPLE=1
|
---|
| 530 | elif [ "${dir}" == "./LcurveAnalysis" ]; then
|
---|
[25946] | 531 | sed -i.bak 's|steps=\[1\];|steps=\[1:4\];\n\ntry\n|' $RUNME_FILE
|
---|
[25915] | 532 | RUN_EXAMPLE=1
|
---|
| 533 | elif [ "${dir}" == "./Mesh" ]; then
|
---|
| 534 | # NOTE: Cannot test exptool region selection without GUI
|
---|
[25946] | 535 | sed -i.bak 's|steps=\[1\];|steps=\[1:7\];\n\ntry\n|' $RUNME_FILE
|
---|
[25915] | 536 | RUN_EXAMPLE=1
|
---|
| 537 | elif [ "${dir}" == "./Pig" ]; then
|
---|
| 538 | # STEP_SIX #{{{
|
---|
| 539 | STEP_SIX="\
|
---|
| 540 | if any(steps==6) %{{{\n\
|
---|
| 541 | % Load Model\n\
|
---|
| 542 | md = loadmodel('./Models/PIG_Control_drag');\n\
|
---|
| 543 | % Disable inversion\n\
|
---|
| 544 | md.inversion.iscontrol=0;\n\
|
---|
| 545 | % Extrude Mesh\n\
|
---|
| 546 | disp(' Extruding mesh');\n\
|
---|
| 547 | number_of_layers=3;\n\
|
---|
| 548 | md=extrude(md,number_of_layers,1);\n\
|
---|
| 549 | % Set Flowequation\n\
|
---|
| 550 | disp(' Using HO Ice Flow Model');\n\
|
---|
| 551 | md=setflowequation(md,'HO','all');\n\
|
---|
| 552 | % Solve\n\
|
---|
| 553 | md=solve(md,'Stressbalance');\n\
|
---|
| 554 | % Save Model\n\
|
---|
| 555 | save ./Models/PIG_ModelHO md;\n\
|
---|
| 556 | end %}}}\n\
|
---|
| 557 | "
|
---|
| 558 | #}}}
|
---|
| 559 | mv ./DomainOutline.bkp ./DomainOutline.exp > /dev/null 2>&1
|
---|
[25946] | 560 | sed -i.bak "s|steps=\[1\];|steps=\[1:7\];\ntry\n|" $RUNME_FILE
|
---|
[25915] | 561 | perl -0755 -p -i -e "s|if any\(steps==6\).*% step 6 end|${STEP_SIX}|s" $RUNME_FILE
|
---|
| 562 | RUN_EXAMPLE=1
|
---|
| 563 | elif [ "${dir}" == "./Pig2" ]; then
|
---|
| 564 | STEP_NINE="\n disp('Needs work!'); exit"
|
---|
[25946] | 565 | sed -i.bak 's|steps=\[1\];|steps=\[1:9\];\n\ntry\n|' $RUNME_FILE
|
---|
[25915] | 566 | perl -0755 -p -i -e "s|if any\(steps==9\).*% step 9 end|${STEP_NINE}|s" $RUNME_FILE
|
---|
| 567 | RUN_EXAMPLE=1
|
---|
| 568 | elif [ "${dir}" == "./PigSensitivity" ]; then
|
---|
| 569 | # STEP_FOUR # {{{
|
---|
[25925] | 570 | STEP_FOUR="\
|
---|
| 571 | if any(steps==4)\n\
|
---|
| 572 | %Load model\n\
|
---|
| 573 | md = loadmodel('./Models/PIG_Transient');\n\
|
---|
| 574 | \n\
|
---|
| 575 | %Change external forcing basal melting rate and surface mass balance)\n\
|
---|
| 576 | md.basalforcings.groundedice_melting_rate=zeros(md.mesh.numberofvertices,1);\n\
|
---|
| 577 | md.basalforcings.floatingice_melting_rate=25*ones(md.mesh.numberofvertices,1);\n\
|
---|
| 578 | md.smb.mass_balance=2*md.smb.mass_balance;\n\
|
---|
| 579 | \n\
|
---|
| 580 | %Define time steps and time span of the simulation\n\
|
---|
| 581 | md.timestepping.time_step=0.1;\n\
|
---|
| 582 | md.timestepping.final_time=10;\n\
|
---|
| 583 | \n\
|
---|
| 584 | %Request additional outputs\n\
|
---|
| 585 | md.transient.requested_outputs={'default','IceVolume','IceVolumeAboveFloatation'};\n\
|
---|
| 586 | \n\
|
---|
| 587 | %Solve\n\
|
---|
| 588 | md=solve(md,'Transient');\n\
|
---|
| 589 | \n\
|
---|
| 590 | %Save model\n\
|
---|
| 591 | save ./Models/PIG_SMB md;\n\
|
---|
| 592 | end\n\
|
---|
| 593 | "
|
---|
[25915] | 594 | #}}}
|
---|
[25946] | 595 | sed -i.bak 's|steps=\[1\];|steps=\[1:4\];\n\ntry\n|' $RUNME_FILE
|
---|
[25915] | 596 | sed -i '' "s|if any(steps==4)|&${STEP_FOUR}|" $RUNME_FILE
|
---|
[25925] | 597 | RUN_EXAMPLE=1
|
---|
[25915] | 598 | elif [ "${dir}" == "./shakti" ]; then
|
---|
[25946] | 599 | sed -i.bak 's|steps=\[1:3\];|steps=\[1:3\];\n\ntry\n|' $RUNME_FILE
|
---|
[25915] | 600 | RUN_EXAMPLE=1
|
---|
| 601 | elif [ "${dir}" == "./SlrFarrell" ]; then
|
---|
| 602 | # TODO: Convert from md.slr
|
---|
[25946] | 603 | sed -i.bak 's|steps=\[1\];|steps=\[1:5\];\n\ntry\n|' $RUNME_FILE
|
---|
[25915] | 604 | RUN_EXAMPLE=0
|
---|
| 605 | elif [ "${dir}" == "./SlrGRACE" ]; then
|
---|
| 606 | # TODO: Convert from md.slr
|
---|
[25946] | 607 | sed -i.bak 's|steps=\[1\];|steps=\[1:7\];\n\ntry\n|' $RUNME_FILE
|
---|
[25915] | 608 | RUN_EXAMPLE=0
|
---|
| 609 | elif [ "${dir}" == "./SlrGRACE_NIMS" ]; then
|
---|
| 610 | # TODO: Convert from md.slr
|
---|
[25946] | 611 | sed -i.bak 's|steps=\[1\];|steps=\[1:8\];\n\ntry\n|' $RUNME_FILE
|
---|
[25915] | 612 | RUN_EXAMPLE=0
|
---|
| 613 | elif [ "${dir}" == "./SquareIceShelf" ]; then
|
---|
[25946] | 614 | sed -i.bak '1 s|^.*$|try\n\n&|' $RUNME_FILE
|
---|
[25915] | 615 | RUN_EXAMPLE=1
|
---|
| 616 | elif [ "${dir}" == "./UncertaintyQuantification" ]; then
|
---|
[25946] | 617 | sed -i.bak 's|steps=\[1\];|steps=\[1:7\];\n\ntry\n|' $RUNME_FILE
|
---|
[25930] | 618 | RUN_EXAMPLE=1
|
---|
[25915] | 619 | else
|
---|
| 620 | echo "Not implemented yet!"
|
---|
| 621 | exit 1
|
---|
| 622 | fi
|
---|
| 623 |
|
---|
| 624 | if [ $RUN_EXAMPLE -eq 1 ]; then
|
---|
| 625 | echo "Testing example: $(basename $dir)"
|
---|
| 626 | LOG_RUNME_FILE="matlab_log_$(basename $dir)_examples.log"
|
---|
| 627 | echo -e ${STATUS_HANDLING} >> ${RUNME_FILE}
|
---|
| 628 | $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
|
---|
| 629 | echo "starting: $(basename $dir)" >> $ISSM_DIR/nightlylog/matlab_log_examples.log
|
---|
| 630 | cat $ISSM_DIR/nightlylog/$LOG_RUNME_FILE >> $ISSM_DIR/nightlylog/matlab_log_examples.log
|
---|
| 631 | echo "finished: $(basename $dir)" >> $ISSM_DIR/nightlylog/matlab_log_examples.log
|
---|
| 632 | mv -f ${RUNME_FILE}.bak ${RUNME_FILE}
|
---|
| 633 | fi
|
---|
| 634 |
|
---|
| 635 | # Extra clean up
|
---|
| 636 | if [ "${dir}" == "./ISMIP" ]; then
|
---|
| 637 | mv -f IsmipA.par.bak IsmipA.par
|
---|
| 638 | mv -f IsmipF.par.bak IsmipF.par
|
---|
| 639 | fi
|
---|
| 640 |
|
---|
| 641 | if [ "${dir}" == "./Pig" ]; then
|
---|
| 642 | mv -f DomainOutline.exp DomainOutline.bkp
|
---|
| 643 | fi
|
---|
| 644 |
|
---|
| 645 | cd ..
|
---|
| 646 | fi
|
---|
| 647 | done
|
---|