Changeset 28263


Ignore:
Timestamp:
05/08/24 17:42:24 (11 months ago)
Author:
Mathieu Morlighem
Message:

CHG: do not error out if output is not found

Location:
issm/trunk-jpl/src/c
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/classes/Cfdragcoeffabsgrad.h

    r27897 r28263  
    99#include "./Definition.h"
    1010#include "./FemModel.h"
    11 
    12 IssmDouble OutputDefinitionsResponsex(FemModel* femmodel,int output_enum);
    1311
    1412class Cfdragcoeffabsgrad: public Object, public Definition{
  • issm/trunk-jpl/src/c/classes/Cfdragcoeffabsgradtransient.h

    r27902 r28263  
    99#include "./Definition.h"
    1010class FemModel;
    11 
    12 IssmDouble OutputDefinitionsResponsex(FemModel* femmodel,int output_enum);
    1311
    1412class Cfdragcoeffabsgradtransient: public Object, public Definition{
  • issm/trunk-jpl/src/c/classes/Cflevelsetmisfit.h

    r27728 r28263  
    99#include "./Definition.h"
    1010#include "./FemModel.h"
    11 
    12 IssmDouble OutputDefinitionsResponsex(FemModel* femmodel,int output_enum);
    1311
    1412class Cflevelsetmisfit: public Object, public Definition{
  • issm/trunk-jpl/src/c/classes/Cfrheologybbarabsgrad.h

    r27920 r28263  
    99#include "./Definition.h"
    1010#include "./FemModel.h"
    11 
    12 IssmDouble OutputDefinitionsResponsex(FemModel* femmodel,int output_enum);
    13 void  GetVectorFromInputsx( IssmDouble** pvector, int* pvector_size, FemModel* femmodel,int name);
    1411
    1512class Cfrheologybbarabsgrad: public Object, public Definition{
  • issm/trunk-jpl/src/c/classes/Cfrheologybbarabsgradtransient.h

    r27920 r28263  
    99#include "./Definition.h"
    1010class FemModel;
    11 
    12 IssmDouble OutputDefinitionsResponsex(FemModel* femmodel,int output_enum);
    1311
    1412class Cfrheologybbarabsgradtransient: public Object, public Definition{
  • issm/trunk-jpl/src/c/classes/Cfsurfacelogvel.h

    r27728 r28263  
    99#include "./Definition.h"
    1010#include "./FemModel.h"
    11 
    12 IssmDouble OutputDefinitionsResponsex(FemModel* femmodel,int output_enum);
    1311
    1412class Cfsurfacelogvel: public Object, public Definition{
  • issm/trunk-jpl/src/c/classes/Cfsurfacesquare.h

    r27728 r28263  
    99#include "./Definition.h"
    1010#include "./FemModel.h"
    11 
    12 IssmDouble OutputDefinitionsResponsex(FemModel* femmodel,int output_enum);
    1311
    1412class Cfsurfacesquare: public Object, public Definition{
  • issm/trunk-jpl/src/c/classes/Cfsurfacesquaretransient.h

    r27721 r28263  
    99#include "./Definition.h"
    1010class FemModel;
    11 
    12 IssmDouble OutputDefinitionsResponsex(FemModel* femmodel,int output_enum);
    1311
    1412class Cfsurfacesquaretransient: public Object, public Definition{
  • issm/trunk-jpl/src/c/classes/DependentObject.cpp

    r27728 r28263  
    7272void  DependentObject::RecordResponsex(FemModel* femmodel){/*{{{*/
    7373
     74        int ierr;
     75
    7476        /*Is this some special type of response for which we need to go in the output definitions? :*/
    75         if (StringToEnumx(this->name,false)==-1){
    76                 this->response_value = OutputDefinitionsResponsex(femmodel,this->name);
     77        if(StringToEnumx(this->name,false)==-1){
     78                ierr = this->response_value = OutputDefinitionsResponsex(&this->response_value, femmodel, this->name);
     79                if(ierr) _error_("Could not find response "<<this->name);
    7780        }
    7881        else{
  • issm/trunk-jpl/src/c/classes/FemModel.cpp

    r28094 r28263  
    23982398        /*Intermediaries*/
    23992399        bool        isvec,results_on_nodes;
    2400         int         step,output_enum,numonnodes;
     2400        int         step,output_enum,numonnodes,ierr;
    24012401        IssmDouble  time;
    24022402        IssmDouble  double_result;
     
    24222422                /*If string is not an enum, it is defined in output definitions*/
    24232423                if(output_enum<0){
    2424                         double_result = OutputDefinitionsResponsex(this,output_string);
     2424                        ierr = OutputDefinitionsResponsex(&double_result, this,output_string);
    24252425                        if(save_results){
    2426                                 results->AddResult(new GenericExternalResult<IssmPDouble>(results->Size()+1,output_string,reCast<IssmPDouble>(double_result),step,time));
     2426                                if(!ierr){
     2427                                        results->AddResult(new GenericExternalResult<IssmPDouble>(results->Size()+1,output_string,reCast<IssmPDouble>(double_result),step,time));
     2428                                }
    24272429                                continue;
    24282430                        }
     
    24312433                        /*last chance for the output definition, if the enum is one of Outputdefinition[1-10]Enum:*/
    24322434                        if(output_enum>=Outputdefinition1Enum && output_enum <=Outputdefinition100Enum){
    2433                                 double_result = OutputDefinitionsResponsex(this,output_enum);
     2435                                ierr = OutputDefinitionsResponsex(&double_result, this, output_enum);
    24342436                                if(save_results){
    2435                                         results->AddResult(new GenericExternalResult<IssmPDouble>(results->Size()+1,output_string,reCast<IssmPDouble>(double_result),step,time));
     2437                                        if(!ierr){
     2438                                                results->AddResult(new GenericExternalResult<IssmPDouble>(results->Size()+1,output_string,reCast<IssmPDouble>(double_result),step,time));
     2439                                        }
    24362440                                        continue;
    24372441                                }
     
    27572761                default:
    27582762                        if(response_descriptor_enum>=Outputdefinition1Enum && response_descriptor_enum <=Outputdefinition100Enum){
    2759                                 IssmDouble double_result = OutputDefinitionsResponsex(this,response_descriptor_enum);
    2760                                 *responses=double_result;
     2763                                int ierr = OutputDefinitionsResponsex(responses, this,response_descriptor_enum);
     2764                                if(ierr) _error_("could not evaluate response");
    27612765                        }
    27622766                        else _error_("response descriptor \"" << EnumToStringx(response_descriptor_enum) << "\" not supported yet!");
  • issm/trunk-jpl/src/c/classes/Massconaxpby.h

    r26469 r28263  
    1414#include "./FemModel.h"
    1515#include "../classes/Params/Parameters.h"
    16 IssmDouble OutputDefinitionsResponsex(FemModel* femmodel,const char* output_string);
     16int OutputDefinitionsResponsex(IssmDouble* pres, FemModel* femmodel,const char* output_string);
    1717/*}}}*/
    1818class Massconaxpby: public Object, public Definition{
     
    108108                 IssmDouble Response(FemModel* femmodel){/*{{{*/
    109109
     110                         int ierr;
    110111                         IssmDouble xresponse,yresponse;
    111112
    112113                         /*Get response from both masscons: */
    113                          xresponse=OutputDefinitionsResponsex(femmodel,this->namex);
    114                          yresponse=OutputDefinitionsResponsex(femmodel,this->namey);
     114                         ierr=OutputDefinitionsResponsex(&xresponse,femmodel,this->namex);
     115                         if(ierr) _error_("not found");
     116                         ierr=OutputDefinitionsResponsex(&yresponse,femmodel,this->namey);
     117                         if(ierr) _error_("not found");
    115118
    116119                         return this->alpha*xresponse+this->beta*yresponse;
  • issm/trunk-jpl/src/c/classes/Misfit.cpp

    r27102 r28263  
    1919#include "./FemModel.h"
    2020#include "../modules/SurfaceAreax/SurfaceAreax.h"
     21#include "../modules/OutputDefinitionsResponsex/OutputDefinitionsResponsex.h"
     22#include "../modules/GetVectorFromInputsx/GetVectorFromInputsx.h"
    2123#include "../classes/Params/Parameters.h"
    2224#include "../classes/gauss/Gauss.h"
     
    226228
    227229                 IssmDouble model, observation;
     230                 int ierr;
    228231
    229232                 /*If we are locked, return time average: */
     
    231234
    232235                 /*First, the global  model response: */
    233                  model=OutputDefinitionsResponsex(femmodel,this->model_enum);
     236                 ierr = OutputDefinitionsResponsex(&model, femmodel, this->model_enum);
     237                 if(ierr) _error_("could not evaluate response");
     238
    234239                 /*Now, the observation is buried inside the elements, go fish it in the first element (cludgy, needs fixing): */
    235240                 Element* element = (Element*)femmodel->elements->GetObjectByOffset(0); _assert_(element);
  • issm/trunk-jpl/src/c/classes/Misfit.h

    r26469 r28263  
    99#include "./Definition.h"
    1010#include "./FemModel.h"
    11 
    12 IssmDouble OutputDefinitionsResponsex(FemModel* femmodel,int output_enum);
    13 void  GetVectorFromInputsx( IssmDouble** pvector, int* pvector_size, FemModel* femmodel,int name);
    1411
    1512class Misfit: public Object, public Definition{
  • issm/trunk-jpl/src/c/classes/Nodalvalue.h

    r27676 r28263  
    1313
    1414void NodalValuex( IssmDouble* pnodalvalue, int natureofdataenum,Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters);
    15 IssmDouble OutputDefinitionsResponsex(FemModel* femmodel,int output_enum);
    1615
    1716class Nodalvalue: public Object, public Definition{
  • issm/trunk-jpl/src/c/classes/Numberedcostfunction.h

    r26469 r28263  
    99#include "./Definition.h"
    1010#include "./FemModel.h"
    11 
    12 IssmDouble OutputDefinitionsResponsex(FemModel* femmodel,int output_enum);
    1311
    1412class Numberedcostfunction: public Object, public Definition{
  • issm/trunk-jpl/src/c/classes/Radar.h

    r26918 r28263  
    99#include "./Definition.h"
    1010#include "./FemModel.h"
    11 
    12 IssmDouble OutputDefinitionsResponsex(FemModel* femmodel,int output_enum);
    1311
    1412class Radar: public Object, public Definition{
  • issm/trunk-jpl/src/c/modules/OutputDefinitionsResponsex/OutputDefinitionsResponsex.cpp

    r25554 r28263  
    88#include "../../classes/classes.h"
    99
    10 IssmDouble OutputDefinitionsResponsex(FemModel* femmodel,const char* output_string){
     10int OutputDefinitionsResponsex(IssmDouble* presponse, FemModel* femmodel,const char* output_string){
    1111
    1212        /*Ok, go find the output definitions dataset in the parameters, where our responses are hiding: */
     
    2121
    2222                        /*This is the object that we have been chasing for. compute the response and return: */
    23                         IssmDouble return_value=definition->Response(femmodel);
     23                        *presponse = definition->Response(femmodel);
    2424
    25                         /*cleanup: */
     25                        /*cleanup and return*/
    2626                        xDelete<char>(name);
    27 
    28                         /*return:*/
    29                         return return_value;
     27                        return 0;
    3028                }
    3129                xDelete<char>(name);
     
    3331
    3432        /*If we are here, did not find the definition for this response, not good!: */
    35         _error_("Could not find the response for output definition " << output_string << " because could not find the definition itself!");
     33        _printf0_("=================================================================\n");
     34        _printf0_("WARNING: Could not find the output \"" << output_string << "\"\n");
     35        _printf0_("         - either this output is unavailable for this model run \n");
     36        _printf0_("         - or there may be a spelling error in your requested_outputs \n");
     37        _printf0_("         - or there may be a spelling error in an outputdefinition \n");
     38        _printf0_("           object name (unlikely)\n");
     39        _printf0_("=================================================================\n");
     40
     41        return 1;
    3642}
    3743
    38 IssmDouble OutputDefinitionsResponsex(FemModel* femmodel,int output_enum){
     44int OutputDefinitionsResponsex(IssmDouble* presponse, FemModel* femmodel,int output_enum){
    3945
    4046        /*Ok, go find the output definitions dataset in the parameters, where our responses are hiding: */
     
    4955
    5056                        /*This is the object that we have been chasing for. compute the response and return: */
    51                         IssmDouble return_value=definition->Response(femmodel);
    52 
    53                         /*return:*/
    54                         return return_value;
     57                        *presponse = definition->Response(femmodel);
     58                        return 0;
    5559                }
    5660        }
    5761
    5862        /*If we are here, did not find the definition for this response, not good!: */
    59         _error_("Could not find the response for output definition " << EnumToStringx(output_enum)
    60                                 <<" ("<<output_enum<<")"
    61                                 << " because could not find the definition itself!");
     63        _printf0_("=================================================================\n");
     64        _printf0_("WARNING: Could not find the output \"" << EnumToStringx(output_enum)<< "\"\n");
     65        _printf0_("         - either this output is unavailable for this model run \n");
     66        _printf0_("         - or there may be a spelling error in your requested_outputs \n");
     67        _printf0_("         - or there may be a spelling error in an outputdefinition \n");
     68        _printf0_("           object name (unlikely)\n");
     69        _printf0_("=================================================================\n");
     70
     71        return 1;
    6272}
  • issm/trunk-jpl/src/c/modules/OutputDefinitionsResponsex/OutputDefinitionsResponsex.h

    r18878 r28263  
    88
    99/* local prototypes: */
    10 IssmDouble OutputDefinitionsResponsex(FemModel* femmodel,const char* output_string);
    11 IssmDouble OutputDefinitionsResponsex(FemModel* femmodel,int output_enum);
     10int OutputDefinitionsResponsex(IssmDouble* presponse, FemModel* femmodel,const char* output_string);
     11int OutputDefinitionsResponsex(IssmDouble* presponse, FemModel* femmodel,int output_enum);
    1212
    1313#endif  /* _OUTPUTDEFINITIONSRESPONSEXX_H */
Note: See TracChangeset for help on using the changeset viewer.