Changeset 804


Ignore:
Timestamp:
06/04/09 18:08:18 (16 years ago)
Author:
Eric.Larour
Message:

Stabilized dakota pluging in core dakota solution

Location:
issm/trunk/src
Files:
2 deleted
14 edited

Legend:

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

    r688 r804  
    6666                /*Call echo on object: */
    6767                (*object)->Echo();
     68
     69        }
     70        return;
     71}
     72
     73#undef __FUNCT__
     74#define  __FUNCT__ "DataSet::DeepEcho"
     75
     76void DataSet::DeepEcho(){
     77
     78       
     79        vector<Object*>::iterator object;
     80
     81        if(this==NULL)throw ErrorException(__FUNCT__," trying to echo a NULL dataset");
     82
     83        _printf_("DataSet echo: %i objects\n",objects.size());
     84
     85        for ( object=objects.begin() ; object < objects.end(); object++ ){
     86
     87                /*Call deep echo on object: */
     88                (*object)->DeepEcho();
    6889
    6990        }
  • issm/trunk/src/c/DataSet/DataSet.h

    r659 r804  
    3737                int   GetEnum();
    3838                void  Echo();
     39                void  DeepEcho();
    3940                char* Marshall();
    4041                int   MarshallSize();
  • issm/trunk/src/c/parallel/DakotaResponses.cpp

    r659 r804  
    182182                        if(my_rank==0)responses[i]=max_abs_vz;
    183183                }
    184                 else throw ErrorException(__FUNCT__,exprintf("%s%s%s"," response descriptor : ",response_descriptor," not supported yet!"));
     184                else{
     185                        if(my_rank==0)printf("%s%s%s"," response descriptor : ",response_descriptor," not supported yet!");
     186                        throw ErrorException(__FUNCT__,exprintf("%s%s%s"," response descriptor : ",response_descriptor," not supported yet!"));
     187                }
    185188        }
    186189
  • issm/trunk/src/c/parallel/SpawnCore.cpp

    r765 r804  
    1919#include "../include/macros.h"
    2020
    21 void SpawnCore(double* responses, double* variables, char** variables_descriptors,int numvariables, FemModel* femmodels,ParameterInputs* inputs,int analysis_type,int sub_analysis_type){
     21void SpawnCore(double* responses, double* variables, char** variables_descriptors,int numvariables, FemModel* femmodels,ParameterInputs* inputs,int analysis_type,int sub_analysis_type,int counter){
    2222
    2323        int i;
     
    3333        double* qmu_part=NULL;
    3434        int     qmu_npart;
     35        int     debug=0;
    3536
    3637        extern int my_rank;
     
    3940        /*synchronize all cpus, as CPU 0 is probably late (it is starting the entire dakota strategy!) : */
    4041        MPI_Barrier(MPI_COMM_WORLD);
    41 
     42       
     43        /*some parameters needed: */
     44        femmodels[0].parameters->FindParam((void*)&debug,"debug");
     45               
    4246        /*First off, recover the response descriptors for the response functions: */
    4347        param=(Param*)femmodels[0].parameters->FindParamObject("responsedescriptors");
     
    9296
    9397
    94         _printf_("initialize results:\n");
     98
     99        if(debug)_printf_("Iteration: %i\n",counter);
     100
     101        //initialize results:
    95102        results=new DataSet(ResultsEnum());
    96103
    97104        /*Modify core inputs to reflect the dakota variables inputs: */
    98105        inputs->UpdateFromDakota(variables,variables_descriptors,numvariables,femmodels[0].parameters,qmu_part,qmu_npart); //femmodel #0 is the one holding the parameters for Dakota.
    99        
    100106
    101107        /*Run the analysis core solution sequence, with the updated inputs: */
    102108        if(analysis_type==DiagnosticAnalysisEnum()){
    103109                       
    104                 _printf_("Starting diagnostic core\n");
     110                if(debug)_printf_("Starting diagnostic core\n");
     111
    105112                diagnostic_core(results,femmodels,inputs);
    106113
     
    108115        else if(analysis_type==ThermalAnalysisEnum()){
    109116               
    110                 _printf_("Starting thermal core\n");
     117                if(debug)_printf_("Starting thermal core\n");
    111118                thermal_core(results,femmodels,inputs);
    112119
     
    114121        else if(analysis_type==PrognosticAnalysisEnum()){
    115122
    116                 _printf_("Starting prognostic core\n");
     123                if(debug)_printf_("Starting prognostic core\n");
    117124                prognostic_core(results,femmodels,inputs);
    118125
     
    120127        else if(analysis_type==TransientAnalysisEnum()){
    121128
    122                 _printf_("Starting transient core\n");
     129                if(debug)_printf_("Starting transient core\n");
    123130                throw ErrorException(__FUNCT__,"not supported yet!");
    124131
     
    129136
    130137        /*Now process the outputs, before computing the dakota responses: */
    131         _printf_("process results:\n");
     138        if(debug)_printf_("process results:\n");
    132139        ProcessResults(&results,femmodels,analysis_type);
    133140       
    134141
    135142        /*compute responses on cpu 0: dummy for now! */
    136         _printf_("compute dakota responses:\n");
     143        if(debug)_printf_("compute dakota responses:\n");
    137144        DakotaResponses(responses,responses_descriptors,numresponses,femmodels,results,analysis_type,sub_analysis_type);
    138145
  • issm/trunk/src/c/parallel/diagnostic.cpp

    r732 r804  
    103103                /*run qmu analysis: */
    104104                _printf_("calling qmu analysis on diagnostic core:\n");
    105        
     105
    106106                #ifdef _HAVE_DAKOTA_
    107107                qmu(qmuinname,qmuoutname,qmuerrname,&femmodels[0],inputs,DiagnosticAnalysisEnum(),NoneAnalysisEnum());
  • issm/trunk/src/c/parallel/parallel.h

    r667 r804  
    3939//int BatchDebug(Mat* Kgg,Vec* pg,FemModel* femmodel,char* filename);
    4040void qmu(const char* dakota_input_file,const char* dakota_output_file,const char* dakota_error_file,FemModel* femmodels,ParameterInputs* inputs,int analysis_type,int sub_analysis_type);
    41 void SpawnCore(double* responses,double* variables,char** variable_descriptors,int numvariables, FemModel* femmodels,ParameterInputs* inputs,int analysis_type,int sub_analysis_type);
     41void SpawnCore(double* responses,double* variables,char** variable_descriptors,int numvariables, FemModel* femmodels,ParameterInputs* inputs,int analysis_type,int sub_analysis_type,int counter);
    4242void DakotaResponses(double* responses,char** responses_descriptors,int numresponses,FemModel* femmodels, DataSet* results,int analysis_type,int sub_analysis_type);
    4343void ProcessResults(DataSet** presults,FemModel* fems,int analysis_type);
  • issm/trunk/src/c/parallel/qmu.cpp

    r662 r804  
    4646                problem_db.manage_inputs(dakota_input_file);
    4747                // specify_outputs_restart() is only necessary if specifying non-defaults
    48                 parallel_lib.specify_outputs_restart(dakota_output_file,dakota_error_file,NULL, NULL);
     48                parallel_lib.specify_outputs_restart(dakota_output_file,dakota_error_file,NULL,NULL);
    4949
    5050                // Instantiate the Strategy object (which instantiates all Model and
     
    7979                for(;;){
    8080
    81                         SpawnCore(NULL,NULL,NULL,0,femmodels,inputs,analysis_type,sub_analysis_type);
     81                        SpawnCore(NULL,NULL,NULL,0,femmodels,inputs,analysis_type,sub_analysis_type,0);
    8282
    8383                        //Figure out if cpu 0 is done iterating
  • issm/trunk/src/m/classes/@model/model.m

    r765 r804  
    262262        md.qmu_method=struct();
    263263        md.qmu_params=struct();
     264        md.dakotaplugin=0;
    264265        md.dakotaresults=struct();
    265266        md.dakotain='';
     
    267268        md.dakotadat='';
    268269        md.qmu_analysis=0;
    269         md.iresp=1;
    270         md.ivar=1;
    271270        md.npart=0;
    272271
  • issm/trunk/src/m/classes/public/LaunchQueueJobGeneric.m

    r659 r804  
    2121if strcmpi(hostname,md.cluster),
    2222        if md.qmu_analysis,
    23                 system(['cp ' md.name '.bin' ' ' md.name '.queue qmu/' md.name '.qmu.in ' ' ' executionpath]);
     23                system(['cp ' md.name '.bin' ' ' md.name '.queue ' md.name '.qmu.in ' ' ' executionpath]);
    2424        else
    2525                system(['cp ' md.name '.bin' ' ' md.name '.queue' ' ' executionpath]);
     
    2727else
    2828        if md.qmu_analysis,
    29                 system(['scp ' md.name '.bin' ' ' md.name '.queue qmu/' md.name '.qmu.in ' ' ' md.cluster ':' executionpath]);
     29                system(['scp ' md.name '.bin' ' ' md.name '.queue ' md.name '.qmu.in ' ' ' md.cluster ':' executionpath]);
    3030        else
    3131                system(['scp ' md.name '.bin' ' ' md.name '.queue' ' ' md.cluster ':' executionpath]);
  • issm/trunk/src/m/classes/public/displayqmu.m

    r765 r804  
    8585if isempty(md.dakotadat), disp(sprintf('         dakotadat: N/A')); else disp(sprintf('         dakotadat:    [%ix%i]    (can be accessed by typing md.dakotadat)',size(md.dakotadat)));end
    8686disp(sprintf('         npart   : %i (number of partitions for semi-descrete qmu)',md.npart));
     87disp(sprintf('         dakotaplugin   : %i (are we running using the library mode for Dakota? defaults to 0',md.dakotaplugin));
  • issm/trunk/src/m/classes/public/ismodelselfconsistent.m

    r802 r804  
    6767        'tolx','np','eps_rel','exclusive','n','gridonbed','gridonsurface','elementonbed','elementonsurface','deltaH','DeltaH','timeacc','timedec'};
    6868for i=1:length(fields),
    69         if ~isempty(md.(fields{i})),
    70                 if any(isnan(md.(fields{i}))),
     69        if ~isempty(eval(['md.' fields{i}])),
     70                if any(isnan(eval(['md.' fields{i}]))),
    7171                        disp(['model ' md.name ' has an NaN value in field ' fields{i} '!']);
    7272                        bool=0; return;
     
    8080        'sparsity','lowmem','n','gridonbed','gridonsurface','elementonbed','elementonsurface','deltaH','DeltaH','timeacc','timedec'};
    8181for i=1:length(fields),
    82         if ~isempty(md.(fields{i})),
    83                 if any(md.(fields{i})<0),
     82        if ~isempty(eval(['md.' fields{i}])),
     83                if any((eval(['md.' fields{i}]))<0),
    8484                        disp(['model ' md.name ' has a <0 value in field ' fields{i} '!']);
    8585                        bool=0; return;
     
    9797        'sparsity','deltaH','DeltaH','timeacc','timedec'};
    9898for i=1:length(fields),
    99         if ~isempty(md.(fields{i})),
    100                 if any(md.(fields{i})==0),
     99        if ~isempty(eval(['md.' fields{i}])),
     100                if any((eval(['md.' fields{i}]))==0),
    101101                        disp(['model ' md.name ' has a =0 value in field ' fields{i} '!']);
    102102                        bool=0; return;
     
    108108fields={'elements','p','q','elementoniceshelf','n','elementonbed'};
    109109for i=1:size(fields,2),
    110         if (size(md.(fields{i}),1)~=md.numberofelements),
     110        if (size(eval(['md.' fields{i}]),1)~=md.numberofelements),
    111111                disp(['model ' md.name ' field ' fields{i} ' should be of size ' num2str(md.numberofelements) '!']);
    112112                bool=0; return;
     
    117117fields={'x','y','z','B','drag','gridondirichlet_diag','melting','accumulation','surface','thickness','bed','gridonbed','gridonsurface'};
    118118for i=1:length(fields),
    119         if length(md.(fields{i}))~=md.numberofgrids,
     119        if length(eval(['md.' fields{i}]))~=md.numberofgrids,
    120120                disp(['model ' md.name ' field ' fields{i} ' should be of size ' num2str(md.numberofgrids) '!']);
    121121                bool=0; return;
     
    157157
    158158%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  SOLUTION CHECKS  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     159%QMU
     160if md.dakotaplugin==1,
     161        if md.qmu_params.evaluation_concurrency~=1,
     162                disp(['concurrency should be set to 1 when running dakota in library mode']);
     163                bool=0;return;
     164        end
     165end
     166
     167
    159168
    160169%DIAGNOSTIC
     
    249258        fields={'dt','ndt'};
    250259        for i=1:length(fields),
    251                 if any(md.(fields{i})<0),
     260                if any((eval(['md.' fields{i}]))<0),
    252261                        disp(['model ' md.name ' has a <0 value in field ' fields{i} '!']);
    253262                        bool=0; return;
     
    320329        fields={'vx_obs','vy_obs'};
    321330        for i=1:length(fields),
    322                 if any(length(md.(fields{i}))~=md.numberofgrids),
     331                if any(length(eval(['md.' fields{i}]))~=md.numberofgrids),
    323332                        disp(['model ' md.name ' field ' fields{i} ' should be of size ' num2str(md.numberofgrids) '!']);
    324333                        bool=0; return;
     
    362371        fields={'sparsity'};
    363372        for i=1:length(fields),
    364                 if ~isempty(md.(fields{i})),
    365                         if any(isnan(md.(fields{i}))),
     373                if ~isempty(eval(['md.' fields{i}])),
     374                        if any(isnan(eval(['md.' fields{i}]))),
    366375                                disp(['model ' md.name ' has an NaN value in field ' fields{i} '!']);
    367376                                bool=0; return;
     
    373382        fields={'sparsity'};
    374383        for i=1:length(fields),
    375                 if ~isempty(md.(fields{i})),
    376                         if any(md.(fields{i})<0),
     384                if ~isempty(eval(['md.' fields{i}])),
     385                        if any((eval(['md.' fields{i}]))<0),
    377386                                disp(['model ' md.name ' has a <0 value in field ' fields{i} '!']);
    378387                                bool=0; return;
     
    384393        fields={'sparsity'};
    385394        for i=1:length(fields),
    386                 if ~isempty(md.(fields{i})),
    387                         if any(md.(fields{i})==0),
     395                if ~isempty(eval(['md.' fields{i}])),
     396                        if any((eval(['md.' fields{i}]))==0),
    388397                                disp(['model ' md.name ' has a =0 value in field ' fields{i} '!']);
    389398                                bool=0; return;
     
    435444                fields={'time','np'};
    436445                for i=1:length(fields),
    437                         if ~isempty(md.(fields{i})),
    438                                 if any(isnan(md.(fields{i}))),
     446                        if ~isempty(eval(['md.' fields{i}])),
     447                                if any(isnan(eval(['md.' fields{i}]))),
    439448                                        disp(['model ' md.name ' has an NaN value in field ' fields{i} '!']);
    440449                                        bool=0; return;
     
    446455                fields={'time','np'};
    447456                for i=1:length(fields),
    448                         if ~isempty(md.(fields{i})),
    449                                 if any(md.(fields{i})<0),
     457                        if ~isempty(eval(['md.' fields{i}])),
     458                                if any((eval(['md.' fields{i}]))<0),
    450459                                        disp(['model ' md.name ' has a <0 value in field ' fields{i} '!']);
    451460                                        bool=0; return;
     
    457466                fields={'time','np'};
    458467                for i=1:length(fields),
    459                         if ~isempty(md.(fields{i})),
    460                                 if any(md.(fields{i})==0),
     468                        if ~isempty(eval(['md.' fields{i}])),
     469                                if any((eval(['md.' fields{i}]))==0),
    461470                                        disp(['model ' md.name ' has a =0 value in field ' fields{i} '!']);
    462471                                        bool=0; return;
  • issm/trunk/src/m/classes/public/loadresultsfromcluster.m

    r672 r804  
    1717%Go pickup output file and logs on cluster
    1818if strcmpi(hostname,md.cluster),
    19         system(['cp ' executionpath '/' md.name '.*o* ./']); %get outlog, errlog and outbin files
     19        if md.qmu_analysis,
     20                system(['cp ' executionpath '/' md.name '.outlog ' executionpath '/' md.name '.errlog ' executionpath '/' md.name '.outbin ' executionpath '/' md.name '.qmu.err ' executionpath '/' md.name '.qmu.out ' executionpath '/dakota_tabular.dat ./']); %get outlog, errlog and outbin files
     21        else
     22                system(['cp ' executionpath '/' md.name '.outlog ' executionpath '/' md.name '.errlog ' executionpath '/' md.name '.outbin ./']); %get outlog, errlog and outbin files
     23        end
    2024else
    21         system(['scp ' md.cluster ':' executionpath '/' md.name '.*o* ./']); %get outlog, errlog and outbin files
     25        if md.qmu_analysis,
     26                system(['scp ' md.cluster ':' executionpath '/' md.name '.outlog ' executionpath '/' md.name '.errlog ' executionpath '/' md.name '.outbin ' executionpath '/' md.name '.qmu.err ' executionpath '/' md.name '.qmu.out ' executionpath '/dakota_tabular.dat ./']); %get outlog, errlog and outbin files
     27        else
     28                system(['scp ' md.cluster ':' executionpath '/' md.name '.outlog ' executionpath '/' md.name '.errlog ' executionpath '/' md.name '.outbin ./']); %get outlog, errlog and outbin files
     29        end
    2230end
    2331
  • issm/trunk/src/m/classes/public/loadresultsfromdisk.m

    r771 r804  
    1212
    1313%load result onto model
    14 if isnan(md.results), md.results=struct(); end
     14if ~isstruct(md.results),
     15        if isnan(md.results), md.results=struct(); end
     16end
    1517eval(['md.results.' md.analysis_type '=parseresultsfromdisk(filename);']);
    1618
    17 %Check result is consistent
    18 disp(sprintf('%s\n','checking result consistency'));
    19 if ~isresultconsistent(md,md.analysis_type),
    20         %it would be very cruel to put an error, it would kill the computed results (even if not consistent...)
    21         disp('!! results not consistent correct the model !!')
     19%Check result is consistent, only if it exists
     20if ~isempty(md.results.diagnostic),
     21        disp(sprintf('%s\n','checking result consistency'));
     22        if ~isresultconsistent(md,md.analysis_type),
     23                %it would be very cruel to put an error, it would kill the computed results (even if not consistent...)
     24                disp('!! results not consistent correct the model !!')
     25        end
    2226end
     27
     28%deal with qmu results
     29if md.qmu_analysis,
     30        md=qmuoutput(md,md.name,'qmu');
     31end
  • issm/trunk/src/m/classes/public/marshall.m

    r765 r804  
    156156end
    157157
    158 %Qmu
     158%Qmu: the rest will be handle by qmumarshall
    159159WriteData(fid,md.qmu_analysis,'Integer','qmu_analysis');
    160 if md.qmu_analysis,
    161         %recover variables for corresponding analysis
    162         variables=md.variables(md.ivar);
    163160
    164         %count how many variables we have
    165         numvariables=0;
    166         variable_fieldnames=fieldnames(variables);
    167         for i=1:length(variable_fieldnames),
    168                 field_name=variable_fieldnames{i};
    169                 fieldvariables=variables.(field_name);
    170                 numvariables=numvariables+numel(variables.(field_name));
    171         end
    172         %write number of variables to disk
    173         WriteData(fid,numvariables,'Integer','numberofvariables');
    174 
    175         %now, for each variable, write descriptor
    176         count=0;
    177         for i=1:length(variable_fieldnames),
    178                 field_name=variable_fieldnames{i};
    179                 fieldvariables=variables.(field_name);
    180                 for j=1:length(fieldvariables),
    181                         descriptor=fieldvariables(j).descriptor;
    182                         WriteData(fid,descriptor,'String',['variabledescriptor' num2str(count)]);
    183                         count=count+1;
    184                 end
    185         end
    186        
    187         %deal with responses
    188 
    189         %recover responses for corresponding analysis
    190         responses=md.responses(md.iresp);
    191 
    192         %count how many responses we have
    193         numresponses=0;
    194         response_fieldnames=fieldnames(responses);
    195         for i=1:length(response_fieldnames),
    196                 field_name=response_fieldnames{i};
    197                 fieldresponses=responses.(field_name);
    198                 numresponses=numresponses+numel(responses.(field_name));
    199         end
    200         %write number of responses to disk
    201         WriteData(fid,numresponses,'Integer','numberofresponses');
    202 
    203         %now, for each response, write descriptor
    204         count=0;
    205         for i=1:length(response_fieldnames),
    206                 field_name=response_fieldnames{i};
    207                 fieldresponses=responses.(field_name);
    208                 for j=1:length(fieldresponses),
    209                         descriptor=fieldresponses(j).descriptor;
    210                         WriteData(fid,descriptor,'String',['responsedescriptor' num2str(count)]);
    211                         count=count+1;
    212                 end
    213         end
    214        
    215        
    216         %write npart to disk
    217         WriteData(fid,md.npart,'Integer','npart');
    218 end
    219        
    220161%Get penalties to connect collapsed and non-collapsed 3d meshes:
    221162if strcmpi(md.type,'3d'),
Note: See TracChangeset for help on using the changeset viewer.