Changeset 20269


Ignore:
Timestamp:
02/27/16 19:17:57 (9 years ago)
Author:
Eric.Larour
Message:

CHG (JS): improved solve.js that uses the local and generic clusters, and a more generic
server interface. Goal is to move towards a cloud server capability.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/solve/solve.js

    r19831 r20269  
    6363        //If we are restarting, actually use the provided runtime name:
    6464        restart=options.getfieldvalue('restart','');
     65
    6566        //First, build a runtime name that is unique
    6667        if (restart==1 ){
     
    8788        }
    8889
    89         //flaim analysis (To be removed?)
    90         if (solutionenum == FlaimSolutionEnum()){
    91                 //fmdir     = options.getfieldvalue('fmdir',['fm' num2str(feature('GetPid'))]);
    92                 //overwrite = options.getfieldvalue('overwrite','n');
    93                 //keep      = options.getfieldvalue('keep','y');
    94                 //latsgn    = options.getfieldvalue('latsgn',0);
    95                 //cmap      = options.getfieldvalue('cmap',[]);
    96                 throw  Error("solve error message: flaim runs not supported yet!");
    97                 //flaim_sol(md,options);
    98                 //md.priv.solution=EnumToString(solutionenum);
    99                 //return;
    100         }
    10190
    10291        //Do we load results only?
     
    10695        }
    10796
    108         //Write all input files
    109         fid = marshall(md);                                          // bin file
     97        //Marshall into a binary array (fid) all the fields of model.
     98        var fid = marshall(md);                                          // bin file
     99       
     100        //deal with toolkits options:
    110101        toolkitsstring= md.toolkits.ToolkitsFile(md.miscellaneous.name + '.toolkits'); // toolkits file
    111102
    112         if (cluster.classname() != 'local'){ //{{{
    113103
    114                 throw Error('non local clusters not supported yet!');
    115 
    116                 cluster.BuildQueueScript(md.priv.runtimename,md.miscellaneous.name,md.priv.solution,md.settings.io_gather,md.debug.valgrind,md.debug.gprof,md.qmu.isdakota); // queue file
    117 
    118                 //Stop here if batch mode
    119                 if (options.getfieldvalue('batch','no') === 'yes'){
    120                         if (md.verbose.solution){
    121                                 console.log('batch mode requested: not launching job interactively');
    122                                 console.log('launch solution sequence on remote cluster by hand');
    123                         }
    124                         return;
    125                 }
    126 
    127                 //Upload all required files
    128                 modelname = md.miscellaneous.name;
    129                 filelist  = [modelname + '.bin ',modelname + '.toolkits '];
    130                 if (ispc){
    131                         filelist.push(modelname + '.bat ');
    132                 }
    133                 else{
    134                         filelist.push(modelname + '.queue ');
    135                 }
    136 
    137                 if (md.qmu.isdakota){
    138                         filelist.push(modelname + '.qmu.in');
    139                 }
    140 
    141                 if (restart == ''){
    142                         cluster.UploadQueueJob(md.miscellaneous.name,md.priv.runtimename,filelist);
    143                 }
    144 
    145                 //launch queue job:
    146                 cluster.LaunchQueueJob(md.miscellaneous.name,md.priv.runtimename,filelist,restart);
    147 
    148                 //wait on lock
    149                 if (md.settings.waitonlock == 'NaN'){
    150                         //load when user enters 'y'
    151                         console.log('solution launched on remote cluster. log in to detect job completion.');
    152                         throw Error("solve error message: user detection of successfull completion of job not support yet!");
    153                         /*choice=input('Is the job successfully completed? (y/n)','s');
    154                           if ~strcmp(choice,'y'),
    155                           console.log('Results not loaded... exiting');
    156                           else
    157                           md=loadresultsfromcluster(md);
    158                           end*/
    159                 }
    160                 else if (md.settings.waitonlock>0){
    161                         //we wait for the done file
    162                         done=waitonlock(md);
    163                         if (md.verbose.solution){
    164                                 console.log('loading results from cluster');
    165                         }
    166                         loadresultsfromcluster(md);
    167                 }
    168                 else if (md.settings.waitonlock==0){
    169                         console.log('Model results must be loaded manually with md=loadresultsfromcluster(md);');
    170                 }
    171 
    172                 //post processes qmu results if necessary
    173                 if (md.qmu.isdakota){
    174                         /*if ~strncmpi(options.getfieldvalue('keep','y'),'y',1)
    175                           system(['rm -rf qmu' num2str(feature('GetPid'))]);
    176                           end*/
    177                 }
    178         } //}}}
    179         else{ //if (cluster.classname() == 'local')
     104        if (cluster.classname() == 'local'){  //{{{
    180105
    181106                /*We are running locally on the machine, using the issm module:*/
     
    189114                       
    190115                //Load results:
    191                 var results = loadresultsfrombuffer(md,outputbuffer,outputbuffersize); //loadresults: [array,solution_type]
     116                md.results = loadresultsfrombuffer(md,outputbuffer,outputbuffersize);
     117               
     118                return md;
    192119
    193                 return results;
     120        } //}}}
     121        else { //{{{
    194122
    195         }
     123                /*We are running somewhere else on a computational server. Send the buffer to that server and retrieve output: */
     124                cluster.UploadAndRun(fid,toolkitsstring,solutionstring,md.miscellaneous.name);
     125
     126                return md;
     127
     128        } //}}}
    196129}
Note: See TracChangeset for help on using the changeset viewer.