Changeset 2048


Ignore:
Timestamp:
08/28/09 14:43:25 (16 years ago)
Author:
Eric.Larour
Message:

bug fix: qmu solution would loop forever

Location:
issm/trunk/src/c
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/Qmux/Qmux.cpp

    r1881 r2048  
    125125               
    126126                #ifdef _PARALLEL_
    127                 //Warn other cpus that we are done running the dakota iterator
    128                 MPI_Bcast(&status,1,MPI_INT,0,MPI_COMM_WORLD);
     127                //Warn other cpus that we are done running the dakota iterator, by setting the counter to -1:
     128                SpawnCore(NULL,0, NULL,NULL,0,model,inputs,analysis_type,sub_analysis_type,-1);
    129129                #endif
     130
    130131        #ifdef _PARALLEL_
    131132        }
     
    133134
    134135                for(;;){
    135 
    136                         SpawnCore(NULL,0, NULL,NULL,0,model,inputs,analysis_type,sub_analysis_type,0);
    137 
    138                         //Figure out if cpu 0 is done iterating
    139                         MPI_Bcast(&status,1,MPI_INT,0,MPI_COMM_WORLD);
    140 
    141                         //yes!
    142                         if(status){
    143                                 break; //yes, we are done
    144                         }
    145                         else{
    146                                 /*We are not done: */
    147 
    148 
    149                         }
     136                        if(!SpawnCore(NULL,0, NULL,NULL,0,model,inputs,analysis_type,sub_analysis_type,0))break; //counter came in at -1 on cpu0, bail out.
    150137                }
    151 
    152                        
    153138        }
    154139        #endif
  • issm/trunk/src/c/Qmux/Qmux.h

    r1842 r2048  
    99
    1010/* local prototypes: */
    11 void SpawnCore(double* responses, int numresponses, double* variables, char** variables_descriptors,int numvariables, void* model,void* inputs,int analysis_type,int sub_analysis_type,int counter);
     11int SpawnCore(double* responses, int numresponses, double* variables, char** variables_descriptors,int numvariables, void* model,void* inputs,int analysis_type,int sub_analysis_type,int counter);
    1212#ifdef _SERIAL_
    1313void Qmux(mxArray* model,mxArray* inputs,int analysis_type,int sub_analysis_type,char* dakota_input_file,char* dakota_output_file,char* dakota_error_file);
  • issm/trunk/src/c/Qmux/SpawnCore.cpp

    r1842 r2048  
    1919#include "../include/macros.h"
    2020
    21 void SpawnCore(double* responses, int numresponses, double* variables, char** variables_descriptors,int numvariables, void* model,void* inputs,int analysis_type,int sub_analysis_type,int counter){
    22 
     21int SpawnCore(double* responses, int numresponses, double* variables, char** variables_descriptors,int numvariables, void* model,void* inputs,int analysis_type,int sub_analysis_type,int counter){
    2322
    2423        /*Branch into a serial SpawnCore and a parallel SpawnCore: */
     
    2625        SpawnCoreSerial(responses, numresponses, variables, variables_descriptors,numvariables, (mxArray*)model, (mxArray*)inputs,analysis_type,sub_analysis_type,counter);
    2726        #else
     27        /*Call SpawnCoreParallel unless counter=-1 on cpu0, in which case, bail out and return 0: */
     28        MPI_Bcast(&counter,1,MPI_INT,0,MPI_COMM_WORLD); if(counter==-1)return 0;
     29       
    2830        SpawnCoreParallel(responses, numresponses, variables, variables_descriptors,numvariables, (Model*)model, (ParameterInputs*)inputs,analysis_type,sub_analysis_type,counter);
    2931        #endif
    3032
    31 
     33        return 1;
    3234}
  • issm/trunk/src/c/objects/DakotaPlugin.cpp

    r1843 r2048  
    5959int DakotaPlugin::derived_map_ac(const Dakota::String& driver) {
    6060
    61         int status=0;
    6261        int i;
    6362        double* variables=NULL;
     
    9897        }
    9998
    100         #ifdef _PARALLEL_
    101         /*warn other cpus that we are done running this iteration: */
    102         MPI_Bcast(&status,1,MPI_INT,0,MPI_COMM_WORLD);
    103         #endif
    10499
    105100        /*Free ressources:*/
  • issm/trunk/src/c/parallel/diagnostic.cpp

    r2020 r2048  
    117117                        control_core(results,model,inputs);
    118118                }
     119                if(!control_analysis){
     120                        /*Add analysis_type to results: */
     121                        result=new Result(results->Size()+1,0,1,"analysis_type","diagnostic");
     122                        results->AddObject(result);
     123                       
     124                        _printf_("process results:\n");
     125                        ProcessResults(&results,model,DiagnosticAnalysisEnum());
     126                }
     127                else{
     128                        /*Add analysis_type and control_type to results: */
     129                        result=new Result(results->Size()+1,0,1,"analysis_type","diagnostic");
     130                        results->AddObject(result);
     131                       
     132                        model->FindParam(&control_type,"control_type");
     133                        result=new Result(results->Size()+1,0,1,"control_type",control_type);
     134                        results->AddObject(result);
     135
     136                        _printf_("process results:\n");
     137                        ProcessResults(&results,model,ControlAnalysisEnum());
     138                }
     139
     140                _printf_("write results to disk:\n");
     141                OutputResults(results,outputfilename);
    119142        }
    120143        else{
     
    129152        }
    130153
    131         if(!control_analysis){
    132                 /*Add analysis_type to results: */
    133                 result=new Result(results->Size()+1,0,1,"analysis_type","diagnostic");
    134                 results->AddObject(result);
    135                
    136                 _printf_("process results:\n");
    137                 ProcessResults(&results,model,DiagnosticAnalysisEnum());
    138         }
    139         else{
    140                 /*Add analysis_type and control_type to results: */
    141                 result=new Result(results->Size()+1,0,1,"analysis_type","diagnostic");
    142                 results->AddObject(result);
    143                
    144                 model->FindParam(&control_type,"control_type");
    145                 result=new Result(results->Size()+1,0,1,"control_type",control_type);
    146                 results->AddObject(result);
    147 
    148                 _printf_("process results:\n");
    149                 ProcessResults(&results,model,ControlAnalysisEnum());
    150         }
    151 
    152         _printf_("write results to disk:\n");
    153         OutputResults(results,outputfilename);
    154 
    155154        _printf_("write lock file:\n");
    156155        if (waitonlock){
    157156                WriteLockFile(lockname);
    158157        }
    159                
     158
    160159        _printf_("closing MPI and Petsc\n");
    161160        PetscFinalize();
  • issm/trunk/src/c/parallel/steadystate.cpp

    r2033 r2048  
    135135                        control_core(results,model,inputs);
    136136                }
     137
     138                if(!control_analysis){
     139                        /*Add analysis_type to results: */
     140                        result=new Result(results->Size()+1,0,1,"analysis_type","steadystate");
     141                        results->AddObject(result);
     142
     143                        _printf_("process results:\n");
     144                        ProcessResults(&results,model,SteadystateAnalysisEnum());
     145                }
     146                else{
     147                        /*Add analysis_type and control_type to results: */
     148                        result=new Result(results->Size()+1,0,1,"analysis_type","steadystate");
     149                        results->AddObject(result);
     150
     151                        model->FindParam(&control_type,"control_type");
     152                        result=new Result(results->Size()+1,0,1,"control_type",control_type);
     153                        results->AddObject(result);
     154
     155                        _printf_("process results:\n");
     156                        ProcessResults(&results,model,ControlAnalysisEnum());
     157                }
     158
     159                _printf_("write results to disk:\n");
     160                OutputResults(results,outputfilename);
    137161        }
    138162        else{
     
    146170                #endif
    147171        }
    148 
    149         if(!control_analysis){
    150                 /*Add analysis_type to results: */
    151                 result=new Result(results->Size()+1,0,1,"analysis_type","steadystate");
    152                 results->AddObject(result);
    153 
    154                 _printf_("process results:\n");
    155                 ProcessResults(&results,model,SteadystateAnalysisEnum());
    156         }
    157         else{
    158                 /*Add analysis_type and control_type to results: */
    159                 result=new Result(results->Size()+1,0,1,"analysis_type","steadystate");
    160                 results->AddObject(result);
    161 
    162                 model->FindParam(&control_type,"control_type");
    163                 result=new Result(results->Size()+1,0,1,"control_type",control_type);
    164                 results->AddObject(result);
    165 
    166                 _printf_("process results:\n");
    167                 ProcessResults(&results,model,ControlAnalysisEnum());
    168         }
    169 
    170         _printf_("write results to disk:\n");
    171         OutputResults(results,outputfilename);
    172172
    173173        _printf_("write lock file:\n");
  • issm/trunk/src/c/parallel/thermal.cpp

    r2012 r2048  
    9999                thermal_core(results,model,inputs);
    100100
     101                /*Add analysis_type to results: */
     102                result=new Result(results->Size()+1,0,1,"analysis_type","thermal");
     103                results->AddObject(result);
     104                       
     105                _printf_("process results:\n");
     106                ProcessResults(&results,model,ThermalAnalysisEnum());
     107               
     108                _printf_("write results to disk:\n");
     109                OutputResults(results,outputfilename);
    101110        }
    102111        else{
     
    110119                #endif
    111120        }
    112 
    113         /*Add analysis_type to results: */
    114         result=new Result(results->Size()+1,0,1,"analysis_type","thermal");
    115         results->AddObject(result);
    116                
    117         _printf_("process results:\n");
    118         ProcessResults(&results,model,ThermalAnalysisEnum());
    119        
    120         _printf_("write results to disk:\n");
    121         OutputResults(results,outputfilename);
    122121
    123122        _printf_("write lock file:\n");
  • issm/trunk/src/c/parallel/transient.cpp

    r2014 r2048  
    124124                _printf_("call computational core:\n");
    125125                transient_core(results,model,inputs);
     126       
     127                /*Add analysis_type to results: */
     128                result=new Result(results->Size()+1,0,1,"analysis_type","transient");
     129                results->AddObject(result);
     130
     131                _printf_("process results:\n");
     132                ProcessResults(&results,model,TransientAnalysisEnum());
     133               
     134                _printf_("write results to disk:\n");
     135                OutputResults(results,outputfilename);
    126136        }
    127137        else{
     
    135145                #endif
    136146        }
    137 
    138         /*Add analysis_type to results: */
    139         result=new Result(results->Size()+1,0,1,"analysis_type","transient");
    140         results->AddObject(result);
    141 
    142         _printf_("process results:\n");
    143         ProcessResults(&results,model,TransientAnalysisEnum());
    144        
    145         _printf_("write results to disk:\n");
    146         OutputResults(results,outputfilename);
    147 
    148147        _printf_("write lock file:\n");
    149148        if (waitonlock){
Note: See TracChangeset for help on using the changeset viewer.