Changeset 27696


Ignore:
Timestamp:
04/20/23 11:09:20 (2 years ago)
Author:
youngmc3
Message:

CHG: added sigma_max parameter (calvingvonmisesAD) inversion

Location:
issm/trunk-jpl/src/c
Files:
2 added
33 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/Makefile.am

    r27686 r27696  
    130130        ./classes/Params/Parameters.cpp \
    131131        ./classes/Params/BoolParam.cpp \
     132        ./classes/Params/ControlParam.cpp \
    132133        ./classes/Params/IntParam.cpp \
    133134        ./classes/Params/IntVecParam.cpp \
  • issm/trunk-jpl/src/c/classes/IoModel.cpp

    r27668 r27696  
    10221022}
    10231023/*}}}*/
     1024void  IoModel::FetchData(IssmDouble** pscalar, const char* data_name){/*{{{*/
     1025
     1026   /*output: */
     1027   IssmPDouble *scalar = NULL;
     1028   int          code   = 0;
     1029
     1030   /*recover my_rank:*/
     1031   int my_rank=IssmComm::GetRank();
     1032
     1033   /*Set file pointer to beginning of the data: */
     1034   fid=this->SetFilePointerToData(&code,NULL,data_name);
     1035   if(code!=3)_error_("expecting a IssmDouble for \""<<data_name<<"\"");
     1036
     1037   /*Now fetch: */
     1038
     1039   /*We have to read a matrix from disk. First read the dimensions of the matrix, then the whole matrix: */
     1040
     1041   /*Now allocate matrix: */
     1042   /*Read matrix on node 0, then broadcast: */
     1043   scalar=xNew<IssmPDouble>(1);
     1044   if(my_rank==0) if(fread(scalar,sizeof(IssmPDouble),1,fid)!=1) _error_("could not read matrix ");
     1045   ISSM_MPI_Bcast(scalar,1,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm());
     1046
     1047   _printf0_("scalar: " << *scalar << "\n");
     1048   *pscalar=xNew<IssmDouble>(1);
     1049   *pscalar[0]=scalar[0];
     1050   xDelete<IssmPDouble>(scalar);
     1051}
     1052/*}}}*/
    10241053void  IoModel::FetchData(char** pstring,const char* data_name){/*{{{*/
    10251054
     
    14251454        if(pM) *pM=M;
    14261455        if(pN) *pN=N;
     1456}
     1457/*}}}*/
     1458void  IoModel::FetchData(IssmPDouble** pscalar,const char* data_name){/*{{{*/
     1459
     1460   /*output: */
     1461   IssmPDouble   *scalar = NULL;
     1462   int      code;
     1463
     1464   /*recover my_rank:*/
     1465   int my_rank=IssmComm::GetRank();
     1466
     1467   /*Set file pointer to beginning of the data: */
     1468   fid=this->SetFilePointerToData(&code,NULL,data_name);
     1469
     1470   if(code!=3)_error_("expecting a IssmDouble for \""<<data_name<<"\"");
     1471
     1472   /*We have to read a scalar from disk. First read the dimensions of the scalar, then the scalar: */
     1473   scalar=xNew<IssmPDouble>(1);
     1474   if(my_rank==0){
     1475      if(fread(scalar,sizeof(IssmPDouble),1,fid)!=1)_error_("could not read scalar ");
     1476   }
     1477   ISSM_MPI_Bcast(scalar,1,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm());
     1478
     1479
     1480   /*Assign output pointers: */
     1481   *pscalar=scalar;
    14271482}
    14281483/*}}}*/
  • issm/trunk-jpl/src/c/classes/IoModel.h

    r27490 r27696  
    133133                void        FetchData(int* pinteger,const char* data_name);
    134134                void        FetchData(IssmDouble* pscalar,const char* data_name);
     135                void        FetchData(IssmDouble** pscalar, const char* data_name);     
    135136                void        FetchData(char** pstring,const char* data_name);
    136137                void        FetchData(char*** pstrings,int* pnumstrings,const char* data_name);
     
    140141#if _HAVE_AD_  && !defined(_WRAPPERS_)
    141142                void        FetchData(IssmPDouble**  pscalarmatrix,int* pM,int* pN,const char* data_name);
     143                void        FetchData(IssmPDouble** pscalar,const char* data_name);
    142144#endif
    143145                void        FetchData(IssmDouble*** pmatrixarray,int** pmdims,int** pndims, int* pnumrecords,const char* data_name);
  • issm/trunk-jpl/src/c/classes/Params/BoolParam.h

    r25508 r27696  
    4949                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
    5050                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
     51                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, const char* data){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
    5152                void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a matrix array");}
    5253                void  GetParameterValue(Vector<IssmDouble>** pvec){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Vec");}
     
    6263                void  SetValue(char* string){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string");}
    6364                void  SetValue(char** stringarray,int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string array");}
     65                void  SetValue(IssmDouble* IssmDoublearray){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
    6466                void  SetValue(IssmDouble* IssmDoublearray,int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
    6567                void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
     
    7072                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
    7173                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
     74                void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    7275                /*}}}*/
    7376};
  • issm/trunk-jpl/src/c/classes/Params/DataSetParam.h

    r25508 r27696  
    5151                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
    5252                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
     53                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, const char* data){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
    5354                void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error_("DataSet param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix array");}
    5455                void  GetParameterValue(Vector<IssmDouble>** pvec){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Vec");}
     
    6465                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a file pointer");}
    6566                void  SetValue(char** stringarray,int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string array");}
     67                void  SetValue(IssmDouble* IssmDoublearray){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
    6668                void  SetValue(IssmDouble* IssmDoublearray,int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
    6769                void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
     
    7274                void  SetValue(DataSet* dataset);
    7375                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("DataSet param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an array of matrices");}
     76                void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    7477                /*}}}*/
    7578};
  • issm/trunk-jpl/src/c/classes/Params/DoubleMatArrayParam.h

    r25508 r27696  
    5252                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error_("Param "<< EnumToStringx(enum_type) << "cannot return a IssmDouble array");}
    5353                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN){_error_("Param "<< EnumToStringx(enum_type) << "cannot return a IssmDouble array");}
     54                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, const char* data){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
    5455                void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims);
    5556                void  GetParameterValue(Vector<IssmDouble>** pvec){_error_("Param "<< EnumToStringx(enum_type) << "cannot return a Vec");}
     
    6566                void  SetValue(char* string){_error_("Param "<< EnumToStringx(enum_type) << "cannot hold a string");}
    6667                void  SetValue(char** stringarray,int M){_error_("Param "<< EnumToStringx(enum_type) << "cannot hold a string array");}
     68                void  SetValue(IssmDouble* IssmDoublearray){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
    6769                void  SetValue(IssmDouble* IssmDoublearray,int M){_error_("Param "<< EnumToStringx(enum_type) << "cannot hold a IssmDouble vec array");}
    6870                void  SetValue(IssmDouble* IssmDoublearray,int M,int N){_error_("Param "<< EnumToStringx(enum_type) << "cannot hold a IssmDouble mat array");}
     
    7375                void  SetValue(FILE* fid){_error_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
    7476                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array);
     77                void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    7578                /*}}}*/
    7679};
  • issm/trunk-jpl/src/c/classes/Params/DoubleMatParam.h

    r25508 r27696  
    5252                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
    5353                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM,int* pN);
     54                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, const char* data){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
    5455                void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a matrix array");}
    5556                void  GetParameterValue(Vector<IssmDouble>** pvec){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Vec");}
     
    6364                void  SetValue(char* string){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string");}
    6465                void  SetValue(char** stringarray,int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string array");}
     66                void  SetValue(IssmDouble* IssmDoublearray){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
    6567                void  SetValue(IssmDouble* IssmDoublearray,int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble vec array");}
    6668                void  SetValue(IssmDouble* IssmDoublearray,int M,int N);
     
    7274                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
    7375                void  SetEnum(int enum_in){this->enum_type = enum_in;};
     76                void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    7477                /*}}}*/
    7578                /*DoubleMatParam specific routines:{{{*/
  • issm/trunk-jpl/src/c/classes/Params/DoubleParam.h

    r25508 r27696  
    5050                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM);
    5151                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN);
     52                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, const char* data){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
    5253                void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a matrix array");}
    5354                void  GetParameterValue(Vector<IssmDouble>** pvec){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Vec");}
     
    6364                void  SetValue(char* string){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string");}
    6465                void  SetValue(char** stringarray,int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string array");}
     66                void  SetValue(IssmDouble* IssmDoublearray){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
    6567                void  SetValue(IssmDouble* IssmDoublearray,int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
    6668                void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
     
    7173                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
    7274                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
     75                void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    7376                /*}}}*/
    7477};
  • issm/trunk-jpl/src/c/classes/Params/DoubleVecParam.h

    r25508 r27696  
    5050                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM);
    5151                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN);
     52                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, const char* data){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
    5253                void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a matrix array");}
    5354                void  GetParameterValue(Vector<IssmDouble>** pvec){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Vec");}
     
    6364                void  SetValue(char* string){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string");}
    6465                void  SetValue(char** stringarray,int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string array");}
     66                void  SetValue(IssmDouble* IssmDoublearray){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
    6567                void  SetValue(IssmDouble* IssmDoublearray,int M);
    6668                void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble mat array");}
     
    7173                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
    7274                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
     75                void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    7376                /*}}}*/
    7477                /*DoubleVecParam specific routines:{{{*/
  • issm/trunk-jpl/src/c/classes/Params/FileParam.h

    r25508 r27696  
    4949                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
    5050                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
     51                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, const char* data){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
    5152                void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error_("File param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix array");}
    5253                void  GetParameterValue(Vector<IssmDouble>** pvec){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Vec");}
     
    6263                void  SetValue(char* string){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string");}
    6364                void  SetValue(char** stringarray,int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string array");}
     65                void  SetValue(IssmDouble* IssmDoublearray){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
    6466                void  SetValue(IssmDouble* IssmDoublearray,int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
    6567                void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
     
    7072                void  SetValue(FILE* fid){_error_("File param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
    7173                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("File param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an array of matrices");}
     74                void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    7275                /*}}}*/
    7376};
  • issm/trunk-jpl/src/c/classes/Params/GenericParam.h

    r25531 r27696  
    7777                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot return a IssmDouble array");}
    7878                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot return a IssmDouble array");}
     79                                         void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, const char* data){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot return a IssmDouble array");}
    7980                void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot return a matrix array");}
    8081                void  GetParameterValue(Vector<IssmDouble>** pvec){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot return a Vec");}
     
    9192                void  SetValue(char* string){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot hold a string");}
    9293                void  SetValue(char** stringarray,int M){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot hold a string array");}
     94                                         void  SetValue(IssmDouble* IssmDoublearray){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot hold a IssmDouble array");}
    9395                void  SetValue(IssmDouble* IssmDoublearray,int M){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot hold a IssmDouble array");}
    9496                void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot hold a IssmDouble array");}
     
    9799                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot hold a FILE");}
    98100                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot hold an array of matrices");}
     101                                         void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot hold an IssmDouble");};
    99102
    100103                /*}}}*/
  • issm/trunk-jpl/src/c/classes/Params/IntMatParam.h

    r25508 r27696  
    5151                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
    5252                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM,int* pN){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a matrix array");};
     53                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, const char* data){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
    5354                void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a matrix array");}
    5455                void  GetParameterValue(Vector<IssmDouble>** pvec){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Vec");}
     
    6465                void  SetValue(char* string){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string");}
    6566                void  SetValue(char** stringarray,int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string array");}
     67                void  SetValue(IssmDouble* IssmDoublearray){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
    6668                void  SetValue(IssmDouble* IssmDoublearray,int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble vec array");}
    6769                void  SetValue(IssmDouble* IssmDoublearray,int M,int N){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble vec array");};
     
    7274                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
    7375                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
     76                void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    7477                /*}}}*/
    7578};
  • issm/trunk-jpl/src/c/classes/Params/IntParam.h

    r25508 r27696  
    5050                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
    5151                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
     52                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, const char* data){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
    5253                void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a matrix array");}
    5354                void  GetParameterValue(Vector<IssmDouble>** pvec){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Vec");}
     
    6566                void  SetValue(char* string){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string");}
    6667                void  SetValue(char** stringarray,int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string array");}
     68                void  SetValue(IssmDouble* IssmDoublearray){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
    6769                void  SetValue(IssmDouble* IssmDoublearray,int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
    6870                void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
     
    7173                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
    7274                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
     75                void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    7376                /*}}}*/
    7477};
  • issm/trunk-jpl/src/c/classes/Params/IntVecParam.h

    r25508 r27696  
    5151                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array (maybe in serial?)");}
    5252                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
     53                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, const char* data){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
    5354                void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a matrix array");}
    5455                void  GetParameterValue(Vector<IssmDouble>** pvec){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Vec");}
     
    6465                void  SetValue(char* string){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string");}
    6566                void  SetValue(char** stringarray,int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string array");}
     67                void  SetValue(IssmDouble* IssmDoublearray){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
    6668                void  SetValue(IssmDouble* IssmDoublearray,int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble mat array");}
    6769                void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble mat array");}
     
    7274                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
    7375                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
     76                void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    7477                /*}}}*/
    7578};
  • issm/trunk-jpl/src/c/classes/Params/MatrixParam.h

    r25508 r27696  
    5050                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
    5151                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
     52                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, const char* data){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
    5253                void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a matrix array");}
    5354                void  GetParameterValue(Vector<IssmDouble>** pvec){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a vec");}
     
    6364                void  SetValue(char* string){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string");}
    6465                void  SetValue(char** stringarray,int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string array");}
     66                void  SetValue(IssmDouble* IssmDoublearray){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
    6567                void  SetValue(IssmDouble* IssmDoublearray,int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
    6668                void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
     
    7173                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
    7274                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
     75                void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    7376                /*}}}*/
    7477};
  • issm/trunk-jpl/src/c/classes/Params/Param.h

    r25508 r27696  
    3939                virtual void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM)=0;
    4040                virtual void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM,int* pN)=0;
     41                virtual void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, const char* data)=0;
    4142                virtual void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims)=0;
    4243                virtual void  GetParameterValue(Vector<IssmDouble>** pvec)=0;
     
    5657                virtual void  SetValue(DataSet* dataset){_error_("not implemented yet");};
    5758                virtual void  SetValue(IssmDouble* IssmDoublearray,int M)=0;
     59                virtual void  SetValue(IssmDouble* IssmDoublearray)=0;
    5860                virtual void  SetValue(IssmDouble* pIssmDoublearray,int M,int N)=0;
    5961                virtual void  SetValue(int* intarray,int M)=0;
     
    6365                virtual void  SetValue(FILE* fid)=0;
    6466                virtual void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array)=0;
     67                virtual void  SetGradient(IssmDouble* poutput, int M)=0;
    6568};
    6669#endif
  • issm/trunk-jpl/src/c/classes/Params/Parameters.cpp

    r27102 r27696  
    2020
    2121#include "./BoolParam.h"
     22#include "./ControlParam.h"
    2223#include "./DoubleMatParam.h"
    2324#include "./DataSetParam.h"
     
    232233                                this->AddObject(transarrayparam);
    233234                        }
     235                        else if(obj_enum==ControlParamEnum){
     236                                ControlParam* controlparam=NULL;
     237                                controlparam=new ControlParam();
     238                                controlparam->Marshall(marshallhandle);
     239                                this->AddObject(controlparam);
     240                        }
    234241                        else if(obj_enum==GenericParamEnum){
    235242                                /*Skip for now (we don't want to Marhsall Comms)*/
     
    417424        if(pM)   *pM   = n;
    418425}/*}}}*/
     426void Parameters::FindControlParam(IssmDouble** pvec,int* pM, int param_enum, const char* data){ _assert_(this);/*{{{*/
     427
     428        int index = EnumToIndex(param_enum);
     429
     430        /*Output*/
     431        int         n;
     432        IssmDouble* vector = NULL;
     433
     434        if(!this->params[index]) _error_("Parameter " << EnumToStringx(param_enum) <<" not set");
     435        this->params[index]->GetParameterValue(pvec,pM,data);
     436
     437}/*}}}*/
     438void Parameters::FindControlParamAndMakePassive(IssmPDouble** pvec,int* pM, int param_enum, const char* data){ _assert_(this);/*{{{*/
     439
     440        int index = EnumToIndex(param_enum);
     441
     442        /*Output*/
     443        int         n;
     444        IssmDouble* vector = NULL;
     445
     446        if(!this->params[index]) _error_("Parameter " << EnumToStringx(param_enum) <<" not set");
     447        this->params[index]->GetParameterValue(&vector,&n,data);
     448
     449        /*Make output passive*/
     450        #ifdef _HAVE_AD_
     451        IssmPDouble* output = xNew<IssmPDouble>(n);
     452        for(int i=0;i<n;i++) output[i] = reCast<IssmPDouble>(vector[i]);
     453        xDelete<IssmDouble>(vector);
     454        if(pvec) *pvec = output;
     455        #else
     456        if(pvec) *pvec = vector;
     457        #endif
     458
     459        /*assign output pointers*/
     460        if(pM)   *pM   = n;
     461}/*}}}*/
    419462void Parameters::FindParamInDataset(IssmDouble** pIssmDoublearray,int* pM,int* pN,int dataset_type,int enum_type){/*{{{*/
    420463        _assert_(this);
     
    524567}
    525568/*}}}*/
     569void   Parameters::SetParam(IssmDouble* IssmDoublearray, int enum_type){/*{{{*/
     570
     571        Param* param=NULL;
     572
     573        /*first, figure out if the param has already been created: */
     574        param=xDynamicCast<Param*>(this->FindParamObject(enum_type));
     575        if(param) param->SetValue(IssmDoublearray); //already exists, just set it.
     576        else _error_("Param "<< EnumToStringx(enum_type) << " cannot setValue");
     577
     578         //this->AddObject(new ControlParam(enum_type,IssmDoublearray,M,N)); //just add the new parameter.
     579}
     580/*}}}*/
    526581void   Parameters::SetParam(int* intarray,int M, int enum_type){/*{{{*/
    527582
     
    592647                this->AddObject(new DataSetParam(enum_type,dataset)); //just add the new parameter.
    593648        }
     649}
     650/*}}}*/
     651void   Parameters::SetControlParam(IssmDouble* IssmDoublearray,int M, int enum_type){/*{{{*/
     652
     653        Param* param=NULL;
     654
     655        /*first, figure out if the param has already been created: */
     656        param=xDynamicCast<Param*>(this->FindParamObject(enum_type));
     657
     658        if(param) param->SetValue(IssmDoublearray,M); //already exists, just set it.
     659        else _error_("Param "<< EnumToStringx(enum_type) << " cannot setValue");
     660}
     661/*}}}*/
     662void   Parameters::ControlParamSetGradient(IssmDouble* IssmDoublearray, int M, int enum_type){/*{{{*/
     663
     664        Param* param=NULL;
     665
     666        /*first, figure out if the param has already been created: */
     667        param=xDynamicCast<Param*>(this->FindParamObject(enum_type));
     668        if(param) param->SetGradient(IssmDoublearray,M); //already exists, just set it.
     669        else _error_("Param "<< EnumToStringx(enum_type) << " cannot setValue");
     670
     671         //this->AddObject(new ControlParam(enum_type,IssmDoublearray,M,N)); //just add the new parameter.
    594672}
    595673/*}}}*/
  • issm/trunk-jpl/src/c/classes/Params/Parameters.h

    r25508 r27696  
    5555                void  FindParamAndMakePassive(IssmPDouble* pscalar, int enum_type);
    5656                void  FindParamAndMakePassive(IssmPDouble** pvec,int* pM,int enum_type);
     57                void  FindControlParam(IssmDouble** pvec,int* pM, int param_enum, const char* data);
     58                void  FindControlParamAndMakePassive(IssmPDouble** pvec,int* pM, int param_enum, const char* data);
    5759                void  FindParamInDataset(IssmDouble** pIssmDoublearray,int* pM,int* pN,int dataset_type,int enum_type);
    5860                IssmDouble FindParam(int enum_type);
     
    6567                void  SetParam(IssmDouble* IssmDoublearray,int M,int enum_type);
    6668                void  SetParam(IssmDouble* IssmDoublearray,int M,int N,int enum_type);
     69                void  SetParam(IssmDouble* IssmDoublearray, int enum_type);
    6770                void  SetParam(int* intarray,int M,int enum_type);
    6871                void  SetParam(int* intarray,int M,int N,int enum_type);
     
    7174                void  SetParam(FILE* fid,int enum_type);
    7275                void  SetParam(DataSet* dataset,int enum_type);
    73 
     76                void  SetControlParam(IssmDouble* IssmDoublearray,int M, int enum_type);
     77                void  ControlParamSetGradient(IssmDouble* IssmDoublearray, int M, int enum_type);
    7478                Param* FindParamObject(int enum_type);
    7579
  • issm/trunk-jpl/src/c/classes/Params/StringArrayParam.h

    r25508 r27696  
    5050                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
    5151                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
     52                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, const char* data){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
    5253                void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error_("Vec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix array");}
    5354                void  GetParameterValue(Vector<IssmDouble>** pvec){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Vec");}
     
    6364                void  SetValue(char* string){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string");}
    6465                void  SetValue(char** stringarray,int M);
     66                void  SetValue(IssmDouble* IssmDoublearray){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
    6567                void  SetValue(IssmDouble* IssmDoublearray,int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
    6668                void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
     
    7173                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
    7274                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
     75                void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    7376                /*}}}*/
    7477};
  • issm/trunk-jpl/src/c/classes/Params/StringParam.h

    r25508 r27696  
    5050                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
    5151                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
     52                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, const char* data){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
    5253                void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a matrix array");}
    5354                void  GetParameterValue(Vector<IssmDouble>** pvec){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Vec");}
     
    6364                void  SetValue(char* string);
    6465                void  SetValue(char** stringarray,int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string array");}
     66                void  SetValue(IssmDouble* IssmDoublearray){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
    6567                void  SetValue(IssmDouble* IssmDoublearray,int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
    6668                void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
     
    7173                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
    7274                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
     75                void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    7376                /*}}}*/
    7477};
  • issm/trunk-jpl/src/c/classes/Params/TransientArrayParam.h

    r26196 r27696  
    5555                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
    5656                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM,int* pN){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
     57                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, const char* data){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
    5758                void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot return a matrix array");}
    5859                void  GetParameterValue(Vector<IssmDouble>** pvec){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot return a Vec");}
     
    6869                void  SetValue(char* string){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold a string");}
    6970                void  SetValue(char** stringarray,int M){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold a string array");}
     71                void  SetValue(IssmDouble* IssmDoublearray){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
    7072                void  SetValue(IssmDouble* IssmDoublearray,int M){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold a IssmDouble vec array");}
    7173                void  SetValue(IssmDouble* IssmDoublearray,int M,int N){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
     
    7678                void  SetValue(FILE* fid){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold a FILE");}
    7779                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold an array of matrices");}
     80                void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    7881                /*}}}*/
    7982};
  • issm/trunk-jpl/src/c/classes/Params/TransientParam.h

    r26196 r27696  
    5353                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
    5454                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM,int* pN){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
     55                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, const char* data){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
    5556                void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot return a matrix array");}
    5657                void  GetParameterValue(Vector<IssmDouble>** pvec){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot return a Vec");}
     
    6667                void  SetValue(char* string){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold a string");}
    6768                void  SetValue(char** stringarray,int M){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold a string array");}
     69                void  SetValue(IssmDouble* IssmDoublearray){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
    6870                void  SetValue(IssmDouble* IssmDoublearray,int M){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold a IssmDouble vec array");}
    6971                void  SetValue(IssmDouble* IssmDoublearray,int M,int N){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
     
    7476                void  SetValue(FILE* fid){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold a FILE");}
    7577                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold an array of matrices");}
     78                void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    7679                /*}}}*/
    7780};
  • issm/trunk-jpl/src/c/classes/Params/VectorParam.h

    r25508 r27696  
    5050                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
    5151                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
     52                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, const char* data){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}
    5253                void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a matrix array");}
    5354                void  GetParameterValue(Matrix<IssmDouble>** pmat){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Mat");}
     
    6364                void  SetValue(char* string){_error_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string");}
    6465                void  SetValue(char** stringarray,int M){_error_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string array");}
     66                void  SetValue(IssmDouble* IssmDoublearray){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}
    6567                void  SetValue(IssmDouble* IssmDoublearray,int M){_error_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
    6668                void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
     
    7173                void  SetValue(FILE* fid){_error_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
    7274                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
     75                void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    7376                /*}}}*/
    7477};
  • issm/trunk-jpl/src/c/classes/classes.h

    r27686 r27696  
    9090#include "./Params/GenericParam.h"
    9191#include "./Params/BoolParam.h"
     92#include "./Params/ControlParam.h"
    9293#include "./Params/DoubleMatParam.h"
    9394#include "./Params/DoubleTransientMatParam.h"
  • issm/trunk-jpl/src/c/cores/controladm1qn3_core.cpp

    r27666 r27696  
    234234        double  *XL = NULL;
    235235        double  *XU = NULL;
    236         GetPassiveVectorFromControlInputsx(&XL,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"lowerbound");
    237         GetPassiveVectorFromControlInputsx(&XU,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"upperbound");
     236        if(IsParamEnum(control_enum[0])){
     237                femmodel->parameters->FindControlParamAndMakePassive(&XL,NULL,control_enum[0],"lowerbound");
     238                femmodel->parameters->FindControlParamAndMakePassive(&XU,NULL,control_enum[0],"upperbound");
     239        }
     240        else{
     241                GetPassiveVectorFromControlInputsx(&XL,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"lowerbound");
     242                GetPassiveVectorFromControlInputsx(&XU,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"upperbound");
     243        }
    238244
    239245        int offset = 0;
     
    251257        #ifdef _HAVE_CODIPACK_
    252258        if(checkpoint_frequency && solution_type == TransientSolutionEnum){
    253                 SetControlInputsFromVectorx(femmodel,X);
     259                if(IsParamEnum(control_enum[0])){
     260#ifdef _HAVE_AD_
     261                        IssmDouble* aX=xNew<IssmDouble>(intn,"t");
     262#else
     263                        IssmDouble* aX=xNew<IssmDouble>(intn);
     264#endif
     265                        for(int i=0;i<intn;i++) {
     266                                aX[i]=X[i];
     267                        }
     268                        femmodel->parameters->SetControlParam(aX,M[0],control_enum[0]);
     269                }
     270                else{
     271                        SetControlInputsFromVectorx(femmodel,X);
     272                }
    254273                *pf = transient_ad(femmodel, G, &Jlist[(*Jlisti)*JlistN]);
    255274        }
     
    304323
    305324                ISSM_MPI_Bcast(aX,intn,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
    306                 SetControlInputsFromVectorx(femmodel,aX);
     325                if(IsParamEnum(control_enum[0])){
     326                        femmodel->parameters->SetControlParam(aX,M[0],control_enum[0]);
     327                }
     328                else{
     329                        SetControlInputsFromVectorx(femmodel,aX);
     330                }
    307331                xDelete<IssmDouble>(aX);
    308332
     
    574598
    575599        /*Get initial guess*/
    576         GetPassiveVectorFromControlInputsx(&X,&intn,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"value");
     600        if(IsParamEnum(control_enum[0])){
     601                femmodel->parameters->FindControlParamAndMakePassive(&X,NULL,control_enum[0],"value");
     602                intn=M[0];
     603        }
     604        else{
     605                GetPassiveVectorFromControlInputsx(&X,&intn,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"value");
     606        }
    577607
    578608        /*Get problem dimension and initialize gradient and initial guess*/
     
    632662        double  *XL = NULL;
    633663        double  *XU = NULL;
    634         GetPassiveVectorFromControlInputsx(&XL,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"lowerbound");
    635         GetPassiveVectorFromControlInputsx(&XU,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"upperbound");
     664        if(IsParamEnum(control_enum[0])){
     665                femmodel->parameters->FindControlParamAndMakePassive(&XL,NULL,control_enum[0],"lowerbound");
     666                femmodel->parameters->FindControlParamAndMakePassive(&XU,NULL,control_enum[0],"upperbound");
     667        }
     668        else{
     669                GetPassiveVectorFromControlInputsx(&XL,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"lowerbound");
     670                GetPassiveVectorFromControlInputsx(&XU,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"upperbound");
     671        }
    636672
    637673   offset = 0;
     
    654690                aG[i] = reCast<IssmDouble>(G[i]);
    655691        }
    656 
    657         ControlInputSetGradientx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,aG);
    658         SetControlInputsFromVectorx(femmodel,aX);
    659 
     692       
     693        if(IsParamEnum(control_enum[0])){
     694                //femmodel->parameters->ControlParamSetGradient(aG,M[0],control_enum[0]);
     695                femmodel->parameters->SetControlParam(aX,M[0],control_enum[0]);
     696        }
     697        else{
     698                ControlInputSetGradientx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,aG);
     699                SetControlInputsFromVectorx(femmodel,aX);
     700        }
    660701        xDelete(aX);
    661702
  • issm/trunk-jpl/src/c/cores/transient_core.cpp

    r27314 r27696  
    274274        int        step,timestepping;
    275275        int        checkpoint_frequency,num_responses;
     276        int              *M = NULL;
     277        int              *control_enum;
    276278
    277279        /*Get rank*/
     
    286288        femmodel->parameters->FindParam(&num_responses,InversionNumCostFunctionsEnum);
    287289        femmodel->parameters->FindParam(&checkpoint_frequency,SettingsCheckpointFrequencyEnum); _assert_(checkpoint_frequency>0);
     290        femmodel->parameters->FindParam(&control_enum,NULL,InversionControlParametersEnum);
     291        femmodel->parameters->FindParam(&M,NULL,ControlInputSizeMEnum);
    288292
    289293        std::vector<IssmDouble> time_all;
     
    356360        /*Get X (control)*/
    357361        IssmDouble *X = NULL; int Xsize;
    358         GetVectorFromControlInputsx(&X,&Xsize,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"value");
    359 
     362        if(IsParamEnum(control_enum[0])){
     363                femmodel->parameters->FindControlParam(&X,NULL,control_enum[0],"value");
     364                Xsize=M[0];
     365        }
     366        else{
     367                GetVectorFromControlInputsx(&X,&Xsize,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"value");
     368        }
    360369        /*Initialize model state adjoint (Yb)*/
    361370        double *Yb  = xNewZeroInit<double>(Ysize);
     
    383392        delete hdl_regin;
    384393        if(my_rank==0) for(int i=0; i < Xsize; i++) tape_codi.registerInput(X[i]);
    385         SetControlInputsFromVectorx(femmodel,X);
    386 
     394       
     395        if(IsParamEnum(control_enum[0])){
     396                femmodel->parameters->SetControlParam(X,M[0],control_enum[0]);
     397        }
     398        else{
     399                SetControlInputsFromVectorx(femmodel,X);
     400        }
     401       
    387402        IssmDouble J     = 0.;
    388403        int        count = 0;
     
    446461                /*Tell codipack that X is the independent*/
    447462                for(int i=0; i<Xsize; i++) tape_codi.registerInput(X[i]);
    448                 SetControlInputsFromVectorx(femmodel,X);
     463               
     464                if(IsParamEnum(control_enum[0])){
     465                        femmodel->parameters->SetControlParam(X,M[0],control_enum[0]);
     466                }
     467                else{
     468                        SetControlInputsFromVectorx(femmodel,X);
     469                }
    449470
    450471                /*Get New state*/
     
    510531        xDelete<double>(Yb);
    511532        xDelete<int>(Yin);
     533        xDelete<int>(control_enum);
     534        xDelete<int>(M);
    512535        return J.getValue();
    513536}/*}}}*/
  • issm/trunk-jpl/src/c/modules/ModelProcessorx/Control/UpdateElementsAndMaterialsControl.cpp

    r27678 r27696  
    283283                        }
    284284                        else if(IsParamEnum(input_enum)){
    285                                 _error_("not supported yet");
     285                                //_error_("not supported yet");
     286                                Interp_all[i] = P0Enum;
     287                                parameters->AddObject(new ControlParam(independent,independents_min,independents_max,input_enum,M_all[i]));
     288
    286289                        }
    287290                        xDelete<IssmDouble>(independent);
  • issm/trunk-jpl/src/c/shared/Enum/Enum.vim

    r27688 r27696  
    14121412syn keyword cConstant ControlInputMinsEnum
    14131413syn keyword cConstant ControlInputValuesEnum
     1414syn keyword cConstant ControlParamEnum
    14141415syn keyword cConstant CrouzeixRaviartEnum
    14151416syn keyword cConstant CuffeyEnum
     
    17771778syn keyword cType Contours
    17781779syn keyword cType ControlInput
     1780syn keyword cType ControlParam
    17791781syn keyword cType Covertree
    17801782syn keyword cType DatasetInput
  • issm/trunk-jpl/src/c/shared/Enum/EnumDefinitions.h

    r27688 r27696  
    14111411        ControlInputMinsEnum,
    14121412        ControlInputValuesEnum,
     1413        ControlParamEnum,
    14131414        CrouzeixRaviartEnum,
    14141415        CuffeyEnum,
  • issm/trunk-jpl/src/c/shared/Enum/EnumToStringx.cpp

    r27688 r27696  
    14141414                case ControlInputMinsEnum : return "ControlInputMins";
    14151415                case ControlInputValuesEnum : return "ControlInputValues";
     1416                case ControlParamEnum : return "ControlParam";
    14161417                case CrouzeixRaviartEnum : return "CrouzeixRaviart";
    14171418                case CuffeyEnum : return "Cuffey";
  • issm/trunk-jpl/src/c/shared/Enum/Enumjl.vim

    r27688 r27696  
    14051405syn keyword juliaConstC ControlInputMinsEnum
    14061406syn keyword juliaConstC ControlInputValuesEnum
     1407syn keyword juliaConstC ControlParamEnum
    14071408syn keyword juliaConstC CrouzeixRaviartEnum
    14081409syn keyword juliaConstC CuffeyEnum
  • issm/trunk-jpl/src/c/shared/Enum/StringToEnumx.cpp

    r27688 r27696  
    14471447              else if (strcmp(name,"ControlInputMins")==0) return ControlInputMinsEnum;
    14481448              else if (strcmp(name,"ControlInputValues")==0) return ControlInputValuesEnum;
     1449              else if (strcmp(name,"ControlParam")==0) return ControlParamEnum;
    14491450              else if (strcmp(name,"CrouzeixRaviart")==0) return CrouzeixRaviartEnum;
    14501451              else if (strcmp(name,"Cuffey")==0) return CuffeyEnum;
     
    14891490              else if (strcmp(name,"FSpressure")==0) return FSpressureEnum;
    14901491              else if (strcmp(name,"FSvelocity")==0) return FSvelocityEnum;
    1491               else if (strcmp(name,"FemModel")==0) return FemModelEnum;
    14921492         else stage=13;
    14931493   }
    14941494   if(stage==13){
    1495               if (strcmp(name,"FileParam")==0) return FileParamEnum;
     1495              if (strcmp(name,"FemModel")==0) return FemModelEnum;
     1496              else if (strcmp(name,"FileParam")==0) return FileParamEnum;
    14961497              else if (strcmp(name,"FixedTimestepping")==0) return FixedTimesteppingEnum;
    14971498              else if (strcmp(name,"FloatingArea")==0) return FloatingAreaEnum;
     
    16121613              else if (strcmp(name,"MatrixParam")==0) return MatrixParamEnum;
    16131614              else if (strcmp(name,"MaxAbsVx")==0) return MaxAbsVxEnum;
    1614               else if (strcmp(name,"MaxAbsVy")==0) return MaxAbsVyEnum;
    16151615         else stage=14;
    16161616   }
    16171617   if(stage==14){
    1618               if (strcmp(name,"MaxAbsVz")==0) return MaxAbsVzEnum;
     1618              if (strcmp(name,"MaxAbsVy")==0) return MaxAbsVyEnum;
     1619              else if (strcmp(name,"MaxAbsVz")==0) return MaxAbsVzEnum;
    16191620              else if (strcmp(name,"MaxDivergence")==0) return MaxDivergenceEnum;
    16201621              else if (strcmp(name,"MaxVel")==0) return MaxVelEnum;
     
    17351736              else if (strcmp(name,"StressbalanceAnalysis")==0) return StressbalanceAnalysisEnum;
    17361737              else if (strcmp(name,"StressbalanceConvergenceNumSteps")==0) return StressbalanceConvergenceNumStepsEnum;
    1737               else if (strcmp(name,"StressbalanceSIAAnalysis")==0) return StressbalanceSIAAnalysisEnum;
    17381738         else stage=15;
    17391739   }
    17401740   if(stage==15){
    1741               if (strcmp(name,"StressbalanceSolution")==0) return StressbalanceSolutionEnum;
     1741              if (strcmp(name,"StressbalanceSIAAnalysis")==0) return StressbalanceSIAAnalysisEnum;
     1742              else if (strcmp(name,"StressbalanceSolution")==0) return StressbalanceSolutionEnum;
    17421743              else if (strcmp(name,"StressbalanceVerticalAnalysis")==0) return StressbalanceVerticalAnalysisEnum;
    17431744              else if (strcmp(name,"StringArrayParam")==0) return StringArrayParamEnum;
  • issm/trunk-jpl/src/c/shared/io/Marshalling/IoCodeConversions.cpp

    r27692 r27696  
    166166                const char* field = "md.calving.stress_threshold_groundedice";
    167167                input_enum        = CalvingStressThresholdGroundediceEnum;
     168                fieldname=xNew<char>((strlen(field)+1)); xMemCpy<char>(fieldname,field,(strlen(field)+1));
     169        }
     170        else if(strcmp(string_in,"CalvingADStressThresholdGroundedice")==0){
     171                const char* field = "md.calving.stress_threshold_groundedice";
     172                input_enum        = CalvingADStressThresholdGroundediceEnum;
    168173                fieldname=xNew<char>((strlen(field)+1)); xMemCpy<char>(fieldname,field,(strlen(field)+1));
    169174        }
Note: See TracChangeset for help on using the changeset viewer.