Changeset 22880
- Timestamp:
- 06/28/18 10:05:28 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified issm/trunk-jpl/src/m/solve/solve.js ¶
r22831 r22880 1 function solve(md, solutionstring) { 1 function solve(md, solutionstring) {//{{{ 2 2 /** 3 3 * SOLVE - apply solution sequence for this model … … 45 45 46 46 //recover and process solve options 47 if ((solutionstring.toLowerCase() === 'sb') || (solutionstring.toLowerCase() === 'stressbalance')) { 47 let solutionStringLowerCase = solutionstring.toLowerCase(); 48 49 if ((solutionStringLowerCase === 'sb') || (solutionStringLowerCase === 'stressbalance')) { 48 50 solutionstring = 'StressbalanceSolution'; 49 } else if ((solution string.toLowerCase() === 'mt') || (solutionstring.toLowerCase()=== 'masstransport')) {51 } else if ((solutionStringLowerCase === 'mt') || (solutionStringLowerCase === 'masstransport')) { 50 52 solutionstring = 'MasstransportSolution'; 51 } else if ((solution string.toLowerCase() === 'th') || (solutionstring.toLowerCase()=== 'thermal')) {53 } else if ((solutionStringLowerCase === 'th') || (solutionStringLowerCase === 'thermal')) { 52 54 solutionstring = 'ThermalSolution'; 53 } else if ((solution string.toLowerCase() === 'st') || (solutionstring.toLowerCase()=== 'steadystate')) {55 } else if ((solutionStringLowerCase === 'st') || (solutionStringLowerCase === 'steadystate')) { 54 56 solutionstring = 'SteadystateSolution'; 55 } else if ((solution string.toLowerCase() === 'tr') || (solutionstring.toLowerCase()=== 'transient')) {57 } else if ((solutionStringLowerCase === 'tr') || (solutionStringLowerCase === 'transient')) { 56 58 solutionstring = 'TransientSolution'; 57 } else if ((solution string.toLowerCase() === 'mc') || (solutionstring.toLowerCase()=== 'balancethickness')) {59 } else if ((solutionStringLowerCase === 'mc') || (solutionStringLowerCase === 'balancethickness')) { 58 60 solutionstring = 'BalancethicknessSolution'; 59 } else if ((solution string.toLowerCase() === 'bv') || (solutionstring.toLowerCase()=== 'balancevelocity')) {61 } else if ((solutionStringLowerCase === 'bv') || (solutionStringLowerCase === 'balancevelocity')) { 60 62 solutionstring = 'BalancevelocitySolution'; 61 } else if ((solution string.toLowerCase() === 'bsl') || (solutionstring.toLowerCase()=== 'bedslope')) {63 } else if ((solutionStringLowerCase === 'bsl') || (solutionStringLowerCase === 'bedslope')) { 62 64 solutionstring = 'BedSlopeSolution'; 63 } else if ((solution string.toLowerCase() === 'ssl') || (solutionstring.toLowerCase()=== 'surfaceslope')) {65 } else if ((solutionStringLowerCase === 'ssl') || (solutionStringLowerCase === 'surfaceslope')) { 64 66 solutionstring = 'SurfaceSlopeSolution'; 65 } else if ((solution string.toLowerCase() === 'hy') || (solutionstring.toLowerCase()=== 'hydrology')) {67 } else if ((solutionStringLowerCase === 'hy') || (solutionStringLowerCase === 'hydrology')) { 66 68 solutionstring = 'HydrologySolution'; 67 } else if ((solution string.toLowerCase() === 'da') || (solutionstring.toLowerCase()=== 'damageevolution')) {69 } else if ((solutionStringLowerCase === 'da') || (solutionStringLowerCase === 'damageevolution')) { 68 70 solutionstring = 'DamageEvolutionSolution'; 69 } else if ((solution string.toLowerCase() === 'gia') || (solutionstring.toLowerCase()=== 'gia')) {71 } else if ((solutionStringLowerCase === 'gia') || (solutionStringLowerCase === 'gia')) { 70 72 solutionstring = 'GiaSolution'; 71 } else if ((solution string.toLowerCase() === 'slr') || (solutionstring.toLowerCase()=== 'sealevelrise')) {73 } else if ((solutionStringLowerCase === 'slr') || (solutionStringLowerCase === 'sealevelrise')) { 72 74 solutionstring = 'SealevelriseSolution'; 73 75 } else { … … 75 77 } 76 78 77 // Process options78 var args= Array.prototype.slice.call(arguments);79 var options = new pairoptions(args.slice(2,args.length));80 options.addfield('solutionstring', solutionstring);81 82 // recover some fields83 md.priv.solution =solutionstring;84 cluster =md.cluster;79 // Process options 80 let args = Array.prototype.slice.call(arguments); 81 let options = new pairoptions(args.slice(2, args.length)); 82 options.addfield('solutionstring', solutionstring); 83 84 // recover some fields 85 md.priv.solution = solutionstring; 86 cluster = md.cluster; 85 87 86 88 //check model consistency 87 if (options.getfieldvalue('checkconsistency', 'yes') == 'yes'){88 if (md.verbose.solution) {89 if (options.getfieldvalue('checkconsistency', 'yes') === 'yes') { 90 if (md.verbose.solution) { 89 91 console.log('checking model consistency'); 90 92 } 93 91 94 ismodelselfconsistent(md); 92 95 } 93 96 94 //If we are restarting, actually use the provided runtime name: 95 restart=options.getfieldvalue('restart',''); 96 97 //First, build a runtime name that is unique 98 if (restart==1 ){ 99 //Leave the runtimename as is 97 // If we are restarting, actually use the provided runtime name: 98 restart = options.getfieldvalue('restart', ''); 99 100 // First, build a runtime name that is unique 101 if (restart === 1 ) { 102 // Leave the runtimename as is 103 } else { 104 if (!(restart === '')) { 105 md.priv.runtimename=restart; 106 } else if (options.getfieldvalue('runtimename',true)) { 107 let c = new Date().getTime(); 108 md.priv.runtimename = sprintf('%s-%g', md.miscellaneous.name, c); 109 } else { 110 md.priv.runtimename = md.miscellaneous.name; 100 111 } 101 else{ 102 if (!(restart == '')){ 103 md.priv.runtimename=restart; 104 } 105 else if (options.getfieldvalue('runtimename',true)){ 106 c=new Date().getTime(); 107 md.priv.runtimename=sprintf('%s-%g',md.miscellaneous.name,c); 108 } 109 else{ 110 md.priv.runtimename=md.miscellaneous.name; 111 } 112 } 113 114 //if running qmu analysis, some preprocessing of dakota files using models 115 //fields needs to be carried out. 116 if (md.qmu.isdakota){ 112 } 113 114 // If running qmu analysis, some preprocessing of dakota files using models fields needs to be carried out 115 if (md.qmu.isdakota) { 117 116 throw Error("solve error message: qmu runs not supported yet!"); 118 117 //md.preqmu(options); 119 118 } 120 119 121 122 //Do we load results only? 123 if (options.getfieldvalue('loadonly',false)){ 120 // Do we load results only? 121 if (options.getfieldvalue('loadonly', false)){ 124 122 loadresultsfromcluster(md); 125 123 return; 126 124 } 127 125 128 // Marshall into a binary array (fid) all the fields of model.129 var fid = marshall(md);// bin file126 // Marshall into a binary array (fid) all the fields of model 127 let fid = marshall(md); // bin file 130 128 131 129 //deal with toolkits options: 132 toolkitsstring = md.toolkits.ToolkitsFile(md.miscellaneous.name + '.toolkits'); // toolkits file130 toolkitsstring = md.toolkits.ToolkitsFile(md.miscellaneous.name + '.toolkits'); // toolkits file 133 131 134 132 135 133 /* 136 134 Set success callback function 137 */138 //{{{139 140 // Default: do nothing if no success callback function requested135 136 Default: do nothing if no success callback function requested 137 */ 138 //{{{ 141 139 function successCallbackDefault() { 142 140 solving = false; … … 149 147 /* 150 148 Set error callback function 151 */152 //{{{153 154 // Default: do nothing if no error callback function requested149 150 Default: do nothing if no error callback function requested 151 */ 152 //{{{ 155 153 function errorCallbackDefault() { 156 154 solving = false; … … 163 161 /* 164 162 Set solve button ID 165 */166 //{{{167 168 // Default: update #solve-button element with progress updates163 164 Default: update #solve-button element with progress updates 165 */ 166 //{{{ 169 167 let solveButtonId = options.getfieldvalue('solveButtonId', '#solve-button'); 170 168 //}}} … … 184 182 /* 185 183 Set progress bar display boolean 186 */ 187 //{{{ 188 // Default: no progress bar; NOTE: must have supplied a callout for progress bar to display 184 185 Default: no progress bar 186 187 NOTE: must have supplied a callout for progress bar to display 188 */ 189 //{{{ 189 190 let withProgressBar = options.getfieldvalue('withProgressBar', false); 190 191 //}}} 191 192 192 193 193 if (cluster.classname() == 'local'){//{{{194 195 / *We are running locally on the machine, using the issm module:*/194 if (cluster.classname() === 'local') {//{{{ 195 196 // We are running locally on the machine, using the issm module 196 197 console.log('running issm locally'); 197 198 198 //Call issm: 199 var outputs = issm(fid, toolkitsstring, solutionstring, md.miscellaneous.name); 200 201 //Recover output arguments: 202 var outputbuffer = outputs[0]; var outputbuffersize = outputs[1]; 199 // Call issm 200 let outputs = issm(fid, toolkitsstring, solutionstring, md.miscellaneous.name); 201 202 // Recover output arguments: 203 let outputbuffer = outputs[0]; 204 let outputbuffersize = outputs[1]; 203 205 204 // Load results:206 // Load results 205 207 md = loadresultsfrombuffer(md, outputbuffer, outputbuffersize); 206 208 … … 210 212 return md; 211 213 //}}} 212 } else { 214 } else {//{{{ 213 215 // We are running somewhere else on a computational server. Send the buffer to that server and retrieve output. 214 216 console.log('running issm remotely'); … … 229 231 230 232 return md; 231 //}}} 232 } 233 //}}} 234 } 233 }//}}} 234 }//}}}
Note:
See TracChangeset
for help on using the changeset viewer.