Changeset 12706


Ignore:
Timestamp:
07/24/12 10:36:19 (13 years ago)
Author:
Mathieu Morlighem
Message:

merged trunk-jpl and trunk for revision 12703

Location:
issm/trunk/src
Files:
11 deleted
666 edited
82 copied

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/ad/todo

    r12331 r12706  
    4141Create an alloc layer with template functions for new and delete.
    4242Check that the new code  is modular --without-kml, options are up to date.
     43
     44Replace memcpy, realloc with x layers.  Replace all calls to malloc and free in the code.
  • issm/trunk/src/c/Container/Constraints.cpp

    r12330 r12706  
    44 */
    55
    6 /*Headers: {{{1*/
     6/*Headers: {{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2525
    2626/*Object constructors and destructor*/
    27 /*FUNCTION Constraints::Constraints(){{{1*/
     27/*FUNCTION Constraints::Constraints(){{{*/
    2828Constraints::Constraints(){
    2929        enum_type=ConstraintsEnum;
     
    3131}
    3232/*}}}*/
    33 /*FUNCTION Constraints::~Constraints(){{{1*/
     33/*FUNCTION Constraints::~Constraints(){{{*/
    3434Constraints::~Constraints(){
    3535        return;
     
    3838
    3939/*Numerics: */
    40 /*FUNCTION Constraints::NumberOfConstraints{{{1*/
     40/*FUNCTION Constraints::NumberOfConstraints{{{*/
    4141int Constraints::NumberOfConstraints(void){
    4242
  • issm/trunk/src/c/Container/Constraints.h

    r10522 r12706  
    2121        public:
    2222
    23                 /*constructors, destructors: {{{1*/
     23                /*constructors, destructors: {{{*/
    2424                Constraints();
    2525                ~Constraints();
    2626                /*}}}*/
    27                 /*numerics: {{{1*/
     27                /*numerics: {{{*/
    2828                int   NumberOfConstraints(void);
    2929                /*}}}*/
  • issm/trunk/src/c/Container/Container.h

    r7737 r12706  
    66#define  _CONTAINER_CONTAINER_H_
    77
     8#include "../include/include.h"
    89#include "./DataSet.h"
    910#include "./Constraints.h"
     
    1718#include "./Results.h"
    1819#include "./Vertices.h"
     20#include "./Observations.h"
    1921
    2022#endif //ifndef _CONTAINER_H_
  • issm/trunk/src/c/Container/DataSet.cpp

    r12330 r12706  
    44 */
    55
    6 /*Headers: {{{1*/
     6/*Headers: {{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2828
    2929/*Constructors/Destructors*/
    30 /*FUNCTION DataSet::DataSet(){{{1*/
     30/*FUNCTION DataSet::DataSet(){{{*/
    3131DataSet::DataSet(){
    3232       
     
    3737}
    3838/*}}}*/
    39 /*FUNCTION DataSet::DataSet(int dataset_enum){{{1*/
     39/*FUNCTION DataSet::DataSet(int dataset_enum){{{*/
    4040DataSet::DataSet(int dataset_enum){
    4141        enum_type=dataset_enum;
     
    4747}
    4848/*}}}*/
    49 /*FUNCTION DataSet::Copy{{{1*/
     49/*FUNCTION DataSet::Copy{{{*/
    5050DataSet*   DataSet::Copy(void){
    5151
     
    5959        copy->presorted=presorted;
    6060        if(sorted_ids){
    61                 copy->sorted_ids=(int*)xmalloc(objects.size()*sizeof(int));
    62                 memcpy(copy->sorted_ids,sorted_ids,objects.size()*sizeof(int));
     61                copy->sorted_ids=xNew<int>(objects.size());
     62                xMemCpy<int>(copy->sorted_ids,sorted_ids,objects.size());
    6363        }
    6464        if(id_offsets){
    65                 copy->id_offsets=(int*)xmalloc(objects.size()*sizeof(int));
    66                 memcpy(copy->id_offsets,id_offsets,objects.size()*sizeof(int));
     65                copy->id_offsets=xNew<int>(objects.size());
     66                xMemCpy<int>(copy->id_offsets,id_offsets,objects.size());
    6767        }
    6868
     
    7777}
    7878/*}}}*/
    79 /*FUNCTION DataSet::~DataSet{{{1*/
     79/*FUNCTION DataSet::~DataSet{{{*/
    8080DataSet::~DataSet(){
    8181        clear();
    82         xfree((void**)&sorted_ids);
    83         xfree((void**)&id_offsets);
     82        xDelete<int>(sorted_ids);
     83        xDelete<int>(id_offsets);
    8484}
    8585/*}}}*/
    8686
    8787/*Specific methods*/
    88 /*FUNCTION DataSet::AddObject{{{1*/
     88/*FUNCTION DataSet::AddObject{{{*/
    8989int  DataSet::AddObject(Object* object){
    9090
     
    9494}
    9595/*}}}*/
    96 /*FUNCTION DataSet::clear{{{1*/
     96/*FUNCTION DataSet::clear{{{*/
    9797void  DataSet::clear(){
    9898
     
    112112}
    113113/*}}}*/
    114 /*FUNCTION DataSet::DeleteObject{{{1*/
     114/*FUNCTION DataSet::DeleteObject{{{*/
    115115int  DataSet::DeleteObject(Object* object){
    116116
     
    127127}
    128128/*}}}*/
    129 /*FUNCTION DataSet::DeepEcho{{{1*/
     129/*FUNCTION DataSet::DeepEcho{{{*/
    130130void DataSet::DeepEcho(){
    131131
     
    133133        vector<Object*>::iterator object;
    134134
    135         if(this==NULL)_error_(" trying to echo a NULL dataset");
    136 
    137         _printf_(true,"DataSet echo: %i objects\n",objects.size());
     135        if(this==NULL)_error2_("trying to echo a NULL dataset");
     136
     137        _pprintLine_("DataSet echo: " << objects.size() << " objects");
    138138
    139139        for ( object=objects.begin() ; object < objects.end(); object++ ){
     
    145145}
    146146/*}}}*/
    147 /*FUNCTION DataSet::Echo{{{1*/
     147/*FUNCTION DataSet::Echo{{{*/
    148148void DataSet::Echo(){
    149149
    150150        vector<Object*>::iterator object;
    151151
    152         if(this==NULL)_error_(" trying to echo a NULL dataset");
    153 
    154         _printf_(true,"DataSet echo: %i objects\n",objects.size());
     152        if(this==NULL)_error2_("trying to echo a NULL dataset");
     153
     154        _pprintLine_("DataSet echo: " << objects.size() << " objects");
    155155
    156156        for ( object=objects.begin() ; object < objects.end(); object++ ){
     
    163163}
    164164/*}}}*/
    165 /*FUNCTION DataSet::GetEnum(){{{1*/
     165/*FUNCTION DataSet::GetEnum(){{{*/
    166166int  DataSet::GetEnum(){
    167167        return enum_type;
    168168}
    169169/*}}}*/
    170 /*FUNCTION DataSet::GetEnum(int offset){{{1*/
     170/*FUNCTION DataSet::GetEnum(int offset){{{*/
    171171int   DataSet::GetEnum(int offset){
    172172
     
    175175}
    176176/*}}}*/
    177 /*FUNCTION DataSet::GetObjectByOffset{{{1*/
     177/*FUNCTION DataSet::GetObjectByOffset{{{*/
    178178Object* DataSet::GetObjectByOffset(int offset){
    179179
     
    186186}
    187187/*}}}*/
    188 /*FUNCTION DataSet::GetObjectById{{{1*/
     188/*FUNCTION DataSet::GetObjectById{{{*/
    189189Object* DataSet::GetObjectById(int* poffset,int eid){
    190190
     
    194194
    195195        _assert_(this);
    196         if(!sorted)_error_(" trying to binary search on a non-sorted dataset!");
     196        if(!sorted)_error2_("trying to binary search on a non-sorted dataset!");
    197197
    198198        /*Carry out a binary search on the sorted_ids: */
    199199        if(!binary_search(&id_offset,eid, sorted_ids,objects.size())){
    200                 _error_("could not find object with id %i in DataSet %s",eid,EnumToStringx(enum_type));
     200                _error2_("could not find object with id " << eid << " in DataSet " << EnumToStringx(enum_type));
    201201        }
    202202
     
    211211}
    212212/*}}}*/
    213 /*FUNCTION DataSet::Presort{{{1*/
     213/*FUNCTION DataSet::Presort{{{*/
    214214void DataSet::Presort(){
    215215
     
    221221
    222222                /*Delete existing ids*/
    223                 xfree((void**)&sorted_ids);
    224                 xfree((void**)&id_offsets);
     223                xDelete<int>(sorted_ids);
     224                xDelete<int>(id_offsets);
    225225
    226226                /*Allocate new ids*/
    227                 sorted_ids=(int*)xmalloc(objects.size()*sizeof(int));
    228                 id_offsets=(int*)xmalloc(objects.size()*sizeof(int));
     227                sorted_ids=xNew<int>(objects.size());
     228                id_offsets=xNew<int>(objects.size());
    229229
    230230                /*Build id_offsets and sorted_ids*/
     
    239239}
    240240/*}}}*/
    241 /*FUNCTION DataSet::SetSorting{{{1*/
     241/*FUNCTION DataSet::SetSorting{{{*/
    242242void DataSet::SetSorting(int* in_sorted_ids,int* in_id_offsets){
    243243
     
    247247}
    248248/*}}}*/
    249 /*FUNCTION DataSet::Size{{{1*/
     249/*FUNCTION DataSet::Size{{{*/
    250250int  DataSet::Size(void){
    251251        _assert_(this!=NULL);
     
    254254}
    255255/*}}}*/
    256 /*FUNCTION DataSet::Sort{{{1*/
     256/*FUNCTION DataSet::Sort{{{*/
    257257void DataSet::Sort(){
    258258
    259259        /*Only sort if we are not already sorted: */
    260260        if(!sorted){
    261                 _error_(" not implemented yet!");
    262         }
    263 }
    264 /*}}}*/
     261                _error2_("not implemented yet!");
     262        }
     263}
     264/*}}}*/
  • issm/trunk/src/c/Container/DataSet.h

    r12330 r12706  
    3939                int*            id_offsets;
    4040
    41                 /*constructors, destructors: {{{1*/
     41                /*constructors, destructors: {{{*/
    4242                DataSet();
    4343                DataSet(int enum_type);
    4444                ~DataSet();
    4545                /*}}}*/
    46                 /*management: {{{1*/
     46                /*management: {{{*/
    4747                int   GetEnum();
    4848                int   GetEnum(int offset);
  • issm/trunk/src/c/Container/Elements.cpp

    r12630 r12706  
    44 */
    55
    6 /*Headers: {{{1*/
     6/*Headers: {{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2525
    2626/*Object constructors and destructor*/
    27 /*FUNCTION Elements::Elements(){{{1*/
     27/*FUNCTION Elements::Elements(){{{*/
    2828Elements::Elements(){
    2929        enum_type=MeshElementsEnum;
     
    3131}
    3232/*}}}*/
    33 /*FUNCTION Elements::~Elements(){{{1*/
     33/*FUNCTION Elements::~Elements(){{{*/
    3434Elements::~Elements(){
    3535        return;
     
    3838
    3939/*Object management*/
    40 /*FUNCTION Elements::Configure{{{1*/
     40/*FUNCTION Elements::Configure{{{*/
    4141void Elements::Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters){
    4242
     
    5353}
    5454/*}}}*/
    55 /*FUNCTION Elements::ProcessResultsUnits{{{1*/
     55/*FUNCTION Elements::ProcessResultsUnits{{{*/
    5656void Elements::ProcessResultsUnits(void){
    5757
     
    6363}
    6464/*}}}*/
    65 /*FUNCTION Elements::DeleteResults{{{1*/
     65/*FUNCTION Elements::DeleteResults{{{*/
    6666void Elements::DeleteResults(void){
    6767       
     
    7272}
    7373/*}}}*/
    74 /*FUNCTION Elements::ResultsToPatch{{{1*/
     74/*FUNCTION Elements::ResultsToPatch{{{*/
    7575Patch* Elements::ResultsToPatch(void){
    7676
     
    148148}
    149149/*}}}*/
    150 /*FUNCTION Elements::SetCurrentConfiguration{{{1*/
     150/*FUNCTION Elements::SetCurrentConfiguration{{{*/
    151151void Elements::SetCurrentConfiguration(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters){
    152152
     
    163163}
    164164/*}}}*/
    165 /*FUNCTION Elements::ToResults{{{1*/
     165/*FUNCTION Elements::ToResults{{{*/
    166166void Elements::ToResults(Results* results,Parameters* parameters){
    167167
     
    173173        int    *resultssizes  = NULL;
    174174        int    *resultssteps  = NULL;
    175         double *resultstimes = NULL;
    176         double *vector_serial= NULL;
     175        IssmDouble *resultstimes = NULL;
     176        IssmDouble *vector_serial= NULL;
    177177        Vector*     vector       = NULL;
    178178        bool   io_gather;
     
    203203                /*see what the first element of this partition has in stock (this is common to all partitions)*/
    204204                if(my_rank==minrank){
    205                         if(this->Size()==0) _error_("Cannot write results because there is no element??");
     205                        if(this->Size()==0) _error2_("Cannot write results because there is no element??");
    206206                        Element* element=(Element*)this->GetObjectByOffset(0);
    207207                        element->ListResultsInfo(&resultsenums,&resultssizes,&resultstimes,&resultssteps,&numberofresults);
     
    215215                #ifdef _HAVE_MPI_
    216216                if(my_rank!=minrank){
    217                         resultsenums=(int*)xmalloc(numberofresults*sizeof(int));
    218                         resultssizes=(int*)xmalloc(numberofresults*sizeof(int));
    219                         resultstimes=(double*)xmalloc(numberofresults*sizeof(double));
    220                         resultssteps=(int*)xmalloc(numberofresults*sizeof(int));
     217                        resultsenums=xNew<int>(numberofresults);
     218                        resultssizes=xNew<int>(numberofresults);
     219                        resultstimes=xNew<IssmDouble>(numberofresults);
     220                        resultssteps=xNew<int>(numberofresults);
    221221                }
    222222                MPI_Bcast(resultsenums,numberofresults,MPI_INT,minrank,MPI_COMM_WORLD);
     
    232232                        if(resultssizes[i]==P1Enum)      vectorsize=numberofvertices;
    233233                        else if(resultssizes[i]==P0Enum) vectorsize=numberofelements;
    234                         else _error_("Unkown result size: %s",EnumToStringx(resultssizes[i]));
     234                        else _error2_("Unkown result size: " << EnumToStringx(resultssizes[i]));
    235235                        vector=new Vector(vectorsize);
    236236
     
    250250                        /*clean up*/
    251251                        xdelete(&vector);
    252                         xfree((void**)&vector_serial);
     252                        xDelete<IssmDouble>(vector_serial);
    253253                }
    254254        }
     
    269269
    270270        /*Free ressources:*/
    271         xfree((void**)&resultsenums);
    272         xfree((void**)&resultssizes);
    273         xfree((void**)&resultstimes);
    274         xfree((void**)&resultssteps);
     271        xDelete<int>(resultsenums);
     272        xDelete<int>(resultssizes);
     273        xDelete<int>(resultssteps);
     274        xDelete<IssmDouble>(resultstimes);
    275275        delete patch;
    276276}
    277277/*}}}*/
    278 /*FUNCTION Elements::NumberOfElements{{{1*/
     278/*FUNCTION Elements::NumberOfElements{{{*/
    279279int Elements::NumberOfElements(void){
    280280
     
    292292}
    293293/*}}}*/
    294 /*FUNCTION Elements::InputCopy{{{1*/
     294/*FUNCTION Elements::InputCopy{{{*/
    295295void Elements::InputDuplicate(int input_enum,int output_enum){
    296296
  • issm/trunk/src/c/Container/Elements.h

    r11027 r12706  
    1616class Inputs;
    1717
    18 
    1918class Elements: public DataSet{
    2019
    2120        public:
    2221
    23                 /*constructors, destructors: {{{1*/
     22                /*constructors, destructors: {{{*/
    2423                Elements();
    2524                ~Elements();
    2625                /*}}}*/
    27                 /*numerics: {{{1*/
     26                /*numerics: {{{*/
    2827                void Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters);
    2928                void DeleteResults(void);
  • issm/trunk/src/c/Container/Inputs.cpp

    r10522 r12706  
    44 */
    55
    6 /*Headers: {{{1*/
     6/*Headers: {{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2525
    2626/*Object constructors and destructor*/
    27 /*FUNCTION Inputs::Inputs(){{{1*/
     27/*FUNCTION Inputs::Inputs(){{{*/
    2828Inputs::Inputs(){
    2929        return;
    3030}
    3131/*}}}*/
    32 /*FUNCTION Inputs::~Inputs(){{{1*/
     32/*FUNCTION Inputs::~Inputs(){{{*/
    3333Inputs::~Inputs(){
    3434        return;
     
    3737
    3838/*Object management*/
    39 /*FUNCTION Inputs::GetInputValue(bool* pvalue,int enum-type){{{1*/
     39/*FUNCTION Inputs::GetInputValue(bool* pvalue,int enum-type){{{*/
    4040void Inputs::GetInputValue(bool* pvalue,int enum_type){
    4141
     
    5757                /*we could not find an input with the correct enum type. No defaults values were provided,
    5858                 * error out: */
    59                 _error_("could not find input with enum type %i (%s)",enum_type,EnumToStringx(enum_type));
     59                _error2_("could not find input with enum type " << enum_type << " (" << EnumToStringx(enum_type) << ")");
    6060        }
    6161
     
    6565}
    6666/*}}}*/
    67 /*FUNCTION Inputs::GetInputValue(int* pvalue,int enum-type){{{1*/
     67/*FUNCTION Inputs::GetInputValue(int* pvalue,int enum-type){{{*/
    6868void Inputs::GetInputValue(int* pvalue,int enum_type){
    6969
     
    8585                /*we could not find an input with the correct enum type. No defaults values were provided,
    8686                 * error out: */
    87                 _error_("could not find input with enum type %i (%s)",enum_type,EnumToStringx(enum_type));
     87                _error2_("could not find input with enum type " << enum_type << " (" << EnumToStringx(enum_type) << ")");
    8888        }
    8989
     
    9393}
    9494/*}}}*/
    95 /*FUNCTION Inputs::GetInputValue(double* pvalue,int enum-type){{{1*/
    96 void Inputs::GetInputValue(double* pvalue,int enum_type){
     95/*FUNCTION Inputs::GetInputValue(IssmDouble* pvalue,int enum-type){{{*/
     96void Inputs::GetInputValue(IssmDouble* pvalue,int enum_type){
    9797
    9898        vector<Object*>::iterator object;
     
    113113                /*we could not find an input with the correct enum type. No defaults values were provided,
    114114                 * error out: */
    115                 _error_("could not find input with enum type %i (%s)",enum_type,EnumToStringx(enum_type));
     115                _error2_("could not find input with enum type " << enum_type << " (" << EnumToStringx(enum_type) << ")");
    116116        }
    117117
     
    121121}
    122122/*}}}*/
    123 /*FUNCTION Inputs::GetInputAverage{{{1*/
    124 void Inputs::GetInputAverage(double* pvalue,int enum_type){
     123/*FUNCTION Inputs::GetInputAverage{{{*/
     124void Inputs::GetInputAverage(IssmDouble* pvalue,int enum_type){
    125125
    126126        vector<Object*>::iterator object;
     
    141141                /*we could not find an input with the correct enum type. No defaults values were provided,
    142142                 * error out: */
    143                 _error_("could not find input with enum type %i (%s)",enum_type,EnumToStringx(enum_type));
     143                _error2_("could not find input with enum type " << enum_type << " (" << EnumToStringx(enum_type) << ")");
    144144        }
    145145
     
    149149}
    150150/*}}}*/
    151 /*FUNCTION Inputs::AddInput{{{1*/
     151/*FUNCTION Inputs::AddInput{{{*/
    152152int  Inputs::AddInput(Input* in_input){
    153153
     
    175175}
    176176/*}}}*/
    177 /*FUNCTION Inputs::ChangeEnum{{{1*/
     177/*FUNCTION Inputs::ChangeEnum{{{*/
    178178void  Inputs::ChangeEnum(int oldenumtype,int newenumtype){
    179179
     
    205205}
    206206/*}}}*/
    207 /*FUNCTION Inputs::ConstrainMin{{{1*/
    208 void  Inputs::ConstrainMin(int constrain_enum, double minimum){
     207/*FUNCTION Inputs::ConstrainMin{{{*/
     208void  Inputs::ConstrainMin(int constrain_enum, IssmDouble minimum){
    209209           
    210210        Input* constrain_input=NULL;
     
    213213
    214214        /*some checks: */
    215         if(!constrain_input) _error_(" input %s could not be found!",EnumToStringx(constrain_enum));
     215        if(!constrain_input) _error2_("input " << EnumToStringx(constrain_enum) << " could not be found!");
    216216
    217217        /*Apply ContrainMin: */
     
    219219}
    220220/*}}}*/
    221 /*FUNCTION Inputs::InfinityNorm{{{1*/
    222 double Inputs::InfinityNorm(int enumtype){
    223 
    224         /*Output*/
    225         double norm;
     221/*FUNCTION Inputs::InfinityNorm{{{*/
     222IssmDouble Inputs::InfinityNorm(int enumtype){
     223
     224        /*Output*/
     225        IssmDouble norm;
    226226
    227227        /*Get input*/
     
    240240}
    241241/*}}}*/
    242 /*FUNCTION Inputs::Max{{{1*/
    243 double Inputs::Max(int enumtype){
    244 
    245         /*Output*/
    246         double max;
     242/*FUNCTION Inputs::Max{{{*/
     243IssmDouble Inputs::Max(int enumtype){
     244
     245        /*Output*/
     246        IssmDouble max;
    247247
    248248        /*Get input*/
     
    254254        }
    255255        else{
    256                 _error_("Input %s not found",EnumToStringx(enumtype));
     256                _error2_("Input " << EnumToStringx(enumtype) << " not found");
    257257        }
    258258
     
    261261}
    262262/*}}}*/
    263 /*FUNCTION Inputs::MaxAbs{{{1*/
    264 double Inputs::MaxAbs(int enumtype){
    265 
    266         /*Output*/
    267         double max;
     263/*FUNCTION Inputs::MaxAbs{{{*/
     264IssmDouble Inputs::MaxAbs(int enumtype){
     265
     266        /*Output*/
     267        IssmDouble max;
    268268
    269269        /*Get input*/
     
    275275        }
    276276        else{
    277                 _error_("Input %s not found",EnumToStringx(enumtype));
     277                _error2_("Input " << EnumToStringx(enumtype) << " not found");
    278278        }
    279279
     
    282282}
    283283/*}}}*/
    284 /*FUNCTION Inputs::Min{{{1*/
    285 double Inputs::Min(int enumtype){
    286 
    287         /*Output*/
    288         double min;
     284/*FUNCTION Inputs::Min{{{*/
     285IssmDouble Inputs::Min(int enumtype){
     286
     287        /*Output*/
     288        IssmDouble min;
    289289
    290290        /*Get input*/
     
    296296        }
    297297        else{
    298                 _error_("Input %s not found",EnumToStringx(enumtype));
     298                _error2_("Input " << EnumToStringx(enumtype) << " not found");
    299299        }
    300300
     
    303303}
    304304/*}}}*/
    305 /*FUNCTION Inputs::MinAbs{{{1*/
    306 double Inputs::MinAbs(int enumtype){
    307 
    308         /*Output*/
    309         double min;
     305/*FUNCTION Inputs::MinAbs{{{*/
     306IssmDouble Inputs::MinAbs(int enumtype){
     307
     308        /*Output*/
     309        IssmDouble min;
    310310
    311311        /*Get input*/
     
    317317        }
    318318        else{
    319                 _error_("Input %s not found",EnumToStringx(enumtype));
     319                _error2_("Input " << EnumToStringx(enumtype) << " not found");
    320320        }
    321321
     
    324324}
    325325/*}}}*/
    326 /*FUNCTION Inputs::GetInput{{{1*/
     326/*FUNCTION Inputs::GetInput{{{*/
    327327Input* Inputs::GetInput(int enum_name){
    328328
     
    341341}
    342342/*}}}*/
    343 /*FUNCTION Inputs::DeleteInput{{{1*/
     343/*FUNCTION Inputs::DeleteInput{{{*/
    344344int  Inputs::DeleteInput(int enum_type){
    345345
     
    361361}
    362362/*}}}*/
    363 /*FUNCTION Inputs::DuplicateInput{{{1*/
     363/*FUNCTION Inputs::DuplicateInput{{{*/
    364364void  Inputs::DuplicateInput(int original_enum,int new_enum){
    365365
     
    369369        /*Make a copy of the original input: */
    370370        original=(Input*)this->GetInput(original_enum);
    371         if(!original)_error_("could not find input with enum: %s",EnumToStringx(original_enum));
     371        if(!original)_error2_("could not find input with enum: " << EnumToStringx(original_enum));
    372372        copy=(Input*)original->copy();
    373373
     
    379379}
    380380/*}}}*/
    381 /*FUNCTION Inputs::SpawnTriaInputs{{{1*/
     381/*FUNCTION Inputs::SpawnTriaInputs{{{*/
    382382Inputs* Inputs::SpawnTriaInputs(int* indices){
    383383
     
    405405}
    406406/*}}}*/
    407 /*FUNCTION Inputs::AXPY{{{1*/
    408 void  Inputs::AXPY(int MeshYEnum, double scalar, int MeshXEnum){
     407/*FUNCTION Inputs::AXPY{{{*/
     408void  Inputs::AXPY(int MeshYEnum, IssmDouble scalar, int MeshXEnum){
    409409           
    410410        Input* xinput=NULL;
     
    416416
    417417        /*some checks: */
    418         if(!xinput) _error_(" input %s could not be found!",EnumToStringx(MeshXEnum));
    419         if(!yinput) _error_(" input %s could not be found!",EnumToStringx(MeshYEnum));
     418        if(!xinput) _error2_("input " << EnumToStringx(MeshXEnum) << " could not be found!");
     419        if(!yinput) _error2_("input " << EnumToStringx(MeshYEnum) << " could not be found!");
    420420
    421421        /*Apply AXPY: */
     
    423423}
    424424/*}}}*/
    425 /*FUNCTION Inputs::Configure{{{1*/
     425/*FUNCTION Inputs::Configure{{{*/
    426426void Inputs::Configure(Parameters* parameters){
    427427
  • issm/trunk/src/c/Container/Inputs.h

    r10522 r12706  
    2323        public:
    2424
    25                 /*constructors, destructors: {{{1*/
     25                /*constructors, destructors: {{{*/
    2626                Inputs();
    2727                ~Inputs();
    2828
    2929                /*}}}*/
    30                 /*numerics: {{{1*/
     30                /*numerics: {{{*/
    3131                int     AddInput(Input* in_input);
    3232                void    ChangeEnum(int enumtype,int new_enumtype);
    33                 void    ConstrainMin(int constrain_enum, double minimum);
     33                void    ConstrainMin(int constrain_enum, IssmDouble minimum);
    3434                int     DeleteInput(int enum_type);
    3535                void    DuplicateInput(int original_enum,int new_enum);
    3636                Input*  GetInput(int enum_name);
    3737                Inputs* SpawnTriaInputs(int* indices);
    38                 void    AXPY(int MeshYEnum, double scalar, int MeshXEnum);
    39                 double  InfinityNorm(int enumtype);
    40                 double  Max(int enumtype);
    41                 double  MaxAbs(int enumtype);
    42                 double  Min(int enumtype);
    43                 double  MinAbs(int enumtype);
     38                void    AXPY(int MeshYEnum, IssmDouble scalar, int MeshXEnum);
     39                IssmDouble  InfinityNorm(int enumtype);
     40                IssmDouble  Max(int enumtype);
     41                IssmDouble  MaxAbs(int enumtype);
     42                IssmDouble  Min(int enumtype);
     43                IssmDouble  MinAbs(int enumtype);
    4444               
    45                 void GetInputAverage(double* pvalue, int enum_type);
     45                void GetInputAverage(IssmDouble* pvalue, int enum_type);
    4646                void GetInputValue(bool* pvalue,int enum_type);
    4747                void GetInputValue(int* pvalue,int enum_type);
    48                 void GetInputValue(double* pvalue,int enum_type);
     48                void GetInputValue(IssmDouble* pvalue,int enum_type);
    4949
    5050                void Configure(Parameters* parameters);
  • issm/trunk/src/c/Container/Loads.cpp

    r12330 r12706  
    44 */
    55
    6 /*Headers: {{{1*/
     6/*Headers: {{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2525
    2626/*Object constructors and destructor*/
    27 /*FUNCTION Loads::Loads(){{{1*/
     27/*FUNCTION Loads::Loads(){{{*/
    2828Loads::Loads(){
    2929        enum_type=LoadsEnum;
     
    3131}
    3232/*}}}*/
    33 /*FUNCTION Loads::~Loads(){{{1*/
     33/*FUNCTION Loads::~Loads(){{{*/
    3434Loads::~Loads(){
    3535        return;
     
    3838
    3939/*Numerics:*/
    40 /*FUNCTION Loads::Configure{{{1*/
     40/*FUNCTION Loads::Configure{{{*/
    4141void Loads::Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters){
    4242
     
    5353}
    5454/*}}}*/
    55 /*FUNCTION Loads::NumberOfLoads{{{1*/
     55/*FUNCTION Loads::NumberOfLoads{{{*/
    5656int Loads::NumberOfLoads(void){
    5757
     
    7474}
    7575/*}}}*/
    76 /*FUNCTION Loads::SetCurrentConfiguration{{{1*/
     76/*FUNCTION Loads::SetCurrentConfiguration{{{*/
    7777void Loads::SetCurrentConfiguration(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters){
    7878
  • issm/trunk/src/c/Container/Loads.h

    r10522 r12706  
    2020        public:
    2121
    22                 /*constructors, destructors: {{{1*/
     22                /*constructors, destructors: {{{*/
    2323                Loads();
    2424                ~Loads();
    2525                /*}}}*/
    26                 /*numerics: {{{1*/
     26                /*numerics: {{{*/
    2727                void  Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters);
    2828                int   NumberOfLoads(void);
  • issm/trunk/src/c/Container/Materials.cpp

    r10522 r12706  
    44 */
    55
    6 /*Headers: {{{1*/
     6/*Headers: {{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2525
    2626/*Object constructors and destructor*/
    27 /*FUNCTION Materials::Materials(){{{1*/
     27/*FUNCTION Materials::Materials(){{{*/
    2828Materials::Materials(){
    2929        enum_type=MaterialsEnum;
     
    3131}
    3232/*}}}*/
    33 /*FUNCTION Materials::~Materials(){{{1*/
     33/*FUNCTION Materials::~Materials(){{{*/
    3434Materials::~Materials(){
    3535        return;
     
    3838
    3939/*Object management*/
    40 /*FUNCTION Materials::Configure{{{1*/
     40/*FUNCTION Materials::Configure{{{*/
    4141void Materials::Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters){
    4242
  • issm/trunk/src/c/Container/Materials.h

    r10522 r12706  
    1919        public:
    2020
    21                 /*constructors, destructors: {{{1*/
     21                /*constructors, destructors: {{{*/
    2222                Materials();
    2323                ~Materials();
    2424                /*}}}*/
    25                 /*numerics: {{{1*/
     25                /*numerics: {{{*/
    2626                void  Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters);
    2727                /*}}}*/
  • issm/trunk/src/c/Container/Nodes.cpp

    r12330 r12706  
    44 */
    55
    6 /*Headers: {{{1*/
     6/*Headers: {{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2525
    2626/*Object constructors and destructor*/
    27 /*FUNCTION Nodes::Nodes(){{{1*/
     27/*FUNCTION Nodes::Nodes(){{{*/
    2828Nodes::Nodes(){
    2929        enum_type=NodesEnum;
     
    3131}
    3232/*}}}*/
    33 /*FUNCTION Nodes::~Nodes(){{{1*/
     33/*FUNCTION Nodes::~Nodes(){{{*/
    3434Nodes::~Nodes(){
    3535        return;
     
    3838
    3939/*Numerics*/
    40 /*FUNCTION Nodes::Configure{{{1*/
     40/*FUNCTION Nodes::Configure{{{*/
    4141void Nodes::Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters){
    4242
     
    5353}
    5454/*}}}*/
    55 /*FUNCTION Nodes::DistributeDofs{{{1*/
     55/*FUNCTION Nodes::DistributeDofs{{{*/
    5656void  Nodes::DistributeDofs(int analysis_type,int setenum){
    5757
     
    8484         * cpus by the total last dofs of the previus cpu, starting from 0.
    8585         * First: get number of dofs for each cpu*/
    86         alldofcount=(int*)xmalloc(num_procs*sizeof(int));
     86        alldofcount=xNew<int>(num_procs);
    8787        #ifdef _HAVE_MPI_
    8888        MPI_Gather(&dofcount,1,MPI_INT,alldofcount,1,MPI_INT,0,MPI_COMM_WORLD);
     
    113113        numnodes=this->NumberOfNodes(analysis_type);
    114114        if(numnodes*maxdofspernode){
    115                 truedofs=   (int*)xcalloc(numnodes*maxdofspernode,sizeof(int)); //initialize to 0, so that we can pick up the max
    116                 alltruedofs=(int*)xcalloc(numnodes*maxdofspernode,sizeof(int));
     115                truedofs=   xNewZeroInit<int>(numnodes*maxdofspernode); //initialize to 0, so that we can pick up the max
     116                alltruedofs=xNewZeroInit<int>(numnodes*maxdofspernode);
    117117        }
    118118
     
    139139
    140140        /* Free ressources: */
    141         xfree((void**)&alldofcount);
    142         xfree((void**)&truedofs);
    143         xfree((void**)&alltruedofs);
    144 }
    145 /*}}}*/
    146 /*FUNCTION Nodes::FlagClones{{{1*/
     141        xDelete<int>(alldofcount);
     142        xDelete<int>(truedofs);
     143        xDelete<int>(alltruedofs);
     144}
     145/*}}}*/
     146/*FUNCTION Nodes::FlagClones{{{*/
    147147void  Nodes::FlagClones(int analysis_type){
    148148
     
    158158
    159159        /*Allocate ranks: */
    160         ranks=(int*)xmalloc(numnodes*sizeof(int));
    161         minranks=(int*)xmalloc(numnodes*sizeof(int));
     160        ranks=xNew<int>(numnodes);
     161        minranks=xNew<int>(numnodes);
    162162
    163163        for(i=0;i<numnodes;i++)ranks[i]=num_procs; //no cpu can have rank num_procs. This is the maximum limit.
     
    190190
    191191        /*Free ressources: */
    192         xfree((void**)&ranks);
    193         xfree((void**)&minranks);
    194 
    195 }
    196 /*}}}*/
    197 /*FUNCTION Nodes::MaxNumDofs{{{1*/
     192        xDelete<int>(ranks);
     193        xDelete<int>(minranks);
     194
     195}
     196/*}}}*/
     197/*FUNCTION Nodes::MaxNumDofs{{{*/
    198198int   Nodes::MaxNumDofs(int analysis_type,int setenum){
    199199
     
    225225}
    226226/*}}}*/
    227 /*FUNCTION Nodes::NumberOfDofs{{{1*/
     227/*FUNCTION Nodes::NumberOfDofs{{{*/
    228228int   Nodes::NumberOfDofs(int analysis_type,int setenum){
    229229
     
    259259}
    260260/*}}}*/
    261 /*FUNCTION Nodes::NumberOfNodes(){{{1*/
     261/*FUNCTION Nodes::NumberOfNodes(){{{*/
    262262int Nodes::NumberOfNodes(void){
    263263
     
    287287}
    288288/*}}}*/
    289 /*FUNCTION Nodes::NumberOfNodes(analysis){{{1*/
     289/*FUNCTION Nodes::NumberOfNodes(analysis){{{*/
    290290int Nodes::NumberOfNodes(int analysis_type){
    291291
     
    326326}
    327327/*}}}*/
    328 /*FUNCTION Nodes::Ranks{{{1*/
     328/*FUNCTION Nodes::Ranks{{{*/
    329329void   Nodes::Ranks(int* ranks,int analysis_type){
    330330
     
    352352}
    353353/*}}}*/
    354 /*FUNCTION Nodes::SetCurrentConfiguration{{{1*/
     354/*FUNCTION Nodes::SetCurrentConfiguration{{{*/
    355355void Nodes::SetCurrentConfiguration(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters){
    356356
  • issm/trunk/src/c/Container/Nodes.h

    r10522 r12706  
    1313        public:
    1414
    15                 /*constructors, destructors: {{{1*/
     15                /*constructors, destructors: {{{*/
    1616                Nodes();
    1717                ~Nodes();
    1818                /*}}}*/
    19                 /*numerics: {{{1*/
     19                /*numerics: {{{*/
    2020                void  Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters);
    2121                void  DistributeDofs(int analysis_type,int SETENUM);
  • issm/trunk/src/c/Container/Observations.cpp

    r12330 r12706  
    2020#include "../shared/shared.h"
    2121#include "../include/include.h"
     22#include "../modules/modules.h"
    2223#include "../EnumDefinitions/EnumDefinitions.h"
     24#include "../io/io.h"
    2325
    2426using namespace std;
     
    3234}
    3335/*}}}*/
    34 /*FUNCTION Observations::Observations(double* observations_list,double* x,double* y,int n,Options* options){{{*/
    35 Observations::Observations(double* observations_list,double* x,double* y,int n,Options* options){
     36/*FUNCTION Observations::Observations(IssmDouble* observations_list,IssmDouble* x,IssmDouble* y,int n,Options* options){{{*/
     37Observations::Observations(IssmDouble* observations_list,IssmDouble* x,IssmDouble* y,int n,Options* options){
    3638
    3739        /*Intermediaries*/
    3840        int          i,j,maxdepth,level,counter,index;
    3941        int          xi,yi;
    40         double       xmin,xmax,ymin,ymax;
    41         double       offset,minlength,minspacing,mintrimming,maxtrimming;
     42        IssmDouble       xmin,xmax,ymin,ymax;
     43        IssmDouble       offset,minlength,minspacing,mintrimming,maxtrimming;
    4244        int         *indices     = NULL;
    4345        Observation *observation = NULL;
     
    5759        options->Get(&maxtrimming,"maxtrimming",+1.e+21);
    5860        options->Get(&minspacing,"minspacing",0.01);
    59         if(minspacing<=0) _error_("minspacing must > 0");
     61        if(minspacing<=0) _error2_("minspacing must > 0");
    6062
    6163        /*Get Minimum box size*/
    6264        if(options->GetOption("boxlength")){
    6365                options->Get(&minlength,"boxlength");
    64                 if(minlength<=0)_error_("boxlength should be a positive number");
     66                if(minlength<=0)_error2_("boxlength should be a positive number");
    6567                maxdepth=int(log(max(xmax-xmin,ymax-ymin)/minlength +1)/log(2.0));
    6668        }
    6769        else{
    6870                maxdepth = 30;
    69                 minlength=max(xmax-xmin,ymax-ymin)/double((1L<<maxdepth)-1);
     71                minlength=max(xmax-xmin,ymax-ymin)/IssmDouble((1L<<maxdepth)-1);
    7072        }
    7173
    7274        /*Initialize Quadtree*/
    73         printf("Generating quadtree with a maximum box size %g (depth=%i)... ",minlength,maxdepth);
     75        _pprintString_("Generating quadtree with a maximum box size " << minlength << " (depth=" << maxdepth << ")... ");
    7476        this->quadtree = new Quadtree(xmin,xmax,ymin,ymax,maxdepth);
    7577
     
    101103                }
    102104        }
    103         printf("done\n");
    104         printf("Initial number of observations: %i\n",n);
    105         printf("  Final number of observations: %i\n",this->quadtree->NbObs);
     105        _pprintLine_("done");
     106        _pprintLine_("Initial number of observations: " << n);
     107        _pprintLine_("  Final number of observations: " << this->quadtree->NbObs);
    106108}
    107109/*}}}*/
     
    114116
    115117/*Methods*/
    116 /*FUNCTION Observations::ObservationList{{{*/
    117 void Observations::ObservationList(double **px,double **py,double **pobs,int* pnobs,double x_interp,double y_interp,double radius,int maxdata){
     118/*FUNCTION Observations::ClosestObservation{{{*/
     119void Observations::ClosestObservation(IssmDouble *px,IssmDouble *py,IssmDouble *pobs,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius){
     120
     121        /*Output and Intermediaries*/
     122        bool         stop;
     123        int          nobs,i,index;
     124        IssmDouble       h2,hmin2,radius2;
     125        int         *indices      = NULL;
     126        Observation *observation  = NULL;
     127
     128        /*If radius is not provided or is 0, return all observations*/
     129        if(radius==0) radius=this->quadtree->root->length;
     130
     131        /*Compute radius square*/
     132        radius2 = radius*radius;
     133
     134        /*Find all observations that are in radius*/
     135        this->quadtree->RangeSearch(&indices,&nobs,x_interp,y_interp,radius);
     136        for (i=0;i<nobs;i++){
     137                observation=(Observation*)this->GetObjectByOffset(indices[i]);
     138                h2 = (observation->x-x_interp)*(observation->x-x_interp) + (observation->y-y_interp)*(observation->y-y_interp);
     139
     140                if(i==0){
     141                        hmin2 = h2;
     142                        index = i;
     143                }
     144                else{
     145                        if(h2<hmin2){
     146                                hmin2 = h2;
     147                                index = i;
     148                        }
     149                }
     150        } 
     151
     152        /*Assign output pointer*/
     153        if(!nobs){
     154                *px=UNDEF;
     155                *py=UNDEF;
     156                *pobs=UNDEF;
     157        }
     158        else{
     159                observation=(Observation*)this->GetObjectByOffset(indices[index]);
     160                *px=observation->x;
     161                *py=observation->y;
     162                *pobs=observation->value;
     163        }
     164        xDelete<int>(indices);
     165
     166}/*}}}*/
     167/*FUNCTION Observations::ObservationList(IssmDouble **px,IssmDouble **py,IssmDouble **pobs,int* pnobs,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius,int maxdata){{{*/
     168void Observations::ObservationList(IssmDouble **px,IssmDouble **py,IssmDouble **pobs,int* pnobs,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius,int maxdata){
    118169
    119170        /*Output and Intermediaries*/
    120171        bool         stop;
    121172        int          nobs,tempnobs,i,j,k,n,counter;
    122         double       h2,radius2;
     173        IssmDouble       h2,radius2;
    123174        int         *indices      = NULL;
    124175        int         *tempindices  = NULL;
    125         double      *dists        = NULL;
    126         double      *x            = NULL;
    127         double      *y            = NULL;
    128         double      *obs          = NULL;
     176        IssmDouble      *dists        = NULL;
     177        IssmDouble      *x            = NULL;
     178        IssmDouble      *y            = NULL;
     179        IssmDouble      *obs          = NULL;
    129180        Observation *observation  = NULL;
    130181
     182        /*If radius is not provided or is 0, return all observations*/
     183        if(radius==0) radius=this->quadtree->root->length;
     184
    131185        /*Compute radius square*/
    132         if(radius==0) radius=this->quadtree->root->length;
    133186        radius2 = radius*radius;
    134187
     
    136189        this->quadtree->RangeSearch(&tempindices,&tempnobs,x_interp,y_interp,radius);
    137190        if(tempnobs){
    138                 indices = (int*)xmalloc(tempnobs*sizeof(int));
    139                 dists   = (double*)xmalloc(tempnobs*sizeof(double));
     191                indices = xNew<int>(tempnobs);
     192                dists   = xNew<IssmDouble>(tempnobs);
    140193        }
    141194        nobs = 0;
     
    172225                }
    173226        } 
    174         xfree((void**)&dists);
    175         xfree((void**)&tempindices);
     227        xDelete<IssmDouble>(dists);
     228        xDelete<int>(tempindices);
    176229
    177230        if(nobs){
    178231                /*Allocate vectors*/
    179                 x   = (double*)xmalloc(nobs*sizeof(double));
    180                 y   = (double*)xmalloc(nobs*sizeof(double));
    181                 obs = (double*)xmalloc(nobs*sizeof(double));
     232                x   = xNew<IssmDouble>(nobs);
     233                y   = xNew<IssmDouble>(nobs);
     234                obs = xNew<IssmDouble>(nobs);
    182235
    183236                /*Loop over all observations and fill in x, y and obs*/
     
    189242
    190243        /*Assign output pointer*/
    191         xfree((void**)&indices);
     244        xDelete<int>(indices);
    192245        *px=x;
    193246        *py=y;
     
    195248        *pnobs=nobs;
    196249}/*}}}*/
     250/*FUNCTION Observations::ObservationList(IssmDouble **px,IssmDouble **py,IssmDouble **pobs,int* pnobs){{{*/
     251void Observations::ObservationList(IssmDouble **px,IssmDouble **py,IssmDouble **pobs,int* pnobs){
     252
     253        /*Output and Intermediaries*/
     254        int          nobs;
     255        IssmDouble      *x            = NULL;
     256        IssmDouble      *y            = NULL;
     257        IssmDouble      *obs          = NULL;
     258        Observation *observation  = NULL;
     259
     260        nobs = this->Size();
     261
     262        if(nobs){
     263                x   = xNew<IssmDouble>(nobs);
     264                y   = xNew<IssmDouble>(nobs);
     265                obs = xNew<IssmDouble>(nobs);
     266                for(int i=0;i<this->Size();i++){
     267                        observation=(Observation*)this->GetObjectByOffset(i);
     268                        observation->WriteXYObs(&x[i],&y[i],&obs[i]);
     269                }
     270        }
     271
     272        /*Assign output pointer*/
     273        *px=x;
     274        *py=y;
     275        *pobs=obs;
     276        *pnobs=nobs;
     277}/*}}}*/
     278/*FUNCTION Observations::InterpolationIDW{{{*/
     279void Observations::InterpolationIDW(IssmDouble *pprediction,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius,int mindata,int maxdata,IssmDouble power){
     280
     281        /*Intermediaries*/
     282        int    i,n_obs;
     283        IssmDouble prediction;
     284        IssmDouble numerator,denominator,h,weight;
     285        IssmDouble *x   = NULL;
     286        IssmDouble *y   = NULL;
     287        IssmDouble *obs = NULL;
     288
     289        /*Some checks*/
     290        _assert_(maxdata>0);
     291        _assert_(pprediction);
     292        _assert_(power>0);
     293
     294        /*If radius is not provided or is 0, return all observations*/
     295        if(radius==0) radius=this->quadtree->root->length;
     296
     297        /*Get list of observations for current point*/
     298        this->ObservationList(&x,&y,&obs,&n_obs,x_interp,y_interp,radius,maxdata);
     299
     300        /*If we have less observations than mindata, return UNDEF*/
     301        if(n_obs<mindata){
     302                prediction = UNDEF;
     303        }
     304        else{
     305                numerator   = 0.;
     306                denominator = 0.;
     307                for(i=0;i<n_obs;i++){
     308                        h = sqrt( (x[i]-x_interp)*(x[i]-x_interp) + (y[i]-y_interp)*(y[i]-y_interp));
     309                        if (h<0.0000001){
     310                                numerator   = obs[i];
     311                                denominator = 1.;
     312                                break;
     313                        }
     314                        weight = 1./pow(h,power);
     315                        numerator   += weight*obs[i];
     316                        denominator += weight;
     317                }
     318                prediction = numerator/denominator;
     319        }
     320
     321        /*clean-up*/
     322        *pprediction = prediction;
     323        xDelete<IssmDouble>(x);
     324        xDelete<IssmDouble>(y);
     325        xDelete<IssmDouble>(obs);
     326}/*}}}*/
     327/*FUNCTION Observations::InterpolationKriging{{{*/
     328void Observations::InterpolationKriging(IssmDouble *pprediction,IssmDouble *perror,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius,int mindata,int maxdata,Variogram* variogram){
     329
     330        /*Intermediaries*/
     331        int           i,j,n_obs;
     332        IssmDouble        prediction,error;
     333        IssmDouble        numerator,denominator,ratio;
     334        IssmDouble       *x            = NULL;
     335        IssmDouble       *y            = NULL;
     336        IssmDouble       *obs          = NULL;
     337        IssmDouble       *Gamma        = NULL;
     338        IssmDouble       *GinvG0       = NULL;
     339        IssmDouble       *Ginv1        = NULL;
     340        IssmDouble       *GinvZ        = NULL;
     341        IssmDouble       *gamma0       = NULL;
     342        IssmDouble       *ones         = NULL;
     343
     344        /*Some checks*/
     345        _assert_(mindata>0 && maxdata>0);
     346        _assert_(pprediction && perror);
     347
     348        /*If radius is not provided or is 0, return all observations*/
     349        if(radius==0) radius=this->quadtree->root->length;
     350
     351        /*Get list of observations for current point*/
     352        this->ObservationList(&x,&y,&obs,&n_obs,x_interp,y_interp,radius,maxdata);
     353
     354        /*If we have less observations than mindata, return UNDEF*/
     355        if(n_obs<mindata){
     356                *pprediction = -999.0;
     357                *perror      = -999.0;
     358                return;
     359        }
     360
     361        /*Allocate intermediary matrix and vectors*/
     362        Gamma  = xNew<IssmDouble>(n_obs*n_obs);
     363        gamma0 = xNew<IssmDouble>(n_obs);
     364        ones   = xNew<IssmDouble>(n_obs);
     365
     366        /*First: Create semivariogram matrix for observations*/
     367        for(i=0;i<n_obs;i++){
     368                for(j=0;j<=i;j++){
     369                        //Gamma[i*n_obs+j] = variogram->SemiVariogram(x[i]-x[j],y[i]-y[j]);
     370                        Gamma[i*n_obs+j] = variogram->Covariance(x[i]-x[j],y[i]-y[j]);
     371                        Gamma[j*n_obs+i] = Gamma[i*n_obs+j];
     372                }
     373        }
     374        for(i=0;i<n_obs;i++) ones[i]=1;
     375
     376        /*Get semivariogram vector associated to this location*/
     377        //for(i=0;i<n_obs;i++) gamma0[i] = variogram->SemiVariogram(x[i]-x_interp,y[i]-y_interp);
     378        for(i=0;i<n_obs;i++) gamma0[i] = variogram->Covariance(x[i]-x_interp,y[i]-y_interp);
     379
     380        /*Solve the three linear systems*/
     381#if _HAVE_GSL_
     382        SolverxGsl(&GinvG0,Gamma,gamma0,n_obs); // Gamma^-1 gamma0
     383        SolverxGsl(&Ginv1, Gamma,ones,n_obs);   // Gamma^-1 ones
     384        SolverxGsl(&GinvZ, Gamma,obs,n_obs);    // Gamma^-1 Z
     385#else
     386        _error2_("GSL is required");
     387#endif
     388
     389        /*Prepare predictor*/
     390        numerator=-1.; denominator=0.;
     391        for(i=0;i<n_obs;i++) numerator  +=GinvG0[i];
     392        for(i=0;i<n_obs;i++) denominator+=Ginv1[i];
     393        ratio=numerator/denominator;
     394
     395        prediction = 0.;
     396        error      = - numerator*numerator/denominator;
     397        for(i=0;i<n_obs;i++) prediction += (gamma0[i]-ratio)*GinvZ[i];
     398        for(i=0;i<n_obs;i++) error += gamma0[i]*GinvG0[i];
     399
     400        /*clean-up*/
     401        *pprediction = prediction;
     402        *perror = error;
     403        xDelete<IssmDouble>(x);
     404        xDelete<IssmDouble>(y);
     405        xDelete<IssmDouble>(obs);
     406        xDelete<IssmDouble>(Gamma);
     407        xDelete<IssmDouble>(gamma0);
     408        xDelete<IssmDouble>(ones);
     409        xDelete<IssmDouble>(GinvG0);
     410        xDelete<IssmDouble>(Ginv1);
     411        xDelete<IssmDouble>(GinvZ);
     412
     413}/*}}}*/
     414/*FUNCTION Observations::InterpolationNearestNeighbor{{{*/
     415void Observations::InterpolationNearestNeighbor(IssmDouble *pprediction,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius){
     416
     417        /*Intermediaries*/
     418        IssmDouble        x,y,obs;
     419
     420        /*Get clostest observation*/
     421        this->ClosestObservation(&x,&y,&obs,x_interp,y_interp,radius);
     422
     423        /*Assign output pointer*/
     424        *pprediction = obs;
     425}/*}}}*/
    197426/*FUNCTION Observations::QuadtreeColoring{{{*/
    198 void Observations::QuadtreeColoring(double* A,double *x,double *y,int n){
     427void Observations::QuadtreeColoring(IssmDouble* A,IssmDouble *x,IssmDouble *y,int n){
    199428
    200429        int xi,yi,level;
     
    203432                this->quadtree->IntergerCoordinates(&xi,&yi,x[i],y[i]);
    204433                this->quadtree->QuadtreeDepth(&level,xi,yi);
    205                 A[i]=(double)level;
     434                A[i]=(IssmDouble)level;
    206435        }
    207436
    208437}/*}}}*/
    209438/*FUNCTION Observations::Variomap{{{*/
    210 void Observations::Variomap(double* gamma,double *x,int n){
     439void Observations::Variomap(IssmDouble* gamma,IssmDouble *x,int n){
    211440
    212441        /*Output and Intermediaries*/
    213442        int          i,j,k;
    214         double       distance;
     443        IssmDouble       distance;
    215444        Observation *observation1 = NULL;
    216445        Observation *observation2 = NULL;
    217446
    218         int *counter= (int*)xmalloc(n*sizeof(int));
    219         for(j=0;j<n;j++) counter[j] = 0;
     447        IssmDouble *counter = xNew<IssmDouble>(n);
     448        for(j=0;j<n;j++) counter[j] = 0.0;
    220449        for(j=0;j<n;j++) gamma[j]   = 0.0;
    221450
     
    234463
    235464                        gamma[index]   += 1./2.*pow(observation1->value - observation2->value,2.);
    236                         counter[index] += 1;
     465                        counter[index] += 1.;
    237466                }
    238467        }
    239468
    240469        /*Normalize semivariogram*/
    241         gamma[0]=0;
     470        gamma[0]=0.;
    242471        for(k=0;k<n;k++){
    243                 if(counter[k]) gamma[k] = gamma[k]/double(counter[k]);
     472                if(counter[k]) gamma[k] = gamma[k]/counter[k];
    244473        }
    245474
    246475        /*Assign output pointer*/
    247         xfree((void**)&counter);
    248 }/*}}}*/
     476        xDelete<IssmDouble>(counter);
     477}/*}}}*/
  • issm/trunk/src/c/Container/Observations.h

    r12330 r12706  
    66#define  _CONTAINER_OBSERVATIONS_H_
    77
    8 class Obsevration;
     8#include "../include/include.h"
     9
    910class Quadtree;
     11class Variogram;
    1012class Options;
    1113
     
    1921                /*constructors, destructors*/
    2022                Observations();
    21                 Observations(double* observations_list,double* x,double* y,int n,Options* options);
     23                Observations(IssmDouble* observations_list,IssmDouble* x,IssmDouble* y,int n,Options* options);
    2224                ~Observations();
    2325
    2426                /*Methods*/
    25                 void ObservationList(double **px,double **py,double **pobs,int* pnobs,double x_interp,double y_interp,double radius,int maxdata);
    26                 void QuadtreeColoring(double* A,double *x,double *y,int n);
    27                 void Variomap(double* gamma,double *x,int n);
     27                void ClosestObservation(IssmDouble *px,IssmDouble *py,IssmDouble *pobs,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius);
     28                void InterpolationIDW(IssmDouble *pprediction,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius,int mindata,int maxdata,IssmDouble power);
     29                void InterpolationKriging(IssmDouble *pprediction,IssmDouble *perror,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius,int mindata,int maxdata,Variogram* variogram);
     30                void InterpolationNearestNeighbor(IssmDouble *pprediction,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius);
     31                void ObservationList(IssmDouble **px,IssmDouble **py,IssmDouble **pobs,int* pnobs);
     32                void ObservationList(IssmDouble **px,IssmDouble **py,IssmDouble **pobs,int* pnobs,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius,int maxdata);
     33                void QuadtreeColoring(IssmDouble* A,IssmDouble *x,IssmDouble *y,int n);
     34                void Variomap(IssmDouble* gamma,IssmDouble *x,int n);
    2835
    2936};
  • issm/trunk/src/c/Container/Options.cpp

    r12330 r12706  
    44 */
    55
    6 /*Headers: {{{1*/
     6/*Headers: {{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2525
    2626/*Object constructors and destructor*/
    27 /*FUNCTION Options::Options(){{{1*/
     27/*FUNCTION Options::Options(){{{*/
    2828Options::Options(){
    2929        return;
    3030}
    3131/*}}}*/
    32 /*FUNCTION Options::~Options(){{{1*/
     32/*FUNCTION Options::~Options(){{{*/
    3333Options::~Options(){
    3434        return;
     
    3737
    3838/*Object management*/
    39 /*FUNCTION Options::AddOption{{{1*/
     39/*FUNCTION Options::AddOption{{{*/
    4040int  Options::AddOption(Option* in_option){
    4141
     
    4747
    4848        /*Also, check the option name*/
    49         if(!in_option->name) _error_("input option has an empty name");
    50         if(strchr(in_option->name,'.')) _error_("Option \"%s\" has a protected character \".\"",in_option->name);
    51         if(strchr(in_option->name,'[')) _error_("Option \"%s\" has a protected character \"[\"",in_option->name);
    52         if(strchr(in_option->name,']')) _error_("Option \"%s\" has a protected character \"]\"",in_option->name);
     49        if(!in_option->name) _error2_("input option has an empty name");
     50        if(strchr(in_option->name,'.')) _error2_("Option \"" << in_option->name << "\" has a protected character \".\"");
     51        if(strchr(in_option->name,'[')) _error2_("Option \"" << in_option->name << "\" has a protected character \"[\"");
     52        if(strchr(in_option->name,']')) _error2_("Option \"" << in_option->name << "\" has a protected character \"]\"");
    5353
    5454        /*Finally, check that no option of the same name already exists in the dataset*/
     
    5757                option=(Option*)(*object);
    5858                if (!strcmp(option->name,in_option->name)){
    59                         _error_("Options \"%s\" found multiple times",in_option->name);
     59                        _error2_("Options \"" << in_option->name << "\" found multiple times");
    6060                        break;
    6161                }
     
    6868}
    6969/*}}}*/
    70 /*FUNCTION Options::Get(int* pvalue, char* name){{{1*/
     70/*FUNCTION Options::Get(int* pvalue, char* name){{{*/
    7171void Options::Get(int* pvalue,const char* name){
    7272
     
    8383        /*Else, the Option does not exist, no default provided*/
    8484        else{
    85                 _error_("option of name \"%s\" not found, and no default value has been provided",name);
    86         }
    87 }
    88 /*}}}*/
    89 /*FUNCTION Options::Get(int* pvalue, char* name,int default_value){{{1*/
     85                _error2_("option of name \"" << name << "\" not found, and no default value has been provided");
     86        }
     87}
     88/*}}}*/
     89/*FUNCTION Options::Get(int* pvalue, char* name,int default_value){{{*/
    9090void Options::Get(int* pvalue,const char* name,int default_value){
    9191
     
    106106}
    107107/*}}}*/
    108 /*FUNCTION Options::Get(double* pvalue, char* name){{{1*/
    109 void Options::Get(double* pvalue,const char* name){
    110 
    111         vector<Object*>::iterator object;
    112         Option* option=NULL;
    113 
    114         /*Get option*/
    115         option=GetOption(name);
    116 
    117         /*If the pointer is not NULL, the option has been found*/
    118         if(option){
    119                 option->Get(pvalue);
    120         }
    121         /*Else, the Option does not exist, no default provided*/
    122         else{
    123                 _error_("option of name \"%s\" not found, and no default value has been provided",name);
    124         }
    125 }
    126 /*}}}*/
    127 /*FUNCTION Options::Get(double* pvalue, char* name,double default_value){{{1*/
    128 void Options::Get(double* pvalue,const char* name,double default_value){
     108/*FUNCTION Options::Get(IssmDouble* pvalue, char* name){{{*/
     109void Options::Get(IssmDouble* pvalue,const char* name){
     110
     111        vector<Object*>::iterator object;
     112        Option* option=NULL;
     113
     114        /*Get option*/
     115        option=GetOption(name);
     116
     117        /*If the pointer is not NULL, the option has been found*/
     118        if(option){
     119                option->Get(pvalue);
     120        }
     121        /*Else, the Option does not exist, no default provided*/
     122        else{
     123                _error2_("option of name \"" << name << "\" not found, and no default value has been provided");
     124        }
     125}
     126/*}}}*/
     127/*FUNCTION Options::Get(IssmDouble* pvalue, char* name,IssmDouble default_value){{{*/
     128void Options::Get(IssmDouble* pvalue,const char* name,IssmDouble default_value){
    129129
    130130        vector<Object*>::iterator object;
     
    144144}
    145145/*}}}*/
    146 /*FUNCTION Options::Get(bool* pvalue, char* name){{{1*/
     146/*FUNCTION Options::Get(bool* pvalue, char* name){{{*/
    147147void Options::Get(bool* pvalue,const char* name){
    148148
     
    159159        /*Else, the Option does not exist, no default provided*/
    160160        else{
    161                 _error_("option of name \"%s\" not found, and no default value has been provided",name);
    162         }
    163 }
    164 /*}}}*/
    165 /*FUNCTION Options::Get(bool* pvalue, char* name,bool default_value){{{1*/
     161                _error2_("option of name \"" << name << "\" not found, and no default value has been provided");
     162        }
     163}
     164/*}}}*/
     165/*FUNCTION Options::Get(bool* pvalue, char* name,bool default_value){{{*/
    166166void Options::Get(bool* pvalue,const char* name,bool default_value){
    167167
     
    182182}
    183183/*}}}*/
    184 /*FUNCTION Options::Get(char** pvalue, char* name){{{1*/
     184/*FUNCTION Options::Get(char** pvalue, char* name){{{*/
    185185void Options::Get(char** pvalue,const char* name){
    186186
     
    199199        /*Else, the Option does not exist, no default provided*/
    200200        else{
    201                 _error_("option of name \"%s\" not found, and no default value has been provided",name);
    202         }
    203 
    204 }
    205 /*}}}*/
    206 /*FUNCTION Options::Get(char** pvalue, char* name,char* default_value){{{1*/
     201                _error2_("option of name \"" << name << "\" not found, and no default value has been provided");
     202        }
     203
     204}
     205/*}}}*/
     206/*FUNCTION Options::Get(char** pvalue, char* name,char* default_value){{{*/
    207207void Options::Get(char** pvalue,const char* name,const char* default_value){
    208208
     
    222222        else{
    223223                stringsize=strlen(default_value)+1;
    224                 outstring=(char*)xmalloc(stringsize*sizeof(char));
    225                 memcpy(outstring,default_value,stringsize*sizeof(char));
     224                outstring=xNew<char>(stringsize);
     225                xMemCpy<char>(outstring,default_value,stringsize);
    226226                *pvalue=outstring;
    227227        }
     
    229229}
    230230/*}}}*/
    231 /*FUNCTION Options::Get(char*** ppvalue,int* numel,char* name){{{1*/
     231/*FUNCTION Options::Get(char*** ppvalue,int* numel,char* name){{{*/
    232232void Options::Get(char*** ppvalue,int* numel,const char* name){
    233233
     
    246246                if(option->ObjectEnum()==OptionCellEnum){
    247247                        if (option->NumEl()) {
    248                                 *ppvalue=(char **) xmalloc(option->NumEl()*sizeof(char *));
     248                                *ppvalue=xNew<char*>(option->NumEl());
    249249                                if (numel) *numel=option->NumEl();
    250250                                option->Get(&options);
     
    264264                /*Else: not supported*/
    265265                else{
    266                         _error_("Cannot recover field \"%s\" for an option of type %s",name,EnumToStringx(option->ObjectEnum()));
     266                        _error2_("Cannot recover field \"" << name << "\" for an option of type " << EnumToStringx(option->ObjectEnum()));
    267267                }
    268268        }
     
    275275}
    276276/*}}}*/
    277 /*FUNCTION Options::Get(double** pvalue,int* numel,const char* name){{{1*/
    278 void Options::Get(double** pvalue,int* numel,const char* name){
     277/*FUNCTION Options::Get(IssmDouble** pvalue,int* numel,const char* name){{{*/
     278void Options::Get(IssmDouble** pvalue,int* numel,const char* name){
    279279
    280280        vector<Object*>::iterator object;
     
    290290        /*Else, the Option does not exist, no default provided*/
    291291        else{
    292                 _error_("option of name \"%s\" not found, and no default value has been provided",name);
    293         }
    294 }
    295 /*}}}*/
    296 /*FUNCTION Options::GetOption{{{1*/
     292                _error2_("option of name \"" << name << "\" not found, and no default value has been provided");
     293        }
     294}
     295/*}}}*/
     296/*FUNCTION Options::GetOption{{{*/
    297297Option* Options::GetOption(const char* name){
    298298
     
    324324                                /*Else: not supported*/
    325325                                else{
    326                                         _error_("Cannot recover field \"%s\" for an option of type %s",name,EnumToStringx(option->ObjectEnum()));
     326                                        _error2_("Cannot recover field \"" << name << "\" for an option of type " << EnumToStringx(option->ObjectEnum()));
    327327                                }
    328328                        }
  • issm/trunk/src/c/Container/Options.h

    r12330 r12706  
    2020                int  AddOption(Option* in_oobject);
    2121                Option* GetOption(const char* name);
    22                 void Get(double*  pvalue,const char* name);
    23                 void Get(double*  pvalue,const char* name,double default_value);
     22                void Get(IssmDouble*  pvalue,const char* name);
     23                void Get(IssmDouble*  pvalue,const char* name,IssmDouble default_value);
    2424                void Get(int*  pvalue,const char* name);
    2525                void Get(int*  pvalue,const char* name,int default_value);
     
    2929                void Get(char**   pvalue,const char* name,const char* default_value);
    3030                void Get(char***  pvalue,int* numel,const char* name);
    31                 void Get(double** pvalue,int* numel,const char* name);
     31                void Get(IssmDouble** pvalue,int* numel,const char* name);
    3232};
    3333
  • issm/trunk/src/c/Container/Parameters.cpp

    r11995 r12706  
    44 */
    55
    6 /*Headers: {{{1*/
     6/*Headers: {{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2525
    2626/*Object constructors and destructor*/
    27 /*FUNCTION Parameters::Parameters(){{{1*/
     27/*FUNCTION Parameters::Parameters(){{{*/
    2828Parameters::Parameters(){
    2929        enum_type=ParametersEnum;
     
    3131}
    3232/*}}}*/
    33 /*FUNCTION Parameters::~Parameters(){{{1*/
     33/*FUNCTION Parameters::~Parameters(){{{*/
    3434Parameters::~Parameters(){
    3535        return;
     
    3838
    3939/*Object management*/
    40 /*FUNCTION Parameters::Exist{{{1*/
     40/*FUNCTION Parameters::Exist{{{*/
    4141bool Parameters::Exist(int enum_type){
    4242
     
    5151}
    5252/*}}}*/
    53 /*FUNCTION Parameters::FindParam(bool* pbool,int enum_type){{{1*/
     53/*FUNCTION Parameters::FindParam(bool* pbool,int enum_type){{{*/
    5454void Parameters::FindParam(bool* pbool,int enum_type){ _assert_(this);
    5555       
     
    6565                }
    6666        }
    67         _error_("could not find parameter %s",EnumToStringx(enum_type));
    68 }
    69 /*}}}*/
    70 /*FUNCTION Parameters::FindParam(int* pinteger,int enum_type){{{1*/
     67        _error2_("could not find parameter " << EnumToStringx(enum_type));
     68}
     69/*}}}*/
     70/*FUNCTION Parameters::FindParam(int* pinteger,int enum_type){{{*/
    7171void Parameters::FindParam(int* pinteger,int enum_type){ _assert_(this);
    7272       
     
    8282                }
    8383        }
    84         _error_("could not find parameter %s",EnumToStringx(enum_type));
    85 }
    86 /*}}}*/
    87 /*FUNCTION Parameters::FindParam(double* pscalar, int enum_type){{{1*/
    88 void Parameters::FindParam(double* pscalar, int enum_type){ _assert_(this);
     84        _error2_("could not find parameter " << EnumToStringx(enum_type));
     85}
     86/*}}}*/
     87/*FUNCTION Parameters::FindParam(IssmDouble* pscalar, int enum_type){{{*/
     88void Parameters::FindParam(IssmDouble* pscalar, int enum_type){ _assert_(this);
    8989       
    9090        vector<Object*>::iterator object;
     
    9999                }
    100100        }
    101         _error_("could not find parameter %s",EnumToStringx(enum_type));
    102 }
    103 /*}}}*/
    104 /*FUNCTION Parameters::FindParam(char** pstring,int enum_type){{{1*/
     101        _error2_("could not find parameter " << EnumToStringx(enum_type));
     102}
     103/*}}}*/
     104/*FUNCTION Parameters::FindParam(char** pstring,int enum_type){{{*/
    105105void Parameters::FindParam(char** pstring,int enum_type){ _assert_(this);
    106106       
     
    116116                }
    117117        }
    118         _error_("could not find parameter %s",EnumToStringx(enum_type));
    119 
    120 }
    121 /*}}}*/
    122 /*FUNCTION Parameters::FindParam(char*** pstringarray,int* pM,int enum_type){{{1*/
     118        _error2_("could not find parameter " << EnumToStringx(enum_type));
     119
     120}
     121/*}}}*/
     122/*FUNCTION Parameters::FindParam(char*** pstringarray,int* pM,int enum_type){{{*/
    123123void Parameters::FindParam(char*** pstringarray,int* pM,int enum_type){ _assert_(this);
    124124       
     
    134134                }
    135135        }
    136         _error_("could not find parameter %s",EnumToStringx(enum_type));
    137 
    138 }
    139 /*}}}*/
    140 /*FUNCTION Parameters::FindParam(int** pintarray,int* pM,int enum_type){{{1*/
     136        _error2_("could not find parameter " << EnumToStringx(enum_type));
     137
     138}
     139/*}}}*/
     140/*FUNCTION Parameters::FindParam(int** pintarray,int* pM,int enum_type){{{*/
    141141void Parameters::FindParam(int** pintarray,int* pM, int enum_type){ _assert_(this);
    142142
     
    152152                }
    153153        }
    154         _error_("could not find parameter %s",EnumToStringx(enum_type));
    155 
    156 }
    157 /*}}}*/
    158 /*FUNCTION Parameters::FindParam(int** pintarray,int* pM,int* pN,int enum_type){{{1*/
     154        _error2_("could not find parameter " << EnumToStringx(enum_type));
     155
     156}
     157/*}}}*/
     158/*FUNCTION Parameters::FindParam(int** pintarray,int* pM,int* pN,int enum_type){{{*/
    159159void Parameters::FindParam(int** pintarray,int* pM,int *pN,int enum_type){ _assert_(this);
    160160
     
    170170                }
    171171        }
    172         _error_("could not find parameter %s",EnumToStringx(enum_type));
    173 
    174 }
    175 /*}}}*/
    176 /*FUNCTION Parameters::FindParam(double** pdoublearray,int* pM,int enum_type){{{1*/
    177 void Parameters::FindParam(double** pdoublearray,int* pM, int enum_type){ _assert_(this);
    178 
    179         vector<Object*>::iterator object;
    180         Param* param=NULL;
    181 
    182         for ( object=objects.begin() ; object < objects.end(); object++ ){
    183 
    184                 param=(Param*)(*object);
    185                 if(param->InstanceEnum()==enum_type){
    186                         param->GetParameterValue(pdoublearray,pM);
    187                         return;
    188                 }
    189         }
    190         _error_("could not find parameter %s",EnumToStringx(enum_type));
    191 
    192 }
    193 /*}}}*/
    194 /*FUNCTION Parameters::FindParam(double** pdoublearray,int* pM, int* pN,int enum_type){{{1*/
    195 void Parameters::FindParam(double** pdoublearray,int* pM, int* pN,int enum_type){ _assert_(this);
    196 
    197         vector<Object*>::iterator object;
    198         Param* param=NULL;
    199 
    200         for ( object=objects.begin() ; object < objects.end(); object++ ){
    201 
    202                 param=(Param*)(*object);
    203                 if(param->InstanceEnum()==enum_type){
    204                         param->GetParameterValue(pdoublearray,pM,pN);
    205                         return;
    206                 }
    207         }
    208         _error_("could not find parameter %s",EnumToStringx(enum_type));
    209 
    210 }
    211 /*}}}*/
    212 /*FUNCTION Parameters::FindParam(double*** parray,int* pM,int** pmdims_array,int** pndims_array,int enum_type){{{1*/
    213 void Parameters::FindParam(double*** parray,int* pM,int** pmdims_array,int** pndims_array,int enum_type){ _assert_(this);
     172        _error2_("could not find parameter " << EnumToStringx(enum_type));
     173
     174}
     175/*}}}*/
     176/*FUNCTION Parameters::FindParam(IssmDouble** pIssmDoublearray,int* pM,int enum_type){{{*/
     177void Parameters::FindParam(IssmDouble** pIssmDoublearray,int* pM, int enum_type){ _assert_(this);
     178
     179        vector<Object*>::iterator object;
     180        Param* param=NULL;
     181
     182        for ( object=objects.begin() ; object < objects.end(); object++ ){
     183
     184                param=(Param*)(*object);
     185                if(param->InstanceEnum()==enum_type){
     186                        param->GetParameterValue(pIssmDoublearray,pM);
     187                        return;
     188                }
     189        }
     190        _error2_("could not find parameter " << EnumToStringx(enum_type));
     191
     192}
     193/*}}}*/
     194/*FUNCTION Parameters::FindParam(IssmDouble** pIssmDoublearray,int* pM, int* pN,int enum_type){{{*/
     195void Parameters::FindParam(IssmDouble** pIssmDoublearray,int* pM, int* pN,int enum_type){ _assert_(this);
     196
     197        vector<Object*>::iterator object;
     198        Param* param=NULL;
     199
     200        for ( object=objects.begin() ; object < objects.end(); object++ ){
     201
     202                param=(Param*)(*object);
     203                if(param->InstanceEnum()==enum_type){
     204                        param->GetParameterValue(pIssmDoublearray,pM,pN);
     205                        return;
     206                }
     207        }
     208        _error2_("could not find parameter " << EnumToStringx(enum_type));
     209
     210}
     211/*}}}*/
     212/*FUNCTION Parameters::FindParam(IssmDouble*** parray,int* pM,int** pmdims_array,int** pndims_array,int enum_type){{{*/
     213void Parameters::FindParam(IssmDouble*** parray,int* pM,int** pmdims_array,int** pndims_array,int enum_type){ _assert_(this);
    214214       
    215215        vector<Object*>::iterator object;
     
    224224                }
    225225        }
    226         _error_("could not find parameter %s",EnumToStringx(enum_type));
    227 }
    228 /*}}}*/
    229 /*FUNCTION Parameters::FindParam(Vector** pvec,int enum_type){{{1*/
     226        _error2_("could not find parameter " << EnumToStringx(enum_type));
     227}
     228/*}}}*/
     229/*FUNCTION Parameters::FindParam(Vector** pvec,int enum_type){{{*/
    230230void Parameters::FindParam(Vector** pvec,int enum_type){ _assert_(this);
    231231       
     
    241241                }
    242242        }
    243         _error_("could not find parameter %s",EnumToStringx(enum_type));
    244 
    245 }
    246 /*}}}*/
    247 /*FUNCTION Parameters::FindParam(Matrix** pmat,int enum_type){{{1*/
     243        _error2_("could not find parameter " << EnumToStringx(enum_type));
     244
     245}
     246/*}}}*/
     247/*FUNCTION Parameters::FindParam(Matrix** pmat,int enum_type){{{*/
    248248void Parameters::FindParam(Matrix** pmat,int enum_type){ _assert_(this);
    249249       
     
    259259                }
    260260        }
    261         _error_("could not find parameter %s",EnumToStringx(enum_type));
    262 
    263 }
    264 /*}}}*/
    265 /*FUNCTION Parameters::FindParam(FILE** pfid,int enum_type){{{1*/
     261        _error2_("could not find parameter " << EnumToStringx(enum_type));
     262
     263}
     264/*}}}*/
     265/*FUNCTION Parameters::FindParam(FILE** pfid,int enum_type){{{*/
    266266void Parameters::FindParam(FILE** pfid,int enum_type){ _assert_(this);
    267267
     
    277277                }
    278278        }
    279         _error_("could not find parameter %s",EnumToStringx(enum_type));
    280 }
    281 /*}}}*/
    282 
    283 /*FUNCTION Parameters::SetParam(bool boolean,int enum_type);{{{1*/
     279        _error2_("could not find parameter " << EnumToStringx(enum_type));
     280}
     281/*}}}*/
     282
     283/*FUNCTION Parameters::SetParam(bool boolean,int enum_type);{{{*/
    284284void   Parameters::SetParam(bool boolean,int enum_type){
    285285
     
    293293}
    294294/*}}}*/
    295 /*FUNCTION Parameters::SetParam(int integer,int enum_type);{{{1*/
     295/*FUNCTION Parameters::SetParam(int integer,int enum_type);{{{*/
    296296void   Parameters::SetParam(int integer,int enum_type){
    297297
     
    305305}
    306306/*}}}*/
    307 /*FUNCTION Parameters::SetParam(double scalar,int enum_type);{{{1*/
    308 void   Parameters::SetParam(double scalar,int enum_type){
     307/*FUNCTION Parameters::SetParam(IssmDouble scalar,int enum_type);{{{*/
     308void   Parameters::SetParam(IssmDouble scalar,int enum_type){
    309309
    310310        Param* param=NULL;
     
    317317}
    318318/*}}}*/
    319 /*FUNCTION Parameters::SetParam(char* string,int enum_type);{{{1*/
     319/*FUNCTION Parameters::SetParam(char* string,int enum_type);{{{*/
    320320void   Parameters::SetParam(char* string,int enum_type){
    321321
     
    329329}
    330330/*}}}*/
    331 /*FUNCTION Parameters::SetParam(char** stringarray,int M, int enum_type);{{{1*/
     331/*FUNCTION Parameters::SetParam(char** stringarray,int M, int enum_type);{{{*/
    332332void   Parameters::SetParam(char** stringarray,int M, int enum_type){
    333333
     
    341341}
    342342/*}}}*/
    343 /*FUNCTION Parameters::SetParam(double* doublearray,int M,int enum_type);{{{1*/
    344 void   Parameters::SetParam(double* doublearray,int M, int enum_type){
    345 
    346         Param* param=NULL;
    347        
    348         /*first, figure out if the param has already been created: */
    349         param=(Param*)this->FindParamObject(enum_type);
    350 
    351         if(param) param->SetValue(doublearray,M); //already exists, just set it.
    352         else this->AddObject(new DoubleVecParam(enum_type,doublearray,M)); //just add the new parameter.
    353 }
    354 /*}}}*/
    355 /*FUNCTION Parameters::SetParam(double* doublearray,int M,int N, int enum_type);{{{1*/
    356 void   Parameters::SetParam(double* doublearray,int M, int N, int enum_type){
    357 
    358         Param* param=NULL;
    359        
    360         /*first, figure out if the param has already been created: */
    361         param=(Param*)this->FindParamObject(enum_type);
    362 
    363         if(param) param->SetValue(doublearray,M,N); //already exists, just set it.
    364         else this->AddObject(new DoubleMatParam(enum_type,doublearray,M,N)); //just add the new parameter.
    365 }
    366 /*}}}*/
    367 /*FUNCTION Parameters::SetParam(int* intarray,int M,int enum_type);{{{1*/
     343/*FUNCTION Parameters::SetParam(IssmDouble* IssmDoublearray,int M,int enum_type);{{{*/
     344void   Parameters::SetParam(IssmDouble* IssmDoublearray,int M, int enum_type){
     345
     346        Param* param=NULL;
     347       
     348        /*first, figure out if the param has already been created: */
     349        param=(Param*)this->FindParamObject(enum_type);
     350
     351        if(param) param->SetValue(IssmDoublearray,M); //already exists, just set it.
     352        else this->AddObject(new DoubleVecParam(enum_type,IssmDoublearray,M)); //just add the new parameter.
     353}
     354/*}}}*/
     355/*FUNCTION Parameters::SetParam(IssmDouble* IssmDoublearray,int M,int N, int enum_type);{{{*/
     356void   Parameters::SetParam(IssmDouble* IssmDoublearray,int M, int N, int enum_type){
     357
     358        Param* param=NULL;
     359       
     360        /*first, figure out if the param has already been created: */
     361        param=(Param*)this->FindParamObject(enum_type);
     362
     363        if(param) param->SetValue(IssmDoublearray,M,N); //already exists, just set it.
     364        else this->AddObject(new DoubleMatParam(enum_type,IssmDoublearray,M,N)); //just add the new parameter.
     365}
     366/*}}}*/
     367/*FUNCTION Parameters::SetParam(int* intarray,int M,int enum_type);{{{*/
    368368void   Parameters::SetParam(int* intarray,int M, int enum_type){
    369369
     
    377377}
    378378/*}}}*/
    379 /*FUNCTION Parameters::SetParam(int* intarray,int M,int N, int enum_type);{{{1*/
     379/*FUNCTION Parameters::SetParam(int* intarray,int M,int N, int enum_type);{{{*/
    380380void   Parameters::SetParam(int* intarray,int M, int N, int enum_type){
    381381
     
    389389}
    390390/*}}}*/
    391 /*FUNCTION Parameters::SetParam(Vector* vector,int enum_type);{{{1*/
     391/*FUNCTION Parameters::SetParam(Vector* vector,int enum_type);{{{*/
    392392void   Parameters::SetParam(Vector* vector,int enum_type){
    393393
     
    401401}
    402402/*}}}*/
    403 /*FUNCTION Parameters::SetParam(Matrix* matrix,int enum_type);{{{1*/
     403/*FUNCTION Parameters::SetParam(Matrix* matrix,int enum_type);{{{*/
    404404void   Parameters::SetParam(Matrix* matrix,int enum_type){
    405405
     
    413413}
    414414/*}}}*/
    415 /*FUNCTION Parameters::SetParam(FILE* fid,int enum_type);{{{1*/
     415/*FUNCTION Parameters::SetParam(FILE* fid,int enum_type);{{{*/
    416416void   Parameters::SetParam(FILE* fid,int enum_type){
    417417
     
    425425}
    426426/*}}}*/
    427 /*FUNCTION Parameters::UnitConversion(int direction_enum);{{{1*/
     427/*FUNCTION Parameters::UnitConversion(int direction_enum);{{{*/
    428428void   Parameters::UnitConversion(int direction_enum){
    429429
     
    439439/*}}}*/
    440440
    441 /*FUNCTION Parameters::FindParamObject{{{1*/
     441/*FUNCTION Parameters::FindParamObject{{{*/
    442442Object* Parameters::FindParamObject(int enum_type){
    443443
  • issm/trunk/src/c/Container/Parameters.h

    r12330 r12706  
    2323        public:
    2424
    25                 /*constructors, destructors: {{{1*/
     25                /*constructors, destructors: {{{*/
    2626                Parameters();
    2727                ~Parameters();
    2828                /*}}}*/
    29                 /*numerics: {{{1*/
     29                /*numerics: {{{*/
    3030                bool  Exist(int enum_type);
    3131
    3232                void  FindParam(bool* pinteger,int enum_type);
    3333                void  FindParam(int* pinteger,int enum_type);
    34                 void  FindParam(double* pscalar, int enum_type);
     34                void  FindParam(IssmDouble* pscalar, int enum_type);
    3535                void  FindParam(char** pstring,int enum_type);
    3636                void  FindParam(char*** pstringarray,int* pM,int enum_type);
    3737                void  FindParam(int** pintarray,int* pM,int enum_type);
    3838                void  FindParam(int** pintarray,int* pM,int* PN,int enum_type);
    39                 void  FindParam(double** pdoublearray,int* pM,int enum_type);
    40                 void  FindParam(double** pdoublearray,int* pM,int* pN,int enum_type);
    41                 void  FindParam(double*** parray,int* pM, int** pmdims_array,int** pndims_array,int enum_type);
     39                void  FindParam(IssmDouble** pIssmDoublearray,int* pM,int enum_type);
     40                void  FindParam(IssmDouble** pIssmDoublearray,int* pM,int* pN,int enum_type);
     41                void  FindParam(IssmDouble*** parray,int* pM, int** pmdims_array,int** pndims_array,int enum_type);
    4242                void  FindParam(Vector** pvec,int enum_type);
    4343                void  FindParam(Matrix** pmat,int enum_type);
     
    4646                void  SetParam(bool boolean,int enum_type);
    4747                void  SetParam(int integer,int enum_type);
    48                 void  SetParam(double scalar, int enum_type);
     48                void  SetParam(IssmDouble scalar, int enum_type);
    4949                void  SetParam(char* string,int enum_type);
    5050                void  SetParam(char** stringarray,int M,int enum_type);
    51                 void  SetParam(double* doublearray,int M,int enum_type);
    52                 void  SetParam(double* doublearray,int M,int N,int enum_type);
     51                void  SetParam(IssmDouble* IssmDoublearray,int M,int enum_type);
     52                void  SetParam(IssmDouble* IssmDoublearray,int M,int N,int enum_type);
    5353                void  SetParam(int* intarray,int M,int enum_type);
    5454                void  SetParam(int* intarray,int M,int N,int enum_type);
  • issm/trunk/src/c/Container/Results.cpp

    r12330 r12706  
    44 */
    55
    6 /*Headers: {{{1*/
     6/*Headers: {{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2525
    2626/*Object constructors and destructor*/
    27 /*FUNCTION Results::Results(){{{1*/
     27/*FUNCTION Results::Results(){{{*/
    2828Results::Results(){
    2929        enum_type=ResultsEnum;
     
    3131}
    3232/*}}}*/
    33 /*FUNCTION Results::~Results(){{{1*/
     33/*FUNCTION Results::~Results(){{{*/
    3434Results::~Results(){
    3535        return;
     
    3838
    3939/*Object management*/
    40 /*FUNCTION Results::SpawnTriaResults{{{1*/
     40/*FUNCTION Results::SpawnTriaResults{{{*/
    4141Results* Results::SpawnTriaResults(int* indices){
    4242
     
    6464}
    6565/*}}}*/
    66 /*FUNCTION Results::Write{{{1*/
     66/*FUNCTION Results::Write{{{*/
    6767void Results::Write(Parameters* parameters){
    6868       
  • issm/trunk/src/c/Container/Results.h

    r12330 r12706  
    2020        public:
    2121
    22                 /*constructors, destructors: {{{1*/
     22                /*constructors, destructors: {{{*/
    2323                Results();
    2424                ~Results();
    2525                /*}}}*/
    26                 /*numerics: {{{1*/
     26                /*numerics: {{{*/
    2727                Results* SpawnTriaResults(int* indices);
    2828                void Write(Parameters* parameters);
  • issm/trunk/src/c/Container/Vertices.cpp

    r12330 r12706  
    44 */
    55
    6 /*Headers: {{{1*/
     6/*Headers: {{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2525
    2626/*Object constructors and destructor*/
    27 /*FUNCTION Vertices::Vertices(){{{1*/
     27/*FUNCTION Vertices::Vertices(){{{*/
    2828Vertices::Vertices(){
    2929        enum_type=VerticesEnum;
     
    3131}
    3232/*}}}*/
    33 /*FUNCTION Vertices::~Vertices(){{{1*/
     33/*FUNCTION Vertices::~Vertices(){{{*/
    3434Vertices::~Vertices(){
    3535        return;
     
    3838
    3939/*Numerics management*/
    40 /*FUNCTION Vertices::DistributeDofs{{{1*/
     40/*FUNCTION Vertices::DistributeDofs{{{*/
    4141void  Vertices::DistributeDofs(int numberofobjects,int numberofdofsperobject){
    4242
     
    6060         * cpus by the total last dofs of the previus cpu, starting from 0.
    6161         * First: bet number of dofs for each cpu*/
    62         alldofcount=(int*)xmalloc(num_procs*sizeof(int));
     62        alldofcount=xNew<int>(num_procs);
    6363        #ifdef _HAVE_MPI_
    6464        MPI_Gather(&dofcount,1,MPI_INT,alldofcount,1,MPI_INT,0,MPI_COMM_WORLD);
     
    8383         * object that is not a clone, tell them to show their dofs, so that later on, they can get picked
    8484         * up by their clones: */
    85         truedofs   =(int*)xcalloc(numberofobjects*numberofdofsperobject,sizeof(int));
    86         alltruedofs=(int*)xcalloc(numberofobjects*numberofdofsperobject,sizeof(int));
     85        truedofs   =xNewZeroInit<int>(numberofobjects*numberofdofsperobject);
     86        alltruedofs=xNewZeroInit<int>(numberofobjects*numberofdofsperobject);
    8787        for (i=0;i<this->Size();i++){
    8888                Vertex* vertex=(Vertex*)this->GetObjectByOffset(i);
     
    102102
    103103        /* Free ressources: */
    104         xfree((void**)&alldofcount);
    105         xfree((void**)&truedofs);
    106         xfree((void**)&alltruedofs);
     104        xDelete<int>(alldofcount);
     105        xDelete<int>(truedofs);
     106        xDelete<int>(alltruedofs);
    107107}
    108108/*}}}*/
    109 /*FUNCTION Vertices::FlagClones{{{1*/
     109/*FUNCTION Vertices::FlagClones{{{*/
    110110void  Vertices::FlagClones(int numberofobjects){
    111111
     
    117117
    118118        /*Allocate ranks: */
    119         ranks=(int*)xmalloc(numberofobjects*sizeof(int));
    120         minranks=(int*)xmalloc(numberofobjects*sizeof(int));
     119        ranks=xNew<int>(numberofobjects);
     120        minranks=xNew<int>(numberofobjects);
    121121
    122122        for(i=0;i<numberofobjects;i++)ranks[i]=num_procs; //no cpu can have rank num_procs. This is the maximum limit.
     
    143143
    144144        /*Free ressources: */
    145         xfree((void**)&ranks);
    146         xfree((void**)&minranks);
     145        xDelete<int>(ranks);
     146        xDelete<int>(minranks);
    147147
    148148}
    149149/*}}}*/
    150 /*FUNCTION Vertices::NumberOfVertices{{{1*/
     150/*FUNCTION Vertices::NumberOfVertices{{{*/
    151151int Vertices::NumberOfVertices(void){
    152152
     
    174174}
    175175/*}}}*/
    176 /*FUNCTION Vertices::Ranks{{{1*/
     176/*FUNCTION Vertices::Ranks{{{*/
    177177void   Vertices::Ranks(int* ranks){
    178178
  • issm/trunk/src/c/Container/Vertices.h

    r12330 r12706  
    1919        public:
    2020
    21                 /*constructors, destructors: {{{1*/
     21                /*constructors, destructors: {{{*/
    2222                Vertices();
    2323                ~Vertices();
    2424                /*}}}*/
    25                 /*numerics: {{{1*/
     25                /*numerics: {{{*/
    2626                void  DistributeDofs(int numberofnodes,int numdofspernode);
    2727                void  FlagClones(int numberofnodes);
  • issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h

    r12330 r12706  
    149149        SettingsResultsAsPatchesEnum,
    150150        SettingsWaitonlockEnum,
    151         DebugPetscProfilingEnum,
    152         PetscProfilingCurrentMemEnum,
    153         PetscProfilingCurrentFlopsEnum,
    154         PetscProfilingSolutionTimeEnum,
     151        DebugProfilingEnum,
     152        ProfilingCurrentMemEnum,
     153        ProfilingCurrentFlopsEnum,
     154        ProfilingSolutionTimeEnum,
    155155        MaxIterationConvergenceFlagEnum,
    156156        SteadystateMaxiterEnum,
     
    162162        SurfaceforcingsMassBalanceEnum,
    163163        SurfaceforcingsIspddEnum,
     164        SurfaceforcingsIssmbgradientsEnum,
    164165        SurfaceforcingsMonthlytemperaturesEnum,
     166        SurfaceforcingsHcEnum,
     167        SurfaceforcingsSmbPosMaxEnum,
     168        SurfaceforcingsSmbPosMinEnum,
     169        SurfaceforcingsAPosEnum,
     170        SurfaceforcingsBPosEnum,
     171        SurfaceforcingsANegEnum,
     172        SurfaceforcingsBNegEnum,
    165173        ThermalMaxiterEnum,
    166174        ThermalPenaltyFactorEnum,
  • issm/trunk/src/c/EnumDefinitions/Synchronize.sh

    r12347 r12706  
    22#Synchronize EnumToStringx.cpp and StringToEnumx.cpp and matlab Enums
    33
    4 #Get all lines of EnumDefinitions2.h which hold Enum | remove all comas > put everything in file temp
     4#Get all lines of EnumDefinitions2.h which hold Enum | remove all commas > put everything in file temp
    55cat EnumDefinitions.h | grep -e "[0-9]Enum," -e "[a-zA-Z]Enum," | grep -v include | sed -e "s/,/ /g" | awk '{print $1}' > temp
    66
    77#Removed existing files
    88rm $ISSM_DIR/src/m/enum/*.m
     9rm $ISSM_DIR/src/m/enum/*.py
    910rm $ISSM_DIR/src/c/modules/EnumToStringx/EnumToStringx.cpp
    1011rm $ISSM_DIR/src/c/modules/StringToEnumx/StringToEnumx.cpp
     
    4849
    4950        len=strlen(EnumToStringx(enum_in));
    50         string=(char*)xmalloc((len+1)*sizeof(char));
     51        string=xNew<char>(len+1);
    5152        memcpy(string,EnumToStringx(enum_in),(len+1)*sizeof(char));
    5253
     
    5657END
    5758#}}}
    58 #Build StringToEnumx.cpp {{{1
     59#Build StringToEnumx.cpp {{{
    5960#Header
    6061cat <<END > $ISSM_DIR/src/c/modules/StringToEnumx/StringToEnumx.cpp
     
    9798cat <<END >> $ISSM_DIR/src/c/modules/StringToEnumx/StringToEnumx.cpp
    9899        /*If we reach this point, the string provided has not been found*/
    99    _error_("Enum %s not found",name);
     100        _error2_("Enum " << name << " not found");
    100101}
    101102END
     
    104105# go through the lines of temp
    105106ENUM=0;
     107#Add header to pythonenum file{{{
     108cat <<END > $ISSM_DIR/src/m/enum/EnumDefinitions.py
     109"""
     110
     111   WARNING: DO NOT MODIFY THIS FILE
     112            this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh
     113            Please read src/c/EnumDefinitions/README for more information
     114
     115"""
     116
     117END
     118#}}}
     119
    106120for NAMEENUM in $(cat temp); do
    107121
     
    142156END
    143157#}}}
     158        #Add case to pythonenum file{{{
     159        cat <<END >> $ISSM_DIR/src/m/enum/EnumDefinitions.py
     160def $(echo $NAMEENUM)():
     161        """
     162        $(echo $NAMEENUM | awk {'print toupper($1)'}) - Enum of $(echo $NAME)
     163
     164           Usage:
     165              macro=$NAMEENUM()
     166        """
     167
     168        return StringToEnum('$NAME')
     169
     170END
     171#}}}
    144172
    145173done
    146 #MaximumNumberOfEnums{{{
     174#MaximumNumberOfEnums (matlab){{{
    147175cat <<END > $ISSM_DIR/src/m/enum/MaximumNumberOfEnums.m
    148176function macro=MaximumNumberOfEnums()
     
    161189END
    162190#}}}
     191#MaximumNumberOfEnums (python){{{
     192cat <<END >> $ISSM_DIR/src/m/enum/EnumDefinitions.py
     193def MaximumNumberOfEnums():
     194        """
     195        $(echo "MaximumNumberOfEnums" | awk {'print toupper($1)'}) - Enum of MaximumNumberOfEnums
     196
     197           Usage:
     198              macro=MaximumNumberOfEnums()
     199        """
     200
     201        return $(cat EnumDefinitions.h | grep -e "[0-9]Enum" -e "[a-zA-Z]Enum" | grep -v include \
     202                | awk '{ printf "%s %s\n", NR-1, $0 }' \
     203                | grep "MaximumNumberOfEnums" | awk '{print $1}')
     204
     205END
     206#}}}
    163207
    164208#clean up{{{
  • issm/trunk/src/c/Makefile.am

    r12640 r12706  
    1 INCLUDES = @DAKOTAINCL@ @SHAPELIBINCL@ @PETSCINCL@ @SLEPCINCL@ @MPIINCL@ @MATLABINCL@ @METISINCL@ @CHACOINCL@ @SCOTCHINCL@ @PLAPACKINCL@ @BLASLAPACKINCL@ @MKLINCL@ @MUMPSINCL@ @TRIANGLEINCL@ @HYPREINCL@ @MLINCL@ @TAOINCL@ @ADIC2INCL@ @ADOLCINCL@ @GSLINCL@ @BOOSTINCL@ @PYTHONINCL@ @PYTHON_NUMPYINCL@
     1INCLUDES = @DAKOTAINCL@ @SHAPELIBINCL@ @PETSCINCL@ @SLEPCINCL@ @MPIINCL@ @MATLABINCL@ @METISINCL@ @CHACOINCL@ @SCOTCHINCL@ @PLAPACKINCL@ @BLASLAPACKINCL@ @MKLINCL@ @MUMPSINCL@ @TRIANGLEINCL@ @SPAIINCL@ @HYPREINCL@ @PROMETHEUSINCL@ @SUPERLUINCL@ @SPOOLESINCL@ @PASTIXINCL@ @MLINCL@ @TAOINCL@ @ADIC2INCL@ @ADOLCINCL@ @GSLINCL@ @BOOSTINCL@ @PYTHONINCL@ @PYTHON_NUMPYINCL@
    22
    33EXEEXT=$(ISSMEXT)
    44
    5 #Library declaration {{{1
     5#Library declaration {{{
    66lib_LIBRARIES = libISSMCore.a libISSMOverload.a
    77if PYTHON
     
    1717
    1818#sources
    19 #Core sources{{{1
     19#Core sources{{{
    2020core_sources = ./issm.h\
    2121                                        ./issm-binding.h\
     
    176176                                        ./shared/Alloc/alloc.h\
    177177                                        ./shared/Alloc/alloc.cpp\
     178                                        ./shared/Alloc/xNewDelete.h\
     179                                        ./shared/MemOps/xMemCpy.h\
    178180                                        ./shared/Matrix/matrix.h\
    179181                                        ./shared/Matrix/MatrixUtils.cpp\
    180                                         ./shared/Dofs/dofs.h\
    181                                         ./shared/Dofs/dofsetgen.cpp\
    182182                                        ./shared/Numerics/numerics.h\
    183183                                        ./shared/Numerics/Verbosity.h\
     
    210210                                        ./shared/Wrapper/ModuleBoot.cpp\
    211211                                        ./shared/Wrapper/ModuleEnd.cpp\
     212                                        ./shared/Sys/sys.h\
     213                                        ./shared/Sys/ProfilingStart.cpp\
     214                                        ./shared/Sys/ProfilingEnd.cpp\
    212215                                        ./toolkits/metis/metisincludes.h\
    213216                                        ./toolkits/issm/issmtoolkit.h\
     
    285288                                        ./modules/PositiveDegreeDayx/PositiveDegreeDayx.h\
    286289                                        ./modules/PositiveDegreeDayx/PositiveDegreeDayx.cpp\
     290                                        ./modules/SmbGradientsx/SmbGradientsx.h\
     291                                        ./modules/SmbGradientsx/SmbGradientsx.cpp\
    287292                                        ./modules/UpdateConstraintsx/UpdateConstraintsx.h\
    288293                                        ./modules/UpdateConstraintsx/UpdateConstraintsx.cpp\
     
    330335                                        ./solvers/solver_linear.cpp\
    331336                                        ./solvers/solver_nonlinear.cpp\
    332                                         ./solvers/solver_newton.cpp
    333 #}}}
    334 #DAKOTA sources  {{{1
     337                                        ./solvers/solver_newton.cpp\
     338                                        ./objects/Options/Option.cpp\
     339                                        ./objects/Options/Option.h\
     340                                        ./objects/Options/OptionDouble.cpp\
     341                                        ./objects/Options/OptionDouble.h\
     342                                        ./objects/Options/OptionChar.cpp\
     343                                        ./objects/Options/OptionChar.h\
     344                                        ./objects/Options/OptionUtilities.cpp\
     345                                        ./objects/Options/OptionUtilities.h
     346
     347#}}}
     348#DAKOTA sources  {{{
    335349dakota_sources = ./objects/DakotaPlugin.h\
    336350                                          ./objects/DakotaPlugin.cpp\
     
    356370                                          ./modules/Dakotax/SpawnCoreParallel.cpp
    357371#}}}
    358 #Transient sources  {{{1
     372#Transient sources  {{{
    359373transient_sources  = ./modules/ModelProcessorx/Transient/UpdateElementsTransient.cpp \
    360374                                         ./solutions/transient_core.cpp
    361375#}}}
    362 #Steadystate sources  {{{1
     376#Steadystate sources  {{{
    363377steadystate_sources = ./solutions/steadystate_core.cpp\
    364378                                          ./solutions/steadystateconvergence.cpp
    365379#}}}
    366 #Prognostic sources  {{{1
     380#Prognostic sources  {{{
    367381prognostic_sources = ./modules/ModelProcessorx/Prognostic/UpdateElementsPrognostic.cpp\
    368382                                              ./modules/ModelProcessorx/Prognostic/CreateNodesPrognostic.cpp\
     
    371385                                                  ./solutions/prognostic_core.cpp
    372386#}}}
    373 #Thermal sources  {{{1
     387#Thermal sources  {{{
    374388thermal_sources = ./modules/ModelProcessorx/Thermal/UpdateElementsThermal.cpp\
    375389                                           ./modules/ModelProcessorx/Thermal/CreateNodesThermal.cpp\
     
    391405                                           ./solvers/solver_thermal_nonlinear.cpp
    392406#}}}
    393 #Control sources  {{{1
     407#Control sources  {{{
    394408control_sources= ./modules/ControlInputGetGradientx/ControlInputGetGradientx.cpp\
    395409                                          ./modules/ControlInputGetGradientx/ControlInputGetGradientx.h\
     
    446460
    447461#}}}
    448 #Hydrology sources  {{{1
     462#Hydrology sources  {{{
    449463hydrology_sources  = ./modules/ModelProcessorx/Hydrology/UpdateElementsHydrology.cpp\
    450464                                              ./modules/ModelProcessorx/Hydrology/CreateNodesHydrology.cpp\
     
    454468                                                  ./solutions/hydrology_core_step.cpp
    455469#}}}
    456 #Diagnostic sources  {{{1
     470#Diagnostic sources  {{{
    457471diagnostic_sources = ./modules/ModelProcessorx/DiagnosticHoriz/UpdateElementsDiagnosticHoriz.cpp\
    458472                                              ./modules/ModelProcessorx/DiagnosticHoriz/CreateNodesDiagnosticHoriz.cpp \
     
    475489                                                  ./solvers/solver_stokescoupling_nonlinear.cpp
    476490#}}}
    477 #Balanced sources  {{{1
     491#Balanced sources  {{{
    478492balanced_sources = ./modules/ModelProcessorx/Balancethickness/UpdateElementsBalancethickness.cpp\
    479493                                            ./modules/ModelProcessorx/Balancethickness/CreateNodesBalancethickness.cpp\
     
    482496                                                ./solutions/balancethickness_core.cpp
    483497#}}}
    484 #Responses sources  {{{1
     498#Responses sources  {{{
    485499responses_sources = ./modules/MinVelx/MinVelx.h\
    486500                                             ./modules/MinVelx/MinVelx.cpp\
     
    512526                                             ./modules/MassFluxx/MassFluxx.h
    513527#}}}
    514 #Slope sources  {{{1
     528#Slope sources  {{{
    515529slope_sources =  ./modules/ModelProcessorx/BedSlope/UpdateElementsBedSlope.cpp\
    516530                                          ./modules/ModelProcessorx/BedSlope/CreateNodesBedSlope.cpp \
     
    524538                                          ./solutions/bedslope_core.cpp
    525539#}}}
    526 #Groundingline sources  {{{1
     540#Groundingline sources  {{{
    527541groundingline_sources= ./modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp\
    528542                                                ./modules/GroundinglineMigrationx/GroundinglineMigrationx.h
    529543#}}}
    530 #Rifts sources  {{{1
     544#Rifts sources  {{{
    531545rifts_sources = ./objects/Loads/Riftfront.cpp\
    532546                                    ./objects/Loads/Riftfront.h\
    533547                                    ./modules/ConstraintsStatex/RiftConstraintsState.cpp
    534548#}}}
    535 #3D sources  {{{1
     549#3D sources  {{{
    536550threed_sources = ./objects/Gauss/GaussPenta.h\
    537551                                     ./objects/Gauss/GaussPenta.cpp\
     
    547561                                     ./objects/Elements/PentaRef.cpp
    548562#}}}
    549 #Bamg sources  {{{1
     563#Bamg sources  {{{
    550564bamg_sources =  ./objects/Bamg/BamgGeom.h\
    551565                                ./objects/Bamg/BamgGeom.cpp\
     
    613627                                ./modules/BamgTriangulatex/BamgTriangulatex.h
    614628#}}}
    615 #Kriging sources  {{{1
     629#Kriging sources  {{{
    616630kriging_sources = ./Container/Observations.h\
    617631                                                ./Container/Observations.cpp\
     
    632646                                                ./modules/Krigingx/Krigingx.h
    633647
    634 #}}}
    635 #Kml sources  {{{1
     648#For parallel kriging, only difference is ./modules/Krigingx/pKrigingx.cpp with no multithreading
     649pkriging_sources = ./Container/Observations.h\
     650                                                ./Container/Observations.cpp\
     651                                                ./objects/Kriging/Variogram.h \
     652                                                ./objects/Kriging/GaussianVariogram.h\
     653                                                ./objects/Kriging/GaussianVariogram.cpp\
     654                                                ./objects/Kriging/ExponentialVariogram.h\
     655                                                ./objects/Kriging/ExponentialVariogram.cpp\
     656                                                ./objects/Kriging/SphericalVariogram.h\
     657                                                ./objects/Kriging/SphericalVariogram.cpp\
     658                                                ./objects/Kriging/PowerVariogram.h\
     659                                                ./objects/Kriging/PowerVariogram.cpp\
     660                                                ./objects/Kriging/Quadtree.h\
     661                                                ./objects/Kriging/Quadtree.cpp\
     662                                                ./objects/Kriging/Observation.h\
     663                                                ./objects/Kriging/Observation.cpp\
     664                                                ./modules/Krigingx/pKrigingx.cpp\
     665                                                ./modules/Krigingx/Krigingx.h
     666
     667#}}}
     668#Kml sources  {{{
    636669kml_sources = ./modules/Exp2Kmlx/Exp2Kmlx.h\
    637670                             ./modules/Exp2Kmlx/Exp2Kmlx.cpp\
     
    701734                             ./objects/KML/KMLFileReadUtils.h
    702735#}}}
    703 #Petsc sources  {{{1
     736#Petsc sources  {{{
    704737petsc_sources= ./toolkits/petsc\
    705738                                        ./toolkits/petsc/patches\
     
    736769
    737770#}}}
    738 #Gsl sources  {{{1
     771#Gsl sources  {{{
    739772gsl_sources= ./modules/Solverx/SolverxGsl.cpp
    740 
    741 #}}}
    742 #Mpi sources  {{{1
     773#}}}
     774#Mpi sources  {{{
    743775mpi_sources= ./toolkits/mpi/mpiincludes.h\
    744776                                ./toolkits/mpi/patches/mpipatches.h\
     
    748780                                ./toolkits/mpi/patches/MPI_Boundariesfromrange.cpp
    749781#}}}
    750 #Metis sources  {{{1
     782#Metis sources  {{{
    751783metis_sources= ./toolkits/metis/patches/metispatches.h\
    752784                                        ./toolkits/metis/patches/METIS_PartMeshNodalPatch.cpp
    753785#}}}
    754 #Python sources  {{{1
     786#Python sources  {{{
    755787python_sources=     ./python/io/pythonio.h\
    756788                                        ./python/python-binding.h\
     
    760792
    761793#}}}
    762 #Matlab sources  {{{1
     794#Matlab sources  {{{
    763795matlab_sources= ./toolkits/matlab/matlabincludes.h\
    764796                                    ./matlab/matlab-binding.h\
     
    777809                                         ./matlab/io/MatlabVectorToSeqVec.cpp
    778810#}}}
    779 #Matlab and Petsc sources  {{{1
     811#Matlab and Petsc sources  {{{
    780812matlabpetsc_sources= ./matlab/io/MatlabMatrixToPetscMatrix.cpp\
    781813                                         ./matlab/io/MatlabVectorToPetscVector.cpp
    782814       
    783815#}}}
    784 #Modules sources{{{1
     816#Modules sources{{{
    785817module_sources= ./objects/Options/Option.cpp\
    786818                        ./objects/Options/Option.h\
     
    870902#}}}
    871903
    872 #{{{1 Conditional build-up of sources
     904#{{{ Conditional build-up of sources
    873905#ISSM sources are a combination of core sources and sources related to specific capabilities (which can
    874906#be activated by autotools conditionals
    875 
    876907
    877908#First the core
     
    957988endif
    958989
    959 
    960 #}}}
    961 #Library flags and sources {{{1
     990if KRIGING
     991issm_sources +=  $(pkriging_sources)
     992endif
     993#}}}
     994#Library flags and sources {{{
    962995ALLCXXFLAGS= -fPIC -D_GNU_SOURCE -fno-omit-frame-pointer -pthread -D_CPP_  $(CXXFLAGS) $(CXXOPTFLAGS)
    963996
     
    9841017
    9851018#}}}
    986 #Overload library, to overload any non-standard symbols. {{{1
     1019#Overload library, to overload any non-standard symbols. {{{
    9871020libISSMOverload_a_SOURCES = ./shared/String/stricmp.c
    9881021libISSMOverload_a_CFLAGS  = -fPIC -D_C_ $(COPTFLAGS) $(CFLAGS)
    9891022#}}}
    9901023
    991 #Executable {{{1
     1024#Executable {{{
    9921025bin_PROGRAMS = issm
    9931026
     
    9961029
    9971030#External packages
    998 LDADD += $(PETSCLIB) $(TAOLIB) $(PLAPACKLIB) $(MUMPSLIB) $(SCALAPACKLIB) $(BLACSLIB) $(HYPRELIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MKLLIB) $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(OSLIBS) $(GSLLIB)
     1031LDADD += $(PETSCLIB) $(TAOLIB) $(PLAPACKLIB) $(MUMPSLIB) $(SUPERLULIB) $(SPOOLESLIB) $(SCALAPACKLIB) $(BLACSLIB) $(HYPRELIB) $(SPAILIB) $(PROMETHEUSLIB) $(PASTIXLIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MKLLIB) $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(OSLIBS) $(GSLLIB) $(ADOLCLIB)
    9991032
    10001033if FORTRAN
     
    10041037issm_SOURCES = solutions/issm.cpp
    10051038issm_CXXFLAGS= -fPIC $(CXXFLAGS) $(CXXOPTFLAGS) $(COPTFLAGS)
     1039
     1040if KRIGING
     1041bin_PROGRAMS += kriging
     1042kriging_SOURCES = solutions/kriging.cpp
     1043kriging_CXXFLAGS= -fPIC $(CXXFLAGS) $(CXXOPTFLAGS) $(COPTFLAGS)
     1044endif
    10061045#}}}
    10071046#Automatic differentiation: append this fold to the end of the src/c/Makefile.am to get this Makefile.am {{{
  • issm/trunk/src/c/include/include.h

    r9761 r12706  
    1010#include "./types.h"
    1111
    12 
    1312#endif //ifndef _INCLUDE_H_
    14 
  • issm/trunk/src/c/include/macros.h

    r12330 r12706  
    33 */
    44
    5 /*Header {{{1*/
     5/*Header {{{*/
    66#ifndef _MACROS_H_
    77#define _MACROS_H_
    88
     9#include <iostream>
     10#include <sstream>
     11#include <iomanip>
    912#include "./typedefs.h"
    1013
     
    1619/*}}}*/
    1720
    18 /* _printf_ {{{1*/
     21/* _printf_ {{{*/
    1922/*Printing macro: only cpu number 0 */
    20 #define _printf_(flag,...) do { if(flag) PrintfFunction(__VA_ARGS__); }while (0)
     23#define _printf_(flag,...) do{if(flag) PrintfFunction(__VA_ARGS__);}while(0)
    2124/*}}}*/
    22 /* _error_ {{{1*/
     25/* _error_ {{{*/
    2326/*Error exception macro*/
    2427#ifdef _INTEL_WIN_
     
    3033#endif
    3134/*}}}*/
    32 /* _assert_ {{{1*/
     35/* _error2_ {{{*/
     36/*new Error exception macro*/
     37#ifdef _INTEL_WIN_
     38#define _error2_(StreamArgs)\
     39   do{std::ostringstream aLoNgAnDwEiRdLoCaLnAmeFoRtHiSmAcRoOnLy; \
     40   aLoNgAnDwEiRdLoCaLnAmeFoRtHiSmAcRoOnLy << StreamArgs << std::ends; \
     41   throw ErrorException(aLoNgAnDwEiRdLoCaLnAmeFoRtHiSmAcRoOnLy.str());}while(0)
     42#else
     43#define _error2_(StreamArgs)\
     44        do{std::ostringstream aLoNgAnDwEiRdLoCaLnAmeFoRtHiSmAcRoOnLy; \
     45   aLoNgAnDwEiRdLoCaLnAmeFoRtHiSmAcRoOnLy << StreamArgs << std::ends; \
     46   throw ErrorException(__FILE__,__func__,__LINE__,aLoNgAnDwEiRdLoCaLnAmeFoRtHiSmAcRoOnLy.str());}while(0)
     47#endif
     48/*}}}*/
     49/* _printLine_ {{{*/
     50/* macro to print a line, adds std::endl */
     51#define _printLine_(StreamArgs)\
     52   do{std::cout << StreamArgs << std::endl;}while(0)
     53/*}}}*/
     54/* _printString_ {{{*/
     55/* macro to print some string, adds std::ends */
     56#define _printString_(StreamArgs)\
     57   do{std::cout << StreamArgs;}while(0)
     58/*}}}*/
     59/* _pprintLine_ {{{*/
     60/* macro to print a line, adds std::endl */
     61#define _pprintLine_(StreamArgs)\
     62  do{std::ostringstream aLoNgAnDwEiRdLoCaLnAmeFoRtHiSmAcRoOnLy; \
     63          aLoNgAnDwEiRdLoCaLnAmeFoRtHiSmAcRoOnLy << StreamArgs << std::ends; \
     64          PrintfFunction(aLoNgAnDwEiRdLoCaLnAmeFoRtHiSmAcRoOnLy.str());}while(0)
     65/*}}}*/
     66/* _pprintString_ {{{*/
     67/* macro to print some string, adds std::ends */
     68#define _pprintString_(StreamArgs)\
     69  do{std::ostringstream aLoNgAnDwEiRdLoCaLnAmeFoRtHiSmAcRoOnLy; \
     70          aLoNgAnDwEiRdLoCaLnAmeFoRtHiSmAcRoOnLy << StreamArgs << std::ends; \
     71          PrintfFunction2(aLoNgAnDwEiRdLoCaLnAmeFoRtHiSmAcRoOnLy.str());}while(0)
     72/*}}}*/
     73/* _assert_ {{{*/
    3374/*Assertion macro: do nothing if macro _ISSM_DEBUG_ undefined*/
    3475#ifdef _ISSM_DEBUG_
     
    4081#endif
    4182/*}}}*/
    42 /* ISSMBOOT/ISSMEND {{{1*/
     83/* ISSMBOOT/ISSMEND {{{*/
    4384
    4485/*The following macros hide the error exception handling in a matlab module. Just put
  • issm/trunk/src/c/include/typedefs.h

    r11527 r12706  
    1616#define NDOF3 3
    1717#define NDOF4 4
    18 
    1918
    2019#define DIM2 2
     
    4039#endif
    4140
    42 
    43 
    44 
    4541#endif //ifndef _ISSMTYPEDEFS_H_
  • issm/trunk/src/c/include/types.h

    r12330 r12706  
    2828
    2929#ifdef _HAVE_ADOLC_
     30#include "adolc/adolc.h"
     31// for active variables
    3032typedef adouble IssmDouble;
     33// for passive variables
     34typedef double IssmPDouble;
    3135#else
     36// see above
    3237typedef double IssmDouble;
     38// see above
     39typedef IssmDouble IssmPDouble;
    3340#endif
    3441
    3542typedef bool IssmBool;
    3643
    37 
    3844#endif //ifndef _TYPES_H_
  • issm/trunk/src/c/io/Disk/diskio.h

    r11237 r12706  
    1010#include "../../include/include.h"
    1111
    12 class DataSet;
    13 class Parameters;
    14 
    1512FILE* pfopen(char* filename,const char* format);
    1613void  pfclose(FILE* fid,char* filename);
  • issm/trunk/src/c/io/Disk/pfclose.cpp

    r9320 r12706  
    1818        extern int my_rank;
    1919        _assert_(fid);
    20         if(fclose(fid)!=0)_error_("%s%s","could not close file ",filename);
     20        if(fclose(fid)!=0)_error2_("could not close file " << filename);
    2121}
  • issm/trunk/src/c/io/Disk/pfopen.cpp

    r11237 r12706  
    2020        /*Open handle to data on disk: */
    2121        fid=fopen(filename,format);
    22         if(fid==NULL) _error_("%s%s%s","could not open file ",filename," for binary reading or writing");
     22        if(fid==NULL) _error2_("could not open file " << filename << " for binary reading or writing");
    2323
    2424        return fid;
  • issm/trunk/src/c/io/PrintfFunction.cpp

    r12330 r12706  
    2525
    2626                /*allocate buffer for given string size*/
    27                 buffer=(char*)xmalloc(size*sizeof(char));
     27                buffer=xNew<char>(size);
    2828
    2929                /* Try to print in the allocated space. */
    3030                va_start(args, format);
    31 #ifndef WIN32
    3231                n=vsnprintf(buffer,size,format,args);
    33 #else
    34                 n=vsnprintf(buffer,size,format,args);
    35 #endif
    3632                va_end(args);
    3733
     
    4541                 size*=2;  /* twice the old size */
    4642
    47                 xfree((void**)&buffer);
     43                xDelete<char>(buffer);
    4844        }
    4945
    5046        /*Ok, if we are running in parallel, get node 0 to print*/
    51         if(my_rank==0)printf(buffer);
     47        if(my_rank==0)_printString_(buffer);
    5248
    5349        /*Clean up and return*/
    54         xfree((void**)&buffer);
     50        xDelete<char>(buffer);
    5551        return 1;
    5652}
     53int PrintfFunction(const string & message){
     54        extern int  my_rank;
     55        if(my_rank==0){
     56                printf("%s\n",message.c_str());
     57        }
     58        return 1;
     59}
     60int PrintfFunction2(const string & message){
     61        extern int  my_rank;
     62        if(my_rank==0){
     63                printf("%s",message.c_str());
     64        }
     65        return 1;
     66}
  • issm/trunk/src/c/io/io.h

    r12330 r12706  
    66#define _ISSM_IO_H_
    77
    8 #ifdef HAVE_CONFIG_H //config.h {{{1
     8#ifdef HAVE_CONFIG_H
    99#include <config.h>
    1010#else
    1111#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
    1212#endif
    13 //}}}
    14 
    1513#include "./Disk/diskio.h"
    1614
    1715/*printf: */
    1816int PrintfFunction(const char* format,...);
     17int PrintfFunction(const string & message);
     18int PrintfFunction2(const string & message);
    1919
    2020#endif  /* _IO_H_ */
  • issm/trunk/src/c/issm.h

    r9761 r12706  
    2222#include "./modules/modules.h"
    2323
    24 
    2524#endif //ifndef _ISSM_H_
  • issm/trunk/src/c/matlab/include/matlab_macros.h

    r12330 r12706  
    33 */
    44
    5 /*Header {{{1*/
     5/*Header {{{*/
    66#ifndef _MATLAB_MACROS_H_
    77#define _MATLAB_MACROS_H_
     
    1515
    1616#ifdef _HAVE_MATLAB_
    17 /* MODULEBOOT/MODULEEND {{{1*/
     17/* MODULEBOOT/MODULEEND {{{*/
    1818
    1919/*The following macros hide the error exception handling in a matlab module. Just put
     
    3636        }
    3737//}}}
    38 /* WRAPPER {{{1*/
     38/* WRAPPER {{{*/
    3939#define WRAPPER(modulename,...) void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
    4040
    4141/*}}}*/
    42 /* CHECKARGUMENTS {{{1*/
     42/* CHECKARGUMENTS {{{*/
    4343#define CHECKARGUMENTS(NLHS,NRHS,functionpointer) CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,functionpointer)
    4444/*}}}*/
  • issm/trunk/src/c/matlab/io/CheckNumMatlabArguments.cpp

    r12330 r12706  
    2222                /* special case: */
    2323                function();
    24                 _error_("usage: see above");
     24                _error2_("usage: see above");
    2525        }
    2626        else if (nlhs!=NLHS || nrhs!=NRHS ) {
    2727                function();
    28                 _error_("usage error.");
     28                _error2_("usage error.");
    2929        }
    3030        return 1;
  • issm/trunk/src/c/matlab/io/FetchMatlabData.cpp

    r12330 r12706  
    1515
    1616/*Primitive data types*/
    17 /*FUNCTION FetchData(double** pmatrix,int* pM,int *pN,const mxArray* dataref){{{1*/
     17/*FUNCTION FetchData(double** pmatrix,int* pM,int *pN,const mxArray* dataref){{{*/
    1818void FetchData(double** pmatrix,int* pM,int *pN,const mxArray* dataref){
    1919
     
    2727                outmatrix=NULL;
    2828        }
    29         else if(mxIsClass(dataref,"double") || mxIsClass(dataref,"single")){
     29        else if( mxIsClass(dataref,"double") ||
     30                                mxIsClass(dataref,"single") ||
     31                                mxIsClass(dataref,"int16") ||
     32                                mxIsClass(dataref,"int8") ||
     33                                mxIsClass(dataref,"uint8")){
    3034                /*Check dataref is not pointing to NaN: */
    3135                if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetM(dataref)==1) && (mxGetN(dataref)==1) ){
     
    3539                }
    3640                else{
     41                        if(!mxIsClass(dataref,"double") && !mxIsClass(dataref,"single")){
     42                                _printLine_("Warning: converting matlab data from '" << mxGetClassName(dataref) << "' to 'double'");
     43                        }
    3744                        /*Convert matlab matrix to double* matrix: */
    3845                        MatlabMatrixToDoubleMatrix(&outmatrix,&outmatrix_rows,&outmatrix_cols,dataref);
     
    4148        else{
    4249                /*This is an error: we don't have the correct input!: */
    43                 _error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
     50                _error2_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
    4451        }
    4552                       
     
    5158}
    5259/*}}}*/
    53 /*FUNCTION FetchData(double** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){{{1*/
     60/*FUNCTION FetchData(double** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){{{*/
    5461void FetchData(double** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){
    5562
     
    8289        else{
    8390                /*This is an error: we don't have the correct input!: */
    84                 _error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
     91                _error2_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
    8592        }
    8693                       
     
    9097        if (pndims)*pndims=outmatrix_ndims;
    9198        if (psize )*psize =outmatrix_size;
    92         else xfree((void**)&outmatrix_size);
    93 
    94 }
    95 /*}}}*/
    96 /*FUNCTION FetchData(int** pmatrix,int* pM,int *pN,const mxArray* dataref){{{1*/
     99        else xDelete<int>(outmatrix_size);
     100
     101}
     102/*}}}*/
     103/*FUNCTION FetchData(int** pmatrix,int* pM,int *pN,const mxArray* dataref){{{*/
    97104void FetchData(int** pmatrix,int* pM,int *pN,const mxArray* dataref){
    98105
     
    121128
    122129                        /*Convert double matrix into integer matrix: */
    123                         outmatrix=(int*)xmalloc(outmatrix_rows*outmatrix_cols*sizeof(int));
     130                        outmatrix=xNew<int>(outmatrix_rows*outmatrix_cols);
    124131                        for(i=0;i<outmatrix_rows*outmatrix_cols;i++)outmatrix[i]=(int)doublematrix[i];
    125132                }
     
    127134        else{
    128135                /*This is an error: we don't have the correct input!: */
    129                 _error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
     136                _error2_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
    130137        }
    131138
     
    136143}
    137144/*}}}*/
    138 /*FUNCTION FetchData(bool** pmatrix,int* pM,int *pN,const mxArray* dataref){{{1*/
     145/*FUNCTION FetchData(bool** pmatrix,int* pM,int *pN,const mxArray* dataref){{{*/
    139146void FetchData(bool** pmatrix,int* pM,int *pN,const mxArray* dataref){
    140147
     
    163170
    164171                        /*Convert double matrix into integer matrix: */
    165                         outmatrix=(bool*)xmalloc(outmatrix_rows*outmatrix_cols*sizeof(bool));
     172                        outmatrix=xNew<bool>(outmatrix_rows*outmatrix_cols);
    166173                        for(i=0;i<outmatrix_rows;i++)outmatrix[i]=(bool)doublematrix[i];
    167174                }
     
    169176        else{
    170177                /*This is an error: we don't have the correct input!: */
    171                 _error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
     178                _error2_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
    172179        }
    173180
     
    178185}
    179186/*}}}*/
    180 /*FUNCTION FetchData(bool** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){{{1*/
     187/*FUNCTION FetchData(bool** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){{{*/
    181188void FetchData(bool** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){
    182189
     
    224231
    225232                        /*Convert double matrix into bool matrix: */
    226                         outmatrix=(bool*)xmalloc(outmatrix_numel*sizeof(bool));
     233                        outmatrix=xNew<bool>(outmatrix_numel);
    227234                        for(i=0;i<outmatrix_numel;i++)outmatrix[i]=(bool)doublematrix[i];
    228                         xfree((void**)&doublematrix);
    229                 }
    230         }
    231         else{
    232                 /*This is an error: we don't have the correct input!: */
    233                 _error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
     235                        xDelete<double>(doublematrix);
     236                }
     237        }
     238        else{
     239                /*This is an error: we don't have the correct input!: */
     240                _error2_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
    234241        }
    235242                       
     
    239246        if (pndims)*pndims=outmatrix_ndims;
    240247        if (psize )*psize =outmatrix_size;
    241         else xfree((void**)&outmatrix_size);
    242 
    243 }
    244 /*}}}*/
    245 /*FUNCTION FetchData(double** pvector,int* pM,const mxArray* dataref){{{1*/
     248        else xDelete<int>(outmatrix_size);
     249
     250}
     251/*}}}*/
     252/*FUNCTION FetchData(double** pvector,int* pM,const mxArray* dataref){{{*/
    246253void FetchData(double** pvector,int* pM,const mxArray* dataref){
    247254
     
    262269        else{
    263270                /*This is an error: we don't have the correct input!: */
    264                 _error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
     271                _error2_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
    265272        }
    266273
     
    270277}
    271278/*}}}*/
    272 /*FUNCTION FetchData(int** pvector,int* pM,const mxArray* dataref){{{1*/
     279/*FUNCTION FetchData(int** pvector,int* pM,const mxArray* dataref){{{*/
    273280void FetchData(int** pvector,int* pM,const mxArray* dataref){
    274281
     
    289296
    290297                /*Convert double vector into integer vector: */
    291                 outvector=(int*)xmalloc(outvector_rows*sizeof(int));
     298                outvector=xNew<int>(outvector_rows);
    292299                for(i=0;i<outvector_rows;i++)outvector[i]=(int)doublevector[i];
    293300        }
    294301        else{
    295302                /*This is an error: we don't have the correct input!: */
    296                 _error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
     303                _error2_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
    297304        }
    298305
     
    302309}
    303310/*}}}*/
    304 /*FUNCTION FetchData(bool** pvector,int* pM,const mxArray* dataref){{{1*/
     311/*FUNCTION FetchData(bool** pvector,int* pM,const mxArray* dataref){{{*/
    305312void FetchData(bool** pvector,int* pM,const mxArray* dataref){
    306313
     
    321328
    322329                /*Convert double vector into integer vector: */
    323                 outvector=(bool*)xmalloc(outvector_rows*sizeof(bool));
     330                outvector=xNew<bool>(outvector_rows);
    324331                for(i=0;i<outvector_rows;i++)outvector[i]=(bool)doublevector[i];
    325332        }
    326333        else{
    327334                /*This is an error: we don't have the correct input!: */
    328                 _error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
     335                _error2_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
    329336        }
    330337
     
    334341}
    335342/*}}}*/
    336 /*FUNCTION FetchData(float** pvector,int* pM,const mxArray* dataref){{{1*/
     343/*FUNCTION FetchData(float** pvector,int* pM,const mxArray* dataref){{{*/
    337344void FetchData(float** pvector,int* pM,const mxArray* dataref){
    338345
     
    353360
    354361                /*Convert double vector into float vector: */
    355                 outvector=(float*)xmalloc(outvector_rows*sizeof(float));
     362                outvector=xNew<float>(outvector_rows);
    356363                for(i=0;i<outvector_rows;i++)outvector[i]=(float)doublevector[i];
    357364        }
    358365        else{
    359366                /*This is an error: we don't have the correct input!: */
    360                 _error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
     367                _error2_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
    361368        }
    362369
     
    366373}
    367374/*}}}*/
    368 /*FUNCTION FetchData(char** pstring,const mxArray* dataref){{{1*/
     375/*FUNCTION FetchData(char** pstring,const mxArray* dataref){{{*/
    369376void FetchData(char** pstring,const mxArray* dataref){
    370377
     
    374381        /*Ok, the string should be coming directly from the matlab workspace: */
    375382        if (!mxIsClass(dataref,"char")){
    376                 _error_("input data_type is not a string!");
     383                _error2_("input data_type is not a string!");
    377384        }
    378385        else{
     
    381388               
    382389                stringlen = mxGetM(dataref)*mxGetN(dataref)+1;
    383                 outstring = (char*)xmalloc(sizeof(mxChar)*stringlen);
     390                outstring =xNew<char>(stringlen);
    384391                mxGetString(dataref,outstring,stringlen);
    385392        }
     
    387394        /*Assign output pointers:*/
    388395        *pstring=outstring;
    389 }
    390 /*FUNCTION FetchData(char** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){{{1*/
     396}/*}}}*/
     397/*FUNCTION FetchData(char** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){{{*/
    391398void FetchData(char** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){
    392399
     
    409416        else{
    410417                /*This is an error: we don't have the correct input!: */
    411                 _error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
     418                _error2_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
    412419        }
    413420                       
     
    417424        if (pndims)*pndims=outmatrix_ndims;
    418425        if (psize )*psize =outmatrix_size;
    419         else xfree((void**)&outmatrix_size);
    420 
    421 }
    422 /*}}}*/
    423 /*FUNCTION FetchData(double* pscalar,const mxArray* dataref){{{1*/
     426        else xDelete<int>(outmatrix_size);
     427
     428}
     429/*}}}*/
     430/*FUNCTION FetchData(double* pscalar,const mxArray* dataref){{{*/
    424431void FetchData(double* pscalar,const mxArray* dataref){
    425432
     
    427434
    428435        if (!mxIsClass(dataref,"double")){
    429                 _error_("input data_type is not a double!");
     436                _error2_("input data_type is not a double!");
    430437        }
    431438        else{
     
    438445}
    439446/*}}}*/
    440 /*FUNCTION FetchData(int* pinteger,const mxArray* dataref){{{1*/
     447/*FUNCTION FetchData(int* pinteger,const mxArray* dataref){{{*/
    441448void FetchData(int* pinteger,const mxArray* dataref){
    442449
     
    444451
    445452        if (!mxIsClass(dataref,"double")){
    446                 _error_("input data_type is not a scalar!");
     453                _error2_("input data_type is not a scalar!");
    447454        }
    448455        else{
     
    455462}
    456463/*}}}*/
    457 /*FUNCTION FetchData(bool* pboolean,const mxArray* dataref){{{1*/
     464/*FUNCTION FetchData(bool* pboolean,const mxArray* dataref){{{*/
    458465void FetchData(bool* pboolean,const mxArray* dataref){
    459466
     
    461468
    462469        if (mxIsClass(dataref,"logical")){
    463                 if(mxGetM(dataref)!=1) _error_("input data is not of size 1x1");
    464                 if(mxGetN(dataref)!=1) _error_("input data is not of size 1x1");
     470                if(mxGetM(dataref)!=1) _error2_("input data is not of size 1x1");
     471                if(mxGetN(dataref)!=1) _error2_("input data is not of size 1x1");
    465472                mxbool_ptr=mxGetLogicals(dataref);
    466473        }
    467474        else{
    468                 _error_("input data_type is not a bool!");
     475                _error2_("input data_type is not a bool!");
    469476        }
    470477
     
    474481
    475482/*ISSM objects*/
    476 /*FUNCTION FetchData(Matrix** pmatrix,const mxArray* dataref){{{1*/
     483/*FUNCTION FetchData(Matrix** pmatrix,const mxArray* dataref){{{*/
    477484void FetchData(Matrix** pmatrix,const mxArray* dataref){
    478485
     
    488495        else{
    489496                /*This is an error: we don't have the correct input!: */
    490                 _error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
     497                _error2_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
    491498        }
    492499
     
    495502}
    496503/*}}}*/
    497 /*FUNCTION FetchData(Vector** pvector,const mxArray* dataref){{{1*/
     504/*FUNCTION FetchData(Vector** pvector,const mxArray* dataref){{{*/
    498505void FetchData(Vector** pvector,const mxArray* dataref){
    499506
     
    512519        else{
    513520                /*This is an error: we don't have the correct input!: */
    514                 _error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
     521                _error2_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
    515522        }
    516523
     
    519526}
    520527/*}}}*/
    521 /*FUNCTION FetchData(BamgGeom** pbamggeom,const mxArray* dataref){{{1*/
     528/*FUNCTION FetchData(BamgGeom** pbamggeom,const mxArray* dataref){{{*/
    522529void FetchData(BamgGeom** pbamggeom,const mxArray* dataref){
    523530
     
    538545}
    539546/*}}}*/
    540 /*FUNCTION FetchData(BamgMesh** pbamgmesh,const mxArray* dataref){{{1*/
     547/*FUNCTION FetchData(BamgMesh** pbamgmesh,const mxArray* dataref){{{*/
    541548void FetchData(BamgMesh** pbamgmesh,const mxArray* dataref){
    542549
     
    558565}
    559566/*}}}*/
    560 /*FUNCTION FetchData(BamgOpts** pbamgopts,const mxArray* dataref){{{1*/
     567/*FUNCTION FetchData(BamgOpts** pbamgopts,const mxArray* dataref){{{*/
    561568void FetchData(BamgOpts** pbamgopts,const mxArray* dataref){
    562569
     
    602609}
    603610/*}}}*/
    604 /*FUNCTION FetchData(Options** poptions,const mxArray* dataref){{{1*/
     611/*FUNCTION FetchData(Options** poptions,const mxArray* dataref){{{*/
    605612void FetchData(Options** poptions,int istart, int nrhs,const mxArray** pdataref){
    606613
     
    613620        /*Fetch all options*/
    614621        for (int i=istart; i<nrhs; i=i+2){
    615                 if (!mxIsClass(pdataref[i],"char")) _error_("Argument %d must be name of option",i+1);
     622                if (!mxIsClass(pdataref[i],"char")) _error2_("Argument " << i+1 << " must be name of option");
    616623
    617624                FetchData(&name,pdataref[i]);
    618                 if(i+1 == nrhs) _error_("Argument %d must exist and be value of option \"%s\".",i+2,name);
     625                if(i+1 == nrhs) _error2_("Argument " << i+2 << " must exist and be value of option \"" << name << "\".");
    619626
    620627                option=(Option*)OptionParse(name,&pdataref[i+1]);
  • issm/trunk/src/c/matlab/io/MatlabMatrixToDoubleMatrix.cpp

    r12330 r12706  
    22 * \brief: convert a sparse or dense matlab matrix to a double* pointer
    33 */
    4 
    54
    65#ifdef HAVE_CONFIG_H
     
    109#endif
    1110
    12 
    1311/*Matlab includes: */
    1412#include "mex.h"
    15 
    1613#include "../../shared/shared.h"
    1714
    1815int MatlabMatrixToDoubleMatrix(double** pmatrix,int* pmatrix_rows,int* pmatrix_cols,const mxArray* mxmatrix){
    1916
    20         int     i,j,count,rows,cols;
    21         double *pmxdoublematrix = NULL;
    22         float  *pmxsinglematrix = NULL;
     17        int        i,j,count,rows,cols;
    2318
    2419        /*output: */
     
    3328
    3429                /*Dealing with sparse matrix: recover size first: */
    35                 pmxdoublematrix=(double*)mxGetPr(mxmatrix);
     30                double* pmxmatrix=(double*)mxGetPr(mxmatrix);
    3631                rows=mxGetM(mxmatrix);
    3732                cols=mxGetN(mxmatrix);
    3833               
    3934                if(rows*cols){
    40                         matrix=(double*)xcalloc(rows*cols,sizeof(double));
     35                        matrix=xNewZeroInit<double>(rows*cols);
    4136
    4237                        /*Now, get ir,jc and pr: */
     
    4843                        for(i=0;i<cols;i++){
    4944                                for(j=0;j<(jc[i+1]-jc[i]);j++){
    50                                         matrix[rows*ir[count]+i]=pmxdoublematrix[count];
     45                                        matrix[rows*ir[count]+i]=pmxmatrix[count];
    5146                                        count++;
    5247                                }
     
    5752        else if(mxIsClass(mxmatrix,"double")){
    5853                /*Dealing with dense matrix: recover pointer and size: */
    59                 pmxdoublematrix=(double*)mxGetPr(mxmatrix);
     54                double* pmxmatrix=(double*)mxGetPr(mxmatrix);
    6055                rows=mxGetM(mxmatrix);
    6156                cols=mxGetN(mxmatrix);
     
    6358                /*Create serial matrix: */
    6459                if(rows*cols){
    65                         matrix=(double*)xcalloc(rows*cols,sizeof(double));
     60                        matrix=xNewZeroInit<double>(rows*cols);
    6661
    6762                        for(i=0;i<rows;i++){
    6863                                for(j=0;j<cols;j++){
    69                                         matrix[cols*i+j]=(double)pmxdoublematrix[rows*j+i];
     64                                        matrix[cols*i+j]=(double)pmxmatrix[rows*j+i];
    7065                                }
    7166                        }
     
    7469        else if(mxIsClass(mxmatrix,"single")){
    7570                /*Dealing with dense matrix: recover pointer and size: */
    76                 pmxsinglematrix=(float*)mxGetPr(mxmatrix);
     71                float *pmxmatrix=(float*)mxGetPr(mxmatrix);
    7772                rows=mxGetM(mxmatrix);
    7873                cols=mxGetN(mxmatrix);
     
    8075                /*Create serial matrix: */
    8176                if(rows*cols){
    82                         matrix=(double*)xcalloc(rows*cols,sizeof(double));
     77                        matrix=xNewZeroInit<double>(rows*cols);
    8378
    8479                        for(i=0;i<rows;i++){
    8580                                for(j=0;j<cols;j++){
    86                                         matrix[cols*i+j]=(double)pmxsinglematrix[rows*j+i];
     81                                        matrix[cols*i+j]=(double)pmxmatrix[rows*j+i];
     82                                }
     83                        }
     84                }
     85        }
     86        else if(mxIsClass(mxmatrix,"int16")){
     87                /*Dealing with dense matrix: recover pointer and size: */
     88                short int *pmxmatrix=(short*)mxGetPr(mxmatrix);
     89                rows=mxGetM(mxmatrix);
     90                cols=mxGetN(mxmatrix);
     91
     92                /*Create serial matrix: */
     93                if(rows*cols){
     94                        matrix=xNewZeroInit<double>(rows*cols);
     95
     96                        for(i=0;i<rows;i++){
     97                                for(j=0;j<cols;j++){
     98                                        matrix[cols*i+j]=(double)pmxmatrix[rows*j+i];
     99                                }
     100                        }
     101                }
     102        }
     103        else if(mxIsClass(mxmatrix,"uint8")){
     104                /*Dealing with dense matrix: recover pointer and size: */
     105                char *pmxmatrix=(char*)mxGetPr(mxmatrix);
     106                rows=mxGetM(mxmatrix);
     107                cols=mxGetN(mxmatrix);
     108
     109                /*Create serial matrix: */
     110                if(rows*cols){
     111                        matrix=xNewZeroInit<double>(rows*cols);
     112
     113                        for(i=0;i<rows;i++){
     114                                for(j=0;j<cols;j++){
     115                                        matrix[cols*i+j]=(double)pmxmatrix[rows*j+i];
    87116                                }
    88117                        }
     
    90119        }
    91120        else{
    92                 _error_("Matlab matrix type Not implemented yet");
     121                _error2_("Matlab matrix type Not implemented yet");
    93122        }
    94123
  • issm/trunk/src/c/matlab/io/MatlabMatrixToMatrix.cpp

    r12330 r12706  
    33
    44/*Headers:*/
    5 /*{{{1*/
     5/*{{{*/
    66#ifdef HAVE_CONFIG_H
    77        #include <config.h>
  • issm/trunk/src/c/matlab/io/MatlabMatrixToPetscMatrix.cpp

    r12330 r12706  
    99#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
    1010#endif
    11 
     11#include "../../shared/shared.h"
    1212
    1313/*Petsc includes: */
     
    1919#include "mex.h"
    2020
    21 #include "../../shared/shared.h"
    22 
    2321int MatlabMatrixToPetscMatrix(Mat* pmatrix,int* pmatrix_rows,int* pmatrix_cols,const mxArray* mxmatrix){
    2422
    2523        int rows, cols;
    26         double* mxmatrix_ptr=NULL;
    27         double* tmatrix=NULL;
     24        double *mxmatrix_ptr = NULL;
     25        double *tmatrix      = NULL;
    2826        int ierr;
    2927        int i,j;
    3028
    3129        /*output: */
    32         Mat matrix=NULL;
     30        Mat matrix = NULL;
    3331
    3432        /*matlab indices: */
    35         mwIndex*    ir=NULL;
    36         mwIndex*    jc=NULL;
    37         double* pr=NULL;
     33        mwIndex *ir = NULL;
     34        mwIndex *jc = NULL;
     35        double  *pr = NULL;
    3836        int     count;
    3937        int     nnz;
     
    4139
    4240        /*petsc indices: */
    43         int* idxm=NULL;
    44         int* idxn=NULL;
     41        int *idxm = NULL;
     42        int *idxn = NULL;
    4543       
    4644        /*Ok, first check if we are dealing with a sparse or full matrix: */
     
    7472                        }
    7573                }
    76 
    7774        }
    7875        else{
    79 
    8076                /*Dealing with dense matrix: recover pointer and size: */
    8177                mxmatrix_ptr=(double*)mxGetPr(mxmatrix);
     
    8480
    8581                /*transpose, as Petsc now does not allows MAT_COLUMN_ORIENTED matrices in MatSetValues: */
    86                 tmatrix=(double*)xmalloc(rows*cols*sizeof(double));
     82                tmatrix=xNew<double>(rows*cols);
    8783                for(i=0;i<cols;i++){
    8884                        for(j=0;j<rows;j++){
     
    9591
    9692                /*Insert mxmatrix_ptr values into petsc matrix: */
    97                 idxm=(int*)xmalloc(rows*sizeof(int));
    98                 idxn=(int*)xmalloc(cols*sizeof(int));
     93                idxm=xNew<int>(rows);
     94                idxn=xNew<int>(cols);
    9995
    10096                for(i=0;i<rows;i++)idxm[i]=i;
     
    10399                ierr=MatSetValues(matrix,rows,idxm,cols,idxn,tmatrix,INSERT_VALUES); CHKERRQ(ierr);
    104100
    105                 xfree((void**)&tmatrix);
    106 
     101                xDelete<double>(tmatrix);
    107102        }
    108103
     
    110105        MatAssemblyBegin(matrix,MAT_FINAL_ASSEMBLY);
    111106        MatAssemblyEnd(matrix,MAT_FINAL_ASSEMBLY);
    112 
    113107
    114108        /*Assign output pointer: */
  • issm/trunk/src/c/matlab/io/MatlabMatrixToSeqMat.cpp

    r12330 r12706  
    33
    44/*Headers:*/
    5 /*{{{1*/
     5/*{{{*/
    66#ifdef HAVE_CONFIG_H
    77        #include <config.h>
  • issm/trunk/src/c/matlab/io/MatlabNArrayToNArray.cpp

    r12330 r12706  
    1515#include <mex.h>
    1616
    17 /*FUNCTION MatlabNArrayToNArray(double** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){{{1*/
     17/*FUNCTION MatlabNArrayToNArray(double** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){{{*/
    1818int MatlabNArrayToNArray(double** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){
    1919
     
    3939        ndims=mxGetNumberOfDimensions(mxmatrix);
    4040        ipt  =mxGetDimensions(mxmatrix);
    41         size =(int *) xcalloc(ndims,sizeof(int));
    42         for (i=0; i<ndims; i++) size[i]=(int)ipt[i];
     41        size =xNew<int>(ndims);
     42        for (i=0;i<ndims;i++) size[i]=(int)ipt[i];
    4343
    4444        /*Ok, first check if we are dealing with a sparse or full matrix: */
     
    5151                nz=(int)((double)nnz/(double)rows);
    5252
    53                 matrix=(double*)xcalloc(rows*cols,sizeof(double));
     53                matrix=xNewZeroInit<double>(rows*cols);
    5454
    5555                /*Now, get ir,jc and pr: */
     
    7474               
    7575                /*Create serial matrix: */
    76                 matrix=(double*)xcalloc(numel,sizeof(double));
    77 
    78                 dims=(int *) xcalloc(ndims,sizeof(int));
     76                matrix=xNewZeroInit<double>(numel);
     77
     78                dims=xNew<int>(ndims);
    7979                for(i=0;i<numel;i++){
    8080                        ColumnWiseDimsFromIndex(dims,i,size,ndims);
     
    8282                        *(matrix+j)=*(mxmatrix_ptr+i);
    8383                }
    84                 xfree((void**)&dims);
     84                xDelete<int>(dims);
    8585               
    8686        }
     
    9595}
    9696/*}}}*/
    97 /*FUNCTION MatlabNArrayToNArray(bool** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){{{1*/
     97/*FUNCTION MatlabNArrayToNArray(bool** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){{{*/
    9898int MatlabNArrayToNArray(bool** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){
    9999
     
    119119        ndims=mxGetNumberOfDimensions(mxmatrix);
    120120        ipt  =mxGetDimensions(mxmatrix);
    121         size =(int *) xcalloc(ndims,sizeof(int));
    122         for (i=0; i<ndims; i++) size[i]=(int)ipt[i];
     121        size =xNew<int>(ndims);
     122        for (i=0;i<ndims;i++) size[i]=(int)ipt[i];
    123123
    124124        /*Ok, first check if we are dealing with a sparse or full matrix: */
     
    131131                nz=(int)((double)nnz/(double)rows);
    132132
    133                 matrix=(bool*)xcalloc(rows*cols,sizeof(bool));
     133                matrix=xNewZeroInit<bool>(rows*cols);
    134134
    135135                /*Now, get ir,jc and pm: */
     
    154154               
    155155                /*Create serial matrix: */
    156                 matrix=(bool*)xcalloc(numel,sizeof(bool));
    157 
    158                 dims=(int *) xcalloc(ndims,sizeof(int));
     156                matrix=xNew<bool>(numel);
     157                dims=xNew<int>(ndims);
    159158                for(i=0;i<numel;i++){
    160159                        ColumnWiseDimsFromIndex(dims,i,size,ndims);
     
    162161                        *(matrix+j)=(bool)*(mxmatrix_ptr+i);
    163162                }
    164                 xfree((void**)&dims);
    165                
     163                xDelete<int>(dims);
    166164        }
    167165
     
    175173}
    176174/*}}}*/
    177 /*FUNCTION MatlabNArrayToNArray(char** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){{{1*/
     175/*FUNCTION MatlabNArrayToNArray(char** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){{{*/
    178176int MatlabNArrayToNArray(char** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){
    179177
    180         int  i,j,rows,cols;
    181         int  numel,ndims;
    182         int *size,*dims;
    183         mxChar* mxmatrix_ptr=NULL;
    184         const mwSize* ipt=NULL;
     178        int           i,j,rows,cols;
     179        int           numel,ndims;
     180        int          *size , *dims;
     181        mxChar       *mxmatrix_ptr = NULL;
     182        const mwSize *ipt          = NULL;
    185183
    186184        /*output: */
     
    188186
    189187        /*matlab indices: */
    190         mwIndex*    ir=NULL;
    191         mwIndex*    jc=NULL;
    192         char*   pm=NULL;
    193         int     count;
    194         int     nnz;
    195         int     nz;
     188        mwIndex *ir    = NULL;
     189        mwIndex *jc    = NULL;
     190        char    *pm    = NULL;
     191        int      count;
     192        int      nnz;
     193        int      nz;
    196194
    197195        /*get Matlab matrix information: */
     
    199197        ndims=mxGetNumberOfDimensions(mxmatrix);
    200198        ipt  =mxGetDimensions(mxmatrix);
    201         size =(int *) xcalloc(ndims,sizeof(int));
    202         for (i=0; i<ndims; i++) size[i]=(int)ipt[i];
     199        size =xNew<int>(ndims);
     200        for (i=0;i<ndims;i++) size[i]=(int)ipt[i];
    203201
    204202        /*Ok, first check if we are dealing with a sparse or full matrix: */
     
    211209                nz=(int)((double)nnz/(double)rows);
    212210
    213                 matrix=(char*)xcalloc(rows*cols,sizeof(double));
     211                matrix=xNew<char>(rows*cols);
    214212
    215213                /*Now, get ir,jc and pm: */
     
    234232               
    235233                /*Create serial matrix: */
    236                 matrix=(char*)xcalloc(numel+1,sizeof(mxChar));
     234                matrix=xNew<char>(numel+1);
     235                matrix[numel]='\0';
    237236
    238237                /*looping code adapted from Matlab example explore.c: */
     
    259258                        }
    260259                }
    261 
    262260        }
    263261
  • issm/trunk/src/c/matlab/io/MatlabVectorToDoubleVector.cpp

    r12330 r12706  
    4646               
    4747                /*Check that input is actualy a vector*/
    48                 if (cols!=1) _error_("input vector of size %ix%i should have only one column",rows,cols);
     48                if (cols!=1) _error2_("input vector of size " << rows << "x" << cols << " should have only one column");
    4949
    5050                nz=(int)((double)nnz/(double)rows);
    5151
    5252                if(rows){
    53                         vector=(double*)xcalloc(rows,sizeof(double));
     53                        vector=xNewZeroInit<double>(rows);
    5454
    5555                        /*Now, get ir,jc and pr: */
     
    7777
    7878                /*Check that input is actualy a vector*/
    79                 if (cols!=1) _error_("input vector of size %ix%i should have only one column",rows,cols);
     79                if (cols!=1) _error2_("input vector of size " << rows << "x" << cols << " should have only one column");
    8080
    8181                /*allocate and memcpy*/
    8282                if(rows){
    83                         vector=(double*)xmalloc(rows*sizeof(double));
     83                        vector=xNew<double>(rows);
    8484                        memcpy(vector,mxvector_ptr,rows*sizeof(double));
    8585                }
  • issm/trunk/src/c/matlab/io/MatlabVectorToPetscVector.cpp

    r12330 r12706  
    7979
    8080                /*Insert mxvector_ptr values into petsc vector: */
    81                 idxm=(int*)xmalloc(rows*sizeof(int));
     81                idxm=xNew<int>(rows);
    8282
    8383                for(i=0;i<rows;i++)idxm[i]=i;
  • issm/trunk/src/c/matlab/io/MatlabVectorToSeqVec.cpp

    r12330 r12706  
    33
    44/*Headers:*/
    5 /*{{{1*/
     5/*{{{*/
    66#ifdef HAVE_CONFIG_H
    77        #include <config.h>
  • issm/trunk/src/c/matlab/io/MatlabVectorToVector.cpp

    r12330 r12706  
    33
    44/*Headers:*/
    5 /*{{{1*/
     5/*{{{*/
    66#ifdef HAVE_CONFIG_H
    77        #include <config.h>
  • issm/trunk/src/c/matlab/io/OptionParse.cpp

    r12348 r12706  
    1515#include "./matlabio.h"
    1616
    17 /*FUNCTION OptionDoubleParse {{{1*/
     17/*FUNCTION OptionDoubleParse {{{*/
    1818OptionDouble* OptionDoubleParse( char* name, const mxArray* prhs[]){
    1919
     
    2222        /*check and parse the name  */
    2323        odouble=new OptionDouble;
    24         odouble->name =(char *) xmalloc((strlen(name)+1)*sizeof(char));
     24        odouble->name =xNew<char>(strlen(name)+1);
    2525        memcpy(odouble->name,name,(strlen(name)+1)*sizeof(char));
    2626
    2727        /*check and parse the value  */
    2828        if (!mxIsClass(prhs[0],"double")){
    29                 _error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".",odouble->name,"double",odouble->name,mxGetClassName(prhs[0]));
     29                _error2_("Value of option \"" << odouble->name  << "\" must be class \"double\", not class \"" << mxGetClassName(prhs[0]) <<"\".");
    3030        }
    31 
    3231        FetchData(&odouble->values,&odouble->numel,&odouble->ndims,&odouble->size,prhs[0]);
    3332
    3433        return(odouble);
    3534}/*}}}*/
    36 /*FUNCTION OptionLogicalParse {{{1*/
     35/*FUNCTION OptionLogicalParse {{{*/
    3736OptionLogical* OptionLogicalParse( char* name, const mxArray* prhs[]){
    3837
     
    4140        /*check and parse the name  */
    4241        ological=new OptionLogical;
    43         ological->name =(char*)xmalloc((strlen(name)+1)*sizeof(char));
     42        ological->name =xNew<char>(strlen(name)+1);
    4443        memcpy(ological->name,name,(strlen(name)+1)*sizeof(char));
    4544
    4645        /*check and parse the value  */
    4746        if (!mxIsClass(prhs[0],"logical")){
    48                 _error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".",ological->name,"logical",ological->name,mxGetClassName(prhs[0]));
     47                _error2_("Value of option \"" << ological->name  << "\" must be class \"logical\", not class \"" << mxGetClassName(prhs[0]) <<"\".");
    4948        }
    50 
    5149        FetchData(&ological->values,&ological->numel,&ological->ndims,&ological->size,prhs[0]);
    5250
    5351        return(ological);
    5452}/*}}}*/
    55 /*FUNCTION OptionCharParse {{{1*/
     53/*FUNCTION OptionCharParse {{{*/
    5654OptionChar* OptionCharParse( char* name, const mxArray* prhs[]){
    5755
     
    6058        /*check and parse the name  */
    6159        ochar=new OptionChar();
    62         ochar->name =(char*)xmalloc((strlen(name)+1)*sizeof(char));
     60        ochar->name =xNew<char>(strlen(name)+1);
    6361        memcpy(ochar->name,name,(strlen(name)+1)*sizeof(char));
    6462
    6563        /*check and parse the value  */
    6664        if (!mxIsClass(prhs[0],"char")){
    67                 _error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".",ochar->name,"char",ochar->name,mxGetClassName(prhs[0]));
     65                _error2_("Value of option \"" << ochar->name  << "\" must be class \"char\", not class \"" << mxGetClassName(prhs[0]) <<"\".");
    6866        }
    69 
    7067        FetchData(&ochar->values,&ochar->numel,&ochar->ndims,&ochar->size,prhs[0]);
    7168
    7269        return(ochar);
    7370}/*}}}*/
    74 /*FUNCTION OptionStructParse {{{1*/
     71/*FUNCTION OptionStructParse {{{*/
    7572OptionStruct* OptionStructParse( char* name, const mxArray* prhs[]){
    7673
     
    8582        /*check and parse the name  */
    8683        ostruct=new OptionStruct;
    87         ostruct->name =(char*)xmalloc((strlen(name)+1)*sizeof(char));
     84        ostruct->name =xNew<char>(strlen(name)+1);
    8885        memcpy(ostruct->name,name,(strlen(name)+1)*sizeof(char));
    8986
    9087        /*check and parse the value  */
    9188        if (!mxIsClass(prhs[0],"struct")){
    92                 _error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".",ostruct->name,"struct",ostruct->name,mxGetClassName(prhs[0]));
     89                _error2_("Value of option \"" << ostruct->name  << "\" must be class \"struct\", not class \"" << mxGetClassName(prhs[0]) <<"\".");
    9390        }
    94 
    9591        ostruct->numel=mxGetNumberOfElements(prhs[0]);
    9692        ostruct->ndims=mxGetNumberOfDimensions(prhs[0]);
    9793        ipt           =mxGetDimensions(prhs[0]);
    98         ostruct->size =(int *) xmalloc(ostruct->ndims*sizeof(int));
     94        ostruct->size =xNew<int>(ostruct->ndims);
    9995        for (i=0; i<ostruct->ndims; i++) ostruct->size[i]=(int)ipt[i];
    100         if (ostruct->numel) ostruct->values=(Options**) xmalloc(ostruct->numel*sizeof(Options *));
     96        if (ostruct->numel) ostruct->values=xNew<Options*>(ostruct->numel);
    10197
    10298        /*loop through and process each element of the struct array  */
     
    117113        return(ostruct);
    118114}/*}}}*/
    119 /*FUNCTION OptionCellParse {{{1*/
     115/*FUNCTION OptionCellParse {{{*/
    120116OptionCell* OptionCellParse( char* name, const mxArray* prhs[]){
    121117
     
    132128        /*check and parse the name  */
    133129        ocell=new OptionCell;
    134         ocell->name =(char *) xmalloc((strlen(name)+1)*sizeof(char));
     130        ocell->name =xNew<char>(strlen(name)+1);
    135131        memcpy(ocell->name,name,(strlen(name)+1)*sizeof(char));
    136132
    137133        /*check and parse the value  */
    138134        if (!mxIsClass(prhs[0],"cell")){
    139                 _error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".",ocell->name,"cell",ocell->name,mxGetClassName(prhs[0]));
     135                _error2_("Value of option \"" << ocell->name  << "\" must be class \"cell\", not class \"" << mxGetClassName(prhs[0]) <<"\".");
    140136        }
    141137
     
    143139        ocell->ndims=mxGetNumberOfDimensions(prhs[0]);
    144140        ipt         =mxGetDimensions(prhs[0]);
    145         ocell->size =(int *) xmalloc(ocell->ndims*sizeof(int));
     141        ocell->size =xNew<int>(ocell->ndims);
    146142        for (i=0; i<ocell->ndims; i++) ocell->size[i]=(int)ipt[i];
    147143        ocell->values=new Options;
    148144
    149145        /*loop through and process each element of the cell array  */
    150         dims=(int *) xmalloc(ocell->ndims*sizeof(int));
     146        dims=xNew<int>(ocell->ndims);
    151147        for (cindex=0; cindex<ocell->numel; cindex++) {
    152148                ColumnWiseDimsFromIndex(dims,(int)cindex,ocell->size,ocell->ndims);
     
    163159                option=NULL;
    164160        }
    165         xfree((void**)&dims);
     161        xDelete<int>(dims);
    166162
    167163        return(ocell);
    168164}/*}}}*/
    169 /*FUNCTION OptionParse{{{1*/
     165/*FUNCTION OptionParse{{{*/
    170166Option* OptionParse(char* name, const mxArray* prhs[]){
    171167
     
    180176        else if(mxIsClass(prhs[0],"cell"))    option=(Option*)OptionCellParse(name,prhs);
    181177        else {
    182                 _printf_(true,"  Converting value of option \"%s\" from unrecognized class \"%s\" to class \"%s\".\n",name,mxGetClassName(prhs[0]),"struct");
     178                _pprintLine_("  Converting value of option \"" << name << "\" from unrecognized class \"" << mxGetClassName(prhs[0]) << "\" to class \"" << "struct" << "\".");
    183179                if (!mexCallMATLAB(1,lhs,1,(mxArray**)prhs,"struct")) {
    184180                        option=(Option*)OptionStructParse(name,(const mxArray**)lhs);
    185181                        mxDestroyArray(lhs[0]);
    186182                }
    187                 else _error_("Second argument value of option \"%s\" is of unrecognized class \"%s\".",name,mxGetClassName(prhs[0]));
     183                else _error2_("Second argument value of option \""<< name <<"\" is of unrecognized class \""<< mxGetClassName(prhs[0]) <<"\".");
    188184        }
    189185
  • issm/trunk/src/c/matlab/io/PrintfFunction.cpp

    r12330 r12706  
    2727
    2828                /*allocate buffer for given string size*/
    29                 buffer=(char*)xmalloc(size*sizeof(char));
     29                buffer=xNew<char>(size);
    3030
    3131                /* Try to print in the allocated space. */
     
    4747                 size*=2;  /* twice the old size */
    4848
    49                 xfree((void**)&buffer);
     49                xDelete<char>(buffer);
    5050        }
    5151
    5252        /*Ok, if we are running in parallel, get node 0 to print*/
    53         if(my_rank==0)printf(buffer);
     53        if(my_rank==0)_printString_(buffer);
    5454
    5555        /*Clean up and return*/
    56         xfree((void**)&buffer);
     56        xDelete<char>(buffer);
    5757        return 1;
    5858}
  • issm/trunk/src/c/matlab/io/WriteMatlabData.cpp

    r12330 r12706  
    1717
    1818/*Primitive data types*/
    19 /*FUNCTION WriteData(mxArray** pdataref,double* matrix, int M,int N){{{1*/
     19/*FUNCTION WriteData(mxArray** pdataref,double* matrix, int M,int N){{{*/
    2020void WriteData(mxArray** pdataref,double* matrix, int M,int N){
    2121
     
    4242}
    4343/*}}}*/
    44 /*FUNCTION WriteData(mxArray** pdataref,int* matrix, int M,int N){{{1*/
     44/*FUNCTION WriteData(mxArray** pdataref,int* matrix, int M,int N){{{*/
    4545void WriteData(mxArray** pdataref,int* matrix, int M,int N){
    4646
     
    6767}
    6868/*}}}*/
    69 /*FUNCTION WriteData(mxArray** pdataref,double* vector, int M){{{1*/
     69/*FUNCTION WriteData(mxArray** pdataref,double* vector, int M){{{*/
    7070void WriteData(mxArray** pdataref,double* vector, int M){
    7171       
     
    9090}
    9191/*}}}*/
    92 /*FUNCTION WriteData(mxArray** pdataref,double scalar){{{1*/
     92/*FUNCTION WriteData(mxArray** pdataref,double scalar){{{*/
    9393void WriteData(mxArray** pdataref,double scalar){
    9494
     
    9696}
    9797/*}}}*/
    98 /*FUNCTION WriteData(mxArray** pdataref,int integer){{{1*/
     98/*FUNCTION WriteData(mxArray** pdataref,int integer){{{*/
    9999void WriteData(mxArray** pdataref,int integer){
    100100
     
    103103}
    104104/*}}}*/
    105 /*FUNCTION WriteData(mxArray** pdataref,int boolean){{{1*/
     105/*FUNCTION WriteData(mxArray** pdataref,int boolean){{{*/
    106106void WriteData(mxArray** pdataref,bool boolean){
    107107
     
    110110}
    111111/*}}}*/
    112 /*FUNCTION WriteData(mxArray** pdataref,char* string){{{1*/
     112/*FUNCTION WriteData(mxArray** pdataref,char* string){{{*/
    113113void WriteData(mxArray** pdataref,char* string){
    114114
     
    118118
    119119/*ISSM objects*/
    120 /*FUNCTION WriteData(mxArray** pdataref,BamgGeom* bamggeom){{{1*/
     120/*FUNCTION WriteData(mxArray** pdataref,BamgGeom* bamggeom){{{*/
    121121void WriteData(mxArray** pdataref,BamgGeom* bamggeom){
    122122
     
    158158}
    159159/*}}}*/
    160 /*FUNCTION WriteData(mxArray** pdataref,BamgMesh* bamgmesh){{{1*/
     160/*FUNCTION WriteData(mxArray** pdataref,BamgMesh* bamgmesh){{{*/
    161161void WriteData(mxArray** pdataref,BamgMesh* bamgmesh){
    162162
     
    216216}
    217217/*}}}*/
    218 /*FUNCTION WriteData(mxArray** pdataref,Matrix* matrix){{{1*/
     218/*FUNCTION WriteData(mxArray** pdataref,Matrix* matrix){{{*/
    219219void WriteData(mxArray** pdataref,Matrix* matrix){
    220220               
     
    249249
    250250                /*Free ressources:*/
    251                 xfree((void**)&matrix_ptr);
    252 
    253         }
    254         else{
    255                 dataref = mxCreateDoubleMatrix(0,0,mxREAL);
    256         }
    257 
    258         *pdataref=dataref;
    259 }
    260 /*}}}*/
    261 /*FUNCTION WriteData(mxArray** pdataref,Vector* vector){{{1*/
     251                xDelete<double>(matrix_ptr);
     252
     253        }
     254        else{
     255                dataref = mxCreateDoubleMatrix(0,0,mxREAL);
     256        }
     257
     258        *pdataref=dataref;
     259}
     260/*}}}*/
     261/*FUNCTION WriteData(mxArray** pdataref,Vector* vector){{{*/
    262262void WriteData(mxArray** pdataref,Vector* vector){
    263263       
     
    290290
    291291        /*Clean-up and return*/
    292         xfree((void**)&vector_ptr);
     292        xDelete<double>(vector_ptr);
    293293        *pdataref=dataref;
    294294}
     
    296296
    297297/*Toolkit*/
    298 /*FUNCTION SetStructureField{{{1*/
     298/*FUNCTION SetStructureField{{{*/
    299299void SetStructureField(mxArray* dataref,const char* fieldname,int M,int N,double* fieldpointer){
    300300
  • issm/trunk/src/c/modules/AverageFilterx/AverageFilterx.cpp

    r3913 r12706  
    1818
    1919        /*output: */
    20         double*         imageout=NULL;
     20        double* imageout=NULL;
    2121
    22         imageout=(double*)xmalloc(samps*lines*sizeof(double));
     22        imageout=xNew<double>(samps*lines);
    2323
    2424        for ( i = 0; i < lines; i++ ){
  • issm/trunk/src/c/modules/AverageOntoPartitionx/AverageOntoPartitionx.cpp

    r11995 r12706  
    6565
    6666        /*Free ressources:*/
    67         xfree((void**)&qmu_part);
     67        xDelete<double>(qmu_part);
    6868        xdelete(&partition_contributions);
    6969        xdelete(&partition_areas);
  • issm/trunk/src/c/modules/BamgConvertMeshx/BamgConvertMeshx.cpp

    r5208 r12706  
    1212using namespace std;
    1313
    14 int BamgConvertMeshx(BamgMesh* bamgmesh,BamgGeom* bamggeom,double* index,double* x,double* y,int nods,int nels){
    15 
    16         /*Intermediary*/
    17         int i,j,k;
    18         int verbose=0;
    19         int noerr=1;
     14int BamgConvertMeshx(BamgMesh* bamgmesh,BamgGeom* bamggeom,int* index,double* x,double* y,int nods,int nels){
    2015
    2116        /*Options*/
    22         BamgOpts* bamgopts=NULL;
    23         bamgopts=new BamgOpts();
     17        BamgOpts* bamgopts=new BamgOpts();
    2418
    25         // read mesh
    26         if(verbose) printf("Reading mesh\n");
     19        /*read mesh*/
    2720        Mesh Th(index,x,y,nods,nels);
    2821
    29         //write mesh and geometry
    30         if (verbose) printf("Write Geometry\n");
     22        /*write mesh and geometry*/
    3123        Th.Gh.WriteGeometry(bamggeom,bamgopts);
    32         if (verbose) printf("Write Mesh\n");
    3324        Th.WriteMesh(bamgmesh,bamgopts);
    3425
    35         //clean up
     26        /*clean up and return*/
    3627        delete bamgopts;
    37 
    38         /*No error return*/
    39         return noerr;
     28        return 1;
    4029
    4130}
  • issm/trunk/src/c/modules/BamgConvertMeshx/BamgConvertMeshx.h

    r3913 r12706  
    99
    1010/* local prototypes: */
    11 int BamgConvertMeshx(BamgMesh* bamgmesh,BamgGeom* bamggeom,double* index,double* x,double* y,int nods,int nels);
     11int BamgConvertMeshx(BamgMesh* bamgmesh,BamgGeom* bamggeom,int* index,double* x,double* y,int nods,int nels);
    1212
    1313#endif
  • issm/trunk/src/c/modules/Bamgx/Bamgx.cpp

    r12330 r12706  
    3838        /*If no mesh in input, generate one*/
    3939        if(bamgmesh_in->TrianglesSize[0]==0){
    40                 /*Mesh generation {{{1*/
     40                /*Mesh generation {{{*/
    4141
    4242                //Step1: generate geometry Gh
    43                 if (verbosity>0) printf("Construction of a mesh from a given geometry\n");
    44                 if (verbosity>1) printf("   Processing geometry...\n");
     43                if (verbosity>0) _printLine_("Construction of a mesh from a given geometry");
     44                if (verbosity>1) _printLine_("   Processing geometry...");
    4545                Geometry Gh(bamggeom_in,bamgopts);
    4646
     
    5050
    5151                //build metric using geometry
    52                 if (verbosity>1) printf("   Generating Metric...\n");
     52                if (verbosity>1) _printLine_("   Generating Metric...");
    5353                for(i=0;i<Gh.nbv;i++){
    5454                        Metric M=Gh[i];
     
    6060
    6161                //generate mesh
    62                 if (verbosity>1) printf("   Generating Mesh...\n");
     62                if (verbosity>1) _printLine_("   Generating Mesh...");
    6363                Mesh Th(maxnbv,Gh,bamgopts);
    6464
     
    7373
    7474                //Build output
    75                 if (verbosity>1) printf("   Write Mesh...\n");
     75                if (verbosity>1) _printLine_("   Write Mesh...");
    7676                Th.WriteMesh(bamgmesh_out,bamgopts);
    77                 if (verbosity>1) printf("   Write Geometry...\n");
     77                if (verbosity>1) _printLine_("   Write Geometry...");
    7878                Gh.WriteGeometry(bamggeom_out,bamgopts);
    7979
     
    8484        }
    8585        else{
    86                 /*Anisotropic mesh adaptation {{{1*/
     86                /*Anisotropic mesh adaptation {{{*/
    8787
    8888                // read background mesh
    89                 if (verbosity>0) printf("Anisotropic mesh adaptation\n");
    90                 if (verbosity>1) printf("   Processing initial mesh and geometry...\n");
     89                if (verbosity>0) _printLine_("Anisotropic mesh adaptation");
     90                if (verbosity>1) _printLine_("   Processing initial mesh and geometry...");
    9191                Mesh BTh(bamggeom_in,bamgmesh_in,bamgopts);
    9292
     
    100100                //Generate initial metric
    101101                if (bamgopts->metric){
    102                         if (verbosity>1) printf("   Processing Metric...\n");
     102                        if (verbosity>1) _printLine_("   Processing Metric...");
    103103                        BTh.ReadMetric(bamgopts);
    104104                }
    105105                else {
    106                         if (verbosity>1) printf("   Generating initial Metric...\n");
     106                        if (verbosity>1) _printLine_("   Generating initial Metric...");
    107107                        Metric Mhmax(bamgopts->hmax);
    108108                        for (int iv=0;iv<BTh.nbv;iv++) BTh[iv].m = Mhmax;
     
    111111                //use present fields to generate metric if present
    112112                if (bamgopts->field){
    113                         if (verbosity>1) printf("   Merge metric with field provided...\n");
     113                        if (verbosity>1) _printLine_("   Merge metric with field provided...");
    114114                        BTh.AddMetric(bamgopts);
    115115                }
     
    117117                // change using hVertices if provided
    118118                if(bamgopts->hVertices && bamgopts->hVerticesSize[0]==BTh.nbv){
    119                         if (verbosity>1) printf("   Merging Metric with hVertices...\n");
     119                        if (verbosity>1) _printLine_("   Merging Metric with hVertices...");
    120120                        for (i=0;i<BTh.nbv;i++){
    121                                 if (!isnan(bamgopts->hVertices[i])){
     121                                if (!xIsNan<IssmDouble>(bamgopts->hVertices[i])){
    122122                                        BTh[i].m=Metric((float)bamgopts->hVertices[i]);
    123123                                }
     
    127127                // change using hminVertices if provided
    128128                if (bamgopts->hminVertices){
    129                         if (verbosity>1) printf("   Merging Metric with hminVertices...\n");
     129                        if (verbosity>1) _printLine_("   Merging Metric with hminVertices...");
    130130                        for (i=0;i<BTh.nbv;i++){
    131                                 if (!isnan(bamgopts->hminVertices[i])){
     131                                if (!xIsNan<IssmDouble>(bamgopts->hminVertices[i])){
    132132                                        Metric M=BTh.vertices[i].m;
    133133                                        EigenMetric Vp(M/coef);
     
    140140                // change using hmaxVertices if provided
    141141                if (bamgopts->hmaxVertices){
    142                         if (verbosity>1) printf("   Merging Metric with hmaxVertices...\n");
     142                        if (verbosity>1) _printLine_("   Merging Metric with hmaxVertices...");
    143143                        for (i=0;i<BTh.nbv;i++){
    144                                 if (!isnan(bamgopts->hmaxVertices[i])){
     144                                if (!xIsNan<IssmDouble>(bamgopts->hmaxVertices[i])){
    145145                                        Metric M=BTh.vertices[i].m;
    146146                                        EigenMetric Vp(M/coef);
     
    164164
    165165                //Build new mesh
    166                 if (verbosity>1) printf("   Generating Mesh...\n");
     166                if (verbosity>1) _printLine_("   Generating Mesh...");
    167167                Thr=&BTh,Thb=0;
    168168                Mesh & Th( *(0 ?  new Mesh(*Thr,&Thr->Gh,Thb,maxnbv) :  new Mesh(maxnbv,BTh,bamgopts,bamgopts->KeepVertices)));
     
    185185                if(verbosity>0) {
    186186                        if (Th.nbt-Th.nbtout-Th.nbq*2){
    187                                 printf("   new number of triangles = %i\n",(Th.nbt-Th.nbtout-Th.nbq*2));
     187                                _printLine_("   new number of triangles = " << (Th.nbt-Th.nbtout-Th.nbq*2));
    188188                        }
    189189                        if (Th.nbq ){
    190                                 printf("   new number of quads = %i\n",Th.nbq);
     190                                _printLine_("   new number of quads = " << Th.nbq);
    191191                        }
    192192                }
    193193
    194194                //Build output
    195                 if (verbosity>1) printf("   Write Mesh...\n");
     195                if (verbosity>1) _printLine_("   Write Mesh...");
    196196                Th.WriteMesh(bamgmesh_out,bamgopts);
    197                 if (verbosity>1) printf("   Write Geometry...\n");
     197                if (verbosity>1) _printLine_("   Write Geometry...");
    198198                Th.Gh.WriteGeometry(bamggeom_out,bamgopts);
    199                 if (verbosity>1) printf("   Write Metric...\n");
     199                if (verbosity>1) _printLine_("   Write Metric...");
    200200                BTh.WriteMetric(bamgopts);
    201201
     
    207207
    208208        /*No error return*/
    209         if (verbosity>1) printf("   Exiting Bamg.\n");
     209        if (verbosity>1) _printLine_("   Exiting Bamg.");
    210210        return noerr;
    211211
  • issm/trunk/src/c/modules/Chacox/Chacox.cpp

    r11527 r12706  
    6666
    6767        if (DEBUG_TRACE > 0) {
    68                 printf("<Entering main>\n");
     68                _printLine_("<Entering main>");
    6969        }
    7070
    7171        if (PRINT_HEADERS) {
    72                 printf("\n                    Chaco 2.0\n");
    73                 printf("          Sandia National Laboratories\n\n");
     72                _printLine_("\n                    Chaco 2.0");
     73                _printLine_("          Sandia National Laboratories\n");
    7474        }
    7575
     
    177177
    178178        if (DEBUG_MEMORY > 0) {
    179                 printf("\n");
     179                _printLine_("");
    180180                smalloc_stats();
    181181        }
     
    185185
    186186        if (DEBUG_TRACE > 1) {
    187                 printf("<Leaving main>\n");
     187                _printLine_("<Leaving main>");
    188188        }
    189189       
  • issm/trunk/src/c/modules/Chacox/input_parse.cpp

    r11527 r12706  
    3838
    3939        if (DEBUG_TRACE > 0) {
    40                 printf("<Entering input_parse>\n");
     40                _printLine_("<Entering input_parse>");
    4141        }
    4242
    4343        if (PROMPT) {
    44                 printf("Parallel machine architecture:\n");
    45                 printf("  (0) Hypercube\n");
    46                 printf("  (1) One-dimensional mesh\n");
    47                 printf("  (2) Two-dimensional mesh\n");
    48                 printf("  (3) Three-dimensional mesh\n");
     44                _printLine_("Parallel machine architecture:");
     45                _printLine_("  (0) Hypercube");
     46                _printLine_("  (1) One-dimensional mesh");
     47                _printLine_("  (2) Two-dimensional mesh");
     48                _printLine_("  (3) Three-dimensional mesh");
    4949        }
    5050        *architecture = (int)options[OPT_ARCH];
     
    5757        /* Name output assignment file. */
    5858        if (PROMPT)
    59                 printf("Assignment output file: ");
     59                _printString_("Assignment output file: ");
    6060        outassignname = NULL;
    6161
    6262        /* Name output results file. */
    6363        if (PROMPT)
    64                 printf("File name for saving run results: ");
     64                _printString_("File name for saving run results: ");
    6565        outfilename = NULL;
    6666
     
    7575        else {
    7676                if (PROMPT) {
    77                         printf("Global partitioning method:\n");
    78                         printf("  (1) Multilevel-KL\n");
    79                         printf("  (2) Spectral\n");
    80                         printf("  (3) Inertial\n");
    81                         printf("  (4) Linear\n");
    82                         printf("  (5) Random\n");
    83                         printf("  (6) Scattered\n");
    84                         printf("  (7) Read-from-file\n");
     77                        _printLine_("Global partitioning method:");
     78                        _printLine_("  (1) Multilevel-KL");
     79                        _printLine_("  (2) Spectral");
     80                        _printLine_("  (3) Inertial");
     81                        _printLine_("  (4) Linear");
     82                        _printLine_("  (5) Random");
     83                        _printLine_("  (6) Scattered");
     84                        _printLine_("  (7) Read-from-file");
    8585                }
    8686                *global_method = (int)options[OPT_GLOBAL];
     
    9494        if (*global_method == 7) {      /* Name and open input assignment file. */
    9595                if (PROMPT)
    96                         printf("Assignment input file: ");
     96                        _printString_("Assignment input file: ");
    9797        }
    9898
    9999        else if (*global_method == 3) {
    100100                if (PROMPT)
    101                         printf("Geometry input file name: ");
     101                        _printString_("Geometry input file name: ");
    102102        }
    103103
    104104        else if (*global_method == 2) {
    105105                if (PROMPT) {
    106                         printf("Eigensolver:\n");
    107                         printf("  (1) Multilevel RQI/Symmlq\n");
    108                         printf("  (2) Lanczos\n");
     106                        _printLine_("Eigensolver:");
     107                        _printLine_("  (1) Multilevel RQI/Symmlq");
     108                        _printLine_("  (2) Lanczos");
    109109                }
    110110                eigensolver = (int)options[OPT_RQI];
     
    117117                        if (MATCH_TYPE == 5) {  /* geometric matching */
    118118                                if (PROMPT)
    119                                         printf("Geometry input file name: ");
     119                                        _printString_("Geometry input file name: ");
    120120                        }
    121121                        *rqi_flag = 1;
    122122                        if (PROMPT)
    123                                 printf("Number of vertices to coarsen down to: ");
     123                                _printString_("Number of vertices to coarsen down to: ");
    124124                        *vmax = (int)options[OPT_VMAX];
    125125                        if (*vmax <= 0) {
     
    137137                if (MATCH_TYPE == 5) {          /* geometric matching */
    138138                        if (PROMPT)
    139                                 printf("Geometry input file name: ");
    140                 }
    141                 if (PROMPT)
    142                         printf("Number of vertices to coarsen down to: ");
     139                                _printString_("Geometry input file name: ");
     140                }
     141                if (PROMPT)
     142                        _printString_("Number of vertices to coarsen down to: ");
    143143                *vmax = (int)options[OPT_VMAX];
    144144                if (*vmax <= 0) {
     
    168168        else {
    169169                if (PROMPT) {
    170                         printf("Local refinement method:\n");
    171                         printf("  (1) Kernighan-Lin\n");
    172                         printf("  (2) None\n");
     170                        _printLine_("Local refinement method:");
     171                        _printLine_("  (1) Kernighan-Lin");
     172                        _printLine_("  (2) None");
    173173                }
    174174                *local_method = (int)options[OPT_LOCAL];
     
    185185                *ndims_tot = 0;
    186186                if (PROMPT)
    187                         printf("Total number of target hypercube dimensions: ");
     187                        _printString_("Total number of target hypercube dimensions: ");
    188188                *ndims_tot = nparts[0];
    189189                if (*ndims_tot < 1) {
    190                         printf(" Number of divisions must be at least 1\n");
     190                        _printLine_(" Number of divisions must be at least 1");
    191191                        printf("%s -- Number of divisions %d must be at least 1.\n",
    192192                                   __FUNCT__,nparts[0]);
     
    200200                if (*architecture == 2) {
    201201                        if (PROMPT)
    202                                 printf("X and Y extent of of 2-D mesh: ");
     202                                _printString_("X and Y extent of of 2-D mesh: ");
    203203                        mesh_dims[0] = nparts[0];
    204204                        mesh_dims[1] = nparts[1];
     
    206206                else if (*architecture == 3) {
    207207                        if (PROMPT)
    208                                 printf("X, Y and Z extent of 3-D mesh: ");
     208                                _printString_("X, Y and Z extent of 3-D mesh: ");
    209209                        mesh_dims[0] = nparts[0];
    210210                        mesh_dims[1] = nparts[1];
     
    213213                else {                  /* Anything else => 1-D mesh */
    214214                        if (PROMPT)
    215                                 printf("Size of 1-D mesh: ");
     215                                _printString_("Size of 1-D mesh: ");
    216216                        mesh_dims[0] = nparts[0];
    217217                        *architecture = 1;
     
    227227        else if (*nprocs <= 7) {
    228228                if (PROMPT) {
    229                         printf("Partitioning dimension: \n");
    230                         printf("  (1) Bisection\n");
    231                         printf("  (2) Quadrisection\n");
     229                        _printLine_("Partitioning dimension: ");
     230                        _printLine_("  (1) Bisection");
     231                        _printLine_("  (2) Quadrisection");
    232232                }
    233233                *ndims = (int)options[OPT_NDIMS];
     
    240240        else {
    241241                if (PROMPT) {
    242                         printf("Partitioning dimension: \n");
    243                         printf("  (1) Bisection\n");
    244                         printf("  (2) Quadrisection\n");
    245                         printf("  (3) Octasection\n");
     242                        _printLine_("Partitioning dimension: ");
     243                        _printLine_("  (1) Bisection");
     244                        _printLine_("  (2) Quadrisection");
     245                        _printLine_("  (3) Octasection");
    246246                }
    247247                *ndims = (int)options[OPT_NDIMS];
  • issm/trunk/src/c/modules/ComputeBasalStressx/ComputeBasalStressx.cpp

    r11995 r12706  
    1515        int i;
    1616        int      found=0;
    17         double   numberofelements;
     17        IssmDouble   numberofelements;
    1818        Element* element=NULL;
    1919
     
    2525
    2626        /*Allocate sigma on numberofelements: */
    27         sigma=new Vector((int)numberofelements);
     27        sigma=new Vector(reCast<int>(numberofelements));
    2828
    2929        /*Compute basal stress for each element: */
  • issm/trunk/src/c/modules/ConfigureObjectsx/ConfigureObjectsx.cpp

    r9761 r12706  
    2525        parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
    2626       
    27         _printf_(VerboseMProcessor(),"      Configuring elements...\n");
     27        if(VerboseMProcessor()) _pprintLine_("      Configuring elements...");
    2828        for (i=0;i<elements->Size();i++){
    2929                element=(Element*)elements->GetObjectByOffset(i);
    3030                element->Configure(elements,loads,nodes,materials,parameters);
    3131        }
    32         _printf_(VerboseMProcessor(),"      Configuring loads...\n");
     32        if(VerboseMProcessor()) _pprintLine_("      Configuring loads...");
    3333        for (i=0;i<loads->Size();i++){
    3434                load=(Load*)loads->GetObjectByOffset(i);
     
    3737                }
    3838        }
    39         _printf_(VerboseMProcessor(),"      Configuring nodes...\n");
     39        if(VerboseMProcessor()) _pprintLine_("      Configuring nodes...");
    4040        for (i=0;i<nodes->Size();i++){
    4141                node=(Node*)nodes->GetObjectByOffset(i);
     
    4545        }
    4646       
    47         _printf_(VerboseMProcessor(),"      Configuring materials...\n");
     47        if(VerboseMProcessor()) _pprintLine_("      Configuring materials...");
    4848        for (i=0;i<materials->Size();i++){
    4949                material=(Material*)materials->GetObjectByOffset(i);
  • issm/trunk/src/c/modules/ConstraintsStatex/ConstraintsStatex.cpp

    r9761 r12706  
    2525
    2626        /*Display message*/
    27         _printf_(VerboseModule(),"   Constraining penalties\n");
     27        if(VerboseModule()) _pprintLine_("   Constraining penalties");
    2828
    2929        /*recover parameters: */
  • issm/trunk/src/c/modules/ConstraintsStatex/RiftConstraintsState.cpp

    r12330 r12706  
    1212
    1313/*current module: */
    14 /*RiftIsPresent(Loads* loads,int configuration_type){{{1*/
     14/*RiftIsPresent(Loads* loads,int configuration_type){{{*/
    1515int RiftIsPresent(Loads* loads,int configuration_type){
    1616
     
    4141}
    4242/*}}}*/
    43 /*RiftConstraintsState(int* pconverged, int* pnum_unstable_constraints,Loads* loads,int min_mechanical_constraints,int configuration_type){{{1*/
     43/*RiftConstraintsState(int* pconverged, int* pnum_unstable_constraints,Loads* loads,int min_mechanical_constraints,int configuration_type){{{*/
    4444void RiftConstraintsState(int* pconverged, int* pnum_unstable_constraints,Loads* loads,int min_mechanical_constraints,int configuration_type){
    4545
     
    5656        }
    5757        else if(num_unstable_constraints<=min_mechanical_constraints){
    58                 _printf_(VerboseModule(),"   freezing constraints\n");
     58                if(VerboseModule()) _pprintLine_("   freezing constraints");
    5959                RiftFreezeConstraints(loads,configuration_type);
    6060        }
     
    6565}
    6666/*}}}*/
    67 /*RiftConstrain(int* pnum_unstable_constraints,Loads* loads,int configuration_type){{{1*/
     67/*RiftConstrain(int* pnum_unstable_constraints,Loads* loads,int configuration_type){{{*/
    6868void RiftConstrain(int* pnum_unstable_constraints,Loads* loads,int configuration_type){
    6969
     
    106106}
    107107/*}}}*/
    108 /*RiftIsFrozen(Loads* loads,int configuration_type){{{1*/
     108/*RiftIsFrozen(Loads* loads,int configuration_type){{{*/
    109109int RiftIsFrozen(Loads* loads,int configuration_type){
    110110
     
    144144}
    145145/*}}}*/
    146 /*RiftFreezeConstraints(Loads* loads,int configuration_type){{{1*/
     146/*RiftFreezeConstraints(Loads* loads,int configuration_type){{{*/
    147147void RiftFreezeConstraints(Loads* loads,int configuration_type){
    148148
     
    172172
    173173/*diverse trials and errors: */
    174 /*RiftIsMaterialStable(Loads* loads){{{1*/
     174/*RiftIsMaterialStable(Loads* loads){{{*/
    175175int RiftIsMaterialStable(Loads* loads){
    176176
     
    204204}
    205205/*}}}*/
    206 /*RiftIsPreStable(Loads* loads){{{1*/
     206/*RiftIsPreStable(Loads* loads){{{*/
    207207int RiftIsPreStable(Loads* loads){
    208208
     
    243243}
    244244/*}}}*/
    245 /*RiftSetPreStable(Loads* loads){{{1*/
     245/*RiftSetPreStable(Loads* loads){{{*/
    246246void RiftSetPreStable(Loads* loads){
    247247
     
    264264}
    265265/*}}}*/
    266 /*RiftPreConstrain(int* pnum_unstable_constraints,Loads* loads){{{1*/
     266/*RiftPreConstrain(int* pnum_unstable_constraints,Loads* loads){{{*/
    267267void RiftPreConstrain(int* pnum_unstable_constraints,Loads* loads){
    268268
     
    300300}
    301301/*}}}*/
    302 /*RiftMaxPenetrationInInputs(Loads* loads){{{1*/
     302/*RiftMaxPenetrationInInputs(Loads* loads){{{*/
    303303void RiftMaxPenetrationInInputs(Loads* loads){
    304304
     
    309309
    310310        /*rift penetration: */
    311         double max_penetration=0;
    312         double mpi_max_penetration;
    313         double penetration;
     311        IssmDouble max_penetration=0;
     312        IssmDouble mpi_max_penetration;
     313        IssmDouble penetration;
    314314
    315315        /*Ok, we are going to find the node pairs which are not penetrating, even though they
     
    342342}
    343343/*}}}*/
    344 /*RiftPotentialUnstableConstraints(Loads* loads){{{1*/
     344/*RiftPotentialUnstableConstraints(Loads* loads){{{*/
    345345int RiftPotentialUnstableConstraints(Loads* loads){
    346346
  • issm/trunk/src/c/modules/ContourToMeshx/ContourToMeshx.cpp

    r12330 r12706  
    7070
    7171        /*Free ressources:*/
    72         xfree((void**)&in_nod_serial);
     72        xDelete<double>(in_nod_serial);
    7373
    7474        return noerr;
  • issm/trunk/src/c/modules/ControlInputGetGradientx/ControlInputGetGradientx.cpp

    r11995 r12706  
    3333
    3434        /*Clean up and return*/
    35         xfree((void**)&control_type);
     35        xDelete<int>(control_type);
    3636        *pgradient=gradient;
    3737}
  • issm/trunk/src/c/modules/ControlInputScaleGradientx/ControlInputScaleGradientx.cpp

    r11527 r12706  
    3737
    3838        /*Clean up and return*/
    39         xfree((void**)&control_type);
    40         xfree((void**)&scalar_list);
     39        xDelete<int>(control_type);
     40        xDelete<double>(scalar_list);
    4141}
  • issm/trunk/src/c/modules/ControlInputSetGradientx/ControlInputSetGradientx.cpp

    r11995 r12706  
    2727
    2828        /*Clean up and return*/
    29         xfree((void**)&control_type);
     29        xDelete<int>(control_type);
    3030
    3131}
     
    3939
    4040        /*Clean up and return*/
    41         xfree((void**)&serial_gradient);
     41        xDelete<double>(serial_gradient);
    4242}
  • issm/trunk/src/c/modules/CostFunctionx/CostFunctionx.cpp

    r11995 r12706  
    3535
    3636        /*Assign output pointers: */
    37         xfree((void**)&responses);
     37        xDelete<int>(responses);
    3838        *pJ=J;
    3939}
  • issm/trunk/src/c/modules/CreateJacobianMatrixx/CreateJacobianMatrixx.cpp

    r11995 r12706  
    1010#include "../../EnumDefinitions/EnumDefinitions.h"
    1111
    12 void CreateJacobianMatrixx(Matrix** pJff,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,double kmax){
     12void CreateJacobianMatrixx(Matrix** pJff,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,IssmDouble kmax){
    1313       
    1414        int      i,connectivity;
  • issm/trunk/src/c/modules/CreateJacobianMatrixx/CreateJacobianMatrixx.h

    r11995 r12706  
    1010
    1111/* local prototypes: */
    12 void CreateJacobianMatrixx(Matrix** pJff,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,double kmax);
     12void CreateJacobianMatrixx(Matrix** pJff,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,IssmDouble kmax);
    1313
    1414#endif  /* _CREATEJACOBIANMATRIXX_H */
  • issm/trunk/src/c/modules/DakotaResponsesx/DakotaResponsesx.cpp

    r9650 r12706  
    3030        double femmodel_response;
    3131        int    flag;
    32         double* vertex_response=NULL;
    33         double* qmu_response=NULL;
    34 
    35         double* responses_pointer=NULL;
     32        double *vertex_response   = NULL;
     33        double *qmu_response      = NULL;
     34        double *responses_pointer = NULL;
    3635
    3736        /*retrieve npart: */
     
    6665
    6766                        /*Free ressources:*/
    68                         xfree((void**)&vertex_response);
    69                         xfree((void**)&qmu_response);
     67                        xDelete<double>(vertex_response);
     68                        xDelete<double>(qmu_response);
    7069
    7170                }
     
    8786                }
    8887                else if (flag==NodalEnum){
    89                         _error_(" nodal response functions not supported yet!");
     88                        _error2_("nodal response functions not supported yet!");
    9089
    9190                        /*increment response_pointer :*/
     
    105104                        }
    106105                }
    107                 else _error_("%s%i%s"," flag type ",flag," not supported yet for response analysis");
     106                else _error2_("flag type " << flag << " not supported yet for response analysis");
    108107        }
    109108
     
    111110        /*Synthesize echo: {{{*/
    112111        if(my_rank==0){
    113                 printf("   responses: %i: ",d_numresponses);
    114                 for(i=0;i<d_numresponses-1;i++)printf("%g|",d_responses[i]);
    115                 printf("%g",d_responses[d_numresponses-1]);
    116                 printf("\n");
     112                _printString_("   responses: " << d_numresponses << ": ");
     113                for(i=0;i<d_numresponses-1;i++)_printString_(d_responses[i] << "|");
     114                _printString_(d_responses[d_numresponses-1]);
     115                _printLine_("");
    117116        }
    118117        /*}}}*/
  • issm/trunk/src/c/modules/Dakotax/DakotaFree.cpp

    r9761 r12706  
    2222        extern int my_rank;
    2323       
    24         double* variables=NULL;
    25         char**  variables_descriptors=NULL;
    26         char**  responses_descriptors=NULL;
    27         char*   string=NULL;
     24        double  *variables             = NULL;
     25        char   **variables_descriptors = NULL;
     26        char   **responses_descriptors = NULL;
     27        char    *string                = NULL;
    2828
    2929        /*recover pointers: */
     
    3535        /*Free variables and variables_descriptors only on cpu !=0*/
    3636        if(my_rank!=0){
    37                 xfree((void**)&variables);
     37                xDelete<double>(variables);
    3838                for(i=0;i<numvariables;i++){
    3939                        string=variables_descriptors[i];
    40                         xfree((void**)&string);
     40                        xDelete<char>(string);
    4141                }
    42                 xfree((void**)&variables_descriptors);
     42                xDelete<char*>(variables_descriptors);
    4343        }
    4444       
     
    4646        for(i=0;i<numresponses;i++){
    4747                string=responses_descriptors[i];
    48                 xfree((void**)&string);
     48                xDelete<char>(string);
    4949        }
    5050        //rest of dynamic allocations.
    51         xfree((void**)&responses_descriptors);
     51        xDelete<char*>(responses_descriptors);
    5252
    5353        /*Assign output pointers:*/
     
    5656        *presponses_descriptors=responses_descriptors;
    5757}
    58 
  • issm/trunk/src/c/modules/Dakotax/DakotaMPI_Bcast.cpp

    r9761 r12706  
    3838       
    3939        /*variables:*/
    40         if(my_rank!=0)variables=(double*)xmalloc(numvariables*sizeof(double));
     40        if(my_rank!=0)variables=xNew<double>(numvariables);
    4141        MPI_Bcast(variables,numvariables,MPI_DOUBLE,0,MPI_COMM_WORLD);
    4242
    4343        /*variables_descriptors: */
    4444        if(my_rank!=0){
    45                 variables_descriptors=(char**)xmalloc(numvariables*sizeof(char*));
     45                variables_descriptors=xNew<char*>(numvariables);
    4646        }
    4747        for(i=0;i<numvariables;i++){
     
    5151                }
    5252                MPI_Bcast(&string_length,1,MPI_INT,0,MPI_COMM_WORLD);
    53                 if(my_rank!=0)string=(char*)xmalloc(string_length);
     53                if(my_rank!=0)string=xNew<char>(string_length);
    5454                MPI_Bcast(string,string_length,MPI_CHAR,0,MPI_COMM_WORLD);
    5555                if(my_rank!=0)variables_descriptors[i]=string;
  • issm/trunk/src/c/modules/Dakotax/Dakotax.cpp

    r12330 r12706  
    121121
    122122        /*Free ressources:*/
    123         xfree((void**)&dakota_input_file);
    124         xfree((void**)&dakota_error_file);
    125         xfree((void**)&dakota_output_file);
     123        xDelete<char>(dakota_input_file);
     124        xDelete<char>(dakota_error_file);
     125        xDelete<char>(dakota_output_file);
    126126
    127127        #endif //#ifdef _HAVE_DAKOTA_
  • issm/trunk/src/c/modules/Dakotax/DescriptorIndex.cpp

    r9761 r12706  
    2323        /*retrieve first token, separated by underscore: */
    2424        pch = strtok (descriptor,"_");
    25         if(!pch)_error_("%s%s%s"," descriptor ",descriptor," is not correctly formatted!");
     25        if(!pch)_error2_("descriptor " << descriptor << " is not correctly formatted!");
    2626
    2727        if (strncmp(pch,"scaled",6)==0){
    2828                /*we have a scaled variable. recover the root: */
    2929                pch = strtok (NULL, "_");
    30                 if(!pch)_error_("%s%s%s"," scaled descriptor ",descriptor," is not correctly formatted!");
     30                if(!pch)_error2_("scaled descriptor " << descriptor << " is not correctly formatted!");
    3131                memcpy(root,pch,(strlen(pch)+1)*sizeof(char));
    3232
     
    4444                /*we have an indexed variable. recover the root: */
    4545                pch = strtok (NULL, "_");
    46                 if(!pch)_error_("%s%s%s"," indexed descriptor ",descriptor," is not correctly formatted!");
     46                if(!pch)_error2_("indexed descriptor " << descriptor << " is not correctly formatted!");
    4747                memcpy(root,pch,(strlen(pch)+1)*sizeof(char));
    4848                /*now recover  the index: */
    4949                pch = strtok (NULL, "_");
    50                 if(!pch)_error_("%s%s%s"," indexed descriptor ",descriptor," is not correctly formatted!");
     50                if(!pch)_error2_("indexed descriptor " << descriptor << " is not correctly formatted!");
    5151                sscanf(pch,"%i",pindex);
    5252                return IndexedEnum;
     
    5555                /*we have an indexed variable. recover the root: */
    5656                pch = strtok (NULL, "_");
    57                 if(!pch)_error_("%s%s%s"," nodal descriptor ",descriptor," is not correctly formatted!");
     57                if(!pch)_error2_("nodal descriptor " << descriptor << " is not correctly formatted!");
    5858                memcpy(root,pch,(strlen(pch)+1)*sizeof(char));
    5959                /*now recover  the index: */
    6060                pch = strtok (NULL, "_");
    61                 if(!pch)_error_("%s%s%s"," nodal descriptor ",descriptor," is not correctly formatted!");
     61                if(!pch)_error2_("nodal descriptor " << descriptor << " is not correctly formatted!");
    6262                sscanf(pch,"%i",pindex);
    6363                return NodalEnum;
  • issm/trunk/src/c/modules/Dakotax/SpawnCoreParallel.cpp

    r9775 r12706  
    5353        /*synchronize all cpus, as CPU 0 is probably late (it is starting the entire dakota strategy!) : */
    5454        MPI_Barrier(MPI_COMM_WORLD);
    55         _printf_(VerboseQmu(),"qmu iteration: %i\n",counter);
     55        if(VerboseQmu()) _pprintLine_("qmu iteration: " << counter);
    5656       
    5757        /*retrieve parameters: */
     
    6767
    6868        /*Determine solution sequence: */
    69         _printf_(VerboseQmu(),"%s%s%s\n","Starting ",EnumToStringx(solution_type)," core:");
     69        if(VerboseQmu()) _pprintLine_("Starting " << EnumToStringx(solution_type) << " core:");
    7070        CorePointerFromSolutionEnum(&solutioncore,femmodel->parameters,solution_type);
    7171        #ifdef _HAVE_CONTROL_
    7272        if(control_analysis)solutioncore=&control_core;
    7373        #else
    74         _error_("ISSM was not compiled with control capabilities, exiting!");
     74        _error2_("ISSM was not compiled with control capabilities, exiting!");
    7575        #endif
    7676
     
    7979
    8080        /*compute responses: */
    81         _printf_(VerboseQmu(),"compute dakota responses:\n");
     81        if(VerboseQmu()) _pprintLine_("compute dakota responses:");
    8282        DakotaResponsesx(d_responses,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,responses_descriptors,numresponsedescriptors,d_numresponses);
    8383       
  • issm/trunk/src/c/modules/ElementConnectivityx/ElementConnectivityx.cpp

    r3913 r12706  
    3636        maxels=width-1;
    3737        /*Allocate connectivity: */
    38         elementconnectivity=(double*)xcalloc(nel*3,sizeof(double));
     38        elementconnectivity=xNewZeroInit<double>(nel*3);
    3939
    4040        /*Go through all elements, and for each element, go through its nodes, to get the neighbouring elements.
  • issm/trunk/src/c/modules/ElementResponsex/ElementResponsex.cpp

    r12330 r12706  
    3939        #ifdef _HAVE_MPI_
    4040        MPI_Allreduce ( &found,&sumfound,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
    41         if(!sumfound)_error_("%s%i%s","could not find material with id",index," to compute ElementResponse");
     41        if(!sumfound)_error2_("could not find material with id" << index << " to compute ElementResponse");
    4242        #endif
    4343
  • issm/trunk/src/c/modules/EnumToStringx/EnumToStringx.cpp

    r12347 r12706  
    154154                case SettingsResultsAsPatchesEnum : return "SettingsResultsAsPatches";
    155155                case SettingsWaitonlockEnum : return "SettingsWaitonlock";
    156                 case DebugPetscProfilingEnum : return "DebugPetscProfiling";
    157                 case PetscProfilingCurrentMemEnum : return "PetscProfilingCurrentMem";
    158                 case PetscProfilingCurrentFlopsEnum : return "PetscProfilingCurrentFlops";
    159                 case PetscProfilingSolutionTimeEnum : return "PetscProfilingSolutionTime";
     156                case DebugProfilingEnum : return "DebugProfiling";
     157                case ProfilingCurrentMemEnum : return "ProfilingCurrentMem";
     158                case ProfilingCurrentFlopsEnum : return "ProfilingCurrentFlops";
     159                case ProfilingSolutionTimeEnum : return "ProfilingSolutionTime";
    160160                case MaxIterationConvergenceFlagEnum : return "MaxIterationConvergenceFlag";
    161161                case SteadystateMaxiterEnum : return "SteadystateMaxiter";
     
    167167                case SurfaceforcingsMassBalanceEnum : return "SurfaceforcingsMassBalance";
    168168                case SurfaceforcingsIspddEnum : return "SurfaceforcingsIspdd";
     169                case SurfaceforcingsIssmbgradientsEnum : return "SurfaceforcingsIssmbgradients";
    169170                case SurfaceforcingsMonthlytemperaturesEnum : return "SurfaceforcingsMonthlytemperatures";
     171                case SurfaceforcingsHcEnum : return "SurfaceforcingsHc";
     172                case SurfaceforcingsSmbPosMaxEnum : return "SurfaceforcingsSmbPosMax";
     173                case SurfaceforcingsSmbPosMinEnum : return "SurfaceforcingsSmbPosMin";
     174                case SurfaceforcingsAPosEnum : return "SurfaceforcingsAPos";
     175                case SurfaceforcingsBPosEnum : return "SurfaceforcingsBPos";
     176                case SurfaceforcingsANegEnum : return "SurfaceforcingsANeg";
     177                case SurfaceforcingsBNegEnum : return "SurfaceforcingsBNeg";
    170178                case ThermalMaxiterEnum : return "ThermalMaxiter";
    171179                case ThermalPenaltyFactorEnum : return "ThermalPenaltyFactor";
     
    466474
    467475        len=strlen(EnumToStringx(enum_in));
    468         string=(char*)xmalloc((len+1)*sizeof(char));
     476        string=xNew<char>(len+1);
    469477        memcpy(string,EnumToStringx(enum_in),(len+1)*sizeof(char));
    470478
  • issm/trunk/src/c/modules/Exp2Kmlx/Exp2Kmlx.cpp

    r12330 r12706  
    1111#include "../modules.h"
    1212
    13 int Exp2Kmlx(char* filexp,char* filkml,
    14                          int sgn,
    15                          bool holes){
     13int Exp2Kmlx(char* filexp,char* filkml,int sgn,bool holes){
    1614
    1715        double  cm,sp;
    1816
    1917        Xy2lldef(&cm,&sp,sgn);
    20 
    21         return(Exp2Kmlx(filexp,filkml,
    22                                         sgn,cm,sp,
    23                                         holes));
     18        return(Exp2Kmlx(filexp,filkml,sgn,cm,sp,holes));
    2419}
    2520
    26 int Exp2Kmlx(char* filexp,char* filkml,
    27                          int sgn,double cm,double sp,
    28                          bool holes){
    29 
    30         int     i,j,iret=0;
    31         int     lwidth=1;
    32         double  popac=0.50;
    33         int     nprof;
    34         int     *pnvert=NULL;
    35         double  **pprofx=NULL,**pprofy=NULL;
    36         bool    *closed=NULL;
    37         double  *lat=NULL,*lon=NULL;
     21int Exp2Kmlx(char* filexp,char* filkml,int sgn,double cm,double sp,bool holes){
     22
     23        int      i        ,j,iret=0;
     24        int      lwidth = 1;
     25        double   popac  = 0.50;
     26        int      nprof;
     27        int     *pnvert = NULL;
     28        double **pprofx = NULL,**pprofy=NULL;
     29        bool    *closed = NULL;
     30        double  *lat    = NULL, *lon=NULL;
    3831
    3932        char    indent[81]="";
     
    5750        clock0=clock();
    5851        time0 =time(NULL);
    59         _printf_(true,"\nExp2Kmlx Module -- %s",ctime(&time0));
    60 
    61 /*  read exp file  */
     52        _pprintString_("\nExp2Kmlx Module -- " << ctime(&time0));
     53
     54        /*read exp file  */
    6255
    6356        if (!DomainOutlineRead(&nprof,&pnvert,&pprofx,&pprofy,&closed,filexp))
    64                 _error_("Error reading exp file.");
    65         _printf_(true,"Exp2Kmlx -- Reading %d exp profiles from file \"%s\".\n",nprof,filexp);
     57                _error2_("Error reading exp file.");
     58        _pprintLine_("Exp2Kmlx -- Reading " << nprof << " exp profiles from file \"" << filexp << "\".");
    6659//      for (i=0; i<nprof; i++)
    67 //              printf("i=%d; nvert=%d, closed=%d\n",i,pnvert[i],closed[i]);
     60//              _printLine_("i=" << i << "; nvert=" << pnvert[i] << ", closed=" << closed[i]);
    6861
    6962/*  construct kml file  */
     
    128121
    129122        if (holes && nprof && (pnvert[0] <= 1 || pprofx[0][pnvert[0]-1] != pprofx[0][0] || pprofy[0][pnvert[0]-1] != pprofy[0][0])) {
    130                 _printf_(true,"Warning -- Outer profile is not closed, so \"holes\" option will be ignored.\n");
     123                _pprintLine_("Warning -- Outer profile is not closed, so \"holes\" option will be ignored.");
    131124                holes=false;
    132125        }
     
    143136
    144137                kring->ncoord    =pnvert[i]-1;
    145                 lat=(double *) xmalloc(kring->ncoord*sizeof(double));
    146                 lon=(double *) xmalloc(kring->ncoord*sizeof(double));
     138                lat=xNew<double>(kring->ncoord);
     139                lon=xNew<double>(kring->ncoord);
    147140                Xy2llx(lat,lon,pprofx[i],pprofy[i],kring->ncoord,sgn,cm,sp);
    148                 kring->coords    =(double (*)[3]) xmalloc(kring->ncoord*3*sizeof(double));
     141                kring->coords=xNew<double>(kring->ncoord*3);
    149142                for (j=0; j<kring->ncoord; j++) {
    150                         kring->coords[j][0]=lon[j];
    151                         kring->coords[j][1]=lat[j];
    152                         kring->coords[j][2]=0.;
     143                        kring->coords[3*j+0]=lon[j];
     144                        kring->coords[3*j+1]=lat[j];
     145                        kring->coords[3*j+2]=0.;
    153146                }
    154                 xfree((void**)&lon);
    155                 xfree((void**)&lat);
     147                xDelete<double>(lon);
     148                xDelete<double>(lat);
    156149
    157150                (kpoly ->outer     )->AddObject((Object*)kring);
     
    160153                for (i=1; i<nprof; i++) {
    161154                        if (pnvert[i] <= 1 || pprofx[i][pnvert[i]-1] != pprofx[i][0] || pprofy[i][pnvert[i]-1] != pprofy[i][0]) {
    162                                 _printf_(true,"Warning -- Inner profile %d is not closed with \"holes\" specified, so it will be ignored.\n",i+1);
     155                                _pprintLine_("Warning -- Inner profile " << i+1 << " is not closed with \"holes\" specified, so it will be ignored.");
    163156                                continue;
    164157                        }
     
    167160
    168161                        kring->ncoord    =pnvert[i]-1;
    169                         lat=(double *) xmalloc(kring->ncoord*sizeof(double));
    170                         lon=(double *) xmalloc(kring->ncoord*sizeof(double));
     162                        lat=xNew<double>(kring->ncoord);
     163                        lon=xNew<double>(kring->ncoord);
    171164                        Xy2llx(lat,lon,pprofx[i],pprofy[i],kring->ncoord,sgn,cm,sp);
    172                         kring->coords    =(double (*)[3]) xmalloc(kring->ncoord*3*sizeof(double));
     165                        kring->coords    =xNew<double>(kring->ncoord*3);
    173166                        for (j=0; j<kring->ncoord; j++) {
    174                                 kring->coords[j][0]=lon[j];
    175                                 kring->coords[j][1]=lat[j];
    176                                 kring->coords[j][2]=0.;
    177                         }
    178                         xfree((void**)&lon);
    179                         xfree((void**)&lat);
     167                                kring->coords[3*j+0]=lon[j];
     168                                kring->coords[3*j+1]=lat[j];
     169                                kring->coords[3*j+2]=0.;
     170                        }
     171                        xDelete<double>(lon);
     172                        xDelete<double>(lat);
    180173
    181174                        (kpoly ->inner     )->AddObject((Object*)kring);
     
    204197
    205198                                kring->ncoord    =pnvert[i]-1;
    206                                 lat=(double *) xmalloc(kring->ncoord*sizeof(double));
    207                                 lon=(double *) xmalloc(kring->ncoord*sizeof(double));
     199                                lat=xNew<double>(kring->ncoord);
     200                                lon=xNew<double>(kring->ncoord);
    208201                                Xy2llx(lat,lon,pprofx[i],pprofy[i],kring->ncoord,sgn,cm,sp);
    209                                 kring->coords    =(double (*)[3]) xmalloc(kring->ncoord*3*sizeof(double));
     202                                kring->coords    =xNew<double>(kring->ncoord*3);
    210203                                for (j=0; j<kring->ncoord; j++) {
    211                                         kring->coords[j][0]=lon[j];
    212                                         kring->coords[j][1]=lat[j];
    213                                         kring->coords[j][2]=0.;
     204                                        kring->coords[3*j+0]=lon[j];
     205                                        kring->coords[3*j+1]=lat[j];
     206                                        kring->coords[3*j+2]=0.;
    214207                                }
    215                                 xfree((void**)&lon);
    216                                 xfree((void**)&lat);
     208                                xDelete<double>(lon);
     209                                xDelete<double>(lat);
    217210
    218211                                (kpoly ->outer     )->AddObject((Object*)kring);
     
    231224
    232225                                kline->ncoord    =pnvert[i];
    233                                 lat=(double *) xmalloc(kline->ncoord*sizeof(double));
    234                                 lon=(double *) xmalloc(kline->ncoord*sizeof(double));
     226                                lat=xNew<double>(kline->ncoord);
     227                                lon=xNew<double>(kline->ncoord);
    235228                                Xy2llx(lat,lon,pprofx[i],pprofy[i],kline->ncoord,sgn,cm,sp);
    236                                 kline->coords    =(double (*)[3]) xmalloc(kline->ncoord*3*sizeof(double));
     229                                kline->coords    =xNew<double>(kline->ncoord*3);
    237230                                for (j=0; j<kline->ncoord; j++) {
    238                                         kline->coords[j][0]=lon[j];
    239                                         kline->coords[j][1]=lat[j];
    240                                         kline->coords[j][2]=0.;
     231                                        kline->coords[3*j+0]=lon[j];
     232                                        kline->coords[3*j+1]=lat[j];
     233                                        kline->coords[3*j+2]=0.;
    241234                                }
    242                                 xfree((void**)&lon);
    243                                 xfree((void**)&lat);
     235                                xDelete<double>(lon);
     236                                xDelete<double>(lat);
    244237
    245238                                (kplace->geometry  )->AddObject((Object*)kline);
     
    251244                                kplace->visibility=true;
    252245                                sprintf(kplace->styleurl  ,"#RandomLineEmptyPoly");
     246                                int one=1;
    253247
    254248                                kpoint=new KML_Point();
    255249
    256                                 lat=(double *) xmalloc(sizeof(double));
    257                                 lon=(double *) xmalloc(sizeof(double));
     250                                lat=xNew<double>(one);
     251                                lon=xNew<double>(one);
    258252                                Xy2llx(lat,lon,pprofx[i],pprofy[i],1,sgn,cm,sp);
    259253                                kpoint->coords[0]=lon[0];
    260254                                kpoint->coords[1]=lat[0];
    261255                                kpoint->coords[2]=0.;
    262                                 xfree((void**)&lon);
    263                                 xfree((void**)&lat);
     256                                xDelete<double>(lon);
     257                                xDelete<double>(lat);
    264258
    265259                                (kplace->geometry  )->AddObject((Object*)kpoint);
     
    281275/*  write kml file  */
    282276
    283         _printf_(true,"Exp2Kmlx -- Writing kml document to file \"%s\".\n",filkml);
     277        _pprintLine_("Exp2Kmlx -- Writing kml document to file \"" << filkml << "\".");
    284278        fid=fopen(filkml,"w");
    285279        fprintf(fid,"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
     
    289283        delete kfile;
    290284        for (i=nprof-1; i>=0; i--) {
    291                 xfree((void**)&(pprofy[i]));
    292                 xfree((void**)&(pprofx[i]));
    293         }
    294         xfree((void**)&pnvert);
     285                xDelete<double>(pprofy[i]);
     286                xDelete<double>(pprofx[i]);
     287        }
     288        xDelete<int>(pnvert);
    295289
    296290        clock1=clock();
  • issm/trunk/src/c/modules/GetSolutionFromInputsx/GetSolutionFromInputsx.cpp

    r11995 r12706  
    2626        /*Get size of vector: */
    2727        gsize=nodes->NumberOfDofs(configuration_type,GsetEnum);
    28         if (gsize==0) _error_("Allocating a Vec of size 0 as gsize=0 for configuration: %s",EnumToStringx(configuration_type));
     28        if (gsize==0) _error2_("Allocating a Vec of size 0 as gsize=0 for configuration: " << EnumToStringx(configuration_type));
    2929       
    3030        /*Initialize solution: */
  • issm/trunk/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.cpp

    r11995 r12706  
    3232
    3333        /*Assign output pointers:*/
    34         xfree((void**)&control_type);
     34        xDelete<int>(control_type);
    3535        *pvector=vector;
    3636}
  • issm/trunk/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.cpp

    r11995 r12706  
    3232        }
    3333        else{
    34                 _error_("%s%s%s"," vector type: ",EnumToStringx(type)," not supported yet!");
     34                _error2_("vector type: " << EnumToStringx(type) << " not supported yet!");
    3535        }
    3636
     
    4141}
    4242
    43 void GetVectorFromInputsx( double** pvector, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters, int name, int type){
     43void GetVectorFromInputsx( IssmDouble** pvector, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters, int name, int type){
    4444       
    4545        /*output: */
    46         double* vector=NULL;
     46        IssmDouble* vector=NULL;
    4747       
    4848        /*intermediary: */
  • issm/trunk/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.h

    r11995 r12706  
    1010/* local prototypes: */
    1111void    GetVectorFromInputsx( Vector** pvector, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,int name,int type);
    12 void    GetVectorFromInputsx( double** pvector, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,int name,int type);
     12void    GetVectorFromInputsx( IssmDouble** pvector, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,int name,int type);
    1313
    1414#endif  /* _GETVECTORFROMINPUTSXX_H */
  • issm/trunk/src/c/modules/Gradjx/Gradjx.cpp

    r11995 r12706  
    1414        int     i,j,numberofvertices;
    1515        int     num_controls;
    16         double  norm_inf;
    17         double *norm_list       = NULL;
    18         int    *control_type    = NULL;
    19         Vector*     gradient        = NULL;
    20         Vector*    *gradient_list  = NULL;
     16        double   norm_inf;
     17        double  *norm_list     = NULL;
     18        int     *control_type  = NULL;
     19        Vector  *gradient      = NULL;
     20        Vector **gradient_list = NULL;
    2121       
    2222        /*retrieve some parameters: */
     
    2626
    2727        /*Allocate gradient_list */
    28         gradient_list = (Vector**)xmalloc(num_controls*sizeof(Vector*));
    29         norm_list = (double*)xmalloc(num_controls*sizeof(double));
     28        gradient_list = xNew<Vector*>(num_controls);
     29        norm_list = xNew<double>(num_controls);
    3030        for(i=0;i<num_controls;i++){
    3131                gradient_list[i]=new Vector(num_controls*numberofvertices);
     
    5454        /*Check that gradient is clean*/
    5555        norm_inf=gradient->Norm(NORM_INF);
    56         if(norm_inf<=0)    _error_("||∂J/∂α||∞ = 0    gradient norm is zero");
    57         if(isnan(norm_inf))_error_("||∂J/∂α||∞ = NaN  gradient norm is NaN");
     56        if(norm_inf<=0)    _error2_("||∂J/∂α||∞ = 0    gradient norm is zero");
     57        if(xIsNan<IssmDouble>(norm_inf))_error2_("||∂J/∂α||∞ = NaN  gradient norm is NaN");
    5858
    5959        /*Clean-up and assign output pointer*/
     
    6262        }
    6363        else{
    64                 xfree((void**)&norm_list);
     64                xDelete<double>(norm_list);
    6565        }
    6666        if(pgradient)  *pgradient=gradient;
    67         xfree((void**)&gradient_list);
    68         xfree((void**)&control_type);
     67        xDelete<Vector*>(gradient_list);
     68        xDelete<int>(control_type);
    6969}
  • issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp

    r12330 r12706  
    2020        Element* element                          = NULL;
    2121       
    22         _printf_(VerboseModule(),"   Migrating grounding line\n");
     22        if(VerboseModule()) _pprintLine_("   Migrating grounding line");
    2323       
    2424        /*retrieve parameters: */
     
    2727
    2828        if(migration_style==NoneEnum) return;
    29         if(migration_style!=AgressiveMigrationEnum && migration_style!=SoftMigrationEnum) _error_("%s not supported yet!",EnumToStringx(migration_style));
     29        if(migration_style!=AgressiveMigrationEnum && migration_style!=SoftMigrationEnum) _error2_(EnumToStringx(migration_style) << " not supported yet!");
    3030
    3131        if(migration_style==SoftMigrationEnum){
     
    4949        /*free ressouces: */
    5050        xdelete(&vec_old_floatingice);
    51         xfree((void**)&vertices_potentially_ungrounding);
    52         xfree((void**)&vertices_ungrounding);
    53         xfree((void**)&old_floatingice);
     51        xDelete<double>(vertices_potentially_ungrounding);
     52        xDelete<double>(vertices_ungrounding);
     53        xDelete<double>(old_floatingice);
    5454}
    5555
    56 /*FUNCTION CreateNodesOnFloatingIce {{{1*/
     56/*FUNCTION CreateNodesOnFloatingIce {{{*/
    5757Vector* CreateNodesOnFloatingIce(Nodes* nodes,int configuration_type){
    5858
     
    8181}
    8282/*%}}}*/
    83 /*FUNCTION PotentialSheetUngrounding {{{1*/
     83/*FUNCTION PotentialSheetUngrounding {{{*/
    8484double*    PotentialSheetUngrounding(Elements* elements,Vertices* vertices,Parameters* parameters){
    8585
     
    108108}
    109109/*}}}*/
    110 /*FUNCTION PropagateFloatingiceToGroundedNeighbors {{{1*/
     110/*FUNCTION PropagateFloatingiceToGroundedNeighbors {{{*/
    111111double*    PropagateFloatingiceToGroundedNeighbors(Elements* elements,Nodes* nodes,Vertices* vertices,Parameters* parameters,double* vertices_potentially_ungrounding){
    112112
     
    158158                #ifdef _HAVE_MPI_
    159159                MPI_Allreduce(&local_nflipped,&nflipped,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
    160                 _printf_(VerboseConvergence(),"   Additional number of vertices allowed to unground: %i\n",nflipped);
     160                if(VerboseConvergence()) _pprintLine_("   Additional number of vertices allowed to unground: " << nflipped);
    161161                #else
    162162                nflipped=local_nflipped;
     
    164164
    165165                /*Avoid leaks: */
    166                 xfree((void**)&elements_neighboring_floatingce);
    167                 xfree((void**)&nodes_on_floatingice);
     166                xDelete<double>(elements_neighboring_floatingce);
     167                xDelete<double>(nodes_on_floatingice);
    168168
    169169                /*Assemble and serialize:*/
     
    174174        /*Free ressources:*/
    175175        xdelete(&vec_nodes_on_floatingice);
    176         xfree((void**)&elements_neighboring_floatingce);
     176        xDelete<double>(elements_neighboring_floatingce);
    177177
    178178        return nodes_on_floatingice;
  • issm/trunk/src/c/modules/HoleFillerx/HoleFillerx.cpp

    r9313 r12706  
    4343
    4444         /*^^^^^^^^^^^^^  Remove pixels close to the holes ^^^^^^^^^^^^^*/
    45         image2 = (double*) xmalloc( lines*samps*sizeof(double));
     45        image2 = xNew<double>(lines*samps);
    4646        memcpy(image2,image,lines*samps*sizeof(double));
    4747       
     
    6464        }
    6565
    66         image3 = (double*) xmalloc( lines*samps*sizeof(double));
     66        image3 = xNew<double>(lines*samps);
    6767        memcpy(image3,image2,lines*samps*sizeof(double));
    6868
     
    7676                        }
    7777                }
    78                 printf( "\n" );
    79                 printf("Number of zeroes remaining: %10ld",lines*samps-counter);
     78                _printLine_( "" );
     79                _printString_("Number of zeroes remaining: " << lines*samps-counter);
    8080                fflush( stdout );
    8181        #endif
     
    9595                }
    9696                //        n u m b e r   o f   z e r o e s   r e m a i n i n g :   1 2 3 4 5 6 7 8 9 10       
    97                 printf( "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b" );
    98                 printf("Number of zeroes remaining: %10ld",lines*samps-counter);
     97                _printString_( "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b" );
     98                _printString_("Number of zeroes remaining: " << lines*samps-counter);
    9999                fflush( stdout );
    100100        #endif
     
    104104/***************** FIRST RUN *********************/
    105105/*
    106 fprintf ( stdout, "First  Application:  " ); time(&t2); printf( ctime(&t2) );
     106fprintf ( stdout, "First  Application:  " ); time(&t2); _printString_( ctime(&t2) );
    107107*/
    108108        for ( i = 0; i < lines; i++ ){
     
    277277                       
    278278                        #ifdef _DEBUG2_
    279                                 //printf("%g %g %g \n",temp,elev,range);
     279                                //_printLine_(temp << " " << elev << " " << range << " ");
    280280                        #endif
    281281
     
    304304/************************ SMOOTH THE RESULT ***********************/           
    305305               
    306         image4 = (double*) xmalloc( lines*samps*sizeof(double));
     306        image4 = xNew<double>(lines*samps);
    307307        memcpy(image4,image3,lines*samps*sizeof(double));
    308308
     
    348348
    349349        /*Allocate output image: */
    350         imageout=(double*)xmalloc(samps*lines*sizeof(double));
     350        imageout=xNew<double>(samps*lines);
    351351        memcpy(imageout,image3,lines*samps*sizeof(double));
    352352
     
    354354       
    355355        #ifdef _DEBUG2_
    356                 printf( "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b" );
    357                 printf("Number of zeroes remaining:          0\n\n");
     356                _printString_( "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b" );
     357                _printLine_("Number of zeroes remaining:          0\n");
    358358                printf ( "\n");
    359359        #endif
     
    363363        /*Assign output pointers: */
    364364        *pimageout=imageout;
    365 
    366365        return 1;
    367        
    368366}
  • issm/trunk/src/c/modules/InputArtificialNoisex/InputArtificialNoisex.cpp

    r5578 r12706  
    99#include "../../EnumDefinitions/EnumDefinitions.h"
    1010
    11 void InputArtificialNoisex( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,int enum_name,double min,double max){
     11void InputArtificialNoisex( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,int enum_name,IssmDouble min,IssmDouble max){
    1212
    1313        int i;
  • issm/trunk/src/c/modules/InputArtificialNoisex/InputArtificialNoisex.h

    r5578 r12706  
    1010
    1111/* local prototypes: */
    12 void    InputArtificialNoisex( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,int enum_name,double min,double max);
     12void    InputArtificialNoisex( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,int enum_name,IssmDouble min,IssmDouble max);
    1313
    1414#endif  /* _UPDATEINPUTSFROMVECTORXX_H */
  • issm/trunk/src/c/modules/InputConvergencex/InputConvergencex.cpp

    r12330 r12706  
    99#include "../../EnumDefinitions/EnumDefinitions.h"
    1010
    11 bool InputConvergencex(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials* materials,Parameters* parameters,int* enums, int num_enums, int* criterionenums, double* criterionvalues,int num_criterionenums){
     11bool InputConvergencex(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials* materials,Parameters* parameters,int* enums, int num_enums, int* criterionenums, IssmDouble* criterionvalues,int num_criterionenums){
    1212
    1313        /*intermediary:*/
    14         int         i;
    15         bool        converged;
    16         int         num_notconverged=0;
    17         int         total_notconverged;
    18         double     *eps       = NULL;
    19         Element*    element=NULL;
     14        int      i;
     15        bool     converged;
     16        int      num_notconverged   = 0;
     17        int      total_notconverged;
     18        IssmDouble  *eps                = NULL;
     19        Element *element            = NULL;
    2020
    2121        /*allocate dynamic memory: */
    22         eps=(double*)xmalloc(num_criterionenums*sizeof(double));
     22        eps=xNew<IssmDouble>(num_criterionenums);
    2323
    2424        /*Go through elements, and ask them to do the job: */
     
    3434        num_notconverged=total_notconverged;
    3535        #endif
    36         _printf_(VerboseConvergence(),"      #elements above convergence criterion = %i\n",num_notconverged);
     36        if(VerboseConvergence()) _pprintLine_("      #elements above convergence criterion = " << num_notconverged);
    3737
    3838        /*Free ressources:*/
    39         xfree((void**)&eps);
     39        xDelete<IssmDouble>(eps);
    4040
    4141        /*return: */
  • issm/trunk/src/c/modules/InputConvergencex/InputConvergencex.h

    r4778 r12706  
    88
    99/* local prototypes: */
    10 bool InputConvergencex(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials* materials,Parameters* parameters,int* enums, int num_enums, int* criterionenums, double* criterionvalues,int num_criterionenums);
     10bool InputConvergencex(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials* materials,Parameters* parameters,int* enums, int num_enums, int* criterionenums, IssmDouble* criterionvalues,int num_criterionenums);
    1111
    1212#endif  /* _INPUTCONVERGENCEX_H */
  • issm/trunk/src/c/modules/InputScalex/InputScalex.cpp

    r4573 r12706  
    99#include "../../EnumDefinitions/EnumDefinitions.h"
    1010
    11 void InputScalex(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials* materials,Parameters* parameters,int enum_type, double scale_factor){
     11void InputScalex(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials* materials,Parameters* parameters,int enum_type, IssmDouble scale_factor){
    1212
    1313        /*intermediary:*/
  • issm/trunk/src/c/modules/InputScalex/InputScalex.h

    r4236 r12706  
    99
    1010/* local prototypes: */
    11 void InputScalex(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials* materials,Parameters* parameters,int enum_type, double scale_factor);
     11void InputScalex(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials* materials,Parameters* parameters,int enum_type, IssmDouble scale_factor);
    1212
    1313#endif  /* _SCALEINPUTX_H */
  • issm/trunk/src/c/modules/InputToResultx/InputToResultx.cpp

    r11995 r12706  
    1313        /*intermediary:*/
    1414        int      step;
    15         double   time;
     15        IssmDouble   time;
    1616        Element *element = NULL;
    1717
  • issm/trunk/src/c/modules/InputUpdateFromConstantx/InputUpdateFromConstantx.cpp

    r4573 r12706  
    4949        }
    5050}
    51 void InputUpdateFromConstantx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,double constant, int name){
     51void InputUpdateFromConstantx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,IssmDouble constant, int name){
    5252
    5353        int i;
  • issm/trunk/src/c/modules/InputUpdateFromConstantx/InputUpdateFromConstantx.h

    r4236 r12706  
    1212void            InputUpdateFromConstantx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters, bool   constant, int name);
    1313void            InputUpdateFromConstantx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters, int    constant, int name);
    14 void            InputUpdateFromConstantx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters, double constant, int name);
     14void            InputUpdateFromConstantx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters, IssmDouble constant, int name);
    1515
    1616#endif  /* _UPDATEINPUTSFROMCONSTANTXX_H */
  • issm/trunk/src/c/modules/InputUpdateFromDakotax/InputUpdateFromDakotax.cpp

    r10571 r12706  
    2121        double *qmu_part  = NULL;
    2222
    23         double* distributed_values=NULL;
    24         double* parameter=NULL;
    25         char*   descriptor=NULL;
     23        double *distributed_values = NULL;
     24        double *parameter          = NULL;
     25        char   *descriptor         = NULL;
    2626        char    root[50]; //root name of variable, ex: DragCoefficent, RhoIce, etc ...
    2727
     
    4949
    5050
    51                         distributed_values=(double*)xmalloc(npart*sizeof(double));
     51                        distributed_values=xNew<double>(npart);
    5252                        for(j=0;j<npart;j++){
    5353                                distributed_values[j]=variables[i+j];
     
    9191
    9292                        /*Free allocations: */
    93                         xfree((void**)&parameter);
    94                         xfree((void**)&distributed_values);
     93                        xDelete<double>(parameter);
     94                        xDelete<double>(distributed_values);
    9595                }
    9696                else if (strncmp(descriptor,"indexed_",8)==0){
    97                         _error_(" indexed variables not supported yet!");
     97                        _error2_("indexed variables not supported yet!");
    9898                }
    9999                else if (strncmp(descriptor,"nodal_",8)==0){
    100                         _error_(" nodal variables not supported yet!");
     100                        _error2_("nodal variables not supported yet!");
    101101                }
    102102                else{
     
    107107
    108108        /*Free ressources:*/
    109         xfree((void**)&qmu_part);
    110 
     109        xDelete<double>(qmu_part);
    111110}
  • issm/trunk/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.cpp

    r11995 r12706  
    1111void InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,Vector* solution){
    1212
    13         double* serial_solution=NULL;
     13        IssmDouble* serial_solution=NULL;
    1414
    1515        /*Serialize solution, so that elements can index into it on every CPU: */
     
    2020
    2121        /*Free ressources:*/
    22         xfree((void**)&serial_solution);
    23 
     22        xDelete<IssmDouble>(serial_solution);
    2423}
    2524
    2625
    27 void InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,double* solution){
     26void InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,IssmDouble* solution){
    2827
    2928        /*Intermediary*/
     
    3635                element->InputUpdateFromSolution(solution);
    3736        }
    38 
    3937}
  • issm/trunk/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.h

    r11995 r12706  
    1111/* local prototypes: */
    1212void            InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,Vector* solution);
    13 void        InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,double* solution);
     13void        InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,IssmDouble* solution);
    1414
    1515//with timestep
    1616void            InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,Vector* solution,int timestep);
    17 void        InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,double* solution, int timestep);
     17void        InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,IssmDouble* solution, int timestep);
    1818
    1919#endif  /* _UPDATEINPUTSFROMSOLUTIONXX_H */
  • issm/trunk/src/c/modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.cpp

    r11995 r12706  
    1818
    1919        /*Free ressources:*/
    20         xfree((void**)&serial_vector);
     20        xDelete<double>(serial_vector);
    2121}
    2222
  • issm/trunk/src/c/modules/InputUpdateFromVectorx/InputUpdateFromVectorx.cpp

    r11995 r12706  
    1111void InputUpdateFromVectorx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,Vector* vector, int name, int type){
    1212
    13         double* serial_vector=NULL;
     13        IssmDouble* serial_vector=NULL;
    1414
    1515        serial_vector=vector->ToMPISerial();
     
    1818
    1919        /*Free ressources:*/
    20         xfree((void**)&serial_vector);
     20        xDelete<IssmDouble>(serial_vector);
    2121}
    2222
    2323       
    24 void InputUpdateFromVectorx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,double* vector, int name, int type){
     24void InputUpdateFromVectorx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,IssmDouble* vector, int name, int type){
    2525
    2626        int i;
  • issm/trunk/src/c/modules/InputUpdateFromVectorx/InputUpdateFromVectorx.h

    r11995 r12706  
    1111/* local prototypes: */
    1212void    InputUpdateFromVectorx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,Vector* vector, int name,int type);
    13 void    InputUpdateFromVectorx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,double* vector, int name,int type);
     13void    InputUpdateFromVectorx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,IssmDouble* vector, int name,int type);
    1414void    InputUpdateFromVectorx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,int* vector, int name,int type);
    1515void    InputUpdateFromVectorx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,bool* vector, int name,int type);
  • issm/trunk/src/c/modules/InterpFromGridToMeshx/InterpFromGridToMeshx.cpp

    r11995 r12706  
    1313#include "../../shared/shared.h"
    1414#include "../../include/include.h"
     15#include "../../io/io.h"
    1516/*}}}*/
    1617
     
    3637        /*Some checks on arguments: */
    3738        if ((M<2) || (N<2) || (nods<=0)){
    38                 _error_("nothing to be done according to the dimensions of input matrices and vectors.");
     39                _error2_("nothing to be done according to the dimensions of input matrices and vectors.");
    3940        }
    4041        if (x_in[1]-x_in[0]<0){
    41                 _error_("x coordinate vector should be increasing.\n   use Matlab's command x=flipud(x), also flip the data matrix data=fliplr(data)");
     42                _error2_("x coordinate vector should be increasing.\n   use Matlab's command x=flipud(x), also flip the data matrix data=fliplr(data)");
    4243        }
    4344        if (y_in[1]-y_in[0]<0){
    44                 _error_("y coordinate vector should be increasing.\n   use Matlab's command y=flipud(y), also flip the data matrix data=flipud(data)");
     45                _error2_("y coordinate vector should be increasing.\n   use Matlab's command y=flipud(y), also flip the data matrix data=flipud(data)");
    4546        }
    4647
     
    5253
    5354                /*The coordinates given in input describe the contour of each pixel. Take the center of each pixel*/
    54                 x=(double*)xmalloc(N*sizeof(double));
    55                 y=(double*)xmalloc(M*sizeof(double));
     55                x=xNew<double>(N);
     56                y=xNew<double>(M);
    5657                for (i=0;i<N;i++) x[i]=(x_in[i]+x_in[i+1])/2;
    5758                for (i=0;i<M;i++) y[i]=(y_in[i]+y_in[i+1])/2;
     
    6263
    6364                /*The coordinates given in input describe the center each pixel. Keep them*/
    64                 x=(double*)xmalloc(N*sizeof(double));
    65                 y=(double*)xmalloc(M*sizeof(double));
     65                x=xNew<double>(N);
     66                y=xNew<double>(M);
    6667                for (i=0;i<N;i++) x[i]=x_in[i];
    6768                for (i=0;i<M;i++) y[i]=y_in[i];
    6869        }
    6970        else{
    70                 _error_("x and y vectors length should be 1 or 0 more than data number of rows.");
     71                _error2_("x and y vectors length should be 1 or 0 more than data number of rows.");
    7172        }
    7273
     
    8182        gate.data_mesh=data_mesh;
    8283        gate.data=data;
     84        gate.default_value=default_value;
     85        gate.interp=interpenum;
    8386        gate.M=M;
    8487        gate.N=N;
    85         gate.interp=interpenum;
    8688
    8789        /*launch the thread manager with InterpFromGridToMeshxt as a core: */
    8890        LaunchThread(InterpFromGridToMeshxt,(void*)&gate,num);
     91        _printLine_("\r      interpolation progress: "<<fixed<<setw(6)<<setprecision(2)<<100.<<"%");
    8992
    9093        /*Assign output pointers:*/
     
    9295}
    9396/*}}}*/
    94 /*InterpFromGridToMeshxt {{{1*/
     97/*InterpFromGridToMeshxt {{{*/
    9598void* InterpFromGridToMeshxt(void* vpthread_handle){
    9699
     
    124127        double *y             = gate->y;
    125128        int     nods          = gate->nods;
    126         Vector*     data_mesh     = gate->data_mesh;
     129        Vector *data_mesh     = gate->data_mesh;
    127130        double *data          = gate->data;
    128131        double  default_value = gate->default_value;
     
    131134        int     N             = gate->N;
    132135
     136        bool debug = M*N>1? true:false;
     137        debug = true;
     138
    133139        /*partition loop across threads: */
    134140        PartitionRange(&i0,&i1,nods,num_threads,my_thread);
    135141        for (i=i0;i<i1;i++) {
    136142
     143                if(debug && my_thread==0)
     144                 _printString_("\r      interpolation progress: "<<setw(6)<<setprecision(2)<<double(i-i0)/double(i1-i0)*100<<"%");
    137145                x_grid=*(x_mesh+i);
    138146                y_grid=*(y_mesh+i);
     
    170178                                        break;
    171179                                default:
    172                                         printf("Interpolation %s not supported yet\n",EnumToStringx(interpenum));
     180                                        _printLine_("Interpolation " << EnumToStringx(interpenum) << " not supported yet");
    173181                                        return NULL; /*WARNING: no error because it would blow up the multithreading!*/
    174182                        }
    175                         if(isnan(data_value)) data_value=default_value;
     183                        if(xIsNan<IssmDouble>(data_value)) data_value=default_value;
    176184                }
    177185                else{
     
    183191}/*}}}*/
    184192
    185 /*findindices {{{1*/
     193/*findindices {{{*/
    186194bool findindices(int* pn,int* pm,double* x,int x_rows, double* y,int y_rows, double xgrid,double ygrid){
    187195
     
    218226        return (foundx && foundy);
    219227}/*}}}*/
    220 /*triangleinterp{{{1*/
     228/*triangleinterp{{{*/
    221229double triangleinterp(double x1,double x2,double y1,double y2,double Q11,double Q12,double Q21,double Q22,double x,double y){
    222230        /*split the rectangle in 2 triangle and
     
    259267        }
    260268}/*}}}*/
    261 /*bilinearinterp{{{1*/
     269/*bilinearinterp{{{*/
    262270double bilinearinterp(double x1,double x2,double y1,double y2,double Q11,double Q12,double Q21,double Q22,double x,double y){
    263271        /*Bilinear  interpolation: (http://en.wikipedia.org/wiki/Bilinear_interpolation) */
     
    286294}
    287295/*}}}*/
    288 /*nearestinterp{{{1*/
     296/*nearestinterp{{{*/
    289297double nearestinterp(double x1,double x2,double y1,double y2,double Q11,double Q12,double Q21,double Q22,double x,double y){
    290298        /*Nearest neighbor interpolation*/
  • issm/trunk/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dx.cpp

    r11995 r12706  
    4141        /*some checks*/
    4242        if (nels_data<1 || nods_data<3 || nods_prime==0){
    43                 _error_("nothing to be done according to the mesh given in input");
     43                _error2_("nothing to be done according to the mesh given in input");
    4444        }
    4545
     
    5555        }
    5656        else{
    57                 _error_("length of vector data not supported yet. It should be of length (number of nodes) or (number of elements)!");
     57                _error2_("length of vector data not supported yet. It should be of length (number of nodes) or (number of elements)!");
    5858        }
    5959
    6060        if((numcontours) && (interpolation_type==2)){
    61                 _error_(" element interpolation_type with contours not supported yet!");
     61                _error2_("element interpolation_type with contours not supported yet!");
    6262        }
    6363
     
    8484        }
    8585        else{
    86                  incontour=(double*)xmalloc(nods_prime*sizeof(double));
    87                  for (i=0;i<nods_prime;i++) incontour[i]=1;
     86                 incontour=xNew<double>(nods_prime);
     87                 for (i=0;i<nods_prime;i++) incontour[i]=1.0;
    8888        }
    8989
     
    112112
    113113        /*Assign output pointers:*/
    114          xfree((void**)&incontour);
     114         xDelete<double>(incontour);
    115115        *pdata_prime=data_prime;
    116116}
  • issm/trunk/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dxt.cpp

    r11995 r12706  
    1717        bool debug;
    1818        int  nels_data;
    19         double* index_data=NULL;
    20         double* x_data=NULL;
    21         double* y_data=NULL;
    22         double* data=NULL;
    23         double xmin,xmax;
    24         double ymin,ymax;
    25         int    nods_prime;
    26         Vector*    data_prime=NULL;
    27         double* x_prime=NULL;
    28         double* y_prime=NULL;
    29         double* default_values=NULL;
     19        double *index_data         = NULL;
     20        double *x_data             = NULL;
     21        double *y_data             = NULL;
     22        double *data               = NULL;
     23        double  xmin                 ,xmax;
     24        double  ymin                 ,ymax;
     25        int     nods_prime;
     26        Vector *data_prime         = NULL;
     27        double *x_prime            = NULL;
     28        double *y_prime            = NULL;
     29        double *default_values     = NULL;
    3030        int     num_default_values;
    31         double*    incontour=NULL;
     31        double *incontour          = NULL;
    3232
    3333        /*intermediary: */
     
    4646       
    4747        /*recover parameters :*/
    48         interpolation_type=gate->interpolation_type;
    49         debug=gate->debug;
    50         nels_data=gate->nels_data;
    51         index_data=gate->index_data;
    52         x_data=gate->x_data;
    53         y_data=gate->y_data;
    54         data=gate->data;
    55         xmin=gate->xmin;
    56         xmax=gate->xmax;
    57         ymin=gate->ymin;
    58         ymax=gate->ymax;
    59         nods_prime=gate->nods_prime;
    60         data_prime=gate->data_prime;
    61         x_prime=gate->x_prime;
    62         y_prime=gate->y_prime;
    63         default_values=gate->default_values;
    64         num_default_values=gate->num_default_values;
    65         incontour=gate->incontour;
     48        interpolation_type = gate->interpolation_type;
     49        debug              = gate->debug;
     50        nels_data          = gate->nels_data;
     51        index_data         = gate->index_data;
     52        x_data             = gate->x_data;
     53        y_data             = gate->y_data;
     54        data               = gate->data;
     55        xmin               = gate->xmin;
     56        xmax               = gate->xmax;
     57        ymin               = gate->ymin;
     58        ymax               = gate->ymax;
     59        nods_prime         = gate->nods_prime;
     60        data_prime         = gate->data_prime;
     61        x_prime            = gate->x_prime;
     62        y_prime            = gate->y_prime;
     63        default_values     = gate->default_values;
     64        num_default_values = gate->num_default_values;
     65        incontour          = gate->incontour;
    6666
    6767        /*partition loop across threads: */
     
    6969
    7070        /*Loop over the elements*/
    71         if (debug && my_thread==0) printf("      interpolation progress:   %5.2lf %%",0.0);
    72 
    7371        for (i=i0;i<i1;i++){
    7472
    7573                /*display current iteration*/
    76                 if (debug && my_thread==0 && fmod((double)i,(double)100)==0) printf("\b\b\b\b\b\b\b%5.2lf %%",(double)i/nels_data*100*num_threads);
     74                if (debug && my_thread==0 && fmod((double)i,(double)100)==0)
     75                 _printString_("\r      interpolation progress: "<<setw(6)<<setprecision(2)<<double(i-i0)/double(i1-i0)*100<<"%");
    7776
    7877                /*if there is no point inside the domain, go to next iteration*/
     
    114113                                                data_value=data[i];
    115114                                        }
    116                                         if (isnan(data_value)){
     115                                        if (xIsNan<IssmDouble>(data_value)){
    117116                                                if(num_default_values==1) data_value=default_values[0];
    118117                                                else data_value=default_values[j];
     
    125124                }
    126125        }
    127         if (debug && my_thread==0) printf("\b\b\b\b\b\b\b%5.2lf %%\n",100.0);
    128        
     126        if(debug && my_thread==0)
     127         _printLine_("\r      interpolation progress: "<<fixed<<setw(6)<<setprecision(2)<<100.<<"%");
    129128        return NULL;
    130 
    131129}
  • issm/trunk/src/c/modules/InterpFromMeshToGridx/InterpFromMeshToGridx.cpp

    r11995 r12706  
    3030        /*some checks*/
    3131        if (nels<1 || nods<3 || nlines<1 || ncols<1 || xposting==0 || yposting==0){
    32                 _error_("nothing to be done according to the mesh given in input");
     32                _error2_("nothing to be done according to the mesh given in input");
    3333        }
    3434
     
    4141        }
    4242        else{
    43                 _error_("length of vector data not supported yet. It should be of length (number of nodes) or (number of elements)!");
     43                _error2_("length of vector data not supported yet. It should be of length (number of nodes) or (number of elements)!");
    4444        }
    4545
    4646        /*First, allocate pointers: */
    47         griddata=(double*)xcalloc(nlines*ncols,sizeof(double));
    48         x_grid=(double*)xcalloc(ncols,sizeof(double));
    49         y_grid=(double*)xcalloc(nlines,sizeof(double));
     47        griddata=xNewZeroInit<double>(nlines*ncols);
     48        x_grid=xNewZeroInit<double>(ncols);
     49        y_grid=xNewZeroInit<double>(nlines);
    5050
    5151        /*Set debug to 1 if there are lots of elements*/
     
    8585
    8686        /*Loop over the elements*/
    87         if (debug) printf("      interpolation progress:   %5.2lf %%",0.0);
    8887        for (n=0;n<nels;n++){
    8988
    9089                /*display current iteration*/
    91                 if (debug && fmod((double)n,(double)100)==0) printf("\b\b\b\b\b\b\b%5.2lf %%",(double)n/nels*100);
     90                if (debug && fmod((double)n,(double)100)==0)
     91                 _printString_("\r      interpolation progress: "<<setw(6)<<setprecision(2)<<double(n)/double(nels)*100<<"%");
    9292
    9393                /*Get extrema coordinates of current elements*/
     
    160160                                                data_value=data_mesh[n];
    161161                                        }
    162                                         if (isnan(data_value)) data_value=default_value;
     162                                        if (xIsNan<IssmDouble>(data_value)) data_value=default_value;
    163163
    164164                                        /*insert value and go to the next point*/
     
    168168                }
    169169        }
    170         if (debug) printf("\b\b\b\b\b\b\b%5.2lf %%\n",100.0);
     170        if (debug)
     171         _printLine_("\r      interpolation progress: "<<fixed<<setw(6)<<setprecision(2)<<100.<<"%");
    171172
    172173        /*Assign output pointers:*/
  • issm/trunk/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp

    r12330 r12706  
    1313using namespace std;
    1414
    15 int InterpFromMeshToMesh2dx(double** pdata_interp,double* index_data,double* x_data,double* y_data,int nods_data,int nels_data,
    16                         double* data,int data_rows,int data_cols,double* x_interp,double* y_interp,int nods_interp,double* default_values,int num_default_values, DataSet* contours){
     15int InterpFromMeshToMesh2dx(double** pdata_interp,int* index_data,double* x_data,double* y_data,int nods_data,int nels_data,
     16                        double* data,int M_data,int N_data,double* x_interp,double* y_interp,int N_interp,Options* options){
    1717       
    1818        /*Output*/
     
    2020
    2121        /*Intermediary*/
     22        bool   isdefault;
     23        double defaultvalue;
    2224        R2     r;
    2325        I2     I;
     
    2931        double data_value;
    3032        Icoor2 dete[3];
    31         int verbose=0;
    32 
    33         /*default values: */
    34         Vector*    vec_incontour=NULL;
    35         double*    incontour=NULL;
    36         bool   skip_bamg=false;
    3733
    3834        /*Checks*/
    39         if (data_cols<=0){
    40                 _error_("data provided has a negative number of columns");
     35        if (M_data!=nods_data && M_data!=nels_data){
     36                _error2_("data provided should have either " << nods_data << " or " << nels_data << " lines (not " << M_data << ")");
    4137        }
    42         if (data_rows!=nods_data && data_rows!=nels_data){
    43                 _error_("data provided should have either %i or %i lines (not %i)",nods_data,nels_data,data_rows);
     38
     39        /*Get default*/
     40        if(options->GetOption("default")){
     41                isdefault=true;
     42                options->Get(&defaultvalue,"default");
    4443        }
    45         if((num_default_values) && (data_cols>1)){
    46                 _error_("data provided can only have 1 column if a default value is provided");
    47         }
    48        
    49         /*If default values supplied, figure out which nodes are inside the contour, including the border of the contour: */
    50         if(num_default_values){
    51                 ContourToNodesx( &vec_incontour,x_interp,y_interp,nods_interp,contours,1);
    52                 incontour=vec_incontour->ToMPISerial();
     44        else{
     45                isdefault=false;
    5346        }
    5447
    5548        /*Initialize output*/
    56         if (verbose) printf("Initializing output vector\n");
    57         data_interp=(double*)xmalloc(nods_interp*data_cols*sizeof(double));
     49        data_interp=xNew<double>(N_interp*N_data);
    5850
    59         // read background mesh
    60         if (verbose) printf("Reading mesh\n");
     51        /*read background mesh*/
    6152        Mesh Th(index_data,x_data,y_data,nods_data,nels_data);
     53
     54        /*Get reference number (for subdomains)*/
     55        long* reft = xNew<long>(Th.nbt);
     56        Th.TriangleReferenceList(reft);
    6257        Th.CreateSingleVertexToTriangleConnectivity();
    6358
    64         //Loop over output nodes
    65         if (verbose) printf("Loop over the nodes\n");
    66         for(i=0;i<nods_interp;i++){
    67                
    68                 /*reset skip_bamg: */
    69                 skip_bamg=false;
     59        /*Loop over output nodes*/
     60        for(i=0;i<N_interp;i++){
    7061
    71                 /*figure out if we should skip bamg logic: */
    72                 if(num_default_values){
    73                         if(!incontour[i]){
    74                                 /*This node is not inside the contour. Skip Bamg logic and apply default value.: */
    75                                 skip_bamg=true;
     62                /*Get current point coordinates*/
     63                r.x=x_interp[i]; r.y=y_interp[i];
     64                I2 I=Th.R2ToI2(r);
     65
     66                /*Find triangle holding r/I*/
     67                Triangle &tb=*Th.TriangleFindFromCoord(I,dete);
     68
     69                /*point inside convex*/
     70                if (tb.det>0){
     71
     72                        /*Area coordinates*/
     73                        areacoord[0]= (double) dete[0]/tb.det;
     74                        areacoord[1]= (double) dete[1]/tb.det;
     75                        areacoord[2]= (double) dete[2]/tb.det;
     76                        /*3 vertices of the triangle*/
     77                        i0=Th.GetId(tb[0]);
     78                        i1=Th.GetId(tb[1]);
     79                        i2=Th.GetId(tb[2]);
     80                        /*triangle number*/
     81                        it=Th.GetId(tb);
     82
     83                        /*Inside convex but outside mesh*/
     84                        if (reft[it]<0 & isdefault){
     85                                for(j=0;j<N_data;j++) data_interp[i*N_data+j]=defaultvalue;
     86                                continue;
    7687                        }
    7788                }
    78 
    79                 if(skip_bamg==false){
    80 
    81                         //Get current point coordinates
    82                         r.x=x_interp[i]; r.y=y_interp[i];
    83                         I2 I=Th.R2ToI2(r);
    84 
    85                         //Find triangle holding r/I
    86                         Triangle &tb=*Th.TriangleFindFromCoord(I,dete);
    87 
    88                         // internal point
    89                         if (tb.det>0){
    90                                 //Area coordinate
    91                                 areacoord[0]= (double) dete[0]/tb.det;
    92                                 areacoord[1]= (double) dete[1]/tb.det;
    93                                 areacoord[2]= (double) dete[2]/tb.det;
    94                                 //3 vertices of the triangle
    95                                 i0=Th.GetId(tb[0]);
    96                                 i1=Th.GetId(tb[1]);
    97                                 i2=Th.GetId(tb[2]);
    98                                 //triangle number
    99                                 it=Th.GetId(tb);
     89                //external point
     90                else{
     91                        if(isdefault){
     92                                for(j=0;j<N_data;j++) data_interp[i*N_data+j]=defaultvalue;
     93                                continue;
    10094                        }
    101                         //external point
    102                         else {
     95                        else{
    10396                                //Get closest adjacent triangle (inside the mesh)
    10497                                AdjacentTriangle ta=CloseBoundaryEdge(I,&tb,aa,bb).Adj();
     
    116109                                it=Th.GetId(tc);
    117110                        }
    118                        
    119                         if (data_rows==nods_data){
    120                                 for (j=0;j<data_cols;j++){
    121                                         data_interp[i*data_cols+j]=areacoord[0]*data[data_cols*i0+j]+areacoord[1]*data[data_cols*i1+j]+areacoord[2]*data[data_cols*i2+j];
    122                                 }
    123                         }
    124                         else{
    125                                 for (j=0;j<data_cols;j++){
    126                                         if (it<0 || it>=nels_data){
    127                                                 _error_("Triangle number %i not in [0 %i], because not correctly implemented yet... interpolate on grid first",it,nels_data);
    128                                         }
    129                                         data_interp[i*data_cols+j]=data[data_cols*it+j];
    130                                 }
     111                }
     112
     113                if (M_data==nods_data){
     114                        for (j=0;j<N_data;j++){
     115                                data_interp[i*N_data+j]=areacoord[0]*data[N_data*i0+j]+areacoord[1]*data[N_data*i1+j]+areacoord[2]*data[N_data*i2+j];
    131116                        }
    132117                }
    133118                else{
    134                         if(num_default_values==1) data_interp[i]=default_values[0];
    135                         else data_interp[i]=default_values[i];
     119                        for (j=0;j<N_data;j++){
     120                                if (it<0 || it>=nels_data){
     121                                        _error2_("Triangle number " << it << " not in [0 " << nels_data << "], report bug to developers");
     122                                }
     123                                data_interp[i*N_data+j]=data[N_data*it+j];
     124                        }
    136125                }
    137126        }
    138127
    139         /*Assign output pointers:*/
    140         if (verbose) printf("Assigning output\n");
     128        /*clean-up and return*/
     129        xDelete<long>(reft);
    141130        *pdata_interp=data_interp;
    142 
    143         /*No error return*/
    144131        return 1;
    145132}
  • issm/trunk/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.h

    r12330 r12706  
    66#define _INTERPFROMMESHTOMESH2DX_H
    77
    8 #include "../../objects/objects.h"
     8class Options;
    99
    10 /* local prototypes: */
    11 int InterpFromMeshToMesh2dx(double** pdata_interp,double* index_data,double* x_data,double* y_data,int nods_data,int nels_data,
    12                         double* data,int data_rows,int data_cols,double* x_interp,double* y_interp,int nods_interp,double* default_values,int num_default_values,DataSet* contours);
     10int InterpFromMeshToMesh2dx(double** pdata_interp,int* index_data,double* x_data,double* y_data,int nods_data,int nels_data,
     11                        double* data,int M_data,int N_data,double* x_interp,double* y_interp,int N_interp,Options* options);
    1312
    1413#endif
  • issm/trunk/src/c/modules/InterpFromMeshToMesh3dx/InterpFromMeshToMesh3dx.cpp

    r11995 r12706  
    2727        /*some checks*/
    2828        if (nels_data<1 || nods_data<6 || nods_prime==0){
    29                 _error_("nothing to be done according to the mesh given in input");
     29                _error2_("nothing to be done according to the mesh given in input");
    3030        }
    3131
     
    4141        }
    4242        else{
    43                 _error_("length of vector data not supported yet. It should be of length (number of nodes) or (number of elements)!");
     43                _error2_("length of vector data not supported yet. It should be of length (number of nodes) or (number of elements)!");
    4444        }
    4545
     
    5858
    5959        /*Loop over the elements*/
    60         if (debug) printf("      interpolation progress:   %5.2lf %%",0.0);
    6160        for (i=0;i<nels_data;i++){
    6261
    6362                /*display current iteration*/
    64                 if (debug && fmod((double)i,(double)100)==0) printf("\b\b\b\b\b\b\b%5.2lf %%",(double)i/nels_data*100);
     63                if (debug && fmod((double)i,(double)100)==0)
     64                 _printString_("\r      interpolation progress: "<<setw(6)<<setprecision(2)<<double(i)/double(nels_data)*100<<"%");
    6565
    6666                /*Get extrema coordinates of current elements*/
     
    124124                                                data_value=data[i];
    125125                                        }
    126                                         if (isnan(data_value)) data_value=default_value;
     126                                        if (xIsNan<IssmDouble>(data_value)) data_value=default_value;
    127127
    128128                                        /*insert value and go to the next point*/
     
    132132                }
    133133        }
    134         if (debug) printf("\b\b\b\b\b\b\b%5.2lf %%\n",100.0);
     134        if (debug)
     135         _printLine_("\r      interpolation progress: "<<fixed<<setw(6)<<setprecision(2)<<100.<<"%");
    135136
    136137        /*Assign output pointers:*/
  • issm/trunk/src/c/modules/IoModelToConstraintsx/IoModelToConstraintsx.cpp

    r9725 r12706  
    2222        int     counter;
    2323        int     nods;
    24         double* times=NULL;
    25         double* values=NULL;
     24        IssmDouble* times=NULL;
     25        IssmDouble* values=NULL;
    2626        bool    spcpresent=false;
    2727        int     count=0;
     
    2929
    3030        /*variables being fetched: */
    31         double *doublevector  = NULL;
     31        IssmDouble *IssmDoublevector  = NULL;
    3232        int     M,N;
    3333
     
    3838        fid=iomodel->SetFilePointerToData(&code, &vector_layout,vector_enum);
    3939
    40         if(code!=7)_error_("%s%s"," expecting a double vector for constraints with enum ",EnumToStringx(vector_enum));
    41         if(vector_layout!=1)_error_("%s%s"," expecting a nodal vector for constraints with enum ",EnumToStringx(vector_enum));
     40        if(code!=7)_error2_("expecting a IssmDouble vector for constraints with enum " << EnumToStringx(vector_enum));
     41        if(vector_layout!=1)_error2_("expecting a nodal vector for constraints with enum " << EnumToStringx(vector_enum));
    4242
    4343        /*Fetch vector:*/
    44         iomodel->FetchData(&doublevector,&M,&N,vector_enum);
     44        iomodel->FetchData(&IssmDoublevector,&M,&N,vector_enum);
    4545
    4646        /*Transient or static?:*/
     
    5555                        if((iomodel->my_vertices[i])){
    5656
    57                                 if (!isnan(doublevector[i])){
     57                                if (!xIsNan<IssmDouble>(IssmDoublevector[i])){
    5858
    59                                         constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,doublevector[i],analysis_type));
     59                                        constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,IssmDoublevector[i],analysis_type));
    6060                                        count++;
    6161                                }
     
    6969
    7070                /*figure out times: */
    71                 times=(double*)xmalloc(N*sizeof(double));
     71                times=xNew<IssmDouble>(N);
    7272                for(j=0;j<N;j++){
    73                         times[j]=doublevector[(M-1)*N+j];
     73                        times[j]=IssmDoublevector[(M-1)*N+j];
    7474                }
    7575                /*unit conversion: */
     
    8383
    8484                                /*figure out times and values: */
    85                                 values=(double*)xmalloc(N*sizeof(double));
     85                                values=xNew<IssmDouble>(N);
    8686                                spcpresent=false;
    8787                                for(j=0;j<N;j++){
    88                                         values[j]=doublevector[i*N+j];
    89                                         if(!isnan(values[j]))spcpresent=true; //NaN means no spc by default
     88                                        values[j]=IssmDoublevector[i*N+j];
     89                                        if(!xIsNan<IssmDouble>(values[j]))spcpresent=true; //NaN means no spc by default
    9090                                }
    9191
     
    9494                                        count++;
    9595                                }
    96                                 xfree((void**)&values);
     96                                xDelete<IssmDouble>(values);
    9797                        }
    9898                }
    9999        }
    100100        else{
    101                 _error_("Size of field %s not supported",EnumToStringx(vector_enum));
     101                _error2_("Size of field " << EnumToStringx(vector_enum) << " not supported");
    102102        }
    103103
    104104        /*Free ressources:*/
    105         xfree((void**)&doublevector);
    106         xfree((void**)&times);
    107         xfree((void**)&values);
     105        xDelete<IssmDouble>(IssmDoublevector);
     106        xDelete<IssmDouble>(times);
     107        xDelete<IssmDouble>(values);
    108108}
  • issm/trunk/src/c/modules/KMLFileReadx/KMLFileReadx.cpp

    r11527 r12706  
    2121        clock0=clock();
    2222        time0 =time(NULL);
    23         _printf_(true,"\nKMLFileReadx Module -- %s",ctime(&time0));
     23        _pprintString_("\nKMLFileReadx Module -- " << ctime(&time0));
    2424
    2525/*  read kml file  */
     
    4343                }
    4444
    45 //              _printf_(true,"%s\n",kstr);
    46                 xfree((void**)&kstr);
     45//              _pprintLine_(kstr);
     46                xDelete<char>(kstr);
    4747        }
    4848
    4949        if (kxml) {
    50                 _printf_(true,"XML declaration:\n");
     50                _pprintLine_("XML declaration:");
    5151                kxml->DeepEcho("  ");
    5252                delete kxml;
    5353        }
    5454        if (kdtd) {
    55                 _printf_(true,"DTD declaration (not yet implemented):\n");
     55                _pprintLine_("DTD declaration (not yet implemented):");
    5656                kdtd->DeepEcho("  ");
    5757                delete kdtd;
  • issm/trunk/src/c/modules/KMLMeshWritex/KMLMeshWritex.cpp

    r9761 r12706  
    99#include "../../EnumDefinitions/EnumDefinitions.h"
    1010
    11 void KMLMeshWritex(int* ierror,
    12                                    char* name,
    13                                    char* notes,
    14                                    int* elem,int melem,int nelem,
    15                                    int* nodecon,int mncon,int nncon,
    16                                    double* lat, double* lng,
    17                                    int* part,
    18                                    double* data, int mdata, int ndata,
    19                                    double* cmap, int mcmap, int ncmap,
    20                                    FILE* fid){
    21 
    22         int     i,j,k,ipt=0,jpt=0,nnodes;
    23         int     mxepg=25;
    24         int     lwidth=1;
    25         double  popac=0.50;
    26         char    indent[81]="  ";
    27         char    cstr[81];
    28         double* edata=NULL;
    29         bool    ncfree=false,
    30                         edfree=false;
    31         KML_Document*  kdoc=NULL;
    32         KML_Style*     kstyle;
    33         KML_LineStyle* klsty;
    34         KML_PolyStyle* kpsty;
     11void KMLMeshWritex(int* ierror,char* name,char* notes,int* elem,int melem,int nelem,int* nodecon,int mncon,int nncon,double* lat, double* lng,int* part,double* data, int mdata, int ndata,double* cmap, int mcmap, int ncmap,FILE* fid){
     12
     13        int                 i,j,k,ipt=0,jpt=0,nnodes;
     14        int                 mxepg      = 25;
     15        int                 lwidth     = 1;
     16        double              popac      = 0.50;
     17        char                indent[81] = " ";
     18        char                cstr[81];
     19        double             *edata = NULL;
     20        bool ncfree=false, edfree=false;
     21        KML_Document       *kdoc = NULL;
     22        KML_Style          *kstyle;
     23        KML_LineStyle      *klsty;
     24        KML_PolyStyle      *kpsty;
    3525
    3626        clock_t clock0,clock1,clock0a,clock0b,clock0c;
     
    3929        clock0=clock();
    4030        time0 =time(NULL);
    41         _printf_(true,"\nKMLMeshWritex Module -- %s",ctime(&time0));
     31        _pprintString_("\nKMLMeshWritex Module -- " << ctime(&time0));
    4232
    4333/*  construct kml document  */
     
    9383
    9484        if (cmap) {
    95                 _printf_(true,"Writing %d Matlab colors as KML style templates.\n",mcmap);
     85                _pprintLine_("Writing " << mcmap << " Matlab colors as KML style templates.");
    9686                ipt=0;
    9787                for (i=0; i<mcmap; i++) {
     
    128118
    129119        if (!nodecon) {
    130                 _printf_(true,"Creating the node connectivity table.\n");
     120                _pprintLine_("Creating the node connectivity table.");
    131121                nncon=mxepg+1;
    132                 nodecon=(int *) xcalloc(mncon*nncon,sizeof(int));
     122                nodecon=xNewZeroInit<int>(mncon*nncon);
    133123                ncfree=true;
    134124
     
    143133                                        }
    144134                                        else
    145                                                 _error_("Nodal connectivity table needs more than specified %d columns.\n",mxepg);
     135                                                _error2_("Nodal connectivity table needs more than specified " << mxepg << " columns.\n");
    146136                                }
    147137                                jpt++;
     
    159149
    160150                else if (mdata == mncon) {
    161                         _printf_(true,"Averaging nodal data to element data.\n");
    162                         edata=(double *) xcalloc(melem*ndata,sizeof(double));
     151                        _pprintLine_("Averaging nodal data to element data.");
     152                        edata=xNewZeroInit<double>(melem*ndata);
    163153                        edfree=true;
    164154
     
    183173
    184174                else
    185                         _error_("Data matrix has incorrect number of %d rows.\n",mdata);
     175                        _error2_("Data matrix has incorrect number of " << mdata << " rows.\n");
    186176        }
    187177
     
    194184                                                                                                                cmap,mcmap,ncmap));
    195185
    196         if (edfree) xfree((void**)&edata);
    197         if (ncfree) xfree((void**)&nodecon);
     186        if(edfree) xDelete<double>(edata);
     187        if(ncfree) xDelete<int>(nodecon);
    198188        clock0a=clock();
    199189        time0a =time(NULL);
     
    203193/*  write kml file  */
    204194
    205         _printf_(true,"Writing kml document to file.\n");
     195        _pprintLine_("Writing kml document to file.");
    206196        fprintf(fid,"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
    207197        fprintf(fid,"<kml xmlns=\"http://www.opengis.net/kml/2.2\">\n");
     
    213203                         ((double)(clock0b-clock0a))/CLOCKS_PER_SEC,difftime(time0b,time0a));
    214204
    215         _printf_(true,"Deleting kml document.\n");
     205        _pprintLine_("Deleting kml document.");
    216206        delete kdoc;
    217207        clock0c=clock();
     
    314304/*  write each element as a polygon placemark  */
    315305
    316         _printf_(true,"Writing %d tria elements as KML polygons.\n",melem);
     306        _pprintLine_("Writing " << melem << " tria elements as KML polygons.");
    317307
    318308        for (i=0; i<melem; i++) {
     
    344334                kring=new KML_LinearRing();
    345335                kring->ncoord    =nelem+1;
    346                 kring->coords    =(double (*)[3]) xmalloc((nelem+1)*3*sizeof(double));
     336                kring->coords =xNew<double>((nelem+1)*3);
    347337
    348338/*  write the nodal coordinates as a linear ring  */
    349339
    350340                for (j=0; j<nelem; j++) {
    351                         kring->coords[j][0]=lng[elem[ipt]-1];
    352                         kring->coords[j][1]=lat[elem[ipt]-1];
    353                         kring->coords[j][2]=alt;
     341                        kring->coords[3*j+0]=lng[elem[ipt]-1];
     342                        kring->coords[3*j+1]=lat[elem[ipt]-1];
     343                        kring->coords[3*j+2]=alt;
    354344                        ipt++;
    355345                }
    356                 kring->coords[nelem][0]=kring->coords[0][0];
    357                 kring->coords[nelem][1]=kring->coords[0][1];
    358                 kring->coords[nelem][2]=kring->coords[0][2];
     346                kring->coords[3*nelem+0]=kring->coords[3*0+0];
     347                kring->coords[3*nelem+1]=kring->coords[3*0+1];
     348                kring->coords[3*nelem+2]=kring->coords[3*0+2];
    359349//              kring->DeepEcho();
    360350
    361351/*  assemble the linear ring into polygon into placemark into folder  */
    362352
    363                 (kpoly ->outer     )->AddObject((Object*)kring);
    364                 (kplace->geometry  )->AddObject((Object*)kpoly);
    365                 (kfold ->feature   )->AddObject((Object*)kplace);
     353                (kpoly ->outer   )->AddObject((Object*)kring);
     354                (kplace->geometry)->AddObject((Object*)kpoly);
     355                (kfold ->feature )->AddObject((Object*)kplace);
    366356
    367357//              if (!(int)fmod((double)(i+1),1000))
    368 //                      _printf_(true,"  %d tria elements written.\n",(i+1));
     358//                      _pprintLine_("  " << (i+1) << " tria elements written.");
    369359        }
    370         _printf_(true,"  %d tria elements written.\n",melem);
     360        _pprintLine_("  " << melem << " tria elements written.");
    371361
    372362        return(kfold);
  • issm/trunk/src/c/modules/KMLOverlayx/KMLOverlayx.cpp

    r9761 r12706  
    2828        clock0=clock();
    2929        time0 =time(NULL);
    30         _printf_(true,"\nKMLOverlayx Module -- %s",ctime(&time0));
     30        _pprintString_("\nKMLOverlayx Module -- " << ctime(&time0));
    3131
    3232/*  construct kml file  */
     
    8282/*  write kml file  */
    8383
    84         _printf_(true,"Writing kml document to file.\n");
     84        _pprintLine_("Writing kml document to file.");
    8585        fprintf(fid,"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
    8686        kfile->Write(fid,indent);
  • issm/trunk/src/c/modules/Kml2Expx/Kml2Expx.cpp

    r9761 r12706  
    3838        clock0=clock();
    3939        time0 =time(NULL);
    40         _printf_(true,"\nKml2Expx Module -- %s",ctime(&time0));
     40        _pprintString_("\nKml2Expx Module -- " << ctime(&time0));
    4141
    4242/*  read kml file  */
     
    4444        fidi=fopen(filkml,"r");
    4545        if (!(kobj=KMLFileReadx(fidi)))
    46                 _error_("Error reading kml file.");
     46                _error2_("Error reading kml file.");
    4747        fclose(fidi);
    4848
    4949/*  open exp file  */
    5050
    51         _printf_(true,"Writing exp profiles to file.\n");
     51        _pprintLine_("Writing exp profiles to file.");
    5252        fido=fopen(filexp,"w");
    5353
  • issm/trunk/src/c/modules/Krigingx/Krigingx.cpp

    r12330 r12706  
    1010#include "../../Container/Observations.h"
    1111#include "../modules.h"
    12 
    1312#ifdef _HAVE_GSL_
    1413#include <gsl/gsl_linalg.h>
    1514#endif
    16 
    17 #include "../../objects/Kriging/GaussianVariogram.h"
    1815/*FUNCTION Krigingx{{{*/
    1916int Krigingx(double** ppredictions,double **perror,double* obs_x, double* obs_y, double* obs_list, int obs_length,double* x_interp,double* y_interp,int n_interp,Options* options){
     
    4744
    4845        /*Allocate output*/
    49         predictions =(double*)xcalloc(n_interp,sizeof(double));
    50         error       =(double*)xcalloc(n_interp,sizeof(double));
     46        predictions =xNewZeroInit<double>(n_interp);
     47        error       =xNewZeroInit<double>(n_interp);
    5148
    5249        /*Get output*/
     
    5956                observations->Variomap(predictions,x_interp,n_interp);
    6057        }
    61         else if(strcmp(output,"prediction")==0){
    62 
     58        else if(strcmp(output,"delaunay")==0){
     59                int nobs,nel;
     60                double *x     = NULL;
     61                double *y     = NULL;
     62                double *data  = NULL;
     63                int    *index = NULL;
     64
     65                observations->ObservationList(&x,&y,&data,&nobs);
     66
     67                _printLine_("Generation Delaunay Triangulation");
     68                BamgTriangulatex(&index,&nel,x,y,nobs);
     69
     70                _printLine_("Interpolating");
     71                xDelete<double>(predictions);
     72                InterpFromMeshToMesh2dx(&predictions,index,x,y,nobs,nel,data,nobs,1,x_interp,y_interp,n_interp,options);
     73                xDelete<double>(x);
     74                xDelete<double>(y);
     75                xDelete<double>(data);
     76                xDelete<int>(index);
     77        }
     78        else if(strcmp(output,"nearestneighbor")==0){
    6379                /*initialize thread parameters: */
    6480                gate.n_interp     = n_interp;
     
    7288                gate.predictions  = predictions;
    7389                gate.error        = error;
    74                 gate.percent      = (double*)xcalloc(num,sizeof(double));
     90                gate.percent      = xNewZeroInit<double>(num);
     91
     92                /*launch the thread manager with Krigingxt as a core: */
     93                LaunchThread(NearestNeighbort,(void*)&gate,num);
     94                _printLine_("\r      interpolation progress: "<<fixed<<setw(6)<<setprecision(2)<<100.<<"%");
     95                xDelete<double>(gate.percent);
     96        }
     97        else if(strcmp(output,"idw")==0){ //Inverse distance weighting
     98                /*initialize thread parameters: */
     99                gate.n_interp     = n_interp;
     100                gate.x_interp     = x_interp;
     101                gate.y_interp     = y_interp;
     102                gate.radius       = radius;
     103                gate.mindata      = mindata;
     104                gate.maxdata      = maxdata;
     105                gate.variogram    = variogram;
     106                gate.observations = observations;
     107                gate.predictions  = predictions;
     108                gate.error        = error;
     109                gate.percent      = xNewZeroInit<double>(num);
     110
     111                /*launch the thread manager with Krigingxt as a core: */
     112                LaunchThread(idwt,(void*)&gate,num);
     113                _printLine_("\r      interpolation progress: "<<fixed<<setw(6)<<setprecision(2)<<100.<<"%");
     114                xDelete<double>(gate.percent);
     115        }
     116        else if(strcmp(output,"prediction")==0){
     117
     118                /*initialize thread parameters: */
     119                gate.n_interp     = n_interp;
     120                gate.x_interp     = x_interp;
     121                gate.y_interp     = y_interp;
     122                gate.radius       = radius;
     123                gate.mindata      = mindata;
     124                gate.maxdata      = maxdata;
     125                gate.variogram    = variogram;
     126                gate.observations = observations;
     127                gate.predictions  = predictions;
     128                gate.error        = error;
     129                gate.percent      = xNewZeroInit<double>(num);
    75130
    76131                /*launch the thread manager with Krigingxt as a core: */
    77132                LaunchThread(Krigingxt,(void*)&gate,num);
    78                 printf("\r      interpolation progress:  100.00%%\n");
    79                 xfree((void**)&gate.percent);
     133                _printLine_("\r      interpolation progress: "<<fixed<<setw(6)<<setprecision(2)<<100.<<"%");
     134                xDelete<double>(gate.percent);
    80135        }
    81136        else{
    82                 _error_("output '%s' not supported yet",output);
     137                _error2_("output '" << output << "' not supported yet");
    83138        }
    84139
     
    86141        delete variogram;
    87142        delete observations;
    88         xfree((void**)&output);
     143        xDelete<char>(output);
    89144        *ppredictions = predictions;
    90145        *perror       = error;
     
    121176
    122177        /*Intermediaries*/
    123         int           i,j,n_obs;
    124         double        numerator,denominator,ratio,localpercent;
    125         double       *x            = NULL;
    126         double       *y            = NULL;
    127         double       *obs          = NULL;
    128         double       *Gamma        = NULL;
    129         double       *GinvG0       = NULL;
    130         double       *Ginv1        = NULL;
    131         double       *GinvZ        = NULL;
    132         double       *gamma0       = NULL;
    133         double       *ones         = NULL;
     178        double        localpercent;
     179
     180        /*partition loop across threads: */
     181        PartitionRange(&i0,&i1,n_interp,num_threads,my_thread);
     182        for(int idx=i0;idx<i1;idx++){
     183
     184                /*Print info*/
     185                percent[my_thread]=double(idx-i0)/double(i1-i0)*100.;
     186                localpercent=percent[0];
     187                for(int i=1;i<num_threads;i++) localpercent=min(localpercent,percent[i]);
     188                if(my_thread==0) _printString_("\r      interpolation progress: "<<setw(6)<<setprecision(2)<<localpercent<<"%");
     189
     190                /*Kriging interpolation*/
     191                observations->InterpolationKriging(&predictions[idx],&error[idx],x_interp[idx],y_interp[idx],radius,mindata,maxdata,variogram);
     192        }
     193
     194        return NULL;
     195}/*}}}*/
     196/*FUNCTION NearestNeighbort{{{*/
     197void* NearestNeighbort(void* vpthread_handle){
     198
     199        /*gate variables :*/
     200        KrigingxThreadStruct *gate        = NULL;
     201        pthread_handle       *handle      = NULL;
     202        int my_thread;
     203        int num_threads;
     204        int i0,i1;
     205
     206        /*recover handle and gate: */
     207        handle      = (pthread_handle*)vpthread_handle;
     208        gate        = (KrigingxThreadStruct*)handle->gate;
     209        my_thread   = handle->id;
     210        num_threads = handle->num;
     211
     212        /*recover parameters :*/
     213        int           n_interp     = gate->n_interp;
     214        double       *x_interp     = gate->x_interp;
     215        double       *y_interp     = gate->y_interp;
     216        double        radius       = gate->radius;
     217        int           mindata      = gate->mindata;
     218        int           maxdata      = gate->maxdata;
     219        Variogram    *variogram    = gate->variogram;
     220        Observations *observations = gate->observations;
     221        double       *predictions  = gate->predictions;
     222        double       *error        = gate->error;
     223        double       *percent      = gate->percent;
     224
     225        /*Intermediaries*/
     226        int           i;
     227        double        localpercent;
    134228
    135229        /*partition loop across threads: */
     
    141235                localpercent=percent[0];
    142236                for(i=1;i<num_threads;i++) localpercent=min(localpercent,percent[i]);
    143                 printf("\r      interpolation progress: %5.2lf%%",localpercent);
    144 
    145                 /*Get list of observations for current point*/
    146                 observations->ObservationList(&x,&y,&obs,&n_obs,x_interp[idx],y_interp[idx],radius,maxdata);
    147                 if(n_obs<mindata){
    148                         predictions[idx] = -999.0;
    149                         error[idx]       = -999.0;
    150                         continue;
    151                 }
    152 
    153                 /*Allocate intermediary matrix and vectors*/
    154 
    155                 Gamma  = (double*)xmalloc(n_obs*n_obs*sizeof(double));
    156                 gamma0 = (double*)xmalloc(n_obs*sizeof(double));
    157                 ones   = (double*)xmalloc(n_obs*sizeof(double));
    158 
    159                 /*First: Create semivariogram matrix for observations*/
    160                 for(i=0;i<n_obs;i++){
    161                         for(j=0;j<=i;j++){
    162                                 //Gamma[i*n_obs+j] = variogram->SemiVariogram(x[i]-x[j],y[i]-y[j]);
    163                                 Gamma[i*n_obs+j] = variogram->Covariance(x[i]-x[j],y[i]-y[j]);
    164                                 Gamma[j*n_obs+i] = Gamma[i*n_obs+j];
    165                         }
    166                 }
    167                 for(i=0;i<n_obs;i++) ones[i]=1;
    168 
    169                 /*Get semivariogram vector associated to this location*/
    170                 //for(i=0;i<n_obs;i++) gamma0[i] = variogram->SemiVariogram(x[i]-x_interp[idx],y[i]-y_interp[idx]);
    171                 for(i=0;i<n_obs;i++) gamma0[i] = variogram->Covariance(x[i]-x_interp[idx],y[i]-y_interp[idx]);
    172 
    173                 /*Solve the three linear systems*/
    174                 GslSolve(&GinvG0,Gamma,gamma0,n_obs); // Gamma^-1 gamma0
    175                 GslSolve(&Ginv1, Gamma,ones,n_obs);   // Gamma^-1 ones
    176                 GslSolve(&GinvZ, Gamma,obs,n_obs);    // Gamma^-1 Z
    177 
    178                 /*Prepare predictor*/
    179                 numerator=-1.; denominator=0.;
    180                 for(i=0;i<n_obs;i++) numerator  +=GinvG0[i];
    181                 for(i=0;i<n_obs;i++) denominator+=Ginv1[i];
    182                 ratio=numerator/denominator;
    183 
    184                 predictions[idx] = 0.;
    185                 error[idx]       = - numerator*numerator/denominator;
    186                 for(i=0;i<n_obs;i++) predictions[idx] += (gamma0[i]-ratio)*GinvZ[i];
    187                 for(i=0;i<n_obs;i++) error[idx] += gamma0[i]*GinvG0[i];
    188 
    189                 /*clean-up*/
    190                 xfree((void**)&x);
    191                 xfree((void**)&y);
    192                 xfree((void**)&obs);
    193                 xfree((void**)&Gamma);
    194                 xfree((void**)&gamma0);
    195                 xfree((void**)&ones);
    196                 xfree((void**)&GinvG0);
    197                 xfree((void**)&Ginv1);
    198                 xfree((void**)&GinvZ);
    199         }
    200 
     237                if(my_thread==0) _printString_("\r      interpolation progress: "<<setw(6)<<setprecision(2)<<localpercent<<"%");
     238
     239                observations->InterpolationNearestNeighbor(&predictions[idx],x_interp[idx],y_interp[idx],radius);
     240        }
     241
     242        return NULL;
     243}/*}}}*/
     244/*FUNCTION idwt{{{*/
     245void* idwt(void* vpthread_handle){
     246
     247        /*gate variables :*/
     248        KrigingxThreadStruct *gate        = NULL;
     249        pthread_handle       *handle      = NULL;
     250        int my_thread;
     251        int num_threads;
     252        int i0,i1;
     253
     254        /*recover handle and gate: */
     255        handle      = (pthread_handle*)vpthread_handle;
     256        gate        = (KrigingxThreadStruct*)handle->gate;
     257        my_thread   = handle->id;
     258        num_threads = handle->num;
     259
     260        /*recover parameters :*/
     261        int           n_interp     = gate->n_interp;
     262        double       *x_interp     = gate->x_interp;
     263        double       *y_interp     = gate->y_interp;
     264        double        radius       = gate->radius;
     265        int           mindata      = gate->mindata;
     266        int           maxdata      = gate->maxdata;
     267        Variogram    *variogram    = gate->variogram;
     268        Observations *observations = gate->observations;
     269        double       *predictions  = gate->predictions;
     270        double       *error        = gate->error;
     271        double       *percent      = gate->percent;
     272
     273        /*Intermediaries*/
     274        double localpercent;
     275        double  power = 2.;
     276
     277        /*partition loop across threads: */
     278        PartitionRange(&i0,&i1,n_interp,num_threads,my_thread);
     279        for(int idx=i0;idx<i1;idx++){
     280
     281                /*Print info*/
     282                percent[my_thread]=double(idx-i0)/double(i1-i0)*100.;
     283                localpercent=percent[0];
     284                for(int i=1;i<num_threads;i++) localpercent=min(localpercent,percent[i]);
     285                if(my_thread==0) _printString_("\r      interpolation progress: "<<setw(6)<<setprecision(2)<<localpercent<<"%");
     286
     287                observations->InterpolationIDW(&predictions[idx],x_interp[idx],y_interp[idx],radius,mindata,maxdata,power);
     288        }
    201289        return NULL;
    202290}/*}}}*/
     
    214302                else if(strcmp(model,"spherical")==0)   variogram = new SphericalVariogram(options);
    215303                else if(strcmp(model,"power")==0)       variogram = new PowerVariogram(options);
    216                 else _error_("variogram %s not supported yet (list of supported variogram: gaussian, exponential, spherical and power)",model);
     304                else _error2_("variogram " << model << " not supported yet (list of supported variogram: gaussian, exponential, spherical and power)");
    217305        }
    218306        else variogram = new GaussianVariogram(options);
    219307
    220308        /*Assign output pointer*/
    221         xfree((void**)&model);
     309        xDelete<char>(model);
    222310        *pvariogram = variogram;
    223311}/*}}}*/
    224 void GslSolve(double** pX,double* A,double* B,int n){/*{{{*/
    225 #ifdef _HAVE_GSL_
    226 
    227                 /*GSL Matrices and vectors: */
    228                 int              s;
    229                 gsl_matrix_view  a;
    230                 gsl_vector_view  b;
    231                 gsl_vector      *x = NULL;
    232                 gsl_permutation *p = NULL;
    233 
    234                 /*A will be modified by LU decomposition. Use copy*/
    235                 double* Acopy = (double*)xmalloc(n*n*sizeof(double));
    236                 memcpy(Acopy,A,n*n*sizeof(double));
    237 
    238                 /*Initialize gsl matrices and vectors: */
    239                 a = gsl_matrix_view_array (Acopy,n,n);
    240                 b = gsl_vector_view_array (B,n);
    241                 x = gsl_vector_alloc (n);
    242 
    243                 /*Run LU and solve: */
    244                 p = gsl_permutation_alloc (n);
    245                 gsl_linalg_LU_decomp (&a.matrix, p, &s);
    246                 gsl_linalg_LU_solve (&a.matrix, p, &b.vector, x);
    247 
    248                 //printf ("x = \n");
    249                 //gsl_vector_fprintf (stdout, x, "%g");
    250 
    251                 /*Copy result*/
    252                 double* X = (double*)xmalloc(n*sizeof(double));
    253                 memcpy(X,gsl_vector_ptr(x,0),n*sizeof(double));
    254 
    255                 /*Clean up and assign output pointer*/
    256                 xfree((void**)&Acopy);
    257                 gsl_permutation_free(p);
    258                 gsl_vector_free(x);
    259                 *pX=X;
    260 #else
    261                 _error_("GSL support required");
    262 #endif
    263         }/*}}}*/
  • issm/trunk/src/c/modules/Krigingx/Krigingx.h

    r12330 r12706  
    1313
    1414int  Krigingx(double** ppredictions,double **perror,double* x, double* y, double* observations, int n_obs,double* x_interp,double* y_interp,int n_interp,Options* options);
     15int  pKrigingx(double** ppredictions,double **perror,double* x, double* y, double* observations, int n_obs,double* x_interp,double* y_interp,int n_interp,Options* options);
    1516void ProcessVariogram(Variogram **pvariogram,Options* options);
    16 void GslSolve(double** pX,double* A,double* B,int n);
    1717
    1818/*threading: */
     
    3232
    3333void* Krigingxt(void*);
     34void* NearestNeighbort(void*);
     35void* idwt(void*);
    3436#endif /* _KRIGINGX_H */
  • issm/trunk/src/c/modules/Ll2xyx/Ll2xyx.cpp

    r9761 r12706  
    5252        double  T,rho,sl,tc,mc;
    5353
    54         if((sgn!=1) && (sgn!=-1)) _error_("Sign should be either +1 or -1.\n");
     54        if((sgn!=1) && (sgn!=-1)) _error2_("Sign should be either +1 or -1.\n");
    5555
    5656        delta = central_meridian;
     
    116116                *pdelta= 45;
    117117                *pslat = 70;
    118                 _printf_(flag,"Info: creating coordinates in polar stereographic (Std Latitude: 70N Meridian: 45).\n");
     118                if(flag) _pprintLine_("Info: creating coordinates in polar stereographic (Std Latitude: 70N Meridian: 45).");
    119119        }
    120120        else if (sgn == -1) {
    121121                *pdelta= 0;
    122122                *pslat = 71;
    123                 _printf_(flag,"Info: creating coordinates in polar stereographic (Std Latitude: 71S Meridian: 0).\n");
     123                if(flag) _pprintLine_("Info: creating coordinates in polar stereographic (Std Latitude: 71S Meridian: 0).");
    124124        }
    125         else _error_("Sign should be either +1 or -1.\n");
     125        else _error2_("Sign should be either +1 or -1.\n");
    126126
    127127        return;
  • issm/trunk/src/c/modules/MassFluxx/MassFluxx.cpp

    r12330 r12706  
    6767        for(j=0;j<M;j++){
    6868                double* matrix=array[j];
    69                 xfree((void**)&matrix);
     69                xDelete<double>(matrix);
    7070        }
    71         xfree((void**)&mdims_array);
    72         xfree((void**)&ndims_array);
    73         xfree((void**)&array);
     71        xDelete<int>(mdims_array);
     72        xDelete<int>(ndims_array);
     73        xDelete<double*>(array);
    7474       
    7575        /*Assign output pointers: */
  • issm/trunk/src/c/modules/Mergesolutionfromftogx/Mergesolutionfromftogx.cpp

    r11995 r12706  
    1717
    1818        /*Display message*/
    19         _printf_(VerboseModule(),"   Merging solution vector from fset to gset\n");
     19        if(VerboseModule()) _pprintLine_("   Merging solution vector from fset to gset");
    2020
    2121        /*first, get gsize, fsize and ssize: */
  • issm/trunk/src/c/modules/MeshPartitionx/MeshPartitionx.cpp

    r12330 r12706  
    99#include "../../EnumDefinitions/EnumDefinitions.h"
    1010
    11 int MeshPartitionx(int** pepart, int** pnpart, int numberofelements,int numberofnodes,double* elements,
    12                 int numberofelements2d,int numberofnodes2d,double* elements2d,int numlayers,int elements_width, int dim,int num_procs){
     11int MeshPartitionx(int** pepart, int** pnpart, int numberofelements,int numberofnodes,IssmDouble* elements,
     12                int numberofelements2d,int numberofnodes2d,IssmDouble* elements2d,int numlayers,int elements_width, int dim,int num_procs){
    1313
    1414        int noerr=1;
     
    3131
    3232        if(dim==2){
    33                 epart=(int*)xmalloc(numberofelements*sizeof(int));
    34                 npart=(int*)xmalloc(numberofnodes*sizeof(int));
    35                 index=(int*)xmalloc(elements_width*numberofelements*sizeof(int));
     33                epart=xNew<int>(numberofelements);
     34                npart=xNew<int>(numberofnodes);
     35                index=xNew<int>(elements_width*numberofelements);
    3636                for (i=0;i<numberofelements;i++){
    3737                        for (j=0;j<elements_width;j++){
    38                                 *(index+elements_width*i+j)=(int)*(elements+elements_width*i+j)-1; //-1 for C indexing in Metis
     38                                *(index+elements_width*i+j)=reCast<int>(*(elements+elements_width*i+j))-1; //-1 for C indexing in Metis
    3939                        }
    4040                }
     
    5151                        for (i=0;i<numberofnodes;i++)    npart[i]=0;
    5252                }
    53                 else _error_("At least one processor is required");
     53                else _error2_("At least one processor is required");
    5454        }
    5555        else{
     
    5757
    5858                /*First build concatenated 2d mesh  from 2d_coll and 2d_noncoll: */
    59                 epart2d=(int*)xmalloc(numberofelements2d*sizeof(int));
    60                 npart2d=(int*)xmalloc(numberofnodes2d*sizeof(int));
    61                 index2d=(int*)xmalloc(3*numberofelements2d*sizeof(int));
     59                epart2d=xNew<int>(numberofelements2d);
     60                npart2d=xNew<int>(numberofnodes2d);
     61                index2d=xNew<int>(3*numberofelements2d);
    6262
    6363                for (i=0;i<numberofelements2d;i++){
    6464                        for (j=0;j<3;j++){
    65                                 *(index2d+3*i+j)=(int)*(elements2d+3*i+j)-1; //-1 for C indexing in Metis
     65                                *(index2d+3*i+j)=reCast<int>(*(elements2d+3*i+j))-1; //-1 for C indexing in Metis
    6666                        }
    6767                }
     
    7878                        for (i=0;i<numberofnodes2d;i++)    npart2d[i]=0;
    7979                }
    80                 else _error_("At least one processor is required");
     80                else _error2_("At least one processor is required");
    8181
    8282                /*Extrude epart2d to epart, using numlayers: */
    83                 epart=(int*)xmalloc(numberofelements*sizeof(int));
     83                epart=xNew<int>(numberofelements);
    8484               
    8585                count=0;
     
    9292
    9393                /*Extrude npart2d to npart, using numlayers: */
    94                 npart=(int*)xmalloc(numberofnodes*sizeof(int));
     94                npart=xNew<int>(numberofnodes);
    9595               
    9696                count=0;
     
    108108
    109109        /*Free ressources: */
    110         xfree((void**)&index);
    111         xfree((void**)&epart2d);
    112         xfree((void**)&npart2d);
    113         xfree((void**)&index2d);
    114 
     110        xDelete<int>(index);
     111        xDelete<int>(epart2d);
     112        xDelete<int>(npart2d);
     113        xDelete<int>(index2d);
    115114        return noerr;
    116 
    117115}
  • issm/trunk/src/c/modules/MeshPartitionx/MeshPartitionx.h

    r8303 r12706  
    66#define _MESHPARTITIONX_H
    77
     8#include "../../include/include.h"
     9
    810/* local prototypes: */
    9 int MeshPartitionx(int** pepart, int** pnpart, int numberofelements,int numberofnodes,double* elements,
    10                 int numberofelements2d,int numberofnodes2d,double* elements2d,int numlayers,int elements_width, int dim,int numareas);
     11int MeshPartitionx(int** pepart, int** pnpart, int numberofelements,int numberofnodes,IssmDouble* elements,
     12                int numberofelements2d,int numberofnodes2d,IssmDouble* elements2d,int numlayers,int elements_width, int dim,int numareas);
    1113       
    1214#endif /* _MESHPARTITIONX_H */
  • issm/trunk/src/c/modules/MeshProfileIntersectionx/ElementSegment.cpp

    r8303 r12706  
    3838        if(    (edge1==IntersectEnum) && (edge2==IntersectEnum) && (edge3==IntersectEnum)   ){
    3939                /*This case is impossible: */
    40                 _error_(" error: a line cannot go through 3 different vertices!");
     40                _error2_("error: a line cannot go through 3 different vertices!");
    4141        }
    4242        else if(    ((edge1==IntersectEnum) && (edge2==IntersectEnum)) || ((edge2==IntersectEnum) && (edge3==IntersectEnum)) || ((edge3==IntersectEnum) && (edge1==IntersectEnum))   ){
  • issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshProfileIntersectionx.cpp

    r8303 r12706  
    55
    66void MeshProfileIntersectionx( double** psegments, int* pnumsegs, int* index, double* x, double* y, int nel, int nods,  Contour** contours,int numcontours){
    7 
    87
    98        int i,j,k;
     
    2827
    2928        /*Allocate: */
    30         allsegments=(double**)xmalloc(numcontours*sizeof(double*));
    31         allnumsegs=(int*)xmalloc(numcontours*sizeof(int));
     29        allsegments=xNew<double*>(numcontours);
     30        allnumsegs=xNew<int>(numcontours);
    3231
    3332        /*Loop through all contours: */
     
    5352
    5453        /*Out of all segments, create one common array of segments: */
    55         segments=(double*)xmalloc(5*numsegs*sizeof(double));
     54        segments=xNew<double>(5*numsegs);
    5655        count=0;
    5756        for(i=0;i<numcontours;i++){
  • issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshSegmentsIntersection.cpp

    r8303 r12706  
    3232        /*Using the segments_dataset dataset, create segments: */
    3333        numsegs=segments_dataset->Size();
    34         segments=(double*)xmalloc(5*numsegs*sizeof(double));
     34        segments=xNew<double>(5*numsegs);
    3535        for(i=0;i<numsegs;i++){
    3636                Segment* segment=(Segment*)segments_dataset->GetObjectByOffset(i);
  • issm/trunk/src/c/modules/ModelProcessorx/Balancethickness/CreateNodesBalancethickness.cpp

    r10522 r12706  
    4646
    4747        /*Check in 3d*/
    48         if(stabilization==3 && dim==3) _error_("DG 3d not implemented yet");
     48        if(stabilization==3 && dim==3) _error2_("DG 3d not implemented yet");
    4949
    5050        /*First fetch data: */
  • issm/trunk/src/c/modules/ModelProcessorx/Control/CreateParametersControl.cpp

    r11527 r12706  
    6363                parameters->AddObject(new DoubleVecParam(InversionMaxiterPerStepEnum,maxiter,nsteps));
    6464
    65                 xfree((void**)&control_type);
    66                 xfree((void**)&cm_responses);
    67                 xfree((void**)&cm_jump);
    68                 xfree((void**)&optscal);
    69                 xfree((void**)&maxiter);
     65                xDelete<int>(control_type);
     66                xDelete<double>(cm_responses);
     67                xDelete<double>(cm_jump);
     68                xDelete<double>(optscal);
     69                xDelete<double>(maxiter);
    7070        }
    7171
  • issm/trunk/src/c/modules/ModelProcessorx/Control/UpdateElementsAndMaterialsControl.cpp

    r10981 r12706  
    4848                        case FrictionCoefficientEnum: iomodel->FetchData(1,FrictionCoefficientEnum); break;
    4949                        case MaterialsRheologyBbarEnum:    iomodel->FetchData(1,MaterialsRheologyBEnum); break;
    50                         default: _error_("Control %s not implemented yet",EnumToStringx((int)iomodel->Data(InversionControlParametersEnum)[i]));
     50                        default: _error2_("Control " << EnumToStringx((int)iomodel->Data(InversionControlParametersEnum)[i]) << " not implemented yet");
    5151                }
    5252        }
  • issm/trunk/src/c/modules/ModelProcessorx/CreateDataSets.cpp

    r9775 r12706  
    124124
    125125                default:
    126                         _error_("%s%s%s"," analysis_type: ",EnumToStringx(analysis_type)," not supported yet!");
     126                        _error2_("analysis_type: " << EnumToStringx(analysis_type) << " not supported yet!");
    127127        }
    128128
  • issm/trunk/src/c/modules/ModelProcessorx/CreateNumberNodeToElementConnectivity.cpp

    r11027 r12706  
    2323        int    numberofelements;
    2424        int    numberofvertices;
    25         double* elements=NULL;
     25        IssmDouble* elements=NULL;
    2626
    2727        /*output*/
     
    4343
    4444        /*Allocate ouput*/
    45         connectivity=(int*)xcalloc(numberofvertices,sizeof(int));
     45        connectivity=xNewZeroInit<int>(numberofvertices);
    4646
    4747        /*Get element width (3 or 6)*/
     
    5656        for (i=0;i<numberofelements;i++){
    5757                for (j=0;j<elementswidth;j++){
    58                         vertexid=(int)elements[elementswidth*i+j];
     58                        vertexid=reCast<int>(elements[elementswidth*i+j]);
    5959                        _assert_(vertexid>0 && vertexid-1<numberofvertices);
    6060                        connectivity[vertexid-1]+=1;
  • issm/trunk/src/c/modules/ModelProcessorx/CreateParameters.cpp

    r12293 r12706  
    2424        int         numoutputs;
    2525        Parameters *parameters       = NULL;
    26         double     *requestedoutputs = NULL;
     26        IssmDouble     *requestedoutputs = NULL;
    2727       
    2828        if(*pparameters)return; //do not create parameters twice!
     
    5757        parameters->AddObject(iomodel->CopyConstantObject(ThermalPenaltyFactorEnum));
    5858        parameters->AddObject(iomodel->CopyConstantObject(SettingsLowmemEnum));
    59         parameters->AddObject(iomodel->CopyConstantObject(DebugPetscProfilingEnum));
     59        parameters->AddObject(iomodel->CopyConstantObject(DebugProfilingEnum));
    6060        parameters->AddObject(iomodel->CopyConstantObject(MeshAverageVertexConnectivityEnum));
    6161        parameters->AddObject(iomodel->CopyConstantObject(ConstantsReferencetemperatureEnum));
     
    9090        parameters->AddObject(iomodel->CopyConstantObject(InversionTaoEnum));
    9191        parameters->AddObject(iomodel->CopyConstantObject(SurfaceforcingsIspddEnum));
     92        parameters->AddObject(iomodel->CopyConstantObject(SurfaceforcingsIssmbgradientsEnum));
    9293
    9394        /*some parameters that did not come with the iomodel: */
     
    105106        parameters->AddObject(new IntParam(DiagnosticNumRequestedOutputsEnum,numoutputs));
    106107        if(numoutputs)parameters->AddObject(new IntVecParam(DiagnosticRequestedOutputsEnum,requestedoutputs,numoutputs));
    107         xfree((void**)&requestedoutputs);
     108        xDelete<IssmDouble>(requestedoutputs);
    108109        iomodel->FetchData(&requestedoutputs,&numoutputs,NULL,TransientRequestedOutputsEnum);
    109110        parameters->AddObject(new IntParam(TransientNumRequestedOutputsEnum,numoutputs));
    110111        if(numoutputs)parameters->AddObject(new IntVecParam(TransientRequestedOutputsEnum,requestedoutputs,numoutputs));
    111         xfree((void**)&requestedoutputs);
     112        xDelete<IssmDouble>(requestedoutputs);
    112113        iomodel->FetchData(&requestedoutputs,&numoutputs,NULL,SteadystateRequestedOutputsEnum);
    113114        parameters->AddObject(new IntParam(SteadystateNumRequestedOutputsEnum,numoutputs));
    114115        if(numoutputs)parameters->AddObject(new IntVecParam(SteadystateRequestedOutputsEnum,requestedoutputs,numoutputs));
    115         xfree((void**)&requestedoutputs);
     116        xDelete<IssmDouble>(requestedoutputs);
    116117       
    117118        /*Before returning, create parameters in case we are running Qmu or control types runs: */
  • issm/trunk/src/c/modules/ModelProcessorx/CreateSingleNodeToElementConnectivity.cpp

    r9733 r12706  
    2323        int    numberofelements;
    2424        int    numberofvertices;
    25         double* elements=NULL;
     25        IssmDouble* elements=NULL;
    2626
    2727        /*output*/
     
    4444
    4545        /*Allocate ouput*/
    46         connectivity=(int*)xcalloc(numberofvertices,sizeof(int));
     46        connectivity=xNewZeroInit<int>(numberofvertices);
    4747
    4848        /*Get element width (3 or 6)*/
     
    5959                if(iomodel->my_elements[i]){
    6060                        for (j=0;j<elementswidth;j++){
    61                                 vertexid=(int)elements[elementswidth*i+j];
     61                                vertexid=reCast<int>(elements[elementswidth*i+j]);
    6262                                _assert_(vertexid>0 && vertexid-1<numberofvertices);
    6363                                connectivity[vertexid-1]=i+1;
  • issm/trunk/src/c/modules/ModelProcessorx/Dakota/CreateParametersDakota.cpp

    r10660 r12706  
    1515void CreateParametersDakota(Parameters** pparameters,IoModel* iomodel,int solution_type,int analysis_type){
    1616
    17         /*variable declarations: {{{1*/
     17        /*variable declarations: {{{*/
    1818        int i,j,k;
    1919       
     
    7373                iomodel->Constant(&numberofvertices,MeshNumberofverticesEnum);
    7474
    75                 /*name of qmu input, error and output files:{{{1*/
    76                 qmuinname=(char*)xmalloc((strlen(name)+strlen(".qmu.in")+1)*sizeof(char));
     75                /*name of qmu input, error and output files:{{{*/
     76                qmuinname=xNew<char>((strlen(name)+strlen(".qmu.in")+1));
    7777                sprintf(qmuinname,"%s%s",name,".qmu.in");
    7878                parameters->AddObject(new   StringParam(QmuInNameEnum,qmuinname));
    7979
    80                 qmuoutname=(char*)xmalloc((strlen(name)+strlen(".qmu.out")+1)*sizeof(char));
     80                qmuoutname=xNew<char>((strlen(name)+strlen(".qmu.out")+1));
    8181                sprintf(qmuoutname,"%s%s",name,".qmu.out");
    8282                parameters->AddObject(new   StringParam(QmuOutNameEnum,qmuoutname));
    8383
    84                 qmuerrname=(char*)xmalloc((strlen(name)+strlen(".qmu.err")+1)*sizeof(char));
     84                qmuerrname=xNew<char>((strlen(name)+strlen(".qmu.err")+1));
    8585                sprintf(qmuerrname,"%s%s",name,".qmu.err");
    8686                parameters->AddObject(new   StringParam(QmuErrNameEnum,qmuerrname));
    8787                /*}}}*/
    88                 /*Fetch variable descriptors: {{{1*/
     88                /*Fetch variable descriptors: {{{*/
    8989                iomodel->FetchData(&variabledescriptors,&numvariabledescriptors,QmuVariabledescriptorsEnum);
    9090
     
    9393
    9494                /*}}}*/
    95                 /*Fetch response descriptors: {{{1*/
     95                /*Fetch response descriptors: {{{*/
    9696                iomodel->FetchData(&responsedescriptors,&numresponsedescriptors,QmuResponsedescriptorsEnum);
    9797
     
    100100                parameters->AddObject(new    IntParam(QmuNumberofresponsesEnum,numberofresponses));
    101101                /*}}}*/
    102                 /*Deal with partitioning: {{{1*/
     102                /*Deal with partitioning: {{{*/
    103103                /*partition vertices in iomodel->qmu_npart parts, unless a partition is already present: */
    104104               
     
    111111                        ElementsAndVerticesPartitioning(&iomodel->my_elements,&iomodel->my_vertices,iomodel);
    112112
    113                         dpart=(double*)xmalloc(numberofvertices*sizeof(double));
     113                        dpart=xNew<double>(numberofvertices);
    114114                        for(i=0;i<numberofvertices;i++)dpart[i]=iomodel->my_vertices[i];
    115115                }
    116116                parameters->AddObject(new DoubleVecParam(QmuPartitionEnum,dpart,numberofvertices));
    117117                /*}}}*/
    118                 /*Deal with data needed because of qmu variables: {{{1*/
     118                /*Deal with data needed because of qmu variables: {{{*/
    119119               
    120120                for(i=0;i<numvariabledescriptors;i++){
     
    136136                               
    137137                                /*Free ressources:*/
    138                                 xfree((void**)&dakota_parameter);
    139                         }
    140                 }
    141                 /*}}}*/
    142                 /*Deal with data needed to compute qmu responses: {{{1*/
     138                                xDelete<double>(dakota_parameter);
     139                        }
     140                }
     141                /*}}}*/
     142                /*Deal with data needed to compute qmu responses: {{{*/
    143143                for(i=0;i<numresponsedescriptors;i++){
    144144                       
     
    153153                        /*Fetch the mass flux segments necessary to compute the mass fluxes.  Build a DoubleMatArrayParam object out of them: */
    154154                        iomodel->FetchData(&array,&mdims_array,&ndims_array,&qmu_mass_flux_num_profiles,QmuMassFluxSegmentsEnum);
    155                         if(qmu_mass_flux_num_profiles==0)_error_(" qmu_mass_flux_num_profiles is 0, when MassFlux computations were requested!");
     155                        if(qmu_mass_flux_num_profiles==0)_error2_("qmu_mass_flux_num_profiles is 0, when MassFlux computations were requested!");
    156156
    157157                        /*Go through segments, and extract those that belong to this cpu: */
     
    166166                                }
    167167                                if(m){
    168                                         matrix=(double*)xcalloc(5*m,sizeof(double));
     168                                        matrix=xNewZeroInit<double>(5*m);
    169169                                        count=0;
    170170                                        for(j=0;j<temp_m;j++){
     
    185185
    186186                                /*Free temporary matrix: */
    187                                 xfree((void**)&temp_matrix);
     187                                xDelete<double>(temp_matrix);
    188188                        }
    189189
     
    194194                        for(i=0;i<qmu_mass_flux_num_profiles;i++){
    195195                                double* matrix=array[i];
    196                                 xfree((void**)&matrix);
    197                         }
    198                         xfree((void**)&mdims_array);
    199                         xfree((void**)&ndims_array);
    200                         xfree((void**)&array);
    201                 }
    202                 /*}}}*/
    203                 /*Free data: {{{1*/
     196                                xDelete<double>(matrix);
     197                        }
     198                        xDelete<int>(mdims_array);
     199                        xDelete<int>(ndims_array);
     200                        xDelete<double*>(array);
     201                }
     202                /*}}}*/
     203                /*Free data: {{{*/
    204204                for(i=0;i<numresponsedescriptors;i++){
    205205                        descriptor=responsedescriptors[i];
    206                         xfree((void**)&descriptor);
    207                 }
    208                 xfree((void**)&responsedescriptors);
     206                        xDelete<char>(descriptor);
     207                }
     208                xDelete<char*>(responsedescriptors);
    209209
    210210                for(i=0;i<numvariabledescriptors;i++){
    211211                        descriptor=variabledescriptors[i];
    212                         xfree((void**)&descriptor);
    213                 }
    214                 xfree((void**)&variabledescriptors);
    215                 xfree((void**)&part);
    216                 xfree((void**)&dpart);
    217                 xfree((void**)&qmuinname);
    218                 xfree((void**)&qmuerrname);
    219                 xfree((void**)&qmuoutname);
     212                        xDelete<char>(descriptor);
     213                }
     214                xDelete<char*>(variabledescriptors);
     215                xDelete<int>(part);
     216                xDelete<double>(dpart);
     217                xDelete<char>(qmuinname);
     218                xDelete<char>(qmuerrname);
     219                xDelete<char>(qmuoutname);
    220220                /*}}}*/
    221221        } //if(dakota_analysis)
    222222
    223223        /*Free data*/
    224         xfree((void**)&name);
     224        xDelete<char>(name);
    225225
    226226        /*Assign output pointer: */
  • issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateConstraintsDiagnosticHoriz.cpp

    r10544 r12706  
    8787
    8888        /*figure out times: */
    89         timesx=(double*)xmalloc(Nx*sizeof(double));
     89        timesx=xNew<double>(Nx);
    9090        for(j=0;j<Nx;j++){
    9191                timesx[j]=spcvx[(Mx-1)*Nx+j];
     
    9494        UnitConversion(timesx,Nx,ExtToIuEnum,TimeEnum);
    9595        /*figure out times: */
    96         timesy=(double*)xmalloc(Ny*sizeof(double));
     96        timesy=xNew<double>(Ny);
    9797        for(j=0;j<Ny;j++){
    9898                timesy[j]=spcvy[(My-1)*Ny+j];
     
    101101        UnitConversion(timesy,Ny,ExtToIuEnum,TimeEnum);
    102102        /*figure out times: */
    103         timesz=(double*)xmalloc(Nz*sizeof(double));
     103        timesz=xNew<double>(Nz);
    104104        for(j=0;j<Nz;j++){
    105105                timesz[j]=spcvz[(Mz-1)*Nz+j];
     
    107107        /*unit conversion: */
    108108        UnitConversion(timesz,Nz,ExtToIuEnum,TimeEnum);
    109 
    110109
    111110        /*Create spcs from x,y,z, as well as the spc values on those spcs: */
     
    121120                                                constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,0,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
    122121                                                count++;
    123                                                 if (!isnan(spcvx[i])){
     122                                                if (!xIsNan<IssmDouble>(spcvx[i])){
    124123                                                        constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,3,spcvx[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
    125124                                                        count++;
    126125                                                }
    127                                                 if (!isnan(spcvy[i])){
     126                                                if (!xIsNan<IssmDouble>(spcvy[i])){
    128127                                                        constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,4,spcvy[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
    129128                                                        count++;
     
    136135                                                constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,4,0,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
    137136                                                count++;
    138                                                 if (!isnan(spcvx[i])){
     137                                                if (!xIsNan<IssmDouble>(spcvx[i])){
    139138                                                        constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,spcvx[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
    140139                                                        count++;
    141140                                                }
    142                                                 if (!isnan(spcvy[i])){
     141                                                if (!xIsNan<IssmDouble>(spcvy[i])){
    143142                                                        constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,spcvy[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
    144143                                                        count++;
     
    146145
    147146                                        }
    148                                         else _error_("if vertices_type is MacAyealPattyn, you shoud have nodeonpattyn or nodeonmacayeal");
     147                                        else _error2_("if vertices_type is MacAyealPattyn, you shoud have nodeonpattyn or nodeonmacayeal");
    149148                        }
    150149                        /*Also add spcs of coupling: zero at the border pattyn/stokes for the appropriate dofs*/
     
    158157                                                constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,5,0,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
    159158                                                count++;
    160                                                 if (!isnan(spcvx[i])){
     159                                                if (!xIsNan<IssmDouble>(spcvx[i])){
    161160                                                        constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,spcvx[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
    162161                                                        count++;
    163162                                                }
    164                                                 if (!isnan(spcvy[i])){
     163                                                if (!xIsNan<IssmDouble>(spcvy[i])){
    165164                                                        constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,spcvy[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
    166165                                                        count++;
     
    173172                                                constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,0,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
    174173                                                count++;
    175                                                 if (!isnan(spcvx[i])){
     174                                                if (!xIsNan<IssmDouble>(spcvx[i])){
    176175                                                        constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,3,spcvx[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
    177176                                                        count++;
    178177                                                }
    179                                                 if (!isnan(spcvy[i])){
     178                                                if (!xIsNan<IssmDouble>(spcvy[i])){
    180179                                                        constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,4,spcvy[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
    181180                                                        count++;
    182181                                                }
    183                                                 if (!isnan(spcvz[i])){
     182                                                if (!xIsNan<IssmDouble>(spcvz[i])){
    184183                                                        constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,5,spcvz[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
    185184                                                        count++;
    186185                                                }
    187186                                        }
    188                                         else _error_("if vertices_type is PattynStokes, you shoud have nodeonpattyn or nodeonstokes");
     187                                        else _error2_("if vertices_type is PattynStokes, you shoud have nodeonpattyn or nodeonstokes");
    189188                        }
    190189                        /*Also add spcs of coupling: zero at the border pattyn/stokes for the appropriate dofs*/
     
    198197                                                constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,5,0,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
    199198                                                count++;
    200                                                 if (!isnan(spcvx[i])){
     199                                                if (!xIsNan<IssmDouble>(spcvx[i])){
    201200                                                        constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,spcvx[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
    202201                                                        count++;
    203202                                                }
    204                                                 if (!isnan(spcvy[i])){
     203                                                if (!xIsNan<IssmDouble>(spcvy[i])){
    205204                                                        constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,spcvy[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
    206205                                                        count++;
     
    213212                                                constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,0,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
    214213                                                count++;
    215                                                 if (!isnan(spcvx[i])){
     214                                                if (!xIsNan<IssmDouble>(spcvx[i])){
    216215                                                        constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,3,spcvx[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
    217216                                                        count++;
    218217                                                }
    219                                                 if (!isnan(spcvy[i])){
     218                                                if (!xIsNan<IssmDouble>(spcvy[i])){
    220219                                                        constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,4,spcvy[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
    221220                                                        count++;
    222221                                                }
    223                                                 if (!isnan(spcvz[i])){
     222                                                if (!xIsNan<IssmDouble>(spcvz[i])){
    224223                                                        constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,5,spcvz[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
    225224                                                        count++;
    226225                                                }
    227226                                        }
    228                                         else _error_("if vertices_type is MacAyealStokes, you shoud have nodeonmacayeal or nodeonstokes");
     227                                        else _error2_("if vertices_type is MacAyealStokes, you shoud have nodeonmacayeal or nodeonstokes");
    229228                        }
    230229                        /*Now add the regular spcs*/
    231230                        else{
    232                                 if (Mx==numberofvertices && !isnan(spcvx[i])){
     231                                if (Mx==numberofvertices && !xIsNan<IssmDouble>(spcvx[i])){
    233232                                        constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,spcvx[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
    234233                                        count++;
     
    236235                                else if (Mx==numberofvertices+1) {
    237236                                        /*figure out times and values: */
    238                                         values=(double*)xmalloc(Nx*sizeof(double));
     237                                        values=xNew<double>(Nx);
    239238                                        spcpresent=false;
    240239                                        for(j=0;j<Nx;j++){
    241240                                                values[j]=spcvx[i*Nx+j]/yts;
    242                                                 if(!isnan(values[j]))spcpresent=true; //NaN means no spc by default
     241                                                if(!xIsNan<IssmDouble>(values[j]))spcpresent=true; //NaN means no spc by default
    243242                                        }
    244243
     
    247246                                                count++;
    248247                                        }
    249                                         xfree((void**)&values);
     248                                        xDelete<double>(values);
    250249                                }
    251250                                else if (vertices_type[i]==HutterApproximationEnum){
     
    254253                                }
    255254
    256                                 if (My==numberofvertices && !isnan(spcvy[i])){
     255                                if (My==numberofvertices && !xIsNan<IssmDouble>(spcvy[i])){
    257256                                        constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,spcvy[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vy.
    258257                                        count++;
     
    260259                                else if (My==numberofvertices+1){
    261260                                        /*figure out times and values: */
    262                                         values=(double*)xmalloc(Ny*sizeof(double));
     261                                        values=xNew<double>(Ny);
    263262                                        spcpresent=false;
    264263                                        for(j=0;j<Ny;j++){
    265264                                                values[j]=spcvy[i*Ny+j]/yts;
    266                                                 if(!isnan(values[j]))spcpresent=true; //NaN means no spc by default
     265                                                if(!xIsNan<IssmDouble>(values[j]))spcpresent=true; //NaN means no spc by default
    267266                                        }
    268267                                        if(spcpresent){
     
    270269                                                count++;
    271270                                        }
    272                                         xfree((void**)&values);
     271                                        xDelete<double>(values);
    273272                                }
    274273                                else if (vertices_type[i]==HutterApproximationEnum){
     
    278277
    279278                                if ((int)vertices_type[i]==StokesApproximationEnum ||  ((int)vertices_type[i]==NoneApproximationEnum)){
    280                                         if (Mz==numberofvertices && !isnan(spcvz[i])){
     279                                        if (Mz==numberofvertices && !xIsNan<IssmDouble>(spcvz[i])){
    281280                                                constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,3,spcvz[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 2 to vy
    282281                                                count++;
     
    284283                                        else if (Mz==numberofvertices+1){
    285284                                                /*figure out times and values: */
    286                                                 values=(double*)xmalloc(Nz*sizeof(double));
     285                                                values=xNew<double>(Nz);
    287286                                                spcpresent=false;
    288287                                                for(j=0;j<Nz;j++){
    289288                                                        values[j]=spcvz[i*Nz+j]/yts;
    290                                                         if(!isnan(values[j]))spcpresent=true; //NaN means no spc by default
     289                                                        if(!xIsNan<IssmDouble>(values[j]))spcpresent=true; //NaN means no spc by default
    291290                                                }
    292291                                                if(spcpresent){
     
    294293                                                        count++;
    295294                                                }
    296                                                 xfree((void**)&values);
     295                                                xDelete<double>(values);
    297296                                        }
    298297
     
    319318                                                count++;
    320319                                                break;
    321                                         default: _error_("Vertex approximation %s not supported",EnumToStringx((int)vertices_type[i]));
     320                                        default: _error2_("Vertex approximation " << EnumToStringx((int)vertices_type[i]) << " not supported");
    322321                                }
    323322                        }
     
    326325         
    327326        /*Free data: */
    328         xfree((void**)&spcvx);
    329         xfree((void**)&spcvy);
    330         xfree((void**)&spcvz);
    331         xfree((void**)&nodeonmacayeal);
    332         xfree((void**)&nodeonpattyn);
    333         xfree((void**)&nodeonstokes);
    334         xfree((void**)&nodeonicesheet);
    335         xfree((void**)&nodeonbed);
    336         xfree((void**)&vertices_type);
    337         xfree((void**)&surface);
    338         xfree((void**)&z);
     327        xDelete<double>(spcvx);
     328        xDelete<double>(spcvy);
     329        xDelete<double>(spcvz);
     330        xDelete<double>(nodeonmacayeal);
     331        xDelete<double>(nodeonpattyn);
     332        xDelete<double>(nodeonstokes);
     333        xDelete<double>(nodeonicesheet);
     334        xDelete<double>(nodeonbed);
     335        xDelete<double>(vertices_type);
     336        xDelete<double>(surface);
     337        xDelete<double>(z);
    339338
    340339        /*Free resources:*/
    341         xfree((void**)&timesx);
    342         xfree((void**)&timesy);
    343         xfree((void**)&timesz);
    344         xfree((void**)&values);
     340        xDelete<double>(timesx);
     341        xDelete<double>(timesy);
     342        xDelete<double>(timesz);
     343        xDelete<double>(values);
    345344
    346345        /*Assign output pointer: */
  • issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateLoadsDiagnosticHoriz.cpp

    r10522 r12706  
    120120        /*Free data: */
    121121        iomodel->DeleteData(3,DiagnosticIcefrontEnum,ThicknessEnum,BedEnum);
    122         xfree((void**)&elements_type);
    123         xfree((void**)&pressureload);
     122        xDelete<double>(elements_type);
     123        xDelete<double>(pressureload);
    124124
    125125        /*Create Penpair for penalties: */
     
    144144
    145145        /*free ressources: */
    146         xfree((void**)&penalties);
     146        xDelete<double>(penalties);
    147147
    148148        /*Create Riffront loads for rifts: */
     
    157157                }
    158158                iomodel->DeleteData(5,RiftsRiftstructEnum,ThicknessEnum,BedEnum,SurfaceEnum,MaskVertexonfloatingiceEnum);
    159                 xfree((void**)&riftfront);
     159                xDelete<Riftfront>(riftfront);
    160160        }
    161161
  • issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHutter/CreateConstraintsDiagnosticHutter.cpp

    r10522 r12706  
    6060                        }
    6161                        else{
    62                                 if (!isnan(iomodel->Data(DiagnosticSpcvxEnum)[i])){
     62                                if (!xIsNan<IssmDouble>(iomodel->Data(DiagnosticSpcvxEnum)[i])){
    6363                                        constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,iomodel->Data(DiagnosticSpcvxEnum)[i]/yts,DiagnosticHutterAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
    6464                                        count++;
    6565                                }
    6666
    67                                 if (!isnan(iomodel->Data(DiagnosticSpcvyEnum)[i])){
     67                                if (!xIsNan<IssmDouble>(iomodel->Data(DiagnosticSpcvyEnum)[i])){
    6868                                        constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,iomodel->Data(DiagnosticSpcvyEnum)[i]/yts,DiagnosticHutterAnalysisEnum)); //add count'th spc, on node i+1, setting dof 2 to vy
    6969                                        count++;
  • issm/trunk/src/c/modules/ModelProcessorx/DiagnosticVert/CreateConstraintsDiagnosticVert.cpp

    r11237 r12706  
    5656                                count++;
    5757                        }
    58                         else if (!isnan(iomodel->Data(DiagnosticSpcvzEnum)[i])){
     58                        else if (!xIsNan<IssmDouble>(iomodel->Data(DiagnosticSpcvzEnum)[i])){
    5959                                constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,
    6060                                                                iomodel->Data(DiagnosticSpcvzEnum)[i]/yts,DiagnosticVertAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
  • issm/trunk/src/c/modules/ModelProcessorx/DistributeNumDofs.cpp

    r9218 r12706  
    77#include "../../EnumDefinitions/EnumDefinitions.h"
    88       
    9 void DistributeNumDofs(DofIndexing* index,int analysis_type,double* vertices_type){
     9void DistributeNumDofs(DofIndexing* index,int analysis_type,IssmDouble* vertices_type){
    1010
    1111        /*For now, we distribute by analysis_type, later, we will distribute using the analysis_type,
     
    3535                else if (vertices_type[0]==MacAyealPattynApproximationEnum){
    3636                        numdofs=4;
    37                         doftype=(int*)xmalloc(numdofs*sizeof(int));
     37                        doftype=xNew<int>(numdofs);
    3838                        doftype[0]=MacAyealApproximationEnum;
    3939                        doftype[1]=MacAyealApproximationEnum;
     
    4343                else if (vertices_type[0]==PattynStokesApproximationEnum){
    4444                        numdofs=6;
    45                         doftype=(int*)xmalloc(numdofs*sizeof(int));
     45                        doftype=xNew<int>(numdofs);
    4646                        doftype[0]=PattynApproximationEnum;
    4747                        doftype[1]=PattynApproximationEnum;
     
    5353                else if (vertices_type[0]==MacAyealStokesApproximationEnum){
    5454                        numdofs=6;
    55                         doftype=(int*)xmalloc(numdofs*sizeof(int));
     55                        doftype=xNew<int>(numdofs);
    5656                        doftype[0]=MacAyealApproximationEnum;
    5757                        doftype[1]=MacAyealApproximationEnum;
     
    6161                        doftype[5]=StokesApproximationEnum;
    6262                }
    63                 else _error_("Approximationtype %i (%s) not implemented yet for DiagnosticHoriz",(int)*vertices_type,EnumToStringx((int)*vertices_type));
     63                else _error2_("Approximationtype " << reCast<int>(*vertices_type) << " (" << EnumToStringx(reCast<int>(*vertices_type)) << ") not implemented yet for DiagnosticHoriz");
    6464        }
    6565        else if (analysis_type==DiagnosticVertAnalysisEnum){
     
    9090                numdofs=1;
    9191        }
    92         else _error_("analysis type: %i (%s) not implemented yet",analysis_type,EnumToStringx(analysis_type));
     92        else _error2_("analysis type: " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not implemented yet");
    9393
    9494        /*Now initialize the index*/
     
    9696
    9797        /*Clean up*/
    98          xfree((void**)&doftype);
     98         xDelete<int>(doftype);
    9999}
  • issm/trunk/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp

    r12330 r12706  
    4242        int  el1,el2;
    4343        int    dim;
    44         double* elements=NULL;
    45         double* elements2d=NULL;
    46         double* riftinfo=NULL;
    47         double* vertex_pairing=NULL;
     44        IssmDouble* elements=NULL;
     45        IssmDouble* elements2d=NULL;
     46        IssmDouble* riftinfo=NULL;
     47        IssmDouble* vertex_pairing=NULL;
    4848
    4949        /*Fetch parameters: */
     
    7676
    7777        /*Free elements and elements2d: */
    78         xfree((void**)&elements);
    79         xfree((void**)&elements2d);
     78        xDelete<IssmDouble>(elements);
     79        xDelete<IssmDouble>(elements2d);
    8080
    8181        /*Deal with rifts, they have to be included into one partition only, not several: */
     
    8383                iomodel->FetchData(&riftinfo,&numrifts,NULL,RiftsRiftstructEnum);
    8484                for(i=0;i<numrifts;i++){
    85                         el1=(int)*(riftinfo+RIFTINFOSIZE*i+2)-1; //matlab indexing to c indexing
    86                         el2=(int)*(riftinfo+RIFTINFOSIZE*i+3)-1; //matlab indexing to c indexing
     85                        el1=reCast<int>(*(riftinfo+RIFTINFOSIZE*i+2))-1; //matlab indexing to c indexing
     86                        el2=reCast<int>(*(riftinfo+RIFTINFOSIZE*i+3))-1; //matlab indexing to c indexing
    8787                        epart[el2]=epart[el1]; //ensures that this pair of elements will be in the same partition, as well as the corresponding vertices;
    8888                }
    89                 xfree((void**)&riftinfo);
     89                xDelete<IssmDouble>(riftinfo);
    9090        }
    9191
    9292        /*Used later on: */
    93         my_vertices=(int*)xcalloc(numberofvertices,sizeof(int));
    94         my_elements=(bool*)xcalloc(numberofelements,sizeof(bool));
     93        my_vertices=xNewZeroInit<int>(numberofvertices);
     94        my_elements=xNewZeroInit<bool>(numberofelements);
    9595
    9696        /*Start figuring out, out of the partition, which elements belong to this cpu: */
     
    107107                         into the vertices coordinates. If we start plugging 1 into my_vertices for each index[n][i] (i=0:2), then my_vertices
    108108                         will hold which vertices belong to this partition*/
    109                         my_vertices[(int)*(elements+elements_width*i+0)-1]=1;
    110                         my_vertices[(int)*(elements+elements_width*i+1)-1]=1;
    111                         my_vertices[(int)*(elements+elements_width*i+2)-1]=1;
     109                        my_vertices[reCast<int>(*(elements+elements_width*i+0))-1]=1;
     110                        my_vertices[reCast<int>(*(elements+elements_width*i+1))-1]=1;
     111                        my_vertices[reCast<int>(*(elements+elements_width*i+2))-1]=1;
    112112                       
    113113                        if(elements_width==6){
    114                                 my_vertices[(int)*(elements+elements_width*i+3)-1]=1;
    115                                 my_vertices[(int)*(elements+elements_width*i+4)-1]=1;
    116                                 my_vertices[(int)*(elements+elements_width*i+5)-1]=1;
     114                                my_vertices[reCast<int>(*(elements+elements_width*i+3))-1]=1;
     115                                my_vertices[reCast<int>(*(elements+elements_width*i+4))-1]=1;
     116                                my_vertices[reCast<int>(*(elements+elements_width*i+5))-1]=1;
    117117                        }
    118118                }
    119119        }//for (i=0;i<numberofelements;i++)
    120120        /*Free data : */
    121         xfree((void**)&elements);
     121        xDelete<IssmDouble>(elements);
    122122
    123123        /*We might have vertex_pairing in which case, some vertices have to be cloned:
     
    126126        iomodel->FetchData(&vertex_pairing,&numvertex_pairing,NULL,DiagnosticVertexPairingEnum);
    127127        for(i=0;i<numvertex_pairing;i++){
    128                 if(my_vertices[(int)vertex_pairing[2*i+0]-1] && !my_vertices[(int)vertex_pairing[2*i+1]-1]){
    129                         my_vertices[(int)vertex_pairing[2*i+1]-1]=2; //to know that these elements are not on the partition
     128                if(my_vertices[reCast<int>(vertex_pairing[2*i+0])-1] && !my_vertices[reCast<int>(vertex_pairing[2*i+1])-1]){
     129                        my_vertices[reCast<int>(vertex_pairing[2*i+1])-1]=2; //to know that these elements are not on the partition
    130130                }
    131131        }
    132         xfree((void**)&vertex_pairing);
     132        xDelete<IssmDouble>(vertex_pairing);
    133133        iomodel->FetchData(&vertex_pairing,&numvertex_pairing,NULL,PrognosticVertexPairingEnum);
    134134        for(i=0;i<numvertex_pairing;i++){
    135                 if(my_vertices[(int)vertex_pairing[2*i+0]-1] && !my_vertices[(int)vertex_pairing[2*i+1]-1]){
    136                         my_vertices[(int)vertex_pairing[2*i+1]-1]=2; //to know that these elements are not on the partition
     135                if(my_vertices[reCast<int>(vertex_pairing[2*i+0])-1] && !my_vertices[reCast<int>(vertex_pairing[2*i+1])-1]){
     136                        my_vertices[reCast<int>(vertex_pairing[2*i+1])-1]=2; //to know that these elements are not on the partition
    137137                }
    138138        }
    139         xfree((void**)&vertex_pairing);
     139        xDelete<IssmDouble>(vertex_pairing);
    140140
    141141        /*Free ressources:*/
    142         xfree((void**)&npart);
    143         xfree((void**)&epart);
     142        xDelete<int>(npart);
     143        xDelete<int>(epart);
    144144
    145145        /*Assign output pointers:*/
  • issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/CreateConstraintsEnthalpy.cpp

    r11527 r12706  
    99#include "../../../objects/objects.h"
    1010#include "../../../shared/shared.h"
     11#include "../../../include/include.h"
    1112#include "../ModelProcessorx.h"
    1213
     
    1415
    1516        /*Intermediary*/
    16         int i;
    17         int count;
     17        int    i,j;
     18        int    count;
    1819        int    dim;
     20        int    M,N;
    1921        int    numberofvertices;
     22        bool   spcpresent=false;
    2023        double heatcapacity;
    2124        double referencetemperature;
    2225       
    2326        /*Output*/
     27        IssmDouble *spcvector  = NULL;
     28        IssmDouble* times=NULL;
     29        IssmDouble* values=NULL;
    2430        Constraints* constraints = NULL;
    25         SpcStatic*    spcstatic  = NULL;
    2631
    2732        /*Fetch parameters: */
     
    4449
    4550        /*Fetch data: */
    46         double *spctemperature=NULL;
    47         iomodel->FetchData(&spctemperature,NULL,NULL,ThermalSpctemperatureEnum);
     51        iomodel->FetchData(&spcvector,&M,&N,ThermalSpctemperatureEnum);
    4852
    49         /*Initialize counter*/
    50         count=0;
     53        //FIX ME: SHOULD USE IOMODELCREATECONSTRAINTS
     54        /*Transient or static?:*/
     55        if(M==numberofvertices){
     56                /*static: just create Constraints objects*/
     57                count=0;
    5158
    52         /*Create constraints from x,y,z: */
    53         for (i=0;i<numberofvertices;i++){
    54                 /*keep only this partition's nodes:*/
    55                 if((iomodel->my_vertices[i])){
     59                for (i=0;i<numberofvertices;i++){
     60                        /*keep only this partition's nodes:*/
     61                        if((iomodel->my_vertices[i])){
    5662
    57                         if (!isnan(spctemperature[i])){
     63                                if (!xIsNan<IssmDouble>(spcvector[i])){
    5864
    59                                 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,heatcapacity*(spctemperature[i]-referencetemperature),EnthalpyAnalysisEnum));
    60                                 count++;
     65                                        constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,heatcapacity*(spcvector[i]-referencetemperature),EnthalpyAnalysisEnum));
     66                                        count++;
    6167
     68                                }
    6269                        }
    6370                }
    6471        }
     72        else if (M==(numberofvertices+1)){
     73                /*transient: create transient SpcTransient objects. Same logic, except we need to retrieve
     74                 * various times and values to initialize an SpcTransient object: */
     75                count=0;
    6576
    66         /*Free data: */
    67         xfree((void**)&spctemperature);
    68        
     77                /*figure out times: */
     78                times=xNew<IssmDouble>(N);
     79                for(j=0;j<N;j++){
     80                        times[j]=spcvector[(M-1)*N+j];
     81                }
     82                /*unit conversion: */
     83                UnitConversion(times,N,ExtToIuEnum,TimeEnum);
     84
     85                /*Create constraints from x,y,z: */
     86                for (i=0;i<numberofvertices;i++){
     87                       
     88                        /*keep only this partition's nodes:*/
     89                        if((iomodel->my_vertices[i])){
     90
     91                                /*figure out times and values: */
     92                                values=xNew<IssmDouble>(N);
     93                                spcpresent=false;
     94                                for(j=0;j<N;j++){
     95                                        values[j]=heatcapacity*(spcvector[i*N+j]-referencetemperature);
     96                                        if(!xIsNan<IssmDouble>(values[j]))spcpresent=true; //NaN means no spc by default
     97                                }
     98
     99                                if(spcpresent){
     100                                        constraints->AddObject(new SpcTransient(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,N,times,values,EnthalpyAnalysisEnum));
     101                                        count++;
     102                                }
     103                                xDelete<IssmDouble>(values);
     104                        }
     105                }
     106        }
     107        else{
     108                _error2_("Size of field " << EnumToStringx(ThermalSpctemperatureEnum) << " not supported");
     109        }
     110
     111        /*Free ressources:*/
     112        xDelete<IssmDouble>(spcvector);
     113        xDelete<IssmDouble>(times);
     114        xDelete<IssmDouble>(values);
     115
    69116        /*Assign output pointer: */
    70117        *pconstraints=constraints;
  • issm/trunk/src/c/modules/ModelProcessorx/Melting/CreateLoadsMelting.cpp

    r10522 r12706  
    2626
    2727        /*if 2d: Error*/
    28         if (dim==2) _error_("2d meshes not supported yet");
     28        if (dim==2) _error2_("2d meshes not supported yet");
    2929
    3030        /*Recover pointer: */
  • issm/trunk/src/c/modules/ModelProcessorx/ModelProcessorx.cpp

    r11995 r12706  
    6868                if(solution_type==SteadystateSolutionEnum && analysis_type==EnthalpyAnalysisEnum && isenthalpy==false) continue;
    6969       
    70                 _printf_(VerboseMProcessor(),"   creating datasets for analysis %s\n",EnumToStringx(analysis_type));
     70                if(VerboseMProcessor()) _pprintLine_("   creating datasets for analysis " << EnumToStringx(analysis_type));
    7171                CreateDataSets(&elements,&nodes,&vertices,&materials,&constraints,&loads,&parameters,iomodel,solution_type,analysis_type,nummodels,i);
    7272        }
  • issm/trunk/src/c/modules/ModelProcessorx/ModelProcessorx.h

    r10576 r12706  
    108108
    109109/*Distribution of dofs: */
    110 void DistributeNumDofs(DofIndexing* index,int analysis_type,double* vertices_type);
     110void DistributeNumDofs(DofIndexing* index,int analysis_type,IssmDouble* vertices_type);
    111111
    112112#endif
  • issm/trunk/src/c/modules/ModelProcessorx/NodesPartitioning.cpp

    r9733 r12706  
    2424       
    2525        /*First thing, this is a new partition for a new analysis_type, therefore, to avoid a leak, erase the nodes partition that might come through pmy_nodes: */
    26         xfree((void**)pmy_nodes);
     26        xDelete<bool>(*pmy_nodes);
    2727
    2828        /*Now, depending on whether we are running galerkin discontinous or continuous elements, carry out a different partition of the nodes: */
     
    4444        iomodel->Constant(&numberofvertices,MeshNumberofverticesEnum);
    4545
    46         my_nodes=(bool*)xmalloc(numberofvertices*sizeof(bool));
    47         memcpy(my_nodes,my_vertices,numberofvertices*sizeof(bool));
     46        my_nodes=xNew<bool>(numberofvertices);
     47        for(int i=0;i<numberofvertices;i++) my_nodes[i]=(bool)my_vertices[i];
    4848
    4949        /*Assign output pointers:*/
     
    6969        bool*   my_nodes=NULL;
    7070
    71         int     i1,i2;
    72         int     cols;
    73         double  e1,e2;
    74         int     pos;
    75         int     numberofedges;
    76         double* edges=NULL;
    77         double* elements=NULL;
     71        int  i1,i2;
     72        int  cols;
     73        int  e1,e2;
     74        int  pos;
     75        int  numberofedges;
     76        int *edges         = NULL;
     77        int *elements      = NULL;
    7878
    7979        /*Fetch parameters: */
     
    9090
    9191        /*Allocate*/
    92         my_nodes=(bool*)xcalloc(3*numberofelements,sizeof(int));
     92        my_nodes=xNewZeroInit<bool>(3*numberofelements);
    9393
    9494        /*First: add all the nodes of all the elements belonging to this cpu*/
     
    9696                for (i=0;i<numberofelements;i++){
    9797                        if (my_elements[i]){
    98                                 my_nodes[3*i+0]=1;
    99                                 my_nodes[3*i+1]=1;
    100                                 my_nodes[3*i+2]=1;
     98                                my_nodes[3*i+0]=true;
     99                                my_nodes[3*i+1]=true;
     100                                my_nodes[3*i+2]=true;
    101101                        }
    102102                }
    103103        }
    104104        else{
    105                 _error_("not implemented yet");
     105                _error2_("not implemented yet");
    106106        }
    107107
     
    111111        iomodel->FetchData(&edges,&numberofedges,&cols,MeshEdgesEnum);
    112112        iomodel->FetchData(&elements,NULL,NULL,MeshElementsEnum);
    113         if (cols!=4) _error_("field edges should have 4 columns");
     113        if (cols!=4) _error2_("field edges should have 4 columns");
    114114
    115115        /*!All elements have been partitioned above, only create elements for this CPU: */
     
    125125                 * we must clone the nodes on this partition so that the loads (Numericalflux)
    126126                 * will have access to their properties (dofs,...)*/
    127                 if(my_elements[(int)e1] && !isnan(e2) && !my_elements[(int)e2]){
     127                if(my_elements[e1] && e2!=-2 && !my_elements[e2]){
    128128
    129129                        /*1: Get vertices ids*/
    130                         i1=(int)edges[4*i+0];
    131                         i2=(int)edges[4*i+1];
     130                        i1=edges[4*i+0];
     131                        i2=edges[4*i+1];
    132132
    133133                        /*2: Get the column where these ids are located in the index*/
    134134                        pos=UNDEF;
    135135                        for(j=0;j<3;j++){
    136                                 if ((int)elements[3*(int)e2+j]==i1) pos=j;
     136                                if (elements[3*e2+j]==i1) pos=j;
    137137                        }
    138138
     
    140140                         * we can now create the corresponding nodes:*/
    141141                        if (pos==0){
    142                                 my_nodes[(int)e2*3+0]=1;
    143                                 my_nodes[(int)e2*3+2]=1;
     142                                my_nodes[e2*3+0]=true;
     143                                my_nodes[e2*3+2]=true;
    144144                        }
    145145                        else if(pos==1){
    146                                 my_nodes[(int)e2*3+1]=1;
    147                                 my_nodes[(int)e2*3+0]=1;
     146                                my_nodes[e2*3+1]=true;
     147                                my_nodes[e2*3+0]=true;
    148148                        }
    149149                        else if (pos==2){
    150                                 my_nodes[(int)e2*3+2]=1;
    151                                 my_nodes[(int)e2*3+1]=1;
     150                                my_nodes[e2*3+2]=true;
     151                                my_nodes[e2*3+1]=true;
    152152                        }
    153153                        else{
    154                                 _error_("Problem in edges creation");
     154                                _error2_("Problem in edges creation");
    155155                        }
    156156                }
     
    158158
    159159        /*Free data: */
    160         xfree((void**)&elements);
    161         xfree((void**)&edges);
     160        xDelete<int>(elements);
     161        xDelete<int>(edges);
    162162
    163163        /*Assign output pointers:*/
  • issm/trunk/src/c/modules/ModelProcessorx/Prognostic/CreateLoadsPrognostic.cpp

    r10522 r12706  
    4747
    4848                        /*Get left and right elements*/
    49                         element=(int)(iomodel->Data(MeshEdgesEnum)[4*i+2])-1; //edges are [node1 node2 elem1 elem2]
     49                        element=reCast<int>(iomodel->Data(MeshEdgesEnum)[4*i+2])-1; //edges are [node1 node2 elem1 elem2]
    5050
    5151                        /*Now, if this element is not in the partition, pass: */
     
    6161
    6262        /*Create Penpair for vertex_pairing: */
    63         double *vertex_pairing=NULL;
    64         double *nodeonbed=NULL;
     63        IssmDouble *vertex_pairing=NULL;
     64        IssmDouble *nodeonbed=NULL;
    6565        iomodel->FetchData(&vertex_pairing,&numvertex_pairing,NULL,PrognosticVertexPairingEnum);
    6666        iomodel->FetchData(&nodeonbed,NULL,NULL,MeshVertexonbedEnum);
     
    6868        for(i=0;i<numvertex_pairing;i++){
    6969
    70                 if(iomodel->my_vertices[(int)vertex_pairing[2*i+0]-1]){
     70                if(iomodel->my_vertices[reCast<int>(vertex_pairing[2*i+0])-1]){
    7171
    7272                        /*In debugging mode, check that the second node is in the same cpu*/
    73                         _assert_(iomodel->my_vertices[(int)vertex_pairing[2*i+1]-1]);
     73                        _assert_(iomodel->my_vertices[reCast<int>(vertex_pairing[2*i+1])-1]);
    7474
    7575                        /*Skip if one of the two is not on the bed*/
    76                         if(!nodeonbed[(int)vertex_pairing[2*i+0]-1] || !nodeonbed[(int)vertex_pairing[2*i+1]-1]) continue;
     76                        if(!(reCast<bool>(nodeonbed[reCast<int>(vertex_pairing[2*i+0])-1])) || !(reCast<bool>(nodeonbed[reCast<int>(vertex_pairing[2*i+1])-1]))) continue;
    7777
    7878                        /*Get node ids*/
    79                         penpair_ids[0]=iomodel->nodecounter+(int)vertex_pairing[2*i+0];
    80                         penpair_ids[1]=iomodel->nodecounter+(int)vertex_pairing[2*i+1];
     79                        penpair_ids[0]=iomodel->nodecounter+reCast<int>(vertex_pairing[2*i+0]);
     80                        penpair_ids[1]=iomodel->nodecounter+reCast<int>(vertex_pairing[2*i+1]);
    8181
    8282                        /*Create Load*/
     
    9090
    9191        /*free ressources: */
    92         xfree((void**)&vertex_pairing);
    93         xfree((void**)&nodeonbed);
    94 
     92        xDelete<IssmDouble>(vertex_pairing);
     93        xDelete<IssmDouble>(nodeonbed);
    9594
    9695        /*Assign output pointer: */
  • issm/trunk/src/c/modules/ModelProcessorx/Prognostic/CreateNodesPrognostic.cpp

    r10522 r12706  
    4646
    4747        /*Check in 3d*/
    48         if(stabilization==3 && dim==3) _error_("DG 3d not implemented yet");
     48        if(stabilization==3 && dim==3) _error2_("DG 3d not implemented yet");
    4949
    5050        /*First fetch data: */
     
    7272
    7373                                        //Get index of the vertex on which the current node is located
    74                                         vertex_id=(int)*(iomodel->Data(MeshElementsEnum)+3*i+j); //(Matlab indexing)
     74                                        vertex_id=reCast<int>(*(iomodel->Data(MeshElementsEnum)+3*i+j)); //(Matlab indexing)
    7575                                        io_index=vertex_id-1;                      //(C indexing)
    7676                                        _assert_(vertex_id>0 && vertex_id<=numberofvertices);
  • issm/trunk/src/c/modules/ModelProcessorx/Prognostic/UpdateElementsPrognostic.cpp

    r12301 r12706  
    2121        bool   dakota_analysis;
    2222        bool   ispdd;
     23        bool   issmbgradients;
    2324
    2425        /*Fetch data needed: */
     
    2930        iomodel->FetchData(1,MeshElementsEnum);
    3031        iomodel->Constant(&ispdd,SurfaceforcingsIspddEnum);
     32        iomodel->Constant(&issmbgradients,SurfaceforcingsIssmbgradientsEnum);
    3133
    3234        /*Update elements: */
     
    7375          iomodel->FetchDataToInput(elements,SurfaceforcingsMonthlytemperaturesEnum);
    7476        }
     77        if(issmbgradients){
     78          iomodel->FetchDataToInput(elements,SurfaceforcingsHcEnum);
     79          iomodel->FetchDataToInput(elements,SurfaceforcingsSmbPosMaxEnum);
     80          iomodel->FetchDataToInput(elements,SurfaceforcingsSmbPosMinEnum);
     81          iomodel->FetchDataToInput(elements,SurfaceforcingsAPosEnum);
     82          iomodel->FetchDataToInput(elements,SurfaceforcingsBPosEnum);
     83          iomodel->FetchDataToInput(elements,SurfaceforcingsANegEnum);
     84          iomodel->FetchDataToInput(elements,SurfaceforcingsBNegEnum);
     85        }
    7586        else{
    7687                iomodel->FetchDataToInput(elements,SurfaceforcingsMassBalanceEnum);
  • issm/trunk/src/c/modules/ModelProcessorx/Thermal/CreateLoadsThermal.cpp

    r10522 r12706  
    3333
    3434        /*return if 2d mesh*/
    35         if (dim==2) _error_("2d meshes not supported yet");
     35        if (dim==2) _error2_("2d meshes not supported yet");
    3636
    3737        //create penalties for nodes: no node can have a temperature over the melting point
     
    4343                /*keep only this partition's nodes:*/
    4444                if((iomodel->my_vertices[i]==1)){
    45                         if (isnan(iomodel->Data(ThermalSpctemperatureEnum)[i])){ //No penalty applied on spc nodes!
     45                        if (xIsNan<IssmDouble>(iomodel->Data(ThermalSpctemperatureEnum)[i])){ //No penalty applied on spc nodes!
    4646                                loads->AddObject(new Pengrid(iomodel->loadcounter+i+1,i,iomodel,ThermalAnalysisEnum));
    4747                        }
  • issm/trunk/src/c/modules/NodalValuex/NodalValuex.cpp

    r12330 r12706  
    1010#include "../../EnumDefinitions/EnumDefinitions.h"
    1111
    12 void NodalValuex( double* pnodalvalue, int natureofdataenum,Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,bool process_units){
     12void NodalValuex( IssmDouble* pnodalvalue, int natureofdataenum,Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,bool process_units){
    1313
    1414        extern int my_rank;
     
    1616        int index;
    1717        Element* element=NULL;
    18         double value;
     18        IssmDouble value;
    1919        int found;
    2020        int sumfound;
     
    3838        #ifdef _HAVE_MPI_
    3939        MPI_Allreduce ( &found,&sumfound,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
    40         if(!sumfound)_error_("%s%i%s%s","could not find element with vertex with id",index," to compute nodal value ",EnumToStringx(natureofdataenum));
     40        if(!sumfound)_error2_("could not find element with vertex with id" << index << " to compute nodal value " << EnumToStringx(natureofdataenum));
    4141        #endif
    4242
  • issm/trunk/src/c/modules/NodalValuex/NodalValuex.h

    r9206 r12706  
    1010
    1111/* local prototypes: */
    12 void NodalValuex( double* pnodalvalue, int natureofdataenum,Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,bool process_units);
     12void NodalValuex( IssmDouble* pnodalvalue, int natureofdataenum,Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,bool process_units);
    1313
    1414#endif  /* _NODALVALUEX_H */
  • issm/trunk/src/c/modules/NodeConnectivityx/NodeConnectivityx.cpp

    r6412 r12706  
    3737
    3838        /*Allocate connectivity: */
    39         connectivity=(double*)xcalloc(nods*width,sizeof(double));
     39        connectivity=xNewZeroInit<double>(nods*width);
    4040
    4141        /*Go through all elements, and for each elements, plug into the connectivity, all the nodes.
     
    7171         * warn the user to increase the connectivity width: */
    7272        for(i=0;i<nods;i++){
    73                 if (*(connectivity+width*i+maxels)>maxels)_error_("%s%g%s"," max connectivity width reached (",*(connectivity+width*i+maxels),")! increase width of connectivity table");
     73                if (*(connectivity+width*i+maxels)>maxels)_error2_("max connectivity width reached (" << *(connectivity+width*i+maxels) << ")! increase width of connectivity table");
    7474        }
    7575
  • issm/trunk/src/c/modules/OutputResultsx/OutputResultsx.cpp

    r12330 r12706  
    1616#include "../../objects/objects.h"
    1717               
    18 void OutputResultsx(                    Elements* elements, Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,Results* results){
     18void OutputResultsx(Elements* elements, Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,Results* results){
    1919
    2020        extern int  my_rank;
     
    4646                EnumToStringx(&solutiontypestring,solutiontype);
    4747                results->AddObject(new StringExternalResult(results->Size()+1,SolutionTypeEnum,solutiontypestring,1,0));
    48                 xfree((void**)&solutiontypestring);
     48                xDelete<char>(solutiontypestring);
    4949        }
    5050
     
    6868                        fid=pfopen(cpu_outputfilename ,"wb");
    6969                }
    70                 xfree((void**)&outputfilename);
     70                xDelete<char>(outputfilename);
    7171               
    7272                /*Add file pointer in parameters for further calls to OutputResultsx: */
  • issm/trunk/src/c/modules/ParsePetscOptionsx/ParsePetscOptionsx.cpp

    r12330 r12706  
    2727
    2828        /*intermediary: */
    29         double* analyses=NULL;
     29        IssmDouble* analyses=NULL;
    3030        char** strings=NULL;
    3131        int numanalyses;
     
    4848
    4949                /*Now, allocate analyses and strings: */
    50                 analyses=(double*)xmalloc(numanalyses*sizeof(double));
    51                 strings=(char**)xmalloc(numanalyses*sizeof(char*));
     50                analyses=xNew<IssmDouble>(numanalyses);
     51                strings=xNew<char*>(numanalyses);
    5252                for(i=0;i<numanalyses;i++)strings[i]=NULL;
    5353
     
    7070                        to the already existing options*/
    7171                                if(strings[numanalyses-1]==NULL){
    72                                         string=(char*)xmalloc((strlen(line)+1)*sizeof(char));
    73                                         memcpy(string,line,(strlen(line)+1)*sizeof(char));
     72                                        string=xNew<char>((strlen(line)+1));
     73                                        xMemCpy<char>(string,line,(strlen(line)+1));
    7474
    7575                                        strings[numanalyses-1]=string;
     
    7777                                else{
    7878                                        string=strings[numanalyses-1];
    79                                         newstring=(char*)xmalloc((strlen(line)+1)*sizeof(char));
    80                                         memcpy(newstring,line,(strlen(line)+1)*sizeof(char));
     79                                        newstring=xNew<char>((strlen(line)+1));
     80                                        xMemCpy<char>(newstring,line,(strlen(line)+1));
    8181
    8282                                        /*concatenate:*/
    83                                         catstring=(char*)xmalloc((strlen(string)+1+strlen(newstring)+1+1)*sizeof(char)); //fit in a space " "
    84                                         memcpy(catstring,string,(strlen(string)+1)*sizeof(char));
     83                                        catstring=xNew<char>(strlen(string)+1+strlen(newstring)+1+1); //fit in a space " "
     84                                        xMemCpy<char>(catstring,string,(strlen(string)+1));
    8585
    8686                                        strcat(catstring," ");
    8787                                        strcat(catstring,newstring);
    8888                                        strings[numanalyses-1]=catstring;
    89                                         xfree((void**)&newstring);
    90                                         xfree((void**)&string);
     89                                        xDelete<char>(newstring);
     90                                        xDelete<char>(string);
    9191                                }
    9292                        }
     
    9898        MPI_Bcast(&numanalyses,1,MPI_INT,0,MPI_COMM_WORLD);
    9999        if(my_rank!=0){
    100                 analyses=(double*)xmalloc(numanalyses*sizeof(double));
    101                 strings=(char**)xmalloc(numanalyses*sizeof(char*));
     100                analyses=xNew<IssmPDouble>(numanalyses);
     101                strings=xNew<char*>(numanalyses);
    102102        }
    103103        MPI_Bcast(analyses,numanalyses,MPI_DOUBLE,0,MPI_COMM_WORLD);
     
    106106                char* string=strings[i];
    107107                if(my_rank==0){
    108                         if(string==NULL) _error_("PETSc options for analysis %s have been declared but were not found",EnumToStringx((int)analyses[i]));
     108                        if(string==NULL) _error2_("PETSc options for analysis " << EnumToStringx(reCast<int>(analyses[i])) << " have been declared but were not found");
    109109                }
    110110                if(my_rank==0)stringlength=(strlen(string)+1)*sizeof(char);
    111111                #ifdef _HAVE_MPI_
    112112                MPI_Bcast(&stringlength,1,MPI_INT,0,MPI_COMM_WORLD);
    113                 if(my_rank!=0)string=(char*)xmalloc(stringlength);
     113                if(my_rank!=0)string=xNew<char>(stringlength);
    114114                MPI_Bcast(string,stringlength,MPI_CHAR,0,MPI_COMM_WORLD);
    115115                if(my_rank!=0)strings[i]=string;
     
    122122
    123123        /*Clean up and return*/
    124         for(i=0;i<numanalyses;i++) xfree((void**)&strings[i]);
    125         xfree((void**)&strings);
    126         xfree((void**)&analyses);
     124        for(i=0;i<numanalyses;i++) xDelete<char>(strings[i]);
     125        xDelete<char*>(strings);
     126        xDelete<IssmDouble>(analyses);
    127127        return;
    128128}
    129 
  • issm/trunk/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsxt.cpp

    r11995 r12706  
    3939
    4040        /*allocate: */
    41         already=(bool*)xcalloc(nods,sizeof(bool));
     41        already=xNewZeroInit<bool>(nods);
    4242
    4343        /*partition loop across threads: */
     
    4545
    4646        /*Loop over the nodes*/
    47         if (my_thread==0) printf("      loop progress:   %5.2lf %%",0.0);
    48 
    4947        for (i=i0;i<i1;i++){
    5048
    5149                /*display current iteration*/
    52                 if (my_thread==0 && fmod((double)i,(double)100)==0) printf("\b\b\b\b\b\b\b%5.2lf %%",(double)i/nods*100*num_threads);
     50                if (my_thread==0 && fmod((double)i,(double)100)==0)
     51                 _printString_("\r      loop progress: "<<setw(6)<<setprecision(2)<<double(i-i0)/double(i1-i0)*100<<"%");
    5352
    5453                distance=mindistance+100; //make sure initialization respects min distance criterion.
     
    7069                }
    7170        }
    72         if (my_thread==0) printf("\b\b\b\b\b\b\b%5.2lf %%\n",100.0);
     71        if (my_thread==0)
     72         _printLine_("\r      loop progress: "<<fixed<<setw(6)<<setprecision(2)<<100.<<"%");
    7373
    7474        /*Free ressources:*/
    75         xfree((void**)&already);
     75        xDelete<bool>(already);
    7676       
    7777        return NULL;
  • issm/trunk/src/c/modules/PositiveDegreeDayx/PositiveDegreeDayx.cpp

    r12346 r12706  
    2323
    2424  int    i, it, jj, itm;
    25   double DT = 0.02, sigfac, snormfac;
    26   double signorm = 5.5;      // signorm : sigma of the temperature distribution for a normal day
    27   double siglim;       // sigma limit for the integration which is equal to 2.5 sigmanorm
    28   double signormc = signorm - 0.5;     // sigma of the temperature distribution for cloudy day
    29   double siglimc, siglim0, siglim0c;
    30   double tstep, tsint, tint, tstepc;
     25  IssmDouble DT = 0.02, sigfac, snormfac;
     26  IssmDouble signorm = 5.5;      // signorm : sigma of the temperature distribution for a normal day
     27  IssmDouble siglim;       // sigma limit for the integration which is equal to 2.5 sigmanorm
     28  IssmDouble signormc = signorm - 0.5;     // sigma of the temperature distribution for cloudy day
     29  IssmDouble siglimc, siglim0, siglim0c;
     30  IssmDouble tstep, tsint, tint, tstepc;
    3131  int    NPDMAX = 1504, NPDCMAX = 1454;
    32   //double pdds[NPDMAX]={0};
    33   //double pds[NPDCMAX]={0};
    34   double pddt, pd ; // pd : snow/precip fraction, precipitation falling as snow
    35   double PDup, PDCUT = 2.0;    // PDcut: rain/snow cutoff temperature (C)
    36   double tstar; // monthly mean surface temp
     32  //IssmDouble pdds[NPDMAX]={0};
     33  //IssmDouble pds[NPDCMAX]={0};
     34  IssmDouble pddt, pd ; // pd : snow/precip fraction, precipitation falling as snow
     35  IssmDouble PDup, PDCUT = 2.0;    // PDcut: rain/snow cutoff temperature (C)
     36  IssmDouble tstar; // monthly mean surface temp
    3737 
    38   double* pdds=NULL;
    39   double* pds=NULL;
     38  IssmDouble* pdds=NULL;
     39  IssmDouble* pds=NULL;
    4040  Element* element = NULL;
    4141 
    42   pdds=(double*)xmalloc(NPDMAX*sizeof(double)+1);
    43   pds=(double*)xmalloc(NPDCMAX*sizeof(double)+1);
     42  pdds=xNew<IssmDouble>(NPDMAX+1);
     43  pds=xNew<IssmDouble>(NPDCMAX+1);
    4444 
    4545  // initialize PDD (creation of a lookup table)
     
    5454  PDup = siglimc+PDCUT;
    5555
    56   itm = (int)(2*siglim/DT + 1.5);
     56  itm = reCast<int,IssmDouble>((2*siglim/DT + 1.5));
    5757 
    5858  if (itm >= NPDMAX){
    59     printf("increase NPDMAX in massBalance.cpp\n");
     59    _printLine_("increase NPDMAX in massBalance.cpp");
    6060    exit (1);
    6161      }
     
    8181  snormfac = 1.0/(signormc*sqrt(2.0*acos(-1.0)));
    8282  siglimc = 2.5*signormc ;
    83   itm = (int)((PDCUT+2.*siglimc)/DT + 1.5);
     83  itm = reCast<int,IssmDouble>((PDCUT+2.*siglimc)/DT + 1.5);
    8484  if (itm >= NPDCMAX){
    85     printf("'increase NPDCMAX in p35com'\n");
     85    _printLine_("'increase NPDCMAX in p35com'");
    8686    exit (1);
    8787      }
     
    106106  }
    107107  /*free ressouces: */
    108   xfree((void**)&pdds);
    109   xfree((void**)&pds);
     108  xDelete<IssmDouble>(pdds);
     109  xDelete<IssmDouble>(pds);
    110110 
    111111}
  • issm/trunk/src/c/modules/Reduceloadx/Reduceloadx.cpp

    r11995 r12706  
    2222        int         verbose;
    2323
    24         _printf_(VerboseModule(),"   Dirichlet lifting applied to load vector\n");
     24        if(VerboseModule()) _pprintLine_("   Dirichlet lifting applied to load vector");
    2525
    2626        Kfs->GetSize(&global_m,&global_n);
  • issm/trunk/src/c/modules/Reducevectorgtofx/Reducevectorgtofx.cpp

    r11995 r12706  
    1515        int configuration_type;
    1616        int fsize;
    17         double* ug_serial=NULL;
     17        IssmDouble* ug_serial=NULL;
    1818
    1919        /*first figure out fsize: */
     
    5151
    5252        /*Free ressources:*/
    53         xfree((void**)&ug_serial);
     53        xDelete<IssmDouble>(ug_serial);
    5454
    5555        /*Assign output pointers:*/
  • issm/trunk/src/c/modules/Reducevectorgtosx/Reducevectorgtosx.cpp

    r11995 r12706  
    5151
    5252        /*Free ressources:*/
    53         xfree((void**)&yg_serial);
     53        xDelete<double>(yg_serial);
    5454
    5555        /*Assign output pointers:*/
  • issm/trunk/src/c/modules/RequestedOutputsx/RequestedOutputsx.cpp

    r11995 r12706  
    1313        int      output_enum;
    1414        int      step;
    15         double   time;
    16         double   output_value;
     15        IssmDouble   time;
     16        IssmDouble   output_value;
    1717        Element *element      = NULL;
    1818
  • issm/trunk/src/c/modules/ResetConstraintsx/ResetConstraintsx.cpp

    r9761 r12706  
    2222
    2323        /*Display message*/
    24         _printf_(VerboseModule(),"   Resetting penalties\n");
     24        if(VerboseModule()) _pprintLine_("   Resetting penalties");
    2525
    2626        /*recover parameters: */
     
    3030         * management routine, otherwise, skip : */
    3131        if (RiftIsPresent(loads,analysis_type)){
    32                 _error_("rift constraints reset not supported yet!");
     32                _error2_("rift constraints reset not supported yet!");
    3333        }
    3434        else if(ThermalIsPresent(loads,analysis_type)){
  • issm/trunk/src/c/modules/Responsex/Responsex.cpp

    r11237 r12706  
    1616#include "../modules.h"
    1717
    18 void Responsex(double* responses,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,const char* response_descriptor,bool process_units,int weight_index){
     18void Responsex(IssmDouble* responses,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,const char* response_descriptor,bool process_units,int weight_index){
    1919
    2020        switch (StringToEnumx(response_descriptor)){
     
    4646                case VelEnum:ElementResponsex(responses, elements,nodes, vertices, loads, materials, parameters,VelEnum,process_units); break;
    4747                case FrictionCoefficientEnum:NodalValuex(responses, FrictionCoefficientEnum,elements,nodes, vertices, loads, materials, parameters,process_units); break;
    48                 default: _error_(" response descriptor \"%s\" not supported yet!",response_descriptor); break;
     48                default: _error2_("response descriptor \"" << response_descriptor << "\" not supported yet!"); break;
    4949                #else
    50                 default: _error_(" ISSM was not compiled with responses capabilities, exiting!");
     50                default: _error2_("ISSM was not compiled with responses capabilities, exiting!");
    5151                #endif
    5252        }
  • issm/trunk/src/c/modules/Responsex/Responsex.h

    r11237 r12706  
    99#include "../../Container/Container.h"
    1010
    11 void Responsex(double* presponse,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,const char* response_descriptor,bool process_units,int weight_index);
     11void Responsex(IssmDouble* presponse,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,const char* response_descriptor,bool process_units,int weight_index);
    1212
    1313#endif  /* _RESPONSESXX_H */
  • issm/trunk/src/c/modules/SetControlInputsFromVectorx/SetControlInputsFromVectorx.cpp

    r11995 r12706  
    2525        }
    2626
    27         xfree((void**)&control_type);
     27        xDelete<int>(control_type);
    2828}
    2929
     
    3737
    3838        /*Free ressources:*/
    39         xfree((void**)&serial_vector);
     39        xDelete<double>(serial_vector);
    4040}
  • issm/trunk/src/c/modules/Shp2Kmlx/Shp2Kmlx.cpp

    r11527 r12706  
    3939        int     nshape,ncoord;
    4040        double  cpsum;
    41         int     *pstype=NULL,*pnpart=NULL,**ppstrt=NULL,**pptype=NULL,*pnvert=NULL;
    42         double  **pshapx=NULL,**pshapy=NULL,**pshapz=NULL,**pshapm=NULL;
    43         double  *lat=NULL,*lon=NULL;
     41        int     *pstype = NULL, *pnpart=NULL,**ppstrt=NULL,**pptype=NULL,*pnvert=NULL;
     42        double **pshapx = NULL,**pshapy=NULL,**pshapz=NULL,**pshapm=NULL;
     43        double  *lat    = NULL, *lon=NULL;
    4444
    4545        SHPHandle   hSHP;
     
    4949
    5050        char    indent[81]="";
    51         KML_File*             kfile =NULL;
    52         KML_Document*         kdoc  =NULL;
    53         KML_Style*            kstyle=NULL;
    54         KML_LineStyle*        klsty =NULL;
    55         KML_PolyStyle*        kpsty =NULL;
    56         KML_Folder*           kfold =NULL;
    57         KML_Placemark*        kplace=NULL;
    58         KML_MultiGeometry*    kmulti=NULL;
    59         KML_Polygon*          kpoly =NULL;
    60         KML_LinearRing*       kring =NULL;
    61         KML_LineString*       kline =NULL;
    62         KML_Point*            kpoint=NULL;
    63 
    64         FILE*   fid=NULL;
     51        KML_File          *kfile  = NULL;
     52        KML_Document      *kdoc   = NULL;
     53        KML_Style         *kstyle = NULL;
     54        KML_LineStyle     *klsty  = NULL;
     55        KML_PolyStyle     *kpsty  = NULL;
     56        KML_Folder        *kfold  = NULL;
     57        KML_Placemark     *kplace = NULL;
     58        KML_MultiGeometry *kmulti = NULL;
     59        KML_Polygon       *kpoly  = NULL;
     60        KML_LinearRing    *kring  = NULL;
     61        KML_LineString    *kline  = NULL;
     62        KML_Point         *kpoint = NULL;
     63        FILE              *fid    = NULL;
    6564
    6665        clock_t clock0,clock1;
     
    6968        clock0=clock();
    7069        time0 =time(NULL);
    71         _printf_(true,"\nShp2Kmlx Module -- %s",ctime(&time0));
     70        _pprintString_("\nShp2Kmlx Module -- " << ctime(&time0));
    7271
    7372/*  note that much of the following code is taken from shpdump.c in shapelib.  */
     
    7675
    7776        hSHP = SHPOpen( filshp, "rb" );
    78         if (!hSHP) _error_("Error opening shp/shx files.");
     77        if (!hSHP) _error2_("Error opening shp/shx files.");
    7978
    8079/*  read header and print out file bounds  */
     
    9796
    9897        nshape=nEntities;
    99         pstype=(int *) xmalloc(nshape*sizeof(int));
    100         pnpart=(int *) xmalloc(nshape*sizeof(int));
    101         ppstrt=(int **) xmalloc(nshape*sizeof(int *));
    102         pptype=(int **) xmalloc(nshape*sizeof(int *));
    103         pnvert=(int *) xmalloc(nshape*sizeof(int));
    104         pshapx=(double **) xmalloc(nshape*sizeof(double *));
    105         pshapy=(double **) xmalloc(nshape*sizeof(double *));
    106         pshapz=(double **) xmalloc(nshape*sizeof(double *));
    107         pshapm=(double **) xmalloc(nshape*sizeof(double *));
     98        pstype=xNew<int>(nshape);
     99        pnpart=xNew<int>(nshape);
     100        ppstrt=xNew<int*>(nshape);
     101        pptype=xNew<int*>(nshape);
     102        pnvert=xNew<int>(nshape);
     103        pshapx=xNew<double*>(nshape);
     104        pshapy=xNew<double*>(nshape);
     105        pshapz=xNew<double*>(nshape);
     106        pshapm=xNew<double*>(nshape);
    108107
    109108/*  loop over the list of shapes  */
     
    129128        pnpart[i]=psShape->nParts;
    130129        if (pnpart[i]) {
    131                 ppstrt[i]=(int *) xmalloc(pnpart[i]*sizeof(int));
    132                 pptype[i]=(int *) xmalloc(pnpart[i]*sizeof(int));
     130                ppstrt[i]=xNew<int>(pnpart[i]);
     131                pptype[i]=xNew<int>(pnpart[i]);
    133132        }
    134133        else {
     
    138137        pnvert[i]=psShape->nVertices;
    139138        if (pnvert[i]) {
    140                 pshapx[i]=(double *) xmalloc(pnvert[i]*sizeof(double));
    141                 pshapy[i]=(double *) xmalloc(pnvert[i]*sizeof(double));
    142                 pshapz[i]=(double *) xmalloc(pnvert[i]*sizeof(double));
    143                 pshapm[i]=(double *) xmalloc(pnvert[i]*sizeof(double));
     139                pshapx[i]=xNew<double>(pnvert[i]);
     140                pshapy[i]=xNew<double>(pnvert[i]);
     141                pshapz[i]=xNew<double>(pnvert[i]);
     142                pshapm[i]=xNew<double>(pnvert[i]);
    144143        }
    145144        else {
     
    296295                        kpoint=new KML_Point();
    297296
    298                         lat=(double *) xmalloc(pnvert[i]*sizeof(double));
    299                         lon=(double *) xmalloc(pnvert[i]*sizeof(double));
     297                        lat=xNew<double>(pnvert[i]);
     298                        lon=xNew<double>(pnvert[i]);
    300299                        if (sgn) {
    301300                                Xy2llx(lat,lon,pshapx[i],pshapy[i],pnvert[i],sgn,cm,sp);
     
    310309                        kpoint->coords[2]=pshapz[i][0];
    311310
    312                         xfree((void**)&lon);
    313                         xfree((void**)&lat);
     311                        xDelete<double>(lon);
     312                        xDelete<double>(lat);
    314313
    315314                        (kplace->geometry  )->AddObject((Object*)kpoint);
     
    337336/*  convert to lat/lon, if necessary  */
    338337
    339                         lat=(double *) xmalloc(pnvert[i]*sizeof(double));
    340                         lon=(double *) xmalloc(pnvert[i]*sizeof(double));
     338                        lat=xNew<double>(pnvert[i]);
     339                        lon=xNew<double>(pnvert[i]);
    341340                        if (sgn) {
    342341                                Xy2llx(lat,lon,pshapx[i],pshapy[i],pnvert[i],sgn,cm,sp);
     
    353352
    354353                                kline->ncoord    =(j<pnpart[i]-1 ? ppstrt[i][j+1]-ppstrt[i][j] : pnvert[i]-ppstrt[i][j]);
    355                                 kline->coords    =(double (*)[3]) xmalloc(kline->ncoord*3*sizeof(double));
     354                                kline->coords    =xNew<double>(kline->ncoord*3);
    356355                                for (k=0; k<kline->ncoord; k++) {
    357                                         kline->coords[k][0]=lon      [ppstrt[i][j]+k];
    358                                         kline->coords[k][1]=lat      [ppstrt[i][j]+k];
    359                                         kline->coords[k][2]=pshapz[i][ppstrt[i][j]+k];
     356                                        kline->coords[3*k+0]=lon      [ppstrt[i][j]+k];
     357                                        kline->coords[3*k+1]=lat      [ppstrt[i][j]+k];
     358                                        kline->coords[3*k+2]=pshapz[i][ppstrt[i][j]+k];
    360359                                }
    361 
    362360                                (kmulti->geometry  )->AddObject((Object*)kline);
    363                                 kline =NULL;
    364                         }
    365 
    366                         xfree((void**)&lon);
    367                         xfree((void**)&lat);
    368 
    369                         (kplace->geometry  )->AddObject((Object*)kmulti);
     361                                kline = NULL;
     362                        }
     363
     364                        xDelete<double>(lon);
     365                        xDelete<double>(lat);
     366
     367                        (kplace->geometry)->AddObject((Object*)kmulti);
    370368                        kmulti=NULL;
    371                         (kfold ->feature   )->AddObject((Object*)kplace);
     369                        (kfold ->feature )->AddObject((Object*)kplace);
    372370                        kplace=NULL;
    373371                }
     
    401399/*  convert to lat/lon, if necessary  */
    402400
    403                         lat=(double *) xmalloc(pnvert[i]*sizeof(double));
    404                         lon=(double *) xmalloc(pnvert[i]*sizeof(double));
     401                        lat=xNew<double>(pnvert[i]);
     402                        lon=xNew<double>(pnvert[i]);
    405403                        if (sgn) {
    406404                                Xy2llx(lat,lon,pshapx[i],pshapy[i],pnvert[i],sgn,cm,sp);
     
    438436
    439437                                        kring->ncoord    =(j<pnpart[i]-1 ? ppstrt[i][j+1]-ppstrt[i][j] : pnvert[i]-ppstrt[i][j]);
    440                                         kring->coords    =(double (*)[3]) xmalloc(kring->ncoord*3*sizeof(double));
     438                                        kring->coords    =xNew<double>(kring->ncoord*3);
    441439                                        if (cpsum < 0)
    442440                                                for (k=0; k<kring->ncoord; k++) {
    443                                                         kring->coords[kring->ncoord-1-k][0]=lon      [ppstrt[i][j]+k];
    444                                                         kring->coords[kring->ncoord-1-k][1]=lat      [ppstrt[i][j]+k];
    445                                                         kring->coords[kring->ncoord-1-k][2]=pshapz[i][ppstrt[i][j]+k];
     441                                                        kring->coords[3*(kring->ncoord-1-k)+0]=lon      [ppstrt[i][j]+k];
     442                                                        kring->coords[3*(kring->ncoord-1-k)+1]=lat      [ppstrt[i][j]+k];
     443                                                        kring->coords[3*(kring->ncoord-1-k)+2]=pshapz[i][ppstrt[i][j]+k];
    446444                                                }
    447445                                        else
    448446                                                for (k=0; k<kring->ncoord; k++) {
    449                                                         kring->coords[k                ][0]=lon      [ppstrt[i][j]+k];
    450                                                         kring->coords[k                ][1]=lat      [ppstrt[i][j]+k];
    451                                                         kring->coords[k                ][2]=pshapz[i][ppstrt[i][j]+k];
     447                                                        kring->coords[3*k+0]=lon      [ppstrt[i][j]+k];
     448                                                        kring->coords[3*k+1]=lat      [ppstrt[i][j]+k];
     449                                                        kring->coords[3*k+2]=pshapz[i][ppstrt[i][j]+k];
    452450                                                }
    453451
     
    470468
    471469                                        kring->ncoord    =(j<pnpart[i]-1 ? ppstrt[i][j+1]-ppstrt[i][j] : pnvert[i]-ppstrt[i][j]);
    472                                         kring->coords    =(double (*)[3]) xmalloc(kring->ncoord*3*sizeof(double));
     470                                        kring->coords    =xNew<double>(kring->ncoord*3);
    473471                                        for (k=0; k<kring->ncoord; k++) {
    474                                                 kring->coords[k][0]=lon      [ppstrt[i][j]+k];
    475                                                 kring->coords[k][1]=lat      [ppstrt[i][j]+k];
    476                                                 kring->coords[k][2]=pshapz[i][ppstrt[i][j]+k];
     472                                                kring->coords[3*k+0]=lon      [ppstrt[i][j]+k];
     473                                                kring->coords[3*k+1]=lat      [ppstrt[i][j]+k];
     474                                                kring->coords[3*k+2]=pshapz[i][ppstrt[i][j]+k];
    477475                                        }
    478476
     
    487485                        }
    488486
    489                         xfree((void**)&lon);
    490                         xfree((void**)&lat);
     487                        xDelete<double>(lon);
     488                        xDelete<double>(lat);
    491489
    492490                        (kplace->geometry  )->AddObject((Object*)kmulti);
     
    518516/*  convert to lat/lon, if necessary  */
    519517
    520                         lat=(double *) xmalloc(pnvert[i]*sizeof(double));
    521                         lon=(double *) xmalloc(pnvert[i]*sizeof(double));
     518                        lat=xNew<double>(pnvert[i]);
     519                        lon=xNew<double>(pnvert[i]);
    522520                        if (sgn) {
    523521                                Xy2llx(lat,lon,pshapx[i],pshapy[i],pnvert[i],sgn,cm,sp);
     
    541539                        }
    542540
    543                         xfree((void**)&lon);
    544                         xfree((void**)&lat);
     541                        xDelete<double>(lon);
     542                        xDelete<double>(lat);
    545543
    546544                        (kplace->geometry  )->AddObject((Object*)kmulti);
     
    575573/*  write kml file  */
    576574
    577         _printf_(true,"Writing kml document to file.\n");
     575        _pprintLine_("Writing kml document to file.");
    578576        fid=fopen(filkml,"w");
    579577        fprintf(fid,"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
     
    583581        delete kfile;
    584582        for (i=nshape-1; i>=0; i--) {
    585                 xfree((void**)&(pshapm[i]));
    586                 xfree((void**)&(pshapz[i]));
    587                 xfree((void**)&(pshapy[i]));
    588                 xfree((void**)&(pshapx[i]));
    589         }
    590         xfree((void**)&pshapm);
    591         xfree((void**)&pshapz);
    592         xfree((void**)&pshapy);
    593         xfree((void**)&pshapx);
    594         xfree((void**)&pnvert);
     583                xDelete<double>((pshapm[i]));
     584                xDelete<double>((pshapz[i]));
     585                xDelete<double>((pshapy[i]));
     586                xDelete<double>((pshapx[i]));
     587        }
     588        xDelete<double*>(pshapm);
     589        xDelete<double*>(pshapz);
     590        xDelete<double*>(pshapy);
     591        xDelete<double*>(pshapx);
     592        xDelete<int>(pnvert);
    595593        for (i=nshape-1; i>=0; i--) {
    596                 xfree((void**)&(pptype[i]));
    597                 xfree((void**)&(ppstrt[i]));
    598         }
    599         xfree((void**)&pptype);
    600         xfree((void**)&ppstrt);
    601         xfree((void**)&pnpart);
    602         xfree((void**)&pstype);
     594                xDelete<int>((pptype[i]));
     595                xDelete<int>((ppstrt[i]));
     596        }
     597        xDelete<int*>(pptype);
     598        xDelete<int*>(ppstrt);
     599        xDelete<int>(pnpart);
     600        xDelete<int>(pstype);
    603601
    604602        clock1=clock();
  • issm/trunk/src/c/modules/Solverx/DofTypesToIndexSet.cpp

    r9826 r12706  
    2020
    2121        int         start,end;
    22         double*     df_local=NULL;
     22        IssmDouble*     df_local=NULL;
    2323        int         df_local_size;
    2424        int         i;
     
    4646
    4747                /*Allocate indices: */
    48                 if(pressure_num)pressure_indices=(int*)xmalloc(pressure_num*sizeof(int));
    49                 if(velocity_num)velocity_indices=(int*)xmalloc(velocity_num*sizeof(int));
     48                if(pressure_num)pressure_indices=xNew<int>(pressure_num);
     49                if(velocity_num)velocity_indices=xNew<int>(velocity_num);
    5050
    5151                pressure_count=0;
     
    7474
    7575        /*Free ressources:*/
    76         xfree((void**)&pressure_indices);
    77         xfree((void**)&velocity_indices);
     76        xDelete<int>(pressure_indices);
     77        xDelete<int>(velocity_indices);
    7878
    7979        /*Assign output pointers:*/
  • issm/trunk/src/c/modules/Solverx/Solverx.cpp

    r12330 r12706  
    5555
    5656                #else
    57                         _error_("GSL support not compiled in!");
     57                        _error2_("GSL support not compiled in!");
    5858                #endif
    5959        #endif
  • issm/trunk/src/c/modules/Solverx/Solverx.h

    r11995 r12706  
    1919#ifdef _HAVE_PETSC_
    2020void    SolverxPetsc(Vec* puf, Mat Kff, Vec pf, Vec uf0,Vec df, Parameters* parameters);
    21 void    DofTypesToIndexSet(IS* pisv, IS* pisp, Vec df,int typeenum);
     21void  DofTypesToIndexSet(IS* pisv, IS* pisp, Vec df,int typeenum);
    2222#endif
    2323
    2424#ifdef _HAVE_GSL_
    25 void    SolverxGsl(SeqVec** puf,SeqMat* Kff, SeqVec* pf);
     25void SolverxGsl(SeqVec** puf,SeqMat* Kff, SeqVec* pf);
     26void SolverxGsl(IssmDouble** pX,IssmDouble* A,IssmDouble* B,int n);
    2627#endif
    2728
  • issm/trunk/src/c/modules/Solverx/SolverxGsl.cpp

    r11995 r12706  
    22 * \brief Gsl implementation of solver
    33 */
     4
     5#ifdef HAVE_CONFIG_H
     6        #include <config.h>
     7#else
     8#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
     9#endif
     10#include <cstring>
     11#include <gsl/gsl_linalg.h>
    412
    513#include "./Solverx.h"
     
    816#include "../../io/io.h"
    917
    10 #ifdef HAVE_CONFIG_H
    11         #include <config.h>
    12 #else
    13 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
    14 #endif
    15  
    16 #include <gsl/gsl_linalg.h>
    17 
    18 void    SolverxGsl(SeqVec** puf,SeqMat* Kff, SeqVec* pf){
    19 
    20         /*intermediary: */
    21         SeqMat* KffCopy=NULL;
    22 
    23         /*Output: */
    24         SeqVec*        uf               = NULL;
    25 
    26        
    27         /*GSL Matrices and vectors: */
    28         gsl_matrix_view m;
    29         gsl_vector_view b;
    30         gsl_vector* x=NULL;
    31         gsl_permutation* p=NULL;
    32        
    33         /*We are going to do an in place LU decomp, so we need to save the matrix with its original structure: */
    34         KffCopy=Kff->Duplicate();
    35 
     18void SolverxGsl(SeqVec** puf,SeqMat* Kff, SeqVec* pf){/*{{{*/
    3619
    3720        /*Intermediary: */
    3821        int M,N,N2,s;
     22        SeqVec *uf = NULL;
     23        IssmDouble *x  = NULL;
    3924
    4025        Kff->GetSize(&M,&N);
    4126        pf->GetSize(&N2);
    4227
    43         if(N!=N2)_error_("Right hand side vector of size %i, when matrix is of size %i-%i !",N2,M,N);
    44         if(M!=N)_error_("Stiffness matrix should be square!");
     28        if(N!=N2)_error2_("Right hand side vector of size " << N2 << ", when matrix is of size " << M << "-" << N << " !");
     29        if(M!=N)_error2_("Stiffness matrix should be square!");
     30
     31        SolverxGsl(&x,Kff->matrix,pf->vector,N);
     32        uf=new SeqVec(x,N);
     33
     34        /*Assign output pointers:*/
     35        *puf=uf;
     36}/*}}}*/
     37void SolverxGsl(IssmDouble** pX,IssmDouble* A,IssmDouble* B,int n){/*{{{*/
     38
     39        /*GSL Matrices and vectors: */
     40        int              s;
     41        gsl_matrix_view  a;
     42        gsl_vector_view  b;
     43        gsl_vector      *x = NULL;
     44        gsl_permutation *p = NULL;
     45#ifdef _HAVE_ADOLC_
     46        // if we use Adol-C then the IssmDouble will be an adouble
     47        // and the calls to gsl_... will not work
     48        // and we should call  a suitable wrapped solve instead
     49        _error2_("SolverxGsl: should not be here with Adol-C");
     50#else
     51        /*A will be modified by LU decomposition. Use copy*/
     52        IssmDouble* Acopy = xNew<IssmDouble>(n*n);
     53        xMemCpy<IssmDouble>(Acopy,A,n*n);
    4554
    4655        /*Initialize gsl matrices and vectors: */
    47         m = gsl_matrix_view_array (KffCopy->matrix, M, N);
    48         b = gsl_vector_view_array (pf->vector, N);
    49         x = gsl_vector_alloc (N);
     56        a = gsl_matrix_view_array (Acopy,n,n);
     57        b = gsl_vector_view_array (B,n);
     58        x = gsl_vector_alloc (n);
    5059
    5160        /*Run LU and solve: */
    52         p = gsl_permutation_alloc (N);
    53         gsl_linalg_LU_decomp (&m.matrix, p, &s);
    54         gsl_linalg_LU_solve (&m.matrix, p, &b.vector, x);
     61        p = gsl_permutation_alloc (n);
     62        gsl_linalg_LU_decomp (&a.matrix, p, &s);
     63        gsl_linalg_LU_solve (&a.matrix, p, &b.vector, x);
    5564
    5665        //printf ("x = \n");
    5766        //gsl_vector_fprintf (stdout, x, "%g");
    5867
    59         /*Get uf initialized with the results: */
    60         uf=new SeqVec(gsl_vector_ptr(x,0),M);
     68        /*Copy result*/
     69        IssmDouble* X = xNew<IssmDouble>(n);
     70        memcpy(X,gsl_vector_ptr(x,0),n*sizeof(IssmDouble));
    6171
    62         /*Free resources:*/
    63         gsl_permutation_free (p);
    64         gsl_vector_free (x);
    65 
    66         delete KffCopy;
    67 
    68 
    69         /*Assign output pointers:*/
    70         *puf=uf;
    71 }
     72        /*Clean up and assign output pointer*/
     73        xDelete<IssmDouble>(Acopy);
     74        gsl_permutation_free(p);
     75        gsl_vector_free(x);
     76        *pX=X;
     77#endif
     78}/*}}}*/
  • issm/trunk/src/c/modules/Solverx/SolverxPetsc.cpp

    r12330 r12706  
    4444
    4545        /*Display message*/
    46         _printf_(VerboseModule(),"   Solving\n");
     46        if(VerboseModule()) _pprintLine_("   Solving");
    4747        #if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
    4848        if(VerboseSolver())PetscOptionsPrint(stdout);
     
    8181                #if _PETSC_MAJOR_ >=3
    8282                        #ifndef _HAVE_MUMPS_
    83                         _error_("requested MUMPS solver, which was not compiled into ISSM!\n");
     83                        _error2_("requested MUMPS solver, which was not compiled into ISSM!\n");
    8484                        #endif
    8585                #endif
     
    105105        if (solver_type==StokesSolverEnum){
    106106                /*Make indices out of doftypes: */
    107                 if(!df)_error_("need doftypes for Stokes solver!\n");
     107                if(!df)_error2_("need doftypes for Stokes solver!\n");
    108108                DofTypesToIndexSet(&isv,&isp,df,StokesSolverEnum);
    109109
     
    136136        /*Check convergence*/
    137137        KSPGetIterationNumber(ksp,&iteration_number);
    138         if (iteration_number<0) _error_("%s%i"," Solver diverged at iteration number: ",-iteration_number);
     138        if (iteration_number<0) _error2_("Solver diverged at iteration number: " << -iteration_number);
    139139
    140140        /*Free resources:*/
  • issm/trunk/src/c/modules/StringToEnumx/StringToEnumx.cpp

    r12347 r12706  
    158158              else if (strcmp(name,"SettingsResultsAsPatches")==0) return SettingsResultsAsPatchesEnum;
    159159              else if (strcmp(name,"SettingsWaitonlock")==0) return SettingsWaitonlockEnum;
    160               else if (strcmp(name,"DebugPetscProfiling")==0) return DebugPetscProfilingEnum;
    161               else if (strcmp(name,"PetscProfilingCurrentMem")==0) return PetscProfilingCurrentMemEnum;
    162               else if (strcmp(name,"PetscProfilingCurrentFlops")==0) return PetscProfilingCurrentFlopsEnum;
    163               else if (strcmp(name,"PetscProfilingSolutionTime")==0) return PetscProfilingSolutionTimeEnum;
     160              else if (strcmp(name,"DebugProfiling")==0) return DebugProfilingEnum;
     161              else if (strcmp(name,"ProfilingCurrentMem")==0) return ProfilingCurrentMemEnum;
     162              else if (strcmp(name,"ProfilingCurrentFlops")==0) return ProfilingCurrentFlopsEnum;
     163              else if (strcmp(name,"ProfilingSolutionTime")==0) return ProfilingSolutionTimeEnum;
    164164              else if (strcmp(name,"MaxIterationConvergenceFlag")==0) return MaxIterationConvergenceFlagEnum;
    165165              else if (strcmp(name,"SteadystateMaxiter")==0) return SteadystateMaxiterEnum;
     
    171171              else if (strcmp(name,"SurfaceforcingsMassBalance")==0) return SurfaceforcingsMassBalanceEnum;
    172172              else if (strcmp(name,"SurfaceforcingsIspdd")==0) return SurfaceforcingsIspddEnum;
     173              else if (strcmp(name,"SurfaceforcingsIssmbgradients")==0) return SurfaceforcingsIssmbgradientsEnum;
    173174              else if (strcmp(name,"SurfaceforcingsMonthlytemperatures")==0) return SurfaceforcingsMonthlytemperaturesEnum;
     175              else if (strcmp(name,"SurfaceforcingsHc")==0) return SurfaceforcingsHcEnum;
     176              else if (strcmp(name,"SurfaceforcingsSmbPosMax")==0) return SurfaceforcingsSmbPosMaxEnum;
     177              else if (strcmp(name,"SurfaceforcingsSmbPosMin")==0) return SurfaceforcingsSmbPosMinEnum;
     178              else if (strcmp(name,"SurfaceforcingsAPos")==0) return SurfaceforcingsAPosEnum;
     179              else if (strcmp(name,"SurfaceforcingsBPos")==0) return SurfaceforcingsBPosEnum;
     180              else if (strcmp(name,"SurfaceforcingsANeg")==0) return SurfaceforcingsANegEnum;
     181              else if (strcmp(name,"SurfaceforcingsBNeg")==0) return SurfaceforcingsBNegEnum;
    174182              else if (strcmp(name,"ThermalMaxiter")==0) return ThermalMaxiterEnum;
    175183              else if (strcmp(name,"ThermalPenaltyFactor")==0) return ThermalPenaltyFactorEnum;
     
    253261              else if (strcmp(name,"DoubleParam")==0) return DoubleParamEnum;
    254262              else if (strcmp(name,"DoubleVecParam")==0) return DoubleVecParamEnum;
    255               else if (strcmp(name,"Element")==0) return ElementEnum;
     263         else stage=3;
     264   }
     265   if(stage==3){
     266              if (strcmp(name,"Element")==0) return ElementEnum;
    256267              else if (strcmp(name,"ElementResult")==0) return ElementResultEnum;
    257268              else if (strcmp(name,"ExternalResult")==0) return ExternalResultEnum;
     
    261272              else if (strcmp(name,"Input")==0) return InputEnum;
    262273              else if (strcmp(name,"IntInput")==0) return IntInputEnum;
    263          else stage=3;
    264    }
    265    if(stage==3){
    266               if (strcmp(name,"IntParam")==0) return IntParamEnum;
     274              else if (strcmp(name,"IntParam")==0) return IntParamEnum;
    267275              else if (strcmp(name,"IntVecParam")==0) return IntVecParamEnum;
    268276              else if (strcmp(name,"MacAyeal2dIceFront")==0) return MacAyeal2dIceFrontEnum;
     
    376384              else if (strcmp(name,"QmuTemperature")==0) return QmuTemperatureEnum;
    377385              else if (strcmp(name,"HydrologyWaterVx")==0) return HydrologyWaterVxEnum;
    378               else if (strcmp(name,"HydrologyWaterVy")==0) return HydrologyWaterVyEnum;
     386         else stage=4;
     387   }
     388   if(stage==4){
     389              if (strcmp(name,"HydrologyWaterVy")==0) return HydrologyWaterVyEnum;
    379390              else if (strcmp(name,"StressTensor")==0) return StressTensorEnum;
    380391              else if (strcmp(name,"StressTensorxx")==0) return StressTensorxxEnum;
     
    384395              else if (strcmp(name,"StressTensoryz")==0) return StressTensoryzEnum;
    385396              else if (strcmp(name,"StressTensorzz")==0) return StressTensorzzEnum;
    386          else stage=4;
    387    }
    388    if(stage==4){
    389               if (strcmp(name,"IceVolume")==0) return IceVolumeEnum;
     397              else if (strcmp(name,"IceVolume")==0) return IceVolumeEnum;
    390398              else if (strcmp(name,"P0")==0) return P0Enum;
    391399              else if (strcmp(name,"P1")==0) return P1Enum;
     
    470478   }
    471479        /*If we reach this point, the string provided has not been found*/
    472    _error_("Enum %s not found",name);
     480        _error2_("Enum " << name << " not found");
    473481}
  • issm/trunk/src/c/modules/SurfaceAreax/SurfaceAreax.cpp

    r12330 r12706  
    1111#include "../InputUpdateFromConstantx/InputUpdateFromConstantx.h"
    1212
    13 void SurfaceAreax( double* pS, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials,Parameters* parameters){
     13void SurfaceAreax( IssmDouble* pS, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials,Parameters* parameters){
    1414       
    1515        /*Intermediary*/
     
    1818
    1919        /*output: */
    20         double S=0;
    21         double S_sum;
     20        IssmDouble S=0;
     21        IssmDouble S_sum;
    2222       
    2323        /*Compute gradients: */
  • issm/trunk/src/c/modules/SurfaceAreax/SurfaceAreax.h

    r4236 r12706  
    1010
    1111/* local prototypes: */
    12 void SurfaceAreax( double* pS, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters);
     12void SurfaceAreax( IssmDouble* pS, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters);
    1313
    1414#endif  /* _SURFACEAREAX_H */
  • issm/trunk/src/c/modules/SystemMatricesx/SystemMatricesx.cpp

    r11995 r12706  
    1010#include "../../EnumDefinitions/EnumDefinitions.h"
    1111
    12 void SystemMatricesx(Matrix** pKff, Matrix** pKfs, Vector** ppf, Vector** pdf, double* pkmax,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,bool kflag,bool pflag,bool penalty_kflag,bool penalty_pflag){
     12void SystemMatricesx(Matrix** pKff, Matrix** pKfs, Vector** ppf, Vector** pdf, IssmDouble* pkmax,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,bool kflag,bool pflag,bool penalty_kflag,bool penalty_pflag){
    1313       
    1414        /*intermediary: */
     
    2525        Vector*    pf   = NULL;
    2626        Vector*    df=NULL;
    27         double kmax = 0;
     27        IssmDouble kmax = 0;
    2828
    2929        /*Display message*/
    30         _printf_(VerboseModule(),"   Generating matrices\n");
     30        if(VerboseModule()) _pprintLine_("   Generating matrices");
    3131
    3232        /*retrive parameters: */
     
    4141        numberofdofspernode=nodes->MaxNumDofs(configuration_type,GsetEnum);
    4242
    43         /*Checks in debugging mode {{{1*/
     43        /*Checks in debugging mode {{{*/
    4444        if(penalty_kflag)_assert_(kflag);
    4545        if(penalty_pflag)_assert_(pflag);
  • issm/trunk/src/c/modules/SystemMatricesx/SystemMatricesx.h

    r11995 r12706  
    1010
    1111/* local prototypes: */
    12 void SystemMatricesx(Matrix** pKff, Matrix** pKfs, Vector** ppf, Vector** pdf, double* pkmax,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,
     12void SystemMatricesx(Matrix** pKff, Matrix** pKfs, Vector** ppf, Vector** pdf, IssmDouble* pkmax,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,
    1313                        bool kflag=true,bool pflag=true,bool penalty_kflag=true,bool penalty_pflag=true);
    1414
  • issm/trunk/src/c/modules/TimeAdaptx/TimeAdaptx.cpp

    r12330 r12706  
    1010#include "../../Container/Container.h"
    1111
    12 void TimeAdaptx(double* pdt, Elements* elements, Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials, Parameters* parameters){
     12void TimeAdaptx(IssmDouble* pdt, Elements* elements, Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials, Parameters* parameters){
    1313
    1414        int      i;
    1515
    1616        /*output: */
    17         double   dt;
     17        IssmDouble   dt;
    1818
    1919        /*intermediary: */
    2020        Element *element     = NULL;
    21         double   min_dt      = 0;
    22         double   node_min_dt = 0;
     21        IssmDouble   min_dt      = 0;
     22        IssmDouble   node_min_dt = 0;
    2323
    2424        /*Go through elements, and figure out the minimum of the time steps for each element (using CFL criterion): */
  • issm/trunk/src/c/modules/TimeAdaptx/TimeAdaptx.h

    r6130 r12706  
    99
    1010/* local prototypes: */
    11 void TimeAdaptx(double* pdt, Elements* elements, Nodes* nodes,Vertices* vertices,Loads* loads, Materials* materials, Parameters* parameters);
     11void TimeAdaptx(IssmDouble* pdt, Elements* elements, Nodes* nodes,Vertices* vertices,Loads* loads, Materials* materials, Parameters* parameters);
    1212
    1313#endif  /* _TIMEADAPTX_H */
  • issm/trunk/src/c/modules/TriMeshx/TriMeshx.cpp

    r12330 r12706  
    5757
    5858        /*fill in the point list: */
    59         in.pointlist = (REAL *) xmalloc(in.numberofpoints * 2 * sizeof(REAL));
     59        in.pointlist = xNew<REAL>(in.numberofpoints*2);
    6060
    6161        counter=0;
     
    7878       
    7979        /*fill in the point attribute list: */
    80         in.pointattributelist = (REAL*)xmalloc(in.numberofpoints*in.numberofpointattributes*sizeof(REAL));
     80        in.pointattributelist = xNew<REAL>(in.numberofpoints*in.numberofpointattributes);
    8181        for (i=0;i<in.numberofpoints;i++) in.pointattributelist[i] = 0.0;
    8282       
    8383        /*fill in the point marker list: */
    84         in.pointmarkerlist = (int *) xmalloc(in.numberofpoints * sizeof(int));
     84        in.pointmarkerlist = xNew<int>(in.numberofpoints);
    8585        for(i=0;i<in.numberofpoints;i++) in.pointmarkerlist[i] = 0;
    8686
     
    9797        }
    9898       
    99         in.segmentlist = (int *) xmalloc(in.numberofsegments * 2 * sizeof(int));
    100         in.segmentmarkerlist = (int *) xcalloc(in.numberofsegments,sizeof(int));
     99        in.segmentlist = xNew<int>(in.numberofsegments*2);
     100        in.segmentmarkerlist = xNewZeroInit<int>(in.numberofsegments);
    101101        counter=0;
    102102        backcounter=0;
     
    135135        in.numberofholes = domain->Size()-1; /*everything is a hole, but for the first profile.*/
    136136        if(in.numberofholes){
    137                 in.holelist = (REAL *) xmalloc(in.numberofholes * 2 * sizeof(REAL));
     137                in.holelist = xNew<REAL>(in.numberofholes*2);
    138138                for (i=0;i<domain->Size()-1;i++){
    139139                        contour=(Contour*)domain->GetObjectByOffset(i+1);
     
    164164
    165165        /*Allocate index, x and y: */
    166         index=(double*)xmalloc(3*out.numberoftriangles*sizeof(double));
    167         x=(double*)xmalloc(out.numberofpoints*sizeof(double));
    168         y=(double*)xmalloc(out.numberofpoints*sizeof(double));
    169         segments=(double*)xmalloc(3*out.numberofsegments*sizeof(double));
    170         segmentmarkerlist=(double*)xmalloc(out.numberofsegments*sizeof(double));
     166        index=xNew<double>(3*out.numberoftriangles);
     167        x=xNew<double>(out.numberofpoints);
     168        y=xNew<double>(out.numberofpoints);
     169        segments=xNew<double>(3*out.numberofsegments);
     170        segmentmarkerlist=xNew<double>(out.numberofsegments);
    171171
    172172        for (i = 0; i< out.numberoftriangles; i++) {
  • issm/trunk/src/c/modules/TriaSearchx/TriaSearchx.cpp

    r8303 r12706  
    1313using namespace std;
    1414
    15 void TriaSearchx(double** ptria,double* index,int nel, double* x, double* y, int nods,double* x0, double* y0,int numberofnodes){
     15void TriaSearchx(double** ptria,int* index,int nel, double* x, double* y, int nods,double* x0, double* y0,int numberofnodes){
    1616
    1717        /*Output*/
     
    1919
    2020        /*allocate: */
    21         tria=(double*)xmalloc(numberofnodes*sizeof(double));
     21        tria=xNew<double>(numberofnodes);
    2222
    2323        /*Intermediary*/
     
    5252        }
    5353
    54 
    5554        /*Assign output pointers:*/
    5655        *ptria=tria;
  • issm/trunk/src/c/modules/TriaSearchx/TriaSearchx.h

    r8303 r12706  
    99
    1010/* local prototypes: */
    11 void TriaSearchx(double** ptria,double* index,int nel, double* x, double* y, int nods,double* x0, double* y0,int numberofnodes);
     11void TriaSearchx(double** ptria,int* index,int nel, double* x, double* y, int nods,double* x0, double* y0,int numberofnodes);
    1212
    1313#endif
  • issm/trunk/src/c/modules/UpdateConstraintsx/UpdateConstraintsx.cpp

    r9761 r12706  
    1414void UpdateConstraintsx(Nodes* nodes,Constraints* constraints,Parameters* parameters){
    1515
    16         double time;
     16        IssmDouble time;
    1717        int    analysis_type;
    1818
     
    2222
    2323        /*start module: */
    24         _printf_(VerboseModule(),"%s%g\n","   Updating constraints for time: ",time);
     24        if(VerboseModule()) _pprintLine_("   Updating constraints for time: " << time);
    2525       
    2626        /*First, update dof constraints in nodes, using constraints: */
  • issm/trunk/src/c/modules/UpdateDynamicConstraintsx/UpdateDynamicConstraintsx.cpp

    r11995 r12706  
    1313       
    1414        int configuration_type;
    15         double* yg_serial=NULL;
     15        IssmDouble* yg_serial=NULL;
    1616
    1717        /*Get current configuration*/
     
    3434
    3535        /*Free ressources:*/
    36         xfree((void**)&yg_serial);
     36        xDelete<IssmDouble>(yg_serial);
    3737}
  • issm/trunk/src/c/modules/UpdateVertexPositionsx/UpdateVertexPositionsx.cpp

    r11995 r12706  
    1515        Vector*     vz        = NULL;
    1616        Vertex *vertex    = NULL;
    17         double *thickness = NULL;
    18         double *bed       = NULL;
     17        IssmDouble *thickness = NULL;
     18        IssmDouble *bed       = NULL;
    1919
    2020        /*get vertex vectors for bed and thickness: */
     
    3838
    3939        /*Free ressources:*/
    40         xfree((void**)&thickness);
    41         xfree((void**)&bed);
     40        xDelete<IssmDouble>(thickness);
     41        xDelete<IssmDouble>(bed);
    4242        xdelete(&vz);
    4343        return 1;
  • issm/trunk/src/c/modules/VecMergex/VecMergex.cpp

    r11995 r12706  
    1515        int i;
    1616        int configuration_type;
    17         double* uf_serial=NULL;
     17        IssmDouble* uf_serial=NULL;
    1818
    1919        /*retrieve parameters: */
     
    4141        }
    4242        /*Free ressources:*/
    43         xfree((void**)&uf_serial);
     43        xDelete<IssmDouble>(uf_serial);
    4444
    4545        /*Assemble vector: */
  • issm/trunk/src/c/modules/Xy2llx/Xy2llx.cpp

    r9761 r12706  
    5353        double  sl,rho,cm,T,chi;
    5454
    55         if((sgn!=1) && (sgn!=-1)) _error_("Sign should be either +1 or -1.\n");
     55        if((sgn!=1) && (sgn!=-1)) _error2_("Sign should be either +1 or -1.\n");
    5656
    5757        delta = central_meridian;
     
    124124                *pdelta= 45;
    125125                *pslat = 70;
    126                 _printf_(flag,"Warning: expecting coordinates in polar stereographic (Std Latitude: 70N Meridian: 45).\n");
     126                if(flag) _pprintLine_("Warning: expecting coordinates in polar stereographic (Std Latitude: 70N Meridian: 45).");
    127127        }
    128128        else if (sgn == -1) {
    129129                *pdelta= 0;
    130130                *pslat = 71;
    131                 _printf_(flag,"Warning: expecting coordinates in polar stereographic (Std Latitude: 71S Meridian: 0).\n");
     131                if(flag) _pprintLine_("Warning: expecting coordinates in polar stereographic (Std Latitude: 71S Meridian: 0).");
    132132        }
    133         else _error_("Sign should be either +1 or -1.\n");
     133        else _error2_("Sign should be either +1 or -1.\n");
    134134
    135135        return;
  • issm/trunk/src/c/modules/modules.h

    r12330 r12706  
    106106#include "./RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.h"
    107107#include "./Scotchx/Scotchx.h"
     108#include "./SmbGradientsx/SmbGradientsx.h"
    108109#include "./Solverx/Solverx.h"
    109110#include "./SpcNodesx/SpcNodesx.h"
  • issm/trunk/src/c/objects/Bamg/AdjacentTriangle.cpp

    r5401 r12706  
    1414
    1515        /*Methods*/
    16         /*FUNCTION AdjacentTriangle::Locked {{{1*/
     16        /*FUNCTION AdjacentTriangle::Locked {{{*/
    1717        int  AdjacentTriangle::Locked() const {
    1818                return t->AdjEdgeIndex[a] & 4;
    1919        }
    2020        /*}}}*/
    21         /*FUNCTION AdjacentTriangle::MarkUnSwap {{{1*/
     21        /*FUNCTION AdjacentTriangle::MarkUnSwap {{{*/
    2222        int  AdjacentTriangle::MarkUnSwap() const {
    2323                return t->AdjEdgeIndex[a] & 8;
    2424        }
    2525        /*}}}*/
    26         /*FUNCTION AdjacentTriangle::GetAllFlag_UnSwap {{{1*/
     26        /*FUNCTION AdjacentTriangle::GetAllFlag_UnSwap {{{*/
    2727        int  AdjacentTriangle::GetAllFlag_UnSwap() const {
    2828                // take all flag except MarkUnSwap
     
    3030        }
    3131        /*}}}*/
    32         /*FUNCTION AdjacentTriangle::SetLock {{{1*/
     32        /*FUNCTION AdjacentTriangle::SetLock {{{*/
    3333        void AdjacentTriangle::SetLock(){
    3434                t->SetLocked(a);
    3535        }
    3636        /*}}}*/
    37         /*FUNCTION AdjacentTriangle::Adj {{{1*/
     37        /*FUNCTION AdjacentTriangle::Adj {{{*/
    3838        AdjacentTriangle AdjacentTriangle::Adj() const {
    3939                return  t->Adj(a);
    4040        }
    4141        /*}}}*/
    42         /*FUNCTION AdjacentTriangle::EdgeVertex {{{1*/
     42        /*FUNCTION AdjacentTriangle::EdgeVertex {{{*/
    4343        BamgVertex* AdjacentTriangle::EdgeVertex(const int & i) const {
    4444                return t->vertices[VerticesOfTriangularEdge[a][i]];
    4545        }
    4646        /*}}}*/
    47         /*FUNCTION AdjacentTriangle::OppositeVertex {{{1*/
     47        /*FUNCTION AdjacentTriangle::OppositeVertex {{{*/
    4848        BamgVertex* AdjacentTriangle::OppositeVertex() const {
    4949                return t->vertices[bamg::OppositeVertex[a]];
    5050        }
    5151        /*}}}*/
    52         /*FUNCTION AdjacentTriangle::det {{{1*/
     52        /*FUNCTION AdjacentTriangle::det {{{*/
    5353        Icoor2 & AdjacentTriangle::det() const {
    5454                return t->det;
    5555        }
    5656        /*}}}*/
    57         /*FUNCTION AdjacentTriangle::swap {{{1*/
     57        /*FUNCTION AdjacentTriangle::swap {{{*/
    5858        int AdjacentTriangle::swap(){
    5959                return  t->swap(a);
    6060        }
    6161        /*}}}*/
    62         /*FUNCTION AdjacentTriangle::SetAdj2 {{{1*/
     62        /*FUNCTION AdjacentTriangle::SetAdj2 {{{*/
    6363        void AdjacentTriangle::SetAdj2(const AdjacentTriangle & ta, int l  ){
    6464                //set Adjacent Triangle of a triangle
  • issm/trunk/src/c/objects/Bamg/BamgGeom.cpp

    r12330 r12706  
    55
    66/*Constructors/Destructors*/
    7 /*FUNCTION BamgGeom::BamgGeom(){{{1*/
     7/*FUNCTION BamgGeom::BamgGeom(){{{*/
    88BamgGeom::BamgGeom(){
    99
     
    1919}
    2020/*}}}*/
    21 /*FUNCTION BamgGeom::~BamgGeom(){{{1*/
     21/*FUNCTION BamgGeom::~BamgGeom(){{{*/
    2222BamgGeom::~BamgGeom(){
    2323
    24         xfree((void**)&this->Vertices);
    25         xfree((void**)&this->Edges);
    26         xfree((void**)&this->TangentAtEdges);
    27         xfree((void**)&this->Corners);
    28         xfree((void**)&this->RequiredVertices);
    29         xfree((void**)&this->RequiredEdges);
    30         xfree((void**)&this->CrackedEdges);
    31         xfree((void**)&this->SubDomains);
     24        xDelete<double>(this->Vertices);
     25        xDelete<double>(this->Edges);
     26        xDelete<double>(this->TangentAtEdges);
     27        xDelete<double>(this->Corners);
     28        xDelete<double>(this->RequiredVertices);
     29        xDelete<double>(this->RequiredEdges);
     30        xDelete<double>(this->CrackedEdges);
     31        xDelete<double>(this->SubDomains);
    3232
    3333}
  • issm/trunk/src/c/objects/Bamg/BamgMesh.cpp

    r12330 r12706  
    55
    66/*Constructors/Destructors*/
    7 /*FUNCTION BamgMesh::BamgMesh(){{{1*/
     7/*FUNCTION BamgMesh::BamgMesh(){{{*/
    88BamgMesh::BamgMesh(){
    99
     
    3030}
    3131/*}}}*/
    32 /*FUNCTION BamgMesh::~BamgMesh(){{{1*/
     32/*FUNCTION BamgMesh::~BamgMesh(){{{*/
    3333BamgMesh::~BamgMesh(){
    3434
    35         xfree((void**)&this->Vertices);
    36         xfree((void**)&this->Edges);
    37         xfree((void**)&this->Triangles);
    38         xfree((void**)&this->Quadrilaterals);
     35        xDelete<double>(this->Vertices);
     36        xDelete<double>(this->Edges);
     37        xDelete<double>(this->Triangles);
     38        xDelete<double>(this->Quadrilaterals);
    3939
    40         xfree((void**)&this->SubDomains);
    41         xfree((void**)&this->SubDomainsFromGeom);
    42         xfree((void**)&this->CrackedVertices);
    43         xfree((void**)&this->CrackedEdges);
     40        xDelete<double>(this->SubDomains);
     41        xDelete<double>(this->SubDomainsFromGeom);
     42        xDelete<double>(this->CrackedVertices);
     43        xDelete<double>(this->CrackedEdges);
    4444
    45         xfree((void**)&this->VerticesOnGeomVertex);
    46         xfree((void**)&this->VerticesOnGeomEdge);
    47         xfree((void**)&this->EdgesOnGeomEdge);
     45        xDelete<double>(this->VerticesOnGeomVertex);
     46        xDelete<double>(this->VerticesOnGeomEdge);
     47        xDelete<double>(this->EdgesOnGeomEdge);
    4848
    49         xfree((void**)&this->IssmEdges);
    50         xfree((void**)&this->IssmSegments);
     49        xDelete<double>(this->IssmEdges);
     50        xDelete<double>(this->IssmSegments);
    5151
    52         xfree((void**)&this->ElementConnectivity);
    53         xfree((void**)&this->NodalConnectivity);
    54         xfree((void**)&this->NodalElementConnectivity);
    55 
    56 
     52        xDelete<double>(this->ElementConnectivity);
     53        xDelete<double>(this->NodalConnectivity);
     54        xDelete<double>(this->NodalElementConnectivity);
    5755}
    5856/*}}}*/
  • issm/trunk/src/c/objects/Bamg/BamgOpts.cpp

    r12330 r12706  
    66
    77/*Constructors/Destructors*/
    8 /*FUNCTION BamgOpts::BamgOpts() {{{1*/
     8/*FUNCTION BamgOpts::BamgOpts() {{{*/
    99BamgOpts::BamgOpts(){
    1010
     
    4141}
    4242/*}}}*/
    43 /*FUNCTION BamgOpts::~BamgOpts() {{{1*/
     43/*FUNCTION BamgOpts::~BamgOpts() {{{*/
    4444BamgOpts::~BamgOpts(){
    4545
    46         xfree((void**)&this->hminVertices);
    47         xfree((void**)&this->hmaxVertices);
    48         xfree((void**)&this->hVertices);
    49         xfree((void**)&this->metric);
    50         xfree((void**)&this->field);
    51         xfree((void**)&this->err);
     46        xDelete<double>(this->hminVertices);
     47        xDelete<double>(this->hmaxVertices);
     48        xDelete<double>(this->hVertices);
     49        xDelete<double>(this->metric);
     50        xDelete<double>(this->field);
     51        xDelete<double>(this->err);
    5252
    5353}
     
    5555
    5656/*Methods*/
    57 /*FUNCTION BamgOpts::Check{{{1*/
     57/*FUNCTION BamgOpts::Check{{{*/
    5858void BamgOpts::Check(void){
    5959
    6060        int i;
    6161
    62         if (this->anisomax<1) _error_("'anisomax' option should be >=1");
    63         if (this->coeff==0) _error_("'coeff' should be positive");
    64         if (this->errg<0) _error_("'errg' option should be >0");
    65         if (this->gradation<1) _error_("'gradation' option should be >=1");
    66         if (this->Hessiantype!=0  && this->Hessiantype!=1) _error_("'Hessiantype' supported options are 0 and 1");
    67         if (this->maxnbv<3) _error_("'maxnbv' option should be >3");
    68         if (this->maxsubdiv<=1) _error_("'maxsubdiv' should be >1");
    69         if (this->Metrictype!=0   && this->Metrictype!=1 && this->Metrictype!=2) _error_("'Metrictype' supported options are 0, 1 and 2");
    70         if (this->nbjacobi<=0) _error_("'nbjacobi' option should be >0");
    71         if (this->nbsmooth<=0) _error_("'nbsmooth' option should be >0");
     62        if (this->anisomax<1) _error2_("'anisomax' option should be >=1");
     63        if (this->coeff==0) _error2_("'coeff' should be positive");
     64        if (this->errg<0) _error2_("'errg' option should be >0");
     65        if (this->gradation<1) _error2_("'gradation' option should be >=1");
     66        if (this->Hessiantype!=0  && this->Hessiantype!=1) _error2_("'Hessiantype' supported options are 0 and 1");
     67        if (this->maxnbv<3) _error2_("'maxnbv' option should be >3");
     68        if (this->maxsubdiv<=1) _error2_("'maxsubdiv' should be >1");
     69        if (this->Metrictype!=0   && this->Metrictype!=1 && this->Metrictype!=2) _error2_("'Metrictype' supported options are 0, 1 and 2");
     70        if (this->nbjacobi<=0) _error2_("'nbjacobi' option should be >0");
     71        if (this->nbsmooth<=0) _error2_("'nbsmooth' option should be >0");
    7272
    73         if (this->Crack!=0  && this->Crack!=1) _error_("'Crack' supported options are 0 and 1");
    74         if (this->KeepVertices!=0 && this->KeepVertices!=1) _error_("'KeepVertices' supported options are 0 and 1");
    75         if (this->geometricalmetric!=0  && this->geometricalmetric!=1) _error_("'geometricalmetric' supported options are 0 and 1");
     73        if (this->Crack!=0  && this->Crack!=1) _error2_("'Crack' supported options are 0 and 1");
     74        if (this->KeepVertices!=0 && this->KeepVertices!=1) _error2_("'KeepVertices' supported options are 0 and 1");
     75        if (this->geometricalmetric!=0  && this->geometricalmetric!=1) _error2_("'geometricalmetric' supported options are 0 and 1");
    7676
    77         if (this->hmin<=0) _error_("'hmin' option should be >0");
    78         if (this->hmax<=0 || this->hmax<this->hmin) _error_("'hmax' option should be between 0 and hmin=%g",this->hmin);
    79         if (this->hminVertices && this->hminVerticesSize[1]!=1) _error_("'hminVertices' should be a column");
    80         if (this->hmaxVertices && this->hmaxVerticesSize[1]!=1) _error_("'hmaxVertices' should be a column");
    81         if (this->hVertices && this->hVerticesSize[1]!=1) _error_("'hVertices' should be a column");
    82         if (this->metric && (this->metricSize[1]!=1 && this->metricSize[1]!=3)) _error_("'metric' should have either 1 (iso) or 3 (aniso) columns.");
     77        if (this->hmin<=0) _error2_("'hmin' option should be >0");
     78        if (this->hmax<=0 || this->hmax<this->hmin) _error2_("'hmax' option should be between 0 and hmin=" << this->hmin);
     79        if (this->hminVertices && this->hminVerticesSize[1]!=1) _error2_("'hminVertices' should be a column");
     80        if (this->hmaxVertices && this->hmaxVerticesSize[1]!=1) _error2_("'hmaxVertices' should be a column");
     81        if (this->hVertices && this->hVerticesSize[1]!=1) _error2_("'hVertices' should be a column");
     82        if (this->metric && (this->metricSize[1]!=1 && this->metricSize[1]!=3)) _error2_("'metric' should have either 1 (iso) or 3 (aniso) columns.");
    8383        if (this->field){
    84                 if (this->errSize[0]!=1 || this->errSize[1]!=this->fieldSize[1]) _error_("'err' should be of size %i x %i",1,this->fieldSize[1]);
    85                 for (i=0;i<this->fieldSize[1];i++) {if (this->err[i]<=0) _error_("'err' option should be >0");};
     84                if (this->errSize[0]!=1 || this->errSize[1]!=this->fieldSize[1]) _error2_("'err' should be of size " << 1 << " x " << this->fieldSize[1]);
     85                for (i=0;i<this->fieldSize[1];i++) {if (this->err[i]<=0) _error2_("'err' option should be >0");};
    8686        }
    8787
  • issm/trunk/src/c/objects/Bamg/BamgQuadtree.cpp

    r12330 r12706  
    77namespace bamg {
    88
    9         /*MACROS {{{1*/
     9        /*MACROS {{{*/
    1010        /*
    1111         *
     
    4848#define J_IJ(k,l)  ((k&2) ? l:0)
    4949        /*}}}*/
    50         /*DOCUMENTATION What is a BamgQuadtree? {{{1
     50        /*DOCUMENTATION What is a BamgQuadtree? {{{
    5151         * A Quadtree is a very simple way to group vertices according
    5252         * to their locations. A square that holds all the points of the mesh
     
    9494         * Using binaries is therefore very easy to locate a vertex in a box:
    9595         * we just need to look at the bits from the left to the right (See ::Add)
    96          }}}1*/
     96         }}}*/
    9797
    9898        /*Constructors/Destructors*/
    99         /*FUNCTION BamgQuadtree::BamgQuadtree(){{{1*/
     99        /*FUNCTION BamgQuadtree::BamgQuadtree(){{{*/
    100100        BamgQuadtree::BamgQuadtree(){
    101101
     
    111111
    112112                }
    113         /*}}}1*/
    114         /*FUNCTION BamgQuadtree::BamgQuadtree(Mesh * t,long nbv){{{1*/
     113        /*}}}*/
     114        /*FUNCTION BamgQuadtree::BamgQuadtree(Mesh * t,long nbv){{{*/
    115115        BamgQuadtree::BamgQuadtree(Mesh * t,long nbv){
    116116
     
    133133
    134134        }
    135         /*}}}1*/
    136         /*FUNCTION BamgQuadtree::~BamgQuadtree(){{{1*/
     135        /*}}}*/
     136        /*FUNCTION BamgQuadtree::~BamgQuadtree(){{{*/
    137137        BamgQuadtree::~BamgQuadtree() {
    138138                delete boxcontainer;
    139139                root=NULL;
    140140        }
    141         /*}}}1*/
     141        /*}}}*/
    142142
    143143        /*Methods*/
    144         /*FUNCTION BamgQuadtree::Add{{{1*/
     144        /*FUNCTION BamgQuadtree::Add{{{*/
    145145        void  BamgQuadtree::Add(BamgVertex &w){
    146146                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, BamgQuadtree.cpp/Add)*/
     
    230230                NbVertices++;
    231231        }
    232         /*}}}1*/
    233         /*FUNCTION BamgQuadtree::NearestVertex{{{1*/
     232        /*}}}*/
     233        /*FUNCTION BamgQuadtree::NearestVertex{{{*/
    234234        BamgVertex*  BamgQuadtree::NearestVertex(Icoor1 i,Icoor1 j) {
    235235                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, BamgQuadtree.cpp/NearestVertex)*/
     
    389389
    390390        }
    391         /*}}}1*/
    392         /*FUNCTION BamgQuadtree::NearestVertexWithNormal{{{1*/
     391        /*}}}*/
     392        /*FUNCTION BamgQuadtree::NearestVertexWithNormal{{{*/
    393393        BamgVertex*  BamgQuadtree::NearestVertexWithNormal(Icoor1 i,Icoor1 j) {
    394394                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, BamgQuadtree.cpp/NearestVertexWithNormal)*/
     
    497497                return vn;
    498498        }
    499         /*}}}1*/
    500         /*FUNCTION BamgQuadtree::NewBamgQuadtreeBox {{{1*/
     499        /*}}}*/
     500        /*FUNCTION BamgQuadtree::NewBamgQuadtreeBox {{{*/
    501501        BamgQuadtree::BamgQuadtreeBox* BamgQuadtree::NewBamgQuadtreeBox(void){
    502502
     
    521521                return newbox;
    522522        }/*}}}*/
    523         /*FUNCTION BamgQuadtree::ToClose {{{1*/
     523        /*FUNCTION BamgQuadtree::ToClose {{{*/
    524524        BamgVertex*   BamgQuadtree::ToClose(BamgVertex & v,double seuil,Icoor1 hx,Icoor1 hy){
    525525                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, BamgQuadtree.cpp/ToClose)*/
     
    595595                return 0;
    596596        }
    597         /*}}}1*/
     597        /*}}}*/
    598598}
  • issm/trunk/src/c/objects/Bamg/BamgQuadtree.h

    r12330 r12706  
    2929                                        };
    3030                                        /*Object functions*/
    31                                         void    Echo()       {_error_("not implemented yet"); };
    32                                         void    DeepEcho()   {_error_("not implemented yet"); };
    33                                         int     Id()         {_error_("not implemented yet"); };
    34                                         int     MyRank()     {_error_("not implemented yet"); };
    35                                         int     ObjectEnum() {_error_("not implemented yet"); };
    36                                         Object *copy()       {_error_("not implemented yet"); };
     31                                        void    Echo()       {_error2_("not implemented yet"); };
     32                                        void    DeepEcho()   {_error2_("not implemented yet"); };
     33                                        int     Id()         {_error2_("not implemented yet"); };
     34                                        int     MyRank()     {_error2_("not implemented yet"); };
     35                                        int     ObjectEnum() {_error2_("not implemented yet"); };
     36                                        Object *copy()       {_error2_("not implemented yet"); };
    3737                        };
    3838
  • issm/trunk/src/c/objects/Bamg/BamgVertex.cpp

    r6412 r12706  
    99
    1010        /*Methods*/
    11         /*FUNCTION BamgVertex::Echo {{{1*/
     11        /*FUNCTION BamgVertex::Echo {{{*/
    1212
    1313        void BamgVertex::Echo(void){
    1414
    15                 printf("Vertex:\n");
    16                 printf("  integer   coordinates i.x: %i, i.y: %i\n",i.x,i.y);
    17                 printf("  Euclidean coordinates r.x: %g, r.y: %g\n",r.x,r.y);
    18                 printf("  ReferenceNumber = %i\n",ReferenceNumber);
     15                _printLine_("Vertex:");
     16                _printLine_("  integer   coordinates i.x: " << i.x << ", i.y: " << i.y);
     17                _printLine_("  Euclidean coordinates r.x: " << r.x << ", r.y: " << r.y);
     18                _printLine_("  ReferenceNumber = " << ReferenceNumber);
    1919                m.Echo();
    2020
     
    2222        }
    2323        /*}}}*/
    24         /*FUNCTION BamgVertex::GetReferenceNumber{{{1*/
     24        /*FUNCTION BamgVertex::GetReferenceNumber{{{*/
    2525        int  BamgVertex::GetReferenceNumber() const {
    2626                return ReferenceNumber;
    2727        }
    2828        /*}}}*/
    29         /*FUNCTION BamgVertex::MetricFromHessian{{{1*/
     29        /*FUNCTION BamgVertex::MetricFromHessian{{{*/
    3030        void BamgVertex::MetricFromHessian(const double Hxx,const double Hyx, const double Hyy,const double smin,const double smax,const double s,double err,BamgOpts* bamgopts){
    3131                /*Compute Metric from Hessian*/
     
    7676                }
    7777                else{
    78                         _error_("Metrictype %i not supported yet (use 0,1 or 2(default))",Metrictype);
     78                        _error2_("Metrictype " << Metrictype << " not supported yet (use 0,1 or 2(default))");
    7979                }
    8080
     
    105105
    106106        }
    107         /*}}}1*/
    108         /*FUNCTION BamgVertex::Optim {{{1*/
     107        /*}}}*/
     108        /*FUNCTION BamgVertex::Optim {{{*/
    109109        long BamgVertex::Optim(int i,int koption){
    110110                long ret=0;
     
    119119        }
    120120        /*}}}*/
    121         /*FUNCTION BamgVertex::Smoothing{{{1*/
     121        /*FUNCTION BamgVertex::Smoothing{{{*/
    122122        double  BamgVertex::Smoothing(Mesh &Th,const Mesh &BTh,Triangle* &tstart ,double omega){
    123123                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/Smoothing)*/
     
    146146                        j = NextEdge[jc];
    147147                        if (k>=2000){
    148                                 _error_("k>=2000 (Maximum number of iterations reached)");
     148                                _error2_("k>=2000 (Maximum number of iterations reached)");
    149149                        }
    150150                } while ( tbegin != tria);
     
    213213                                j = NextEdge[jc];
    214214                                if (k>=2000){
    215                                         _error_("k>=2000");
     215                                        _error2_("k>=2000");
    216216                                }
    217217                        }while ( tbegin != tria);
     
    222222                return delta;
    223223        }
    224         /*}}}1*/
     224        /*}}}*/
    225225
    226226        /*Intermediary*/
    227         /*FUNCTION QuadQuality{{{1*/
     227        /*FUNCTION QuadQuality{{{*/
    228228        double QuadQuality(const BamgVertex & a,const BamgVertex &b,const BamgVertex &c,const BamgVertex &d) {
    229229                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshQuad.cpp/QuadQuality)*/
     
    252252                return 1.0-Max(Max(Abs(cosDAB),Abs(cosABC)),Max(Abs(cosBCD),Abs(cosCDA)));
    253253        }
    254         /*}}}1*/
     254        /*}}}*/
    255255
    256256}
  • issm/trunk/src/c/objects/Bamg/CrackedEdge.cpp

    r3913 r12706  
    99
    1010        /*Constructors/Destructors*/
    11         /*FUNCTION CrackedEdge() {{{1*/
     11        /*FUNCTION CrackedEdge() {{{*/
    1212        CrackedEdge::CrackedEdge() {
    1313                a=NULL;
  • issm/trunk/src/c/objects/Bamg/Curve.cpp

    r5401 r12706  
    1010
    1111        /*Constructors/Destructors*/
    12         /*FUNCTION Curve::Curve(){{{1*/
     12        /*FUNCTION Curve::Curve(){{{*/
    1313        Curve::Curve(){
    1414                FirstEdge=NULL;
     
    2020
    2121        /*Methods*/
    22         /*FUNCTION Curve::Reverse {{{1*/
     22        /*FUNCTION Curve::Reverse {{{*/
    2323        void Curve::Reverse() {
    2424                /*reverse the direction of the curve */
     
    2727        }
    2828        /*}}}*/
    29         /*FUNCTION Curve::Set {{{1*/
     29        /*FUNCTION Curve::Set {{{*/
    3030        void Curve::Set(const Curve & rec,const Geometry & Gh ,Geometry & GhNew){
    3131                *this = rec;
  • issm/trunk/src/c/objects/Bamg/Direction.cpp

    r5148 r12706  
    99
    1010        /*Constructors/Destructors*/
    11         /*FUNCTION Direction() {{{1*/
     11        /*FUNCTION Direction() {{{*/
    1212        Direction::Direction():
    1313                dir(MaxICoor){
    1414
    1515        }/*}}}*/
    16         /*FUNCTION Direction(Icoor1 i,Icoor1 j) {{{1*/
     16        /*FUNCTION Direction(Icoor1 i,Icoor1 j) {{{*/
    1717        Direction::Direction(Icoor1 i,Icoor1 j) {
    1818                Icoor2 n2 = 2*(Abs(i)+Abs(j)); 
     
    2323
    2424        /*Methods*/
    25         /*FUNCTION Direction::direction{{{1*/
     25        /*FUNCTION Direction::direction{{{*/
    2626        int Direction::direction(Icoor1 i,Icoor1 j) {
    2727                int r =1;
  • issm/trunk/src/c/objects/Bamg/Edge.cpp

    r6412 r12706  
    1313
    1414        /*Methods*/
    15         /*FUNCTION Edge::Set {{{1*/
     15        /*FUNCTION Edge::Set {{{*/
    1616        void Edge::Set(const Mesh & Th ,long i,Mesh & ThNew){
    1717                *this = Th.edges[i];
     
    2424        }
    2525        /*}}}*/
    26         /*FUNCTION Edge::Echo {{{1*/
     26        /*FUNCTION Edge::Echo {{{*/
    2727        void Edge::Echo(void){
    28                 printf("Edge:\n");
    29                 printf("   pointers towards two vertices: %p %p\n",v[0],v[1]);
    30                 printf("   ReferenceNumber = %i\n",ReferenceNumber);
    31                 printf("   GeomEdgeHook = %p\n",GeomEdgeHook);
    32                 printf("   two adjacent edges on the same curve: %p %p\n",adj[0],adj[1]);
     28                _printLine_("Edge:");
     29                _printLine_("   pointers towards two vertices: " << v[0] << " " << v[1]);
     30                _printLine_("   ReferenceNumber = " << ReferenceNumber);
     31                _printLine_("   GeomEdgeHook = " << GeomEdgeHook);
     32                _printLine_("   two adjacent edges on the same curve: " << adj[0] << " " << adj[1]);
    3333        }
    3434        /*}}}*/
    35         /*FUNCTION Edge::Renumbering{{{1*/
     35        /*FUNCTION Edge::Renumbering{{{*/
    3636        void Edge::Renumbering(BamgVertex *vb,BamgVertex *ve, long *renu){
    3737
     
    4141        }
    4242        /*}}}*/
    43         /*FUNCTION Edge::Intersection{{{1*/
     43        /*FUNCTION Edge::Intersection{{{*/
    4444        int Edge::Intersection(const  Edge & e){
    4545
    4646                /*some shecks*/
    47                 if (!(adj[0]==&e || adj[1]==&e)){ _error_("Intersection bug"); }
     47                if (!(adj[0]==&e || adj[1]==&e)){ _error2_("Intersection bug"); }
    4848                _assert_(adj[0]==&e || adj[1]==&e);
    4949
  • issm/trunk/src/c/objects/Bamg/EigenMetric.cpp

    r9371 r12706  
    99
    1010        /*Constructor*/
    11         /*FUNCTION EigenMetric::EigenMetric(const Metric M){{{1*/
     11        /*FUNCTION EigenMetric::EigenMetric(const Metric M){{{*/
    1212        EigenMetric::EigenMetric(const Metric& M){
    1313                /*From a metric (a11,a21,a22), get eigen values lambda1 and lambda2 and one eigen vector v*/
     
    8888
    8989        }
    90         /*}}}1*/
    91         /*FUNCTION EigenMetric::EigenMetric(double r1,double r2,const D2 vp1){{{1*/
     90        /*}}}*/
     91        /*FUNCTION EigenMetric::EigenMetric(double r1,double r2,const D2 vp1){{{*/
    9292        EigenMetric::EigenMetric(double r1,double r2,const D2& vp1): lambda1(r1),lambda2(r2),v(vp1){
    9393
     
    9595
    9696        /*Methods*/
    97         /*FUNCTION EigenMetric::Abs{{{1*/
     97        /*FUNCTION EigenMetric::Abs{{{*/
    9898        void   EigenMetric::Abs(){
    9999                lambda1=bamg::Abs(lambda1),lambda2=bamg::Abs(lambda2);
    100100        }/*}}}*/
    101         /*FUNCTION EigenMetric::Aniso{{{1*/
     101        /*FUNCTION EigenMetric::Aniso{{{*/
    102102        double EigenMetric::Aniso() const  {
    103103                return sqrt( Aniso2());
    104104        }/*}}}*/
    105         /*FUNCTION EigenMetric::Aniso2{{{1*/
     105        /*FUNCTION EigenMetric::Aniso2{{{*/
    106106        double EigenMetric::Aniso2() const  {
    107107                return lmax()/lmin();
    108108        }/*}}}*/
    109         /*FUNCTION EigenMetric::BoundAniso{{{1*/
     109        /*FUNCTION EigenMetric::BoundAniso{{{*/
    110110        void   EigenMetric::BoundAniso(const double c){
    111111                BoundAniso2(1/(c*c));
    112112        }/*}}}*/
    113         /*FUNCTION EigenMetric::Echo {{{1*/
     113        /*FUNCTION EigenMetric::Echo {{{*/
    114114        void EigenMetric::Echo(void){
    115115
    116                 printf("EigenMetric:\n");
    117                 printf("   lambda1: %g\n",lambda1);
    118                 printf("   lambda2: %g\n",lambda2);
    119                 printf("   v.x: %g\n",v.x);
    120                 printf("   v.y: %g\n",v.y);
     116                _printLine_("EigenMetric:");
     117                _printLine_("   lambda1: " << lambda1);
     118                _printLine_("   lambda2: " << lambda2);
     119                _printLine_("   v.x: " << v.x);
     120                _printLine_("   v.y: " << v.y);
    121121
    122122                return;
    123123        }
    124124        /*}}}*/
    125         /*FUNCTION EigenMetric::hmin{{{1*/
     125        /*FUNCTION EigenMetric::hmin{{{*/
    126126        double EigenMetric::hmin() const {
    127127                return sqrt(1/bamg::Max3(lambda1,lambda2,1e-30));
    128128        }/*}}}*/
    129         /*FUNCTION EigenMetric::hmax{{{1*/
     129        /*FUNCTION EigenMetric::hmax{{{*/
    130130        double EigenMetric::hmax() const {
    131131                return sqrt(1/bamg::Max(bamg::Min(lambda1,lambda2),1e-30));
    132132        }/*}}}*/
    133         /*FUNCTION EigenMetric::Isotrope{{{1*/
     133        /*FUNCTION EigenMetric::Isotrope{{{*/
    134134        void   EigenMetric::Isotrope() {
    135135                lambda1=lambda2=bamg::Max(lambda1,lambda2);
    136136        }/*}}}*/
    137         /*FUNCTION EigenMetric::lmax{{{1*/
     137        /*FUNCTION EigenMetric::lmax{{{*/
    138138        double EigenMetric::lmax() const {
    139139                return bamg::Max3(lambda1,lambda2,1e-30);
    140140        }/*}}}*/
    141         /*FUNCTION EigenMetric::lmin{{{1*/
     141        /*FUNCTION EigenMetric::lmin{{{*/
    142142        double EigenMetric::lmin() const {
    143143                return bamg::Max(bamg::Min(lambda1,lambda2),1e-30);
    144144        }/*}}}*/
    145         /*FUNCTION EigenMetric::Min{{{1*/
     145        /*FUNCTION EigenMetric::Min{{{*/
    146146        void   EigenMetric::Min(double a) {
    147147                lambda1=bamg::Min(a,lambda1); lambda2=bamg::Min(a,lambda2) ;
    148148        }/*}}}*/
    149         /*FUNCTION EigenMetric::Max{{{1*/
     149        /*FUNCTION EigenMetric::Max{{{*/
    150150        void   EigenMetric::Max(double a) {
    151151                //change eigen values
    152152                lambda1=bamg::Max(a,lambda1); lambda2=bamg::Max(a,lambda2) ;
    153153        }/*}}}*/
    154         /*FUNCTION EigenMetric::Minh{{{1*/
     154        /*FUNCTION EigenMetric::Minh{{{*/
    155155        void   EigenMetric::Minh(double h) {
    156156                Min(1.0/(h*h));
    157157        }/*}}}*/
    158         /*FUNCTION EigenMetric::Maxh{{{1*/
     158        /*FUNCTION EigenMetric::Maxh{{{*/
    159159        void   EigenMetric::Maxh(double h) {
    160160                //Call Max function
    161161                Max(1.0/(h*h));
    162162        }/*}}}*/
    163         /*FUNCTION EigenMetric::pow{{{1*/
     163        /*FUNCTION EigenMetric::pow{{{*/
    164164        void   EigenMetric::pow(double p){
    165165                lambda1=::pow(lambda1,p);lambda2=::pow(lambda2,p);
  • issm/trunk/src/c/objects/Bamg/GeomEdge.cpp

    r6412 r12706  
    1616
    1717        /*Methods*/
    18         /*FUNCTION GeomEdge::Cracked{{{1*/
     18        /*FUNCTION GeomEdge::Cracked{{{*/
    1919        int    GeomEdge::Cracked() const  {
    2020                return type &1; 
    2121        }/*}}}*/
    22         /*FUNCTION GeomEdge::F{{{1*/
     22        /*FUNCTION GeomEdge::F{{{*/
    2323        R2 GeomEdge::F(double theta) const{
    2424                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshGeom.cpp/F)*/
     
    6262                return A*ca + B*cb + tg[0]*cta + tg[1]*ctb;
    6363          }
    64         /*}}}1*/
    65         /*FUNCTION GeomEdge::Mark{{{1*/
     64        /*}}}*/
     65        /*FUNCTION GeomEdge::Mark{{{*/
    6666        int    GeomEdge::Mark()    const  {
    6767                return type &16;
    6868        }/*}}}*/
    69         /*FUNCTION GeomEdge::R1tg{{{1*/
     69        /*FUNCTION GeomEdge::R1tg{{{*/
    7070        double GeomEdge::R1tg(double theta,R2 & t) const{
    7171                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshGeom.cpp/R1tg)*/
     
    138138                else return 0;
    139139        }
    140         /*}}}1*/
    141         /*FUNCTION GeomEdge::Required{{{1*/
     140        /*}}}*/
     141        /*FUNCTION GeomEdge::Required{{{*/
    142142        int    GeomEdge::Required()       {
    143143                return type &64;
    144144        }/*}}}*/
    145         /*FUNCTION GeomEdge::Set {{{1*/
     145        /*FUNCTION GeomEdge::Set {{{*/
    146146        void GeomEdge::Set(const GeomEdge & rec,const Geometry & Gh ,Geometry & GhNew){
    147147                *this = rec;
     
    152152        }
    153153        /*}}}*/
    154         /*FUNCTION GeomEdge::SetCracked{{{1*/
     154        /*FUNCTION GeomEdge::SetCracked{{{*/
    155155        void   GeomEdge::SetCracked()     {
    156156                type |= 1;/*=>1st digit to 1*/
    157157        }/*}}}*/
    158         /*FUNCTION GeomEdge::SetTgA{{{1*/
     158        /*FUNCTION GeomEdge::SetTgA{{{*/
    159159        void   GeomEdge::SetTgA()         {
    160160                type |=4; /*=>2d digit to 1*/
    161161        }/*}}}*/
    162         /*FUNCTION GeomEdge::SetTgB{{{1*/
     162        /*FUNCTION GeomEdge::SetTgB{{{*/
    163163        void   GeomEdge::SetTgB()         {
    164164                type |=8; /*=> 3d digit to 1*/
    165165        }/*}}}*/
    166         /*FUNCTION GeomEdge::SetMark{{{1*/
     166        /*FUNCTION GeomEdge::SetMark{{{*/
    167167        void   GeomEdge::SetMark()        {
    168168                type |=16;/*=> 4th digiy to 1*/
    169169        }/*}}}*/
    170         /*FUNCTION GeomEdge::SetUnMark{{{1*/
     170        /*FUNCTION GeomEdge::SetUnMark{{{*/
    171171        void   GeomEdge::SetUnMark()      {
    172172                type &= 1007 /* 1023-16 = 000111110111 => 4th digit to 0*/;
    173173        }/*}}}*/
    174         /*FUNCTION GeomEdge::SetRequired{{{1*/
     174        /*FUNCTION GeomEdge::SetRequired{{{*/
    175175        void   GeomEdge::SetRequired()    {
    176176                type |= 64;/*=>6th digit to 1*/
    177177        }/*}}}*/
    178           /*FUNCTION GeomEdge::Tg{{{1*/
     178          /*FUNCTION GeomEdge::Tg{{{*/
    179179        int    GeomEdge::Tg(int i) const  {
    180180                return i==0 ? TgA() : TgB();
    181181        }/*}}}*/
    182         /*FUNCTION GeomEdge::TgA{{{1*/
     182        /*FUNCTION GeomEdge::TgA{{{*/
    183183        int    GeomEdge::TgA()     const  {
    184184                return type &4; 
    185185        }/*}}}*/
    186         /*FUNCTION GeomEdge::TgB{{{1*/
     186        /*FUNCTION GeomEdge::TgB{{{*/
    187187        int    GeomEdge::TgB()     const  {
    188188                return type &8; 
  • issm/trunk/src/c/objects/Bamg/GeomSubDomain.cpp

    r5573 r12706  
    1212
    1313        /*Methods*/
    14         /*FUNCTION GeomSubDomain::Set {{{1*/
     14        /*FUNCTION GeomSubDomain::Set {{{*/
    1515        void GeomSubDomain::Set(const GeomSubDomain & rec,const Geometry & Gh ,const Geometry & GhNew){
    1616                *this = rec;
  • issm/trunk/src/c/objects/Bamg/GeomVertex.cpp

    r5573 r12706  
    1414
    1515        /*Methods*/
    16         /*FUNCTION GeomVertex::Corner {{{1*/
     16        /*FUNCTION GeomVertex::Corner {{{*/
    1717        int  GeomVertex::Corner() const {
    1818                return type & 4;
    1919        }
    2020        /*}}}*/
    21         /*FUNCTION GeomVertex::Required {{{1*/
     21        /*FUNCTION GeomVertex::Required {{{*/
    2222        int  GeomVertex::Required()const {
    2323                // a corner is required
     
    2525        }
    2626        /*}}}*/
    27         /*FUNCTION GeomVertex::SetCorner {{{1*/
     27        /*FUNCTION GeomVertex::SetCorner {{{*/
    2828        void GeomVertex::SetCorner(){
    2929                type |= 4;
    3030        }
    3131        /*}}}*/
    32         /*FUNCTION GeomVertex::SetRequired {{{1*/
     32        /*FUNCTION GeomVertex::SetRequired {{{*/
    3333        void GeomVertex::SetRequired(){
    3434                type |= 2;
  • issm/trunk/src/c/objects/Bamg/Geometry.cpp

    r12330 r12706  
    1313
    1414        /*Constructors/Destructors*/
    15         /*FUNCTION Geometry::Geometry(){{{1*/
     15        /*FUNCTION Geometry::Geometry(){{{*/
    1616        Geometry::Geometry(){
    1717                Init();
    1818        }
    1919        /*}}}*/
    20         /*FUNCTION Geometry::Geometry(BamgGeom* bamggeom, BamgOpts* bamgopts){{{1*/
     20        /*FUNCTION Geometry::Geometry(BamgGeom* bamggeom, BamgOpts* bamgopts){{{*/
    2121        Geometry::Geometry(BamgGeom* bamggeom, BamgOpts* bamgopts){
    2222                Init();
     
    2525        }
    2626        /*}}}*/
    27         /*FUNCTION Geometry::Geometry(const Geometry & Gh) (COPY operator){{{1*/
     27        /*FUNCTION Geometry::Geometry(const Geometry & Gh) (COPY operator){{{*/
    2828        Geometry::Geometry(const Geometry & Gh) {
    2929                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshGeom.cpp/Geometry)*/
     
    4444                 subdomains[i].Set(Gh.subdomains[i],Gh,*this);
    4545        }
    46         /*}}}1*/
    47         /*FUNCTION Geometry::~Geometry(){{{1*/
     46        /*}}}*/
     47        /*FUNCTION Geometry::~Geometry(){{{*/
    4848        Geometry::~Geometry() {
    4949                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshGeom.cpp/~Geometry)*/
    50                 if(NbRef>0){   printf("Trying to delete geometry and NbRef>0, probably due to an error"); return;}
     50                if(NbRef>0){   _printString_("Trying to delete geometry and NbRef>0, probably due to an error"); return;}
    5151                if(vertices)   delete [] vertices;  vertices=0;
    5252                if(edges)      delete [] edges;     edges=0;
     
    5656                Init();
    5757        }
    58         /*}}}1*/
     58        /*}}}*/
    5959
    6060        /*IO*/
    61         /*FUNCTION Geometry::ReadGeometry{{{1*/
     61        /*FUNCTION Geometry::ReadGeometry{{{*/
    6262        void Geometry::ReadGeometry(BamgGeom* bamggeom,BamgOpts* bamgopts){
    6363
     
    7676
    7777                //some checks
    78                 if (bamggeom->Vertices==NULL) _error_("the domain provided does not contain any vertex");
    79                 if (bamggeom->Edges==NULL) _error_("the domain provided does not contain any edge");
     78                if (bamggeom->Vertices==NULL) _error2_("the domain provided does not contain any vertex");
     79                if (bamggeom->Edges==NULL) _error2_("the domain provided does not contain any edge");
    8080
    8181                //Vertices
    8282                if (bamggeom->Vertices){
    83                         if(verbose>5) printf("      processing Vertices\n");
    84                         if (bamggeom->VerticesSize[1]!=3) _error_("Vertices should have 3 columns");
     83                        if(verbose>5) _printLine_("      processing Vertices");
     84                        if (bamggeom->VerticesSize[1]!=3) _error2_("Vertices should have 3 columns");
    8585                        vertices = new GeomVertex[nbv];
    8686                        for (i=0;i<nbv;i++) {
     
    115115                         */
    116116                        coefIcoor=(MaxICoor)/(Max(pmax.x-pmin.x,pmax.y-pmin.y));
    117                         if(coefIcoor<=0) _error_("coefIcoor should be positive");
     117                        if(coefIcoor<=0) _error2_("coefIcoor should be positive");
    118118                }
    119119                else{
    120                         _error_("No BamgVertex provided");
     120                        _error2_("No BamgVertex provided");
    121121                }
    122122
     
    126126                        double* verticeslength=NULL;
    127127
    128                         if(verbose>5) printf("      processing Edges\n");
    129                         if (bamggeom->EdgesSize[1]!=3) _error_("Edges should have 3 columns");
     128                        if(verbose>5) _printLine_("      processing Edges");
     129                        if (bamggeom->EdgesSize[1]!=3) _error2_("Edges should have 3 columns");
    130130                        edges = new GeomEdge[nbe];
    131131
     
    176176                }
    177177                else{
    178                         _error_("No edges provided");
     178                        _error2_("No edges provided");
    179179                }
    180180
    181181                //hVertices
    182182                if(bamgopts->hVertices && bamgopts->hVerticesSize[0]==nbv){
    183                         if(verbose>5) printf("      processing hVertices\n");
     183                        if(verbose>5) _printLine_("      processing hVertices");
    184184                        for (i=0;i< nbv;i++){
    185                                 if (!isnan(bamgopts->hVertices[i])){
     185                                if (!xIsNan<IssmDouble>(bamgopts->hVertices[i])){
    186186                                        vertices[i].m=Metric((double)bamgopts->hVertices[i]);
    187187                                }
     
    191191                //MetricVertices
    192192                if(bamgopts->metric && bamgopts->metric[0]==nbv){
    193                         if(verbose>5) printf("      processing MetricVertices\n");
     193                        if(verbose>5) _printLine_("      processing MetricVertices");
    194194                        for (i=0;i< nbv;i++) {
    195195                                vertices[i].m = Metric((double)bamgopts->metric[i*3+0],(double)bamgopts->metric[i*3+1],(double)bamgopts->metric[i*3+2]);
     
    199199                //MaxCornerAngle
    200200                if (bamgopts->MaxCornerAngle){
    201                         if(verbose>5) printf("      processing MaxCornerAngle\n");
     201                        if(verbose>5) _printLine_("      processing MaxCornerAngle");
    202202                        MaxCornerAngle=bamgopts->MaxCornerAngle*Pi/180;
    203203                }
     
    205205                //TangentAtEdges
    206206                if (bamggeom->TangentAtEdges){
    207                         if(verbose>5) printf("      processing TangentAtEdges");
    208                         if (bamggeom->TangentAtEdgesSize[1]!=4) _error_("TangentAtEdges should have 4 columns");
     207                        if(verbose>5) _printString_("      processing TangentAtEdges");
     208                        if (bamggeom->TangentAtEdgesSize[1]!=4) _error2_("TangentAtEdges should have 4 columns");
    209209                        int n,i,j,k;
    210210                        R2 tg;
     
    216216                                tg.x=bamggeom->TangentAtEdges[k*4+2];
    217217                                tg.y=bamggeom->TangentAtEdges[k*4+3];
    218                                 if (i<0 || i>=nbe) _error_("TangentAtEdges first index exceeds matrix dimension");
    219                                 if (j!=0 && j!=1)  _error_("TangentAtEdges second index should be 1 or 2 only");
     218                                if (i<0 || i>=nbe) _error2_("TangentAtEdges first index exceeds matrix dimension");
     219                                if (j!=0 && j!=1)  _error2_("TangentAtEdges second index should be 1 or 2 only");
    220220                                edges[i].tg[j] = tg;
    221221                        }
     
    224224                //Corners
    225225                if(bamggeom->Corners){
    226                         if(verbose>5) printf("      processing Corners");
    227                         if (bamggeom->CornersSize[1]!=1) _error_("Corners should have 1 column");
     226                        if(verbose>5) _printString_("      processing Corners");
     227                        if (bamggeom->CornersSize[1]!=1) _error2_("Corners should have 1 column");
    228228                        n=bamggeom->CornersSize[0];
    229229                        for (i=0;i<n;i++) {     
    230230                                j=(int)bamggeom->Corners[i]-1; //for C indexing
    231                                 if (j>nbv-1 || j<0) _error_("Bad corner definition: should in [0 %i]",nbv);
     231                                if (j>nbv-1 || j<0) _error2_("Bad corner definition: should in [0 " << nbv << "]");
    232232                                /*Required => at the same time SetRequired and SetCorner*/
    233233                                vertices[j].SetCorner();
     
    238238                //RequiredVertices
    239239                if(bamggeom->RequiredVertices){
    240                         if(verbose>5) printf("      processing RequiredVertices\n");
    241                         if (bamggeom->RequiredVerticesSize[1]!=1) _error_("RequiredVertices should have 1 column");
     240                        if(verbose>5) _printLine_("      processing RequiredVertices");
     241                        if (bamggeom->RequiredVerticesSize[1]!=1) _error2_("RequiredVertices should have 1 column");
    242242                        n=bamggeom->RequiredVerticesSize[0];
    243243                        for (i=0;i<n;i++) {     
    244244                                j=(int)bamggeom->RequiredVertices[i]-1; //for C indexing
    245                                 if (j>nbv-1 || j<0) _error_("Bad RequiredVerticess  definition: should in [0 %i]",nbv);
     245                                if (j>nbv-1 || j<0) _error2_("Bad RequiredVerticess  definition: should in [0 " << nbv << "]");
    246246                                vertices[j].SetRequired();
    247247                        }
     
    250250                //RequiredEdges
    251251                if(bamggeom->RequiredEdges){
    252                         if(verbose>5) printf("      processing RequiredEdges\n");
    253                         if (bamggeom->RequiredEdgesSize[1]!=1) _error_("RequiredEdges should have 1 column");
     252                        if(verbose>5) _printLine_("      processing RequiredEdges");
     253                        if (bamggeom->RequiredEdgesSize[1]!=1) _error2_("RequiredEdges should have 1 column");
    254254                        n=bamggeom->RequiredEdgesSize[0];
    255255                        for (i=0;i<n;i++) {     
    256256                                j=(int)bamggeom->RequiredEdges[i]-1; //for C indexing
    257                                 if (j>nbe-1 || j<0) _error_("Bad RequiredEdges definition: should in [0 %i]",nbe);
     257                                if (j>nbe-1 || j<0) _error2_("Bad RequiredEdges definition: should in [0 " << nbe << "]");
    258258                                edges[j].SetRequired(); 
    259259                        }
     
    262262                //SubDomain
    263263                if(bamggeom->SubDomains){
    264                         if(verbose>5) printf("      processing SubDomains\n");
    265                         if (bamggeom->SubDomainsSize[1]!=4) _error_("SubDomains should have 4 columns");
     264                        if(verbose>5) _printLine_("      processing SubDomains");
     265                        if (bamggeom->SubDomainsSize[1]!=4) _error2_("SubDomains should have 4 columns");
    266266                        nbsubdomains=bamggeom->SubDomainsSize[0];
    267267                        subdomains = new GeomSubDomain[nbsubdomains];
     
    271271                                i2=(int)bamggeom->SubDomains[i*4+2];
    272272                                i3=(int)bamggeom->SubDomains[i*4+3];
    273                                 if (i0!=2) _error_("Bad Subdomain definition: first number should be 2 (for Edges)");
    274                                 if (i1>nbe || i1<=0) _error_("Bad Subdomain definition: second number should in [1 %i] (edge number)",nbe);
     273                                if (i0!=2) _error2_("Bad Subdomain definition: first number should be 2 (for Edges)");
     274                                if (i1>nbe || i1<=0) _error2_("Bad Subdomain definition: second number should in [1 " << nbe << "] (edge number)");
    275275                                subdomains[i].edge=edges + (i1-1);
    276276                                subdomains[i].direction = (int) i2;
     
    279279                }
    280280        }
    281         /*}}}1*/
    282         /*FUNCTION Geometry::WriteGeometry{{{1*/
     281        /*}}}*/
     282        /*FUNCTION Geometry::WriteGeometry{{{*/
    283283        void Geometry::WriteGeometry(BamgGeom* bamggeom, BamgOpts* bamgopts){
    284284
     
    294294
    295295                /*Vertices*/
    296                 if(verbose>5) printf("      writing Vertices\n");
     296                if(verbose>5) _printLine_("      writing Vertices");
    297297                bamggeom->VerticesSize[0]=nbv;
    298298                bamggeom->VerticesSize[1]=3;
    299299                if (nbv){
    300                         bamggeom->Vertices=(double*)xmalloc(3*nbv*sizeof(double));
     300                        bamggeom->Vertices=xNew<double>(3*nbv);
    301301                        for (i=0;i<nbv;i++){
    302302                                bamggeom->Vertices[i*3+0]=vertices[i].r.x;
     
    310310
    311311                /*Edges*/
    312                 if(verbose>5) printf("      writing Edges\n");
     312                if(verbose>5) _printLine_("      writing Edges");
    313313                bamggeom->EdgesSize[0]=nbe;
    314314                bamggeom->EdgesSize[1]=3;
    315315                if (nbe){
    316                         bamggeom->Edges=(double*)xmalloc(3*nbe*sizeof(double));
     316                        bamggeom->Edges=xNew<double>(3*nbe);
    317317                        for (i=0;i<nbe;i++){
    318318                                bamggeom->Edges[i*3+0]=GetId(edges[i][0])+1; //back to Matlab indexing
     
    328328
    329329                /*RequiredEdges*/
    330                 if(verbose>5) printf("      writing %i RequiredEdges\n",nbreq);
     330                if(verbose>5) _printLine_("      writing " << nbreq << " RequiredEdges");
    331331                bamggeom->RequiredEdgesSize[0]=nbreq;
    332332                bamggeom->RequiredEdgesSize[1]=1;
    333333                if (nbreq){
    334                         bamggeom->RequiredEdges=(double*)xmalloc(1*nbreq*sizeof(double));
     334                        bamggeom->RequiredEdges=xNew<double>(1*nbreq);
    335335                        count=0;
    336336                        for (i=0;i<nbe;i++){
     
    345345
    346346                /*RequiredVertices*/
    347                 if(verbose>5) printf("      writing %i RequiredVertices\n",nbreqv);
     347                if(verbose>5) _printLine_("      writing " << nbreqv << " RequiredVertices");
    348348                bamggeom->RequiredVerticesSize[0]=nbreqv;
    349349                bamggeom->RequiredVerticesSize[1]=1;
    350350                if (nbreqv){
    351                         bamggeom->RequiredVertices=(double*)xmalloc(1*nbreqv*sizeof(double));
     351                        bamggeom->RequiredVertices=xNew<double>(1*nbreqv);
    352352                        count=0;
    353353                        for (i=0;i<nbv;i++){
     
    360360
    361361                /*SubDomains*/
    362                 if(verbose>5) printf("      writing SubDomains\n");
     362                if(verbose>5) _printLine_("      writing SubDomains");
    363363                bamggeom->SubDomainsSize[0]=nbsubdomains;
    364364                bamggeom->SubDomainsSize[1]=4;
    365365                if (nbsubdomains){
    366                         bamggeom->SubDomains=(double*)xmalloc(4*nbsubdomains*sizeof(double));
     366                        bamggeom->SubDomains=xNew<double>(4*nbsubdomains);
    367367                        for (i=0;i<nbsubdomains;i++){
    368368                                bamggeom->SubDomains[4*i+0]=2;
     
    374374
    375375                /*TangentAtEdges*/
    376                 if(verbose>5) printf("      writing TangentAtEdges\n");
     376                if(verbose>5) _printLine_("      writing TangentAtEdges");
    377377                bamggeom->TangentAtEdgesSize[0]=nbtan;
    378378                bamggeom->TangentAtEdgesSize[1]=4;
    379379                if (nbtan){
    380                         bamggeom->TangentAtEdges=(double*)xmalloc(4*nbtan*sizeof(double));
     380                        bamggeom->TangentAtEdges=xNew<double>(4*nbtan);
    381381                        count=0;
    382382                        for (i=0;i<nbe;i++){
     
    397397                }
    398398        }
    399         /*}}}1*/
     399        /*}}}*/
    400400
    401401        /*Methods*/
    402         /*FUNCTION Geometry::Echo {{{1*/
     402        /*FUNCTION Geometry::Echo {{{*/
    403403        void Geometry::Echo(void){
    404404
    405                 printf("Geometry:\n");
    406                 printf("   nbv  (number of vertices) : %i\n",nbv);
    407                 printf("   nbe  (number of edges)    : %i\n",nbe);
    408                 printf("   nbsubdomains: %i\n",nbsubdomains);
    409                 printf("   nbcurves: %i\n",nbcurves);
    410                 printf("   vertices: %p\n",vertices);
    411                 printf("   edges: %p\n",edges);
    412                 printf("   quadtree: %p\n",quadtree);
    413                 printf("   subdomains: %p\n",subdomains);
    414                 printf("   curves: %p\n",curves);
    415                 printf("   pmin (x,y): (%g %g)\n",pmin.x,pmin.y);
    416                 printf("   pmax (x,y): (%g %g)\n",pmax.x,pmax.y);
    417                 printf("   coefIcoor: %g\n",coefIcoor);
    418                 printf("   MaxCornerAngle: %g\n",MaxCornerAngle);
     405                _printLine_("Geometry:");
     406                _printLine_("   nbv  (number of vertices) : " << nbv);
     407                _printLine_("   nbe  (number of edges)    : " << nbe);
     408                _printLine_("   nbsubdomains: " << nbsubdomains);
     409                _printLine_("   nbcurves: " << nbcurves);
     410                _printLine_("   vertices: " << vertices);
     411                _printLine_("   edges: " << edges);
     412                _printLine_("   quadtree: " << quadtree);
     413                _printLine_("   subdomains: " << subdomains);
     414                _printLine_("   curves: " << curves);
     415                _printLine_("   pmin (x,y): (" << pmin.x << " " << pmin.y << ")");
     416                _printLine_("   pmax (x,y): (" << pmax.x << " " << pmax.y << ")");
     417                _printLine_("   coefIcoor: " << coefIcoor);
     418                _printLine_("   MaxCornerAngle: " << MaxCornerAngle);
    419419
    420420                return;
    421421        }
    422422        /*}}}*/
    423         /*FUNCTION Geometry::Init{{{1*/
     423        /*FUNCTION Geometry::Init{{{*/
    424424        void Geometry::Init(void){
    425425                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshGeom.cpp/EmptyGeometry)*/
     
    437437                MaxCornerAngle = 10*Pi/180; //default is 10 degres
    438438        }
    439         /*}}}1*/
    440         /*FUNCTION Geometry::MinimalHmin{{{1*/
     439        /*}}}*/
     440        /*FUNCTION Geometry::MinimalHmin{{{*/
    441441        double Geometry::MinimalHmin() {
    442442                /* coeffIcoor = (2^30-1)/D
     
    445445                return 2.0/coefIcoor;
    446446        }/*}}}*/
    447         /*FUNCTION Geometry::MaximalHmax{{{1*/
     447        /*FUNCTION Geometry::MaximalHmax{{{*/
    448448        double Geometry::MaximalHmax() {
    449449                return Max(pmax.x-pmin.x,pmax.y-pmin.y);
    450450        }/*}}}*/
    451         /*FUNCTION Geometry::GetId(const GeomVertex &t){{{1*/
     451        /*FUNCTION Geometry::GetId(const GeomVertex &t){{{*/
    452452        long Geometry::GetId(const GeomVertex & t) const  {
    453453                return &t - vertices;
    454454        }/*}}}*/
    455         /*FUNCTION Geometry::GetId(const GeomVertex * t){{{1*/
     455        /*FUNCTION Geometry::GetId(const GeomVertex * t){{{*/
    456456        long Geometry::GetId(const GeomVertex * t) const  {
    457457                return t - vertices;
    458458        }/*}}}*/
    459         /*FUNCTION Geometry::GetId(const GeomEdge & t){{{1*/
     459        /*FUNCTION Geometry::GetId(const GeomEdge & t){{{*/
    460460        long Geometry::GetId(const GeomEdge & t) const  {
    461461                return &t - edges;
    462462        }/*}}}*/
    463         /*FUNCTION Geometry::GetId(const GeomEdge * t){{{1*/
     463        /*FUNCTION Geometry::GetId(const GeomEdge * t){{{*/
    464464        long Geometry::GetId(const GeomEdge * t) const  {
    465465                return t - edges;
    466466        }/*}}}*/
    467         /*FUNCTION Geometry::GetId(const Curve * c){{{1*/
     467        /*FUNCTION Geometry::GetId(const Curve * c){{{*/
    468468        long Geometry::GetId(const Curve * c) const  {
    469469                return c - curves;
    470470        }/*}}}*/
    471         /*FUNCTION Geometry::Containing{{{1*/
     471        /*FUNCTION Geometry::Containing{{{*/
    472472        GeomEdge* Geometry::Containing(const R2 P,  GeomEdge * start) const {
    473473                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshGeom.cpp/Contening)*/
     
    494494                return on;
    495495        }
    496         /*}}}1*/
    497         /*FUNCTION Geometry::PostRead{{{1*/
     496        /*}}}*/
     497        /*FUNCTION Geometry::PostRead{{{*/
    498498        void Geometry::PostRead(){
    499499                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshGeom.cpp/AfterRead)*/
     
    527527                        /*if there is a vertex found that is to close to vertices[i] -> error*/
    528528                        if( v && Norme1(v->r - vertices[i].r) < eps ){
    529                                 printf("reference numbers: %i %i\n",v->ReferenceNumber,vertices[i].ReferenceNumber);
    530                                 printf("Id: %i\n",i+1);
     529                                _printLine_("reference numbers: " << v->ReferenceNumber << " " << vertices[i].ReferenceNumber);
     530                                _printLine_("Id: " << i+1);
    531531                                delete [] next_p;
    532532                                delete [] head_v;
    533533                                delete [] eangle;
    534                                 _error_("two points of the geometry are very closed to each other (see reference numbers above)");
     534                                _error2_("two points of the geometry are very closed to each other (see reference numbers above)");
    535535                        }
    536536
     
    610610                                delete [] head_v;
    611611                                delete [] eangle;
    612                                 _error_("Length of edge %i is 0",i);
     612                                _error2_("Length of edge " << i << " is 0");
    613613                        }
    614614                        //compute angle in [-Pi Pi]
     
    704704                                long i1 = n1/2 ,j1=n1%2;
    705705
    706                                 if( edges[i1].v[j1] != edges[i].v[j]) _error_("Problem while processing edges: check the edge list");
     706                                if( edges[i1].v[j1] != edges[i].v[j]) _error2_("Problem while processing edges: check the edge list");
    707707
    708708                                edges[i1].Adj[j1] = edges + i;
     
    817817
    818818        }
    819         /*}}}1*/
    820         /*FUNCTION Geometry::ProjectOnCurve {{{1*/
     819        /*}}}*/
     820        /*FUNCTION Geometry::ProjectOnCurve {{{*/
    821821        GeomEdge* Geometry::ProjectOnCurve(const Edge &e,double s,BamgVertex &V,VertexOnGeom &GV) const {
    822822                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshGeom.cpp/ProjectOnCurve)*/
     
    831831                GeomEdge* on=e.GeomEdgeHook;
    832832                if (!on){
    833                         _error_("ProjectOnCurve error message: edge provided should be on geometry");
     833                        _error2_("ProjectOnCurve error message: edge provided should be on geometry");
    834834                }
    835835                if (!e[0].GeomEdgeHook ||  !e[1].GeomEdgeHook){
    836                         _error_("ProjectOnCurve error message: at least one of the vertex of the edge provided is not on geometry");
     836                        _error2_("ProjectOnCurve error message: at least one of the vertex of the edge provided is not on geometry");
    837837                }
    838838
     
    870870                        if (bge<=0) {
    871871                                if(NbTry) {
    872                                         printf("Fatal Error: on the class Mesh before call Geometry::ProjectOnCurve\n");
    873                                         printf("That bug might come from:\n");
    874                                         printf(" 1)  a mesh edge  containing more than %i geometrical edges\n",mxe/2);
    875                                         printf(" 2)  code bug : be sure that we call   Mesh::SetVertexFieldOn() before\n");
    876                                         printf("To solve the problem do a coarsening of the geometrical mesh or change the constant value of mxe (dangerous)\n");
    877                                         _error_("see above");
     872                                        _printLine_("Fatal Error: on the class Mesh before call Geometry::ProjectOnCurve");
     873                                        _printLine_("That bug might come from:");
     874                                        _printLine_(" 1)  a mesh edge  containing more than " << mxe/2 << " geometrical edges");
     875                                        _printLine_(" 2)  code bug : be sure that we call   Mesh::SetVertexFieldOn() before");
     876                                        _printLine_("To solve the problem do a coarsening of the geometrical mesh or change the constant value of mxe (dangerous)");
     877                                        _error2_("see above");
    878878                                }
    879879                                NbTry++;
     
    887887                while (eg1 != (GeomEdge*) vg1  &&  (*eg1)(direction1) != (GeomVertex*) vg1) {
    888888                        if(tge>=mxe ) {
    889                                 printf("WARNING: on the class Mesh before call Geometry::ProjectOnCurve is having issues (isn't it Eric?)\n");
     889                                _printLine_("WARNING: on the class Mesh before call Geometry::ProjectOnCurve is having issues (isn't it Eric?)");
    890890                                NbTry++;
    891891                                if (NbTry<2) goto retry;
    892                                 printf("Fatal Error: on the class Mesh before call Geometry::ProjectOnCurve\n");
    893                                 printf("That bug might come from:\n");
    894                                 printf(" 1)  a mesh edge  contening more than %i geometrical edges\n",mxe/2);
    895                                 printf(" 2)  code bug : be sure that we call   Mesh::SetVertexFieldOn() before\n");
    896                                 printf("To solve the problem do a coarsening of the geometrical mesh or change the constant value of mxe (dangerous)\n");
    897                                 _error_("see above");
     892                                _printLine_("Fatal Error: on the class Mesh before call Geometry::ProjectOnCurve");
     893                                _printLine_("That bug might come from:");
     894                                _printLine_(" 1)  a mesh edge  contening more than " << mxe/2 << " geometrical edges");
     895                                _printLine_(" 2)  code bug : be sure that we call   Mesh::SetVertexFieldOn() before");
     896                                _printLine_("To solve the problem do a coarsening of the geometrical mesh or change the constant value of mxe (dangerous)");
     897                                _error2_("see above");
    898898                        }
    899899                        GeomEdge* tmpge = eg1;
     
    951951                return on;
    952952        }
    953         /*}}}1*/
    954         /*FUNCTION Geometry::R2ToI2{{{1*/
     953        /*}}}*/
     954        /*FUNCTION Geometry::R2ToI2{{{*/
    955955        I2 Geometry::R2ToI2(const R2 & P) const {
    956956                /*coefIcoor is the coefficient used for integer coordinates:
     
    965965                return  I2( (Icoor1) (coefIcoor*(P.x-pmin.x)) ,(Icoor1) (coefIcoor*(P.y-pmin.y)) );
    966966        }/*}}}*/
    967         /*FUNCTION Geometry::UnMarkEdges{{{1*/
     967        /*FUNCTION Geometry::UnMarkEdges{{{*/
    968968        void Geometry::UnMarkEdges() {
    969969                for (int i=0;i<nbe;i++) edges[i].SetUnMark();
  • issm/trunk/src/c/objects/Bamg/ListofIntersectionTriangles.cpp

    r9306 r12706  
    99
    1010        /*Constructors Destructors*/
    11         /*FUNCTION ListofIntersectionTriangles::ListofIntersectionTriangles{{{1*/
     11        /*FUNCTION ListofIntersectionTriangles::ListofIntersectionTriangles{{{*/
    1212        ListofIntersectionTriangles::ListofIntersectionTriangles(int n,int m)
    1313          : MaxSize(n), Size(0), len(-1),state(-1),lIntTria(new IntersectionTriangles[n]) ,
     
    1515          }
    1616        /*}}}*/
    17         /*FUNCTION ListofIntersectionTriangles::~ListofIntersectionTriangles{{{1*/
     17        /*FUNCTION ListofIntersectionTriangles::~ListofIntersectionTriangles{{{*/
    1818        ListofIntersectionTriangles::~ListofIntersectionTriangles(){
    1919                if (lIntTria) delete [] lIntTria,lIntTria=0;
     
    2323
    2424        /*Methods*/
    25         /*FUNCTION ListofIntersectionTriangles::Init{{{1*/
     25        /*FUNCTION ListofIntersectionTriangles::Init{{{*/
    2626        void ListofIntersectionTriangles::Init(void){
    2727                state=0;
     
    3030        }
    3131        /*}}}*/
    32         /*FUNCTION ListofIntersectionTriangles::Length{{{1*/
     32        /*FUNCTION ListofIntersectionTriangles::Length{{{*/
    3333        double  ListofIntersectionTriangles::Length(){
    3434                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/Length)*/
     
    3838                // check Size
    3939                if (Size<=0){
    40                         _error_("Size<=0");
     40                        _error2_("Size<=0");
    4141                }
    4242
     
    7777                return s;
    7878        }
    79         /*}}}1*/
    80         /*FUNCTION ListofIntersectionTriangles::NewItem(Triangle * tt,double d0,double d1,double d2) {{{1*/
     79        /*}}}*/
     80        /*FUNCTION ListofIntersectionTriangles::NewItem(Triangle * tt,double d0,double d1,double d2) {{{*/
    8181        int  ListofIntersectionTriangles::NewItem(Triangle * tt,double d0,double d1,double d2) {
    8282                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/NewItem)*/
     
    105105                return n;
    106106        }
    107         /*}}}1*/
    108         /*FUNCTION ListofIntersectionTriangles::NewItem(R2 A,const Metric & mm){{{1*/
     107        /*}}}*/
     108        /*FUNCTION ListofIntersectionTriangles::NewItem(R2 A,const Metric & mm){{{*/
    109109        int ListofIntersectionTriangles::NewItem(R2 A,const Metric & mm) {
    110110                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/NewItem)*/
     
    121121                return  n;
    122122        }
    123         /*}}}1*/
    124         /*FUNCTION ListofIntersectionTriangles::NewPoints{{{1*/
     123        /*}}}*/
     124        /*FUNCTION ListofIntersectionTriangles::NewPoints{{{*/
    125125        long ListofIntersectionTriangles::NewPoints(BamgVertex* vertices,long &nbv,long maxnbv){
    126126                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/NewPoints)*/
     
    167167                        //x.Echo();
    168168                        //y.Echo();
    169                         //printf("cx = %g, cy=%g\n",cx,cy);
     169                        //_printLine_("cx = " << cx << ", cy=" << cy);
    170170
    171171                        si += sint;
     
    178178                return nbv-nbvold;
    179179        }
    180         /*}}}1*/
    181         /*FUNCTION ListofIntersectionTriangles::NewSubSeg{{{1*/
     180        /*}}}*/
     181        /*FUNCTION ListofIntersectionTriangles::NewSubSeg{{{*/
    182182        void  ListofIntersectionTriangles::NewSubSeg(GeomEdge *e,double s0,double s1){
    183183                long int verbosity=0;
     
    186186                        MaxNbSeg *= 2;
    187187                        if (verbosity>3){
    188                                 printf("   reshape lSegsI from %i to %i\n",mneo,MaxNbSeg);
     188                                _printLine_("   reshape lSegsI from " << mneo << " to " << MaxNbSeg);
    189189                        }
    190190                        _assert_(lSegsI && NbSeg<MaxNbSeg);
     
    201201        }
    202202        /*}}}*/
    203         /*FUNCTION ListofIntersectionTriangles::ReShape{{{1*/
     203        /*FUNCTION ListofIntersectionTriangles::ReShape{{{*/
    204204        void ListofIntersectionTriangles::ReShape(){
    205205
     
    211211                for (int i=0;i<MaxSize;i++) nw[i] = lIntTria[i];       
    212212                long int verbosity=0;
    213                 if(verbosity>3) printf("   ListofIntersectionTriangles  ReShape Maxsize %i -> %i\n",MaxSize,MaxNbSeg);
     213                if(verbosity>3) _printLine_("   ListofIntersectionTriangles  ReShape Maxsize " << MaxSize << " -> " << MaxNbSeg);
    214214                MaxSize = newsize;
    215215                delete [] lIntTria;// remove old
     
    217217        }
    218218        /*}}}*/
    219         /*FUNCTION ListofIntersectionTriangles::SplitEdge{{{1*/
     219        /*FUNCTION ListofIntersectionTriangles::SplitEdge{{{*/
    220220        void ListofIntersectionTriangles::SplitEdge(const Mesh & Bh, const R2 &A,const R2  &B,int nbegin) {
    221221                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/ListofIntersectionTriangles)*/
     
    268268                                k=(*t)(0) ?  ((  (*t)(1) ? ( (*t)(2) ? -1 : 2) : 1  )) : 0;
    269269                                if (k<0){
    270                                         _error_("k<0");
     270                                        _error2_("k<0");
    271271                                }
    272272                                ocut = OppositeEdge[k];
     
    312312                                double dij = detj-deti;
    313313                                if (i+j+k != 0 + 1 +2){
    314                                         _error_("i+j+k != 0 + 1 +2");
     314                                        _error2_("i+j+k != 0 + 1 +2");
    315315                                }
    316316                                ba[j] =  detj/dij;
     
    384384                                        }
    385385                                        else {
    386                                                 _error_("Bug Split Edge");
     386                                                _error2_("Bug Split Edge");
    387387                                        }
    388388                                }
     
    421421                } // for(;;)
    422422        }
    423         /*}}}1*/
     423        /*}}}*/
    424424
    425425}
  • issm/trunk/src/c/objects/Bamg/ListofIntersectionTriangles.h

    r6412 r12706  
    3434                                        double c01=lEnd-lBegin, c0=(lEnd-s)/c01, c1=(s-lBegin)/c01;
    3535                                        if (lBegin>s || s>lEnd){
    36                                                 _error_("lBegin>s || s>lEnd");
     36                                                _error2_("lBegin>s || s>lEnd");
    3737                                        }
    3838                                        return e->F(sBegin*c0+sEnd*c1);
  • issm/trunk/src/c/objects/Bamg/Mesh.cpp

    r12330 r12706  
    1111
    1212        /*Constructors/Destructors*/
    13         /*FUNCTION Mesh::Mesh(BamgGeom* bamggeom,BamgMesh* bamgmesh, BamgOpts* bamgopts){{{1*/
     13        /*FUNCTION Mesh::Mesh(BamgGeom* bamggeom,BamgMesh* bamgmesh, BamgOpts* bamgopts){{{*/
    1414        Mesh::Mesh(BamgGeom* bamggeom,BamgMesh* bamgmesh, BamgOpts* bamgopts):Gh(*(new Geometry())),BTh(*this){
    1515
     
    2929                if(bamggeom->Edges==NULL) {
    3030                        /*Recreate geometry if needed*/
    31                         printf("WARNING: mesh present but no geometry found. Reconstructing...\n");
     31                        _printLine_("WARNING: mesh present but no geometry found. Reconstructing...");
    3232                        BuildGeometryFromMesh(bamgopts);
    3333                        Gh.PostRead();
     
    4040                ReconstructExistingMesh();
    4141        }
    42         /*}}}1*/
    43         /*FUNCTION Mesh::Mesh(double* index,double* x,double* y,int nods,int nels){{{1*/
    44         Mesh::Mesh(double* index,double* x,double* y,int nods,int nels):Gh(*(new Geometry())),BTh(*this){
     42        /*}}}*/
     43        /*FUNCTION Mesh::Mesh(int* index,double* x,double* y,int nods,int nels){{{*/
     44        Mesh::Mesh(int* index,double* x,double* y,int nods,int nels):Gh(*(new Geometry())),BTh(*this){
    4545
    4646                Init(0);
     
    4949                ReconstructExistingMesh();
    5050        }
    51         /*}}}1*/
    52         /*FUNCTION Mesh::Mesh(double* x,double* y,int nods){{{1*/
     51        /*}}}*/
     52        /*FUNCTION Mesh::Mesh(double* x,double* y,int nods){{{*/
    5353        Mesh::Mesh(double* x,double* y,int nods):Gh(*(new Geometry())),BTh(*this){
    5454                Triangulate(x,y,nods);
    5555        }
    56         /*}}}1*/
    57         /*FUNCTION Mesh::Mesh(const Mesh & Tho,const int *flag ,const int *bb){{{1*/
     56        /*}}}*/
     57        /*FUNCTION Mesh::Mesh(const Mesh & Tho,const int *flag ,const int *bb){{{*/
    5858        Mesh::Mesh(const Mesh & Tho,const int *flag ,const int *bb,BamgOpts* bamgopts) : Gh(*(new Geometry())), BTh(*this) {
    5959                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/Triangles)*/
     
    101101                          if (kk[i]>=0) kk[i]=k++;
    102102                        }
    103                   printf("   number of vertices %i, remove = %i\n",k,Tho.nbv - k);
    104                   printf("   number of triangles %i, remove = %i\n",kt,nbInT-kt);
    105                   printf("   number of New boundary edge %i\n",nbNewBedge);
     103                  _printLine_("   number of vertices " << k << ", remove = " << Tho.nbv - k);
     104                  _printLine_("   number of triangles " << kt << ", remove = " << nbInT-kt);
     105                  _printLine_("   number of New boundary edge " << nbNewBedge);
    106106                  long imaxnbv =k;
    107107                  Init(imaxnbv);
     
    117117                          delete [] kk;
    118118                          delete [] refv;
    119                           _error_("imaxnbv != nbv");
     119                          _error2_("imaxnbv != nbv");
    120120                  }
    121121                  for (i=0;i<Tho.nbt;i++)
     
    128128                                if (i0<0 || i1<0 || i2<0){
    129129                                        delete [] refv;
    130                                         _error_("i0<0 || i1<0 || i2< 0");
     130                                        _error2_("i0<0 || i1<0 || i2< 0");
    131131                                }
    132132                                if (i0>=Tho.nbv || i1>=Tho.nbv || i2>=Tho.nbv){
    133                                         _error_("i0>=Tho.nbv || i1>=Tho.nbv || i2>=Tho.nbv");
     133                                        _error2_("i0>=Tho.nbv || i1>=Tho.nbv || i2>=Tho.nbv");
    134134                                }
    135135                                triangles[nbt] = Triangle(this,kk[i0],kk[i1],kk[i2]);
     
    138138                          }
    139139                  if (kt!=nbt){
    140                           _error_("kt!=nbt");
     140                          _error2_("kt!=nbt");
    141141                  }
    142142                  if (nbt==0 && nbv==0) {
    143                           _error_("All triangles have been removed");
     143                          _error2_("All triangles have been removed");
    144144                  }
    145145                  delete [] kk;
     
    153153
    154154                  if (!nbsubdomains){
    155                           _error_("nbsubdomains==0");
     155                          _error2_("nbsubdomains==0");
    156156                  }
    157157                  if (!subdomains[0].head || !subdomains[0].head->link){
    158                           _error_("!subdomains[0].head || !subdomains[0].head->link");
     158                          _error2_("!subdomains[0].head || !subdomains[0].head->link");
    159159                  }
    160160
    161161          }
    162         /*}}}1*/
    163         /*FUNCTION Mesh::Mesh(Mesh & Th,Geometry * pGh,Mesh * pBth,long maxnbv_in) COPY{{{1*/
     162        /*}}}*/
     163        /*FUNCTION Mesh::Mesh(Mesh & Th,Geometry * pGh,Mesh * pBth,long maxnbv_in) COPY{{{*/
    164164        Mesh::Mesh(Mesh & Th,Geometry * pGh,Mesh * pBth,long maxnbv_in)
    165165          : Gh(*(pGh?pGh:&Th.Gh)), BTh(*(pBth?pBth:this)) {
     
    224224
    225225          }
    226         /*}}}1*/
    227         /*FUNCTION Mesh::Mesh(long maxnbv,Mesh & BT,BamgOpts* bamgopts,int keepBackVertices){{{1*/
     226        /*}}}*/
     227        /*FUNCTION Mesh::Mesh(long maxnbv,Mesh & BT,BamgOpts* bamgopts,int keepBackVertices){{{*/
    228228        Mesh::Mesh(long imaxnbv,Mesh & BT,BamgOpts* bamgopts,int keepBackVertices) :Gh(BT.Gh),BTh(BT) {
    229229                this->Init(imaxnbv);
    230230                TriangulateFromGeom1(bamgopts,keepBackVertices);
    231231        }
    232         /*}}}1*/
    233         /*FUNCTION Mesh::Mesh(long maxnbv,Geometry & G,BamgOpts* bamgopts){{{1*/
     232        /*}}}*/
     233        /*FUNCTION Mesh::Mesh(long maxnbv,Geometry & G,BamgOpts* bamgopts){{{*/
    234234        Mesh::Mesh(long imaxnbv,Geometry & G,BamgOpts* bamgopts):Gh(G),BTh(*this){
    235235                Init(imaxnbv);
    236236                TriangulateFromGeom0(bamgopts);
    237237        }
    238         /*}}}1*/
    239         /*FUNCTION Mesh::~Mesh(){{{1*/
     238        /*}}}*/
     239        /*FUNCTION Mesh::~Mesh(){{{*/
    240240        Mesh::~Mesh() {
    241241                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/Triangles)*/
     
    262262                Init(0); // set all to zero
    263263        }
    264         /*}}}1*/
     264        /*}}}*/
    265265
    266266        /*IO*/
    267         /*FUNCTION Mesh::ReadMesh(double* index,double* x,double* y,int nods,int nels){{{1*/
    268         void Mesh::ReadMesh(double* index,double* x,double* y,int nods,int nels){
     267        /*FUNCTION Mesh::ReadMesh(int* index,double* x,double* y,int nods,int nels){{{*/
     268        void Mesh::ReadMesh(int* index,double* x,double* y,int nods,int nels){
    269269
    270270                double Hmin = HUGE_VAL;// the infinie value
     
    280280
    281281                //Vertices
    282                 if (verbose) printf("Reading vertices (%i)\n",nbv);
    283                 vertices=(BamgVertex*)xmalloc(nbv*sizeof(BamgVertex));
    284                 orderedvertices=(BamgVertex**)xmalloc(nbv*sizeof(BamgVertex*));
     282                if (verbose) _printLine_("Reading vertices (" << nbv << ")");
     283                vertices=xNew<BamgVertex>(nbv);
     284                orderedvertices=xNew<BamgVertex*>(nbv);
    285285                for (i=0;i<nbv;i++){
    286286                        vertices[i].r.x=x[i];
     
    294294
    295295                //Triangles
    296                 if (verbose) printf("Reading triangles (%i)\n",nbt);
     296                if (verbose) _printLine_("Reading triangles (" << nbt << ")");
    297297                triangles =new Triangle[maxnbt]; //we cannot allocate only nbt triangles since
    298                 nodeflags=(bool*)xmalloc(nbv*sizeof(bool));
     298                nodeflags=xNew<bool>(nbv);
    299299                for(i=0;i<nbv;i++) nodeflags[i]=false;
    300300                //other triangles will be added for each edge
     
    310310
    311311                /*Recreate geometry: */
    312                 if (verbose) printf("Building Geometry\n");
     312                if (verbose) _printLine_("Building Geometry");
    313313                BuildGeometryFromMesh();
    314                 if (verbose) printf("Completing geometry\n");
     314                if (verbose) _printLine_("Completing geometry");
    315315                Gh.PostRead();
    316316
     
    319319                for(i=0;i<nbv;i++){
    320320                        if(!nodeflags[i]){
    321                                 printf("Vertex %i does not belong to any element\n",i+1);
     321                                _printLine_("Vertex " << i+1 << " does not belong to any element");
    322322                                isorphan=true;
    323323                        }
    324324                }
    325                 if(isorphan) _error_("Orphan found in mesh, see ids above");
     325                if(isorphan) _error2_("Orphan found in mesh, see ids above");
    326326
    327327                /*Clean up*/
    328                 xfree((void**)&nodeflags);
    329         }
    330         /*}}}1*/
    331         /*FUNCTION Mesh::ReadMesh(BamgMesh* bamgmesh, BamgOpts* bamgopts){{{1*/
     328                xDelete<bool>(nodeflags);
     329        }
     330        /*}}}*/
     331        /*FUNCTION Mesh::ReadMesh(BamgMesh* bamgmesh, BamgOpts* bamgopts){{{*/
    332332        void Mesh::ReadMesh(BamgMesh* bamgmesh, BamgOpts* bamgopts){
    333333
     
    346346                //Vertices
    347347                if(bamgmesh->Vertices){
    348                         if(verbose>5) printf("      processing Vertices\n");
    349 
    350                         vertices=(BamgVertex*)xmalloc(nbv*sizeof(BamgVertex));
    351                         orderedvertices=(BamgVertex**)xmalloc(nbv*sizeof(BamgVertex*));
     348                        if(verbose>5) _printLine_("      processing Vertices");
     349
     350                        vertices=xNew<BamgVertex>(nbv);
     351                        orderedvertices=xNew<BamgVertex*>(nbv);
    352352
    353353                        for (i=0;i<nbv;i++){
     
    362362                }
    363363                else{
    364                         if(verbose>5) _error_("no Vertices found in the initial mesh");
     364                        if(verbose>5) _error2_("no Vertices found in the initial mesh");
    365365                }
    366366
    367367                //Triangles
    368368                if(bamgmesh->Triangles){
    369                         if(verbose>5) printf("      processing Triangles\n");
     369                        if(verbose>5) _printLine_("      processing Triangles");
    370370                        triangles =new Triangle[maxnbt]; //we cannot allocate only nbt triangles since
    371371                        //other triangles will be added for each edge
     
    380380                }
    381381                else{
    382                         if(verbose>5) _error_("no Triangles found in the initial mesh");
     382                        if(verbose>5) _error2_("no Triangles found in the initial mesh");
    383383                }
    384384
    385385                //Quadrilaterals
    386386                if(bamgmesh->Quadrilaterals){
    387                         if(verbose>5) printf("      processing Quadrilaterals\n");
     387                        if(verbose>5) _printLine_("      processing Quadrilaterals");
    388388                        long i1,i2,i3,i4,iref;
    389389                        triangles =new Triangle[nbt];
     
    407407                //VerticesOnGeomEdge
    408408                if(bamgmesh->VerticesOnGeomEdge){
    409                         if(verbose>5) printf("      processing VerticesOnGeomEdge\n");
     409                        if(verbose>5) _printLine_("      processing VerticesOnGeomEdge");
    410410                        NbVerticesOnGeomEdge=bamgmesh->VerticesOnGeomEdgeSize[0];
    411411                        VerticesOnGeomEdge= new  VertexOnGeom[NbVerticesOnGeomEdge] ;
     
    422422                //VerticesOnGeomVertex
    423423                if(bamgmesh->VerticesOnGeomVertexSize[0]){
    424                         if(verbose>5) printf("      processing VerticesOnGeomVertex\n");
     424                        if(verbose>5) _printLine_("      processing VerticesOnGeomVertex");
    425425                        NbVerticesOnGeomVertex=bamgmesh->VerticesOnGeomVertexSize[0];
    426426                        VerticesOnGeomVertex  = new  VertexOnGeom[NbVerticesOnGeomVertex] ;
     
    438438                        double* len=NULL;
    439439
    440                         if(verbose>5) printf("      processing Edges\n");
     440                        if(verbose>5) _printLine_("      processing Edges");
    441441                        nbe=bamgmesh->EdgesSize[0];
    442442                        edges= new Edge[nbe];
     
    498498                //EdgeOnGeomEdge
    499499                if(bamgmesh->EdgesOnGeomEdge){
    500                         if(verbose>5) printf("      processing EdgesOnGeomEdge\n");
     500                        if(verbose>5) _printLine_("      processing EdgesOnGeomEdge");
    501501                        int i1,i2,i,j;
    502502                        i2=bamgmesh->EdgesOnGeomEdgeSize[0];
     
    506506                                //Check value
    507507                                if(!(i>=0 && j>=0 && i<nbe && j<Gh.nbe)) {
    508                                         _error_("ReadMesh error: EdgesOnGeomEdge edge provided (line %i: [%i %i]) is incorrect (must be positive, [0<i<nbe=%i 0<j<Gh.nbe=%i]",i1+1,i+1,j+1,nbe,Gh.nbe);
     508                                        _error2_("ReadMesh error: EdgesOnGeomEdge edge provided (line " << i1+1 << ": [" << i+1 << " " << j+1 << "]) is incorrect (must be positive, [0<i<nbe=" << nbe << " 0<j<Gh.nbe=" << Gh.nbe << "]");
    509509                                }
    510510                                edges[i].GeomEdgeHook=Gh.edges+j;
     
    515515                if(bamgmesh->SubDomains){
    516516                        long i3,head,direction;
    517                         if(verbose>5) printf("      processing SubDomains\n");
     517                        if(verbose>5) _printLine_("      processing SubDomains");
    518518                        nbsubdomains=bamgmesh->SubDomainsSize[0];
    519519                        subdomains = new SubDomain [ nbsubdomains ];
     
    522522                                head=(int)bamgmesh->SubDomains[i*3+1]-1;//C indexing
    523523                                direction=(int)bamgmesh->SubDomains[i*3+2];
    524                                 if (i3!=23) _error_("Bad Subdomain definition: first number should be 3");
    525                                 if (head<0 || head>=nbt) _error_("Bad Subdomain definition: head should in [1 %i] (triangle number)",nbt);
     524                                if (i3!=23) _error2_("Bad Subdomain definition: first number should be 3");
     525                                if (head<0 || head>=nbt) _error2_("Bad Subdomain definition: head should in [1 " << nbt << "] (triangle number)");
    526526                                subdomains[i].head = triangles+head;
    527527                        }
     
    529529
    530530        }
    531         /*}}}1*/
    532         /*FUNCTION Mesh::WriteMesh {{{1*/
     531        /*}}}*/
     532        /*FUNCTION Mesh::WriteMesh {{{*/
    533533        void Mesh::WriteMesh(BamgMesh* bamgmesh,BamgOpts* bamgopts){
    534534
     
    553553
    554554                //Memory Allocation
    555                 head_1=(int*)xmalloc(nbv*sizeof(int));
    556                 next_1=(int*)xmalloc(3*nbt*sizeof(int));
    557                 connectivitysize_1=(int*)xmalloc(nbv*sizeof(int));
     555                head_1=xNew<int>(nbv);
     556                next_1=xNew<int>(3*nbt);
     557                connectivitysize_1=xNew<int>(nbv);
    558558
    559559                //Initialization
     
    567567                                for (j=0;j<3;j++){
    568568                                        int v=GetId(triangles[i][j]); //jth vertex of the ith triangle
    569                                         if (k>3*nbt-1 || k<0) _error_("k = %i, nbt = %i",k,nbt);
     569                                        if (k>3*nbt-1 || k<0) _error2_("k = " << k << ", nbt = " << nbt);
    570570                                        next_1[k]=head_1[v];
    571                                         if (v>nbv-1 || v<0)   _error_("v = %i, nbv = %i",v,nbv);
     571                                        if (v>nbv-1 || v<0)   _error2_("v = " << v << ", nbv = " << nbv);
    572572                                        head_1[v]=k++;
    573573                                        connectivitysize_1[v]+=1;
     
    584584
    585585                /*Vertices*/
    586                 if(verbose>5) printf("      writing Vertices\n");
     586                if(verbose>5) _printLine_("      writing Vertices");
    587587                bamgmesh->VerticesSize[0]=nbv;
    588588                bamgmesh->VerticesSize[1]=3;
    589589                if (nbv){
    590                         bamgmesh->Vertices=(double*)xmalloc(3*nbv*sizeof(double));
     590                        bamgmesh->Vertices=xNew<double>(3*nbv);
    591591                        for (i=0;i<nbv;i++){
    592592                                bamgmesh->Vertices[i*3+0]=vertices[i].r.x;
     
    597597
    598598                /*Edges*/
    599                 if(verbose>5) printf("      writing Edges\n");
     599                if(verbose>5) _printLine_("      writing Edges");
    600600                bamgmesh->EdgesSize[0]=nbe;
    601601                bamgmesh->EdgesSize[1]=3;
    602602                int NumIssmSegments=0;
    603603                if (nbe){
    604                         bamgmesh->Edges=(double*)xmalloc(3*nbe*sizeof(double));
     604                        bamgmesh->Edges=xNew<double>(3*nbe);
    605605                        for (i=0;i<nbe;i++){
    606606                                bamgmesh->Edges[i*3+0]=GetId(edges[i][0])+1; //back to M indexing
     
    614614
    615615                /*Element edges*/
    616                 if(verbose>5) printf("      writing element edges\n");
     616                if(verbose>5) _printLine_("      writing element edges");
    617617                SetOfEdges4* edge4=new SetOfEdges4(nbt*3,nbv);
    618618                double* elemedge=NULL;
    619                 elemedge=(double*)xmalloc(3*nbt*sizeof(double));
    620                 for (i=0;i<3*nbt;i++) elemedge[i]=NAN;
     619                elemedge=xNew<double>(3*nbt);
     620                for (i=0;i<3*nbt;i++) elemedge[i]=-2.;//will become -1
    621621                k=0;
    622622                for (i=0;i<nbt;i++){
     
    642642                bamgmesh->IssmEdgesSize[0]=edge4->nb();
    643643                bamgmesh->IssmEdgesSize[1]=4;
    644                 bamgmesh->IssmEdges=(double*)xmalloc(4*edge4->nb()*sizeof(double));
     644                bamgmesh->IssmEdges=xNew<double>(4*edge4->nb());
    645645                for (i=0;i<edge4->nb();i++){
    646646                        /*Invert first two vertices if necessary*/
     
    667667                //clean up
    668668                delete edge4;
    669                 xfree((void**)&elemedge);
     669                xDelete<double>(elemedge);
    670670
    671671                /*IssmSegments*/
    672                 if(verbose>5) printf("      writing IssmSegments\n");
     672                if(verbose>5) _printLine_("      writing IssmSegments");
    673673                bamgmesh->IssmSegmentsSize[0]=NumIssmSegments;
    674674                bamgmesh->IssmSegmentsSize[1]=4;
    675                 bamgmesh->IssmSegments=(double*)xmalloc(4*NumIssmSegments*sizeof(double));
     675                bamgmesh->IssmSegments=xNew<double>(4*NumIssmSegments);
    676676                num=0;
    677677                for (i=0;i<nbe;i++){
     
    707707                                }
    708708                                if (!stop){
    709                                         _error_("Element holding segment [%i %i] not found...",i1+1,i2+1);
     709                                        _error2_("Element holding segment [" << i1+1 << " " << i2+1 << "] not found...");
    710710                                }
    711711                        }
     
    713713
    714714                /*Triangles*/
    715                 if(verbose>5) printf("      writing Triangles\n");
     715                if(verbose>5) _printLine_("      writing Triangles");
    716716                k=nbInT-nbq*2;
    717717                num=0;
     
    719719                bamgmesh->TrianglesSize[1]=4;
    720720                if (k){
    721                         bamgmesh->Triangles=(double*)xmalloc(4*k*sizeof(double));
     721                        bamgmesh->Triangles=xNew<double>(4*k);
    722722                        for (i=0;i<nbt;i++){
    723723                                Triangle &t=triangles[i];
     
    734734
    735735                /*Quadrilaterals*/
    736                 if(verbose>5) printf("      writing Quadrilaterals\n");
     736                if(verbose>5) _printLine_("      writing Quadrilaterals");
    737737                bamgmesh->QuadrilateralsSize[0]=nbq;
    738738                bamgmesh->QuadrilateralsSize[1]=5;
    739739                if (nbq){
    740                         bamgmesh->Quadrilaterals=(double*)xmalloc(5*nbq*sizeof(double));
     740                        bamgmesh->Quadrilaterals=xNew<double>(5*nbq);
    741741                        for (i=0;i<nbt;i++){
    742742                                Triangle &t =triangles[i];
     
    755755
    756756                /*SubDomains*/
    757                 if(verbose>5) printf("      writing SubDomains\n");
     757                if(verbose>5) _printLine_("      writing SubDomains");
    758758                bamgmesh->SubDomainsSize[0]=nbsubdomains;
    759759                bamgmesh->SubDomainsSize[1]=4;
    760760                if (nbsubdomains){
    761                         bamgmesh->SubDomains=(double*)xmalloc(4*nbsubdomains*sizeof(double));
     761                        bamgmesh->SubDomains=xNew<double>(4*nbsubdomains);
    762762                        for (i=0;i<nbsubdomains;i++){
    763763                                bamgmesh->SubDomains[i*4+0]=3;
     
    769769
    770770                /*SubDomainsFromGeom*/
    771                 if(verbose>5) printf("      writing SubDomainsFromGeom\n");
     771                if(verbose>5) _printLine_("      writing SubDomainsFromGeom");
    772772                bamgmesh->SubDomainsFromGeomSize[0]=Gh.nbsubdomains;
    773773                bamgmesh->SubDomainsFromGeomSize[1]=4;
    774774                if (Gh.nbsubdomains){
    775                         bamgmesh->SubDomainsFromGeom=(double*)xmalloc(4*Gh.nbsubdomains*sizeof(double));
     775                        bamgmesh->SubDomainsFromGeom=xNew<double>(4*Gh.nbsubdomains);
    776776                        for (i=0;i<Gh.nbsubdomains;i++){
    777777                                bamgmesh->SubDomainsFromGeom[i*4+0]=2;
     
    783783
    784784                /*VerticesOnGeomVertex*/
    785                 if(verbose>5) printf("      writing VerticesOnGeomVertex\n");
     785                if(verbose>5) _printLine_("      writing VerticesOnGeomVertex");
    786786                bamgmesh->VerticesOnGeomVertexSize[0]=NbVerticesOnGeomVertex;
    787787                bamgmesh->VerticesOnGeomVertexSize[1]=2;
    788788                if (NbVerticesOnGeomVertex){
    789                         bamgmesh->VerticesOnGeomVertex=(double*)xmalloc(2*NbVerticesOnGeomVertex*sizeof(double));
     789                        bamgmesh->VerticesOnGeomVertex=xNew<double>(2*NbVerticesOnGeomVertex);
    790790                        for (i=0;i<NbVerticesOnGeomVertex;i++){
    791791                                VertexOnGeom &v=VerticesOnGeomVertex[i];
     
    797797
    798798                /*VertexOnGeomEdge*/
    799                 if(verbose>5) printf("      writing VerticesOnGeomEdge\n");
     799                if(verbose>5) _printLine_("      writing VerticesOnGeomEdge");
    800800                bamgmesh->VerticesOnGeomEdgeSize[0]=NbVerticesOnGeomEdge;
    801801                bamgmesh->VerticesOnGeomEdgeSize[1]=3;
    802802                if (NbVerticesOnGeomEdge){
    803                         bamgmesh->VerticesOnGeomEdge=(double*)xmalloc(3*NbVerticesOnGeomEdge*sizeof(double));
     803                        bamgmesh->VerticesOnGeomEdge=xNew<double>(3*NbVerticesOnGeomEdge);
    804804                        for (i=0;i<NbVerticesOnGeomEdge;i++){
    805805                                const VertexOnGeom &v=VerticesOnGeomEdge[i];
    806806                                if (!v.OnGeomEdge()){
    807                                         _error_("A vertices supposed to be OnGeomEdge is actually not");
     807                                        _error2_("A vertices supposed to be OnGeomEdge is actually not");
    808808                                }
    809809                                bamgmesh->VerticesOnGeomEdge[i*3+0]=GetId((BamgVertex*)v)+1; //back to Matlab indexing
     
    814814
    815815                /*EdgesOnGeomEdge*/
    816                 if(verbose>5) printf("      writing EdgesOnGeomEdge\n");
     816                if(verbose>5) _printLine_("      writing EdgesOnGeomEdge");
    817817                k=0;
    818818                for (i=0;i<nbe;i++){
     
    822822                bamgmesh->EdgesOnGeomEdgeSize[1]=2;
    823823                if (k){
    824                         bamgmesh->EdgesOnGeomEdge=(double*)xmalloc(2*(int)k*sizeof(double));
     824                        bamgmesh->EdgesOnGeomEdge=xNew<double>(2*(int)k);
    825825                        int count=0;
    826826                        for (i=0;i<nbe;i++){
     
    834834
    835835                /*Element Connectivity*/
    836                 if(verbose>5) printf("      writing Element connectivity\n");
     836                if(verbose>5) _printLine_("      writing Element connectivity");
    837837                bamgmesh->ElementConnectivitySize[0]=nbt-nbtout;
    838838                bamgmesh->ElementConnectivitySize[1]=3;
    839                 bamgmesh->ElementConnectivity=(double*)xmalloc(3*(nbt-nbtout)*sizeof(double));
     839                bamgmesh->ElementConnectivity=xNew<double>(3*(nbt-nbtout));
    840840                for (i=0;i<3*(nbt-nbtout);i++) bamgmesh->ElementConnectivity[i]=NAN;
    841841                num=0;
     
    854854
    855855                /*ElementNodal Connectivity*/
    856                 if(verbose>5) printf("      writing Nodal element connectivity\n");
     856                if(verbose>5) _printLine_("      writing Nodal element connectivity");
    857857                bamgmesh->NodalElementConnectivitySize[0]=nbv;
    858858                bamgmesh->NodalElementConnectivitySize[1]=connectivitymax_1;
    859                 bamgmesh->NodalElementConnectivity=(double*)xmalloc(connectivitymax_1*nbv*sizeof(double));
     859                bamgmesh->NodalElementConnectivity=xNew<double>(connectivitymax_1*nbv);
    860860                for (i=0;i<connectivitymax_1*nbv;i++) bamgmesh->NodalElementConnectivity[i]=NAN;
    861861                for (i=0;i<nbv;i++){
     
    869869
    870870                /*Nodal Connectivity*/
    871                 if(verbose>5) printf("      writing Nodal connectivity\n");
     871                if(verbose>5) _printLine_("      writing Nodal connectivity");
    872872                //chaining algorithm (again...)
    873873                int* head_2=NULL;
     
    877877                i1=bamgmesh->IssmEdgesSize[0];
    878878                i2=bamgmesh->IssmEdgesSize[1];
    879                 head_2=(int*)xmalloc(nbv*sizeof(int));
    880                 next_2=(int*)xmalloc(2*i1*sizeof(int));
    881                 connectivitysize_2=(int*)xmalloc(nbv*sizeof(int));
     879                head_2=xNew<int>(nbv);
     880                next_2=xNew<int>(2*i1);
     881                connectivitysize_2=xNew<int>(nbv);
    882882                //Initialization
    883883                for (i=0;i<nbv;i++) head_2[i]=-1;
     
    888888                        for (j=0;j<2;j++){
    889889                                int v=(int)bamgmesh->IssmEdges[i*i2+j]-1; //back to C indexing
    890                                 if (k>2*i1-1 || k<0) _error_("Index exceed matrix dimensions (k=%i not in [0 %i]",k,2*i1-1);
     890                                if (k>2*i1-1 || k<0) _error2_("Index exceed matrix dimensions (k=" << k << " not in [0 " << 2*i1-1 << "]");
    891891                                next_2[k]=head_2[v];
    892                                 if (v>nbv-1 || v<0)   _error_("Index exceed matrix dimensions (v=%i not in [0 %i])",v,nbv-1);
     892                                if (v>nbv-1 || v<0)   _error2_("Index exceed matrix dimensions (v=" << v << " not in [0 " << nbv-1 << "])");
    893893                                head_2[v]=k++;
    894894                                connectivitysize_2[v]+=1;
     
    902902                bamgmesh->NodalConnectivitySize[0]=nbv;
    903903                bamgmesh->NodalConnectivitySize[1]=connectivitymax_2;
    904                 bamgmesh->NodalConnectivity=(double*)xmalloc(connectivitymax_2*nbv*sizeof(double));
     904                bamgmesh->NodalConnectivity=xNew<double>(connectivitymax_2*nbv);
    905905                for (i=0;i<connectivitymax_2*nbv;i++) bamgmesh->NodalConnectivity[i]=NAN;
    906906                for (i=0;i<nbv;i++){
     
    921921
    922922                /*Cracked vertices*/
    923                 if(verbose>5) printf("      writing Cracked vertices\n");
     923                if(verbose>5) _printLine_("      writing Cracked vertices");
    924924                bamgmesh->CrackedVerticesSize[0]=NbCrackedVertices;
    925925                bamgmesh->CrackedVerticesSize[1]=2;
    926926                if (NbCrackedVertices){
    927                         bamgmesh->CrackedVertices=(double*)xmalloc(2*NbCrackedVertices*sizeof(double));
     927                        bamgmesh->CrackedVertices=xNew<double>(2*NbCrackedVertices);
    928928                        for (i=0;i<NbCrackedVertices;i++){
    929929                                bamgmesh->CrackedVertices[i*2+0]=CrackedVertices[i*2+0]+1; //M indexing
     
    933933
    934934                /*Cracked vertices*/
    935                 if(verbose>5) printf("      writing Cracked vertices\n");
     935                if(verbose>5) _printLine_("      writing Cracked vertices");
    936936                bamgmesh->CrackedEdgesSize[0]=NbCrackedEdges;
    937937                bamgmesh->CrackedEdgesSize[1]=4;
    938938                if (NbCrackedEdges){
    939                         bamgmesh->CrackedEdges=(double*)xmalloc(2*NbCrackedEdges*sizeof(double));
     939                        bamgmesh->CrackedEdges=xNew<double>(2*NbCrackedEdges);
    940940                        for (i=0;i<NbCrackedEdges;i++){
    941941                                bamgmesh->CrackedEdges[i*2+0]=0;//CrackedEdges[i]->+1; //M indexing
     
    945945
    946946                //clean up
    947                 xfree((void**)&connectivitysize_1);
    948                 xfree((void**)&head_1);
    949                 xfree((void**)&next_1);
    950                 xfree((void**)&connectivitysize_2);
    951                 xfree((void**)&head_2);
    952                 xfree((void**)&next_2);
     947                xDelete<int>(connectivitysize_1);
     948                xDelete<int>(head_1);
     949                xDelete<int>(next_1);
     950                xDelete<int>(connectivitysize_2);
     951                xDelete<int>(head_2);
     952                xDelete<int>(next_2);
    953953                delete [] reft;
    954954                delete [] numt;
    955955        }
    956         /*}}}1*/
    957         /*FUNCTION Mesh::ReadMetric{{{1*/
     956        /*}}}*/
     957        /*FUNCTION Mesh::ReadMetric{{{*/
    958958        void Mesh::ReadMetric(const BamgOpts* bamgopts) {
    959959
     
    961961                int  i,j;
    962962
    963                 if(bamgopts->verbose>3) printf("      processing metric\n");
     963                if(bamgopts->verbose>3) _printLine_("      processing metric");
    964964                double hmin = Max(bamgopts->hmin,MinimalHmin());
    965965                double hmax = Min(bamgopts->hmax,MaximalHmax());
     
    992992                }
    993993        }
    994         /*}}}1*/
    995         /*FUNCTION Mesh::WriteMetric{{{1*/
     994        /*}}}*/
     995        /*FUNCTION Mesh::WriteMetric{{{*/
    996996        void Mesh::WriteMetric(BamgOpts* bamgopts) {
    997997                int i;
    998                 xfree((void**)&bamgopts->metric);
    999                 bamgopts->metric=(double*)xmalloc(3*nbv*sizeof(double));
     998                xDelete<double>(bamgopts->metric);
     999                bamgopts->metric=xNew<double>(3*nbv);
    10001000                for (i=0;i<nbv;i++){
    10011001                        bamgopts->metric[i*3+0]=vertices[i].m.a11;
     
    10041004                }
    10051005        }
    1006         /*}}}1*/
    1007         /*FUNCTION Mesh::WriteIndex{{{1*/
     1006        /*}}}*/
     1007        /*FUNCTION Mesh::WriteIndex{{{*/
    10081008        void Mesh::WriteIndex(int** pindex,int* pnels){
    10091009
     
    10231023
    10241024                if (k){
    1025                         index=(int*)xmalloc(3*k*sizeof(double));
     1025                        index=xNew<int>(3*k);
    10261026                        num=0;
    10271027                        for (i=0;i<nbt;i++){
    10281028                                Triangle &t=triangles[i];
    10291029                                if (t.det>0 && !(t.Hidden(0)||t.Hidden(1) || t.Hidden(2) )){
    1030                                         if(t.Anisotropy()<2 & t.Length()<1.e+5){
     1030                                        //if(t.Anisotropy()<2 & t.Length()<1.e+5){
    10311031                                                index[num*3+0]=GetId(t[0])+1; //back to M indexing
    10321032                                                index[num*3+1]=GetId(t[1])+1; //back to M indexing
    10331033                                                index[num*3+2]=GetId(t[2])+1; //back to M indexing
    10341034                                                num=num+1;
    1035                                         }
     1035                                        //}
    10361036                                }
    10371037                        }
     
    10421042                *pnels=num;
    10431043        }
    1044         /*}}}1*/
     1044        /*}}}*/
    10451045
    10461046        /*Methods*/
    1047         /*FUNCTION Mesh::AddGeometryMetric{{{1*/
     1047        /*FUNCTION Mesh::AddGeometryMetric{{{*/
    10481048        void Mesh::AddGeometryMetric(BamgOpts* bamgopts){
    10491049                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Metric.cpp/IntersectGeomMetric)*/
     
    10611061                //check that hmax is positive
    10621062                if (hmax<=0){
    1063                         _error_("hmax<=0");
     1063                        _error2_("hmax<=0");
    10641064                }
    10651065
     
    10901090
    10911091                                if (ht<=0 || hn<=0){
    1092                                         _error_("ht<=0 || hn<=0");
     1092                                        _error2_("ht<=0 || hn<=0");
    10931093                                }
    10941094                                EigenMetric Vp(1/(ht*ht),1/(hn*hn),tg);
     
    10991099                // the problem is for the vertex on vertex
    11001100        }
    1101         /*}}}1*/
    1102         /*FUNCTION Mesh::AddMetric{{{1*/
     1101        /*}}}*/
     1102        /*FUNCTION Mesh::AddMetric{{{*/
    11031103        void Mesh::AddMetric(BamgOpts* bamgopts){
    11041104                //  Hessiantype = 0 =>  H is computed using double P2 projection
     
    11151115                }
    11161116                else{
    1117                         _error_("Hessiantype %i not supported yet (1->use Green formula, 0-> double P2 projection)",Hessiantype);
    1118                 }
    1119         }
    1120         /*}}}1*/
    1121         /*FUNCTION Mesh::AddVertex{{{1*/
     1117                        _error2_("Hessiantype " << Hessiantype << " not supported yet (1->use Green formula, 0-> double P2 projection)");
     1118                }
     1119        }
     1120        /*}}}*/
     1121        /*FUNCTION Mesh::AddVertex{{{*/
    11221122        void Mesh::AddVertex( BamgVertex &s,Triangle* t, Icoor2* det3) {
    11231123                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/Add)*/
     
    11591159                //some checks
    11601160                if (( infvertexindex <0 ) && (detOld <0) ||  ( infvertexindex >=0  ) && (detOld >0) ){
    1161                         _error_("inconsistent configuration (Contact ISSM developers)");
     1161                        _error2_("inconsistent configuration (Contact ISSM developers)");
    11621162                }
    11631163
     
    12011201                        }
    12021202                        else{
    1203                                 _error_("Cannot add a vertex more than once. Check duplicates");
     1203                                _error2_("Cannot add a vertex more than once. Check duplicates");
    12041204                        }
    12051205                }
     
    12141214                tt[2]= &triangles[nbt++];
    12151215
    1216                 if (nbt>maxnbt) _error_("Not enough triangles");
     1216                if (nbt>maxnbt) _error2_("Not enough triangles");
    12171217
    12181218                *tt[1]=*tt[2]=*t;
     
    12511251
    12521252                        if (!rswap) {
    1253                                 _error_("swap the point s is on a edge");
    1254                         }
    1255                 }
    1256         }
    1257         /*}}}1*/
    1258         /*FUNCTION Mesh::BoundAnisotropy{{{1*/
     1253                                _error2_("swap the point s is on a edge");
     1254                        }
     1255                }
     1256        }
     1257        /*}}}*/
     1258        /*FUNCTION Mesh::BoundAnisotropy{{{*/
    12591259        void  Mesh::BoundAnisotropy(double anisomax,double hminaniso) {
    12601260                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Metric.cpp/BoundAnisotropy)*/
     
    12641264
    12651265                //display info
    1266                 if (verbose > 1)  printf("   BoundAnisotropy by %g\n",anisomax);
     1266                if (verbose > 1)  _printLine_("   BoundAnisotropy by " << anisomax);
    12671267
    12681268                double h1=1.e30,h2=1e-30;
     
    12911291                //display info
    12921292                if (verbose>2){
    1293                         printf("      input:  Hmin = %g, Hmax = %g, factor of anisotropy max  = %g\n",pow(h2,-0.5),pow(h1,-0.5),pow(rx,0.5));
    1294                         printf("      output: Hmin = %g, Hmax = %g, factor of anisotropy max  = %g\n",pow(hn2,-0.5),pow(hn1,-0.5),pow(rnx,0.5));
    1295                 }
    1296         }
    1297         /*}}}1*/
    1298         /*FUNCTION Mesh::BuildGeometryFromMesh{{{1*/
     1293                        _printLine_("      input:  Hmin = " << pow(h2,-0.5)  << ", Hmax = " << pow(h1,-0.5) << ", factor of anisotropy max  = " << pow(rx,0.5));
     1294                        _printLine_("      output: Hmin = " << pow(hn2,-0.5) << ", Hmax = " << pow(hn1,-0.5)<< ", factor of anisotropy max  = " <<pow(rnx,0.5));
     1295                }
     1296        }
     1297        /*}}}*/
     1298        /*FUNCTION Mesh::BuildGeometryFromMesh{{{*/
    12991299        void Mesh::BuildGeometryFromMesh(BamgOpts* bamgopts){
    13001300                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshGeom.cpp/ConsGeometry)*/
     
    13141314
    13151315                //display info
    1316                 if (verbose>1) printf("   construction of the geometry from the 2d mesh\n");
     1316                if (verbose>1) _printLine_("   construction of the geometry from the 2d mesh");
    13171317
    13181318                //check that the mesh is not empty
    13191319                if (nbt<=0 || nbv <=0 ) {
    1320                         _error_("nbt or nbv is negative (Mesh empty?)");
     1320                        _error2_("nbt or nbv is negative (Mesh empty?)");
    13211321                }
    13221322
     
    13401340                if (nbe !=  edge4->nb()){
    13411341                        delete [] st;
    1342                         _error_("Some Double edge in the mesh, the number is %i, nbe4=%i",nbe,edge4->nb());
     1342                        _error2_("Some Double edge in the mesh, the number is " << nbe << ", nbe4=" << edge4->nb());
    13431343                }
    13441344                //keep nbe in nbeold
     
    13601360                                        //check that it is not an edge on boundary (should not already exist)
    13611361                                        if (triangles[i].TriangleAdj(j) || triangles[st[k]/3].TriangleAdj((int) (st[k]%3))){
    1362                                                 _error_("problem in Geometry reconstruction: an edge on boundary is duplicated (double element?)");
     1362                                                _error2_("problem in Geometry reconstruction: an edge on boundary is duplicated (double element?)");
    13631363                                        }
    13641364                                        //OK, the element is not on boundary, is belongs to 2 triangles -> build Adjacent triangles list
     
    13741374                                //else (see 3 lines above), the edge has been called more than twice: return error
    13751375                                else {
    1376                                         printf("The edge (%i,%i) belongs to more than 2 triangles (%i)\n",GetId(triangles[i][VerticesOfTriangularEdge[j][0]]),GetId(triangles[i][VerticesOfTriangularEdge[j][1]]),k);
    1377                                         printf("Edge %i of triangle %i\n",j,i);
    1378                                         printf("Edge %i of triangle %i\n",(-st[k]+2)%3,(-st[k]+2)/3);
    1379                                         printf("Edge %i of triangle %i\n",triangles[(-st[k]+2)/3].NuEdgeTriangleAdj((int)((-st[k]+2)%3)),GetId(triangles[(-st[k]+2)/3].TriangleAdj((int)((-st[k]+2)%3))));
    1380                                         _error_("An edge belongs to more than 2 triangles");
     1376                                        _printLine_("The edge (" << GetId(triangles[i][VerticesOfTriangularEdge[j][0]]) << "," << GetId(triangles[i][VerticesOfTriangularEdge[j][1]]) << ") belongs to more than 2 triangles (" << k << ")");
     1377                                        _printLine_("Edge " << j << " of triangle " << i);
     1378                                        _printLine_("Edge " << (-st[k]+2)%3 << " of triangle " << (-st[k]+2)/3);
     1379                                        _printLine_("Edge " << triangles[(-st[k]+2)/3].NuEdgeTriangleAdj((int)((-st[k]+2)%3)) << " of triangle " << GetId(triangles[(-st[k]+2)/3].TriangleAdj((int)((-st[k]+2)%3))));
     1380                                        _error2_("An edge belongs to more than 2 triangles");
    13811381                                }       
    13821382                        }
     
    13891389                //display info
    13901390                if(verbose>5) {
    1391                         printf("         info on Mesh:\n");
    1392                         printf("            - number of vertices    = %i \n",nbv);
    1393                         printf("            - number of triangles   = %i \n",nbt);
    1394                         printf("            - number of given edges = %i \n",nbe);
    1395                         printf("            - number of all edges   = %i \n",nbedges);
    1396                         printf("            - Euler number 1 - nb of holes = %i \n"  ,nbt-nbedges+nbv);
     1391                        _printLine_("         info on Mesh:");
     1392                        _printLine_("            - number of vertices    = " << nbv);
     1393                        _printLine_("            - number of triangles   = " << nbt);
     1394                        _printLine_("            - number of given edges = " << nbe);
     1395                        _printLine_("            - number of all edges   = " << nbedges);
     1396                        _printLine_("            - Euler number 1 - nb of holes = " << nbt-nbedges+nbv);
    13971397                }
    13981398
     
    14251425
    14261426                        //display info
    1427                         if(verbose>4) printf("   Construction of the edges %i\n",nbe);
     1427                        if(verbose>4) _printLine_("   Construction of the edges " << nbe);
    14281428
    14291429                        for (i=0;i<nbedges;i++){
     
    14511451                                                edges[add].ReferenceNumber=edgessave[i].ReferenceNumber;                     
    14521452                                                edges[add].GeomEdgeHook=edgessave[i].GeomEdgeHook; //  HACK to get required edges
    1453                                                 printf("oh no...\n");
     1453                                                _printLine_("oh no...");
    14541454                                        }
    14551455                                        else
     
    14601460                        //check that we have been through all edges
    14611461                        if (k!=nbe){
    1462                                 _error_("problem in edge construction process: k!=nbe (should not happen)");
     1462                                _error2_("problem in edge construction process: k!=nbe (should not happen)");
    14631463                        }
    14641464                        //delete edgessave
     
    15051505                                        //check that we have the correct vertex
    15061506                                        if (v!=edges[i0 ].v[j0]){
    1507                                                 _error_("v!=edges[i0 ].v[j0]: this should not happen as the vertex belongs to this edge");
     1507                                                _error2_("v!=edges[i0 ].v[j0]: this should not happen as the vertex belongs to this edge");
    15081508                                        }
    15091509
     
    15221522                //check that nbsubdomains is empty
    15231523                if (nbsubdomains){
    1524                         _error_("nbsubdomains should be 0");
     1524                        _error2_("nbsubdomains should be 0");
    15251525                }
    15261526                nbsubdomains=0;
     
    15661566                        }
    15671567                }
    1568                 if (verbose> 3) printf("      The Number of sub domain = %i\n",nbsubdomains);
     1568                if (verbose> 3) _printLine_("      The Number of sub domain = " << nbsubdomains);
    15691569
    15701570                //build subdomains
     
    15911591                if (k!= nbsubdomains){
    15921592                        delete [] colorT;
    1593                         _error_("k!= nbsubdomains");
     1593                        _error2_("k!= nbsubdomains");
    15941594                }
    15951595                //delete colorT and st
     
    16181618                Gh.nbsubdomains = nbsubdomains;
    16191619                Gh.subdomains = new GeomSubDomain[nbsubdomains];
    1620                 if (verbose>3) printf("   number of vertices = %i\n   number of edges = %i\n",Gh.nbv,Gh.nbe);
     1620                if (verbose>3) _printLine_("   number of vertices = " << Gh.nbv << "\n   number of edges = " << Gh.nbe);
    16211621                NbVerticesOnGeomVertex = Gh.nbv;
    16221622                VerticesOnGeomVertex = new VertexOnGeom[NbVerticesOnGeomVertex];
     
    16521652                if (Gh.coefIcoor<=0){
    16531653                        delete [] colorV;
    1654                         _error_("Gh.coefIcoor<=0 in infered Geometry (this should not happen)");
     1654                        _error2_("Gh.coefIcoor<=0 in infered Geometry (this should not happen)");
    16551655                }
    16561656
     
    17051705                                delete [] len;
    17061706                                delete [] colorV;
    1707                                 _error_("problem in Edge4 construction: k != i");
     1707                                _error2_("problem in Edge4 construction: k != i");
    17081708                        }
    17091709                }
     
    17341734                        }
    17351735                        else
    1736                          _error_("%i should be >=0");
     1736                         _error2_("%i should be >=0");
    17371737                  }
    17381738
     
    17481748
    17491749        }
    1750         /*}}}1*/
    1751         /*FUNCTION Mesh::BuildMetric0 (double P2 projection){{{1*/
     1750        /*}}}*/
     1751        /*FUNCTION Mesh::BuildMetric0 (double P2 projection){{{*/
    17521752        void Mesh::BuildMetric0(BamgOpts* bamgopts){
    17531753
     
    17681768
    17691769                /*Check size*/
    1770                 if (bamgopts->fieldSize[0] != nbv) _error_("'field' should have %i rows",nbv);
     1770                if (bamgopts->fieldSize[0] != nbv) _error2_("'field' should have " << nbv << " rows");
    17711771
    17721772                //initialization of some variables
     
    17901790                //display infos
    17911791                if(verbose>1) {
    1792                         printf("   Construction of Metric: number of field: %i (nbt=%i, nbv=%i)\n",nbsol,nbt,nbv);
     1792                        _printLine_("   Construction of Metric: number of field: " << nbsol << " (nbt=" << nbt << ", nbv=" << nbv << ")");
    17931793                }
    17941794
    17951795                //first, build the chains that will be used for the Hessian computation, as weel as the area of each element
    17961796                int* head_s=NULL;
    1797                 head_s=(int*)xmalloc(nbv*sizeof(int));
     1797                head_s=xNew<int>(nbv);
    17981798                int* next_p=NULL;
    1799                 next_p=(int*)xmalloc(3*nbt*sizeof(int));
     1799                next_p=xNew<int>(3*nbt);
    18001800                int  p=0;
    18011801                //initialization
     
    18621862
    18631863                        //display info
    1864                         if(verbose>2) printf("      Solution %i, Min = %g, Max = %g, Delta = %g\n",nusol,smin,smax,sdelta);
     1864                        if(verbose>2) _printLine_("      Solution " << nusol << ", Min = " << smin << ", Max = " << smax << ", Delta = " << sdelta);
    18651865
    18661866                        //skip constant field
    18671867                        if (sdelta < 1.0e-10*Max(absmax,1e-20)){
    1868                                 printf("      Solution %i is constant, skipping...\n",nusol);
     1868                                _printLine_("      Solution " << nusol << " is constant, skipping...");
    18691869                                continue;
    18701870                        }
     
    19361936
    19371937                //clean up
    1938                 xfree((void**)&head_s);
    1939                 xfree((void**)&next_p);
     1938                xDelete<int>(head_s);
     1939                xDelete<int>(next_p);
    19401940                delete [] detT;
    19411941                delete [] alpha;
     
    19531953                delete [] dydy_vertex;
    19541954        }
    1955         /*}}}1*/
    1956         /*FUNCTION Mesh::BuildMetric1 (Green formula){{{1*/
     1955        /*}}}*/
     1956        /*FUNCTION Mesh::BuildMetric1 (Green formula){{{*/
    19571957        void Mesh::BuildMetric1(BamgOpts* bamgopts){
    19581958                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Metric.cpp/IntersectConsMetric)*/
     
    19731973
    19741974                /*Check size*/
    1975                 if (bamgopts->fieldSize[0] != nbv) _error_("'field' should have %i rows",nbv);
     1975                if (bamgopts->fieldSize[0] != nbv) _error2_("'field' should have " << nbv << " rows");
    19761976
    19771977                //initialization of some variables
     
    19921992                //display infos
    19931993                if(verbose>1) {
    1994                         printf("   Construction of Metric: number of field: %i (nbt=%i, nbv=%i)\n",nbsol,nbt,nbv);
     1994                        _printLine_("   Construction of Metric: number of field: " << nbsol << " (nbt=" << nbt << ", nbv=" << nbv << ")");
    19951995                }
    19961996
     
    20752075
    20762076                        //display info
    2077                         if(verbose>2) printf("      Solution %i, Min = %g, Max = %g, Delta = %g, number of fields = %i\n",nusol,smin,smax,sdelta,nbsol);
     2077                        if(verbose>2) _printLine_("      Solution " << nusol << ", Min = " << smin << ", Max = " << smax << ", Delta = " << sdelta << ", number of fields = " << nbsol);
    20782078
    20792079                        //skip constant field
    20802080                        if (sdelta < 1.0e-10*Max(absmax,1e-20) ){
    2081                                 if (verbose>2) printf("      Solution %i is constant, skipping...\n",nusol);
     2081                                if (verbose>2) _printLine_("      Solution " << nusol << " is constant, skipping...");
    20822082                                continue;
    20832083                        }
     
    22442244
    22452245        }
    2246         /*}}}1*/
    2247         /*FUNCTION Mesh::CrackMesh{{{1*/
     2246        /*}}}*/
     2247        /*FUNCTION Mesh::CrackMesh{{{*/
    22482248        void Mesh::CrackMesh(BamgOpts* bamgopts) {
    22492249                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/CrackMesh)*/
     
    22642264                //Return if no edge is cracked
    22652265                if(k==0) return;
    2266                 if (verbose>4) printf("      number of Cracked Edges = %i\n",k);
     2266                if (verbose>4) _printLine_("      number of Cracked Edges = " << k);
    22672267
    22682268                //Initialize Cracked edge
     
    22982298                                if (splitvertex[i1]==3 || splitvertex[i2]==3){
    22992299                                        delete [] splitvertex;
    2300                                         _error_("Crossing rifts not supported yet");
     2300                                        _error2_("Crossing rifts not supported yet");
    23012301                                }
    23022302                        }
     
    23052305
    23062306                //Add new vertices
    2307                 if (verbose>4) printf("      number of Cracked Vertices = %i\n",NbCrackedVertices);
     2307                if (verbose>4) _printLine_("      number of Cracked Vertices = " << NbCrackedVertices);
    23082308                if (NbCrackedVertices){
    2309                         CrackedVertices=(long*)xmalloc(2*NbCrackedVertices*sizeof(double));
     2309                        CrackedVertices=xNew<long>(2*NbCrackedVertices);
    23102310                        num=0;
    23112311                        for (i=0;i<nbv;i++){
     
    23742374                                        }
    23752375                                }
    2376                                 //printf("%i -> %i %i %i, edge [%i->%i %i->%i]\n",element_renu[GetId(ta.t)],GetId((*ta.t)[0])+1,GetId((*ta.t)[1])+1,GetId((*ta.t)[2])+1,i1,j1,i2,j2);
     2376                                //_printLine_(element_renu[GetId(ta.t)] << " -> " << GetId((*ta.t)[0])+1 << " " << GetId((*ta.t)[1])+1 << " " << GetId((*ta.t)[2])+1 << ", edge [" << i1 << "->" << j1 << " " << i2 << "->" << j2 << "]");
    23772377                                ta = Next(ta).Adj();
    2378                                 if (count++>50) _error_("Maximum number of iteration exceeded");
     2378                                if (count++>50) _error2_("Maximum number of iteration exceeded");
    23792379                        }while ((tbegin != ta));
    23802380                }
     
    23832383                for(i=0;i<NbCrackedEdges;i++){
    23842384                        if (Edgeflags[i]!=2){
    2385                                 _error_("A problem occured: at least one crack edge (number %i) does not belong to 2 elements",i+1);
     2385                                _error2_("A problem occured: at least one crack edge (number " << i+1 << ") does not belong to 2 elements");
    23862386                        }
    23872387                }
     
    23922392
    23932393        }
    2394         /*}}}1*/
    2395         /*FUNCTION Mesh::Echo{{{1*/
     2394        /*}}}*/
     2395        /*FUNCTION Mesh::Echo{{{*/
    23962396        void Mesh::Echo(void) {
    23972397
    23982398                int i;
    23992399
    2400                 printf("Mesh Echo:\n");
    2401                 printf("   nbv = %i\n",nbv);
    2402                 printf("   nbt = %i\n",nbt);
    2403                 printf("   nbe = %i\n",nbe);
    2404                 printf("   nbq = %i\n",nbq);
    2405                 printf("   index:\n");
     2400                _printLine_("Mesh Echo:");
     2401                _printLine_("   nbv = " << nbv);
     2402                _printLine_("   nbt = " << nbt);
     2403                _printLine_("   nbe = " << nbe);
     2404                _printLine_("   nbq = " << nbq);
     2405                _printLine_("   index:");
    24062406                for (i=0;i<nbt;i++){
    2407                         printf("   %4i: [%4i %4i %4i]\n",i+1,
    2408                                                 ((BamgVertex *)triangles[i](0))?GetId(triangles[i][0])+1:0,
    2409                                                 ((BamgVertex *)triangles[i](1))?GetId(triangles[i][1])+1:0,
    2410                                                 ((BamgVertex *)triangles[i](2))?GetId(triangles[i][2])+1:0);
    2411                 }
    2412                 printf("   coordinates:\n");
     2407                        _printLine_("   " << setw(4) << i+1 << ": ["
     2408                                                << setw(4) << (((BamgVertex *)triangles[i](0))?GetId(triangles[i][0])+1:0) << " "
     2409                                                << setw(4) << (((BamgVertex *)triangles[i](0))?GetId(triangles[i][1])+1:0) << " "
     2410                                                << setw(4) << (((BamgVertex *)triangles[i](0))?GetId(triangles[i][2])+1:0) << "]");
     2411                }
     2412                _printLine_("   coordinates:");
    24132413                for (i=0;i<nbv;i++){
    2414                         printf("   %4i: [%g %g]\n",i+1,vertices[i].r.x,vertices[i].r.y);
    2415                 }
    2416 
    2417         }
    2418         /*}}}1*/
    2419         /*FUNCTION Mesh::ForceBoundary{{{1*/
     2414                        _printLine_("   " << setw(4) << i+1 << ": [" << vertices[i].r.x << " " << vertices[i].r.y << "]");
     2415                }
     2416
     2417        }
     2418        /*}}}*/
     2419        /*FUNCTION Mesh::ForceBoundary{{{*/
    24202420                void Mesh::ForceBoundary() {
    24212421                        /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/ForceBoundary)*/
     
    24262426
    24272427                        //display
    2428                         if (verbose > 2) printf("   ForceBoundary  nb of edge: %i\n",nbe);
     2428                        if (verbose > 2) _printLine_("   ForceBoundary  nb of edge: " << nbe);
    24292429
    24302430                        //check that there is no triangle with 0 determinant
     
    24332433                        }
    24342434                        if (k!=0) {
    2435                                 _error_("there is %i triangles of mes = 0",k);
     2435                                _error2_("there is " << k << " triangles of mes = 0");
    24362436                        }
    24372437
     
    24472447                                if (nbswp) nbfe++;
    24482448                                if ( nbswp < 0 && k < 5){
    2449                                         _error_("Missing Edge %i, v0=%i,v1=%i",i,GetId(edges[i][0]),GetId(edges[i][1]));
     2449                                        _error2_("Missing Edge " << i << ", v0=" << GetId(edges[i][0]) << ",v1=" << GetId(edges[i][1]));
    24502450                                }
    24512451                        }
    24522452
    24532453                        if (k!=0) {
    2454                                 _error_("There are %i lost edges, the boundary might be crossing",k);
     2454                                _error2_("There are " << k << " lost edges, the boundary might be crossing");
    24552455                        }
    24562456                        for (int j=0;j<nbv;j++){
    24572457                                Nbswap +=  vertices[j].Optim(1,0);
    24582458                        }
    2459                         if (verbose > 3) printf("      number of inforced edge = %i, number of swap= %i\n",nbfe,Nbswap);
    2460                 }
    2461         /*}}}1*/
    2462         /*FUNCTION Mesh::FindSubDomain{{{1*/
     2459                        if (verbose > 3) _printLine_("      number of inforced edge = " << nbfe << ", number of swap= " << Nbswap);
     2460                }
     2461        /*}}}*/
     2462        /*FUNCTION Mesh::FindSubDomain{{{*/
    24632463        void Mesh::FindSubDomain(int OutSide) {
    24642464                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/FindSubDomain)*/
     
    24672467
    24682468                if (verbose >2){
    2469                         if (OutSide) printf("   Find all external sub-domain\n");
    2470                         else printf("   Find all internal sub-domain\n");
     2469                        if (OutSide) _printLine_("   Find all external sub-domain");
     2470                        else _printLine_("   Find all internal sub-domain");
    24712471                  }
    24722472                short * HeapArete = new short[nbt];
     
    25342534                        if (nbt == nbtout ||  !NbSubDomTot) {
    25352535                                delete [] HeapArete;
    2536                                 _error_("The boundary is not close: all triangles are outside");
     2536                                _error2_("The boundary is not close: all triangles are outside");
    25372537                        }
    25382538
     
    25722572                                                if (k!=nbsubdomains){
    25732573                                                        delete [] mark;
    2574                                                         _error_("k!=nbsubdomains");
     2574                                                        _error2_("k!=nbsubdomains");
    25752575                                                }
    25762576                                                if(OutSide)
     
    26132613                                                                 }//while (t)
    26142614                                                                }
    2615                                                         if(verbose>4) printf("      Number of removes subdomains (OutSideMesh) = %i\n",nbsubdomains-j);
     2615                                                        if(verbose>4) _printLine_("      Number of removes subdomains (OutSideMesh) = " << nbsubdomains-j);
    26162616                                                        nbsubdomains=j;
    26172617                                                  }
     
    26622662                                                         subdomains[i].head=t=ta;
    26632663                                                        if(t<triangles || t >= triangles+nbt || t->det < 0 || t->link == 0) {
    2664                                                                 _error_("bad definition of SubSomain %i",i);
     2664                                                                _error2_("bad definition of SubSomain " << i);
    26652665                                                        }
    26662666                                                        long it = GetId(t);
     
    26772677                                                                kkk++;
    26782678                                                                if (mark[GetId(tt)]>=0){
    2679                                                                         _error_("mark[GetId(tt)]>=0");
     2679                                                                        _error2_("mark[GetId(tt)]>=0");
    26802680                                                                }
    26812681                                                                mark[GetId(tt)]=i;
     
    26862686                                                ta = Previous(Adj(ta));         
    26872687                                                if(t == (Triangle *) ta) {
    2688                                                         _error_("bad definition of SubSomain %i",i);
     2688                                                        _error2_("bad definition of SubSomain " << i);
    26892689                                                }
    26902690                                        }
     
    26922692
    26932693                                if (inew < nbsubdomains) {
    2694                                         if (verbose>5) printf("WARNING: %i SubDomains are being removed\n",nbsubdomains-inew);
     2694                                        if (verbose>5) _printLine_("WARNING: " << nbsubdomains-inew << " SubDomains are being removed");
    26952695                                        nbsubdomains=inew;}
    26962696
     
    27072707                         if(!triangles[it].link)  nbtout++;
    27082708        }
    2709         /*}}}1*/
    2710         /*FUNCTION Mesh::GetId(const Triangle & t) const{{{1*/
     2709        /*}}}*/
     2710        /*FUNCTION Mesh::GetId(const Triangle & t) const{{{*/
    27112711        long Mesh::GetId(const Triangle & t) const  {
    27122712                return &t - triangles;
    27132713        }
    2714         /*}}}1*/
    2715         /*FUNCTION Mesh::GetId(const Triangle * t) const{{{1*/
     2714        /*}}}*/
     2715        /*FUNCTION Mesh::GetId(const Triangle * t) const{{{*/
    27162716        long Mesh::GetId(const Triangle * t) const  {
    27172717                return t - triangles;
    27182718        }
    2719         /*}}}1*/
    2720         /*FUNCTION Mesh::GetId(const BamgVertex & t) const{{{1*/
     2719        /*}}}*/
     2720        /*FUNCTION Mesh::GetId(const BamgVertex & t) const{{{*/
    27212721        long Mesh::GetId(const BamgVertex & t) const  {
    27222722                return &t - vertices;
    27232723        }
    2724         /*}}}1*/
    2725         /*FUNCTION Mesh::GetId(const BamgVertex * t) const{{{1*/
     2724        /*}}}*/
     2725        /*FUNCTION Mesh::GetId(const BamgVertex * t) const{{{*/
    27262726        long Mesh::GetId(const BamgVertex * t) const  {
    27272727                return t - vertices;
    27282728        }
    2729         /*}}}1*/
    2730         /*FUNCTION Mesh::GetId(const Edge & t) const{{{1*/
     2729        /*}}}*/
     2730        /*FUNCTION Mesh::GetId(const Edge & t) const{{{*/
    27312731        long Mesh::GetId(const Edge & t) const  {
    27322732                return &t - edges;
    27332733        }
    2734         /*}}}1*/
    2735         /*FUNCTION Mesh::GetId(const Edge * t) const{{{1*/
     2734        /*}}}*/
     2735        /*FUNCTION Mesh::GetId(const Edge * t) const{{{*/
    27362736        long Mesh::GetId(const Edge * t) const  {
    27372737                return t - edges;
    27382738        }
    2739         /*}}}1*/
    2740         /*FUNCTION Mesh::Init{{{1*/
     2739        /*}}}*/
     2740        /*FUNCTION Mesh::Init{{{*/
    27412741        void Mesh::Init(long maxnbv_in) {
    27422742                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/PreInit)*/
     
    27862786                }
    27872787        }
    2788         /*}}}1*/
    2789         /*FUNCTION Mesh::Insert{{{1*/
     2788        /*}}}*/
     2789        /*FUNCTION Mesh::Insert{{{*/
    27902790        void Mesh::Insert() {
    27912791                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/Insert)*/
     
    28002800
    28012801                //Display info
    2802                 if (verbose>2) printf("   Insert initial %i vertices\n",nbv);
     2802                if (verbose>2) _printLine_("   Insert initial " << nbv << " vertices");
    28032803
    28042804                //Compute integer coordinates for the existing vertices
     
    28482848                        //if i is higher than nbv, it means that all the determinants are 0,
    28492849                        //all vertices are aligned!
    2850                         if  (++i>=nbv) _error_("all the vertices are aligned");
     2850                        if  (++i>=nbv) _error2_("all the vertices are aligned");
    28512851                }
    28522852                // exchange i et 2 in "orderedvertices" so that
     
    28912891                /*Now, add the vertices One by One*/
    28922892                long NbSwap=0;
    2893                 if (verbose>3) printf("   Begining of insertion process...\n");
     2893                if (verbose>3) _printLine_("   Begining of insertion process...");
    28942894
    28952895                for (int icount=2; icount<nbv; icount++) {
     
    29142914                //Display info
    29152915                if (verbose>3) {
    2916                         printf("      NbSwap of insertion: %i\n",NbSwap);
    2917                         printf("      NbSwap/nbv:          %i\n",NbSwap/nbv);
     2916                        _printLine_("      NbSwap of insertion: " << NbSwap);
     2917                        _printLine_("      NbSwap/nbv:          " << NbSwap/nbv);
    29182918                }
    29192919
     
    29292929                         NbSwap += orderedvertices[is1]->Optim(0,0);
    29302930                        if (verbose>3) {
    2931                                 printf("      Optim Loop: %i\n",Nbloop);
    2932                                 printf("      NbSwap/nbv:          %i\n",NbSwap/nbv);
     2931                                _printLine_("      Optim Loop: " << Nbloop);
     2932                                _printLine_("      NbSwap/nbv:          " << NbSwap/nbv);
    29332933                        }
    29342934                        if(!NbSwap) break;
     
    29382938#endif
    29392939        }
    2940         /*}}}1*/
    2941         /*FUNCTION Mesh::InsertNewPoints{{{1*/
     2940        /*}}}*/
     2941        /*FUNCTION Mesh::InsertNewPoints{{{*/
    29422942        long Mesh::InsertNewPoints(long nbvold,long & NbTSwap) {
    29432943                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/InsertNewPoints)*/
     
    29532953
    29542954                //display info if required
    2955                 if (verbose>5) printf("      Try to Insert %i new points\n",nbvnew);
     2955                if (verbose>5) _printLine_("      Try to Insert " << nbvnew << " new points");
    29562956
    29572957                //return if no new points
     
    29842984                                long  j=vj.ReferenceNumber;
    29852985                                if (&vj!=orderedvertices[j]){
    2986                                         _error_("&vj!= orderedvertices[j]");
     2986                                        _error2_("&vj!= orderedvertices[j]");
    29872987                                }
    29882988                                if(i!=j){
     
    29942994                                if (tcvj && !tcvj->link){
    29952995                                        tcvj->Echo();
    2996                                         _error_("problem inserting point in InsertNewPoints (tcvj=%p and tcvj->link=%i)",tcvj,tcvj->link);
     2996                                        _error2_("problem inserting point in InsertNewPoints (tcvj=" << tcvj << " and tcvj->link=" << tcvj->link << ")");
    29972997                                }
    29982998                                quadtree->Add(vj);
     
    30033003                }
    30043004                if (verbose>3) {
    3005                         printf("         number of new points: %i\n",iv);
    3006                         printf("         number of to close (?) points: %i\n",nbv-iv);
    3007                         printf("         number of swap after: %i\n",NbSwap);
     3005                        _printLine_("         number of new points: " << iv);
     3006                        _printLine_("         number of to close (?) points: " << nbv-iv);
     3007                        _printLine_("         number of swap after: " << NbSwap);
    30083008                }
    30093009                nbv = iv;
    30103010
    30113011                for (i=nbvold;i<nbv;i++) NbSwap += vertices[i].Optim(1); 
    3012                 if (verbose>3) printf("   NbSwap=%i\n",NbSwap);
     3012                if (verbose>3) _printLine_("   NbSwap=" << NbSwap);
    30133013
    30143014                NbTSwap +=  NbSwap ;
    30153015                return nbv-nbvold;
    30163016        }
    3017         /*}}}1*/
    3018         /*FUNCTION Mesh::isCracked{{{1*/
     3017        /*}}}*/
     3018        /*FUNCTION Mesh::isCracked{{{*/
    30193019        int Mesh::isCracked() const {
    30203020                return NbCrackedVertices != 0;
    30213021        }
    3022         /*}}}1*/
    3023         /*FUNCTION Mesh::MakeGeomEdgeToEdge{{{1*/
     3022        /*}}}*/
     3023        /*FUNCTION Mesh::MakeGeomEdgeToEdge{{{*/
    30243024        Edge** Mesh::MakeGeomEdgeToEdge() {
    30253025                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/MakeGeomEdgeToEdge)*/
    30263026
    30273027                if (!Gh.nbe){
    3028                         _error_("!Gh.nbe");
     3028                        _error2_("!Gh.nbe");
    30293029                }
    30303030                Edge **e= new (Edge* [Gh.nbe]);
     
    30563056                        if (!e[i]){
    30573057                                kk++;
    3058                                 if(kk<10) printf("BUG: the geometrical edge %i is on no edge curve\n",i);
    3059                         }
    3060                 }
    3061                 if(kk) _error_("See above");
     3058                                if(kk<10) _printLine_("BUG: the geometrical edge " << i << " is on no edge curve");
     3059                        }
     3060                }
     3061                if(kk) _error2_("See above");
    30623062
    30633063                return e;
    30643064        }
    3065         /*}}}1*/
    3066         /*FUNCTION Mesh::MakeQuadrangles{{{1*/
     3065        /*}}}*/
     3066        /*FUNCTION Mesh::MakeQuadrangles{{{*/
    30673067        void Mesh::MakeQuadrangles(double costheta){
    30683068                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/MakeQuadrangles)*/
     
    30703070                long int verbose=0;
    30713071
    3072                 if (verbose>2) printf("MakeQuadrangles costheta = %g\n",costheta);
     3072                if (verbose>2) _printLine_("MakeQuadrangles costheta = " << costheta);
    30733073
    30743074                if (costheta >1) {
    3075                         if (verbose>5) printf("   do nothing: costheta > 1\n");
     3075                        if (verbose>5) _printLine_("   do nothing: costheta > 1");
    30763076                }
    30773077
     
    31003100                        nbq = kk;
    31013101                        if (verbose>2){
    3102                                 printf("   number of quadrilaterals    = %i\n",nbq);
    3103                                 printf("   number of triangles         = %i\n",nbt-nbtout- nbq*2);
    3104                                 printf("   number of outside triangles = %i\n",nbtout);
     3102                                _printLine_("   number of quadrilaterals    = " << nbq);
     3103                                _printLine_("   number of triangles         = " << nbt-nbtout- nbq*2);
     3104                                _printLine_("   number of outside triangles = " << nbtout);
    31053105                        }
    31063106                        delete [] qq;
    31073107        }
    3108         /*}}}1*/
    3109         /*FUNCTION Mesh::MakeBamgQuadtree{{{1*/
     3108        /*}}}*/
     3109        /*FUNCTION Mesh::MakeBamgQuadtree{{{*/
    31103110        void Mesh::MakeBamgQuadtree() { 
    31113111                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/MakeBamgQuadtree)*/
     
    31153115
    31163116        }
    3117         /*}}}1*/
    3118         /*FUNCTION Mesh::MaxinalHmax{{{1*/
     3117        /*}}}*/
     3118        /*FUNCTION Mesh::MaxinalHmax{{{*/
    31193119        double Mesh::MaximalHmax() {
    31203120                return Max(pmax.x-pmin.x,pmax.y-pmin.y);
    31213121        }
    3122         /*}}}1*/
    3123         /*FUNCTION Mesh::MaxSubDivision{{{1*/
     3122        /*}}}*/
     3123        /*FUNCTION Mesh::MaxSubDivision{{{*/
    31243124        void  Mesh::MaxSubDivision(double maxsubdiv) {
    31253125                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Metric.cpp/MaxSubDivision)*/
     
    31283128
    31293129                const  double maxsubdiv2 = maxsubdiv*maxsubdiv;
    3130                 if(verbose>1) printf("   Limit the subdivision of a edges in the new mesh by %g\n",maxsubdiv);
     3130                if(verbose>1) _printLine_("   Limit the subdivision of a edges in the new mesh by " << maxsubdiv);
    31313131                // for all the edges
    31323132                // if the len of the edge is to long
     
    31713171                }
    31723172                if(verbose>3){
    3173                         printf("      number of metric changes = %i, maximum number of subdivision of a edges before change = %g\n",nbchange,pow(lmax,0.5));
    3174                 }
    3175         }
    3176         /*}}}1*/
    3177         /*FUNCTION Mesh::MetricAt{{{1*/
     3173                        _printLine_("      number of metric changes = " << nbchange << ", maximum number of subdivision of a edges before change = " << pow(lmax,0.5));
     3174                }
     3175        }
     3176        /*}}}*/
     3177        /*FUNCTION Mesh::MetricAt{{{*/
    31783178        Metric Mesh::MetricAt(const R2 & A) const {
    31793179                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/MetricAt)*/
     
    31953195                }
    31963196        }
    3197         /*}}}1*/
    3198         /*FUNCTION Mesh::MininalHmin{{{1*/
     3197        /*}}}*/
     3198        /*FUNCTION Mesh::MininalHmin{{{*/
    31993199        double Mesh::MinimalHmin() {
    32003200                return 2.0/coefIcoor;
    32013201        }
    3202         /*}}}1*/
    3203 /*FUNCTION Mesh::NearestVertex{{{1*/
     3202        /*}}}*/
     3203/*FUNCTION Mesh::NearestVertex{{{*/
    32043204BamgVertex* Mesh::NearestVertex(Icoor1 i,Icoor1 j) {
    32053205        /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/NearestVertex)*/
    32063206        return  quadtree->NearestVertex(i,j);
    32073207}
    3208 /*}}}1*/
    3209         /*FUNCTION Mesh::NewPoints{{{1*/
     3208/*}}}*/
     3209        /*FUNCTION Mesh::NewPoints{{{*/
    32103210        void  Mesh::NewPoints(Mesh & Bh,BamgOpts* bamgopts,int KeepVertices){
    32113211                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/NewPoints)*/
     
    32253225                /*First, insert old points if requested*/
    32263226                if (KeepVertices && (&Bh != this) && (nbv+Bh.nbv< maxnbv)){
    3227                         if (verbose>5) printf("         Inserting initial mesh points\n");
     3227                        if (verbose>5) _printLine_("         Inserting initial mesh points");
    32283228                        for (i=0;i<Bh.nbv;i++){
    32293229                                BamgVertex &bv=Bh[i];
     
    32443244                // Big loop (most time consuming)
    32453245                int iter=0;
    3246                 if (verbose>5) printf("         Big loop\n");
     3246                if (verbose>5) _printLine_("         Big loop");
    32473247                do {
    32483248                        /*Update variables*/
     
    32583258                                //check i
    32593259                                if (i<0 || i>=nbt ){
    3260                                         _error_("Index problem in NewPoints (i=%i not in [0 %i])",i,nbt-1);
     3260                                        _error2_("Index problem in NewPoints (i=" << i << " not in [0 " << nbt-1 << "])");
    32613261                                }
    32623262                                //change first_np_or_next_t[i]
     
    33093309                                        }
    33103310                                        if (ta.EdgeVertex(0)!=s){
    3311                                                 _error_("ta.EdgeVertex(0)!=s");
     3311                                                _error2_("ta.EdgeVertex(0)!=s");
    33123312                                        }
    33133313                                        ta = Next(Adj(ta));
     
    33263326                NbTSwap +=  NbSwapf ;
    33273327        }
    3328         /*}}}1*/
    3329         /*FUNCTION Mesh::ProjectOnCurve{{{1*/
     3328        /*}}}*/
     3329        /*FUNCTION Mesh::ProjectOnCurve{{{*/
    33303330        GeomEdge*   Mesh::ProjectOnCurve( Edge & BhAB, BamgVertex &  vA, BamgVertex & vB,
    33313331                                double theta,BamgVertex & R,VertexOnEdge &  BR,VertexOnGeom & GR) {
     
    33443344                }
    33453345                else {
    3346                         _error_("ProjectOnCurve On BamgVertex %i forget call to SetVertexFieldOnBTh",BTh.GetId(vA));
     3346                        _error2_("ProjectOnCurve On BamgVertex " << BTh.GetId(vA) << " forget call to SetVertexFieldOnBTh");
    33473347                }
    33483348
     
    33553355                }
    33563356                else {
    3357                         _error_("ProjectOnCurve On BamgVertex %i forget call to SetVertexFieldOnBTh",BTh.GetId(vB));
     3357                        _error2_("ProjectOnCurve On BamgVertex " << BTh.GetId(vB) << " forget call to SetVertexFieldOnBTh");
    33583358                }
    33593359                Edge * e = &BhAB;
    33603360                if (!pA || !pB || !e){
    3361                         _error_("!pA || !pB || !e");
     3361                        _error2_("!pA || !pB || !e");
    33623362                }
    33633363                // be carefull the back ground edge e is on same geom edge
     
    33653365                //check Is a background Mesh;   
    33663366                if (e<BTh.edges || e>=BTh.edges+BTh.nbe){
    3367                         _error_("e<BTh.edges || e>=BTh.edges+BTh.nbe");
     3367                        _error2_("e<BTh.edges || e>=BTh.edges+BTh.nbe");
    33683368                }
    33693369                // walk on BTh edge
     
    33883388                  }
    33893389                else{ // do the search by walking
    3390                         _error_("case not supported yet");
     3390                        _error2_("case not supported yet");
    33913391                  }
    33923392
     
    34523452
    34533453                  }
    3454                 _error_("Big bug...");
     3454                _error2_("Big bug...");
    34553455                return 0; // just for the compiler
    34563456        }                 
    3457         /*}}}1*/
    3458 /*FUNCTION Mesh::ReconstructExistingMesh{{{1*/
     3457        /*}}}*/
     3458/*FUNCTION Mesh::ReconstructExistingMesh{{{*/
    34593459void Mesh::ReconstructExistingMesh(){
    34603460        /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/FillHoleInMesh)*/
     
    34753475        // find extrema coordinates of vertices pmin,pmax
    34763476        long i;
    3477         if(verbose>2) printf("      Reconstruct mesh of %i vertices\n",nbv);
     3477        if(verbose>2) _printLine_("      Reconstruct mesh of " << nbv << " vertices");
    34783478
    34793479        //initialize orderedvertices
     
    34933493        }
    34943494        if (kk != nbe){
    3495                 _error_("There are %i double edges in the mesh",kk-nbe);
     3495                _error2_("There are " << kk-nbe << " double edges in the mesh");
    34963496        }
    34973497
     
    35253525                        //An edge belongs to 2 triangles
    35263526                        else {
    3527                                 _error_("The edge (%i , %i) belongs to more than 2 triangles",GetId(triangles[i][VerticesOfTriangularEdge[j][0]]),GetId(triangles[i][VerticesOfTriangularEdge[j][1]]));
     3527                                _error2_("The edge (" << GetId(triangles[i][VerticesOfTriangularEdge[j][0]]) << " , " << GetId(triangles[i][VerticesOfTriangularEdge[j][1]]) << ") belongs to more than 2 triangles");
    35283528                        }
    35293529                }
     
    35323532        //Display info if required
    35333533        if(verbose>5) {
    3534                 printf("         info of Mesh:\n");
    3535                 printf("            - number of vertices    = %i \n",nbv);
    3536                 printf("            - number of triangles   = %i \n",nbt);
    3537                 printf("            - number of given edges = %i \n",nbe);
    3538                 printf("            - number of all edges   = %i \n"  ,edge4->nb());
    3539                 printf("            - Euler number 1 - nb of holes = %i \n"  ,nbt-edge4->nb()+nbv);
     3534                _printLine_("         info of Mesh:");
     3535                _printLine_("            - number of vertices    = " << nbv << " ");
     3536                _printLine_("            - number of triangles   = " << nbt << " ");
     3537                _printLine_("            - number of given edges = " << nbe << " ");
     3538                _printLine_("            - number of all edges   = " << edge4->nb());
     3539                _printLine_("            - Euler number 1 - nb of holes = " << nbt-edge4->nb()+nbv);
    35403540        }
    35413541
     
    35543554                                if (k<10) {
    35553555                                        //print only 10 edges
    3556                                         printf("Lost boundary edges %i : %i %i\n",i,edge4->i(i),edge4->j(i));
     3556                                        _printLine_("Lost boundary edges " << i << " : " << edge4->i(i) << " " << edge4->j(i));
    35573557                                }
    35583558                                else if (k==10){
    3559                                         printf("Other lost boundary edges not shown...\n");
     3559                                        _printLine_("Other lost boundary edges not shown...");
    35603560                                }
    35613561                        }
     
    35633563        }
    35643564        if(k) {
    3565                 _error_("%i boundary edges (from the geometry) are not defined as mesh edges",k);
     3565                _error2_(k << " boundary edges (from the geometry) are not defined as mesh edges");
    35663566        }
    35673567
     
    35903590        for (i=2;det(orderedvertices[0]->i,orderedvertices[1]->i,orderedvertices[i]->i)==0;)
    35913591         if  (++i>=nbvb) {
    3592                  _error_("ReconstructExistingMesh: All the vertices are aligned");
     3592                 _error2_("ReconstructExistingMesh: All the vertices are aligned");
    35933593         }
    35943594        //Move this vertex (i) to the 2d position in orderedvertices
     
    36503650        }
    36513651        if(nbloss) {
    3652                 _error_("we lost %i existing edges other %i",nbloss,knbe);
     3652                _error2_("we lost " << nbloss << " existing edges other " << knbe);
    36533653        }
    36543654
     
    37253725        subdomains = savesubdomains;
    37263726        if (k) {
    3727                 _error_("number of triangles edges alone = %i",k);
     3727                _error2_("number of triangles edges alone = " << k);
    37283728        }
    37293729        FindSubDomain();
     
    37453745                                        /*Check that the 2 vertices are on geometry AND required*/
    37463746                                        if(!edges[i][j].GeomEdgeHook->IsRequiredVertex()){
    3747                                                 printf("ReconstructExistingMesh error message: problem with the edge number %i: [%i %i]\n",i+1,GetId(edges[i][0])+1,GetId(edges[i][1])+1);
    3748                                                 printf("This edge is on geometrical edge number %i\n",Gh.GetId(edges[i].GeomEdgeHook)+1);
     3747                                                _printLine_("ReconstructExistingMesh error message: problem with the edge number " << i+1 << ": [" << GetId(edges[i][0])+1 << " " << GetId(edges[i][1])+1 << "]");
     3748                                                _printLine_("This edge is on geometrical edge number " << Gh.GetId(edges[i].GeomEdgeHook)+1);
    37493749                                                if (edges[i][j].GeomEdgeHook->OnGeomVertex())
    3750                                                  printf("the vertex number %i of this edge is a geometric BamgVertex number %i\n",GetId(edges[i][j])+1,Gh.GetId(edges[i][j].GeomEdgeHook->gv)+1);
     3750                                                 _printLine_("the vertex number " << GetId(edges[i][j])+1 << " of this edge is a geometric BamgVertex number " << Gh.GetId(edges[i][j].GeomEdgeHook->gv)+1);
    37513751                                                else if (edges[i][j].GeomEdgeHook->OnGeomEdge())
    3752                                                  printf("the vertex number %i of this edge is a geometric Edge number %i\n",GetId(edges[i][j])+1,Gh.GetId(edges[i][j].GeomEdgeHook->ge)+1);
     3752                                                 _printLine_("the vertex number " << GetId(edges[i][j])+1 << " of this edge is a geometric Edge number " << Gh.GetId(edges[i][j].GeomEdgeHook->ge)+1);
    37533753                                                else
    3754                                                  printf("Its pointer is %p\n",edges[i][j].GeomEdgeHook);
    3755 
    3756                                                 printf("This edge is on geometry and has no adjacent edge (open curve) and one of the tip is not required\n");
    3757                                                 _error_("See above (might be cryptic...)");
     3754                                                 _printLine_("Its pointer is " << edges[i][j].GeomEdgeHook);
     3755
     3756                                                _printLine_("This edge is on geometry and has no adjacent edge (open curve) and one of the tip is not required");
     3757                                                _error2_("See above (might be cryptic...)");
    37583758                                        }
    37593759                                }
     
    37623762        }
    37633763}
    3764 /*}}}1*/
    3765         /*FUNCTION Mesh::TrianglesRenumberBySubDomain{{{1*/
     3764/*}}}*/
     3765        /*FUNCTION Mesh::TrianglesRenumberBySubDomain{{{*/
    37663766        void Mesh::TrianglesRenumberBySubDomain(bool justcompress){
    37673767                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/ReNumberingTheTriangleBySubDomain)*/
     
    37783778                        t=t0=subdomains[i].head;
    37793779                        if (!t0){ // not empty sub domain
    3780                                 _error_("!t0");
     3780                                _error2_("!t0");
    37813781                        }
    37823782                        do {
    37833783                                long kt = GetId(t);
    37843784                                if (kt<0 || kt >= nbt ){
    3785                                         _error_("kt<0 || kt >= nbt");
     3785                                        _error2_("kt<0 || kt >= nbt");
    37863786                                }
    37873787                                if (renu[kt]!=-1){
    3788                                         _error_("renu[kt]!=-1");
     3788                                        _error2_("renu[kt]!=-1");
    37893789                                }
    37903790                                renu[kt]=k++;
     
    38033803                }
    38043804                if (k != nbt){
    3805                         _error_("k != nbt");
     3805                        _error2_("k != nbt");
    38063806                }
    38073807                // do the change on all the pointeur
     
    38313831
    38323832        }
    3833         /*}}}1*/
    3834         /*FUNCTION Mesh::VerticesRenumber{{{1*/
     3833        /*}}}*/
     3834        /*FUNCTION Mesh::VerticesRenumber{{{*/
    38353835        void Mesh::VerticesRenumber(long * renu) {
    38363836                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/ReNumberingVertex)*/
     
    38423842                long it,ie,i;
    38433843
    3844                 printf("renumbering triangles\n");
     3844                _printLine_("renumbering triangles");
    38453845                for ( it=0;it<nbt;it++)
    38463846                 triangles[it].Renumbering(vertices,ve,renu);
    38473847
    3848                 printf("renumbering edges\n");
     3848                _printLine_("renumbering edges");
    38493849                for ( ie=0;ie<nbe;ie++)
    38503850                 edges[ie].Renumbering(vertices,ve,renu);
    38513851
    3852                 printf("renumbering vertices on geom\n");
     3852                _printLine_("renumbering vertices on geom");
    38533853                for (i=0;i< NbVerticesOnGeomVertex;i++)
    38543854                  {
     
    38583858                  }
    38593859
    3860                 printf("renumbering vertices on edge\n");
     3860                _printLine_("renumbering vertices on edge");
    38613861                for (i=0;i< NbVerticesOnGeomEdge;i++)
    38623862                  {
     
    38663866                  }
    38673867
    3868                 printf("renumbering vertices on Bth vertex\n");
     3868                _printLine_("renumbering vertices on Bth vertex");
    38693869                for (i=0;i< NbVertexOnBThVertex;i++)
    38703870                  {
     
    39053905                for ( it=0;it<nbv;it++) renu[i]= -renu[i]-1;
    39063906        }
    3907         /*}}}1*/
    3908 /*FUNCTION Mesh::SetIntCoor{{{1*/
     3907        /*}}}*/
     3908/*FUNCTION Mesh::SetIntCoor{{{*/
    39093909void Mesh::SetIntCoor(const char * strfrom) {
    39103910        /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/SetIntCoor)*/
     
    39293929        coefIcoor= (MaxICoor)/(Max(pmax.x-pmin.x,pmax.y-pmin.y));
    39303930        if (coefIcoor<=0){
    3931                 _error_("coefIcoor should be positive, a problem in the geometry is likely");
     3931                _error2_("coefIcoor should be positive, a problem in the geometry is likely");
    39323932        }
    39333933
     
    39563956                                number_of_errors++;
    39573957                                if (number_of_errors<20){
    3958                                         printf("Area of Triangle %i < 0 (det=%i)\n",i+1,triangles[i].det);
     3958                                        _printLine_("Area of Triangle " << i+1 << " < 0 (det=" << triangles[i].det << ")");
    39593959                                }
    39603960                        }
     
    39653965        }
    39663966
    3967         if (number_of_errors) _error_("Fatal error: some triangles have negative areas, see above");
     3967        if (number_of_errors) _error2_("Fatal error: some triangles have negative areas, see above");
    39683968}
    3969 /*}}}1*/
    3970 /*FUNCTION Mesh::ShowRegulaty{{{1*/
     3969/*}}}*/
     3970/*FUNCTION Mesh::ShowRegulaty{{{*/
    39713971void  Mesh::ShowRegulaty() const {
    39723972        /*Original code from Frederic Hecht <hecht@ann.jussieu.fr>*/
     
    40244024        gammamn=sqrt(gammamn);
    40254025        gammamx=sqrt(gammamx);   
    4026         printf("   Adaptmesh info:\n");
    4027         printf("      number of triangles = %i\n",nt);
    4028         printf("      hmin = %g, hmax=%g\n",hmin,hmax);
    4029         printf("      area = %g, M area = %g, M area/( |Khat| nt) = %g\n",area,Marea, Marea/(aireKh*nt));
    4030         printf("      infinite-regularity(?): min = %g, max = %g\n",gammamn,gammamx);
    4031         printf("      anisomax = %g, beta max = %g, min = %g\n",pow(alpha2,0.5),1./pow(beta/aireKh,0.5), 1./pow(beta0/aireKh,0.5));
     4026        _printLine_("   Adaptmesh info:");
     4027        _printLine_("      number of triangles = " << nt);
     4028        _printLine_("      hmin = " << hmin << ", hmax=" << hmax);
     4029        _printLine_("      area = " << area << ", M area = " << Marea << ", M area/( |Khat| nt) = " << Marea/(aireKh*nt));
     4030        _printLine_("      infinite-regularity(?): min = " << gammamn << ", max = " << gammamx);
     4031        _printLine_("      anisomax = " << pow(alpha2,0.5) << ", beta max = " << 1./pow(beta/aireKh,0.5) << ", min = " << 1./pow(beta0/aireKh,0.5));
    40324032}
    4033 /*}}}1*/
    4034 /*FUNCTION Mesh::ShowHistogram{{{1*/
     4033/*}}}*/
     4034/*FUNCTION Mesh::ShowHistogram{{{*/
    40354035void  Mesh::ShowHistogram() const {
    40364036        /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/ShowHistogram)*/
     
    40634063                        }
    40644064                } 
    4065         printf(" --- Histogram of the unit mesh,  nb of edges = %i\n",nbedges);
    4066         printf("      length of edge in   | %% of edge  | Nb of edges \n");
    4067         printf("      --------------------+-------------+-------------\n");
     4065        _printLine_(" --- Histogram of the unit mesh,  nb of edges = " << nbedges);
     4066        _printLine_("      length of edge in   | %% of edge  | Nb of edges ");
     4067        _printLine_("      --------------------+-------------+-------------");
    40684068        for   (i=0;i<=kmax;i++){
    4069                 if (i==0) printf("      %10i",0);
    4070                 else      printf("      %10g",exp(lmin+i/delta));
    4071                 if (i==kmax) printf("          +inf   ");
    4072                 else printf("      %10g",exp(lmin+(i+1)/delta));
    4073                 printf("|  %10g |\n",((long)  ((10000.0 * histo[i])/ nbedges))/100.0);
    4074                 printf("  %i\n",histo[i]);
    4075         }
    4076         printf("      --------------------+-------------+-------------\n");
     4069                if (i==0) _printString_( "      " << setw(10) << 0.);
     4070                else      _printString_( "      " << setw(10) << exp(lmin+i/delta));
     4071                if (i==kmax) _printString_("          +inf   ");
     4072                else      _printString_( "      " << setw(10) << exp(lmin+(i+1)/delta));
     4073                _printLine_("|  " << setw(10) << (long((10000. * histo[i])/ nbedges)/100.) << " |");
     4074                _printLine_("  " << histo[i]);
     4075        }
     4076        _printLine_("      --------------------+-------------+-------------");
    40774077}
    4078 /*}}}1*/
    4079 /*FUNCTION Mesh::SmoothingVertex{{{1*/
     4078/*}}}*/
     4079/*FUNCTION Mesh::SmoothingVertex{{{*/
    40804080void Mesh::SmoothingVertex(int nbiter,double omega ) {
    40814081        /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/SmoothingVertex)*/
     
    41004100        for ( k=0;k<NbVerticesOnGeomEdge;k++ )
    41014101         tstart[ GetId(VerticesOnGeomEdge[k].meshvertex)]=&vide;
    4102         if(verbose>2) printf("   SmoothingVertex: nb Iteration = %i, Omega=%g\n",nbiter,omega);
     4102        if(verbose>2) _printLine_("   SmoothingVertex: nb Iteration = " << nbiter << ", Omega=" << omega);
    41034103        for (k=0;k<nbiter;k++)
    41044104          {
     
    41124112                  if (tstart[i] != &vide) // not a boundary vertex
    41134113                        NbSwap += vertices[i].Optim(1);
    4114                 if (verbose>3) printf("      move max = %g, iteration = %i, nb of swap = %i\n",pow(delta,0.5),k,NbSwap);
     4114                if (verbose>3) _printLine_("      move max = " << pow(delta,0.5) << ", iteration = " << k << ", nb of swap = " << NbSwap);
    41154115          }
    41164116
     
    41184118        if (quadtree) quadtree= new BamgQuadtree(this);
    41194119}
    4120 /*}}}1*/
    4121 /*FUNCTION Mesh::SmoothMetric{{{1*/
     4120/*}}}*/
     4121/*FUNCTION Mesh::SmoothMetric{{{*/
    41224122void Mesh::SmoothMetric(double raisonmax) {
    41234123        /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Metric.cpp/SmoothMetric)*/
     
    41264126
    41274127        if(raisonmax<1.1) return;
    4128         if(verbose > 1) printf("   Mesh::SmoothMetric raisonmax = %g\n",raisonmax);
     4128        if(verbose > 1) _printLine_("   Mesh::SmoothMetric raisonmax = " << raisonmax);
    41294129        CreateSingleVertexToTriangleConnectivity();
    41304130        long i,j,kch,kk,ip;
     
    41464146                        register Triangle* t= vertices[i].t;
    41474147                        if (!t){
    4148                                 _error_("!t");
     4148                                _error2_("!t");
    41494149                        }
    41504150                        BamgVertex & vi = vertices[i];
     
    41544154                                ta=Previous(Adj(ta));
    41554155                                if (vertices+i != ta.EdgeVertex(1)){
    4156                                         _error_("vertices+i != ta.EdgeVertex(1)");
     4156                                        _error2_("vertices+i != ta.EdgeVertex(1)");
    41574157                                }
    41584158                                BamgVertex & vj = *(ta.EdgeVertex(0));
     
    41604160                                        j= &vj-vertices;
    41614161                                        if (j<0 || j >= nbv){
    4162                                                 _error_("j<0 || j >= nbv");
     4162                                                _error2_("j<0 || j >= nbv");
    41634163                                        }
    41644164                                        R2 Aij = (R2) vj - (R2) vi;
     
    41924192                Exchange(first_np_or_next_t0,first_np_or_next_t1);
    41934193        }
    4194         if(verbose>2) printf("      number of iterations = %i\n",kch);
     4194        if(verbose>2) _printLine_("      number of iterations = " << kch);
    41954195        delete [] first_np_or_next_t0;
    41964196        delete [] first_np_or_next_t1;
    41974197}
    4198 /*}}}1*/
    4199         /*FUNCTION Mesh::SplitElement{{{1*/
     4198/*}}}*/
     4199        /*FUNCTION Mesh::SplitElement{{{*/
    42004200        int  Mesh::SplitElement(int choice){
    42014201                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshQuad.cpp/SplitElement)*/
     
    42844284                                        // the first PB is to now a background edge between the 2 vertices
    42854285                                        if (!edgesGtoB){
    4286                                                 _error_("!edgesGtoB");
     4286                                                _error2_("!edgesGtoB");
    42874287                                        }
    42884288                                        ong= ProjectOnCurve(*edgesGtoB[Gh.GetId(edges[i].GeomEdgeHook)],
     
    43564356                        Triangle & t = triangles[i];
    43574357                        if (!t.link){
    4358                                 _error_("!t.link");
     4358                                _error2_("!t.link");
    43594359                        }
    43604360                        for(int j=0;j<3;j++)
     
    43824382                                                                                ||   (bb=Area2( t[0].r , A.r    , t[2].r )) < 0.0 
    43834383                                                                                ||   (cc=Area2( t[0].r , t[1].r , A.r    )) < 0.0)){
    4384                                                         printf("%i not in triangle %i In= %i %g %g %g %g\n",ke + nbvold,i,!!t.link,aa,bb,cc,dd);
    4385                                                         _error_("Number of triangles with P2 interpolation Problem");
     4384                                                        _printLine_(ke + nbvold << " not in triangle " << i << " In= " << !!t.link << " " << aa << " " << bb << " " << cc << " " << dd);
     4385                                                        _error2_("Number of triangles with P2 interpolation Problem");
    43864386                                                }
    43874387                                        }
     
    43904390                                                                                ||   (bb=Area2( tt[0].r , A.r     , tt[2].r )) < 0
    43914391                                                                                ||   (cc=Area2( tt[0].r , tt[1].r , A.r     )) < 0)){
    4392                                                         printf("%i not in triangle %i In= %i %g %g %g %g\n",ke + nbvold,ii,!!tt.link,aa,bb,cc,dd);
    4393                                                         _error_("Number of triangles with P2 interpolation Problem");
     4392                                                        _printLine_(ke + nbvold << " not in triangle " << ii << " In= " << !!tt.link << " " << aa << " " << bb << " " << cc << " " << dd);
     4393                                                        _error2_("Number of triangles with P2 interpolation Problem");
    43944394                                                }
    43954395                                        }
     
    44394439                                                  } // tt
    44404440                                                else
    4441                                                  _error_("Bug...");
     4441                                                 _error2_("Bug...");
    44424442                                          } // ke<0           
    44434443                                        else
     
    44524452                          }
    44534453                        if (nbinvisible>=2){
    4454                                 _error_("nbinvisible>=2");
     4454                                _error2_("nbinvisible>=2");
    44554455                        }
    44564456                        switch (nbsplitedge) {
     
    44644464                        }
    44654465                        if (ksplit[i]<40){
    4466                                 _error_("ksplit[i]<40");
     4466                                _error2_("ksplit[i]<40");
    44674467                        }
    44684468                  }
     
    44814481                        int  ke=(int) (ksplit[i]%10);
    44824482                        if (kk>=7 || kk<=0){
    4483                                 _error_("kk>=7 || kk<=0");
     4483                                _error2_("kk>=7 || kk<=0");
    44844484                        }
    44854485
     
    44984498
    44994499                        if (nbmkadj>=10){
    4500                                 _error_("nbmkadj>=10");
     4500                                _error2_("nbmkadj>=10");
    45014501                        }
    45024502                        // --------------------------
     
    45164516                                                        t1=t0;
    45174517                                                        if (kedge[3*i+i0]<0){
    4518                                                                 _error_("kedge[3*i+i0]<0");
     4518                                                                _error2_("kedge[3*i+i0]<0");
    45194519                                                        }
    45204520                                                        BamgVertex * v3 = vertices + kedge[3*i+k0];
     
    45324532                                                        t2=t1=t0;
    45334533                                                        if (kedge[3*i+k1]<0){
    4534                                                                 _error_("kedge[3*i+k1]<0");
     4534                                                                _error2_("kedge[3*i+k1]<0");
    45354535                                                        }
    45364536                                                        if (kedge[3*i+k2]<0){
    4537                                                                 _error_("kedge[3*i+k2]<0");
     4537                                                                _error2_("kedge[3*i+k2]<0");
    45384538                                                        }
    45394539
     
    45594559                                                        t3=t2=t1=t0;
    45604560                                                        if (kedge[3*i+k0] <0 || kedge[3*i+k1]<0 || kedge[3*i+k2]<0){
    4561                                                                 _error_("kedge[3*i+k0] <0 || kedge[3*i+k1]<0 || kedge[3*i+k2]<0");
     4561                                                                _error2_("kedge[3*i+k0] <0 || kedge[3*i+k1]<0 || kedge[3*i+k2]<0");
    45624562                                                        }
    45634563                                                        BamgVertex * v12 = vertices + kedge[3*i+k0];
     
    46334633                                }
    46344634                        if (nbmkadj>13){// 13 = 6 + 4 +
    4635                                 _error_("nbmkadj>13");
     4635                                _error2_("nbmkadj>13");
    46364636                        }
    46374637
     
    46854685
    46864686                if (verbose>2){
    4687                         printf("   number of quadrilaterals    = %i\n",nbq);
    4688                         printf("   number of triangles         = %i\n",nbt-nbtout- nbq*2);
    4689                         printf("   number of outside triangles = %i\n",nbtout);
     4687                        _printLine_("   number of quadrilaterals    = " << nbq);
     4688                        _printLine_("   number of triangles         = " << nbt-nbtout- nbq*2);
     4689                        _printLine_("   number of outside triangles = " << nbtout);
    46904690                }
    46914691
     
    47064706                return ret; // ok
    47074707        }
    4708         /*}}}1*/
    4709 /*FUNCTION Mesh::SplitInternalEdgeWithBorderVertices{{{1*/
     4708        /*}}}*/
     4709/*FUNCTION Mesh::SplitInternalEdgeWithBorderVertices{{{*/
    47104710long  Mesh::SplitInternalEdgeWithBorderVertices(){
    47114711        /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/SplitInternalEdgeWithBorderVertices)*/
     
    47544754                        Triangle *tcvi = TriangleFindFromCoord(vi.i,det3);
    47554755                        if (tcvi && !tcvi->link) {
    4756                                 printf("problem inserting point in SplitInternalEdgeWithBorderVertices (tcvj && !tcvj->link)\n");
     4756                                _printLine_("problem inserting point in SplitInternalEdgeWithBorderVertices (tcvj && !tcvj->link)");
    47574757                        }
    47584758
    47594759                        quadtree->Add(vi);
    47604760                        if (!tcvi || tcvi->det<0){// internal
    4761                                 _error_("!tcvi || tcvi->det < 0");
     4761                                _error2_("!tcvi || tcvi->det < 0");
    47624762                        }
    47634763                        AddVertex(vi,tcvi,det3);
     
    47674767        }
    47684768        if (verbose>3) {
    4769                 printf("   number of points: %i\n",iv);
    4770                 printf("   number of swap to  split internal edges with border vertices: %i\n",NbSwap);
     4769                _printLine_("   number of points: " << iv);
     4770                _printLine_("   number of swap to  split internal edges with border vertices: " << NbSwap);
    47714771                nbv = iv;
    47724772        }
    47734773}
    4774 if (NbSplitEdge>nbv-nbvold) printf("WARNING: not enough vertices  to split all internal edges, we lost %i edges...\n",NbSplitEdge - ( nbv-nbvold));
    4775 if (verbose>2) printf("SplitInternalEdgeWithBorderVertices: Number of splited edge %i\n",NbSplitEdge);
     4774if (NbSplitEdge>nbv-nbvold) _printLine_("WARNING: not enough vertices  to split all internal edges, we lost " << NbSplitEdge - ( nbv-nbvold) << " edges...");
     4775if (verbose>2) _printLine_("SplitInternalEdgeWithBorderVertices: Number of splited edge " << NbSplitEdge);
    47764776
    47774777return  NbSplitEdge;
    47784778}
    4779 /*}}}1*/
    4780 /*FUNCTION Mesh::ToI2{{{1*/
     4779/*}}}*/
     4780/*FUNCTION Mesh::ToI2{{{*/
    47814781I2 Mesh::R2ToI2(const R2 & P) const {
    47824782        return  I2( (Icoor1) (coefIcoor*(P.x-pmin.x)),(Icoor1) (coefIcoor*(P.y-pmin.y)) );
    47834783}
    4784 /*}}}1*/
    4785 /*FUNCTION Mesh::ToR2{{{1*/
     4784/*}}}*/
     4785/*FUNCTION Mesh::ToR2{{{*/
    47864786R2 Mesh::I2ToR2(const I2 & P) const {
    47874787        return  R2( (double) P.x/coefIcoor+pmin.x, (double) P.y/coefIcoor+pmin.y);
    47884788}
    4789 /*}}}1*/
    4790 /*FUNCTION Mesh::TriangleFindFromCoord{{{1*/
     4789/*}}}*/
     4790/*FUNCTION Mesh::TriangleFindFromCoord{{{*/
    47914791Triangle * Mesh::TriangleFindFromCoord(const I2 & B,Icoor2 det3[3], Triangle *tstart) const {
    47924792        /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/FindTriangleContening)*/
     
    48034803
    48044804                /*Check that the quadtree does exist*/
    4805                 if (!quadtree) _error_("no starting triangle provided and no quadtree available");
     4805                if (!quadtree) _error2_("no starting triangle provided and no quadtree available");
    48064806
    48074807                /*Call NearestVertex*/
     
    48094809
    48104810                /*Check output (Vertex a)*/
    4811                 if (!a)    _error_("problem while trying to find nearest vertex from a given point. No output found");
    4812                 if (!a->t) _error_("no triangle is associated to vertex number %i (orphan?)",GetId(a)+1);
     4811                if (!a)    _error2_("problem while trying to find nearest vertex from a given point. No output found");
     4812                if (!a->t) _error2_("no triangle is associated to vertex number " << GetId(a)+1 << " (orphan?)");
    48134813                _assert_(a>=vertices && a<vertices+nbv);
    48144814
     
    48454845
    48464846                /*Increase counter*/
    4847                 if (++counter>=10000) _error_("Maximum number of iteration reached (threshold = %i).",counter);
     4847                if (++counter>=10000) _error2_("Maximum number of iteration reached (threshold = " << counter << ").");
    48484848
    48494849                j= OppositeVertex[jj];
     
    48794879        return t;
    48804880}
    4881 /*}}}1*/
    4882 /*FUNCTION Mesh::TriangleIntNumbering{{{1*/
     4881/*}}}*/
     4882/*FUNCTION Mesh::TriangleIntNumbering{{{*/
    48834883void Mesh::TriangleIntNumbering(long* renumbering){
    48844884
     
    48904890        return;   
    48914891}
    4892 /*}}}1*/
    4893 /*FUNCTION Mesh::TriangleReferenceList{{{1*/
     4892/*}}}*/
     4893/*FUNCTION Mesh::TriangleReferenceList{{{*/
    48944894long  Mesh::TriangleReferenceList(long* reft) const {
    48954895        /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/ConsRefTriangle)*/
     
    49094909
    49104910                //check that the subdomain is not empty
    4911                 if (!t0){ _error_("At least one subdomain is empty");}
     4911                if (!t0){ _error2_("At least one subdomain is empty");}
    49124912
    49134913                //loop
     
    49304930        return k;   
    49314931}
    4932 /*}}}1*/
    4933 /*FUNCTION Mesh::Triangulate{{{1*/
     4932/*}}}*/
     4933/*FUNCTION Mesh::Triangulate{{{*/
    49344934void Mesh::Triangulate(double* x,double* y,int nods){
    49354935
     
    49434943
    49444944        //Vertices
    4945         if(verbose) printf("Reading vertices (%i)\n",nbv);
     4945        if(verbose) _printLine_("Reading vertices (" << nbv << ")");
    49464946        for (i=0;i<nbv;i++){
    49474947                vertices[i].r.x=x[i];
     
    49574957        Insert();
    49584958}
    4959 /*}}}1*/
    4960         /*FUNCTION Mesh::TriangulateFromGeom0{{{1*/
     4959/*}}}*/
     4960        /*FUNCTION Mesh::TriangulateFromGeom0{{{*/
    49614961        void Mesh::TriangulateFromGeom0(BamgOpts* bamgopts){
    49624962                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/GeomToTriangles0)*/
     
    49924992                //allocate
    49934993                VerticesOnGeomVertex = new VertexOnGeom[NbVerticesOnGeomVertex]; 
    4994                 if(NbVerticesOnGeomVertex >= maxnbv) _error_("too many vertices on geometry: %i >= %i",NbVerticesOnGeomVertex,maxnbv);
     4994                if(NbVerticesOnGeomVertex >= maxnbv) _error2_("too many vertices on geometry: " << NbVerticesOnGeomVertex << " >= " << maxnbv);
    49954995                _assert_(nbv==0);
    49964996                //Build VerticesOnGeomVertex
     
    50815081                                                                NbNewPoints=0;
    50825082                                                                NbEdgeCurve=0;
    5083                                                                 if (nbvend>=maxnbv) _error_("maximum number of vertices too low! Check the domain outline or increase maxnbv");
     5083                                                                if (nbvend>=maxnbv) _error2_("maximum number of vertices too low! Check the domain outline or increase maxnbv");
    50845084                                                                lcurve =0;
    50855085                                                                s = lstep; //-1 initially, then length of each sub edge
     
    52555255
    52565256                //Insert points inside existing triangles
    5257                 if (verbose>4) printf("      -- current number of vertices = %i\n",nbv);
    5258                 if (verbose>3) printf("      Creating initial Constrained Delaunay Triangulation...\n");
    5259                 if (verbose>3) printf("         Inserting boundary points\n");
     5257                if (verbose>4) _printLine_("      -- current number of vertices = " << nbv);
     5258                if (verbose>3) _printLine_("      Creating initial Constrained Delaunay Triangulation...");
     5259                if (verbose>3) _printLine_("         Inserting boundary points");
    52605260                Insert();
    52615261
    52625262                //Force the boundary
    5263                 if (verbose>3) printf("         Forcing boundaries\n");
     5263                if (verbose>3) _printLine_("         Forcing boundaries");
    52645264                ForceBoundary();
    52655265
    52665266                //Extract SubDomains
    5267                 if (verbose>3) printf("         Extracting subdomains\n");
     5267                if (verbose>3) _printLine_("         Extracting subdomains");
    52685268                FindSubDomain();
    52695269
    5270                 if (verbose>3) printf("      Inserting internal points\n");
     5270                if (verbose>3) _printLine_("      Inserting internal points");
    52715271                NewPoints(*this,bamgopts,0) ;
    5272                 if (verbose>4) printf("      -- current number of vertices = %i\n",nbv);
    5273         }
    5274         /*}}}1*/
    5275         /*FUNCTION Mesh::TriangulateFromGeom1{{{1*/
     5272                if (verbose>4) _printLine_("      -- current number of vertices = " << nbv);
     5273        }
     5274        /*}}}*/
     5275        /*FUNCTION Mesh::TriangulateFromGeom1{{{*/
    52765276        void Mesh::TriangulateFromGeom1(BamgOpts* bamgopts,int KeepVertices){
    52775277                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/GeomToTriangles1)*/
     
    53235323                if(NbVerticesOnGeomVertex >= maxnbv){
    53245324                        delete [] bcurve;
    5325                         _error_("too many vertices on geometry: %i >= %i",NbVerticesOnGeomVertex,maxnbv);
     5325                        _error2_("too many vertices on geometry: " << NbVerticesOnGeomVertex << " >= " << maxnbv);
    53265326                }
    53275327
     
    53735373                                        int nc=ei.GeomEdgeHook->CurveNumber;
    53745374                                       
    5375                                         //printf("Dealing with curve number %i\n",nc);
    5376                                         //printf("edge on geometry is same as GhCurve? %s\n",(ei.GeomEdgeHook==Gh.curves[nc].FirstEdge || ei.GeomEdgeHook==Gh.curves[nc].LastEdge)?"yes":"no");
     5375                                        //_printLine_("Dealing with curve number " << nc);
     5376                                        //_printLine_("edge on geometry is same as GhCurve? " << (ei.GeomEdgeHook==Gh.curves[nc].FirstEdge || ei.GeomEdgeHook==Gh.curves[nc].LastEdge)?"yes":"no");
    53775377                                        //if(ei.GeomEdgeHook==Gh.curves[nc].FirstEdge || ei.GeomEdgeHook==Gh.curves[nc].LastEdge){
    5378                                         //      printf("Do we have the right extremity? curve first vertex -> %s\n",((GeomVertex *)*ei[je].GeomEdgeHook==&(*Gh.curves[nc].FirstEdge)[Gh.curves[nc].FirstVertexIndex])?"yes":"no");
    5379                                         //      printf("Do we have the right extremity? curve last  vertex -> %s\n",((GeomVertex *)*ei[je].GeomEdgeHook==&(*Gh.curves[nc].LastEdge)[Gh.curves[nc].LastVertexIndex])?"yes":"no");
     5378                                        //      _printLine_("Do we have the right extremity? curve first vertex -> " << ((GeomVertex *)*ei[je].GeomEdgeHook==&(*Gh.curves[nc].FirstEdge)[Gh.curves[nc].FirstVertexIndex])?"yes":"no");
     5379                                        //      _printLine_("Do we have the right extremity? curve last  vertex -> " << ((GeomVertex *)*ei[je].GeomEdgeHook==&(*Gh.curves[nc].LastEdge)[Gh.curves[nc].LastVertexIndex])?"yes":"no");
    53805380                                        //}
    53815381                                        //BUG FIX from original bamg
     
    53945394                if (bfind!=Gh.nbcurves){
    53955395                        delete [] bcurve;
    5396                         _error_("problem generating number of curves (%i found in the geometry but %i curve found in the mesh)",Gh.nbcurves,bfind);
     5396                        _error2_("problem generating number of curves (" << Gh.nbcurves << " found in the geometry but " << bfind << " curve found in the mesh)");
    53975397                }
    53985398
     
    54935493                                                                        double se= (sNew-L0)/LAB;
    54945494                                                                        if (se<0 || se>=1.000000001){
    5495                                                                                 _error_("Problem creating point on a boundary: se=%g should be in [0 1]",se);
     5495                                                                                _error2_("Problem creating point on a boundary: se=" << se << " should be in [0 1]");
    54965496                                                                        }
    54975497                                                                        se = abscisseInterpole(v0.m,v1.m,AB,se,1);
    54985498                                                                        if (se<0 || se>1){
    5499                                                                                 _error_("Problem creating point on a boundary: se=%g should be in [0 1]",se);
     5499                                                                                _error2_("Problem creating point on a boundary: se=" << se << " should be in [0 1]");
    55005500                                                                        }
    55015501                                                                        se = k1         ? se : 1. - se;
     
    55295529                                                        }
    55305530                                                        if (!ee.adj[k1]) {
    5531                                                                 _error_(" adj edge %i, nbe=%i, Gh.vertices=%i",BTh.GetId(ee),nbe,Gh.vertices);
     5531                                                                _error2_("adj edge " << BTh.GetId(ee) << ", nbe=" << nbe << ", Gh.vertices=" << Gh.vertices);
    55325532                                                        }
    55335533                                                        pe = ee.adj[k1]; // next edge
     
    55675567                        if(step==0){
    55685568                                if(nbv+NbOfNewPoints > maxnbv) {
    5569                                         _error_("too many vertices on geometry: %i >= %i",nbv+NbOfNewPoints,maxnbv);
     5569                                        _error2_("too many vertices on geometry: " << nbv+NbOfNewPoints << " >= " << maxnbv);
    55705570                                }
    55715571                                edges = new Edge[NbOfNewEdge];
     
    55855585
    55865586                //Insert points inside existing triangles
    5587                 if (verbose>4) printf("      -- current number of vertices = %i\n",nbv);
    5588                 if (verbose>3) printf("      Creating initial Constrained Delaunay Triangulation...\n");
    5589                 if (verbose>3) printf("         Inserting boundary points\n");
     5587                if (verbose>4) _printLine_("      -- current number of vertices = " << nbv);
     5588                if (verbose>3) _printLine_("      Creating initial Constrained Delaunay Triangulation...");
     5589                if (verbose>3) _printLine_("         Inserting boundary points");
    55905590                Insert();
    55915591
    55925592                //Force the boundary
    5593                 if (verbose>3) printf("         Forcing boundaries\n");
     5593                if (verbose>3) _printLine_("         Forcing boundaries");
    55945594                ForceBoundary();
    55955595
    55965596                //Extract SubDomains
    5597                 if (verbose>3) printf("         Extracting subdomains\n");
     5597                if (verbose>3) _printLine_("         Extracting subdomains");
    55985598                FindSubDomain();
    55995599
    5600                 if (verbose>3) printf("      Inserting internal points\n");
     5600                if (verbose>3) _printLine_("      Inserting internal points");
    56015601                NewPoints(BTh,bamgopts,KeepVertices) ;
    5602                 if (verbose>4) printf("      -- current number of vertices = %i\n",nbv);
    5603         }
    5604         /*}}}1*/
     5602                if (verbose>4) _printLine_("      -- current number of vertices = " << nbv);
     5603        }
     5604        /*}}}*/
    56055605
    56065606        /*Intermediary*/
    5607         /*FUNCTION CloseBoundaryEdge{{{1*/
     5607        /*FUNCTION CloseBoundaryEdge{{{*/
    56085608        AdjacentTriangle CloseBoundaryEdge(I2 A,Triangle *t, double &a,double &b) {
    56095609                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/CloseBoundaryEdge)*/
     
    56125612                int dir=0;
    56135613                if (k<0){
    5614                         _error_("k<0");
     5614                        _error2_("k<0");
    56155615                }
    56165616                int kkk=0; 
     
    56205620                        kkk++;
    56215621                        if (kkk>=1000){
    5622                                 _error_("kkk>=1000");
     5622                                _error2_("kkk>=1000");
    56235623                        }
    56245624                        BamgVertex  &vI =  *edge.EdgeVertex(0);
     
    56375637                                                        double IJ2 = IJ_IA + IJ_AJ;
    56385638                                                        if (IJ2==0){
    5639                                                                 _error_("IJ2==0");
     5639                                                                _error2_("IJ2==0");
    56405640                                                        }
    56415641                                                        a= IJ_AJ/IJ2;
     
    56445644                  }
    56455645        }
    5646         /*}}}1*/
    5647         /*FUNCTION CloseBoundaryEdgeV2{{{1*/
     5646        /*}}}*/
     5647        /*FUNCTION CloseBoundaryEdgeV2{{{*/
    56485648        AdjacentTriangle CloseBoundaryEdgeV2(I2 C,Triangle *t, double &a,double &b) {
    56495649                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/CloseBoundaryEdgeV2)*/
     
    56555655                //   int dir=0;
    56565656                if (t->link != 0){
    5657                         _error_("t->link != 0");
     5657                        _error2_("t->link != 0");
    56585658                }
    56595659                // to have a starting edges
     
    57275727                  }
    57285728                if (cas ==-2){
    5729                         _error_("cas==-2");
     5729                        _error2_("cas==-2");
    57305730                }
    57315731                // l1 = ||C s1||  , l0 = ||C s0||
     
    57445744                                kkk++;
    57455745                                if (edge.EdgeVertex(0)!=s && kkk>=10000){
    5746                                         _error_("edge.EdgeVertex(0)!=s && kkk>=10000");
     5746                                        _error2_("edge.EdgeVertex(0)!=s && kkk>=10000");
    57475747                                }
    57485748
     
    57765776
    57775777                        if (!(Triangle *) er){
    5778                                 _error_("!(Triangle *) er");
     5778                                _error2_("!(Triangle *) er");
    57795779                        }
    57805780                        I2 A((I2)*er.EdgeVertex(0));
     
    57935793                return er;
    57945794        }
    5795         /*}}}1*/
    5796 /*FUNCTION ForceEdge{{{1*/
     5795        /*}}}*/
     5796/*FUNCTION ForceEdge{{{*/
    57975797int ForceEdge(BamgVertex &a, BamgVertex & b,AdjacentTriangle & taret)  {
    57985798        /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/ForceEdge)*/
     
    58005800        int NbSwap =0;
    58015801        if (!a.t || !b.t){ // the 2 vertex is in a mesh
    5802                 _error_("!a.t || !b.t");
     5802                _error2_("!a.t || !b.t");
    58035803        }
    58045804        int k=0;
     
    58175817                vbegin =v2;
    58185818                if (!v2){
    5819                         _error_("!v2");
     5819                        _error2_("!v2");
    58205820                }
    58215821                det2 = det(*v2,a,b);
     
    58345834                        tc = Previous(tc);
    58355835                        if (!v1 || !v2){
    5836                                 _error_("!v1 || !v2");
     5836                                _error2_("!v1 || !v2");
    58375837                        }
    58385838                        Icoor2 detss = 0,l=0,ks;
    58395839                        while ((ks=SwapForForcingEdge(  va,  vb, tc, detss, det1,det2,NbSwap)))
    58405840                         if(l++ > 10000000) {
    5841                                  _error_("Loop in forcing Egde, nb de swap=%i, nb of try swap (%i) too big",NbSwap,l);
     5841                                 _error2_("Loop in forcing Egde, nb de swap=" << NbSwap << ", nb of try swap (" << l << ") too big");
    58425842                         }
    58435843                        BamgVertex *aa = tc.EdgeVertex(0), *bb = tc.EdgeVertex(1);
     
    58585858                k++;
    58595859                if (k>=2000){
    5860                         _error_("k>=2000");
     5860                        _error2_("k>=2000");
    58615861                }
    58625862                if ( vbegin == v2 ) return -1;// error
     
    58695869        return NbSwap;
    58705870}
    5871 /*}}}1*/
    5872 /*FUNCTION swap{{{1*/
     5871/*}}}*/
     5872/*FUNCTION swap{{{*/
    58735873void  swap(Triangle *t1,short a1, Triangle *t2,short a2, BamgVertex *s1,BamgVertex *s2,Icoor2 det1,Icoor2 det2){
    58745874        /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/swap)*/
     
    59145914        t2->SetSingleVertexToTriangleConnectivity();
    59155915} // end swap
    5916 /*}}}1*/
    5917         /*FUNCTION SwapForForcingEdge{{{1*/
     5916/*}}}*/
     5917        /*FUNCTION SwapForForcingEdge{{{*/
    59185918        int SwapForForcingEdge(BamgVertex   *  & pva ,BamgVertex  * &   pvb ,AdjacentTriangle & tt1,Icoor2 & dets1, Icoor2 & detsa,Icoor2 & detsb, int & NbSwap) {
    59195919                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/SwapForForcingEdge)*/
     
    59305930                short a1=tt1,a2=tt2;// les 2 numero de l arete dans les 2 triangles
    59315931                if ( a1<0 || a1>=3 ){
    5932                         _error_("a1<0 || a1>=3");
     5932                        _error2_("a1<0 || a1>=3");
    59335933                }
    59345934
     
    59425942                Icoor2 detT = det1+det2;
    59435943                if ((det1<=0 ) || (det2<=0)){
    5944                         _error_("(det1<=0 ) || (det2<=0)");
     5944                        _error2_("(det1<=0 ) || (det2<=0)");
    59455945                }
    59465946                if ( (detsa>=0) || (detsb<=0) ){ // [a,b] cut infinite line va,bb
    5947                         _error_("(detsa>=0) || (detsb<=0)");
     5947                        _error2_("(detsa>=0) || (detsb<=0)");
    59485948                }
    59495949                Icoor2 ndet1 = bamg::det(s1,sa,s2);
     
    60026002                return ret;
    60036003        }
    6004         /*}}}1*/
     6004        /*}}}*/
    60056005
    60066006}
  • issm/trunk/src/c/objects/Bamg/Mesh.h

    r12330 r12706  
    5757                        //Constructors/Destructors
    5858                        Mesh(BamgGeom* bamggeom,BamgMesh* bamgmesh,BamgOpts* bamgopts);
    59                         Mesh(double* index,double* x,double* y,int nods,int nels);/*MeshConvert*/
     59                        Mesh(int* index,double* x,double* y,int nods,int nels);/*MeshConvert*/
    6060                        Mesh(double* x,double* y,int nods); /*BamgTriangulate*/
    6161                        Mesh(Mesh &,Geometry * pGh=0,Mesh* pBTh=0,long maxnbv_in=0 ); //copy operator
     
    110110                        BamgVertex* NearestVertex(Icoor1 i,Icoor1 j) ;
    111111                        Triangle* TriangleFindFromCoord(const I2 & ,Icoor2 [3],Triangle *tstart=0) const;
    112                         void ReadMesh(double* index,double* x,double* y,int nods,int nels);
     112                        void ReadMesh(int* index,double* x,double* y,int nods,int nels);
    113113                        void ReadMesh(BamgMesh* bamgmesh, BamgOpts* bamgopts);
    114114                        void WriteMesh(BamgMesh* bamgmesh,BamgOpts* bamgopts);
  • issm/trunk/src/c/objects/Bamg/Metric.cpp

    r9371 r12706  
    1414
    1515        /*Constructor/Destructor*/
    16         /*FUNCTION Metric::Metric(){{{1*/
    17         /*FUNCTION Metric::Metric(double a){{{1*/
     16        /*FUNCTION Metric::Metric(double a){{{*/
    1817        Metric::Metric(double a): a11(1/(a*a)),a21(0),a22(1/(a*a)){
    1918       
    2019        }/*}}}*/
    21         /*FUNCTION Metric::Metric(double a,double b,double c){{{1*/
     20        /*FUNCTION Metric::Metric(double a,double b,double c){{{*/
    2221        Metric::Metric(double a,double b,double c) :a11(a),a21(b),a22(c){
    2322       
    2423        }/*}}}*/
    25         /*FUNCTION Metric::Metric(const double  a[3],const  Metric& m0, const  Metric& m1,const  Metric&  m2 ){{{1*/
     24        /*FUNCTION Metric::Metric(const double  a[3],const  Metric& m0, const  Metric& m1,const  Metric&  m2 ){{{*/
    2625        Metric::Metric(const double  a[3],const  Metric& m0, const  Metric& m1,const  Metric& m2 ){
    2726                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Metric.cpp/Metric)*/
     
    4342                *this = vab;
    4443        }
    45         /*}}}1*/
    46         /*FUNCTION Metric::Metric(double  a,const  Metric& ma, double  b,const  Metric& mb){{{1*/
     44        /*}}}*/
     45        /*FUNCTION Metric::Metric(double  a,const  Metric& ma, double  b,const  Metric& mb){{{*/
    4746        Metric::Metric(double  a,const  Metric& ma, double  b,const  Metric& mb) {
    4847                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Metric.cpp/EigenMetric)*/
     
    6362                *this=vab;
    6463        }
    65         /*}}}1*/
     64        /*}}}*/
    6665
    6766        /*Methods*/
    68         /*FUNCTION Metric::det{{{1*/
     67        /*FUNCTION Metric::det{{{*/
    6968        double Metric::det() const {
    7069                return a11*a22-a21*a21;
    7170        }  /*}}}*/
    72         /*FUNCTION Metric::Echo {{{1*/
     71        /*FUNCTION Metric::Echo {{{*/
    7372        void Metric::Echo(void){
    7473
    75                 printf("Metric:\n");
    76                 printf("   [a11 a21 a22]: [%g %g %g]\n",a11,a21,a22);
     74                _printLine_("Metric:");
     75                _printLine_("   [a11 a21 a22]: [" << a11 << " " << a21 << " " << a22 << "]");
    7776
    7877                return;
    7978        }
    8079        /*}}}*/
    81         /*FUNCTION Metric::IntersectWith{{{1*/
     80        /*FUNCTION Metric::IntersectWith{{{*/
    8281        int Metric::IntersectWith(const Metric& M2) {
    8382                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Metric.cpp/IntersectWith)*/
     
    131130                return change;
    132131        }
    133         /*}}}1*/
    134         /*FUNCTION Metric::mul{{{1*/
     132        /*}}}*/
     133        /*FUNCTION Metric::mul{{{*/
    135134        R2     Metric::mul(const R2 x)const {
    136135                return R2(a11*x.x+a21*x.y,a21*x.x+a22*x.y);
     
    138137
    139138        /*Intermediary*/
    140         /*FUNCTION LengthInterpole{{{1*/
     139        /*FUNCTION LengthInterpole{{{*/
    141140        double LengthInterpole(const Metric& Ma,const  Metric& Mb, R2 AB) {
    142141                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Metric.cpp/LengthInterpole)*/
     
    198197                // warning for optimisation S is in [0:0.5] not in [0:1]
    199198                if (i>=512){
    200                         _error_("i>=512");
     199                        _error2_("i>=512");
    201200                }
    202201                LastMetricInterpole.lab=l;
    203202                LastMetricInterpole.opt=i;
    204                 if (i>200 && kkk++<10) printf("WARNING: LengthInterpole: ( i=%i l=%i sss=%g ) %g\n",i,l,sss,sstop);
     203                if (i>200 && kkk++<10) _printLine_("WARNING: LengthInterpole: ( i=" << i << " l=" << l << " sss=" << sss << " ) " << sstop);
    205204                return l;
    206205        }
    207         /*}}}1*/
    208         /*FUNCTION SimultaneousMatrixReduction{{{1*/
     206        /*}}}*/
     207        /*FUNCTION SimultaneousMatrixReduction{{{*/
    209208        void SimultaneousMatrixReduction( Metric M1,  Metric M2, D2xD2 &V) {
    210209                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Metric.cpp/ReductionSimultanee)*/
     
    308307                }
    309308        }
    310         /*}}}1*/
    311         /*FUNCTION abscisseInterpole{{{1*/
     309        /*}}}*/
     310        /*FUNCTION abscisseInterpole{{{*/
    312311        double abscisseInterpole(const Metric& Ma,const  Metric& Mb, R2 AB,double s,int optim) {
    313312                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Metric.cpp/abscisseInterpole)*/
     
    346345                }
    347346                if (r>1 || r<0){
    348                         _error_("r>1 || r<0");
     347                        _error2_("r>1 || r<0");
    349348                }
    350349                return r ;
    351350        }
    352         /*}}}1*/
     351        /*}}}*/
    353352
    354353}
  • issm/trunk/src/c/objects/Bamg/SetOfE4.cpp

    r6412 r12706  
    55
    66        /*Constructor*/
    7         /*FUNCTION  SetOfEdges4::SetOfEdges4(long mmx,long nnx){{{1*/
     7        /*FUNCTION  SetOfEdges4::SetOfEdges4(long mmx,long nnx){{{*/
    88        SetOfEdges4::SetOfEdges4(long mmx,long nnx){
    99                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, SetOfEdges4.cpp/SetOfEdges4)*/
     
    2323                while(i--) head[i]=-1;
    2424        }
    25         /*}}}1*/
     25        /*}}}*/
    2626
    2727        /*Methods*/
    28         /*FUNCTION  SetOfEdges4::add{{{1*/
     28        /*FUNCTION  SetOfEdges4::add{{{*/
    2929        long SetOfEdges4::add(long ii,long jj) {
    3030                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, SetOfEdges4.cpp/add)*/
     
    5050                //check that nbax <=NbOfEdges
    5151                if (nbax <=NbOfEdges ) {
    52                         _error_("SetOfEdges4::add overflow: NbOfEdges=%i > nbax=%i",NbOfEdges,nbax);
     52                        _error2_("SetOfEdges4::add overflow: NbOfEdges=" << NbOfEdges << " > nbax=" << nbax);
    5353                }
    5454
     
    6060                return NbOfEdges ++;
    6161        }
    62         /*}}}1*/
    63         /*FUNCTION  SetOfEdges4::find {{{1*/
     62        /*}}}*/
     63        /*FUNCTION  SetOfEdges4::find {{{*/
    6464        long SetOfEdges4::find(long ii,long jj) {
    6565                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, SetOfEdges4.cpp/find)*/
     
    8787                return -1;
    8888        }
    89         /*}}}1*/
    90         /*FUNCTION  SetOfEdges4::i{{{1*/
     89        /*}}}*/
     90        /*FUNCTION  SetOfEdges4::i{{{*/
    9191        long SetOfEdges4::i(long k){
    9292                return Edges[k].i;
    9393        }
    94         /*}}}1*/
    95         /*FUNCTION  SetOfEdges4::j{{{1*/
     94        /*}}}*/
     95        /*FUNCTION  SetOfEdges4::j{{{*/
    9696        long SetOfEdges4::j(long k){
    9797                return Edges[k].j;
    9898        }
    99         /*}}}1*/
    100         /*FUNCTION  SetOfEdges4::nb{{{1*/
     99        /*}}}*/
     100        /*FUNCTION  SetOfEdges4::nb{{{*/
    101101        long SetOfEdges4::nb(){
    102102                return NbOfEdges;
    103103        }
    104         /*}}}1*/
    105         /*FUNCTION  SetOfEdges4::newarete{{{1*/
     104        /*}}}*/
     105        /*FUNCTION  SetOfEdges4::newarete{{{*/
    106106        long SetOfEdges4::newarete(long k){
    107107                return NbOfEdges == k+1;
    108108        }
    109         /*}}}1*/
    110         /*FUNCTION  SetOfEdges4::SortAndAdd{{{1*/
     109        /*}}}*/
     110        /*FUNCTION  SetOfEdges4::SortAndAdd{{{*/
    111111        long SetOfEdges4::SortAndAdd (long ii,long jj) {
    112112                return ii <=jj ? add (ii,jj)  : add (jj,ii) ;
    113113        }
    114         /*}}}1*/
    115         /*FUNCTION  SetOfEdges4::SortAndFind{{{1*/
     114        /*}}}*/
     115        /*FUNCTION  SetOfEdges4::SortAndFind{{{*/
    116116        long SetOfEdges4::SortAndFind (long ii,long jj) {
    117117                return ii <=jj ? find (ii,jj)  : find (jj,ii) ;
    118118        }
    119         /*}}}1*/
     119        /*}}}*/
    120120}
  • issm/trunk/src/c/objects/Bamg/SubDomain.cpp

    r6412 r12706  
    1212
    1313        /*Methods*/
    14         /*FUNCTION SubDomain::Set {{{1*/
     14        /*FUNCTION SubDomain::Set {{{*/
    1515        void SubDomain::Set(const Mesh & Th ,long i,Mesh & ThNew){
    1616                *this = Th.subdomains[i];
    1717                if ( head-Th.triangles<0 || head-Th.triangles>=Th.nbt){
    18                         _error_("head-Th.triangles<0 || head-Th.triangles>=Th.nbt");
     18                        _error2_("head-Th.triangles<0 || head-Th.triangles>=Th.nbt");
    1919                }
    2020                head = ThNew.triangles + Th.GetId(head) ;
    2121                if (edge-Th.edges<0 || edge-Th.edges>=Th.nbe);{
    22                         _error_("edge-Th.edges<0 || edge-Th.edges>=Th.nbe");
     22                        _error2_("edge-Th.edges<0 || edge-Th.edges>=Th.nbe");
    2323                }
    2424                edge = ThNew.edges+ Th.GetId(edge);
  • issm/trunk/src/c/objects/Bamg/Triangle.cpp

    r11995 r12706  
    99
    1010        /*Constructors/Destructors*/
    11         /*FUNCTION Triangle(){{{1*/
     11        /*FUNCTION Triangle(){{{*/
    1212        Triangle::Triangle(void){
    1313
    1414        }
    1515        /*}}}*/
    16         /*FUNCTION Triangle(Mesh *Th,long i,long j,long k) {{{1*/
     16        /*FUNCTION Triangle(Mesh *Th,long i,long j,long k) {{{*/
    1717        Triangle::Triangle(Mesh *Th,long i,long j,long k) {
    1818                BamgVertex *v=Th->vertices;
    1919                long nbv = Th->nbv;
    2020                if (i<0 || j<0 || k<0){
    21                         _error_("i<0 || j<0 || k<0");
     21                        _error2_("i<0 || j<0 || k<0");
    2222                }
    2323                if (i>=nbv || j>=nbv || k>=nbv){
    24                         _error_("i>=nbv || j>=nbv || k>=nbv");
     24                        _error2_("i>=nbv || j>=nbv || k>=nbv");
    2525                }
    2626                vertices[0]=v+i;
     
    3232        }
    3333        /*}}}*/
    34         /*FUNCTION Triangle(BamgVertex *v0,BamgVertex *v1,BamgVertex *v2) {{{1*/
     34        /*FUNCTION Triangle(BamgVertex *v0,BamgVertex *v1,BamgVertex *v2) {{{*/
    3535        Triangle::Triangle(BamgVertex *v0,BamgVertex *v1,BamgVertex *v2){
    3636                vertices[0]=v0;
     
    4747
    4848        /*Methods*/
    49         /*FUNCTION Triangle::Adj{{{1*/
     49        /*FUNCTION Triangle::Adj{{{*/
    5050        AdjacentTriangle Triangle::Adj(int i)  const {
    5151                return AdjacentTriangle(adj[i],AdjEdgeIndex[i]&3);
    5252        };/*}}}*/
    53         /*FUNCTION Triangle::Anisotropy{{{1*/
     53        /*FUNCTION Triangle::Anisotropy{{{*/
    5454        double Triangle::Anisotropy() const{
    5555
     
    8080                return lmax/lmin;
    8181        };/*}}}*/
    82         /*FUNCTION Triangle::Length{{{1*/
     82        /*FUNCTION Triangle::Length{{{*/
    8383        double Triangle::Length() const{
    8484
     
    102102                return l;
    103103        };/*}}}*/
    104         /*FUNCTION Triangle::Echo {{{1*/
     104        /*FUNCTION Triangle::Echo {{{*/
    105105        void Triangle::Echo(void){
    106106
    107107                int i;
    108108
    109                 printf("Triangle:\n");
    110                 printf("   vertices pointer towards three vertices\n");
    111                 printf("      vertices[0] vertices[1] vertices[2] = %p %p %p\n",vertices[0],vertices[1],vertices[2]);
    112                 printf("   adj pointer towards three adjacent triangles\n");
    113                 printf("      adj[0] adj[1] adj[2] = %p %p %p\n",adj[0],adj[1],adj[2]);
    114                 printf("   det (integer triangle determinant) = %i\n",det);
     109                _printLine_("Triangle:");
     110                _printLine_("   vertices pointer towards three vertices");
     111                _printLine_("      vertices[0] vertices[1] vertices[2] = " << vertices[0] << " " << vertices[1] << " " << vertices[2]);
     112                _printLine_("   adj pointer towards three adjacent triangles");
     113                _printLine_("      adj[0] adj[1] adj[2] = " << adj[0] << " " << adj[1] << " " << adj[2]);
     114                _printLine_("   det (integer triangle determinant) = " << det);
    115115                if (link){
    116                         printf("   link (pointer toward duplicate triangle)= %p\n",link);
     116                        _printLine_("   link (pointer toward duplicate triangle)= " << link);
    117117                }
    118118                else{
    119                         printf("   color = %i\n",color);
    120                 }
    121 
    122                 printf("\nThree vertices:\n");
     119                        _printLine_("   color = " << color);
     120                }
     121
     122                _printLine_("\nThree vertices:");
    123123                for(i=0;i<3;i++){
    124124                        if (vertices[i]){
     
    126126                        }
    127127                        else{
    128                                 printf("   vertex %i does not exist\n",i+1);
     128                                _printLine_("   vertex " << i+1 << " does not exist");
    129129                        }
    130130                }
     
    133133        }
    134134        /*}}}*/
    135         /*FUNCTION Triangle::FindBoundaryEdge{{{1*/
     135        /*FUNCTION Triangle::FindBoundaryEdge{{{*/
    136136        AdjacentTriangle Triangle::FindBoundaryEdge(int i) const{
    137137                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/FindBoundaryEdge)*/
     
    173173                        //check number of iterations
    174174                        if (k>=2000){
    175                                 _error_("too many iteration in Triangle::FindBoundaryEdge (k>=2000)");
     175                                _error2_("too many iteration in Triangle::FindBoundaryEdge (k>=2000)");
    176176                        }
    177177                } while (this!= t);
     
    179179                return AdjacentTriangle(NULL,0);
    180180        }
    181         /*}}}1*/
    182         /*FUNCTION Triangle::GetAllflag{{{1*/
     181        /*}}}*/
     182        /*FUNCTION Triangle::GetAllflag{{{*/
    183183        int    Triangle::GetAllflag(int a){
    184184                return AdjEdgeIndex[a] & 1020;
    185185        }/*}}}*/
    186         /*FUNCTION Triangle::Hidden{{{1*/
     186        /*FUNCTION Triangle::Hidden{{{*/
    187187        int    Triangle::Hidden(int a)const {
    188188                return AdjEdgeIndex[a]&16;
    189189        } /*}}}*/
    190         /*FUNCTION Triangle::Locked{{{1*/
     190        /*FUNCTION Triangle::Locked{{{*/
    191191        int    Triangle::Locked(int a)const {
    192192                return AdjEdgeIndex[a]&4;
    193193        } /*}}}*/
    194         /*FUNCTION Triangle::NuEdgeTriangleAdj{{{1*/
     194        /*FUNCTION Triangle::NuEdgeTriangleAdj{{{*/
    195195        short  Triangle::NuEdgeTriangleAdj(int i) const {
    196196                /*Number of the  adjacent edge in adj tria (make sure it is between 0 and 2*/
    197197                return AdjEdgeIndex[i&3]&3;
    198198        }/*}}}*/
    199         /*FUNCTION Triangle::Optim{{{1*/
     199        /*FUNCTION Triangle::Optim{{{*/
    200200        long  Triangle::Optim(short i,int koption) {
    201201                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/Optim)*/
     
    213213                do {
    214214                        while (t->swap(j,koption)){
    215                                 if (k>=20000) _error_("k>=20000");
     215                                if (k>=20000) _error2_("k>=20000");
    216216                                NbSwap++;
    217217                                k++;
     
    229229                return NbSwap;
    230230        }
    231         /*}}}1*/
    232         /*FUNCTION Triangle::Quadrangle {{{1*/
     231        /*}}}*/
     232        /*FUNCTION Triangle::Quadrangle {{{*/
    233233        Triangle* Triangle::Quadrangle(BamgVertex * & v0,BamgVertex * & v1,BamgVertex * & v2,BamgVertex * & v3) const{
    234234                // return the other triangle of the quad if a quad or 0 if not a quat
     
    251251        }
    252252        /*}}}*/
    253         /*FUNCTION Triangle::QualityQuad {{{1*/
     253        /*FUNCTION Triangle::QualityQuad {{{*/
    254254        double   Triangle::QualityQuad(int a,int option) const{
    255255                double q;
     
    274274        }
    275275        /*}}}*/
    276         /*FUNCTION Triangle::Renumbering(Triangle *tb,Triangle *te, long *renu){{{1*/
     276        /*FUNCTION Triangle::Renumbering(Triangle *tb,Triangle *te, long *renu){{{*/
    277277        void  Triangle::Renumbering(Triangle *tb,Triangle *te, long *renu){
    278278
     
    282282                if (adj[2] >=tb && adj[2] <te) adj[2] = tb + renu[adj[2]-tb];   
    283283        }/*}}}*/
    284         /*FUNCTION Triangle::Renumbering(BamgVertex *vb,BamgVertex *ve, long *renu){{{1*/
     284        /*FUNCTION Triangle::Renumbering(BamgVertex *vb,BamgVertex *ve, long *renu){{{*/
    285285        void Triangle::Renumbering(BamgVertex *vb,BamgVertex *ve, long *renu){
    286286                if (vertices[0] >=vb && vertices[0] <ve) vertices[0] = vb + renu[vertices[0]-vb];
     
    288288                if (vertices[2] >=vb && vertices[2] <ve) vertices[2] = vb + renu[vertices[2]-vb];   
    289289        }/*}}}*/
    290         /*FUNCTION Triangle::Set {{{1*/
     290        /*FUNCTION Triangle::Set {{{*/
    291291        void Triangle::Set(const Triangle & rec,const Mesh & Th ,Mesh & ThNew){
    292292                *this = rec;
     
    301301        }
    302302        /*}}}*/
    303         /*FUNCTION Triangle::SetAdjAdj{{{1*/
     303        /*FUNCTION Triangle::SetAdjAdj{{{*/
    304304        void Triangle::SetAdjAdj(short a){
    305305                // Copy all the mark
     
    313313                }
    314314        }/*}}}*/
    315         /*FUNCTION Triangle::SetAdj2{{{1*/
     315        /*FUNCTION Triangle::SetAdj2{{{*/
    316316        void Triangle::SetAdj2(short a,Triangle *t,short aat){
    317317                /*For current triangle:
     
    326326                }
    327327        }/*}}}*/
    328         /*FUNCTION Triangle::SetAllFlag{{{1*/
     328        /*FUNCTION Triangle::SetAllFlag{{{*/
    329329        void   Triangle::SetAllFlag(int a,int f){
    330330                AdjEdgeIndex[a] = (AdjEdgeIndex[a] &3) + (1020 & f);
    331331        }/*}}}*/
    332         /*FUNCTION Triangle::SetDet{{{1*/
     332        /*FUNCTION Triangle::SetDet{{{*/
    333333        void Triangle::SetDet() {
    334334                if(vertices[0] && vertices[1] && vertices[2])    det = bamg::det(*vertices[0],*vertices[1],*vertices[2]);
    335335                else det = -1;
    336336        }/*}}}*/
    337         /*FUNCTION Triangle::SetHidden{{{1*/
     337        /*FUNCTION Triangle::SetHidden{{{*/
    338338        void Triangle::SetHidden(int a){
    339339                //Get Adjacent Triangle number a
     
    344344                AdjEdgeIndex[a] |= 16;
    345345        }/*}}}*/
    346         /*FUNCTION Triangle::SetLocked{{{1*/
     346        /*FUNCTION Triangle::SetLocked{{{*/
    347347        void Triangle::SetLocked(int a){
    348348                //mark the edge as on Boundary
     
    351351                AdjEdgeIndex[a] |= 4;
    352352        }/*}}}*/
    353         /*FUNCTION Triangle::SetMarkUnSwap{{{1*/
     353        /*FUNCTION Triangle::SetMarkUnSwap{{{*/
    354354        void Triangle::SetMarkUnSwap(int a){
    355355                register Triangle * t = adj[a];
     
    357357                AdjEdgeIndex[a] |=8 ;
    358358        }/*}}}*/
    359         /*FUNCTION Triangle::SetSingleVertexToTriangleConnectivity{{{1*/
     359        /*FUNCTION Triangle::SetSingleVertexToTriangleConnectivity{{{*/
    360360        void Triangle::SetSingleVertexToTriangleConnectivity() {
    361361                if (vertices[0]) (vertices[0]->t=this,vertices[0]->IndexInTriangle=0);
     
    363363                if (vertices[2]) (vertices[2]->t=this,vertices[2]->IndexInTriangle=2);
    364364        }/*}}}*/
    365         /*FUNCTION Triangle::SetUnMarkUnSwap{{{1*/
     365        /*FUNCTION Triangle::SetUnMarkUnSwap{{{*/
    366366        void Triangle::SetUnMarkUnSwap(int a){
    367367                register Triangle * t = adj[a];
     
    369369                AdjEdgeIndex[a] &=55 ;
    370370        }/*}}}*/
    371         /*FUNCTION Triangle::swap{{{1*/
     371        /*FUNCTION Triangle::swap{{{*/
    372372        int Triangle::swap(short a,int koption){
    373373                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/swap)*/
     
    483483                return OnSwap;
    484484        }
    485         /*}}}1*/
    486         /*FUNCTION Triangle::TriangleAdj{{{1*/
     485        /*}}}*/
     486        /*FUNCTION Triangle::TriangleAdj{{{*/
    487487        Triangle* Triangle::TriangleAdj(int i) const {
    488488                return adj[i&3];
  • issm/trunk/src/c/objects/Bamg/VertexOnEdge.cpp

    r9326 r12706  
    1010
    1111        /*Methods*/
    12         /*FUNCTION VertexOnEdge::Set {{{1*/
     12        /*FUNCTION VertexOnEdge::Set {{{*/
    1313        void VertexOnEdge::Set(const Mesh & Th ,long i,Mesh & ThNew){
    1414                *this = Th.VertexOnBThEdge[i]; 
     
    1616        }
    1717        /*}}}*/
    18         /*FUNCTION VertexOnEdge::SetOnBTh{{{1*/
     18        /*FUNCTION VertexOnEdge::SetOnBTh{{{*/
    1919        void VertexOnEdge::SetOnBTh(){
    2020                v->BackgroundEdgeHook=this;
  • issm/trunk/src/c/objects/Bamg/VertexOnGeom.cpp

    r9399 r12706  
    1111
    1212        /*Constructors/Destructors*/
    13         /*FUNCTION VertexOnGeom::VertexOnGeom(){{{1*/
     13        /*FUNCTION VertexOnGeom::VertexOnGeom(){{{*/
    1414        VertexOnGeom::VertexOnGeom(){
    1515                meshvertex=NULL;
     
    1818        }
    1919        /*}}}*/
    20         /*FUNCTION VertexOnGeom::VertexOnGeom(BamgVertex & m,GeomVertex &g){{{1*/
     20        /*FUNCTION VertexOnGeom::VertexOnGeom(BamgVertex & m,GeomVertex &g){{{*/
    2121        VertexOnGeom::VertexOnGeom(BamgVertex & m,GeomVertex &g){
    2222                meshvertex=&m;
     
    2525        }
    2626        /*}}}*/
    27         /*FUNCTION VertexOnGeom::VertexOnGeom(BamgVertex & m,GeomEdge &g,double s){{{1*/
     27        /*FUNCTION VertexOnGeom::VertexOnGeom(BamgVertex & m,GeomEdge &g,double s){{{*/
    2828        VertexOnGeom::VertexOnGeom(BamgVertex & m,GeomEdge &g,double s){
    2929                meshvertex=&m;
     
    3434
    3535        /*Methods*/
    36         /*FUNCTION VertexOnGeom::Set {{{1*/
     36        /*FUNCTION VertexOnGeom::Set {{{*/
    3737        void VertexOnGeom::Set(const VertexOnGeom & rec,const Mesh & Th ,Mesh & ThNew){
    3838                *this = rec; 
     
    4646        }
    4747        /*}}}*/
    48         /*FUNCTION VertexOnGeom::OnGeomVertex{{{1*/
     48        /*FUNCTION VertexOnGeom::OnGeomVertex{{{*/
    4949        int VertexOnGeom::OnGeomVertex()const{
    5050                return this? curvilincoord <0 :0;
    5151        }
    5252        /*}}}*/
    53         /*FUNCTION VertexOnGeom::OnGeomEdge{{{1*/
     53        /*FUNCTION VertexOnGeom::OnGeomEdge{{{*/
    5454        int VertexOnGeom::OnGeomEdge() const{
    5555                return this? curvilincoord >=0 :0;
    5656        }
    5757        /*}}}*/
    58         /*FUNCTION VertexOnGeom::IsRequiredVertex{{{1*/
     58        /*FUNCTION VertexOnGeom::IsRequiredVertex{{{*/
    5959        int VertexOnGeom::IsRequiredVertex() {
    6060                return this? ((curvilincoord<0 ? (gv?gv->Required():0):0 )) : 0;
    6161        }
    6262        /*}}}*/
    63         /*FUNCTION VertexOnGeom::SetOn{{{1*/
     63        /*FUNCTION VertexOnGeom::SetOn{{{*/
    6464        void VertexOnGeom::SetOn(){
    6565                meshvertex->GeomEdgeHook=this;
  • issm/trunk/src/c/objects/Bamg/VertexOnVertex.cpp

    r9371 r12706  
    1010
    1111        /*Constructors/Destructors*/
    12         /*FUNCTION VertexOnVertex::VertexOnVertex(){{{1*/
     12        /*FUNCTION VertexOnVertex::VertexOnVertex(){{{*/
    1313        VertexOnVertex::VertexOnVertex() {
    1414                v=NULL;
    1515                bv=NULL;
    1616        };/*}}}*/
    17         /*FUNCTION VertexOnVertex::VertexOnVertex(BamgVertex * w,BamgVertex *bw){{{1*/
     17        /*FUNCTION VertexOnVertex::VertexOnVertex(BamgVertex * w,BamgVertex *bw){{{*/
    1818        VertexOnVertex::VertexOnVertex(BamgVertex * w,BamgVertex *bw) :v(w),bv(bw){
    1919       
     
    2121
    2222        /*Methods*/
    23         /*FUNCTION VertexOnVertex::Set{{{1*/
     23        /*FUNCTION VertexOnVertex::Set{{{*/
    2424        void VertexOnVertex::Set(const Mesh &Th ,long i,Mesh &ThNew) {
    2525                *this = Th.VertexOnBThVertex[i]; 
     
    2727        }
    2828        /*}}}*/
    29         /*FUNCTION VertexOnVertex::SetOnBTh{{{1*/
     29        /*FUNCTION VertexOnVertex::SetOnBTh{{{*/
    3030        void VertexOnVertex::SetOnBTh(){
    3131                v->BackgroundVertexHook=bv;v->IndexInTriangle=IsVertexOnVertex;
  • issm/trunk/src/c/objects/Constraints/Constraint.h

    r12330 r12706  
    1010
    1111/*Headers:*/
    12 /*{{{1*/
     12/*{{{*/
    1313class Nodes;
    1414#include "../Object.h"
  • issm/trunk/src/c/objects/Constraints/SpcDynamic.cpp

    r12330 r12706  
    1818
    1919/*SpcDynamic constructors and destructor*/
    20 /*FUNCTION SpcDynamic::SpcDynamic(){{{1*/
     20/*FUNCTION SpcDynamic::SpcDynamic(){{{*/
    2121SpcDynamic::SpcDynamic(){
    2222        return;
    2323}
    24 /*}}}1*/
    25 /*FUNCTION SpcDynamic::SpcDynamic(int spc_sid,int spc_nodeid,...){{{1*/
     24/*}}}*/
     25/*FUNCTION SpcDynamic::SpcDynamic(int spc_sid,int spc_nodeid,...){{{*/
    2626SpcDynamic::SpcDynamic(int spc_sid,int spc_nodeid, int spc_dof,int spc_analysis_type){
    2727
     
    3535        return;
    3636}
    37 /*}}}1*/
    38 /*FUNCTION SpcDynamic::~SpcDynamic{{{1*/
     37/*}}}*/
     38/*FUNCTION SpcDynamic::~SpcDynamic{{{*/
    3939SpcDynamic::~SpcDynamic(){
    4040        return;
    4141}
    42 /*}}}1*/
     42/*}}}*/
    4343               
    4444/*Object virtual functions definitions:*/
    45 /*FUNCTION SpcDynamic::Echo {{{1*/
     45/*FUNCTION SpcDynamic::Echo {{{*/
    4646void SpcDynamic::Echo(void){
    4747
    48         printf("SpcDynamic:\n");
    49         printf("   sid: %i\n",sid);
    50         printf("   nodeid: %i\n",nodeid);
    51         printf("   dof: %i\n",dof);
    52         printf("   value: %g\n",value);
    53         printf("   isset: %s\n",isset?"true":"false");
    54         printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
     48        _printLine_("SpcDynamic:");
     49        _printLine_("   sid: " << sid);
     50        _printLine_("   nodeid: " << nodeid);
     51        _printLine_("   dof: " << dof);
     52        _printLine_("   value: " << value);
     53        _printLine_("   isset: " <<(isset?"true":"false"));
     54        _printLine_("   analysis_type: " << EnumToStringx(analysis_type));
    5555        return;
    5656}
    57 /*}}}1*/
    58 /*FUNCTION SpcDynamic::DeepEcho {{{1*/
     57/*}}}*/
     58/*FUNCTION SpcDynamic::DeepEcho {{{*/
    5959void SpcDynamic::DeepEcho(void){
    6060
     
    6262        return;
    6363}               
    64 /*}}}1*/
    65 /*FUNCTION SpcDynamic::Id {{{1*/
     64/*}}}*/
     65/*FUNCTION SpcDynamic::Id {{{*/
    6666int    SpcDynamic::Id(void){ return sid; }
    67 /*}}}1*/
    68 /*FUNCTION SpcDynamic::MyRank {{{1*/
     67/*}}}*/
     68/*FUNCTION SpcDynamic::MyRank {{{*/
    6969int    SpcDynamic::MyRank(void){
    7070        extern int my_rank;
    7171        return my_rank;
    7272}
    73 /*}}}1*/
    74 /*FUNCTION SpcDynamic::ObjectEnum{{{1*/
     73/*}}}*/
     74/*FUNCTION SpcDynamic::ObjectEnum{{{*/
    7575int SpcDynamic::ObjectEnum(void){
    7676
     
    7878
    7979}
    80 /*}}}1*/
    81 /*FUNCTION SpcDynamic::copy {{{1*/
     80/*}}}*/
     81/*FUNCTION SpcDynamic::copy {{{*/
    8282Object* SpcDynamic::copy() {
    8383        return new SpcDynamic(*this);
    8484}
    85 /*}}}1*/
     85/*}}}*/
    8686
    8787/*Constraint virtual functions definitions: */
    88 /*FUNCTION SpcDynamic::InAnalysis{{{1*/
     88/*FUNCTION SpcDynamic::InAnalysis{{{*/
    8989bool SpcDynamic::InAnalysis(int in_analysis_type){
    9090        if (in_analysis_type==this->analysis_type) return true;
     
    9292}
    9393/*}}}*/
    94 /*FUNCTION SpcDynamic::ConstrainNode{{{1*/
     94/*FUNCTION SpcDynamic::ConstrainNode{{{*/
    9595void SpcDynamic::ConstrainNode(Nodes* nodes,Parameters* parameters){
    9696
     
    110110
    111111/*SpcDynamic functions*/
    112 /*FUNCTION SpcDynamic::GetDof {{{1*/
     112/*FUNCTION SpcDynamic::GetDof {{{*/
    113113int SpcDynamic::GetDof(){
    114114        return dof;
    115115}
    116 /*}}}1*/
    117 /*FUNCTION SpcDynamic::GetNodeId {{{1*/
     116/*}}}*/
     117/*FUNCTION SpcDynamic::GetNodeId {{{*/
    118118int   SpcDynamic::GetNodeId(){
    119119       
    120120        return nodeid;
    121121}
    122 /*}}}1*/
    123 /*FUNCTION SpcDynamic::GetValue {{{1*/
    124 double SpcDynamic::GetValue(){
     122/*}}}*/
     123/*FUNCTION SpcDynamic::GetValue {{{*/
     124IssmDouble SpcDynamic::GetValue(){
    125125        _assert_(this->isset);
    126         _assert_(!isnan(value));
     126        _assert_(!xIsNan<IssmDouble>(value));
    127127        return value;
    128128}
    129 /*}}}1*/
    130 /*FUNCTION SpcDynamic::SetDynamicConstraint {{{1*/
    131 void SpcDynamic::SetDynamicConstraint(Nodes* nodes,double* yg_serial){
     129/*}}}*/
     130/*FUNCTION SpcDynamic::SetDynamicConstraint {{{*/
     131void SpcDynamic::SetDynamicConstraint(Nodes* nodes,IssmDouble* yg_serial){
    132132
    133133        int pos;
     
    139139        this->isset=true;
    140140}
    141 /*}}}1*/
     141/*}}}*/
  • issm/trunk/src/c/objects/Constraints/SpcDynamic.h

    r12330 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "../Object.h"
    1111class DataSet;
     
    1818                int     nodeid; /*!node id*/
    1919                int dof; /*!component*/
    20                 double value; /*value*/
     20                IssmDouble value; /*value*/
    2121                bool isset;
    2222                int analysis_type;
     
    2424        public:
    2525
    26                 /*SpcDynamic constructors, destructors:{{{1*/
     26                /*SpcDynamic constructors, destructors:{{{*/
    2727                SpcDynamic();
    2828                SpcDynamic(int sid,int nodeid, int dof,int analysis_type);
    2929                ~SpcDynamic();
    3030                /*}}}*/
    31                 /*Object virtual functions definitions:{{{1 */
     31                /*Object virtual functions definitions:{{{ */
    3232                void  Echo();
    3333                void  DeepEcho();
     
    3737                Object* copy();
    3838                /*}}}*/
    39                 /*Constraint virtual functions definitions: {{{1*/
     39                /*Constraint virtual functions definitions: {{{*/
    4040                void   ConstrainNode(Nodes* nodes,Parameters* parameters);
    4141                bool   InAnalysis(int analysis_type);
    4242                /*}}}*/
    43                 /*SpcDynamic management:{{{1 */
     43                /*SpcDynamic management:{{{ */
    4444                int    GetNodeId();
    4545                int    GetDof();
    46                 double GetValue();
    47                 void   SetDynamicConstraint(Nodes* nodes,double *yg_serial);
     46                IssmDouble GetValue();
     47                void   SetDynamicConstraint(Nodes* nodes,IssmDouble *yg_serial);
    4848                /*}}}*/
    4949
  • issm/trunk/src/c/objects/Constraints/SpcStatic.cpp

    r12330 r12706  
    1818
    1919/*SpcStatic constructors and destructor*/
    20 /*FUNCTION SpcStatic::SpcStatic(){{{1*/
     20/*FUNCTION SpcStatic::SpcStatic(){{{*/
    2121SpcStatic::SpcStatic(){
    2222        return;
    2323}
    24 /*}}}1*/
    25 /*FUNCTION SpcStatic::SpcStatic(int spc_sid,int spc_nodeid,...){{{1*/
    26 SpcStatic::SpcStatic(int spc_sid,int spc_nodeid, int spc_dof,double spc_value,int spc_analysis_type){
     24/*}}}*/
     25/*FUNCTION SpcStatic::SpcStatic(int spc_sid,int spc_nodeid,...){{{*/
     26SpcStatic::SpcStatic(int spc_sid,int spc_nodeid, int spc_dof,IssmDouble spc_value,int spc_analysis_type){
    2727
    2828        sid=spc_sid;
     
    3434        return;
    3535}
    36 /*}}}1*/
    37 /*FUNCTION SpcStatic::~SpcStatic{{{1*/
     36/*}}}*/
     37/*FUNCTION SpcStatic::~SpcStatic{{{*/
    3838SpcStatic::~SpcStatic(){
    3939        return;
    4040}
    41 /*}}}1*/
     41/*}}}*/
    4242               
    4343/*Object virtual functions definitions:*/
    44 /*FUNCTION SpcStatic::Echo {{{1*/
     44/*FUNCTION SpcStatic::Echo {{{*/
    4545void SpcStatic::Echo(void){
    4646
    47         printf("SpcStatic:\n");
    48         printf("   sid: %i\n",sid);
    49         printf("   nodeid: %i\n",nodeid);
    50         printf("   dof: %i\n",dof);
    51         printf("   value: %g\n",value);
    52         printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
     47        _printLine_("SpcStatic:");
     48        _printLine_("   sid: " << sid);
     49        _printLine_("   nodeid: " << nodeid);
     50        _printLine_("   dof: " << dof);
     51        _printLine_("   value: " << value);
     52        _printLine_("   analysis_type: " << EnumToStringx(analysis_type));
    5353        return;
    5454}
    55 /*}}}1*/
    56 /*FUNCTION SpcStatic::DeepEcho {{{1*/
     55/*}}}*/
     56/*FUNCTION SpcStatic::DeepEcho {{{*/
    5757void SpcStatic::DeepEcho(void){
    5858
    59         printf("SpcStatic:\n");
    60         printf("   sid: %i\n",sid);
    61         printf("   nodeid: %i\n",nodeid);
    62         printf("   dof: %i\n",dof);
    63         printf("   value: %g\n",value);
    64         printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
     59        _printLine_("SpcStatic:");
     60        _printLine_("   sid: " << sid);
     61        _printLine_("   nodeid: " << nodeid);
     62        _printLine_("   dof: " << dof);
     63        _printLine_("   value: " << value);
     64        _printLine_("   analysis_type: " << EnumToStringx(analysis_type));
    6565        return;
    6666}               
    67 /*}}}1*/
    68 /*FUNCTION SpcStatic::Id {{{1*/
     67/*}}}*/
     68/*FUNCTION SpcStatic::Id {{{*/
    6969int    SpcStatic::Id(void){ return sid; }
    70 /*}}}1*/
    71 /*FUNCTION SpcStatic::MyRank {{{1*/
     70/*}}}*/
     71/*FUNCTION SpcStatic::MyRank {{{*/
    7272int    SpcStatic::MyRank(void){
    7373        extern int my_rank;
    7474        return my_rank;
    7575}
    76 /*}}}1*/
    77 /*FUNCTION SpcStatic::ObjectEnum{{{1*/
     76/*}}}*/
     77/*FUNCTION SpcStatic::ObjectEnum{{{*/
    7878int SpcStatic::ObjectEnum(void){
    7979
     
    8181
    8282}
    83 /*}}}1*/
    84 /*FUNCTION SpcStatic::copy {{{1*/
     83/*}}}*/
     84/*FUNCTION SpcStatic::copy {{{*/
    8585Object* SpcStatic::copy() {
    8686        return new SpcStatic(*this);
    8787}
    88 /*}}}1*/
     88/*}}}*/
    8989
    9090/*Constraint virtual functions definitions: */
    91 /*FUNCTION SpcStatic::InAnalysis{{{1*/
     91/*FUNCTION SpcStatic::InAnalysis{{{*/
    9292bool SpcStatic::InAnalysis(int in_analysis_type){
    9393        if (in_analysis_type==this->analysis_type) return true;
     
    9595}
    9696/*}}}*/
    97 /*FUNCTION SpcStatic::ConstrainNode{{{1*/
     97/*FUNCTION SpcStatic::ConstrainNode{{{*/
    9898void SpcStatic::ConstrainNode(Nodes* nodes,Parameters* parameters){
    9999
     
    111111
    112112/*SpcStatic functions*/
    113 /*FUNCTION SpcStatic::GetDof {{{1*/
     113/*FUNCTION SpcStatic::GetDof {{{*/
    114114int SpcStatic::GetDof(){
    115115        return dof;
    116116}
    117 /*}}}1*/
    118 /*FUNCTION SpcStatic::GetNodeId {{{1*/
     117/*}}}*/
     118/*FUNCTION SpcStatic::GetNodeId {{{*/
    119119int   SpcStatic::GetNodeId(){
    120120       
    121121        return nodeid;
    122122}
    123 /*}}}1*/
    124 /*FUNCTION SpcStatic::GetValue {{{1*/
    125 double SpcStatic::GetValue(){
    126         _assert_(!isnan(value));
     123/*}}}*/
     124/*FUNCTION SpcStatic::GetValue {{{*/
     125IssmDouble SpcStatic::GetValue(){
     126        _assert_(!xIsNan<IssmDouble>(value));
    127127        return value;
    128128}
    129 /*}}}1*/
     129/*}}}*/
  • issm/trunk/src/c/objects/Constraints/SpcStatic.h

    r12330 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "../Object.h"
    1111class DataSet;
     
    1818                int     nodeid; /*!node id*/
    1919                int dof; /*!component*/
    20                 double value; /*value*/
     20                IssmDouble value; /*value*/
    2121                int analysis_type;
    2222
    2323        public:
    2424
    25                 /*SpcStatic constructors, destructors:{{{1*/
     25                /*SpcStatic constructors, destructors:{{{*/
    2626                SpcStatic();
    27                 SpcStatic(int sid,int nodeid, int dof,double value,int analysis_type);
     27                SpcStatic(int sid,int nodeid, int dof,IssmDouble value,int analysis_type);
    2828                ~SpcStatic();
    2929                /*}}}*/
    30                 /*Object virtual functions definitions:{{{1 */
     30                /*Object virtual functions definitions:{{{ */
    3131                void  Echo();
    3232                void  DeepEcho();
     
    3636                Object* copy();
    3737                /*}}}*/
    38                 /*Constraint virtual functions definitions: {{{1*/
     38                /*Constraint virtual functions definitions: {{{*/
    3939                void   ConstrainNode(Nodes* nodes,Parameters* parameters);
    4040                bool   InAnalysis(int analysis_type);
    4141                /*}}}*/
    42                 /*SpcStatic management:{{{1 */
     42                /*SpcStatic management:{{{ */
    4343                int    GetNodeId();
    4444                int    GetDof();
    45                 double GetValue();
     45                IssmDouble GetValue();
    4646                /*}}}*/
    4747
  • issm/trunk/src/c/objects/Constraints/SpcTransient.cpp

    r12330 r12706  
    1818
    1919/*SpcTransient constructors and destructor*/
    20 /*FUNCTION SpcTransient::SpcTransient(){{{1*/
     20/*FUNCTION SpcTransient::SpcTransient(){{{*/
    2121SpcTransient::SpcTransient(){
    2222        sid=-1;
     
    2929        return;
    3030}
    31 /*}}}1*/
    32 /*FUNCTION SpcTransient::SpcTransient(int spc_sid,int spc_nodeid,...){{{1*/
    33 SpcTransient::SpcTransient(int spc_sid,int spc_nodeid, int spc_dof,int spc_nsteps, double* spc_times, double* spc_values,int spc_analysis_type){
     31/*}}}*/
     32/*FUNCTION SpcTransient::SpcTransient(int spc_sid,int spc_nodeid,...){{{*/
     33SpcTransient::SpcTransient(int spc_sid,int spc_nodeid, int spc_dof,int spc_nsteps, IssmDouble* spc_times, IssmDouble* spc_values,int spc_analysis_type){
    3434
    3535        sid=spc_sid;
     
    3838        nsteps=spc_nsteps;
    3939        if(spc_nsteps){
    40                 values=(double*)xmalloc(spc_nsteps*sizeof(double));
    41                 times=(double*)xmalloc(spc_nsteps*sizeof(double));
    42                 memcpy(values,spc_values,nsteps*sizeof(double));
    43                 memcpy(times,spc_times,nsteps*sizeof(double));
     40                values=xNew<IssmDouble>(spc_nsteps);
     41                times=xNew<IssmDouble>(spc_nsteps);
     42                xMemCpy<IssmDouble>(values,spc_values,nsteps);
     43                xMemCpy<IssmDouble>(times,spc_times,nsteps);
    4444        }
    4545        analysis_type=spc_analysis_type;
    4646        return;
    4747}
    48 /*}}}1*/
    49 /*FUNCTION SpcTransient::~SpcTransient{{{1*/
     48/*}}}*/
     49/*FUNCTION SpcTransient::~SpcTransient{{{*/
    5050SpcTransient::~SpcTransient(){
    51         xfree((void**)&times);
    52         xfree((void**)&values);
     51        xDelete<IssmDouble>(times);
     52        xDelete<IssmDouble>(values);
    5353        return;
    5454}
    55 /*}}}1*/
     55/*}}}*/
    5656               
    5757/*Object virtual functions definitions:*/
    58 /*FUNCTION SpcTransient::Echo {{{1*/
     58/*FUNCTION SpcTransient::Echo {{{*/
    5959void SpcTransient::Echo(void){
    6060
    6161        int i;
    62         printf("SpcTransient:\n");
    63         printf("   sid: %i\n",sid);
    64         printf("   nodeid: %i\n",nodeid);
    65         printf("   dof: %i\n",dof);
    66         printf("   nsteps: %i\n",nsteps);
    67         printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
    68         printf("   steps|times|values\n");
     62        _printLine_("SpcTransient:");
     63        _printLine_("   sid: " << sid);
     64        _printLine_("   nodeid: " << nodeid);
     65        _printLine_("   dof: " << dof);
     66        _printLine_("   nsteps: " << nsteps);
     67        _printLine_("   analysis_type: " << EnumToStringx(analysis_type));
     68        _printLine_("   steps|times|values");
    6969        for(i=0;i<nsteps;i++){
    70                 printf("%i-%g:%g\n",i,times[i],values[i]);
     70                _printLine_(i << "-" << times[i] << ":" << values[i]);
    7171        }
    7272        return;
    7373}
    74 /*}}}1*/
    75 /*FUNCTION SpcTransient::DeepEcho {{{1*/
     74/*}}}*/
     75/*FUNCTION SpcTransient::DeepEcho {{{*/
    7676void SpcTransient::DeepEcho(void){
    7777        this->Echo();
    7878}               
    79 /*}}}1*/
    80 /*FUNCTION SpcTransient::Id {{{1*/
     79/*}}}*/
     80/*FUNCTION SpcTransient::Id {{{*/
    8181int    SpcTransient::Id(void){ return sid; }
    82 /*}}}1*/
    83 /*FUNCTION SpcTransient::MyRank {{{1*/
     82/*}}}*/
     83/*FUNCTION SpcTransient::MyRank {{{*/
    8484int    SpcTransient::MyRank(void){
    8585        extern int my_rank;
    8686        return my_rank;
    8787}
    88 /*}}}1*/
    89 /*FUNCTION SpcTransient::ObjectEnum{{{1*/
     88/*}}}*/
     89/*FUNCTION SpcTransient::ObjectEnum{{{*/
    9090int SpcTransient::ObjectEnum(void){
    9191
     
    9393
    9494}
    95 /*}}}1*/
    96 /*FUNCTION SpcTransient::copy {{{1*/
     95/*}}}*/
     96/*FUNCTION SpcTransient::copy {{{*/
    9797Object* SpcTransient::copy() {
    9898        return new SpcTransient(sid,nodeid,dof,nsteps,times,values,analysis_type);
    9999}
    100 /*}}}1*/
     100/*}}}*/
    101101
    102102/*Constraint virtual functions definitions:*/
    103 /*FUNCTION SpcTransient::InAnalysis{{{1*/
     103/*FUNCTION SpcTransient::InAnalysis{{{*/
    104104bool SpcTransient::InAnalysis(int in_analysis_type){
    105105       
     
    108108}
    109109/*}}}*/
    110 /*FUNCTION SpcTransient::ConstrainNode{{{1*/
     110/*FUNCTION SpcTransient::ConstrainNode{{{*/
    111111void SpcTransient::ConstrainNode(Nodes* nodes,Parameters* parameters){
    112112
    113113        Node* node=NULL;
    114         double time=0;
     114        IssmDouble time=0;
    115115        int    i;
    116         double alpha=-1;
    117         double value;
     116        IssmDouble alpha=-1;
     117        IssmDouble value;
    118118        bool   found=false;
    119119
     
    146146                }
    147147
    148                 if(!found)_error_("could not find time segment for constraint");
     148                if(!found)_error2_("could not find time segment for constraint");
    149149
    150150                /*Apply or relax constraint: */
    151                 if(isnan(value)){
     151                if(xIsNan<IssmDouble>(value)){
    152152                        node->RelaxConstraint(dof);
    153153                }
     
    158158
    159159/*SpcTransient functions*/
    160 /*FUNCTION SpcTransient::GetDof {{{1*/
     160/*FUNCTION SpcTransient::GetDof {{{*/
    161161int SpcTransient::GetDof(){
    162162        return dof;
    163163}
    164 /*}}}1*/
    165 /*FUNCTION SpcTransient::GetNodeId {{{1*/
     164/*}}}*/
     165/*FUNCTION SpcTransient::GetNodeId {{{*/
    166166int   SpcTransient::GetNodeId(){
    167167       
    168168        return nodeid;
    169169}
    170 /*}}}1*/
    171 /*FUNCTION SpcTransient::GetValue {{{1*/
    172 double SpcTransient::GetValue(){
     170/*}}}*/
     171/*FUNCTION SpcTransient::GetValue {{{*/
     172IssmDouble SpcTransient::GetValue(){
    173173        return values[0];
    174174}
    175 /*}}}1*/
     175/*}}}*/
    176176
  • issm/trunk/src/c/objects/Constraints/SpcTransient.h

    r12330 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "../Object.h"
    1111class DataSet;
     
    1818                int     nodeid; /*!node id*/
    1919                int dof; /*!component*/
    20                 double* values; /*different values in time*/
    21                 double* times; /*different time steps*/
     20                IssmDouble* values; /*different values in time*/
     21                IssmDouble* times; /*different time steps*/
    2222                int nsteps; /*number of time steps*/
    2323                int analysis_type;
     
    2525        public:
    2626
    27                 /*SpcTransient constructors, destructors:{{{1*/
     27                /*SpcTransient constructors, destructors:{{{*/
    2828                SpcTransient();
    29                 SpcTransient(int sid,int nodeid, int dof,int nsteps, double* times, double* values,int analysis_type);
     29                SpcTransient(int sid,int nodeid, int dof,int nsteps, IssmDouble* times, IssmDouble* values,int analysis_type);
    3030                ~SpcTransient();
    3131                /*}}}*/
    32                 /*Object virtual functions definitions:{{{1 */
     32                /*Object virtual functions definitions:{{{ */
    3333                void  Echo();
    3434                void  DeepEcho();
     
    3838                Object* copy();
    3939                /*}}}*/
    40                 /*Constraint virtual functions definitions: {{{1*/
     40                /*Constraint virtual functions definitions: {{{*/
    4141                void   ConstrainNode(Nodes* nodes,Parameters* parameters);
    4242                bool   InAnalysis(int analysis_type);
    4343                /*}}}*/
    44                 /*SpcTransient management:{{{1 */
     44                /*SpcTransient management:{{{ */
    4545                int    GetNodeId();
    4646                int    GetDof();
    47                 double GetValue();
     47                IssmDouble GetValue();
    4848                /*}}}*/
    4949
  • issm/trunk/src/c/objects/Contour.cpp

    r12330 r12706  
    1515
    1616/*Contour constructors and destructors:*/
    17 /*FUNCTION Contour::Contour() default constructor {{{1*/
     17/*FUNCTION Contour::Contour() default constructor {{{*/
    1818Contour::Contour(){
    1919        this->id=0;
     
    2424}
    2525/*}}}*/
    26 /*FUNCTION Contour::Contour(int pid, int nods, double* x, double* y,bool closed) {{{1*/
    27 Contour::Contour(int pid,int pnods, double* px, double* py,bool pclosed){
     26/*FUNCTION Contour::Contour(int pid, int nods, IssmDouble* x, IssmDouble* y,bool closed) {{{*/
     27Contour::Contour(int pid,int pnods, IssmDouble* px, IssmDouble* py,bool pclosed){
    2828       
    2929        this->id=pid;
     
    3131        this->closed=pclosed;
    3232        if(nods){
    33                 this->x=(double*)xmalloc(nods*sizeof(double));
    34                 memcpy(this->x,px,nods*sizeof(double));
    35                 this->y=(double*)xmalloc(nods*sizeof(double));
    36                 memcpy(this->y,py,nods*sizeof(double));
     33                this->x=xNew<IssmDouble>(nods);
     34                xMemCpy<IssmDouble>(this->x,px,nods);
     35                this->y=xNew<IssmDouble>(nods);
     36                xMemCpy<IssmDouble>(this->y,py,nods);
    3737        }
    3838}
    3939/*}}}*/
    40 /*FUNCTION Contour::Contour() default constructor {{{1*/
     40/*FUNCTION Contour::Contour() default constructor {{{*/
    4141Contour::~Contour(){
    42         xfree((void**)&this->x);
    43         xfree((void**)&this->y);
     42        xDelete<IssmDouble>(this->x);
     43        xDelete<IssmDouble>(this->y);
    4444}
    4545/*}}}*/
     
    4747
    4848/*Object virtual function resolutoin: */
    49 /*FUNCTION Contour::Echo(){{{1*/
     49/*FUNCTION Contour::Echo(){{{*/
    5050void Contour::Echo(void){
    5151
    5252        int i;
    5353
    54         printf("Contour: %i:\n",id);
    55         printf("   nods: %i\n",nods);
    56         printf("   closed: %s\n",closed?"true":"false");
     54        _printLine_("Contour: " << id);
     55        _printLine_("   nods: " << nods);
     56        _printLine_("   closed: " << (closed?"true":"false"));
    5757        if(nods){
    58                 printf("   x,y:\n");
     58                _printLine_("   x,y:");
    5959                for(i=0;i<nods;i++){
    60                         printf("%i: %g|%g\n",i,x[i],y[i]);
     60                        _printLine_(i << ": " << x[i] << "|" << y[i]);
    6161                }
    6262        }
    6363}
    6464/*}}}*/
    65 /*FUNCTION Contour::DeepEcho(){{{1*/
     65/*FUNCTION Contour::DeepEcho(){{{*/
    6666void Contour::DeepEcho(void){
    6767        this->Echo();
    6868}
    6969/*}}}*/
    70 /*FUNCTION Contour::Id(){{{1*/
     70/*FUNCTION Contour::Id(){{{*/
    7171int Contour::Id(void){
    7272        return id;
    7373}
    7474/*}}}*/
    75 /*FUNCTION Contour::MyRank{{{1*/
     75/*FUNCTION Contour::MyRank{{{*/
    7676int    Contour::MyRank(void){
    7777        extern int my_rank;
     
    8080}
    8181/*}}}*/
    82 /*FUNCTION Contour::ObjectEnum{{{1*/
     82/*FUNCTION Contour::ObjectEnum{{{*/
    8383int Contour::ObjectEnum(void){
    8484
     
    8787}
    8888/*}}}*/
    89 /*FUNCTION Contour::copy {{{1*/
     89/*FUNCTION Contour::copy {{{*/
    9090Object* Contour::copy() {
    9191
  • issm/trunk/src/c/objects/Contour.h

    r12330 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "./Object.h"
    1111#include "../shared/Exceptions/exceptions.h"
     
    2424                bool    closed; //is this contour closed?
    2525
    26                 /*Contour constructors, destructors {{{1*/
     26                /*Contour constructors, destructors {{{*/
    2727                Contour();
    2828                Contour(int id, int nods, IssmDouble* x, IssmDouble* y,bool closed);
    2929                ~Contour();
    3030                /*}}}*/
    31                 /*Object virtual functions{{{1*/
     31                /*Object virtual functions{{{*/
    3232                void  Echo(void);
    3333                void  DeepEcho(void);
  • issm/trunk/src/c/objects/DakotaPlugin.cpp

    r9571 r12706  
    5757
    5858        int i;
    59         double* variables=NULL;
     59        IssmDouble* variables=NULL;
    6060        char** variable_descriptors=NULL;
    6161        char*  variable_descriptor=NULL;
    62         double* responses=NULL;
     62        IssmDouble* responses=NULL;
    6363
    6464        /*increae counter: */
     
    6969
    7070        /*First, the variables: */
    71         variables=(double*)xmalloc(numACV*sizeof(double));
     71        variables=xNew<IssmDouble>(numACV);
    7272        for(i=0;i<numACV;i++){
    7373                variables[i]=xC[i];
    7474        }
    7575        /*The descriptors: */
    76         variable_descriptors=(char**)xmalloc(numACV*sizeof(char*));
     76        variable_descriptors=xNew<char*>(numACV);
    7777        for(i=0;i<numACV;i++){
    7878                string label=xCLabels[i];
    79                 variable_descriptor=(char*)xmalloc((strlen(label.c_str())+1)*sizeof(char));
     79                variable_descriptor=xNew<char>(strlen(label.c_str())+1);
    8080                memcpy(variable_descriptor,label.c_str(),(strlen(label.c_str())+1)*sizeof(char));
    8181
     
    8585
    8686        /*Initialize responses: */
    87         responses=(double*)xcalloc(numFns,sizeof(double));
     87        responses=xNewZeroInit<IssmDouble>(numFns);
    8888
    8989        /*run core solution: */
     
    9797
    9898        /*Free ressources:*/
    99         xfree((void**)&variables);
     99        xDelete<IssmDouble>(variables);
    100100        for(i=0;i<numACV;i++){
    101101                variable_descriptor=variable_descriptors[i];
    102                 xfree((void**)&variable_descriptor);
     102                xDelete<char>(variable_descriptor);
    103103        }
    104         xfree((void**)&variable_descriptors);
    105         xfree((void**)&responses);
     104        xDelete<char*>(variable_descriptors);
     105        xDelete<IssmDouble>(responses);
    106106
    107107        return 0;
  • issm/trunk/src/c/objects/DakotaPlugin.h

    r4042 r12706  
    99
    1010/*Headers:*/
    11 /*{{{1*/
     11/*{{{*/
    1212
    1313
  • issm/trunk/src/c/objects/DofIndexing.cpp

    r12330 r12706  
    1818
    1919/*DofIndexing constructors and destructor*/
    20 /*FUNCTION DofIndexing::DofIndexing(){{{1*/
     20/*FUNCTION DofIndexing::DofIndexing(){{{*/
    2121DofIndexing::DofIndexing(){
    2222
     
    3535}
    3636/*}}}*/
    37 /*FUNCTION DofIndexing::DofIndexing(int gsize){{{1*/
     37/*FUNCTION DofIndexing::DofIndexing(int gsize){{{*/
    3838DofIndexing::DofIndexing(int in_gsize){
    3939        this->Init(in_gsize,NULL);
    4040}
    4141/*}}}*/
    42 /*FUNCTION DofIndexing::DofIndexing(DofIndexing* in)  -> copy{{{1*/
     42/*FUNCTION DofIndexing::DofIndexing(DofIndexing* in)  -> copy{{{*/
    4343DofIndexing::DofIndexing(DofIndexing* in){ //copy constructor
    4444
     
    5151
    5252        if(this->gsize>0){
    53                 this->f_set=(bool*)xmalloc(this->gsize*sizeof(bool));
    54                 this->s_set=(bool*)xmalloc(this->gsize*sizeof(bool));
    55                 this->svalues=(double*)xmalloc(this->gsize*sizeof(int));
    56                 if(in->doftype)this->doftype=(int*)xmalloc(this->gsize*sizeof(int));
    57                 this->gdoflist=(int*)xmalloc(this->gsize*sizeof(int));
     53                this->f_set=xNew<bool>(this->gsize);
     54                this->s_set=xNew<bool>(this->gsize);
     55                this->svalues=xNew<IssmDouble>(this->gsize);
     56                if(in->doftype)this->doftype=xNew<int>(this->gsize);
     57                this->gdoflist=xNew<int>(this->gsize);
    5858        }
    5959        else{
     
    6464                this->gdoflist=NULL;
    6565        }
    66         if(this->fsize>0 && this->fsize!=UNDEF)this->fdoflist=(int*)xmalloc(this->fsize*sizeof(int)); else this->fdoflist=NULL;
    67         if(this->ssize>0 && this->ssize!=UNDEF)this->sdoflist=(int*)xmalloc(this->ssize*sizeof(int)); else this->sdoflist=NULL;
     66        if(this->fsize>0 && this->fsize!=UNDEF)this->fdoflist=xNew<int>(this->fsize); else this->fdoflist=NULL;
     67        if(this->ssize>0 && this->ssize!=UNDEF)this->sdoflist=xNew<int>(this->ssize); else this->sdoflist=NULL;
    6868
    6969        if(this->gsize>0){
    7070                memcpy(this->f_set,in->f_set,this->gsize*sizeof(bool));
    7171                memcpy(this->s_set,in->s_set,this->gsize*sizeof(bool));
    72                 memcpy(this->svalues,in->svalues,this->gsize*sizeof(double));
     72                xMemCpy<IssmDouble>(this->svalues,in->svalues,this->gsize);
    7373                if(this->doftype)memcpy(this->doftype,in->doftype,this->gsize*sizeof(int));
    7474                memcpy(this->gdoflist,in->gdoflist,this->gsize*sizeof(int));
     
    7979}
    8080/*}}}*/
    81 /*FUNCTION DofIndexing::~DofIndexing() {{{1*/
     81/*FUNCTION DofIndexing::~DofIndexing() {{{*/
    8282DofIndexing::~DofIndexing(){ //destructor
    8383
    84         xfree((void**)&f_set);
    85         xfree((void**)&s_set);
    86         xfree((void**)&svalues);
    87         xfree((void**)&doftype);
    88         xfree((void**)&gdoflist);
    89         xfree((void**)&fdoflist);
    90         xfree((void**)&sdoflist);
    91 
    92 }
    93 /*}}}*/
    94 /*FUNCTION DofIndexing::Init{{{1*/
     84        xDelete<bool>(f_set);
     85        xDelete<bool>(s_set);
     86        xDelete<IssmDouble>(svalues);
     87        xDelete<int>(doftype);
     88        xDelete<int>(gdoflist);
     89        xDelete<int>(fdoflist);
     90        xDelete<int>(sdoflist);
     91
     92}
     93/*}}}*/
     94/*FUNCTION DofIndexing::Init{{{*/
    9595void DofIndexing::Init(int in_gsize,int* in_doftype){
    9696
     
    102102        /*allocate: */
    103103        if(this->gsize>0){
    104                 this->f_set=(bool*)xmalloc(this->gsize*sizeof(bool));
    105                 this->s_set=(bool*)xmalloc(this->gsize*sizeof(bool));
    106                 this->svalues=(double*)xmalloc(this->gsize*sizeof(double));
    107                 if(in_doftype)this->doftype=(int*)xmalloc(this->gsize*sizeof(int));
    108                 this->gdoflist=(int*)xmalloc(this->gsize*sizeof(int));
     104                this->f_set=xNew<bool>(this->gsize);
     105                this->s_set=xNew<bool>(this->gsize);
     106                this->svalues=xNew<IssmDouble>(this->gsize);
     107                if(in_doftype)this->doftype=xNew<int>(this->gsize);
     108                this->gdoflist=xNew<int>(this->gsize);
    109109        }
    110110
     
    119119}
    120120/*}}}*/
    121 /*FUNCTION DofIndexing::InitSet{{{1*/
     121/*FUNCTION DofIndexing::InitSet{{{*/
    122122void DofIndexing::InitSet(int setenum){
    123123
     
    131131                for(i=0;i<this->gsize;i++) if(f_set[i])size++;
    132132                this->fsize=size;
    133                 xfree((void**)&this->fdoflist);
    134                 if(this->fsize)this->fdoflist=(int*)xmalloc(size*sizeof(int));
     133                xDelete<int>(this->fdoflist);
     134                if(this->fsize)this->fdoflist=xNew<int>(size);
    135135                else this->fdoflist=NULL;
    136136        }
     
    139139                for(i=0;i<this->gsize;i++) if(s_set[i])size++;
    140140                this->ssize=size;
    141                 xfree((void**)&this->sdoflist);
    142                 if(this->ssize)this->sdoflist=(int*)xmalloc(size*sizeof(int));
     141                xDelete<int>(this->sdoflist);
     142                if(this->ssize)this->sdoflist=xNew<int>(size);
    143143                else this->sdoflist=NULL;
    144144        }
    145         else _error_("%s%s%s"," set of enum type ",EnumToStringx(setenum)," not supported yet!");
     145        else _error2_("set of enum type " << EnumToStringx(setenum) << " not supported yet!");
    146146}
    147147/*}}}*/
    148148
    149149/*Some of the Object functionality: */
    150 /*FUNCTION DofIndexing::Echo{{{1*/
     150/*FUNCTION DofIndexing::Echo{{{*/
    151151void DofIndexing::Echo(void){
    152152
    153153        int i;
    154154
    155         printf("DofIndexing:\n");
    156         printf("   gsize: %i\n",gsize);
    157         printf("   clone: %i\n",clone);
    158 }
    159 /*}}}*/
    160 /*FUNCTION DofIndexing::DeepEcho{{{1*/
     155        _printLine_("DofIndexing:");
     156        _printLine_("   gsize: " << gsize);
     157        _printLine_("   clone: " << clone);
     158}
     159/*}}}*/
     160/*FUNCTION DofIndexing::DeepEcho{{{*/
    161161void DofIndexing::DeepEcho(void){
    162162
    163163        int i;
    164164
    165         printf("DofIndexing:\n");
    166         printf("   gsize: %i\n",gsize);
    167         printf("   fsize: %i\n",fsize);
    168         printf("   ssize: %i\n",ssize);
    169         printf("   clone: %i\n",clone);
     165        _printLine_("DofIndexing:");
     166        _printLine_("   gsize: " << gsize);
     167        _printLine_("   fsize: " << fsize);
     168        _printLine_("   ssize: " << ssize);
     169        _printLine_("   clone: " << clone);
    170170       
    171         printf("   set membership: f,s sets \n");
     171        _printLine_("   set membership: f,s sets ");
    172172        for(i=0;i<gsize;i++){
    173                 printf("      dof %i: %s %s\n",i,f_set[i]?"true":"false",s_set[i]?"true":"false");
    174         }
    175 
    176         printf("   svalues (%i): |",this->ssize);
     173                _printLine_("      dof " << i << ": " <<(f_set[i]?"true":"false")<< " " <<(s_set[i]?"true":"false"));
     174        }
     175
     176        _printString_("   svalues (" << this->ssize << "): |");
    177177        for(i=0;i<this->gsize;i++){
    178                 if(this->s_set[i])printf(" %g |",svalues[i]);
    179         }
    180         printf("\n");
     178                if(this->s_set[i])_printString_(" " << svalues[i] << " |");
     179        }
     180        _printLine_("");
    181181
    182182        if(doftype){
    183                 printf("   doftype: |");
     183                _printString_("   doftype: |");
    184184                for(i=0;i<gsize;i++){
    185                         printf(" %i |",doftype[i]);
     185                        _printString_(" " << doftype[i] << " |");
    186186                }
    187                 printf("\n");
    188         }
    189         else printf("   doftype: NULL\n");
    190 
    191         printf("   g_doflist (%i): |",this->gsize);
     187                _printLine_("");
     188        }
     189        else _printLine_("   doftype: NULL");
     190
     191        _printString_("   g_doflist (" << this->gsize << "): |");
    192192        for(i=0;i<this->gsize;i++){
    193                 printf(" %i |",gdoflist[i]);
    194         }
    195         printf("\n");
    196 
    197         printf("   f_doflist (%i): |",this->fsize);
     193                _printString_(" " << gdoflist[i] << " |");
     194        }
     195        _printLine_("");
     196
     197        _printString_("   f_doflist (" << this->fsize << "): |");
    198198        for(i=0;i<this->fsize;i++){
    199                 printf(" %i |",fdoflist[i]);
    200         }
    201         printf("\n");
    202 
    203         printf("   s_doflist (%i): |",this->ssize);
     199                _printString_(" " << fdoflist[i] << " |");
     200        }
     201        _printLine_("");
     202
     203        _printString_("   s_doflist (" << this->ssize << "): |");
    204204        for(i=0;i<this->ssize;i++){
    205                 printf(" %i |",sdoflist[i]);
    206         }
    207         printf("\n");
     205                _printString_(" " << sdoflist[i] << " |");
     206        }
     207        _printLine_("");
    208208}               
    209209/*}}}*/
  • issm/trunk/src/c/objects/DofIndexing.h

    r12330 r12706  
    3434
    3535
    36                 /*DofIndexing constructors, destructors {{{1*/
     36                /*DofIndexing constructors, destructors {{{*/
    3737                DofIndexing();
    3838                DofIndexing(int g_size);
     
    4242                ~DofIndexing();
    4343                /*}}}*/
    44                 /*Object like functionality: {{{1*/
     44                /*Object like functionality: {{{*/
    4545                void  Echo(void);
    4646                void  DeepEcho(void);
    4747                void  copy(DofIndexing* properties);
    4848                /*}}}*/
    49                 /*DofIndexing management: {{{1*/
     49                /*DofIndexing management: {{{*/
    5050                DofIndexing* Spawn(int* indices, int numindices);
    5151                /*}}}*/
  • issm/trunk/src/c/objects/ElementResults/BoolElementResult.cpp

    r12330 r12706  
    1919
    2020/*BoolElementResult constructors and destructor*/
    21 /*FUNCTION BoolElementResult::BoolElementResult(){{{1*/
     21/*FUNCTION BoolElementResult::BoolElementResult(){{{*/
    2222BoolElementResult::BoolElementResult(){
    2323        return;
    2424}
    2525/*}}}*/
    26 /*FUNCTION BoolElementResult::BoolElementResult(int in_enum_type,IssmDouble in_value,int in_step, double in_time){{{1*/
    27 BoolElementResult::BoolElementResult(int in_enum_type,bool in_value,int in_step, double in_time){
     26/*FUNCTION BoolElementResult::BoolElementResult(int in_enum_type,IssmDouble in_value,int in_step, IssmDouble in_time){{{*/
     27BoolElementResult::BoolElementResult(int in_enum_type,bool in_value,int in_step, IssmDouble in_time){
    2828
    2929        enum_type=in_enum_type;
     
    3333}
    3434/*}}}*/
    35 /*FUNCTION BoolElementResult::~BoolElementResult(){{{1*/
     35/*FUNCTION BoolElementResult::~BoolElementResult(){{{*/
    3636BoolElementResult::~BoolElementResult(){
    3737        return;
     
    4040
    4141/*Object virtual functions definitions:*/
    42 /*FUNCTION BoolElementResult::Echo {{{1*/
     42/*FUNCTION BoolElementResult::Echo {{{*/
    4343void BoolElementResult::Echo(void){
    4444        this->DeepEcho();
    4545}
    4646/*}}}*/
    47 /*FUNCTION BoolElementResult::DeepEcho{{{1*/
     47/*FUNCTION BoolElementResult::DeepEcho{{{*/
    4848void BoolElementResult::DeepEcho(void){
    4949
    50         printf("BoolElementResult:\n");
    51         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    52         printf("   value: %s\n",this->value?"true":"false");
    53         printf("   step: %i\n",this->step);
    54         printf("   time: %g\n",this->time);
     50        _printLine_("BoolElementResult:");
     51        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     52        _printLine_("   value: "<<(this->value?"true":"false"));
     53        _printLine_("   step: " << this->step);
     54        _printLine_("   time: " << this->time);
    5555}
    5656/*}}}*/
    57 /*FUNCTION BoolElementResult::Id{{{1*/
     57/*FUNCTION BoolElementResult::Id{{{*/
    5858int    BoolElementResult::Id(void){ return -1; }
    5959/*}}}*/
    60 /*FUNCTION BoolElementResult::MyRank{{{1*/
     60/*FUNCTION BoolElementResult::MyRank{{{*/
    6161int    BoolElementResult::MyRank(void){
    6262        extern int my_rank;
     
    6464}
    6565/*}}}*/
    66 /*FUNCTION BoolElementResult::ObjectEnum{{{1*/
     66/*FUNCTION BoolElementResult::ObjectEnum{{{*/
    6767int BoolElementResult::ObjectEnum(void){
    6868
     
    7171}
    7272/*}}}*/
    73 /*FUNCTION BoolElementResult::copy{{{1*/
     73/*FUNCTION BoolElementResult::copy{{{*/
    7474Object* BoolElementResult::copy() {
    7575
     
    8080
    8181/*ElementResult management*/
    82 /*FUNCTION BoolElementResult::InstanceEnum{{{1*/
     82/*FUNCTION BoolElementResult::InstanceEnum{{{*/
    8383int BoolElementResult::InstanceEnum(void){
    8484
     
    8787}
    8888/*}}}*/
    89 /*FUNCTION BoolElementResult::SpawnTriaElementResult{{{1*/
     89/*FUNCTION BoolElementResult::SpawnTriaElementResult{{{*/
    9090ElementResult* BoolElementResult::SpawnTriaElementResult(int* indices){
    9191
     
    104104}
    105105/*}}}*/
    106 /*FUNCTION BoolElementResult::ProcessUnits{{{1*/
     106/*FUNCTION BoolElementResult::ProcessUnits{{{*/
    107107void BoolElementResult::ProcessUnits(Parameters* parameters){
    108        
    109         this->value=UnitConversion(this->value,IuToExtEnum,this->enum_type);
    110 
     108// no op
    111109}
    112110/*}}}*/
    113 /*FUNCTION BoolElementResult::NumberOfNodalValues{{{1*/
     111/*FUNCTION BoolElementResult::NumberOfNodalValues{{{*/
    114112int BoolElementResult::NumberOfNodalValues(void){
    115113        return 1;
    116114}
    117115/*}}}*/
    118 /*FUNCTION BoolElementResult::PatchFill{{{1*/
     116/*FUNCTION BoolElementResult::PatchFill{{{*/
    119117void BoolElementResult::PatchFill(int row, Patch* patch){
    120118       
     
    122120          * of the patch object: enum_type step time element_id interpolation vertices_ids nodal_values
    123121          * Here, we will supply the enum_type, step, time, interpolation and nodal_values: */
    124         double doublevalue=this->value?1:0;
    125         patch->fillresultinfo(row,this->enum_type,this->step,this->time,P0Enum,&doublevalue,1);
     122        IssmDouble IssmDoublevalue=this->value?1:0;
     123        patch->fillresultinfo(row,this->enum_type,this->step,this->time,P0Enum,&IssmDoublevalue,1);
    126124
    127125}
    128126/*}}}*/
    129 /*FUNCTION BoolElementResult::GetVectorFromResults{{{1*/
     127/*FUNCTION BoolElementResult::GetVectorFromResults{{{*/
    130128void BoolElementResult::GetVectorFromResults(Vector* vector,int* doflist,int* connectivitylist,int numdofs){
    131129
    132         _error_("cannot return vector on vertices");
     130        _error2_("cannot return vector on vertices");
    133131} /*}}}*/
    134 /*FUNCTION BoolElementResult::GetElementVectorFromResults{{{1*/
     132/*FUNCTION BoolElementResult::GetElementVectorFromResults{{{*/
    135133void BoolElementResult::GetElementVectorFromResults(Vector* vector,int dof){
    136134
  • issm/trunk/src/c/objects/ElementResults/BoolElementResult.h

    r12330 r12706  
    99
    1010/*Headers:*/
    11 /*{{{1*/
     11/*{{{*/
    1212#include "../Inputs/Input.h"
    1313#include "../../include/include.h"
     
    2121                bool   value;
    2222                int    step;
    23                 double time;
     23                IssmDouble time;
    2424
    2525        public:
    2626
    27                 /*BoolElementResult constructors, destructors: {{{1*/
     27                /*BoolElementResult constructors, destructors: {{{*/
    2828                BoolElementResult();
    29                 BoolElementResult(int enum_type,bool value,int step,double time);
     29                BoolElementResult(int enum_type,bool value,int step,IssmDouble time);
    3030                ~BoolElementResult();
    3131                /*}}}*/
    32                 /*Object virtual functions definitions:{{{1 */
     32                /*Object virtual functions definitions:{{{ */
    3333                void  Echo();
    3434                void  DeepEcho();
     
    3838                Object* copy();
    3939                /*}}}*/
    40                 /*ElementResult virtual functions definitions: {{{1*/
     40                /*ElementResult virtual functions definitions: {{{*/
    4141                ElementResult* SpawnTriaElementResult(int* indices);
    42                 double  GetTime(void){return time;};
     42                IssmDouble  GetTime(void){return time;};
    4343                int     GetStep(void){return step;};
    4444                void    ProcessUnits(Parameters* parameters);
     
    4646                void    PatchFill(int row, Patch* patch);
    4747                /*}}}*/
    48                 /*BoolElementResult management: {{{1*/
     48                /*BoolElementResult management: {{{*/
    4949                int   InstanceEnum();
    5050                void GetVectorFromResults(Vector* vector,int* doflist,int* connectivitylist,int numdofs);
  • issm/trunk/src/c/objects/ElementResults/DoubleElementResult.cpp

    r12628 r12706  
    1919
    2020/*DoubleElementResult constructors and destructor*/
    21 /*FUNCTION DoubleElementResult::DoubleElementResult(){{{1*/
     21/*FUNCTION DoubleElementResult::DoubleElementResult(){{{*/
    2222DoubleElementResult::DoubleElementResult(){
    2323        return;
    2424}
    2525/*}}}*/
    26 /*FUNCTION DoubleElementResult::DoubleElementResult(int in_enum_type,IssmDouble in_value,int in_step, double in_time){{{1*/
    27 DoubleElementResult::DoubleElementResult(int in_enum_type,IssmDouble in_value,int in_step, double in_time){
     26/*FUNCTION DoubleElementResult::DoubleElementResult(int in_enum_type,IssmDouble in_value,int in_step, IssmDouble in_time){{{*/
     27DoubleElementResult::DoubleElementResult(int in_enum_type,IssmDouble in_value,int in_step, IssmDouble in_time){
    2828
    2929        enum_type=in_enum_type;
     
    3333}
    3434/*}}}*/
    35 /*FUNCTION DoubleElementResult::~DoubleElementResult(){{{1*/
     35/*FUNCTION DoubleElementResult::~DoubleElementResult(){{{*/
    3636DoubleElementResult::~DoubleElementResult(){
    3737        return;
     
    4040
    4141/*Object virtual functions definitions:*/
    42 /*FUNCTION DoubleElementResult::Echo {{{1*/
     42/*FUNCTION DoubleElementResult::Echo {{{*/
    4343void DoubleElementResult::Echo(void){
    4444        this->DeepEcho();
    4545}
    4646/*}}}*/
    47 /*FUNCTION DoubleElementResult::DeepEcho{{{1*/
     47/*FUNCTION DoubleElementResult::DeepEcho{{{*/
    4848void DoubleElementResult::DeepEcho(void){
    4949
    50         printf("DoubleElementResult:\n");
    51         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    52         printf("   value: %g\n",this->value);
    53         printf("   step: %i\n",this->step);
    54         printf("   time: %g\n",this->time);
     50        _printLine_("DoubleElementResult:");
     51        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     52        _printLine_("   value: " << this->value);
     53        _printLine_("   step: " << this->step);
     54        _printLine_("   time: " << this->time);
    5555}
    5656/*}}}*/
    57 /*FUNCTION DoubleElementResult::Id{{{1*/
     57/*FUNCTION DoubleElementResult::Id{{{*/
    5858int    DoubleElementResult::Id(void){ return -1; }
    5959/*}}}*/
    60 /*FUNCTION DoubleElementResult::MyRank{{{1*/
     60/*FUNCTION DoubleElementResult::MyRank{{{*/
    6161int    DoubleElementResult::MyRank(void){
    6262        extern int my_rank;
     
    6464}
    6565/*}}}*/
    66 /*FUNCTION DoubleElementResult::ObjectEnum{{{1*/
     66/*FUNCTION DoubleElementResult::ObjectEnum{{{*/
    6767int DoubleElementResult::ObjectEnum(void){
    6868
     
    7171}
    7272/*}}}*/
    73 /*FUNCTION DoubleElementResult::copy{{{1*/
     73/*FUNCTION DoubleElementResult::copy{{{*/
    7474Object* DoubleElementResult::copy() {
    7575
     
    8080
    8181/*ElementResult management*/
    82 /*FUNCTION DoubleElementResult::InstanceEnum{{{1*/
     82/*FUNCTION DoubleElementResult::InstanceEnum{{{*/
    8383int DoubleElementResult::InstanceEnum(void){
    8484
     
    8787}
    8888/*}}}*/
    89 /*FUNCTION DoubleElementResult::SpawnTriaElementResult{{{1*/
     89/*FUNCTION DoubleElementResult::SpawnTriaElementResult{{{*/
    9090ElementResult* DoubleElementResult::SpawnTriaElementResult(int* indices){
    9191
     
    104104}
    105105/*}}}*/
    106 /*FUNCTION DoubleElementResult::ProcessUnits{{{1*/
     106/*FUNCTION DoubleElementResult::ProcessUnits{{{*/
    107107void DoubleElementResult::ProcessUnits(Parameters* parameters){
    108108       
     
    111111}
    112112/*}}}*/
    113 /*FUNCTION DoubleElementResult::NumberOfNodalValues{{{1*/
     113/*FUNCTION DoubleElementResult::NumberOfNodalValues{{{*/
    114114int DoubleElementResult::NumberOfNodalValues(void){
    115115        return 1;
    116116}
    117117/*}}}*/
    118 /*FUNCTION DoubleElementResult::PatchFill{{{1*/
     118/*FUNCTION DoubleElementResult::PatchFill{{{*/
    119119void DoubleElementResult::PatchFill(int row, Patch* patch){
    120120       
  • issm/trunk/src/c/objects/ElementResults/DoubleElementResult.h

    r12628 r12706  
    11/*! \file DoubleElementResult.h
    2  *  \brief: header file for double result object
    3  *  A double result object is just derived from a DoubleInput object, with additional time and step information.
     2 *  \brief: header file for IssmDouble result object
     3 *  A IssmDouble result object is just derived from a DoubleInput object, with additional time and step information.
    44 */
    55
     
    99
    1010/*Headers:*/
    11 /*{{{1*/
     11/*{{{*/
    1212#include "../Inputs/Input.h"
    1313#include "../../include/include.h"
     
    1919        private:
    2020                int    enum_type;
    21                 double value;
     21                IssmDouble value;
    2222                int    step;
    23                 double time;
     23                IssmDouble time;
    2424
    2525        public:
    2626
    27                 /*DoubleElementResult constructors, destructors: {{{1*/
     27                /*DoubleElementResult constructors, destructors: {{{*/
    2828                DoubleElementResult();
    29                 DoubleElementResult(int enum_type,double value,int step,double time);
     29                DoubleElementResult(int enum_type,IssmDouble value,int step,IssmDouble time);
    3030                ~DoubleElementResult();
    3131                /*}}}*/
    32                 /*Object virtual functions definitions:{{{1 */
     32                /*Object virtual functions definitions:{{{ */
    3333                void  Echo();
    3434                void  DeepEcho();
     
    3838                Object* copy();
    3939                /*}}}*/
    40                 /*ElementResult virtual functions definitions: {{{1*/
     40                /*ElementResult virtual functions definitions: {{{*/
    4141                ElementResult* SpawnTriaElementResult(int* indices);
    42                 double  GetTime(void){return time;};
     42                IssmDouble  GetTime(void){return time;};
    4343                int     GetStep(void){return step;};
    4444                void    ProcessUnits(Parameters* parameters);
     
    4646                void    PatchFill(int row, Patch* patch);
    4747                /*}}}*/
    48                 /*DoubleElementResult management: {{{1*/
     48                /*DoubleElementResult management: {{{*/
    4949                int   InstanceEnum();
    5050                void GetVectorFromResults(Vector* vector,int* doflist,int* connectivitylist,int numdofs);
  • issm/trunk/src/c/objects/ElementResults/ElementResult.h

    r11995 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111#include "../Object.h"
    1212/*}}}*/
     
    1919               
    2020                virtual         ElementResult* SpawnTriaElementResult(int* indices)=0;
    21                 virtual double  GetTime(void)=0;
     21                virtual IssmDouble  GetTime(void)=0;
    2222                virtual int     GetStep(void)=0;
    2323                virtual void    ProcessUnits(Parameters* parameters)=0;
  • issm/trunk/src/c/objects/ElementResults/PentaP1ElementResult.cpp

    r12330 r12706  
    1919
    2020/*PentaP1ElementResult constructors and destructor*/
    21 /*FUNCTION PentaP1ElementResult::PentaP1ElementResult(){{{1*/
     21/*FUNCTION PentaP1ElementResult::PentaP1ElementResult(){{{*/
    2222PentaP1ElementResult::PentaP1ElementResult(){
    2323        return;
    2424}
    2525/*}}}*/
    26 /*FUNCTION PentaP1ElementResult::PentaP1ElementResult(int in_enum_type,double* in_values,int in_step, double in_time){{{1*/
    27 PentaP1ElementResult::PentaP1ElementResult(int in_enum_type,double* in_values,int in_step, double in_time){
     26/*FUNCTION PentaP1ElementResult::PentaP1ElementResult(int in_enum_type,IssmDouble* in_values,int in_step, IssmDouble in_time){{{*/
     27PentaP1ElementResult::PentaP1ElementResult(int in_enum_type,IssmDouble* in_values,int in_step, IssmDouble in_time){
    2828
    2929        int i;
     
    3535}
    3636/*}}}*/
    37 /*FUNCTION PentaP1ElementResult::~PentaP1ElementResult(){{{1*/
     37/*FUNCTION PentaP1ElementResult::~PentaP1ElementResult(){{{*/
    3838PentaP1ElementResult::~PentaP1ElementResult(){
    3939        return;
     
    4242
    4343/*Object virtual functions definitions:*/
    44 /*FUNCTION PentaP1ElementResult::Echo {{{1*/
     44/*FUNCTION PentaP1ElementResult::Echo {{{*/
    4545void PentaP1ElementResult::Echo(void){
    4646        this->DeepEcho();
    4747}
    4848/*}}}*/
    49 /*FUNCTION PentaP1ElementResult::DeepEcho{{{1*/
     49/*FUNCTION PentaP1ElementResult::DeepEcho{{{*/
    5050void PentaP1ElementResult::DeepEcho(void){
    5151
    52         printf("PentaP1ElementResult:\n");
    53         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    54         printf("   values: [%g %g %g %g %g %g]\n",this->values[0],this->values[1],this->values[2],this->values[3],this->values[4],this->values[5]);
    55         printf("   step: %i\n",this->step);
    56         printf("   time: %g\n",this->time);
     52        _printLine_("PentaP1ElementResult:");
     53        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     54        _printLine_("   values: [" << this->values[0] << " " << this->values[1] << " " << this->values[2] << " " << this->values[3] << " " << this->values[4] << " " << this->values[5] << "]");
     55        _printLine_("   step: " << this->step);
     56        _printLine_("   time: " << this->time);
    5757
    5858}
    5959/*}}}*/
    60 /*FUNCTION PentaP1ElementResult::Id{{{1*/
     60/*FUNCTION PentaP1ElementResult::Id{{{*/
    6161int    PentaP1ElementResult::Id(void){ return -1; }
    6262/*}}}*/
    63 /*FUNCTION PentaP1ElementResult::MyRank{{{1*/
     63/*FUNCTION PentaP1ElementResult::MyRank{{{*/
    6464int    PentaP1ElementResult::MyRank(void){
    6565        extern int my_rank;
     
    6767}
    6868/*}}}*/
    69 /*FUNCTION PentaP1ElementResult::ObjectEnum{{{1*/
     69/*FUNCTION PentaP1ElementResult::ObjectEnum{{{*/
    7070int PentaP1ElementResult::ObjectEnum(void){
    7171
     
    7474}
    7575/*}}}*/
    76 /*FUNCTION PentaP1ElementResult::copy{{{1*/
     76/*FUNCTION PentaP1ElementResult::copy{{{*/
    7777Object* PentaP1ElementResult::copy() {
    7878       
     
    8383
    8484/*ElementResult management*/
    85 /*FUNCTION PentaP1ElementResult::InstanceEnum{{{1*/
     85/*FUNCTION PentaP1ElementResult::InstanceEnum{{{*/
    8686int PentaP1ElementResult::InstanceEnum(void){
    8787
     
    9090}
    9191/*}}}*/
    92 /*FUNCTION PentaP1ElementResult::SpawnTriaElementResult{{{1*/
     92/*FUNCTION PentaP1ElementResult::SpawnTriaElementResult{{{*/
    9393ElementResult* PentaP1ElementResult::SpawnTriaElementResult(int* indices){
    9494
    9595        /*output*/
    9696        TriaP1ElementResult* outresult=NULL;
    97         double newvalues[3];
     97        IssmDouble newvalues[3];
    9898
    9999        /*Loop over the new indices*/
     
    115115}
    116116/*}}}*/
    117 /*FUNCTION PentaP1ElementResult::ProcessUnits{{{1*/
     117/*FUNCTION PentaP1ElementResult::ProcessUnits{{{*/
    118118void PentaP1ElementResult::ProcessUnits(Parameters* parameters){
    119119       
     
    122122}
    123123/*}}}*/
    124 /*FUNCTION PentaP1ElementResult::NumberOfNodalValues{{{1*/
     124/*FUNCTION PentaP1ElementResult::NumberOfNodalValues{{{*/
    125125int PentaP1ElementResult::NumberOfNodalValues(void){
    126126        return 6;
    127127}
    128128/*}}}*/
    129 /*FUNCTION PentaP1ElementResult::PatchFill{{{1*/
     129/*FUNCTION PentaP1ElementResult::PatchFill{{{*/
    130130void PentaP1ElementResult::PatchFill(int row, Patch* patch){
    131131       
     
    137137}
    138138/*}}}*/
    139 /*FUNCTION PentaP1ElementResult::GetVectorFromResults{{{1*/
     139/*FUNCTION PentaP1ElementResult::GetVectorFromResults{{{*/
    140140void PentaP1ElementResult::GetVectorFromResults(Vector* vector,int* doflist,int* connectivitylist,int numdofs){
    141141
    142         double data[6];
     142        IssmDouble data[6];
    143143
    144         if(numdofs!=6)_error_("Result %s is a PentaP1ElementResult and cannot write vector of %i dofs",numdofs);
    145         for(int i=0;i<6;i++) data[i]=this->values[i]/(double)connectivitylist[i];
     144        if(numdofs!=6)_error2_("Result " << EnumToStringx(this->enum_type) << " is a PentaP1ElementResult and cannot write vector of " << numdofs << " dofs");
     145        for(int i=0;i<6;i++) data[i]=this->values[i]/(IssmDouble)connectivitylist[i];
    146146        vector->SetValues(numdofs,doflist,&data[0],ADD_VAL);
    147147
    148148} /*}}}*/
    149 /*FUNCTION PentaP1ElementResult::GetElementVectorFromResults{{{1*/
     149/*FUNCTION PentaP1ElementResult::GetElementVectorFromResults{{{*/
    150150void PentaP1ElementResult::GetElementVectorFromResults(Vector* vector,int dof){
    151151
    152         _error_("Result %s is a PentaP1ElementResult and should not write vector of size numberofelemenrs",EnumToStringx(enum_type));
     152        _error2_("Result " << EnumToStringx(enum_type) << " is a PentaP1ElementResult and should not write vector of size numberofelemenrs");
    153153} /*}}}*/
  • issm/trunk/src/c/objects/ElementResults/PentaP1ElementResult.h

    r12330 r12706  
    99
    1010/*Headers:*/
    11 /*{{{1*/
     11/*{{{*/
    1212#include "../Inputs/Input.h"
    1313#include "../../include/include.h"
     
    1818        private:
    1919                int    enum_type;
    20                 double values[6];
     20                IssmDouble values[6];
    2121                int    step;
    22                 double time;
     22                IssmDouble time;
    2323
    2424        public:
    2525
    26                 /*PentaP1ElementResult constructors, destructors: {{{1*/
     26                /*PentaP1ElementResult constructors, destructors: {{{*/
    2727                PentaP1ElementResult();
    28                 PentaP1ElementResult(int enum_type,double* values,int step, double time);
     28                PentaP1ElementResult(int enum_type,IssmDouble* values,int step, IssmDouble time);
    2929                ~PentaP1ElementResult();
    3030                /*}}}*/
    31                 /*Object virtual functions definitions:{{{1 */
     31                /*Object virtual functions definitions:{{{ */
    3232                void  Echo();
    3333                void  DeepEcho();
     
    3737                Object* copy();
    3838                /*}}}*/
    39                 /*ElementResult virtual functions definitions: {{{1*/
     39                /*ElementResult virtual functions definitions: {{{*/
    4040                ElementResult* SpawnTriaElementResult(int* indices);
    41                 double  GetTime(void){return time;};
     41                IssmDouble  GetTime(void){return time;};
    4242                int     GetStep(void){return step;};
    4343                void    ProcessUnits(Parameters* parameters);
     
    4545                void    PatchFill(int row, Patch* patch);
    4646                /*}}}*/
    47                 /*PentaP1ElementResult management: {{{1*/
     47                /*PentaP1ElementResult management: {{{*/
    4848                int   InstanceEnum();
    4949                void GetVectorFromResults(Vector* vector,int* doflist,int* connectivitylist,int numdofs);
  • issm/trunk/src/c/objects/ElementResults/TriaP1ElementResult.cpp

    r12330 r12706  
    1919
    2020/*TriaP1ElementResult constructors and destructor*/
    21 /*FUNCTION TriaP1ElementResult::TriaP1ElementResult(){{{1*/
     21/*FUNCTION TriaP1ElementResult::TriaP1ElementResult(){{{*/
    2222TriaP1ElementResult::TriaP1ElementResult(){
    2323        return;
    2424}
    2525/*}}}*/
    26 /*FUNCTION TriaP1ElementResult::TriaP1ElementResult(int in_enum_type,double* in_values,int in_step, double in_time){{{1*/
    27 TriaP1ElementResult::TriaP1ElementResult(int in_enum_type,double* in_values,int in_step, double in_time){
     26/*FUNCTION TriaP1ElementResult::TriaP1ElementResult(int in_enum_type,IssmDouble* in_values,int in_step, IssmDouble in_time){{{*/
     27TriaP1ElementResult::TriaP1ElementResult(int in_enum_type,IssmDouble* in_values,int in_step, IssmDouble in_time){
    2828
    2929        enum_type=in_enum_type;
     
    3535}
    3636/*}}}*/
    37 /*FUNCTION TriaP1ElementResult::~TriaP1ElementResult(){{{1*/
     37/*FUNCTION TriaP1ElementResult::~TriaP1ElementResult(){{{*/
    3838TriaP1ElementResult::~TriaP1ElementResult(){
    3939        return;
     
    4242
    4343/*Object virtual functions definitions:*/
    44 /*FUNCTION TriaP1ElementResult::Echo {{{1*/
     44/*FUNCTION TriaP1ElementResult::Echo {{{*/
    4545void TriaP1ElementResult::Echo(void){
    4646        this->DeepEcho();
    4747}
    4848/*}}}*/
    49 /*FUNCTION TriaP1ElementResult::DeepEcho{{{1*/
     49/*FUNCTION TriaP1ElementResult::DeepEcho{{{*/
    5050void TriaP1ElementResult::DeepEcho(void){
    5151               
    52         printf("TriaP1ElementResult:\n");
    53         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    54         printf("   values: [%g %g %g]\n",this->values[0],this->values[1],this->values[2]);
    55         printf("   step: %i\n",this->step);
    56         printf("   time: %g\n",this->time);
     52        _printLine_("TriaP1ElementResult:");
     53        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     54        _printLine_("   values: [" << this->values[0] << " " << this->values[1] << " " << this->values[2] << "]");
     55        _printLine_("   step: " << this->step);
     56        _printLine_("   time: " << this->time);
    5757}
    5858/*}}}*/
    59 /*FUNCTION TriaP1ElementResult::Id{{{1*/
     59/*FUNCTION TriaP1ElementResult::Id{{{*/
    6060int    TriaP1ElementResult::Id(void){ return -1; }
    6161/*}}}*/
    62 /*FUNCTION TriaP1ElementResult::MyRank{{{1*/
     62/*FUNCTION TriaP1ElementResult::MyRank{{{*/
    6363int    TriaP1ElementResult::MyRank(void){
    6464        extern int my_rank;
     
    6666}
    6767/*}}}*/
    68 /*FUNCTION TriaP1ElementResult::ObjectEnum{{{1*/
     68/*FUNCTION TriaP1ElementResult::ObjectEnum{{{*/
    6969int TriaP1ElementResult::ObjectEnum(void){
    7070
     
    7373}
    7474/*}}}*/
    75 /*FUNCTION TriaP1ElementResult::copy{{{1*/
     75/*FUNCTION TriaP1ElementResult::copy{{{*/
    7676Object* TriaP1ElementResult::copy() {
    7777       
     
    8282
    8383/*ElementResult management*/
    84 /*FUNCTION TriaP1ElementResult::InstanceEnum{{{1*/
     84/*FUNCTION TriaP1ElementResult::InstanceEnum{{{*/
    8585int TriaP1ElementResult::InstanceEnum(void){
    8686
     
    8989}
    9090/*}}}*/
    91 /*FUNCTION TriaP1ElementResult::SpawnTriaElementResult{{{1*/
     91/*FUNCTION TriaP1ElementResult::SpawnTriaElementResult{{{*/
    9292ElementResult* TriaP1ElementResult::SpawnTriaElementResult(int* indices){
    9393
     
    103103}
    104104/*}}}*/
    105 /*FUNCTION TriaP1ElementResult::ProcessUnits{{{1*/
     105/*FUNCTION TriaP1ElementResult::ProcessUnits{{{*/
    106106void TriaP1ElementResult::ProcessUnits(Parameters* parameters){
    107107       
     
    110110}
    111111/*}}}*/
    112 /*FUNCTION TriaP1ElementResult::NumberOfNodalValues{{{1*/
     112/*FUNCTION TriaP1ElementResult::NumberOfNodalValues{{{*/
    113113int TriaP1ElementResult::NumberOfNodalValues(void){
    114114        return 3;
    115115}
    116116/*}}}*/
    117 /*FUNCTION TriaP1ElementResult::PatchFill{{{1*/
     117/*FUNCTION TriaP1ElementResult::PatchFill{{{*/
    118118void TriaP1ElementResult::PatchFill(int row, Patch* patch){
    119119       
     
    125125}
    126126/*}}}*/
    127 /*FUNCTION TriaP1ElementResult::GetVectorFromResults{{{1*/
     127/*FUNCTION TriaP1ElementResult::GetVectorFromResults{{{*/
    128128void TriaP1ElementResult::GetVectorFromResults(Vector* vector,int* doflist,int* connectivitylist,int numdofs){
    129129
    130         double data[3];
     130        IssmDouble data[3];
    131131
    132         if(numdofs!=3)_error_("Result %s is a TriaP1ElementResult and cannot write vector of %i dofs",numdofs);
    133         for(int i=0;i<3;i++) data[i]=this->values[i]/(double)connectivitylist[i];
     132        if(numdofs!=3)_error2_("Result " << EnumToStringx(this->enum_type) << " is a TriaP1ElementResult and cannot write vector of " << numdofs << " dofs");
     133        for(int i=0;i<3;i++) data[i]=this->values[i]/(IssmDouble)connectivitylist[i];
    134134        vector->SetValues(numdofs,doflist,&data[0],ADD_VAL);
    135135
    136136} /*}}}*/
    137 /*FUNCTION TriaP1ElementResult::GetElementVectorFromResults{{{1*/
     137/*FUNCTION TriaP1ElementResult::GetElementVectorFromResults{{{*/
    138138void TriaP1ElementResult::GetElementVectorFromResults(Vector* vector,int dof){
    139         _error_("Result %s is a TriaP1ElementResult and should not write vector of size numberofelemenrs",EnumToStringx(enum_type));
     139        _error2_("Result " << EnumToStringx(enum_type) << " is a TriaP1ElementResult and should not write vector of size numberofelemenrs");
    140140} /*}}}*/
  • issm/trunk/src/c/objects/ElementResults/TriaP1ElementResult.h

    r12330 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111#include "../Inputs/Input.h"
    1212#include "../../include/include.h"
     
    1717        private:
    1818                int    enum_type;
    19                 double values[3];
     19                IssmDouble values[3];
    2020                int    step;
    21                 double time;
     21                IssmDouble time;
    2222
    2323        public:
    2424
    25                 /*TriaP1ElementResult constructors, destructors: {{{1*/
     25                /*TriaP1ElementResult constructors, destructors: {{{*/
    2626                TriaP1ElementResult();
    27                 TriaP1ElementResult(int enum_type,double* values,int step,double time);
     27                TriaP1ElementResult(int enum_type,IssmDouble* values,int step,IssmDouble time);
    2828                ~TriaP1ElementResult();
    2929                /*}}}*/
    30                 /*Object virtual functions definitions:{{{1 */
     30                /*Object virtual functions definitions:{{{ */
    3131                void  Echo();
    3232                void  DeepEcho();
     
    3636                Object* copy();
    3737                /*}}}*/
    38                 /*ElementResult virtual functions definitions: {{{1*/
     38                /*ElementResult virtual functions definitions: {{{*/
    3939                ElementResult* SpawnTriaElementResult(int* indices);
    40                 double  GetTime(void){return time;};
     40                IssmDouble  GetTime(void){return time;};
    4141                int     GetStep(void){return step;};
    4242                void    ProcessUnits(Parameters* parameters);
     
    4444                void    PatchFill(int row, Patch* patch);
    4545                /*}}}*/
    46                 /*TriaP1ElementResult management: {{{1*/
     46                /*TriaP1ElementResult management: {{{*/
    4747                int   InstanceEnum();
    4848                void GetVectorFromResults(Vector* vector,int* doflist,int* connectivitylist,int numdofs);
  • issm/trunk/src/c/objects/Elements/Element.h

    r12630 r12706  
    1010
    1111/*Headers:*/
    12 /*{{{1*/
     12/*{{{*/
    1313#include "../Object.h"
    1414
     
    3838                virtual bool   IsFloating()=0;
    3939                virtual bool   IsNodeOnShelf()=0;
    40                 virtual bool   IsNodeOnShelfFromFlags(double* flags)=0;
     40                virtual bool   IsNodeOnShelfFromFlags(IssmDouble* flags)=0;
    4141                virtual bool   IsOnBed()=0;
    42                 virtual void   GetInputListOnVertices(double* pvalue,int enumtype)=0;
    43                 virtual void   GetInputListOnVertices(double* pvalue,int enumtype,double defaultvalue)=0;
    44                 virtual void   GetInputValue(double* pvalue,Node* node,int enumtype)=0;
     42                virtual void   GetInputListOnVertices(IssmDouble* pvalue,int enumtype)=0;
     43                virtual void   GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue)=0;
     44                virtual void   GetInputValue(IssmDouble* pvalue,Node* node,int enumtype)=0;
    4545               
    46                 virtual double SurfaceArea(void)=0;
     46                virtual IssmDouble SurfaceArea(void)=0;
    4747                virtual void   InputDepthAverageAtBase(int enum_type,int average_enum_type,int object_enum)=0;
    4848                virtual void   ComputeBasalStress(Vector* sigma_b)=0;
     
    5050                virtual void   PatchSize(int* pnumrows, int* pnumvertices,int* pnumnodes)=0;
    5151                virtual void   PatchFill(int* pcount, Patch* patch)=0;
    52                 virtual void   ListResultsInfo(int** results_enums,int** results_size,double** results_times,int** results_steps,int* num_results)=0;
     52                virtual void   ListResultsInfo(int** results_enums,int** results_size,IssmDouble** results_times,int** results_steps,int* num_results)=0;
    5353                virtual void   DeleteResults(void)=0;
    5454                virtual void   Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type)=0;
    55                 virtual void   InputToResult(int enum_type,int step,double time)=0;
     55                virtual void   InputToResult(int enum_type,int step,IssmDouble time)=0;
    5656                virtual void   InputDuplicate(int original_enum,int new_enum)=0;
    57                 virtual void   InputCreate(double scalar,int name,int code)=0;
    58                 virtual void   InputCreate(double* vector, int index,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code)=0;
     57                virtual void   InputCreate(IssmDouble scalar,int name,int code)=0;
     58                virtual void   InputCreate(IssmDouble* vector, int index,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code)=0;
    5959                virtual void   ProcessResultsUnits(void)=0;
    60                 virtual void   RequestedOutput(int output_enum,int step,double time)=0;
     60                virtual void   RequestedOutput(int output_enum,int step,IssmDouble time)=0;
    6161               
    62                 virtual int    NodalValue(double* pvalue, int index, int natureofdataenum,bool process_units)=0;
    63                 virtual void   InputScale(int enum_type,double scale_factor)=0;
     62                virtual int    NodalValue(IssmDouble* pvalue, int index, int natureofdataenum,bool process_units)=0;
     63                virtual void   InputScale(int enum_type,IssmDouble scale_factor)=0;
    6464                virtual void   GetVectorFromInputs(Vector* vector, int name_enum)=0;
    6565                virtual void   GetVectorFromResults(Vector* vector,int id,int enum_in,int interp)=0;
    66                 virtual void   InputArtificialNoise(int enum_type,double min,double max)=0;
    67                 virtual bool   InputConvergence(double* eps, int* enums,int num_enums,int* criterionenums,double* criterionvalues,int num_criterionenums)=0;
    68                 virtual void   AverageOntoPartition(Vector* partition_contributions,Vector* partition_areas,double* vertex_response,double* qmu_part)=0;
     66                virtual void   InputArtificialNoise(int enum_type,IssmDouble min,IssmDouble max)=0;
     67                virtual bool   InputConvergence(IssmDouble* eps, int* enums,int num_enums,int* criterionenums,IssmDouble* criterionvalues,int num_criterionenums)=0;
     68                virtual void   AverageOntoPartition(Vector* partition_contributions,Vector* partition_areas,IssmDouble* vertex_response,IssmDouble* qmu_part)=0;
    6969                virtual int*   GetHorizontalNeighboorSids(void)=0;
    70                 virtual double TimeAdapt()=0;
    71                 virtual void   MigrateGroundingLine(double* old_floating_ice,double* sheet_ungrounding)=0;
     70                virtual IssmDouble TimeAdapt()=0;
     71                virtual void   MigrateGroundingLine(IssmDouble* old_floating_ice,IssmDouble* sheet_ungrounding)=0;
    7272                virtual void   PotentialSheetUngrounding(Vector* potential_sheet_ungrounding)=0;
    73                 virtual void   PositiveDegreeDay(double* pdds,double* pds,double signorm)=0;
    74                 virtual int    UpdatePotentialSheetUngrounding(double* potential_sheet_ungrounding,Vector* vec_nodes_on_iceshelf,double* nodes_on_iceshelf)=0;
     73                virtual void   PositiveDegreeDay(IssmDouble* pdds,IssmDouble* pds,IssmDouble signorm)=0;
     74                virtual void   SmbGradients()=0;
     75                virtual int    UpdatePotentialSheetUngrounding(IssmDouble* potential_sheet_ungrounding,Vector* vec_nodes_on_iceshelf,IssmDouble* nodes_on_iceshelf)=0;
    7576                virtual void   ResetCoordinateSystem()=0;
    76                 virtual void   SmearFunction(Vector* smearedvector,double (*WeightFunction)(double distance,double radius),double radius)=0;
     77                virtual void   SmearFunction(Vector* smearedvector,IssmDouble (*WeightFunction)(IssmDouble distance,IssmDouble radius),IssmDouble radius)=0;
    7778
    7879                #ifdef _HAVE_RESPONSES_
    79                 virtual void   MinVel(double* pminvel, bool process_units)=0;
    80                 virtual void   MaxVel(double* pmaxvel, bool process_units)=0;
    81                 virtual void   MinVx(double* pminvx, bool process_units)=0;
    82                 virtual void   MaxVx(double* pmaxvx, bool process_units)=0;
    83                 virtual void   MaxAbsVx(double* pmaxabsvx, bool process_units)=0;
    84                 virtual void   MinVy(double* pminvy, bool process_units)=0;
    85                 virtual void   MaxVy(double* pmaxvy, bool process_units)=0;
    86                 virtual void   MaxAbsVy(double* pmaxabsvy, bool process_units)=0;
    87                 virtual void   MinVz(double* pminvz, bool process_units)=0;
    88                 virtual void   MaxVz(double* pmaxvz, bool process_units)=0;
    89                 virtual void   MaxAbsVz(double* pmaxabsvz, bool process_units)=0;
    90                 virtual double MassFlux(double* segment,bool process_units)=0;
    91                 virtual void   ElementResponse(double* presponse,int response_enum,bool process_units)=0;
    92                 virtual double IceVolume(void)=0;
     80                virtual void   MinVel(IssmDouble* pminvel, bool process_units)=0;
     81                virtual void   MaxVel(IssmDouble* pmaxvel, bool process_units)=0;
     82                virtual void   MinVx(IssmDouble* pminvx, bool process_units)=0;
     83                virtual void   MaxVx(IssmDouble* pmaxvx, bool process_units)=0;
     84                virtual void   MaxAbsVx(IssmDouble* pmaxabsvx, bool process_units)=0;
     85                virtual void   MinVy(IssmDouble* pminvy, bool process_units)=0;
     86                virtual void   MaxVy(IssmDouble* pmaxvy, bool process_units)=0;
     87                virtual void   MaxAbsVy(IssmDouble* pmaxabsvy, bool process_units)=0;
     88                virtual void   MinVz(IssmDouble* pminvz, bool process_units)=0;
     89                virtual void   MaxVz(IssmDouble* pmaxvz, bool process_units)=0;
     90                virtual void   MaxAbsVz(IssmDouble* pmaxabsvz, bool process_units)=0;
     91                virtual IssmDouble MassFlux(IssmDouble* segment,bool process_units)=0;
     92                virtual void   ElementResponse(IssmDouble* presponse,int response_enum,bool process_units)=0;
     93                virtual IssmDouble IceVolume(void)=0;
    9394                #endif
    9495
    9596                #ifdef _HAVE_CONTROL_
    9697                virtual void   Gradj(Vector* gradient,int control_type,int control_index)=0;
    97                 virtual double ThicknessAbsMisfit(bool process_units  ,int weight_index)=0;
    98                 virtual double SurfaceAbsVelMisfit(bool process_units ,int weight_index)=0;
    99                 virtual double SurfaceRelVelMisfit(bool process_units ,int weight_index)=0;
    100                 virtual double SurfaceLogVelMisfit(bool process_units ,int weight_index)=0;
    101                 virtual double SurfaceLogVxVyMisfit(bool process_units,int weight_index)=0;
    102                 virtual double SurfaceAverageVelMisfit(bool process_units,int weight_index)=0;
    103                 virtual double ThicknessAbsGradient(bool process_units,int weight_index)=0;
    104                 virtual double RheologyBbarAbsGradient(bool process_units,int weight_index)=0;
    105                 virtual double DragCoefficientAbsGradient(bool process_units,int weight_index)=0;
     98                virtual IssmDouble ThicknessAbsMisfit(bool process_units  ,int weight_index)=0;
     99                virtual IssmDouble SurfaceAbsVelMisfit(bool process_units ,int weight_index)=0;
     100                virtual IssmDouble SurfaceRelVelMisfit(bool process_units ,int weight_index)=0;
     101                virtual IssmDouble SurfaceLogVelMisfit(bool process_units ,int weight_index)=0;
     102                virtual IssmDouble SurfaceLogVxVyMisfit(bool process_units,int weight_index)=0;
     103                virtual IssmDouble SurfaceAverageVelMisfit(bool process_units,int weight_index)=0;
     104                virtual IssmDouble ThicknessAbsGradient(bool process_units,int weight_index)=0;
     105                virtual IssmDouble RheologyBbarAbsGradient(bool process_units,int weight_index)=0;
     106                virtual IssmDouble DragCoefficientAbsGradient(bool process_units,int weight_index)=0;
    106107                virtual void   ControlInputGetGradient(Vector* gradient,int enum_type,int control_index)=0;
    107                 virtual void   ControlInputSetGradient(double* gradient,int enum_type,int control_index)=0;
    108                 virtual void   ControlInputScaleGradient(int enum_type, double scale)=0;
     108                virtual void   ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index)=0;
     109                virtual void   ControlInputScaleGradient(int enum_type, IssmDouble scale)=0;
    109110                virtual void   GetVectorFromControlInputs(Vector* gradient,int control_enum,int control_index,const char* data)=0;
    110                 virtual void   SetControlInputsFromVector(double* vector,int control_enum,int control_index)=0;
    111                 virtual void   InputControlUpdate(double scalar,bool save_parameter)=0;
     111                virtual void   SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index)=0;
     112                virtual void   InputControlUpdate(IssmDouble scalar,bool save_parameter)=0;
    112113                #endif
    113114};
  • issm/trunk/src/c/objects/Elements/Penta.cpp

    r12643 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88#include <config.h>
     
    2424
    2525/*Constructors/destructor/copy*/
    26 /*FUNCTION Penta::Penta(){{{1*/
     26/*FUNCTION Penta::Penta(){{{*/
    2727Penta::Penta(){
    2828
     
    3939}
    4040/*}}}*/
    41 /*FUNCTION Penta::~Penta(){{{1*/
     41/*FUNCTION Penta::~Penta(){{{*/
    4242Penta::~Penta(){
    4343        delete inputs;
     
    4646}
    4747/*}}}*/
    48 /*FUNCTION Penta::Penta(int id, int index, IoModel* iomodel,int nummodels) {{{1*/
     48/*FUNCTION Penta::Penta(int id, int index, IoModel* iomodel,int nummodels) {{{*/
    4949Penta::Penta(int penta_id, int penta_sid, int index, IoModel* iomodel,int nummodels)
    5050        :PentaRef(nummodels)
     
    5656
    5757        /*Checks in debugging mode*/
    58         /*{{{2*/
     58        /*{{{*/
    5959        _assert_(iomodel->Data(MeshUpperelementsEnum));
    6060        _assert_(iomodel->Data(MeshLowerelementsEnum));
     
    6666
    6767        /*Build neighbors list*/
    68         if (isnan(iomodel->Data(MeshUpperelementsEnum)[index])) penta_elements_ids[1]=this->id; //upper penta is the same penta
     68        if (xIsNan<IssmDouble>(iomodel->Data(MeshUpperelementsEnum)[index])) penta_elements_ids[1]=this->id; //upper penta is the same penta
    6969        else                                    penta_elements_ids[1]=(int)(iomodel->Data(MeshUpperelementsEnum)[index]);
    70         if (isnan(iomodel->Data(MeshLowerelementsEnum)[index])) penta_elements_ids[0]=this->id; //lower penta is the same penta
     70        if (xIsNan<IssmDouble>(iomodel->Data(MeshLowerelementsEnum)[index])) penta_elements_ids[0]=this->id; //lower penta is the same penta
    7171        else                                    penta_elements_ids[0]=(int)(iomodel->Data(MeshLowerelementsEnum)[index]);
    7272        this->InitHookNeighbors(penta_elements_ids);
     
    9090}
    9191/*}}}*/
    92 /*FUNCTION Penta::copy {{{1*/
     92/*FUNCTION Penta::copy {{{*/
    9393Object* Penta::copy() {
    9494
     
    100100
    101101        //deal with PentaRef mother class
    102         penta->element_type_list=(int*)xmalloc(this->numanalyses*sizeof(int));
     102        penta->element_type_list=xNew<int>(this->numanalyses);
    103103        for(i=0;i<this->numanalyses;i++) penta->element_type_list[i]=this->element_type_list[i];
    104104
     
    130130
    131131        /*recover objects: */
    132         penta->nodes=(Node**)xmalloc(6*sizeof(Node*)); //we cannot rely on an analysis_counter to tell us which analysis_type we are running, so we just copy the nodes.
     132        penta->nodes=xNew<Node*>(6); //we cannot rely on an analysis_counter to tell us which analysis_type we are running, so we just copy the nodes.
    133133        for(i=0;i<6;i++)penta->nodes[i]=this->nodes[i];
    134134        penta->matice=(Matice*)penta->hmatice->delivers();
     
    144144
    145145/*Other*/
    146 /*FUNCTION Penta::AverageOntoPartition {{{1*/
    147 void  Penta::AverageOntoPartition(Vector* partition_contributions,Vector* partition_areas,double* vertex_response,double* qmu_part){
    148         _error_("Not supported yet!");
    149 }
    150 /*}}}*/
    151 /*FUNCTION Penta::BedNormal {{{1*/
    152 void Penta::BedNormal(double* bed_normal, double xyz_list[3][3]){
     146/*FUNCTION Penta::AverageOntoPartition {{{*/
     147void  Penta::AverageOntoPartition(Vector* partition_contributions,Vector* partition_areas,IssmDouble* vertex_response,IssmDouble* qmu_part){
     148        _error2_("Not supported yet!");
     149}
     150/*}}}*/
     151/*FUNCTION Penta::BedNormal {{{*/
     152void Penta::BedNormal(IssmDouble* bed_normal, IssmDouble xyz_list[3][3]){
    153153
    154154        int i;
    155         double v13[3],v23[3];
    156         double normal[3];
    157         double normal_norm;
     155        IssmDouble v13[3],v23[3];
     156        IssmDouble normal[3];
     157        IssmDouble normal_norm;
    158158
    159159        for (i=0;i<3;i++){
     
    173173}
    174174/*}}}*/
    175 /*FUNCTION Penta::BasalFrictionCreateInput {{{1*/
     175/*FUNCTION Penta::BasalFrictionCreateInput {{{*/
    176176void Penta::BasalFrictionCreateInput(void){
    177177
     
    181181        /*Intermediaries */
    182182        int    count,ig;
    183         double basalfriction[NUMVERTICES]={0,0,0,0,0,0};
    184         double alpha2,vx,vy;
     183        IssmDouble basalfriction[NUMVERTICES]={0,0,0,0,0,0};
     184        IssmDouble alpha2,vx,vy;
    185185        Friction*  friction=NULL;
    186186        GaussPenta* gauss=NULL;
     
    225225}
    226226/*}}}*/
    227 /*FUNCTION Penta::ComputeBasalStress {{{1*/
     227/*FUNCTION Penta::ComputeBasalStress {{{*/
    228228void  Penta::ComputeBasalStress(Vector* sigma_b){
    229229
     
    233233        int         analysis_type,approximation;
    234234        int         doflist[NUMVERTICES];
    235         double      xyz_list[NUMVERTICES][3];
    236         double      xyz_list_tria[3][3];
    237         double      rho_ice,gravity,stokesreconditioning;
    238         double      pressure,viscosity,bed,Jdet2d;
    239         double      bed_normal[3];
    240         double      basalforce[3];
    241         double      epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
    242         double      devstresstensor[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
    243         double      stresstensor[6]={0.0};
    244         double      sigma_xx,sigma_yy,sigma_zz;
    245         double      sigma_xy,sigma_xz,sigma_yz;
    246         double      surface=0,value=0;
     235        IssmDouble      xyz_list[NUMVERTICES][3];
     236        IssmDouble      xyz_list_tria[3][3];
     237        IssmDouble      rho_ice,gravity,stokesreconditioning;
     238        IssmDouble      pressure,viscosity,bed,Jdet2d;
     239        IssmDouble      bed_normal[3];
     240        IssmDouble      basalforce[3];
     241        IssmDouble      epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
     242        IssmDouble      devstresstensor[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
     243        IssmDouble      stresstensor[6]={0.0};
     244        IssmDouble      sigma_xx,sigma_yy,sigma_zz;
     245        IssmDouble      sigma_xy,sigma_xz,sigma_yz;
     246        IssmDouble      surface=0,value=0;
    247247        GaussPenta* gauss;
    248248
     
    252252
    253253        /*Check analysis_types*/
    254         if (analysis_type!=DiagnosticHorizAnalysisEnum) _error_("Not supported yet!");
    255         if (approximation!=StokesApproximationEnum) _error_("Not supported yet!");
     254        if (analysis_type!=DiagnosticHorizAnalysisEnum) _error2_("Not supported yet!");
     255        if (approximation!=StokesApproximationEnum) _error2_("Not supported yet!");
    256256
    257257        /*retrieve some parameters: */
     
    315315}
    316316/*}}}*/
    317 /*FUNCTION Penta::ComputeStrainRate {{{1*/
     317/*FUNCTION Penta::ComputeStrainRate {{{*/
    318318void  Penta::ComputeStrainRate(Vector* eps){
    319319
    320         _error_("Not implemented yet");
    321 
    322 }
    323 /*}}}*/
    324 /*FUNCTION Penta::ComputeStressTensor {{{1*/
     320        _error2_("Not implemented yet");
     321
     322}
     323/*}}}*/
     324/*FUNCTION Penta::ComputeStressTensor {{{*/
    325325void  Penta::ComputeStressTensor(){
    326326
    327327        int         iv;
    328         double      xyz_list[NUMVERTICES][3];
    329         double      pressure,viscosity;
    330         double      epsilon[6]; /* epsilon=[exx,eyy,exy];*/
    331         double      sigma_xx[NUMVERTICES];
    332         double          sigma_yy[NUMVERTICES];
    333         double          sigma_zz[NUMVERTICES];
    334         double      sigma_xy[NUMVERTICES];
    335         double          sigma_xz[NUMVERTICES];
    336         double          sigma_yz[NUMVERTICES];
     328        IssmDouble      xyz_list[NUMVERTICES][3];
     329        IssmDouble      pressure,viscosity;
     330        IssmDouble      epsilon[6]; /* epsilon=[exx,eyy,exy];*/
     331        IssmDouble      sigma_xx[NUMVERTICES];
     332        IssmDouble              sigma_yy[NUMVERTICES];
     333        IssmDouble              sigma_zz[NUMVERTICES];
     334        IssmDouble      sigma_xy[NUMVERTICES];
     335        IssmDouble              sigma_xz[NUMVERTICES];
     336        IssmDouble              sigma_yz[NUMVERTICES];
    337337        GaussPenta* gauss=NULL;
    338338
     
    377377}
    378378/*}}}*/
    379                 /*FUNCTION Penta::Configure {{{1*/
     379                /*FUNCTION Penta::Configure {{{*/
    380380void  Penta::Configure(Elements* elementsin, Loads* loadsin, DataSet* nodesin, Materials* materialsin, Parameters* parametersin){
    381381
     
    409409}
    410410/*}}}*/
    411 /*FUNCTION Penta::CreateKMatrix {{{1*/
     411/*FUNCTION Penta::CreateKMatrix {{{*/
    412412void  Penta::CreateKMatrix(Matrix* Kff, Matrix* Kfs,Vector* df){
    413413
     
    418418        parameters->FindParam(&analysis_type,AnalysisTypeEnum);
    419419
    420         /*Checks in debugging {{{2*/
     420        /*Checks in debugging {{{*/
    421421        _assert_(this->nodes && this->matice && this->matpar && this->verticalneighbors && this->parameters && this->inputs);
    422422        /*}}}*/
     
    464464                #endif
    465465                default:
    466                         _error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
     466                        _error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
    467467        }
    468468
     
    479479}
    480480/*}}}*/
    481 /*FUNCTION Penta::CreateKMatrixPrognostic {{{1*/
     481/*FUNCTION Penta::CreateKMatrixPrognostic {{{*/
    482482ElementMatrix* Penta::CreateKMatrixPrognostic(void){
    483483
     
    500500}
    501501/*}}}*/
    502 /*FUNCTION Penta::CreateKMatrixSlope {{{1*/
     502/*FUNCTION Penta::CreateKMatrixSlope {{{*/
    503503ElementMatrix* Penta::CreateKMatrixSlope(void){
    504504
     
    513513}
    514514/*}}}*/
    515 /*FUNCTION Penta::CreatePVector {{{1*/
     515/*FUNCTION Penta::CreatePVector {{{*/
    516516void  Penta::CreatePVector(Vector* pf){
    517517
     
    521521        parameters->FindParam(&analysis_type,AnalysisTypeEnum);
    522522
    523         /*if debugging mode, check that all pointers exist {{{2*/
     523        /*if debugging mode, check that all pointers exist {{{*/
    524524        _assert_(this->nodes && this->matice && this->matpar && this->verticalneighbors && this->parameters && this->inputs);
    525525        /*}}}*/
     
    569569                #endif
    570570                default:
    571                         _error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
     571                        _error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
    572572        }
    573573
     
    579579}
    580580/*}}}*/
    581 /*FUNCTION Penta::CreatePVectorPrognostic {{{1*/
     581/*FUNCTION Penta::CreatePVectorPrognostic {{{*/
    582582ElementVector* Penta::CreatePVectorPrognostic(void){
    583583
     
    601601}
    602602/*}}}*/
    603 /*FUNCTION Penta::CreatePVectorSlope {{{1*/
     603/*FUNCTION Penta::CreatePVectorSlope {{{*/
    604604ElementVector* Penta::CreatePVectorSlope(void){
    605605
     
    615615}
    616616/*}}}*/
    617 /*FUNCTION Penta::CreateJacobianMatrix{{{1*/
     617/*FUNCTION Penta::CreateJacobianMatrix{{{*/
    618618void  Penta::CreateJacobianMatrix(Matrix* Jff){
    619619
     
    623623        parameters->FindParam(&analysis_type,AnalysisTypeEnum);
    624624
    625         /*Checks in debugging {{{2*/
     625        /*Checks in debugging {{{*/
    626626        _assert_(this->nodes && this->matice && this->matpar && this->verticalneighbors && this->parameters && this->inputs);
    627627        /*}}}*/
     
    638638#endif
    639639                default:
    640                         _error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
     640                        _error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
    641641        }
    642642
     
    648648}
    649649/*}}}*/
    650 /*FUNCTION Penta::DeepEcho{{{1*/
     650/*FUNCTION Penta::DeepEcho{{{*/
    651651void Penta::DeepEcho(void){
    652652
    653653        int i;
    654654       
    655         printf("Penta:\n");
    656         printf("   id: %i\n",id);
     655        _printLine_("Penta:");
     656        _printLine_("   id: " << id);
    657657        nodes[0]->DeepEcho();
    658658        nodes[1]->DeepEcho();
     
    663663        matice->DeepEcho();
    664664        matpar->DeepEcho();
    665         printf("   neighbor ids: %i-%i\n",verticalneighbors[0]->Id(),verticalneighbors[1]->Id());
    666         printf("   parameters\n");
     665        _printLine_("   neighbor ids: " << verticalneighbors[0]->Id() << "-" << verticalneighbors[1]->Id());
     666        _printLine_("   parameters");
    667667        parameters->DeepEcho();
    668         printf("   inputs\n");
     668        _printLine_("   inputs");
    669669        inputs->DeepEcho();
    670         printf("   results\n");
     670        _printLine_("   results");
    671671        results->DeepEcho();
    672         printf("neighboor sids: \n");
    673         printf(" %i %i %i\n",horizontalneighborsids[0],horizontalneighborsids[1],horizontalneighborsids[2]);
     672        _printLine_("neighboor sids: ");
     673        _printLine_(" " << horizontalneighborsids[0] << " " << horizontalneighborsids[1] << " " << horizontalneighborsids[2]);
    674674
    675675        return;
    676676}
    677677/*}}}*/
    678 /*FUNCTION Penta::DeleteResults {{{1*/
     678/*FUNCTION Penta::DeleteResults {{{*/
    679679void  Penta::DeleteResults(void){
    680680
     
    685685}
    686686/*}}}*/
    687 /*FUNCTION Penta::Echo{{{1*/
     687/*FUNCTION Penta::Echo{{{*/
    688688
    689689void Penta::Echo(void){
     
    691691}
    692692/*}}}*/
    693 /*FUNCTION Penta::ObjectEnum{{{1*/
     693/*FUNCTION Penta::ObjectEnum{{{*/
    694694int Penta::ObjectEnum(void){
    695695
     
    698698}
    699699/*}}}*/
    700 /*FUNCTION Penta::GetBasalElement{{{1*/
     700/*FUNCTION Penta::GetBasalElement{{{*/
    701701Penta* Penta::GetBasalElement(void){
    702702
     
    719719}
    720720/*}}}*/
    721 /*FUNCTION Penta::GetDofList {{{1*/
     721/*FUNCTION Penta::GetDofList {{{*/
    722722void  Penta::GetDofList(int** pdoflist,int approximation_enum,int setenum){
    723723
     
    730730
    731731        /*Allocate: */
    732         doflist=(int*)xmalloc(numberofdofs*sizeof(int));
     732        doflist=xNew<int>(numberofdofs);
    733733
    734734        /*Populate: */
     
    743743}
    744744/*}}}*/
    745 /*FUNCTION Penta::GetDofList1 {{{1*/
     745/*FUNCTION Penta::GetDofList1 {{{*/
    746746void  Penta::GetDofList1(int* doflist){
    747747
     
    751751}
    752752/*}}}*/
    753 /*FUNCTION Penta::GetConnectivityList {{{1*/
     753/*FUNCTION Penta::GetConnectivityList {{{*/
    754754void  Penta::GetConnectivityList(int* connectivity){
    755755        for(int i=0;i<NUMVERTICES;i++) connectivity[i]=nodes[i]->GetConnectivity();
    756756}
    757757/*}}}*/
    758 /*FUNCTION Penta::GetElementType {{{1*/
     758/*FUNCTION Penta::GetElementType {{{*/
    759759int Penta::GetElementType(){
    760760
     
    763763}
    764764/*}}}*/
    765 /*FUNCTION Penta::GetElementSizes{{{1*/
    766 void Penta::GetElementSizes(double* hx,double* hy,double* hz){
    767 
    768         double xyz_list[NUMVERTICES][3];
    769         double xmin,ymin,zmin;
    770         double xmax,ymax,zmax;
     765/*FUNCTION Penta::GetElementSizes{{{*/
     766void Penta::GetElementSizes(IssmDouble* hx,IssmDouble* hy,IssmDouble* hz){
     767
     768        IssmDouble xyz_list[NUMVERTICES][3];
     769        IssmDouble xmin,ymin,zmin;
     770        IssmDouble xmax,ymax,zmax;
    771771
    772772        /*Get xyz list: */
     
    790790}
    791791/*}}}*/
    792 /*FUNCTION Penta::GetHorizontalNeighboorSids {{{1*/
     792/*FUNCTION Penta::GetHorizontalNeighboorSids {{{*/
    793793int* Penta::GetHorizontalNeighboorSids(){
    794794
     
    798798}
    799799/*}}}*/
    800 /*FUNCTION Penta::GetLowerElement{{{1*/
     800/*FUNCTION Penta::GetLowerElement{{{*/
    801801Penta* Penta::GetLowerElement(void){
    802802
     
    808808}
    809809/*}}}*/
    810 /*FUNCTION Penta::GetNodeIndex {{{1*/
     810/*FUNCTION Penta::GetNodeIndex {{{*/
    811811int Penta::GetNodeIndex(Node* node){
    812812
     
    816816                 return i;
    817817        }
    818         _error_("Node provided not found among element nodes");
    819 
    820 }
    821 /*}}}*/
    822 /*FUNCTION Penta::GetInputListOnVertices(double* pvalue,int enumtype) {{{1*/
    823 void Penta::GetInputListOnVertices(double* pvalue,int enumtype){
     818        _error2_("Node provided not found among element nodes");
     819
     820}
     821/*}}}*/
     822/*FUNCTION Penta::GetInputListOnVertices(IssmDouble* pvalue,int enumtype) {{{*/
     823void Penta::GetInputListOnVertices(IssmDouble* pvalue,int enumtype){
    824824
    825825        /*Intermediaries*/
    826         double     value[NUMVERTICES];
     826        IssmDouble     value[NUMVERTICES];
    827827        GaussPenta *gauss              = NULL;
    828828
    829829        /*Recover input*/
    830830        Input* input=inputs->GetInput(enumtype);
    831         if (!input) _error_("Input %s not found in element",EnumToStringx(enumtype));
     831        if (!input) _error2_("Input " << EnumToStringx(enumtype) << " not found in element");
    832832
    833833        /*Checks in debugging mode*/
     
    845845}
    846846/*}}}*/
    847 /*FUNCTION Penta::GetInputListOnVertices(double* pvalue,int enumtype,double defaultvalue) {{{1*/
    848 void Penta::GetInputListOnVertices(double* pvalue,int enumtype,double defaultvalue){
     847/*FUNCTION Penta::GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue) {{{*/
     848void Penta::GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue){
    849849
    850850        /*Intermediaries*/
    851         double     value[NUMVERTICES];
     851        IssmDouble     value[NUMVERTICES];
    852852        GaussPenta *gauss              = NULL;
    853853
     
    874874}
    875875/*}}}*/
    876 /*FUNCTION Penta::GetInputValue(double* pvalue,Node* node,int enumtype) {{{1*/
    877 void Penta::GetInputValue(double* pvalue,Node* node,int enumtype){
     876/*FUNCTION Penta::GetInputValue(IssmDouble* pvalue,Node* node,int enumtype) {{{*/
     877void Penta::GetInputValue(IssmDouble* pvalue,Node* node,int enumtype){
    878878
    879879        Input* input=inputs->GetInput(enumtype);
    880         if(!input) _error_("No input of type %s found in tria",EnumToStringx(enumtype));
     880        if(!input) _error2_("No input of type " << EnumToStringx(enumtype) << " found in tria");
    881881
    882882        GaussPenta* gauss=new GaussPenta();
     
    887887}
    888888/*}}}*/
    889 /*FUNCTION Penta::GetPhi {{{1*/
    890 void Penta::GetPhi(double* phi, double*  epsilon, double viscosity){
     889/*FUNCTION Penta::GetPhi {{{*/
     890void Penta::GetPhi(IssmDouble* phi, IssmDouble*  epsilon, IssmDouble viscosity){
    891891        /*Compute deformational heating from epsilon and viscosity */
    892892
    893         double epsilon_matrix[3][3];
    894         double epsilon_eff;
    895         double epsilon_sqr[3][3];
     893        IssmDouble epsilon_matrix[3][3];
     894        IssmDouble epsilon_eff;
     895        IssmDouble epsilon_sqr[3][3];
    896896
    897897        /* Build epsilon matrix */
     
    925925}
    926926/*}}}*/
    927 /*FUNCTION Penta::GetSidList{{{1*/
     927/*FUNCTION Penta::GetSidList{{{*/
    928928void  Penta::GetSidList(int* sidlist){
    929929
     
    933933}
    934934/*}}}*/
    935 /*FUNCTION Penta::GetSolutionFromInputs{{{1*/
     935/*FUNCTION Penta::GetSolutionFromInputs{{{*/
    936936void  Penta::GetSolutionFromInputs(Vector* solution){
    937937
     
    973973        #endif
    974974        default:
    975                 _error_("analysis: %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
    976         }
    977 }
    978 /*}}}*/
    979 /*FUNCTION Penta::GetStabilizationParameter {{{1*/
    980 double Penta::GetStabilizationParameter(double u, double v, double w, double diameter, double kappa){
     975                _error2_("analysis: " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
     976        }
     977}
     978/*}}}*/
     979/*FUNCTION Penta::GetStabilizationParameter {{{*/
     980IssmDouble Penta::GetStabilizationParameter(IssmDouble u, IssmDouble v, IssmDouble w, IssmDouble diameter, IssmDouble kappa){
    981981        /*Compute stabilization parameter*/
    982982        /*kappa=thermalconductivity/(rho_ice*hearcapacity) for thermal model*/
    983983        /*kappa=enthalpydiffusionparameter for enthalpy model*/
    984984
    985         double normu;
    986         double tau_parameter;
     985        IssmDouble normu;
     986        IssmDouble tau_parameter;
    987987
    988988        normu=pow(pow(u,2)+pow(v,2)+pow(w,2),0.5);
     
    995995}
    996996/*}}}*/
    997 /*FUNCTION Penta::GetStrainRate3dPattyn{{{1*/
    998 void Penta::GetStrainRate3dPattyn(double* epsilon,double* xyz_list, GaussPenta* gauss, Input* vx_input, Input* vy_input){
     997/*FUNCTION Penta::GetStrainRate3dPattyn{{{*/
     998void Penta::GetStrainRate3dPattyn(IssmDouble* epsilon,IssmDouble* xyz_list, GaussPenta* gauss, Input* vx_input, Input* vy_input){
    999999        /*Compute the 3d Blatter/PattynStrain Rate (5 components):
    10001000         *
     
    10081008
    10091009        int i;
    1010         double epsilonvx[5];
    1011         double epsilonvy[5];
     1010        IssmDouble epsilonvx[5];
     1011        IssmDouble epsilonvy[5];
    10121012
    10131013        /*Check that both inputs have been found*/
    10141014        if (!vx_input || !vy_input){
    1015                 _error_("Input missing. Here are the input pointers we have for vx: %p, vy: %p\n",vx_input,vy_input);
     1015                _error2_("Input missing. Here are the input pointers we have for vx: " << vx_input << ", vy: " << vy_input << "\n");
    10161016        }
    10171017
     
    10241024}
    10251025/*}}}*/
    1026 /*FUNCTION Penta::GetStrainRate3d{{{1*/
    1027 void Penta::GetStrainRate3d(double* epsilon,double* xyz_list, GaussPenta* gauss, Input* vx_input, Input* vy_input, Input* vz_input){
     1026/*FUNCTION Penta::GetStrainRate3d{{{*/
     1027void Penta::GetStrainRate3d(IssmDouble* epsilon,IssmDouble* xyz_list, GaussPenta* gauss, Input* vx_input, Input* vy_input, Input* vz_input){
    10281028        /*Compute the 3d Strain Rate (6 components):
    10291029         *
     
    10321032
    10331033        int i;
    1034         double epsilonvx[6];
    1035         double epsilonvy[6];
    1036         double epsilonvz[6];
     1034        IssmDouble epsilonvx[6];
     1035        IssmDouble epsilonvy[6];
     1036        IssmDouble epsilonvz[6];
    10371037
    10381038        /*Check that both inputs have been found*/
    10391039        if (!vx_input || !vy_input || !vz_input){
    1040                 _error_("Input missing. Here are the input pointers we have for vx: %p, vy: %p, vz: %p\n",vx_input,vy_input,vz_input);
     1040                _error2_("Input missing. Here are the input pointers we have for vx: " << vx_input << ", vy: " << vy_input << ", vz: " << vz_input << "\n");
    10411041        }
    10421042
     
    10501050}
    10511051/*}}}*/
    1052 /*FUNCTION Penta::GetUpperElement{{{1*/
     1052/*FUNCTION Penta::GetUpperElement{{{*/
    10531053Penta* Penta::GetUpperElement(void){
    10541054
     
    10601060}
    10611061/*}}}*/
    1062 /*FUNCTION Penta::GetVectorFromInputs{{{1*/
     1062/*FUNCTION Penta::GetVectorFromInputs{{{*/
    10631063void  Penta::GetVectorFromInputs(Vector* vector,int input_enum){
    10641064
     
    10731073        /*Get input (either in element or material)*/
    10741074        Input* input=inputs->GetInput(input_enum);
    1075         if(!input) _error_("Input %s not found in element",EnumToStringx(input_enum));
     1075        if(!input) _error2_("Input " << EnumToStringx(input_enum) << " not found in element");
    10761076
    10771077        /*We found the enum.  Use its values to fill into the vector, using the vertices ids: */
     
    10791079}
    10801080/*}}}*/
    1081 /*FUNCTION Penta::GetVectorFromResults{{{1*/
     1081/*FUNCTION Penta::GetVectorFromResults{{{*/
    10821082void  Penta::GetVectorFromResults(Vector* vector,int offset,int enum_in,int interp){
    10831083
     
    10981098        }
    10991099        else{
    1100                 printf("Interpolation %s not supported\n",EnumToStringx(interp));
    1101         }
    1102 }
    1103 /*}}}*/
    1104 /*FUNCTION Penta::GetZcoord {{{1*/
    1105 double Penta::GetZcoord(GaussPenta* gauss){
     1100                _printLine_("Interpolation " << EnumToStringx(interp) << " not supported");
     1101        }
     1102}
     1103/*}}}*/
     1104/*FUNCTION Penta::GetZcoord {{{*/
     1105IssmDouble Penta::GetZcoord(GaussPenta* gauss){
    11061106
    11071107        int    i;
    1108         double z;
    1109         double xyz_list[NUMVERTICES][3];
    1110         double z_list[NUMVERTICES];
     1108        IssmDouble z;
     1109        IssmDouble xyz_list[NUMVERTICES][3];
     1110        IssmDouble z_list[NUMVERTICES];
    11111111
    11121112        GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
     
    11171117}
    11181118/*}}}*/
    1119 /*FUNCTION Penta::Sid {{{1*/
     1119/*FUNCTION Penta::Sid {{{*/
    11201120int    Penta::Sid(){
    11211121       
     
    11241124}
    11251125/*}}}*/
    1126 /*FUNCTION Penta::Id {{{1*/
     1126/*FUNCTION Penta::Id {{{*/
    11271127int    Penta::Id(void){
    11281128        return id;
    11291129}
    11301130/*}}}*/
    1131 /*FUNCTION Penta::InputArtificialNoise{{{1*/
    1132 void  Penta::InputArtificialNoise(int enum_type,double min,double max){
     1131/*FUNCTION Penta::InputArtificialNoise{{{*/
     1132void  Penta::InputArtificialNoise(int enum_type,IssmDouble min,IssmDouble max){
    11331133
    11341134        Input* input=NULL;
     
    11361136        /*Make a copy of the original input: */
    11371137        input=(Input*)this->inputs->GetInput(enum_type);
    1138         if(!input)_error_(" could not find old input with enum: %s",EnumToStringx(enum_type));
     1138        if(!input)_error2_("could not find old input with enum: " << EnumToStringx(enum_type));
    11391139
    11401140        /*ArtificialNoise: */
     
    11421142}
    11431143/*}}}*/
    1144 /*FUNCTION Penta::InputConvergence{{{1*/
    1145 bool Penta::InputConvergence(double* eps, int* enums,int num_enums,int* criterionenums,double* criterionvalues,int num_criterionenums){
     1144/*FUNCTION Penta::InputConvergence{{{*/
     1145bool Penta::InputConvergence(IssmDouble* eps, int* enums,int num_enums,int* criterionenums,IssmDouble* criterionvalues,int num_criterionenums){
    11461146
    11471147        int i;
     
    11501150        Input** old_inputs=NULL;
    11511151
    1152         new_inputs=(Input**)xmalloc(num_enums/2*sizeof(Input*)); //half the enums are for the new inputs
    1153         old_inputs=(Input**)xmalloc(num_enums/2*sizeof(Input*)); //half the enums are for the old inputs
     1152        new_inputs=xNew<Input*>(num_enums/2); //half the enums are for the new inputs
     1153        old_inputs=xNew<Input*>(num_enums/2); //half the enums are for the old inputs
    11541154
    11551155        for(i=0;i<num_enums/2;i++){
    11561156                new_inputs[i]=(Input*)this->inputs->GetInput(enums[2*i+0]);
    11571157                old_inputs[i]=(Input*)this->inputs->GetInput(enums[2*i+1]);
    1158                 if(!new_inputs[i])_error_("%s%s"," could not find input with enum ",EnumToStringx(enums[2*i+0]));
    1159                 if(!old_inputs[i])_error_("%s%s"," could not find input with enum ",EnumToStringx(enums[2*i+0]));
     1158                if(!new_inputs[i])_error2_("could not find input with enum " << EnumToStringx(enums[2*i+0]));
     1159                if(!old_inputs[i])_error2_("could not find input with enum " << EnumToStringx(enums[2*i+0]));
    11601160        }
    11611161
     
    11671167
    11681168        /*clean up*/
    1169         xfree((void**)&new_inputs);
    1170         xfree((void**)&old_inputs);
     1169        xDelete<Input*>(new_inputs);
     1170        xDelete<Input*>(old_inputs);
    11711171
    11721172        /*Return output*/
     
    11741174}
    11751175/*}}}*/
    1176 /*FUNCTION Penta::InputCreate(double scalar,int enum,int code);{{{1*/
    1177 void Penta::InputCreate(double scalar,int name,int code){
     1176/*FUNCTION Penta::InputCreate(IssmDouble scalar,int enum,int code);{{{*/
     1177void Penta::InputCreate(IssmDouble scalar,int name,int code){
    11781178
    11791179        /*Check that name is an element input*/
     
    11861186                this->inputs->AddInput(new IntInput(name,(int)scalar));
    11871187        }
    1188         else if ((code==7) || (code==3)){ //double
    1189                 this->inputs->AddInput(new DoubleInput(name,(double)scalar));
    1190         }
    1191         else _error_("%s%i"," could not recognize nature of vector from code ",code);
    1192 
    1193 }
    1194 /*}}}*/
    1195 /*FUNCTION Penta::InputCreate(double* vector,int index,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code){{{1*/
    1196 void Penta::InputCreate(double* vector, int index,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code){//index into elements
     1188        else if ((code==7) || (code==3)){ //IssmDouble
     1189                this->inputs->AddInput(new DoubleInput(name,(IssmDouble)scalar));
     1190        }
     1191        else _error2_("could not recognize nature of vector from code " << code);
     1192
     1193}
     1194/*}}}*/
     1195/*FUNCTION Penta::InputCreate(IssmDouble* vector,int index,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code){{{*/
     1196void Penta::InputCreate(IssmDouble* vector, int index,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code){//index into elements
    11971197
    11981198        /*Intermediaries*/
     
    12001200        int    penta_vertex_ids[6];
    12011201        int    row;
    1202         double nodeinputs[6];
    1203         double time;
     1202        IssmDouble nodeinputs[6];
     1203        IssmDouble time;
    12041204        TransientInput* transientinput=NULL;
    12051205
    12061206        int    numberofvertices;
    12071207        int    numberofelements;
    1208         double yts;
     1208        IssmDouble yts;
    12091209
    12101210        /*Fetch parameters: */
     
    12251225
    12261226                        /*create input values: */
    1227                         for(i=0;i<6;i++)nodeinputs[i]=(double)vector[penta_vertex_ids[i]-1];
     1227                        for(i=0;i<6;i++)nodeinputs[i]=(IssmDouble)vector[penta_vertex_ids[i]-1];
    12281228
    12291229                        /*process units: */
     
    12401240                                for(i=0;i<6;i++){
    12411241                                        row=penta_vertex_ids[i]-1;
    1242                                         nodeinputs[i]=(double)vector[N*row+t];
     1242                                        nodeinputs[i]=(IssmDouble)vector[N*row+t];
    12431243                                }
    12441244
     
    12471247
    12481248                                /*time? :*/
    1249                                 time=(double)vector[(M-1)*N+t]*yts;
     1249                                time=(IssmDouble)vector[(M-1)*N+t]*yts;
    12501250
    12511251                                if(t==0)transientinput=new TransientInput(vector_enum);
     
    12541254                        this->inputs->AddInput(transientinput);
    12551255                }
    1256                 else _error_("nodal vector is either numberofnodes (%i), or numberofnodes+1 long. Field provided is %i long. Enum %s",numberofvertices,M,EnumToStringx(vector_enum));
     1256                else _error2_("nodal vector is either numberofnodes (" << numberofvertices << "), or numberofnodes+1 long. Field provided is " << M << " long. Enum " << EnumToStringx(vector_enum));
    12571257        }
    12581258        else if(vector_type==2){ //element vector
     
    12681268                                this->inputs->AddInput(new IntInput(vector_enum,(int)vector[index]));
    12691269                        }
    1270                         else if (code==7){ //double
    1271                                 this->inputs->AddInput(new DoubleInput(vector_enum,(double)vector[index]));
     1270                        else if (code==7){ //IssmDouble
     1271                                this->inputs->AddInput(new DoubleInput(vector_enum,(IssmDouble)vector[index]));
    12721272                        }
    1273                         else _error_("%s%i"," could not recognize nature of vector from code ",code);
     1273                        else _error2_("could not recognize nature of vector from code " << code);
    12741274                }
    12751275                else {
    1276                         _error_("transient elementary inputs not supported yet!");
     1276                        _error2_("transient elementary inputs not supported yet!");
    12771277                }
    12781278        }
    12791279        else{
    1280                 _error_("Cannot add input for vector type %i (not supported)",vector_type);
    1281         }
    1282 
    1283 }
    1284 /*}}}*/
    1285 /*FUNCTION Penta::InputDepthAverageAtBase{{{1*/
     1280                _error2_("Cannot add input for vector type " << vector_type << " (not supported)");
     1281        }
     1282
     1283}
     1284/*}}}*/
     1285/*FUNCTION Penta::InputDepthAverageAtBase{{{*/
    12861286void  Penta::InputDepthAverageAtBase(int enum_type,int average_enum_type,int object_enum){
    12871287
    12881288        int  step,i;
    1289         double  xyz_list[NUMVERTICES][3];
    1290         double  Helem_list[NUMVERTICES];
    1291         double  zeros_list[NUMVERTICES]={0.0};
     1289        IssmDouble  xyz_list[NUMVERTICES][3];
     1290        IssmDouble  Helem_list[NUMVERTICES];
     1291        IssmDouble  zeros_list[NUMVERTICES]={0.0};
    12921292        Penta* penta=NULL;
    12931293        Input* original_input=NULL;
     
    13171317                 original_input=(Input*)penta->matice->inputs->GetInput(enum_type);
    13181318                else
    1319                  _error_("object %s not supported yet",EnumToStringx(object_enum));
    1320                 if(!original_input) _error_("could not find input with enum %s",EnumToStringx(enum_type));
     1319                 _error2_("object " << EnumToStringx(object_enum) << " not supported yet");
     1320                if(!original_input) _error2_("could not find input with enum " << EnumToStringx(enum_type));
    13211321
    13221322                /*If first time, initialize total_integrated_input*/
     
    13291329                         total_integrated_input=new DoubleInput(average_enum_type,0.0);
    13301330                        else
    1331                          _error_("object %s not supported yet",EnumToStringx(original_input->ObjectEnum()));
     1331                         _error2_("object " << EnumToStringx(original_input->ObjectEnum()) << " not supported yet");
    13321332                }
    13331333
     
    13771377         this->matice->inputs->AddInput((Input*)depth_averaged_input);
    13781378        else
    1379          _error_("object %s not supported yet",EnumToStringx(object_enum));
    1380 }
    1381 /*}}}*/
    1382 /*FUNCTION Penta::InputDuplicate{{{1*/
     1379         _error2_("object " << EnumToStringx(object_enum) << " not supported yet");
     1380}
     1381/*}}}*/
     1382/*FUNCTION Penta::InputDuplicate{{{*/
    13831383void  Penta::InputDuplicate(int original_enum,int new_enum){
    13841384
     
    13881388}
    13891389/*}}}*/
    1390 /*FUNCTION Penta::InputExtrude {{{1*/
     1390/*FUNCTION Penta::InputExtrude {{{*/
    13911391void  Penta::InputExtrude(int enum_type,int object_type){
    13921392
     
    14021402        if (object_type==ElementEnum){
    14031403                num_inputs=1;
    1404                 base_inputs=(Input**)xmalloc(num_inputs*sizeof(Input*));
     1404                base_inputs=xNew<Input*>(num_inputs);
    14051405                base_inputs[0]=(Input*)this->inputs->GetInput(enum_type);
    14061406        }
    14071407        else if (object_type==MaterialsEnum){
    14081408                num_inputs=1;
    1409                 base_inputs=(Input**)xmalloc(num_inputs*sizeof(Input*));
     1409                base_inputs=xNew<Input*>(num_inputs);
    14101410                base_inputs[0]=(Input*)matice->inputs->GetInput(enum_type);
    14111411        }
    14121412        else if (object_type==NodeEnum){
    14131413                num_inputs=3; //only the three upper nodes
    1414                 base_inputs=(Input**)xmalloc(num_inputs*sizeof(Input*));
     1414                base_inputs=xNew<Input*>(num_inputs);
    14151415                for(i=0;i<num_inputs;i++){
    14161416                        base_inputs[i]=(Input*)this->nodes[i]->inputs->GetInput(enum_type);
     
    14181418        }
    14191419        else{
    1420                 _error_("object of type %s not supported yet",EnumToStringx(object_type));
     1420                _error2_("object of type " << EnumToStringx(object_type) << " not supported yet");
    14211421        }
    14221422        for(i=0;i<num_inputs;i++){
    1423                 if(!base_inputs[i]) _error_("could not find input with enum %s in object %s",EnumToStringx(enum_type),EnumToStringx(object_type));
     1423                if(!base_inputs[i]) _error2_("could not find input with enum " << EnumToStringx(enum_type) << " in object " << EnumToStringx(object_type));
    14241424                base_inputs[i]->Extrude();
    14251425        }
     
    14481448                        }
    14491449                        else{
    1450                                 _error_("object of type %s not supported yet",EnumToStringx(object_type));
     1450                                _error2_("object of type " << EnumToStringx(object_type) << " not supported yet");
    14511451                        }
    14521452                }
     
    14571457
    14581458        /*clean-up and return*/
    1459         xfree((void**)&base_inputs);
    1460 }
    1461 /*}}}*/
    1462 /*FUNCTION Penta::InputScale{{{1*/
    1463 void  Penta::InputScale(int enum_type,double scale_factor){
     1459        xDelete<Input*>(base_inputs);
     1460}
     1461/*}}}*/
     1462/*FUNCTION Penta::InputScale{{{*/
     1463void  Penta::InputScale(int enum_type,IssmDouble scale_factor){
    14641464
    14651465        Input* input=NULL;
     
    14671467        /*Make a copy of the original input: */
    14681468        input=(Input*)this->inputs->GetInput(enum_type);
    1469         if(!input)_error_(" could not find old input with enum: %s",EnumToStringx(enum_type));
     1469        if(!input)_error2_("could not find old input with enum: " << EnumToStringx(enum_type));
    14701470
    14711471        /*Scale: */
     
    14731473}
    14741474/*}}}*/
    1475 /*FUNCTION Penta::InputToResult{{{1*/
    1476 void  Penta::InputToResult(int enum_type,int step,double time){
     1475/*FUNCTION Penta::InputToResult{{{*/
     1476void  Penta::InputToResult(int enum_type,int step,IssmDouble time){
    14771477
    14781478        int    i;
     
    14831483        if (enum_type==MaterialsRheologyBbarEnum) input=this->matice->inputs->GetInput(MaterialsRheologyBEnum);
    14841484        else input=this->inputs->GetInput(enum_type);
    1485         //if (!input) _error_("Input %s not found in penta->inputs",EnumToStringx(enum_type)); why error out? if the requested input does not exist, we should still
     1485        //if (!input) _error2_("Input " << EnumToStringx(enum_type) << " not found in penta->inputs"); why error out? if the requested input does not exist, we should still
    14861486        //try and output whatever we can instead of just failing.
    14871487        if(!input)return;
     
    14981498}
    14991499/*}}}*/
    1500 /*FUNCTION Penta::InputUpdateFromConstant(bool value, int name);{{{1*/
     1500/*FUNCTION Penta::InputUpdateFromConstant(bool value, int name);{{{*/
    15011501void  Penta::InputUpdateFromConstant(bool constant, int name){
    15021502
     
    15081508}
    15091509/*}}}*/
    1510 /*FUNCTION Penta::InputUpdateFromConstant(double value, int name);{{{1*/
    1511 void  Penta::InputUpdateFromConstant(double constant, int name){
     1510/*FUNCTION Penta::InputUpdateFromConstant(IssmDouble value, int name);{{{*/
     1511void  Penta::InputUpdateFromConstant(IssmDouble constant, int name){
    15121512        /*Check that name is an element input*/
    15131513        if (!IsInput(name)) return;
     
    15171517}
    15181518/*}}}*/
    1519 /*FUNCTION Penta::InputUpdateFromConstant(int value, int name);{{{1*/
     1519/*FUNCTION Penta::InputUpdateFromConstant(int value, int name);{{{*/
    15201520void  Penta::InputUpdateFromConstant(int constant, int name){
    15211521        /*Check that name is an element input*/
     
    15261526}
    15271527/*}}}*/
    1528 /*FUNCTION Penta::InputUpdateFromIoModel {{{1*/
     1528/*FUNCTION Penta::InputUpdateFromIoModel {{{*/
    15291529void Penta::InputUpdateFromIoModel(int index,IoModel* iomodel){
    15301530
     
    15321532        IssmInt i,j;
    15331533        int     penta_vertex_ids[6];
    1534         double  nodeinputs[6];
    1535         double  cmmininputs[6];
    1536         double  cmmaxinputs[6];
    1537 
    1538         double  yts;
     1534        IssmDouble  nodeinputs[6];
     1535        IssmDouble  cmmininputs[6];
     1536        IssmDouble  cmmaxinputs[6];
     1537
     1538        IssmDouble  yts;
    15391539        bool    control_analysis;
    15401540        int     num_control_type;
     
    15481548
    15491549        /*Checks if debuging*/
    1550         /*{{{2*/
     1550        /*{{{*/
    15511551        _assert_(iomodel->Data(MeshElementsEnum));
    15521552        /*}}}*/
     
    15971597                                        /*Matice will take care of it*/ break;
    15981598                                default:
    1599                                         _error_("Control %s not implemented yet",EnumToStringx((int)iomodel->Data(InversionControlParametersEnum)[i]));
     1599                                        _error2_("Control " << EnumToStringx((int)iomodel->Data(InversionControlParametersEnum)[i]) << " not implemented yet");
    16001600                        }
    16011601                }
     
    16301630                }
    16311631                else{
    1632                         _error_("Approximation type %s not supported yet",EnumToStringx((int)*(iomodel->Data(FlowequationElementEquationEnum)+index)));
     1632                        _error2_("Approximation type " << EnumToStringx((int)*(iomodel->Data(FlowequationElementEquationEnum)+index)) << " not supported yet");
    16331633                }
    16341634        }
     
    16491649}
    16501650/*}}}*/
    1651 /*FUNCTION Penta::InputUpdateFromSolution {{{1*/
    1652 void  Penta::InputUpdateFromSolution(double* solution){
     1651/*FUNCTION Penta::InputUpdateFromSolution {{{*/
     1652void  Penta::InputUpdateFromSolution(IssmDouble* solution){
    16531653
    16541654        int analysis_type;
     
    17141714        #endif
    17151715        default:
    1716                 _error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
    1717         }
    1718 }
    1719 /*}}}*/
    1720 /*FUNCTION Penta::InputUpdateFromSolutionPrognostic{{{1*/
    1721 void  Penta::InputUpdateFromSolutionPrognostic(double* solution){
     1716                _error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
     1717        }
     1718}
     1719/*}}}*/
     1720/*FUNCTION Penta::InputUpdateFromSolutionPrognostic{{{*/
     1721void  Penta::InputUpdateFromSolutionPrognostic(IssmDouble* solution){
    17221722
    17231723        const int  numdof   = NDOF1*NUMVERTICES;
     
    17261726        int    i,hydroadjustment;
    17271727        int*   doflist = NULL;
    1728         double rho_ice,rho_water,minthickness;
    1729         double newthickness[numdof];
    1730         double newbed[numdof];
    1731         double newsurface[numdof];
    1732         double oldbed[NUMVERTICES];
    1733         double oldsurface[NUMVERTICES];
    1734         double oldthickness[NUMVERTICES];
     1728        IssmDouble rho_ice,rho_water,minthickness;
     1729        IssmDouble newthickness[numdof];
     1730        IssmDouble newbed[numdof];
     1731        IssmDouble newsurface[numdof];
     1732        IssmDouble oldbed[NUMVERTICES];
     1733        IssmDouble oldsurface[NUMVERTICES];
     1734        IssmDouble oldthickness[NUMVERTICES];
    17351735        Penta  *penta   = NULL;
    17361736
     
    17451745        for(i=0;i<numdof2d;i++){
    17461746                newthickness[i]=solution[doflist[i]];
    1747                 if(isnan(newthickness[i])) _error_("NaN found in solution vector");
     1747                if(xIsNan<IssmDouble>(newthickness[i])) _error2_("NaN found in solution vector");
    17481748                /*Constrain thickness to be at least 1m*/
    17491749                if(newthickness[i]<minthickness) newthickness[i]=minthickness;
     
    17781778                                newbed[i]=oldbed[i]-rho_ice/rho_water*(newthickness[i]-oldthickness[i]); //bed = oldbed + di * dH
    17791779                        }
    1780                         else _error_("Hydrostatic adjustment %i (%s) not supported yet",hydroadjustment,EnumToStringx(hydroadjustment));
     1780                        else _error2_("Hydrostatic adjustment " << hydroadjustment << " (" << EnumToStringx(hydroadjustment) << ") not supported yet");
    17811781                }
    17821782        }
     
    17981798       
    17991799        /*Free ressources:*/
    1800         xfree((void**)&doflist);
    1801 }
    1802 /*}}}*/
    1803 /*FUNCTION Penta::InputUpdateFromSolutionOneDof{{{1*/
    1804 void  Penta::InputUpdateFromSolutionOneDof(double* solution,int enum_type){
     1800        xDelete<int>(doflist);
     1801}
     1802/*}}}*/
     1803/*FUNCTION Penta::InputUpdateFromSolutionOneDof{{{*/
     1804void  Penta::InputUpdateFromSolutionOneDof(IssmDouble* solution,int enum_type){
    18051805
    18061806        const int numdof = NDOF1*NUMVERTICES;
    18071807
    1808         double values[numdof];
     1808        IssmDouble values[numdof];
    18091809        int*   doflist=NULL;
    18101810
     
    18151815        for(int i=0;i<numdof;i++){
    18161816                values[i]=solution[doflist[i]];
    1817                 if(isnan(values[i])) _error_("NaN found in solution vector");
     1817                if(xIsNan<IssmDouble>(values[i])) _error2_("NaN found in solution vector");
    18181818        }
    18191819
     
    18221822       
    18231823        /*Free ressources:*/
    1824         xfree((void**)&doflist);
    1825 }
    1826 /*}}}*/
    1827 /*FUNCTION Penta::InputUpdateFromSolutionOneDofCollpased{{{1*/
    1828 void  Penta::InputUpdateFromSolutionOneDofCollapsed(double* solution,int enum_type){
     1824        xDelete<int>(doflist);
     1825}
     1826/*}}}*/
     1827/*FUNCTION Penta::InputUpdateFromSolutionOneDofCollpased{{{*/
     1828void  Penta::InputUpdateFromSolutionOneDofCollapsed(IssmDouble* solution,int enum_type){
    18291829
    18301830        const int  numdof   = NDOF1*NUMVERTICES;
    18311831        const int  numdof2d = NDOF1*NUMVERTICES2D;
    18321832
    1833         double  values[numdof];
     1833        IssmDouble  values[numdof];
    18341834        int*    doflist = NULL;
    18351835        Penta  *penta   = NULL;
     
    18451845                values[i]         =solution[doflist[i]];
    18461846                values[i+numdof2d]=values[i];
    1847                 if(isnan(values[i])) _error_("NaN found in solution vector");
     1847                if(xIsNan<IssmDouble>(values[i])) _error2_("NaN found in solution vector");
    18481848        }
    18491849
     
    18621862       
    18631863        /*Free ressources:*/
    1864         xfree((void**)&doflist);
    1865 }
    1866 /*}}}*/
    1867 /*FUNCTION Penta::InputUpdateFromVector(double* vector, int name, int type);{{{1*/
    1868 void  Penta::InputUpdateFromVector(double* vector, int name, int type){
     1864        xDelete<int>(doflist);
     1865}
     1866/*}}}*/
     1867/*FUNCTION Penta::InputUpdateFromVector(IssmDouble* vector, int name, int type);{{{*/
     1868void  Penta::InputUpdateFromVector(IssmDouble* vector, int name, int type){
    18691869
    18701870        /*Check that name is an element input*/
     
    18781878
    18791879                        /*New PentaVertexInpu*/
    1880                         double values[6];
     1880                        IssmDouble values[6];
    18811881
    18821882                        /*Get values on the 6 vertices*/
     
    18911891                default:
    18921892
    1893                         _error_("type %i (%s) not implemented yet",type,EnumToStringx(type));
    1894         }
    1895 }
    1896 /*}}}*/
    1897 /*FUNCTION Penta::InputUpdateFromVector(int* vector, int name, int type);{{{1*/
     1893                        _error2_("type " << type << " (" << EnumToStringx(type) << ") not implemented yet");
     1894        }
     1895}
     1896/*}}}*/
     1897/*FUNCTION Penta::InputUpdateFromVector(int* vector, int name, int type);{{{*/
    18981898void  Penta::InputUpdateFromVector(int* vector, int name, int type){
    1899         _error_(" not supported yet!");
    1900 }
    1901 /*}}}*/
    1902 /*FUNCTION Penta::InputUpdateFromVector(bool* vector, int name, int type);{{{1*/
     1899        _error2_("not supported yet!");
     1900}
     1901/*}}}*/
     1902/*FUNCTION Penta::InputUpdateFromVector(bool* vector, int name, int type);{{{*/
    19031903void  Penta::InputUpdateFromVector(bool* vector, int name, int type){
    1904         _error_(" not supported yet!");
    1905 }
    1906 /*}}}*/
    1907 /*FUNCTION Penta::IsOnBed{{{1*/
     1904        _error2_("not supported yet!");
     1905}
     1906/*}}}*/
     1907/*FUNCTION Penta::IsOnBed{{{*/
    19081908bool Penta::IsOnBed(void){
    19091909
     
    19131913}
    19141914/*}}}*/
    1915 /*FUNCTION Penta::IsInput{{{1*/
     1915/*FUNCTION Penta::IsInput{{{*/
    19161916bool Penta::IsInput(int name){
    19171917        if (
     
    19571957}
    19581958/*}}}*/
    1959 /*FUNCTION Penta::IsFloating{{{1*/
     1959/*FUNCTION Penta::IsFloating{{{*/
    19601960bool   Penta::IsFloating(){
    19611961
     
    19651965}
    19661966/*}}}*/
    1967 /*FUNCTION Penta::IsNodeOnShelf {{{1*/
     1967/*FUNCTION Penta::IsNodeOnShelf {{{*/
    19681968bool   Penta::IsNodeOnShelf(){
    19691969
     
    19801980}
    19811981/*}}}*/
    1982 /*FUNCTION Penta::IsNodeOnShelfFromFlags {{{1*/
    1983 bool   Penta::IsNodeOnShelfFromFlags(double* flags){
     1982/*FUNCTION Penta::IsNodeOnShelfFromFlags {{{*/
     1983bool   Penta::IsNodeOnShelfFromFlags(IssmDouble* flags){
    19841984
    19851985        int  i;
     
    19951995}
    19961996/*}}}*/
    1997 /*FUNCTION Penta::IsOnSurface{{{1*/
     1997/*FUNCTION Penta::IsOnSurface{{{*/
    19981998bool Penta::IsOnSurface(void){
    19991999
     
    20032003}
    20042004/*}}}*/
    2005 /*FUNCTION Penta::IsOnWater {{{1*/
     2005/*FUNCTION Penta::IsOnWater {{{*/
    20062006bool   Penta::IsOnWater(){
    20072007
     
    20122012/*}}}*/
    20132013/*FUNCTION Penta::ListResultsInfo{{{*/
    2014 void Penta::ListResultsInfo(int** in_resultsenums,int** in_resultssizes,double** in_resultstimes,int** in_resultssteps,int* in_num_results){
     2014void Penta::ListResultsInfo(int** in_resultsenums,int** in_resultssizes,IssmDouble** in_resultstimes,int** in_resultssteps,int* in_num_results){
    20152015
    20162016        /*Intermediaries*/
     
    20192019        int     *resultsenums   = NULL;
    20202020        int     *resultssizes   = NULL;
    2021         double  *resultstimes   = NULL;
     2021        IssmDouble  *resultstimes   = NULL;
    20222022        int     *resultssteps   = NULL;
    20232023
     
    20342034
    20352035                /*Allocate output*/
    2036                 resultsenums=(int*)xmalloc(numberofresults*sizeof(int));
    2037                 resultssizes=(int*)xmalloc(numberofresults*sizeof(int));
    2038                 resultstimes=(double*)xmalloc(numberofresults*sizeof(double));
    2039                 resultssteps=(int*)xmalloc(numberofresults*sizeof(int));
     2036                resultsenums=xNew<int>(numberofresults);
     2037                resultssizes=xNew<int>(numberofresults);
     2038                resultstimes=xNew<IssmDouble>(numberofresults);
     2039                resultssteps=xNew<int>(numberofresults);
    20402040
    20412041                /*populate enums*/
     
    20622062
    20632063}/*}}}*/
    2064 /*FUNCTION Penta::MigrateGroundingLine{{{1*/
    2065 void  Penta::MigrateGroundingLine(double* old_floating_ice,double* sheet_ungrounding){
     2064/*FUNCTION Penta::MigrateGroundingLine{{{*/
     2065void  Penta::MigrateGroundingLine(IssmDouble* old_floating_ice,IssmDouble* sheet_ungrounding){
    20662066
    20672067        int     i,migration_style,unground;
    20682068        bool    elementonshelf = false;
    2069         double  bed_hydro,yts,gl_melting_rate;
    2070         double  rho_water,rho_ice,density;
    2071         double  melting[NUMVERTICES];
    2072         double  h[NUMVERTICES],s[NUMVERTICES],b[NUMVERTICES],ba[NUMVERTICES];
     2069        IssmDouble  bed_hydro,yts,gl_melting_rate;
     2070        IssmDouble  rho_water,rho_ice,density;
     2071        IssmDouble  melting[NUMVERTICES];
     2072        IssmDouble  h[NUMVERTICES],s[NUMVERTICES],b[NUMVERTICES],ba[NUMVERTICES];
    20732073
    20742074        if(!IsOnBed()) return;
     
    21452145}
    21462146/*}}}*/
    2147 /*FUNCTION Penta::MinEdgeLength{{{1*/
    2148 double Penta::MinEdgeLength(double xyz_list[6][3]){
     2147/*FUNCTION Penta::MinEdgeLength{{{*/
     2148IssmDouble Penta::MinEdgeLength(IssmDouble xyz_list[6][3]){
    21492149        /*Return the minimum lenght of the nine egdes of the penta*/
    21502150
    21512151        int    i,node0,node1;
    21522152        int    edges[9][2]={{0,1},{0,2},{1,2},{3,4},{3,5},{4,5},{0,3},{1,4},{2,5}}; //list of the nine edges
    2153         double length;
    2154         double minlength=-1;
     2153        IssmDouble length;
     2154        IssmDouble minlength=-1;
    21552155
    21562156        for(i=0;i<9;i++){
     
    21672167}
    21682168/*}}}*/
    2169 /*FUNCTION Penta::MyRank {{{1*/
     2169/*FUNCTION Penta::MyRank {{{*/
    21702170int    Penta::MyRank(void){
    21712171        extern int my_rank;
     
    21732173}
    21742174/*}}}*/
    2175 /*FUNCTION Penta::NodalValue {{{1*/
    2176 int    Penta::NodalValue(double* pvalue, int index, int natureofdataenum,bool process_units){
     2175/*FUNCTION Penta::NodalValue {{{*/
     2176int    Penta::NodalValue(IssmDouble* pvalue, int index, int natureofdataenum,bool process_units){
    21772177
    21782178        int i;
    21792179        int found=0;
    2180         double value;
     2180        IssmDouble value;
    21812181        Input* data=NULL;
    21822182        GaussPenta* gauss=NULL;
     
    22042204}
    22052205/*}}}*/
    2206 /*FUNCTION Penta::PatchFill{{{1*/
     2206/*FUNCTION Penta::PatchFill{{{*/
    22072207void  Penta::PatchFill(int* pcount, Patch* patch){
    22082208
     
    22312231        *pcount=count;
    22322232}/*}}}*/
    2233 /*FUNCTION Penta::PatchSize{{{1*/
     2233/*FUNCTION Penta::PatchSize{{{*/
    22342234void  Penta::PatchSize(int* pnumrows, int* pnumvertices,int* pnumnodes){
    22352235
     
    22552255}
    22562256/*}}}*/
    2257 /*FUNCTION Penta::PositiveDegreeDay{{{1*/
    2258 void  Penta::PositiveDegreeDay(double* pdds,double* pds,double signorm){
    2259 
    2260    double agd[NUMVERTICES];             // surface mass balance
    2261    double monthlytemperatures[NUMVERTICES][12],monthlyprec[NUMVERTICES][12];
    2262    double h[NUMVERTICES],s[NUMVERTICES]; // ,b
    2263    double rho_water,rho_ice;
     2257/*FUNCTION Penta::PositiveDegreeDay{{{*/
     2258void  Penta::PositiveDegreeDay(IssmDouble* pdds,IssmDouble* pds,IssmDouble signorm){
     2259
     2260   IssmDouble agd[NUMVERTICES];             // surface mass balance
     2261   IssmDouble monthlytemperatures[NUMVERTICES][12],monthlyprec[NUMVERTICES][12];
     2262   IssmDouble h[NUMVERTICES],s[NUMVERTICES]; // ,b
     2263   IssmDouble rho_water,rho_ice;
    22642264
    22652265   /*Recover monthly temperatures and precipitation*/
     
    22672267   Input*     input2=inputs->GetInput(SurfaceforcingsPrecipitationEnum); _assert_(input2);
    22682268   GaussPenta* gauss=new GaussPenta();
    2269    double time,yts;
     2269   IssmDouble time,yts;
    22702270   this->parameters->FindParam(&time,TimeEnum);
    22712271   this->parameters->FindParam(&yts,ConstantsYtsEnum);
     
    22992299}
    23002300/*}}}*/
    2301 /*FUNCTION Penta::PotentialSheetUngrounding{{{1*/
     2301/*FUNCTION Penta::PotentialSheetUngrounding{{{*/
    23022302void  Penta::PotentialSheetUngrounding(Vector* potential_sheet_ungrounding){
    23032303
    23042304        int     i;
    2305         double  h[NUMVERTICES],ba[NUMVERTICES];
    2306         double  bed_hydro;
    2307         double  rho_water,rho_ice,density;
     2305        IssmDouble  h[NUMVERTICES],ba[NUMVERTICES];
     2306        IssmDouble  bed_hydro;
     2307        IssmDouble  rho_water,rho_ice,density;
    23082308        bool    elementonshelf = false;
    23092309
     
    23282328}
    23292329/*}}}*/
    2330 /*FUNCTION Penta::ProcessResultsUnits{{{1*/
     2330/*FUNCTION Penta::ProcessResultsUnits{{{*/
    23312331void  Penta::ProcessResultsUnits(void){
    23322332
     
    23392339}
    23402340/*}}}*/
    2341 /*FUNCTION Penta::ReduceMatrixStokes {{{1*/
    2342 void Penta::ReduceMatrixStokes(double* Ke_reduced, double* Ke_temp){
     2341/*FUNCTION Penta::ReduceMatrixStokes {{{*/
     2342void Penta::ReduceMatrixStokes(IssmDouble* Ke_reduced, IssmDouble* Ke_temp){
    23432343
    23442344        int    i,j;
    2345         double Kii[24][24];
    2346         double Kib[24][3];
    2347         double Kbb[3][3];
    2348         double Kbi[3][24];
    2349         double Kbbinv[3][3];
    2350         double Kright[24][24];
     2345        IssmDouble Kii[24][24];
     2346        IssmDouble Kib[24][3];
     2347        IssmDouble Kbb[3][3];
     2348        IssmDouble Kbi[3][24];
     2349        IssmDouble Kbbinv[3][3];
     2350        IssmDouble Kright[24][24];
    23512351
    23522352        /*Create the four matrices used for reduction */
     
    23812381}
    23822382/*}}}*/
    2383 /*FUNCTION Penta::ReduceVectorStokes {{{1*/
    2384 void Penta::ReduceVectorStokes(double* Pe_reduced, double* Ke_temp, double* Pe_temp){
     2383/*FUNCTION Penta::ReduceVectorStokes {{{*/
     2384void Penta::ReduceVectorStokes(IssmDouble* Pe_reduced, IssmDouble* Ke_temp, IssmDouble* Pe_temp){
    23852385
    23862386        int    i,j;
    2387         double Pi[24];
    2388         double Pb[3];
    2389         double Kbb[3][3];
    2390         double Kib[24][3];
    2391         double Kbbinv[3][3];
    2392         double Pright[24];
     2387        IssmDouble Pi[24];
     2388        IssmDouble Pb[3];
     2389        IssmDouble Kbb[3][3];
     2390        IssmDouble Kib[24][3];
     2391        IssmDouble Kbbinv[3][3];
     2392        IssmDouble Pright[24];
    23932393
    23942394        /*Create the four matrices used for reduction */
     
    24162416}
    24172417/*}}}*/
    2418 /*FUNCTION Penta::RequestedOutput{{{1*/
    2419 void Penta::RequestedOutput(int output_enum,int step,double time){
     2418/*FUNCTION Penta::RequestedOutput{{{*/
     2419void Penta::RequestedOutput(int output_enum,int step,IssmDouble time){
    24202420                       
    24212421        if(IsInput(output_enum)){
     
    24672467}
    24682468/*}}}*/
    2469 /*FUNCTION Penta::ResetCoordinateSystem{{{1*/
     2469/*FUNCTION Penta::ResetCoordinateSystem{{{*/
    24702470void  Penta::ResetCoordinateSystem(void){
    24712471
    24722472        int    approximation;
    2473         double slopex[NUMVERTICES];
    2474         double slopey[NUMVERTICES];
    2475         double xz_plane[6];
     2473        IssmDouble slopex[NUMVERTICES];
     2474        IssmDouble slopey[NUMVERTICES];
     2475        IssmDouble xz_plane[6];
    24762476
    24772477        /*For Stokes only: we want the CS to be tangential to the bedrock*/
     
    24952495}
    24962496/*}}}*/
    2497 /*FUNCTION Penta::SetClone {{{1*/
     2497/*FUNCTION Penta::SetClone {{{*/
    24982498void  Penta::SetClone(int* minranks){
    24992499
    2500         _error_("not implemented yet");
    2501 }
    2502 /*}}}1*/
    2503 /*FUNCTION Penta::SetCurrentConfiguration {{{1*/
     2500        _error2_("not implemented yet");
     2501}
     2502/*}}}*/
     2503/*FUNCTION Penta::SetCurrentConfiguration {{{*/
    25042504void  Penta::SetCurrentConfiguration(Elements* elementsin, Loads* loadsin, DataSet* nodesin, Materials* materialsin, Parameters* parametersin){
    25052505
     
    25172517}
    25182518/*}}}*/
    2519 /*FUNCTION Penta::SpawnTria {{{1*/
     2519/*FUNCTION Penta::SpawnTria {{{*/
    25202520Tria*  Penta::SpawnTria(int g0, int g1, int g2){
    25212521
     
    25602560}
    25612561/*}}}*/
    2562 /*FUNCTION Penta::SurfaceArea {{{1*/
    2563 double Penta::SurfaceArea(void){
     2562/*FUNCTION Penta::SmbGradients{{{*/
     2563void Penta::SmbGradients(void){
     2564
     2565        int i;
     2566
     2567        // input
     2568   IssmDouble h[NUMVERTICES];                                   // ice thickness (m)           
     2569        IssmDouble s[NUMVERTICES];                                      // surface elevation (m)
     2570        IssmDouble a_pos[NUMVERTICES];                          // Hs-SMB relation parameter
     2571        IssmDouble b_pos[NUMVERTICES];                          // Hs-SMB relation parameter
     2572        IssmDouble a_neg[NUMVERTICES];                          // Hs-SMB relation parameter
     2573        IssmDouble b_neg[NUMVERTICES];                          // Hs-SMB relation paremeter
     2574        IssmDouble Hc[NUMVERTICES];                                     // elevation of transition between accumulation regime and ablation regime
     2575        IssmDouble smb_pos_max[NUMVERTICES];            // maximum SMB value in the accumulation regime
     2576        IssmDouble smb_pos_min[NUMVERTICES];            // minimum SMB value in the accumulation regime
     2577   IssmDouble rho_water;                   // density of fresh water
     2578        IssmDouble rho_ice;                     // density of ice
     2579
     2580        // output
     2581        IssmDouble smb[NUMVERTICES];                                    // surface mass balance (m/yr ice)
     2582
     2583        /*Recover SmbGradients*/
     2584        GetInputListOnVertices(&Hc[0],SurfaceforcingsHcEnum);
     2585        GetInputListOnVertices(&smb_pos_max[0],SurfaceforcingsSmbPosMaxEnum);
     2586        GetInputListOnVertices(&smb_pos_min[0],SurfaceforcingsSmbPosMinEnum);
     2587        GetInputListOnVertices(&a_pos[0],SurfaceforcingsAPosEnum);
     2588        GetInputListOnVertices(&b_pos[0],SurfaceforcingsBPosEnum);
     2589        GetInputListOnVertices(&a_neg[0],SurfaceforcingsANegEnum);
     2590        GetInputListOnVertices(&b_neg[0],SurfaceforcingsBNegEnum);
     2591       
     2592   /*Recover surface elevatio at vertices: */
     2593        GetInputListOnVertices(&h[0],ThicknessEnum);
     2594        GetInputListOnVertices(&s[0],SurfaceEnum);
     2595
     2596   /*Get material parameters :*/
     2597   rho_ice=matpar->GetRhoIce();
     2598   rho_water=matpar->GetRhoFreshwater();
     2599                       
     2600   // loop over all vertices
     2601   for(i=0;i<NUMVERTICES;i++){
     2602     if(s[i]>Hc[i]){
     2603            smb[i]=a_pos[i]+b_pos[i]*s[i];
     2604                 if(smb[i]>smb_pos_max[i]){smb[i]=smb_pos_max[i];}
     2605                 if(smb[i]<smb_pos_min[i]){smb[i]=smb_pos_min[i];}
     2606          }
     2607          else{
     2608            smb[i]=a_neg[i]+b_neg[i]*s[i];
     2609          }
     2610          smb[i]=smb[i]/rho_ice;      // SMB in m/y ice         
     2611         
     2612        }  //end of the loop over the vertices
     2613          /*Update inputs*/
     2614          this->inputs->AddInput(new PentaP1Input(SurfaceforcingsMassBalanceEnum,&smb[0]));
     2615}
     2616/*}}}*/
     2617/*FUNCTION Penta::SurfaceArea {{{*/
     2618IssmDouble Penta::SurfaceArea(void){
    25642619
    25652620        int    approximation;
    2566         double S;
     2621        IssmDouble S;
    25672622        Tria*  tria=NULL;
    25682623
     
    25972652}
    25982653/*}}}*/
    2599 /*FUNCTION Penta::SurfaceNormal {{{1*/
    2600 void Penta::SurfaceNormal(double* surface_normal, double xyz_list[3][3]){
     2654/*FUNCTION Penta::SurfaceNormal {{{*/
     2655void Penta::SurfaceNormal(IssmDouble* surface_normal, IssmDouble xyz_list[3][3]){
    26012656
    26022657        int    i;
    2603         double v13[3],v23[3];
    2604         double normal[3];
    2605         double normal_norm;
     2658        IssmDouble v13[3],v23[3];
     2659        IssmDouble normal[3];
     2660        IssmDouble normal_norm;
    26062661
    26072662        for (i=0;i<3;i++){
     
    26212676}
    26222677/*}}}*/
    2623 /*FUNCTION Penta::TimeAdapt{{{1*/
    2624 double  Penta::TimeAdapt(void){
     2678/*FUNCTION Penta::TimeAdapt{{{*/
     2679IssmDouble  Penta::TimeAdapt(void){
    26252680
    26262681        int    i;
    2627         double C,dx,dy,dz,dt;
    2628         double maxabsvx,maxabsvy,maxabsvz;
    2629         double maxx,minx,maxy,miny,maxz,minz;
    2630         double xyz_list[NUMVERTICES][3];
     2682        IssmDouble C,dx,dy,dz,dt;
     2683        IssmDouble maxabsvx,maxabsvy,maxabsvz;
     2684        IssmDouble maxx,minx,maxy,miny,maxz,minz;
     2685        IssmDouble xyz_list[NUMVERTICES][3];
    26312686
    26322687        /*get CFL coefficient:*/
     
    26642719
    26652720        return dt;
    2666 }
    2667 /*FUNCTION Penta::Update(int index,IoModel* iomodel,int analysis_counter,int analysis_type) {{{1*/
     2721}/*}}}*/
     2722/*FUNCTION Penta::Update(int index,IoModel* iomodel,int analysis_counter,int analysis_type) {{{*/
    26682723void Penta::Update(int index,IoModel* iomodel,int analysis_counter,int analysis_type){
    26692724
     
    26732728        int     penta_node_ids[6];
    26742729        int     penta_vertex_ids[6];
    2675         double  nodeinputs[6];
    2676         double  yts;
     2730        IssmDouble  nodeinputs[6];
     2731        IssmDouble  yts;
    26772732        int     stabilization;
    26782733        bool    dakota_analysis;
    26792734        bool    isstokes;
    2680         double  beta,heatcapacity,referencetemperature,meltingpoint,latentheat;
     2735        IssmDouble  beta,heatcapacity,referencetemperature,meltingpoint,latentheat;
    26812736
    26822737        /*Fetch parameters: */
     
    26922747
    26932748        /*Checks if debuging*/
    2694         /*{{{2*/
     2749        /*{{{*/
    26952750        _assert_(iomodel->Data(MeshElementsEnum));
    26962751        /*}}}*/
     
    28102865                                this->inputs->AddInput(new PentaP1Input(EnthalpyEnum,nodeinputs));
    28112866                        }
    2812                         else _error_("temperature and waterfraction required for the enthalpy solution");
     2867                        else _error2_("temperature and waterfraction required for the enthalpy solution");
    28132868                        break;
    28142869
     
    28192874}
    28202875/*}}}*/
    2821 /*FUNCTION Penta::UpdatePotentialSheetUngrounding{{{1*/
    2822 int Penta::UpdatePotentialSheetUngrounding(double* vertices_potentially_ungrounding,Vector* vec_nodes_on_iceshelf,double* nodes_on_iceshelf){
     2876/*FUNCTION Penta::UpdatePotentialSheetUngrounding{{{*/
     2877int Penta::UpdatePotentialSheetUngrounding(IssmDouble* vertices_potentially_ungrounding,Vector* vec_nodes_on_iceshelf,IssmDouble* nodes_on_iceshelf){
    28232878
    28242879        int i;
     
    28392894}
    28402895/*}}}*/
    2841 /*FUNCTION Penta::ViscousHeatingCreateInput {{{1*/
     2896/*FUNCTION Penta::ViscousHeatingCreateInput {{{*/
    28422897void Penta::ViscousHeatingCreateInput(void){
    28432898
     
    28472902        /*Intermediaries*/
    28482903        int    iv;
    2849         double phi;
    2850         double viscosity;
    2851         double xyz_list[NUMVERTICES][3];
    2852         double epsilon[6];
    2853         double     viscousheating[NUMVERTICES]={0,0,0,0,0,0};
    2854         double     thickness;
     2904        IssmDouble phi;
     2905        IssmDouble viscosity;
     2906        IssmDouble xyz_list[NUMVERTICES][3];
     2907        IssmDouble epsilon[6];
     2908        IssmDouble     viscousheating[NUMVERTICES]={0,0,0,0,0,0};
     2909        IssmDouble     thickness;
    28552910        GaussPenta *gauss=NULL;
    28562911
     
    28872942}
    28882943/*}}}*/
    2889 /*FUNCTION Penta::SmearFunction {{{1*/
    2890 void  Penta::SmearFunction(Vector* smearedvector,double (*WeightFunction)(double distance,double radius),double radius){
    2891         _error_("not implemented yet");
    2892 }
    2893 /*}}}1*/
     2944/*FUNCTION Penta::SmearFunction {{{*/
     2945void  Penta::SmearFunction(Vector* smearedvector,IssmDouble (*WeightFunction)(IssmDouble distance,IssmDouble radius),IssmDouble radius){
     2946        _error2_("not implemented yet");
     2947}
     2948/*}}}*/
    28942949
    28952950#ifdef _HAVE_RESPONSES_
    2896 /*FUNCTION Penta::IceVolume {{{1*/
    2897 double Penta::IceVolume(void){
     2951/*FUNCTION Penta::IceVolume {{{*/
     2952IssmDouble Penta::IceVolume(void){
    28982953
    28992954        /*The volume of a troncated prism is base * 1/3 sum(length of edges)*/
    2900         double base,height;
    2901         double xyz_list[NUMVERTICES][3];
     2955        IssmDouble base,height;
     2956        IssmDouble xyz_list[NUMVERTICES][3];
    29022957
    29032958        if(IsOnWater())return 0;
     
    29172972}
    29182973/*}}}*/
    2919 /*FUNCTION Penta::MinVel{{{1*/
    2920 void  Penta::MinVel(double* pminvel, bool process_units){
     2974/*FUNCTION Penta::MinVel{{{*/
     2975void  Penta::MinVel(IssmDouble* pminvel, bool process_units){
    29212976
    29222977        /*Get minimum:*/
    2923         double minvel=this->inputs->Min(VelEnum);
     2978        IssmDouble minvel=this->inputs->Min(VelEnum);
    29242979
    29252980        /*process units if requested: */
     
    29302985}
    29312986/*}}}*/
    2932 /*FUNCTION Penta::MinVx{{{1*/
    2933 void  Penta::MinVx(double* pminvx, bool process_units){
     2987/*FUNCTION Penta::MinVx{{{*/
     2988void  Penta::MinVx(IssmDouble* pminvx, bool process_units){
    29342989
    29352990        /*Get minimum:*/
    2936         double minvx=this->inputs->Min(VxEnum);
     2991        IssmDouble minvx=this->inputs->Min(VxEnum);
    29372992
    29382993        /*process units if requested: */
     
    29432998}
    29442999/*}}}*/
    2945 /*FUNCTION Penta::MinVy{{{1*/
    2946 void  Penta::MinVy(double* pminvy, bool process_units){
     3000/*FUNCTION Penta::MinVy{{{*/
     3001void  Penta::MinVy(IssmDouble* pminvy, bool process_units){
    29473002
    29483003        /*Get minimum:*/
    2949         double minvy=this->inputs->Min(VyEnum);
     3004        IssmDouble minvy=this->inputs->Min(VyEnum);
    29503005
    29513006        /*process units if requested: */
     
    29563011}
    29573012/*}}}*/
    2958 /*FUNCTION Penta::MinVz{{{1*/
    2959 void  Penta::MinVz(double* pminvz, bool process_units){
     3013/*FUNCTION Penta::MinVz{{{*/
     3014void  Penta::MinVz(IssmDouble* pminvz, bool process_units){
    29603015
    29613016        /*Get minimum:*/
    2962         double minvz=this->inputs->Min(VzEnum);
     3017        IssmDouble minvz=this->inputs->Min(VzEnum);
    29633018
    29643019        /*process units if requested: */
     
    29693024}
    29703025/*}}}*/
    2971 /*FUNCTION Penta::MassFlux {{{1*/
    2972 double Penta::MassFlux( double* segment,bool process_units){
    2973 
    2974         double mass_flux=0;
     3026/*FUNCTION Penta::MassFlux {{{*/
     3027IssmDouble Penta::MassFlux( IssmDouble* segment,bool process_units){
     3028
     3029        IssmDouble mass_flux=0;
    29753030
    29763031        if(!IsOnBed()) return mass_flux;
     
    29933048}
    29943049/*}}}*/
    2995 /*FUNCTION Penta::MaxAbsVx{{{1*/
    2996 void  Penta::MaxAbsVx(double* pmaxabsvx, bool process_units){
     3050/*FUNCTION Penta::MaxAbsVx{{{*/
     3051void  Penta::MaxAbsVx(IssmDouble* pmaxabsvx, bool process_units){
    29973052
    29983053        /*Get maximum:*/
    2999         double maxabsvx=this->inputs->MaxAbs(VxEnum);
     3054        IssmDouble maxabsvx=this->inputs->MaxAbs(VxEnum);
    30003055
    30013056        /*process units if requested: */
     
    30063061}
    30073062/*}}}*/
    3008 /*FUNCTION Penta::MaxAbsVy{{{1*/
    3009 void  Penta::MaxAbsVy(double* pmaxabsvy, bool process_units){
     3063/*FUNCTION Penta::MaxAbsVy{{{*/
     3064void  Penta::MaxAbsVy(IssmDouble* pmaxabsvy, bool process_units){
    30103065
    30113066        /*Get maximum:*/
    3012         double maxabsvy=this->inputs->MaxAbs(VyEnum);
     3067        IssmDouble maxabsvy=this->inputs->MaxAbs(VyEnum);
    30133068
    30143069        /*process units if requested: */
     
    30193074}
    30203075/*}}}*/
    3021 /*FUNCTION Penta::MaxAbsVz{{{1*/
    3022 void  Penta::MaxAbsVz(double* pmaxabsvz, bool process_units){
     3076/*FUNCTION Penta::MaxAbsVz{{{*/
     3077void  Penta::MaxAbsVz(IssmDouble* pmaxabsvz, bool process_units){
    30233078
    30243079        /*Get maximum:*/
    3025         double maxabsvz=this->inputs->MaxAbs(VzEnum);
     3080        IssmDouble maxabsvz=this->inputs->MaxAbs(VzEnum);
    30263081
    30273082        /*process units if requested: */
     
    30323087}
    30333088/*}}}*/
    3034 /*FUNCTION Penta::MaxVel{{{1*/
    3035 void  Penta::MaxVel(double* pmaxvel, bool process_units){
     3089/*FUNCTION Penta::MaxVel{{{*/
     3090void  Penta::MaxVel(IssmDouble* pmaxvel, bool process_units){
    30363091
    30373092        /*Get maximum:*/
    3038         double maxvel=this->inputs->Max(VelEnum);
     3093        IssmDouble maxvel=this->inputs->Max(VelEnum);
    30393094
    30403095        /*process units if requested: */
     
    30463101}
    30473102/*}}}*/
    3048 /*FUNCTION Penta::MaxVx{{{1*/
    3049 void  Penta::MaxVx(double* pmaxvx, bool process_units){
     3103/*FUNCTION Penta::MaxVx{{{*/
     3104void  Penta::MaxVx(IssmDouble* pmaxvx, bool process_units){
    30503105
    30513106        /*Get maximum:*/
    3052         double maxvx=this->inputs->Max(VxEnum);
     3107        IssmDouble maxvx=this->inputs->Max(VxEnum);
    30533108
    30543109        /*process units if requested: */
     
    30593114}
    30603115/*}}}*/
    3061 /*FUNCTION Penta::MaxVy{{{1*/
    3062 void  Penta::MaxVy(double* pmaxvy, bool process_units){
     3116/*FUNCTION Penta::MaxVy{{{*/
     3117void  Penta::MaxVy(IssmDouble* pmaxvy, bool process_units){
    30633118
    30643119        /*Get maximum:*/
    3065         double maxvy=this->inputs->Max(VyEnum);
     3120        IssmDouble maxvy=this->inputs->Max(VyEnum);
    30663121
    30673122        /*process units if requested: */
     
    30723127}
    30733128/*}}}*/
    3074 /*FUNCTION Penta::MaxVz{{{1*/
    3075 void  Penta::MaxVz(double* pmaxvz, bool process_units){
     3129/*FUNCTION Penta::MaxVz{{{*/
     3130void  Penta::MaxVz(IssmDouble* pmaxvz, bool process_units){
    30763131
    30773132        /*Get maximum:*/
    3078         double maxvz=this->inputs->Max(VzEnum);
     3133        IssmDouble maxvz=this->inputs->Max(VzEnum);
    30793134
    30803135        /*process units if requested: */
     
    30853140}
    30863141/*}}}*/
    3087 /*FUNCTION Penta::ElementResponse{{{1*/
    3088 void Penta::ElementResponse(double* presponse,int response_enum,bool process_units){
     3142/*FUNCTION Penta::ElementResponse{{{*/
     3143void Penta::ElementResponse(IssmDouble* presponse,int response_enum,bool process_units){
    30893144
    30903145        switch(response_enum){
     
    30953150
    30963151                        /*Get input:*/
    3097                         double vel;
     3152                        IssmDouble vel;
    30983153                        Input* vel_input;
    30993154
     
    31073162                        *presponse=vel;
    31083163                default: 
    3109                         _error_("Response type %s not supported yet!",EnumToStringx(response_enum));
     3164                        _error2_("Response type " << EnumToStringx(response_enum) << " not supported yet!");
    31103165        }
    31113166
     
    31153170
    31163171#ifdef _HAVE_THERMAL_
    3117 /*FUNCTION Penta::CreateKMatrixEnthalpy {{{1*/
     3172/*FUNCTION Penta::CreateKMatrixEnthalpy {{{*/
    31183173ElementMatrix* Penta::CreateKMatrixEnthalpy(void){
    31193174       
     
    31293184}
    31303185/*}}}*/
    3131 /*FUNCTION Penta::CreateKMatrixEnthalpyVolume {{{1*/
     3186/*FUNCTION Penta::CreateKMatrixEnthalpyVolume {{{*/
    31323187ElementMatrix* Penta::CreateKMatrixEnthalpyVolume(void){
    31333188
     
    31383193        int        stabilization;
    31393194        int        i,j,ig,found=0;
    3140         double     Jdet,u,v,w,um,vm,wm;
    3141         double     h,hx,hy,hz,vx,vy,vz,vel;
    3142         double     gravity,rho_ice,rho_water;
    3143         double     epsvel=2.220446049250313e-16;
    3144         double     heatcapacity,thermalconductivity,dt;
    3145         double     pressure,enthalpy;
    3146         double     latentheat,kappa;
    3147         double     tau_parameter,diameter;
    3148         double     xyz_list[NUMVERTICES][3];
    3149         double     B_conduct[3][numdof];
    3150         double     B_advec[3][numdof];
    3151         double     Bprime_advec[3][numdof];
    3152         double     L[numdof];
    3153         double     dbasis[3][6];
    3154         double     D_scalar_conduct,D_scalar_advec;
    3155         double     D_scalar_trans,D_scalar_stab;
    3156         double     D[3][3];
    3157         double     K[3][3]={0.0};
     3195        IssmDouble     Jdet,u,v,w,um,vm,wm;
     3196        IssmDouble     h,hx,hy,hz,vx,vy,vz,vel;
     3197        IssmDouble     gravity,rho_ice,rho_water;
     3198        IssmDouble     epsvel=2.220446049250313e-16;
     3199        IssmDouble     heatcapacity,thermalconductivity,dt;
     3200        IssmDouble     pressure,enthalpy;
     3201        IssmDouble     latentheat,kappa;
     3202        IssmDouble     tau_parameter,diameter;
     3203        IssmDouble     xyz_list[NUMVERTICES][3];
     3204        IssmDouble     B_conduct[3][numdof];
     3205        IssmDouble     B_advec[3][numdof];
     3206        IssmDouble     Bprime_advec[3][numdof];
     3207        IssmDouble     L[numdof];
     3208        IssmDouble     dbasis[3][6];
     3209        IssmDouble     D_scalar_conduct,D_scalar_advec;
     3210        IssmDouble     D_scalar_trans,D_scalar_stab;
     3211        IssmDouble     D[3][3];
     3212        IssmDouble     K[3][3]={0.0};
    31583213        Tria*      tria=NULL;
    31593214        GaussPenta *gauss=NULL;
     
    32863341}
    32873342/*}}}*/
    3288 /*FUNCTION Penta::CreateKMatrixEnthalpyShelf {{{1*/
     3343/*FUNCTION Penta::CreateKMatrixEnthalpyShelf {{{*/
    32893344ElementMatrix* Penta::CreateKMatrixEnthalpyShelf(void){
    32903345
     
    32943349        /*Intermediaries */
    32953350        int       i,j,ig;
    3296         double    mixed_layer_capacity,thermal_exchange_velocity;
    3297         double    rho_ice,rho_water,heatcapacity;
    3298         double    Jdet2d,dt;
    3299         double    xyz_list[NUMVERTICES][3];
    3300         double   xyz_list_tria[NUMVERTICES2D][3];
    3301         double    basis[NUMVERTICES];
    3302         double    D_scalar;
     3351        IssmDouble    mixed_layer_capacity,thermal_exchange_velocity;
     3352        IssmDouble    rho_ice,rho_water,heatcapacity;
     3353        IssmDouble    Jdet2d,dt;
     3354        IssmDouble    xyz_list[NUMVERTICES][3];
     3355        IssmDouble       xyz_list_tria[NUMVERTICES2D][3];
     3356        IssmDouble    basis[NUMVERTICES];
     3357        IssmDouble    D_scalar;
    33033358        GaussPenta *gauss=NULL;
    33043359
     
    33403395}
    33413396/*}}}*/
    3342 /*FUNCTION Penta::CreateKMatrixMelting {{{1*/
     3397/*FUNCTION Penta::CreateKMatrixMelting {{{*/
    33433398ElementMatrix* Penta::CreateKMatrixMelting(void){
    33443399
     
    33523407}
    33533408/*}}}*/
    3354 /*FUNCTION Penta::CreateKMatrixThermal {{{1*/
     3409/*FUNCTION Penta::CreateKMatrixThermal {{{*/
    33553410ElementMatrix* Penta::CreateKMatrixThermal(void){
    33563411       
     
    33663421}
    33673422/*}}}*/
    3368 /*FUNCTION Penta::CreateKMatrixThermalVolume {{{1*/
     3423/*FUNCTION Penta::CreateKMatrixThermalVolume {{{*/
    33693424ElementMatrix* Penta::CreateKMatrixThermalVolume(void){
    33703425
     
    33753430        int        stabilization;
    33763431        int        i,j,ig,found=0;
    3377         double     Jdet,u,v,w,um,vm,wm,vel;
    3378         double     h,hx,hy,hz,vx,vy,vz;
    3379         double     gravity,rho_ice,rho_water,kappa;
    3380         double     heatcapacity,thermalconductivity,dt;
    3381         double     tau_parameter,diameter;
    3382         double     xyz_list[NUMVERTICES][3];
    3383         double     B_conduct[3][numdof];
    3384         double     B_advec[3][numdof];
    3385         double     Bprime_advec[3][numdof];
    3386         double     L[numdof];
    3387         double     dbasis[3][6];
    3388         double     D_scalar_conduct,D_scalar_advec;
    3389         double     D_scalar_trans,D_scalar_stab;
    3390         double     D[3][3];
    3391         double     K[3][3]={0.0};
     3432        IssmDouble     Jdet,u,v,w,um,vm,wm,vel;
     3433        IssmDouble     h,hx,hy,hz,vx,vy,vz;
     3434        IssmDouble     gravity,rho_ice,rho_water,kappa;
     3435        IssmDouble     heatcapacity,thermalconductivity,dt;
     3436        IssmDouble     tau_parameter,diameter;
     3437        IssmDouble     xyz_list[NUMVERTICES][3];
     3438        IssmDouble     B_conduct[3][numdof];
     3439        IssmDouble     B_advec[3][numdof];
     3440        IssmDouble     Bprime_advec[3][numdof];
     3441        IssmDouble     L[numdof];
     3442        IssmDouble     dbasis[3][6];
     3443        IssmDouble     D_scalar_conduct,D_scalar_advec;
     3444        IssmDouble     D_scalar_trans,D_scalar_stab;
     3445        IssmDouble     D[3][3];
     3446        IssmDouble     K[3][3]={0.0};
    33923447        Tria*      tria=NULL;
    33933448        GaussPenta *gauss=NULL;
     
    35183573}
    35193574/*}}}*/
    3520 /*FUNCTION Penta::CreateKMatrixThermalShelf {{{1*/
     3575/*FUNCTION Penta::CreateKMatrixThermalShelf {{{*/
    35213576ElementMatrix* Penta::CreateKMatrixThermalShelf(void){
    35223577
     
    35273582        /*Intermediaries */
    35283583        int       i,j,ig;
    3529         double    mixed_layer_capacity,thermal_exchange_velocity;
    3530         double    rho_ice,rho_water,heatcapacity;
    3531         double    Jdet2d,dt;
    3532         double    xyz_list[NUMVERTICES][3];
    3533         double   xyz_list_tria[NUMVERTICES2D][3];
    3534         double    basis[NUMVERTICES];
    3535         double    D_scalar;
     3584        IssmDouble    mixed_layer_capacity,thermal_exchange_velocity;
     3585        IssmDouble    rho_ice,rho_water,heatcapacity;
     3586        IssmDouble    Jdet2d,dt;
     3587        IssmDouble    xyz_list[NUMVERTICES][3];
     3588        IssmDouble       xyz_list_tria[NUMVERTICES2D][3];
     3589        IssmDouble    basis[NUMVERTICES];
     3590        IssmDouble    D_scalar;
    35363591        GaussPenta *gauss=NULL;
    35373592
     
    35733628}
    35743629/*}}}*/
    3575 /*FUNCTION Penta::CreatePVectorEnthalpy {{{1*/
     3630/*FUNCTION Penta::CreatePVectorEnthalpy {{{*/
    35763631ElementVector* Penta::CreatePVectorEnthalpy(void){
    35773632
     
    35893644}
    35903645/*}}}*/
    3591 /*FUNCTION Penta::CreatePVectorEnthalpyVolume {{{1*/
     3646/*FUNCTION Penta::CreatePVectorEnthalpyVolume {{{*/
    35923647ElementVector* Penta::CreatePVectorEnthalpyVolume(void){
    35933648
     
    35983653        int    i,j,ig,found=0;
    35993654        int    friction_type,stabilization;
    3600         double Jdet,phi,dt;
    3601         double rho_ice,heatcapacity;
    3602         double thermalconductivity,kappa;
    3603         double viscosity,pressure;
    3604         double enthalpy,enthalpypicard;
    3605         double tau_parameter,diameter;
    3606         double u,v,w;
    3607         double scalar_def,scalar_transient;
    3608         double temperature_list[NUMVERTICES];
    3609         double xyz_list[NUMVERTICES][3];
    3610         double L[numdof];
    3611         double dbasis[3][6];
    3612         double epsilon[6];
     3655        IssmDouble Jdet,phi,dt;
     3656        IssmDouble rho_ice,heatcapacity;
     3657        IssmDouble thermalconductivity,kappa;
     3658        IssmDouble viscosity,pressure;
     3659        IssmDouble enthalpy,enthalpypicard;
     3660        IssmDouble tau_parameter,diameter;
     3661        IssmDouble u,v,w;
     3662        IssmDouble scalar_def,scalar_transient;
     3663        IssmDouble temperature_list[NUMVERTICES];
     3664        IssmDouble xyz_list[NUMVERTICES][3];
     3665        IssmDouble L[numdof];
     3666        IssmDouble dbasis[3][6];
     3667        IssmDouble epsilon[6];
    36133668        GaussPenta *gauss=NULL;
    36143669
     
    36853740}
    36863741/*}}}*/
    3687 /*FUNCTION Penta::CreatePVectorEnthalpyShelf {{{1*/
     3742/*FUNCTION Penta::CreatePVectorEnthalpyShelf {{{*/
    36883743ElementVector* Penta::CreatePVectorEnthalpyShelf(void){
    36893744
     
    36933748        /*Intermediaries */
    36943749        int        i,j,ig;
    3695         double     Jdet2d;
    3696         double     heatcapacity,h_pmp;
    3697         double     mixed_layer_capacity,thermal_exchange_velocity;
    3698         double     rho_ice,rho_water,pressure,dt,scalar_ocean;
    3699         double     xyz_list[NUMVERTICES][3];
    3700         double     xyz_list_tria[NUMVERTICES2D][3];
    3701         double     basis[NUMVERTICES];
     3750        IssmDouble     Jdet2d;
     3751        IssmDouble     heatcapacity,h_pmp;
     3752        IssmDouble     mixed_layer_capacity,thermal_exchange_velocity;
     3753        IssmDouble     rho_ice,rho_water,pressure,dt,scalar_ocean;
     3754        IssmDouble     xyz_list[NUMVERTICES][3];
     3755        IssmDouble     xyz_list_tria[NUMVERTICES2D][3];
     3756        IssmDouble     basis[NUMVERTICES];
    37023757        GaussPenta* gauss=NULL;
    37033758
     
    37423797}
    37433798/*}}}*/
    3744 /*FUNCTION Penta::CreatePVectorEnthalpySheet {{{1*/
     3799/*FUNCTION Penta::CreatePVectorEnthalpySheet {{{*/
    37453800ElementVector* Penta::CreatePVectorEnthalpySheet(void){
    37463801
     
    37513806        int        i,j,ig;
    37523807        int        analysis_type;
    3753         double     xyz_list[NUMVERTICES][3];
    3754         double     xyz_list_tria[NUMVERTICES2D][3]={0.0};
    3755         double     Jdet2d,dt;
    3756         double     rho_ice,heatcapacity,geothermalflux_value;
    3757         double     basalfriction,alpha2,vx,vy;
    3758         double     scalar,enthalpy,enthalpyup;
    3759         double     pressure,pressureup;
    3760         double     basis[NUMVERTICES];
     3808        IssmDouble     xyz_list[NUMVERTICES][3];
     3809        IssmDouble     xyz_list_tria[NUMVERTICES2D][3]={0.0};
     3810        IssmDouble     Jdet2d,dt;
     3811        IssmDouble     rho_ice,heatcapacity,geothermalflux_value;
     3812        IssmDouble     basalfriction,alpha2,vx,vy;
     3813        IssmDouble     scalar,enthalpy,enthalpyup;
     3814        IssmDouble     pressure,pressureup;
     3815        IssmDouble     basis[NUMVERTICES];
    37613816        Friction*  friction=NULL;
    37623817        GaussPenta* gauss=NULL;
     
    38313886}
    38323887/*}}}*/
    3833 /*FUNCTION Penta::CreatePVectorMelting {{{1*/
     3888/*FUNCTION Penta::CreatePVectorMelting {{{*/
    38343889ElementVector* Penta::CreatePVectorMelting(void){
    38353890        return NULL;
    38363891}
    38373892/*}}}*/
    3838 /*FUNCTION Penta::CreatePVectorThermal {{{1*/
     3893/*FUNCTION Penta::CreatePVectorThermal {{{*/
    38393894ElementVector* Penta::CreatePVectorThermal(void){
    38403895
     
    38523907}
    38533908/*}}}*/
    3854 /*FUNCTION Penta::CreatePVectorThermalVolume {{{1*/
     3909/*FUNCTION Penta::CreatePVectorThermalVolume {{{*/
    38553910ElementVector* Penta::CreatePVectorThermalVolume(void){
    38563911
     
    38613916        int    i,j,ig,found=0;
    38623917        int    friction_type,stabilization;
    3863         double Jdet,phi,dt;
    3864         double rho_ice,heatcapacity;
    3865         double thermalconductivity,kappa;
    3866         double viscosity,temperature;
    3867         double tau_parameter,diameter;
    3868         double u,v,w;
    3869         double scalar_def,scalar_transient;
    3870         double temperature_list[NUMVERTICES];
    3871         double xyz_list[NUMVERTICES][3];
    3872         double L[numdof];
    3873         double dbasis[3][6];
    3874         double epsilon[6];
     3918        IssmDouble Jdet,phi,dt;
     3919        IssmDouble rho_ice,heatcapacity;
     3920        IssmDouble thermalconductivity,kappa;
     3921        IssmDouble viscosity,temperature;
     3922        IssmDouble tau_parameter,diameter;
     3923        IssmDouble u,v,w;
     3924        IssmDouble scalar_def,scalar_transient;
     3925        IssmDouble temperature_list[NUMVERTICES];
     3926        IssmDouble xyz_list[NUMVERTICES][3];
     3927        IssmDouble L[numdof];
     3928        IssmDouble dbasis[3][6];
     3929        IssmDouble epsilon[6];
    38753930        GaussPenta *gauss=NULL;
    38763931
     
    39393994}
    39403995/*}}}*/
    3941 /*FUNCTION Penta::CreatePVectorThermalShelf {{{1*/
     3996/*FUNCTION Penta::CreatePVectorThermalShelf {{{*/
    39423997ElementVector* Penta::CreatePVectorThermalShelf(void){
    39433998
     
    39474002        /*Intermediaries */
    39484003        int        i,j,ig;
    3949         double     Jdet2d;
    3950         double     mixed_layer_capacity,thermal_exchange_velocity;
    3951         double     rho_ice,rho_water,pressure,dt,scalar_ocean;
    3952         double     heatcapacity,t_pmp;
    3953         double     xyz_list[NUMVERTICES][3];
    3954         double     xyz_list_tria[NUMVERTICES2D][3];
    3955         double     basis[NUMVERTICES];
     4004        IssmDouble     Jdet2d;
     4005        IssmDouble     mixed_layer_capacity,thermal_exchange_velocity;
     4006        IssmDouble     rho_ice,rho_water,pressure,dt,scalar_ocean;
     4007        IssmDouble     heatcapacity,t_pmp;
     4008        IssmDouble     xyz_list[NUMVERTICES][3];
     4009        IssmDouble     xyz_list_tria[NUMVERTICES2D][3];
     4010        IssmDouble     basis[NUMVERTICES];
    39564011        GaussPenta* gauss=NULL;
    39574012
     
    39964051}
    39974052/*}}}*/
    3998 /*FUNCTION Penta::CreatePVectorThermalSheet {{{1*/
     4053/*FUNCTION Penta::CreatePVectorThermalSheet {{{*/
    39994054ElementVector* Penta::CreatePVectorThermalSheet(void){
    40004055
     
    40054060        int        i,j,ig;
    40064061        int        analysis_type;
    4007         double     xyz_list[NUMVERTICES][3];
    4008         double     xyz_list_tria[NUMVERTICES2D][3]={0.0};
    4009         double     Jdet2d,dt;
    4010         double     rho_ice,heatcapacity,geothermalflux_value;
    4011         double     basalfriction,alpha2,vx,vy;
    4012         double     basis[NUMVERTICES];
    4013         double     scalar;
     4062        IssmDouble     xyz_list[NUMVERTICES][3];
     4063        IssmDouble     xyz_list_tria[NUMVERTICES2D][3]={0.0};
     4064        IssmDouble     Jdet2d,dt;
     4065        IssmDouble     rho_ice,heatcapacity,geothermalflux_value;
     4066        IssmDouble     basalfriction,alpha2,vx,vy;
     4067        IssmDouble     basis[NUMVERTICES];
     4068        IssmDouble     scalar;
    40144069        Friction*  friction=NULL;
    40154070        GaussPenta* gauss=NULL;
     
    40634118}
    40644119/*}}}*/
    4065 /*FUNCTION Penta::GetSolutionFromInputsThermal{{{1*/
     4120/*FUNCTION Penta::GetSolutionFromInputsThermal{{{*/
    40664121void  Penta::GetSolutionFromInputsThermal(Vector* solution){
    40674122
     
    40704125        int          i;
    40714126        int*         doflist=NULL;
    4072         double       values[numdof];
    4073         double       temp;
     4127        IssmDouble       values[numdof];
     4128        IssmDouble       temp;
    40744129        GaussPenta   *gauss=NULL;
    40754130
     
    40914146        /*Free ressources:*/
    40924147        delete gauss;
    4093         xfree((void**)&doflist);
    4094 }
    4095 /*}}}*/
    4096 /*FUNCTION Penta::GetSolutionFromInputsEnthalpy{{{1*/
     4148        xDelete<int>(doflist);
     4149}
     4150/*}}}*/
     4151/*FUNCTION Penta::GetSolutionFromInputsEnthalpy{{{*/
    40974152void  Penta::GetSolutionFromInputsEnthalpy(Vector* solution){
    40984153
     
    41014156        int          i;
    41024157        int*         doflist=NULL;
    4103         double       values[numdof];
    4104         double       enthalpy;
     4158        IssmDouble       values[numdof];
     4159        IssmDouble       enthalpy;
    41054160        GaussPenta   *gauss=NULL;
    41064161
     
    41224177        /*Free ressources:*/
    41234178        delete gauss;
    4124         xfree((void**)&doflist);
    4125 }
    4126 /*}}}*/
    4127 /*FUNCTION Penta::InputUpdateFromSolutionThermal {{{1*/
    4128 void  Penta::InputUpdateFromSolutionThermal(double* solution){
     4179        xDelete<int>(doflist);
     4180}
     4181/*}}}*/
     4182/*FUNCTION Penta::InputUpdateFromSolutionThermal {{{*/
     4183void  Penta::InputUpdateFromSolutionThermal(IssmDouble* solution){
    41294184
    41304185        const int    numdof=NDOF1*NUMVERTICES;
     
    41324187        bool   converged;
    41334188        int    i,rheology_law;
    4134         double xyz_list[NUMVERTICES][3];
    4135         double values[numdof];
    4136         double B[numdof];
    4137         double B_average,s_average;
     4189        IssmDouble xyz_list[NUMVERTICES][3];
     4190        IssmDouble values[numdof];
     4191        IssmDouble B[numdof];
     4192        IssmDouble B_average,s_average;
    41384193        int*   doflist=NULL;
    4139         //double pressure[numdof];
     4194        //IssmDouble pressure[numdof];
    41404195
    41414196        /*Get dof list: */
     
    41504205
    41514206                /*Check solution*/
    4152                 if(isnan(values[i])) _error_("NaN found in solution vector");
    4153                 //if(values[i]<0)      printf("temperature < 0°K found in solution vector\n");
    4154                 //if(values[i]>275)    printf("temperature > 275°K found in solution vector (Paterson's rheology associated is negative)\n");
     4207                if(xIsNan<IssmDouble>(values[i])) _error2_("NaN found in solution vector");
     4208                //if(values[i]<0)      _printLine_("temperature < 0°K found in solution vector");
     4209                //if(values[i]>275)    _printLine_("temperature > 275°K found in solution vector (Paterson's rheology associated is negative)");
    41554210        }
    41564211
     
    41844239                                break;
    41854240                        default:
    4186                                 _error_("Rheology law %s not supported yet",EnumToStringx(rheology_law));
     4241                                _error2_("Rheology law " << EnumToStringx(rheology_law) << " not supported yet");
    41874242
    41884243                }
     
    41934248
    41944249        /*Free ressources:*/
    4195         xfree((void**)&doflist);
    4196 }
    4197 /*}}}*/
    4198 /*FUNCTION Penta::InputUpdateFromSolutionEnthalpy {{{1*/
    4199 void  Penta::InputUpdateFromSolutionEnthalpy(double* solution){
     4250        xDelete<int>(doflist);
     4251}
     4252/*}}}*/
     4253/*FUNCTION Penta::InputUpdateFromSolutionEnthalpy {{{*/
     4254void  Penta::InputUpdateFromSolutionEnthalpy(IssmDouble* solution){
    42004255
    42014256        const int    numdof=NDOF1*NUMVERTICES;
     
    42034258        bool   converged=false;
    42044259        int    i,rheology_law;
    4205         double xyz_list[NUMVERTICES][3];
    4206         double values[numdof];
    4207         double pressure[NUMVERTICES];
    4208         double temperatures[numdof];
    4209         double waterfraction[numdof];
    4210         double B[numdof];
    4211         double B_average,s_average;
     4260        IssmDouble xyz_list[NUMVERTICES][3];
     4261        IssmDouble values[numdof];
     4262        IssmDouble pressure[NUMVERTICES];
     4263        IssmDouble temperatures[numdof];
     4264        IssmDouble waterfraction[numdof];
     4265        IssmDouble B[numdof];
     4266        IssmDouble B_average,s_average;
    42124267        int*   doflist=NULL;
    42134268
     
    42204275
    42214276                /*Check solution*/
    4222                 if(isnan(values[i])) _error_("NaN found in solution vector");
     4277                if(xIsNan<IssmDouble>(values[i])) _error2_("NaN found in solution vector");
    42234278        }
    42244279
     
    42334288                for(i=0;i<numdof;i++){
    42344289                        matpar->EnthalpyToThermal(&temperatures[i],&waterfraction[i],values[i],pressure[i]);
    4235                         if(waterfraction[i]<0) _error_("Negative water fraction found in solution vector");
    4236                         //if(waterfraction[i]>1) _error_("Water fraction >1 found in solution vector");
     4290                        if(waterfraction[i]<0) _error2_("Negative water fraction found in solution vector");
     4291                        //if(waterfraction[i]>1) _error2_("Water fraction >1 found in solution vector");
    42374292                }
    42384293                       
     
    42624317                                break;
    42634318                        default:
    4264                                 _error_("Rheology law %s not supported yet",EnumToStringx(rheology_law));
     4319                                _error2_("Rheology law " << EnumToStringx(rheology_law) << " not supported yet");
    42654320
    42664321                }
     
    42714326
    42724327        /*Free ressources:*/
    4273         xfree((void**)&doflist);
     4328        xDelete<int>(doflist);
    42744329}
    42754330/*}}}*/
     
    42774332
    42784333#ifdef _HAVE_CONTROL_
    4279 /*FUNCTION Penta::ControlInputGetGradient{{{1*/
     4334/*FUNCTION Penta::ControlInputGetGradient{{{*/
    42804335void Penta::ControlInputGetGradient(Vector* gradient,int enum_type,int control_index){
    42814336
     
    42904345                input=inputs->GetInput(enum_type);
    42914346        }
    4292         if (!input) _error_("Input %s not found",EnumToStringx(enum_type));
    4293         if (input->ObjectEnum()!=ControlInputEnum) _error_("Input %s is not a ControlInput",EnumToStringx(enum_type));
     4347        if (!input) _error2_("Input " << EnumToStringx(enum_type) << " not found");
     4348        if (input->ObjectEnum()!=ControlInputEnum) _error2_("Input " << EnumToStringx(enum_type) << " is not a ControlInput");
    42944349
    42954350        GradientIndexing(&doflist1[0],control_index);
     
    42974352
    42984353}/*}}}*/
    4299 /*FUNCTION Penta::ControlInputScaleGradient{{{1*/
    4300 void Penta::ControlInputScaleGradient(int enum_type,double scale){
     4354/*FUNCTION Penta::ControlInputScaleGradient{{{*/
     4355void Penta::ControlInputScaleGradient(int enum_type,IssmDouble scale){
    43014356
    43024357        Input* input=NULL;
     
    43084363                input=inputs->GetInput(enum_type);
    43094364        }
    4310         if (!input) _error_("Input %s not found",EnumToStringx(enum_type));
    4311         if (input->ObjectEnum()!=ControlInputEnum) _error_("Input %s is not a ControlInput",EnumToStringx(enum_type));
     4365        if (!input) _error2_("Input " << EnumToStringx(enum_type) << " not found");
     4366        if (input->ObjectEnum()!=ControlInputEnum) _error2_("Input " << EnumToStringx(enum_type) << " is not a ControlInput");
    43124367
    43134368        ((ControlInput*)input)->ScaleGradient(scale);
    43144369}/*}}}*/
    4315 /*FUNCTION Penta::ControlInputSetGradient{{{1*/
    4316 void Penta::ControlInputSetGradient(double* gradient,int enum_type,int control_index){
     4370/*FUNCTION Penta::ControlInputSetGradient{{{*/
     4371void Penta::ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index){
    43174372
    43184373        int    doflist1[NUMVERTICES];
    4319         double grad_list[NUMVERTICES];
     4374        IssmDouble grad_list[NUMVERTICES];
    43204375        Input* grad_input=NULL;
    43214376        Input* input=NULL;
     
    43274382                input=inputs->GetInput(enum_type);
    43284383        }
    4329         if (!input) _error_("Input %s not found",EnumToStringx(enum_type));
    4330         if (input->ObjectEnum()!=ControlInputEnum) _error_("Input %s is not a ControlInput",EnumToStringx(enum_type));
     4384        if (!input) _error2_("Input " << EnumToStringx(enum_type) << " not found");
     4385        if (input->ObjectEnum()!=ControlInputEnum) _error2_("Input " << EnumToStringx(enum_type) << " is not a ControlInput");
    43314386
    43324387        GradientIndexing(&doflist1[0],control_index);
     
    43364391
    43374392}/*}}}*/
    4338 /*FUNCTION Penta::CreateKMatrixAdjointHoriz{{{1*/
     4393/*FUNCTION Penta::CreateKMatrixAdjointHoriz{{{*/
    43394394ElementMatrix* Penta::CreateKMatrixAdjointHoriz(void){
    43404395
     
    43524407                        return NULL;
    43534408                default:
    4354                         _error_("Approximation %s not supported yet",EnumToStringx(approximation));
    4355         }
    4356 }
    4357 /*}}}*/
    4358 /*FUNCTION Penta::CreateKMatrixAdjointMacAyeal2d{{{1*/
     4409                        _error2_("Approximation " << EnumToStringx(approximation) << " not supported yet");
     4410        }
     4411}
     4412/*}}}*/
     4413/*FUNCTION Penta::CreateKMatrixAdjointMacAyeal2d{{{*/
    43594414ElementMatrix* Penta::CreateKMatrixAdjointMacAyeal2d(void){
    43604415
     
    43794434}
    43804435/*}}}*/
    4381 /*FUNCTION Penta::CreateKMatrixAdjointPattyn{{{1*/
     4436/*FUNCTION Penta::CreateKMatrixAdjointPattyn{{{*/
    43824437ElementMatrix* Penta::CreateKMatrixAdjointPattyn(void){
    43834438
     
    43884443        int        i,j,ig;
    43894444        bool       incomplete_adjoint;
    4390         double     xyz_list[NUMVERTICES][3];
    4391         double     Jdet;
    4392         double     eps1dotdphii,eps1dotdphij;
    4393         double     eps2dotdphii,eps2dotdphij;
    4394         double     mu_prime;
    4395         double     epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
    4396         double     eps1[3],eps2[3];
    4397         double     phi[NUMVERTICES];
    4398         double     dphi[3][NUMVERTICES];
     4445        IssmDouble     xyz_list[NUMVERTICES][3];
     4446        IssmDouble     Jdet;
     4447        IssmDouble     eps1dotdphii,eps1dotdphij;
     4448        IssmDouble     eps2dotdphii,eps2dotdphij;
     4449        IssmDouble     mu_prime;
     4450        IssmDouble     epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
     4451        IssmDouble     eps1[3],eps2[3];
     4452        IssmDouble     phi[NUMVERTICES];
     4453        IssmDouble     dphi[3][NUMVERTICES];
    43994454        GaussPenta *gauss=NULL;
    44004455
     
    44474502}
    44484503/*}}}*/
    4449 /*FUNCTION Penta::CreateKMatrixAdjointStokes{{{1*/
     4504/*FUNCTION Penta::CreateKMatrixAdjointStokes{{{*/
    44504505ElementMatrix* Penta::CreateKMatrixAdjointStokes(void){
    44514506
     
    44564511        int        i,j,ig;
    44574512        bool       incomplete_adjoint;
    4458         double     xyz_list[NUMVERTICES][3];
    4459         double     Jdet;
    4460         double     eps1dotdphii,eps1dotdphij;
    4461         double     eps2dotdphii,eps2dotdphij;
    4462         double     eps3dotdphii,eps3dotdphij;
    4463         double     mu_prime;
    4464         double     epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
    4465         double     eps1[3],eps2[3],eps3[3];
    4466         double     phi[NUMVERTICES];
    4467         double     dphi[3][NUMVERTICES];
     4513        IssmDouble     xyz_list[NUMVERTICES][3];
     4514        IssmDouble     Jdet;
     4515        IssmDouble     eps1dotdphii,eps1dotdphij;
     4516        IssmDouble     eps2dotdphii,eps2dotdphij;
     4517        IssmDouble     eps3dotdphii,eps3dotdphij;
     4518        IssmDouble     mu_prime;
     4519        IssmDouble     epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
     4520        IssmDouble     eps1[3],eps2[3],eps3[3];
     4521        IssmDouble     phi[NUMVERTICES];
     4522        IssmDouble     dphi[3][NUMVERTICES];
    44684523        GaussPenta *gauss=NULL;
    44694524
     
    45264581}
    45274582/*}}}*/
    4528 /*FUNCTION Penta::CreatePVectorAdjointHoriz{{{1*/
     4583/*FUNCTION Penta::CreatePVectorAdjointHoriz{{{*/
    45294584ElementVector* Penta::CreatePVectorAdjointHoriz(void){
    45304585
     
    45424597                        return CreatePVectorAdjointStokes();
    45434598                default:
    4544                         _error_("Approximation %s not supported yet",EnumToStringx(approximation));
    4545         }
    4546 }
    4547 /*}}}*/
    4548 /*FUNCTION Penta::CreatePVectorAdjointMacAyeal{{{1*/
     4599                        _error2_("Approximation " << EnumToStringx(approximation) << " not supported yet");
     4600        }
     4601}
     4602/*}}}*/
     4603/*FUNCTION Penta::CreatePVectorAdjointMacAyeal{{{*/
    45494604ElementVector* Penta::CreatePVectorAdjointMacAyeal(){
    45504605
     
    45604615}
    45614616/*}}}*/
    4562 /*FUNCTION Penta::CreatePVectorAdjointPattyn{{{1*/
     4617/*FUNCTION Penta::CreatePVectorAdjointPattyn{{{*/
    45634618ElementVector* Penta::CreatePVectorAdjointPattyn(void){
    45644619
     
    45744629}
    45754630/*}}}*/
    4576 /*FUNCTION Penta::CreatePVectorAdjointStokes{{{1*/
     4631/*FUNCTION Penta::CreatePVectorAdjointStokes{{{*/
    45774632ElementVector* Penta::CreatePVectorAdjointStokes(void){
    45784633
     
    45884643}
    45894644/*}}}*/
    4590 /*FUNCTION Penta::GradientIndexing{{{1*/
     4645/*FUNCTION Penta::GradientIndexing{{{*/
    45914646void Penta::GradientIndexing(int* indexing,int control_index){
    45924647
     
    46024657}
    46034658/*}}}*/
    4604 /*FUNCTION Penta::Gradj {{{1*/
     4659/*FUNCTION Penta::Gradj {{{*/
    46054660void  Penta::Gradj(Vector* gradient,int control_type,int control_index){
    46064661        /*dJ/dalpha = ∂L/∂alpha = ∂J/∂alpha + ∂/∂alpha(KU-F)*/
     
    46314686                                        break;
    46324687                                default:
    4633                                         _error_("approximation %s not supported yet",EnumToStringx(approximation));
     4688                                        _error2_("approximation " << EnumToStringx(approximation) << " not supported yet");
    46344689                        }
    46354690                        break;
     
    46514706                                        break;
    46524707                                default:
    4653                                         _error_("approximation %s not supported yet",EnumToStringx(approximation));
     4708                                        _error2_("approximation " << EnumToStringx(approximation) << " not supported yet");
    46544709                        }
    46554710                        break;
    46564711
    46574712                default:
    4658                         _error_("control type %s not supported yet: ",EnumToStringx(control_type));
     4713                        _error2_("control type " << EnumToStringx(control_type) << " not supported yet: ");
    46594714        }
    46604715
     
    46884743                        break;
    46894744                default:
    4690                         _error_("response %s not supported yet",EnumToStringx(responses[resp]));
    4691         }
    4692         xfree((void**)&responses);
    4693 }
    4694 /*}}}*/
    4695 /*FUNCTION Penta::GradjDragMacAyeal {{{1*/
     4745                        _error2_("response " << EnumToStringx(responses[resp]) << " not supported yet");
     4746        }
     4747        xDelete<int>(responses);
     4748}
     4749/*}}}*/
     4750/*FUNCTION Penta::GradjDragMacAyeal {{{*/
    46964751void  Penta::GradjDragMacAyeal(Vector* gradient,int control_index){
    46974752
     
    47054760
    47064761} /*}}}*/
    4707 /*FUNCTION Penta::GradjDragPattyn {{{1*/
     4762/*FUNCTION Penta::GradjDragPattyn {{{*/
    47084763void  Penta::GradjDragPattyn(Vector* gradient,int control_index){
    47094764
     
    47114766        int        analysis_type;
    47124767        int        doflist1[NUMVERTICES];
    4713         double     vx,vy,lambda,mu,alpha_complement,Jdet;
    4714         double     bed,thickness,Neff,drag;
    4715         double     xyz_list[NUMVERTICES][3];
    4716         double     xyz_list_tria[NUMVERTICES2D][3]={0.0};
    4717         double     dk[NDOF3];
    4718         double     grade_g[NUMVERTICES]={0.0};
    4719         double     grade_g_gaussian[NUMVERTICES];
    4720         double     basis[6];
     4768        IssmDouble     vx,vy,lambda,mu,alpha_complement,Jdet;
     4769        IssmDouble     bed,thickness,Neff,drag;
     4770        IssmDouble     xyz_list[NUMVERTICES][3];
     4771        IssmDouble     xyz_list_tria[NUMVERTICES2D][3]={0.0};
     4772        IssmDouble     dk[NDOF3];
     4773        IssmDouble     grade_g[NUMVERTICES]={0.0};
     4774        IssmDouble     grade_g_gaussian[NUMVERTICES];
     4775        IssmDouble     basis[6];
    47214776        Friction*  friction=NULL;
    47224777        GaussPenta  *gauss=NULL;
     
    47654820                /*Add gradje_g_gaussian vector to gradje_g: */
    47664821                for(i=0;i<NUMVERTICES;i++){
    4767                         _assert_(!isnan(grade_g[i]));
     4822                        _assert_(!xIsNan<IssmDouble>(grade_g[i]));
    47684823                        grade_g[i]+=grade_g_gaussian[i];
    47694824                }
     
    47764831}
    47774832/*}}}*/
    4778 /*FUNCTION Penta::GradjDragStokes {{{1*/
     4833/*FUNCTION Penta::GradjDragStokes {{{*/
    47794834void  Penta::GradjDragStokes(Vector* gradient,int control_index){
    47804835
     
    47824837        int        analysis_type;
    47834838        int        doflist1[NUMVERTICES];
    4784         double     bed,thickness,Neff;
    4785         double     lambda,mu,xi,Jdet,vx,vy,vz;
    4786         double     alpha_complement,drag;
    4787         double     surface_normal[3],bed_normal[3];
    4788         double     xyz_list[NUMVERTICES][3];
    4789         double     xyz_list_tria[NUMVERTICES2D][3]={0.0};
    4790         double     dk[NDOF3];
    4791         double     basis[6];
    4792         double     grade_g[NUMVERTICES]={0.0};
    4793         double     grade_g_gaussian[NUMVERTICES];
     4839        IssmDouble     bed,thickness,Neff;
     4840        IssmDouble     lambda,mu,xi,Jdet,vx,vy,vz;
     4841        IssmDouble     alpha_complement,drag;
     4842        IssmDouble     surface_normal[3],bed_normal[3];
     4843        IssmDouble     xyz_list[NUMVERTICES][3];
     4844        IssmDouble     xyz_list_tria[NUMVERTICES2D][3]={0.0};
     4845        IssmDouble     dk[NDOF3];
     4846        IssmDouble     basis[6];
     4847        IssmDouble     grade_g[NUMVERTICES]={0.0};
     4848        IssmDouble     grade_g_gaussian[NUMVERTICES];
    47944849        Friction*  friction=NULL;
    47954850        GaussPenta* gauss=NULL;
     
    48684923}
    48694924/*}}}*/
    4870 /*FUNCTION Penta::GradjBbarMacAyeal {{{1*/
     4925/*FUNCTION Penta::GradjBbarMacAyeal {{{*/
    48714926void  Penta::GradjBbarMacAyeal(Vector* gradient,int control_index){
    48724927
     
    48864941
    48874942} /*}}}*/
    4888 /*FUNCTION Penta::GradjBbarPattyn {{{1*/
     4943/*FUNCTION Penta::GradjBbarPattyn {{{*/
    48894944void  Penta::GradjBbarPattyn(Vector* gradient,int control_index){
    48904945
     
    49034958        this->matice->inputs->DeleteInput(MaterialsRheologyBbarEnum);
    49044959} /*}}}*/
    4905 /*FUNCTION Penta::GradjBbarStokes {{{1*/
     4960/*FUNCTION Penta::GradjBbarStokes {{{*/
    49064961void  Penta::GradjBbarStokes(Vector* gradient,int control_index){
    49074962
     
    49204975        this->matice->inputs->DeleteInput(MaterialsRheologyBbarEnum);
    49214976} /*}}}*/
    4922 /*FUNCTION Penta::InputControlUpdate{{{1*/
    4923 void  Penta::InputControlUpdate(double scalar,bool save_parameter){
     4977/*FUNCTION Penta::InputControlUpdate{{{*/
     4978void  Penta::InputControlUpdate(IssmDouble scalar,bool save_parameter){
    49244979
    49254980        /*Intermediary*/
     
    49424997                }
    49434998
    4944                 if (input->ObjectEnum()!=ControlInputEnum) _error_("input %s is not a ControlInput",EnumToStringx(control_type[i]));
     4999                if (input->ObjectEnum()!=ControlInputEnum) _error2_("input " << EnumToStringx(control_type[i]) << " is not a ControlInput");
    49455000
    49465001                ((ControlInput*)input)->UpdateValue(scalar);
     
    49555010        /*Clean up and return*/
    49565011cleanup_and_return:
    4957         xfree((void**)&control_type);
    4958 }
    4959 /*}}}*/
    4960 /*FUNCTION Penta::InputUpdateFromSolutionAdjointStokes {{{1*/
    4961 void  Penta::InputUpdateFromSolutionAdjointStokes(double* solution){
     5012        xDelete<int>(control_type);
     5013}
     5014/*}}}*/
     5015/*FUNCTION Penta::InputUpdateFromSolutionAdjointStokes {{{*/
     5016void  Penta::InputUpdateFromSolutionAdjointStokes(IssmDouble* solution){
    49625017
    49635018        const int    numdof=NDOF4*NUMVERTICES;
    49645019
    49655020        int    i;
    4966         double values[numdof];
    4967         double lambdax[NUMVERTICES];
    4968         double lambday[NUMVERTICES];
    4969         double lambdaz[NUMVERTICES];
    4970         double lambdap[NUMVERTICES];
     5021        IssmDouble values[numdof];
     5022        IssmDouble lambdax[NUMVERTICES];
     5023        IssmDouble lambday[NUMVERTICES];
     5024        IssmDouble lambdaz[NUMVERTICES];
     5025        IssmDouble lambdap[NUMVERTICES];
    49715026        int*   doflist=NULL;
    49725027
     
    49855040
    49865041                /*Check solution*/
    4987                 if(isnan(lambdax[i])) _error_("NaN found in solution vector");
    4988                 if(isnan(lambday[i])) _error_("NaN found in solution vector");
    4989                 if(isnan(lambdaz[i])) _error_("NaN found in solution vector");
    4990                 if(isnan(lambdap[i])) _error_("NaN found in solution vector");
     5042                if(xIsNan<IssmDouble>(lambdax[i])) _error2_("NaN found in solution vector");
     5043                if(xIsNan<IssmDouble>(lambday[i])) _error2_("NaN found in solution vector");
     5044                if(xIsNan<IssmDouble>(lambdaz[i])) _error2_("NaN found in solution vector");
     5045                if(xIsNan<IssmDouble>(lambdap[i])) _error2_("NaN found in solution vector");
    49915046        }
    49925047
     
    49985053
    49995054        /*Free ressources:*/
    5000         xfree((void**)&doflist);
    5001 }
    5002 /*}}}*/
    5003 /*FUNCTION Penta::InputUpdateFromSolutionAdjointHoriz {{{1*/
    5004 void  Penta::InputUpdateFromSolutionAdjointHoriz(double* solution){
     5055        xDelete<int>(doflist);
     5056}
     5057/*}}}*/
     5058/*FUNCTION Penta::InputUpdateFromSolutionAdjointHoriz {{{*/
     5059void  Penta::InputUpdateFromSolutionAdjointHoriz(IssmDouble* solution){
    50055060
    50065061        const int numdof=NDOF2*NUMVERTICES;
    50075062
    50085063        int    i;
    5009         double values[numdof];
    5010         double lambdax[NUMVERTICES];
    5011         double lambday[NUMVERTICES];
     5064        IssmDouble values[numdof];
     5065        IssmDouble lambdax[NUMVERTICES];
     5066        IssmDouble lambday[NUMVERTICES];
    50125067        int*   doflist=NULL;
    50135068
     
    50245079
    50255080                /*Check solution*/
    5026                 if(isnan(lambdax[i]))       _error_("NaN found in solution vector");
    5027                 if(isnan(lambday[i]))       _error_("NaN found in solution vector");
     5081                if(xIsNan<IssmDouble>(lambdax[i]))       _error2_("NaN found in solution vector");
     5082                if(xIsNan<IssmDouble>(lambday[i]))       _error2_("NaN found in solution vector");
    50285083        }
    50295084
     
    50335088
    50345089        /*Free ressources:*/
    5035         xfree((void**)&doflist);
    5036 }
    5037 /*}}}*/
    5038 /*FUNCTION Penta::SurfaceAverageVelMisfit {{{1*/
    5039 double Penta::SurfaceAverageVelMisfit(bool process_units,int weight_index){
     5090        xDelete<int>(doflist);
     5091}
     5092/*}}}*/
     5093/*FUNCTION Penta::SurfaceAverageVelMisfit {{{*/
     5094IssmDouble Penta::SurfaceAverageVelMisfit(bool process_units,int weight_index){
    50405095
    50415096        int    approximation;
    5042         double J;
     5097        IssmDouble J;
    50435098        Tria*  tria=NULL;
    50445099
     
    50735128}
    50745129/*}}}*/
    5075 /*FUNCTION Penta::SurfaceAbsVelMisfit {{{1*/
    5076 double Penta::SurfaceAbsVelMisfit(bool process_units,int weight_index){
     5130/*FUNCTION Penta::SurfaceAbsVelMisfit {{{*/
     5131IssmDouble Penta::SurfaceAbsVelMisfit(bool process_units,int weight_index){
    50775132
    50785133        int    approximation;
    5079         double J;
     5134        IssmDouble J;
    50805135        Tria*  tria=NULL;
    50815136
     
    51105165}
    51115166/*}}}*/
    5112 /*FUNCTION Penta::SurfaceLogVelMisfit {{{1*/
    5113 double Penta::SurfaceLogVelMisfit(bool process_units,int weight_index){
     5167/*FUNCTION Penta::SurfaceLogVelMisfit {{{*/
     5168IssmDouble Penta::SurfaceLogVelMisfit(bool process_units,int weight_index){
    51145169
    51155170        int    approximation;
    5116         double J;
     5171        IssmDouble J;
    51175172        Tria*  tria=NULL;
    51185173
     
    51475202}
    51485203/*}}}*/
    5149 /*FUNCTION Penta::SurfaceLogVxVyMisfit {{{1*/
    5150 double Penta::SurfaceLogVxVyMisfit(bool process_units,int weight_index){
    5151 
    5152         double J;
     5204/*FUNCTION Penta::SurfaceLogVxVyMisfit {{{*/
     5205IssmDouble Penta::SurfaceLogVxVyMisfit(bool process_units,int weight_index){
     5206
     5207        IssmDouble J;
    51535208        Tria* tria=NULL;
    51545209
     
    51865241}
    51875242/*}}}*/
    5188 /*FUNCTION Penta::SurfaceRelVelMisfit {{{1*/
    5189 double Penta::SurfaceRelVelMisfit(bool process_units,int weight_index){
     5243/*FUNCTION Penta::SurfaceRelVelMisfit {{{*/
     5244IssmDouble Penta::SurfaceRelVelMisfit(bool process_units,int weight_index){
    51905245
    51915246        int    approximation;
    5192         double J;
     5247        IssmDouble J;
    51935248        Tria*  tria=NULL;
    51945249
     
    52235278}
    52245279/*}}}*/
    5225 /*FUNCTION Penta::ThicknessAbsGradient{{{1*/
    5226 double Penta::ThicknessAbsGradient(bool process_units,int weight_index){
    5227 
    5228         _error_("Not implemented yet");
    5229 }
    5230 /*}}}*/
    5231 /*FUNCTION Penta::ThicknessAbsMisfit {{{1*/
    5232 double Penta::ThicknessAbsMisfit(bool process_units,int weight_index){
     5280/*FUNCTION Penta::ThicknessAbsGradient{{{*/
     5281IssmDouble Penta::ThicknessAbsGradient(bool process_units,int weight_index){
     5282
     5283        _error2_("Not implemented yet");
     5284}
     5285/*}}}*/
     5286/*FUNCTION Penta::ThicknessAbsMisfit {{{*/
     5287IssmDouble Penta::ThicknessAbsMisfit(bool process_units,int weight_index){
    52335288
    52345289        int    approximation;
    5235         double J;
     5290        IssmDouble J;
    52365291        Tria*  tria=NULL;
    52375292
     
    52415296        /*If on water, return 0: */
    52425297        if(IsOnWater())return 0;
    5243         _error_("Not implemented yet");
     5298        _error2_("Not implemented yet");
    52445299
    52455300        tria=(Tria*)SpawnTria(0,1,2);
     
    52495304}
    52505305/*}}}*/
    5251 /*FUNCTION Penta::DragCoefficientAbsGradient{{{1*/
    5252 double Penta::DragCoefficientAbsGradient(bool process_units,int weight_index){
    5253 
    5254         double J;
     5306/*FUNCTION Penta::DragCoefficientAbsGradient{{{*/
     5307IssmDouble Penta::DragCoefficientAbsGradient(bool process_units,int weight_index){
     5308
     5309        IssmDouble J;
    52555310        Tria*  tria=NULL;
    52565311
     
    52645319}
    52655320/*}}}*/
    5266 /*FUNCTION Penta::RheologyBbarAbsGradient{{{1*/
    5267 double Penta::RheologyBbarAbsGradient(bool process_units,int weight_index){
    5268 
    5269         double J;
     5321/*FUNCTION Penta::RheologyBbarAbsGradient{{{*/
     5322IssmDouble Penta::RheologyBbarAbsGradient(bool process_units,int weight_index){
     5323
     5324        IssmDouble J;
    52705325        Tria*  tria=NULL;
    52715326
     
    52795334}
    52805335/*}}}*/
    5281 /*FUNCTION Penta::GetVectorFromControlInputs{{{1*/
     5336/*FUNCTION Penta::GetVectorFromControlInputs{{{*/
    52825337void  Penta::GetVectorFromControlInputs(Vector* vector,int control_enum,int control_index,const char* data){
    52835338
     
    52925347        /*Get input (either in element or material)*/
    52935348        Input* input=inputs->GetInput(control_enum);
    5294         if(!input) _error_("Input %s not found in element",EnumToStringx(control_enum));
     5349        if(!input) _error2_("Input " << EnumToStringx(control_enum) << " not found in element");
    52955350
    52965351        /*Check that it is a ControlInput*/
    52975352        if (input->ObjectEnum()!=ControlInputEnum){
    5298                 _error_("input %s is not a ControlInput",EnumToStringx(control_enum));
     5353                _error2_("input " << EnumToStringx(control_enum) << " is not a ControlInput");
    52995354        }
    53005355
     
    53025357}
    53035358/*}}}*/
    5304 /*FUNCTION Penta::SetControlInputsFromVector{{{1*/
    5305 void  Penta::SetControlInputsFromVector(double* vector,int control_enum,int control_index){
    5306 
    5307         double  values[NUMVERTICES];
     5359/*FUNCTION Penta::SetControlInputsFromVector{{{*/
     5360void  Penta::SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index){
     5361
     5362        IssmDouble  values[NUMVERTICES];
    53085363        int     doflist1[NUMVERTICES];
    53095364        Input  *input     = NULL;
     
    53315386
    53325387        if (input->ObjectEnum()!=ControlInputEnum){
    5333                 _error_("input %s is not a ControlInput",EnumToStringx(control_enum));
     5388                _error2_("input " << EnumToStringx(control_enum) << " is not a ControlInput");
    53345389        }
    53355390
     
    53405395
    53415396#ifdef _HAVE_DAKOTA_
    5342 /*FUNCTION Penta::InputUpdateFromVectorDakota(double* vector, int name, int type);{{{1*/
    5343 void  Penta::InputUpdateFromVectorDakota(double* vector, int name, int type){
     5397/*FUNCTION Penta::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);{{{*/
     5398void  Penta::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){
    53445399       
    53455400        int i,j;
     
    53535408
    53545409                        /*New PentaP1Input*/
    5355                         double values[6];
     5410                        IssmDouble values[6];
    53565411
    53575412                        /*Get values on the 6 vertices*/
     
    53635418                        switch(name){
    53645419                                case ThicknessEnum:
    5365                                         /*Update thickness + surface: assume bed is constant. On ice shelves, takes hydrostatic equilibrium {{{2*/
    5366                                         double  thickness[6];
    5367                                         double  thickness_init[6];
    5368                                         double  hydrostatic_ratio[6];
    5369                                         double  surface[6];
    5370                                         double  bed[6];
     5420                                        /*Update thickness + surface: assume bed is constant. On ice shelves, takes hydrostatic equilibrium {{{*/
     5421                                        IssmDouble  thickness[6];
     5422                                        IssmDouble  thickness_init[6];
     5423                                        IssmDouble  hydrostatic_ratio[6];
     5424                                        IssmDouble  surface[6];
     5425                                        IssmDouble  bed[6];
    53715426                                       
    53725427                                        /*retrieve inputs: */
     
    53825437                                        if (this->IsFloating()){
    53835438                                                /*hydrostatic equilibrium: */
    5384                                                 double rho_ice,rho_water,di;
     5439                                                IssmDouble rho_ice,rho_water,di;
    53855440                                                rho_ice=this->matpar->GetRhoIce();
    53865441                                                rho_water=this->matpar->GetRhoWater();
     
    54375492
    54385493                default:
    5439                         _error_("type %i (%s) not implemented yet",type,EnumToStringx(type));
    5440         }
    5441 
    5442 }
    5443 /*}}}*/
    5444 /*FUNCTION Penta::InputUpdateFromVectorDakota(int* vector, int name, int type);{{{1*/
     5494                        _error2_("type " << type << " (" << EnumToStringx(type) << ") not implemented yet");
     5495        }
     5496
     5497}
     5498/*}}}*/
     5499/*FUNCTION Penta::InputUpdateFromVectorDakota(int* vector, int name, int type);{{{*/
    54455500void  Penta::InputUpdateFromVectorDakota(int* vector, int name, int type){
    5446         _error_(" not supported yet!");
    5447 }
    5448 /*}}}*/
    5449 /*FUNCTION Penta::InputUpdateFromVectorDakota(bool* vector, int name, int type);{{{1*/
     5501        _error2_("not supported yet!");
     5502}
     5503/*}}}*/
     5504/*FUNCTION Penta::InputUpdateFromVectorDakota(bool* vector, int name, int type);{{{*/
    54505505void  Penta::InputUpdateFromVectorDakota(bool* vector, int name, int type){
    5451         _error_(" not supported yet!");
    5452 }
    5453 /*}}}*/
    5454 /*FUNCTION Penta::InputUpdateFromMatrixDakota(double* matrix, int nrows, int ncols, int name, int type);{{{1*/
    5455 void  Penta::InputUpdateFromMatrixDakota(double* matrix, int nrows, int ncols, int name, int type){
     5506        _error2_("not supported yet!");
     5507}
     5508/*}}}*/
     5509/*FUNCTION Penta::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type);{{{*/
     5510void  Penta::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type){
    54565511       
    54575512        int i,j,t;
    54585513        TransientInput* transientinput=NULL;
    5459         double values[6];
    5460         double time;
     5514        IssmDouble values[6];
     5515        IssmDouble time;
    54615516        int row;
    5462         double yts;
     5517        IssmDouble yts;
    54635518
    54645519        /*Check that name is an element input*/
     
    54785533                                for(i=0;i<6;i++){
    54795534                                        row=this->nodes[i]->GetSidList();
    5480                                         values[i]=(double)matrix[ncols*row+t];
     5535                                        values[i]=(IssmDouble)matrix[ncols*row+t];
    54815536                                }
    54825537
    54835538                                /*time? :*/
    5484                                 time=(double)matrix[(nrows-1)*ncols+t]*yts;
     5539                                time=(IssmDouble)matrix[(nrows-1)*ncols+t]*yts;
    54855540
    54865541                                if(t==0) transientinput=new TransientInput(name);
     
    54925547
    54935548                default:
    5494                         _error_("type %i (%s) not implemented yet",type,EnumToStringx(type));
     5549                        _error2_("type " << type << " (" << EnumToStringx(type) << ") not implemented yet");
    54955550        }
    54965551
     
    55005555
    55015556#ifdef _HAVE_DIAGNOSTIC_
    5502 /*FUNCTION Penta::CreateDVectorDiagnosticHoriz {{{1*/
     5557/*FUNCTION Penta::CreateDVectorDiagnosticHoriz {{{*/
    55035558ElementVector* Penta::CreateDVectorDiagnosticHoriz(void){
    55045559
     
    55145569}
    55155570/*}}}*/
    5516 /*FUNCTION Penta::CreateDVectorDiagnosticStokes{{{1*/
     5571/*FUNCTION Penta::CreateDVectorDiagnosticStokes{{{*/
    55175572ElementVector* Penta::CreateDVectorDiagnosticStokes(void){
    55185573
     
    55395594}
    55405595/*}}}*/
    5541 /*FUNCTION Penta::CreateKMatrixCouplingMacAyealPattyn{{{1*/
     5596/*FUNCTION Penta::CreateKMatrixCouplingMacAyealPattyn{{{*/
    55425597ElementMatrix* Penta::CreateKMatrixCouplingMacAyealPattyn(void){
    55435598       
     
    55535608}
    55545609/*}}}*/
    5555 /*FUNCTION Penta::CreateKMatrixCouplingMacAyealPattynViscous{{{1*/
     5610/*FUNCTION Penta::CreateKMatrixCouplingMacAyealPattynViscous{{{*/
    55565611ElementMatrix* Penta::CreateKMatrixCouplingMacAyealPattynViscous(void){
    55575612
     
    55645619        /*Intermediaries */
    55655620        int         i,j,ig;
    5566         double      Jdet;
    5567         double      viscosity,oldviscosity,newviscosity,viscosity_overshoot; //viscosity
    5568         double      epsilon[5],oldepsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
    5569         double      xyz_list[NUMVERTICES][3];
    5570         double      B[3][numdofp];
    5571         double      Bprime[3][numdofm];
    5572         double      D[3][3]={0.0};            // material matrix, simple scalar matrix.
    5573         double      D_scalar;
    5574         double      Ke_gg[numdofp][numdofm]={0.0}; //local element stiffness matrix
    5575         double      Ke_gg_gaussian[numdofp][numdofm]; //stiffness matrix evaluated at the gaussian point.
     5621        IssmDouble      Jdet;
     5622        IssmDouble      viscosity,oldviscosity,newviscosity,viscosity_overshoot; //viscosity
     5623        IssmDouble      epsilon[5],oldepsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
     5624        IssmDouble      xyz_list[NUMVERTICES][3];
     5625        IssmDouble      B[3][numdofp];
     5626        IssmDouble      Bprime[3][numdofm];
     5627        IssmDouble      D[3][3]={0.0};            // material matrix, simple scalar matrix.
     5628        IssmDouble      D_scalar;
     5629        IssmDouble      Ke_gg[numdofp][numdofm]={0.0}; //local element stiffness matrix
     5630        IssmDouble      Ke_gg_gaussian[numdofp][numdofm]; //stiffness matrix evaluated at the gaussian point.
    55765631        GaussPenta *gauss=NULL;
    55775632        GaussTria  *gauss_tria=NULL;
     
    56465701}
    56475702/*}}}*/
    5648 /*FUNCTION Penta::CreateKMatrixCouplingMacAyealPattynFriction{{{1*/
     5703/*FUNCTION Penta::CreateKMatrixCouplingMacAyealPattynFriction{{{*/
    56495704ElementMatrix* Penta::CreateKMatrixCouplingMacAyealPattynFriction(void){
    56505705
     
    56565711        /*Intermediaries */
    56575712        int       i,j,ig,analysis_type;
    5658         double    Jdet2d,slope_magnitude,alpha2;
    5659         double    xyz_list[NUMVERTICES][3];
    5660         double    xyz_list_tria[NUMVERTICES2D][3]={0.0};
    5661         double    slope[3]={0.0,0.0,0.0};
    5662         double    MAXSLOPE=.06; // 6 %
    5663         double    MOUNTAINKEXPONENT=10;
    5664         double    L[2][numdof];
    5665         double    DL[2][2]                  ={{ 0,0 },{0,0}}; //for basal drag
    5666         double    DL_scalar;
    5667         double    Ke_gg[numdof][numdof]     ={0.0};
    5668         double    Ke_gg_gaussian[numdof][numdof]; //stiffness matrix contribution from drag
     5713        IssmDouble    Jdet2d,slope_magnitude,alpha2;
     5714        IssmDouble    xyz_list[NUMVERTICES][3];
     5715        IssmDouble    xyz_list_tria[NUMVERTICES2D][3]={0.0};
     5716        IssmDouble    slope[3]={0.0,0.0,0.0};
     5717        IssmDouble    MAXSLOPE=.06; // 6 %
     5718        IssmDouble    MOUNTAINKEXPONENT=10;
     5719        IssmDouble    L[2][numdof];
     5720        IssmDouble    DL[2][2]                  ={{ 0,0 },{0,0}}; //for basal drag
     5721        IssmDouble    DL_scalar;
     5722        IssmDouble    Ke_gg[numdof][numdof]     ={0.0};
     5723        IssmDouble    Ke_gg_gaussian[numdof][numdof]; //stiffness matrix contribution from drag
    56695724        Friction  *friction = NULL;
    56705725        GaussPenta *gauss=NULL;
     
    57145769
    57155770                if (slope_magnitude>MAXSLOPE){
    5716                         alpha2=pow((double)10,MOUNTAINKEXPONENT);
     5771                        alpha2=pow((IssmDouble)10,MOUNTAINKEXPONENT);
    57175772                }
    57185773
     
    57445799}
    57455800/*}}}*/
    5746 /*FUNCTION Penta::CreateKMatrixCouplingMacAyealStokes{{{1*/
     5801/*FUNCTION Penta::CreateKMatrixCouplingMacAyealStokes{{{*/
    57475802ElementMatrix* Penta::CreateKMatrixCouplingMacAyealStokes(void){
    57485803
     
    57585813}
    57595814/*}}}*/
    5760 /*FUNCTION Penta::CreateKMatrixCouplingMacAyealStokesViscous{{{1*/
     5815/*FUNCTION Penta::CreateKMatrixCouplingMacAyealStokesViscous{{{*/
    57615816ElementMatrix* Penta::CreateKMatrixCouplingMacAyealStokesViscous(void){
    57625817
     
    57695824        /*Intermediaries */
    57705825        int         i,j,ig;
    5771         double      Jdet;
    5772         double      viscosity,stokesreconditioning; //viscosity
    5773         double      epsilon[6]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
    5774         double      xyz_list[NUMVERTICES][3];
    5775         double      B[4][numdofs+3];
    5776         double      Bprime[4][numdofm];
    5777         double      B2[3][numdofm];
    5778         double      Bprime2[3][numdofs+3];
    5779         double      D[4][4]={0.0};            // material matrix, simple scalar matrix.
    5780         double      D2[3][3]={0.0};            // material matrix, simple scalar matrix.
    5781         double      D_scalar;
    5782         double      Ke_gg[numdofs][numdofm]={0.0}; //local element stiffness matrix
    5783         double      Ke_gg2[numdofm][numdofs]={0.0}; //local element stiffness matrix
    5784         double      Ke_gg_gaussian[numdofs+3][numdofm]; //stiffness matrix evaluated at the gaussian point.
    5785         double      Ke_gg_gaussian2[numdofm][numdofs+3]; //stiffness matrix evaluated at the gaussian point.
     5826        IssmDouble      Jdet;
     5827        IssmDouble      viscosity,stokesreconditioning; //viscosity
     5828        IssmDouble      epsilon[6]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
     5829        IssmDouble      xyz_list[NUMVERTICES][3];
     5830        IssmDouble      B[4][numdofs+3];
     5831        IssmDouble      Bprime[4][numdofm];
     5832        IssmDouble      B2[3][numdofm];
     5833        IssmDouble      Bprime2[3][numdofs+3];
     5834        IssmDouble      D[4][4]={0.0};            // material matrix, simple scalar matrix.
     5835        IssmDouble      D2[3][3]={0.0};            // material matrix, simple scalar matrix.
     5836        IssmDouble      D_scalar;
     5837        IssmDouble      Ke_gg[numdofs][numdofm]={0.0}; //local element stiffness matrix
     5838        IssmDouble      Ke_gg2[numdofm][numdofs]={0.0}; //local element stiffness matrix
     5839        IssmDouble      Ke_gg_gaussian[numdofs+3][numdofm]; //stiffness matrix evaluated at the gaussian point.
     5840        IssmDouble      Ke_gg_gaussian2[numdofm][numdofs+3]; //stiffness matrix evaluated at the gaussian point.
    57865841        GaussPenta *gauss=NULL;
    57875842        GaussTria  *gauss_tria=NULL;
     
    58625917}
    58635918/*}}}*/
    5864 /*FUNCTION Penta::CreateKMatrixCouplingMacAyealStokesFriction {{{1*/
     5919/*FUNCTION Penta::CreateKMatrixCouplingMacAyealStokesFriction {{{*/
    58655920ElementMatrix* Penta::CreateKMatrixCouplingMacAyealStokesFriction(void){
    58665921
     
    58765931        int        i,j,ig;
    58775932        int        analysis_type,approximation;
    5878         double     stokesreconditioning;
    5879         double     viscosity,alpha2_gauss,Jdet2d;
    5880         double    bed_normal[3];
    5881         double     epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
    5882         double     xyz_list[NUMVERTICES][3];
    5883         double    xyz_list_tria[NUMVERTICES2D][3];
    5884         double     LMacAyealStokes[8][numdof2dm];
    5885         double     LprimeMacAyealStokes[8][numdof2d];
    5886         double     DLMacAyealStokes[8][8]={0.0};
    5887         double     LStokesMacAyeal[4][numdof2d];
    5888         double     LprimeStokesMacAyeal[4][numdof2dm];
    5889         double     DLStokesMacAyeal[4][4]={0.0};
    5890         double     Ke_drag_gaussian[numdof2dm][numdof2d];
    5891         double     Ke_drag_gaussian2[numdof2d][numdof2dm];
     5933        IssmDouble     stokesreconditioning;
     5934        IssmDouble     viscosity,alpha2_gauss,Jdet2d;
     5935        IssmDouble        bed_normal[3];
     5936        IssmDouble     epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
     5937        IssmDouble     xyz_list[NUMVERTICES][3];
     5938        IssmDouble        xyz_list_tria[NUMVERTICES2D][3];
     5939        IssmDouble     LMacAyealStokes[8][numdof2dm];
     5940        IssmDouble     LprimeMacAyealStokes[8][numdof2d];
     5941        IssmDouble     DLMacAyealStokes[8][8]={0.0};
     5942        IssmDouble     LStokesMacAyeal[4][numdof2d];
     5943        IssmDouble     LprimeStokesMacAyeal[4][numdof2dm];
     5944        IssmDouble     DLStokesMacAyeal[4][4]={0.0};
     5945        IssmDouble     Ke_drag_gaussian[numdof2dm][numdof2d];
     5946        IssmDouble     Ke_drag_gaussian2[numdof2d][numdof2dm];
    58925947        Friction*  friction=NULL;
    58935948        GaussPenta *gauss=NULL;
     
    59786033}
    59796034/*}}}*/
    5980 /*FUNCTION Penta::CreateKMatrixCouplingPattynStokes{{{1*/
     6035/*FUNCTION Penta::CreateKMatrixCouplingPattynStokes{{{*/
    59816036ElementMatrix* Penta::CreateKMatrixCouplingPattynStokes(void){
    59826037
     
    60276082}
    60286083/*}}}*/
    6029 /*FUNCTION Penta::CreateKMatrixDiagnosticHoriz {{{1*/
     6084/*FUNCTION Penta::CreateKMatrixDiagnosticHoriz {{{*/
    60306085ElementMatrix* Penta::CreateKMatrixDiagnosticHoriz(void){
    60316086
     
    60516106                        return CreateKMatrixDiagnosticPattynStokes();
    60526107                default:
    6053                         _error_("Approximation %s not supported yet",EnumToStringx(approximation));
    6054         }
    6055 }
    6056 /*}}}*/
    6057 /*FUNCTION Penta::CreateKMatrixDiagnosticHutter{{{1*/
     6108                        _error2_("Approximation " << EnumToStringx(approximation) << " not supported yet");
     6109        }
     6110}
     6111/*}}}*/
     6112/*FUNCTION Penta::CreateKMatrixDiagnosticHutter{{{*/
    60586113ElementMatrix* Penta::CreateKMatrixDiagnosticHutter(void){
    60596114
     
    60646119        int       connectivity[2];
    60656120        int       i,i0,i1,j0,j1;
    6066         double    one0,one1;
     6121        IssmDouble    one0,one1;
    60676122
    60686123        /*Initialize Element matrix*/
     
    60816136                connectivity[0]=nodes[i]->GetConnectivity();
    60826137                connectivity[1]=nodes[i+3]->GetConnectivity();
    6083                 one0=1/(double)connectivity[0];
    6084                 one1=1/(double)connectivity[1];
     6138                one0=1/(IssmDouble)connectivity[0];
     6139                one1=1/(IssmDouble)connectivity[1];
    60856140
    60866141                /*Create matrix for these two nodes*/
     
    61176172        /*Clean up and return*/
    61186173        return Ke;
    6119 }
    6120 /*FUNCTION Penta::CreateKMatrixDiagnosticMacAyeal2d{{{1*/
     6174}/*}}}*/
     6175/*FUNCTION Penta::CreateKMatrixDiagnosticMacAyeal2d{{{*/
    61216176ElementMatrix* Penta::CreateKMatrixDiagnosticMacAyeal2d(void){
    61226177
     
    61416196}
    61426197/*}}}*/
    6143 /*FUNCTION Penta::CreateKMatrixDiagnosticMacAyeal3d{{{1*/
     6198/*FUNCTION Penta::CreateKMatrixDiagnosticMacAyeal3d{{{*/
    61446199ElementMatrix* Penta::CreateKMatrixDiagnosticMacAyeal3d(void){
    61456200
     
    61556210}
    61566211/*}}}*/
    6157 /*FUNCTION Penta::CreateKMatrixDiagnosticMacAyeal3dViscous{{{1*/
     6212/*FUNCTION Penta::CreateKMatrixDiagnosticMacAyeal3dViscous{{{*/
    61586213ElementMatrix* Penta::CreateKMatrixDiagnosticMacAyeal3dViscous(void){
    61596214
     
    61636218        /*Intermediaries */
    61646219        int         i,j,ig,approximation;
    6165         double      Jdet;
    6166         double      viscosity, oldviscosity, newviscosity, viscosity_overshoot;
    6167         double      epsilon[5],oldepsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
    6168         double      epsilons[6]; //6 for stokes
    6169         double      xyz_list[NUMVERTICES][3];
    6170         double      B[3][numdof2d];
    6171         double      Bprime[3][numdof2d];
    6172         double      D[3][3]={0.0};            // material matrix, simple scalar matrix.
    6173         double      D_scalar;
    6174         double      Ke_gg_gaussian[numdof2d][numdof2d]; //stiffness matrix evaluated at the gaussian point.
     6220        IssmDouble      Jdet;
     6221        IssmDouble      viscosity, oldviscosity, newviscosity, viscosity_overshoot;
     6222        IssmDouble      epsilon[5],oldepsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
     6223        IssmDouble      epsilons[6]; //6 for stokes
     6224        IssmDouble      xyz_list[NUMVERTICES][3];
     6225        IssmDouble      B[3][numdof2d];
     6226        IssmDouble      Bprime[3][numdof2d];
     6227        IssmDouble      D[3][3]={0.0};            // material matrix, simple scalar matrix.
     6228        IssmDouble      D_scalar;
     6229        IssmDouble      Ke_gg_gaussian[numdof2d][numdof2d]; //stiffness matrix evaluated at the gaussian point.
    61756230        Tria*       tria=NULL;
    61766231        Penta*      pentabase=NULL;
     
    62196274                        matice->GetViscosity3dStokes(&newviscosity,&epsilons[0]);
    62206275                }
    6221                 else _error_("approximation %i (%s) not supported yet",approximation,EnumToStringx(approximation));
     6276                else _error2_("approximation " << approximation << " (" << EnumToStringx(approximation) << ") not supported yet");
    62226277
    62236278                D_scalar=2*newviscosity*gauss->weight*Jdet;
     
    62436298}
    62446299/*}}}*/
    6245 /*FUNCTION Penta::CreateKMatrixDiagnosticMacAyeal3dFriction{{{1*/
     6300/*FUNCTION Penta::CreateKMatrixDiagnosticMacAyeal3dFriction{{{*/
    62466301ElementMatrix* Penta::CreateKMatrixDiagnosticMacAyeal3dFriction(void){
    62476302
     
    62606315}
    62616316/*}}}*/
    6262 /*FUNCTION Penta::CreateKMatrixDiagnosticMacAyealPattyn{{{1*/
     6317/*FUNCTION Penta::CreateKMatrixDiagnosticMacAyealPattyn{{{*/
    62636318ElementMatrix* Penta::CreateKMatrixDiagnosticMacAyealPattyn(void){
    62646319
     
    62766331}
    62776332/*}}}*/
    6278 /*FUNCTION Penta::CreateKMatrixDiagnosticMacAyealStokes{{{1*/
     6333/*FUNCTION Penta::CreateKMatrixDiagnosticMacAyealStokes{{{*/
    62796334ElementMatrix* Penta::CreateKMatrixDiagnosticMacAyealStokes(void){
    62806335
     
    62926347}
    62936348/*}}}*/
    6294 /*FUNCTION Penta::CreateKMatrixDiagnosticPattyn{{{1*/
     6349/*FUNCTION Penta::CreateKMatrixDiagnosticPattyn{{{*/
    62956350ElementMatrix* Penta::CreateKMatrixDiagnosticPattyn(void){
    62966351
     
    63076362}
    63086363/*}}}*/
    6309 /*FUNCTION Penta::CreateKMatrixDiagnosticPattynViscous{{{1*/
     6364/*FUNCTION Penta::CreateKMatrixDiagnosticPattynViscous{{{*/
    63106365ElementMatrix* Penta::CreateKMatrixDiagnosticPattynViscous(void){
    63116366
     
    63166371        int        i,j,ig;
    63176372        int        approximation;
    6318         double     xyz_list[NUMVERTICES][3];
    6319         double     Jdet;
    6320         double     viscosity,oldviscosity,newviscosity,viscosity_overshoot; //viscosity
    6321         double     epsilon[5],oldepsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
    6322         double     D_scalar;
    6323         double     D[5][5]={0.0};            // material matrix, simple scalar matrix.
    6324         double     B[5][numdof];
    6325         double     Bprime[5][numdof];
     6373        IssmDouble     xyz_list[NUMVERTICES][3];
     6374        IssmDouble     Jdet;
     6375        IssmDouble     viscosity,oldviscosity,newviscosity,viscosity_overshoot; //viscosity
     6376        IssmDouble     epsilon[5],oldepsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
     6377        IssmDouble     D_scalar;
     6378        IssmDouble     D[5][5]={0.0};            // material matrix, simple scalar matrix.
     6379        IssmDouble     B[5][numdof];
     6380        IssmDouble     Bprime[5][numdof];
    63266381        Tria*      tria=NULL;
    63276382        GaussPenta *gauss=NULL;
     
    63726427}
    63736428/*}}}*/
    6374 /*FUNCTION Penta::CreateKMatrixDiagnosticPattynFriction{{{1*/
     6429/*FUNCTION Penta::CreateKMatrixDiagnosticPattynFriction{{{*/
    63756430ElementMatrix* Penta::CreateKMatrixDiagnosticPattynFriction(void){
    63766431
     
    63816436        int       i,j,ig;
    63826437        int       analysis_type;
    6383         double    xyz_list[NUMVERTICES][3];
    6384         double    xyz_list_tria[NUMVERTICES2D][3]={0.0};
    6385         double    slope_magnitude,alpha2,Jdet;
    6386         double    slope[3]={0.0,0.0,0.0};
    6387         double    MAXSLOPE=.06; // 6 %
    6388         double    MOUNTAINKEXPONENT=10;
    6389         double    L[2][numdof];
    6390         double    DL[2][2]={{ 0,0 },{0,0}}; //for basal drag
    6391         double    DL_scalar;
     6438        IssmDouble    xyz_list[NUMVERTICES][3];
     6439        IssmDouble    xyz_list_tria[NUMVERTICES2D][3]={0.0};
     6440        IssmDouble    slope_magnitude,alpha2,Jdet;
     6441        IssmDouble    slope[3]={0.0,0.0,0.0};
     6442        IssmDouble    MAXSLOPE=.06; // 6 %
     6443        IssmDouble    MOUNTAINKEXPONENT=10;
     6444        IssmDouble    L[2][numdof];
     6445        IssmDouble    DL[2][2]={{ 0,0 },{0,0}}; //for basal drag
     6446        IssmDouble    DL_scalar;
    63926447        Friction  *friction = NULL;
    63936448        GaussPenta *gauss=NULL;
     
    64266481                //velocity should be = 0. To achieve this result, we set alpha2_list to a very high value: */
    64276482                if (slope_magnitude>MAXSLOPE){
    6428                         alpha2=pow((double)10,MOUNTAINKEXPONENT);
     6483                        alpha2=pow((IssmDouble)10,MOUNTAINKEXPONENT);
    64296484                }
    64306485               
     
    64476502}
    64486503/*}}}*/
    6449 /*FUNCTION Penta::CreateKMatrixDiagnosticPattynStokes{{{1*/
     6504/*FUNCTION Penta::CreateKMatrixDiagnosticPattynStokes{{{*/
    64506505ElementMatrix* Penta::CreateKMatrixDiagnosticPattynStokes(void){
    64516506
     
    64636518}
    64646519/*}}}*/
    6465 /*FUNCTION Penta::CreateKMatrixDiagnosticStokes{{{1*/
     6520/*FUNCTION Penta::CreateKMatrixDiagnosticStokes{{{*/
    64666521ElementMatrix* Penta::CreateKMatrixDiagnosticStokes(void){
    64676522
     
    64776532}
    64786533/*}}}*/
    6479 /*FUNCTION Penta::CreateKMatrixDiagnosticStokesViscous {{{1*/
     6534/*FUNCTION Penta::CreateKMatrixDiagnosticStokesViscous {{{*/
    64806535ElementMatrix* Penta::CreateKMatrixDiagnosticStokesViscous(void){
    64816536
    64826537        /*Intermediaries */
    64836538        int        i,j,ig,approximation;
    6484         double     Jdet,viscosity,stokesreconditioning;
    6485         double     xyz_list[NUMVERTICES][3];
    6486         double     epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
    6487         double     B[8][27];
    6488         double     B_prime[8][27];
    6489         double     D_scalar;
    6490         double     D[8][8]={0.0};
    6491         double     Ke_temp[27][27]={0.0}; //for the six nodes and the bubble
     6539        IssmDouble     Jdet,viscosity,stokesreconditioning;
     6540        IssmDouble     xyz_list[NUMVERTICES][3];
     6541        IssmDouble     epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
     6542        IssmDouble     B[8][27];
     6543        IssmDouble     B_prime[8][27];
     6544        IssmDouble     D_scalar;
     6545        IssmDouble     D[8][8]={0.0};
     6546        IssmDouble     Ke_temp[27][27]={0.0}; //for the six nodes and the bubble
    64926547        GaussPenta *gauss=NULL;
    64936548
     
    65386593}
    65396594/*}}}*/
    6540 /*FUNCTION Penta::CreateKMatrixDiagnosticStokesFriction{{{1*/
     6595/*FUNCTION Penta::CreateKMatrixDiagnosticStokesFriction{{{*/
    65416596ElementMatrix* Penta::CreateKMatrixDiagnosticStokesFriction(void){
    65426597
     
    65486603        int        i,j,ig;
    65496604        int        analysis_type,approximation;
    6550         double     alpha2,Jdet2d;
    6551         double     stokesreconditioning,viscosity;
    6552         double     epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
    6553         double     xyz_list[NUMVERTICES][3];
    6554         double    xyz_list_tria[NUMVERTICES2D][3];
    6555         double     LStokes[2][numdof2d];
    6556         double     DLStokes[2][2]={0.0};
    6557         double     Ke_drag_gaussian[numdof2d][numdof2d];
     6605        IssmDouble     alpha2,Jdet2d;
     6606        IssmDouble     stokesreconditioning,viscosity;
     6607        IssmDouble     epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
     6608        IssmDouble     xyz_list[NUMVERTICES][3];
     6609        IssmDouble        xyz_list_tria[NUMVERTICES2D][3];
     6610        IssmDouble     LStokes[2][numdof2d];
     6611        IssmDouble     DLStokes[2][2]={0.0};
     6612        IssmDouble     Ke_drag_gaussian[numdof2d][numdof2d];
    65586613        Friction*  friction=NULL;
    65596614        GaussPenta *gauss=NULL;
     
    66106665}
    66116666/*}}}*/
    6612 /*FUNCTION Penta::CreateKMatrixDiagnosticVert {{{1*/
     6667/*FUNCTION Penta::CreateKMatrixDiagnosticVert {{{*/
    66136668ElementMatrix* Penta::CreateKMatrixDiagnosticVert(void){
    66146669       
     
    66256680}
    66266681/*}}}*/
    6627 /*FUNCTION Penta::CreateKMatrixDiagnosticVertVolume {{{1*/
     6682/*FUNCTION Penta::CreateKMatrixDiagnosticVertVolume {{{*/
    66286683ElementMatrix* Penta::CreateKMatrixDiagnosticVertVolume(void){
    66296684
     
    66336688        /*Intermediaries */
    66346689        int         i,j,ig;
    6635         double      Jdet;
    6636         double      xyz_list[NUMVERTICES][3];
    6637         double      B[NDOF1][NUMVERTICES];
    6638         double      Bprime[NDOF1][NUMVERTICES];
    6639         double      DL_scalar;
     6690        IssmDouble      Jdet;
     6691        IssmDouble      xyz_list[NUMVERTICES][3];
     6692        IssmDouble      B[NDOF1][NUMVERTICES];
     6693        IssmDouble      Bprime[NDOF1][NUMVERTICES];
     6694        IssmDouble      DL_scalar;
    66406695        GaussPenta  *gauss=NULL;
    66416696
     
    66696724}
    66706725/*}}}*/
    6671 /*FUNCTION Penta::CreateKMatrixDiagnosticVertSurface {{{1*/
     6726/*FUNCTION Penta::CreateKMatrixDiagnosticVertSurface {{{*/
    66726727ElementMatrix* Penta::CreateKMatrixDiagnosticVertSurface(void){
    66736728
     
    66796734        /*Intermediaries */
    66806735        int       i,j,ig;
    6681         double    xyz_list[NUMVERTICES][3];
    6682         double    xyz_list_tria[NUMVERTICES2D][3];
    6683         double    surface_normal[3];
    6684         double    Jdet2d,DL_scalar;
    6685         double    basis[NUMVERTICES];
     6736        IssmDouble    xyz_list[NUMVERTICES][3];
     6737        IssmDouble    xyz_list_tria[NUMVERTICES2D][3];
     6738        IssmDouble    surface_normal[3];
     6739        IssmDouble    Jdet2d,DL_scalar;
     6740        IssmDouble    basis[NUMVERTICES];
    66866741        GaussPenta *gauss=NULL;
    66876742
     
    67166771}
    67176772/*}}}*/
    6718 /*FUNCTION Penta::CreatePVectorCouplingMacAyealStokes {{{1*/
     6773/*FUNCTION Penta::CreatePVectorCouplingMacAyealStokes {{{*/
    67196774ElementVector* Penta::CreatePVectorCouplingMacAyealStokes(void){
    67206775
     
    67306785}
    67316786/*}}}*/
    6732 /*FUNCTION Penta::CreatePVectorCouplingMacAyealStokesViscous {{{1*/
     6787/*FUNCTION Penta::CreatePVectorCouplingMacAyealStokesViscous {{{*/
    67336788ElementVector* Penta::CreatePVectorCouplingMacAyealStokesViscous(void){
    67346789
     
    67396794        int         i,j,ig;
    67406795        int         approximation;
    6741         double      viscosity,Jdet;
    6742         double      stokesreconditioning;
    6743         double      epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
    6744         double      dw[3];
    6745         double      xyz_list[NUMVERTICES][3];
    6746         double      basis[6]; //for the six nodes of the penta
    6747         double      dbasis[3][6]; //for the six nodes of the penta
     6796        IssmDouble      viscosity,Jdet;
     6797        IssmDouble      stokesreconditioning;
     6798        IssmDouble      epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
     6799        IssmDouble      dw[3];
     6800        IssmDouble      xyz_list[NUMVERTICES][3];
     6801        IssmDouble      basis[6]; //for the six nodes of the penta
     6802        IssmDouble      dbasis[3][6]; //for the six nodes of the penta
    67486803        GaussPenta *gauss=NULL;
    67496804
     
    67926847}
    67936848/*}}}*/
    6794 /*FUNCTION Penta::CreatePVectorCouplingMacAyealStokesFriction{{{1*/
     6849/*FUNCTION Penta::CreatePVectorCouplingMacAyealStokesFriction{{{*/
    67956850ElementVector* Penta::CreatePVectorCouplingMacAyealStokesFriction(void){
    67966851
     
    68016856        int         i,j,ig;
    68026857        int         approximation,analysis_type;
    6803         double      Jdet,Jdet2d;
    6804         double      stokesreconditioning;
    6805         double     bed_normal[3];
    6806         double      epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
    6807         double      viscosity, w, alpha2_gauss;
    6808         double      dw[3];
    6809         double     xyz_list_tria[NUMVERTICES2D][3];
    6810         double      xyz_list[NUMVERTICES][3];
    6811         double      basis[6]; //for the six nodes of the penta
     6858        IssmDouble      Jdet,Jdet2d;
     6859        IssmDouble      stokesreconditioning;
     6860        IssmDouble         bed_normal[3];
     6861        IssmDouble      epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
     6862        IssmDouble      viscosity, w, alpha2_gauss;
     6863        IssmDouble      dw[3];
     6864        IssmDouble         xyz_list_tria[NUMVERTICES2D][3];
     6865        IssmDouble      xyz_list[NUMVERTICES][3];
     6866        IssmDouble      basis[6]; //for the six nodes of the penta
    68126867        Tria*       tria=NULL;
    68136868        Friction*   friction=NULL;
     
    68676922}
    68686923/*}}}*/
    6869 /*FUNCTION Penta::CreatePVectorCouplingPattynStokes {{{1*/
     6924/*FUNCTION Penta::CreatePVectorCouplingPattynStokes {{{*/
    68706925ElementVector* Penta::CreatePVectorCouplingPattynStokes(void){
    68716926
     
    68816936}
    68826937/*}}}*/
    6883 /*FUNCTION Penta::CreatePVectorCouplingPattynStokesViscous {{{1*/
     6938/*FUNCTION Penta::CreatePVectorCouplingPattynStokesViscous {{{*/
    68846939ElementVector* Penta::CreatePVectorCouplingPattynStokesViscous(void){
    68856940
     
    68906945        int         i,j,ig;
    68916946        int         approximation;
    6892         double      viscosity,Jdet;
    6893         double      stokesreconditioning;
    6894         double      epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
    6895         double      dw[3];
    6896         double      xyz_list[NUMVERTICES][3];
    6897         double      basis[6]; //for the six nodes of the penta
    6898         double      dbasis[3][6]; //for the six nodes of the penta
     6947        IssmDouble      viscosity,Jdet;
     6948        IssmDouble      stokesreconditioning;
     6949        IssmDouble      epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
     6950        IssmDouble      dw[3];
     6951        IssmDouble      xyz_list[NUMVERTICES][3];
     6952        IssmDouble      basis[6]; //for the six nodes of the penta
     6953        IssmDouble      dbasis[3][6]; //for the six nodes of the penta
    68996954        GaussPenta *gauss=NULL;
    69006955
     
    69436998}
    69446999/*}}}*/
    6945 /*FUNCTION Penta::CreatePVectorCouplingPattynStokesFriction{{{1*/
     7000/*FUNCTION Penta::CreatePVectorCouplingPattynStokesFriction{{{*/
    69467001ElementVector* Penta::CreatePVectorCouplingPattynStokesFriction(void){
    69477002
     
    69527007        int         i,j,ig;
    69537008        int         approximation,analysis_type;
    6954         double      Jdet,Jdet2d;
    6955         double      stokesreconditioning;
    6956         double     bed_normal[3];
    6957         double      epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
    6958         double      viscosity, w, alpha2_gauss;
    6959         double      dw[3];
    6960         double     xyz_list_tria[NUMVERTICES2D][3];
    6961         double      xyz_list[NUMVERTICES][3];
    6962         double      basis[6]; //for the six nodes of the penta
     7009        IssmDouble      Jdet,Jdet2d;
     7010        IssmDouble      stokesreconditioning;
     7011        IssmDouble         bed_normal[3];
     7012        IssmDouble      epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
     7013        IssmDouble      viscosity, w, alpha2_gauss;
     7014        IssmDouble      dw[3];
     7015        IssmDouble         xyz_list_tria[NUMVERTICES2D][3];
     7016        IssmDouble      xyz_list[NUMVERTICES][3];
     7017        IssmDouble      basis[6]; //for the six nodes of the penta
    69637018        Tria*       tria=NULL;
    69647019        Friction*   friction=NULL;
     
    70187073}
    70197074/*}}}*/
    7020 /*FUNCTION Penta::CreatePVectorDiagnosticHoriz{{{1*/
     7075/*FUNCTION Penta::CreatePVectorDiagnosticHoriz{{{*/
    70217076ElementVector* Penta::CreatePVectorDiagnosticHoriz(void){
    70227077
     
    70427097                        return CreatePVectorDiagnosticPattynStokes();
    70437098                default:
    7044                         _error_("Approximation %s not supported yet",EnumToStringx(approximation));
    7045         }
    7046 }
    7047 /*}}}*/
    7048 /*FUNCTION Penta::CreatePVectorDiagnosticMacAyealPattyn{{{1*/
     7099                        _error2_("Approximation " << EnumToStringx(approximation) << " not supported yet");
     7100        }
     7101}
     7102/*}}}*/
     7103/*FUNCTION Penta::CreatePVectorDiagnosticMacAyealPattyn{{{*/
    70497104ElementVector* Penta::CreatePVectorDiagnosticMacAyealPattyn(void){
    70507105
     
    70607115}
    70617116/*}}}*/
    7062 /*FUNCTION Penta::CreatePVectorDiagnosticMacAyealStokes{{{1*/
     7117/*FUNCTION Penta::CreatePVectorDiagnosticMacAyealStokes{{{*/
    70637118ElementVector* Penta::CreatePVectorDiagnosticMacAyealStokes(void){
    70647119
     
    70767131}
    70777132/*}}}*/
    7078 /*FUNCTION Penta::CreatePVectorDiagnosticPattynStokes{{{1*/
     7133/*FUNCTION Penta::CreatePVectorDiagnosticPattynStokes{{{*/
    70797134ElementVector* Penta::CreatePVectorDiagnosticPattynStokes(void){
    70807135
     
    70927147}
    70937148/*}}}*/
    7094 /*FUNCTION Penta::CreatePVectorDiagnosticHutter{{{1*/
     7149/*FUNCTION Penta::CreatePVectorDiagnosticHutter{{{*/
    70957150ElementVector* Penta::CreatePVectorDiagnosticHutter(void){
    70967151
     
    71027157        int          node0,node1;
    71037158        int          connectivity[2];
    7104         double       Jdet;
    7105         double       xyz_list[NUMVERTICES][3];
    7106         double       xyz_list_segment[2][3];
    7107         double       z_list[NUMVERTICES];
    7108         double       z_segment[2],slope[2];
    7109         double       slope2,constant_part;
    7110         double       rho_ice,gravity,n,B;
    7111         double       ub,vb,z_g,surface,thickness;
     7159        IssmDouble       Jdet;
     7160        IssmDouble       xyz_list[NUMVERTICES][3];
     7161        IssmDouble       xyz_list_segment[2][3];
     7162        IssmDouble       z_list[NUMVERTICES];
     7163        IssmDouble       z_segment[2],slope[2];
     7164        IssmDouble       slope2,constant_part;
     7165        IssmDouble       rho_ice,gravity,n,B;
     7166        IssmDouble       ub,vb,z_g,surface,thickness;
    71127167        GaussPenta*  gauss=NULL;
    71137168
     
    71577212
    71587213                        if (IsOnSurface()){
    7159                                 for(j=0;j<NDOF2;j++) pe->values[2*node1+j]+=constant_part*pow((surface-z_g)/B,n)*slope[j]*Jdet*gauss->weight/(double)connectivity[1];
     7214                                for(j=0;j<NDOF2;j++) pe->values[2*node1+j]+=constant_part*pow((surface-z_g)/B,n)*slope[j]*Jdet*gauss->weight/(IssmDouble)connectivity[1];
    71607215                        }
    71617216                        else{//connectivity is too large, should take only half on it
    7162                                 for(j=0;j<NDOF2;j++) pe->values[2*node1+j]+=constant_part*pow((surface-z_g)/B,n)*slope[j]*Jdet*gauss->weight*2/(double)connectivity[1];
     7217                                for(j=0;j<NDOF2;j++) pe->values[2*node1+j]+=constant_part*pow((surface-z_g)/B,n)*slope[j]*Jdet*gauss->weight*2/(IssmDouble)connectivity[1];
    71637218                        }
    71647219                }
     
    71677222                //Deal with lower surface
    71687223                if (IsOnBed()){
    7169                         constant_part=-1.58*pow((double)10.0,-(double)10.0)*rho_ice*gravity*thickness;
     7224                        constant_part=-1.58*pow((IssmDouble)10.0,-(IssmDouble)10.0)*rho_ice*gravity*thickness;
    71707225                        ub=constant_part*slope[0];
    71717226                        vb=constant_part*slope[1];
    71727227
    7173                         pe->values[2*node0]+=ub/(double)connectivity[0];
    7174                         pe->values[2*node0+1]+=vb/(double)connectivity[0];
     7228                        pe->values[2*node0]+=ub/(IssmDouble)connectivity[0];
     7229                        pe->values[2*node0+1]+=vb/(IssmDouble)connectivity[0];
    71757230                }
    71767231        }
     
    71807235}
    71817236/*}}}*/
    7182 /*FUNCTION Penta::CreatePVectorDiagnosticMacAyeal{{{1*/
     7237/*FUNCTION Penta::CreatePVectorDiagnosticMacAyeal{{{*/
    71837238ElementVector* Penta::CreatePVectorDiagnosticMacAyeal(void){
    71847239
     
    71947249}
    71957250/*}}}*/
    7196 /*FUNCTION Penta::CreatePVectorDiagnosticPattyn{{{1*/
     7251/*FUNCTION Penta::CreatePVectorDiagnosticPattyn{{{*/
    71977252ElementVector* Penta::CreatePVectorDiagnosticPattyn(void){
    71987253
     
    72027257        /*Intermediaries*/
    72037258        int         i,j,ig;
    7204         double      Jdet;
    7205         double      slope[3]; //do not put 2! this goes into GetInputDerivativeValue, which addresses slope[3] also!
    7206         double      driving_stress_baseline,thickness;
    7207         double      xyz_list[NUMVERTICES][3];
    7208         double      basis[6];
     7259        IssmDouble      Jdet;
     7260        IssmDouble      slope[3]; //do not put 2! this goes into GetInputDerivativeValue, which addresses slope[3] also!
     7261        IssmDouble      driving_stress_baseline,thickness;
     7262        IssmDouble      xyz_list[NUMVERTICES][3];
     7263        IssmDouble      basis[6];
    72097264        GaussPenta  *gauss=NULL;
    72107265
     
    72427297}
    72437298/*}}}*/
    7244 /*FUNCTION Penta::CreatePVectorDiagnosticStokes {{{1*/
     7299/*FUNCTION Penta::CreatePVectorDiagnosticStokes {{{*/
    72457300ElementVector* Penta::CreatePVectorDiagnosticStokes(void){
    72467301
     
    72567311}
    72577312/*}}}*/
    7258 /*FUNCTION Penta::CreatePVectorDiagnosticStokesViscous {{{1*/
     7313/*FUNCTION Penta::CreatePVectorDiagnosticStokesViscous {{{*/
    72597314ElementVector* Penta::CreatePVectorDiagnosticStokesViscous(void){
    72607315
     
    72657320        int        i,j,ig;
    72667321        int        approximation;
    7267         double     Jdet,viscosity;
    7268         double     gravity,rho_ice,stokesreconditioning;
    7269         double     xyz_list[NUMVERTICES][3];
    7270         double     epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
    7271         double     l1l7[7]; //for the six nodes and the bubble
    7272         double     B[8][numdofbubble];
    7273         double     B_prime[8][numdofbubble];
    7274         double     B_prime_bubble[8][3];
    7275         double     D[8][8]={0.0};
    7276         double     D_scalar;
    7277         double     Pe_gaussian[numdofbubble]={0.0}; //for the six nodes and the bubble
    7278         double     Ke_temp[numdofbubble][3]={0.0}; //for the six nodes and the bubble
    7279         double     Ke_gaussian[numdofbubble][3];
     7322        IssmDouble     Jdet,viscosity;
     7323        IssmDouble     gravity,rho_ice,stokesreconditioning;
     7324        IssmDouble     xyz_list[NUMVERTICES][3];
     7325        IssmDouble     epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
     7326        IssmDouble     l1l7[7]; //for the six nodes and the bubble
     7327        IssmDouble     B[8][numdofbubble];
     7328        IssmDouble     B_prime[8][numdofbubble];
     7329        IssmDouble     B_prime_bubble[8][3];
     7330        IssmDouble     D[8][8]={0.0};
     7331        IssmDouble     D_scalar;
     7332        IssmDouble     Pe_gaussian[numdofbubble]={0.0}; //for the six nodes and the bubble
     7333        IssmDouble     Ke_temp[numdofbubble][3]={0.0}; //for the six nodes and the bubble
     7334        IssmDouble     Ke_gaussian[numdofbubble][3];
    72807335        GaussPenta *gauss=NULL;
    72817336
     
    73367391}
    73377392/*}}}*/
    7338 /*FUNCTION Penta::CreatePVectorDiagnosticStokesShelf{{{1*/
     7393/*FUNCTION Penta::CreatePVectorDiagnosticStokesShelf{{{*/
    73397394ElementVector* Penta::CreatePVectorDiagnosticStokesShelf(void){
    73407395
     
    73427397        int         i,j,ig;
    73437398        int         approximation,shelf_dampening;
    7344         double      gravity,rho_water,bed,water_pressure;
    7345         double      damper,normal_vel,vx,vy,vz,dt;
    7346         double          xyz_list_tria[NUMVERTICES2D][3];
    7347         double      xyz_list[NUMVERTICES][3];
    7348         double          bed_normal[3];
    7349         double      dz[3];
    7350         double      basis[6]; //for the six nodes of the penta
    7351         double      Jdet2d;
     7399        IssmDouble      gravity,rho_water,bed,water_pressure;
     7400        IssmDouble      damper,normal_vel,vx,vy,vz,dt;
     7401        IssmDouble              xyz_list_tria[NUMVERTICES2D][3];
     7402        IssmDouble      xyz_list[NUMVERTICES][3];
     7403        IssmDouble              bed_normal[3];
     7404        IssmDouble      dz[3];
     7405        IssmDouble      basis[6]; //for the six nodes of the penta
     7406        IssmDouble      Jdet2d;
    73527407        GaussPenta  *gauss=NULL;
    73537408
     
    74047459}
    74057460/*}}}*/
    7406 /*FUNCTION Penta::CreatePVectorDiagnosticVert {{{1*/
     7461/*FUNCTION Penta::CreatePVectorDiagnosticVert {{{*/
    74077462ElementVector* Penta::CreatePVectorDiagnosticVert(void){
    74087463
     
    74187473}
    74197474/*}}}*/
    7420 /*FUNCTION Penta::CreatePVectorDiagnosticVertVolume {{{1*/
     7475/*FUNCTION Penta::CreatePVectorDiagnosticVertVolume {{{*/
    74217476ElementVector* Penta::CreatePVectorDiagnosticVertVolume(void){
    74227477
     
    74277482        int        i,ig;
    74287483        int        approximation;
    7429         double     Jdet;
    7430         double     xyz_list[NUMVERTICES][3];
    7431         double     dudx,dvdy,dwdz;
    7432         double     du[3],dv[3],dw[3];
    7433         double     basis[6];
     7484        IssmDouble     Jdet;
     7485        IssmDouble     xyz_list[NUMVERTICES][3];
     7486        IssmDouble     dudx,dvdy,dwdz;
     7487        IssmDouble     du[3],dv[3],dw[3];
     7488        IssmDouble     basis[6];
    74347489        GaussPenta *gauss=NULL;
    74357490
     
    74747529}
    74757530/*}}}*/
    7476 /*FUNCTION Penta::CreatePVectorDiagnosticVertBase {{{1*/
     7531/*FUNCTION Penta::CreatePVectorDiagnosticVertBase {{{*/
    74777532ElementVector* Penta::CreatePVectorDiagnosticVertBase(void){
    74787533
     
    74847539        int        i,j,ig;
    74857540        int        approximation;
    7486         double     xyz_list[NUMVERTICES][3];
    7487         double     xyz_list_tria[NUMVERTICES2D][3];
    7488         double     Jdet2d;
    7489         double     vx,vy,vz,dbdx,dbdy,basalmeltingvalue;
    7490         double     slope[3];
    7491         double     basis[NUMVERTICES];
     7541        IssmDouble     xyz_list[NUMVERTICES][3];
     7542        IssmDouble     xyz_list_tria[NUMVERTICES2D][3];
     7543        IssmDouble     Jdet2d;
     7544        IssmDouble     vx,vy,vz,dbdx,dbdy,basalmeltingvalue;
     7545        IssmDouble     slope[3];
     7546        IssmDouble     basis[NUMVERTICES];
    74927547        GaussPenta* gauss=NULL;
    74937548
     
    75397594}
    75407595/*}}}*/
    7541 /*FUNCTION Penta::CreateJacobianDiagnosticHoriz{{{1*/
     7596/*FUNCTION Penta::CreateJacobianDiagnosticHoriz{{{*/
    75427597ElementMatrix* Penta::CreateJacobianDiagnosticHoriz(void){
    75437598
     
    75557610                        return NULL;
    75567611                default:
    7557                         _error_("Approximation %s not supported yet",EnumToStringx(approximation));
    7558         }
    7559 }
    7560 /*}}}*/
    7561 /*FUNCTION Penta::CreateJacobianDiagnosticMacayeal2d{{{1*/
     7612                        _error2_("Approximation " << EnumToStringx(approximation) << " not supported yet");
     7613        }
     7614}
     7615/*}}}*/
     7616/*FUNCTION Penta::CreateJacobianDiagnosticMacayeal2d{{{*/
    75627617ElementMatrix* Penta::CreateJacobianDiagnosticMacayeal2d(void){
    75637618
     
    75827637}
    75837638/*}}}*/
    7584 /*FUNCTION Penta::CreateJacobianDiagnosticPattyn{{{1*/
     7639/*FUNCTION Penta::CreateJacobianDiagnosticPattyn{{{*/
    75857640ElementMatrix* Penta::CreateJacobianDiagnosticPattyn(void){
    75867641
     
    75907645        /*Intermediaries */
    75917646        int        i,j,ig;
    7592         double     xyz_list[NUMVERTICES][3];
    7593         double     Jdet;
    7594         double     eps1dotdphii,eps1dotdphij;
    7595         double     eps2dotdphii,eps2dotdphij;
    7596         double     mu_prime;
    7597         double     epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
    7598         double     eps1[3],eps2[3];
    7599         double     phi[NUMVERTICES];
    7600         double     dphi[3][NUMVERTICES];
     7647        IssmDouble     xyz_list[NUMVERTICES][3];
     7648        IssmDouble     Jdet;
     7649        IssmDouble     eps1dotdphii,eps1dotdphij;
     7650        IssmDouble     eps2dotdphii,eps2dotdphij;
     7651        IssmDouble     mu_prime;
     7652        IssmDouble     epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
     7653        IssmDouble     eps1[3],eps2[3];
     7654        IssmDouble     phi[NUMVERTICES];
     7655        IssmDouble     dphi[3][NUMVERTICES];
    76017656        GaussPenta *gauss=NULL;
    76027657
     
    76477702}
    76487703/*}}}*/
    7649 /*FUNCTION Penta::CreateJacobianDiagnosticStokes{{{1*/
     7704/*FUNCTION Penta::CreateJacobianDiagnosticStokes{{{*/
    76507705ElementMatrix* Penta::CreateJacobianDiagnosticStokes(void){
    76517706
     
    76557710        /*Intermediaries */
    76567711        int        i,j,ig;
    7657         double     xyz_list[NUMVERTICES][3];
    7658         double     Jdet;
    7659         double     eps1dotdphii,eps1dotdphij;
    7660         double     eps2dotdphii,eps2dotdphij;
    7661         double     eps3dotdphii,eps3dotdphij;
    7662         double     mu_prime;
    7663         double     epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
    7664         double     eps1[3],eps2[3],eps3[3];
    7665         double     phi[NUMVERTICES];
    7666         double     dphi[3][NUMVERTICES];
     7712        IssmDouble     xyz_list[NUMVERTICES][3];
     7713        IssmDouble     Jdet;
     7714        IssmDouble     eps1dotdphii,eps1dotdphij;
     7715        IssmDouble     eps2dotdphii,eps2dotdphij;
     7716        IssmDouble     eps3dotdphii,eps3dotdphij;
     7717        IssmDouble     mu_prime;
     7718        IssmDouble     epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
     7719        IssmDouble     eps1[3],eps2[3],eps3[3];
     7720        IssmDouble     phi[NUMVERTICES];
     7721        IssmDouble     dphi[3][NUMVERTICES];
    76677722        GaussPenta *gauss=NULL;
    76687723
     
    77237778}
    77247779/*}}}*/
    7725 /*FUNCTION Penta::GetSolutionFromInputsDiagnosticHoriz{{{1*/
     7780/*FUNCTION Penta::GetSolutionFromInputsDiagnosticHoriz{{{*/
    77267781void  Penta::GetSolutionFromInputsDiagnosticHoriz(Vector* solution){
    77277782
     
    77317786        int          approximation;
    77327787        int*         doflist=NULL;
    7733         double       vx,vy;
    7734         double       values[numdof];
     7788        IssmDouble       vx,vy;
     7789        IssmDouble       values[numdof];
    77357790        GaussPenta*  gauss;
    77367791
     
    77627817        /*Free ressources:*/
    77637818        delete gauss;
    7764         xfree((void**)&doflist);
    7765 }
    7766 /*}}}*/
    7767 /*FUNCTION Penta::GetSolutionFromInputsDiagnosticHutter{{{1*/
     7819        xDelete<int>(doflist);
     7820}
     7821/*}}}*/
     7822/*FUNCTION Penta::GetSolutionFromInputsDiagnosticHutter{{{*/
    77687823void  Penta::GetSolutionFromInputsDiagnosticHutter(Vector* solution){
    77697824
     
    77727827        int          i;
    77737828        int*         doflist=NULL;
    7774         double       vx,vy;
    7775         double       values[numdof];
     7829        IssmDouble       vx,vy;
     7830        IssmDouble       values[numdof];
    77767831        GaussPenta*  gauss=NULL;
    77777832
     
    77987853        /*Free ressources:*/
    77997854        delete gauss;
    7800         xfree((void**)&doflist);
    7801 }
    7802 /*}}}*/
    7803 /*FUNCTION Penta::GetSolutionFromInputsDiagnosticVert{{{1*/
     7855        xDelete<int>(doflist);
     7856}
     7857/*}}}*/
     7858/*FUNCTION Penta::GetSolutionFromInputsDiagnosticVert{{{*/
    78047859void  Penta::GetSolutionFromInputsDiagnosticVert(Vector* solution){
    78057860
     
    78087863        int          i;
    78097864        int*         doflist=NULL;
    7810         double       vz;
    7811         double       values[numdof];
     7865        IssmDouble       vz;
     7866        IssmDouble       values[numdof];
    78127867        GaussPenta*  gauss=NULL;
    78137868
     
    78317886        /*Free ressources:*/
    78327887        delete gauss;
    7833         xfree((void**)&doflist);
    7834 }
    7835 /*}}}*/
    7836 /*FUNCTION Penta::GetSolutionFromInputsDiagnosticStokes{{{1*/
     7888        xDelete<int>(doflist);
     7889}
     7890/*}}}*/
     7891/*FUNCTION Penta::GetSolutionFromInputsDiagnosticStokes{{{*/
    78377892void  Penta::GetSolutionFromInputsDiagnosticStokes(Vector* solution){
    78387893
     
    78417896        int          i;
    78427897        int*         doflist=NULL;
    7843         double       vx,vy,vz,p;
    7844         double       stokesreconditioning;
    7845         double       values[numdof];
     7898        IssmDouble       vx,vy,vz,p;
     7899        IssmDouble       stokesreconditioning;
     7900        IssmDouble       values[numdof];
    78467901        GaussPenta   *gauss;
    78477902
     
    78767931        /*Free ressources:*/
    78777932        delete gauss;
    7878         xfree((void**)&doflist);
    7879 }
    7880 /*}}}*/
    7881 /*FUNCTION Penta::InputUpdateFromSolutionDiagnosticHoriz {{{1*/
    7882 void  Penta::InputUpdateFromSolutionDiagnosticHoriz(double* solution){
     7933        xDelete<int>(doflist);
     7934}
     7935/*}}}*/
     7936/*FUNCTION Penta::InputUpdateFromSolutionDiagnosticHoriz {{{*/
     7937void  Penta::InputUpdateFromSolutionDiagnosticHoriz(IssmDouble* solution){
    78837938
    78847939        int  approximation;
     
    79157970}
    79167971/*}}}*/
    7917 /*FUNCTION Penta::InputUpdateFromSolutionDiagnosticMacAyeal {{{1*/
    7918 void  Penta::InputUpdateFromSolutionDiagnosticMacAyeal(double* solution){
     7972/*FUNCTION Penta::InputUpdateFromSolutionDiagnosticMacAyeal {{{*/
     7973void  Penta::InputUpdateFromSolutionDiagnosticMacAyeal(IssmDouble* solution){
    79197974
    79207975        const int    numdof=NDOF2*NUMVERTICES;
    79217976
    79227977        int     i;
    7923         double  rho_ice,g;
    7924         double  values[numdof];
    7925         double  vx[NUMVERTICES];
    7926         double  vy[NUMVERTICES];
    7927         double  vz[NUMVERTICES];
    7928         double  vel[NUMVERTICES];
    7929         double  pressure[NUMVERTICES];
    7930         double  surface[NUMVERTICES];
    7931         double  xyz_list[NUMVERTICES][3];
     7978        IssmDouble  rho_ice,g;
     7979        IssmDouble  values[numdof];
     7980        IssmDouble  vx[NUMVERTICES];
     7981        IssmDouble  vy[NUMVERTICES];
     7982        IssmDouble  vz[NUMVERTICES];
     7983        IssmDouble  vel[NUMVERTICES];
     7984        IssmDouble  pressure[NUMVERTICES];
     7985        IssmDouble  surface[NUMVERTICES];
     7986        IssmDouble  xyz_list[NUMVERTICES][3];
    79327987        int    *doflist = NULL;
    79337988        Penta  *penta   = NULL;
     
    79508005
    79518006                /*Check solution*/
    7952                 if(isnan(vx[i])) _error_("NaN found in solution vector");
    7953                 if(isnan(vy[i])) _error_("NaN found in solution vector");
     8007                if(xIsNan<IssmDouble>(vx[i])) _error2_("NaN found in solution vector");
     8008                if(xIsNan<IssmDouble>(vy[i])) _error2_("NaN found in solution vector");
    79548009        }
    79558010
     
    79938048       
    79948049        /*Free ressources:*/
    7995         xfree((void**)&doflist);
    7996 }
    7997 /*}}}*/
    7998 /*FUNCTION Penta::InputUpdateFromSolutionDiagnosticMacAyealPattyn {{{1*/
    7999 void  Penta::InputUpdateFromSolutionDiagnosticMacAyealPattyn(double* solution){
     8050        xDelete<int>(doflist);
     8051}
     8052/*}}}*/
     8053/*FUNCTION Penta::InputUpdateFromSolutionDiagnosticMacAyealPattyn {{{*/
     8054void  Penta::InputUpdateFromSolutionDiagnosticMacAyealPattyn(IssmDouble* solution){
    80008055
    80018056        const int    numdof=NDOF2*NUMVERTICES;
     
    80038058
    80048059        int     i;
    8005         double  rho_ice,g;
    8006         double  macayeal_values[numdof];
    8007         double  pattyn_values[numdof];
    8008         double  vx[NUMVERTICES];
    8009         double  vy[NUMVERTICES];
    8010         double  vz[NUMVERTICES];
    8011         double  vel[NUMVERTICES];
    8012         double  pressure[NUMVERTICES];
    8013         double  surface[NUMVERTICES];
    8014         double  xyz_list[NUMVERTICES][3];
     8060        IssmDouble  rho_ice,g;
     8061        IssmDouble  macayeal_values[numdof];
     8062        IssmDouble  pattyn_values[numdof];
     8063        IssmDouble  vx[NUMVERTICES];
     8064        IssmDouble  vy[NUMVERTICES];
     8065        IssmDouble  vz[NUMVERTICES];
     8066        IssmDouble  vel[NUMVERTICES];
     8067        IssmDouble  pressure[NUMVERTICES];
     8068        IssmDouble  surface[NUMVERTICES];
     8069        IssmDouble  xyz_list[NUMVERTICES][3];
    80158070        int*    doflistp = NULL;
    80168071        int*    doflistm = NULL;
     
    80488103
    80498104                /*Check solution*/
    8050                 if(isnan(vx[i])) _error_("NaN found in solution vector");
    8051                 if(isnan(vy[i])) _error_("NaN found in solution vector");
     8105                if(xIsNan<IssmDouble>(vx[i])) _error2_("NaN found in solution vector");
     8106                if(xIsNan<IssmDouble>(vy[i])) _error2_("NaN found in solution vector");
    80528107        }
    80538108
     
    80768131
    80778132        /*Free ressources:*/
    8078         xfree((void**)&doflistp);
    8079         xfree((void**)&doflistm);
    8080 }
    8081 /*}}}*/
    8082 /*FUNCTION Penta::InputUpdateFromSolutionDiagnosticMacAyealStokes {{{1*/
    8083 void  Penta::InputUpdateFromSolutionDiagnosticMacAyealStokes(double* solution){
     8133        xDelete<int>(doflistp);
     8134        xDelete<int>(doflistm);
     8135}
     8136/*}}}*/
     8137/*FUNCTION Penta::InputUpdateFromSolutionDiagnosticMacAyealStokes {{{*/
     8138void  Penta::InputUpdateFromSolutionDiagnosticMacAyealStokes(IssmDouble* solution){
    80848139
    80858140        const int    numdofm=NDOF2*NUMVERTICES;
     
    80888143
    80898144        int     i;
    8090         double  stokesreconditioning;
    8091         double  macayeal_values[numdofm];
    8092         double  stokes_values[numdofs];
    8093         double  vx[NUMVERTICES];
    8094         double  vy[NUMVERTICES];
    8095         double  vz[NUMVERTICES];
    8096         double  vzmacayeal[NUMVERTICES];
    8097         double  vzstokes[NUMVERTICES];
    8098         double  vel[NUMVERTICES];
    8099         double  pressure[NUMVERTICES];
    8100         double  xyz_list[NUMVERTICES][3];
     8145        IssmDouble  stokesreconditioning;
     8146        IssmDouble  macayeal_values[numdofm];
     8147        IssmDouble  stokes_values[numdofs];
     8148        IssmDouble  vx[NUMVERTICES];
     8149        IssmDouble  vy[NUMVERTICES];
     8150        IssmDouble  vz[NUMVERTICES];
     8151        IssmDouble  vzmacayeal[NUMVERTICES];
     8152        IssmDouble  vzstokes[NUMVERTICES];
     8153        IssmDouble  vel[NUMVERTICES];
     8154        IssmDouble  pressure[NUMVERTICES];
     8155        IssmDouble  xyz_list[NUMVERTICES][3];
    81018156        int*    doflistm        = NULL;
    81028157        int*    doflists        = NULL;
     
    81368191
    81378192                /*Check solution*/
    8138                 if(isnan(vx[i]))       _error_("NaN found in solution vector");
    8139                 if(isnan(vy[i]))       _error_("NaN found in solution vector");
    8140                 if(isnan(vzstokes[i])) _error_("NaN found in solution vector");
    8141                 if(isnan(pressure[i])) _error_("NaN found in solution vector");
     8193                if(xIsNan<IssmDouble>(vx[i]))       _error2_("NaN found in solution vector");
     8194                if(xIsNan<IssmDouble>(vy[i]))       _error2_("NaN found in solution vector");
     8195                if(xIsNan<IssmDouble>(vzstokes[i])) _error2_("NaN found in solution vector");
     8196                if(xIsNan<IssmDouble>(pressure[i])) _error2_("NaN found in solution vector");
    81428197        }
    81438198
     
    81468201        if (vzmacayeal_input){
    81478202                if (vzmacayeal_input->ObjectEnum()!=PentaP1InputEnum){
    8148                         _error_("Cannot compute Vel as VzMacAyeal is of type %s",EnumToStringx(vzmacayeal_input->ObjectEnum()));
     8203                        _error2_("Cannot compute Vel as VzMacAyeal is of type " << EnumToStringx(vzmacayeal_input->ObjectEnum()));
    81498204                }
    81508205                GetInputListOnVertices(&vzmacayeal[0],VzMacAyealEnum);
    81518206        }
    81528207        else{
    8153                 _error_("Cannot update solution as VzMacAyeal is not present");
     8208                _error2_("Cannot update solution as VzMacAyeal is not present");
    81548209        }
    81558210
     
    81768231
    81778232        /*Free ressources:*/
    8178         xfree((void**)&doflistm);
    8179         xfree((void**)&doflists);
    8180 }
    8181 /*}}}*/
    8182 /*FUNCTION Penta::InputUpdateFromSolutionDiagnosticPattyn {{{1*/
    8183 void  Penta::InputUpdateFromSolutionDiagnosticPattyn(double* solution){
     8233        xDelete<int>(doflistm);
     8234        xDelete<int>(doflists);
     8235}
     8236/*}}}*/
     8237/*FUNCTION Penta::InputUpdateFromSolutionDiagnosticPattyn {{{*/
     8238void  Penta::InputUpdateFromSolutionDiagnosticPattyn(IssmDouble* solution){
    81848239       
    81858240        const int    numdof=NDOF2*NUMVERTICES;
    81868241
    81878242        int    i;
    8188         double rho_ice,g;
    8189         double values[numdof];
    8190         double vx[NUMVERTICES];
    8191         double vy[NUMVERTICES];
    8192         double vz[NUMVERTICES];
    8193         double vel[NUMVERTICES];
    8194         double pressure[NUMVERTICES];
    8195         double surface[NUMVERTICES];
    8196         double xyz_list[NUMVERTICES][3];
     8243        IssmDouble rho_ice,g;
     8244        IssmDouble values[numdof];
     8245        IssmDouble vx[NUMVERTICES];
     8246        IssmDouble vy[NUMVERTICES];
     8247        IssmDouble vz[NUMVERTICES];
     8248        IssmDouble vel[NUMVERTICES];
     8249        IssmDouble pressure[NUMVERTICES];
     8250        IssmDouble surface[NUMVERTICES];
     8251        IssmDouble xyz_list[NUMVERTICES][3];
    81978252        int*   doflist = NULL;
    81988253
     
    82158270
    82168271                /*Check solution*/
    8217                 if(isnan(vx[i])) _error_("NaN found in solution vector");
    8218                 if(isnan(vy[i])) _error_("NaN found in solution vector");
     8272                if(xIsNan<IssmDouble>(vx[i])) _error2_("NaN found in solution vector");
     8273                if(xIsNan<IssmDouble>(vy[i])) _error2_("NaN found in solution vector");
    82198274        }
    82208275
     
    82518306
    82528307        /*Free ressources:*/
    8253         xfree((void**)&doflist);
    8254 }
    8255 /*}}}*/
    8256 /*FUNCTION Penta::InputUpdateFromSolutionDiagnosticPattynStokes {{{1*/
    8257 void  Penta::InputUpdateFromSolutionDiagnosticPattynStokes(double* solution){
     8308        xDelete<int>(doflist);
     8309}
     8310/*}}}*/
     8311/*FUNCTION Penta::InputUpdateFromSolutionDiagnosticPattynStokes {{{*/
     8312void  Penta::InputUpdateFromSolutionDiagnosticPattynStokes(IssmDouble* solution){
    82588313
    82598314        const int    numdofp=NDOF2*NUMVERTICES;
     
    82618316
    82628317        int    i;
    8263         double pattyn_values[numdofp];
    8264         double stokes_values[numdofs];
    8265         double vx[NUMVERTICES];
    8266         double vy[NUMVERTICES];
    8267         double vz[NUMVERTICES];
    8268         double vzpattyn[NUMVERTICES];
    8269         double vzstokes[NUMVERTICES];
    8270         double vel[NUMVERTICES];
    8271         double pressure[NUMVERTICES];
    8272         double xyz_list[NUMVERTICES][3];
    8273         double stokesreconditioning;
     8318        IssmDouble pattyn_values[numdofp];
     8319        IssmDouble stokes_values[numdofs];
     8320        IssmDouble vx[NUMVERTICES];
     8321        IssmDouble vy[NUMVERTICES];
     8322        IssmDouble vz[NUMVERTICES];
     8323        IssmDouble vzpattyn[NUMVERTICES];
     8324        IssmDouble vzstokes[NUMVERTICES];
     8325        IssmDouble vel[NUMVERTICES];
     8326        IssmDouble pressure[NUMVERTICES];
     8327        IssmDouble xyz_list[NUMVERTICES][3];
     8328        IssmDouble stokesreconditioning;
    82748329        int*   doflistp      = NULL;
    82758330        int*   doflists      = NULL;
     
    83048359
    83058360                /*Check solution*/
    8306                 if(isnan(vx[i]))       _error_("NaN found in solution vector");
    8307                 if(isnan(vy[i]))       _error_("NaN found in solution vector");
    8308                 if(isnan(vzstokes[i])) _error_("NaN found in solution vector");
    8309                 if(isnan(pressure[i])) _error_("NaN found in solution vector");
     8361                if(xIsNan<IssmDouble>(vx[i]))       _error2_("NaN found in solution vector");
     8362                if(xIsNan<IssmDouble>(vy[i]))       _error2_("NaN found in solution vector");
     8363                if(xIsNan<IssmDouble>(vzstokes[i])) _error2_("NaN found in solution vector");
     8364                if(xIsNan<IssmDouble>(pressure[i])) _error2_("NaN found in solution vector");
    83108365        }
    83118366
     
    83148369        if (vzpattyn_input){
    83158370                if (vzpattyn_input->ObjectEnum()!=PentaP1InputEnum){
    8316                         _error_("Cannot compute Vel as VzPattyn is of type %s",EnumToStringx(vzpattyn_input->ObjectEnum()));
     8371                        _error2_("Cannot compute Vel as VzPattyn is of type " << EnumToStringx(vzpattyn_input->ObjectEnum()));
    83178372                }
    83188373                GetInputListOnVertices(&vzpattyn[0],VzPattynEnum);
    83198374        }
    83208375        else{
    8321                 _error_("Cannot update solution as VzPattyn is not present");
     8376                _error2_("Cannot update solution as VzPattyn is not present");
    83228377        }
    83238378
     
    83448399
    83458400        /*Free ressources:*/
    8346         xfree((void**)&doflistp);
    8347         xfree((void**)&doflists);
    8348 }
    8349 /*}}}*/
    8350 /*FUNCTION Penta::InputUpdateFromSolutionDiagnosticHutter {{{1*/
    8351 void  Penta::InputUpdateFromSolutionDiagnosticHutter(double* solution){
     8401        xDelete<int>(doflistp);
     8402        xDelete<int>(doflists);
     8403}
     8404/*}}}*/
     8405/*FUNCTION Penta::InputUpdateFromSolutionDiagnosticHutter {{{*/
     8406void  Penta::InputUpdateFromSolutionDiagnosticHutter(IssmDouble* solution){
    83528407       
    83538408        const int    numdof=NDOF2*NUMVERTICES;
    83548409
    83558410        int     i;
    8356         double  rho_ice,g;
    8357         double  values[numdof];
    8358         double  vx[NUMVERTICES];
    8359         double  vy[NUMVERTICES];
    8360         double  vz[NUMVERTICES];
    8361         double  vel[NUMVERTICES];
    8362         double  pressure[NUMVERTICES];
    8363         double  surface[NUMVERTICES];
    8364         double  xyz_list[NUMVERTICES][3];
     8411        IssmDouble  rho_ice,g;
     8412        IssmDouble  values[numdof];
     8413        IssmDouble  vx[NUMVERTICES];
     8414        IssmDouble  vy[NUMVERTICES];
     8415        IssmDouble  vz[NUMVERTICES];
     8416        IssmDouble  vel[NUMVERTICES];
     8417        IssmDouble  pressure[NUMVERTICES];
     8418        IssmDouble  surface[NUMVERTICES];
     8419        IssmDouble  xyz_list[NUMVERTICES][3];
    83658420        int*    doflist = NULL;
    83668421
     
    83808435
    83818436                /*Check solution*/
    8382                 if(isnan(vx[i])) _error_("NaN found in solution vector");
    8383                 if(isnan(vy[i])) _error_("NaN found in solution vector");
     8437                if(xIsNan<IssmDouble>(vx[i])) _error2_("NaN found in solution vector");
     8438                if(xIsNan<IssmDouble>(vy[i])) _error2_("NaN found in solution vector");
    83848439        }
    83858440
     
    84088463
    84098464        /*Free ressources:*/
    8410         xfree((void**)&doflist);
    8411 }
    8412 /*}}}*/
    8413 /*FUNCTION Penta::InputUpdateFromSolutionDiagnosticVert {{{1*/
    8414 void  Penta::InputUpdateFromSolutionDiagnosticVert(double* solution){
     8465        xDelete<int>(doflist);
     8466}
     8467/*}}}*/
     8468/*FUNCTION Penta::InputUpdateFromSolutionDiagnosticVert {{{*/
     8469void  Penta::InputUpdateFromSolutionDiagnosticVert(IssmDouble* solution){
    84158470
    84168471        const int numdof=NDOF1*NUMVERTICES;
     
    84188473        int      i;
    84198474        int      approximation;
    8420         double   rho_ice,g;
    8421         double   values[numdof];
    8422         double   vx[NUMVERTICES];
    8423         double   vy[NUMVERTICES];
    8424         double   vz[NUMVERTICES];
    8425         double   vzmacayeal[NUMVERTICES];
    8426         double   vzpattyn[NUMVERTICES];
    8427         double   vzstokes[NUMVERTICES];
    8428         double   vel[NUMVERTICES];
    8429         double   pressure[NUMVERTICES];
    8430         double   surface[NUMVERTICES];
    8431         double   xyz_list[NUMVERTICES][3];
     8475        IssmDouble   rho_ice,g;
     8476        IssmDouble   values[numdof];
     8477        IssmDouble   vx[NUMVERTICES];
     8478        IssmDouble   vy[NUMVERTICES];
     8479        IssmDouble   vz[NUMVERTICES];
     8480        IssmDouble   vzmacayeal[NUMVERTICES];
     8481        IssmDouble   vzpattyn[NUMVERTICES];
     8482        IssmDouble   vzstokes[NUMVERTICES];
     8483        IssmDouble   vel[NUMVERTICES];
     8484        IssmDouble   pressure[NUMVERTICES];
     8485        IssmDouble   surface[NUMVERTICES];
     8486        IssmDouble   xyz_list[NUMVERTICES][3];
    84328487        int*     doflist      = NULL;
    84338488
     
    84498504
    84508505                /*Check solution*/
    8451                 if(isnan(vz[i])) _error_("NaN found in solution vector");
     8506                if(xIsNan<IssmDouble>(vz[i])) _error2_("NaN found in solution vector");
    84528507        }
    84538508
     
    84608515                Input* vzstokes_input=inputs->GetInput(VzStokesEnum);
    84618516                if (vzstokes_input){
    8462                         if (vzstokes_input->ObjectEnum()!=PentaP1InputEnum) _error_("Cannot compute Vel as VzStokes is of type %s",EnumToStringx(vzstokes_input->ObjectEnum()));
     8517                        if (vzstokes_input->ObjectEnum()!=PentaP1InputEnum) _error2_("Cannot compute Vel as VzStokes is of type " << EnumToStringx(vzstokes_input->ObjectEnum()));
    84638518                        GetInputListOnVertices(&vzstokes[0],VzStokesEnum);
    84648519                }
    8465                 else _error_("Cannot compute Vz as VzStokes in not present in PattynStokes element");
     8520                else _error2_("Cannot compute Vz as VzStokes in not present in PattynStokes element");
    84668521                for(i=0;i<NUMVERTICES;i++){
    84678522                        vzpattyn[i]=vz[i];
     
    84728527                Input* vzstokes_input=inputs->GetInput(VzStokesEnum);
    84738528                if (vzstokes_input){
    8474                         if (vzstokes_input->ObjectEnum()!=PentaP1InputEnum) _error_("Cannot compute Vel as VzStokes is of type %s",EnumToStringx(vzstokes_input->ObjectEnum()));
     8529                        if (vzstokes_input->ObjectEnum()!=PentaP1InputEnum) _error2_("Cannot compute Vel as VzStokes is of type " << EnumToStringx(vzstokes_input->ObjectEnum()));
    84758530                        GetInputListOnVertices(&vzstokes[0],VzStokesEnum);
    84768531                }
    8477                 else _error_("Cannot compute Vz as VzStokes in not present in MacAyealStokes element");
     8532                else _error2_("Cannot compute Vz as VzStokes in not present in MacAyealStokes element");
    84788533                for(i=0;i<NUMVERTICES;i++){
    84798534                        vzmacayeal[i]=vz[i];
     
    85128567
    85138568        /*Free ressources:*/
    8514         xfree((void**)&doflist);
    8515 }
    8516 /*}}}*/
    8517 /*FUNCTION Penta::InputUpdateFromSolutionDiagnosticStokes {{{1*/
    8518 void  Penta::InputUpdateFromSolutionDiagnosticStokes(double* solution){
     8569        xDelete<int>(doflist);
     8570}
     8571/*}}}*/
     8572/*FUNCTION Penta::InputUpdateFromSolutionDiagnosticStokes {{{*/
     8573void  Penta::InputUpdateFromSolutionDiagnosticStokes(IssmDouble* solution){
    85198574       
    85208575        const int numdof=NDOF4*NUMVERTICES;
    85218576
    85228577        int     i;
    8523         double  values[numdof];
    8524         double  vx[NUMVERTICES];
    8525         double  vy[NUMVERTICES];
    8526         double  vz[NUMVERTICES];
    8527         double  vel[NUMVERTICES];
    8528         double  pressure[NUMVERTICES];
    8529         double  stokesreconditioning;
     8578        IssmDouble  values[numdof];
     8579        IssmDouble  vx[NUMVERTICES];
     8580        IssmDouble  vy[NUMVERTICES];
     8581        IssmDouble  vz[NUMVERTICES];
     8582        IssmDouble  vel[NUMVERTICES];
     8583        IssmDouble  pressure[NUMVERTICES];
     8584        IssmDouble  stokesreconditioning;
    85308585        int*    doflist=NULL;
    85318586
     
    85478602
    85488603                /*Check solution*/
    8549                 if(isnan(vx[i]))       _error_("NaN found in solution vector");
    8550                 if(isnan(vy[i]))       _error_("NaN found in solution vector");
    8551                 if(isnan(vz[i]))       _error_("NaN found in solution vector");
    8552                 if(isnan(pressure[i])) _error_("NaN found in solution vector");
     8604                if(xIsNan<IssmDouble>(vx[i]))       _error2_("NaN found in solution vector");
     8605                if(xIsNan<IssmDouble>(vy[i]))       _error2_("NaN found in solution vector");
     8606                if(xIsNan<IssmDouble>(vz[i]))       _error2_("NaN found in solution vector");
     8607                if(xIsNan<IssmDouble>(pressure[i])) _error2_("NaN found in solution vector");
    85538608        }
    85548609
     
    85738628
    85748629        /*Free ressources:*/
    8575         xfree((void**)&doflist);
     8630        xDelete<int>(doflist);
    85768631}
    85778632/*}}}*/
     
    85798634
    85808635#ifdef _HAVE_BALANCED_
    8581 /*FUNCTION Penta::CreateKMatrixBalancethickness {{{1*/
     8636/*FUNCTION Penta::CreateKMatrixBalancethickness {{{*/
    85828637ElementMatrix* Penta::CreateKMatrixBalancethickness(void){
    85838638
     
    86048659}
    86058660/*}}}*/
    8606 /*FUNCTION Penta::CreatePVectorBalancethickness {{{1*/
     8661/*FUNCTION Penta::CreatePVectorBalancethickness {{{*/
    86078662ElementVector* Penta::CreatePVectorBalancethickness(void){
    86088663
  • issm/trunk/src/c/objects/Elements/Penta.h

    r12630 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "./Element.h"
    1111#include "./PentaHook.h"
     
    4444                Results      *results;
    4545
    46                 /*Penta constructors and destructor: {{{1*/
     46                /*Penta constructors and destructor: {{{*/
    4747                Penta();
    4848                Penta(int penta_id,int penta_sid,int i, IoModel* iomodel,int nummodels);
    4949                ~Penta();
    5050                /*}}}*/
    51                 /*Object virtual functions definitions: {{{1*/
     51                /*Object virtual functions definitions: {{{*/
    5252                Object*   copy();
    5353                void      DeepEcho();
     
    5757                int               MyRank();
    5858                /*}}}*/
    59                 /*Update virtual functions definitions: {{{1*/
     59                /*Update virtual functions definitions: {{{*/
    6060                void  InputUpdateFromConstant(bool constant, int name);
    61                 void  InputUpdateFromConstant(double constant, int name);
     61                void  InputUpdateFromConstant(IssmDouble constant, int name);
    6262                void  InputUpdateFromConstant(int constant, int name);
    63                 void  InputUpdateFromSolution(double* solutiong);
     63                void  InputUpdateFromSolution(IssmDouble* solutiong);
    6464                void  InputUpdateFromVector(bool* vector, int name, int type);
    65                 void  InputUpdateFromVector(double* vector, int name, int type);
     65                void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
    6666                void  InputUpdateFromVector(int* vector, int name, int type);
    6767                #ifdef _HAVE_DAKOTA_
    6868                void  InputUpdateFromVectorDakota(bool* vector, int name, int type);
    69                 void  InputUpdateFromVectorDakota(double* vector, int name, int type);
     69                void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
    7070                void  InputUpdateFromVectorDakota(int* vector, int name, int type);
    71                 void  InputUpdateFromMatrixDakota(double* matrix, int nows, int ncols, int name, int type);
     71                void  InputUpdateFromMatrixDakota(IssmDouble* matrix, int nows, int ncols, int name, int type);
    7272                #endif
    7373                void  InputUpdateFromIoModel(int index, IoModel* iomodel);
    7474                /*}}}*/
    75                 /*Element virtual functions definitions: {{{1*/
    76                 void   AverageOntoPartition(Vector* partition_contributions,Vector* partition_areas,double* vertex_response,double* qmu_part);
     75                /*Element virtual functions definitions: {{{*/
     76                void   AverageOntoPartition(Vector* partition_contributions,Vector* partition_areas,IssmDouble* vertex_response,IssmDouble* qmu_part);
    7777                void   BasalFrictionCreateInput(void);
    7878                void   ComputeBasalStress(Vector* sigma_b);
     
    8787                int    GetNodeIndex(Node* node);
    8888                void   GetSolutionFromInputs(Vector* solution);
    89                 double GetZcoord(GaussPenta* gauss);
     89                IssmDouble GetZcoord(GaussPenta* gauss);
    9090                void   GetVectorFromInputs(Vector* vector,int name_enum);
    9191                void   GetVectorFromResults(Vector* vector,int offset,int name_enum,int interp);
    9292               
    9393                int    Sid();
    94                 void   InputArtificialNoise(int enum_type,double min, double max);
    95                 bool   InputConvergence(double* eps, int* enums,int num_enums,int* criterionenums,double* criterionvalues,int num_criterionenums);
    96                 void   InputCreate(double scalar,int name,int code);
    97                 void   InputCreate(double* vector, int index,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code);
     94                void   InputArtificialNoise(int enum_type,IssmDouble min, IssmDouble max);
     95                bool   InputConvergence(IssmDouble* eps, int* enums,int num_enums,int* criterionenums,IssmDouble* criterionvalues,int num_criterionenums);
     96                void   InputCreate(IssmDouble scalar,int name,int code);
     97                void   InputCreate(IssmDouble* vector, int index,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code);
    9898                void   InputDepthAverageAtBase(int enum_type,int average_enum_type,int object_enum=MeshElementsEnum);
    9999                void   InputDuplicate(int original_enum,int new_enum);
    100                 void   InputScale(int enum_type,double scale_factor);
     100                void   InputScale(int enum_type,IssmDouble scale_factor);
    101101               
    102                 void   InputToResult(int enum_type,int step,double time);
    103                 void   MigrateGroundingLine(double* old_floating_ice,double* sheet_ungrounding);
     102                void   InputToResult(int enum_type,int step,IssmDouble time);
     103                void   MigrateGroundingLine(IssmDouble* old_floating_ice,IssmDouble* sheet_ungrounding);
    104104                void   PotentialSheetUngrounding(Vector* potential_sheet_ungrounding);
    105                 void   RequestedOutput(int output_enum,int step,double time);
    106                 void   ListResultsInfo(int** results_enums,int** results_size,double** results_times,int** results_steps,int* num_results);
     105                void   RequestedOutput(int output_enum,int step,IssmDouble time);
     106                void   ListResultsInfo(int** results_enums,int** results_size,IssmDouble** results_times,int** results_steps,int* num_results);
    107107                void   PatchFill(int* pcount, Patch* patch);
    108108                void   PatchSize(int* pnumrows, int* pnumvertices,int* pnumnodes);
    109                 void   PositiveDegreeDay(double* pdds,double* pds,double signorm);
     109                void   PositiveDegreeDay(IssmDouble* pdds,IssmDouble* pds,IssmDouble signorm);
    110110                void   ProcessResultsUnits(void);
    111111                void   ResetCoordinateSystem(void);
    112                 double SurfaceArea(void);
     112                void   SmbGradients();
     113                IssmDouble SurfaceArea(void);
    113114                void   Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type);
    114                 int    UpdatePotentialSheetUngrounding(double* potential_sheet_ungrounding,Vector* vec_nodes_on_iceshelf,double* nodes_on_iceshelf);
    115                 int    NodalValue(double* pvalue, int index, int natureofdataenum,bool process_units);
    116                 double TimeAdapt();
     115                int    UpdatePotentialSheetUngrounding(IssmDouble* potential_sheet_ungrounding,Vector* vec_nodes_on_iceshelf,IssmDouble* nodes_on_iceshelf);
     116                int    NodalValue(IssmDouble* pvalue, int index, int natureofdataenum,bool process_units);
     117                IssmDouble TimeAdapt();
    117118                int*   GetHorizontalNeighboorSids(void);
    118119                void   ViscousHeatingCreateInput(void);
    119                 void   SmearFunction(Vector* smearedvector,double (*WeightFunction)(double distance,double radius),double radius);
     120                void   SmearFunction(Vector* smearedvector,IssmDouble (*WeightFunction)(IssmDouble distance,IssmDouble radius),IssmDouble radius);
    120121
    121122                 #ifdef _HAVE_RESPONSES_
    122                 double IceVolume(void);
    123                 void   MinVel(double* pminvel, bool process_units);
    124                 void   MinVx(double* pminvx, bool process_units);
    125                 void   MinVy(double* pminvy, bool process_units);
    126                 void   MinVz(double* pminvz, bool process_units);
    127                 double MassFlux(double* segment,bool process_units);
    128                 void   MaxAbsVx(double* pmaxabsvx, bool process_units);
    129                 void   MaxAbsVy(double* pmaxabsvy, bool process_units);
    130                 void   MaxAbsVz(double* pmaxabsvz, bool process_units);
    131                 void   MaxVel(double* pmaxvel, bool process_units);
    132                 void   ElementResponse(double* presponse,int response_enum,bool process_units);
    133                 void   MaxVx(double* pmaxvx, bool process_units);
    134                 void   MaxVy(double* pmaxvy, bool process_units);
    135                 void   MaxVz(double* pmaxvz, bool process_units);
     123                IssmDouble IceVolume(void);
     124                void   MinVel(IssmDouble* pminvel, bool process_units);
     125                void   MinVx(IssmDouble* pminvx, bool process_units);
     126                void   MinVy(IssmDouble* pminvy, bool process_units);
     127                void   MinVz(IssmDouble* pminvz, bool process_units);
     128                IssmDouble MassFlux(IssmDouble* segment,bool process_units);
     129                void   MaxAbsVx(IssmDouble* pmaxabsvx, bool process_units);
     130                void   MaxAbsVy(IssmDouble* pmaxabsvy, bool process_units);
     131                void   MaxAbsVz(IssmDouble* pmaxabsvz, bool process_units);
     132                void   MaxVel(IssmDouble* pmaxvel, bool process_units);
     133                void   ElementResponse(IssmDouble* presponse,int response_enum,bool process_units);
     134                void   MaxVx(IssmDouble* pmaxvx, bool process_units);
     135                void   MaxVy(IssmDouble* pmaxvy, bool process_units);
     136                void   MaxVz(IssmDouble* pmaxvz, bool process_units);
    136137                #endif
    137138
    138139                #ifdef _HAVE_CONTROL_
    139                 double DragCoefficientAbsGradient(bool process_units,int weight_index);
     140                IssmDouble DragCoefficientAbsGradient(bool process_units,int weight_index);
    140141                void   GradientIndexing(int* indexing,int control_index);
    141142                void   Gradj(Vector* gradient,int control_type,int control_index);
     
    147148                void   GradjBbarStokes(Vector* gradient,int control_index);
    148149                void   GetVectorFromControlInputs(Vector* gradient,int control_enum,int control_index,const char* data);
    149                 void   SetControlInputsFromVector(double* vector,int control_enum,int control_index);
     150                void   SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index);
    150151                void   ControlInputGetGradient(Vector* gradient,int enum_type,int control_index);
    151                 void   ControlInputScaleGradient(int enum_type,double scale);
    152                 void   ControlInputSetGradient(double* gradient,int enum_type,int control_index);
    153                 double RheologyBbarAbsGradient(bool process_units,int weight_index);
    154                 double ThicknessAbsMisfit(     bool process_units,int weight_index);
    155                 double SurfaceAbsVelMisfit(    bool process_units,int weight_index);
    156                 double SurfaceRelVelMisfit(    bool process_units,int weight_index);
    157                 double SurfaceLogVelMisfit(    bool process_units,int weight_index);
    158                 double SurfaceLogVxVyMisfit(   bool process_units,int weight_index);
    159                 double SurfaceAverageVelMisfit(bool process_units,int weight_index);
    160                 double ThicknessAbsGradient(bool process_units,int weight_index);
    161                 void   InputControlUpdate(double scalar,bool save_parameter);
    162                 #endif
    163                 /*}}}*/
    164                 /*Penta specific routines:{{{1*/
    165                 void      BedNormal(double* bed_normal, double xyz_list[3][3]);
     152                void   ControlInputScaleGradient(int enum_type,IssmDouble scale);
     153                void   ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index);
     154                IssmDouble RheologyBbarAbsGradient(bool process_units,int weight_index);
     155                IssmDouble ThicknessAbsMisfit(     bool process_units,int weight_index);
     156                IssmDouble SurfaceAbsVelMisfit(    bool process_units,int weight_index);
     157                IssmDouble SurfaceRelVelMisfit(    bool process_units,int weight_index);
     158                IssmDouble SurfaceLogVelMisfit(    bool process_units,int weight_index);
     159                IssmDouble SurfaceLogVxVyMisfit(   bool process_units,int weight_index);
     160                IssmDouble SurfaceAverageVelMisfit(bool process_units,int weight_index);
     161                IssmDouble ThicknessAbsGradient(bool process_units,int weight_index);
     162                void   InputControlUpdate(IssmDouble scalar,bool save_parameter);
     163                #endif
     164                /*}}}*/
     165                /*Penta specific routines:{{{*/
     166                void      BedNormal(IssmDouble* bed_normal, IssmDouble xyz_list[3][3]);
    166167                ElementMatrix* CreateKMatrixPrognostic(void);
    167168                ElementMatrix* CreateKMatrixSlope(void);
     
    173174                void    GetConnectivityList(int* connectivity);
    174175                int     GetElementType(void);
    175                 void    GetElementSizes(double* hx,double* hy,double* hz);
    176                 void    GetInputListOnVertices(double* pvalue,int enumtype);
    177                 void    GetInputListOnVertices(double* pvalue,int enumtype,double defaultvalue);
    178                 void    GetInputValue(double* pvalue,Node* node,int enumtype);
    179                 void      GetPhi(double* phi, double*  epsilon, double viscosity);
     176                void    GetElementSizes(IssmDouble* hx,IssmDouble* hy,IssmDouble* hz);
     177                void    GetInputListOnVertices(IssmDouble* pvalue,int enumtype);
     178                void    GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue);
     179                void    GetInputValue(IssmDouble* pvalue,Node* node,int enumtype);
     180                void      GetPhi(IssmDouble* phi, IssmDouble*  epsilon, IssmDouble viscosity);
    180181                void      GetSolutionFromInputsEnthalpy(Vector* solutiong);
    181                 double  GetStabilizationParameter(double u, double v, double w, double diameter, double kappa);
    182                 void    GetStrainRate3dPattyn(double* epsilon,double* xyz_list, GaussPenta* gauss, Input* vx_input, Input* vy_input);
    183                 void    GetStrainRate3d(double* epsilon,double* xyz_list, GaussPenta* gauss, Input* vx_input, Input* vy_input, Input* vz_input);
     182                IssmDouble  GetStabilizationParameter(IssmDouble u, IssmDouble v, IssmDouble w, IssmDouble diameter, IssmDouble kappa);
     183                void    GetStrainRate3dPattyn(IssmDouble* epsilon,IssmDouble* xyz_list, GaussPenta* gauss, Input* vx_input, Input* vy_input);
     184                void    GetStrainRate3d(IssmDouble* epsilon,IssmDouble* xyz_list, GaussPenta* gauss, Input* vx_input, Input* vy_input, Input* vz_input);
    184185                Penta*  GetUpperElement(void);
    185186                Penta*  GetLowerElement(void);
    186187                Penta*  GetBasalElement(void);
    187188                void      InputExtrude(int enum_type,int object_type);
    188                 void    InputUpdateFromSolutionPrognostic(double* solutiong);
    189                 void    InputUpdateFromSolutionOneDof(double* solutiong,int enum_type);
    190                 void    InputUpdateFromSolutionOneDofCollapsed(double* solutiong,int enum_type);
     189                void    InputUpdateFromSolutionPrognostic(IssmDouble* solutiong);
     190                void    InputUpdateFromSolutionOneDof(IssmDouble* solutiong,int enum_type);
     191                void    InputUpdateFromSolutionOneDofCollapsed(IssmDouble* solutiong,int enum_type);
    191192                bool      IsInput(int name);
    192193                bool      IsOnSurface(void);
     
    194195                bool    IsFloating(void);
    195196                bool    IsNodeOnShelf();
    196                 bool    IsNodeOnShelfFromFlags(double* flags);
     197                bool    IsNodeOnShelfFromFlags(IssmDouble* flags);
    197198                bool    IsOnWater(void);
    198                 double  MinEdgeLength(double xyz_list[6][3]);
    199                 void      ReduceMatrixStokes(double* Ke_reduced, double* Ke_temp);
    200                 void      ReduceVectorStokes(double* Pe_reduced, double* Ke_temp, double* Pe_temp);
     199                IssmDouble  MinEdgeLength(IssmDouble xyz_list[6][3]);
     200                void      ReduceMatrixStokes(IssmDouble* Ke_reduced, IssmDouble* Ke_temp);
     201                void      ReduceVectorStokes(IssmDouble* Pe_reduced, IssmDouble* Ke_temp, IssmDouble* Pe_temp);
    201202                void      SetClone(int* minranks);
    202203                Tria*     SpawnTria(int g0, int g1, int g2);
    203                 void      SurfaceNormal(double* surface_normal, double xyz_list[3][3]);
     204                void      SurfaceNormal(IssmDouble* surface_normal, IssmDouble xyz_list[3][3]);
    204205
    205206                #ifdef _HAVE_DIAGNOSTIC_
     
    236237                ElementMatrix* CreateJacobianDiagnosticPattyn(void);
    237238                ElementMatrix* CreateJacobianDiagnosticStokes(void);
    238                 void           InputUpdateFromSolutionDiagnosticHoriz( double* solutiong);
    239                 void           InputUpdateFromSolutionDiagnosticMacAyeal( double* solutiong);
    240                 void           InputUpdateFromSolutionDiagnosticMacAyealPattyn( double* solutiong);
    241                 void           InputUpdateFromSolutionDiagnosticMacAyealStokes( double* solutiong);
    242                 void           InputUpdateFromSolutionDiagnosticPattyn( double* solutiong);
    243                 void           InputUpdateFromSolutionDiagnosticPattynStokes( double* solutiong);
    244                 void           InputUpdateFromSolutionDiagnosticHutter( double* solutiong);
    245                 void           InputUpdateFromSolutionDiagnosticVert( double* solutiong);
    246                 void           InputUpdateFromSolutionDiagnosticStokes( double* solutiong);
     239                void           InputUpdateFromSolutionDiagnosticHoriz( IssmDouble* solutiong);
     240                void           InputUpdateFromSolutionDiagnosticMacAyeal( IssmDouble* solutiong);
     241                void           InputUpdateFromSolutionDiagnosticMacAyealPattyn( IssmDouble* solutiong);
     242                void           InputUpdateFromSolutionDiagnosticMacAyealStokes( IssmDouble* solutiong);
     243                void           InputUpdateFromSolutionDiagnosticPattyn( IssmDouble* solutiong);
     244                void           InputUpdateFromSolutionDiagnosticPattynStokes( IssmDouble* solutiong);
     245                void           InputUpdateFromSolutionDiagnosticHutter( IssmDouble* solutiong);
     246                void           InputUpdateFromSolutionDiagnosticVert( IssmDouble* solutiong);
     247                void           InputUpdateFromSolutionDiagnosticStokes( IssmDouble* solutiong);
    247248                void             GetSolutionFromInputsDiagnosticHoriz(Vector* solutiong);
    248249                void             GetSolutionFromInputsDiagnosticHutter(Vector* solutiong);
     
    278279                ElementVector* CreatePVectorAdjointPattyn(void);
    279280                ElementVector* CreatePVectorAdjointStokes(void);
    280                 void    InputUpdateFromSolutionAdjointHoriz( double* solutiong);
    281                 void    InputUpdateFromSolutionAdjointStokes( double* solutiong);
     281                void    InputUpdateFromSolutionAdjointHoriz( IssmDouble* solutiong);
     282                void    InputUpdateFromSolutionAdjointStokes( IssmDouble* solutiong);
    282283                #endif
    283284
     
    303304                ElementVector* CreatePVectorThermalSheet(void);
    304305                void           GetSolutionFromInputsThermal(Vector* solutiong);
    305                 void           InputUpdateFromSolutionThermal( double* solutiong);
    306                 void           InputUpdateFromSolutionEnthalpy( double* solutiong);
     306                void           InputUpdateFromSolutionThermal( IssmDouble* solutiong);
     307                void           InputUpdateFromSolutionEnthalpy( IssmDouble* solutiong);
    307308                #endif
    308309                #ifdef _HAVE_BALANCED_
  • issm/trunk/src/c/objects/Elements/PentaHook.cpp

    r9725 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*Object constructors and destructor*/
    23 /*FUNCTION PentaHook::PentaHook(){{{1*/
     23/*FUNCTION PentaHook::PentaHook(){{{*/
    2424PentaHook::PentaHook(){
    2525        numanalyses=UNDEF;
     
    3030}
    3131/*}}}*/
    32 /*FUNCTION PentaHook::~PentaHook(){{{1*/
     32/*FUNCTION PentaHook::~PentaHook(){{{*/
    3333PentaHook::~PentaHook(){
    3434
     
    4444}
    4545/*}}}*/
    46 /*FUNCTION PentaHook::PentaHook(int in_numanalyses,int matice_id, int matpar_id){{{1*/
     46/*FUNCTION PentaHook::PentaHook(int in_numanalyses,int matice_id, int matpar_id){{{*/
    4747PentaHook::PentaHook(int in_numanalyses,int matice_id, IoModel* iomodel){
    4848
     
    6767/*}}}*/
    6868
    69 /*FUNCTION PentaHook::SetHookNodes{{{1*/
     69/*FUNCTION PentaHook::SetHookNodes{{{*/
    7070void PentaHook::SetHookNodes(int* node_ids,int analysis_counter){
    7171        this->hnodes[analysis_counter]= new Hook(node_ids,6);
     
    7373}
    7474/*}}}*/
    75 /*FUNCTION PentaHook::InitHookNeighbors{{{1*/
     75/*FUNCTION PentaHook::InitHookNeighbors{{{*/
    7676void PentaHook::InitHookNeighbors(int* element_ids){
    7777        this->hneighbors=new Hook(element_ids,2);
     
    7979}
    8080/*}}}*/
    81 /*FUNCTION PentaHook::SpawnTriaHook{{{1*/
     81/*FUNCTION PentaHook::SpawnTriaHook{{{*/
    8282void PentaHook::SpawnTriaHook(TriaHook* triahook,int* indices){
    8383
  • issm/trunk/src/c/objects/Elements/PentaHook.h

    r9356 r12706  
    1919                Hook*  hneighbors; // 2 elements, first down, second up
    2020
    21                 /*FUNCTION constructors, destructors {{{1*/
     21                /*FUNCTION constructors, destructors {{{*/
    2222                PentaHook();
    2323                PentaHook(int in_numanalyses,int matice_id, IoModel* iomodel);
  • issm/trunk/src/c/objects/Elements/PentaRef.cpp

    r10628 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2626
    2727/*Object constructors and destructor*/
    28 /*FUNCTION PentaRef::PentaRef(){{{1*/
     28/*FUNCTION PentaRef::PentaRef(){{{*/
    2929PentaRef::PentaRef(){
    3030        this->element_type_list=NULL;
    3131}
    3232/*}}}*/
    33 /*FUNCTION PentaRef::PentaRef(int* types,int nummodels){{{1*/
     33/*FUNCTION PentaRef::PentaRef(int* types,int nummodels){{{*/
    3434PentaRef::PentaRef(const int nummodels){
    3535
    3636        /*Only allocate pointer*/
    37         element_type_list=(int*)xmalloc(nummodels*sizeof(int));
    38 
    39 }
    40 /*}}}*/
    41 /*FUNCTION PentaRef::~PentaRef(){{{1*/
     37        element_type_list=xNew<int>(nummodels);
     38
     39}
     40/*}}}*/
     41/*FUNCTION PentaRef::~PentaRef(){{{*/
    4242PentaRef::~PentaRef(){
    43         xfree((void**)&element_type_list);
     43        xDelete<int>(element_type_list);
    4444}
    4545/*}}}*/
    4646
    4747/*Management*/
    48 /*FUNCTION PentaRef::SetElementType{{{1*/
     48/*FUNCTION PentaRef::SetElementType{{{*/
    4949void PentaRef::SetElementType(int type,int type_counter){
    5050
     
    5757
    5858/*Reference Element numerics*/
    59 /*FUNCTION PentaRef::GetBMacAyealPattyn {{{1*/
    60 void PentaRef::GetBMacAyealPattyn(double* B, double* xyz_list, GaussPenta* gauss){
     59/*FUNCTION PentaRef::GetBMacAyealPattyn {{{*/
     60void PentaRef::GetBMacAyealPattyn(IssmDouble* B, IssmDouble* xyz_list, GaussPenta* gauss){
    6161        /*Compute B  matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF2.
    6262         * For node i, Bi can be expressed in the actual coordinate system
     
    7070         */
    7171
    72         double dbasis[3][NUMNODESP1];
     72        IssmDouble dbasis[3][NUMNODESP1];
    7373
    7474        /*Get dbasis in actual coordinate system: */
     
    8888}
    8989/*}}}*/
    90 /*FUNCTION PentaRef::GetBMacAyealStokes{{{1*/
    91 void PentaRef::GetBMacAyealStokes(double* B, double* xyz_list, GaussPenta* gauss){
     90/*FUNCTION PentaRef::GetBMacAyealStokes{{{*/
     91void PentaRef::GetBMacAyealStokes(IssmDouble* B, IssmDouble* xyz_list, GaussPenta* gauss){
    9292        /*Compute B  matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF2.
    9393         * For node i, Bi can be expressed in the actual coordinate system
     
    103103
    104104        int    i;
    105         double dh1dh7[3][NUMNODESMINI];
    106         double l1l6[NUMNODESP1];
     105        IssmDouble dh1dh7[3][NUMNODESMINI];
     106        IssmDouble l1l6[NUMNODESP1];
    107107
    108108        /*Get dh1dh6 in actual coordinate system: */
     
    134134}
    135135/*}}}*/
    136 /*FUNCTION PentaRef::GetBPattyn {{{1*/
    137 void PentaRef::GetBPattyn(double* B, double* xyz_list, GaussPenta* gauss){
     136/*FUNCTION PentaRef::GetBPattyn {{{*/
     137void PentaRef::GetBPattyn(IssmDouble* B, IssmDouble* xyz_list, GaussPenta* gauss){
    138138        /*Compute B  matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF2.
    139139         * For node i, Bi can be expressed in the actual coordinate system
     
    149149         */
    150150
    151         double dbasis[3][NUMNODESP1];
     151        IssmDouble dbasis[3][NUMNODESP1];
    152152
    153153        /*Get dbasis in actual coordinate system: */
     
    174174}
    175175/*}}}*/
    176 /*FUNCTION PentaRef::GetBprimePattyn {{{1*/
    177 void PentaRef::GetBprimePattyn(double* B, double* xyz_list, GaussPenta* gauss_coord){
     176/*FUNCTION PentaRef::GetBprimePattyn {{{*/
     177void PentaRef::GetBprimePattyn(IssmDouble* B, IssmDouble* xyz_list, GaussPenta* gauss_coord){
    178178        /*Compute B  prime matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF2.
    179179         * For node i, Bi can be expressed in the actual coordinate system
     
    188188         * We assume B has been allocated already, of size: 5x(NDOF2*NUMNODESP1)
    189189         */
    190         double dbasis[3][NUMNODESP1];
     190        IssmDouble dbasis[3][NUMNODESP1];
    191191
    192192        /*Get dbasis in actual coordinate system: */
     
    212212}
    213213/*}}}*/
    214 /*FUNCTION PentaRef::GetBprimeMacAyealStokes{{{1*/
    215 void PentaRef::GetBprimeMacAyealStokes(double* Bprime, double* xyz_list, GaussPenta* gauss){
     214/*FUNCTION PentaRef::GetBprimeMacAyealStokes{{{*/
     215void PentaRef::GetBprimeMacAyealStokes(IssmDouble* Bprime, IssmDouble* xyz_list, GaussPenta* gauss){
    216216        /*Compute Bprime  matrix. Bprime=[Bprime1 Bprime2 Bprime3 Bprime4 Bprime5 Bprime6] where Bprimei is of size 5*NDOF2.
    217217         * For node i, Bprimei can be expressed in the actual coordinate system
     
    226226
    227227        int    i;
    228         double dh1dh7[3][NUMNODESMINI];
     228        IssmDouble dh1dh7[3][NUMNODESMINI];
    229229
    230230        /*Get dh1dh6 in actual coordinate system: */
     
    252252}
    253253/*}}}*/
    254 /*FUNCTION PentaRef::GetBStokes {{{1*/
    255 void PentaRef::GetBStokes(double* B, double* xyz_list, GaussPenta* gauss){
     254/*FUNCTION PentaRef::GetBStokes {{{*/
     255void PentaRef::GetBStokes(IssmDouble* B, IssmDouble* xyz_list, GaussPenta* gauss){
    256256
    257257        /*Compute B  matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 3*NDOF4.
     
    271271        int i;
    272272
    273         double dh1dh7[3][NUMNODESMINI];
    274         double l1l6[NUMNODESP1];
     273        IssmDouble dh1dh7[3][NUMNODESMINI];
     274        IssmDouble l1l6[NUMNODESP1];
    275275
    276276        /*Get dh1dh7 in actual coordinate system: */
     
    319319}
    320320/*}}}*/
    321 /*FUNCTION PentaRef::GetBprimeStokes {{{1*/
    322 void PentaRef::GetBprimeStokes(double* B_prime, double* xyz_list, GaussPenta* gauss){
     321/*FUNCTION PentaRef::GetBprimeStokes {{{*/
     322void PentaRef::GetBprimeStokes(IssmDouble* B_prime, IssmDouble* xyz_list, GaussPenta* gauss){
    323323        /*      Compute B'  matrix. B'=[B1' B2' B3' B4' B5' B6' Bb'] where Bi' is of size 3*NDOF2.
    324324         *      For node i, Bi' can be expressed in the actual coordinate system
     
    338338
    339339        int i;
    340         double dh1dh7[3][NUMNODESMINI];
    341         double l1l6[NUMNODESP1];
     340        IssmDouble dh1dh7[3][NUMNODESMINI];
     341        IssmDouble l1l6[NUMNODESP1];
    342342
    343343        /*Get dh1dh7 in actual coordinate system: */
     
    386386}
    387387/*}}}*/
    388 /*FUNCTION PentaRef::GetBAdvec{{{1*/
    389 void PentaRef::GetBAdvec(double* B_advec, double* xyz_list, GaussPenta* gauss){
     388/*FUNCTION PentaRef::GetBAdvec{{{*/
     389void PentaRef::GetBAdvec(IssmDouble* B_advec, IssmDouble* xyz_list, GaussPenta* gauss){
    390390        /*Compute B  matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1.
    391391         * For node i, Bi' can be expressed in the actual coordinate system
     
    400400
    401401        /*Same thing in the actual coordinate system: */
    402         double l1l6[6];
     402        IssmDouble l1l6[6];
    403403
    404404        /*Get dh1dh2dh3 in actual coordinates system : */
     
    413413}
    414414/*}}}*/
    415 /*FUNCTION PentaRef::GetBConduct{{{1*/
    416 void PentaRef::GetBConduct(double* B_conduct, double* xyz_list, GaussPenta* gauss){
     415/*FUNCTION PentaRef::GetBConduct{{{*/
     416void PentaRef::GetBConduct(IssmDouble* B_conduct, IssmDouble* xyz_list, GaussPenta* gauss){
    417417        /*Compute B  matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1.
    418418         * For node i, Bi' can be expressed in the actual coordinate system
     
    427427
    428428        /*Same thing in the actual coordinate system: */
    429         double dh1dh6[3][NUMNODESP1];
     429        IssmDouble dh1dh6[3][NUMNODESP1];
    430430
    431431        /*Get dh1dh2dh3 in actual coordinates system : */
     
    440440}
    441441/*}}}*/
    442 /*FUNCTION PentaRef::GetBVert{{{1*/
    443 void PentaRef::GetBVert(double* B, double* xyz_list, GaussPenta* gauss){
     442/*FUNCTION PentaRef::GetBVert{{{*/
     443void PentaRef::GetBVert(IssmDouble* B, IssmDouble* xyz_list, GaussPenta* gauss){
    444444        /*      Compute B  matrix. B=[dh1/dz dh2/dz dh3/dz dh4/dz dh5/dz dh6/dz];
    445445                where hi is the interpolation function for node i.*/
    446446
    447447        int i;
    448         double dh1dh6[3][NUMNODESP1];
     448        IssmDouble dh1dh6[3][NUMNODESP1];
    449449
    450450        /*Get dh1dh6 in actual coordinate system: */
     
    458458}
    459459/*}}}*/
    460 /*FUNCTION PentaRef::GetBprimeAdvec{{{1*/
    461 void PentaRef::GetBprimeAdvec(double* Bprime_advec, double* xyz_list, GaussPenta* gauss){
     460/*FUNCTION PentaRef::GetBprimeAdvec{{{*/
     461void PentaRef::GetBprimeAdvec(IssmDouble* Bprime_advec, IssmDouble* xyz_list, GaussPenta* gauss){
    462462        /*Compute B  matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1.
    463463         * For node i, Bi' can be expressed in the actual coordinate system
     
    472472
    473473        /*Same thing in the actual coordinate system: */
    474         double dh1dh6[3][NUMNODESP1];
     474        IssmDouble dh1dh6[3][NUMNODESP1];
    475475
    476476        /*Get dh1dh2dh3 in actual coordinates system : */
     
    485485}
    486486/*}}}*/
    487 /*FUNCTION PentaRef::GetBprimeVert{{{1*/
    488 void PentaRef::GetBprimeVert(double* B, double* xyz_list, GaussPenta* gauss){
     487/*FUNCTION PentaRef::GetBprimeVert{{{*/
     488void PentaRef::GetBprimeVert(IssmDouble* B, IssmDouble* xyz_list, GaussPenta* gauss){
    489489        /* Compute Bprime  matrix. Bprime=[L1 L2 L3 L4 L5 L6] where Li is the nodal function for node i*/
    490490
     
    493493}
    494494/*}}}*/
    495 /*FUNCTION PentaRef::GetL{{{1*/
    496 void PentaRef::GetL(double* L, GaussPenta* gauss, int numdof){
     495/*FUNCTION PentaRef::GetL{{{*/
     496void PentaRef::GetL(IssmDouble* L, GaussPenta* gauss, int numdof){
    497497        /*Compute L  matrix. L=[L1 L2 L3] where Li is square and of size numdof.
    498498         ** For node i, Li can be expressed in the actual coordinate system
     
    509509
    510510        int i;
    511         double l1l6[6];
     511        IssmDouble l1l6[6];
    512512
    513513        /*Get l1l6 in actual coordinate system: */
     
    530530}
    531531/*}}}*/
    532 /*FUNCTION PentaRef::GetLStokes{{{1*/
    533 void PentaRef::GetLStokes(double* LStokes, GaussPenta* gauss){
     532/*FUNCTION PentaRef::GetLStokes{{{*/
     533void PentaRef::GetLStokes(IssmDouble* LStokes, GaussPenta* gauss){
    534534        /*
    535535         * Compute L  matrix. L=[L1 L2 L3] where Li is square and of size numdof.
     
    544544
    545545        const int num_dof=4;
    546         double l1l2l3[NUMNODESP1_2d];
     546        IssmDouble l1l2l3[NUMNODESP1_2d];
    547547
    548548        /*Get l1l2l3 in actual coordinate system: */
     
    565565}
    566566/*}}}*/
    567 /*FUNCTION PentaRef::GetLprimeStokes {{{1*/
    568 void PentaRef::GetLprimeStokes(double* LprimeStokes, double* xyz_list, GaussPenta* gauss){
     567/*FUNCTION PentaRef::GetLprimeStokes {{{*/
     568void PentaRef::GetLprimeStokes(IssmDouble* LprimeStokes, IssmDouble* xyz_list, GaussPenta* gauss){
    569569
    570570        /*
     
    606606        int num_dof=4;
    607607
    608         double l1l2l3[NUMNODESP1_2d];
    609         double dh1dh6[3][NUMNODESP1];
     608        IssmDouble l1l2l3[NUMNODESP1_2d];
     609        IssmDouble dh1dh6[3][NUMNODESP1];
    610610
    611611        /*Get l1l2l3 in actual coordinate system: */
     
    677677}
    678678/*}}}*/
    679 /*FUNCTION PentaRef::GetLMacAyealStokes {{{1*/
    680 void PentaRef::GetLMacAyealStokes(double* LStokes, GaussPenta* gauss){
     679/*FUNCTION PentaRef::GetLMacAyealStokes {{{*/
     680void PentaRef::GetLMacAyealStokes(IssmDouble* LStokes, GaussPenta* gauss){
    681681        /*
    682682         * Compute L  matrix. L=[L1 L2 L3] where Li is square and of size numdof.
     
    697697        int num_dof=2;
    698698
    699         double l1l2l3[NUMNODESP1_2d];
     699        IssmDouble l1l2l3[NUMNODESP1_2d];
    700700
    701701
     
    727727}
    728728/*}}}*/
    729 /*FUNCTION PentaRef::GetLprimeMacAyealStokes {{{1*/
    730 void PentaRef::GetLprimeMacAyealStokes(double* LprimeStokes, double* xyz_list, GaussPenta* gauss){
     729/*FUNCTION PentaRef::GetLprimeMacAyealStokes {{{*/
     730void PentaRef::GetLprimeMacAyealStokes(IssmDouble* LprimeStokes, IssmDouble* xyz_list, GaussPenta* gauss){
    731731
    732732        /*
     
    747747        int num_dof=4;
    748748
    749         double l1l2l3[NUMNODESP1_2d];
    750         double dh1dh6[3][NUMNODESP1];
     749        IssmDouble l1l2l3[NUMNODESP1_2d];
     750        IssmDouble dh1dh6[3][NUMNODESP1];
    751751
    752752        /*Get l1l2l3 in actual coordinate system: */
     
    794794}
    795795/*}}}*/
    796 /*FUNCTION PentaRef::GetLStokesMacAyeal {{{1*/
    797 void PentaRef::GetLStokesMacAyeal(double* LStokes, GaussPenta* gauss){
     796/*FUNCTION PentaRef::GetLStokesMacAyeal {{{*/
     797void PentaRef::GetLStokesMacAyeal(IssmDouble* LStokes, GaussPenta* gauss){
    798798        /*
    799799         * Compute L  matrix. L=[L1 L2 L3] where Li is square and of size numdof.
     
    810810        int num_dof=4;
    811811
    812         double l1l2l3[NUMNODESP1_2d];
     812        IssmDouble l1l2l3[NUMNODESP1_2d];
    813813
    814814
     
    840840}
    841841/*}}}*/
    842 /*FUNCTION PentaRef::GetLprimeStokesMacAyeal {{{1*/
    843 void PentaRef::GetLprimeStokesMacAyeal(double* LprimeStokes, double* xyz_list, GaussPenta* gauss){
     842/*FUNCTION PentaRef::GetLprimeStokesMacAyeal {{{*/
     843void PentaRef::GetLprimeStokesMacAyeal(IssmDouble* LprimeStokes, IssmDouble* xyz_list, GaussPenta* gauss){
    844844
    845845        /*
     
    856856        int num_dof=2;
    857857
    858         double l1l2l3[NUMNODESP1_2d];
    859         double dh1dh6[3][NUMNODESP1];
     858        IssmDouble l1l2l3[NUMNODESP1_2d];
     859        IssmDouble dh1dh6[3][NUMNODESP1];
    860860
    861861        /*Get l1l2l3 in actual coordinate system: */
     
    879879}
    880880/*}}}*/
    881 /*FUNCTION PentaRef::GetJacobian {{{1*/
    882 void PentaRef::GetJacobian(double* J, double* xyz_list,GaussPenta* gauss){
     881/*FUNCTION PentaRef::GetJacobian {{{*/
     882void PentaRef::GetJacobian(IssmDouble* J, IssmDouble* xyz_list,GaussPenta* gauss){
    883883
    884884        int i,j;
     
    887887         * J is assumed to have been allocated of size NDOF2xNDOF2.*/
    888888
    889         double A1,A2,A3; //area coordinates
    890         double xi,eta,zi; //parametric coordinates
    891 
    892         double x1,x2,x3,x4,x5,x6;
    893         double y1,y2,y3,y4,y5,y6;
    894         double z1,z2,z3,z4,z5,z6;
     889        IssmDouble A1,A2,A3; //area coordinates
     890        IssmDouble xi,eta,zi; //parametric coordinates
     891
     892        IssmDouble x1,x2,x3,x4,x5,x6;
     893        IssmDouble y1,y2,y3,y4,y5,y6;
     894        IssmDouble z1,z2,z3,z4,z5,z6;
    895895
    896896        /*Figure out xi,eta and zi (parametric coordinates), for this gaussian point: */
     
    938938}
    939939/*}}}*/
    940 /*FUNCTION PentaRef::GetJacobianDeterminant {{{1*/
    941 void PentaRef::GetJacobianDeterminant(double*  Jdet, double* xyz_list,GaussPenta* gauss){
     940/*FUNCTION PentaRef::GetJacobianDeterminant {{{*/
     941void PentaRef::GetJacobianDeterminant(IssmDouble*  Jdet, IssmDouble* xyz_list,GaussPenta* gauss){
    942942        /*On a penta, Jacobian varies according to coordinates. We need to get the Jacobian, and take
    943943         * the determinant of it: */
    944         double J[3][3];
     944        IssmDouble J[3][3];
    945945
    946946        /*Get Jacobian*/
     
    949949        /*Get Determinant*/
    950950        Matrix3x3Determinant(Jdet,&J[0][0]);
    951         if(*Jdet<0) _error_("negative jacobian determinant!");
    952 
    953 }
    954 /*}}}*/
    955 /*FUNCTION PentaRef::GetTriaJacobianDeterminant{{{1*/
    956 void PentaRef::GetTriaJacobianDeterminant(double*  Jdet, double* xyz_list,GaussPenta* gauss){
     951        if(*Jdet<0) _error2_("negative jacobian determinant!");
     952
     953}
     954/*}}}*/
     955/*FUNCTION PentaRef::GetTriaJacobianDeterminant{{{*/
     956void PentaRef::GetTriaJacobianDeterminant(IssmDouble*  Jdet, IssmDouble* xyz_list,GaussPenta* gauss){
    957957        /*The Jacobian determinant is constant over the element, discard the gaussian points.
    958958         * J is assumed to have been allocated of size NDOF2xNDOF2.*/
    959959
    960         double x1,x2,x3,y1,y2,y3,z1,z2,z3;
     960        IssmDouble x1,x2,x3,y1,y2,y3,z1,z2,z3;
    961961
    962962        x1=*(xyz_list+3*0+0);
     
    972972        /*Jdet = norm( AB ^ AC ) / (2 * area of the reference triangle), with areaRef=sqrt(3) */
    973973        *Jdet=SQRT3/6.0*pow(pow(((y2-y1)*(z3-z1)-(z2-z1)*(y3-y1)),2.0)+pow(((z2-z1)*(x3-x1)-(x2-x1)*(z3-z1)),2.0)+pow(((x2-x1)*(y3-y1)-(y2-y1)*(x3-x1)),2.0),0.5);
    974         if(*Jdet<0) _error_("negative jacobian determinant!");
    975 }
    976 /*}}}*/
    977 /*FUNCTION PentaRef::GetSegmentJacobianDeterminant{{{1*/
    978 void PentaRef::GetSegmentJacobianDeterminant(double*  Jdet, double* xyz_list,GaussPenta* gauss){
     974        if(*Jdet<0) _error2_("negative jacobian determinant!");
     975}
     976/*}}}*/
     977/*FUNCTION PentaRef::GetSegmentJacobianDeterminant{{{*/
     978void PentaRef::GetSegmentJacobianDeterminant(IssmDouble*  Jdet, IssmDouble* xyz_list,GaussPenta* gauss){
    979979        /*The Jacobian determinant is constant over the element, discard the gaussian points.
    980980         * J is assumed to have been allocated of size NDOF2xNDOF2.*/
    981981
    982         double x1,x2,y1,y2,z1,z2;
     982        IssmDouble x1,x2,y1,y2,z1,z2;
    983983
    984984        x1=*(xyz_list+3*0+0);
     
    990990
    991991        *Jdet=1.0/2.0*sqrt(pow(x2-x1,2.) + pow(y2-y1,2.) + pow(z2-z1,2.));
    992         if(*Jdet<0) _error_("negative jacobian determinant!");
    993 
    994 }
    995 /*}}}*/
    996 /*FUNCTION PentaRef::GetJacobianInvert {{{1*/
    997 void PentaRef::GetJacobianInvert(double* Jinv, double* xyz_list,GaussPenta* gauss){
     992        if(*Jdet<0) _error2_("negative jacobian determinant!");
     993
     994}
     995/*}}}*/
     996/*FUNCTION PentaRef::GetJacobianInvert {{{*/
     997void PentaRef::GetJacobianInvert(IssmDouble* Jinv, IssmDouble* xyz_list,GaussPenta* gauss){
    998998
    999999        /*Jacobian*/
    1000         double J[3][3];
     1000        IssmDouble J[3][3];
    10011001
    10021002        /*Call Jacobian routine to get the jacobian:*/
     
    10071007}
    10081008/*}}}*/
    1009 /*FUNCTION PentaRef::GetNodalFunctionsMINI{{{1*/
    1010 void PentaRef::GetNodalFunctionsMINI(double* l1l7, GaussPenta* gauss){
     1009/*FUNCTION PentaRef::GetNodalFunctionsMINI{{{*/
     1010void PentaRef::GetNodalFunctionsMINI(IssmDouble* l1l7, GaussPenta* gauss){
    10111011        /*This routine returns the values of the nodal functions  at the gaussian point.*/
    10121012
     
    10211021}
    10221022/*}}}*/
    1023 /*FUNCTION PentaRef::GetNodalFunctionsMINIDerivatives{{{1*/
    1024 void PentaRef::GetNodalFunctionsMINIDerivatives(double* dh1dh7,double* xyz_list, GaussPenta* gauss){
     1023/*FUNCTION PentaRef::GetNodalFunctionsMINIDerivatives{{{*/
     1024void PentaRef::GetNodalFunctionsMINIDerivatives(IssmDouble* dh1dh7,IssmDouble* xyz_list, GaussPenta* gauss){
    10251025
    10261026        /*This routine returns the values of the nodal functions derivatives  (with respect to the
     
    10281028
    10291029        int       i;
    1030         double    dh1dh7_ref[3][NUMNODESMINI];
    1031         double    Jinv[3][3];
     1030        IssmDouble    dh1dh7_ref[3][NUMNODESMINI];
     1031        IssmDouble    Jinv[3][3];
    10321032
    10331033        /*Get derivative values with respect to parametric coordinate system: */
     
    10521052}
    10531053/*}}}*/
    1054 /*FUNCTION PentaRef::GetNodalFunctionsMINIDerivativesReference{{{1*/
    1055 void PentaRef::GetNodalFunctionsMINIDerivativesReference(double* dl1dl7,GaussPenta* gauss){
     1054/*FUNCTION PentaRef::GetNodalFunctionsMINIDerivativesReference{{{*/
     1055void PentaRef::GetNodalFunctionsMINIDerivativesReference(IssmDouble* dl1dl7,GaussPenta* gauss){
    10561056
    10571057        /*This routine returns the values of the nodal functions derivatives  (with respect to the
    10581058         * natural coordinate system) at the gaussian point. */
    1059         double r=gauss->coord2-gauss->coord1;
    1060         double s=-3.0/SQRT3*(gauss->coord1+gauss->coord2-2.0/3.0);
    1061         double zeta=gauss->coord4;
     1059        IssmDouble r=gauss->coord2-gauss->coord1;
     1060        IssmDouble s=-3.0/SQRT3*(gauss->coord1+gauss->coord2-2.0/3.0);
     1061        IssmDouble zeta=gauss->coord4;
    10621062
    10631063        /*First nodal function: */
     
    10981098}
    10991099/*}}}*/
    1100 /*FUNCTION PentaRef::GetNodalFunctionsP1 {{{1*/
    1101 void PentaRef::GetNodalFunctionsP1(double* l1l6, GaussPenta* gauss){
     1100/*FUNCTION PentaRef::GetNodalFunctionsP1 {{{*/
     1101void PentaRef::GetNodalFunctionsP1(IssmDouble* l1l6, GaussPenta* gauss){
    11021102        /*This routine returns the values of the nodal functions  at the gaussian point.*/
    11031103
     
    11111111}
    11121112/*}}}*/
    1113 /*FUNCTION PentaRef::GetNodalFunctionsP1Derivatives {{{1*/
    1114 void PentaRef::GetNodalFunctionsP1Derivatives(double* dh1dh6,double* xyz_list, GaussPenta* gauss){
     1113/*FUNCTION PentaRef::GetNodalFunctionsP1Derivatives {{{*/
     1114void PentaRef::GetNodalFunctionsP1Derivatives(IssmDouble* dh1dh6,IssmDouble* xyz_list, GaussPenta* gauss){
    11151115
    11161116        /*This routine returns the values of the nodal functions derivatives  (with respect to the
    11171117         * actual coordinate system): */
    1118         double    dh1dh6_ref[NDOF3][NUMNODESP1];
    1119         double    Jinv[NDOF3][NDOF3];
     1118        IssmDouble    dh1dh6_ref[NDOF3][NUMNODESP1];
     1119        IssmDouble    Jinv[NDOF3][NDOF3];
    11201120
    11211121        /*Get derivative values with respect to parametric coordinate system: */
     
    11401140}
    11411141/*}}}*/
    1142 /*FUNCTION PentaRef::GetNodalFunctionsP1DerivativesReference {{{1*/
    1143 void PentaRef::GetNodalFunctionsP1DerivativesReference(double* dl1dl6,GaussPenta* gauss){
     1142/*FUNCTION PentaRef::GetNodalFunctionsP1DerivativesReference {{{*/
     1143void PentaRef::GetNodalFunctionsP1DerivativesReference(IssmDouble* dl1dl6,GaussPenta* gauss){
    11441144
    11451145        /*This routine returns the values of the nodal functions derivatives  (with respect to the
    11461146         * natural coordinate system) at the gaussian point. Those values vary along xi,eta,z */
    11471147
    1148         double A1,A2,A3,z;
     1148        IssmDouble A1,A2,A3,z;
    11491149
    11501150        A1=gauss->coord1; _assert_(A1>=0 && A1<=1);//first area coordinate value. In term of xi and eta: A1=(1-xi)/2-eta/(2*SQRT3);
     
    11841184}
    11851185/*}}}*/
    1186 /*FUNCTION PentaRef::GetQuadNodalFunctions {{{1*/
    1187 void PentaRef::GetQuadNodalFunctions(double* l1l4,GaussPenta* gauss,int index1,int index2,int index3,int index4){
     1186/*FUNCTION PentaRef::GetQuadNodalFunctions {{{*/
     1187void PentaRef::GetQuadNodalFunctions(IssmDouble* l1l4,GaussPenta* gauss,int index1,int index2,int index3,int index4){
    11881188        /*This routine returns the values of the nodal functions  at the gaussian point.*/
    11891189
    1190         double BasisFunctions[6];
     1190        IssmDouble BasisFunctions[6];
    11911191
    11921192        GetNodalFunctionsP1(&BasisFunctions[0],gauss);
     
    12041204}
    12051205/*}}}*/
    1206 /*FUNCTION PentaRef::GetQuadJacobianDeterminant{{{1*/
    1207 void PentaRef::GetQuadJacobianDeterminant(double* Jdet,double xyz_list[4][3],GaussPenta* gauss){
     1206/*FUNCTION PentaRef::GetQuadJacobianDeterminant{{{*/
     1207void PentaRef::GetQuadJacobianDeterminant(IssmDouble* Jdet,IssmDouble xyz_list[4][3],GaussPenta* gauss){
    12081208        /*This routine returns the values of the nodal functions  at the gaussian point.*/
    12091209
    1210         double x1,x2,x3,x4,y1,y2,y3,y4,z1,z2,z3,z4;
     1210        IssmDouble x1,x2,x3,x4,y1,y2,y3,y4,z1,z2,z3,z4;
    12111211
    12121212        x1=xyz_list[0][0];
     
    12261226        /*Area of a trabezoid = altitude * (base1 + base2)/2 */
    12271227        *Jdet= pow(pow(x2-x1,2.) + pow(y2-y1,2.),0.5) * (z4-z1 + z3-z2)/8;
    1228         if(*Jdet<0) _error_("negative jacobian determinant!");
    1229 
    1230 }
    1231 /*}}}*/
    1232 /*FUNCTION PentaRef::GetInputValue{{{1*/
    1233 void PentaRef::GetInputValue(double* pvalue,double* plist,GaussPenta* gauss){
     1228        if(*Jdet<0) _error2_("negative jacobian determinant!");
     1229
     1230}
     1231/*}}}*/
     1232/*FUNCTION PentaRef::GetInputValue{{{*/
     1233void PentaRef::GetInputValue(IssmDouble* pvalue,IssmDouble* plist,GaussPenta* gauss){
    12341234        /*P1 interpolation on Gauss point*/
    12351235
    12361236        /*intermediary*/
    1237         double l1l6[6];
     1237        IssmDouble l1l6[6];
    12381238
    12391239        /*nodal functions: */
     
    12451245}
    12461246/*}}}*/
    1247 /*FUNCTION PentaRef::GetInputDerivativeValue{{{1*/
    1248 void PentaRef::GetInputDerivativeValue(double* p, double* plist,double* xyz_list, GaussPenta* gauss){
     1247/*FUNCTION PentaRef::GetInputDerivativeValue{{{*/
     1248void PentaRef::GetInputDerivativeValue(IssmDouble* p, IssmDouble* plist,IssmDouble* xyz_list, GaussPenta* gauss){
    12491249        /*From node values of parameter p (p_list[0], p_list[1], p_list[2], p_list[3], p_list[4] and p_list[4]), return parameter derivative value at gaussian point specified by gauss_coord:
    12501250         *   dp/dx=p_list[0]*dh1/dx+p_list[1]*dh2/dx+p_list[2]*dh3/dx+p_list[3]*dh4/dx+p_list[4]*dh5/dx+p_list[5]*dh6/dx;
     
    12541254         *   p is a vector of size 3x1 already allocated.
    12551255         */
    1256         double dh1dh6[3][NUMNODESP1];
     1256        IssmDouble dh1dh6[3][NUMNODESP1];
    12571257
    12581258        /*Get nodal funnctions derivatives in actual coordinate system: */
  • issm/trunk/src/c/objects/Elements/PentaRef.h

    r10628 r12706  
    2323
    2424                /*Numerics*/
    25                 void GetNodalFunctionsP1(double* l1l6, GaussPenta* gauss);
    26                 void GetNodalFunctionsMINI(double* l1l7, GaussPenta* gauss);
    27                 void GetNodalFunctionsP1Derivatives(double* dh1dh6,double* xyz_list, GaussPenta* gauss);
    28                 void GetNodalFunctionsMINIDerivatives(double* dh1dh7,double* xyz_list, GaussPenta* gauss);
    29                 void GetNodalFunctionsP1DerivativesReference(double* dl1dl6,GaussPenta* gauss);
    30                 void GetNodalFunctionsMINIDerivativesReference(double* dl1dl7,GaussPenta* gauss);
    31                 void GetQuadNodalFunctions(double* l1l4,GaussPenta* gauss,int index1,int index2,int index3,int index4);
    32                 void GetQuadJacobianDeterminant(double*  Jdet, double xyz_list[4][3],GaussPenta* gauss);
    33                 void GetJacobian(double* J, double* xyz_list,GaussPenta* gauss);
    34                 void GetJacobianDeterminant(double*  Jdet, double* xyz_list,GaussPenta* gauss);
    35                 void GetTriaJacobianDeterminant(double*  Jdet, double* xyz_list,GaussPenta* gauss);
    36                 void GetSegmentJacobianDeterminant(double*  Jdet, double* xyz_list,GaussPenta* gauss);
    37                 void GetJacobianInvert(double*  Jinv, double* xyz_list,GaussPenta* gauss);
    38                 void GetBMacAyealPattyn(double* B, double* xyz_list, GaussPenta* gauss);
    39                 void GetBMacAyealStokes(double* B, double* xyz_list, GaussPenta* gauss);
    40                 void GetBPattyn(double* B, double* xyz_list, GaussPenta* gauss);
    41                 void GetBStokes(double* B, double* xyz_list, GaussPenta* gauss);
    42                 void GetBprimeMacAyealStokes(double* Bprime, double* xyz_list, GaussPenta* gauss);
    43                 void GetBprimePattyn(double* B, double* xyz_list, GaussPenta* gauss);
    44                 void GetBprimeStokes(double* B_prime, double* xyz_list, GaussPenta* gauss);
    45                 void GetBprimeVert(double* B, double* xyz_list, GaussPenta* gauss);
    46                 void GetBAdvec(double* B_advec, double* xyz_list, GaussPenta* gauss);
    47                 void GetBConduct(double* B_conduct, double* xyz_list, GaussPenta* gauss);
    48                 void GetBVert(double* B, double* xyz_list, GaussPenta* gauss);
    49                 void GetBprimeAdvec(double* Bprime_advec, double* xyz_list, GaussPenta* gauss);
    50                 void GetL(double* L, GaussPenta* gauss,int numdof);
    51                 void GetLStokes(double* LStokes, GaussPenta* gauss);
    52                 void GetLprimeStokes(double* LprimeStokes, double* xyz_list, GaussPenta* gauss);
    53                 void GetLMacAyealStokes(double* LMacAyealStokes, GaussPenta* gauss);
    54                 void GetLprimeMacAyealStokes(double* LprimeMacAyealStokes, double* xyz_list, GaussPenta* gauss);
    55                 void GetLStokesMacAyeal(double* LStokesMacAyeal, GaussPenta* gauss);
    56                 void GetLprimeStokesMacAyeal(double* LprimeStokesMacAyeal, double* xyz_list, GaussPenta* gauss);
    57                 void GetInputValue(double* pvalue,double* plist, GaussPenta* gauss);
    58                 void GetInputValue(double* pvalue,double* plist,GaussTria* gauss){_error_("only PentaGauss are supported");};
    59                 void GetInputDerivativeValue(double* pvalues, double* plist,double* xyz_list, GaussPenta* gauss);
    60                 void GetInputDerivativeValue(double* pvalues, double* plist,double* xyz_list, GaussTria* gauss){_error_("only PentaGauss are supported");};
     25                void GetNodalFunctionsP1(IssmDouble* l1l6, GaussPenta* gauss);
     26                void GetNodalFunctionsMINI(IssmDouble* l1l7, GaussPenta* gauss);
     27                void GetNodalFunctionsP1Derivatives(IssmDouble* dh1dh6,IssmDouble* xyz_list, GaussPenta* gauss);
     28                void GetNodalFunctionsMINIDerivatives(IssmDouble* dh1dh7,IssmDouble* xyz_list, GaussPenta* gauss);
     29                void GetNodalFunctionsP1DerivativesReference(IssmDouble* dl1dl6,GaussPenta* gauss);
     30                void GetNodalFunctionsMINIDerivativesReference(IssmDouble* dl1dl7,GaussPenta* gauss);
     31                void GetQuadNodalFunctions(IssmDouble* l1l4,GaussPenta* gauss,int index1,int index2,int index3,int index4);
     32                void GetQuadJacobianDeterminant(IssmDouble*  Jdet, IssmDouble xyz_list[4][3],GaussPenta* gauss);
     33                void GetJacobian(IssmDouble* J, IssmDouble* xyz_list,GaussPenta* gauss);
     34                void GetJacobianDeterminant(IssmDouble*  Jdet, IssmDouble* xyz_list,GaussPenta* gauss);
     35                void GetTriaJacobianDeterminant(IssmDouble*  Jdet, IssmDouble* xyz_list,GaussPenta* gauss);
     36                void GetSegmentJacobianDeterminant(IssmDouble*  Jdet, IssmDouble* xyz_list,GaussPenta* gauss);
     37                void GetJacobianInvert(IssmDouble*  Jinv, IssmDouble* xyz_list,GaussPenta* gauss);
     38                void GetBMacAyealPattyn(IssmDouble* B, IssmDouble* xyz_list, GaussPenta* gauss);
     39                void GetBMacAyealStokes(IssmDouble* B, IssmDouble* xyz_list, GaussPenta* gauss);
     40                void GetBPattyn(IssmDouble* B, IssmDouble* xyz_list, GaussPenta* gauss);
     41                void GetBStokes(IssmDouble* B, IssmDouble* xyz_list, GaussPenta* gauss);
     42                void GetBprimeMacAyealStokes(IssmDouble* Bprime, IssmDouble* xyz_list, GaussPenta* gauss);
     43                void GetBprimePattyn(IssmDouble* B, IssmDouble* xyz_list, GaussPenta* gauss);
     44                void GetBprimeStokes(IssmDouble* B_prime, IssmDouble* xyz_list, GaussPenta* gauss);
     45                void GetBprimeVert(IssmDouble* B, IssmDouble* xyz_list, GaussPenta* gauss);
     46                void GetBAdvec(IssmDouble* B_advec, IssmDouble* xyz_list, GaussPenta* gauss);
     47                void GetBConduct(IssmDouble* B_conduct, IssmDouble* xyz_list, GaussPenta* gauss);
     48                void GetBVert(IssmDouble* B, IssmDouble* xyz_list, GaussPenta* gauss);
     49                void GetBprimeAdvec(IssmDouble* Bprime_advec, IssmDouble* xyz_list, GaussPenta* gauss);
     50                void GetL(IssmDouble* L, GaussPenta* gauss,int numdof);
     51                void GetLStokes(IssmDouble* LStokes, GaussPenta* gauss);
     52                void GetLprimeStokes(IssmDouble* LprimeStokes, IssmDouble* xyz_list, GaussPenta* gauss);
     53                void GetLMacAyealStokes(IssmDouble* LMacAyealStokes, GaussPenta* gauss);
     54                void GetLprimeMacAyealStokes(IssmDouble* LprimeMacAyealStokes, IssmDouble* xyz_list, GaussPenta* gauss);
     55                void GetLStokesMacAyeal(IssmDouble* LStokesMacAyeal, GaussPenta* gauss);
     56                void GetLprimeStokesMacAyeal(IssmDouble* LprimeStokesMacAyeal, IssmDouble* xyz_list, GaussPenta* gauss);
     57                void GetInputValue(IssmDouble* pvalue,IssmDouble* plist, GaussPenta* gauss);
     58                void GetInputValue(IssmDouble* pvalue,IssmDouble* plist,GaussTria* gauss){_error2_("only PentaGauss are supported");};
     59                void GetInputDerivativeValue(IssmDouble* pvalues, IssmDouble* plist,IssmDouble* xyz_list, GaussPenta* gauss);
     60                void GetInputDerivativeValue(IssmDouble* pvalues, IssmDouble* plist,IssmDouble* xyz_list, GaussTria* gauss){_error2_("only PentaGauss are supported");};
    6161
    6262};
  • issm/trunk/src/c/objects/Elements/Tria.cpp

    r12643 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2323
    2424/*Constructors/destructor/copy*/
    25 /*FUNCTION Tria::Tria(){{{1*/
     25/*FUNCTION Tria::Tria(){{{*/
    2626Tria::Tria(){
    2727
     
    3838}
    3939/*}}}*/
    40 /*FUNCTION Tria::Tria(int id, int sid,int index, IoModel* iomodel,int nummodels){{{1*/
     40/*FUNCTION Tria::Tria(int id, int sid,int index, IoModel* iomodel,int nummodels){{{*/
    4141Tria::Tria(int tria_id, int tria_sid, int index, IoModel* iomodel,int nummodels)
    4242        :TriaRef(nummodels)
     
    6666}
    6767/*}}}*/
    68 /*FUNCTION Tria::~Tria(){{{1*/
     68/*FUNCTION Tria::~Tria(){{{*/
    6969Tria::~Tria(){
    7070        delete inputs;
     
    7373}
    7474/*}}}*/
    75 /*FUNCTION Tria::copy {{{1*/
     75/*FUNCTION Tria::copy {{{*/
    7676Object* Tria::copy() {
    7777
     
    8282
    8383        //deal with TriaRef mother class
    84         tria->element_type_list=(int*)xmalloc(this->numanalyses*sizeof(int));
     84        tria->element_type_list=xNew<int>(this->numanalyses);
    8585        for(i=0;i<this->numanalyses;i++) tria->element_type_list[i]=this->element_type_list[i];
    8686
     
    111111
    112112        /*recover objects: */
    113         tria->nodes=(Node**)xmalloc(3*sizeof(Node*)); //we cannot rely on an analysis_counter to tell us which analysis_type we are running, so we just copy the nodes.
     113        tria->nodes=xNew<Node*>(3); //we cannot rely on an analysis_counter to tell us which analysis_type we are running, so we just copy the nodes.
    114114        for(i=0;i<3;i++)tria->nodes[i]=this->nodes[i];
    115115        tria->matice=(Matice*)tria->hmatice->delivers();
     
    124124
    125125/*Other*/
    126 /*FUNCTION Tria::AverageOntoPartition {{{1*/
    127 void  Tria::AverageOntoPartition(Vector* partition_contributions,Vector* partition_areas,double* vertex_response,double* qmu_part){
     126/*FUNCTION Tria::AverageOntoPartition {{{*/
     127void  Tria::AverageOntoPartition(Vector* partition_contributions,Vector* partition_areas,IssmDouble* vertex_response,IssmDouble* qmu_part){
    128128
    129129        bool      already=false;
     
    132132        int       offsetsid[NUMVERTICES];
    133133        int       offsetdof[NUMVERTICES];
    134         double    area;
    135         double    mean;
    136         double    values[3];
     134        IssmDouble    area;
     135        IssmDouble    mean;
     136        IssmDouble    values[3];
    137137
    138138        /*First, get the area: */
     
    144144        mean=0;
    145145        for(i=0;i<NUMVERTICES;i++){
    146                 partition[i]=(int)qmu_part[offsetsid[i]];
     146                partition[i]=reCast<int>(qmu_part[offsetsid[i]]);
    147147                mean=mean+1.0/NUMVERTICES*vertex_response[offsetdof[i]];
    148148        }
     
    164164}
    165165/*}}}*/
    166 /*FUNCTION Tria::CreateKMatrix {{{1*/
     166/*FUNCTION Tria::CreateKMatrix {{{*/
    167167void  Tria::CreateKMatrix(Matrix* Kff, Matrix* Kfs,Vector* df){
    168168
     
    172172        parameters->FindParam(&analysis_type,AnalysisTypeEnum);
    173173
    174         /*Checks in debugging mode{{{2*/
     174        /*Checks in debugging mode{{{*/
    175175        _assert_(this->nodes && this->matice && this->matpar && this->parameters && this->inputs);
    176176        /*}}}*/
     
    214214                #endif
    215215                default:
    216                         _error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
     216                        _error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
    217217        }
    218218
     
    224224}
    225225/*}}}*/
    226 /*FUNCTION Tria::CreateKMatrixMelting {{{1*/
     226/*FUNCTION Tria::CreateKMatrixMelting {{{*/
    227227ElementMatrix* Tria::CreateKMatrixMelting(void){
    228228
     
    232232        /*Intermediaries */
    233233        int        i,j,ig;
    234         double     heatcapacity,latentheat;
    235         double     Jdet,D_scalar;
    236         double     xyz_list[NUMVERTICES][3];
    237         double     L[3];
     234        IssmDouble     heatcapacity,latentheat;
     235        IssmDouble     Jdet,D_scalar;
     236        IssmDouble     xyz_list[NUMVERTICES][3];
     237        IssmDouble     L[3];
    238238        GaussTria *gauss=NULL;
    239239
     
    268268}
    269269/*}}}*/
    270 /*FUNCTION Tria::CreateKMatrixPrognostic {{{1*/
     270/*FUNCTION Tria::CreateKMatrixPrognostic {{{*/
    271271ElementMatrix* Tria::CreateKMatrixPrognostic(void){
    272272
     
    277277                        return CreateKMatrixPrognostic_DG();
    278278                default:
    279                         _error_("Element type %s not supported yet",EnumToStringx(GetElementType()));
    280         }
    281 
    282 }
    283 /*}}}*/
    284 /*FUNCTION Tria::CreateKMatrixPrognostic_CG {{{1*/
     279                        _error2_("Element type " << EnumToStringx(GetElementType()) << " not supported yet");
     280        }
     281
     282}
     283/*}}}*/
     284/*FUNCTION Tria::CreateKMatrixPrognostic_CG {{{*/
    285285ElementMatrix* Tria::CreateKMatrixPrognostic_CG(void){
    286286
     
    291291        int        stabilization;
    292292        int        i,j,ig,dim;
    293         double     Jdettria,DL_scalar,dt,h;
    294         double     vel,vx,vy,dvxdx,dvydy;
    295         double     dvx[2],dvy[2];
    296         double     v_gauss[2]={0.0};
    297         double     xyz_list[NUMVERTICES][3];
    298         double     L[NUMVERTICES];
    299         double     B[2][NUMVERTICES];
    300         double     Bprime[2][NUMVERTICES];
    301         double     K[2][2]                        ={0.0};
    302         double     KDL[2][2]                      ={0.0};
    303         double     DL[2][2]                        ={0.0};
    304         double     DLprime[2][2]                   ={0.0};
     293        IssmDouble     Jdettria,DL_scalar,dt,h;
     294        IssmDouble     vel,vx,vy,dvxdx,dvydy;
     295        IssmDouble     dvx[2],dvy[2];
     296        IssmDouble     v_gauss[2]={0.0};
     297        IssmDouble     xyz_list[NUMVERTICES][3];
     298        IssmDouble     L[NUMVERTICES];
     299        IssmDouble     B[2][NUMVERTICES];
     300        IssmDouble     Bprime[2][NUMVERTICES];
     301        IssmDouble     K[2][2]                        ={0.0};
     302        IssmDouble     KDL[2][2]                      ={0.0};
     303        IssmDouble     DL[2][2]                        ={0.0};
     304        IssmDouble     DLprime[2][2]                   ={0.0};
    305305        GaussTria *gauss=NULL;
    306306
     
    402402}
    403403/*}}}*/
    404 /*FUNCTION Tria::CreateKMatrixPrognostic_DG {{{1*/
     404/*FUNCTION Tria::CreateKMatrixPrognostic_DG {{{*/
    405405ElementMatrix* Tria::CreateKMatrixPrognostic_DG(void){
    406406
     
    410410        /*Intermediaries */
    411411        int        i,j,ig,dim;
    412         double     xyz_list[NUMVERTICES][3];
    413         double     Jdettria,dt,vx,vy;
    414         double     L[NUMVERTICES];
    415         double     B[2][NUMVERTICES];
    416         double     Bprime[2][NUMVERTICES];
    417         double     DL[2][2]={0.0};
    418         double     DLprime[2][2]={0.0};
    419         double     DL_scalar;
     412        IssmDouble     xyz_list[NUMVERTICES][3];
     413        IssmDouble     Jdettria,dt,vx,vy;
     414        IssmDouble     L[NUMVERTICES];
     415        IssmDouble     B[2][NUMVERTICES];
     416        IssmDouble     Bprime[2][NUMVERTICES];
     417        IssmDouble     DL[2][2]={0.0};
     418        IssmDouble     DLprime[2][2]={0.0};
     419        IssmDouble     DL_scalar;
    420420        GaussTria  *gauss=NULL;
    421421
     
    477477}
    478478/*}}}*/
    479 /*FUNCTION Tria::CreateKMatrixSlope {{{1*/
     479/*FUNCTION Tria::CreateKMatrixSlope {{{*/
    480480ElementMatrix* Tria::CreateKMatrixSlope(void){
    481481
     
    485485        /* Intermediaries */
    486486        int        i,j,ig;
    487         double     DL_scalar,Jdet;
    488         double     xyz_list[NUMVERTICES][3];
    489         double     L[1][3];
     487        IssmDouble     DL_scalar,Jdet;
     488        IssmDouble     xyz_list[NUMVERTICES][3];
     489        IssmDouble     L[1][3];
    490490        GaussTria *gauss = NULL;
    491491
     
    517517}
    518518/*}}}*/
    519 /*FUNCTION Tria::CreatePVector {{{1*/
     519/*FUNCTION Tria::CreatePVector {{{*/
    520520void  Tria::CreatePVector(Vector* pf){
    521521
     
    568568                #endif
    569569                default:
    570                         _error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
     570                        _error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
    571571        }
    572572
     
    578578}
    579579/*}}}*/
    580 /*FUNCTION Tria::CreatePVectorPrognostic{{{1*/
     580/*FUNCTION Tria::CreatePVectorPrognostic{{{*/
    581581ElementVector* Tria::CreatePVectorPrognostic(void){
    582582
     
    587587                        return CreatePVectorPrognostic_DG();
    588588                default:
    589                         _error_("Element type %s not supported yet",EnumToStringx(GetElementType()));
    590         }
    591 }
    592 /*}}}*/
    593 /*FUNCTION Tria::CreatePVectorPrognostic_CG {{{1*/
     589                        _error2_("Element type " << EnumToStringx(GetElementType()) << " not supported yet");
     590        }
     591}
     592/*}}}*/
     593/*FUNCTION Tria::CreatePVectorPrognostic_CG {{{*/
    594594ElementVector* Tria::CreatePVectorPrognostic_CG(void){
    595595
     
    599599        /*Intermediaries */
    600600        int        i,j,ig;
    601         double     Jdettria,dt;
    602         double     surface_mass_balance_g,basal_melting_g,basal_melting_correction_g,thickness_g;
    603         double     xyz_list[NUMVERTICES][3];
    604         double     L[NUMVERTICES];
     601        IssmDouble     Jdettria,dt;
     602        IssmDouble     surface_mass_balance_g,basal_melting_g,basal_melting_correction_g,thickness_g;
     603        IssmDouble     xyz_list[NUMVERTICES][3];
     604        IssmDouble     L[NUMVERTICES];
    605605        GaussTria* gauss=NULL;
    606606
     
    642642}
    643643/*}}}*/
    644 /*FUNCTION Tria::CreatePVectorPrognostic_DG {{{1*/
     644/*FUNCTION Tria::CreatePVectorPrognostic_DG {{{*/
    645645ElementVector* Tria::CreatePVectorPrognostic_DG(void){
    646646
     
    650650        /*Intermediaries */
    651651        int        i,j,ig;
    652         double     Jdettria,dt;
    653         double     surface_mass_balance_g,basal_melting_g,thickness_g;
    654         double     xyz_list[NUMVERTICES][3];
    655         double     L[NUMVERTICES];
     652        IssmDouble     Jdettria,dt;
     653        IssmDouble     surface_mass_balance_g,basal_melting_g,thickness_g;
     654        IssmDouble     xyz_list[NUMVERTICES][3];
     655        IssmDouble     L[NUMVERTICES];
    656656        GaussTria* gauss=NULL;
    657657
     
    687687}
    688688/*}}}*/
    689 /*FUNCTION Tria::CreatePVectorSlope {{{1*/
     689/*FUNCTION Tria::CreatePVectorSlope {{{*/
    690690ElementVector* Tria::CreatePVectorSlope(void){
    691691
     
    696696        int        i,j,ig;
    697697        int        analysis_type;
    698         double     Jdet;
    699         double     xyz_list[NUMVERTICES][3];
    700         double     slope[2];
    701         double     basis[3];
     698        IssmDouble     Jdet;
     699        IssmDouble     xyz_list[NUMVERTICES][3];
     700        IssmDouble     slope[2];
     701        IssmDouble     basis[3];
    702702        GaussTria* gauss=NULL;
    703703
     
    740740}
    741741/*}}}*/
    742 /*FUNCTION Tria::CreateJacobianMatrix{{{1*/
     742/*FUNCTION Tria::CreateJacobianMatrix{{{*/
    743743void  Tria::CreateJacobianMatrix(Matrix* Jff){
    744744
     
    748748        parameters->FindParam(&analysis_type,AnalysisTypeEnum);
    749749
    750         /*Checks in debugging {{{2*/
     750        /*Checks in debugging {{{*/
    751751        _assert_(this->nodes && this->matice && this->matpar && this->parameters && this->inputs);
    752752        /*}}}*/
     
    763763#endif
    764764                default:
    765                         _error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
     765                        _error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
    766766        }
    767767
     
    773773}
    774774/*}}}*/
    775 /*FUNCTION Tria::ComputeBasalStress {{{1*/
     775/*FUNCTION Tria::ComputeBasalStress {{{*/
    776776void  Tria::ComputeBasalStress(Vector* eps){
    777         _error_("Not Implemented yet");
    778 }
    779 /*}}}*/
    780 /*FUNCTION Tria::ComputeStrainRate {{{1*/
     777        _error2_("Not Implemented yet");
     778}
     779/*}}}*/
     780/*FUNCTION Tria::ComputeStrainRate {{{*/
    781781void  Tria::ComputeStrainRate(Vector* eps){
    782         _error_("Not Implemented yet");
    783 }
    784 /*}}}*/
    785 /*FUNCTION Tria::ComputeStressTensor {{{1*/
     782        _error2_("Not Implemented yet");
     783}
     784/*}}}*/
     785/*FUNCTION Tria::ComputeStressTensor {{{*/
    786786void  Tria::ComputeStressTensor(){
    787787
    788788        int         iv;
    789         double      xyz_list[NUMVERTICES][3];
    790         double      pressure,viscosity;
    791         double      epsilon[3]; /* epsilon=[exx,eyy,exy];*/
    792         double      sigma_xx[NUMVERTICES];
    793         double          sigma_yy[NUMVERTICES];
    794         double          sigma_zz[NUMVERTICES]={0,0,0};
    795         double      sigma_xy[NUMVERTICES];
    796         double          sigma_xz[NUMVERTICES]={0,0,0};
    797         double          sigma_yz[NUMVERTICES]={0,0,0};
     789        IssmDouble      xyz_list[NUMVERTICES][3];
     790        IssmDouble      pressure,viscosity;
     791        IssmDouble      epsilon[3]; /* epsilon=[exx,eyy,exy];*/
     792        IssmDouble      sigma_xx[NUMVERTICES];
     793        IssmDouble              sigma_yy[NUMVERTICES];
     794        IssmDouble              sigma_zz[NUMVERTICES]={0,0,0};
     795        IssmDouble      sigma_xy[NUMVERTICES];
     796        IssmDouble              sigma_xz[NUMVERTICES]={0,0,0};
     797        IssmDouble              sigma_yz[NUMVERTICES]={0,0,0};
    798798        GaussTria* gauss=NULL;
    799799
     
    834834}
    835835/*}}}*/
    836 /*FUNCTION Tria::Configure {{{1*/
     836/*FUNCTION Tria::Configure {{{*/
    837837void  Tria::Configure(Elements* elementsin, Loads* loadsin, DataSet* nodesin, Materials* materialsin, Parameters* parametersin){
    838838       
     
    864864}
    865865/*}}}*/
    866 /*FUNCTION Tria::DeepEcho{{{1*/
     866/*FUNCTION Tria::DeepEcho{{{*/
    867867void Tria::DeepEcho(void){
    868868
    869         printf("Tria:\n");
    870         printf("   id: %i\n",id);
     869        _printLine_("Tria:");
     870        _printLine_("   id: " << id);
    871871        if(nodes){
    872872                nodes[0]->DeepEcho();
     
    874874                nodes[2]->DeepEcho();
    875875        }
    876         else printf("nodes = NULL\n");
     876        else _printLine_("nodes = NULL");
    877877
    878878        if (matice) matice->DeepEcho();
    879         else printf("matice = NULL\n");
     879        else _printLine_("matice = NULL");
    880880
    881881        if (matpar) matpar->DeepEcho();
    882         else printf("matpar = NULL\n");
    883 
    884         printf("   parameters\n");
     882        else _printLine_("matpar = NULL");
     883
     884        _printLine_("   parameters");
    885885        if (parameters) parameters->DeepEcho();
    886         else printf("parameters = NULL\n");
    887 
    888         printf("   inputs\n");
     886        else _printLine_("parameters = NULL");
     887
     888        _printLine_("   inputs");
    889889        if (inputs) inputs->DeepEcho();
    890         else printf("inputs=NULL\n");
     890        else _printLine_("inputs=NULL");
    891891
    892892        if (results) results->DeepEcho();
    893         else printf("results=NULL\n");
    894 
    895         printf("neighboor sids: \n");
    896         printf(" %i %i %i\n",horizontalneighborsids[0],horizontalneighborsids[1],horizontalneighborsids[2]);
     893        else _printLine_("results=NULL");
     894
     895        _printLine_("neighboor sids: ");
     896        _printLine_(" " << horizontalneighborsids[0] << " " << horizontalneighborsids[1] << " " << horizontalneighborsids[2]);
    897897       
    898898        return;
    899899}
    900900/*}}}*/
    901 /*FUNCTION Tria::DeleteResults {{{1*/
     901/*FUNCTION Tria::DeleteResults {{{*/
    902902void  Tria::DeleteResults(void){
    903903
     
    908908}
    909909/*}}}*/
    910 /*FUNCTION Tria::Echo{{{1*/
     910/*FUNCTION Tria::Echo{{{*/
    911911void Tria::Echo(void){
    912         printf("Tria:\n");
    913         printf("   id: %i\n",id);
     912        _printLine_("Tria:");
     913        _printLine_("   id: " << id);
    914914        if(nodes){
    915915                nodes[0]->Echo();
     
    917917                nodes[2]->Echo();
    918918        }
    919         else printf("nodes = NULL\n");
     919        else _printLine_("nodes = NULL");
    920920
    921921        if (matice) matice->Echo();
    922         else printf("matice = NULL\n");
     922        else _printLine_("matice = NULL");
    923923
    924924        if (matpar) matpar->Echo();
    925         else printf("matpar = NULL\n");
    926 
    927         printf("   parameters\n");
     925        else _printLine_("matpar = NULL");
     926
     927        _printLine_("   parameters");
    928928        if (parameters) parameters->Echo();
    929         else printf("parameters = NULL\n");
    930 
    931         printf("   inputs\n");
     929        else _printLine_("parameters = NULL");
     930
     931        _printLine_("   inputs");
    932932        if (inputs) inputs->Echo();
    933         else printf("inputs=NULL\n");
     933        else _printLine_("inputs=NULL");
    934934
    935935        if (results) results->Echo();
    936         else printf("results=NULL\n");
    937 
    938         printf("neighboor sids: \n");
    939         printf(" %i %i %i\n",horizontalneighborsids[0],horizontalneighborsids[1],horizontalneighborsids[2]);
    940 }
    941 /*}}}*/
    942 /*FUNCTION Tria::ObjectEnum{{{1*/
     936        else _printLine_("results=NULL");
     937
     938        _printLine_("neighboor sids: ");
     939        _printLine_(" " << horizontalneighborsids[0] << " " << horizontalneighborsids[1] << " " << horizontalneighborsids[2]);
     940}
     941/*}}}*/
     942/*FUNCTION Tria::ObjectEnum{{{*/
    943943int Tria::ObjectEnum(void){
    944944
     
    947947}
    948948/*}}}*/
    949 /*FUNCTION Tria::GetArea {{{1*/
    950 double Tria::GetArea(void){
    951 
    952         double area=0;
    953         double xyz_list[NUMVERTICES][3];
    954         double x1,y1,x2,y2,x3,y3;
     949/*FUNCTION Tria::GetArea {{{*/
     950IssmDouble Tria::GetArea(void){
     951
     952        IssmDouble area=0;
     953        IssmDouble xyz_list[NUMVERTICES][3];
     954        IssmDouble x1,y1,x2,y2,x3,y3;
    955955
    956956        /*Get xyz list: */
     
    964964}
    965965/*}}}*/
    966 /*FUNCTION Tria::GetDofList {{{1*/
     966/*FUNCTION Tria::GetDofList {{{*/
    967967void  Tria::GetDofList(int** pdoflist, int approximation_enum,int setenum){
    968968
     
    974974        /*First, figure out size of doflist and create it: */
    975975        for(i=0;i<3;i++) numberofdofs+=nodes[i]->GetNumberOfDofs(approximation_enum,setenum);
    976         doflist=(int*)xmalloc(numberofdofs*sizeof(int));
     976        doflist=xNew<int>(numberofdofs);
    977977
    978978        /*Populate: */
     
    987987}
    988988/*}}}*/
    989 /*FUNCTION Tria::GetDofList1 {{{1*/
     989/*FUNCTION Tria::GetDofList1 {{{*/
    990990void  Tria::GetDofList1(int* doflist){
    991991
     
    995995}
    996996/*}}}*/
    997 /*FUNCTION Tria::GetElementType {{{1*/
     997/*FUNCTION Tria::GetElementType {{{*/
    998998int Tria::GetElementType(){
    999999
     
    10031003}
    10041004/*}}}*/
    1005 /*FUNCTION Tria::GetHorizontalNeighboorSids {{{1*/
     1005/*FUNCTION Tria::GetHorizontalNeighboorSids {{{*/
    10061006int* Tria::GetHorizontalNeighboorSids(){
    10071007
     
    10111011}
    10121012/*}}}*/
    1013 /*FUNCTION Tria::GetNodeIndex {{{1*/
     1013/*FUNCTION Tria::GetNodeIndex {{{*/
    10141014int Tria::GetNodeIndex(Node* node){
    10151015
     
    10191019                 return i;
    10201020        }
    1021         _error_("Node provided not found among element nodes");
    1022 }
    1023 /*}}}*/
    1024 /*FUNCTION Tria::GetInputListOnVertices(double* pvalue,int enumtype) {{{1*/
    1025 void Tria::GetInputListOnVertices(double* pvalue,int enumtype){
     1021        _error2_("Node provided not found among element nodes");
     1022}
     1023/*}}}*/
     1024/*FUNCTION Tria::GetInputListOnVertices(IssmDouble* pvalue,int enumtype) {{{*/
     1025void Tria::GetInputListOnVertices(IssmDouble* pvalue,int enumtype){
    10261026
    10271027        /*Intermediaries*/
    1028         double     value[NUMVERTICES];
     1028        IssmDouble     value[NUMVERTICES];
    10291029        GaussTria *gauss              = NULL;
    10301030
    10311031        /*Recover input*/
    10321032        Input* input=inputs->GetInput(enumtype);
    1033         if (!input) _error_("Input %s not found in element",EnumToStringx(enumtype));
     1033        if (!input) _error2_("Input " << EnumToStringx(enumtype) << " not found in element");
    10341034
    10351035        /*Checks in debugging mode*/
     
    10471047}
    10481048/*}}}*/
    1049 /*FUNCTION Tria::GetInputListOnVertices(double* pvalue,int enumtype,double defaultvalue) {{{1*/
    1050 void Tria::GetInputListOnVertices(double* pvalue,int enumtype,double defaultvalue){
    1051 
    1052         double     value[NUMVERTICES];
     1049/*FUNCTION Tria::GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue) {{{*/
     1050void Tria::GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue){
     1051
     1052        IssmDouble     value[NUMVERTICES];
    10531053        GaussTria *gauss = NULL;
    10541054        Input     *input = inputs->GetInput(enumtype);
     
    10731073}
    10741074/*}}}*/
    1075 /*FUNCTION Tria::GetInputListOnVertices(double* pvalue,int enumtype,double defaultvalue,int index) TO BE REMOVED{{{1*/
    1076 void Tria::GetInputListOnVertices(double* pvalue,int enumtype,double defaultvalue,int index){
    1077 
    1078         double     value[NUMVERTICES];
     1075/*FUNCTION Tria::GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue,int index) TO BE REMOVED{{{*/
     1076void Tria::GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue,int index){
     1077
     1078        IssmDouble     value[NUMVERTICES];
    10791079        GaussTria *gauss = NULL;
    10801080        Input     *input = inputs->GetInput(enumtype);
     
    10991099}
    11001100/*}}}*/
    1101 /*FUNCTION Tria::GetInputValue(double* pvalue,Node* node,int enumtype) {{{1*/
    1102 void Tria::GetInputValue(double* pvalue,Node* node,int enumtype){
     1101/*FUNCTION Tria::GetInputValue(IssmDouble* pvalue,Node* node,int enumtype) {{{*/
     1102void Tria::GetInputValue(IssmDouble* pvalue,Node* node,int enumtype){
    11031103
    11041104        Input* input=inputs->GetInput(enumtype);
    1105         if(!input) _error_("No input of type %s found in tria",EnumToStringx(enumtype));
     1105        if(!input) _error2_("No input of type " << EnumToStringx(enumtype) << " found in tria");
    11061106
    11071107        GaussTria* gauss=new GaussTria();
     
    11121112}
    11131113/*}}}*/
    1114 /*FUNCTION Tria::GetSidList {{{1*/
     1114/*FUNCTION Tria::GetSidList {{{*/
    11151115void  Tria::GetSidList(int* sidlist){
    11161116        for(int i=0;i<NUMVERTICES;i++) sidlist[i]=nodes[i]->GetSidList();
    11171117}
    11181118/*}}}*/
    1119 /*FUNCTION Tria::GetConnectivityList {{{1*/
     1119/*FUNCTION Tria::GetConnectivityList {{{*/
    11201120void  Tria::GetConnectivityList(int* connectivity){
    11211121        for(int i=0;i<NUMVERTICES;i++) connectivity[i]=nodes[i]->GetConnectivity();
    11221122}
    11231123/*}}}*/
    1124 /*FUNCTION Tria::GetSolutionFromInputs{{{1*/
     1124/*FUNCTION Tria::GetSolutionFromInputs{{{*/
    11251125void  Tria::GetSolutionFromInputs(Vector* solution){
    11261126
     
    11451145        #endif
    11461146        default:
    1147                 _error_("analysis: %s not supported yet",EnumToStringx(analysis_type));
    1148         }
    1149 
    1150 }
    1151 /*}}}*/
    1152 /*FUNCTION Tria::GetStrainRate2d(double* epsilon,double* xyz_list, GaussTria* gauss, Input* vx_input, Input* vy_input){{{1*/
    1153 void Tria::GetStrainRate2d(double* epsilon,double* xyz_list, GaussTria* gauss, Input* vx_input, Input* vy_input){
     1147                _error2_("analysis: " << EnumToStringx(analysis_type) << " not supported yet");
     1148        }
     1149
     1150}
     1151/*}}}*/
     1152/*FUNCTION Tria::GetStrainRate2d(IssmDouble* epsilon,IssmDouble* xyz_list, GaussTria* gauss, Input* vx_input, Input* vy_input){{{*/
     1153void Tria::GetStrainRate2d(IssmDouble* epsilon,IssmDouble* xyz_list, GaussTria* gauss, Input* vx_input, Input* vy_input){
    11541154        /*Compute the 2d Strain Rate (3 components):
    11551155         * epsilon=[exx eyy exy] */
    11561156
    11571157        int i;
    1158         double epsilonvx[3];
    1159         double epsilonvy[3];
     1158        IssmDouble epsilonvx[3];
     1159        IssmDouble epsilonvy[3];
    11601160
    11611161        /*Check that both inputs have been found*/
    11621162        if (!vx_input || !vy_input){
    1163                 _error_("Input missing. Here are the input pointers we have for vx: %p, vy: %p\n",vx_input,vy_input);
     1163                _error2_("Input missing. Here are the input pointers we have for vx: " << vx_input << ", vy: " << vy_input << "\n");
    11641164        }
    11651165
     
    11721172}
    11731173/*}}}*/
    1174 /*FUNCTION Tria::GetVectorFromInputs{{{1*/
     1174/*FUNCTION Tria::GetVectorFromInputs{{{*/
    11751175void  Tria::GetVectorFromInputs(Vector* vector,int input_enum){
    11761176
     
    11851185        /*Get input (either in element or material)*/
    11861186        Input* input=inputs->GetInput(input_enum);
    1187         if(!input) _error_("Input %s not found in element",EnumToStringx(input_enum));
     1187        if(!input) _error2_("Input " << EnumToStringx(input_enum) << " not found in element");
    11881188
    11891189        /*We found the enum.  Use its values to fill into the vector, using the vertices ids: */
     
    11911191}
    11921192/*}}}*/
    1193 /*FUNCTION Tria::GetVectorFromResults{{{1*/
     1193/*FUNCTION Tria::GetVectorFromResults{{{*/
    11941194void  Tria::GetVectorFromResults(Vector* vector,int offset,int enum_in,int interp){
    11951195
     
    12101210        }
    12111211        else{
    1212                 printf("Interpolation %s not supported\n",EnumToStringx(interp));
    1213         }
    1214 }
    1215 /*}}}*/
    1216 /*FUNCTION Tria::Id {{{1*/
     1212                _printLine_("Interpolation " << EnumToStringx(interp) << " not supported");
     1213        }
     1214}
     1215/*}}}*/
     1216/*FUNCTION Tria::Id {{{*/
    12171217int    Tria::Id(){
    12181218       
     
    12211221}
    12221222/*}}}*/
    1223 /*FUNCTION Tria::Sid {{{1*/
     1223/*FUNCTION Tria::Sid {{{*/
    12241224int    Tria::Sid(){
    12251225       
     
    12281228}
    12291229/*}}}*/
    1230 /*FUNCTION Tria::InputArtificialNoise{{{1*/
    1231 void  Tria::InputArtificialNoise(int enum_type,double min,double max){
     1230/*FUNCTION Tria::InputArtificialNoise{{{*/
     1231void  Tria::InputArtificialNoise(int enum_type,IssmDouble min,IssmDouble max){
    12321232
    12331233        Input* input=NULL;
     
    12351235        /*Make a copy of the original input: */
    12361236        input=(Input*)this->inputs->GetInput(enum_type);
    1237         if(!input)_error_(" could not find old input with enum: %s",EnumToStringx(enum_type));
     1237        if(!input)_error2_("could not find old input with enum: " << EnumToStringx(enum_type));
    12381238
    12391239        /*ArtificialNoise: */
     
    12411241}
    12421242/*}}}*/
    1243 /*FUNCTION Tria::InputConvergence{{{1*/
    1244 bool Tria::InputConvergence(double* eps, int* enums,int num_enums,int* criterionenums,double* criterionvalues,int num_criterionenums){
     1243/*FUNCTION Tria::InputConvergence{{{*/
     1244bool Tria::InputConvergence(IssmDouble* eps, int* enums,int num_enums,int* criterionenums,IssmDouble* criterionvalues,int num_criterionenums){
    12451245
    12461246        bool    converged=true;
     
    12491249        Input** old_inputs=NULL;
    12501250
    1251         new_inputs=(Input**)xmalloc(num_enums/2*sizeof(Input*)); //half the enums are for the new inputs
    1252         old_inputs=(Input**)xmalloc(num_enums/2*sizeof(Input*)); //half the enums are for the old inputs
     1251        new_inputs=xNew<Input*>(num_enums/2); //half the enums are for the new inputs
     1252        old_inputs=xNew<Input*>(num_enums/2); //half the enums are for the old inputs
    12531253
    12541254        for(i=0;i<num_enums/2;i++){
    12551255                new_inputs[i]=(Input*)this->inputs->GetInput(enums[2*i+0]);
    12561256                old_inputs[i]=(Input*)this->inputs->GetInput(enums[2*i+1]);
    1257                 if(!new_inputs[i])_error_("%s%s"," could not find input with enum ",EnumToStringx(enums[2*i+0]));
    1258                 if(!old_inputs[i])_error_("%s%s"," could not find input with enum ",EnumToStringx(enums[2*i+0]));
     1257                if(!new_inputs[i])_error2_("could not find input with enum " << EnumToStringx(enums[2*i+0]));
     1258                if(!old_inputs[i])_error2_("could not find input with enum " << EnumToStringx(enums[2*i+0]));
    12591259        }
    12601260
     
    12661266
    12671267        /*clean up and return*/
    1268         xfree((void**)&new_inputs);
    1269         xfree((void**)&old_inputs);
     1268        xDelete<Input*>(new_inputs);
     1269        xDelete<Input*>(old_inputs);
    12701270        return converged;
    12711271}
    12721272/*}}}*/
    1273 /*FUNCTION Tria::InputDepthAverageAtBase {{{1*/
     1273/*FUNCTION Tria::InputDepthAverageAtBase {{{*/
    12741274void  Tria::InputDepthAverageAtBase(int enum_type,int average_enum_type,int object_enum){
    12751275
     
    12841284         oldinput=(Input*)this->matice->inputs->GetInput(enum_type);
    12851285        else
    1286          _error_("object %s not supported yet",EnumToStringx(object_enum));
    1287         if(!oldinput)_error_("%s%s"," could not find old input with enum: ",EnumToStringx(enum_type));
     1286         _error2_("object " << EnumToStringx(object_enum) << " not supported yet");
     1287        if(!oldinput)_error2_("could not find old input with enum: " << EnumToStringx(enum_type));
    12881288        newinput=(Input*)oldinput->copy();
    12891289
     
    12971297         this->matice->inputs->AddInput((Input*)newinput);
    12981298        else
    1299          _error_("object %s not supported yet",EnumToStringx(object_enum));
    1300 }
    1301 /*}}}*/
    1302 /*FUNCTION Tria::InputDuplicate{{{1*/
     1299         _error2_("object " << EnumToStringx(object_enum) << " not supported yet");
     1300}
     1301/*}}}*/
     1302/*FUNCTION Tria::InputDuplicate{{{*/
    13031303void  Tria::InputDuplicate(int original_enum,int new_enum){
    13041304
     
    13081308}
    13091309/*}}}*/
    1310 /*FUNCTION Tria::InputScale{{{1*/
    1311 void  Tria::InputScale(int enum_type,double scale_factor){
     1310/*FUNCTION Tria::InputScale{{{*/
     1311void  Tria::InputScale(int enum_type,IssmDouble scale_factor){
    13121312
    13131313        Input* input=NULL;
     
    13151315        /*Make a copy of the original input: */
    13161316        input=(Input*)this->inputs->GetInput(enum_type);
    1317         if(!input)_error_(" could not find old input with enum: %s",EnumToStringx(enum_type));
     1317        if(!input)_error2_("could not find old input with enum: " << EnumToStringx(enum_type));
    13181318
    13191319        /*Scale: */
     
    13211321}
    13221322/*}}}*/
    1323 /*FUNCTION Tria::InputToResult{{{1*/
    1324 void  Tria::InputToResult(int enum_type,int step,double time){
     1323/*FUNCTION Tria::InputToResult{{{*/
     1324void  Tria::InputToResult(int enum_type,int step,IssmDouble time){
    13251325
    13261326        int    i;
     
    13301330        if (enum_type==MaterialsRheologyBbarEnum) input=this->matice->inputs->GetInput(enum_type);
    13311331        else input=this->inputs->GetInput(enum_type);
    1332         //if (!input) _error_("Input %s not found in tria->inputs",EnumToStringx(enum_type));
     1332        //if (!input) _error2_("Input " << EnumToStringx(enum_type) << " not found in tria->inputs");
    13331333        if(!input)return;
    13341334
     
    13441344}
    13451345/*}}}*/
    1346 /*FUNCTION Tria::InputUpdateFromConstant(int value, int name);{{{1*/
     1346/*FUNCTION Tria::InputUpdateFromConstant(int value, int name);{{{*/
    13471347void  Tria::InputUpdateFromConstant(int constant, int name){
    13481348        /*Check that name is an element input*/
     
    13531353}
    13541354/*}}}*/
    1355 /*FUNCTION Tria::InputUpdateFromConstant(double value, int name);{{{1*/
    1356 void  Tria::InputUpdateFromConstant(double constant, int name){
     1355/*FUNCTION Tria::InputUpdateFromConstant(IssmDouble value, int name);{{{*/
     1356void  Tria::InputUpdateFromConstant(IssmDouble constant, int name){
    13571357        /*Check that name is an element input*/
    13581358        if (!IsInput(name)) return;
     
    13621362}
    13631363/*}}}*/
    1364 /*FUNCTION Tria::InputUpdateFromConstant(bool value, int name);{{{1*/
     1364/*FUNCTION Tria::InputUpdateFromConstant(bool value, int name);{{{*/
    13651365void  Tria::InputUpdateFromConstant(bool constant, int name){
    13661366        /*Check that name is an element input*/
     
    13711371}
    13721372/*}}}*/
    1373 /*FUNCTION Tria::InputUpdateFromIoModel{{{1*/
     1373/*FUNCTION Tria::InputUpdateFromIoModel{{{*/
    13741374void Tria::InputUpdateFromIoModel(int index, IoModel* iomodel){ //i is the element index
    13751375
     
    13771377        int    i,j;
    13781378        int    tria_vertex_ids[3];
    1379         double nodeinputs[3];
    1380         double cmmininputs[3];
    1381         double cmmaxinputs[3];
     1379        IssmDouble nodeinputs[3];
     1380        IssmDouble cmmininputs[3];
     1381        IssmDouble cmmaxinputs[3];
    13821382        bool   control_analysis=false;
    13831383        int    num_control_type;
    1384         double yts;
     1384        IssmDouble yts;
    13851385        int    num_cm_responses;
    13861386   
     
    13931393        /*Recover vertices ids needed to initialize inputs*/
    13941394        for(i=0;i<3;i++){
    1395                 tria_vertex_ids[i]=(int)iomodel->Data(MeshElementsEnum)[3*index+i]; //ids for vertices are in the elements array from Matlab
     1395                tria_vertex_ids[i]=reCast<int>(iomodel->Data(MeshElementsEnum)[3*index+i]); //ids for vertices are in the elements array from Matlab
    13961396        }
    13971397
     
    14361436                                        /*Matice will take care of it*/ break;
    14371437                                default:
    1438                                         _error_("Control %s not implemented yet",EnumToStringx((int)iomodel->Data(InversionControlParametersEnum)[i]));
     1438                                        _error2_("Control " << EnumToStringx((int)iomodel->Data(InversionControlParametersEnum)[i]) << " not implemented yet");
    14391439                        }
    14401440                }
     
    14571457}
    14581458/*}}}*/
    1459 /*FUNCTION Tria::InputUpdateFromSolution {{{1*/
    1460 void  Tria::InputUpdateFromSolution(double* solution){
     1459/*FUNCTION Tria::InputUpdateFromSolution {{{*/
     1460void  Tria::InputUpdateFromSolution(IssmDouble* solution){
    14611461
    14621462        /*retrive parameters: */
     
    15081508                        break;
    15091509                default:
    1510                         _error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
    1511         }
    1512 }
    1513 /*}}}*/
    1514 /*FUNCTION Tria::InputUpdateFromSolutionOneDof{{{1*/
    1515 void  Tria::InputUpdateFromSolutionOneDof(double* solution,int enum_type){
     1510                        _error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
     1511        }
     1512}
     1513/*}}}*/
     1514/*FUNCTION Tria::InputUpdateFromSolutionOneDof{{{*/
     1515void  Tria::InputUpdateFromSolutionOneDof(IssmDouble* solution,int enum_type){
    15161516
    15171517        const int numdof          = NDOF1*NUMVERTICES;
    15181518
    15191519        int*      doflist=NULL;
    1520         double    values[numdof];
     1520        IssmDouble    values[numdof];
    15211521
    15221522        /*Get dof list: */
     
    15261526        for(int i=0;i<numdof;i++){
    15271527                values[i]=solution[doflist[i]];
    1528                 if(isnan(values[i])) _error_("NaN found in solution vector");
     1528                if(xIsNan<IssmDouble>(values[i])) _error2_("NaN found in solution vector");
    15291529        }
    15301530
     
    15331533
    15341534        /*Free ressources:*/
    1535         xfree((void**)&doflist);
    1536 }
    1537 /*}}}*/
    1538 /*FUNCTION Tria::InputUpdateFromSolutionPrognostic{{{1*/
    1539 void  Tria::InputUpdateFromSolutionPrognostic(double* solution){
     1535        xDelete<int>(doflist);
     1536}
     1537/*}}}*/
     1538/*FUNCTION Tria::InputUpdateFromSolutionPrognostic{{{*/
     1539void  Tria::InputUpdateFromSolutionPrognostic(IssmDouble* solution){
    15401540
    15411541        /*Intermediaries*/
     
    15441544        int       i,hydroadjustment;
    15451545        int*      doflist=NULL;
    1546         double    rho_ice,rho_water,minthickness;
    1547         double    newthickness[numdof];
    1548         double    newbed[numdof];
    1549         double    newsurface[numdof];
    1550         double    oldbed[NUMVERTICES];
    1551         double    oldsurface[NUMVERTICES];
    1552         double    oldthickness[NUMVERTICES];
     1546        IssmDouble    rho_ice,rho_water,minthickness;
     1547        IssmDouble    newthickness[numdof];
     1548        IssmDouble    newbed[numdof];
     1549        IssmDouble    newsurface[numdof];
     1550        IssmDouble    oldbed[NUMVERTICES];
     1551        IssmDouble    oldsurface[NUMVERTICES];
     1552        IssmDouble    oldthickness[NUMVERTICES];
    15531553
    15541554        /*Get dof list: */
     
    15591559        for(i=0;i<numdof;i++){
    15601560                newthickness[i]=solution[doflist[i]];
    1561                 if(isnan(newthickness[i])) _error_("NaN found in solution vector");
     1561                if(xIsNan<IssmDouble>(newthickness[i])) _error2_("NaN found in solution vector");
    15621562                /*Constrain thickness to be at least 1m*/
    15631563                if(newthickness[i]<minthickness) newthickness[i]=minthickness;
     
    15901590                                newbed[i]=oldbed[i]-rho_ice/rho_water*(newthickness[i]-oldthickness[i]); //bed = oldbed + di * dH
    15911591                        }
    1592                         else _error_("Hydrostatic adjustment %i (%s) not supported yet",hydroadjustment,EnumToStringx(hydroadjustment));
     1592                        else _error2_("Hydrostatic adjustment " << hydroadjustment << " (" << EnumToStringx(hydroadjustment) << ") not supported yet");
    15931593                }
    15941594        }
     
    16001600
    16011601        /*Free ressources:*/
    1602         xfree((void**)&doflist);
    1603 }
    1604 /*}}}*/
    1605 /*FUNCTION Tria::InputUpdateFromVector(double* vector, int name, int type);{{{1*/
    1606 void  Tria::InputUpdateFromVector(double* vector, int name, int type){
     1602        xDelete<int>(doflist);
     1603}
     1604/*}}}*/
     1605/*FUNCTION Tria::InputUpdateFromVector(IssmDouble* vector, int name, int type);{{{*/
     1606void  Tria::InputUpdateFromVector(IssmDouble* vector, int name, int type){
    16071607
    16081608        /*Check that name is an element input*/
     
    16111611        switch(type){
    16121612
    1613                 case VertexEnum:
     1613                case VertexEnum: {
    16141614
    16151615                        /*New TriaP1Input*/
    1616                         double values[3];
     1616                        IssmDouble values[3];
    16171617
    16181618                        /*Get values on the 3 vertices*/
     
    16291629                        }
    16301630                        return;
    1631 
     1631                }
    16321632                default:
    1633                         _error_("type %i (%s) not implemented yet",type,EnumToStringx(type));
    1634         }
    1635 }
    1636 /*}}}*/
    1637 /*FUNCTION Tria::InputUpdateFromVector(int* vector, int name, int type);{{{1*/
     1633                        _error2_("type " << type << " (" << EnumToStringx(type) << ") not implemented yet");
     1634        }
     1635}
     1636/*}}}*/
     1637/*FUNCTION Tria::InputUpdateFromVector(int* vector, int name, int type);{{{*/
    16381638void  Tria::InputUpdateFromVector(int* vector, int name, int type){
    1639         _error_(" not supported yet!");
    1640 }
    1641 /*}}}*/
    1642 /*FUNCTION Tria::InputUpdateFromVector(bool* vector, int name, int type);{{{1*/
     1639        _error2_("not supported yet!");
     1640}
     1641/*}}}*/
     1642/*FUNCTION Tria::InputUpdateFromVector(bool* vector, int name, int type);{{{*/
    16431643void  Tria::InputUpdateFromVector(bool* vector, int name, int type){
    1644         _error_(" not supported yet!");
    1645 }
    1646 /*}}}*/
    1647 /*FUNCTION Tria::InputCreate(double scalar,int enum,int code);{{{1*/
    1648 void Tria::InputCreate(double scalar,int name,int code){
     1644        _error2_("not supported yet!");
     1645}
     1646/*}}}*/
     1647/*FUNCTION Tria::InputCreate(IssmDouble scalar,int enum,int code);{{{*/
     1648void Tria::InputCreate(IssmDouble scalar,int name,int code){
    16491649
    16501650        /*Check that name is an element input*/
     
    16521652       
    16531653        if ((code==5) || (code==1)){ //boolean
    1654                 this->inputs->AddInput(new BoolInput(name,(bool)scalar));
     1654                this->inputs->AddInput(new BoolInput(name,reCast<bool>(scalar)));
    16551655        }
    16561656        else if ((code==6) || (code==2)){ //integer
    1657                 this->inputs->AddInput(new IntInput(name,(int)scalar));
    1658         }
    1659         else if ((code==7) || (code==3)){ //double
    1660                 this->inputs->AddInput(new DoubleInput(name,(int)scalar));
    1661         }
    1662         else _error_("%s%i"," could not recognize nature of vector from code ",code);
    1663 
    1664 }
    1665 /*}}}*/
    1666 /*FUNCTION Tria::InputCreate(double* vector,int index,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code){{{1*/
    1667 void Tria::InputCreate(double* vector, int index,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code){//index into elements
     1657                this->inputs->AddInput(new IntInput(name,reCast<int>(scalar)));
     1658        }
     1659        else if ((code==7) || (code==3)){ //IssmDouble
     1660                this->inputs->AddInput(new DoubleInput(name,reCast<int>(scalar)));
     1661        }
     1662        else _error2_("could not recognize nature of vector from code " << code);
     1663
     1664}
     1665/*}}}*/
     1666/*FUNCTION Tria::InputCreate(IssmDouble* vector,int index,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code){{{*/
     1667void Tria::InputCreate(IssmDouble* vector, int index,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code){//index into elements
    16681668
    16691669        /*Intermediaries*/
     
    16711671        int    tria_vertex_ids[3];
    16721672        int    row;
    1673         double nodeinputs[3];
    1674         double time;
     1673        IssmDouble nodeinputs[3];
     1674        IssmDouble time;
    16751675        TransientInput* transientinput=NULL;
    16761676        int    numberofvertices;
    16771677        int    numberofelements;
    1678         double yts;
     1678        IssmDouble yts;
    16791679
    16801680
     
    16891689                /*Recover vertices ids needed to initialize inputs*/
    16901690                for(i=0;i<3;i++){
    1691                         tria_vertex_ids[i]=(int)iomodel->Data(MeshElementsEnum)[3*index+i]; //ids for vertices are in the elements array from Matlab
     1691                        tria_vertex_ids[i]=reCast<int>(iomodel->Data(MeshElementsEnum)[3*index+i]); //ids for vertices are in the elements array from Matlab
    16921692                }
    16931693
     
    16961696
    16971697                        /*create input values: */
    1698                         for(i=0;i<3;i++)nodeinputs[i]=(double)vector[tria_vertex_ids[i]-1];
     1698                        for(i=0;i<3;i++)nodeinputs[i]=(IssmDouble)vector[tria_vertex_ids[i]-1];
    16991699
    17001700                        /*process units: */
     
    17111711                                for(i=0;i<3;i++){
    17121712                                        row=tria_vertex_ids[i]-1;
    1713                                         nodeinputs[i]=(double)vector[N*row+t];
     1713                                        nodeinputs[i]=(IssmDouble)vector[N*row+t];
    17141714                                }
    17151715
     
    17181718
    17191719                                /*time? :*/
    1720                                 time=(double)vector[(M-1)*N+t]*yts;
     1720                                time=(IssmDouble)vector[(M-1)*N+t]*yts;
    17211721
    17221722                                if(t==0) transientinput=new TransientInput(vector_enum);
     
    17251725                        this->inputs->AddInput(transientinput);
    17261726                }
    1727                 else _error_("nodal vector is either numberofnodes or numberofnodes+1 long. Field provided (%s) is %i long",EnumToStringx(vector_enum),M);
     1727                else _error2_("nodal vector is either numberofnodes or numberofnodes+1 long. Field provided (" << EnumToStringx(vector_enum) << ") is " << M << " long");
    17281728        }
    17291729        else if(vector_type==2){ //element vector
     
    17341734
    17351735                        if (code==5){ //boolean
    1736                                 this->inputs->AddInput(new BoolInput(vector_enum,(bool)vector[index]));
     1736                                this->inputs->AddInput(new BoolInput(vector_enum,reCast<bool>(vector[index])));
    17371737                        }
    17381738                        else if (code==6){ //integer
    1739                                 this->inputs->AddInput(new IntInput(vector_enum,(int)vector[index]));
     1739                                this->inputs->AddInput(new IntInput(vector_enum,reCast<int>(vector[index])));
    17401740                        }
    1741                         else if (code==7){ //double
    1742                                 this->inputs->AddInput(new DoubleInput(vector_enum,(double)vector[index]));
     1741                        else if (code==7){ //IssmDouble
     1742                                this->inputs->AddInput(new DoubleInput(vector_enum,vector[index]));
    17431743                        }
    1744                         else _error_("%s%i"," could not recognize nature of vector from code ",code);
     1744                        else _error2_("could not recognize nature of vector from code " << code);
    17451745                }
    17461746                else {
    1747                         _error_("transient elementary inputs not supported yet!");
     1747                        _error2_("transient elementary inputs not supported yet!");
    17481748                }
    17491749        }
    17501750        else{
    1751                 _error_("Cannot add input for vector type %i (not supported)",vector_type);
    1752         }
    1753 
    1754 }
    1755 /*}}}*/
    1756 /*FUNCTION Tria::IsInput{{{1*/
     1751                _error2_("Cannot add input for vector type " << vector_type << " (not supported)");
     1752        }
     1753
     1754}
     1755/*}}}*/
     1756/*FUNCTION Tria::IsInput{{{*/
    17571757bool Tria::IsInput(int name){
    17581758        if (
     
    17881788}
    17891789/*}}}*/
    1790 /*FUNCTION Tria::IsOnBed {{{1*/
     1790/*FUNCTION Tria::IsOnBed {{{*/
    17911791bool Tria::IsOnBed(){
    17921792       
     
    17961796}
    17971797/*}}}*/
    1798 /*FUNCTION Tria::IsFloating {{{1*/
     1798/*FUNCTION Tria::IsFloating {{{*/
    17991799bool   Tria::IsFloating(){
    18001800
     
    18041804}
    18051805/*}}}*/
    1806 /*FUNCTION Tria::IsNodeOnShelf {{{1*/
     1806/*FUNCTION Tria::IsNodeOnShelf {{{*/
    18071807bool   Tria::IsNodeOnShelf(){
    18081808
     
    18191819}
    18201820/*}}}*/
    1821 /*FUNCTION Tria::IsNodeOnShelfFromFlags {{{1*/
    1822 bool   Tria::IsNodeOnShelfFromFlags(double* flags){
     1821/*FUNCTION Tria::IsNodeOnShelfFromFlags {{{*/
     1822bool   Tria::IsNodeOnShelfFromFlags(IssmDouble* flags){
    18231823
    18241824        int  i;
     
    18261826
    18271827        for(i=0;i<NUMVERTICES;i++){
    1828                 if (flags[nodes[i]->Sid()]){
     1828                if (reCast<bool>(flags[nodes[i]->Sid()])){
    18291829                        shelf=true;
    18301830                        break;
     
    18341834}
    18351835/*}}}*/
    1836 /*FUNCTION Tria::IsOnWater {{{1*/
     1836/*FUNCTION Tria::IsOnWater {{{*/
    18371837bool   Tria::IsOnWater(){
    18381838
     
    18431843/*}}}*/
    18441844/*FUNCTION Tria::ListResultsInfo{{{*/
    1845 void Tria::ListResultsInfo(int** in_resultsenums,int** in_resultssizes,double** in_resultstimes,int** in_resultssteps,int* in_num_results){
     1845void Tria::ListResultsInfo(int** in_resultsenums,int** in_resultssizes,IssmDouble** in_resultstimes,int** in_resultssteps,int* in_num_results){
    18461846
    18471847        /*Intermediaries*/
     
    18501850        int     *resultsenums   = NULL;
    18511851        int     *resultssizes   = NULL;
    1852         double  *resultstimes   = NULL;
     1852        IssmDouble  *resultstimes   = NULL;
    18531853        int     *resultssteps   = NULL;
    18541854
     
    18651865
    18661866                /*Allocate output*/
    1867                 resultsenums=(int*)xmalloc(numberofresults*sizeof(int));
    1868                 resultssizes=(int*)xmalloc(numberofresults*sizeof(int));
    1869                 resultstimes=(double*)xmalloc(numberofresults*sizeof(double));
    1870                 resultssteps=(int*)xmalloc(numberofresults*sizeof(int));
     1867                resultsenums=xNew<int>(numberofresults);
     1868                resultssizes=xNew<int>(numberofresults);
     1869                resultstimes=xNew<IssmDouble>(numberofresults);
     1870                resultssteps=xNew<int>(numberofresults);
    18711871
    18721872                /*populate enums*/
     
    18931893
    18941894}/*}}}*/
    1895 /*FUNCTION Tria::MigrateGroundingLine{{{1*/
    1896 void  Tria::MigrateGroundingLine(double* old_floating_ice,double* sheet_ungrounding){
     1895/*FUNCTION Tria::MigrateGroundingLine{{{*/
     1896void  Tria::MigrateGroundingLine(IssmDouble* old_floating_ice,IssmDouble* sheet_ungrounding){
    18971897
    18981898        int     i,migration_style,unground;
    18991899        bool    elementonshelf = false;
    1900         double  bed_hydro,yts,gl_melting_rate;
    1901         double  rho_water,rho_ice,density;
    1902         double  melting[NUMVERTICES];
    1903         double  h[NUMVERTICES],s[NUMVERTICES],b[NUMVERTICES],ba[NUMVERTICES];
     1900        IssmDouble  bed_hydro,yts,gl_melting_rate;
     1901        IssmDouble  rho_water,rho_ice,density;
     1902        IssmDouble  melting[NUMVERTICES];
     1903        IssmDouble  h[NUMVERTICES],s[NUMVERTICES],b[NUMVERTICES],ba[NUMVERTICES];
    19041904
    19051905        /*Recover info at the vertices: */
     
    19171917        for(i=0;i<NUMVERTICES;i++){
    19181918                /*Ice shelf: if bed below bathymetry, impose it at the bathymetry and update surface, elso do nothing */
    1919                 if(old_floating_ice[nodes[i]->Sid()]){
     1919                if(reCast<bool>(old_floating_ice[nodes[i]->Sid()])){
    19201920                        if(b[i]<=ba[i]){
    19211921                                b[i]=ba[i];
     
    19371937                                        nodes[i]->inputs->AddInput(new BoolInput(MaskVertexongroundediceEnum,false));
    19381938                                }
    1939                                 else if(migration_style==SoftMigrationEnum && sheet_ungrounding[nodes[i]->Sid()]){
     1939                                else if(migration_style==SoftMigrationEnum && reCast<bool>(sheet_ungrounding[nodes[i]->Sid()])){
    19401940                                        s[i]=(1-density)*h[i];
    19411941                                        b[i]=-density*h[i];
     
    19691969}
    19701970/*}}}*/
    1971 /*FUNCTION Tria::MyRank {{{1*/
     1971/*FUNCTION Tria::MyRank {{{*/
    19721972int    Tria::MyRank(void){
    19731973        extern int my_rank;
     
    19751975}
    19761976/*}}}*/
    1977 /*FUNCTION Tria::NodalValue {{{1*/
    1978 int    Tria::NodalValue(double* pvalue, int index, int natureofdataenum,bool process_units){
     1977/*FUNCTION Tria::NodalValue {{{*/
     1978int    Tria::NodalValue(IssmDouble* pvalue, int index, int natureofdataenum,bool process_units){
    19791979
    19801980        int i;
    19811981        int found=0;
    1982         double value;
     1982        IssmDouble value;
    19831983        Input* data=NULL;
    19841984        GaussTria *gauss                            = NULL;
     
    20062006}
    20072007/*}}}*/
    2008 /*FUNCTION Tria::PatchFill{{{1*/
     2008/*FUNCTION Tria::PatchFill{{{*/
    20092009void  Tria::PatchFill(int* prow, Patch* patch){
    20102010
     
    20332033}
    20342034/*}}}*/
    2035 /*FUNCTION Tria::PatchSize{{{1*/
     2035/*FUNCTION Tria::PatchSize{{{*/
    20362036void  Tria::PatchSize(int* pnumrows, int* pnumvertices,int* pnumnodes){
    20372037
     
    20572057}
    20582058/*}}}*/
    2059 /*FUNCTION Tria::PotentialSheetUngrounding{{{1*/
     2059/*FUNCTION Tria::PotentialSheetUngrounding{{{*/
    20602060void  Tria::PotentialSheetUngrounding(Vector* potential_sheet_ungrounding){
    20612061
    20622062        int     i;
    2063         double  h[NUMVERTICES],ba[NUMVERTICES];
    2064         double  bed_hydro;
    2065         double  rho_water,rho_ice,density;
     2063        IssmDouble  h[NUMVERTICES],ba[NUMVERTICES];
     2064        IssmDouble  bed_hydro;
     2065        IssmDouble  rho_water,rho_ice,density;
    20662066        bool    elementonshelf = false;
    20672067
     
    20862086}
    20872087/*}}}*/
    2088 /*FUNCTION Tria::PositiveDegreeDay{{{1*/
    2089 void  Tria::PositiveDegreeDay(double* pdds,double* pds,double signorm){
    2090 
    2091    double agd[NUMVERTICES];             // surface mass balance
    2092    double monthlytemperatures[NUMVERTICES][12],monthlyprec[NUMVERTICES][12];
    2093    double h[NUMVERTICES],s[NUMVERTICES]; // ,b
    2094    double rho_water,rho_ice;
     2088/*FUNCTION Tria::PositiveDegreeDay{{{*/
     2089void  Tria::PositiveDegreeDay(IssmDouble* pdds,IssmDouble* pds,IssmDouble signorm){
     2090
     2091   IssmDouble agd[NUMVERTICES];             // surface mass balance
     2092   IssmDouble monthlytemperatures[NUMVERTICES][12],monthlyprec[NUMVERTICES][12];
     2093   IssmDouble h[NUMVERTICES],s[NUMVERTICES]; // ,b
     2094   IssmDouble rho_water,rho_ice;
    20952095
    20962096   /*Recover monthly temperatures and precipitation*/
     
    20982098   Input*     input2=inputs->GetInput(SurfaceforcingsPrecipitationEnum); _assert_(input2);
    20992099   GaussTria* gauss=new GaussTria();
    2100    double time,yts;
     2100   IssmDouble time,yts;
    21012101   this->parameters->FindParam(&time,TimeEnum);
    21022102   this->parameters->FindParam(&yts,ConstantsYtsEnum);
     
    21292129}
    21302130/*}}}*/
    2131 /*FUNCTION Tria::ProcessResultsUnits{{{1*/
     2131/*FUNCTION Tria::ProcessResultsUnits{{{*/
    21322132void  Tria::ProcessResultsUnits(void){
    21332133
     
    21402140}
    21412141/*}}}*/
    2142 /*FUNCTION Tria::RequestedOutput{{{1*/
    2143 void Tria::RequestedOutput(int output_enum,int step,double time){
     2142/*FUNCTION Tria::RequestedOutput{{{*/
     2143void Tria::RequestedOutput(int output_enum,int step,IssmDouble time){
    21442144
    21452145        if(IsInput(output_enum)){
     
    21682168}
    21692169/*}}}*/
    2170 /*FUNCTION Tria::SetClone {{{1*/
     2170/*FUNCTION Tria::SetClone {{{*/
    21712171void  Tria::SetClone(int* minranks){
    21722172
    2173         _error_("not implemented yet");
    2174 }
    2175 /*}}}1*/
    2176 /*FUNCTION Tria::SmearFunction {{{1*/
    2177 void  Tria::SmearFunction(Vector*  smearedvector,double (*WeightFunction)(double distance,double radius),double radius){
    2178         _error_("not implemented yet");
    2179 
    2180 }
    2181 /*}}}1*/
    2182 /*FUNCTION Tria::SetCurrentConfiguration {{{1*/
     2173        _error2_("not implemented yet");
     2174}
     2175/*}}}*/
     2176/*FUNCTION Tria::SmearFunction {{{*/
     2177void  Tria::SmearFunction(Vector*  smearedvector,IssmDouble (*WeightFunction)(IssmDouble distance,IssmDouble radius),IssmDouble radius){
     2178        _error2_("not implemented yet");
     2179
     2180}
     2181/*}}}*/
     2182/*FUNCTION Tria::SmbGradients{{{*/
     2183void Tria::SmbGradients(void){
     2184
     2185        int i;
     2186
     2187        // input
     2188   IssmDouble h[NUMVERTICES];                                   // ice thickness (m)           
     2189        IssmDouble s[NUMVERTICES];                                      // surface elevation (m)
     2190        IssmDouble a_pos[NUMVERTICES];                          // Hs-SMB relation parameter
     2191        IssmDouble b_pos[NUMVERTICES];                          // Hs-SMB relation parameter
     2192        IssmDouble a_neg[NUMVERTICES];                          // Hs-SMB relation parameter
     2193        IssmDouble b_neg[NUMVERTICES];                          // Hs-SMB relation paremeter
     2194        IssmDouble Hc[NUMVERTICES];                                     // elevation of transition between accumulation regime and ablation regime
     2195        IssmDouble smb_pos_max[NUMVERTICES];            // maximum SMB value in the accumulation regime
     2196        IssmDouble smb_pos_min[NUMVERTICES];            // minimum SMB value in the accumulation regime
     2197   IssmDouble rho_water;                   // density of fresh water
     2198        IssmDouble rho_ice;                     // density of ice
     2199
     2200        // output
     2201        IssmDouble smb[NUMVERTICES];                                    // surface mass balance (m/yr ice)
     2202
     2203        /*Recover SmbGradients*/
     2204        GetInputListOnVertices(&Hc[0],SurfaceforcingsHcEnum);
     2205        GetInputListOnVertices(&smb_pos_max[0],SurfaceforcingsSmbPosMaxEnum);
     2206        GetInputListOnVertices(&smb_pos_min[0],SurfaceforcingsSmbPosMinEnum);
     2207        GetInputListOnVertices(&a_pos[0],SurfaceforcingsAPosEnum);
     2208        GetInputListOnVertices(&b_pos[0],SurfaceforcingsBPosEnum);
     2209        GetInputListOnVertices(&a_neg[0],SurfaceforcingsANegEnum);
     2210        GetInputListOnVertices(&b_neg[0],SurfaceforcingsBNegEnum);
     2211       
     2212   /*Recover surface elevatio at vertices: */
     2213        GetInputListOnVertices(&h[0],ThicknessEnum);
     2214        GetInputListOnVertices(&s[0],SurfaceEnum);
     2215
     2216   /*Get material parameters :*/
     2217   rho_ice=matpar->GetRhoIce();
     2218   rho_water=matpar->GetRhoFreshwater();
     2219                       
     2220   // loop over all vertices
     2221   for(i=0;i<NUMVERTICES;i++){
     2222     if(s[i]>Hc[i]){
     2223            smb[i]=a_pos[i]+b_pos[i]*s[i];
     2224                 if(smb[i]>smb_pos_max[i]){smb[i]=smb_pos_max[i];}
     2225                 if(smb[i]<smb_pos_min[i]){smb[i]=smb_pos_min[i];}
     2226          }
     2227          else{
     2228            smb[i]=a_neg[i]+b_neg[i]*s[i];
     2229          }
     2230          smb[i]=smb[i]/rho_ice;      // SMB in m/y ice         
     2231        }  //end of the loop over the vertices
     2232          /*Update inputs*/
     2233          this->inputs->AddInput(new TriaP1Input(SurfaceforcingsMassBalanceEnum,&smb[0]));
     2234}
     2235/*}}}*/
     2236/*FUNCTION Tria::SetCurrentConfiguration {{{*/
    21832237void  Tria::SetCurrentConfiguration(Elements* elementsin, Loads* loadsin, DataSet* nodesin, Materials* materialsin, Parameters* parametersin){
    21842238       
     
    21962250}
    21972251/*}}}*/
    2198 /*FUNCTION Tria::SurfaceArea {{{1*/
    2199 double Tria::SurfaceArea(void){
     2252/*FUNCTION Tria::SurfaceArea {{{*/
     2253IssmDouble Tria::SurfaceArea(void){
    22002254
    22012255        int    i;
    2202         double S;
    2203         double normal[3];
    2204         double v13[3],v23[3];
    2205         double xyz_list[NUMVERTICES][3];
     2256        IssmDouble S;
     2257        IssmDouble normal[3];
     2258        IssmDouble v13[3],v23[3];
     2259        IssmDouble xyz_list[NUMVERTICES][3];
    22062260
    22072261        /*If on water, return 0: */
     
    22192273        normal[2]=v13[0]*v23[1]-v13[1]*v23[0];
    22202274
    2221         S = 0.5 * sqrt(pow(normal[0],(double)2)+pow(normal[1],(double)2)+pow(normal[2],(double)2));
     2275        S = 0.5 * sqrt(pow(normal[0],(IssmDouble)2)+pow(normal[1],(IssmDouble)2)+pow(normal[2],(IssmDouble)2));
    22222276
    22232277        /*Return: */
     
    22252279}
    22262280/*}}}*/
    2227 /*FUNCTION Tria::SurfaceNormal{{{1*/
    2228 void Tria::SurfaceNormal(double* surface_normal, double xyz_list[3][3]){
     2281/*FUNCTION Tria::SurfaceNormal{{{*/
     2282void Tria::SurfaceNormal(IssmDouble* surface_normal, IssmDouble xyz_list[3][3]){
    22292283
    22302284        int i;
    2231         double v13[3],v23[3];
    2232         double normal[3];
    2233         double normal_norm;
     2285        IssmDouble v13[3],v23[3];
     2286        IssmDouble normal[3];
     2287        IssmDouble normal_norm;
    22342288
    22352289        for (i=0;i<3;i++){
     
    22422296        normal[2]=v13[0]*v23[1]-v13[1]*v23[0];
    22432297
    2244         normal_norm=sqrt( pow(normal[0],(double)2)+pow(normal[1],(double)2)+pow(normal[2],(double)2) );
     2298        normal_norm=sqrt( pow(normal[0],(IssmDouble)2)+pow(normal[1],(IssmDouble)2)+pow(normal[2],(IssmDouble)2) );
    22452299
    22462300        *(surface_normal)=normal[0]/normal_norm;
     
    22492303}
    22502304/*}}}*/
    2251 /*FUNCTION Tria::TimeAdapt{{{1*/
    2252 double  Tria::TimeAdapt(void){
     2305/*FUNCTION Tria::TimeAdapt{{{*/
     2306IssmDouble  Tria::TimeAdapt(void){
    22532307
    22542308        /*intermediary: */
    22552309        int    i;
    2256         double C,dt;
    2257         double dx,dy;
    2258         double maxx,minx;
    2259         double maxy,miny;
    2260         double maxabsvx,maxabsvy;
    2261         double xyz_list[NUMVERTICES][3];
     2310        IssmDouble C,dt;
     2311        IssmDouble dx,dy;
     2312        IssmDouble maxx,minx;
     2313        IssmDouble maxy,miny;
     2314        IssmDouble maxabsvx,maxabsvy;
     2315        IssmDouble xyz_list[NUMVERTICES][3];
    22622316
    22632317        /*get CFL coefficient:*/
     
    22692323        this->MaxAbsVy(&maxabsvy,false);
    22702324        #else
    2271                 _error_("ISSM was not compiled with responses compiled in, exiting!");
     2325                _error2_("ISSM was not compiled with responses compiled in, exiting!");
    22722326        #endif
    22732327
     
    22952349}
    22962350/*}}}*/
    2297 /*FUNCTION Tria::Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type){{{1*/
     2351/*FUNCTION Tria::Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type){{{*/
    22982352void Tria::Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type){ //i is the element index
    22992353
     
    23032357        int    tria_vertex_ids[3];
    23042358        int    tria_type;
    2305         double nodeinputs[3];
    2306         double yts;
     2359        IssmDouble nodeinputs[3];
     2360        IssmDouble yts;
    23072361        int    progstabilization,balancestabilization;
    23082362        bool   dakota_analysis;
    23092363
    23102364        /*Checks if debuging*/
    2311         /*{{{2*/
     2365        /*{{{*/
    23122366        _assert_(iomodel->Data(MeshElementsEnum));
    23132367        /*}}}*/
     
    23322386        /*Recover vertices ids needed to initialize inputs*/
    23332387        for(i=0;i<3;i++){
    2334                 tria_vertex_ids[i]=(int)iomodel->Data(MeshElementsEnum)[3*index+i]; //ids for vertices are in the elements array from Matlab
     2388                tria_vertex_ids[i]=reCast<int>(iomodel->Data(MeshElementsEnum)[3*index+i]); //ids for vertices are in the elements array from Matlab
    23352389        }
    23362390
     
    23452399                /*Continuous Galerkin*/
    23462400                for(i=0;i<3;i++){
    2347                         tria_node_ids[i]=iomodel->nodecounter+(int)*(iomodel->Data(MeshElementsEnum)+3*index+i); //ids for vertices are in the elements array from Matlab
     2401                        tria_node_ids[i]=iomodel->nodecounter+reCast<int,IssmDouble>(*(iomodel->Data(MeshElementsEnum)+3*index+i)); //ids for vertices are in the elements array from Matlab
    23482402                }
    23492403        }
     
    23952449}
    23962450/*}}}*/
    2397 /*FUNCTION Tria::UpdatePotentialSheetUngrounding{{{1*/
    2398 int Tria::UpdatePotentialSheetUngrounding(double* vertices_potentially_ungrounding,Vector* vec_nodes_on_iceshelf,double* nodes_on_iceshelf){
     2451/*FUNCTION Tria::UpdatePotentialSheetUngrounding{{{*/
     2452int Tria::UpdatePotentialSheetUngrounding(IssmDouble* vertices_potentially_ungrounding,Vector* vec_nodes_on_iceshelf,IssmDouble* nodes_on_iceshelf){
    23992453
    24002454        int i;
     
    24032457        /*Go through nodes, and whoever is on the potential_sheet_ungrounding, ends up in nodes_on_iceshelf: */
    24042458        for(i=0;i<3;i++){
    2405                 if (vertices_potentially_ungrounding[nodes[i]->Sid()]){
     2459                if (reCast<bool>(vertices_potentially_ungrounding[nodes[i]->Sid()])){
    24062460                        vec_nodes_on_iceshelf->SetValue(nodes[i]->Sid(),1,INS_VAL);
    24072461               
     
    24172471
    24182472#ifdef _HAVE_RESPONSES_
    2419 /*FUNCTION Tria::IceVolume {{{1*/
    2420 double Tria::IceVolume(void){
     2473/*FUNCTION Tria::IceVolume {{{*/
     2474IssmDouble Tria::IceVolume(void){
    24212475
    24222476        /*The volume of a troncated prism is base * 1/3 sum(length of edges)*/
    2423         double base,surface,bed;
    2424         double xyz_list[NUMVERTICES][3];
     2477        IssmDouble base,surface,bed;
     2478        IssmDouble xyz_list[NUMVERTICES][3];
    24252479
    24262480        if(IsOnWater())return 0;
     
    24432497}
    24442498/*}}}*/
    2445 /*FUNCTION Tria::MassFlux {{{1*/
    2446 double Tria::MassFlux( double* segment,bool process_units){
     2499/*FUNCTION Tria::MassFlux {{{*/
     2500IssmDouble Tria::MassFlux( IssmDouble* segment,bool process_units){
    24472501
    24482502        const int    numdofs=2;
    24492503
    24502504        int        i,dim;
    2451         double     mass_flux=0;
    2452         double     xyz_list[NUMVERTICES][3];
    2453         double     normal[2];
    2454         double     length,rho_ice;
    2455         double     x1,y1,x2,y2,h1,h2;
    2456         double     vx1,vx2,vy1,vy2;
     2505        IssmDouble     mass_flux=0;
     2506        IssmDouble     xyz_list[NUMVERTICES][3];
     2507        IssmDouble     normal[2];
     2508        IssmDouble     length,rho_ice;
     2509        IssmDouble     x1,y1,x2,y2,h1,h2;
     2510        IssmDouble     vx1,vx2,vy1,vy2;
    24572511        GaussTria* gauss_1=NULL;
    24582512        GaussTria* gauss_2=NULL;
     
    24622516
    24632517        /*First off, check that this segment belongs to this element: */
    2464         if ((int)*(segment+4)!=this->id)_error_("%s%i%s%i","error message: segment with id ",(int)*(segment+4)," does not belong to element with id:",this->id);
     2518        if ((int)*(segment+4)!=this->id)_error2_("error message: segment with id " << (int)*(segment+4) << " does not belong to element with id:" << this->id);
    24652519
    24662520        /*Recover segment node locations: */
     
    25152569}
    25162570/*}}}*/
    2517 /*FUNCTION Tria::MaxAbsVx{{{1*/
    2518 void  Tria::MaxAbsVx(double* pmaxabsvx, bool process_units){
     2571/*FUNCTION Tria::MaxAbsVx{{{*/
     2572void  Tria::MaxAbsVx(IssmDouble* pmaxabsvx, bool process_units){
    25192573
    25202574        /*Get maximum:*/
    2521         double maxabsvx=this->inputs->MaxAbs(VxEnum);
     2575        IssmDouble maxabsvx=this->inputs->MaxAbs(VxEnum);
    25222576
    25232577        /*process units if requested: */
     
    25282582}
    25292583/*}}}*/
    2530 /*FUNCTION Tria::MaxAbsVy{{{1*/
    2531 void  Tria::MaxAbsVy(double* pmaxabsvy, bool process_units){
     2584/*FUNCTION Tria::MaxAbsVy{{{*/
     2585void  Tria::MaxAbsVy(IssmDouble* pmaxabsvy, bool process_units){
    25322586
    25332587        /*Get maximum:*/
    2534         double maxabsvy=this->inputs->MaxAbs(VyEnum);
     2588        IssmDouble maxabsvy=this->inputs->MaxAbs(VyEnum);
    25352589
    25362590        /*process units if requested: */
     
    25412595}
    25422596/*}}}*/
    2543 /*FUNCTION Tria::MaxAbsVz{{{1*/
    2544 void  Tria::MaxAbsVz(double* pmaxabsvz, bool process_units){
     2597/*FUNCTION Tria::MaxAbsVz{{{*/
     2598void  Tria::MaxAbsVz(IssmDouble* pmaxabsvz, bool process_units){
    25452599
    25462600        /*Get maximum:*/
    2547         double maxabsvz=this->inputs->MaxAbs(VzEnum);
     2601        IssmDouble maxabsvz=this->inputs->MaxAbs(VzEnum);
    25482602
    25492603        /*process units if requested: */
     
    25542608}
    25552609/*}}}*/
    2556 /*FUNCTION Tria::MaxVel{{{1*/
    2557 void  Tria::MaxVel(double* pmaxvel, bool process_units){
     2610/*FUNCTION Tria::MaxVel{{{*/
     2611void  Tria::MaxVel(IssmDouble* pmaxvel, bool process_units){
    25582612
    25592613        /*Get maximum:*/
    2560         double maxvel=this->inputs->Max(VelEnum);
     2614        IssmDouble maxvel=this->inputs->Max(VelEnum);
    25612615
    25622616        /*process units if requested: */
     
    25672621}
    25682622/*}}}*/
    2569 /*FUNCTION Tria::MaxVx{{{1*/
    2570 void  Tria::MaxVx(double* pmaxvx, bool process_units){
     2623/*FUNCTION Tria::MaxVx{{{*/
     2624void  Tria::MaxVx(IssmDouble* pmaxvx, bool process_units){
    25712625
    25722626        /*Get maximum:*/
    2573         double maxvx=this->inputs->Max(VxEnum);
     2627        IssmDouble maxvx=this->inputs->Max(VxEnum);
    25742628
    25752629        /*process units if requested: */
     
    25802634}
    25812635/*}}}*/
    2582 /*FUNCTION Tria::MaxVy{{{1*/
    2583 void  Tria::MaxVy(double* pmaxvy, bool process_units){
     2636/*FUNCTION Tria::MaxVy{{{*/
     2637void  Tria::MaxVy(IssmDouble* pmaxvy, bool process_units){
    25842638
    25852639        /*Get maximum:*/
    2586         double maxvy=this->inputs->Max(VyEnum);
     2640        IssmDouble maxvy=this->inputs->Max(VyEnum);
    25872641
    25882642        /*process units if requested: */
     
    25942648}
    25952649/*}}}*/
    2596 /*FUNCTION Tria::MaxVz{{{1*/
    2597 void  Tria::MaxVz(double* pmaxvz, bool process_units){
     2650/*FUNCTION Tria::MaxVz{{{*/
     2651void  Tria::MaxVz(IssmDouble* pmaxvz, bool process_units){
    25982652
    25992653        /*Get maximum:*/
    2600         double maxvz=this->inputs->Max(VzEnum);
     2654        IssmDouble maxvz=this->inputs->Max(VzEnum);
    26012655
    26022656        /*process units if requested: */
     
    26072661}
    26082662/*}}}*/
    2609 /*FUNCTION Tria::MinVel{{{1*/
    2610 void  Tria::MinVel(double* pminvel, bool process_units){
     2663/*FUNCTION Tria::MinVel{{{*/
     2664void  Tria::MinVel(IssmDouble* pminvel, bool process_units){
    26112665
    26122666        /*Get minimum:*/
    2613         double minvel=this->inputs->Min(VelEnum);
     2667        IssmDouble minvel=this->inputs->Min(VelEnum);
    26142668
    26152669        /*process units if requested: */
     
    26202674}
    26212675/*}}}*/
    2622 /*FUNCTION Tria::MinVx{{{1*/
    2623 void  Tria::MinVx(double* pminvx, bool process_units){
     2676/*FUNCTION Tria::MinVx{{{*/
     2677void  Tria::MinVx(IssmDouble* pminvx, bool process_units){
    26242678
    26252679        /*Get minimum:*/
    2626         double minvx=this->inputs->Min(VxEnum);
     2680        IssmDouble minvx=this->inputs->Min(VxEnum);
    26272681
    26282682        /*process units if requested: */
     
    26332687}
    26342688/*}}}*/
    2635 /*FUNCTION Tria::MinVy{{{1*/
    2636 void  Tria::MinVy(double* pminvy, bool process_units){
     2689/*FUNCTION Tria::MinVy{{{*/
     2690void  Tria::MinVy(IssmDouble* pminvy, bool process_units){
    26372691
    26382692        /*Get minimum:*/
    2639         double minvy=this->inputs->Min(VyEnum);
     2693        IssmDouble minvy=this->inputs->Min(VyEnum);
    26402694
    26412695        /*process units if requested: */
     
    26462700}
    26472701/*}}}*/
    2648 /*FUNCTION Tria::MinVz{{{1*/
    2649 void  Tria::MinVz(double* pminvz, bool process_units){
     2702/*FUNCTION Tria::MinVz{{{*/
     2703void  Tria::MinVz(IssmDouble* pminvz, bool process_units){
    26502704
    26512705        /*Get minimum:*/
    2652         double minvz=this->inputs->Min(VzEnum);
     2706        IssmDouble minvz=this->inputs->Min(VzEnum);
    26532707
    26542708        /*process units if requested: */
     
    26592713}
    26602714/*}}}*/
    2661 /*FUNCTION Tria::ElementResponse{{{1*/
    2662 void Tria::ElementResponse(double* presponse,int response_enum,bool process_units){
     2715/*FUNCTION Tria::ElementResponse{{{*/
     2716void Tria::ElementResponse(IssmDouble* presponse,int response_enum,bool process_units){
    26632717
    26642718        switch(response_enum){
     
    26692723
    26702724                        /*Get input:*/
    2671                         double vel;
     2725                        IssmDouble vel;
    26722726                        Input* vel_input;
    26732727
     
    26812735                        *presponse=vel;
    26822736                default: 
    2683                         _error_("Response type %s not supported yet!",EnumToStringx(response_enum));
     2737                        _error2_("Response type " << EnumToStringx(response_enum) << " not supported yet!");
    26842738        }
    26852739
     
    26892743
    26902744#ifdef _HAVE_DIAGNOSTIC_
    2691 /*FUNCTION Tria::CreateKMatrixDiagnosticMacAyeal {{{1*/
     2745/*FUNCTION Tria::CreateKMatrixDiagnosticMacAyeal {{{*/
    26922746ElementMatrix* Tria::CreateKMatrixDiagnosticMacAyeal(void){
    26932747
     
    27032757}
    27042758/*}}}*/
    2705 /*FUNCTION Tria::CreateKMatrixDiagnosticMacAyealViscous{{{1*/
     2759/*FUNCTION Tria::CreateKMatrixDiagnosticMacAyealViscous{{{*/
    27062760ElementMatrix* Tria::CreateKMatrixDiagnosticMacAyealViscous(void){
    27072761
     
    27112765        /*Intermediaries*/
    27122766        int        i,j,ig;
    2713         double     xyz_list[NUMVERTICES][3];
    2714         double     viscosity,newviscosity,oldviscosity;
    2715         double     viscosity_overshoot,thickness,Jdet;
    2716         double     epsilon[3],oldepsilon[3];    /* epsilon=[exx,eyy,exy];    */
    2717         double     B[3][numdof];
    2718         double     Bprime[3][numdof];
    2719         double     D[3][3]   = {0.0};
    2720         double     D_scalar;
     2767        IssmDouble     xyz_list[NUMVERTICES][3];
     2768        IssmDouble     viscosity,newviscosity,oldviscosity;
     2769        IssmDouble     viscosity_overshoot,thickness,Jdet;
     2770        IssmDouble     epsilon[3],oldepsilon[3];    /* epsilon=[exx,eyy,exy];    */
     2771        IssmDouble     B[3][numdof];
     2772        IssmDouble     Bprime[3][numdof];
     2773        IssmDouble     D[3][3]   = {0.0};
     2774        IssmDouble     D_scalar;
    27212775        GaussTria *gauss = NULL;
    27222776
     
    27672821}
    27682822/*}}}*/
    2769 /*FUNCTION Tria::CreateKMatrixDiagnosticMacAyealFriction {{{1*/
     2823/*FUNCTION Tria::CreateKMatrixDiagnosticMacAyealFriction {{{*/
    27702824ElementMatrix* Tria::CreateKMatrixDiagnosticMacAyealFriction(void){
    27712825
     
    27762830        int        i,j,ig;
    27772831        int        analysis_type;
    2778         double     MAXSLOPE  = .06; // 6 %
    2779         double     MOUNTAINKEXPONENT = 10;
    2780         double     slope_magnitude,alpha2;
    2781         double     Jdet;
    2782         double     L[2][numdof];
    2783         double     DL[2][2]  = {{ 0,0 },{0,0}};
    2784         double     DL_scalar;
    2785         double     slope[2]  = {0.0,0.0};
    2786         double     xyz_list[NUMVERTICES][3];
     2832        IssmDouble     MAXSLOPE  = .06; // 6 %
     2833        IssmDouble     MOUNTAINKEXPONENT = 10;
     2834        IssmDouble     slope_magnitude,alpha2;
     2835        IssmDouble     Jdet;
     2836        IssmDouble     L[2][numdof];
     2837        IssmDouble     DL[2][2]  = {{ 0,0 },{0,0}};
     2838        IssmDouble     DL_scalar;
     2839        IssmDouble     slope[2]  = {0.0,0.0};
     2840        IssmDouble     xyz_list[NUMVERTICES][3];
    27872841        Friction  *friction = NULL;
    27882842        GaussTria *gauss    = NULL;
     
    28132867                surface_input->GetInputDerivativeValue(&slope[0],&xyz_list[0][0],gauss);
    28142868                slope_magnitude=sqrt(pow(slope[0],2)+pow(slope[1],2));
    2815                 if(slope_magnitude>MAXSLOPE) alpha2=pow((double)10,MOUNTAINKEXPONENT);
     2869                if(slope_magnitude>MAXSLOPE) alpha2=pow((IssmDouble)10,MOUNTAINKEXPONENT);
    28162870                else friction->GetAlpha2(&alpha2, gauss,VxEnum,VyEnum,VzEnum);
    28172871
     
    28362890}
    28372891/*}}}*/
    2838 /*FUNCTION Tria::CreateKMatrixDiagnosticHutter{{{1*/
     2892/*FUNCTION Tria::CreateKMatrixDiagnosticHutter{{{*/
    28392893ElementMatrix* Tria::CreateKMatrixDiagnosticHutter(void){
    28402894
     
    28492903        for(i=0;i<NUMVERTICES;i++){
    28502904                connectivity=nodes[i]->GetConnectivity();
    2851                 Ke->values[(2*i)*numdof  +(2*i)  ]=1/(double)connectivity;
    2852                 Ke->values[(2*i+1)*numdof+(2*i+1)]=1/(double)connectivity;
     2905                Ke->values[(2*i)*numdof  +(2*i)  ]=1/(IssmDouble)connectivity;
     2906                Ke->values[(2*i+1)*numdof+(2*i+1)]=1/(IssmDouble)connectivity;
    28532907        }
    28542908
     
    28572911}
    28582912/*}}}*/
    2859 /*FUNCTION Tria::CreatePVectorDiagnosticMacAyeal {{{1*/
     2913/*FUNCTION Tria::CreatePVectorDiagnosticMacAyeal {{{*/
    28602914ElementVector* Tria::CreatePVectorDiagnosticMacAyeal(){
    28612915
     
    28652919        /*Intermediaries */
    28662920        int            i,j,ig;
    2867         double         driving_stress_baseline,thickness;
    2868         double         Jdet;
    2869         double         xyz_list[NUMVERTICES][3];
    2870         double         slope[2];
    2871         double         basis[3];
    2872         double         pe_g_gaussian[numdof];
     2921        IssmDouble         driving_stress_baseline,thickness;
     2922        IssmDouble         Jdet;
     2923        IssmDouble         xyz_list[NUMVERTICES][3];
     2924        IssmDouble         slope[2];
     2925        IssmDouble         basis[3];
     2926        IssmDouble         pe_g_gaussian[numdof];
    28732927        GaussTria*     gauss=NULL;
    28742928
     
    29112965}
    29122966/*}}}*/
    2913 /*FUNCTION Tria::CreatePVectorDiagnosticHutter{{{1*/
     2967/*FUNCTION Tria::CreatePVectorDiagnosticHutter{{{*/
    29142968ElementVector* Tria::CreatePVectorDiagnosticHutter(void){
    29152969
    29162970        /*Intermediaries */
    29172971        int        i,connectivity;
    2918         double     constant_part,ub,vb;
    2919         double     rho_ice,gravity,n,B;
    2920         double     slope2,thickness;
    2921         double     slope[2];
     2972        IssmDouble     constant_part,ub,vb;
     2973        IssmDouble     rho_ice,gravity,n,B;
     2974        IssmDouble     slope2,thickness;
     2975        IssmDouble     slope[2];
    29222976        GaussTria* gauss=NULL;
    29232977
     
    29493003                constant_part=-2*pow(rho_ice*gravity,n)*pow(slope2,((n-1)/2));
    29503004
    2951                 ub=-1.58*pow((double)10.0,(double)-10.0)*rho_ice*gravity*thickness*slope[0];
    2952                 vb=-1.58*pow((double)10.0,(double)-10.0)*rho_ice*gravity*thickness*slope[1];
    2953 
    2954                 pe->values[2*i]  =(ub-2.0*pow(rho_ice*gravity,n)*pow(slope2,((n-1)/2.0))*pow(thickness,n)/(pow(B,n)*(n+1))*slope[0])/(double)connectivity;
    2955                 pe->values[2*i+1]=(vb-2.0*pow(rho_ice*gravity,n)*pow(slope2,((n-1)/2.0))*pow(thickness,n)/(pow(B,n)*(n+1))*slope[1])/(double)connectivity;
     3005                ub=-1.58*pow((IssmDouble)10.0,(IssmDouble)-10.0)*rho_ice*gravity*thickness*slope[0];
     3006                vb=-1.58*pow((IssmDouble)10.0,(IssmDouble)-10.0)*rho_ice*gravity*thickness*slope[1];
     3007
     3008                pe->values[2*i]  =(ub-2.0*pow(rho_ice*gravity,n)*pow(slope2,((n-1)/2.0))*pow(thickness,n)/(pow(B,n)*(n+1))*slope[0])/(IssmDouble)connectivity;
     3009                pe->values[2*i+1]=(vb-2.0*pow(rho_ice*gravity,n)*pow(slope2,((n-1)/2.0))*pow(thickness,n)/(pow(B,n)*(n+1))*slope[1])/(IssmDouble)connectivity;
    29563010        }
    29573011
     
    29613015}
    29623016/*}}}*/
    2963 /*FUNCTION Tria::CreateJacobianDiagnosticMacayeal{{{1*/
     3017/*FUNCTION Tria::CreateJacobianDiagnosticMacayeal{{{*/
    29643018ElementMatrix* Tria::CreateJacobianDiagnosticMacayeal(void){
    29653019
     
    29693023        /*Intermediaries */
    29703024        int        i,j,ig;
    2971         double     xyz_list[NUMVERTICES][3];
    2972         double     Jdet,thickness;
    2973         double     eps1dotdphii,eps1dotdphij;
    2974         double     eps2dotdphii,eps2dotdphij;
    2975         double     mu_prime;
    2976         double     epsilon[3];/* epsilon=[exx,eyy,exy];*/
    2977         double     eps1[2],eps2[2];
    2978         double     phi[NUMVERTICES];
    2979         double     dphi[2][NUMVERTICES];
     3025        IssmDouble     xyz_list[NUMVERTICES][3];
     3026        IssmDouble     Jdet,thickness;
     3027        IssmDouble     eps1dotdphii,eps1dotdphij;
     3028        IssmDouble     eps2dotdphii,eps2dotdphij;
     3029        IssmDouble     mu_prime;
     3030        IssmDouble     epsilon[3];/* epsilon=[exx,eyy,exy];*/
     3031        IssmDouble     eps1[2],eps2[2];
     3032        IssmDouble     phi[NUMVERTICES];
     3033        IssmDouble     dphi[2][NUMVERTICES];
    29803034        GaussTria *gauss=NULL;
    29813035
     
    30273081}
    30283082/*}}}*/
    3029 /*FUNCTION Tria::GetSolutionFromInputsDiagnosticHoriz{{{1*/
     3083/*FUNCTION Tria::GetSolutionFromInputsDiagnosticHoriz{{{*/
    30303084void  Tria::GetSolutionFromInputsDiagnosticHoriz(Vector* solution){
    30313085
     
    30343088        int          i;
    30353089        int*         doflist=NULL;
    3036         double       vx,vy;
    3037         double       values[numdof];
     3090        IssmDouble       vx,vy;
     3091        IssmDouble       values[numdof];
    30383092        GaussTria*   gauss=NULL;
    30393093
     
    30633117        /*Free ressources:*/
    30643118        delete gauss;
    3065         xfree((void**)&doflist);
    3066 }
    3067 /*}}}*/
    3068 /*FUNCTION Tria::GetSolutionFromInputsDiagnosticHutter{{{1*/
     3119        xDelete<int>(doflist);
     3120}
     3121/*}}}*/
     3122/*FUNCTION Tria::GetSolutionFromInputsDiagnosticHutter{{{*/
    30693123void  Tria::GetSolutionFromInputsDiagnosticHutter(Vector* solution){
    30703124
     
    30723126
    30733127        int        i;
    3074         double     vx,vy;
    3075         double     values[numdof];
     3128        IssmDouble     vx,vy;
     3129        IssmDouble     values[numdof];
    30763130        int       *doflist = NULL;
    30773131        GaussTria *gauss   = NULL;
     
    31023156        /*Free ressources:*/
    31033157        delete gauss;
    3104         xfree((void**)&doflist);
    3105 }
    3106 /*}}}*/
    3107 /*FUNCTION Tria::InputUpdateFromSolutionDiagnosticHoriz {{{1*/
    3108 void  Tria::InputUpdateFromSolutionDiagnosticHoriz(double* solution){
     3158        xDelete<int>(doflist);
     3159}
     3160/*}}}*/
     3161/*FUNCTION Tria::InputUpdateFromSolutionDiagnosticHoriz {{{*/
     3162void  Tria::InputUpdateFromSolutionDiagnosticHoriz(IssmDouble* solution){
    31093163       
    31103164        const int numdof=NDOF2*NUMVERTICES;
     
    31123166        int       i;
    31133167        int*      doflist=NULL;
    3114         double    rho_ice,g;
    3115         double    values[numdof];
    3116         double    vx[NUMVERTICES];
    3117         double    vy[NUMVERTICES];
    3118         double    vz[NUMVERTICES];
    3119         double    vel[NUMVERTICES];
    3120         double    pressure[NUMVERTICES];
    3121         double    thickness[NUMVERTICES];
     3168        IssmDouble    rho_ice,g;
     3169        IssmDouble    values[numdof];
     3170        IssmDouble    vx[NUMVERTICES];
     3171        IssmDouble    vy[NUMVERTICES];
     3172        IssmDouble    vz[NUMVERTICES];
     3173        IssmDouble    vel[NUMVERTICES];
     3174        IssmDouble    pressure[NUMVERTICES];
     3175        IssmDouble    thickness[NUMVERTICES];
    31223176       
    31233177        /*Get dof list: */
     
    31363190
    31373191                /*Check solution*/
    3138                 if(isnan(vx[i])) _error_("NaN found in solution vector");
    3139                 if(isnan(vy[i])) _error_("NaN found in solution vector");
     3192                if(xIsNan<IssmDouble>(vx[i])) _error2_("NaN found in solution vector");
     3193                if(xIsNan<IssmDouble>(vy[i])) _error2_("NaN found in solution vector");
    31403194        }
    31413195
     
    31643218
    31653219        /*Free ressources:*/
    3166         xfree((void**)&doflist);
    3167 
    3168 }
    3169 /*}}}*/
    3170 /*FUNCTION Tria::InputUpdateFromSolutionDiagnosticHutter {{{1*/
    3171 void  Tria::InputUpdateFromSolutionDiagnosticHutter(double* solution){
     3220        xDelete<int>(doflist);
     3221
     3222}
     3223/*}}}*/
     3224/*FUNCTION Tria::InputUpdateFromSolutionDiagnosticHutter {{{*/
     3225void  Tria::InputUpdateFromSolutionDiagnosticHutter(IssmDouble* solution){
    31723226       
    31733227        const int numdof=NDOF2*NUMVERTICES;
     
    31753229        int       i;
    31763230        int*      doflist=NULL;
    3177         double    rho_ice,g;
    3178         double    values[numdof];
    3179         double    vx[NUMVERTICES];
    3180         double    vy[NUMVERTICES];
    3181         double    vz[NUMVERTICES];
    3182         double    vel[NUMVERTICES];
    3183         double    pressure[NUMVERTICES];
    3184         double    thickness[NUMVERTICES];
     3231        IssmDouble    rho_ice,g;
     3232        IssmDouble    values[numdof];
     3233        IssmDouble    vx[NUMVERTICES];
     3234        IssmDouble    vy[NUMVERTICES];
     3235        IssmDouble    vz[NUMVERTICES];
     3236        IssmDouble    vel[NUMVERTICES];
     3237        IssmDouble    pressure[NUMVERTICES];
     3238        IssmDouble    thickness[NUMVERTICES];
    31853239       
    31863240        /*Get dof list: */
     
    31963250
    31973251                /*Check solution*/
    3198                 if(isnan(vx[i])) _error_("NaN found in solution vector");
    3199                 if(isnan(vy[i])) _error_("NaN found in solution vector");
     3252                if(xIsNan<IssmDouble>(vx[i])) _error2_("NaN found in solution vector");
     3253                if(xIsNan<IssmDouble>(vy[i])) _error2_("NaN found in solution vector");
    32003254        }
    32013255
     
    32243278
    32253279        /*Free ressources:*/
    3226         xfree((void**)&doflist);
     3280        xDelete<int>(doflist);
    32273281}
    32283282/*}}}*/
     
    32303284
    32313285#ifdef _HAVE_CONTROL_
    3232 /*FUNCTION Tria::InputControlUpdate{{{1*/
    3233 void  Tria::InputControlUpdate(double scalar,bool save_parameter){
     3286/*FUNCTION Tria::InputControlUpdate{{{*/
     3287void  Tria::InputControlUpdate(IssmDouble scalar,bool save_parameter){
    32343288
    32353289        /*Intermediary*/
     
    32523306
    32533307                if (input->ObjectEnum()!=ControlInputEnum){
    3254                         _error_("input %s is not a ControlInput",EnumToStringx(control_type[i]));
     3308                        _error2_("input " << EnumToStringx(control_type[i]) << " is not a ControlInput");
    32553309                }
    32563310
     
    32623316
    32633317        /*Clean up and return*/
    3264         xfree((void**)&control_type);
    3265 }
    3266 /*}}}*/
    3267 /*FUNCTION Tria::ControlInputGetGradient{{{1*/
     3318        xDelete<int>(control_type);
     3319}
     3320/*}}}*/
     3321/*FUNCTION Tria::ControlInputGetGradient{{{*/
    32683322void Tria::ControlInputGetGradient(Vector* gradient,int enum_type,int control_index){
    32693323
     
    32773331                input=inputs->GetInput(enum_type);
    32783332        }
    3279         if (!input) _error_("Input %s not found",EnumToStringx(enum_type));
    3280         if (input->ObjectEnum()!=ControlInputEnum) _error_("Input %s is not a ControlInput",EnumToStringx(enum_type));
     3333        if (!input) _error2_("Input " << EnumToStringx(enum_type) << " not found");
     3334        if (input->ObjectEnum()!=ControlInputEnum) _error2_("Input " << EnumToStringx(enum_type) << " is not a ControlInput");
    32813335
    32823336        GradientIndexing(&doflist1[0],control_index);
     
    32843338
    32853339}/*}}}*/
    3286 /*FUNCTION Tria::ControlInputScaleGradient{{{1*/
    3287 void Tria::ControlInputScaleGradient(int enum_type,double scale){
     3340/*FUNCTION Tria::ControlInputScaleGradient{{{*/
     3341void Tria::ControlInputScaleGradient(int enum_type,IssmDouble scale){
    32883342
    32893343        Input* input=NULL;
     
    32953349                input=inputs->GetInput(enum_type);
    32963350        }
    3297         if (!input) _error_("Input %s not found",EnumToStringx(enum_type));
    3298         if (input->ObjectEnum()!=ControlInputEnum) _error_("Input %s is not a ControlInput",EnumToStringx(enum_type));
     3351        if (!input) _error2_("Input " << EnumToStringx(enum_type) << " not found");
     3352        if (input->ObjectEnum()!=ControlInputEnum) _error2_("Input " << EnumToStringx(enum_type) << " is not a ControlInput");
    32993353
    33003354        ((ControlInput*)input)->ScaleGradient(scale);
    33013355}/*}}}*/
    3302 /*FUNCTION Tria::ControlInputSetGradient{{{1*/
    3303 void Tria::ControlInputSetGradient(double* gradient,int enum_type,int control_index){
     3356/*FUNCTION Tria::ControlInputSetGradient{{{*/
     3357void Tria::ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index){
    33043358
    33053359        int    doflist1[NUMVERTICES];
    3306         double grad_list[NUMVERTICES];
     3360        IssmDouble grad_list[NUMVERTICES];
    33073361        Input* grad_input=NULL;
    33083362        Input* input=NULL;
     
    33143368                input=inputs->GetInput(enum_type);
    33153369        }
    3316         if (!input) _error_("Input %s not found",EnumToStringx(enum_type));
    3317         if (input->ObjectEnum()!=ControlInputEnum) _error_("Input %s is not a ControlInput",EnumToStringx(enum_type));
     3370        if (!input) _error2_("Input " << EnumToStringx(enum_type) << " not found");
     3371        if (input->ObjectEnum()!=ControlInputEnum) _error2_("Input " << EnumToStringx(enum_type) << " is not a ControlInput");
    33183372
    33193373        GradientIndexing(&doflist1[0],control_index);
     
    33243378
    33253379}/*}}}*/
    3326 /*FUNCTION Tria::Gradj {{{1*/
     3380/*FUNCTION Tria::Gradj {{{*/
    33273381void  Tria::Gradj(Vector* gradient,int control_type,int control_index){
    33283382        /*dJ/dalpha = ∂L/∂alpha = ∂J/∂alpha + ∂/∂alpha(KU-F)*/
     
    33493403                        break;
    33503404                default:
    3351                         _error_("%s%i","control type not supported yet: ",control_type);
     3405                        _error2_("control type not supported yet: " << control_type);
    33523406        }
    33533407
     
    33773431                        break;
    33783432                default:
    3379                         _error_("response %s not supported yet",EnumToStringx(responses[resp]));
    3380         }
    3381 
    3382         xfree((void**)&responses);
    3383 }
    3384 /*}}}*/
    3385 /*FUNCTION Tria::GradjBGradient{{{1*/
     3433                        _error2_("response " << EnumToStringx(responses[resp]) << " not supported yet");
     3434        }
     3435
     3436        xDelete<int>(responses);
     3437}
     3438/*}}}*/
     3439/*FUNCTION Tria::GradjBGradient{{{*/
    33863440void  Tria::GradjBGradient(Vector* gradient,int weight_index,int control_index){
    33873441
    33883442        int        i,ig;
    33893443        int        doflist1[NUMVERTICES];
    3390         double     Jdet,weight;
    3391         double     xyz_list[NUMVERTICES][3];
    3392         double     dbasis[NDOF2][NUMVERTICES];
    3393         double     dk[NDOF2];
    3394         double     grade_g[NUMVERTICES]={0.0};
     3444        IssmDouble     Jdet,weight;
     3445        IssmDouble     xyz_list[NUMVERTICES][3];
     3446        IssmDouble     dbasis[NDOF2][NUMVERTICES];
     3447        IssmDouble     dk[NDOF2];
     3448        IssmDouble     grade_g[NUMVERTICES]={0.0};
    33953449        GaussTria  *gauss=NULL;
    33963450
     
    34233477}
    34243478/*}}}*/
    3425 /*FUNCTION Tria::GradjBMacAyeal{{{1*/
     3479/*FUNCTION Tria::GradjBMacAyeal{{{*/
    34263480void  Tria::GradjBMacAyeal(Vector* gradient,int control_index){
    34273481
     
    34293483        int        i,ig;
    34303484        int        doflist[NUMVERTICES];
    3431         double     vx,vy,lambda,mu,thickness,Jdet;
    3432         double     viscosity_complement;
    3433         double     dvx[NDOF2],dvy[NDOF2],dadjx[NDOF2],dadjy[NDOF2],dB[NDOF2];
    3434         double     xyz_list[NUMVERTICES][3];
    3435         double     basis[3],epsilon[3];
    3436         double     grad[NUMVERTICES]={0.0};
     3485        IssmDouble     vx,vy,lambda,mu,thickness,Jdet;
     3486        IssmDouble     viscosity_complement;
     3487        IssmDouble     dvx[NDOF2],dvy[NDOF2],dadjx[NDOF2],dadjy[NDOF2],dB[NDOF2];
     3488        IssmDouble     xyz_list[NUMVERTICES][3];
     3489        IssmDouble     basis[3],epsilon[3];
     3490        IssmDouble     grad[NUMVERTICES]={0.0};
    34373491        GaussTria *gauss = NULL;
    34383492
     
    34803534}
    34813535/*}}}*/
    3482 /*FUNCTION Tria::GradjDragMacAyeal {{{1*/
     3536/*FUNCTION Tria::GradjDragMacAyeal {{{*/
    34833537void  Tria::GradjDragMacAyeal(Vector* gradient,int control_index){
    34843538
     
    34873541        int        doflist1[NUMVERTICES];
    34883542        int        connectivity[NUMVERTICES];
    3489         double     vx,vy,lambda,mu,alpha_complement,Jdet;
    3490         double     bed,thickness,Neff,drag;
    3491         double     xyz_list[NUMVERTICES][3];
    3492         double     dk[NDOF2];
    3493         double     grade_g[NUMVERTICES]={0.0};
    3494         double     grade_g_gaussian[NUMVERTICES];
    3495         double     basis[3];
    3496         double     epsilon[3]; /* epsilon=[exx,eyy,exy];*/
     3543        IssmDouble     vx,vy,lambda,mu,alpha_complement,Jdet;
     3544        IssmDouble     bed,thickness,Neff,drag;
     3545        IssmDouble     xyz_list[NUMVERTICES][3];
     3546        IssmDouble     dk[NDOF2];
     3547        IssmDouble     grade_g[NUMVERTICES]={0.0};
     3548        IssmDouble     grade_g_gaussian[NUMVERTICES];
     3549        IssmDouble     basis[3];
     3550        IssmDouble     epsilon[3]; /* epsilon=[exx,eyy,exy];*/
    34973551        Friction*  friction=NULL;
    34983552        GaussTria  *gauss=NULL;
     
    35423596                /*Add gradje_g_gaussian vector to gradje_g: */
    35433597                for(i=0;i<NUMVERTICES;i++){
    3544                         _assert_(!isnan(grade_g[i]));
     3598                        _assert_(!xIsNan<IssmDouble>(grade_g[i]));
    35453599                        grade_g[i]+=grade_g_gaussian[i];
    35463600                }
     
    35573611        //      vx_input->GetInputValue(&vx,gauss);
    35583612        //      vy_input->GetInputValue(&vy,gauss);
    3559         //      grade_g[iv] = -2*1.e+7*drag*alpha_complement*(lambda*vx+mu*vy)/((double)connectivity[iv]);
     3613        //      grade_g[iv] = -2*1.e+7*drag*alpha_complement*(lambda*vx+mu*vy)/((IssmDouble)connectivity[iv]);
    35603614        //}
    35613615        /*End Analytical gradient*/
     
    35683622}
    35693623/*}}}*/
    3570 /*FUNCTION Tria::GradjDragGradient{{{1*/
     3624/*FUNCTION Tria::GradjDragGradient{{{*/
    35713625void  Tria::GradjDragGradient(Vector* gradient, int weight_index,int control_index){
    35723626
    35733627        int        i,ig;
    35743628        int        doflist1[NUMVERTICES];
    3575         double     Jdet,weight;
    3576         double     xyz_list[NUMVERTICES][3];
    3577         double     dbasis[NDOF2][NUMVERTICES];
    3578         double     dk[NDOF2];
    3579         double     grade_g[NUMVERTICES]={0.0};
     3629        IssmDouble     Jdet,weight;
     3630        IssmDouble     xyz_list[NUMVERTICES][3];
     3631        IssmDouble     dbasis[NDOF2][NUMVERTICES];
     3632        IssmDouble     dk[NDOF2];
     3633        IssmDouble     grade_g[NUMVERTICES]={0.0};
    35803634        GaussTria  *gauss=NULL;
    35813635
     
    36033657                for (i=0;i<NUMVERTICES;i++){
    36043658                        grade_g[i]+=-weight*Jdet*gauss->weight*(dbasis[0][i]*dk[0]+dbasis[1][i]*dk[1]);
    3605                         _assert_(!isnan(grade_g[i]));
     3659                        _assert_(!xIsNan<IssmDouble>(grade_g[i]));
    36063660                }
    36073661        }
     
    36123666}
    36133667/*}}}*/
    3614 /*FUNCTION Tria::GradjDhDtBalancedthickness{{{1*/
     3668/*FUNCTION Tria::GradjDhDtBalancedthickness{{{*/
    36153669void  Tria::GradjDhDtBalancedthickness(Vector* gradient,int control_index){
    36163670
    36173671        /*Intermediaries*/
    36183672        int    doflist1[NUMVERTICES];
    3619         double lambda[NUMVERTICES];
    3620         double gradient_g[NUMVERTICES];
     3673        IssmDouble lambda[NUMVERTICES];
     3674        IssmDouble gradient_g[NUMVERTICES];
    36213675
    36223676        /*Compute Gradient*/
     
    36283682}
    36293683/*}}}*/
    3630 /*FUNCTION Tria::GradjVxBalancedthickness{{{1*/
     3684/*FUNCTION Tria::GradjVxBalancedthickness{{{*/
    36313685void  Tria::GradjVxBalancedthickness(Vector* gradient,int control_index){
    36323686
     
    36343688        int        i,ig;
    36353689        int        doflist1[NUMVERTICES];
    3636         double     thickness,Jdet;
    3637         double     basis[3];
    3638         double     Dlambda[2],dp[2];
    3639         double     xyz_list[NUMVERTICES][3];
    3640         double     grade_g[NUMVERTICES] = {0.0};
     3690        IssmDouble     thickness,Jdet;
     3691        IssmDouble     basis[3];
     3692        IssmDouble     Dlambda[2],dp[2];
     3693        IssmDouble     xyz_list[NUMVERTICES][3];
     3694        IssmDouble     grade_g[NUMVERTICES] = {0.0};
    36413695        GaussTria *gauss                = NULL;
    36423696
     
    36713725}
    36723726/*}}}*/
    3673 /*FUNCTION Tria::GradjVyBalancedthickness{{{1*/
     3727/*FUNCTION Tria::GradjVyBalancedthickness{{{*/
    36743728void  Tria::GradjVyBalancedthickness(Vector* gradient,int control_index){
    36753729
     
    36773731        int        i,ig;
    36783732        int        doflist1[NUMVERTICES];
    3679         double     thickness,Jdet;
    3680         double     basis[3];
    3681         double     Dlambda[2],dp[2];
    3682         double     xyz_list[NUMVERTICES][3];
    3683         double     grade_g[NUMVERTICES] = {0.0};
     3733        IssmDouble     thickness,Jdet;
     3734        IssmDouble     basis[3];
     3735        IssmDouble     Dlambda[2],dp[2];
     3736        IssmDouble     xyz_list[NUMVERTICES][3];
     3737        IssmDouble     grade_g[NUMVERTICES] = {0.0};
    36843738        GaussTria *gauss                = NULL;
    36853739
     
    37133767}
    37143768/*}}}*/
    3715 /*FUNCTION Tria::GradientIndexing{{{1*/
     3769/*FUNCTION Tria::GradientIndexing{{{*/
    37163770void  Tria::GradientIndexing(int* indexing,int control_index){
    37173771
     
    37273781}
    37283782/*}}}*/
    3729 /*FUNCTION Tria::RheologyBbarAbsGradient{{{1*/
    3730 double Tria::RheologyBbarAbsGradient(bool process_units,int weight_index){
     3783/*FUNCTION Tria::RheologyBbarAbsGradient{{{*/
     3784IssmDouble Tria::RheologyBbarAbsGradient(bool process_units,int weight_index){
    37313785
    37323786        /* Intermediaries */
    37333787        int        ig;
    3734         double     Jelem = 0;
    3735         double     weight;
    3736         double     Jdet;
    3737         double     xyz_list[NUMVERTICES][3];
    3738         double     dp[NDOF2];
     3788        IssmDouble     Jelem = 0;
     3789        IssmDouble     weight;
     3790        IssmDouble     Jdet;
     3791        IssmDouble     xyz_list[NUMVERTICES][3];
     3792        IssmDouble     dp[NDOF2];
    37393793        GaussTria *gauss = NULL;
    37403794
     
    37713825}
    37723826/*}}}*/
    3773 /*FUNCTION Tria::SurfaceAverageVelMisfit {{{1*/
    3774 double Tria::SurfaceAverageVelMisfit(bool process_units,int weight_index){
     3827/*FUNCTION Tria::SurfaceAverageVelMisfit {{{*/
     3828IssmDouble Tria::SurfaceAverageVelMisfit(bool process_units,int weight_index){
    37753829
    37763830        const int    numdof=2*NUMVERTICES;
    37773831
    37783832        int        i,ig;
    3779         double     Jelem=0,S,Jdet;
    3780         double     misfit;
    3781         double     vx,vy,vxobs,vyobs,weight;
    3782         double     xyz_list[NUMVERTICES][3];
     3833        IssmDouble     Jelem=0,S,Jdet;
     3834        IssmDouble     misfit;
     3835        IssmDouble     vx,vy,vxobs,vyobs,weight;
     3836        IssmDouble     xyz_list[NUMVERTICES][3];
    37833837        GaussTria *gauss=NULL;
    37843838
     
    38323886}
    38333887/*}}}*/
    3834 /*FUNCTION Tria::SurfaceLogVelMisfit {{{1*/
    3835 double Tria::SurfaceLogVelMisfit(bool process_units,int weight_index){
     3888/*FUNCTION Tria::SurfaceLogVelMisfit {{{*/
     3889IssmDouble Tria::SurfaceLogVelMisfit(bool process_units,int weight_index){
    38363890
    38373891        const int    numdof=NDOF2*NUMVERTICES;
    38383892
    38393893        int        i,ig;
    3840         double     Jelem=0;
    3841         double     misfit,Jdet;
    3842         double     epsvel=2.220446049250313e-16;
    3843         double     meanvel=3.170979198376458e-05; /*1000 m/yr*/
    3844         double     velocity_mag,obs_velocity_mag;
    3845         double     xyz_list[NUMVERTICES][3];
    3846         double     vx,vy,vxobs,vyobs,weight;
     3894        IssmDouble     Jelem=0;
     3895        IssmDouble     misfit,Jdet;
     3896        IssmDouble     epsvel=2.220446049250313e-16;
     3897        IssmDouble     meanvel=3.170979198376458e-05; /*1000 m/yr*/
     3898        IssmDouble     velocity_mag,obs_velocity_mag;
     3899        IssmDouble     xyz_list[NUMVERTICES][3];
     3900        IssmDouble     vx,vy,vxobs,vyobs,weight;
    38473901        GaussTria *gauss=NULL;
    38483902
     
    38973951}
    38983952/*}}}*/
    3899 /*FUNCTION Tria::SurfaceLogVxVyMisfit {{{1*/
    3900 double Tria::SurfaceLogVxVyMisfit(bool process_units,int weight_index){
     3953/*FUNCTION Tria::SurfaceLogVxVyMisfit {{{*/
     3954IssmDouble Tria::SurfaceLogVxVyMisfit(bool process_units,int weight_index){
    39013955
    39023956        const int    numdof=NDOF2*NUMVERTICES;
     
    39043958        int        i,ig;
    39053959        int        fit=-1;
    3906         double     Jelem=0, S=0;
    3907         double     epsvel=2.220446049250313e-16;
    3908         double     meanvel=3.170979198376458e-05; /*1000 m/yr*/
    3909         double     misfit, Jdet;
    3910         double     vx,vy,vxobs,vyobs,weight;
    3911         double     xyz_list[NUMVERTICES][3];
     3960        IssmDouble     Jelem=0, S=0;
     3961        IssmDouble     epsvel=2.220446049250313e-16;
     3962        IssmDouble     meanvel=3.170979198376458e-05; /*1000 m/yr*/
     3963        IssmDouble     misfit, Jdet;
     3964        IssmDouble     vx,vy,vxobs,vyobs,weight;
     3965        IssmDouble     xyz_list[NUMVERTICES][3];
    39123966        GaussTria *gauss=NULL;
    39133967
     
    39634017}
    39644018/*}}}*/
    3965 /*FUNCTION Tria::SurfaceAbsVelMisfit {{{1*/
    3966 double Tria::SurfaceAbsVelMisfit(bool process_units,int weight_index){
     4019/*FUNCTION Tria::SurfaceAbsVelMisfit {{{*/
     4020IssmDouble Tria::SurfaceAbsVelMisfit(bool process_units,int weight_index){
    39674021
    39684022        const int    numdof=NDOF2*NUMVERTICES;
    39694023
    39704024        int        i,ig;
    3971         double     Jelem=0;
    3972         double     misfit,Jdet;
    3973         double     vx,vy,vxobs,vyobs,weight;
    3974         double     xyz_list[NUMVERTICES][3];
     4025        IssmDouble     Jelem=0;
     4026        IssmDouble     misfit,Jdet;
     4027        IssmDouble     vx,vy,vxobs,vyobs,weight;
     4028        IssmDouble     xyz_list[NUMVERTICES][3];
    39754029        GaussTria *gauss=NULL;
    39764030
     
    40244078}
    40254079/*}}}*/
    4026 /*FUNCTION Tria::SurfaceRelVelMisfit {{{1*/
    4027 double Tria::SurfaceRelVelMisfit(bool process_units,int weight_index){
     4080/*FUNCTION Tria::SurfaceRelVelMisfit {{{*/
     4081IssmDouble Tria::SurfaceRelVelMisfit(bool process_units,int weight_index){
    40284082        const int  numdof=2*NUMVERTICES;
    40294083
    40304084        int        i,ig;
    4031         double     Jelem=0;
    4032         double     scalex=1,scaley=1;
    4033         double     misfit,Jdet;
    4034         double     epsvel=2.220446049250313e-16;
    4035         double     meanvel=3.170979198376458e-05; /*1000 m/yr*/
    4036         double     vx,vy,vxobs,vyobs,weight;
    4037         double     xyz_list[NUMVERTICES][3];
     4085        IssmDouble     Jelem=0;
     4086        IssmDouble     scalex=1,scaley=1;
     4087        IssmDouble     misfit,Jdet;
     4088        IssmDouble     epsvel=2.220446049250313e-16;
     4089        IssmDouble     meanvel=3.170979198376458e-05; /*1000 m/yr*/
     4090        IssmDouble     vx,vy,vxobs,vyobs,weight;
     4091        IssmDouble     xyz_list[NUMVERTICES][3];
    40384092        GaussTria *gauss=NULL;
    40394093
     
    40884142}
    40894143/*}}}*/
    4090 /*FUNCTION Tria::ThicknessAbsGradient{{{1*/
    4091 double Tria::ThicknessAbsGradient(bool process_units,int weight_index){
     4144/*FUNCTION Tria::ThicknessAbsGradient{{{*/
     4145IssmDouble Tria::ThicknessAbsGradient(bool process_units,int weight_index){
    40924146
    40934147        /* Intermediaries */
    40944148        int        ig;
    4095         double     Jelem = 0;
    4096         double     weight;
    4097         double     Jdet;
    4098         double     xyz_list[NUMVERTICES][3];
    4099         double     dp[NDOF2];
     4149        IssmDouble     Jelem = 0;
     4150        IssmDouble     weight;
     4151        IssmDouble     Jdet;
     4152        IssmDouble     xyz_list[NUMVERTICES][3];
     4153        IssmDouble     dp[NDOF2];
    41004154        GaussTria *gauss = NULL;
    41014155
     
    41324186}
    41334187/*}}}*/
    4134 /*FUNCTION Tria::ThicknessAbsMisfit {{{1*/
    4135 double Tria::ThicknessAbsMisfit(bool process_units,int weight_index){
     4188/*FUNCTION Tria::ThicknessAbsMisfit {{{*/
     4189IssmDouble Tria::ThicknessAbsMisfit(bool process_units,int weight_index){
    41364190
    41374191        /*Intermediaries*/
    41384192        int        i,ig;
    4139         double     thickness,thicknessobs,weight;
    4140         double     Jdet;
    4141         double     Jelem = 0;
    4142         double     xyz_list[NUMVERTICES][3];
     4193        IssmDouble     thickness,thicknessobs,weight;
     4194        IssmDouble     Jdet;
     4195        IssmDouble     Jelem = 0;
     4196        IssmDouble     xyz_list[NUMVERTICES][3];
    41434197        GaussTria *gauss = NULL;
    4144         double     dH[2];
     4198        IssmDouble     dH[2];
    41454199
    41464200        /*If on water, return 0: */
     
    41774231}
    41784232/*}}}*/
    4179 /*FUNCTION Tria::CreatePVectorAdjointBalancethickness{{{1*/
     4233/*FUNCTION Tria::CreatePVectorAdjointBalancethickness{{{*/
    41804234ElementVector* Tria::CreatePVectorAdjointBalancethickness(void){
    41814235
     
    41854239        /*Intermediaries */
    41864240        int         i,ig,resp;
    4187         double      Jdet;
    4188         double      thickness,thicknessobs,weight;
     4241        IssmDouble      Jdet;
     4242        IssmDouble      thickness,thicknessobs,weight;
    41894243        int        *responses = NULL;
    41904244        int         num_responses;
    4191         double      xyz_list[NUMVERTICES][3];
    4192         double      basis[3];
    4193         double      dbasis[NDOF2][NUMVERTICES];
    4194         double      dH[2];
     4245        IssmDouble      xyz_list[NUMVERTICES][3];
     4246        IssmDouble      basis[3];
     4247        IssmDouble      dbasis[NDOF2][NUMVERTICES];
     4248        IssmDouble      dH[2];
    41954249        GaussTria*  gauss=NULL;
    41964250
     
    42334287                                break;
    42344288                        default:
    4235                                 _error_("response %s not supported yet",EnumToStringx(responses[resp]));
     4289                                _error2_("response " << EnumToStringx(responses[resp]) << " not supported yet");
    42364290                }
    42374291        }
     
    42394293        /*Clean up and return*/
    42404294        delete gauss;
    4241         xfree((void**)&responses);
     4295        xDelete<int>(responses);
    42424296        return pe;
    42434297}
    42444298/*}}}*/
    4245 /*FUNCTION Tria::CreatePVectorAdjointHoriz{{{1*/
     4299/*FUNCTION Tria::CreatePVectorAdjointHoriz{{{*/
    42464300ElementVector* Tria::CreatePVectorAdjointHoriz(void){
    42474301
     
    42534307        int       *responses=NULL;
    42544308        int        num_responses;
    4255         double     Jdet;
    4256         double     obs_velocity_mag,velocity_mag;
    4257         double     dux,duy;
    4258         double     epsvel=2.220446049250313e-16;
    4259         double     meanvel=3.170979198376458e-05; /*1000 m/yr*/
    4260         double     scalex=0,scaley=0,scale=0,S=0;
    4261         double     vx,vy,vxobs,vyobs,weight;
    4262         double     xyz_list[NUMVERTICES][3];
    4263         double     basis[3];
     4309        IssmDouble     Jdet;
     4310        IssmDouble     obs_velocity_mag,velocity_mag;
     4311        IssmDouble     dux,duy;
     4312        IssmDouble     epsvel=2.220446049250313e-16;
     4313        IssmDouble     meanvel=3.170979198376458e-05; /*1000 m/yr*/
     4314        IssmDouble     scalex=0,scaley=0,scale=0,S=0;
     4315        IssmDouble     vx,vy,vxobs,vyobs,weight;
     4316        IssmDouble     xyz_list[NUMVERTICES][3];
     4317        IssmDouble     basis[3];
    42644318        GaussTria* gauss=NULL;
    42654319
     
    44114465                                        break;
    44124466                                default:
    4413                                         _error_("response %s not supported yet",EnumToStringx(responses[resp]));
     4467                                        _error2_("response " << EnumToStringx(responses[resp]) << " not supported yet");
    44144468                        }
    44154469                }
     
    44184472        /*Clean up and return*/
    44194473        delete gauss;
    4420         xfree((void**)&responses);
     4474        xDelete<int>(responses);
    44214475        return pe;
    44224476}
    44234477/*}}}*/
    4424 /*FUNCTION Tria::CreatePVectorAdjointStokes{{{1*/
     4478/*FUNCTION Tria::CreatePVectorAdjointStokes{{{*/
    44254479ElementVector* Tria::CreatePVectorAdjointStokes(void){
    44264480
     
    44294483        int       *responses=NULL;
    44304484        int        num_responses;
    4431         double     Jdet;
    4432         double     obs_velocity_mag,velocity_mag;
    4433         double     dux,duy;
    4434         double     epsvel=2.220446049250313e-16;
    4435         double     meanvel=3.170979198376458e-05; /*1000 m/yr*/
    4436         double     scalex=0,scaley=0,scale=0,S=0;
    4437         double     vx,vy,vxobs,vyobs,weight;
    4438         double     xyz_list[NUMVERTICES][3];
    4439         double     basis[3];
     4485        IssmDouble     Jdet;
     4486        IssmDouble     obs_velocity_mag,velocity_mag;
     4487        IssmDouble     dux,duy;
     4488        IssmDouble     epsvel=2.220446049250313e-16;
     4489        IssmDouble     meanvel=3.170979198376458e-05; /*1000 m/yr*/
     4490        IssmDouble     scalex=0,scaley=0,scale=0,S=0;
     4491        IssmDouble     vx,vy,vxobs,vyobs,weight;
     4492        IssmDouble     xyz_list[NUMVERTICES][3];
     4493        IssmDouble     basis[3];
    44404494        GaussTria* gauss=NULL;
    44414495
     
    45884642                                        break;
    45894643                                default:
    4590                                         _error_("response %s not supported yet",EnumToStringx(responses[resp]));
     4644                                        _error2_("response " << EnumToStringx(responses[resp]) << " not supported yet");
    45914645                        }
    45924646                }
     
    45954649        /*Clean up and return*/
    45964650        delete gauss;
    4597         xfree((void**)&responses);
     4651        xDelete<int>(responses);
    45984652        return pe;
    45994653}
    46004654/*}}}*/
    4601 /*FUNCTION Tria::DragCoefficientAbsGradient{{{1*/
    4602 double Tria::DragCoefficientAbsGradient(bool process_units,int weight_index){
     4655/*FUNCTION Tria::DragCoefficientAbsGradient{{{*/
     4656IssmDouble Tria::DragCoefficientAbsGradient(bool process_units,int weight_index){
    46034657
    46044658        /* Intermediaries */
    46054659        int        ig;
    4606         double     Jelem = 0;
    4607         double     weight;
    4608         double     Jdet;
    4609         double     xyz_list[NUMVERTICES][3];
    4610         double     dp[NDOF2];
     4660        IssmDouble     Jelem = 0;
     4661        IssmDouble     weight;
     4662        IssmDouble     Jdet;
     4663        IssmDouble     xyz_list[NUMVERTICES][3];
     4664        IssmDouble     dp[NDOF2];
    46114665        GaussTria *gauss = NULL;
    46124666
     
    46434697}
    46444698/*}}}*/
    4645 /*FUNCTION Tria::CreateKMatrixAdjointBalancethickness {{{1*/
     4699/*FUNCTION Tria::CreateKMatrixAdjointBalancethickness {{{*/
    46464700ElementMatrix* Tria::CreateKMatrixAdjointBalancethickness(void){
    46474701
     
    46574711                        break;
    46584712                default:
    4659                         _error_("Element type %s not supported yet",EnumToStringx(GetElementType()));
     4713                        _error2_("Element type " << EnumToStringx(GetElementType()) << " not supported yet");
    46604714        }
    46614715
     
    46654719}
    46664720/*}}}*/
    4667 /*FUNCTION Tria::CreateKMatrixAdjointMacAyeal{{{1*/
     4721/*FUNCTION Tria::CreateKMatrixAdjointMacAyeal{{{*/
    46684722ElementMatrix* Tria::CreateKMatrixAdjointMacAyeal(void){
    46694723
     
    46744728        int        i,j,ig;
    46754729        bool       incomplete_adjoint;
    4676         double     xyz_list[NUMVERTICES][3];
    4677         double     Jdet,thickness;
    4678         double     eps1dotdphii,eps1dotdphij;
    4679         double     eps2dotdphii,eps2dotdphij;
    4680         double     mu_prime;
    4681         double     epsilon[3];/* epsilon=[exx,eyy,exy];*/
    4682         double     eps1[2],eps2[2];
    4683         double     phi[NUMVERTICES];
    4684         double     dphi[2][NUMVERTICES];
     4730        IssmDouble     xyz_list[NUMVERTICES][3];
     4731        IssmDouble     Jdet,thickness;
     4732        IssmDouble     eps1dotdphii,eps1dotdphij;
     4733        IssmDouble     eps2dotdphii,eps2dotdphij;
     4734        IssmDouble     mu_prime;
     4735        IssmDouble     epsilon[3];/* epsilon=[exx,eyy,exy];*/
     4736        IssmDouble     eps1[2],eps2[2];
     4737        IssmDouble     phi[NUMVERTICES];
     4738        IssmDouble     dphi[2][NUMVERTICES];
    46854739        GaussTria *gauss=NULL;
    46864740
     
    47354789}
    47364790/*}}}*/
    4737 /*FUNCTION Tria::InputUpdateFromSolutionAdjointHoriz {{{1*/
    4738 void  Tria::InputUpdateFromSolutionAdjointHoriz(double* solution){
     4791/*FUNCTION Tria::InputUpdateFromSolutionAdjointHoriz {{{*/
     4792void  Tria::InputUpdateFromSolutionAdjointHoriz(IssmDouble* solution){
    47394793
    47404794        const int numdof=NDOF2*NUMVERTICES;
     
    47424796        int       i;
    47434797        int*      doflist=NULL;
    4744         double    values[numdof];
    4745         double    lambdax[NUMVERTICES];
    4746         double    lambday[NUMVERTICES];
     4798        IssmDouble    values[numdof];
     4799        IssmDouble    lambdax[NUMVERTICES];
     4800        IssmDouble    lambday[NUMVERTICES];
    47474801
    47484802        /*Get dof list: */
     
    47584812
    47594813                /*Check solution*/
    4760                 if(isnan(lambdax[i])) _error_("NaN found in solution vector");
    4761                 if(isnan(lambday[i])) _error_("NaN found in solution vector");
     4814                if(xIsNan<IssmDouble>(lambdax[i])) _error2_("NaN found in solution vector");
     4815                if(xIsNan<IssmDouble>(lambday[i])) _error2_("NaN found in solution vector");
    47624816        }
    47634817
     
    47674821
    47684822        /*Free ressources:*/
    4769         xfree((void**)&doflist);
    4770 }
    4771 /*}}}*/
    4772 
    4773 /*FUNCTION Tria::InputUpdateFromSolutionAdjointBalancethickness {{{1*/
    4774 void  Tria::InputUpdateFromSolutionAdjointBalancethickness(double* solution){
     4823        xDelete<int>(doflist);
     4824}
     4825/*}}}*/
     4826/*FUNCTION Tria::InputUpdateFromSolutionAdjointBalancethickness {{{*/
     4827void  Tria::InputUpdateFromSolutionAdjointBalancethickness(IssmDouble* solution){
    47754828
    47764829        const int numdof=NDOF1*NUMVERTICES;
     
    47784831        int       i;
    47794832        int*      doflist=NULL;
    4780         double    values[numdof];
    4781         double    lambda[NUMVERTICES];
     4833        IssmDouble    values[numdof];
     4834        IssmDouble    lambda[NUMVERTICES];
    47824835
    47834836        /*Get dof list: */
     
    47904843        for(i=0;i<numdof;i++){
    47914844                lambda[i]=values[i];
    4792                 if(isnan(lambda[i])) _error_("NaN found in solution vector");
     4845                if(xIsNan<IssmDouble>(lambda[i])) _error2_("NaN found in solution vector");
    47934846        }
    47944847
     
    47974850
    47984851        /*Free ressources:*/
    4799         xfree((void**)&doflist);
    4800 }
    4801 /*}}}*/
    4802 /*FUNCTION Tria::GetVectorFromControlInputs{{{1*/
     4852        xDelete<int>(doflist);
     4853}
     4854/*}}}*/
     4855/*FUNCTION Tria::GetVectorFromControlInputs{{{*/
    48034856void  Tria::GetVectorFromControlInputs(Vector* vector,int control_enum,int control_index,const char* data){
    48044857
     
    48224875        /*Check that it is a ControlInput*/
    48234876        if (input->ObjectEnum()!=ControlInputEnum){
    4824                 _error_("input %s is not a ControlInput",EnumToStringx(control_enum));
     4877                _error2_("input " << EnumToStringx(control_enum) << " is not a ControlInput");
    48254878        }
    48264879
     
    48284881}
    48294882/*}}}*/
    4830 /*FUNCTION Tria::SetControlInputsFromVector{{{1*/
    4831 void  Tria::SetControlInputsFromVector(double* vector,int control_enum,int control_index){
    4832 
    4833         double  values[NUMVERTICES];
     4883/*FUNCTION Tria::SetControlInputsFromVector{{{*/
     4884void  Tria::SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index){
     4885
     4886        IssmDouble  values[NUMVERTICES];
    48344887        int     doflist1[NUMVERTICES];
    48354888        Input  *input     = NULL;
     
    48564909
    48574910        if (input->ObjectEnum()!=ControlInputEnum){
    4858                 _error_("input %s is not a ControlInput",EnumToStringx(control_enum));
     4911                _error2_("input " << EnumToStringx(control_enum) << " is not a ControlInput");
    48594912        }
    48604913
     
    48654918
    48664919#ifdef _HAVE_HYDROLOGY_
    4867 /*FUNCTION Tria::CreateHydrologyWaterVelocityInput {{{1*/
     4920/*FUNCTION Tria::CreateHydrologyWaterVelocityInput {{{*/
    48684921void Tria::CreateHydrologyWaterVelocityInput(void){
    48694922
    48704923        /*material parameters: */
    4871         double mu_water;
    4872         double VelocityFactor;  // This factor represents the number 12 in laminar flow velocity which can vary by differnt hydrology.CR
    4873         double n_man,CR;
    4874         double w;
    4875         double rho_ice, rho_water, g;
    4876         double dsdx,dsdy,dbdx,dbdy;
    4877         double vx[NUMVERTICES];
    4878         double vy[NUMVERTICES];
     4924        IssmDouble mu_water;
     4925        IssmDouble VelocityFactor;  // This factor represents the number 12 in laminar flow velocity which can vary by differnt hydrology.CR
     4926        IssmDouble n_man,CR;
     4927        IssmDouble w;
     4928        IssmDouble rho_ice, rho_water, g;
     4929        IssmDouble dsdx,dsdy,dbdx,dbdy;
     4930        IssmDouble vx[NUMVERTICES];
     4931        IssmDouble vy[NUMVERTICES];
    48794932        GaussTria *gauss = NULL;
    48804933
     
    49204973}
    49214974/*}}}*/
    4922 /*FUNCTION Tria::CreateKMatrixHydrology{{{1*/
     4975/*FUNCTION Tria::CreateKMatrixHydrology{{{*/
    49234976ElementMatrix* Tria::CreateKMatrixHydrology(void){
    49244977
     
    49274980
    49284981        /*Intermediaries */
    4929         double     diffusivity;
     4982        IssmDouble     diffusivity;
    49304983        int        i,j,ig;
    4931         double     Jdettria,DL_scalar,dt,h;
    4932         double     vx,vy,vel,dvxdx,dvydy;
    4933         double     dvx[2],dvy[2];
    4934         double     v_gauss[2]={0.0};
    4935         double     xyz_list[NUMVERTICES][3];
    4936         double     L[NUMVERTICES];
    4937         double     B[2][NUMVERTICES];
    4938         double     Bprime[2][NUMVERTICES];
    4939         double     K[2][2]                        ={0.0};
    4940         double     KDL[2][2]                      ={0.0};
    4941         double     DL[2][2]                        ={0.0};
    4942         double     DLprime[2][2]                   ={0.0};
     4984        IssmDouble     Jdettria,DL_scalar,dt,h;
     4985        IssmDouble     vx,vy,vel,dvxdx,dvydy;
     4986        IssmDouble     dvx[2],dvy[2];
     4987        IssmDouble     v_gauss[2]={0.0};
     4988        IssmDouble     xyz_list[NUMVERTICES][3];
     4989        IssmDouble     L[NUMVERTICES];
     4990        IssmDouble     B[2][NUMVERTICES];
     4991        IssmDouble     Bprime[2][NUMVERTICES];
     4992        IssmDouble     K[2][2]                        ={0.0};
     4993        IssmDouble     KDL[2][2]                      ={0.0};
     4994        IssmDouble     DL[2][2]                        ={0.0};
     4995        IssmDouble     DLprime[2][2]                   ={0.0};
    49434996        GaussTria *gauss=NULL;
    49444997
     
    50255078}
    50265079/*}}}*/
    5027 /*FUNCTION Tria::CreatePVectorHydrology {{{1*/
     5080/*FUNCTION Tria::CreatePVectorHydrology {{{*/
    50285081ElementVector* Tria::CreatePVectorHydrology(void){
    50295082
     
    50335086        /*Intermediaries */
    50345087        int        i,j,ig;
    5035         double     Jdettria,dt;
    5036         double     basal_melting_g;
    5037         double     old_watercolumn_g;
    5038         double     xyz_list[NUMVERTICES][3];
    5039         double     basis[numdof];
     5088        IssmDouble     Jdettria,dt;
     5089        IssmDouble     basal_melting_g;
     5090        IssmDouble     old_watercolumn_g;
     5091        IssmDouble     xyz_list[NUMVERTICES][3];
     5092        IssmDouble     basis[numdof];
    50405093        GaussTria* gauss=NULL;
    50415094
     
    50745127}
    50755128/*}}}*/
    5076 /*FUNCTION Tria::GetSolutionFromInputsHydrology{{{1*/
     5129/*FUNCTION Tria::GetSolutionFromInputsHydrology{{{*/
    50775130void  Tria::GetSolutionFromInputsHydrology(Vector* solution){
    50785131
     
    50815134        int i;
    50825135        int*         doflist=NULL;
    5083         double       watercolumn;
    5084         double       values[numdof];
     5136        IssmDouble       watercolumn;
     5137        IssmDouble       values[numdof];
    50855138        GaussTria*   gauss=NULL;
    50865139
     
    51075160        /*Free ressources:*/
    51085161        delete gauss;
    5109         xfree((void**)&doflist);
    5110 }
    5111 /*}}}*/
    5112 /*FUNCTION Tria::InputUpdateFromSolutionHydrology{{{1*/
    5113 void  Tria::InputUpdateFromSolutionHydrology(double* solution){
     5162        xDelete<int>(doflist);
     5163}
     5164/*}}}*/
     5165/*FUNCTION Tria::InputUpdateFromSolutionHydrology{{{*/
     5166void  Tria::InputUpdateFromSolutionHydrology(IssmDouble* solution){
    51145167
    51155168        /*Intermediaries*/
     
    51185171        int       i;
    51195172        int*      doflist=NULL;
    5120         double    values[numdof];
     5173        IssmDouble    values[numdof];
    51215174
    51225175        /*Get dof list: */
     
    51265179        for(i=0;i<numdof;i++){
    51275180                values[i]=solution[doflist[i]];
    5128                 if(isnan(values[i])) _error_("NaN found in solution vector");
    5129                 if (values[i]<pow((double)10,(double)-10))values[i]=pow((double)10,(double)-10); //correcting the water column to positive values
     5181                if(xIsNan<IssmDouble>(values[i])) _error2_("NaN found in solution vector");
     5182                if (values[i]<pow((IssmDouble)10,(IssmDouble)-10))values[i]=pow((IssmDouble)10,(IssmDouble)-10); //correcting the water column to positive values
    51305183 
    51315184        }
     
    51355188
    51365189        /*Free ressources:*/
    5137         xfree((void**)&doflist);
     5190        xDelete<int>(doflist);
    51385191}
    51395192/*}}}*/
     
    51415194
    51425195#ifdef _HAVE_DAKOTA_
    5143 /*FUNCTION Tria::InputUpdateFromVectorDakota(double* vector, int name, int type);{{{1*/
    5144 void  Tria::InputUpdateFromVectorDakota(double* vector, int name, int type){
     5196/*FUNCTION Tria::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);{{{*/
     5197void  Tria::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){
    51455198       
    51465199        int i,j;
     
    51545207
    51555208                        /*New TriaP1Input*/
    5156                         double values[3];
     5209                        IssmDouble values[3];
    51575210
    51585211                        /*Get values on the 3 vertices*/
     
    51645217                        switch(name){
    51655218                                case ThicknessEnum:
    5166                                         /*Update thickness + surface: assume bed is constant. On ice shelves, takes hydrostatic equilibrium {{{2*/
    5167                                         double  thickness[3];
    5168                                         double  thickness_init[3];
    5169                                         double  hydrostatic_ratio[3];
    5170                                         double  surface[3];
    5171                                         double  bed[3];
     5219                                        IssmDouble  thickness[3];
     5220                                        IssmDouble  thickness_init[3];
     5221                                        IssmDouble  hydrostatic_ratio[3];
     5222                                        IssmDouble  surface[3];
     5223                                        IssmDouble  bed[3];
    51725224                                       
    51735225                                        /*retrieve inputs: */
     
    51775229                                        GetInputListOnVertices(&surface[0],SurfaceEnum);
    51785230
    5179                                         /*build new thickness: */
    5180 //                                      for(j=0;j<3;j++)thickness[j]=values[j];
    5181 
    51825231                                        /*build new bed and surface: */
    51835232                                        if (this->IsFloating()){
    51845233                                                /*hydrostatic equilibrium: */
    5185                                                 double rho_ice,rho_water,di;
    5186                                                 rho_ice=this->matpar->GetRhoIce();
    5187                                                 rho_water=this->matpar->GetRhoWater();
    5188 
    5189                                                 di=rho_ice/rho_water;
     5234                                                IssmDouble rho_ice,rho_water,di;
     5235                                                rho_ice   = this->matpar->GetRhoIce();
     5236                                                rho_water = this->matpar->GetRhoWater();
     5237                                                di        = rho_ice/rho_water;
    51905238
    51915239                                                /*build new thickness: */
    51925240                                                for (j=0; j<3; j++) {
    5193                                                 /*  for observed/interpolated/hydrostatic thickness, remove scaling from any hydrostatic thickness  */
    5194                                                         if     (hydrostatic_ratio[j] >= 0.)
     5241                                                        /*  for observed/interpolated/hydrostatic thickness, remove scaling from any hydrostatic thickness  */
     5242                                                        if (hydrostatic_ratio[j] >= 0.)
    51955243                                                                thickness[j]=values[j]-(values[j]/thickness_init[j]-1.)*hydrostatic_ratio[j]*surface[j]/(1.-di);
    5196                                                 /*  for minimum thickness, don't scale  */
     5244                                                        /*  for minimum thickness, don't scale  */
    51975245                                                        else
    51985246                                                                thickness[j]=thickness_init[j];
    51995247
    5200                                                 /*  check the computed thickness and update bed  */
    5201                                                         if (thickness[j] < 0.)
    5202                                                                 thickness[j]=1./(1.-di);
     5248                                                        /*  check the computed thickness and update bed*/
     5249                                                        if (thickness[j] < 0.) thickness[j]=1./(1.-di);
    52035250                                                        bed[j]=surface[j]-thickness[j];
    52045251                                                }
    5205 
    5206 //                                              for(j=0;j<3;j++){
    5207 //                                                      surface[j]=(1-di)*thickness[j];
    5208 //                                                      bed[j]=-di*thickness[j];
    5209 //                                              }
    52105252                                        }
    52115253                                        else{
    52125254                                                /*build new thickness: */
    52135255                                                for (j=0; j<3; j++) {
    5214                                                 /*  for observed thickness, use scaled value  */
     5256                                                        /*  for observed thickness, use scaled value  */
    52155257                                                        if (hydrostatic_ratio[j] >= 0.)
    52165258                                                                thickness[j]=values[j];
    5217                                                 /*  for minimum thickness, don't scale  */
     5259                                                        /*  for minimum thickness, don't scale  */
    52185260                                                        else
    52195261                                                                thickness[j]=thickness_init[j];
     
    52215263
    52225264                                                /*update bed on grounded ice: */
    5223 //                                              for(j=0;j<3;j++)surface[j]=bed[j]+thickness[j];
    52245265                                                for(j=0;j<3;j++)bed[j]=surface[j]-thickness[j];
    52255266                                        }
     
    52305271                                        this->inputs->AddInput(new TriaP1Input(SurfaceEnum,surface));
    52315272
    5232                                         /*}}}*/
    52335273                                        break;
    52345274                                default:
     
    52385278
    52395279                default:
    5240                         _error_("type %i (%s) not implemented yet",type,EnumToStringx(type));
    5241         }
    5242 
    5243 }
    5244 /*}}}*/
    5245 /*FUNCTION Tria::InputUpdateFromVectorDakota(int* vector, int name, int type);{{{1*/
     5280                        _error2_("type " << type << " (" << EnumToStringx(type) << ") not implemented yet");
     5281        }
     5282
     5283}
     5284/*}}}*/
     5285/*FUNCTION Tria::InputUpdateFromVectorDakota(int* vector, int name, int type);{{{*/
    52465286void  Tria::InputUpdateFromVectorDakota(int* vector, int name, int type){
    5247         _error_(" not supported yet!");
    5248 }
    5249 /*}}}*/
    5250 /*FUNCTION Tria::InputUpdateFromVectorDakota(bool* vector, int name, int type);{{{1*/
     5287        _error2_("not supported yet!");
     5288}
     5289/*}}}*/
     5290/*FUNCTION Tria::InputUpdateFromVectorDakota(bool* vector, int name, int type);{{{*/
    52515291void  Tria::InputUpdateFromVectorDakota(bool* vector, int name, int type){
    5252         _error_(" not supported yet!");
    5253 }
    5254 /*}}}*/
    5255 /*FUNCTION Tria::InputUpdateFromMatrixDakota(double* matrix, int nrows, int ncols, int name, int type);{{{1*/
    5256 void  Tria::InputUpdateFromMatrixDakota(double* matrix, int nrows, int ncols, int name, int type){
     5292        _error2_("not supported yet!");
     5293}
     5294/*}}}*/
     5295/*FUNCTION Tria::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type);{{{*/
     5296void  Tria::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type){
    52575297       
    52585298        int i,j,t;
    52595299        TransientInput* transientinput=NULL;
    5260         double values[3];
    5261         double time;
     5300        IssmDouble values[3];
     5301        IssmDouble time;
    52625302        int row;
    5263         double yts;
     5303        IssmDouble yts;
    52645304
    52655305        /*Check that name is an element input*/
     
    52785318                                for(i=0;i<3;i++){
    52795319                                        row=this->nodes[i]->GetSidList();
    5280                                         values[i]=(double)matrix[ncols*row+t];
     5320                                        values[i]=(IssmDouble)matrix[ncols*row+t];
    52815321                                }
    52825322
    52835323                                /*time? :*/
    5284                                 time=(double)matrix[(nrows-1)*ncols+t]*yts;
     5324                                time=(IssmDouble)matrix[(nrows-1)*ncols+t]*yts;
    52855325
    52865326                                if(t==0) transientinput=new TransientInput(name);
     
    52925332
    52935333                default:
    5294                         _error_("type %i (%s) not implemented yet",type,EnumToStringx(type));
     5334                        _error2_("type " << type << " (" << EnumToStringx(type) << ") not implemented yet");
    52955335        }
    52965336
     
    53005340
    53015341#ifdef _HAVE_BALANCED_
    5302 /*FUNCTION Tria::CreateKMatrixBalancethickness {{{1*/
     5342/*FUNCTION Tria::CreateKMatrixBalancethickness {{{*/
    53035343ElementMatrix* Tria::CreateKMatrixBalancethickness(void){
    53045344
     
    53095349                        return CreateKMatrixBalancethickness_DG();
    53105350                default:
    5311                         _error_("Element type %s not supported yet",EnumToStringx(GetElementType()));
    5312         }
    5313 
    5314 }
    5315 /*}}}*/
    5316 /*FUNCTION Tria::CreateKMatrixBalancethickness_CG {{{1*/
     5351                        _error2_("Element type " << EnumToStringx(GetElementType()) << " not supported yet");
     5352        }
     5353
     5354}
     5355/*}}}*/
     5356/*FUNCTION Tria::CreateKMatrixBalancethickness_CG {{{*/
    53175357ElementMatrix* Tria::CreateKMatrixBalancethickness_CG(void){
    53185358
     
    53235363        int        stabilization;
    53245364        int        i,j,ig,dim;
    5325         double     Jdettria,vx,vy,dvxdx,dvydy,vel,h;
    5326         double     dvx[2],dvy[2];
    5327         double     xyz_list[NUMVERTICES][3];
    5328         double     L[NUMVERTICES];
    5329         double     B[2][NUMVERTICES];
    5330         double     Bprime[2][NUMVERTICES];
    5331         double     K[2][2]                          = {0.0};
    5332         double     KDL[2][2]                        = {0.0};
    5333         double     DL[2][2]                         = {0.0};
    5334         double     DLprime[2][2]                    = {0.0};
    5335         double     DL_scalar;
     5365        IssmDouble     Jdettria,vx,vy,dvxdx,dvydy,vel,h;
     5366        IssmDouble     dvx[2],dvy[2];
     5367        IssmDouble     xyz_list[NUMVERTICES][3];
     5368        IssmDouble     L[NUMVERTICES];
     5369        IssmDouble     B[2][NUMVERTICES];
     5370        IssmDouble     Bprime[2][NUMVERTICES];
     5371        IssmDouble     K[2][2]                          = {0.0};
     5372        IssmDouble     KDL[2][2]                        = {0.0};
     5373        IssmDouble     DL[2][2]                         = {0.0};
     5374        IssmDouble     DLprime[2][2]                    = {0.0};
     5375        IssmDouble     DL_scalar;
    53365376        GaussTria *gauss                            = NULL;
    53375377
     
    54245464}
    54255465/*}}}*/
    5426 /*FUNCTION Tria::CreateKMatrixBalancethickness_DG {{{1*/
     5466/*FUNCTION Tria::CreateKMatrixBalancethickness_DG {{{*/
    54275467ElementMatrix* Tria::CreateKMatrixBalancethickness_DG(void){
    54285468
     
    54325472        /*Intermediaries*/
    54335473        int        i,j,ig,dim;
    5434         double     vx,vy,Jdettria;
    5435         double     xyz_list[NUMVERTICES][3];
    5436         double     B[2][NUMVERTICES];
    5437         double     Bprime[2][NUMVERTICES];
    5438         double     DL[2][2]={0.0};
    5439         double     DL_scalar;
     5474        IssmDouble     vx,vy,Jdettria;
     5475        IssmDouble     xyz_list[NUMVERTICES][3];
     5476        IssmDouble     B[2][NUMVERTICES];
     5477        IssmDouble     Bprime[2][NUMVERTICES];
     5478        IssmDouble     DL[2][2]={0.0};
     5479        IssmDouble     DL_scalar;
    54405480        GaussTria  *gauss=NULL;
    54415481
     
    54785518}
    54795519/*}}}*/
    5480 /*FUNCTION Tria::CreatePVectorBalancethickness{{{1*/
     5520/*FUNCTION Tria::CreatePVectorBalancethickness{{{*/
    54815521ElementVector* Tria::CreatePVectorBalancethickness(void){
    54825522
     
    54885528                        return CreatePVectorBalancethickness_DG();
    54895529                default:
    5490                         _error_("Element type %s not supported yet",EnumToStringx(GetElementType()));
    5491         }
    5492 }
    5493 /*}}}*/
    5494 /*FUNCTION Tria::CreatePVectorBalancethickness_CG{{{1*/
     5530                        _error2_("Element type " << EnumToStringx(GetElementType()) << " not supported yet");
     5531        }
     5532}
     5533/*}}}*/
     5534/*FUNCTION Tria::CreatePVectorBalancethickness_CG{{{*/
    54955535ElementVector* Tria::CreatePVectorBalancethickness_CG(void){
    54965536
     
    55005540        /*Intermediaries */
    55015541        int        i,j,ig;
    5502         double     xyz_list[NUMVERTICES][3];
    5503         double     dhdt_g,basal_melting_g,surface_mass_balance_g,Jdettria;
    5504         double     L[NUMVERTICES];
     5542        IssmDouble     xyz_list[NUMVERTICES][3];
     5543        IssmDouble     dhdt_g,basal_melting_g,surface_mass_balance_g,Jdettria;
     5544        IssmDouble     L[NUMVERTICES];
    55055545        GaussTria* gauss=NULL;
    55065546
     
    55355575}
    55365576/*}}}*/
    5537 /*FUNCTION Tria::CreatePVectorBalancethickness_DG {{{1*/
     5577/*FUNCTION Tria::CreatePVectorBalancethickness_DG {{{*/
    55385578ElementVector* Tria::CreatePVectorBalancethickness_DG(void){
    55395579
     
    55435583        /*Intermediaries */
    55445584        int        i,j,ig;
    5545         double     xyz_list[NUMVERTICES][3];
    5546         double     basal_melting_g,surface_mass_balance_g,dhdt_g,Jdettria;
    5547         double     L[NUMVERTICES];
     5585        IssmDouble     xyz_list[NUMVERTICES][3];
     5586        IssmDouble     basal_melting_g,surface_mass_balance_g,dhdt_g,Jdettria;
     5587        IssmDouble     L[NUMVERTICES];
    55485588        GaussTria* gauss=NULL;
    55495589
  • issm/trunk/src/c/objects/Elements/Tria.h

    r12630 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "./Element.h"
    1111#include "./TriaHook.h"
     
    4141                Results    *results;
    4242
    43                 /*Tria constructors, destructors {{{1*/
     43                /*Tria constructors, destructors {{{*/
    4444                Tria();
    4545                Tria(int tria_id,int tria_sid,int i, IoModel* iomodel,int nummodels);
    4646                ~Tria();
    4747                /*}}}*/
    48                 /*Object virtual functions definitions:{{{1 */
     48                /*Object virtual functions definitions:{{{ */
    4949                void  Echo();
    5050                void  DeepEcho();
     
    5454                Object* copy();
    5555                /*}}}*/
    56                 /*Update virtual functions resolution: {{{1*/
    57                 void  InputUpdateFromSolution(double* solutiong);
    58                 void  InputUpdateFromVector(double* vector, int name, int type);
     56                /*Update virtual functions resolution: {{{*/
     57                void  InputUpdateFromSolution(IssmDouble* solutiong);
     58                void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
    5959                void  InputUpdateFromVector(int* vector, int name, int type);
    6060                void  InputUpdateFromVector(bool* vector, int name, int type);
    6161                #ifdef _HAVE_DAKOTA_
    62                 void  InputUpdateFromVectorDakota(double* vector, int name, int type);
     62                void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
    6363                void  InputUpdateFromVectorDakota(int* vector, int name, int type);
    6464                void  InputUpdateFromVectorDakota(bool* vector, int name, int type);
    65                 void  InputUpdateFromMatrixDakota(double* matrix, int nows, int ncols, int name, int type);
    66                 #endif
    67                 void  InputUpdateFromConstant(double constant, int name);
     65                void  InputUpdateFromMatrixDakota(IssmDouble* matrix, int nows, int ncols, int name, int type);
     66                #endif
     67                void  InputUpdateFromConstant(IssmDouble constant, int name);
    6868                void  InputUpdateFromConstant(int constant, int name);
    6969                void  InputUpdateFromConstant(bool constant, int name);
    7070                void  InputUpdateFromIoModel(int index, IoModel* iomodel);
    7171                /*}}}*/
    72                 /*Element virtual functions definitions: {{{1*/
    73                 void   AverageOntoPartition(Vector* partition_contributions,Vector* partition_areas,double* vertex_response,double* qmu_part);
     72                /*Element virtual functions definitions: {{{*/
     73                void   AverageOntoPartition(Vector* partition_contributions,Vector* partition_areas,IssmDouble* vertex_response,IssmDouble* qmu_part);
    7474                void   ComputeBasalStress(Vector* sigma_b);
    7575                void   ComputeStrainRate(Vector* eps);
     
    8585                bool   IsFloating();
    8686                bool   IsNodeOnShelf();
    87                 bool   IsNodeOnShelfFromFlags(double* flags);
     87                bool   IsNodeOnShelfFromFlags(IssmDouble* flags);
    8888                bool   IsOnWater();
    8989                void   GetSolutionFromInputs(Vector* solution);
    9090                void   GetVectorFromInputs(Vector* vector, int name_enum);
    9191                void   GetVectorFromResults(Vector* vector,int offset,int enum_in,int interp);
    92                 void   InputArtificialNoise(int enum_type,double min, double max);
    93                 bool   InputConvergence(double* eps, int* enums,int num_enums,int* criterionenums,double* criterionvalues,int num_criterionenums);
    94                 void   InputCreate(double scalar,int name,int code);
    95                 void   InputCreate(double* vector, int index,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code);
     92                void   InputArtificialNoise(int enum_type,IssmDouble min, IssmDouble max);
     93                bool   InputConvergence(IssmDouble* eps, int* enums,int num_enums,int* criterionenums,IssmDouble* criterionvalues,int num_criterionenums);
     94                void   InputCreate(IssmDouble scalar,int name,int code);
     95                void   InputCreate(IssmDouble* vector, int index,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code);
    9696                void   InputDepthAverageAtBase(int enum_type,int average_enum_type,int object_enum=MeshElementsEnum);
    9797                void   InputDuplicate(int original_enum,int new_enum);
    98                 void   InputScale(int enum_type,double scale_factor);
    99                 void   InputToResult(int enum_type,int step,double time);
     98                void   InputScale(int enum_type,IssmDouble scale_factor);
     99                void   InputToResult(int enum_type,int step,IssmDouble time);
    100100                void   DeleteResults(void);
    101                 void   MaterialUpdateFromTemperature(void){_error_("not implemented yet");};
    102                 void   MigrateGroundingLine(double* oldfloating,double* sheet_ungrounding);
    103                 int    NodalValue(double* pvalue, int index, int natureofdataenum,bool process_units);
     101                void   MaterialUpdateFromTemperature(void){_error2_("not implemented yet");};
     102                void   MigrateGroundingLine(IssmDouble* oldfloating,IssmDouble* sheet_ungrounding);
     103                int    NodalValue(IssmDouble* pvalue, int index, int natureofdataenum,bool process_units);
    104104                void   PotentialSheetUngrounding(Vector* potential_sheet_ungrounding);
    105                 void   PositiveDegreeDay(double* pdds,double* pds,double signorm);
    106                 void   RequestedOutput(int output_enum,int step,double time);
    107                 void   ListResultsInfo(int** results_enums,int** results_size,double** results_times,int** results_steps,int* num_results);
     105                void   PositiveDegreeDay(IssmDouble* pdds,IssmDouble* pds,IssmDouble signorm);
     106                void   RequestedOutput(int output_enum,int step,IssmDouble time);
     107                void   ListResultsInfo(int** results_enums,int** results_size,IssmDouble** results_times,int** results_steps,int* num_results);
    108108                void   PatchFill(int* pcount, Patch* patch);
    109109                void   PatchSize(int* pnumrows, int* pnumvertices,int* pnumnodes);
    110110                void   ProcessResultsUnits(void);
    111                 void   ResetCoordinateSystem(void){_error_("not implemented yet");};
    112                 double SurfaceArea(void);
     111                void   ResetCoordinateSystem(void){_error2_("not implemented yet");};
     112                void     SmbGradients();
     113                IssmDouble SurfaceArea(void);
    113114                void   Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type);
    114                 int    UpdatePotentialSheetUngrounding(double* vertices_potentially_ungrounding,Vector* vec_nodes_on_iceshelf,double* nodes_on_iceshelf);
    115                 double TimeAdapt();
     115                int    UpdatePotentialSheetUngrounding(IssmDouble* vertices_potentially_ungrounding,Vector* vec_nodes_on_iceshelf,IssmDouble* nodes_on_iceshelf);
     116                IssmDouble TimeAdapt();
    116117                int*   GetHorizontalNeighboorSids(void);
    117                 void   SmearFunction(Vector* smearedvector,double (*WeightFunction)(double distance,double radius),double radius);
     118                void   SmearFunction(Vector* smearedvector,IssmDouble (*WeightFunction)(IssmDouble distance,IssmDouble radius),IssmDouble radius);
    118119
    119120                #ifdef _HAVE_RESPONSES_
    120                 double IceVolume(void);
    121                 void   MinVel(double* pminvel, bool process_units);
    122                 void   MinVx(double* pminvx, bool process_units);
    123                 void   MinVy(double* pminvy, bool process_units);
    124                 void   MinVz(double* pminvz, bool process_units);
    125                 double MassFlux(double* segment,bool process_units);
    126                 void   MaxAbsVx(double* pmaxabsvx, bool process_units);
    127                 void   MaxAbsVy(double* pmaxabsvy, bool process_units);
    128                 void   MaxAbsVz(double* pmaxabsvz, bool process_units);
    129                 void   ElementResponse(double* presponse,int response_enum,bool process_units);
    130                 void   MaxVel(double* pmaxvel, bool process_units);
    131                 void   MaxVx(double* pmaxvx, bool process_units);
    132                 void   MaxVy(double* pmaxvy, bool process_units);
    133                 void   MaxVz(double* pmaxvz, bool process_units);
     121                IssmDouble IceVolume(void);
     122                void   MinVel(IssmDouble* pminvel, bool process_units);
     123                void   MinVx(IssmDouble* pminvx, bool process_units);
     124                void   MinVy(IssmDouble* pminvy, bool process_units);
     125                void   MinVz(IssmDouble* pminvz, bool process_units);
     126                IssmDouble MassFlux(IssmDouble* segment,bool process_units);
     127                void   MaxAbsVx(IssmDouble* pmaxabsvx, bool process_units);
     128                void   MaxAbsVy(IssmDouble* pmaxabsvy, bool process_units);
     129                void   MaxAbsVz(IssmDouble* pmaxabsvz, bool process_units);
     130                void   ElementResponse(IssmDouble* presponse,int response_enum,bool process_units);
     131                void   MaxVel(IssmDouble* pmaxvel, bool process_units);
     132                void   MaxVx(IssmDouble* pmaxvx, bool process_units);
     133                void   MaxVy(IssmDouble* pmaxvy, bool process_units);
     134                void   MaxVz(IssmDouble* pmaxvz, bool process_units);
    134135                #endif
    135136
    136137
    137138                #ifdef _HAVE_CONTROL_
    138                 double DragCoefficientAbsGradient(bool process_units,int weight_index);
     139                IssmDouble DragCoefficientAbsGradient(bool process_units,int weight_index);
    139140                void   GradientIndexing(int* indexing,int control_index);
    140141                void   Gradj(Vector* gradient,int control_type,int control_index);
     
    148149                void   GradjVyBalancedthickness(Vector* gradient,int control_index);
    149150                void   GetVectorFromControlInputs(Vector* gradient,int control_enum,int control_index,const char* data);
    150                 void   SetControlInputsFromVector(double* vector,int control_enum,int control_index);
     151                void   SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index);
    151152                void   ControlInputGetGradient(Vector* gradient,int enum_type,int control_index);
    152                 void   ControlInputScaleGradient(int enum_type,double scale);
    153                 void   ControlInputSetGradient(double* gradient,int enum_type,int control_index);
    154                 double RheologyBbarAbsGradient(bool process_units,int weight_index);
    155                 double ThicknessAbsMisfit(     bool process_units,int weight_index);
    156                 double SurfaceAbsVelMisfit(    bool process_units,int weight_index);
    157                 double ThicknessAbsGradient(bool process_units,int weight_index);
    158                 double SurfaceRelVelMisfit(    bool process_units,int weight_index);
    159                 double SurfaceLogVelMisfit(    bool process_units,int weight_index);
    160                 double SurfaceLogVxVyMisfit(   bool process_units,int weight_index);
    161                 double SurfaceAverageVelMisfit(bool process_units,int weight_index);
    162                 void   InputControlUpdate(double scalar,bool save_parameter);
    163                 #endif
    164 
    165                 /*}}}*/
    166                 /*Tria specific routines:{{{1*/
     153                void   ControlInputScaleGradient(int enum_type,IssmDouble scale);
     154                void   ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index);
     155                IssmDouble RheologyBbarAbsGradient(bool process_units,int weight_index);
     156                IssmDouble ThicknessAbsMisfit(     bool process_units,int weight_index);
     157                IssmDouble SurfaceAbsVelMisfit(    bool process_units,int weight_index);
     158                IssmDouble ThicknessAbsGradient(bool process_units,int weight_index);
     159                IssmDouble SurfaceRelVelMisfit(    bool process_units,int weight_index);
     160                IssmDouble SurfaceLogVelMisfit(    bool process_units,int weight_index);
     161                IssmDouble SurfaceLogVxVyMisfit(   bool process_units,int weight_index);
     162                IssmDouble SurfaceAverageVelMisfit(bool process_units,int weight_index);
     163                void   InputControlUpdate(IssmDouble scalar,bool save_parameter);
     164                #endif
     165
     166                /*}}}*/
     167                /*Tria specific routines:{{{*/
    167168                ElementMatrix* CreateKMatrixBalancethickness(void);
    168169                ElementMatrix* CreateKMatrixBalancethickness_DG(void);
     
    180181                ElementVector* CreatePVectorPrognostic_DG(void);
    181182                ElementVector* CreatePVectorSlope(void);
    182                 double         GetArea(void);
     183                IssmDouble         GetArea(void);
    183184                int            GetElementType(void);
    184185                void             GetDofList(int** pdoflist,int approximation_enum,int setenum);
     
    186187                void           GetSidList(int* sidlist);
    187188                void           GetConnectivityList(int* connectivity);
    188                 void           GetInputListOnVertices(double* pvalue,int enumtype);
    189                 void           GetInputListOnVertices(double* pvalue,int enumtype,double defaultvalue);
    190                 void           GetInputListOnVertices(double* pvalue,int enumtype,double defaultvalue,int index); //TO BE REMOVED
    191                 void           GetInputValue(double* pvalue,Node* node,int enumtype);
    192                 void           GetStrainRate2d(double* epsilon,double* xyz_list, GaussTria* gauss, Input* vx_input, Input* vy_input);
    193                 void             InputUpdateFromSolutionOneDof(double* solution,int enum_type);
    194                 void             InputUpdateFromSolutionPrognostic(double* solution);
     189                void           GetInputListOnVertices(IssmDouble* pvalue,int enumtype);
     190                void           GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue);
     191                void           GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue,int index); //TO BE REMOVED
     192                void           GetInputValue(IssmDouble* pvalue,Node* node,int enumtype);
     193                void           GetStrainRate2d(IssmDouble* epsilon,IssmDouble* xyz_list, GaussTria* gauss, Input* vx_input, Input* vy_input);
     194                void             InputUpdateFromSolutionOneDof(IssmDouble* solution,int enum_type);
     195                void             InputUpdateFromSolutionPrognostic(IssmDouble* solution);
    195196                bool             IsInput(int name);
    196197                void             SetClone(int* minranks);
    197                 void             SurfaceNormal(double* surface_normal, double xyz_list[3][3]);
     198                void             SurfaceNormal(IssmDouble* surface_normal, IssmDouble xyz_list[3][3]);
    198199               
    199200                #ifdef _HAVE_DIAGNOSTIC_
     
    207208                void      GetSolutionFromInputsDiagnosticHoriz(Vector* solution);
    208209                void      GetSolutionFromInputsDiagnosticHutter(Vector* solution);
    209                 void      InputUpdateFromSolutionDiagnosticHoriz( double* solution);
    210                 void      InputUpdateFromSolutionDiagnosticHutter( double* solution);
     210                void      InputUpdateFromSolutionDiagnosticHoriz( IssmDouble* solution);
     211                void      InputUpdateFromSolutionDiagnosticHutter( IssmDouble* solution);
    211212                #endif
    212213
     
    217218                ElementVector* CreatePVectorAdjointStokes(void);
    218219                ElementVector* CreatePVectorAdjointBalancethickness(void);
    219                 void      InputUpdateFromSolutionAdjointBalancethickness( double* solution);
    220                 void      InputUpdateFromSolutionAdjointHoriz( double* solution);
     220                void      InputUpdateFromSolutionAdjointBalancethickness( IssmDouble* solution);
     221                void      InputUpdateFromSolutionAdjointHoriz( IssmDouble* solution);
    221222                #endif
    222223
     
    226227                void      CreateHydrologyWaterVelocityInput(void);
    227228                void      GetSolutionFromInputsHydrology(Vector* solution);
    228                 void      InputUpdateFromSolutionHydrology(double* solution);
     229                void      InputUpdateFromSolutionHydrology(IssmDouble* solution);
    229230                #endif
    230231                #ifdef _HAVE_BALANCED_
  • issm/trunk/src/c/objects/Elements/TriaHook.cpp

    r9725 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*Object constructors and destructor*/
    23 /*FUNCTION TriaHook::TriaHook(){{{1*/
     23/*FUNCTION TriaHook::TriaHook(){{{*/
    2424TriaHook::TriaHook(){
    2525        numanalyses=UNDEF;
     
    2929}
    3030/*}}}*/
    31 /*FUNCTION TriaHook::~TriaHook(){{{1*/
     31/*FUNCTION TriaHook::~TriaHook(){{{*/
    3232TriaHook::~TriaHook(){
    3333        int i;
     
    4242}
    4343/*}}}*/
    44 /*FUNCTION TriaHook::TriaHook(int in_numanalyses,int matice_id, int matpar_id){{{1*/
     44/*FUNCTION TriaHook::TriaHook(int in_numanalyses,int matice_id, int matpar_id){{{*/
    4545TriaHook::TriaHook(int in_numanalyses,int matice_id, IoModel* iomodel){
    4646
     
    6464/*}}}*/
    6565
    66 /*FUNCTION TriaHook::SetHookNodes{{{1*/
     66/*FUNCTION TriaHook::SetHookNodes{{{*/
    6767void TriaHook::SetHookNodes(int* node_ids,int analysis_counter){
    6868
  • issm/trunk/src/c/objects/Elements/TriaHook.h

    r9356 r12706  
    1818
    1919
    20                 /*FUNCTION constructors, destructors {{{1*/
     20                /*FUNCTION constructors, destructors {{{*/
    2121                TriaHook();
    2222                TriaHook(int in_numanalyses,int matice_id, IoModel* iomodel);
  • issm/trunk/src/c/objects/Elements/TriaRef.cpp

    r10135 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2424
    2525/*Object constructors and destructor*/
    26 /*FUNCTION TriaRef::TriaRef(){{{1*/
     26/*FUNCTION TriaRef::TriaRef(){{{*/
    2727TriaRef::TriaRef(){
    2828        this->element_type_list=NULL;
    2929}
    3030/*}}}*/
    31 /*FUNCTION TriaRef::TriaRef(int* types,int nummodels){{{1*/
     31/*FUNCTION TriaRef::TriaRef(int* types,int nummodels){{{*/
    3232
    3333TriaRef::TriaRef(const int nummodels){
    3434
    3535        /*Only allocate pointer*/
    36         element_type_list=(int*)xmalloc(nummodels*sizeof(int));
    37 
    38 }
    39 /*}}}*/
    40 /*FUNCTION TriaRef::~TriaRef(){{{1*/
     36        element_type_list=xNew<int>(nummodels);
     37
     38}
     39/*}}}*/
     40/*FUNCTION TriaRef::~TriaRef(){{{*/
    4141TriaRef::~TriaRef(){
    42         xfree((void**)&element_type_list);
     42        xDelete<int>(element_type_list);
    4343}
    4444/*}}}*/
    4545
    4646/*Management*/
    47 /*FUNCTION TriaRef::SetElementType{{{1*/
     47/*FUNCTION TriaRef::SetElementType{{{*/
    4848void TriaRef::SetElementType(int type,int type_counter){
    4949
     
    5656
    5757/*Reference Element numerics*/
    58 /*FUNCTION TriaRef::GetBMacAyeal {{{1*/
    59 void TriaRef::GetBMacAyeal(double* B, double* xyz_list, GaussTria* gauss){
     58/*FUNCTION TriaRef::GetBMacAyeal {{{*/
     59void TriaRef::GetBMacAyeal(IssmDouble* B, IssmDouble* xyz_list, GaussTria* gauss){
    6060        /*Compute B  matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2.
    6161         * For node i, Bi can be expressed in the actual coordinate system
     
    7070
    7171        int i;
    72         double dbasis[NDOF2][NUMNODES];
     72        IssmDouble dbasis[NDOF2][NUMNODES];
    7373
    7474        /*Get dh1dh2dh3 in actual coordinate system: */
     
    8686}
    8787/*}}}*/
    88 /*FUNCTION TriaRef::GetBMacAyealStokes {{{1*/
    89 void TriaRef::GetBMacAyealStokes(double* B, double* xyz_list, GaussTria* gauss){
     88/*FUNCTION TriaRef::GetBMacAyealStokes {{{*/
     89void TriaRef::GetBMacAyealStokes(IssmDouble* B, IssmDouble* xyz_list, GaussTria* gauss){
    9090
    9191        /*Compute B  matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2.
     
    101101
    102102        /*Same thing in the actual coordinate system: */
    103         double dbasis[NDOF2][NUMNODES];
     103        IssmDouble dbasis[NDOF2][NUMNODES];
    104104
    105105        /*Get dh1dh2dh3 in actual coordinates system : */
     
    117117}
    118118/*}}}*/
    119 /*FUNCTION TriaRef::GetSegmentBFlux{{{1*/
    120 void TriaRef::GetSegmentBFlux(double* B,GaussTria* gauss, int index1,int index2){
     119/*FUNCTION TriaRef::GetSegmentBFlux{{{*/
     120void TriaRef::GetSegmentBFlux(IssmDouble* B,GaussTria* gauss, int index1,int index2){
    121121        /*Compute B  matrix. B=[phi1 phi2 -phi3 -phi4]
    122122         *
     
    126126         */
    127127
    128         double l1l3[NUMNODES];
     128        IssmDouble l1l3[NUMNODES];
    129129
    130130        GetNodalFunctions(&l1l3[0],gauss);
     
    136136}
    137137/*}}}*/
    138 /*FUNCTION TriaRef::GetSegmentBprimeFlux{{{1*/
    139 void TriaRef::GetSegmentBprimeFlux(double* Bprime,GaussTria* gauss, int index1,int index2){
     138/*FUNCTION TriaRef::GetSegmentBprimeFlux{{{*/
     139void TriaRef::GetSegmentBprimeFlux(IssmDouble* Bprime,GaussTria* gauss, int index1,int index2){
    140140        /*Compute Bprime  matrix. Bprime=[phi1 phi2 phi3 phi4]
    141141         *
     
    145145         */
    146146
    147         double l1l3[NUMNODES];
     147        IssmDouble l1l3[NUMNODES];
    148148
    149149        GetNodalFunctions(&l1l3[0],gauss);
     
    155155}
    156156/*}}}*/
    157 /*FUNCTION TriaRef::GetBPrognostic{{{1*/
    158 void TriaRef::GetBPrognostic(double* B_prog, double* xyz_list, GaussTria* gauss){
     157/*FUNCTION TriaRef::GetBPrognostic{{{*/
     158void TriaRef::GetBPrognostic(IssmDouble* B_prog, IssmDouble* xyz_list, GaussTria* gauss){
    159159        /*Compute B  matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2.
    160160         * For node i, Bi can be expressed in the actual coordinate system
     
    167167         */
    168168
    169         double basis[NUMNODES];
     169        IssmDouble basis[NUMNODES];
    170170
    171171        /*Get dh1dh2dh3 in actual coordinate system: */
     
    179179}
    180180/*}}}*/
    181 /*FUNCTION TriaRef::GetBprimeMacAyeal {{{1*/
    182 void TriaRef::GetBprimeMacAyeal(double* Bprime, double* xyz_list, GaussTria* gauss){
     181/*FUNCTION TriaRef::GetBprimeMacAyeal {{{*/
     182void TriaRef::GetBprimeMacAyeal(IssmDouble* Bprime, IssmDouble* xyz_list, GaussTria* gauss){
    183183
    184184        /*Compute B'  matrix. B'=[B1' B2' B3'] where Bi' is of size 3*NDOF2.
     
    194194
    195195        /*Same thing in the actual coordinate system: */
    196         double dbasis[NDOF2][NUMNODES];
     196        IssmDouble dbasis[NDOF2][NUMNODES];
    197197
    198198        /*Get dh1dh2dh3 in actual coordinates system : */
     
    210210}
    211211/*}}}*/
    212 /*FUNCTION TriaRef::GetBprimeMacAyealStokes {{{1*/
    213 void TriaRef::GetBprimeMacAyealStokes(double* Bprime, double* xyz_list, GaussTria* gauss){
     212/*FUNCTION TriaRef::GetBprimeMacAyealStokes {{{*/
     213void TriaRef::GetBprimeMacAyealStokes(IssmDouble* Bprime, IssmDouble* xyz_list, GaussTria* gauss){
    214214
    215215        /*Compute Bprime  matrix. Bprime=[Bprime1 Bprime2 Bprime3] where Bprimei is of size 3*NDOF2.
     
    226226
    227227        /*Same thing in the actual coordinate system: */
    228         double dbasis[NDOF2][NUMNODES];
     228        IssmDouble dbasis[NDOF2][NUMNODES];
    229229
    230230        /*Get dh1dh2dh3 in actual coordinates system : */
     
    244244}
    245245/*}}}*/
    246 /*FUNCTION TriaRef::GetBprimePrognostic{{{1*/
    247 void TriaRef::GetBprimePrognostic(double* Bprime_prog, double* xyz_list, GaussTria* gauss){
     246/*FUNCTION TriaRef::GetBprimePrognostic{{{*/
     247void TriaRef::GetBprimePrognostic(IssmDouble* Bprime_prog, IssmDouble* xyz_list, GaussTria* gauss){
    248248        /*Compute B'  matrix. B'=[B1' B2' B3'] where Bi' is of size 3*NDOF2.
    249249         * For node i, Bi' can be expressed in the actual coordinate system
     
    257257
    258258        /*Same thing in the actual coordinate system: */
    259         double dbasis[NDOF2][NUMNODES];
     259        IssmDouble dbasis[NDOF2][NUMNODES];
    260260
    261261        /*Get dh1dh2dh3 in actual coordinates system : */
     
    269269}
    270270/*}}}*/
    271 /*FUNCTION TriaRef::GetL{{{1*/
    272 void TriaRef::GetL(double* L, double* xyz_list,GaussTria* gauss,int numdof){
     271/*FUNCTION TriaRef::GetL{{{*/
     272void TriaRef::GetL(IssmDouble* L, IssmDouble* xyz_list,GaussTria* gauss,int numdof){
    273273        /*Compute L  matrix. L=[L1 L2 L3] where Li is square and of size numdof.
    274274         * For node i, Li can be expressed in the actual coordinate system
     
    285285
    286286        int i;
    287         double basis[3];
     287        IssmDouble basis[3];
    288288
    289289        /*Get basis in actual coordinate system: */
     
    306306}
    307307/*}}}*/
    308 /*FUNCTION TriaRef::GetJacobian{{{1*/
    309 void TriaRef::GetJacobian(double* J, double* xyz_list,GaussTria* gauss){
     308/*FUNCTION TriaRef::GetJacobian{{{*/
     309void TriaRef::GetJacobian(IssmDouble* J, IssmDouble* xyz_list,GaussTria* gauss){
    310310        /*The Jacobian is constant over the element, discard the gaussian points.
    311311         * J is assumed to have been allocated of size NDOF2xNDOF2.*/
    312         double x1,y1,x2,y2,x3,y3;
     312        IssmDouble x1,y1,x2,y2,x3,y3;
    313313
    314314        x1=*(xyz_list+NUMNODES*0+0);
     
    326326}
    327327/*}}}*/
    328 /*FUNCTION TriaRef::GetSegmentJacobianDeterminant{{{1*/
    329 void TriaRef::GetSegmentJacobianDeterminant(double* Jdet, double* xyz_list,GaussTria* gauss){
     328/*FUNCTION TriaRef::GetSegmentJacobianDeterminant{{{*/
     329void TriaRef::GetSegmentJacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,GaussTria* gauss){
    330330        /*The Jacobian determinant is constant over the element, discard the gaussian points.
    331331         * J is assumed to have been allocated*/
    332         double x1,y1,x2,y2;
     332        IssmDouble x1,y1,x2,y2;
    333333
    334334        x1=*(xyz_list+3*0+0);
     
    338338
    339339        *Jdet=1.0/2.0*sqrt(pow(x2-x1,2.) + pow(y2-y1,2.));
    340         if(*Jdet<0) _error_("negative jacobian determinant!");
    341 
    342 }
    343 /*}}}*/
    344 /*FUNCTION TriaRef::GetJacobianDeterminant2d{{{1*/
    345 void TriaRef::GetJacobianDeterminant2d(double* Jdet, double* xyz_list,GaussTria* gauss){
     340        if(*Jdet<0) _error2_("negative jacobian determinant!");
     341
     342}
     343/*}}}*/
     344/*FUNCTION TriaRef::GetJacobianDeterminant2d{{{*/
     345void TriaRef::GetJacobianDeterminant2d(IssmDouble* Jdet, IssmDouble* xyz_list,GaussTria* gauss){
    346346        /*The Jacobian determinant is constant over the element, discard the gaussian points.
    347347         * J is assumed to have been allocated of size NDOF2xNDOF2.*/
    348         double J[2][2];
     348        IssmDouble J[2][2];
    349349
    350350        /*Get Jacobian*/
     
    353353        /*Get Determinant*/
    354354        Matrix2x2Determinant(Jdet,&J[0][0]);
    355         if(*Jdet<0) _error_("negative jacobian determinant!");
    356 
    357 }
    358 /*}}}*/
    359 /*FUNCTION TriaRef::GetJacobianDeterminant3d {{{1*/
    360 void TriaRef::GetJacobianDeterminant3d(double*  Jdet, double* xyz_list,GaussTria* gauss){
     355        if(*Jdet<0) _error2_("negative jacobian determinant!");
     356
     357}
     358/*}}}*/
     359/*FUNCTION TriaRef::GetJacobianDeterminant3d {{{*/
     360void TriaRef::GetJacobianDeterminant3d(IssmDouble*  Jdet, IssmDouble* xyz_list,GaussTria* gauss){
    361361        /*The Jacobian determinant is constant over the element, discard the gaussian points.
    362362         * J is assumed to have been allocated of size NDOF2xNDOF2.*/
    363363
    364         double x1,x2,x3,y1,y2,y3,z1,z2,z3;
     364        IssmDouble x1,x2,x3,y1,y2,y3,z1,z2,z3;
    365365
    366366        x1=*(xyz_list+3*0+0);
     
    375375
    376376        *Jdet=SQRT3/6.0*pow(pow(((y2-y1)*(z3-z1)-(z2-z1)*(y3-y1)),2.0)+pow(((z2-z1)*(x3-x1)-(x2-x1)*(z3-z1)),2.0)+pow(((x2-x1)*(y3-y1)-(y2-y1)*(x3-x1)),2.0),0.5);
    377         if(*Jdet<0) _error_("negative jacobian determinant!");
    378 
    379 }
    380 /*}}}*/
    381 /*FUNCTION TriaRef::GetJacobianInvert{{{1*/
    382 void TriaRef::GetJacobianInvert(double*  Jinv, double* xyz_list,GaussTria* gauss){
     377        if(*Jdet<0) _error2_("negative jacobian determinant!");
     378
     379}
     380/*}}}*/
     381/*FUNCTION TriaRef::GetJacobianInvert{{{*/
     382void TriaRef::GetJacobianInvert(IssmDouble*  Jinv, IssmDouble* xyz_list,GaussTria* gauss){
    383383
    384384        /*Jacobian*/
    385         double J[2][2];
     385        IssmDouble J[2][2];
    386386
    387387        /*Call Jacobian routine to get the jacobian:*/
     
    393393}
    394394/*}}}*/
    395 /*FUNCTION TriaRef::GetNodalFunctions{{{1*/
    396 void TriaRef::GetNodalFunctions(double* basis,GaussTria* gauss){
     395/*FUNCTION TriaRef::GetNodalFunctions{{{*/
     396void TriaRef::GetNodalFunctions(IssmDouble* basis,GaussTria* gauss){
    397397        /*This routine returns the values of the nodal functions  at the gaussian point.*/
    398398
     
    403403}
    404404/*}}}*/
    405 /*FUNCTION TriaRef::GetSegmentNodalFunctions{{{1*/
    406 void TriaRef::GetSegmentNodalFunctions(double* basis,GaussTria* gauss,int index1,int index2){
     405/*FUNCTION TriaRef::GetSegmentNodalFunctions{{{*/
     406void TriaRef::GetSegmentNodalFunctions(IssmDouble* basis,GaussTria* gauss,int index1,int index2){
    407407        /*This routine returns the values of the nodal functions  at the gaussian point.*/
    408408
    409         double BasisFunctions[3];
     409        IssmDouble BasisFunctions[3];
    410410
    411411        GetNodalFunctions(&BasisFunctions[0],gauss);
     
    417417}
    418418/*}}}*/
    419 /*FUNCTION TriaRef::GetNodalFunctionsDerivatives{{{1*/
    420 void TriaRef::GetNodalFunctionsDerivatives(double* dbasis,double* xyz_list, GaussTria* gauss){
     419/*FUNCTION TriaRef::GetNodalFunctionsDerivatives{{{*/
     420void TriaRef::GetNodalFunctionsDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list, GaussTria* gauss){
    421421
    422422        /*This routine returns the values of the nodal functions derivatives  (with respect to the
    423423         * actual coordinate system): */
    424424        int       i;
    425         double    dbasis_ref[NDOF2][NUMNODES];
    426         double    Jinv[NDOF2][NDOF2];
     425        IssmDouble    dbasis_ref[NDOF2][NUMNODES];
     426        IssmDouble    Jinv[NDOF2][NDOF2];
    427427
    428428        /*Get derivative values with respect to parametric coordinate system: */
     
    444444}
    445445/*}}}*/
    446 /*FUNCTION TriaRef::GetNodalFunctionsDerivativesReference{{{1*/
    447 void TriaRef::GetNodalFunctionsDerivativesReference(double* dl1dl3,GaussTria* gauss){
     446/*FUNCTION TriaRef::GetNodalFunctionsDerivativesReference{{{*/
     447void TriaRef::GetNodalFunctionsDerivativesReference(IssmDouble* dl1dl3,GaussTria* gauss){
    448448        /*This routine returns the values of the nodal functions derivatives  (with respect to the
    449449         * natural coordinate system) at the gaussian point. */
     
    463463}
    464464/*}}}*/
    465 /*FUNCTION TriaRef::GetInputDerivativeValue{{{1*/
    466 void TriaRef::GetInputDerivativeValue(double* p, double* plist,double* xyz_list, GaussTria* gauss){
     465/*FUNCTION TriaRef::GetInputDerivativeValue{{{*/
     466void TriaRef::GetInputDerivativeValue(IssmDouble* p, IssmDouble* plist,IssmDouble* xyz_list, GaussTria* gauss){
    467467
    468468        /*From node values of parameter p (plist[0],plist[1],plist[2]), return parameter derivative value at gaussian
     
    475475
    476476        /*Nodal Derivatives*/
    477         double dbasis[2][3]; //nodal derivative functions in actual coordinate system.
     477        IssmDouble dbasis[2][3]; //nodal derivative functions in actual coordinate system.
    478478
    479479        /*Get dh1dh2dh3 in actual coordinate system: */
     
    486486}
    487487/*}}}*/
    488 /*FUNCTION TriaRef::GetInputValue{{{1*/
    489 void TriaRef::GetInputValue(double* p, double* plist, GaussTria* gauss){
     488/*FUNCTION TriaRef::GetInputValue{{{*/
     489void TriaRef::GetInputValue(IssmDouble* p, IssmDouble* plist, GaussTria* gauss){
    490490
    491491        /*From node values of parameter p (plist[0],plist[1],plist[2]), return parameter value at gaussian
     
    493493
    494494        /*nodal functions annd output: */
    495         double basis[3];
     495        IssmDouble basis[3];
    496496
    497497        /*Get nodal functions*/
  • issm/trunk/src/c/objects/Elements/TriaRef.h

    r10135 r12706  
    2525
    2626                /*Numerics*/
    27                 void GetBMacAyeal(double* B, double* xyz_list, GaussTria* gauss);
    28                 void GetBMacAyealStokes(double* B , double* xyz_list, GaussTria* gauss);
    29                 void GetBprimeMacAyeal(double* Bprime, double* xyz_list, GaussTria* gauss);
    30                 void GetBprimeMacAyealStokes(double* Bprime, double* xyz_list, GaussTria* gauss);
    31                 void GetBprimePrognostic(double* Bprime_prog, double* xyz_list, GaussTria* gauss);
    32                 void GetBPrognostic(double* B_prog, double* xyz_list, GaussTria* gauss);
    33                 void GetL(double* L, double* xyz_list,GaussTria* gauss,int numdof);
    34                 void GetJacobian(double* J, double* xyz_list,GaussTria* gauss);
    35                 void GetSegmentJacobianDeterminant(double* Jdet, double* xyz_list,GaussTria* gauss);
    36                 void GetJacobianDeterminant2d(double* Jdet, double* xyz_list,GaussTria* gauss);
    37                 void GetJacobianDeterminant3d(double* Jdet, double* xyz_list,GaussTria* gauss);
    38                 void GetJacobianInvert(double*  Jinv, double* xyz_list,GaussTria* gauss);
    39                 void GetNodalFunctions(double* l1l2l3,GaussTria* gauss);
    40                 void GetSegmentNodalFunctions(double* l1l2l3,GaussTria* gauss, int index1,int index2);
    41                 void GetSegmentBFlux(double* B,GaussTria* gauss, int index1,int index2);
    42                 void GetSegmentBprimeFlux(double* Bprime,GaussTria* gauss, int index1,int index2);
    43                 void GetNodalFunctionsDerivatives(double* l1l2l3,double* xyz_list, GaussTria* gauss);
    44                 void GetNodalFunctionsDerivativesReference(double* dl1dl3,GaussTria* gauss);
    45                 void GetInputValue(double* pp, double* plist, GaussTria* gauss);
    46                 void GetInputDerivativeValue(double* pp, double* plist,double* xyz_list, GaussTria* gauss);
     27                void GetBMacAyeal(IssmDouble* B, IssmDouble* xyz_list, GaussTria* gauss);
     28                void GetBMacAyealStokes(IssmDouble* B , IssmDouble* xyz_list, GaussTria* gauss);
     29                void GetBprimeMacAyeal(IssmDouble* Bprime, IssmDouble* xyz_list, GaussTria* gauss);
     30                void GetBprimeMacAyealStokes(IssmDouble* Bprime, IssmDouble* xyz_list, GaussTria* gauss);
     31                void GetBprimePrognostic(IssmDouble* Bprime_prog, IssmDouble* xyz_list, GaussTria* gauss);
     32                void GetBPrognostic(IssmDouble* B_prog, IssmDouble* xyz_list, GaussTria* gauss);
     33                void GetL(IssmDouble* L, IssmDouble* xyz_list,GaussTria* gauss,int numdof);
     34                void GetJacobian(IssmDouble* J, IssmDouble* xyz_list,GaussTria* gauss);
     35                void GetSegmentJacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,GaussTria* gauss);
     36                void GetJacobianDeterminant2d(IssmDouble* Jdet, IssmDouble* xyz_list,GaussTria* gauss);
     37                void GetJacobianDeterminant3d(IssmDouble* Jdet, IssmDouble* xyz_list,GaussTria* gauss);
     38                void GetJacobianInvert(IssmDouble*  Jinv, IssmDouble* xyz_list,GaussTria* gauss);
     39                void GetNodalFunctions(IssmDouble* l1l2l3,GaussTria* gauss);
     40                void GetSegmentNodalFunctions(IssmDouble* l1l2l3,GaussTria* gauss, int index1,int index2);
     41                void GetSegmentBFlux(IssmDouble* B,GaussTria* gauss, int index1,int index2);
     42                void GetSegmentBprimeFlux(IssmDouble* Bprime,GaussTria* gauss, int index1,int index2);
     43                void GetNodalFunctionsDerivatives(IssmDouble* l1l2l3,IssmDouble* xyz_list, GaussTria* gauss);
     44                void GetNodalFunctionsDerivativesReference(IssmDouble* dl1dl3,GaussTria* gauss);
     45                void GetInputValue(IssmDouble* pp, IssmDouble* plist, GaussTria* gauss);
     46                void GetInputDerivativeValue(IssmDouble* pp, IssmDouble* plist,IssmDouble* xyz_list, GaussTria* gauss);
    4747
    4848};
  • issm/trunk/src/c/objects/ExternalResults/BoolExternalResult.cpp

    r12330 r12706  
    44
    55/*header files: */
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*BoolExternalResult constructors and destructor*/
    23 /*FUNCTION BoolExternalResult::BoolExternalResult(){{{1*/
     23/*FUNCTION BoolExternalResult::BoolExternalResult(){{{*/
    2424BoolExternalResult::BoolExternalResult(){
    2525        return;
    2626}
    2727/*}}}*/
    28 /*FUNCTION BoolExternalResult::BoolExternalResult(int enum_type,bool value){{{1*/
    29 BoolExternalResult::BoolExternalResult(int in_id, int in_enum_type,bool in_value,int in_step, double in_time){
     28/*FUNCTION BoolExternalResult::BoolExternalResult(int enum_type,bool value){{{*/
     29BoolExternalResult::BoolExternalResult(int in_id, int in_enum_type,bool in_value,int in_step, IssmDouble in_time){
    3030
    3131        id=in_id;
     
    3636}
    3737/*}}}*/
    38 /*FUNCTION BoolExternalResult::~BoolExternalResult(){{{1*/
     38/*FUNCTION BoolExternalResult::~BoolExternalResult(){{{*/
    3939BoolExternalResult::~BoolExternalResult(){
    4040        return;
     
    4343
    4444/*Object virtual functions definitions:*/
    45 /*FUNCTION BoolExternalResult::Echo {{{1*/
     45/*FUNCTION BoolExternalResult::Echo {{{*/
    4646void BoolExternalResult::Echo(void){
    4747        this->DeepEcho();
    4848}
    4949/*}}}*/
    50 /*FUNCTION BoolExternalResult::DeepEcho{{{1*/
     50/*FUNCTION BoolExternalResult::DeepEcho{{{*/
    5151void BoolExternalResult::DeepEcho(void){
    5252
    53         printf("BoolExternalResult:\n");
    54         printf("   id: %i\n",this->id);
    55         printf("   enum:  %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    56         printf("   value: %s\n",this->value?"true":"false");
    57         printf("   step: %i\n",this->step);
    58         printf("   time: %g\n",this->time);
     53        _printLine_("BoolExternalResult:");
     54        _printLine_("   id: " << this->id);
     55        _printLine_("   enum:  " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     56        _printLine_("   value: " <<(this->value?"true":"false"));
     57        _printLine_("   step: " << this->step);
     58        _printLine_("   time: " << this->time);
    5959}
    6060/*}}}*/
    61 /*FUNCTION BoolExternalResult::Id{{{1*/
     61/*FUNCTION BoolExternalResult::Id{{{*/
    6262int    BoolExternalResult::Id(void){ return -1; }
    6363/*}}}*/
    64 /*FUNCTION BoolExternalResult::MyRank{{{1*/
     64/*FUNCTION BoolExternalResult::MyRank{{{*/
    6565int    BoolExternalResult::MyRank(void){
    6666        extern int my_rank;
     
    6868}
    6969/*}}}*/
    70 /*FUNCTION BoolExternalResult::ObjectEnum{{{1*/
     70/*FUNCTION BoolExternalResult::ObjectEnum{{{*/
    7171int BoolExternalResult::ObjectEnum(void){
    7272
     
    7575}
    7676/*}}}*/
    77 /*FUNCTION BoolExternalResult::copy{{{1*/
     77/*FUNCTION BoolExternalResult::copy{{{*/
    7878Object* BoolExternalResult::copy() {
    7979       
     
    8484
    8585/*BoolExternalResult management: */
    86 /*FUNCTION BoolExternalResult::WriteData{{{1*/
     86/*FUNCTION BoolExternalResult::WriteData{{{*/
    8787void   BoolExternalResult::WriteData(FILE* fid,bool io_gather){
    8888
     
    9090        int     type;
    9191        int     size;
    92         double  boolean;
     92        IssmPDouble  passiveDouble;
    9393        extern  int my_rank;
    9494        char*   name = NULL;
     
    102102        fwrite(&length,sizeof(int),1,fid);
    103103        fwrite(name,length,1,fid);
    104         xfree((void**)&name);
     104        xDelete<char>(name);
    105105
    106106        /*Now write time and step: */
    107         fwrite(&time,sizeof(double),1,fid);
     107        passiveDouble=reCast<IssmPDouble>(time);
     108        fwrite(&passiveDouble,sizeof(IssmPDouble),1,fid);
    108109        fwrite(&step,sizeof(int),1,fid);
    109110
    110         /*Now write bool, after casting it: */
    111         boolean=(double)this->value;
    112 
    113         /*writing a double, type is 1, size is 1: */
     111        /*writing a IssmDouble, type is 1, size is 1: */
    114112        type=1;
    115113        size=1;
    116114        fwrite(&type,sizeof(int),1,fid);
    117115        fwrite(&size,sizeof(int),1,fid);
    118         fwrite(&boolean,size*sizeof(double),1,fid);
     116        /*Now write bool, after casting it: */
     117        passiveDouble=reCast<IssmPDouble>(this->value);
     118        fwrite(&passiveDouble,size*sizeof(IssmPDouble),1,fid);
    119119
    120120}
    121 /*}}}1*/
    122 /*FUNCTION BoolExternalResult::GetResultName{{{1*/
     121/*}}}*/
     122/*FUNCTION BoolExternalResult::GetResultName{{{*/
    123123void BoolExternalResult::GetResultName(char** pname){
    124124        EnumToStringx(pname,this->enum_type);
    125125}
    126126/*}}}*/
    127 /*FUNCTION BoolExternalResult::GetStep{{{1*/
     127/*FUNCTION BoolExternalResult::GetStep{{{*/
    128128int BoolExternalResult::GetStep(void){
    129129
  • issm/trunk/src/c/objects/ExternalResults/BoolExternalResult.h

    r12330 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111
    1212#ifdef HAVE_CONFIG_H
     
    3030                bool   value;
    3131                int    step;
    32                 double time;
     32                IssmDouble time;
    3333
    34                 /*BoolExternalResult constructors, destructors: {{{1*/
     34                /*BoolExternalResult constructors, destructors: {{{*/
    3535                BoolExternalResult();
    36                 BoolExternalResult(int id, int enum_type,bool value,int step,double time);
     36                BoolExternalResult(int id, int enum_type,bool value,int step,IssmDouble time);
    3737                ~BoolExternalResult();
    3838                /*}}}*/
    39                 /*Object virtual functions definitions:{{{1 */
     39                /*Object virtual functions definitions:{{{ */
    4040                void  Echo();
    4141                void  DeepEcho();
     
    4545                Object* copy();
    4646                /*}}}*/
    47                 /*ExternalResult management: {{{1*/
     47                /*ExternalResult management: {{{*/
    4848                int   InstanceEnum(){return enum_type;}
    4949                void  WriteData(FILE* fid,bool io_gather);
  • issm/trunk/src/c/objects/ExternalResults/DoubleExternalResult.cpp

    r12330 r12706  
    44
    55/*header files: */
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*DoubleExternalResult constructors and destructor*/
    23 /*FUNCTION DoubleExternalResult::DoubleExternalResult(){{{1*/
     23/*FUNCTION DoubleExternalResult::DoubleExternalResult(){{{*/
    2424DoubleExternalResult::DoubleExternalResult(){
    2525        return;
    2626}
    2727/*}}}*/
    28 /*FUNCTION DoubleExternalResult::DoubleExternalResult(int enum_type,double value){{{1*/
    29 DoubleExternalResult::DoubleExternalResult(int in_id, int in_enum_type,double in_value,int in_step, double in_time){
     28/*FUNCTION DoubleExternalResult::DoubleExternalResult(int enum_type,IssmDouble value){{{*/
     29DoubleExternalResult::DoubleExternalResult(int in_id, int in_enum_type,IssmDouble in_value,int in_step, IssmDouble in_time){
    3030
    3131        id=in_id;
     
    3636}
    3737/*}}}*/
    38 /*FUNCTION DoubleExternalResult::~DoubleExternalResult(){{{1*/
     38/*FUNCTION DoubleExternalResult::~DoubleExternalResult(){{{*/
    3939DoubleExternalResult::~DoubleExternalResult(){
    4040        return;
     
    4343
    4444/*Object virtual functions definitions:*/
    45 /*FUNCTION DoubleExternalResult::Echo {{{1*/
     45/*FUNCTION DoubleExternalResult::Echo {{{*/
    4646void DoubleExternalResult::Echo(void){
    4747        this->DeepEcho();
    4848}
    4949/*}}}*/
    50 /*FUNCTION DoubleExternalResult::DeepEcho{{{1*/
     50/*FUNCTION DoubleExternalResult::DeepEcho{{{*/
    5151void DoubleExternalResult::DeepEcho(void){
    5252
    53         printf("DoubleExternalResult:\n");
    54         printf("   id: %i\n",this->id);
    55         printf("   enum:  %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    56         printf("   value: %g\n",this->value);
    57         printf("   step: %i\n",this->step);
    58         printf("   time: %g\n",this->time);
     53        _printLine_("DoubleExternalResult:");
     54        _printLine_("   id: " << this->id);
     55        _printLine_("   enum:  " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     56        _printLine_("   value: " << this->value);
     57        _printLine_("   step: " << this->step);
     58        _printLine_("   time: " << this->time);
    5959}
    6060/*}}}*/
    61 /*FUNCTION DoubleExternalResult::Id{{{1*/
     61/*FUNCTION DoubleExternalResult::Id{{{*/
    6262int    DoubleExternalResult::Id(void){ return -1; }
    6363/*}}}*/
    64 /*FUNCTION DoubleExternalResult::MyRank{{{1*/
     64/*FUNCTION DoubleExternalResult::MyRank{{{*/
    6565int    DoubleExternalResult::MyRank(void){
    6666        extern int my_rank;
     
    6868}
    6969/*}}}*/
    70 /*FUNCTION DoubleExternalResult::ObjectEnum{{{1*/
     70/*FUNCTION DoubleExternalResult::ObjectEnum{{{*/
    7171int DoubleExternalResult::ObjectEnum(void){
    7272
     
    7575}
    7676/*}}}*/
    77 /*FUNCTION DoubleExternalResult::copy{{{1*/
     77/*FUNCTION DoubleExternalResult::copy{{{*/
    7878Object* DoubleExternalResult::copy() {
    7979       
     
    8484
    8585/*DoubleExternalResult management: */
    86 /*FUNCTION DoubleExternalResult::WriteData{{{1*/
     86/*FUNCTION DoubleExternalResult::WriteData{{{*/
    8787void   DoubleExternalResult::WriteData(FILE* fid,bool io_gather){
    8888
     
    9292        char   *name    = NULL;
    9393        extern  int my_rank;
     94        IssmPDouble passiveDouble;
    9495
    9596        /*return if now on cpu 0: */
     
    101102        fwrite(&length,sizeof(int),1,fid);
    102103        fwrite(name,length,1,fid);
    103         xfree((void**)&name);
     104        xDelete<char>(name);
    104105
    105106        /*Now write time and step: */
    106         fwrite(&time,sizeof(double),1,fid);
     107        passiveDouble=reCast<IssmPDouble>(time);
     108        fwrite(&passiveDouble,sizeof(IssmPDouble),1,fid);
    107109        fwrite(&step,sizeof(int),1,fid);
    108110
    109         /*writing a double, type is 1, size is 1: */
     111        /*writing a IssmDouble, type is 1, size is 1: */
    110112        type=1;
    111113        size=1;
    112114        fwrite(&type,sizeof(int),1,fid);
    113115        fwrite(&size,sizeof(int),1,fid);
    114         fwrite(&this->value,size*sizeof(double),1,fid);
     116        passiveDouble=reCast<IssmPDouble>(this->value);
     117        fwrite(&passiveDouble,size*sizeof(IssmPDouble),1,fid);
    115118
    116119}
    117 /*}}}1*/
    118 /*FUNCTION DoubleExternalResult::GetResultName{{{1*/
     120/*}}}*/
     121/*FUNCTION DoubleExternalResult::GetResultName{{{*/
    119122void DoubleExternalResult::GetResultName(char** pname){
    120123        EnumToStringx(pname,this->enum_type);
    121124}
    122125/*}}}*/
    123 /*FUNCTION DoubleExternalResult::GetStep{{{1*/
     126/*FUNCTION DoubleExternalResult::GetStep{{{*/
    124127int DoubleExternalResult::GetStep(void){
    125128
  • issm/trunk/src/c/objects/ExternalResults/DoubleExternalResult.h

    r12330 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111
    1212#ifdef HAVE_CONFIG_H
     
    2929                int    id;
    3030                int    enum_type;
    31                 double value;
     31                IssmDouble value;
    3232                int    step;
    33                 double time;
     33                IssmDouble time;
    3434
    3535
    36                 /*DoubleExternalResult constructors, destructors: {{{1*/
     36                /*DoubleExternalResult constructors, destructors: {{{*/
    3737                DoubleExternalResult();
    38                 DoubleExternalResult(int id,int enum_type,double value,int step,double time);
     38                DoubleExternalResult(int id,int enum_type,IssmDouble value,int step,IssmDouble time);
    3939                ~DoubleExternalResult();
    4040                /*}}}*/
    41                 /*Object virtual functions definitions:{{{1 */
     41                /*Object virtual functions definitions:{{{ */
    4242                void  Echo();
    4343                void  DeepEcho();
     
    4747                Object* copy();
    4848                /*}}}*/
    49                 /*ExternalResult management: {{{1*/
     49                /*ExternalResult management: {{{*/
    5050                int   InstanceEnum(){return enum_type;}
    5151                void  WriteData(FILE* fid,bool io_gather);
  • issm/trunk/src/c/objects/ExternalResults/DoubleMatExternalResult.cpp

    r12330 r12706  
    44
    55/*header files: */
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*DoubleMatExternalResult constructors and destructor*/
    23 /*FUNCTION DoubleMatExternalResult::DoubleMatExternalResult(){{{1*/
     23/*FUNCTION DoubleMatExternalResult::DoubleMatExternalResult(){{{*/
    2424DoubleMatExternalResult::DoubleMatExternalResult(){
    2525        return;
    2626}
    2727/*}}}*/
    28 /*FUNCTION DoubleMatExternalResult::DoubleMatExternalResult(int in_id, int enum_type,IssmDoubleMat values,int M,int N,int in_step,double in_time){{{1*/
    29 DoubleMatExternalResult::DoubleMatExternalResult(int in_id, int in_enum_type,double* in_values, int in_M,int in_N,int in_step,double in_time){
     28/*FUNCTION DoubleMatExternalResult::DoubleMatExternalResult(int in_id, int enum_type,IssmDoubleMat values,int M,int N,int in_step,IssmDouble in_time){{{*/
     29DoubleMatExternalResult::DoubleMatExternalResult(int in_id, int in_enum_type,IssmDouble* in_values, int in_M,int in_N,int in_step,IssmDouble in_time){
    3030
    3131        id=in_id;
     
    3636        /*Copy result in values*/
    3737        if(M*N){
    38                 values=(double*)xmalloc(M*N*sizeof(double));
    39                 memcpy(values,in_values,M*N*sizeof(double));
     38                values=xNew<IssmDouble>(M*N);
     39                xMemCpy<IssmDouble>(values,in_values,M*N);
    4040        }
    4141        else values=NULL;
     
    4545}
    4646/*}}}*/
    47 /*FUNCTION DoubleMatExternalResult::~DoubleMatExternalResult(){{{1*/
     47/*FUNCTION DoubleMatExternalResult::~DoubleMatExternalResult(){{{*/
    4848DoubleMatExternalResult::~DoubleMatExternalResult(){
    4949
    50         xfree((void**)&this->values);
     50        xDelete<IssmDouble>(this->values);
    5151        return;
    5252}
     
    5454
    5555/*Object virtual functions definitions:*/
    56 /*FUNCTION DoubleMatExternalResult::Echo {{{1*/
     56/*FUNCTION DoubleMatExternalResult::Echo {{{*/
    5757void DoubleMatExternalResult::Echo(void){
    5858
    59         printf("DoubleMatExternalResult:\n");
    60         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    61         printf("   step: %i\n",this->step);
    62         printf("   time: %g\n",this->time);
    63         printf("   matrix size: %i-%i\n",this->M,this->N);
     59        _printLine_("DoubleMatExternalResult:");
     60        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     61        _printLine_("   step: " << this->step);
     62        _printLine_("   time: " << this->time);
     63        _printLine_("   matrix size: " << this->M << "-" << this->N);
    6464
    6565}
    6666/*}}}*/
    67 /*FUNCTION DoubleMatExternalResult::DeepEcho{{{1*/
     67/*FUNCTION DoubleMatExternalResult::DeepEcho{{{*/
    6868void DoubleMatExternalResult::DeepEcho(void){
    6969
    7070        int i,j;
    7171       
    72         printf("DoubleMatExternalResult:\n");
    73         printf("   id: %i\n",this->id);
    74         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    75         printf("   step: %i\n",this->step);
    76         printf("   time: %g\n",this->time);
    77         printf("   matrix size: %i-%i\n",this->M,this->N);
     72        _printLine_("DoubleMatExternalResult:");
     73        _printLine_("   id: " << this->id);
     74        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     75        _printLine_("   step: " << this->step);
     76        _printLine_("   time: " << this->time);
     77        _printLine_("   matrix size: " << this->M << "-" << this->N);
    7878        for (i=0;i<this->M;i++){ 
    79                 printf("   [ ");
     79                _printString_("   [ ");
    8080                for (j=0;j<this->N;j++){
    81                         printf(" %12.6g ",this->values[i*this->N+j]);
     81                        _printString_( " " << setw(11) << setprecision (5) << this->values[i*this->N+j]);
    8282                } 
    83                 printf(" ]\n");
     83                _printLine_(" ]");
    8484        } 
    85         printf("\n");
    8685
    8786}
    8887/*}}}*/
    89 /*FUNCTION DoubleMatExternalResult::Id{{{1*/
     88/*FUNCTION DoubleMatExternalResult::Id{{{*/
    9089int    DoubleMatExternalResult::Id(void){ return -1; }
    9190/*}}}*/
    92 /*FUNCTION DoubleMatExternalResult::MyRank{{{1*/
     91/*FUNCTION DoubleMatExternalResult::MyRank{{{*/
    9392int    DoubleMatExternalResult::MyRank(void){
    9493        extern int my_rank;
     
    9695}
    9796/*}}}*/
    98 /*FUNCTION DoubleMatExternalResult::ObjectEnum{{{1*/
     97/*FUNCTION DoubleMatExternalResult::ObjectEnum{{{*/
    9998int DoubleMatExternalResult::ObjectEnum(void){
    10099
     
    103102}
    104103/*}}}*/
    105 /*FUNCTION DoubleMatExternalResult::copy{{{1*/
     104/*FUNCTION DoubleMatExternalResult::copy{{{*/
    106105Object* DoubleMatExternalResult::copy() {
    107106       
     
    112111
    113112/*DoubleMatExternalResult management: */
    114 /*FUNCTION DoubleMatExternalResult::WriteData{{{1*/
     113/*FUNCTION DoubleMatExternalResult::WriteData{{{*/
    115114void   DoubleMatExternalResult::WriteData(FILE* fid,bool io_gather){
    116115
     
    120119        char   *name    = NULL;
    121120        extern  int my_rank;
     121        IssmPDouble *passiveDouble_p=NULL;
     122        IssmPDouble passiveDouble;
    122123
    123124        if(io_gather){
     
    126127        }
    127128
     129        passiveDouble_p=xNew<IssmPDouble>(M*N);
     130
    128131        /*First write enum: */
    129132        EnumToStringx(&name,this->enum_type);
     
    131134        fwrite(&length,sizeof(int),1,fid);
    132135        fwrite(name,length,1,fid);
    133         xfree((void**)&name);
     136        xDelete<char>(name);
    134137
    135138        /*Now write time and step: */
    136         fwrite(&time,sizeof(double),1,fid);
     139        passiveDouble=reCast<IssmPDouble>(time);
     140        fwrite(&passiveDouble,sizeof(IssmPDouble),1,fid);
    137141        fwrite(&step,sizeof(int),1,fid);
    138142
    139         /*writing a double array, type is 3:*/
     143        /*writing a IssmDouble array, type is 3:*/
    140144        type=3;
    141145        fwrite(&type,sizeof(int),1,fid);
     
    144148        cols=this->N;
    145149        fwrite(&cols,sizeof(int),1,fid);
    146         fwrite(this->values,cols*rows*sizeof(double),1,fid);
     150        for (int i=0; i<N*M; ++i) passiveDouble_p[i]=reCast<IssmPDouble>(values[i]);
     151        fwrite(passiveDouble_p,cols*rows*sizeof(IssmPDouble),1,fid);
     152        xDelete(passiveDouble_p);
    147153
    148154}
    149 /*}}}1*/
    150 /*FUNCTION DoubleMatExternalResult::GetResultName{{{1*/
     155/*}}}*/
     156/*FUNCTION DoubleMatExternalResult::GetResultName{{{*/
    151157void DoubleMatExternalResult::GetResultName(char** pname){
    152158        EnumToStringx(pname,this->enum_type);
    153159}
    154160/*}}}*/
    155 /*FUNCTION DoubleMatExternalResult::GetStep{{{1*/
     161/*FUNCTION DoubleMatExternalResult::GetStep{{{*/
    156162int DoubleMatExternalResult::GetStep(void){
    157163
  • issm/trunk/src/c/objects/ExternalResults/DoubleMatExternalResult.h

    r12330 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010
    1111#ifdef HAVE_CONFIG_H
     
    2727                int id;
    2828                int enum_type;
    29                 double* values;
     29                IssmDouble* values;
    3030                int M;
    3131                int N;
    3232                int step;
    33                 double time;
     33                IssmDouble time;
    3434
    3535        public:
    36                 /*DoubleMatExternalResult constructors, destructors: {{{1*/
     36                /*DoubleMatExternalResult constructors, destructors: {{{*/
    3737                DoubleMatExternalResult();
    38                 DoubleMatExternalResult(int id,int enum_type,double* values,int M,int N,int step, double time);
     38                DoubleMatExternalResult(int id,int enum_type,IssmDouble* values,int M,int N,int step, IssmDouble time);
    3939                ~DoubleMatExternalResult();
    4040                /*}}}*/
    41                 /*Object virtual functions definitions:{{{1 */
     41                /*Object virtual functions definitions:{{{ */
    4242                void  Echo();
    4343                void  DeepEcho();
     
    4747                Object* copy();
    4848                /*}}}*/
    49                 /*ExternalResult managemnet: {{{1*/
     49                /*ExternalResult managemnet: {{{*/
    5050                int   InstanceEnum(){return enum_type;}
    5151                void  WriteData(FILE* fid,bool io_gather);
  • issm/trunk/src/c/objects/ExternalResults/DoubleVecExternalResult.cpp

    r12330 r12706  
    44
    55/*header files: */
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*DoubleVecExternalResult constructors and destructor*/
    23 /*FUNCTION DoubleVecExternalResult::DoubleVecExternalResult(){{{1*/
     23/*FUNCTION DoubleVecExternalResult::DoubleVecExternalResult(){{{*/
    2424DoubleVecExternalResult::DoubleVecExternalResult(){
    2525        return;
    2626}
    2727/*}}}*/
    28 /*FUNCTION DoubleVecExternalResult::DoubleVecExternalResult(int enum_type,IssmDoubleVec values,int M,int in_step,double in_time){{{1*/
    29 DoubleVecExternalResult::DoubleVecExternalResult(int in_id, int in_enum_type,double* in_values, int in_M,int in_step,double in_time){
     28/*FUNCTION DoubleVecExternalResult::DoubleVecExternalResult(int enum_type,IssmDoubleVec values,int M,int in_step,IssmDouble in_time){{{*/
     29DoubleVecExternalResult::DoubleVecExternalResult(int in_id, int in_enum_type,IssmDouble* in_values, int in_M,int in_step,IssmDouble in_time){
    3030
    3131        id=in_id;
     
    3434
    3535        if(M){
    36                 values=(double*)xmalloc(M*sizeof(double));
    37                 memcpy(values,in_values,M*sizeof(double));
     36                values=xNew<IssmDouble>(M);
     37                xMemCpy<IssmDouble>(values,in_values,M);
    3838        }
    3939        else values=NULL;
     
    4343}
    4444/*}}}*/
    45 /*FUNCTION DoubleVecExternalResult::~DoubleVecExternalResult(){{{1*/
     45/*FUNCTION DoubleVecExternalResult::~DoubleVecExternalResult(){{{*/
    4646DoubleVecExternalResult::~DoubleVecExternalResult(){
    47         xfree((void**)&values);
     47        xDelete<IssmDouble>(values);
    4848        return;
    4949}
     
    5151
    5252/*Object virtual functions definitions:*/
    53 /*FUNCTION DoubleVecExternalResult::Echo {{{1*/
     53/*FUNCTION DoubleVecExternalResult::Echo {{{*/
    5454void DoubleVecExternalResult::Echo(void){
    5555
    56         printf("DoubleVecExternalResult:\n");
    57         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    58         printf("   vector size: %i\n",this->M);
    59         printf("   step: %i\n",this->step);
    60         printf("   time: %g\n",this->time);
     56        _printLine_("DoubleVecExternalResult:");
     57        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     58        _printLine_("   vector size: " << this->M);
     59        _printLine_("   step: " << this->step);
     60        _printLine_("   time: " << this->time);
    6161
    6262}
    6363/*}}}*/
    64 /*FUNCTION DoubleVecExternalResult::DeepEcho{{{1*/
     64/*FUNCTION DoubleVecExternalResult::DeepEcho{{{*/
    6565void DoubleVecExternalResult::DeepEcho(void){
    6666
    6767        int i;
    6868       
    69         printf("DoubleVecExternalResult:\n");
    70         printf("   id: %i\n",this->id);
    71         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    72         printf("   vector size: %i\n",this->M);
     69        _printLine_("DoubleVecExternalResult:");
     70        _printLine_("   id: " << this->id);
     71        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     72        _printLine_("   vector size: " << this->M);
    7373        for(i=0;i<this->M;i++){
    74                 printf("%i %g\n",i,this->values[i]);
     74                _printLine_(i << " " << this->values[i]);
    7575        }
    76         printf("   step: %i\n",this->step);
    77         printf("   time: %g\n",this->time);
     76        _printLine_("   step: " << this->step);
     77        _printLine_("   time: " << this->time);
    7878}
    7979/*}}}*/
    80 /*FUNCTION DoubleVecExternalResult::Id{{{1*/
     80/*FUNCTION DoubleVecExternalResult::Id{{{*/
    8181int    DoubleVecExternalResult::Id(void){ return -1; }
    8282/*}}}*/
    83 /*FUNCTION DoubleVecExternalResult::MyRank{{{1*/
     83/*FUNCTION DoubleVecExternalResult::MyRank{{{*/
    8484int    DoubleVecExternalResult::MyRank(void){
    8585        extern int my_rank;
     
    8787}
    8888/*}}}*/
    89 /*FUNCTION DoubleVecExternalResult::ObjectEnum{{{1*/
     89/*FUNCTION DoubleVecExternalResult::ObjectEnum{{{*/
    9090int DoubleVecExternalResult::ObjectEnum(void){
    9191
     
    9494}
    9595/*}}}*/
    96 /*FUNCTION DoubleVecExternalResult::copy{{{1*/
     96/*FUNCTION DoubleVecExternalResult::copy{{{*/
    9797Object* DoubleVecExternalResult::copy() {
    9898       
     
    103103
    104104/*DoubleVecExternalResult management: */
    105 /*FUNCTION DoubleVecExternalResult::WriteData{{{1*/
     105/*FUNCTION DoubleVecExternalResult::WriteData{{{*/
    106106void   DoubleVecExternalResult::WriteData(FILE* fid,bool io_gather){
    107107
     
    111111        char   *name    = NULL;
    112112        extern  int my_rank;
     113        IssmPDouble *passiveDouble_p=NULL;
     114        IssmPDouble passiveDouble;
    113115
    114116        /*return if now on cpu 0: */
    115117        if(my_rank)return;
    116118
     119        passiveDouble_p=xNew<IssmPDouble>(M);
    117120        /*First write enum: */
    118121        EnumToStringx(&name,this->enum_type);
     
    120123        fwrite(&length,sizeof(int),1,fid);
    121124        fwrite(name,length,1,fid);
    122         xfree((void**)&name);
     125        xDelete<char>(name);
    123126
    124127        /*Now write time and step: */
    125         fwrite(&time,sizeof(double),1,fid);
     128        passiveDouble=reCast<IssmPDouble>(time);
     129        fwrite(&passiveDouble,sizeof(IssmPDouble),1,fid);
    126130        fwrite(&step,sizeof(int),1,fid);
    127131
    128         /*writing a double, type is 1, size is 1: */
     132        /*writing a IssmDouble, type is 1, size is 1: */
    129133        type=1;
    130134        size=this->M;
    131135        fwrite(&type,sizeof(int),1,fid);
    132136        fwrite(&size,sizeof(int),1,fid);
    133         fwrite(this->values,size*sizeof(double),1,fid);
    134 
     137        for (int i=0; i<M; ++i) passiveDouble_p[i]=reCast<IssmPDouble>(values[i]);
     138        fwrite(passiveDouble_p,size*sizeof(IssmPDouble),1,fid);
     139        xDelete(passiveDouble_p);
    135140}
    136 /*}}}1*/
    137 /*FUNCTION DoubleVecExternalResult::GetResultName{{{1*/
     141/*}}}*/
     142/*FUNCTION DoubleVecExternalResult::GetResultName{{{*/
    138143void DoubleVecExternalResult::GetResultName(char** pname){
    139144        EnumToStringx(pname,this->enum_type);
    140145}
    141146/*}}}*/
    142 /*FUNCTION DoubleVecExternalResult::GetStep{{{1*/
     147/*FUNCTION DoubleVecExternalResult::GetStep{{{*/
    143148int DoubleVecExternalResult::GetStep(void){
    144149
  • issm/trunk/src/c/objects/ExternalResults/DoubleVecExternalResult.h

    r12330 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010
    1111#ifdef HAVE_CONFIG_H
     
    2727                int id;
    2828                int enum_type;
    29                 double* values;
     29                IssmDouble* values;
    3030                int M;
    3131                int step;
    32                 double time;
     32                IssmDouble time;
    3333
    3434        public:
    35                 /*DoubleVecExternalResult constructors, destructors: {{{1*/
     35                /*DoubleVecExternalResult constructors, destructors: {{{*/
    3636                DoubleVecExternalResult();
    37                 DoubleVecExternalResult(int id,int enum_type,double* values,int M,int step, double time);
     37                DoubleVecExternalResult(int id,int enum_type,IssmDouble* values,int M,int step, IssmDouble time);
    3838                ~DoubleVecExternalResult();
    3939                /*}}}*/
    40                 /*Object virtual functions definitions:{{{1 */
     40                /*Object virtual functions definitions:{{{ */
    4141                void  Echo();
    4242                void  DeepEcho();
     
    4646                Object* copy();
    4747                /*}}}*/
    48                 /*ExternalResult management: {{{1*/
     48                /*ExternalResult management: {{{*/
    4949                int   InstanceEnum(){return enum_type;}
    5050                void  WriteData(FILE* fid,bool io_gather);
  • issm/trunk/src/c/objects/ExternalResults/ExternalResult.h

    r12330 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111
    1212#ifdef HAVE_CONFIG_H
     
    2525               
    2626                virtual        ~ExternalResult(){};
    27                 /*Virtual functions:{{{1*/
     27                /*Virtual functions:{{{*/
    2828                virtual int   InstanceEnum()=0;
    2929                virtual void  WriteData(FILE* fid,bool io_gather)=0;
  • issm/trunk/src/c/objects/ExternalResults/IntExternalResult.cpp

    r12330 r12706  
    44
    55/*header files: */
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*IntExternalResult constructors and destructor*/
    23 /*FUNCTION IntExternalResult::IntExternalResult(){{{1*/
     23/*FUNCTION IntExternalResult::IntExternalResult(){{{*/
    2424IntExternalResult::IntExternalResult(){
    2525        return;
    2626}
    2727/*}}}*/
    28 /*FUNCTION IntExternalResult::IntExternalResult(int in_id, int in_enum_type,int in_value,int in_step, double in_time){{{1*/
    29 IntExternalResult::IntExternalResult(int in_id, int in_enum_type,int in_value,int in_step, double in_time){
     28/*FUNCTION IntExternalResult::IntExternalResult(int in_id, int in_enum_type,int in_value,int in_step, IssmDouble in_time){{{*/
     29IntExternalResult::IntExternalResult(int in_id, int in_enum_type,int in_value,int in_step, IssmDouble in_time){
    3030
    3131        id=in_id;
     
    3636}
    3737/*}}}*/
    38 /*FUNCTION IntExternalResult::~IntExternalResult(){{{1*/
     38/*FUNCTION IntExternalResult::~IntExternalResult(){{{*/
    3939IntExternalResult::~IntExternalResult(){
    4040        return;
     
    4343
    4444/*Object virtual functions definitions:*/
    45 /*FUNCTION IntExternalResult::Echo {{{1*/
     45/*FUNCTION IntExternalResult::Echo {{{*/
    4646void IntExternalResult::Echo(void){
    4747        this->DeepEcho();
    4848}
    4949/*}}}*/
    50 /*FUNCTION IntExternalResult::DeepEcho{{{1*/
     50/*FUNCTION IntExternalResult::DeepEcho{{{*/
    5151void IntExternalResult::DeepEcho(void){
    5252
    53         printf("IntExternalResult:\n");
    54         printf("   id: %i\n",this->id);
    55         printf("   enum:  %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    56         printf("   value: %i\n",this->value);
    57         printf("   step: %i\n",this->step);
    58         printf("   time: %g\n",this->time);
     53        _printLine_("IntExternalResult:");
     54        _printLine_("   id: " << this->id);
     55        _printLine_("   enum:  " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     56        _printLine_("   value: " << this->value);
     57        _printLine_("   step: " << this->step);
     58        _printLine_("   time: " << this->time);
    5959}
    6060/*}}}*/
    61 /*FUNCTION IntExternalResult::Id{{{1*/
     61/*FUNCTION IntExternalResult::Id{{{*/
    6262int    IntExternalResult::Id(void){ return -1; }
    6363/*}}}*/
    64 /*FUNCTION IntExternalResult::MyRank{{{1*/
     64/*FUNCTION IntExternalResult::MyRank{{{*/
    6565int    IntExternalResult::MyRank(void){
    6666        extern int my_rank;
     
    6868}
    6969/*}}}*/
    70 /*FUNCTION IntExternalResult::ObjectEnum{{{1*/
     70/*FUNCTION IntExternalResult::ObjectEnum{{{*/
    7171int IntExternalResult::ObjectEnum(void){
    7272
     
    7575}
    7676/*}}}*/
    77 /*FUNCTION IntExternalResult::copy{{{1*/
     77/*FUNCTION IntExternalResult::copy{{{*/
    7878Object* IntExternalResult::copy() {
    7979       
     
    8484
    8585/*IntExternalResult management: */
    86 /*FUNCTION IntExternalResult::WriteData{{{1*/
     86/*FUNCTION IntExternalResult::WriteData{{{*/
    8787void   IntExternalResult::WriteData(FILE* fid,bool io_gather){
    8888
     
    9191        int     size;
    9292        char   *name    = NULL;
    93         double  integer;
     93        IssmPDouble  passiveDouble;
    9494        extern  int my_rank;
    9595
     
    102102        fwrite(&length,sizeof(int),1,fid);
    103103        fwrite(name,length,1,fid);
    104         xfree((void**)&name);
     104        xDelete<char>(name);
    105105
    106106        /*Now write time and step: */
    107         fwrite(&time,sizeof(double),1,fid);
     107        passiveDouble=reCast<IssmPDouble>(time);
     108        fwrite(&passiveDouble,sizeof(IssmPDouble),1,fid);
    108109        fwrite(&step,sizeof(int),1,fid);
    109110
    110         /*cast to a double: */
    111         integer=(double)this->value;
    112 
    113         /*writing a double, type is 1, size is 1: */
     111        /*writing a IssmPDouble, type is 1, size is 1: */
    114112        type=1;
    115113        size=1;
    116114        fwrite(&type,sizeof(int),1,fid);
    117115        fwrite(&size,sizeof(int),1,fid);
    118         fwrite(&integer,size*sizeof(double),1,fid);
     116        /*cast to a IssmPDouble: */
     117        passiveDouble=reCast<IssmPDouble>(value);
     118        fwrite(&passiveDouble,size*sizeof(IssmPDouble),1,fid);
    119119
    120120}
    121 /*}}}1*/
    122 /*FUNCTION IntExternalResult::GetResultName{{{1*/
     121/*}}}*/
     122/*FUNCTION IntExternalResult::GetResultName{{{*/
    123123void IntExternalResult::GetResultName(char** pname){
    124124        EnumToStringx(pname,this->enum_type);
    125125}
    126126/*}}}*/
    127 /*FUNCTION IntExternalResult::GetStep{{{1*/
     127/*FUNCTION IntExternalResult::GetStep{{{*/
    128128int IntExternalResult::GetStep(void){
    129129
  • issm/trunk/src/c/objects/ExternalResults/IntExternalResult.h

    r12330 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111
    1212#ifdef HAVE_CONFIG_H
     
    2828                int    value;
    2929                int    step;
    30                 double time;
     30                IssmDouble time;
    3131
    3232
    33                 /*IntExternalResult constructors, destructors: {{{1*/
     33                /*IntExternalResult constructors, destructors: {{{*/
    3434                IntExternalResult();
    35                 IntExternalResult(int id,int enum_type,int value,int step,double time);
     35                IntExternalResult(int id,int enum_type,int value,int step,IssmDouble time);
    3636                ~IntExternalResult();
    3737
    3838                /*}}}*/
    39                 /*Object virtual functions definitions:{{{1 */
     39                /*Object virtual functions definitions:{{{ */
    4040                void  Echo();
    4141                void  DeepEcho();
     
    4545                Object* copy();
    4646                /*}}}*/
    47                 /*ExternalResult managemnet: {{{1*/
     47                /*ExternalResult managemnet: {{{*/
    4848                int   InstanceEnum(){return enum_type;}
    4949                void  WriteData(FILE* fid,bool io_gather);
  • issm/trunk/src/c/objects/ExternalResults/PetscVecExternalResult.cpp

    r12330 r12706  
    44
    55/*header files: */
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*PetscVecExternalResult constructors and destructor*/
    23 /*FUNCTION PetscVecExternalResult::PetscVecExternalResult(){{{1*/
     23/*FUNCTION PetscVecExternalResult::PetscVecExternalResult(){{{*/
    2424PetscVecExternalResult::PetscVecExternalResult(){
    2525        return;
    2626}
    2727/*}}}*/
    28 /*FUNCTION PetscVecExternalResult::PetscVecExternalResult(int enum_type,IssmPetscVec value){{{1*/
    29 PetscVecExternalResult::PetscVecExternalResult(int in_id, int in_enum_type,Vector* in_value,int in_step, double in_time){
     28/*FUNCTION PetscVecExternalResult::PetscVecExternalResult(int enum_type,IssmPetscVec value){{{*/
     29PetscVecExternalResult::PetscVecExternalResult(int in_id, int in_enum_type,Vector* in_value,int in_step, IssmDouble in_time){
    3030
    3131        id=in_id;
     
    4444}
    4545/*}}}*/
    46 /*FUNCTION PetscVecExternalResult::~PetscVecExternalResult(){{{1*/
     46/*FUNCTION PetscVecExternalResult::~PetscVecExternalResult(){{{*/
    4747PetscVecExternalResult::~PetscVecExternalResult(){
    4848        VecFree(&value);
     
    5151
    5252/*Object virtual functions definitions:*/
    53 /*FUNCTION PetscVecExternalResult::Echo {{{1*/
     53/*FUNCTION PetscVecExternalResult::Echo {{{*/
    5454void PetscVecExternalResult::Echo(void){
    5555
    56         printf("PetscVecExternalResult:\n");
    57         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
     56        _printLine_("PetscVecExternalResult:");
     57        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
    5858
    5959}
    6060/*}}}*/
    61 /*FUNCTION PetscVecExternalResult::DeepEcho{{{1*/
     61/*FUNCTION PetscVecExternalResult::DeepEcho{{{*/
    6262void PetscVecExternalResult::DeepEcho(void){
    6363
    6464        int i;
    65         printf("PetscVecExternalResult:\n");
    66         printf("   id: %i\n",this->id);
    67         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    68         printf("   step: %i\n",this->step);
    69         printf("   time: %g\n",this->time);
     65        _printLine_("PetscVecExternalResult:");
     66        _printLine_("   id: " << this->id);
     67        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     68        _printLine_("   step: " << this->step);
     69        _printLine_("   time: " << this->time);
    7070        VecView(value,PETSC_VIEWER_STDOUT_WORLD);
    7171}
    7272/*}}}*/
    73 /*FUNCTION PetscVecExternalResult::Id{{{1*/
     73/*FUNCTION PetscVecExternalResult::Id{{{*/
    7474int    PetscVecExternalResult::Id(void){ return -1; }
    7575/*}}}*/
    76 /*FUNCTION PetscVecExternalResult::MyRank{{{1*/
     76/*FUNCTION PetscVecExternalResult::MyRank{{{*/
    7777int    PetscVecExternalResult::MyRank(void){
    7878        extern int my_rank;
     
    8080}
    8181/*}}}*/
    82 /*FUNCTION PetscVecExternalResult::ObjectEnum{{{1*/
     82/*FUNCTION PetscVecExternalResult::ObjectEnum{{{*/
    8383int PetscVecExternalResult::ObjectEnum(void){
    8484
     
    8787}
    8888/*}}}*/
    89 /*FUNCTION PetscVecExternalResult::copy{{{1*/
     89/*FUNCTION PetscVecExternalResult::copy{{{*/
    9090Object* PetscVecExternalResult::copy() {
    9191       
     
    9696
    9797/*PetscVecExternalResult management: */
    98 /*FUNCTION PetscVecExternalResult::WriteData{{{1*/
     98/*FUNCTION PetscVecExternalResult::WriteData{{{*/
    9999void   PetscVecExternalResult::WriteData(FILE* fid,bool io_gather){
    100100
     
    103103        int     size;
    104104        char   *name      = NULL;
    105         double *serialvec = NULL;
     105        IssmPDouble *serialvec = NULL;
    106106        extern int my_rank;
     107        IssmPDouble passiveDouble;
    107108
    108109        /*serialize: */
     
    118119        fwrite(&length,sizeof(int),1,fid);
    119120        fwrite(name,length,1,fid);
    120         xfree((void**)&name);
     121        xDelete<char>(name);
    121122
    122123        /*Now write time and step: */
    123         fwrite(&time,sizeof(double),1,fid);
     124        passiveDouble=reCast<IssmPDouble>(time);
     125        fwrite(&passiveDouble,sizeof(IssmPDouble),1,fid);
    124126        fwrite(&step,sizeof(int),1,fid);
    125127
    126         /*writing a double, type is 1, size is 1: */
     128        /*writing a IssmDouble, type is 1, size is 1: */
    127129        type=1;
    128130       
    129131        fwrite(&type,sizeof(int),1,fid);
    130132        fwrite(&size,sizeof(int),1,fid);
    131         fwrite(serialvec,size*sizeof(double),1,fid);
     133        fwrite(serialvec,size*sizeof(IssmPDouble),1,fid);
    132134
    133135        /*Free ressources:*/
    134         xfree((void**)&serialvec);
     136        xDelete<IssmPDouble>(serialvec);
    135137}
    136 /*}}}1*/
    137 /*FUNCTION PetscVecExternalResult::GetResultName{{{1*/
     138/*}}}*/
     139/*FUNCTION PetscVecExternalResult::GetResultName{{{*/
    138140void PetscVecExternalResult::GetResultName(char**pname){
    139141        EnumToStringx(pname,this->enum_type);
    140142}
    141143/*}}}*/
    142 /*FUNCTION PetscVecExternalResult::GetStep{{{1*/
     144/*FUNCTION PetscVecExternalResult::GetStep{{{*/
    143145int PetscVecExternalResult::GetStep(void){
    144146
  • issm/trunk/src/c/objects/ExternalResults/PetscVecExternalResult.h

    r12330 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111
    1212#ifdef HAVE_CONFIG_H
     
    3030                Vector* value;
    3131                int step;
    32                 double time;
     32                IssmDouble time;
    3333
    3434        public:
    35                 /*PetscVecExternalResult constructors, destructors: {{{1*/
     35                /*PetscVecExternalResult constructors, destructors: {{{*/
    3636                PetscVecExternalResult();
    37                 PetscVecExternalResult(int id,int enum_type,Vector* value, int step, double time);
     37                PetscVecExternalResult(int id,int enum_type,Vector* value, int step, IssmDouble time);
    3838                ~PetscVecExternalResult();
    3939                /*}}}*/
    40                 /*Object virtual functions definitions:{{{1 */
     40                /*Object virtual functions definitions:{{{ */
    4141                void  Echo();
    4242                void  DeepEcho();
     
    4646                Object* copy();
    4747                /*}}}*/
    48                 /*ExternalResult management: {{{1*/
     48                /*ExternalResult management: {{{*/
    4949                int   InstanceEnum(){return enum_type;}
    5050                void  WriteData(FILE* fid,bool io_gather);
  • issm/trunk/src/c/objects/ExternalResults/StringExternalResult.cpp

    r12330 r12706  
    44
    55/*header files: */
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*StringExternalResult constructors and destructor*/
    23 /*FUNCTION StringExternalResult::StringExternalResult(){{{1*/
     23/*FUNCTION StringExternalResult::StringExternalResult(){{{*/
    2424StringExternalResult::StringExternalResult(){
    2525        return;
    2626}
    2727/*}}}*/
    28 /*FUNCTION StringExternalResult::StringExternalResult(int enum_type,IssmString value){{{1*/
    29 StringExternalResult::StringExternalResult(int in_id, int in_enum_type,char* in_value,int in_step, double in_time){
     28/*FUNCTION StringExternalResult::StringExternalResult(int enum_type,IssmString value){{{*/
     29StringExternalResult::StringExternalResult(int in_id, int in_enum_type,char* in_value,int in_step, IssmDouble in_time){
    3030
    3131        id=in_id;
    3232        enum_type=in_enum_type;
    33         value=(char*)xmalloc((strlen(in_value)+1)*sizeof(char));
    34         memcpy(value,in_value,(strlen(in_value)+1)*sizeof(char));
    35 
     33        value=xNew<char>(strlen(in_value)+1);
     34        xMemCpy<char>(value,in_value,(strlen(in_value)+1));
    3635        step=in_step;
    3736        time=in_time;
     
    3938}
    4039/*}}}*/
    41 /*FUNCTION StringExternalResult::~StringExternalResult(){{{1*/
     40/*FUNCTION StringExternalResult::~StringExternalResult(){{{*/
    4241StringExternalResult::~StringExternalResult(){
    43         xfree((void**)&value);
     42        xDelete<char>(value);
    4443}
    4544/*}}}*/
    4645
    4746/*Object virtual functions definitions:*/
    48 /*FUNCTION StringExternalResult::Echo {{{1*/
     47/*FUNCTION StringExternalResult::Echo {{{*/
    4948void StringExternalResult::Echo(void){
    5049        this->DeepEcho();
    5150}
    5251/*}}}*/
    53 /*FUNCTION StringExternalResult::DeepEcho{{{1*/
     52/*FUNCTION StringExternalResult::DeepEcho{{{*/
    5453void StringExternalResult::DeepEcho(void){
    5554
    56         printf("StringExternalResult:\n");
    57         printf("   id: %i\n",this->id);
    58         printf("   enum:  %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    59         printf("   value: %s\n",this->value);
    60         printf("   step: %i\n",this->step);
    61         printf("   time: %g\n",this->time);
     55        _printLine_("StringExternalResult:");
     56        _printLine_("   id: " << this->id);
     57        _printLine_("   enum:  " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     58        _printLine_("   value: " << this->value);
     59        _printLine_("   step: " << this->step);
     60        _printLine_("   time: " << this->time);
    6261}
    6362/*}}}*/
    64 /*FUNCTION StringExternalResult::Id{{{1*/
     63/*FUNCTION StringExternalResult::Id{{{*/
    6564int    StringExternalResult::Id(void){ return -1; }
    6665/*}}}*/
    67 /*FUNCTION StringExternalResult::MyRank{{{1*/
     66/*FUNCTION StringExternalResult::MyRank{{{*/
    6867int    StringExternalResult::MyRank(void){
    6968        extern int my_rank;
     
    7170}
    7271/*}}}*/
    73 /*FUNCTION StringExternalResult::ObjectEnum{{{1*/
     72/*FUNCTION StringExternalResult::ObjectEnum{{{*/
    7473int StringExternalResult::ObjectEnum(void){
    7574
     
    7877}
    7978/*}}}*/
    80 /*FUNCTION StringExternalResult::copy{{{1*/
     79/*FUNCTION StringExternalResult::copy{{{*/
    8180Object* StringExternalResult::copy() {
    8281       
     
    8786
    8887/*StringExternalResult management: */
    89 /*FUNCTION StringExternalResult::WriteData{{{1*/
     88/*FUNCTION StringExternalResult::WriteData{{{*/
    9089void   StringExternalResult::WriteData(FILE* fid,bool io_gather){
    9190
     
    9493        char   *name      = NULL;
    9594        extern  int my_rank;
     95        IssmPDouble passiveDouble;
    9696
    9797        /*return if now on cpu 0: */
     
    103103        fwrite(&length,sizeof(int),1,fid);
    104104        fwrite(name,length,1,fid);
    105         xfree((void**)&name);
     105        xDelete<char>(name);
    106106
    107107        /*Now write time and step: */
    108         fwrite(&time,sizeof(double),1,fid);
     108        passiveDouble=reCast<IssmPDouble>(time);
     109        fwrite(&passiveDouble,sizeof(IssmPDouble),1,fid);
    109110        fwrite(&step,sizeof(int),1,fid);
    110111
     
    118119
    119120}
    120 /*}}}1*/
    121 /*FUNCTION StringExternalResult::GetResultName{{{1*/
     121/*}}}*/
     122/*FUNCTION StringExternalResult::GetResultName{{{*/
    122123void StringExternalResult::GetResultName(char**pname){
    123124        EnumToStringx(pname,this->enum_type);
    124125}
    125126/*}}}*/
    126 /*FUNCTION StringExternalResult::GetStep{{{1*/
     127/*FUNCTION StringExternalResult::GetStep{{{*/
    127128int StringExternalResult::GetStep(void){
    128129
  • issm/trunk/src/c/objects/ExternalResults/StringExternalResult.h

    r12330 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111
    1212#ifdef HAVE_CONFIG_H
     
    3030                char*  value;
    3131                int    step;
    32                 double time;
     32                IssmDouble time;
    3333
    3434        public:
    35                 /*StringExternalResult constructors, destructors: {{{1*/
     35                /*StringExternalResult constructors, destructors: {{{*/
    3636                StringExternalResult();
    37                 StringExternalResult(int id,int enum_type,char* value,int step, double time);
     37                StringExternalResult(int id,int enum_type,char* value,int step, IssmDouble time);
    3838                ~StringExternalResult();
    3939                /*}}}*/
    40                 /*Object virtual functions definitions:{{{1 */
     40                /*Object virtual functions definitions:{{{ */
    4141                void  Echo();
    4242                void  DeepEcho();
     
    4646                Object* copy();
    4747                /*}}}*/
    48                 /*ExternalResult management: {{{1*/
     48                /*ExternalResult management: {{{*/
    4949                int   InstanceEnum(){return enum_type;}
    5050                void  WriteData(FILE* fid,bool io_gather);
  • issm/trunk/src/c/objects/FemModel.cpp

    r12330 r12706  
    2020
    2121/*Object constructors and destructor*/
    22 /*FUNCTION FemModel::constructor {{{1*/
     22/*FUNCTION FemModel::constructor {{{*/
    2323FemModel::FemModel(char* inputfilename, char* outputfilename, const int in_solution_type,const int* analyses,const int nummodels){
    2424
    2525        /*intermediary*/
    26         int i;
    27         int analysis_type;
    28         FILE* IOMODEL;
    29         extern int my_rank;
     26        int         i;
     27        int         analysis_type;
     28        FILE       *IOMODEL = NULL;
     29        extern int  my_rank;
    3030
    3131        /*Open input file on cpu 0: */
    32         if(my_rank==0) IOMODEL= pfopen(inputfilename ,"rb");
     32        if(my_rank==0) IOMODEL = pfopen(inputfilename ,"rb");
    3333
    3434        /*Initialize internal data: */
     
    3939       
    4040        /*Dynamically allocate whatever is a list of length nummodels: */
    41         analysis_type_list=(int*)xmalloc(nummodels*sizeof(int));
     41        analysis_type_list=xNew<int>(nummodels);
    4242
    4343        /*Initialize: */
     
    5050        for(i=0;i<nummodels;i++){
    5151
    52                 _printf_(VerboseMProcessor(),"   Processing finite element model of analysis %s:\n",EnumToStringx(analysis_type_list[i]));
     52                if(VerboseMProcessor()) _pprintLine_("   Processing finite element model of analysis " << EnumToStringx(analysis_type_list[i]) << ":");
    5353                analysis_type=analysis_type_list[i];
    5454                this->SetCurrentConfiguration(analysis_type);
    5555       
    5656                if(i==0){
    57                         _printf_(VerboseMProcessor(),"      creating vertex degrees of freedom\n");
     57                        if(VerboseMProcessor()) _pprintLine_("      creating vertex degrees of freedom");
    5858                        VerticesDofx(vertices,parameters); //only call once, we only have one set of vertices
    5959                }
    6060
    61                 _printf_(VerboseMProcessor(),"      resolving node constraints\n");
     61                if(VerboseMProcessor()) _pprintLine_("      resolving node constraints");
    6262                SpcNodesx(nodes,constraints,parameters,analysis_type);
    6363
    64                 _printf_(VerboseMProcessor(),"      creating nodal degrees of freedom\n");
     64                if(VerboseMProcessor()) _pprintLine_("      creating nodal degrees of freedom");
    6565                NodesDofx(nodes,parameters,analysis_type);
    6666       
    67                 _printf_(VerboseMProcessor(),"      configuring element and loads\n");
     67                if(VerboseMProcessor()) _pprintLine_("      configuring element and loads");
    6868                ConfigureObjectsx(elements, loads, nodes, vertices, materials,parameters);
    6969        }
     
    7777}
    7878
    79 /*}}}1*/
    80 /*FUNCTION FemModel::destructor {{{1*/
     79/*}}}*/
     80/*FUNCTION FemModel::destructor {{{*/
    8181FemModel::~FemModel(){
    8282
     
    8585
    8686        /*Delete all the datasets: */
    87         xfree((void**)&analysis_type_list);
     87        xDelete<int>(analysis_type_list);
    8888        delete elements;
    8989        delete nodes;
     
    9696
    9797}
    98 /*}}}1*/
     98/*}}}*/
    9999
    100100/*Object management*/
    101 /*FUNCTION FemModel::Echo {{{1*/
     101/*FUNCTION FemModel::Echo {{{*/
    102102void FemModel::Echo(void){
    103103
    104         printf("FemModel echo: \n");
    105         printf("   number of fem models: %i\n",nummodels);
    106         printf("   analysis_type_list: \n");
    107         for(int i=0;i<nummodels;i++)printf("     %i: %s\n",i,EnumToStringx(analysis_type_list[i]));
    108         printf("   current analysis_type: \n");
    109         printf("     %i: %s\n",analysis_counter,EnumToStringx(analysis_type_list[analysis_counter]));
     104        _printLine_("FemModel echo: ");
     105        _printLine_("   number of fem models: " << nummodels);
     106        _printLine_("   analysis_type_list: ");
     107        for(int i=0;i<nummodels;i++)_printLine_("     " << i << ": " << EnumToStringx(analysis_type_list[i]));
     108        _printLine_("   current analysis_type: ");
     109        _printLine_("     " << analysis_counter << ": " << EnumToStringx(analysis_type_list[analysis_counter]));
    110110
    111111}
     
    113113
    114114/*Numerics: */
    115 /*FUNCTION FemModel::SetCurrentConfiguration(int configuration_type,int analysis_type){{{1*/
     115/*FUNCTION FemModel::SetCurrentConfiguration(int configuration_type,int analysis_type){{{*/
    116116void FemModel::SetCurrentConfiguration(int configuration_type,int analysis_type){
    117117
     
    129129        }
    130130        if(found!=-1) analysis_counter=found;
    131         else _error_("Could not find alias for analysis_type %s in list of FemModel analyses",EnumToStringx(configuration_type));
     131        else _error2_("Could not find alias for analysis_type " << EnumToStringx(configuration_type) << " in list of FemModel analyses");
    132132
    133133        /*Now, plug analysis_counter and analysis_type inside the parameters: */
     
    145145        if(this->parameters->Exist(PetscOptionsStringsEnum)){
    146146                PetscOptionsFromAnalysis(this->parameters,analysis_type);
    147                 _printf_(VerboseSolver(),"      petsc Options set for analysis type: %s\n",EnumToStringx(analysis_type));
     147                if(VerboseSolver()) _pprintLine_("      petsc Options set for analysis type: " << EnumToStringx(analysis_type));
    148148        }
    149149        #endif
    150150
    151151}
    152 /*}}}1*/
    153 /*FUNCTION FemModel::SetCurrentConfiguration(int configuration_type){{{1*/
     152/*}}}*/
     153/*FUNCTION FemModel::SetCurrentConfiguration(int configuration_type){{{*/
    154154void FemModel::SetCurrentConfiguration(int configuration_type){
    155155
     
    157157        this->SetCurrentConfiguration(configuration_type,configuration_type);
    158158}
    159 /*}}}1*/
     159/*}}}*/
  • issm/trunk/src/c/objects/FemModel.h

    r8800 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "./Object.h"
    1111#include "../toolkits/toolkits.h"
  • issm/trunk/src/c/objects/Gauss/GaussPenta.cpp

    r8416 r12706  
    33 */
    44
    5 /*Include files: {{{1*/
     5/*Include files: {{{*/
    66#include "./../objects.h"
    77/*}}}*/
    88
    99/*GaussPenta constructors and destructors:*/
    10 /*FUNCTION GaussPenta::GaussPenta() {{{1*/
     10/*FUNCTION GaussPenta::GaussPenta() {{{*/
    1111GaussPenta::GaussPenta(){
    1212
     
    2626}
    2727/*}}}*/
    28 /*FUNCTION GaussPenta::GaussPenta(int order_horiz,int order_vert) {{{1*/
     28/*FUNCTION GaussPenta::GaussPenta(int order_horiz,int order_vert) {{{*/
    2929GaussPenta::GaussPenta(int order_horiz,int order_vert){
    3030
     
    4747        /*Allocate GaussPenta fields*/
    4848        numgauss=numgauss_horiz*numgauss_vert;
    49         coords1=(double*)xmalloc(numgauss*sizeof(double));
    50         coords2=(double*)xmalloc(numgauss*sizeof(double));
    51         coords3=(double*)xmalloc(numgauss*sizeof(double));
    52         coords4=(double*)xmalloc(numgauss*sizeof(double));
    53         weights=(double*)xmalloc(numgauss*sizeof(double));
     49        coords1=xNew<double>(numgauss);
     50        coords2=xNew<double>(numgauss);
     51        coords3=xNew<double>(numgauss);
     52        coords4=xNew<double>(numgauss);
     53        weights=xNew<double>(numgauss);
    5454
    5555        /*Combine Horizontal and vertical points*/
     
    7272
    7373        /*Clean up*/
    74         xfree((void**)&coords1_horiz);
    75         xfree((void**)&coords2_horiz);
    76         xfree((void**)&coords3_horiz);
    77         xfree((void**)&coords_vert);
    78         xfree((void**)&weights_horiz);
    79         xfree((void**)&weights_vert);
    80 }
    81 /*}}}*/
    82 /*FUNCTION GaussPenta::GaussPenta(int index1, int index2, int order){{{1*/
     74        xDelete<double>(coords1_horiz);
     75        xDelete<double>(coords2_horiz);
     76        xDelete<double>(coords3_horiz);
     77        xDelete<double>(coords_vert);
     78        xDelete<double>(weights_horiz);
     79        xDelete<double>(weights_vert);
     80}
     81/*}}}*/
     82/*FUNCTION GaussPenta::GaussPenta(int index1, int index2, int order){{{*/
    8383GaussPenta::GaussPenta(int index1, int index2,int order){
    8484
     
    9393
    9494        /*Allocate GaussPenta fields*/
    95         coords1=(double*)xmalloc(numgauss*sizeof(double));
    96         coords2=(double*)xmalloc(numgauss*sizeof(double));
    97         coords3=(double*)xmalloc(numgauss*sizeof(double));
    98         coords4=(double*)xmalloc(numgauss*sizeof(double));
    99         weights=(double*)xmalloc(numgauss*sizeof(double));
     95        coords1=xNew<double>(numgauss);
     96        coords2=xNew<double>(numgauss);
     97        coords3=xNew<double>(numgauss);
     98        coords4=xNew<double>(numgauss);
     99        weights=xNew<double>(numgauss);
    100100
    101101        if(index1==0 && index2==3){
     
    121121        }
    122122        else{
    123                 _error_("Penta not supported yet");
     123                _error2_("Penta not supported yet");
    124124        }
    125125
     
    132132
    133133        /*clean up*/
    134         xfree((void**)&seg_coords);
    135         xfree((void**)&seg_weights);
    136 
    137 }
    138 /*}}}*/
    139 /*FUNCTION GaussPenta::GaussPenta(int index1, int index2, int index3, int order){{{1*/
     134        xDelete<double>(seg_coords);
     135        xDelete<double>(seg_weights);
     136
     137}
     138/*}}}*/
     139/*FUNCTION GaussPenta::GaussPenta(int index1, int index2, int index3, int order){{{*/
    140140GaussPenta::GaussPenta(int index1, int index2, int index3, int order){
    141141
     
    147147
    148148                /*compute z coordinate*/
    149                 coords4=(double*)xmalloc(numgauss*sizeof(double));
     149                coords4=xNew<double>(numgauss);
    150150                for(int i=0;i<numgauss;i++) coords4[i]=-1.0;
    151151        }
     
    157157
    158158                /*compute z coordinate*/
    159                 coords4=(double*)xmalloc(numgauss*sizeof(double));
     159                coords4=xNew<double>(numgauss);
    160160                for(int i=0;i<numgauss;i++) coords4[i]=1.0;
    161161        }
    162162        else{
    163                 _error_("Tria not supported yet");
    164         }
    165 
    166 }
    167 /*}}}*/
    168 /*FUNCTION GaussPenta::GaussPenta(int index1, int index2, int index3, int index4,int order_horiz,int order_vert){{{1*/
     163                _error2_("Tria not supported yet");
     164        }
     165
     166}
     167/*}}}*/
     168/*FUNCTION GaussPenta::GaussPenta(int index1, int index2, int index3, int index4,int order_horiz,int order_vert){{{*/
    169169GaussPenta::GaussPenta(int index1, int index2, int index3, int index4,int order_horiz,int order_vert){
    170170
     
    182182        /*Allocate GaussPenta fields*/
    183183        numgauss=order_horiz*order_vert;
    184         coords1=(double*)xmalloc(numgauss*sizeof(double));
    185         coords2=(double*)xmalloc(numgauss*sizeof(double));
    186         coords3=(double*)xmalloc(numgauss*sizeof(double));
    187         coords4=(double*)xmalloc(numgauss*sizeof(double));
    188         weights=(double*)xmalloc(numgauss*sizeof(double));
     184        coords1=xNew<double>(numgauss);
     185        coords2=xNew<double>(numgauss);
     186        coords3=xNew<double>(numgauss);
     187        coords4=xNew<double>(numgauss);
     188        weights=xNew<double>(numgauss);
    189189
    190190        /*Quads: get the gauss points using the product of two line rules  */
     
    223223        }
    224224        else{
    225                 _error_("Tria not supported yet (user provided indices %i %i %i %i)",index1,index2,index3,index4);
     225                _error2_("Tria not supported yet (user provided indices " << index1 << " " << index2 << " " << index3 << " " << index4 << ")");
    226226        }
    227227
    228228        /*clean-up*/
    229         xfree((void**)&seg_horiz_coords);
    230         xfree((void**)&seg_horiz_weights);
    231         xfree((void**)&seg_vert_coords);
    232         xfree((void**)&seg_vert_weights);
    233 }
    234 /*}}}*/
    235 /*FUNCTION GaussPenta::~GaussPenta(){{{1*/
     229        xDelete<double>(seg_horiz_coords);
     230        xDelete<double>(seg_horiz_weights);
     231        xDelete<double>(seg_vert_coords);
     232        xDelete<double>(seg_vert_weights);
     233}
     234/*}}}*/
     235/*FUNCTION GaussPenta::~GaussPenta(){{{*/
    236236GaussPenta::~GaussPenta(){
    237         xfree((void**)&weights);
    238         xfree((void**)&coords1);
    239         xfree((void**)&coords2);
    240         xfree((void**)&coords3);
    241         xfree((void**)&coords4);
     237        xDelete<double>(weights);
     238        xDelete<double>(coords1);
     239        xDelete<double>(coords2);
     240        xDelete<double>(coords3);
     241        xDelete<double>(coords4);
    242242}
    243243/*}}}*/
    244244
    245245/*Methods*/
    246 /*FUNCTION GaussPenta::Echo{{{1*/
     246/*FUNCTION GaussPenta::Echo{{{*/
    247247void GaussPenta::Echo(void){
    248248
    249         printf("GaussPenta:\n");
    250         printf("   numgauss: %i\n",numgauss);
     249        _printLine_("GaussPenta:");
     250        _printLine_("   numgauss: " << numgauss);
    251251
    252252        if (weights){
    253          printf("   weights = [");
    254          for(int i=0;i<numgauss;i++) printf(" %g\n",weights[i]);
    255          printf("]\n");
    256         }
    257         else printf("weights = NULL\n");
     253         _printString_("   weights = [");
     254         for(int i=0;i<numgauss;i++) _printLine_(" " << weights[i]);
     255         _printLine_("]");
     256        }
     257        else _printLine_("weights = NULL");
    258258        if (coords1){
    259          printf("   coords1 = [");
    260          for(int i=0;i<numgauss;i++) printf(" %g\n",coords1[i]);
    261          printf("]\n");
    262         }
    263         else printf("coords1 = NULL\n");
     259         _printString_("   coords1 = [");
     260         for(int i=0;i<numgauss;i++) _printLine_(" " << coords1[i]);
     261         _printLine_("]");
     262        }
     263        else _printLine_("coords1 = NULL");
    264264        if (coords2){
    265          printf("   coords2 = [");
    266          for(int i=0;i<numgauss;i++) printf(" %g\n",coords2[i]);
    267          printf("]\n");
    268         }
    269         else printf("coords2 = NULL\n");
     265         _printString_("   coords2 = [");
     266         for(int i=0;i<numgauss;i++) _printLine_(" " << coords2[i]);
     267         _printLine_("]");
     268        }
     269        else _printLine_("coords2 = NULL");
    270270        if (coords3){
    271          printf("   coords3 = [");
    272          for(int i=0;i<numgauss;i++) printf(" %g\n",coords3[i]);
    273          printf("]\n");
    274         }
    275         else printf("coords3 = NULL\n");
     271         _printString_("   coords3 = [");
     272         for(int i=0;i<numgauss;i++) _printLine_(" " << coords3[i]);
     273         _printLine_("]");
     274        }
     275        else _printLine_("coords3 = NULL");
    276276        if (coords4){
    277                 printf("   coords4 = [");
    278                 for(int i=0;i<numgauss;i++) printf(" %g\n",coords4[i]);
    279                 printf("]\n");
    280         }
    281         else printf("coords4 = NULL\n");
    282 
    283         printf("   weight = %g\n",weight);
    284         printf("   coord1 = %g\n",coord1);
    285         printf("   coord2 = %g\n",coord2);
    286         printf("   coord3 = %g\n",coord3);
    287         printf("   coord4 = %g\n",coord4);
    288 
    289 }
    290 /*}}}*/
    291 /*FUNCTION GaussPenta::GaussCenter{{{1*/
     277                _printString_("   coords4 = [");
     278                for(int i=0;i<numgauss;i++) _printLine_(" " << coords4[i]);
     279                _printLine_("]");
     280        }
     281        else _printLine_("coords4 = NULL");
     282
     283        _printLine_("   weight = " << weight);
     284        _printLine_("   coord1 = " << coord1);
     285        _printLine_("   coord2 = " << coord2);
     286        _printLine_("   coord3 = " << coord3);
     287        _printLine_("   coord4 = " << coord4);
     288
     289}
     290/*}}}*/
     291/*FUNCTION GaussPenta::GaussCenter{{{*/
    292292void GaussPenta::GaussCenter(void){
    293293
     
    300300}
    301301/*}}}*/
    302 /*FUNCTION GaussPenta::GaussPoint{{{1*/
     302/*FUNCTION GaussPenta::GaussPoint{{{*/
    303303void GaussPenta::GaussPoint(int ig){
    304304
     
    315315}
    316316/*}}}*/
    317 /*FUNCTION GaussPenta::GaussVertex{{{1*/
     317/*FUNCTION GaussPenta::GaussVertex{{{*/
    318318void GaussPenta::GaussVertex(int iv){
    319319
     
    342342                        break;
    343343                default:
    344                         _error_("vertex index should be in [0 5]");
    345 
    346         }
    347 
    348 }
    349 /*}}}*/
    350 /*FUNCTION GaussPenta::GaussFaceTria{{{1*/
     344                        _error2_("vertex index should be in [0 5]");
     345
     346        }
     347
     348}
     349/*}}}*/
     350/*FUNCTION GaussPenta::GaussFaceTria{{{*/
    351351void GaussPenta::GaussFaceTria(int index1, int index2, int index3, int order){
    352352
     
    357357        if(index1==0 && index2==1 && index3==2){
    358358                GaussLegendreTria(&numgauss,&coords1,&coords2,&coords3,&weights,order);
    359                 coords4=(double*)xmalloc(numgauss*sizeof(double));
     359                coords4=xNew<double>(numgauss);
    360360                for(int i=0;i<numgauss;i++) coords4[i]=-1.0;
    361361        }
    362362        else{
    363                 _error_("Tria not supported yet");
    364         }
    365 
    366 }
    367 /*}}}*/
    368 /*FUNCTION GaussPenta::begin{{{1*/
     363                _error2_("Tria not supported yet");
     364        }
     365
     366}
     367/*}}}*/
     368/*FUNCTION GaussPenta::begin{{{*/
    369369int GaussPenta::begin(void){
    370370
     
    381381}
    382382/*}}}*/
    383 /*FUNCTION GaussPenta::end{{{1*/
     383/*FUNCTION GaussPenta::end{{{*/
    384384int GaussPenta::end(void){
    385385
     
    396396}
    397397/*}}}*/
    398 /*FUNCTION GaussPenta::SynchronizeGaussTria{{{1*/
     398/*FUNCTION GaussPenta::SynchronizeGaussTria{{{*/
    399399void GaussPenta::SynchronizeGaussTria(GaussTria* gauss_tria){
    400400
  • issm/trunk/src/c/objects/Gauss/GaussPenta.h

    r5797 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "./../../shared/shared.h"
    1111class GaussTria;
  • issm/trunk/src/c/objects/Gauss/GaussTria.cpp

    r6412 r12706  
    33 */
    44
    5 /*Include files: {{{1*/
     5/*Include files: {{{*/
    66#include "./../objects.h"
    77/*}}}*/
    88
    99/*GaussTria constructors and destructors:*/
    10 /*FUNCTION GaussTria::GaussTria() {{{1*/
     10/*FUNCTION GaussTria::GaussTria() {{{*/
    1111GaussTria::GaussTria(){
    1212
     
    2424}
    2525/*}}}*/
    26 /*FUNCTION GaussTria::GaussTria(int order) {{{1*/
     26/*FUNCTION GaussTria::GaussTria(int order) {{{*/
    2727GaussTria::GaussTria(int order){
    2828
     
    3838}
    3939/*}}}*/
    40 /*FUNCTION GaussTria::GaussTria(int index1,int index2,int order) {{{1*/
     40/*FUNCTION GaussTria::GaussTria(int index1,int index2,int order) {{{*/
    4141GaussTria::GaussTria(int index1,int index2,int order){
    4242
    4343        /*Intermediaties*/
    44         double *seg_coords  = NULL;
    45         double *seg_weights = NULL;
     44        IssmPDouble *seg_coords  = NULL;
     45        IssmPDouble *seg_weights = NULL;
    4646        int     i,index3;
    4747
     
    5151
    5252        /*Allocate GaussTria fields*/
    53         coords1=(double*)xmalloc(numgauss*sizeof(double));
    54         coords2=(double*)xmalloc(numgauss*sizeof(double));
    55         coords3=(double*)xmalloc(numgauss*sizeof(double));
    56         weights=(double*)xmalloc(numgauss*sizeof(double));
     53        coords1=xNew<IssmPDouble>(numgauss);
     54        coords2=xNew<IssmPDouble>(numgauss);
     55        coords3=xNew<IssmPDouble>(numgauss);
     56        weights=xNew<IssmPDouble>(numgauss);
    5757
    5858        /*Reverse index1 and 2 if necessary*/
     
    7171        else if (index1==0 && index2==2){
    7272                for(i=0;i<numgauss;i++) coords1[i]=  0.5*(1-seg_coords[i]);
    73                 for(i=0;i<numgauss;i++) coords2[i]=0;
     73                for(i=0;i<numgauss;i++) coords2[i]= 0 ;
    7474                for(i=0;i<numgauss;i++) coords3[i]=1-0.5*(1.-seg_coords[i]);
    7575                for(i=0;i<numgauss;i++) weights[i]=seg_weights[i];
     
    8282        }
    8383        else
    84          _error_("The 2 indices provided are not supported yet (user provided %i and %i)",index1,index2);
     84         _error2_("The 2 indices provided are not supported yet (user provided " << index1 << " and " << index2 << ")");
    8585
    8686        /*Initialize static fields as undefined*/
     
    9191
    9292        /*clean up*/
    93         xfree((void**)&seg_coords);
    94         xfree((void**)&seg_weights);
    95 }
    96 /*}}}*/
    97 /*FUNCTION GaussTria::~GaussTria(){{{1*/
     93        xDelete<double>(seg_coords);
     94        xDelete<double>(seg_weights);
     95}
     96/*}}}*/
     97/*FUNCTION GaussTria::~GaussTria(){{{*/
    9898GaussTria::~GaussTria(){
    99         xfree((void**)&weights);
    100         xfree((void**)&coords1);
    101         xfree((void**)&coords2);
    102         xfree((void**)&coords3);
     99        xDelete<IssmPDouble>(weights);
     100        xDelete<IssmPDouble>(coords1);
     101        xDelete<IssmPDouble>(coords2);
     102        xDelete<IssmPDouble>(coords3);
    103103}
    104104/*}}}*/
    105105
    106106/*Methods*/
    107 /*FUNCTION GaussTria::Echo{{{1*/
     107/*FUNCTION GaussTria::Echo{{{*/
    108108void GaussTria::Echo(void){
    109109
    110         printf("GaussTria:\n");
    111         printf("   numgauss: %i\n",numgauss);
     110        _printLine_("GaussTria:");
     111        _printLine_("   numgauss: " << numgauss);
    112112
    113113        if (weights){
    114          printf("   weights = [");
    115          for(int i=0;i<numgauss;i++) printf(" %g\n",weights[i]);
    116          printf("]\n");
    117         }
    118         else printf("weights = NULL\n");
     114         _printString_("   weights = [");
     115         for(int i=0;i<numgauss;i++) _printLine_(" " << weights[i]);
     116         _printLine_("]");
     117        }
     118        else _printLine_("weights = NULL");
    119119        if (coords1){
    120          printf("   coords1 = [");
    121          for(int i=0;i<numgauss;i++) printf(" %g\n",coords1[i]);
    122          printf("]\n");
    123         }
    124         else printf("coords1 = NULL\n");
     120         _printString_("   coords1 = [");
     121         for(int i=0;i<numgauss;i++) _printLine_(" " << coords1[i]);
     122         _printLine_("]");
     123        }
     124        else _printLine_("coords1 = NULL");
    125125        if (coords2){
    126          printf("   coords2 = [");
    127          for(int i=0;i<numgauss;i++) printf(" %g\n",coords2[i]);
    128          printf("]\n");
    129         }
    130         else printf("coords2 = NULL\n");
     126         _printString_("   coords2 = [");
     127         for(int i=0;i<numgauss;i++) _printLine_(" " << coords2[i]);
     128         _printLine_("]");
     129        }
     130        else _printLine_("coords2 = NULL");
    131131        if (coords3){
    132          printf("   coords3 = [");
    133          for(int i=0;i<numgauss;i++) printf(" %g\n",coords3[i]);
    134          printf("]\n");
    135         }
    136         else printf("coords3 = NULL\n");
    137 
    138         printf("   weight = %g\n",weight);
    139         printf("   coord1 = %g\n",coord1);
    140         printf("   coord2 = %g\n",coord2);
    141         printf("   coord3 = %g\n",coord3);
    142 
    143 }
    144 /*}}}*/
    145 /*FUNCTION GaussTria::GaussCenter{{{1*/
     132         _printString_("   coords3 = [");
     133         for(int i=0;i<numgauss;i++) _printLine_(" " << coords3[i]);
     134         _printLine_("]");
     135        }
     136        else _printLine_("coords3 = NULL");
     137
     138        _printLine_("   weight = " << weight);
     139        _printLine_("   coord1 = " << coord1);
     140        _printLine_("   coord2 = " << coord2);
     141        _printLine_("   coord3 = " << coord3);
     142
     143}
     144/*}}}*/
     145/*FUNCTION GaussTria::GaussCenter{{{*/
    146146void GaussTria::GaussCenter(void){
    147147
     
    153153}
    154154/*}}}*/
    155 /*FUNCTION GaussTria::GaussEdgeCenter{{{1*/
     155/*FUNCTION GaussTria::GaussEdgeCenter{{{*/
    156156void GaussTria::GaussEdgeCenter(int index1,int index2){
    157157
     
    180180        }
    181181        else
    182          _error_("The 2 indices provided are not supported yet (user provided %i and %i)",index1,index2);
    183 
    184 }
    185 /*}}}*/
    186 /*FUNCTION GaussTria::GaussPoint{{{1*/
     182         _error2_("The 2 indices provided are not supported yet (user provided " << index1 << " and " << index2 << ")");
     183
     184}
     185/*}}}*/
     186/*FUNCTION GaussTria::GaussPoint{{{*/
    187187void GaussTria::GaussPoint(int ig){
    188188
     
    198198}
    199199/*}}}*/
    200 /*FUNCTION GaussTria::GaussFromCoords{{{1*/
    201 void GaussTria::GaussFromCoords(double x,double y,double* xyz_list){
     200/*FUNCTION GaussTria::GaussFromCoords{{{*/
     201void GaussTria::GaussFromCoords(IssmPDouble x,IssmPDouble y,IssmPDouble* xyz_list){
    202202
    203203        /*Intermediaries*/
    204         double    area = 0;
    205         double    x1,y1,x2,y2,x3,y3;
     204        IssmPDouble    area = 0;
     205        IssmPDouble    x1,y1,x2,y2,x3,y3;
    206206
    207207        /*in debugging mode: check that the default constructor has been called*/
     
    225225}
    226226/*}}}*/
    227 /*FUNCTION GaussTria::GaussVertex{{{1*/
     227/*FUNCTION GaussTria::GaussVertex{{{*/
    228228void GaussTria::GaussVertex(int iv){
    229229
     
    243243                        break;
    244244                default:
    245                         _error_("vertex index should be in [0 2]");
    246 
    247         }
    248 
    249 }
    250 /*}}}*/
    251 /*FUNCTION GaussTria::begin{{{1*/
     245                        _error2_("vertex index should be in [0 2]");
     246
     247        }
     248
     249}
     250/*}}}*/
     251/*FUNCTION GaussTria::begin{{{*/
    252252int GaussTria::begin(void){
    253253
     
    263263}
    264264/*}}}*/
    265 /*FUNCTION GaussTria::end{{{1*/
     265/*FUNCTION GaussTria::end{{{*/
    266266int GaussTria::end(void){
    267267
  • issm/trunk/src/c/objects/Gauss/GaussTria.h

    r5739 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "./../../shared/shared.h"
    1111/*}}}*/
     
    1515        private:
    1616                int numgauss;
    17                 double* weights;
    18                 double* coords1;
    19                 double* coords2;
    20                 double* coords3;
     17                IssmPDouble* weights;
     18                IssmPDouble* coords1;
     19                IssmPDouble* coords2;
     20                IssmPDouble* coords3;
    2121
    2222        public:
    23                 double weight;
    24                 double coord1;
    25                 double coord2;
    26                 double coord3;
     23                IssmPDouble weight;
     24                IssmPDouble coord1;
     25                IssmPDouble coord2;
     26                IssmPDouble coord3;
    2727               
    2828        public:
     
    3838                int  end(void);
    3939                void Echo(void);
    40                 void GaussFromCoords(double x1,double y1,double* xyz_list);
     40                void GaussFromCoords(IssmPDouble x1,IssmPDouble y1,IssmPDouble* xyz_list);
    4141                void GaussPoint(int ig);
    4242                void GaussVertex(int iv);
  • issm/trunk/src/c/objects/Hook.cpp

    r12330 r12706  
    2020
    2121/*Constructor/Destructors*/
    22 /*FUNCTION Hook::Hook(){{{1*/
     22/*FUNCTION Hook::Hook(){{{*/
    2323Hook::Hook(){
    2424        this->num=0;
     
    2929}
    3030/*}}}*/
    31 /*FUNCTION Hook::Hook(int* ids, int num){{{1*/
     31/*FUNCTION Hook::Hook(int* ids, int num){{{*/
    3232Hook::Hook(int* in_ids, int in_num){
    3333
     
    4747        else{
    4848                /*Allocate: */
    49                 this->objects=(Object**)xmalloc(this->num*sizeof(Object*));
    50                 this->ids=(int*)xmalloc(this->num*sizeof(int));
    51                 this->offsets=(int*)xmalloc(this->num*sizeof(int));
     49                this->objects=xNew<Object*>(this->num);
     50                this->ids=xNew<int>(this->num);
     51                this->offsets=xNew<int>(this->num);
    5252
    5353                /*Copy ids: */
     
    6060}
    6161/*}}}*/
    62 /*FUNCTION Hook::~Hook(){{{1*/
     62/*FUNCTION Hook::~Hook(){{{*/
    6363Hook::~Hook(){
    6464        /*deallocate: */
    65         xfree((void**)&this->objects);
    66         xfree((void**)&this->ids);
    67         xfree((void**)&this->offsets);
     65        xDelete<Object*>(this->objects);
     66        xDelete<int>(this->ids);
     67        xDelete<int>(this->offsets);
    6868        return;
    6969}
     
    7171
    7272/*Some of the Object functionality: */
    73 /*FUNCTION Hook::Echo{{{1*/
     73/*FUNCTION Hook::Echo{{{*/
    7474void Hook::Echo(void){
    7575
    7676        int i;
    7777        if (num){
    78                 printf("   Hook: \n");
    79                 printf("      num=%i\n",this->num);
    80                 printf("      ids: ");
    81                 for (i=0;i<this->num;i++) printf("%i ",this->ids[i]);
    82                 printf("\n");
    83                 printf("      offsets: ");
    84                 for (i=0;i<this->num;i++) printf("%i ",this->offsets[i]);
    85                 printf("\n");
     78                _printLine_("   Hook: ");
     79                _printLine_("      num=" << this->num);
     80                _printString_("      ids: ");
     81                for (i=0;i<this->num;i++) _printString_(this->ids[i] << " ");
     82                _printLine_("");
     83                _printString_("      offsets: ");
     84                for (i=0;i<this->num;i++) _printString_(this->offsets[i] << " ");
     85                _printLine_("");
    8686        }
    8787        else{
    88                 printf("   Hook: num=0 \n");
    89         }
    90 }
    91 /*}}}*/
    92 /*FUNCTION Hook::DeepEcho{{{1*/
     88                _printLine_("   Hook: num=0 ");
     89        }
     90}
     91/*}}}*/
     92/*FUNCTION Hook::DeepEcho{{{*/
    9393void Hook::DeepEcho(void){
    9494
    9595        int i;
    9696        if (num){
    97                 printf("   Hook: \n");
    98                 printf("      num=%i\n",this->num);
    99                 printf("      ids: ");
    100                 for (i=0;i<this->num;i++) printf("%i ",this->ids[i]);
    101                 printf("\n");
    102                 printf("      offsets: ");
    103                 for (i=0;i<this->num;i++) printf("%i ",this->offsets[i]);
    104                 printf("\n");
    105                 if (!objects) printf("      warning: object not hooked yet\n");
     97                _printLine_("   Hook: ");
     98                _printLine_("      num=" << this->num);
     99                _printString_("      ids: ");
     100                for (i=0;i<this->num;i++) _printString_(this->ids[i] << " ");
     101                _printLine_("");
     102                _printString_("      offsets: ");
     103                for (i=0;i<this->num;i++) _printString_(this->offsets[i] << " ");
     104                _printLine_("");
     105                if (!objects) _printLine_("      warning: object not hooked yet");
    106106                else{
    107                         printf("      objects:\n   ");
     107                        _printString_("      objects:\n   ");
    108108                        for (i=0;i<this->num;i++){
    109                                 printf("         object %i\n",i);
     109                                _printLine_("         object " << i);
    110110                                if(objects[i]) objects[i]->DeepEcho();
    111                                 else           printf("            no object hooked yet (not configured)\n");
     111                                else           _printLine_("            no object hooked yet (not configured)");
    112112                        }
    113113                }
    114114        }
    115115        else{
    116                 printf("   Hook: num=0 \n");
    117         }
    118 }
    119 /*}}}*/
    120 /*FUNCTION Hook::copy {{{1*/
     116                _printLine_("   Hook: num=0 ");
     117        }
     118}
     119/*}}}*/
     120/*FUNCTION Hook::copy {{{*/
    121121Object* Hook::copy(void){
    122122
     
    132132        output->num=this->num;
    133133        if(output->num){
    134                 output->objects=(Object**)xmalloc(output->num*sizeof(Object*));
    135                 output->ids=(int*)xmalloc(output->num*sizeof(int));
    136                 output->offsets=(int*)xmalloc(output->num*sizeof(int));
     134                output->objects=xNew<Object*>(output->num);
     135                output->ids=xNew<int>(output->num);
     136                output->offsets=xNew<int>(output->num);
    137137        }
    138138       
     
    148148
    149149/*Hook management: */
    150 /*FUNCTION Hook::configure{{{1*/
     150/*FUNCTION Hook::configure{{{*/
    151151void Hook::configure(DataSet* dataset){
    152152
     
    185185                        this->objects[i]=(Object*)dataset->GetObjectById(this->offsets+i,this->ids[i]); //remember the offset for later on.
    186186                        /*check the id is correct!: */
    187                         if (this->objects[i]->Id()!=this->ids[i]) _error_("%s%i%s%i%s"," wrong id: ",this->objects[i]->Id()," vs ",this->ids[i],"  in resolved pointer!");
    188                 }
    189         }
    190 }
    191 /*}}}*/
    192 /*FUNCTION Hook::delivers{{{1*/
     187                        if (this->objects[i]->Id()!=this->ids[i]) _error2_("wrong id: " << this->objects[i]->Id() << " vs " << this->ids[i] << "  in resolved pointer!");
     188                }
     189        }
     190}
     191/*}}}*/
     192/*FUNCTION Hook::delivers{{{*/
    193193Object* Hook::delivers(void){
    194194       
    195195        /*first, check that we only have one T object in our object list: */
    196         if (this->num!=1) _error_("%s%i%s\n"," trying to delivery a single hook object when hook holds ",this->num," objects");
     196        if (this->num!=1) _error2_("trying to delivery a single hook object when hook holds " << this->num << " objects" << "\n");
    197197
    198198        /*check NULL: */
    199         if (this->objects==NULL) _error_("hook is not pointing to any object, objects pointer is NULL");
     199        if (this->objects==NULL) _error2_("hook is not pointing to any object, objects pointer is NULL");
    200200
    201201        return *objects;
     
    203203
    204204/*}}}*/
    205 /*FUNCTION Hook::deliverp{{{1*/
     205/*FUNCTION Hook::deliverp{{{*/
    206206Object** Hook::deliverp(void){
    207207        return objects;
    208208}
    209209/*}}}*/
    210 /*FUNCTION Hook::Ids{{{1*/
     210/*FUNCTION Hook::Ids{{{*/
    211211int* Hook::Ids(void){
    212212        return this->ids;
    213213}
    214214/*}}}*/
    215 /*FUNCTION Hook::GetNum{{{1*/
     215/*FUNCTION Hook::GetNum{{{*/
    216216int Hook::GetNum(void){
    217217        return this->num;
    218218}
    219219/*}}}*/
    220 /*FUNCTION Hook::GetObjects{{{1*/
     220/*FUNCTION Hook::GetObjects{{{*/
    221221Object** Hook::GetObjects(void){
    222222        return this->objects;
    223223}
    224224/*}}}*/
    225 /*FUNCTION Hook::GetOffsets{{{1*/
     225/*FUNCTION Hook::GetOffsets{{{*/
    226226int* Hook::GetOffsets(void){
    227227        return this->offsets;
    228228}
    229229/*}}}*/
    230 /*FUNCTION Hook::Spawn{{{1*/
     230/*FUNCTION Hook::Spawn{{{*/
    231231Hook* Hook::Spawn(int* indices, int numindices){
    232232
     
    246246
    247247        /*Else, check that we are requesting a half of num*/
    248         if (numindices>this->num) _error_("Cannot spawn hook with %i objects from a Hook of %i objects",numindices,this->num);
     248        if (numindices>this->num) _error2_("Cannot spawn hook with " << numindices << " objects from a Hook of " << this->num << " objects");
    249249
    250250        /*go pickup the correct objects, ids and offsets :*/
    251251        output->num=numindices;
    252         if(output->num<1) _error_("Trying to spawn an empty ElementProperties!");
    253 
    254         output->objects=(Object**)xmalloc(output->num*sizeof(Object*));
    255         output->ids=(int*)xmalloc(output->num*sizeof(int));
    256         output->offsets=(int*)xmalloc(output->num*sizeof(int));
     252        if(output->num<1) _error2_("Trying to spawn an empty ElementProperties!");
     253
     254        output->objects=xNew<Object*>(output->num);
     255        output->ids=xNew<int>(output->num);
     256        output->offsets=xNew<int>(output->num);
    257257
    258258        for(i=0;i<output->num;i++){
  • issm/trunk/src/c/objects/Hook.h

    r12330 r12706  
    1010
    1111/*Headers:*/
    12 /*{{{1*/
     12/*{{{*/
    1313#include "./Object.h"
    1414class DataSet;
     
    3131                ~Hook();
    3232                /*}}}*/
    33                 /*Object like functionality:{{{1*/
     33                /*Object like functionality:{{{*/
    3434                void       Echo(void);
    3535                void       DeepEcho(void);
    3636                Object*    copy(void);
    3737                /*}}}*/
    38                 /*Hook management: {{{1*/
     38                /*Hook management: {{{*/
    3939                Object*    delivers(void); //single object deliver
    4040                Object**   deliverp(void); //deliver all objects
  • issm/trunk/src/c/objects/Inputs/BoolInput.cpp

    r12330 r12706  
    1818
    1919/*BoolInput constructors and destructor*/
    20 /*FUNCTION BoolInput::BoolInput(){{{1*/
     20/*FUNCTION BoolInput::BoolInput(){{{*/
    2121BoolInput::BoolInput(){
    2222        return;
    2323}
    2424/*}}}*/
    25 /*FUNCTION BoolInput::BoolInput(double* values){{{1*/
     25/*FUNCTION BoolInput::BoolInput(IssmDouble* values){{{*/
    2626BoolInput::BoolInput(int in_enum_type,IssmBool in_value){
    2727
     
    3030}
    3131/*}}}*/
    32 /*FUNCTION BoolInput::~BoolInput(){{{1*/
     32/*FUNCTION BoolInput::~BoolInput(){{{*/
    3333BoolInput::~BoolInput(){
    3434        return;
     
    3737
    3838/*Object virtual functions definitions:*/
    39 /*FUNCTION BoolInput::Echo {{{1*/
     39/*FUNCTION BoolInput::Echo {{{*/
    4040void BoolInput::Echo(void){
    4141        this->DeepEcho();
    4242}
    4343/*}}}*/
    44 /*FUNCTION BoolInput::DeepEcho{{{1*/
     44/*FUNCTION BoolInput::DeepEcho{{{*/
    4545void BoolInput::DeepEcho(void){
    4646
    47         printf("BoolInput:\n");
    48         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    49         printf("   value: %s\n",value?"true":"false");
     47        _printLine_("BoolInput:");
     48        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     49        _printLine_("   value: " <<(value?"true":"false"));
    5050}
    5151/*}}}*/
    52 /*FUNCTION BoolInput::Id{{{1*/
     52/*FUNCTION BoolInput::Id{{{*/
    5353int    BoolInput::Id(void){ return -1; }
    5454/*}}}*/
    55 /*FUNCTION BoolInput::MyRank{{{1*/
     55/*FUNCTION BoolInput::MyRank{{{*/
    5656int    BoolInput::MyRank(void){
    5757        extern int my_rank;
     
    5959}
    6060/*}}}*/
    61 /*FUNCTION BoolInput::ObjectEnum{{{1*/
     61/*FUNCTION BoolInput::ObjectEnum{{{*/
    6262int BoolInput::ObjectEnum(void){
    6363
     
    6666}
    6767/*}}}*/
    68 /*FUNCTION BoolInput::copy{{{1*/
     68/*FUNCTION BoolInput::copy{{{*/
    6969Object* BoolInput::copy() {
    7070       
     
    7575       
    7676/*BoolInput management*/
    77 /*FUNCTION BoolInput::InstanceEnum{{{1*/
     77/*FUNCTION BoolInput::InstanceEnum{{{*/
    7878int BoolInput::InstanceEnum(void){
    7979
     
    8282}
    8383/*}}}*/
    84 /*FUNCTION BoolInput::SpawnTriaInput{{{1*/
     84/*FUNCTION BoolInput::SpawnTriaInput{{{*/
    8585Input* BoolInput::SpawnTriaInput(int* indices){
    8686
     
    9797}
    9898/*}}}*/
    99 /*FUNCTION BoolInput::SpawnResult{{{1*/
    100 ElementResult* BoolInput::SpawnResult(int step, double time){
     99/*FUNCTION BoolInput::SpawnResult{{{*/
     100ElementResult* BoolInput::SpawnResult(int step, IssmDouble time){
    101101       
    102102        return new BoolElementResult(this->enum_type,this->value,step,time);
     
    106106
    107107/*Object functions*/
    108 /*FUNCTION BoolInput::GetInputValue(bool* pvalue) {{{1*/
     108/*FUNCTION BoolInput::GetInputValue(bool* pvalue) {{{*/
    109109void BoolInput::GetInputValue(bool* pvalue){
    110110        *pvalue=value;
    111111}
    112112/*}}}*/
    113 /*FUNCTION BoolInput::GetInputValue(int* pvalue){{{1*/
    114 void BoolInput::GetInputValue(int* pvalue){_error_(" not supported yet!");}
     113/*FUNCTION BoolInput::GetInputValue(int* pvalue){{{*/
     114void BoolInput::GetInputValue(int* pvalue){_error2_("not supported yet!");}
    115115/*}}}*/
    116 /*FUNCTION BoolInput::GetInputValue(double* pvalue){{{1*/
    117 void BoolInput::GetInputValue(double* pvalue){_error_(" not supported yet!");}
     116/*FUNCTION BoolInput::GetInputValue(IssmDouble* pvalue){{{*/
     117void BoolInput::GetInputValue(IssmDouble* pvalue){_error2_("not supported yet!");}
    118118/*}}}*/
    119 /*FUNCTION BoolInput::GetInputValue(double* pvalue,GaussTria* gauss){{{1*/
    120 void BoolInput::GetInputValue(double* pvalue,GaussTria* gauss){_error_(" not supported yet!");}
     119/*FUNCTION BoolInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss){{{*/
     120void BoolInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss){_error2_("not supported yet!");}
    121121/*}}}*/
    122 /*FUNCTION BoolInput::GetInputValue(double* pvalue,GaussPenta* gauss){{{1*/
    123 void BoolInput::GetInputValue(double* pvalue,GaussPenta* gauss){_error_(" not supported yet!");}
     122/*FUNCTION BoolInput::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){{{*/
     123void BoolInput::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){_error2_("not supported yet!");}
    124124/*}}}*/
    125 /*FUNCTION BoolInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss){{{1*/
    126 void BoolInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss){_error_(" not supported yet!");}
     125/*FUNCTION BoolInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss){{{*/
     126void BoolInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss){_error2_("not supported yet!");}
    127127/*}}}*/
    128 /*FUNCTION BoolInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss){{{1*/
    129 void BoolInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss){_error_(" not supported yet!");}
     128/*FUNCTION BoolInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss){{{*/
     129void BoolInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not supported yet!");}
    130130/*}}}*/
    131 /*FUNCTION BoolInput::ChangeEnum{{{1*/
     131/*FUNCTION BoolInput::ChangeEnum{{{*/
    132132void BoolInput::ChangeEnum(int newenumtype){
    133133        this->enum_type=newenumtype;
    134134}
    135135/*}}}*/
    136 /*FUNCTION BoolInput::SquareMin{{{1*/
    137 void BoolInput::SquareMin(double* psquaremin, bool process_units,Parameters* parameters){
     136/*FUNCTION BoolInput::SquareMin{{{*/
     137void BoolInput::SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters){
    138138        /*square of a bool is the bool itself: */
    139139        *psquaremin=value;
    140140}
    141141/*}}}*/
    142 /*FUNCTION BoolInput::Scale{{{1*/
    143 void BoolInput::Scale(double scale_factor){
     142/*FUNCTION BoolInput::Scale{{{*/
     143void BoolInput::Scale(IssmDouble scale_factor){
    144144        /*a bool cannot be scaled: */
    145145}
    146146/*}}}*/
    147 /*FUNCTION BoolInput::AXPY{{{1*/
    148 void BoolInput::AXPY(Input* xinput,double scalar){
     147/*FUNCTION BoolInput::AXPY{{{*/
     148void BoolInput::AXPY(Input* xinput,IssmDouble scalar){
    149149
    150150        BoolInput*  xboolinput=NULL;
     
    157157
    158158                case BoolInputEnum:
    159                         this->value=(bool)(this->value+scalar*xboolinput->value);
     159                        this->value=reCast<bool,IssmDouble>(this->value+scalar*xboolinput->value);
    160160                        return;
    161161
    162162                default:
    163                         _error_("not implemented yet");
     163                        _error2_("not implemented yet");
    164164        }
    165165
    166166}
    167167/*}}}*/
    168 /*FUNCTION BoolInput::Constrain{{{1*/
    169 void BoolInput::Constrain(double cm_min, double cm_max){
    170 
    171         if(!isnan(cm_min)) if (this->value<cm_min)this->value=cm_min;
    172         if(!isnan(cm_max)) if (this->value>cm_max)this->value=cm_max;
    173 
    174 }
    175 /*}}}*/
    176 /*FUNCTION BoolInput::Extrude{{{1*/
     168/*FUNCTION BoolInput::Extrude{{{*/
    177169void BoolInput::Extrude(void){
    178170
     
    181173}
    182174/*}}}*/
    183 /*FUNCTION BoolInput::GetVectorFromInputs{{{1*/
     175/*FUNCTION BoolInput::GetVectorFromInputs{{{*/
    184176void BoolInput::GetVectorFromInputs(Vector* vector,int* doflist){
    185177
    186         _error_(" not supporte yet!");
     178        _error2_("not supporte yet!");
    187179
    188180}
    189181/*}}}*/
    190 /*FUNCTION BoolInput::GetValuesPtr{{{1*/
    191 void BoolInput::GetValuesPtr(double** pvalues,int* pnum_values){
     182/*FUNCTION BoolInput::GetValuesPtr{{{*/
     183void BoolInput::GetValuesPtr(IssmDouble** pvalues,int* pnum_values){
    192184
    193         _error_(" not supported yet!");
     185        _error2_("not supported yet!");
    194186
    195187}
    196188/*}}}*/
    197 /*FUNCTION BoolInput::Configure{{{1*/
     189/*FUNCTION BoolInput::Configure{{{*/
    198190void BoolInput::Configure(Parameters* parameters){
    199191        /*do nothing: */
  • issm/trunk/src/c/objects/Inputs/BoolInput.h

    r12358 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111#include "./Input.h"
    1212#include "../../include/include.h"
     
    2121                IssmBool value;
    2222
    23                 /*BoolInput constructors, destructors: {{{1*/
     23                /*BoolInput constructors, destructors: {{{*/
    2424                BoolInput();
    2525                BoolInput(int enum_type,IssmBool value);
    2626                ~BoolInput();
    2727                /*}}}*/
    28                 /*Object virtual functions definitions:{{{1 */
     28                /*Object virtual functions definitions:{{{ */
    2929                void  Echo();
    3030                void  DeepEcho();
     
    3434                Object* copy();
    3535                /*}}}*/
    36                 /*BoolInput management: {{{1*/
     36                /*BoolInput management: {{{*/
    3737                int   InstanceEnum();
    3838                Input* SpawnTriaInput(int* indices);
    39                 Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
    40                 Input* PointwiseMin(Input* inputB){_error_("not implemented yet");};
    41                 Input* PointwiseMax(Input* inputB){_error_("not implemented yet");};
    42                 ElementResult* SpawnResult(int step, double time);
     39                Input* PointwiseDivide(Input* inputB){_error2_("not implemented yet");};
     40                Input* PointwiseMin(Input* inputB){_error2_("not implemented yet");};
     41                Input* PointwiseMax(Input* inputB){_error2_("not implemented yet");};
     42                ElementResult* SpawnResult(int step, IssmDouble time);
    4343                void Configure(Parameters* parameters);
    44                 void AddTimeValues(double* values,int step,double time){_error_("not supported yet");};
     44                void AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error2_("not supported yet");};
    4545                /*}}}*/
    46                 /*numerics: {{{1*/
     46                /*numerics: {{{*/
    4747                void GetInputValue(bool* pvalue);
    4848                void GetInputValue(int* pvalue);
    49                 void GetInputValue(double* pvalue);
    50                 void GetInputValue(double* pvalue,GaussTria* gauss);
    51                 void GetInputValue(double* pvalue,GaussPenta* gauss);
    52                 void GetInputValue(double* pvalue,GaussTria* gauss,double time){_error_("not implemented yet");};
    53                 void GetInputValue(double* pvalue,GaussPenta* gauss,double time){_error_("not implemented yet");};
    54                 void GetInputValue(double* pvalue,GaussTria* gauss ,int index){_error_("not implemented yet");};
    55                 void GetInputValue(double* pvalue,GaussPenta* gauss ,int index){_error_("not implemented yet");};
    56                 void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss);
    57                 void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss);
    58                 void GetInputAverage(double* pvalue){_error_("not implemented yet");};
    59                 void GetVxStrainRate2d(double* epsilonvx,double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
    60                 void GetVyStrainRate2d(double* epsilonvy,double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
    61                 void GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
    62                 void GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
    63                 void GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
    64                 void GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
    65                 void GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
     49                void GetInputValue(IssmDouble* pvalue);
     50                void GetInputValue(IssmDouble* pvalue,GaussTria* gauss);
     51                void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss);
     52                void GetInputValue(IssmDouble* pvalue,GaussTria* gauss,IssmDouble time){_error2_("not implemented yet");};
     53                void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,IssmDouble time){_error2_("not implemented yet");};
     54                void GetInputValue(IssmDouble* pvalue,GaussTria* gauss ,int index){_error2_("not implemented yet");};
     55                void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss ,int index){_error2_("not implemented yet");};
     56                void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss);
     57                void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss);
     58                void GetInputAverage(IssmDouble* pvalue){_error2_("not implemented yet");};
     59                void GetVxStrainRate2d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussTria* gauss){_error2_("not implemented yet");};
     60                void GetVyStrainRate2d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussTria* gauss){_error2_("not implemented yet");};
     61                void GetVxStrainRate3d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
     62                void GetVyStrainRate3d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
     63                void GetVzStrainRate3d(IssmDouble* epsilonvz,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
     64                void GetVxStrainRate3dPattyn(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
     65                void GetVyStrainRate3dPattyn(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
    6666                void ChangeEnum(int newenumtype);
    67                 void SquareMin(double* psquaremin, bool process_units,Parameters* parameters);
    68                 void ConstrainMin(double minimum){_error_("not implemented yet");};
    69                 double InfinityNorm(void){_error_("InfinityNorm not implemented for booleans");};
    70                 double Max(void){_error_("Max not implemented for booleans");};
    71                 double MaxAbs(void){_error_("Max not implemented for booleans");};
    72                 double Min(void){_error_("Min not implemented for booleans");};
    73                 double MinAbs(void){_error_("Min not implemented for booleans");};
    74                 void Scale(double scale_factor);
    75                 void ArtificialNoise(double min,double max){_error_("not implemented yet");};
    76                 void AXPY(Input* xinput,double scalar);
    77                 void Constrain(double cm_min, double cm_max);
     67                void SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters);
     68                void ConstrainMin(IssmDouble minimum){_error2_("not implemented yet");};
     69                IssmDouble InfinityNorm(void){_error2_("InfinityNorm not implemented for booleans");};
     70                IssmDouble Max(void){_error2_("Max not implemented for booleans");};
     71                IssmDouble MaxAbs(void){_error2_("Max not implemented for booleans");};
     72                IssmDouble Min(void){_error2_("Min not implemented for booleans");};
     73                IssmDouble MinAbs(void){_error2_("Min not implemented for booleans");};
     74                void Scale(IssmDouble scale_factor);
     75                void ArtificialNoise(IssmDouble min,IssmDouble max){_error2_("not implemented yet");};
     76                void AXPY(Input* xinput,IssmDouble scalar);
     77                void Constrain(IssmDouble cm_min, IssmDouble cm_max){_error2_("Constrain not implemented for booleans");};
    7878                void Extrude(void);
    79                 void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");};
     79                void VerticallyIntegrate(Input* thickness_input){_error2_("not supported yet");};
    8080                void GetVectorFromInputs(Vector* vector,int* doflist);
    81                 void GetValuesPtr(double** pvalues,int* pnum_values);
     81                void GetValuesPtr(IssmDouble** pvalues,int* pnum_values);
    8282                /*}}}*/
    8383
  • issm/trunk/src/c/objects/Inputs/ControlInput.cpp

    r12330 r12706  
    1818
    1919/*ControlInput constructors and destructor*/
    20 /*FUNCTION ControlInput::ControlInput(){{{1*/
     20/*FUNCTION ControlInput::ControlInput(){{{*/
    2121ControlInput::ControlInput(){
    2222        control_id  = 0;
     
    2828}
    2929/*}}}*/
    30 /*FUNCTION ControlInput::ControlInput(int enum_type,int enum_input,double* pvalues,double* pmin,double* pmax,int id){{{1*/
    31 ControlInput::ControlInput(int in_enum_type,int enum_input,double* pvalues,double* pmin,double* pmax,int id){
     30/*FUNCTION ControlInput::ControlInput(int enum_type,int enum_input,IssmDouble* pvalues,IssmDouble* pmin,IssmDouble* pmax,int id){{{*/
     31ControlInput::ControlInput(int in_enum_type,int enum_input,IssmDouble* pvalues,IssmDouble* pmin,IssmDouble* pmax,int id){
    3232
    3333        control_id=id;
     
    4848                        break;
    4949                default:
    50                         _error_("Input of Enum %s not supported yet by ControlInput",EnumToStringx(enum_input));
     50                        _error2_("Input of Enum " << EnumToStringx(enum_input) << " not supported yet by ControlInput");
    5151        }
    5252        gradient   =NULL;
    5353}
    5454/*}}}*/
    55 /*FUNCTION ControlInput::~ControlInput(){{{1*/
     55/*FUNCTION ControlInput::~ControlInput(){{{*/
    5656ControlInput::~ControlInput(){
    5757        delete values;
     
    6464
    6565/*Object virtual functions definitions:*/
    66                 /*FUNCTION ControlInput::Echo {{{1*/
     66                /*FUNCTION ControlInput::Echo {{{*/
    6767void ControlInput::Echo(void){
    6868        this->DeepEcho();
    6969}
    7070/*}}}*/
    71 /*FUNCTION ControlInput::DeepEcho{{{1*/
     71/*FUNCTION ControlInput::DeepEcho{{{*/
    7272void ControlInput::DeepEcho(void){
    7373
    74         printf("ControlInput:\n");
    75         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    76         printf("---values: \n");     if (values)      values->Echo();
    77         printf("---savedvalues: \n");if (savedvalues) savedvalues->Echo();
    78         printf("---minvalues: \n");  if (minvalues)   minvalues->Echo();
    79         printf("---maxvalues: \n");  if (maxvalues)   maxvalues->Echo();
    80         printf("---gradient: \n");   if (gradient)    gradient->Echo();
    81 }
    82 /*}}}*/
    83 /*FUNCTION ControlInput::Id{{{1*/
     74        _printLine_("ControlInput:");
     75        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     76        _printLine_("---values: ");     if (values)      values->Echo();
     77        _printLine_("---savedvalues: ");if (savedvalues) savedvalues->Echo();
     78        _printLine_("---minvalues: ");  if (minvalues)   minvalues->Echo();
     79        _printLine_("---maxvalues: ");  if (maxvalues)   maxvalues->Echo();
     80        _printLine_("---gradient: ");   if (gradient)    gradient->Echo();
     81}
     82/*}}}*/
     83/*FUNCTION ControlInput::Id{{{*/
    8484int    ControlInput::Id(void){ return -1; }
    8585/*}}}*/
    86 /*FUNCTION ControlInput::MyRank{{{1*/
     86/*FUNCTION ControlInput::MyRank{{{*/
    8787int    ControlInput::MyRank(void){
    8888        extern int my_rank;
     
    9090}
    9191/*}}}*/
    92 /*FUNCTION ControlInput::ObjectEnum{{{1*/
     92/*FUNCTION ControlInput::ObjectEnum{{{*/
    9393int ControlInput::ObjectEnum(void){
    9494
     
    9797}
    9898/*}}}*/
    99 /*FUNCTION ControlInput::copy{{{1*/
     99/*FUNCTION ControlInput::copy{{{*/
    100100Object* ControlInput::copy() {
    101101       
     
    117117       
    118118/*ControlInput management*/
    119 /*FUNCTION ControlInput::InstanceEnum{{{1*/
     119/*FUNCTION ControlInput::InstanceEnum{{{*/
    120120int ControlInput::InstanceEnum(void){
    121121
     
    126126
    127127/*Object functions*/
    128 /*FUNCTION ControlInput::Constrain(){{{1*/
     128/*FUNCTION ControlInput::Constrain(){{{*/
    129129void ControlInput::Constrain(void){
    130130
     
    136136        delete values; this->values=newvalues;
    137137}/*}}}*/
    138 /*FUNCTION ControlInput::Constrain(double min, double max){{{1*/
    139 void ControlInput::Constrain(double min, double max){
     138/*FUNCTION ControlInput::Constrain(IssmDouble min, IssmDouble max){{{*/
     139void ControlInput::Constrain(IssmDouble min, IssmDouble max){
    140140           values->Constrain(min,max);
    141141}/*}}}*/
    142 /*FUNCTION ControlInput::Extrude{{{1*/
     142/*FUNCTION ControlInput::Extrude{{{*/
    143143void ControlInput::Extrude(void){
    144144        values->Extrude();
     
    146146        //gradient->Extrude();
    147147}/*}}}*/
    148 /*FUNCTION ControlInput::GetGradient{{{1*/
     148/*FUNCTION ControlInput::GetGradient{{{*/
    149149void ControlInput::GetGradient(Vector* gradient_vec,int* doflist){
    150150        if(gradient) gradient->GetVectorFromInputs(gradient_vec,doflist);
    151151}/*}}}*/
    152 /*FUNCTION ControlInput::ScaleGradient{{{1*/
    153 void ControlInput::ScaleGradient(double scaling_factor){
    154         if(!gradient) _error_("Gradient of ControlInput %s not found",EnumToStringx(enum_type));
     152/*FUNCTION ControlInput::ScaleGradient{{{*/
     153void ControlInput::ScaleGradient(IssmDouble scaling_factor){
     154        if(!gradient) _error2_("Gradient of ControlInput " << EnumToStringx(enum_type) << " not found");
    155155        gradient->Scale(scaling_factor);
    156156}/*}}}*/
    157 /*FUNCTION ControlInput::SetGradient{{{1*/
     157/*FUNCTION ControlInput::SetGradient{{{*/
    158158void ControlInput::SetGradient(Input* gradient_in){
    159159
     
    170170                        break;
    171171                default:
    172                         _error_("more than 3 controls not implemented yet (Gradient %i was requested). EnumDefinitions.h needs to be updated.",this->control_id);
     172                        _error2_("more than 3 controls not implemented yet (Gradient " << this->control_id << " was requested). EnumDefinitions.h needs to be updated.");
    173173        }
    174174
     
    178178
    179179}/*}}}*/
    180 /*FUNCTION ControlInput::SetInput{{{1*/
     180/*FUNCTION ControlInput::SetInput{{{*/
    181181void ControlInput::SetInput(Input* in_input){
    182182
     
    185185
    186186}/*}}}*/
    187 /*FUNCTION ControlInput::SpawnResult{{{1*/
    188 ElementResult* ControlInput::SpawnResult(int step, double time){
     187/*FUNCTION ControlInput::SpawnResult{{{*/
     188ElementResult* ControlInput::SpawnResult(int step, IssmDouble time){
    189189        return savedvalues->SpawnResult(step,time);
    190190}/*}}}*/
    191 /*FUNCTION ControlInput::SpawnTriaInput{{{1*/
     191/*FUNCTION ControlInput::SpawnTriaInput{{{*/
    192192Input* ControlInput::SpawnTriaInput(int* indices){
    193193        return values->SpawnTriaInput(indices);
    194194}/*}}}*/
    195 /*FUNCTION ControlInput::SpawnGradient{{{1*/
    196 ElementResult* ControlInput::SpawnGradient(int step, double time){
     195/*FUNCTION ControlInput::SpawnGradient{{{*/
     196ElementResult* ControlInput::SpawnGradient(int step, IssmDouble time){
    197197        _assert_(gradient);
    198198        return gradient->SpawnResult(step,time);
    199199}/*}}}*/
    200 /*FUNCTION ControlInput::GetVectorFromInputs(Vector* vector,int* doflist){{{1*/
     200/*FUNCTION ControlInput::GetVectorFromInputs(Vector* vector,int* doflist){{{*/
    201201void ControlInput::GetVectorFromInputs(Vector* vector,int* doflist){
    202202        values->GetVectorFromInputs(vector,doflist);
    203203}/*}}}*/
    204 /*FUNCTION ControlInput::GetVectorFromInputs(Vector* vector,int* doflist,const char* data){{{1*/
     204/*FUNCTION ControlInput::GetVectorFromInputs(Vector* vector,int* doflist,const char* data){{{*/
    205205void ControlInput::GetVectorFromInputs(Vector* vector,int* doflist,const char* data){
    206206         if(strcmp(data,"value")==0){
     
    221221         }
    222222         else{
    223                  _error_("Data %s not supported yet",data);
    224          }
    225 }/*}}}*/
    226 /*FUNCTION ControlInput::GetInputAverage(double* pvalue){{{1*/
    227 void ControlInput::GetInputAverage(double* pvalue){
     223                 _error2_("Data " << data << " not supported yet");
     224         }
     225}/*}}}*/
     226/*FUNCTION ControlInput::GetInputAverage(IssmDouble* pvalue){{{*/
     227void ControlInput::GetInputAverage(IssmDouble* pvalue){
    228228        values->GetInputAverage(pvalue);
    229229}/*}}}*/
    230 /*FUNCTION ControlInput::GetInputValue(bool* pvalue){{{1*/
     230/*FUNCTION ControlInput::GetInputValue(bool* pvalue){{{*/
    231231void ControlInput::GetInputValue(bool* pvalue){
    232232        values->GetInputValue(pvalue);
    233233}/*}}}*/
    234 /*FUNCTION ControlInput::GetInputValue(int* pvalue){{{1*/
     234/*FUNCTION ControlInput::GetInputValue(int* pvalue){{{*/
    235235void ControlInput::GetInputValue(int* pvalue){
    236236        values->GetInputValue(pvalue);
    237237}/*}}}*/
    238 /*FUNCTION ControlInput::GetInputValue(double* pvalue){{{1*/
    239 void ControlInput::GetInputValue(double* pvalue){
     238/*FUNCTION ControlInput::GetInputValue(IssmDouble* pvalue){{{*/
     239void ControlInput::GetInputValue(IssmDouble* pvalue){
    240240        values->GetInputValue(pvalue);
    241241}/*}}}*/
    242 /*FUNCTION ControlInput::GetInputValue(double* pvalue){{{1*/
    243 void ControlInput::GetInputValue(double* pvalue,GaussTria* gauss){
     242/*FUNCTION ControlInput::GetInputValue(IssmDouble* pvalue){{{*/
     243void ControlInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss){
    244244        values->GetInputValue(pvalue,gauss);
    245245}/*}}}*/
    246 /*FUNCTION ControlInput::GetInputValue(double* pvalue){{{1*/
    247 void ControlInput::GetInputValue(double* pvalue,GaussPenta* gauss){
     246/*FUNCTION ControlInput::GetInputValue(IssmDouble* pvalue){{{*/
     247void ControlInput::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){
    248248        values->GetInputValue(pvalue,gauss);
    249249}/*}}}*/
    250 /*FUNCTION ControlInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss){{{1*/
    251 void ControlInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss){
     250/*FUNCTION ControlInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss){{{*/
     251void ControlInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss){
    252252        values->GetInputDerivativeValue(derivativevalues,xyz_list,gauss);
    253253}/*}}}*/
    254 /*FUNCTION ControlInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss){{{1*/
    255 void ControlInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss){
     254/*FUNCTION ControlInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss){{{*/
     255void ControlInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss){
    256256        values->GetInputDerivativeValue(derivativevalues,xyz_list,gauss);
    257257}/*}}}*/
    258 /*FUNCTION ControlInput::SaveValue{{{1*/
     258/*FUNCTION ControlInput::SaveValue{{{*/
    259259void ControlInput::SaveValue(void){
    260         if(!values) _error_("Values of %s not found",EnumToStringx(this->enum_type));
     260        if(!values) _error2_("Values of " << EnumToStringx(this->enum_type) << " not found");
    261261
    262262        if(savedvalues) delete this->savedvalues;
    263263        this->savedvalues=(Input*)this->values->copy();
    264264}/*}}}*/
    265 /*FUNCTION ControlInput::UpdateValue{{{1*/
    266 void ControlInput::UpdateValue(double scalar){
    267         if(!gradient)    _error_("Gradient of %s not found",EnumToStringx(this->enum_type));
    268         if(!savedvalues) _error_("Values of %s not found",EnumToStringx(this->enum_type));
     265/*FUNCTION ControlInput::UpdateValue{{{*/
     266void ControlInput::UpdateValue(IssmDouble scalar){
     267        if(!gradient)    _error2_("Gradient of " << EnumToStringx(this->enum_type) << " not found");
     268        if(!savedvalues) _error2_("Values of " << EnumToStringx(this->enum_type) << " not found");
    269269
    270270        if(values) delete this->values;
     
    272272        this->values->AXPY(gradient,scalar);
    273273}/*}}}*/
    274 /*FUNCTION ControlInput::VerticallyIntegrate{{{1*/
     274/*FUNCTION ControlInput::VerticallyIntegrate{{{*/
    275275void ControlInput::VerticallyIntegrate(Input* thickness_input){
    276276        values->VerticallyIntegrate(thickness_input);
    277277}/*}}}*/
    278 /*FUNCTION ControlInput::Configure{{{1*/
     278/*FUNCTION ControlInput::Configure{{{*/
    279279void ControlInput::Configure(Parameters* parameters){
    280280        /*do nothing: */
  • issm/trunk/src/c/objects/Inputs/ControlInput.h

    r12358 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111#include "./Input.h"
    1212#include "../../include/include.h"
     
    2525                Input* gradient;
    2626
    27                 /*ControlInput constructors, destructors: {{{1*/
     27                /*ControlInput constructors, destructors: {{{*/
    2828                ControlInput();
    29                 ControlInput(int enum_type,int enum_input,double* pvalues,double* pmin,double* pmax,int id);
     29                ControlInput(int enum_type,int enum_input,IssmDouble* pvalues,IssmDouble* pmin,IssmDouble* pmax,int id);
    3030                ~ControlInput();
    3131                /*}}}*/
    32                 /*Object virtual functions definitions:{{{1 */
     32                /*Object virtual functions definitions:{{{ */
    3333                void  Echo();
    3434                void  DeepEcho();
     
    3838                Object* copy();
    3939                /*}}}*/
    40                 /*ControlInput management: {{{1*/
     40                /*ControlInput management: {{{*/
    4141                int    InstanceEnum();
    4242                Input* SpawnTriaInput(int* indices);
    43                 Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
    44                 Input* PointwiseMin(Input* inputB){_error_("not implemented yet");};
    45                 Input* PointwiseMax(Input* inputB){_error_("not implemented yet");};
    46                 ElementResult* SpawnResult(int step, double time);
    47                 void AddTimeValues(double* values,int step,double time){_error_("not supported yet");};
     43                Input* PointwiseDivide(Input* inputB){_error2_("not implemented yet");};
     44                Input* PointwiseMin(Input* inputB){_error2_("not implemented yet");};
     45                Input* PointwiseMax(Input* inputB){_error2_("not implemented yet");};
     46                ElementResult* SpawnResult(int step, IssmDouble time);
     47                void AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error2_("not supported yet");};
    4848                void Configure(Parameters* parameters);
    4949                /*}}}*/
    50                 /*numerics: {{{1*/
     50                /*numerics: {{{*/
    5151                void SetInput(Input* in_input);
    5252                void GetInputValue(bool* pvalue);
    5353                void GetInputValue(int* pvalue);
    54                 void GetInputValue(double* pvalue);
    55                 void GetInputValue(double* pvalue,GaussTria* gauss);
    56                 void GetInputValue(double* pvalue,GaussPenta* gauss);
    57                 void GetInputValue(double* pvalue,GaussTria* gauss,double time){_error_("not implemented yet");};
    58                 void GetInputValue(double* pvalue,GaussPenta* gauss,double time){_error_("not implemented yet");};
    59                 void GetInputValue(double* pvalue,GaussTria* gauss ,int index){_error_("not implemented yet");};
    60                 void GetInputValue(double* pvalue,GaussPenta* gauss ,int index){_error_("not implemented yet");};
    61                 void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss);
    62                 void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss);
    63                 void GetInputAverage(double* pvalue);
    64                 void GetVxStrainRate2d(double* epsilonvx,double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
    65                 void GetVyStrainRate2d(double* epsilonvy,double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
    66                 void GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
    67                 void GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
    68                 void GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
    69                 void GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
    70                 void GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
    71                 void ChangeEnum(int newenumtype){_error_("not implemented yet");};
    72                 void SquareMin(double* psquaremin, bool process_units,Parameters* parameters){_error_("not implemented yet");};
    73                 void ConstrainMin(double minimum){_error_("not implemented yet");};
    74                 void Scale(double scale_factor){_error_("not implemented yet");};
    75                 void ArtificialNoise(double min,double max){_error_("not implemented yet");};
    76                 void AXPY(Input* xinput,double scalar){_error_("not implemented yet");};
     54                void GetInputValue(IssmDouble* pvalue);
     55                void GetInputValue(IssmDouble* pvalue,GaussTria* gauss);
     56                void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss);
     57                void GetInputValue(IssmDouble* pvalue,GaussTria* gauss,IssmDouble time){_error2_("not implemented yet");};
     58                void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,IssmDouble time){_error2_("not implemented yet");};
     59                void GetInputValue(IssmDouble* pvalue,GaussTria* gauss ,int index){_error2_("not implemented yet");};
     60                void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss ,int index){_error2_("not implemented yet");};
     61                void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss);
     62                void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss);
     63                void GetInputAverage(IssmDouble* pvalue);
     64                void GetVxStrainRate2d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussTria* gauss){_error2_("not implemented yet");};
     65                void GetVyStrainRate2d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussTria* gauss){_error2_("not implemented yet");};
     66                void GetVxStrainRate3d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
     67                void GetVyStrainRate3d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
     68                void GetVzStrainRate3d(IssmDouble* epsilonvz,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
     69                void GetVxStrainRate3dPattyn(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
     70                void GetVyStrainRate3dPattyn(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
     71                void ChangeEnum(int newenumtype){_error2_("not implemented yet");};
     72                void SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters){_error2_("not implemented yet");};
     73                void ConstrainMin(IssmDouble minimum){_error2_("not implemented yet");};
     74                void Scale(IssmDouble scale_factor){_error2_("not implemented yet");};
     75                void ArtificialNoise(IssmDouble min,IssmDouble max){_error2_("not implemented yet");};
     76                void AXPY(Input* xinput,IssmDouble scalar){_error2_("not implemented yet");};
    7777                void Constrain(void);
    78                 void Constrain(double min,double max);
    79                 double InfinityNorm(void){_error_("not implemented yet");};
    80                 double Max(void){_error_("not implemented yet");};
    81                 double MaxAbs(void){_error_("not implemented yet");};
    82                 double Min(void){_error_("not implemented yet");};
    83                 double MinAbs(void){_error_("not implemented yet");};
     78                void Constrain(IssmDouble min,IssmDouble max);
     79                IssmDouble InfinityNorm(void){_error2_("not implemented yet");};
     80                IssmDouble Max(void){_error2_("not implemented yet");};
     81                IssmDouble MaxAbs(void){_error2_("not implemented yet");};
     82                IssmDouble Min(void){_error2_("not implemented yet");};
     83                IssmDouble MinAbs(void){_error2_("not implemented yet");};
    8484                void Extrude(void);
    8585                void VerticallyIntegrate(Input* thickness_input);
    8686                void GetVectorFromInputs(Vector* vector,int* doflist,const char* data);
    8787                void GetVectorFromInputs(Vector* vector,int* doflist);
    88                 void GetValuesPtr(double** pvalues,int* pnum_values){_error_("not implemented yet");};
    89                 ElementResult* SpawnGradient(int step, double time);
     88                void GetValuesPtr(IssmDouble** pvalues,int* pnum_values){_error2_("not implemented yet");};
     89                ElementResult* SpawnGradient(int step, IssmDouble time);
    9090                void GetGradient(Vector* gradient_vec,int* doflist);
    91                 void ScaleGradient(double scale);
     91                void ScaleGradient(IssmDouble scale);
    9292                void SetGradient(Input* gradient_in);
    93                 void UpdateValue(double scalar);
     93                void UpdateValue(IssmDouble scalar);
    9494                void SaveValue(void);
    9595                /*}}}*/
  • issm/trunk/src/c/objects/Inputs/DatasetInput.cpp

    r12330 r12706  
    22 * \brief: implementation of the datasetinput object
    33 */
    4 /*Headers{{{1*/
     4/*Headers{{{*/
    55#ifdef HAVE_CONFIG_H
    66        #include <config.h>
     
    1919
    2020/*DatasetInput constructors and destructor*/
    21 /*FUNCTION DatasetInput::DatasetInput(){{{1*/
     21/*FUNCTION DatasetInput::DatasetInput(){{{*/
    2222DatasetInput::DatasetInput(){
    2323        enum_type=UNDEF;
     
    2525}
    2626/*}}}*/
    27 /*FUNCTION DatasetInput::DatasetInput(int in_enum_type) {{{1*/
     27/*FUNCTION DatasetInput::DatasetInput(int in_enum_type) {{{*/
    2828DatasetInput::DatasetInput(int in_enum_type){
    2929
     
    3232}
    3333/*}}}*/
    34 /*FUNCTION DatasetInput::~DatasetInput(){{{1*/
     34/*FUNCTION DatasetInput::~DatasetInput(){{{*/
    3535DatasetInput::~DatasetInput(){
    3636        delete inputs;
     
    3939
    4040/*Object virtual functions definitions:*/
    41                 /*FUNCTION DatasetInput::Echo {{{1*/
     41                /*FUNCTION DatasetInput::Echo {{{*/
    4242void DatasetInput::Echo(void){
    4343        this->DeepEcho();
    4444}
    4545/*}}}*/
    46 /*FUNCTION DatasetInput::DeepEcho{{{1*/
     46/*FUNCTION DatasetInput::DeepEcho{{{*/
    4747void DatasetInput::DeepEcho(void){
    4848
    49         printf("DatasetInput:\n");
    50         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    51         printf("---inputs: \n"); inputs->Echo();
     49        _printLine_("DatasetInput:");
     50        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     51        _printLine_("---inputs: "); inputs->Echo();
    5252}
    5353/*}}}*/
    54 /*FUNCTION DatasetInput::Id{{{1*/
     54/*FUNCTION DatasetInput::Id{{{*/
    5555int    DatasetInput::Id(void){ return -1; }
    5656/*}}}*/
    57 /*FUNCTION DatasetInput::MyRank{{{1*/
     57/*FUNCTION DatasetInput::MyRank{{{*/
    5858int    DatasetInput::MyRank(void){
    5959        extern int my_rank;
     
    6161}
    6262/*}}}*/
    63 /*FUNCTION DatasetInput::ObjectEnum{{{1*/
     63/*FUNCTION DatasetInput::ObjectEnum{{{*/
    6464int DatasetInput::ObjectEnum(void){
    6565
     
    6868}
    6969/*}}}*/
    70 /*FUNCTION DatasetInput::copy{{{1*/
     70/*FUNCTION DatasetInput::copy{{{*/
    7171Object* DatasetInput::copy() {
    7272       
     
    8080}
    8181/*}}}*/
    82 /*FUNCTION DatasetInput::SpawnTriaInput{{{1*/
     82/*FUNCTION DatasetInput::SpawnTriaInput{{{*/
    8383Input* DatasetInput::SpawnTriaInput(int* indices){
    8484
     
    9797       
    9898/*DatasetInput management*/
    99 /*FUNCTION DatasetInput::InstanceEnum{{{1*/
     99/*FUNCTION DatasetInput::InstanceEnum{{{*/
    100100int DatasetInput::InstanceEnum(void){
    101101
     
    106106
    107107/*Object functions*/
    108 /*FUNCTION DatasetInput::Configure{{{1*/
     108/*FUNCTION DatasetInput::Configure{{{*/
    109109void DatasetInput::Configure(Parameters* parameters){
    110110        /*do nothing: */
    111111}
    112112/*}}}*/
    113 /*FUNCTION DatasetInput::GetInputValue(double* pvalue,GaussTria* gauss,int index){{{1*/
    114 void DatasetInput::GetInputValue(double* pvalue,GaussTria* gauss,int index){
     113/*FUNCTION DatasetInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss,int index){{{*/
     114void DatasetInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss,int index){
    115115
    116116        /*Get requested input within dataset*/
    117         if(index<0 || index > inputs->Size()-1) _error_("index requested (%i) exceeds dataset size (%i)",index,inputs->Size());
     117        if(index<0 || index > inputs->Size()-1) _error2_("index requested (" << index << ") exceeds dataset size (" << inputs->Size() << ")");
    118118        Input* input=(Input*)this->inputs->GetObjectByOffset(index);
    119119       
  • issm/trunk/src/c/objects/Inputs/DatasetInput.h

    r12358 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111#include "./Input.h"
    1212#include "../../include/include.h"
     
    2121                Inputs*     inputs;
    2222
    23                 /*DatasetInput constructors, destructors: {{{1*/
     23                /*DatasetInput constructors, destructors: {{{*/
    2424                DatasetInput();
    2525                DatasetInput(int enum_type);
    2626                ~DatasetInput();
    2727                /*}}}*/
    28                 /*Object virtual functions definitions:{{{1 */
     28                /*Object virtual functions definitions:{{{ */
    2929                void  Echo();
    3030                void  DeepEcho();
     
    3434                Object* copy();
    3535                /*}}}*/
    36                 /*DatasetInput management: {{{1*/
     36                /*DatasetInput management: {{{*/
    3737                int    InstanceEnum();
    3838                Input* SpawnTriaInput(int* indices);
    39                 Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
    40                 Input* PointwiseMin(Input* inputB){_error_("not implemented yet");};
    41                 Input* PointwiseMax(Input* inputB){_error_("not implemented yet");};
    42                 ElementResult* SpawnResult(int step, double time){_error_("not implemented yet");};
    43                 void AddTimeValues(double* values,int step,double time){_error_("not supported yet");};
     39                Input* PointwiseDivide(Input* inputB){_error2_("not implemented yet");};
     40                Input* PointwiseMin(Input* inputB){_error2_("not implemented yet");};
     41                Input* PointwiseMax(Input* inputB){_error2_("not implemented yet");};
     42                ElementResult* SpawnResult(int step, IssmDouble time){_error2_("not implemented yet");};
     43                void AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error2_("not supported yet");};
    4444                void Configure(Parameters* parameters);
    4545                /*}}}*/
    46                 /*numeriics: {{{1*/
    47                 void GetInputValue(bool* pvalue){_error_("not implemented yet");};
    48                 void GetInputValue(int* pvalue){_error_("not implemented yet");};
    49                 void GetInputValue(double* pvalue){_error_("not implemented yet");};
    50                 void GetInputValue(double* pvalue,GaussTria* gauss){_error_("not implemented yet");};
    51                 void GetInputValue(double* pvalue,GaussPenta* gauss){_error_("not implemented yet");};
    52                 void GetInputValue(double* pvalue,GaussTria* gauss,double time){_error_("not implemented yet");};
    53                 void GetInputValue(double* pvalue,GaussPenta* gauss,double time){_error_("not implemented yet");};
    54                 void GetInputValue(double* pvalue,GaussTria* gauss ,int index);
    55                 void GetInputValue(double* pvalue,GaussPenta* gauss ,int index){_error_("not implemented yet");};
    56                 void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
    57                 void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
    58                 void GetInputAverage(double* pvalue){_error_("not implemented yet");};
    59                 void GetVxStrainRate2d(double* epsilonvx,double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
    60                 void GetVyStrainRate2d(double* epsilonvy,double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
    61                 void GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
    62                 void GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
    63                 void GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
    64                 void GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
    65                 void GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
    66                 void ChangeEnum(int newenumtype){_error_("not implemented yet");};
    67                 void SquareMin(double* psquaremin, bool process_units,Parameters* parameters){_error_("not implemented yet");};
    68                 void ConstrainMin(double minimum){_error_("not implemented yet");};
    69                 void Scale(double scale_factor){_error_("not implemented yet");};
    70                 void ArtificialNoise(double min,double max){_error_("not implemented yet");};
    71                 void AXPY(Input* xinput,double scalar){_error_("not implemented yet");};
    72                 void Constrain(void){_error_("not implemented yet");};
    73                 void Constrain(double min,double max){_error_("not implemented yet");};
    74                 double InfinityNorm(void){_error_("not implemented yet");};
    75                 double Max(void){_error_("not implemented yet");};
    76                 double MaxAbs(void){_error_("not implemented yet");};
    77                 double Min(void){_error_("not implemented yet");};
    78                 double MinAbs(void){_error_("not implemented yet");};
    79                 void Extrude(void){_error_("not implemented yet");};
    80                 void VerticallyIntegrate(Input* thickness_input){_error_("not implemented yet");};
    81                 void GetVectorFromInputs(Vector* vector,int* doflist){_error_("not implemented yet");};
    82                 void GetValuesPtr(double** pvalues,int* pnum_values){_error_("not implemented yet");};
    83                 ElementResult* SpawnGradient(int step, double time){_error_("not implemented yet");};
    84                 void GetGradient(Vector* gradient_vec,int* doflist){_error_("not implemented yet");};
    85                 void ScaleGradient(double scale){_error_("not implemented yet");};
    86                 void SetGradient(Input* gradient_in){_error_("not implemented yet");};
    87                 void UpdateValue(double scalar){_error_("not implemented yet");};
    88                 void SaveValue(void){_error_("not implemented yet");};
     46                /*numerics: {{{*/
     47                void GetInputValue(bool* pvalue){_error2_("not implemented yet");};
     48                void GetInputValue(int* pvalue){_error2_("not implemented yet");};
     49                void GetInputValue(IssmDouble* pvalue){_error2_("not implemented yet");};
     50                void GetInputValue(IssmDouble* pvalue,GaussTria* gauss){_error2_("not implemented yet");};
     51                void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){_error2_("not implemented yet");};
     52                void GetInputValue(IssmDouble* pvalue,GaussTria* gauss,IssmDouble time){_error2_("not implemented yet");};
     53                void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,IssmDouble time){_error2_("not implemented yet");};
     54                void GetInputValue(IssmDouble* pvalue,GaussTria* gauss ,int index);
     55                void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss ,int index){_error2_("not implemented yet");};
     56                void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss){_error2_("not implemented yet");};
     57                void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
     58                void GetInputAverage(IssmDouble* pvalue){_error2_("not implemented yet");};
     59                void GetVxStrainRate2d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussTria* gauss){_error2_("not implemented yet");};
     60                void GetVyStrainRate2d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussTria* gauss){_error2_("not implemented yet");};
     61                void GetVxStrainRate3d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
     62                void GetVyStrainRate3d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
     63                void GetVzStrainRate3d(IssmDouble* epsilonvz,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
     64                void GetVxStrainRate3dPattyn(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
     65                void GetVyStrainRate3dPattyn(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
     66                void ChangeEnum(int newenumtype){_error2_("not implemented yet");};
     67                void SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters){_error2_("not implemented yet");};
     68                void ConstrainMin(IssmDouble minimum){_error2_("not implemented yet");};
     69                void Scale(IssmDouble scale_factor){_error2_("not implemented yet");};
     70                void ArtificialNoise(IssmDouble min,IssmDouble max){_error2_("not implemented yet");};
     71                void AXPY(Input* xinput,IssmDouble scalar){_error2_("not implemented yet");};
     72                void Constrain(void){_error2_("not implemented yet");};
     73                void Constrain(IssmDouble min,IssmDouble max){_error2_("not implemented yet");};
     74                IssmDouble InfinityNorm(void){_error2_("not implemented yet");};
     75                IssmDouble Max(void){_error2_("not implemented yet");};
     76                IssmDouble MaxAbs(void){_error2_("not implemented yet");};
     77                IssmDouble Min(void){_error2_("not implemented yet");};
     78                IssmDouble MinAbs(void){_error2_("not implemented yet");};
     79                void Extrude(void){_error2_("not implemented yet");};
     80                void VerticallyIntegrate(Input* thickness_input){_error2_("not implemented yet");};
     81                void GetVectorFromInputs(Vector* vector,int* doflist){_error2_("not implemented yet");};
     82                void GetValuesPtr(IssmDouble** pvalues,int* pnum_values){_error2_("not implemented yet");};
     83                ElementResult* SpawnGradient(int step, IssmDouble time){_error2_("not implemented yet");};
     84                void GetGradient(Vector* gradient_vec,int* doflist){_error2_("not implemented yet");};
     85                void ScaleGradient(IssmDouble scale){_error2_("not implemented yet");};
     86                void SetGradient(Input* gradient_in){_error2_("not implemented yet");};
     87                void UpdateValue(IssmDouble scalar){_error2_("not implemented yet");};
     88                void SaveValue(void){_error2_("not implemented yet");};
    8989                /*}}}*/
    9090
  • issm/trunk/src/c/objects/Inputs/DoubleInput.cpp

    r12330 r12706  
    1818
    1919/*DoubleInput constructors and destructor*/
    20 /*FUNCTION DoubleInput::DoubleInput(){{{1*/
     20/*FUNCTION DoubleInput::DoubleInput(){{{*/
    2121DoubleInput::DoubleInput(){
    2222        return;
    2323}
    2424/*}}}*/
    25 /*FUNCTION DoubleInput::DoubleInput(double value){{{1*/
     25/*FUNCTION DoubleInput::DoubleInput(IssmDouble value){{{*/
    2626DoubleInput::DoubleInput(int in_enum_type,IssmDouble in_value){
    2727
     
    3030}
    3131/*}}}*/
    32 /*FUNCTION DoubleInput::~DoubleInput(){{{1*/
     32/*FUNCTION DoubleInput::~DoubleInput(){{{*/
    3333DoubleInput::~DoubleInput(){
    3434        return;
     
    3737
    3838/*Object virtual functions definitions:*/
    39                 /*FUNCTION DoubleInput::Echo {{{1*/
     39                /*FUNCTION DoubleInput::Echo {{{*/
    4040void DoubleInput::Echo(void){
    4141        this->DeepEcho();
    4242}
    4343/*}}}*/
    44 /*FUNCTION DoubleInput::DeepEcho{{{1*/
     44/*FUNCTION DoubleInput::DeepEcho{{{*/
    4545void DoubleInput::DeepEcho(void){
    4646
    47         printf("DoubleInput:\n");
    48         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    49         printf("   value: %g\n",this->value);
    50 }
    51 /*}}}*/
    52 /*FUNCTION DoubleInput::Id{{{1*/
     47        _printLine_("DoubleInput:");
     48        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     49        _printLine_("   value: " << this->value);
     50}
     51/*}}}*/
     52/*FUNCTION DoubleInput::Id{{{*/
    5353int    DoubleInput::Id(void){ return -1; }
    5454/*}}}*/
    55 /*FUNCTION DoubleInput::MyRank{{{1*/
     55/*FUNCTION DoubleInput::MyRank{{{*/
    5656int    DoubleInput::MyRank(void){
    5757        extern int my_rank;
     
    5959}
    6060/*}}}*/
    61 /*FUNCTION DoubleInput::ObjectEnum{{{1*/
     61/*FUNCTION DoubleInput::ObjectEnum{{{*/
    6262int DoubleInput::ObjectEnum(void){
    6363
     
    6666}
    6767/*}}}*/
    68 /*FUNCTION DoubleInput::copy{{{1*/
     68/*FUNCTION DoubleInput::copy{{{*/
    6969Object* DoubleInput::copy() {
    7070       
     
    7575       
    7676/*DoubleInput management*/
    77 /*FUNCTION DoubleInput::InstanceEnum{{{1*/
     77/*FUNCTION DoubleInput::InstanceEnum{{{*/
    7878int DoubleInput::InstanceEnum(void){
    7979
     
    8282}
    8383/*}}}*/
    84 /*FUNCTION DoubleInput::SpawnTriaInput{{{1*/
     84/*FUNCTION DoubleInput::SpawnTriaInput{{{*/
    8585Input* DoubleInput::SpawnTriaInput(int* indices){
    8686
     
    9797}
    9898/*}}}*/
    99 /*FUNCTION DoubleInput::SpawnResult{{{1*/
    100 ElementResult* DoubleInput::SpawnResult(int step, double time){
     99/*FUNCTION DoubleInput::SpawnResult{{{*/
     100ElementResult* DoubleInput::SpawnResult(int step, IssmDouble time){
    101101
    102102        return new DoubleElementResult(this->enum_type,this->value,step,time);
     
    106106
    107107/*Object functions*/
    108 /*FUNCTION DoubleInput::GetInputValue(bool* pvalue) {{{1*/
     108/*FUNCTION DoubleInput::GetInputValue(bool* pvalue) {{{*/
    109109void DoubleInput::GetInputValue(bool* pvalue){
    110         _error_("Double input of enum %s cannot return a boolean",EnumToStringx(enum_type));
    111 
    112 }
    113 /*}}}*/
    114 /*FUNCTION DoubleInput::GetInputValue(int* pvalue){{{1*/
     110        _error2_("Double input of enum " << EnumToStringx(enum_type) << " cannot return a boolean");
     111
     112}
     113/*}}}*/
     114/*FUNCTION DoubleInput::GetInputValue(int* pvalue){{{*/
    115115void DoubleInput::GetInputValue(int* pvalue){
    116         _error_("Double input of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type));
    117 
    118 }
    119 /*}}}*/
    120 /*FUNCTION DoubleInput::GetInputValue(double* pvalue){{{1*/
    121 void DoubleInput::GetInputValue(double* pvalue){
     116        _error2_("Double input of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an integer");
     117
     118}
     119/*}}}*/
     120/*FUNCTION DoubleInput::GetInputValue(IssmDouble* pvalue){{{*/
     121void DoubleInput::GetInputValue(IssmDouble* pvalue){
    122122
    123123        /*return value*/
     
    125125}
    126126/*}}}*/
    127 /*FUNCTION DoubleInput::GetInputValue(double* pvalue,GaussTria* gauss){{{1*/
    128 void DoubleInput::GetInputValue(double* pvalue,GaussTria* gauss){*pvalue=this->value;}
    129 /*}}}*/
    130 /*FUNCTION DoubleInput::GetInputValue(double* pvalue,GaussPenta* gauss){{{1*/
    131 void DoubleInput::GetInputValue(double* pvalue,GaussPenta* gauss){*pvalue=this->value;}
    132 /*}}}*/
    133 /*FUNCTION DoubleInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss){{{1*/
    134 void DoubleInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss){_error_(" not supported yet!");}
    135 /*}}}*/
    136 /*FUNCTION DoubleInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss){{{1*/
    137 void DoubleInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss){_error_(" not supported yet!");}
    138 /*}}}*/
    139 /*FUNCTION DoubleInput::GetVxStrainRate2d(double* epsilonvx,double* xyz_list, GaussTria* gauss){{{1*/
    140 void DoubleInput::GetVxStrainRate2d(double* epsilonvx,double* xyz_list, GaussTria* gauss){
     127/*FUNCTION DoubleInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss){{{*/
     128void DoubleInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss){*pvalue=this->value;}
     129/*}}}*/
     130/*FUNCTION DoubleInput::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){{{*/
     131void DoubleInput::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){*pvalue=this->value;}
     132/*}}}*/
     133/*FUNCTION DoubleInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss){{{*/
     134void DoubleInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss){_error2_("not supported yet!");}
     135/*}}}*/
     136/*FUNCTION DoubleInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss){{{*/
     137void DoubleInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not supported yet!");}
     138/*}}}*/
     139/*FUNCTION DoubleInput::GetVxStrainRate2d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussTria* gauss){{{*/
     140void DoubleInput::GetVxStrainRate2d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussTria* gauss){
    141141        /*Epsilon is zero as vx is constant over the element*/
    142142        for(int i=0;i<3;i++) epsilonvx[i]=0;
    143143}
    144144/*}}}*/
    145 /*FUNCTION DoubleInput::GetVyStrainRate2d(double* epsilonvy,double* xyz_list, GaussTria* gauss){{{1*/
    146 void DoubleInput::GetVyStrainRate2d(double* epsilonvy,double* xyz_list, GaussTria* gauss){
     145/*FUNCTION DoubleInput::GetVyStrainRate2d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussTria* gauss){{{*/
     146void DoubleInput::GetVyStrainRate2d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussTria* gauss){
    147147        /*Epsilon is zero as vy is constant over the element*/
    148148        for(int i=0;i<3;i++) epsilonvy[i]=0;
    149149}
    150150/*}}}*/
    151 /*FUNCTION DoubleInput::GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss){{{1*/
    152 void DoubleInput::GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss){
     151/*FUNCTION DoubleInput::GetVxStrainRate3d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){{{*/
     152void DoubleInput::GetVxStrainRate3d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){
    153153        /*Epsilon is zero as vx is constant over the element*/
    154154        for(int i=0;i<6;i++) epsilonvx[i]=0;
    155155}
    156156/*}}}*/
    157 /*FUNCTION DoubleInput::GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss){{{1*/
    158 void DoubleInput::GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss){
     157/*FUNCTION DoubleInput::GetVyStrainRate3d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){{{*/
     158void DoubleInput::GetVyStrainRate3d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){
    159159        /*Epsilon is zero as vy is constant over the element*/
    160160        for(int i=0;i<6;i++) epsilonvy[i]=0;
    161161}
    162162/*}}}*/
    163 /*FUNCTION DoubleInput::GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss){{{1*/
    164 void DoubleInput::GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss){
     163/*FUNCTION DoubleInput::GetVzStrainRate3d(IssmDouble* epsilonvz,IssmDouble* xyz_list, GaussPenta* gauss){{{*/
     164void DoubleInput::GetVzStrainRate3d(IssmDouble* epsilonvz,IssmDouble* xyz_list, GaussPenta* gauss){
    165165        /*Epsilon is zero as vz is constant over the element*/
    166166        for(int i=0;i<6;i++) epsilonvz[i]=0;
    167167}
    168168/*}}}*/
    169 /*FUNCTION DoubleInput::GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss){{{1*/
    170 void DoubleInput::GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss){
     169/*FUNCTION DoubleInput::GetVxStrainRate3dPattyn(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){{{*/
     170void DoubleInput::GetVxStrainRate3dPattyn(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){
    171171        /*Epsilon is zero as vx is constant over the element*/
    172172        for(int i=0;i<5;i++) epsilonvx[i]=0;
    173173}
    174174/*}}}*/
    175 /*FUNCTION DoubleInput::GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss){{{1*/
    176 void DoubleInput::GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss){
     175/*FUNCTION DoubleInput::GetVyStrainRate3dPattyn(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){{{*/
     176void DoubleInput::GetVyStrainRate3dPattyn(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){
    177177        /*Epsilon is zero as vy is constant over the element*/
    178178        for(int i=0;i<5;i++) epsilonvy[i]=0;
    179179}
    180180/*}}}*/
    181 /*FUNCTION DoubleInput::ChangeEnum{{{1*/
     181/*FUNCTION DoubleInput::ChangeEnum{{{*/
    182182void DoubleInput::ChangeEnum(int newenumtype){
    183183        this->enum_type=newenumtype;
    184184}
    185185/*}}}*/
    186 /*FUNCTION DoubleInput::SquareMin{{{1*/
    187 void DoubleInput::SquareMin(double* psquaremin, bool process_units,Parameters* parameters){
    188 
    189         /*square min of a double is the square of the double itself: */
     186/*FUNCTION DoubleInput::SquareMin{{{*/
     187void DoubleInput::SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters){
     188
     189        /*square min of a IssmDouble is the square of the IssmDouble itself: */
    190190        *psquaremin=pow(value,2);
    191191}
    192192/*}}}*/
    193 /*FUNCTION DoubleInput::Scale{{{1*/
    194 void DoubleInput::Scale(double scale_factor){
     193/*FUNCTION DoubleInput::Scale{{{*/
     194void DoubleInput::Scale(IssmDouble scale_factor){
    195195        value=value*scale_factor;
    196196}
    197197/*}}}*/
    198 /*FUNCTION DoubleInput::ConstrainMin{{{1*/
    199 void DoubleInput::ConstrainMin(double minimum){
     198/*FUNCTION DoubleInput::ConstrainMin{{{*/
     199void DoubleInput::ConstrainMin(IssmDouble minimum){
    200200        if (value<minimum) value=minimum;
    201201}
    202202/*}}}*/
    203 /*FUNCTION DoubleInput::AXPY{{{1*/
    204 void DoubleInput::AXPY(Input* xinput,double scalar){
    205 
    206         DoubleInput*  xdoubleinput=NULL;
     203/*FUNCTION DoubleInput::AXPY{{{*/
     204void DoubleInput::AXPY(Input* xinput,IssmDouble scalar){
     205
     206        DoubleInput*  xIssmDoubleinput=NULL;
    207207
    208208        /*xinput is of the same type, so cast it: */
    209         xdoubleinput=(DoubleInput*)xinput;
     209        xIssmDoubleinput=(DoubleInput*)xinput;
    210210
    211211        /*Carry out the AXPY operation depending on type:*/
     
    213213
    214214                case DoubleInputEnum:
    215                         this->value=this->value+scalar*xdoubleinput->value;
     215                        this->value=this->value+scalar*xIssmDoubleinput->value;
    216216                        return;
    217217
    218218                default:
    219                         _error_("not implemented yet");
     219                        _error2_("not implemented yet");
    220220        }
    221221
    222222}
    223223/*}}}*/
    224 /*FUNCTION DoubleInput::Constrain{{{1*/
    225 void DoubleInput::Constrain(double cm_min, double cm_max){
    226 
    227         if(!isnan(cm_min)) if (this->value<cm_min)this->value=cm_min;
    228         if(!isnan(cm_max)) if (this->value>cm_max)this->value=cm_max;
    229 
    230 }
    231 /*}}}*/
    232 /*FUNCTION DoubleInput::Max{{{1*/
    233 double DoubleInput::Max(void){
     224/*FUNCTION DoubleInput::Constrain{{{*/
     225void DoubleInput::Constrain(IssmDouble cm_min, IssmDouble cm_max){
     226
     227        if(!xIsNan<IssmDouble>(cm_min)) if (this->value<cm_min)this->value=cm_min;
     228        if(!xIsNan<IssmDouble>(cm_max)) if (this->value>cm_max)this->value=cm_max;
     229
     230}
     231/*}}}*/
     232/*FUNCTION DoubleInput::Max{{{*/
     233IssmDouble DoubleInput::Max(void){
    234234        return this->value;
    235235}
    236236/*}}}*/
    237 /*FUNCTION DoubleInput::MaxAbs{{{1*/
    238 double DoubleInput::MaxAbs(void){
     237/*FUNCTION DoubleInput::MaxAbs{{{*/
     238IssmDouble DoubleInput::MaxAbs(void){
    239239        return fabs(this->value);
    240240}
    241241/*}}}*/
    242 /*FUNCTION DoubleInput::Min{{{1*/
    243 double DoubleInput::Min(void){
     242/*FUNCTION DoubleInput::Min{{{*/
     243IssmDouble DoubleInput::Min(void){
    244244        return this->value;
    245245}
    246246/*}}}*/
    247 /*FUNCTION DoubleInput::MinAbs{{{1*/
    248 double DoubleInput::MinAbs(void){
     247/*FUNCTION DoubleInput::MinAbs{{{*/
     248IssmDouble DoubleInput::MinAbs(void){
    249249        return fabs(this->value);
    250250}
    251251/*}}}*/
    252 /*FUNCTION DoubleInput::GetVectorFromInputs{{{1*/
     252/*FUNCTION DoubleInput::GetVectorFromInputs{{{*/
    253253void DoubleInput::GetVectorFromInputs(Vector* vector,int* doflist){
    254254
    255         _error_(" not supporte yet!");
    256 
    257 }
    258 /*}}}*/
    259 /*FUNCTION DoubleInput::GetValuesPtr{{{1*/
    260 void DoubleInput::GetValuesPtr(double** pvalues,int* pnum_values){
    261 
    262         _error_(" not supported yet!");
    263 
    264 }
    265 /*}}}*/
    266 /*FUNCTION DoubleInput::GetInputAverage{{{1*/
    267 void DoubleInput::GetInputAverage(double* pvalue){
     255        _error2_("not supporte yet!");
     256
     257}
     258/*}}}*/
     259/*FUNCTION DoubleInput::GetValuesPtr{{{*/
     260void DoubleInput::GetValuesPtr(IssmDouble** pvalues,int* pnum_values){
     261
     262        _error2_("not supported yet!");
     263
     264}
     265/*}}}*/
     266/*FUNCTION DoubleInput::GetInputAverage{{{*/
     267void DoubleInput::GetInputAverage(IssmDouble* pvalue){
    268268        *pvalue=value;
    269269}
    270270/*}}}*/
    271 /*FUNCTION DoubleInput::VerticallyIntegrate{{{1*/
     271/*FUNCTION DoubleInput::VerticallyIntegrate{{{*/
    272272void DoubleInput::VerticallyIntegrate(Input* thickness_input){
    273273
    274274        /*Intermediaries*/
    275         double thickness_value;
     275        IssmDouble thickness_value;
    276276
    277277        /*Check that input provided is a thickness*/
    278         if (thickness_input->InstanceEnum()!=ThicknessEnum) _error_("Input provided is not a Thickness (enum_type is %s)",EnumToStringx(thickness_input->InstanceEnum()));
     278        if (thickness_input->InstanceEnum()!=ThicknessEnum) _error2_("Input provided is not a Thickness (enum_type is " << EnumToStringx(thickness_input->InstanceEnum()) << ")");
    279279
    280280        /*vertically integrate depending on type:*/
     
    287287
    288288                default:
    289                         _error_("not implemented yet");
     289                        _error2_("not implemented yet");
    290290        }
    291291}
    292292/*}}}*/
    293 /*FUNCTION DoubleInput::PointwiseDivide{{{1*/
     293/*FUNCTION DoubleInput::PointwiseDivide{{{*/
    294294Input* DoubleInput::PointwiseDivide(Input* inputB){
    295295
     
    298298
    299299        /*Intermediaries*/
    300         double       Bvalue;
     300        IssmDouble       Bvalue;
    301301
    302302        /*Check that inputB is of the same type*/
     
    311311}
    312312/*}}}*/
    313 /*FUNCTION DoubleInput::PointwiseMin{{{1*/
     313/*FUNCTION DoubleInput::PointwiseMin{{{*/
    314314Input* DoubleInput::PointwiseMin(Input* input){
    315315
     
    318318
    319319        /*Intermediaries*/
    320         double       min;
     320        IssmDouble       min;
    321321
    322322        /*Check that inputB is of the same type*/
     
    332332}
    333333/*}}}*/
    334 /*FUNCTION DoubleInput::PointwiseMax{{{1*/
     334/*FUNCTION DoubleInput::PointwiseMax{{{*/
    335335Input* DoubleInput::PointwiseMax(Input* input){
    336336
     
    339339
    340340        /*Intermediaries*/
    341         double       max;
     341        IssmDouble       max;
    342342
    343343        /*Check that inputB is of the same type*/
     
    353353}
    354354/*}}}*/
    355 /*FUNCTION DoubleInput::Configure{{{1*/
     355/*FUNCTION DoubleInput::Configure{{{*/
    356356void DoubleInput::Configure(Parameters* parameters){
    357357        /*do nothing: */
  • issm/trunk/src/c/objects/Inputs/DoubleInput.h

    r12358 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111#include "./Input.h"
    1212#include "../../include/include.h"
     
    1818        public:
    1919                int    enum_type;
    20                 double value;
     20                IssmDouble value;
    2121
    22                 /*DoubleInput constructors, destructors: {{{1*/
     22                /*DoubleInput constructors, destructors: {{{*/
    2323                DoubleInput();
    2424                DoubleInput(int enum_type,IssmDouble value);
    2525                ~DoubleInput();
    2626                /*}}}*/
    27                 /*Object virtual functions definitions:{{{1 */
     27                /*Object virtual functions definitions:{{{ */
    2828                void  Echo();
    2929                void  DeepEcho();
     
    3333                Object* copy();
    3434                /*}}}*/
    35                 /*DoubleInput management: {{{1*/
     35                /*DoubleInput management: {{{*/
    3636                int   InstanceEnum();
    3737                Input* SpawnTriaInput(int* indices);
     
    3939                Input* PointwiseMin(Input* inputB);
    4040                Input* PointwiseMax(Input* inputB);
    41                 ElementResult* SpawnResult(int step, double time);
    42                 void AddTimeValues(double* values,int step,double time){_error_("not supported yet");};
     41                ElementResult* SpawnResult(int step, IssmDouble time);
     42                void AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error2_("not supported yet");};
    4343                void Configure(Parameters* parameters);
    4444                /*}}}*/
    45                 /*numerics: {{{1*/
     45                /*numerics: {{{*/
    4646                void GetInputValue(bool* pvalue);
    4747                void GetInputValue(int* pvalue);
    48                 void GetInputValue(double* pvalue);
    49                 void GetInputValue(double* pvalue,GaussTria* gauss);
    50                 void GetInputValue(double* pvalue,GaussPenta* gauss);
    51                 void GetInputValue(double* pvalue,GaussTria* gauss,double time){_error_("not implemented yet");};
    52                 void GetInputValue(double* pvalue,GaussPenta* gauss,double time){_error_("not implemented yet");};
    53                 void GetInputValue(double* pvalue,GaussTria* gauss ,int index){_error_("not implemented yet");};
    54                 void GetInputValue(double* pvalue,GaussPenta* gauss ,int index){_error_("not implemented yet");};
    55                 void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss);
    56                 void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss);
    57                 void GetInputAverage(double* pvalue);
    58                 void GetVxStrainRate2d(double* epsilonvx,double* xyz_list, GaussTria* gauss);
    59                 void GetVyStrainRate2d(double* epsilonvy,double* xyz_list, GaussTria* gauss);
    60                 void GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss);
    61                 void GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss);
    62                 void GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss);
    63                 void GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss);
    64                 void GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss);
     48                void GetInputValue(IssmDouble* pvalue);
     49                void GetInputValue(IssmDouble* pvalue,GaussTria* gauss);
     50                void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss);
     51                void GetInputValue(IssmDouble* pvalue,GaussTria* gauss,IssmDouble time){_error2_("not implemented yet");};
     52                void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,IssmDouble time){_error2_("not implemented yet");};
     53                void GetInputValue(IssmDouble* pvalue,GaussTria* gauss ,int index){_error2_("not implemented yet");};
     54                void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss ,int index){_error2_("not implemented yet");};
     55                void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss);
     56                void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss);
     57                void GetInputAverage(IssmDouble* pvalue);
     58                void GetVxStrainRate2d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussTria* gauss);
     59                void GetVyStrainRate2d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussTria* gauss);
     60                void GetVxStrainRate3d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss);
     61                void GetVyStrainRate3d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss);
     62                void GetVzStrainRate3d(IssmDouble* epsilonvz,IssmDouble* xyz_list, GaussPenta* gauss);
     63                void GetVxStrainRate3dPattyn(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss);
     64                void GetVyStrainRate3dPattyn(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss);
    6565                void ChangeEnum(int newenumtype);
    66                 void SquareMin(double* psquaremin, bool process_units,Parameters* parameters);
    67                 void ConstrainMin(double minimum);
    68                 void Scale(double scale_factor);
    69                 void ArtificialNoise(double min,double max){_error_("not implemented yet");};
    70                 void AXPY(Input* xinput,double scalar);
    71                 void Constrain(double cm_min, double cm_max);
    72                 double InfinityNorm(void){_error_("not implemented yet");};
    73                 double Max(void);
    74                 double MaxAbs(void);
    75                 double Min(void);
    76                 double MinAbs(void);
    77                 void Extrude(void){_error_("not supported yet");};
     66                void SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters);
     67                void ConstrainMin(IssmDouble minimum);
     68                void Scale(IssmDouble scale_factor);
     69                void ArtificialNoise(IssmDouble min,IssmDouble max){_error2_("not implemented yet");};
     70                void AXPY(Input* xinput,IssmDouble scalar);
     71                void Constrain(IssmDouble cm_min, IssmDouble cm_max);
     72                IssmDouble InfinityNorm(void){_error2_("not implemented yet");};
     73                IssmDouble Max(void);
     74                IssmDouble MaxAbs(void);
     75                IssmDouble Min(void);
     76                IssmDouble MinAbs(void);
     77                void Extrude(void){_error2_("not supported yet");};
    7878                void VerticallyIntegrate(Input* thickness_input);
    7979                void GetVectorFromInputs(Vector* vector,int* doflist);
    80                 void GetValuesPtr(double** pvalues,int* pnum_values);
     80                void GetValuesPtr(IssmDouble** pvalues,int* pnum_values);
    8181                /*}}}*/
    8282
  • issm/trunk/src/c/objects/Inputs/Input.h

    r12358 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111#include "../Object.h"
    1212class Node;
     
    2121               
    2222                virtual        ~Input(){};
     23
    2324                virtual int  InstanceEnum()=0;
    2425                virtual void GetInputValue(bool* pvalue)=0;
    2526                virtual void GetInputValue(int* pvalue)=0;
    26                 virtual void GetInputValue(double* pvalue)=0;
    27                 virtual void GetInputValue(double* pvalue,GaussTria* gauss)=0;
    28                 virtual void GetInputValue(double* pvalue,GaussPenta* gauss)=0;
    29                 virtual void GetInputValue(double* pvalue,GaussTria* gauss,double time)=0;
    30                 virtual void GetInputValue(double* pvalue,GaussPenta* gauss,double time)=0;
    31                 virtual void GetInputValue(double* pvalue,GaussTria* gauss ,int index)=0;
    32                 virtual void GetInputValue(double* pvalue,GaussPenta* gauss,int index)=0;
    33                 virtual void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss)=0;
    34                 virtual void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss)=0;
    35                 virtual void GetInputAverage(double* pvalue)=0;
    36                 virtual void GetVxStrainRate2d(double* epsilonvx,double* xyz_list, GaussTria* gauss)=0;
    37                 virtual void GetVyStrainRate2d(double* epsilonvy,double* xyz_list, GaussTria* gauss)=0;
    38                 virtual void GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss)=0;
    39                 virtual void GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss)=0;
    40                 virtual void GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss)=0;
    41                 virtual void GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss)=0;
    42                 virtual void GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss)=0;
     27                virtual void GetInputValue(IssmDouble* pvalue)=0;
     28                virtual void GetInputValue(IssmDouble* pvalue,GaussTria* gauss)=0;
     29                virtual void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss)=0;
     30                virtual void GetInputValue(IssmDouble* pvalue,GaussTria* gauss,IssmDouble time)=0;
     31                virtual void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,IssmDouble time)=0;
     32                virtual void GetInputValue(IssmDouble* pvalue,GaussTria* gauss ,int index)=0;
     33                virtual void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,int index)=0;
     34                virtual void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss)=0;
     35                virtual void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss)=0;
     36                virtual void GetInputAverage(IssmDouble* pvalue)=0;
     37                virtual void GetVxStrainRate2d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussTria* gauss)=0;
     38                virtual void GetVyStrainRate2d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussTria* gauss)=0;
     39                virtual void GetVxStrainRate3d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss)=0;
     40                virtual void GetVyStrainRate3d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss)=0;
     41                virtual void GetVzStrainRate3d(IssmDouble* epsilonvz,IssmDouble* xyz_list, GaussPenta* gauss)=0;
     42                virtual void GetVxStrainRate3dPattyn(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss)=0;
     43                virtual void GetVyStrainRate3dPattyn(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss)=0;
    4344                virtual void ChangeEnum(int newenumtype)=0;
    4445                virtual void Configure(Parameters* parameters)=0;
    4546
    46                 virtual void   SquareMin(double* psquaremin, bool process_units,Parameters* parameters)=0;
    47                 virtual void   ConstrainMin(double minimum)=0;
    48                 virtual double InfinityNorm(void)=0;
    49                 virtual double MaxAbs(void)=0;
    50                 virtual double MinAbs(void)=0;
    51                 virtual double Max(void)=0;
    52                 virtual double Min(void)=0;
    53                 virtual void   Scale(double scale_factor)=0;
    54                 virtual void   ArtificialNoise(double min,double max)=0;
    55                 virtual void   AXPY(Input* xinput,double scalar)=0;
    56                 virtual void   Constrain(double cm_min, double cm_max)=0;
     47                virtual void   SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters)=0;
     48                virtual void   ConstrainMin(IssmDouble minimum)=0;
     49                virtual IssmDouble InfinityNorm(void)=0;
     50                virtual IssmDouble MaxAbs(void)=0;
     51                virtual IssmDouble MinAbs(void)=0;
     52                virtual IssmDouble Max(void)=0;
     53                virtual IssmDouble Min(void)=0;
     54                virtual void   Scale(IssmDouble scale_factor)=0;
     55                virtual void   ArtificialNoise(IssmDouble min,IssmDouble max)=0;
     56                virtual void   AXPY(Input* xinput,IssmDouble scalar)=0;
     57                virtual void   Constrain(IssmDouble cm_min, IssmDouble cm_max)=0;
    5758                virtual void   VerticallyIntegrate(Input* thickness_input)=0;
    5859                virtual void   Extrude()=0;
    5960                virtual void   GetVectorFromInputs(Vector* vector,int* doflist)=0;
    60                 virtual void   GetValuesPtr(double** pvalues,int* pnum_values)=0;
     61                virtual void   GetValuesPtr(IssmDouble** pvalues,int* pnum_values)=0;
    6162               
    6263                virtual Input* SpawnTriaInput(int* indices)=0;
     
    6465                virtual Input* PointwiseMax(Input* inputmax)=0;
    6566                virtual Input* PointwiseMin(Input* inputmin)=0;
    66                 virtual ElementResult* SpawnResult(int step, double time)=0;
     67                virtual ElementResult* SpawnResult(int step, IssmDouble time)=0;
    6768};
    6869#endif
  • issm/trunk/src/c/objects/Inputs/IntInput.cpp

    r12330 r12706  
    1818
    1919/*IntInput constructors and destructor*/
    20 /*FUNCTION IntInput::IntInput(){{{1*/
     20/*FUNCTION IntInput::IntInput(){{{*/
    2121IntInput::IntInput(){
    2222        return;
    2323}
    2424/*}}}*/
    25 /*FUNCTION IntInput::IntInput(double* values){{{1*/
     25/*FUNCTION IntInput::IntInput(IssmDouble* values){{{*/
    2626IntInput::IntInput(int in_enum_type,IssmInt in_value){
    2727
     
    3030}
    3131/*}}}*/
    32 /*FUNCTION IntInput::~IntInput(){{{1*/
     32/*FUNCTION IntInput::~IntInput(){{{*/
    3333IntInput::~IntInput(){
    3434        return;
     
    3737
    3838/*Object virtual functions definitions:*/
    39 /*FUNCTION IntInput::DeepEcho{{{1*/
     39/*FUNCTION IntInput::DeepEcho{{{*/
    4040void IntInput::DeepEcho(void){
    4141
    42         printf("IntInput:\n");
    43         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    44         printf("   value: %i\n",(int)this->value);
     42        _printLine_("IntInput:");
     43        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     44        _printLine_("   value: " << (int)this->value);
    4545}
    4646/*}}}*/
    47 /*FUNCTION IntInput::Id{{{1*/
     47/*FUNCTION IntInput::Id{{{*/
    4848int    IntInput::Id(void){ return -1; }
    4949/*}}}*/
    50 /*FUNCTION IntInput::MyRank{{{1*/
     50/*FUNCTION IntInput::MyRank{{{*/
    5151int    IntInput::MyRank(void){
    5252        extern int my_rank;
     
    5454}
    5555/*}}}*/
    56 /*FUNCTION IntInput::ObjectEnum{{{1*/
     56/*FUNCTION IntInput::ObjectEnum{{{*/
    5757int IntInput::ObjectEnum(void){
    5858
     
    6161}
    6262/*}}}*/
    63 /*FUNCTION IntInput::copy{{{1*/
     63/*FUNCTION IntInput::copy{{{*/
    6464Object* IntInput::copy() {
    6565       
     
    7070
    7171/*IntInput management*/
    72 /*FUNCTION IntInput::Echo {{{1*/
     72/*FUNCTION IntInput::Echo {{{*/
    7373void IntInput::Echo(void){
    7474        this->DeepEcho();
    7575}
    7676/*}}}*/
    77 /*FUNCTION IntInput::InstanceEnum{{{1*/
     77/*FUNCTION IntInput::InstanceEnum{{{*/
    7878int IntInput::InstanceEnum(void){
    7979
     
    8282}
    8383/*}}}*/
    84 /*FUNCTION IntInput::SpawnTriaInput{{{1*/
     84/*FUNCTION IntInput::SpawnTriaInput{{{*/
    8585Input* IntInput::SpawnTriaInput(int* indices){
    8686
     
    9696}
    9797/*}}}*/
    98 /*FUNCTION IntInput::SpawnResult{{{1*/
    99 ElementResult* IntInput::SpawnResult(int step, double time){
     98/*FUNCTION IntInput::SpawnResult{{{*/
     99ElementResult* IntInput::SpawnResult(int step, IssmDouble time){
    100100       
    101         _error_(" not supported yet!");
     101        _error2_("not supported yet!");
    102102
    103103}
     
    105105
    106106/*Object functions*/
    107 /*FUNCTION IntInput::GetInputValue(bool* pvalue) {{{1*/
    108 void IntInput::GetInputValue(bool* pvalue){_error_(" not supported yet!");}
     107/*FUNCTION IntInput::GetInputValue(bool* pvalue) {{{*/
     108void IntInput::GetInputValue(bool* pvalue){_error2_("not supported yet!");}
    109109/*}}}*/
    110 /*FUNCTION IntInput::GetInputValue(int* pvalue){{{1*/
     110/*FUNCTION IntInput::GetInputValue(int* pvalue){{{*/
    111111void IntInput::GetInputValue(int* pvalue){
    112112        *pvalue=value;
    113113}
    114114/*}}}*/
    115 /*FUNCTION IntInput::GetInputValue(double* pvalue){{{1*/
    116 void IntInput::GetInputValue(double* pvalue){
    117         _error_("IntInput cannot return a double in parallel");
     115/*FUNCTION IntInput::GetInputValue(IssmDouble* pvalue){{{*/
     116void IntInput::GetInputValue(IssmDouble* pvalue){
     117        _error2_("IntInput cannot return a IssmDouble in parallel");
    118118}
    119119/*}}}*/
    120 /*FUNCTION IntInput::GetInputValue(double* pvalue,GaussTria* gauss){{{1*/
    121 void IntInput::GetInputValue(double* pvalue,GaussTria* gauss){_error_(" not supported yet!");}
     120/*FUNCTION IntInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss){{{*/
     121void IntInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss){_error2_("not supported yet!");}
    122122/*}}}*/
    123 /*FUNCTION IntInput::GetInputValue(double* pvalue,GaussPenta* gauss){{{1*/
    124 void IntInput::GetInputValue(double* pvalue,GaussPenta* gauss){_error_(" not supported yet!");}
     123/*FUNCTION IntInput::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){{{*/
     124void IntInput::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){_error2_("not supported yet!");}
    125125/*}}}*/
    126 /*FUNCTION IntInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss){{{1*/
    127 void IntInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss){_error_(" not supported yet!");}
     126/*FUNCTION IntInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss){{{*/
     127void IntInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss){_error2_("not supported yet!");}
    128128/*}}}*/
    129 /*FUNCTION IntInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss){{{1*/
    130 void IntInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss){_error_(" not supported yet!");}
     129/*FUNCTION IntInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss){{{*/
     130void IntInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not supported yet!");}
    131131/*}}}*/
    132 /*FUNCTION IntInput::ChangeEnum{{{1*/
     132/*FUNCTION IntInput::ChangeEnum{{{*/
    133133void IntInput::ChangeEnum(int newenumtype){
    134134        this->enum_type=newenumtype;
    135135}
    136136/*}}}*/
    137 /*FUNCTION IntInput::SquareMin{{{1*/
    138 void IntInput::SquareMin(double* psquaremin, bool process_units,Parameters* parameters){
     137/*FUNCTION IntInput::SquareMin{{{*/
     138void IntInput::SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters){
    139139
    140140        /*square min of an integer is the square of the integer itself: */
    141         *psquaremin=pow((double)value,2);
     141        *psquaremin=pow((IssmDouble)value,2);
    142142}
    143143/*}}}*/
    144 /*FUNCTION IntInput::Scale{{{1*/
    145 void IntInput::Scale(double scale_factor){
    146         double dvalue=(double)value*scale_factor;
    147         value=(int)dvalue;
     144/*FUNCTION IntInput::Scale{{{*/
     145void IntInput::Scale(IssmDouble scale_factor){
     146        IssmDouble dvalue=(IssmDouble)value*scale_factor;
     147        value=reCast<int>(dvalue);
    148148}
    149149/*}}}*/
    150 /*FUNCTION IntInput::AXPY{{{1*/
    151 void IntInput::AXPY(Input* xinput,double scalar){
     150/*FUNCTION IntInput::AXPY{{{*/
     151void IntInput::AXPY(Input* xinput,IssmDouble scalar){
    152152
    153         double dvalue;
     153        IssmDouble dvalue;
    154154        IntInput*  xintinput=NULL;
    155155
     
    161161
    162162                case IntInputEnum:
    163                         dvalue=(double)this->value+scalar*(double)xintinput->value;
    164                         this->value=(int)dvalue;
     163                        dvalue=(IssmDouble)this->value+scalar*(IssmDouble)xintinput->value;
     164                        this->value=reCast<int>(dvalue);
    165165                        return;
    166166
    167167                default:
    168                         _error_("not implemented yet");
     168                        _error2_("not implemented yet");
    169169        }
    170170
    171171}
    172172/*}}}*/
    173 /*FUNCTION IntInput::Constrain{{{1*/
    174 void IntInput::Constrain(double cm_min, double cm_max){
     173/*FUNCTION IntInput::Constrain{{{*/
     174void IntInput::Constrain(IssmDouble cm_min, IssmDouble cm_max){
    175175
    176         if(!isnan(cm_min)) if (this->value<cm_min)this->value=(int)cm_min;
    177         if(!isnan(cm_max)) if (this->value>cm_max)this->value=(int)cm_max;
     176        if(!xIsNan<IssmDouble>(cm_min)) if (this->value<cm_min)this->value=reCast<int>(cm_min);
     177        if(!xIsNan<IssmDouble>(cm_max)) if (this->value>cm_max)this->value=reCast<int>(cm_max);
    178178
    179179}
    180180/*}}}*/
    181 /*FUNCTION IntInput::GetVectorFromInputs{{{1*/
     181/*FUNCTION IntInput::GetVectorFromInputs{{{*/
    182182void IntInput::GetVectorFromInputs(Vector* vector,int* doflist){
    183183
    184         _error_(" not supporte yet!");
     184        _error2_("not supporte yet!");
    185185
    186186}
    187187/*}}}*/
    188 /*FUNCTION IntInput::GetValuesPtr{{{1*/
    189 void IntInput::GetValuesPtr(double** pvalues,int* pnum_values){
     188/*FUNCTION IntInput::GetValuesPtr{{{*/
     189void IntInput::GetValuesPtr(IssmDouble** pvalues,int* pnum_values){
    190190
    191         _error_(" not supported yet!");
     191        _error2_("not supported yet!");
    192192
    193193}
    194194/*}}}*/
    195 /*FUNCTION IntInput::Configure{{{1*/
     195/*FUNCTION IntInput::Configure{{{*/
    196196void IntInput::Configure(Parameters* parameters){
    197197        /*do nothing: */
  • issm/trunk/src/c/objects/Inputs/IntInput.h

    r12358 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111#include "./Input.h"
    1212#include "../../include/include.h"
     
    2121                IssmInt value;
    2222
    23                 /*IntInput constructors, destructors: {{{1*/
     23                /*IntInput constructors, destructors: {{{*/
    2424                IntInput();
    2525                IntInput(int enum_type,IssmInt value);
    2626                ~IntInput();
    2727                /*}}}*/
    28                 /*Object virtual functions definitions:{{{1 */
     28                /*Object virtual functions definitions:{{{ */
    2929                void  Echo();
    3030                void  DeepEcho();
     
    3434                Object* copy();
    3535                /*}}}*/
    36                 /*IntInput management: {{{1*/
     36                /*IntInput management: {{{*/
    3737                int   InstanceEnum();
    3838                Input* SpawnTriaInput(int* indices);
    39                 Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
    40                 Input* PointwiseMin(Input* inputB){_error_("not implemented yet");};
    41                 Input* PointwiseMax(Input* inputB){_error_("not implemented yet");};
    42                 ElementResult* SpawnResult(int step, double time);
    43                 void AddTimeValues(double* values,int step,double time){_error_("not supported yet");};
     39                Input* PointwiseDivide(Input* inputB){_error2_("not implemented yet");};
     40                Input* PointwiseMin(Input* inputB){_error2_("not implemented yet");};
     41                Input* PointwiseMax(Input* inputB){_error2_("not implemented yet");};
     42                ElementResult* SpawnResult(int step, IssmDouble time);
     43                void AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error2_("not supported yet");};
    4444                void Configure(Parameters* parameters);
    4545                /*}}}*/
    46                 /*numerics: {{{1*/
     46                /*numerics: {{{*/
    4747                void GetInputValue(bool* pvalue);
    4848                void GetInputValue(int* pvalue);
    49                 void GetInputValue(double* pvalue);
    50                 void GetInputValue(double* pvalue,GaussTria* gauss);
    51                 void GetInputValue(double* pvalue,GaussPenta* gauss);
    52                 void GetInputValue(double* pvalue,GaussTria* gauss,double time){_error_("not implemented yet");};
    53                 void GetInputValue(double* pvalue,GaussPenta* gauss,double time){_error_("not implemented yet");};
    54                 void GetInputValue(double* pvalue,GaussTria* gauss ,int index){_error_("not implemented yet");};
    55                 void GetInputValue(double* pvalue,GaussPenta* gauss ,int index){_error_("not implemented yet");};
    56                 void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss);
    57                 void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss);
    58                 void GetInputAverage(double* pvalue){_error_("not implemented yet");};
    59                 void GetVxStrainRate2d(double* epsilonvx,double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
    60                 void GetVyStrainRate2d(double* epsilonvy,double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
    61                 void GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
    62                 void GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
    63                 void GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
    64                 void GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
    65                 void GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
     49                void GetInputValue(IssmDouble* pvalue);
     50                void GetInputValue(IssmDouble* pvalue,GaussTria* gauss);
     51                void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss);
     52                void GetInputValue(IssmDouble* pvalue,GaussTria* gauss,IssmDouble time){_error2_("not implemented yet");};
     53                void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,IssmDouble time){_error2_("not implemented yet");};
     54                void GetInputValue(IssmDouble* pvalue,GaussTria* gauss ,int index){_error2_("not implemented yet");};
     55                void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss ,int index){_error2_("not implemented yet");};
     56                void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss);
     57                void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss);
     58                void GetInputAverage(IssmDouble* pvalue){_error2_("not implemented yet");};
     59                void GetVxStrainRate2d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussTria* gauss){_error2_("not implemented yet");};
     60                void GetVyStrainRate2d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussTria* gauss){_error2_("not implemented yet");};
     61                void GetVxStrainRate3d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
     62                void GetVyStrainRate3d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
     63                void GetVzStrainRate3d(IssmDouble* epsilonvz,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
     64                void GetVxStrainRate3dPattyn(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
     65                void GetVyStrainRate3dPattyn(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
    6666                void ChangeEnum(int newenumtype);
    67                 void SquareMin(double* psquaremin, bool process_units,Parameters* parameters);
    68                 void ConstrainMin(double minimum){_error_("not implemented yet");};
    69                 void Scale(double scale_factor);
    70                 void ArtificialNoise(double min,double max){_error_("not implemented yet");};
    71                 void AXPY(Input* xinput,double scalar);
    72                 void Constrain(double cm_min, double cm_max);
    73                 double InfinityNorm(void){_error_("InfinityNorm not implemented for integers");};
    74                 double Max(void){_error_("Max not implemented for integers");};
    75                 double MaxAbs(void){_error_("Max not implemented for integers");};
    76                 double Min(void){_error_("Min not implemented for integers");};
    77                 double MinAbs(void){_error_("Min not implemented for integers");};
    78                 void Extrude(void){_error_("not supported yet");};
    79                 void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");};
     67                void SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters);
     68                void ConstrainMin(IssmDouble minimum){_error2_("not implemented yet");};
     69                void Scale(IssmDouble scale_factor);
     70                void ArtificialNoise(IssmDouble min,IssmDouble max){_error2_("not implemented yet");};
     71                void AXPY(Input* xinput,IssmDouble scalar);
     72                void Constrain(IssmDouble cm_min, IssmDouble cm_max);
     73                IssmDouble InfinityNorm(void){_error2_("InfinityNorm not implemented for integers");};
     74                IssmDouble Max(void){_error2_("Max not implemented for integers");};
     75                IssmDouble MaxAbs(void){_error2_("Max not implemented for integers");};
     76                IssmDouble Min(void){_error2_("Min not implemented for integers");};
     77                IssmDouble MinAbs(void){_error2_("Min not implemented for integers");};
     78                void Extrude(void){_error2_("not supported yet");};
     79                void VerticallyIntegrate(Input* thickness_input){_error2_("not supported yet");};
    8080                void GetVectorFromInputs(Vector* vector,int* doflist);
    81                 void GetValuesPtr(double** pvalues,int* pnum_values);
     81                void GetValuesPtr(IssmDouble** pvalues,int* pnum_values);
    8282                /*}}}*/
    8383
  • issm/trunk/src/c/objects/Inputs/PentaP1Input.cpp

    r12330 r12706  
    1818
    1919/*PentaP1Input constructors and destructor*/
    20 /*FUNCTION PentaP1Input::PentaP1Input(){{{1*/
     20/*FUNCTION PentaP1Input::PentaP1Input(){{{*/
    2121PentaP1Input::PentaP1Input(){
    2222        return;
    2323}
    2424/*}}}*/
    25 /*FUNCTION PentaP1Input::PentaP1Input(int in_enum_type,double* values){{{1*/
    26 PentaP1Input::PentaP1Input(int in_enum_type,double* in_values)
     25/*FUNCTION PentaP1Input::PentaP1Input(int in_enum_type,IssmDouble* values){{{*/
     26PentaP1Input::PentaP1Input(int in_enum_type,IssmDouble* in_values)
    2727                :PentaRef(1)
    2828{
     
    4141}
    4242/*}}}*/
    43 /*FUNCTION PentaP1Input::~PentaP1Input(){{{1*/
     43/*FUNCTION PentaP1Input::~PentaP1Input(){{{*/
    4444PentaP1Input::~PentaP1Input(){
    4545        return;
     
    4848
    4949/*Object virtual functions definitions:*/
    50 /*FUNCTION PentaP1Input::Echo {{{1*/
     50/*FUNCTION PentaP1Input::Echo {{{*/
    5151void PentaP1Input::Echo(void){
    5252        this->DeepEcho();
    5353}
    5454/*}}}*/
    55 /*FUNCTION PentaP1Input::DeepEcho{{{1*/
     55/*FUNCTION PentaP1Input::DeepEcho{{{*/
    5656void PentaP1Input::DeepEcho(void){
    5757
    58         printf("PentaP1Input:\n");
    59         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    60         printf("   values: [%g %g %g %g %g %g]\n",this->values[0],this->values[1],this->values[2],this->values[3],this->values[4],this->values[5]);
    61 }
    62 /*}}}*/
    63 /*FUNCTION PentaP1Input::Id{{{1*/
     58        _printLine_("PentaP1Input:");
     59        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     60        _printLine_("   values: [" << this->values[0] << " " << this->values[1] << " " << this->values[2] << " " << this->values[3] << " " << this->values[4] << " " << this->values[5] << "]");
     61}
     62/*}}}*/
     63/*FUNCTION PentaP1Input::Id{{{*/
    6464int    PentaP1Input::Id(void){ return -1; }
    6565/*}}}*/
    66 /*FUNCTION PentaP1Input::MyRank{{{1*/
     66/*FUNCTION PentaP1Input::MyRank{{{*/
    6767int    PentaP1Input::MyRank(void){
    6868        extern int my_rank;
     
    7070}
    7171/*}}}*/
    72 /*FUNCTION PentaP1Input::ObjectEnum{{{1*/
     72/*FUNCTION PentaP1Input::ObjectEnum{{{*/
    7373int PentaP1Input::ObjectEnum(void){
    7474
     
    7979       
    8080/*PentaP1Input management*/
    81 /*FUNCTION PentaP1Input::copy{{{1*/
     81/*FUNCTION PentaP1Input::copy{{{*/
    8282Object* PentaP1Input::copy() {
    8383       
     
    8686}
    8787/*}}}*/
    88 /*FUNCTION PentaP1Input::InstanceEnum{{{1*/
     88/*FUNCTION PentaP1Input::InstanceEnum{{{*/
    8989int PentaP1Input::InstanceEnum(void){
    9090
     
    9393}
    9494/*}}}*/
    95 /*FUNCTION PentaP1Input::SpawnTriaInput{{{1*/
     95/*FUNCTION PentaP1Input::SpawnTriaInput{{{*/
    9696Input* PentaP1Input::SpawnTriaInput(int* indices){
    9797
    9898        /*output*/
    9999        TriaP1Input* outinput=NULL;
    100         double newvalues[3];
     100        IssmDouble newvalues[3];
    101101
    102102        /*Loop over the new indices*/
     
    118118}
    119119/*}}}*/
    120 /*FUNCTION PentaP1Input::SpawnResult{{{1*/
    121 ElementResult* PentaP1Input::SpawnResult(int step, double time){
     120/*FUNCTION PentaP1Input::SpawnResult{{{*/
     121ElementResult* PentaP1Input::SpawnResult(int step, IssmDouble time){
    122122
    123123        return new PentaP1ElementResult(this->enum_type,this->values,step,time);
     
    127127
    128128/*Object functions*/
    129 /*FUNCTION PentaP1Input::GetInputValue(double* pvalue,GaussPenta* gauss){{{1*/
    130 void PentaP1Input::GetInputValue(double* pvalue,GaussPenta* gauss){
     129/*FUNCTION PentaP1Input::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){{{*/
     130void PentaP1Input::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){
    131131
    132132        /*Call PentaRef function*/
     
    135135}
    136136/*}}}*/
    137 /*FUNCTION PentaP1Input::GetInputDerivativeValue(double* p, double* xyz_list, GaussPenta* gauss){{{1*/
    138 void PentaP1Input::GetInputDerivativeValue(double* p, double* xyz_list, GaussPenta* gauss){
     137/*FUNCTION PentaP1Input::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list, GaussPenta* gauss){{{*/
     138void PentaP1Input::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list, GaussPenta* gauss){
    139139
    140140        /*Call PentaRef function*/
     
    142142}
    143143/*}}}*/
    144 /*FUNCTION PentaP1Input::GetVxStrainRate3d{{{1*/
    145 void PentaP1Input::GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss){
     144/*FUNCTION PentaP1Input::GetVxStrainRate3d{{{*/
     145void PentaP1Input::GetVxStrainRate3d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){
    146146        int i,j;
    147147
    148148        const int numnodes=6;
    149149        const int DOFVELOCITY=3;
    150         double B[8][27];
    151         double B_reduced[6][DOFVELOCITY*numnodes];
    152         double velocity[numnodes][DOFVELOCITY];
     150        IssmDouble B[8][27];
     151        IssmDouble B_reduced[6][DOFVELOCITY*numnodes];
     152        IssmDouble velocity[numnodes][DOFVELOCITY];
    153153
    154154        /*Get B matrix: */
     
    187187}
    188188/*}}}*/
    189 /*FUNCTION PentaP1Input::GetVyStrainRate3d{{{1*/
    190 void PentaP1Input::GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss){
     189/*FUNCTION PentaP1Input::GetVyStrainRate3d{{{*/
     190void PentaP1Input::GetVyStrainRate3d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){
    191191        int i,j;
    192192
    193193        const int numnodes=6;
    194194        const int DOFVELOCITY=3;
    195         double B[8][27];
    196         double B_reduced[6][DOFVELOCITY*numnodes];
    197         double velocity[numnodes][DOFVELOCITY];
     195        IssmDouble B[8][27];
     196        IssmDouble B_reduced[6][DOFVELOCITY*numnodes];
     197        IssmDouble velocity[numnodes][DOFVELOCITY];
    198198
    199199        /*Get B matrix: */
     
    232232}
    233233/*}}}*/
    234 /*FUNCTION PentaP1Input::GetVzStrainRate3d{{{1*/
    235 void PentaP1Input::GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss){
     234/*FUNCTION PentaP1Input::GetVzStrainRate3d{{{*/
     235void PentaP1Input::GetVzStrainRate3d(IssmDouble* epsilonvz,IssmDouble* xyz_list, GaussPenta* gauss){
    236236        int i,j;
    237237
    238238        const int numnodes=6;
    239239        const int DOFVELOCITY=3;
    240         double B[8][27];
    241         double B_reduced[6][DOFVELOCITY*numnodes];
    242         double velocity[numnodes][DOFVELOCITY];
     240        IssmDouble B[8][27];
     241        IssmDouble B_reduced[6][DOFVELOCITY*numnodes];
     242        IssmDouble velocity[numnodes][DOFVELOCITY];
    243243
    244244        /*Get B matrix: */
     
    278278}
    279279/*}}}*/
    280 /*FUNCTION PentaP1Input::GetVxStrainRate3dPattyn{{{1*/
    281 void PentaP1Input::GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss){
    282 
    283         int i;
    284         const int numnodes=6;
    285         double B[5][NDOF2*numnodes];
    286         double velocity[numnodes][NDOF2];
     280/*FUNCTION PentaP1Input::GetVxStrainRate3dPattyn{{{*/
     281void PentaP1Input::GetVxStrainRate3dPattyn(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){
     282
     283        int i;
     284        const int numnodes=6;
     285        IssmDouble B[5][NDOF2*numnodes];
     286        IssmDouble velocity[numnodes][NDOF2];
    287287
    288288        /*Get B matrix: */
     
    302302}
    303303/*}}}*/
    304 /*FUNCTION PentaP1Input::GetVyStrainRate3dPattyn{{{1*/
    305 void PentaP1Input::GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss){
    306 
    307         int i;
    308         const int numnodes=6;
    309         double B[5][NDOF2*numnodes];
    310         double velocity[numnodes][NDOF2];
     304/*FUNCTION PentaP1Input::GetVyStrainRate3dPattyn{{{*/
     305void PentaP1Input::GetVyStrainRate3dPattyn(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){
     306
     307        int i;
     308        const int numnodes=6;
     309        IssmDouble B[5][NDOF2*numnodes];
     310        IssmDouble velocity[numnodes][NDOF2];
    311311
    312312        /*Get B matrix: */
     
    326326}
    327327/*}}}*/
    328 /*FUNCTION PentaP1Input::ChangeEnum{{{1*/
     328/*FUNCTION PentaP1Input::ChangeEnum{{{*/
    329329void PentaP1Input::ChangeEnum(int newenumtype){
    330330        this->enum_type=newenumtype;
    331331}
    332332/*}}}*/
    333 /*FUNCTION PentaP1Input::GetInputAverage{{{1*/
    334 void PentaP1Input::GetInputAverage(double* pvalue){
     333/*FUNCTION PentaP1Input::GetInputAverage{{{*/
     334void PentaP1Input::GetInputAverage(IssmDouble* pvalue){
    335335        *pvalue=1./6.*(values[0]+values[1]+values[2]+values[3]+values[4]+values[5]);
    336336}
     
    338338
    339339/*Intermediary*/
    340 /*FUNCTION PentaP1Input::SquareMin{{{1*/
    341 void PentaP1Input::SquareMin(double* psquaremin, bool process_units,Parameters* parameters){
    342 
    343         int i;
    344         const int numnodes=6;
    345         double valuescopy[numnodes];
    346         double squaremin;
     340/*FUNCTION PentaP1Input::SquareMin{{{*/
     341void PentaP1Input::SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters){
     342
     343        int i;
     344        const int numnodes=6;
     345        IssmDouble valuescopy[numnodes];
     346        IssmDouble squaremin;
    347347
    348348        /*First,  copy values, to process units if requested: */
     
    361361}
    362362/*}}}*/
    363 /*FUNCTION PentaP1Input::ConstrainMin{{{1*/
    364 void PentaP1Input::ConstrainMin(double minimum){
     363/*FUNCTION PentaP1Input::ConstrainMin{{{*/
     364void PentaP1Input::ConstrainMin(IssmDouble minimum){
    365365       
    366366        int i;
     
    370370}
    371371/*}}}*/
    372 /*FUNCTION PentaP1Input::InfinityNorm{{{1*/
    373 double PentaP1Input::InfinityNorm(void){
     372/*FUNCTION PentaP1Input::InfinityNorm{{{*/
     373IssmDouble PentaP1Input::InfinityNorm(void){
    374374
    375375        /*Output*/
    376376        const int numnodes=6;
    377         double norm=0;
     377        IssmDouble norm=0;
    378378
    379379        for(int i=0;i<numnodes;i++) if(fabs(values[i])>norm) norm=fabs(values[i]);
     
    381381}
    382382/*}}}*/
    383 /*FUNCTION PentaP1Input::Max{{{1*/
    384 double PentaP1Input::Max(void){
    385 
    386         const int numnodes=6;
    387         double    max=values[0];
     383/*FUNCTION PentaP1Input::Max{{{*/
     384IssmDouble PentaP1Input::Max(void){
     385
     386        const int numnodes=6;
     387        IssmDouble    max=values[0];
    388388
    389389        for(int i=1;i<numnodes;i++){
     
    393393}
    394394/*}}}*/
    395 /*FUNCTION PentaP1Input::MaxAbs{{{1*/
    396 double PentaP1Input::MaxAbs(void){
    397 
    398         const int numnodes=6;
    399         double    max=fabs(values[0]);
     395/*FUNCTION PentaP1Input::MaxAbs{{{*/
     396IssmDouble PentaP1Input::MaxAbs(void){
     397
     398        const int numnodes=6;
     399        IssmDouble    max=fabs(values[0]);
    400400
    401401        for(int i=1;i<numnodes;i++){
     
    405405}
    406406/*}}}*/
    407 /*FUNCTION PentaP1Input::Min{{{1*/
    408 double PentaP1Input::Min(void){
    409 
    410         const int numnodes=6;
    411         double    min=values[0];
     407/*FUNCTION PentaP1Input::Min{{{*/
     408IssmDouble PentaP1Input::Min(void){
     409
     410        const int numnodes=6;
     411        IssmDouble    min=values[0];
    412412
    413413        for(int i=1;i<numnodes;i++){
     
    417417}
    418418/*}}}*/
    419 /*FUNCTION PentaP1Input::MinAbs{{{1*/
    420 double PentaP1Input::MinAbs(void){
    421 
    422         const int numnodes=6;
    423         double    min=fabs(values[0]);
     419/*FUNCTION PentaP1Input::MinAbs{{{*/
     420IssmDouble PentaP1Input::MinAbs(void){
     421
     422        const int numnodes=6;
     423        IssmDouble    min=fabs(values[0]);
    424424
    425425        for(int i=1;i<numnodes;i++){
     
    429429}
    430430/*}}}*/
    431 /*FUNCTION PentaP1Input::Scale{{{1*/
    432 void PentaP1Input::Scale(double scale_factor){
     431/*FUNCTION PentaP1Input::Scale{{{*/
     432void PentaP1Input::Scale(IssmDouble scale_factor){
    433433       
    434434        int i;
     
    438438}
    439439/*}}}*/
    440 /*FUNCTION PentaP1Input::AXPY{{{1*/
    441 void PentaP1Input::AXPY(Input* xinput,double scalar){
     440/*FUNCTION PentaP1Input::AXPY{{{*/
     441void PentaP1Input::AXPY(Input* xinput,IssmDouble scalar){
    442442
    443443        int i;
     
    455455                case ControlInputEnum:{
    456456                        ControlInput* cont_input=(ControlInput*)xinput;
    457                         if(cont_input->values->ObjectEnum()!=PentaP1InputEnum) _error_("not supported yet");
     457                        if(cont_input->values->ObjectEnum()!=PentaP1InputEnum) _error2_("not supported yet");
    458458                        PentaP1Input* cast_input=(PentaP1Input*)cont_input->values;
    459459                        for(i=0;i<numnodes;i++)this->values[i]=this->values[i]+scalar*(cast_input->values[i]);}
    460460                        return;
    461461                default:
    462                         _error_("not implemented yet");
    463         }
    464 
    465 }
    466 /*}}}*/
    467 /*FUNCTION PentaP1Input::Constrain{{{1*/
    468 void PentaP1Input::Constrain(double cm_min, double cm_max){
     462                        _error2_("not implemented yet");
     463        }
     464
     465}
     466/*}}}*/
     467/*FUNCTION PentaP1Input::Constrain{{{*/
     468void PentaP1Input::Constrain(IssmDouble cm_min, IssmDouble cm_max){
    469469
    470470        int i;
    471471        const int numnodes=6;
    472472               
    473         if(!isnan(cm_min)) for(i=0;i<numnodes;i++)if (this->values[i]<cm_min)this->values[i]=cm_min;
    474         if(!isnan(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;
    475 
    476 }
    477 /*}}}*/
    478 /*FUNCTION PentaP1Input::Extrude{{{1*/
     473        if(!xIsNan<IssmDouble>(cm_min)) for(i=0;i<numnodes;i++)if (this->values[i]<cm_min)this->values[i]=cm_min;
     474        if(!xIsNan<IssmDouble>(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;
     475
     476}
     477/*}}}*/
     478/*FUNCTION PentaP1Input::Extrude{{{*/
    479479void PentaP1Input::Extrude(void){
    480480
     
    485485}
    486486/*}}}*/
    487 /*FUNCTION PentaP1Input::VerticallyIntegrate{{{1*/
     487/*FUNCTION PentaP1Input::VerticallyIntegrate{{{*/
    488488void PentaP1Input::VerticallyIntegrate(Input* thickness_input){
    489489
     
    492492        const int  numnodes = 6;
    493493        int        num_thickness_values;
    494         double    *thickness_values = NULL;
     494        IssmDouble    *thickness_values = NULL;
    495495
    496496        /*Check that input provided is a thickness*/
    497         if (thickness_input->InstanceEnum()!=ThicknessEnum) _error_("Input provided is not a Thickness (enum_type is %s)",EnumToStringx(thickness_input->InstanceEnum()));
     497        if (thickness_input->InstanceEnum()!=ThicknessEnum) _error2_("Input provided is not a Thickness (enum_type is " << EnumToStringx(thickness_input->InstanceEnum()) << ")");
    498498
    499499        /*Get Thickness value pointer*/
     
    511511
    512512                default:
    513                         _error_("not implemented yet");
    514         }
    515 }
    516 /*}}}*/
    517 /*FUNCTION PentaP1Input::PointwiseDivide{{{1*/
     513                        _error2_("not implemented yet");
     514        }
     515}
     516/*}}}*/
     517/*FUNCTION PentaP1Input::PointwiseDivide{{{*/
    518518Input* PentaP1Input::PointwiseDivide(Input* inputB){
    519519
     
    526526        int               B_numvalues;
    527527        const int         numnodes    = 6;
    528         double            AdotBvalues[numnodes];
     528        IssmDouble            AdotBvalues[numnodes];
    529529
    530530        /*Check that inputB is of the same type*/
    531         if (inputB->ObjectEnum()!=PentaP1InputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToStringx(inputB->ObjectEnum()));
     531        if (inputB->ObjectEnum()!=PentaP1InputEnum) _error2_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
    532532        xinputB=(PentaP1Input*)inputB;
    533533
     
    546546}
    547547/*}}}*/
    548 /*FUNCTION PentaP1Input::PointwiseMin{{{1*/
     548/*FUNCTION PentaP1Input::PointwiseMin{{{*/
    549549Input* PentaP1Input::PointwiseMin(Input* inputB){
    550550
     
    557557        int               B_numvalues;
    558558        const int         numnodes    = 6;
    559         double            minvalues[numnodes];
     559        IssmDouble            minvalues[numnodes];
    560560
    561561        /*Check that inputB is of the same type*/
    562         if (inputB->ObjectEnum()!=PentaP1InputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToStringx(inputB->ObjectEnum()));
     562        if (inputB->ObjectEnum()!=PentaP1InputEnum) _error2_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
    563563        xinputB=(PentaP1Input*)inputB;
    564564
     
    577577}
    578578/*}}}*/
    579 /*FUNCTION PentaP1Input::PointwiseMax{{{1*/
     579/*FUNCTION PentaP1Input::PointwiseMax{{{*/
    580580Input* PentaP1Input::PointwiseMax(Input* inputB){
    581581
     
    588588        int               B_numvalues;
    589589        const int         numnodes    = 6;
    590         double            maxvalues[numnodes];
     590        IssmDouble            maxvalues[numnodes];
    591591
    592592        /*Check that inputB is of the same type*/
    593         if (inputB->ObjectEnum()!=PentaP1InputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToStringx(inputB->ObjectEnum()));
     593        if (inputB->ObjectEnum()!=PentaP1InputEnum) _error2_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
    594594        xinputB=(PentaP1Input*)inputB;
    595595
     
    608608}
    609609/*}}}*/
    610 /*FUNCTION PentaP1Input::GetVectorFromInputs{{{1*/
     610/*FUNCTION PentaP1Input::GetVectorFromInputs{{{*/
    611611void PentaP1Input::GetVectorFromInputs(Vector* vector,int* doflist){
    612612
     
    615615
    616616} /*}}}*/
    617 /*FUNCTION PentaP1Input::GetValuesPtr{{{1*/
    618 void PentaP1Input::GetValuesPtr(double** pvalues,int* pnum_values){
     617/*FUNCTION PentaP1Input::GetValuesPtr{{{*/
     618void PentaP1Input::GetValuesPtr(IssmDouble** pvalues,int* pnum_values){
    619619
    620620        *pvalues=this->values;
     
    623623}
    624624/*}}}*/
    625 /*FUNCTION PentaP1Input::Configure{{{1*/
     625/*FUNCTION PentaP1Input::Configure{{{*/
    626626void PentaP1Input::Configure(Parameters* parameters){
    627627        /*do nothing: */
  • issm/trunk/src/c/objects/Inputs/PentaP1Input.h

    r12358 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111#include "./Input.h"
    1212#include "../Elements/PentaRef.h"
     
    1919                /*just hold 6 values for 6 vertices: */
    2020                int    enum_type;
    21                 double values[6];
     21                IssmDouble values[6];
    2222
    23                 /*PentaP1Input constructors, destructors: {{{1*/
     23                /*PentaP1Input constructors, destructors: {{{*/
    2424                PentaP1Input();
    25                 PentaP1Input(int enum_type,double* values);
     25                PentaP1Input(int enum_type,IssmDouble* values);
    2626                ~PentaP1Input();
    2727                /*}}}*/
    28                 /*Object virtual functions definitions:{{{1 */
     28                /*Object virtual functions definitions:{{{ */
    2929                void  Echo();
    3030                void  DeepEcho();
     
    3434                Object* copy();
    3535                /*}}}*/
    36                 /*PentaP1Input management: {{{1*/
     36                /*PentaP1Input management: {{{*/
    3737                int   InstanceEnum();
    3838                Input* SpawnTriaInput(int* indices);
     
    4040                Input* PointwiseMin(Input* inputB);
    4141                Input* PointwiseMax(Input* inputB);
    42                 ElementResult* SpawnResult(int step, double time);
    43                 void AddTimeValues(double* values,int step,double time){_error_("not supported yet");};
     42                ElementResult* SpawnResult(int step, IssmDouble time);
     43                void AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error2_("not supported yet");};
    4444                void Configure(Parameters* parameters);
    4545                /*}}}*/
    46                 /*numerics: {{{1*/
    47                 void GetInputValue(bool* pvalue){_error_("not implemented yet");};
    48                 void GetInputValue(int* pvalue){_error_("not implemented yet");};
    49                 void GetInputValue(double* pvalue){_error_("not implemented yet");};
    50                 void GetInputValue(double* pvalue,GaussTria* gauss){_error_("not implemented yet");};
    51                 void GetInputValue(double* pvalue,GaussPenta* gauss);
    52                 void GetInputValue(double* pvalue,GaussTria* gauss,double time){_error_("not implemented yet");};
    53                 void GetInputValue(double* pvalue,GaussPenta* gauss,double time){_error_("not implemented yet");};
    54                 void GetInputValue(double* pvalue,GaussTria* gauss ,int index){_error_("not implemented yet");};
    55                 void GetInputValue(double* pvalue,GaussPenta* gauss ,int index){_error_("not implemented yet");};
    56                 void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
    57                 void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss);
    58                 void GetInputAverage(double* pvalue);
    59                 void GetVxStrainRate2d(double* epsilonvx,double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
    60                 void GetVyStrainRate2d(double* epsilonvy,double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
    61                 void GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss);
    62                 void GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss);
    63                 void GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss);
    64                 void GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss);
    65                 void GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss);
     46                /*numerics: {{{*/
     47                void GetInputValue(bool* pvalue){_error2_("not implemented yet");};
     48                void GetInputValue(int* pvalue){_error2_("not implemented yet");};
     49                void GetInputValue(IssmDouble* pvalue){_error2_("not implemented yet");};
     50                void GetInputValue(IssmDouble* pvalue,GaussTria* gauss){_error2_("not implemented yet");};
     51                void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss);
     52                void GetInputValue(IssmDouble* pvalue,GaussTria* gauss,IssmDouble time){_error2_("not implemented yet");};
     53                void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,IssmDouble time){_error2_("not implemented yet");};
     54                void GetInputValue(IssmDouble* pvalue,GaussTria* gauss ,int index){_error2_("not implemented yet");};
     55                void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss ,int index){_error2_("not implemented yet");};
     56                void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss){_error2_("not implemented yet");};
     57                void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss);
     58                void GetInputAverage(IssmDouble* pvalue);
     59                void GetVxStrainRate2d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussTria* gauss){_error2_("not implemented yet");};
     60                void GetVyStrainRate2d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussTria* gauss){_error2_("not implemented yet");};
     61                void GetVxStrainRate3d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss);
     62                void GetVyStrainRate3d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss);
     63                void GetVzStrainRate3d(IssmDouble* epsilonvz,IssmDouble* xyz_list, GaussPenta* gauss);
     64                void GetVxStrainRate3dPattyn(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss);
     65                void GetVyStrainRate3dPattyn(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss);
    6666                void ChangeEnum(int newenumtype);
    6767
    68                 void SquareMin(double* psquaremin, bool process_units,Parameters* parameters);
    69                 void ConstrainMin(double minimum);
    70                 void Scale(double scale_factor);
    71                 void ArtificialNoise(double min,double max){_error_("not implemented yet");};
    72                 void AXPY(Input* xinput,double scalar);
    73                 void Constrain(double cm_min, double cm_max);
    74                 double InfinityNorm(void);
    75                 double Max(void);
    76                 double MaxAbs(void);
    77                 double Min(void);
    78                 double MinAbs(void);
     68                void SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters);
     69                void ConstrainMin(IssmDouble minimum);
     70                void Scale(IssmDouble scale_factor);
     71                void ArtificialNoise(IssmDouble min,IssmDouble max){_error2_("not implemented yet");};
     72                void AXPY(Input* xinput,IssmDouble scalar);
     73                void Constrain(IssmDouble cm_min, IssmDouble cm_max);
     74                IssmDouble InfinityNorm(void);
     75                IssmDouble Max(void);
     76                IssmDouble MaxAbs(void);
     77                IssmDouble Min(void);
     78                IssmDouble MinAbs(void);
    7979                void Extrude(void);
    8080                void VerticallyIntegrate(Input* thickness_input);
    8181                void GetVectorFromInputs(Vector* vector,int* doflist);
    82                 void GetValuesPtr(double** pvalues,int* pnum_values);
     82                void GetValuesPtr(IssmDouble** pvalues,int* pnum_values);
    8383                /*}}}*/
    8484
  • issm/trunk/src/c/objects/Inputs/TransientInput.cpp

    r12358 r12706  
    4646/*FUNCTION TransientInput::~TransientInput{{{*/
    4747TransientInput::~TransientInput(){
    48         xfree((void**)&this->timesteps);
     48        xDelete<IssmDouble>(this->timesteps);
    4949        this->timesteps=NULL;
    5050        this->numtimesteps=0;
     
    6666        int i;
    6767
    68         printf("TransientInput:\n");
    69         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    70         printf("   numtimesteps: %i\n",this->numtimesteps);
    71         printf("---inputs: \n");
     68        _printLine_("TransientInput:");
     69        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     70        _printLine_("   numtimesteps: " << this->numtimesteps);
     71        _printLine_("---inputs: ");
    7272        for(i=0;i<this->numtimesteps;i++){
    73                 printf("   time: %g  \n",this->timesteps[i]);
     73                _printLine_("   time: " << this->timesteps[i] << "  ");
    7474                ((Input*)this->inputs->GetObjectByOffset(i))->Echo();
    7575        }
     
    100100        output->enum_type=this->enum_type;
    101101        output->numtimesteps=this->numtimesteps;
    102         output->timesteps=(double*)xmalloc(this->numtimesteps*sizeof(double));
    103    memcpy(output->timesteps,this->timesteps,this->numtimesteps*sizeof(double));
     102        output->timesteps=xNew<IssmDouble>(this->numtimesteps);
     103   memcpy(output->timesteps,this->timesteps,this->numtimesteps*sizeof(IssmDouble));
    104104        output->inputs=(Inputs*)this->inputs->Copy();
    105105        output->parameters=this->parameters;
     
    128128        outinput->enum_type=this->enum_type;
    129129        outinput->numtimesteps=this->numtimesteps;
    130         outinput->timesteps=(double*)xmalloc(this->numtimesteps*sizeof(double));
    131         memcpy(outinput->timesteps,this->timesteps,this->numtimesteps*sizeof(double));
     130        outinput->timesteps=xNew<IssmDouble>(this->numtimesteps);
     131        memcpy(outinput->timesteps,this->timesteps,this->numtimesteps*sizeof(IssmDouble));
    132132        outinput->inputs=(Inputs*)this->inputs->SpawnTriaInputs(indices);
    133133        outinput->parameters=this->parameters;
     
    139139/*}}}*/
    140140/*FUNCTION TransientInput::SpawnResult{{{*/
    141 ElementResult* TransientInput::SpawnResult(int step, double time){
     141ElementResult* TransientInput::SpawnResult(int step, IssmDouble time){
    142142
    143143        ElementResult* elementresult=NULL;
     
    156156
    157157/*Object functions*/
    158 /*FUNCTION TransientInput::GetInputValue(double* pvalue,GaussTria* gauss){{{*/
    159 void TransientInput::GetInputValue(double* pvalue,GaussTria* gauss){
    160         double time;
     158/*FUNCTION TransientInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss){{{*/
     159void TransientInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss){
     160        IssmDouble time;
    161161
    162162        /*First, recover current time from parameters: */
     
    172172}
    173173/*}}}*/
    174 /*FUNCTION TransientInput::GetInputValue(double* pvalue,GaussPenta* gauss){{{*/
    175 void TransientInput::GetInputValue(double* pvalue,GaussPenta* gauss){
    176         double time;
     174/*FUNCTION TransientInput::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){{{*/
     175void TransientInput::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){
     176        IssmDouble time;
    177177
    178178        /*First, recover current time from parameters: */
     
    188188}
    189189/*}}}*/
    190 /*FUNCTION TransientInput::GetInputValue(double* pvalue,GaussTria* gauss,double time){{{*/
    191 void TransientInput::GetInputValue(double* pvalue,GaussTria* gauss,double time){
     190/*FUNCTION TransientInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss,IssmDouble time){{{*/
     191void TransientInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss,IssmDouble time){
    192192
    193193        /*Retrieve interpolated values for this time step: */
     
    200200}
    201201/*}}}*/
    202 /*FUNCTION TransientInput::GetInputValue(double* pvalue,GaussPenta* gauss,double time){{{*/
    203 void TransientInput::GetInputValue(double* pvalue,GaussPenta* gauss,double time){
     202/*FUNCTION TransientInput::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,IssmDouble time){{{*/
     203void TransientInput::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,IssmDouble time){
    204204
    205205        /*Retrieve interpolated values for this time step: */
     
    212212}
    213213/*}}}*/
    214 /*FUNCTION TransientInput::GetInputDerivativeValue(double* p, double* xyz_list, GaussTria* gauss){{{*/
    215 void TransientInput::GetInputDerivativeValue(double* p, double* xyz_list, GaussTria* gauss){
    216 
    217         double time;
     214/*FUNCTION TransientInput::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list, GaussTria* gauss){{{*/
     215void TransientInput::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list, GaussTria* gauss){
     216
     217        IssmDouble time;
    218218
    219219        /*First, recover current time from parameters: */
     
    236236/*}}}*/
    237237/*FUNCTION TransientInput::GetInputAverage{{{*/
    238 void TransientInput::GetInputAverage(double* pvalue){
     238void TransientInput::GetInputAverage(IssmDouble* pvalue){
    239239       
    240         double time;
     240        IssmDouble time;
    241241
    242242        /*First, recover current time from parameters: */
     
    256256/*Intermediary*/
    257257/*FUNCTION TransientInput::AddTimeInput{{{*/
    258 void TransientInput::AddTimeInput(Input* input,double time){
     258void TransientInput::AddTimeInput(Input* input,IssmDouble time){
    259259
    260260        /*insert values at time step: */
     
    262262
    263263        //copy timesteps, add the new time, delete previous timesteps, and add the new input: inputs->AddObject(input);
    264         double* old_timesteps=NULL;
     264        IssmDouble* old_timesteps=NULL;
    265265
    266266        if (this->numtimesteps > 0){
    267                 old_timesteps=(double*)xmalloc(this->numtimesteps*sizeof(double));
    268                 memcpy(old_timesteps,this->timesteps,this->numtimesteps*sizeof(double));
    269                 xfree((void**)&this->timesteps);
     267                old_timesteps=xNew<IssmDouble>(this->numtimesteps);
     268                memcpy(old_timesteps,this->timesteps,this->numtimesteps*sizeof(IssmDouble));
     269                xDelete<IssmDouble>(this->timesteps);
    270270        }
    271271
    272272        this->numtimesteps=this->numtimesteps+1;
    273         this->timesteps=(double*)xmalloc(this->numtimesteps*sizeof(double));
     273        this->timesteps=xNew<IssmDouble>(this->numtimesteps);
    274274
    275275        if (this->numtimesteps > 1){
    276                 memcpy(this->timesteps,old_timesteps,(this->numtimesteps-1)*sizeof(double));
    277                 xfree((void**)&old_timesteps);
     276                memcpy(this->timesteps,old_timesteps,(this->numtimesteps-1)*sizeof(IssmDouble));
     277                xDelete<IssmDouble>(old_timesteps);
    278278        }
    279279
     
    285285/*}}}*/
    286286/*FUNCTION TransientInput::SquareMin{{{*/
    287 void TransientInput::SquareMin(double* psquaremin, bool process_units,Parameters* parameters){
    288 
    289         double time;
     287void TransientInput::SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters){
     288
     289        IssmDouble time;
    290290
    291291        /*First, recover current time from parameters: */
     
    303303/*}}}*/
    304304/*FUNCTION TransientInput::InfinityNorm{{{*/
    305 double TransientInput::InfinityNorm(void){
    306 
    307         double time;
    308         double infnorm;
     305IssmDouble TransientInput::InfinityNorm(void){
     306
     307        IssmDouble time;
     308        IssmDouble infnorm;
    309309
    310310        /*First, recover current time from parameters: */
     
    323323/*}}}*/
    324324/*FUNCTION TransientInput::Max{{{*/
    325 double TransientInput::Max(void){
    326 
    327         double time;
    328         double max;
     325IssmDouble TransientInput::Max(void){
     326
     327        IssmDouble time;
     328        IssmDouble max;
    329329
    330330        /*First, recover current time from parameters: */
     
    343343/*}}}*/
    344344/*FUNCTION TransientInput::MaxAbs{{{*/
    345 double TransientInput::MaxAbs(void){
    346 
    347         double time;
    348         double maxabs;
     345IssmDouble TransientInput::MaxAbs(void){
     346
     347        IssmDouble time;
     348        IssmDouble maxabs;
    349349
    350350        /*First, recover current time from parameters: */
     
    364364/*}}}*/
    365365/*FUNCTION TransientInput::Min{{{*/
    366 double TransientInput::Min(void){
    367 
    368         double time;
    369         double min;
     366IssmDouble TransientInput::Min(void){
     367
     368        IssmDouble time;
     369        IssmDouble min;
    370370
    371371        /*First, recover current time from parameters: */
     
    385385/*}}}*/
    386386/*FUNCTION TransientInput::MinAbs{{{*/
    387 double TransientInput::MinAbs(void){
    388 
    389         double time;
    390         double minabs;
     387IssmDouble TransientInput::MinAbs(void){
     388
     389        IssmDouble time;
     390        IssmDouble minabs;
    391391
    392392        /*First, recover current time from parameters: */
     
    407407void TransientInput::GetVectorFromInputs(Vector* vector,int* doflist){
    408408
    409         double time;
     409        IssmDouble time;
    410410
    411411        /*First, recover current time from parameters: */
     
    422422} /*}}}*/
    423423/*FUNCTION TransientInput::GetTimeInput{{{*/
    424 Input* TransientInput::GetTimeInput(double intime){
     424Input* TransientInput::GetTimeInput(IssmDouble intime){
    425425
    426426        int     i,j;
    427         double  deltat;
    428         double  alpha1,alpha2;
     427        IssmDouble  deltat;
     428        IssmDouble  alpha1,alpha2;
    429429        bool    found=false;
    430430        Input*  input=NULL;
     
    474474                }
    475475        }
    476         if(!found)_error_("did not find time interval on which to interpolate forcing values!");
     476        if(!found)_error2_("did not find time interval on which to interpolate forcing values!");
    477477
    478478        /*Assign output pointer*/
  • issm/trunk/src/c/objects/Inputs/TransientInput.h

    r12359 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111#include "./Input.h"
    1212class GaussTria;
     
    2020                int     numtimesteps;
    2121                Inputs* inputs;
    22                 double* timesteps;
     22                IssmDouble* timesteps;
    2323                Parameters* parameters; //to find current time.
    2424
    25                 /*TransientInput constructors, destructors: {{{1*/
     25                /*TransientInput constructors, destructors: {{{*/
    2626                TransientInput();
    2727                TransientInput(int enum_type);
    2828                ~TransientInput();
    29                 void AddTimeInput(Input* input,double time);
     29                void AddTimeInput(Input* input,IssmDouble time);
    3030                /*}}}*/
    31                 /*Object virtual functions definitions:{{{1*/
     31                /*Object virtual functions definitions:{{{*/
    3232                void  Echo();
    3333                void  DeepEcho();
     
    3737                Object* copy();
    3838                /*}}}*/
    39                 /*TransientInput management: {{{1*/
     39                /*TransientInput management: {{{*/
    4040                int    InstanceEnum();
    4141                Input* SpawnTriaInput(int* indices);
    42                 Input* PointwiseDivide(Input* forcingB){_error_("not implemented yet");};
    43                 Input* PointwiseMin(Input* forcingB){_error_("not implemented yet");};
    44                 Input* PointwiseMax(Input* forcingB){_error_("not implemented yet");};
    45                 ElementResult* SpawnResult(int step, double time);
     42                Input* PointwiseDivide(Input* forcingB){_error2_("not implemented yet");};
     43                Input* PointwiseMin(Input* forcingB){_error2_("not implemented yet");};
     44                Input* PointwiseMax(Input* forcingB){_error2_("not implemented yet");};
     45                ElementResult* SpawnResult(int step, IssmDouble time);
    4646                void Configure(Parameters* parameters);
    4747                /*}}}*/
    48                 /*numerics: {{{1*/
    49                 void GetInputValue(bool* pvalue){_error_("not implemented yet");};
    50                 void GetInputValue(int* pvalue){_error_("not implemented yet");};
    51                 void GetInputValue(double* pvalue){_error_("not implemented yet");};
    52                 void GetInputValue(double* pvalue,GaussTria* gauss);
    53                 void GetInputValue(double* pvalue,GaussPenta* gauss);
    54                 void GetInputValue(double* pvalue,GaussTria* gauss,double time);
    55                 void GetInputValue(double* pvalue,GaussPenta* gauss,double time);
    56                 void GetInputValue(double* pvalue,GaussTria* gauss ,int index){_error_("not implemented yet");};
    57                 void GetInputValue(double* pvalue,GaussPenta* gauss ,int index){_error_("not implemented yet");};
    58                 void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss);
    59                 void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
    60                 void GetInputAverage(double* pvalue);
    61                 void GetVxStrainRate2d(double* epsilonvx,double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
    62                 void GetVyStrainRate2d(double* epsilonvy,double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
    63                 void GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
    64                 void GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
    65                 void GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
    66                 void GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
    67                 void GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
     48                /*numerics: {{{*/
     49                void GetInputValue(bool* pvalue){_error2_("not implemented yet");};
     50                void GetInputValue(int* pvalue){_error2_("not implemented yet");};
     51                void GetInputValue(IssmDouble* pvalue){_error2_("not implemented yet");};
     52                void GetInputValue(IssmDouble* pvalue,GaussTria* gauss);
     53                void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){_error2_("not implemented yet");};
     54                void GetInputValue(IssmDouble* pvalue,GaussTria* gauss,IssmDouble time);
     55                void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,IssmDouble time){_error2_("not implemented yet");};
     56                void GetInputValue(IssmDouble* pvalue,GaussTria* gauss ,int index){_error2_("not implemented yet");};
     57                void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss ,int index){_error2_("not implemented yet");};
     58                void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss);
     59                void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
     60                void GetInputAverage(IssmDouble* pvalue);
     61                void GetVxStrainRate2d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussTria* gauss){_error2_("not implemented yet");};
     62                void GetVyStrainRate2d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussTria* gauss){_error2_("not implemented yet");};
     63                void GetVxStrainRate3d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
     64                void GetVyStrainRate3d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
     65                void GetVzStrainRate3d(IssmDouble* epsilonvz,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
     66                void GetVxStrainRate3dPattyn(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
     67                void GetVyStrainRate3dPattyn(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
    6868                void ChangeEnum(int newenumtype);
    6969
    70                 void SquareMin(double* psquaremin, bool process_units,Parameters* parameters);
    71                 void ConstrainMin(double minimum){_error_("not implemented yet");};
    72                 void Scale(double scale_factor){_error_("not implemented yet");};
    73                 void ArtificialNoise(double min,double max){_error_("not implemented yet");};
    74                 void AXPY(Input* xforcing,double scalar){_error_("not implemented yet");};
    75                 void Constrain(double cm_min, double cm_max){_error_("not implemented yet");};
    76                 double InfinityNorm(void);
    77                 double Max(void);
    78                 double MaxAbs(void);
    79                 double Min(void);
    80                 double MinAbs(void);
    81                 void Extrude(void){_error_("not supported yet");}
    82                 void VerticallyIntegrate(Input* thickness_forcing){_error_("not supported yet");};
     70                void SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters);
     71                void ConstrainMin(IssmDouble minimum){_error2_("not implemented yet");};
     72                void Scale(IssmDouble scale_factor){_error2_("not implemented yet");};
     73                void ArtificialNoise(IssmDouble min,IssmDouble max){_error2_("not implemented yet");};
     74                void AXPY(Input* xforcing,IssmDouble scalar){_error2_("not implemented yet");};
     75                void Constrain(IssmDouble cm_min, IssmDouble cm_max){_error2_("not implemented yet");};
     76                IssmDouble InfinityNorm(void);
     77                IssmDouble Max(void);
     78                IssmDouble MaxAbs(void);
     79                IssmDouble Min(void);
     80                IssmDouble MinAbs(void);
     81                void Extrude(void){_error2_("not supported yet");}
     82                void VerticallyIntegrate(Input* thickness_forcing){_error2_("not supported yet");};
    8383                void GetVectorFromInputs(Vector* vector,int* doflist);
    84                 void GetValuesPtr(double** pvalues,int* pnum_values){_error_("not supported yet");};
    85       void GetTimeValues(double* values,double time){_error_("not implemented yet");};
    86                 Input* GetTimeInput(double time);
     84                void GetValuesPtr(IssmDouble** pvalues,int* pnum_values){_error2_("not supported yet");};
     85      void GetTimeValues(IssmDouble* values,IssmDouble time){_error2_("not implemented yet");};
     86                Input* GetTimeInput(IssmDouble time);
    8787                /*}}}*/
    8888
  • issm/trunk/src/c/objects/Inputs/TriaP1Input.cpp

    r12330 r12706  
    1818
    1919/*TriaP1Input constructors and destructor*/
    20 /*FUNCTION TriaP1Input::TriaP1Input(){{{1*/
     20/*FUNCTION TriaP1Input::TriaP1Input(){{{*/
    2121TriaP1Input::TriaP1Input(){
    2222        return;
    2323}
    2424/*}}}*/
    25 /*FUNCTION TriaP1Input::TriaP1Input(int in_enum_type,double* values){{{1*/
    26 TriaP1Input::TriaP1Input(int in_enum_type,double* in_values)
     25/*FUNCTION TriaP1Input::TriaP1Input(int in_enum_type,IssmDouble* values){{{*/
     26TriaP1Input::TriaP1Input(int in_enum_type,IssmDouble* in_values)
    2727        :TriaRef(1)
    2828{
     
    4141}
    4242/*}}}*/
    43 /*FUNCTION TriaP1Input::~TriaP1Input(){{{1*/
     43/*FUNCTION TriaP1Input::~TriaP1Input(){{{*/
    4444TriaP1Input::~TriaP1Input(){
    4545        return;
     
    4848
    4949/*Object virtual functions definitions:*/
    50 /*FUNCTION TriaP1Input::Echo {{{1*/
     50/*FUNCTION TriaP1Input::Echo {{{*/
    5151void TriaP1Input::Echo(void){
    5252        this->DeepEcho();
    5353}
    5454/*}}}*/
    55 /*FUNCTION TriaP1Input::DeepEcho{{{1*/
     55/*FUNCTION TriaP1Input::DeepEcho{{{*/
    5656void TriaP1Input::DeepEcho(void){
    5757
    58         printf("TriaP1Input:\n");
    59         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    60         printf("   values: [%g %g %g]\n",this->values[0],this->values[1],this->values[2]);
    61 }
    62 /*}}}*/
    63 /*FUNCTION TriaP1Input::Id{{{1*/
     58        _printLine_("TriaP1Input:");
     59        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     60        _printLine_("   values: [" << this->values[0] << " " << this->values[1] << " " << this->values[2] << "]");
     61}
     62/*}}}*/
     63/*FUNCTION TriaP1Input::Id{{{*/
    6464int    TriaP1Input::Id(void){ return -1; }
    6565/*}}}*/
    66 /*FUNCTION TriaP1Input::MyRank{{{1*/
     66/*FUNCTION TriaP1Input::MyRank{{{*/
    6767int    TriaP1Input::MyRank(void){
    6868        extern int my_rank;
     
    7070}
    7171/*}}}*/
    72 /*FUNCTION TriaP1Input::ObjectEnum{{{1*/
     72/*FUNCTION TriaP1Input::ObjectEnum{{{*/
    7373int TriaP1Input::ObjectEnum(void){
    7474
     
    7777}
    7878/*}}}*/
    79 /*FUNCTION TriaP1Input::copy{{{1*/
     79/*FUNCTION TriaP1Input::copy{{{*/
    8080Object* TriaP1Input::copy() {
    8181       
     
    8686       
    8787/*TriaP1Input management*/
    88 /*FUNCTION TriaP1Input::InstanceEnum{{{1*/
     88/*FUNCTION TriaP1Input::InstanceEnum{{{*/
    8989int TriaP1Input::InstanceEnum(void){
    9090
     
    9393}
    9494/*}}}*/
    95 /*FUNCTION TriaP1Input::SpawnTriaInput{{{1*/
     95/*FUNCTION TriaP1Input::SpawnTriaInput{{{*/
    9696Input* TriaP1Input::SpawnTriaInput(int* indices){
    9797
     
    107107}
    108108/*}}}*/
    109 /*FUNCTION TriaP1Input::SpawnResult{{{1*/
    110 ElementResult* TriaP1Input::SpawnResult(int step, double time){
     109/*FUNCTION TriaP1Input::SpawnResult{{{*/
     110ElementResult* TriaP1Input::SpawnResult(int step, IssmDouble time){
    111111
    112112        return new TriaP1ElementResult(this->enum_type,this->values,step,time);
     
    116116
    117117/*Object functions*/
    118 /*FUNCTION TriaP1Input::GetInputValue(double* pvalue,GaussTria* gauss){{{1*/
    119 void TriaP1Input::GetInputValue(double* pvalue,GaussTria* gauss){
     118/*FUNCTION TriaP1Input::GetInputValue(IssmDouble* pvalue,GaussTria* gauss){{{*/
     119void TriaP1Input::GetInputValue(IssmDouble* pvalue,GaussTria* gauss){
    120120
    121121        /*Call TriaRef function*/
     
    124124}
    125125/*}}}*/
    126 /*FUNCTION TriaP1Input::GetInputDerivativeValue(double* p, double* xyz_list, GaussTria* gauss){{{1*/
    127 void TriaP1Input::GetInputDerivativeValue(double* p, double* xyz_list, GaussTria* gauss){
     126/*FUNCTION TriaP1Input::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list, GaussTria* gauss){{{*/
     127void TriaP1Input::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list, GaussTria* gauss){
    128128
    129129        /*Call TriaRef function*/
     
    131131}
    132132/*}}}*/
    133 /*FUNCTION TriaP1Input::GetVxStrainRate2d{{{1*/
    134 void TriaP1Input::GetVxStrainRate2d(double* epsilonvx,double* xyz_list, GaussTria* gauss){
     133/*FUNCTION TriaP1Input::GetVxStrainRate2d{{{*/
     134void TriaP1Input::GetVxStrainRate2d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussTria* gauss){
    135135
    136136        /*Intermediary*/
    137137        int       i;
    138138        const int numnodes=3;
    139         double B[3][NDOF2*numnodes];
    140         double velocity[3][NDOF2];
     139        IssmDouble B[3][NDOF2*numnodes];
     140        IssmDouble velocity[3][NDOF2];
    141141
    142142        /*Get B matrix: */
     
    154154}
    155155/*}}}*/
    156 /*FUNCTION TriaP1Input::GetVyStrainRate2d{{{1*/
    157 void TriaP1Input::GetVyStrainRate2d(double* epsilonvy,double* xyz_list, GaussTria* gauss){
     156/*FUNCTION TriaP1Input::GetVyStrainRate2d{{{*/
     157void TriaP1Input::GetVyStrainRate2d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussTria* gauss){
    158158
    159159        /*Intermediary*/
    160160        int       i;
    161161        const int numnodes=3;
    162         double B[3][NDOF2*numnodes];
    163         double velocity[3][NDOF2];
     162        IssmDouble B[3][NDOF2*numnodes];
     163        IssmDouble velocity[3][NDOF2];
    164164
    165165        /*Get B matrix: */
     
    177177}
    178178/*}}}*/
    179 /*FUNCTION TriaP1Input::ChangeEnum{{{1*/
     179/*FUNCTION TriaP1Input::ChangeEnum{{{*/
    180180void TriaP1Input::ChangeEnum(int newenumtype){
    181181        this->enum_type=newenumtype;
    182182}
    183183/*}}}*/
    184 /*FUNCTION TriaP1Input::GetInputAverage{{{1*/
    185 void TriaP1Input::GetInputAverage(double* pvalue){
     184/*FUNCTION TriaP1Input::GetInputAverage{{{*/
     185void TriaP1Input::GetInputAverage(IssmDouble* pvalue){
    186186        *pvalue=1./3.*(values[0]+values[1]+values[2]);
    187187}
     
    189189
    190190/*Intermediary*/
    191 /*FUNCTION TriaP1Input::SquareMin{{{1*/
    192 void TriaP1Input::SquareMin(double* psquaremin, bool process_units,Parameters* parameters){
    193 
    194         int i;
    195         const int numnodes=3;
    196         double valuescopy[numnodes];
    197         double squaremin;
     191/*FUNCTION TriaP1Input::SquareMin{{{*/
     192void TriaP1Input::SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters){
     193
     194        int i;
     195        const int numnodes=3;
     196        IssmDouble valuescopy[numnodes];
     197        IssmDouble squaremin;
    198198
    199199        /*First,  copy values, to process units if requested: */
     
    212212}
    213213/*}}}*/
    214 /*FUNCTION TriaP1Input::ContrainMin{{{1*/
    215 void TriaP1Input::ConstrainMin(double minimum){
     214/*FUNCTION TriaP1Input::ContrainMin{{{*/
     215void TriaP1Input::ConstrainMin(IssmDouble minimum){
    216216       
    217217        int i;
     
    221221}
    222222/*}}}*/
    223 /*FUNCTION TriaP1Input::InfinityNorm{{{1*/
    224 double TriaP1Input::InfinityNorm(void){
     223/*FUNCTION TriaP1Input::InfinityNorm{{{*/
     224IssmDouble TriaP1Input::InfinityNorm(void){
    225225
    226226        /*Output*/
    227         double norm=0;
     227        IssmDouble norm=0;
    228228        const int numnodes=3;
    229229
     
    232232}
    233233/*}}}*/
    234 /*FUNCTION TriaP1Input::Max{{{1*/
    235 double TriaP1Input::Max(void){
    236 
    237         const int numnodes=3;
    238         double    max=values[0];
     234/*FUNCTION TriaP1Input::Max{{{*/
     235IssmDouble TriaP1Input::Max(void){
     236
     237        const int numnodes=3;
     238        IssmDouble    max=values[0];
    239239
    240240        for(int i=1;i<numnodes;i++){
     
    244244}
    245245/*}}}*/
    246 /*FUNCTION TriaP1Input::MaxAbs{{{1*/
    247 double TriaP1Input::MaxAbs(void){
    248 
    249         const int numnodes=3;
    250         double    max=fabs(values[0]);
     246/*FUNCTION TriaP1Input::MaxAbs{{{*/
     247IssmDouble TriaP1Input::MaxAbs(void){
     248
     249        const int numnodes=3;
     250        IssmDouble    max=fabs(values[0]);
    251251
    252252        for(int i=1;i<numnodes;i++){
     
    256256}
    257257/*}}}*/
    258 /*FUNCTION TriaP1Input::Min{{{1*/
    259 double TriaP1Input::Min(void){
    260 
    261         const int numnodes=3;
    262         double    min=values[0];
     258/*FUNCTION TriaP1Input::Min{{{*/
     259IssmDouble TriaP1Input::Min(void){
     260
     261        const int numnodes=3;
     262        IssmDouble    min=values[0];
    263263
    264264        for(int i=1;i<numnodes;i++){
     
    268268}
    269269/*}}}*/
    270 /*FUNCTION TriaP1Input::MinAbs{{{1*/
    271 double TriaP1Input::MinAbs(void){
    272 
    273         const int numnodes=3;
    274         double    min=fabs(values[0]);
     270/*FUNCTION TriaP1Input::MinAbs{{{*/
     271IssmDouble TriaP1Input::MinAbs(void){
     272
     273        const int numnodes=3;
     274        IssmDouble    min=fabs(values[0]);
    275275
    276276        for(int i=1;i<numnodes;i++){
     
    280280}
    281281/*}}}*/
    282 /*FUNCTION TriaP1Input::Scale{{{1*/
    283 void TriaP1Input::Scale(double scale_factor){
     282/*FUNCTION TriaP1Input::Scale{{{*/
     283void TriaP1Input::Scale(IssmDouble scale_factor){
    284284       
    285285        int i;
     
    289289}
    290290/*}}}*/
    291 /*FUNCTION TriaP1Input::ArtificialNoise{{{1*/
    292 void TriaP1Input::ArtificialNoise(double min,double max){
    293 
    294         int i;
    295         const int numnodes=3;
    296         double noise;
     291/*FUNCTION TriaP1Input::ArtificialNoise{{{*/
     292void TriaP1Input::ArtificialNoise(IssmDouble min,IssmDouble max){
     293
     294        int i;
     295        const int numnodes=3;
     296        IssmDouble noise;
    297297
    298298        /*Compute random number between bounds:
    299299         * rand() outputs an integer in [0 RAND_MAX]
    300          * (double)rand()/RAND_MAX is in [0 1]
     300         * (IssmDouble)rand()/RAND_MAX is in [0 1]
    301301         */
    302          noise=min+(max-min)*(double)rand()/RAND_MAX;
     302         noise=min+(max-min)*(IssmDouble)rand()/RAND_MAX;
    303303
    304304        for(i=0;i<numnodes;i++)values[i]=values[i]+noise;
    305305}
    306306/*}}}*/
    307 /*FUNCTION TriaP1Input::AXPY{{{1*/
    308 void TriaP1Input::AXPY(Input* xinput,double scalar){
     307/*FUNCTION TriaP1Input::AXPY{{{*/
     308void TriaP1Input::AXPY(Input* xinput,IssmDouble scalar){
    309309
    310310        int i;
     
    323323
    324324                default :
    325                         _error_("not implemented yet");
    326         }
    327 
    328 }
    329 /*}}}*/
    330 /*FUNCTION TriaP1Input::Constrain{{{1*/
    331 void TriaP1Input::Constrain(double cm_min, double cm_max){
     325                        _error2_("not implemented yet");
     326        }
     327
     328}
     329/*}}}*/
     330/*FUNCTION TriaP1Input::Constrain{{{*/
     331void TriaP1Input::Constrain(IssmDouble cm_min, IssmDouble cm_max){
    332332
    333333        int i;
    334334        const int numnodes=3;
    335335               
    336         if(!isnan(cm_min)) for(i=0;i<numnodes;i++)if (this->values[i]<cm_min)this->values[i]=cm_min;
    337         if(!isnan(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;
    338 
    339 }
    340 /*}}}*/
    341 /*FUNCTION TriaP1Input::GetVectorFromInputs{{{1*/
     336        if(!xIsNan<IssmDouble>(cm_min)) for(i=0;i<numnodes;i++)if (this->values[i]<cm_min)this->values[i]=cm_min;
     337        if(!xIsNan<IssmDouble>(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;
     338
     339}
     340/*}}}*/
     341/*FUNCTION TriaP1Input::GetVectorFromInputs{{{*/
    342342void TriaP1Input::GetVectorFromInputs(Vector* vector,int* doflist){
    343343
     
    346346
    347347} /*}}}*/
    348 /*FUNCTION TriaP1Input::GetValuesPtr{{{1*/
    349 void TriaP1Input::GetValuesPtr(double** pvalues,int* pnum_values){
     348/*FUNCTION TriaP1Input::GetValuesPtr{{{*/
     349void TriaP1Input::GetValuesPtr(IssmDouble** pvalues,int* pnum_values){
    350350
    351351        *pvalues=this->values;
     
    354354}
    355355/*}}}*/
    356 /*FUNCTION TriaP1Input::PointwiseMin{{{1*/
     356/*FUNCTION TriaP1Input::PointwiseMin{{{*/
    357357Input* TriaP1Input::PointwiseMin(Input* inputB){
    358358
     
    365365        int               B_numvalues;
    366366        const int         numnodes    = 3;
    367         double            minvalues[numnodes];
     367        IssmDouble            minvalues[numnodes];
    368368
    369369        /*Check that inputB is of the same type*/
    370         if (inputB->ObjectEnum()!=TriaP1InputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToStringx(inputB->ObjectEnum()));
     370        if (inputB->ObjectEnum()!=TriaP1InputEnum) _error2_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
    371371        xinputB=(TriaP1Input*)inputB;
    372372
     
    385385}
    386386/*}}}*/
    387 /*FUNCTION TriaP1Input::PointwiseMax{{{1*/
     387/*FUNCTION TriaP1Input::PointwiseMax{{{*/
    388388Input* TriaP1Input::PointwiseMax(Input* inputB){
    389389
     
    396396        int               B_numvalues;
    397397        const int         numnodes    = 3;
    398         double            maxvalues[numnodes];
     398        IssmDouble            maxvalues[numnodes];
    399399
    400400        /*Check that inputB is of the same type*/
    401         if (inputB->ObjectEnum()!=TriaP1InputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToStringx(inputB->ObjectEnum()));
     401        if (inputB->ObjectEnum()!=TriaP1InputEnum) _error2_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
    402402        xinputB=(TriaP1Input*)inputB;
    403403
     
    416416}
    417417/*}}}*/
    418 /*FUNCTION TriaP1Input::Configure{{{1*/
     418/*FUNCTION TriaP1Input::Configure{{{*/
    419419void TriaP1Input::Configure(Parameters* parameters){
    420420        /*do nothing: */
  • issm/trunk/src/c/objects/Inputs/TriaP1Input.h

    r12358 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111#include "./Input.h"
    1212#include "../Elements/TriaRef.h"
     
    1919                /*just hold 3 values for 3 vertices: */
    2020                int    enum_type;
    21                 double values[3];
     21                IssmDouble values[3];
    2222
    23                 /*TriaP1Input constructors, destructors: {{{1*/
     23                /*TriaP1Input constructors, destructors: {{{*/
    2424                TriaP1Input();
    25                 TriaP1Input(int enum_type,double* values);
     25                TriaP1Input(int enum_type,IssmDouble* values);
    2626                ~TriaP1Input();
    2727                /*}}}*/
    28                 /*Object virtual functions definitions:{{{1 */
     28                /*Object virtual functions definitions:{{{ */
    2929                void  Echo();
    3030                void  DeepEcho();
     
    3434                Object* copy();
    3535                /*}}}*/
    36                 /*TriaP1Input management: {{{1*/
     36                /*TriaP1Input management: {{{*/
    3737                int   InstanceEnum();
    3838                Input* SpawnTriaInput(int* indices);
    39                 Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
     39                Input* PointwiseDivide(Input* inputB){_error2_("not implemented yet");};
    4040                Input* PointwiseMin(Input* inputB);
    4141                Input* PointwiseMax(Input* inputB);
    42                 ElementResult* SpawnResult(int step, double time);
    43                 void AddTimeValues(double* values,int step,double time){_error_("not supported yet");};
     42                ElementResult* SpawnResult(int step, IssmDouble time);
     43                void AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error2_("not supported yet");};
    4444                void Configure(Parameters* parameters);
    4545                /*}}}*/
    46                 /*numerics: {{{1*/
    47                 void GetInputValue(bool* pvalue){_error_("not implemented yet");}
    48                 void GetInputValue(int* pvalue){_error_("not implemented yet");}
    49                 void GetInputValue(double* pvalue){_error_("not implemented yet");}
    50                 void GetInputValue(double* pvalue,GaussTria* gauss);
    51                 void GetInputValue(double* pvalue,GaussPenta* gauss){_error_("not implemented yet");};
    52                 void GetInputValue(double* pvalue,GaussTria* gauss,double time){_error_("not implemented yet");};
    53                 void GetInputValue(double* pvalue,GaussPenta* gauss,double time){_error_("not implemented yet");};
    54                 void GetInputValue(double* pvalue,GaussTria* gauss ,int index){_error_("not implemented yet");};
    55                 void GetInputValue(double* pvalue,GaussPenta* gauss,int index){_error_("not implemented yet");};
    56                 void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss);
    57                 void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
    58                 void GetInputAverage(double* pvalue);
    59                 void GetVxStrainRate2d(double* epsilonvx,double* xyz_list, GaussTria* gauss);
    60                 void GetVyStrainRate2d(double* epsilonvy,double* xyz_list, GaussTria* gauss);
    61                 void GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
    62                 void GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
    63                 void GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
    64                 void GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
    65                 void GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
     46                /*numerics: {{{*/
     47                void GetInputValue(bool* pvalue){_error2_("not implemented yet");}
     48                void GetInputValue(int* pvalue){_error2_("not implemented yet");}
     49                void GetInputValue(IssmDouble* pvalue){_error2_("not implemented yet");}
     50                void GetInputValue(IssmDouble* pvalue,GaussTria* gauss);
     51                void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){_error2_("not implemented yet");};
     52                void GetInputValue(IssmDouble* pvalue,GaussTria* gauss,IssmDouble time){_error2_("not implemented yet");};
     53                void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,IssmDouble time){_error2_("not implemented yet");};
     54                void GetInputValue(IssmDouble* pvalue,GaussTria* gauss ,int index){_error2_("not implemented yet");};
     55                void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,int index){_error2_("not implemented yet");};
     56                void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss);
     57                void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
     58                void GetInputAverage(IssmDouble* pvalue);
     59                void GetVxStrainRate2d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussTria* gauss);
     60                void GetVyStrainRate2d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussTria* gauss);
     61                void GetVxStrainRate3d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
     62                void GetVyStrainRate3d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
     63                void GetVzStrainRate3d(IssmDouble* epsilonvz,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
     64                void GetVxStrainRate3dPattyn(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
     65                void GetVyStrainRate3dPattyn(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
    6666                void ChangeEnum(int newenumtype);
    6767
    68                 void SquareMin(double* psquaremin, bool process_units,Parameters* parameters);
    69                 void ConstrainMin(double minimum);
    70                 void Scale(double scale_factor);
    71                 void ArtificialNoise(double min,double max);
    72                 void AXPY(Input* xinput,double scalar);
    73                 void Constrain(double cm_min, double cm_max);
    74                 double InfinityNorm(void);
    75                 double Max(void);
    76                 double MaxAbs(void);
    77                 double Min(void);
    78                 double MinAbs(void);
    79                 void Extrude(void){_error_("not supported yet");};
    80                 void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");};
     68                void SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters);
     69                void ConstrainMin(IssmDouble minimum);
     70                void Scale(IssmDouble scale_factor);
     71                void ArtificialNoise(IssmDouble min,IssmDouble max);
     72                void AXPY(Input* xinput,IssmDouble scalar);
     73                void Constrain(IssmDouble cm_min, IssmDouble cm_max);
     74                IssmDouble InfinityNorm(void);
     75                IssmDouble Max(void);
     76                IssmDouble MaxAbs(void);
     77                IssmDouble Min(void);
     78                IssmDouble MinAbs(void);
     79                void Extrude(void){_error2_("not supported yet");};
     80                void VerticallyIntegrate(Input* thickness_input){_error2_("not supported yet");};
    8181                void GetVectorFromInputs(Vector* vector,int* doflist);
    82                 void GetValuesPtr(double** pvalues,int* pnum_values);
     82                void GetValuesPtr(IssmDouble** pvalues,int* pnum_values);
    8383                /*}}}*/
    8484
  • issm/trunk/src/c/objects/IoModel.cpp

    r12330 r12706  
    2222#include "../include/include.h"
    2323
    24 /*FUNCTION IoModel::IoModel(){{{1*/
     24/*FUNCTION IoModel::IoModel(){{{*/
    2525IoModel::IoModel(){
    2626        this->fid=NULL;
     
    3939}
    4040/*}}}*/
    41 /*FUNCTION IoModel::IoModel(FILE*  iomodel_handle){{{1*/
     41/*FUNCTION IoModel::IoModel(FILE*  iomodel_handle){{{*/
    4242IoModel::IoModel(FILE* iomodel_handle){
    4343       
     
    5050        /*Initialize and read constants:*/
    5151        this->constants=new Parameters();
    52         this->FetchConstants(); /*this routine goes through the input file, and fetches bools, ints, doubles and strings only, nothing memory intensive*/
     52        this->FetchConstants(); /*this routine goes through the input file, and fetches bools, ints, IssmDoubles and strings only, nothing memory intensive*/
    5353
    5454        /*Initialize data: */
    55         this->data=(double**)xmalloc(MaximumNumberOfEnums*sizeof(double*));
     55        this->data=xNew<IssmDouble*>(MaximumNumberOfEnums);
    5656        for(int i=0;i<MaximumNumberOfEnums;i++) this->data[i]=NULL;
    5757       
     
    6868}
    6969/*}}}*/
    70 /*FUNCTION IoModel::~IoModel(){{{1*/
     70/*FUNCTION IoModel::~IoModel(){{{*/
    7171IoModel::~IoModel(){
    7272
    73         delete this->constants;
     73        if(this->constants) delete this->constants;
    7474
    7575        /*Some checks in debugging mode*/
    7676        #ifdef _ISSM_DEBUG_
    77         for(int i=0;i<MaximumNumberOfEnums;i++){
    78                 if(this->data[i]){
    79                         _printf_("Info: previous pointer of %s has not been freed (DeleteData has not been called)",EnumToStringx(i));
     77        if(this->data){
     78                for(int i=0;i<MaximumNumberOfEnums;i++){
     79                        if(this->data[i]){
     80                                _pprintLine_("Info: previous pointer of " << EnumToStringx(i) << " has not been freed (DeleteData has not been called)");
     81                        }
    8082                }
    8183        }
    8284        #endif
    8385
    84         xfree((void**)&this->data);
    85 
    86         xfree((void**)&this->my_elements);
    87         xfree((void**)&this->my_nodes);
    88         xfree((void**)&this->my_vertices);
    89         xfree((void**)&this->singlenodetoelementconnectivity);
    90         xfree((void**)&this->numbernodetoelementconnectivity);
    91 }
    92 /*}}}*/
    93 
    94 /*FUNCTION IoModel::CheckEnumSync{{{1*/
     86        xDelete<IssmDouble*>(this->data);
     87        xDelete<bool>(this->my_elements);
     88        xDelete<bool>(this->my_nodes);
     89        xDelete<int>(this->my_vertices);
     90        xDelete<int>(this->singlenodetoelementconnectivity);
     91        xDelete<int>(this->numbernodetoelementconnectivity);
     92}
     93/*}}}*/
     94
     95/*FUNCTION IoModel::CheckEnumSync{{{*/
    9596void  IoModel::CheckEnumSync(void){
    9697
     
    9899        int record_enum = 0;
    99100
    100 
    101101        /*Check that some fields have been allocated*/
    102102        _assert_(this->fid || my_rank);
    103103
    104 
    105104        /*Go find in the binary file, the position of the data we want to fetch: */
    106105        if(my_rank==0){ //cpu 0
     
    111110                /*Get first Enum*/
    112111                if(fread(&record_enum,sizeof(int),1,this->fid)==0){
    113                         _error_("Marshalled file is empty");
     112                        _error2_("Marshalled file is empty");
    114113                }
    115114                else{
    116115                        if(record_enum!=MaximumNumberOfEnums){
    117                                 printf("\n");
    118                                 printf("=========================================================================\n");
    119                                 printf(" Enums in marshalled file are not compatible with compiled code          \n");
    120                                 printf("                                                                         \n");
    121                                 printf("   * If you are running ISSM on a remote cluster:                        \n");
    122                                 printf("     make sure that you are using the same version of ISSM on your local \n");
    123                                 printf("     machine and remote cluster (you might need to run svn update)       \n");
    124                                 printf("   * If you are running ISSM on your local machine:                      \n");
    125                                 printf("     make sure that all the code is compiled (modules and executables)   \n");
    126                                 printf("   * If you are a developer and just added a new Enum:                   \n");
    127                                 printf("     you might need to run ./Synchronize.sh in src/c/EnumDefinitions     \n");
    128                                 printf("     and recompile                                                       \n");
    129                                 printf("=========================================================================\n");
    130                                 printf("\n");
    131                                 _error_("Enums not consistent (See error message above)");
    132                         }
    133                 }
    134         }
    135 }
    136 /*}}}*/
    137 /*FUNCTION IoModel::Constant(bool* poutput,int constant_enum){{{1*/
     116                                _printLine_("");
     117                                _printLine_("=========================================================================");
     118                                _printLine_(" Enums in marshalled file are not compatible with compiled code          ");
     119                                _printLine_("                                                                         ");
     120                                _printLine_("   * If you are running ISSM on a remote cluster:                        ");
     121                                _printLine_("     make sure that you are using the same version of ISSM on your local ");
     122                                _printLine_("     machine and remote cluster (you might need to run svn update)       ");
     123                                _printLine_("   * If you are running ISSM on your local machine:                      ");
     124                                _printLine_("     make sure that all the code is compiled (modules and executables)   ");
     125                                _printLine_("   * If you are a developer and just added a new Enum:                   ");
     126                                _printLine_("     you might need to run ./Synchronize.sh in src/c/EnumDefinitions     ");
     127                                _printLine_("     and recompile                                                       ");
     128                                _printLine_("=========================================================================");
     129                                _printLine_("");
     130                                _error2_("Enums not consistent (See error message above)");
     131                        }
     132                }
     133        }
     134}
     135/*}}}*/
     136/*FUNCTION IoModel::Constant(bool* poutput,int constant_enum){{{*/
    138137void IoModel::Constant(bool* poutput,int constant_enum){
    139138
     
    144143}
    145144/*}}}*/
    146 /*FUNCTION IoModel::Constant(int* poutput,int constant_enum){{{1*/
     145/*FUNCTION IoModel::Constant(int* poutput,int constant_enum){{{*/
    147146void IoModel::Constant(int* poutput,int constant_enum){
    148147
     
    153152}
    154153/*}}}*/
    155 /*FUNCTION IoModel::Constant(double* poutput,int constant_enum){{{1*/
    156 void IoModel::Constant(double* poutput,int constant_enum){
     154/*FUNCTION IoModel::Constant(IssmDouble* poutput,int constant_enum){{{*/
     155void IoModel::Constant(IssmDouble* poutput,int constant_enum){
    157156
    158157        _assert_(constant_enum>=0);
     
    162161}
    163162/*}}}*/
    164 /*FUNCTION IoModel::Constant(char** poutput,int constant_enum){{{1*/
     163/*FUNCTION IoModel::Constant(char** poutput,int constant_enum){{{*/
    165164void IoModel::Constant(char** poutput,int constant_enum){
    166165
     
    171170}
    172171/*}}}*/
    173 /*FUNCTION IoModel::CopyConstantObject{{{1*/
     172/*FUNCTION IoModel::CopyConstantObject{{{*/
    174173Param* IoModel::CopyConstantObject(int constant_enum){
    175174
     
    178177        /*Find constant*/
    179178        Param* param=(Param*)this->constants->FindParamObject(constant_enum);
    180         if(!param) _error_("Constant %s not found in iomodel",EnumToStringx(constant_enum));
     179        if(!param) _error2_("Constant " << EnumToStringx(constant_enum) << " not found in iomodel");
    181180
    182181        return (Param*)param->copy();
    183182}
    184183/*}}}*/
    185 /*FUNCTION IoModel::Data{{{1*/
    186 double* IoModel::Data(int data_enum){
     184/*FUNCTION IoModel::Data{{{*/
     185IssmDouble* IoModel::Data(int data_enum){
    187186
    188187        _assert_(data_enum<MaximumNumberOfEnums);
     
    192191}
    193192/*}}}*/
    194 /*FUNCTION IoModel::DeleteData{{{1*/
     193/*FUNCTION IoModel::DeleteData{{{*/
    195194void  IoModel::DeleteData(int num,...){
    196195
     
    206205                dataenum=va_arg(ap, int);
    207206                _assert_(dataenum<MaximumNumberOfEnums);
    208                 xfree((void**)&this->data[dataenum]);
     207                xDelete<IssmDouble>(this->data[dataenum]);
    209208        }
    210209        va_end(ap);
    211210} /*}}}*/
    212 /*FUNCTION IoModel::FetchConstants{{{1*/
     211/*FUNCTION IoModel::FetchConstants{{{*/
    213212void  IoModel::FetchConstants(void){
    214213
     
    224223        int  booleanint=0;
    225224        int  integer=0;
    226         double scalar=0;
     225        IssmPDouble scalar=0;
    227226        char* string=NULL;
    228227        int   string_size;
     
    233232
    234233        /*Go find in the binary file, the position of the data we want to fetch: */
    235         if(my_rank==0){ //cpu 0{{{2
     234        if(my_rank==0){ //cpu 0{{{
    236235       
    237236                /*First set FILE* position to the beginning of the file: */
    238237                fseek(this->fid,0,SEEK_SET);
    239238
    240                 /*Now march through file looking for the correct data identifiers (bool,int,double or string): */
     239                /*Now march through file looking for the correct data identifiers (bool,int,IssmDouble or string): */
    241240                for(;;){
    242241                        if(fread(&record_enum,sizeof(int),1,this->fid)==0){
     
    267266                                        case 1:
    268267                                                /*Read the boolean and broadcast it to other cpus:*/
    269                                                 if(fread(&booleanint,sizeof(int),1,this->fid)!=1) _error_(" could not read boolean ");
     268                                                if(fread(&booleanint,sizeof(int),1,this->fid)!=1) _error2_("could not read boolean ");
    270269                                                #ifdef _HAVE_MPI_
    271270                                                MPI_Bcast(&booleanint,1,MPI_INT,0,MPI_COMM_WORLD);
     
    278277                                        case 2:
    279278                                                /*Read the integer and broadcast it to other cpus:*/
    280                                                 if(fread(&integer,sizeof(int),1,this->fid)!=1) _error_(" could not read integer ");
     279                                                if(fread(&integer,sizeof(int),1,this->fid)!=1) _error2_("could not read integer ");
    281280                                                #ifdef _HAVE_MPI_
    282281                                                MPI_Bcast(&integer,1,MPI_INT,0,MPI_COMM_WORLD);
     
    289288                                        case 3:
    290289                                                /*Read the scalar and broadcast it to other cpus:*/
    291                                                 if(fread(&scalar,sizeof(double),1,this->fid)!=1) _error_(" could not read scalar ");
     290                                                if(fread(&scalar,sizeof(IssmPDouble),1,this->fid)!=1) _error2_("could not read scalar ");
    292291                                                #ifdef _HAVE_MPI_
    293292                                                MPI_Bcast(&scalar,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
     
    300299                                        case 4:
    301300                                                /*We have to read a string from disk. First read the dimensions of the string, then the string: */
    302                                                 if(fread(&string_size,sizeof(int),1,this->fid)!=1) _error_(" could not read length of string ");
     301                                                if(fread(&string_size,sizeof(int),1,this->fid)!=1) _error2_("could not read length of string ");
    303302                                                #ifdef _HAVE_MPI_
    304303                                                MPI_Bcast(&string_size,1,MPI_INT,0,MPI_COMM_WORLD);
     
    306305
    307306                                                if(string_size){
    308                                                         string=(char*)xmalloc((string_size+1)*sizeof(char));
     307                                                        string=xNew<char>(string_size+1);
    309308                                                        string[string_size]='\0';
    310309
    311310                                                        /*Read string, then broadcast: */
    312                                                         if(fread(string,string_size*sizeof(char),1,this->fid)!=1)_error_(" could not read string ");
     311                                                        if(fread(string,string_size*sizeof(char),1,this->fid)!=1)_error2_(" could not read string ");
    313312                                                        #ifdef _HAVE_MPI_
    314313                                                        MPI_Bcast(string,string_size,MPI_CHAR,0,MPI_COMM_WORLD);
     
    316315                                                }
    317316                                                else{
    318                                                         string=(char*)xmalloc(sizeof(char));
     317                                                        string=xNew<char>(1);
    319318                                                        string[0]='\0';
    320319                                                }
     
    324323
    325324                                                /*Free string*/
    326                                                 xfree((void**)&string);
     325                                                xDelete<char>(string);
    327326
    328327                                                break;
     
    361360
    362361                                        default:
    363                                                 _error_("%s%i","unknown record type:",record_code);
     362                                                _error2_("unknown record type:" << record_code);
    364363                                                break;;
    365364                                }
     
    368367        } //}}}
    369368        #ifdef _HAVE_MPI_
    370         else{ //cpu ~0 {{{2
     369        else{ //cpu ~0 {{{
    371370                for(;;){ //wait on cpu 0
    372371                        MPI_Bcast(&record_code,1,MPI_INT,0,MPI_COMM_WORLD);  /*get from cpu 0 what we are going to do: */
     
    405404                                        MPI_Bcast(&string_size,1,MPI_INT,0,MPI_COMM_WORLD);
    406405                                        if(string_size){
    407                                                 string=(char*)xmalloc((string_size+1)*sizeof(char));
     406                                                string=xNew<char>((string_size+1));
    408407                                                string[string_size]='\0';
    409408
     
    412411                                        }
    413412                                        else{
    414                                                 string=(char*)xmalloc(sizeof(char));
     413                                                string=xNew<char>(1);
    415414                                                string[0]='\0';
    416415                                        }
     
    419418
    420419                                        /*Free string*/
    421                                         xfree((void**)&string);
     420                                        xDelete<char>(string);
    422421
    423422                                        break;
     
    429428
    430429                                default:
    431                                         _error_("%s%i","unknown record type:",record_code);
     430                                        _error2_("unknown record type:" << record_code);
    432431                                        break;;
    433432                                }
     
    440439}
    441440/*}}}*/
    442 /*FUNCTION IoModel::FetchData(bool*     pbool,int data_enum){{{1*/
     441/*FUNCTION IoModel::FetchData(bool*     pbool,int data_enum){{{*/
    443442void  IoModel::FetchData(bool* pboolean,int data_enum){
    444443
     
    454453        fid=this->SetFilePointerToData(&code,NULL,data_enum);
    455454
    456         if(code!=1)_error_("expecting a boolean for enum %s",EnumToStringx(data_enum));
     455        if(code!=1)_error2_("expecting a boolean for enum " << EnumToStringx(data_enum));
    457456       
    458457        /*We have to read a boolean from disk. */
    459458        if(my_rank==0){ 
    460                 if(fread(&booleanint,sizeof(int),1,fid)!=1) _error_(" could not read boolean ");
     459                if(fread(&booleanint,sizeof(int),1,fid)!=1) _error2_("could not read boolean ");
    461460        }
    462461        #ifdef _HAVE_MPI_
     
    470469}
    471470/*}}}*/
    472 /*FUNCTION IoModel::FetchData(int*      pinteger,int data_enum){{{1*/
     471/*FUNCTION IoModel::FetchData(int*      pinteger,int data_enum){{{*/
    473472void  IoModel::FetchData(int* pinteger,int data_enum){
    474473
    475474        extern int my_rank;
    476475        extern int num_procs;
    477        
    478476
    479477        /*output: */
     
    484482        fid=this->SetFilePointerToData(&code,NULL,data_enum);
    485483       
    486         if(code!=2)_error_("expecting an integer for enum %s",EnumToStringx(data_enum));
     484        if(code!=2)_error2_("expecting an integer for enum " << EnumToStringx(data_enum));
    487485       
    488486        /*We have to read a integer from disk. First read the dimensions of the integer, then the integer: */
    489487        if(my_rank==0){ 
    490                 if(fread(&integer,sizeof(int),1,fid)!=1) _error_(" could not read integer ");
     488                if(fread(&integer,sizeof(int),1,fid)!=1) _error2_("could not read integer ");
    491489        }
    492490
     
    497495        /*Assign output pointers: */
    498496        *pinteger=integer;
    499 
    500 }
    501 /*}}}*/
    502 /*FUNCTION IoModel::FetchData(double*   pscalar,int data_enum){{{1*/
    503 void  IoModel::FetchData(double* pscalar,int data_enum){
     497}
     498/*}}}*/
     499/*FUNCTION IoModel::FetchData(IssmDouble*   pscalar,int data_enum){{{*/
     500void  IoModel::FetchData(IssmDouble* pscalar,int data_enum){
    504501
    505502
     
    509506
    510507        /*output: */
    511         double   scalar;
     508        IssmPDouble   scalar;
    512509        int      code;
    513510       
     
    515512        fid=this->SetFilePointerToData(&code,NULL,data_enum);
    516513       
    517         if(code!=3)_error_("expecting a double for enum %s",EnumToStringx(data_enum));
     514        if(code!=3)_error2_("expecting a IssmDouble for enum " << EnumToStringx(data_enum));
    518515       
    519516        /*We have to read a scalar from disk. First read the dimensions of the scalar, then the scalar: */
    520517        if(my_rank==0){
    521                 if(fread(&scalar,sizeof(double),1,fid)!=1)_error_(" could not read scalar ");
     518                if(fread(&scalar,sizeof(IssmPDouble),1,fid)!=1)_error2_("could not read scalar ");
    522519        }
    523520        #ifdef _HAVE_MPI_
     
    530527}
    531528/*}}}*/
    532 /*FUNCTION IoModel::FetchData(char**    pstring,int data_enum){{{1*/
     529/*FUNCTION IoModel::FetchData(char**    pstring,int data_enum){{{*/
    533530void  IoModel::FetchData(char** pstring,int data_enum){
    534531
     
    545542        fid=this->SetFilePointerToData(&code,NULL,data_enum);
    546543       
    547         if(code!=4)_error_("expecting a string for enum %s",EnumToStringx(data_enum));
     544        if(code!=4)_error2_("expecting a string for enum " << EnumToStringx(data_enum));
    548545       
    549546        /*Now fetch: */
     
    551548        /*We have to read a string from disk. First read the dimensions of the string, then the string: */
    552549        if(my_rank==0){ 
    553                 if(fread(&string_size,sizeof(int),1,fid)!=1) _error_(" could not read length of string ");
     550                if(fread(&string_size,sizeof(int),1,fid)!=1) _error2_("could not read length of string ");
    554551        }
    555552
     
    560557        /*Now allocate string: */
    561558        if(string_size){
    562                 string=(char*)xmalloc((string_size+1)*sizeof(char));
     559                string=xNew<char>((string_size+1));
    563560                string[string_size]='\0';
    564561
    565562                /*Read string on node 0, then broadcast: */
    566563                if(my_rank==0){ 
    567                         if(fread(string,string_size*sizeof(char),1,fid)!=1)_error_(" could not read string ");
     564                        if(fread(string,string_size*sizeof(char),1,fid)!=1)_error2_(" could not read string ");
    568565                }
    569566                #ifdef _HAVE_MPI_
     
    572569        }
    573570        else{
    574                 string=(char*)xmalloc(sizeof(char));
     571                string=xNew<char>(1);
    575572                string[0]='\0';
    576573        }
     
    581578}
    582579/*}}}*/
    583 /*FUNCTION IoModel::FetchData(int**  pintegerematrix,int* pM,int* pN,int data_enum){{{1*/
     580/*FUNCTION IoModel::FetchData(int**     pintegerematrix,int* pM,int* pN,int data_enum){{{*/
    584581void  IoModel::FetchData(int** pmatrix,int* pM,int* pN,int data_enum){
    585582
     
    590587        /*output: */
    591588        int M,N;
    592         double* matrix=NULL;
     589        IssmPDouble* matrix=NULL;
    593590        int*    integer_matrix=NULL;
    594591        int code=0;
     
    599596        fid=this->SetFilePointerToData(&code,&vector_type,data_enum);
    600597
    601         if((code!=5) && (code!=6) && (code!=7))_error_("expecting a double, integer or boolean matrix for enum %s",EnumToStringx(data_enum));
     598        if((code!=5) && (code!=6) && (code!=7))_error2_("expecting a IssmDouble, integer or boolean matrix for enum " << EnumToStringx(data_enum));
    602599       
    603600        /*Now fetch: */
     
    606603        /*numberofelements: */
    607604        if(my_rank==0){ 
    608                 if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix ");
     605                if(fread(&M,sizeof(int),1,fid)!=1) _error2_("could not read number of rows for matrix ");
    609606        }
    610607
     
    614611
    615612        if(my_rank==0){ 
    616                 if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix ");
     613                if(fread(&N,sizeof(int),1,fid)!=1) _error2_("could not read number of columns for matrix ");
    617614        }
    618615        #ifdef _HAVE_MPI_
     
    622619        /*Now allocate matrix: */
    623620        if(M*N){
    624                 matrix=(double*)xmalloc(M*N*sizeof(double));
     621                matrix=xNew<IssmPDouble>(M*N);
    625622
    626623                /*Read matrix on node 0, then broadcast: */
    627624                if(my_rank==0){ 
    628                         if(fread(matrix,M*N*sizeof(double),1,fid)!=1) _error_("could not read matrix ");
     625                        if(fread(matrix,M*N*sizeof(IssmPDouble),1,fid)!=1) _error2_("could not read matrix ");
    629626                }
    630627               
     
    636633        /*Now cast to integer: */
    637634        if(M*N){
    638                 integer_matrix=(int*)xmalloc(M*N*sizeof(int));
     635                integer_matrix=xNew<int>(M*N);
    639636                for (i=0;i<M;i++){
    640637                        for (j=0;j<N;j++){
     
    647644        }
    648645        /*Free ressources:*/
    649         xfree((void**)&matrix);
     646        xDelete<IssmPDouble>(matrix);
    650647
    651648        /*Assign output pointers: */
     
    656653}
    657654/*}}}*/
    658 /*FUNCTION IoModel::FetchData(double**  pdoublematrix,int* pM,int* pN,int data_enum){{{1*/
    659 void  IoModel::FetchData(double** pmatrix,int* pM,int* pN,int data_enum){
     655/*FUNCTION IoModel::FetchData(IssmDouble**  pIssmDoublematrix,int* pM,int* pN,int data_enum){{{*/
     656void  IoModel::FetchData(IssmDouble** pmatrix,int* pM,int* pN,int data_enum){
    660657
    661658        extern int my_rank;
     
    664661        /*output: */
    665662        int M,N;
    666         double* matrix=NULL;
     663        IssmPDouble* matrix=NULL;
    667664        int code=0;
    668665        int vector_type=0;
     
    670667        /*Set file pointer to beginning of the data: */
    671668        fid=this->SetFilePointerToData(&code,&vector_type,data_enum);
    672         if((code!=5) && (code!=6) && (code!=7))_error_("expecting a double, integer or boolean matrix for enum %s",EnumToStringx(data_enum));
     669        if((code!=5) && (code!=6) && (code!=7))_error2_("expecting a IssmDouble, integer or boolean matrix for enum " << EnumToStringx(data_enum));
    673670       
    674671        /*Now fetch: */
     
    677674        /*numberofelements: */
    678675        if(my_rank==0){ 
    679                 if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix ");
     676                if(fread(&M,sizeof(int),1,fid)!=1) _error2_("could not read number of rows for matrix ");
    680677        }
    681678        #ifdef _HAVE_MPI_
     
    684681
    685682        if(my_rank==0){ 
    686                 if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix ");
     683                if(fread(&N,sizeof(int),1,fid)!=1) _error2_("could not read number of columns for matrix ");
    687684        }
    688685        #ifdef _HAVE_MPI_
     
    692689        /*Now allocate matrix: */
    693690        if(M*N){
    694                 matrix=(double*)xmalloc(M*N*sizeof(double));
     691                matrix=xNew<IssmPDouble>(M*N);
    695692
    696693                /*Read matrix on node 0, then broadcast: */
    697694                if(my_rank==0){ 
    698                         if(fread(matrix,M*N*sizeof(double),1,fid)!=1) _error_("could not read matrix ");
     695                        if(fread(matrix,M*N*sizeof(IssmPDouble),1,fid)!=1) _error2_("could not read matrix ");
    699696                }
    700697                #ifdef _HAVE_MPI_
    701698                MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,MPI_COMM_WORLD);
    702699                #endif
    703         }
    704 
     700                *pmatrix=xNew<IssmDouble>(M*N);
     701                for (int i=0;i<M*N;++i) (*pmatrix)[i]=matrix[i];
     702                xDelete<IssmPDouble>(matrix);
     703        }
     704        else
     705          *pmatrix=NULL;
    705706        /*Assign output pointers: */
    706         *pmatrix=matrix;
    707707        if (pM)*pM=M;
    708708        if (pN)*pN=N;
    709709}
    710710/*}}}*/
    711 /*FUNCTION IoModel::FetchData(char***   pstrings,int* pnumstrings,int data_enum){{{1*/
     711/*FUNCTION IoModel::FetchData(char***   pstrings,int* pnumstrings,int data_enum){{{*/
    712712void  IoModel::FetchData(char*** pstrings,int* pnumstrings,int data_enum){
    713713
     
    729729        fid=this->SetFilePointerToData(&code,NULL,data_enum);
    730730       
    731         if(code!=9)_error_("expecting a string array for enum %s",EnumToStringx(data_enum));
     731        if(code!=9)_error2_("expecting a string array for enum " << EnumToStringx(data_enum));
    732732       
    733733        /*We have to read a bunch of strings from disk. First read the number of strings, and allocate: */
    734734        if(my_rank==0){ 
    735                 if(fread(&numstrings,sizeof(int),1,fid)!=1) _error_(" could not read length of string array");
     735                if(fread(&numstrings,sizeof(int),1,fid)!=1) _error2_("could not read length of string array");
    736736        }
    737737        #ifdef _HAVE_MPI_
     
    741741        /*Now allocate string array: */
    742742        if(numstrings){
    743                 strings=(char**)xmalloc(numstrings*sizeof(char*));
     743                strings=xNew<char*>(numstrings);
    744744                for(i=0;i<numstrings;i++)strings[i]=NULL;
    745745
     
    748748                       
    749749                        if(my_rank==0){ 
    750                                 if(fread(&string_size,sizeof(int),1,fid)!=1) _error_(" could not read length of string ");
     750                                if(fread(&string_size,sizeof(int),1,fid)!=1) _error2_("could not read length of string ");
    751751                        }
    752752                        #ifdef _HAVE_MPI_
     
    754754                        #endif
    755755                        if(string_size){
    756                                 string=(char*)xmalloc((string_size+1)*sizeof(char));
     756                                string=xNew<char>((string_size+1));
    757757                                string[string_size]='\0';
    758758
    759759                                /*Read string on node 0, then broadcast: */
    760760                                if(my_rank==0){ 
    761                                         if(fread(string,string_size*sizeof(char),1,fid)!=1)_error_(" could not read string ");
     761                                        if(fread(string,string_size*sizeof(char),1,fid)!=1)_error2_(" could not read string ");
    762762                                }
    763763                                #ifdef _HAVE_MPI_
     
    766766                        }
    767767                        else{
    768                                 string=(char*)xmalloc(sizeof(char));
     768                                string=xNew<char>(1);
    769769                                string[0]='\0';
    770770                        }
     
    779779}
    780780/*}}}*/
    781 /*FUNCTION IoModel::FetchData(double*** pmatrices,int** pmdims,int** pndims, int* pM,int data_enum){{{1*/
    782 void  IoModel::FetchData(double*** pmatrices,int** pmdims,int** pndims, int* pnumrecords,int data_enum){
     781/*FUNCTION IoModel::FetchData(IssmDouble*** pmatrices,int** pmdims,int** pndims, int* pM,int data_enum){{{*/
     782void  IoModel::FetchData(IssmDouble*** pmatrices,int** pmdims,int** pndims, int* pnumrecords,int data_enum){
    783783
    784784        int i;
     
    788788
    789789        /*output: */
    790         double** matrices=NULL;
     790        IssmDouble** matrices=NULL;
    791791        int*     mdims=NULL;
    792792        int*     ndims=NULL;
     
    795795        /*intermediary: */
    796796        int     M, N;
    797         double *matrix = NULL;
     797        IssmPDouble *matrix = NULL;
    798798        int     code;
    799799       
    800800        /*Set file pointer to beginning of the data: */
    801801        fid=this->SetFilePointerToData(&code,NULL,data_enum);
    802         if(code!=8)_error_("expecting a double mat array for enum %s",EnumToStringx(data_enum));
     802        if(code!=8)_error2_("expecting a IssmDouble mat array for enum " << EnumToStringx(data_enum));
    803803       
    804804        /*Now fetch: */
    805805        if(my_rank==0){ 
    806                 if(fread(&numrecords,sizeof(int),1,fid)!=1) _error_("could not read number of records in matrix array ");
     806                if(fread(&numrecords,sizeof(int),1,fid)!=1) _error2_("could not read number of records in matrix array ");
    807807        }
    808808        #ifdef _HAVE_MPI_
     
    813813
    814814                /*Allocate matrices :*/
    815                 matrices=(double**)xmalloc(numrecords*sizeof(double*));
    816                 mdims=(int*)xmalloc(numrecords*sizeof(int));
    817                 ndims=(int*)xmalloc(numrecords*sizeof(int));
     815                matrices=xNew<IssmDouble*>(numrecords);
     816                mdims=xNew<int>(numrecords);
     817                ndims=xNew<int>(numrecords);
    818818
    819819                for(i=0;i<numrecords;i++){
     
    827827
    828828                        if(my_rank==0){ 
    829                                 if(fread(&M,sizeof(int),1,fid)!=1) _error_("%s%i%s","could not read number of rows in ",i,"th matrix of matrix array");
     829                                if(fread(&M,sizeof(int),1,fid)!=1) _error2_("could not read number of rows in " << i << "th matrix of matrix array");
    830830                        }
    831831                        #ifdef _HAVE_MPI_
     
    834834
    835835                        if(my_rank==0){ 
    836                                 if(fread(&N,sizeof(int),1,fid)!=1) _error_("%s%i%s","could not read number of columns in ",i,"th matrix of matrix array");
     836                                if(fread(&N,sizeof(int),1,fid)!=1) _error2_("could not read number of columns in " << i << "th matrix of matrix array");
    837837                        }
    838838                        #ifdef _HAVE_MPI_
     
    842842                        /*Now allocate matrix: */
    843843                        if(M*N){
    844                                 matrix=(double*)xmalloc(M*N*sizeof(double));
     844                                matrix=xNew<IssmPDouble>(M*N);
    845845
    846846                                /*Read matrix on node 0, then broadcast: */
    847847                                if(my_rank==0){ 
    848                                         if(fread(matrix,M*N*sizeof(double),1,fid)!=1) _error_("could not read matrix ");
     848                                        if(fread(matrix,M*N*sizeof(IssmPDouble),1,fid)!=1) _error2_("could not read matrix ");
    849849                                }
    850850
     
    852852                                MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,MPI_COMM_WORLD);
    853853                                #endif
    854                         }
    855 
     854                                matrices[i]=xNew<IssmDouble>(M*N);
     855                                for (int j=0;j<M*N;++j) {matrices[i][j]=matrix[j];}
     856                                xDelete<IssmPDouble>(matrix);
     857                        }
     858                        else
     859                          matrices[i]=NULL;
    856860                        /*Assign: */
    857                         matrices[i]=matrix;
    858861                        mdims[i]=M;
    859862                        ndims[i]=N;
     
    868871}
    869872/*}}}*/
    870 /*FUNCTION IoModel::FetchData(int num,...){{{1*/
     873/*FUNCTION IoModel::FetchData(Option**  poption,int data_enum){{{*/
     874void  IoModel::FetchData(Option** poption,int index){
     875
     876        extern int my_rank;
     877        extern int num_procs;
     878
     879        /*output: */
     880        int     code;
     881        Option *option      = NULL;
     882        char   *name        = NULL;
     883
     884        /*First get option name*/
     885        this->FetchData(&name,index);
     886
     887        /*Get option value*/
     888        fid=this->SetFilePointerToData(&code,NULL,index+1);
     889        switch(code){
     890                case 3: {//IssmDouble
     891                          IssmDouble *value = NULL;
     892                          value=xNew<IssmDouble>(1);
     893                          FetchData(value,index+1);
     894                          option = new OptionDouble();
     895                          ((OptionDouble*)option)->values = value;
     896                          option->name  = name;
     897                          option->numel = 1;
     898                          option->ndims = 1;
     899                          option->size  = NULL;
     900                          break;
     901                          }
     902                case 4: {//char
     903                          char* value = NULL;
     904                          FetchData(&value,index+1);
     905                          option = new OptionChar();
     906                          ((OptionChar*)option)->values = value;
     907                          option->name  = name;
     908                          option->numel = 1;
     909                          option->ndims = 1;
     910                          option->size  = NULL;
     911                          break;
     912                          }
     913                default:
     914                          _error2_("Option of format " << code << " not supported yet");
     915        }
     916
     917        /*Assign output pointers: */
     918        *poption=option;
     919}
     920/*}}}*/
     921/*FUNCTION IoModel::FetchData(int num,...){{{*/
    871922void  IoModel::FetchData(int num,...){
    872923
    873924        va_list ap;
    874925        int     dataenum;
    875         double* matrix=NULL;
     926        IssmDouble* matrix=NULL;
    876927        int     M,N;
    877928        int     i;
    878929
    879930        /*Go through the entire list of enums and fetch the corresponding data. Add it to the iomodel->data dataset. Everything
    880          *we fetch is a double* : */
     931         *we fetch is a IssmDouble* : */
    881932       
    882933        va_start(ap,num);
     
    890941                _assert_(dataenum<MaximumNumberOfEnums);
    891942                if(this->data[dataenum]){
    892                         _error_("Info: trying to fetch %s but previous pointer has not been freed (DeleteData has not been called)",EnumToStringx(dataenum));
     943                        _error2_("Info: trying to fetch " << EnumToStringx(dataenum) << " but previous pointer has not been freed (DeleteData has not been called)");
    893944                }
    894945                #endif
     
    903954}
    904955/*}}}*/
    905 /*FUNCTION IoModel::FetchDataToInput{{{1*/
    906 void IoModel::FetchDataToInput(Elements* elements,int vector_enum,int default_vector_enum,double default_value){
     956/*FUNCTION IoModel::FetchDataToInput{{{*/
     957void IoModel::FetchDataToInput(Elements* elements,int vector_enum,int default_vector_enum,IssmDouble default_value){
    907958
    908959        /*intermediary: */
     
    923974        bool    boolean;
    924975        int     integer;
    925         double  scalar;
     976        IssmDouble  scalar;
    926977        char   *string        = NULL;
    927         double *doublevector  = NULL;
     978        IssmDouble *IssmDoublevector  = NULL;
    928979        int     M,N;
    929980
     
    935986
    936987        switch(code){
    937                 case 1: //boolean constant.  {{{2
     988                case 1: //boolean constant.  {{{
    938989                        this->FetchData(&boolean,vector_enum);
    939990
     
    943994                                if(this->my_elements[i]){
    944995                                        Element* element=(Element*)elements->GetObjectByOffset(counter);
    945                                         element->InputCreate((double)boolean,vector_enum,code);
     996                                        element->InputCreate((IssmDouble)boolean,vector_enum,code);
    946997                                        counter++;
    947998                                }
    948999                        }
    9491000                        break; /*}}}*/
    950                 case 2: //integer constant.  {{{2
     1001                case 2: //integer constant.  {{{
    9511002                        this->FetchData(&integer,vector_enum);
    9521003
     
    9561007                                if(this->my_elements[i]){
    9571008                                        Element* element=(Element*)elements->GetObjectByOffset(counter);
    958                                         element->InputCreate((double)integer,vector_enum,code);
     1009                                        element->InputCreate((IssmDouble)integer,vector_enum,code);
    9591010                                        counter++;
    9601011                                }
    9611012                        }
    9621013                        break; /*}}}*/
    963                 case 3: //double constant.  {{{2
     1014                case 3: //IssmDouble constant.  {{{
    9641015                        this->FetchData(&scalar,vector_enum);
    9651016
    966                         /*Add double constant input to all elements: */
     1017                        /*Add IssmDouble constant input to all elements: */
    9671018                        counter=0;
    9681019                        for (i=0;i<numberofelements;i++){
     
    9741025                        }
    9751026                        break; /*}}}*/
    976                 case 5: //boolean vector.  {{{2
     1027                case 5: //boolean vector.  {{{
    9771028
    9781029                        /*Fetch vector:*/
    979                         this->FetchData(&doublevector,&M,&N,vector_enum); //we still have a doublevector, because it might include times in transient mode
     1030                        this->FetchData(&IssmDoublevector,&M,&N,vector_enum); //we still have a IssmDoublevector, because it might include times in transient mode
    9801031                        /*Check we got something, otherwise fetch default: */
    981                         if(doublevector){
     1032                        if(IssmDoublevector){
    9821033                                defaulting=false;  //we are not defaulting, because  we do have a vector
    9831034                        }
     
    9861037                                if(default_vector_enum!=NoneEnum){
    9871038                                        /*yes. fetch it: */
    988                                         this->FetchData(&doublevector,&M,&N,default_vector_enum);
    989                                         if(doublevector){
     1039                                        this->FetchData(&IssmDoublevector,&M,&N,default_vector_enum);
     1040                                        if(IssmDoublevector){
    9901041                                                defaulting=false;  //we are not defaulting, because  we do have a vector
    9911042                                        }
     
    10071058                                        Element* element=(Element*)elements->GetObjectByOffset(counter);
    10081059                                        if(defaulting) element->InputCreate(default_value,vector_enum,code);
    1009                                         else           element->InputCreate(doublevector,i,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements.
     1060                                        else           element->InputCreate(IssmDoublevector,i,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements.
    10101061                                        counter++;
    10111062                                }
    10121063                        }
    10131064                        break; /*}}}*/
    1014                 case 6: //int vector.  {{{2
     1065                case 6: //int vector{{{
    10151066
    10161067                        /*Fetch vector:*/
    1017                         this->FetchData(&doublevector,&M,&N,vector_enum); //we still have a doublevector, because it might include times in transient mode
     1068                        this->FetchData(&IssmDoublevector,&M,&N,vector_enum); //we still have a IssmDoublevector, because it might include times in transient mode
    10181069                        /*Check we got something, otherwise fetch default: */
    1019                         if(doublevector){
     1070                        if(IssmDoublevector){
    10201071                                defaulting=false;  //we are not defaulting, because  we do have a vector
    10211072                        }
     
    10241075                                if(default_vector_enum!=NoneEnum){
    10251076                                        /*yes. fetch it: */
    1026                                         this->FetchData(&doublevector,&M,&N,default_vector_enum);
    1027                                         if(doublevector){
     1077                                        this->FetchData(&IssmDoublevector,&M,&N,default_vector_enum);
     1078                                        if(IssmDoublevector){
    10281079                                                defaulting=false;  //we are not defaulting, because  we do have a vector
    10291080                                        }
     
    10451096                                        Element* element=(Element*)elements->GetObjectByOffset(counter);
    10461097                                        if(defaulting) element->InputCreate(default_value,vector_enum,code);
    1047                                         else           element->InputCreate(doublevector,i,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements.
     1098                                        else           element->InputCreate(IssmDoublevector,i,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements.
    10481099                                        counter++;
    10491100                                }
    10501101                        }
    10511102                        break; /*}}}*/
    1052                 case 7: //double vector.  {{{2
     1103                case 7: //IssmDouble vector{{{
    10531104
    10541105                        /*Fetch vector:*/
    1055                         this->FetchData(&doublevector,&M,&N,vector_enum);
     1106                        this->FetchData(&IssmDoublevector,&M,&N,vector_enum);
    10561107                        /*Check we got something, otherwise fetch default: */
    1057                         if(doublevector){
     1108                        if(IssmDoublevector){
    10581109                                defaulting=false;  //we are not defaulting, because  we do have a vector
    10591110                        }
     
    10621113                                if(default_vector_enum!=NoneEnum){
    10631114                                        /*yes. fetch it: */
    1064                                         this->FetchData(&doublevector,&M,&N,default_vector_enum);
    1065                                         if(doublevector){
     1115                                        this->FetchData(&IssmDoublevector,&M,&N,default_vector_enum);
     1116                                        if(IssmDoublevector){
    10661117                                                defaulting=false;  //we are not defaulting, because  we do have a vector
    10671118                                        }
     
    10831134                                        Element* element=(Element*)elements->GetObjectByOffset(counter);
    10841135                                        if(defaulting) element->InputCreate(default_value,vector_enum,code);
    1085                                         else           element->InputCreate(doublevector,i,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements.
     1136                                        else           element->InputCreate(IssmDoublevector,i,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements.
    10861137                                        counter++;
    10871138                                }
     
    10891140
    10901141                        break; /*}}}*/
    1091                 default: /*{{{2*/
    1092                         _error_("%s%i%s","data code ",code," not supported yet!");
     1142                default: /*{{{*/
     1143                        _error2_("data code " << code << " not supported yet!");
    10931144                        break;
    10941145                        /*}}}*/
    10951146        }
    10961147        /*Free ressources:*/
    1097         xfree((void**)&doublevector);
    1098         xfree((void**)&string);
    1099 }
    1100 /*FUNCTION IoModel::SetFilePointerToData{{{1*/
     1148        xDelete<IssmDouble>(IssmDoublevector);
     1149        xDelete<char>(string);
     1150}
     1151/*FUNCTION IoModel::LastIndex{{{*/
     1152void IoModel::LastIndex(int *pindex){
     1153
     1154        extern int my_rank;
     1155        int        lastindex,index;
     1156        int        record_length;
     1157
     1158        /*Go find in the binary file, the position of the data we want to fetch: */
     1159        if(my_rank==0){
     1160
     1161                /*First set FILE* position to the beginning of the file: */
     1162                fseek(fid,0,SEEK_SET);
     1163
     1164                /*Now march through file looking for the correct data identifier: */
     1165                for(;;){
     1166                        /*Read enum for this size of first string name: */
     1167                        if(fread(&index,sizeof(int),1,fid)==0){
     1168                                /*Ok, we have reached the end of the file. break: */
     1169                                break;
     1170                        }
     1171
     1172                        /*read the record length, and use it to skip this record: */
     1173                        fread(&record_length,sizeof(int),1,fid);
     1174                        fseek(fid,record_length,SEEK_CUR);
     1175                        lastindex=index;
     1176                }
     1177        }
     1178        /*Broadcast code and vector type: */
     1179#ifdef _HAVE_MPI_
     1180        MPI_Bcast(&lastindex,1,MPI_INT,0,MPI_COMM_WORLD);
     1181#endif
     1182
     1183        /*Assign output pointers:*/
     1184        *pindex=lastindex;
     1185}
     1186/*FUNCTION IoModel::SetFilePointerToData{{{*/
    11011187FILE* IoModel::SetFilePointerToData(int* pcode,int* pvector_type, int data_enum){
    11021188
    11031189        extern int my_rank;
    11041190        extern int num_procs;
    1105        
     1191
    11061192        int found=0;
    11071193        int record_enum;
     
    11091195        int record_code; //1 to 7 number
    11101196        int vector_type; //nodal or elementary
    1111  
     1197
    11121198        /*Go find in the binary file, the position of the data we want to fetch: */
    11131199        if(my_rank==0){
    1114        
     1200
    11151201                /*First set FILE* position to the beginning of the file: */
    11161202                fseek(fid,0,SEEK_SET);
     
    11241210                                break;
    11251211                        }
    1126                        
     1212
    11271213                        /*Is this the record sought for? : */
    11281214                        if (data_enum==record_enum){
     
    11441230                }
    11451231        }
    1146         #ifdef _HAVE_MPI_
     1232#ifdef _HAVE_MPI_
    11471233        MPI_Bcast(&found,1,MPI_INT,0,MPI_COMM_WORLD);
    1148         if(!found)_error_("%s %s ","could not find data with name",EnumToStringx(data_enum));
    1149         #endif
     1234        if(!found)_error2_("could not find data with name" << " " << EnumToStringx(data_enum) << " ");
     1235#endif
    11501236
    11511237        /*Broadcast code and vector type: */
    1152         #ifdef _HAVE_MPI_
     1238#ifdef _HAVE_MPI_
    11531239        MPI_Bcast(&record_code,1,MPI_INT,0,MPI_COMM_WORLD);
    11541240        MPI_Bcast(&vector_type,1,MPI_INT,0,MPI_COMM_WORLD);
    11551241        if(record_code==5) MPI_Bcast(&vector_type,1,MPI_INT,0,MPI_COMM_WORLD);
    1156         #endif
     1242#endif
    11571243
    11581244        /*Assign output pointers:*/
  • issm/trunk/src/c/objects/IoModel.h

    r12330 r12706  
    1313class Elements;
    1414class Param;
    15 
     15class Option;
    1616
    1717class IoModel {
    1818
    1919        private:
    20                 FILE        *fid;         //pointer to input file
    21                 IssmDouble     **data;        //this dataset holds temporary data, memory intensive.
     20                IssmDouble **data;        //this dataset holds temporary data, memory intensive.
    2221                Parameters  *constants;   //this dataset holds all IssmDouble, int, bool and char *parameters read in from the input file.*
    2322
    2423        public:
    2524                /*This data needs to stay memory resident at all time, even if it's memory intensive: */
     25                FILE *fid;         //pointer to input file
    2626                bool *my_elements;
    2727                bool *my_nodes;
     
    4141
    4242                /*Input/Output*/
    43                 void    CheckEnumSync(void);
    44                 void    Constant(bool  *poutput,int constant_enum);
    45                 void    Constant(int    *poutput,int constant_enum);
    46                 void    Constant(IssmDouble *poutput,int constant_enum);
    47                 void    Constant(char **poutput,int constant_enum);
    48                 Param  *CopyConstantObject(int constant_enum);
     43                void        CheckEnumSync(void);
     44                void        Constant(bool *poutput,int constant_enum);
     45                void        Constant(int *poutput,int constant_enum);
     46                void        Constant(IssmDouble *poutput,int constant_enum);
     47                void        Constant(char **poutput,int constant_enum);
     48                Param      *CopyConstantObject(int constant_enum);
    4949                IssmDouble *Data(int dataenum);
    50                 void    DeleteData(int num,...);
    51                 void    FetchConstants(void);
    52                 void    FetchData(bool*     pboolean,int data_enum);
    53                 void    FetchData(int*      pinteger,int data_enum);
    54                 void    FetchData(IssmDouble*   pscalar,int data_enum);
    55                 void    FetchData(char**    pstring,int data_enum);
    56                 void    FetchData(int** pmatrix,int* pM,int* pN,int data_enum);
    57                 void    FetchData(IssmDouble**  pscalarmatrix,int* pM,int* pN,int data_enum);
    58                 void    FetchData(char***   pstringarray,int* pnumstrings,int data_enum);
    59                 void    FetchData(IssmDouble*** pmatrixarray,int** pmdims,int** pndims, int* pnumrecords,int data_enum);
    60                 void    FetchData(int num,...);
    61                 void    FetchDataToInput(Elements* elements,int vector_enum,int default_vector_enum=NoneEnum,IssmDouble default_value=0);
    62                 FILE*   SetFilePointerToData(int* pcode,int* pvector_type, int data_enum);
     50                void        DeleteData(int num,...);
     51                void        FetchConstants(void);
     52                void        FetchData(bool* pboolean,int data_enum);
     53                void        FetchData(int* pinteger,int data_enum);
     54                void        FetchData(IssmDouble* pscalar,int data_enum);
     55                void        FetchData(char** pstring,int data_enum);
     56                void        FetchData(int** pmatrix,int* pM,int* pN,int data_enum);
     57                void        FetchData(IssmDouble**  pscalarmatrix,int* pM,int* pN,int data_enum);
     58                void        FetchData(char***   pstringarray,int* pnumstrings,int data_enum);
     59                void        FetchData(IssmDouble*** pmatrixarray,int** pmdims,int** pndims, int* pnumrecords,int data_enum);
     60                void        FetchData(Option **poption,int data_enum);
     61                void        FetchData(int num,...);
     62                void        FetchDataToInput(Elements* elements,int vector_enum,int default_vector_enum=NoneEnum,IssmDouble default_value=0);
     63                void        LastIndex(int *pindex);
     64                FILE*       SetFilePointerToData(int* pcode,int* pvector_type, int data_enum);
    6365};
    6466
  • issm/trunk/src/c/objects/KML/KMLFileReadUtils.cpp

    r11527 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2020/*}}}*/
    2121
    22 /*FUNCTION  KMLFileToken(FILE* fid,int* pncom=NULL,char*** ppcom=NULL) {{{1*/
     22/*FUNCTION  KMLFileToken(FILE* fid,int* pncom=NULL,char*** ppcom=NULL) {{{*/
    2323char* KMLFileToken(FILE* fid,
    2424                                   int* pncom=NULL,char*** ppcom=NULL){
     
    127127
    128128//      if      (itag)
    129 //              _printf_(true,"tag buffer (length=%d):\n",ibuf);
     129//              _pprintLine_("tag buffer (length=" << ibuf << "):");
    130130//      else if (ifield)
    131 //              _printf_(true,"field buffer (length=%d):\n",ibuf);
    132 //      _printf_(true,"%s\n",buffer);
     131//              _pprintLine_("field buffer (length=" << ibuf << "):");
     132//      _pprintLine_(buffer);
    133133
    134134        if (!ibuf)
     
    138138}
    139139/*}}}*/
    140 
    141 /*FUNCTION  KMLFileTokenComment(FILE* fid) {{{1*/
     140/*FUNCTION  KMLFileTokenComment(FILE* fid) {{{*/
    142141char* KMLFileTokenComment(FILE* fid){
    143142
     
    194193                }
    195194
    196 //      _printf_(true,"comment buffer (length=%d):\n",ibuf);
    197 //      _printf_(true,"%s\n",buffer);
     195//      _pprintLine_("comment buffer (length=" << ibuf << "):");
     196//      _pprintLine_(buffer);
    198197
    199198        if (!ibuf)
     
    203202}
    204203/*}}}*/
    205 
    206 /*FUNCTION  KMLFileTokenBuffer {{{1*/
     204/*FUNCTION  KMLFileTokenBuffer {{{*/
    207205void KMLFileTokenBuffer(char** pbuffer,int* pibuf,int* pbuflen,
    208206                                                int c,
     
    228226}
    229227/*}}}*/
    230 
    231 /*FUNCTION  KMLFileTagName {{{1*/
     228/*FUNCTION  KMLFileTagName {{{*/
    232229char* KMLFileTagName(char* pname,
    233230                                         char* ktag){
     
    237234}
    238235/*}}}*/
    239 
    240 /*FUNCTION  KMLFileTagName {{{1*/
     236/*FUNCTION  KMLFileTagName {{{*/
    241237char* KMLFileTagName(char* pname,int *m,int maxlen,
    242238                                         char* ktag){
     
    248244
    249245        if (strncmp(&ktag[0],"<"        ,1) || strncmp(&ktag[strlen(ktag)-1],">",1))
    250                 _error_("KMLFileTagName -- Missing tag delimiters in %s.\n",ktag);
     246                _error2_("KMLFileTagName -- Missing tag delimiters in " << ktag << ".\n");
    251247
    252248/*  strtok modifies ktag, so work on copy  */
     
    258254
    259255        ktokn=strtok(ktagi,"< >");
    260 //      _printf_(true,"KMLFileTagName -- initial token=\"%s\".\n",ktokn);
     256//      _pprintLine_("KMLFileTagName -- initial token=\"" << ktokn << "\".");
    261257
    262258        if (!pname) {
     
    268264
    269265        if (maxlen && (maxlen < strlen(ktokn))) {
    270                 _printf_(true,"KMLFileTagName -- string field too short for %s.\n",ktag);
    271                 _printf_(true,"KMLFileTagName -- \"%s\" truncated to %d characters.\n",ktokn,maxlen);
     266                _pprintLine_("KMLFileTagName -- string field too short for " << ktag << ".");
     267                _pprintLine_("KMLFileTagName -- \"" << ktokn << "\" truncated to " << maxlen << " characters.");
    272268                strncpy(pname,ktokn,maxlen);
    273269        }
     
    283279}
    284280/*}}}*/
    285 
    286 /*FUNCTION  KMLFileTagAttrib {{{1*/
     281/*FUNCTION  KMLFileTagAttrib {{{*/
    287282int KMLFileTagAttrib(KML_Object* kobj,
    288283                                         char* ktag){
     
    305300        /*  return first non blank and move past subsequent blank  */
    306301        ktokn=strtok(ktagi," ");
    307 //      _printf_(true,"KMLFileTagAttrib -- initial token=\"%s\".\n",ktokn);
     302//      _pprintLine_("KMLFileTagAttrib -- initial token=\"" << ktokn << "\".");
    308303
    309304        /*  return next non " =?/>" and move past subsequent " =?/>"  */
     
    312307                /*  return next non quote and move past subsequent quote  */
    313308                ktokv=strtok(NULL,quote);
    314 //              _printf_(true,"KMLFileTagAttrib -- attribute %s=\"%s\".\n",ktokn,ktokv);
     309//              _pprintLine_("KMLFileTagAttrib -- attribute " << ktokn << "=\"" << ktokv << "\".");
    315310
    316311/*  add the attribute to the dataset  */
     
    328323                (!strncmp(&ktag[0],"<"        ,1) && !strncmp(&ktag[strlen(ktag)-2],"/>",2)))
    329324                isolo=1;
    330 //      _printf_(true,"KMLFileTagAttrib -- isolo=%d.\n",isolo);
     325//      _pprintLine_("KMLFileTagAttrib -- isolo=" << isolo << ".");
    331326
    332327        return(isolo);
    333328}
    334329/*}}}*/
    335 
    336 /*FUNCTION  KMLFileTokenParse {{{1*/
     330/*FUNCTION  KMLFileTokenParse {{{*/
    337331int KMLFileTokenParse(int* pival,
    338332                                          char* ktag,
     
    346340                                                        NULL,NULL)) ||
    347341                (kstr[0] == '<'))
    348                 _error_("KMLFileTokenParse -- Missing integer field for %s.\n",ktag);
     342                _error2_("KMLFileTokenParse -- Missing integer field for " << ktag << ".\n");
    349343
    350344        sscanf(kstr,"%d",pival);
     
    359353                        (kstr[1] != '/') ||
    360354                        (strncmp(&(kstr[2]),&(ktag[1]),strlen(ktag)-1)))
    361                         _error_("KMLFileTokenParse -- Missing closing tag for %s.\n",ktag);
     355                  {_error2_("KMLFileTokenParse -- Missing closing tag for " << ktag << ".\n");}
    362356                else
    363357                        xfree((void**)&kstr);
    364358
    365 //      _printf_(true,"KMLFileTokenParse -- %s=%d.\n",ktag,*pival);
     359//      _pprintLine_("KMLFileTokenParse -- " << ktag << "=" << *pival << ".");
    366360
    367361        return(0);
    368362}
    369363/*}}}*/
    370 
    371 /*FUNCTION  KMLFileTokenParse {{{1*/
    372 int KMLFileTokenParse(bool* pbval,
    373                                           char* ktag,
    374                                           FILE* fid){
     364/*FUNCTION  KMLFileTokenParse {{{*/
     365int KMLFileTokenParse(bool* pbval, char* ktag, FILE* fid){
    375366
    376367        int     ival;
     
    382373                                                        NULL,NULL)) ||
    383374                (kstr[0] == '<'))
    384                 _error_("KMLFileTokenParse -- Missing bool field for %s.\n",ktag);
     375          {_error2_("KMLFileTokenParse -- Missing bool field for " << ktag << ".\n");}
    385376
    386377        sscanf(kstr,"%d",&ival);
     
    396387                        (kstr[1] != '/') ||
    397388                        (strncmp(&(kstr[2]),&(ktag[1]),strlen(ktag)-1)))
    398                         _error_("KMLFileTokenParse -- Missing closing tag for %s.\n",ktag);
     389                  {_error2_("KMLFileTokenParse -- Missing closing tag for " << ktag << ".\n");}
    399390                else
    400391                        xfree((void**)&kstr);
    401392
    402 //      _printf_(true,"KMLFileTokenParse -- %s=%s.\n",ktag,(*pbval ? "true" : "false"));
     393//      _pprintLine_("KMLFileTokenParse -- " << ktag << "=" << (*pbval ? "true" : "false") << ".");
    403394
    404395        return(0);
    405396}
    406397/*}}}*/
    407 
    408 /*FUNCTION  KMLFileTokenParse {{{1*/
     398/*FUNCTION  KMLFileTokenParse {{{*/
    409399char* KMLFileTokenParse(char* pstr,
    410400                                                char* ktag,
     
    416406}
    417407/*}}}*/
    418 
    419 /*FUNCTION  KMLFileTokenParse {{{1*/
     408/*FUNCTION  KMLFileTokenParse {{{*/
    420409char* KMLFileTokenParse(char* pstr,int *m,int maxlen,
    421410                                                char* ktag,
     
    429418                                                        NULL,NULL)) ||
    430419                (kstr[0] == '<'))
    431                 _error_("KMLFileTokenParse -- Missing string field for %s.\n",ktag);
     420                _error2_("KMLFileTokenParse -- Missing string field for " << ktag << ".\n");
    432421
    433422        if (!pstr) {
     
    439428
    440429        if (maxlen && (maxlen < strlen(kstr))) {
    441                 _printf_(true,"KMLFileTokenParse -- string field too short for %s.\n",ktag);
    442                 _printf_(true,"KMLFileTokenParse -- \"%s\" truncated to %d characters.\n",kstr,maxlen);
     430                _pprintLine_("KMLFileTokenParse -- string field too short for " << ktag << ".");
     431                _pprintLine_("KMLFileTokenParse -- \"" << kstr << "\" truncated to " << maxlen << " characters.");
    443432                strncpy(pstr,kstr,maxlen);
    444433        }
     
    459448                        (kstr[1] != '/') ||
    460449                        (strncmp(&(kstr[2]),&(ktag[1]),strlen(ktag)-1)))
    461                         _error_("KMLFileTokenParse -- Missing closing tag for %s.\n",ktag);
     450                  {_error2_("KMLFileTokenParse -- Missing closing tag for " << ktag << ".\n");}
    462451                else
    463452                        xfree((void**)&kstr);
    464453
    465 //      _printf_(true,"KMLFileTokenParse -- %s=\"%s\".\n",ktag,pstr);
     454//      _pprintLine_("KMLFileTokenParse -- " << ktag << "=\"" << pstr << "\".");
    466455
    467456        return(pstr);
    468457}
    469458/*}}}*/
    470 
    471 /*FUNCTION  KMLFileTokenParse {{{1*/
     459/*FUNCTION  KMLFileTokenParse {{{*/
    472460int KMLFileTokenParse(float* pfval,
    473461                                          char* ktag,
     
    481469                                                        NULL,NULL)) ||
    482470                (kstr[0] == '<'))
    483                 _error_("KMLFileTokenParse -- Missing integer field for %s.\n",ktag);
     471          {_error2_("KMLFileTokenParse -- Missing integer field for " << ktag << ".\n");}
    484472
    485473        sscanf(kstr,"%g",pfval);
     
    494482                        (kstr[1] != '/') ||
    495483                        (strncmp(&(kstr[2]),&(ktag[1]),strlen(ktag)-1)))
    496                         _error_("KMLFileTokenParse -- Missing closing tag for %s.\n",ktag);
     484                  {_error2_("KMLFileTokenParse -- Missing closing tag for " << ktag << ".\n");}
    497485                else
    498486                        xfree((void**)&kstr);
    499487
    500 //      _printf_(true,"KMLFileTokenParse -- %s=%g.\n",ktag,*pfval);
     488//      _pprintLine_("KMLFileTokenParse -- " << ktag << "=" << *pfval << ".");
    501489
    502490        return(0);
    503491}
    504492/*}}}*/
    505 
    506 /*FUNCTION  KMLFileTokenParse {{{1*/
     493/*FUNCTION  KMLFileTokenParse {{{*/
    507494int KMLFileTokenParse(double* pdval,
    508495                                          char* ktag,
     
    516503                                                        NULL,NULL)) ||
    517504                (kstr[0] == '<'))
    518                 _error_("KMLFileTokenParse -- Missing integer field for %s.\n",ktag);
     505                _error2_("KMLFileTokenParse -- Missing integer field for " << ktag << ".\n");
    519506
    520507        sscanf(kstr,"%lg",pdval);
     
    529516                        (kstr[1] != '/') ||
    530517                        (strncmp(&(kstr[2]),&(ktag[1]),strlen(ktag)-1)))
    531                         _error_("KMLFileTokenParse -- Missing closing tag for %s.\n",ktag);
     518                  {_error2_("KMLFileTokenParse -- Missing closing tag for " << ktag << ".\n");}
    532519                else
    533520                        xfree((void**)&kstr);
    534521
    535 //      _printf_(true,"KMLFileTokenParse -- %s=%g.\n",ktag,*pdval);
     522//      _pprintLine_("KMLFileTokenParse -- " << ktag << "=" << *pdval << ".");
    536523
    537524        return(0);
    538525}
    539526/*}}}*/
    540 
    541 /*FUNCTION  KMLFileTokenParse {{{1*/
     527/*FUNCTION  KMLFileTokenParse {{{*/
    542528int KMLFileTokenParse(double **pdval,int* m,int maxlen,
    543529                                          char* ktag,
     
    554540                                                        NULL,NULL)) ||
    555541                (kstr[0] == '<'))
    556                 _error_("KMLFileTokenParse -- Missing double [m] field for %s.\n",ktag);
     542                _error2_("KMLFileTokenParse -- Missing double [m] field for " << ktag << ".\n");
    557543
    558544        if (!*pdval)
     
    568554                i++;
    569555                if (maxlen && (maxlen < i+1))
    570                         _error_("KMLFileTokenParse -- Double [m] field too short for %s.\n",ktag);
     556                        _error2_("KMLFileTokenParse -- Double [m] field too short for " << ktag << ".\n");
    571557                sscanf(ktok,"%lg",&((*pdval)[i]));
    572558                ktok=strtok(NULL,delim);
     
    588574                        (kstr[1] != '/') ||
    589575                        (strncmp(&(kstr[2]),&(ktag[1]),strlen(ktag)-1)))
    590                         _error_("KMLFileTokenParse -- Missing closing tag for %s.\n",ktag);
     576                  {_error2_("KMLFileTokenParse -- Missing closing tag for " << ktag << ".\n");}
    591577                else
    592578                        xfree((void**)&kstr);
    593579
    594 //      _printf_(true,"KMLFileTokenParse -- %s=...\n",ktag);
     580//      _pprintLine_("KMLFileTokenParse -- " << ktag << "=...");
    595581//      for (j=0; j<=i; j++)
    596 //              _printf_(true,"   [%d]: %lg\n",j,(*pdval)[j]);
     582//              _pprintLine_("   [" << j << "]: " << (*pdval)[j] << "g");
    597583
    598584        return(0);
    599585}
    600586/*}}}*/
    601 
    602 /*FUNCTION  KMLFileTokenParse {{{1*/
     587/*FUNCTION  KMLFileTokenParse {{{*/
    603588int KMLFileTokenParse(double (**pdval3)[3],int* m,int maxlen,
    604589                                          char* ktag,
     
    615600                                                        NULL,NULL)) ||
    616601                (kstr[0] == '<'))
    617                 _error_("KMLFileTokenParse -- Missing double [m x 3] field for %s.\n",ktag);
     602                _error2_("KMLFileTokenParse -- Missing double [m x 3] field for " << ktag << ".\n");
    618603
    619604        if (!*pdval3)
     
    632617                        j=0;
    633618                        if (maxlen && (maxlen < i+1))
    634                                 _error_("KMLFileTokenParse -- Double [m x 3] field too short for %s.\n",ktag);
     619                                _error2_("KMLFileTokenParse -- Double [m x 3] field too short for " << ktag << ".\n");
    635620                }
    636621                sscanf(ktok,"%lg",&((*pdval3)[i][j]));
     
    646631
    647632        if (j != 2)
    648                 _printf_(true,"KMLFileTokenParse -- Double [m x 3] field for %s does not have multiple of 3 values.\n",ktag);
     633                _pprintLine_("KMLFileTokenParse -- Double [m x 3] field for " << ktag << " does not have multiple of 3 values.");
    649634
    650635/*  get additional token and compare to closing tag  */
     
    656641                        (kstr[1] != '/') ||
    657642                        (strncmp(&(kstr[2]),&(ktag[1]),strlen(ktag)-1)))
    658                         _error_("KMLFileTokenParse -- Missing closing tag for %s.\n",ktag);
     643                  {_error2_("KMLFileTokenParse -- Missing closing tag for " << ktag << ".\n");}
    659644                else
    660645                        xfree((void**)&kstr);
    661646
    662 //      _printf_(true,"KMLFileTokenParse -- %s=...\n",ktag);
     647//      _pprintLine_("KMLFileTokenParse -- " << ktag << "=...");
    663648//      for (j=0; j<=i; j++)
    664 //              _printf_(true,"   [%d][0-2]: %lg,%lg,%lg\n",j,(*pdval3)[j][0],(*pdval3)[j][1],(*pdval3)[j][2]);
     649//              _pprintLine_("   [" << j << "][0-2]: " << (*pdval3)[j][0] << "g," << (*pdval3)[j][1] << "g," << (*pdval3)[j][2] << "g");
    665650
    666651        return(0);
    667652}
    668653/*}}}*/
    669 
    670 /*FUNCTION  KMLFileTagSkip {{{1*/
     654/*FUNCTION  KMLFileTagSkip {{{*/
    671655int KMLFileTagSkip(char* ktag,
    672656                                   FILE* fid){
     
    677661        opening tag, must find corresponding closing tag  */
    678662
    679         _printf_(true,"KMLFileTagSkip -- input tag %s.\n",ktag);
     663        _pprintLine_("KMLFileTagSkip -- input tag " << ktag << ".");
    680664
    681665/*  if next token is a closing tag, compare to input  */
     
    686670                                 (kstr[1] == '/') &&
    687671                                 (!strncmp(&(kstr[2]),&(ktag[1]),(strcspn(ktag," >")-1)/sizeof(char)))) {
    688                         _printf_(true,"KMLFileTagSkip -- closing tag %s.\n",kstr);
     672                        _pprintLine_("KMLFileTagSkip -- closing tag " << kstr << ".");
    689673                        xfree((void**)&kstr);
    690674                        return(0);
     
    695679                else if ((kstr[0] == '<') &&
    696680                                 (kstr[1] != '/')) {
    697                         _printf_(true,"KMLFileTagSkip -- opening tag %s.\n",kstr);
     681                        _pprintLine_("KMLFileTagSkip -- opening tag " << kstr << ".");
    698682                        KMLFileTagSkip(kstr,
    699683                                                   fid);
     
    704688                else if ((kstr[0] == '<') &&
    705689                                 (kstr[1] == '/')) {
    706                         _error_("KMLFileTagSkip -- Unexpected closing tag %s.\n",kstr);
     690                        _error2_("KMLFileTagSkip -- Unexpected closing tag " << kstr << ".\n");
    707691                }
    708692
     
    710694        }
    711695
    712         _error_("KMLFileTokenParse -- Corresponding closing tag for %s not found.\n",ktag);
     696        _error2_("KMLFileTokenParse -- Corresponding closing tag for " << ktag << " not found.\n");
    713697
    714698        return(0);
    715699}
    716700/*}}}*/
    717 
  • issm/trunk/src/c/objects/KML/KMLFileReadUtils.h

    r11527 r12706  
    66#define _KMLFILEREADUTILS_H
    77
    8 /*Headers:{{{1*/
     8/*Headers:{{{*/
    99#include "../../include/include.h"
    1010#include "../../shared/Exceptions/exceptions.h"
  • issm/trunk/src/c/objects/KML/KML_Attribute.cpp

    r11237 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*Constructors/destructor/copy*/
    23 /*FUNCTION KML_Attribute::KML_Attribute(){{{1*/
     23/*FUNCTION KML_Attribute::KML_Attribute(){{{*/
    2424KML_Attribute::KML_Attribute(){
    2525
     
    2929}
    3030/*}}}*/
    31 /*FUNCTION KML_Attribute::~KML_Attribute(){{{1*/
     31/*FUNCTION KML_Attribute::~KML_Attribute(){{{*/
    3232KML_Attribute::~KML_Attribute(){
    3333
     
    3939
    4040/*Other*/
    41 /*FUNCTION KML_Attribute::Echo {{{1*/
     41/*FUNCTION KML_Attribute::Echo {{{*/
    4242void  KML_Attribute::Echo(){
    4343
     
    4545        bool  flag=true;
    4646
    47         _printf_(flag,"    ");
     47        if(flag) _pprintString_("    ");
    4848        for (i=0;i<10-strlen(name);i++)
    49                 _printf_(flag," ");
    50         _printf_(flag,"%s: \"%s\"\n",name,value);
     49                if(flag) _pprintString_(" ");
     50        if(flag) _pprintLine_(name << ": \"" << value << "\"");
    5151
    5252        return;
    5353}
    5454/*}}}*/
    55 /*FUNCTION KML_Attribute::DeepEcho {{{1*/
     55/*FUNCTION KML_Attribute::DeepEcho {{{*/
    5656void  KML_Attribute::DeepEcho(){
    5757
     
    6363}
    6464/*}}}*/
    65 /*FUNCTION KML_Attribute::DeepEcho {{{1*/
     65/*FUNCTION KML_Attribute::DeepEcho {{{*/
    6666void  KML_Attribute::DeepEcho(const char* indent){
    6767
     
    6969        bool  flag=true;
    7070
    71         _printf_(flag,"%s    ",indent);
     71        if(flag) _pprintString_(indent << "    ");
    7272        for (i=0;i<10-strlen(name);i++)
    73                 _printf_(flag," ");
    74         _printf_(flag,"%s: \"%s\"\n",name,value);
     73                if(flag) _pprintString_(" ");
     74        if(flag) _pprintLine_(name << ": \"" << value << "\"");
    7575
    7676        return;
    7777}
    7878/*}}}*/
    79 /*FUNCTION KML_Attribute::Write {{{1*/
     79/*FUNCTION KML_Attribute::Write {{{*/
    8080void  KML_Attribute::Write(FILE* filout,const char* indent){
    8181
     
    8787}
    8888/*}}}*/
    89 /*FUNCTION KML_Attribute::Read {{{1*/
     89/*FUNCTION KML_Attribute::Read {{{*/
    9090void  KML_Attribute::Read(FILE* fid,char* kstr){
    9191
     
    9797}
    9898/*}}}*/
    99 /*FUNCTION KML_Attribute::Alloc {{{1*/
     99/*FUNCTION KML_Attribute::Alloc {{{*/
    100100void  KML_Attribute::Alloc(const char* namei,const char* valuei){
    101101
     
    109109}
    110110/*}}}*/
    111 /*FUNCTION KML_Attribute::Add {{{1*/
     111/*FUNCTION KML_Attribute::Add {{{*/
    112112void  KML_Attribute::Add(DataSet* attrib){
    113113
     
    117117}
    118118/*}}}*/
    119 /*FUNCTION KML_Attribute::Get {{{1*/
     119/*FUNCTION KML_Attribute::Get {{{*/
    120120void  KML_Attribute::Get(char** pvalueo,char* deflt){
    121121
  • issm/trunk/src/c/objects/KML/KML_Attribute.h

    r11237 r12706  
    66#define _KML_ATTRIBUTE_H_
    77
    8 /*Headers:{{{1*/
     8/*Headers:{{{*/
    99#include "../../include/include.h"
    1010#include "../../shared/Exceptions/exceptions.h"
     
    2222                char* value;
    2323
    24                 /*KML_Attribute constructors, destructors {{{1*/
     24                /*KML_Attribute constructors, destructors {{{*/
    2525                KML_Attribute();
    2626                ~KML_Attribute();
    2727                /*}}}*/
    28                 /*Object virtual functions definitions:{{{1*/
     28                /*Object virtual functions definitions:{{{*/
    2929                virtual void  Echo();
    3030                virtual void  DeepEcho();
    3131                virtual void  DeepEcho(const char* indent);
    32                 int   Id(){_error_("Not implemented yet.");};
    33                 int   MyRank(){_error_("Not implemented yet.");};
    34                 void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    35                 int   MarshallSize(){_error_("Not implemented yet.");};
    36                 void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    37                 int   ObjectEnum(){_error_("Not implemented yet.");};
    38                 Object* copy(){_error_("Not implemented yet.");};
     32                int   Id(){_error2_("Not implemented yet.");};
     33                int   MyRank(){_error2_("Not implemented yet.");};
     34                void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     35                int   MarshallSize(){_error2_("Not implemented yet.");};
     36                void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     37                int   ObjectEnum(){_error2_("Not implemented yet.");};
     38                Object* copy(){_error2_("Not implemented yet.");};
    3939                /*}}}*/
    4040
  • issm/trunk/src/c/objects/KML/KML_ColorStyle.cpp

    r11237 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*Constructors/destructor/copy*/
    23 /*FUNCTION KML_ColorStyle::KML_ColorStyle(){{{1*/
     23/*FUNCTION KML_ColorStyle::KML_ColorStyle(){{{*/
    2424KML_ColorStyle::KML_ColorStyle(){
    2525
     
    2929}
    3030/*}}}*/
    31 /*FUNCTION KML_ColorStyle::~KML_ColorStyle(){{{1*/
     31/*FUNCTION KML_ColorStyle::~KML_ColorStyle(){{{*/
    3232KML_ColorStyle::~KML_ColorStyle(){
    3333
     
    3838
    3939/*Other*/
    40 /*FUNCTION KML_ColorStyle::Echo {{{1*/
     40/*FUNCTION KML_ColorStyle::Echo {{{*/
    4141void  KML_ColorStyle::Echo(){
    4242
     
    4545        KML_SubStyle::Echo();
    4646
    47         _printf_(flag,"         color: %s\n"          ,color);
    48         _printf_(flag,"     colormode: %s\n"          ,colormode);
     47        if(flag) _pprintLine_("         color: " << color);
     48        if(flag) _pprintLine_("     colormode: " << colormode);
    4949
    5050        return;
    5151}
    5252/*}}}*/
    53 /*FUNCTION KML_ColorStyle::DeepEcho {{{1*/
     53/*FUNCTION KML_ColorStyle::DeepEcho {{{*/
    5454void  KML_ColorStyle::DeepEcho(){
    5555
     
    6161}
    6262/*}}}*/
    63 /*FUNCTION KML_ColorStyle::DeepEcho {{{1*/
     63/*FUNCTION KML_ColorStyle::DeepEcho {{{*/
    6464void  KML_ColorStyle::DeepEcho(const char* indent){
    6565
     
    6868        KML_SubStyle::DeepEcho(indent);
    6969
    70         _printf_(flag,"%s         color: %s\n"          ,indent,color);
    71         _printf_(flag,"%s     colormode: %s\n"          ,indent,colormode);
    72 
    73         return;
     70        if(flag) _pprintLine_(indent << "         color: " << color);
     71        if(flag) _pprintLine_(indent << "     colormode: " << colormode);
    7472}
    7573/*}}}*/
    76 /*FUNCTION KML_ColorStyle::Write {{{1*/
     74/*FUNCTION KML_ColorStyle::Write {{{*/
    7775void  KML_ColorStyle::Write(FILE* filout,const char* indent){
    7876
     
    8785}
    8886/*}}}*/
    89 /*FUNCTION KML_ColorStyle::Read {{{1*/
     87/*FUNCTION KML_ColorStyle::Read {{{*/
    9088void  KML_ColorStyle::Read(FILE* fid,char* kstr){
    9189
     
    9593                return;
    9694        else if (!strncmp(kstr,"</",2))
    97                 _error_("KML_ColorStyle::Read -- Unexpected closing tag %s.\n",kstr);
     95          {_error2_("KML_ColorStyle::Read -- Unexpected closing tag " << kstr);}
    9896        else if (strncmp(kstr,"<",1))
    99                 _error_("KML_ColorStyle::Read -- Unexpected field \"%s\".\n",kstr);
     97          {_error2_("KML_ColorStyle::Read -- Unexpected field \"" << kstr << "\"");}
    10098
    10199        else if (!strcmp(kstr,"<color>"))
    102                 KMLFileTokenParse( color     ,NULL,KML_COLORSTYLE_COLOR_LENGTH,
    103                                                   kstr,
    104                                                   fid);
     100                KMLFileTokenParse( color     ,NULL,KML_COLORSTYLE_COLOR_LENGTH, kstr, fid);
    105101        else if (!strcmp(kstr,"<colorMode>"))
    106                 KMLFileTokenParse( colormode ,NULL,KML_COLORSTYLE_COLORMODE_LENGTH,
    107                                                   kstr,
    108                                                   fid);
     102                KMLFileTokenParse( colormode ,NULL,KML_COLORSTYLE_COLORMODE_LENGTH, kstr, fid);
    109103
    110104        else if (!strncmp(kstr,"<",1))
  • issm/trunk/src/c/objects/KML/KML_ColorStyle.h

    r11237 r12706  
    1010
    1111/*Headers:*/
    12 /*{{{1*/
     12/*{{{*/
    1313#include "../../include/include.h"
    1414#include "../../shared/Exceptions/exceptions.h"
     
    2525                char  colormode[KML_COLORSTYLE_COLORMODE_LENGTH+1];
    2626
    27                 /*KML_ColorStyle constructors, destructors {{{1*/
     27                /*KML_ColorStyle constructors, destructors {{{*/
    2828                KML_ColorStyle();
    2929                ~KML_ColorStyle();
    3030                /*}}}*/
    31                 /*Object virtual functions definitions:{{{1*/
     31                /*Object virtual functions definitions:{{{*/
    3232                void  Echo();
    3333                void  DeepEcho();
     
    3535                void  Write(FILE* fid,const char* indent);
    3636                void  Read(FILE* fid,char* kstr);
    37                 int   Id(){_error_("Not implemented yet.");};
    38                 int   MyRank(){_error_("Not implemented yet.");};
    39                 void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    40                 int   MarshallSize(){_error_("Not implemented yet.");};
    41                 void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    42                 int   ObjectEnum(){_error_("Not implemented yet.");};
    43                 Object* copy(){_error_("Not implemented yet.");};
     37                int   Id(){_error2_("Not implemented yet.");};
     38                int   MyRank(){_error2_("Not implemented yet.");};
     39                void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     40                int   MarshallSize(){_error2_("Not implemented yet.");};
     41                void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     42                int   ObjectEnum(){_error2_("Not implemented yet.");};
     43                Object* copy(){_error2_("Not implemented yet.");};
    4444                /*}}}*/
    4545
  • issm/trunk/src/c/objects/KML/KML_Comment.cpp

    r11237 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*Constructors/destructor/copy*/
    23 /*FUNCTION KML_Comment::KML_Comment(){{{1*/
     23/*FUNCTION KML_Comment::KML_Comment(){{{*/
    2424KML_Comment::KML_Comment(){
    2525
     
    2828}
    2929/*}}}*/
    30 /*FUNCTION KML_Comment::~KML_Comment(){{{1*/
     30/*FUNCTION KML_Comment::~KML_Comment(){{{*/
    3131KML_Comment::~KML_Comment(){
    3232
     
    3737
    3838/*Other*/
    39 /*FUNCTION KML_Comment::Echo {{{1*/
     39/*FUNCTION KML_Comment::Echo {{{*/
    4040void  KML_Comment::Echo(){
    4141
    4242        bool  flag=true;
    4343
    44         _printf_(flag,"    ");
    45         _printf_(flag,"%s\n",value);
     44        if(flag) _pprintString_("    ");
     45        if(flag) _pprintLine_(value);
    4646
    4747        return;
    4848}
    4949/*}}}*/
    50 /*FUNCTION KML_Comment::DeepEcho {{{1*/
     50/*FUNCTION KML_Comment::DeepEcho {{{*/
    5151void  KML_Comment::DeepEcho(){
    5252
     
    5858}
    5959/*}}}*/
    60 /*FUNCTION KML_Comment::DeepEcho {{{1*/
     60/*FUNCTION KML_Comment::DeepEcho {{{*/
    6161void  KML_Comment::DeepEcho(const char* indent){
    6262
    6363        bool  flag=true;
    6464
    65         _printf_(flag,"%s    ",indent);
    66         _printf_(flag,"%s\n",value);
     65        if(flag) _pprintString_(indent << "    ");
     66        if(flag) _pprintLine_(value);
    6767
    6868        return;
    6969}
    7070/*}}}*/
    71 /*FUNCTION KML_Comment::Write {{{1*/
     71/*FUNCTION KML_Comment::Write {{{*/
    7272void  KML_Comment::Write(FILE* filout,const char* indent){
    7373
     
    8181}
    8282/*}}}*/
    83 /*FUNCTION KML_Comment::Read {{{1*/
     83/*FUNCTION KML_Comment::Read {{{*/
    8484void  KML_Comment::Read(FILE* fid,char* kstr){
    8585
     
    9191}
    9292/*}}}*/
    93 /*FUNCTION KML_Comment::Alloc {{{1*/
     93/*FUNCTION KML_Comment::Alloc {{{*/
    9494void  KML_Comment::Alloc(const char* valuei){
    9595
     
    100100}
    101101/*}}}*/
    102 /*FUNCTION KML_Comment::Add {{{1*/
     102/*FUNCTION KML_Comment::Add {{{*/
    103103void  KML_Comment::Add(DataSet* commnt){
    104104
     
    108108}
    109109/*}}}*/
    110 /*FUNCTION KML_Comment::Get {{{1*/
     110/*FUNCTION KML_Comment::Get {{{*/
    111111void  KML_Comment::Get(char** pvalueo){
    112112
  • issm/trunk/src/c/objects/KML/KML_Comment.h

    r11237 r12706  
    66#define _KML_COMMENT_H_
    77
    8 /*Headers:{{{1*/
     8/*Headers:{{{*/
    99#include "../../include/include.h"
    1010#include "../../shared/Exceptions/exceptions.h"
     
    2222                char* value;
    2323
    24                 /*KML_Comment constructors, destructors {{{1*/
     24                /*KML_Comment constructors, destructors {{{*/
    2525                KML_Comment();
    2626                ~KML_Comment();
    2727                /*}}}*/
    28                 /*Object virtual functions definitions:{{{1*/
     28                /*Object virtual functions definitions:{{{*/
    2929                virtual void  Echo();
    3030                virtual void  DeepEcho();
    3131                virtual void  DeepEcho(const char* indent);
    32                 int   Id(){_error_("Not implemented yet.");};
    33                 int   MyRank(){_error_("Not implemented yet.");};
    34                 void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    35                 int   MarshallSize(){_error_("Not implemented yet.");};
    36                 void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    37                 int   ObjectEnum(){_error_("Not implemented yet.");};
    38                 Object* copy(){_error_("Not implemented yet.");};
     32                int   Id(){_error2_("Not implemented yet.");};
     33                int   MyRank(){_error2_("Not implemented yet.");};
     34                void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     35                int   MarshallSize(){_error2_("Not implemented yet.");};
     36                void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     37                int   ObjectEnum(){_error2_("Not implemented yet.");};
     38                Object* copy(){_error2_("Not implemented yet.");};
    3939                /*}}}*/
    4040
  • issm/trunk/src/c/objects/KML/KML_Container.cpp

    r11527 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*Constructors/destructor/copy*/
    23 /*FUNCTION KML_Container::KML_Container(){{{1*/
     23/*FUNCTION KML_Container::KML_Container(){{{*/
    2424KML_Container::KML_Container(){
    2525
     
    2828}
    2929/*}}}*/
    30 /*FUNCTION KML_Container::~KML_Container(){{{1*/
     30/*FUNCTION KML_Container::~KML_Container(){{{*/
    3131KML_Container::~KML_Container(){
    3232
     
    4040
    4141/*Other*/
    42 /*FUNCTION KML_Container::Echo {{{1*/
     42/*FUNCTION KML_Container::Echo {{{*/
    4343void  KML_Container::Echo(){
    4444
     
    4747        KML_Feature::Echo();
    4848
    49         _printf_(flag,"       feature: (size=%d)\n" ,feature->Size());
     49        if(flag) _pprintLine_("       feature: (size=" << feature->Size() << ")");
    5050
    5151        return;
    5252}
    5353/*}}}*/
    54 /*FUNCTION KML_Container::DeepEcho {{{1*/
     54/*FUNCTION KML_Container::DeepEcho {{{*/
    5555void  KML_Container::DeepEcho(){
    5656
     
    6262}
    6363/*}}}*/
    64 /*FUNCTION KML_Container::DeepEcho {{{1*/
     64/*FUNCTION KML_Container::DeepEcho {{{*/
    6565void  KML_Container::DeepEcho(const char* indent){
    6666
     
    7878        if (feature->Size())
    7979                for (i=0; i<feature->Size(); i++) {
    80                         _printf_(flag,"%s       feature: -------- begin [%d] --------\n" ,indent,i);
     80                        if(flag) _pprintLine_(indent << "       feature: -------- begin [" << i << "] --------");
    8181                        ((KML_Feature *)feature->GetObjectByOffset(i))->DeepEcho(indent2);
    82                         _printf_(flag,"%s       feature: --------  end  [%d] --------\n" ,indent,i);
     82                        if(flag) _pprintLine_(indent << "       feature: --------  end  [" << i << "] --------");
    8383                }
    8484        else
    85                 _printf_(flag,"%s       feature: [empty]\n"    ,indent);
     85                if(flag) _pprintLine_(indent << "       feature: [empty]");
    8686
    8787        return;
    8888}
    8989/*}}}*/
    90 /*FUNCTION KML_Container::Write {{{1*/
     90/*FUNCTION KML_Container::Write {{{*/
    9191void  KML_Container::Write(FILE* filout,const char* indent){
    9292
     
    108108}
    109109/*}}}*/
    110 /*FUNCTION KML_Container::Read {{{1*/
     110/*FUNCTION KML_Container::Read {{{*/
    111111void  KML_Container::Read(FILE* fid,char* kstr){
    112112
     
    120120        }
    121121        else if (!strncmp(kstr,"</",2))
    122                 _error_("KML_Container::Read -- Unexpected closing tag %s.\n",kstr);
     122          {_error2_("KML_Container::Read -- Unexpected closing tag " << kstr );}
    123123        else if (strncmp(kstr,"<",1))
    124                 _error_("KML_Container::Read -- Unexpected field \"%s\".\n",kstr);
     124          {_error2_("KML_Container::Read -- Unexpected field \"" << kstr << "\"");}
    125125
    126126        else if (!strncmp(kstr,"<Placemark",10)) {
     
    154154}
    155155/*}}}*/
    156 /*FUNCTION KML_Container::WriteExp {{{1*/
     156/*FUNCTION KML_Container::WriteExp {{{*/
    157157void  KML_Container::WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp){
    158158
  • issm/trunk/src/c/objects/KML/KML_Container.h

    r11237 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "../../include/include.h"
    1111#include "../../shared/Exceptions/exceptions.h"
     
    2222                DataSet* feature;
    2323
    24                 /*KML_Container constructors, destructors {{{1*/
     24                /*KML_Container constructors, destructors {{{*/
    2525                KML_Container();
    2626                ~KML_Container();
    2727                /*}}}*/
    28                 /*Object virtual functions definitions:{{{1*/
     28                /*Object virtual functions definitions:{{{*/
    2929                void  Echo();
    3030                void  DeepEcho();
     
    3333                void  Read(FILE* fid,char* kstr);
    3434                void  WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp);
    35                 int   Id(){_error_("Not implemented yet.");};
    36                 int   MyRank(){_error_("Not implemented yet.");};
    37                 void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    38                 int   MarshallSize(){_error_("Not implemented yet.");};
    39                 void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    40                 int   ObjectEnum(){_error_("Not implemented yet.");};
    41                 Object* copy(){_error_("Not implemented yet.");};
     35                int   Id(){_error2_("Not implemented yet.");};
     36                int   MyRank(){_error2_("Not implemented yet.");};
     37                void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     38                int   MarshallSize(){_error2_("Not implemented yet.");};
     39                void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     40                int   ObjectEnum(){_error2_("Not implemented yet.");};
     41                Object* copy(){_error2_("Not implemented yet.");};
    4242                /*}}}*/
    4343
  • issm/trunk/src/c/objects/KML/KML_Document.cpp

    r11237 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*Constructors/destructor/copy*/
    23 /*FUNCTION KML_Document::KML_Document(){{{1*/
     23/*FUNCTION KML_Document::KML_Document(){{{*/
    2424KML_Document::KML_Document(){
    2525
     
    2828}
    2929/*}}}*/
    30 /*FUNCTION KML_Document::~KML_Document(){{{1*/
     30/*FUNCTION KML_Document::~KML_Document(){{{*/
    3131KML_Document::~KML_Document(){
    3232
     
    3737
    3838/*Other*/
    39 /*FUNCTION KML_Document::Echo {{{1*/
     39/*FUNCTION KML_Document::Echo {{{*/
    4040void  KML_Document::Echo(){
    4141
    4242        bool  flag=true;
    4343
    44         _printf_(flag,"KML_Document:\n");
     44        if(flag) _pprintLine_("KML_Document:");
    4545        KML_Container::Echo();
    4646
     
    4949/*}}}*/
    5050
    51 /*FUNCTION KML_Document::DeepEcho {{{1*/
     51/*FUNCTION KML_Document::DeepEcho {{{*/
    5252void  KML_Document::DeepEcho(){
    5353
     
    6060/*}}}*/
    6161
    62 /*FUNCTION KML_Document::DeepEcho {{{1*/
     62/*FUNCTION KML_Document::DeepEcho {{{*/
    6363void  KML_Document::DeepEcho(const char* indent){
    6464
    6565        bool  flag=true;
    6666
    67         _printf_(flag,"%sKML_Document:\n",indent);
     67        if(flag) _pprintLine_(indent << "KML_Document:");
    6868        KML_Container::DeepEcho(indent);
    6969
     
    7272/*}}}*/
    7373
    74 /*FUNCTION KML_Document::Write {{{1*/
     74/*FUNCTION KML_Document::Write {{{*/
    7575void  KML_Document::Write(FILE* filout,const char* indent){
    7676
     
    8888/*}}}*/
    8989
    90 /*FUNCTION KML_Document::Read {{{1*/
     90/*FUNCTION KML_Document::Read {{{*/
    9191void  KML_Document::Read(FILE* fid,char* kstr){
    9292
     
    110110                }
    111111                else if (!strncmp(kstri,"</",2))
    112                         _error_("KML_Document::Read -- Unexpected closing tag %s.\n",kstri);
     112                  {_error2_("KML_Document::Read -- Unexpected closing tag " << kstri << ".\n");}
    113113                else if (strncmp(kstri,"<",1))
    114                         _error_("KML_Document::Read -- Unexpected field \"%s\".\n",kstri);
     114                  {_error2_("KML_Document::Read -- Unexpected field \"" << kstri << "\".\n");}
    115115
    116116                else if (!strncmp(kstri,"<",1))
  • issm/trunk/src/c/objects/KML/KML_Document.h

    r11237 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "../../include/include.h"
    1111#include "../../shared/Exceptions/exceptions.h"
     
    2020        public:
    2121
    22                 /*KML_Document constructors, destructors {{{1*/
     22                /*KML_Document constructors, destructors {{{*/
    2323                KML_Document();
    2424                ~KML_Document();
    2525                /*}}}*/
    26                 /*Object virtual functions definitions:{{{1 */
     26                /*Object virtual functions definitions:{{{ */
    2727                void  Echo();
    2828                void  DeepEcho();
     
    3030                void  Write(FILE* fid,const char* indent);
    3131                void  Read(FILE* fid,char* kstr);
    32                 int   Id(){_error_("Not implemented yet.");};
    33                 int   MyRank(){_error_("Not implemented yet.");};
    34                 void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    35                 int   MarshallSize(){_error_("Not implemented yet.");};
    36                 void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    37                 int   ObjectEnum(){_error_("Not implemented yet.");};
    38                 Object* copy(){_error_("Not implemented yet.");};
     32                int   Id(){_error2_("Not implemented yet.");};
     33                int   MyRank(){_error2_("Not implemented yet.");};
     34                void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     35                int   MarshallSize(){_error2_("Not implemented yet.");};
     36                void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     37                int   ObjectEnum(){_error2_("Not implemented yet.");};
     38                Object* copy(){_error2_("Not implemented yet.");};
    3939                /*}}}*/
    4040
  • issm/trunk/src/c/objects/KML/KML_Feature.cpp

    r11527 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*Constructors/destructor/copy*/
    23 /*FUNCTION KML_Feature::KML_Feature(){{{1*/
     23/*FUNCTION KML_Feature::KML_Feature(){{{*/
    2424KML_Feature::KML_Feature(){
    2525
     
    3535}
    3636/*}}}*/
    37 /*FUNCTION KML_Feature::~KML_Feature(){{{1*/
     37/*FUNCTION KML_Feature::~KML_Feature(){{{*/
    3838KML_Feature::~KML_Feature(){
    3939
     
    4747
    4848/*Other*/
    49 /*FUNCTION KML_Feature::Echo {{{1*/
     49/*FUNCTION KML_Feature::Echo {{{*/
    5050void  KML_Feature::Echo(){
    5151
     
    5454        KML_Object::Echo();
    5555
    56         _printf_(flag,"          name: \"%s\"\n"    ,name);
    57         _printf_(flag,"    visibility: %s\n"        ,(visibility ? "true" : "false"));
    58         _printf_(flag,"          open: %s\n"        ,(open ? "true" : "false"));
    59         _printf_(flag,"       snippet: \"%s\"\n"    ,snippet);
    60         _printf_(flag,"      descript: \"%s\"\n"    ,descript);
    61         _printf_(flag,"      styleurl: \"%s\"\n"    ,styleurl);
    62         _printf_(flag,"         style: (size=%d)\n" ,style->Size());
     56        if(flag) _pprintLine_("          name: \"" << name << "\"");
     57        if(flag) _pprintLine_("    visibility: " << (visibility ? "true" : "false"));
     58        if(flag) _pprintLine_("          open: " << (open ? "true" : "false"));
     59        if(flag) _pprintLine_("       snippet: \"" << snippet << "\"");
     60        if(flag) _pprintLine_("      descript: \"" << descript << "\"");
     61        if(flag) _pprintLine_("      styleurl: \"" << styleurl << "\"");
     62        if(flag) _pprintLine_("         style: (size=" << style->Size() << ")");
    6363
    6464        return;
    6565}
    6666/*}}}*/
    67 
    68 /*FUNCTION KML_Feature::DeepEcho {{{1*/
     67/*FUNCTION KML_Feature::DeepEcho {{{*/
    6968void  KML_Feature::DeepEcho(){
    7069
     
    7675}
    7776/*}}}*/
    78 
    79 /*FUNCTION KML_Feature::DeepEcho {{{1*/
     77/*FUNCTION KML_Feature::DeepEcho {{{*/
    8078void  KML_Feature::DeepEcho(const char* indent){
    8179
     
    8684        KML_Object::DeepEcho(indent);
    8785
    88         _printf_(flag,"%s          name: \"%s\"\n"      ,indent,name);
    89         _printf_(flag,"%s    visibility: %s\n"          ,indent,(visibility ? "true" : "false"));
    90         _printf_(flag,"%s          open: %s\n"          ,indent,(open ? "true" : "false"));
    91         _printf_(flag,"%s       snippet: \"%s\"\n"      ,indent,snippet);
    92         _printf_(flag,"%s      descript: \"%s\"\n"      ,indent,descript);
    93         _printf_(flag,"%s      styleurl: \"%s\"\n"      ,indent,styleurl);
     86        if(flag) _pprintLine_(indent << "          name: \"" << name << "\"");
     87        if(flag) _pprintLine_(indent << "    visibility: " << (visibility ? "true" : "false"));
     88        if(flag) _pprintLine_(indent << "          open: " << (open ? "true" : "false"));
     89        if(flag) _pprintLine_(indent << "       snippet: \"" << snippet << "\"");
     90        if(flag) _pprintLine_(indent << "      descript: \"" << descript << "\"");
     91        if(flag) _pprintLine_(indent << "      styleurl: \"" << styleurl << "\"");
    9492
    9593/*  loop over any styles for the feature  */
     
    10098        if (style->Size())
    10199                for (i=0; i<style->Size(); i++) {
    102                         _printf_(flag,"%s         style: -------- begin [%d] --------\n" ,indent,i);
     100                        if(flag) _pprintLine_(indent << "         style: -------- begin [" << i << "] --------");
    103101                        ((KML_Style *)style->GetObjectByOffset(i))->DeepEcho(indent2);
    104                         _printf_(flag,"%s         style: --------  end  [%d] --------\n" ,indent,i);
     102                        if(flag) _pprintLine_(indent << "         style: --------  end  [" << i << "] --------");
    105103                }
    106104        else
    107                 _printf_(flag,"%s         style: [empty]\n"    ,indent);
     105                if(flag) _pprintLine_(indent << "         style: [empty]");
    108106
    109107        return;
    110108}
    111109/*}}}*/
    112 
    113 /*FUNCTION KML_Feature::Write {{{1*/
     110/*FUNCTION KML_Feature::Write {{{*/
    114111void  KML_Feature::Write(FILE* filout,const char* indent){
    115112
     
    142139}
    143140/*}}}*/
    144 
    145 /*FUNCTION KML_Feature::Read {{{1*/
     141/*FUNCTION KML_Feature::Read {{{*/
    146142void  KML_Feature::Read(FILE* fid,char* kstr){
    147143
     
    153149                return;
    154150        else if (!strncmp(kstr,"</",2))
    155                 _error_("KML_Feature::Read -- Unexpected closing tag %s.\n",kstr);
     151          {_error2_("KML_Feature::Read -- Unexpected closing tag " << kstr);}
    156152        else if (strncmp(kstr,"<",1))
    157                 _error_("KML_Feature::Read -- Unexpected field \"%s\".\n",kstr);
     153          {_error2_("KML_Feature::Read -- Unexpected field \"" << kstr << "\"");}
    158154
    159155        else if (!strncmp(kstr,"<Style", 6)) {
     
    164160
    165161        else if (!strcmp(kstr,"<name>"))
    166                 KMLFileTokenParse( name      ,NULL,KML_FEATURE_NAME_LENGTH,
    167                                                   kstr,
    168                                                   fid);
     162                KMLFileTokenParse( name      ,NULL,KML_FEATURE_NAME_LENGTH, kstr, fid);
    169163        else if (!strcmp(kstr,"<visibility>"))
    170                 KMLFileTokenParse(&visibility,
    171                                                   kstr,
    172                                                   fid);
     164                KMLFileTokenParse(&visibility, kstr, fid);
    173165        else if (!strcmp(kstr,"<open>"))
    174                 KMLFileTokenParse(&open      ,
    175                                                   kstr,
    176                                                   fid);
     166                KMLFileTokenParse(&open      , kstr, fid);
    177167        else if (!strncmp(kstr,"<snippet", 8))
    178                 KMLFileTokenParse( snippet   ,NULL,KML_FEATURE_SNIPPET_LENGTH,
    179                                                   kstr,
    180                                                   fid);
     168                KMLFileTokenParse( snippet   ,NULL,KML_FEATURE_SNIPPET_LENGTH, kstr, fid);
    181169        else if (!strcmp(kstr,"<description>"))
    182                 KMLFileTokenParse( descript  ,NULL,KML_FEATURE_DESCRIPT_LENGTH,
    183                                                   kstr,
    184                                                   fid);
     170                KMLFileTokenParse( descript  ,NULL,KML_FEATURE_DESCRIPT_LENGTH, kstr, fid);
    185171        else if (!strcmp(kstr,"<styleUrl>"))
    186                 KMLFileTokenParse( styleurl  ,NULL,KML_FEATURE_STYLEURL_LENGTH,
    187                                                   kstr,
    188                                                   fid);
     172                KMLFileTokenParse( styleurl  ,NULL,KML_FEATURE_STYLEURL_LENGTH, kstr, fid);
    189173
    190174        else if (!strncmp(kstr,"<",1))
     
    194178}
    195179/*}}}*/
    196 
  • issm/trunk/src/c/objects/KML/KML_Feature.h

    r11237 r12706  
    1212
    1313/*Headers:*/
    14 /*{{{1*/
     14/*{{{*/
    1515#include "../../include/include.h"
    1616#include "../../shared/Exceptions/exceptions.h"
     
    3434                DataSet* style;
    3535
    36                 /*KML_Feature constructors, destructors {{{1*/
     36                /*KML_Feature constructors, destructors {{{*/
    3737                KML_Feature();
    3838                ~KML_Feature();
    3939                /*}}}*/
    40                 /*Object virtual functions definitions:{{{1*/
     40                /*Object virtual functions definitions:{{{*/
    4141                void  Echo();
    4242                void  DeepEcho();
     
    4444                void  Write(FILE* fid,const char* indent);
    4545                void  Read(FILE* fid,char* kstr);
    46                 int   Id(){_error_("Not implemented yet.");};
    47                 int   MyRank(){_error_("Not implemented yet.");};
    48                 void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    49                 int   MarshallSize(){_error_("Not implemented yet.");};
    50                 void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    51                 int   ObjectEnum(){_error_("Not implemented yet.");};
    52                 Object* copy(){_error_("Not implemented yet.");};
     46                int   Id(){_error2_("Not implemented yet.");};
     47                int   MyRank(){_error2_("Not implemented yet.");};
     48                void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     49                int   MarshallSize(){_error2_("Not implemented yet.");};
     50                void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     51                int   ObjectEnum(){_error2_("Not implemented yet.");};
     52                Object* copy(){_error2_("Not implemented yet.");};
    5353                /*}}}*/
    5454
  • issm/trunk/src/c/objects/KML/KML_File.cpp

    r11527 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*Constructors/destructor/copy*/
    23 /*FUNCTION KML_File::KML_File(){{{1*/
     23/*FUNCTION KML_File::KML_File(){{{*/
    2424KML_File::KML_File(){
    2525
     
    2828}
    2929/*}}}*/
    30 /*FUNCTION KML_File::~KML_File(){{{1*/
     30/*FUNCTION KML_File::~KML_File(){{{*/
    3131KML_File::~KML_File(){
    3232
     
    3737
    3838/*Other*/
    39 /*FUNCTION KML_File::Echo {{{1*/
     39/*FUNCTION KML_File::Echo {{{*/
    4040void  KML_File::Echo(){
    4141
    4242        bool  flag=true;
    4343
    44         _printf_(flag,"KML_File:\n");
     44        if(flag) _pprintLine_("KML_File:");
    4545        KML_Object::Echo();
    4646
     
    4848}
    4949/*}}}*/
    50 /*FUNCTION KML_File::DeepEcho {{{1*/
     50/*FUNCTION KML_File::DeepEcho {{{*/
    5151void  KML_File::DeepEcho(){
    5252
     
    5858}
    5959/*}}}*/
    60 /*FUNCTION KML_File::DeepEcho {{{1*/
     60/*FUNCTION KML_File::DeepEcho {{{*/
    6161void  KML_File::DeepEcho(const char* indent){
    6262
    6363        bool  flag=true;
    6464
    65         _printf_(flag,"%sKML_File:\n",indent);
     65        if(flag) _pprintLine_(indent << "KML_File:");
    6666        KML_Object::DeepEcho(indent);
    6767
     
    6969}
    7070/*}}}*/
    71 /*FUNCTION KML_File::Write {{{1*/
     71/*FUNCTION KML_File::Write {{{*/
    7272void  KML_File::Write(FILE* filout,const char* indent){
    7373
     
    8484}
    8585/*}}}*/
    86 /*FUNCTION KML_File::Read {{{1*/
     86/*FUNCTION KML_File::Read {{{*/
    8787void  KML_File::Read(FILE* fid,char* kstr){
    8888
     
    107107                }
    108108                else if (!strncmp(kstri,"</",2))
    109                         _error_("KML_File::Read -- Unexpected closing tag %s.\n",kstri);
     109                  {_error2_("KML_File::Read -- Unexpected closing tag " << kstri << ".");}
    110110                else if (strncmp(kstri,"<",1))
    111                         _error_("KML_File::Read -- Unexpected field \"%s\".\n",kstri);
     111                  {_error2_("KML_File::Read -- Unexpected field \"" << kstri << "\"");}
    112112
    113113                else if (!strncmp(kstri,"<",1))
     
    126126}
    127127/*}}}*/
    128 /*FUNCTION KML_File::WriteExp {{{1*/
     128/*FUNCTION KML_File::WriteExp {{{*/
    129129void  KML_File::WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp){
    130130
  • issm/trunk/src/c/objects/KML/KML_File.h

    r11527 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "../../include/include.h"
    1111#include "../../shared/Exceptions/exceptions.h"
     
    2020        public:
    2121
    22                 /*KML_File constructors, destructors {{{1*/
     22                /*KML_File constructors, destructors {{{*/
    2323                KML_File();
    2424                ~KML_File();
    2525                /*}}}*/
    26                 /*Object virtual functions definitions:{{{1*/
     26                /*Object virtual functions definitions:{{{*/
    2727                void  Echo();
    2828                void  DeepEcho();
     
    3131                void  Read(FILE* fid,char* kstr);
    3232                void  WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp);
    33                 int   Id(){_error_("Not implemented yet.");};
    34                 int   MyRank(){_error_("Not implemented yet.");};
    35                 void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    36                 int   MarshallSize(){_error_("Not implemented yet.");};
    37                 void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    38                 int   ObjectEnum(){_error_("Not implemented yet.");};
    39                 Object* copy(){_error_("Not implemented yet.");};
     33                int   Id(){_error2_("Not implemented yet.");};
     34                int   MyRank(){_error2_("Not implemented yet.");};
     35                void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     36                int   MarshallSize(){_error2_("Not implemented yet.");};
     37                void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     38                int   ObjectEnum(){_error2_("Not implemented yet.");};
     39                Object* copy(){_error2_("Not implemented yet.");};
    4040                /*}}}*/
    4141
  • issm/trunk/src/c/objects/KML/KML_Folder.cpp

    r11237 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*Constructors/destructor/copy*/
    23 /*FUNCTION KML_Folder::KML_Folder(){{{1*/
     23/*FUNCTION KML_Folder::KML_Folder(){{{*/
    2424KML_Folder::KML_Folder(){
    2525
     
    2828}
    2929/*}}}*/
    30 /*FUNCTION KML_Folder::~KML_Folder(){{{1*/
     30/*FUNCTION KML_Folder::~KML_Folder(){{{*/
    3131KML_Folder::~KML_Folder(){
    3232
     
    3737
    3838/*Other*/
    39 /*FUNCTION KML_Folder::Echo {{{1*/
     39/*FUNCTION KML_Folder::Echo {{{*/
    4040void  KML_Folder::Echo(){
    4141
    4242        bool  flag=true;
    4343
    44         _printf_(flag,"KML_Folder:\n");
     44        if(flag) _pprintLine_("KML_Folder:");
    4545        KML_Container::Echo();
    4646
     
    4949/*}}}*/
    5050
    51 /*FUNCTION KML_Folder::DeepEcho {{{1*/
     51/*FUNCTION KML_Folder::DeepEcho {{{*/
    5252void  KML_Folder::DeepEcho(){
    5353
     
    6060/*}}}*/
    6161
    62 /*FUNCTION KML_Folder::DeepEcho {{{1*/
     62/*FUNCTION KML_Folder::DeepEcho {{{*/
    6363void  KML_Folder::DeepEcho(const char* indent){
    6464
    6565        bool  flag=true;
    6666
    67         _printf_(flag,"%sKML_Folder:\n",indent);
     67        if(flag) _pprintLine_(indent << "KML_Folder:");
    6868        KML_Container::DeepEcho(indent);
    6969
     
    7272/*}}}*/
    7373
    74 /*FUNCTION KML_Folder::Write {{{1*/
     74/*FUNCTION KML_Folder::Write {{{*/
    7575void  KML_Folder::Write(FILE* filout,const char* indent){
    7676
     
    8888/*}}}*/
    8989
    90 /*FUNCTION KML_Folder::Read {{{1*/
     90/*FUNCTION KML_Folder::Read {{{*/
    9191void  KML_Folder::Read(FILE* fid,char* kstr){
    9292
     
    110110                }
    111111                else if (!strncmp(kstri,"</",2))
    112                         _error_("KML_Folder::Read -- Unexpected closing tag %s.\n",kstri);
     112                  {_error2_("KML_Folder::Read -- Unexpected closing tag " << kstri << ".\n");}
    113113                else if (strncmp(kstri,"<",1))
    114                         _error_("KML_Folder::Read -- Unexpected field \"%s\".\n",kstri);
     114                  {_error2_("KML_Folder::Read -- Unexpected field \"" << kstri << "\".\n");}
    115115
    116116                else if (!strncmp(kstri,"<",1))
  • issm/trunk/src/c/objects/KML/KML_Folder.h

    r11237 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "../../include/include.h"
    1111#include "../../shared/Exceptions/exceptions.h"
     
    2020        public:
    2121
    22                 /*KML_Folder constructors, destructors {{{1*/
     22                /*KML_Folder constructors, destructors {{{*/
    2323                KML_Folder();
    2424                ~KML_Folder();
    2525                /*}}}*/
    26                 /*Object virtual functions definitions:{{{1 */
     26                /*Object virtual functions definitions:{{{ */
    2727                void  Echo();
    2828                void  DeepEcho();
     
    3030                void  Write(FILE* fid,const char* indent);
    3131                void  Read(FILE* fid,char* kstr);
    32                 int   Id(){_error_("Not implemented yet.");};
    33                 int   MyRank(){_error_("Not implemented yet.");};
    34                 void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    35                 int   MarshallSize(){_error_("Not implemented yet.");};
    36                 void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    37                 int   ObjectEnum(){_error_("Not implemented yet.");};
    38                 Object* copy(){_error_("Not implemented yet.");};
     32                int   Id(){_error2_("Not implemented yet.");};
     33                int   MyRank(){_error2_("Not implemented yet.");};
     34                void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     35                int   MarshallSize(){_error2_("Not implemented yet.");};
     36                void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     37                int   ObjectEnum(){_error2_("Not implemented yet.");};
     38                Object* copy(){_error2_("Not implemented yet.");};
    3939                /*}}}*/
    4040
  • issm/trunk/src/c/objects/KML/KML_Geometry.cpp

    r11237 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2020
    2121/*Constructors/destructor/copy*/
    22 /*FUNCTION KML_Geometry::KML_Geometry(){{{1*/
     22/*FUNCTION KML_Geometry::KML_Geometry(){{{*/
    2323KML_Geometry::KML_Geometry(){
    2424
     
    2727}
    2828/*}}}*/
    29 /*FUNCTION KML_Geometry::~KML_Geometry(){{{1*/
     29/*FUNCTION KML_Geometry::~KML_Geometry(){{{*/
    3030KML_Geometry::~KML_Geometry(){
    3131
     
    3636
    3737/*Other*/
    38 /*FUNCTION KML_Geometry::Echo {{{1*/
     38/*FUNCTION KML_Geometry::Echo {{{*/
    3939void  KML_Geometry::Echo(){
    4040
     
    4545/*}}}*/
    4646
    47 /*FUNCTION KML_Geometry::DeepEcho {{{1*/
     47/*FUNCTION KML_Geometry::DeepEcho {{{*/
    4848void  KML_Geometry::DeepEcho(){
    4949
     
    5656/*}}}*/
    5757
    58 /*FUNCTION KML_Geometry::DeepEcho {{{1*/
     58/*FUNCTION KML_Geometry::DeepEcho {{{*/
    5959void  KML_Geometry::DeepEcho(const char* indent){
    6060
     
    6565/*}}}*/
    6666
    67 /*FUNCTION KML_Geometry::Write {{{1*/
     67/*FUNCTION KML_Geometry::Write {{{*/
    6868void  KML_Geometry::Write(FILE* filout,const char* indent){
    6969
     
    7474/*}}}*/
    7575
    76 /*FUNCTION KML_Geometry::Read {{{1*/
     76/*FUNCTION KML_Geometry::Read {{{*/
    7777void  KML_Geometry::Read(FILE* fid,char* kstr){
    7878
     
    8282                return;
    8383        else if (!strncmp(kstr,"</",2))
    84                 _error_("KML_Geometry::Read -- Unexpected closing tag %s.\n",kstr);
     84          {_error2_("KML_Geometry::Read -- Unexpected closing tag " << kstr << ".\n");}
    8585        else if (strncmp(kstr,"<",1))
    86                 _error_("KML_Geometry::Read -- Unexpected field \"%s\".\n",kstr);
     86          {_error2_("KML_Geometry::Read -- Unexpected field \"" << kstr << "\".\n");}
    8787
    8888        else if (!strncmp(kstr,"<",1))
  • issm/trunk/src/c/objects/KML/KML_Geometry.h

    r11237 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "../../include/include.h"
    1111#include "../../shared/Exceptions/exceptions.h"
     
    1919        public:
    2020
    21                 /*KML_Geometry constructors, destructors {{{1*/
     21                /*KML_Geometry constructors, destructors {{{*/
    2222                KML_Geometry();
    2323                ~KML_Geometry();
    2424                /*}}}*/
    25                 /*Object virtual functions definitions:{{{1*/
     25                /*Object virtual functions definitions:{{{*/
    2626                void  Echo();
    2727                void  DeepEcho();
     
    2929                void  Write(FILE* fid,const char* indent);
    3030                void  Read(FILE* fid,char* kstr);
    31                 int   Id(){_error_("Not implemented yet.");};
    32                 int   MyRank(){_error_("Not implemented yet.");};
    33                 void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    34                 int   MarshallSize(){_error_("Not implemented yet.");};
    35                 void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    36                 int   ObjectEnum(){_error_("Not implemented yet.");};
    37                 Object* copy(){_error_("Not implemented yet.");};
     31                int   Id(){_error2_("Not implemented yet.");};
     32                int   MyRank(){_error2_("Not implemented yet.");};
     33                void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     34                int   MarshallSize(){_error2_("Not implemented yet.");};
     35                void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     36                int   ObjectEnum(){_error2_("Not implemented yet.");};
     37                Object* copy(){_error2_("Not implemented yet.");};
    3838                /*}}}*/
    3939
  • issm/trunk/src/c/objects/KML/KML_GroundOverlay.cpp

    r11527 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*Constructors/destructor/copy*/
    23 /*FUNCTION KML_GroundOverlay::KML_GroundOverlay(){{{1*/
     23/*FUNCTION KML_GroundOverlay::KML_GroundOverlay(){{{*/
    2424KML_GroundOverlay::KML_GroundOverlay(){
    2525
     
    3131}
    3232/*}}}*/
    33 /*FUNCTION KML_GroundOverlay::~KML_GroundOverlay(){{{1*/
     33/*FUNCTION KML_GroundOverlay::~KML_GroundOverlay(){{{*/
    3434KML_GroundOverlay::~KML_GroundOverlay(){
    3535
     
    4343
    4444/*Other*/
    45 /*FUNCTION KML_GroundOverlay::Echo {{{1*/
     45/*FUNCTION KML_GroundOverlay::Echo {{{*/
    4646void  KML_GroundOverlay::Echo(){
    4747
    48         bool  flag=true;
    49 
    50         _printf_(flag,"KML_GroundOverlay:\n");
     48        _printLine_("KML_GroundOverlay:");
    5149        KML_Overlay::Echo();
    5250
    53         _printf_(flag,"      altitude: %0.16g\n"      ,altitude);
    54         _printf_(flag,"       altmode: \"%s\"\n"      ,altmode);
    55         _printf_(flag,"         llbox: %p\n"          ,llbox);
    56 
    57         return;
     51        _printLine_("         altitude: " << altitude);
     52        _printLine_("          altmode: " << altmode);
     53        _printLine_("            llbox: " << llbox);
    5854}
    5955/*}}}*/
    60 
    61 /*FUNCTION KML_GroundOverlay::DeepEcho {{{1*/
     56/*FUNCTION KML_GroundOverlay::DeepEcho {{{*/
    6257void  KML_GroundOverlay::DeepEcho(){
    6358
     
    6964}
    7065/*}}}*/
    71 
    72 /*FUNCTION KML_GroundOverlay::DeepEcho {{{1*/
     66/*FUNCTION KML_GroundOverlay::DeepEcho {{{*/
    7367void  KML_GroundOverlay::DeepEcho(const char* indent){
    7468
    7569        char  indent2[81];
    76         bool  flag=true;
    7770
    78         _printf_(flag,"%sKML_GroundOverlay:\n",indent);
     71        _printLine_(indent << "KML_GroundOverlay:");
    7972        KML_Overlay::DeepEcho(indent);
    8073
     
    8275        strcat(indent2,"  ");
    8376
    84         _printf_(flag,"%s      altitude: %0.16g\n"      ,indent,altitude);
    85         _printf_(flag,"%s       altmode: \"%s\"\n"      ,indent,altmode);
     77        _printLine_(indent<<"      altitude: " << altitude);
     78        _printLine_(indent<<"       altmode: " << altmode);
    8679        if (llbox)
    87                 llbox->DeepEcho(indent2);
     80         llbox->DeepEcho(indent2);
    8881        else
    89                 _printf_(flag,"%s         llbox: %p\n"          ,indent,llbox);
    90 
    91         return;
     82         _printLine_(indent<<"         llbox: " << llbox);
    9283}
    9384/*}}}*/
    94 
    95 /*FUNCTION KML_GroundOverlay::Write {{{1*/
     85/*FUNCTION KML_GroundOverlay::Write {{{*/
    9686void  KML_GroundOverlay::Write(FILE* filout,const char* indent){
    9787
     
    119109}
    120110/*}}}*/
    121 
    122 /*FUNCTION KML_GroundOverlay::Read {{{1*/
     111/*FUNCTION KML_GroundOverlay::Read {{{*/
    123112void  KML_GroundOverlay::Read(FILE* fid,char* kstr){
    124113
     
    142131                }
    143132                else if (!strncmp(kstri,"</",2))
    144                         _error_("KML_GroundOverlay::Read -- Unexpected closing tag %s.\n",kstri);
     133                  {_error2_("KML_GroundOverlay::Read -- Unexpected closing tag " << kstri << ".\n");}
    145134                else if (strncmp(kstri,"<",1))
    146                         _error_("KML_GroundOverlay::Read -- Unexpected field \"%s\".\n",kstri);
     135                  {_error2_("KML_GroundOverlay::Read -- Unexpected field \"" << kstri << "\".\n");}
    147136
    148137                else if (!strcmp(kstri,"<altitude>"))
     
    174163}
    175164/*}}}*/
    176 
  • issm/trunk/src/c/objects/KML/KML_GroundOverlay.h

    r11237 r12706  
    99
    1010/*Headers:*/
    11 /*{{{1*/
     11/*{{{*/
    1212#include "../../include/include.h"
    1313#include "../../shared/Exceptions/exceptions.h"
     
    2626                KML_LatLonBox* llbox;
    2727
    28                 /*KML_GroundOverlay constructors, destructors {{{1*/
     28                /*KML_GroundOverlay constructors, destructors {{{*/
    2929                KML_GroundOverlay();
    3030                ~KML_GroundOverlay();
    3131                /*}}}*/
    32                 /*Object virtual functions definitions:{{{1*/
     32                /*Object virtual functions definitions:{{{*/
    3333                void  Echo();
    3434                void  DeepEcho();
     
    3636                void  Write(FILE* fid,const char* indent);
    3737                void  Read(FILE* fid,char* kstr);
    38                 int   Id(){_error_("Not implemented yet.");};
    39                 int   MyRank(){_error_("Not implemented yet.");};
    40                 void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    41                 int   MarshallSize(){_error_("Not implemented yet.");};
    42                 void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    43                 int   ObjectEnum(){_error_("Not implemented yet.");};
    44                 Object* copy(){_error_("Not implemented yet.");};
     38                int   Id(){_error2_("Not implemented yet.");};
     39                int   MyRank(){_error2_("Not implemented yet.");};
     40                void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     41                int   MarshallSize(){_error2_("Not implemented yet.");};
     42                void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     43                int   ObjectEnum(){_error2_("Not implemented yet.");};
     44                Object* copy(){_error2_("Not implemented yet.");};
    4545                /*}}}*/
    4646
  • issm/trunk/src/c/objects/KML/KML_Icon.cpp

    r11237 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*Constructors/destructor/copy*/
    23 /*FUNCTION KML_Icon::KML_Icon(){{{1*/
     23/*FUNCTION KML_Icon::KML_Icon(){{{*/
    2424KML_Icon::KML_Icon(){
    2525
     
    3535}
    3636/*}}}*/
    37 /*FUNCTION KML_Icon::~KML_Icon(){{{1*/
     37/*FUNCTION KML_Icon::~KML_Icon(){{{*/
    3838KML_Icon::~KML_Icon(){
    3939
     
    4444
    4545/*Other*/
    46 /*FUNCTION KML_Icon::Echo {{{1*/
     46/*FUNCTION KML_Icon::Echo {{{*/
    4747void  KML_Icon::Echo(){
    4848
    4949        bool  flag=true;
    5050
    51         _printf_(flag,"KML_Icon:\n");
     51        if(flag) _pprintLine_("KML_Icon:");
    5252        KML_Object::Echo();
    5353
    54         _printf_(flag,"          href: \"%s\"\n"    ,href);
    55         _printf_(flag,"       refmode: \"%s\"\n"    ,refmode);
    56         _printf_(flag,"        refint: %g\n"        ,refint);
    57         _printf_(flag,"      vrefmode: \"%s\"\n"    ,vrefmode);
    58         _printf_(flag,"      vreftime: %g\n"        ,vreftime);
    59         _printf_(flag,"      vboundsc: %g\n"        ,vboundsc);
    60         _printf_(flag,"       vformat: \"%s\"\n"    ,vformat);
    61         _printf_(flag,"        hquery: \"%s\"\n"    ,hquery);
     54        if(flag) _pprintLine_("          href: \"" << href << "\"");
     55        if(flag) _pprintLine_("       refmode: \"" << refmode << "\"");
     56        if(flag) _pprintLine_("        refint: " << refint);
     57        if(flag) _pprintLine_("      vrefmode: \"" << vrefmode << "\"");
     58        if(flag) _pprintLine_("      vreftime: " << vreftime);
     59        if(flag) _pprintLine_("      vboundsc: " << vboundsc);
     60        if(flag) _pprintLine_("       vformat: \"" << vformat << "\"");
     61        if(flag) _pprintLine_("        hquery: \"" << hquery << "\"");
    6262
    6363        return;
    6464}
    6565/*}}}*/
    66 
    67 /*FUNCTION KML_Icon::DeepEcho {{{1*/
     66/*FUNCTION KML_Icon::DeepEcho {{{*/
    6867void  KML_Icon::DeepEcho(){
    6968
     
    7574}
    7675/*}}}*/
    77 
    78 /*FUNCTION KML_Icon::DeepEcho {{{1*/
     76/*FUNCTION KML_Icon::DeepEcho {{{*/
    7977void  KML_Icon::DeepEcho(const char* indent){
    8078
    8179        bool  flag=true;
    8280
    83         _printf_(flag,"%sKML_Icon:\n",indent);
     81        if(flag) _pprintLine_(indent << "KML_Icon:");
    8482        KML_Object::DeepEcho(indent);
    8583
    86         _printf_(flag,"%s          href: \"%s\"\n"    ,indent,href);
    87         _printf_(flag,"%s       refmode: \"%s\"\n"    ,indent,refmode);
    88         _printf_(flag,"%s        refint: %g\n"        ,indent,refint);
    89         _printf_(flag,"%s      vrefmode: \"%s\"\n"    ,indent,vrefmode);
    90         _printf_(flag,"%s      vreftime: %g\n"        ,indent,vreftime);
    91         _printf_(flag,"%s      vboundsc: %g\n"        ,indent,vboundsc);
    92         _printf_(flag,"%s       vformat: \"%s\"\n"    ,indent,vformat);
    93         _printf_(flag,"%s        hquery: \"%s\"\n"    ,indent,hquery);
     84        if(flag) _pprintLine_(indent << "          href: \"" << href << "\"");
     85        if(flag) _pprintLine_(indent << "       refmode: \"" << refmode << "\"");
     86        if(flag) _pprintLine_(indent << "        refint: " << refint);
     87        if(flag) _pprintLine_(indent << "      vrefmode: \"" << vrefmode << "\"");
     88        if(flag) _pprintLine_(indent << "      vreftime: " << vreftime);
     89        if(flag) _pprintLine_(indent << "      vboundsc: " << vboundsc);
     90        if(flag) _pprintLine_(indent << "       vformat: \"" << vformat << "\"");
     91        if(flag) _pprintLine_(indent << "        hquery: \"" << hquery << "\"");
    9492
    9593        return;
    9694}
    9795/*}}}*/
    98 
    99 /*FUNCTION KML_Icon::Write {{{1*/
     96/*FUNCTION KML_Icon::Write {{{*/
    10097void  KML_Icon::Write(FILE* filout,const char* indent){
    10198
     
    126123}
    127124/*}}}*/
    128 
    129 /*FUNCTION KML_Icon::Read {{{1*/
     125/*FUNCTION KML_Icon::Read {{{*/
    130126void  KML_Icon::Read(FILE* fid,char* kstr){
    131127
     
    149145                }
    150146                else if (!strncmp(kstri,"</",2))
    151                         _error_("KML_Icon::Read -- Unexpected closing tag %s.\n",kstri);
     147                  {_error2_("KML_Icon::Read -- Unexpected closing tag " << kstri << ".\n");}
    152148                else if (strncmp(kstri,"<",1))
    153                         _error_("KML_Icon::Read -- Unexpected field \"%s\".\n",kstri);
     149                  {_error2_("KML_Icon::Read -- Unexpected field \"" << kstri << "\".\n");}
    154150
    155151                else if (!strcmp(kstri,"<href>"))
    156                         KMLFileTokenParse( href      ,NULL,KML_ICON_HREF_LENGTH,
    157                                                           kstri,
    158                                                           fid);
     152                        KMLFileTokenParse( href      ,NULL,KML_ICON_HREF_LENGTH, kstri, fid);
    159153                else if (!strcmp(kstri,"<refreshMode>"))
    160                         KMLFileTokenParse( refmode   ,NULL,KML_ICON_REFMODE_LENGTH,
    161                                                           kstri,
    162                                                           fid);
     154                        KMLFileTokenParse( refmode   ,NULL,KML_ICON_REFMODE_LENGTH, kstri, fid);
    163155                else if (!strcmp(kstri,"<refreshInterval>"))
    164                         KMLFileTokenParse(&refint    ,
    165                                                           kstri,
    166                                                           fid);
     156                        KMLFileTokenParse(&refint    , kstri, fid);
    167157                else if (!strcmp(kstri,"<viewRefreshMode>"))
    168                         KMLFileTokenParse( vrefmode  ,NULL,KML_ICON_VREFMODE_LENGTH,
    169                                                           kstri,
    170                                                           fid);
     158                        KMLFileTokenParse( vrefmode  ,NULL,KML_ICON_VREFMODE_LENGTH, kstri, fid);
    171159                else if (!strcmp(kstri,"<viewRefreshTime>"))
    172                         KMLFileTokenParse(&vreftime  ,
    173                                                           kstri,
    174                                                           fid);
     160                        KMLFileTokenParse(&vreftime  , kstri, fid);
    175161                else if (!strcmp(kstri,"<viewBoundScale>"))
    176                         KMLFileTokenParse(&vboundsc  ,
    177                                                           kstri,
    178                                                           fid);
     162                        KMLFileTokenParse(&vboundsc  , kstri, fid);
    179163                else if (!strcmp(kstri,"<viewFormat>"))
    180                         KMLFileTokenParse( vformat   ,NULL,KML_ICON_VFORMAT_LENGTH,
    181                                                           kstri,
    182                                                           fid);
     164                        KMLFileTokenParse( vformat   ,NULL,KML_ICON_VFORMAT_LENGTH, kstri, fid);
    183165                else if (!strcmp(kstri,"<httpQuery>"))
    184                         KMLFileTokenParse( hquery    ,NULL,KML_ICON_HQUERY_LENGTH,
    185                                                           kstri,
    186                                                           fid);
     166                        KMLFileTokenParse( hquery    ,NULL,KML_ICON_HQUERY_LENGTH, kstri, fid);
    187167
    188168                else if (!strncmp(kstri,"<",1))
     
    201181}
    202182/*}}}*/
    203 
  • issm/trunk/src/c/objects/KML/KML_Icon.h

    r11237 r12706  
    1313
    1414/*Headers:*/
    15 /*{{{1*/
     15/*{{{*/
    1616#include "../../include/include.h"
    1717#include "../../shared/Exceptions/exceptions.h"
     
    3434                char  hquery[KML_ICON_HQUERY_LENGTH+1];
    3535
    36                 /*KML_Icon constructors, destructors {{{1*/
     36                /*KML_Icon constructors, destructors {{{*/
    3737                KML_Icon();
    3838                ~KML_Icon();
    3939                /*}}}*/
    40                 /*Object virtual functions definitions:{{{1*/
     40                /*Object virtual functions definitions:{{{*/
    4141                void  Echo();
    4242                void  DeepEcho();
     
    4444                void  Write(FILE* fid,const char* indent);
    4545                void  Read(FILE* fid,char* kstr);
    46                 int   Id(){_error_("Not implemented yet.");};
    47                 int   MyRank(){_error_("Not implemented yet.");};
    48                 void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    49                 int   MarshallSize(){_error_("Not implemented yet.");};
    50                 void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    51                 int   ObjectEnum(){_error_("Not implemented yet.");};
    52                 Object* copy(){_error_("Not implemented yet.");};
     46                int   Id(){_error2_("Not implemented yet.");};
     47                int   MyRank(){_error2_("Not implemented yet.");};
     48                void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     49                int   MarshallSize(){_error2_("Not implemented yet.");};
     50                void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     51                int   ObjectEnum(){_error2_("Not implemented yet.");};
     52                Object* copy(){_error2_("Not implemented yet.");};
    5353                /*}}}*/
    5454
  • issm/trunk/src/c/objects/KML/KML_LatLonBox.cpp

    r11237 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*Constructors/destructor/copy*/
    23 /*FUNCTION KML_LatLonBox::KML_LatLonBox(){{{1*/
     23/*FUNCTION KML_LatLonBox::KML_LatLonBox(){{{*/
    2424KML_LatLonBox::KML_LatLonBox(){
    2525
     
    3232}
    3333/*}}}*/
    34 /*FUNCTION KML_LatLonBox::~KML_LatLonBox(){{{1*/
     34/*FUNCTION KML_LatLonBox::~KML_LatLonBox(){{{*/
    3535KML_LatLonBox::~KML_LatLonBox(){
    3636
     
    4141
    4242/*Other*/
    43 /*FUNCTION KML_LatLonBox::Echo {{{1*/
     43/*FUNCTION KML_LatLonBox::Echo {{{*/
    4444void  KML_LatLonBox::Echo(){
    4545
    46         bool  flag=true;
    4746
    48         _printf_(flag,"KML_LatLonBox:\n");
     47        _printLine_("KML_LatLonBox:");
    4948        KML_Object::Echo();
    5049
    51         _printf_(flag,"         north: %0.16g\n"    ,north);
    52         _printf_(flag,"         south: %0.16g\n"    ,south);
    53         _printf_(flag,"          east: %0.16g\n"    ,east);
    54         _printf_(flag,"          west: %0.16g\n"    ,west);
    55         _printf_(flag,"      rotation: %0.16g\n"    ,rotation);
    56 
    57         return;
     50        _printLine_("         north: " << north);
     51        _printLine_("         south: " << south);
     52        _printLine_("          east: " << east);
     53        _printLine_("          west: " << west);
     54        _printLine_("      rotation: " << rotation);
    5855}
    5956/*}}}*/
    60 
    61 /*FUNCTION KML_LatLonBox::DeepEcho {{{1*/
     57/*FUNCTION KML_LatLonBox::DeepEcho {{{*/
    6258void  KML_LatLonBox::DeepEcho(){
    6359
     
    6965}
    7066/*}}}*/
    71 
    72 /*FUNCTION KML_LatLonBox::DeepEcho {{{1*/
     67/*FUNCTION KML_LatLonBox::DeepEcho {{{*/
    7368void  KML_LatLonBox::DeepEcho(const char* indent){
    7469
    75         bool  flag=true;
    76 
    77         _printf_(flag,"%sKML_LatLonBox:\n",indent);
     70        _printLine_(indent << "KML_LatLonBox:");
    7871        KML_Object::DeepEcho(indent);
    7972
    80         _printf_(flag,"%s         north: %0.16g\n"    ,indent,north);
    81         _printf_(flag,"%s         south: %0.16g\n"    ,indent,south);
    82         _printf_(flag,"%s          east: %0.16g\n"    ,indent,east);
    83         _printf_(flag,"%s          west: %0.16g\n"    ,indent,west);
    84         _printf_(flag,"%s      rotation: %0.16g\n"    ,indent,rotation);
    85 
    86         return;
     73        _printLine_("         north: " << north);
     74        _printLine_("         south: " << south);
     75        _printLine_("          east: " << east);
     76        _printLine_("          west: " << west);
     77        _printLine_("      rotation: " << rotation);
    8778}
    8879/*}}}*/
    89 
    90 /*FUNCTION KML_LatLonBox::Write {{{1*/
     80/*FUNCTION KML_LatLonBox::Write {{{*/
    9181void  KML_LatLonBox::Write(FILE* filout,const char* indent){
    9282
     
    10999}
    110100/*}}}*/
    111 
    112 /*FUNCTION KML_LatLonBox::Read {{{1*/
     101/*FUNCTION KML_LatLonBox::Read {{{*/
    113102void  KML_LatLonBox::Read(FILE* fid,char* kstr){
    114103
     
    132121                }
    133122                else if (!strncmp(kstri,"</",2))
    134                         _error_("KML_LatLonBox::Read -- Unexpected closing tag %s.\n",kstri);
     123                  {_error2_("KML_LatLonBox::Read -- Unexpected closing tag " << kstri << ".\n");}
    135124                else if (strncmp(kstri,"<",1))
    136                         _error_("KML_LatLonBox::Read -- Unexpected field \"%s\".\n",kstri);
     125                  {_error2_("KML_LatLonBox::Read -- Unexpected field \"" << kstri << "\".\n");}
    137126
    138127                else if (!strcmp(kstri,"<north>"))
     
    172161}
    173162/*}}}*/
    174 
  • issm/trunk/src/c/objects/KML/KML_LatLonBox.h

    r11237 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "../../include/include.h"
    1111#include "../../shared/Exceptions/exceptions.h"
     
    2525                double rotation;
    2626
    27                 /*KML_LatLonBox constructors, destructors {{{1*/
     27                /*KML_LatLonBox constructors, destructors {{{*/
    2828                KML_LatLonBox();
    2929                ~KML_LatLonBox();
    3030                /*}}}*/
    31                 /*Object virtual functions definitions:{{{1*/
     31                /*Object virtual functions definitions:{{{*/
    3232                void  Echo();
    3333                void  DeepEcho();
     
    3535                void  Write(FILE* fid,const char* indent);
    3636                void  Read(FILE* fid,char* kstr);
    37                 int   Id(){_error_("Not implemented yet.");};
    38                 int   MyRank(){_error_("Not implemented yet.");};
    39                 void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    40                 int   MarshallSize(){_error_("Not implemented yet.");};
    41                 void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    42                 int   ObjectEnum(){_error_("Not implemented yet.");};
    43                 Object* copy(){_error_("Not implemented yet.");};
     37                int   Id(){_error2_("Not implemented yet.");};
     38                int   MyRank(){_error2_("Not implemented yet.");};
     39                void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     40                int   MarshallSize(){_error2_("Not implemented yet.");};
     41                void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     42                int   ObjectEnum(){_error2_("Not implemented yet.");};
     43                Object* copy(){_error2_("Not implemented yet.");};
    4444                /*}}}*/
    4545
  • issm/trunk/src/c/objects/KML/KML_LineString.cpp

    r11237 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2222
    2323/*Constructors/destructor/copy*/
    24 /*FUNCTION KML_LineString::KML_LineString(){{{1*/
     24/*FUNCTION KML_LineString::KML_LineString(){{{*/
    2525KML_LineString::KML_LineString(){
    2626
     
    3434}
    3535/*}}}*/
    36 /*FUNCTION KML_LineString::~KML_LineString(){{{1*/
     36/*FUNCTION KML_LineString::~KML_LineString(){{{*/
    3737KML_LineString::~KML_LineString(){
    3838
    39         if (coords) xfree((void**)&coords);
     39        if (coords) xDelete<double>(coords);
    4040
    4141        coords    =NULL;
     
    4646
    4747/*Other*/
    48 /*FUNCTION KML_LineString::Echo {{{1*/
     48/*FUNCTION KML_LineString::Echo {{{*/
    4949void  KML_LineString::Echo(){
    5050
    5151        bool  flag=true;
    5252
    53         _printf_(flag,"KML_LineString:\n");
     53        if(flag) _pprintLine_("KML_LineString:");
    5454        KML_Geometry::Echo();
    5555
    56         _printf_(flag,"       extrude: %s\n"          ,(extrude ? "true" : "false"));
    57         _printf_(flag,"    tessellate: %s\n"          ,(tessellate ? "true" : "false"));
    58         _printf_(flag,"       altmode: \"%s\"\n"      ,altmode);
    59         _printf_(flag,"        coords: (ncoord=%d)\n" ,ncoord);
    60 
    61         return;
    62 }
    63 /*}}}*/
    64 /*FUNCTION KML_LineString::DeepEcho {{{1*/
     56        if(flag) _pprintLine_("       extrude: " << (extrude ? "true" : "false"));
     57        if(flag) _pprintLine_("    tessellate: " << (tessellate ? "true" : "false"));
     58        if(flag) _pprintLine_("       altmode: \"" << altmode << "\"");
     59        if(flag) _pprintLine_("        coords: (ncoord=" << ncoord << ")");
     60
     61        return;
     62}
     63/*}}}*/
     64/*FUNCTION KML_LineString::DeepEcho {{{*/
    6565void  KML_LineString::DeepEcho(){
    6666
     
    7272}
    7373/*}}}*/
    74 /*FUNCTION KML_LineString::DeepEcho {{{1*/
     74/*FUNCTION KML_LineString::DeepEcho {{{*/
    7575void  KML_LineString::DeepEcho(const char* indent){
    7676
     
    7878        bool  flag=true;
    7979
    80         _printf_(flag,"%sKML_LineString:\n",indent);
     80        if(flag) _pprintLine_(indent << "KML_LineString:");
    8181        KML_Geometry::DeepEcho(indent);
    8282
    83         _printf_(flag,"%s       extrude: %s\n"          ,indent,(extrude ? "true" : "false"));
    84         _printf_(flag,"%s    tessellate: %s\n"          ,indent,(tessellate ? "true" : "false"));
    85         _printf_(flag,"%s       altmode: \"%s\"\n"      ,indent,altmode);
    86         _printf_(flag,"%s        coords: (ncoord=%d)\n" ,indent,ncoord);
     83        if(flag) _pprintLine_(indent << "       extrude: " << (extrude ? "true" : "false"));
     84        if(flag) _pprintLine_(indent << "    tessellate: " << (tessellate ? "true" : "false"));
     85        if(flag) _pprintLine_(indent << "       altmode: \"" << altmode << "\"");
     86        if(flag) _pprintLine_(indent << "        coords: (ncoord=" << ncoord << ")");
    8787        for (i=0; i<ncoord; i++)
    88                 _printf_(flag,"%s                (%g,%g,%g)\n" ,indent,
    89                                 coords[i][0],coords[i][1],coords[i][2]);
    90 
    91         return;
    92 }
    93 /*}}}*/
    94 /*FUNCTION KML_LineString::Write {{{1*/
     88                if(flag) _pprintLine_(indent << "                (" << coords[3*i+0] << "," << coords[3*i+1] << "," << coords[3*i+2] << ")");
     89
     90        return;
     91}
     92/*}}}*/
     93/*FUNCTION KML_LineString::Write {{{*/
    9594void  KML_LineString::Write(FILE* filout,const char* indent){
    9695
     
    112111
    113112        for (i=0; i<ncoord; i++)
    114                 fprintf(filout,"%s    %0.16g,%0.16g,%0.16g\n",indent,
    115                                 coords[i][0],coords[i][1],coords[i][2]);
     113                fprintf(filout,"%s    %0.16g,%0.16g,%0.16g\n",indent, coords[3*i+0],coords[3*i+1],coords[3*i+2]);
    116114
    117115        fprintf(filout,"%s  </coordinates>\n",indent);
     
    121119}
    122120/*}}}*/
    123 /*FUNCTION KML_LineString::Read {{{1*/
     121/*FUNCTION KML_LineString::Read {{{*/
    124122void  KML_LineString::Read(FILE* fid,char* kstr){
    125123
     
    143141                }
    144142                else if (!strncmp(kstri,"</",2))
    145                         _error_("KML_LineString::Read -- Unexpected closing tag %s.\n",kstri);
     143                  {_error2_("KML_LineString::Read -- Unexpected closing tag " << kstri << ".\n");}
    146144                else if (strncmp(kstri,"<",1))
    147                         _error_("KML_LineString::Read -- Unexpected field \"%s\".\n",kstri);
     145                  {_error2_("KML_LineString::Read -- Unexpected field \"" << kstri << "\".\n");}
    148146
    149147                else if (!strcmp(kstri,"<extrude>"))
     
    179177}
    180178/*}}}*/
    181 /*FUNCTION KML_LineString::WriteExp {{{1*/
     179/*FUNCTION KML_LineString::WriteExp {{{*/
    182180void  KML_LineString::WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp){
    183181
     
    191189        lon=(double *) xmalloc(ncoord*sizeof(double));
    192190        for (i=0; i<ncoord; i++) {
    193                 lon[i]=coords[i][0];
    194                 lat[i]=coords[i][1];
     191                lon[i]=coords[3*i+0];
     192                lat[i]=coords[3*i+1];
    195193        }
    196194
  • issm/trunk/src/c/objects/KML/KML_LineString.h

    r11237 r12706  
    99
    1010/*Headers:*/
    11 /*{{{1*/
     11/*{{{*/
    1212#include "../../include/include.h"
    1313#include "../../shared/Exceptions/exceptions.h"
     
    2121        public:
    2222
    23                 bool  extrude;
    24                 bool  tessellate;
    25                 char  altmode[KML_LINESTRING_ALTMODE_LENGTH+1];
    26         int   ncoord;
    27                 double (*coords)[3];
     23                bool    extrude;
     24                bool    tessellate;
     25                char    altmode[KML_LINESTRING_ALTMODE_LENGTH+1];
     26                int     ncoord;
     27                double *coords;
    2828
    29                 /*KML_LineString constructors, destructors {{{1*/
     29                /*KML_LineString constructors, destructors {{{*/
    3030                KML_LineString();
    3131                ~KML_LineString();
    3232                /*}}}*/
    33                 /*Object virtual functions definitions:{{{1*/
     33                /*Object virtual functions definitions:{{{*/
    3434                void  Echo();
    3535                void  DeepEcho();
     
    3838                void  Read(FILE* fid,char* kstr);
    3939                void  WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp);
    40                 int   Id(){_error_("Not implemented yet.");};
    41                 int   MyRank(){_error_("Not implemented yet.");};
    42                 void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    43                 int   MarshallSize(){_error_("Not implemented yet.");};
    44                 void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    45                 int   ObjectEnum(){_error_("Not implemented yet.");};
    46                 Object* copy(){_error_("Not implemented yet.");};
     40                int   Id(){_error2_("Not implemented yet.");};
     41                int   MyRank(){_error2_("Not implemented yet.");};
     42                void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     43                int   MarshallSize(){_error2_("Not implemented yet.");};
     44                void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     45                int   ObjectEnum(){_error2_("Not implemented yet.");};
     46                Object* copy(){_error2_("Not implemented yet.");};
    4747                /*}}}*/
    4848
  • issm/trunk/src/c/objects/KML/KML_LineStyle.cpp

    r11237 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*Constructors/destructor/copy*/
    23 /*FUNCTION KML_LineStyle::KML_LineStyle(){{{1*/
     23/*FUNCTION KML_LineStyle::KML_LineStyle(){{{*/
    2424KML_LineStyle::KML_LineStyle(){
    2525
     
    2828}
    2929/*}}}*/
    30 /*FUNCTION KML_LineStyle::~KML_LineStyle(){{{1*/
     30/*FUNCTION KML_LineStyle::~KML_LineStyle(){{{*/
    3131KML_LineStyle::~KML_LineStyle(){
    3232
     
    3737
    3838/*Other*/
    39 /*FUNCTION KML_LineStyle::Echo {{{1*/
     39/*FUNCTION KML_LineStyle::Echo {{{*/
    4040void  KML_LineStyle::Echo(){
    4141
    4242        bool  flag=true;
    4343
    44         _printf_(flag,"KML_LineStyle:\n");
     44        if(flag) _pprintLine_("KML_LineStyle:");
    4545        KML_ColorStyle::Echo();
    4646
    47         _printf_(flag,"         width: %g\n"          ,width);
     47        if(flag) _pprintLine_("         width: " << width);
    4848
    4949        return;
    5050}
    5151/*}}}*/
    52 
    53 /*FUNCTION KML_LineStyle::DeepEcho {{{1*/
     52/*FUNCTION KML_LineStyle::DeepEcho {{{*/
    5453void  KML_LineStyle::DeepEcho(){
    5554
     
    6160}
    6261/*}}}*/
    63 
    64 /*FUNCTION KML_LineStyle::DeepEcho {{{1*/
     62/*FUNCTION KML_LineStyle::DeepEcho {{{*/
    6563void  KML_LineStyle::DeepEcho(const char* indent){
    6664
     
    6866        bool  flag=true;
    6967
    70         _printf_(flag,"%sKML_LineStyle:\n",indent);
     68        if(flag) _pprintLine_(indent << "KML_LineStyle:");
    7169        KML_ColorStyle::DeepEcho(indent);
    7270
    73         _printf_(flag,"%s         width: %g\n"          ,indent,width);
     71        if(flag) _pprintLine_(indent << "         width: " << width);
    7472
    7573        return;
    7674}
    7775/*}}}*/
    78 
    79 /*FUNCTION KML_LineStyle::Write {{{1*/
     76/*FUNCTION KML_LineStyle::Write {{{*/
    8077void  KML_LineStyle::Write(FILE* filout,const char* indent){
    8178
     
    9491}
    9592/*}}}*/
    96 
    97 /*FUNCTION KML_LineStyle::Read {{{1*/
     93/*FUNCTION KML_LineStyle::Read {{{*/
    9894void  KML_LineStyle::Read(FILE* fid,char* kstr){
    9995
     
    117113                }
    118114                else if (!strncmp(kstri,"</",2))
    119                         _error_("KML_LineStyle::Read -- Unexpected closing tag %s.\n",kstri);
     115                  {_error2_("KML_LineStyle::Read -- Unexpected closing tag " << kstri << ".\n");}
    120116                else if (strncmp(kstri,"<",1))
    121                         _error_("KML_LineStyle::Read -- Unexpected field \"%s\".\n",kstri);
     117                  {_error2_("KML_LineStyle::Read -- Unexpected field \"" << kstri << "\".\n");}
    122118
    123119                else if (!strcmp(kstri,"<width>"))
     
    141137}
    142138/*}}}*/
    143 
  • issm/trunk/src/c/objects/KML/KML_LineStyle.h

    r11237 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "../../include/include.h"
    1111#include "../../shared/Exceptions/exceptions.h"
     
    2121                float width;
    2222
    23                 /*KML_LineStyle constructors, destructors {{{1*/
     23                /*KML_LineStyle constructors, destructors {{{*/
    2424                KML_LineStyle();
    2525                ~KML_LineStyle();
    2626                /*}}}*/
    27                 /*Object virtual functions definitions:{{{1 */
     27                /*Object virtual functions definitions:{{{ */
    2828                void  Echo();
    2929                void  DeepEcho();
     
    3131                void  Write(FILE* fid,const char* indent);
    3232                void  Read(FILE* fid,char* kstr);
    33                 int   Id(){_error_("Not implemented yet.");};
    34                 int   MyRank(){_error_("Not implemented yet.");};
    35                 void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    36                 int   MarshallSize(){_error_("Not implemented yet.");};
    37                 void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    38                 int   ObjectEnum(){_error_("Not implemented yet.");};
    39                 Object* copy(){_error_("Not implemented yet.");};
     33                int   Id(){_error2_("Not implemented yet.");};
     34                int   MyRank(){_error2_("Not implemented yet.");};
     35                void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     36                int   MarshallSize(){_error2_("Not implemented yet.");};
     37                void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     38                int   ObjectEnum(){_error2_("Not implemented yet.");};
     39                Object* copy(){_error2_("Not implemented yet.");};
    4040                /*}}}*/
    4141
  • issm/trunk/src/c/objects/KML/KML_LinearRing.cpp

    r11237 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2222
    2323/*Constructors/destructor/copy*/
    24 /*FUNCTION KML_LinearRing::KML_LinearRing(){{{1*/
     24/*FUNCTION KML_LinearRing::KML_LinearRing(){{{*/
    2525KML_LinearRing::KML_LinearRing(){
    2626
     
    3434}
    3535/*}}}*/
    36 /*FUNCTION KML_LinearRing::~KML_LinearRing(){{{1*/
     36/*FUNCTION KML_LinearRing::~KML_LinearRing(){{{*/
    3737KML_LinearRing::~KML_LinearRing(){
    3838
    39         if (coords) xfree((void**)&coords);
     39        if (coords) xDelete<double>(coords);
    4040
    4141        coords    =NULL;
     
    4646
    4747/*Other*/
    48 /*FUNCTION KML_LinearRing::Echo {{{1*/
     48/*FUNCTION KML_LinearRing::Echo {{{*/
    4949void  KML_LinearRing::Echo(){
    5050
    5151        bool  flag=true;
    5252
    53         _printf_(flag,"KML_LinearRing:\n");
     53        if(flag) _pprintLine_("KML_LinearRing:");
    5454        KML_Geometry::Echo();
    5555
    56         _printf_(flag,"       extrude: %s\n"          ,(extrude ? "true" : "false"));
    57         _printf_(flag,"    tessellate: %s\n"          ,(tessellate ? "true" : "false"));
    58         _printf_(flag,"       altmode: \"%s\"\n"      ,altmode);
    59         _printf_(flag,"        coords: (ncoord=%d)\n" ,ncoord);
    60 
    61         return;
    62 }
    63 /*}}}*/
    64 
    65 /*FUNCTION KML_LinearRing::DeepEcho {{{1*/
     56        if(flag) _pprintLine_("       extrude: " << (extrude ? "true" : "false"));
     57        if(flag) _pprintLine_("    tessellate: " << (tessellate ? "true" : "false"));
     58        if(flag) _pprintLine_("       altmode: \"" << altmode << "\"");
     59        if(flag) _pprintLine_("        coords: (ncoord=" << ncoord << ")");
     60
     61        return;
     62}
     63/*}}}*/
     64/*FUNCTION KML_LinearRing::DeepEcho {{{*/
    6665void  KML_LinearRing::DeepEcho(){
    6766
     
    7372}
    7473/*}}}*/
    75 
    76 /*FUNCTION KML_LinearRing::DeepEcho {{{1*/
     74/*FUNCTION KML_LinearRing::DeepEcho {{{*/
    7775void  KML_LinearRing::DeepEcho(const char* indent){
    7876
     
    8078        bool  flag=true;
    8179
    82         _printf_(flag,"%sKML_LinearRing:\n",indent);
     80        if(flag) _pprintLine_(indent << "KML_LinearRing:");
    8381        KML_Geometry::DeepEcho(indent);
    8482
    85         _printf_(flag,"%s       extrude: %s\n"          ,indent,(extrude ? "true" : "false"));
    86         _printf_(flag,"%s    tessellate: %s\n"          ,indent,(tessellate ? "true" : "false"));
    87         _printf_(flag,"%s       altmode: \"%s\"\n"      ,indent,altmode);
    88         _printf_(flag,"%s        coords: (ncoord=%d)\n" ,indent,ncoord);
     83        if(flag) _pprintLine_(indent << "       extrude: " << (extrude ? "true" : "false"));
     84        if(flag) _pprintLine_(indent << "    tessellate: " << (tessellate ? "true" : "false"));
     85        if(flag) _pprintLine_(indent << "       altmode: \"" << altmode << "\"");
     86        if(flag) _pprintLine_(indent << "        coords: (ncoord=" << ncoord << ")");
    8987        for (i=0; i<ncoord; i++)
    90                 _printf_(flag,"%s                (%g,%g,%g)\n" ,indent,
    91                                 coords[i][0],coords[i][1],coords[i][2]);
    92 
    93         return;
    94 }
    95 /*}}}*/
    96 
    97 /*FUNCTION KML_LinearRing::Write {{{1*/
     88                _printf_(flag,"%s                (%g,%g,%g)\n",indent,
     89                                coords[3*i+0],coords[3*i+1],coords[3*i+2]);
     90
     91        return;
     92}
     93/*}}}*/
     94/*FUNCTION KML_LinearRing::Write {{{*/
    9895void  KML_LinearRing::Write(FILE* filout,const char* indent){
    9996
     
    115112
    116113        for (i=0; i<ncoord; i++)
    117                 fprintf(filout,"%s    %0.16g,%0.16g,%0.16g\n",indent,
    118                                 coords[i][0],coords[i][1],coords[i][2]);
     114                fprintf(filout,"%s    %0.16g,%0.16g,%0.16g\n",indent,coords[3*i+0],coords[3*i+1],coords[3*i+2]);
    119115
    120116        fprintf(filout,"%s  </coordinates>\n",indent);
     
    124120}
    125121/*}}}*/
    126 
    127 /*FUNCTION KML_LinearRing::Read {{{1*/
     122/*FUNCTION KML_LinearRing::Read {{{*/
    128123void  KML_LinearRing::Read(FILE* fid,char* kstr){
    129124
    130         char*        kstri;
    131         int          ncom=0;
    132         char**       pcom=NULL;
     125        char  *kstri = NULL;
     126        int    ncom  = 0;
     127        char **pcom  = NULL;
    133128
    134129/*  get object attributes and check for solo tag  */
    135130
    136         if (KMLFileTagAttrib(this,
    137                                                  kstr))
    138                 return;
     131        if (KMLFileTagAttrib(this,kstr)) return;
    139132
    140133/*  loop over and process fields within opening and closing tags  */
    141134
    142         while (kstri=KMLFileToken(fid,
    143                                                           &ncom,&pcom)) {
    144                 if      (!strncmp(kstri,"</LinearRing",12)) {
    145                         xfree((void**)&kstri);
     135        while (kstri=KMLFileToken(fid,&ncom,&pcom)){
     136                if (!strncmp(kstri,"</LinearRing",12)){
     137                        xDelete<char>(kstri);
    146138                        break;
    147139                }
    148140                else if (!strncmp(kstri,"</",2))
    149                         _error_("KML_LinearRing::Read -- Unexpected closing tag %s.\n",kstri);
     141                  {_error2_("KML_LinearRing::Read -- Unexpected closing tag " << kstri << ".\n");}
    150142                else if (strncmp(kstri,"<",1))
    151                         _error_("KML_LinearRing::Read -- Unexpected field \"%s\".\n",kstri);
     143                  {_error2_("KML_LinearRing::Read -- Unexpected field \"" << kstri << "\".\n");}
    152144
    153145                else if (!strcmp(kstri,"<extrude>"))
    154                         KMLFileTokenParse(&extrude   ,
    155                                                           kstri,
    156                                                           fid);
     146                        KMLFileTokenParse(&extrude,kstri,fid);
    157147                else if (!strcmp(kstri,"<tessellate>"))
    158                         KMLFileTokenParse(&tessellate,
    159                                                           kstri,
    160                                                           fid);
     148                        KMLFileTokenParse(&tessellate,kstri,fid);
    161149                else if (!strcmp(kstri,"<altitudeMode>"))
    162                         KMLFileTokenParse( altmode   ,NULL,KML_LINEARRING_ALTMODE_LENGTH,
    163                                                           kstri,
    164                                                           fid);
     150                        KMLFileTokenParse(altmode,NULL,KML_LINEARRING_ALTMODE_LENGTH,kstri,fid);
    165151                else if (!strcmp(kstri,"<coordinates>"))
    166                         KMLFileTokenParse(&coords    ,&ncoord    ,0,
    167                                                           kstri,
    168                                                           fid);
    169 
     152                        KMLFileTokenParse(&coords,&ncoord,0,kstri,fid);
    170153                else if (!strncmp(kstri,"<",1))
    171154                        KML_Geometry::Read(fid,kstri);
    172155
    173                 xfree((void**)&kstri);
     156                xDelete<char>(kstri);
    174157        }
    175158
    176159        this->AddCommnt(ncom,pcom);
    177160
    178         for (ncom; ncom>0; ncom--)
    179                 xfree((void**)&(pcom[ncom-1]));
    180         xfree((void**)&pcom);
    181 
    182         return;
    183 }
    184 /*}}}*/
    185 
    186 /*FUNCTION KML_LinearRing::WriteExp {{{1*/
     161        for(ncom;ncom>0;ncom--) xDelete<char>((pcom[ncom-1]));
     162        xDelete<char*>(pcom);
     163
     164        return;
     165}
     166/*}}}*/
     167/*FUNCTION KML_LinearRing::WriteExp {{{*/
    187168void  KML_LinearRing::WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp){
    188169
     
    193174/*  extract latitude and longitude into vectors  */
    194175
    195         lat=(double *) xmalloc(ncoord*sizeof(double));
    196         lon=(double *) xmalloc(ncoord*sizeof(double));
     176        lat=xNew<double>(ncoord);
     177        lon=xNew<double>(ncoord);
    197178        for (i=0; i<ncoord; i++) {
    198                 lon[i]=coords[i][0];
    199                 lat[i]=coords[i][1];
     179                lon[i]=coords[3*i+0];
     180                lat[i]=coords[3*i+1];
    200181        }
    201182
    202183/*  convert latitude and longitude to x and y  */
    203184
    204         x  =(double *) xmalloc(ncoord*sizeof(double));
    205         y  =(double *) xmalloc(ncoord*sizeof(double));
     185        x  =xNew<double>(ncoord);
     186        y  =xNew<double>(ncoord);
    206187        Ll2xyx(x,y,lat,lon,ncoord,sgn,cm,sp);
    207188
     
    233214        fprintf(fid,"\n");
    234215
    235         xfree((void**)&y);
    236         xfree((void**)&x);
    237         xfree((void**)&lon);
    238         xfree((void**)&lat);
    239 
    240         return;
    241 }
    242 /*}}}*/
    243 
     216        xDelete<double>(y);
     217        xDelete<double>(x);
     218        xDelete<double>(lon);
     219        xDelete<double>(lat);
     220
     221        return;
     222}
     223/*}}}*/
  • issm/trunk/src/c/objects/KML/KML_LinearRing.h

    r11237 r12706  
    99
    1010/*Headers:*/
    11 /*{{{1*/
     11/*{{{*/
    1212#include "../../include/include.h"
    1313#include "../../shared/Exceptions/exceptions.h"
     
    2121        public:
    2222
    23                 bool  extrude;
    24                 bool  tessellate;
    25                 char  altmode[KML_LINEARRING_ALTMODE_LENGTH+1];
    26         int   ncoord;
    27                 double (*coords)[3];
     23                bool     extrude;
     24                bool     tessellate;
     25                char     altmode[KML_LINEARRING_ALTMODE_LENGTH+1];
     26                int      ncoord;
     27                double  *coords;
    2828
    29                 /*KML_LinearRing constructors, destructors {{{1*/
     29                /*KML_LinearRing constructors, destructors {{{*/
    3030                KML_LinearRing();
    3131                ~KML_LinearRing();
    3232                /*}}}*/
    33                 /*Object virtual functions definitions:{{{1*/
     33                /*Object virtual functions definitions:{{{*/
    3434                void  Echo();
    3535                void  DeepEcho();
     
    3838                void  Read(FILE* fid,char* kstr);
    3939                void  WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp);
    40                 int   Id(){_error_("Not implemented yet.");};
    41                 int   MyRank(){_error_("Not implemented yet.");};
    42                 void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    43                 int   MarshallSize(){_error_("Not implemented yet.");};
    44                 void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    45                 int   ObjectEnum(){_error_("Not implemented yet.");};
    46                 Object* copy(){_error_("Not implemented yet.");};
     40                int   Id(){_error2_("Not implemented yet.");};
     41                int   MyRank(){_error2_("Not implemented yet.");};
     42                void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     43                int   MarshallSize(){_error2_("Not implemented yet.");};
     44                void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     45                int   ObjectEnum(){_error2_("Not implemented yet.");};
     46                Object* copy(){_error2_("Not implemented yet.");};
    4747                /*}}}*/
    4848
  • issm/trunk/src/c/objects/KML/KML_MultiGeometry.cpp

    r11527 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*Constructors/destructor/copy*/
    23 /*FUNCTION KML_MultiGeometry::KML_MultiGeometry(){{{1*/
     23/*FUNCTION KML_MultiGeometry::KML_MultiGeometry(){{{*/
    2424KML_MultiGeometry::KML_MultiGeometry(){
    2525
     
    2828}
    2929/*}}}*/
    30 /*FUNCTION KML_MultiGeometry::~KML_MultiGeometry(){{{1*/
     30/*FUNCTION KML_MultiGeometry::~KML_MultiGeometry(){{{*/
    3131KML_MultiGeometry::~KML_MultiGeometry(){
    3232
     
    4040
    4141/*Other*/
    42 /*FUNCTION KML_MultiGeometry::Echo {{{1*/
     42/*FUNCTION KML_MultiGeometry::Echo {{{*/
    4343void  KML_MultiGeometry::Echo(){
    4444
    4545        bool  flag=true;
    4646
    47         _printf_(flag,"KML_Multigeometry:\n");
     47        if(flag) _pprintLine_("KML_Multigeometry:");
    4848        KML_Geometry::Echo();
    4949
    50         _printf_(flag,"      geometry: (size=%d)\n" ,geometry->Size());
    51 
    52         return;
    53 }
    54 /*}}}*/
    55 
    56 /*FUNCTION KML_MultiGeometry::DeepEcho {{{1*/
     50        if(flag) _pprintLine_("      geometry: (size=" << geometry->Size() << ")");
     51
     52        return;
     53}
     54/*}}}*/
     55/*FUNCTION KML_MultiGeometry::DeepEcho {{{*/
    5756void  KML_MultiGeometry::DeepEcho(){
    5857
     
    6463}
    6564/*}}}*/
    66 
    67 /*FUNCTION KML_MultiGeometry::DeepEcho {{{1*/
     65/*FUNCTION KML_MultiGeometry::DeepEcho {{{*/
    6866void  KML_MultiGeometry::DeepEcho(const char* indent){
    6967
     
    7270        bool  flag=true;
    7371
    74         _printf_(flag,"%sKML_Multigeometry:\n",indent);
     72        if(flag) _pprintLine_(indent << "KML_Multigeometry:");
    7573        KML_Geometry::DeepEcho(indent);
    7674
     
    8280        if (geometry->Size())
    8381                for (i=0; i<geometry->Size(); i++) {
    84                         _printf_(flag,"%s      geometry: -------- begin [%d] --------\n" ,indent,i);
     82                        if(flag) _pprintLine_(indent << "      geometry: -------- begin [" << i << "] --------");
    8583                        ((KML_Geometry *)geometry->GetObjectByOffset(i))->DeepEcho(indent2);
    86                         _printf_(flag,"%s      geometry: --------  end  [%d] --------\n" ,indent,i);
     84                        if(flag) _pprintLine_(indent << "      geometry: --------  end  [" << i << "] --------");
    8785                }
    8886        else
    89                 _printf_(flag,"%s      geometry: [empty]\n"    ,indent);
    90 
    91         return;
    92 }
    93 /*}}}*/
    94 
    95 /*FUNCTION KML_MultiGeometry::Write {{{1*/
     87                if(flag) _pprintLine_(indent << "      geometry: [empty]");
     88
     89        return;
     90}
     91/*}}}*/
     92/*FUNCTION KML_MultiGeometry::Write {{{*/
    9693void  KML_MultiGeometry::Write(FILE* filout,const char* indent){
    9794
     
    120117}
    121118/*}}}*/
    122 
    123 /*FUNCTION KML_MultiGeometry::Read {{{1*/
     119/*FUNCTION KML_MultiGeometry::Read {{{*/
    124120void  KML_MultiGeometry::Read(FILE* fid,char* kstr){
    125121
     
    144140                }
    145141                else if (!strncmp(kstri,"</",2))
    146                         _error_("KML_MultiGeometry::Read -- Unexpected closing tag %s.\n",kstri);
     142                  {_error2_("KML_MultiGeometry::Read -- Unexpected closing tag " << kstri << ".\n");}
    147143                else if (strncmp(kstri,"<",1))
    148                         _error_("KML_MultiGeometry::Read -- Unexpected field \"%s\".\n",kstri);
     144                  {_error2_("KML_MultiGeometry::Read -- Unexpected field \"" << kstri << "\".\n");}
    149145
    150146                else if (!strncmp(kstri,"<Point", 6)) {
     
    193189}
    194190/*}}}*/
    195 
    196 /*FUNCTION KML_MultiGeometry::WriteExp {{{1*/
     191/*FUNCTION KML_MultiGeometry::WriteExp {{{*/
    197192void  KML_MultiGeometry::WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp){
    198193
     
    207202}
    208203/*}}}*/
    209 
  • issm/trunk/src/c/objects/KML/KML_MultiGeometry.h

    r11237 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "../../include/include.h"
    1111#include "../../shared/Exceptions/exceptions.h"
     
    2323                DataSet* geometry;
    2424
    25                 /*KML_MultiGeometry constructors, destructors {{{1*/
     25                /*KML_MultiGeometry constructors, destructors {{{*/
    2626                KML_MultiGeometry();
    2727                ~KML_MultiGeometry();
    2828                /*}}}*/
    29                 /*Object virtual functions definitions:{{{1*/
     29                /*Object virtual functions definitions:{{{*/
    3030                void  Echo();
    3131                void  DeepEcho();
     
    3434                void  Read(FILE* fid,char* kstr);
    3535                void  WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp);
    36                 int   Id(){_error_("Not implemented yet.");};
    37                 int   MyRank(){_error_("Not implemented yet.");};
    38                 void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    39                 int   MarshallSize(){_error_("Not implemented yet.");};
    40                 void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    41                 int   ObjectEnum(){_error_("Not implemented yet.");};
    42                 Object* copy(){_error_("Not implemented yet.");};
     36                int   Id(){_error2_("Not implemented yet.");};
     37                int   MyRank(){_error2_("Not implemented yet.");};
     38                void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     39                int   MarshallSize(){_error2_("Not implemented yet.");};
     40                void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     41                int   ObjectEnum(){_error2_("Not implemented yet.");};
     42                Object* copy(){_error2_("Not implemented yet.");};
    4343                /*}}}*/
    4444
  • issm/trunk/src/c/objects/KML/KML_Object.cpp

    r11527 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*Constructors/destructor/copy*/
    23 /*FUNCTION KML_Object::KML_Object(){{{1*/
     23/*FUNCTION KML_Object::KML_Object(){{{*/
    2424KML_Object::KML_Object(){
    2525
     
    3030}
    3131/*}}}*/
    32 /*FUNCTION KML_Object::~KML_Object(){{{1*/
     32/*FUNCTION KML_Object::~KML_Object(){{{*/
    3333KML_Object::~KML_Object(){
    3434
     
    5050
    5151/*Other*/
    52 /*FUNCTION KML_Object::Echo {{{1*/
     52/*FUNCTION KML_Object::Echo {{{*/
    5353void  KML_Object::Echo(){
    5454
    5555        bool  flag=true;
    5656
    57         _printf_(flag,"        attrib: (size=%d)\n" ,attrib->Size());
    58         _printf_(flag,"        commnt: (size=%d)\n" ,commnt->Size());
    59         _printf_(flag,"        kmlobj: (size=%d)\n" ,kmlobj->Size());
    60 
    61         return;
    62 }
    63 /*}}}*/
    64 /*FUNCTION KML_Object::DeepEcho {{{1*/
     57        if(flag) _pprintLine_("        attrib: (size=" << attrib->Size() << ")");
     58        if(flag) _pprintLine_("        commnt: (size=" << commnt->Size() << ")");
     59        if(flag) _pprintLine_("        kmlobj: (size=" << kmlobj->Size() << ")");
     60
     61        return;
     62}
     63/*}}}*/
     64/*FUNCTION KML_Object::DeepEcho {{{*/
    6565void  KML_Object::DeepEcho(){
    6666
     
    7272}
    7373/*}}}*/
    74 /*FUNCTION KML_Object::DeepEcho {{{1*/
     74/*FUNCTION KML_Object::DeepEcho {{{*/
    7575void  KML_Object::DeepEcho(const char* indent){
    7676
     
    8686                }
    8787        else
    88                 _printf_(flag,"%s        attrib: [empty]\n"    ,indent);
     88                if(flag) _pprintLine_(indent << "        attrib: [empty]");
    8989
    9090/*  loop over the comments for the object  */
     
    9595                }
    9696        else
    97                 _printf_(flag,"%s        commnt: [empty]\n"    ,indent);
     97                if(flag) _pprintLine_(indent << "        commnt: [empty]");
    9898
    9999/*  loop over the unknown objects for the object  */
     
    104104        if (kmlobj->Size())
    105105                for (i=0; i<kmlobj->Size(); i++) {
    106             _printf_(flag,"%s        kmlobj: -------- begin [%d] --------\n" ,indent,i);
     106            if(flag) _pprintLine_(indent << "        kmlobj: -------- begin [" << i << "] --------");
    107107                        ((KML_Unknown *)kmlobj->GetObjectByOffset(i))->DeepEcho(indent2);
    108             _printf_(flag,"%s        kmlobj: --------  end  [%d] --------\n" ,indent,i);
     108            if(flag) _pprintLine_(indent << "        kmlobj: --------  end  [" << i << "] --------");
    109109                }
    110110        else
    111                 _printf_(flag,"%s        kmlobj: [empty]\n"    ,indent);
    112 
    113         return;
    114 }
    115 /*}}}*/
    116 /*FUNCTION KML_Object::Write {{{1*/
     111                if(flag) _pprintLine_(indent << "        kmlobj: [empty]");
     112
     113        return;
     114}
     115/*}}}*/
     116/*FUNCTION KML_Object::Write {{{*/
    117117void  KML_Object::Write(FILE* filout,const char* indent){
    118118
     
    136136}
    137137/*}}}*/
    138 /*FUNCTION KML_Object::Read {{{1*/
     138/*FUNCTION KML_Object::Read {{{*/
    139139void  KML_Object::Read(FILE* fid,char* kstr){
    140140
     
    146146                return;
    147147        else if (!strncmp(kstr,"</",2))
    148                 _error_("KML_Object::Read -- Unexpected closing tag %s.\n",kstr);
     148          {_error2_("KML_Object::Read -- Unexpected closing tag " << kstr << ".\n");}
    149149        else if (strncmp(kstr,"<",1))
    150                 _error_("KML_Object::Read -- Unexpected field \"%s\".\n",kstr);
     150          {_error2_("KML_Object::Read -- Unexpected field \"" << kstr << "\".\n");}
    151151
    152152        else if (!strncmp(kstr,"<Placemark",10)) {
     
    253253
    254254        else if (!strncmp(kstr,"<",1)) {
    255                 _printf_(true,"KML_Object::Read -- Unrecognized opening tag %s.\n",kstr);
     255                _pprintLine_("KML_Object::Read -- Unrecognized opening tag " << kstr << ".");
    256256//              KMLFileTagSkip(kstr,
    257257//                                         fid);
     
    264264}
    265265/*}}}*/
    266 /*FUNCTION KML_Object::WriteExp {{{1*/
     266/*FUNCTION KML_Object::WriteExp {{{*/
    267267void  KML_Object::WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp){
    268268
     
    272272}
    273273/*}}}*/
    274 /*FUNCTION KML_Object::AddAttrib {{{1*/
     274/*FUNCTION KML_Object::AddAttrib {{{*/
    275275void  KML_Object::AddAttrib(const char* name,const char* value){
    276276
     
    284284}
    285285/*}}}*/
    286 /*FUNCTION KML_Object::FindAttrib {{{1*/
     286/*FUNCTION KML_Object::FindAttrib {{{*/
    287287void  KML_Object::FindAttrib(char** pvalue,char* name,char* deflt){
    288288
     
    311311}
    312312/*}}}*/
    313 /*FUNCTION KML_Object::WriteAttrib {{{1*/
     313/*FUNCTION KML_Object::WriteAttrib {{{*/
    314314void  KML_Object::WriteAttrib(FILE* filout,const char* indent){
    315315
     
    325325}
    326326/*}}}*/
    327 /*FUNCTION KML_Object::AddCommnt {{{1*/
     327/*FUNCTION KML_Object::AddCommnt {{{*/
    328328void  KML_Object::AddCommnt(int ncom,char** pcom){
    329329
     
    340340}
    341341/*}}}*/
    342 /*FUNCTION KML_Object::AddCommnt {{{1*/
     342/*FUNCTION KML_Object::AddCommnt {{{*/
    343343void  KML_Object::AddCommnt(char* value){
    344344
     
    352352}
    353353/*}}}*/
    354 /*FUNCTION KML_Object::FindCommnt {{{1*/
     354/*FUNCTION KML_Object::FindCommnt {{{*/
    355355void  KML_Object::FindCommnt(char** pvalue,int inum){
    356356
     
    370370}
    371371/*}}}*/
    372 /*FUNCTION KML_Object::WriteCommnt {{{1*/
     372/*FUNCTION KML_Object::WriteCommnt {{{*/
    373373void  KML_Object::WriteCommnt(FILE* filout,const char* indent){
    374374
  • issm/trunk/src/c/objects/KML/KML_Object.h

    r11527 r12706  
    66#define _KML_OBJECT_H_
    77
    8 /*Headers:{{{1*/
     8/*Headers:{{{*/
    99#include "../../include/include.h"
    1010#include "../../shared/Exceptions/exceptions.h"
     
    2323                DataSet* kmlobj;
    2424
    25                 /*KML_Object constructors, destructors {{{1*/
     25                /*KML_Object constructors, destructors {{{*/
    2626                KML_Object();
    2727                ~KML_Object();
    2828                /*}}}*/
    29                 /*Object virtual functions definitions:{{{1*/
     29                /*Object virtual functions definitions:{{{*/
    3030                virtual void  Echo();
    3131                virtual void  DeepEcho();
    3232                virtual void  DeepEcho(const char* indent);
    33                 int   Id(){_error_("Not implemented yet.");};
    34                 int   MyRank(){_error_("Not implemented yet.");};
    35                 void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    36                 int   MarshallSize(){_error_("Not implemented yet.");};
    37                 void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    38                 int   ObjectEnum(){_error_("Not implemented yet.");};
    39                 Object* copy(){_error_("Not implemented yet.");};
     33                int   Id(){_error2_("Not implemented yet.");};
     34                int   MyRank(){_error2_("Not implemented yet.");};
     35                void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     36                int   MarshallSize(){_error2_("Not implemented yet.");};
     37                void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     38                int   ObjectEnum(){_error2_("Not implemented yet.");};
     39                Object* copy(){_error2_("Not implemented yet.");};
    4040                /*}}}*/
    4141
  • issm/trunk/src/c/objects/KML/KML_Overlay.cpp

    r11527 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*Constructors/destructor/copy*/
    23 /*FUNCTION KML_Overlay::KML_Overlay(){{{1*/
     23/*FUNCTION KML_Overlay::KML_Overlay(){{{*/
    2424KML_Overlay::KML_Overlay(){
    2525
     
    3232}
    3333/*}}}*/
    34 /*FUNCTION KML_Overlay::~KML_Overlay(){{{1*/
     34/*FUNCTION KML_Overlay::~KML_Overlay(){{{*/
    3535KML_Overlay::~KML_Overlay(){
    3636
     
    4444
    4545/*Other*/
    46 /*FUNCTION KML_Overlay::Echo {{{1*/
     46/*FUNCTION KML_Overlay::Echo {{{*/
    4747void  KML_Overlay::Echo(){
    4848
    49         bool  flag=true;
    50 
    5149        KML_Feature::Echo();
    52 
    53         _printf_(flag,"         color: \"%s\"\n" ,color);
    54         _printf_(flag,"       draword: %d\n"     ,draword);
    55         _printf_(flag,"          icon: %p\n"     ,icon);
    56 
    57         return;
     50        _pprintLine_("         color: \"" << color << "\"");
     51        _pprintLine_("       draword: " << draword);
     52        _pprintLine_("          icon: " << icon);
    5853}
    5954/*}}}*/
    60 
    61 /*FUNCTION KML_Overlay::DeepEcho {{{1*/
     55/*FUNCTION KML_Overlay::DeepEcho {{{*/
    6256void  KML_Overlay::DeepEcho(){
    6357
     
    6963}
    7064/*}}}*/
    71 
    72 /*FUNCTION KML_Overlay::DeepEcho {{{1*/
     65/*FUNCTION KML_Overlay::DeepEcho {{{*/
    7366void  KML_Overlay::DeepEcho(const char* indent){
    7467
    7568        char  indent2[81];
    76         bool  flag=true;
    77 
    7869        KML_Feature::DeepEcho(indent);
    7970
     
    8172        strcat(indent2,"  ");
    8273
    83         _printf_(flag,"%s         color: %s\n"          ,indent,color);
    84         _printf_(flag,"%s       draword: %d\n"          ,indent,draword);
     74        _pprintLine_(indent << "         color: " << color);
     75        _pprintLine_(indent << "       draword: " << draword);
    8576        if (icon)
    8677                icon->DeepEcho(indent2);
    8778        else
    88                 _printf_(flag,"%s          icon: %p\n"          ,indent,icon);
    89 
    90         return;
     79                _pprintLine_(indent << "          icon: " << icon);
    9180}
    9281/*}}}*/
    93 
    94 /*FUNCTION KML_Overlay::Write {{{1*/
     82/*FUNCTION KML_Overlay::Write {{{*/
    9583void  KML_Overlay::Write(FILE* filout,const char* indent){
    9684
     
    112100}
    113101/*}}}*/
    114 
    115 /*FUNCTION KML_Overlay::Read {{{1*/
     102/*FUNCTION KML_Overlay::Read {{{*/
    116103void  KML_Overlay::Read(FILE* fid,char* kstr){
    117104
     
    123110        }
    124111        else if (!strncmp(kstr,"</",2))
    125                 _error_("KML_Overlay::Read -- Unexpected closing tag %s.\n",kstr);
     112          {_error2_("KML_Overlay::Read -- Unexpected closing tag " << kstr << ".\n");}
    126113        else if (strncmp(kstr,"<",1))
    127                 _error_("KML_Overlay::Read -- Unexpected field \"%s\".\n",kstr);
     114          {_error2_("KML_Overlay::Read -- Unexpected field \"" << kstr << "\".\n");}
    128115
    129116        else if (!strcmp(kstr,"<color>"))
     
    147134}
    148135/*}}}*/
    149 
  • issm/trunk/src/c/objects/KML/KML_Overlay.h

    r11237 r12706  
    99
    1010/*Headers:*/
    11 /*{{{1*/
     11/*{{{*/
    1212#include "../../include/include.h"
    1313#include "../../shared/Exceptions/exceptions.h"
     
    2626                KML_Icon* icon;
    2727
    28                 /*KML_Overlay constructors, destructors {{{1*/
     28                /*KML_Overlay constructors, destructors {{{*/
    2929                KML_Overlay();
    3030                ~KML_Overlay();
    3131                /*}}}*/
    32                 /*Object virtual functions definitions:{{{1*/
     32                /*Object virtual functions definitions:{{{*/
    3333                void  Echo();
    3434                void  DeepEcho();
     
    3636                void  Write(FILE* fid,const char* indent);
    3737                void  Read(FILE* fid,char* kstr);
    38                 int   Id(){_error_("Not implemented yet.");};
    39                 int   MyRank(){_error_("Not implemented yet.");};
    40                 void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    41                 int   MarshallSize(){_error_("Not implemented yet.");};
    42                 void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    43                 int   ObjectEnum(){_error_("Not implemented yet.");};
    44                 Object* copy(){_error_("Not implemented yet.");};
     38                int   Id(){_error2_("Not implemented yet.");};
     39                int   MyRank(){_error2_("Not implemented yet.");};
     40                void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     41                int   MarshallSize(){_error2_("Not implemented yet.");};
     42                void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     43                int   ObjectEnum(){_error2_("Not implemented yet.");};
     44                Object* copy(){_error2_("Not implemented yet.");};
    4545                /*}}}*/
    4646
  • issm/trunk/src/c/objects/KML/KML_Placemark.cpp

    r11527 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*Constructors/destructor/copy*/
    23 /*FUNCTION KML_Placemark::KML_Placemark(){{{1*/
     23/*FUNCTION KML_Placemark::KML_Placemark(){{{*/
    2424KML_Placemark::KML_Placemark(){
    2525
     
    2828}
    2929/*}}}*/
    30 /*FUNCTION KML_Placemark::~KML_Placemark(){{{1*/
     30/*FUNCTION KML_Placemark::~KML_Placemark(){{{*/
    3131KML_Placemark::~KML_Placemark(){
    3232
     
    4040
    4141/*Other*/
    42 /*FUNCTION KML_Placemark::Echo {{{1*/
     42/*FUNCTION KML_Placemark::Echo {{{*/
    4343void  KML_Placemark::Echo(){
    4444
    4545        bool  flag=true;
    4646
    47         _printf_(flag,"KML_Placemark:\n");
     47        if(flag) _pprintLine_("KML_Placemark:");
    4848        KML_Feature::Echo();
    4949
    50         _printf_(flag,"      geometry: (size=%d)\n" ,geometry->Size());
    51 
    52         return;
    53 }
    54 /*}}}*/
    55 /*FUNCTION KML_Placemark::DeepEcho {{{1*/
     50        if(flag) _pprintLine_("      geometry: (size=" << geometry->Size() << ")");
     51
     52        return;
     53}
     54/*}}}*/
     55/*FUNCTION KML_Placemark::DeepEcho {{{*/
    5656void  KML_Placemark::DeepEcho(){
    5757
     
    6363}
    6464/*}}}*/
    65 /*FUNCTION KML_Placemark::DeepEcho {{{1*/
     65/*FUNCTION KML_Placemark::DeepEcho {{{*/
    6666void  KML_Placemark::DeepEcho(const char* indent){
    6767
     
    7070        bool  flag=true;
    7171
    72         _printf_(flag,"%sKML_Placemark:\n",indent);
     72        if(flag) _pprintLine_(indent << "KML_Placemark:");
    7373        KML_Feature::DeepEcho(indent);
    7474
     
    8080        if (geometry->Size())
    8181                for (i=0; i<geometry->Size(); i++) {
    82                         _printf_(flag,"%s      geometry: -------- begin [%d] --------\n" ,indent,i);
     82                        if(flag) _pprintLine_(indent << "      geometry: -------- begin [" << i << "] --------");
    8383                        ((KML_Geometry *)geometry->GetObjectByOffset(i))->DeepEcho(indent2);
    84                         _printf_(flag,"%s      geometry: --------  end  [%d] --------\n" ,indent,i);
     84                        if(flag) _pprintLine_(indent << "      geometry: --------  end  [" << i << "] --------");
    8585                }
    8686        else
    87                 _printf_(flag,"%s      geometry: [empty]\n"    ,indent);
    88 
    89         return;
    90 }
    91 /*}}}*/
    92 /*FUNCTION KML_Placemark::Write {{{1*/
     87                if(flag) _pprintLine_(indent << "      geometry: [empty]");
     88
     89        return;
     90}
     91/*}}}*/
     92/*FUNCTION KML_Placemark::Write {{{*/
    9393void  KML_Placemark::Write(FILE* filout,const char* indent){
    9494
     
    117117}
    118118/*}}}*/
    119 /*FUNCTION KML_Placemark::Read {{{1*/
     119/*FUNCTION KML_Placemark::Read {{{*/
    120120void  KML_Placemark::Read(FILE* fid,char* kstr){
    121121
     
    140140                }
    141141                else if (!strncmp(kstri,"</",2))
    142                         _error_("KML_Placemark::Read -- Unexpected closing tag %s.\n",kstri);
     142                  {_error2_("KML_Placemark::Read -- Unexpected closing tag " << kstri << ".\n");}
    143143                else if (strncmp(kstri,"<",1))
    144                         _error_("KML_Placemark::Read -- Unexpected field \"%s\".\n",kstri);
     144                  {_error2_("KML_Placemark::Read -- Unexpected field \"" << kstri << "\".\n");}
    145145
    146146                else if (!strncmp(kstri,"<Point", 6)) {
     
    189189}
    190190/*}}}*/
    191 /*FUNCTION KML_Placemark::WriteExp {{{1*/
     191/*FUNCTION KML_Placemark::WriteExp {{{*/
    192192void  KML_Placemark::WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp){
    193193
  • issm/trunk/src/c/objects/KML/KML_Placemark.h

    r11237 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "../../include/include.h"
    1111#include "../../shared/Exceptions/exceptions.h"
     
    2323                DataSet* geometry;
    2424
    25                 /*KML_Placemark constructors, destructors {{{1*/
     25                /*KML_Placemark constructors, destructors {{{*/
    2626                KML_Placemark();
    2727                ~KML_Placemark();
    2828                /*}}}*/
    29                 /*Object virtual functions definitions:{{{1*/
     29                /*Object virtual functions definitions:{{{*/
    3030                void  Echo();
    3131                void  DeepEcho();
     
    3434                void  Read(FILE* fid,char* kstr);
    3535                void  WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp);
    36                 int   Id(){_error_("Not implemented yet.");};
    37                 int   MyRank(){_error_("Not implemented yet.");};
    38                 void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    39                 int   MarshallSize(){_error_("Not implemented yet.");};
    40                 void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    41                 int   ObjectEnum(){_error_("Not implemented yet.");};
    42                 Object* copy(){_error_("Not implemented yet.");};
     36                int   Id(){_error2_("Not implemented yet.");};
     37                int   MyRank(){_error2_("Not implemented yet.");};
     38                void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     39                int   MarshallSize(){_error2_("Not implemented yet.");};
     40                void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     41                int   ObjectEnum(){_error2_("Not implemented yet.");};
     42                Object* copy(){_error2_("Not implemented yet.");};
    4343                /*}}}*/
    4444
  • issm/trunk/src/c/objects/KML/KML_Point.cpp

    r11237 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2222
    2323/*Constructors/destructor/copy*/
    24 /*FUNCTION KML_Point::KML_Point(){{{1*/
     24/*FUNCTION KML_Point::KML_Point(){{{*/
    2525KML_Point::KML_Point(){
    2626
     
    3434}
    3535/*}}}*/
    36 /*FUNCTION KML_Point::~KML_Point(){{{1*/
     36/*FUNCTION KML_Point::~KML_Point(){{{*/
    3737KML_Point::~KML_Point(){
    3838
     
    4343
    4444/*Other*/
    45 /*FUNCTION KML_Point::Echo {{{1*/
     45/*FUNCTION KML_Point::Echo {{{*/
    4646void  KML_Point::Echo(){
    4747
    4848        bool  flag=true;
    4949
    50         _printf_(flag,"KML_Point:\n");
     50        if(flag) _pprintLine_("KML_Point:");
    5151        KML_Geometry::Echo();
    5252
    53         _printf_(flag,"       extrude: %s\n"         ,(extrude ? "true" : "false"));
    54         _printf_(flag,"       altmode: \"%s\"\n"     ,altmode);
    55         _printf_(flag,"        coords: (%g,%g,%g)\n" ,coords[0],coords[1],coords[2]);
     53        if(flag) _pprintLine_("       extrude: " << (extrude ? "true" : "false"));
     54        if(flag) _pprintLine_("       altmode: \"" << altmode << "\"");
     55        if(flag) _pprintLine_("        coords: (" << coords[0] << "," << coords[1] << "," << coords[2] << ")");
    5656
    5757        return;
    5858}
    5959/*}}}*/
    60 /*FUNCTION KML_Point::DeepEcho {{{1*/
     60/*FUNCTION KML_Point::DeepEcho {{{*/
    6161void  KML_Point::DeepEcho(){
    6262
     
    6868}
    6969/*}}}*/
    70 /*FUNCTION KML_Point::DeepEcho {{{1*/
     70/*FUNCTION KML_Point::DeepEcho {{{*/
    7171void  KML_Point::DeepEcho(const char* indent){
    7272
    7373        bool  flag=true;
    7474
    75         _printf_(flag,"%sKML_Point:\n",indent);
     75        if(flag) _pprintLine_(indent << "KML_Point:");
    7676        KML_Geometry::DeepEcho(indent);
    7777
    78         _printf_(flag,"%s       extrude: %s\n"         ,indent,(extrude ? "true" : "false"));
    79         _printf_(flag,"%s       altmode: \"%s\"\n"     ,indent,altmode);
    80         _printf_(flag,"%s        coords: (%g,%g,%g)\n" ,indent,coords[0],coords[1],coords[2]);
     78        if(flag) _pprintLine_(indent << "       extrude: " << (extrude ? "true" : "false"));
     79        if(flag) _pprintLine_(indent << "       altmode: \"" << altmode << "\"");
     80        if(flag) _pprintLine_(indent << "        coords: (" << coords[0] << "," << coords[1] << "," << coords[2] << ")");
    8181
    8282        return;
    8383}
    8484/*}}}*/
    85 /*FUNCTION KML_Point::Write {{{1*/
     85/*FUNCTION KML_Point::Write {{{*/
    8686void  KML_Point::Write(FILE* filout,const char* indent){
    8787
     
    103103}
    104104/*}}}*/
    105 /*FUNCTION KML_Point::Read {{{1*/
     105/*FUNCTION KML_Point::Read {{{*/
    106106void  KML_Point::Read(FILE* fid,char* kstr){
    107107
     
    126126                }
    127127                else if (!strncmp(kstri,"</",2))
    128                         _error_("KML_Point::Read -- Unexpected closing tag %s.\n",kstri);
     128                  {_error2_("KML_Point::Read -- Unexpected closing tag " << kstri << ".\n");}
    129129                else if (strncmp(kstri,"<",1))
    130                         _error_("KML_Point::Read -- Unexpected field \"%s\".\n",kstri);
     130                  {_error2_("KML_Point::Read -- Unexpected field \"" << kstri << "\".\n");}
    131131
    132132                else if (!strcmp(kstri,"<extrude>"))
    133                         KMLFileTokenParse(&extrude   ,
    134                                                           kstri,
    135                                                           fid);
     133                        KMLFileTokenParse(&extrude   , kstri, fid);
    136134                else if (!strcmp(kstri,"<altitudeMode>"))
    137                         KMLFileTokenParse( altmode   ,NULL,KML_POINT_ALTMODE_LENGTH,
    138                                                           kstri,
    139                                                           fid);
     135                        KMLFileTokenParse( altmode   ,NULL,KML_POINT_ALTMODE_LENGTH, kstri, fid);
    140136                else if (!strcmp(kstri,"<coordinates>"))
    141                         KMLFileTokenParse(&pcoords   ,NULL,3,
    142                                                           kstri,
    143                                                           fid);
     137                        KMLFileTokenParse(&pcoords   ,NULL,3, kstri, fid);
    144138
    145139                else if (!strncmp(kstri,"<",1))
     
    158152}
    159153/*}}}*/
    160 /*FUNCTION KML_Point::WriteExp {{{1*/
     154/*FUNCTION KML_Point::WriteExp {{{*/
    161155void  KML_Point::WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp){
    162156
  • issm/trunk/src/c/objects/KML/KML_Point.h

    r11237 r12706  
    99
    1010/*Headers:*/
    11 /*{{{1*/
     11/*{{{*/
    1212#include "../../include/include.h"
    1313#include "../../shared/Exceptions/exceptions.h"
     
    2525                double coords[3];
    2626
    27                 /*KML_Point constructors, destructors {{{1*/
     27                /*KML_Point constructors, destructors {{{*/
    2828                KML_Point();
    2929                ~KML_Point();
    3030                /*}}}*/
    31                 /*Object virtual functions definitions:{{{1*/
     31                /*Object virtual functions definitions:{{{*/
    3232                void  Echo();
    3333                void  DeepEcho();
     
    3636                void  Read(FILE* fid,char* kstr);
    3737                void  WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp);
    38                 int   Id(){_error_("Not implemented yet.");};
    39                 int   MyRank(){_error_("Not implemented yet.");};
    40                 void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    41                 int   MarshallSize(){_error_("Not implemented yet.");};
    42                 void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    43                 int   ObjectEnum(){_error_("Not implemented yet.");};
    44                 Object* copy(){_error_("Not implemented yet.");};
     38                int   Id(){_error2_("Not implemented yet.");};
     39                int   MyRank(){_error2_("Not implemented yet.");};
     40                void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     41                int   MarshallSize(){_error2_("Not implemented yet.");};
     42                void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     43                int   ObjectEnum(){_error2_("Not implemented yet.");};
     44                Object* copy(){_error2_("Not implemented yet.");};
    4545                /*}}}*/
    4646
  • issm/trunk/src/c/objects/KML/KML_PolyStyle.cpp

    r11237 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*Constructors/destructor/copy*/
    23 /*FUNCTION KML_PolyStyle::KML_PolyStyle(){{{1*/
     23/*FUNCTION KML_PolyStyle::KML_PolyStyle(){{{*/
    2424KML_PolyStyle::KML_PolyStyle(){
    2525
     
    2929}
    3030/*}}}*/
    31 /*FUNCTION KML_PolyStyle::~KML_PolyStyle(){{{1*/
     31/*FUNCTION KML_PolyStyle::~KML_PolyStyle(){{{*/
    3232KML_PolyStyle::~KML_PolyStyle(){
    3333
     
    3838
    3939/*Other*/
    40 /*FUNCTION KML_PolyStyle::Echo {{{1*/
     40/*FUNCTION KML_PolyStyle::Echo {{{*/
    4141void  KML_PolyStyle::Echo(){
    4242
    4343        bool  flag=true;
    4444
    45         _printf_(flag,"KML_PolyStyle:\n");
     45        if(flag) _pprintLine_("KML_PolyStyle:");
    4646        KML_ColorStyle::Echo();
    4747
    48         _printf_(flag,"          fill: %d\n"          ,fill);
    49         _printf_(flag,"       outline: %d\n"          ,outline);
     48        if(flag) _pprintLine_("          fill: " << fill);
     49        if(flag) _pprintLine_("       outline: " << outline);
    5050
    5151        return;
    5252}
    5353/*}}}*/
    54 
    55 /*FUNCTION KML_PolyStyle::DeepEcho {{{1*/
     54/*FUNCTION KML_PolyStyle::DeepEcho {{{*/
    5655void  KML_PolyStyle::DeepEcho(){
    5756
     
    6362}
    6463/*}}}*/
    65 
    66 /*FUNCTION KML_PolyStyle::DeepEcho {{{1*/
     64/*FUNCTION KML_PolyStyle::DeepEcho {{{*/
    6765void  KML_PolyStyle::DeepEcho(const char* indent){
    6866
     
    7068        bool  flag=true;
    7169
    72         _printf_(flag,"%sKML_PolyStyle:\n",indent);
     70        if(flag) _pprintLine_(indent << "KML_PolyStyle:");
    7371        KML_ColorStyle::DeepEcho(indent);
    7472
    75         _printf_(flag,"%s          fill: %d\n"          ,indent,fill);
    76         _printf_(flag,"%s       outline: %d\n"          ,indent,outline);
     73        if(flag) _pprintLine_(indent << "          fill: " << fill);
     74        if(flag) _pprintLine_(indent << "       outline: " << outline);
    7775
    7876        return;
    7977}
    8078/*}}}*/
    81 
    82 /*FUNCTION KML_PolyStyle::Write {{{1*/
     79/*FUNCTION KML_PolyStyle::Write {{{*/
    8380void  KML_PolyStyle::Write(FILE* filout,const char* indent){
    8481
     
    9895}
    9996/*}}}*/
    100 
    101 /*FUNCTION KML_PolyStyle::Read {{{1*/
     97/*FUNCTION KML_PolyStyle::Read {{{*/
    10298void  KML_PolyStyle::Read(FILE* fid,char* kstr){
    10399
     
    121117                }
    122118                else if (!strncmp(kstri,"</",2))
    123                         _error_("KML_PolyStyle::Read -- Unexpected closing tag %s.\n",kstri);
     119                  {_error2_("KML_PolyStyle::Read -- Unexpected closing tag " << kstri << ".\n");}
    124120                else if (strncmp(kstri,"<",1))
    125                         _error_("KML_PolyStyle::Read -- Unexpected field \"%s\".\n",kstri);
     121                  {_error2_("KML_PolyStyle::Read -- Unexpected field \"" << kstri << "\".\n");}
    126122
    127123                else if (!strcmp(kstri,"<fill>"))
     
    149145}
    150146/*}}}*/
    151 
  • issm/trunk/src/c/objects/KML/KML_PolyStyle.h

    r11237 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "../../include/include.h"
    1111#include "../../shared/Exceptions/exceptions.h"
     
    2222                int   outline;
    2323
    24                 /*KML_PolyStyle constructors, destructors {{{1*/
     24                /*KML_PolyStyle constructors, destructors {{{*/
    2525                KML_PolyStyle();
    2626                ~KML_PolyStyle();
    2727                /*}}}*/
    28                 /*Object virtual functions definitions:{{{1 */
     28                /*Object virtual functions definitions:{{{ */
    2929                void  Echo();
    3030                void  DeepEcho();
     
    3232                void  Write(FILE* fid,const char* indent);
    3333                void  Read(FILE* fid,char* kstr);
    34                 int   Id(){_error_("Not implemented yet.");};
    35                 int   MyRank(){_error_("Not implemented yet.");};
    36                 void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    37                 int   MarshallSize(){_error_("Not implemented yet.");};
    38                 void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    39                 int   ObjectEnum(){_error_("Not implemented yet.");};
    40                 Object* copy(){_error_("Not implemented yet.");};
     34                int   Id(){_error2_("Not implemented yet.");};
     35                int   MyRank(){_error2_("Not implemented yet.");};
     36                void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     37                int   MarshallSize(){_error2_("Not implemented yet.");};
     38                void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     39                int   ObjectEnum(){_error2_("Not implemented yet.");};
     40                Object* copy(){_error2_("Not implemented yet.");};
    4141                /*}}}*/
    4242
  • issm/trunk/src/c/objects/KML/KML_Polygon.cpp

    r11527 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*Constructors/destructor/copy*/
    23 /*FUNCTION KML_Polygon::KML_Polygon(){{{1*/
     23/*FUNCTION KML_Polygon::KML_Polygon(){{{*/
    2424KML_Polygon::KML_Polygon(){
    2525
     
    3333}
    3434/*}}}*/
    35 /*FUNCTION KML_Polygon::~KML_Polygon(){{{1*/
     35/*FUNCTION KML_Polygon::~KML_Polygon(){{{*/
    3636KML_Polygon::~KML_Polygon(){
    3737
     
    5050
    5151/*Other*/
    52 /*FUNCTION KML_Polygon::Echo {{{1*/
     52/*FUNCTION KML_Polygon::Echo {{{*/
    5353void  KML_Polygon::Echo(){
    5454
    5555        bool  flag=true;
    5656
    57         _printf_(flag,"KML_Polygon:\n");
     57        if(flag) _pprintLine_("KML_Polygon:");
    5858        KML_Geometry::Echo();
    5959
    60         _printf_(flag,"       extrude: %s\n"          ,(extrude ? "true" : "false"));
    61         _printf_(flag,"    tessellate: %s\n"          ,(tessellate ? "true" : "false"));
    62         _printf_(flag,"       altmode: \"%s\"\n"      ,altmode);
    63         _printf_(flag,"         outer: (size=%d)\n"   ,outer->Size());
    64         _printf_(flag,"         inner: (size=%d)\n"   ,inner->Size());
    65 
    66         return;
    67 }
    68 /*}}}*/
    69 /*FUNCTION KML_Polygon::DeepEcho {{{1*/
     60        if(flag) _pprintLine_("       extrude: " << (extrude ? "true" : "false"));
     61        if(flag) _pprintLine_("    tessellate: " << (tessellate ? "true" : "false"));
     62        if(flag) _pprintLine_("       altmode: \"" << altmode << "\"");
     63        if(flag) _pprintLine_("         outer: (size=" << outer->Size() << ")");
     64        if(flag) _pprintLine_("         inner: (size=" << inner->Size() << ")");
     65
     66        return;
     67}
     68/*}}}*/
     69/*FUNCTION KML_Polygon::DeepEcho {{{*/
    7070void  KML_Polygon::DeepEcho(){
    7171
     
    7777}
    7878/*}}}*/
    79 /*FUNCTION KML_Polygon::DeepEcho {{{1*/
     79/*FUNCTION KML_Polygon::DeepEcho {{{*/
    8080void  KML_Polygon::DeepEcho(const char* indent){
    8181
     
    8484        bool  flag=true;
    8585
    86         _printf_(flag,"%sKML_Polygon:\n",indent);
     86        if(flag) _pprintLine_(indent << "KML_Polygon:");
    8787        KML_Geometry::DeepEcho(indent);
    8888
    89         _printf_(flag,"%s       extrude: %s\n"          ,indent,(extrude ? "true" : "false"));
    90         _printf_(flag,"%s    tessellate: %s\n"          ,indent,(tessellate ? "true" : "false"));
    91         _printf_(flag,"%s       altmode: \"%s\"\n"      ,indent,altmode);
     89        if(flag) _pprintLine_(indent << "       extrude: " << (extrude ? "true" : "false"));
     90        if(flag) _pprintLine_(indent << "    tessellate: " << (tessellate ? "true" : "false"));
     91        if(flag) _pprintLine_(indent << "       altmode: \"" << altmode << "\"");
    9292
    9393        memcpy(indent2,indent,(strlen(indent)+1)*sizeof(char));
     
    9696        if (outer->Size())
    9797                for (i=0; i<outer->Size(); i++) {
    98                         _printf_(flag,"%s         outer: -------- begin [%d] --------\n" ,indent,i);
     98                        if(flag) _pprintLine_(indent << "         outer: -------- begin [" << i << "] --------");
    9999                        ((KML_LinearRing *)outer->GetObjectByOffset(i))->DeepEcho(indent2);
    100                         _printf_(flag,"%s         outer: --------  end  [%d] --------\n" ,indent,i);
     100                        if(flag) _pprintLine_(indent << "         outer: --------  end  [" << i << "] --------");
    101101                }
    102102        else
    103                 _printf_(flag,"%s         outer: [empty]\n"    ,indent);
     103                if(flag) _pprintLine_(indent << "         outer: [empty]");
    104104
    105105        if (inner->Size())
    106106                for (i=0; i<inner->Size(); i++) {
    107                         _printf_(flag,"%s         inner: -------- begin [%d] --------\n" ,indent,i);
     107                        if(flag) _pprintLine_(indent << "         inner: -------- begin [" << i << "] --------");
    108108                        ((KML_LinearRing *)inner->GetObjectByOffset(i))->DeepEcho(indent2);
    109                         _printf_(flag,"%s         inner: --------  end  [%d] --------\n" ,indent,i);
     109                        if(flag) _pprintLine_(indent << "         inner: --------  end  [" << i << "] --------");
    110110                }
    111111        else
    112                 _printf_(flag,"%s         inner: [empty]\n"    ,indent);
    113 
    114         return;
    115 }
    116 /*}}}*/
    117 /*FUNCTION KML_Polygon::Write {{{1*/
     112                if(flag) _pprintLine_(indent << "         inner: [empty]");
     113
     114        return;
     115}
     116/*}}}*/
     117/*FUNCTION KML_Polygon::Write {{{*/
    118118void  KML_Polygon::Write(FILE* filout,const char* indent){
    119119
     
    155155}
    156156/*}}}*/
    157 /*FUNCTION KML_Polygon::Read {{{1*/
     157/*FUNCTION KML_Polygon::Read {{{*/
    158158void  KML_Polygon::Read(FILE* fid,char* kstr){
    159159
     
    179179                }
    180180                else if (!strncmp(kstri,"</",2))
    181                         _error_("KML_Polygon::Read -- Unexpected closing tag %s.\n",kstri);
     181                  {_error2_("KML_Polygon::Read -- Unexpected closing tag " << kstri << ".\n");}
    182182                else if (strncmp(kstri,"<",1))
    183                         _error_("KML_Polygon::Read -- Unexpected field \"%s\".\n",kstri);
     183                  {_error2_("KML_Polygon::Read -- Unexpected field \"" << kstri << "\".\n");}
    184184
    185185                else if (!strcmp(kstri,"<extrude>"))
     
    207207                                }
    208208                                else if (!strncmp(kstrj,"</",2))
    209                                         _error_("KML_Polygon::Read -- Unexpected closing tag %s.\n",kstrj);
     209                                  {_error2_("KML_Polygon::Read -- Unexpected closing tag " << kstrj << ".\n");}
    210210                                else if (strncmp(kstrj,"<",1))
    211                                         _error_("KML_Polygon::Read -- Unexpected field \"%s\".\n",kstrj);
     211                                  {_error2_("KML_Polygon::Read -- Unexpected field \"" << kstrj << "\".\n");}
    212212
    213213                                else if (!strncmp(kstrj,"<LinearRing",11)) {
     
    234234                                }
    235235                                else if (!strncmp(kstrj,"</",2))
    236                                         _error_("KML_Polygon::Read -- Unexpected closing tag %s.\n",kstrj);
     236                                  {_error2_("KML_Polygon::Read -- Unexpected closing tag " << kstrj << ".\n");}
    237237                                else if (strncmp(kstrj,"<",1))
    238                                         _error_("KML_Polygon::Read -- Unexpected field \"%s\".\n",kstrj);
     238                                  {_error2_("KML_Polygon::Read -- Unexpected field \"" << kstrj << "\".\n");}
    239239
    240240                                else if (!strncmp(kstrj,"<LinearRing",11)) {
     
    266266}
    267267/*}}}*/
    268 /*FUNCTION KML_Polygon::WriteExp {{{1*/
     268/*FUNCTION KML_Polygon::WriteExp {{{*/
    269269void  KML_Polygon::WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp){
    270270
  • issm/trunk/src/c/objects/KML/KML_Polygon.h

    r11237 r12706  
    99
    1010/*Headers:*/
    11 /*{{{1*/
     11/*{{{*/
    1212#include "../../include/include.h"
    1313#include "../../shared/Exceptions/exceptions.h"
     
    2929                DataSet* inner;
    3030
    31                 /*KML_Polygon constructors, destructors {{{1*/
     31                /*KML_Polygon constructors, destructors {{{*/
    3232                KML_Polygon();
    3333                ~KML_Polygon();
    3434                /*}}}*/
    35                 /*Object virtual functions definitions:{{{1*/
     35                /*Object virtual functions definitions:{{{*/
    3636                void  Echo();
    3737                void  DeepEcho();
     
    4040                void  Read(FILE* fid,char* kstr);
    4141                void  WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp);
    42                 int   Id(){_error_("Not implemented yet.");};
    43                 int   MyRank(){_error_("Not implemented yet.");};
    44                 void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    45                 int   MarshallSize(){_error_("Not implemented yet.");};
    46                 void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    47                 int   ObjectEnum(){_error_("Not implemented yet.");};
    48                 Object* copy(){_error_("Not implemented yet.");};
     42                int   Id(){_error2_("Not implemented yet.");};
     43                int   MyRank(){_error2_("Not implemented yet.");};
     44                void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     45                int   MarshallSize(){_error2_("Not implemented yet.");};
     46                void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     47                int   ObjectEnum(){_error2_("Not implemented yet.");};
     48                Object* copy(){_error2_("Not implemented yet.");};
    4949                /*}}}*/
    5050
  • issm/trunk/src/c/objects/KML/KML_Style.cpp

    r11527 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*Constructors/destructor/copy*/
    23 /*FUNCTION KML_Style::KML_Style(){{{1*/
     23/*FUNCTION KML_Style::KML_Style(){{{*/
    2424KML_Style::KML_Style(){
    2525
     
    3333}
    3434/*}}}*/
    35 /*FUNCTION KML_Style::~KML_Style(){{{1*/
     35/*FUNCTION KML_Style::~KML_Style(){{{*/
    3636KML_Style::~KML_Style(){
    3737
     
    6969
    7070/*Other*/
    71 /*FUNCTION KML_Style::Echo {{{1*/
     71/*FUNCTION KML_Style::Echo {{{*/
    7272void  KML_Style::Echo(){
    7373
    7474        bool  flag=true;
    7575
    76         _printf_(flag,"KML_Style:\n");
     76        if(flag) _pprintLine_("KML_Style:");
    7777        KML_StyleSelector::Echo();
    7878
    79         _printf_(flag,"          icon: %p\n"          ,icon);
    80         _printf_(flag,"         label: %p\n"          ,label);
    81         _printf_(flag,"          line: %p\n"          ,line);
    82         _printf_(flag,"          poly: %p\n"          ,poly);
    83         _printf_(flag,"       balloon: %p\n"          ,balloon);
    84         _printf_(flag,"          list: %p\n"          ,list);
    85 
    86         return;
    87 }
    88 /*}}}*/
    89 
    90 /*FUNCTION KML_Style::DeepEcho {{{1*/
     79        if(flag) _pprintLine_("          icon: " << icon);
     80        if(flag) _pprintLine_("         label: " << label);
     81        if(flag) _pprintLine_("          line: " << line);
     82        if(flag) _pprintLine_("          poly: " << poly);
     83        if(flag) _pprintLine_("       balloon: " << balloon);
     84        if(flag) _pprintLine_("          list: " << list);
     85
     86        return;
     87}
     88/*}}}*/
     89/*FUNCTION KML_Style::DeepEcho {{{*/
    9190void  KML_Style::DeepEcho(){
    9291
     
    9897}
    9998/*}}}*/
    100 
    101 /*FUNCTION KML_Style::DeepEcho {{{1*/
     99/*FUNCTION KML_Style::DeepEcho {{{*/
    102100void  KML_Style::DeepEcho(const char* indent){
    103101
     
    105103        bool  flag=true;
    106104
    107         _printf_(flag,"%sKML_Style:\n",indent);
     105        if(flag) _pprintLine_(indent << "KML_Style:");
    108106        KML_StyleSelector::DeepEcho(indent);
    109107
     
    114112//              icon->DeepEcho(indent2);
    115113//      else
    116                 _printf_(flag,"%s          icon: %p\n"          ,indent,icon);
     114                if(flag) _pprintLine_(indent << "          icon: " << icon);
    117115//      if (label)
    118116//              label->DeepEcho(indent2);
    119117//      else
    120                 _printf_(flag,"%s         label: %p\n"          ,indent,label);
     118                if(flag) _pprintLine_(indent << "         label: " << label);
    121119        if (line)
    122120                line->DeepEcho(indent2);
    123121        else
    124                 _printf_(flag,"%s          line: %p\n"          ,indent,line);
     122                if(flag) _pprintLine_(indent << "          line: " << line);
    125123        if (poly)
    126124                poly->DeepEcho(indent2);
    127125        else
    128                 _printf_(flag,"%s          poly: %p\n"          ,indent,poly);
     126                if(flag) _pprintLine_(indent << "          poly: " << poly);
    129127//      if (balloon)
    130128//              balloon->DeepEcho(indent2);
    131129//      else
    132                 _printf_(flag,"%s       balloon: %p\n"          ,indent,balloon);
     130                if(flag) _pprintLine_(indent << "       balloon: " << balloon);
    133131//      if (list)
    134132//              list->DeepEcho(indent2);
    135133//      else
    136                 _printf_(flag,"%s          list: %p\n"          ,indent,list);
    137 
    138         return;
    139 }
    140 /*}}}*/
    141 
    142 /*FUNCTION KML_Style::Write {{{1*/
     134                if(flag) _pprintLine_(indent << "          list: " << list);
     135
     136        return;
     137}
     138/*}}}*/
     139/*FUNCTION KML_Style::Write {{{*/
    143140void  KML_Style::Write(FILE* filout,const char* indent){
    144141
     
    174171}
    175172/*}}}*/
    176 
    177 /*FUNCTION KML_Style::Read {{{1*/
     173/*FUNCTION KML_Style::Read {{{*/
    178174void  KML_Style::Read(FILE* fid,char* kstr){
    179175
     
    197193                }
    198194                else if (!strncmp(kstri,"</",2))
    199                         _error_("KML_Style::Read -- Unexpected closing tag %s.\n",kstri);
     195                  {_error2_("KML_Style::Read -- Unexpected closing tag " << kstri << ".\n");}
    200196                else if (strncmp(kstri,"<",1))
    201                         _error_("KML_Style::Read -- Unexpected field \"%s\".\n",kstri);
     197                  {_error2_("KML_Style::Read -- Unexpected field \"" << kstri << "\".\n");}
    202198
    203199//              else if (!strncmp(kstri,"<IconStyle",10)) {
     
    246242}
    247243/*}}}*/
    248 
  • issm/trunk/src/c/objects/KML/KML_Style.h

    r11237 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "../../include/include.h"
    1111#include "../../shared/Exceptions/exceptions.h"
     
    2828                void* list;
    2929
    30                 /*KML_Style constructors, destructors {{{1*/
     30                /*KML_Style constructors, destructors {{{*/
    3131                KML_Style();
    3232                ~KML_Style();
    3333                /*}}}*/
    34                 /*Object virtual functions definitions:{{{1*/
     34                /*Object virtual functions definitions:{{{*/
    3535                void  Echo();
    3636                void  DeepEcho();
     
    3838                void  Write(FILE* fid,const char* indent);
    3939                void  Read(FILE* fid,char* kstr);
    40                 int   Id(){_error_("Not implemented yet.");};
    41                 int   MyRank(){_error_("Not implemented yet.");};
    42                 void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    43                 int   MarshallSize(){_error_("Not implemented yet.");};
    44                 void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    45                 int   ObjectEnum(){_error_("Not implemented yet.");};
    46                 Object* copy(){_error_("Not implemented yet.");};
     40                int   Id(){_error2_("Not implemented yet.");};
     41                int   MyRank(){_error2_("Not implemented yet.");};
     42                void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     43                int   MarshallSize(){_error2_("Not implemented yet.");};
     44                void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     45                int   ObjectEnum(){_error2_("Not implemented yet.");};
     46                Object* copy(){_error2_("Not implemented yet.");};
    4747                /*}}}*/
    4848
  • issm/trunk/src/c/objects/KML/KML_StyleSelector.cpp

    r11237 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2020
    2121/*Constructors/destructor/copy*/
    22 /*FUNCTION KML_StyleSelector::KML_StyleSelector(){{{1*/
     22/*FUNCTION KML_StyleSelector::KML_StyleSelector(){{{*/
    2323KML_StyleSelector::KML_StyleSelector(){
    2424
     
    2727}
    2828/*}}}*/
    29 /*FUNCTION KML_StyleSelector::~KML_StyleSelector(){{{1*/
     29/*FUNCTION KML_StyleSelector::~KML_StyleSelector(){{{*/
    3030KML_StyleSelector::~KML_StyleSelector(){
    3131
     
    3636
    3737/*Other*/
    38 /*FUNCTION KML_StyleSelector::Echo {{{1*/
     38/*FUNCTION KML_StyleSelector::Echo {{{*/
    3939void  KML_StyleSelector::Echo(){
    4040
     
    4545/*}}}*/
    4646
    47 /*FUNCTION KML_StyleSelector::DeepEcho {{{1*/
     47/*FUNCTION KML_StyleSelector::DeepEcho {{{*/
    4848void  KML_StyleSelector::DeepEcho(){
    4949
     
    5656/*}}}*/
    5757
    58 /*FUNCTION KML_StyleSelector::DeepEcho {{{1*/
     58/*FUNCTION KML_StyleSelector::DeepEcho {{{*/
    5959void  KML_StyleSelector::DeepEcho(const char* indent){
    6060
     
    6565/*}}}*/
    6666
    67 /*FUNCTION KML_StyleSelector::Write {{{1*/
     67/*FUNCTION KML_StyleSelector::Write {{{*/
    6868void  KML_StyleSelector::Write(FILE* filout,const char* indent){
    6969
     
    7474/*}}}*/
    7575
    76 /*FUNCTION KML_StyleSelector::Read {{{1*/
     76/*FUNCTION KML_StyleSelector::Read {{{*/
    7777void  KML_StyleSelector::Read(FILE* fid,char* kstr){
    7878
     
    8282                return;
    8383        else if (!strncmp(kstr,"</",2))
    84                 _error_("KML_StyleSelector::Read -- Unexpected closing tag %s.\n",kstr);
     84          {_error2_("KML_StyleSelector::Read -- Unexpected closing tag " << kstr << ".\n");}
    8585        else if (strncmp(kstr,"<",1))
    86                 _error_("KML_StyleSelector::Read -- Unexpected field \"%s\".\n",kstr);
     86          {_error2_("KML_StyleSelector::Read -- Unexpected field \"" << kstr << "\".\n");}
    8787
    8888        else if (!strncmp(kstr,"<",1))
  • issm/trunk/src/c/objects/KML/KML_StyleSelector.h

    r11237 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "../../include/include.h"
    1111#include "../../shared/Exceptions/exceptions.h"
     
    1919        public:
    2020
    21                 /*KML_StyleSelector constructors, destructors {{{1*/
     21                /*KML_StyleSelector constructors, destructors {{{*/
    2222                KML_StyleSelector();
    2323                ~KML_StyleSelector();
    2424                /*}}}*/
    25                 /*Object virtual functions definitions:{{{1*/
     25                /*Object virtual functions definitions:{{{*/
    2626                void  Echo();
    2727                void  DeepEcho();
     
    2929                void  Write(FILE* fid,const char* indent);
    3030                void  Read(FILE* fid,char* kstr);
    31                 int   Id(){_error_("Not implemented yet.");};
    32                 int   MyRank(){_error_("Not implemented yet.");};
    33                 void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    34                 int   MarshallSize(){_error_("Not implemented yet.");};
    35                 void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    36                 int   ObjectEnum(){_error_("Not implemented yet.");};
    37                 Object* copy(){_error_("Not implemented yet.");};
     31                int   Id(){_error2_("Not implemented yet.");};
     32                int   MyRank(){_error2_("Not implemented yet.");};
     33                void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     34                int   MarshallSize(){_error2_("Not implemented yet.");};
     35                void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     36                int   ObjectEnum(){_error2_("Not implemented yet.");};
     37                Object* copy(){_error2_("Not implemented yet.");};
    3838                /*}}}*/
    3939
  • issm/trunk/src/c/objects/KML/KML_SubStyle.cpp

    r11237 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2020
    2121/*Constructors/destructor/copy*/
    22 /*FUNCTION KML_SubStyle::KML_SubStyle(){{{1*/
     22/*FUNCTION KML_SubStyle::KML_SubStyle(){{{*/
    2323KML_SubStyle::KML_SubStyle(){
    2424
     
    2727}
    2828/*}}}*/
    29 /*FUNCTION KML_SubStyle::~KML_SubStyle(){{{1*/
     29/*FUNCTION KML_SubStyle::~KML_SubStyle(){{{*/
    3030KML_SubStyle::~KML_SubStyle(){
    3131
     
    3636
    3737/*Other*/
    38 /*FUNCTION KML_SubStyle::Echo {{{1*/
     38/*FUNCTION KML_SubStyle::Echo {{{*/
    3939void  KML_SubStyle::Echo(){
    4040
     
    4545/*}}}*/
    4646
    47 /*FUNCTION KML_SubStyle::DeepEcho {{{1*/
     47/*FUNCTION KML_SubStyle::DeepEcho {{{*/
    4848void  KML_SubStyle::DeepEcho(){
    4949
     
    5656/*}}}*/
    5757
    58 /*FUNCTION KML_SubStyle::DeepEcho {{{1*/
     58/*FUNCTION KML_SubStyle::DeepEcho {{{*/
    5959void  KML_SubStyle::DeepEcho(const char* indent){
    6060
     
    6565/*}}}*/
    6666
    67 /*FUNCTION KML_SubStyle::Write {{{1*/
     67/*FUNCTION KML_SubStyle::Write {{{*/
    6868void  KML_SubStyle::Write(FILE* filout,const char* indent){
    6969
     
    7474/*}}}*/
    7575
    76 /*FUNCTION KML_SubStyle::Read {{{1*/
     76/*FUNCTION KML_SubStyle::Read {{{*/
    7777void  KML_SubStyle::Read(FILE* fid,char* kstr){
    7878
     
    8282                return;
    8383        else if (!strncmp(kstr,"</",2))
    84                 _error_("KML_SubStyle::Read -- Unexpected closing tag %s.\n",kstr);
     84          {_error2_("KML_SubStyle::Read -- Unexpected closing tag " << kstr << ".\n");}
    8585        else if (strncmp(kstr,"<",1))
    86                 _error_("KML_SubStyle::Read -- Unexpected field \"%s\".\n",kstr);
     86          {_error2_("KML_SubStyle::Read -- Unexpected field \"" << kstr << "\".\n");}
    8787
    8888        else if (!strncmp(kstr,"<",1))
  • issm/trunk/src/c/objects/KML/KML_SubStyle.h

    r11237 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "../../include/include.h"
    1111#include "../../shared/Exceptions/exceptions.h"
     
    1919        public:
    2020
    21                 /*KML_SubStyle constructors, destructors {{{1*/
     21                /*KML_SubStyle constructors, destructors {{{*/
    2222                KML_SubStyle();
    2323                ~KML_SubStyle();
    2424                /*}}}*/
    25                 /*Object virtual functions definitions:{{{1*/
     25                /*Object virtual functions definitions:{{{*/
    2626                void  Echo();
    2727                void  DeepEcho();
     
    2929                void  Write(FILE* fid,const char* indent);
    3030                void  Read(FILE* fid,char* kstr);
    31                 int   Id(){_error_("Not implemented yet.");};
    32                 int   MyRank(){_error_("Not implemented yet.");};
    33                 void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    34                 int   MarshallSize(){_error_("Not implemented yet.");};
    35                 void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    36                 int   ObjectEnum(){_error_("Not implemented yet.");};
    37                 Object* copy(){_error_("Not implemented yet.");};
     31                int   Id(){_error2_("Not implemented yet.");};
     32                int   MyRank(){_error2_("Not implemented yet.");};
     33                void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     34                int   MarshallSize(){_error2_("Not implemented yet.");};
     35                void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     36                int   ObjectEnum(){_error2_("Not implemented yet.");};
     37                Object* copy(){_error2_("Not implemented yet.");};
    3838                /*}}}*/
    3939
  • issm/trunk/src/c/objects/KML/KML_Unknown.cpp

    r11527 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*Constructors/destructor/copy*/
    23 /*FUNCTION KML_Unknown::KML_Unknown(){{{1*/
     23/*FUNCTION KML_Unknown::KML_Unknown(){{{*/
    2424KML_Unknown::KML_Unknown(){
    2525
     
    2929}
    3030/*}}}*/
    31 /*FUNCTION KML_Unknown::~KML_Unknown(){{{1*/
     31/*FUNCTION KML_Unknown::~KML_Unknown(){{{*/
    3232KML_Unknown::~KML_Unknown(){
    3333
     
    3939
    4040/*Other*/
    41 /*FUNCTION KML_Unknown::Echo {{{1*/
     41/*FUNCTION KML_Unknown::Echo {{{*/
    4242void  KML_Unknown::Echo(){
    4343
    4444        bool  flag=true;
    4545
    46         _printf_(flag,"KML_Unknown %s:\n",name);
     46        if(flag) _pprintLine_("KML_Unknown " << name << ":");
    4747        KML_Object::Echo();
    4848
    4949        if (value     )
    50                 _printf_(flag,"         value: \"%s\"\n"     ,value);
     50                if(flag) _pprintLine_("         value: \"" << value << "\"");
    5151    else
    52         _printf_(flag,"         value: [none]\n"     );
     52        if(flag) _pprintLine_("         value: [none]");
    5353
    5454        return;
    5555}
    5656/*}}}*/
    57 /*FUNCTION KML_Unknown::DeepEcho {{{1*/
     57/*FUNCTION KML_Unknown::DeepEcho {{{*/
    5858void  KML_Unknown::DeepEcho(){
    5959
     
    6565}
    6666/*}}}*/
    67 /*FUNCTION KML_Unknown::DeepEcho {{{1*/
     67/*FUNCTION KML_Unknown::DeepEcho {{{*/
    6868void  KML_Unknown::DeepEcho(const char* indent){
    6969
     
    7373        bool         flag=true;
    7474
    75         _printf_(flag,"%sKML_Unknown %s:\n",indent,name);
     75        if(flag) _pprintLine_(indent << "KML_Unknown " << name << ":");
    7676        KML_Object::DeepEcho(indent);
    7777
     
    8181       
    8282                vtoken=strtok(valuei,nl);
    83                 _printf_(flag,"%s         value: \"%s"     ,indent,vtoken);
     83                if(flag) _pprintString_(indent << "         value: \"" << vtoken);
    8484   
    8585                while (vtoken=strtok(NULL,nl))
    86                         _printf_(flag,"\n%s                 %s"     ,indent,vtoken);
    87                 _printf_(flag,"\"\n");
     86                        if(flag) _pprintString_("\n" << indent << "                 " << vtoken);
     87                if(flag) _pprintLine_("\"");
    8888
    8989                xfree((void**)&valuei);
    9090        }
    9191    else
    92         _printf_(flag,"%s         value: [none]\n"     ,indent);
     92        if(flag) _pprintLine_(indent << "         value: [none]");
    9393
    9494        return;
    9595}
    9696/*}}}*/
    97 /*FUNCTION KML_Unknown::Write {{{1*/
     97/*FUNCTION KML_Unknown::Write {{{*/
    9898void  KML_Unknown::Write(FILE* filout,const char* indent){
    9999
     
    127127}
    128128/*}}}*/
    129 /*FUNCTION KML_Unknown::Read {{{1*/
     129/*FUNCTION KML_Unknown::Read {{{*/
    130130void  KML_Unknown::Read(FILE* fid,char* kstr){
    131131
     
    139139        name=KMLFileTagName(NULL,
    140140                                                kstr);
    141 //      _printf_(true,"KML_Unknown::Read -- opening name=%s.\n",name);
     141//      _pprintLine_("KML_Unknown::Read -- opening name=" << name << ".");
    142142
    143143/*  get object attributes and check for solo tag  */
     
    151151        while (kstri=KMLFileToken(fid,
    152152                                                          &ncom,&pcom)) {
    153 //              _printf_(true,"KML_Unknown::Read -- kstri=%s.\n",kstri);
     153//              _pprintLine_("KML_Unknown::Read -- kstri=" << kstri << ".");
    154154                if      (!strncmp(&kstri[0],"</", 2) &&
    155155                                 !strncmp(&kstri[2],name,strlen(name))) {
    156 //                      _printf_(true,"KML_Unknown::Read -- closing name=%s.\n",name);
     156//                      _pprintLine_("KML_Unknown::Read -- closing name=" << name << ".");
    157157                        xfree((void**)&kstri);
    158158                        break;
    159159                }
    160160                else if (!strncmp(kstri,"</",2))
    161                         _error_("KML_Unknown::Read -- Unexpected closing tag %s.\n",kstri);
     161                  {_error2_("KML_Unknown::Read -- Unexpected closing tag " << kstri << ".\n");}
    162162
    163163                else if (strncmp(kstri,"<",1)) {
  • issm/trunk/src/c/objects/KML/KML_Unknown.h

    r11527 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "../../include/include.h"
    1111#include "../../shared/Exceptions/exceptions.h"
     
    2222                char* value;
    2323
    24                 /*KML_Unknown constructors, destructors {{{1*/
     24                /*KML_Unknown constructors, destructors {{{*/
    2525                KML_Unknown();
    2626                ~KML_Unknown();
    2727                /*}}}*/
    28                 /*Object virtual functions definitions:{{{1*/
     28                /*Object virtual functions definitions:{{{*/
    2929                void  Echo();
    3030                void  DeepEcho();
     
    3232                void  Write(FILE* fid,const char* indent);
    3333                void  Read(FILE* fid,char* kstr);
    34                 int   Id(){_error_("Not implemented yet.");};
    35                 int   MyRank(){_error_("Not implemented yet.");};
    36                 void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    37                 int   MarshallSize(){_error_("Not implemented yet.");};
    38                 void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
    39                 int   ObjectEnum(){_error_("Not implemented yet.");};
    40                 Object* copy(){_error_("Not implemented yet.");};
     34                int   Id(){_error2_("Not implemented yet.");};
     35                int   MyRank(){_error2_("Not implemented yet.");};
     36                void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     37                int   MarshallSize(){_error2_("Not implemented yet.");};
     38                void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
     39                int   ObjectEnum(){_error2_("Not implemented yet.");};
     40                Object* copy(){_error2_("Not implemented yet.");};
    4141                /*}}}*/
    4242
  • issm/trunk/src/c/objects/Kriging/ExponentialVariogram.cpp

    r12330 r12706  
    1717
    1818/*ExponentialVariogram constructors and destructor*/
    19 /*FUNCTION ExponentialVariogram::ExponentialVariogram(){{{1*/
     19/*FUNCTION ExponentialVariogram::ExponentialVariogram(){{{*/
    2020ExponentialVariogram::ExponentialVariogram(){
    2121        this->nugget = 0.2;
     
    2525}
    2626/*}}}*/
    27 /*FUNCTION ExponentialVariogram::ExponentialVariogram(Options* options){{{1*/
     27/*FUNCTION ExponentialVariogram::ExponentialVariogram(Options* options){{{*/
    2828ExponentialVariogram::ExponentialVariogram(Options* options){
    2929
     
    3939
    4040        /*Checks*/
    41         if(nugget==sill) _error_("nugget and sill cannot be equal (constant semivariogram not allowed)");
     41        if(nugget==sill) _error2_("nugget and sill cannot be equal (constant semivariogram not allowed)");
    4242}
    4343/*}}}*/
    44 /*FUNCTION ExponentialVariogram::~ExponentialVariogram(){{{1*/
     44/*FUNCTION ExponentialVariogram::~ExponentialVariogram(){{{*/
    4545ExponentialVariogram::~ExponentialVariogram(){
    4646        return;
     
    4949
    5050/*Object virtual functions definitions:*/
    51 /*FUNCTION ExponentialVariogram::Echo {{{1*/
     51/*FUNCTION ExponentialVariogram::Echo {{{*/
    5252void ExponentialVariogram::Echo(void){
    53         printf("ExponentialVariogram\n");
    54         printf("   nugget: %g\n",this->nugget);
    55         printf("   sill  : %g\n",this->sill);
    56         printf("   range : %g\n",this->range);
     53        _printLine_("ExponentialVariogram");
     54        _printLine_("   nugget: " << this->nugget);
     55        _printLine_("   sill  : " << this->sill);
     56        _printLine_("   range : " << this->range);
    5757}
    5858/*}}}*/
    5959
    6060/*Variogram function*/
    61 /*FUNCTION ExponentialVariogram::Covariance{{{1*/
     61/*FUNCTION ExponentialVariogram::Covariance{{{*/
    6262double ExponentialVariogram::Covariance(double deltax,double deltay){
    6363        /*The covariance can be deduced from the variogram from the following
     
    7171        h=sqrt(pow(deltax,2.)+pow(deltay,2.));
    7272
    73         /*return covariance*/
     73        /*If h is too small, return sill*/
     74        if(h<0.0000001) return sill;
     75
     76        /*compute covariance*/
    7477        a     = 1./3.;
    7578        cova = (sill-nugget)*exp(-h/(a*range));
     
    7780}
    7881/*}}}*/
    79 /*FUNCTION ExponentialVariogram::SemiVariogram{{{1*/
     82/*FUNCTION ExponentialVariogram::SemiVariogram{{{*/
    8083double ExponentialVariogram::SemiVariogram(double deltax,double deltay){
    8184        /*http://en.wikipedia.org/wiki/Variogram*/
  • issm/trunk/src/c/objects/Kriging/ExponentialVariogram.h

    r12330 r12706  
    2323                /*Object virtual functions definitions*/
    2424                void  Echo();
    25                 void  DeepEcho(){_error_("Not implemented yet");};
    26                 int   Id(){_error_("Not implemented yet");};
    27                 int   MyRank(){_error_("Not implemented yet");};
    28                 int   ObjectEnum(){_error_("Not implemented yet");};
    29                 Object* copy(){_error_("Not implemented yet");};
     25                void  DeepEcho(){_error2_("Not implemented yet");};
     26                int   Id(){_error2_("Not implemented yet");};
     27                int   MyRank(){_error2_("Not implemented yet");};
     28                int   ObjectEnum(){_error2_("Not implemented yet");};
     29                Object* copy(){_error2_("Not implemented yet");};
    3030
    3131                /*Variogram functions*/
  • issm/trunk/src/c/objects/Kriging/GaussianVariogram.cpp

    r12330 r12706  
    1717
    1818/*GaussianVariogram constructors and destructor*/
    19 /*FUNCTION GaussianVariogram::GaussianVariogram(){{{1*/
     19/*FUNCTION GaussianVariogram::GaussianVariogram(){{{*/
    2020GaussianVariogram::GaussianVariogram(){
    2121        this->nugget = 0.2;
     
    2525}
    2626/*}}}*/
    27 /*FUNCTION GaussianVariogram::GaussianVariogram(Options* options){{{1*/
     27/*FUNCTION GaussianVariogram::GaussianVariogram(Options* options){{{*/
    2828GaussianVariogram::GaussianVariogram(Options* options){
    2929
     
    3939
    4040        /*Checks*/
    41         if(nugget==sill) _error_("nugget and sill cannot be equal (constant semivariogram not allowed)");
     41        if(nugget==sill) _error2_("nugget and sill cannot be equal (constant semivariogram not allowed)");
    4242}
    4343/*}}}*/
    44 /*FUNCTION GaussianVariogram::~GaussianVariogram(){{{1*/
     44/*FUNCTION GaussianVariogram::~GaussianVariogram(){{{*/
    4545GaussianVariogram::~GaussianVariogram(){
    4646        return;
     
    4949
    5050/*Object virtual functions definitions:*/
    51 /*FUNCTION GaussianVariogram::Echo {{{1*/
     51/*FUNCTION GaussianVariogram::Echo {{{*/
    5252void GaussianVariogram::Echo(void){
    53         printf("GaussianVariogram\n");
    54         printf("   nugget: %g\n",this->nugget);
    55         printf("   sill  : %g\n",this->sill);
    56         printf("   range : %g\n",this->range);
     53        _printLine_("GaussianVariogram");
     54        _printLine_("   nugget: " << this->nugget);
     55        _printLine_("   sill  : " << this->sill);
     56        _printLine_("   range : " << this->range);
    5757}
    5858/*}}}*/
    5959
    6060/*Variogram function*/
    61 /*FUNCTION GaussianVariogram::Covariance{{{1*/
     61/*FUNCTION GaussianVariogram::Covariance{{{*/
    6262double GaussianVariogram::Covariance(double deltax,double deltay){
    6363        /*The covariance can be deduced from the variogram from the following
     
    7171        h2=pow(deltax,2.)+pow(deltay,2.);
    7272
    73         /*return covariance*/
     73        /*If h is too small, return sill*/
     74        if(h2<0.0000001) return sill;
     75
     76        /*compute covariance*/
    7477        a     = 1./3.;
    7578        cova = (sill-nugget)*exp(-h2/(a*range*range));
    76 
    77         if(h2<0.0000001) cova = sill;
    7879
    7980        return cova;
    8081}
    8182/*}}}*/
    82 /*FUNCTION GaussianVariogram::SemiVariogram{{{1*/
     83/*FUNCTION GaussianVariogram::SemiVariogram{{{*/
    8384double GaussianVariogram::SemiVariogram(double deltax,double deltay){
    8485        /*http://en.wikipedia.org/wiki/Variogram*/
     
    9293        gamma = (sill-nugget)*(1.-exp(-h2/(a*range*range))) + nugget;
    9394
    94         //if(h2>1000*1000) printf("gamma = %g h= %g\n",gamma,sqrt(h2));
    95         printf("h = %g gamma = %g\n",sqrt(h2),gamma);
     95        //if(h2>1000*1000) _printLine_("gamma = " << gamma << " h= " << sqrt(h2));
     96        _printLine_("h = " << sqrt(h2) << " gamma = " << gamma);
    9697        return gamma;
    9798}
  • issm/trunk/src/c/objects/Kriging/GaussianVariogram.h

    r12330 r12706  
    2323                /*Object virtual functions definitions*/
    2424                void  Echo();
    25                 void  DeepEcho(){_error_("Not implemented yet");};
    26                 int   Id(){_error_("Not implemented yet");};
    27                 int   MyRank(){_error_("Not implemented yet");};
    28                 int   ObjectEnum(){_error_("Not implemented yet");};
    29                 Object* copy(){_error_("Not implemented yet");};
     25                void  DeepEcho(){_error2_("Not implemented yet");};
     26                int   Id(){_error2_("Not implemented yet");};
     27                int   MyRank(){_error2_("Not implemented yet");};
     28                int   ObjectEnum(){_error2_("Not implemented yet");};
     29                Object* copy(){_error2_("Not implemented yet");};
    3030
    3131                /*Variogram functions*/
  • issm/trunk/src/c/objects/Kriging/Observation.cpp

    r12330 r12706  
    77
    88/*Observation constructors and destructor*/
    9 /*FUNCTION Observation::Observation(){{{1*/
     9/*FUNCTION Observation::Observation(){{{*/
    1010Observation::Observation(){
    1111        return;
    1212}
    1313/*}}}*/
    14 /*FUNCTION Observation::Observation(double x,double y,int xi,int yi,int index,double value){{{1*/
     14/*FUNCTION Observation::Observation(double x,double y,int xi,int yi,int index,double value){{{*/
    1515Observation::Observation(double x_in,double y_in,int xi_in,int yi_in,int index_in,double value_in){
    1616
     
    2525}
    2626/*}}}*/
    27 /*FUNCTION Observation::~Observation(){{{1*/
     27/*FUNCTION Observation::~Observation(){{{*/
    2828Observation::~Observation(){
    2929        return;
     
    3232
    3333/*Object virtual functions definitions:*/
    34 /*FUNCTION Observation::Echo {{{1*/
     34/*FUNCTION Observation::Echo {{{*/
    3535void Observation::Echo(void){
    3636
    3737        int  bit;
    3838
    39         printf("Observation\n");
    40         printf("   index : %i\n",this->index);
    41         printf("   x     : %g\n",this->x);
    42         printf("   y     : %g\n",this->y);
    43         printf("   xi    : "); printbinary(this->xi); printf("\n");
    44         printf("   yi    : "); printbinary(this->yi); printf("\n");
    45         printf("   weight: %g\n",this->weight);
    46         printf("   value : %g\n",this->value);
     39        _printLine_("Observation");
     40        _printLine_("   index : " << this->index);
     41        _printLine_("   x     : " << this->x);
     42        _printLine_("   y     : " << this->y);
     43        _printLine_("   xi    : "); printbinary(this->xi); _printLine_("");
     44        _printLine_("   yi    : "); printbinary(this->yi); _printLine_("");
     45        _printLine_("   weight: " << this->weight);
     46        _printLine_("   value : " << this->value);
    4747}
    4848/*}}}*/
    4949
    5050/*Observations functions*/
    51 /*FUNCTION Observation::WriteXYObs(double* px,double* py,double* pobs){{{1*/
     51/*FUNCTION Observation::WriteXYObs(double* px,double* py,double* pobs){{{*/
    5252void Observation::WriteXYObs(double* px,double* py,double* pobs){
    5353        *px   = this->x;
  • issm/trunk/src/c/objects/Kriging/Observation.h

    r12330 r12706  
    2424                /*Object virtual functions definitions*/
    2525                void    Echo();
    26                 void    DeepEcho()  {_error_("Not implemented yet"); };
    27                 int     Id()        {_error_("Not implemented yet"); };
    28                 int     MyRank()    {_error_("Not implemented yet"); };
    29                 int     ObjectEnum(){_error_("Not implemented yet"); };
    30                 Object *copy()      {_error_("Not implemented yet"); };
     26                void    DeepEcho()  {_error2_("Not implemented yet"); };
     27                int     Id()        {_error2_("Not implemented yet"); };
     28                int     MyRank()    {_error2_("Not implemented yet"); };
     29                int     ObjectEnum(){_error2_("Not implemented yet"); };
     30                Object *copy()      {_error2_("Not implemented yet"); };
    3131
    3232                /*Management*/
  • issm/trunk/src/c/objects/Kriging/PowerVariogram.cpp

    r12330 r12706  
    1717
    1818/*PowerVariogram constructors and destructor*/
    19 /*FUNCTION PowerVariogram::PowerVariogram(){{{1*/
     19/*FUNCTION PowerVariogram::PowerVariogram(){{{*/
    2020PowerVariogram::PowerVariogram(){
    2121        this->nugget = 0.2;
     
    2525}
    2626/*}}}*/
    27 /*FUNCTION PowerVariogram::PowerVariogram(Options* options){{{1*/
     27/*FUNCTION PowerVariogram::PowerVariogram(Options* options){{{*/
    2828PowerVariogram::PowerVariogram(Options* options){
    2929
     
    3939
    4040        /*Checks*/
    41         if(power<=0 || power>=2) _error_("power must be betwwen 0 and 2 (0 < power < 2)");
    42         if(slope<=0) _error_("slope must be positive");
     41        if(power<=0 || power>=2) _error2_("power must be betwwen 0 and 2 (0 < power < 2)");
     42        if(slope<=0) _error2_("slope must be positive");
    4343}
    4444/*}}}*/
    45 /*FUNCTION PowerVariogram::~PowerVariogram(){{{1*/
     45/*FUNCTION PowerVariogram::~PowerVariogram(){{{*/
    4646PowerVariogram::~PowerVariogram(){
    4747        return;
     
    5050
    5151/*Object virtual functions definitions:*/
    52 /*FUNCTION PowerVariogram::Echo {{{1*/
     52/*FUNCTION PowerVariogram::Echo {{{*/
    5353void PowerVariogram::Echo(void){
    54         printf("PowerVariogram\n");
    55         printf("   nugget: %g\n",this->nugget);
    56         printf("   slope : %g\n",this->slope);
    57         printf("   power : %g\n",this->power);
     54        _printLine_("PowerVariogram");
     55        _printLine_("   nugget: " << this->nugget);
     56        _printLine_("   slope : " << this->slope);
     57        _printLine_("   power : " << this->power);
    5858}
    5959/*}}}*/
    6060
    6161/*Variogram function*/
    62 /*FUNCTION PowerVariogram::Covariance{{{1*/
     62/*FUNCTION PowerVariogram::Covariance{{{*/
    6363double PowerVariogram::Covariance(double deltax,double deltay){
    6464        /*The covariance can be deduced from the variogram from the following
     
    7878}
    7979/*}}}*/
    80 /*FUNCTION PowerVariogram::SemiVariogram{{{1*/
     80/*FUNCTION PowerVariogram::SemiVariogram{{{*/
    8181double PowerVariogram::SemiVariogram(double deltax,double deltay){
    8282        /*http://en.wikipedia.org/wiki/Variogram*/
     
    8989        gamma = this->nugget + this->slope*pow(h,this->power);
    9090
    91         //if(h>1000) printf("gamma = %g h=%g\n",gamma,h);
     91        //if(h>1000) _printLine_("gamma = " << gamma << " h=" << h);
    9292        return gamma;
    9393}
  • issm/trunk/src/c/objects/Kriging/PowerVariogram.h

    r12330 r12706  
    2323                /*Object virtual functions definitions*/
    2424                void  Echo();
    25                 void  DeepEcho(){_error_("Not implemented yet");};
    26                 int   Id(){_error_("Not implemented yet");};
    27                 int   MyRank(){_error_("Not implemented yet");};
    28                 int   ObjectEnum(){_error_("Not implemented yet");};
    29                 Object* copy(){_error_("Not implemented yet");};
     25                void  DeepEcho(){_error2_("Not implemented yet");};
     26                int   Id(){_error2_("Not implemented yet");};
     27                int   MyRank(){_error2_("Not implemented yet");};
     28                int   ObjectEnum(){_error2_("Not implemented yet");};
     29                Object* copy(){_error2_("Not implemented yet");};
    3030
    3131                /*Variogram functions*/
  • issm/trunk/src/c/objects/Kriging/Quadtree.cpp

    r12330 r12706  
    11#include "../objects.h"
    2 /*DOCUMENTATION What is a Quadtree? {{{1
     2
     3/*DOCUMENTATION What is a Quadtree? {{{
    34 * A Quadtree is a very simple way to group vertices according
    45 * to their locations. A square that holds all the points of the mesh
     
    4647 * Using binaries is therefore very easy to locate a vertex in a box:
    4748 * we just need to look at the bits from the left to the right (See ::Add)
    48  }}}1*/
    49 /*MACROS {{{1*/
     49 }}}*/
     50/*MACROS {{{*/
    5051/*
    5152 *
     
    8081
    8182        /*Constructors/Destructors*/
    82 /*FUNCTION Quadtree::Quadtree(){{{1*/
     83/*FUNCTION Quadtree::Quadtree(){{{*/
    8384Quadtree::Quadtree(){
    84         _error_("Constructor not supported");
     85        _error2_("Constructor not supported");
    8586
    8687}
    87 /*}}}1*/
    88 /*FUNCTION Quadtree::Quadtree(double xmin,double xmax,double ymin,double ymax,int maxdepth){{{1*/
     88/*}}}*/
     89/*FUNCTION Quadtree::Quadtree(double xmin,double xmax,double ymin,double ymax,int maxdepth){{{*/
    8990Quadtree::Quadtree(double xmin,double xmax,double ymin,double ymax,int maxdepth){
    9091
     
    104105        this->root=NewQuadtreeBox(xmin+length/2,ymin+length/2,length);
    105106}
    106 /*}}}1*/
    107         /*FUNCTION Quadtree::~Quadtree(){{{1*/
     107/*}}}*/
     108        /*FUNCTION Quadtree::~Quadtree(){{{*/
    108109        Quadtree::~Quadtree(){
    109110
     
    112113
    113114        }
    114         /*}}}1*/
     115        /*}}}*/
    115116
    116117        /*Methods*/
    117 /*FUNCTION Quadtree::Add{{{1*/
     118/*FUNCTION Quadtree::Add{{{*/
    118119void  Quadtree::Add(Observation* observation){
    119120
     
    198199
    199200}/*}}}*/
    200 /*FUNCTION Quadtree::AddAndAverage{{{1*/
     201/*FUNCTION Quadtree::AddAndAverage{{{*/
    201202void Quadtree::AddAndAverage(double x,double y,double value){
    202203
     
    247248        }
    248249        else{
    249                 _error_("Box is not full");
    250         }
    251 }/*}}}*/
    252 /*FUNCTION Quadtree::ClosestObs{{{1*/
     250                _error2_("Box is not full");
     251        }
     252}/*}}}*/
     253/*FUNCTION Quadtree::ClosestObs{{{*/
    253254void Quadtree::ClosestObs(int *pindex,double x,double y){
    254255
     
    293294        *pindex=index;
    294295}/*}}}*/
    295 /*FUNCTION Quadtree::Echo{{{1*/
     296/*FUNCTION Quadtree::Echo{{{*/
    296297void  Quadtree::Echo(void){
    297298
    298         printf("Quadtree:\n");
    299         printf("   MaxDepth      = %i\n",this->MaxDepth);
    300         printf("   NbQuadtreeBox = %i\n",this->NbQuadtreeBox);
    301         printf("   NbObs         = %i\n",this->NbObs);
    302         printf("   root          = %p\n",this->root);
    303 
    304 }/*}}}*/
    305 /*FUNCTION Quadtree::DeepEcho{{{1*/
     299        _printLine_("Quadtree:");
     300        _printLine_("   MaxDepth      = " << this->MaxDepth);
     301        _printLine_("   NbQuadtreeBox = " << this->NbQuadtreeBox);
     302        _printLine_("   NbObs         = " << this->NbObs);
     303        _printLine_("   root          = " << this->root);
     304
     305}/*}}}*/
     306/*FUNCTION Quadtree::DeepEcho{{{*/
    306307void  Quadtree::DeepEcho(void){
    307308
    308         printf("Quadtree:\n");
    309         printf("   MaxDepth      = %i\n",this->MaxDepth);
    310         printf("   NbQuadtreeBox = %i\n",this->NbQuadtreeBox);
    311         printf("   NbObs         = %i\n",this->NbObs);
    312         printf("   root          = %p\n",this->root);
     309        _printLine_("Quadtree:");
     310        _printLine_("   MaxDepth      = " << this->MaxDepth);
     311        _printLine_("   NbQuadtreeBox = " << this->NbQuadtreeBox);
     312        _printLine_("   NbObs         = " << this->NbObs);
     313        _printLine_("   root          = " << this->root);
    313314        boxcontainer->Echo();
    314315
    315316}/*}}}*/
    316 /*FUNCTION Quadtree::IntergerCoordinates{{{1*/
     317/*FUNCTION Quadtree::IntergerCoordinates{{{*/
    317318void  Quadtree::IntergerCoordinates(int *xi,int *yi,double x,double y){
    318319
     
    338339        *yi=int(coefficient*(y - ymin));
    339340}/*}}}*/
    340 /*FUNCTION Quadtree::NewQuadtreeBox(double xcenter,double ycenter,double length){{{1*/
     341/*FUNCTION Quadtree::NewQuadtreeBox(double xcenter,double ycenter,double length){{{*/
    341342Quadtree::QuadtreeBox* Quadtree::NewQuadtreeBox(double xcenter,double ycenter,double length){
    342343
     
    362363        return newbox;
    363364}/*}}}*/
    364 /*FUNCTION Quadtree::NewQuadtreeBox(QuadtreeBox* master,int index) {{{1*/
     365/*FUNCTION Quadtree::NewQuadtreeBox(QuadtreeBox* master,int index) {{{*/
    365366Quadtree::QuadtreeBox* Quadtree::NewQuadtreeBox(QuadtreeBox* master,int index){
    366367
     
    396397                        break;
    397398                default:
    398                         _error_("Case %i not supported",index);
     399                        _error2_("Case " << index << " not supported");
    399400        }
    400401        newbox->length=master->length/2;
     
    407408        return newbox;
    408409}/*}}}*/
    409 /*FUNCTION Quadtree::QuadtreeDepth{{{1*/
     410/*FUNCTION Quadtree::QuadtreeDepth{{{*/
    410411void Quadtree::QuadtreeDepth(int* A,int xi,int yi){
    411412
     
    435436        *A=level;
    436437}/*}}}*/
    437 /*FUNCTION Quadtree::QuadtreeDepth2{{{1*/
     438/*FUNCTION Quadtree::QuadtreeDepth2{{{*/
    438439void Quadtree::QuadtreeDepth2(int* A,int xi,int yi){
    439440
     
    488489        *A=level;
    489490}/*}}}*/
    490 /*FUNCTION Quadtree::RangeSearch{{{1*/
     491/*FUNCTION Quadtree::RangeSearch{{{*/
    491492void Quadtree::RangeSearch(int **pindices,int *pnobs,double x,double y,double range){
    492493
     
    496497
    497498        /*Allocate indices (maximum by default*/
    498         if(this->NbObs) indices = (int*)xmalloc(this->NbObs*sizeof(int));
     499        if(this->NbObs) indices = xNew<int>(this->NbObs);
    499500        nobs = 0;
    500501
     
    508509
    509510/*QuadtreeBox methos*/
    510 /*FUNCTION QuadtreeBox::Echo{{{1*/
     511/*FUNCTION QuadtreeBox::Echo{{{*/
    511512void  Quadtree::QuadtreeBox::Echo(void){
    512513
    513         printf("QuadtreeBox:\n");
    514         printf("   nbitems = %i\n",this->nbitems);
    515         printf("   xcenter = %g\n",this->xcenter);
    516         printf("   ycenter = %g\n",this->ycenter);
    517         printf("   length  = %g\n",this->length);
    518 
    519 }/*}}}*/
    520 /*FUNCTION QuadtreeBox::IsWithinRange{{{1*/
     514        _printLine_("QuadtreeBox:");
     515        _printLine_("   nbitems = " << this->nbitems);
     516        _printLine_("   xcenter = " << this->xcenter);
     517        _printLine_("   ycenter = " << this->ycenter);
     518        _printLine_("   length  = " << this->length);
     519
     520}/*}}}*/
     521/*FUNCTION QuadtreeBox::IsWithinRange{{{*/
    521522int Quadtree::QuadtreeBox::IsWithinRange(double x,double y,double range){
    522523
     
    537538
    538539}/*}}}*/
    539 /*FUNCTION QuadtreeBox::RangeSearch{{{1*/
     540/*FUNCTION QuadtreeBox::RangeSearch{{{*/
    540541void Quadtree::QuadtreeBox::RangeSearch(int* indices,int *pnobs,double x,double y,double range){
    541542
     
    573574                        break;
    574575                default:
    575                         _error_("Case %i not supported",this->IsWithinRange(x,y,range));
     576                        _error2_("Case " << this->IsWithinRange(x,y,range) << " not supported");
    576577        }
    577578
     
    579580        *pnobs=nobs;
    580581}/*}}}*/
    581 /*FUNCTION QuadtreeBox::WriteObservations{{{1*/
     582/*FUNCTION QuadtreeBox::WriteObservations{{{*/
    582583void Quadtree::QuadtreeBox::WriteObservations(int* indices,int *pnobs){
    583584
  • issm/trunk/src/c/objects/Kriging/Quadtree.h

    r12330 r12706  
    2727                                /*Object functions (Needed because the Quadtree uses a Container*/
    2828                                void    Echo();
    29                                 void    DeepEcho()  {_error_("not implemented yet"); };
    30                                 int     Id()        {_error_("not implemented yet"); };
    31                                 int     MyRank()    {_error_("not implemented yet"); };
    32                                 int     ObjectEnum(){_error_("not implemented yet"); };
    33                                 Object *copy()      {_error_("not implemented yet"); };
     29                                void    DeepEcho()  {_error2_("not implemented yet"); };
     30                                int     Id()        {_error2_("not implemented yet"); };
     31                                int     MyRank()    {_error2_("not implemented yet"); };
     32                                int     ObjectEnum(){_error2_("not implemented yet"); };
     33                                Object *copy()      {_error2_("not implemented yet"); };
    3434
    3535                                /*Methods*/
     
    4646                int          MaxDepth;          // maximum number of subdivision
    4747                QuadtreeBox *root;              // main box
    48                 long         NbQuadtreeBox;     // total number of boxes
    49                 long         NbObs;             // number of points
     48                int          NbQuadtreeBox;     // total number of boxes
     49                int          NbObs;             // number of points
    5050
    5151                Quadtree();
  • issm/trunk/src/c/objects/Kriging/SphericalVariogram.cpp

    r12330 r12706  
    1717
    1818/*SphericalVariogram constructors and destructor*/
    19 /*FUNCTION SphericalVariogram::SphericalVariogram(){{{1*/
     19/*FUNCTION SphericalVariogram::SphericalVariogram(){{{*/
    2020SphericalVariogram::SphericalVariogram(){
    2121        this->nugget = 0.2;
     
    2525}
    2626/*}}}*/
    27 /*FUNCTION SphericalVariogram::SphericalVariogram(Options* options){{{1*/
     27/*FUNCTION SphericalVariogram::SphericalVariogram(Options* options){{{*/
    2828SphericalVariogram::SphericalVariogram(Options* options){
    2929
     
    3939
    4040        /*Checks*/
    41         if(nugget==sill) _error_("nugget and sill cannot be equal (constant semivariogram not allowed)");
     41        if(nugget==sill) _error2_("nugget and sill cannot be equal (constant semivariogram not allowed)");
    4242}
    4343/*}}}*/
    44 /*FUNCTION SphericalVariogram::~SphericalVariogram(){{{1*/
     44/*FUNCTION SphericalVariogram::~SphericalVariogram(){{{*/
    4545SphericalVariogram::~SphericalVariogram(){
    4646        return;
     
    4949
    5050/*Object virtual functions definitions:*/
    51 /*FUNCTION SphericalVariogram::Echo {{{1*/
     51/*FUNCTION SphericalVariogram::Echo {{{*/
    5252void SphericalVariogram::Echo(void){
    53         printf("SphericalVariogram\n");
    54         printf("   nugget: %g\n",this->nugget);
    55         printf("   sill  : %g\n",this->sill);
    56         printf("   range : %g\n",this->range);
     53        _printLine_("SphericalVariogram");
     54        _printLine_("   nugget: " << this->nugget);
     55        _printLine_("   sill  : " << this->sill);
     56        _printLine_("   range : " << this->range);
    5757}
    5858/*}}}*/
    5959
    6060/*Variogram function*/
    61 /*FUNCTION SphericalVariogram::Covariance{{{1*/
     61/*FUNCTION SphericalVariogram::Covariance{{{*/
    6262double SphericalVariogram::Covariance(double deltax,double deltay){
    6363        /*The covariance can be deduced from the variogram from the following
     
    8080}
    8181/*}}}*/
    82 /*FUNCTION SphericalVariogram::SemiVariogram{{{1*/
     82/*FUNCTION SphericalVariogram::SemiVariogram{{{*/
    8383double SphericalVariogram::SemiVariogram(double deltax,double deltay){
    8484        /*http://en.wikipedia.org/wiki/Variogram*/
  • issm/trunk/src/c/objects/Kriging/SphericalVariogram.h

    r12330 r12706  
    2323                /*Object virtual functions definitions*/
    2424                void  Echo();
    25                 void  DeepEcho(){_error_("Not implemented yet");};
    26                 int   Id(){_error_("Not implemented yet");};
    27                 int   MyRank(){_error_("Not implemented yet");};
    28                 int   ObjectEnum(){_error_("Not implemented yet");};
    29                 Object* copy(){_error_("Not implemented yet");};
     25                void  DeepEcho(){_error2_("Not implemented yet");};
     26                int   Id(){_error2_("Not implemented yet");};
     27                int   MyRank(){_error2_("Not implemented yet");};
     28                int   ObjectEnum(){_error2_("Not implemented yet");};
     29                Object* copy(){_error2_("Not implemented yet");};
    3030
    3131                /*Variogram functions*/
  • issm/trunk/src/c/objects/Loads/Friction.cpp

    r11237 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*Constructors/destructors*/
    23 /*FUNCTION Friction::Friction() {{{1*/
     23/*FUNCTION Friction::Friction() {{{*/
    2424Friction::Friction(){
    2525        this->element_type=NULL;
     
    2828}
    2929/*}}}*/
    30 /*FUNCTION Friction::Friction(const char* element_type, Inputs* inputs,Matpar* matpar,int analysis_type){{{1*/
     30/*FUNCTION Friction::Friction(const char* element_type, Inputs* inputs,Matpar* matpar,int analysis_type){{{*/
    3131Friction::Friction(const char* element_type_in,Inputs* inputs_in,Matpar* matpar_in, int in_analysis_type){
    3232
    3333        this->analysis_type=in_analysis_type;
    3434        this->inputs=inputs_in;
    35         this->element_type=(char*)xmalloc((strlen(element_type_in)+1)*sizeof(char));
    36         memcpy(this->element_type,element_type_in,(strlen(element_type_in)+1)*sizeof(char));
     35        this->element_type=xNew<char>(strlen(element_type_in)+1);
     36        xMemCpy<char>(this->element_type,element_type_in,(strlen(element_type_in)+1));
    3737
    3838        this->matpar=matpar_in;
    3939}
    4040/*}}}*/
    41 /*FUNCTION Friction::~Friction() {{{1*/
     41/*FUNCTION Friction::~Friction() {{{*/
    4242Friction::~Friction(){
    43         xfree((void**)&element_type);
     43        xDelete<char>(element_type);
    4444}
    4545/*}}}*/
    4646
    4747/*methods: */
    48 /*FUNCTION Friction::Echo {{{1*/
     48/*FUNCTION Friction::Echo {{{*/
    4949void Friction::Echo(void){
    50         printf("Friction:\n");
    51         printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
    52         printf("   element_type: %s\n",this->element_type);
     50        _printLine_("Friction:");
     51        _printLine_("   analysis_type: " << EnumToStringx(analysis_type));
     52        _printLine_("   element_type: " << this->element_type);
    5353        inputs->Echo();
    5454        matpar->Echo();
    5555}
    5656/*}}}*/
    57 /*FUNCTION Friction::GetAlpha2(double* palpha2, GaussTria* gauss,int vxenum,int vyenum,int vzenum){{{1*/
    58 void Friction::GetAlpha2(double* palpha2, GaussTria* gauss,int vxenum,int vyenum,int vzenum){
     57/*FUNCTION Friction::GetAlpha2(IssmDouble* palpha2, GaussTria* gauss,int vxenum,int vyenum,int vzenum){{{*/
     58void Friction::GetAlpha2(IssmDouble* palpha2, GaussTria* gauss,int vxenum,int vyenum,int vzenum){
    5959
    6060        /*This routine calculates the basal friction coefficient
     
    6262
    6363        /*diverse: */
    64         double  r,s;
    65         double  drag_p, drag_q;
    66         double  gravity,rho_ice,rho_water;
    67         double  Neff;
    68         double  thickness,bed;
    69         double  vx,vy,vz,vmag;
    70         double  drag_coefficient;
    71         double  alpha2;
     64        IssmDouble  r,s;
     65        IssmDouble  drag_p, drag_q;
     66        IssmDouble  gravity,rho_ice,rho_water;
     67        IssmDouble  Neff;
     68        IssmDouble  thickness,bed;
     69        IssmDouble  vx,vy,vz,vmag;
     70        IssmDouble  drag_coefficient;
     71        IssmDouble  alpha2;
    7272
    7373        /*Recover parameters: */
     
    107107                vmag=sqrt(pow(vx,2)+pow(vy,2)+pow(vz,2));
    108108        }
    109         else _error_("element_type %s not supported yet",element_type);
     109        else _error2_("element_type "<< element_type << " not supported yet");
    110110
    111111        /*Checks that s-1>0 if v=0*/
    112         if(vmag==0 && (s-1)<0) _error_("velocity is 0 ans (s-1)=%g<0, alpha_complement is Inf",s-1);
     112        if(vmag==0 && (s-1)<0) _error2_("velocity is 0 and (s-1)=" << (s-1) << "<0, alpha_complement is Inf");
    113113
    114114        alpha2=pow(drag_coefficient,2)*pow(Neff,r)*pow(vmag,(s-1));
    115         _assert_(!isnan(alpha2));
     115        _assert_(!xIsNan<IssmDouble>(alpha2));
    116116
    117117        /*Assign output pointers:*/
     
    119119}
    120120/*}}}*/
    121 /*FUNCTION Friction::GetAlpha2(double* palpha2, GaussPenta* gauss,int vxenum,int vyenum,int vzenum){{{1*/
    122 void Friction::GetAlpha2(double* palpha2, GaussPenta* gauss,int vxenum,int vyenum,int vzenum){
     121/*FUNCTION Friction::GetAlpha2(IssmDouble* palpha2, GaussPenta* gauss,int vxenum,int vyenum,int vzenum){{{*/
     122void Friction::GetAlpha2(IssmDouble* palpha2, GaussPenta* gauss,int vxenum,int vyenum,int vzenum){
    123123
    124124        /*This routine calculates the basal friction coefficient
     
    126126
    127127        /*diverse: */
    128         double  r,s;
    129         double  drag_p, drag_q;
    130         double  gravity,rho_ice,rho_water;
    131         double  Neff;
    132         double  thickness,bed;
    133         double  vx,vy,vz,vmag;
    134         double  drag_coefficient;
    135         double  alpha2;
     128        IssmDouble  r,s;
     129        IssmDouble  drag_p, drag_q;
     130        IssmDouble  gravity,rho_ice,rho_water;
     131        IssmDouble  Neff;
     132        IssmDouble  thickness,bed;
     133        IssmDouble  vx,vy,vz,vmag;
     134        IssmDouble  drag_coefficient;
     135        IssmDouble  alpha2;
    136136
    137137        /*Recover parameters: */
     
    171171                vmag=sqrt(pow(vx,2)+pow(vy,2)+pow(vz,2));
    172172        }
    173         else _error_("element_type %s not supported yet",element_type);
     173        else _error2_("element_type "<< element_type << " not supported yet");
    174174
    175175        /*Checks that s-1>0 if v=0*/
    176         if(vmag==0 && (s-1)<0) _error_("velocity is 0 ans (s-1)=%g<0, alpha_complement is Inf",s-1);
     176        if(vmag==0 && (s-1)<0) _error2_("velocity is 0 and (s-1)=" << (s-1) << "<0, alpha_complement is Inf");
    177177
    178178        alpha2=pow(drag_coefficient,2)*pow(Neff,r)*pow(vmag,(s-1));
    179         _assert_(!isnan(alpha2));
     179        _assert_(!xIsNan<IssmDouble>(alpha2));
    180180
    181181        /*Assign output pointers:*/
     
    183183}
    184184/*}}}*/
    185 /*FUNCTION Friction::GetAlphaComplement(double* palpha_complement, GaussTria* gauss,int vxenum,int vyenum,int vzenum) {{{1*/
    186 void Friction::GetAlphaComplement(double* palpha_complement, GaussTria* gauss,int vxenum,int vyenum,int vzenum){
     185/*FUNCTION Friction::GetAlphaComplement(IssmDouble* palpha_complement, GaussTria* gauss,int vxenum,int vyenum,int vzenum) {{{*/
     186void Friction::GetAlphaComplement(IssmDouble* palpha_complement, GaussTria* gauss,int vxenum,int vyenum,int vzenum){
    187187
    188188        /* FrictionGetAlpha2 computes alpha2= drag^2 * Neff ^r * vel ^s, with Neff=rho_ice*g*thickness+rho_ice*g*bed, r=q/p and s=1/p.
     
    192192        /*diverse: */
    193193        int     i;
    194         double  r,s;
    195         double  vx,vy,vz,vmag;
    196         double  drag_p,drag_q;
    197         double  Neff;
    198         double  drag_coefficient;
    199         double  bed,thickness;
    200         double  gravity,rho_ice,rho_water;
    201         double  alpha_complement;
     194        IssmDouble  r,s;
     195        IssmDouble  vx,vy,vz,vmag;
     196        IssmDouble  drag_p,drag_q;
     197        IssmDouble  Neff;
     198        IssmDouble  drag_coefficient;
     199        IssmDouble  bed,thickness;
     200        IssmDouble  gravity,rho_ice,rho_water;
     201        IssmDouble  alpha_complement;
    202202
    203203        /*Recover parameters: */
     
    238238                vmag=sqrt(pow(vx,2)+pow(vy,2)+pow(vz,2));
    239239        }
    240         else _error_("element_type %s not supported yet",element_type);
     240        else _error2_("element_type "<< element_type << " not supported yet");
    241241
    242242        /*Checks that s-1>0 if v=0*/
    243         if(vmag==0 && (s-1)<0) _error_("velocity is 0 ans (s-1)=%g<0, alpha_complement is Inf",s-1);
    244 
    245         alpha_complement=pow(Neff,r)*pow(vmag,(s-1));            _assert_(!isnan(alpha_complement));
     243        if(vmag==0 && (s-1)<0) _error2_("velocity is 0 and (s-1)=" << (s-1) << "<0, alpha_complement is Inf");
     244
     245        alpha_complement=pow(Neff,r)*pow(vmag,(s-1));            _assert_(!xIsNan<IssmDouble>(alpha_complement));
    246246
    247247        /*Assign output pointers:*/
     
    249249}
    250250/*}}}*/
    251 /*FUNCTION Friction::GetAlphaComplement(double* palpha_complement, GaussPenta* gauss,int vxenum,int vyenum,int vzenum) {{{1*/
    252 void Friction::GetAlphaComplement(double* palpha_complement, GaussPenta* gauss,int vxenum,int vyenum,int vzenum){
     251/*FUNCTION Friction::GetAlphaComplement(IssmDouble* palpha_complement, GaussPenta* gauss,int vxenum,int vyenum,int vzenum) {{{*/
     252void Friction::GetAlphaComplement(IssmDouble* palpha_complement, GaussPenta* gauss,int vxenum,int vyenum,int vzenum){
    253253
    254254        /* FrictionGetAlpha2 computes alpha2= drag^2 * Neff ^r * vel ^s, with Neff=rho_ice*g*thickness+rho_ice*g*bed, r=q/p and s=1/p.
     
    258258        /*diverse: */
    259259        int     i;
    260         double  r,s;
    261         double  vx,vy,vz,vmag;
    262         double  drag_p,drag_q;
    263         double  Neff;
    264         double  drag_coefficient;
    265         double  bed,thickness;
    266         double  gravity,rho_ice,rho_water;
    267         double  alpha_complement;
     260        IssmDouble  r,s;
     261        IssmDouble  vx,vy,vz,vmag;
     262        IssmDouble  drag_p,drag_q;
     263        IssmDouble  Neff;
     264        IssmDouble  drag_coefficient;
     265        IssmDouble  bed,thickness;
     266        IssmDouble  gravity,rho_ice,rho_water;
     267        IssmDouble  alpha_complement;
    268268
    269269        /*Recover parameters: */
     
    304304                vmag=sqrt(pow(vx,2)+pow(vy,2)+pow(vz,2));
    305305        }
    306         else _error_("element_type %s not supported yet",element_type);
     306        else _error2_("element_type "<< element_type << " not supported yet");
    307307
    308308        /*Checks that s-1>0 if v=0*/
    309         if(vmag==0 && (s-1)<0) _error_("velocity is 0 ans (s-1)=%g<0, alpha_complement is Inf",s-1);
    310 
    311         alpha_complement=pow(Neff,r)*pow(vmag,(s-1));            _assert_(!isnan(alpha_complement));
     309        if(vmag==0 && (s-1)<0) _error2_("velocity is 0 and (s-1)=" << (s-1) << "<0, alpha_complement is Inf");
     310
     311        alpha_complement=pow(Neff,r)*pow(vmag,(s-1));            _assert_(!xIsNan<IssmDouble>(alpha_complement));
    312312
    313313        /*Assign output pointers:*/
     
    315315}
    316316/*}}}*/
    317 /*FUNCTION Friction::GetInputValue{{{1*/
    318 void Friction::GetInputValue(double* pvalue,GaussTria* gauss,int enum_type){
     317/*FUNCTION Friction::GetInputValue{{{*/
     318void Friction::GetInputValue(IssmDouble* pvalue,GaussTria* gauss,int enum_type){
    319319
    320320        Input* input=inputs->GetInput(enum_type);
    321         if(!input) _error_("input %s not found",EnumToStringx(enum_type));
     321        if(!input) _error2_("input " << EnumToStringx(enum_type) << " not found");
    322322        input->GetInputValue(pvalue,gauss);
    323323
    324324}
    325325/*}}}*/
    326 /*FUNCTION Friction::GetInputValue{{{1*/
    327 void Friction::GetInputValue(double* pvalue,GaussPenta* gauss,int enum_type){
     326/*FUNCTION Friction::GetInputValue{{{*/
     327void Friction::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,int enum_type){
    328328
    329329        Input* input=inputs->GetInput(enum_type);
    330         if(!input) _error_("input %s not found",EnumToStringx(enum_type));
     330        if(!input) _error2_("input " << EnumToStringx(enum_type) << " not found");
    331331        input->GetInputValue(pvalue,gauss);
    332332
  • issm/trunk/src/c/objects/Loads/Friction.h

    r11237 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010class Inputs;
    1111class Matpar;
     
    2727       
    2828                void  Echo(void);
    29                 void  GetAlpha2(double* palpha2, GaussTria* gauss,int vxenum,int vyenum,int vzenum);
    30                 void  GetAlpha2(double* palpha2, GaussPenta* gauss,int vxenum,int vyenum,int vzenum);
    31                 void  GetAlphaComplement(double* alpha_complement, GaussTria* gauss,int vxenum,int vyenum,int vzenum);
    32                 void  GetAlphaComplement(double* alpha_complement, GaussPenta* gauss,int vxenum,int vyenum,int vzenum);
    33                 void  GetInputValue(double* pvalue,GaussTria* gauss,int enum_type);
    34                 void  GetInputValue(double* pvalue,GaussPenta* gauss,int enum_type);
     29                void  GetAlpha2(IssmDouble* palpha2, GaussTria* gauss,int vxenum,int vyenum,int vzenum);
     30                void  GetAlpha2(IssmDouble* palpha2, GaussPenta* gauss,int vxenum,int vyenum,int vzenum);
     31                void  GetAlphaComplement(IssmDouble* alpha_complement, GaussTria* gauss,int vxenum,int vyenum,int vzenum);
     32                void  GetAlphaComplement(IssmDouble* alpha_complement, GaussPenta* gauss,int vxenum,int vyenum,int vzenum);
     33                void  GetInputValue(IssmDouble* pvalue,GaussTria* gauss,int enum_type);
     34                void  GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,int enum_type);
    3535
    3636};
  • issm/trunk/src/c/objects/Loads/Icefront.cpp

    r12330 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2424
    2525/*Icefront constructors and destructor*/
    26 /*FUNCTION Icefront::Icefront() {{{1*/
     26/*FUNCTION Icefront::Icefront() {{{*/
    2727Icefront::Icefront(){
    2828
     
    3838}
    3939/*}}}*/
    40 /*FUNCTION Icefront::Icefront(int id, int i, IoModel* iomodel,int analysis_type) {{{1*/
     40/*FUNCTION Icefront::Icefront(int id, int i, IoModel* iomodel,int analysis_type) {{{*/
    4141Icefront::Icefront(int icefront_id,int i, IoModel* iomodel,int in_icefront_type, int in_analysis_type){
    4242
     
    6565        }
    6666        _assert_(iomodel->Data(DiagnosticIcefrontEnum));
    67         element=(int)(*(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+segment_width-2)-1); //element is in the penultimate column (node1 node2 ... elem fill)
     67        element=reCast<int,IssmDouble>(*(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+segment_width-2)-1); //element is in the penultimate column (node1 node2 ... elem fill)
    6868
    6969        /*Build ids for hook constructors: */
    70         icefront_eid=(int) *(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+segment_width-2); //matlab indexing
     70        icefront_eid=reCast<int,IssmDouble>( *(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+segment_width-2)); //matlab indexing
    7171        icefront_mparid=numberofelements+1; //matlab indexing
    7272
    7373        if (in_icefront_type==MacAyeal2dIceFrontEnum || in_icefront_type==MacAyeal3dIceFrontEnum){
    74                 icefront_node_ids[0]=iomodel->nodecounter+(int)*(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+0);
    75                 icefront_node_ids[1]=iomodel->nodecounter+(int)*(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+1);
     74                icefront_node_ids[0]=iomodel->nodecounter+reCast<int>(*(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+0));
     75                icefront_node_ids[1]=iomodel->nodecounter+reCast<int>(*(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+1));
    7676        }
    7777        else if (in_icefront_type==PattynIceFrontEnum || in_icefront_type==StokesIceFrontEnum){
    78                 icefront_node_ids[0]=iomodel->nodecounter+(int)*(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+0);
    79                 icefront_node_ids[1]=iomodel->nodecounter+(int)*(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+1);
    80                 icefront_node_ids[2]=iomodel->nodecounter+(int)*(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+2);
    81                 icefront_node_ids[3]=iomodel->nodecounter+(int)*(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+3);
    82         }
    83         else _error_("in_icefront_type %s not supported yet!",EnumToStringx(in_icefront_type));
     78                icefront_node_ids[0]=iomodel->nodecounter+reCast<int>(*(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+0));
     79                icefront_node_ids[1]=iomodel->nodecounter+reCast<int>(*(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+1));
     80                icefront_node_ids[2]=iomodel->nodecounter+reCast<int>(*(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+2));
     81                icefront_node_ids[3]=iomodel->nodecounter+reCast<int>(*(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+3));
     82        }
     83        else _error2_("in_icefront_type " << EnumToStringx(in_icefront_type) << " not supported yet!");
    8484
    8585        if (in_icefront_type==PattynIceFrontEnum || in_icefront_type==StokesIceFrontEnum)
     
    8989
    9090        /*Fill*/
    91         icefront_fill=(int)iomodel->Data(DiagnosticIcefrontEnum)[segment_width*i+segment_width-1];
     91        icefront_fill=reCast<int>(iomodel->Data(DiagnosticIcefrontEnum)[segment_width*i+segment_width-1]);
    9292       
    9393        /*Ok, we have everything to build the object: */
     
    114114
    115115/*}}}*/
    116 /*FUNCTION Icefront::~Icefront() {{{1*/
     116/*FUNCTION Icefront::~Icefront() {{{*/
    117117Icefront::~Icefront(){
    118118        delete inputs;
     
    125125
    126126/*Object virtual functions definitions:*/
    127 /*FUNCTION Icefront::Echo {{{1*/
     127/*FUNCTION Icefront::Echo {{{*/
    128128void Icefront::Echo(void){
    129         printf("Icefront:\n");
    130         printf("   id: %i\n",id);
    131         printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
     129        _printLine_("Icefront:");
     130        _printLine_("   id: " << id);
     131        _printLine_("   analysis_type: " << EnumToStringx(analysis_type));
    132132        hnodes->Echo();
    133133        helement->Echo();
    134134        hmatpar->Echo();
    135         printf("   parameters: %p\n",parameters);
     135        _printLine_("   parameters: " << parameters);
    136136        if(parameters)parameters->Echo();
    137         printf("   inputs: %p\n",inputs);
     137        _printLine_("   inputs: " << inputs);
    138138        if(inputs)inputs->Echo();
    139139}
    140140/*}}}*/
    141 /*FUNCTION Icefront::DeepEcho{{{1*/
     141/*FUNCTION Icefront::DeepEcho{{{*/
    142142void Icefront::DeepEcho(void){
    143143
    144         printf("Icefront:\n");
    145         printf("   id: %i\n",id);
    146         printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
     144        _printLine_("Icefront:");
     145        _printLine_("   id: " << id);
     146        _printLine_("   analysis_type: " << EnumToStringx(analysis_type));
    147147        hnodes->DeepEcho();
    148148        helement->DeepEcho();
    149149        hmatpar->DeepEcho();
    150         printf("   parameters: %p\n",parameters);
     150        _printLine_("   parameters: " << parameters);
    151151        if(parameters)parameters->DeepEcho();
    152         printf("   inputs: %p\n",inputs);
     152        _printLine_("   inputs: " << inputs);
    153153        if(inputs)inputs->DeepEcho();
    154154}
    155155/*}}}*/
    156 /*FUNCTION Icefront::Id {{{1*/
     156/*FUNCTION Icefront::Id {{{*/
    157157int    Icefront::Id(void){ return id; }
    158158/*}}}*/
    159 /*FUNCTION Icefront::MyRank {{{1*/
     159/*FUNCTION Icefront::MyRank {{{*/
    160160int    Icefront::MyRank(void){
    161161        extern int my_rank;
     
    163163}
    164164/*}}}*/
    165 /*FUNCTION Icefront::ObjectEnum{{{1*/
     165/*FUNCTION Icefront::ObjectEnum{{{*/
    166166int Icefront::ObjectEnum(void){
    167167
     
    170170}
    171171/*}}}*/
    172 /*FUNCTION Icefront::copy {{{1*/
     172/*FUNCTION Icefront::copy {{{*/
    173173Object* Icefront::copy() {
    174174       
     
    205205
    206206/*Load virtual functions definitions:*/
    207 /*FUNCTION Icefront::Configure {{{1*/
     207/*FUNCTION Icefront::Configure {{{*/
    208208void  Icefront::Configure(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){
    209209
     
    223223}
    224224/*}}}*/
    225 /*FUNCTION Icefront::SetCurrentConfiguration {{{1*/
     225/*FUNCTION Icefront::SetCurrentConfiguration {{{*/
    226226void  Icefront::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){
    227227}
    228228/*}}}*/
    229 /*FUNCTION Icefront::CreateKMatrix {{{1*/
     229/*FUNCTION Icefront::CreateKMatrix {{{*/
    230230void  Icefront::CreateKMatrix(Matrix* Kff, Matrix* Kfs){
    231231
     
    235235}
    236236/*}}}*/
    237 /*FUNCTION Icefront::CreatePVector {{{1*/
     237/*FUNCTION Icefront::CreatePVector {{{*/
    238238void  Icefront::CreatePVector(Vector* pf){
    239239
    240240        /*Checks in debugging mode*/
    241         /*{{{2*/
     241        /*{{{*/
    242242        _assert_(nodes);
    243243        _assert_(element);
     
    263263                #endif
    264264                default:
    265                         _error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
     265                        _error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
    266266        }
    267267
     
    273273}
    274274/*}}}*/
    275 /*FUNCTION Icefront::CreateJacobianMatrix{{{1*/
     275/*FUNCTION Icefront::CreateJacobianMatrix{{{*/
    276276void  Icefront::CreateJacobianMatrix(Matrix* Jff){
    277277        this->CreateKMatrix(Jff,NULL);
    278278}
    279 /*}}}1*/
    280 /*FUNCTION Icefront::PenaltyCreateKMatrix {{{1*/
    281 void  Icefront::PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs, double kmax){
     279/*}}}*/
     280/*FUNCTION Icefront::PenaltyCreateKMatrix {{{*/
     281void  Icefront::PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs, IssmDouble kmax){
    282282        /*do nothing: */
    283283        return;
    284284}
    285285/*}}}*/
    286 /*FUNCTION Icefront::PenaltyCreatePVector{{{1*/
    287 void  Icefront::PenaltyCreatePVector(Vector* pf,double kmax){
     286/*FUNCTION Icefront::PenaltyCreatePVector{{{*/
     287void  Icefront::PenaltyCreatePVector(Vector* pf,IssmDouble kmax){
    288288        /*do nothing: */
    289289        return;
    290290}
    291291/*}}}*/
    292 /*FUNCTION Icefront::PenaltyCreateJacobianMatrix{{{1*/
    293 void  Icefront::PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax){
     292/*FUNCTION Icefront::PenaltyCreateJacobianMatrix{{{*/
     293void  Icefront::PenaltyCreateJacobianMatrix(Matrix* Jff,IssmDouble kmax){
    294294        this->PenaltyCreateKMatrix(Jff,NULL,kmax);
    295295}
    296 /*}}}1*/
    297 /*FUNCTION Icefront::InAnalysis{{{1*/
     296/*}}}*/
     297/*FUNCTION Icefront::InAnalysis{{{*/
    298298bool Icefront::InAnalysis(int in_analysis_type){
    299299        if (in_analysis_type==this->analysis_type)return true;
     
    303303
    304304/*Update virtual functions definitions:*/
    305 /*FUNCTION Icefront::InputUpdateFromVector(double* vector, int name, int type) {{{1*/
    306 void  Icefront::InputUpdateFromVector(double* vector, int name, int type){
    307         /*Nothing updated yet*/
    308 }
    309 /*}}}*/
    310 /*FUNCTION Icefront::InputUpdateFromVector(int* vector, int name, int type) {{{1*/
     305/*FUNCTION Icefront::InputUpdateFromVector(IssmDouble* vector, int name, int type) {{{*/
     306void  Icefront::InputUpdateFromVector(IssmDouble* vector, int name, int type){
     307        /*Nothing updated yet*/
     308}
     309/*}}}*/
     310/*FUNCTION Icefront::InputUpdateFromVector(int* vector, int name, int type) {{{*/
    311311void  Icefront::InputUpdateFromVector(int* vector, int name, int type){
    312312        /*Nothing updated yet*/
    313313}
    314314/*}}}*/
    315 /*FUNCTION Icefront::InputUpdateFromVector(bool* vector, int name, int type) {{{1*/
     315/*FUNCTION Icefront::InputUpdateFromVector(bool* vector, int name, int type) {{{*/
    316316void  Icefront::InputUpdateFromVector(bool* vector, int name, int type){
    317317        /*Nothing updated yet*/
    318318}
    319319/*}}}*/
    320 /*FUNCTION Icefront::InputUpdateFromMatrixDakota(double* matrix, int nrows, int ncols, int name, int type) {{{1*/
    321 void  Icefront::InputUpdateFromMatrixDakota(double* matrix, int nrows, int ncols, int name, int type){
    322         /*Nothing updated yet*/
    323 }
    324 /*}}}*/
    325 /*FUNCTION Icefront::InputUpdateFromVectorDakota(double* vector, int name, int type) {{{1*/
    326 void  Icefront::InputUpdateFromVectorDakota(double* vector, int name, int type){
    327         /*Nothing updated yet*/
    328 }
    329 /*}}}*/
    330 /*FUNCTION Icefront::InputUpdateFromVectorDakota(int* vector, int name, int type) {{{1*/
     320/*FUNCTION Icefront::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type) {{{*/
     321void  Icefront::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type){
     322        /*Nothing updated yet*/
     323}
     324/*}}}*/
     325/*FUNCTION Icefront::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type) {{{*/
     326void  Icefront::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){
     327        /*Nothing updated yet*/
     328}
     329/*}}}*/
     330/*FUNCTION Icefront::InputUpdateFromVectorDakota(int* vector, int name, int type) {{{*/
    331331void  Icefront::InputUpdateFromVectorDakota(int* vector, int name, int type){
    332332        /*Nothing updated yet*/
    333333}
    334334/*}}}*/
    335 /*FUNCTION Icefront::InputUpdateFromVectorDakota(bool* vector, int name, int type) {{{1*/
     335/*FUNCTION Icefront::InputUpdateFromVectorDakota(bool* vector, int name, int type) {{{*/
    336336void  Icefront::InputUpdateFromVectorDakota(bool* vector, int name, int type){
    337337        /*Nothing updated yet*/
    338338}
    339339/*}}}*/
    340 /*FUNCTION Icefront::InputUpdateFromConstant(double constant, int name) {{{1*/
    341 void  Icefront::InputUpdateFromConstant(double constant, int name){
    342         /*Nothing updated yet*/
    343 }
    344 /*}}}*/
    345 /*FUNCTION Icefront::InputUpdateFromConstant(int constant, int name) {{{1*/
     340/*FUNCTION Icefront::InputUpdateFromConstant(IssmDouble constant, int name) {{{*/
     341void  Icefront::InputUpdateFromConstant(IssmDouble constant, int name){
     342        /*Nothing updated yet*/
     343}
     344/*}}}*/
     345/*FUNCTION Icefront::InputUpdateFromConstant(int constant, int name) {{{*/
    346346void  Icefront::InputUpdateFromConstant(int constant, int name){
    347347        /*Nothing updated yet*/
    348348}
    349349/*}}}*/
    350 /*FUNCTION Icefront::InputUpdateFromConstant(bool constant, int name) {{{1*/
     350/*FUNCTION Icefront::InputUpdateFromConstant(bool constant, int name) {{{*/
    351351void  Icefront::InputUpdateFromConstant(bool constant, int name){
    352352        /*Nothing updated yet*/
    353353}
    354354/*}}}*/
    355 /*FUNCTION Icefront::InputUpdateFromSolution{{{1*/
    356 void  Icefront::InputUpdateFromSolution(double* solution){
     355/*FUNCTION Icefront::InputUpdateFromSolution{{{*/
     356void  Icefront::InputUpdateFromSolution(IssmDouble* solution){
    357357        /*Nothing updated yet*/
    358358}
     
    361361/*Icefront numerics: */
    362362#ifdef _HAVE_DIAGNOSTIC_
    363 /*FUNCTION Icefront::CreatePVectorDiagnosticHoriz {{{1*/
     363/*FUNCTION Icefront::CreatePVectorDiagnosticHoriz {{{*/
    364364ElementVector* Icefront::CreatePVectorDiagnosticHoriz(void){
    365365
     
    379379            #endif
    380380                default:
    381                         _error_("Icefront type %s not supported yet",EnumToStringx(type));
    382         }
    383 }
    384 /*}}}*/
    385 /*FUNCTION Icefront::CreatePVectorDiagnosticMacAyeal2d{{{1*/
     381                        _error2_("Icefront type " << EnumToStringx(type) << " not supported yet");
     382        }
     383}
     384/*}}}*/
     385/*FUNCTION Icefront::CreatePVectorDiagnosticMacAyeal2d{{{*/
    386386ElementVector* Icefront::CreatePVectorDiagnosticMacAyeal2d(void){
    387387
     
    392392        /*Intermediary*/
    393393        int        ig,index1,index2,fill;
    394         double     Jdet;
    395         double     thickness,bed,pressure,ice_pressure,rho_water,rho_ice,gravity;
    396         double     water_pressure,air_pressure,surface_under_water,base_under_water;
    397         double     xyz_list[numnodes][3];
    398         double     normal[2];
    399         double     L[2];
     394        IssmDouble     Jdet;
     395        IssmDouble     thickness,bed,pressure,ice_pressure,rho_water,rho_ice,gravity;
     396        IssmDouble     water_pressure,air_pressure,surface_under_water,base_under_water;
     397        IssmDouble     xyz_list[numnodes][3];
     398        IssmDouble     normal[2];
     399        IssmDouble     L[2];
    400400        GaussTria *gauss;
    401401
     
    441441                                break;
    442442                        default:
    443                                 _error_("fill type %s not supported yet",EnumToStringx(fill));
     443                                _error2_("fill type " << EnumToStringx(fill) << " not supported yet");
    444444                }
    445445                ice_pressure=1.0/2.0*gravity*rho_ice*pow(thickness,2);
     
    467467
    468468#ifdef _HAVE_CONTROL_
    469 /*FUNCTION Icefront::CreatePVectorAdjointHoriz {{{1*/
     469/*FUNCTION Icefront::CreatePVectorAdjointHoriz {{{*/
    470470ElementVector* Icefront::CreatePVectorAdjointHoriz(void){
    471471
     
    476476#endif
    477477#ifdef _HAVE_3D_
    478 /*FUNCTION Icefront::CreatePVectorDiagnosticMacAyeal3d{{{1*/
     478/*FUNCTION Icefront::CreatePVectorDiagnosticMacAyeal3d{{{*/
    479479ElementVector* Icefront::CreatePVectorDiagnosticMacAyeal3d(void){
    480480
     
    504504}
    505505/*}}}*/
    506 /*FUNCTION Icefront::CreatePVectorDiagnosticPattyn{{{1*/
     506/*FUNCTION Icefront::CreatePVectorDiagnosticPattyn{{{*/
    507507ElementVector* Icefront::CreatePVectorDiagnosticPattyn(void){
    508508
     
    513513        int         i,j,ig,index1,index2,index3,index4;
    514514        int         fill;
    515         double      surface,pressure,ice_pressure,rho_water,rho_ice,gravity;
    516         double      water_pressure,air_pressure;
    517         double      Jdet,z_g;
    518         double      xyz_list[NUMVERTICESQUA][3];
    519         double      normal[3];
    520         double      l1l4[4];
     515        IssmDouble      surface,pressure,ice_pressure,rho_water,rho_ice,gravity;
     516        IssmDouble      water_pressure,air_pressure;
     517        IssmDouble      Jdet,z_g;
     518        IssmDouble      xyz_list[NUMVERTICESQUA][3];
     519        IssmDouble      normal[3];
     520        IssmDouble      l1l4[4];
    521521        GaussPenta *gauss = NULL;
    522522
     
    543543
    544544        /* Start  looping on the number of gaussian points: */
    545         double zmax=xyz_list[0][2]; for(i=1;i<NUMVERTICESQUA;i++) if(xyz_list[i][2]>zmax) zmax=xyz_list[i][2];
    546         double zmin=xyz_list[0][2]; for(i=1;i<NUMVERTICESQUA;i++) if(xyz_list[i][2]<zmin) zmin=xyz_list[i][2];
     545        IssmDouble zmax=xyz_list[0][2]; for(i=1;i<NUMVERTICESQUA;i++) if(xyz_list[i][2]>zmax) zmax=xyz_list[i][2];
     546        IssmDouble zmin=xyz_list[0][2]; for(i=1;i<NUMVERTICESQUA;i++) if(xyz_list[i][2]<zmin) zmin=xyz_list[i][2];
    547547        if(zmax>0 && zmin<0) gauss=new GaussPenta(index1,index2,index3,index4,3,10); //refined in vertical because of the sea level discontinuity
    548548        else                 gauss=new GaussPenta(index1,index2,index3,index4,3,3);
     
    564564                                break;
    565565                        default:
    566                                 _error_("fill type %s not supported yet",EnumToStringx(fill));
     566                                _error2_("fill type " << EnumToStringx(fill) << " not supported yet");
    567567                }
    568568                ice_pressure=rho_ice*gravity*(surface-z_g);
     
    581581}
    582582/*}}}*/
    583 /*FUNCTION Icefront::CreatePVectorDiagnosticStokes{{{1*/
     583/*FUNCTION Icefront::CreatePVectorDiagnosticStokes{{{*/
    584584ElementVector* Icefront::CreatePVectorDiagnosticStokes(void){
    585585
     
    590590        int         i,j,ig,index1,index2,index3,index4;
    591591        int         fill;
    592         double      pressure,rho_water,gravity;
    593         double      water_pressure,air_pressure;
    594         double      Jdet,z_g;
    595         double      xyz_list[NUMVERTICESQUA][3];
    596         double      normal[3];
    597         double      l1l4[4];
     592        IssmDouble      pressure,rho_water,gravity;
     593        IssmDouble      water_pressure,air_pressure;
     594        IssmDouble      Jdet,z_g;
     595        IssmDouble      xyz_list[NUMVERTICESQUA][3];
     596        IssmDouble      normal[3];
     597        IssmDouble      l1l4[4];
    598598        GaussPenta *gauss = NULL;
    599599
     
    618618
    619619        /* Start  looping on the number of gaussian points: */
    620         double zmax=xyz_list[0][2]; for(i=1;i<NUMVERTICESQUA;i++) if(xyz_list[i][2]>zmax) zmax=xyz_list[i][2];
    621         double zmin=xyz_list[0][2]; for(i=1;i<NUMVERTICESQUA;i++) if(xyz_list[i][2]<zmin) zmin=xyz_list[i][2];
     620        IssmDouble zmax=xyz_list[0][2]; for(i=1;i<NUMVERTICESQUA;i++) if(xyz_list[i][2]>zmax) zmax=xyz_list[i][2];
     621        IssmDouble zmin=xyz_list[0][2]; for(i=1;i<NUMVERTICESQUA;i++) if(xyz_list[i][2]<zmin) zmin=xyz_list[i][2];
    622622        if(zmax>0 && zmin<0) gauss=new GaussPenta(index1,index2,index3,index4,3,30); //refined in vertical because of the sea level discontinuity
    623623        else                 gauss=new GaussPenta(index1,index2,index3,index4,3,3);
     
    638638                                break;
    639639                        default:
    640                                 _error_("fill type %s not supported yet",EnumToStringx(fill));
     640                                _error2_("fill type " << EnumToStringx(fill) << " not supported yet");
    641641                }
    642642                air_pressure=0;
     
    660660/*}}}*/
    661661#endif
    662 /*FUNCTION Icefront::GetDofList {{{1*/
     662/*FUNCTION Icefront::GetDofList {{{*/
    663663void  Icefront::GetDofList(int** pdoflist,int approximation_enum,int setenum){
    664664
     
    691691
    692692        /*Allocate: */
    693         doflist=(int*)xmalloc(numberofdofs*sizeof(int));
     693        doflist=xNew<int>(numberofdofs);
    694694
    695695        /*Populate: */
     
    704704}
    705705/*}}}*/
    706 /*FUNCTION Icefront::GetSegmentNormal {{{1*/
    707 void Icefront:: GetSegmentNormal(double* normal,double xyz_list[4][3]){
     706/*FUNCTION Icefront::GetSegmentNormal {{{*/
     707void Icefront:: GetSegmentNormal(IssmDouble* normal,IssmDouble xyz_list[4][3]){
    708708
    709709        /*Build unit outward pointing vector*/
    710710        const int numnodes=NUMVERTICESSEG;
    711         double vector[2];
    712         double norm;
     711        IssmDouble vector[2];
     712        IssmDouble norm;
    713713
    714714        vector[0]=xyz_list[1][0] - xyz_list[0][0];
     
    721721}
    722722/*}}}*/
    723 /*FUNCTION Icefront::GetQuadNormal {{{1*/
    724 void Icefront:: GetQuadNormal(double* normal,double xyz_list[4][3]){
     723/*FUNCTION Icefront::GetQuadNormal {{{*/
     724void Icefront:: GetQuadNormal(IssmDouble* normal,IssmDouble xyz_list[4][3]){
    725725
    726726        /*Build unit outward pointing vector*/
    727         double AB[3];
    728         double AC[3];
    729         double norm;
     727        IssmDouble AB[3];
     728        IssmDouble AC[3];
     729        IssmDouble norm;
    730730
    731731        AB[0]=xyz_list[1][0] - xyz_list[0][0];
  • issm/trunk/src/c/objects/Loads/Icefront.h

    r12330 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "./Load.h"
    1111class Hook;
     
    3939                Parameters* parameters;
    4040
    41                 /*Icefront constructors, destructors: {{{1*/
     41                /*Icefront constructors, destructors: {{{*/
    4242                Icefront();
    4343                Icefront(int icefront_id,int i, IoModel* iomodel,int in_icefront_type, int analysis_type);
    4444                ~Icefront();
    4545                /*}}}*/
    46                 /*Object virtual functions definitions:{{{1 */
     46                /*Object virtual functions definitions:{{{ */
    4747                void  Echo();
    4848                void  DeepEcho();
     
    5252                Object* copy();
    5353                /*}}}*/
    54                 /*Update virtual functions definitions: {{{1*/
    55                 void  InputUpdateFromVector(double* vector, int name, int type);
     54                /*Update virtual functions definitions: {{{*/
     55                void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
    5656                void  InputUpdateFromVector(int* vector, int name, int type);
    5757                void  InputUpdateFromVector(bool* vector, int name, int type);
    58                 void  InputUpdateFromMatrixDakota(double* matrix,int ncols,int nrows, int name, int type);
    59                 void  InputUpdateFromVectorDakota(double* vector, int name, int type);
     58                void  InputUpdateFromMatrixDakota(IssmDouble* matrix,int ncols,int nrows, int name, int type);
     59                void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
    6060                void  InputUpdateFromVectorDakota(int* vector, int name, int type);
    6161                void  InputUpdateFromVectorDakota(bool* vector, int name, int type);
    62                 void  InputUpdateFromConstant(double constant, int name);
     62                void  InputUpdateFromConstant(IssmDouble constant, int name);
    6363                void  InputUpdateFromConstant(int constant, int name);
    6464                void  InputUpdateFromConstant(bool constant, int name);
    65                 void  InputUpdateFromSolution(double* solution);
    66                 void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("not implemented yet");};
     65                void  InputUpdateFromSolution(IssmDouble* solution);
     66                void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error2_("not implemented yet");};
    6767                /*}}}*/
    68                 /*Load virtual functions definitions: {{{1*/
     68                /*Load virtual functions definitions: {{{*/
    6969                void  Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
    7070                void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
     
    7272                void  CreatePVector(Vector* pf);
    7373                void  CreateJacobianMatrix(Matrix* Jff);
    74                 void  PenaltyCreateKMatrix(Matrix* Kff, Matrix* kfs, double kmax);
    75                 void  PenaltyCreatePVector(Vector*  pf, double kmax);
    76                 void  PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax);
     74                void  PenaltyCreateKMatrix(Matrix* Kff, Matrix* kfs, IssmDouble kmax);
     75                void  PenaltyCreatePVector(Vector*  pf, IssmDouble kmax);
     76                void  PenaltyCreateJacobianMatrix(Matrix* Jff,IssmDouble kmax);
    7777                bool  InAnalysis(int analysis_type);
    7878                /*}}}*/
    79                 /*Load management: {{{1*/
     79                /*Load management: {{{*/
    8080                void GetDofList(int** pdoflist,int approximation_enum,int setenum);
    81                 void GetSegmentNormal(double* normal,double xyz_list[2][3]);
    82                 void GetQuadNormal(double* normal,double xyz_list[4][3]);
     81                void GetSegmentNormal(IssmDouble* normal,IssmDouble xyz_list[2][3]);
     82                void GetQuadNormal(IssmDouble* normal,IssmDouble xyz_list[4][3]);
    8383                #ifdef _HAVE_CONTROL_
    8484                ElementVector* CreatePVectorAdjointHoriz(void);
  • issm/trunk/src/c/objects/Loads/Load.h

    r11995 r12706  
    1010
    1111/*Headers:*/
    12 /*{{{1*/
     12/*{{{*/
    1313class Object;
    1414class Matrix;
     
    2626                virtual       ~Load(){};
    2727               
    28                 /*Virtual functions: {{{1*/
     28                /*Virtual functions: {{{*/
    2929                virtual void  Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters)=0;
    3030                virtual void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters)=0;
     
    3232                virtual void  CreatePVector(Vector* pf)=0;
    3333                virtual void  CreateJacobianMatrix(Matrix* Jff)=0;
    34                 virtual void  PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax)=0;
    35                 virtual void  PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs, double kmax)=0;
    36                 virtual void  PenaltyCreatePVector(Vector* pf, double kmax)=0;
     34                virtual void  PenaltyCreateJacobianMatrix(Matrix* Jff,IssmDouble kmax)=0;
     35                virtual void  PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs, IssmDouble kmax)=0;
     36                virtual void  PenaltyCreatePVector(Vector* pf, IssmDouble kmax)=0;
    3737                virtual bool  InAnalysis(int analysis_type)=0;
    3838                /*}}}*/
  • issm/trunk/src/c/objects/Loads/Numericalflux.cpp

    r12330 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88#include <config.h>
     
    2424
    2525/*Numericalflux constructors and destructor*/
    26 /*FUNCTION Numericalflux::Numericalflux(){{{1*/
     26/*FUNCTION Numericalflux::Numericalflux(){{{*/
    2727Numericalflux::Numericalflux(){
    2828        this->inputs=NULL;
     
    3434}
    3535/*}}}*/
    36 /*}}}*//*FUNCTION Numericalflux::Numericalflux(int id, int i, IoModel* iomodel, int analysis_type) {{{1*/
     36/*}}}*//*FUNCTION Numericalflux::Numericalflux(int id, int i, IoModel* iomodel, int analysis_type) {{{*/
    3737Numericalflux::Numericalflux(int numericalflux_id,int i, IoModel* iomodel, int in_analysis_type){
    3838
     
    5959        numericalflux_mparid=numberofelements+1; //matlab indexing
    6060
    61         /*First, see wether this is an internal or boundary edge (if e2=NaN)*/
    62         if (isnan((double)iomodel->Data(MeshEdgesEnum)[4*i+3])){ //edges are [node1 node2 elem1 elem2]
     61        /*First, see wether this is an internal or boundary edge (if e2=-1)*/
     62        if (iomodel->Data(MeshEdgesEnum)[4*i+3]==-1.){ //edges are [node1 node2 elem1 elem2]
    6363                /* Boundary edge, only one element */
    64                 e1=(int)iomodel->Data(MeshEdgesEnum)[4*i+2];
    65                 e2=(int)UNDEF;
     64                e1=reCast<int>(iomodel->Data(MeshEdgesEnum)[4*i+2]);
     65                e2=reCast<int>(UNDEF);
    6666                num_elems=1;
    6767                num_nodes=2;
    6868                numericalflux_type=BoundaryEnum;
    69                 numericalflux_elem_ids[0]=(int)e1;
     69                numericalflux_elem_ids[0]=e1;
    7070        }
    7171        else{
    7272                /* internal edge: connected to 2 elements */
    73                 e1=(int)iomodel->Data(MeshEdgesEnum)[4*i+2];
    74                 e2=(int)iomodel->Data(MeshEdgesEnum)[4*i+3];
     73                e1=reCast<int>(iomodel->Data(MeshEdgesEnum)[4*i+2]);
     74                e2=reCast<int>(iomodel->Data(MeshEdgesEnum)[4*i+3]);
    7575                num_elems=2;
    7676                num_nodes=4;
    7777                numericalflux_type=InternalEnum;
    78                 numericalflux_elem_ids[0]=(int)e1;
    79                 numericalflux_elem_ids[1]=(int)e2;
     78                numericalflux_elem_ids[0]=e1;
     79                numericalflux_elem_ids[1]=e2;
    8080        }
    8181
    8282        /*1: Get vertices ids*/
    83         i1=(int)iomodel->Data(MeshEdgesEnum)[4*i+0];
    84         i2=(int)iomodel->Data(MeshEdgesEnum)[4*i+1];
     83        i1=reCast<int>(iomodel->Data(MeshEdgesEnum)[4*i+0]);
     84        i2=reCast<int>(iomodel->Data(MeshEdgesEnum)[4*i+1]);
    8585
    8686        if (numericalflux_type==InternalEnum){
     
    139139}
    140140/*}}}*/
    141 /*FUNCTION Numericalflux::~Numericalflux(){{{1*/
     141/*FUNCTION Numericalflux::~Numericalflux(){{{*/
    142142Numericalflux::~Numericalflux(){
    143143        delete inputs;
     
    149149
    150150/*Object virtual functions definitions:*/
    151 /*FUNCTION Numericalflux::Echo {{{1*/
     151/*FUNCTION Numericalflux::Echo {{{*/
    152152void Numericalflux::Echo(void){
    153         printf("Numericalflux:\n");
    154         printf("   id: %i\n",id);
    155         printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
     153        _printLine_("Numericalflux:");
     154        _printLine_("   id: " << id);
     155        _printLine_("   analysis_type: " << EnumToStringx(analysis_type));
    156156        hnodes->Echo();
    157157        helement->Echo();
    158         printf("   parameters: %p\n",parameters);
    159         printf("   inputs: %p\n",inputs);
    160 }
    161 /*}}}*/
    162 /*FUNCTION Numericalflux::DeepEcho {{{1*/
     158        _printLine_("   parameters: " << parameters);
     159        _printLine_("   inputs: " << inputs);
     160}
     161/*}}}*/
     162/*FUNCTION Numericalflux::DeepEcho {{{*/
    163163void Numericalflux::DeepEcho(void){
    164164
    165         printf("Numericalflux:\n");
    166         printf("   id: %i\n",id);
    167         printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
     165        _printLine_("Numericalflux:");
     166        _printLine_("   id: " << id);
     167        _printLine_("   analysis_type: " << EnumToStringx(analysis_type));
    168168        hnodes->DeepEcho();
    169169        helement->DeepEcho();
    170         printf("   parameters\n");
     170        _printLine_("   parameters");
    171171        if(parameters)
    172172         parameters->DeepEcho();
    173173        else
    174          printf("      NULL\n");
    175         printf("   inputs\n");
     174         _printLine_("      NULL");
     175        _printLine_("   inputs");
    176176        inputs->DeepEcho();
    177177       
    178178}               
    179179/*}}}*/
    180 /*FUNCTION Numericalflux::Id {{{1*/
     180/*FUNCTION Numericalflux::Id {{{*/
    181181int    Numericalflux::Id(void){
    182182        return id;
    183183}
    184184/*}}}*/
    185 /*FUNCTION Numericalflux::MyRank {{{1*/
     185/*FUNCTION Numericalflux::MyRank {{{*/
    186186int    Numericalflux::MyRank(void){
    187187        extern int my_rank;
     
    189189}
    190190/*}}}*/
    191 /*FUNCTION Numericalflux::ObjectEnum{{{1*/
     191/*FUNCTION Numericalflux::ObjectEnum{{{*/
    192192int Numericalflux::ObjectEnum(void){
    193193
     
    196196}
    197197/*}}}*/
    198 /*FUNCTION Numericalflux::copy {{{1*/
     198/*FUNCTION Numericalflux::copy {{{*/
    199199Object* Numericalflux::copy() {
    200200       
     
    228228
    229229/*Load virtual functions definitions:*/
    230 /*FUNCTION Numericalflux::Configure {{{1*/
     230/*FUNCTION Numericalflux::Configure {{{*/
    231231void  Numericalflux::Configure(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){
    232232
     
    245245}
    246246/*}}}*/
    247 /*FUNCTION Numericalflux::SetCurrentConfiguration {{{1*/
     247/*FUNCTION Numericalflux::SetCurrentConfiguration {{{*/
    248248void  Numericalflux::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){
    249249
    250250}
    251251/*}}}*/
    252 /*FUNCTION Numericalflux::CreateKMatrix {{{1*/
     252/*FUNCTION Numericalflux::CreateKMatrix {{{*/
    253253void  Numericalflux::CreateKMatrix(Matrix* Kff, Matrix* Kfs){
    254254
     
    270270                        break;
    271271                default:
    272                         _error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
     272                        _error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
    273273        }
    274274
     
    281281}
    282282/*}}}*/
    283 /*FUNCTION Numericalflux::CreatePVector {{{1*/
     283/*FUNCTION Numericalflux::CreatePVector {{{*/
    284284void  Numericalflux::CreatePVector(Vector* pf){
    285285
     
    300300                        break;
    301301                default:
    302                         _error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
     302                        _error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
    303303        }
    304304
     
    311311}
    312312/*}}}*/
    313 /*FUNCTION Numericalflux::PenaltyCreateKMatrix {{{1*/
    314 void  Numericalflux::PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs,double kmax){
     313/*FUNCTION Numericalflux::PenaltyCreateKMatrix {{{*/
     314void  Numericalflux::PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs,IssmDouble kmax){
    315315
    316316        /*No stiffness loads applied, do nothing: */
     
    319319}
    320320/*}}}*/
    321 /*FUNCTION Numericalflux::PenaltyCreatePVector{{{1*/
    322 void  Numericalflux::PenaltyCreatePVector(Vector* pf,double kmax){
     321/*FUNCTION Numericalflux::PenaltyCreatePVector{{{*/
     322void  Numericalflux::PenaltyCreatePVector(Vector* pf,IssmDouble kmax){
    323323
    324324        /*No penalty loads applied, do nothing: */
     
    327327}
    328328/*}}}*/
    329 /*FUNCTION Numericalflux::InAnalysis{{{1*/
     329/*FUNCTION Numericalflux::InAnalysis{{{*/
    330330bool Numericalflux::InAnalysis(int in_analysis_type){
    331331        if (in_analysis_type==this->analysis_type) return true;
     
    335335
    336336/*Numericalflux management*/
    337 /*FUNCTION Numericalflux::CreateKMatrixPrognostic{{{1*/
     337/*FUNCTION Numericalflux::CreateKMatrixPrognostic{{{*/
    338338ElementMatrix* Numericalflux::CreateKMatrixPrognostic(void){
    339339
     
    347347                        return CreateKMatrixPrognosticBoundary();
    348348                default:
    349                         _error_("type not supported yet");
    350         }
    351 }
    352 /*}}}*/
    353 /*FUNCTION Numericalflux::CreateKMatrixPrognosticInternal {{{1*/
     349                        _error2_("type not supported yet");
     350        }
     351}
     352/*}}}*/
     353/*FUNCTION Numericalflux::CreateKMatrixPrognosticInternal {{{*/
    354354ElementMatrix* Numericalflux::CreateKMatrixPrognosticInternal(void){
    355355
     
    359359        /* Intermediaries*/
    360360        int        i,j,ig,index1,index2;
    361         double     DL1,DL2,Jdet,dt,vx,vy,UdotN;
    362         double     xyz_list[NUMVERTICES_INTERNAL][3];
    363         double     normal[2];
    364         double     B[numdof];
    365         double     Bprime[numdof];
    366         double     Ke_g1[numdof][numdof];
    367         double     Ke_g2[numdof][numdof];
     361        IssmDouble     DL1,DL2,Jdet,dt,vx,vy,UdotN;
     362        IssmDouble     xyz_list[NUMVERTICES_INTERNAL][3];
     363        IssmDouble     normal[2];
     364        IssmDouble     B[numdof];
     365        IssmDouble     Bprime[numdof];
     366        IssmDouble     Ke_g1[numdof][numdof];
     367        IssmDouble     Ke_g2[numdof][numdof];
    368368        GaussTria *gauss;
    369369
     
    416416}
    417417/*}}}*/
    418 /*FUNCTION Numericalflux::CreateKMatrixPrognosticBoundary {{{1*/
     418/*FUNCTION Numericalflux::CreateKMatrixPrognosticBoundary {{{*/
    419419ElementMatrix* Numericalflux::CreateKMatrixPrognosticBoundary(void){
    420420
     
    424424        /* Intermediaries*/
    425425        int        i,j,ig,index1,index2;
    426         double     DL,Jdet,dt,vx,vy,mean_vx,mean_vy,UdotN;
    427         double     xyz_list[NUMVERTICES_BOUNDARY][3];
    428         double     normal[2];
    429         double     L[numdof];
    430         double     Ke_g[numdof][numdof];
     426        IssmDouble     DL,Jdet,dt,vx,vy,mean_vx,mean_vy,UdotN;
     427        IssmDouble     xyz_list[NUMVERTICES_BOUNDARY][3];
     428        IssmDouble     normal[2];
     429        IssmDouble     L[numdof];
     430        IssmDouble     Ke_g[numdof][numdof];
    431431        GaussTria *gauss;
    432432
     
    488488}
    489489/*}}}*/
    490 /*FUNCTION Numericalflux::CreateKMatrixBalancethickness{{{1*/
     490/*FUNCTION Numericalflux::CreateKMatrixBalancethickness{{{*/
    491491ElementMatrix* Numericalflux::CreateKMatrixBalancethickness(void){
    492492
     
    500500                        return CreateKMatrixBalancethicknessBoundary();
    501501                default:
    502                         _error_("type not supported yet");
    503         }
    504 }
    505 /*}}}*/
    506 /*FUNCTION Numericalflux::CreateKMatrixBalancethicknessInternal {{{1*/
     502                        _error2_("type not supported yet");
     503        }
     504}
     505/*}}}*/
     506/*FUNCTION Numericalflux::CreateKMatrixBalancethicknessInternal {{{*/
    507507ElementMatrix* Numericalflux::CreateKMatrixBalancethicknessInternal(void){
    508508
     
    512512        /* Intermediaries*/
    513513        int        i,j,ig,index1,index2;
    514         double     DL1,DL2,Jdet,vx,vy,UdotN;
    515         double     xyz_list[NUMVERTICES_INTERNAL][3];
    516         double     normal[2];
    517         double     B[numdof];
    518         double     Bprime[numdof];
    519         double     Ke_g1[numdof][numdof];
    520         double     Ke_g2[numdof][numdof];
     514        IssmDouble     DL1,DL2,Jdet,vx,vy,UdotN;
     515        IssmDouble     xyz_list[NUMVERTICES_INTERNAL][3];
     516        IssmDouble     normal[2];
     517        IssmDouble     B[numdof];
     518        IssmDouble     Bprime[numdof];
     519        IssmDouble     Ke_g1[numdof][numdof];
     520        IssmDouble     Ke_g2[numdof][numdof];
    521521        GaussTria *gauss;
    522522
     
    568568}
    569569/*}}}*/
    570 /*FUNCTION Numericalflux::CreateKMatrixBalancethicknessBoundary {{{1*/
     570/*FUNCTION Numericalflux::CreateKMatrixBalancethicknessBoundary {{{*/
    571571ElementMatrix* Numericalflux::CreateKMatrixBalancethicknessBoundary(void){
    572572
     
    576576        /* Intermediaries*/
    577577        int        i,j,ig,index1,index2;
    578         double     DL,Jdet,vx,vy,mean_vx,mean_vy,UdotN;
    579         double     xyz_list[NUMVERTICES_BOUNDARY][3];
    580         double     normal[2];
    581         double     L[numdof];
    582         double     Ke_g[numdof][numdof];
     578        IssmDouble     DL,Jdet,vx,vy,mean_vx,mean_vy,UdotN;
     579        IssmDouble     xyz_list[NUMVERTICES_BOUNDARY][3];
     580        IssmDouble     normal[2];
     581        IssmDouble     L[numdof];
     582        IssmDouble     Ke_g[numdof][numdof];
    583583        GaussTria *gauss;
    584584
     
    639639}
    640640/*}}}*/
    641 /*FUNCTION Numericalflux::CreateKMatrixAdjointBalancethickness{{{1*/
     641/*FUNCTION Numericalflux::CreateKMatrixAdjointBalancethickness{{{*/
    642642ElementMatrix* Numericalflux::CreateKMatrixAdjointBalancethickness(void){
    643643
     
    651651                        return CreateKMatrixAdjointBalancethicknessBoundary();
    652652                default:
    653                         _error_("type not supported yet");
    654         }
    655 }
    656 /*}}}*/
    657 /*FUNCTION Numericalflux::CreateKMatrixAdjointBalancethicknessInternal {{{1*/
     653                        _error2_("type not supported yet");
     654        }
     655}
     656/*}}}*/
     657/*FUNCTION Numericalflux::CreateKMatrixAdjointBalancethicknessInternal {{{*/
    658658ElementMatrix* Numericalflux::CreateKMatrixAdjointBalancethicknessInternal(void){
    659659
     
    663663}
    664664/*}}}*/
    665 /*FUNCTION Numericalflux::CreateKMatrixAdjointBalancethicknessBoundary {{{1*/
     665/*FUNCTION Numericalflux::CreateKMatrixAdjointBalancethicknessBoundary {{{*/
    666666ElementMatrix* Numericalflux::CreateKMatrixAdjointBalancethicknessBoundary(void){
    667667
     
    671671}
    672672/*}}}*/
    673 /*FUNCTION Numericalflux::CreatePVectorPrognostic{{{1*/
     673/*FUNCTION Numericalflux::CreatePVectorPrognostic{{{*/
    674674ElementVector* Numericalflux::CreatePVectorPrognostic(void){
    675675
     
    683683                        return CreatePVectorPrognosticBoundary();
    684684                default:
    685                         _error_("type not supported yet");
    686         }
    687 }
    688 /*}}}*/
    689 /*FUNCTION Numericalflux::CreatePVectorPrognosticInternal{{{1*/
     685                        _error2_("type not supported yet");
     686        }
     687}
     688/*}}}*/
     689/*FUNCTION Numericalflux::CreatePVectorPrognosticInternal{{{*/
    690690ElementVector* Numericalflux::CreatePVectorPrognosticInternal(void){
    691691
     
    695695}
    696696/*}}}*/
    697 /*FUNCTION Numericalflux::CreatePVectorPrognosticBoundary{{{1*/
     697/*FUNCTION Numericalflux::CreatePVectorPrognosticBoundary{{{*/
    698698ElementVector* Numericalflux::CreatePVectorPrognosticBoundary(void){
    699699
     
    703703        /* Intermediaries*/
    704704        int        i,j,ig,index1,index2;
    705         double     DL,Jdet,dt,vx,vy,mean_vx,mean_vy,UdotN,thickness;
    706         double     xyz_list[NUMVERTICES_BOUNDARY][3];
    707         double     normal[2];
    708         double     L[numdof];
     705        IssmDouble     DL,Jdet,dt,vx,vy,mean_vx,mean_vy,UdotN,thickness;
     706        IssmDouble     xyz_list[NUMVERTICES_BOUNDARY][3];
     707        IssmDouble     normal[2];
     708        IssmDouble     L[numdof];
    709709        GaussTria *gauss;
    710710
     
    751751                vyaverage_input->GetInputValue(&vy,gauss);
    752752                spcthickness_input->GetInputValue(&thickness,gauss);
    753                 if(isnan(thickness)) _error_("Cannot weakly apply constraint because NaN was provided");
     753                if(xIsNan<IssmDouble>(thickness)) _error2_("Cannot weakly apply constraint because NaN was provided");
    754754
    755755                UdotN=vx*normal[0]+vy*normal[1];
     
    765765}
    766766/*}}}*/
    767 /*FUNCTION Numericalflux::CreatePVectorBalancethickness{{{1*/
     767/*FUNCTION Numericalflux::CreatePVectorBalancethickness{{{*/
    768768ElementVector* Numericalflux::CreatePVectorBalancethickness(void){
    769769
     
    777777                        return CreatePVectorBalancethicknessBoundary();
    778778                default:
    779                         _error_("type not supported yet");
    780         }
    781 }
    782 /*}}}*/
    783 /*FUNCTION Numericalflux::CreatePVectorBalancethicknessInternal{{{1*/
     779                        _error2_("type not supported yet");
     780        }
     781}
     782/*}}}*/
     783/*FUNCTION Numericalflux::CreatePVectorBalancethicknessInternal{{{*/
    784784ElementVector* Numericalflux::CreatePVectorBalancethicknessInternal(void){
    785785
     
    789789}
    790790/*}}}*/
    791 /*FUNCTION Numericalflux::CreatePVectorBalancethicknessBoundary{{{1*/
     791/*FUNCTION Numericalflux::CreatePVectorBalancethicknessBoundary{{{*/
    792792ElementVector* Numericalflux::CreatePVectorBalancethicknessBoundary(void){
    793793
     
    797797        /* Intermediaries*/
    798798        int        i,j,ig,index1,index2;
    799         double     DL,Jdet,vx,vy,mean_vx,mean_vy,UdotN,thickness;
    800         double     xyz_list[NUMVERTICES_BOUNDARY][3];
    801         double     normal[2];
    802         double     L[numdof];
     799        IssmDouble     DL,Jdet,vx,vy,mean_vx,mean_vy,UdotN,thickness;
     800        IssmDouble     xyz_list[NUMVERTICES_BOUNDARY][3];
     801        IssmDouble     normal[2];
     802        IssmDouble     L[numdof];
    803803        GaussTria *gauss;
    804804
     
    856856}
    857857/*}}}*/
    858 /*FUNCTION Numericalflux::CreatePVectorAdjointBalancethickness{{{1*/
     858/*FUNCTION Numericalflux::CreatePVectorAdjointBalancethickness{{{*/
    859859ElementVector* Numericalflux::CreatePVectorAdjointBalancethickness(void){
    860860
     
    863863}
    864864/*}}}*/
    865 /*FUNCTION Numericalflux::GetNormal {{{1*/
    866 void Numericalflux:: GetNormal(double* normal,double xyz_list[4][3]){
     865/*FUNCTION Numericalflux::GetNormal {{{*/
     866void Numericalflux:: GetNormal(IssmDouble* normal,IssmDouble xyz_list[4][3]){
    867867
    868868        /*Build unit outward pointing vector*/
    869         double vector[2];
    870         double norm;
     869        IssmDouble vector[2];
     870        IssmDouble norm;
    871871
    872872        vector[0]=xyz_list[1][0] - xyz_list[0][0];
  • issm/trunk/src/c/objects/Loads/Numericalflux.h

    r12330 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "./Load.h"
    1111class Hook;
     
    3535
    3636
    37                 /*Numericalflux constructors,destructors {{{1*/
     37                /*Numericalflux constructors,destructors {{{*/
    3838                Numericalflux();
    3939                Numericalflux(int numericalflux_id,int i, IoModel* iomodel,int analysis_type);
    4040                ~Numericalflux();
    4141                /*}}}*/
    42                 /*Object virtual functions definitions:{{{1 */
     42                /*Object virtual functions definitions:{{{ */
    4343                void  Echo();
    4444                void  DeepEcho();
     
    4848                Object* copy();
    4949                /*}}}*/
    50                 /*Update virtual functions resolution: {{{1*/
    51                 void    InputUpdateFromVector(double* vector, int name, int type){/*Do nothing*/}
    52                 void    InputUpdateFromVector(int* vector, int name, int type){_error_("Not implemented yet!");}
    53                 void    InputUpdateFromVector(bool* vector, int name, int type){_error_("Not implemented yet!");}
    54                 void    InputUpdateFromMatrixDakota(double* matrix, int nrows, int ncols, int name, int type){/*Do nothing*/}
    55                 void    InputUpdateFromVectorDakota(double* vector, int name, int type){/*Do nothing*/}
    56                 void    InputUpdateFromVectorDakota(int* vector, int name, int type){_error_("Not implemented yet!");}
    57                 void    InputUpdateFromVectorDakota(bool* vector, int name, int type){_error_("Not implemented yet!");}
    58                 void    InputUpdateFromConstant(double constant, int name){/*Do nothing*/};
     50                /*Update virtual functions resolution: {{{*/
     51                void    InputUpdateFromVector(IssmDouble* vector, int name, int type){/*Do nothing*/}
     52                void    InputUpdateFromVector(int* vector, int name, int type){_error2_("Not implemented yet!");}
     53                void    InputUpdateFromVector(bool* vector, int name, int type){_error2_("Not implemented yet!");}
     54                void    InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type){/*Do nothing*/}
     55                void    InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){/*Do nothing*/}
     56                void    InputUpdateFromVectorDakota(int* vector, int name, int type){_error2_("Not implemented yet!");}
     57                void    InputUpdateFromVectorDakota(bool* vector, int name, int type){_error2_("Not implemented yet!");}
     58                void    InputUpdateFromConstant(IssmDouble constant, int name){/*Do nothing*/};
    5959                void    InputUpdateFromConstant(int constant, int name){/*Do nothing*/};
    60                 void    InputUpdateFromConstant(bool constant, int name){_error_("Not implemented yet!");}
    61                 void    InputUpdateFromSolution(double* solution){_error_("Not implemented yet!");}
    62                 void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("not implemented yet");};
     60                void    InputUpdateFromConstant(bool constant, int name){_error2_("Not implemented yet!");}
     61                void    InputUpdateFromSolution(IssmDouble* solution){_error2_("Not implemented yet!");}
     62                void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error2_("not implemented yet");};
    6363                /*}}}*/
    64                 /*Load virtual functions definitions: {{{1*/
     64                /*Load virtual functions definitions: {{{*/
    6565                void  Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
    6666                void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
    6767                void  CreateKMatrix(Matrix* Kff, Matrix* Kfs);
    6868                void  CreatePVector(Vector* pf);
    69                 void  CreateJacobianMatrix(Matrix* Jff){_error_("Not implemented yet");};
    70                 void  PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax){_error_("Not implemented yet");};
    71                 void  PenaltyCreateKMatrix(Matrix* Kff, Matrix* kfs, double kmax);
    72                 void  PenaltyCreatePVector(Vector* pf, double kmax);
     69                void  CreateJacobianMatrix(Matrix* Jff){_error2_("Not implemented yet");};
     70                void  PenaltyCreateJacobianMatrix(Matrix* Jff,IssmDouble kmax){_error2_("Not implemented yet");};
     71                void  PenaltyCreateKMatrix(Matrix* Kff, Matrix* kfs, IssmDouble kmax);
     72                void  PenaltyCreatePVector(Vector* pf, IssmDouble kmax);
    7373                bool  InAnalysis(int analysis_type);
    7474                /*}}}*/
    75                 /*Numericalflux management:{{{1*/
    76                 void  GetNormal(double* normal,double xyz_list[4][3]);
     75                /*Numericalflux management:{{{*/
     76                void  GetNormal(IssmDouble* normal,IssmDouble xyz_list[4][3]);
    7777                ElementMatrix* CreateKMatrixPrognostic(void);
    7878                ElementMatrix* CreateKMatrixPrognosticInternal(void);
  • issm/trunk/src/c/objects/Loads/Pengrid.cpp

    r12330 r12706  
    44
    55/*Headers*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2424
    2525/*Pengrid constructors and destructor*/
    26 /*FUNCTION Pengrid::Pengrid(){{{1*/
     26/*FUNCTION Pengrid::Pengrid(){{{*/
    2727Pengrid::Pengrid(){
    2828        this->inputs=NULL;
     
    4040
    4141}
    42 /*}}}1*/
    43 /*FUNCTION Pengrid::Pengrid(int index, int id, IoModel* iomodel,int analysis_type){{{1*/
     42/*}}}*/
     43/*FUNCTION Pengrid::Pengrid(int index, int id, IoModel* iomodel,int analysis_type){{{*/
    4444Pengrid::Pengrid(int id, int index, IoModel* iomodel, int in_analysis_type){ //i is the element index
    4545
     
    9090}
    9191/*}}}*/
    92 /*FUNCTION Pengrid::~Pengrid(){{{1*/
     92/*FUNCTION Pengrid::~Pengrid(){{{*/
    9393Pengrid::~Pengrid(){
    9494        delete inputs;
     
    9898        return;
    9999}
    100 /*}}}1*/
     100/*}}}*/
    101101                       
    102102/*Object virtual functions definitions:*/
    103 /*FUNCTION Pengrid::Echo {{{1*/
     103/*FUNCTION Pengrid::Echo {{{*/
    104104void Pengrid::Echo(void){
    105105        this->DeepEcho();
    106106}
    107 /*}}}1*/
    108 /*FUNCTION Pengrid::DeepEcho{{{1*/
     107/*}}}*/
     108/*FUNCTION Pengrid::DeepEcho{{{*/
    109109void Pengrid::DeepEcho(void){
    110110
    111         printf("Pengrid:\n");
    112         printf("   id: %i\n",id);
    113         printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
     111        _printLine_("Pengrid:");
     112        _printLine_("   id: " << id);
     113        _printLine_("   analysis_type: " << EnumToStringx(analysis_type));
    114114        hnode->DeepEcho();
    115115        helement->DeepEcho();
    116116        hmatpar->DeepEcho();
    117         printf("   active %i\n",this->active);
    118         printf("   zigzag_counter %i\n",this->zigzag_counter);
    119         printf("   parameters\n");
     117        _printLine_("   active " << this->active);
     118        _printLine_("   zigzag_counter " << this->zigzag_counter);
     119        _printLine_("   parameters");
    120120        parameters->DeepEcho();
    121         printf("   inputs\n");
     121        _printLine_("   inputs");
    122122        inputs->DeepEcho();
    123123}
    124124/*}}}*/
    125 /*FUNCTION Pengrid::Id {{{1*/
     125/*FUNCTION Pengrid::Id {{{*/
    126126int    Pengrid::Id(void){ return id; }
    127 /*}}}1*/
    128 /*FUNCTION Pengrid::MyRank {{{1*/
     127/*}}}*/
     128/*FUNCTION Pengrid::MyRank {{{*/
    129129int    Pengrid::MyRank(void){
    130130        extern int my_rank;
    131131        return my_rank;
    132132}
    133 /*}}}1*/
    134 /*FUNCTION Pengrid::ObjectEnum{{{1*/
     133/*}}}*/
     134/*FUNCTION Pengrid::ObjectEnum{{{*/
    135135int Pengrid::ObjectEnum(void){
    136136
    137137        return PengridEnum;
    138138}
    139 /*}}}1*/
    140 /*FUNCTION Icefront::copy {{{1*/
     139/*}}}*/
     140/*FUNCTION Icefront::copy {{{*/
    141141Object* Pengrid::copy() {
    142142       
     
    177177
    178178/*Load virtual functions definitions:*/
    179 /*FUNCTION Pengrid::Configure {{{1*/
     179/*FUNCTION Pengrid::Configure {{{*/
    180180void  Pengrid::Configure(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){
    181181
     
    194194        this->parameters=parametersin;
    195195}
    196 /*}}}1*/
    197 /*FUNCTION Pengrid::SetCurrentConfiguration {{{1*/
     196/*}}}*/
     197/*FUNCTION Pengrid::SetCurrentConfiguration {{{*/
    198198void  Pengrid::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){
    199199
    200200}
    201 /*}}}1*/
    202 /*FUNCTION Pengrid::CreateKMatrix {{{1*/
     201/*}}}*/
     202/*FUNCTION Pengrid::CreateKMatrix {{{*/
    203203void  Pengrid::CreateKMatrix(Matrix* Kff, Matrix* Kfs){
    204204
     
    207207
    208208}
    209 /*}}}1*/
    210 /*FUNCTION Pengrid::CreatePVector {{{1*/
     209/*}}}*/
     210/*FUNCTION Pengrid::CreatePVector {{{*/
    211211void  Pengrid::CreatePVector(Vector* pf){
    212212
     
    215215
    216216}
    217 /*}}}1*/
    218 /*FUNCTION Pengrid::PenaltyCreateMatrix {{{1*/
    219 void  Pengrid::PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs,double kmax){
     217/*}}}*/
     218/*FUNCTION Pengrid::PenaltyCreateMatrix {{{*/
     219void  Pengrid::PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs,IssmDouble kmax){
    220220
    221221        /*Retrieve parameters: */
     
    239239                #endif
    240240                default:
    241                         _error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
     241                        _error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
    242242        }
    243243
     
    248248        }
    249249}
    250 /*}}}1*/
    251 /*FUNCTION Pengrid::PenaltyCreatePVector {{{1*/
    252 void  Pengrid::PenaltyCreatePVector(Vector* pf,double kmax){
     250/*}}}*/
     251/*FUNCTION Pengrid::PenaltyCreatePVector {{{*/
     252void  Pengrid::PenaltyCreatePVector(Vector* pf,IssmDouble kmax){
    253253
    254254        /*Retrieve parameters: */
     
    271271                #endif
    272272                default:
    273                         _error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
     273                        _error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
    274274        }
    275275
     
    280280        }
    281281}
    282 /*}}}1*/
    283 /*FUNCTION Pengrid::InAnalysis{{{1*/
     282/*}}}*/
     283/*FUNCTION Pengrid::InAnalysis{{{*/
    284284bool Pengrid::InAnalysis(int in_analysis_type){
    285285        if (in_analysis_type==this->analysis_type)return true;
     
    289289
    290290/*Update virtual functions definitions:*/
    291 /*FUNCTION Pengrid::InputUpdateFromVector(double* vector, int name, int type) {{{1*/
    292 void  Pengrid::InputUpdateFromVector(double* vector, int name, int type){
    293         /*Nothing updated yet*/
    294 }
    295 /*}}}*/
    296 /*FUNCTION Pengrid::InputUpdateFromVector(int* vector, int name, int type) {{{1*/
     291/*FUNCTION Pengrid::InputUpdateFromVector(IssmDouble* vector, int name, int type) {{{*/
     292void  Pengrid::InputUpdateFromVector(IssmDouble* vector, int name, int type){
     293        /*Nothing updated yet*/
     294}
     295/*}}}*/
     296/*FUNCTION Pengrid::InputUpdateFromVector(int* vector, int name, int type) {{{*/
    297297void  Pengrid::InputUpdateFromVector(int* vector, int name, int type){
    298298        /*Nothing updated yet*/
    299299}
    300300/*}}}*/
    301 /*FUNCTION Pengrid::InputUpdateFromVector(bool* vector, int name, int type) {{{1*/
     301/*FUNCTION Pengrid::InputUpdateFromVector(bool* vector, int name, int type) {{{*/
    302302void  Pengrid::InputUpdateFromVector(bool* vector, int name, int type){
    303303        /*Nothing updated yet*/
    304304}
    305305/*}}}*/
    306 /*FUNCTION Pengrid::InputUpdateFromMatrixDakota(double* vector, int nrows, int ncols, int name, int type) {{{1*/
    307 void  Pengrid::InputUpdateFromMatrixDakota(double* matrix, int nrows, int ncols, int name, int type){
    308         /*Nothing updated yet*/
    309 }
    310 /*}}}*/
    311 /*FUNCTION Pengrid::InputUpdateFromVectorDakota(double* vector, int name, int type) {{{1*/
    312 void  Pengrid::InputUpdateFromVectorDakota(double* vector, int name, int type){
    313         /*Nothing updated yet*/
    314 }
    315 /*}}}*/
    316 /*FUNCTION Pengrid::InputUpdateFromVectorDakota(int* vector, int name, int type) {{{1*/
     306/*FUNCTION Pengrid::InputUpdateFromMatrixDakota(IssmDouble* vector, int nrows, int ncols, int name, int type) {{{*/
     307void  Pengrid::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type){
     308        /*Nothing updated yet*/
     309}
     310/*}}}*/
     311/*FUNCTION Pengrid::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type) {{{*/
     312void  Pengrid::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){
     313        /*Nothing updated yet*/
     314}
     315/*}}}*/
     316/*FUNCTION Pengrid::InputUpdateFromVectorDakota(int* vector, int name, int type) {{{*/
    317317void  Pengrid::InputUpdateFromVectorDakota(int* vector, int name, int type){
    318318        /*Nothing updated yet*/
    319319}
    320320/*}}}*/
    321 /*FUNCTION Pengrid::InputUpdateFromVectorDakota(bool* vector, int name, int type) {{{1*/
     321/*FUNCTION Pengrid::InputUpdateFromVectorDakota(bool* vector, int name, int type) {{{*/
    322322void  Pengrid::InputUpdateFromVectorDakota(bool* vector, int name, int type){
    323323        /*Nothing updated yet*/
    324324}
    325325/*}}}*/
    326 /*FUNCTION Pengrid::InputUpdateFromConstant(double constant, int name) {{{1*/
    327 void  Pengrid::InputUpdateFromConstant(double constant, int name){
     326/*FUNCTION Pengrid::InputUpdateFromConstant(IssmDouble constant, int name) {{{*/
     327void  Pengrid::InputUpdateFromConstant(IssmDouble constant, int name){
    328328        switch(name){
    329329
     
    335335}
    336336/*}}}*/
    337 /*FUNCTION Pengrid::InputUpdateFromConstant(int constant, int name) {{{1*/
     337/*FUNCTION Pengrid::InputUpdateFromConstant(int constant, int name) {{{*/
    338338void  Pengrid::InputUpdateFromConstant(int constant, int name){
    339339        /*Nothing updated yet*/
    340340}
    341341/*}}}*/
    342 /*FUNCTION Pengrid::InputUpdateFromConstant(bool constant, int name) {{{1*/
     342/*FUNCTION Pengrid::InputUpdateFromConstant(bool constant, int name) {{{*/
    343343void  Pengrid::InputUpdateFromConstant(bool constant, int name){
    344344
     
    352352}
    353353/*}}}*/
    354 /*FUNCTION Pengrid::InputUpdateFromSolution{{{1*/
    355 void  Pengrid::InputUpdateFromSolution(double* solution){
     354/*FUNCTION Pengrid::InputUpdateFromSolution{{{*/
     355void  Pengrid::InputUpdateFromSolution(IssmDouble* solution){
    356356        /*Nothing updated yet*/
    357357}
     
    359359
    360360/*Pengrid management:*/
    361 /*FUNCTION Pengrid::ConstraintActivate {{{1*/
     361/*FUNCTION Pengrid::ConstraintActivate {{{*/
    362362void  Pengrid::ConstraintActivate(int* punstable){
    363363
     
    379379        }
    380380        else{
    381                 _error_("analysis: %s not supported yet",EnumToStringx(analysis_type));
    382         }
    383 
    384 }
    385 /*}}}1*/
    386 /*FUNCTION Pengrid::ConstraintActivateThermal {{{1*/
     381                _error2_("analysis: " << EnumToStringx(analysis_type) << " not supported yet");
     382        }
     383
     384}
     385/*}}}*/
     386/*FUNCTION Pengrid::ConstraintActivateThermal {{{*/
    387387void  Pengrid::ConstraintActivateThermal(int* punstable){
    388388
     
    391391        int    found=0;
    392392        const int numnodes=1;
    393         double pressure;
    394         double temperature;
    395         double t_pmp;
     393        IssmDouble pressure;
     394        IssmDouble temperature;
     395        IssmDouble t_pmp;
    396396        int    new_active;
    397397        int    unstable=0;
     
    452452        *punstable=unstable;
    453453}
    454 /*}}}1*/
     454/*}}}*/
    455455#ifdef _HAVE_DIAGNOSTIC_
    456 /*FUNCTION Pengrid::PenaltyCreateKMatrixDiagnosticStokes {{{1*/
    457 ElementMatrix* Pengrid::PenaltyCreateKMatrixDiagnosticStokes(double kmax){
     456/*FUNCTION Pengrid::PenaltyCreateKMatrixDiagnosticStokes {{{*/
     457ElementMatrix* Pengrid::PenaltyCreateKMatrixDiagnosticStokes(IssmDouble kmax){
    458458       
    459459        const int numdof = NUMVERTICES *NDOF4;
    460         double    slope[2];
    461         double    penalty_offset;
     460        IssmDouble    slope[2];
     461        IssmDouble    penalty_offset;
    462462        int       approximation;
    463463
     
    475475
    476476        /*Create elementary matrix: add penalty to constrain wb (wb=ub*db/dx+vb*db/dy)*/
    477         Ke->values[2*NDOF4+0]=-slope[0]*kmax*pow((double)10.0,penalty_offset);
    478         Ke->values[2*NDOF4+1]=-slope[1]*kmax*pow((double)10.0,penalty_offset);
    479         Ke->values[2*NDOF4+2]= kmax*pow((double)10,penalty_offset);
     477        Ke->values[2*NDOF4+0]=-slope[0]*kmax*pow((IssmDouble)10.0,penalty_offset);
     478        Ke->values[2*NDOF4+1]=-slope[1]*kmax*pow((IssmDouble)10.0,penalty_offset);
     479        Ke->values[2*NDOF4+2]= kmax*pow((IssmDouble)10,penalty_offset);
    480480
    481481        /*Transform Coordinate System*/
     
    485485        return Ke;
    486486}
    487 /*}}}1*/
     487/*}}}*/
    488488#endif
    489489#ifdef _HAVE_THERMAL_
    490 /*FUNCTION Pengrid::PenaltyCreateKMatrixMelting {{{1*/
    491 ElementMatrix* Pengrid::PenaltyCreateKMatrixMelting(double kmax){
     490/*FUNCTION Pengrid::PenaltyCreateKMatrixMelting {{{*/
     491ElementMatrix* Pengrid::PenaltyCreateKMatrixMelting(IssmDouble kmax){
    492492
    493493        const int numdof=NUMVERTICES*NDOF1;
    494         double pressure,temperature,t_pmp;
    495         double penalty_factor;
     494        IssmDouble pressure,temperature,t_pmp;
     495        IssmDouble penalty_factor;
    496496
    497497        Penta* penta=(Penta*)element;
     
    511511        /*Add penalty load*/
    512512        if (temperature<t_pmp){ //If T<Tpmp, there must be no melting. Therefore, melting should be  constrained to 0 when T<Tpmp, instead of using spcs, use penalties
    513                 Ke->values[0]=kmax*pow((double)10,penalty_factor);
     513                Ke->values[0]=kmax*pow((IssmDouble)10,penalty_factor);
    514514        }
    515515
     
    517517        return Ke;
    518518}
    519 /*}}}1*/
    520 /*FUNCTION Pengrid::PenaltyCreateKMatrixThermal {{{1*/
    521 ElementMatrix* Pengrid::PenaltyCreateKMatrixThermal(double kmax){
     519/*}}}*/
     520/*FUNCTION Pengrid::PenaltyCreateKMatrixThermal {{{*/
     521ElementMatrix* Pengrid::PenaltyCreateKMatrixThermal(IssmDouble kmax){
    522522
    523523        const int numdof=NUMVERTICES*NDOF1;
    524         double    penalty_factor;
     524        IssmDouble    penalty_factor;
    525525
    526526        /*Initialize Element matrix and return if necessary*/
     
    531531        parameters->FindParam(&penalty_factor,ThermalPenaltyFactorEnum);
    532532
    533         Ke->values[0]=kmax*pow((double)10,penalty_factor);
     533        Ke->values[0]=kmax*pow((IssmDouble)10,penalty_factor);
    534534
    535535        /*Clean up and return*/
    536536        return Ke;
    537537}
    538 /*}}}1*/
    539 /*FUNCTION Pengrid::PenaltyCreatePVectorMelting {{{1*/
    540 ElementVector* Pengrid::PenaltyCreatePVectorMelting(double kmax){
     538/*}}}*/
     539/*FUNCTION Pengrid::PenaltyCreatePVectorMelting {{{*/
     540ElementVector* Pengrid::PenaltyCreatePVectorMelting(IssmDouble kmax){
    541541       
    542542        const int numdof=NUMVERTICES*NDOF1;
    543         double pressure;
    544         double temperature;
    545         double melting_offset;
    546         double t_pmp;
    547         double dt,penalty_factor;
     543        IssmDouble pressure;
     544        IssmDouble temperature;
     545        IssmDouble melting_offset;
     546        IssmDouble t_pmp;
     547        IssmDouble dt,penalty_factor;
    548548
    549549        /*recover pointers: */
     
    572572        }
    573573        else{
    574                 if (dt) pe->values[0]=melting_offset*pow((double)10,penalty_factor)*(temperature-t_pmp)/dt;
    575                 else    pe->values[0]=melting_offset*pow((double)10,penalty_factor)*(temperature-t_pmp);
     574                if (dt) pe->values[0]=melting_offset*pow((IssmDouble)10,penalty_factor)*(temperature-t_pmp)/dt;
     575                else    pe->values[0]=melting_offset*pow((IssmDouble)10,penalty_factor)*(temperature-t_pmp);
    576576        }
    577577
     
    579579        return pe;
    580580}
    581 /*}}}1*/
    582 /*FUNCTION Pengrid::PenaltyCreatePVectorThermal {{{1*/
    583 ElementVector* Pengrid::PenaltyCreatePVectorThermal(double kmax){
     581/*}}}*/
     582/*FUNCTION Pengrid::PenaltyCreatePVectorThermal {{{*/
     583ElementVector* Pengrid::PenaltyCreatePVectorThermal(IssmDouble kmax){
    584584
    585585        const int numdof=NUMVERTICES*NDOF1;
    586         double pressure;
    587         double t_pmp;
    588         double penalty_factor;
     586        IssmDouble pressure;
     587        IssmDouble t_pmp;
     588        IssmDouble penalty_factor;
    589589
    590590        Penta* penta=(Penta*)element;
     
    601601        t_pmp=matpar->GetMeltingPoint()-matpar->GetBeta()*pressure;
    602602
    603         pe->values[0]=kmax*pow((double)10,penalty_factor)*t_pmp;
     603        pe->values[0]=kmax*pow((IssmDouble)10,penalty_factor)*t_pmp;
    604604
    605605        /*Clean up and return*/
    606606        return pe;
    607607}
    608 /*}}}1*/
     608/*}}}*/
    609609#endif
    610 /*FUNCTION Pengrid::ResetConstraint {{{1*/
     610/*FUNCTION Pengrid::ResetConstraint {{{*/
    611611void  Pengrid::ResetConstraint(void){
    612612        active=0;
    613613        zigzag_counter=0;
    614614}
    615 /*}}}1*/
    616 /*FUNCTION Pengrid::UpdateInputs {{{1*/
    617 void  Pengrid::UpdateInputs(double* solution){
    618         _error_("not supported yet!");
    619 }
    620 /*}}}1*/
     615/*}}}*/
     616/*FUNCTION Pengrid::UpdateInputs {{{*/
     617void  Pengrid::UpdateInputs(IssmDouble* solution){
     618        _error2_("not supported yet!");
     619}
     620/*}}}*/
  • issm/trunk/src/c/objects/Loads/Pengrid.h

    r12330 r12706  
    66
    77/*Headers:*/
    8 /*{{{1*/
     8/*{{{*/
    99#include "./Load.h"
    1010class Hook;
     
    4040        public:
    4141
    42                 /*Pengrid constructors, destructors {{{1*/
     42                /*Pengrid constructors, destructors {{{*/
    4343                Pengrid();
    4444                Pengrid(int index, int id, IoModel* iomodel,int analysis_type);
    4545                ~Pengrid();
    4646                /*}}}*/
    47                 /*Object virtual functions definitions:{{{1 */
     47                /*Object virtual functions definitions:{{{ */
    4848                void  Echo();
    4949                void  DeepEcho();
     
    5353                Object* copy();
    5454                /*}}}*/
    55                 /*Update virtual functions resolution: {{{1*/
    56                 void  InputUpdateFromVector(double* vector, int name, int type);
     55                /*Update virtual functions resolution: {{{*/
     56                void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
    5757                void  InputUpdateFromVector(int* vector, int name, int type);
    5858                void  InputUpdateFromVector(bool* vector, int name, int type);
    59                 void  InputUpdateFromMatrixDakota(double* matrix ,int nrows, int ncols, int name, int type);
    60                 void  InputUpdateFromVectorDakota(double* vector, int name, int type);
     59                void  InputUpdateFromMatrixDakota(IssmDouble* matrix ,int nrows, int ncols, int name, int type);
     60                void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
    6161                void  InputUpdateFromVectorDakota(int* vector, int name, int type);
    6262                void  InputUpdateFromVectorDakota(bool* vector, int name, int type);
    63                 void  InputUpdateFromConstant(double constant, int name);
     63                void  InputUpdateFromConstant(IssmDouble constant, int name);
    6464                void  InputUpdateFromConstant(int constant, int name);
    6565                void  InputUpdateFromConstant(bool constant, int name);
    66                 void  InputUpdateFromSolution(double* solution);
    67                 void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("not implemented yet");};
     66                void  InputUpdateFromSolution(IssmDouble* solution);
     67                void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error2_("not implemented yet");};
    6868                /*}}}*/
    69                 /*Load virtual functions definitions: {{{1*/
     69                /*Load virtual functions definitions: {{{*/
    7070                void  Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
    7171                void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
    7272                void  CreateKMatrix(Matrix* Kff, Matrix* Kfs);
    7373                void  CreatePVector(Vector* pf);
    74                 void  CreateJacobianMatrix(Matrix* Jff){_error_("Not implemented yet");};
    75                 void  PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax){_error_("Not implemented yet");};
    76                 void  PenaltyCreateKMatrix(Matrix* Kff, Matrix* kfs, double kmax);
    77                 void  PenaltyCreatePVector(Vector* pf, double kmax);
     74                void  CreateJacobianMatrix(Matrix* Jff){_error2_("Not implemented yet");};
     75                void  PenaltyCreateJacobianMatrix(Matrix* Jff,IssmDouble kmax){_error2_("Not implemented yet");};
     76                void  PenaltyCreateKMatrix(Matrix* Kff, Matrix* kfs, IssmDouble kmax);
     77                void  PenaltyCreatePVector(Vector* pf, IssmDouble kmax);
    7878                bool  InAnalysis(int analysis_type);
    7979                /*}}}*/
    80                 /*Pengrid management {{{1*/
     80                /*Pengrid management {{{*/
    8181                #ifdef _HAVE_DIAGNOSTIC_
    82                 ElementMatrix* PenaltyCreateKMatrixDiagnosticStokes(double kmax);
     82                ElementMatrix* PenaltyCreateKMatrixDiagnosticStokes(IssmDouble kmax);
    8383                #endif
    8484                #ifdef _HAVE_THERMAL_
    85                 ElementMatrix* PenaltyCreateKMatrixThermal(double kmax);
    86                 ElementMatrix* PenaltyCreateKMatrixMelting(double kmax);
    87                 ElementVector* PenaltyCreatePVectorThermal(double kmax);
    88                 ElementVector* PenaltyCreatePVectorMelting(double kmax);
     85                ElementMatrix* PenaltyCreateKMatrixThermal(IssmDouble kmax);
     86                ElementMatrix* PenaltyCreateKMatrixMelting(IssmDouble kmax);
     87                ElementVector* PenaltyCreatePVectorThermal(IssmDouble kmax);
     88                ElementVector* PenaltyCreatePVectorMelting(IssmDouble kmax);
    8989                #endif
    9090                void  ConstraintActivate(int* punstable);
    9191                void  ConstraintActivateThermal(int* punstable);
    92                 void  UpdateInputs(double* solution);
     92                void  UpdateInputs(IssmDouble* solution);
    9393                void  ResetConstraint(void);
    9494                /*}}}*/
  • issm/trunk/src/c/objects/Loads/Penpair.cpp

    r12330 r12706  
    44
    55/*Headers*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88#include <config.h>
     
    2323
    2424/*Penpair constructors and destructor*/
    25 /*FUNCTION Penpair::constructor {{{1*/
     25/*FUNCTION Penpair::constructor {{{*/
    2626Penpair::Penpair(){
    2727
     
    3131        return;
    3232}
    33 /*}}}1*/
    34 /*FUNCTION Penpair::creation {{{1*/
     33/*}}}*/
     34/*FUNCTION Penpair::creation {{{*/
    3535Penpair::Penpair(int penpair_id, int* penpair_node_ids,int in_analysis_type){
    3636       
     
    4343        return;
    4444}
    45 /*}}}1*/
    46 /*FUNCTION Penpair::destructor {{{1*/
     45/*}}}*/
     46/*FUNCTION Penpair::destructor {{{*/
    4747Penpair::~Penpair(){
    4848        delete hnodes;
    4949        return;
    5050}
    51 /*}}}1*/
     51/*}}}*/
    5252
    5353/*Object virtual functions definitions:*/
    54 /*FUNCTION Penpair::Echo {{{1*/
     54/*FUNCTION Penpair::Echo {{{*/
    5555void Penpair::Echo(void){
    5656
    5757        int i;
    5858
    59         printf("Penpair:\n");
    60         printf("   id: %i\n",id);
    61         printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
     59        _printLine_("Penpair:");
     60        _printLine_("   id: " << id);
     61        _printLine_("   analysis_type: " << EnumToStringx(analysis_type));
    6262        hnodes->Echo();
    6363       
    6464        return;
    6565}
    66 /*}}}1*/
    67 /*FUNCTION Penpair::DeepEcho {{{1*/
     66/*}}}*/
     67/*FUNCTION Penpair::DeepEcho {{{*/
    6868void Penpair::DeepEcho(void){
    6969
    70         printf("Penpair:\n");
    71         printf("   id: %i\n",id);
    72         printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
     70        _printLine_("Penpair:");
     71        _printLine_("   id: " << id);
     72        _printLine_("   analysis_type: " << EnumToStringx(analysis_type));
    7373        hnodes->DeepEcho();
    7474
    7575        return;
    7676}               
    77 /*}}}1*/
    78 /*FUNCTION Penpair::Id {{{1*/
     77/*}}}*/
     78/*FUNCTION Penpair::Id {{{*/
    7979int    Penpair::Id(void){ return id; }
    80 /*}}}1*/
    81 /*FUNCTION Penpair::MyRank {{{1*/
     80/*}}}*/
     81/*FUNCTION Penpair::MyRank {{{*/
    8282int    Penpair::MyRank(void){
    8383        extern int my_rank;
    8484        return my_rank;
    8585}
    86 /*}}}1*/
    87 /*FUNCTION Penpair::ObjectEnum{{{1*/
     86/*}}}*/
     87/*FUNCTION Penpair::ObjectEnum{{{*/
    8888int Penpair::ObjectEnum(void){
    8989
    9090        return PenpairEnum;
    9191}
    92 /*}}}1*/
    93 /*FUNCTION Penpair::copy {{{1*/
     92/*}}}*/
     93/*FUNCTION Penpair::copy {{{*/
    9494Object* Penpair::copy() {
    9595       
     
    115115               
    116116/*Load virtual functions definitions:*/
    117 /*FUNCTION Penpair::Configure {{{1*/
     117/*FUNCTION Penpair::Configure {{{*/
    118118void  Penpair::Configure(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){
    119119
     
    129129
    130130}
    131 /*}}}1*/
    132 /*FUNCTION Penpair::SetCurrentConfiguration {{{1*/
     131/*}}}*/
     132/*FUNCTION Penpair::SetCurrentConfiguration {{{*/
    133133void  Penpair::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){
    134134
    135135}
    136 /*}}}1*/
    137 /*FUNCTION Penpair::CreateKMatrix {{{1*/
     136/*}}}*/
     137/*FUNCTION Penpair::CreateKMatrix {{{*/
    138138void  Penpair::CreateKMatrix(Matrix* Kff, Matrix* Kfs){
    139139        /*If you code this piece, don't forget that a penalty will be inactive if it is dealing with clone nodes*/
     
    142142
    143143}
    144 /*}}}1*/
    145 /*FUNCTION Penpair::CreatePVector {{{1*/
     144/*}}}*/
     145/*FUNCTION Penpair::CreatePVector {{{*/
    146146void  Penpair::CreatePVector(Vector* pf){
    147147
     
    150150
    151151}
    152 /*}}}1*/
    153 /*FUNCTION Penpair::CreateJacobianMatrix{{{1*/
     152/*}}}*/
     153/*FUNCTION Penpair::CreateJacobianMatrix{{{*/
    154154void  Penpair::CreateJacobianMatrix(Matrix* Jff){
    155155        this->CreateKMatrix(Jff,NULL);
    156156}
    157 /*}}}1*/
    158 /*FUNCTION Penpair::PenaltyCreateKMatrix {{{1*/
    159 void  Penpair::PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs,double kmax){
     157/*}}}*/
     158/*FUNCTION Penpair::PenaltyCreateKMatrix {{{*/
     159void  Penpair::PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs,IssmDouble kmax){
    160160
    161161        /*Retrieve parameters: */
     
    172172                        break;
    173173                default:
    174                         _error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
     174                        _error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
    175175        }
    176176
     
    181181        }
    182182}
    183 /*}}}1*/
    184 /*FUNCTION Penpair::PenaltyCreatePVector {{{1*/
    185 void  Penpair::PenaltyCreatePVector(Vector* pf,double kmax){
     183/*}}}*/
     184/*FUNCTION Penpair::PenaltyCreatePVector {{{*/
     185void  Penpair::PenaltyCreatePVector(Vector* pf,IssmDouble kmax){
    186186        /*No loads applied, do nothing: */
    187187        return;
    188188}
    189 /*}}}1*/
    190 /*FUNCTION Penpair::PenaltyCreateJacobianMatrix{{{1*/
    191 void  Penpair::PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax){
     189/*}}}*/
     190/*FUNCTION Penpair::PenaltyCreateJacobianMatrix{{{*/
     191void  Penpair::PenaltyCreateJacobianMatrix(Matrix* Jff,IssmDouble kmax){
    192192        this->PenaltyCreateKMatrix(Jff,NULL,kmax);
    193193}
    194 /*}}}1*/
    195 /*FUNCTION Penpair::InAnalysis{{{1*/
     194/*}}}*/
     195/*FUNCTION Penpair::InAnalysis{{{*/
    196196bool Penpair::InAnalysis(int in_analysis_type){
    197197        if (in_analysis_type==this->analysis_type)return true;
     
    201201
    202202/*Update virtual functions definitions:*/
    203 /*FUNCTION Penpair::InputUpdateFromConstant(double constant, int name) {{{1*/
    204 void  Penpair::InputUpdateFromConstant(double constant, int name){
    205         /*Nothing updated yet*/
    206 }
    207 /*}}}*/
    208 /*FUNCTION Penpair::InputUpdateFromConstant(int constant, int name) {{{1*/
     203/*FUNCTION Penpair::InputUpdateFromConstant(IssmDouble constant, int name) {{{*/
     204void  Penpair::InputUpdateFromConstant(IssmDouble constant, int name){
     205        /*Nothing updated yet*/
     206}
     207/*}}}*/
     208/*FUNCTION Penpair::InputUpdateFromConstant(int constant, int name) {{{*/
    209209void  Penpair::InputUpdateFromConstant(int constant, int name){
    210210        /*Nothing updated yet*/
    211211}
    212212/*}}}*/
    213 /*FUNCTION Penpair::InputUpdateFromConstant(bool constant, int name) {{{1*/
     213/*FUNCTION Penpair::InputUpdateFromConstant(bool constant, int name) {{{*/
    214214void  Penpair::InputUpdateFromConstant(bool constant, int name){
    215215        /*Nothing updated yet*/
    216216}
    217217/*}}}*/
    218 /*FUNCTION Penpair::InputUpdateFromVector(double* vector, int name, int type) {{{1*/
    219 void  Penpair::InputUpdateFromVector(double* vector, int name, int type){
    220         /*Nothing updated yet*/
    221 }
    222 /*}}}*/
    223 /*FUNCTION Penpair::InputUpdateFromVector(int* vector, int name, int type) {{{1*/
     218/*FUNCTION Penpair::InputUpdateFromVector(IssmDouble* vector, int name, int type) {{{*/
     219void  Penpair::InputUpdateFromVector(IssmDouble* vector, int name, int type){
     220        /*Nothing updated yet*/
     221}
     222/*}}}*/
     223/*FUNCTION Penpair::InputUpdateFromVector(int* vector, int name, int type) {{{*/
    224224void  Penpair::InputUpdateFromVector(int* vector, int name, int type){
    225225        /*Nothing updated yet*/
    226226}
    227227/*}}}*/
    228 /*FUNCTION Penpair::InputUpdateFromVector(bool* vector, int name, int type) {{{1*/
     228/*FUNCTION Penpair::InputUpdateFromVector(bool* vector, int name, int type) {{{*/
    229229void  Penpair::InputUpdateFromVector(bool* vector, int name, int type){
    230230        /*Nothing updated yet*/
     
    233233
    234234/*Penpair management:*/
    235 /*FUNCTION Penpair::PenaltyCreateKMatrixDiagnosticHoriz{{{1*/
    236 ElementMatrix* Penpair::PenaltyCreateKMatrixDiagnosticHoriz(double kmax){
     235/*FUNCTION Penpair::PenaltyCreateKMatrixDiagnosticHoriz{{{*/
     236ElementMatrix* Penpair::PenaltyCreateKMatrixDiagnosticHoriz(IssmDouble kmax){
    237237
    238238        int    approximation0=nodes[0]->GetApproximation();
     
    244244                                case MacAyealApproximationEnum: return PenaltyCreateKMatrixDiagnosticMacAyealPattyn(kmax);
    245245                                case PattynApproximationEnum:   return PenaltyCreateKMatrixDiagnosticMacAyealPattyn(kmax);
    246                                 default: _error_("not supported yet");
     246                                default: _error2_("not supported yet");
    247247                        }
    248248                case PattynApproximationEnum:
     
    250250                                case MacAyealApproximationEnum: return PenaltyCreateKMatrixDiagnosticMacAyealPattyn(kmax);
    251251                                case PattynApproximationEnum:   return PenaltyCreateKMatrixDiagnosticMacAyealPattyn(kmax);
    252                                 default: _error_("not supported yet");
     252                                default: _error2_("not supported yet");
    253253                        }
    254254                case StokesApproximationEnum:
     
    256256                                case StokesApproximationEnum: return PenaltyCreateKMatrixDiagnosticStokes(kmax);
    257257                                case NoneApproximationEnum: return   PenaltyCreateKMatrixDiagnosticStokes(kmax);
    258                                 default: _error_("not supported yet");
     258                                default: _error2_("not supported yet");
    259259                        }
    260260                case NoneApproximationEnum:
     
    262262                                case StokesApproximationEnum: return PenaltyCreateKMatrixDiagnosticStokes(kmax);
    263263                                case NoneApproximationEnum: return   PenaltyCreateKMatrixDiagnosticStokes(kmax);
    264                                 default: _error_("not supported yet");
     264                                default: _error2_("not supported yet");
    265265                        }
    266                 default: _error_("not supported yet");
     266                default: _error2_("not supported yet");
    267267        }
    268268}
    269 /*}}}1*/
    270 /*FUNCTION Penpair::PenaltyCreateKMatrixDiagnosticMacAyealPattyn {{{1*/
    271 ElementMatrix* Penpair::PenaltyCreateKMatrixDiagnosticMacAyealPattyn(double kmax){
     269/*}}}*/
     270/*FUNCTION Penpair::PenaltyCreateKMatrixDiagnosticMacAyealPattyn {{{*/
     271ElementMatrix* Penpair::PenaltyCreateKMatrixDiagnosticMacAyealPattyn(IssmDouble kmax){
    272272       
    273273        const int numdof=NUMVERTICES*NDOF2;
    274         double penalty_offset;
     274        IssmDouble penalty_offset;
    275275
    276276        /*Initialize Element vector and return if necessary*/
     
    281281
    282282        //Create elementary matrix: add penalty to
    283         Ke->values[0*numdof+0]=+kmax*pow((double)10.0,penalty_offset);
    284         Ke->values[0*numdof+2]=-kmax*pow((double)10.0,penalty_offset);
    285         Ke->values[2*numdof+0]=-kmax*pow((double)10.0,penalty_offset);
    286         Ke->values[2*numdof+2]=+kmax*pow((double)10.0,penalty_offset);
    287 
    288         Ke->values[1*numdof+1]=+kmax*pow((double)10.0,penalty_offset);
    289         Ke->values[1*numdof+3]=-kmax*pow((double)10.0,penalty_offset);
    290         Ke->values[3*numdof+1]=-kmax*pow((double)10.0,penalty_offset);
    291         Ke->values[3*numdof+3]=+kmax*pow((double)10.0,penalty_offset);
     283        Ke->values[0*numdof+0]=+kmax*pow((IssmDouble)10.0,penalty_offset);
     284        Ke->values[0*numdof+2]=-kmax*pow((IssmDouble)10.0,penalty_offset);
     285        Ke->values[2*numdof+0]=-kmax*pow((IssmDouble)10.0,penalty_offset);
     286        Ke->values[2*numdof+2]=+kmax*pow((IssmDouble)10.0,penalty_offset);
     287
     288        Ke->values[1*numdof+1]=+kmax*pow((IssmDouble)10.0,penalty_offset);
     289        Ke->values[1*numdof+3]=-kmax*pow((IssmDouble)10.0,penalty_offset);
     290        Ke->values[3*numdof+1]=-kmax*pow((IssmDouble)10.0,penalty_offset);
     291        Ke->values[3*numdof+3]=+kmax*pow((IssmDouble)10.0,penalty_offset);
    292292
    293293        /*Clean up and return*/
    294294        return Ke;
    295295}
    296 /*}}}1*/
    297 /*FUNCTION Penpair::PenaltyCreateKMatrixDiagnosticStokes {{{1*/
    298 ElementMatrix* Penpair::PenaltyCreateKMatrixDiagnosticStokes(double kmax){
     296/*}}}*/
     297/*FUNCTION Penpair::PenaltyCreateKMatrixDiagnosticStokes {{{*/
     298ElementMatrix* Penpair::PenaltyCreateKMatrixDiagnosticStokes(IssmDouble kmax){
    299299       
    300300        const int numdof=NUMVERTICES*NDOF4;
    301         double penalty_offset;
     301        IssmDouble penalty_offset;
    302302
    303303        /*Initialize Element vector and return if necessary*/
     
    308308
    309309        //Create elementary matrix: add penalty to
    310         Ke->values[0*numdof+0]=+kmax*pow((double)10.0,penalty_offset);
    311         Ke->values[0*numdof+4]=-kmax*pow((double)10.0,penalty_offset);
    312         Ke->values[4*numdof+0]=-kmax*pow((double)10.0,penalty_offset);
    313         Ke->values[4*numdof+4]=+kmax*pow((double)10.0,penalty_offset);
    314 
    315         Ke->values[1*numdof+1]=+kmax*pow((double)10.0,penalty_offset);
    316         Ke->values[1*numdof+5]=-kmax*pow((double)10.0,penalty_offset);
    317         Ke->values[5*numdof+1]=-kmax*pow((double)10.0,penalty_offset);
    318         Ke->values[5*numdof+5]=+kmax*pow((double)10.0,penalty_offset);
    319        
    320         Ke->values[2*numdof+2]=+kmax*pow((double)10.0,penalty_offset);
    321         Ke->values[2*numdof+6]=-kmax*pow((double)10.0,penalty_offset);
    322         Ke->values[6*numdof+2]=-kmax*pow((double)10.0,penalty_offset);
    323         Ke->values[6*numdof+6]=+kmax*pow((double)10.0,penalty_offset);
    324 
    325         Ke->values[3*numdof+3]=+kmax*pow((double)10.0,penalty_offset);
    326         Ke->values[3*numdof+7]=-kmax*pow((double)10.0,penalty_offset);
    327         Ke->values[7*numdof+3]=-kmax*pow((double)10.0,penalty_offset);
    328         Ke->values[7*numdof+7]=+kmax*pow((double)10.0,penalty_offset);
     310        Ke->values[0*numdof+0]=+kmax*pow((IssmDouble)10.0,penalty_offset);
     311        Ke->values[0*numdof+4]=-kmax*pow((IssmDouble)10.0,penalty_offset);
     312        Ke->values[4*numdof+0]=-kmax*pow((IssmDouble)10.0,penalty_offset);
     313        Ke->values[4*numdof+4]=+kmax*pow((IssmDouble)10.0,penalty_offset);
     314
     315        Ke->values[1*numdof+1]=+kmax*pow((IssmDouble)10.0,penalty_offset);
     316        Ke->values[1*numdof+5]=-kmax*pow((IssmDouble)10.0,penalty_offset);
     317        Ke->values[5*numdof+1]=-kmax*pow((IssmDouble)10.0,penalty_offset);
     318        Ke->values[5*numdof+5]=+kmax*pow((IssmDouble)10.0,penalty_offset);
     319       
     320        Ke->values[2*numdof+2]=+kmax*pow((IssmDouble)10.0,penalty_offset);
     321        Ke->values[2*numdof+6]=-kmax*pow((IssmDouble)10.0,penalty_offset);
     322        Ke->values[6*numdof+2]=-kmax*pow((IssmDouble)10.0,penalty_offset);
     323        Ke->values[6*numdof+6]=+kmax*pow((IssmDouble)10.0,penalty_offset);
     324
     325        Ke->values[3*numdof+3]=+kmax*pow((IssmDouble)10.0,penalty_offset);
     326        Ke->values[3*numdof+7]=-kmax*pow((IssmDouble)10.0,penalty_offset);
     327        Ke->values[7*numdof+3]=-kmax*pow((IssmDouble)10.0,penalty_offset);
     328        Ke->values[7*numdof+7]=+kmax*pow((IssmDouble)10.0,penalty_offset);
    329329
    330330        /*Clean up and return*/
    331331        return Ke;
    332332}
    333 /*}}}1*/
    334 /*FUNCTION Penpair::PenaltyCreateKMatrixPrognostic {{{1*/
    335 ElementMatrix* Penpair::PenaltyCreateKMatrixPrognostic(double kmax){
     333/*}}}*/
     334/*FUNCTION Penpair::PenaltyCreateKMatrixPrognostic {{{*/
     335ElementMatrix* Penpair::PenaltyCreateKMatrixPrognostic(IssmDouble kmax){
    336336
    337337        const int numdof=NUMVERTICES*NDOF1;
    338         double penalty_factor;
     338        IssmDouble penalty_factor;
    339339
    340340        /*Initialize Element vector and return if necessary*/
     
    345345
    346346        //Create elementary matrix: add penalty to
    347         Ke->values[0*numdof+0]=+kmax*pow((double)10.0,penalty_factor);
    348         Ke->values[0*numdof+1]=-kmax*pow((double)10.0,penalty_factor);
    349         Ke->values[1*numdof+0]=-kmax*pow((double)10.0,penalty_factor);
    350         Ke->values[1*numdof+1]=+kmax*pow((double)10.0,penalty_factor);
     347        Ke->values[0*numdof+0]=+kmax*pow((IssmDouble)10.0,penalty_factor);
     348        Ke->values[0*numdof+1]=-kmax*pow((IssmDouble)10.0,penalty_factor);
     349        Ke->values[1*numdof+0]=-kmax*pow((IssmDouble)10.0,penalty_factor);
     350        Ke->values[1*numdof+1]=+kmax*pow((IssmDouble)10.0,penalty_factor);
    351351
    352352        /*Clean up and return*/
    353353        return Ke;
    354354}
    355 /*}}}1*/
     355/*}}}*/
  • issm/trunk/src/c/objects/Loads/Penpair.h

    r12330 r12706  
    66
    77/*Headers:*/
    8 /*{{{1*/
     8/*{{{*/
    99#include "./Load.h"
    1010#include "../Node.h"
     
    2727        public:
    2828
    29                 /*Penpair constructors, destructors: {{{1*/
     29                /*Penpair constructors, destructors: {{{*/
    3030                Penpair();
    3131                Penpair(int penpair_id,int* penpair_node_ids,int analysis_type);
    3232                ~Penpair();
    3333                /*}}}*/
    34                 /*Object virtual functions definitions:{{{1 */
     34                /*Object virtual functions definitions:{{{ */
    3535                void  Echo();
    3636                void  DeepEcho();
     
    4040                Object* copy();
    4141                /*}}}*/
    42                 /*Update virtual functions resolution: {{{1*/
    43                 void  InputUpdateFromVector(double* vector, int name, int type);
     42                /*Update virtual functions resolution: {{{*/
     43                void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
    4444                void  InputUpdateFromVector(int* vector, int name, int type);
    4545                void  InputUpdateFromVector(bool* vector, int name, int type);
    46                 void  InputUpdateFromMatrixDakota(double* matrix, int nrow, int ncols,int name, int type){_error_("Not implemented yet!");}
    47                 void  InputUpdateFromVectorDakota(double* vector, int name, int type){_error_("Not implemented yet!");}
    48                 void  InputUpdateFromVectorDakota(int* vector, int name, int type){_error_("Not implemented yet!");}
    49                 void  InputUpdateFromVectorDakota(bool* vector, int name, int type){_error_("Not implemented yet!");}
    50                 void  InputUpdateFromConstant(double constant, int name);
     46                void  InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrow, int ncols,int name, int type){_error2_("Not implemented yet!");}
     47                void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){_error2_("Not implemented yet!");}
     48                void  InputUpdateFromVectorDakota(int* vector, int name, int type){_error2_("Not implemented yet!");}
     49                void  InputUpdateFromVectorDakota(bool* vector, int name, int type){_error2_("Not implemented yet!");}
     50                void  InputUpdateFromConstant(IssmDouble constant, int name);
    5151                void  InputUpdateFromConstant(int constant, int name);
    5252                void  InputUpdateFromConstant(bool constant, int name);
    53                 void  InputUpdateFromSolution(double* solution){_error_("Not implemented yet!");}
    54                 void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("not implemented yet");};
     53                void  InputUpdateFromSolution(IssmDouble* solution){_error2_("Not implemented yet!");}
     54                void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error2_("not implemented yet");};
    5555                /*}}}*/
    56                         /*Load virtual functions definitions: {{{1*/
     56                        /*Load virtual functions definitions: {{{*/
    5757                void  Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
    5858                void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
     
    6060                void  CreatePVector(Vector* pf);
    6161                void  CreateJacobianMatrix(Matrix* Jff);
    62                 void  PenaltyCreateKMatrix(Matrix* Kff,Matrix* Kfs,double kmax);
    63                 void  PenaltyCreatePVector(Vector* pf, double kmax);
    64                 void  PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax);
     62                void  PenaltyCreateKMatrix(Matrix* Kff,Matrix* Kfs,IssmDouble kmax);
     63                void  PenaltyCreatePVector(Vector* pf, IssmDouble kmax);
     64                void  PenaltyCreateJacobianMatrix(Matrix* Jff,IssmDouble kmax);
    6565                bool  InAnalysis(int analysis_type);
    6666                /*}}}*/
    67                         /*Penpair management: {{{1*/
    68                 ElementMatrix* PenaltyCreateKMatrixDiagnosticHoriz(double kmax);
    69                 ElementMatrix* PenaltyCreateKMatrixDiagnosticMacAyealPattyn(double kmax);
    70                 ElementMatrix* PenaltyCreateKMatrixDiagnosticStokes(double kmax);
    71                 ElementMatrix* PenaltyCreateKMatrixPrognostic(double kmax);
     67                        /*Penpair management: {{{*/
     68                ElementMatrix* PenaltyCreateKMatrixDiagnosticHoriz(IssmDouble kmax);
     69                ElementMatrix* PenaltyCreateKMatrixDiagnosticMacAyealPattyn(IssmDouble kmax);
     70                ElementMatrix* PenaltyCreateKMatrixDiagnosticStokes(IssmDouble kmax);
     71                ElementMatrix* PenaltyCreateKMatrixPrognostic(IssmDouble kmax);
    7272                /*}}}*/
    7373};
  • issm/trunk/src/c/objects/Loads/Riftfront.cpp

    r12330 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2424
    2525/*Riftfront constructors and destructor*/
    26 /*FUNCTION Riftfront::Riftfront(){{{1*/
     26/*FUNCTION Riftfront::Riftfront(){{{*/
    2727Riftfront::Riftfront(){
    2828        this->inputs=NULL;
     
    3636}
    3737/*}}}*/
    38 /*FUNCTION Riftfront::Riftfront(int id, int i, IoModel* iomodel,int analysis_type){{{1*/
     38/*FUNCTION Riftfront::Riftfront(int id, int i, IoModel* iomodel,int analysis_type){{{*/
    3939Riftfront::Riftfront(int riftfront_id,int i, IoModel* iomodel,int riftfront_analysis_type){
    4040
     
    4545        int    riftfront_type;
    4646        int    riftfront_fill;
    47         double riftfront_friction;
    48         double riftfront_fractionincrement;
     47        IssmDouble riftfront_friction;
     48        IssmDouble riftfront_fractionincrement;
    4949        bool   riftfront_shelf;
    5050        int    numberofelements;
     
    117117               
    118118}
    119 /*}}}1*/
    120 /*FUNCTION Riftfront::~Riftfront(){{{1*/
     119/*}}}*/
     120/*FUNCTION Riftfront::~Riftfront(){{{*/
    121121Riftfront::~Riftfront(){
    122122        delete inputs;
     
    130130
    131131/*Object virtual functions definitions:*/
    132 /*FUNCTION Riftfront::Echo {{{1*/
     132/*FUNCTION Riftfront::Echo {{{*/
    133133void Riftfront::Echo(void){
    134134
    135135        Input* input=NULL;
    136136        int fill;
    137         double friction,fractionincrement;
     137        IssmDouble friction,fractionincrement;
    138138
    139139       
     
    143143        input=(Input*)this->inputs->GetInput(FractionIncrementEnum); input->GetInputValue(&fractionincrement);
    144144
    145         printf("Riftfront:\n");
    146         printf("   id: %i\n",id);
    147         printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
    148         printf("   hnodes: %p\n",hnodes);
    149         printf("   helements: %p\n",helements);
    150         printf("   hmatpar: %p\n",hmatpar);
    151         printf("   parameters: %p\n",parameters);
    152         printf("   inputs: %p\n",inputs);
    153         printf("   internal parameters: \n");
    154         printf("   normal: %g|%g\n",normal[0],normal[1]);
    155         printf("   length: %g\n",length);
    156         printf("   penalty_lock: %i\n",penalty_lock);
    157         printf("   active: %s\n",active ? "true":"false");
    158         printf("   counter: %i\n",counter);
    159         printf("   prestable: %s\n",prestable ? "true":"false");
    160         printf("   material_converged: %s\n",material_converged ? "true":"false");
    161         printf("   fill: %i\n",fill);
    162         printf("   friction: %g\n",friction);
    163         printf("   fraction: %g\n",fraction);
    164         printf("   fractionincrement: %g\n",fractionincrement);
    165         printf("   state: %i\n",state);
    166         printf("   frozen: %s\n",frozen ? "true":"false");
     145        _printLine_("Riftfront:");
     146        _printLine_("   id: " << id);
     147        _printLine_("   analysis_type: " << EnumToStringx(analysis_type));
     148        _printLine_("   hnodes: " << hnodes);
     149        _printLine_("   helements: " << helements);
     150        _printLine_("   hmatpar: " << hmatpar);
     151        _printLine_("   parameters: " << parameters);
     152        _printLine_("   inputs: " << inputs);
     153        _printLine_("   internal parameters: ");
     154        _printLine_("   normal: " << normal[0] << "|" << normal[1]);
     155        _printLine_("   length: " << length);
     156        _printLine_("   penalty_lock: " << penalty_lock);
     157        _printLine_("   active: " <<(active ? "true":"false"));
     158        _printLine_("   counter: " << counter);
     159        _printLine_("   prestable: " << (prestable ? "true":"false"));
     160        _printLine_("   material_converged: " << (material_converged ? "true":"false"));
     161        _printLine_("   fill: " << fill);
     162        _printLine_("   friction: " << friction);
     163        _printLine_("   fraction: " << fraction);
     164        _printLine_("   fractionincrement: " << fractionincrement);
     165        _printLine_("   state: " << state);
     166        _printLine_("   frozen: " << (frozen ? "true":"false"));
    167167               
    168168}
    169 /*}}}1*/
    170 /*FUNCTION Riftfront::DeepEcho{{{1*/
     169/*}}}*/
     170/*FUNCTION Riftfront::DeepEcho{{{*/
    171171void Riftfront::DeepEcho(void){
    172172
    173         printf("Riftfront:\n");
    174         printf("   id: %i\n",id);
    175         printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
     173        _printLine_("Riftfront:");
     174        _printLine_("   id: " << id);
     175        _printLine_("   analysis_type: " << EnumToStringx(analysis_type));
    176176        hnodes->DeepEcho();
    177177        helements->DeepEcho();
    178178        hmatpar->DeepEcho();
    179         printf("   parameters\n");
     179        _printLine_("   parameters");
    180180        if(parameters)parameters->DeepEcho();
    181         printf("   inputs\n");
     181        _printLine_("   inputs");
    182182        if(inputs)inputs->DeepEcho();
    183183}
    184184/*}}}*/
    185 /*FUNCTION Riftfront::Id {{{1*/
     185/*FUNCTION Riftfront::Id {{{*/
    186186int    Riftfront::Id(void){ return id; }
    187 /*}}}1*/
    188 /*FUNCTION Riftfront::MyRank {{{1*/
     187/*}}}*/
     188/*FUNCTION Riftfront::MyRank {{{*/
    189189int    Riftfront::MyRank(void){
    190190        extern int my_rank;
    191191        return my_rank;
    192192}
    193 /*}}}1*/
    194 /*FUNCTION Riftfront::ObjectEnum{{{1*/
     193/*}}}*/
     194/*FUNCTION Riftfront::ObjectEnum{{{*/
    195195int Riftfront::ObjectEnum(void){
    196196
     
    198198
    199199}
    200 /*}}}1*/
    201 /*FUNCTION Riftfront::copy {{{1*/
     200/*}}}*/
     201/*FUNCTION Riftfront::copy {{{*/
    202202Object* Riftfront::copy() {
    203203       
     
    247247               
    248248/*Update virtual functions definitions:*/
    249 /*FUNCTION Riftfront::InputUpdateFromConstant(bool constant,int name) {{{1*/
     249/*FUNCTION Riftfront::InputUpdateFromConstant(bool constant,int name) {{{*/
    250250void  Riftfront::InputUpdateFromConstant(bool constant,int name){
    251251
     
    258258}
    259259/*}}}*/
    260 /*FUNCTION Riftfront::InputUpdateFromConstant(double constant,int name) {{{1*/
    261 void  Riftfront::InputUpdateFromConstant(double constant,int name){
     260/*FUNCTION Riftfront::InputUpdateFromConstant(IssmDouble constant,int name) {{{*/
     261void  Riftfront::InputUpdateFromConstant(IssmDouble constant,int name){
    262262
    263263        /*Check that name is a Riftfront input*/
     
    269269}
    270270/*}}}*/
    271 /*FUNCTION Riftfront::InputUpdateFromConstant(double* constant,int name) {{{1*/
    272 void    Riftfront::InputUpdateFromVector(double* vector, int name, int type){
     271/*FUNCTION Riftfront::InputUpdateFromConstant(IssmDouble* constant,int name) {{{*/
     272void    Riftfront::InputUpdateFromVector(IssmDouble* vector, int name, int type){
    273273
    274274        /*Check that name is a Riftfront input*/
     
    276276
    277277        /*update input*/
    278         _error_("not implemented yet");
     278        _error2_("not implemented yet");
    279279        //this->inputs->AddInput(new DoubleInput(name,constant));
    280280
     
    284284
    285285/*Load virtual functions definitions:*/
    286 /*FUNCTION Riftfront::Configure {{{1*/
     286/*FUNCTION Riftfront::Configure {{{*/
    287287void  Riftfront::Configure(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){
    288288
     
    303303}
    304304/*}}}*/
    305 /*FUNCTION Riftfront::SetCurrentConfiguration {{{1*/
     305/*FUNCTION Riftfront::SetCurrentConfiguration {{{*/
    306306void  Riftfront::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){
    307307
    308308}
    309309/*}}}*/
    310 /*FUNCTION Riftfront::PenaltyCreateKMatrix {{{1*/
    311 void  Riftfront::PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs,double kmax){
     310/*FUNCTION Riftfront::PenaltyCreateKMatrix {{{*/
     311void  Riftfront::PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs,IssmDouble kmax){
    312312
    313313        /*Retrieve parameters: */
     
    324324                        break;
    325325                default:
    326                         _error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
     326                        _error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
    327327        }
    328328
     
    333333        }
    334334}
    335 /*}}}1*/
    336 /*FUNCTION Riftfront::PenaltyCreatePVector {{{1*/
    337 void  Riftfront::PenaltyCreatePVector(Vector* pf,double kmax){
     335/*}}}*/
     336/*FUNCTION Riftfront::PenaltyCreatePVector {{{*/
     337void  Riftfront::PenaltyCreatePVector(Vector* pf,IssmDouble kmax){
    338338
    339339        /*Retrieve parameters: */
     
    350350                        break;
    351351                default:
    352                         _error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
     352                        _error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
    353353        }
    354354
     
    359359        }
    360360}
    361 /*}}}1*/
    362 /*FUNCTION Riftfront::CreateKMatrix {{{1*/
     361/*}}}*/
     362/*FUNCTION Riftfront::CreateKMatrix {{{*/
    363363void  Riftfront::CreateKMatrix(Matrix* Kff, Matrix* Kfs){
    364364        /*do nothing: */
    365365        return;
    366366}
    367 /*}}}1*/
    368 /*FUNCTION Riftfront::CreatePVector {{{1*/
     367/*}}}*/
     368/*FUNCTION Riftfront::CreatePVector {{{*/
    369369void  Riftfront::CreatePVector(Vector* pf){
    370370        /*do nothing: */
    371371        return;
    372372}
    373 /*}}}1*/
    374 /*FUNCTION Riftfront::InAnalysis{{{1*/
     373/*}}}*/
     374/*FUNCTION Riftfront::InAnalysis{{{*/
    375375bool Riftfront::InAnalysis(int in_analysis_type){
    376376        if (in_analysis_type==this->analysis_type) return true;
     
    380380
    381381/*Riftfront numerics*/
    382 /*FUNCTION Riftfront::PenaltyCreateKMatrixDiagnosticHoriz {{{1*/
    383 ElementMatrix* Riftfront::PenaltyCreateKMatrixDiagnosticHoriz(double kmax){
     382/*FUNCTION Riftfront::PenaltyCreateKMatrixDiagnosticHoriz {{{*/
     383ElementMatrix* Riftfront::PenaltyCreateKMatrixDiagnosticHoriz(IssmDouble kmax){
    384384
    385385        const int   numdof = NDOF2*NUMVERTICES;
    386386        int         i,j;
    387387        int         dofs[1]             = {0};
    388         double      Ke_gg[4][4];
    389         double      thickness;
    390         double      h[2];
    391         double      penalty_offset;
    392         double      friction;
     388        IssmDouble      Ke_gg[4][4];
     389        IssmDouble      thickness;
     390        IssmDouble      h[2];
     391        IssmDouble      penalty_offset;
     392        IssmDouble      friction;
    393393
    394394        /*Objects: */
     
    397397
    398398        /*enum of element? */
    399         if(elements[0]->ObjectEnum()!=TriaEnum)_error_(" only Tria element allowed for Riftfront load!");
     399        if(elements[0]->ObjectEnum()!=TriaEnum)_error2_("only Tria element allowed for Riftfront load!");
    400400        tria1=(Tria*)elements[0];
    401401        tria2=(Tria*)elements[1];
     
    410410        tria1->GetInputValue(&h[0],nodes[0],ThicknessEnum);
    411411        tria2->GetInputValue(&h[1],nodes[1],ThicknessEnum);
    412         if (h[0]!=h[1])_error_(" different thicknesses not supported for rift fronts");
     412        if (h[0]!=h[1])_error2_("different thicknesses not supported for rift fronts");
    413413        thickness=h[0];
    414414
     
    462462        return Ke;
    463463}
    464 /*}}}1*/
    465 /*FUNCTION Riftfront::PenaltyCreatePVectorDiagnosticHoriz {{{1*/
    466 ElementVector* Riftfront::PenaltyCreatePVectorDiagnosticHoriz(double kmax){
     464/*}}}*/
     465/*FUNCTION Riftfront::PenaltyCreatePVectorDiagnosticHoriz {{{*/
     466ElementVector* Riftfront::PenaltyCreatePVectorDiagnosticHoriz(IssmDouble kmax){
    467467
    468468        const int   numdof = NDOF2*NUMVERTICES;
    469469        int         i,j;
    470         double      rho_ice;
    471         double      rho_water;
    472         double      gravity;
    473         double      thickness;
    474         double      h[2];
    475         double      bed;
    476         double      b[2];
    477         double      pressure;
    478         double      pressure_litho;
    479         double      pressure_air;
    480         double      pressure_melange;
    481         double      pressure_water;
     470        IssmDouble      rho_ice;
     471        IssmDouble      rho_water;
     472        IssmDouble      gravity;
     473        IssmDouble      thickness;
     474        IssmDouble      h[2];
     475        IssmDouble      bed;
     476        IssmDouble      b[2];
     477        IssmDouble      pressure;
     478        IssmDouble      pressure_litho;
     479        IssmDouble      pressure_air;
     480        IssmDouble      pressure_melange;
     481        IssmDouble      pressure_water;
    482482        int         fill;
    483483        bool        shelf;
     
    488488
    489489        /*enum of element? */
    490         if(elements[0]->ObjectEnum()!=TriaEnum)_error_(" only Tria element allowed for Riftfront load!");
     490        if(elements[0]->ObjectEnum()!=TriaEnum)_error2_("only Tria element allowed for Riftfront load!");
    491491        tria1=(Tria*)elements[0];
    492492        tria2=(Tria*)elements[1];
     
    504504        tria1->GetInputValue(&h[0],nodes[0],ThicknessEnum);
    505505        tria2->GetInputValue(&h[1],nodes[1],ThicknessEnum);
    506         if (h[0]!=h[1])_error_(" different thicknesses not supported for rift fronts");
     506        if (h[0]!=h[1])_error2_("different thicknesses not supported for rift fronts");
    507507        thickness=h[0];
    508508        tria1->GetInputValue(&b[0],nodes[0],BedEnum);
    509509        tria2->GetInputValue(&b[1],nodes[1],BedEnum);
    510         if (b[0]!=b[1])_error_(" different beds not supported for rift fronts");
     510        if (b[0]!=b[1])_error2_("different beds not supported for rift fronts");
    511511        bed=b[0];
    512512
     
    521521                if(shelf){
    522522                        /*We are on an ice shelf, hydrostatic equilibrium is used to determine the pressure for water fill: */
    523                         pressure=rho_ice*gravity*pow(thickness,(double)2)/(double)2  - rho_water*gravity*pow(bed,(double)2)/(double)2;
     523                        pressure=rho_ice*gravity*pow(thickness,(IssmDouble)2)/(IssmDouble)2  - rho_water*gravity*pow(bed,(IssmDouble)2)/(IssmDouble)2;
    524524                }
    525525                else{
    526526                        //We are on an icesheet, we assume the water column fills the entire front: */
    527                         pressure=rho_ice*gravity*pow(thickness,(double)2)/(double)2  - rho_water*gravity*pow(thickness,(double)2)/(double)2;
     527                        pressure=rho_ice*gravity*pow(thickness,(IssmDouble)2)/(IssmDouble)2  - rho_water*gravity*pow(thickness,(IssmDouble)2)/(IssmDouble)2;
    528528                }
    529529        }
    530530        else if(fill==AirEnum){
    531                 pressure=rho_ice*gravity*pow(thickness,(double)2)/(double)2;   //icefront on an ice sheet, pressure imbalance ice vs air.
     531                pressure=rho_ice*gravity*pow(thickness,(IssmDouble)2)/(IssmDouble)2;   //icefront on an ice sheet, pressure imbalance ice vs air.
    532532        }
    533533        else if(fill==IceEnum){ //icefront finding itself against another icefront (pressure imbalance is fully compensated, ice vs ice)
     
    536536        else if(fill==MelangeEnum){ //icefront finding itself against another icefront (pressure imbalance is fully compensated, ice vs ice)
    537537
    538                 if(!shelf) _error_("%s%i%s","fill type ",fill," not supported on ice sheets yet.");
    539 
    540                 pressure_litho=rho_ice*gravity*pow(thickness,(double)2)/(double)2;
     538                if(!shelf) _error2_("fill type " << fill << " not supported on ice sheets yet.");
     539
     540                pressure_litho=rho_ice*gravity*pow(thickness,(IssmDouble)2)/(IssmDouble)2;
    541541                pressure_air=0;
    542                 pressure_melange=rho_ice*gravity*pow(fraction*thickness,(double)2)/(double)2;
     542                pressure_melange=rho_ice*gravity*pow(fraction*thickness,(IssmDouble)2)/(IssmDouble)2;
    543543                pressure_water=1.0/2.0*rho_water*gravity*  ( pow(bed,2.0)-pow(rho_ice/rho_water*fraction*thickness,2.0) );
    544544
     
    546546        }
    547547        else{
    548                 _error_("%s%i%s","fill type ",fill," not supported yet.");
     548                _error2_("fill type " << fill << " not supported yet.");
    549549        }
    550550
     
    562562        return pe;
    563563}
    564 /*}}}1*/
    565 /*FUNCTION Riftfront::Constrain {{{1*/
     564/*}}}*/
     565/*FUNCTION Riftfront::Constrain {{{*/
    566566#define _ZIGZAGCOUNTER_
    567567
     
    569569
    570570        const int   numnodes        = 2;
    571         double      max_penetration;
    572         double      penetration;
     571        IssmDouble      max_penetration;
     572        IssmDouble      penetration;
    573573        int         activate;
    574574        int         found;
    575575        int         unstable;
    576         double      vx1;
    577         double      vy1;
    578         double      vx2;
    579         double      vy2;
    580         double      fractionincrement;
     576        IssmDouble      vx1;
     577        IssmDouble      vy1;
     578        IssmDouble      vx2;
     579        IssmDouble      vy2;
     580        IssmDouble      fractionincrement;
    581581
    582582        /*Objects: */
     
    585585
    586586        /*enum of element? */
    587         if(elements[0]->ObjectEnum()!=TriaEnum)_error_(" only Tria element allowed for Riftfront load!");
     587        if(elements[0]->ObjectEnum()!=TriaEnum)_error2_("only Tria element allowed for Riftfront load!");
    588588
    589589        /*recover elements on both side of rift: */
     
    632632                /*increase melange fraction: */
    633633                this->fraction+=fractionincrement;
    634                 if (this->fraction>1)this->fraction=(double)1.0;
    635                 //printf("riftfront %i fraction: %g\n",this->Id(),this->fraction);
     634                if (this->fraction>1)this->fraction=(IssmDouble)1.0;
     635                //_printLine_("riftfront " << this->Id() << " fraction: " << this->fraction);
    636636        }
    637637
     
    648648        this->active=activate;
    649649
    650         //if ((penetration>0) && (this->active==1))printf("Riftfront %i wants to be released\n",Id());
     650        //if ((penetration>0) && (this->active==1))_printLine_("Riftfront " << Id() << " wants to be released");
    651651
    652652        /*assign output pointer: */
     
    654654        return 1;
    655655}
    656 /*}}}1*/
    657 /*FUNCTION Riftfront::FreezeConstraints{{{1*/
     656/*}}}*/
     657/*FUNCTION Riftfront::FreezeConstraints{{{*/
    658658void   Riftfront::FreezeConstraints(void){
    659659
     
    662662
    663663}
    664 /*}}}1*/
    665 /*FUNCTION Riftfront::IsFrozen{{{1*/
     664/*}}}*/
     665/*FUNCTION Riftfront::IsFrozen{{{*/
    666666bool   Riftfront::IsFrozen(void){
    667667
     
    670670        else return 0;
    671671}
    672 /*}}}1*/
    673 /*FUNCTION Riftfront::IsMaterialStable {{{1*/
     672/*}}}*/
     673/*FUNCTION Riftfront::IsMaterialStable {{{*/
    674674int   Riftfront::IsMaterialStable(void){
    675675
    676676        int found=0;
    677         double converged=0;
     677        IssmDouble converged=0;
    678678
    679679        this->inputs->GetInputValue(&converged,ConvergedEnum);
     
    688688        return this->material_converged;
    689689}
    690 /*}}}1*/
    691 /*FUNCTION Riftfront::MaxPenetration {{{1*/
    692 int   Riftfront::MaxPenetration(double* ppenetration){
     690/*}}}*/
     691/*FUNCTION Riftfront::MaxPenetration {{{*/
     692int   Riftfront::MaxPenetration(IssmDouble* ppenetration){
    693693
    694694        const int     numnodes=2;
    695         double        max_penetration;
    696         double        penetration=0;
     695        IssmDouble        max_penetration;
     696        IssmDouble        penetration=0;
    697697        int           found;
    698         double      vx1;
    699         double      vy1;
    700         double      vx2;
    701         double      vy2;
     698        IssmDouble      vx1;
     699        IssmDouble      vy1;
     700        IssmDouble      vx2;
     701        IssmDouble      vy2;
    702702
    703703        /*Objects: */
     
    706706
    707707        /*enum of element? */
    708         if(elements[0]->ObjectEnum()!=TriaEnum)_error_(" only Tria element allowed for Riftfront load!");
     708        if(elements[0]->ObjectEnum()!=TriaEnum)_error2_("only Tria element allowed for Riftfront load!");
    709709
    710710        /*recover elements on both side of rift: */
     
    734734        return 1;
    735735}
    736 /*}}}1*/
    737 /*FUNCTION Riftfront::Penetration {{{1*/
    738 int   Riftfront::Penetration(double* ppenetration){
    739 
    740         double    vx1;
    741         double    vy1;
    742         double    vx2;
    743         double    vy2;
    744 
    745         double    penetration;
     736/*}}}*/
     737/*FUNCTION Riftfront::Penetration {{{*/
     738int   Riftfront::Penetration(IssmDouble* ppenetration){
     739
     740        IssmDouble    vx1;
     741        IssmDouble    vy1;
     742        IssmDouble    vx2;
     743        IssmDouble    vy2;
     744
     745        IssmDouble    penetration;
    746746        int       found;
    747747
     
    751751
    752752        /*enum of element? */
    753         if(elements[0]->ObjectEnum()!=TriaEnum)_error_(" only Tria element allowed for Riftfront load!");
     753        if(elements[0]->ObjectEnum()!=TriaEnum)_error2_("only Tria element allowed for Riftfront load!");
    754754
    755755        /*recover elements on both side of rift: */
     
    773773        return 1;
    774774}
    775 /*}}}1*/
    776 /*FUNCTION Riftfront::PotentialUnstableConstraint {{{1*/
     775/*}}}*/
     776/*FUNCTION Riftfront::PotentialUnstableConstraint {{{*/
    777777int   Riftfront::PotentialUnstableConstraint(int* punstable){
    778778
    779779
    780780        const int   numnodes        = 2;
    781         double      max_penetration;
    782         double      penetration;
     781        IssmDouble      max_penetration;
     782        IssmDouble      penetration;
    783783        int         activate;
    784784        int         unstable;
    785785        int         found;
    786         double      vx1;
    787         double      vy1;
    788         double      vx2;
    789         double      vy2;
     786        IssmDouble      vx1;
     787        IssmDouble      vy1;
     788        IssmDouble      vx2;
     789        IssmDouble      vy2;
    790790
    791791        /*Objects: */
     
    794794
    795795        /*enum of element? */
    796         if(elements[0]->ObjectEnum()!=TriaEnum)_error_(" only Tria element allowed for Riftfront load!");
     796        if(elements[0]->ObjectEnum()!=TriaEnum)_error2_("only Tria element allowed for Riftfront load!");
    797797
    798798        /*recover elements on both side of rift: */
     
    826826        return 1;
    827827}
    828 /*}}}1*/
    829 /*FUNCTION Riftfront::PreConstrain {{{1*/
     828/*}}}*/
     829/*FUNCTION Riftfront::PreConstrain {{{*/
    830830int   Riftfront::PreConstrain(int* punstable){
    831831
    832832        const int   numnodes    = 2;
    833         double      penetration;
     833        IssmDouble      penetration;
    834834        int         unstable;
    835835        int         found;
    836         double      vx1;
    837         double      vy1;
    838         double      vx2;
    839         double      vy2;
     836        IssmDouble      vx1;
     837        IssmDouble      vy1;
     838        IssmDouble      vx2;
     839        IssmDouble      vy2;
    840840
    841841        /*Objects: */
     
    844844
    845845        /*enum of element? */
    846         if(elements[0]->ObjectEnum()!=TriaEnum)_error_(" only Tria element allowed for Riftfront load!");
     846        if(elements[0]->ObjectEnum()!=TriaEnum)_error2_("only Tria element allowed for Riftfront load!");
    847847
    848848        /*recover elements on both side of rift: */
     
    891891        return 1;
    892892}
    893 /*}}}1*/
    894 /*FUNCTION Riftfront::PreStable {{{1*/
     893/*}}}*/
     894/*FUNCTION Riftfront::PreStable {{{*/
    895895bool  Riftfront::PreStable(){
    896896        return prestable;
    897897}
    898 /*}}}1*/
    899 /*FUNCTION Riftfront::SetPreStable {{{1*/
     898/*}}}*/
     899/*FUNCTION Riftfront::SetPreStable {{{*/
    900900void Riftfront::SetPreStable(){
    901901        prestable=1;
    902902}
    903 /*}}}1*/
    904 /*FUNCTION Riftfront::IsInput{{{1*/
     903/*}}}*/
     904/*FUNCTION Riftfront::IsInput{{{*/
    905905bool Riftfront::IsInput(int name){
    906906        if (
  • issm/trunk/src/c/objects/Loads/Riftfront.h

    r12330 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "./Load.h"
    1111class Hook;
     
    3838                bool     prestable;
    3939                bool     material_converged;
    40                 double   normal[2];
    41                 double   length;
    42                 double   fraction;
     40                IssmDouble   normal[2];
     41                IssmDouble   length;
     42                IssmDouble   fraction;
    4343                int      state;
    4444               
     
    4747
    4848
    49                 /*Riftfrontconstructors,destructors: {{{1*/
     49                /*Riftfrontconstructors,destructors: {{{*/
    5050                Riftfront();
    5151                Riftfront(int riftfront_id,int i, IoModel* iomodel,int analysis_type);
    5252                ~Riftfront();
    5353                /*}}}*/
    54                 /*Object virtual functions definitions:{{{1 */
     54                /*Object virtual functions definitions:{{{ */
    5555                void  Echo();
    5656                void  DeepEcho();
     
    6060                Object* copy();
    6161                /*}}}*/
    62                 /*Update virtual functions resolution: {{{1*/
    63                 void    InputUpdateFromVector(double* vector, int name, int type);
    64                 void    InputUpdateFromVector(int* vector, int name, int type){_error_("Not implemented yet!");}
    65                 void    InputUpdateFromVector(bool* vector, int name, int type){_error_("Not implemented yet!");}
    66                 void    InputUpdateFromMatrixDakota(double* matrix, int nrows,int ncols, int name, int type){_error_("Not implemented yet!");}
    67                 void    InputUpdateFromVectorDakota(double* vector, int name, int type){_error_("Not implemented yet!");}
    68                 void    InputUpdateFromVectorDakota(int* vector, int name, int type){_error_("Not implemented yet!");}
    69                 void    InputUpdateFromVectorDakota(bool* vector, int name, int type){_error_("Not implemented yet!");}
    70                 void    InputUpdateFromConstant(double constant, int name);
    71                 void    InputUpdateFromConstant(int constant, int name){_error_("Not implemented yet!");}
     62                /*Update virtual functions resolution: {{{*/
     63                void    InputUpdateFromVector(IssmDouble* vector, int name, int type);
     64                void    InputUpdateFromVector(int* vector, int name, int type){_error2_("Not implemented yet!");}
     65                void    InputUpdateFromVector(bool* vector, int name, int type){_error2_("Not implemented yet!");}
     66                void    InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows,int ncols, int name, int type){_error2_("Not implemented yet!");}
     67                void    InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){_error2_("Not implemented yet!");}
     68                void    InputUpdateFromVectorDakota(int* vector, int name, int type){_error2_("Not implemented yet!");}
     69                void    InputUpdateFromVectorDakota(bool* vector, int name, int type){_error2_("Not implemented yet!");}
     70                void    InputUpdateFromConstant(IssmDouble constant, int name);
     71                void    InputUpdateFromConstant(int constant, int name){_error2_("Not implemented yet!");}
    7272                void    InputUpdateFromConstant(bool constant, int name);
    73                 void    InputUpdateFromSolution(double* solution){_error_("Not implemented yet!");}
    74                 void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("not implemented yet");};
     73                void    InputUpdateFromSolution(IssmDouble* solution){_error2_("Not implemented yet!");}
     74                void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error2_("not implemented yet");};
    7575                /*}}}*/
    76                 /*Load virtual functions definitions: {{{1*/
     76                /*Load virtual functions definitions: {{{*/
    7777                void  Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
    7878                void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
    7979                void  CreateKMatrix(Matrix* Kff, Matrix* Kfs);
    8080                void  CreatePVector(Vector* pf);
    81                 void  CreateJacobianMatrix(Matrix* Jff){_error_("Not implemented yet");};
    82                 void  PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax){_error_("Not implemented yet");};
    83                 void  PenaltyCreateKMatrix(Matrix* Kff, Matrix* kfs, double kmax);
    84                 void  PenaltyCreatePVector(Vector* pf, double kmax);
     81                void  CreateJacobianMatrix(Matrix* Jff){_error2_("Not implemented yet");};
     82                void  PenaltyCreateJacobianMatrix(Matrix* Jff,IssmDouble kmax){_error2_("Not implemented yet");};
     83                void  PenaltyCreateKMatrix(Matrix* Kff, Matrix* kfs, IssmDouble kmax);
     84                void  PenaltyCreatePVector(Vector* pf, IssmDouble kmax);
    8585                bool  InAnalysis(int analysis_type);
    8686                /*}}}*/
    87                 /*Riftfront specific routines: {{{1*/
     87                /*Riftfront specific routines: {{{*/
    8888                bool  PreStable();
    89                 ElementMatrix* PenaltyCreateKMatrixDiagnosticHoriz(double kmax);
    90                 ElementVector* PenaltyCreatePVectorDiagnosticHoriz(double kmax);
     89                ElementMatrix* PenaltyCreateKMatrixDiagnosticHoriz(IssmDouble kmax);
     90                ElementVector* PenaltyCreatePVectorDiagnosticHoriz(IssmDouble kmax);
    9191                void  SetPreStable();
    9292                int   PreConstrain(int* punstable);
     
    9494                void  FreezeConstraints(void);
    9595                bool  IsFrozen(void);
    96                 int   Penetration(double* ppenetration);
    97                 int   MaxPenetration(double* ppenetration);
     96                int   Penetration(IssmDouble* ppenetration);
     97                int   MaxPenetration(IssmDouble* ppenetration);
    9898                int   PotentialUnstableConstraint(int* punstable);
    9999                int   IsMaterialStable(void);
  • issm/trunk/src/c/objects/Materials/Material.h

    r11995 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111class Object;
    1212#include "../Object.h"
  • issm/trunk/src/c/objects/Materials/Matice.cpp

    r12330 r12706  
    1717               
    1818/*Matice constructors and destructor*/
    19 /*FUNCTION Matice::Matice(){{{1*/
     19/*FUNCTION Matice::Matice(){{{*/
    2020Matice::Matice(){
    2121        this->inputs=NULL;
     
    2424}
    2525/*}}}*/
    26 /*FUNCTION Matice::Matice(int id, int index, IoModel* iomodel, int num_vertices){{{1*/
     26/*FUNCTION Matice::Matice(int id, int index, IoModel* iomodel, int num_vertices){{{*/
    2727Matice::Matice(int matice_mid,int index, IoModel* iomodel){
    2828
     
    4848}
    4949/*}}}*/
    50 /*FUNCTION Matice::~Matice(){{{1*/
     50/*FUNCTION Matice::~Matice(){{{*/
    5151Matice::~Matice(){
    5252        delete helement;
     
    5757
    5858/*Object virtual functions definitions:*/
    59 /*FUNCTION Matice::Echo {{{1*/
     59/*FUNCTION Matice::Echo {{{*/
    6060void Matice::Echo(void){
    6161
    62         printf("Matice:\n");
    63         printf("   mid: %i\n",mid);
    64         printf("   inputs:\n");
     62        _printLine_("Matice:");
     63        _printLine_("   mid: " << mid);
     64        _printLine_("   inputs:");
    6565        inputs->Echo();
    66         printf("   element:\n");
     66        _printLine_("   element:");
    6767        helement->Echo();
    6868}
    6969/*}}}*/
    70 /*FUNCTION Matice::DeepEcho {{{1*/
     70/*FUNCTION Matice::DeepEcho {{{*/
    7171void Matice::DeepEcho(void){
    7272
    73         printf("Matice:\n");
    74         printf("   mid: %i\n",mid);
    75         printf("   inputs:\n");
     73        _printLine_("Matice:");
     74        _printLine_("   mid: " << mid);
     75        _printLine_("   inputs:");
    7676        inputs->DeepEcho();
    77         printf("   element:\n");
     77        _printLine_("   element:");
    7878        helement->Echo();
    7979}               
    8080/*}}}*/
    81 /*FUNCTION Matice::Id {{{1*/
     81/*FUNCTION Matice::Id {{{*/
    8282int    Matice::Id(void){ return mid; }
    8383/*}}}*/
    84 /*FUNCTION Matice::MyRank {{{1*/
     84/*FUNCTION Matice::MyRank {{{*/
    8585int    Matice::MyRank(void){
    8686        extern int my_rank;
     
    8888}
    8989/*}}}*/
    90 /*FUNCTION Matice::ObjectEnum{{{1*/
     90/*FUNCTION Matice::ObjectEnum{{{*/
    9191int Matice::ObjectEnum(void){
    9292
     
    9595}
    9696/*}}}*/
    97 /*FUNCTION Matice::copy {{{1*/
     97/*FUNCTION Matice::copy {{{*/
    9898Object* Matice::copy() {
    9999
     
    115115
    116116/*Matice management*/
    117 /*FUNCTION Matice::Configure {{{1*/
     117/*FUNCTION Matice::Configure {{{*/
    118118void  Matice::Configure(Elements* elementsin){
    119119
     
    123123}
    124124/*}}}*/
    125 /*FUNCTION Matice::SetCurrentConfiguration {{{1*/
     125/*FUNCTION Matice::SetCurrentConfiguration {{{*/
    126126void  Matice::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){
    127127
    128128}
    129129/*}}}*/
    130 /*FUNCTION Matice::GetB {{{1*/
    131 double Matice::GetB(){
     130/*FUNCTION Matice::GetB {{{*/
     131IssmDouble Matice::GetB(){
    132132
    133133        /*Output*/
    134         double B;
     134        IssmDouble B;
    135135
    136136        inputs->GetInputAverage(&B,MaterialsRheologyBEnum);
     
    138138}
    139139/*}}}*/
    140 /*FUNCTION Matice::GetBbar {{{1*/
    141 double Matice::GetBbar(){
     140/*FUNCTION Matice::GetBbar {{{*/
     141IssmDouble Matice::GetBbar(){
    142142
    143143        /*Output*/
    144         double Bbar;
     144        IssmDouble Bbar;
    145145
    146146        inputs->GetInputAverage(&Bbar,MaterialsRheologyBbarEnum);
     
    148148}
    149149/*}}}*/
    150 /*FUNCTION Matice::GetN {{{1*/
    151 double Matice::GetN(){
     150/*FUNCTION Matice::GetN {{{*/
     151IssmDouble Matice::GetN(){
    152152
    153153        /*Output*/
    154         double n;
     154        IssmDouble n;
    155155
    156156        inputs->GetInputAverage(&n,MaterialsRheologyNEnum);
     
    158158}
    159159/*}}}*/
    160 /*FUNCTION Matice::GetVectorFromInputs{{{1*/
     160/*FUNCTION Matice::GetVectorFromInputs{{{*/
    161161void  Matice::GetVectorFromInputs(Vector* vector,int input_enum){
    162162
     
    180180                        /*Get input (either in element or material)*/
    181181                        Input* input=inputs->GetInput(input_enum);
    182                         if(!input) _error_("Input %s not found in material",EnumToStringx(input_enum));
     182                        if(!input) _error2_("Input " << EnumToStringx(input_enum) << " not found in material");
    183183
    184184                        /*We found the enum.  Use its values to fill into the vector, using the vertices ids: */
     
    186186                        break;
    187187
    188                 default: _error_("element %s not implemented yet",EnumToStringx(element->ObjectEnum()));
    189         }
    190 }
    191 /*}}}*/
    192 /*FUNCTION Matice::GetViscosity2d {{{1*/
    193 void  Matice::GetViscosity2d(double* pviscosity, double* epsilon){
     188                default: _error2_("element " << EnumToStringx(element->ObjectEnum()) << " not implemented yet");
     189        }
     190}
     191/*}}}*/
     192/*FUNCTION Matice::GetViscosity2d {{{*/
     193void  Matice::GetViscosity2d(IssmDouble* pviscosity, IssmDouble* epsilon){
    194194        /*From a string tensor and a material object, return viscosity, using Glen's flow law.
    195195                                                                                                    B
     
    205205
    206206        /*output: */
    207         double viscosity;
     207        IssmDouble viscosity;
    208208
    209209        /*input strain rate: */
    210         double exx,eyy,exy;
     210        IssmDouble exx,eyy,exy;
    211211
    212212        /*Intermediary: */
    213         double A,e;
    214         double B,n;
     213        IssmDouble A,e;
     214        IssmDouble B,n;
    215215
    216216        /*Get B and n*/
     
    224224        else{
    225225                if((epsilon[0]==0) && (epsilon[1]==0) && (epsilon[2]==0)){
    226                         viscosity=0.5*pow((double)10,(double)14);
     226                        viscosity=0.5*pow((IssmDouble)10,(IssmDouble)14);
    227227                }
    228228                else{
     
    236236                        if(A==0){
    237237                                /*Maxiviscositym viscosity for 0 shear areas: */
    238                                 viscosity=2.5*pow((double)10,(double)17);
     238                                viscosity=2.5*pow((IssmDouble)10,(IssmDouble)17);
    239239                        }
    240240                        else{
     
    246246
    247247        /*Checks in debugging mode*/
    248         if(viscosity<=0) _error_("Negative viscosity");
     248        if(viscosity<=0) _error2_("Negative viscosity");
    249249        _assert_(B>0);
    250250        _assert_(n>0);
     
    254254}
    255255/*}}}*/
    256 /*FUNCTION Matice::GetViscosity3d {{{1*/
    257 void  Matice::GetViscosity3d(double* pviscosity3d, double* epsilon){
     256/*FUNCTION Matice::GetViscosity3d {{{*/
     257void  Matice::GetViscosity3d(IssmDouble* pviscosity3d, IssmDouble* epsilon){
    258258
    259259        /*Return viscosity accounting for steady state power law creep [Thomas and MacAyeal, 1982]:
     
    271271       
    272272        /*output: */
    273         double viscosity3d;
     273        IssmDouble viscosity3d;
    274274
    275275        /*input strain rate: */
    276         double exx,eyy,exy,exz,eyz;
     276        IssmDouble exx,eyy,exy,exz,eyz;
    277277
    278278        /*Intermediaries: */
    279         double A,e;
    280         double B,n;
     279        IssmDouble A,e;
     280        IssmDouble B,n;
    281281
    282282        /*Get B and n*/
     
    291291                if((epsilon[0]==0) && (epsilon[1]==0) && (epsilon[2]==0) &&
    292292                                (epsilon[3]==0) && (epsilon[4]==0)){
    293                         viscosity3d=0.5*pow((double)10,(double)14);
     293                        viscosity3d=0.5*pow((IssmDouble)10,(IssmDouble)14);
    294294                }
    295295                else{
     
    306306                        if(A==0){
    307307                                /*Maxiviscosity3dm viscosity for 0 shear areas: */
    308                                 viscosity3d=2.25*pow((double)10,(double)17);
     308                                viscosity3d=2.25*pow((IssmDouble)10,(IssmDouble)17);
    309309                        }
    310310                        else{
     
    317317
    318318        /*Checks in debugging mode*/
    319         if(viscosity3d<=0) _error_("Negative viscosity");
     319        if(viscosity3d<=0) _error2_("Negative viscosity");
    320320        _assert_(B>0);
    321321        _assert_(n>0);
     
    325325}
    326326/*}}}*/
    327 /*FUNCTION Matice::GetViscosity3dStokes {{{1*/
    328 void  Matice::GetViscosity3dStokes(double* pviscosity3d, double* epsilon){
     327/*FUNCTION Matice::GetViscosity3dStokes {{{*/
     328void  Matice::GetViscosity3dStokes(IssmDouble* pviscosity3d, IssmDouble* epsilon){
    329329        /*Return viscosity accounting for steady state power law creep [Thomas and MacAyeal, 1982]:
    330330         *
     
    341341       
    342342        /*output: */
    343         double viscosity3d;
     343        IssmDouble viscosity3d;
    344344
    345345        /*input strain rate: */
    346         double exx,eyy,exy,exz,eyz,ezz;
     346        IssmDouble exx,eyy,exy,exz,eyz,ezz;
    347347
    348348        /*Intermediaries: */
    349         double A,e;
    350         double B,n;
    351         double eps0;
     349        IssmDouble A,e;
     350        IssmDouble B,n;
     351        IssmDouble eps0;
    352352
    353353        /*Get B and n*/
    354         eps0=pow((double)10,(double)-27);
     354        eps0=pow((IssmDouble)10,(IssmDouble)-27);
    355355        B=GetB();
    356356        n=GetN();
     
    363363                if((epsilon[0]==0) && (epsilon[1]==0) && (epsilon[2]==0) &&
    364364                                (epsilon[3]==0) && (epsilon[4]==0) && (epsilon[5]==0)){
    365                         viscosity3d=0.5*pow((double)10,(double)14);
     365                        viscosity3d=0.5*pow((IssmDouble)10,(IssmDouble)14);
    366366                }
    367367                else{
     
    379379                        if(A==0){
    380380                                /*Maxiviscosity3dm viscosity for 0 shear areas: */
    381                                 viscosity3d=2.25*pow((double)10,(double)17);
     381                                viscosity3d=2.25*pow((IssmDouble)10,(IssmDouble)17);
    382382                        }
    383383                        else{
     
    389389
    390390        /*Checks in debugging mode*/
    391         if(viscosity3d<=0) _error_("Negative viscosity");
     391        if(viscosity3d<=0) _error2_("Negative viscosity");
    392392        _assert_(B>0);
    393393        _assert_(n>0);
     
    397397}
    398398/*}}}*/
    399 /*FUNCTION Matice::GetViscosityComplement {{{1*/
    400 void  Matice::GetViscosityComplement(double* pviscosity_complement, double* epsilon){
     399/*FUNCTION Matice::GetViscosityComplement {{{*/
     400void  Matice::GetViscosityComplement(IssmDouble* pviscosity_complement, IssmDouble* epsilon){
    401401        /*Return viscosity accounting for steady state power law creep [Thomas and MacAyeal, 1982]:
    402402         *
     
    410410       
    411411        /*output: */
    412         double viscosity_complement;
     412        IssmDouble viscosity_complement;
    413413
    414414        /*input strain rate: */
    415         double exx,eyy,exy;
     415        IssmDouble exx,eyy,exy;
    416416
    417417        /*Intermediary value A and exponent e: */
    418         double A,e;
    419         double B,n;
     418        IssmDouble A,e;
     419        IssmDouble B,n;
    420420
    421421        /*Get B and n*/
     
    432432                if(A==0){
    433433                        /*Maximum viscosity_complement for 0 shear areas: */
    434                         viscosity_complement=2.25*pow((double)10,(double)17);
     434                        viscosity_complement=2.25*pow((IssmDouble)10,(IssmDouble)17);
    435435                }
    436436                else{
     
    441441        }
    442442        else{
    443                 viscosity_complement=4.5*pow((double)10,(double)17);
     443                viscosity_complement=4.5*pow((IssmDouble)10,(IssmDouble)17);
    444444        }
    445445
     
    453453}
    454454/*}}}*/
    455 /*FUNCTION Matice::GetViscosityDerivativeEpsSquare{{{1*/
    456 void  Matice::GetViscosityDerivativeEpsSquare(double* pmu_prime, double* epsilon){
     455/*FUNCTION Matice::GetViscosityDerivativeEpsSquare{{{*/
     456void  Matice::GetViscosityDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* epsilon){
    457457
    458458        /*output: */
    459         double mu_prime;
    460         double mu,n,eff2;
     459        IssmDouble mu_prime;
     460        IssmDouble mu,n,eff2;
    461461
    462462        /*input strain rate: */
    463         double exx,eyy,exy,exz,eyz;
     463        IssmDouble exx,eyy,exy,exz,eyz;
    464464
    465465        /*Get visocisty and n*/
     
    469469        if((epsilon[0]==0) && (epsilon[1]==0) && (epsilon[2]==0) &&
    470470                                (epsilon[3]==0) && (epsilon[4]==0)){
    471                 mu_prime=0.5*pow((double)10,(double)14);
     471                mu_prime=0.5*pow((IssmDouble)10,(IssmDouble)14);
    472472        }
    473473        else{
     
    487487}
    488488/*}}}*/
    489 /*FUNCTION Matice::GetViscosity2dDerivativeEpsSquare{{{1*/
    490 void  Matice::GetViscosity2dDerivativeEpsSquare(double* pmu_prime, double* epsilon){
     489/*FUNCTION Matice::GetViscosity2dDerivativeEpsSquare{{{*/
     490void  Matice::GetViscosity2dDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* epsilon){
    491491
    492492        /*output: */
    493         double mu_prime;
    494         double mu,n,eff2;
     493        IssmDouble mu_prime;
     494        IssmDouble mu,n,eff2;
    495495
    496496        /*input strain rate: */
    497         double exx,eyy,exy,exz;
     497        IssmDouble exx,eyy,exy,exz;
    498498
    499499        /*Get visocisty and n*/
     
    502502
    503503        if((epsilon[0]==0) && (epsilon[1]==0) && (epsilon[2]==0)){
    504                 mu_prime=0.5*pow((double)10,(double)14);
     504                mu_prime=0.5*pow((IssmDouble)10,(IssmDouble)14);
    505505        }
    506506        else{
     
    518518}
    519519/*}}}*/
    520 /*FUNCTION Matice::InputDuplicate{{{1*/
     520/*FUNCTION Matice::InputDuplicate{{{*/
    521521void  Matice::InputDuplicate(int original_enum,int new_enum){
    522522
     
    526526}
    527527/*}}}*/
    528 /*FUNCTION Matice::InputUpdateFromVector(double* vector, int name, int type) {{{1*/
    529 void  Matice::InputUpdateFromVector(double* vector, int name, int type){
     528/*FUNCTION Matice::InputUpdateFromVector(IssmDouble* vector, int name, int type) {{{*/
     529void  Matice::InputUpdateFromVector(IssmDouble* vector, int name, int type){
    530530
    531531        /*Intermediaries*/
     
    544544                        switch(element->ObjectEnum()){
    545545
    546                                 case TriaEnum:
    547                                         double values[3];
     546                                case TriaEnum: {
     547                                        IssmDouble values[3];
    548548                                        for (int i=0;i<3;i++) values[i]=vector[((Tria*)element)->nodes[i]->GetVertexDof()];
    549549                                        this->inputs->AddInput(new TriaP1Input(name,values));
    550550                                        return;
    551 
    552                                 default: _error_("element %s not implemented yet",EnumToStringx(element->ObjectEnum()));
    553                         }
    554                 default: _error_("type %i (%s) not implemented yet",type,EnumToStringx(type));
    555         }
    556 }
    557 /*}}}*/
    558 /*FUNCTION Matice::InputUpdateFromVector(int* vector, int name, int type) {{{1*/
     551                                }
     552                                default: _error2_("element " << EnumToStringx(element->ObjectEnum()) << " not implemented yet");
     553                        }
     554                default: _error2_("type " << type << " (" << EnumToStringx(type) << ") not implemented yet");
     555        }
     556}
     557/*}}}*/
     558/*FUNCTION Matice::InputUpdateFromVector(int* vector, int name, int type) {{{*/
    559559void  Matice::InputUpdateFromVector(int* vector, int name, int type){
    560560        /*Nothing updated yet*/
    561561}
    562562/*}}}*/
    563 /*FUNCTION Matice::InputUpdateFromVector(bool* vector, int name, int type) {{{1*/
     563/*FUNCTION Matice::InputUpdateFromVector(bool* vector, int name, int type) {{{*/
    564564void  Matice::InputUpdateFromVector(bool* vector, int name, int type){
    565565        /*Nothing updated yet*/
    566566}
    567567/*}}}*/
    568 /*FUNCTION Matice::InputUpdateFromVectorDakota(double* vector, int name, int type) {{{1*/
    569 void  Matice::InputUpdateFromVectorDakota(double* vector, int name, int type){
     568/*FUNCTION Matice::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type) {{{*/
     569void  Matice::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){
    570570
    571571        /*Intermediaries*/
     
    586586                        switch(element->ObjectEnum()){
    587587
    588                                 case TriaEnum:
    589                                         double values[3];
     588                                case TriaEnum: {
     589                                        IssmDouble values[3];
    590590                                        for (int i=0;i<3;i++) values[i]=vector[((Tria*)element)->nodes[i]->GetSidList()]; //use sid list, to index into serial oriented vector
    591591                                        this->inputs->AddInput(new TriaP1Input(name,values));
    592                                         /*Special case for rheology B in 2D: Pourave land for this solution{{{2*/
     592                                        /*Special case for rheology B in 2D: Pourave land for this solution{{{*/
    593593                                        if(name==MaterialsRheologyBEnum){
    594594                                                /*Are we in 2D?:*/
     
    607607                                        /*}}}*/
    608608                                        return;
    609 
    610                                 default: _error_("element %s not implemented yet",EnumToStringx(element->ObjectEnum()));
    611                         }
    612                 default: _error_("type %i (%s) not implemented yet",type,EnumToStringx(type));
    613         }
    614 
    615 
    616 
    617 }
    618 /*}}}*/
    619 /*FUNCTION Matice::InputUpdateFromMatrixDakota(int* vector, int name, int type) {{{1*/
    620 void  Matice::InputUpdateFromMatrixDakota(double* matrix, int nrows, int ncols,int name, int type){
    621         /*Nothing updated yet*/
    622 }
    623 /*}}}*/
    624 /*FUNCTION Matice::InputUpdateFromVectorDakota(int* vector, int name, int type) {{{1*/
     609                                }
     610                                default: _error2_("element " << EnumToStringx(element->ObjectEnum()) << " not implemented yet");
     611                        }
     612                default: _error2_("type " << type << " (" << EnumToStringx(type) << ") not implemented yet");
     613        }
     614
     615
     616
     617}
     618/*}}}*/
     619/*FUNCTION Matice::InputUpdateFromMatrixDakota(int* vector, int name, int type) {{{*/
     620void  Matice::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols,int name, int type){
     621        /*Nothing updated yet*/
     622}
     623/*}}}*/
     624/*FUNCTION Matice::InputUpdateFromVectorDakota(int* vector, int name, int type) {{{*/
    625625void  Matice::InputUpdateFromVectorDakota(int* vector, int name, int type){
    626626        /*Nothing updated yet*/
    627627}
    628628/*}}}*/
    629 /*FUNCTION Matice::InputUpdateFromVectorDakota(bool* vector, int name, int type) {{{1*/
     629/*FUNCTION Matice::InputUpdateFromVectorDakota(bool* vector, int name, int type) {{{*/
    630630void  Matice::InputUpdateFromVectorDakota(bool* vector, int name, int type){
    631631        /*Nothing updated yet*/
    632632}
    633633/*}}}*/
    634 /*FUNCTION Matice::InputUpdateFromConstant(double constant, int name) {{{1*/
    635 void  Matice::InputUpdateFromConstant(double constant, int name){
    636         /*Nothing updated yet*/
    637 }
    638 /*}}}*/
    639 /*FUNCTION Matice::InputUpdateFromConstant(int constant, int name) {{{1*/
     634/*FUNCTION Matice::InputUpdateFromConstant(IssmDouble constant, int name) {{{*/
     635void  Matice::InputUpdateFromConstant(IssmDouble constant, int name){
     636        /*Nothing updated yet*/
     637}
     638/*}}}*/
     639/*FUNCTION Matice::InputUpdateFromConstant(int constant, int name) {{{*/
    640640void  Matice::InputUpdateFromConstant(int constant, int name){
    641641        /*Nothing updated yet*/
    642642}
    643643/*}}}*/
    644 /*FUNCTION Matice::InputUpdateFromConstant(bool constant, int name) {{{1*/
     644/*FUNCTION Matice::InputUpdateFromConstant(bool constant, int name) {{{*/
    645645void  Matice::InputUpdateFromConstant(bool constant, int name){
    646646        /*Nothing updated yet*/
    647647}
    648648/*}}}*/
    649 /*FUNCTION Matice::InputUpdateFromSolution{{{1*/
    650 void  Matice::InputUpdateFromSolution(double* solution){
    651         /*Nothing updated yet*/
    652 }
    653 /*}}}*/
    654 /*FUNCTION Matice::InputUpdateFromIoModel{{{1*/
     649/*FUNCTION Matice::InputUpdateFromSolution{{{*/
     650void  Matice::InputUpdateFromSolution(IssmDouble* solution){
     651        /*Nothing updated yet*/
     652}
     653/*}}}*/
     654/*FUNCTION Matice::InputUpdateFromIoModel{{{*/
    655655void Matice::InputUpdateFromIoModel(int index, IoModel* iomodel){
    656656
     
    671671                /*Intermediaries*/
    672672                const int num_vertices = 3; //Tria has 3 vertices
    673                 double    nodeinputs[num_vertices];
    674                 double    cmmininputs[num_vertices];
    675                 double    cmmaxinputs[num_vertices];
     673                IssmDouble    nodeinputs[num_vertices];
     674                IssmDouble    cmmininputs[num_vertices];
     675                IssmDouble    cmmaxinputs[num_vertices];
    676676
    677677                /*Get B*/
    678678                if (iomodel->Data(MaterialsRheologyBEnum)) {
    679                         for(i=0;i<num_vertices;i++) nodeinputs[i]=iomodel->Data(MaterialsRheologyBEnum)[int(iomodel->Data(MeshElementsEnum)[num_vertices*index+i]-1)];
     679                        for(i=0;i<num_vertices;i++) nodeinputs[i]=iomodel->Data(MaterialsRheologyBEnum)[reCast<int,IssmDouble>(iomodel->Data(MeshElementsEnum)[num_vertices*index+i]-1)];
    680680                        this->inputs->AddInput(new TriaP1Input(MaterialsRheologyBbarEnum,nodeinputs));
    681681                }
     
    713713                /*Intermediaries*/
    714714                const int num_vertices = 6; //Penta has 6 vertices
    715                 double    nodeinputs[num_vertices];
    716                 double    cmmininputs[num_vertices];
    717                 double    cmmaxinputs[num_vertices];
     715                IssmDouble    nodeinputs[num_vertices];
     716                IssmDouble    cmmininputs[num_vertices];
     717                IssmDouble    cmmaxinputs[num_vertices];
    718718
    719719                /*Get B*/
     
    750750        #endif
    751751        else{
    752                 _error_(" Mesh type not supported yet!");
     752                _error2_("Mesh type not supported yet!");
    753753        }
    754754
     
    756756}
    757757/*}}}*/
    758 /*FUNCTION Matice::IsInput{{{1*/
     758/*FUNCTION Matice::IsInput{{{*/
    759759bool Matice::IsInput(int name){
    760760        if (
  • issm/trunk/src/c/objects/Materials/Matice.h

    r12330 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "./Material.h"
    1111class IoModel;
     
    2525                Inputs*  inputs;
    2626
    27                 /*Matice constructors, destructors: {{{1*/
     27                /*Matice constructors, destructors: {{{*/
    2828                Matice();
    2929                Matice(int mid,int i, IoModel* iomodel);
    3030                ~Matice();
    3131                /*}}}*/
    32                 /*Object virtual functions definitions:{{{1 */
     32                /*Object virtual functions definitions:{{{ */
    3333                void  Echo();
    3434                void  DeepEcho();
     
    3838                Object* copy();
    3939                /*}}}*/
    40                 /*Update virtual functions definitions: {{{1*/
    41                 void  InputUpdateFromVector(double* vector, int name, int type);
     40                /*Update virtual functions definitions: {{{*/
     41                void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
    4242                void  InputUpdateFromVector(int* vector, int name, int type);
    4343                void  InputUpdateFromVector(bool* vector, int name, int type);
    44                 void  InputUpdateFromMatrixDakota(double* matrix, int nrow, int ncols, int name, int type);
    45                 void  InputUpdateFromVectorDakota(double* vector, int name, int type);
     44                void  InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrow, int ncols, int name, int type);
     45                void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
    4646                void  InputUpdateFromVectorDakota(int* vector, int name, int type);
    4747                void  InputUpdateFromVectorDakota(bool* vector, int name, int type);
    48                 void  InputUpdateFromConstant(double constant, int name);
     48                void  InputUpdateFromConstant(IssmDouble constant, int name);
    4949                void  InputUpdateFromConstant(int constant, int name);
    5050                void  InputUpdateFromConstant(bool constant, int name);
    51                 void  InputUpdateFromSolution(double* solution);
     51                void  InputUpdateFromSolution(IssmDouble* solution);
    5252                void  InputUpdateFromIoModel(int index, IoModel* iomodel);
    5353                /*}}}*/
    54                 /*Material virtual functions resolution: {{{1*/
     54                /*Material virtual functions resolution: {{{*/
    5555                void   InputDuplicate(int original_enum,int new_enum);
    5656                void   Configure(Elements* elements);
    5757                void   GetVectorFromInputs(Vector* vector,int input_enum);
    5858                /*}}}*/
    59                 /*Matice Numerics: {{{1*/
     59                /*Matice Numerics: {{{*/
    6060                void   SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin);
    61                 void   GetViscosity2d(double* pviscosity, double* pepsilon);
    62                 void   GetViscosity3d(double* pviscosity3d, double* pepsilon);
    63                 void   GetViscosity3dStokes(double* pviscosity3d, double* epsilon);
    64                 void   GetViscosityComplement(double* pviscosity_complement, double* pepsilon);
    65                 void   GetViscosityDerivativeEpsSquare(double* pmu_prime, double* pepsilon);
    66                 void   GetViscosity2dDerivativeEpsSquare(double* pmu_prime, double* pepsilon);
    67                 double GetB();
    68                 double GetBbar();
    69                 double GetN();
     61                void   GetViscosity2d(IssmDouble* pviscosity, IssmDouble* pepsilon);
     62                void   GetViscosity3d(IssmDouble* pviscosity3d, IssmDouble* pepsilon);
     63                void   GetViscosity3dStokes(IssmDouble* pviscosity3d, IssmDouble* epsilon);
     64                void   GetViscosityComplement(IssmDouble* pviscosity_complement, IssmDouble* pepsilon);
     65                void   GetViscosityDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* pepsilon);
     66                void   GetViscosity2dDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* pepsilon);
     67                IssmDouble GetB();
     68                IssmDouble GetBbar();
     69                IssmDouble GetN();
    7070                bool   IsInput(int name);
    7171                /*}}}*/
  • issm/trunk/src/c/objects/Materials/Matpar.cpp

    r12330 r12706  
    1717               
    1818/*Matpar constructors and destructor*/
    19 /*FUNCTION Matpar::Matpar() {{{1*/
     19/*FUNCTION Matpar::Matpar() {{{*/
    2020Matpar::Matpar(){
    2121        return;
    2222}
    23 /*}}}1*/
    24 /*FUNCTION Matpar::Matpar(int matpar_mid,IoModel* iomodel){{{1*/
     23/*}}}*/
     24/*FUNCTION Matpar::Matpar(int matpar_mid,IoModel* iomodel){{{*/
    2525Matpar::Matpar(int matpar_mid, IoModel* iomodel){
    2626
     
    4646        iomodel->Constant(&this->hydro_q,HydrologyQEnum);
    4747}
    48 /*}}}1*/
    49 /*FUNCTION Matpar::~Matpar() {{{1*/
     48/*}}}*/
     49/*FUNCTION Matpar::~Matpar() {{{*/
    5050Matpar::~Matpar(){
    5151        return;
    5252}
    53 /*}}}1*/
     53/*}}}*/
    5454
    5555/*Object virtual functions definitions:*/
    56 /*FUNCTION Matpar::Echo {{{1*/
     56/*FUNCTION Matpar::Echo {{{*/
    5757void Matpar::Echo(void){
    5858
    59         printf("Matpar:\n");
    60         printf("   mid: %i\n",mid);
    61         printf("   rho_ice: %g\n",rho_ice);
    62         printf("   rho_water: %g\n",rho_water);
    63         printf("   rho_freshwater: %g\n",rho_freshwater);
    64         printf("   mu_water: %g\n",mu_water);
    65         printf("   heatcapacity: %g\n",heatcapacity);
    66         printf("   thermalconductivity: %g\n",thermalconductivity);
    67         printf("   latentheat: %g\n",latentheat);
    68         printf("   beta: %g\n",beta);
    69         printf("   meltingpoint: %g\n",meltingpoint);
    70         printf("   referencetemperature: %g\n",referencetemperature);
    71         printf("   mixed_layer_capacity: %g\n",mixed_layer_capacity);
    72         printf("   thermal_exchange_velocity: %g\n",thermal_exchange_velocity);
    73         printf("   g: %g\n",g);
     59        _printLine_("Matpar:");
     60        _printLine_("   mid: " << mid);
     61        _printLine_("   rho_ice: " << rho_ice);
     62        _printLine_("   rho_water: " << rho_water);
     63        _printLine_("   rho_freshwater: " << rho_freshwater);
     64        _printLine_("   mu_water: " << mu_water);
     65        _printLine_("   heatcapacity: " << heatcapacity);
     66        _printLine_("   thermalconductivity: " << thermalconductivity);
     67        _printLine_("   latentheat: " << latentheat);
     68        _printLine_("   beta: " << beta);
     69        _printLine_("   meltingpoint: " << meltingpoint);
     70        _printLine_("   referencetemperature: " << referencetemperature);
     71        _printLine_("   mixed_layer_capacity: " << mixed_layer_capacity);
     72        _printLine_("   thermal_exchange_velocity: " << thermal_exchange_velocity);
     73        _printLine_("   g: " << g);
    7474        return;
    7575}
    76 /*}}}1*/
    77 /*FUNCTION Matpar::DeepEcho {{{1*/
     76/*}}}*/
     77/*FUNCTION Matpar::DeepEcho {{{*/
    7878void Matpar::DeepEcho(void){
    7979
    8080        this->Echo();
    8181}               
    82 /*}}}1*/
    83 /*FUNCTION Matpar::Id {{{1*/
     82/*}}}*/
     83/*FUNCTION Matpar::Id {{{*/
    8484int    Matpar::Id(void){ return mid; }
    85 /*}}}1*/
    86 /*FUNCTION Matpar::MyRank {{{1*/
     85/*}}}*/
     86/*FUNCTION Matpar::MyRank {{{*/
    8787int    Matpar::MyRank(void){
    8888        extern int my_rank;
    8989        return my_rank;
    9090}
    91 /*}}}1*/
    92 /*FUNCTION Matpar::ObjectEnum{{{1*/
     91/*}}}*/
     92/*FUNCTION Matpar::ObjectEnum{{{*/
    9393int Matpar::ObjectEnum(void){
    9494
     
    9696
    9797}
    98 /*}}}1*/
    99 /*FUNCTION Matpar::copy {{{1*/
     98/*}}}*/
     99/*FUNCTION Matpar::copy {{{*/
    100100Object* Matpar::copy() {
    101101        return new Matpar(*this);
    102102}
    103 /*}}}1*/
     103/*}}}*/
    104104
    105105/*Update virtual functions definitions:*/
    106 /*FUNCTION Matpar::InputUpdateFromVector(double* vector, int name, int type) {{{1*/
    107 void   Matpar::InputUpdateFromVector(double* vector, int name, int type){
    108         /*Nothing updated yet*/
    109 }
    110 /*}}}*/
    111 /*FUNCTION Matpar::InputUpdateFromVector(int* vector, int name, int type) {{{1*/
     106/*FUNCTION Matpar::InputUpdateFromVector(IssmDouble* vector, int name, int type) {{{*/
     107void   Matpar::InputUpdateFromVector(IssmDouble* vector, int name, int type){
     108        /*Nothing updated yet*/
     109}
     110/*}}}*/
     111/*FUNCTION Matpar::InputUpdateFromVector(int* vector, int name, int type) {{{*/
    112112void   Matpar::InputUpdateFromVector(int* vector, int name, int type){
    113113        /*Nothing updated yet*/
    114114}
    115115/*}}}*/
    116 /*FUNCTION Matpar::InputUpdateFromVector(bool* vector, int name, int type) {{{1*/
     116/*FUNCTION Matpar::InputUpdateFromVector(bool* vector, int name, int type) {{{*/
    117117void   Matpar::InputUpdateFromVector(bool* vector, int name, int type){
    118118        /*Nothing updated yet*/
    119119}
    120120/*}}}*/
    121 /*FUNCTION Matpar::InputUpdateFromVectorDakota(double* vector, int name, int type) {{{1*/
    122 void   Matpar::InputUpdateFromVectorDakota(double* vector, int name, int type){
    123         /*Nothing updated yet*/
    124 }
    125 /*}}}*/
    126 /*FUNCTION Matpar::InputUpdateFromVectorDakota(int* vector, int name, int type) {{{1*/
     121/*FUNCTION Matpar::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type) {{{*/
     122void   Matpar::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){
     123        /*Nothing updated yet*/
     124}
     125/*}}}*/
     126/*FUNCTION Matpar::InputUpdateFromVectorDakota(int* vector, int name, int type) {{{*/
    127127void   Matpar::InputUpdateFromVectorDakota(int* vector, int name, int type){
    128128        /*Nothing updated yet*/
    129129}
    130130/*}}}*/
    131 /*FUNCTION Matpar::InputUpdateFromVectorDakota(bool* vector, int name, int type) {{{1*/
     131/*FUNCTION Matpar::InputUpdateFromVectorDakota(bool* vector, int name, int type) {{{*/
    132132void   Matpar::InputUpdateFromVectorDakota(bool* vector, int name, int type){
    133133        /*Nothing updated yet*/
    134134}
    135135/*}}}*/
    136 /*FUNCTION Matpar::InputUpdateFromMatrixDakota(int* vector, int name, int type) {{{1*/
    137 void  Matpar::InputUpdateFromMatrixDakota(double* matrix, int nrows, int ncols,int name, int type){
    138         /*Nothing updated yet*/
    139 }
    140 /*}}}*/
    141 /*FUNCTION Matpar::InputUpdateFromConstant(double constant, int name) {{{1*/
    142 void   Matpar::InputUpdateFromConstant(double constant, int name){
     136/*FUNCTION Matpar::InputUpdateFromMatrixDakota(int* vector, int name, int type) {{{*/
     137void  Matpar::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols,int name, int type){
     138        /*Nothing updated yet*/
     139}
     140/*}}}*/
     141/*FUNCTION Matpar::InputUpdateFromConstant(IssmDouble constant, int name) {{{*/
     142void   Matpar::InputUpdateFromConstant(IssmDouble constant, int name){
    143143
    144144        switch(name){
     
    188188}
    189189/*}}}*/
    190 /*FUNCTION Matpar::InputUpdateFromConstant(int constant, int name) {{{1*/
     190/*FUNCTION Matpar::InputUpdateFromConstant(int constant, int name) {{{*/
    191191void   Matpar::InputUpdateFromConstant(int constant, int name){
    192192        /*Nothing updated yet*/
    193193}
    194194/*}}}*/
    195 /*FUNCTION Matpar::InputUpdateFromConstant(bool constant, int name) {{{1*/
     195/*FUNCTION Matpar::InputUpdateFromConstant(bool constant, int name) {{{*/
    196196void   Matpar::InputUpdateFromConstant(bool constant, int name){
    197197        /*Nothing updated yet*/
    198198}
    199199/*}}}*/
    200 /*FUNCTION Matpar::InputUpdateFromSolution{{{1*/
    201 void   Matpar::InputUpdateFromSolution(double* solution){
     200/*FUNCTION Matpar::InputUpdateFromSolution{{{*/
     201void   Matpar::InputUpdateFromSolution(IssmDouble* solution){
    202202        /*Nothing updated yet*/
    203203}
     
    205205
    206206/*Matpar management: */
    207 /*FUNCTION Matpar::Configure {{{1*/
     207/*FUNCTION Matpar::Configure {{{*/
    208208void  Matpar::Configure(Elements* elementsin){
    209209
     
    212212}
    213213/*}}}*/
    214 /*FUNCTION Matpar::GetBeta {{{1*/
    215 double Matpar::GetBeta(){
     214/*FUNCTION Matpar::GetBeta {{{*/
     215IssmDouble Matpar::GetBeta(){
    216216        return beta;
    217217}
    218 /*}}}1*/
    219 /*FUNCTION Matpar::GetG {{{1*/
    220 double Matpar::GetG(){
     218/*}}}*/
     219/*FUNCTION Matpar::GetG {{{*/
     220IssmDouble Matpar::GetG(){
    221221        return g;
    222222}
    223 /*}}}1*/
    224 /*FUNCTION Matpar::GetHeatCapacity {{{1*/
    225 double Matpar::GetHeatCapacity(){
     223/*}}}*/
     224/*FUNCTION Matpar::GetHeatCapacity {{{*/
     225IssmDouble Matpar::GetHeatCapacity(){
    226226        return heatcapacity;
    227227}
    228 /*}}}1*/
    229 /*FUNCTION Matpar::GetLatentHeat {{{1*/
    230 double Matpar::GetLatentHeat(){
     228/*}}}*/
     229/*FUNCTION Matpar::GetLatentHeat {{{*/
     230IssmDouble Matpar::GetLatentHeat(){
    231231        return latentheat;
    232232}
    233 /*}}}1*/
    234 /*FUNCTION Matpar::GetMeltingPoint {{{1*/
    235 double Matpar::GetMeltingPoint(){
     233/*}}}*/
     234/*FUNCTION Matpar::GetMeltingPoint {{{*/
     235IssmDouble Matpar::GetMeltingPoint(){
    236236        return meltingpoint;
    237237}
    238 /*}}}1*/
    239 /*FUNCTION Matpar::GetReferenceTemperature {{{1*/
    240 double Matpar::GetReferenceTemperature(){
     238/*}}}*/
     239/*FUNCTION Matpar::GetReferenceTemperature {{{*/
     240IssmDouble Matpar::GetReferenceTemperature(){
    241241        return referencetemperature;
    242242}
    243 /*}}}1*/
    244 /*FUNCTION Matpar::GetMixedLayerCapacity {{{1*/
    245 double Matpar::GetMixedLayerCapacity(){
     243/*}}}*/
     244/*FUNCTION Matpar::GetMixedLayerCapacity {{{*/
     245IssmDouble Matpar::GetMixedLayerCapacity(){
    246246        return mixed_layer_capacity;
    247247}
    248 /*}}}1*/
    249 /*FUNCTION Matpar::GetRhoIce {{{1*/
    250 double Matpar::GetRhoIce(){
     248/*}}}*/
     249/*FUNCTION Matpar::GetRhoIce {{{*/
     250IssmDouble Matpar::GetRhoIce(){
    251251       
    252252        return rho_ice;
    253253}
    254 /*}}}1*/
    255 /*FUNCTION Matpar::GetRhoWater {{{1*/
    256 double Matpar::GetRhoWater(){
     254/*}}}*/
     255/*FUNCTION Matpar::GetRhoWater {{{*/
     256IssmDouble Matpar::GetRhoWater(){
    257257        return rho_water;
    258258}
    259 /*}}}1*/
    260 /*FUNCTION Matpar::GetRhoFreshwater {{{1*/
    261 double Matpar::GetRhoFreshwater(){
     259/*}}}*/
     260/*FUNCTION Matpar::GetRhoFreshwater {{{*/
     261IssmDouble Matpar::GetRhoFreshwater(){
    262262        return rho_freshwater;
    263263}
    264 /*}}}1*/
    265 /*FUNCTION Matpar::GetMuWater {{{1*/
    266 double Matpar::GetMuWater(){
     264/*}}}*/
     265/*FUNCTION Matpar::GetMuWater {{{*/
     266IssmDouble Matpar::GetMuWater(){
    267267        return mu_water;
    268268}
    269 /*}}}1*/
    270 /*FUNCTION Matpar::GetThermalConductivity {{{1*/
    271 double Matpar::GetThermalConductivity(){
     269/*}}}*/
     270/*FUNCTION Matpar::GetThermalConductivity {{{*/
     271IssmDouble Matpar::GetThermalConductivity(){
    272272        return thermalconductivity;
    273273}
    274 /*}}}1*/
    275 /*FUNCTION Matpar::GetThermalExchangeVelocity {{{1*/
    276 double Matpar::GetThermalExchangeVelocity(){
     274/*}}}*/
     275/*FUNCTION Matpar::GetThermalExchangeVelocity {{{*/
     276IssmDouble Matpar::GetThermalExchangeVelocity(){
    277277        return thermal_exchange_velocity;
    278278}
    279 /*}}}1*/
    280 /*FUNCTION Matpar::GetKn {{{1*/         
    281 double Matpar::GetKn(){                 
     279/*}}}*/
     280/*FUNCTION Matpar::GetKn {{{*/           
     281IssmDouble Matpar::GetKn(){                     
    282282        return kn;               
    283283}               
    284 /*}}}1*/                         
    285 /*FUNCTION Matpar::GetHydrologyP {{{1*/                 
    286 double Matpar::GetHydrologyP(){         
     284/*}}}*/                 
     285/*FUNCTION Matpar::GetHydrologyP {{{*/                   
     286IssmDouble Matpar::GetHydrologyP(){             
    287287        return hydro_p;                 
    288288}               
    289 /*}}}1*/                         
    290 /*FUNCTION Matqar::GetHydrologyQ {{{1*/                 
    291 double Matpar::GetHydrologyQ(){         
     289/*}}}*/                 
     290/*FUNCTION Matqar::GetHydrologyQ {{{*/                   
     291IssmDouble Matpar::GetHydrologyQ(){             
    292292        return hydro_q;                 
    293293}               
    294 /*}}}1*/                         
    295 /*FUNCTION Matpar::GetHydrologyCR {{{1*/                 
    296 double Matpar::GetHydrologyCR(){                 
     294/*}}}*/                 
     295/*FUNCTION Matpar::GetHydrologyCR {{{*/         
     296IssmDouble Matpar::GetHydrologyCR(){             
    297297        return hydro_CR;                 
    298298}               
    299 /*}}}1*/                         
    300 /*FUNCTION Matpar::GetHydrologyN {{{1*/                 
    301 double Matpar::GetHydrologyN(){         
     299/*}}}*/                 
     300/*FUNCTION Matpar::GetHydrologyN {{{*/                   
     301IssmDouble Matpar::GetHydrologyN(){             
    302302        return hydro_n;                 
    303303}               
    304 /*}}}1*/
    305 /*FUNCTION Matpar::TMeltingPoint {{{1*/
    306 double Matpar::TMeltingPoint(double pressure){
     304/*}}}*/
     305/*FUNCTION Matpar::TMeltingPoint {{{*/
     306IssmDouble Matpar::TMeltingPoint(IssmDouble pressure){
    307307        return meltingpoint-beta*pressure;
    308308}
    309 /*}}}1*/
    310 /*FUNCTION Matpar::PureIceEnthalpy{{{1*/
    311 double Matpar::PureIceEnthalpy(double pressure){
     309/*}}}*/
     310/*FUNCTION Matpar::PureIceEnthalpy{{{*/
     311IssmDouble Matpar::PureIceEnthalpy(IssmDouble pressure){
    312312        return heatcapacity*(TMeltingPoint(pressure)-referencetemperature);
    313313}
    314 /*}}}1*/
    315 /*FUNCTION Matpar::GetEnthalpyDiffusionParameter{{{1*/
    316 double Matpar::GetEnthalpyDiffusionParameter(double enthalpy,double pressure){
     314/*}}}*/
     315/*FUNCTION Matpar::GetEnthalpyDiffusionParameter{{{*/
     316IssmDouble Matpar::GetEnthalpyDiffusionParameter(IssmDouble enthalpy,IssmDouble pressure){
    317317        if(enthalpy<PureIceEnthalpy(pressure)){
    318318                return thermalconductivity/(rho_ice*heatcapacity);
     
    322322        }
    323323}
    324 /*}}}1*/
    325 /*FUNCTION Matpar::EnthalpyToThermal {{{1*/
    326 void Matpar::EnthalpyToThermal(double* ptemperature,double* pwaterfraction,double enthalpy,double pressure){
     324/*}}}*/
     325/*FUNCTION Matpar::EnthalpyToThermal {{{*/
     326void Matpar::EnthalpyToThermal(IssmDouble* ptemperature,IssmDouble* pwaterfraction,IssmDouble enthalpy,IssmDouble pressure){
    327327
    328328        /*Ouput*/
    329         double temperature,waterfraction;
     329        IssmDouble temperature,waterfraction;
    330330       
    331331        if(enthalpy<PureIceEnthalpy(pressure)){
     
    342342        *ptemperature=temperature;
    343343}
    344 /*}}}1*/
    345 /*FUNCTION Matpar::ThermalToEnthalpy {{{1*/
    346 void Matpar::ThermalToEnthalpy(double * penthalpy,double temperature,double waterfraction,double pressure){
     344/*}}}*/
     345/*FUNCTION Matpar::ThermalToEnthalpy {{{*/
     346void Matpar::ThermalToEnthalpy(IssmDouble * penthalpy,IssmDouble temperature,IssmDouble waterfraction,IssmDouble pressure){
    347347
    348348        /*Ouput*/
    349         double enthalpy;
     349        IssmDouble enthalpy;
    350350       
    351351        if(temperature<TMeltingPoint(pressure)){
     
    359359        *penthalpy=enthalpy;
    360360}
    361 /*}}}1*/
     361/*}}}*/
  • issm/trunk/src/c/objects/Materials/Matpar.h

    r12330 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "./Material.h"
    1111class IoModel;
     
    1616        private:
    1717                int       mid;
    18                 double  rho_ice;
    19                 double  rho_water;
    20                 double  rho_freshwater;
    21                 double  mu_water;
    22                 double  heatcapacity;
    23                 double  thermalconductivity;
    24                 double  latentheat;
    25                 double  beta;
    26                 double  meltingpoint;
    27                 double  referencetemperature;
    28                 double  mixed_layer_capacity;
    29                 double  thermal_exchange_velocity;
    30                 double  g;
     18                IssmDouble  rho_ice;
     19                IssmDouble  rho_water;
     20                IssmDouble  rho_freshwater;
     21                IssmDouble  mu_water;
     22                IssmDouble  heatcapacity;
     23                IssmDouble  thermalconductivity;
     24                IssmDouble  latentheat;
     25                IssmDouble  beta;
     26                IssmDouble  meltingpoint;
     27                IssmDouble  referencetemperature;
     28                IssmDouble  mixed_layer_capacity;
     29                IssmDouble  thermal_exchange_velocity;
     30                IssmDouble  g;
    3131
    3232                /*hydrology: */         
    33                 double  kn;                     
    34                 double  hydro_p;                 
    35                 double  hydro_q;                 
    36                 double  hydro_CR;                       
    37                 double  hydro_n;
     33                IssmDouble  kn;                 
     34                IssmDouble  hydro_p;             
     35                IssmDouble  hydro_q;             
     36                IssmDouble  hydro_CR;                   
     37                IssmDouble  hydro_n;
    3838
    3939        public:
     
    4242                ~Matpar();
    4343
    44                 /*Object virtual functions definitions:{{{1 */
     44                /*Object virtual functions definitions:{{{ */
    4545                void  Echo();
    4646                void  DeepEcho();
     
    5050                Object* copy();
    5151                /*}}}*/
    52                 /*Update virtual functions resolution: {{{1*/
    53                 void   InputUpdateFromVector(double* vector, int name, int type);
     52                /*Update virtual functions resolution: {{{*/
     53                void   InputUpdateFromVector(IssmDouble* vector, int name, int type);
    5454                void   InputUpdateFromVector(int* vector, int name, int type);
    5555                void   InputUpdateFromVector(bool* vector, int name, int type);
    56                 void   InputUpdateFromMatrixDakota(double* matrix,int nrows,int ncols, int name, int type);
    57                 void   InputUpdateFromVectorDakota(double* vector, int name, int type);
     56                void   InputUpdateFromMatrixDakota(IssmDouble* matrix,int nrows,int ncols, int name, int type);
     57                void   InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
    5858                void   InputUpdateFromVectorDakota(int* vector, int name, int type);
    5959                void   InputUpdateFromVectorDakota(bool* vector, int name, int type);
    60                 void   InputUpdateFromConstant(double constant, int name);
     60                void   InputUpdateFromConstant(IssmDouble constant, int name);
    6161                void   InputUpdateFromConstant(int constant, int name);
    6262                void   InputUpdateFromConstant(bool constant, int name);
    63                 void   InputUpdateFromSolution(double* solution);
    64                 void   InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("not implemented yet");};
     63                void   InputUpdateFromSolution(IssmDouble* solution);
     64                void   InputUpdateFromIoModel(int index, IoModel* iomodel){_error2_("not implemented yet");};
    6565                /*}}}*/
    66                 /*Material virtual functions resolution: {{{1*/
    67                 void   InputDuplicate(int original_enum,int new_enum){_error_("not implemented yet");};
     66                /*Material virtual functions resolution: {{{*/
     67                void   InputDuplicate(int original_enum,int new_enum){_error2_("not implemented yet");};
    6868                void   Configure(Elements* elements);
    6969                void   GetVectorFromInputs(Vector* vector,int input_enum){return;}
    7070                /*}}}*/
    71                 /*Numerics: {{{1*/
    72                 double GetG();
    73                 double GetRhoIce();
    74                 double GetRhoWater();
    75                 double GetRhoFreshwater();
    76                 double GetMuWater();
    77                 double GetMixedLayerCapacity();
    78                 double GetThermalExchangeVelocity();
    79                 double GetHeatCapacity();
    80                 double GetThermalConductivity();
    81                 double GetLatentHeat();
    82                 double GetBeta();
    83                 double GetMeltingPoint();
    84                 double GetReferenceTemperature();
    85                 double GetKn();
    86                 double GetHydrologyP();
    87                 double GetHydrologyQ();
    88                 double GetHydrologyCR();
    89                 double GetHydrologyN();
    90                 double TMeltingPoint(double pressure);
    91                 double PureIceEnthalpy(double pressure);
    92                 double GetEnthalpyDiffusionParameter(double enthalpy,double pressure);
    93                 void   EnthalpyToThermal(double* ptemperature,double* pwaterfraction,double enthalpy,double pressure);
    94                 void   ThermalToEnthalpy(double* penthalpy,double temperature,double waterfraction,double pressure);
     71                /*Numerics: {{{*/
     72                IssmDouble GetG();
     73                IssmDouble GetRhoIce();
     74                IssmDouble GetRhoWater();
     75                IssmDouble GetRhoFreshwater();
     76                IssmDouble GetMuWater();
     77                IssmDouble GetMixedLayerCapacity();
     78                IssmDouble GetThermalExchangeVelocity();
     79                IssmDouble GetHeatCapacity();
     80                IssmDouble GetThermalConductivity();
     81                IssmDouble GetLatentHeat();
     82                IssmDouble GetBeta();
     83                IssmDouble GetMeltingPoint();
     84                IssmDouble GetReferenceTemperature();
     85                IssmDouble GetKn();
     86                IssmDouble GetHydrologyP();
     87                IssmDouble GetHydrologyQ();
     88                IssmDouble GetHydrologyCR();
     89                IssmDouble GetHydrologyN();
     90                IssmDouble TMeltingPoint(IssmDouble pressure);
     91                IssmDouble PureIceEnthalpy(IssmDouble pressure);
     92                IssmDouble GetEnthalpyDiffusionParameter(IssmDouble enthalpy,IssmDouble pressure);
     93                void   EnthalpyToThermal(IssmDouble* ptemperature,IssmDouble* pwaterfraction,IssmDouble enthalpy,IssmDouble pressure);
     94                void   ThermalToEnthalpy(IssmDouble* penthalpy,IssmDouble temperature,IssmDouble waterfraction,IssmDouble pressure);
    9595                /*}}}*/
    9696
  • issm/trunk/src/c/objects/Node.cpp

    r12330 r12706  
    33 */
    44
    5 /*Include files: {{{1*/
     5/*Include files: {{{*/
    66#ifdef HAVE_CONFIG_H
    77        #include <config.h>
     
    2121
    2222/*Node constructors and destructors:*/
    23 /*FUNCTION Node::Node() default constructor {{{1*/
     23/*FUNCTION Node::Node() default constructor {{{*/
    2424Node::Node(){
    2525                 this->inputs=NULL;
     
    2828}
    2929/*}}}*/
    30 /*FUNCTION Node::Node(int node_id,int node_sid,int vertex_id,int io_index, IoModel* iomodel,int analysis_type) {{{1*/
     30/*FUNCTION Node::Node(int node_id,int node_sid,int vertex_id,int io_index, IoModel* iomodel,int analysis_type) {{{*/
    3131Node::Node(int node_id,int node_sid,int vertex_id,int io_index, IoModel* iomodel,int analysis_type){
    3232
     
    5858        this->inputs=new Inputs();
    5959        if (iomodel->Data(MeshVertexonbedEnum))
    60          this->inputs->AddInput(new BoolInput(MeshVertexonbedEnum,(IssmBool)iomodel->Data(MeshVertexonbedEnum)[io_index]));
     60         this->inputs->AddInput(new BoolInput(MeshVertexonbedEnum,reCast<IssmBool>(iomodel->Data(MeshVertexonbedEnum)[io_index])));
    6161        if (iomodel->Data(MeshVertexonsurfaceEnum))
    62          this->inputs->AddInput(new BoolInput(MeshVertexonsurfaceEnum,(IssmBool)iomodel->Data(MeshVertexonsurfaceEnum)[io_index]));
     62         this->inputs->AddInput(new BoolInput(MeshVertexonsurfaceEnum,reCast<IssmBool>(iomodel->Data(MeshVertexonsurfaceEnum)[io_index])));
    6363        if (iomodel->Data(MaskVertexonfloatingiceEnum))
    64          this->inputs->AddInput(new BoolInput(MaskVertexonfloatingiceEnum,(IssmBool)iomodel->Data(MaskVertexonfloatingiceEnum)[io_index]));
     64         this->inputs->AddInput(new BoolInput(MaskVertexonfloatingiceEnum,reCast<IssmBool>(iomodel->Data(MaskVertexonfloatingiceEnum)[io_index])));
    6565        if (iomodel->Data(MaskVertexongroundediceEnum))
    66          this->inputs->AddInput(new BoolInput(MaskVertexongroundediceEnum,(IssmBool)iomodel->Data(MaskVertexongroundediceEnum)[io_index]));
     66          this->inputs->AddInput(new BoolInput(MaskVertexongroundediceEnum,reCast<IssmBool>(iomodel->Data(MaskVertexongroundediceEnum)[io_index])));
    6767        if (analysis_type==DiagnosticHorizAnalysisEnum)
    68          this->inputs->AddInput(new IntInput(ApproximationEnum,(IssmInt)iomodel->Data(FlowequationVertexEquationEnum)[io_index]));
    69        
     68         this->inputs->AddInput(new IntInput(ApproximationEnum,reCast<IssmInt>(iomodel->Data(FlowequationVertexEquationEnum)[io_index])));
    7069        /*set single point constraints: */
    7170
    7271        /*spc all nodes on water*/
    73         if (!iomodel->Data(MaskVertexonwaterEnum)) _error_("iomodel->nodeonwater is NULL");
    74         if (iomodel->Data(MaskVertexonwaterEnum)[io_index]){
     72        if (!iomodel->Data(MaskVertexonwaterEnum)) _error2_("iomodel->nodeonwater is NULL");
     73        if (reCast<IssmBool>(iomodel->Data(MaskVertexonwaterEnum)[io_index])){
    7574                for(k=1;k<=gsize;k++){
    7675                        this->FreezeDof(k);
     
    115114        /*Diagnostic Hutter*/
    116115        if (analysis_type==DiagnosticHutterAnalysisEnum){
    117                 if (!iomodel->Data(FlowequationVertexEquationEnum)) _error_("iomodel->vertices_type is NULL");
     116                if (!iomodel->Data(FlowequationVertexEquationEnum)) _error2_("iomodel->vertices_type is NULL");
    118117                /*Constrain all nodes that are not Hutter*/
    119                 if (!iomodel->Data(FlowequationVertexEquationEnum)[io_index]==HutterApproximationEnum){
     118                if (reCast<int>(iomodel->Data(FlowequationVertexEquationEnum)[io_index])!=HutterApproximationEnum){
    120119                        for(k=1;k<=gsize;k++){
    121120                                this->FreezeDof(k);
     
    135134                        /*On a 3d mesh, we may have collapsed elements, hence dead nodes. Freeze them out: */
    136135                        _assert_(iomodel->Data(MeshVertexonbedEnum));
    137                         if (!iomodel->Data(MeshVertexonbedEnum)[io_index]){
     136                        if (!(reCast<IssmBool>(iomodel->Data(MeshVertexonbedEnum)[io_index]))){
    138137                                for(k=1;k<=gsize;k++){
    139138                                        this->FreezeDof(k);
     
    145144}
    146145/*}}}*/
    147 /*FUNCTION Node::~Node(){{{1*/
     146/*FUNCTION Node::~Node(){{{*/
    148147Node::~Node(){
    149148        delete inputs;
     
    154153
    155154/*Object virtual functions definitions:*/
    156 /*FUNCTION Node::Echo{{{1*/
     155/*FUNCTION Node::Echo{{{*/
    157156void Node::Echo(void){
    158157
    159         printf("Node:\n");
    160         printf("   id: %i\n",id);
    161         printf("   sid: %i\n",sid);
    162         printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
     158        _printLine_("Node:");
     159        _printLine_("   id: " << id);
     160        _printLine_("   sid: " << sid);
     161        _printLine_("   analysis_type: " << EnumToStringx(analysis_type));
    163162        indexing.Echo();
    164         printf("   hvertex:     not displayed\n");
    165         printf("   inputs:      %p\n",inputs);
    166 
    167 
    168 }
    169 /*}}}*/
    170 /*FUNCTION Node::DeepEcho{{{1*/
     163        _printLine_("   hvertex:     not displayed");
     164        _printLine_("   inputs:      " << inputs);
     165
     166
     167}
     168/*}}}*/
     169/*FUNCTION Node::DeepEcho{{{*/
    171170void Node::DeepEcho(void){
    172171
    173         printf("Node:\n");
    174         printf("   id: %i\n",id);
    175         printf("   sid: %i\n",sid);
    176         printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
     172        _printLine_("Node:");
     173        _printLine_("   id: " << id);
     174        _printLine_("   sid: " << sid);
     175        _printLine_("   analysis_type: " << EnumToStringx(analysis_type));
    177176        indexing.DeepEcho();
    178         printf("Vertex:\n");
     177        _printLine_("Vertex:");
    179178        hvertex->DeepEcho();
    180         printf("   inputs\n");
    181 
    182 
    183 }
    184 /*}}}*/
    185 /*FUNCTION Node::Id{{{1*/
     179        _printLine_("   inputs");
     180
     181
     182}
     183/*}}}*/
     184/*FUNCTION Node::Id{{{*/
    186185int    Node::Id(void){ return id; }
    187186/*}}}*/
    188 /*FUNCTION Node::MyRank{{{1*/
     187/*FUNCTION Node::MyRank{{{*/
    189188int    Node::MyRank(void){
    190189        extern int my_rank;
     
    193192}
    194193/*}}}*/
    195 /*FUNCTION Node::ObjectEnum{{{1*/
     194/*FUNCTION Node::ObjectEnum{{{*/
    196195int Node::ObjectEnum(void){
    197196
     
    202201
    203202/*Node management:*/
    204 /*FUNCTION Node::Configure {{{1*/
     203/*FUNCTION Node::Configure {{{*/
    205204void  Node::Configure(DataSet* nodesin,Vertices* verticesin){
    206205
     
    212211
    213212}
    214 /*FUNCTION Node::SetCurrentConfiguration {{{1*/
     213/*FUNCTION Node::SetCurrentConfiguration {{{*/
    215214void  Node::SetCurrentConfiguration(DataSet* nodesin,Vertices* verticesin){
    216215
    217216}
    218 /*FUNCTION Node::GetDof {{{1*/
     217/*FUNCTION Node::GetDof {{{*/
    219218int   Node::GetDof(int dofindex,int setenum){
    220219
     
    231230                return indexing.sdoflist[dofindex];
    232231        }
    233         else _error_("%s%s%s"," set of enum type ",EnumToStringx(setenum)," not supported yet!");
    234 
    235 }
    236 /*}}}*/
    237 /*FUNCTION Node::GetDofList1{{{1*/
     232        else _error2_("set of enum type " << EnumToStringx(setenum) << " not supported yet!");
     233
     234}
     235/*}}}*/
     236/*FUNCTION Node::GetDofList1{{{*/
    238237int  Node::GetDofList1(void){
    239238
     
    245244}
    246245/*}}}*/
    247 /*FUNCTION Node::GetDofList{{{1*/
     246/*FUNCTION Node::GetDofList{{{*/
    248247void  Node::GetDofList(int* outdoflist,int approximation_enum,int setenum){
    249248        int i;
     
    303302                        else for(i=0;i<this->indexing.ssize;i++) outdoflist[i]=indexing.sdoflist[i];
    304303                }
    305                 else _error_("%s%s%s"," set of enum type ",EnumToStringx(setenum)," not supported yet!");
    306         }
    307 }
    308 /*}}}*/
    309 /*FUNCTION Node::GetSidList{{{1*/
     304                else _error2_("set of enum type " << EnumToStringx(setenum) << " not supported yet!");
     305        }
     306}
     307/*}}}*/
     308/*FUNCTION Node::GetSidList{{{*/
    310309int  Node::GetSidList(void){
    311310
     
    317316}
    318317/*}}}*/
    319 /*FUNCTION Node::GetLocalDofList{{{1*/
     318/*FUNCTION Node::GetLocalDofList{{{*/
    320319void  Node::GetLocalDofList(int* outdoflist,int approximation_enum,int setenum){
    321320        int i;
     
    343342                        }
    344343                }
    345                 else _error_("%s%s%s"," set of enum type ",EnumToStringx(setenum)," not supported yet!");
     344                else _error2_("set of enum type " << EnumToStringx(setenum) << " not supported yet!");
    346345        }
    347346        else{
     
    412411                        }
    413412                }
    414                 else _error_("%s%s%s"," set of enum type ",EnumToStringx(setenum)," not supported yet!");
    415         }
    416 }
    417 /*}}}*/
    418 /*FUNCTION Node::Sid{{{1*/
     413                else _error2_("set of enum type " << EnumToStringx(setenum) << " not supported yet!");
     414        }
     415}
     416/*}}}*/
     417/*FUNCTION Node::Sid{{{*/
    419418int    Node::Sid(void){ return sid; }
    420419/*}}}*/
    421 /*FUNCTION Node::GetVertexId {{{1*/
     420/*FUNCTION Node::GetVertexId {{{*/
    422421int   Node::GetVertexId(void){
    423422
     
    428427}
    429428/*}}}*/
    430 /*FUNCTION Node::GetVertexDof {{{1*/
     429/*FUNCTION Node::GetVertexDof {{{*/
    431430int   Node::GetVertexDof(void){
    432431
     
    438437/*}}}*/
    439438#ifdef _HAVE_DIAGNOSTIC_
    440 /*FUNCTION Node::GetCoordinateSystem{{{1*/
    441 void Node::GetCoordinateSystem(double* coord_system_out){
     439/*FUNCTION Node::GetCoordinateSystem{{{*/
     440void Node::GetCoordinateSystem(IssmDouble* coord_system_out){
    442441
    443442        /*Copy coord_system*/
     
    447446/*}}}*/
    448447#endif
    449 /*FUNCTION Node::SetVertexDof {{{1*/
     448/*FUNCTION Node::SetVertexDof {{{*/
    450449void   Node::SetVertexDof(int in_dof){
    451450
     
    457456}
    458457/*}}}*/
    459 /*FUNCTION Node::InAnalysis{{{1*/
     458/*FUNCTION Node::InAnalysis{{{*/
    460459bool Node::InAnalysis(int in_analysis_type){
    461460        if (in_analysis_type==this->analysis_type) return true;
     
    465464
    466465/*Node numerics:*/
    467 /*FUNCTION Node::ApplyConstraints{{{1*/
    468 void  Node::ApplyConstraint(int dof,double value){
     466/*FUNCTION Node::ApplyConstraints{{{*/
     467void  Node::ApplyConstraint(int dof,IssmDouble value){
    469468
    470469        int index;
     
    476475}
    477476/*}}}*/
    478 /*FUNCTION Node::RelaxConstraint{{{1*/
     477/*FUNCTION Node::RelaxConstraint{{{*/
    479478void  Node::RelaxConstraint(int dof){
    480479
     
    484483}
    485484/*}}}*/
    486 /*FUNCTION Node::CreateVecSets {{{1*/
     485/*FUNCTION Node::CreateVecSets {{{*/
    487486void  Node::CreateVecSets(Vector* pv_g,Vector* pv_f,Vector* pv_s){
    488487
    489         double gvalue=1.0; //all nodes are in the g set;
    490         double value;
     488        IssmDouble gvalue=1.0; //all nodes are in the g set;
     489        IssmDouble value;
    491490
    492491        int i;
     
    498497               
    499498                /*f set: */
    500                 value=(double)this->indexing.f_set[i];
     499                value=(IssmDouble)this->indexing.f_set[i];
    501500                pv_f->SetValue(indexing.gdoflist[i],value,INS_VAL);
    502501
    503502                /*s set: */
    504                 value=(double)this->indexing.s_set[i];
     503                value=(IssmDouble)this->indexing.s_set[i];
    505504                pv_s->SetValue(indexing.gdoflist[i],value,INS_VAL);
    506505
     
    510509}
    511510/*}}}*/
    512 /*FUNCTION Node::CreateNodalConstraints{{{1*/
     511/*FUNCTION Node::CreateNodalConstraints{{{*/
    513512void  Node::CreateNodalConstraints(Vector* ys){
    514513
    515514        int i;
    516         double* values=NULL;
     515        IssmDouble* values=NULL;
    517516        int count;
    518517
    519518        /*Recover values for s set and plug them in constraints vector: */
    520519        if(this->indexing.ssize){
    521                 values=(double*)xmalloc(this->indexing.ssize*sizeof(double));
     520                values=xNew<IssmDouble>(this->indexing.ssize);
    522521                count=0;
    523522                for(i=0;i<this->indexing.gsize;i++){
    524523                        if(this->indexing.s_set[i]){
    525524                                values[count]=this->indexing.svalues[i];
    526                                 _assert_(!isnan(values[count]));
     525                                _assert_(!xIsNan<IssmDouble>(values[count]));
    527526                                count++;
    528527                        }
     
    534533
    535534        /*Free ressources:*/
    536         xfree((void**)&values);
    537 
    538 
    539 }
    540 /*}}}*/
    541 /*FUNCTION Node::DofInSSet {{{1*/
     535        xDelete<IssmDouble>(values);
     536
     537
     538}
     539/*}}}*/
     540/*FUNCTION Node::DofInSSet {{{*/
    542541void  Node::DofInSSet(int dof){
    543542
     
    549548}
    550549/*}}}*/
    551 /*FUNCTION Node::DofInFSet {{{1*/
     550/*FUNCTION Node::DofInFSet {{{*/
    552551void  Node::DofInFSet(int dof){
    553552
     
    559558}
    560559/*}}}*/
    561 /*FUNCTION Node::FreezeDof{{{1*/
     560/*FUNCTION Node::FreezeDof{{{*/
    562561void  Node::FreezeDof(int dof){
    563562       
     
    566565}
    567566/*}}}*/
    568 /*FUNCTION Node::GetApproximation {{{1*/
     567/*FUNCTION Node::GetApproximation {{{*/
    569568int   Node::GetApproximation(){
    570569
     
    577576}
    578577/*}}}*/
    579 /*FUNCTION Node::GetConnectivity {{{1*/
     578/*FUNCTION Node::GetConnectivity {{{*/
    580579int Node::GetConnectivity(){
    581580
     
    585584}
    586585/*}}}*/
    587 /*FUNCTION Node::GetNumberOfDofs{{{1*/
     586/*FUNCTION Node::GetNumberOfDofs{{{*/
    588587int   Node::GetNumberOfDofs(int approximation_enum,int setenum){
    589588
     
    598597                else if (setenum==FsetEnum) numdofs=this->indexing.fsize;
    599598                else if (setenum==SsetEnum) numdofs=this->indexing.ssize;
    600                 else _error_("%s%s%s"," set of enum type ",EnumToStringx(setenum)," not supported yet!");
     599                else _error2_("set of enum type " << EnumToStringx(setenum) << " not supported yet!");
    601600        }
    602601        else{
     
    628627                        else numdofs=this->indexing.ssize;
    629628                }
    630                 else _error_("%s%s%s"," set of enum type ",EnumToStringx(setenum)," not supported yet!");
     629                else _error2_("set of enum type " << EnumToStringx(setenum) << " not supported yet!");
    631630        }
    632631        return numdofs;
    633632}
    634633/*}}}*/
    635 /*FUNCTION Node::GetSigma {{{1*/
    636 double Node::GetSigma(){
     634/*FUNCTION Node::GetSigma {{{*/
     635IssmDouble Node::GetSigma(){
    637636        Vertex* vertex=NULL;
    638637
     
    641640}
    642641/*}}}*/
    643 /*FUNCTION Node::GetX {{{1*/
    644 double Node::GetX(){
     642/*FUNCTION Node::GetX {{{*/
     643IssmDouble Node::GetX(){
    645644        Vertex* vertex=NULL;
    646645
     
    649648}
    650649/*}}}*/
    651 /*FUNCTION Node::GetY {{{1*/
    652 double Node::GetY(){
     650/*FUNCTION Node::GetY {{{*/
     651IssmDouble Node::GetY(){
    653652        Vertex* vertex=NULL;
    654653
     
    657656}
    658657/*}}}*/
    659 /*FUNCTION Node::GetZ {{{1*/
    660 double Node::GetZ(){
     658/*FUNCTION Node::GetZ {{{*/
     659IssmDouble Node::GetZ(){
    661660        Vertex* vertex=NULL;
    662661
     
    665664}
    666665/*}}}*/
    667 /*FUNCTION Node::IsClone {{{1*/
     666/*FUNCTION Node::IsClone {{{*/
    668667int   Node::IsClone(){
    669668       
     
    672671}
    673672/*}}}*/
    674 /*FUNCTION Node::IsOnBed {{{1*/
     673/*FUNCTION Node::IsOnBed {{{*/
    675674int   Node::IsOnBed(){
    676675
     
    683682}
    684683/*}}}*/
    685 /*FUNCTION Node::IsGrounded {{{1*/
     684/*FUNCTION Node::IsGrounded {{{*/
    686685int   Node::IsGrounded(){
    687686
     
    694693}               
    695694/*}}}*/
    696 /*FUNCTION Node::IsFloating {{{1*/
     695/*FUNCTION Node::IsFloating {{{*/
    697696int   Node::IsFloating(){
    698697       
     
    705704}
    706705/*}}}*/
    707 /*FUNCTION Node::IsOnSurface {{{1*/
     706/*FUNCTION Node::IsOnSurface {{{*/
    708707int   Node::IsOnSurface(){
    709708
     
    716715}
    717716/*}}}*/
    718 /*FUNCTION Node::InputUpdateFromVector(double* vector, int name, int type){{{1*/
    719 void  Node::InputUpdateFromVector(double* vector, int name, int type){
     717/*FUNCTION Node::InputUpdateFromVector(IssmDouble* vector, int name, int type){{{*/
     718void  Node::InputUpdateFromVector(IssmDouble* vector, int name, int type){
    720719
    721720        /*Nothing updated yet*/
    722721}
    723722/*}}}*/
    724 /*FUNCTION Node::InputUpdateFromVector(int* vector, int name, int type){{{1*/
     723/*FUNCTION Node::InputUpdateFromVector(int* vector, int name, int type){{{*/
    725724void  Node::InputUpdateFromVector(int* vector, int name, int type){
    726725
     
    728727}
    729728/*}}}*/
    730 /*FUNCTION Node::InputUpdateFromVector(bool* vector, int name, int type){{{1*/
     729/*FUNCTION Node::InputUpdateFromVector(bool* vector, int name, int type){{{*/
    731730void  Node::InputUpdateFromVector(bool* vector, int name, int type){
    732731
     
    734733}
    735734/*}}}*/
    736 /*FUNCTION Node::InputUpdateFromVectorDakota(double* vector, int name, int type){{{1*/
    737 void  Node::InputUpdateFromVectorDakota(double* vector, int name, int type){
     735/*FUNCTION Node::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){{{*/
     736void  Node::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){
    738737
    739738        /*Nothing updated yet*/
    740739}
    741740/*}}}*/
    742 /*FUNCTION Node::InputUpdateFromMatrixDakota(double* matrix, int nrows, int ncols, int name, int type){{{1*/
    743 void  Node::InputUpdateFromMatrixDakota(double* matrix, int nrows, int ncols, int name, int type){
     741/*FUNCTION Node::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type){{{*/
     742void  Node::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type){
    744743
    745744        /*Nothing updated yet*/
    746745}
    747746/*}}}*/
    748 /*FUNCTION Node::InputUpdateFromVectorDakota(int* vector, int name, int type){{{1*/
     747/*FUNCTION Node::InputUpdateFromVectorDakota(int* vector, int name, int type){{{*/
    749748void  Node::InputUpdateFromVectorDakota(int* vector, int name, int type){
    750749
     
    752751}
    753752/*}}}*/
    754 /*FUNCTION Node::InputUpdateFromVectorDakota(bool* vector, int name, int type){{{1*/
     753/*FUNCTION Node::InputUpdateFromVectorDakota(bool* vector, int name, int type){{{*/
    755754void  Node::InputUpdateFromVectorDakota(bool* vector, int name, int type){
    756755
     
    758757}
    759758/*}}}*/
    760 /*FUNCTION Node::InputUpdateFromConstant(double constant, int name){{{1*/
    761 void  Node::InputUpdateFromConstant(double constant, int name){
     759/*FUNCTION Node::InputUpdateFromConstant(IssmDouble constant, int name){{{*/
     760void  Node::InputUpdateFromConstant(IssmDouble constant, int name){
    762761
    763762        /*Nothing updated yet*/
    764763}
    765764/*}}}*/
    766 /*FUNCTION Node::InputUpdateFromConstant(int constant, int name){{{1*/
     765/*FUNCTION Node::InputUpdateFromConstant(int constant, int name){{{*/
    767766void  Node::InputUpdateFromConstant(int constant, int name){
    768767
     
    770769}
    771770/*}}}*/
    772 /*FUNCTION Node::InputUpdateFromConstant(bool constant, int name){{{1*/
     771/*FUNCTION Node::InputUpdateFromConstant(bool constant, int name){{{*/
    773772void  Node::InputUpdateFromConstant(bool constant, int name){
    774773
     
    776775}
    777776/*}}}*/
    778 /*FUNCTION Node::UpdateSpcs {{{1*/
    779 void   Node::UpdateSpcs(double* ys){
     777/*FUNCTION Node::UpdateSpcs {{{*/
     778void   Node::UpdateSpcs(IssmDouble* ys){
    780779
    781780        int     count=0;
     
    791790}
    792791/*}}}*/
    793 /*FUNCTION Node::VecMerge {{{1*/
    794 void   Node::VecMerge(Vector* ug, double* vector_serial,int setenum){
    795 
    796         double* values=NULL;
     792/*FUNCTION Node::VecMerge {{{*/
     793void   Node::VecMerge(Vector* ug, IssmDouble* vector_serial,int setenum){
     794
     795        IssmDouble* values=NULL;
    797796        int*    indices=NULL;
    798797        int     count=0;
     
    801800        if(setenum==FsetEnum){
    802801                if(this->indexing.fsize){
    803                         indices=(int*)xmalloc(this->indexing.fsize*sizeof(int));
    804                         values=(double*)xmalloc(this->indexing.fsize*sizeof(double));
     802                        indices=xNew<int>(this->indexing.fsize);
     803                        values=xNew<IssmDouble>(this->indexing.fsize);
    805804
    806805                        for(i=0;i<this->indexing.gsize;i++){
     
    819818        else if(setenum==SsetEnum){
    820819                if(this->indexing.ssize){
    821                         indices=(int*)xmalloc(this->indexing.ssize*sizeof(int));
    822                         values=(double*)xmalloc(this->indexing.ssize*sizeof(double));
     820                        indices=xNew<int>(this->indexing.ssize);
     821                        values=xNew<IssmDouble>(this->indexing.ssize);
    823822
    824823                        for(i=0;i<this->indexing.gsize;i++){
     
    835834                }
    836835        }
    837         else _error_("VecMerge can only merge from the s or f-set onto the g-set!");
     836        else _error2_("VecMerge can only merge from the s or f-set onto the g-set!");
    838837
    839838        /*Free ressources:*/
    840         xfree((void**)&values);
    841         xfree((void**)&indices);
    842 }
    843 /*}}}*/
    844 /*FUNCTION Node::VecReduce {{{1*/
    845 void   Node::VecReduce(Vector* vector, double* ug_serial,int setenum){
    846 
    847         double* values=NULL;
     839        xDelete<IssmDouble>(values);
     840        xDelete<int>(indices);
     841}
     842/*}}}*/
     843/*FUNCTION Node::VecReduce {{{*/
     844void   Node::VecReduce(Vector* vector, IssmDouble* ug_serial,int setenum){
     845
     846        IssmDouble* values=NULL;
    848847        int     count=0;
    849848        int     i;
     
    851850        if(setenum==FsetEnum){
    852851                if(this->indexing.fsize){
    853                         values=(double*)xmalloc(this->indexing.fsize*sizeof(double));
     852                        values=xNew<IssmDouble>(this->indexing.fsize);
    854853
    855854                        for(i=0;i<this->indexing.gsize;i++){
     
    867866        else if(setenum==SsetEnum){
    868867                if(this->indexing.ssize){
    869                         values=(double*)xmalloc(this->indexing.ssize*sizeof(double));
     868                        values=xNew<IssmDouble>(this->indexing.ssize);
    870869
    871870                        for(i=0;i<this->indexing.gsize;i++){
     
    881880                }
    882881        }
    883         else _error_("VecReduce can only merge from the s or f-set onto the g-set!");
     882        else _error2_("VecReduce can only merge from the s or f-set onto the g-set!");
    884883
    885884        /*Free ressources:*/
    886         xfree((void**)&values);
     885        xDelete<IssmDouble>(values);
    887886}
    888887/*}}}*/
    889888
    890889/* DofObject routines:*/
    891 /*FUNCTION Node::DistributeDofs{{{1*/
     890/*FUNCTION Node::DistributeDofs{{{*/
    892891void  Node::DistributeDofs(int* pdofcount,int setenum){
    893892
     
    928927                dofcount+=this->indexing.ssize;
    929928        }
    930         else _error_("%s%s%s"," set of enum type ",EnumToStringx(setenum)," not supported yet!");
     929        else _error2_("set of enum type " << EnumToStringx(setenum) << " not supported yet!");
    931930
    932931
     
    936935}
    937936/*}}}*/
    938 /*FUNCTION Node::Off_setDofs{{{1*/
     937/*FUNCTION Node::Off_setDofs{{{*/
    939938void  Node::OffsetDofs(int dofcount,int setenum){
    940939       
     
    957956                for(i=0;i<this->indexing.ssize;i++) indexing.sdoflist[i]+=dofcount;
    958957        }
    959         else _error_("%s%s%s"," set of enum type ",EnumToStringx(setenum)," not supported yet!");
    960 }
    961 /*}}}*/
    962 /*FUNCTION Node::ShowTrueDofs{{{1*/
     958        else _error2_("set of enum type " << EnumToStringx(setenum) << " not supported yet!");
     959}
     960/*}}}*/
     961/*FUNCTION Node::ShowTrueDofs{{{*/
    963962void  Node::ShowTrueDofs(int* truedofs, int ncols,int setenum){
    964963
     
    973972        else if(setenum==FsetEnum)for(j=0;j<this->indexing.fsize;j++)  *(truedofs+ncols*sid+j)=indexing.fdoflist[j];
    974973        else if(setenum==SsetEnum)for(j=0;j<this->indexing.ssize;j++)  *(truedofs+ncols*sid+j)=indexing.sdoflist[j];
    975         else _error_("%s%s%s"," set of enum type ",EnumToStringx(setenum)," not supported yet!");
    976 
    977 }
    978 /*}}}*/
    979 /*FUNCTION Node::UpdateCloneDofs{{{1*/
     974        else _error2_("set of enum type " << EnumToStringx(setenum) << " not supported yet!");
     975
     976}
     977/*}}}*/
     978/*FUNCTION Node::UpdateCloneDofs{{{*/
    980979void  Node::UpdateCloneDofs(int* alltruedofs,int ncols,int setenum){
    981980
     
    992991        else if(setenum==FsetEnum)for(j=0;j<this->indexing.fsize;j++) indexing.fdoflist[j]=*(alltruedofs+ncols*sid+j);
    993992        else if(setenum==SsetEnum)for(j=0;j<this->indexing.ssize;j++) indexing.sdoflist[j]=*(alltruedofs+ncols*sid+j);
    994         else _error_("%s%s%s"," set of enum type ",EnumToStringx(setenum)," not supported yet!");
    995 
    996 }
    997 /*}}}*/
    998 /*FUNCTION Node::SetClone {{{1*/
     993        else _error2_("set of enum type " << EnumToStringx(setenum) << " not supported yet!");
     994
     995}
     996/*}}}*/
     997/*FUNCTION Node::SetClone {{{*/
    999998void  Node::SetClone(int* minranks){
    1000999
  • issm/trunk/src/c/objects/Node.h

    r12330 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "./Object.h"
    1111#include "../shared/shared.h"
     
    3434                IssmDouble         coord_system[3][3];
    3535
    36                 /*Node constructors, destructors {{{1*/
     36                /*Node constructors, destructors {{{*/
    3737                Node();
    3838                Node(int node_id,int node_sid, int vertex_id,int io_index, IoModel* iomodel,int analysis_type);
    3939                ~Node();
    4040                /*}}}*/
    41                 /*Object virtual functions definitions:{{{1 */
     41                /*Object virtual functions definitions:{{{ */
    4242                void  Echo();
    4343                void  DeepEcho();
     
    4545                int   MyRank();
    4646                int   ObjectEnum();
    47                 Object* copy(){_error_("Not implemented yet (similar to Elements)");};
     47                Object* copy(){_error2_("Not implemented yet (similar to Elements)");};
    4848                /*}}}*/
    49                 /*Update virtual functions definitions: {{{1*/
     49                /*Update virtual functions definitions: {{{*/
    5050               
    5151                void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
     
    5959                void  InputUpdateFromConstant(int constant, int name);
    6060                void  InputUpdateFromConstant(bool constant, int name);
    61                 void  InputUpdateFromSolution(IssmDouble* solution){_error_("Not implemented yet!");}
    62                 void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("Not implemented yet!");}
     61                void  InputUpdateFromSolution(IssmDouble* solution){_error2_("Not implemented yet!");}
     62                void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error2_("Not implemented yet!");}
    6363                /*}}}*/
    64                 /*Node numerical routines {{{1*/
     64                /*Node numerical routines {{{*/
    6565                void   Configure(DataSet* nodes,Vertices* vertices);
    6666                void   CreateNodalConstraints(Vector* ys);
     
    102102               
    103103                /*}}}*/
    104                 /*Dof Object routines {{{1*/
     104                /*Dof Object routines {{{*/
    105105                void  DistributeDofs(int* pdofcount,int setenum);
    106106                void  OffsetDofs(int dofcount,int setenum);
  • issm/trunk/src/c/objects/Numerics/ElementMatrix.cpp

    r11995 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2020
    2121/*ElementMatrix constructors and destructor*/
    22 /*FUNCTION ElementMatrix::ElementMatrix(){{{1*/
     22/*FUNCTION ElementMatrix::ElementMatrix(){{{*/
    2323ElementMatrix::ElementMatrix(){
    2424
     
    4444}
    4545/*}}}*/
    46 /*FUNCTION ElementMatrix::ElementMatrix(ElementMatrix* Ke){{{1*/
     46/*FUNCTION ElementMatrix::ElementMatrix(ElementMatrix* Ke){{{*/
    4747ElementMatrix::ElementMatrix(ElementMatrix* Ke){
    4848
    49         if(!Ke) _error_("Input Element Matrix is a NULL pointer");
     49        if(!Ke) _error2_("Input Element Matrix is a NULL pointer");
    5050        this->Init(Ke);
    5151        return;
    5252}
    5353/*}}}*/
    54 /*FUNCTION ElementMatrix::ElementMatrix(ElementMatrix* Ke1, ElementMatrix* Ke2){{{1*/
     54/*FUNCTION ElementMatrix::ElementMatrix(ElementMatrix* Ke1, ElementMatrix* Ke2){{{*/
    5555ElementMatrix::ElementMatrix(ElementMatrix* Ke1, ElementMatrix* Ke2){
    5656
     
    6363        /*If one of the two matrix is NULL, we copy the other one*/
    6464        if(!Ke1 && !Ke2){
    65                 _error_("Two input element matrices are NULL");
     65                _error2_("Two input element matrices are NULL");
    6666        }
    6767        else if(!Ke1){
     
    7575
    7676        /*General Case: Ke1 and Ke2 are not empty*/
    77         if(!Ke1->dofsymmetrical || !Ke2->dofsymmetrical) _error_("merging 2 non dofsymmetrical matrices not implemented yet");
     77        if(!Ke1->dofsymmetrical || !Ke2->dofsymmetrical) _error2_("merging 2 non dofsymmetrical matrices not implemented yet");
    7878
    7979        /*Initialize itransformation matrix Ke[P[i]] = Ke2[i]*/
    80         P=(int*)xmalloc(Ke2->nrows*sizeof(int));
     80        P=xNew<int>(Ke2->nrows);
    8181
    8282        /*1: Get the new numbering of Ke2 and get size of the new matrix*/
     
    100100
    101101        /*Gset and values*/
    102         this->gglobaldoflist=(int*)xmalloc(this->nrows*sizeof(int));
    103         this->values=(double*)xcalloc(this->nrows*this->ncols,sizeof(double));
     102        this->gglobaldoflist=xNew<int>(this->nrows);
     103        this->values=xNewZeroInit<IssmDouble>(this->nrows*this->ncols);
    104104        for(i=0;i<Ke1->nrows;i++){
    105105                for(j=0;j<Ke1->ncols;j++){
     
    122122        this->row_fsize=fsize;
    123123        if(fsize){
    124                 this->row_flocaldoflist =(int*)xmalloc(fsize*sizeof(int));
    125                 this->row_fglobaldoflist=(int*)xmalloc(fsize*sizeof(int));
     124                this->row_flocaldoflist =xNew<int>(fsize);
     125                this->row_fglobaldoflist=xNew<int>(fsize);
    126126                for(i=0;i<Ke1->row_fsize;i++){
    127127                        this->row_flocaldoflist[i] =Ke1->row_flocaldoflist[i];
     
    149149        this->row_ssize=ssize;
    150150        if(ssize){
    151                 this->row_slocaldoflist =(int*)xmalloc(ssize*sizeof(int));
    152                 this->row_sglobaldoflist=(int*)xmalloc(ssize*sizeof(int));
     151                this->row_slocaldoflist =xNew<int>(ssize);
     152                this->row_sglobaldoflist=xNew<int>(ssize);
    153153                for(i=0;i<Ke1->row_ssize;i++){
    154154                        this->row_slocaldoflist[i] =Ke1->row_slocaldoflist[i];
     
    178178
    179179        /*clean-up*/
    180         xfree((void**)&P);
    181 }
    182 /*}}}*/
    183 /*FUNCTION ElementMatrix::ElementMatrix(ElementMatrix* Ke1, ElementMatrix* Ke2,ElementMatrix* Ke3){{{1*/
     180        xDelete<int>(P);
     181}
     182/*}}}*/
     183/*FUNCTION ElementMatrix::ElementMatrix(ElementMatrix* Ke1, ElementMatrix* Ke2,ElementMatrix* Ke3){{{*/
    184184ElementMatrix::ElementMatrix(ElementMatrix* Ke1, ElementMatrix* Ke2,ElementMatrix* Ke3){
    185185
     
    196196}
    197197/*}}}*/
    198 /*FUNCTION ElementMatrix::ElementMatrix(Node** nodes,int numnodes,Parameters* parameters,int approximation){{{1*/
     198/*FUNCTION ElementMatrix::ElementMatrix(Node** nodes,int numnodes,Parameters* parameters,int approximation){{{*/
    199199ElementMatrix::ElementMatrix(Node** nodes,int numnodes,Parameters* parameters,int approximation){
    200200
     
    205205
    206206        /*fill values with 0: */
    207         this->values=(double*)xcalloc(this->nrows*this->ncols,sizeof(double));
     207        this->values=xNewZeroInit<IssmDouble>(this->nrows*this->ncols);
    208208
    209209        /*g list*/
     
    228228}
    229229/*}}}*/
    230 /*FUNCTION ElementMatrix::~ElementMatrix(){{{1*/
     230/*FUNCTION ElementMatrix::~ElementMatrix(){{{*/
    231231ElementMatrix::~ElementMatrix(){
    232232       
    233         xfree((void**)&this->values);
    234         xfree((void**)&this->gglobaldoflist);
    235         xfree((void**)&this->row_flocaldoflist);
    236         xfree((void**)&this->row_fglobaldoflist);
    237         xfree((void**)&this->row_slocaldoflist);
    238         xfree((void**)&this->row_sglobaldoflist);
    239         xfree((void**)&this->col_flocaldoflist);
    240         xfree((void**)&this->col_fglobaldoflist);
    241         xfree((void**)&this->col_slocaldoflist);
    242         xfree((void**)&this->col_sglobaldoflist);
     233        xDelete<IssmDouble>(this->values);
     234        xDelete<int>(this->gglobaldoflist);
     235        xDelete<int>(this->row_flocaldoflist);
     236        xDelete<int>(this->row_fglobaldoflist);
     237        xDelete<int>(this->row_slocaldoflist);
     238        xDelete<int>(this->row_sglobaldoflist);
     239        xDelete<int>(this->col_flocaldoflist);
     240        xDelete<int>(this->col_fglobaldoflist);
     241        xDelete<int>(this->col_slocaldoflist);
     242        xDelete<int>(this->col_sglobaldoflist);
    243243}
    244244/*}}}*/
    245245
    246246/*ElementMatrix specific routines: */
    247 /*FUNCTION ElementMatrix::AddToGlobal(Matrix* Kff, Matrix* Kfs){{{1*/
     247/*FUNCTION ElementMatrix::AddToGlobal(Matrix* Kff, Matrix* Kfs){{{*/
    248248void ElementMatrix::AddToGlobal(Matrix* Kff, Matrix* Kfs){
    249249
    250250        int i,j;
    251         double* localvalues=NULL;
     251        IssmDouble* localvalues=NULL;
    252252
    253253        /*If Kfs is not provided, call the other function*/
     
    265265                if(this->row_fsize){
    266266                        /*first, retrieve values that are in the f-set from the g-set values matrix: */
    267                         localvalues=(double*)xmalloc(this->row_fsize*this->row_fsize*sizeof(double));
     267                        localvalues=xNew<IssmDouble>(this->row_fsize*this->row_fsize);
    268268                        for(i=0;i<this->row_fsize;i++){
    269269                                for(j=0;j<this->row_fsize;j++){
     
    275275
    276276                        /*Free ressources:*/
    277                         xfree((void**)&localvalues);
     277                        xDelete<IssmDouble>(localvalues);
    278278                }
    279279
     
    281281                if((this->row_ssize!=0) && (this->row_fsize!=0)){
    282282                        /*first, retrieve values that are in the f and s-set from the g-set values matrix: */
    283                         localvalues=(double*)xmalloc(this->row_fsize*this->row_ssize*sizeof(double));
     283                        localvalues=xNew<IssmDouble>(this->row_fsize*this->row_ssize);
    284284                        for(i=0;i<this->row_fsize;i++){
    285285                                for(j=0;j<this->row_ssize;j++){
     
    291291
    292292                        /*Free ressources:*/
    293                         xfree((void**)&localvalues);
    294                 }
    295         }
    296         else{
    297                 _error_(" non dofsymmetrical matrix AddToGlobal routine not support yet!");
    298         }
    299 
    300 }
    301 /*}}}*/
    302 /*FUNCTION ElementMatrix::AddToGlobal(Matrix* Jff){{{1*/
     293                        xDelete<IssmDouble>(localvalues);
     294                }
     295        }
     296        else{
     297                _error2_("non dofsymmetrical matrix AddToGlobal routine not support yet!");
     298        }
     299
     300}
     301/*}}}*/
     302/*FUNCTION ElementMatrix::AddToGlobal(Matrix* Jff){{{*/
    303303void ElementMatrix::AddToGlobal(Matrix* Jff){
    304304
    305305        int i,j;
    306         double* localvalues=NULL;
     306        IssmDouble* localvalues=NULL;
    307307
    308308        /*Check that Jff is not NULL*/
     
    317317                if(this->row_fsize){
    318318                        /*first, retrieve values that are in the f-set from the g-set values matrix: */
    319                         localvalues=(double*)xmalloc(this->row_fsize*this->row_fsize*sizeof(double));
     319                        localvalues=xNew<IssmDouble>(this->row_fsize*this->row_fsize);
    320320                        for(i=0;i<this->row_fsize;i++){
    321321                                for(j=0;j<this->row_fsize;j++){
     
    327327
    328328                        /*Free ressources:*/
    329                         xfree((void**)&localvalues);
    330                 }
    331 
    332         }
    333         else{
    334                 _error_(" non dofsymmetrical matrix AddToGlobal routine not support yet!");
    335         }
    336 
    337 }
    338 /*}}}*/
    339 /*FUNCTION ElementMatrix::CheckConsistency{{{1*/
     329                        xDelete<IssmDouble>(localvalues);
     330                }
     331
     332        }
     333        else{
     334                _error2_("non dofsymmetrical matrix AddToGlobal routine not support yet!");
     335        }
     336
     337}
     338/*}}}*/
     339/*FUNCTION ElementMatrix::CheckConsistency{{{*/
    340340void ElementMatrix::CheckConsistency(void){
    341341        /*Check element matrix values, only in debugging mode*/
     
    343343        for (int i=0;i<this->nrows;i++){
    344344                for(int j=0;j<this->ncols;j++){
    345                         if (isnan(this->values[i*this->ncols+j])) _error_("NaN found in Element Matrix");
    346                         if (fabs(this->values[i*this->ncols+j])>1.e+50) _error_("Element Matrix values exceeds 1.e+50");
     345                        if (xIsNan<IssmDouble>(this->values[i*this->ncols+j])) _error2_("NaN found in Element Matrix");
     346                        if (fabs(this->values[i*this->ncols+j])>1.e+50) _error2_("Element Matrix values exceeds 1.e+50");
    347347                }
    348348        }
     
    350350}
    351351/*}}}*/
    352 /*FUNCTION ElementMatrix::Transpose{{{1*/
     352/*FUNCTION ElementMatrix::Transpose{{{*/
    353353void ElementMatrix::Transpose(void){
    354354
     
    365365        /*Transpose indices*/
    366366        if(!dofsymmetrical){
    367                 _error_("not supported yet");
     367                _error2_("not supported yet");
    368368        }
    369369
     
    373373}
    374374/*}}}*/
    375 /*FUNCTION ElementMatrix::Echo{{{1*/
     375/*FUNCTION ElementMatrix::Echo{{{*/
    376376void ElementMatrix::Echo(void){
    377377
    378378        int i,j;
    379         printf("Element Matrix echo: \n");
    380         printf("   nrows: %i\n",nrows);
    381         printf("   ncols: %i\n",ncols);
    382         printf("   dofsymmetrical: %s\n",dofsymmetrical?"true":"false");
    383 
    384         printf("   values: \n");
     379        _printLine_("Element Matrix echo:");
     380        _printLine_("   nrows: " << nrows);
     381        _printLine_("   ncols: " << nrows);
     382        _printLine_("   dofsymmetrical: " << (dofsymmetrical?"true":"false"));
     383
     384        _printLine_("   values:");
    385385        for(i=0;i<nrows;i++){
    386                 printf("      %i: ",i);
    387                 for(j=0;j<ncols;j++) printf("%10g ",*(values+ncols*i+j));
    388                 printf("\n");
    389         }
    390 
    391         printf("   gglobaldoflist (%p): ",gglobaldoflist);
    392         if(gglobaldoflist) for(i=0;i<nrows;i++)printf("%i ",gglobaldoflist[i]); printf("\n");
    393 
    394         printf("   row_fsize: %i\n",row_fsize);
    395         printf("   row_flocaldoflist (%p): ",row_flocaldoflist);
    396         if(row_flocaldoflist) for(i=0;i<row_fsize;i++)printf("%i ",row_flocaldoflist[i]); printf("\n");
    397         printf("   row_fglobaldoflist (%p): ",row_fglobaldoflist);
    398         if(row_fglobaldoflist)for(i=0;i<row_fsize;i++)printf("%i ",row_fglobaldoflist[i]); printf("\n");
    399 
    400         printf("   row_ssize: %i\n",row_ssize);
    401         printf("   row_slocaldoflist (%p): ",row_slocaldoflist);
    402         if(row_slocaldoflist)for(i=0;i<row_ssize;i++)printf("%i ",row_slocaldoflist[i]); printf("\n");
    403         printf("   row_sglobaldoflist (%p): ",row_sglobaldoflist);
    404         if(row_sglobaldoflist)for(i=0;i<row_ssize;i++)printf("%i ",row_sglobaldoflist[i]); printf("\n");
     386                _printString_(setw(4) << right << i << ": ");
     387                for(j=0;j<ncols;j++) _printString_( " " << setw(11) << setprecision (5) << right << values[i*ncols+j]);
     388                _printLine_("");
     389        }
     390
     391        _printString_("   gglobaldoflist (" << gglobaldoflist << "): ");
     392        if(gglobaldoflist) for(i=0;i<nrows;i++) _printString_(" " << gglobaldoflist[i]); _printLine_("");
     393
     394        _printLine_("   row_fsize: " << row_fsize);
     395        _printString_("   row_flocaldoflist  (" << row_flocaldoflist << "): ");
     396        if(row_flocaldoflist) for(i=0;i<row_fsize;i++) _printString_(" " << row_flocaldoflist[i]); _printLine_(" ");
     397        _printString_("   row_fglobaldoflist  (" << row_fglobaldoflist << "): ");
     398        if(row_fglobaldoflist) for(i=0;i<row_fsize;i++) _printString_(" " << row_fglobaldoflist[i]); _printLine_(" ");
     399
     400        _printLine_("   row_ssize: " << row_ssize);
     401        _printString_("   row_slocaldoflist  (" << row_slocaldoflist << "): ");
     402        if(row_slocaldoflist) for(i=0;i<row_ssize;i++) _printString_(" " << row_slocaldoflist[i]); _printLine_(" ");
     403        _printString_("   row_sglobaldoflist  (" << row_sglobaldoflist << "): ");
     404        if(row_sglobaldoflist) for(i=0;i<row_ssize;i++) _printString_(" " << row_sglobaldoflist[i]); _printLine_(" ");
    405405
    406406        if(!dofsymmetrical){
    407                 printf("   col_fsize: %i\n",col_fsize);
    408                 printf("   col_flocaldoflist (%p): ",col_flocaldoflist);
    409                 if(col_flocaldoflist)for(i=0;i<col_fsize;i++)printf("%i ",col_flocaldoflist[i]); printf("\n");
    410                 printf("   col_fglobaldoflist (%p): ",col_fglobaldoflist);
    411                 if(col_fglobaldoflist)for(i=0;i<col_fsize;i++)printf("%i ",col_fglobaldoflist[i]); printf("\n");
    412 
    413                 printf("   col_ssize: %i\n",col_ssize);
    414                 printf("   col_slocaldoflist (%p): ",col_slocaldoflist);
    415                 if(col_slocaldoflist)for(i=0;i<col_ssize;i++)printf("%i ",col_slocaldoflist[i]); printf("\n");
    416                 printf("   col_sglobaldoflist (%p): ",col_sglobaldoflist);
    417                 if(col_sglobaldoflist)for(i=0;i<col_ssize;i++)printf("%i ",col_sglobaldoflist[i]); printf("\n");
    418         }
    419 }
    420 /*}}}*/
    421 /*FUNCTION ElementMatrix::Init{{{1*/
     407                _printLine_("   col_fsize: " << col_fsize);
     408                _printString_("   col_flocaldoflist  (" << col_flocaldoflist << "): ");
     409                if(col_flocaldoflist) for(i=0;i<col_fsize;i++) _printString_(" " << col_flocaldoflist[i]); _printLine_(" ");
     410                _printString_("   col_fglobaldoflist  (" << col_fglobaldoflist << "): ");
     411                if(col_fglobaldoflist) for(i=0;i<col_fsize;i++) _printString_(" " << col_fglobaldoflist[i]); _printLine_(" ");
     412
     413                _printLine_("   col_ssize: " << col_ssize);
     414                _printString_("   col_slocaldoflist  (" << col_slocaldoflist << "): ");
     415                if(col_slocaldoflist) for(i=0;i<col_ssize;i++) _printString_(" " << col_slocaldoflist[i]); _printLine_(" ");
     416                _printString_("   col_sglobaldoflist  (" << col_sglobaldoflist << "): ");
     417                if(col_sglobaldoflist) for(i=0;i<col_ssize;i++) _printString_(" " << col_sglobaldoflist[i]); _printLine_(" ");
     418        }
     419}
     420/*}}}*/
     421/*FUNCTION ElementMatrix::Init{{{*/
    422422void ElementMatrix::Init(ElementMatrix* Ke){
    423423
     
    428428        this->dofsymmetrical=Ke->dofsymmetrical;
    429429
    430         this->values=(double*)xmalloc(this->nrows*this->ncols*sizeof(double));
    431         memcpy(this->values,Ke->values,this->nrows*this->ncols*sizeof(double));
    432 
    433         this->gglobaldoflist=(int*)xmalloc(this->nrows*sizeof(int));
    434         memcpy(this->gglobaldoflist,Ke->gglobaldoflist,this->nrows*sizeof(int));
     430        this->values=xNew<IssmDouble>(this->nrows*this->ncols);
     431        xMemCpy<IssmDouble>(this->values,Ke->values,this->nrows*this->ncols);
     432
     433        this->gglobaldoflist=xNew<int>(this->nrows);
     434        xMemCpy<int>(this->gglobaldoflist,Ke->gglobaldoflist,this->nrows);
    435435
    436436        this->row_fsize=Ke->row_fsize;
    437437        if(this->row_fsize){
    438                 this->row_flocaldoflist=(int*)xmalloc(this->row_fsize*sizeof(int));
    439                 memcpy(this->row_flocaldoflist,Ke->row_flocaldoflist,this->row_fsize*sizeof(int));
    440                 this->row_fglobaldoflist=(int*)xmalloc(this->row_fsize*sizeof(int));
    441                 memcpy(this->row_fglobaldoflist,Ke->row_fglobaldoflist,this->row_fsize*sizeof(int));
     438                this->row_flocaldoflist=xNew<int>(this->row_fsize);
     439                xMemCpy<int>(this->row_flocaldoflist,Ke->row_flocaldoflist,this->row_fsize);
     440                this->row_fglobaldoflist=xNew<int>(this->row_fsize);
     441                xMemCpy<int>(this->row_fglobaldoflist,Ke->row_fglobaldoflist,this->row_fsize);
    442442        }
    443443        else{
     
    448448        this->row_ssize=Ke->row_ssize;
    449449        if(this->row_ssize){
    450                 this->row_slocaldoflist=(int*)xmalloc(this->row_ssize*sizeof(int));
    451                 memcpy(this->row_slocaldoflist,Ke->row_slocaldoflist,this->row_ssize*sizeof(int));
    452                 this->row_sglobaldoflist=(int*)xmalloc(this->row_ssize*sizeof(int));
    453                 memcpy(this->row_sglobaldoflist,Ke->row_sglobaldoflist,this->row_ssize*sizeof(int));
     450                this->row_slocaldoflist=xNew<int>(this->row_ssize);
     451                xMemCpy<int>(this->row_slocaldoflist,Ke->row_slocaldoflist,this->row_ssize);
     452                this->row_sglobaldoflist=xNew<int>(this->row_ssize);
     453                xMemCpy<int>(this->row_sglobaldoflist,Ke->row_sglobaldoflist,this->row_ssize);
    454454        }
    455455        else{
     
    460460        this->col_fsize=Ke->col_fsize;
    461461        if(this->col_fsize){
    462                 this->col_flocaldoflist=(int*)xmalloc(this->col_fsize*sizeof(int));
    463                 memcpy(this->col_flocaldoflist,Ke->col_flocaldoflist,this->col_fsize*sizeof(int));
    464                 this->col_fglobaldoflist=(int*)xmalloc(this->col_fsize*sizeof(int));
    465                 memcpy(this->col_fglobaldoflist,Ke->col_fglobaldoflist,this->col_fsize*sizeof(int));
     462                this->col_flocaldoflist=xNew<int>(this->col_fsize);
     463                xMemCpy<int>(this->col_flocaldoflist,Ke->col_flocaldoflist,this->col_fsize);
     464                this->col_fglobaldoflist=xNew<int>(this->col_fsize);
     465                xMemCpy<int>(this->col_fglobaldoflist,Ke->col_fglobaldoflist,this->col_fsize);
    466466        }
    467467        else{
     
    472472        this->col_ssize=Ke->col_ssize;
    473473        if(this->col_ssize){
    474                 this->col_slocaldoflist=(int*)xmalloc(this->col_ssize*sizeof(int));
    475                 memcpy(this->col_slocaldoflist,Ke->col_slocaldoflist,this->col_ssize*sizeof(int));
    476                 this->col_sglobaldoflist=(int*)xmalloc(this->col_ssize*sizeof(int));
    477                 memcpy(this->col_sglobaldoflist,Ke->col_sglobaldoflist,this->col_ssize*sizeof(int));
     474                this->col_slocaldoflist=xNew<int>(this->col_ssize);
     475                xMemCpy<int>(this->col_slocaldoflist,Ke->col_slocaldoflist,this->col_ssize);
     476                this->col_sglobaldoflist=xNew<int>(this->col_ssize);
     477                xMemCpy<int>(this->col_sglobaldoflist,Ke->col_sglobaldoflist,this->col_ssize);
    478478        }
    479479        else{
     
    483483}
    484484/*}}}*/
    485 /*FUNCTION ElementMatrix::SetDiag{{{1*/
    486 void ElementMatrix::SetDiag(double scalar){
     485/*FUNCTION ElementMatrix::SetDiag{{{*/
     486void ElementMatrix::SetDiag(IssmDouble scalar){
    487487
    488488        int i;
    489489
    490         if(this->nrows!=this->ncols)_error_("need square matrix in input!");
     490        if(this->nrows!=this->ncols)_error2_("need square matrix in input!");
    491491
    492492        for(i=0;i<this->nrows;i++){
  • issm/trunk/src/c/objects/Numerics/ElementMatrix.h

    r11995 r12706  
    1010
    1111/*Headers:*/
    12 /*{{{1*/
     12/*{{{*/
    1313#include "../Object.h"
    1414#include "../../toolkits/toolkits.h"
     
    2424                int      ncols;
    2525                bool     dofsymmetrical;
    26                 double*  values;
     26                IssmDouble*  values;
    2727
    2828                //gset
     
    4949                int*     col_sglobaldoflist;
    5050
    51                 /*ElementMatrix constructors, destructors {{{1*/
     51                /*ElementMatrix constructors, destructors {{{*/
    5252                ElementMatrix();
    5353                ElementMatrix(ElementMatrix* Ke);
     
    5757                ~ElementMatrix();
    5858                /*}}}*/
    59                 /*ElementMatrix specific routines {{{1*/
     59                /*ElementMatrix specific routines {{{*/
    6060                void AddToGlobal(Matrix* Kff, Matrix* Kfs);
    6161                void AddToGlobal(Matrix* Jff);
     
    6464                void Transpose(void);
    6565                void Init(ElementMatrix* Ke);
    66                 void SetDiag(double scalar);
     66                void SetDiag(IssmDouble scalar);
    6767                /*}}}*/
    6868};
  • issm/trunk/src/c/objects/Numerics/ElementVector.cpp

    r12330 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2020
    2121/*ElementVector constructors and destructor*/
    22 /*FUNCTION ElementVector::ElementVector(){{{1*/
     22/*FUNCTION ElementVector::ElementVector(){{{*/
    2323ElementVector::ElementVector(){
    2424
     
    3131}
    3232/*}}}*/
    33 /*FUNCTION ElementVector::ElementVector(ElementVector* pe1, ElementVector* pe2){{{1*/
     33/*FUNCTION ElementVector::ElementVector(ElementVector* pe1, ElementVector* pe2){{{*/
    3434ElementVector::ElementVector(ElementVector* pe1, ElementVector* pe2){
    3535
     
    4242        /*If one of the two matrix is NULL, we copy the other one*/
    4343        if(!pe1 && !pe2){
    44                 _error_("Two input element matrices are NULL");
     44                _error2_("Two input element matrices are NULL");
    4545        }
    4646        else if(!pe1){
     
    5454
    5555        /*Initialize itransformation matrix pe[P[i]] = pe2[i]*/
    56         P=(int*)xmalloc(pe2->nrows*sizeof(int));
     56        P=xNew<int>(pe2->nrows);
    5757
    5858        /*1: Get the new numbering of pe2 and get size of the new matrix*/
     
    7474
    7575        /*Gset and values*/
    76         this->gglobaldoflist=(int*)xmalloc(this->nrows*sizeof(int));
    77         this->values=(double*)xcalloc(this->nrows,sizeof(double));
     76        this->gglobaldoflist=xNew<int>(this->nrows);
     77        this->values=xNewZeroInit<IssmDouble>(this->nrows);
    7878        for(i=0;i<pe1->nrows;i++){
    7979                this->values[i] += pe1->values[i];
     
    9292        this->fsize=fsize;
    9393        if(fsize){
    94                 this->flocaldoflist =(int*)xmalloc(fsize*sizeof(int));
    95                 this->fglobaldoflist=(int*)xmalloc(fsize*sizeof(int));
     94                this->flocaldoflist =xNew<int>(fsize);
     95                this->fglobaldoflist=xNew<int>(fsize);
    9696                for(i=0;i<pe1->fsize;i++){
    9797                        this->flocaldoflist[i] =pe1->flocaldoflist[i];
     
    113113
    114114        /*clean-up*/
    115         xfree((void**)&P);
    116 }
    117 /*}}}*/
    118 /*FUNCTION ElementVector::ElementVector(ElementVector* pe1, ElementVector* pe2,ElementVector* pe3){{{1*/
     115        xDelete<int>(P);
     116}
     117/*}}}*/
     118/*FUNCTION ElementVector::ElementVector(ElementVector* pe1, ElementVector* pe2,ElementVector* pe3){{{*/
    119119ElementVector::ElementVector(ElementVector* pe1, ElementVector* pe2,ElementVector* pe3){
    120120
     
    131131}
    132132/*}}}*/
    133 /*FUNCTION ElementVector::ElementVector(Node** nodes,int numnodes,Parameters* parameters,int approximation){{{1*/
     133/*FUNCTION ElementVector::ElementVector(Node** nodes,int numnodes,Parameters* parameters,int approximation){{{*/
    134134ElementVector::ElementVector(Node** nodes,int numnodes,Parameters* parameters,int approximation){
    135135
     
    138138
    139139        /*fill values with 0: */
    140         this->values=(double*)xcalloc(this->nrows,sizeof(double));
     140        this->values=xNewZeroInit<IssmDouble>(this->nrows);
    141141       
    142142        /*g list*/
     
    149149}
    150150/*}}}*/
    151 /*FUNCTION ElementVector::~ElementVector(){{{1*/
     151/*FUNCTION ElementVector::~ElementVector(){{{*/
    152152ElementVector::~ElementVector(){
    153153       
    154         xfree((void**)&this->values);
    155         xfree((void**)&this->gglobaldoflist);
    156         xfree((void**)&this->flocaldoflist);
    157         xfree((void**)&this->fglobaldoflist);
     154        xDelete<IssmDouble>(this->values);
     155        xDelete<int>(this->gglobaldoflist);
     156        xDelete<int>(this->flocaldoflist);
     157        xDelete<int>(this->fglobaldoflist);
    158158}
    159159/*}}}*/
    160160
    161161/*ElementVector specific routines: */
    162 /*FUNCTION ElementVector::AddToGlobal(Vector* pf){{{1*/
     162/*FUNCTION ElementVector::AddToGlobal(Vector* pf){{{*/
    163163void ElementVector::AddToGlobal(Vector* pf){
    164164
    165165        int i;
    166         double* localvalues=NULL;
     166        IssmDouble* localvalues=NULL;
    167167
    168168        /*In debugging mode, check consistency (no NaN, and values not too big)*/
     
    171171        if(this->fsize){
    172172                /*first, retrieve values that are in the f-set from the g-set values vector: */
    173                 localvalues=(double*)xmalloc(this->fsize*sizeof(double));
     173                localvalues=xNew<IssmDouble>(this->fsize);
    174174                for(i=0;i<this->fsize;i++){
    175175                        localvalues[i]=this->values[this->flocaldoflist[i]];
     
    179179
    180180                /*Free ressources:*/
    181                 xfree((void**)&localvalues);
     181                xDelete<IssmDouble>(localvalues);
    182182        }
    183183       
    184184}
    185185/*}}}*/
    186 /*FUNCTION ElementVector::InsertIntoGlobal(Vector* pf){{{1*/
     186/*FUNCTION ElementVector::InsertIntoGlobal(Vector* pf){{{*/
    187187void ElementVector::InsertIntoGlobal(Vector* pf){
    188188
    189189        int i;
    190         double* localvalues=NULL;
     190        IssmDouble* localvalues=NULL;
    191191
    192192        if(this->fsize){
    193193                /*first, retrieve values that are in the f-set from the g-set values vector: */
    194                 localvalues=(double*)xmalloc(this->fsize*sizeof(double));
     194                localvalues=xNew<IssmDouble>(this->fsize);
    195195                for(i=0;i<this->fsize;i++){
    196196                        localvalues[i]=this->values[this->flocaldoflist[i]];
     
    200200
    201201                /*Free ressources:*/
    202                 xfree((void**)&localvalues);
    203         }
    204 
    205 }
    206 /*}}}*/
    207 /*FUNCTION ElementVector::CheckConsistency{{{1*/
     202                xDelete<IssmDouble>(localvalues);
     203        }
     204
     205}
     206/*}}}*/
     207/*FUNCTION ElementVector::CheckConsistency{{{*/
    208208void ElementVector::CheckConsistency(void){
    209209        /*Check element matrix values, only in debugging mode*/
    210210#ifdef _ISSM_DEBUG_
    211211        for (int i=0;i<this->nrows;i++){
    212                 if (isnan(this->values[i])) _error_("NaN found in Element Vector");
    213                 if (fabs( this->values[i])>1.e+50) _error_("Element Vector values exceeds 1.e+50");
     212                if (xIsNan<IssmDouble>(this->values[i])) _error2_("NaN found in Element Vector");
     213                if (fabs( this->values[i])>1.e+50) _error2_("Element Vector values exceeds 1.e+50");
    214214        }
    215215#endif
    216216}
    217217/*}}}*/
    218 /*FUNCTION ElementVector::Echo{{{1*/
     218/*FUNCTION ElementVector::Echo{{{*/
    219219void ElementVector::Echo(void){
    220220
    221221        int i,j;
    222         printf("Element Vector echo: \n");
    223         printf("   nrows: %i\n",nrows);
    224 
    225         printf("   values: \n");
     222        _printLine_("Element Vector echo:");
     223        _printLine_("   nrows: " << nrows);
     224        _printLine_("   values:");
    226225        for(i=0;i<nrows;i++){
    227                 printf("      %i: %10g\n",i,values[i]);
    228         }
    229 
    230         printf("   gglobaldoflist (%p): ",gglobaldoflist);
    231         if(gglobaldoflist) for(i=0;i<nrows;i++)printf("%i ",gglobaldoflist[i]); printf("\n");
    232 
    233         printf("   fsize: %i\n",fsize);
    234         printf("   flocaldoflist (%p): ",flocaldoflist);
    235         if(flocaldoflist) for(i=0;i<fsize;i++)printf("%i ",flocaldoflist[i]); printf("\n");
    236         printf("   fglobaldoflist (%p): ",fglobaldoflist);
    237         if(fglobaldoflist)for(i=0;i<fsize;i++)printf("%i ",fglobaldoflist[i]); printf("\n");
    238 }
    239 /*}}}*/
    240 /*FUNCTION ElementVector::Init{{{1*/
     226                _printLine_(setw(4) << right << i << ": " << setw(10) << values[i]);
     227        }
     228
     229        _printString_("   gglobaldoflist (" << gglobaldoflist << "): ");
     230        if(gglobaldoflist) for(i=0;i<nrows;i++) _printString_(" " << gglobaldoflist[i] );
     231        _printLine_(" ");
     232
     233        _printLine_("   fsize: " << fsize);
     234        _printString_("   flocaldoflist  (" << flocaldoflist << "): ");
     235        if(flocaldoflist) for(i=0;i<fsize;i++) _printString_(" " << flocaldoflist[i] );
     236        _printLine_(" ");
     237        _printString_("   fglobaldoflist (" << fglobaldoflist << "): ");
     238        if(fglobaldoflist) for(i=0;i<fsize;i++) _printString_(" " << fglobaldoflist[i] );
     239        _printLine_(" ");
     240}
     241/*}}}*/
     242/*FUNCTION ElementVector::Init{{{*/
    241243void ElementVector::Init(ElementVector* pe){
    242244
     
    245247        this->nrows =pe->nrows;
    246248
    247         this->values=(double*)xmalloc(this->nrows*sizeof(double));
    248         memcpy(this->values,pe->values,this->nrows*sizeof(double));
    249 
    250         this->gglobaldoflist=(int*)xmalloc(this->nrows*sizeof(int));
    251         memcpy(this->gglobaldoflist,pe->gglobaldoflist,this->nrows*sizeof(int));
     249        this->values=xNew<IssmDouble>(this->nrows);
     250        xMemCpy<IssmDouble>(this->values,pe->values,this->nrows);
     251
     252        this->gglobaldoflist=xNew<int>(this->nrows);
     253        xMemCpy<int>(this->gglobaldoflist,pe->gglobaldoflist,this->nrows);
    252254
    253255        this->fsize=pe->fsize;
    254256        if(this->fsize){
    255                 this->flocaldoflist=(int*)xmalloc(this->fsize*sizeof(int));
    256                 memcpy(this->flocaldoflist,pe->flocaldoflist,this->fsize*sizeof(int));
    257                 this->fglobaldoflist=(int*)xmalloc(this->fsize*sizeof(int));
    258                 memcpy(this->fglobaldoflist,pe->fglobaldoflist,this->fsize*sizeof(int));
     257                this->flocaldoflist=xNew<int>(this->fsize);
     258                xMemCpy<int>(this->flocaldoflist,pe->flocaldoflist,this->fsize);
     259                this->fglobaldoflist=xNew<int>(this->fsize);
     260                xMemCpy<int>(this->fglobaldoflist,pe->fglobaldoflist,this->fsize);
    259261        }
    260262        else{
     
    264266}
    265267/*}}}*/
    266 /*FUNCTION ElementVector::SetValue{{{1*/
    267 void ElementVector::SetValue(double scalar){
     268/*FUNCTION ElementVector::SetValue{{{*/
     269void ElementVector::SetValue(IssmDouble scalar){
    268270
    269271        int i;
  • issm/trunk/src/c/objects/Numerics/ElementVector.h

    r12330 r12706  
    1010
    1111/*Headers:*/
    12 /*{{{1*/
     12/*{{{*/
    1313#include "../Object.h"
    1414#include "../../toolkits/toolkits.h"
     
    2222       
    2323                int      nrows;
    24                 double*  values;
     24                IssmDouble*  values;
    2525               
    2626                //gset
     
    3232                int*     fglobaldoflist;
    3333               
    34                 /*ElementVector constructors, destructors {{{1*/
     34                /*ElementVector constructors, destructors {{{*/
    3535                ElementVector();
    3636                ElementVector(ElementVector* pe1,ElementVector* pe2);
     
    3939                ~ElementVector();
    4040                /*}}}*/
    41                 /*ElementVector specific routines {{{1*/
     41                /*ElementVector specific routines {{{*/
    4242                void AddToGlobal(Vector* pf);
    4343                void InsertIntoGlobal(Vector* pf);
     
    4545                void CheckConsistency(void);
    4646                void Init(ElementVector* pe);
    47                 void SetValue(double scalar);
     47                void SetValue(IssmDouble scalar);
    4848                /*}}}*/
    4949};
  • issm/trunk/src/c/objects/Numerics/Matrix.cpp

    r12330 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2323
    2424/*Matrix constructors and destructor*/
    25 /*FUNCTION Matrix::Matrix(){{{1*/
     25/*FUNCTION Matrix::Matrix(){{{*/
    2626Matrix::Matrix(){
    2727
     
    3636}
    3737/*}}}*/
    38 /*FUNCTION Matrix::Matrix(int M,int N){{{1*/
     38/*FUNCTION Matrix::Matrix(int M,int N){{{*/
    3939Matrix::Matrix(int M,int N){
    4040
     
    4545        #endif
    4646        #ifdef _HAVE_ADOLC_
    47         this->amatrix=(adouble*)xmalloc(M*N*sizeof(adouble));
    48         #endif
    49 }
    50 /*}}}*/
    51 /*FUNCTION Matrix::Matrix(int M,int N,double sparsity){{{1*/
    52 Matrix::Matrix(int M,int N,double sparsity){
     47        this->amatrix=xNew<IssmDouble>(M*N);
     48        #endif
     49}
     50/*}}}*/
     51/*FUNCTION Matrix::Matrix(int M,int N,IssmDouble sparsity){{{*/
     52Matrix::Matrix(int M,int N,IssmDouble sparsity){
    5353
    5454        #ifdef _HAVE_PETSC_
     
    5858        #endif
    5959        #ifdef _HAVE_ADOLC_
    60         this->amatrix=(adouble*)xmalloc(M*N*sizeof(adouble));
    61         #endif
    62 }
    63 /*}}}*/
    64 /*FUNCTION Matrix::Matrix(double* serial_mat, int M,int N,double sparsity){{{1*/
    65 Matrix::Matrix(double* serial_mat, int M,int N,double sparsity){
     60        this->amatrix=xNew<IssmDouble>(M*N);
     61        #endif
     62}
     63/*}}}*/
     64/*FUNCTION Matrix::Matrix(IssmDouble* serial_mat, int M,int N,IssmDouble sparsity){{{*/
     65Matrix::Matrix(IssmDouble* serial_mat, int M,int N,IssmDouble sparsity){
    6666
    6767        #ifdef _HAVE_PETSC_
     
    6969
    7070
    71         int* idxm=(int*)xmalloc(M*sizeof(int));
    72         int* idxn=(int*)xmalloc(N*sizeof(int));
     71        int* idxm=xNew<int>(M);
     72        int* idxn=xNew<int>(N);
    7373        for(i=0;i<M;i++)idxm[i]=i;
    7474        for(i=0;i<N;i++)idxn[i]=i;
     
    7979        MatAssemblyEnd(this->matrix,MAT_FINAL_ASSEMBLY);
    8080
    81         xfree((void**)&idxm);
    82         xfree((void**)&idxn);
     81        xDelete<int>(idxm);
     82        xDelete<int>(idxn);
    8383        #else
    8484        this->matrix=new SeqMat(serial_mat,M,N,sparsity);
    8585        #endif
    8686        #ifdef _HAVE_ADOLC_
    87         this->amatrix=(adouble*)xmalloc(M*N*sizeof(adouble));
    88         #endif
    89 }
    90 /*}}}*/
    91 /*FUNCTION Matrix::Matrix(int M,int N,int connectivity,int numberofdofspernode){{{1*/
     87        this->amatrix=xNew<IssmDouble>(M*N);
     88        #endif
     89}
     90/*}}}*/
     91/*FUNCTION Matrix::Matrix(int M,int N,int connectivity,int numberofdofspernode){{{*/
    9292Matrix::Matrix(int M,int N,int connectivity,int numberofdofspernode){
    9393       
     
    9898        #endif
    9999        #ifdef _HAVE_ADOLC_
    100         this->amatrix=(adouble*)xmalloc(M*N*sizeof(adouble));
    101         #endif
    102 }
    103 /*}}}*/
    104 /*FUNCTION Matrix::~Matrix(){{{1*/
     100        this->amatrix=xNew<IssmDouble>(M*N);
     101        #endif
     102}
     103/*}}}*/
     104/*FUNCTION Matrix::~Matrix(){{{*/
    105105Matrix::~Matrix(){
    106106
     
    111111        #endif
    112112        #ifdef _HAVE_ADOLC_
    113         xfree((void**)&this->amatrix);
     113        xDelete<IssmDouble>(this->amatrix);
    114114        #endif
    115115}
     
    117117
    118118/*Matrix specific routines: */
    119 /*FUNCTION Matrix::Echo{{{1*/
     119/*FUNCTION Matrix::Echo{{{*/
    120120void Matrix::Echo(void){
    121121
     
    130130        #ifdef _HAVE_ADOLC_
    131131        /*Not sure about that one. Should we use the overloaded operator >>?*/
    132         printf("ADOLC Matrix equivalent:" );
    133         for(i=0;i<M;i++){
    134                 for(j=0;j<N;j++){
    135                         printf("%g ",*(amatrix+N*i+j));
    136                 }
    137                 printf("\n");
    138         }
    139         #endif
    140 }
    141 /*}}}*/
    142 /*FUNCTION Matrix::Assemble{{{1*/
     132        _printString_("ADOLC Matrix equivalent:" );
     133//      for(i=0;i<M;i++){
     134//              for(j=0;j<N;j++){
     135//                      _printString_(*(amatrix+N*i+j) << " ");
     136//              }
     137//              _printLine_("");
     138//      }
     139        #endif
     140}
     141/*}}}*/
     142/*FUNCTION Matrix::Assemble{{{*/
    143143void Matrix::Assemble(void){
    144144        #ifdef _HAVE_PETSC_
     
    155155}
    156156/*}}}*/
    157 /*FUNCTION Matrix::Norm{{{1*/
    158 double Matrix::Norm(NormMode norm_type){
    159        
    160         double norm=0;
     157/*FUNCTION Matrix::Norm{{{*/
     158IssmDouble Matrix::Norm(NormMode norm_type){
     159       
     160        IssmDouble norm=0;
    161161        #ifdef _HAVE_PETSC_
    162162                _assert_(this->matrix);
     
    168168}
    169169/*}}}*/
    170 /*FUNCTION Matrix::GetSize{{{1*/
     170/*FUNCTION Matrix::GetSize{{{*/
    171171void Matrix::GetSize(int* pM,int* pN){
    172172       
     
    179179}
    180180/*}}}*/
    181 /*FUNCTION Matrix::GetLocalSize{{{1*/
     181/*FUNCTION Matrix::GetLocalSize{{{*/
    182182void Matrix::GetLocalSize(int* pM,int* pN){
    183183       
     
    190190}
    191191/*}}}*/
    192 /*FUNCTION Matrix::MatMult{{{1*/
     192/*FUNCTION Matrix::MatMult{{{*/
    193193void Matrix::MatMult(Vector* X,Vector* AX){
    194194
     
    202202}
    203203/*}}}*/
    204 /*FUNCTION Matrix::Duplicate{{{1*/
     204/*FUNCTION Matrix::Duplicate{{{*/
    205205Matrix* Matrix::Duplicate(void){
    206206
     
    219219}
    220220/*}}}*/
    221 /*FUNCTION Matrix::ToSerial{{{1*/
    222 double* Matrix::ToSerial(void){
    223 
    224         double* output=NULL;
     221/*FUNCTION Matrix::ToSerial{{{*/
     222IssmDouble* Matrix::ToSerial(void){
     223
     224        IssmDouble* output=NULL;
    225225
    226226        #ifdef _HAVE_PETSC_
     
    232232}
    233233/*}}}*/
    234 /*FUNCTION Matrix::SetValues{{{1*/
    235 void Matrix::SetValues(int m,int* idxm,int n,int* idxn,double* values,InsMode mode){
     234/*FUNCTION Matrix::SetValues{{{*/
     235void Matrix::SetValues(int m,int* idxm,int n,int* idxn,IssmDouble* values,InsMode mode){
    236236
    237237        #ifdef _HAVE_PETSC_
     
    242242}
    243243/*}}}*/
    244 /*FUNCTION Matrix::Convert{{{1*/
     244/*FUNCTION Matrix::Convert{{{*/
    245245void Matrix::Convert(MatrixType type){
    246246
  • issm/trunk/src/c/objects/Numerics/Matrix.h

    r12330 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111#ifdef HAVE_CONFIG_H
    1212        #include <config.h>
     
    1616#include "../../toolkits/toolkits.h"
    1717#include "../../EnumDefinitions/EnumDefinitions.h"
    18 
    19 #ifdef _HAVE_ADOLC_
    20 #include "adolc.h"
    21 #endif
    2218
    2319class Vector;
     
    3531                #endif
    3632                #ifdef _HAVE_ADOLC_
    37                 adouble* amatrix;
     33                IssmDouble* amatrix;
    3834                #endif
    3935
    40                 /*Matrix constructors, destructors {{{1*/
     36                /*Matrix constructors, destructors {{{*/
    4137                Matrix();
    4238                Matrix(int M,int N);
    43                 Matrix(int M,int N,double sparsity);
    44                 Matrix(double* serial_mat,int M,int N,double sparsity);
     39                Matrix(int M,int N,IssmDouble sparsity);
     40                Matrix(IssmDouble* serial_mat,int M,int N,IssmDouble sparsity);
    4541                Matrix(int M,int N,int connectivity,int numberofdofspernode);
    4642                ~Matrix();
    4743                /*}}}*/
    48                 /*Matrix specific routines {{{1*/
     44                /*Matrix specific routines {{{*/
    4945                void Echo(void);
    5046                void Assemble(void);
    51                 double Norm(NormMode norm_type);
     47                IssmDouble Norm(NormMode norm_type);
    5248                void GetSize(int* pM,int* pN);
    5349                void GetLocalSize(int* pM,int* pN);
    5450                void MatMult(Vector* X,Vector* AX);
    5551                Matrix* Duplicate(void);
    56                 double* ToSerial(void);
    57                 void SetValues(int m,int* idxm,int n,int* idxn,double* values,InsMode mode);
     52                IssmDouble* ToSerial(void);
     53                void SetValues(int m,int* idxm,int n,int* idxn,IssmDouble* values,InsMode mode);
    5854                void Convert(MatrixType type);
    5955                /*}}}*/
  • issm/trunk/src/c/objects/Numerics/Vector.cpp

    r12330 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2222
    2323/*Vector constructors and destructor*/
    24 /*FUNCTION Vector::Vector(){{{1*/
     24/*FUNCTION Vector::Vector(){{{*/
    2525Vector::Vector(){
    2626
     
    3535}
    3636/*}}}*/
    37 /*FUNCTION Vector::Vector(int M,bool fromlocalsize){{{1*/
     37/*FUNCTION Vector::Vector(int M,bool fromlocalsize){{{*/
    3838Vector::Vector(int pM,bool fromlocalsize){
    3939
     
    4444        #endif
    4545        #ifdef _HAVE_ADOLC_
    46         this->avector=(adouble*)xmalloc(pM*sizeof(adouble));
    47         #endif
    48 }
    49 /*}}}*/
    50 /*FUNCTION Vector::Vector(double* serial_vec,int M){{{1*/
    51 Vector::Vector(double* serial_vec,int M){
    52 
    53         #ifdef _HAVE_PETSC_
    54                 int* idxm=(int*)xmalloc(M*sizeof(int));
     46        this->avector=xNew<IssmDouble>(pM);
     47        #endif
     48}
     49/*}}}*/
     50/*FUNCTION Vector::Vector(IssmDouble* serial_vec,int M){{{*/
     51Vector::Vector(IssmDouble* serial_vec,int M){
     52
     53        #ifdef _HAVE_PETSC_
     54                int* idxm=xNew<int>(M);
    5555                for(int i=0;i<M;i++) idxm[i]=i;
    5656
     
    6060                VecAssemblyEnd(this->vector);
    6161
    62                 xfree((void**)&idxm);
     62                xDelete<int>(idxm);
    6363        #else
    6464                this->vector=new SeqVec(serial_vec,M);
    6565        #endif
    6666        #ifdef _HAVE_ADOLC_
    67                 this->avector=(adouble*)xmalloc(M*sizeof(adouble));
     67                this->avector=xNew<IssmDouble>(M);
    6868        #endif
    6969}
    7070/*}}}*/
    7171#ifdef _HAVE_PETSC_
    72 /*FUNCTION Vector::Vector(Vec petsc_vec){{{1*/
     72/*FUNCTION Vector::Vector(Vec petsc_vec){{{*/
    7373Vector::Vector(Vec petsc_vec){
    7474
     
    8686#endif
    8787#if defined(_HAVE_GSL_) && !defined(_HAVE_PETSC_)
    88 /*FUNCTION Vector::Vector(SeqVec* seq_vec){{{1*/
     88/*FUNCTION Vector::Vector(SeqVec* seq_vec){{{*/
    8989Vector::Vector(SeqVec*  seq_vec){
    9090
     
    100100#endif
    101101
    102                 /*FUNCTION Vector::~Vector(){{{1*/
     102                /*FUNCTION Vector::~Vector(){{{*/
    103103Vector::~Vector(){
    104104
     
    109109        #endif
    110110        #ifdef _HAVE_ADOLC_
    111         xfree((void**)&this->avector);
     111        xDelete<IssmDouble>(this->avector);
    112112        #endif
    113113}
     
    115115
    116116/*Vector specific routines: */
    117 /*FUNCTION Vector::Echo{{{1*/
     117/*FUNCTION Vector::Echo{{{*/
    118118void Vector::Echo(void){
    119119
     
    132132}
    133133/*}}}*/
    134 /*FUNCTION Vector::Assemble{{{1*/
     134/*FUNCTION Vector::Assemble{{{*/
    135135void Vector::Assemble(void){
    136136               
     
    145145}
    146146/*}}}*/
    147 /*FUNCTION Vector::SetValues{{{1*/
    148 void Vector::SetValues(int ssize, int* list, double* values, InsMode mode){
     147/*FUNCTION Vector::SetValues{{{*/
     148void Vector::SetValues(int ssize, int* list, IssmDouble* values, InsMode mode){
    149149               
    150150               
     
    158158}
    159159/*}}}*/
    160 /*FUNCTION Vector::SetValue{{{1*/
    161 void Vector::SetValue(int dof, double value, InsMode mode){
     160/*FUNCTION Vector::SetValue{{{*/
     161void Vector::SetValue(int dof, IssmDouble value, InsMode mode){
    162162               
    163163        #ifdef _HAVE_PETSC_
     
    170170}
    171171/*}}}*/
    172 /*FUNCTION Vector::GetValue{{{1*/
    173 void Vector::GetValue(double* pvalue,int dof){
     172/*FUNCTION Vector::GetValue{{{*/
     173void Vector::GetValue(IssmDouble* pvalue,int dof){
    174174               
    175175        #ifdef _HAVE_PETSC_
     
    181181}
    182182/*}}}*/
    183 /*FUNCTION Vector::GetSize{{{1*/
     183/*FUNCTION Vector::GetSize{{{*/
    184184void Vector::GetSize(int* pM){
    185185               
     
    193193}
    194194/*}}}*/
    195 /*FUNCTION Vector::IsEmpty{{{1*/
     195/*FUNCTION Vector::IsEmpty{{{*/
    196196bool Vector::IsEmpty(void){
    197197
     
    207207}
    208208/*}}}*/
    209 /*FUNCTION Vector::GetLocalSize{{{1*/
     209/*FUNCTION Vector::GetLocalSize{{{*/
    210210void Vector::GetLocalSize(int* pM){
    211211               
     
    219219}
    220220/*}}}*/
    221 /*FUNCTION Vector::Duplicate{{{1*/
     221/*FUNCTION Vector::Duplicate{{{*/
    222222Vector* Vector::Duplicate(void){
    223223       
     
    237237}
    238238/*}}}*/
    239 /*FUNCTION Vector::Set{{{1*/
    240 void Vector::Set(double value){
     239/*FUNCTION Vector::Set{{{*/
     240void Vector::Set(IssmDouble value){
    241241       
    242242        #ifdef _HAVE_PETSC_
     
    249249}
    250250/*}}}*/
    251 /*FUNCTION Vector::AXPY{{{1*/
    252 void Vector::AXPY(Vector* X, double a){
     251/*FUNCTION Vector::AXPY{{{*/
     252void Vector::AXPY(Vector* X, IssmDouble a){
    253253       
    254254        #ifdef _HAVE_PETSC_
     
    260260}
    261261/*}}}*/
    262 /*FUNCTION Vector::AYPX{{{1*/
    263 void Vector::AYPX(Vector* X, double a){
     262/*FUNCTION Vector::AYPX{{{*/
     263void Vector::AYPX(Vector* X, IssmDouble a){
    264264       
    265265        #ifdef _HAVE_PETSC_
     
    272272}
    273273/*}}}*/
    274 /*FUNCTION Vector::ToMPISerial{{{1*/
    275 double* Vector::ToMPISerial(void){
    276 
    277         double* vec_serial=NULL;
     274/*FUNCTION Vector::ToMPISerial{{{*/
     275IssmDouble* Vector::ToMPISerial(void){
     276
     277        IssmDouble* vec_serial=NULL;
    278278
    279279        #ifdef _HAVE_PETSC_
     
    287287}
    288288/*}}}*/
    289 /*FUNCTION Vector::Copy{{{1*/
     289/*FUNCTION Vector::Copy{{{*/
    290290void Vector::Copy(Vector* to){
    291291
     
    298298}
    299299/*}}}*/
    300 /*FUNCTION Vector::Norm{{{1*/
    301 double Vector::Norm(NormMode norm_type){
    302        
    303         double norm=0;
     300/*FUNCTION Vector::Norm{{{*/
     301IssmDouble Vector::Norm(NormMode norm_type){
     302       
     303        IssmDouble norm=0;
    304304        #ifdef _HAVE_PETSC_
    305305                _assert_(this->vector);
     
    311311}
    312312/*}}}*/
    313 /*FUNCTION Vector::Scale{{{1*/
    314 void Vector::Scale(double scale_factor){
     313/*FUNCTION Vector::Scale{{{*/
     314void Vector::Scale(IssmDouble scale_factor){
    315315       
    316316        #ifdef _HAVE_PETSC_
     
    322322}
    323323/*}}}*/
    324 /*FUNCTION Vector::Dot{{{1*/
    325 double Vector::Dot(Vector* vector){
    326 
    327         double dot;
     324/*FUNCTION Vector::Dot{{{*/
     325IssmDouble Vector::Dot(Vector* vector){
     326
     327        IssmDouble dot;
    328328        #ifdef _HAVE_PETSC_
    329329                _assert_(this->vector);
     
    335335}
    336336/*}}}*/
    337 /*FUNCTION Vector::PointwiseDivide{{{1*/
     337/*FUNCTION Vector::PointwiseDivide{{{*/
    338338void Vector::PointwiseDivide(Vector* x,Vector* y){
    339339
  • issm/trunk/src/c/objects/Numerics/Vector.h

    r12330 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111#ifdef HAVE_CONFIG_H
    1212        #include <config.h>
     
    1717#include "../../EnumDefinitions/EnumDefinitions.h"
    1818
    19 #ifdef _HAVE_ADOLC_
    20 #include "adolc.h"
    21 #endif
    22                
    2319/*}}}*/
    2420
     
    3329                #endif
    3430                #ifdef _HAVE_ADOLC_
    35                         adouble* avector;
     31                        IssmDouble* avector;
    3632                #endif
    3733
    38                 /*Vector constructors, destructors {{{1*/
     34                /*Vector constructors, destructors {{{*/
    3935                Vector();
    4036                Vector(int M,bool fromlocalsize=false);
    41                 Vector(double* serial_vec,int pM);
     37                Vector(IssmDouble* serial_vec,int pM);
    4238                #ifdef _HAVE_PETSC_
    4339                Vector(Vec petsc_vec);
     
    4844                ~Vector();
    4945                /*}}}*/
    50                 /*Vector specific routines {{{1*/
     46                /*Vector specific routines {{{*/
    5147                void Echo(void);
    52                 void    AXPY(Vector *X, double a);
    53                 void    AYPX(Vector *X, double a);
     48                void    AXPY(Vector *X, IssmDouble a);
     49                void    AYPX(Vector *X, IssmDouble a);
    5450                void    Assemble(void);
    5551                void    Copy(Vector *to);
    56                 double  Dot(Vector *vector);
     52                IssmDouble  Dot(Vector *vector);
    5753                Vector *Duplicate(void);
    58                 void    GetValue(double *pvalue, int dof);
     54                void    GetValue(IssmDouble *pvalue, int dof);
    5955                void    GetSize(int *pM);
    6056                void    GetLocalSize(int *pM);
    6157                bool    IsEmpty(void);
    62                 double  Norm(NormMode norm_type);
     58                IssmDouble  Norm(NormMode norm_type);
    6359                void    PointwiseDivide(Vector  *x,Vector*y);
    64                 void    Scale(double scale_factor);
    65                 void    Set(double value);
    66                 void    SetValues(int ssize, int *list, double*values, InsMode mode);
    67                 void    SetValue(int dof, double value, InsMode mode);
    68                 double *ToMPISerial(void);
     60                void    Scale(IssmDouble scale_factor);
     61                void    Set(IssmDouble value);
     62                void    SetValues(int ssize, int *list, IssmDouble*values, InsMode mode);
     63                void    SetValue(int dof, IssmDouble value, InsMode mode);
     64                IssmDouble *ToMPISerial(void);
    6965                /*}}}*/
    7066};
  • issm/trunk/src/c/objects/Options/Option.cpp

    r9761 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*Constructors/destructor/copy*/
    23 /*FUNCTION Option::Option(){{{1*/
     23/*FUNCTION Option::Option(){{{*/
    2424Option::Option(){
    2525
     
    3131}
    3232/*}}}*/
    33 /*FUNCTION Option::~Option(){{{1*/
     33/*FUNCTION Option::~Option(){{{*/
    3434Option::~Option(){
    3535
    36         if(size) xfree((void**)&size);
    37         if(name) xfree((void**)&name);
     36        if(size) xDelete<int>(size);
     37        if(name) xDelete<char>(name);
    3838
    3939}
     
    4141
    4242/*Other*/
    43 /*FUNCTION Option::Echo {{{1*/
     43/*FUNCTION Option::Echo {{{*/
    4444void  Option::Echo(){
    4545
     
    4747        bool  flag=true;
    4848
    49         _printf_(flag,"          name: \"%s\"\n" ,name);
    50         _printf_(flag,"         numel: %d\n"     ,numel);
    51         _printf_(flag,"         ndims: %d\n"     ,ndims);
     49        if(flag) _pprintLine_("          name: \"" << name << "\"");
     50        if(flag) _pprintLine_("         numel: " << numel);
     51        if(flag) _pprintLine_("         ndims: " << ndims);
    5252        if(size){
    5353                StringFromSize(cstr,size,ndims);
    54                 _printf_(flag,"          size: %s\n" ,cstr);
     54                if(flag) _pprintLine_("          size: " << cstr);
    5555        }
    56         else _printf_(flag,"          size: [empty]\n" );
     56        else if(flag) _pprintLine_("          size: [empty]");
    5757}
    5858/*}}}*/
    59 /*FUNCTION Option::DeepEcho() {{{1*/
     59/*FUNCTION Option::DeepEcho() {{{*/
    6060void  Option::DeepEcho(){
    6161
     
    6767}
    6868/*}}}*/
    69 /*FUNCTION Option::DeepEcho(char* indent) {{{1*/
     69/*FUNCTION Option::DeepEcho(char* indent) {{{*/
    7070void  Option::DeepEcho(char* indent){
    7171
     
    7373        bool  flag=true;
    7474
    75         _printf_(flag,"%s          name: \"%s\"\n" ,indent,name);
    76         _printf_(flag,"%s         numel: %d\n"     ,indent,numel);
    77         _printf_(flag,"%s         ndims: %d\n"     ,indent,ndims);
     75        if(flag) _pprintLine_(indent << "          name: \"" << name << "\"");
     76        if(flag) _pprintLine_(indent << "         numel: " << numel);
     77        if(flag) _pprintLine_(indent << "         ndims: " << ndims);
    7878        if(size){
    7979                StringFromSize(cstr,size,ndims);
    80                 _printf_(flag,"%s          size: %s\n" ,indent,cstr);
     80                if(flag) _pprintLine_(indent << "          size: " << cstr);
    8181        }
    82         else _printf_(flag,"%s          size: [empty]\n" ,indent);
     82        else if(flag) _pprintLine_(indent << "          size: [empty]");
    8383}
    8484/*}}}*/
    85 /*FUNCTION Option::Name {{{1*/
     85/*FUNCTION Option::Name {{{*/
    8686char* Option::Name(){
    8787
     
    8989}
    9090/*}}}*/
    91 /*FUNCTION Option::NumEl {{{1*/
     91/*FUNCTION Option::NumEl {{{*/
    9292int   Option::NumEl(){
    9393
     
    9595}
    9696/*}}}*/
    97 /*FUNCTION Option::NDims {{{1*/
     97/*FUNCTION Option::NDims {{{*/
    9898int   Option::NDims(){
    9999
     
    101101}
    102102/*}}}*/
    103 /*FUNCTION Option::Size {{{1*/
     103/*FUNCTION Option::Size {{{*/
    104104int*  Option::Size(){
    105105
     
    107107}
    108108/*}}}*/
    109 /*FUNCTION Option::Get {{{1*/
     109/*FUNCTION Option::Get {{{*/
    110110//void* Option::Get(){
    111111
  • issm/trunk/src/c/objects/Options/Option.h

    r12330 r12706  
    66#define _OPTIONOBJECT_H_
    77
    8 /*Headers:{{{1*/
     8/*Headers:{{{*/
    99#include "../../include/include.h"
    1010#include "../../shared/Exceptions/exceptions.h"
     
    2323                int*  size;
    2424
    25                 /*Option constructors, destructors {{{1*/
     25                /*Option constructors, destructors {{{*/
    2626                Option();
    2727                ~Option();
    2828                /*}}}*/
    29                 /*Object virtual functions definitions:{{{1*/
     29                /*Object virtual functions definitions:{{{*/
    3030                virtual void  Echo();
    3131                virtual void  DeepEcho();
    3232                virtual void  DeepEcho(char* indent);
    33                 int   Id(){_error_("Not implemented yet");};
    34                 int   MyRank(){_error_("Not implemented yet");};
     33                int   Id(){_error2_("Not implemented yet");};
     34                int   MyRank(){_error2_("Not implemented yet");};
    3535                int   ObjectEnum(){return OptionEnum;};
    36                 Object* copy(){_error_("Not implemented yet");};
     36                Object* copy(){_error2_("Not implemented yet");};
    3737                /*}}}*/
    3838
     
    4343                virtual int*  Size()=0;
    4444                virtual void  Get(int* pvalue)=0;
    45                 virtual void  Get(double* pvalue)=0;
     45                virtual void  Get(IssmDouble* pvalue)=0;
    4646                virtual void  Get(bool* pvalue)=0;
    4747                virtual void  Get(char** pvalue)=0;
    4848                virtual void  Get(char*** ppvalue,int *pnumel)=0;
    49                 virtual void  Get(double** pvalue,int *pnumel)=0;
     49                virtual void  Get(IssmDouble** pvalue,int *pnumel)=0;
    5050                virtual void  Get(Options** pvalue)=0;
    5151                virtual void  Get(Options*** ppvalue,int *pnumel)=0;
  • issm/trunk/src/c/objects/Options/OptionCell.cpp

    r9761 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*Constructors/destructor/copy*/
    23 /*FUNCTION OptionCell::OptionCell(){{{1*/
     23/*FUNCTION OptionCell::OptionCell(){{{*/
    2424OptionCell::OptionCell(){
    2525
     
    2828}
    2929/*}}}*/
    30 /*FUNCTION OptionCell::~OptionCell(){{{1*/
     30/*FUNCTION OptionCell::~OptionCell(){{{*/
    3131OptionCell::~OptionCell(){
    3232
     
    4040
    4141/*Other*/
    42 /*FUNCTION OptionCell::Echo {{{1*/
     42/*FUNCTION OptionCell::Echo {{{*/
    4343void  OptionCell::Echo(){
    4444
     
    4646        bool flag     = true;
    4747
    48         _printf_(flag,"OptionCell Echo:\n");
     48        if(flag) _pprintLine_("OptionCell Echo:");
    4949        Option::Echo();
    5050
    5151        if (values && size) {
    5252                StringFromSize(cstr,size,ndims);
    53                 _printf_(flag,"        values: %s %s\n" ,cstr,"cell");
     53                if(flag) _pprintLine_("        values: " << cstr << " " << "cell");
    5454        }
    55         else _printf_(flag,"        values: [empty]\n" );
     55        else if(flag) _pprintLine_("        values: [empty]");
    5656}
    5757/*}}}*/
    58 /*FUNCTION OptionCell::DeepEcho() {{{1*/
     58/*FUNCTION OptionCell::DeepEcho() {{{*/
    5959void  OptionCell::DeepEcho(){
    6060
     
    6666}
    6767/*}}}*/
    68 /*FUNCTION OptionCell::DeepEcho(char* indent) {{{1*/
     68/*FUNCTION OptionCell::DeepEcho(char* indent) {{{*/
    6969void  OptionCell::DeepEcho(char* indent){
    7070
     
    7575        bool  flag=true;
    7676
    77         _printf_(flag,"%sOptionCell DeepEcho:\n",indent);
     77        if(flag) _pprintLine_(indent << "OptionCell DeepEcho:");
    7878        Option::DeepEcho(indent);
    7979
    80         memcpy(indent2,indent,(strlen(indent)+1)*sizeof(char));
     80        xMemCpy<char>(indent2,indent,(strlen(indent)+1));
    8181        strcat(indent2,"  ");
    8282
    8383        if (values->Size()) {
    84                 dims=(int *) xmalloc(ndims*sizeof(int));
     84                dims=xNew<int>(ndims);
    8585                for (i=0; i<values->Size(); i++) {
    8686                        ColumnWiseDimsFromIndex(dims,i,size,ndims);
    8787                        StringFromDims(cstr,dims,ndims);
    88                         _printf_(flag,"%s        values: -------- begin %s --------\n" ,indent,cstr);
     88                        if(flag) _pprintLine_(indent << "        values: -------- begin " << cstr << " --------");
    8989                        ((Option *)values->GetObjectByOffset(i))->DeepEcho(indent2);
    90                         _printf_(flag,"%s        values: --------  end  %s --------\n" ,indent,cstr);
     90                        if(flag) _pprintLine_(indent << "        values: --------  end  " << cstr << " --------");
    9191                }
    92                 xfree((void**)&dims);
     92                xDelete<int>(dims);
    9393        }
    94         else _printf_(flag,"%s        values: [empty]\n" ,indent);
     94        else if(flag) _pprintLine_(indent << "        values: [empty]");
    9595}
    9696/*}}}*/
    97 /*FUNCTION OptionCell::Name {{{1*/
     97/*FUNCTION OptionCell::Name {{{*/
    9898char* OptionCell::Name(){
    9999
     
    101101}
    102102/*}}}*/
    103 /*FUNCTION OptionCell::NumEl {{{1*/
     103/*FUNCTION OptionCell::NumEl {{{*/
    104104int   OptionCell::NumEl(){
    105105
     
    107107}
    108108/*}}}*/
    109 /*FUNCTION OptionCell::NDims {{{1*/
     109/*FUNCTION OptionCell::NDims {{{*/
    110110int   OptionCell::NDims(){
    111111
     
    113113}
    114114/*}}}*/
    115 /*FUNCTION OptionCell::Size {{{1*/
     115/*FUNCTION OptionCell::Size {{{*/
    116116int*  OptionCell::Size(){
    117117
     
    119119}
    120120/*}}}*/
    121 /*FUNCTION OptionCell::Get(Options** pvalue) {{{1*/
     121/*FUNCTION OptionCell::Get(Options** pvalue) {{{*/
    122122void OptionCell::Get(Options** pvalue){
    123123
  • issm/trunk/src/c/objects/Options/OptionCell.h

    r12330 r12706  
    66#define _OPTIONCELL_H_
    77
    8 /*Headers:{{{1*/
     8/*Headers:{{{*/
    99#include "../../include/include.h"
    1010#include "../../shared/Exceptions/exceptions.h"
     
    2020                Options* values;
    2121
    22                 /*OptionCell constructors, destructors {{{1*/
     22                /*OptionCell constructors, destructors {{{*/
    2323                OptionCell();
    2424                ~OptionCell();
    2525                /*}}}*/
    26                 /*Object virtual functions definitions:{{{1*/
     26                /*Object virtual functions definitions:{{{*/
    2727                void  Echo();
    2828                void  DeepEcho();
    2929                void  DeepEcho(char* indent);
    30                 int   Id(){_error_("Not implemented yet");};
    31                 int   MyRank(){_error_("Not implemented yet");};
     30                int   Id(){_error2_("Not implemented yet");};
     31                int   MyRank(){_error2_("Not implemented yet");};
    3232                int   ObjectEnum(){return OptionCellEnum;};
    33                 Object* copy(){_error_("Not implemented yet");};
     33                Object* copy(){_error2_("Not implemented yet");};
    3434                /*}}}*/
    3535
     
    3939                int   NDims();
    4040                int*  Size();
    41                 void  Get(int* pvalue){_error_("An OptionCell object cannot return a int");};
    42                 void  Get(double* pvalue){_error_("An OptionCell object cannot return a double");};
    43                 void  Get(bool* pvalue){  _error_("An OptionCell object cannot return a bool");};
    44                 void  Get(char** pvalue){ _error_("An OptionCell object cannot return a string");};
    45                 void  Get(char*** ppvalue,int *pnumel){ _error_("An OptionCell object cannot return a string vec");};
    46                 void  Get(double** pvalue,int *pnumel){ _error_("An OptionCell object cannot return a double vec");};
     41                void  Get(int* pvalue){_error2_("An OptionCell object cannot return a int");};
     42                void  Get(IssmDouble* pvalue){_error2_("An OptionCell object cannot return a IssmDouble");};
     43                void  Get(bool* pvalue){  _error2_("An OptionCell object cannot return a bool");};
     44                void  Get(char** pvalue){ _error2_("An OptionCell object cannot return a string");};
     45                void  Get(char*** ppvalue,int *pnumel){ _error2_("An OptionCell object cannot return a string vec");};
     46                void  Get(IssmDouble** pvalue,int *pnumel){ _error2_("An OptionCell object cannot return a IssmDouble vec");};
    4747                void  Get(Options** pvalue);
    48                 void  Get(Options*** ppvalue,int *pnumel){ _error_("An OptionCell object cannot return an Options DataSet vec");};
     48                void  Get(Options*** ppvalue,int *pnumel){ _error2_("An OptionCell object cannot return an Options DataSet vec");};
    4949
    5050};
  • issm/trunk/src/c/objects/Options/OptionChar.cpp

    r9761 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*Constructors/destructor/copy*/
    23 /*FUNCTION OptionChar::OptionChar(){{{1*/
     23/*FUNCTION OptionChar::OptionChar(){{{*/
    2424OptionChar::OptionChar(){
    2525
     
    2828}
    2929/*}}}*/
    30 /*FUNCTION OptionChar::~OptionChar(){{{1*/
     30/*FUNCTION OptionChar::~OptionChar(){{{*/
    3131OptionChar::~OptionChar(){
    3232
    33         if (values) xfree((void**)&values);
     33        if (values) xDelete<char>(values);
    3434
    3535}
     
    3737
    3838/*Other*/
    39 /*FUNCTION OptionChar::Echo {{{1*/
     39/*FUNCTION OptionChar::Echo {{{*/
    4040void  OptionChar::Echo(){
    4141
     
    4343        bool  flag=true;
    4444
    45         _printf_(flag,"OptionChar Echo:\n");
     45        if(flag) _pprintLine_("OptionChar Echo:");
    4646        Option::Echo();
    4747
     
    4949//              if (numel == 1) {
    5050                if (1) {
    51 //                      _printf_(flag,"        values: \"%s\"\n" ,values[0]);
    52                         _printf_(flag,"        values: \"%s\"\n" ,values);
     51//                      if(flag) _pprintLine_("        values: \"" << values[0] << "\"");
     52                        if(flag) _pprintLine_("        values: \"" << values << "\"");
    5353                }
    5454                else {
    5555                        StringFromSize(cstr,size,ndims);
    56                         _printf_(flag,"        values: %s %s\n" ,cstr,"char");
     56                        if(flag) _pprintLine_("        values: " << cstr << " " << "char");
    5757                }
    5858        }
    59         else _printf_(flag,"        values: [empty]\n" );
     59        else if(flag) _pprintLine_("        values: [empty]");
    6060}
    6161/*}}}*/
    62 /*FUNCTION OptionChar::DeepEcho() {{{1*/
     62/*FUNCTION OptionChar::DeepEcho() {{{*/
    6363void  OptionChar::DeepEcho(){
    6464
     
    7070}
    7171/*}}}*/
    72 /*FUNCTION OptionChar::DeepEcho(char* indent) {{{1*/
     72/*FUNCTION OptionChar::DeepEcho(char* indent) {{{*/
    7373void  OptionChar::DeepEcho(char* indent){
    7474
     
    7979        bool  flag=true;
    8080
    81         _printf_(flag,"%sOptionChar DeepEcho:\n",indent);
     81        if(flag) _pprintLine_(indent << "OptionChar DeepEcho:");
    8282        Option::DeepEcho(indent);
    8383
    84         memcpy(indent2,indent,(strlen(indent)+1)*sizeof(char));
     84        xMemCpy<char>(indent2,indent,(strlen(indent)+1));
    8585        strcat(indent2,"  ");
    8686
    8787        if (values) {
    8888                if (ndims == 2 && size[0] == 1) {
    89                         _printf_(flag,"%s        values: \"%s\"\n" ,indent,values);
     89                        if(flag) _pprintLine_(indent << "        values: \"" << values << "\"");
    9090                }
    9191                else {
     
    9393                        for (i=2; i<ndims; i++) nstr*=size[i];
    9494
    95                         dims=(int *) xmalloc(ndims*sizeof(int));
     95                        dims=xNew<int>(ndims);
    9696                        for (i=0; i<nstr; i++) {
    9797                                RowWiseDimsFromIndex(dims,ipt,size,ndims);
    9898                                StringFromDims(cstr,dims,ndims);
    99                                 _printf_(flag,"%s        values%s: \"%.*s\"\n" ,indent,cstr,size[1],&(values[ipt]));
     99                                if(flag) _pprintLine_(indent << "        values" << cstr << ": \"" << size[1] << "*s\"");
    100100                                ipt+=size[1];
    101101                        }
    102                         xfree((void**)&dims);
     102                        xDelete<int>(dims);
    103103                }
    104104        }
    105         else _printf_(flag,"%s        values: [empty]\n" ,indent);
     105        else if(flag) _pprintLine_(indent << "        values: [empty]");
    106106}
    107107/*}}}*/
    108 /*FUNCTION OptionChar::Name {{{1*/
     108/*FUNCTION OptionChar::Name {{{*/
    109109char* OptionChar::Name(){
    110110
     
    112112}
    113113/*}}}*/
    114 /*FUNCTION OptionChar::NumEl {{{1*/
     114/*FUNCTION OptionChar::NumEl {{{*/
    115115int   OptionChar::NumEl(){
    116116
     
    118118}
    119119/*}}}*/
    120 /*FUNCTION OptionChar::NDims {{{1*/
     120/*FUNCTION OptionChar::NDims {{{*/
    121121int   OptionChar::NDims(){
    122122
     
    124124}
    125125/*}}}*/
    126 /*FUNCTION OptionChar::Size {{{1*/
     126/*FUNCTION OptionChar::Size {{{*/
    127127int*  OptionChar::Size(){
    128128
     
    130130}
    131131/*}}}*/
    132 /*FUNCTION OptionChar::Get(char** pvalue) {{{1*/
     132/*FUNCTION OptionChar::Get(char** pvalue) {{{*/
    133133void OptionChar::Get(char** pvalue){
    134134
     
    138138        stringsize=strlen(this->values)+1;
    139139
    140         outstring=(char*)xmalloc(stringsize*sizeof(char));
    141         memcpy(outstring,this->values,stringsize*sizeof(char));
     140        outstring=xNew<char>(stringsize);
     141        xMemCpy<char>(outstring,this->values,stringsize);
    142142
    143143        *pvalue=outstring;
    144144}
    145145/*}}}*/
    146 /*FUNCTION OptionChar::Get(char*** ppvalue,int *pnumel) {{{1*/
     146/*FUNCTION OptionChar::Get(char*** ppvalue,int *pnumel) {{{*/
    147147void OptionChar::Get(char*** ppvalue,int *pnumel){
    148148
     
    153153        /*We should first check that the size is at least one*/
    154154        if(this->NumEl()<=0){
    155                 _error_("option \"%s\" is empty and cannot return a string vector",this->name);
     155                _error2_("option \"" << this->name << "\" is empty and cannot return a string vector");
    156156        }
    157157
     
    162162
    163163        /*Break concatenated string into individual strings*/
    164         *ppvalue=(char **) xmalloc(nstr*sizeof(char *));
     164        *ppvalue=xNew<char*>(nstr);
    165165        for (i=0; i<nstr; i++) {
    166                 outstring=(char*)xmalloc(stringsize*sizeof(char));
    167                 memcpy(outstring,&(this->values[ipt]),(stringsize-1)*sizeof(char));
     166                outstring=xNew<char>(stringsize);
     167                xMemCpy<char>(outstring,&(this->values[ipt]),(stringsize-1));
    168168                outstring[stringsize-1]='\0';
    169169                (*ppvalue)[i]=outstring;
  • issm/trunk/src/c/objects/Options/OptionChar.h

    r12330 r12706  
    66#define _OPTIONCHAR_H_
    77
    8 /*Headers:{{{1*/
     8/*Headers:{{{*/
    99#include "../../include/include.h"
    1010#include "../../shared/Exceptions/exceptions.h"
     
    2020                char* values;
    2121
    22                 /*OptionChar constructors, destructors {{{1*/
     22                /*OptionChar constructors, destructors {{{*/
    2323                OptionChar();
    2424                ~OptionChar();
    2525                /*}}}*/
    26                 /*Object virtual functions definitions:{{{1*/
     26                /*Object virtual functions definitions:{{{*/
    2727                void  Echo();
    2828                void  DeepEcho();
    2929                void  DeepEcho(char* indent);
    30                 int   Id(){_error_("Not implemented yet");};
    31                 int   MyRank(){_error_("Not implemented yet");};
     30                int   Id(){_error2_("Not implemented yet");};
     31                int   MyRank(){_error2_("Not implemented yet");};
    3232                int   ObjectEnum(){return OptionCharEnum;};
    33                 Object* copy(){_error_("Not implemented yet");};
     33                Object* copy(){_error2_("Not implemented yet");};
    3434                /*}}}*/
    3535
     
    3939                int   NDims();
    4040                int*  Size();
    41                 void  Get(int* pvalue){_error_("An OptionChar object cannot return a int");};
    42                 void  Get(double* pvalue){_error_("An OptionChar object cannot return a double");};
    43                 void  Get(bool* pvalue){  _error_("An OptionChar object cannot return a bool");};
     41                void  Get(int* pvalue){_error2_("An OptionChar object cannot return a int");};
     42                void  Get(IssmDouble* pvalue){_error2_("An OptionChar object cannot return a IssmDouble");};
     43                void  Get(bool* pvalue){  _error2_("An OptionChar object cannot return a bool");};
    4444                void  Get(char** pvalue);
    4545                void  Get(char*** ppvalue,int *pnumel);
    46                 void  Get(double** pvalue,int *pnumel){ _error_("An OptionChar object cannot return a double vec");};
    47                 void  Get(Options** pvalue){ _error_("An OptionChar object cannot return an Options DataSet");};
    48                 void  Get(Options*** ppvalue,int *pnumel){ _error_("An OptionChar object cannot return an Options DataSet vec");};
     46                void  Get(IssmDouble** pvalue,int *pnumel){ _error2_("An OptionChar object cannot return a IssmDouble vec");};
     47                void  Get(Options** pvalue){ _error2_("An OptionChar object cannot return an Options DataSet");};
     48                void  Get(Options*** ppvalue,int *pnumel){ _error2_("An OptionChar object cannot return an Options DataSet vec");};
    4949
    5050};
  • issm/trunk/src/c/objects/Options/OptionDouble.cpp

    r12330 r12706  
    11/*!\file OptionDouble.cpp
    2  * \brief: implementation of the optionsdouble object
     2 * \brief: implementation of the optionsIssmDouble object
    33 */
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*Constructors/destructor/copy*/
    23 /*FUNCTION OptionDouble::OptionDouble(){{{1*/
     23/*FUNCTION OptionDouble::OptionDouble(){{{*/
    2424OptionDouble::OptionDouble(){
    2525
     
    2828}
    2929/*}}}*/
    30 /*FUNCTION OptionDouble::~OptionDouble(){{{1*/
     30/*FUNCTION OptionDouble::~OptionDouble(){{{*/
    3131OptionDouble::~OptionDouble(){
    3232
    33         if (values) xfree((void**)&values);
     33        if (values) xDelete<IssmDouble>(values);
    3434
    3535}
     
    3737
    3838/*Other*/
    39 /*FUNCTION OptionDouble::Echo {{{1*/
     39/*FUNCTION OptionDouble::Echo {{{*/
    4040void  OptionDouble::Echo(){
    4141
     
    4343        bool  flag=true;
    4444
    45         _printf_(flag,"OptionDouble Echo:\n");
     45        if(flag) _pprintLine_("OptionDouble Echo:");
    4646        Option::Echo();
    4747
    4848        if (values && size) {
    49                 if(numel == 1) _printf_(flag,"        values: %g\n" ,values[0]);
     49                if(numel == 1) if(flag) _pprintLine_("        values: " << values[0]);
    5050                else {
    5151                        StringFromSize(cstr,size,ndims);
    52                         _printf_(flag,"        values: %s %s\n" ,cstr,"double");
     52                        if(flag) _pprintLine_("        values: " << cstr << " " << "IssmDouble");
    5353                }
    5454        }
    55         else _printf_(flag,"        values: [empty]\n" );
     55        else if(flag) _pprintLine_("        values: [empty]");
    5656}
    5757/*}}}*/
    58 /*FUNCTION OptionDouble::DeepEcho() {{{1*/
     58/*FUNCTION OptionDouble::DeepEcho() {{{*/
    5959void  OptionDouble::DeepEcho(){
    6060
     
    6666}
    6767/*}}}*/
    68 /*FUNCTION OptionDouble::DeepEcho(char* indent) {{{1*/
     68/*FUNCTION OptionDouble::DeepEcho(char* indent) {{{*/
    6969void  OptionDouble::DeepEcho(char* indent){
    7070
     
    7575        bool  flag=true;
    7676
    77         _printf_(flag,"%sOptionDouble DeepEcho:\n",indent);
     77        if(flag) _pprintLine_(indent << "OptionDouble DeepEcho:");
    7878        Option::DeepEcho(indent);
    7979
    80         memcpy(indent2,indent,(strlen(indent)+1)*sizeof(char));
     80        xMemCpy<char>(indent2,indent,(strlen(indent)+1));
    8181        strcat(indent2,"  ");
    8282
    8383        if (values) {
    84                 dims=(int *) xmalloc(ndims*sizeof(int));
    85                 if(numel==1) _printf_(flag,"%s        values: %g\n" ,indent,values[0]);
     84                dims=xNew<int>(ndims);
     85                if(numel==1) if(flag) _pprintLine_(indent << "        values: " << values[0]);
    8686                else{
    8787                        for (i=0; i<numel; i++) {
    8888                                RowWiseDimsFromIndex(dims,i,size,ndims);
    8989                                StringFromDims(cstr,dims,ndims);
    90                                 _printf_(flag,"%s        values%s: %g\n" ,indent,cstr,values[i]);
     90                                if(flag) _pprintLine_(indent << "        values" << cstr << ": " << values[i]);
    9191                        }
    9292                }
    93                 xfree((void**)&dims);
     93                xDelete<int>(dims);
    9494        }
    95         else _printf_(flag,"%s        values: [empty]\n" ,indent);
     95        else if(flag) _pprintLine_(indent << "        values: [empty]");
    9696}
    9797/*}}}*/
    98 /*FUNCTION OptionDouble::Name {{{1*/
     98/*FUNCTION OptionDouble::Name {{{*/
    9999char* OptionDouble::Name(){
    100100
     
    102102}
    103103/*}}}*/
    104 /*FUNCTION OptionDouble::NumEl {{{1*/
     104/*FUNCTION OptionDouble::NumEl {{{*/
    105105int   OptionDouble::NumEl(){
    106106
     
    108108}
    109109/*}}}*/
    110 /*FUNCTION OptionDouble::NDims {{{1*/
     110/*FUNCTION OptionDouble::NDims {{{*/
    111111int   OptionDouble::NDims(){
    112112
     
    114114}
    115115/*}}}*/
    116 /*FUNCTION OptionDouble::Size {{{1*/
     116/*FUNCTION OptionDouble::Size {{{*/
    117117int*  OptionDouble::Size(){
    118118
     
    120120}
    121121/*}}}*/
    122 /*FUNCTION OptionDouble::Get(int* pvalue) {{{1*/
     122/*FUNCTION OptionDouble::Get(int* pvalue) {{{*/
    123123void OptionDouble::Get(int* pvalue){
    124124
    125125        /*We should first check that the size is one*/
    126126        if(this->NumEl()!=1){
    127                 _error_("option \"%s\" has %i elements and cannot return a single int",this->name,this->NumEl());
     127                _error2_("option \"" << this->name << "\" has " << this->NumEl() << " elements and cannot return a single int");
    128128        }
    129129
    130130        /*Assign output pointer*/
    131         *pvalue=(int)this->values[0];
     131        *pvalue=reCast<int>(values[0]);
    132132}
    133133/*}}}*/
    134 /*FUNCTION OptionDouble::Get(double* pvalue) {{{1*/
    135 void OptionDouble::Get(double* pvalue){
     134/*FUNCTION OptionDouble::Get(IssmDouble* pvalue) {{{*/
     135void OptionDouble::Get(IssmDouble* pvalue){
    136136
    137137        /*We should first check that the size is one*/
    138138        if(this->NumEl()!=1){
    139                 _error_("option \"%s\" has %i elements and cannot return a single double",this->name,this->NumEl());
     139                _error2_("option \"" << this->name << "\" has " << this->NumEl() << " elements and cannot return a single IssmDouble");
    140140        }
    141141
     
    144144}
    145145/*}}}*/
    146 /*FUNCTION OptionDouble::Get(double** pvalue,int* numel) {{{1*/
    147 void OptionDouble::Get(double** pvalue,int* numel){
     146/*FUNCTION OptionDouble::Get(IssmDouble** pvalue,int* numel) {{{*/
     147void OptionDouble::Get(IssmDouble** pvalue,int* numel){
    148148
    149149        /*We should first check that the size is at least one*/
    150150        if(this->NumEl()<=0){
    151                 _error_("option \"%s\" is empty and cannot return a double vector",this->name);
     151                _error2_("option \"" << this->name << "\" is empty and cannot return a IssmDouble vector");
    152152        }
    153153
    154154        /*Copy vector*/
    155         double* outvalue=(double*)xmalloc(this->NumEl()*sizeof(double));
     155        IssmDouble* outvalue=xNew<IssmDouble>(this->NumEl());
    156156        for(int i=0;i<this->NumEl();i++) outvalue[i]=this->values[i];
    157157
  • issm/trunk/src/c/objects/Options/OptionDouble.h

    r12330 r12706  
    11/*! \file OptionDouble.h
    2  *  \brief: header file for optiondouble object
     2 *  \brief: header file for optionIssmDouble object
    33 */
    44
     
    66#define _OPTIONDOUBLE_H_
    77
    8 /*Headers:{{{1*/
     8/*Headers:{{{*/
    99#include "../../include/include.h"
    1010#include "../../shared/Exceptions/exceptions.h"
     
    1818        public:
    1919
    20                 double* values;
     20                IssmDouble* values;
    2121
    22                 /*OptionDouble constructors, destructors {{{1*/
     22                /*OptionDouble constructors, destructors {{{*/
    2323                OptionDouble();
    2424                ~OptionDouble();
    2525                /*}}}*/
    26                 /*Object virtual functions definitions:{{{1*/
     26                /*Object virtual functions definitions:{{{*/
    2727                void  Echo();
    2828                void  DeepEcho();
    2929                void  DeepEcho(char* indent);
    30                 int   Id(){_error_("Not implemented yet");};
    31                 int   MyRank(){_error_("Not implemented yet");};
     30                int   Id(){_error2_("Not implemented yet");};
     31                int   MyRank(){_error2_("Not implemented yet");};
    3232                int   ObjectEnum(){return OptionDoubleEnum;};
    33                 Object* copy(){_error_("Not implemented yet");};
     33                Object* copy(){_error2_("Not implemented yet");};
    3434                /*}}}*/
    3535
     
    4040                int*  Size();
    4141                void  Get(int* pvalue);
    42                 void  Get(double* pvalue);
    43                 void  Get(bool* pvalue){  _error_("An OptionDouble object cannot return a bool");};
    44                 void  Get(char** pvalue){ _error_("An OptionDouble object cannot return a string");};
    45                 void  Get(char*** ppvalue,int *pnumel){ _error_("An OptionDouble object cannot return a string vec");};
    46                 void  Get(double** pvalue,int* pnumel);
    47                 void  Get(Options** pvalue){ _error_("An OptionDouble object cannot return an Options DataSet");};
    48                 void  Get(Options*** ppvalue,int *pnumel){ _error_("An OptionDouble object cannot return an Options DataSet vec");};
     42                void  Get(IssmDouble* pvalue);
     43                void  Get(bool* pvalue){  _error2_("An OptionDouble object cannot return a bool");};
     44                void  Get(char** pvalue){ _error2_("An OptionDouble object cannot return a string");};
     45                void  Get(char*** ppvalue,int *pnumel){ _error2_("An OptionDouble object cannot return a string vec");};
     46                void  Get(IssmDouble** pvalue,int* pnumel);
     47                void  Get(Options** pvalue){ _error2_("An OptionDouble object cannot return an Options DataSet");};
     48                void  Get(Options*** ppvalue,int *pnumel){ _error2_("An OptionDouble object cannot return an Options DataSet vec");};
    4949
    5050};
  • issm/trunk/src/c/objects/Options/OptionLogical.cpp

    r9761 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*Constructors/destructor/copy*/
    23 /*FUNCTION OptionLogical::OptionLogical(){{{1*/
     23/*FUNCTION OptionLogical::OptionLogical(){{{*/
    2424OptionLogical::OptionLogical(){
    2525
     
    2828}
    2929/*}}}*/
    30 /*FUNCTION OptionLogical::~OptionLogical(){{{1*/
     30/*FUNCTION OptionLogical::~OptionLogical(){{{*/
    3131OptionLogical::~OptionLogical(){
    3232
    33         if (values) xfree((void**)&values);
     33        if (values) xDelete<bool>(values);
    3434
    3535}
     
    3737
    3838/*Other*/
    39 /*FUNCTION OptionLogical::Echo {{{1*/
     39/*FUNCTION OptionLogical::Echo {{{*/
    4040void  OptionLogical::Echo(){
    4141
     
    4343        bool  flag=true;
    4444
    45         _printf_(flag,"OptionLogical Echo:\n");
     45        if(flag) _pprintLine_("OptionLogical Echo:");
    4646        Option::Echo();
    4747
    4848        if (values && size) {
    49                 if(numel == 1) _printf_(flag,"        values: %s\n" ,(values[0] ? "true" : "false"));
     49                if(numel == 1) if(flag) _pprintLine_("        values: " << (values[0] ? "true" : "false"));
    5050                else{
    5151                        StringFromSize(cstr,size,ndims);
    52                         _printf_(flag,"        values: %s %s\n" ,cstr,"logical");
     52                        if(flag) _pprintLine_("        values: " << cstr << " " << "logical");
    5353                }
    5454        }
    55         else _printf_(flag,"        values: [empty]\n" );
     55        else if(flag) _pprintLine_("        values: [empty]");
    5656}
    5757/*}}}*/
    58 /*FUNCTION OptionLogical::DeepEcho() {{{1*/
     58/*FUNCTION OptionLogical::DeepEcho() {{{*/
    5959void  OptionLogical::DeepEcho(){
    6060
     
    6666}
    6767/*}}}*/
    68 /*FUNCTION OptionLogical::DeepEcho(char* indent) {{{1*/
     68/*FUNCTION OptionLogical::DeepEcho(char* indent) {{{*/
    6969void  OptionLogical::DeepEcho(char* indent){
    7070
     
    7575        bool  flag=true;
    7676
    77         _printf_(flag,"%sOptionLogical DeepEcho:\n",indent);
     77        if(flag) _pprintLine_(indent << "OptionLogical DeepEcho:");
    7878        Option::DeepEcho(indent);
    7979
    80         memcpy(indent2,indent,(strlen(indent)+1)*sizeof(char));
     80        xMemCpy<char>(indent2,indent,(strlen(indent)+1));
    8181        strcat(indent2,"  ");
    8282
    8383        if (values) {
    84                 if(numel==1) _printf_(flag,"%s        values: %s\n" ,indent,(values[0] ? "true" : "false"));
     84                if(numel==1) if(flag) _pprintLine_(indent << "        values: " << (values[0] ? "true" : "false"));
    8585                else{
    86                         dims=(int *) xmalloc(ndims*sizeof(int));
     86                        dims=xNew<int>(ndims);
    8787                        for (i=0; i<numel; i++) {
    8888                                RowWiseDimsFromIndex(dims,i,size,ndims);
    8989                                StringFromDims(cstr,dims,ndims);
    90                                 _printf_(flag,"%s        values%s: %s\n" ,indent,cstr,(values[i] ? "true" : "false"));
     90                                if(flag) _pprintLine_(indent << "        values" << cstr << ": " << (values[i] ? "true" : "false"));
    9191                        }
    92                         xfree((void**)&dims);
     92                        xDelete<int>(dims);
    9393                }
    9494        }
    95         else _printf_(flag,"%s        values: [empty]\n" ,indent);
     95        else if(flag) _pprintLine_(indent << "        values: [empty]");
    9696}
    9797/*}}}*/
    98 /*FUNCTION OptionLogical::Name {{{1*/
     98/*FUNCTION OptionLogical::Name {{{*/
    9999char* OptionLogical::Name(){
    100100
     
    102102}
    103103/*}}}*/
    104 /*FUNCTION OptionLogical::NumEl {{{1*/
     104/*FUNCTION OptionLogical::NumEl {{{*/
    105105int   OptionLogical::NumEl(){
    106106
     
    108108}
    109109/*}}}*/
    110 /*FUNCTION OptionLogical::NDims {{{1*/
     110/*FUNCTION OptionLogical::NDims {{{*/
    111111int   OptionLogical::NDims(){
    112112
     
    114114}
    115115/*}}}*/
    116 /*FUNCTION OptionLogical::Size {{{1*/
     116/*FUNCTION OptionLogical::Size {{{*/
    117117int*  OptionLogical::Size(){
    118118
     
    120120}
    121121/*}}}*/
    122 /*FUNCTION OptionLogical::Get(bool* pvalue) {{{1*/
     122/*FUNCTION OptionLogical::Get(bool* pvalue) {{{*/
    123123void OptionLogical::Get(bool* pvalue){
    124124
    125125        /*We should first check that the size is one*/
    126126        if(this->NumEl()!=1){
    127                 _error_("option \"%s\" has %i elements and cannot return a single bool",this->name,this->NumEl());
     127                _error2_("option \"" << this->name << "\" has " << this->NumEl() << " elements and cannot return a single bool");
    128128        }
    129129
  • issm/trunk/src/c/objects/Options/OptionLogical.h

    r12330 r12706  
    66#define _OPTIONLOGICAL_H_
    77
    8 /*Headers:{{{1*/
     8/*Headers:{{{*/
    99#include "../../include/include.h"
    1010#include "../../shared/Exceptions/exceptions.h"
     
    2020                bool* values;
    2121
    22                 /*OptionLogical constructors, destructors {{{1*/
     22                /*OptionLogical constructors, destructors {{{*/
    2323                OptionLogical();
    2424                ~OptionLogical();
    2525                /*}}}*/
    26                 /*Object virtual functions definitions:{{{1*/
     26                /*Object virtual functions definitions:{{{*/
    2727                void  Echo();
    2828                void  DeepEcho();
    2929                void  DeepEcho(char* indent);
    30                 int   Id(){_error_("Not implemented yet");};
    31                 int   MyRank(){_error_("Not implemented yet");};
     30                int   Id(){_error2_("Not implemented yet");};
     31                int   MyRank(){_error2_("Not implemented yet");};
    3232                int   ObjectEnum(){return OptionLogicalEnum;};
    33                 Object* copy(){_error_("Not implemented yet");};
     33                Object* copy(){_error2_("Not implemented yet");};
    3434                /*}}}*/
    3535
     
    3939                int   NDims();
    4040                int*  Size();
    41                 void  Get(int* pvalue){_error_("An OptionLogical object cannot return a int");};
    42                 void  Get(double* pvalue){_error_("An OptionLogical object cannot return a double");};
     41                void  Get(int* pvalue){_error2_("An OptionLogical object cannot return a int");};
     42                void  Get(IssmDouble* pvalue){_error2_("An OptionLogical object cannot return a IssmDouble");};
    4343                void  Get(bool* pvalue);
    44                 void  Get(char** pvalue){ _error_("An OptionLogical object cannot return a string");};
    45                 void  Get(char*** ppvalue,int *pnumel){ _error_("An OptionLogical object cannot return a string vec");};
    46                 void  Get(double** pvalue,int *pnumel){ _error_("An OptionLogical object cannot return a double vec");};
    47                 void  Get(Options** pvalue){ _error_("An OptionLogical object cannot return an Options DataSet");};
    48                 void  Get(Options*** ppvalue,int *pnumel){ _error_("An OptionLogical object cannot return an Options DataSet vec");};
     44                void  Get(char** pvalue){ _error2_("An OptionLogical object cannot return a string");};
     45                void  Get(char*** ppvalue,int *pnumel){ _error2_("An OptionLogical object cannot return a string vec");};
     46                void  Get(IssmDouble** pvalue,int *pnumel){ _error2_("An OptionLogical object cannot return a IssmDouble vec");};
     47                void  Get(Options** pvalue){ _error2_("An OptionLogical object cannot return an Options DataSet");};
     48                void  Get(Options*** ppvalue,int *pnumel){ _error2_("An OptionLogical object cannot return an Options DataSet vec");};
    4949
    5050};
  • issm/trunk/src/c/objects/Options/OptionStruct.cpp

    r9761 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*Constructors/destructor/copy*/
    23 /*FUNCTION OptionStruct::OptionStruct(){{{1*/
     23/*FUNCTION OptionStruct::OptionStruct(){{{*/
    2424OptionStruct::OptionStruct(){
    2525
     
    2828}
    2929/*}}}*/
    30 /*FUNCTION OptionStruct::~OptionStruct(){{{1*/
     30/*FUNCTION OptionStruct::~OptionStruct(){{{*/
    3131OptionStruct::~OptionStruct(){
    3232
     
    3838                        values[i] =NULL;
    3939                }
    40                 xfree((void**)&values);
     40                xDelete<Options*>(values);
    4141        }
    4242
     
    4545
    4646/*Other*/
    47 /*FUNCTION OptionStruct::Echo {{{1*/
     47/*FUNCTION OptionStruct::Echo {{{*/
    4848void  OptionStruct::Echo(){
    4949
     
    5151        bool  flag=true;
    5252
    53         _printf_(flag,"OptionStruct Echo:\n");
     53        if(flag) _pprintLine_("OptionStruct Echo:");
    5454        Option::Echo();
    5555
    5656        if (values && size) {
    5757                StringFromSize(cstr,size,ndims);
    58                 _printf_(flag,"        values: %s %s\n" ,cstr,"struct");
     58                if(flag) _pprintLine_("        values: " << cstr << " " << "struct");
    5959        }
    60         else _printf_(flag,"        values: [empty]\n" );
     60        else if(flag) _pprintLine_("        values: [empty]");
    6161}
    6262/*}}}*/
    63 /*FUNCTION OptionStruct::DeepEcho() {{{1*/
     63/*FUNCTION OptionStruct::DeepEcho() {{{*/
    6464void  OptionStruct::DeepEcho(){
    6565
     
    7171}
    7272/*}}}*/
    73 /*FUNCTION OptionStruct::DeepEcho(char* indent) {{{1*/
     73/*FUNCTION OptionStruct::DeepEcho(char* indent) {{{*/
    7474void  OptionStruct::DeepEcho(char* indent){
    7575
     
    8080        bool  flag=true;
    8181
    82         _printf_(flag,"%sOptionStruct DeepEcho:\n",indent);
     82        if(flag) _pprintLine_(indent << "OptionStruct DeepEcho:");
    8383        Option::DeepEcho(indent);
    8484
    85         memcpy(indent2,indent,(strlen(indent)+1)*sizeof(char));
     85        xMemCpy<char>(indent2,indent,(strlen(indent)+1));
    8686        strcat(indent2,"  ");
    8787
    8888        if (values) {
    89                 dims=(int *)xmalloc(ndims*sizeof(int));
     89                dims=xNew<int>(ndims);
    9090                for (i=0; i<numel; i++) {
    9191                        ColumnWiseDimsFromIndex(dims,i,size,ndims);
    9292                        StringFromDims(cstr,dims,ndims);
    9393                        if (values[i]->Size()){
    94                                 _printf_(flag,"%s        values: -------- begin %s --------\n" ,indent,cstr);
     94                                if(flag) _pprintLine_(indent << "        values: -------- begin " << cstr << " --------");
    9595                                for (j=0; j<values[i]->Size(); j++) ((Option *)values[i]->GetObjectByOffset(j))->DeepEcho(indent2);
    96                                 _printf_(flag,"%s        values: --------  end  %s --------\n" ,indent,cstr);
     96                                if(flag) _pprintLine_(indent << "        values: --------  end  " << cstr << " --------");
    9797                        }
    98                         else _printf_(flag,"%s        values: %s [empty]\n" ,indent,cstr);
     98                        else if(flag) _pprintLine_(indent << "        values: " << cstr << " [empty]");
    9999                }
    100                 xfree((void**)&dims);
     100                xDelete<int>(dims);
    101101        }
    102         else _printf_(flag,"%s        values: [empty]\n" ,indent);
     102        else if(flag) _pprintLine_(indent << "        values: [empty]");
    103103}
    104104/*}}}*/
    105 /*FUNCTION OptionStruct::Name {{{1*/
     105/*FUNCTION OptionStruct::Name {{{*/
    106106char* OptionStruct::Name(){
    107107
     
    109109}
    110110/*}}}*/
    111 /*FUNCTION OptionStruct::NumEl {{{1*/
     111/*FUNCTION OptionStruct::NumEl {{{*/
    112112int   OptionStruct::NumEl(){
    113113
     
    115115}
    116116/*}}}*/
    117 /*FUNCTION OptionStruct::NDims {{{1*/
     117/*FUNCTION OptionStruct::NDims {{{*/
    118118int   OptionStruct::NDims(){
    119119
     
    121121}
    122122/*}}}*/
    123 /*FUNCTION OptionStruct::Size {{{1*/
     123/*FUNCTION OptionStruct::Size {{{*/
    124124int*  OptionStruct::Size(){
    125125
     
    127127}
    128128/*}}}*/
    129 /*FUNCTION OptionStruct::Get(Options** pvalue) {{{1*/
     129/*FUNCTION OptionStruct::Get(Options** pvalue) {{{*/
    130130void OptionStruct::Get(Options** pvalue){
    131131
    132132        /*We should first check that the size is one*/
    133133        if(this->NumEl()!=1){
    134                 _error_("option \"%s\" has %i elements and cannot return a single options dataset",this->name,this->NumEl());
     134                _error2_("option \"" << this->name << "\" has " << this->NumEl() << " elements and cannot return a single options dataset");
    135135        }
    136136
     
    139139}
    140140/*}}}*/
    141 /*FUNCTION OptionStruct::Get(Options*** ppvalue,int* numel) {{{1*/
     141/*FUNCTION OptionStruct::Get(Options*** ppvalue,int* numel) {{{*/
    142142void OptionStruct::Get(Options*** ppvalue,int* numel){
    143143
    144144        /*We should first check that the size is at least one*/
    145145        if(this->NumEl()<=0){
    146                 _error_("option \"%s\" is empty and cannot return an options dataset vector",this->name);
     146                _error2_("option \"" << this->name << "\" is empty and cannot return an options dataset vector");
    147147        }
    148148
  • issm/trunk/src/c/objects/Options/OptionStruct.h

    r12330 r12706  
    66#define _OPTIONSTRUCT_H_
    77
    8 /*Headers:{{{1*/
     8/*Headers:{{{*/
    99#include "../../include/include.h"
    1010#include "../../shared/Exceptions/exceptions.h"
     
    2020                Options** values;
    2121
    22                 /*OptionStruct constructors, destructors {{{1*/
     22                /*OptionStruct constructors, destructors {{{*/
    2323                OptionStruct();
    2424                ~OptionStruct();
    2525                /*}}}*/
    26                 /*Object virtual functions definitions:{{{1*/
     26                /*Object virtual functions definitions:{{{*/
    2727                void  Echo();
    2828                void  DeepEcho();
    2929                void  DeepEcho(char* indent);
    30                 int   Id(){_error_("Not implemented yet");};
    31                 int   MyRank(){_error_("Not implemented yet");};
     30                int   Id(){_error2_("Not implemented yet");};
     31                int   MyRank(){_error2_("Not implemented yet");};
    3232                int   ObjectEnum(){return OptionStructEnum;};
    33                 Object* copy(){_error_("Not implemented yet");};
     33                Object* copy(){_error2_("Not implemented yet");};
    3434                /*}}}*/
    3535
     
    3939                int   NDims();
    4040                int*  Size();
    41                 void  Get(int* pvalue){_error_("An OptionStruct object cannot return a int");};
    42                 void  Get(double* pvalue){_error_("An OptionStruct object cannot return a double");};
    43                 void  Get(bool* pvalue){  _error_("An OptionStruct object cannot return a bool");};
    44                 void  Get(char** pvalue){ _error_("An OptionStruct object cannot return a string");};
    45                 void  Get(char*** ppvalue,int *pnumel){ _error_("An OptionStruct object cannot return a string vec");};
    46                 void  Get(double** pvalue,int *pnumel){ _error_("An OptionStruct object cannot return a double vec");};
     41                void  Get(int* pvalue){_error2_("An OptionStruct object cannot return a int");};
     42                void  Get(IssmDouble* pvalue){_error2_("An OptionStruct object cannot return a IssmDouble");};
     43                void  Get(bool* pvalue){  _error2_("An OptionStruct object cannot return a bool");};
     44                void  Get(char** pvalue){ _error2_("An OptionStruct object cannot return a string");};
     45                void  Get(char*** ppvalue,int *pnumel){ _error2_("An OptionStruct object cannot return a string vec");};
     46                void  Get(IssmDouble** pvalue,int *pnumel){ _error2_("An OptionStruct object cannot return a IssmDouble vec");};
    4747                void  Get(Options** pvalue);
    4848                void  Get(Options*** ppvalue,int *pnumel);
  • issm/trunk/src/c/objects/Options/OptionUtilities.cpp

    r9320 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    1919/*}}}*/
    2020
    21 /*FUNCTION ColumnWiseDimsFromIndex{{{1*/
     21/*FUNCTION ColumnWiseDimsFromIndex{{{*/
    2222int ColumnWiseDimsFromIndex(int* dims,int index,int* size,int ndims){
    2323
     
    2727        /*check for index too large  */
    2828        for (i=0;i<ndims;i++) aprod*=size[i];
    29         if (index >= aprod) _error_("Index %d exceeds number of elements %d.",index,aprod);
     29        if (index >= aprod) _error2_("Index " << index << " exceeds number of elements " << aprod << ".");
    3030
    3131        /*calculate the dimensions (being careful of integer division)  */
    3232        for (i=ndims-1; i>=0; i--) {
    33                 aprod=(int)(((double)aprod+0.5)/(double)size[i]);
    34                 dims[i]=(int)floor(((double)index+0.5)/(double)aprod);
     33                aprod=reCast<int>(((IssmPDouble)aprod+0.5)/(IssmPDouble)size[i]);
     34                dims[i]=(int)floor(((IssmPDouble)index+0.5)/(IssmPDouble)aprod);
    3535                index-=dims[i]*aprod;
    3636        }
     
    3838        return(0);
    3939}/*}}}*/
    40 /*FUNCTION IndexFromColumnWiseDims{{{1*/
     40/*FUNCTION IndexFromColumnWiseDims{{{*/
    4141int IndexFromColumnWiseDims(int* dims, int* size, int ndims) {
    4242
     
    4646        /*check for any dimension too large  */
    4747        for (i=0;i<ndims;i++){
    48                 if (dims[i] >= size[i]) _error_("Dimension %d of %d exceeds size of %d.",i,dims[i],size[i]);
     48                if (dims[i] >= size[i]) _error2_("Dimension " << i << " of " << dims[i] << " exceeds size of " << size[i] << ".");
    4949        }
    5050
     
    5757        return(index);
    5858}/*}}}*/
    59 /*FUNCTION RowWiseDimsFromIndex{{{1*/
     59/*FUNCTION RowWiseDimsFromIndex{{{*/
    6060int RowWiseDimsFromIndex(int* dims, int index, int* size, int ndims) {
    6161
     
    6565        /*check for index too large  */
    6666        for (i=0; i<ndims; i++) aprod*=size[i];
    67         if (index >= aprod) _error_("Index %d exceeds number of elements %d.",index,aprod);
     67        if (index >= aprod) _error2_("Index " << index << " exceeds number of elements " << aprod << ".");
    6868
    6969        /*calculate the dimensions (being careful of integer division)  */
    7070        for (i=0; i<ndims; i++) {
    71                 aprod=(int)(((double)aprod+0.5)/(double)size[i]);
    72                 dims[i]=(int)floor(((double)index+0.5)/(double)aprod);
     71                aprod=(int)(((IssmPDouble)aprod+0.5)/(IssmPDouble)size[i]);
     72                dims[i]=(int)floor(((IssmPDouble)index+0.5)/(IssmPDouble)aprod);
    7373                index-=dims[i]*aprod;
    7474        }
     
    7676        return(0);
    7777}/*}}}*/
    78 /*FUNCTION IndexFromRowWiseDims{{{1*/
     78/*FUNCTION IndexFromRowWiseDims{{{*/
    7979int IndexFromRowWiseDims(int* dims, int* size, int ndims) {
    8080
     
    8484        /*check for any dimension too large  */
    8585        for (i=0; i<ndims; i++){
    86                 if (dims[i] >= size[i]) _error_("Dimension %d of %d exceeds size of %d.",i,dims[i],size[i]);
     86                if (dims[i] >= size[i]) _error2_("Dimension " << i << " of " << dims[i] << " exceeds size of " << size[i] << ".");
    8787        }
    8888
     
    9595        return(index);
    9696}/*}}}*/
    97 /*FUNCTION StringFromDims{{{1*/
     97/*FUNCTION StringFromDims{{{*/
    9898int StringFromDims(char* cstr, int* dims, int ndims) {
    9999
     
    104104        return(0);
    105105}/*}}}*/
    106 /*FUNCTION StringFromSize{{{1*/
     106/*FUNCTION StringFromSize{{{*/
    107107int StringFromSize(char* cstr, int* size, int ndims) {
    108108
  • issm/trunk/src/c/objects/Options/OptionUtilities.h

    r8535 r12706  
    66#define _OPTIONUTILITIES_H_
    77
    8 /*Headers:{{{1*/
     8/*Headers:{{{*/
    99#include "../../include/include.h"
    1010#include "../../shared/Exceptions/exceptions.h"
  • issm/trunk/src/c/objects/Params/BoolParam.cpp

    r12330 r12706  
    44
    55/*header files: */
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*BoolParam constructors and destructor*/
    23 /*FUNCTION BoolParam::BoolParam(){{{1*/
     23/*FUNCTION BoolParam::BoolParam(){{{*/
    2424BoolParam::BoolParam(){
    2525        return;
    2626}
    2727/*}}}*/
    28 /*FUNCTION BoolParam::BoolParam(int enum_type,IssmBool value){{{1*/
     28/*FUNCTION BoolParam::BoolParam(int enum_type,IssmBool value){{{*/
    2929BoolParam::BoolParam(int in_enum_type,IssmBool in_value){
    3030
     
    3333}
    3434/*}}}*/
    35 /*FUNCTION BoolParam::~BoolParam(){{{1*/
     35/*FUNCTION BoolParam::~BoolParam(){{{*/
    3636BoolParam::~BoolParam(){
    3737        return;
     
    4040
    4141/*Object virtual functions definitions:*/
    42 /*FUNCTION BoolParam::Echo {{{1*/
     42/*FUNCTION BoolParam::Echo {{{*/
    4343void BoolParam::Echo(void){
    4444        this->DeepEcho();
    4545}
    4646/*}}}*/
    47 /*FUNCTION BoolParam::DeepEcho{{{1*/
     47/*FUNCTION BoolParam::DeepEcho{{{*/
    4848void BoolParam::DeepEcho(void){
    4949
    50         printf("BoolParam:\n");
    51         printf("   enum:  %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    52         printf("   value: %s\n",this->value?"true":"false");
     50        _printLine_("BoolParam:");
     51        _printLine_("   enum:  " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     52        _printLine_("   value: " <<(this->value?"true":"false"));
    5353}
    5454/*}}}*/
    55 /*FUNCTION BoolParam::Id{{{1*/
     55/*FUNCTION BoolParam::Id{{{*/
    5656int    BoolParam::Id(void){ return -1; }
    5757/*}}}*/
    58 /*FUNCTION BoolParam::MyRank{{{1*/
     58/*FUNCTION BoolParam::MyRank{{{*/
    5959int    BoolParam::MyRank(void){
    6060        extern int my_rank;
     
    6262}
    6363/*}}}*/
    64 /*FUNCTION BoolParam::ObjectEnum{{{1*/
     64/*FUNCTION BoolParam::ObjectEnum{{{*/
    6565int BoolParam::ObjectEnum(void){
    6666
     
    6969}
    7070/*}}}*/
    71 /*FUNCTION BoolParam::copy{{{1*/
     71/*FUNCTION BoolParam::copy{{{*/
    7272Object* BoolParam::copy() {
    7373       
     
    7878
    7979/*BoolParam virtual functions definitions: */
    80 /*FUNCTION BoolParam::GetParameterName{{{1*/
     80/*FUNCTION BoolParam::GetParameterName{{{*/
    8181void BoolParam::GetParameterName(char**pname){
    8282        EnumToStringx(pname,this->enum_type);
    8383}
    8484/*}}}*/
    85 /*FUNCTION BoolParam::UnitConversion{{{1*/
     85/*FUNCTION BoolParam::UnitConversion{{{*/
    8686void  BoolParam::UnitConversion(int direction_enum){
    8787        /*do nothing, no unit conversion*/
  • issm/trunk/src/c/objects/Params/BoolParam.h

    r12330 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111#ifdef HAVE_CONFIG_H
    1212        #include <config.h>
     
    2727                IssmBool value;
    2828
    29                 /*BoolParam constructors, destructors: {{{1*/
     29                /*BoolParam constructors, destructors: {{{*/
    3030                BoolParam();
    3131                BoolParam(int enum_type,IssmBool value);
    3232                ~BoolParam();
    3333                /*}}}*/
    34                 /*Object virtual functions definitions:{{{1 */
     34                /*Object virtual functions definitions:{{{ */
    3535                void  Echo();
    3636                void  DeepEcho();
     
    4040                Object* copy();
    4141                /*}}}*/
    42                 /*Param vritual function definitions: {{{1*/
     42                /*Param vritual function definitions: {{{*/
    4343                int   InstanceEnum(){return enum_type;}
    4444                void  GetParameterValue(bool* pbool){*pbool=value;}
    45                 void  GetParameterValue(int* pinteger){_error_("Bool param of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type));}
    46                 void  GetParameterValue(int** pintarray,int* pM){_error_("Bool param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
    47                 void  GetParameterValue(int** pintarray,int* pM,int* pN){_error_("Bool param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
    48                 void  GetParameterValue(double* pdouble){_error_("Bool param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
    49                 void  GetParameterValue(char** pstring){_error_("Bool param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
    50                 void  GetParameterValue(char*** pstringarray,int* pM){_error_("Bool param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
    51                 void  GetParameterValue(double** pdoublearray,int* pM){_error_("Bool param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
    52                 void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("Bool param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
    53                 void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("Bool param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
    54                 void  GetParameterValue(Vector** pvec){_error_("Bool param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
    55                 void  GetParameterValue(Matrix** pmat){_error_("Bool param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
    56                 void  GetParameterValue(FILE** pfid){_error_("Bool param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
     45                void  GetParameterValue(int* pinteger){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an integer");}
     46                void  GetParameterValue(int** pintarray,int* pM){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
     47                void  GetParameterValue(int** pintarray,int* pM,int* pN){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
     48                void  GetParameterValue(IssmDouble* pIssmDouble){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble");}
     49                void  GetParameterValue(char** pstring){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string");}
     50                void  GetParameterValue(char*** pstringarray,int* pM){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string array");}
     51                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
     52                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
     53                void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix array");}
     54                void  GetParameterValue(Vector** pvec){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Vec");}
     55                void  GetParameterValue(Matrix** pmat){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Mat");}
     56                void  GetParameterValue(FILE** pfid){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");}
    5757
    5858                void  SetValue(bool boolean){this->value=boolean;}
    59                 void  SetValue(int integer){this->value=(bool)integer;}
    60                 void  SetValue(double scalar){this->value=(bool)scalar;}
    61                 void  SetValue(char* string){_error_("Bool param of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
    62                 void  SetValue(char** stringarray,int M){_error_("Bool param of enum %i (%s) cannot hold a string array",enum_type,EnumToStringx(enum_type));}
    63                 void  SetValue(double* doublearray,int M){_error_("Bool param of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
    64                 void  SetValue(double* pdoublearray,int M,int N){_error_("Bool param of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
    65                 void  SetValue(int* intarray,int M){_error_("Bool param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
    66                 void  SetValue(int* pintarray,int M,int N){_error_("Bool param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
    67                 void  SetValue(Vector* vec){_error_("Bool param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
    68                 void  SetValue(Matrix* mat){_error_("Bool param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
    69                 void  SetValue(FILE* fid){_error_("Bool param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
    70                 void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("Bool param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
     59                void  SetValue(int integer){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an int");}
     60                void  SetValue(IssmDouble scalar){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an IssmPDouble");}
     61                void  SetValue(char* string){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string");}
     62                void  SetValue(char** stringarray,int M){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string array");}
     63                void  SetValue(IssmDouble* IssmDoublearray,int M){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
     64                void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
     65                void  SetValue(int* intarray,int M){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int array");}
     66                void  SetValue(int* pintarray,int M,int N){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int array");}
     67                void  SetValue(Vector* vec){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Vec");}
     68                void  SetValue(Matrix* mat){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Mat");}
     69                void  SetValue(FILE* fid){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
     70                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an array of matrices");}
    7171                void  UnitConversion(int direction_enum);
    7272               
  • issm/trunk/src/c/objects/Params/DoubleMatArrayParam.cpp

    r12330 r12706  
    44
    55/*header files: */
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*DoubleMatArrayParam constructors and destructor*/
    23 /*FUNCTION DoubleMatArrayParam::DoubleMatArrayParam(){{{1*/
     23/*FUNCTION DoubleMatArrayParam::DoubleMatArrayParam(){{{*/
    2424DoubleMatArrayParam::DoubleMatArrayParam(){
    2525        return;
    2626}
    2727/*}}}*/
    28 /*FUNCTION DoubleMatArrayParam::DoubleMatArrayParam(int enum_type,double** array, int M, int* mdim_array, int* ndim_array){{{1*/
    29 DoubleMatArrayParam::DoubleMatArrayParam(int in_enum_type,double** in_array, int in_M, int* in_mdim_array, int* in_ndim_array){
     28/*FUNCTION DoubleMatArrayParam::DoubleMatArrayParam(int enum_type,IssmDouble** array, int M, int* mdim_array, int* ndim_array){{{*/
     29DoubleMatArrayParam::DoubleMatArrayParam(int in_enum_type,IssmDouble** in_array, int in_M, int* in_mdim_array, int* in_ndim_array){
    3030
    3131        int i;
    32         double* matrix=NULL;
     32        IssmDouble* matrix=NULL;
    3333        int     m,n;
    3434
     
    3636        M=in_M;
    3737        if(M){
    38                 array=(double**)xmalloc(M*sizeof(double*));
    39                 mdim_array=(int*)xmalloc(M*sizeof(int));
    40                 ndim_array=(int*)xmalloc(M*sizeof(int));
     38                array=xNew<IssmDouble*>(M);
     39                mdim_array=xNew<int>(M);
     40                ndim_array=xNew<int>(M);
    4141
    4242                for(i=0;i<M;i++){
     
    4848
    4949                        if(m*n){
    50                                 matrix=(double*)xmalloc(m*n*sizeof(double));
    51                                 memcpy(matrix,in_array[i],m*n*sizeof(double));
     50                                matrix=xNew<IssmDouble>(m*n);
     51                                xMemCpy<IssmDouble>(matrix,in_array[i],m*n);
    5252                        }
    5353                        else{
     
    6464}
    6565/*}}}*/
    66 /*FUNCTION DoubleMatArrayParam::~DoubleMatArrayParam(){{{1*/
     66/*FUNCTION DoubleMatArrayParam::~DoubleMatArrayParam(){{{*/
    6767DoubleMatArrayParam::~DoubleMatArrayParam(){
    6868
    6969        int i;
    70         double* matrix=NULL;
    71 
    72         xfree((void**)&mdim_array);
    73         xfree((void**)&ndim_array);
     70        IssmDouble* matrix=NULL;
     71
     72        xDelete<int>(mdim_array);
     73        xDelete<int>(ndim_array);
    7474
    7575        for(i=0;i<M;i++){
    7676                matrix=array[i];
    77                 xfree((void**)&matrix);
    78         }
    79        
    80         xfree((void**)&array);
     77                xDelete<IssmDouble>(matrix);
     78        }
     79       
     80        xDelete<IssmDouble*>(array);
    8181        return;
    8282}
     
    8484
    8585/*Object virtual functions definitions:*/
    86 /*FUNCTION DoubleMatArrayParam::Echo {{{1*/
     86/*FUNCTION DoubleMatArrayParam::Echo {{{*/
    8787void DoubleMatArrayParam::Echo(void){
    8888
    89         printf("DoubleMatArrayParam:\n");
    90         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    91         printf("   array size: %i\n",this->M);
    92         printf("   array pointer: %p\n",this->array);
    93 
    94 }
    95 /*}}}*/
    96 /*FUNCTION DoubleMatArrayParam::DeepEcho{{{1*/
     89        _printLine_("DoubleMatArrayParam:");
     90        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     91        _printLine_("   array size: " << this->M);
     92        _printLine_("   array pointer: " << this->array);
     93
     94}
     95/*}}}*/
     96/*FUNCTION DoubleMatArrayParam::DeepEcho{{{*/
    9797void DoubleMatArrayParam::DeepEcho(void){
    9898
    9999        int i,j,k;
    100100        int m,n;
    101         double* matrix=NULL;
    102        
    103         printf("DoubleMatArrayParam:\n");
    104         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    105         printf("   array size: %i\n",this->M);
    106         for(i=0;i<M;i++){
    107                 printf("   array %i (%ix%i):\n",i,mdim_array[i],ndim_array[i]);
     101        IssmDouble* matrix=NULL;
     102       
     103        _printLine_("DoubleMatArrayParam:");
     104        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     105        _printLine_("   array size: " << this->M);
     106        for(i=0;i<M;i++){
     107                _printLine_("   array " << i << " (" << mdim_array[i] << "x" << ndim_array[i] << "):");
    108108                matrix=array[i];
    109109                m=mdim_array[i];
     
    111111
    112112                for(j=0;j<m;j++){
    113                         printf("   ");
    114                         for(k=0;k<n;k++)printf("%g ",*(matrix+n*j+k));
    115                         printf("\n");
     113                        _printString_("   ");
     114                        for(k=0;k<n;k++)_printString_(*(matrix+n*j+k) << " ");
     115                        _printLine_("");
    116116                }
    117117        }
    118118}
    119119/*}}}*/
    120 /*FUNCTION DoubleMatArrayParam::Id{{{1*/
     120/*FUNCTION DoubleMatArrayParam::Id{{{*/
    121121int    DoubleMatArrayParam::Id(void){ return -1; }
    122122/*}}}*/
    123 /*FUNCTION DoubleMatArrayParam::MyRank{{{1*/
     123/*FUNCTION DoubleMatArrayParam::MyRank{{{*/
    124124int    DoubleMatArrayParam::MyRank(void){
    125125        extern int my_rank;
     
    127127}
    128128/*}}}*/
    129 /*FUNCTION DoubleMatArrayParam::ObjectEnum{{{1*/
     129/*FUNCTION DoubleMatArrayParam::ObjectEnum{{{*/
    130130int DoubleMatArrayParam::ObjectEnum(void){
    131131
     
    134134}
    135135/*}}}*/
    136 /*FUNCTION DoubleMatArrayParam::copy{{{1*/
     136/*FUNCTION DoubleMatArrayParam::copy{{{*/
    137137Object* DoubleMatArrayParam::copy() {
    138138       
     
    143143
    144144/*DoubleMatArrayParam virtual functions definitions: */
    145 /*FUNCTION DoubleMatArrayParam::GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){{{1*/
    146 void  DoubleMatArrayParam::GetParameterValue(double*** pout_array, int* pout_M,int** pout_mdim_array, int** pout_ndim_array){
     145/*FUNCTION DoubleMatArrayParam::GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){{{*/
     146void  DoubleMatArrayParam::GetParameterValue(IssmDouble*** pout_array, int* pout_M,int** pout_mdim_array, int** pout_ndim_array){
    147147
    148148        int i,m,n;
    149         double* matrix=NULL;
    150         double* out_matrix=NULL;
     149        IssmDouble* matrix=NULL;
     150        IssmDouble* out_matrix=NULL;
    151151
    152152        /*output: */
    153         double** out_array=NULL;
     153        IssmDouble** out_array=NULL;
    154154        int      out_M;
    155155        int*     out_mdim_array=NULL;
     
    159159        out_M=this->M;
    160160        if(out_M){
    161                 out_array=(double**)xmalloc(M*sizeof(double*));
    162                 out_mdim_array=(int*)xmalloc(M*sizeof(int));
    163                 out_ndim_array=(int*)xmalloc(M*sizeof(int));
    164 
    165                 memcpy(out_mdim_array,this->mdim_array,M*sizeof(int));
    166                 memcpy(out_ndim_array,this->ndim_array,M*sizeof(int));
     161                out_array=xNew<IssmDouble*>(M);
     162                out_mdim_array=xNew<int>(M);
     163                out_ndim_array=xNew<int>(M);
     164
     165                xMemCpy<int>(out_mdim_array,this->mdim_array,M);
     166                xMemCpy<int>(out_ndim_array,this->ndim_array,M);
    167167
    168168                for(i=0;i<this->M;i++){
     
    172172
    173173                        if(m*n){
    174                                 out_matrix=(double*)xmalloc(m*n*sizeof(double));
    175                                 memcpy(out_matrix,matrix,m*n*sizeof(double));
     174                                out_matrix=xNew<IssmDouble>(m*n);
     175                                xMemCpy<IssmDouble>(out_matrix,matrix,m*n);
    176176                        }
    177177                        else{
     
    196196}
    197197/*}}}*/
    198 /*FUNCTION DoubleMatArrayParam::GetParameterName{{{1*/
     198/*FUNCTION DoubleMatArrayParam::GetParameterName{{{*/
    199199void DoubleMatArrayParam::GetParameterName(char**pname){
    200200        EnumToStringx(pname,this->enum_type);
    201201}
    202202/*}}}*/
    203 /*FUNCTION DoubleMatArrayParam::SetValue(double** array, int M, int* mdim_array, int* ndim_array){{{1*/
    204 void  DoubleMatArrayParam::SetValue(double** in_array, int in_M, int* in_mdim_array, int* in_ndim_array){
     203/*FUNCTION DoubleMatArrayParam::SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){{{*/
     204void  DoubleMatArrayParam::SetValue(IssmDouble** in_array, int in_M, int* in_mdim_array, int* in_ndim_array){
    205205
    206206        int i,m,n;
    207         double* in_matrix=NULL;
    208         double* matrix=NULL;
     207        IssmDouble* in_matrix=NULL;
     208        IssmDouble* matrix=NULL;
    209209
    210210        /*avoid leak: */
    211         xfree((void**)&mdim_array);
    212         xfree((void**)&ndim_array);
     211        xDelete<int>(mdim_array);
     212        xDelete<int>(ndim_array);
    213213        for(i=0;i<M;i++){
    214214                matrix=array[i];
    215                 xfree((void**)&matrix);
    216         }
    217         xfree((void**)&array);
     215                xDelete<IssmDouble>(matrix);
     216        }
     217        xDelete<IssmDouble*>(array);
    218218
    219219        /*copy data: */
    220220        this->M=in_M;
    221         this->array=(double**)xmalloc(M*sizeof(double*));
    222         this->mdim_array=(int*)xmalloc(M*sizeof(int));
    223         this->ndim_array=(int*)xmalloc(M*sizeof(int));
    224        
    225         memcpy(this->mdim_array,in_mdim_array,M*sizeof(double));
    226         memcpy(this->ndim_array,in_ndim_array,M*sizeof(double));
     221        this->array=xNew<IssmDouble*>(M);
     222        this->mdim_array=xNew<int>(M);
     223        this->ndim_array=xNew<int>(M);
     224       
     225        xMemCpy<int>(this->mdim_array,in_mdim_array,M);
     226        xMemCpy<int>(this->ndim_array,in_ndim_array,M);
    227227
    228228        for(i=0;i<M;i++){
     
    231231                n=in_ndim_array[i];
    232232
    233                 matrix=(double*)xmalloc(m*n*sizeof(double));
    234                 memcpy(matrix,in_matrix,m*n*sizeof(double));
     233                matrix=xNew<IssmDouble>(m*n);
     234                xMemCpy<IssmDouble>(matrix,in_matrix,m*n);
    235235
    236236                this->array[i]=matrix;
     
    239239}
    240240/*}}}*/
    241 /*FUNCTION DoubleMatArrayParam::UnitConversion{{{1*/
     241/*FUNCTION DoubleMatArrayParam::UnitConversion{{{*/
    242242void  DoubleMatArrayParam::UnitConversion(int direction_enum){
    243243        /*go through all matrices and convert: */
    244244        for (int i=0;i<this->M;i++){
    245                 double* matrix=this->array[i];
     245                IssmDouble* matrix=this->array[i];
    246246                int     m=this->mdim_array[i];
    247247                int     n=this->ndim_array[i];
  • issm/trunk/src/c/objects/Params/DoubleMatArrayParam.h

    r12330 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111#ifdef HAVE_CONFIG_H
    1212        #include <config.h>
     
    2424        private:
    2525                int      enum_type;
    26                 double** array; //array of matrices
     26                IssmDouble** array; //array of matrices
    2727                int      M; //size of array
    2828                int*     mdim_array; //m-dimensions of matrices in the array
     
    3030
    3131        public:
    32                 /*DoubleMatArrayParam constructors, destructors: {{{1*/
     32                /*DoubleMatArrayParam constructors, destructors: {{{*/
    3333                DoubleMatArrayParam();
    34                 DoubleMatArrayParam(int enum_type,double** array, int M, int* mdim_array, int* ndim_array);
     34                DoubleMatArrayParam(int enum_type,IssmDouble** array, int M, int* mdim_array, int* ndim_array);
    3535                ~DoubleMatArrayParam();
    3636                /*}}}*/
    37                 /*Object virtual functions definitions:{{{1 */
     37                /*Object virtual functions definitions:{{{ */
    3838                void  Echo();
    3939                void  DeepEcho();
     
    4343                Object* copy();
    4444                /*}}}*/
    45                 /*Param vritual function definitions: {{{1*/
     45                /*Param vritual function definitions: {{{*/
    4646                int   InstanceEnum(){return enum_type;}
    47                 void  GetParameterValue(bool* pbool){_error_("DoubleMatArray param of enum %i (%s) cannot return a bool",enum_type,EnumToStringx(enum_type));}
    48                 void  GetParameterValue(int* pinteger){_error_("DoubleMatArray param of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type));}
    49                 void  GetParameterValue(int** pintarray,int* pM){_error_("DoubleMatArray param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
    50                 void  GetParameterValue(int** pintarray,int* pM,int* pN){_error_("DoubleMatArray param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
    51                 void  GetParameterValue(double* pdouble){_error_("DoubleMatArray param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
    52                 void  GetParameterValue(char** pstring){_error_("DoubleMatArray param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
    53                 void  GetParameterValue(char*** pstringarray,int* pM){_error_("DoubleMatArray param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
    54                 void  GetParameterValue(double** pdoublearray,int* pM){_error_("DoubleMatArray param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
    55                 void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("DoubleMatArray param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
    56                 void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims);
    57                 void  GetParameterValue(Vector** pvec){_error_("DoubleMatArray param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
    58                 void  GetParameterValue(Matrix** pmat){_error_("DoubleMatArray param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
    59                 void  GetParameterValue(FILE** pfid){_error_("DoubleMatArray param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
     47                void  GetParameterValue(bool* pbool){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a bool");}
     48                void  GetParameterValue(int* pinteger){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an integer");}
     49                void  GetParameterValue(int** pintarray,int* pM){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
     50                void  GetParameterValue(int** pintarray,int* pM,int* pN){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
     51                void  GetParameterValue(IssmDouble* pIssmDouble){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble");}
     52                void  GetParameterValue(char** pstring){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string");}
     53                void  GetParameterValue(char*** pstringarray,int* pM){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string array");}
     54                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
     55                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
     56                void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims);
     57                void  GetParameterValue(Vector** pvec){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Vec");}
     58                void  GetParameterValue(Matrix** pmat){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Mat");}
     59                void  GetParameterValue(FILE** pfid){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");}
    6060
    61                 void  SetValue(bool boolean){_error_("DoubleMatArray param of enum %i (%s) cannot hold a boolean",enum_type,EnumToStringx(enum_type));}
    62                 void  SetValue(int integer){_error_("DoubleMatArray param of enum %i (%s) cannot hold an integer",enum_type,EnumToStringx(enum_type));}
    63                 void  SetValue(double scalar){_error_("DoubleMatArray param of enum %i (%s) cannot hold a scalar",enum_type,EnumToStringx(enum_type));}
    64                 void  SetValue(char* string){_error_("DoubleMatArray param of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
    65                 void  SetValue(char** stringarray,int M){_error_("DoubleMatArray param of enum %i (%s) cannot hold a string array",enum_type,EnumToStringx(enum_type));}
    66                 void  SetValue(double* doublearray,int M){_error_("DoubleMatArray param of enum %i (%s) cannot hold a double vec array",enum_type,EnumToStringx(enum_type));}
    67                 void  SetValue(double* doublearray,int M,int N){_error_("DoubleMatArray param of enum %i (%s) cannot hold a double mat array",enum_type,EnumToStringx(enum_type));}
    68                 void  SetValue(int* intarray,int M){_error_("DoubleMatArray param of enum %i (%s) cannot hold a int vec array",enum_type,EnumToStringx(enum_type));}
    69                 void  SetValue(int* intarray,int M,int N){_error_("DoubleMatArray param of enum %i (%s) cannot hold a int mat array",enum_type,EnumToStringx(enum_type));}
    70                 void  SetValue(Vector* vec){_error_("DoubleMatArray param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
    71                 void  SetValue(Matrix* mat){_error_("DoubleMatArray param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
    72                 void  SetValue(FILE* fid){_error_("Bool param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
    73                 void  SetValue(double** array, int M, int* mdim_array, int* ndim_array);
     61                void  SetValue(bool boolean){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a boolean");}
     62                void  SetValue(int integer){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an integer");}
     63                void  SetValue(IssmDouble scalar){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a scalar");}
     64                void  SetValue(char* string){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string");}
     65                void  SetValue(char** stringarray,int M){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string array");}
     66                void  SetValue(IssmDouble* IssmDoublearray,int M){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble vec array");}
     67                void  SetValue(IssmDouble* IssmDoublearray,int M,int N){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble mat array");}
     68                void  SetValue(int* intarray,int M){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int vec array");}
     69                void  SetValue(int* intarray,int M,int N){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int mat array");}
     70                void  SetValue(Vector* vec){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Vec");}
     71                void  SetValue(Matrix* mat){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Mat");}
     72                void  SetValue(FILE* fid){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
     73                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array);
    7474                void  UnitConversion(int direction_enum);
    7575
  • issm/trunk/src/c/objects/Params/DoubleMatParam.cpp

    r12330 r12706  
    44
    55/*header files: */
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*DoubleMatParam constructors and destructor*/
    23 /*FUNCTION DoubleMatParam::DoubleMatParam(){{{1*/
     23/*FUNCTION DoubleMatParam::DoubleMatParam(){{{*/
    2424DoubleMatParam::DoubleMatParam(){
    2525        return;
    2626}
    2727/*}}}*/
    28 /*FUNCTION DoubleMatParam::DoubleMatParam(int enum_type,IssmDoubleMat value){{{1*/
    29 DoubleMatParam::DoubleMatParam(int in_enum_type,double* in_value, int in_M,int in_N){
     28/*FUNCTION DoubleMatParam::DoubleMatParam(int enum_type,IssmDoubleMat value){{{*/
     29DoubleMatParam::DoubleMatParam(int in_enum_type,IssmDouble* in_value, int in_M,int in_N){
    3030
    3131        enum_type=in_enum_type;
     
    3333        N=in_N;
    3434
    35         value=(double*)xmalloc(M*N*sizeof(double));
    36         memcpy(value,in_value,M*N*sizeof(double));
     35        value=xNew<IssmDouble>(M*N);
     36        xMemCpy<IssmDouble>(value,in_value,M*N);
    3737}
    3838/*}}}*/
    39 /*FUNCTION DoubleMatParam::~DoubleMatParam(){{{1*/
     39/*FUNCTION DoubleMatParam::~DoubleMatParam(){{{*/
    4040DoubleMatParam::~DoubleMatParam(){
    41         xfree((void**)&value);
     41        xDelete<IssmDouble>(value);
    4242        return;
    4343}
     
    4545
    4646/*Object virtual functions definitions:*/
    47 /*FUNCTION DoubleMatParam::Echo {{{1*/
     47/*FUNCTION DoubleMatParam::Echo {{{*/
    4848void DoubleMatParam::Echo(void){
    4949
    50         printf("DoubleMatParam:\n");
    51         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    52         printf("   matrix size: %ix%i\n",this->M,this->N);
     50        _printLine_("DoubleMatParam:");
     51        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     52        _printLine_("   matrix size: " << this->M << "x" << this->N);
    5353
    5454}
    5555/*}}}*/
    56 /*FUNCTION DoubleMatParam::DeepEcho{{{1*/
     56/*FUNCTION DoubleMatParam::DeepEcho{{{*/
    5757void DoubleMatParam::DeepEcho(void){
    5858
    5959        int i,j;
    6060       
    61         printf("DoubleMatParam:\n");
    62         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    63         printf("   matrix size: %ix%i\n",this->M,this->N);
     61        _printLine_("DoubleMatParam:");
     62        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     63        _printLine_("   matrix size: " << this->M << "x" << this->N);
    6464        for(i=0;i<this->M;i++){
    6565                for(i=0;i<this->N;i++){
    66                         printf("%i %i %g\n",i,j,*(this->value+N*i+j));
     66                        _printLine_(i << " " << j << " " << *(this->value+N*i+j));
    6767                }
    6868        }
    6969}
    7070/*}}}*/
    71 /*FUNCTION DoubleMatParam::Id{{{1*/
     71/*FUNCTION DoubleMatParam::Id{{{*/
    7272int    DoubleMatParam::Id(void){ return -1; }
    7373/*}}}*/
    74 /*FUNCTION DoubleMatParam::MyRank{{{1*/
     74/*FUNCTION DoubleMatParam::MyRank{{{*/
    7575int    DoubleMatParam::MyRank(void){
    7676        extern int my_rank;
     
    7878}
    7979/*}}}*/
    80 /*FUNCTION DoubleMatParam::ObjectEnum{{{1*/
     80/*FUNCTION DoubleMatParam::ObjectEnum{{{*/
    8181int DoubleMatParam::ObjectEnum(void){
    8282
     
    8585}
    8686/*}}}*/
    87 /*FUNCTION DoubleMatParam::copy{{{1*/
     87/*FUNCTION DoubleMatParam::copy{{{*/
    8888Object* DoubleMatParam::copy() {
    8989       
     
    9494
    9595/*DoubleMatParam virtual functions definitions: */
    96 /*FUNCTION DoubleMatParam::GetParameterValue(double** pdoublearray,int* pM,int* pN){{{1*/
    97 void  DoubleMatParam::GetParameterValue(double** pdoublearray,int* pM,int* pN){
    98         double* output=NULL;
     96/*FUNCTION DoubleMatParam::GetParameterValue(IssmDouble** pIssmDoublearray,int* pM,int* pN){{{*/
     97void  DoubleMatParam::GetParameterValue(IssmDouble** pIssmDoublearray,int* pM,int* pN){
     98        IssmDouble* output=NULL;
    9999
    100         output=(double*)xmalloc((int)(M*N*sizeof(double)));
    101         memcpy(output,value,M*N*sizeof(double));
     100        output=xNew<IssmDouble>(M*N);
     101        xMemCpy<IssmDouble>(output,value,M*N);
    102102
    103103        /*Assign output pointers:*/
    104104        if(pM) *pM=M;
    105105        if(pN) *pN=N;
    106         *pdoublearray=output;
     106        *pIssmDoublearray=output;
    107107}
    108108/*}}}*/
    109 /*FUNCTION DoubleMatParam::GetParameterValue(int** pintarray,int* pM,int* pN){{{1*/
     109/*FUNCTION DoubleMatParam::GetParameterValue(int** pintarray,int* pM,int* pN){{{*/
    110110void  DoubleMatParam::GetParameterValue(int** pintarray,int* pM,int* pN){
    111         _error_("DoubleMat of enum %i (%s) cannot return an array of int",enum_type,EnumToStringx(enum_type));
     111        _error2_("DoubleMat of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of int");
    112112}
    113113/*}}}*/
    114 /*FUNCTION DoubleMatParam::GetParameterName{{{1*/
     114/*FUNCTION DoubleMatParam::GetParameterName{{{*/
    115115void DoubleMatParam::GetParameterName(char**pname){
    116116        EnumToStringx(pname,this->enum_type);
    117117}
    118118/*}}}*/
    119 /*FUNCTION DoubleMatParam::SetValue{{{1*/
    120 void  DoubleMatParam::SetValue(double* doublearray,int in_M,int in_N){
     119/*FUNCTION DoubleMatParam::SetValue{{{*/
     120void  DoubleMatParam::SetValue(IssmDouble* IssmDoublearray,int in_M,int in_N){
    121121
    122122        /*avoid leak: */
    123         xfree((void**)&this->value);
     123        xDelete<IssmDouble>(this->value);
    124124
    125         this->value=(double*)xmalloc(in_M*in_N*sizeof(double));
    126         memcpy(this->value,doublearray,in_M*in_N*sizeof(double));
     125        this->value=xNew<IssmDouble>(in_M*in_N);
     126        xMemCpy<IssmDouble>(this->value,IssmDoublearray,in_M*in_N);
    127127
    128128        this->M=in_M;
     
    130130}
    131131/*}}}*/
    132 /*FUNCTION DoubleMatParam::UnitConversion{{{1*/
     132/*FUNCTION DoubleMatParam::UnitConversion{{{*/
    133133void  DoubleMatParam::UnitConversion(int direction_enum){
    134134        ::UnitConversion(this->value,this->M*this->N,direction_enum,this->enum_type);
     
    137137               
    138138/*diverse: */
    139 /*FUNCTION DoubleMatParam::GetPointer{{{1*/
    140 double* DoubleMatParam::GetPointer(void){
     139/*FUNCTION DoubleMatParam::GetPointer{{{*/
     140IssmDouble* DoubleMatParam::GetPointer(void){
    141141        return this->value;
    142142}
  • issm/trunk/src/c/objects/Params/DoubleMatParam.h

    r12330 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111#ifdef HAVE_CONFIG_H
    1212        #include <config.h>
     
    2424        protected:
    2525                int enum_type;
    26                 double* value;
     26                IssmDouble* value;
    2727                int M;
    2828                int N;
    2929
    3030        public:
    31                 /*DoubleMatParam constructors, destructors: {{{1*/
     31                /*DoubleMatParam constructors, destructors: {{{*/
    3232                DoubleMatParam();
    3333                DoubleMatParam(int enum_type,IssmDouble* value,int M,int N);
    3434                ~DoubleMatParam();
    3535                /*}}}*/
    36                 /*Object virtual functions definitions:{{{1 */
     36                /*Object virtual functions definitions:{{{ */
    3737                void  Echo();
    3838                void  DeepEcho();
     
    4242                Object* copy();
    4343                /*}}}*/
    44                 /*Param vritual function definitions: {{{1*/
     44                /*Param vritual function definitions: {{{*/
    4545                int   InstanceEnum(){return enum_type;}
    46                 void  GetParameterValue(bool* pbool){_error_("DoubleMat param of enum %i (%s) cannot return a bool",enum_type,EnumToStringx(enum_type));}
    47                 void  GetParameterValue(int* pinteger){_error_("DoubleMat param of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type));}
    48                 void  GetParameterValue(int** pintarray,int* pM){_error_("DoubleMat param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
     46                void  GetParameterValue(bool* pbool){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a bool");}
     47                void  GetParameterValue(int* pinteger){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an integer");}
     48                void  GetParameterValue(int** pintarray,int* pM){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
    4949                void  GetParameterValue(int** pintarray,int* pM,int* pN);
    50                 void  GetParameterValue(double* pdouble){_error_("DoubleMat param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
    51                 void  GetParameterValue(char** pstring){_error_("DoubleMat param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
    52                 void  GetParameterValue(char*** pstringarray,int* pM){_error_("DoubleMat param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
    53                 void  GetParameterValue(double** pdoublearray,int* pM){_error_("DoubleMat param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
    54                 void  GetParameterValue(double** pdoublearray,int* pM,int* pN);
    55                 void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("DoubleMat param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
    56                 void  GetParameterValue(Vector** pvec){_error_("DoubleMat param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
    57                 void  GetParameterValue(Matrix** pmat){_error_("DoubleMat param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
    58                 void  GetParameterValue(FILE** pfid){_error_("DoubleMat param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
     50                void  GetParameterValue(IssmDouble* pIssmDouble){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble");}
     51                void  GetParameterValue(char** pstring){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string");}
     52                void  GetParameterValue(char*** pstringarray,int* pM){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string array");}
     53                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
     54                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM,int* pN);
     55                void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix array");}
     56                void  GetParameterValue(Vector** pvec){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Vec");}
     57                void  GetParameterValue(Matrix** pmat){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Mat");}
     58                void  GetParameterValue(FILE** pfid){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");}
    5959
    60                 void  SetValue(bool boolean){_error_("DoubleMat param of enum %i (%s) cannot hold a boolean",enum_type,EnumToStringx(enum_type));}
    61                 void  SetValue(int integer){_error_("DoubleMat param of enum %i (%s) cannot hold an integer",enum_type,EnumToStringx(enum_type));}
    62                 void  SetValue(double scalar){_error_("DoubleMat param of enum %i (%s) cannot hold a scalar",enum_type,EnumToStringx(enum_type));}
    63                 void  SetValue(char* string){_error_("DoubleMat param of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
    64                 void  SetValue(char** stringarray,int M){_error_("DoubleMat param of enum %i (%s) cannot hold a string array",enum_type,EnumToStringx(enum_type));}
    65                 void  SetValue(double* doublearray,int M){_error_("DoubleMat param of enum %i (%s) cannot hold a double vec array",enum_type,EnumToStringx(enum_type));}
    66                 void  SetValue(double* doublearray,int M,int N);
    67                 void  SetValue(int* intarray,int M){_error_("DoubleMat param of enum %i (%s) cannot hold a int vec array",enum_type,EnumToStringx(enum_type));}
    68                 void  SetValue(int* intarray,int M,int N){_error_("DoubleMat param of enum %i (%s) cannot hold a int mat array",enum_type,EnumToStringx(enum_type));};
    69                 void  SetValue(Vector* vec){_error_("DoubleMat param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
    70                 void  SetValue(Matrix* mat){_error_("DoubleMat param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
    71                 void  SetValue(FILE* fid){_error_("DoubleMat param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
    72                 void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("DoubleMat param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
     60                void  SetValue(bool boolean){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a boolean");}
     61                void  SetValue(int integer){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an integer");}
     62                void  SetValue(IssmDouble scalar){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a scalar");}
     63                void  SetValue(char* string){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string");}
     64                void  SetValue(char** stringarray,int M){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string array");}
     65                void  SetValue(IssmDouble* IssmDoublearray,int M){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble vec array");}
     66                void  SetValue(IssmDouble* IssmDoublearray,int M,int N);
     67                void  SetValue(int* intarray,int M){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int vec array");}
     68                void  SetValue(int* intarray,int M,int N){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int mat array");};
     69                void  SetValue(Vector* vec){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Vec");}
     70                void  SetValue(Matrix* mat){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Mat");}
     71                void  SetValue(FILE* fid){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
     72                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an array of matrices");}
    7373                void  UnitConversion(int direction_enum);
    74                 double* GetPointer(void);
     74                IssmDouble* GetPointer(void);
    7575
    7676                void GetParameterName(char**pname);
  • issm/trunk/src/c/objects/Params/DoubleParam.cpp

    r12330 r12706  
    1818
    1919/*DoubleParam constructors and destructor*/
    20 /*FUNCTION DoubleParam::DoubleParam(){{{1*/
     20/*FUNCTION DoubleParam::DoubleParam(){{{*/
    2121DoubleParam::DoubleParam(){
    2222        return;
    2323}
    2424/*}}}*/
    25 /*FUNCTION DoubleParam::DoubleParam(int enum_type,IssmDouble value){{{1*/
     25/*FUNCTION DoubleParam::DoubleParam(int enum_type,IssmDouble value){{{*/
    2626DoubleParam::DoubleParam(int in_enum_type,IssmDouble in_value){
    2727
     
    3030}
    3131/*}}}*/
    32 /*FUNCTION DoubleParam::~DoubleParam(){{{1*/
     32/*FUNCTION DoubleParam::~DoubleParam(){{{*/
    3333DoubleParam::~DoubleParam(){
    3434        return;
     
    3737
    3838/*Object virtual functions definitions:*/
    39 /*FUNCTION DoubleParam::Echo {{{1*/
     39/*FUNCTION DoubleParam::Echo {{{*/
    4040void DoubleParam::Echo(void){
    4141        this->DeepEcho();
    4242}
    4343/*}}}*/
    44 /*FUNCTION DoubleParam::DeepEcho{{{1*/
     44/*FUNCTION DoubleParam::DeepEcho{{{*/
    4545void DoubleParam::DeepEcho(void){
    4646
    47         printf("DoubleParam:\n");
    48         printf("   enum:  %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    49         printf("   value: %g\n",this->value);
     47        _printLine_("DoubleParam:");
     48        _printLine_("   enum:  " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     49        _printLine_("   value: " << this->value);
    5050}
    5151/*}}}*/
    52 /*FUNCTION DoubleParam::Id{{{1*/
     52/*FUNCTION DoubleParam::Id{{{*/
    5353int    DoubleParam::Id(void){ return -1; }
    5454/*}}}*/
    55 /*FUNCTION DoubleParam::MyRank{{{1*/
     55/*FUNCTION DoubleParam::MyRank{{{*/
    5656int    DoubleParam::MyRank(void){
    5757        extern int my_rank;
     
    5959}
    6060/*}}}*/
    61 /*FUNCTION DoubleParam::ObjectEnum{{{1*/
     61/*FUNCTION DoubleParam::ObjectEnum{{{*/
    6262int DoubleParam::ObjectEnum(void){
    6363
     
    6666}
    6767/*}}}*/
    68 /*FUNCTION DoubleParam::copy{{{1*/
     68/*FUNCTION DoubleParam::copy{{{*/
    6969Object* DoubleParam::copy() {
    7070       
     
    7575
    7676/*DoubleParam virtual functions definitions: */
    77 /*FUNCTION DoubleParam::GetParameterName{{{1*/
     77/*FUNCTION DoubleParam::GetParameterName{{{*/
    7878void DoubleParam::GetParameterName(char**pname){
    7979        EnumToStringx(pname,this->enum_type);
    8080}
    8181/*}}}*/
    82 /*FUNCTION DoubleParam::GetParameterValue(int* pinteger){{{1*/
     82/*FUNCTION DoubleParam::GetParameterValue(int* pinteger){{{*/
    8383void DoubleParam::GetParameterValue(int* pinteger){
    84         _error_("Double param of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type));
     84        _error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an integer");
    8585}
    8686/*}}}*/
    87 /*FUNCTION DoubleParam::GetParameterValue(bool* pbool){{{1*/
     87/*FUNCTION DoubleParam::GetParameterValue(bool* pbool){{{*/
    8888void DoubleParam::GetParameterValue(bool* pbool){
    89         _error_("Double param of enum %i (%s) cannot return an bool",enum_type,EnumToStringx(enum_type));
     89        _error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an bool");
    9090}
    9191/*}}}*/
    92 /*FUNCTION DoubleParam::GetParameterValue(int** pintarray,int* pM){{{1*/
     92/*FUNCTION DoubleParam::GetParameterValue(int** pintarray,int* pM){{{*/
    9393void DoubleParam::GetParameterValue(int** pintarray,int* pM){
    94         _error_("Double param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));
     94        _error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");
    9595}
    9696/*}}}*/
    97 /*FUNCTION DoubleParam::GetParameterValue(int** pintarray,int* pM,int* pN){{{1*/
     97/*FUNCTION DoubleParam::GetParameterValue(int** pintarray,int* pM,int* pN){{{*/
    9898void DoubleParam::GetParameterValue(int** pintarray,int* pM,int* pN){
    99         _error_("Double param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));
     99        _error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");
    100100}
    101101/*}}}*/
    102 /*FUNCTION DoubleParam::GetParameterValue(double** pdoublearray,int* pM){{{1*/
    103 void DoubleParam::GetParameterValue(double** pdoublearray,int* pM){
    104         _error_("Double param of enum %i (%s) cannot return an array of double",enum_type,EnumToStringx(enum_type));
     102/*FUNCTION DoubleParam::GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){{{*/
     103void DoubleParam::GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){
     104        _error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of IssmDouble");
    105105}
    106106/*}}}*/
    107 /*FUNCTION DoubleParam::GetParameterValue(double** pdoublearray,int* pM,int* pN){{{1*/
    108 void DoubleParam::GetParameterValue(double** pdoublearray,int* pM,int* pN){
    109         _error_("Double param of enum %i (%s) cannot return an array of double",enum_type,EnumToStringx(enum_type));
     107/*FUNCTION DoubleParam::GetParameterValue(IssmDouble** pIssmDoublearray,int* pM,int* pN){{{*/
     108void DoubleParam::GetParameterValue(IssmDouble** pIssmDoublearray,int* pM,int* pN){
     109        _error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of IssmDouble");
    110110}
    111111/*}}}*/
    112 /*FUNCTION DoubleParam::UnitConversion{{{1*/
     112/*FUNCTION DoubleParam::UnitConversion{{{*/
    113113void  DoubleParam::UnitConversion(int direction_enum){
    114114        ::UnitConversion(&this->value,1,direction_enum,this->enum_type);
  • issm/trunk/src/c/objects/Params/DoubleParam.h

    r12330 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111#ifdef HAVE_CONFIG_H
    1212        #include <config.h>
     
    2828
    2929        public:
    30                 /*DoubleParam constructors, destructors: {{{1*/
     30                /*DoubleParam constructors, destructors: {{{*/
    3131                DoubleParam();
    3232                DoubleParam(int enum_type,IssmDouble value);
    3333                ~DoubleParam();
    3434                /*}}}*/
    35                 /*Object virtual functions definitions:{{{1 */
     35                /*Object virtual functions definitions:{{{ */
    3636                void  Echo();
    3737                void  DeepEcho();
     
    4141                Object* copy();
    4242                /*}}}*/
    43                 /*Param vritual function definitions: {{{1*/
     43                /*Param vritual function definitions: {{{*/
    4444                int   InstanceEnum(){return enum_type;}
    4545                void  GetParameterValue(bool* pbool);
     
    4747                void  GetParameterValue(int** pintarray,int* pM);
    4848                void  GetParameterValue(int** pintarray,int* pM,int* pN);
    49                 void  GetParameterValue(double* pdouble){*pdouble=value;}
    50                 void  GetParameterValue(char** pstring){_error_("Double param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
    51                 void  GetParameterValue(char*** pstringarray,int* pM){_error_("Double param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
    52                 void  GetParameterValue(double** pdoublearray,int* pM);
    53                 void  GetParameterValue(double** pdoublearray,int* pM, int* pN);
    54                 void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("Double param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
    55                 void  GetParameterValue(Vector** pvec){_error_("Double param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
    56                 void  GetParameterValue(Matrix** pmat){_error_("Double param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
    57                 void  GetParameterValue(FILE** pfid){_error_("Double param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
     49                void  GetParameterValue(IssmDouble* pIssmDouble){*pIssmDouble=value;}
     50                void  GetParameterValue(char** pstring){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string");}
     51                void  GetParameterValue(char*** pstringarray,int* pM){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string array");}
     52                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM);
     53                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN);
     54                void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix array");}
     55                void  GetParameterValue(Vector** pvec){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Vec");}
     56                void  GetParameterValue(Matrix** pmat){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Mat");}
     57                void  GetParameterValue(FILE** pfid){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");}
    5858
    59                 void  SetValue(bool boolean){this->value=(double)boolean;}
    60                 void  SetValue(int integer){this->value=(double)integer;}
    61                 void  SetValue(double scalar){this->value=(double)scalar;}
    62                 void  SetValue(char* string){_error_("Double param of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
    63                 void  SetValue(char** stringarray,int M){_error_("Double param of enum %i (%s) cannot hold a string array",enum_type,EnumToStringx(enum_type));}
    64                 void  SetValue(double* doublearray,int M){_error_("Double param of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
    65                 void  SetValue(double* pdoublearray,int M,int N){_error_("Double param of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
    66                 void  SetValue(int* intarray,int M){_error_("Double param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
    67                 void  SetValue(int* pintarray,int M,int N){_error_("Double param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
    68                 void  SetValue(Vector* vec){_error_("Double param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
    69                 void  SetValue(Matrix* mat){_error_("Double param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
    70                 void  SetValue(FILE* fid){_error_("Double param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
    71                 void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("Double param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
     59                void  SetValue(bool boolean){this->value=(IssmDouble)boolean;}
     60                void  SetValue(int integer){this->value=(IssmDouble)integer;}
     61                void  SetValue(IssmDouble scalar){this->value=(IssmDouble)scalar;}
     62                void  SetValue(char* string){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string");}
     63                void  SetValue(char** stringarray,int M){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string array");}
     64                void  SetValue(IssmDouble* IssmDoublearray,int M){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
     65                void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
     66                void  SetValue(int* intarray,int M){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int array");}
     67                void  SetValue(int* pintarray,int M,int N){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int array");}
     68                void  SetValue(Vector* vec){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Vec");}
     69                void  SetValue(Matrix* mat){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Mat");}
     70                void  SetValue(FILE* fid){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
     71                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an array of matrices");}
    7272                void  UnitConversion(int direction_enum);
    7373
  • issm/trunk/src/c/objects/Params/DoubleTransientMatParam.cpp

    r10660 r12706  
    44
    55/*header files: */
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2020/*}}}*/
    2121
    22 /*FUNCTION DoubleTransientMatParam::DoubleTransientMatParam(int enum_type,IssmDoubleMat value){{{1*/
    23 DoubleTransientMatParam::DoubleTransientMatParam(int in_enum_type,double* in_value, int in_M,int in_N):DoubleMatParam(in_enum_type,in_value,in_M,in_N){
     22/*FUNCTION DoubleTransientMatParam::DoubleTransientMatParam(int enum_type,IssmDoubleMat value){{{*/
     23DoubleTransientMatParam::DoubleTransientMatParam(int in_enum_type,IssmDouble* in_value, int in_M,int in_N):DoubleMatParam(in_enum_type,in_value,in_M,in_N){
    2424}
    2525/*}}}*/
    2626
    27 /*FUNCTION DoubleTransientMatParam::UnitConversion{{{1*/
     27/*FUNCTION DoubleTransientMatParam::UnitConversion{{{*/
    2828void  DoubleTransientMatParam::UnitConversion(int direction_enum){
    2929        ::UnitConversion(this->value,(this->M-1)*this->N,direction_enum,this->enum_type);
  • issm/trunk/src/c/objects/Params/DoubleTransientMatParam.h

    r12330 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111#ifdef HAVE_CONFIG_H
    1212        #include <config.h>
     
    2323
    2424        public:
    25                 /*DoubleTransientMatParam constructors, destructors: {{{1*/
     25                /*DoubleTransientMatParam constructors, destructors: {{{*/
    2626                DoubleTransientMatParam(int enum_type,IssmDouble* value,int M,int N);
    2727                /*}}}*/
    28                 /*Param vritual function definitions: {{{1*/
     28                /*Param vritual function definitions: {{{*/
    2929                void  UnitConversion(int direction_enum);
    3030                /*}}}*/
  • issm/trunk/src/c/objects/Params/DoubleVecParam.cpp

    r12330 r12706  
    44
    55/*header files: */
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*DoubleVecParam constructors and destructor*/
    23 /*FUNCTION DoubleVecParam::DoubleVecParam(){{{1*/
     23/*FUNCTION DoubleVecParam::DoubleVecParam(){{{*/
    2424DoubleVecParam::DoubleVecParam(){
    2525        return;
    2626}
    2727/*}}}*/
    28 /*FUNCTION DoubleVecParam::DoubleVecParam(int enum_type,IssmDoubleVec values,int M){{{1*/
    29 DoubleVecParam::DoubleVecParam(int in_enum_type,double* in_values, int in_M){
     28/*FUNCTION DoubleVecParam::DoubleVecParam(int enum_type,IssmDoubleVec values,int M){{{*/
     29DoubleVecParam::DoubleVecParam(int in_enum_type,IssmDouble* in_values, int in_M){
    3030
    3131        enum_type=in_enum_type;
    3232        M=in_M;
    3333
    34         values=(double*)xmalloc(M*sizeof(double));
    35         memcpy(values,in_values,M*sizeof(double));
     34        values=xNew<IssmDouble>(M);
     35        xMemCpy<IssmDouble>(values,in_values,M);
    3636}
    3737/*}}}*/
    38 /*FUNCTION DoubleVecParam::~DoubleVecParam(){{{1*/
     38/*FUNCTION DoubleVecParam::~DoubleVecParam(){{{*/
    3939DoubleVecParam::~DoubleVecParam(){
    40         xfree((void**)&values);
     40        xDelete<IssmDouble>(values);
    4141        return;
    4242}
     
    4444
    4545/*Object virtual functions definitions:*/
    46 /*FUNCTION DoubleVecParam::Echo {{{1*/
     46/*FUNCTION DoubleVecParam::Echo {{{*/
    4747void DoubleVecParam::Echo(void){
    4848
    49         printf("DoubleVecParam:\n");
    50         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    51         printf("   vector size: %i\n",this->M);
     49        _printLine_("DoubleVecParam:");
     50        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     51        _printLine_("   vector size: " << this->M);
    5252
    5353}
    5454/*}}}*/
    55 /*FUNCTION DoubleVecParam::DeepEcho{{{1*/
     55/*FUNCTION DoubleVecParam::DeepEcho{{{*/
    5656void DoubleVecParam::DeepEcho(void){
    5757
    5858        int i;
    5959       
    60         printf("DoubleVecParam:\n");
    61         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    62         printf("   vector size: %i\n",this->M);
     60        _printLine_("DoubleVecParam:");
     61        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     62        _printLine_("   vector size: " << this->M);
    6363        for(i=0;i<this->M;i++){
    64                 printf("%i %g\n",i,this->values[i]);
     64                _printLine_(i << " " << this->values[i]);
    6565        }
    6666}
    6767/*}}}*/
    68 /*FUNCTION DoubleVecParam::Id{{{1*/
     68/*FUNCTION DoubleVecParam::Id{{{*/
    6969int    DoubleVecParam::Id(void){ return -1; }
    7070/*}}}*/
    71 /*FUNCTION DoubleVecParam::MyRank{{{1*/
     71/*FUNCTION DoubleVecParam::MyRank{{{*/
    7272int    DoubleVecParam::MyRank(void){
    7373        extern int my_rank;
     
    7575}
    7676/*}}}*/
    77 /*FUNCTION DoubleVecParam::ObjectEnum{{{1*/
     77/*FUNCTION DoubleVecParam::ObjectEnum{{{*/
    7878int DoubleVecParam::ObjectEnum(void){
    7979
     
    8282}
    8383/*}}}*/
    84 /*FUNCTION DoubleVecParam::copy{{{1*/
     84/*FUNCTION DoubleVecParam::copy{{{*/
    8585Object* DoubleVecParam::copy() {
    8686       
     
    9191
    9292/*DoubleVecParam virtual functions definitions: */
    93 /*FUNCTION DoubleVecParam::GetParameterValue(double** pdoublearray,int* pM){{{1*/
    94 void  DoubleVecParam::GetParameterValue(double** pdoublearray,int* pM){
    95         double* output=NULL;
     93/*FUNCTION DoubleVecParam::GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){{{*/
     94void  DoubleVecParam::GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){
     95        IssmDouble* output=NULL;
    9696        int M;
    9797
    9898        M=this->M;
    99         output=(double*)xmalloc(M*sizeof(double));
    100         memcpy(output,values,M*sizeof(double));
     99        output=xNew<IssmDouble>(M);
     100        xMemCpy<IssmDouble>(output,values,M);
    101101
    102102        /*Assign output pointers:*/
    103103        if(pM) *pM=M;
    104         *pdoublearray=output;
     104        *pIssmDoublearray=output;
    105105}
    106106/*}}}*/
    107 /*FUNCTION DoubleVecParam::GetParameterValue(double** pdoublearray,int* pM){{{1*/
    108 void  DoubleVecParam::GetParameterValue(double** pdoublearray,int* pM,int* pN){
    109         double* output=NULL;
     107/*FUNCTION DoubleVecParam::GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){{{*/
     108void  DoubleVecParam::GetParameterValue(IssmDouble** pIssmDoublearray,int* pM,int* pN){
     109        IssmDouble* output=NULL;
    110110        int M;
    111111        int N;
     
    113113        N=1;
    114114        M=this->M;
    115         output=(double*)xmalloc(M*sizeof(double));
    116         memcpy(output,values,M*sizeof(double));
     115        output=xNew<IssmDouble>(M);
     116        xMemCpy<IssmDouble>(output,values,M);
    117117
    118118        /*Assign output pointers:*/
    119119        if(pM) *pM=M;
    120120        if(pN) *pN=N;
    121         *pdoublearray=output;
     121        *pIssmDoublearray=output;
    122122}
    123123/*}}}*/
    124 /*FUNCTION DoubleVecParam::GetParameterValue(int** pintarray,int* pM){{{1*/
     124/*FUNCTION DoubleVecParam::GetParameterValue(int** pintarray,int* pM){{{*/
    125125void  DoubleVecParam::GetParameterValue(int** pintarray,int* pM){
    126         _error_("DoubleVec param of enum %i (%s) cannot return an array of int",enum_type,EnumToStringx(enum_type));
     126        _error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of int");
    127127}
    128128/*}}}*/
    129 /*FUNCTION DoubleVecParam::GetParameterName{{{1*/
     129/*FUNCTION DoubleVecParam::GetParameterName{{{*/
    130130void DoubleVecParam::GetParameterName(char**pname){
    131131        EnumToStringx(pname,this->enum_type);
    132132}
    133133/*}}}*/
    134 /*FUNCTION DoubleVecParam::SetValue{{{1*/
    135 void  DoubleVecParam::SetValue(double* doublearray,int in_M){
     134/*FUNCTION DoubleVecParam::SetValue{{{*/
     135void  DoubleVecParam::SetValue(IssmDouble* IssmDoublearray,int in_M){
    136136
    137137        /*avoid leak: */
    138         xfree((void**)&this->values);
     138        xDelete<IssmDouble>(this->values);
    139139
    140         this->values=(double*)xmalloc(in_M*sizeof(double));
    141         memcpy(this->values,doublearray,in_M*sizeof(double));
     140        this->values=xNew<IssmDouble>(in_M);
     141        xMemCpy<IssmDouble>(this->values,IssmDoublearray,in_M);
    142142
    143143        this->M=in_M;
    144144}
    145145/*}}}*/
    146 /*FUNCTION DoubleVecParam::UnitConversion{{{1*/
     146/*FUNCTION DoubleVecParam::UnitConversion{{{*/
    147147void  DoubleVecParam::UnitConversion(int direction_enum){
    148148        ::UnitConversion(this->values,this->M,direction_enum,this->enum_type);
  • issm/trunk/src/c/objects/Params/DoubleVecParam.h

    r12330 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111#ifdef HAVE_CONFIG_H
    1212        #include <config.h>
     
    2828
    2929        public:
    30                 /*DoubleVecParam constructors, destructors: {{{1*/
     30                /*DoubleVecParam constructors, destructors: {{{*/
    3131                DoubleVecParam();
    3232                DoubleVecParam(int enum_type,IssmDouble* values,int M);
    3333                ~DoubleVecParam();
    3434                /*}}}*/
    35                 /*Object virtual functions definitions:{{{1 */
     35                /*Object virtual functions definitions:{{{ */
    3636                void  Echo();
    3737                void  DeepEcho();
     
    4141                Object* copy();
    4242                /*}}}*/
    43                 /*Param virtual functions definitions: {{{1*/
     43                /*Param virtual functions definitions: {{{*/
    4444                int   InstanceEnum(){return enum_type;}
    45                 void  GetParameterValue(bool* pbool){_error_("DoubleVec param of enum %i (%s) cannot return a bool",enum_type,EnumToStringx(enum_type));}
    46                 void  GetParameterValue(int* pinteger){_error_("DoubleVec param of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type));}
     45                void  GetParameterValue(bool* pbool){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a bool");}
     46                void  GetParameterValue(int* pinteger){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an integer");}
    4747                void  GetParameterValue(int** pintarray,int* pM);
    48                 void  GetParameterValue(int** pintarray,int* pM,int* pN){_error_("DoubleVec param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));};
    49                 void  GetParameterValue(double* pdouble){_error_("DoubleVec param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
    50                 void  GetParameterValue(char** pstring){_error_("DoubleVec param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
    51                 void  GetParameterValue(char*** pstringarray,int* pM){_error_("DoubleVec param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
    52                 void  GetParameterValue(double** pdoublearray,int* pM);
    53                 void  GetParameterValue(double** pdoublearray,int* pM, int* pN);
    54                 void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("DoubleVec param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
    55                 void  GetParameterValue(Vector** pvec){_error_("DoubleVec param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
    56                 void  GetParameterValue(Matrix** pmat){_error_("DoubleVec param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
    57                 void  GetParameterValue(FILE** pfid){_error_("DoubleVec param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
     48                void  GetParameterValue(int** pintarray,int* pM,int* pN){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");};
     49                void  GetParameterValue(IssmDouble* pIssmDouble){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble");}
     50                void  GetParameterValue(char** pstring){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string");}
     51                void  GetParameterValue(char*** pstringarray,int* pM){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string array");}
     52                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM);
     53                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN);
     54                void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix array");}
     55                void  GetParameterValue(Vector** pvec){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Vec");}
     56                void  GetParameterValue(Matrix** pmat){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Mat");}
     57                void  GetParameterValue(FILE** pfid){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");}
    5858
    59                 void  SetValue(bool boolean){_error_("DoubleVec param of enum %i (%s) cannot hold a boolean",enum_type,EnumToStringx(enum_type));}
    60                 void  SetValue(int integer){_error_("DoubleVec param of enum %i (%s) cannot hold an integer",enum_type,EnumToStringx(enum_type));}
    61                 void  SetValue(double scalar){_error_("DoubleVec param of enum %i (%s) cannot hold a scalar",enum_type,EnumToStringx(enum_type));}
    62                 void  SetValue(char* string){_error_("DoubleVec param of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
    63                 void  SetValue(char** stringarray,int M){_error_("DoubleVec param of enum %i (%s) cannot hold a string array",enum_type,EnumToStringx(enum_type));}
    64                 void  SetValue(double* doublearray,int M);
    65                 void  SetValue(double* pdoublearray,int M,int N){_error_("DoubleVec param of enum %i (%s) cannot hold a double mat array",enum_type,EnumToStringx(enum_type));}
    66                 void  SetValue(int* intarray,int M){_error_("DoubleVec param of enum %i (%s) cannot hold a int mat array",enum_type,EnumToStringx(enum_type));};
    67                 void  SetValue(int* pintarray,int M,int N){_error_("DoubleVec param of enum %i (%s) cannot hold a int mat array",enum_type,EnumToStringx(enum_type));}
    68                 void  SetValue(Vector* vec){_error_("DoubleVec param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
    69                 void  SetValue(Matrix* mat){_error_("DoubleVec param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
    70                 void  SetValue(FILE* fid){_error_("DoubleVec param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
    71                 void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("DoubleVec param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
     59                void  SetValue(bool boolean){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a boolean");}
     60                void  SetValue(int integer){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an integer");}
     61                void  SetValue(IssmDouble scalar){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a scalar");}
     62                void  SetValue(char* string){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string");}
     63                void  SetValue(char** stringarray,int M){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string array");}
     64                void  SetValue(IssmDouble* IssmDoublearray,int M);
     65                void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble mat array");}
     66                void  SetValue(int* intarray,int M){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int mat array");};
     67                void  SetValue(int* pintarray,int M,int N){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int mat array");}
     68                void  SetValue(Vector* vec){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Vec");}
     69                void  SetValue(Matrix* mat){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Mat");}
     70                void  SetValue(FILE* fid){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
     71                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an array of matrices");}
    7272                void  UnitConversion(int direction_enum);
    7373               
  • issm/trunk/src/c/objects/Params/FileParam.cpp

    r12330 r12706  
    44
    55/*header files: */
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*FileParam constructors and destructor*/
    23 /*FUNCTION FileParam::FileParam(){{{1*/
     23/*FUNCTION FileParam::FileParam(){{{*/
    2424FileParam::FileParam(){
    2525        return;
    2626}
    2727/*}}}*/
    28 /*FUNCTION FileParam::FileParam(int enum_type,FILE *value){{{1*/
     28/*FUNCTION FileParam::FileParam(int enum_type,FILE *value){{{*/
    2929FileParam::FileParam(int in_enum_type,FILE* in_value){
    3030
     
    3333}
    3434/*}}}*/
    35 /*FUNCTION FileParam::~FileParam(){{{1*/
     35/*FUNCTION FileParam::~FileParam(){{{*/
    3636FileParam::~FileParam(){
    3737        return;
     
    4040
    4141/*Object virtual functions definitions:*/
    42 /*FUNCTION FileParam::Echo {{{1*/
     42/*FUNCTION FileParam::Echo {{{*/
    4343void FileParam::Echo(void){
    4444        this->DeepEcho();
    4545}
    4646/*}}}*/
    47 /*FUNCTION FileParam::DeepEcho{{{1*/
     47/*FUNCTION FileParam::DeepEcho{{{*/
    4848void FileParam::DeepEcho(void){
    4949
    50         printf("FileParam:\n");
    51         printf("   enum:  %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    52         printf("   value: %p\n",this->value);
     50        _printLine_("FileParam:");
     51        _printLine_("   enum:  " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     52        _printLine_("   value: " << this->value);
    5353}
    5454/*}}}*/
    55 /*FUNCTION FileParam::Id{{{1*/
     55/*FUNCTION FileParam::Id{{{*/
    5656int    FileParam::Id(void){ return -1; }
    5757/*}}}*/
    58 /*FUNCTION FileParam::MyRank{{{1*/
     58/*FUNCTION FileParam::MyRank{{{*/
    5959int    FileParam::MyRank(void){
    6060        extern int my_rank;
     
    6262}
    6363/*}}}*/
    64 /*FUNCTION FileParam::ObjectEnum{{{1*/
     64/*FUNCTION FileParam::ObjectEnum{{{*/
    6565int FileParam::ObjectEnum(void){
    6666
     
    6969}
    7070/*}}}*/
    71 /*FUNCTION FileParam::copy{{{1*/
     71/*FUNCTION FileParam::copy{{{*/
    7272Object* FileParam::copy() {
    7373       
     
    7878
    7979/*FileParam virtual functions definitions: */
    80 /*FUNCTION FileParam::GetParameterName{{{1*/
     80/*FUNCTION FileParam::GetParameterName{{{*/
    8181void FileParam::GetParameterName(char**pname){
    8282        EnumToStringx(pname,this->enum_type);
    8383}
    8484/*}}}*/
    85 /*FUNCTION FileParam::UnitConversion{{{1*/
     85/*FUNCTION FileParam::UnitConversion{{{*/
    8686void  FileParam::UnitConversion(int direction_enum){
    8787        /*do nothing, no unit conversion*/
  • issm/trunk/src/c/objects/Params/FileParam.h

    r12330 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111#ifdef HAVE_CONFIG_H
    1212        #include <config.h>
     
    2727
    2828        public:
    29                 /*FileParam constructors, destructors: {{{1*/
     29                /*FileParam constructors, destructors: {{{*/
    3030                FileParam();
    3131                FileParam(int enum_type,FILE* fid);
    3232                ~FileParam();
    3333                /*}}}*/
    34                 /*Object virtual functions definitions:{{{1 */
     34                /*Object virtual functions definitions:{{{ */
    3535                void  Echo();
    3636                void  DeepEcho();
     
    4040                Object* copy();
    4141                /*}}}*/
    42                 /*Param vritual function definitions: {{{1*/
     42                /*Param vritual function definitions: {{{*/
    4343                int   InstanceEnum(){return enum_type;}
    44                 void  GetParameterValue(bool* pbool){  _error_("FileParam of enum %i (%s) cannot return a bool",enum_type,EnumToStringx(enum_type));}
    45                 void  GetParameterValue(int* pinteger){_error_("FileParam of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
    46                 void  GetParameterValue(int** pintarray,int* pM){_error_("FileParam of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
    47                 void  GetParameterValue(int** pintarray,int* pM,int* pN){_error_("FileParam of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
    48                 void  GetParameterValue(double* pdouble){_error_("FileParam of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
    49                 void  GetParameterValue(char** pstring){_error_("FileParam of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
    50                 void  GetParameterValue(char*** pstringarray,int* pM){_error_("FileParam of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
    51                 void  GetParameterValue(double** pdoublearray,int* pM){_error_("FileParam of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
    52                 void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("FileParam of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
    53                 void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("File param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
    54                 void  GetParameterValue(Vector** pvec){_error_("FileParam of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
    55                 void  GetParameterValue(Matrix** pmat){_error_("FileParam of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
     44                void  GetParameterValue(bool* pbool){  _error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a bool");}
     45                void  GetParameterValue(int* pinteger){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble");}
     46                void  GetParameterValue(int** pintarray,int* pM){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble");}
     47                void  GetParameterValue(int** pintarray,int* pM,int* pN){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble");}
     48                void  GetParameterValue(IssmDouble* pIssmDouble){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble");}
     49                void  GetParameterValue(char** pstring){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string");}
     50                void  GetParameterValue(char*** pstringarray,int* pM){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string array");}
     51                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
     52                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
     53                void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error2_("File param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix array");}
     54                void  GetParameterValue(Vector** pvec){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Vec");}
     55                void  GetParameterValue(Matrix** pmat){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Mat");}
    5656                void  GetParameterValue(FILE** pfid){*pfid=value;};
    5757
    58                 void  SetValue(bool boolean){_error_("FileParam of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
    59                 void  SetValue(int integer){_error_("FileParam of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
    60                 void  SetValue(double scalar){_error_("FileParam of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
    61                 void  SetValue(char* string){_error_("FileParam of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
    62                 void  SetValue(char** stringarray,int M){_error_("FileParam of enum %i (%s) cannot hold a string array",enum_type,EnumToStringx(enum_type));}
    63                 void  SetValue(double* doublearray,int M){_error_("FileParam of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
    64                 void  SetValue(double* pdoublearray,int M,int N){_error_("FileParam of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
    65                 void  SetValue(int* intarray,int M){_error_("FileParam of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
    66                 void  SetValue(int* pintarray,int M,int N){_error_("FileParam of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
    67                 void  SetValue(Vector* vec){_error_("FileParam of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
    68                 void  SetValue(Matrix* mat){_error_("FileParam of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
    69                 void  SetValue(FILE* fid){_error_("File param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
    70                 void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("File param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
     58                void  SetValue(bool boolean){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string");}
     59                void  SetValue(int integer){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string");}
     60                void  SetValue(IssmDouble scalar){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string");}
     61                void  SetValue(char* string){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string");}
     62                void  SetValue(char** stringarray,int M){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string array");}
     63                void  SetValue(IssmDouble* IssmDoublearray,int M){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
     64                void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
     65                void  SetValue(int* intarray,int M){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int array");}
     66                void  SetValue(int* pintarray,int M,int N){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int array");}
     67                void  SetValue(Vector* vec){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Vec");}
     68                void  SetValue(Matrix* mat){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Mat");}
     69                void  SetValue(FILE* fid){_error2_("File param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
     70                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error2_("File param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an array of matrices");}
    7171                void  UnitConversion(int direction_enum);
    7272
  • issm/trunk/src/c/objects/Params/IntMatParam.cpp

    r12330 r12706  
    44
    55/*header files: */
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*IntMatParam constructors and destructor*/
    23 /*FUNCTION IntMatParam::IntMatParam(){{{1*/
     23/*FUNCTION IntMatParam::IntMatParam(){{{*/
    2424IntMatParam::IntMatParam(){
    2525        return;
    2626}
    2727/*}}}*/
    28 /*FUNCTION IntMatParam::IntMatParam(int enum_type,IssmIntMat value){{{1*/
     28/*FUNCTION IntMatParam::IntMatParam(int enum_type,IssmIntMat value){{{*/
    2929IntMatParam::IntMatParam(int in_enum_type,int* in_value, int in_M,int in_N){
    3030
     
    3333        N=in_N;
    3434
    35         value=(int*)xmalloc(M*N*sizeof(int));
    36         memcpy(value,in_value,M*N*sizeof(int));
     35        value=xNew<int>(M*N);
     36        xMemCpy<int>(value,in_value,M*N);
    3737}
    3838/*}}}*/
    39 /*FUNCTION IntMatParam::~IntMatParam(){{{1*/
     39/*FUNCTION IntMatParam::~IntMatParam(){{{*/
    4040IntMatParam::~IntMatParam(){
    41         xfree((void**)&value);
     41        xDelete<int>(value);
    4242        return;
    4343}
     
    4545
    4646/*Object virtual functions definitions:*/
    47 /*FUNCTION IntMatParam::Echo {{{1*/
     47/*FUNCTION IntMatParam::Echo {{{*/
    4848void IntMatParam::Echo(void){
    4949
    50         printf("IntMatParam:\n");
    51         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    52         printf("   matrix size: %ix%i\n",this->M,this->N);
     50        _printLine_("IntMatParam:");
     51        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     52        _printLine_("   matrix size: " << this->M << "x" << this->N);
    5353
    5454}
    5555/*}}}*/
    56 /*FUNCTION IntMatParam::DeepEcho{{{1*/
     56/*FUNCTION IntMatParam::DeepEcho{{{*/
    5757void IntMatParam::DeepEcho(void){
    5858
    5959        int i,j;
    6060       
    61         printf("IntMatParam:\n");
    62         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    63         printf("   matrix size: %ix%i\n",this->M,this->N);
     61        _printLine_("IntMatParam:");
     62        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     63        _printLine_("   matrix size: " << this->M << "x" << this->N);
    6464        for(i=0;i<this->M;i++){
    6565                for(i=0;i<this->N;i++){
    66                         printf("(%i,%i) %i\n",i,j,*(this->value+N*i+j));
     66                        _printLine_("(" << i << "," << j << ") " << *(this->value+N*i+j));
    6767                }
    6868        }
    6969}
    7070/*}}}*/
    71 /*FUNCTION IntMatParam::Id{{{1*/
     71/*FUNCTION IntMatParam::Id{{{*/
    7272int    IntMatParam::Id(void){ return -1; }
    7373/*}}}*/
    74 /*FUNCTION IntMatParam::MyRank{{{1*/
     74/*FUNCTION IntMatParam::MyRank{{{*/
    7575int    IntMatParam::MyRank(void){
    7676        extern int my_rank;
     
    7878}
    7979/*}}}*/
    80 /*FUNCTION IntMatParam::ObjectEnum{{{1*/
     80/*FUNCTION IntMatParam::ObjectEnum{{{*/
    8181int IntMatParam::ObjectEnum(void){
    8282
     
    8585}
    8686/*}}}*/
    87 /*FUNCTION IntMatParam::copy{{{1*/
     87/*FUNCTION IntMatParam::copy{{{*/
    8888Object* IntMatParam::copy() {
    8989       
     
    9494
    9595/*IntMatParam virtual functions definitions: */
    96 /*FUNCTION IntMatParam::GetParameterValue{{{1*/
     96/*FUNCTION IntMatParam::GetParameterValue{{{*/
    9797void  IntMatParam::GetParameterValue(int** pintarray,int* pM,int* pN){
    9898        int* output=NULL;
    9999
    100         output=(int*)xmalloc((int)(M*N*sizeof(int)));
    101         memcpy(output,value,M*N*sizeof(int));
     100        output=xNew<int>(M*N);
     101        xMemCpy<int>(output,value,M*N);
    102102
    103103        /*Assign output pointers:*/
     
    107107}
    108108/*}}}*/
    109 /*FUNCTION IntMatParam::GetParameterName{{{1*/
     109/*FUNCTION IntMatParam::GetParameterName{{{*/
    110110void IntMatParam::GetParameterName(char**pname){
    111111        EnumToStringx(pname,this->enum_type);
    112112}
    113113/*}}}*/
    114 /*FUNCTION IntMatParam::SetValue{{{1*/
     114/*FUNCTION IntMatParam::SetValue{{{*/
    115115void  IntMatParam::SetValue(int* intarray,int in_M,int in_N){
    116116
    117117        /*avoid leak: */
    118         xfree((void**)&this->value);
     118        xDelete<int>(this->value);
    119119
    120         this->value=(int*)xmalloc(in_M*in_N*sizeof(int));
    121         memcpy(this->value,intarray,in_M*in_N*sizeof(int));
     120        this->value=xNew<int>(in_M*in_N);
     121        xMemCpy<int>(this->value,intarray,in_M*in_N);
    122122
    123123        this->M=in_M;
     
    125125}
    126126/*}}}*/
    127 /*FUNCTION IntMatParam::UnitConversion{{{1*/
     127/*FUNCTION IntMatParam::UnitConversion{{{*/
    128128void  IntMatParam::UnitConversion(int direction_enum){
    129129        /*do nothing, no unit conversion*/
  • issm/trunk/src/c/objects/Params/IntMatParam.h

    r12330 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111#ifdef HAVE_CONFIG_H
    1212        #include <config.h>
     
    2929
    3030        public:
    31                 /*IntMatParam constructors, destructors: {{{1*/
     31                /*IntMatParam constructors, destructors: {{{*/
    3232                IntMatParam();
    3333                IntMatParam(int enum_type,int* value,int M,int N);
    3434                ~IntMatParam();
    3535                /*}}}*/
    36                 /*Object virtual functions definitions:{{{1 */
     36                /*Object virtual functions definitions:{{{ */
    3737                void  Echo();
    3838                void  DeepEcho();
     
    4242                Object* copy();
    4343                /*}}}*/
    44                 /*Param vritual function definitions: {{{1*/
     44                /*Param vritual function definitions: {{{*/
    4545                int   InstanceEnum(){return enum_type;}
    46                 void  GetParameterValue(bool* pbool){_error_("IntMat param of enum %i (%s) cannot return a bool",enum_type,EnumToStringx(enum_type));}
    47                 void  GetParameterValue(int* pinteger){_error_("IntMat param of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type));}
    48                 void  GetParameterValue(int** pintarray,int* pM){_error_("IntMat param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
     46                void  GetParameterValue(bool* pbool){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a bool");}
     47                void  GetParameterValue(int* pinteger){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an integer");}
     48                void  GetParameterValue(int** pintarray,int* pM){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
    4949                void  GetParameterValue(int** pintarray,int* pM,int* pN);
    50                 void  GetParameterValue(double* pdouble){_error_("IntMat param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
    51                 void  GetParameterValue(char** pstring){_error_("IntMat param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
    52                 void  GetParameterValue(char*** pstringarray,int* pM){_error_("IntMat param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
    53                 void  GetParameterValue(double** pdoublearray,int* pM){_error_("IntMat param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
    54                 void  GetParameterValue(double** pdoublearray,int* pM,int* pN){_error_("IntMat param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));};
    55                 void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("IntMat param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
    56                 void  GetParameterValue(Vector** pvec){_error_("IntMat param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
    57                 void  GetParameterValue(Matrix** pmat){_error_("IntMat param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
    58                 void  GetParameterValue(FILE** pfid){_error_("IntMat param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
     50                void  GetParameterValue(IssmDouble* pIssmDouble){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble");}
     51                void  GetParameterValue(char** pstring){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string");}
     52                void  GetParameterValue(char*** pstringarray,int* pM){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string array");}
     53                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
     54                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM,int* pN){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix array");};
     55                void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix array");}
     56                void  GetParameterValue(Vector** pvec){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Vec");}
     57                void  GetParameterValue(Matrix** pmat){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Mat");}
     58                void  GetParameterValue(FILE** pfid){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");}
    5959
    60                 void  SetValue(bool boolean){_error_("IntMat param of enum %i (%s) cannot hold a boolean",enum_type,EnumToStringx(enum_type));}
    61                 void  SetValue(int integer){_error_("IntMat param of enum %i (%s) cannot hold an integer",enum_type,EnumToStringx(enum_type));}
    62                 void  SetValue(double scalar){_error_("IntMat param of enum %i (%s) cannot hold a scalar",enum_type,EnumToStringx(enum_type));}
    63                 void  SetValue(char* string){_error_("IntMat param of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
    64                 void  SetValue(char** stringarray,int M){_error_("IntMat param of enum %i (%s) cannot hold a string array",enum_type,EnumToStringx(enum_type));}
    65                 void  SetValue(double* doublearray,int M){_error_("IntMat param of enum %i (%s) cannot hold a double vec array",enum_type,EnumToStringx(enum_type));}
    66                 void  SetValue(double* doublearray,int M,int N){_error_("IntMat param of enum %i (%s) cannot hold a double vec array",enum_type,EnumToStringx(enum_type));};
    67                 void  SetValue(int* intarray,int M){_error_("IntMat param of enum %i (%s) cannot hold a int vec array",enum_type,EnumToStringx(enum_type));};
     60                void  SetValue(bool boolean){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a boolean");}
     61                void  SetValue(int integer){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an integer");}
     62                void  SetValue(IssmDouble scalar){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a scalar");}
     63                void  SetValue(char* string){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string");}
     64                void  SetValue(char** stringarray,int M){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string array");}
     65                void  SetValue(IssmDouble* IssmDoublearray,int M){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble vec array");}
     66                void  SetValue(IssmDouble* IssmDoublearray,int M,int N){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble vec array");};
     67                void  SetValue(int* intarray,int M){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int vec array");};
    6868                void  SetValue(int* intarray,int M,int N);
    69                 void  SetValue(Vector* vec){_error_("IntMat param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
    70                 void  SetValue(Matrix* mat){_error_("IntMat param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
    71                 void  SetValue(FILE* fid){_error_("IntMat param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
    72                 void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("IntMat param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
     69                void  SetValue(Vector* vec){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Vec");}
     70                void  SetValue(Matrix* mat){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Mat");}
     71                void  SetValue(FILE* fid){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
     72                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an array of matrices");}
    7373                void  UnitConversion(int direction_enum);
    7474
  • issm/trunk/src/c/objects/Params/IntParam.cpp

    r12330 r12706  
    44
    55/*header files: */
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*IntParam constructors and destructor*/
    23 /*FUNCTION IntParam::IntParam(){{{1*/
     23/*FUNCTION IntParam::IntParam(){{{*/
    2424IntParam::IntParam(){
    2525        return;
    2626}
    2727/*}}}*/
    28 /*FUNCTION IntParam::IntParam(int enum_type,IssmInt value){{{1*/
     28/*FUNCTION IntParam::IntParam(int enum_type,IssmInt value){{{*/
    2929IntParam::IntParam(int in_enum_type,IssmInt in_value){
    3030
     
    3333}
    3434/*}}}*/
    35 /*FUNCTION IntParam::~IntParam(){{{1*/
     35/*FUNCTION IntParam::~IntParam(){{{*/
    3636IntParam::~IntParam(){
    3737        return;
     
    4040
    4141/*Object virtual functions definitions:*/
    42 /*FUNCTION IntParam::Echo {{{1*/
     42/*FUNCTION IntParam::Echo {{{*/
    4343void IntParam::Echo(void){
    4444        this->DeepEcho();
    4545}
    4646/*}}}*/
    47 /*FUNCTION IntParam::DeepEcho{{{1*/
     47/*FUNCTION IntParam::DeepEcho{{{*/
    4848void IntParam::DeepEcho(void){
    4949
    50         printf("IntParam:\n");
    51         printf("   enum:  %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    52         printf("   value: %i\n",this->value);
     50        _printLine_("IntParam:");
     51        _printLine_("   enum:  " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     52        _printLine_("   value: " << this->value);
    5353}
    5454/*}}}*/
    55 /*FUNCTION IntParam::Id{{{1*/
     55/*FUNCTION IntParam::Id{{{*/
    5656int    IntParam::Id(void){ return -1; }
    5757/*}}}*/
    58 /*FUNCTION IntParam::MyRank{{{1*/
     58/*FUNCTION IntParam::MyRank{{{*/
    5959int    IntParam::MyRank(void){
    6060        extern int my_rank;
     
    6262}
    6363/*}}}*/
    64 /*FUNCTION IntParam::ObjectEnum{{{1*/
     64/*FUNCTION IntParam::ObjectEnum{{{*/
    6565int IntParam::ObjectEnum(void){
    6666
     
    6969}
    7070/*}}}*/
    71 /*FUNCTION IntParam::copy{{{1*/
     71/*FUNCTION IntParam::copy{{{*/
    7272Object* IntParam::copy() {
    7373       
     
    7878
    7979/*IntParam virtual functions definitions: */
    80 /*FUNCTION IntParam::GetParameterName{{{1*/
     80/*FUNCTION IntParam::GetParameterName{{{*/
    8181void IntParam::GetParameterName(char**pname){
    8282        EnumToStringx(pname,this->enum_type);
    8383}
    8484/*}}}*/
    85 /*FUNCTION IntParam::UnitConversion{{{1*/
     85/*FUNCTION IntParam::UnitConversion{{{*/
    8686void  IntParam::UnitConversion(int direction_enum){
    8787        /*do nothing, no unit conversion*/
  • issm/trunk/src/c/objects/Params/IntParam.h

    r12330 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111#ifdef HAVE_CONFIG_H
    1212        #include <config.h>
     
    2828
    2929        public:
    30                 /*IntParam constructors, destructors: {{{1*/
     30                /*IntParam constructors, destructors: {{{*/
    3131                IntParam();
    3232                IntParam(int enum_type,IssmInt value);
    3333                ~IntParam();
    3434                /*}}}*/
    35                 /*Object virtual functions definitions:{{{1 */
     35                /*Object virtual functions definitions:{{{ */
    3636                void  Echo();
    3737                void  DeepEcho();
     
    4141                Object* copy();
    4242                /*}}}*/
    43                 /*Param vritual function definitions: {{{1*/
     43                /*Param vritual function definitions: {{{*/
    4444                int   InstanceEnum(){return enum_type;}
    45                 void  GetParameterValue(bool* pbool){_error_("Int param of enum %i (%s) cannot return a bool",enum_type,EnumToStringx(enum_type));}
     45                void  GetParameterValue(bool* pbool){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a bool");}
    4646                void  GetParameterValue(int* pinteger){*pinteger=value;}
    47                 void  GetParameterValue(int** pintarray,int* pM){_error_("Int param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
    48                 void  GetParameterValue(int** pintarray,int* pM,int* pN){_error_("Int param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
    49                 void  GetParameterValue(double* pdouble){_error_("Int param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
    50                 void  GetParameterValue(char** pstring){_error_("Int param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
    51                 void  GetParameterValue(char*** pstringarray,int* pM){_error_("Int param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
    52                 void  GetParameterValue(double** pdoublearray,int* pM){_error_("Int param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
    53                 void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("Int param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
    54                 void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("Int param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
    55                 void  GetParameterValue(Vector** pvec){_error_("Int param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
    56                 void  GetParameterValue(Matrix** pmat){_error_("Int param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
    57                 void  GetParameterValue(FILE** pfid){_error_("Int param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
     47                void  GetParameterValue(int** pintarray,int* pM){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
     48                void  GetParameterValue(int** pintarray,int* pM,int* pN){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
     49                void  GetParameterValue(IssmDouble* pIssmDouble){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble");}
     50                void  GetParameterValue(char** pstring){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string");}
     51                void  GetParameterValue(char*** pstringarray,int* pM){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string array");}
     52                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
     53                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
     54                void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix array");}
     55                void  GetParameterValue(Vector** pvec){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Vec");}
     56                void  GetParameterValue(Matrix** pmat){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Mat");}
     57                void  GetParameterValue(FILE** pfid){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");}
    5858
    59                 void  SetValue(bool boolean){this->value=(int)boolean;}
     59                void  SetValue(bool boolean){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a bool");}
    6060                void  SetValue(int integer){this->value=integer;}
    61                 void  SetValue(int* intarray,int M){_error_("Int param of enum %i (%s) cannot hold an int array",enum_type,EnumToStringx(enum_type));}
    62                 void  SetValue(int* intarray,int M,int N){_error_("Int param of enum %i (%s) cannot hold an int array",enum_type,EnumToStringx(enum_type));}
    63                 void  SetValue(double scalar){this->value=(int)scalar;}
    64                 void  SetValue(char* string){_error_("Int param of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
    65                 void  SetValue(char** stringarray,int M){_error_("Int param of enum %i (%s) cannot hold a string array",enum_type,EnumToStringx(enum_type));}
    66                 void  SetValue(double* doublearray,int M){_error_("Int param of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
    67                 void  SetValue(double* pdoublearray,int M,int N){_error_("Int param of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
    68                 void  SetValue(Vector* vec){_error_("Int param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
    69                 void  SetValue(Matrix* mat){_error_("Int param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
    70                 void  SetValue(FILE* fid){_error_("Int param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
    71                 void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("Int param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
     61                void  SetValue(int* intarray,int M){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an int array");}
     62                void  SetValue(int* intarray,int M,int N){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an int array");}
     63                void  SetValue(IssmDouble scalar){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an IssmDouble");}
     64                void  SetValue(char* string){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string");}
     65                void  SetValue(char** stringarray,int M){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string array");}
     66                void  SetValue(IssmDouble* IssmDoublearray,int M){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
     67                void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
     68                void  SetValue(Vector* vec){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Vec");}
     69                void  SetValue(Matrix* mat){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Mat");}
     70                void  SetValue(FILE* fid){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
     71                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an array of matrices");}
    7272                void  UnitConversion(int direction_enum);
    7373
  • issm/trunk/src/c/objects/Params/IntVecParam.cpp

    r12330 r12706  
    44
    55/*header files: */
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*IntVecParam constructors and destructor*/
    23 /*FUNCTION IntVecParam::IntVecParam(){{{1*/
     23/*FUNCTION IntVecParam::IntVecParam(){{{*/
    2424IntVecParam::IntVecParam(){
    2525        return;
    2626}
    2727/*}}}*/
    28 /*FUNCTION IntVecParam::IntVecParam(int enum_type,int* values,int M){{{1*/
     28/*FUNCTION IntVecParam::IntVecParam(int enum_type,int* values,int M){{{*/
    2929IntVecParam::IntVecParam(int in_enum_type,int* in_values, int in_M){
    3030
     
    3333
    3434        if(M){
    35                 values=(int*)xmalloc(M*sizeof(int));
    36                 memcpy(values,in_values,M*sizeof(int));
     35                values=xNew<int>(M);
     36                xMemCpy<int>(values,in_values,M);
    3737        }
    3838        else values=NULL;
    3939}
    4040/*}}}*/
    41 /*FUNCTION IntVecParam::IntVecParam(int enum_type,double* values,int M){{{1*/
    42 IntVecParam::IntVecParam(int in_enum_type,double* in_values, int in_M){
     41/*FUNCTION IntVecParam::IntVecParam(int enum_type,IssmDouble* values,int M){{{*/
     42IntVecParam::IntVecParam(int in_enum_type,IssmDouble* in_values, int in_M){
    4343
    4444        enum_type=in_enum_type;
     
    4646
    4747        if(M){
    48                 values=(int*)xmalloc(M*sizeof(int));
    49                 for(int i=0;i<in_M;i++) values[i]=(int)in_values[i];
     48                values=xNew<int>(M);
     49                for(int i=0;i<in_M;i++) values[i]=reCast<int>(in_values[i]);
    5050        }
    5151        else values=NULL;
    5252}
    5353/*}}}*/
    54 /*FUNCTION IntVecParam::~IntVecParam(){{{1*/
     54/*FUNCTION IntVecParam::~IntVecParam(){{{*/
    5555IntVecParam::~IntVecParam(){
    56         xfree((void**)&values);
     56        xDelete<int>(values);
    5757        return;
    5858}
     
    6060
    6161/*Object virtual functions definitions:*/
    62 /*FUNCTION IntVecParam::Echo {{{1*/
     62/*FUNCTION IntVecParam::Echo {{{*/
    6363void IntVecParam::Echo(void){
    6464
    65         printf("IntVecParam:\n");
    66         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    67         printf("   vector size: %i\n",this->M);
     65        _printLine_("IntVecParam:");
     66        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     67        _printLine_("   vector size: " << this->M);
    6868
    6969}
    7070/*}}}*/
    71 /*FUNCTION IntVecParam::DeepEcho{{{1*/
     71/*FUNCTION IntVecParam::DeepEcho{{{*/
    7272void IntVecParam::DeepEcho(void){
    7373
    7474        int i;
    7575       
    76         printf("IntVecParam:\n");
    77         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    78         printf("   vector size: %i\n",this->M);
     76        _printLine_("IntVecParam:");
     77        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     78        _printLine_("   vector size: " << this->M);
    7979        for(i=0;i<this->M;i++){
    80                 printf("%i %i\n",i,this->values[i]);
     80                _printLine_(i << " " << this->values[i]);
    8181        }
    8282}
    8383/*}}}*/
    84 /*FUNCTION IntVecParam::Id{{{1*/
     84/*FUNCTION IntVecParam::Id{{{*/
    8585int    IntVecParam::Id(void){ return -1; }
    8686/*}}}*/
    87 /*FUNCTION IntVecParam::MyRank{{{1*/
     87/*FUNCTION IntVecParam::MyRank{{{*/
    8888int    IntVecParam::MyRank(void){
    8989        extern int my_rank;
     
    9191}
    9292/*}}}*/
    93 /*FUNCTION IntVecParam::ObjectEnum{{{1*/
     93/*FUNCTION IntVecParam::ObjectEnum{{{*/
    9494int IntVecParam::ObjectEnum(void){
    9595
     
    9898}
    9999/*}}}*/
    100 /*FUNCTION IntVecParam::copy{{{1*/
     100/*FUNCTION IntVecParam::copy{{{*/
    101101Object* IntVecParam::copy() {
    102102       
     
    107107
    108108/*IntVecParam virtual functions definitions: */
    109 /*FUNCTION IntVecParam::GetParameterValue{{{1*/
     109/*FUNCTION IntVecParam::GetParameterValue{{{*/
    110110void  IntVecParam::GetParameterValue(int** pintarray,int* pM){
    111111        int* output=NULL;
    112112
    113113        if(M){
    114                 output=(int*)xmalloc(M*sizeof(int));
    115                 memcpy(output,values,M*sizeof(int));
     114                output=xNew<int>(M);
     115                xMemCpy<int>(output,values,M);
    116116        }
    117117
     
    121121}
    122122/*}}}*/
    123 /*FUNCTION IntVecParam::GetParameterName{{{1*/
     123/*FUNCTION IntVecParam::GetParameterName{{{*/
    124124void IntVecParam::GetParameterName(char**pname){
    125125        EnumToStringx(pname,this->enum_type);
    126126}
    127127/*}}}*/
    128 /*FUNCTION IntVecParam::SetValue{{{1*/
     128/*FUNCTION IntVecParam::SetValue{{{*/
    129129void  IntVecParam::SetValue(int* intarray,int in_M){
    130130
    131131        /*avoid leak: */
    132         xfree((void**)&this->values);
     132        xDelete<int>(this->values);
    133133
    134134        if(in_M){
    135                 this->values=(int*)xmalloc(in_M*sizeof(int));
    136                 memcpy(this->values,intarray,in_M*sizeof(int));
     135                this->values=xNew<int>(in_M);
     136                xMemCpy<int>(this->values,intarray,in_M);
    137137        }
    138138        else this->values=NULL;
     
    141141}
    142142/*}}}*/
    143 /*FUNCTION IntVecParam::UnitConversion{{{1*/
     143/*FUNCTION IntVecParam::UnitConversion{{{*/
    144144void  IntVecParam::UnitConversion(int direction_enum){
    145145        /*do nothing, no unit conversion*/
  • issm/trunk/src/c/objects/Params/IntVecParam.h

    r12330 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111#ifdef HAVE_CONFIG_H
    1212        #include <config.h>
     
    2828
    2929        public:
    30                 /*IntVecParam constructors, destructors: {{{1*/
     30                /*IntVecParam constructors, destructors: {{{*/
    3131                IntVecParam();
    3232                IntVecParam(int enum_type,int* values,int M);
    33                 IntVecParam(int enum_type,double* values,int M);
     33                IntVecParam(int enum_type,IssmDouble* values,int M);
    3434                ~IntVecParam();
    3535                /*}}}*/
    36                 /*Object virtual functions definitions:{{{1 */
     36                /*Object virtual functions definitions:{{{ */
    3737                void  Echo();
    3838                void  DeepEcho();
     
    4242                Object* copy();
    4343                /*}}}*/
    44                 /*Param virtual functions definitions: {{{1*/
     44                /*Param virtual functions definitions: {{{*/
    4545                int   InstanceEnum(){return enum_type;}
    46                 void  GetParameterValue(bool* pbool){_error_("IntVec param of enum %i (%s) cannot return a bool",enum_type,EnumToStringx(enum_type));}
    47                 void  GetParameterValue(int* pinteger){_error_("IntVec param of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type));}
     46                void  GetParameterValue(bool* pbool){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a bool");}
     47                void  GetParameterValue(int* pinteger){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an integer");}
    4848                void  GetParameterValue(int** pintarray,int* pM);
    49                 void  GetParameterValue(int** pintarray,int* pM,int* pN){_error_("IntVec param of enum %i (%s) cannot return a matrix",enum_type,EnumToStringx(enum_type));}
    50                 void  GetParameterValue(double* pdouble){_error_("IntVec param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
    51                 void  GetParameterValue(char** pstring){_error_("IntVec param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
    52                 void  GetParameterValue(char*** pstringarray,int* pM){_error_("IntVec param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
    53                 void  GetParameterValue(double** pdoublearray,int* pM){_error_("IntVec param of enum %i (%s) cannot return a double array (maybe in serial?)",enum_type,EnumToStringx(enum_type));}
    54                 void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("IntVec param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
    55                 void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("IntVec param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
    56                 void  GetParameterValue(Vector** pvec){_error_("IntVec param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
    57                 void  GetParameterValue(Matrix** pmat){_error_("IntVec param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
    58                 void  GetParameterValue(FILE** pfid){_error_("IntVec param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
     49                void  GetParameterValue(int** pintarray,int* pM,int* pN){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix");}
     50                void  GetParameterValue(IssmDouble* pIssmDouble){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble");}
     51                void  GetParameterValue(char** pstring){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string");}
     52                void  GetParameterValue(char*** pstringarray,int* pM){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string array");}
     53                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array (maybe in serial?)");}
     54                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
     55                void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix array");}
     56                void  GetParameterValue(Vector** pvec){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Vec");}
     57                void  GetParameterValue(Matrix** pmat){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Mat");}
     58                void  GetParameterValue(FILE** pfid){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");}
    5959
    60                 void  SetValue(bool boolean){_error_("IntVec param of enum %i (%s) cannot hold a boolean",enum_type,EnumToStringx(enum_type));}
    61                 void  SetValue(int integer){_error_("IntVec param of enum %i (%s) cannot hold an integer",enum_type,EnumToStringx(enum_type));}
    62                 void  SetValue(double scalar){_error_("IntVec param of enum %i (%s) cannot hold a scalar",enum_type,EnumToStringx(enum_type));}
    63                 void  SetValue(char* string){_error_("IntVec param of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
    64                 void  SetValue(char** stringarray,int M){_error_("IntVec param of enum %i (%s) cannot hold a string array",enum_type,EnumToStringx(enum_type));}
    65                 void  SetValue(double* doublearray,int M){_error_("IntVec param of enum %i (%s) cannot hold a double mat array",enum_type,EnumToStringx(enum_type));}
    66                 void  SetValue(double* pdoublearray,int M,int N){_error_("IntVec param of enum %i (%s) cannot hold a double mat array",enum_type,EnumToStringx(enum_type));}
     60                void  SetValue(bool boolean){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a boolean");}
     61                void  SetValue(int integer){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an integer");}
     62                void  SetValue(IssmDouble scalar){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a scalar");}
     63                void  SetValue(char* string){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string");}
     64                void  SetValue(char** stringarray,int M){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string array");}
     65                void  SetValue(IssmDouble* IssmDoublearray,int M){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble mat array");}
     66                void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble mat array");}
    6767                void  SetValue(int* intarray,int M);
    68                 void  SetValue(int* pintarray,int M,int N){_error_("IntVec param of enum %i (%s) cannot hold a int mat array",enum_type,EnumToStringx(enum_type));}
    69                 void  SetValue(Vector* vec){_error_("IntVec param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
    70                 void  SetValue(Matrix* mat){_error_("IntVec param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
    71                 void  SetValue(FILE* fid){_error_("IntVec param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
    72                 void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("IntVec param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
     68                void  SetValue(int* pintarray,int M,int N){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int mat array");}
     69                void  SetValue(Vector* vec){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Vec");}
     70                void  SetValue(Matrix* mat){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Mat");}
     71                void  SetValue(FILE* fid){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
     72                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an array of matrices");}
    7373                void  UnitConversion(int direction_enum);
    7474               
  • issm/trunk/src/c/objects/Params/MatrixParam.cpp

    r12330 r12706  
    44
    55/*header files: */
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*MatrixParam constructors and destructor*/
    23 /*FUNCTION MatrixParam::MatrixParam(){{{1*/
     23/*FUNCTION MatrixParam::MatrixParam(){{{*/
    2424MatrixParam::MatrixParam(){
    2525        return;
    2626}
    2727/*}}}*/
    28 /*FUNCTION MatrixParam::MatrixParam(int enum_type,Matrix* value){{{1*/
     28/*FUNCTION MatrixParam::MatrixParam(int enum_type,Matrix* value){{{*/
    2929MatrixParam::MatrixParam(int in_enum_type,Matrix* in_value){
    3030
     
    3737}
    3838/*}}}*/
    39 /*FUNCTION MatrixParam::~MatrixParam(){{{1*/
     39/*FUNCTION MatrixParam::~MatrixParam(){{{*/
    4040MatrixParam::~MatrixParam(){
    4141        xdelete(&value);
     
    4444
    4545/*Object virtual functions definitions:*/
    46 /*FUNCTION MatrixParam::Echo {{{1*/
     46/*FUNCTION MatrixParam::Echo {{{*/
    4747void MatrixParam::Echo(void){
    4848
    49         printf("MatrixParam:\n");
    50         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
     49        _printLine_("MatrixParam:");
     50        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
    5151
    5252}
    5353/*}}}*/
    54 /*FUNCTION MatrixParam::DeepEcho{{{1*/
     54/*FUNCTION MatrixParam::DeepEcho{{{*/
    5555void MatrixParam::DeepEcho(void){
    5656
    5757        int i;
    58         printf("MatrixParam:\n");
    59         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
     58        _printLine_("MatrixParam:");
     59        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
    6060        this->value->Echo();
    6161}
    6262/*}}}*/
    63 /*FUNCTION MatrixParam::Id{{{1*/
     63/*FUNCTION MatrixParam::Id{{{*/
    6464int    MatrixParam::Id(void){ return -1; }
    6565/*}}}*/
    66 /*FUNCTION MatrixParam::MyRank{{{1*/
     66/*FUNCTION MatrixParam::MyRank{{{*/
    6767int    MatrixParam::MyRank(void){
    6868        extern int my_rank;
     
    7070}
    7171/*}}}*/
    72 /*FUNCTION MatrixParam::ObjectEnum{{{1*/
     72/*FUNCTION MatrixParam::ObjectEnum{{{*/
    7373int MatrixParam::ObjectEnum(void){
    7474
     
    7777}
    7878/*}}}*/
    79 /*FUNCTION MatrixParam::copy{{{1*/
     79/*FUNCTION MatrixParam::copy{{{*/
    8080Object* MatrixParam::copy() {
    8181       
     
    8686
    8787/*MatrixParam virtual functions definitions: */
    88 /*FUNCTION MatrixParam::GetParameterValue{{{1*/
     88/*FUNCTION MatrixParam::GetParameterValue{{{*/
    8989void  MatrixParam::GetParameterValue(Matrix** poutput){
    9090        Matrix* output=NULL;
     
    9696}
    9797/*}}}*/
    98 /*FUNCTION MatrixParam::GetParameterName{{{1*/
     98/*FUNCTION MatrixParam::GetParameterName{{{*/
    9999void MatrixParam::GetParameterName(char**pname){
    100100        EnumToStringx(pname,this->enum_type);
    101101}
    102102/*}}}*/
    103 /*FUNCTION MatrixParam::SetValue{{{1*/
     103/*FUNCTION MatrixParam::SetValue{{{*/
    104104void  MatrixParam::SetValue(Matrix* matrix){
    105105       
     
    111111}
    112112/*}}}*/
    113 /*FUNCTION MatrixParam::UnitConversion{{{1*/
     113/*FUNCTION MatrixParam::UnitConversion{{{*/
    114114void  MatrixParam::UnitConversion(int direction_enum){
    115115        /*do nothing, no unit conversion*/
  • issm/trunk/src/c/objects/Params/MatrixParam.h

    r12330 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111#ifdef HAVE_CONFIG_H
    1212        #include <config.h>
     
    2828
    2929        public:
    30                 /*MatrixParam constructors, destructors: {{{1*/
     30                /*MatrixParam constructors, destructors: {{{*/
    3131                MatrixParam();
    3232                MatrixParam(int enum_type,Matrix* value);
    3333                ~MatrixParam();
    3434                /*}}}*/
    35                 /*Object virtual functions definitions:{{{1 */
     35                /*Object virtual functions definitions:{{{ */
    3636                void  Echo();
    3737                void  DeepEcho();
     
    4141                Object* copy();
    4242                /*}}}*/
    43                 /*Param vritual function definitions: {{{1*/
     43                /*Param vritual function definitions: {{{*/
    4444                int   InstanceEnum(){return enum_type;}
    45                 void  GetParameterValue(bool* pbool){_error_("Matrix param of enum %i (%s) cannot return a bool",enum_type,EnumToStringx(enum_type));}
    46                 void  GetParameterValue(int* pinteger){_error_("Matrix param of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type));}
    47                 void  GetParameterValue(int** pintarray,int* pM){_error_("Matrix param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
    48                 void  GetParameterValue(int** pintarray,int* pM,int* pN){_error_("Matrix param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
    49                 void  GetParameterValue(double* pdouble){_error_("Matrix param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
    50                 void  GetParameterValue(char** pstring){_error_("Matrix param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
    51                 void  GetParameterValue(char*** pstringarray,int* pM){_error_("Matrix param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
    52                 void  GetParameterValue(double** pdoublearray,int* pM){_error_("Matrix param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
    53                 void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("Matrix param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
    54                 void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("Matrix param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
    55                 void  GetParameterValue(Vector** pvec){_error_("Matrix param of enum %i (%s) cannot return a vec",enum_type,EnumToStringx(enum_type));}
     45                void  GetParameterValue(bool* pbool){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a bool");}
     46                void  GetParameterValue(int* pinteger){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an integer");}
     47                void  GetParameterValue(int** pintarray,int* pM){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
     48                void  GetParameterValue(int** pintarray,int* pM,int* pN){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
     49                void  GetParameterValue(IssmDouble* pIssmDouble){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble");}
     50                void  GetParameterValue(char** pstring){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string");}
     51                void  GetParameterValue(char*** pstringarray,int* pM){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string array");}
     52                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
     53                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
     54                void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix array");}
     55                void  GetParameterValue(Vector** pvec){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a vec");}
    5656                void  GetParameterValue(Matrix** poutput);
    57                 void  GetParameterValue(FILE** pfid){_error_("Matrix param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
     57                void  GetParameterValue(FILE** pfid){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");}
    5858
    59                 void  SetValue(bool boolean){_error_("Matrix param of enum %i (%s) cannot hold a boolean",enum_type,EnumToStringx(enum_type));}
    60                 void  SetValue(int integer){_error_("Matrix param of enum %i (%s) cannot hold an integer",enum_type,EnumToStringx(enum_type));}
    61                 void  SetValue(double scalar){_error_("Matrix param of enum %i (%s) cannot hold a scalar",enum_type,EnumToStringx(enum_type));}
    62                 void  SetValue(char* string){_error_("Matrix param of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
    63                 void  SetValue(char** stringarray,int M){_error_("Matrix param of enum %i (%s) cannot hold a string array",enum_type,EnumToStringx(enum_type));}
    64                 void  SetValue(double* doublearray,int M){_error_("Matrix param of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
    65                 void  SetValue(double* pdoublearray,int M,int N){_error_("Matrix param of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
    66                 void  SetValue(int* intarray,int M){_error_("Matrix param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
    67                 void  SetValue(int* pintarray,int M,int N){_error_("Matrix param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
    68                 void  SetValue(Vector* vec){_error_("Matrix param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
     59                void  SetValue(bool boolean){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a boolean");}
     60                void  SetValue(int integer){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an integer");}
     61                void  SetValue(IssmDouble scalar){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a scalar");}
     62                void  SetValue(char* string){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string");}
     63                void  SetValue(char** stringarray,int M){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string array");}
     64                void  SetValue(IssmDouble* IssmDoublearray,int M){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
     65                void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
     66                void  SetValue(int* intarray,int M){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int array");}
     67                void  SetValue(int* pintarray,int M,int N){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int array");}
     68                void  SetValue(Vector* vec){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Vec");}
    6969                void  SetValue(Matrix* mat);
    70                 void  SetValue(FILE* fid){_error_("Matrix param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
    71                 void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("Matrix param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
     70                void  SetValue(FILE* fid){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
     71                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an array of matrices");}
    7272                void  UnitConversion(int direction_enum);
    7373
  • issm/trunk/src/c/objects/Params/Param.h

    r12330 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111
    1212#ifdef HAVE_CONFIG_H
     
    3131                virtual void  GetParameterValue(int** pintarray,int* pM)=0;
    3232                virtual void  GetParameterValue(int** pintarray,int* pM,int* pN)=0;
    33                 virtual void  GetParameterValue(double* pdouble)=0;
     33                virtual void  GetParameterValue(IssmDouble* pIssmDouble)=0;
    3434                virtual void  GetParameterValue(char** pstring)=0;
    3535                virtual void  GetParameterValue(char*** pstringarray,int* pM)=0;
    36                 virtual void  GetParameterValue(double** pdoublearray,int* pM)=0;
    37                 virtual void  GetParameterValue(double** pdoublearray,int* pM,int* pN)=0;
    38                 virtual void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims)=0;
     36                virtual void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM)=0;
     37                virtual void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM,int* pN)=0;
     38                virtual void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims)=0;
    3939                virtual void  GetParameterValue(Vector** pvec)=0;
    4040                virtual void  GetParameterValue(Matrix** pmat)=0;
     
    4343                virtual void  SetValue(bool boolean)=0;
    4444                virtual void  SetValue(int integer)=0;
    45                 virtual void  SetValue(double scalar)=0;
     45                virtual void  SetValue(IssmDouble scalar)=0;
    4646                virtual void  SetValue(char* string)=0;
    4747                virtual void  SetValue(char** stringarray,int M)=0;
    48                 virtual void  SetValue(double* doublearray,int M)=0;
    49                 virtual void  SetValue(double* pdoublearray,int M,int N)=0;
     48                virtual void  SetValue(IssmDouble* IssmDoublearray,int M)=0;
     49                virtual void  SetValue(IssmDouble* pIssmDoublearray,int M,int N)=0;
    5050                virtual void  SetValue(int* intarray,int M)=0;
    5151                virtual void  SetValue(int* pintarray,int M,int N)=0;
     
    5353                virtual void  SetValue(Matrix* mat)=0;
    5454                virtual void  SetValue(FILE* fid)=0;
    55                 virtual void  SetValue(double** array, int M, int* mdim_array, int* ndim_array)=0;
     55                virtual void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array)=0;
    5656                virtual void  UnitConversion(int direction_enum)=0;
    5757                virtual void  GetParameterName(char**pname)=0;
  • issm/trunk/src/c/objects/Params/StringArrayParam.cpp

    r12330 r12706  
    44
    55/*header files: */
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*StringArrayParam constructors and destructor*/
    23 /*FUNCTION StringArrayParam::StringArrayParam(){{{1*/
     23/*FUNCTION StringArrayParam::StringArrayParam(){{{*/
    2424StringArrayParam::StringArrayParam(){
    2525        return;
    2626}
    2727/*}}}*/
    28 /*FUNCTION StringArrayParam::StringArrayParam(int enum_type,char** in_values,int in_numstrings){{{1*/
     28/*FUNCTION StringArrayParam::StringArrayParam(int enum_type,char** in_values,int in_numstrings){{{*/
    2929StringArrayParam::StringArrayParam(int in_enum_type,char** in_values, int in_numstrings){
    3030
     
    3636
    3737        if(numstrings){
    38                 value=(char**)xmalloc(numstrings*sizeof(char*));
     38                value=xNew<char*>(numstrings);
    3939                for(i=0;i<numstrings;i++){
    4040                        char* string=NULL;
    4141                        size=strlen(in_values[i])+1;
    42                         string=(char*)xmalloc(size*sizeof(char));
    43                         memcpy(string,in_values[i],size*sizeof(char));
     42                        string=xNew<char>(size);
     43                        xMemCpy<char>(string,in_values[i],size);
    4444                        value[i]=string;
    4545                }
     
    4949}
    5050/*}}}*/
    51 /*FUNCTION StringArrayParam::~StringArrayParam(){{{1*/
     51/*FUNCTION StringArrayParam::~StringArrayParam(){{{*/
    5252StringArrayParam::~StringArrayParam(){
    5353               
     
    5757        for(i=0;i<this->numstrings;i++){
    5858                string=value[i];
    59                 xfree((void**)&string);
     59                xDelete<char>(string);
    6060        }
    61         xfree((void**)&value);
     61        xDelete<char*>(value);
    6262}
    6363/*}}}*/
    6464
    6565/*Object virtual functions definitions:*/
    66 /*FUNCTION StringArrayParam::Echo {{{1*/
     66/*FUNCTION StringArrayParam::Echo {{{*/
    6767void StringArrayParam::Echo(void){
    6868        this->DeepEcho();
    6969}
    7070/*}}}*/
    71 /*FUNCTION StringArrayParam::DeepEcho{{{1*/
     71/*FUNCTION StringArrayParam::DeepEcho{{{*/
    7272void StringArrayParam::DeepEcho(void){
    7373
     
    7575        char* string=NULL;
    7676
    77         printf("StringArrayParam:\n");
    78         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
     77        _printLine_("StringArrayParam:");
     78        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
    7979        for(i=0;i<this->numstrings;i++){
    8080                string=this->value[i];
    81                 printf("   %i: %s\n",i,string);
     81                _printLine_("   " << i << ": " << string);
    8282        }
    8383}
    8484/*}}}*/
    85 /*FUNCTION StringArrayParam::Id{{{1*/
     85/*FUNCTION StringArrayParam::Id{{{*/
    8686int    StringArrayParam::Id(void){ return -1; }
    8787/*}}}*/
    88 /*FUNCTION StringArrayParam::MyRank{{{1*/
     88/*FUNCTION StringArrayParam::MyRank{{{*/
    8989int    StringArrayParam::MyRank(void){
    9090        extern int my_rank;
     
    9292}
    9393/*}}}*/
    94 /*FUNCTION StringArrayParam::ObjectEnum{{{1*/
     94/*FUNCTION StringArrayParam::ObjectEnum{{{*/
    9595int StringArrayParam::ObjectEnum(void){
    9696
     
    9999}
    100100/*}}}*/
    101 /*FUNCTION StringArrayParam::copy{{{1*/
     101/*FUNCTION StringArrayParam::copy{{{*/
    102102Object* StringArrayParam::copy() {
    103103       
     
    108108
    109109/*StringArrayParam virtual functions definitions: */
    110 /*FUNCTION StringArrayParam::GetParameterValue{{{1*/
     110/*FUNCTION StringArrayParam::GetParameterValue{{{*/
    111111void  StringArrayParam::GetParameterValue(char*** pstringarray,int* pM){
    112112       
     
    120120        M=this->numstrings;
    121121        if(this->numstrings){
    122                 outstrings=(char**)xmalloc(this->numstrings*sizeof(char*));
     122                outstrings=xNew<char*>(this->numstrings);
    123123
    124124                for(i=0;i<this->numstrings;i++){
     
    126126                        stringsize=strlen(string)+1;
    127127
    128                         string2=(char*)xmalloc(stringsize*sizeof(char));
    129                         memcpy(string2,string,stringsize*sizeof(char));
     128                        string2=xNew<char>(stringsize);
     129                        xMemCpy<char>(string2,string,stringsize);
    130130
    131131                        outstrings[i]=string2;
     
    139139}
    140140/*}}}*/
    141 /*FUNCTION StringArrayParam::GetParameterName{{{1*/
     141/*FUNCTION StringArrayParam::GetParameterName{{{*/
    142142void StringArrayParam::GetParameterName(char**pname){
    143143        EnumToStringx(pname,this->enum_type);
    144144}
    145145/*}}}*/
    146 /*FUNCTION StringArrayParam::SetValue{{{1*/
     146/*FUNCTION StringArrayParam::SetValue{{{*/
    147147void  StringArrayParam::SetValue(char** stringarray,int M){
    148148       
     
    155155        for(i=0;i<this->numstrings;i++){
    156156                string=this->value[i];
    157                 xfree((void**)&string);
     157                xDelete<char>(string);
    158158        }
    159         xfree((void**)&this->value);
     159        xDelete<char*>(this->value);
    160160
    161161        /*copy: */
    162162        this->numstrings=M;
    163         this->value=(char**)xmalloc(this->numstrings*sizeof(char*));
     163        this->value=xNew<char*>(this->numstrings);
    164164        for(i=0;i<this->numstrings;i++){
    165165                string=stringarray[i];
    166166                stringsize=strlen(string)+1;
    167167
    168                 string2=(char*)xmalloc(stringsize*sizeof(char));
    169                 memcpy(string2,string,stringsize*sizeof(char));
     168                string2=xNew<char>(stringsize);
     169                xMemCpy<char>(string2,string,stringsize);
    170170
    171171                this->value[i]=string2;
     
    173173}
    174174/*}}}*/
    175 /*FUNCTION StringArrayParam::UnitConversion{{{1*/
     175/*FUNCTION StringArrayParam::UnitConversion{{{*/
    176176void  StringArrayParam::UnitConversion(int direction_enum){
    177177        /*do nothing, no unit conversion*/
  • issm/trunk/src/c/objects/Params/StringArrayParam.h

    r12330 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111#ifdef HAVE_CONFIG_H
    1212        #include <config.h>
     
    3030
    3131        public:
    32                 /*StringArrayParam constructors, destructors: {{{1*/
     32                /*StringArrayParam constructors, destructors: {{{*/
    3333                StringArrayParam();
    3434                StringArrayParam(int enum_type,char** values, int numstrings);
    3535                ~StringArrayParam();
    3636                /*}}}*/
    37                 /*Object virtual functions definitions:{{{1 */
     37                /*Object virtual functions definitions:{{{ */
    3838                void  Echo();
    3939                void  DeepEcho();
     
    4343                Object* copy();
    4444                /*}}}*/
    45                 /*Param vritual function definitions: {{{1*/
     45                /*Param vritual function definitions: {{{*/
    4646                int   InstanceEnum(){return enum_type;}
    47                 void  GetParameterValue(bool* pbool){_error_("StringArray param of enum %i (%s) cannot return a bool",enum_type,EnumToStringx(enum_type));}
    48                 void  GetParameterValue(int* pinteger){_error_("StringArray param of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type));}
    49                 void  GetParameterValue(int** pintarray,int* pM){_error_("StringArray param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
    50                 void  GetParameterValue(int** pintarray,int* pM,int* pN){_error_("StringArray param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
    51                 void  GetParameterValue(double* pdouble){_error_("StringArray param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
    52                 void  GetParameterValue(char** pstring){_error_("StringArray param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
     47                void  GetParameterValue(bool* pbool){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a bool");}
     48                void  GetParameterValue(int* pinteger){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an integer");}
     49                void  GetParameterValue(int** pintarray,int* pM){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
     50                void  GetParameterValue(int** pintarray,int* pM,int* pN){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
     51                void  GetParameterValue(IssmDouble* pIssmDouble){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble");}
     52                void  GetParameterValue(char** pstring){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string");}
    5353                void  GetParameterValue(char*** pstringarray,int* pM);
    54                 void  GetParameterValue(double** pdoublearray,int* pM){_error_("StringArray param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
    55                 void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("StringArray param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
    56                 void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("Vec param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
    57                 void  GetParameterValue(Vector** pvec){_error_("StringArray param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
    58                 void  GetParameterValue(Matrix** pmat){_error_("StringArray param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
    59                 void  GetParameterValue(FILE** pfid){_error_("StringArray param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
     54                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
     55                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
     56                void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error2_("Vec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix array");}
     57                void  GetParameterValue(Vector** pvec){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Vec");}
     58                void  GetParameterValue(Matrix** pmat){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Mat");}
     59                void  GetParameterValue(FILE** pfid){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");}
    6060
    61                 void  SetValue(bool boolean){_error_("StringArray param of enum %i (%s) cannot hold a boolean",enum_type,EnumToStringx(enum_type));}
    62                 void  SetValue(int integer){_error_("StringArray param of enum %i (%s) cannot hold an integer",enum_type,EnumToStringx(enum_type));}
    63                 void  SetValue(double scalar){_error_("StringArray param of enum %i (%s) cannot hold a scalar",enum_type,EnumToStringx(enum_type));}
    64                 void  SetValue(char* string){_error_("StringArray param of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
     61                void  SetValue(bool boolean){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a boolean");}
     62                void  SetValue(int integer){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an integer");}
     63                void  SetValue(IssmDouble scalar){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a scalar");}
     64                void  SetValue(char* string){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string");}
    6565                void  SetValue(char** stringarray,int M);
    66                 void  SetValue(double* doublearray,int M){_error_("StringArray param of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
    67                 void  SetValue(double* pdoublearray,int M,int N){_error_("StringArray param of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
    68                 void  SetValue(int* intarray,int M){_error_("StringArray param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
    69                 void  SetValue(int* pintarray,int M,int N){_error_("StringArray param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
    70                 void  SetValue(Vector* vec){_error_("StringArray param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
    71                 void  SetValue(Matrix* mat){_error_("StringArray param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
    72                 void  SetValue(FILE* fid){_error_("StringArray param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
    73                 void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("StringArray param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
     66                void  SetValue(IssmDouble* IssmDoublearray,int M){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
     67                void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
     68                void  SetValue(int* intarray,int M){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int array");}
     69                void  SetValue(int* pintarray,int M,int N){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int array");}
     70                void  SetValue(Vector* vec){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Vec");}
     71                void  SetValue(Matrix* mat){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Mat");}
     72                void  SetValue(FILE* fid){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
     73                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an array of matrices");}
    7474                void  UnitConversion(int direction_enum);
    7575
  • issm/trunk/src/c/objects/Params/StringParam.cpp

    r12330 r12706  
    44
    55/*header files: */
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*StringParam constructors and destructor*/
    23 /*FUNCTION StringParam::StringParam(){{{1*/
     23/*FUNCTION StringParam::StringParam(){{{*/
    2424StringParam::StringParam(){
    2525        return;
    2626}
    2727/*}}}*/
    28 /*FUNCTION StringParam::StringParam(int enum_type,IssmString value){{{1*/
     28/*FUNCTION StringParam::StringParam(int enum_type,IssmString value){{{*/
    2929StringParam::StringParam(int in_enum_type,char* in_value){
    3030
    3131        enum_type=in_enum_type;
    32         value=(char*)xmalloc((strlen(in_value)+1)*sizeof(char));
    33         memcpy(value,in_value,(strlen(in_value)+1)*sizeof(char));
     32        value=xNew<char>(strlen(in_value)+1);
     33        xMemCpy<char>(value,in_value,(strlen(in_value)+1));
    3434
    3535       
    3636}
    3737/*}}}*/
    38 /*FUNCTION StringParam::~StringParam(){{{1*/
     38/*FUNCTION StringParam::~StringParam(){{{*/
    3939StringParam::~StringParam(){
    40         xfree((void**)&value);
     40        xDelete<char>(value);
    4141}
    4242/*}}}*/
    4343
    4444/*Object virtual functions definitions:*/
    45 /*FUNCTION StringParam::Echo {{{1*/
     45/*FUNCTION StringParam::Echo {{{*/
    4646void StringParam::Echo(void){
    4747        this->DeepEcho();
    4848}
    4949/*}}}*/
    50 /*FUNCTION StringParam::DeepEcho{{{1*/
     50/*FUNCTION StringParam::DeepEcho{{{*/
    5151void StringParam::DeepEcho(void){
    52         printf("StringParam:\n");
    53         printf("   enum:  %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
    54         printf("   value: %s\n",this->value);
     52        _printLine_("StringParam:");
     53        _printLine_("   enum:  " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
     54        _printLine_("   value: " << this->value);
    5555}
    5656/*}}}*/
    57 /*FUNCTION StringParam::Id{{{1*/
     57/*FUNCTION StringParam::Id{{{*/
    5858int    StringParam::Id(void){ return -1; }
    5959/*}}}*/
    60 /*FUNCTION StringParam::MyRank{{{1*/
     60/*FUNCTION StringParam::MyRank{{{*/
    6161int    StringParam::MyRank(void){
    6262        extern int my_rank;
     
    6464}
    6565/*}}}*/
    66 /*FUNCTION StringParam::ObjectEnum{{{1*/
     66/*FUNCTION StringParam::ObjectEnum{{{*/
    6767int StringParam::ObjectEnum(void){
    6868
     
    7171}
    7272/*}}}*/
    73 /*FUNCTION StringParam::copy{{{1*/
     73/*FUNCTION StringParam::copy{{{*/
    7474Object* StringParam::copy() {
    7575       
     
    8080
    8181/*StringParam virtual functions definitions: */
    82 /*FUNCTION StringParam::GetParameterValue{{{1*/
     82/*FUNCTION StringParam::GetParameterValue{{{*/
    8383void  StringParam::GetParameterValue(char** pstring){
    8484       
     
    8888        stringsize=strlen(this->value)+1;
    8989
    90         outstring=(char*)xmalloc(stringsize*sizeof(char));
    91         memcpy(outstring,this->value,stringsize*sizeof(char));
     90        outstring=xNew<char>(stringsize);
     91        xMemCpy<char>(outstring,this->value,stringsize);
    9292
    9393        *pstring=outstring;
     
    9595}
    9696/*}}}*/
    97 /*FUNCTION StringParam::GetParameterName{{{1*/
     97/*FUNCTION StringParam::GetParameterName{{{*/
    9898void StringParam::GetParameterName(char**pname){
    9999        EnumToStringx(pname,this->enum_type);
    100100}
    101101/*}}}*/
    102 /*FUNCTION StringParam::SetValue{{{1*/
     102/*FUNCTION StringParam::SetValue{{{*/
    103103void  StringParam::SetValue(char* string){
    104104       
     
    106106       
    107107        /*avoid leak: */
    108         xfree((void**)&this->value);
     108        xDelete<char>(this->value);
    109109
    110110        /*copy: */
    111111        stringsize=strlen(string)+1;
    112         this->value=(char*)xmalloc(stringsize*sizeof(char));
    113         memcpy(this->value,string,stringsize*sizeof(char));
     112        this->value=xNew<char>(stringsize);
     113        xMemCpy<char>(this->value,string,stringsize);
    114114
    115115}
    116116/*}}}*/
    117 /*FUNCTION StringParam::UnitConversion{{{1*/
     117/*FUNCTION StringParam::UnitConversion{{{*/
    118118void  StringParam::UnitConversion(int direction_enum){
    119119        /*do nothing, no unit conversion*/
  • issm/trunk/src/c/objects/Params/StringParam.h

    r12330 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111#ifdef HAVE_CONFIG_H
    1212        #include <config.h>
     
    2828
    2929        public:
    30                 /*StringParam constructors, destructors: {{{1*/
     30                /*StringParam constructors, destructors: {{{*/
    3131                StringParam();
    3232                StringParam(int enum_type,char* value);
    3333                ~StringParam();
    3434                /*}}}*/
    35                 /*Object virtual functions definitions:{{{1 */
     35                /*Object virtual functions definitions:{{{ */
    3636                void  Echo();
    3737                void  DeepEcho();
     
    4141                Object* copy();
    4242                /*}}}*/
    43                 /*Param vritual function definitions: {{{1*/
     43                /*Param vritual function definitions: {{{*/
    4444                int   InstanceEnum(){return enum_type;}
    45                 void  GetParameterValue(bool* pbool){_error_("String param of enum %i (%s) cannot return a bool",enum_type,EnumToStringx(enum_type));}
    46                 void  GetParameterValue(int* pinteger){_error_("String param of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type));}
    47                 void  GetParameterValue(int** pintarray,int* pM){_error_("String param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
    48                 void  GetParameterValue(int** pintarray,int* pM,int* pN){_error_("String param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
    49                 void  GetParameterValue(double* pdouble){_error_("String param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
     45                void  GetParameterValue(bool* pbool){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a bool");}
     46                void  GetParameterValue(int* pinteger){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an integer");}
     47                void  GetParameterValue(int** pintarray,int* pM){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
     48                void  GetParameterValue(int** pintarray,int* pM,int* pN){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
     49                void  GetParameterValue(IssmDouble* pIssmDouble){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble");}
    5050                void  GetParameterValue(char** pstring);
    51                 void  GetParameterValue(char*** pstringarray,int* pM){_error_("String param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
    52                 void  GetParameterValue(double** pdoublearray,int* pM){_error_("String param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
    53                 void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("String param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
    54                 void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("String param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
    55                 void  GetParameterValue(Vector** pvec){_error_("String param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
    56                 void  GetParameterValue(Matrix** pmat){_error_("String param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
    57                 void  GetParameterValue(FILE** pfid){_error_("Bool param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
     51                void  GetParameterValue(char*** pstringarray,int* pM){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string array");}
     52                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
     53                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
     54                void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix array");}
     55                void  GetParameterValue(Vector** pvec){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Vec");}
     56                void  GetParameterValue(Matrix** pmat){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Mat");}
     57                void  GetParameterValue(FILE** pfid){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");}
    5858
    59                 void  SetValue(bool boolean){_error_("String param of enum %i (%s) cannot hold a boolean",enum_type,EnumToStringx(enum_type));}
    60                 void  SetValue(int integer){_error_("String param of enum %i (%s) cannot hold an integer",enum_type,EnumToStringx(enum_type));}
    61                 void  SetValue(double scalar){_error_("String param of enum %i (%s) cannot hold a scalar",enum_type,EnumToStringx(enum_type));}
     59                void  SetValue(bool boolean){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a boolean");}
     60                void  SetValue(int integer){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an integer");}
     61                void  SetValue(IssmDouble scalar){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a scalar");}
    6262                void  SetValue(char* string);
    63                 void  SetValue(char** stringarray,int M){_error_("String param of enum %i (%s) cannot hold a string array",enum_type,EnumToStringx(enum_type));}
    64                 void  SetValue(double* doublearray,int M){_error_("String param of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
    65                 void  SetValue(double* pdoublearray,int M,int N){_error_("String param of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
    66                 void  SetValue(int* intarray,int M){_error_("String param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
    67                 void  SetValue(int* pintarray,int M,int N){_error_("String param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
    68                 void  SetValue(Vector* vec){_error_("String param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
    69                 void  SetValue(Matrix* mat){_error_("String param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
    70                 void  SetValue(FILE* fid){_error_("String param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
    71                 void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("String param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
     63                void  SetValue(char** stringarray,int M){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string array");}
     64                void  SetValue(IssmDouble* IssmDoublearray,int M){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
     65                void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
     66                void  SetValue(int* intarray,int M){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int array");}
     67                void  SetValue(int* pintarray,int M,int N){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int array");}
     68                void  SetValue(Vector* vec){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Vec");}
     69                void  SetValue(Matrix* mat){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Mat");}
     70                void  SetValue(FILE* fid){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
     71                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an array of matrices");}
    7272                void  UnitConversion(int direction_enum);
    7373
  • issm/trunk/src/c/objects/Params/VectorParam.cpp

    r12330 r12706  
    44
    55/*header files: */
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    2121
    2222/*VectorParam constructors and destructor*/
    23 /*FUNCTION VectorParam::VectorParam(){{{1*/
     23/*FUNCTION VectorParam::VectorParam(){{{*/
    2424VectorParam::VectorParam(){
    2525        return;
    2626}
    2727/*}}}*/
    28 /*FUNCTION VectorParam::VectorParam(int enum_type,IssmVector value){{{1*/
     28/*FUNCTION VectorParam::VectorParam(int enum_type,IssmVector value){{{*/
    2929VectorParam::VectorParam(int in_enum_type,Vector* in_value){
    3030
     
    3939}
    4040/*}}}*/
    41 /*FUNCTION VectorParam::~VectorParam(){{{1*/
     41/*FUNCTION VectorParam::~VectorParam(){{{*/
    4242VectorParam::~VectorParam(){
    4343        xdelete(&value);
     
    4646
    4747/*Object virtual functions definitions:*/
    48 /*FUNCTION VectorParam::Echo {{{1*/
     48/*FUNCTION VectorParam::Echo {{{*/
    4949void VectorParam::Echo(void){
    5050
    51         printf("VectorParam:\n");
    52         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
     51        _printLine_("VectorParam:");
     52        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
    5353
    5454}
    5555/*}}}*/
    56 /*FUNCTION VectorParam::DeepEcho{{{1*/
     56/*FUNCTION VectorParam::DeepEcho{{{*/
    5757void VectorParam::DeepEcho(void){
    5858
    5959        int i;
    60         printf("VectorParam:\n");
    61         printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
     60        _printLine_("VectorParam:");
     61        _printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
    6262        value->Echo();
    6363}
    6464/*}}}*/
    65 /*FUNCTION VectorParam::Id{{{1*/
     65/*FUNCTION VectorParam::Id{{{*/
    6666int    VectorParam::Id(void){ return -1; }
    6767/*}}}*/
    68 /*FUNCTION VectorParam::MyRank{{{1*/
     68/*FUNCTION VectorParam::MyRank{{{*/
    6969int    VectorParam::MyRank(void){
    7070        extern int my_rank;
     
    7272}
    7373/*}}}*/
    74 /*FUNCTION VectorParam::ObjectEnum{{{1*/
     74/*FUNCTION VectorParam::ObjectEnum{{{*/
    7575int VectorParam::ObjectEnum(void){
    7676
     
    7979}
    8080/*}}}*/
    81 /*FUNCTION VectorParam::copy{{{1*/
     81/*FUNCTION VectorParam::copy{{{*/
    8282Object* VectorParam::copy() {
    8383       
     
    8888
    8989/*VectorParam virtual functions definitions: */
    90 /*FUNCTION VectorParam::GetParameterValue{{{1*/
     90/*FUNCTION VectorParam::GetParameterValue{{{*/
    9191void  VectorParam::GetParameterValue(Vector** poutput){
    9292        Vector*  output=NULL;
     
    9999}
    100100/*}}}*/
    101 /*FUNCTION VectorParam::GetParameterName{{{1*/
     101/*FUNCTION VectorParam::GetParameterName{{{*/
    102102void VectorParam::GetParameterName(char**pname){
    103103        EnumToStringx(pname,this->enum_type);
    104104}
    105105/*}}}*/
    106 /*FUNCTION VectorParam::SetValue{{{1*/
     106/*FUNCTION VectorParam::SetValue{{{*/
    107107void  VectorParam::SetValue(Vector* vector){
    108108
     
    115115}
    116116/*}}}*/
    117 /*FUNCTION VectorParam::UnitConversion{{{1*/
     117/*FUNCTION VectorParam::UnitConversion{{{*/
    118118void  VectorParam::UnitConversion(int direction_enum){
    119119        /*do nothing, no unit conversion*/
  • issm/trunk/src/c/objects/Params/VectorParam.h

    r12330 r12706  
    88
    99/*Headers:*/
    10 /*{{{1*/
     10/*{{{*/
    1111#ifdef HAVE_CONFIG_H
    1212        #include <config.h>
     
    2828
    2929        public:
    30                 /*VectorParam constructors, destructors: {{{1*/
     30                /*VectorParam constructors, destructors: {{{*/
    3131                VectorParam();
    3232                VectorParam(int enum_type,Vector* value);
    3333                ~VectorParam();
    3434                /*}}}*/
    35                 /*Object virtual functions definitions:{{{1 */
     35                /*Object virtual functions definitions:{{{ */
    3636                void  Echo();
    3737                void  DeepEcho();
     
    4141                Object* copy();
    4242                /*}}}*/
    43                 /*Param vritual function definitions: {{{1*/
     43                /*Param vritual function definitions: {{{*/
    4444                int   InstanceEnum(){return enum_type;}
    45                 void  GetParameterValue(bool* pbool){_error_("Vector param of enum %i (%s) cannot return a bool",enum_type,EnumToStringx(enum_type));}
    46                 void  GetParameterValue(int* pinteger){_error_("Vector param of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type));}
    47                 void  GetParameterValue(int** pintarray,int* pM){_error_("Vector param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
    48                 void  GetParameterValue(int** pintarray,int* pM,int* pN){_error_("Vector param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
    49                 void  GetParameterValue(double* pdouble){_error_("Vector param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
    50                 void  GetParameterValue(char** pstring){_error_("Vector param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
    51                 void  GetParameterValue(char*** pstringarray,int* pM){_error_("Vector param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
    52                 void  GetParameterValue(double** pdoublearray,int* pM){_error_("Vector param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
    53                 void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("Vector param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
    54                 void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("Vector param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
    55                 void  GetParameterValue(Matrix** pmat){_error_("Vector param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
     45                void  GetParameterValue(bool* pbool){_error2_("Vector param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a bool");}
     46                void  GetParameterValue(int* pinteger){_error2_("Vector param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an integer");}
     47                void  GetParameterValue(int** pintarray,int* pM){_error2_("Vector param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
     48                void  GetParameterValue(int** pintarray,int* pM,int* pN){_error2_("Vector param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
     49                void  GetParameterValue(IssmDouble* pIssmDouble){_error2_("Vector param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble");}
     50                void  GetParameterValue(char** pstring){_error2_("Vector param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string");}
     51                void  GetParameterValue(char*** pstringarray,int* pM){_error2_("Vector param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string array");}
     52                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error2_("Vector param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
     53                void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN){_error2_("Vector param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
     54                void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error2_("Vector param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix array");}
     55                void  GetParameterValue(Matrix** pmat){_error2_("Vector param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Mat");}
    5656                void  GetParameterValue(Vector** poutput);
    57                 void  GetParameterValue(FILE** pfid){_error_("Vector of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
     57                void  GetParameterValue(FILE** pfid){_error2_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");}
    5858
    59                 void  SetValue(bool boolean){_error_("Vector of enum %i (%s) cannot hold a boolean",enum_type,EnumToStringx(enum_type));}
    60                 void  SetValue(int integer){_error_("Vector of enum %i (%s) cannot hold an integer",enum_type,EnumToStringx(enum_type));}
    61                 void  SetValue(double scalar){_error_("Vector of enum %i (%s) cannot hold a scalar",enum_type,EnumToStringx(enum_type));}
    62                 void  SetValue(char* string){_error_("Vector of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
    63                 void  SetValue(char** stringarray,int M){_error_("Vector of enum %i (%s) cannot hold a string array",enum_type,EnumToStringx(enum_type));}
    64                 void  SetValue(double* doublearray,int M){_error_("Vector of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
    65                 void  SetValue(double* pdoublearray,int M,int N){_error_("Vector of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
    66                 void  SetValue(int* intarray,int M){_error_("Vector of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
    67                 void  SetValue(int* pintarray,int M,int N){_error_("Vector of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
     59                void  SetValue(bool boolean){_error2_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a boolean");}
     60                void  SetValue(int integer){_error2_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an integer");}
     61                void  SetValue(IssmDouble scalar){_error2_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a scalar");}
     62                void  SetValue(char* string){_error2_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string");}
     63                void  SetValue(char** stringarray,int M){_error2_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string array");}
     64                void  SetValue(IssmDouble* IssmDoublearray,int M){_error2_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
     65                void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error2_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
     66                void  SetValue(int* intarray,int M){_error2_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int array");}
     67                void  SetValue(int* pintarray,int M,int N){_error2_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int array");}
    6868                void  SetValue(Vector* vec);
    69                 void  SetValue(Matrix* mat){_error_("Vector of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
    70                 void  SetValue(FILE* fid){_error_("Vector of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
    71                 void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("Vector param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
     69                void  SetValue(Matrix* mat){_error2_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Mat");}
     70                void  SetValue(FILE* fid){_error2_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
     71                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error2_("Vector param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an array of matrices");}
    7272                void  UnitConversion(int direction_enum);
    7373
  • issm/trunk/src/c/objects/Patch.cpp

    r12330 r12706  
    33 */
    44
    5 /*Include files: {{{1*/
     5/*Include files: {{{*/
    66#ifdef HAVE_CONFIG_H
    77        #include <config.h>
     
    2222
    2323/*Object constructors and destructors:*/
    24 /*FUNCTION Patch::Patch() default constructor {{{1*/
     24/*FUNCTION Patch::Patch() default constructor {{{*/
    2525Patch::Patch(){
    2626        this->numrows=0;
     
    3131}
    3232/*}}}*/
    33 /*FUNCTION Patch::Patch(int numrows, int maxvertices, int maxnodes){{{1*/
     33/*FUNCTION Patch::Patch(int numrows, int maxvertices, int maxnodes){{{*/
    3434Patch::Patch(int in_numrows, int in_maxvertices, int in_maxnodes){
    3535
     
    5252        }
    5353        else{
    54                 this->values=(double*)xmalloc(this->numcols*this->numrows*sizeof(double));
     54                this->values=xNew<IssmDouble>(this->numcols*this->numrows);
    5555                for(i=0;i<this->numrows;i++){
    5656                        for(j=0;j<this->numcols;j++){
     
    6262}
    6363/*}}}*/
    64 /*FUNCTION Patch::~Patch(){{{1*/
     64/*FUNCTION Patch::~Patch(){{{*/
    6565Patch::~Patch(){
    66         xfree((void**)&values);
     66        xDelete<IssmDouble>(values);
    6767}
    6868/*}}}*/
    6969
    7070/*Object methods*/
    71 /*FUNCTION Patch::fillelementinfo{{{1*/
     71/*FUNCTION Patch::fillelementinfo{{{*/
    7272void Patch::fillelementinfo(int count, int element_id, int* vertices_ids, int num_vertices){
    7373
    7474        int i;
    75         double* row=NULL;
     75        IssmDouble* row=NULL;
    7676
    7777        /*point to the start of the row: */
     
    8888}
    8989/*}}}*/
    90 /*FUNCTION Patch::fillresultinfo{{{1*/
    91 void Patch::fillresultinfo(int count,int enum_type,int step, double time, int interpolation, double* nodal_values, int num_nodes){
     90/*FUNCTION Patch::fillresultinfo{{{*/
     91void Patch::fillresultinfo(int count,int enum_type,int step, IssmDouble time, int interpolation, IssmDouble* nodal_values, int num_nodes){
    9292
    9393        int i;
    94         double* row=NULL;
     94        IssmDouble* row=NULL;
    9595
    9696        /*point to the start of the row: */
     
    101101         */
    102102        row[0]=enum_type;
    103         row[1]=(double)step;
     103        row[1]=(IssmDouble)step;
    104104        row[2]=time;
    105105        row[4]=interpolation;
     
    110110}
    111111/*}}}*/
    112 /*FUNCTION Patch::Gather{{{1*/
     112/*FUNCTION Patch::Gather{{{*/
    113113void Patch::Gather(void){
    114114
     
    119119        int         total_numrows;
    120120        int         node_numrows;
    121         double     *total_values  = NULL;
     121        IssmDouble     *total_values  = NULL;
    122122        #ifdef _HAVE_MPI_
    123123        MPI_Status  status;
     
    136136
    137137        /*Now, allocate buffer to holds all the values, on node 0: */
    138         if(my_rank==0)total_values=(double*)xmalloc(this->numcols*total_numrows*sizeof(double));
     138        if(my_rank==0)total_values=xNew<IssmDouble>(this->numcols*total_numrows);
    139139
    140140        /*Start by copying node 0 values onto total_values: */
    141141        if(my_rank==0){
    142142                count=0;
    143                 memcpy(total_values+count,this->values,this->numcols*this->numrows*sizeof(double));
     143                xMemCpy<IssmDouble>(total_values+count,this->values,this->numcols*this->numrows);
    144144                count+=this->numrows*this->numcols;
    145145        }
     
    164164        if(my_rank==0){
    165165                this->numrows=total_numrows;
    166                 xfree((void**)&this->values);
     166                xDelete<IssmDouble>(this->values);
    167167                this->values=total_values;
    168168        }
     
    170170        else{
    171171                this->numrows=0;
    172                 xfree((void**)&this->values);
     172                xDelete<IssmDouble>(this->values);
    173173        }
    174174        #endif
  • issm/trunk/src/c/objects/Segment.cpp

    r12330 r12706  
    33 */
    44
    5 /*Include files: {{{1*/
     5/*Include files: {{{*/
    66#ifdef HAVE_CONFIG_H
    77        #include <config.h>
     
    2020
    2121/*Segment constructors and destructors:*/
    22 /*FUNCTION Segment::Segment() default constructor {{{1*/
     22/*FUNCTION Segment::Segment() default constructor {{{*/
    2323Segment::Segment(){
    2424        this->eid=UNDEF;
     
    2929}
    3030/*}}}*/
    31 /*FUNCTION Segment::Segment(int eid, double x1,double y1,double x2, double y2){{{1*/
    32 Segment::Segment(int segment_eid, double segment_x1,double segment_y1,double segment_x2, double segment_y2){
     31/*FUNCTION Segment::Segment(int eid, IssmDouble x1,IssmDouble y1,IssmDouble x2, IssmDouble y2){{{*/
     32Segment::Segment(int segment_eid, IssmDouble segment_x1,IssmDouble segment_y1,IssmDouble segment_x2, IssmDouble segment_y2){
    3333
    3434        this->eid=segment_eid;
     
    4040}
    4141/*}}}*/
    42 /*FUNCTION Segment::~Segment(){{{1*/
     42/*FUNCTION Segment::~Segment(){{{*/
    4343Segment::~Segment(){
    4444}
     
    4646
    4747/*Object virtual functions definitions:*/
    48 /*FUNCTION Segment::Echo{{{1*/
     48/*FUNCTION Segment::Echo{{{*/
    4949void Segment::Echo(void){
    5050
    51         printf("Segment:\n");
    52         printf("   eid: %i\n",eid);
    53         printf("   node 1: %g|%g\n",this->x1,this->y1);
    54         printf("   node 2: %g|%g\n",this->x2,this->y2);
     51        _printLine_("Segment:");
     52        _printLine_("   eid: " << eid);
     53        _printLine_("   node 1: " << this->x1 << "|" << this->y1);
     54        _printLine_("   node 2: " << this->x2 << "|" << this->y2);
    5555
    5656}
    5757/*}}}*/
    58 /*FUNCTION Segment::DeepEcho{{{1*/
     58/*FUNCTION Segment::DeepEcho{{{*/
    5959void Segment::DeepEcho(void){
    6060        this->Echo();
    6161}
    6262/*}}}*/
    63 /*FUNCTION Segment::Id{{{1*/
     63/*FUNCTION Segment::Id{{{*/
    6464int    Segment::Id(void){ return eid; }
    6565/*}}}*/
    66 /*FUNCTION Segment::MyRank{{{1*/
     66/*FUNCTION Segment::MyRank{{{*/
    6767int    Segment::MyRank(void){
    6868        extern int my_rank;
     
    7171}
    7272/*}}}*/
    73 /*FUNCTION Segment::ObjectEnum{{{1*/
     73/*FUNCTION Segment::ObjectEnum{{{*/
    7474int Segment::ObjectEnum(void){
    7575
     
    7878}
    7979/*}}}*/
    80 /*FUNCTION Segment::copy {{{1*/
     80/*FUNCTION Segment::copy {{{*/
    8181Object* Segment::copy() {
    8282        return new Segment(this->eid,this->x1,this->y1,this->x2,this->y2);
  • issm/trunk/src/c/objects/Segment.h

    r12330 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "./Object.h"
    1111/*}}}*/
     
    2020                IssmDouble y2;
    2121
    22                 /*Segment constructors, destructors {{{1*/
     22                /*Segment constructors, destructors {{{*/
    2323                Segment();
    2424                Segment(int eid,IssmDouble x1,IssmDouble y1, IssmDouble x2, IssmDouble y2);
    2525                ~Segment();
    2626                /*}}}*/
    27                 /*Object virtual functions definitions:{{{1 */
     27                /*Object virtual functions definitions:{{{ */
    2828                void  Echo();
    2929                void  DeepEcho();
  • issm/trunk/src/c/objects/Update.h

    r12330 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "../shared/shared.h"
    1111/*}}}*/
  • issm/trunk/src/c/objects/Vertex.cpp

    r12330 r12706  
    33 */
    44
    5 /*Include files: {{{1*/
     5/*Include files: {{{*/
    66#ifdef HAVE_CONFIG_H
    77        #include <config.h>
     
    1818
    1919/*Vertex constructors and destructor:*/
    20 /*FUNCTION Vertex::Vertex() {{{1*/
     20/*FUNCTION Vertex::Vertex() {{{*/
    2121Vertex::Vertex(){
    2222        return;
    2323}
    2424/*}}}*/
    25 /*FUNCTION Vertex::Vertex(int vertex_id, double vertex_x, double vertex_y, double vertex_z, double vertex_sigma){{{1*/
    26 Vertex::Vertex(int vertex_id, int vertex_sid,double vertex_x, double vertex_y, double vertex_z, double vertex_sigma,int vertex_connectivity){
     25/*FUNCTION Vertex::Vertex(int vertex_id, IssmDouble vertex_x, IssmDouble vertex_y, IssmDouble vertex_z, IssmDouble vertex_sigma){{{*/
     26Vertex::Vertex(int vertex_id, int vertex_sid,IssmDouble vertex_x, IssmDouble vertex_y, IssmDouble vertex_z, IssmDouble vertex_sigma,int vertex_connectivity){
    2727        this->Init(vertex_id, vertex_sid,vertex_x, vertex_y, vertex_z, vertex_sigma,vertex_connectivity);
    2828}
    2929/*}}}*/
    30 /*FUNCTION Vertex::Vertex(int vertex_id, int vertex_sid,int i, IoModel* iomodel) {{{1*/
     30/*FUNCTION Vertex::Vertex(int vertex_id, int vertex_sid,int i, IoModel* iomodel) {{{*/
    3131Vertex::Vertex(int vertex_id, int vertex_sid,int i, IoModel* iomodel){
    3232
     
    3838}
    3939/*}}}*/
    40 /*FUNCTION Vertex::~Vertex() {{{1*/
     40/*FUNCTION Vertex::~Vertex() {{{*/
    4141Vertex::~Vertex(){
    4242        return;
    4343}
    4444/*}}}*/
    45 /*FUNCTION Vertex::Init{{{1*/
    46 void Vertex::Init(int vertex_id, int vertex_sid,double vertex_x, double vertex_y, double vertex_z, double vertex_sigma,int vertex_connectivity){
     45/*FUNCTION Vertex::Init{{{*/
     46void Vertex::Init(int vertex_id, int vertex_sid,IssmDouble vertex_x, IssmDouble vertex_y, IssmDouble vertex_z, IssmDouble vertex_sigma,int vertex_connectivity){
    4747
    4848        /*all the initialization has been done by the initializer, just fill in the id: */
     
    6161
    6262/*Object virtual functions definitions:*/
    63 /*FUNCTION Vertex::Echo{{{1*/
     63/*FUNCTION Vertex::Echo{{{*/
    6464void Vertex::Echo(void){
    6565
    66         printf("Vertex:\n");
    67         printf("   id: %i\n",id);
    68         printf("   sid: %i\n",sid);
    69         printf("   x: %g\n",x);
    70         printf("   y: %g\n",y);
    71         printf("   z: %g\n",z);
    72         printf("   sigma: %g\n",sigma);
    73         printf("   connectivity: %i\n",connectivity);
    74         printf("   dof: %i\n",dof);
    75         printf("   clone: %i\n",clone);
    76 
    77         return;
    78 }
    79 /*}}}*/
    80 /*FUNCTION Vertex::DeepEcho{{{1*/
     66        _printLine_("Vertex:");
     67        _printLine_("   id: " << id);
     68        _printLine_("   sid: " << sid);
     69        _printLine_("   x: " << x);
     70        _printLine_("   y: " << y);
     71        _printLine_("   z: " << z);
     72        _printLine_("   sigma: " << sigma);
     73        _printLine_("   connectivity: " << connectivity);
     74        _printLine_("   dof: " << dof);
     75        _printLine_("   clone: " << clone);
     76
     77        return;
     78}
     79/*}}}*/
     80/*FUNCTION Vertex::DeepEcho{{{*/
    8181void Vertex::DeepEcho(void){
    8282        this->Echo();
    8383}
    8484/*}}}*/
    85 /*FUNCTION Vertex::Id{{{1*/
     85/*FUNCTION Vertex::Id{{{*/
    8686int    Vertex::Id(void){ return id; }
    8787/*}}}*/
    88 /*FUNCTION Vertex::MyRank {{{1*/
     88/*FUNCTION Vertex::MyRank {{{*/
    8989int    Vertex::MyRank(void){
    9090        extern int my_rank;
     
    9292}
    9393/*}}}*/
    94 /*FUNCTION Vertex::ObjectEnum{{{1*/
     94/*FUNCTION Vertex::ObjectEnum{{{*/
    9595int Vertex::ObjectEnum(void){
    9696
     
    9999}
    100100/*}}}*/
    101 /*FUNCTION Vertex::copy {{{1*/
     101/*FUNCTION Vertex::copy {{{*/
    102102Object* Vertex::copy() {
    103103
     
    108108
    109109/* DofObject routines: */
    110 /*FUNCTION Vertex::DistributeDofs{{{1*/
     110/*FUNCTION Vertex::DistributeDofs{{{*/
    111111void  Vertex::DistributeDofs(int* pdofcount){
    112112
     
    131131}
    132132/*}}}*/
    133 /*FUNCTION Vertex::OffsetDofs{{{1*/
     133/*FUNCTION Vertex::OffsetDofs{{{*/
    134134void  Vertex::OffsetDofs(int dofcount){
    135135       
     
    146146}
    147147/*}}}*/
    148 /*FUNCTION Vertex::ShowTrueDofs{{{1*/
     148/*FUNCTION Vertex::ShowTrueDofs{{{*/
    149149void  Vertex::ShowTrueDofs(int* truedofs){
    150150
     
    160160}
    161161/*}}}*/
    162 /*FUNCTION Vertex::UpdateCloneDofs{{{1*/
     162/*FUNCTION Vertex::UpdateCloneDofs{{{*/
    163163void  Vertex::UpdateCloneDofs(int* alltruedofs){
    164164
     
    174174}
    175175/*}}}*/
    176 /*FUNCTION Vertex::SetClone {{{1*/
     176/*FUNCTION Vertex::SetClone {{{*/
    177177void  Vertex::SetClone(int* minranks){
    178178
     
    192192
    193193/*Vertex management: */
    194 /*FUNCTION Vertex::Connectivity{{{1*/
     194/*FUNCTION Vertex::Connectivity{{{*/
    195195int    Vertex::Connectivity(void){return connectivity;}
    196196/*}}}*/
    197 /*FUNCTION Vertex::Sid{{{1*/
     197/*FUNCTION Vertex::Sid{{{*/
    198198int    Vertex::Sid(void){ return sid; }
    199199/*}}}*/
    200 /*FUNCTION Vertex::UpdateVertexPosition {{{1*/
    201 void  Vertex::UpdatePosition(Vector* vz,Parameters* parameters,double* thickness,double* bed){
    202 
    203         double oldz,newz;
    204         double dt,velz;
     200/*FUNCTION Vertex::UpdateVertexPosition {{{*/
     201void  Vertex::UpdatePosition(Vector* vz,Parameters* parameters,IssmDouble* thickness,IssmDouble* bed){
     202
     203        IssmDouble oldz,newz;
     204        IssmDouble dt,velz;
    205205
    206206        /*Get time stepping*/
  • issm/trunk/src/c/objects/Vertex.h

    r12330 r12706  
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#include "./Object.h"
    1111class IoModel;
     
    3535                int    dof; //dof to recover values in a vertex indexed vector
    3636
    37                 /*Vertex constructors, destructors {{{1*/
     37                /*Vertex constructors, destructors {{{*/
    3838                Vertex();
    3939                Vertex(int id, int sid,IssmDouble x, IssmDouble y, IssmDouble z, IssmDouble sigma, int connectivity);
     
    4242                ~Vertex();
    4343                /*}}}*/
    44                 /*Object virtual functions definitions:{{{1 */
     44                /*Object virtual functions definitions:{{{ */
    4545                void  Echo();
    4646                void  DeepEcho();
     
    5050                Object* copy();
    5151                /*}}}*/
    52                 /*DofObject routines {{{1*/
     52                /*DofObject routines {{{*/
    5353                void  DistributeDofs(int* pdofcount);
    5454                void  OffsetDofs(int dofcount);
     
    5757                void  SetClone(int* minranks);
    5858                /*}}}*/
    59                 /*Vertex management: {{{1*/
     59                /*Vertex management: {{{*/
    6060                int   Sid(void);
    6161                int   Connectivity(void);
  • issm/trunk/src/c/python/include/python_macros.h

    r12330 r12706  
    66#define _PYTHON_MACROS_H_
    77
    8 /*Header {{{1*/
     8/*Header {{{*/
    99
    1010#ifdef HAVE_CONFIG_H
     
    1616
    1717#ifdef _HAVE_PYTHON_
    18 /* MODULEBOOT/MODULEEND {{{1*/
     18/* MODULEBOOT/MODULEEND {{{*/
    1919
    2020/*The following macros hide the error exception handling in a matlab module. Just put
     
    3030//}}}
    3131#if _PYTHON_MAJOR_ >=3
    32 /* WRAPPER 3.2 {{{1*/
     32/* WRAPPER 3.2 {{{*/
    3333#define WRAPPER(modulename,...)  \
    3434\
     
    5757/*}}}*/
    5858#else
    59 /* WRAPPER 2.7 {{{1*/
     59/* WRAPPER 2.7 {{{*/
    6060#define WRAPPER(modulename,...)  \
    6161\
     
    7575/*}}}*/
    7676#endif
    77 /* CHECKARGUMENTS {{{1*/
     77/* CHECKARGUMENTS {{{*/
    7878#define CHECKARGUMENTS(NLHS,NRHS,functionpointer) CheckNumPythonArguments(args, NRHS,functionpointer)
    7979/*}}}*/
  • issm/trunk/src/c/python/io/CheckNumPythonArguments.cpp

    r12330 r12706  
    2727        if (size==0){
    2828                function();
    29                 _error_("usage: see above");
     29                _error2_("usage: see above");
    3030        }
    3131        else if (size!=NRHS ) {
    3232                function();
    33                 _error_("usage error.");
     33                _error2_("usage error.");
    3434        }
    3535        return 1;
  • issm/trunk/src/c/python/io/FetchPythonData.cpp

    r12330 r12706  
    1717
    1818/*Primitive data types*/
    19 /*FUNCTION FetchData(double* pscalar,PyObject* py_float){{{1*/
     19/*FUNCTION FetchData(double* pscalar,PyObject* py_float){{{*/
    2020void FetchData(double* pscalar,PyObject* py_float){
    2121
     
    2929}
    3030/*}}}*/
    31 /*FUNCTION FetchData(int* pinteger,PyObject* py_long){{{1*/
     31/*FUNCTION FetchData(int* pinteger,PyObject* py_long){{{*/
    3232void FetchData(int* pinteger, PyObject* py_long){
    3333
     
    4141}
    4242/*}}}*/
    43 /*FUNCTION FetchData(bool* pboolean,PyObject* py_boolean){{{1*/
     43/*FUNCTION FetchData(bool* pboolean,PyObject* py_boolean){{{*/
    4444void FetchData(bool* pboolean,PyObject* py_boolean){
    4545
     
    4747       
    4848        /*check this is indeed a subtype of long type: */
    49         if(!PyBool_Check(py_boolean))_error_("expecting a boolean in input!");
     49        if(!PyBool_Check(py_boolean))_error2_("expecting a boolean in input!");
    5050
    5151        /*extract boolean: */
     
    5757}
    5858/*}}}*/
    59 /*FUNCTION FetchData(double** pmatrix,int* pM, int* pN, PyObject* py_matrix){{{1*/
     59/*FUNCTION FetchData(double** pmatrix,int* pM, int* pN, PyObject* py_matrix){{{*/
    6060void FetchData(double** pmatrix,int* pM,int *pN,PyObject* py_matrix){
    6161
     
    6868        /*retrive dimensions: */
    6969        ndim=PyArray_NDIM((const PyArrayObject*)py_matrix);
    70         if(ndim!=2)_error_("expecting an MxN matrix in input!");
     70        if(ndim!=2)_error2_("expecting an MxN matrix in input!");
    7171        dims=PyArray_DIMS((PyArrayObject*)py_matrix);
    7272        M=dims[0]; N=dims[1];
     
    8181}
    8282/*}}}*/
    83 /*FUNCTION FetchData(double** pvector,int* pM, PyObject* py_vector){{{1*/
     83/*FUNCTION FetchData(double** pvector,int* pM, PyObject* py_vector){{{*/
    8484void FetchData(double** pvector,int* pM,PyObject* py_vector){
    8585
     
    9292        /*retrive dimensions: */
    9393        ndim=PyArray_NDIM((const PyArrayObject*)py_vector);
    94         if(ndim!=1)_error_("expecting an Mx1 vector in input!");
     94        if(ndim!=1)_error2_("expecting an Mx1 vector in input!");
    9595        dims=PyArray_DIMS((PyArrayObject*)py_vector);
    9696        M=dims[0];
     
    107107/*Python version dependent: */
    108108#if _PYTHON_MAJOR_ >= 3
    109 /*FUNCTION FetchData(char** pstring,PyObject* py_unicode){{{1*/
     109/*FUNCTION FetchData(char** pstring,PyObject* py_unicode){{{*/
    110110void FetchData(char** pstring,PyObject* py_unicode){
    111111
     
    124124/*}}}*/
    125125#else
    126 /*FUNCTION FetchData(char** pstring,PyObject* py_string){{{1*/
     126/*FUNCTION FetchData(char** pstring,PyObject* py_string){{{*/
    127127void FetchData(char** pstring,PyObject* py_string){
    128128
  • issm/trunk/src/c/python/io/WritePythonData.cpp

    r12330 r12706  
    2121
    2222
    23 /*FUNCTION WriteData(PyObject* py_tuple,int index,char* string){{{1*/
     23/*FUNCTION WriteData(PyObject* py_tuple,int index,char* string){{{*/
    2424void WriteData(PyObject* py_tuple, int index, char* string){
    2525       
    2626        PyTuple_SetItem(py_tuple, index, PyUnicode_FromString(string));
    2727
    28 }
    29 /*}}}*/
    30 /*FUNCTION WriteData(PyObject* tuple,int index,Matrix* matrix){{{1*/
     28}/*}}}*/
     29/*FUNCTION WriteData(PyObject* tuple,int index,Matrix* matrix){{{*/
    3130void WriteData(PyObject* tuple,int index,Matrix* matrix){
    3231       
     
    4544
    4645
    47 }
    48 /*FUNCTION WriteData(PyObject* py_tuple,int index,Vector* vector){{{1*/
     46}/*}}}*/
     47/*FUNCTION WriteData(PyObject* py_tuple,int index,Vector* vector){{{*/
    4948void WriteData(PyObject* tuple,int index,Vector* vector){
    5049       
     
    6463}
    6564/*}}}*/
    66 /*FUNCTION WriteData(PyObject* py_tuple,int index, double* matrix, int M, int N){{{1*/
     65/*FUNCTION WriteData(PyObject* py_tuple,int index, double* matrix, int M, int N){{{*/
    6766void WriteData(PyObject* tuple, int index, double* matrix, int M,int N){
    6867       
     
    7675        PyTuple_SetItem(tuple, index, array);
    7776
    78 }
     77}/*}}}*/
  • issm/trunk/src/c/shared/Alloc/alloc.cpp

    r12330 r12706  
    3131        void* memptr=NULL;
    3232
    33         if(!size)_error_(" attempting to 0 size allocation!");
     33        if(!size)_error2_("attempting to 0 size allocation!");
    3434
    3535        /* Use the c library to do the allocation: */
    3636        memptr=malloc(size);
    37         if(!memptr) _error_("memory allocation failed!");
     37        if(!memptr) _error2_("memory allocation failed!");
    3838
    3939        return memptr;
     
    4444        void* memptr=NULL;
    4545       
    46         if(!size)_error_("attempting to 0 size allocation!");
     46        if(!size)_error2_("attempting to 0 size allocation!");
    4747
    4848        /* Use the c library to do the allocation: */
    4949        memptr=calloc(n,size);
    50         if(!memptr) _error_("memory allocation failed!");
     50        if(!memptr) _error2_("memory allocation failed!");
    5151
    5252        return memptr;
     
    8484}
    8585
    86 
    8786void* xrealloc( void* pv, int size){
    8887       
    8988        register void* value=NULL;
    9089       
    91         if(!size)_error_("attempting to realloc to zero");
     90        if(!size)_error2_("attempting to realloc to zero");
    9291        value = (void*)realloc(pv,size);
    9392
    9493        if (value == NULL) {
    95                 _error_("virtual memory exhausted");
     94                _error2_("virtual memory exhausted");
    9695        }
    9796        return value;
  • issm/trunk/src/c/shared/Alloc/xNewDelete.h

    r12330 r12706  
    88#include <cassert>
    99
     10
     11// memory management of types
     12// T with non-trivial constructors require
     13// C++ style memory management
     14#define USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
     15// but for speed on may alternatively use C memory managment
     16// but can do so safely only for T that are at most
     17// plain old data structures (POD)
     18#ifndef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
     19#include <cstdlib>
     20#endif
     21
    1022template <class T>
    1123T* xNew(unsigned int size) {
     24#ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
    1225  T* aT_p=new T[size];
    1326  assert(aT_p);
    1427  return aT_p;
    15 };
     28#else
     29  T* aT_p=(T*)malloc(size*sizeof(T));
     30  assert(aT_p);
     31  return aT_p;
     32#endif 
     33}
     34
     35template <class T>
     36T* xNewZeroInit(unsigned int size) {
     37#ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
     38  T* aT_p=xNew<T>(size);
     39  for (unsigned int i=0; i<size;++i)
     40    aT_p[i]=(T)0;
     41  return aT_p;
     42#else
     43  T* aT_p=(T*)calloc(size,sizeof(T));
     44  assert(aT_p);
     45  return aT_p;
     46#endif
     47}
    1648
    1749template <class T>
    1850void xDelete(T*& aT_p) {
    1951  if (aT_p)
     52#ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
    2053    delete []aT_p;
     54#else
     55    free((void*)aT_p);
     56#endif
    2157  aT_p=0;
    22 };
     58}
     59
     60template <class T>
     61T* xReNew(T* old, unsigned int old_size, unsigned int size) {
     62#ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
     63  T* aT_p=0;
     64  if (!old) { // no old memory
     65    if (size) 
     66      aT_p=xNew<T>(size); // according to realloc behavior in manual page
     67  }
     68  else { // have old memory
     69    if (!size)  // but 0 size
     70      xDelete<T>(old); // according to realloc behavior in manual page
     71    else { // non-zero size
     72      assert(old_size); // have old memory - need to have old_size set or this call is bad
     73      // allocate new, delete old; ; even for the case when size is
     74      // less than old_size we can't just keep the memory unchanged
     75      // because otherwise classes that have ctors/dtors with side-effects
     76      // may misbehave, for example classes with static instance/operations counters.
     77      aT_p=xNew<T>(size);
     78      unsigned int iMax=(old_size<size)?old_size:size;
     79      for (unsigned int i=0; i<iMax;++i) {
     80        // we need to copy the items by explicit assignments
     81        aT_p[i]=old[i];
     82      }
     83      xDelete<T>(old);
     84    }
     85  }
     86  return aT_p;
     87#else
     88  T* aT_p=0;
     89  aT_p=(T*)realloc((void*)old,size*sizeof(T));
     90  if (size)
     91    assert(aT_p); // according to realloc behavior in manual page
     92  return aT_p;
     93#endif
     94}
    2395
    2496#endif
  • issm/trunk/src/c/shared/Elements/Arrhenius.cpp

    r7848 r12706  
    66#include <math.h>
    77
    8 double Arrhenius(double temperature,double depth,double n){
     8IssmDouble Arrhenius(IssmDouble temperature,IssmDouble depth,IssmDouble n){
    99        /*Use EISMINT Parameterization for the rheology: Payne2000
    1010         *
     
    2525
    2626        /*Some physical constants (Payne2000)*/
    27         double beta=8.66*pow(10.,-4.);
    28         double R=8.314;
     27        IssmDouble beta=8.66*pow(10.,-4.);
     28        IssmDouble R=8.314;
    2929
    3030        /*Intermediaries*/
    31         double A,B,Tstar;
     31        IssmDouble A,B,Tstar;
    3232
    3333        /*convert temperature to absolute temperature*/
  • issm/trunk/src/c/shared/Elements/CoordinateSystemTransform.cpp

    r10532 r12706  
    55#include <math.h>
    66
    7 void CoordinateSystemTransform(double** ptransform,Node** nodes,int numnodes,int* cs_array){
     7void CoordinateSystemTransform(IssmDouble** ptransform,Node** nodes,int numnodes,int* cs_array){
    88
    99        int     i,counter;
    1010        int     numdofs           = 0;
    11         double  norm;
    12         double *transform         = NULL;
    13         double *values            = NULL;
    14         double  coord_system[3][3];
     11        IssmDouble  norm;
     12        IssmDouble *transform         = NULL;
     13        IssmDouble *values            = NULL;
     14        IssmDouble  coord_system[3][3];
    1515
    1616        /*Some checks in debugging mode*/
     
    2222                        case XYEnum:   numdofs+=2; break;
    2323                        case XYZPEnum: numdofs+=4; break;
    24                         default: _error_("Coordinate system %s not supported yet",EnumToStringx(cs_array[i]));
     24                        default: _error2_("Coordinate system " << EnumToStringx(cs_array[i]) << " not supported yet");
    2525                }
    2626        }
    2727
    2828        /*Allocate and initialize transform matrix*/
    29         transform=(double*)xmalloc(numdofs*numdofs*sizeof(double));
     29        transform=xNew<IssmDouble>(numdofs*numdofs);
    3030        for(i=0;i<numdofs*numdofs;i++) transform[i]=0.0;
    3131
     
    6767                                break;
    6868                        default:
    69                                 _error_("Coordinate system %s not supported yet",EnumToStringx(cs_array[i]));
     69                                _error2_("Coordinate system " << EnumToStringx(cs_array[i]) << " not supported yet");
    7070                }
    7171        }
  • issm/trunk/src/c/shared/Elements/GetGlobalDofList.cpp

    r10116 r12706  
    1414
    1515                /*Allocate:*/
    16                 ndof_list=(int*)xmalloc(numnodes*sizeof(int));
     16                ndof_list=xNew<int>(numnodes);
    1717
    1818                /*First, figure out size of doflist: */
     
    2525                if(numdof){
    2626                        /*Allocate: */
    27                         doflist=(int*)xmalloc(numdof*sizeof(int));
     27                        doflist=xNew<int>(numdof);
    2828
    2929                        /*Populate: */
     
    3737        }
    3838        /*Free ressources:*/
    39         xfree((void**)&ndof_list);
     39        xDelete<int>(ndof_list);
    4040
    4141        return doflist;
  • issm/trunk/src/c/shared/Elements/GetLocalDofList.cpp

    r10104 r12706  
    1313        if(numnodes){
    1414                /*allocate: */
    15                 ndof_list=(int*)xmalloc(numnodes*sizeof(int));
    16                 ngdof_list_cumulative=(int*)xmalloc(numnodes*sizeof(int));
     15                ndof_list=xNew<int>(numnodes);
     16                ngdof_list_cumulative=xNew<int>(numnodes);
    1717
    1818
     
    3333                if(numdof){
    3434                        /*Allocate: */
    35                         doflist=(int*)xmalloc(numdof*sizeof(int));
     35                        doflist=xNew<int>(numdof);
    3636
    3737                        /*Populate: */
     
    5555
    5656        /*Free ressources:*/
    57         xfree((void**)&ndof_list);
    58         xfree((void**)&ngdof_list_cumulative);
     57        xDelete<int>(ndof_list);
     58        xDelete<int>(ngdof_list_cumulative);
    5959
    6060        /*CLean-up and return*/
  • issm/trunk/src/c/shared/Elements/GetVerticesCoordinates.cpp

    r11237 r12706  
    55#include "./elements.h"
    66
    7 void GetVerticesCoordinates(double* xyz,  Node** nodes, int numvertices){
     7void GetVerticesCoordinates(IssmDouble* xyz,  Node** nodes, int numvertices){
    88
    99        /*In debugging mode, check that nodes is not a NULL pointer*/
  • issm/trunk/src/c/shared/Elements/Paterson.cpp

    r6966 r12706  
    77#include <math.h>
    88
    9 double Paterson(double temperature){
     9#include "../../include/include.h"
     10
     11IssmDouble Paterson(IssmDouble temperature){
    1012       
    1113        /*output: */
    12         double B;
    13         double T;
     14        IssmDouble B;
     15        IssmDouble T;
    1416
    1517        /*Switch to celsius from Kelvin: */
     
    3032
    3133        if(T<=-45.0){
    32                 B=pow((double)10,(double)8)*(-0.000292866376675*pow(T+50,3)+ 0.011672640664130*pow(T+50,2)  -0.325004442485481*(T+50)+  6.524779401948101);
     34                B=pow((IssmPDouble)10,(IssmPDouble)8)*(-0.000292866376675*pow(T+50,3)+ 0.011672640664130*pow(T+50,2)  -0.325004442485481*(T+50)+  6.524779401948101);
    3335        }
    3436        else if((T>=-45.0) && (T<=-40.0)){
    35                 B=pow((double)10,(double)8)*(-0.000292866376675*pow(T+45,3)+ 0.007279645014004*pow(T+45,2)  -0.230243014094813*(T+45)+  5.154964909039554);
     37                B=pow((IssmPDouble)10,(IssmPDouble)8)*(-0.000292866376675*pow(T+45,3)+ 0.007279645014004*pow(T+45,2)  -0.230243014094813*(T+45)+  5.154964909039554);
    3638        }
    3739        else if((T>=-40.0) && (T<=-35.0)){
    38                 B=pow((double)10,(double)8)*(0.000072737147457*pow(T+40,3)+  0.002886649363879*pow(T+40,2)  -0.179411542205399*(T+40)+  4.149132666831214);
     40                B=pow((IssmPDouble)10,(IssmPDouble)8)*(0.000072737147457*pow(T+40,3)+  0.002886649363879*pow(T+40,2)  -0.179411542205399*(T+40)+  4.149132666831214);
    3941        }
    4042        else if((T>=-35.0) && (T<=-30.0)){
    41                 B=pow((double)10,(double)8)*(-0.000086144770023*pow(T+35,3)+ 0.003977706575736*pow(T+35,2)  -0.145089762507325*(T+35)+  3.333333333333331);
     43                B=pow((IssmPDouble)10,(IssmPDouble)8)*(-0.000086144770023*pow(T+35,3)+ 0.003977706575736*pow(T+35,2)  -0.145089762507325*(T+35)+  3.333333333333331);
    4244        }
    4345        else if((T>=-30.0) && (T<=-25.0)){
    44                 B=pow((double)10,(double)8)*(-0.000043984685769*pow(T+30,3)+ 0.002685535025386*pow(T+30,2)  -0.111773554501713*(T+30)+  2.696559088937191);
     46                B=pow((IssmPDouble)10,(IssmPDouble)8)*(-0.000043984685769*pow(T+30,3)+ 0.002685535025386*pow(T+30,2)  -0.111773554501713*(T+30)+  2.696559088937191);
    4547        }
    4648        else if((T>=-25.0) && (T<=-20.0)){
    47                 B=pow((double)10,(double)8)*(-0.000029799523463*pow(T+25,3)+ 0.002025764738854*pow(T+25,2)  -0.088217055680511*(T+25)+  2.199331606342181);
     49                B=pow((IssmPDouble)10,(IssmPDouble)8)*(-0.000029799523463*pow(T+25,3)+ 0.002025764738854*pow(T+25,2)  -0.088217055680511*(T+25)+  2.199331606342181);
    4850        }
    4951        else if((T>=-20.0) && (T<=-15.0)){
    50                 B=pow((double)10,(double)8)*(0.000136920904777*pow(T+20,3)+  0.001578771886910*pow(T+20,2)  -0.070194372551690*(T+20)+  1.805165505978111);
     52                B=pow((IssmPDouble)10,(IssmPDouble)8)*(0.000136920904777*pow(T+20,3)+  0.001578771886910*pow(T+20,2)  -0.070194372551690*(T+20)+  1.805165505978111);
    5153        }
    5254        else if((T>=-15.0) && (T<=-10.0)){
    53                 B=pow((double)10,(double)8)*(-0.000899763781026*pow(T+15,3)+ 0.003632585458564*pow(T+15,2)  -0.044137585824322*(T+15)+  1.510778053489523);
     55                B=pow((IssmPDouble)10,(IssmPDouble)8)*(-0.000899763781026*pow(T+15,3)+ 0.003632585458564*pow(T+15,2)  -0.044137585824322*(T+15)+  1.510778053489523);
    5456        }
    5557        else if((T>=-10.0) && (T<=-5.0)){
    56                 B=pow((double)10,(double)8)*(0.001676964325070*pow(T+10,3)-  0.009863871256831*pow(T+10,2)  -0.075294014815659*(T+10)+  1.268434288203714);
     58                B=pow((IssmPDouble)10,(IssmPDouble)8)*(0.001676964325070*pow(T+10,3)-  0.009863871256831*pow(T+10,2)  -0.075294014815659*(T+10)+  1.268434288203714);
    5759        }
    5860        else if((T>=-5.0) && (T<=-2.0)){
    59                 B=pow((double)10,(double)8)*(-0.003748937622487*pow(T+5,3)+0.015290593619213*pow(T+5,2)  -0.048160403003748*(T+5)+  0.854987973338348);
     61                B=pow((IssmPDouble)10,(IssmPDouble)8)*(-0.003748937622487*pow(T+5,3)+0.015290593619213*pow(T+5,2)  -0.048160403003748*(T+5)+  0.854987973338348);
    6062        }
    6163        else if(T>=-2.0){
    62                 B=pow((double)10,(double)8)*(-0.003748937622488*pow(T+2,3)-0.018449844983174*pow(T+2,2)  -0.057638157095631*(T+2)+  0.746900791092860);
     64                B=pow((IssmPDouble)10,(IssmPDouble)8)*(-0.003748937622488*pow(T+2,3)-0.018449844983174*pow(T+2,2)  -0.057638157095631*(T+2)+  0.746900791092860);
    6365        }
    6466
    6567        /*B cannot be negative!*/
    66         if(B<0) B=pow((double)10,(double)6);
     68        if(B<0) B=pow((IssmPDouble)10,(IssmPDouble)6);
    6769
    6870        return B;
  • issm/trunk/src/c/shared/Elements/TransformInvStiffnessMatrixCoord.cpp

    r10529 r12706  
    99
    1010        /*All nodes have the same Coordinate System*/
    11         cs_array=(int*)xmalloc(numnodes*sizeof(int));
     11        cs_array=xNew<int>(numnodes);
    1212        for(int i=0;i<numnodes;i++) cs_array[i]=cs_enum;
    1313
     
    1616
    1717        /*Clean-up*/
    18         xfree((void**)&cs_array);
     18        xDelete<int>(cs_array);
    1919}
    2020
     
    2323        int     i,j;
    2424        int     numdofs   = 0;
    25         double *transform = NULL;
    26         double *values    = NULL;
     25        IssmDouble *transform = NULL;
     26        IssmDouble *values    = NULL;
    2727
    2828        /*Get total number of dofs*/
     
    3131                        case XYEnum:   numdofs+=2; break;
    3232                        case XYZPEnum: numdofs+=4; break;
    33                         default: _error_("Coordinate system %s not supported yet",EnumToStringx(cs_array[i]));
     33                        default: _error2_("Coordinate system " << EnumToStringx(cs_array[i]) << " not supported yet");
    3434                }
    3535        }
    3636
    3737        /*Copy current stiffness matrix*/
    38         values=(double*)xmalloc(Ke->nrows*Ke->ncols*sizeof(double));
     38        values=xNew<IssmDouble>(Ke->nrows*Ke->ncols);
    3939        for(i=0;i<Ke->nrows;i++) for(j=0;j<Ke->ncols;j++) values[i*Ke->ncols+j]=Ke->values[i*Ke->ncols+j];
    4040
     
    4949
    5050        /*Free Matrix*/
    51         xfree((void**)&transform);
    52         xfree((void**)&values);
     51        xDelete<IssmDouble>(transform);
     52        xDelete<IssmDouble>(values);
    5353}
  • issm/trunk/src/c/shared/Elements/TransformLoadVectorCoord.cpp

    r10523 r12706  
    88
    99        /*All nodes have the same Coordinate System*/
    10         cs_array=(int*)xmalloc(numnodes*sizeof(int));
     10        cs_array=xNew<int>(numnodes);
    1111        for(int i=0;i<numnodes;i++) cs_array[i]=cs_enum;
    1212
     
    1515
    1616        /*Clean-up*/
    17         xfree((void**)&cs_array);
     17        xDelete<int>(cs_array);
    1818}
    1919
     
    2222        int     i,j;
    2323        int     numdofs   = 0;
    24         double *transform = NULL;
    25         double *values    = NULL;
     24        IssmDouble *transform = NULL;
     25        IssmDouble *values    = NULL;
    2626
    2727        /*Get total number of dofs*/
     
    3030                        case XYEnum:   numdofs+=2; break;
    3131                        case XYZPEnum: numdofs+=4; break;
    32                         default: _error_("Coordinate system %s not supported yet",EnumToStringx(cs_array[i]));
     32                        default: _error2_("Coordinate system " << EnumToStringx(cs_array[i]) << " not supported yet");
    3333                }
    3434        }
    3535
    3636        /*Copy current load vector*/
    37         values=(double*)xmalloc(pe->nrows*sizeof(double));
     37        values=xNew<IssmDouble>(pe->nrows);
    3838        for(i=0;i<pe->nrows;i++) values[i]=pe->values[i];
    3939
     
    4646                                &pe->values[0],0);
    4747
    48         /*Free Matrix*/
    49         xfree((void**)&transform);
    50         xfree((void**)&values);
     48        /*Free Matrices*/
     49        xDelete<IssmDouble>(transform);
     50        xDelete<IssmDouble>(values);
    5151}
  • issm/trunk/src/c/shared/Elements/TransformSolutionCoord.cpp

    r10523 r12706  
    44#include "./elements.h"
    55
    6 void TransformSolutionCoord(double* solution,Node** nodes,int numnodes,int cs_enum){
     6void TransformSolutionCoord(IssmDouble* solution,Node** nodes,int numnodes,int cs_enum){
    77
    88        int* cs_array=NULL;
    99
    1010        /*All nodes have the same Coordinate System*/
    11         cs_array=(int*)xmalloc(numnodes*sizeof(int));
     11        cs_array=xNew<int>(numnodes);
    1212        for(int i=0;i<numnodes;i++) cs_array[i]=cs_enum;
    1313
     
    1616
    1717        /*Clean-up*/
    18         xfree((void**)&cs_array);
     18        xDelete<int>(cs_array);
    1919}
    2020
    21 void TransformSolutionCoord(double* solution,Node** nodes,int numnodes,int* cs_array){
     21void TransformSolutionCoord(IssmDouble* solution,Node** nodes,int numnodes,int* cs_array){
    2222
    2323        int     i,j;
    2424        int     numdofs   = 0;
    25         double *transform = NULL;
    26         double *values    = NULL;
     25        IssmDouble *transform = NULL;
     26        IssmDouble *values    = NULL;
    2727
    2828        /*Get total number of dofs*/
     
    3131                        case XYEnum:   numdofs+=2; break;
    3232                        case XYZPEnum: numdofs+=4; break;
    33                         default: _error_("Coordinate system %s not supported yet",EnumToStringx(cs_array[i]));
     33                        default: _error2_("Coordinate system " << EnumToStringx(cs_array[i]) << " not supported yet");
    3434                }
    3535        }
    3636
    3737        /*Copy current solution vector*/
    38         values=(double*)xmalloc(numdofs*sizeof(double));
     38        values=xNew<IssmDouble>(numdofs);
    3939        for(i=0;i<numdofs;i++) values[i]=solution[i];
    4040
     
    4747                                &solution[0],0);
    4848
    49         /*Free Matrix*/
    50         xfree((void**)&transform);
    51         xfree((void**)&values);
     49        /*Free Matrices*/
     50        xDelete<IssmDouble>(transform);
     51        xDelete<IssmDouble>(values);
    5252}
  • issm/trunk/src/c/shared/Elements/TransformStiffnessMatrixCoord.cpp

    r10523 r12706  
    99
    1010        /*All nodes have the same Coordinate System*/
    11         cs_array=(int*)xmalloc(numnodes*sizeof(int));
     11        cs_array=xNew<int>(numnodes);
    1212        for(int i=0;i<numnodes;i++) cs_array[i]=cs_enum;
    1313
     
    1616
    1717        /*Clean-up*/
    18         xfree((void**)&cs_array);
     18        xDelete<int>(cs_array);
    1919}
    2020
     
    2323        int     i,j;
    2424        int     numdofs   = 0;
    25         double *transform = NULL;
    26         double *values    = NULL;
     25        IssmDouble *transform = NULL;
     26        IssmDouble *values    = NULL;
    2727
    2828        /*Get total number of dofs*/
     
    3131                        case XYEnum:   numdofs+=2; break;
    3232                        case XYZPEnum: numdofs+=4; break;
    33                         default: _error_("Coordinate system %s not supported yet",EnumToStringx(cs_array[i]));
     33                        default: _error2_("Coordinate system " << EnumToStringx(cs_array[i]) << " not supported yet");
    3434                }
    3535        }
    3636
    3737        /*Copy current stiffness matrix*/
    38         values=(double*)xmalloc(Ke->nrows*Ke->ncols*sizeof(double));
     38        values=xNew<IssmDouble>(Ke->nrows*Ke->ncols);
    3939        for(i=0;i<Ke->nrows;i++) for(j=0;j<Ke->ncols;j++) values[i*Ke->ncols+j]=Ke->values[i*Ke->ncols+j];
    4040
     
    4949
    5050        /*Free Matrix*/
    51         xfree((void**)&transform);
    52         xfree((void**)&values);
     51        xDelete<IssmDouble>(transform);
     52        xDelete<IssmDouble>(values);
    5353}
  • issm/trunk/src/c/shared/Elements/elements.h

    r12641 r12706  
    1111class ElementVector;
    1212
     13<<<<<<< .working
    1314double Paterson(double temperature);
    1415double Arrhenius(double temperature,double depth,double n);
    1516double PddSurfaceMassBlance(double* monthlytemperatures,  double* monthlyprec, double* pdds, double* pds, double signorm, double yts, double h, double s, double rho_ice, double rho_water);
    1617void   GetVerticesCoordinates(double* xyz,  Node** nodes, int numvertices);
     18=======
     19IssmDouble Paterson(IssmDouble temperature);
     20IssmDouble Arrhenius(IssmDouble temperature,IssmDouble depth,IssmDouble n);
     21void   GetVerticesCoordinates(IssmDouble* xyz,  Node** nodes, int numvertices);
     22>>>>>>> .merge-right.r12703
    1723int    GetNumberOfDofs( Node** nodes,int numnodes,int setenum,int approximation_enum);
    1824int*   GetLocalDofList( Node** nodes,int numnodes,int setenum,int approximation_enum);
    1925int*   GetGlobalDofList(Node** nodes,int numnodes,int setenum,int approximation_enum);
    2026#ifdef _HAVE_DIAGNOSTIC_
    21 void   CoordinateSystemTransform(double** ptransform,Node** nodes,int numnodes,int* cs_array);
     27void   CoordinateSystemTransform(IssmDouble** ptransform,Node** nodes,int numnodes,int* cs_array);
    2228void   TransformInvStiffnessMatrixCoord(ElementMatrix* Ke,Node** nodes,int numnodes,int cs_enum);
    2329void   TransformInvStiffnessMatrixCoord(ElementMatrix* Ke,Node** nodes,int numnodes,int* cs_array);
     
    2632void   TransformLoadVectorCoord(ElementVector* pe,Node** nodes,int numnodes,int cs_enum);
    2733void   TransformLoadVectorCoord(ElementVector* pe,Node** nodes,int numnodes,int* cs_array);
    28 void   TransformSolutionCoord(double* solution,Node** nodes,int numnodes,int cs_enum);
    29 void   TransformSolutionCoord(double* solution,Node** nodes,int numnodes,int* cs_array);
     34void   TransformSolutionCoord(IssmDouble* solution,Node** nodes,int numnodes,int cs_enum);
     35void   TransformSolutionCoord(IssmDouble* solution,Node** nodes,int numnodes,int* cs_array);
    3036#endif
    3137
    32 inline void printarray(double* array,int lines,int cols=1){
    33         printf("\n");
     38inline void printarray(IssmPDouble* array,int lines,int cols=1){
     39        _printLine_("");
    3440        for(int i=0;i<lines;i++){ 
    35                 printf("   [ ");
    36                 for(int j=0;j<cols;j++) printf(" %12.7g ",array[i*cols+j]);
    37                 printf(" ]\n");
     41                _printString_("   [ ");
     42                for(int j=0;j<cols;j++) _printString_( " " << setw(11) << setprecision (5) << array[i*cols+j]);
     43                _printLine_(" ]");
    3844        } 
    39         printf("\n");
     45        _printLine_("");
    4046}
    4147inline void printarray(int* array,int lines,int cols=1){
    42         printf("\n");
     48        _printLine_("");
    4349        for(int i=0;i<lines;i++){ 
    44                 printf("   [ ");
    45                 for(int j=0;j<cols;j++) printf(" %6i",array[i*cols+j]);
    46                 printf(" ]\n");
     50                _printString_("   [ ");
     51                for(int j=0;j<cols;j++) _printString_( " " << setw(11) << setprecision (5) << array[i*cols+j]);
     52                _printLine_(" ]");
    4753        } 
    48         printf("\n");
     54        _printLine_("");
    4955}
    5056inline void printbinary(int n) {
    5157        unsigned int i=1L<<(sizeof(n)*8-1);
    52 
    5358        while (i>0) {
    5459                if (n&i)
    55                  printf("1");
     60                 _printString_("1");
    5661                else
    57                  printf("0");
     62                 _printString_("0");
    5863                i>>=1;
    5964        }
  • issm/trunk/src/c/shared/Exceptions/Exceptions.cpp

    r12330 r12706  
    2020}
    2121
    22 ErrorException::ErrorException(string what_file,string what_function,int what_line,string what_arg){
     22ErrorException::ErrorException(const string& what_file, const string& what_function,int what_line, const string& what_arg){
    2323
    2424        what_str=what_arg;
     
    4444
    4545        if (function_name=="" || file_line==0){ //WINDOWS
    46                 printf("%s%s","Error message: ",what());
     46                _printString_("Error message: " << what());
    4747        }
    4848        else{
    4949                if(num_procs==1){
    50                         printf("\n??? Error using ==> %s:%i\n",file_name.c_str(),file_line);
    51                         printf("%s error message: %s\n\n",function_name.c_str(),what());
     50                        _printLine_("\n??? Error using ==> " << file_name.c_str() << ":" << file_line);
     51                        _printLine_(function_name.c_str() << " error message: " << what() << "\n");
    5252                }
    5353                else{
    54                         printf("\n[%i] ??? Error using ==> %s:%i\n",my_rank,file_name.c_str(),file_line);
    55                         printf("[%i] %s error message: %s\n\n",my_rank,function_name.c_str(),what());
     54                        _printLine_("\n[" << my_rank << "] ??? Error using ==> " << file_name.c_str() << ":" << file_line);
     55                        _printLine_("[" << my_rank << "] " << function_name.c_str() << " error message: " << what() << "\n");
    5656                }
    5757        }
  • issm/trunk/src/c/shared/Exceptions/exceptions.h

    r12330 r12706  
    2424        public:
    2525        ErrorException(const string &what_arg); //for windows
    26         ErrorException(string what_file,string what_function,int what_line,string what_arg);//UNIX
     26        ErrorException(const string&  what_file,const string& what_function,int what_line,const string& what_arg);//UNIX
    2727        ~ErrorException() throw();
    2828        virtual const char *what() const throw();
  • issm/trunk/src/c/shared/Exceptions/exprintf.cpp

    r11237 r12706  
    99#include <stdarg.h>
    1010#include <stdio.h>
     11#include "../Alloc/xNewDelete.h"
    1112#include "../Alloc/alloc.h"
    1213
     
    1415
    1516        /*returned string: */
    16         char* string=NULL;
     17        char *buffer = NULL;
     18        int   n,size = 100;
     19        int   string_size;
    1720
    18         /*Assum nobody will print more that 1024 characters!*/
    19         string=(char*)xmalloc(1024*sizeof(char));//assume that nobody will print more than 1024 characters at once.
    20                                                                                                                                                                                                      
    2121        //variable list of arguments
    22         va_list ap;
     22        va_list args;
    2323
    24         //First use vsprintf to get the whole input string.
    25         va_start(ap,format);
    26         vsprintf(string,format,ap); //printf style coding
    27         va_end(ap);
     24        while(true){
    2825
    29         return string;
     26                /*allocate buffer for given string size*/
     27                buffer=xNew<char>(size);
     28
     29                /* Try to print in the allocated space. */
     30                va_start(args, format);
     31#ifndef WIN32
     32                n=vsnprintf(buffer,size,format,args);
     33#else
     34                n=vsnprintf(buffer,size,format,args);
     35#endif
     36                va_end(args);
     37
     38                /* If that worked, return the string. */
     39                if(n>-1 && n<size) break;
     40
     41                /* Else try again with more space. */
     42                if(n>-1)   /* glibc 2.1 */
     43                 size=n+1; /* precisely what is needed */
     44                else       /* glibc 2.0 */
     45                 size*=2;  /* twice the old size */
     46
     47                xDelete<char>(buffer);
     48        }
     49
     50        return buffer;
    3051}
  • issm/trunk/src/c/shared/Exp/DomainOutlineRead.cpp

    r12349 r12706  
    2020
    2121        /*I/O: */
    22         FILE* fid=NULL;
    23         char chardummy[256];
     22        FILE   *fid = NULL;
     23        char    chardummy[256];
    2424        double  ddummy;
    2525
    2626        /*output: */
    27         int nprof; //number of profiles in the domainname file
    28         int* profnvertices=NULL; //array holding the number of vertices for the nprof profiles
    29         double** pprofx=NULL; //array of profiles x coordinates
    30         double** pprofy=NULL; //array of profiles y coordinates
    31         bool* closed=NULL; //array holding closed flags for the nprof profiles
     27        int      nprof;                //number of profiles in the domainname file
     28        int     *profnvertices = NULL; //array holding the number of vertices for the nprof profiles
     29        double **pprofx        = NULL; //array of profiles x coordinates
     30        double **pprofy        = NULL; //array of profiles y coordinates
     31        bool    *closed        = NULL; //array holding closed flags for the nprof profiles
    3232
    3333        /*For each profile: */
    34         int n;
    35         double* x=NULL;
    36         double* y=NULL;
    37         bool cl;
     34        int     n;
     35        double *x  = NULL;
     36        double *y  = NULL;
     37        bool    cl;
    3838
    3939        /*open domain outline file for reading: */
    4040        if ((fid=fopen(domainname,"r"))==NULL){
    41                 _error_("%s%s","could not find domain file ",domainname);
     41                _error2_("could not find domain file " << domainname);
    4242        }
    4343
     
    6262       
    6363        /*Allocate and initialize all the profiles: */
    64         profnvertices=(int*)xmalloc(nprof*sizeof(int));
    65         pprofx=(double**)xmalloc(nprof*sizeof(double*));
    66         pprofy=(double**)xmalloc(nprof*sizeof(double*));
     64        profnvertices=xNew<int>(nprof);
     65        pprofx=xNew<double*>(nprof);
     66        pprofy=xNew<double*>(nprof);
    6767        for (i=0;i<nprof;i++){
    6868                pprofx[i]=NULL;
    6969                pprofy[i]=NULL;
    7070        }
    71         closed=(bool*)xmalloc(nprof*sizeof(bool));
     71        closed=xNew<bool>(nprof);
    7272
    7373        /*Reaset file pointer to beginning of file: */
     
    8989
    9090                /*Allocate vertices: */
    91                 x=(double*)xmalloc(n*sizeof(double));
    92                 y=(double*)xmalloc(n*sizeof(double));
     91                x=xNew<double>(n);
     92                y=xNew<double>(n);
    9393               
    94 
    9594                /*Read vertices: */
    9695                for (i=0;i<n;i++){
     
    119118        *ppprofx=pprofx;
    120119        *ppprofy=pprofy;
    121         if(pclosed)*pclosed=closed;
    122         else       xfree((void**)&closed);
     120        if(pclosed)
     121         *pclosed=closed;
     122        else
     123         xDelete<bool>(closed);
    123124}
    124125
  • issm/trunk/src/c/shared/Exp/DomainOutlineWrite.cpp

    r12330 r12706  
    2323        /*open domain outline file for writing: */
    2424        if ((fid=fopen(domainname,"w"))==NULL){
    25                 _error_("%s%s","could not open domain file ",domainname);
     25                _error2_("could not open domain file " << domainname);
    2626                noerr=0; goto cleanupandreturn;
    2727        }
  • issm/trunk/src/c/shared/Exp/IsInPoly.cpp

    r11995 r12706  
    1414#endif
    1515
    16 /*IsInPoly {{{1*/
     16/*IsInPoly {{{*/
    1717int IsInPoly(Vector* in,double* xc,double* yc,int numvertices,double* x,double* y,int i0,int i1, int edgevalue){
    1818
     
    5555         return 1;
    5656}/*}}}*/
    57 /*IsOutsidePoly {{{1*/
     57/*IsOutsidePoly {{{*/
    5858int IsOutsidePoly(Vector* in,double* xc,double* yc,int numvertices,double* x,double* y,int i0,int i1, int edgevalue){
    5959
     
    9696        return 1;
    9797}/*}}}*/
    98 /*pnpoly{{{1*/
     98/*pnpoly{{{*/
    9999int pnpoly(int npol, double *xp, double *yp, double x, double y, int edgevalue) {
    100100        int i, j, c = 0;
  • issm/trunk/src/c/shared/Matrix/MatrixUtils.cpp

    r11995 r12706  
    44
    55/*Headers*/
    6 /*{{{1*/
     6/*{{{*/
    77#include "./matrix.h"
    88#include "../Exceptions/exceptions.h"
     
    1616/*}}}*/
    1717
    18 /*FUNCTION TripleMultiply {{{1*/
    19 int TripleMultiply( double* a, int nrowa, int ncola, int itrna, double* b, int nrowb, int ncolb, int itrnb, double* c, int nrowc, int ncolc, int itrnc, double* d, int iaddd){
     18/*FUNCTION TripleMultiply {{{*/
     19int TripleMultiply( IssmDouble* a, int nrowa, int ncola, int itrna, IssmDouble* b, int nrowb, int ncolb, int itrnb, IssmDouble* c, int nrowc, int ncolc, int itrnc, IssmDouble* d, int iaddd){
    2020        /*TripleMultiply    Perform triple matrix product a*b*c+d.*/
    2121       
    2222        int idima,idimb,idimc,idimd;
    23         double* dtemp;
     23        IssmDouble* dtemp;
    2424
    2525/*  set up dimensions for triple product  */
     
    3636        if (!itrnb) {
    3737                if (nrowb != idimb) {
    38                         _error_("Matrix A and B inner vectors not equal size.");
     38                        _error2_("Matrix A and B inner vectors not equal size.");
    3939                }
    4040                idimc=ncolb;
     
    4242        else {
    4343                if (ncolb != idimb) {
    44                         _error_("Matrix A and B inner vectors not equal size.");
     44                        _error2_("Matrix A and B inner vectors not equal size.");
    4545                }
    4646                idimc=nrowb;
     
    4949        if (!itrnc) {
    5050                if (nrowc != idimc) {
    51                         _error_("Matrix B and C inner vectors not equal size.");
     51                        _error2_("Matrix B and C inner vectors not equal size.");
    5252                }
    5353                idimd=ncolc;
     
    5555        else {
    5656                if (ncolc != idimc) {
    57                         _error_("Matrix B and C inner vectors not equal size.");
     57                        _error2_("Matrix B and C inner vectors not equal size.");
    5858                }
    5959                idimd=nrowc;
     
    6262/*  perform the matrix triple product in the order that minimizes the
    6363        number of multiplies and the temporary space used, noting that
    64         (a*b)*c requires ac(b+d) multiplies and ac doubles, and a*(b*c)
    65         requires bd(a+c) multiplies and bd doubles (both are the same for
     64        (a*b)*c requires ac(b+d) multiplies and ac IssmDoubles, and a*(b*c)
     65        requires bd(a+c) multiplies and bd IssmDoubles (both are the same for
    6666        a symmetric triple product)  */
    6767
     
    6969
    7070        if (idima*idimc*(idimb+idimd) <= idimb*idimd*(idima+idimc)) {
    71                 dtemp=(double *) xmalloc(idima*idimc*sizeof(double));
    72 
    73                 MatrixMultiply(a    ,nrowa,ncola,itrna,
    74                                    b    ,nrowb,ncolb,itrnb,
    75                                    dtemp,0);
    76                 MatrixMultiply(dtemp,idima,idimc,0    ,
    77                                    c    ,nrowc,ncolc,itrnc,
    78                                    d    ,iaddd);
    79 
    80                 xfree((void **)&dtemp);
     71                dtemp=xNew<IssmDouble>(idima*idimc);
     72
     73                MatrixMultiply(a,nrowa,ncola,itrna,b,nrowb,ncolb,itrnb,dtemp,0);
     74                MatrixMultiply(dtemp,idima,idimc,0,c,nrowc,ncolc,itrnc,d,iaddd);
     75                xDelete<IssmDouble>(dtemp);
    8176        }
    8277
     
    8479
    8580        else {
    86                 dtemp=(double *) xmalloc(idimb*idimd*sizeof(double));
    87 
    88                 MatrixMultiply(b    ,nrowb,ncolb,itrnb,
    89                                    c    ,nrowc,ncolc,itrnc,
    90                                    dtemp,0);
    91                 MatrixMultiply(a    ,nrowa,ncola,itrna,
    92                                    dtemp,idimb,idimd,0    ,
    93                                    d    ,iaddd);
    94 
    95                 xfree((void **)&dtemp);
     81                dtemp=xNew<IssmDouble>(idimb*idimd);
     82
     83                MatrixMultiply(b,nrowb,ncolb,itrnb,c,nrowc,ncolc,itrnc,dtemp,0);
     84                MatrixMultiply(a,nrowa,ncola,itrna,dtemp,idimb,idimd,0,d,iaddd);
     85                xDelete<IssmDouble>(dtemp);
    9686        }
    9787
    9888        return 1;
    9989}/*}}}*/
    100 /*FUNCTION MatrixMuliply {{{1*/
    101 int MatrixMultiply( double* a, int nrowa, int ncola, int itrna, double* b, int nrowb, int ncolb, int itrnb, double* c, int iaddc ){
     90/*FUNCTION MatrixMuliply {{{*/
     91int MatrixMultiply( IssmDouble* a, int nrowa, int ncola, int itrna, IssmDouble* b, int nrowb, int ncolb, int itrnb, IssmDouble* c, int iaddc ){
    10292        /*MatrixMultiply    Perform matrix multiplication a*b+c.*/
    10393        int noerr=1;
     
    134124
    135125        if (ntrma != ntrmb) {
    136                 _error_("Matrix A and B inner vectors not equal size");
     126                _error2_("Matrix A and B inner vectors not equal size");
    137127            noerr=0;   
    138128                return noerr;
     
    167157        return noerr;
    168158}/*}}}*/
    169 /*FUNCTION MatrixInverse {{{1*/
    170 int MatrixInverse( double* a, int ndim, int nrow, double* b, int nvec, double* pdet ){
     159/*FUNCTION MatrixInverse {{{*/
     160int MatrixInverse( IssmDouble* a, int ndim, int nrow, IssmDouble* b, int nvec, IssmDouble* pdet ){
    171161/* MatrixInverse    Perform matrix inversion and linear equation solution.
    172162
     
    181171        int noerr=1;
    182172        int i,j,k,ipt,jpt,irow,icol,ipiv,ncol;
    183         int (*pivrc)[2],*pindx;
    184         double pivot,det,dtemp;
     173        int *pivrc1,*pivrc2,*pindx;
     174        IssmDouble pivot,det,dtemp;
    185175
    186176        if (!b && nvec) {
    187                 _error_("No right-hand side for nvec=%d.",nvec);
     177                _error2_("No right-hand side for nvec=" << nvec << ".");
    188178                noerr=0;
    189179                return noerr;
     
    198188        ncol=nrow;
    199189        det=1.;
    200 
    201         pivrc = (int (*)[2]) xmalloc((nrow*2)*sizeof(int));
    202         pindx = (int (*)   ) xcalloc( nrow   ,sizeof(int));
     190        pivrc1 =xNew<int>(nrow);
     191        pivrc2 =xNew<int>(nrow);
     192        pindx =xNew<int>(nrow);
    203193
    204194/*  loop over the rows/columns of the matrix  */
     
    221211
    222212                if (fabs(pivot) < DBL_EPSILON) {
    223                         xfree((void **)&pivrc);
    224                         xfree((void **)&pindx);
    225                         _error_("Pivot %f less than machine epsilon",pivot);
     213                        xDelete<int>(pivrc1);
     214                        xDelete<int>(pivrc2);
     215                        xDelete<int>(pindx);
     216                        _error2_("Pivot " << pivot << " less than machine epsilon");
    226217                        noerr=0;
    227218                        return noerr;
    228219                }
    229220
    230                 pivrc[i][0]=irow;
    231                 pivrc[i][1]=icol;
     221                pivrc1[i]=irow;
     222                pivrc2[i]=icol;
    232223
    233224                ipiv=icol;
     
    319310                j=(nrow-1)-i;
    320311
    321                 if (pivrc[j][0] != pivrc[j][1]) {
    322                         irow=pivrc[j][0];
    323                         icol=pivrc[j][1];
     312                if (pivrc1[j] != pivrc2[j]) {
     313                        irow=pivrc1[j];
     314                        icol=pivrc2[j];
    324315
    325316//                      _printf_(true,"column switch back for j=%d: irow=%d, icol=%d\n",
     
    336327        }
    337328
    338         if (pdet)
    339                 *pdet=det;
    340 
    341         xfree((void **)&pivrc);
    342         xfree((void **)&pindx);
    343 
     329        if (pdet) *pdet=det;
     330        xDelete<int>(pivrc1);
     331        xDelete<int>(pivrc2);
     332        xDelete<int>(pindx);
    344333        return noerr;
    345334}/*}}}*/
    346 /*FUNCTION Matrix2x2Determinant(double* Adet,double* A) {{{1*/
    347 void Matrix2x2Determinant(double* Adet,double* A){
     335/*FUNCTION Matrix2x2Determinant(IssmDouble* Adet,IssmDouble* A) {{{*/
     336void Matrix2x2Determinant(IssmDouble* Adet,IssmDouble* A){
    348337        /*Compute determinant of a 2x2 matrix*/
    349338
     
    352341}
    353342/*}}}*/
    354 /*FUNCTION Matrix2x2Invert(double* Ainv,double* A) {{{1*/
    355 void Matrix2x2Invert(double* Ainv,double* A){
     343/*FUNCTION Matrix2x2Invert(IssmDouble* Ainv,IssmDouble* A) {{{*/
     344void Matrix2x2Invert(IssmDouble* Ainv,IssmDouble* A){
    356345
    357346        /*Intermediaries*/
    358         double det;
     347        IssmDouble det;
    359348
    360349        /*Compute determinant*/
    361350        Matrix2x2Determinant(&det,A);
    362         if (fabs(det) < DBL_EPSILON) _error_("Determinant smaller that machine epsilon");
     351        if (fabs(det) < DBL_EPSILON) _error2_("Determinant smaller that machine epsilon");
    363352
    364353        /*Compute invert*/
     
    369358
    370359}/*}}}*/
    371 /*FUNCTION Matrix3x3Determinant(double* Adet,double* A) {{{1*/
    372 void Matrix3x3Determinant(double* Adet,double* A){
     360/*FUNCTION Matrix3x3Determinant(IssmDouble* Adet,IssmDouble* A) {{{*/
     361void Matrix3x3Determinant(IssmDouble* Adet,IssmDouble* A){
    373362        /*Compute determinant of a 3x3 matrix*/
    374363
     
    377366}
    378367/*}}}*/
    379 /*FUNCTION Matrix3x3Invert(double* Ainv,double* A) {{{1*/
    380 void Matrix3x3Invert(double* Ainv,double* A){
     368/*FUNCTION Matrix3x3Invert(IssmDouble* Ainv,IssmDouble* A) {{{*/
     369void Matrix3x3Invert(IssmDouble* Ainv,IssmDouble* A){
    381370
    382371        /*Intermediaries*/
    383         double det;
     372        IssmDouble det;
    384373
    385374        /*Compute determinant*/
    386375        Matrix3x3Determinant(&det,A);
    387         if (fabs(det) < DBL_EPSILON) _error_("Determinant smaller that machine epsilon");
     376        if (fabs(det) < DBL_EPSILON) _error2_("Determinant smaller that machine epsilon");
    388377
    389378        /*Compute invert*/
     
    399388
    400389}/*}}}*/
    401 /*FUNCTION MatrixTranspose(double* Adet,double* A) {{{1*/
    402 void MatrixTranspose(double* tA,double* A, int nrows, int ncols){
     390/*FUNCTION MatrixTranspose(IssmDouble* Adet,IssmDouble* A) {{{*/
     391void MatrixTranspose(IssmDouble* tA,IssmDouble* A, int nrows, int ncols){
    403392        /*Transpose a n*m matrix*/
    404393
  • issm/trunk/src/c/shared/Matrix/matrix.h

    r5371 r12706  
    66#define _MATRIXUTILS_H_
    77
    8 int  TripleMultiply( double* a, int nrowa, int ncola, int itrna, double* b, int nrowb, int ncolb, int itrnb, double* c, int nrowc, int ncolc, int itrnc, double* d, int iaddd);
    9 int  MatrixMultiply( double* a, int nrowa, int ncola, int itrna, double* b, int nrowb, int ncolb, int itrnb, double* c, int iaddc );
    10 int  MatrixInverse( double* a, int ndim, int nrow, double* b, int nvec, double* pdet );
    11 void Matrix2x2Invert(double* Ainv, double* A);
    12 void Matrix2x2Determinant(double* Adet,double* A);
    13 void Matrix3x3Invert(double* Ainv, double* A);
    14 void Matrix3x3Determinant(double* Adet,double* A);
    15 void MatrixTranspose(double* tA,double* A,int nrows, int ncols);
     8#include "../../include/include.h"
     9
     10int  TripleMultiply( IssmDouble* a, int nrowa, int ncola, int itrna, IssmDouble* b, int nrowb, int ncolb, int itrnb, IssmDouble* c, int nrowc, int ncolc, int itrnc, IssmDouble* d, int iaddd);
     11int  MatrixMultiply( IssmDouble* a, int nrowa, int ncola, int itrna, IssmDouble* b, int nrowb, int ncolb, int itrnb, IssmDouble* c, int iaddc );
     12int  MatrixInverse( IssmDouble* a, int ndim, int nrow, IssmDouble* b, int nvec, IssmDouble* pdet );
     13void Matrix2x2Invert(IssmDouble* Ainv, IssmDouble* A);
     14void Matrix2x2Determinant(IssmDouble* Adet,IssmDouble* A);
     15void Matrix3x3Invert(IssmDouble* Ainv, IssmDouble* A);
     16void Matrix3x3Determinant(IssmDouble* Adet,IssmDouble* A);
     17void MatrixTranspose(IssmDouble* tA,IssmDouble* A,int nrows, int ncols);
    1618
    1719#endif //ifndef _MATRIXUTILS_H_
  • issm/trunk/src/c/shared/Numerics/BrentSearch.cpp

    r9761 r12706  
    1515#include "../../shared/shared.h"
    1616#include <float.h>
    17 
    18 void BrentSearch(double* psearch_scalar,double* pJ,OptPars* optpars,double (*f)(double,OptArgs*), OptArgs* optargs){
     17#include <iomanip>
     18
     19void BrentSearch(IssmDouble* psearch_scalar,IssmDouble* pJ,OptPars* optpars,IssmDouble (*f)(IssmDouble,OptArgs*), OptArgs* optargs){
    1920
    2021        /* This routine is optimizing a given function using Brent's method
     
    2223
    2324        /*Intermediary*/
    24         double si,gold,intervalgold,oldintervalgold;
    25         double parab_num,parab_den;
    26         double distance,cm_jump;
    27         double fxmax,fxmin,fxbest;
    28         double fx,fx1,fx2;
    29         double xmax,xmin,xbest;
    30         double x,x1,x2,xm;
    31         double tol1,tol2,seps;
    32         double tolerance=1.e-4;
    33         int    maxiter,iter;
    34         bool   loop=true,goldenflag;
     25        IssmDouble si,gold,intervalgold,oldintervalgold;
     26        IssmDouble parab_num,parab_den;
     27        IssmDouble distance,cm_jump;
     28        IssmDouble fxmax,fxmin,fxbest;
     29        IssmDouble fx,fx1,fx2;
     30        IssmDouble xmax,xmin,xbest;
     31        IssmDouble x,x1,x2,xm;
     32        IssmDouble tol1,tol2,seps;
     33        IssmDouble tolerance = 1.e-4;
     34        int        maxiter ,iter;
     35        bool       loop= true,goldenflag;
    3536
    3637        /*Recover parameters:*/
     
    4344        iter=0;
    4445        fxmin = (*f)(xmin,optargs);
    45         if (isnan(fxmin)) _error_("Function evaluation returned NaN");
    46         _printf_(VerboseControl(),"\n        Iteration         x           f(x)       Tolerance         Procedure\n\n");
    47         _printf_(VerboseControl(),"        %s    %12.6g  %12.6g  %s","   N/A",xmin,fxmin,"         N/A         boundary\n");
     46        if (xIsNan<IssmDouble>(fxmin)) _error2_("Function evaluation returned NaN");
     47        cout<<setprecision(5);
     48        if(VerboseControl()) _pprintLine_("");
     49        if(VerboseControl()) _pprintLine_("       Iteration         x           f(x)       Tolerance         Procedure");
     50        if(VerboseControl()) _pprintLine_("");
     51        if(VerboseControl()) _pprintLine_("           N/A    "<<setw(12)<<xmin<<"  "<<setw(12)<<fxmin<<"           N/A         boundary");
    4852        fxmax = (*f)(xmax,optargs);
    49         if (isnan(fxmax)) _error_("Function evaluation returned NaN");
    50         _printf_(VerboseControl(),"        %s    %12.6g  %12.6g  %s","   N/A",xmax,fxmax,"         N/A         boundary\n");
     53        if (xIsNan<IssmDouble>(fxmax)) _error2_("Function evaluation returned NaN");
     54        if(VerboseControl()) _pprintLine_("           N/A    "<<setw(12)<<xmax<<"  "<<setw(12)<<fxmax<<"           N/A         boundary");
    5155
    5256        /*test if jump option activated and xmin==0*/
    53         if (!isnan(cm_jump) && (xmin==0) && (fxmax/fxmin)<cm_jump){
     57        if (!xIsNan<IssmDouble>(cm_jump) && (xmin==0) && (fxmax/fxmin)<cm_jump){
    5458                *psearch_scalar=xmax;
    5559                *pJ=fxmax;
     
    5862
    5963        /*initialize optimization variables*/
    60         seps=sqrt(DBL_EPSILON);    //precision of a double
     64        seps=sqrt(DBL_EPSILON);    //precision of a IssmDouble
    6165        distance=0.0;              //new_x=old_x + distance
    6266        gold=0.5*(3.0-sqrt(5.0));  //gold = 1 - golden ratio
     
    7175        /*2: call the function to be evaluated*/
    7276        fxbest = (*f)(x,optargs);
    73         if(isnan(fxbest)) _error_("Function evaluation returned NaN");
     77        if(xIsNan<IssmDouble>(fxbest)) _error2_("Function evaluation returned NaN");
    7478        iter=iter+1;
    7579
     
    8488
    8589        /*4: print result*/
    86         _printf_(VerboseControl(),"         %5i    %12.6g  %12.6g  %12.6g  %s\n",iter,xbest,fxbest,pow(pow(xbest-xm,2),0.5),"       initial");
    87         if (!isnan(cm_jump) && (xmin==0) && ((fxbest/fxmin)<cm_jump)){
    88                 _printf_(VerboseControl(),"      optimization terminated: current x satisfies criteria 'cm_jump'=%g\n",cm_jump);
     90        if(VerboseControl())
     91         _pprintLine_("         "<<setw(5)<<iter<<"    "<<setw(12)<<xbest<<"  "<<setw(12)<<fxbest<<"  "<<setw(12)<<pow(pow(xbest-xm,2),0.5)<<"         initial");
     92        if (!xIsNan<IssmDouble>(cm_jump) && (xmin==0) && ((fxbest/fxmin)<cm_jump)){
     93                if(VerboseControl()) _pprintLine_("      optimization terminated: current x satisfies criteria 'cm_jump'=" << cm_jump);
    8994                loop=false;
    9095        }
     
    154159                //evaluate function on x
    155160                fx = (*f)(x,optargs);
    156                 if(isnan(fx)) _error_("Function evaluation returned NaN");
     161                if(xIsNan<IssmDouble>(fx)) _error2_("Function evaluation returned NaN");
    157162                iter=iter+1;
    158163
     
    179184                tol1=seps*pow(pow(xbest,2),0.5)+tolerance/3.0;
    180185                tol2=2.0*tol1;
    181                 _printf_(VerboseControl(),"         %5i    %12.6g  %12.6g  %12.6g  %s\n",iter,x,fx,pow(pow(xbest-xm,2),0.5),goldenflag?"       golden":"       parabolic");
     186                if(VerboseControl())
     187                 _pprintLine_("         "<<setw(5)<<iter<<"    "<<setw(12)<<x<<"  "<<setw(12)<<fx<<"  "<<setw(12)<<pow(pow(xbest-xm,2),0.5)<<
     188                                         "         "<<(goldenflag?"golden":"parabolic"));
    182189
    183190                /*Stop the optimization?*/
    184191                if (sqrt(pow(xbest-xm,2)) < (tol2-0.5*(xmax-xmin))){
    185                         _printf_(VerboseControl(),"      optimization terminated: current x satisfies criteria 'tolx'=%g\n",tolerance);
     192                        if(VerboseControl()) _pprintLine_("      optimization terminated: current x satisfies criteria 'tolx'=" << tolerance);
    186193                        loop=false;
    187194                }
    188195                else if (iter>=maxiter){
    189                         _printf_(VerboseControl(),"      exiting: Maximum number of iterations has been exceeded  ('maxiter'=%i)\n",maxiter);
     196                        if(VerboseControl()) _pprintLine_("      exiting: Maximum number of iterations has been exceeded  ('maxiter'=" << maxiter << ")");
    190197                        loop=false;
    191198                }
    192                 else if (!isnan(cm_jump) && (xmin==0) && ((fxbest/fxmin)<cm_jump)){
    193                         _printf_(VerboseControl(),"      optimization terminated: current x satisfies criteria 'cm_jump'=%g\n",cm_jump);
     199                else if (!xIsNan<IssmDouble>(cm_jump) && (xmin==0) && ((fxbest/fxmin)<cm_jump)){
     200                        if(VerboseControl()) _pprintLine_("      optimization terminated: current x satisfies criteria 'cm_jump'=" << cm_jump);
    194201                        loop=false;
    195202                }
  • issm/trunk/src/c/shared/Numerics/GaussPoints.cpp

    r11995 r12706  
    11/*  Gauss point structures and prototypes  */
    22
     3#include "../../include/include.h"
    34#include "./GaussPoints.h"
    45#include "../Alloc/alloc.h"
    5 #include "../../include/include.h"
    66#include "../../io/io.h"
    77#include "../Exceptions/exceptions.h"
     
    1010
    1111/*General Gauss points*/
    12 /*FUNCTION GaussLegendreLinear {{{1*/
    13 void GaussLegendreLinear( double** pxgaus, double** pxwgt, int ngaus){
     12/*FUNCTION GaussLegendreLinear {{{*/
     13void GaussLegendreLinear( IssmPDouble** pxgaus, IssmPDouble** pxwgt, int ngaus){
    1414        /* Gauss-Legendre quadrature points.
    1515
     
    2525        /*Intermediaries*/
    2626        int i;
    27         double *alpha,*beta;
     27        IssmPDouble *alpha,*beta;
    2828
    2929        /*p= 1, npoint= 1*/
    30         static double wgt1[]={2.000000000000000};
    31         static double xi1[]={0.000000000000000};
     30        static IssmPDouble wgt1[]={2.000000000000000};
     31        static IssmPDouble xi1[]={0.000000000000000};
    3232
    3333        /*p= 3, npoint= 2*/
    34         static double wgt2[]={1.000000000000000, 1.000000000000000};
    35         static double xi2[]={-0.577350269189626, 0.577350269189626};
     34        static IssmPDouble wgt2[]={1.000000000000000, 1.000000000000000};
     35        static IssmPDouble xi2[]={-0.577350269189626, 0.577350269189626};
    3636
    3737        /*p= 5, npoint= 3*/
    38         static double wgt3[]={0.555555555555556, 0.888888888888889, 0.555555555555556};
    39         static double xi3[]={-0.774596669241483, 0.000000000000000, 0.774596669241483};
     38        static IssmPDouble wgt3[]={0.555555555555556, 0.888888888888889, 0.555555555555556};
     39        static IssmPDouble xi3[]={-0.774596669241483, 0.000000000000000, 0.774596669241483};
    4040
    4141        /*p= 7, npoint= 4*/
    42         static double wgt4[]={0.347854845137454, 0.652145154862546, 0.652145154862546, 0.347854845137454};
    43         static double xi4[]={-0.861136311594053,-0.339981043584856, 0.339981043584856, 0.861136311594053};
    44 
    45         static double* wgtp[MAX_LINE_GAUS_PTS]={wgt1 ,wgt2 ,wgt3 ,wgt4 };
    46         static double* xip [MAX_LINE_GAUS_PTS]={xi1  ,xi2  ,xi3  ,xi4  };
    47 
    48         static int np[MAX_LINE_GAUS_PTS]={sizeof(wgt1 )/sizeof(double),
    49                 sizeof(wgt2 )/sizeof(double),
    50                 sizeof(wgt3 )/sizeof(double),
    51                 sizeof(wgt4 )/sizeof(double)};
    52 
    53         //      _printf_(true,"Gauss-Legendre recurrence coefficients ngaus=%d\n",ngaus);
    54         *pxgaus = (double *) xmalloc(ngaus*sizeof(double));
    55         *pxwgt  = (double *) xmalloc(ngaus*sizeof(double));
     42        static IssmPDouble wgt4[]={0.347854845137454, 0.652145154862546, 0.652145154862546, 0.347854845137454};
     43        static IssmPDouble xi4[]={-0.861136311594053,-0.339981043584856, 0.339981043584856, 0.861136311594053};
     44
     45        static IssmPDouble* wgtp[MAX_LINE_GAUS_PTS]={wgt1 ,wgt2 ,wgt3 ,wgt4 };
     46        static IssmPDouble* xip [MAX_LINE_GAUS_PTS]={xi1  ,xi2  ,xi3  ,xi4  };
     47
     48        static int np[MAX_LINE_GAUS_PTS]={sizeof(wgt1 )/sizeof(IssmPDouble),
     49                sizeof(wgt2 )/sizeof(IssmPDouble),
     50                sizeof(wgt3 )/sizeof(IssmPDouble),
     51                sizeof(wgt4 )/sizeof(IssmPDouble)};
     52
     53        //      _pprintLine_("Gauss-Legendre recurrence coefficients ngaus=" << ngaus);
     54        *pxgaus =xNew<IssmPDouble>(ngaus);
     55        *pxwgt  =xNew<IssmPDouble>(ngaus);
    5656
    5757        /*  check to see if Gauss points need to be calculated  */
     
    7070
    7171                /*  calculate the Gauss points using recurrence relations  */
    72                 alpha=(double *) xmalloc(ngaus*sizeof(double));
    73                 beta =(double *) xmalloc(ngaus*sizeof(double));
     72                alpha=xNew<IssmPDouble>(ngaus);
     73                beta =xNew<IssmPDouble>(ngaus);
    7474
    7575                /*  calculate the Legendre recurrence coefficients  */
     
    8484                /*  calculate the Gauss points  */
    8585                GaussRecur(*pxgaus, *pxwgt, ngaus, alpha, beta );
    86                 xfree((void **)&beta );
    87                 xfree((void **)&alpha);
     86                xDelete<IssmPDouble>(beta);
     87                xDelete<IssmPDouble>(alpha);
    8888        }
    89 }/*}}}1*/
    90 /*FUNCTION GaussLegendreTria{{{1*/
    91 void GaussLegendreTria( int* pngaus, double** pl1, double** pl2, double** pl3, double** pwgt, int iord ) {
     89}/*}}}*/
     90/*FUNCTION GaussLegendreTria{{{*/
     91void GaussLegendreTria( int* pngaus, IssmPDouble** pl1, IssmPDouble** pl2, IssmPDouble** pl3, IssmPDouble** pwgt, int iord ) {
    9292        /*Gauss quadrature points for the triangle.
    9393
     
    9898        /*Intermediaries*/
    9999        int i,j,ipt,nigaus;
    100         double xi,eta;
    101         double *xgaus=NULL,*xwgt=NULL,*egaus,*ewgt;
     100        IssmPDouble xi,eta;
     101        IssmPDouble *xgaus=NULL,*xwgt=NULL,*egaus,*ewgt;
    102102
    103103        /*Hardcoded Gauss points declaration*/
    104         /*p= 1, npoint= 1{{{2*/
    105         static double wgt1[]={
     104        /*p= 1, npoint= 1{{{*/
     105        static IssmPDouble wgt1[]={
    106106                1.732050807568877};
    107         static double l11[]={
     107        static IssmPDouble l11[]={
    108108                0.333333333333333};
    109         static double l21[]={
     109        static IssmPDouble l21[]={
    110110                0.333333333333333};
    111         static double l31[]={
     111        static IssmPDouble l31[]={
    112112                0.333333333333333};
    113         /*}}}2*/
    114         /*p= 2, npoint= 3  {{{2*/
    115         static double wgt2[]={
     113        /*}}}*/
     114        /*p= 2, npoint= 3  {{{*/
     115        static IssmPDouble wgt2[]={
    116116                0.577350269189625, 0.577350269189625, 0.577350269189625};
    117         static double l12[]={
     117        static IssmPDouble l12[]={
    118118                0.666666666666667, 0.166666666666667, 0.166666666666667};
    119         static double l22[]={
     119        static IssmPDouble l22[]={
    120120                0.166666666666667, 0.666666666666667, 0.166666666666667};
    121         static double l32[]={
     121        static IssmPDouble l32[]={
    122122                0.166666666666667, 0.166666666666667, 0.666666666666667};
    123         /*}}}2*/
    124         /*p= 3, npoint= 4  {{{2*/
    125         static double wgt3[]={
     123        /*}}}*/
     124        /*p= 3, npoint= 4  {{{*/
     125        static IssmPDouble wgt3[]={
    126126                -0.974278579257493, 0.902109795608790, 0.902109795608790,
    127127                0.902109795608790};
    128         static double l13[]={
     128        static IssmPDouble l13[]={
    129129                0.333333333333333, 0.600000000000000, 0.200000000000000,
    130130                0.200000000000000};
    131         static double l23[]={
     131        static IssmPDouble l23[]={
    132132                0.333333333333333, 0.200000000000000, 0.600000000000000,
    133133                0.200000000000000};
    134         static double l33[]={
     134        static IssmPDouble l33[]={
    135135                0.333333333333333, 0.200000000000000, 0.200000000000000,
    136136                0.600000000000000};
    137         /*}}}2*/
    138         /*p= 4, npoint= 6  {{{2*/
    139         static double wgt4[]={
     137        /*}}}*/
     138        /*p= 4, npoint= 6  {{{*/
     139        static IssmPDouble wgt4[]={
    140140                0.386908262797819, 0.386908262797819, 0.386908262797819,
    141141                0.190442006391807, 0.190442006391807, 0.190442006391807};
    142         static double l14[]={
     142        static IssmPDouble l14[]={
    143143                0.108103018168070, 0.445948490915965, 0.445948490915965,
    144144                0.816847572980459, 0.091576213509771, 0.091576213509771};
    145         static double l24[]={
     145        static IssmPDouble l24[]={
    146146                0.445948490915965, 0.108103018168070, 0.445948490915965,
    147147                0.091576213509771, 0.816847572980459, 0.091576213509771};
    148         static double l34[]={
     148        static IssmPDouble l34[]={
    149149                0.445948490915965, 0.445948490915965, 0.108103018168070,
    150150                0.091576213509771, 0.091576213509771, 0.816847572980459};
    151         /*}}}2*/
    152         /*p= 5, npoint= 7  {{{2*/
    153         static double wgt5[]={
     151        /*}}}*/
     152        /*p= 5, npoint= 7  {{{*/
     153        static IssmPDouble wgt5[]={
    154154                0.389711431702997, 0.229313399254729, 0.229313399254729,
    155155                0.229313399254729, 0.218133059367230, 0.218133059367230,
    156156                0.218133059367230};
    157         static double l15[]={
     157        static IssmPDouble l15[]={
    158158                0.333333333333333, 0.059715871789770, 0.470142064105115,
    159159                0.470142064105115, 0.797426985353087, 0.101286507323456,
    160160                0.101286507323456};
    161         static double l25[]={
     161        static IssmPDouble l25[]={
    162162                0.333333333333333, 0.470142064105115, 0.059715871789770,
    163163                0.470142064105115, 0.101286507323456, 0.797426985353087,
    164164                0.101286507323456};
    165         static double l35[]={
     165        static IssmPDouble l35[]={
    166166                0.333333333333333, 0.470142064105115, 0.470142064105115,
    167167                0.059715871789770, 0.101286507323456, 0.101286507323456,
    168168                0.797426985353087};
    169         /*}}}2*/
    170         /*p= 6, npoint=12  {{{2*/
    171         static double wgt6[]={
     169        /*}}}*/
     170        /*p= 6, npoint=12  {{{*/
     171        static IssmPDouble wgt6[]={
    172172                0.202279763184836, 0.202279763184836, 0.202279763184836,
    173173                0.088065961139281, 0.088065961139281, 0.088065961139281,
    174174                0.143502272432755, 0.143502272432755, 0.143502272432755,
    175175                0.143502272432755, 0.143502272432755, 0.143502272432755};
    176         static double l16[]={
     176        static IssmPDouble l16[]={
    177177                0.501426509658179, 0.249286745170910, 0.249286745170910,
    178178                0.873821971016996, 0.063089014491502, 0.063089014491502,
    179179                0.053145049844817, 0.053145049844817, 0.310352451033784,
    180180                0.636502499121399, 0.310352451033784, 0.636502499121399};
    181         static double l26[]={
     181        static IssmPDouble l26[]={
    182182                0.249286745170910, 0.501426509658179, 0.249286745170910,
    183183                0.063089014491502, 0.873821971016996, 0.063089014491502,
    184184                0.310352451033784, 0.636502499121399, 0.053145049844817,
    185185                0.053145049844817, 0.636502499121399, 0.310352451033784};
    186         static double l36[]={
     186        static IssmPDouble l36[]={
    187187                0.249286745170910, 0.249286745170910, 0.501426509658179,
    188188                0.063089014491502, 0.063089014491502, 0.873821971016996,
    189189                0.636502499121399, 0.310352451033784, 0.636502499121399,
    190190                0.310352451033784, 0.053145049844817, 0.053145049844817};
    191         /*}}}2*/
    192         /*p= 7, npoint=13  {{{2*/
    193         static double wgt7[]={
     191        /*}}}*/
     192        /*p= 7, npoint=13  {{{*/
     193        static IssmPDouble wgt7[]={
    194194                -0.259062916308362, 0.304174548458604, 0.304174548458604,
    195195                0.304174548458604, 0.092400122517855, 0.092400122517855,
     
    197197                0.133564951824643, 0.133564951824643, 0.133564951824643,
    198198                0.133564951824643};
    199         static double l17[]={
     199        static IssmPDouble l17[]={
    200200                0.333333333333333, 0.479308067841920, 0.260345966079040,
    201201                0.260345966079040, 0.869739794195568, 0.065130102902216,
     
    203203                0.312865496004874, 0.638444188569810, 0.312865496004874,
    204204                0.638444188569810};
    205         static double l27[]={
     205        static IssmPDouble l27[]={
    206206                0.333333333333333, 0.260345966079040, 0.479308067841920,
    207207                0.260345966079040, 0.065130102902216, 0.869739794195568,
     
    209209                0.048690315425316, 0.048690315425316, 0.638444188569810,
    210210                0.312865496004874};
    211         static double l37[]={
     211        static IssmPDouble l37[]={
    212212                0.333333333333333, 0.260345966079040, 0.260345966079040,
    213213                0.479308067841920, 0.065130102902216, 0.065130102902216,
     
    215215                0.638444188569810, 0.312865496004874, 0.048690315425316,
    216216                0.048690315425316};
    217         /*}}}2*/
    218         /*p= 8, npoint=16  {{{2*/
    219         static double wgt8[]={
     217        /*}}}*/
     218        /*p= 8, npoint=16  {{{*/
     219        static IssmPDouble wgt8[]={
    220220                0.249961964823104, 0.164703541925695, 0.164703541925695,
    221221                0.164703541925695, 0.178777729989794, 0.178777729989794,
     
    224224                0.047164287656184, 0.047164287656184, 0.047164287656184,
    225225                0.047164287656184};
    226         static double l18[]={
     226        static IssmPDouble l18[]={
    227227                0.333333333333333, 0.081414823414554, 0.459292588292723,
    228228                0.459292588292723, 0.658861384496480, 0.170569307751760,
     
    231231                0.263112829634638, 0.728492392955404, 0.263112829634638,
    232232                0.728492392955404};
    233         static double l28[]={
     233        static IssmPDouble l28[]={
    234234                0.333333333333333, 0.459292588292723, 0.081414823414554,
    235235                0.459292588292723, 0.170569307751760, 0.658861384496480,
     
    238238                0.008394777409958, 0.008394777409958, 0.728492392955404,
    239239                0.263112829634638};
    240         static double l38[]={
     240        static IssmPDouble l38[]={
    241241                0.333333333333333, 0.459292588292723, 0.459292588292723,
    242242                0.081414823414554, 0.170569307751760, 0.170569307751760,
     
    245245                0.728492392955404, 0.263112829634638, 0.008394777409958,
    246246                0.008394777409958};
    247         /*}}}2*/
    248         /*p= 9, npoint=19  {{{2*/
    249         static double wgt9[]={
     247        /*}}}*/
     248        /*p= 9, npoint=19  {{{*/
     249        static IssmPDouble wgt9[]={
    250250                0.168244134395468, 0.054273292833345, 0.054273292833345,
    251251                0.054273292833345, 0.134801255248419, 0.134801255248419,
     
    255255                0.074969289332873, 0.074969289332873, 0.074969289332873,
    256256                0.074969289332873};
    257         static double l19[]={
     257        static IssmPDouble l19[]={
    258258                0.333333333333333, 0.020634961602525, 0.489682519198738,
    259259                0.489682519198738, 0.125820817014127, 0.437089591492937,
     
    263263                0.221962989160766, 0.741198598784498, 0.221962989160766,
    264264                0.741198598784498};
    265         static double l29[]={
     265        static IssmPDouble l29[]={
    266266                0.333333333333333, 0.489682519198738, 0.020634961602525,
    267267                0.489682519198738, 0.437089591492937, 0.125820817014127,
     
    271271                0.036838412054736, 0.036838412054736, 0.741198598784498,
    272272                0.221962989160766};
    273         static double l39[]={
     273        static IssmPDouble l39[]={
    274274                0.333333333333333, 0.489682519198738, 0.489682519198738,
    275275                0.020634961602525, 0.437089591492937, 0.437089591492937,
     
    279279                0.741198598784498, 0.221962989160766, 0.036838412054736,
    280280                0.036838412054736};
    281         /*}}}2*/
    282         /*p=10, npoint=25  {{{2*/
    283         static double wgt10[]={
     281        /*}}}*/
     282        /*p=10, npoint=25  {{{*/
     283        static IssmPDouble wgt10[]={
    284284                0.157301373584232, 0.063611224790829, 0.063611224790829,
    285285                0.063611224790829, 0.078498377595183, 0.078498377595183,
     
    291291                0.016318805873179, 0.016318805873179, 0.016318805873179,
    292292                0.016318805873179};
    293         static double l110[]={
     293        static IssmPDouble l110[]={
    294294                0.333333333333333, 0.028844733232685, 0.485577633383657,
    295295                0.485577633383657, 0.781036849029926, 0.109481575485037,
     
    301301                0.066803251012200, 0.923655933587500, 0.066803251012200,
    302302                0.923655933587500};
    303         static double l210[]={
     303        static IssmPDouble l210[]={
    304304                0.333333333333333, 0.485577633383657, 0.028844733232685,
    305305                0.485577633383657, 0.109481575485037, 0.781036849029926,
     
    311311                0.009540815400299, 0.009540815400299, 0.923655933587500,
    312312                0.066803251012200};
    313         static double l310[]={
     313        static IssmPDouble l310[]={
    314314                0.333333333333333, 0.485577633383657, 0.485577633383657,
    315315                0.028844733232685, 0.109481575485037, 0.109481575485037,
     
    321321                0.923655933587500, 0.066803251012200, 0.009540815400299,
    322322                0.009540815400299};
    323         /*}}}2*/
    324         /*p=11, npoint=27  {{{2*/
    325         static double wgt11[]={
     323        /*}}}*/
     324        /*p=11, npoint=27  {{{*/
     325        static IssmPDouble wgt11[]={
    326326                0.001605622060698, 0.001605622060698, 0.001605622060698,
    327327                0.133626914252765, 0.133626914252765, 0.133626914252765,
     
    333333                0.035866718600836, 0.035866718600836, 0.035866718600836,
    334334                0.035866718600836, 0.035866718600836, 0.035866718600836};
    335         static double l111[]={
     335        static IssmPDouble l111[]={
    336336                -0.069222096541517, 0.534611048270758, 0.534611048270758,
    337337                0.202061394068290, 0.398969302965855, 0.398969302965855,
     
    343343                0.021022016536166, 0.021022016536166, 0.171488980304042,
    344344                0.807489003159792, 0.171488980304042, 0.807489003159792};
    345         static double l211[]={
     345        static IssmPDouble l211[]={
    346346                0.534611048270758,-0.069222096541517, 0.534611048270758,
    347347                0.398969302965855, 0.202061394068290, 0.398969302965855,
     
    353353                0.171488980304042, 0.807489003159792, 0.021022016536166,
    354354                0.021022016536166, 0.807489003159792, 0.171488980304042};
    355         static double l311[]={
     355        static IssmPDouble l311[]={
    356356                0.534611048270758, 0.534611048270758,-0.069222096541517,
    357357                0.398969302965855, 0.398969302965855, 0.202061394068290,
     
    363363                0.807489003159792, 0.171488980304042, 0.807489003159792,
    364364                0.171488980304042, 0.021022016536166, 0.021022016536166};
    365         /*}}}2*/
    366         /*p=12, npoint=33  {{{2*/
    367         static double wgt12[]={
     365        /*}}}*/
     366        /*p=12, npoint=33  {{{*/
     367        static IssmPDouble wgt12[]={
    368368                0.044567514407799, 0.044567514407799, 0.044567514407799,
    369369                0.075677707051848, 0.075677707051848, 0.075677707051848,
     
    377377                0.029992592075802, 0.029992592075802, 0.029992592075802,
    378378                0.029992592075802, 0.029992592075802, 0.029992592075802};
    379         static double l112[]={
     379        static IssmPDouble l112[]={
    380380                0.023565220452390, 0.488217389773805, 0.488217389773805,
    381381                0.120551215411079, 0.439724392294460, 0.439724392294460,
     
    389389                0.025734050548330, 0.025734050548330, 0.116251915907597,
    390390                0.858014033544073, 0.116251915907597, 0.858014033544073};
    391         static double l212[]={
     391        static IssmPDouble l212[]={
    392392                0.488217389773805, 0.023565220452390, 0.488217389773805,
    393393                0.439724392294460, 0.120551215411079, 0.439724392294460,
     
    401401                0.116251915907597, 0.858014033544073, 0.025734050548330,
    402402                0.025734050548330, 0.858014033544073, 0.116251915907597};
    403         static double l312[]={
     403        static IssmPDouble l312[]={
    404404                0.488217389773805, 0.488217389773805, 0.023565220452390,
    405405                0.439724392294460, 0.439724392294460, 0.120551215411079,
     
    413413                0.858014033544073, 0.116251915907597, 0.858014033544073,
    414414                0.116251915907597, 0.025734050548330, 0.025734050548330};
    415         /*}}}2*/
    416         /*  p=13, npoint=37  {{{2*/
    417         static double wgt13[]={
     415        /*}}}*/
     416        /*  p=13, npoint=37  {{{*/
     417        static IssmPDouble wgt13[]={
    418418                0.090968907790622, 0.019537784619314, 0.019537784619314,
    419419                0.019537784619314, 0.054427130356344, 0.054427130356344,
     
    429429                0.026884523429480, 0.026884523429480, 0.026884523429480,
    430430                0.026884523429480};
    431         static double l113[]={
     431        static IssmPDouble l113[]={
    432432                0.333333333333333, 0.009903630120591, 0.495048184939705,
    433433                0.495048184939705, 0.062566729780852, 0.468716635109574,
     
    443443                0.126357385491669, 0.851409537834241, 0.126357385491669,
    444444                0.851409537834241};
    445         static double l213[]={
     445        static IssmPDouble l213[]={
    446446                0.333333333333333, 0.495048184939705, 0.009903630120591,
    447447                0.495048184939705, 0.468716635109574, 0.062566729780852,
     
    457457                0.022233076674090, 0.022233076674090, 0.851409537834241,
    458458                0.126357385491669};
    459         static double l313[]={
     459        static IssmPDouble l313[]={
    460460                0.333333333333333, 0.495048184939705, 0.495048184939705,
    461461                0.009903630120591, 0.468716635109574, 0.468716635109574,
     
    471471                0.851409537834241, 0.126357385491669, 0.022233076674090,
    472472                0.022233076674090};
    473         /*}}}2*/
    474         /*p=14, npoint=42{{{2*/
    475         static double wgt14[]={
     473        /*}}}*/
     474        /*p=14, npoint=42{{{*/
     475        static IssmPDouble wgt14[]={
    476476                0.037903474783419, 0.037903474783419, 0.037903474783419,
    477477                0.056791094234956, 0.056791094234956, 0.056791094234956,
     
    488488                0.008677970905831, 0.008677970905831, 0.008677970905831,
    489489                0.008677970905831, 0.008677970905831, 0.008677970905831};
    490         static double l114[]={
     490        static IssmPDouble l114[]={
    491491                0.022072179275643, 0.488963910362179, 0.488963910362179,
    492492                0.164710561319092, 0.417644719340454, 0.417644719340454,
     
    503503                0.001268330932872, 0.001268330932872, 0.118974497696957,
    504504                0.879757171370171, 0.118974497696957, 0.879757171370171};
    505         static double l214[]={
     505        static IssmPDouble l214[]={
    506506                0.488963910362179, 0.022072179275643, 0.488963910362179,
    507507                0.417644719340454, 0.164710561319092, 0.417644719340454,
     
    518518                0.118974497696957, 0.879757171370171, 0.001268330932872,
    519519                0.001268330932872, 0.879757171370171, 0.118974497696957};
    520         static double l314[]={
     520        static IssmPDouble l314[]={
    521521                0.488963910362179, 0.488963910362179, 0.022072179275643,
    522522                0.417644719340454, 0.417644719340454, 0.164710561319092,
     
    533533                0.879757171370171, 0.118974497696957, 0.879757171370171,
    534534                0.118974497696957, 0.001268330932872, 0.001268330932872};
    535         /*}}}2*/
    536         /*p=15, npoint=48{{{2*/
    537         static double wgt15[]={
     535        /*}}}*/
     536        /*p=15, npoint=48{{{*/
     537        static IssmPDouble wgt15[]={
    538538                0.003320126005206, 0.003320126005206, 0.003320126005206,
    539539                0.076641563419124, 0.076641563419124, 0.076641563419124,
     
    552552                0.013291658531346, 0.013291658531346, 0.013291658531346,
    553553                0.013291658531346, 0.013291658531346, 0.013291658531346};
    554         static double l115[]={
     554        static IssmPDouble l115[]={
    555555                -0.013945833716486, 0.506972916858243, 0.506972916858243,
    556556                0.137187291433955, 0.431406354283023, 0.431406354283023,
     
    569569                0.012459809331199, 0.012459809331199, 0.103575616576386,
    570570                0.883964574092416, 0.103575616576386, 0.883964574092416};
    571         static double l215[]={
     571        static IssmPDouble l215[]={
    572572                0.506972916858243,-0.013945833716486, 0.506972916858243,
    573573                0.431406354283023, 0.137187291433955, 0.431406354283023,
     
    586586                0.103575616576386, 0.883964574092416, 0.012459809331199,
    587587                0.012459809331199, 0.883964574092416, 0.103575616576386};
    588         static double l315[]={
     588        static IssmPDouble l315[]={
    589589                0.506972916858243, 0.506972916858243,-0.013945833716486,
    590590                0.431406354283023, 0.431406354283023, 0.137187291433955,
     
    603603                0.883964574092416, 0.103575616576386, 0.883964574092416,
    604604                0.103575616576386, 0.012459809331199, 0.012459809331199};
    605         /*}}}2*/
    606         /*p=16, npoint=52  {{{2*/
    607         static double wgt16[]={
     605        /*}}}*/
     606        /*p=16, npoint=52  {{{*/
     607        static IssmPDouble wgt16[]={
    608608                0.081191089584902, 0.011095307165226, 0.011095307165226,
    609609                0.011095307165226, 0.072244353151393, 0.072244353151393,
     
    624624                0.011864642509229, 0.011864642509229, 0.011864642509229,
    625625                0.011864642509229};
    626         static double l116[]={
     626        static IssmPDouble l116[]={
    627627                0.333333333333333, 0.005238916103123, 0.497380541948438,
    628628                0.497380541948438, 0.173061122901295, 0.413469438549352,
     
    643643                0.085283615682657, 0.900399064086661, 0.085283615682657,
    644644                0.900399064086661};
    645         static double l216[]={
     645        static IssmPDouble l216[]={
    646646                0.333333333333333, 0.497380541948438, 0.005238916103123,
    647647                0.497380541948438, 0.413469438549352, 0.173061122901295,
     
    662662                0.014317320230681, 0.014317320230681, 0.900399064086661,
    663663                0.085283615682657};
    664         static double l316[]={
     664        static IssmPDouble l316[]={
    665665                0.333333333333333, 0.497380541948438, 0.497380541948438,
    666666                0.005238916103123, 0.413469438549352, 0.413469438549352,
     
    681681                0.900399064086661, 0.085283615682657, 0.014317320230681,
    682682                0.014317320230681};
    683         /*}}}2*/
    684         /*p=17, npoint=61{{{2*/
    685         static double wgt17[]={
     683        /*}}}*/
     684        /*p=17, npoint=61{{{*/
     685        static IssmPDouble wgt17[]={
    686686                0.057914928034477, 0.008822054327014, 0.008822054327014,
    687687                0.008822054327014, 0.025410682752829, 0.025410682752829,
     
    705705                0.011545213295771, 0.011545213295771, 0.011545213295771,
    706706                0.011545213295771};
    707         static double l117[]={
     707        static IssmPDouble l117[]={
    708708                0.333333333333333, 0.005658918886452, 0.497170540556774,
    709709                0.497170540556774, 0.035647354750751, 0.482176322624625,
     
    727727                0.080711313679564, 0.904625504095608, 0.080711313679564,
    728728                0.904625504095608};
    729         static double l217[]={
     729        static IssmPDouble l217[]={
    730730                0.333333333333333, 0.497170540556774, 0.005658918886452,
    731731                0.497170540556774, 0.482176322624625, 0.035647354750751,
     
    749749                0.014663182224828, 0.014663182224828, 0.904625504095608,
    750750                0.080711313679564};
    751         static double l317[]={
     751        static IssmPDouble l317[]={
    752752                0.333333333333333, 0.497170540556774, 0.497170540556774,
    753753                0.005658918886452, 0.482176322624625, 0.482176322624625,
     
    771771                0.904625504095608, 0.080711313679564, 0.014663182224828,
    772772                0.014663182224828};
    773         /*}}}2*/
    774         /*  p=18, npoint=70  {{{2*/
    775 
    776         static double wgt18[]={
     773        /*}}}*/
     774        /*  p=18, npoint=70  {{{*/
     775
     776        static IssmPDouble wgt18[]={
    777777                0.053364381350150, 0.015713921277179, 0.015713921277179,
    778778                0.015713921277179, 0.032495554156279, 0.032495554156279,
     
    799799                0.000079999375178, 0.000079999375178, 0.000079999375178,
    800800                0.000079999375178};
    801         static double l118[]={
     801        static IssmPDouble l118[]={
    802802                0.333333333333333, 0.013310382738157, 0.493344808630921,
    803803                0.493344808630921, 0.061578811516086, 0.469210594241957,
     
    824824                0.020874755282586, 1.014347260005363, 0.020874755282586,
    825825                1.014347260005363};
    826         static double l218[]={
     826        static IssmPDouble l218[]={
    827827                0.333333333333333, 0.493344808630921, 0.013310382738157,
    828828                0.493344808630921, 0.469210594241957, 0.061578811516086,
     
    849849                -0.035222015287949,-0.035222015287949, 1.014347260005363,
    850850                0.020874755282586};
    851         static double l318[]={
     851        static IssmPDouble l318[]={
    852852                0.333333333333333, 0.493344808630921, 0.493344808630921,
    853853                0.013310382738157, 0.469210594241957, 0.469210594241957,
     
    874874                1.014347260005363, 0.020874755282586,-0.035222015287949,
    875875                -0.035222015287949};
    876         /*}}}2*/
    877         /*p=19, npoint=73  {{{2*/
    878 
    879         static double wgt19[]={
     876        /*}}}*/
     877        /*p=19, npoint=73  {{{*/
     878
     879        static IssmPDouble wgt19[]={
    880880                0.056995437856306, 0.017893352515055, 0.017893352515055,
    881881                0.017893352515055, 0.038775849701151, 0.038775849701151,
     
    903903                0.006581669842530, 0.006581669842530, 0.006581669842530,
    904904                0.006581669842530};
    905         static double l119[]={
     905        static IssmPDouble l119[]={
    906906                0.333333333333333, 0.020780025853987, 0.489609987073006,
    907907                0.489609987073006, 0.090926214604215, 0.454536892697893,
     
    929929                0.065494628082938, 0.924344252620784, 0.065494628082938,
    930930                0.924344252620784};
    931         static double l219[]={
     931        static IssmPDouble l219[]={
    932932                0.333333333333333, 0.489609987073006, 0.020780025853987,
    933933                0.489609987073006, 0.454536892697893, 0.090926214604215,
     
    955955                0.010161119296278, 0.010161119296278, 0.924344252620784,
    956956                0.065494628082938};
    957         static double l319[]={
     957        static IssmPDouble l319[]={
    958958                0.333333333333333, 0.489609987073006, 0.489609987073006,
    959959                0.020780025853987, 0.454536892697893, 0.454536892697893,
     
    981981                0.924344252620784, 0.065494628082938, 0.010161119296278,
    982982                0.010161119296278};
    983         /*}}}2*/
    984         /*p=20, npoint=79 {{{2*/
    985         static double wgt20[]={
     983        /*}}}*/
     984        /*p=20, npoint=79 {{{*/
     985        static IssmPDouble wgt20[]={
    986986                0.057256499746719, 0.001501721280705, 0.001501721280705,
    987987                0.001501721280705, 0.020195803723819, 0.020195803723819,
     
    10111011                0.006190192638113, 0.006190192638113, 0.006190192638113,
    10121012                0.006190192638113};
    1013         static double l120[]={
     1013        static IssmPDouble l120[]={
    10141014                0.333333333333333,-0.001900928704400, 0.500950464352200,
    10151015                0.500950464352200, 0.023574084130543, 0.488212957934729,
     
    10391039                0.059696109149007, 0.929756171556853, 0.059696109149007,
    10401040                0.929756171556853};
    1041         static double l220[]={
     1041        static IssmPDouble l220[]={
    10421042                0.333333333333333, 0.500950464352200,-0.001900928704400,
    10431043                0.500950464352200, 0.488212957934729, 0.023574084130543,
     
    10671067                0.010547719294141, 0.010547719294141, 0.929756171556853,
    10681068                0.059696109149007};
    1069         static double l320[]={
     1069        static IssmPDouble l320[]={
    10701070                0.333333333333333, 0.500950464352200, 0.500950464352200,
    10711071                -0.001900928704400, 0.488212957934729, 0.488212957934729,
     
    10951095                0.929756171556853, 0.059696109149007, 0.010547719294141,
    10961096                0.010547719294141};
    1097         /*}}}2*/
    1098 
    1099         static double* wgtp[MAX_TRIA_SYM_ORD]={
     1097        /*}}}*/
     1098
     1099        static IssmPDouble* wgtp[MAX_TRIA_SYM_ORD]={
    11001100                wgt1 ,wgt2 ,wgt3 ,wgt4 ,wgt5 ,
    11011101                wgt6 ,wgt7 ,wgt8 ,wgt9 ,wgt10,
    11021102                wgt11,wgt12,wgt13,wgt14,wgt15,
    11031103                wgt16,wgt17,wgt18,wgt19,wgt20};
    1104         static double* l1p [MAX_TRIA_SYM_ORD]={
     1104        static IssmPDouble* l1p [MAX_TRIA_SYM_ORD]={
    11051105                l11  ,l12  ,l13  ,l14  ,l15  ,
    11061106                l16  ,l17  ,l18  ,l19  ,l110 ,
    11071107                l111 ,l112 ,l113 ,l114 ,l115 ,
    11081108                l116 ,l117 ,l118 ,l119 ,l120 };
    1109         static double* l2p [MAX_TRIA_SYM_ORD]={
     1109        static IssmPDouble* l2p [MAX_TRIA_SYM_ORD]={
    11101110                l21  ,l22  ,l23  ,l24  ,l25  ,
    11111111                l26  ,l27  ,l28  ,l29  ,l210 ,
    11121112                l211 ,l212 ,l213 ,l214 ,l215 ,
    11131113                l216 ,l217 ,l218 ,l219 ,l220 };
    1114         static double* l3p [MAX_TRIA_SYM_ORD]={
     1114        static IssmPDouble* l3p [MAX_TRIA_SYM_ORD]={
    11151115                l31  ,l32  ,l33  ,l34  ,l35  ,
    11161116                l36  ,l37  ,l38  ,l39  ,l310 ,
     
    11181118                l316 ,l317 ,l318 ,l319 ,l320 };
    11191119
    1120         static int np[MAX_TRIA_SYM_ORD]={sizeof(wgt1 )/sizeof(double),
    1121                 sizeof(wgt2 )/sizeof(double),
    1122                 sizeof(wgt3 )/sizeof(double),
    1123                 sizeof(wgt4 )/sizeof(double),
    1124                 sizeof(wgt5 )/sizeof(double),
    1125                 sizeof(wgt6 )/sizeof(double),
    1126                 sizeof(wgt7 )/sizeof(double),
    1127                 sizeof(wgt8 )/sizeof(double),
    1128                 sizeof(wgt9 )/sizeof(double),
    1129                 sizeof(wgt10)/sizeof(double),
    1130                 sizeof(wgt11)/sizeof(double),
    1131                 sizeof(wgt12)/sizeof(double),
    1132                 sizeof(wgt13)/sizeof(double),
    1133                 sizeof(wgt14)/sizeof(double),
    1134                 sizeof(wgt15)/sizeof(double),
    1135                 sizeof(wgt16)/sizeof(double),
    1136                 sizeof(wgt17)/sizeof(double),
    1137                 sizeof(wgt18)/sizeof(double),
    1138                 sizeof(wgt19)/sizeof(double),
    1139                 sizeof(wgt20)/sizeof(double)};
    1140 
    1141         //      _printf_(true,"GaussLegendreTria: iord=%d\n",iord);
     1120        static int np[MAX_TRIA_SYM_ORD]={sizeof(wgt1 )/sizeof(IssmPDouble),
     1121                sizeof(wgt2 )/sizeof(IssmPDouble),
     1122                sizeof(wgt3 )/sizeof(IssmPDouble),
     1123                sizeof(wgt4 )/sizeof(IssmPDouble),
     1124                sizeof(wgt5 )/sizeof(IssmPDouble),
     1125                sizeof(wgt6 )/sizeof(IssmPDouble),
     1126                sizeof(wgt7 )/sizeof(IssmPDouble),
     1127                sizeof(wgt8 )/sizeof(IssmPDouble),
     1128                sizeof(wgt9 )/sizeof(IssmPDouble),
     1129                sizeof(wgt10)/sizeof(IssmPDouble),
     1130                sizeof(wgt11)/sizeof(IssmPDouble),
     1131                sizeof(wgt12)/sizeof(IssmPDouble),
     1132                sizeof(wgt13)/sizeof(IssmPDouble),
     1133                sizeof(wgt14)/sizeof(IssmPDouble),
     1134                sizeof(wgt15)/sizeof(IssmPDouble),
     1135                sizeof(wgt16)/sizeof(IssmPDouble),
     1136                sizeof(wgt17)/sizeof(IssmPDouble),
     1137                sizeof(wgt18)/sizeof(IssmPDouble),
     1138                sizeof(wgt19)/sizeof(IssmPDouble),
     1139                sizeof(wgt20)/sizeof(IssmPDouble)};
     1140
     1141        //      _pprintLine_("GaussLegendreTria: iord=" << iord);
    11421142
    11431143        /*  check to see if Gauss points need to be calculated  */
     
    11501150                *pngaus=np[iord-1];
    11511151
    1152                 *pl1  = (double *) xmalloc(*pngaus*sizeof(double));
    1153                 *pl2  = (double *) xmalloc(*pngaus*sizeof(double));
    1154                 *pl3  = (double *) xmalloc(*pngaus*sizeof(double));
    1155                 *pwgt = (double *) xmalloc(*pngaus*sizeof(double));
     1152                *pl1  =xNew<IssmPDouble>(*pngaus);
     1153                *pl2  =xNew<IssmPDouble>(*pngaus);
     1154                *pl3  =xNew<IssmPDouble>(*pngaus);
     1155                *pwgt =xNew<IssmPDouble>(*pngaus);
    11561156
    11571157                for (i=0; i<*pngaus; i++) {
     
    11681168                *pngaus=nigaus*nigaus;
    11691169
    1170                 *pl1  = (double *) xmalloc(*pngaus*sizeof(double));
    1171                 *pl2  = (double *) xmalloc(*pngaus*sizeof(double));
    1172                 *pl3  = (double *) xmalloc(*pngaus*sizeof(double));
    1173                 *pwgt = (double *) xmalloc(*pngaus*sizeof(double));
     1170                *pl1  =xNew<IssmPDouble>(*pngaus);
     1171                *pl2  =xNew<IssmPDouble>(*pngaus);
     1172                *pl3  =xNew<IssmPDouble>(*pngaus);
     1173                *pwgt =xNew<IssmPDouble>(*pngaus);
    11741174
    11751175                /*  get the gauss points in each direction  */
     
    11951195                        }
    11961196                }
    1197                 xfree((void **)&xwgt );
    1198                 xfree((void **)&xgaus);
     1197                xDelete<IssmPDouble>(xwgt );
     1198                xDelete<IssmPDouble>(xgaus);
    11991199        }
    12001200
    1201         //      _printf_(true,"GaussLegendreTria - ngaus=%d\n",*pngaus);
     1201        //      _pprintLine_("GaussLegendreTria - ngaus=" << *pngaus);
    12021202        //      for (i=0; i<*pngaus; i++)
    12031203        //              _printf_(true,"i=%d: l1gaus=%f,l2gaus=%f,l3gaus=%f,wgt=%f\n",
     
    12051205
    12061206        return;
    1207 }/*}}}1*/
    1208 /*FUNCTION GaussLegendreTetra{{{1*/
    1209 void GaussLegendreTetra( int* pngaus, double** pl1, double** pl2, double** pl3, double** pl4, double** pwgt, int iord ) {
     1207}/*}}}*/
     1208/*FUNCTION GaussLegendreTetra{{{*/
     1209void GaussLegendreTetra( int* pngaus, IssmPDouble** pl1, IssmPDouble** pl2, IssmPDouble** pl3, IssmPDouble** pl4, IssmPDouble** pwgt, int iord ) {
    12101210        /* Gauss quadrature points for the tetrahedron.
    12111211
     
    12201220        /*Intermediaries*/
    12211221        int i,j,k,ipt,nigaus;
    1222         double xi,eta,zeta;
    1223         double *xgaus=NULL,*xwgt=NULL,*egaus,*ewgt,*zgaus,*zwgt;
     1222        IssmPDouble xi,eta,zeta;
     1223        IssmPDouble *xgaus=NULL,*xwgt=NULL,*egaus,*ewgt,*zgaus,*zwgt;
    12241224
    12251225        /*Hardcoded Gauss points definition*/
    1226         /*p= 1, npoint= 1  {{{2*/
    1227         static double wgt1[]={
     1226        /*p= 1, npoint= 1  {{{*/
     1227        static IssmPDouble wgt1[]={
    12281228                1.000000000000000};
    1229         static double l11[]={
     1229        static IssmPDouble l11[]={
    12301230                0.250000000000000};
    1231         static double l21[]={
     1231        static IssmPDouble l21[]={
    12321232                0.250000000000000};
    1233         static double l31[]={
     1233        static IssmPDouble l31[]={
    12341234                0.250000000000000};
    1235         static double l41[]={
     1235        static IssmPDouble l41[]={
    12361236                0.250000000000000};
    1237         /*}}}2*/
    1238         /*p= 2, npoint= 4  {{{2*/
    1239 
    1240         static double wgt2[]={
     1237        /*}}}*/
     1238        /*p= 2, npoint= 4  {{{*/
     1239
     1240        static IssmPDouble wgt2[]={
    12411241                0.250000000000000, 0.250000000000000, 0.250000000000000,
    12421242                0.250000000000000};
    1243         static double l12[]={
     1243        static IssmPDouble l12[]={
    12441244                0.585410196624969, 0.138196601125011, 0.138196601125011,
    12451245                0.138196601125011};
    1246         static double l22[]={
     1246        static IssmPDouble l22[]={
    12471247                0.138196601125011, 0.585410196624969, 0.138196601125011,
    12481248                0.138196601125011};
    1249         static double l32[]={
     1249        static IssmPDouble l32[]={
    12501250                0.138196601125011, 0.138196601125011, 0.585410196624969,
    12511251                0.138196601125011};
    1252         static double l42[]={
     1252        static IssmPDouble l42[]={
    12531253                0.138196601125011, 0.138196601125011, 0.138196601125011,
    12541254                0.585410196624969};
    1255         /*}}}2*/
    1256         /*p= 3, npoint= 5  {{{2*/
    1257         static double wgt3[]={
     1255        /*}}}*/
     1256        /*p= 3, npoint= 5  {{{*/
     1257        static IssmPDouble wgt3[]={
    12581258                -0.800000000000000, 0.450000000000000, 0.450000000000000,
    12591259                0.450000000000000, 0.450000000000000};
    1260         static double l13[]={
     1260        static IssmPDouble l13[]={
    12611261                0.250000000000000, 0.500000000000000, 0.166666666666667,
    12621262                0.166666666666667, 0.166666666666667};
    1263         static double l23[]={
     1263        static IssmPDouble l23[]={
    12641264                0.250000000000000, 0.166666666666667, 0.500000000000000,
    12651265                0.166666666666667, 0.166666666666667};
    1266         static double l33[]={
     1266        static IssmPDouble l33[]={
    12671267                0.250000000000000, 0.166666666666667, 0.166666666666667,
    12681268                0.500000000000000, 0.166666666666667};
    1269         static double l43[]={
     1269        static IssmPDouble l43[]={
    12701270                0.250000000000000, 0.166666666666667, 0.166666666666667,
    12711271                0.166666666666667, 0.500000000000000};
    1272         /*}}}2*/
    1273         /*p= 4, npoint=11  {{{2*/
    1274 
    1275         static double wgt4[]={
     1272        /*}}}*/
     1273        /*p= 4, npoint=11  {{{*/
     1274
     1275        static IssmPDouble wgt4[]={
    12761276                -0.013155555555556, 0.007622222222222, 0.007622222222222,
    12771277                0.007622222222222, 0.007622222222222, 0.024888888888889,
    12781278                0.024888888888889, 0.024888888888889, 0.024888888888889,
    12791279                0.024888888888889, 0.024888888888889};
    1280         static double l14[]={
     1280        static IssmPDouble l14[]={
    12811281                0.250000000000000, 0.785714285714286, 0.071428571428571,
    12821282                0.071428571428571, 0.071428571428571, 0.399403576166799,
    12831283                0.399403576166799, 0.399403576166799, 0.100596423833201,
    12841284                0.100596423833201, 0.100596423833201};
    1285         static double l24[]={
     1285        static IssmPDouble l24[]={
    12861286                0.250000000000000, 0.071428571428571, 0.785714285714286,
    12871287                0.071428571428571, 0.071428571428571, 0.399403576166799,
    12881288                0.100596423833201, 0.100596423833201, 0.399403576166799,
    12891289                0.399403576166799, 0.100596423833201};
    1290         static double l34[]={
     1290        static IssmPDouble l34[]={
    12911291                0.250000000000000, 0.071428571428571, 0.071428571428571,
    12921292                0.785714285714286, 0.071428571428571, 0.100596423833201,
    12931293                0.399403576166799, 0.100596423833201, 0.399403576166799,
    12941294                0.100596423833201, 0.399403576166799};
    1295         static double l44[]={
     1295        static IssmPDouble l44[]={
    12961296                0.250000000000000, 0.071428571428571, 0.071428571428571,
    12971297                0.071428571428571, 0.785714285714286, 0.100596423833201,
    12981298                0.100596423833201, 0.399403576166799, 0.100596423833201,
    12991299                0.399403576166799, 0.399403576166799};
    1300         /*}}}2*/
    1301         /*p= 5, npoint=15  {{{2*/
    1302 
    1303         static double wgt5[]={
     1300        /*}}}*/
     1301        /*p= 5, npoint=15  {{{*/
     1302
     1303        static IssmPDouble wgt5[]={
    13041304                0.030283678097089, 0.006026785714286, 0.006026785714286,
    13051305                0.006026785714286, 0.006026785714286, 0.011645249086029,
     
    13071307                0.010949141561386, 0.010949141561386, 0.010949141561386,
    13081308                0.010949141561386, 0.010949141561386, 0.010949141561386};
    1309         static double l15[]={
     1309        static IssmPDouble l15[]={
    13101310                0.250000000000000, 0.000000000000000, 0.333333333333333,
    13111311                0.333333333333333, 0.333333333333333, 0.727272727272727,
     
    13131313                0.066550153573664, 0.066550153573664, 0.066550153573664,
    13141314                0.433449846426336, 0.433449846426336, 0.433449846426336};
    1315         static double l25[]={
     1315        static IssmPDouble l25[]={
    13161316                0.250000000000000, 0.333333333333333, 0.000000000000000,
    13171317                0.333333333333333, 0.333333333333333, 0.090909090909091,
     
    13191319                0.066550153573664, 0.433449846426336, 0.433449846426336,
    13201320                0.066550153573664, 0.066550153573664, 0.433449846426336};
    1321         static double l35[]={
     1321        static IssmPDouble l35[]={
    13221322                0.250000000000000, 0.333333333333333, 0.333333333333333,
    13231323                0.000000000000000, 0.333333333333333, 0.090909090909091,
     
    13251325                0.433449846426336, 0.066550153573664, 0.433449846426336,
    13261326                0.066550153573664, 0.433449846426336, 0.066550153573664};
    1327         static double l45[]={
     1327        static IssmPDouble l45[]={
    13281328                0.250000000000000, 0.333333333333333, 0.333333333333333,
    13291329                0.333333333333333, 0.000000000000000, 0.090909090909091,
     
    13311331                0.433449846426336, 0.433449846426336, 0.066550153573664,
    13321332                0.433449846426336, 0.066550153573664, 0.066550153573664};
    1333         /*}}}2*/
    1334         /*p= 6, npoint=24  {{{2*/
    1335 
    1336         static double wgt6[]={
     1333        /*}}}*/
     1334        /*p= 6, npoint=24  {{{*/
     1335
     1336        static IssmPDouble wgt6[]={
    13371337                0.006653791709695, 0.006653791709695, 0.006653791709695,
    13381338                0.006653791709695, 0.001679535175887, 0.001679535175887,
     
    13431343                0.008035714285714, 0.008035714285714, 0.008035714285714,
    13441344                0.008035714285714, 0.008035714285714, 0.008035714285714};
    1345         static double l16[]={
     1345        static IssmPDouble l16[]={
    13461346                0.356191386222545, 0.214602871259152, 0.214602871259152,
    13471347                0.214602871259152, 0.877978124396166, 0.040673958534611,
     
    13531353                0.269672331458316, 0.603005664791649, 0.269672331458316,
    13541354                0.603005664791649, 0.269672331458316, 0.603005664791649};
    1355         static double l26[]={
     1355        static IssmPDouble l26[]={
    13561356                0.214602871259152, 0.356191386222545, 0.214602871259152,
    13571357                0.214602871259152, 0.040673958534611, 0.877978124396166,
     
    13631363                0.063661001875018, 0.063661001875018, 0.063661001875018,
    13641364                0.063661001875018, 0.603005664791649, 0.269672331458316};
    1365         static double l36[]={
     1365        static IssmPDouble l36[]={
    13661366                0.214602871259152, 0.214602871259152, 0.356191386222545,
    13671367                0.214602871259152, 0.040673958534611, 0.040673958534611,
     
    13731373                0.063661001875018, 0.063661001875018, 0.603005664791649,
    13741374                0.269672331458316, 0.063661001875018, 0.063661001875018};
    1375         static double l46[]={
     1375        static IssmPDouble l46[]={
    13761376                0.214602871259152, 0.214602871259152, 0.214602871259152,
    13771377                0.356191386222545, 0.040673958534611, 0.040673958534611,
     
    13831383                0.603005664791649, 0.269672331458316, 0.063661001875018,
    13841384                0.063661001875018, 0.063661001875018, 0.063661001875018};
    1385         /*}}}2*/
    1386 
    1387         static double* wgtp[MAX_TETRA_SYM_ORD]={wgt1,wgt2,wgt3,wgt4,wgt5,wgt6};
    1388         static double* l1p [MAX_TETRA_SYM_ORD]={l11 ,l12 ,l13 ,l14 ,l15 ,l16 };
    1389         static double* l2p [MAX_TETRA_SYM_ORD]={l21 ,l22 ,l32 ,l24 ,l25 ,l26 };
    1390         static double* l3p [MAX_TETRA_SYM_ORD]={l31 ,l32 ,l33 ,l34 ,l35 ,l36 };
    1391         static double* l4p [MAX_TETRA_SYM_ORD]={l41 ,l42 ,l43 ,l44 ,l45 ,l46 };
    1392 
    1393         static int np[MAX_TETRA_SYM_ORD]={sizeof(wgt1 )/sizeof(double),
    1394                 sizeof(wgt2 )/sizeof(double),
    1395                 sizeof(wgt3 )/sizeof(double),
    1396                 sizeof(wgt4 )/sizeof(double),
    1397                 sizeof(wgt5 )/sizeof(double),
    1398                 sizeof(wgt6 )/sizeof(double)};
    1399 
    1400         //      _printf_(true,"GaussLegendreTetra: iord=%d\n",iord);
     1385        /*}}}*/
     1386
     1387        static IssmPDouble* wgtp[MAX_TETRA_SYM_ORD]={wgt1,wgt2,wgt3,wgt4,wgt5,wgt6};
     1388        static IssmPDouble* l1p [MAX_TETRA_SYM_ORD]={l11 ,l12 ,l13 ,l14 ,l15 ,l16 };
     1389        static IssmPDouble* l2p [MAX_TETRA_SYM_ORD]={l21 ,l22 ,l32 ,l24 ,l25 ,l26 };
     1390        static IssmPDouble* l3p [MAX_TETRA_SYM_ORD]={l31 ,l32 ,l33 ,l34 ,l35 ,l36 };
     1391        static IssmPDouble* l4p [MAX_TETRA_SYM_ORD]={l41 ,l42 ,l43 ,l44 ,l45 ,l46 };
     1392
     1393        static int np[MAX_TETRA_SYM_ORD]={sizeof(wgt1 )/sizeof(IssmPDouble),
     1394                sizeof(wgt2 )/sizeof(IssmPDouble),
     1395                sizeof(wgt3 )/sizeof(IssmPDouble),
     1396                sizeof(wgt4 )/sizeof(IssmPDouble),
     1397                sizeof(wgt5 )/sizeof(IssmPDouble),
     1398                sizeof(wgt6 )/sizeof(IssmPDouble)};
     1399
     1400        //      _pprintLine_("GaussLegendreTetra: iord=" << iord);
    14011401
    14021402        /*  check to see if Gauss points need to be calculated  */
     
    14101410                *pngaus=np[iord-1];
    14111411
    1412                 *pl1  = (double *) xmalloc(*pngaus*sizeof(double));
    1413                 *pl2  = (double *) xmalloc(*pngaus*sizeof(double));
    1414                 *pl3  = (double *) xmalloc(*pngaus*sizeof(double));
    1415                 *pl4  = (double *) xmalloc(*pngaus*sizeof(double));
    1416                 *pwgt = (double *) xmalloc(*pngaus*sizeof(double));
     1412                *pl1  =xNew<IssmPDouble>(*pngaus);
     1413                *pl2  =xNew<IssmPDouble>(*pngaus);
     1414                *pl3  =xNew<IssmPDouble>(*pngaus);
     1415                *pl4  =xNew<IssmPDouble>(*pngaus);
     1416                *pwgt =xNew<IssmPDouble>(*pngaus);
    14171417
    14181418                for (i=0; i<*pngaus; i++) {
     
    14301430                *pngaus=nigaus*nigaus*nigaus;
    14311431
    1432                 *pl1  = (double *) xmalloc(*pngaus*sizeof(double));
    1433                 *pl2  = (double *) xmalloc(*pngaus*sizeof(double));
    1434                 *pl3  = (double *) xmalloc(*pngaus*sizeof(double));
    1435                 *pl4  = (double *) xmalloc(*pngaus*sizeof(double));
    1436                 *pwgt = (double *) xmalloc(*pngaus*sizeof(double));
     1432                *pl1  =xNew<IssmPDouble>(*pngaus);
     1433                *pl2  =xNew<IssmPDouble>(*pngaus);
     1434                *pl3  =xNew<IssmPDouble>(*pngaus);
     1435                *pl4  =xNew<IssmPDouble>(*pngaus);
     1436                *pwgt =xNew<IssmPDouble>(*pngaus);
    14371437
    14381438                /*  get the gauss points in each direction  */
     
    14671467                        }
    14681468                }
    1469                 xfree((void **)&xwgt );
    1470                 xfree((void **)&xgaus);
     1469                xDelete<IssmPDouble>(xwgt );
     1470                xDelete<IssmPDouble>(xgaus);
    14711471        }
    1472 }/*}}}1*/
    1473 /*FUNCTION GaussLobatto{{{1*/
    1474 void GaussLobatto( double** pxgaus, double** pxwgt, int ngaus ) {
     1472}/*}}}*/
     1473/*FUNCTION GaussLobatto{{{*/
     1474void GaussLobatto( IssmPDouble** pxgaus, IssmPDouble** pxwgt, int ngaus ) {
    14751475        /*Gauss-Lobatto quadrature points.
    14761476
     
    14881488
    14891489        int i;
    1490         double *alpha,*beta;
    1491         double left=-1.,right= 1.;
    1492         double p0l=0.,p0r=0.,p1l=1.,p1r=1.,pm1l,pm1r,det;
     1490        IssmPDouble *alpha,*beta;
     1491        IssmPDouble left=-1.,right= 1.;
     1492        IssmPDouble p0l=0.,p0r=0.,p1l=1.,p1r=1.,pm1l,pm1r,det;
    14931493
    14941494        /*p= 1, npoint= 1 (Gauss-Legendre)*/
    1495         static double wgt1[]={2.000000000000000};
    1496         static double xi1[]={0.000000000000000};
     1495        static IssmPDouble wgt1[]={2.000000000000000};
     1496        static IssmPDouble xi1[]={0.000000000000000};
    14971497
    14981498        /*p= 1, npoint= 2*/
    1499         static double wgt2[]={1.000000000000000, 1.000000000000000};
    1500         static double xi2[]={-1.000000000000000, 1.000000000000000};
     1499        static IssmPDouble wgt2[]={1.000000000000000, 1.000000000000000};
     1500        static IssmPDouble xi2[]={-1.000000000000000, 1.000000000000000};
    15011501
    15021502        /*p= 3, npoint= 3*/
    1503         static double wgt3[]={0.333333333333333, 1.333333333333333, 0.333333333333333};
    1504         static double xi3[]={-1.000000000000000, 0.000000000000000, 1.000000000000000};
     1503        static IssmPDouble wgt3[]={0.333333333333333, 1.333333333333333, 0.333333333333333};
     1504        static IssmPDouble xi3[]={-1.000000000000000, 0.000000000000000, 1.000000000000000};
    15051505
    15061506        /*p= 5, npoint= 4*/
    1507         static double wgt4[]={0.166666666666667, 0.833333333333333, 0.833333333333333, 0.166666666666667};
    1508         static double xi4[]={-1.000000000000000,-0.447213595499958, 0.447213595499958, 1.000000000000000};
     1507        static IssmPDouble wgt4[]={0.166666666666667, 0.833333333333333, 0.833333333333333, 0.166666666666667};
     1508        static IssmPDouble xi4[]={-1.000000000000000,-0.447213595499958, 0.447213595499958, 1.000000000000000};
    15091509
    15101510        /*p= 7, npoint= 5*/
    1511         static double wgt5[]={0.100000000000000, 0.544444444444444, 0.711111111111111, 0.544444444444444, 0.100000000000000};
    1512         static double xi5[]={-1.000000000000000,-0.654653670707977, 0.000000000000000, 0.654653670707977, 1.000000000000000};
    1513 
    1514         static double* wgtp[MAX_LINE_GLOB_PTS]={wgt1 ,wgt2 ,wgt3 ,wgt4 ,wgt5 };
    1515         static double* xip [MAX_LINE_GLOB_PTS]={xi1  ,xi2  ,xi3  ,xi4  ,xi5  };
    1516 
    1517         static int np[MAX_LINE_GLOB_PTS]={sizeof(wgt1 )/sizeof(double),
    1518                 sizeof(wgt2 )/sizeof(double),
    1519                 sizeof(wgt3 )/sizeof(double),
    1520                 sizeof(wgt4 )/sizeof(double),
    1521                 sizeof(wgt5 )/sizeof(double)};
    1522 
    1523         //      _printf_(true,"Gauss-Lobatto recurrence coefficients ngaus=%d\n",ngaus);
    1524         *pxgaus = (double *) xmalloc(ngaus*sizeof(double));
    1525         *pxwgt  = (double *) xmalloc(ngaus*sizeof(double));
     1511        static IssmPDouble wgt5[]={0.100000000000000, 0.544444444444444, 0.711111111111111, 0.544444444444444, 0.100000000000000};
     1512        static IssmPDouble xi5[]={-1.000000000000000,-0.654653670707977, 0.000000000000000, 0.654653670707977, 1.000000000000000};
     1513
     1514        static IssmPDouble* wgtp[MAX_LINE_GLOB_PTS]={wgt1 ,wgt2 ,wgt3 ,wgt4 ,wgt5 };
     1515        static IssmPDouble* xip [MAX_LINE_GLOB_PTS]={xi1  ,xi2  ,xi3  ,xi4  ,xi5  };
     1516
     1517        static int np[MAX_LINE_GLOB_PTS]={sizeof(wgt1 )/sizeof(IssmPDouble),
     1518                sizeof(wgt2 )/sizeof(IssmPDouble),
     1519                sizeof(wgt3 )/sizeof(IssmPDouble),
     1520                sizeof(wgt4 )/sizeof(IssmPDouble),
     1521                sizeof(wgt5 )/sizeof(IssmPDouble)};
     1522
     1523        //      _pprintLine_("Gauss-Lobatto recurrence coefficients ngaus=" << ngaus);
     1524        *pxgaus =xNew<IssmPDouble>(ngaus);
     1525        *pxwgt  =xNew<IssmPDouble>(ngaus);
    15261526
    15271527        /*  check to see if Gauss points need to be calculated  */
     
    15391539
    15401540                /*  calculate the Gauss points using recurrence relations  */
    1541                 alpha=(double *) xmalloc(ngaus*sizeof(double));
    1542                 beta =(double *) xmalloc(ngaus*sizeof(double));
     1541                alpha=xNew<IssmPDouble>(ngaus);
     1542                beta =xNew<IssmPDouble>(ngaus);
    15431543
    15441544                /*  calculate the Legendre recurrence coefficients  */
     
    15751575                /*  calculate the Gauss points  */
    15761576                GaussRecur(*pxgaus, *pxwgt, ngaus, alpha, beta );
    1577                 xfree((void **)&beta );
    1578                 xfree((void **)&alpha);
     1577                xDelete<IssmPDouble>(beta );
     1578                xDelete<IssmPDouble>(alpha);
    15791579        }
    15801580
    1581 }/*}}}1*/
    1582 /*FUNCTION GaussRecur{{{1*/
    1583 void GaussRecur( double* zero, double* weight, int n, double* alpha, double* beta ) {
     1581}/*}}}*/
     1582/*FUNCTION GaussRecur{{{*/
     1583void GaussRecur( IssmPDouble* zero, IssmPDouble* weight, int n, IssmPDouble* alpha, IssmPDouble* beta ) {
    15841584        /*Gauss quadrature points from recursion coefficients.
    15851585         *
     
    15891589        /*Intermediaries*/
    15901590        int i,j,k,l,m,ii,mml,iter;
    1591         double p,g,r,s,c,f,b;
    1592         double* work;
     1591        IssmPDouble p,g,r,s,c,f,b;
     1592        IssmPDouble* work;
    15931593
    15941594        if (n==1){
     
    15981598        }
    15991599
    1600         work=(double*)xmalloc(n*sizeof(double));
     1600        work=xNew<IssmPDouble>(n);
    16011601
    16021602        zero[0]  =alpha[0];
     
    16691669                } while (iter < MAX_GAUS_ITER);
    16701670                if (iter >= MAX_GAUS_ITER) {
    1671                         xfree((void **)&work);
    1672                         _error_("%s%i"," Max iterations exceeded for l=",MAX_GAUS_ITER);
     1671                        xDelete<IssmPDouble>(work);
     1672                        _error2_("Max iterations exceeded for l=" << MAX_GAUS_ITER);
    16731673                }
    16741674        }
     
    16981698
    16991699        /*Cleanup*/
    1700         xfree((void **)&work);
    1701 
    1702 }/*}}}1*/
     1700        xDelete<IssmPDouble>(work);
     1701
     1702}/*}}}*/
    17031703
    17041704/*Element Gauss points TO BE REMOVED*/
    1705 /*FUNCTION gaussQuad{{{1*/
    1706 void gaussQuad( double** pxgaus, double** pxwgt, double** pegaus, double** pewgt, int nigaus, int njgaus ) {
     1705/*FUNCTION gaussQuad{{{*/
     1706void gaussQuad( IssmPDouble** pxgaus, IssmPDouble** pxwgt, IssmPDouble** pegaus, IssmPDouble** pewgt, int nigaus, int njgaus ) {
    17071707        /*Gauss quadrature points for the quadrilaterial.*/
    17081708
     
    17101710        GaussLegendreLinear(pxgaus, pxwgt, nigaus);
    17111711        GaussLegendreLinear(pegaus, pewgt, njgaus);
    1712 }/*}}}1*/
    1713 /*FUNCTION gaussHexa{{{1*/
    1714 void gaussHexa( double** pxgaus, double** pxwgt, double** pegaus, double** pewgt, double** pzgaus, double** pzwgt, int nigaus, int njgaus, int nkgaus ) {
     1712}/*}}}*/
     1713/*FUNCTION gaussHexa{{{*/
     1714void gaussHexa( IssmPDouble** pxgaus, IssmPDouble** pxwgt, IssmPDouble** pegaus, IssmPDouble** pewgt, IssmPDouble** pzgaus, IssmPDouble ** pzwgt, int nigaus, int njgaus, int nkgaus ) {
    17151715        /*Gauss quadrature points for the hexahedron.*/
    17161716
     
    17191719        GaussLegendreLinear(pegaus, pewgt, njgaus);
    17201720        GaussLegendreLinear(pzgaus, pzwgt, nkgaus);
    1721 }/*}}}1*/
     1721}/*}}}*/
  • issm/trunk/src/c/shared/Numerics/GaussPoints.h

    r5808 r12706  
    33 */
    44
     5#include "../../include/types.h"
    56#ifndef _GAUSSPOINTS_H
    67#define _GAUSSPOINTS_H
    78
    89#define MAX_LINE_GAUS_PTS    4
    9 void GaussLegendreLinear( double** pxgaus, double** pxwgt, int ngaus );
     10void GaussLegendreLinear(IssmPDouble** pxgaus, IssmPDouble** pxwgt, int ngaus);
    1011#define MAX_TRIA_SYM_ORD    20
    11 void GaussLegendreTria( int* pngaus, double** pl1, double** pl2, double** pl3, double** pwgt, int iord );
     12void GaussLegendreTria(int* pngaus, IssmPDouble** pl1, IssmPDouble** pl2, IssmPDouble** pl3, IssmPDouble** pwgt, int iord);
    1213#define MAX_TETRA_SYM_ORD    6
    13 void GaussLegendreTetra( int* pngaus, double** pl1, double** pl2, double** pl3, double** pl4, double** pwgt, int iord );
     14void GaussLegendreTetra(int* pngaus, IssmPDouble** pl1, IssmPDouble** pl2, IssmPDouble** pl3, IssmPDouble** pl4, IssmPDouble** pwgt, int iord);
    1415#define MAX_LINE_GLOB_PTS    5
    15 void GaussLobatto( double** pxgaus, double** pxwgt, int ngaus );
     16void GaussLobatto(IssmPDouble** pxgaus, IssmPDouble** pxwgt, int ngaus);
    1617#define MAX_GAUS_ITER   30
    17 void GaussRecur( double* zero, double* weight, int n, double* alpha, double* beta );
     18void GaussRecur(IssmPDouble* zero, IssmPDouble* weight, int n, IssmPDouble* alpha, IssmPDouble* beta);
    1819
    19 void gaussQuad( double** pxgaus, double** pxwgt, double** pegaus, double** pewgt, int nigaus, int njgaus );
    20 void gaussHexa( double** pxgaus, double** pxwgt, double** pegaus, double** pewgt, double** pzgaus, double** pzwgt, int nigaus, int njgaus, int nkgaus );
     20void gaussQuad(IssmPDouble** pxgaus, IssmPDouble** pxwgt, IssmPDouble** pegaus, IssmPDouble** pewgt, int nigaus, int njgaus);
     21void gaussHexa(IssmPDouble** pxgaus, IssmPDouble** pxwgt, IssmPDouble** pegaus, IssmPDouble** pewgt, IssmPDouble** pzgaus, IssmPDouble ** pzwgt, int nigaus, int njgaus, int nkgaus);
    2122
    2223#endif
  • issm/trunk/src/c/shared/Numerics/IsInputConverged.cpp

    r9883 r12706  
    1414#include "../../objects/objects.h"
    1515
    16 void IsInputConverged(double* peps, Input** new_inputs,Input** old_inputs,int num_inputs,int criterion_enum){
     16void IsInputConverged(IssmDouble* peps, Input** new_inputs,Input** old_inputs,int num_inputs,int criterion_enum){
    1717
    1818        int i,j;
    1919
    2020        /*output: */
    21         double eps;
     21        IssmDouble eps;
    2222       
    2323        /*intermediary: */
    24         double *newvalues     = NULL;
    25         double *oldvalues     = NULL;
     24        IssmDouble *newvalues     = NULL;
     25        IssmDouble *oldvalues     = NULL;
    2626        int     num_values;
    27         double  ndu        = 0;
    28         double  nu         = 0;
     27        IssmDouble  ndu        = 0;
     28        IssmDouble  nu         = 0;
    2929
    3030        if(criterion_enum==RelativeEnum){
     
    5050
    5151                /*now, compute eps: */
    52                 if(nu)eps=ndu/nu;
     52                if(reCast<bool>(nu))eps=ndu/nu;
    5353                else eps=0;
    5454        }
    55         else _error_("%s%s%s"," convergence criterion ",EnumToStringx(criterion_enum)," not supported yet!");
     55        else _error2_("convergence criterion " << EnumToStringx(criterion_enum) << " not supported yet!");
    5656
    5757        /*Assign output pointers:*/
  • issm/trunk/src/c/shared/Numerics/OptimalSearch.cpp

    r9761 r12706  
    1616#include <float.h>
    1717
    18 void OptimalSearch(double* psearch_scalar,double* pJ,OptPars* optpars,double (*f)(double,OptArgs*), OptArgs* optargs){
     18void OptimalSearch(IssmDouble* psearch_scalar,IssmDouble* pJ,OptPars* optpars,IssmDouble (*f)(IssmDouble,OptArgs*), OptArgs* optargs){
    1919
    2020        /* This routine is optimizing a given function*/
    2121
    2222        /*function values: */
    23         double fx1,fx2,fxbest;
    24         double x1,x2,xmin,xbest;
     23        IssmDouble fx1,fx2,fxbest;
     24        IssmDouble x1,x2,xmin,xbest;
    2525
    2626        /*tolerances: */
    27         double seps;
    28         double tolerance=1.e-4;
     27        IssmDouble seps;
     28        IssmDouble tolerance=1.e-4;
    2929        int    maxiter;
    3030
     
    4141        //get the value of the function at the first boundary
    4242        fx1= (*f)(x1,optargs);
    43         if (isnan(fx1)) _error_("Function evaluation returned NaN");
    44         _printf_(VerboseControl(),"\n        Iteration         x           f(x)       Tolerance\n\n");
    45         _printf_(VerboseControl(),"        %s    %12.6g  %12.6g  %s","   N/A",x1,fx1,"         N/A\n");
     43        if (xIsNan<IssmDouble>(fx1)) _error2_("Function evaluation returned NaN");
     44        cout<<setprecision(5);
     45        if(VerboseControl()) _pprintLine_("");
     46        if(VerboseControl()) _pprintLine_("       Iteration         x           f(x)       Tolerance");
     47        if(VerboseControl()) _pprintLine_("");
     48        if(VerboseControl()) _pprintLine_("           N/A    "<<setw(12)<<x1<<"  "<<setw(12)<<fx1<<"           N/A");
    4649
    4750        //update tolerances
     
    5457                iter++;
    5558                fx2 = (*f)(x2,optargs);
    56                 if (isnan(fx2)) _error_("Function evaluation returned NaN");
    57                 _printf_(VerboseControl(),"         %5i    %12.6g  %12.6g  %12.6g\n",iter,x2,fx2,fabs(x2-x1)>fabs(fx2-fx1)?fabs(fx2-fx1):fabs(x2-x1));
     59                if (xIsNan<IssmDouble>(fx2)) _error2_("Function evaluation returned NaN");
     60                if(VerboseControl())
     61                 _pprintLine_("         "<<setw(5)<<iter<<"    "<<setw(12)<<x2<<"  "<<setw(12)<<fx2<<"  "<<(fabs(x2-x1)>fabs(fx2-fx1)?fabs(fx2-fx1):fabs(x2-x1)));
    5862
    5963                //Stop the optimization?
    6064                if ((fabs(x2-x1)+seps)<tolerance || (fabs(fx2-fx1)+seps)<tolerance){
    61                         _printf_(VerboseControl(),"      %s%g\n","optimization terminated: the current x satisfies the termination criteria using 'tolx' of " ,tolerance);
     65                        if(VerboseControl()) _pprintLine_("      " << "optimization terminated: the current x satisfies the termination criteria using 'tolx' of "  << tolerance);
    6266                        loop=false;
    6367                }
    6468                else if (iter>=maxiter){
    65                         _printf_(VerboseControl(),"      %s\n","exiting: Maximum number of iterations has been exceeded  - increase 'maxiter'\n");
     69                        if(VerboseControl()) _pprintLine_("      " << "exiting: Maximum number of iterations has been exceeded  - increase 'maxiter'");
    6670                        loop=false;
    6771                }
  • issm/trunk/src/c/shared/Numerics/OptionsFromAnalysis.cpp

    r12330 r12706  
    2222        /*intermediary: */
    2323        int     dummy;
    24         double* analyses=NULL;
     24        IssmDouble* analyses=NULL;
    2525        char**  strings=NULL;
    2626        char*   string=NULL;
     
    5757        if (found==-1){
    5858                /*ok, we did not find anything, this is not good! error out: */
    59                 _error_("%s%s","could find neither a default analysis  nor analysis ",EnumToStringx(analysis_type));
     59                _error2_("could find neither a default analysis  nor analysis " << EnumToStringx(analysis_type));
    6060        }
    6161
    6262        /*ok, grab the option string: */
    63         outstring=(char*)xmalloc((strlen(strings[found])+1)*sizeof(char));
     63        outstring=xNew<char>(strlen(strings[found])+1);
    6464        strcpy(outstring,strings[found]);
    6565
    6666        /*Free ressources*/
    67         xfree((void**)&analyses);
     67        xDelete<IssmDouble>(analyses);
    6868        for(i=0;i<numanalyses;i++){
    6969                string=strings[i];
    70                 xfree((void**)&string);
     70                xDelete<char>(string);
    7171        }
    72         xfree((void**)&strings);
    73 
    74 
     72        xDelete<char*>(strings);
    7573        return outstring;
    7674}
  • issm/trunk/src/c/shared/Numerics/PetscOptionsFromAnalysis.cpp

    r11995 r12706  
    3939
    4040        /*Free ressources:*/
    41         xfree((void**)&options);
     41        xDelete<char>(options);
    4242}
  • issm/trunk/src/c/shared/Numerics/Synchronize.sh

    r12330 r12706  
    88#Get all lines of Verbosity.cpp
    99cat Verbosity.h |  grep "bool Verbose" | awk '{print $2}' | sed -e "s/(/ /" | awk '{print $1}' | awk '{ printf "%s %s\n", NR, $0 }' >temp
    10 #Build header of Verbosity.cpp {{{1
     10#Build header of Verbosity.cpp {{{
    1111cat <<END > Verbosity.cpp
    1212/*
     
    127127done
    128128
    129 #Add footer of Verbosity.cpp{{{1
     129#Add footer of Verbosity.cpp{{{
    130130cat <<END >> Verbosity.cpp
    131131
     
    135135void SetVerbosityLevel(int level){
    136136
    137         if(level<0) _error_("vebosity level should be a positive integer (user provided %i)",level);
     137        if(level<0) _error2_("vebosity level should be a positive integer (user provided " << level << ")");
    138138
    139139        verbositylevel = level;
     
    147147END
    148148#}}}
    149 #Complete verbose.m {{{1
     149#Complete verbose.m {{{
    150150VERBOSEPATH="$ISSM_DIR/src/m/classes/verbose.m"
    151151cat $VERBOSEPATH  | sed "/%BEGINFIELDS/,$ d"  > temp_begin
  • issm/trunk/src/c/shared/Numerics/UnitConversion.cpp

    r11995 r12706  
    33 */
    44
    5 /*headers {{{1*/
     5/*headers {{{*/
    66#ifdef HAVE_CONFIG_H
    77        #include <config.h>
     
    1515#include "../../shared/shared.h"
    1616
    17 double UnitConversionScaleFactor(int type_enum);
     17IssmDouble UnitConversionScaleFactor(int type_enum);
    1818/*}}}*/
    1919
    20 void UnitConversion(double* values, int numvalues,int direction_enum, int type_enum){
     20void UnitConversion(IssmDouble* values, int numvalues,int direction_enum, int type_enum){
    2121
    22         double scale;
     22        IssmDouble scale;
    2323        int i;
    2424
     
    2929        if(direction_enum==IuToExtEnum) for(i=0;i<numvalues;i++)values[i]=values[i]*scale;
    3030        else if(direction_enum==ExtToIuEnum) for(i=0;i<numvalues;i++)values[i]=values[i]/scale;
    31         else _error_(" wrong direction for unit conversion, either IuToExtEnum or ExtToIuEnum. ");
     31        else _error2_("wrong direction for unit conversion, either IuToExtEnum or ExtToIuEnum. ");
    3232
    3333}
    3434
    35 double UnitConversion(double value, int direction_enum, int type_enum){
     35IssmDouble UnitConversion(IssmDouble value, int direction_enum, int type_enum){
    3636
    3737        UnitConversion(&value,1,direction_enum,type_enum);
     
    4141
    4242
    43 double UnitConversionScaleFactor(int type_enum){
     43IssmDouble UnitConversionScaleFactor(int type_enum){
    4444
    45         double yts=365.0*24.0*3600.0;
     45        IssmDouble yts=365.0*24.0*3600.0;
    4646       
    47         double scale;
     47        IssmDouble scale;
    4848        switch(type_enum){
    4949                case TimesteppingStartTimeEnum:              scale=1.0/yts;break; //yr
     
    6666                case SurfaceforcingsPrecipitationEnum:       scale=yts;break; //m/yr
    6767                case SurfaceforcingsMassBalanceEnum:         scale=yts;break; //m/yr
     68                case SurfaceforcingsSmbPosMaxEnum:                              scale=yts;break; //m/yr
     69                case SurfaceforcingsSmbPosMinEnum:                              scale=yts;break; //m/yr
     70                case SurfaceforcingsAPosEnum:                                           scale=yts;break; //m/yr
     71                case SurfaceforcingsBPosEnum:                                           scale=yts;break; //m/yr
     72                case SurfaceforcingsANegEnum:                                           scale=yts;break; //m/yr
     73                case SurfaceforcingsBNegEnum:                                           scale=yts;break; //m/yr
    6874                case MisfitEnum:                             scale=pow(yts,2);break; //(m/yr)^2
    69                 case MassFluxEnum:                           scale=pow((double)10,-12)*yts;break; // (GigaTon/year)
     75                case MassFluxEnum:                           scale=pow((IssmDouble)10,-12)*yts;break; // (GigaTon/year)
    7076                default: scale=1.0; break;
    7177        }
  • issm/trunk/src/c/shared/Numerics/Verbosity.cpp

    r12330 r12706  
    3434void SetVerbosityLevel(int level){
    3535
    36         if(level<0) _error_("vebosity level should be a positive integer (user provided %i)",level);
     36        if(level<0) _error2_("vebosity level should be a positive integer (user provided " << level << ")");
    3737
    3838        verbositylevel = level;
  • issm/trunk/src/c/shared/Numerics/XZvectorsToCoordinateSystem.cpp

    r12330 r12706  
    55#include <math.h>
    66
    7 void XZvectorsToCoordinateSystem(double* T,double* xzvectors){
     7void XZvectorsToCoordinateSystem(IssmDouble* T,IssmDouble* xzvectors){
    88
    99        int             i,j;
    10         double  x[3],y[3],z[3];
    11         double  x_norm, y_norm, z_norm;
     10        IssmDouble      x[3],y[3],z[3];
     11        IssmDouble      x_norm, y_norm, z_norm;
    1212
    1313        for(i=0;i<6;i++){
    14                 if(isnan(xzvectors[i])){
     14                if(xIsNan<IssmDouble>(xzvectors[i])){
    1515                        /*At least one NaN found: default to Id*/
    1616                        T[0*3+0] = 1.0; T[0*3+1] = 0.0; T[0*3+2] = 0.0;
  • issm/trunk/src/c/shared/Numerics/cross.cpp

    r9320 r12706  
    99#endif
    1010
    11 void cross(double* result,double* vector1,double* vector2){
     11#include "../../include/include.h"
     12
     13void cross(IssmDouble* result,IssmDouble* vector1,IssmDouble* vector2){
    1214
    1315        /*result,vector1 and vector2 are all assumed to be of size 3: */
  • issm/trunk/src/c/shared/Numerics/extrema.cpp

    r9320 r12706  
    99#endif
    1010
     11#include "../../include/include.h"
    1112
    12 double min(double a,double b){
     13IssmDouble min(IssmDouble a,IssmDouble b){
    1314        if (a<b)return a;
    1415        else return b;
     
    1819        else return b;
    1920}
    20 double max(double a,double b){
     21IssmDouble max(IssmDouble a,IssmDouble b){
    2122        if (a>b)return a;
    2223        else return b;
  • issm/trunk/src/c/shared/Numerics/isnan.cpp

    r2241 r12706  
    11/*This routine only used by Intel compler: */
    2 #ifdef _INTEL_WIN_
    32
    4 int isnan(double x){
    5         if (x!=x)return 1;
    6         else return 0;
     3#include "../../include/include.h"
     4#include "isnan.h"
     5
     6#ifdef _HAVE_ADOLC_
     7template <> int xIsNan<adouble> (const adouble& X) {
     8  return isnan(X.getValue());
    79}
    810#endif
    9 
  • issm/trunk/src/c/shared/Numerics/isnan.h

    r2241 r12706  
    33 */
    44
    5 #ifndef _ISNAN_INTEL_H_
    6 #define _ISNAN_INTEL_H_
     5#ifndef _XISNAN_H_
     6#define _XISNAN_H_
    77
     8#include <cmath>
     9
     10template <class T> int xIsNan(const T& X) {
    811#ifdef _INTEL_WIN_
    9 int isnan(double X);
     12                return (X!=X)?1:0;
     13#else
     14                return isnan(X);
     15#endif
     16}
     17
     18#ifdef _HAVE_ADOLC_
     19template <> int xIsNan<adouble> (const adouble& X);
    1020#endif
    1121
    1222#endif
    13 
  • issm/trunk/src/c/shared/Numerics/numerics.h

    r11995 r12706  
    99#include "./GaussPoints.h"
    1010#include "./isnan.h"
     11#include "./recast.h"
    1112
    1213class Input;
     
    1617struct OptPars;
    1718
    18 double min(double a,double b);
    19 double max(double a,double b);
     19IssmDouble min(IssmDouble a,IssmDouble b);
     20IssmDouble max(IssmDouble a,IssmDouble b);
    2021int    min(int a,int b);
    2122int    max(int a,int b);
    22 double OptFunc(double scalar, OptArgs* optargs);
    23 void   BrentSearch(double* psearch_scalar,double* pJ,OptPars* optpars,double (*f)(double,OptArgs*), OptArgs* optargs);
    24 void   OptimalSearch(double* psearch_scalar,double* pJ,OptPars* optpars,double (*f)(double,OptArgs*), OptArgs* optargs);
    25 void   cross(double* result,double* vector1,double* vector2);
    26 void   IsInputConverged(double* peps, Input** new_inputs,Input** old_inputs,int num_inputs,int criterion_enum);
    27 void   UnitConversion(double* values, int numvalues,int direction_enum, int type_enum);
    28 double UnitConversion(double value, int direction_enum, int type_enum);
     23IssmDouble OptFunc(IssmDouble scalar, OptArgs* optargs);
     24void   BrentSearch(IssmDouble* psearch_scalar,IssmDouble* pJ,OptPars* optpars,IssmDouble (*f)(IssmDouble,OptArgs*), OptArgs* optargs);
     25void   OptimalSearch(IssmDouble* psearch_scalar,IssmDouble* pJ,OptPars* optpars,IssmDouble (*f)(IssmDouble,OptArgs*), OptArgs* optargs);
     26void   cross(IssmDouble* result,IssmDouble* vector1,IssmDouble* vector2);
     27void   IsInputConverged(IssmDouble* peps, Input** new_inputs,Input** old_inputs,int num_inputs,int criterion_enum);
     28void   UnitConversion(IssmDouble* values, int numvalues,int direction_enum, int type_enum);
     29IssmDouble UnitConversion(IssmDouble value, int direction_enum, int type_enum);
    2930char*  OptionsFromAnalysis(Parameters* parameters,int analysis_type);
    30 void   XZvectorsToCoordinateSystem(double* T,double* xzvectors);
     31void   XZvectorsToCoordinateSystem(IssmDouble* T,IssmDouble* xzvectors);
    3132#ifdef _HAVE_PETSC_
    3233void   PetscOptionsFromAnalysis(Parameters* parameters,int analysis_type);
  • issm/trunk/src/c/shared/String/DescriptorIndex.cpp

    r9336 r12706  
    2323        /*retrieve first token, separated by underscore: */
    2424        pch = strtok (descriptor,"_");
    25         if(!pch)_error_("%s%s%s"," descriptor ",descriptor," is not correctly formatted!");
     25        if(!pch)_error2_("descriptor " << descriptor << " is not correctly formatted!");
    2626
    2727        if (strncmp(pch,"scaled",6)==0){
    2828                /*we have a scaled variable. recover the root: */
    2929                pch = strtok (NULL, "_");
    30                 if(!pch)_error_("%s%s%s"," scaled descriptor ",descriptor," is not correctly formatted!");
     30                if(!pch)_error2_("scaled descriptor " << descriptor << " is not correctly formatted!");
    3131                memcpy(root,pch,(strlen(pch)+1)*sizeof(char));
    3232
     
    4444                /*we have an indexed variable. recover the root: */
    4545                pch = strtok (NULL, "_");
    46                 if(!pch)_error_("%s%s%s"," indexed descriptor ",descriptor," is not correctly formatted!");
     46                if(!pch)_error2_("indexed descriptor " << descriptor << " is not correctly formatted!");
    4747                memcpy(root,pch,(strlen(pch)+1)*sizeof(char));
    4848                /*now recover  the index: */
    4949                pch = strtok (NULL, "_");
    50                 if(!pch)_error_("%s%s%s"," indexed descriptor ",descriptor," is not correctly formatted!");
     50                if(!pch)_error2_("indexed descriptor " << descriptor << " is not correctly formatted!");
    5151                sscanf(pch,"%i",pindex);
    5252                return IndexedEnum;
     
    5555                /*we have an indexed variable. recover the root: */
    5656                pch = strtok (NULL, "_");
    57                 if(!pch)_error_("%s%s%s"," nodal descriptor ",descriptor," is not correctly formatted!");
     57                if(!pch)_error2_("nodal descriptor " << descriptor << " is not correctly formatted!");
    5858                memcpy(root,pch,(strlen(pch)+1)*sizeof(char));
    5959                /*now recover  the index: */
    6060                pch = strtok (NULL, "_");
    61                 if(!pch)_error_("%s%s%s"," nodal descriptor ",descriptor," is not correctly formatted!");
     61                if(!pch)_error2_("nodal descriptor " << descriptor << " is not correctly formatted!");
    6262                sscanf(pch,"%i",pindex);
    6363                return NodalEnum;
  • issm/trunk/src/c/shared/Threads/LaunchThread.cpp

    r12330 r12706  
    2020
    2121#include "./issm_threads.h"
    22 #include "../Alloc/alloc.h"
     22#include "../Alloc/xNewDelete.h"
    2323#include "../Exceptions/exceptions.h"
    2424#include "../../include/include.h"
     
    2828        #ifdef _MULTITHREADING_
    2929        int i;
    30         int* status=NULL;
    31 
    32         pthread_t* threads=NULL;
    33         pthread_handle* handles=NULL;
     30        int            *status  = NULL;
     31        pthread_t      *threads = NULL;
     32        pthread_handle *handles = NULL;
    3433       
    3534        /*dynamically allocate: */
    36         threads=(pthread_t*)xmalloc(num_threads*sizeof(pthread_t));
    37         handles=(pthread_handle*)xmalloc(num_threads*sizeof(pthread_handle));
     35        threads=xNew<pthread_t>(num_threads);
     36        handles=xNew<pthread_handle>(num_threads);
    3837
    3938        for(i=0;i<num_threads;i++){
     
    4241                handles[i].num=num_threads;
    4342        }
    44        
    4543        for(i=0;i<num_threads;i++){
    4644
    4745                if(pthread_create(threads+i,NULL,function,(void*)(handles+i))){
    48                         _error_(" pthread_create error");
     46                        _error2_("pthread_create error");
    4947                }
    5048        }
    5149        for(i=0;i<num_threads;i++){
    5250                if(pthread_join(threads[i],(void**)&status)){
    53                         _error_(" pthread_join error");
     51                        _error2_("pthread_join error");
    5452                }
    5553        }
    5654       
    5755        /*Free ressources:*/
    58         xfree((void**)&threads);
    59         xfree((void**)&handles);
     56        xDelete<pthread_t>(threads);
     57        xDelete<pthread_handle>(handles);
    6058
    6159        #else
  • issm/trunk/src/c/shared/TriMesh/SplitMeshForRifts.cpp

    r12330 r12706  
    33 */
    44#include "./trimesh.h"
    5 
     5#include "../Alloc/xNewDelete.h"
    66#include "../Alloc/alloc.h"
    77
     
    5252
    5353        /*Go through all nodes of the rift segments, and start splitting the mesh: */
    54         flags=(int*)xcalloc(nods,sizeof(int)); //to make sure we don't split the same nodes twice!
     54        flags=xNewZeroInit<int>(nods); //to make sure we don't split the same nodes twice!
    5555        for (i=0;i<nriftsegs;i++){
    5656                for (j=0;j<2;j++){
  • issm/trunk/src/c/shared/TriMesh/TriMeshUtils.cpp

    r12330 r12706  
    77#include "./trimesh.h"
    88#include "../Exceptions/exceptions.h"
     9#include "../Alloc/xNewDelete.h"
    910#include "../Alloc/alloc.h"
    1011#include "../../include/include.h"
     
    5354        current_size=max_number_elements;
    5455        NumGridElements=0;
    55         GridElements=(int*)xmalloc(max_number_elements*sizeof(int));
     56        GridElements=xNew<int>(max_number_elements);
    5657
    5758        for (i=0;i<nel;i++){
     
    6566                                else{
    6667                                        /*Reallocate another max_number_elements slots in the GridElements: */
    67                                         GridElementsRealloc=(int*)xrealloc(GridElements,(current_size+max_number_elements)*sizeof(int));
     68                                        GridElementsRealloc=xReNew<int>(GridElements,current_size,(current_size+max_number_elements));
    6869                                        if (!GridElementsRealloc){
    6970                                                noerr=0;
     
    8182        cleanup_and_return:
    8283        if(!noerr){
    83                 xfree((void**)&GridElements);
     84                xDelete<int>(GridElements);
    8485        }
    8586        /*Allocate return pointers: */
     
    128129
    129130        /*Allocate segmentflags: */
    130         riftsegments_uncompressed=(int*)xcalloc(nsegs*5,sizeof(int));
     131        riftsegments_uncompressed=xNewZeroInit<int>(nsegs*5);
    131132
    132133        /*Find the segments that belong to a rift: they are the ones that see two elements. The other ones belong to a boundary
     
    165166
    166167        /*Compress riftsegments_uncompressed:*/
    167         riftsegments=(int*)xmalloc(nriftsegs*4*sizeof(int));
     168        riftsegments=xNew<int>(nriftsegs*4);
    168169        counter=0;
    169170        for (i=0;i<nsegs;i++){
     
    177178        }
    178179
    179         xfree((void**)&riftsegments_uncompressed);
     180        xDelete<int>(riftsegments_uncompressed);
    180181       
    181182        /*Assign output pointers: */
     
    202203        /*Figure out the list of elements  that are on the same side of the rift. To do so, we start from one
    203204         * side of the rift and keep rotating in the same direction:*/
    204         GridElementListOnOneSideOfRift=(int*)xmalloc(NumGridElements*sizeof(int));
     205        GridElementListOnOneSideOfRift=xNew<int>(NumGridElements);
    205206        //bootstrap the GridElementListOnOneSideOfRift by filling elements from riftsegments: */
    206207        GridElementListOnOneSideOfRift[0]=*(riftsegments+4*segmentnumber+0); /*this one does not belong to the same side, but is just there
     
    241242
    242243        /*Free ressources: */
    243         xfree((void**)&GridElements);
     244        xDelete<int>(GridElements);
    244245        /*Assign output pointers: */
    245246        *pNumGridElementListOnOneSideOfRift=NumGridElementListOnOneSideOfRift;
     
    380381
    381382        /*input: */
    382         double* segments=NULL;
    383         double* segmentmarkerlist=NULL;
     383        double *segments          = NULL;
     384        double *segmentmarkerlist = NULL;
    384385        int numsegs;
    385386       
    386387        /*output: */
    387         int* riftsnumsegs=NULL;
    388         double** riftssegments=NULL;
    389         int new_numsegs;
    390         double* new_segments=NULL;
    391         double* new_segmentmarkers=NULL;
     388        int      new_numsegs;
     389        int     *riftsnumsegs       = NULL;
     390        double **riftssegments      = NULL;
     391        double  *new_segments       = NULL;
     392        double  *new_segmentmarkers = NULL;
    392393
    393394        /*intermediary: */
     
    406407        /*Allocate new segments: */
    407408        new_numsegs=counter;
    408         new_segments=(double*)xmalloc(new_numsegs*3*sizeof(double));
    409         new_segmentmarkers=(double*)xmalloc(new_numsegs*sizeof(double));
     409        new_segments=xNew<double>(new_numsegs*3);
     410        new_segmentmarkers=xNew<double>(new_numsegs);
    410411
    411412        /*Copy new segments info : */
     
    422423
    423424        /*Now deal with rift segments: */
    424         riftsnumsegs=(int*)xmalloc(numrifts*sizeof(int));
    425         riftssegments=(double**)xmalloc(numrifts*sizeof(double*));
     425        riftsnumsegs=xNew<int>(numrifts);
     426        riftssegments=xNew<double*>(numrifts);
    426427        for (i=0;i<numrifts;i++){
    427428                /*Figure out how many segments for rift i: */
     
    431432                }
    432433                riftsnumsegs[i]=counter;
    433                 riftsegment=(double*)xmalloc(counter*3*sizeof(double));
     434                riftsegment=xNew<double>(counter*3);
    434435                /*Copy new segments info :*/
    435436                counter=0;
     
    446447
    447448        /*Free ressources: */
    448         xfree((void**)&segments);
     449        xDelete<double>(segments);
    449450
    450451        /*Assign output pointers: */
     
    465466
    466467        /*output: */
    467         int* riftsnumpairs=NULL;
    468         double** riftspairs=NULL;
     468        int     *riftsnumpairs = NULL;
     469        double **riftspairs    = NULL;
    469470
    470471        /*intermediary :*/
     
    474475        int     node1,node2,node3,node4;
    475476
    476         riftsnumpairs=(int*)xmalloc(numrifts*sizeof(int));
    477         riftspairs=(double**)xmalloc(numrifts*sizeof(double*));
     477        riftsnumpairs=xNew<int>(numrifts);
     478        riftspairs=xNew<double*>(numrifts);
    478479        for (i=0;i<numrifts;i++){
    479480                segments=riftssegments[i];
    480481                numsegs=riftsnumsegments[i];
    481482                riftsnumpairs[i]=numsegs;
    482                 pairs=(double*)xmalloc(2*numsegs*sizeof(double));
     483                pairs=xNew<double>(2*numsegs);
    483484                for (j=0;j<numsegs;j++){
    484485                        *(pairs+2*j+0)=*(segments+3*j+2); //retrieve element to which this segment belongs.
     
    500501        }
    501502
    502 
    503503        /*Assign output pointers: */
    504504        *priftsnumpairs=riftsnumpairs;
    505505        *priftspairs=riftspairs;
    506 
    507506        return noerr;
    508507}/*}}}*/
     
    522521
    523522        /*intermediary: */
    524         double* riftsegments=NULL;
    525         double* riftpairs=NULL;
     523        double *riftsegments = NULL;
     524        double *riftpairs    = NULL;
    526525        int     node1,node2,node3,node4,temp_node;
    527526        double  el2;
    528527        int     newnods; //temporary # node counter.
    529528        double  xmin,ymin;
    530         double* xreal=NULL;
    531         double* yreal=NULL;
    532         int* nodes=NULL;
    533         int* mergingnodes=NULL;
     529        double *xreal        = NULL;
     530        double *yreal        = NULL;
     531        int    *nodes        = NULL;
     532        int    *mergingnodes = NULL;
    534533        int     max_size;
    535534        int     redundant;
    536 
    537535
    538536        /*Recover input: */
     
    562560                max_size+=rifts1numsegs[i];
    563561        }
    564         nodes=(int*)xmalloc(max_size*sizeof(int));
    565         mergingnodes=(int*)xmalloc(max_size*sizeof(int));
     562        nodes=xNew<int>(max_size);
     563        mergingnodes=xNew<int>(max_size);
    566564
    567565        /*Go through the rifts segments, and identify which node we are going to merge with its counterpart on the other side
     
    678676                }
    679677        }
    680         xfree((void**)&x); x=xreal;
    681         xfree((void**)&y); y=yreal;
     678        xDelete<double>(x); x=xreal;
     679        xDelete<double>(y); y=yreal;
    682680
    683681        /*Assign output pointers:*/
     
    688686        *psegments=segments;
    689687        *pnumsegs=numsegs;
    690 
    691688        return noerr;
    692689}/*}}}*/
     
    716713        *priftflag=riftflag;
    717714        *pnumrifts=numrifts;
    718 
    719715        return noerr;
    720716}/*}}}*/
     
    726722
    727723        /*intermediary: */
    728         double* riftsegments=NULL;
    729         double* riftpairs=NULL;
     724        double *riftsegments = NULL;
     725        double *riftpairs    = NULL;
    730726        int numsegs;
    731727
    732728        /*ordering and copy: */
    733         int*    order=NULL;
    734         double* riftsegments_copy=NULL;
    735         double* riftpairs_copy=NULL;
     729        int    *order             = NULL;
     730        double *riftsegments_copy = NULL;
     731        double *riftpairs_copy    = NULL;
    736732
    737733        /*node and element manipulation: */
     
    744740
    745741        /*Allocate byproduct of this routine, riftstips: */
    746         riftstips=(double*)xmalloc(numrifts*2*sizeof(double));
     742        riftstips=xNew<double>(numrifts*2);
    747743
    748744        /*Go through all rifts: */
     
    754750                /*Allocate copy of riftsegments and riftpairs,
    755751                 *as well as ordering vector: */
    756                 riftsegments_copy=(double*)xmalloc(numsegs*3*sizeof(double));
    757                 riftpairs_copy=(double*)xmalloc(numsegs*2*sizeof(double));
    758                 order=(int*)xmalloc(numsegs*sizeof(int));
     752                riftsegments_copy=xNew<double>(numsegs*3);
     753                riftpairs_copy=xNew<double>(numsegs*2);
     754                order=xNew<int>(numsegs);
    759755
    760756                /*First find the tips, using the pairs. If a pair of elements has one node in common, this node is a rift tip: */
     
    814810                *(riftstips+2*i+0)=(double)tip1;
    815811                *(riftstips+2*i+1)=(double)tip2;
    816 
    817812
    818813                /*We have the two tips for this rift.  Go from tip1 to tip2, and figure out the order in which segments are sequential.
     
    865860                }
    866861
    867                 xfree((void**)&order);
    868                 xfree((void**)&riftsegments_copy);
    869                 xfree((void**)&riftpairs_copy);
     862                xDelete<int>(order);
     863                xDelete<double>(riftsegments_copy);
     864                xDelete<double>(riftpairs_copy);
    870865
    871866        }
     
    887882
    888883        /*output: */
    889         double** riftspenaltypairs=NULL;
    890         double*  riftpenaltypairs=NULL;
    891         int*     riftsnumpenaltypairs=NULL;
     884        double **riftspenaltypairs    = NULL;
     885        double  *riftpenaltypairs     = NULL;
     886        int     *riftsnumpenaltypairs = NULL;
    892887
    893888        /*intermediary: */
     
    901896
    902897        /*Allocate: */
    903         riftspenaltypairs=(double**)xmalloc(numrifts*sizeof(double*));
    904         riftsnumpenaltypairs=(int*)xmalloc(numrifts*sizeof(int));
     898        riftspenaltypairs=xNew<double*>(numrifts);
     899        riftsnumpenaltypairs=xNew<int>(numrifts);
    905900
    906901        for(i=0;i<numrifts;i++){
     
    910905
    911906                /*allocate riftpenaltypairs, and riftnumpenaltypairs: */
    912                 if((numsegs/2-1)!=0)riftpenaltypairs=(double*)xcalloc((numsegs/2-1)*RIFTPENALTYPAIRSWIDTH,sizeof(double));
     907                if((numsegs/2-1)!=0)riftpenaltypairs=xNewZeroInit<double>((numsegs/2-1)*RIFTPENALTYPAIRSWIDTH);
    913908               
    914909                /*Go through only one flank of the rifts, not counting the tips: */
     
    10061001                riftsnumpenaltypairs[i]=(numsegs/2-1);
    10071002        }
    1008                        
    1009 
    10101003
    10111004        /*Assign output pointers: */
    10121005        *priftspenaltypairs=riftspenaltypairs;
    10131006        *priftsnumpenaltypairs=riftsnumpenaltypairs;
    1014 
    10151007        return noerr;
    10161008}
     
    11431135        *py=y;
    11441136        *pnods=nods;
    1145 
    11461137        return noerr;
    11471138}
  • issm/trunk/src/c/shared/shared.h

    r12330 r12706  
    66#define _SHARED_H_
    77
    8 
    98#include "Alloc/alloc.h"
    109#include "Alloc/alloc_module.h"
     10#include "Alloc/xNewDelete.h"
     11#include "Bamg/shared.h"
     12#include "Elements/elements.h"
    1113#include "Exceptions/exceptions.h"
    1214#include "Exp/exp.h"
     15#include "Matrix/matrix.h"
     16#include "MemOps/xMemCpy.h"
     17#include "Numerics/numerics.h"
     18#include "Sorting/sorting.h"
     19#include "Sys/sys.h"
     20#include "Threads/issm_threads.h"
    1321#include "TriMesh/trimesh.h"
    14 #include "Sorting/sorting.h"
    15 #include "Elements/elements.h"
    16 #include "Matrix/matrix.h"
    17 #include "Numerics/numerics.h"
    18 #include "Dofs/dofs.h"
    19 #include "Threads/issm_threads.h"
    20 #include "Bamg/shared.h"
    2122#include "Wrapper/wrappershared.h"
    2223
  • issm/trunk/src/c/solutions/AdjointCorePointerFromSolutionEnum.cpp

    r9320 r12706  
    3535                        break;
    3636                default:
    37                         _error_("No adjoint has been implemented for solution %s yet",EnumToStringx(solutiontype));
     37                        _error2_("No adjoint has been implemented for solution " << EnumToStringx(solutiontype) << " yet");
    3838                        break;
    3939        }
  • issm/trunk/src/c/solutions/AnalysisConfiguration.cpp

    r11995 r12706  
    2929                case DiagnosticSolutionEnum:
    3030                        numanalyses=5;
    31                         analyses=(int*)xmalloc(numanalyses*sizeof(int));
     31                        analyses=xNew<int>(numanalyses);
    3232                        analyses[0]=DiagnosticHorizAnalysisEnum;
    3333                        analyses[1]=DiagnosticVertAnalysisEnum;
     
    3939                case SteadystateSolutionEnum:
    4040                        numanalyses=8;
    41                         analyses=(int*)xmalloc(numanalyses*sizeof(int));
     41                        analyses=xNew<int>(numanalyses);
    4242                        analyses[0]=DiagnosticHorizAnalysisEnum;
    4343                        analyses[1]=DiagnosticVertAnalysisEnum;
     
    5252                case ThermalSolutionEnum:
    5353                        numanalyses=2;
    54                         analyses=(int*)xmalloc(numanalyses*sizeof(int));
     54                        analyses=xNew<int>(numanalyses);
    5555                        analyses[0]=ThermalAnalysisEnum;
    5656                        analyses[1]=MeltingAnalysisEnum;
     
    5959                case EnthalpySolutionEnum:
    6060                        numanalyses=1;
    61                         analyses=(int*)xmalloc(numanalyses*sizeof(int));
     61                        analyses=xNew<int>(numanalyses);
    6262                        analyses[0]=EnthalpyAnalysisEnum;
    6363                        break;
     
    6565                case HydrologySolutionEnum:
    6666                        numanalyses=3;
    67                         analyses=(int*)xmalloc(numanalyses*sizeof(int));
     67                        analyses=xNew<int>(numanalyses);
    6868                        analyses[0]=HydrologyAnalysisEnum;
    6969                        analyses[1]=SurfaceSlopeAnalysisEnum;
     
    7373                case PrognosticSolutionEnum:
    7474                        numanalyses=1;
    75                         analyses=(int*)xmalloc(numanalyses*sizeof(int));
     75                        analyses=xNew<int>(numanalyses);
    7676                        analyses[0]=PrognosticAnalysisEnum;
    7777                        break;
     
    7979                case BalancethicknessSolutionEnum:
    8080                        numanalyses=1;
    81                         analyses=(int*)xmalloc(numanalyses*sizeof(int));
     81                        analyses=xNew<int>(numanalyses);
    8282                        analyses[0]=BalancethicknessAnalysisEnum;
    8383                        break;
     
    8585                case SurfaceSlopeSolutionEnum:
    8686                        numanalyses=1;
    87                         analyses=(int*)xmalloc(numanalyses*sizeof(int));
     87                        analyses=xNew<int>(numanalyses);
    8888                        analyses[0]=SurfaceSlopeAnalysisEnum;
    8989                        break;
     
    9191                case BedSlopeSolutionEnum:
    9292                        numanalyses=1;
    93                         analyses=(int*)xmalloc(numanalyses*sizeof(int));
     93                        analyses=xNew<int>(numanalyses);
    9494                        analyses[0]=BedSlopeAnalysisEnum;
    9595                        break;
     
    9797                case TransientSolutionEnum:
    9898                        numanalyses=9;
    99                         analyses=(int*)xmalloc(numanalyses*sizeof(int));
     99                        analyses=xNew<int>(numanalyses);
    100100                        analyses[0]=DiagnosticHorizAnalysisEnum;
    101101                        analyses[1]=DiagnosticVertAnalysisEnum;
     
    110110               
    111111                default:
    112                         _error_("%s%s%s"," solution type: ",EnumToStringx(solutiontype)," not supported yet!");
     112                        _error2_("solution type: " << EnumToStringx(solutiontype) << " not supported yet!");
    113113                        break;
    114114        }
     
    117117        if(pnumanalyses) *pnumanalyses=numanalyses;
    118118        if(panalyses)    *panalyses=analyses;
    119         else              xfree((void**)&analyses);
     119        else              xDelete<int>(analyses);
    120120}
  • issm/trunk/src/c/solutions/CorePointerFromSolutionEnum.cpp

    r10287 r12706  
    2929                        solutioncore=&diagnostic_core;
    3030                        #else
    31                         _error_("ISSM was not compiled with diagnostic capabilities. Exiting");
     31                        _error2_("ISSM was not compiled with diagnostic capabilities. Exiting");
    3232                        #endif
    3333                        break;
     
    3636                        solutioncore=&steadystate_core;
    3737                        #else
    38                         _error_("ISSM was not compiled with steady state capabilities. Exiting");
     38                        _error2_("ISSM was not compiled with steady state capabilities. Exiting");
    3939                        #endif
    4040                        break;
     
    4343                        solutioncore=&thermal_core;
    4444                        #else
    45                         _error_("ISSM was not compiled with thermal capabilities. Exiting");
     45                        _error2_("ISSM was not compiled with thermal capabilities. Exiting");
    4646                        #endif
    4747                        break;
     
    5050                        solutioncore=&enthalpy_core;
    5151                        #else
    52                         _error_("ISSM was not compiled with thermal capabilities. Exiting");
     52                        _error2_("ISSM was not compiled with thermal capabilities. Exiting");
    5353                        #endif
    5454                        break;
     
    5757                        solutioncore=&balancethickness_core;
    5858                        #else
    59                         _error_("ISSM was not compiled with balanced capabilities. Exiting");
     59                        _error2_("ISSM was not compiled with balanced capabilities. Exiting");
    6060                        #endif
    6161                        break;
     
    6464                        solutioncore=&hydrology_core;
    6565                        #else
    66                         _error_("ISSM was not compiled with hydrology capabilities. Exiting");
     66                        _error2_("ISSM was not compiled with hydrology capabilities. Exiting");
    6767                        #endif
    6868                        break;
     
    7171                        solutioncore=&surfaceslope_core;
    7272                        #else
    73                         _error_("ISSM was not compiled with slope capabilities. Exiting");
     73                        _error2_("ISSM was not compiled with slope capabilities. Exiting");
    7474                        #endif
    7575                        break;
     
    7878                        solutioncore=&bedslope_core;
    7979                        #else
    80                         _error_("ISSM was not compiled with slope capabilities. Exiting");
     80                        _error2_("ISSM was not compiled with slope capabilities. Exiting");
    8181                        #endif
    8282                        break;
     
    8585                        solutioncore=&transient_core;
    8686                        #else
    87                         _error_("ISSM was not compiled with transient capabilities. Exiting");
     87                        _error2_("ISSM was not compiled with transient capabilities. Exiting");
    8888                        #endif
    8989                        break;
     
    9292                        solutioncore=&prognostic_core;
    9393                        #else
    94                         _error_("ISSM was not compiled with prognostic capabilities. Exiting");
     94                        _error2_("ISSM was not compiled with prognostic capabilities. Exiting");
    9595                        #endif
    9696                        break;
    9797                default:
    98                         _error_("%s%s%s"," solution type: ",EnumToStringx(solutiontype)," not supported yet!");
     98                        _error2_("solution type: " << EnumToStringx(solutiontype) << " not supported yet!");
    9999                        break;
    100100        }
  • issm/trunk/src/c/solutions/ProcessArguments.cpp

    r12330 r12706  
    1717        char *lockfilename   = NULL;
    1818
    19         if(argc<2)_error_("Usage error: no solution requested");
     19        if(argc<2)_error2_("Usage error: no solution requested");
    2020        *solution_type=StringToEnumx(argv[1]);
    21         if(argc<3)_error_("Usage error: missing model name");
     21        if(argc<3)_error2_("Usage error: missing model name");
    2222        modelname=argv[3];
    23         binfilename    = (char*)xmalloc((strlen(modelname)+strlen(".bin")   +1)*sizeof(char)); sprintf(binfilename,   "%s%s",modelname,".bin");
    24         outbinfilename = (char*)xmalloc((strlen(modelname)+strlen(".outbin")+1)*sizeof(char)); sprintf(outbinfilename,"%s%s",modelname,".outbin");
    25         petscfilename  = (char*)xmalloc((strlen(modelname)+strlen(".petsc") +1)*sizeof(char)); sprintf(petscfilename, "%s%s",modelname,".petsc");
    26         lockfilename   = (char*)xmalloc((strlen(modelname)+strlen(".lock")  +1)*sizeof(char)); sprintf(lockfilename,  "%s%s",modelname,".lock");
     23        binfilename    = xNew<char>(strlen(modelname)+strlen(".bin")   +1); sprintf(binfilename,   "%s%s",modelname,".bin");
     24        outbinfilename = xNew<char>(strlen(modelname)+strlen(".outbin")+1); sprintf(outbinfilename,"%s%s",modelname,".outbin");
     25        petscfilename  = xNew<char>(strlen(modelname)+strlen(".petsc") +1); sprintf(petscfilename, "%s%s",modelname,".petsc");
     26        lockfilename   = xNew<char>(strlen(modelname)+strlen(".lock")  +1); sprintf(lockfilename,  "%s%s",modelname,".lock");
    2727
    2828        /*Clean up and assign output pointer*/
  • issm/trunk/src/c/solutions/ResetBoundaryConditions.cpp

    r11995 r12706  
    1515        int    i;
    1616
    17         _printf_(VerboseSolution(),"%s\n","   updating boundary conditions...");
     17        if(VerboseSolution()) _pprintLine_("   updating boundary conditions...");
    1818                       
    1919        /*set current analysis: */
  • issm/trunk/src/c/solutions/WriteLockFile.cpp

    r9320 r12706  
    1717        if(my_rank==0){
    1818                fid=fopen(filename,"w");
    19                 if(fid==NULL) _error_("%s%s","error message: could not open lock file ",filename);
     19                if(fid==NULL) _error2_("error message: could not open lock file " << filename);
    2020
    2121                /*Close file: */
    22                 if(fclose(fid)!=0) _error_("%s%s","could not close lock file ",filename);
     22                if(fclose(fid)!=0) _error2_("could not close lock file " << filename);
    2323        }
    2424
  • issm/trunk/src/c/solutions/adjointbalancethickness_core.cpp

    r11995 r12706  
    2222
    2323        /*compute thickness */
    24         _printf_(VerboseSolution(),"%s\n","   computing thickness");
     24        if(VerboseSolution()) _pprintLine_("   computing thickness");
    2525        femmodel->SetCurrentConfiguration(BalancethicknessAnalysisEnum);
    2626        solver_linear(femmodel);
     
    3030
    3131        /*compute adjoint*/
    32         _printf_(VerboseSolution(),"%s\n","   computing adjoint");
     32        if(VerboseSolution()) _pprintLine_("   computing adjoint");
    3333        femmodel->SetCurrentConfiguration(BalancethicknessAnalysisEnum,AdjointBalancethicknessAnalysisEnum);
    3434        solver_adjoint_linear(femmodel);
     
    3636        /*Save results*/
    3737        if(save_results){
    38                 _printf_(VerboseSolution(),"   saving results\n");
     38                if(VerboseSolution()) _pprintLine_("   saving results");
    3939                InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,AdjointEnum);
    4040        }
  • issm/trunk/src/c/solutions/adjointdiagnostic_core.cpp

    r11995 r12706  
    2525
    2626        /*Compute velocities*/
    27         _printf_(VerboseSolution(),"%s\n","   computing velocities");
     27        if(VerboseSolution()) _pprintLine_("   computing velocities");
    2828        femmodel->SetCurrentConfiguration(DiagnosticHorizAnalysisEnum);
    2929        solver_nonlinear(femmodel,conserve_loads);
     
    3333
    3434        /*Compute adjoint*/
    35         _printf_(VerboseSolution(),"%s\n","   computing adjoint");
     35        if(VerboseSolution()) _pprintLine_("   computing adjoint");
    3636        femmodel->SetCurrentConfiguration(DiagnosticHorizAnalysisEnum,AdjointHorizAnalysisEnum);
    3737        solver_adjoint_linear(femmodel);
     
    3939        /*Save results*/
    4040        if(save_results){
    41                 _printf_(VerboseSolution(),"   saving results\n");
     41                if(VerboseSolution()) _pprintLine_("   saving results");
    4242                InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,AdjointxEnum);
    4343                InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,AdjointyEnum);
  • issm/trunk/src/c/solutions/balancethickness_core.cpp

    r11995 r12706  
    2424        femmodel->parameters->FindParam(&save_results,SaveResultsEnum);
    2525
    26         _printf_(VerboseSolution(),"call computational core:\n");
     26        if(VerboseSolution()) _pprintLine_("call computational core:");
    2727        solver_linear(femmodel);
    2828
    2929        if(save_results){
    30                 _printf_(VerboseSolution(),"   saving results\n");
     30                if(VerboseSolution()) _pprintLine_("   saving results");
    3131                InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,ThicknessEnum);
    3232        }
  • issm/trunk/src/c/solutions/bedslope_core.cpp

    r11995 r12706  
    1919        femmodel->parameters->FindParam(&save_results,SaveResultsEnum);
    2020
    21         _printf_(VerboseSolution(),"%s\n","   computing slope");
     21        if(VerboseSolution()) _pprintLine_("   computing slope");
    2222
    2323        /*Call on core computations: */
     
    2828       
    2929        if(save_results){
    30                 _printf_(VerboseSolution(),"   saving results\n");
     30                if(VerboseSolution()) _pprintLine_("   saving results");
    3131                InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,BedSlopeXEnum);
    3232                InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,BedSlopeYEnum);
  • issm/trunk/src/c/solutions/control_core.cpp

    r11995 r12706  
    2020        int     num_controls,num_responses;
    2121        int     nsteps;
    22         double  tol_cm;
     22        IssmDouble  tol_cm;
    2323        bool    cm_gradient;
    2424        int     dim;
     
    2828
    2929        int*    control_type = NULL;
    30         double* responses=NULL;
     30        IssmDouble* responses=NULL;
    3131        int*    step_responses=NULL;
    32         double* maxiter=NULL;
    33         double* cm_jump=NULL;
     32        IssmDouble* maxiter=NULL;
     33        IssmDouble* cm_jump=NULL;
    3434               
    3535        /*intermediary: */
    36         double  search_scalar=1;
     36        IssmDouble  search_scalar=1;
    3737        OptArgs optargs;
    3838        OptPars optpars;
     
    4343
    4444        /*output: */
    45         double* J=NULL;
     45        IssmDouble* J=NULL;
    4646
    4747        /*Recover parameters used throughout the solution*/
     
    6666
    6767        /*Launch once a complete solution to set up all inputs*/
    68         _printf_(VerboseControl(),"%s\n","   preparing initial solution");
     68        if(VerboseControl()) _pprintLine_("   preparing initial solution");
    6969        if(isstokes) solutioncore(femmodel);
    7070
    7171        /*Initialize responses: */
    72         J=(double*)xmalloc(nsteps*sizeof(double));
    73         step_responses=(int*)xmalloc(num_responses*sizeof(int));
     72        J=xNew<IssmDouble>(nsteps);
     73        step_responses=xNew<int>(num_responses);
    7474               
    7575        /*Initialize some of the BrentSearch arguments: */
     
    8181
    8282                /*Display info*/
    83                 _printf_(VerboseControl(),"\n%s%i%s%i\n","   control method step ",n+1,"/",nsteps);
     83                if(VerboseControl()) _pprintLine_("\n" << "   control method step " << n+1 << "/" << nsteps);
    8484                for(i=0;i<num_responses;i++) step_responses[i]=(int)responses[n*num_responses+i];
    8585                femmodel->parameters->SetParam(step_responses,1,num_responses,StepResponsesEnum);
     
    8888                if(solution_type==SteadystateSolutionEnum) solutioncore(femmodel);
    8989
    90                 _printf_(VerboseControl(),"%s\n","   compute adjoint state:");
     90                if(VerboseControl()) _pprintLine_("   compute adjoint state:");
    9191                adjointcore(femmodel);
    9292                gradient_core(femmodel,n,search_scalar==0);
     
    9898                }
    9999
    100                 _printf_(VerboseControl(),"%s\n","   optimizing along gradient direction");
     100                if(VerboseControl()) _pprintLine_("   optimizing along gradient direction");
    101101                optpars.maxiter=(int)maxiter[n]; optpars.cm_jump=cm_jump[n];
    102102                BrentSearch(&search_scalar,J+n,&optpars,&objectivefunction,&optargs);
    103103
    104                 _printf_(VerboseControl(),"%s\n","   updating parameter using optimized search scalar"); //true means update save controls
     104                if(VerboseControl()) _pprintLine_("   updating parameter using optimized search scalar"); //true means update save controls
    105105                InputControlUpdatex(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,search_scalar,true);
    106106               
     
    108108        }
    109109
    110         _printf_(VerboseControl(),"%s\n","   preparing final solution");
     110        if(VerboseControl()) _pprintLine_("   preparing final solution");
    111111        femmodel->parameters->SetParam(true,SaveResultsEnum);
    112112        solutioncore(femmodel);
     
    120120        cleanup_and_return:
    121121        /*Free ressources: */
    122         xfree((void**)&control_type);
    123         xfree((void**)&responses);
    124         xfree((void**)&step_responses);
    125         xfree((void**)&maxiter);
    126         xfree((void**)&cm_jump);
    127         xfree((void**)&J);
     122        xDelete<int>(control_type);
     123        xDelete<int>(step_responses);
     124        xDelete<IssmDouble>(maxiter);
     125        xDelete<IssmDouble>(responses);
     126        xDelete<IssmDouble>(cm_jump);
     127        xDelete<IssmDouble>(J);
    128128}
  • issm/trunk/src/c/solutions/controlconvergence.cpp

    r10197 r12706  
    1717#include "./solutions.h"
    1818
    19 bool controlconvergence(double J, double tol_cm){
     19bool controlconvergence(IssmDouble J, IssmDouble tol_cm){
    2020
    2121        int i;
     
    2323
    2424        /*Has convergence been reached?*/
    25         if (!isnan(tol_cm) && J<tol_cm){
     25        if (!xIsNan<IssmDouble>(tol_cm) && J<tol_cm){
    2626                converged=true;
    27                 _printf_(VerboseConvergence(),"      Convergence criterion reached: J = %g < %g",J,tol_cm);
     27                if(VerboseConvergence()) _pprintString_("      Convergence criterion reached: J = " << J << " < " << tol_cm);
    2828        }
    2929
  • issm/trunk/src/c/solutions/controlrestart.cpp

    r11995 r12706  
    77#include "../EnumDefinitions/EnumDefinitions.h"
    88
    9 void controlrestart(FemModel* femmodel,double* J){
     9void controlrestart(FemModel* femmodel,IssmDouble* J){
    1010
    1111        int      num_controls;
     
    3333
    3434        /*Clean up and return*/
    35         xfree((void**)&control_type);
     35        xDelete<int>(control_type);
    3636}
  • issm/trunk/src/c/solutions/controltao_core.cpp

    r11995 r12706  
    1717
    1818/*Local prototype*/
    19 int FormFunctionGradient(TaoSolver,Vec,double*,Vec,void*);
     19int FormFunctionGradient(TaoSolver,Vec,IssmDouble*,Vec,void*);
    2020int IssmMonitor(TaoSolver,void*);
    2121typedef struct {
     
    3030        int        nsteps,maxiter;
    3131        AppCtx     user;
    32         TaoSolver  tao;
    33         double    *dummy          = NULL;
     32        TaoSolver  tao = 0;
     33        IssmDouble    *dummy          = NULL;
    3434        int       *control_list   = NULL;
    3535        Vector    *X              = NULL;
     
    4141        PetscGetArgs(&argc,&args);
    4242        ierr = TaoInitialize(&argc,&args,(char*)0,"");
    43         if(ierr) _error_("Could not initialize Tao");
     43        if(ierr) _error2_("Could not initialize Tao");
    4444
    4545        /*Recover some parameters*/
     
    5050        femmodel->parameters->FindParam(&dummy,NULL,NULL,InversionMaxiterPerStepEnum);
    5151        femmodel->parameters->SetParam(false,SaveResultsEnum);
    52         maxiter=nsteps*(int)dummy[0]; xfree((void**)&dummy);
     52        maxiter=nsteps*(int)dummy[0]; xDelete<IssmDouble>(dummy);
    5353
    5454        /*Initialize TAO*/
    55         _printf_(VerboseControl(),"%s\n","   Initializing the Toolkit for Advanced Optimization (TAO)");
    5655        TaoCreate(PETSC_COMM_WORLD,&tao);
     56        if(VerboseControl()) _pprintLine_("   Initializing the Toolkit for Advanced Optimization (TAO)");
    5757        TaoSetFromOptions(tao);
    5858        TaoSetType(tao,"tao_blmvm");
     
    7878
    7979        /*Solver optimization problem*/
    80         _printf_(VerboseControl(),"%s\n","   Starting optimization");
     80        if(VerboseControl()) _pprintLine_("   Starting optimization");
    8181        TaoSolve(tao);
    8282        TaoView(tao,PETSC_VIEWER_STDOUT_WORLD);
     
    8888
    8989        /*Finalize*/
    90         _printf_(VerboseControl(),"%s\n","   preparing final solution");
     90        if(VerboseControl()) _pprintLine_("   preparing final solution");
    9191        femmodel->parameters->SetParam(true,SaveResultsEnum);
    9292        void (*solutioncore)(FemModel*)=NULL;
     
    9595
    9696        /*Clean up and return*/
    97         xfree((void**)&control_list);
     97        xDelete<int>(control_list);
    9898        xdelete(&X);
    9999        TaoDestroy(&tao);
    100100        TaoFinalize();
    101101}
    102 int FormFunctionGradient(TaoSolver tao, Vec Xpetsc, double *fcn,Vec G,void *userCtx){
     102int FormFunctionGradient(TaoSolver tao, Vec Xpetsc, IssmDouble *fcn,Vec G,void *userCtx){
    103103
    104104        /*Retreive arguments*/
     
    107107        FemModel *femmodel       = user->femmodel;
    108108        int      *cost_functions = NULL;
    109         double   *cost_functionsd= NULL;
     109        IssmDouble   *cost_functionsd= NULL;
    110110        Vector   *gradient       = NULL;
    111111        Vector   *X              = NULL;
     
    125125
    126126        /*Prepare objective function*/
    127         cost_functions=(int*)xmalloc(num_cost_functions*sizeof(int));
     127        cost_functions=xNew<int>(num_cost_functions);
    128128        for(int i=0;i<num_cost_functions;i++) cost_functions[i]=(int)cost_functionsd[i]; //FIXME
    129129        femmodel->parameters->SetParam(cost_functions,1,num_cost_functions,StepResponsesEnum);
     
    146146
    147147        /*Clean-up and return*/
    148         xfree((void**)&cost_functions);
    149         xfree((void**)&cost_functionsd);
     148        xDelete<int>(cost_functions);
     149        xDelete<IssmDouble>(cost_functionsd);
    150150        return 0;
    151151}
     
    153153
    154154        int       i,its,num_responses;
    155         double    f,gnorm,cnorm,xdiff;
     155        IssmDouble    f,gnorm,cnorm,xdiff;
    156156        AppCtx   *user      = (AppCtx *)userCtx;
    157157        FemModel *femmodel  = user->femmodel;
     
    163163
    164164        TaoGetSolutionStatus(tao, &its, &f, &gnorm, &cnorm, &xdiff, NULL);
    165         if(its==0) _printf_(true,"Iter       Function      Residual  |  List of contributions\n");
    166         if(its==0) _printf_(true,"-----------------------------------+-----------------------\n");
    167         _printf_(true,"%4i   %12.7g  %12.7g  | ",its,f,gnorm);
     165        if(its==0) _pprintLine_("Iter       Function      Residual  |  List of contributions");
     166        if(its==0) _pprintLine_("-----------------------------------+-----------------------");
     167        _pprintString_(setw(4)<<its<<"   "<<setw(12)<<setprecision(7)<<f<<"  "<<setw(12)<<setprecision(7)<<gnorm<<"  | ");
    168168
    169169        /*Retrieve objective functions independently*/
    170170        for(i=0;i<num_responses;i++){
    171171                Responsex(&f,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,EnumToStringx(responses[i]),false,i);
    172                 _printf_(true," %12.7g ","",f);
     172                _pprintString_(" "<<setw(12)<<setprecision(7)<<f);
    173173        }
    174         _printf_(true,"\n");
     174        _pprintLine_("");
    175175
    176176        /*Clean-up and return*/
    177         xfree((void**)&responses);
     177        xDelete<int>(responses);
    178178        return 0;
    179179}
     
    181181#else
    182182void controltao_core(FemModel* femmodel){
    183         _error_("TAO not installed or PETSc version not supported");
     183        _error2_("TAO not installed or PETSc version not supported");
    184184}
    185185#endif //_HAVE_TAO_
  • issm/trunk/src/c/solutions/convergence.cpp

    r11995 r12706  
    1919        Vector* KUoldF=NULL;
    2020        Vector* duf=NULL;
    21         double ndu,nduinf,nu;
    22         double nKUF;
    23         double nKUoldF;
    24         double nF;
    25         double solver_residue,res;
     21        IssmDouble ndu,nduinf,nu;
     22        IssmDouble nKUF;
     23        IssmDouble nKUoldF;
     24        IssmDouble nF;
     25        IssmDouble solver_residue,res;
    2626
    2727        /*convergence options*/
    28         double eps_res;
    29         double eps_rel;
    30         double eps_abs;
    31         double yts;
     28        IssmDouble eps_res;
     29        IssmDouble eps_rel;
     30        IssmDouble eps_abs;
     31        IssmDouble yts;
    3232
    3333        /*If uf is NULL in input, f-set is nil, model is fully constrained, therefore converged from
     
    5555                nF=pf->Norm(NORM_TWO);
    5656                solver_residue=nKUF/nF;
    57                 _printf_(true,"\n%s%g\n","   solver residue: norm(KU-F)/norm(F)=",solver_residue);
     57                _pprintLine_("\n" << "   solver residue: norm(KU-F)/norm(F)=" << solver_residue);
    5858
    5959                //clean up
     
    7070        nF=pf->Norm(NORM_TWO);
    7171        res=nKUoldF/nF;
    72         if (isnan(res)){
    73                 _printf_(true,"norm nf = %lf and norm kuold = %lf\n",nF,nKUoldF);
    74                 _error_("mechanical equilibrium convergence criterion is NaN!");
     72        if (xIsNan<IssmDouble>(res)){
     73                _pprintLine_("norm nf = " << nF << "f and norm kuold = " << nKUoldF << "f");
     74                _error2_("mechanical equilibrium convergence criterion is NaN!");
    7575        }
    7676
     
    8181        //print
    8282        if(res<eps_res){
    83                 _printf_(VerboseConvergence(),"%-50s%g%s%g%s\n","   mechanical equilibrium convergence criterion",res*100," < ",eps_res*100," %");
     83                if(VerboseConvergence()) _pprintLine_(setw(50) << left << "   mechanical equilibrium convergence criterion" << res*100 << " < " << eps_res*100 << " %");
    8484                converged=true;
    8585        }
    8686        else{
    87                 _printf_(VerboseConvergence(),"%-50s%g%s%g%s\n","   mechanical equilibrium convergence criterion",res*100," > ",eps_res*100," %");
     87                if(VerboseConvergence()) _pprintLine_(setw(50) << left << "   mechanical equilibrium convergence criterion" << res*100 << " > " << eps_res*100 << " %");
    8888                converged=false;
    8989        }
    9090
    9191        /*Relative criterion (optional)*/
    92         if (!isnan(eps_rel) || (VerboseConvergence())){
     92        if (!xIsNan<IssmDouble>(eps_rel) || (VerboseConvergence())){
    9393
    9494                //compute norm(du)/norm(u)
     
    9696                ndu=duf->Norm(NORM_TWO); nu=old_uf->Norm(NORM_TWO);
    9797
    98                 if (isnan(ndu) || isnan(nu)) _error_("convergence criterion is NaN!");
     98                if (xIsNan<IssmDouble>(ndu) || xIsNan<IssmDouble>(nu)) _error2_("convergence criterion is NaN!");
    9999
    100100                //clean up
     
    102102
    103103                //print
    104                 if (!isnan(eps_rel)){
     104                if (!xIsNan<IssmDouble>(eps_rel)){
    105105                        if((ndu/nu)<eps_rel){
    106                                 _printf_(VerboseConvergence(),"%-50s%g%s%g%s\n","   Convergence criterion: norm(du)/norm(u)",ndu/nu*100," < ",eps_rel*100," %");
     106                                if(VerboseConvergence()) _pprintLine_(setw(50) << left << "   Convergence criterion: norm(du)/norm(u)" << ndu/nu*100 << " < " << eps_rel*100 << " %");
    107107                        }
    108108                        else{
    109                                 _printf_(VerboseConvergence(),"%-50s%g%s%g%s\n","   Convergence criterion: norm(du)/norm(u)",ndu/nu*100," > ",eps_rel*100," %");
     109                                if(VerboseConvergence()) _pprintLine_(setw(50) << left << "   Convergence criterion: norm(du)/norm(u)" << ndu/nu*100 << " > " << eps_rel*100 << " %");
    110110                                converged=false;
    111111                        }
    112112                }
    113                 else _printf_(true,"%-50s%g%s\n","   Convergence criterion: norm(du)/norm(u)",ndu/nu*100," %");
     113                else _pprintLine_(setw(50) << left << "   Convergence criterion: norm(du)/norm(u)" << ndu/nu*100 << " %");
    114114
    115115        }
    116116
    117117        /*Absolute criterion (Optional) = max(du)*/
    118         if (!isnan(eps_abs) || (VerboseConvergence())){
     118        if (!xIsNan<IssmDouble>(eps_abs) || (VerboseConvergence())){
    119119
    120120                //compute max(du)
    121121                duf=old_uf->Duplicate(); old_uf->Copy(duf); duf->AYPX(uf,-1.0);
    122122                ndu=duf->Norm(NORM_TWO); nduinf=duf->Norm(NORM_INF);
    123                 if (isnan(ndu) || isnan(nu)) _error_("convergence criterion is NaN!");
     123                if (xIsNan<IssmDouble>(ndu) || xIsNan<IssmDouble>(nu)) _error2_("convergence criterion is NaN!");
    124124
    125125                //clean up
     
    127127
    128128                //print
    129                 if (!isnan(eps_abs)){
     129                if (!xIsNan<IssmDouble>(eps_abs)){
    130130                        if ((nduinf*yts)<eps_abs){
    131                                 _printf_(VerboseConvergence(),"%-50s%g%s%g%s\n","   Convergence criterion: max(du)",nduinf*yts," < ",eps_abs," m/yr");
     131                                if(VerboseConvergence()) _pprintLine_(setw(50) << left << "   Convergence criterion: max(du)" << nduinf*yts << " < " << eps_abs << " m/yr");
    132132                        }
    133133                        else{
    134                                 _printf_(VerboseConvergence(),"%-50s%g%s%g%s\n","   Convergence criterion: max(du)",nduinf*yts," > ",eps_abs," m/yr");
     134                                if(VerboseConvergence()) _pprintLine_(setw(50) << left << "   Convergence criterion: max(du)" << nduinf*yts << " > " << eps_abs << " m/yr");
    135135                                converged=false;
    136136                        }
    137137                }
    138                 else  _printf_(true,"%-50s%g%s\n","   Convergence criterion: max(du)",nduinf*yts," m/yr");
     138                else  _pprintLine_(setw(50) << left << "   Convergence criterion: max(du)" << nduinf*yts << " m/yr");
    139139
    140140        }
  • issm/trunk/src/c/solutions/diagnostic_core.cpp

    r11995 r12706  
    5959        if(ishutter){
    6060                       
    61                 _printf_(VerboseSolution(),"%s\n","   computing hutter velocities");
     61                if(VerboseSolution()) _pprintLine_("   computing hutter velocities");
    6262
    6363                //Take the last velocity into account so that the velocity on the MacAyeal domain is not zero
     
    7272        if (ismacayealpattyn ^ isstokes){ // ^ = xor
    7373               
    74                 _printf_(VerboseSolution(),"%s\n","   computing velocities");
     74                if(VerboseSolution()) _pprintLine_("   computing velocities");
    7575                femmodel->SetCurrentConfiguration(DiagnosticHorizAnalysisEnum);
    7676                if(isnewton)
     
    8282        if (ismacayealpattyn && isstokes){
    8383
    84                 _printf_(VerboseSolution(),"%s\n","   computing coupling macayealpattyn and stokes velocities and pressure ");
     84                if(VerboseSolution()) _pprintLine_("   computing coupling macayealpattyn and stokes velocities and pressure ");
    8585                solver_stokescoupling_nonlinear(femmodel,conserve_loads);
    8686        }
     
    8888        if (dim==3 & (ishutter || ismacayealpattyn)){
    8989
    90                 _printf_(VerboseSolution(),"%s\n","   computing vertical velocities");
     90                if(VerboseSolution()) _pprintLine_("   computing vertical velocities");
    9191                femmodel->SetCurrentConfiguration(DiagnosticVertAnalysisEnum);
    9292                solver_linear(femmodel);
     
    9595
    9696        if(save_results){
    97                 _printf_(VerboseSolution(),"   saving results\n");
     97                if(VerboseSolution()) _pprintLine_("   saving results");
    9898                InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VxEnum);
    9999                InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VyEnum);
     
    105105
    106106        /*Free ressources:*/
    107         xfree((void**)&requested_outputs);
     107        xDelete<int>(requested_outputs);
    108108}
  • issm/trunk/src/c/solutions/enthalpy_core.cpp

    r11995 r12706  
    2121        femmodel->parameters->FindParam(&save_results,SaveResultsEnum);
    2222
    23         _printf_(VerboseSolution(),"   computing enthalpy\n");
     23        if(VerboseSolution()) _pprintLine_("   computing enthalpy");
    2424        femmodel->SetCurrentConfiguration(EnthalpyAnalysisEnum);
    2525        solver_nonlinear(femmodel,true);
     
    2929
    3030        if(save_results){
    31                 _printf_(VerboseSolution(),"   saving results\n");
     31                if(VerboseSolution()) _pprintLine_("   saving results");
    3232                InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,TemperatureEnum);
    3333                InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,EnthalpyEnum);
  • issm/trunk/src/c/solutions/gradient_core.cpp

    r11995 r12706  
    1616
    1717        /*Intermediaries*/
    18         double  norm_inf;
    19         double *norm_list    = NULL;
     18        IssmDouble  norm_inf;
     19        IssmDouble *norm_list    = NULL;
    2020        Vector*     new_gradient = NULL;
    2121        Vector*     gradient     = NULL;
     
    2323
    2424        /*Compute gradient*/
    25         _printf_(VerboseControl(),"   compute cost function gradient\n");
     25        if(VerboseControl()) _pprintLine_("   compute cost function gradient");
    2626        Gradjx(&gradient,&norm_list,femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters);
    2727
    2828        if (orthogonalize){
    29                 _printf_(VerboseControl(),"   orthogonalization\n");
     29                if(VerboseControl()) _pprintLine_("   orthogonalization");
    3030                ControlInputGetGradientx(&old_gradient,femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters);
    3131                Orthx(&new_gradient,gradient,old_gradient); xdelete(&old_gradient); xdelete(&gradient);
     
    3737        /*Check that gradient is clean*/
    3838        norm_inf=new_gradient->Norm(NORM_INF);
    39         if(norm_inf<=0)    _error_("||∂J/∂α||∞ = 0    gradient norm is zero");
    40         if(isnan(norm_inf))_error_("||∂J/∂α||∞ = NaN  gradient norm is NaN");
     39        if(norm_inf<=0)    _error2_("||∂J/∂α||∞ = 0    gradient norm is zero");
     40        if(xIsNan<IssmDouble>(norm_inf))_error2_("||∂J/∂α||∞ = NaN  gradient norm is NaN");
    4141
    4242        /*plug back into inputs: */
     
    4848
    4949        /*Clean up and return*/
    50         xfree((void**)&norm_list);
     50        xDelete<IssmDouble>(norm_list);
    5151}
  • issm/trunk/src/c/solutions/hydrology_core.cpp

    r11995 r12706  
    1717
    1818        /*intermediary*/
    19         double time;
     19        IssmDouble time;
    2020        int    nsteps;
    21         double starttime,final_time;
    22         double dt;
     21        IssmDouble starttime,final_time;
     22        IssmDouble dt;
    2323        bool   save_results;
    2424        int    output_frequency;
     
    4545        for(i=0;i<nsteps;i++){
    4646               
    47                 if(nsteps)_printf_(VerboseSolution(),"time step:%i/%i\n",i+1,nsteps);
     47                if(nsteps)if(VerboseSolution()) _pprintLine_("time step:" << i+1 << "/" << nsteps);
    4848                time+=dt;
    4949                femmodel->parameters->SetParam(time,TimeEnum);
     
    5353
    5454                if(save_results && ((i+1)%output_frequency==0 || (i+1)==nsteps)){
    55                         _printf_(VerboseSolution(),"   saving results \n");
     55                        if(VerboseSolution()) _pprintLine_("   saving results ");
    5656                        //InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,WatercolumnEnum,i+1,time);
    5757                        //InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,HydrologyWaterVxEnum,i+1,time);
     
    5959                       
    6060                        /*unload results*/
    61                         _printf_(VerboseSolution(),"   saving temporary results\n");
     61                        if(VerboseSolution()) _pprintLine_("   saving temporary results");
    6262                        OutputResultsx(femmodel->elements, femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,femmodel->results);
    6363                }
  • issm/trunk/src/c/solutions/hydrology_core_step.cpp

    r9761 r12706  
    1313#include "../solvers/solvers.h"
    1414
    15 void hydrology_core_step(FemModel* femmodel,int step, double time){
     15void hydrology_core_step(FemModel* femmodel,int step, IssmDouble time){
    1616       
    1717        bool modify_loads=true;
    1818
    19         _printf_(VerboseSolution(),"   computing water column\n");
     19        if(VerboseSolution()) _pprintLine_("   computing water column");
    2020        femmodel->SetCurrentConfiguration(HydrologyAnalysisEnum);
    2121        solver_nonlinear(femmodel,modify_loads);
  • issm/trunk/src/c/solutions/issm.cpp

    r12330 r12706  
    3030
    3131        /*time*/
    32         double   start, finish;
    33         double   start_core, finish_core;
    34         double   start_init, finish_init;
     32        IssmPDouble   start, finish;
     33        IssmPDouble   start_core, finish_core;
     34        IssmPDouble   start_init, finish_init;
    3535        int      ierr;
     36
     37        /*profiling*/   
     38        bool profiling = false;
     39        IssmPDouble Time_start, Flops_start;
     40        IssmPDouble Solution_time, Memory_use, Current_flops;
    3641
    3742        ISSMBOOT();
     
    4045        #ifdef _HAVE_PETSC_
    4146        ierr=PetscInitialize(&argc,&argv,(char*)0,""); 
    42         if(ierr) _error_("Could not initialize Petsc");
     47        if(ierr) _error2_("Could not initialize Petsc");
    4348        #else
    4449        #ifdef _HAVE_MPI_
     
    5055        MPI_Barrier(MPI_COMM_WORLD); start=MPI_Wtime();
    5156        #else
    52         start=(double)clock();
     57        start=(IssmPDouble)clock();
    5358        #endif
    5459
     
    6065
    6166        /*First process inputs*/
    62         _printf_(true,"\n");
    63         _printf_(true,"Ice Sheet System Model (%s) version %s\n",PACKAGE_NAME,PACKAGE_VERSION);
    64         _printf_(true,"(website: %s contact: %s)\n",PACKAGE_URL,PACKAGE_BUGREPORT);
    65         _printf_(true,"\n");
     67        _pprintLine_("");
     68        _pprintLine_("Ice Sheet System Model (" << PACKAGE_NAME << ") version " << PACKAGE_VERSION);
     69        _pprintLine_("(website: " << PACKAGE_URL << " contact: " << PACKAGE_BUGREPORT << ")");
     70        _pprintLine_("");
    6671        ProcessArguments(&solution_type,&binfilename,&outbinfilename,&petscfilename,&lockfilename,argc,argv);
    6772
     
    7378        MPI_Barrier(MPI_COMM_WORLD); start_init=MPI_Wtime();
    7479        #else
    75         start_init=(double)clock();
     80        start_init=(IssmPDouble)clock();
    7681        #endif
    7782        femmodel=new FemModel(binfilename,outbinfilename,solution_type,analyses,numanalyses);
     
    9499        femmodel->parameters->FindParam(&control_analysis,InversionIscontrolEnum);
    95100        femmodel->parameters->FindParam(&tao_analysis,InversionTaoEnum);
     101        femmodel->parameters->FindParam(&profiling,DebugProfilingEnum);
     102
    96103        #ifdef _HAVE_MPI_
    97104        MPI_Barrier(MPI_COMM_WORLD); finish_init=MPI_Wtime();
    98105        #else
    99         finish_init=(double)clock();
    100         #endif
    101 
    102         _printf_(true,"call computational core:\n");
     106        finish_init=(IssmPDouble)clock();
     107        #endif
     108
     109        _pprintLine_("call computational core:");
    103110        #ifdef _HAVE_MPI_
    104111        MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( );
    105112        #else
    106         start_core=(double)clock();
    107         #endif
    108        
     113        start_core=(IssmPDouble)clock();
     114        #endif
     115       
     116        if(profiling)ProfilingStart(&Time_start,&Flops_start);
     117
    109118        if(dakota_analysis){
    110119                #ifdef _HAVE_DAKOTA_
    111120                Dakotax(femmodel);
    112121                #else
    113                 _error_("ISSM was not compiled with dakota support, cannot carry out dakota analysis!");
     122                _error2_("ISSM was not compiled with dakota support, cannot carry out dakota analysis!");
    114123                #endif
    115124        }
     
    121130                 control_core(femmodel);
    122131                #else
    123                 _error_("ISSM was not compiled with control support, cannot carry out dakota analysis!");
     132                _error2_("ISSM was not compiled with control support, cannot carry out dakota analysis!");
    124133                #endif
    125134        }
     
    127136                solutioncore(femmodel);
    128137        }
     138
     139        if(profiling){
     140                ProfilingEnd(&Solution_time,&Memory_use,&Current_flops,Time_start,Flops_start);
     141                femmodel->results->AddObject(new DoubleExternalResult(femmodel->results->Size()+1, ProfilingSolutionTimeEnum, Solution_time, 1, 0));
     142                femmodel->results->AddObject(new DoubleExternalResult(femmodel->results->Size()+1, ProfilingCurrentMemEnum, Memory_use, 1, 0));
     143                femmodel->results->AddObject(new DoubleExternalResult(femmodel->results->Size()+1, ProfilingCurrentFlopsEnum, Current_flops, 1, 0));
     144        }
     145
     146
    129147        #ifdef _HAVE_MPI_
    130148        MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( );
    131149        #else
    132         finish_core=(double)clock();
    133         #endif
    134        
    135         _printf_(true,"write results to disk:\n");
     150        finish_core=(IssmPDouble)clock();
     151        #endif
     152
     153        _pprintLine_("write results to disk:");
    136154        OutputResultsx(femmodel->elements, femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,femmodel->results);
    137155
     
    139157        pfclose(output_fid,lockfilename);
    140158        if (waitonlock>0){
    141                 _printf_(true,"write lock file:\n");
     159                _pprintLine_("write lock file:");
    142160                WriteLockFile(lockfilename);
    143161        }
    144162
    145         /*Free ressources */
    146         xfree((void**)&analyses);
    147         xfree((void**)&lockfilename);
    148         xfree((void**)&binfilename);
    149         xfree((void**)&outbinfilename);
    150         xfree((void**)&petscfilename);
     163        /*Free resources */
     164        xDelete<int>(analyses);
     165        xDelete<char>(lockfilename);
     166        xDelete<char>(binfilename);
     167        xDelete<char>(outbinfilename);
     168        xDelete<char>(petscfilename);
    151169        delete femmodel;
    152170
     
    154172        #ifdef _HAVE_MPI_
    155173        MPI_Barrier(MPI_COMM_WORLD); finish = MPI_Wtime( );
    156         _printf_(true,"\n   %-34s %f seconds  \n","FemModel initialization elapsed time:",finish_init-start_init);
    157         _printf_(true,"   %-34s %f seconds  \n","Core solution elapsed time:",finish_core-start_core);
    158         _printf_(true,"\n   %s %i hrs %i min %i sec\n\n","Total elapsed time:",int((finish-start)/3600),int(int(finish-start)%3600/60),int(finish-start)%60);
    159         #else
    160         finish=(double)clock();
    161         _printf_(true,"\n   %-34s %f seconds  \n","FemModel initialization elapsed time:",(finish_init-start_init)/CLOCKS_PER_SEC);
    162         _printf_(true,"   %-34s %f seconds  \n","Core solution elapsed time:",(finish_core-start_core)/CLOCKS_PER_SEC);
    163         _printf_(true,"\n   %s %i hrs %i min %i sec\n\n","Total elapsed time:",int((finish-start)/3600/CLOCKS_PER_SEC),int(int((finish-start)/CLOCKS_PER_SEC)%3600/60),(int(finish-start)/CLOCKS_PER_SEC)%60);
    164         #endif
    165        
    166                
     174        _pprintLine_("");
     175        _pprintLine_("   "<<setw(40)<<left<<"FemModel initialization elapsed time:"<<finish_init-start_init);
     176        _pprintLine_("   "<<setw(40)<<left<<"Core solution elapsed time:"<<finish_core-start_core);
     177        _pprintLine_("");
     178        _pprintLine_("   Total elapsed time:"<<int((finish-start)/3600)<<" hrs "<<int(int(finish-start)%3600/60)<<" min "<<int(finish-start)%60<<" sec");
     179        _pprintLine_("");
     180        #else
     181        finish=(IssmPDouble)clock();
     182        _pprintLine_("");
     183        _pprintLine_("   "<<setw(40)<<left<<"FemModel initialization elapsed time:"<<(finish_init-start_init)/CLOCKS_PER_SEC);
     184        _pprintLine_("   "<<setw(40)<<left<<"Core solution elapsed time:"<<(finish_core-start_core)/CLOCKS_PER_SEC);
     185        _pprintLine_("");
     186        _pprintLine_("   Total elapsed time:"
     187                                <<int((finish-start)/CLOCKS_PER_SEC/3600)<<" hrs "
     188                                <<int(int(finish-start)/CLOCKS_PER_SEC%3600/60)<<" min "
     189                                <<int(finish-start)/CLOCKS_PER_SEC%60<<" sec");
     190        _pprintLine_("");
     191        #endif
    167192       
    168193        #ifdef _HAVE_PETSC_
    169         _printf_(true,"closing MPI and Petsc\n");
     194        _pprintLine_("closing MPI and Petsc");
    170195        PetscFinalize();
    171196        #else
    172197        #ifdef _HAVE_MPI_
    173         _printf_(true,"closing MPI and Petsc\n");
     198        _pprintLine_("closing MPI and Petsc");
    174199        MPI_Finalize();
    175200        #endif
  • issm/trunk/src/c/solutions/objectivefunction.cpp

    r11995 r12706  
    33 */
    44
    5 /*include files: {{{1*/
     5/*include files: {{{*/
    66#ifdef HAVE_CONFIG_H
    77        #include <config.h>
     
    2020/*}}}*/
    2121
    22 double objectivefunction(double search_scalar,OptArgs* optargs){
     22IssmDouble objectivefunction(IssmDouble search_scalar,OptArgs* optargs){
    2323
    2424        int i; 
    2525       
    2626        /*output: */
    27         double J;
     27        IssmDouble J;
    2828       
    2929        /*parameters: */
     
    4949        }
    5050        else{
    51                 _error_("Solution %s not implemented yet",EnumToStringx(solution_type));
     51                _error2_("Solution " << EnumToStringx(solution_type) << " not implemented yet");
    5252        }
    5353
     
    6666        }
    6767        else{
    68                 _error_("Solution %s not implemented yet",EnumToStringx(solution_type));
     68                _error2_("Solution " << EnumToStringx(solution_type) << " not implemented yet");
    6969        }
    7070
  • issm/trunk/src/c/solutions/prognostic_core.cpp

    r12293 r12706  
    1717        bool save_results;
    1818        bool ispdd;
     19        bool issmbgradients;
    1920
    2021        /*activate formulation: */
     
    2425        femmodel->parameters->FindParam(&save_results,SaveResultsEnum);
    2526        femmodel->parameters->FindParam(&ispdd,SurfaceforcingsIspddEnum);
     27        femmodel->parameters->FindParam(&issmbgradients,SurfaceforcingsIssmbgradientsEnum);
    2628
    2729        if(ispdd){
    28           _printf_(VerboseSolution(),"   call positive degree day module\n");
     30          if(VerboseSolution()) _pprintLine_("   call positive degree day module");
    2931          PositiveDegreeDayx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);
    30         }       
     32        }
    3133
    32         _printf_(VerboseSolution(),"   call computational core\n");
     34        if(issmbgradients){
     35          _printf_(VerboseSolution(),"  call smb gradients module\n");
     36          SmbGradientsx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);
     37        }
     38
     39        if(VerboseSolution()) _pprintLine_("   call computational core");
    3340        solver_linear(femmodel);
    3441       
    3542        if(save_results){
    36                 _printf_(VerboseSolution(),"   saving results\n");
     43                if(VerboseSolution()) _pprintLine_("   saving results");
    3744                InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,ThicknessEnum);
    3845        }
  • issm/trunk/src/c/solutions/solutions.h

    r11995 r12706  
    1818void diagnostic_core(FemModel* femmodel);
    1919void hydrology_core(FemModel* femmodel);
    20 void hydrology_core_step(FemModel* femmodel,int step, double time);
     20void hydrology_core_step(FemModel* femmodel,int step, IssmDouble time);
    2121void thermal_core(FemModel* femmodel);
    2222void enthalpy_core(FemModel* femmodel);
     
    3030void steadystate_core(FemModel* femmodel);
    3131void transient_core(FemModel* femmodel);
    32 double objectivefunction(double search_scalar,OptArgs* optargs);
     32IssmDouble objectivefunction(IssmDouble search_scalar,OptArgs* optargs);
    3333
    3434//convergence:
    3535void convergence(bool* pconverged, Matrix* K_ff,Vector* p_f,Vector* u_f,Vector* u_f_old,Parameters* parameters);
    36 bool controlconvergence(double J,double tol_cm);
     36bool controlconvergence(IssmDouble J,IssmDouble tol_cm);
    3737bool steadystateconvergence(FemModel* femmodel);
    3838
    3939//optimization
    40 int GradJSearch(double* search_vector,FemModel* femmodel,int step);
     40int GradJSearch(IssmDouble* search_vector,FemModel* femmodel,int step);
    4141
    4242//diverse
    4343void ProcessArguments(int* solution,char** pbinname,char** poutbinname,char** ppetscname,char** plockname,int argc,char **argv);
    4444void WriteLockFile(char* filename);
    45 void controlrestart(FemModel* femmodel,double* J);
     45void controlrestart(FemModel* femmodel,IssmDouble* J);
    4646void ResetBoundaryConditions(FemModel* femmodel, int analysis_type);
    4747
  • issm/trunk/src/c/solutions/steadystate_core.cpp

    r11995 r12706  
    99#endif
    1010
     11#include "../include/include.h"
    1112#include "../toolkits/toolkits.h"
    1213#include "../objects/objects.h"
     
    1617#include "./solutions.h"
    1718#include "../modules/modules.h"
    18 #include "../include/include.h"
    1919#include "../solvers/solvers.h"
    2020
     
    4343        for(;;){
    4444       
    45                 _printf_(VerboseSolution(),"%s%i\n","   computing temperature and velocity for step: ",step);
     45                if(VerboseSolution()) _pprintLine_("   computing temperature and velocity for step: " << step);
    4646                #ifdef _HAVE_THERMAL_
    4747                if(isenthalpy==0){
     
    5252                }
    5353                #else
    54                 _error_("ISSM was not compiled with thermal capabilities. Exiting");
     54                _error2_("ISSM was not compiled with thermal capabilities. Exiting");
    5555                #endif
    5656
    57                 _printf_(VerboseSolution(),"%s\n","   computing new velocity");
     57                if(VerboseSolution()) _pprintLine_("   computing new velocity");
    5858                diagnostic_core(femmodel);
    5959
    6060                if (step>1){
    61                         _printf_(VerboseSolution(),"%s\n","   checking velocity, temperature and pressure convergence");
     61                        if(VerboseSolution()) _pprintLine_("   checking velocity, temperature and pressure convergence");
    6262                        if(steadystateconvergence(femmodel)) break;
    6363                }
    6464                if(step>maxiter){
    65                         _printf_(VerboseSolution(),"%s%i%s\n","   maximum number steadystate iterations ",maxiter," reached");
     65                        if(VerboseSolution()) _pprintLine_("   maximum number steadystate iterations " << maxiter << " reached");
    6666                        break;
    6767                }
    6868               
    69                 _printf_(VerboseSolution(),"%s\n","   saving velocity, temperature and pressure to check for convergence at next step");
     69                if(VerboseSolution()) _pprintLine_("   saving velocity, temperature and pressure to check for convergence at next step");
    7070                InputDuplicatex(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VxEnum,VxPicardEnum);
    7171                InputDuplicatex(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VyEnum,VyPicardEnum);
     
    7979       
    8080        if(save_results){
    81                 _printf_(VerboseSolution(),"   saving results\n");
     81                if(VerboseSolution()) _pprintLine_("   saving results");
    8282                InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VxEnum);
    8383                InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VyEnum);
     
    9393
    9494        /*Free ressources:*/
    95         xfree((void**)&requested_outputs);
     95        xDelete<int>(requested_outputs);
    9696}
  • issm/trunk/src/c/solutions/steadystateconvergence.cpp

    r9677 r12706  
    2828        int temperatureenums[2]={TemperatureEnum,TemperatureOldEnum};
    2929        int convergencecriterion[1]={RelativeEnum}; //criterions for convergence, RelativeEnum or AbsoluteEnum
    30         double convergencecriterionvalue[1]; //value of criterion to be respected
     30        IssmDouble convergencecriterionvalue[1]; //value of criterion to be respected
    3131
    3232        /*retrieve parameters: */
  • issm/trunk/src/c/solutions/surfaceslope_core.cpp

    r11995 r12706  
    1919        femmodel->parameters->FindParam(&save_results,SaveResultsEnum);
    2020
    21         _printf_(VerboseSolution(),"%s\n","computing slope...");
     21        if(VerboseSolution()) _pprintLine_("computing slope...");
    2222
    2323        /*Call on core computations: */
     
    2828       
    2929        if(save_results){
    30                 _printf_(VerboseSolution(),"saving results:\n");
     30                if(VerboseSolution()) _pprintLine_("saving results:");
    3131                InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,SurfaceSlopeXEnum);
    3232                InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,SurfaceSlopeYEnum);
  • issm/trunk/src/c/solutions/thermal_core.cpp

    r11995 r12706  
    1616
    1717        /*intermediary*/
    18         double melting_offset;
     18        IssmDouble melting_offset;
    1919        bool   save_results;
    2020        bool   dakota_analysis  = false;
     
    2929        }
    3030
    31         _printf_(VerboseSolution(),"   computing temperatures\n");
     31        if(VerboseSolution()) _pprintLine_("   computing temperatures");
    3232        femmodel->SetCurrentConfiguration(ThermalAnalysisEnum);
    3333        solver_thermal_nonlinear(femmodel);
    3434
    35         _printf_(VerboseSolution(),"   computing melting\n");
     35        if(VerboseSolution()) _pprintLine_("   computing melting");
    3636        femmodel->SetCurrentConfiguration(MeltingAnalysisEnum);
    3737        solver_linear(femmodel);
    3838
    3939        if(save_results){
    40                 _printf_(VerboseSolution(),"   saving results\n");
     40                if(VerboseSolution()) _pprintLine_("   saving results");
    4141                InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,TemperatureEnum);
    4242                InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,BasalforcingsMeltingRateEnum);
  • issm/trunk/src/c/solutions/transient_core.cpp

    r11995 r12706  
    2323
    2424        /*parameters: */
    25         double starttime,finaltime,dt,yts;
     25        IssmDouble starttime,finaltime,dt,yts;
    2626        bool   isdiagnostic,isprognostic,isthermal,isgroundingline,isenthalpy;
    2727        bool   save_results,dakota_analysis;
     
    3434        /*intermediary: */
    3535        int    step;
    36         double time;
     36        IssmDouble time;
    3737
    3838        //first recover parameters common to all solutions
     
    8686                femmodel->parameters->SetParam(step,StepEnum);
    8787
    88                 _printf_(VerboseSolution(),"iteration %i/%g  time [yr]: %-7.3g (time step: %.2g)\n",step,floor((finaltime-time)/dt)+step,time/yts,dt/yts);
     88                if(VerboseSolution()) _pprintLine_("iteration " << step << "/" << floor((finaltime-time)/dt)+step << "  time [yr]: " << time/yts << " (time step: " << dt/yts << ")");
    8989                if(step%output_frequency==0 || time==finaltime)
    9090                 save_results=true;
     
    9494
    9595                if(isthermal && dim==3){
    96                         _printf_(VerboseSolution(),"   computing temperatures\n");
     96                        if(VerboseSolution()) _pprintLine_("   computing temperatures");
    9797                        #ifdef _HAVE_THERMAL_
    9898                        if(isenthalpy==0){
     
    103103                        }
    104104                        #else
    105                         _error_("ISSM was not compiled with thermal capabilities. Exiting");
     105                        _error2_("ISSM was not compiled with thermal capabilities. Exiting");
    106106                        #endif
    107107                }
    108108
    109109                if(isdiagnostic){
    110                         _printf_(VerboseSolution(),"   computing new velocity\n");
     110                        if(VerboseSolution()) _pprintLine_("   computing new velocity");
    111111                        #ifdef _HAVE_DIAGNOSTIC_
    112112                        diagnostic_core(femmodel);
    113113                        #else
    114                         _error_("ISSM was not compiled with diagnostic capabilities. Exiting");
     114                        _error2_("ISSM was not compiled with diagnostic capabilities. Exiting");
    115115                        #endif
    116116                }
    117117
    118118                if(isprognostic){
    119                         _printf_(VerboseSolution(),"   computing new thickness\n");
     119                        if(VerboseSolution()) _pprintLine_("   computing new thickness");
    120120                        prognostic_core(femmodel);
    121                         _printf_(VerboseSolution(),"   updating vertices positions\n");
     121                        if(VerboseSolution()) _pprintLine_("   updating vertices positions");
    122122                        UpdateVertexPositionsx(femmodel->elements, femmodel->nodes,femmodel->vertices,femmodel->loads, femmodel->materials, femmodel->parameters);
    123123                }
    124124
    125125                if(isgroundingline){
    126                         _printf_(VerboseSolution(),"   computing new grounding line position\n");
     126                        if(VerboseSolution()) _pprintLine_("   computing new grounding line position");
    127127                        #ifdef _HAVE_GROUNDINGLINE_
    128128                        GroundinglineMigrationx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);
    129129                        #else
    130                         _error_("ISSM was not compiled with grounding line migration capabilities. Exiting");
     130                        _error2_("ISSM was not compiled with grounding line migration capabilities. Exiting");
    131131                        #endif
    132132                }
     
    134134                /*unload results*/
    135135                if(save_results){
    136                         _printf_(VerboseSolution(),"   saving transient results\n");
     136                        if(VerboseSolution()) _pprintLine_("   saving transient results");
    137137                        InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,SurfaceEnum);
    138138                        InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,BedEnum);
     
    141141                        RequestedOutputsx(femmodel->results,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,requested_outputs,numoutputs);
    142142
    143                         _printf_(VerboseSolution(),"   saving temporary results\n");
     143                        if(VerboseSolution()) _pprintLine_("   saving temporary results");
    144144                        OutputResultsx(femmodel->elements, femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,femmodel->results);
    145145                }
     
    147147
    148148        /*Free ressources:*/
    149         xfree((void**)&requested_outputs);
     149        xDelete<int>(requested_outputs);
    150150}
  • issm/trunk/src/c/solvers/solver_newton.cpp

    r12330 r12706  
    1717        int    num_unstable_constraints;
    1818        int    count;
    19         double kmax;
     19        IssmDouble kmax;
    2020        Matrix* Kff = NULL;
    2121        Matrix* Kfs    = NULL;
     
    7070                        bool max_iteration_state=false;
    7171                        int tempStep=1;
    72                         double tempTime=1.0;
     72                        IssmDouble tempTime=1.0;
    7373                        femmodel->results->AddObject(new BoolExternalResult(femmodel->results->Size()+1, MaxIterationConvergenceFlagEnum, max_iteration_state, tempStep, tempTime));
    7474                        break;
    7575                }
    7676                if(count>=max_nonlinear_iterations){
    77                         _printf_(true,"   maximum number of Newton iterations (%i) exceeded\n",max_nonlinear_iterations);
     77                        _pprintLine_("   maximum number of Newton iterations (" << max_nonlinear_iterations << ") exceeded");
    7878                        bool max_iteration_state=true;
    7979                        int tempStep=1;
    80                         double tempTime=1.0;
     80                        IssmDouble tempTime=1.0;
    8181                        femmodel->results->AddObject(new BoolExternalResult(femmodel->results->Size()+1, MaxIterationConvergenceFlagEnum, max_iteration_state, tempStep, tempTime));
    8282                        break;
     
    100100        }
    101101
    102         _printf_(VerboseConvergence(),"\n   total number of iterations: %i\n",count-1);
     102        if(VerboseConvergence()) _pprintLine_("\n   total number of iterations: " << count-1);
    103103
    104104        /*clean-up*/
  • issm/trunk/src/c/solvers/solver_nonlinear.cpp

    r12330 r12706  
    7373
    7474                ConstraintsStatex(&constraints_converged, &num_unstable_constraints, femmodel->elements,femmodel->nodes,femmodel->vertices,loads,femmodel->materials,femmodel->parameters);
    75                 _printf_(VerboseConvergence(),"   number of unstable constraints: %i\n",num_unstable_constraints);
     75                if(VerboseConvergence()) _pprintLine_("   number of unstable constraints: " << num_unstable_constraints);
    7676
    7777                //rift convergence
     
    8888                        bool max_iteration_state=false;
    8989                        int tempStep=1;
    90                         double tempTime=1.0;
     90                        IssmDouble tempTime=1.0;
    9191                        femmodel->results->AddObject(new BoolExternalResult(femmodel->results->Size()+1, MaxIterationConvergenceFlagEnum, max_iteration_state, tempStep, tempTime));
    9292                        break;
    9393                }
    9494                if(count>=max_nonlinear_iterations){
    95                         _printf_(true,"   maximum number of nonlinear iterations (%i) exceeded\n",max_nonlinear_iterations);
     95                        _pprintLine_("   maximum number of nonlinear iterations (" << max_nonlinear_iterations << ") exceeded");
    9696                        converged=true;
    9797                        InputUpdateFromConstantx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,converged,ConvergedEnum);
     
    9999                        bool max_iteration_state=true;
    100100                        int tempStep=1;
    101                         double tempTime=1.0;
     101                        IssmDouble tempTime=1.0;
    102102                        femmodel->results->AddObject(new BoolExternalResult(femmodel->results->Size()+1, MaxIterationConvergenceFlagEnum, max_iteration_state, tempStep, tempTime));
    103103                        break;
     
    105105        }
    106106
    107         _printf_(VerboseConvergence(),"\n   total number of iterations: %i\n",count-1);
     107        if(VerboseConvergence()) _pprintLine_("\n   total number of iterations: " << count-1);
    108108
    109109        /*clean-up*/
  • issm/trunk/src/c/solvers/solver_stokescoupling_nonlinear.cpp

    r11995 r12706  
    9191                if(converged==true)break;
    9292                if(count>=max_nonlinear_iterations){
    93                         _printf_(true,"   maximum number of iterations (%i) exceeded\n",max_nonlinear_iterations);
     93                        _pprintLine_("   maximum number of iterations (" << max_nonlinear_iterations << ") exceeded");
    9494                        break;
    9595                }
  • issm/trunk/src/c/solvers/solver_thermal_nonlinear.cpp

    r11995 r12706  
    1616        Vector* tf_old=NULL;
    1717        Vector* ys=NULL;
    18         double melting_offset;
     18        IssmDouble melting_offset;
    1919
    2020        /*intermediary: */
     
    4747        converged=false;
    4848
    49         _printf_(VerboseSolution(),"%s\n","starting direct shooting method");
     49        if(VerboseSolution()) _pprintLine_("starting direct shooting method");
    5050        InputUpdateFromConstantx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,true,ResetPenaltiesEnum);
    5151        InputUpdateFromConstantx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,false,ConvergedEnum);
     
    6666
    6767                if (!converged){
    68                         _printf_(VerboseConvergence(),"%s%i\n","   #unstable constraints = ",num_unstable_constraints);
     68                        if(VerboseConvergence()) _pprintLine_("   #unstable constraints = " << num_unstable_constraints);
    6969                        if (num_unstable_constraints <= thermal_penalty_threshold)converged=true;
    7070                        if (count>=thermal_maxiter){
    7171                                converged=true;
    72                                 _printf_(true,"   maximum number of iterations (%i) exceeded\n",thermal_maxiter);
     72                                _pprintLine_("   maximum number of iterations (" << thermal_maxiter << ") exceeded");
    7373                        }
    7474                }
  • issm/trunk/src/c/toolkits/issm/SeqMat.cpp

    r12330 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    1919
    2020/*SeqMat constructors and destructor*/
    21 /*FUNCTION SeqMat::SeqMat(){{{1*/
     21/*FUNCTION SeqMat::SeqMat(){{{*/
    2222SeqMat::SeqMat(){
    2323
     
    2727}
    2828/*}}}*/
    29 /*FUNCTION SeqMat::SeqMat(int M,int N){{{1*/
     29/*FUNCTION SeqMat::SeqMat(int M,int N){{{*/
    3030SeqMat::SeqMat(int pM,int pN){
    3131
     
    3333        this->N=pN;
    3434        this->matrix=NULL;
    35         if(M*N) this->matrix=(double*)xcalloc(pM*pN,sizeof(double));
    36 }
    37 /*}}}*/
    38 /*FUNCTION SeqMat::SeqMat(int M,int N, double sparsity){{{1*/
    39 SeqMat::SeqMat(int pM,int pN, double sparsity){
    40 
    41         this->M=pM;
    42         this->N=pN;
    43         this->matrix=NULL;
    44         if(M*N) this->matrix=(double*)xcalloc(pM*pN,sizeof(double));
    45 }
    46 /*}}}*/
    47 /*FUNCTION SeqMat(double* serial_mat,int M,int N,double sparsity){{{1*/
    48 SeqMat::SeqMat(double* serial_mat,int pM,int pN,double sparsity){
     35        if(M*N) this->matrix=xNewZeroInit<IssmDouble>(pM*pN);
     36}
     37/*}}}*/
     38/*FUNCTION SeqMat::SeqMat(int M,int N, IssmDouble sparsity){{{*/
     39SeqMat::SeqMat(int pM,int pN, IssmDouble sparsity){
     40
     41        this->M=pM;
     42        this->N=pN;
     43        this->matrix=NULL;
     44        if(M*N) this->matrix=xNewZeroInit<IssmDouble>(pM*pN);
     45}
     46/*}}}*/
     47/*FUNCTION SeqMat(IssmDouble* serial_mat,int M,int N,IssmDouble sparsity){{{*/
     48SeqMat::SeqMat(IssmDouble* serial_mat,int pM,int pN,IssmDouble sparsity){
    4949
    5050        int i,j;
     
    5454        this->matrix=NULL;
    5555        if(M*N){
    56                 this->matrix=(double*)xcalloc(pM*pN,sizeof(double));
    57                 memcpy(this->matrix,serial_mat,pM*pN*sizeof(double));
    58         }
    59 
    60 }
    61 /*}}}*/
    62 /*FUNCTION SeqMat::SeqMat(int M,int N, int connectivity, int numberofdofspernode){{{1*/
     56                this->matrix=xNewZeroInit<IssmDouble>(pM*pN);
     57                xMemCpy<IssmDouble>(this->matrix,serial_mat,pM*pN);
     58        }
     59
     60}
     61/*}}}*/
     62/*FUNCTION SeqMat::SeqMat(int M,int N, int connectivity, int numberofdofspernode){{{*/
    6363SeqMat::SeqMat(int pM,int pN, int connectivity,int numberofdofspernode){
    6464
     
    6666        this->N=pN;
    6767        this->matrix=NULL;
    68         if(M*N)this->matrix=(double*)xcalloc(pM*pN,sizeof(double));
    69 }
    70 /*}}}*/
    71 /*FUNCTION SeqMat::~SeqMat(){{{1*/
     68        if(M*N) this->matrix=xNewZeroInit<IssmDouble>(pM*pN);
     69}
     70/*}}}*/
     71/*FUNCTION SeqMat::~SeqMat(){{{*/
    7272SeqMat::~SeqMat(){
    7373
    74         xfree((void**)&this->matrix);
     74        xDelete<IssmDouble>(this->matrix);
    7575        M=0;
    7676        N=0;
     
    7979
    8080/*SeqMat specific routines: */
    81 /*FUNCTION SeqMat::Echo{{{1*/
     81/*FUNCTION SeqMat::Echo{{{*/
    8282void SeqMat::Echo(void){
    8383
    8484        int i,j;
    85         printf("SeqMat size %i-%i\n",this->M,this->N);
     85        _printLine_("SeqMat size " << this->M << "-" << this->N);
    8686        for(i=0;i<M;i++){
    8787                for(j=0;j<N;j++){
    88                         printf("%g ",this->matrix[N*i+j]);
     88                        _printString_(this->matrix[N*i+j] << " ");
    8989                }
    90                 printf("\n");
    91         }
    92 }
    93 /*}}}*/
    94 /*FUNCTION SeqMat::Assemble{{{1*/
     90                _printLine_("");
     91        }
     92}
     93/*}}}*/
     94/*FUNCTION SeqMat::Assemble{{{*/
    9595void SeqMat::Assemble(void){
    9696               
     
    9999}
    100100/*}}}*/
    101 /*FUNCTION SeqMat::Norm{{{1*/
    102 double SeqMat::Norm(NormMode mode){
    103 
    104         double norm;
    105         double absolute;
     101/*FUNCTION SeqMat::Norm{{{*/
     102IssmDouble SeqMat::Norm(NormMode mode){
     103
     104        IssmDouble norm;
     105        IssmDouble absolute;
    106106        int i,j;
    107107
     
    119119                        break;
    120120                default:
    121                         _error_("unknown norm !");
    122                         break;
    123         }
    124 }
    125 /*}}}*/
    126 /*FUNCTION SeqMat::GetSize{{{1*/
     121                        _error2_("unknown norm !");
     122                        break;
     123        }
     124}
     125/*}}}*/
     126/*FUNCTION SeqMat::GetSize{{{*/
    127127void SeqMat::GetSize(int* pM,int* pN){
    128128
     
    132132}
    133133/*}}}*/
    134 /*FUNCTION SeqMat::GetLocalSize{{{1*/
     134/*FUNCTION SeqMat::GetLocalSize{{{*/
    135135void SeqMat::GetLocalSize(int* pM,int* pN){
    136136       
     
    140140}
    141141/*}}}*/
    142 /*FUNCTION SeqMat::MatMult{{{1*/
     142/*FUNCTION SeqMat::MatMult{{{*/
    143143void SeqMat::MatMult(SeqVec* X,SeqVec* AX){
    144144
    145145        int i,j;
    146146        int XM,AXM;
    147         double dummy;
     147        IssmDouble dummy;
    148148
    149149        X->GetSize(&XM);
    150150        AX->GetSize(&AXM);
    151151
    152         if(M!=AXM)_error_("A and AX should have the same number of rows!");
    153         if(N!=XM)_error_("A and X should have the same number of columns!");
     152        if(M!=AXM)_error2_("A and AX should have the same number of rows!");
     153        if(N!=XM)_error2_("A and X should have the same number of columns!");
    154154
    155155        for(i=0;i<M;i++){
     
    163163}
    164164/*}}}*/
    165 /*FUNCTION SeqMat::Duplicate{{{1*/
     165/*FUNCTION SeqMat::Duplicate{{{*/
    166166SeqMat* SeqMat::Duplicate(void){
    167167
    168         double dummy=0;
     168        IssmDouble dummy=0;
    169169
    170170        return new SeqMat(this->matrix,this->M,this->N,dummy);
     
    172172}
    173173/*}}}*/
    174 /*FUNCTION SeqMat::ToSerial{{{1*/
    175 double* SeqMat::ToSerial(void){
    176 
    177         double* buffer=NULL;
     174/*FUNCTION SeqMat::ToSerial{{{*/
     175IssmDouble* SeqMat::ToSerial(void){
     176
     177        IssmDouble* buffer=NULL;
    178178
    179179        if(this->M*this->N){
    180                 buffer=(double*)xmalloc(this->M*this->N*sizeof(double));
    181                 memcpy(buffer,this->matrix,this->M*this->N*sizeof(double));
     180                buffer=xNew<IssmDouble>(this->M*this->N);
     181                xMemCpy<IssmDouble>(buffer,this->matrix,this->M*this->N);
    182182        }
    183183        return buffer;
     
    185185}
    186186/*}}}*/
    187 /*FUNCTION SeqMat::SetValues{{{1*/
    188 void SeqMat::SetValues(int m,int* idxm,int n,int* idxn,double* values,InsMode mode){
     187/*FUNCTION SeqMat::SetValues{{{*/
     188void SeqMat::SetValues(int m,int* idxm,int n,int* idxn,IssmDouble* values,InsMode mode){
    189189       
    190190        int i,j;
     
    197197                        break;
    198198                default:
    199                         _error_("unknown insert mode!");
    200                         break;
    201         }
    202 
    203 }
    204 /*}}}*/
    205 /*FUNCTION SeqMat::Convert{{{1*/
     199                        _error2_("unknown insert mode!");
     200                        break;
     201        }
     202
     203}
     204/*}}}*/
     205/*FUNCTION SeqMat::Convert{{{*/
    206206void SeqMat::Convert(MatrixType type){
    207207
  • issm/trunk/src/c/toolkits/issm/SeqMat.h

    r12330 r12706  
    11/*!\file:  SeqMat.h
    2  * \brief wrapper to SeqMat objects, which are just wrappers to a simple double* buffer.
     2 * \brief wrapper to SeqMat objects, which are just wrappers to a simple IssmDouble* buffer.
    33 */
    44
     
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#ifdef HAVE_CONFIG_H
    1111        #include <config.h>
     
    2424       
    2525                int M,N;
    26                 double* matrix;
     26                IssmDouble* matrix;
    2727
    28                 /*SeqMat constructors, destructors {{{1*/
     28                /*SeqMat constructors, destructors {{{*/
    2929                SeqMat();
    3030                SeqMat(int M,int N);
    31                 SeqMat(int M,int N,double sparsity);
    32                 SeqMat(double* serial_mat,int M,int N,double sparsity);
     31                SeqMat(int M,int N,IssmDouble sparsity);
     32                SeqMat(IssmDouble* serial_mat,int M,int N,IssmDouble sparsity);
    3333                SeqMat(int M,int N,int connectivity,int numberofdofspernode);
    3434                ~SeqMat();
    3535                /*}}}*/
    36                 /*SeqMat specific routines {{{1*/
     36                /*SeqMat specific routines {{{*/
    3737                void Echo(void);
    3838                void Assemble(void);
    39                 double Norm(NormMode norm_type);
     39                IssmDouble Norm(NormMode norm_type);
    4040                void GetSize(int* pM,int* pN);
    4141                void GetLocalSize(int* pM,int* pN);
    4242                void MatMult(SeqVec* X,SeqVec* AX);
    4343                SeqMat* Duplicate(void);
    44                 double* ToSerial(void);
    45                 void SetValues(int m,int* idxm,int n,int* idxn,double* values,InsMode mode);
     44                IssmDouble* ToSerial(void);
     45                void SetValues(int m,int* idxm,int n,int* idxn,IssmDouble* values,InsMode mode);
    4646                void Convert(MatrixType type);
    4747                /*}}}*/
  • issm/trunk/src/c/toolkits/issm/SeqVec.cpp

    r12330 r12706  
    44
    55/*Headers:*/
    6 /*{{{1*/
     6/*{{{*/
    77#ifdef HAVE_CONFIG_H
    88        #include <config.h>
     
    1919
    2020/*SeqVec constructors and destructor*/
    21 /*FUNCTION SeqVec::SeqVec(){{{1*/
     21/*FUNCTION SeqVec::SeqVec(){{{*/
    2222SeqVec::SeqVec(){
    2323
     
    2626}
    2727/*}}}*/
    28 /*FUNCTION SeqVec::SeqVec(int M,bool fromlocalsize){{{1*/
     28/*FUNCTION SeqVec::SeqVec(int M,bool fromlocalsize){{{*/
    2929SeqVec::SeqVec(int pM,bool fromlocalsize){
    3030
    3131        this->M=pM;
    3232        this->vector=NULL;
    33         if(this->M) this->vector=(double*)xcalloc(pM,sizeof(double));
    34 }
    35 /*}}}*/
    36 /*FUNCTION SeqVec::SeqVec(double* serial_vec,int M){{{1*/
    37 SeqVec::SeqVec(double* buffer,int pM){
     33        if(this->M) this->vector=xNewZeroInit<IssmDouble>(pM);
     34}
     35/*}}}*/
     36/*FUNCTION SeqVec::SeqVec(IssmDouble* serial_vec,int M){{{*/
     37SeqVec::SeqVec(IssmDouble* buffer,int pM){
    3838
    3939        int i,j;
     
    4242        this->vector=NULL;
    4343        if(this->M){
    44                 this->vector=(double*)xcalloc(pM,sizeof(double));
    45                 memcpy(this->vector,buffer,pM*sizeof(double));
    46         }
    47 }
    48 /*}}}*/
    49                 /*FUNCTION SeqVec::~SeqVec(){{{1*/
     44                this->vector=xNewZeroInit<IssmDouble>(pM);
     45                xMemCpy<IssmDouble>(this->vector,buffer,pM);
     46        }
     47}
     48/*}}}*/
     49                /*FUNCTION SeqVec::~SeqVec(){{{*/
    5050SeqVec::~SeqVec(){
    51         xfree((void**)&this->vector);
     51        xDelete<IssmDouble>(this->vector);
    5252        M=0;
    5353}
     
    5555
    5656/*SeqVec specific routines: */
    57 /*FUNCTION SeqVec::Echo{{{1*/
     57/*FUNCTION SeqVec::Echo{{{*/
    5858void SeqVec::Echo(void){
    5959
    6060        int i;
    61         printf("SeqVec size %i\n",this->M);
     61        _printLine_("SeqVec size " << this->M);
    6262        for(i=0;i<M;i++){
    63                 printf("%g\n ",vector[i]);
    64         }
    65 }
    66 /*}}}*/
    67 
    68 /*FUNCTION SeqVec::Assemble{{{1*/
     63                _printString_(vector[i] << "\n ");
     64        }
     65}
     66/*}}}*/
     67
     68/*FUNCTION SeqVec::Assemble{{{*/
    6969void SeqVec::Assemble(void){
    7070               
     
    7373}
    7474/*}}}*/
    75 /*FUNCTION SeqVec::SetValues{{{1*/
    76 void SeqVec::SetValues(int ssize, int* list, double* values, InsMode mode){
     75/*FUNCTION SeqVec::SetValues{{{*/
     76void SeqVec::SetValues(int ssize, int* list, IssmDouble* values, InsMode mode){
    7777       
    7878        int i;
     
    8585                        break;
    8686                default:
    87                         _error_("unknown insert mode!");
    88                         break;
    89         }
    90 
    91 }
    92 /*}}}*/
    93 /*FUNCTION SeqVec::SetValue{{{1*/
    94 void SeqVec::SetValue(int dof, double value, InsMode mode){
     87                        _error2_("unknown insert mode!");
     88                        break;
     89        }
     90
     91}
     92/*}}}*/
     93/*FUNCTION SeqVec::SetValue{{{*/
     94void SeqVec::SetValue(int dof, IssmDouble value, InsMode mode){
    9595
    9696        switch(mode){
     
    102102                        break;
    103103                default:
    104                         _error_("unknown insert mode!");
    105                         break;
    106         }
    107 }
    108 /*}}}*/
    109 /*FUNCTION SeqVec::GetValue{{{1*/
    110 void SeqVec::GetValue(double* pvalue,int dof){
     104                        _error2_("unknown insert mode!");
     105                        break;
     106        }
     107}
     108/*}}}*/
     109/*FUNCTION SeqVec::GetValue{{{*/
     110void SeqVec::GetValue(IssmDouble* pvalue,int dof){
    111111
    112112        *pvalue=this->vector[dof];
     
    115115/*}}}*/
    116116               
    117 /*FUNCTION SeqVec::GetSize{{{1*/
     117/*FUNCTION SeqVec::GetSize{{{*/
    118118void SeqVec::GetSize(int* pM){
    119119
     
    122122}
    123123/*}}}*/
    124 /*FUNCTION SeqVec::GetLocalSize{{{1*/
     124/*FUNCTION SeqVec::GetLocalSize{{{*/
    125125void SeqVec::GetLocalSize(int* pM){
    126126       
     
    129129}
    130130/*}}}*/
    131 /*FUNCTION SeqVec::Duplicate{{{1*/
     131/*FUNCTION SeqVec::Duplicate{{{*/
    132132SeqVec* SeqVec::Duplicate(void){
    133133       
     
    136136}
    137137/*}}}*/
    138 /*FUNCTION SeqVec::Set{{{1*/
    139 void SeqVec::Set(double value){
     138/*FUNCTION SeqVec::Set{{{*/
     139void SeqVec::Set(IssmDouble value){
    140140
    141141        int i;
     
    144144}
    145145/*}}}*/
    146 /*FUNCTION SeqVec::AXPY{{{1*/
    147 void SeqVec::AXPY(SeqVec* X, double a){
     146/*FUNCTION SeqVec::AXPY{{{*/
     147void SeqVec::AXPY(SeqVec* X, IssmDouble a){
    148148
    149149        int i;
     
    154154}
    155155/*}}}*/
    156 /*FUNCTION SeqVec::AYPX{{{1*/
    157 void SeqVec::AYPX(SeqVec* X, double a){
     156/*FUNCTION SeqVec::AYPX{{{*/
     157void SeqVec::AYPX(SeqVec* X, IssmDouble a){
    158158       
    159159        int i;
     
    164164}
    165165/*}}}*/
    166 /*FUNCTION SeqVec::ToMPISerial{{{1*/
    167 double* SeqVec::ToMPISerial(void){
    168 
    169         double* buffer=NULL;
     166/*FUNCTION SeqVec::ToMPISerial{{{*/
     167IssmDouble* SeqVec::ToMPISerial(void){
     168
     169        IssmDouble* buffer=NULL;
    170170
    171171        if(this->M){
    172                 buffer=(double*)xmalloc(this->M*sizeof(double));
    173                 memcpy(buffer,this->vector,this->M*sizeof(double));
     172                buffer=xNew<IssmDouble>(this->M);
     173                xMemCpy<IssmDouble>(buffer,this->vector,this->M);
    174174        }
    175175        return buffer;
     
    177177}
    178178/*}}}*/
    179 /*FUNCTION SeqVec::Copy{{{1*/
     179/*FUNCTION SeqVec::Copy{{{*/
    180180void SeqVec::Copy(SeqVec* to){
    181181
     
    187187}
    188188/*}}}*/
    189 /*FUNCTION SeqVec::Norm{{{1*/
    190 double SeqVec::Norm(NormMode mode){
    191 
    192         double norm;
     189/*FUNCTION SeqVec::Norm{{{*/
     190IssmDouble SeqVec::Norm(NormMode mode){
     191
     192        IssmDouble norm;
    193193        int i;
    194194
     
    204204                        break;
    205205                default:
    206                         _error_("unknown norm !");
    207                         break;
    208         }
    209 }
    210 /*}}}*/
    211 /*FUNCTION SeqVec::Scale{{{1*/
    212 void SeqVec::Scale(double scale_factor){
     206                        _error2_("unknown norm !");
     207                        break;
     208        }
     209}
     210/*}}}*/
     211/*FUNCTION SeqVec::Scale{{{*/
     212void SeqVec::Scale(IssmDouble scale_factor){
    213213
    214214        int i;
     
    217217}
    218218/*}}}*/
    219 /*FUNCTION SeqVec::Dot{{{1*/
    220 double SeqVec::Dot(SeqVec* input){
    221 
    222         int i;
    223 
    224         double dot=0;
     219/*FUNCTION SeqVec::Dot{{{*/
     220IssmDouble SeqVec::Dot(SeqVec* input){
     221
     222        int i;
     223
     224        IssmDouble dot=0;
    225225        for(i=0;i<this->M;i++)dot+=this->vector[i]*input->vector[i];
    226226        return dot;
     
    228228}
    229229/*}}}*/
    230 /*FUNCTION SeqVec::PointwiseDivide{{{1*/
     230/*FUNCTION SeqVec::PointwiseDivide{{{*/
    231231void SeqVec::PointwiseDivide(SeqVec* x,SeqVec* y){
    232232
  • issm/trunk/src/c/toolkits/issm/SeqVec.h

    r12330 r12706  
    11/*!\file:  SeqVec.h
    2  * \brief wrapper to our SeqVec object, which is just a wrapper to a double*
     2 * \brief wrapper to our SeqVec object, which is just a wrapper to a IssmDouble*
    33 */
    44
     
    77
    88/*Headers:*/
    9 /*{{{1*/
     9/*{{{*/
    1010#ifdef HAVE_CONFIG_H
    1111        #include <config.h>
     
    2222        public:
    2323       
    24                 double* vector;
     24                IssmDouble* vector;
    2525                int M;
    2626
    27                 /*SeqVec constructors, destructors {{{1*/
     27                /*SeqVec constructors, destructors {{{*/
    2828                SeqVec();
    2929                SeqVec(int M,bool fromlocalsize=false);
    30                 SeqVec(double* buffer, int M);
     30                SeqVec(IssmDouble* buffer, int M);
    3131                ~SeqVec();
    3232                /*}}}*/
    33                 /*SeqVec specific routines {{{1*/
     33                /*SeqVec specific routines {{{*/
    3434                void Echo(void);
    3535                void Assemble(void);
    36                 void SetValues(int ssize, int* list, double* values, InsMode mode);
    37                 void SetValue(int dof, double value, InsMode  mode);
    38                 void GetValue(double* pvalue, int dof);
     36                void SetValues(int ssize, int* list, IssmDouble* values, InsMode mode);
     37                void SetValue(int dof, IssmDouble value, InsMode  mode);
     38                void GetValue(IssmDouble* pvalue, int dof);
    3939                void GetSize(int* pM);
    4040                void GetLocalSize(int* pM);
    4141                SeqVec* Duplicate(void);
    42                 void Set(double value);
    43                 void AXPY(SeqVec* X, double a);
    44                 void AYPX(SeqVec* X, double a);
    45                 double* ToMPISerial(void);
     42                void Set(IssmDouble value);
     43                void AXPY(SeqVec* X, IssmDouble a);
     44                void AYPX(SeqVec* X, IssmDouble a);
     45                IssmDouble* ToMPISerial(void);
    4646                void Copy(SeqVec* to);
    47                 double Norm(NormMode norm_type);
    48                 void Scale(double scale_factor);
     47                IssmDouble Norm(NormMode norm_type);
     48                void Scale(IssmDouble scale_factor);
    4949                void PointwiseDivide(SeqVec* x,SeqVec* y);
    50                 double Dot(SeqVec* vector);
     50                IssmDouble Dot(SeqVec* vector);
    5151                /*}}}*/
    5252};
  • issm/trunk/src/c/toolkits/issm/issmtoolkit.h

    r11995 r12706  
    66#define _ISSM_TOOLKIT_H_
    77
     8#include "../../include/include.h"
     9
    810#include "./SeqMat.h"
    911#include "./SeqVec.h"
  • issm/trunk/src/c/toolkits/metis/patches/METIS_PartMeshNodalPatch.cpp

    r10087 r12706  
    1313        METIS_PartMeshNodal(pnumberofelements,pnumberofnodes, index, petype, pnumflag, pnum_procs, pedgecut, epart, npart);
    1414        #elif _METIS_VERSION_ == 5
    15         /*This interface is heavily changed. More options, different way of meshing, etc ...: */
     15        /*This interface is heavily changed. More options, different ways of meshing, etc ...: */
    1616        int i;
    1717
     
    2121        idx_t  k=0;
    2222        real_t* tpwgts=NULL;
    23 
    24 
    2523
    2624        /*setup options: */
     
    4038        options[METIS_OPTION_NCUTS]   = 1;
    4139
    42 
    4340        /*create eptr: */
    44         eptr=(idx_t*)xmalloc((*pnumberofelements+1)*sizeof(idx_t));
     41        eptr=xNew<idx_t>((*pnumberofelements+1));
    4542        eptr[0]=0;
    4643        for(i=0;i<*pnumberofelements;i++){
     
    4946        }
    5047
    51 
    5248        /*create tpwgts: */
    53         tpwgts=(real_t*)xmalloc(*pnum_procs*sizeof(real_t));
     49        tpwgts=xNew<real_t>(*pnum_procs);
    5450        for(i=0;i<*pnum_procs;i++){
    5551                tpwgts[i]=1.0/(*pnum_procs);
    5652        }
    5753
    58 
    5954        METIS_PartMeshNodal(pnumberofelements,pnumberofnodes, eptr, index,
    60                         NULL, NULL, pnum_procs, tpwgts, options, &objval,
    61                         epart, npart);
    62        
     55                        NULL, NULL, pnum_procs, tpwgts, options, &objval,epart, npart);
    6356
    6457        #else
    65         _error_("METIS version not supported yet");
     58        _error2_("METIS version not supported yet");
    6659        #endif
    6760}
  • issm/trunk/src/c/toolkits/mpi/patches/DetermineLocalSize.cpp

    r11995 r12706  
    55#include <stdio.h>
    66#include <math.h>
    7 
    8 
    97#include "../../../shared/shared.h"
    108
     
    2422       
    2523        /*We are  not bound by any library, just use what seems most logical*/
    26         num_local_rows=(int*)xmalloc(num_procs*sizeof(int));   
     24        num_local_rows=xNew<int>(num_procs);   
    2725
    2826        for (i=0;i<num_procs;i++){
    29 
    3027                /*Here, we use floor. We under distribute rows. The rows
    3128                  left  are then redistributed, therefore resulting in a
     
    3936                num_local_rows[i]++;
    4037        }
    41 
    4238        local_size=num_local_rows[my_rank];
    4339       
    4440        /*free ressources: */
    45         xfree((void**)&num_local_rows);
     41        xDelete<int>(num_local_rows);
    4642
    4743        /*return size: */
  • issm/trunk/src/c/toolkits/mpi/patches/MPI_Boundariesfromrange.cpp

    r11995 r12706  
    2020
    2121        /*Gather all range values into allranges, for all nodes*/
    22         allranges=(int*)xmalloc(num_procs*sizeof(int));
     22        allranges=xNew<int>(num_procs);
    2323        MPI_Allgather(&range,1,MPI_INT,allranges,1,MPI_INT,MPI_COMM_WORLD);
    24 
    2524
    2625        /*From all ranges, get lower row and upper row*/
     
    3130                upper_row=upper_row+allranges[i];
    3231        }
    33        
    34         /*free: */
    35         xfree((void**)&allranges);
    3632
    3733        /*Assign output pointers: */
     34        xDelete<int>(allranges);
    3835        *plower_row=lower_row;
    3936        *pupper_row=upper_row;
    40 
    4137        return 1;
    4238}
  • issm/trunk/src/c/toolkits/petsc/patches/GetOwnershipBoundariesFromRange.cpp

    r9320 r12706  
    2828
    2929        /*Gather all range values into allranges, for all nodes*/
    30         allranges=(int*)xmalloc(num_procs*sizeof(int));
     30        allranges=xNew<int>(num_procs);
    3131        MPI_Allgather(&range,1,MPI_INT,allranges,1,MPI_INT,MPI_COMM_WORLD);
    3232
     
    4242        *plower_row=lower_row;
    4343        *pupper_row=upper_row;
    44 
    45         /*Free ressources:*/
    46         xfree((void**)&allranges);
    47 
     44        xDelete<int>(allranges);
    4845}
  • issm/trunk/src/c/toolkits/petsc/patches/ISSMToPetscInsertMode.cpp

    r11995 r12706  
    3030                        break;
    3131                default:
    32                         _error_("unknown insert mode!");
     32                        _error2_("unknown insert mode!");
    3333                        break;
    3434        }
  • issm/trunk/src/c/toolkits/petsc/patches/ISSMToPetscMatrixType.cpp

    r11995 r12706  
    3030                        break;
    3131                default:
    32                         _error_("unknown matrix type !");
     32                        _error2_("unknown matrix type !");
    3333                        break;
    3434        }
  • issm/trunk/src/c/toolkits/petsc/patches/ISSMToPetscNormMode.cpp

    r11995 r12706  
    3030                        break;
    3131                default:
    32                         _error_("unknown norm !");
     32                        _error2_("unknown norm !");
    3333                        break;
    3434        }
  • issm/trunk/src/c/toolkits/petsc/patches/MatInvert.cpp

    r12330 r12706  
    2929        /*Some checks: */
    3030        MatGetSize(matrix,&M,&N);
    31         if(M!=N) _error_("trying to invert a non square matrix!");
     31        if(M!=N) _error2_("trying to invert a non square matrix!");
    3232
    3333        /*Create identitiy matrix: */
  • issm/trunk/src/c/toolkits/petsc/patches/MatMultPatch.cpp

    r9826 r12706  
    6464        }
    6565        else{
    66                 result=1;\
     66                result=1;
    6767        }
    6868        return result;
     
    8989        range=upper_row-lower_row+1;
    9090        if (range){
    91                 index=(int*)xmalloc(range*sizeof(int));
    92                 values=(double*)xmalloc(range*sizeof(double));
     91                index=xNew<int>(range);
     92                values=xNew<double>(range);
    9393                for (int i=0;i<range;i++){
    9494                        *(index+i)=lower_row+i;
     
    103103
    104104        /*Free ressources:*/
    105         xfree((void**)&index);
    106         xfree((void**)&values);
     105        xDelete<int>(index);
     106        xDelete<double>(values);       
    107107
    108108        /*Assign output pointers:*/
  • issm/trunk/src/c/toolkits/petsc/patches/MatPartition.cpp

    r11995 r12706  
    6262                }
    6363                else{
    64                         _error_("MatType %s not supported yet",type);
     64                        _error2_("MatType " << type << " not supported yet");
    6565                }
    6666                /*Assemble*/
     
    7777                count=0;
    7878                if (range){
    79                         node_rows=(int*)xmalloc(range*sizeof(int)); //this is the maximum number of rows one node can extract.
     79                        node_rows=xNew<int>(range); //this is the maximum number of rows one node can extract.
    8080               
    8181                        for (i=0;i<row_partition_vector_size;i++){
     
    9898               
    9999                /*Same deal for columns*/
    100                 node_cols=(int*)xmalloc(col_partition_vector_size*sizeof(int));
     100                node_cols=xNew<int>(col_partition_vector_size);
    101101                for (i=0;i<col_partition_vector_size;i++){
    102102                        *(node_cols+i)=(int)*(col_partition_vector+i)-1;
     
    128128
    129129        /*Free ressources:*/
    130         xfree((void**)&node_rows);
    131         xfree((void**)&node_cols);
     130        xDelete<int>(node_rows);
     131        xDelete<int>(node_cols);
    132132        ISFree(&col_index);
    133133        ISFree(&row_index);
  • issm/trunk/src/c/toolkits/petsc/patches/MatToSerial.cpp

    r11995 r12706  
    3232        double* outmatrix=NULL;
    3333       
    34        
    3534        /*get matrix size: */
    3635        MatGetSize(matrix,&M,&N);
     
    4241       
    4342        /*Local and global allocation*/
    44         if (my_rank==0)outmatrix=(double*)xmalloc(M*N*sizeof(double));
     43        if (my_rank==0)outmatrix=xNew<double>(M*N);
    4544       
    4645        if (range){
    47                 local_matrix=(double*)xmalloc(N*range*sizeof(double));
    48                 idxm=(int*)xmalloc(range*sizeof(int)); 
    49                 idxn=(int*)xmalloc(N*sizeof(int)); 
     46                local_matrix=xNew<double>(N*range);
     47                idxm=xNew<int>(range); 
     48                idxn=xNew<int>(N); 
    5049         
    5150                for (i=0;i<N;i++){
     
    7877                //Still have the local_matrix on node 0 to take care of.
    7978                memcpy(outmatrix,local_matrix,N*range*sizeof(double));
    80 
    8179        }
    8280       
    8381        /*Assign output pointer: */
    8482        *poutmatrix=outmatrix;
    85        
    86         xfree((void**)&idxm);
    87         xfree((void**)&idxn);
    88         xfree((void**)&local_matrix);
    89 
     83        xDelete<int>(idxm);
     84        xDelete<int>(idxn);
     85        xDelete<double>(local_matrix);
    9086}
  • issm/trunk/src/c/toolkits/petsc/patches/NewMat.cpp

    r12330 r12706  
    2020#include "../../mpi/patches/mpipatches.h"
    2121
    22 /*NewMat(int M,int N){{{1*/
     22/*NewMat(int M,int N){{{*/
    2323Mat NewMat(int M,int N){
    2424
     
    4848}
    4949/*}}}*/
    50 /*NewMat(int M,int N,double sparsity){{{1*/
     50/*NewMat(int M,int N,double sparsity){{{*/
    5151Mat NewMat(int M,int N,double sparsity){
    5252
     
    8181}
    8282/*}}}*/
    83 /*NewMat(int M,int N,int connectivity,int numberofdofspernode){{{1*/
     83/*NewMat(int M,int N,int connectivity,int numberofdofspernode){{{*/
    8484Mat NewMat(int M,int N,int connectivity,int numberofdofspernode){
    8585
  • issm/trunk/src/c/toolkits/petsc/patches/PetscMatrixToDoubleMatrix.cpp

    r12330 r12706  
    3636        MatGetSize(petsc_matrix,&rows,&cols);
    3737
    38         idxm=(int*)xmalloc(rows*sizeof(int));
    39         idxn=(int*)xmalloc(cols*sizeof(int));
     38        idxm=xNew<int>(rows);
     39        idxn=xNew<int>(cols);
    4040
    4141        for(i=0;i<rows;i++)idxm[i]=i;
    4242        for(i=0;i<cols;i++)idxn[i]=i;
    4343
    44         matrix=(double*)xmalloc(rows*cols*sizeof(double));
     44        matrix=xNew<double>(rows*cols);
    4545        MatGetValues(petsc_matrix,rows,idxm,cols,idxn,matrix);
     46
     47        xDelete<int>(idxm);
     48        xDelete<int>(idxn);
    4649
    4750        /*Assign output pointers: */
  • issm/trunk/src/c/toolkits/petsc/patches/PetscOptionsInsertMultipleString.cpp

    r11995 r12706  
    5555                        if(first[0]!='-'){
    5656                                /*This is not good, the option does not have '-'! Get out*/
    57                                 _error_("%s%s%s","Option ",first," should be preceded by '-'!");
     57                                _error2_("Option " << first << " should be preceded by '-'!");
    5858                        }
    5959                        /*Reduce first to bare option value*/
  • issm/trunk/src/c/toolkits/petsc/patches/PetscVectorToDoubleVector.cpp

    r12330 r12706  
    2828                VecGetSize(petsc_vector,&rows);
    2929                if(rows){
    30                         idxm=(int*)xmalloc(rows*sizeof(int));
    31                         vector=(double*)xmalloc(rows*sizeof(double));
     30                        idxm=xNew<int>(rows);
     31                        vector=xNew<double>(rows);
    3232                        for(i=0;i<rows;i++)idxm[i]=i;
    33 
    3433                        VecGetValues(petsc_vector,rows,idxm,vector);
     34                        xDelete<int>(idxm);
    3535                }
    3636        }
  • issm/trunk/src/c/toolkits/petsc/patches/SerialToVec.cpp

    r11995 r12706  
    3838
    3939        if (range){
    40                 idxn=(int*)xmalloc(range*sizeof(int));
    41                 values=(double*)xmalloc(range*sizeof(double));
     40                idxn=xNew<int>(range);
     41                values=xNew<double>(range);
    4242                for (i=0;i<range;i++){
    4343                        idxn[i]=lower_row+i;
     
    5454
    5555        /*Free ressources:*/
    56         xfree((void**)&idxn);
    57         xfree((void**)&values);
     56        xDelete<int>(idxn);
     57        xDelete<double>(values);
    5858
    5959        return outvector;
  • issm/trunk/src/c/toolkits/petsc/patches/VecMerge.cpp

    r9320 r12706  
    3535        /*If the dimension of the partitioning vector is not the same as that of vector B, we have a problem: */
    3636        if ( (row_partition_size !=MB) ){
    37                 _error_("Dimensions of partitioning vector incompatible with dimensions of input vector\n");
     37                _error2_("Dimensions of partitioning vector incompatible with dimensions of input vector\n");
    3838        }
    3939
     
    4545        if (range){
    4646                /*This node owns rows of vector B, get them*/
    47                 idxm=(int*)xmalloc(range*sizeof(int));
    48                 values=(double*)xmalloc(range*sizeof(double));
     47                idxm=xNew<int>(range);
     48                values=xNew<double>(range);
    4949                for (i=0;i<range;i++){
    5050                        *(idxm+i)=lower_row+i;
     
    6363
    6464        /*Free ressources:*/
    65         xfree((void**)&idxm);
    66         xfree((void**)&values);
    67 
     65        xDelete<int>(idxm);
     66        xDelete<double>(values);
    6867}
  • issm/trunk/src/c/toolkits/petsc/patches/VecPartition.cpp

    r9320 r12706  
    5656
    5757                if (range){
    58                         node_rows=(int*)xmalloc(range*sizeof(int)); //this is the maximum number of rows one node can extract.
     58                        node_rows=xNew<int>(range); //this is the maximum number of rows one node can extract.
    5959               
    6060                        count=0;
     
    7171                                       
    7272        if (count){
    73                         values=(double*)xmalloc(count*sizeof(double)); //holder for the values to be extracted from vectorA
     73                        values=xNew<double>(count); //holder for the values to be extracted from vectorA
    7474                }
    7575                else{
    76                         xfree((void**)&node_rows); //count=0 means no values was condensed out for this node. null node_rows for use in VecGetValues.
     76                        xDelete<int>(node_rows); //count=0 means no values was condensed out for this node. null node_rows for use in VecGetValues.
    7777                        values=NULL;
    7878                }
     
    110110                VecAssemblyBegin(outvector);
    111111                VecAssemblyEnd(outvector);
    112                
    113112        }
    114113       
    115114        /*Assign output pointers:*/
    116115        *poutvector=outvector;
    117 
    118         /*Free ressources:*/
    119         xfree((void**)&node_rows);
    120         xfree((void**)&values);
    121 
     116        xDelete<int>(node_rows);
     117        xDelete<double>(values);
    122118}
  • issm/trunk/src/c/toolkits/petsc/patches/VecToMPISerial.cpp

    r11995 r12706  
    4242
    4343        /*Allocate gathered vector on all nodes .*/
    44         gathered_vector=(double*)xmalloc(vector_size*sizeof(double));
     44        gathered_vector=xNew<double>(vector_size);
    4545       
    4646        /*Allocate local vectors*/
     
    5050
    5151        if (range){
    52                 idxn=(int*)xmalloc(range*sizeof(int));
     52                idxn=xNew<int>(range);
    5353                for (i=0;i<range;i++){
    5454                        *(idxn+i)=lower_row+i;
    5555                }
    56                 local_vector=(double*)xmalloc(range*sizeof(double));
     56                local_vector=xNew<double>(range);
    5757                /*Extract values from MPI vector to serial local_vector on each node*/
    5858                VecGetValues(vector,range,idxn,local_vector);
     
    8787       
    8888        /*free ressources: */
    89         xfree((void**)&idxn);
    90         xfree((void**)&local_vector);
     89        xDelete<int>(idxn);
     90        xDelete<double>(local_vector);
    9191       
    9292        return 1;
  • issm/trunk/src/c/toolkits/petsc/patches/VecTranspose.cpp

    r1 r12706  
    3333
    3434        if (range){
    35                 idxm=(int*)xmalloc(range*sizeof(int));
    36                 tidxm=(int*)xmalloc(range*sizeof(int));
     35                idxm=xNew<int>(range);
     36                tidxm=xNew<int>(range);
    3737                for (i=0;i<range;i++){
    3838                        *(idxm+i)=lower_row+i;
    3939                }
    40                 values=(double*)xmalloc(range*sizeof(double));
    41                 tvalues=(double*)xmalloc(range*sizeof(double));
     40                values=xNew<double>(range);
     41                tvalues=xNew<double>(range);
    4242               
    4343                VecGetValues(vector,range,idxm,values);
     
    5656
    5757        /*Free ressources: */
    58         xfree((void**)&idxm);
    59         xfree((void**)&values);
    60         xfree((void**)&tidxm);
    61         xfree((void**)&tvalues);
     58        xDelete<int>(idxm);
     59        xDelete<double>(values);
     60        xDelete<int>(tidxm);
     61        xDelete<double>(tvalues);
    6262
    6363        /*Assign output pointers: */
  • issm/trunk/src/c/toolkits/plapack/patches/CyclicalFactorization.cpp

    r3595 r12706  
    4444        int i;
    4545
    46         decomp=xmalloc(input*sizeof(int));
     46        decomp=xNew<int>(input);
    4747        *decomp=input;
    4848        for (i=0;i<input;i++){
     
    5757                }
    5858        }
    59 
    6059        *pdecomp=decomp;
    6160}
  • issm/trunk/src/c/toolkits/plapack/patches/PlapackInvertMatrix.cpp

    r6412 r12706  
    1313#include "../../scalapack/FortranMapping.h"
    1414
    15 void PlapackInvertMatrixLocalCleanup(PLA_Obj* pa,PLA_Template* ptempl,double** parrayA,
    16                 int** pidxnA,MPI_Comm* pcomm_2d);
     15void PlapackInvertMatrixLocalCleanup(PLA_Obj* pa,PLA_Template* ptempl,double** parrayA,int** pidxnA,MPI_Comm* pcomm_2d);
    1716       
    1817int PlapackInvertMatrix(Mat* A,Mat* inv_A,int status,int con){
    19         /*inv_A does not yet exist, inv_A was just xmalloced, that's all*/
     18        /*inv_A does not yet exist, inv_A was just allocated, that's all*/
    2019
    2120        /*Error management*/
    2221        int i,j;
    23        
    2422
    2523        /*input*/
     
    5351
    5452        /*Some dimensions checks: */
    55         if (mA!=nA) _error_(" trying to take the invert of a non-square matrix!");
     53        if (mA!=nA) _error2_("trying to take the invert of a non-square matrix!");
    5654
    5755        /* Set default Plapack parameters */
     
    9492        /* Set the datatype */
    9593        datatype = MPI_DOUBLE;
    96 
    9794       
    9895        /* Copy A into a*/
     
    104101        upper_row--;
    105102        range=upper_row-lower_row+1;
    106         arrayA=xmalloc(nA*sizeof(double));
    107         idxnA=xmalloc(nA*sizeof(int));
     103        arrayA = xNew<double>(nA);
     104        idxnA  = xNew<int>(nA);
    108105        for (i=0;i<nA;i++){
    109106                *(idxnA+i)=i;
     
    128125        PLA_Obj_free(&a);
    129126        PLA_Temp_free(&templ);
    130         xfree((void**)&arrayA);
    131         xfree((void**)&idxnA);
     127        xDelete<double>(arrayA);
     128        xDelete<int>(idxnA);
    132129       
    133130        /*Finalize PLAPACK*/
    134131        PLA_Finalize();
    135132        MPI_Comm_free(&comm_2d);
    136 
    137133}
  • issm/trunk/src/c/toolkits/plapack/patches/PlapackToPetsc.cpp

    r3332 r12706  
    4545       
    4646        /*Vector physically based block cyclic distribution: */
    47         row_nodes=xmalloc(mA*sizeof(int));
    48         col_nodes=xmalloc(nA*sizeof(int));
     47        row_nodes=xNew<int>(mA);
     48        col_nodes=xNew<int>(nA);
    4949        for (i=0;i<mA;i++){
    5050                i0=i/nb;
     
    6060        PLA_Temp_comm_col_rank(templ,&myrow);
    6161
    62         idxm=xmalloc(mA*sizeof(int));
     62        idxm=xNew<int>(mA);
    6363        count=0;
    6464        for (i=0;i<mA;i++){
     
    7070        idxm_count=count;
    7171
    72         idxn=xmalloc(nA*sizeof(int));
     72        idxn=xNew<int>(nA);
    7373        count=0;
    7474        for (i=0;i<nA;i++){
     
    9292
    9393        /*Free ressources:*/
    94         xfree((void**)&row_nodes);
    95         xfree((void**)&col_nodes);
    96         xfree((void**)&idxm);
    97         xfree((void**)&idxn);
     94        xDelete<int>(row_nodes);
     95        xDelete<int>(col_nodes);
     96        xDelete<int>(idxm);
     97        xDelete<int>(idxn);
    9898}
  • issm/trunk/src/dox/issm.dox

    r12337 r12706  
    4646</th>
    4747<tr>
    48 <th  bgcolor=#FFFFFF style="text-align:left;"> C++ </th><td  bgcolor=#FFFFFF style="text-align:right;">508</td><td  bgcolor=#FFFFFF style="text-align:right;">14595</td><td  bgcolor=#FFFFFF style="text-align:right;">16762</td><td  bgcolor=#FFFFFF style="text-align:right;">56034</td><td  bgcolor=#FFFFFF style="text-align:right;">87391</td>
     48<th  bgcolor=#FFFFFF style="text-align:left;"> C++ </th><td  bgcolor=#FFFFFF style="text-align:right;">508</td><td  bgcolor=#FFFFFF style="text-align:right;">14595</td><td  bgcolor=#FFFFFF style="text-align:right;">16762</td><td  bgcolor=#FFFFFF style="text-align:right;">56036</td><td  bgcolor=#FFFFFF style="text-align:right;">87393</td>
    4949</tr>
    5050<tr>
    51 <th  bgcolor=#C6E2FF style="text-align:left;"> MATLAB </th><td  bgcolor=#C6E2FF style="text-align:right;">926</td><td  bgcolor=#C6E2FF style="text-align:right;">6911</td><td  bgcolor=#C6E2FF style="text-align:right;">13305</td><td  bgcolor=#C6E2FF style="text-align:right;">30623</td><td  bgcolor=#C6E2FF style="text-align:right;">50839</td>
     51<th  bgcolor=#C6E2FF style="text-align:left;"> MATLAB </th><td  bgcolor=#C6E2FF style="text-align:right;">925</td><td  bgcolor=#C6E2FF style="text-align:right;">6851</td><td  bgcolor=#C6E2FF style="text-align:right;">13228</td><td  bgcolor=#C6E2FF style="text-align:right;">30468</td><td  bgcolor=#C6E2FF style="text-align:right;">50547</td>
    5252</tr>
    5353<tr>
    54 <th  bgcolor=#FFFFFF style="text-align:left;"> C/C++  Header </th><td  bgcolor=#FFFFFF style="text-align:right;">378</td><td  bgcolor=#FFFFFF style="text-align:right;">2754</td><td  bgcolor=#FFFFFF style="text-align:right;">2625</td><td  bgcolor=#FFFFFF style="text-align:right;">9801</td><td  bgcolor=#FFFFFF style="text-align:right;">15180</td>
     54<th  bgcolor=#FFFFFF style="text-align:left;"> C/C++  Header </th><td  bgcolor=#FFFFFF style="text-align:right;">378</td><td  bgcolor=#FFFFFF style="text-align:right;">2758</td><td  bgcolor=#FFFFFF style="text-align:right;">2612</td><td  bgcolor=#FFFFFF style="text-align:right;">9818</td><td  bgcolor=#FFFFFF style="text-align:right;">15188</td>
    5555</tr>
    5656<tr>
     
    5858</tr>
    5959<tr>
    60 <th  bgcolor=#FFFFFF style="text-align:left;"> Python </th><td  bgcolor=#FFFFFF style="text-align:right;">54</td><td  bgcolor=#FFFFFF style="text-align:right;">404</td><td  bgcolor=#FFFFFF style="text-align:right;">799</td><td  bgcolor=#FFFFFF style="text-align:right;">1435</td><td  bgcolor=#FFFFFF style="text-align:right;">2638</td>
     60<th  bgcolor=#FFFFFF style="text-align:left;"> Python </th><td  bgcolor=#FFFFFF style="text-align:right;">53</td><td  bgcolor=#FFFFFF style="text-align:right;">400</td><td  bgcolor=#FFFFFF style="text-align:right;">610</td><td  bgcolor=#FFFFFF style="text-align:right;">1424</td><td  bgcolor=#FFFFFF style="text-align:right;">2434</td>
    6161</tr>
    6262<tr>
     
    6464</tr>
    6565<tr>
    66 <th  bgcolor=#FFFFFF style="text-align:left;"> Bourne  Shell </th><td  bgcolor=#FFFFFF style="text-align:right;">6</td><td  bgcolor=#FFFFFF style="text-align:right;">47</td><td  bgcolor=#FFFFFF style="text-align:right;">73</td><td  bgcolor=#FFFFFF style="text-align:right;">241</td><td  bgcolor=#FFFFFF style="text-align:right;">361</td>
     66<th  bgcolor=#FFFFFF style="text-align:left;"> Perl </th><td  bgcolor=#FFFFFF style="text-align:right;">3</td><td  bgcolor=#FFFFFF style="text-align:right;">21</td><td  bgcolor=#FFFFFF style="text-align:right;">23</td><td  bgcolor=#FFFFFF style="text-align:right;">240</td><td  bgcolor=#FFFFFF style="text-align:right;">284</td>
    6767</tr>
    6868<tr>
    69 <th  bgcolor=#C6E2FF style="text-align:left;"> Perl </th><td  bgcolor=#C6E2FF style="text-align:right;">3</td><td  bgcolor=#C6E2FF style="text-align:right;">21</td><td  bgcolor=#C6E2FF style="text-align:right;">23</td><td  bgcolor=#C6E2FF style="text-align:right;">240</td><td  bgcolor=#C6E2FF style="text-align:right;">284</td>
     69<th  bgcolor=#C6E2FF style="text-align:left;"> Bourne  Shell </th><td  bgcolor=#C6E2FF style="text-align:right;">5</td><td  bgcolor=#C6E2FF style="text-align:right;">47</td><td  bgcolor=#C6E2FF style="text-align:right;">75</td><td  bgcolor=#C6E2FF style="text-align:right;">239</td><td  bgcolor=#C6E2FF style="text-align:right;">361</td>
    7070</tr>
    7171<tr>
     
    7373</tr>
    7474<tr>
    75 <th  bgcolor=#C6E2FF style="text-align:left;"> XML </th><td  bgcolor=#C6E2FF style="text-align:right;">8</td><td  bgcolor=#C6E2FF style="text-align:right;">37</td><td  bgcolor=#C6E2FF style="text-align:right;">121</td><td  bgcolor=#C6E2FF style="text-align:right;">85</td><td  bgcolor=#C6E2FF style="text-align:right;">243</td>
     75<th  bgcolor=#C6E2FF style="text-align:left;"> C </th><td  bgcolor=#C6E2FF style="text-align:right;">1</td><td  bgcolor=#C6E2FF style="text-align:right;">2</td><td  bgcolor=#C6E2FF style="text-align:right;">3</td><td  bgcolor=#C6E2FF style="text-align:right;">6</td><td  bgcolor=#C6E2FF style="text-align:right;">11</td>
    7676</tr>
    7777<tr>
    78 <th  bgcolor=#FFFFFF style="text-align:left;"> Java </th><td  bgcolor=#FFFFFF style="text-align:right;">5</td><td  bgcolor=#FFFFFF style="text-align:right;">17</td><td  bgcolor=#FFFFFF style="text-align:right;">42</td><td  bgcolor=#FFFFFF style="text-align:right;">61</td><td  bgcolor=#FFFFFF style="text-align:right;">120</td>
    79 </tr>
    80 <tr>
    81 <th  bgcolor=#C6E2FF style="text-align:left;"> D </th><td  bgcolor=#C6E2FF style="text-align:right;">7</td><td  bgcolor=#C6E2FF style="text-align:right;">3</td><td  bgcolor=#C6E2FF style="text-align:right;">0</td><td  bgcolor=#C6E2FF style="text-align:right;">27</td><td  bgcolor=#C6E2FF style="text-align:right;">30</td>
    82 </tr>
    83 <tr>
    84 <th  bgcolor=#FFFFFF style="text-align:left;"> C </th><td  bgcolor=#FFFFFF style="text-align:right;">3</td><td  bgcolor=#FFFFFF style="text-align:right;">4</td><td  bgcolor=#FFFFFF style="text-align:right;">35</td><td  bgcolor=#FFFFFF style="text-align:right;">21</td><td  bgcolor=#FFFFFF style="text-align:right;">60</td>
    85 </tr>
    86 <tr>
    87 <th  bgcolor=#C6E2FF style="text-align:left;"> SUM: </th><td  bgcolor=#C6E2FF style="text-align:right;">1915</td><td  bgcolor=#C6E2FF style="text-align:right;">25906</td><td  bgcolor=#C6E2FF style="text-align:right;">33869</td><td  bgcolor=#C6E2FF style="text-align:right;">107321</td><td  bgcolor=#C6E2FF style="text-align:right;">167096</td>
     78<th  bgcolor=#FFFFFF style="text-align:left;"> SUM: </th><td  bgcolor=#FFFFFF style="text-align:right;">1890</td><td  bgcolor=#FFFFFF style="text-align:right;">25787</td><td  bgcolor=#FFFFFF style="text-align:right;">33397</td><td  bgcolor=#FFFFFF style="text-align:right;">106984</td><td  bgcolor=#FFFFFF style="text-align:right;">166168</td>
    8879</tr>
    8980</table>
  • issm/trunk/src/m/classes/autodiff.m

    r11995 r12706  
    2222
    2323                end % }}}
    24                 function checkconsistency(obj,md,solution,analyses) % {{{
     24                function md = checkconsistency(obj,md,solution,analyses) % {{{
    2525
    2626                end % }}}
  • issm/trunk/src/m/classes/balancethickness.m

    r11995 r12706  
    2525
    2626                end % }}}
    27                 function checkconsistency(obj,md,solution,analyses) % {{{
     27                function md = checkconsistency(obj,md,solution,analyses) % {{{
    2828                        %Early return
    2929                        if solution~=BalancethicknessSolutionEnum, return; end
    3030
    31                         checkfield(md,'balancethickness.spcthickness','forcing',1);
    32                         checkfield(md,'balancethickness.thickening_rate','size',[md.mesh.numberofvertices 1],'NaN',1);
    33                         checkfield(md,'balancethickness.stabilization','size',[1 1],'values',[0 1 2 3]);
     31                        md = checkfield(md,'balancethickness.spcthickness','forcing',1);
     32                        md = checkfield(md,'balancethickness.thickening_rate','size',[md.mesh.numberofvertices 1],'NaN',1);
     33                        md = checkfield(md,'balancethickness.stabilization','size',[1 1],'values',[0 1 2 3]);
    3434                end % }}}
    3535                function disp(obj) % {{{
  • issm/trunk/src/m/classes/bamggeom.m

    r8587 r12706  
    66classdef bamggeom
    77        properties (SetAccess=public)
    8                 % {{{1
     8                % {{{
    99                Vertices=[];
    1010                Edges=[];
     
    1818        end
    1919        methods
    20                 function bg = bamggeom(varargin)% {{{1
     20                function bg = bamggeom(varargin)% {{{
    2121                %BAMGGEOM - constructor for bamggeom object
    2222                %
     
    4444                        end
    4545                end%}}}
    46                 function display(bg)% {{{1
     46                function display(bg)% {{{
    4747                        disp(sprintf('\n%s = \n',inputname(1)));
    4848                        disp(struct(bg))
  • issm/trunk/src/m/classes/bamgmesh.m

    r8587 r12706  
    66classdef bamgmesh
    77        properties (SetAccess=public)
    8                 % {{{1
     8                % {{{
    99                Vertices=[];
    1010                Edges=[];
     
    2626        end
    2727        methods
    28                 function bg = bamgmesh(varargin)% {{{1
     28                function bg = bamgmesh(varargin)% {{{
    2929
    3030                switch nargin
     
    4848                        end
    4949                end%}}}
    50                 function display(bm)% {{{1
     50                function display(bm)% {{{
    5151                        disp(sprintf('\n%s = \n',inputname(1)));
    5252                        disp(struct(bm))
  • issm/trunk/src/m/classes/basalforcings.m

    r11995 r12706  
    2222
    2323                end % }}}
    24                 function checkconsistency(obj,md,solution,analyses) % {{{
     24                function md = checkconsistency(obj,md,solution,analyses) % {{{
    2525
    2626                        if ismember(PrognosticAnalysisEnum,analyses) & ~(solution==TransientSolutionEnum & md.transient.isprognostic==0),
    27                                 checkfield(md,'basalforcings.melting_rate','NaN',1,'forcing',1);
     27                                md = checkfield(md,'basalforcings.melting_rate','NaN',1,'forcing',1);
    2828                        end
    2929                        if ismember(BalancethicknessAnalysisEnum,analyses),
    30                                 checkfield(md,'basalforcings.melting_rate','NaN',1,'size',[md.mesh.numberofvertices 1]);
     30                                md = checkfield(md,'basalforcings.melting_rate','NaN',1,'size',[md.mesh.numberofvertices 1]);
    3131                        end
    3232                        if ismember(ThermalAnalysisEnum,analyses) & ~(solution==TransientSolutionEnum & md.transient.isthermal==0),
    33                                 checkfield(md,'basalforcings.melting_rate','NaN',1,'forcing',1);
    34                                 checkfield(md,'basalforcings.geothermalflux','NaN',1,'forcing',1,'>=',0);
     33                                md = checkfield(md,'basalforcings.melting_rate','NaN',1,'forcing',1);
     34                                md = checkfield(md,'basalforcings.geothermalflux','NaN',1,'forcing',1,'>=',0);
    3535                        end
    3636                end % }}}
  • issm/trunk/src/m/classes/clusters/acenet.m

    r12293 r12706  
    88classdef acenet
    99    properties (SetAccess=public)
    10                  % {{{1
     10                 % {{{
    1111                 name='glacdyn.ace-net.ca'
    1212                 %name='placentia.ace-net.ca'
     
    2323         end
    2424         methods
    25                  function cluster=acenet(varargin) % {{{1
     25                 function cluster=acenet(varargin) % {{{
    2626                         %use provided options to change fields
    2727                         options=pairoptions(varargin{:});
     
    3434                 end
    3535                 %}}}
    36                  function disp(cluster) % {{{1
     36                 function disp(cluster) % {{{
    3737                         %  display the object
    3838                         disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
     
    4747                 end
    4848                 %}}}
    49                  function checkconsistency(cluster,md,solution,analyses) % {{{1
     49                 function md = checkconsistency(cluster,md,solution,analyses) % {{{
    5050
    5151                         available_queues={'debug','shortq','longq'};
     
    5656                 end
    5757                 %}}}
    58                  function BuildQueueScript(cluster,md) % {{{1
     58                 function BuildQueueScript(cluster,modelname,solution,io_gather,isvalgrind,isgprof) % {{{
    5959
    60                          %retrieve parameters
    61                          modelname=md.miscellaneous.name;
    62                          solution=md.private.solution;
     60                         if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
     61                         if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
    6362
    64                          %open file for writing:
     63                         %write queuing script
    6564                         fid=fopen([modelname '.queue'],'w');
    66 
    67           %write instructions for launching a job on the cluster
    68           % fprintf(fid,'#!/bin/sh\n');
    6965                         fprintf(fid,'#!/bin/bash\n');
    70           %fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s 2> %s.errlog >%s.outlog ',...
    71           %         cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
    7266                         fprintf(fid,'#$ -cwd\n');
    7367          fprintf(fid,'#$ -N issm\n');
    74           %fprintf(fid,'#$ -l h_rt=%i\n',cluster.time);
    7568          fprintf(fid,'#$ -l h_rt=10:0:0\n');
    76           %fprintf(fid,'#$ -l h_rt=1:0:0,test=true\n');
    7769          fprintf(fid,'#$ -pe ompi* %i\n',cluster.np);
    7870          fprintf(fid,'#$ -j y\n');
     
    8173          fprintf(fid,'module load issm\n');
    8274          fprintf(fid,'\n');
    83           %fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s',cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
    8475          fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s 2> %s.errlog >%s.outlog ',...
    8576                   cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
    86 
    87           % fprintf(fid,'#PBS -l select=%i:ncpus=1\n',cluster.np);
    88                          % fprintf(fid,'#PBS -N %s\n',modelname);
    89                          % fprintf(fid,'#PBS -l walltime=%i\n',time*60); %walltime is in seconds.
    90                          % fprintf(fid,'#PBS -q %s\n',queue);
    91                          % fprintf(fid,'#PBS -o %s.outlog \n',modelname);
    92                          % fprintf(fid,'#PBS -e %s.errlog \n',modelname);
    93                          % fprintf(fid,'export PBS_O_WORKDIR=%s\n',cluster.executionpath);
    94                          % fprintf(fid,'cd $PBS_O_WORKDIR\n');
    95                          % fprintf(fid,'export OMP_NUM_THREADS=1\n');
    96                          % fprintf(fid,'ulimit -s unlimited\n');
    97                          % fprintf(fid,'ulimit -c 0\n');
    98                          % fprintf(fid,'/opt/mpich/gm/intel10.1/bin/mpiexec -np %i %s/issm.exe %s %s %s',cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
    99 
    100                          %close file
    10177                         fclose(fid);
    10278
    10379                 end
    10480                 %}}}
    105                  function LaunchQueueJob(cluster,md,options)% {{{1
    106                           %retrieve parameters
    107           modelname=md.miscellaneous.name;
    108           solution=md.private.solution;
     81                 function LaunchQueueJob(cluster,modelname,dirname,filelist)% {{{
    10982
    110                          %lauch command, to be executed via ssh
    111                          launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' md.private.runtimename ' && mkdir ' md.private.runtimename ...
    112                                         ' && cd ' md.private.runtimename ' && mv ../' md.private.runtimename '.tar.gz ./ && tar -zxf ' md.private.runtimename '.tar.gz  && qsub ' modelname '.queue '];
     83                         %compress the files into one zip.
     84                         compressstring=['tar -zcf ' dirname '.tar.gz '];
     85                         for i=1:numel(filelist),
     86                                 compressstring = [compressstring ' ' filelist{i}];
     87                         end
     88                         if cluster.interactive,
     89                                 compressstring = [compressstring ' ' modelname '.errlog ' modelname '.outlog '];
     90                         end
     91                         system(compressstring);
    11392
    114                         if ~strcmpi(options.batch,'yes'),
    115                                
    116                                 %compress the files into one zip.
    117                                 compressstring=['tar -zcf ' md.private.runtimename '.tar.gz ' md.miscellaneous.name '.bin ' md.miscellaneous.name '.queue '  md.miscellaneous.name '.petsc '];
    118                                 if md.qmu.isdakota,
    119                                         compressstring=[compressstring md.miscellaneous.name '.qmu.in'];
    120                                 end
    121                                 system(compressstring);
    122                                
    123                                 disp('uploading input file and queueing script');
    124                                 issmscpout(md.cluster.name,md.cluster.executionpath,md.cluster.login,md.cluster.port,{[md.private.runtimename '.tar.gz']});
    125                                
    126                                 disp('launching solution sequence on remote cluster');
    127                                 issmssh(md.cluster.name,md.cluster.login,md.cluster.port,launchcommand);
     93                         disp('uploading input file and queueing script');
     94                         issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
    12895
    129                         else
    130                                 disp('batch mode requested: not launching job interactively');
    131                                 disp('launch solution sequence on remote cluster by hand');
    132                         end
     96                         disp('launching solution sequence on remote cluster');
     97                         launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
     98                                 ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && qsub ' modelname '.queue '];
     99                         issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
     100                 end %}}}
     101                 function Download(cluster,dirname,filelist)% {{{
    133102
    134                  end
    135                  %}}}
    136                  function Download(cluster,md)% {{{1
     103                         %copy files from cluster to current directory
     104                         directory=[cluster.executionpath '/' dirname '/'];
     105                         issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
    137106
    138                         %some check
    139                         if isempty(md.private.runtimename),
    140                                 error('pfe Download error message: supply runtime name for results to be loaded!');
    141                         end
    142 
    143                         %Figure out the  directory where all the files are in:
    144                         directory=[cluster.executionpath '/' md.private.runtimename '/'];
    145 
    146                         %What packages are we picking up from remote cluster
    147                         packages={[md.miscellaneous.name '.outlog'],[md.miscellaneous.name '.errlog']};
    148                         %packages={};
    149                         if md.qmu.isdakota,
    150                                 packages{end+1}=[md.miscellaneous.name '.qmu.err'];
    151                                 packages{end+1}=[md.miscellaneous.name '.qmu.out'];
    152                                 if isfield(md.qmu.params,'tabular_graphics_data'),
    153                                         if md.qmu.params.tabular_graphics_data==true,
    154                                                 packages{end+1}='dakota_tabular.dat';
    155                                         end
    156                                 end
    157                         else
    158                                 packages{end+1}=[md.miscellaneous.name '.outbin'];
    159                         end
    160 
    161                         %copy files from cluster to present directory
    162                         issmscpin(cluster.name, cluster.login, cluster.port, directory, packages);
    163                 end %}}}
     107                 end %}}}
    164108        end
    165109end
  • issm/trunk/src/m/classes/clusters/castor.m

    r11995 r12706  
    88classdef castor
    99    properties (SetAccess=public)
    10                  % {{{1
     10                 % {{{
    1111                 name='castor'
    1212                 login='username';
     
    2020         end
    2121         methods
    22                  function cluster=castor(varargin) % {{{1
     22                 function cluster=castor(varargin) % {{{
    2323                         cluster=AssignObjectFields(pairoptions(varargin{:}),cluster);
    2424                 end
    2525                 %}}}
    26                  function disp(cluster) % {{{1
     26                 function disp(cluster) % {{{
    2727                         %  display the object
    2828                         disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
     
    3737                 end
    3838                 %}}}
    39                  function checkconsistency(cluster,md,solution,analyses) % {{{1
     39                 function md = checkconsistency(cluster,md,solution,analyses) % {{{
    4040
    4141                         available_queues={'shortc','longc'};
     
    4646                 end
    4747                 %}}}
    48                  function BuildQueueScript(cluster,md) % {{{1
     48                 function BuildQueueScript(cluster,modelname,solution,io_gather,isvalgrind,isgprof) % {{{
    4949
    50                          %retrieve parameters
    51                          modelname=md.miscellaneous.name;
    52                          solution=md.private.solution;
     50                         if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
     51                         if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
    5352
    54                          %open file for writing:
     53                         %write queuing script
    5554                         fid=fopen([modelname '.queue'],'w');
    56 
    5755                         fprintf(fid,'#!/bin/sh\n');
    5856                         fprintf(fid,'#PBS -l walltime=%i\n',cluster.time*60); %walltime is in seconds.
     
    6462                         fprintf(fid,'#PBS -o %s.outlog \n',modelname);
    6563                         fprintf(fid,'#PBS -e %s.errlog \n',modelname);
    66 
    6764                         fprintf(fid,'export PBS_O_WORKDIR=%s\n',cluster.executionpath);
    6865                         fprintf(fid,'cd $PBS_O_WORKDIR\n');
    6966                         fprintf(fid,'export OMP_NUM_THREADS=1\n');
    7067                         fprintf(fid,'dplace -s1 -c0-%i mpiexec -np %i %s/issm.exe %s %s %s',cluster.np-1,cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
    71 
    72                          %close file
    7368                         fclose(fid);
    7469
    7570                 end
    7671                 %}}}
    77                  function LaunchQueueJob(cluster,md,options)% {{{1
    78                          
    79                          %lauch command, to be executed via ssh
    80                          launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' md.private.runtimename ' && mkdir ' md.private.runtimename ...
    81                                         ' && cd ' md.private.runtimename ' && mv ../' md.private.runtimename '.tar.gz ./ && tar -zxf ' md.private.runtimename '.tar.gz  && qsub ' modelname '.queue '];
     72                 function LaunchQueueJob(cluster,modelname,dirname,filelist)% {{{
    8273
    83                         if ~strcmpi(options.batch,'yes'),
    84                                
    85                                 %compress the files into one zip.
    86                                 compressstring=['tar -zcf ' md.private.runtimename '.tar.gz ' md.miscellaneous.name '.bin ' md.miscellaneous.name '.queue '  md.miscellaneous.name '.petsc '];
    87                                 if md.qmu.isdakota,
    88                                         compressstring=[compressstring md.miscellaneous.name '.qmu.in'];
    89                                 end
    90                                 system(compressstring);
    91                                
    92                                 disp('uploading input file and queueing script');
    93                                 issmscpout(md.cluster.name,md.cluster.executionpath,md.cluster.login,md.cluster.port,{[md.private.runtimename '.tar.gz']});
    94                                
    95                                 disp('launching solution sequence on remote cluster');
    96                                 issmssh(md.cluster.name,md.cluster.login,md.cluster.port,launchcommand);
     74                         %compress the files into one zip.
     75                         compressstring=['tar -zcf ' dirname '.tar.gz '];
     76                         for i=1:numel(filelist),
     77                                 compressstring = [compressstring ' ' filelist{i}];
     78                         end
     79                         if cluster.interactive,
     80                                 compressstring = [compressstring ' ' modelname '.errlog ' modelname '.outlog '];
     81                         end
     82                         system(compressstring);
    9783
    98                         else
    99                                 disp('batch mode requested: not launching job interactively');
    100                                 disp('launch solution sequence on remote cluster by hand');
    101                         end
     84                         disp('uploading input file and queueing script');
     85                         issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
    10286
    103                  end
    104                  %}}}
    105                  function Download(cluster,md)% {{{1
     87                         disp('launching solution sequence on remote cluster');
     88                         launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
     89                                 ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && qsub ' modelname '.queue '];
     90                         issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
     91                 end %}}}
     92                 function Download(cluster,dirname,filelist)% {{{
    10693
    107                         %some check
    108                         if isempty(md.private.runtimename),
    109                                 error('pfe Download error message: supply runtime name for results to be loaded!');
    110                         end
     94                         %copy files from cluster to current directory
     95                         directory=[cluster.executionpath '/' dirname '/'];
     96                         issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
    11197
    112                         %Figure out the  directory where all the files are in:
    113                         directory=[cluster.executionpath '/' md.private.runtimename '/'];
    114 
    115                         %What packages are we picking up from remote cluster
    116                         packages={[md.miscellaneous.name '.outlog'],[md.miscellaneous.name '.errlog']};
    117                         if md.qmu.isdakota,
    118                                 packages{end+1}=[md.miscellaneous.name '.qmu.err'];
    119                                 packages{end+1}=[md.miscellaneous.name '.qmu.out'];
    120                                 if isfield(md.qmu.params,'tabular_graphics_data'),
    121                                         if md.qmu.params.tabular_graphics_data==true,
    122                                                 packages{end+1}='dakota_tabular.dat';
    123                                         end
    124                                 end
    125                         else
    126                                 packages{end+1}=[md.miscellaneous.name '.outbin'];
    127                         end
    128 
    129                         %copy files from cluster to present directory
    130                         issmscpin(cluster.name, cluster.login, cluster.port, directory, packages);
    131                 end %}}}
     98                 end %}}}
    13299        end
    133100end
  • issm/trunk/src/m/classes/clusters/cosmos.m

    r11995 r12706  
    88classdef cosmos
    99    properties (SetAccess=public)
    10                  % {{{1
     10                 % {{{
    1111                 name='cosmos'
    1212                 login='username';
     
    2020         end
    2121         methods
    22                  function cluster=cosmos(varargin) % {{{1
     22                 function cluster=cosmos(varargin) % {{{
    2323                         cluster=AssignObjectFields(pairoptions(varargin{:}),cluster);
    2424                 end
    2525                 %}}}
    26                  function disp(cluster) % {{{1
     26                 function disp(cluster) % {{{
    2727                         %  display the object
    2828                         disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
     
    3737                 end
    3838                 %}}}
    39                  function checkconsistency(cluster,md,solution,analyses) % {{{1
     39                 function md = checkconsistency(cluster,md,solution,analyses) % {{{
    4040
    4141                         available_queues={'debug','shortq','longq'};
     
    4646                 end
    4747                 %}}}
    48                  function BuildQueueScript(cluster,md) % {{{1
     48                 function BuildQueueScript(cluster,modelname,solution,io_gather,isvalgrind,isgprof) % {{{
    4949
    50                          %retrieve parameters
    51                          modelname=md.miscellaneous.name;
    52                          solution=md.private.solution;
     50                         if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
     51                         if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
    5352
    54                          %open file for writing:
     53                         %write queuing script
    5554                         fid=fopen([modelname '.queue'],'w');
    56 
    5755                         fprintf(fid,'#!/bin/bash\n');
    5856                         fprintf(fid,'#PBS -l select=%i:ncpus=1\n',cluster.np);
     
    6866                         fprintf(fid,'ulimit -c 0\n');
    6967                         fprintf(fid,'/opt/mpich/gm/intel10.1/bin/mpiexec -np %i %s/issm.exe %s %s %s',cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
    70 
    71                          %close file
    7268                         fclose(fid);
    7369
    7470                 end
    7571                 %}}}
    76                  function LaunchQueueJob(cluster,md,options)% {{{1
    77                          
    78                          %lauch command, to be executed via ssh
    79                          launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' md.private.runtimename ' && mkdir ' md.private.runtimename ...
    80                                         ' && cd ' md.private.runtimename ' && mv ../' md.private.runtimename '.tar.gz ./ && tar -zxf ' md.private.runtimename '.tar.gz  && qsub -S/bin/sh ' modelname '.queue '];
     72                 function LaunchQueueJob(cluster,modelname,dirname,filelist)% {{{
    8173
    82                         if ~strcmpi(options.batch,'yes'),
    83                                
    84                                 %compress the files into one zip.
    85                                 compressstring=['tar -zcf ' md.private.runtimename '.tar.gz ' md.miscellaneous.name '.bin ' md.miscellaneous.name '.queue '  md.miscellaneous.name '.petsc '];
    86                                 if md.qmu.isdakota,
    87                                         compressstring=[compressstring md.miscellaneous.name '.qmu.in'];
    88                                 end
    89                                 system(compressstring);
    90                                
    91                                 disp('uploading input file and queueing script');
    92                                 issmscpout(md.cluster.name,md.cluster.executionpath,md.cluster.login,md.cluster.port,{[md.private.runtimename '.tar.gz']});
    93                                
    94                                 disp('launching solution sequence on remote cluster');
    95                                 issmssh(md.cluster.name,md.cluster.login,md.cluster.port,launchcommand);
     74                         %compress the files into one zip.
     75                         compressstring=['tar -zcf ' dirname '.tar.gz '];
     76                         for i=1:numel(filelist),
     77                                 compressstring = [compressstring ' ' filelist{i}];
     78                         end
     79                         if cluster.interactive,
     80                                 compressstring = [compressstring ' ' modelname '.errlog ' modelname '.outlog '];
     81                         end
     82                         system(compressstring);
    9683
    97                         else
    98                                 disp('batch mode requested: not launching job interactively');
    99                                 disp('launch solution sequence on remote cluster by hand');
    100                         end
     84                         disp('uploading input file and queueing script');
     85                         issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
    10186
    102                  end
    103                  %}}}
    104                  function Download(cluster,md)% {{{1
     87                         disp('launching solution sequence on remote cluster');
     88                         launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
     89                                 ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && qsub ' modelname '.queue '];
     90                         issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
     91                 end %}}}
     92                 function Download(cluster,dirname,filelist)% {{{
    10593
    106                         %some check
    107                         if isempty(md.private.runtimename),
    108                                 error('pfe Download error message: supply runtime name for results to be loaded!');
    109                         end
     94                         %copy files from cluster to current directory
     95                         directory=[cluster.executionpath '/' dirname '/'];
     96                         issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
    11097
    111                         %Figure out the  directory where all the files are in:
    112                         directory=[cluster.executionpath '/' md.private.runtimename '/'];
    113 
    114                         %What packages are we picking up from remote cluster
    115                         packages={[md.miscellaneous.name '.outlog'],[md.miscellaneous.name '.errlog']};
    116                         if md.qmu.isdakota,
    117                                 packages{end+1}=[md.miscellaneous.name '.qmu.err'];
    118                                 packages{end+1}=[md.miscellaneous.name '.qmu.out'];
    119                                 if isfield(md.qmu.params,'tabular_graphics_data'),
    120                                         if md.qmu.params.tabular_graphics_data==true,
    121                                                 packages{end+1}='dakota_tabular.dat';
    122                                         end
    123                                 end
    124                         else
    125                                 packages{end+1}=[md.miscellaneous.name '.outbin'];
    126                         end
    127 
    128                         %copy files from cluster to present directory
    129                         issmscpin(cluster.name, cluster.login, cluster.port, directory, packages);
    130                 end %}}}
     98                 end %}}}
    13199        end
    132100end
  • issm/trunk/src/m/classes/clusters/gemini.m

    r11995 r12706  
    88classdef gemini
    99    properties (SetAccess=public)
    10         % {{{1
     10        % {{{
    1111                name='gemini'
    1212                login='username';
     
    2020    end
    2121    methods
    22                  function cluster=gemini(varargin) % {{{1
     22                 function cluster=gemini(varargin) % {{{
    2323                         cluster=AssignObjectFields(pairoptions(varargin{:}),cluster);
    2424                 end
    2525                 %}}}
    26                  function disp(cluster) % {{{1
     26                 function disp(cluster) % {{{
    2727                         %  display the object
    2828                         disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
     
    3737                 end
    3838                 %}}}
    39                  function checkconsistency(cluster,md,solution,analyses) % {{{1
     39                 function md = checkconsistency(cluster,md,solution,analyses) % {{{
    4040
    4141                         available_queues={'debug','shortg','longg'};
     
    4646                 end
    4747                 %}}}
    48                  function BuildQueueScript(cluster,md) % {{{1
     48                 function BuildQueueScript(cluster,modelname,solution,io_gather,isvalgrind,isgprof) % {{{
    4949
    50                          %retrieve parameters
    51                          modelname=md.miscellaneous.name;
    52                          solution=md.private.solution;
     50                         if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
     51                         if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
    5352
    54                          %open file for writing:
     53                         %write queuing script
    5554                         fid=fopen([modelname '.queue'],'w');
    56 
    5755                         fprintf(fid,'#!/bin/sh\n');
    5856                         fprintf(fid,'#PBS -l walltime=%i\n',cluster.time*60); %walltime is in seconds.
     
    6967                         fprintf(fid,'export OMP_NUM_THREADS=1\n');
    7068                         fprintf(fid,'dplace -s1 -c0-%i mpiexec -np %i %s/issm.exe %s %s %s',cluster.np-1,cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
    71 
    72                          %close file
    7369                         fclose(fid);
    7470
    7571                 end
    7672                 %}}}
    77                  function LaunchQueueJob(cluster,md,options)% {{{1
    78                          
    79                          %lauch command, to be executed via ssh
    80                          launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' md.private.runtimename ' && mkdir ' md.private.runtimename ...
    81                                         ' && cd ' md.private.runtimename ' && mv ../' md.private.runtimename '.tar.gz ./ && tar -zxf ' md.private.runtimename '.tar.gz  && qsub ' modelname '.queue '];
     73                 function LaunchQueueJob(cluster,modelname,dirname,filelist)% {{{
    8274
    83                         if ~strcmpi(options.batch,'yes'),
    84                                
    85                                 %compress the files into one zip.
    86                                 compressstring=['tar -zcf ' md.private.runtimename '.tar.gz ' md.miscellaneous.name '.bin ' md.miscellaneous.name '.queue '  md.miscellaneous.name '.petsc '];
    87                                 if md.qmu.isdakota,
    88                                         compressstring=[compressstring md.miscellaneous.name '.qmu.in'];
    89                                 end
    90                                 system(compressstring);
    91                                
    92                                 disp('uploading input file and queueing script');
    93                                 issmscpout(md.cluster.name,md.cluster.executionpath,md.cluster.login,md.cluster.port,{[md.private.runtimename '.tar.gz']});
    94                                
    95                                 disp('launching solution sequence on remote cluster');
    96                                 issmssh(md.cluster.name,md.cluster.login,md.cluster.port,launchcommand);
     75                         %compress the files into one zip.
     76                         compressstring=['tar -zcf ' dirname '.tar.gz '];
     77                         for i=1:numel(filelist),
     78                                 compressstring = [compressstring ' ' filelist{i}];
     79                         end
     80                         if cluster.interactive,
     81                                 compressstring = [compressstring ' ' modelname '.errlog ' modelname '.outlog '];
     82                         end
     83                         system(compressstring);
    9784
    98                         else
    99                                 disp('batch mode requested: not launching job interactively');
    100                                 disp('launch solution sequence on remote cluster by hand');
    101                         end
     85                         disp('uploading input file and queueing script');
     86                         issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
    10287
    103                  end
    104                  %}}}
    105                  function Download(cluster,md)% {{{1
     88                         disp('launching solution sequence on remote cluster');
     89                         launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
     90                                 ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && qsub ' modelname '.queue '];
     91                         issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
     92                 end %}}}
     93                 function Download(cluster,dirname,filelist)% {{{
    10694
    107                         %some check
    108                         if isempty(md.private.runtimename),
    109                                 error('pfe Download error message: supply runtime name for results to be loaded!');
    110                         end
     95                         %copy files from cluster to current directory
     96                         directory=[cluster.executionpath '/' dirname '/'];
     97                         issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
    11198
    112                         %Figure out the  directory where all the files are in:
    113                         directory=[cluster.executionpath '/' md.private.runtimename '/'];
    114 
    115                         %What packages are we picking up from remote cluster
    116                         packages={[md.miscellaneous.name '.outlog'],[md.miscellaneous.name '.errlog']};
    117                         if md.qmu.isdakota,
    118                                 packages{end+1}=[md.miscellaneous.name '.qmu.err'];
    119                                 packages{end+1}=[md.miscellaneous.name '.qmu.out'];
    120                                 if isfield(md.qmu.params,'tabular_graphics_data'),
    121                                         if md.qmu.params.tabular_graphics_data==true,
    122                                                 packages{end+1}='dakota_tabular.dat';
    123                                         end
    124                                 end
    125                         else
    126                                 packages{end+1}=[md.miscellaneous.name '.outbin'];
    127                         end
    128 
    129                         %copy files from cluster to present directory
    130                         issmscpin(cluster.name, cluster.login, cluster.port, directory, packages);
    131                 end %}}}
     99                 end %}}}
    132100        end
    133101end
  • issm/trunk/src/m/classes/clusters/generic.m

    r12329 r12706  
    77classdef generic
    88    properties (SetAccess=public)
    9                  % {{{1
     9                 % {{{
    1010                 name='';
    1111                 login='';
     
    2121         end
    2222         methods
    23                  function cluster=generic(varargin) % {{{1
     23                 function cluster=generic(varargin) % {{{
    2424
    2525                         %use provided options to change fields
     
    3636                 end
    3737                 %}}}
    38                  function disp(cluster) % {{{1
     38                 function disp(cluster) % {{{
    3939                         %  display the object
    4040                         disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
     
    5050                 end
    5151                 %}}}
    52                  function checkconsistency(cluster,md,solution,analyses) % {{{1
     52                 function md = checkconsistency(cluster,md,solution,analyses) % {{{
    5353                         if cluster.np<1
    54                                  checkmessage(['number of processors should be at least 1']);
     54                                 md = checkmessage(md,['number of processors should be at least 1']);
    5555                         end
    5656                         if isnan(cluster.np),
     
    5959                 end
    6060                 %}}}
    61                  function BuildQueueScript(cluster,md) % {{{1
    62                  
    63                          %retrieve parameters
    64                          modelname=md.miscellaneous.name;
    65                          solution=md.private.solution;
    66                          isvalgrind=md.debug.valgrind;
    67                          isgprof=md.debug.gprof;
     61                 function BuildQueueScript(cluster,modelname,solution,io_gather,isvalgrind,isgprof) % {{{
    6862
    69                          %open file for writing:
     63                         %write queuing script
    7064                         if ~ispc,
     65
    7166                                 fid=fopen([modelname '.queue'],'w');
    72                          else
    73                                  fid=fopen([modelname '.bat'],'w');
    74                          end
    75 
    76                          %write instructions for launching a job on the cluster
    77                          if ~ispc,
    7867                                 fprintf(fid,'#!/bin/sh\n');
    79                          else
    80                                  fprintf(fid,'@echo off\n');
    81                          end
    82                          
    83                          if ~isvalgrind,
    84                                  if cluster.interactive
    85                                          if ~ispc,
     68                                 if ~isvalgrind,
     69                                         if cluster.interactive
    8670                                                 fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s ',cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
    8771                                         else
    88                                                  fprintf(fid,'"%s/issm.exe" %s "%s" %s ',cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
     72                                                 fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s 2> %s.errlog >%s.outlog ',cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
    8973                                         end
     74                                 elseif isgprof,
     75                                         fprintf(fid,'\n gprof %s/issm.exe gmon.out > %s.performance',cluster.codepath,modelname);
    9076                                 else
    91                                          if ~ispc,
    92                                                  fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s 2> %s.errlog >%s.outlog ',cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
    93                                          else
    94                                                  fprintf(fid,'"%s/issm.exe" %s "%s" %s 2> %s.errlog >%s.outlog ',cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
    95                                          end
    96                                  end
    97                          else
    98                                  if ~ispc,
    9977                                         %Add --gen-suppressions=all to get suppression lines
    10078                                         fprintf(fid,'LD_PRELOAD=%s \\\n',cluster.valgrindlib);
    10179                                         fprintf(fid,'mpiexec -np %i %s --leak-check=full --suppressions=%s %s/issm.exe %s %s %s 2> %s.errlog >%s.outlog ',...
    102                                          cluster.np,cluster.valgrind,cluster.valgrindsup, cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
     80                                                 cluster.np,cluster.valgrind,cluster.valgrindsup,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
     81                                 end
     82                                 if ~io_gather, %concatenate the output files:
     83                                         fprintf(fid,'\ncat %s.outbin.* > %s.outbin',modelname,modelname);
     84                                 end
     85                                 fclose(fid);
     86
     87                         else % Windows
     88
     89                                 fid=fopen([modelname '.bat'],'w');
     90                                 fprintf(fid,'@echo off\n');
     91                                 if cluster.interactive
     92                                         fprintf(fid,'"%s/issm.exe" %s "%s" %s ',cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
    10393                                 else
    104                                          error('valgrind not supported on windows platforms');
     94                                         fprintf(fid,'"%s/issm.exe" %s "%s" %s 2> %s.errlog >%s.outlog',...
     95                                                 cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
    10596                                 end
     97                                 fclose(fid);
    10698                         end
    107 
    108                          if isgprof,
    109                                  if ~ispc,
    110                                          fprintf(fid,'\n gprof %s/issm.exe gmon.out > %s.performance',cluster.codepath,modelname);
    111                                  else
    112                                          error('gprof not supported on windows platforms');
    113                                  end
    114 
    115                          end
    116 
    117                          if ~md.settings.io_gather,
    118                                  if ~ispc,
    119                                          %concatenate the output files:
    120                                          fprintf(fid,'\ncat %s.outbin.* > %s.outbin',modelname,modelname);
    121                                  else
    122                                          error('iogather not supported on windows platforms');
    123                                  end
    124 
    125                          end
    126                          
    127                          %close file:
    128                          fclose(fid);
    12999
    130100                         %in interactive mode, create a run file, and errlog and outlog file
     
    133103                                 fid=fopen([modelname '.outlog'],'w'); fclose(fid);
    134104                         end
    135 
    136 
    137105                 end
    138106                 %}}}
    139                  function LaunchQueueJob(cluster,md,options)% {{{1
    140                          
     107                 function BuildKrigingQueueScript(cluster,modelname,solution,io_gather,isvalgrind,isgprof) % {{{
     108
     109                         %write queuing script
    141110                         if ~ispc,
    142                                          %lauch command, to be executed via ssh
    143                                          launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' md.private.runtimename ' && mkdir ' md.private.runtimename ...
    144                                          ' && cd ' md.private.runtimename ' && mv ../' md.private.runtimename '.tar.gz ./ && tar -zxf ' md.private.runtimename '.tar.gz  && source  ' md.miscellaneous.name '.queue '];
    145111
    146                                          if ~strcmpi(options.batch,'yes'),
     112                                 fid=fopen([modelname '.queue'],'w');
     113                                 fprintf(fid,'#!/bin/sh\n');
     114                                 if ~isvalgrind,
     115                                         if cluster.interactive
     116                                                 fprintf(fid,'mpiexec -np %i %s/kriging.exe %s %s ',cluster.np,cluster.codepath,cluster.executionpath,modelname);
     117                                         else
     118                                                 fprintf(fid,'mpiexec -np %i %s/kriging.exe %s %s 2> %s.errlog >%s.outlog ',cluster.np,cluster.codepath,cluster.executionpath,modelname,modelname,modelname);
     119                                         end
     120                                 elseif isgprof,
     121                                         fprintf(fid,'\n gprof %s/kriging.exe gmon.out > %s.performance',cluster.codepath,modelname);
     122                                 else
     123                                         %Add --gen-suppressions=all to get suppression lines
     124                                         fprintf(fid,'LD_PRELOAD=%s \\\n',cluster.valgrindlib);
     125                                         fprintf(fid,'mpiexec -np %i %s --leak-check=full --suppressions=%s %s/kriging.exe %s %s 2> %s.errlog >%s.outlog ',...
     126                                                 cluster.np,cluster.valgrind,cluster.valgrindsup,cluster.codepath,cluster.executionpath,modelname,modelname,modelname);
     127                                 end
     128                                 if ~io_gather, %concatenate the output files:
     129                                         fprintf(fid,'\ncat %s.outbin.* > %s.outbin',modelname,modelname);
     130                                 end
     131                                 fclose(fid);
    147132
    148                                                  %compress the files into one zip.
    149                                                  compressstring=['tar -zcf ' md.private.runtimename '.tar.gz ' md.miscellaneous.name '.bin ' md.miscellaneous.name '.queue '  md.miscellaneous.name '.petsc '];
    150                                                  if md.qmu.isdakota,
    151                                                          compressstring=[compressstring md.miscellaneous.name '.qmu.in'];
    152                                         end
    153                                         if cluster.interactive,
    154                                                 compressstring=[compressstring ' ' md.miscellaneous.name '.errlog ' md.miscellaneous.name '.outlog '];
    155                                         end
    156                                         system(compressstring);
     133                         else % Windows
    157134
    158                                         disp('uploading input file and queueing script');
    159                                         issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[md.private.runtimename '.tar.gz']});
     135                                 fid=fopen([modelname '.bat'],'w');
     136                                 fprintf(fid,'@echo off\n');
     137                                 if cluster.interactive
     138                                         fprintf(fid,'"%s/issm.exe" %s "%s" %s ',cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
     139                                 else
     140                                         fprintf(fid,'"%s/issm.exe" %s "%s" %s 2> %s.errlog >%s.outlog',...
     141                                                 cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
     142                                 end
     143                                 fclose(fid);
     144                         end
    160145
    161                                         disp('launching solution sequence on remote cluster');
    162                                         issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
    163                                 else
    164                                         disp('batch mode requested: not launching job interactively');
    165                                         disp('launch solution sequence on remote cluster by hand');
    166                                 end
    167                         else
    168                                 %launch right here, do not compress or archive.
    169                                 system([md.miscellaneous.name '.bat']);
     146                         %in interactive mode, create a run file, and errlog and outlog file
     147                         if cluster.interactive,
     148                                 fid=fopen([modelname '.errlog'],'w'); fclose(fid);
     149                                 fid=fopen([modelname '.outlog'],'w'); fclose(fid);
     150                         end
     151                 end
     152                 %}}}
     153                 function LaunchQueueJob(cluster,modelname,dirname,filelist)% {{{
     154
     155                         %compress the files into one zip.
     156                         compressstring=['tar -zcf ' dirname '.tar.gz '];
     157                         for i=1:numel(filelist),
     158                                 compressstring = [compressstring ' ' filelist{i}];
     159                         end
     160                         if cluster.interactive,
     161                                 compressstring = [compressstring ' ' modelname '.errlog ' modelname '.outlog '];
     162                         end
     163                         system(compressstring);
     164
     165                         disp('uploading input file and queueing script');
     166                         issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
     167
     168                         disp('launching solution sequence on remote cluster');
     169                         launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
     170                                 ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && source  ' modelname '.queue '];
     171                         issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
     172                 end %}}}
     173                 function Download(cluster,dirname,filelist)% {{{
     174
     175                        if ispc,
     176                                %do nothing
     177                                return;
    170178                        end
    171179
    172                 end %}}}
    173                  function Download(cluster,md)% {{{1
    174 
    175                         if ~ispc,
    176                                 %some check
    177                                 if isempty(md.private.runtimename),
    178                                         error('supply runtime name for results to be loaded!');
    179                                 end
    180 
    181                                 %Figure out the  directory where all the files are in:
    182                                 directory=[cluster.executionpath '/' md.private.runtimename '/'];
    183 
    184                                 %What packages are we picking up from remote cluster
    185                                 packages={[md.miscellaneous.name '.outlog'],[md.miscellaneous.name '.errlog']};
    186                                 if md.qmu.isdakota,
    187                                         packages{end+1}=[md.miscellaneous.name '.qmu.err'];
    188                                         packages{end+1}=[md.miscellaneous.name '.qmu.out'];
    189                                         if isfield(md.qmu.params,'tabular_graphics_data'),
    190                                                 if md.qmu.params.tabular_graphics_data==true,
    191                                                         packages{end+1}='dakota_tabular.dat';
    192                                                 end
    193                                         end
    194                                 else
    195                                         packages{end+1}=[md.miscellaneous.name '.outbin'];
    196                                 end
    197 
    198                                 %copy files from cluster to present directory
    199                                 issmscpin(cluster.name, cluster.login, cluster.port, directory, packages);
    200                         else
    201                                 %do nothing!
    202                         end
     180                        %copy files from cluster to current directory
     181                        directory=[cluster.executionpath '/' dirname '/'];
     182                        issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
    203183                end %}}}
    204184        end
  • issm/trunk/src/m/classes/clusters/generic.py

    r12329 r12706  
    3636                return string
    3737                #}}}
    38                
    39 
    40 #old matlab
    41 #               function cluster=generic(varargin) % {{{1
    42 #
    43 #                        %use provided options to change fields
    44 #                        options=pairoptions(varargin{:});
    45 #
    46 #                        %get name
    47 #                        if ~exist(options,'name'), error('option ''name'' has not been provided'); end
    48 #                        cluster.name=getfieldvalue(options,'name');
    49 #
    50 #                        %initialize cluster using user settings if provided
    51 #                        if (exist([cluster.name '_settings'])==2), eval([cluster.name '_settings']); end
    52 #
    53 #                        %OK get other fields
    54 #                        for i=1:size(options.list,1),
    55 #                                fieldname=options.list{i,1};
    56 #                                fieldvalue=options.list{i,2};
    57 #                                if ismember(fieldname,properties('generic')),
    58 #                                        cluster.(fieldname)=fieldvalue;
    59 #                                else
    60 #                                        disp(['''' fieldname ''' is not a property of cluster generic']);
    61 #                                end
    62 #                        end
    63 #                end
    64 #                %}}}
    65 #                function checkconsistency(cluster,md,solution,analyses) % {{{1
    66 #                        if cluster.np<1
    67 #                                checkmessage(['number of processors should be at least 1']);
    68 #                        end
    69 #                        if isnan(cluster.np),
    70 #                                checkessage('number of processors should not be NaN!');
    71 #                        end
    72 #                end
    73 #                %}}}
    74 #                function BuildQueueScript(cluster,md) % {{{1
    75 #               
    76 #                        %retrieve parameters
    77 #                        modelname=md.miscellaneous.name;
    78 #                        solution=md.private.solution;
    79 #                        isvalgrind=md.debug.valgrind;
    80 #                        isgprof=md.debug.gprof;
    81 #
    82 #                        %open file for writing:
    83 #                        if ~ispc,
    84 #                                fid=fopen([modelname '.queue'],'w');
    85 #                        else
    86 #                                fid=fopen([modelname '.bat'],'w');
    87 #                        end
    88 #
    89 #                        %write instructions for launching a job on the cluster
    90 #                        if ~ispc,
    91 #                                fprintf(fid,'#!/bin/sh\n');
    92 #                        else
    93 #                                fprintf(fid,'@echo off\n');
    94 #                        end
    95 #                       
    96 #                        if ~isvalgrind,
    97 #                                if cluster.interactive
    98 #                                        if ~ispc,
    99 #                                                fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s ',cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
    100 #                                        else
    101 #                                                fprintf(fid,'"%s/issm.exe" %s "%s" %s ',cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
    102 #                                        end
    103 #                                else
    104 #                                        if ~ispc,
    105 #                                                fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s 2> %s.errlog >%s.outlog ',cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
    106 #                                        else
    107 #                                                fprintf(fid,'"%s/issm.exe" %s "%s" %s 2> %s.errlog >%s.outlog ',cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
    108 #                                        end
    109 #                                end
    110 #                        else
    111 #                                if ~ispc,
    112 #                                        %Add --gen-suppressions=all to get suppression lines
    113 #                                        fprintf(fid,'LD_PRELOAD=%s \\\n',cluster.valgrindlib);
    114 #                                        fprintf(fid,'mpiexec -np %i %s --leak-check=full --suppressions=%s %s/issm.exe %s %s %s 2> %s.errlog >%s.outlog ',...
    115 #                                        cluster.np,cluster.valgrind,cluster.valgrindsup, cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
    116 #                                else
    117 #                                        error('valgrind not supported on windows platforms');
    118 #                                end
    119 #                        end
    120 #
    121 #                        if isgprof,
    122 #                                if ~ispc,
    123 #                                        fprintf(fid,'\n gprof %s/issm.exe gmon.out > %s.performance',cluster.codepath,modelname);
    124 #                                else
    125 #                                        error('gprof not supported on windows platforms');
    126 #                                end
    127 #
    128 #                        end
    129 #
    130 #                        if ~md.settings.io_gather,
    131 #                                if ~ispc,
    132 #                                        %concatenate the output files:
    133 #                                        fprintf(fid,'\ncat %s.outbin.* > %s.outbin',modelname,modelname);
    134 #                                else
    135 #                                        error('iogather not supported on windows platforms');
    136 #                                end
    137 #
    138 #                        end
    139 #                       
    140 #                        %close file:
    141 #                        fclose(fid);
    142 #
    143 #                        %in interactive mode, create a run file, and errlog and outlog file
    144 #                        if cluster.interactive,
    145 #                                fid=fopen([modelname '.errlog'],'w'); fclose(fid);
    146 #                                fid=fopen([modelname '.outlog'],'w'); fclose(fid);
    147 #                        end
    148 #
    149 #
    150 #                end
    151 #                %}}}
    152 #                function LaunchQueueJob(cluster,md,options)% {{{1
    153 #                       
    154 #                        if ~ispc,
    155 #                                        %lauch command, to be executed via ssh
    156 #                                        launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' md.private.runtimename ' && mkdir ' md.private.runtimename ...
    157 #                                        ' && cd ' md.private.runtimename ' && mv ../' md.private.runtimename '.tar.gz ./ && tar -zxf ' md.private.runtimename '.tar.gz  && source  ' md.miscellaneous.name '.queue '];
    158 #
    159 #                                        if ~strcmpi(options.batch,'yes'),
    160 #
    161 #                                                %compress the files into one zip.
    162 #                                                compressstring=['tar -zcf ' md.private.runtimename '.tar.gz ' md.miscellaneous.name '.bin ' md.miscellaneous.name '.queue '  md.miscellaneous.name '.petsc '];
    163 #                                                if md.qmu.isdakota,
    164 #                                                        compressstring=[compressstring md.miscellaneous.name '.qmu.in'];
    165 #                                       end
    166 #                                       if cluster.interactive,
    167 #                                               compressstring=[compressstring ' ' md.miscellaneous.name '.errlog ' md.miscellaneous.name '.outlog '];
    168 #                                       end
    169 #                                       system(compressstring);
    170 #
    171 #                                       disp('uploading input file and queueing script');
    172 #                                       issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[md.private.runtimename '.tar.gz']});
    173 #
    174 #                                       disp('launching solution sequence on remote cluster');
    175 #                                       issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
    176 #                               else
    177 #                                       disp('batch mode requested: not launching job interactively');
    178 #                                       disp('launch solution sequence on remote cluster by hand');
    179 #                               end
    180 #                       else
    181 #                               %launch right here, do not compress or archive.
    182 #                               system([md.miscellaneous.name '.bat']);
    183 #                       end
    184 #
    185 #               end %}}}
    186 #                function Download(cluster,md)% {{{1
    187 #
    188 #                       if ~ispc,
    189 #                               %some check
    190 #                               if isempty(md.private.runtimename),
    191 #                                       error('supply runtime name for results to be loaded!');
    192 #                               end
    193 #
    194 #                               %Figure out the  directory where all the files are in:
    195 #                               directory=[cluster.executionpath '/' md.private.runtimename '/'];
    196 #
    197 #                               %What packages are we picking up from remote cluster
    198 #                               packages={[md.miscellaneous.name '.outlog'],[md.miscellaneous.name '.errlog']};
    199 #                               if md.qmu.isdakota,
    200 #                                       packages{end+1}=[md.miscellaneous.name '.qmu.err'];
    201 #                                       packages{end+1}=[md.miscellaneous.name '.qmu.out'];
    202 #                                       if isfield(md.qmu.params,'tabular_graphics_data'),
    203 #                                               if md.qmu.params.tabular_graphics_data==true,
    204 #                                                       packages{end+1}='dakota_tabular.dat';
    205 #                                               end
    206 #                                       end
    207 #                               else
    208 #                                       packages{end+1}=[md.miscellaneous.name '.outbin'];
    209 #                               end
    210 #
    211 #                               %copy files from cluster to present directory
    212 #                               issmscpin(cluster.name, cluster.login, cluster.port, directory, packages);
    213 #                       else
    214 #                               %do nothing!
    215 #                       end
    216 #               end %}}}
    217 #
  • issm/trunk/src/m/classes/clusters/greenplanet.m

    r11995 r12706  
    88classdef greenplanet
    99    properties (SetAccess=public) 
    10                  % {{{1
     10                 % {{{
    1111                 name='greenplanet'
    1212                 login='';
     
    2424         end
    2525         methods
    26                  function cluster=greenplanet(varargin) % {{{1
     26                 function cluster=greenplanet(varargin) % {{{
    2727
    2828                         %initialize cluster using default settings if provided
     
    3333                 end
    3434                 %}}}
    35                  function disp(cluster) % {{{1
     35                 function disp(cluster) % {{{
    3636                         %  display the object
    3737                         disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
     
    4848                 end
    4949                 %}}}
    50                  function checkconsistency(cluster,md,solution,analyses) % {{{1
     50                 function md = checkconsistency(cluster,md,solution,analyses) % {{{
    5151
    5252                         available_queues={'rignot','default'};
     
    5757
    5858                         %Miscelaneous
    59                          if isempty(cluster.login), checkmessage('login empty'); end
    60                          if isempty(cluster.codepath), checkmessage('codepath empty'); end
    61                          if isempty(cluster.executionpath), checkmessage('executionpath empty'); end
     59                         if isempty(cluster.login), md = checkmessage(md,'login empty'); end
     60                         if isempty(cluster.codepath), md = checkmessage(md,'codepath empty'); end
     61                         if isempty(cluster.executionpath), md = checkmessage(md,'executionpath empty'); end
    6262
    6363                 end
    6464                 %}}}
    65                  function BuildQueueScript(cluster,md) % {{{1
     65                 function BuildQueueScript(cluster,modelname,solution,io_gather,isvalgrind,isgprof) % {{{
    6666
    67                          %retrieve parameters
    68                          modelname=md.miscellaneous.name;
    69                          solution=md.private.solution;
    70                          isvalgrind=md.debug.valgrind;
     67                         if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
     68                         if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
    7169
    7270                         %compute number of processors
    7371                         cluster.np=cluster.numnodes*cluster.cpuspernode;
    7472
    75                          %open file for writing:
     73                         %write queuing script
    7674                         fid=fopen([modelname '.queue'],'w');
    77 
    7875                         fprintf(fid,'#PBS -S /bin/bash\n');
    7976                         fprintf(fid,'#PBS -N %s\n',modelname);
     
    8481                         fprintf(fid,'#PBS -o %s.outlog \n',modelname);
    8582                         fprintf(fid,'#PBS -e %s.errlog \n\n',modelname);
    86 
    8783                         fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,md.private.runtimename);
    8884                         fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
    89 
    90                          if ~md.settings.io_gather,
    91                                  %concatenate the output files:
     85                         if ~io_gather, %concatenate the output files:
    9286                                 fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
    9387                         end
    94 
    95                          %close file
    9688                         fclose(fid);
    9789
     
    10092                                 fid=fopen([modelname '.run'],'w');
    10193                                 fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
    102 
    103                                  if ~md.settings.io_gather,
    104                                          %concatenate the output files:
     94                                 if ~io_gather, %concatenate the output files:
    10595                                         fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
    10696                                 end
     
    112102                         end
    113103                 end %}}}
    114                  function LaunchQueueJob(cluster,md,options)% {{{1
    115                          
    116                          %lauch command, to be executed via ssh
    117                          if ~cluster.interactive,
    118                                 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' md.private.runtimename ' && mkdir ' md.private.runtimename ...
    119                                         ' && cd ' md.private.runtimename ' && mv ../' md.private.runtimename '.tar.gz ./ && tar -zxf ' md.private.runtimename '.tar.gz  && qsub ' md.miscellaneous.name '.queue '];
    120                         else
    121                                 launchcommand=['cd ' cluster.executionpath '/Interactive' num2str(cluster.interactive) ' && tar -zxf ' md.private.runtimename '.tar.gz'];
    122                         end
     104                 function LaunchQueueJob(cluster,modelname,dirname,filelist)% {{{
    123105
    124                         if ~strcmpi(options.batch,'yes'),
    125                                
    126                                 %compress the files into one zip.
    127                                 compressstring=['tar -zcf ' md.private.runtimename '.tar.gz ' md.miscellaneous.name '.bin ' md.miscellaneous.name '.queue '  md.miscellaneous.name '.petsc '];
    128                                 if md.qmu.isdakota,
    129                                         compressstring=[compressstring md.miscellaneous.name '.qmu.in '];
    130                                 end
    131                                 if cluster.interactive,
    132                                         compressstring=[compressstring md.miscellaneous.name '.run ' md.miscellaneous.name '.errlog ' md.miscellaneous.name '.outlog '];
    133                                 end
    134                                 system(compressstring);
    135                                
    136                                 disp('uploading input file and queueing script');
    137                                 if cluster.interactive,
    138                                         directory=[cluster.executionpath '/Interactive' num2str(cluster.interactive)];
    139                                 else
    140                                         directory=cluster.executionpath;
    141                                 end
    142                                
    143                                 issmscpout(cluster.name,directory,cluster.login,cluster.port,{[md.private.runtimename '.tar.gz']});
    144                                
    145                                 disp('launching solution sequence on remote cluster');
    146                                 issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
     106                         %compress the files into one zip.
     107                         compressstring=['tar -zcf ' dirname '.tar.gz '];
     108                         for i=1:numel(filelist),
     109                                 compressstring = [compressstring ' ' filelist{i}];
     110                         end
     111                         if cluster.interactive,
     112                                 compressstring = [compressstring ' ' modelname '.errlog ' modelname '.outlog '];
     113                         end
     114                         system(compressstring);
    147115
    148                         else
    149                                 disp('batch mode requested: not launching job interactively');
    150                                 disp('launch solution sequence on remote cluster by hand');
    151                         end
    152                  end
    153                  %}}}
    154                  function Download(cluster,md)% {{{1
     116                         disp('uploading input file and queueing script');
     117                         issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
    155118
    156                         %some check
    157                         if isempty(md.private.runtimename),
    158                                 if ~cluster.interactive,
    159                                         error('greenplanet Download error message: supply runtime name for results to be loaded!');
    160                                 end
    161                         end
     119                         disp('launching solution sequence on remote cluster');
     120                         launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
     121                                 ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && qsub ' modelname '.queue '];
     122                         issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
     123                 end %}}}
     124                 function Download(cluster,dirname,filelist)% {{{
    162125
    163                         %Figure out the  directory where all the files are in:
    164                         if ~cluster.interactive,
    165                                 directory=[cluster.executionpath '/' md.private.runtimename '/'];
    166                         else
    167                                 directory=[cluster.executionpath '/Interactive' num2str(cluster.interactive) '/'];
    168                         end
     126                         %copy files from cluster to current directory
     127                         directory=[cluster.executionpath '/' dirname '/'];
     128                         issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
    169129
    170                         %What packages are we picking up from remote cluster
    171                         if ~cluster.interactive,
    172                                 packages={[md.miscellaneous.name '.outlog'],[md.miscellaneous.name '.errlog']};
    173                         else
    174                                 packages={};
    175                         end
    176                         if md.qmu.isdakota,
    177                                 packages{end+1}=[md.miscellaneous.name '.qmu.err'];
    178                                 packages{end+1}=[md.miscellaneous.name '.qmu.out'];
    179                                 if isfield(md.qmu.params,'tabular_graphics_data'),
    180                                         if md.qmu.params.tabular_graphics_data==true,
    181                                                 packages{end+1}='dakota_tabular.dat';
    182                                         end
    183                                 end
    184                         else
    185                                 packages{end+1}=[md.miscellaneous.name '.outbin'];
    186                         end
    187 
    188                         %copy files from cluster to present directory
    189                         issmscpin(cluster.name, cluster.login, cluster.port, directory, packages);
    190 
    191                 end %}}}
     130                 end %}}}
    192131        end
    193132end
  • issm/trunk/src/m/classes/clusters/pfe.m

    r11995 r12706  
    88classdef pfe
    99    properties (SetAccess=public) 
    10                  % {{{1
     10                 % {{{
    1111                 name='pfe'
    1212                 login='';
     
    2929         end
    3030         methods
    31                  function cluster=pfe(varargin) % {{{1
     31                 function cluster=pfe(varargin) % {{{
    3232
    3333                         %initialize cluster using default settings if provided
     
    3838                 end
    3939                 %}}}
    40                  function disp(cluster) % {{{1
     40                 function disp(cluster) % {{{
    4141                         %  display the object
    4242                         disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
     
    5656                 end
    5757                 %}}}
    58                  function checkconsistency(cluster,md,solution,analyses) % {{{1
     58                 function md = checkconsistency(cluster,md,solution,analyses) % {{{
    5959
    6060                         available_queues={'long','normal','debug'};
     
    6868                                 if cluster.hyperthreading,
    6969                                         if ((cluster.cpuspernode>16 ) | (cluster.cpuspernode<1)),
    70                                                  checkmessage('cpuspernode should be between 1 and 16 for ''neh'' and ''har'' processors in hyperthreading mode');
     70                                                 md = checkmessage(md,'cpuspernode should be between 1 and 16 for ''neh'' and ''har'' processors in hyperthreading mode');
    7171                                         end
    7272                                 else
    7373                                         if ((cluster.cpuspernode>8 ) | (cluster.cpuspernode<1)),
    74                                                  checkmessage('cpuspernode should be between 1 and 8 for ''neh'' and ''har'' processors');
     74                                                 md = checkmessage(md,'cpuspernode should be between 1 and 8 for ''neh'' and ''har'' processors');
    7575                                         end
    7676                                 end
     
    7878                                 if cluster.hyperthreading,
    7979                                         if ((cluster.cpuspernode>24 ) | (cluster.cpuspernode<1)),
    80                                                  checkmessage('cpuspernode should be between 1 and 24 for ''wes'' processors in hyperthreading mode');
     80                                                 md = checkmessage(md,'cpuspernode should be between 1 and 24 for ''wes'' processors in hyperthreading mode');
    8181                                         end
    8282                                 else
    8383                                         if ((cluster.cpuspernode>12 ) | (cluster.cpuspernode<1)),
    84                                                  checkmessage('cpuspernode should be between 1 and 12 for ''wes'' processors');
    85                                          end
    86                                  end
    87                          else
    88                                  checkmessage('unknown processor type, should be ''neh'',''wes'' or ''har''');
     84                                                 md = checkmessage(md,'cpuspernode should be between 1 and 12 for ''wes'' processors');
     85                                         end
     86                                 end
     87                         else
     88                                 md = checkmessage(md,'unknown processor type, should be ''neh'',''wes'' or ''har''');
    8989                         end
    9090
    9191                         %Miscelaneous
    92                          if isempty(cluster.login), checkmessage('login empty'); end
    93                          if isempty(cluster.codepath), checkmessage('codepath empty'); end
    94                          if isempty(cluster.executionpath), checkmessage('executionpath empty'); end
    95 
    96                  end
    97                  %}}}
    98                  function BuildQueueScript(cluster,md) % {{{1
    99 
    100                          %retrieve parameters
    101                          modelname=md.miscellaneous.name;
    102                          solution=md.private.solution;
    103                          isvalgrind=md.debug.valgrind;
     92                         if isempty(cluster.login), md = checkmessage(md,'login empty'); end
     93                         if isempty(cluster.codepath), md = checkmessage(md,'codepath empty'); end
     94                         if isempty(cluster.executionpath), md = checkmessage(md,'executionpath empty'); end
     95
     96                 end
     97                 %}}}
     98                 function BuildQueueScript(cluster,modelname,solution,io_gather,isvalgrind,isgprof) % {{{
     99
     100                         if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
    104101
    105102                         %compute number of processors
    106103                         cluster.np=cluster.numnodes*cluster.cpuspernode;
    107104
    108                          %open file for writing:
     105                         %write queuing script
    109106                         fid=fopen([modelname '.queue'],'w');
    110 
    111107                         fprintf(fid,'#PBS -S /bin/bash\n');
    112108%                        fprintf(fid,'#PBS -N %s\n',modelname);
     
    118114                         fprintf(fid,'#PBS -o %s.outlog \n',modelname);
    119115                         fprintf(fid,'#PBS -e %s.errlog \n\n',modelname);
    120 
    121116                         fprintf(fid,'. /usr/share/modules/init/bash\n\n');
    122 
    123117                         fprintf(fid,'module load comp-intel/11.1.046\n');
    124118                         fprintf(fid,'module load mpi/mpt.1.25\n');
    125119                         fprintf(fid,'module load math/intel_mkl_64_10.0.011\n\n');
    126 
    127120                         fprintf(fid,'export PATH="$PATH:."\n\n');
    128121                         fprintf(fid,'export MPI_GROUP_MAX=64\n\n');
    129 
    130122                         fprintf(fid,'cd $PBS_O_WORKDIR\n\n');
    131 
    132123                         fprintf(fid,'mpiexec -np %i %s/issm.exe %s $PBS_O_WORKDIR %s\n',cluster.np,cluster.codepath,EnumToString(solution),modelname);
    133 
    134                          if ~md.settings.io_gather,
    135                                  %concatenate the output files:
     124                         if ~io_gather, %concatenate the output files:
    136125                                 fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
    137126                         end
    138 
    139                          %close file
    140127                         fclose(fid);
    141128
     
    148135                                         fprintf(fid,'mpiexec -np %i valgrind --leak-check=full %s/issm.exe %s $PBS_O_WORKDIR %s\n',cluster.np,cluster.codepath,EnumToString(solution),modelname);
    149136                                 end
    150 
    151                                  if ~md.settings.io_gather,
    152                                          %concatenate the output files:
     137                                 if ~io_gather, %concatenate the output files:
    153138                                         fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
    154139                                 end
     
    160145                         end
    161146                 end %}}}
    162                  function LaunchQueueJob(cluster,md,options)% {{{1
    163                          
     147                 function LaunchQueueJob(cluster,modelname,dirname,filelist)% {{{
     148
     149                         %compress the files into one zip.
     150                         compressstring=['tar -zcf ' dirname '.tar.gz '];
     151                         for i=1:numel(filelist),
     152                                 compressstring = [compressstring ' ' filelist{i}];
     153                         end
     154                         if cluster.interactive,
     155                                 compressstring = [compressstring ' ' modelname '.run '  modelname '.errlog ' modelname '.outlog '];
     156                         end
     157                         system(compressstring);
     158
     159                         disp('uploading input file and queueing script');
     160                         if cluster.interactive,
     161                                 directory=[cluster.executionpath '/Interactive' num2str(cluster.interactive)];
     162                         else
     163                                 directory=cluster.executionpath;
     164                         end
     165
     166                         if ~cluster.bbftp,
     167                                 issmscpout(cluster.name,directory,cluster.login,cluster.port,{[dirname '.tar.gz']});
     168                         else
     169                                 issmbbftpout(cluster.name,directory,cluster.login,cluster.port,cluster.numstreams,{[dirname '.tar.gz']});
     170                         end
     171
    164172                         %lauch command, to be executed via ssh
    165173                         if ~cluster.interactive,
    166                                 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' md.private.runtimename ' && mkdir ' md.private.runtimename ...
    167                                         ' && cd ' md.private.runtimename ' && mv ../' md.private.runtimename '.tar.gz ./ && tar -zxf ' md.private.runtimename '.tar.gz  && qsub ' md.miscellaneous.name '.queue '];
    168                         else
    169                                 launchcommand=['cd ' cluster.executionpath '/Interactive' num2str(cluster.interactive) ' && tar -zxf ' md.private.runtimename '.tar.gz'];
    170                         end
    171 
    172                         if ~strcmpi(options.batch,'yes'),
    173                                
    174                                 %compress the files into one zip.
    175                                 compressstring=['tar -zcf ' md.private.runtimename '.tar.gz ' md.miscellaneous.name '.bin ' md.miscellaneous.name '.queue '  md.miscellaneous.name '.petsc '];
    176                                 if md.qmu.isdakota,
    177                                         compressstring=[compressstring md.miscellaneous.name '.qmu.in '];
    178                                 end
    179                                 if cluster.interactive,
    180                                         compressstring=[compressstring md.miscellaneous.name '.run ' md.miscellaneous.name '.errlog ' md.miscellaneous.name '.outlog '];
    181                                 end
    182                                 system(compressstring);
    183                                
    184                                 disp('uploading input file and queueing script');
    185                                 if cluster.interactive,
    186                                         directory=[cluster.executionpath '/Interactive' num2str(cluster.interactive)];
    187                                 else
    188                                         directory=cluster.executionpath;
    189                                 end
    190                                
    191                                 if ~cluster.bbftp,
    192                                         issmscpout(cluster.name,directory,cluster.login,cluster.port,{[md.private.runtimename '.tar.gz']});
    193                                 else
    194                                         issmbbftpout(cluster.name,directory,cluster.login,cluster.port,cluster.numstreams,{[md.private.runtimename '.tar.gz']});
    195                                 end
    196                                
    197                                 disp('launching solution sequence on remote cluster');
    198                                 issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
    199 
    200                         else
    201                                 disp('batch mode requested: not launching job interactively');
    202                                 disp('launch solution sequence on remote cluster by hand');
    203                         end
    204                  end
    205                  %}}}
    206                  function Download(cluster,md)% {{{1
    207 
    208                         %some check
    209                         if isempty(md.private.runtimename),
    210                                 if ~cluster.interactive,
    211                                         error('pfe Download error message: supply runtime name for results to be loaded!');
    212                                 end
    213                         end
    214 
    215                         %Figure out the  directory where all the files are in:
    216                         if ~cluster.interactive,
    217                                 directory=[cluster.executionpath '/' md.private.runtimename '/'];
    218                         else
    219                                 directory=[cluster.executionpath '/Interactive' num2str(cluster.interactive) '/'];
    220                         end
    221 
    222                         %What packages are we picking up from remote cluster
    223                         if ~cluster.interactive,
    224                                 packages={[md.miscellaneous.name '.outlog'],[md.miscellaneous.name '.errlog']};
    225                         else
    226                                 packages={};
    227                         end
    228                         if md.qmu.isdakota,
    229                                 packages{end+1}=[md.miscellaneous.name '.qmu.err'];
    230                                 packages{end+1}=[md.miscellaneous.name '.qmu.out'];
    231                                 if isfield(md.qmu.params,'tabular_graphics_data'),
    232                                         if md.qmu.params.tabular_graphics_data==true,
    233                                                 packages{end+1}='dakota_tabular.dat';
    234                                         end
    235                                 end
    236                         else
    237                                 packages{end+1}=[md.miscellaneous.name '.outbin'];
    238                         end
    239 
    240                         %copy files from cluster to present directory
    241                         if ~cluster.bbftp,
    242                                 issmscpin(cluster.name, cluster.login, cluster.port, directory, packages);
    243                         else
    244                                 issmbbftpin(cluster.name, cluster.login, cluster.port, cluster.numstreams, directory, packages);
    245                         end
    246 
    247                 end %}}}
     174                                 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
     175                                         ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && qsub ' modelname '.queue '];
     176                         else
     177                                 launchcommand=['cd ' cluster.executionpath '/Interactive' num2str(cluster.interactive) ' && tar -zxf ' dirname '.tar.gz'];
     178                         end
     179
     180                         disp('launching solution sequence on remote cluster');
     181                         issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
     182                 end
     183                 %}}}
     184                 function Download(cluster,dirname,filelist)% {{{
     185
     186                         %copy files from cluster to current directory
     187                         if ~cluster.interactive,
     188                                 directory=[cluster.executionpath '/' dirname '/'];
     189                         else
     190                                 directory=[cluster.executionpath '/Interactive' num2str(cluster.interactive) '/'];
     191                         end
     192
     193                         if ~cluster.bbftp,
     194                                 issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
     195                         else
     196                                 issmbbftpin(cluster.name, cluster.login, cluster.port, cluster.numstreams, directory, filelist);
     197                         end
     198
     199                 end %}}}
    248200        end
    249201end
  • issm/trunk/src/m/classes/clusters/pollux.m

    r11995 r12706  
    88classdef pollux
    99    properties (SetAccess=public)
    10                  % {{{1
     10                 % {{{
    1111                 name='pollux'
    1212                 login='username';
     
    2020         end
    2121         methods
    22                  function cluster=pollux(varargin) % {{{1
     22                 function cluster=pollux(varargin) % {{{
    2323                         cluster=AssignObjectFields(pairoptions(varargin{:}),cluster);
    2424                 end
    2525                 %}}}
    26                  function disp(cluster) % {{{1
     26                 function disp(cluster) % {{{
    2727                         %  display the object
    2828                         disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
     
    3737                 end
    3838                 %}}}
    39                  function checkconsistency(cluster,md,solution,analyses) % {{{1
     39                 function md = checkconsistency(cluster,md,solution,analyses) % {{{
    4040
    4141                         available_queues={'shortp','longp'};
     
    4646                 end
    4747                 %}}}
    48                  function BuildQueueScript(cluster,md) % {{{1
     48                 function BuildQueueScript(cluster,modelname,solution,io_gather,isvalgrind,isgprof) % {{{
    4949
    50                          %retrieve parameters
    51                          modelname=md.miscellaneous.name;
    52                          solution=md.private.solution;
     50                         if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
     51                         if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
    5352
    54                          %open file for writing:
     53                         %write queuing script
    5554                         fid=fopen([modelname '.queue'],'w');
    56 
    5755                         fprintf(fid,'#!/bin/sh\n');
    5856                         fprintf(fid,'#PBS -l walltime=%i\n',cluster.time*60); %walltime is in seconds.
     
    6462                         fprintf(fid,'#PBS -o %s.outlog \n',modelname);
    6563                         fprintf(fid,'#PBS -e %s.errlog \n',modelname);
    66 
    6764                         fprintf(fid,'export PBS_O_WORKDIR=%s\n',cluster.executionpath);
    6865                         fprintf(fid,'cd $PBS_O_WORKDIR\n');
    6966                         fprintf(fid,'export OMP_NUM_THREADS=1\n');
    7067                         fprintf(fid,'dplace -s1 -c0-%i mpiexec -np %i %s/issm.exe %s %s %s',cluster.np-1,cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
    71 
    72                          %close file
    7368                         fclose(fid);
    7469
    7570                 end
    7671                 %}}}
    77                  function LaunchQueueJob(cluster,md,options)% {{{1
    78                          
    79                          %lauch command, to be executed via ssh
    80                          launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' md.private.runtimename ' && mkdir ' md.private.runtimename ...
    81                                         ' && cd ' md.private.runtimename ' && mv ../' md.private.runtimename '.tar.gz ./ && tar -zxf ' md.private.runtimename '.tar.gz  && qsub ' modelname '.queue '];
     72                 function LaunchQueueJob(cluster,modelname,dirname,filelist)% {{{
    8273
    83                         if ~strcmpi(options.batch,'yes'),
    84                                
    85                                 %compress the files into one zip.
    86                                 compressstring=['tar -zcf ' md.private.runtimename '.tar.gz ' md.miscellaneous.name '.bin ' md.miscellaneous.name '.queue '  md.miscellaneous.name '.petsc '];
    87                                 if md.qmu.isdakota,
    88                                         compressstring=[compressstring md.miscellaneous.name '.qmu.in'];
    89                                 end
    90                                 system(compressstring);
    91                                
    92                                 disp('uploading input file and queueing script');
    93                                 issmscpout(md.cluster.name,md.cluster.executionpath,md.cluster.login,md.cluster.port,{[md.private.runtimename '.tar.gz']});
    94                                
    95                                 disp('launching solution sequence on remote cluster');
    96                                 issmssh(md.cluster.name,md.cluster.login,md.cluster.port,launchcommand);
     74                         %compress the files into one zip.
     75                         compressstring=['tar -zcf ' dirname '.tar.gz '];
     76                         for i=1:numel(filelist),
     77                                 compressstring = [compressstring ' ' filelist{i}];
     78                         end
     79                         if cluster.interactive,
     80                                 compressstring = [compressstring ' ' modelname '.errlog ' modelname '.outlog '];
     81                         end
     82                         system(compressstring);
    9783
    98                         else
    99                                 disp('batch mode requested: not launching job interactively');
    100                                 disp('launch solution sequence on remote cluster by hand');
    101                         end
     84                         disp('uploading input file and queueing script');
     85                         issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
    10286
    103                  end
    104                  %}}}
    105                  function Download(cluster,md)% {{{1
     87                         disp('launching solution sequence on remote cluster');
     88                         launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
     89                                 ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && qsub ' modelname '.queue '];
     90                         issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
     91                 end %}}}
     92                 function Download(cluster,dirname,filelist)% {{{
    10693
    107                         %some check
    108                         if isempty(md.private.runtimename),
    109                                 error('pfe Download error message: supply runtime name for results to be loaded!');
    110                         end
     94                         %copy files from cluster to current directory
     95                         directory=[cluster.executionpath '/' dirname '/'];
     96                         issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
    11197
    112                         %Figure out the  directory where all the files are in:
    113                         directory=[cluster.executionpath '/' md.private.runtimename '/'];
    114 
    115                         %What packages are we picking up from remote cluster
    116                         packages={[md.miscellaneous.name '.outlog'],[md.miscellaneous.name '.errlog']};
    117                         if md.qmu.isdakota,
    118                                 packages{end+1}=[md.miscellaneous.name '.qmu.err'];
    119                                 packages{end+1}=[md.miscellaneous.name '.qmu.out'];
    120                                 if isfield(md.qmu.params,'tabular_graphics_data'),
    121                                         if md.qmu.params.tabular_graphics_data==true,
    122                                                 packages{end+1}='dakota_tabular.dat';
    123                                         end
    124                                 end
    125                         else
    126                                 packages{end+1}=[md.miscellaneous.name '.outbin'];
    127                         end
    128 
    129                         %copy files from cluster to present directory
    130                         issmscpin(cluster.name, cluster.login, cluster.port, directory, packages);
    131                 end %}}}
     98                 end %}}}
    13299        end
    133100end
  • issm/trunk/src/m/classes/constants.m

    r11995 r12706  
    3131
    3232                end % }}}
    33                 function flag = checkconsistency(obj,md,solution,analyses) % {{{
     33                function md = checkconsistency(obj,md,solution,analyses) % {{{
    3434
    35                         checkfield(md,'constants.g','>',0,'size',[1 1]);
    36                         checkfield(md,'constants.yts','>',0,'size',[1 1]);
    37                         checkfield(md,'constants.referencetemperature','size',[1 1]);
     35                        md = checkfield(md,'constants.g','>',0,'size',[1 1]);
     36                        md = checkfield(md,'constants.yts','>',0,'size',[1 1]);
     37                        md = checkfield(md,'constants.referencetemperature','size',[1 1]);
    3838
    3939                end % }}}
  • issm/trunk/src/m/classes/debug.m

    r11995 r12706  
    88                valgrind = false;
    99                gprof    = false;
    10                 petsc_profiling = false;
     10                profiling = false;
    1111        end
    1212        methods
     
    2727                        fielddisplay(obj,'valgrind','use Valgrind to debug (0 or 1)');
    2828                        fielddisplay(obj,'gprof','use gnu-profiler to find out where the time is spent');
    29                         fielddisplay(obj,'petsc_profiling','enables PETSc profiling (memory, flops, time)');
     29                        fielddisplay(obj,'profiling','enables profiling (memory, flops, time)');
    3030
    3131                end % }}}
    3232                function marshall(obj,fid) % {{{
    33                         WriteData(fid,'object',obj,'fieldname','petsc_profiling','format','Boolean');
     33                        WriteData(fid,'object',obj,'fieldname','profiling','format','Boolean');
    3434                end % }}}
    3535        end
  • issm/trunk/src/m/classes/diagnostic.m

    r11995 r12706  
    6464
    6565                end % }}}
    66                 function checkconsistency(obj,md,solution,analyses) % {{{
     66                function md = checkconsistency(obj,md,solution,analyses) % {{{
    6767
    6868                        %Early return
     
    7070                        %if ~ismember(DiagnosticHorizAnalysisEnum,analyses) |  (solution==TransientSolutionEnum & md.transient.isdiagnostic==0), return; end
    7171
    72                         checkfield(md,'diagnostic.spcvx','forcing',1);
    73                         checkfield(md,'diagnostic.spcvy','forcing',1);
    74                         if md.mesh.dimension==3, checkfield(md,'diagnostic.spcvz','forcing',1); end
    75                         checkfield(md,'diagnostic.restol','size',[1 1],'>',0);
    76                         checkfield(md,'diagnostic.reltol','size',[1 1]);
    77                         checkfield(md,'diagnostic.abstol','size',[1 1]);
    78                         checkfield(md,'diagnostic.isnewton','numel',1,'values',[0 1]);
    79                         checkfield(md,'diagnostic.stokesreconditioning','size',[1 1],'NaN',1);
    80                         checkfield(md,'diagnostic.viscosity_overshoot','size',[1 1],'NaN',1);
     72                        md = checkfield(md,'diagnostic.spcvx','forcing',1);
     73                        md = checkfield(md,'diagnostic.spcvy','forcing',1);
     74                        if md.mesh.dimension==3, md = checkfield(md,'diagnostic.spcvz','forcing',1); end
     75                        md = checkfield(md,'diagnostic.restol','size',[1 1],'>',0);
     76                        md = checkfield(md,'diagnostic.reltol','size',[1 1]);
     77                        md = checkfield(md,'diagnostic.abstol','size',[1 1]);
     78                        md = checkfield(md,'diagnostic.isnewton','numel',1,'values',[0 1]);
     79                        md = checkfield(md,'diagnostic.stokesreconditioning','size',[1 1],'NaN',1);
     80                        md = checkfield(md,'diagnostic.viscosity_overshoot','size',[1 1],'NaN',1);
    8181                        if md.mesh.dimension==2,
    82                                 checkfield(md,'diagnostic.icefront','size',[NaN 4],'NaN',1);
     82                                md = checkfield(md,'diagnostic.icefront','size',[NaN 4],'NaN',1);
    8383                        else
    84                                 checkfield(md,'diagnostic.icefront','size',[NaN 6],'NaN',1);
     84                                md = checkfield(md,'diagnostic.icefront','size',[NaN 6],'NaN',1);
    8585                        end
    86                         checkfield(md,'diagnostic.icefront(:,end)','values',[0 1 2]);
    87                         checkfield(md,'diagnostic.maxiter','size',[1 1],'>=',1);
    88                         checkfield(md,'diagnostic.referential','size',[md.mesh.numberofvertices 6]);
     86                        md = checkfield(md,'diagnostic.icefront(:,end)','values',[0 1 2]);
     87                        md = checkfield(md,'diagnostic.maxiter','size',[1 1],'>=',1);
     88                        md = checkfield(md,'diagnostic.referential','size',[md.mesh.numberofvertices 6]);
    8989                        if ~isempty(md.diagnostic.requested_outputs),
    90                                 checkfield(md,'diagnostic.requested_outputs','size',[NaN 1]);
     90                                md = checkfield(md,'diagnostic.requested_outputs','size',[NaN 1]);
    9191                        end
    9292
    9393                        %singular solution
    9494                        if ~any((~isnan(md.diagnostic.spcvx)+~isnan(md.diagnostic.spcvy))==2),
    95                                 checkmessage(['model ' md.miscellaneous.name ' is not well posed (singular). You need at least one node with fixed velocity!'])
     95                                md = checkmessage(md,['model is not well posed (singular). You need at least one node with fixed velocity!']);
    9696                        end
    9797                        %CHECK THAT EACH LINES CONTAINS ONLY NAN VALUES OR NO NAN VALUES
    9898                        if any(sum(isnan(md.diagnostic.referential),2)~=0 & sum(isnan(md.diagnostic.referential),2)~=6),
    99                                 checkmessage(['model ' md.miscellaneous.name ' has problem with rotated spc. Each line of diagnostic.referential should contain either only NaN values or no NaN values']);
     99                                md = checkmessage(md,['Each line of diagnostic.referential should contain either only NaN values or no NaN values']);
    100100                        end
    101101                        %CHECK THAT THE TWO VECTORS PROVIDED ARE ORTHOGONAL
     
    103103                                pos=find(sum(isnan(md.diagnostic.referential),2)==0);
    104104                                if any(abs(dot(md.diagnostic.referential(pos,1:3)',md.diagnostic.referential(pos,4:6)'))>eps),
    105                                         checkmessage(['model ' md.miscellaneous.name ' has problem with referential. Vectors in diagnostic.referential (colums 1 to 3 and 4 to 6) must be orthogonal']);
     105                                        md = checkmessage(md,['Vectors in diagnostic.referential (colums 1 to 3 and 4 to 6) must be orthogonal']);
    106106                                end
    107107                        end
     
    110110                                pos=find(md.mask.vertexongroundedice & md.mesh.vertexonbed);
    111111                                if any(~isnan(md.diagnostic.referential(pos,:))),
    112                                         checkmessage(['no referential should be specified for basal vertices of grounded ice']);
     112                                        md = checkmessage(md,['no referential should be specified for basal vertices of grounded ice']);
    113113                                end
    114114                        end
  • issm/trunk/src/m/classes/flaim.m

    r11995 r12706  
    3232
    3333                end % }}}
    34                 function checkconsistency(obj,md,solution,analyses) % {{{
     34                function md = checkconsistency(obj,md,solution,analyses) % {{{
    3535
    3636                        %Early return
    3737                        if solution~=FlaimSolutionEnum, return; end
    3838
    39                         checkfield(md,'flaim.tracks','file',1);
     39                        md = checkfield(md,'flaim.tracks','file',1);
    4040                        if any(isnan(md.flaim.criterion)) || isempty(md.flaim.criterion)
    41                                 checkfield(md,'flaim.targets','file',1);
     41                                md = checkfield(md,'flaim.targets','file',1);
    4242                        else
    43                                 checkfield(md,'flaim.criterion','numel',[md.mesh.numberofvertices md.mesh.numberofelements]);
     43                                md = checkfield(md,'flaim.criterion','numel',[md.mesh.numberofvertices md.mesh.numberofelements]);
    4444                        end
    4545
  • issm/trunk/src/m/classes/flowequation.m

    r11995 r12706  
    2727
    2828                end % }}}
    29                 function checkconsistency(obj,md,solution,analyses) % {{{
     29                function md = checkconsistency(obj,md,solution,analyses) % {{{
    3030
    3131                        if ismember(DiagnosticHorizAnalysisEnum,analyses),
    3232
    33                                 checkfield(md,'flowequation.ismacayealpattyn','numel',1,'values',[0 1]);
    34                                 checkfield(md,'flowequation.ishutter','numel',1,'values',[0 1]);
    35                                 checkfield(md,'flowequation.isstokes','numel',1,'values',[0 1]);
    36                                 checkfield(md,'flowequation.bordermacayeal','size',[md.mesh.numberofvertices 1],'values',[0 1]);
    37                                 checkfield(md,'flowequation.borderpattyn','size',[md.mesh.numberofvertices 1],'values',[0 1]);
    38                                 checkfield(md,'flowequation.borderstokes','size',[md.mesh.numberofvertices 1],'values',[0 1]);
     33                                md = checkfield(md,'flowequation.ismacayealpattyn','numel',1,'values',[0 1]);
     34                                md = checkfield(md,'flowequation.ishutter','numel',1,'values',[0 1]);
     35                                md = checkfield(md,'flowequation.isstokes','numel',1,'values',[0 1]);
     36                                md = checkfield(md,'flowequation.bordermacayeal','size',[md.mesh.numberofvertices 1],'values',[0 1]);
     37                                md = checkfield(md,'flowequation.borderpattyn','size',[md.mesh.numberofvertices 1],'values',[0 1]);
     38                                md = checkfield(md,'flowequation.borderstokes','size',[md.mesh.numberofvertices 1],'values',[0 1]);
    3939                                if (md.mesh.dimension==2),
    40                                         checkfield(md,'flowequation.vertex_equation','size',[md.mesh.numberofvertices 1],'values',[1:2]);
    41                                         checkfield(md,'flowequation.element_equation','size',[md.mesh.numberofelements 1],'values',[1:2]);
     40                                        md = checkfield(md,'flowequation.vertex_equation','size',[md.mesh.numberofvertices 1],'values',[1:2]);
     41                                        md = checkfield(md,'flowequation.element_equation','size',[md.mesh.numberofelements 1],'values',[1:2]);
    4242                                else
    43                                         checkfield(md,'flowequation.vertex_equation','size',[md.mesh.numberofvertices 1],'values',[0:7]);
    44                                         checkfield(md,'flowequation.element_equation','size',[md.mesh.numberofelements 1],'values',[0:7]);
     43                                        md = checkfield(md,'flowequation.vertex_equation','size',[md.mesh.numberofvertices 1],'values',[0:7]);
     44                                        md = checkfield(md,'flowequation.element_equation','size',[md.mesh.numberofelements 1],'values',[0:7]);
    4545                                end
    4646                                if (md.flowequation.ismacayealpattyn==0 && md.flowequation.ishutter==0 && md.flowequation.isstokes==0),
    47                                         checkmessage(['no element types set for this model. At least one of ismacayealpattyn, ishutter or isstokes need to be =1']);
     47                                        md = checkmessage(md,['no element types set for this model. At least one of ismacayealpattyn, ishutter or isstokes need to be =1']);
    4848                                end
    4949                        end
    5050                        if ismember(DiagnosticHutterAnalysisEnum,analyses),
    51                                 if any(md.flowequation.element_equation==1 & md.mask.elementonfloatingice),
    52                                         disp(sprintf('\n !!! Warning: Hutter''s model is not consistent on ice shelves !!!\n'));
     51                                if any(md.flowequation.element_equation==1),
     52                                        if(md.flowequation.element_equation & md.mask.elementonfloatingice),
     53                                                disp(sprintf('\n !!! Warning: Hutter''s model is not consistent on ice shelves !!!\n'));
     54                                        end
    5355                                end
    5456                        end
  • issm/trunk/src/m/classes/friction.m

    r11995 r12706  
    2222
    2323                end % }}}
    24                 function checkconsistency(obj,md,solution,analyses) % {{{
     24                function md = checkconsistency(obj,md,solution,analyses) % {{{
    2525
    2626                        %Early return
    2727                        if ~ismember(DiagnosticHorizAnalysisEnum,analyses) & ~ismember(ThermalAnalysisEnum,analyses), return; end
    2828
    29                         checkfield(md,'friction.coefficient','NaN',1,'size',[md.mesh.numberofvertices 1]);
    30                         checkfield(md,'friction.q','NaN',1,'size',[md.mesh.numberofelements 1]);
    31                         checkfield(md,'friction.p','NaN',1,'size',[md.mesh.numberofelements 1]);
     29                        md = checkfield(md,'friction.coefficient','NaN',1,'size',[md.mesh.numberofvertices 1]);
     30                        md = checkfield(md,'friction.q','NaN',1,'size',[md.mesh.numberofelements 1]);
     31                        md = checkfield(md,'friction.p','NaN',1,'size',[md.mesh.numberofelements 1]);
    3232                end % }}}
    3333                function disp(obj) % {{{
  • issm/trunk/src/m/classes/geometry.m

    r11995 r12706  
    2424
    2525                end % }}}
    26                 function checkconsistency(obj,md,solution,analyses) % {{{
     26                function md = checkconsistency(obj,md,solution,analyses) % {{{
    2727
    28                         checkfield(md,'geometry.surface'  ,'NaN',1,'size',[md.mesh.numberofvertices 1]);
    29                         checkfield(md,'geometry.bed'      ,'NaN',1,'size',[md.mesh.numberofvertices 1]);
    30                         checkfield(md,'geometry.thickness','NaN',1,'size',[md.mesh.numberofvertices 1],'>',0);
     28                        md = checkfield(md,'geometry.surface'  ,'NaN',1,'size',[md.mesh.numberofvertices 1]);
     29                        md = checkfield(md,'geometry.bed'      ,'NaN',1,'size',[md.mesh.numberofvertices 1]);
     30                        md = checkfield(md,'geometry.thickness','NaN',1,'size',[md.mesh.numberofvertices 1],'>',0);
    3131                        if any((obj.thickness-obj.surface+obj.bed)>10^-9),
    32                                 checkmessage(['equality thickness=surface-bed violated']);
     32                                md = checkmessage(md,['equality thickness=surface-bed violated']);
    3333                        end
    3434                        if solution==TransientSolutionEnum & md.transient.isgroundingline,
    35                                 checkfield(md,'geometry.bathymetry','NaN',1,'size',[md.mesh.numberofvertices 1]);
     35                                md = checkfield(md,'geometry.bathymetry','NaN',1,'size',[md.mesh.numberofvertices 1]);
    3636                        end
    3737                end % }}}
  • issm/trunk/src/m/classes/groundingline.m

    r12329 r12706  
    2828
    2929                end % }}}
    30                 function checkconsistency(obj,md,solution,analyses) % {{{
     30                function md = checkconsistency(obj,md,solution,analyses) % {{{
    3131
    32                         checkfield(md,'groundingline.migration','values',{'None' 'AgressiveMigration' 'SoftMigration'});
     32                        md = checkfield(md,'groundingline.migration','values',{'None' 'AgressiveMigration' 'SoftMigration'});
    3333
    3434                        if ~strcmp(obj.migration,'None'),
    3535                                if isnan(md.geometry.bathymetry),
    36                                         checkmessage(['requesting grounding line migration, but bathymetry is absent!']);
     36                                        md = checkmessage(md,['requesting grounding line migration, but bathymetry is absent!']);
    3737                                end
    3838                                pos=find(md.mask.vertexongroundedice);
    3939                                if any(abs(md.geometry.bed(pos)-md.geometry.bathymetry(pos))>10^-10),
    40                                         checkmessage(['bathymetry not equal to bed on grounded ice !']);
     40                                        md = checkmessage(md,['bathymetry not equal to bed on grounded ice !']);
    4141                                end
    4242                                pos=find(md.mask.vertexonfloatingice);
    4343                                if any(md.geometry.bathymetry(pos)-md.geometry.bed(pos)>10^-9),
    44                                         checkmessage(['bathymetry superior to bed on floating ice !']);
     44                                        md = checkmessage(md,['bathymetry superior to bed on floating ice !']);
    4545                                end
    4646                        end
  • issm/trunk/src/m/classes/hydrology.m

    r11995 r12706  
    3535                        obj.stabilization=1;
    3636                end % }}}
    37                 function checkconsistency(obj,md,solution,analyses) % {{{
     37                function md = checkconsistency(obj,md,solution,analyses) % {{{
    3838
    3939                        %Early return
    4040                        if ~ismember(HydrologyAnalysisEnum,analyses), return; end
    4141
    42                         checkfield(md,'hydrology.spcwatercolumn','forcing',1);
    43                         checkfield(md,'hydrology.stabilization','>=',0);
     42                        md = checkfield(md,'hydrology.spcwatercolumn','forcing',1);
     43                        md = checkfield(md,'hydrology.stabilization','>=',0);
    4444                end % }}}
    4545                function disp(obj) % {{{
  • issm/trunk/src/m/classes/initialization.m

    r11995 r12706  
    2727
    2828                end % }}}
    29                 function checkconsistency(obj,md,solution,analyses) % {{{
     29                function md = checkconsistency(obj,md,solution,analyses) % {{{
    3030                        if ismember(DiagnosticHorizAnalysisEnum,analyses)
    3131                                if ~isnan(md.initialization.vx) & ~isnan(md.initialization.vy),
    32                                         checkfield(md,'initialization.vx','NaN',1,'size',[md.mesh.numberofvertices 1]);
    33                                         checkfield(md,'initialization.vy','NaN',1,'size',[md.mesh.numberofvertices 1]);
     32                                        md = checkfield(md,'initialization.vx','NaN',1,'size',[md.mesh.numberofvertices 1]);
     33                                        md = checkfield(md,'initialization.vy','NaN',1,'size',[md.mesh.numberofvertices 1]);
    3434                                end
    3535                        end
    3636                        if ismember(PrognosticAnalysisEnum,analyses),
    37                                 checkfield(md,'initialization.vx','NaN',1,'size',[md.mesh.numberofvertices 1]);
    38                                 checkfield(md,'initialization.vy','NaN',1,'size',[md.mesh.numberofvertices 1]);
     37                                md = checkfield(md,'initialization.vx','NaN',1,'size',[md.mesh.numberofvertices 1]);
     38                                md = checkfield(md,'initialization.vy','NaN',1,'size',[md.mesh.numberofvertices 1]);
    3939                        end
    4040                        if ismember(HydrologyAnalysisEnum,analyses),
    41                                 checkfield(md,'initialization.watercolumn','NaN',1,'size',[md.mesh.numberofvertices 1]);
     41                                md = checkfield(md,'initialization.watercolumn','NaN',1,'size',[md.mesh.numberofvertices 1]);
    4242                        end
    4343                        if ismember(BalancethicknessAnalysisEnum,analyses),
    44                                 checkfield(md,'initialization.vx','NaN',1,'size',[md.mesh.numberofvertices 1]);
    45                                 checkfield(md,'initialization.vy','NaN',1,'size',[md.mesh.numberofvertices 1]);
     44                                md = checkfield(md,'initialization.vx','NaN',1,'size',[md.mesh.numberofvertices 1]);
     45                                md = checkfield(md,'initialization.vy','NaN',1,'size',[md.mesh.numberofvertices 1]);
    4646                                %Triangle with zero velocity
    4747                                if any(sum(abs(md.initialization.vx(md.mesh.elements)),2)==0 & sum(abs(md.initialization.vy(md.mesh.elements)),2)==0)
    48                                         checkmessage('at least one triangle has all its vertices with a zero velocity');
     48                                        md = checkmessage(md,'at least one triangle has all its vertices with a zero velocity');
    4949                                end
    5050                        end
    5151                        if ismember(ThermalAnalysisEnum,analyses),
    52                                 checkfield(md,'initialization.vx','NaN',1,'size',[md.mesh.numberofvertices 1]);
    53                                 checkfield(md,'initialization.vy','NaN',1,'size',[md.mesh.numberofvertices 1]);
    54                                 checkfield(md,'initialization.vz','NaN',1,'size',[md.mesh.numberofvertices 1]);
    55                                 checkfield(md,'initialization.pressure','NaN',1,'size',[md.mesh.numberofvertices 1]);
     52                                md = checkfield(md,'initialization.vx','NaN',1,'size',[md.mesh.numberofvertices 1]);
     53                                md = checkfield(md,'initialization.vy','NaN',1,'size',[md.mesh.numberofvertices 1]);
     54                                md = checkfield(md,'initialization.vz','NaN',1,'size',[md.mesh.numberofvertices 1]);
     55                                md = checkfield(md,'initialization.pressure','NaN',1,'size',[md.mesh.numberofvertices 1]);
    5656                        end
    57                         if (ismember(EnthalpyAnalysisEnum,analyses) & md.thermal.isenthalpy),
    58                                 checkfield(md,'initialization.waterfraction','>=',0,'size',[md.mesh.numberofvertices 1]);
     57                        if (ismember(EnthalpyAnalysisEnum,analyses) & md.thermal.isenthalpy) | solution==EnthalpySolutionEnum,
     58                                md = checkfield(md,'initialization.waterfraction','>=',0,'size',[md.mesh.numberofvertices 1]);
    5959                        end
    6060                end % }}}
  • issm/trunk/src/m/classes/inversion.m

    r11995 r12706  
    7575
    7676                end % }}}
    77                 function checkconsistency(obj,md,solution,analyses) % {{{
     77                function md = checkconsistency(obj,md,solution,analyses) % {{{
    7878
    7979                        %Early return
     
    8383                        num_costfunc=size(md.inversion.cost_functions,2);
    8484
    85                         checkfield(md,'inversion.iscontrol','values',[0 1]);
    86                         checkfield(md,'inversion.tao','values',[0 1]);
    87                         checkfield(md,'inversion.incomplete_adjoint','values',[0 1]);
    88                         checkfield(md,'inversion.control_parameters','cell',1,'values',{'BalancethicknessThickeningRate' 'FrictionCoefficient' 'MaterialsRheologyBbar' 'Vx' 'Vy'});
    89                         checkfield(md,'inversion.nsteps','numel',1,'>=',1);
    90                         checkfield(md,'inversion.maxiter_per_step','size',[md.inversion.nsteps 1],'>=',0);
    91                         checkfield(md,'inversion.step_threshold','size',[md.inversion.nsteps 1]);
    92                         checkfield(md,'inversion.cost_functions','size',[md.inversion.nsteps num_costfunc],'values',[101:105 201 501:503]);
    93                         checkfield(md,'inversion.cost_functions_coefficients','size',[md.mesh.numberofvertices num_costfunc],'>=',0);
    94                         checkfield(md,'inversion.gradient_only','values',[0 1]);
    95                         checkfield(md,'inversion.gradient_scaling','size',[md.inversion.nsteps num_controls]);
    96                         checkfield(md,'inversion.min_parameters','size',[md.mesh.numberofvertices num_controls]);
    97                         checkfield(md,'inversion.max_parameters','size',[md.mesh.numberofvertices num_controls]);
     85                        md = checkfield(md,'inversion.iscontrol','values',[0 1]);
     86                        md = checkfield(md,'inversion.tao','values',[0 1]);
     87                        md = checkfield(md,'inversion.incomplete_adjoint','values',[0 1]);
     88                        md = checkfield(md,'inversion.control_parameters','cell',1,'values',{'BalancethicknessThickeningRate' 'FrictionCoefficient' 'MaterialsRheologyBbar' 'Vx' 'Vy'});
     89                        md = checkfield(md,'inversion.nsteps','numel',1,'>=',1);
     90                        md = checkfield(md,'inversion.maxiter_per_step','size',[md.inversion.nsteps 1],'>=',0);
     91                        md = checkfield(md,'inversion.step_threshold','size',[md.inversion.nsteps 1]);
     92                        md = checkfield(md,'inversion.cost_functions','size',[md.inversion.nsteps num_costfunc],'values',[101:105 201 501:503]);
     93                        md = checkfield(md,'inversion.cost_functions_coefficients','size',[md.mesh.numberofvertices num_costfunc],'>=',0);
     94                        md = checkfield(md,'inversion.gradient_only','values',[0 1]);
     95                        md = checkfield(md,'inversion.gradient_scaling','size',[md.inversion.nsteps num_controls]);
     96                        md = checkfield(md,'inversion.min_parameters','size',[md.mesh.numberofvertices num_controls]);
     97                        md = checkfield(md,'inversion.max_parameters','size',[md.mesh.numberofvertices num_controls]);
    9898
    9999                        if solution==BalancethicknessSolutionEnum
    100                                 checkfield(md,'inversion.thickness_obs','size',[md.mesh.numberofvertices 1],'NaN',1);
     100                                md = checkfield(md,'inversion.thickness_obs','size',[md.mesh.numberofvertices 1],'NaN',1);
    101101                        else
    102                                 checkfield(md,'inversion.vx_obs','size',[md.mesh.numberofvertices 1],'NaN',1);
    103                                 checkfield(md,'inversion.vy_obs','size',[md.mesh.numberofvertices 1],'NaN',1);
     102                                md = checkfield(md,'inversion.vx_obs','size',[md.mesh.numberofvertices 1],'NaN',1);
     103                                md = checkfield(md,'inversion.vy_obs','size',[md.mesh.numberofvertices 1],'NaN',1);
    104104                        end
    105105                end % }}}
  • issm/trunk/src/m/classes/mask.m

    r11995 r12706  
    2525
    2626                end % }}}
    27                 function checkconsistency(obj,md,solution,analyses) % {{{
     27                function md = checkconsistency(obj,md,solution,analyses) % {{{
    2828
    29                         checkfield(md,'mask.elementonfloatingice','size',[md.mesh.numberofelements 1],'values',[0 1]);
    30                         checkfield(md,'mask.elementongroundedice','size',[md.mesh.numberofelements 1],'values',[0 1]);
    31                         checkfield(md,'mask.elementonwater'      ,'size',[md.mesh.numberofelements 1],'values',[0 1]);
    32                         checkfield(md,'mask.vertexonfloatingice','size',[md.mesh.numberofvertices 1],'values',[0 1]);
    33                         checkfield(md,'mask.vertexongroundedice','size',[md.mesh.numberofvertices 1],'values',[0 1]);
    34                         checkfield(md,'mask.vertexonwater'      ,'size',[md.mesh.numberofvertices 1],'values',[0 1]);
     29                        md = checkfield(md,'mask.elementonfloatingice','size',[md.mesh.numberofelements 1],'values',[0 1]);
     30                        md = checkfield(md,'mask.elementongroundedice','size',[md.mesh.numberofelements 1],'values',[0 1]);
     31                        md = checkfield(md,'mask.elementonwater'      ,'size',[md.mesh.numberofelements 1],'values',[0 1]);
     32                        md = checkfield(md,'mask.vertexonfloatingice','size',[md.mesh.numberofvertices 1],'values',[0 1]);
     33                        md = checkfield(md,'mask.vertexongroundedice','size',[md.mesh.numberofvertices 1],'values',[0 1]);
     34                        md = checkfield(md,'mask.vertexonwater'      ,'size',[md.mesh.numberofvertices 1],'values',[0 1]);
    3535                end % }}}
    3636                function disp(obj) % {{{
  • issm/trunk/src/m/classes/materials.m

    r12301 r12706  
    6969                        obj.rheology_law='Paterson';
    7070                end % }}}
    71                 function checkconsistency(obj,md,solution,analyses) % {{{
    72                         checkfield(md,'materials.rho_ice','>',0);
    73                         checkfield(md,'materials.rho_water','>',0);
    74                         checkfield(md,'materials.rho_freshwater','>',0);
    75                         checkfield(md,'materials.mu_water','>',0);
    76                         checkfield(md,'materials.rheology_B','>',0,'size',[md.mesh.numberofvertices 1]);
    77                         checkfield(md,'materials.rheology_n','>',0,'size',[md.mesh.numberofelements 1]);
    78                         checkfield(md,'materials.rheology_law','values',{'None' 'Paterson' 'Arrhenius'});
     71                function md = checkconsistency(obj,md,solution,analyses) % {{{
     72                        md = checkfield(md,'materials.rho_ice','>',0);
     73                        md = checkfield(md,'materials.rho_water','>',0);
     74                        md = checkfield(md,'materials.rho_freshwater','>',0);
     75                        md = checkfield(md,'materials.mu_water','>',0);
     76                        md = checkfield(md,'materials.rheology_B','>',0,'size',[md.mesh.numberofvertices 1]);
     77                        md = checkfield(md,'materials.rheology_n','>',0,'size',[md.mesh.numberofelements 1]);
     78                        md = checkfield(md,'materials.rheology_law','values',{'None' 'Paterson' 'Arrhenius'});
    7979                end % }}}
    8080                function disp(obj) % {{{
     
    8383                        fielddisplay(obj,'rho_ice','ice density [kg/m^3]');
    8484                        fielddisplay(obj,'rho_water','ocean water density [kg/m^3]');
    85                         fielddisplay(obj,'freshrho_water','fresh water density [kg/m^3]');
     85                        fielddisplay(obj,'rho_freshwater','fresh water density [kg/m^3]');
    8686                        fielddisplay(obj,'mu_water','water viscosity [N s/m^2]');
    8787                        fielddisplay(obj,'heatcapacity','heat capacity [J/kg/K]');
  • issm/trunk/src/m/classes/mesh.m

    r11995 r12706  
    6464                        obj.average_vertex_connectivity=25;
    6565                end % }}}
    66                 function checkconsistency(obj,md,solution,analyses) % {{{
     66                function md = checkconsistency(obj,md,solution,analyses) % {{{
    6767
    68                         checkfield(md,'mesh.x','NaN',1,'size',[md.mesh.numberofvertices 1]);
    69                         checkfield(md,'mesh.y','NaN',1,'size',[md.mesh.numberofvertices 1]);
    70                         checkfield(md,'mesh.z','NaN',1,'size',[md.mesh.numberofvertices 1]);
    71                         checkfield(md,'mesh.elements','NaN',1,'>',0,'values',1:md.mesh.numberofvertices);
     68                        md = checkfield(md,'mesh.x','NaN',1,'size',[md.mesh.numberofvertices 1]);
     69                        md = checkfield(md,'mesh.y','NaN',1,'size',[md.mesh.numberofvertices 1]);
     70                        md = checkfield(md,'mesh.z','NaN',1,'size',[md.mesh.numberofvertices 1]);
     71                        md = checkfield(md,'mesh.elements','NaN',1,'>',0,'values',1:md.mesh.numberofvertices);
    7272                        if(md.mesh.dimension==2),
    73                                 checkfield(md,'mesh.elements','size',[md.mesh.numberofelements 3]);
     73                                md = checkfield(md,'mesh.elements','size',[md.mesh.numberofelements 3]);
    7474                        else
    75                                 checkfield(md,'mesh.elements','size',[md.mesh.numberofelements 6]);
     75                                md = checkfield(md,'mesh.elements','size',[md.mesh.numberofelements 6]);
    7676                        end
    7777                        if any(~ismember(1:md.mesh.numberofvertices,sort(unique(md.mesh.elements(:)))));
    78                                 checkmessage('orphan nodes have been found. Check the mesh outline');
     78                                md = checkmessage(md,'orphan nodes have been found. Check the mesh outline');
    7979                        end
    80                         checkfield(md,'mesh.dimension','values',[2 3]);
    81                         checkfield(md,'mesh.numberoflayers','>=',0);
    82                         checkfield(md,'mesh.numberofelements','>',0);
    83                         checkfield(md,'mesh.numberofvertices','>',0);
     80                        md = checkfield(md,'mesh.dimension','values',[2 3]);
     81                        md = checkfield(md,'mesh.numberoflayers','>=',0);
     82                        md = checkfield(md,'mesh.numberofelements','>',0);
     83                        md = checkfield(md,'mesh.numberofvertices','>',0);
    8484                        %no checks for numberofedges lat long and hemisphere
    85                         checkfield(md,'mesh.elementonbed','size',[md.mesh.numberofelements 1],'values',[0 1]);
    86                         checkfield(md,'mesh.elementonsurface','size',[md.mesh.numberofelements 1],'values',[0 1]);
    87                         checkfield(md,'mesh.vertexonbed','size',[md.mesh.numberofvertices 1],'values',[0 1]);
    88                         checkfield(md,'mesh.vertexonsurface','size',[md.mesh.numberofvertices 1],'values',[0 1]);
     85                        md = checkfield(md,'mesh.elementonbed','size',[md.mesh.numberofelements 1],'values',[0 1]);
     86                        md = checkfield(md,'mesh.elementonsurface','size',[md.mesh.numberofelements 1],'values',[0 1]);
     87                        md = checkfield(md,'mesh.vertexonbed','size',[md.mesh.numberofvertices 1],'values',[0 1]);
     88                        md = checkfield(md,'mesh.vertexonsurface','size',[md.mesh.numberofvertices 1],'values',[0 1]);
    8989                        if (md.mesh.dimension==2),
    90                                 checkfield(md,'mesh.average_vertex_connectivity','>=',9,'message','''mesh.average_vertex_connectivity'' should be at least 9 in 2d');
     90                                md = checkfield(md,'mesh.average_vertex_connectivity','>=',9,'message','''mesh.average_vertex_connectivity'' should be at least 9 in 2d');
    9191                        else
    92                                 checkfield(md,'mesh.average_vertex_connectivity','>=',24,'message','''mesh.average_vertex_connectivity'' should be at least 24 in 3d');
     92                                md = checkfield(md,'mesh.average_vertex_connectivity','>=',24,'message','''mesh.average_vertex_connectivity'' should be at least 24 in 3d');
    9393                        end
    94                         checkfield(md,'mesh.elementconnectivity','size',[md.mesh.numberofelements 3],'NaN',1);
     94                        md = checkfield(md,'mesh.elementconnectivity','size',[md.mesh.numberofelements 3],'NaN',1);
    9595
    9696                        %Solution specific checks
     
    9898                                case PrognosticSolutionEnum,
    9999                                        if md.prognostic.stabilization==3,
    100                                                 checkfield(md,'mesh.dimension','values',2,'message','Discontinuous Galerkin only supported for 2d meshes');
    101                                                 checkfield(md,'mesh.edges','size',[NaN 4]);
    102                                                 checkfield(md,'mesh.edges(:,1:3)','>',0);
     100                                                md = checkfield(md,'mesh.dimension','values',2,'message','Discontinuous Galerkin only supported for 2d meshes');
     101                                                md = checkfield(md,'mesh.edges','size',[NaN 4]);
     102                                                md = checkfield(md,'mesh.edges(:,1:3)','>',0);
    103103                                        end
    104104                                case BalancethicknessSolutionEnum,
    105105                                        if md.balancethickness.stabilization==3,
    106                                                 checkfield(md,'mesh.dimension','values',2,'message','Discontinuous Galerkin only supported for 2d meshes');
    107                                                 checkfield(md,'mesh.edges','size',[NaN 4]);
    108                                                 checkfield(md,'mesh.edges(:,1:3)','>',0);
     106                                                md = checkfield(md,'mesh.dimension','values',2,'message','Discontinuous Galerkin only supported for 2d meshes');
     107                                                md = checkfield(md,'mesh.edges','size',[NaN 4]);
     108                                                md = checkfield(md,'mesh.edges(:,1:3)','>',0);
    109109                                        end
    110110                                case TransientSolutionEnum,
    111111                                        if md.transient.isprognostic & md.prognostic.stabilization==3,
    112                                                 checkfield(md,'mesh.dimension','values',2,'message','Discontinuous Galerkin only supported for 2d meshes');
    113                                                 checkfield(md,'mesh.edges','size',[NaN 4]);
    114                                                 checkfield(md,'mesh.edges(:,1:3)','>',0);
     112                                                md = checkfield(md,'mesh.dimension','values',2,'message','Discontinuous Galerkin only supported for 2d meshes');
     113                                                md = checkfield(md,'mesh.edges','size',[NaN 4]);
     114                                                md = checkfield(md,'mesh.edges(:,1:3)','>',0);
    115115                                        end
    116116                                case ThermalSolutionEnum,
    117                                         checkfield(md,'mesh.dimension','values',3,'message','thermal solution only supported on 3d meshes');
     117                                        md = checkfield(md,'mesh.dimension','values',3,'message','thermal solution only supported on 3d meshes');
    118118                        end
    119119                end % }}}
  • issm/trunk/src/m/classes/miscellaneous.m

    r11995 r12706  
    1919                        end
    2020                end % }}}
    21                 function checkconsistency(obj,md,solution,analyses) % {{{
     21                function md = checkconsistency(obj,md,solution,analyses) % {{{
    2222
    23                         checkfield(md,'miscellaneous.name','empty',1);
     23                        md = checkfield(md,'miscellaneous.name','empty',1);
    2424
    2525                end % }}}
  • issm/trunk/src/m/classes/model/model.m

    r12337 r12706  
    66classdef model
    77    properties (SetAccess=public) %Model fields
    8                  % {{{1
     8                 % {{{
    99                 %Careful here: no other class should be used as default value this is a bug of matlab
    1010                 mesh             = 0;
     
    7575         end
    7676         methods
    77                  function md = model(varargin) % {{{1
     77                 function md = model(varargin) % {{{
    7878
    7979                         switch nargin
     
    8383                                         error('model constructor error message: 0 of 1 argument only in input.');
    8484                                 end
     85                 end
     86                 %}}}
     87                 function md = checkmessage(md,string) % {{{
     88                         if(nargout~=1) error('wrong usage, model must be an output'); end
     89                         disp(['model not consistent: ' string]);
     90                         md.private.isconsistent=false;
    8591                 end
    8692                 %}}}
     
    242248                         if isfield(structmd,'pressureload'), md.diagnostic.icefront=structmd.pressureload; end
    243249                         if isfield(structmd,'diagnostic_ref'), md.diagnostic.referential=structmd.diagnostic_ref; end
    244 
    245 
    246 
    247 
     250                         if isfield(structmd,'npart'); md.qmu.numberofpartitions=structmd.npart; end
     251                         if isfield(structmd,'part'); md.qmu.partition=structmd.part; end
     252                                 
    248253                         %Field changes
    249254                         if (isfield(structmd,'type') & ischar(structmd.type)),
     
    356361                                 md.diagnostic.referential=NaN*ones(md.mesh.numberofvertices,6);
    357362                         end
    358                          if isfield(structmd,'npart'); md.qmu.numberofpartitions=structmd.npart; end
    359                          if isfield(structmd,'part'); md.qmu.partition=structmd.part; end
    360                                  
     363
    361364                 end% }}}
    362                  function md = setdefaultparameters(md) % {{{1
     365                 function md = setdefaultparameters(md) % {{{
    363366
    364367                         %initialize subclasses
  • issm/trunk/src/m/classes/model/planet.m

    r9548 r12706  
    66classdef planet < model
    77    properties (SetAccess=public) %Planet fields
    8                  % {{{1
     8                 % {{{
    99                 %Planet specific fields
    1010                 r=NaN;
     
    1414         end
    1515         methods
    16                 function md=planetmesh(md,varargin) % {{{1
     16                function md=planetmesh(md,varargin) % {{{
    1717                %PLANETMESH: build 2d shell mesh
    1818                %
  • issm/trunk/src/m/classes/organizer.m

    r9423 r12706  
    1616classdef organizer
    1717    properties (SetAccess=private)
    18                  % {{{1
     18                 % {{{
    1919                 currentstep   =0;
    2020         end
     
    2828         end
    2929         methods
    30                  function org=organizer(varargin) % {{{1
     30                 function org=organizer(varargin) % {{{
    3131
    3232                         %process options
     
    5757                 end
    5858                 %}}}
    59                  function disp(org) % {{{1
     59                 function disp(org) % {{{
    6060                         disp(sprintf('   Repository: ''%s''',org.repository));
    6161                         disp(sprintf('   Prefix:     ''%s''',org.prefix));
     
    6969                 end
    7070                 %}}}
    71                  function md=loadmodel(org,string),% {{{1
     71                 function md=load(org,string),% {{{
     72
     73                         %Get model path
     74                         if ~ischar(string), error('argument provided is not a string'); end
     75                         path=[org.repository '/' org.prefix string];
     76
     77                         %figure out if the model is there
     78                         if exist(path,'file'),
     79                                 struc=load(path,'-mat');
     80                                 name=char(fieldnames(struc));
     81                                 md=struc.(name);
     82                                 if nargout,
     83                                         varargout{1}=md;
     84                                 end
     85                         else
     86                                 error(['Could not find ' path ]);
     87                         end
     88                 end%}}}
     89                 function md=loadmodel(org,string),% {{{
    7290
    7391                         %Get model path
     
    7694
    7795                         %figure out if the model is there, otherwise, we have to use the default path supplied by user.
    78                          if exist(path,'file'),
     96                         if exist(path,'file') | exist([path '.mat'],'file'),
    7997                                 md=loadmodel(path);
    8098                                 return;
     
    95113                         end
    96114                 end%}}}
    97                  function bool=perform(org,string) % {{{1
     115                 function bool=perform(org,string) % {{{
    98116                         
    99117                         bool=false;
     
    129147
    130148                 end%}}}
    131                  function savemodel(org,md) % {{{1
     149                 function savemodel(org,md) % {{{
    132150
    133151                         %check
     
    139157                         
    140158                         %check that md is a model
    141                          if ~isa(md,'model'),       error('savemodel error message: third argument is not a model'); end
     159                         if ~isa(md,'model'), warning('third argument is not a model'); end
    142160                         if (org.currentstep>length(org.steps)), error(['organizer error message: element with id ' num2str(org.currentstep) ' not found']); end
    143161
  • issm/trunk/src/m/classes/pairoptions.m

    r11995 r12706  
    223223                        end
    224224                end % }}}
     225                function marshall(obj,fid,firstindex)% {{{
     226
     227                        for i=1:size(obj.list,1),
     228                                name  = obj.list{i,1};
     229                                value = obj.list{i,2};
     230
     231                                %Write option name
     232                                WriteData(fid,'enum',(firstindex-1)+2*i-1,'data',name,'format','String');
     233
     234                                %Write option value
     235                                if (isnumeric(value) & numel(value)==1),
     236                                        WriteData(fid,'enum',(firstindex-1)+2*i,'data',value,'format','Double');
     237                                elseif ischar(value),
     238                                        WriteData(fid,'enum',(firstindex-1)+2*i,'data',value,'format','String');
     239                                else
     240                                        error(['Cannot marshall option ' name ': format not supported yet']);
     241                                end
     242                        end
     243                end % }}}
    225244        end
    226245end
  • issm/trunk/src/m/classes/pairoptions.py

    r12329 r12706  
    1 class pairoptions:
    2         #properties
    3         def __init__(self,*args):
    4                 # {{{ Properties
    5                 if len(args)%2==1:
    6                         raise RuntimeError('pairoption error message: an even number of options is required')
    7 
    8                 #create a pairoption object
    9                 if len(args)==0:
    10                         self.list=[]
    11                 else:
    12                         self.list=[]
    13                         for i in range(int(round(len(args)/2))):
    14                                 if isinstance(args[2*i],str):
    15                                         self.list.append([args[2*i],args[2*i+1]])
     1"""
     2PAIROPTIONS class definition
     3 
     4    Usage:
     5       pairoptions=pairoptions();
     6       pairoptions=pairoptions('module',true,'solver',false);
     7"""
     8
     9from WriteData import *
     10
     11class pairoptions(object):
     12        def __init__(self,*arg):
     13                self.functionname = ''
     14                self.list         = {}
     15
     16                #get calling function name
     17                import inspect
     18                if len(inspect.stack()) > 1:
     19                        self.functionname=inspect.stack()[1][3]
     20
     21                #initialize list
     22                if not len(arg):
     23                        pass    #Do nothing,
     24                else:
     25                        self.buildlist(*arg)
     26        # }}}
     27
     28        def buildlist(self,*arg):    # {{{
     29                """BUILDLIST - build list of objects from input"""
     30
     31                #check length of input
     32                if len(arg) % 2:
     33                        raise TypeError('error: an even number of options is required')
     34                numoptions = len(arg)/2
     35
     36                #go through arg and build list of objects
     37                for i in xrange(numoptions):
     38                        if isinstance(arg[2*i],str):
     39                                self.list[arg[2*i]] = arg[2*i+1];
     40                        else:
     41                                #option is not a string, ignore it
     42                                print "WARNING: option number %d '%s' is not a string and will be ignored." % (i+1,type(arg[2*i]))
     43        # }}}
     44
     45        def addfield(self,field,value):    # {{{
     46                """ADDFIELD - add a field to an options list"""
     47                if isinstance(field,str):
     48                        if field in self.list:
     49                                print "WARNING: field '%s' with value=%s exists and will be overwritten with value=%s." % (field,str(self.list[field]),str(value))
     50                        self.list[field] = value
     51        # }}}
     52
     53        def addfielddefault(self,field,value):    # {{{
     54                """ADDFIELDDEFAULT - add a field to an options list if it does not exist"""
     55                if isinstance(field,str):
     56                        if not field in self.list:
     57                                self.list[field] = value
     58        # }}}
     59
     60        def AssignObjectFields(self,obj2):    # {{{
     61                """ASSIGNOBJECTFIELDS - assign object fields from options"""
     62                for item in self.list.iteritems():
     63                        if item[0] in dir(obj2):
     64                                setattr(obj2,item[0],item[1])
     65                        else:
     66                                print "WARNING: field '%s' is not a property of '%s'." % (item[0],type(obj2))
     67                return obj2
     68        # }}}
     69
     70        def changefieldvalue(self,field,newvalue):    # {{{
     71                """CHANGEOPTIONVALUE - change the value of an option in an option list"""
     72
     73                self.list[field]=newvalue;
     74        # }}}
     75
     76#       function obj = deleteduplicates(obj,warn) % {{{
     77#       %DELETEDUPLICATES - delete duplicates in an option list
     78#
     79#               %track the first occurance of each option
     80#               [dummy lines]=unique(obj.list(:,1),'first');
     81#               clear dummy
     82#
     83#               %warn user if requested
     84#               if warn,
     85#                       numoptions=size(obj.list,1);
     86#                       for i=1:numoptions,
     87#                               if ~ismember(i,lines),
     88#                                       disp(['WARNING: option ' obj.list{i,1} ' appeared more than once. Only its first occurence will be kept'])
     89#                               end
     90#                       end
     91#               end
     92#
     93#               %remove duplicates from the options list
     94#               obj.list=obj.list(lines,:);
     95#       end % }}}
     96
     97        def __repr__(self):    # {{{
     98                s="   functionname: '%s'\n" % self.functionname
     99                if self.list:
     100                        s+="   list: (%ix%i)\n\n" % (len(self.list),2)
     101                        for item in self.list.iteritems():
     102                                if   isinstance(item[1],str):
     103                                        s+="     field: %-10s value: '%s'\n" % (item[0],item[1])
     104                                elif isinstance(item[1],(bool,int,long,float)):
     105                                        s+="     field: %-10s value: %g\n" % (item[0],item[1])
    16106                                else:
    17                                         #option is not a string, ignore it
    18                                         print("%s%i%s"%('buildlist info: option number ',i,' is not a string, it will be ignored'))
    19                                         continue
    20 
    21                 #}}}
    22         def __repr__(obj):
    23                 # {{{ Display
    24                 if not obj.list:
    25                         string='   list: empty'
    26                 else:
    27                         string="   list: (%i)"%(len(obj.list))
    28                         for i in range(len(obj.list)):
    29                                 if isinstance(obj.list[i][1],str):
    30                                         string2="     field: %-10s value: '%s'"%(obj.list[i][0],obj.list[i][1])
    31                                 elif isinstance(obj.list[i][1],float):
    32                                         string2="     field: %-10s value: %g"%(obj.list[i][0],obj.list[i][1])
    33                                 elif isinstance(obj.list[i][1],int):
    34                                         string2="     field: %-10s value: %i"%(obj.list[i][0],obj.list[i][1])
    35                                 else:
    36                                         string2="     field: %-10s value: (%i)"%(len(obj.list[i][1]))
    37                                 string="%s\n%s"%(string,string2)
    38                 return string
     107                                        s+="     field: %-10s value: %s\n" % (item[0],type(item[1]))
     108                else:
     109                        s+="   list: empty\n"
     110                return s
     111        # }}}
     112
     113        def exist(self,field):    # {{{
     114                """EXIST - check if the option exist"""
     115
     116                #some argument checking:
     117                if field == None or field == '':
     118                        raise ValueError('exist error message: bad usage');
     119                if not isinstance(field,str):
     120                        raise TypeError("exist error message: field '%s' should be a string." % str(field));
     121
     122                #Recover option
     123                if field in self.list:
     124                        return True
     125                else:
     126                        return False
     127        # }}}
     128
     129#       function num = fieldoccurences(obj,field), % {{{
     130#       %FIELDOCCURENCES - get number of occurence of a field
     131#
     132#               %check input
     133#               if ~ischar(field),
     134#                       error('fieldoccurences error message: field should be a string');
     135#               end
     136#
     137#               %get number of occurence
     138#               num=sum(strcmpi(field,obj.list(:,1)));
     139#       end % }}}
     140
     141        def getfieldvalue(self,field,default=None):    # {{{
     142                """
     143                GETOPTION - get the value of an option
     144       
     145                Usage:
     146                   value=options.getfieldvalue(field,default)
     147         
     148                Find an option value from a field. A default option
     149                can be given in input if the field does not exist
     150         
     151                Examples:
     152                   value=options.getfieldvalue(options,'caxis')
     153                   value=options.getfieldvalue(options,'caxis',[0 2])
     154                """
     155
     156                #some argument checking:
     157                if field == None or field == '':
     158                        raise ValueError('getfieldvalue error message: bad usage');
     159                if not isinstance(field,str):
     160                        raise TypeError("getfieldvalue error message: field '%s' should be a string." % str(field));
     161
     162                #Recover option
     163                if field in self.list:
     164                        value=self.list[field]
     165                else:
     166                        if not default == None:
     167                                value=default
     168                        else:
     169                                raise KeyError("error message: field '%s' has not been provided by user (and no default value has been specified)." % field)
     170
     171                return value
     172        # }}}
     173
     174        def removefield(self,field,warn):    # {{{
     175                """
     176                REMOVEFIELD - delete a field in an option list
     177         
     178                Usage:
     179                   obj=removefield(self,field,warn)
     180         
     181                if warn==1 display an info message to warn user that
     182                some of his options have been removed.
     183                """
     184
     185                #check if field exist
     186                if field in self.list:
     187
     188                        #remove duplicates from the options list
     189                        del self.list[field]
     190
     191                        #warn user if requested
     192                        if warn:
     193                                print "removefield info: option '%s' has been removed from the list of options." % field
     194        # }}}
     195
     196        def marshall(self,fid,firstindex):    # {{{
     197
     198                for i,item in enumerate(self.list.iteritems()):
     199                        name  = item[0]
     200                        value = item[1]
     201
     202                        #Write option name
     203                        WriteData(fid,'enum',(firstindex-1)+2*i+1,'data',name,'format','String')
     204
     205                        #Write option value
     206                        if   isinstance(value,str):
     207                                WriteData(fid,'enum',(firstindex-1)+2*i+2,'data',value,'format','String')
     208                        elif isinstance(value,(bool,int,long,float)):
     209                                WriteData(fid,'enum',(firstindex-1)+2*i+2,'data',value,'format','Double')
     210                        else:
     211                                raise TypeError("Cannot marshall option '%s': format not supported yet." % name)
     212        # }}}
     213
  • issm/trunk/src/m/classes/plotoptions.m

    r11995 r12706  
    66classdef plotoptions
    77    properties (SetAccess=public)
    8                  % {{{1
     8                 % {{{
    99                 numberofplots = 0;
    1010                 figurenumber  = 1;
     
    1313         end
    1414         methods
    15                  function opt=plotoptions(varargin) % {{{1
     15                 function opt=plotoptions(varargin) % {{{
    1616                         opt=buildlist(opt,varargin{:});
    1717                 end
    1818                 %}}}
    19                  function disp(opt) % {{{1
     19                 function disp(opt) % {{{
    2020                         disp(sprintf('\n%s = \n',inputname(1)));
    2121                         disp(sprintf('   numberofplots: %i',opt.numberofplots));
     
    4141                 end
    4242                 %}}}
    43                  function opt=buildlist(opt,varargin) % {{{1
     43                 function opt=buildlist(opt,varargin) % {{{
    4444
    4545                         %check length of input
  • issm/trunk/src/m/classes/private.m

    r11995 r12706  
    66classdef private
    77        properties (SetAccess=public)
    8                  runtimename = '';
    9                  bamg        = struct();
    10                  solution    = '';
     8                isconsistent = true;
     9                runtimename  = '';
     10                bamg         = struct();
     11                solution     = '';
    1112        end
    1213        methods
     
    2223
    2324                end % }}}
    24                 function checkconsistency(obj,md,solution,analyses) % {{{
     25                function md = checkconsistency(obj,md,solution,analyses) % {{{
    2526
    2627                end % }}}
     
    2829                        disp(sprintf('   private parameters: do not change'));
    2930
     31                        fielddisplay(obj,'isconsistent','is model self consistent');
    3032                        fielddisplay(obj,'runtimename','name of the run launched');
    3133                        fielddisplay(obj,'bamg','structure with mesh properties construced if bamg is used to mesh the domain');
  • issm/trunk/src/m/classes/prognostic.m

    r11995 r12706  
    3636                        obj.hydrostatic_adjustment='Absolute';
    3737                end % }}}
    38                 function checkconsistency(obj,md,solution,analyses) % {{{
     38                function md = checkconsistency(obj,md,solution,analyses) % {{{
    3939
    4040                        %Early return,
    4141                        if ~ismember(PrognosticAnalysisEnum,analyses) |  (solution==TransientSolutionEnum & md.transient.isprognostic==0), return; end
    4242
    43                         checkfield(md,'prognostic.spcthickness','forcing',1);
    44                         checkfield(md,'prognostic.hydrostatic_adjustment','values',{'Absolute' 'Incremental'});
    45                         checkfield(md,'prognostic.stabilization','values',[0 1 2 3]);
    46                         checkfield(md,'prognostic.min_thickness','>',0);
     43                        md = checkfield(md,'prognostic.spcthickness','forcing',1);
     44                        md = checkfield(md,'prognostic.hydrostatic_adjustment','values',{'Absolute' 'Incremental'});
     45                        md = checkfield(md,'prognostic.stabilization','values',[0 1 2 3]);
     46                        md = checkfield(md,'prognostic.min_thickness','>',0);
    4747
    4848                end % }}}
  • issm/trunk/src/m/classes/qmu.m

    r11995 r12706  
    3535       
    3636                end % }}}
    37                 function checkconsistency(obj,md,solution,analyses) % {{{
     37                function md = checkconsistency(obj,md,solution,analyses) % {{{
    3838
    3939                        %Early return
     
    4141
    4242                        if md.qmu.params.evaluation_concurrency~=1,
    43                                 checkmessage(['concurrency should be set to 1 when running dakota in library mode']);
     43                                md = checkmessage(md,['concurrency should be set to 1 when running dakota in library mode']);
    4444                        end
    4545                        if ~isempty(md.qmu.partition),
    4646                                if numel(md.qmu.partition)~=md.mesh.numberofvertices,
    47                                         checkmessage(['user supplied partition for qmu analysis should have size md.mesh.numberofvertices x 1 ']);
     47                                        md = checkmessage(md,['user supplied partition for qmu analysis should have size md.mesh.numberofvertices x 1 ']);
    4848                                end
    4949                                if find(md.qmu.partition)>=md.mesh.numberofvertices,
    50                                         checkmessage(['user supplied partition should be indexed from 0 (c-convention)']);
     50                                        md = checkmessage(md,['user supplied partition should be indexed from 0 (c-convention)']);
    5151                                end
    5252                                if min(md.qmu.partition)~=0,
    53                                         checkmessage(['partition vector not indexed from 0 on']);
     53                                        md = checkmessage(md,['partition vector not indexed from 0 on']);
    5454                                end
    5555                                if max(md.qmu.partition)>=md.mesh.numberofvertices,
    56                                         checkmessage(['partition vector cannot have maximum index larger than number of nodes']);
     56                                        md = checkmessage(md,['partition vector cannot have maximum index larger than number of nodes']);
    5757                                end
    5858                                if ~isempty(find(md.qmu.partition<0)),
    59                                         checkmessage(['partition vector cannot have values less than 0']);
     59                                        md = checkmessage(md,['partition vector cannot have values less than 0']);
    6060                                end
    6161                                if ~isempty(find(md.qmu.partition>=md.qmu.numberofpartitions)),
    62                                         checkmessage(['partition vector cannot have values more than md.qmu.numberofpartitions-1']);
     62                                        md = checkmessage(md,['partition vector cannot have values more than md.qmu.numberofpartitions-1']);
    6363                                end
    6464                                if max(md.qmu.partition)>=md.qmu.numberofpartitions,
    65                                         checkmessage(['for qmu analysis, partitioning vector cannot go over npart, number of partition areas']);
     65                                        md = checkmessage(md,['for qmu analysis, partitioning vector cannot go over npart, number of partition areas']);
    6666                                end
    6767                        end
     
    6969                        if ~strcmpi(md.cluster.name,'none'),
    7070                                if md.settings.waitonlock==0,
    71                                         checkmessage(['waitonlock should be activated when running qmu in parallel mode!']);
     71                                        md = checkmessage(md,['waitonlock should be activated when running qmu in parallel mode!']);
    7272                                end
    7373                        end
  • issm/trunk/src/m/classes/rifts.m

    r11995 r12706  
    2121
    2222                end % }}}
    23                 function checkconsistency(obj,md,solution,analyses) % {{{
     23                function md = checkconsistency(obj,md,solution,analyses) % {{{
    2424                        if isempty(obj.riftstruct) | isnans(obj.riftstruct),
    2525                                numrifts=0;
     
    2929                        if numrifts,
    3030                                if ~(md.mesh.dimension==2),
    31                                         checkmessage(['models with rifts are only supported in 2d for now!']);
     31                                        md = checkmessage(md,['models with rifts are only supported in 2d for now!']);
    3232                                end
    3333                                if ~isstruct(obj.riftstruct),
    34                                         checkmessage(['rifts.riftstruct should be a structure!']);
     34                                        md = checkmessage(md,['rifts.riftstruct should be a structure!']);
    3535                                end
    3636                                if ~isempty(find(md.mesh.segmentmarkers>=2)),
    3737                                        %We have segments with rift markers, but no rift structure!
    38                                         checkmessage(['model should be processed for rifts (run meshprocessrifts)!']);
     38                                        md = checkmessage(md,['model should be processed for rifts (run meshprocessrifts)!']);
    3939                                end
    40                                 checkfield(md,'rifts.riftstruct.fill','values',[WaterEnum() AirEnum() IceEnum() MelangeEnum()]);
     40                                md = checkfield(md,'rifts.riftstruct.fill','values',[WaterEnum() AirEnum() IceEnum() MelangeEnum()]);
    4141                        else
    4242                                if ~isnans(obj.riftstruct),
    43                                         checkmessage(['riftstruct shoud be NaN since numrifts is 0!']);
     43                                        md = checkmessage(md,['riftstruct shoud be NaN since numrifts is 0!']);
    4444                                end
    4545                        end
  • issm/trunk/src/m/classes/settings.m

    r11995 r12706  
    4141                        obj.waitonlock=Inf;
    4242                end % }}}
    43                 function checkconsistency(obj,md,solution,analyses) % {{{
     43                function md = checkconsistency(obj,md,solution,analyses) % {{{
    4444
    45                         checkfield(md,'settings.io_gather','numel',1,'values',[0 1]);
    46                         checkfield(md,'settings.lowmem','numel',1,'values',[0 1]);
    47                         checkfield(md,'settings.results_as_patches','numel',1,'values',[0 1]);
    48                         checkfield(md,'settings.output_frequency','numel',1,'>=',1);
    49                         checkfield(md,'settings.waitonlock','numel',1);
     45                        md = checkfield(md,'settings.io_gather','numel',1,'values',[0 1]);
     46                        md = checkfield(md,'settings.lowmem','numel',1,'values',[0 1]);
     47                        md = checkfield(md,'settings.results_as_patches','numel',1,'values',[0 1]);
     48                        md = checkfield(md,'settings.output_frequency','numel',1,'>=',1);
     49                        md = checkfield(md,'settings.waitonlock','numel',1);
    5050
    5151                end % }}}
  • issm/trunk/src/m/classes/solver.m

    r12329 r12706  
    1818                                 end
    1919                         end % }}}
    20                  function obj = addoptions(obj,analysis,varargin) % {{{1
     20                 function obj = addoptions(obj,analysis,varargin) % {{{
    2121                 % Usage example:
    2222                 %    md.solver=addoptions(md.solver,DiagnosticHorizAnalysisEnum,stokesoptions());
     
    5454                         end
    5555                 end % }}}
    56                  function checkconsistency(obj,md,solution,analyses) % {{{
     56                 function md = checkconsistency(obj,md,solution,analyses) % {{{
    5757                         analyses=properties(obj);
    5858                         for i=1:numel(analyses),
    5959                                 if isempty(fieldnames(obj.(analyses{i})))
    60                                          checkmessage(['md.solver.' analyses{i} ' is empty']);
     60                                         md = checkmessage(md,['md.solver.' analyses{i} ' is empty']);
    6161                                 end
    6262                         end
  • issm/trunk/src/m/classes/steadystate.m

    r11995 r12706  
    2626                        obj.reltol=0.01;
    2727                end % }}}
    28                 function checkconsistency(obj,md,solution,analyses) % {{{
     28                function md = checkconsistency(obj,md,solution,analyses) % {{{
    2929
    3030                        %Early return
     
    3232
    3333                        if md.timestepping.time_step~=0,
    34                                 checkmessage(['for a steadystate computation, timestepping.time_step must be zero.']);
     34                                md = checkmessage(md,['for a steadystate computation, timestepping.time_step must be zero.']);
    3535                        end
    3636
    3737                        if isnan(md.diagnostic.reltol),
    38                                 checkmessage(['for a steadystate computation, diagnostic.reltol (relative convergence criterion) must be defined!']);
     38                                md = checkmessage(md,['for a steadystate computation, diagnostic.reltol (relative convergence criterion) must be defined!']);
    3939                        end
    4040                end % }}}
  • issm/trunk/src/m/classes/surfaceforcings.m

    r12297 r12706  
    99                mass_balance  = NaN;
    1010                ispdd = 0;
     11                issmbgradients = 0;
     12           hc = NaN;
     13                smb_pos_max = NaN;
     14                smb_pos_min = NaN;
     15                a_pos = NaN;
     16                b_pos = NaN;
     17                a_neg = NaN;
     18                b_neg = NaN;
    1119                monthlytemperatures = NaN;
    1220        end
     
    2432                  %pdd method not used in default mode
    2533                  obj.ispdd=0;
     34                  obj.issmbgradients=0;
    2635
    2736                end % }}}
    28                 function checkconsistency(obj,md,solution,analyses) % {{{
     37                function md = checkconsistency(obj,md,solution,analyses) % {{{
    2938
    3039                        if ismember(PrognosticAnalysisEnum,analyses),
    31                                 checkfield(md,'surfaceforcings.ispdd','numel',1,'values',[0 1]);
     40                                md = checkfield(md,'surfaceforcings.ispdd','numel',1,'values',[0 1]);
     41                                checkfield(md,'surfaceforcings.issmbgradients','numel',1,'values',[0 1]);
    3242                                if(obj.ispdd)
    33                                         checkfield(md,'surfaceforcings.monthlytemperatures','forcing',1,'NaN',1);
     43                                        md = checkfield(md,'surfaceforcings.monthlytemperatures','forcing',1,'NaN',1);
     44                                elseif(obj.issmbgradients)
     45                                        checkfield(md,'surfaceforcings.hc','forcing',1,'NaN',1);
     46                                        checkfield(md,'surfaceforcings.smb_pos_max','forcing',1,'NaN',1);
     47                                        checkfield(md,'surfaceforcings.smb_pos_min','forcing',1,'NaN',1);
     48                                        checkfield(md,'surfaceforcings.a_pos','forcing',1,'NaN',1);
     49                                        checkfield(md,'surfaceforcings.b_pos','forcing',1,'NaN',1);
     50                                        checkfield(md,'surfaceforcings.a_neg','forcing',1,'NaN',1);
     51                                        checkfield(md,'surfaceforcings.b_neg','forcing',1,'NaN',1);
    3452                                else
    35                                         checkfield(md,'surfaceforcings.mass_balance','forcing',1,'NaN',1);
     53                                        md = checkfield(md,'surfaceforcings.mass_balance','forcing',1,'NaN',1);
    3654                                end
    3755                        end
    3856                        if ismember(BalancethicknessAnalysisEnum,analyses),
    39                                 checkfield(md,'surfaceforcings.mass_balance','size',[md.mesh.numberofvertices 1],'NaN',1);
     57                                md = checkfield(md,'surfaceforcings.mass_balance','size',[md.mesh.numberofvertices 1],'NaN',1);
    4058                        end
    4159                end % }}}
     
    4765                        fielddisplay(obj,'ispdd','is pdd activated (0 or 1, default is 0)');
    4866                        fielddisplay(obj,'monthlytemperatures','monthly surface temperatures required if pdd is activated');
     67                        fielddisplay(obj,'issmbgradients','is smb gradients method activated (0 or 1, default is 0)');
     68                        fielddisplay(obj,'hc',' elevation of intersection between accumulation and ablation regime required if smb gradients is activated');
     69                        fielddisplay(obj,'smb_pos_max',' maximum value of positive smb required if smb gradients is activated');
     70                        fielddisplay(obj,'smb_pos_min',' minimum value of positive smb required if smb gradients is activated');
     71                        fielddisplay(obj,'a_pos',' intercept of hs - smb regression line for accumulation regime required if smb gradients is activated');
     72                        fielddisplay(obj,'b_pos',' slope of hs - smb regression line for accumulation regime required if smb gradients is activated');
     73                        fielddisplay(obj,'a_neg',' intercept of hs - smb regression line for ablation regime required if smb gradients is activated');
     74                        fielddisplay(obj,'b_neg',' slope of hs - smb regression line for ablation regime required if smb gradients is activated');
    4975
    5076                end % }}}
     
    5682                                WriteData(fid,'object',obj,'fieldname','monthlytemperatures','format','DoubleMat','mattype',1);
    5783                        end
     84                        WriteData(fid,'object',obj,'fieldname','issmbgradients','format','Boolean');
     85                        if obj.issmbgradients,
     86                                WriteData(fid,'object',obj,'fieldname','hc','format','DoubleMat','mattype',1);
     87                                WriteData(fid,'object',obj,'fieldname','smb_pos_max','format','DoubleMat','mattype',1);
     88                                WriteData(fid,'object',obj,'fieldname','smb_pos_min','format','DoubleMat','mattype',1);
     89                                WriteData(fid,'object',obj,'fieldname','a_pos','format','DoubleMat','mattype',1);
     90                                WriteData(fid,'object',obj,'fieldname','b_pos','format','DoubleMat','mattype',1);
     91                                WriteData(fid,'object',obj,'fieldname','a_neg','format','DoubleMat','mattype',1);
     92                                WriteData(fid,'object',obj,'fieldname','b_neg','format','DoubleMat','mattype',1);
     93                        end
    5894
    5995                end % }}}
  • issm/trunk/src/m/classes/thermal.m

    r11995 r12706  
    4040                        obj.isenthalpy=0;
    4141                end % }}}
    42                 function checkconsistency(obj,md,solution,analyses) % {{{
     42                function md = checkconsistency(obj,md,solution,analyses) % {{{
    4343
    4444                        %Early return
    4545                        if (~ismember(ThermalAnalysisEnum,analyses) & ~ismember(EnthalpyAnalysisEnum,analyses)) | (solution==TransientSolutionEnum & md.transient.isthermal==0), return; end
    4646
    47                         checkfield(md,'thermal.stabilization','numel',1,'values',[0 1 2]);
    48                         checkfield(md,'thermal.spctemperature','forcing',1);
    49                         if (ismember(EnthalpyAnalysisEnum,analyses) & md.thermal.isenthalpy),
    50                         checkfield(md,'thermal.spctemperature','<',md.materials.meltingpoint-md.materials.beta*md.materials.rho_ice*md.constants.g*md.geometry.thickness,'message','spctemperature should be below the adjusted melting point');
    51                         checkfield(md,'thermal.isenthalpy','numel',1,'values',[0 1]);
     47                        md = checkfield(md,'thermal.stabilization','numel',1,'values',[0 1 2]);
     48                        md = checkfield(md,'thermal.spctemperature','forcing',1);
     49                        if (ismember(EnthalpyAnalysisEnum,analyses) & md.thermal.isenthalpy & md.mesh.dimension==3),
     50                        md = checkfield(md,'thermal.spctemperature','<',md.materials.meltingpoint-md.materials.beta*md.materials.rho_ice*md.constants.g*(md.geometry.surface-md.mesh.z),'message','spctemperature should be below the adjusted melting point');
     51                        md = checkfield(md,'thermal.isenthalpy','numel',1,'values',[0 1]);
    5252                        end
    5353                end % }}}
  • issm/trunk/src/m/classes/timestepping.m

    r11995 r12706  
    3333                        obj.cfl_coefficient=.5;
    3434                end % }}}
    35                 function checkconsistency(obj,md,solution,analyses) % {{{
     35                function md = checkconsistency(obj,md,solution,analyses) % {{{
    3636
    37                         checkfield(md,'timestepping.start_time','numel',1,'NaN',1);
    38                         checkfield(md,'timestepping.final_time','numel',1,'NaN',1);
    39                         checkfield(md,'timestepping.time_step','numel',1,'>=',0,'NaN',1);
    40                         checkfield(md,'timestepping.time_adapt','numel',1,'values',[0 1]);
    41                         checkfield(md,'timestepping.cfl_coefficient','numel',1,'>',0,'<=',1);
     37                        md = checkfield(md,'timestepping.start_time','numel',1,'NaN',1);
     38                        md = checkfield(md,'timestepping.final_time','numel',1,'NaN',1);
     39                        md = checkfield(md,'timestepping.time_step','numel',1,'>=',0,'NaN',1);
     40                        md = checkfield(md,'timestepping.time_adapt','numel',1,'values',[0 1]);
     41                        md = checkfield(md,'timestepping.cfl_coefficient','numel',1,'>',0,'<=',1);
    4242                        if obj.final_time-obj.start_time<0,
    43                                 checkmessage('timestepping.final_time should be larger than timestepping.start_time');
     43                                md = checkmessage(md,'timestepping.final_time should be larger than timestepping.start_time');
    4444                        end
    4545                end % }}}
  • issm/trunk/src/m/classes/transient.m

    r11995 r12706  
    3030
    3131                end % }}}
    32                 function checkconsistency(obj,md,solution,analyses) % {{{
     32                function md = checkconsistency(obj,md,solution,analyses) % {{{
    3333
    3434                        %Early return
    3535                        if solution~=TransientSolutionEnum, return; end
    3636
    37                         checkfield(md,'transient.isprognostic','numel',1,'values',[0 1]);
    38                         checkfield(md,'transient.isdiagnostic','numel',1,'values',[0 1]);
    39                         checkfield(md,'transient.isthermal','numel',1,'values',[0 1]);
    40                         checkfield(md,'transient.isgroundingline','numel',1,'values',[0 1]);
     37                        md = checkfield(md,'transient.isprognostic','numel',1,'values',[0 1]);
     38                        md = checkfield(md,'transient.isdiagnostic','numel',1,'values',[0 1]);
     39                        md = checkfield(md,'transient.isthermal','numel',1,'values',[0 1]);
     40                        md = checkfield(md,'transient.isgroundingline','numel',1,'values',[0 1]);
    4141
    4242                end % }}}
  • issm/trunk/src/m/classes/verbose.m

    r11995 r12706  
    2121classdef verbose
    2222        properties (SetAccess=public)
    23                 % {{{1
     23                % {{{
    2424                %BEGINFIELDS
    2525                mprocessor  = false;
     
    3535        %}}}
    3636        methods
    37                 function verbose=verbose(varargin) % {{{1
     37                function verbose=verbose(varargin) % {{{
    3838
    3939                        switch(nargin),
     
    7070                end
    7171                %}}}
    72                 function binary=VerboseToBinary(verbose) % {{{1
     72                function binary=VerboseToBinary(verbose) % {{{
    7373
    7474                %BEGINVERB2BIN
     
    8585                end
    8686                %}}}
    87                 function verbose=BinaryToVerbose(verbose,binary) % {{{1
     87                function verbose=BinaryToVerbose(verbose,binary) % {{{
    8888
    8989                %BEGINBIN2VERB
     
    9999                end
    100100                %}}}
    101                 function checkconsistency(obj,md,solution,analyses) % {{{
     101                function md = checkconsistency(obj,md,solution,analyses) % {{{
    102102
    103103                end % }}}
    104                 function disp(verbose) % {{{1
     104                function disp(verbose) % {{{
    105105                       
    106106                %BEGINDISP
  • issm/trunk/src/m/enum/MaximumNumberOfEnums.m

    r12329 r12706  
    99%      macro=MaximumNumberOfEnums()
    1010
    11 macro=440;
     11macro=448;
  • issm/trunk/src/m/model/SectionValues.m

    r11995 r12706  
    1212if ischar(infile),
    1313        %read infile:
    14         contempt=expread(infile);
    15         nods=contempt.nods;
    16         x=contempt.x;
    17         y=contempt.y;
     14        profile=expread(infile);
     15        nods=profile.nods;
     16        x=profile.x;
     17        y=profile.y;
    1818else
    1919        %read infile:
  • issm/trunk/src/m/model/WriteData.m

    r10981 r12706  
    3535%Step 2: write the data itself.
    3636if     strcmpi(format,'Boolean'),% {{{
    37         if(numel(data)~=1), error(['field ' field ' cannot be marshalled as it has more than one element!']); end
     37        if(numel(data)~=1), error(['field ' EnumToString(enum) ' cannot be marshalled as it has more than one element!']); end
    3838
    3939        %first write length of record
     
    5959        % }}}
    6060elseif strcmpi(format,'Double'), % {{{
    61         if(numel(data)~=1), error(['field ' field ' cannot be marshalled as it has more than one element!']); end
     61        if(numel(data)~=1), error(['field ' EnumToString(enum) ' cannot be marshalled as it has more than one element!']); end
    6262
    6363        %first write length of record
     
    233233        enum=eval([string 'Enum();']);
    234234end % }}}
    235 function code=FormatToCode(format) % {{{1
     235function code=FormatToCode(format) % {{{
    236236%This routine takes the format string, and hardcodes it into an integer, which
    237237%is passed along the record, in order to identify the nature of the dataset being
  • issm/trunk/src/m/model/averaging.m

    r9734 r12706  
    1 function average=averaging(md,data,iterations)
     1function average=averaging(md,data,iterations,varargin)
    22%AVERAGING - smooths the input over the mesh
    33%
     
    88%   by taking the average of the element around a node weighted by the
    99%   elements volume
     10%   For 3d mesh, a last argument can be added to specify the layer to be averaged on.
    1011%
    1112%   Usage:
    1213%      smoothdata=averaging(md,data,iterations)
     14%      smoothdata=averaging(md,data,iterations,layer)
    1315%
    1416%   Examples:
    1517%      velsmoothed=averaging(md,md.initialization.vel,4);
    1618%      pressure=averaging(md,md.initialization.pressure,0);
     19%      temperature=averaging(md,md.initialization.temperature,1,1);
    1720
    18 if length(data)~=md.mesh.numberofelements & length(data)~=md.mesh.numberofvertices
     21if ((nargin~=4) & (nargin~=3)),
     22        error('averaging error message');
     23end
     24if (length(data)~=md.mesh.numberofelements & length(data)~=md.mesh.numberofvertices),
    1925        error('averaging error message: data not supported yet');
     26end
     27if md.mesh.dimension==3 & nargin==4,
     28        if varargin{1}<=0 | varargin{1}>md.mesh.numberoflayers,
     29                error('layer should be between 1 and md.mesh.numberoflayers');
     30        end
     31        layer=varargin{1};
     32else
     33        layer=0;
    2034end
    2135
    2236%initialization
    23 weights=zeros(md.mesh.numberofvertices,1);
    24 data=data(:);
     37if layer==0,
     38        weights=zeros(md.mesh.numberofvertices,1);
     39        data=data(:);
     40else
     41        weights=zeros(md.mesh.numberofvertices2d,1);
     42        data=data((layer-1)*md.mesh.numberofvertices2d+1:layer*md.mesh.numberofvertices2d,:);
     43end
    2544
    26 %load some variables (it is much faster if the variab;es are loaded from md once for all)
    27 index=md.mesh.elements;
    28 numberofnodes=md.mesh.numberofvertices;
    29 numberofelements=md.mesh.numberofelements;
     45%load some variables (it is much faster if the variabes are loaded from md once for all)
     46if layer==0,
     47        index=md.mesh.elements;
     48        numberofnodes=md.mesh.numberofvertices;
     49        numberofelements=md.mesh.numberofelements;
     50else
     51        index=md.mesh.elements2d;
     52        numberofnodes=md.mesh.numberofvertices2d;
     53        numberofelements=md.mesh.numberofelements2d;
     54end
    3055
    3156%build some variables
    3257line=index(:);
    33 if md.mesh.dimension==3
     58if md.mesh.dimension==3 & layer==0,
    3459        rep=6;
    3560        areas=GetAreas(index,md.mesh.x,md.mesh.y,md.mesh.z);
     61elseif md.mesh.dimension==2,
     62        rep=3;
     63        areas=GetAreas(index,md.mesh.x,md.mesh.y);
    3664else
    3765        rep=3;
    38         areas=GetAreas(index,md.mesh.x,md.mesh.y);
     66        areas=GetAreas(index,md.mesh.x2d,md.mesh.y2d);
    3967end
    4068summation=1/rep*ones(rep,1);
  • issm/trunk/src/m/model/collapse.m

    r12329 r12706  
    4242if ~isnan(md.initialization.vz),md.initialization.vz=DepthAverage(md,md.initialization.vz);end;
    4343if ~isnan(md.initialization.vel),md.initialization.vel=DepthAverage(md,md.initialization.vel);end;
     44if ~isnan(md.initialization.temperature),md.initialization.temperature=DepthAverage(md,md.initialization.temperature);end;
    4445
    4546%bedinfo and surface info
     
    9192md.geometry.thickness=project2d(md,md.geometry.thickness,1);
    9293md.geometry.bed=project2d(md,md.geometry.bed,1);
     94md.geometry.bathymetry=project2d(md,md.geometry.bathymetry,1);
    9395md.mesh.vertexonboundary=project2d(md,md.mesh.vertexonboundary,1);
    9496md.mesh.elementconnectivity=project2d(md,md.mesh.elementconnectivity,1);
  • issm/trunk/src/m/model/contourenvelope.m

    r9734 r12706  
    3535%Now, build the connectivity tables for this mesh.
    3636%Computing connectivity
    37 if size(md.mesh.vertexconnectivity,1)~=md.mesh.numberofvertices,
     37if (size(md.mesh.vertexconnectivity,1)~=md.mesh.numberofvertices & size(md.mesh.vertexconnectivity,1)~=md.mesh.numberofvertices2d),
    3838        md.mesh.vertexconnectivity=NodeConnectivity(md.mesh.elements,md.mesh.numberofvertices);
    3939end
    40 if size(md.mesh.elementconnectivity,1)~=md.mesh.numberofelements,
     40if (size(md.mesh.elementconnectivity,1)~=md.mesh.numberofelements & size(md.mesh.elementconnectivity,1)~=md.mesh.numberofelements2d),
    4141        md.mesh.elementconnectivity=ElementConnectivity(md.mesh.elements,md.mesh.vertexconnectivity);
    4242end
     
    4444%get nodes inside profile
    4545mesh.elementconnectivity=md.mesh.elementconnectivity;
     46if md.mesh.dimension==2;
     47        mesh.elements=md.mesh.elements;
     48        mesh.x=md.mesh.x;
     49        mesh.y=md.mesh.y;
     50        mesh.numberofvertices=md.mesh.numberofvertices;
     51        mesh.numberofelements=md.mesh.numberofelements;
     52else
     53        mesh.elements=md.mesh.elements2d;
     54        mesh.x=md.mesh.x2d;
     55        mesh.y=md.mesh.y2d;
     56        mesh.numberofvertices=md.mesh.numberofvertices2d;
     57        mesh.numberofelements=md.mesh.numberofelements2d;
     58end
     59
    4660if nargin==2,
     61
    4762        if isfile,
    4863                %get flag list of elements and nodes inside the contour
    49                 nodein=ContourToMesh(md.mesh.elements,md.mesh.x,md.mesh.y,file,'node',1);
    50                 elemin=(sum(nodein(md.mesh.elements),2)==size(md.mesh.elements,2));
     64                nodein=ContourToMesh(mesh.elements,mesh.x,mesh.y,file,'node',1);
     65                elemin=(sum(nodein(mesh.elements),2)==size(mesh.elements,2));
    5166                %modify element connectivity
    5267                elemout=find(~elemin);
     
    5570        else
    5671                %get flag list of elements and nodes inside the contour
    57                 nodein=zeros(md.mesh.numberofvertices,1);
    58                 elemin=zeros(md.mesh.numberofelements,1);
     72                nodein=zeros(mesh.numberofvertices,1);
     73                elemin=zeros(mesh.numberofelements,1);
    5974               
    6075                pos=find(flags);
    6176                elemin(pos)=1;
    62                 nodein(md.mesh.elements(pos,:))=1;
     77                nodein(mesh.elements(pos,:))=1;
    6378
    6479                %modify element connectivity
     
    87102        els2=mesh.elementconnectivity(el1,find(mesh.elementconnectivity(el1,:)));
    88103        if length(els2)>1,
    89                 flag=intersect(md.mesh.elements(els2(1),:),md.mesh.elements(els2(2),:));
    90                 nods1=md.mesh.elements(el1,:);
     104                flag=intersect(mesh.elements(els2(1),:),mesh.elements(els2(2),:));
     105                nods1=mesh.elements(el1,:);
    91106                nods1(find(nods1==flag))=[];
    92107                segments(count,:)=[nods1 el1];
    93108
    94                 ord1=find(nods1(1)==md.mesh.elements(el1,:));
    95                 ord2=find(nods1(2)==md.mesh.elements(el1,:));
     109                ord1=find(nods1(1)==mesh.elements(el1,:));
     110                ord2=find(nods1(2)==mesh.elements(el1,:));
    96111
    97112                %swap segment nodes if necessary
     
    104119                count=count+1;
    105120        else
    106                 nods1=md.mesh.elements(el1,:);
    107                 flag=setdiff(nods1,md.mesh.elements(els2,:));
     121                nods1=mesh.elements(el1,:);
     122                flag=setdiff(nods1,mesh.elements(els2,:));
    108123                for j=1:3,
    109124                        nods=nods1; nods(j)=[];
    110125                        if any(ismember(flag,nods)),
    111126                                segments(count,:)=[nods el1];
    112                                 ord1=find(nods(1)==md.mesh.elements(el1,:));
    113                                 ord2=find(nods(2)==md.mesh.elements(el1,:));
     127                                ord1=find(nods(1)==mesh.elements(el1,:));
     128                                ord2=find(nods(2)==mesh.elements(el1,:));
    114129                                if ( (ord1==1 & ord2==2) | (ord1==2 & ord2==3) | (ord1==3 & ord2==1) ),
    115130                                        temp=segments(count,1);
  • issm/trunk/src/m/model/ismodelselfconsistent.m

    r11237 r12706  
    66
    77%initialize consistency as true
    8 modelconsistency(true);
     8md.private.isconsistent=true;
    99
    1010%Get solution and associated analyses
     
    2424        %Check that current field is an object
    2525        if ~isobject(md.(field))
    26                 checkmessage(['field ''' char(field) ''' is not an object']);
     26                md=checkmessage(md,['field ''' char(field) ''' is not an object']);
    2727        end
    2828
    2929        %Check consistency of the object
    3030        if verLessThan('matlab', '7.6')
    31                 checkconsistency(md.(field),md,solution,analyses);
     31                md=checkconsistency(md.(field),md,solution,analyses);
    3232        else
    33                 md.(field).checkconsistency(md,solution,analyses);
     33                md=md.(field).checkconsistency(md,solution,analyses);
    3434        end
    3535end
    3636
    3737%error message if mode is not consistent
    38 if modelconsistency==false,
    39         error(' ');
     38if md.private.isconsistent==false,
     39        error('Model not consistent, see messages above');
    4040end
  • issm/trunk/src/m/model/loadresultsfromcluster.m

    r11527 r12706  
    1313
    1414%Download outputs from the cluster
    15 if verLessThan('matlab', '7.6');
    16         Download(cluster,md);
     15filelist={[md.miscellaneous.name '.outlog'],[md.miscellaneous.name '.errlog']};
     16if md.qmu.isdakota,
     17        filelist{end+1}=[md.miscellaneous.name '.qmu.err'];
     18        filelist{end+1}=[md.miscellaneous.name '.qmu.out'];
     19        if isfield(md.qmu.params,'tabular_graphics_data'),
     20                if md.qmu.params.tabular_graphics_data==true,
     21                        filelist{end+1}='dakota_tabular.dat';
     22                end
     23        end
    1724else
    18         cluster.Download(md);
     25        filelist{end+1}=[md.miscellaneous.name '.outbin'];
    1926end
     27Download(cluster,md.private.runtimename,filelist);
    2028
    2129%If we are here, no errors in the solution sequence, call loadresultsfromdisk.
  • issm/trunk/src/m/model/loadresultsfromdisk.m

    r11527 r12706  
    5959        md=postqmu(md);
    6060        cd ..
    61 
    6261end
  • issm/trunk/src/m/model/marshall.m

    r12329 r12706  
    3131        %Check that current field is an object
    3232        if ~isobject(md.(field))
    33                 checkmessage(['field ''' char(field) ''' is not an object']);
     33                error(['field ''' char(field) ''' is not an object']);
    3434        end
    3535
  • issm/trunk/src/m/model/mesh/bamg.m

    r11995 r12706  
    5858bamg_mesh=bamgmesh;
    5959
    60 % Bamg Geometry parameters {{{1
     60% Bamg Geometry parameters {{{
    6161if exist(options,'domain'),
    6262
     
    259259end
    260260%}}}
    261 % Bamg Mesh parameters {{{1
     261% Bamg Mesh parameters {{{
    262262if (~exist(options,'domain') & md.mesh.numberofvertices~=0 & md.mesh.dimension==2),
    263263
     
    274274end
    275275%}}}
    276 % Bamg Options {{{1
     276% Bamg Options {{{
    277277bamg_options.Crack=getfieldvalue(options,'Crack',0);
    278278bamg_options.anisomax=getfieldvalue(options,'anisomax',10^30);
  • issm/trunk/src/m/model/modelextract.m

    r11237 r12706  
    166166        if size(md2.mesh.edges,2)>1, %do not use ~isnan because there are some NaNs...
    167167                %renumber first two columns
    168                 pos=find(~isnan(md2.mesh.edges(:,4)));
     168                pos=find(md2.mesh.edges(:,4)~=-1);
    169169                md2.mesh.edges(:  ,1)=Pnode(md2.mesh.edges(:,1));
    170170                md2.mesh.edges(:  ,2)=Pnode(md2.mesh.edges(:,2));
     
    173173                %remove edges when the 2 vertices are not in the domain.
    174174                md2.mesh.edges=md2.mesh.edges(find(md2.mesh.edges(:,1) & md2.mesh.edges(:,2)),:);
    175                 %Replace all zeros by NaN in the last two columns;
     175                %Replace all zeros by -1 in the last two columns;
    176176                pos=find(md2.mesh.edges(:,3)==0);
    177                 md2.mesh.edges(pos,3)=NaN;
     177                md2.mesh.edges(pos,3)=-1;
    178178                pos=find(md2.mesh.edges(:,4)==0);
    179                 md2.mesh.edges(pos,4)=NaN;
    180                 %Invert NaN of the third column with last column (Also invert first two columns!!)
    181                 pos=find(isnan(md2.mesh.edges(:,3)));
     179                md2.mesh.edges(pos,4)=-1;
     180                %Invert -1 on the third column with last column (Also invert first two columns!!)
     181                pos=find(md2.mesh.edges(:,3)==-1);
    182182                md2.mesh.edges(pos,3)=md2.mesh.edges(pos,4);
    183                 md2.mesh.edges(pos,4)=NaN;
     183                md2.mesh.edges(pos,4)=-1;
    184184                values=md2.mesh.edges(pos,2);
    185185                md2.mesh.edges(pos,2)=md2.mesh.edges(pos,1);
    186186                md2.mesh.edges(pos,1)=values;
    187187                %Finally remove edges that do not belong to any element
    188                 pos=find(isnan(md2.mesh.edges(:,3)) & isnan(md2.mesh.edges(:,4)));
     188                pos=find(md2.mesh.edges(:,3)==-1 & md2.mesh.edges(:,4)==-1);
    189189                md2.mesh.edges(pos,:)=[];
    190190        end
     
    210210                md2.mesh.segments=contourenvelope(md2);
    211211                md2.mesh.vertexonboundary=zeros(numberofvertices2,1); md2.mesh.vertexonboundary(md2.mesh.segments(:,1:2))=1;
     212        else
     213                %First do the connectivity for the contourenvelope in 2d
     214                md2.mesh.vertexconnectivity=NodeConnectivity(md2.mesh.elements2d,md2.mesh.numberofvertices2d);
     215                md2.mesh.elementconnectivity=ElementConnectivity(md2.mesh.elements2d,md2.mesh.vertexconnectivity);
     216                md2.mesh.segments=contourenvelope(md2);
     217                md2.mesh.vertexonboundary=zeros(numberofvertices2/md2.mesh.numberoflayers,1); md2.mesh.vertexonboundary(md2.mesh.segments(:,1:2))=1;
     218                md2.mesh.vertexonboundary=repmat(md2.mesh.vertexonboundary,md2.mesh.numberoflayers,1);
     219                %Then do it for 3d as usual
     220                md2.mesh.vertexconnectivity=NodeConnectivity(md2.mesh.elements,md2.mesh.numberofvertices);
     221                md2.mesh.elementconnectivity=ElementConnectivity(md2.mesh.elements,md2.mesh.vertexconnectivity);
    212222        end
    213223
  • issm/trunk/src/m/model/plot/applyoptions.m

    r12329 r12706  
    3131end
    3232
    33 %xlabel
     33%xlabel, ylabel and zlabel
    3434if exist(options,'xlabel');
    3535        xlabel(getfieldvalue(options,'xlabel'),'FontSize',fontsize,'FontWeight',fontweight);
    3636end
    37 
    38 %ylabel
    3937if exist(options,'ylabel');
    4038        ylabel(getfieldvalue(options,'ylabel'),'FontSize',fontsize,'FontWeight',fontweight);
    4139end
    42 
    43 %zlabel
    4440if exist(options,'zlabel');
    4541        zlabel(getfieldvalue(options,'zlabel'),'FontSize',fontsize,'FontWeight',fontweight);
    4642end
    4743
    48 %xtikcs
     44%xticks, yticks and zticks
    4945if exist(options,'xtick'), set(gca,'XTick',getfieldvalue(options,'xtick')); end
    5046if exist(options,'ytick'), set(gca,'YTick',getfieldvalue(options,'ytick')); end
     
    7571end
    7672
    77 %xlim
     73%xlim, ylim and zlim
    7874if exist(options,'xlim');
    7975        xlim(getfieldvalue(options,'xlim'));
    8076end
    81 
    82 %ylim
    8377if exist(options,'ylim');
    8478        ylim(getfieldvalue(options,'ylim'));
     79end
     80if exist(options,'zlim');
     81        zlim(getfieldvalue(options,'zlim'));
    8582end
    8683
     
    9289end
    9390
    94 
    95 %zlim
    96 if exist(options,'zlim');
    97         zlim(getfieldvalue(options,'zlim'));
    98 end
    99 
    10091%Basinzoom
    10192if exist(options,'basin');
     
    10798        showbasins(options);
    10899end
    109 
    110100
    111101%Caxis
     
    127117
    128118%colormap
    129 if exist(options,'colormap'),
    130         cname=getfieldvalue(options,'colormap');
    131         if strcmpi(cname,'Ala'),
    132                 c = jet(64);
    133                 c = c (32:end,:);
    134         elseif strcmpi(cname,'redblue'),
    135                 %m = 30;
    136                 %n = fix(0.5*m);
    137                 %r = [(0:1:n-1)/n,ones(1,n)];
    138                 %g = [(0:n-1)/n, (n-1:-1:0)/n];
    139                 %b = [ones(1,n),(n-1:-1:0)/n];
    140                 %c = [r(:), g(:), b(:)];
    141 
    142                 c = hsv(64);
    143                 c = rgb2hsv(c);
    144                 c(:,2) = max(min( abs(c(:,1)-0.5)/0.5 ,1),0);
    145                 c(1:32,1)   = 0.7;
    146                 c(33:end,1) = 1;
    147                 c = hsv2rgb(c);
    148 
    149         elseif strcmpi(cname,'Rignot'),
    150                 c = hsv;
    151 
    152                 %adjust saturation
    153                 c = rgb2hsv(c);
    154                 alpha=getfieldvalue(options,'alpha',1);
    155                 c(:,2) = max(min( (0.1+c(:,1)).^(1/alpha) ,1),0);
    156                 c = hsv2rgb(c);
    157 
    158         elseif strcmpi(cname,'Rignot2'),
    159                 c = hsv;
    160 
    161                 %adjust saturation
    162                 c = rgb2hsv(c);
    163                 alpha=getfieldvalue(options,'alpha',1);
    164                 c(:,2) = max(min( (0.1+c(:,1)).^(1/alpha) ,1),0);
    165                 c = hsv2rgb(c);
    166 
    167                 c=flipud(c);
    168 
    169         else
    170                 c = cname;
    171         end
    172         h=colormap(c);
    173 else
    174         h=colormap(jet(60));
    175 end
     119c = getcolormap(options);
     120h = colormap(c);
    176121
    177122%wrapping
     
    375320                        left=screen(1); bott=screen(2); widt=screen(3); heig=screen(4)-25;
    376321                        set(gcf,'Position',fix([left bott widt/2 heig]));
     322                elseif strcmpi(figposition,'square'),
     323                        screen=get(0,'ScreenSize');
     324                        left=screen(1); bott=screen(2); widt=min(screen(3)-25,screen(4)-25);
     325                        set(gcf,'Position',fix([left+(screen(3)-widt) bott widt widt]));
    377326                elseif strcmpi(figposition,'portrait'),
    378327                        %reformat with letter paper size (8.5" x 11")
  • issm/trunk/src/m/model/plot/plot_gridded.m

    r12329 r12706  
    66%
    77%   See also: PLOTMODEL
    8 
    9 whitepos=getfieldvalue(options,'whitepos',2); %1: up, 2: down, else: none
    108
    119%process mesh and data
     
    2927end
    3028
     29%Get and change colormap
     30map    = getcolormap(options);
     31lenmap = size(map,1);
     32map    = [1 1 1; map];
     33options=changefieldvalue(options,'colormap',map);
     34
    3135%Process data_grid: add white in NaN and correct caxis accordingly
    3236if exist(options,'caxis'),
     
    4044        data_max=max(data_grid(:));
    4145end
    42 options=changefieldvalue(options,'cbYLim',[data_min data_max]);
    43 if whitepos==1,
    44         white  =data_max + (data_max-data_min)/55;
    45         options=changefieldvalue(options,'caxis',[data_min white]);
    46         data_grid(isnan(data_grid))=white;
    47 elseif whitepos==2,
    48         white  =data_min - (data_max-data_min)/55;
    49         options=changefieldvalue(options,'caxis',[white data_max]);
    50         data_grid(isnan(data_grid))=white;
    51 end
     46options = changefieldvalue(options,'cbYLim',[data_min data_max]);
     47white   = data_min - (data_max-data_min)/(lenmap);
     48options = changefieldvalue(options,'caxis',[white data_max]);
     49data_grid(isnan(data_grid))=white;
    5250
    5351%Select plot area
     
    5654%shading interp;
    5755h=imagesc(xlim,ylim,data_grid);set(gca,'YDir','normal');
    58 map=getfieldvalue(options,'colormap',jet);
    59 if whitepos==1,
    60         map(end,:)=[1 1 1];
    61 elseif whitepos==2,
    62         map(1,:)=[1 1 1];
    63 end
    64 options=changefieldvalue(options,'colormap',map);
    6556
    6657%last step: mesh gridded?
  • issm/trunk/src/m/model/plot/plot_manager.m

    r11527 r12706  
    165165if exist(options,'sectionvalue')
    166166        plot_section(md,data,options,nlines,ncols,i);
     167        return;
     168end
     169
     170%Figure out if this is a Profile plot
     171if exist(options,'profile')
     172        plot_profile(md,data,options,nlines,ncols,i);
    167173        return;
    168174end
  • issm/trunk/src/m/model/plot/plot_overlay.m

    r12329 r12706  
    4141        md=radarpower(md,options);
    4242end
     43contrast = getfieldvalue(options,'contrast',1); 
     44radar = (md.radaroverlay.pwr).^(contrast);
     45radar = radar./max(radar(:));
     46%radar(find(radar==0))=1; %Change background from black to white
    4347
    4448%InterpFromMeshToGrid
     
    5054ncols =length(md.radaroverlay.x);
    5155disp('Interpolating data on grid...');
    52 [x_m y_m data_grid]=InterpFromMeshToGrid(elements,x/getfieldvalue(options,'unit',1),y/getfieldvalue(options,'unit',1),...
    53         data,xmin,ymax,xspacing,yspacing,nlines,ncols,NaN);
     56if radaronly,
     57        x_m=xmin:xspacing:xmin+ncols*xspacing;
     58        y_m=ymax-nlines*yspacing:yspacing:ymax;
     59        data_grid=NaN*ones(nlines,ncols);
     60else
     61        [x_m y_m data_grid]=InterpFromMeshToGrid(elements,x/getfieldvalue(options,'unit',1),y/getfieldvalue(options,'unit',1),...
     62                data,xmin,ymax,xspacing,yspacing,nlines,ncols,NaN);
     63end
    5464
    55 %Process data_grid
     65%Process data_grid (For processing, it is better not to have nan)
    5666pos=find(isinf(data_grid));
    5767if ~isempty(pos),
     
    7080end
    7181data_nan=find(isnan(data_grid));
    72 
    73 %Generate HSV image
    74 contrast=getfieldvalue(options,'contrast',1); 
    75 transparency=getfieldvalue(options,'alpha',1);
    7682data_grid(data_nan)=data_min;
    7783
     84%Special colormaps that require hsv treatment
    7885colorm=getfieldvalue(options,'colormap','Rignot');
    79 if strcmpi(colorm,'Rignot'),
    80         %hue (H)
    81         h_data=(data_grid-data_min)/(data_max-data_min+eps);
    82         if radaronly, h_data(:)=0; end
    83         %saturation (S)
    84         s_data=max(min((0.1+h_data).^(1/transparency),1),0);
    85 elseif strcmpi(colorm,'Seroussi'),
    86         %hue (H)
    87         h_data=1-(data_grid-data_min)/(data_max-data_min+eps)*0.7;
    88         %h_data=(data_grid-data_min)/(data_max-data_min)*2/3;
    89         if radaronly, h_data(:)=0; end
    90         %saturation (S)
    91         s_data=max(min((0.1+h_data).^(1/transparency),1),0);
    92 elseif strcmpi(colorm,'redblue')
    93         data_mean=data_min+(data_max-data_min)/2;
    94         %hue (H)
    95         %h_data=0.7*ones(size(data_grid));
    96         %h_data(find(data_grid>data_mean))=1;
    97         h_data=1*ones(size(data_grid));
    98         h_data(find(data_grid<data_mean))=0.7;
    99         %saturation (S)
    100         s_data=max(min(abs(data_grid-data_mean)/(data_max-data_mean) ,1),0);
     86if strcmpi(colorm,'Rignot') | strcmpi(colorm,'Seroussi') | strcmpi(colorm,'redblue')
     87        if strcmpi(colorm,'Rignot'),
     88                transparency=getfieldvalue(options,'alpha',1);
     89                h=(data_grid-data_min)/(data_max-data_min+eps);
     90                if radaronly, h(:)=0; end
     91                s=max(min((0.1+h).^(1/transparency),1),0);
     92        elseif strcmpi(colorm,'Seroussi'),
     93                transparency=getfieldvalue(options,'alpha',1);
     94                h=1-(data_grid-data_min)/(data_max-data_min+eps)*0.7;
     95                if radaronly, h(:)=0; end
     96                s=max(min((0.1+h).^(1/transparency),1),0);
     97        elseif strcmpi(colorm,'redblue')
     98                data_mean=data_min+(data_max-data_min)/2;
     99                h=1*ones(size(data_grid));
     100                h(find(data_grid<data_mean))=0.7;
     101                s=max(min(abs(data_grid-data_mean)/(data_max-data_mean) ,1),0);
     102        else
     103                error('colormap not supported yet. (''Rignot'' and ''redblue'' are the only cupported colormaps)');
     104        end
     105        %(S) Saturation is 0 in NaNs
     106        s(data_nan)=0;
     107        %(V) intensity is based on radar image
     108        v=radar; %use radar power as intensity
     109
     110        %Transform HSV to RGB
     111        image_hsv=zeros(size(data_grid,1),size(data_grid,2),3);
     112        image_hsv(:,:,1)=h; clear h;
     113        image_hsv(:,:,2)=s; clear s;
     114        image_hsv(:,:,3)=v; clear v;
     115        image_rgb=hsv2rgb(image_hsv);
    101116else
    102         error('colormap not supported yet. (''Rignot'' and ''redblue'' are the only cupported colormaps)');
     117        colorm = getcolormap(options);
     118        len    = size(colorm,1);
     119
     120        ind = ceil((len-1)*(data_grid-data_min)/(data_max - data_min + eps) +1);
     121        ind(find(ind>len))=len;
     122        image_rgb=zeros(size(data_grid,1),size(data_grid,2),3);
     123        r=colorm(:,1); image_rgb(:,:,1)=r(ind); clear r;
     124        g=colorm(:,2); image_rgb(:,:,2)=g(ind); clear g;
     125        b=colorm(:,3); image_rgb(:,:,3)=b(ind); clear b;
     126
     127        %Now add radarmap
     128        r = image_rgb(:,:,1).*radar;  r(data_nan) = radar(data_nan);  image_rgb(:,:,1) = r;  clear r;
     129        g = image_rgb(:,:,2).*radar;  g(data_nan) = radar(data_nan);  image_rgb(:,:,2) = g;  clear g;
     130        b = image_rgb(:,:,3).*radar;  b(data_nan) = radar(data_nan);  image_rgb(:,:,3) = b;  clear b;
    103131end
    104 
    105 %Saturation is 0 in NaNs
    106 s_data(data_nan)=0;
    107 %intensity (V)
    108 radar=(md.radaroverlay.pwr).^(contrast);
    109 v_data=radar/max(radar(:)); %use radar power as intensity
    110 
    111 %Change background from black to white
    112 %pos=find(v_data==0);v_data(pos)=1;
    113 
    114 %Transform HSV to RGB
    115 image_hsv=zeros(size(data_grid,1),size(data_grid,2),3);
    116 image_hsv(:,:,1)=h_data;
    117 image_hsv(:,:,2)=s_data;
    118 image_hsv(:,:,3)=v_data;
    119 image_rgb=hsv2rgb(image_hsv);
    120132
    121133%Select plot area
     
    134146
    135147%Apply options, without colorbar and without grid
    136 options=changefieldvalue(options,'colormap',colorm);           %We used an HSV colorbar
     148options=changefieldvalue(options,'colormap',colorm);              % We used an HSV colorbar
    137149if ~isnan(data_min),
    138         options=changefieldvalue(options,'caxis',[data_min data_max]); %force caxis so that the colorbar is ready
     150        options=changefieldvalue(options,'caxis',[data_min data_max]); % force caxis so that the colorbar is ready
    139151end
    140 options=addfielddefault(options,'axis','equal off');           %default axis
     152options=addfielddefault(options,'axis','equal off');              % default axis
    141153applyoptions(md,data,options);
    142154drawnow
  • issm/trunk/src/m/model/plot/plotdoc.m

    r12329 r12706  
    9494disp('       ''showsection'': show section used by ''sectionvalue'' (string ''on'' or a number of labels)');
    9595disp('       ''sectionvalue'': give the value of data on a profile given by an Argus file (string ''Argusfile_name.exp'')');
     96disp('       ''profile'': give the value of data along a vertical profile ([xlocation ylocation])');
    9697disp('       ''smooth'': smooth element data (string ''yes'' or integer)');
    9798disp('       ''title'': same as standard matlab option');
  • issm/trunk/src/m/model/plot/plotmodel.m

    r11995 r12706  
    4848                for i=1:numberofplots,
    4949                        plot_manager(getfieldvalue(options.list{i},'model',md),options.list{i},subplotwidth,nlines,ncols,i);
    50                         %cbfreeze;
    5150                end
    5251        catch me,
  • issm/trunk/src/m/model/plot/subplotmodel.m

    r12329 r12706  
    1414hmargin = getfieldvalue(options,'hmargin',[.01 .01]);
    1515vmargin = getfieldvalue(options,'vmargin',[.01 .01]);
    16 
    1716
    1817height = (1-sum(vmargin)-(nlines-1)*gap(1))/nlines;
  • issm/trunk/src/m/model/radarpower.m

    r12329 r12706  
    3737                        error(['radarpower error message: file ' jplsvn() '/projects/ModelData/MOG/mog150_greenland_map.jpg not found.']);
    3838                end
    39                 jpgim=[jplsvn() '/projects/ModelData/MOG/mog150_greenland_map.jpg'];
    40                 geom=load([jplsvn() '/projects/ModelData/MOG/mog150_greenland_map.jpgw'],'ascii');
     39                name = 'mog150_greenland_map';
     40                %name = 'mog100_hp1_v10';
     41                %name = 'mog500_hp1_v10';
     42                jpgim=[jplsvn() '/projects/ModelData/MOG/' name '.jpg'];
     43                geom=load([jplsvn() '/projects/ModelData/MOG/' name '.jpgw'],'ascii');
    4144
    4245                %geom:   xposting nbcols nbrows yposting xmin ymax
    4346                xmin=max(geom(5),x0);
    4447                xmax=min(geom(5)+geom(1)*geom(2),x1);
    45                 ymin=max(geom(6)-geom(4)*geom(3),y0);
     48                ymin=max(geom(6)-geom(3)*geom(4),y0);
    4649                ymax=min(geom(6),y1);
    4750
     
    106109        toplefty=floor((overlay_ylim(2)-y1)/overlay_yposting); % y max
    107110
    108 
    109111        %Read and crop file
    110112        disp('Warning: expecting coordinates in polar stereographic (Std Latitude: 70ºN Meridian: 45º)');
  • issm/trunk/src/m/model/regionaltransient2d.m

    r10587 r12706  
    106106                        thickness=PatchToVec(md1.results.TransientSolution(t).Thickness);
    107107                        spcx=[spcx InterpFromMeshToMesh2d(md1.mesh.elements,md1.mesh.x,md1.mesh.y,vx,md2.mesh.x,md2.mesh.y)];
    108                         spcy=[spcy InterpFromMeshToMesh2d(md1.mesh.elements,md1.mesh.x,md1.mesh.y,vx,md2.mesh.x,md2.mesh.y)];
     108                        spcy=[spcy InterpFromMeshToMesh2d(md1.mesh.elements,md1.mesh.x,md1.mesh.y,vy,md2.mesh.x,md2.mesh.y)];
    109109                        spct=[spct InterpFromMeshToMesh2d(md1.mesh.elements,md1.mesh.x,md1.mesh.y,thickness,md2.mesh.x,md2.mesh.y)];
    110110                        steps=[steps t*md1.timestepping.time_step];
  • issm/trunk/src/m/model/setmask.m

    r11035 r12706  
    2525elements=md.mesh.elements;
    2626
    27 %Assign elementonfloatingice, elementongroundedice, vertexongroundedice and vertexonfloatingice. Only change at your own peril! This is synchronized heavily with the GroundingLineMigration module. {{{1
     27%Assign elementonfloatingice, elementongroundedice, vertexongroundedice and vertexonfloatingice. Only change at your own peril! This is synchronized heavily with the GroundingLineMigration module. {{{
    2828elementonfloatingice=FlagElements(md,floatingicename);
    2929elementongroundedice=FlagElements(md,groundedicename);
  • issm/trunk/src/m/model/setmask.py

    r12329 r12706  
    2222        elements = md.mesh.elements
    2323
    24         #Assign elementonfloatingice, elementongroundedice, vertexongroundedice and vertexonfloatingice. Only change at your own peril! This is synchronized heavily with the GroundingLineMigration module. {{{1
     24        #Assign elementonfloatingice, elementongroundedice, vertexongroundedice and vertexonfloatingice. Only change at your own peril! This is synchronized heavily with the GroundingLineMigration module. {{{
    2525        elementonfloatingice = fe.FlagElements(md, floatingicename)
    2626        elementongroundedice = fe.FlagElements(md, groundedicename)
  • issm/trunk/src/m/model/solve.m

    r10981 r12706  
    2424%      md=solve(md,DiagnosticSolutionEnum);
    2525
    26 %recover options
     26%recover and process solve options
    2727options=pairoptions(varargin{:},'solution_type',solutionenum);
    28 
    29 %add default options
    3028options=process_solve_options(options);
    3129
    3230%recover some fields
    3331md.private.solution=options.solution_type;
     32cluster=md.cluster;
    3433
    3534%check model consistency
    3635disp('checking model consistency');
    3736if (solutionenum == FlaimSolutionEnum)
    38         modelconsistency(true);
    39         md.mesh.checkconsistency(md,solutionenum);
    40         md.flaim.checkconsistency(md,solutionenum);
    41         if ~modelconsistency()
    42                 error(' ');
     37        md.private.isconsistent=true;
     38        md=checkconsistency(md.mesh,md,solutionenum);
     39        md=checkconsistency(md.flaim,md,solutionenum);
     40        if md.private.isconsistent==false,
     41                error('Model not consistent, see messages above');
    4342        end
    4443else
     
    4645end
    4746
    48 %if running qmu analysis, some preprocessing of dakota files using
    49 %models fields needs to be carried out.
     47%First, build a runtime name that is unique
     48c=clock;
     49md.private.runtimename=sprintf('%s-%02i-%02i-%04i-%02i-%02i-%02i-%i',md.miscellaneous.name,c(2),c(3),c(1),c(4),c(5),floor(c(6)),feature('GetPid'));
     50
     51%if running qmu analysis, some preprocessing of dakota files using models
     52%fields needs to be carried out.
    5053if md.qmu.isdakota,
    5154        md=preqmu(md,options);
    5255end
    5356
    54 %Save model as is (in case of a crash)
    55 assignin('base',inputname(1),md);
    56 
    5757%flaim analysis
    58 if (md.private.solution == FlaimSolutionEnum)
     58if (options.solution_type == FlaimSolutionEnum)
    5959        md=flaim_sol(md,options);
    6060        md.private.solution=EnumToString(options.solution_type);
     
    6262end
    6363
    64 %Marshall model data into a binary file.
    65 marshall(md);
    66 
    67 %write a template file for issm to use, in parallel
    68 PetscFile(md.solver,[md.miscellaneous.name '.petsc']);
    69 
    70 %If running in parallel, we have a different way of launching the solution
    71 %sequences.
    72 if ~strcmpi(md.cluster.name,'none'),
    73         md=solveparallel(md,options);
     64%Do we load results only?
     65if options.loadonly, 
     66        md=loadresultsfromcluster(md);
    7467        return;
    7568end
    7669
    77 %Launch correct solution sequence
    78 md=issm(md,md.private.solution);
     70%Wite all input files
     71marshall(md);                                          % bin file
     72PetscFile(md.solver,[md.miscellaneous.name '.petsc']); % petsc file
     73BuildQueueScript(cluster,md.miscellaneous.name,md.private.solution,md.settings.io_gather,md.debug.valgrind,md.debug.gprof); % queue file
     74
     75%we need to make sure we have PETSC support, otherwise, we run with only one cpu:
     76if ~ispetsc,
     77        disp('PETSC support not included, running on 1 cpu only!');
     78        cluster.np=1;
     79end
     80
     81%Stop here if batch mode
     82if strcmpi(options.batch,'yes')
     83        disp('batch mode requested: not launching job interactively');
     84        disp('launch solution sequence on remote cluster by hand');
     85        return;
     86end
     87
     88%Launch job
     89modelname = md.miscellaneous.name;
     90filelist  = {[modelname '.bin '] [modelname '.petsc '] [modelname '.queue ']};
     91if md.qmu.isdakota,
     92        filelist{end+1} = [modelname '.qmu.in'];
     93end
     94LaunchQueueJob(cluster,md.miscellaneous.name,md.private.runtimename,filelist);
     95
     96%did we even try to run? if so, wait on lock
     97if strcmpi(options.upload,'on'),
     98        disp('solve done uploading test decks');
     99        return;
     100end
     101
     102%wait on lock
     103if md.settings.waitonlock>0,
     104        %we wait for the done file
     105        islock=waitonlock(md);
     106        if islock==0, %no results to be loaded
     107                disp('The results must be loaded manually with md=loadresultsfromcluster(md).');
     108        else          %load results
     109                disp('loading results from cluster');
     110                md=loadresultsfromcluster(md);
     111        end
     112end
    79113
    80114%post processes qmu results if necessary
    81115if md.qmu.isdakota,
    82         md=postqmu(md);
    83         cd ..
    84116        if ~strncmpi(options.keep,'y',1)
    85117                system(['rm -rf qmu' num2str(feature('GetPid'))]);
    86118        end
    87119end
    88 
    89 %convert analysis type to string finally
    90 md.private.solution=EnumToString(options.solution_type);
  • issm/trunk/src/m/model/solvers/stokesoptions.m

    r11995 r12706  
    66
    77%retrieve options provided in varargin
    8 arguments=pairoptions(varargin{:});
     8options=pairoptions(varargin{:});
    99stokes=struct();
    1010
  • issm/trunk/src/m/qmu/preqmu.m

    r9668 r12706  
    4444responses=expandresponses(md,responses);
    4545
    46 %go through variables and responses, and check they don't have more than md.qmu.numberofpartitions values. Also determine numvariables and numresponses{{{1
     46%go through variables and responses, and check they don't have more than md.qmu.numberofpartitions values. Also determine numvariables and numresponses{{{
    4747numvariables=0;
    4848variable_fieldnames=fieldnames(variables);
     
    7676system(['rm -rf ' md.miscellaneous.name '.m']);
    7777
    78 %build a list of variables and responses descriptors. the list is not expanded. {{{1
     78%build a list of variables and responses descriptors. the list is not expanded. {{{
    7979variabledescriptors={};
    8080variable_fieldnames=fieldnames(md.qmu.variables(options.ivar));
  • issm/trunk/src/m/utils/Basins/basinzoom.m

    r8100 r12706  
    3838
    3939%Ok, find basin we are talking about:
    40 load([issmdir '/projects/ModelData/Names/Names.mat']);
     40load([jplsvn() '/projects/ModelData/Names/Names.mat']);
    4141               
    4242%Go through names:
  • issm/trunk/src/m/utils/Basins/isbasin.m

    r7140 r12706  
    99
    1010%First, load basin names:
    11 load([issmdir '/projects/ModelData/Names/Names.mat']);
     11load([jplsvn '/projects/ModelData/Names/Names.mat']);
    1212
    1313
  • issm/trunk/src/m/utils/Basins/showbasins.m

    r7245 r12706  
    4545
    4646%Ok, find basin we are talking about:
    47 load([issmdir '/projects/ModelData/Names/Names.mat']);
     47load([jplsvn '/projects/ModelData/Names/Names.mat']);
    4848
    4949%Get xlim and ylim, and convert into lat,long:
  • issm/trunk/src/m/utils/Exp/expcoarsen.m

    r1264 r12706  
    2626%Get exp oldfile
    2727[path root ext ver]=fileparts(oldfile);
    28 A=expread(oldfile,1);
     28A=expread(oldfile);
    2929numprofiles=size(A,2);
    3030
  • issm/trunk/src/m/utils/Exp/expcontract.m

    r8298 r12706  
    88
    99
    10 contour=expread(oldfile,1);
     10contour=expread(oldfile);
    1111num=numel(contour.x);
    1212
  • issm/trunk/src/m/utils/Exp/expll2xy.m

    r8367 r12706  
    2727
    2828%read filename:
    29 domain=expread(filename,1);
     29domain=expread(filename);
    3030
    3131%change to x,y:
  • issm/trunk/src/m/utils/Exp/expxy2ll.m

    r8367 r12706  
    2727
    2828%read filename:
    29 domain=expread(filename,1);
     29domain=expread(filename);
    3030
    3131%change to x,y:
  • issm/trunk/src/m/utils/Exp/manipulation/cutarea.m

    r8662 r12706  
    8787                                                                        A(selection).x=x(1:p1);
    8888                                                                        A(selection).y=y(1:p1);
     89                                                                        closed(selection)=0;
    8990                                                                        A(end+1).x=x(p2:end);
    9091                                                                        A(end).y=y(p2:end);
    9192                                                                        A(end).density=A(selection).density;
    9293                                                                        A(end).name=A(selection).name;
     94                                                                        closed(end+1)=0;
    9395                                                                        numprofiles=numprofiles+1;
    9496                                                                        numpoints=numpoints-(p2-p1-1);
     
    113115                                                                else
    114116                                                                        %cut in 2 profiles
     117                                                                        closed(selection)=0;
    115118                                                                        A(selection).x=x(1:p2);
    116119                                                                        A(selection).y=y(1:p2);
     
    119122                                                                        A(end).density=A(selection).density;
    120123                                                                        A(end).name=A(selection).name;
     124                                                                        closed(end+1)=0;
    121125                                                                        numprofiles=numprofiles+1;
    122126                                                                        numpoints=numpoints-(p1-p2-1);
  • issm/trunk/src/m/utils/Geometry/find_point.m

    r1 r12706  
    88%      f=find_point(tabx,taby,pointx,pointy)
    99
     10%Compute distance between point and cloud of points
    1011distance=sqrt((tabx-pointx).^2+(taby-pointy).^2);
    11 f=find(distance==min(min(distance)));
     12
     13%find index of the minimum distance and return the first one only
     14f=find(distance==min(min(distance)),1);
  • issm/trunk/src/m/utils/Kml/exp2kml.m

    r7148 r12706  
    88
    99%First, read exp file
    10 domain=expread(input,1);
     10domain=expread(input);
    1111
    1212
  • issm/trunk/src/m/utils/Miscellaneous/issmdoc.m

    r12329 r12706  
    99disp(sprintf('%s','        md=model;                                %creates a new empty model structure'));
    1010disp(sprintf('%s','        md=triangle(md,''DomainOutline.exp'',50000);   %creates a mesh of the domain outline with a resolution of 50000m'));
    11 disp(sprintf('%s','        md=geography(md,''all'','''');               %defines the glacier system as an ice shelf (no island)'));
     11disp(sprintf('%s','        md=setmask(md,''all'','''');               %defines the glacier system as an ice shelf (no island)'));
    1212disp(sprintf('%s','        md=parameterize(md,''Square.par'');        %fills all the other fields of the model'));
    13 disp(sprintf('%s','        md=setelementstype(md,''macayeal'',''all''); %defines all elements as MacAyeal''s'));
     13disp(sprintf('%s','        md=setflowequation(md,''macayeal'',''all''); %defines all elements as MacAyeal''s'));
    1414disp(sprintf('%s','        md=solve(md,DiagnosticSolutionEnum);   %generate the velocity field'));
    1515disp(sprintf('%s','        plotmodel(md,''data'',md.results.DiagnosticSolution.Vel);    %displays the velocity (type plotdoc for plotmodel help)'));
  • issm/trunk/src/m/utils/Model/loadmodel.m

    r10184 r12706  
    1212        error('loadmodel usage error: md=loadmodel(path)');
    1313end
     14
    1415%check existence
    15 if ~exist(path)
     16if exist(path,'file')
     17        %do nothing
     18elseif exist([path '.mat'],'file')
     19        %add extension
     20        path = [path '.mat'];
     21else
    1622        error(['loadmodel error message: file ' path ' does not exist']);
    1723end
  • issm/trunk/src/m/utils/Numerics/cfl_step.m

    r11995 r12706  
    88%
    99%   Example:
    10 %      dt=cfl_step(md,md,md.results.DiagnosticSolution.Vx,md.results.DiagnosticSolution.Vy)
     10%      dt=cfl_step(md,md.results.DiagnosticSolution.Vx,md.results.DiagnosticSolution.Vy)
    1111
    1212%Check length of velocities
  • issm/trunk/src/m/utils/consistency/checkfield.m

    r11527 r12706  
    1 function checkfield(md,fieldname,varargin)
     1function md = checkfield(md,fieldname,varargin)
    22%CHECKFIELD - check field consistency
    33%
     
    1919%
    2020%   Usage:
    21 %      checkfield(md,fieldname,options);
     21%      md = checkfield(md,fieldname,options);
    2222%
    2323%   Example:
    24 %      checkfield(md,'mesh.elementonbed','size',[md.mesh.numberofelements 1],'values',[0 1]);
    25 %      checkfield(md,'diagnostic.icefront','size',[NaN 4],'NaN',1);
    26 %      checkfield(md,'diagnostic.icefront(:,end)','values',[0 1 2]);
     24%      md = checkfield(md,'mesh.elementonbed','size',[md.mesh.numberofelements 1],'values',[0 1]);
     25%      md = checkfield(md,'diagnostic.icefront','size',[NaN 4],'NaN',1);
     26%      md = checkfield(md,'diagnostic.icefront(:,end)','values',[0 1 2]);
    2727
    2828%get options
     
    3535if exist(options,'empty')
    3636        if isempty(field),
    37                 checkmessage(getfieldvalue(options,'message',...
     37                md = checkmessage(md,getfieldvalue(options,'message',...
    3838                        ['field ''' fieldname ''' is empty']));
    3939        end
     
    4545        if isnan(fieldsize(1)),
    4646                if (size(field,2)~=fieldsize(2)),
    47                         checkmessage(getfieldvalue(options,'message',...
     47                        md = checkmessage(md,getfieldvalue(options,'message',...
    4848                                ['field ''' fieldname ''' should have ' num2str(fieldsize(2)) ' columns']));
    4949                end
    5050        elseif isnan(fieldsize(2)),
    5151                if (size(field,1)~=fieldsize(1)),
    52                         checkmessage(getfieldvalue(options,'message',...
     52                        md = checkmessage(md,getfieldvalue(options,'message',...
    5353                                ['field ''' fieldname ''' should have ' num2str(fieldsize(1)) ' lines']));
    5454                end
    5555        else
    5656                if ((size(field)~=fieldsize(1)) |  (size(field,2)~=fieldsize(2)))
    57                         checkmessage(getfieldvalue(options,'message',...
     57                        md = checkmessage(md,getfieldvalue(options,'message',...
    5858                                ['field ''' fieldname ''' size should be ' num2str(fieldsize(1)) ' x ' num2str(fieldsize(2))]));
    5959                end
     
    6666        if ~ismember(numel(field),fieldnumel),
    6767                if length(fieldnumel)==1
    68                         checkmessage(getfieldvalue(options,'message',...
     68                        md = checkmessage(md,getfieldvalue(options,'message',...
    6969                                ['field ''' fieldname ''' size should be ' sprintf('%g ',fieldnumel) ]));
    7070                elseif length(fieldnumel)==2
    71                         checkmessage(getfieldvalue(options,'message',...
     71                        md = checkmessage(md,getfieldvalue(options,'message',...
    7272                                ['field ''' fieldname ''' size should be ' num2str(fieldnumel(1)) ' or ' num2str(fieldnumel(2)) ]));
    7373                else
    74                         checkmessage(getfieldvalue(options,'message',...
     74                        md = checkmessage(md,getfieldvalue(options,'message',...
    7575                                ['field ''' fieldname ''' size should be ' sprintf('%g, ',fieldnumel(1:end-1)) ' or ' num2str(fieldnumel(end)) ]));
    7676                end
     
    8282        field2=reshape(field,prod(size(field)),1);
    8383        if any(isnan(field2)),
    84                 checkmessage(getfieldvalue(options,'message',...
     84                md = checkmessage(md,getfieldvalue(options,'message',...
    8585                        ['NaN values found in field ''' fieldname '''']));
    8686        end
     
    9090if getfieldvalue(options,'cell',0);
    9191        if ~iscell(field),
    92                 checkmessage(getfieldvalue(options,'message',...
     92                md = checkmessage(md,getfieldvalue(options,'message',...
    9393                        ['field ''' fieldname ''' should be a cell']));
    9494        end
     
    102102                if any(~ismember(field,fieldvalues)),
    103103                        if length(fieldvalues)==1
    104                                 checkmessage(getfieldvalue(options,'message',...
     104                                md = checkmessage(md,getfieldvalue(options,'message',...
    105105                                        ['field ''' fieldname ''' value should be ' fieldvalues{1} ]));
    106106                        elseif length(fieldvalues)==2
    107                                 checkmessage(getfieldvalue(options,'message',...
     107                                md = checkmessage(md,getfieldvalue(options,'message',...
    108108                                        ['field ''' fieldname ''' values should be ' fieldvalues{1} ' or ' fieldvalues{2} ]));
    109109                        else
    110                                 checkmessage(getfieldvalue(options,'message',...
     110                                md = checkmessage(md,getfieldvalue(options,'message',...
    111111                                        ['field ''' fieldname ''' should have values in ' sprintf('''%s'', ',fieldvalues{1:end-1}) 'or ''' fieldvalues{end} '''']));
    112112                        end
    113113                end
    114114        else
    115                 checkmessage(getfieldvalue(options,'message',...
     115                md = checkmessage(md,getfieldvalue(options,'message',...
    116116                        ['field ''' fieldname ''' should be one of the following strings: ' sprintf('''%s'', ',fieldvalues{1:end-1}) 'or ''' fieldvalues{end} '''']));
    117117        end
     
    120120        if isnumeric(field),
    121121                if any(~ismember(field2,fieldvalues)),
    122                         checkmessage(getfieldvalue(options,'message',...
     122                        md = checkmessage(md,getfieldvalue(options,'message',...
    123123                                ['field ''' fieldname ''' should have values in [' num2str(fieldvalues) ']']));
    124124                end
    125125        else
    126                 checkmessage(getfieldvalue(options,'message',...
     126                md = checkmessage(md,getfieldvalue(options,'message',...
    127127                        ['field ''' fieldname ''' should be a number in [' num2str(fieldvalues) ']']));
    128128        end
     
    135135        field2=reshape(field,prod(size(field)),1);
    136136        if any(field2<lowerbound),
    137                 checkmessage(getfieldvalue(options,'message',...
     137                md = checkmessage(md,getfieldvalue(options,'message',...
    138138                        ['field ''' fieldname ''' should have values above ' num2str(lowerbound)]));
    139139        end
     
    143143        field2=reshape(field,prod(size(field)),1);
    144144        if any(field2<=lowerbound),
    145                 checkmessage(getfieldvalue(options,'message',...
     145                md = checkmessage(md,getfieldvalue(options,'message',...
    146146                        ['field ''' fieldname ''' should have values above ' num2str(lowerbound)]));
    147147        end
     
    153153        field2=reshape(field,prod(size(field)),1);
    154154        if any(field2>upperbound),
    155                 checkmessage(getfieldvalue(options,'message',...
     155                md = checkmessage(md,getfieldvalue(options,'message',...
    156156                        ['field ''' fieldname ''' should have values below ' num2str(upperbound)]));
    157157        end
     
    161161        field2=reshape(field,prod(size(field)),1);
    162162        if any(field2>=upperbound),
    163                 checkmessage(getfieldvalue(options,'message',...
     163                md = checkmessage(md,getfieldvalue(options,'message',...
    164164                        ['field ''' fieldname ''' should have values below ' num2str(upperbound(1))]));
    165165        end
     
    169169if getfieldvalue(options,'file',0),
    170170        if ~exist(field,'file')
    171                 checkmessage(['file profided in ''' fieldname ''': ''' field ''' does not exist']);
     171                md = checkmessage(md,['file profided in ''' fieldname ''': ''' field ''' does not exist']);
    172172        end
    173173end
     
    177177        if size(field,1)==md.mesh.numberofvertices,
    178178                if ~size(field,2)==1,
    179                         checkmessage(getfieldvalue(options,'message',...
     179                        md = checkmessage(md,getfieldvalue(options,'message',...
    180180                                ['field ''' fieldname ''' should have only one column as there are md.mesh.numberofvertices lines']));
    181181                end
    182182        elseif size(field,1)==md.mesh.numberofvertices+1
    183183                if any(field(end,:)~=sort(field(end,:))),
    184                         checkmessage(getfieldvalue(options,'message',...
    185                                 ['field ''' fieldname ''' columns should be chronological']));
     184                        md = checkmessage(md,getfieldvalue(options,'message',...
     185                                ['field ''' fieldname ''' columns should be sorted chronologically']));
    186186                end
    187187                if any(field(end,1:end-1)==field(end,2:end)),
    188                         checkmessage(getfieldvalue(options,'message',...
     188                        md = checkmessage(md,getfieldvalue(options,'message',...
    189189                                ['field ''' fieldname ''' columns must not contain duplicate timesteps']));
    190190                end
    191191        else
    192                 checkmessage(getfieldvalue(options,'message',...
     192                md = checkmessage(md,getfieldvalue(options,'message',...
    193193                        ['field ''' fieldname ''' should have md.mesh.numberofvertices or md.mesh.numberofvertices+1 lines']));
    194194        end
  • issm/trunk/src/modules/AverageFilter/AverageFilter.cpp

    r12331 r12706  
    5353void AverageFilterUsage(void)
    5454{
    55         printf("   AverageFilter usage:\n");
    56         printf("   [image_out]=AverageFilter(image_in,pixels);\n\n");
    57         printf("   where:\n");
    58         printf("      image_in in double format\n");
    59         printf("      pixels: characteristic size of smoothing\n");
    60         printf("      image_out in double format\n");
    61         printf("\n");
     55        _printLine_("   AverageFilter usage:");
     56        _printLine_("   [image_out]=AverageFilter(image_in,pixels);\n");
     57        _printLine_("   where:");
     58        _printLine_("      image_in in double format");
     59        _printLine_("      pixels: characteristic size of smoothing");
     60        _printLine_("      image_out in double format");
     61        _printLine_("");
    6262}
  • issm/trunk/src/modules/BamgConvertMesh/BamgConvertMesh.cpp

    r12331 r12706  
    44#include "./BamgConvertMesh.h"
    55
    6 void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
     6void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
    77
    88        /*input: */
    9         double* index=NULL;
    10         int     index_rows;
    11         double* x=NULL;
    12         int     x_cols;
    13         double* y=NULL;
    14         int     y_rows;
    15         int     y_cols;
     9        int    *index      = NULL;
     10        double *x          = NULL;
     11        double *y          = NULL;
     12        int     nods,nels,test1,test2;
    1613
    1714        /*Output*/
    18         BamgMesh* bamgmesh=NULL;
    19         BamgGeom* bamggeom=NULL;
    20         mxArray* bamgmesh_mat=NULL;
    21         mxArray* bamggeom_mat=NULL;
    22 
    23         /*Intermediary*/
    24         int nods;
    25         int nels;
    26         int verbose=0;
     15        BamgMesh *bamgmesh     = NULL;
     16        BamgGeom *bamggeom     = NULL;
     17        mxArray  *bamgmesh_mat = NULL;
     18        mxArray  *bamggeom_mat = NULL;
    2719
    2820        /*Boot module: */
     
    3729
    3830        /*Input datasets: */
    39         if (verbose) printf("Fetching inputs\n");
    40         FetchData(&index,&nels,&index_rows,INDEXHANDLE);
    41         FetchData(&x,&nods,&x_cols,XHANDLE);
    42         FetchData(&y,&y_rows,&y_cols,YHANDLE);
     31        FetchData(&index,&nels,&test1,INDEXHANDLE);
     32        FetchData(&x,&nods,XHANDLE);
     33        FetchData(&y,&test2,YHANDLE);
    4334
    4435        /*Check inputs*/
    45         if (nels<0){
    46                 _error_("Number of elements must be positive, check index number of lines");
    47         }
    48         if (nods<0){
    49                 _error_("Number of nods must be positive, check x and y sizes");
    50         }
    51         if (index_rows!=3){
    52                 _error_("index should have 3 columns");
    53         }
    54         if (y_rows!=nods){
    55                 _error_("x and y do not have the same length");
    56         }
    57         if (x_cols>1 || y_cols>1){
    58                 _error_("x and y should have only one column");
    59         }
     36        if(nels<0) _error2_("Number of elements must be positive, check index number of lines");
     37        if(nods<0) _error2_("Number of nods must be positive, check x and y sizes");
     38        if(test1!=3) _error2_("index should have 3 columns");
     39        if(test2!=nods) _error2_("x and y do not have the same length");
    6040
    6141        /* Run core computations: */
    62         if (verbose) printf("Call core\n");
    6342        BamgConvertMeshx(bamgmesh,bamggeom,index,x,y,nods,nels);
    6443
     
    7554}
    7655
    77 void BamgConvertMeshUsage(void)
    78 {
    79         _printf_(true,"BAMGCONVERTMESH - convert [x y index] to a bamg geom and mesh geom");
    80         _printf_(true,"\n");
    81         _printf_(true,"   Usage:\n");
    82         _printf_(true,"      [bamggeom bamgmesh]=BamgConvertMesh(index,x,y);\n");
    83         _printf_(true,"      index: index of the mesh\n");
    84         _printf_(true,"      x,y: coordinates of the nodes\n");
    85         _printf_(true,"\n");
     56void BamgConvertMeshUsage(void){
     57        _pprintString_("BAMGCONVERTMESH - convert [x y index] to a bamg geom and mesh geom");
     58        _pprintLine_("");
     59        _pprintLine_("   Usage:");
     60        _pprintLine_("      [bamggeom bamgmesh]=BamgConvertMesh(index,x,y);");
     61        _pprintLine_("      index: index of the mesh");
     62        _pprintLine_("      x,y: coordinates of the nodes");
     63        _pprintLine_("");
    8664}
  • issm/trunk/src/modules/BamgMesher/BamgMesher.cpp

    r12331 r12706  
    5151
    5252void BamgMesherUsage(void){
    53         _printf_(true,"\n");
    54         _printf_(true,"   usage: [bamgmesh,bamggeom]=%s(bamgmesh,bamggeom,bamgoptions);\n",__FUNCT__);
    55         _printf_(true,"\n");
     53        _pprintLine_("");
     54        _pprintLine_("   usage: [bamgmesh,bamggeom]=" << __FUNCT__ << "(bamgmesh,bamggeom,bamgoptions);");
     55        _pprintLine_("");
    5656}
  • issm/trunk/src/modules/BamgTriangulate/BamgTriangulate.cpp

    r12331 r12706  
    2727
    2828        /*Input datasets: */
    29         if (verbose) printf("Fetching inputs\n");
     29        if (verbose) _printLine_("Fetching inputs");
    3030        FetchData(&x,&nods,&x_cols,XHANDLE);
    3131        FetchData(&y,&y_rows,&y_cols,YHANDLE);
    3232
    3333        /*Check inputs*/
    34         if(y_rows!=nods)         _error_("x and y do not have the same length");
    35         if(x_cols>1 || y_cols>1) _error_("x and y should have only one column");
    36         if(nods<3)               _error_("At least 3 points are required");
     34        if(y_rows!=nods)         _error2_("x and y do not have the same length");
     35        if(x_cols>1 || y_cols>1) _error2_("x and y should have only one column");
     36        if(nods<3)               _error2_("At least 3 points are required");
    3737
    3838        /* Run core computations: */
    39         if (verbose) printf("Call core\n");
     39        if (verbose) _printLine_("Call core");
    4040        BamgTriangulatex(&index,&nels,x,y,nods);
    4141
     
    4949void BamgTriangulateUsage(void)
    5050{
    51         _printf_(true,"BAMGTRIANGULATE - Delaunay Triangulation of a list of points");
    52         _printf_(true,"\n");
    53         _printf_(true,"   Usage:\n");
    54         _printf_(true,"      index=BamgTriangulate(x,y);\n");
    55         _printf_(true,"      index: index of the triangulation\n");
    56         _printf_(true,"      x,y: coordinates of the nodes\n");
    57         _printf_(true,"\n");
     51        _pprintString_("BAMGTRIANGULATE - Delaunay Triangulation of a list of points");
     52        _pprintLine_("");
     53        _pprintLine_("   Usage:");
     54        _pprintLine_("      index=BamgTriangulate(x,y);");
     55        _pprintLine_("      index: index of the triangulation");
     56        _pprintLine_("      x,y: coordinates of the nodes");
     57        _pprintLine_("");
    5858}
  • issm/trunk/src/modules/Chaco/Chaco.cpp

    r12331 r12706  
    4242
    4343        #ifndef _HAVE_CHACO_ //only works if dakota library has been compiled in.
    44         _error_(" Chaco not available! Cannot carry out Chaco partitioning!");
     44        _error2_("Chaco not available! Cannot carry out Chaco partitioning!");
    4545        #endif
    4646
     
    8282        /*Some debugging print: {{{*/
    8383        #ifdef _DEBUG_
    84         printf("nvtxs: %i\n",nvtxs);
    85         printf("options: [");
    86         for(i=0;i<10;i++)printf("%g|",options[i]);
    87         printf("]\n");
    88         printf("start: \n");
    89         for (i=0; i<nvtxs+1;i++)printf("%i ",start[i]);
    90         printf("\n");
    91         printf("adjacency: \n");
    92         for (i=0; i<mxGetNzmax(A_IN);i++)printf("%i ",adjacency[i]);
    93         printf("\n");
    94         printf("nedges: %i %p\n",nedges,ewgts);
    95         if(ewgts) for (i = 0; i < nedges; i++)printf("%g ",ewgts[i]);
    96         printf("\n");
    97         printf("vwgts:\n");
    98         for (i = 0; i < nvtxs; i++)printf("%g ",vwgts[i]);
    99         printf("\n");
    100         printf("nparts: %i\n",nparts[0]);
    101         printf("goal: %p\n",goal);
     84        _printLine_("nvtxs: " << nvtxs);
     85        _printString_("options: [");
     86        for(i=0;i<10;i++)_printString_(options[i] << "|");
     87        _printLine_("]");
     88        _printLine_("start: ");
     89        for (i=0; i<nvtxs+1;i++)_printString_(start[i] << " ");
     90        _printLine_("");
     91        _printLine_("adjacency: ");
     92        for (i=0; i<mxGetNzmax(A_IN);i++)_printString_("" <<adjacency[i]<< " ");i++)
     93        _printLine_("");
     94        _printLine_("nedges: " << nedges << " " << ewgts);
     95        if(ewgts) for (i = 0; i < nedges; i++)_printString_(ewgts[i] << " ");
     96        _printLine_("");
     97        _printLine_("vwgts:");
     98        for (i = 0; i < nvtxs; i++)_printString_(vwgts[i] << " ");
     99        _printLine_("");
     100        _printLine_("nparts: " << nparts[0]);
     101        _printLine_("goal: " << goal);
    102102        #endif
    103103        /*}}}*/
     
    132132
    133133void ChacoUsage(void){
    134         _printf_(true,"\n");
    135         _printf_(true,"Usage: [assgn] = Chaco(A,vwgts,ewgts,x,y,z,options,nparts,goal);\n");
    136         _printf_(true,"\n");
     134        _pprintLine_("");
     135        _pprintLine_("Usage: [assgn] = Chaco(A,vwgts,ewgts,x,y,z,options,nparts,goal);");
     136        _pprintLine_("");
    137137}
  • issm/trunk/src/modules/ContourToMesh/ContourToMesh.cpp

    r12331 r12706  
    4747        if(nlhs!=1 && nlhs!=2){
    4848                ContourToMeshUsage();
    49                 _error_(" usage. See above");
     49                _error2_("usage. See above");
    5050        }
    5151        #endif
     
    5353        if(nrhs!=NRHS){
    5454                ContourToMeshUsage();
    55                 _error_(" usage. See above");
     55                _error2_("usage. See above");
    5656        }
    5757
     
    8282                WriteData(PLHS1,in_elem);
    8383        }
    84         else _error_(" wrong interpolation type");
     84        else _error2_("wrong interpolation type");
    8585
    8686        /*end module: */
     
    9191void ContourToMeshUsage(void)//{{{1
    9292{
    93         printf("CONTOURTOMESH - Flag the elements or nodes inside a contour\n");
    94         printf("\n");
    95         printf("      Usage: \n");
    96         printf("         [in_nod,in_elem]=ContourToMesh(index,x,y,contourname,interptype,edgevalue)\n\n");
    97         printf("\n");
    98         printf("         index,x,y: mesh triangulation.\n");
    99         printf("         contourname: name of .exp file containing the contours.\n");
    100         printf("         interptype: string definining type of interpolation ('element', or 'node').\n");
    101         printf("         edgevalue: integer (0, 1 or 2) defining the value associated to the nodes on the edges of the polygons.\n");
    102         printf("         in_nod: vector of flags (0 or 1), of size nods if interptype is set to 'node' or 'element and node', \n");
    103         printf("            or of size 0 otherwise.\n");
    104         printf("         in_elem: vector of flags (0 or 1), of size nel if interptype is set to 'element' or 'element and node', \n");
    105         printf("            or of size 0 otherwise.\n");
    106         printf("\n");
    107         printf("      Example: \n");
    108         printf("         in_nod=ContourToMesh(md.elements,md.x,md.y,'Contour.exp','node',1)\n");
    109         printf("         in_elements=ContourToMesh(md.elements,md.x,md.y,'Contour.exp','element',0)\n");
    110         printf("         [in_nodes,in_elements]=ContourToMesh(md.elements,md.x,md.y,'Contour.exp','element and node',0)\n");
    111         printf("\n");
     93        _printLine_("CONTOURTOMESH - Flag the elements or nodes inside a contour");
     94        _printLine_("");
     95        _printLine_("      Usage: ");
     96        _printLine_("         [in_nod,in_elem]=ContourToMesh(index,x,y,contourname,interptype,edgevalue)\n");
     97        _printLine_("");
     98        _printLine_("         index,x,y: mesh triangulation.");
     99        _printLine_("         contourname: name of .exp file containing the contours.");
     100        _printLine_("         interptype: string definining type of interpolation ('element', or 'node').");
     101        _printLine_("         edgevalue: integer (0, 1 or 2) defining the value associated to the nodes on the edges of the polygons.");
     102        _printLine_("         in_nod: vector of flags (0 or 1), of size nods if interptype is set to 'node' or 'element and node', ");
     103        _printLine_("            or of size 0 otherwise.");
     104        _printLine_("         in_elem: vector of flags (0 or 1), of size nel if interptype is set to 'element' or 'element and node', ");
     105        _printLine_("            or of size 0 otherwise.");
     106        _printLine_("");
     107        _printLine_("      Example: ");
     108        _printLine_("         in_nod=ContourToMesh(md.elements,md.x,md.y,'Contour.exp','node',1)");
     109        _printLine_("         in_elements=ContourToMesh(md.elements,md.x,md.y,'Contour.exp','element',0)");
     110        _printLine_("         [in_nodes,in_elements]=ContourToMesh(md.elements,md.x,md.y,'Contour.exp','element and node',0)");
     111        _printLine_("");
    112112}
    113113//}}}
  • issm/trunk/src/modules/ContourToNodes/ContourToNodes.cpp

    r12331 r12706  
    8282        /* Debugging of contours :{{{1*/
    8383        /*for(i=0;i<numcontours;i++){
    84                 printf("\nContour echo: contour number  %i / %i\n",i+1,numcontours);
     84                _printLine_("\nContour echo: contour number  " << i+1 << " / " << numcontours);
    8585                contouri=*(contours+i);
    86                 printf("   Number of nodes %i\n",contouri->nods);
     86                _printLine_("   Number of nodes " << contouri->nods);
    8787                for (j=0;j<contouri->nods;j++){
    88                         printf("   %lf %lf\n",*(contouri->x+j),*(contouri->y+j));
     88                        _printLine_("   " << *(contouri->x+j) << "f " << *(contouri->y+j) << "f");
    8989                }
    9090        }*/
     
    103103
    104104void ContourToNodesUsage(void){
    105         printf("   usage:\n");
    106         printf("   [flags]=ContourToNodes(x,y,contourname,edgevalue);\n\n");
    107         printf("   where:\n");
    108         printf("      x,y: list of nodes.\n");
    109         printf("      contourname: name of .exp file containing the contours, or resulting structure from call to expread.\n");
    110         printf("      interptype: string definining type of interpolation ('element', or 'node').\n");
    111         printf("      edgevalue: integer (0, 1 or 2) defining the value associated to the nodes on the edges of the polygons.\n");
    112         printf("      flags: vector of flags (0 or 1), of size nods.\n");
    113         printf("\n");
     105        _printLine_("   usage:");
     106        _printLine_("   [flags]=ContourToNodes(x,y,contourname,edgevalue);\n");
     107        _printLine_("   where:");
     108        _printLine_("      x,y: list of nodes.");
     109        _printLine_("      contourname: name of .exp file containing the contours, or resulting structure from call to expread.");
     110        _printLine_("      interptype: string definining type of interpolation ('element', or 'node').");
     111        _printLine_("      edgevalue: integer (0, 1 or 2) defining the value associated to the nodes on the edges of the polygons.");
     112        _printLine_("      flags: vector of flags (0 or 1), of size nods.");
     113        _printLine_("");
    114114}
  • issm/trunk/src/modules/ElementConnectivity/ElementConnectivity.cpp

    r12331 r12706  
    3737
    3838void ElementConnectivityUsage(void) {
    39         _printf_(true,"\n");
    40         _printf_(true,"   usage: elementconnectivity = %s(elements, nodeconnectivity);\n",__FUNCT__);
    41         _printf_(true,"\n");
     39        _pprintLine_("");
     40        _pprintLine_("   usage: elementconnectivity = " << __FUNCT__ << "(elements, nodeconnectivity);");
     41        _pprintLine_("");
    4242}
  • issm/trunk/src/modules/EnumToString/EnumToString.cpp

    r12331 r12706  
    1212        /*checks on arguments on the matlab side: */
    1313        if(nrhs!=NRHS){
    14                 EnumToStringUsage(); _error_(" usage. See above");
     14                EnumToStringUsage(); _error2_("usage. See above");
    1515        }
    1616
     
    2727void EnumToStringUsage(void)
    2828{
    29         _printf_(true,"\n");
    30         _printf_(true,"   usage: %sstring = EnumToString(enum);\n",__FUNCT__);
    31         _printf_(true,"\n");
     29        _pprintLine_("");
     30        _pprintLine_("   usage: " << __FUNCT__ << "string = EnumToString(enum);");
     31        _pprintLine_("");
    3232}
  • issm/trunk/src/modules/Exp2Kml/Exp2Kml.cpp

    r12331 r12706  
    2525        /*checks on arguments on the matlab side: */
    2626        if (nlhs > NLHS) {
    27                 Exp2KmlUsage(); _error_("Exp2Kml usage error");
     27                Exp2KmlUsage(); _error2_("Exp2Kml usage error");
    2828        }
    2929        if (nrhs < NRHS) {
    30                 Exp2KmlUsage(); _error_("Exp2Kml usage error");
     30                Exp2KmlUsage(); _error2_("Exp2Kml usage error");
    3131        }
    3232
     
    4343        if (options->GetOption("central_meridian") || options->GetOption("standard_parallel")) {
    4444                options->Get(&cm,"central_meridian");
    45                 if (verbose) printf("  cm=%g\n",cm);
     45                if (verbose) _printLine_("  cm=" << cm);
    4646                options->Get(&sp,"standard_parallel");
    47                 if (verbose) printf("  sp=%g\n",sp);
     47                if (verbose) _printLine_("  sp=" << sp);
    4848        }
    4949
    5050        /*some checks*/
    51         if (sgn !=+1 && sgn !=-1) _error_("Hemisphere sgn=%d must be +1 (north) or -1 (south).",sgn);
    52         if (fabs(cm)      > 180.) _error_("Central meridian cm=%g must be between -180 (west) and +180 (east) degrees.",cm);
    53         if (sp < 0. || sp >  90.) _error_("Standard parallel sp=%g must be between 0 and 90 degrees (in specified hemisphere).",sp);
     51        if (sgn !=+1 && sgn !=-1) _error2_("Hemisphere sgn=" << sgn << " must be +1 (north) or -1 (south).");
     52        if (fabs(cm)      > 180.) _error2_("Central meridian cm=" << cm << " must be between -180 (west) and +180 (east) degrees.");
     53        if (sp < 0. || sp >  90.) _error2_("Standard parallel sp=" << sp << " must be between 0 and 90 degrees (in specified hemisphere).");
    5454
    5555        /* Run core computations: */
     
    7373
    7474void Exp2KmlUsage(void){
    75         _printf_(true,"Exp2Kml - exp to kml file conversion module:\n");
    76         _printf_(true,"\n");
    77         _printf_(true,"   This module converts a file from exp to kml format.\n");
    78         _printf_(true,"\n");
    79         _printf_(true,"   Usage:\n");
    80         _printf_(true,"      [ret]=Exp2Kml(filexp,filkml,sgn,'param name',param,...);\n");
    81         _printf_(true,"\n");
    82         _printf_(true,"      filexp      file name of exp file to be read (char)\n");
    83         _printf_(true,"      filkml      file name of kml file to be written (char)\n");
    84         _printf_(true,"      sgn         sign for hemisphere (double, +1 (north) or -1 (south))\n");
    85         _printf_(true,"\n");
    86         _printf_(true,"      central_meridian     central meridian (double, optional, but must specify with sp)\n");
    87         _printf_(true,"      standard_parallel    standard parallel (double, optional, but must specify with cm)\n");
    88         _printf_(true,"      holes       flag for treatment of multiple profiles (char, optional, 'yes' for holes))\n");
    89         _printf_(true,"\n");
    90         _printf_(true,"      ret         return code (non-zero for warning)\n");
    91         _printf_(true,"\n");
    92         _printf_(true,"   Examples:\n");
    93         _printf_(true,"      [ret]=Exp2Kml('file.exp','file.kml', 1);\n");
    94         _printf_(true,"      [ret]=Exp2Kml('file.exp','file.kml', 1,'central_meridian',45,'standard_parallel',70,'holes','yes');\n");
    95         _printf_(true,"      [ret]=Exp2Kml('file.exp','file.kml',-1,'central_meridian', 0,'standard_parallel',71,'holes','yes');\n");
    96         _printf_(true,"\n");
     75        _pprintLine_("Exp2Kml - exp to kml file conversion module:");
     76        _pprintLine_("");
     77        _pprintLine_("   This module converts a file from exp to kml format.");
     78        _pprintLine_("");
     79        _pprintLine_("   Usage:");
     80        _pprintLine_("      [ret]=Exp2Kml(filexp,filkml,sgn,'param name',param,...);");
     81        _pprintLine_("");
     82        _pprintLine_("      filexp      file name of exp file to be read (char)");
     83        _pprintLine_("      filkml      file name of kml file to be written (char)");
     84        _pprintLine_("      sgn         sign for hemisphere (double, +1 (north) or -1 (south))");
     85        _pprintLine_("");
     86        _pprintLine_("      central_meridian     central meridian (double, optional, but must specify with sp)");
     87        _pprintLine_("      standard_parallel    standard parallel (double, optional, but must specify with cm)");
     88        _pprintLine_("      holes       flag for treatment of multiple profiles (char, optional, 'yes' for holes))");
     89        _pprintLine_("");
     90        _pprintLine_("      ret         return code (non-zero for warning)");
     91        _pprintLine_("");
     92        _pprintLine_("   Examples:");
     93        _pprintLine_("      [ret]=Exp2Kml('file.exp','file.kml', 1);");
     94        _pprintLine_("      [ret]=Exp2Kml('file.exp','file.kml', 1,'central_meridian',45,'standard_parallel',70,'holes','yes');");
     95        _pprintLine_("      [ret]=Exp2Kml('file.exp','file.kml',-1,'central_meridian', 0,'standard_parallel',71,'holes','yes');");
     96        _pprintLine_("");
    9797}
    9898
  • issm/trunk/src/modules/HoleFiller/HoleFiller.cpp

    r12331 r12706  
    6060void HoleFillerUsage(void)
    6161{
    62         printf("   HoleFiller usage:\n");
    63         printf("   [image_out]=HoleFiller(image_in,smooth);\n\n");
    64         printf("   where:\n");
    65         printf("      image_in in double format\n");
    66         printf("      smooth: 1 to smooth with a box filer, 0 to leave data raw\n");
    67         printf("      image_out in double format\n");
    68         printf("\n");
     62        _printLine_("   HoleFiller usage:");
     63        _printLine_("   [image_out]=HoleFiller(image_in,smooth);\n");
     64        _printLine_("   where:");
     65        _printLine_("      image_in in double format");
     66        _printLine_("      smooth: 1 to smooth with a box filer, 0 to leave data raw");
     67        _printLine_("      image_out in double format");
     68        _printLine_("");
    6969}
  • issm/trunk/src/modules/InternalFront/InternalFront.cpp

    r12331 r12706  
    2626        /*Fetch required fields*/
    2727        FetchData(&numberofelements,mxGetAssignedField(MODEL,0,"numberofelements"));
    28         if(numberofelements<=0) _error_("No elements found in the model");
     28        if(numberofelements<=0) _error2_("No elements found in the model");
    2929        FetchData(&elements,&M,&N,mxGetAssignedField(MODEL,0,"elements"));
    30         if(M!=numberofelements || N!=3) _error_("Field 'elements' should be of size [md.numberofelements 3]");
     30        if(M!=numberofelements || N!=3) _error2_("Field 'elements' should be of size [md.numberofelements 3]");
    3131        FetchData(&elementonwater,&M,&N,mxGetAssignedField(MODEL,0,"elementonwater"));
    32         if(M!=numberofelements || N!=1) _error_("Field 'elementonwater' should be of size [md.numberofelements 1]");
     32        if(M!=numberofelements || N!=1) _error2_("Field 'elementonwater' should be of size [md.numberofelements 1]");
    3333        FetchData(&elementconnectivity,&M,&N,mxGetAssignedField(MODEL,0,"elementconnectivity"));
    34         if(M!=numberofelements || N!=3) _error_("Field 'elementconnectivity' should be of size [md.numberofelements 3]");
     34        if(M!=numberofelements || N!=3) _error2_("Field 'elementconnectivity' should be of size [md.numberofelements 3]");
    3535
    3636        /*Allocate and initialize all variables*/
     
    9494
    9595void InternalFrontUsage(void) {
    96         _printf_(true,"\n");
    97         _printf_(true,"   usage: icefront = %s(md);\n",__FUNCT__);
    98         _printf_(true,"\n");
     96        _pprintLine_("");
     97        _pprintLine_("   usage: icefront = " << __FUNCT__ << "(md);");
     98        _pprintLine_("");
    9999}
  • issm/trunk/src/modules/InterpFromGridToMesh/InterpFromGridToMesh.cpp

    r12331 r12706  
    4646        if((nlhs!=NLHS) || (nrhs!=6 && nrhs!=7)){
    4747                InterpFromGridToMeshUsage();
    48                 _error_(" usage. See above");
     48                _error2_("usage. See above");
    4949        }
    5050
     
    7575void InterpFromGridToMeshUsage(void)
    7676{
    77         _printf_(true,"INTERPFROMGRIDTOMESH - interpolation from a grid onto a list of points\n");
    78         _printf_(true,"\n");
    79         _printf_(true,"   This function is a multi-threaded mex file that interpolates a field\n");
    80         _printf_(true,"   defined on a grid onto a list of points\n");
    81         _printf_(true,"\n");
    82         _printf_(true,"   Usage:\n");
    83         _printf_(true,"      data_mesh=InterpFromGridToMesh(x,y,data,x_mesh,y_mesh,default_value);\n");
    84         _printf_(true,"\n");
    85         _printf_(true,"      data: matrix holding the data to be interpolated onto the mesh.\n");
    86         _printf_(true,"      x,y: coordinates of matrix data. (x and y must be in increasing order)\n");
    87         _printf_(true,"      x_mesh,y_mesh: coordinates of the points onto which we interpolate.\n");
    88         _printf_(true,"      default_value: default value if no data is found (holes).\n");
    89         _printf_(true,"      data_mesh: vector of mesh interpolated data.\n");
    90         _printf_(true,"\n");
    91         _printf_(true,"   Example:\n");
    92         _printf_(true,"      load('velocities.mat');\n");
    93         _printf_(true,"      md.inversion.vx_obs=InterpFromGridToMesh(x_n,y_m,vx,md.mesh.x,md.mesh.y,0);\n");
    94         _printf_(true,"\n");
     77        _pprintLine_("INTERPFROMGRIDTOMESH - interpolation from a grid onto a list of points");
     78        _pprintLine_("");
     79        _pprintLine_("   This function is a multi-threaded mex file that interpolates a field");
     80        _pprintLine_("   defined on a grid onto a list of points");
     81        _pprintLine_("");
     82        _pprintLine_("   Usage:");
     83        _pprintLine_("      data_mesh=InterpFromGridToMesh(x,y,data,x_mesh,y_mesh,default_value);");
     84        _pprintLine_("");
     85        _pprintLine_("      data: matrix holding the data to be interpolated onto the mesh.");
     86        _pprintLine_("      x,y: coordinates of matrix data. (x and y must be in increasing order)");
     87        _pprintLine_("      x_mesh,y_mesh: coordinates of the points onto which we interpolate.");
     88        _pprintLine_("      default_value: default value if no data is found (holes).");
     89        _pprintLine_("      data_mesh: vector of mesh interpolated data.");
     90        _pprintLine_("");
     91        _pprintLine_("   Example:");
     92        _pprintLine_("      load('velocities.mat');");
     93        _pprintLine_("      md.inversion.vx_obs=InterpFromGridToMesh(x_n,y_m,vx,md.mesh.x,md.mesh.y,0);");
     94        _pprintLine_("");
    9595}
  • issm/trunk/src/modules/InterpFromMesh2d/InterpFromMesh2d.cpp

    r12331 r12706  
    6969        if(nlhs!=NLHS){
    7070                InterpFromMesh2dUsage();
    71                 _error_("InterpFromMeshToMesh2dUsage usage error");
     71                _error2_("InterpFromMeshToMesh2dUsage usage error");
    7272        }
    7373        if((nrhs!=6) && (nrhs!=7) && (nrhs!=8)){
    7474                InterpFromMesh2dUsage();
    75                 _error_("InterpFromMeshToMesh2dUsage usage error");
     75                _error2_("InterpFromMeshToMesh2dUsage usage error");
    7676        }
    7777
     
    114114                /* Debugging of contours :{{{1*/
    115115                /*for(i=0;i<numcontours;i++){
    116                   printf("\nContour echo: contour number  %i / %i\n",i+1,numcontours);
     116                  _printLine_("\nContour echo: contour number  " << i+1 << " / " << numcontours);
    117117                  contouri=*(contours+i);
    118                   printf("   Number of vertices %i\n",contouri->nods);
     118                  _printLine_("   Number of vertices " << contouri->nods);
    119119                  for (j=0;j<contouri->nods;j++){
    120                   printf("   %lf %lf\n",*(contouri->x+j),*(contouri->y+j));
     120                  _printLine_("   " << *(contouri->x+j) << "f " << *(contouri->y+j) << "f");
    121121                  }
    122122                  }*/
     
    131131        /*some checks*/
    132132        if (x_data_rows!=y_data_rows){
    133                 _error_("vectors x and y should have the same length!");
     133                _error2_("vectors x and y should have the same length!");
    134134        }
    135135        if (x_prime_rows!=y_prime_rows){
    136                 _error_("vectors x_prime and y_prime should have the same length!");
     136                _error2_("vectors x_prime and y_prime should have the same length!");
    137137        }
    138138       
     
    154154void InterpFromMesh2dUsage(void)
    155155{
    156         _printf_(true,"   usage:\n");
    157         _printf_(true,"         data_prime=InterpFromMesh2d(index,x,y,data,x_prime,y_prime);\n\n");
    158         _printf_(true,"      or data_prime=InterpFromMesh2d(index,x,y,data,x_prime,y_prime,default_value);\n\n");
    159         _printf_(true,"      or data_prime=InterpFromMesh2d(index,x,y,data,x_prime,y_prime,default_value,contourname);\n\n");
    160         _printf_(true,"   where:\n");
    161         _printf_(true,"      x,y: coordinates of the nodes where data is defined\n");
    162         _printf_(true,"      index: index of the mesh where data is defined\n");
    163         _printf_(true,"      data - vector holding the data to be interpolated onto the points.\n");
    164         _printf_(true,"      x_prime,y_prime: coordinates of the mesh vertices onto which we interpolate.\n");
    165         _printf_(true,"      default_value: a scalar or vector of size length(x_prime).\n");
    166         _printf_(true,"      contourname: linear interpolation will happen on all x_interp,y_interp inside the contour, default value will be adopted on the rest of the mesh.\n");
    167         _printf_(true,"      data_prime:  vector of prime interpolated data.\n");
    168         _printf_(true,"\n");
     156        _pprintLine_("   usage:");
     157        _pprintLine_("         data_prime=InterpFromMesh2d(index,x,y,data,x_prime,y_prime);\n");
     158        _pprintLine_("      or data_prime=InterpFromMesh2d(index,x,y,data,x_prime,y_prime,default_value);\n");
     159        _pprintLine_("      or data_prime=InterpFromMesh2d(index,x,y,data,x_prime,y_prime,default_value,contourname);\n");
     160        _pprintLine_("   where:");
     161        _pprintLine_("      x,y: coordinates of the nodes where data is defined");
     162        _pprintLine_("      index: index of the mesh where data is defined");
     163        _pprintLine_("      data - vector holding the data to be interpolated onto the points.");
     164        _pprintLine_("      x_prime,y_prime: coordinates of the mesh vertices onto which we interpolate.");
     165        _pprintLine_("      default_value: a scalar or vector of size length(x_prime).");
     166        _pprintLine_("      contourname: linear interpolation will happen on all x_interp,y_interp inside the contour, default value will be adopted on the rest of the mesh.");
     167        _pprintLine_("      data_prime:  vector of prime interpolated data.");
     168        _pprintLine_("");
    169169}
  • issm/trunk/src/modules/InterpFromMeshToGrid/InterpFromMeshToGrid.cpp

    r12331 r12706  
    6464void InterpFromMeshToGridUsage(void)
    6565{
    66         _printf_(true,"INTERPFROMMESHTOGRID - interpolation of a data defined on a mesh onto a grid\n");
    67         _printf_(true,"\n");
    68         _printf_(true,"   This function is a multi-threaded mex file that interpolates a field\n");
    69         _printf_(true,"   defined on a triangular mesh onto a regular grid\n");
    70         _printf_(true,"\n");
    71         _printf_(true,"   Usage:\n");
    72         _printf_(true,"      [x_m,y_m,griddata]=InterpFromMeshToGrid(index,x,y,data,xmin,ymax,xposting,yposting,nlines,ncols,default_value)\n");
    73         _printf_(true,"\n");
    74         _printf_(true,"      index,x,y: delaunay triangulation defining the mesh.\n");
    75         _printf_(true,"      meshdata: vertex values of data to be interpolated.\n");
    76         _printf_(true,"      xmin,ymax,posting,nlines,ncols: parameters that define the grid\n");
    77         _printf_(true,"      default_value: value of points located out of the mesh.\n");
    78         _printf_(true,"\n");
     66        _pprintLine_("INTERPFROMMESHTOGRID - interpolation of a data defined on a mesh onto a grid");
     67        _pprintLine_("");
     68        _pprintLine_("   This function is a multi-threaded mex file that interpolates a field");
     69        _pprintLine_("   defined on a triangular mesh onto a regular grid");
     70        _pprintLine_("");
     71        _pprintLine_("   Usage:");
     72        _pprintLine_("      [x_m,y_m,griddata]=InterpFromMeshToGrid(index,x,y,data,xmin,ymax,xposting,yposting,nlines,ncols,default_value)");
     73        _pprintLine_("");
     74        _pprintLine_("      index,x,y: delaunay triangulation defining the mesh.");
     75        _pprintLine_("      meshdata: vertex values of data to be interpolated.");
     76        _pprintLine_("      xmin,ymax,posting,nlines,ncols: parameters that define the grid");
     77        _pprintLine_("      default_value: value of points located out of the mesh.");
     78        _pprintLine_("");
    7979}
  • issm/trunk/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp

    r12331 r12706  
    77WRAPPER(InterpFromMeshToMesh2d){
    88
    9         /*input: */
    10         double* index=NULL;
    11         int     index_cols;
    12         double* x_data=NULL;
    13         int     x_data_rows;
    14         double* y_data=NULL;
    15         int     y_data_rows;
    16         double* data=NULL;
    17         int     data_rows;
    18         int     data_cols;
    19         double* x_interp=NULL;
    20         int     x_interp_rows;
    21         double* y_interp=NULL;
    22         int     y_interp_rows;
    23         char*   contourname=NULL;
    24         double* default_values=NULL;
    25         int     num_default_values=0;
    26         DataSet *contours = NULL;
    27 
    28         /*Intermediary*/
    29         int nels_data;
    30 
    31         /* output: */
    32         double* data_interp=NULL;
     9        /*Intermediaties*/
     10        int     *index              = NULL;
     11        double  *x_data             = NULL;
     12        double  *y_data             = NULL;
     13        double  *data               = NULL;
     14        int      nods_data,nels_data;
     15        int      M_data,N_data;
     16        double  *x_interp           = NULL;
     17        double  *y_interp           = NULL;
     18        int      N_interp;
     19        Options *options   = NULL;
     20        double  *data_interp = NULL;
     21        int      test1,test2,test;
    3322
    3423        /*Boot module: */
     
    3928        if(nlhs!=NLHS){
    4029                InterpFromMeshToMesh2dUsage();
    41                 _error_("InterpFromMeshToMesh2dUsage usage error");
     30                _error2_("InterpFromMeshToMesh2dUsage usage error");
    4231        }
    4332        #endif
    4433        /*check on input arguments: */
    45         if((nrhs!=6) & (nrhs!=8)){
     34        if(nrhs<NRHS){
    4635                InterpFromMeshToMesh2dUsage();
    47                 _error_("InterpFromMeshToMesh2dUsage usage error");
     36                _error2_("InterpFromMeshToMesh2dUsage usage error");
    4837        }
    4938
    50         /*Input datasets: */
    51         FetchData(&index,&nels_data,&index_cols,INDEX);
    52         FetchData(&x_data,&x_data_rows,NULL,X);
    53         FetchData(&y_data,&y_data_rows,NULL,Y);
    54         FetchData(&data,&data_rows,&data_cols,DATA);
    55         FetchData(&x_interp,&x_interp_rows,XINTERP);
    56         FetchData(&y_interp,&y_interp_rows,YINTERP);
     39        /*Fetch inputs: */
     40        FetchData(&index,&nels_data,&test,INDEX); if(test!=3) _error2_("index should have 3 columns");
     41        FetchData(&x_data,&nods_data,X);          if(nods_data<3) _error2_("there should be at least three points");
     42        FetchData(&y_data,&test,Y);               if(test!=nods_data) _error2_("vectors x and y should have the same length");
     43        FetchData(&data,&M_data,&N_data,DATA);    if(M_data*N_data<1) _error2_("data is empty");
     44        FetchData(&x_interp,&N_interp,XINTERP);   if(N_interp<1) _error2_("no interpolation requested");
     45        FetchData(&y_interp,&test,YINTERP);       if(test!=N_interp) _error2_("vectors x_interp and y_interp should have the same length");
     46        FetchData(&options,NRHS,nrhs,prhs);
    5747
    58         /*Figure out contours and default values: */
    59         if(nrhs==8){
    60                 FetchData(&default_values,&num_default_values,DEFAULT);
    61                 FetchData(&contourname,CONTOURNAME);
    62                 contours=DomainOutlineRead(contourname);
    63         }
    64         else{
    65                 num_default_values=0;
    66                 default_values=NULL;
    67                 contours=new DataSet();
    68         }
    69 
    70 
    71         /*some checks*/
    72         if (x_data_rows!=y_data_rows){
    73                 _error_("vectors x and y should have the same length!");
    74         }
    75         if (x_interp_rows!=y_interp_rows){
    76                 _error_("vectors x_interp and y_interp should have the same length!");
    77         }
    78         if (index_cols!=3){
    79                 _error_("index should have 3 columns (input provided has %i columns)",index_cols);
    80         }
    81 
    82         /* Run core computations: */
    83         InterpFromMeshToMesh2dx(&data_interp,index,x_data,y_data,x_data_rows,nels_data,data,data_rows,data_cols,x_interp,y_interp,x_interp_rows,default_values,num_default_values,contours);
     48        /*Run core computations*/
     49        InterpFromMeshToMesh2dx(&data_interp,index,x_data,y_data,nods_data,nels_data,data,M_data,N_data,x_interp,y_interp,N_interp,options);
    8450
    8551        /*Write data: */
    86         WriteData(DATAINTERP,data_interp,x_interp_rows,data_cols);
     52        WriteData(DATAINTERP,data_interp,N_interp,N_data);
    8753
    8854        /*end module: */
     
    9056}
    9157
    92 void InterpFromMeshToMesh2dUsage(void)//{{{1
    93 
    94 {
    95         _printf_(true,"INTERFROMMESHTOMESH2D - interpolation from a 2d triangular mesh onto a list of point\n");
    96         _printf_(true,"\n");
    97         _printf_(true,"   This function is a multi-threaded mex file that interpolates a field\n");
    98         _printf_(true,"   defined on a triangular mesh onto a list of point\n");
    99         _printf_(true,"\n");
    100         _printf_(true,"   Usage:\n");
    101         _printf_(true,"         data_interp=InterpFromMeshToMesh2d(index,x,y,data,x_interp,y_interp);\n");
    102         _printf_(true,"      or data_interp=InterpFromMeshToMesh2d(index,x,y,data,x_interp,y_interp,default_value,contourname);\n");
    103         _printf_(true,"\n");
    104         _printf_(true,"      index: index of the mesh where data is defined\n");
    105         _printf_(true,"      x,y: coordinates of the nodes where data is defined\n");
    106         _printf_(true,"      data: matrix holding the data to be interpolated onto the mesh. (one column per field)\n");
    107         _printf_(true,"      x_interp,y_interp: coordinates of the points onto which we interpolate.\n");
    108         _printf_(true,"      if default_value and contourname not specified: linear interpolation will happen on all x_interp,y_interp.\n");
    109         _printf_(true,"      if (default_value,contourname) specified: linear interpolation will happen on all x_interp,y_interp inside the contour, default value will be adopted on the rest of the mesh.\n");
    110         _printf_(true,"      note that default_value is either a scalar, or a vector of size  length(x_interp)\n");
    111         _printf_(true,"      data_interp: vector of mesh interpolated data.\n");
    112         _printf_(true,"\n");
    113         _printf_(true,"   Example:\n");
    114         _printf_(true,"      load('temperature.mat');\n");
    115         _printf_(true,"      md.initialization.temperature=InterpFromMeshToMesh2d(index,x,y,temperature,md.mesh.x,md.mesh.y);\n");
    116         _printf_(true,"      md.initialization.temperature=InterpFromMeshToMesh2d(index,x,y,temperature,md.mesh.x,md.mesh.y,253,'Contour.exp');\n");
    117         _printf_(true,"\n");
     58void InterpFromMeshToMesh2dUsage(void){ /*{{{*/
     59        _pprintLine_("INTERFROMMESHTOMESH2D - interpolation from a 2d triangular mesh onto a list of point");
     60        _pprintLine_("");
     61        _pprintLine_("   This function is a multi-threaded mex file that interpolates a field");
     62        _pprintLine_("   defined on a Delaunay triangulation onto a list of point");
     63        _pprintLine_("");
     64        _pprintLine_("   Usage:");
     65        _pprintLine_("         data_interp=InterpFromMeshToMesh2d(index,x,y,data,x_interp,y_interp);");
     66        _pprintLine_("      or data_interp=InterpFromMeshToMesh2d(index,x,y,data,x_interp,y_interp,OPTIONS);");
     67        _pprintLine_("");
     68        _pprintLine_("      index             : index of the mesh where data is defined");
     69        _pprintLine_("      x,y               : coordinates of the nodes where data is defined");
     70        _pprintLine_("      data              : matrix holding the data to be interpolated onto the mesh. (one column per field)");
     71        _pprintLine_("      x_interp,y_interp : coordinates of the points onto which we interpolate.");
     72        _pprintLine_("      data_interp       : vector of mesh interpolated data.");
     73        _pprintLine_("      Available options :");
     74        _pprintLine_("         - 'default' : default value if point is outsite of triangulation (instead of linear interolation)");
     75        _pprintLine_("");
     76        _pprintLine_("   Example:");
     77        _pprintLine_("      load('temperature.mat');");
     78        _pprintLine_("      md.initialization.temperature=InterpFromMeshToMesh2d(index,x,y,temperature,md.mesh.x,md.mesh.y);");
     79        _pprintLine_("      md.initialization.temperature=InterpFromMeshToMesh2d(index,x,y,temperature,md.mesh.x,md.mesh.y,'default',253);");
     80        _pprintLine_("");
    11881}
    119 //}}}
     82/*}}}*/
  • issm/trunk/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.h

    r12331 r12706  
    1212#endif
    1313
    14 /*Very important definition in case we are compiling a python module!: needs to come before header files inclusion*/
     14/* local prototypes: */
     15void InterpFromMeshToMesh2dUsage(void);
     16
     17/*If python: this macro needs to come before header files inclusion*/
    1518#ifdef _HAVE_PYTHON_
    1619#define PY_ARRAY_UNIQUE_SYMBOL PythonIOSymbol
     
    2831#include "../../c/EnumDefinitions/EnumDefinitions.h"
    2932
     33#undef __FUNCT__
     34#define __FUNCT__  "InterpFromMeshToMesh2d"
     35
    3036#ifdef _HAVE_MATLAB_MODULES_
    3137/* serial input macros: */
     
    3642#define XINTERP prhs[4]
    3743#define YINTERP prhs[5]
    38 #define DEFAULT prhs[6]
    39 #define CONTOURNAME prhs[7]
    4044
    4145/* serial output macros: */
     
    5155#define XINTERP PyTuple_GetItem(args,4)
    5256#define YINTERP PyTuple_GetItem(args,5)
    53 #define DEFAULT PyTuple_GetItem(args,6)
    54 #define CONTOURNAME PyTuple_GetItem(args,7)
     57
    5558/* serial output macros: */
    5659#define DATAINTERP output,0
    5760#endif
    58 
    59 #undef __FUNCT__
    60 #define __FUNCT__  "InterpFromMeshToMesh2d"
    6161
    6262/* serial arg counts: */
     
    6464#define NLHS  1
    6565#undef NRHS
    66 #define NRHS  6 //can be 8 though
    67 
    68 /* local prototypes: */
    69 void InterpFromMeshToMesh2dUsage(void);
     66#define NRHS  6
    7067
    7168#endif
  • issm/trunk/src/modules/InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.cpp

    r12331 r12706  
    7676        /*some checks*/
    7777        if (x_data_rows!=y_data_rows || x_data_rows!=z_data_rows){
    78                 _error_("vectors x, y and z should have the same length!");
     78                _error2_("vectors x, y and z should have the same length!");
    7979        }
    8080        if (x_prime_rows!=y_prime_rows || x_prime_rows!=z_prime_rows){
    81                 _error_("vectors x_prime, y_prime and z_prime should have the same length!");
     81                _error2_("vectors x_prime, y_prime and z_prime should have the same length!");
    8282        }
    8383        /*get number of elements and number of nodes in the data*/
     
    9898void InterpFromMeshToMesh3dUsage(void)
    9999{
    100         _printf_(true,"INTERPFROMMESHTOMESH3D - interpolation from a 3d hexahedron mesh onto a list of point\n");
    101         _printf_(true,"\n");
    102         _printf_(true,"   This function is a multi-threaded mex file that interpolates a field\n");
    103         _printf_(true,"   defined on a triangular mesh onto a list of point\n");
    104         _printf_(true,"\n");
    105         _printf_(true,"   Usage:\n");
    106         _printf_(true,"      data_prime=InterpFromMeshToMesh3d(index,x,y,z,data,x_prime,y_prime,z_prime,default_value);\n");
    107         _printf_(true,"\n");
    108         _printf_(true,"      index: index of the mesh where data is defined\n");
    109         _printf_(true,"      x,y,z: coordinates of the nodes where data is defined\n");
    110         _printf_(true,"      data: matrix holding the data to be interpolated onto the mesh.\n");
    111         _printf_(true,"      x_prime,y_prime,z_prime: coordinates of the points onto which we interpolate.\n");
    112         _printf_(true,"      default_value: default value if no data is found (holes).\n");
    113         _printf_(true,"      data_prime: vector of mesh interpolated data.\n");
    114         _printf_(true,"\n");
    115         _printf_(true,"   Example:\n");
    116         _printf_(true,"      load('temperature.mat');\n");
    117         _printf_(true,"      md.initialization.temperature=InterpFromMeshToMesh3d(index,x,y,z,temperature,md.mesh.x,md.mesh.y,md.mesh.z,253);\n");
    118         _printf_(true,"\n");
     100        _pprintLine_("INTERPFROMMESHTOMESH3D - interpolation from a 3d hexahedron mesh onto a list of point");
     101        _pprintLine_("");
     102        _pprintLine_("   This function is a multi-threaded mex file that interpolates a field");
     103        _pprintLine_("   defined on a triangular mesh onto a list of point");
     104        _pprintLine_("");
     105        _pprintLine_("   Usage:");
     106        _pprintLine_("      data_prime=InterpFromMeshToMesh3d(index,x,y,z,data,x_prime,y_prime,z_prime,default_value);");
     107        _pprintLine_("");
     108        _pprintLine_("      index: index of the mesh where data is defined");
     109        _pprintLine_("      x,y,z: coordinates of the nodes where data is defined");
     110        _pprintLine_("      data: matrix holding the data to be interpolated onto the mesh.");
     111        _pprintLine_("      x_prime,y_prime,z_prime: coordinates of the points onto which we interpolate.");
     112        _pprintLine_("      default_value: default value if no data is found (holes).");
     113        _pprintLine_("      data_prime: vector of mesh interpolated data.");
     114        _pprintLine_("");
     115        _pprintLine_("   Example:");
     116        _pprintLine_("      load('temperature.mat');");
     117        _pprintLine_("      md.initialization.temperature=InterpFromMeshToMesh3d(index,x,y,z,temperature,md.mesh.x,md.mesh.y,md.mesh.z,253);");
     118        _pprintLine_("");
    119119}
  • issm/trunk/src/modules/KMLFileRead/KMLFileRead.cpp

    r12331 r12706  
    4545        /*checks on arguments on the matlab side: */
    4646        if (nlhs > NLHS) {
    47                 KMLFileReadUsage(); _error_("KMLFileRead usage error");
     47                KMLFileReadUsage(); _error2_("KMLFileRead usage error");
    4848        }
    4949        if (nrhs < NRHS) {
    50                 KMLFileReadUsage(); _error_("KMLFileRead usage error");
     50                KMLFileReadUsage(); _error2_("KMLFileRead usage error");
    5151        }
    5252
     
    6363        if (!strlen(filnam)) strcpy(filnam,"stdout");
    6464
    65         if (verbose) printf("Opening file \"%s\".\n",filnam);
     65        if (verbose) _printLine_("Opening file \"" << filnam << "\".");
    6666        fidi=fopen(filnam,"r");
    6767
    6868        /* Run core computations: */
    69         if (verbose) printf("Calling core:\n");
     69        if (verbose) _printLine_("Calling core:");
    7070        kobj=KMLFileReadx(fidi);
    7171
    72         if (verbose) printf("Closing file \"%s\".\n",filnam);
     72        if (verbose) _printLine_("Closing file \"" << filnam << "\".");
    7373        fclose(fidi);
    7474
     
    8383                        }
    8484                        else {
    85                                 if (verbose) printf("Opening file \"%s\".\n",write);
     85                                if (verbose) _printLine_("Opening file \"" << write << "\".");
    8686                                fido=fopen(write,"w");
    8787                                kobj->Write(fido,"");
    88                                 if (verbose) printf("Closing file \"%s\".\n",write);
     88                                if (verbose) _printLine_("Closing file \"" << write << "\".");
    8989                                ierror=fclose(fido);
    9090                        }
     
    107107
    108108void KMLFileReadUsage(void){
    109         _printf_(true,"KMLFileRead - KML file reader module:\n");
    110         _printf_(true,"\n");
    111         _printf_(true,"   This module reads a KML file.\n");
    112         _printf_(true,"\n");
    113         _printf_(true,"   Usage:\n");
    114         _printf_(true,"      [ierror]=KMLFileRead(kmlfile,'param name',param,...);\n");
    115         _printf_(true,"\n");
    116         _printf_(true,"      kmlfile      file name of kml file to be read (char)\n");
    117         _printf_(true,"\n");
    118         _printf_(true,"      echo         echo command (char, optional, 'off'/'on')\n");
    119         _printf_(true,"      deepecho     deep echo command (char, optional, 'off'/'on')\n");
    120         _printf_(true,"      write        write command (char, optional, 'off'/'stdout'/kmlfile)\n");
    121         _printf_(true,"\n");
    122         _printf_(true,"      ierror       return code (non-zero for error)\n");
    123         _printf_(true,"\n");
    124         _printf_(true,"   Examples:\n");
    125         _printf_(true,"      [ierror]=KMLFileRead('file.kml','deepecho','on');\n");
    126         _printf_(true,"      [ierror]=KMLFileRead('filin.kml','echo','on','write','filout.kml');\n");
    127         _printf_(true,"\n");
     109        _pprintLine_("KMLFileRead - KML file reader module:");
     110        _pprintLine_("");
     111        _pprintLine_("   This module reads a KML file.");
     112        _pprintLine_("");
     113        _pprintLine_("   Usage:");
     114        _pprintLine_("      [ierror]=KMLFileRead(kmlfile,'param name',param,...);");
     115        _pprintLine_("");
     116        _pprintLine_("      kmlfile      file name of kml file to be read (char)");
     117        _pprintLine_("");
     118        _pprintLine_("      echo         echo command (char, optional, 'off'/'on')");
     119        _pprintLine_("      deepecho     deep echo command (char, optional, 'off'/'on')");
     120        _pprintLine_("      write        write command (char, optional, 'off'/'stdout'/kmlfile)");
     121        _pprintLine_("");
     122        _pprintLine_("      ierror       return code (non-zero for error)");
     123        _pprintLine_("");
     124        _pprintLine_("   Examples:");
     125        _pprintLine_("      [ierror]=KMLFileRead('file.kml','deepecho','on');");
     126        _pprintLine_("      [ierror]=KMLFileRead('filin.kml','echo','on','write','filout.kml');");
     127        _pprintLine_("");
    128128}
    129129
  • issm/trunk/src/modules/KMLMeshWrite/KMLMeshWrite.cpp

    r12331 r12706  
    4040        /*checks on arguments on the matlab side: */
    4141        if (nlhs > NLHS) {
    42                 KMLMeshWriteUsage(); _error_("KMLMeshWrite usage error");
     42                KMLMeshWriteUsage(); _error2_("KMLMeshWrite usage error");
    4343        }
    4444        if (nrhs < NRHS) {
    45                 KMLMeshWriteUsage(); _error_("KMLMeshWrite usage error");
     45                KMLMeshWriteUsage(); _error2_("KMLMeshWrite usage error");
    4646        }
    4747
     
    8787
    8888        if (nodecon && (mncon != nnodes))
    89                 _error_("Nodal connectivity table, if supplied, must be supplied for all nodes.");
     89          {_error2_("Nodal connectivity table, if supplied, must be supplied for all nodes.");}
    9090        else if (!nodecon)
    9191                mncon=nnodes;
    9292        if ((llat != nnodes) || (llng != nnodes) || (llat != llng))
    93                 _error_("Latitude and longitude vectors must be supplied for all nodes.");
     93                _error2_("Latitude and longitude vectors must be supplied for all nodes.");
    9494        if (part && (lprt != nnodes))
    95                 _error_("Partitioning vector, if supplied, must be supplied for all nodes.");
     95                _error2_("Partitioning vector, if supplied, must be supplied for all nodes.");
    9696        if (data && !((mdata == nnodes) || (mdata == melem)))
    97                 _error_("Data matrix, if supplied, must be supplied for all nodes or all elements.");
     97                _error2_("Data matrix, if supplied, must be supplied for all nodes or all elements.");
    9898        if (cmap && (ncmap != 3))
    99                 _error_("Colormap matrix, if supplied, must have three columns for rgb.");
     99                _error2_("Colormap matrix, if supplied, must have three columns for rgb.");
    100100        if (!strlen(filnam))
    101101                strcpy(filnam,"stdout");
     
    118118
    119119void KMLMeshWriteUsage(void){
    120         _printf_(true,"KMLMeshWrite - KML mesh writer module:\n");
    121         _printf_(true,"\n");
    122         _printf_(true,"   This module writes the mesh of a model as KML polygons into the specified KML file.\n");
    123         _printf_(true,"\n");
    124         _printf_(true,"   Usage:\n");
    125         _printf_(true,"      ierror=KMLMeshWrite(name,notes,elem,nodecon,lat,long,part,data,cmap,kmlfile);\n");
    126         _printf_(true,"\n");
    127         _printf_(true,"      name       model name (string, may be empty)\n");
    128         _printf_(true,"      notes      model notes (string or cell array of strings, may be empty)\n");
    129         _printf_(true,"      elem       elements (double array)\n");
    130         _printf_(true,"      nodecon    nodal connectivity array (double array, may be empty)\n");
    131         _printf_(true,"      lat        nodal latititudes (double vector)\n");
    132         _printf_(true,"      long       nodal longitudes (double vector)\n");
    133         _printf_(true,"      part       nodal partitions (double vector, may be empty)\n");
    134         _printf_(true,"      data       nodal or element data (double vector, may be empty)\n");
    135         _printf_(true,"      cmap       color map (double nx3 array, may be empty)\n");
    136         _printf_(true,"      kmlfile    KML file name (string)\n");
    137         _printf_(true,"\n");
    138         _printf_(true,"      ierror     error flag (double, non-zero for error)\n");
    139         _printf_(true,"\n");
    140         _printf_(true,"   Example:\n");
    141         _printf_(true,"      KMLMeshWrite(md.name,md.notes,md.elements,md.nodeconnectivity,md.lat,md.long,md.part,md.fm_criterion,options.cmap,filekml);\n");
    142         _printf_(true,"\n");
     120        _pprintLine_("KMLMeshWrite - KML mesh writer module:");
     121        _pprintLine_("");
     122        _pprintLine_("   This module writes the mesh of a model as KML polygons into the specified KML file.");
     123        _pprintLine_("");
     124        _pprintLine_("   Usage:");
     125        _pprintLine_("      ierror=KMLMeshWrite(name,notes,elem,nodecon,lat,long,part,data,cmap,kmlfile);");
     126        _pprintLine_("");
     127        _pprintLine_("      name       model name (string, may be empty)");
     128        _pprintLine_("      notes      model notes (string or cell array of strings, may be empty)");
     129        _pprintLine_("      elem       elements (double array)");
     130        _pprintLine_("      nodecon    nodal connectivity array (double array, may be empty)");
     131        _pprintLine_("      lat        nodal latititudes (double vector)");
     132        _pprintLine_("      long       nodal longitudes (double vector)");
     133        _pprintLine_("      part       nodal partitions (double vector, may be empty)");
     134        _pprintLine_("      data       nodal or element data (double vector, may be empty)");
     135        _pprintLine_("      cmap       color map (double nx3 array, may be empty)");
     136        _pprintLine_("      kmlfile    KML file name (string)");
     137        _pprintLine_("");
     138        _pprintLine_("      ierror     error flag (double, non-zero for error)");
     139        _pprintLine_("");
     140        _pprintLine_("   Example:");
     141        _pprintLine_("      KMLMeshWrite(md.name,md.notes,md.elements,md.nodeconnectivity,md.lat,md.long,md.part,md.fm_criterion,options.cmap,filekml);");
     142        _pprintLine_("");
    143143}
  • issm/trunk/src/modules/KMLOverlay/KMLOverlay.cpp

    r12331 r12706  
    3131        /*checks on arguments on the matlab side: */
    3232        if(nlhs>NLHS){
    33                 KMLOverlayUsage(); _error_("KMLOverlay usage error");
     33                KMLOverlayUsage(); _error2_("KMLOverlay usage error");
    3434        }
    3535        if(nrhs<NRHS){
    36                 KMLOverlayUsage(); _error_("KMLOverlay usage error");
     36                KMLOverlayUsage(); _error2_("KMLOverlay usage error");
    3737        }
    3838
     
    4242
    4343        options->Get(&lataxis ,&nlat ,"lataxis" );
    44         if (verbose && lataxis) for (i=0; i<nlat; i++) printf("  lataxis [%d]=%g\n",i,lataxis[i]);
     44        if (verbose && lataxis) for (i=0; i<nlat; i++) _printLine_("  lataxis [" << i << "]=" << lataxis[i]);
    4545        options->Get(&longaxis,&nlong,"longaxis");
    46         if (verbose && longaxis) for (i=0; i<nlong; i++) printf("  longaxis[%d]=%g\n",i,longaxis[i]);
     46        if (verbose && longaxis) for (i=0; i<nlong; i++) _printLine_("  longaxis[" << i << "]=" << longaxis[i]);
    4747        options->Get(&pimages,&nimages,"images");
    48         if (verbose && pimages) for (i=0; i<nimages; i++) printf("  pimages[%d]=\"%s\"\n",i,pimages[i]);
     48        if (verbose && pimages) for (i=0; i<nimages; i++) _printLine_("  pimages[" << i << "]=\"" << pimages[i] << "\"");
    4949        options->Get(&dzip,"zip",0.);
    50         if (verbose) printf("  dzip=%g\n",dzip);
     50        if (verbose) _printLine_("  dzip=" << dzip);
    5151
    5252        /*some checks*/
    53         if (nlat !=2) _error_("Latitudinal axes \"lataxis\" require two double values, not %d.",nlat);
    54         if (nlong!=2) _error_("Longitudinal axes \"longaxis\" require two double values, not %d.",nlong);
    55         if (!nimages) _error_("No image files provided.");
     53        if (nlat !=2) _error2_("Latitudinal axes \"lataxis\" require two double values, not " << nlat << ".");
     54        if (nlong!=2) _error2_("Longitudinal axes \"longaxis\" require two double values, not " << nlong << ".");
     55        if (!nimages) _error2_("No image files provided.");
    5656
    5757        if ((int)dzip){
     
    6363        if(!strlen(filkml)) strcpy(filkml,"stdout");
    6464
    65         if(verbose) printf("Opening kml overlay file \"%s\".\n",filkml);
     65        if(verbose) _printLine_("Opening kml overlay file \"" << filkml << "\".");
    6666        fid=fopen(filkml,"w");
    6767
    6868        /* Run core computations: */
    69         if (verbose) printf("Calling core:\n");
     69        if (verbose) _printLine_("Calling core:");
    7070        KMLOverlayx(&ierror,lataxis,longaxis,nimages,pimages,fid);
    7171
    72         if (verbose) printf("Closing file \"%s\".\n",filkml);
     72        if (verbose) _printLine_("Closing file \"" << filkml << "\".");
    7373        fclose(fid);
    7474
     
    8787                                strcat(czip,pimages[i]);
    8888                        }
    89                 if (verbose) printf("Zipping file \"%s\".\n",filkmz);
    90                 if (verbose) printf("%s\n",czip);
     89                if (verbose) _printLine_("Zipping file \"" << filkmz << "\".");
     90                if (verbose) _printLine_(czip);
    9191
    92                 if (mexEvalString(czip)) _error_("Error zipping file \"%s\".",filkmz);
     92                if (mexEvalString(czip)) _error2_("Error zipping file \"" << filkmz << "\".");
    9393                xfree((void**)&czip);
    9494                xfree((void**)&filkmz);
     
    113113
    114114void KMLOverlayUsage(void){
    115         _printf_(true,"KMLOverlay - KML file overlay module:\n");
    116         _printf_(true,"\n");
    117         _printf_(true,"   This module reads a list of image files and writes a KML or KMZ overlay file.\n");
    118         _printf_(true,"\n");
    119         _printf_(true,"   Usage:\n");
    120         _printf_(true,"      ierror=KMLOverlay(kmlfile,'param name',param,...);\n");
    121         _printf_(true,"\n");
    122         _printf_(true,"      kmlfile     KML or KMZ file name (string)\n");
    123         _printf_(true,"\n");
    124         _printf_(true,"      lataxis     latitude axis (double vector [south north], required)\n");
    125         _printf_(true,"      longaxis    longitude axis (double vector [west east], required)\n");
    126         _printf_(true,"      images      relative or http image file names (string or array of strings or cell array of strings, required)\n");
    127         _printf_(true,"      zip         flag to zip the doc.kml and image files into kmzfile (double, non-zero for kmz)\n");
    128         _printf_(true,"\n");
    129         _printf_(true,"      ierror     error flag (double, non-zero for error)\n");
    130         _printf_(true,"\n");
    131         _printf_(true,"   Example:\n");
    132         _printf_(true,"      KMLOverlay(kmlfile,'lataxis',[south north],'longaxis',[west east],'images',{'file1.png','http://issm/file2.png'},'zip',1);\n");
    133         _printf_(true,"\n");
     115        _pprintLine_("KMLOverlay - KML file overlay module:");
     116        _pprintLine_("");
     117        _pprintLine_("   This module reads a list of image files and writes a KML or KMZ overlay file.");
     118        _pprintLine_("");
     119        _pprintLine_("   Usage:");
     120        _pprintLine_("      ierror=KMLOverlay(kmlfile,'param name',param,...);");
     121        _pprintLine_("");
     122        _pprintLine_("      kmlfile     KML or KMZ file name (string)");
     123        _pprintLine_("");
     124        _pprintLine_("      lataxis     latitude axis (double vector [south north], required)");
     125        _pprintLine_("      longaxis    longitude axis (double vector [west east], required)");
     126        _pprintLine_("      images      relative or http image file names (string or array of strings or cell array of strings, required)");
     127        _pprintLine_("      zip         flag to zip the doc.kml and image files into kmzfile (double, non-zero for kmz)");
     128        _pprintLine_("");
     129        _pprintLine_("      ierror     error flag (double, non-zero for error)");
     130        _pprintLine_("");
     131        _pprintLine_("   Example:");
     132        _pprintLine_("      KMLOverlay(kmlfile,'lataxis',[south north],'longaxis',[west east],'images',{'file1.png','http://issm/file2.png'},'zip',1);");
     133        _pprintLine_("");
    134134}
  • issm/trunk/src/modules/Kml2Exp/Kml2Exp.cpp

    r12331 r12706  
    2222        /*checks on arguments on the matlab side: */
    2323        if (nlhs > NLHS) {
    24                 Kml2ExpUsage(); _error_("Kml2Exp usage error");
     24                Kml2ExpUsage(); _error2_("Kml2Exp usage error");
    2525        }
    2626        if (nrhs < NRHS) {
    27                 Kml2ExpUsage(); _error_("Kml2Exp usage error");
     27                Kml2ExpUsage(); _error2_("Kml2Exp usage error");
    2828        }
    2929
     
    3737        if (options->GetOption("central_meridian") || options->GetOption("standard_parallel")) {
    3838                options->Get(&cm,"central_meridian");
    39                 if (verbose) printf("  cm=%g\n",cm);
     39                if (verbose) _printLine_("  cm=" << cm);
    4040                options->Get(&sp,"standard_parallel");
    41                 if (verbose) printf("  sp=%g\n",sp);
     41                if (verbose) _printLine_("  sp=" << sp);
    4242        }
    4343
    4444        /*some checks*/
    45         if (sgn !=+1 && sgn!= -1) _error_("Hemisphere sgn=%d must be +1 (north) or -1 (south).",sgn);
    46         if (fabs(cm)      > 180.) _error_("Central meridian cm=%g must be between -180 (west) and +180 (east) degrees.",cm);
    47         if (sp < 0. || sp >  90.) _error_("Standard parallel sp=%g must be between 0 and 90 degrees (in specified hemisphere).",sp);
     45        if (sgn !=+1 && sgn!= -1) _error2_("Hemisphere sgn=" << sgn << " must be +1 (north) or -1 (south).");
     46        if (fabs(cm)      > 180.) _error2_("Central meridian cm=" << cm << " must be between -180 (west) and +180 (east) degrees.");
     47        if (sp < 0. || sp >  90.) _error2_("Standard parallel sp=" << sp << " must be between 0 and 90 degrees (in specified hemisphere).");
    4848
    4949        /* Run core computations: */
     
    6666
    6767void Kml2ExpUsage(void){
    68         _printf_(true,"Kml2Exp - kml to exp file conversion module:\n");
    69         _printf_(true,"\n");
    70         _printf_(true,"   This module converts a file from kml to exp format.\n");
    71         _printf_(true,"\n");
    72         _printf_(true,"   Usage:\n");
    73         _printf_(true,"      [ret]=Kml2Exp(filexp,filkml,sgn,'param name',param,...);\n");
    74         _printf_(true,"\n");
    75         _printf_(true,"      filkml      file name of kml file to be read (char)\n");
    76         _printf_(true,"      filexp      file name of exp file to be written (char)\n");
    77         _printf_(true,"      sgn         sign for hemisphere (double, +1 (north) or -1 (south))\n");
    78         _printf_(true,"\n");
    79         _printf_(true,"      central_meridian     central meridian (double, optional, but must specify with sp)\n");
    80         _printf_(true,"      standard_parallel    standard parallel (double, optional, but must specify with cm)\n");
    81         _printf_(true,"\n");
    82         _printf_(true,"      ret         return code (non-zero for warning)\n");
    83         _printf_(true,"\n");
    84         _printf_(true,"   Examples:\n");
    85         _printf_(true,"      [ret]=Kml2Exp('file.kml','file.exp', 1);\n");
    86         _printf_(true,"      [ret]=Kml2Exp('file.kml','file.exp', 1,'central_meridian',45,'standard_parallel',70);\n");
    87         _printf_(true,"      [ret]=Kml2Exp('file.kml','file.exp',-1,'central_meridian', 0,'standard_parallel',71);\n");
    88         _printf_(true,"\n");
     68        _pprintLine_("Kml2Exp - kml to exp file conversion module:");
     69        _pprintLine_("");
     70        _pprintLine_("   This module converts a file from kml to exp format.");
     71        _pprintLine_("");
     72        _pprintLine_("   Usage:");
     73        _pprintLine_("      [ret]=Kml2Exp(filexp,filkml,sgn,'param name',param,...);");
     74        _pprintLine_("");
     75        _pprintLine_("      filkml      file name of kml file to be read (char)");
     76        _pprintLine_("      filexp      file name of exp file to be written (char)");
     77        _pprintLine_("      sgn         sign for hemisphere (double, +1 (north) or -1 (south))");
     78        _pprintLine_("");
     79        _pprintLine_("      central_meridian     central meridian (double, optional, but must specify with sp)");
     80        _pprintLine_("      standard_parallel    standard parallel (double, optional, but must specify with cm)");
     81        _pprintLine_("");
     82        _pprintLine_("      ret         return code (non-zero for warning)");
     83        _pprintLine_("");
     84        _pprintLine_("   Examples:");
     85        _pprintLine_("      [ret]=Kml2Exp('file.kml','file.exp', 1);");
     86        _pprintLine_("      [ret]=Kml2Exp('file.kml','file.exp', 1,'central_meridian',45,'standard_parallel',70);");
     87        _pprintLine_("      [ret]=Kml2Exp('file.kml','file.exp',-1,'central_meridian', 0,'standard_parallel',71);");
     88        _pprintLine_("");
    8989}
    9090
  • issm/trunk/src/modules/Kriging/Kriging.cpp

    r12331 r12706  
    2222        /*checks on arguments on the matlab side: */
    2323        if (nrhs<NRHS || nlhs>NLHS){
    24                 KrigingUsage(); _error_("Kriging usage error");
     24                KrigingUsage(); _error2_("Kriging usage error");
    2525        }
    2626
    2727        /*Fetch inputs: */
    2828        FetchData(&x,&n_obs,X);
    29         FetchData(&y,&N,Y);                       if(n_obs!=N) _error_("x and y should have the same size");
    30         FetchData(&observations,&N,OBSERVATIONS); if(n_obs!=N) _error_("x and observations should have the same size");
     29        FetchData(&y,&N,Y);                       if(n_obs!=N) _error2_("x and y should have the same size");
     30        FetchData(&observations,&N,OBSERVATIONS); if(n_obs!=N) _error2_("x and observations should have the same size");
    3131        FetchData(&x_interp,&M_interp,&N_interp,XINTERP);
    32         FetchData(&y_interp,&M,&N,YINTERP);       if(N!=N_interp || M!=M_interp) _error_("x_interp and y_interp should have the same size");
     32        FetchData(&y_interp,&M,&N,YINTERP);       if(N!=N_interp || M!=M_interp) _error2_("x_interp and y_interp should have the same size");
    3333        FetchData(&options,NRHS,nrhs,prhs);
    3434
     
    5454
    5555void KrigingUsage(void){
    56         _printf_(true,"\n");
    57         _printf_(true,"   usage: predictions=%s(x,y,observations,x_interp,y_interp,'options');\n",__FUNCT__);
    58         _printf_(true,"   available options:\n");
    59         _printf_(true,"      -'model': Available variogram models 'gaussian' (default),'spherical','power','exponential'\n");
    60         _printf_(true,"         -'nugget': nugget effect (default 0.2)\n");
    61         _printf_(true,"         -'range':  for gaussian, spherical and exponential models (default sqrt(3))\n");
    62         _printf_(true,"         -'sill':   for gaussian, spherical and exponential models (default 1)\n");
    63         _printf_(true,"         -'slope':  for power model (default 1)\n");
    64         _printf_(true,"         -'power':  for power model (default 1)\n");
    65         _printf_(true,"      -'searchradius': search radius for each prediction (default is observations span)\n");
    66         _printf_(true,"      -'boxlength':    minimum length of quadtree boxes (useful to decrease the number of observations)\n");
    67         _printf_(true,"      -'maxdata':      minimum number of observations for a prediction (default is 50)\n");
    68         _printf_(true,"      -'mindata':      maximum number of observations for a prediction (default is 1)\n");
    69         _printf_(true,"      -'maxtrimming':  maximum trimming value (default is -1.e+21)\n");
    70         _printf_(true,"      -'mintrimming':  minimum trimming value (default is +1.e+21)\n");
    71         _printf_(true,"      -'minspacing':   minimum distance between observation (default is 0.01)\n");
    72         _printf_(true,"\n");
     56        _pprintLine_("");
     57        _pprintLine_("   usage: predictions=" << __FUNCT__ << "(x,y,observations,x_interp,y_interp,'options');");
     58        _pprintLine_("   available options:");
     59        _pprintLine_("      -'model': Available variogram models 'gaussian' (default),'spherical','power','exponential'");
     60        _pprintLine_("         -'nugget': nugget effect (default 0.2)");
     61        _pprintLine_("         -'range':  for gaussian, spherical and exponential models (default sqrt(3))");
     62        _pprintLine_("         -'sill':   for gaussian, spherical and exponential models (default 1)");
     63        _pprintLine_("         -'slope':  for power model (default 1)");
     64        _pprintLine_("         -'power':  for power model (default 1)");
     65        _pprintLine_("      -'searchradius': search radius for each prediction (default is observations span)");
     66        _pprintLine_("      -'boxlength':    minimum length of quadtree boxes (useful to decrease the number of observations)");
     67        _pprintLine_("      -'maxdata':      minimum number of observations for a prediction (default is 50)");
     68        _pprintLine_("      -'mindata':      maximum number of observations for a prediction (default is 1)");
     69        _pprintLine_("      -'maxtrimming':  maximum trimming value (default is -1.e+21)");
     70        _pprintLine_("      -'mintrimming':  minimum trimming value (default is +1.e+21)");
     71        _pprintLine_("      -'minspacing':   minimum distance between observation (default is 0.01)");
     72        _pprintLine_("");
    7373}
  • issm/trunk/src/modules/Ll2xy/Ll2xy.cpp

    r12331 r12706  
    2525        /*checks on arguments on the matlab side: */
    2626        if (nlhs > NLHS) {
    27                 Ll2xyUsage(); _error_("Ll2xy usage error");
     27                Ll2xyUsage(); _error2_("Ll2xy usage error");
    2828        }
    2929        if (nrhs < NRHS) {
    30                 Ll2xyUsage(); _error_("Ll2xy usage error");
     30                Ll2xyUsage(); _error2_("Ll2xy usage error");
    3131        }
    3232
     
    4040        if(options->GetOption("central_meridian") || options->GetOption("standard_parallel")){
    4141                options->Get(&cm,"central_meridian");
    42                 if (verbose) printf("  cm=%g\n",cm);
     42                if (verbose) _printLine_("  cm=" << cm);
    4343                options->Get(&sp,"standard_parallel");
    44                 if (verbose) printf("  sp=%g\n",sp);
     44                if (verbose) _printLine_("  sp=" << sp);
    4545        }
    4646
    4747        /*some checks*/
    48         if (verbose) printf("Checking inputs:\n");
    49         if (nlat != nlon) _error_("Must have same number of lat[%d] and lon[%d] coordinates.",nlat,nlon);
     48        if (verbose) _printLine_("Checking inputs:");
     49        if (nlat != nlon){_error2_("Must have same number of lat[" << nlat << "] and lon[" << nlon << "] coordinates.");}
    5050        else                ncoord=nlat;
    51         if (sgn != +1 && sgn != -1) _error_("Hemisphere sgn=%d must be +1 (north) or -1 (south).",sgn);
    52         if (fabs(cm)      > 180.) _error_("Central meridian cm=%g must be between -180 (west) and +180 (east) degrees.",cm);
    53         if (sp < 0. || sp >  90.) _error_("Standard parallel sp=%g must be between 0 and 90 degrees (in specified hemisphere).",sp);
     51        if (sgn != +1 && sgn != -1) _error2_("Hemisphere sgn=" << sgn << " must be +1 (north) or -1 (south).");
     52        if (fabs(cm)      > 180.) _error2_("Central meridian cm=" << cm << " must be between -180 (west) and +180 (east) degrees.");
     53        if (sp < 0. || sp >  90.) _error2_("Standard parallel sp=" << sp << " must be between 0 and 90 degrees (in specified hemisphere).");
    5454
    5555        x=(double*)mxMalloc(ncoord*sizeof(double));
     
    7474
    7575void Ll2xyUsage(void){
    76         _printf_(true,"Ll2xy - lat/long to x/y coordinate transformation module:\n");
    77         _printf_(true,"\n");
    78         _printf_(true,"   This module transforms lat/long to x/y coordinates.\n");
    79         _printf_(true,"\n");
    80         _printf_(true,"   Usage:\n");
    81         _printf_(true,"      [x,y]=Ll2xy(lat,lon,sgn,'param name',param,...);\n");
    82         _printf_(true,"\n");
    83         _printf_(true,"      lat         latitude coordinates (double vector)\n");
    84         _printf_(true,"      lon         longitude coordinates (double vector)\n");
    85         _printf_(true,"      sgn         sign for hemisphere (double, +1 (north) or -1 (south))\n");
    86         _printf_(true,"\n");
    87         _printf_(true,"      central_meridian     central meridian (double, optional, but must specify with sp)\n");
    88         _printf_(true,"      standard_parallel    standard parallel (double, optional, but must specify with cm)\n");
    89         _printf_(true,"\n");
    90         _printf_(true,"      x           x coordinates (double vector)\n");
    91         _printf_(true,"      y           y coordinates (double vector)\n");
    92         _printf_(true,"\n");
    93         _printf_(true,"   Examples:\n");
    94         _printf_(true,"      [x,y]=Ll2xy(lat,lon, 1);\n");
    95         _printf_(true,"      [x,y]=Ll2xy(lat,lon, 1,'central_meridian',45,'standard_parallel',70);\n");
    96         _printf_(true,"      [x,y]=Ll2xy(lat,lon,-1,'central_meridian', 0,'standard_parallel',71);\n");
    97         _printf_(true,"\n");
     76        _pprintLine_("Ll2xy - lat/long to x/y coordinate transformation module:");
     77        _pprintLine_("");
     78        _pprintLine_("   This module transforms lat/long to x/y coordinates.");
     79        _pprintLine_("");
     80        _pprintLine_("   Usage:");
     81        _pprintLine_("      [x,y]=Ll2xy(lat,lon,sgn,'param name',param,...);");
     82        _pprintLine_("");
     83        _pprintLine_("      lat         latitude coordinates (double vector)");
     84        _pprintLine_("      lon         longitude coordinates (double vector)");
     85        _pprintLine_("      sgn         sign for hemisphere (double, +1 (north) or -1 (south))");
     86        _pprintLine_("");
     87        _pprintLine_("      central_meridian     central meridian (double, optional, but must specify with sp)");
     88        _pprintLine_("      standard_parallel    standard parallel (double, optional, but must specify with cm)");
     89        _pprintLine_("");
     90        _pprintLine_("      x           x coordinates (double vector)");
     91        _pprintLine_("      y           y coordinates (double vector)");
     92        _pprintLine_("");
     93        _pprintLine_("   Examples:");
     94        _pprintLine_("      [x,y]=Ll2xy(lat,lon, 1);");
     95        _pprintLine_("      [x,y]=Ll2xy(lat,lon, 1,'central_meridian',45,'standard_parallel',70);");
     96        _pprintLine_("      [x,y]=Ll2xy(lat,lon,-1,'central_meridian', 0,'standard_parallel',71);");
     97        _pprintLine_("");
    9898}
  • issm/trunk/src/modules/MeshPartition/MeshPartition.cpp

    r12331 r12706  
    9696
    9797void MeshPartitionUsage(void){
    98         printf("   usage:\n");
    99         printf("   [element_partitioning,node_partitioning]=MeshPartition(md.mesh,numpartitions)");
    100         printf("   where:\n");
    101         printf("      element_partitioning is a vector of partitioning area numbers, for every element.\n");
    102         printf("      node_partitioning is a vector of partitioning area numbers, for every node.\n");
    103         printf("\n");
     98        _printLine_("   usage:");
     99        _printString_("   [element_partitioning,node_partitioning]=MeshPartition(md.mesh,numpartitions)");
     100        _printLine_("   where:");
     101        _printLine_("      element_partitioning is a vector of partitioning area numbers, for every element.");
     102        _printLine_("      node_partitioning is a vector of partitioning area numbers, for every node.");
     103        _printLine_("");
    104104}
  • issm/trunk/src/modules/MeshProfileIntersection/MeshProfileIntersection.cpp

    r12331 r12706  
    5454        //index
    5555        FetchData(&double_index,&nel,&dummy,INDEX);
    56         if(dummy!=3 && dummy!=6)_error_(" element triangulation should be of 3 or 6 column width!");
     56        if(dummy!=3 && dummy!=6)_error2_("element triangulation should be of 3 or 6 column width!");
    5757        index=(int*)xmalloc(nel*3*sizeof(int));
    5858        for(i=0;i<nel;i++){
     
    8181        /* Debugging of contours :{{{1*/
    8282        /*for(i=0;i<numcontours;i++){
    83                 printf("\nContour echo: contour number  %i / %i\n",i+1,numcontours);
     83                _printLine_("\nContour echo: contour number  " << i+1 << " / " << numcontours);
    8484                contouri=*(contours+i);
    85                 printf("   Number of vertices %i\n",contouri->nods);
     85                _printLine_("   Number of vertices " << contouri->nods);
    8686                for (j=0;j<contouri->nods;j++){
    87                         printf("   %lf %lf\n",*(contouri->x+j),*(contouri->y+j));
     87                        _printLine_("   " << *(contouri->x+j) << "f " << *(contouri->y+j) << "f");
    8888                }
    8989        }*/
     
    102102
    103103void MeshProfileIntersectionUsage(void){
    104         printf("   usage:\n");
    105         printf("   [segments]=MeshProfileIntersection(index,x,y,filename);\n");
    106         printf("   where:\n");
    107         printf("   input:\n");
    108         printf("        index,x,y is a triangulation\n");
    109         printf("        filename: name of Argus style .exp file containing the segments (can be groups of disconnected segments)\n");
    110         printf("   output:\n");
    111         printf("        segments: array made of x1,y1,x2,y2,element_id lines (x1,y1) and (x2,y2) are segment extremitis for a segment \n");
    112         printf("        belonging to the elemnt_id element. there are as many lines in segments as there are segments intersecting the \n");
    113         printf("        mesh.\n");
     104        _printLine_("   usage:");
     105        _printLine_("   [segments]=MeshProfileIntersection(index,x,y,filename);");
     106        _printLine_("   where:");
     107        _printLine_("   input:");
     108        _printLine_("        index,x,y is a triangulation");
     109        _printLine_("        filename: name of Argus style .exp file containing the segments (can be groups of disconnected segments)");
     110        _printLine_("   output:");
     111        _printLine_("        segments: array made of x1,y1,x2,y2,element_id lines (x1,y1) and (x2,y2) are segment extremitis for a segment ");
     112        _printLine_("        belonging to the elemnt_id element. there are as many lines in segments as there are segments intersecting the ");
     113        _printLine_("        mesh.");
    114114}
  • issm/trunk/src/modules/NodeConnectivity/NodeConnectivity.cpp

    r12331 r12706  
    3737
    3838void NodeConnectivityUsage(void) {
    39         _printf_(true,"\n");
    40         _printf_(true,"   usage: connectivity = %s(elements, numnodes);\n",__FUNCT__);
    41         _printf_(true,"\n");
     39        _pprintLine_("");
     40        _pprintLine_("   usage: connectivity = " << __FUNCT__ << "(elements, numnodes);");
     41        _pprintLine_("");
    4242}
  • issm/trunk/src/modules/PointCloudFindNeighbors/PointCloudFindNeighbors.cpp

    r12331 r12706  
    4242
    4343void PointCloudFindNeighborsUsage(void){
    44         printf("   usage:\n");
    45         printf("   [flags]=PointCloudFindNeighbors(x,y,mindistance,multithread);\n\n");
    46         printf("   where:\n");
    47         printf("      x,y: list of points.\n");
    48         printf("      mindistance: minimum distance that should exist between points in the cloud.\n");
    49         printf("      multithread: run multithreaded or not. with multithreads, flags can get 1 and 2 values in duplicates.\n");
    50         printf("      flags: array of flags (flag==1 means point is within mindistance of another point)\n");
    51         printf("\n");
     44        _printLine_("   usage:");
     45        _printLine_("   [flags]=PointCloudFindNeighbors(x,y,mindistance,multithread);\n");
     46        _printLine_("   where:");
     47        _printLine_("      x,y: list of points.");
     48        _printLine_("      mindistance: minimum distance that should exist between points in the cloud.");
     49        _printLine_("      multithread: run multithreaded or not. with multithreads, flags can get 1 and 2 values in duplicates.");
     50        _printLine_("      flags: array of flags (flag==1 means point is within mindistance of another point)");
     51        _printLine_("");
    5252}
  • issm/trunk/src/modules/PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.cpp

    r12331 r12706  
    4242
    4343void PropagateFlagsFromConnectivityUsage(void) {
    44         printf("\n");
    45         printf("   usage: [pool] = %s(connectivity,pool,index,flags);\n",__FUNCT__);
    46         printf("\n");
     44        _printLine_("");
     45        _printLine_("   usage: [pool] = " << __FUNCT__ << "(connectivity,pool,index,flags);");;
     46        _printLine_("");
    4747}
  • issm/trunk/src/modules/Scotch/Scotch.cpp

    r12331 r12706  
    2525
    2626#ifndef _HAVE_SCOTCH_ //only works if scotch library has been compiled in.
    27         _error_(" Scotch not available! Cannot carry out Scotch partitioning!");
     27        _error2_("Scotch not available! Cannot carry out Scotch partitioning!");
    2828        #else
    2929
  • issm/trunk/src/modules/Shp2Kml/Shp2Kml.cpp

    r12331 r12706  
    2525
    2626        #ifndef _HAVE_SHAPELIB_ //only works if shapelib library has been compiled in.
    27         _error_(" Shapelib not available! Cannot carry out shp file translation!");
     27        _error2_("Shapelib not available! Cannot carry out shp file translation!");
    2828        #endif
    2929
     
    3333        /*checks on arguments on the matlab side: */
    3434        if (nlhs > NLHS) {
    35                 Shp2KmlUsage(); _error_("Shp2Kml usage error");
     35                Shp2KmlUsage(); _error2_("Shp2Kml usage error");
    3636        }
    3737        if (nrhs < NRHS) {
    38                 Shp2KmlUsage(); _error_("Shp2Kml usage error");
     38                Shp2KmlUsage(); _error2_("Shp2Kml usage error");
    3939        }
    4040
     
    4848        if (options->GetOption("central_meridian") || options->GetOption("standard_parallel")) {
    4949                options->Get(&cm,"central_meridian");
    50                 if (verbose) printf("  cm=%g\n",cm);
     50                if (verbose) _printLine_("  cm=" << cm);
    5151                options->Get(&sp,"standard_parallel");
    52                 if (verbose) printf("  sp=%g\n",sp);
     52                if (verbose) _printLine_("  sp=" << sp);
    5353        }
    5454
    5555        /*some checks*/
    56         if (sgn < -1 || sgn > +1) _error_("Hemisphere sgn=%d must be +1 (north), -1 (south), or 0 (no translation).",sgn);
    57         if (fabs(cm)      > 180.) _error_("Central meridian cm=%g must be between -180 (west) and +180 (east) degrees.",cm);
    58         if (sp < 0. || sp >  90.) _error_("Standard parallel sp=%g must be between 0 and 90 degrees (in specified hemisphere).",sp);
     56        if (sgn < -1 || sgn > +1) _error2_("Hemisphere sgn=" << sgn << " must be +1 (north), -1 (south), or 0 (no translation).");
     57        if (fabs(cm)      > 180.) _error2_("Central meridian cm=" << cm << " must be between -180 (west) and +180 (east) degrees.");
     58        if (sp < 0. || sp >  90.) _error2_("Standard parallel sp=" << sp << " must be between 0 and 90 degrees (in specified hemisphere).");
    5959
    6060        /* Run core computations: */
     
    7777
    7878void Shp2KmlUsage(void){
    79         _printf_(true,"Shp2Kml - shp to kml file conversion module:\n");
    80         _printf_(true,"\n");
    81         _printf_(true,"   This module converts a file from shp to kml format.\n");
    82         _printf_(true,"\n");
    83         _printf_(true,"   Usage:\n");
    84         _printf_(true,"      [ret]=Shp2Kml(filshp,filkml,sgn,'param name',param,...);\n");
    85         _printf_(true,"\n");
    86         _printf_(true,"      filshp      file name of shp file to be read (char, extension optional)\n");
    87         _printf_(true,"      filkml      file name of kml file to be written (char)\n");
    88         _printf_(true,"      sgn         sign for hemisphere (double, +1 (north); -1 (south); or 0 (no translation))\n");
    89         _printf_(true,"\n");
    90         _printf_(true,"      central_meridian     central meridian (double, optional, but must specify with sp)\n");
    91         _printf_(true,"      standard_parallel    standard parallel (double, optional, but must specify with cm)\n");
    92         _printf_(true,"\n");
    93         _printf_(true,"      ret         return code (non-zero for warning)\n");
    94         _printf_(true,"\n");
    95         _printf_(true,"   Examples:\n");
    96         _printf_(true,"      [ret]=Shp2Kml('file.shp','file.kml', 0);\n");
    97         _printf_(true,"      [ret]=Shp2Kml('file.shp','file.kml', 1,'central_meridian',45,'standard_parallel',70);\n");
    98         _printf_(true,"      [ret]=Shp2Kml('file.shp','file.kml',-1,'central_meridian', 0,'standard_parallel',71);\n");
    99         _printf_(true,"\n");
     79        _pprintLine_("Shp2Kml - shp to kml file conversion module:");
     80        _pprintLine_("");
     81        _pprintLine_("   This module converts a file from shp to kml format.");
     82        _pprintLine_("");
     83        _pprintLine_("   Usage:");
     84        _pprintLine_("      [ret]=Shp2Kml(filshp,filkml,sgn,'param name',param,...);");
     85        _pprintLine_("");
     86        _pprintLine_("      filshp      file name of shp file to be read (char, extension optional)");
     87        _pprintLine_("      filkml      file name of kml file to be written (char)");
     88        _pprintLine_("      sgn         sign for hemisphere (double, +1 (north); -1 (south); or 0 (no translation))");
     89        _pprintLine_("");
     90        _pprintLine_("      central_meridian     central meridian (double, optional, but must specify with sp)");
     91        _pprintLine_("      standard_parallel    standard parallel (double, optional, but must specify with cm)");
     92        _pprintLine_("");
     93        _pprintLine_("      ret         return code (non-zero for warning)");
     94        _pprintLine_("");
     95        _pprintLine_("   Examples:");
     96        _pprintLine_("      [ret]=Shp2Kml('file.shp','file.kml', 0);");
     97        _pprintLine_("      [ret]=Shp2Kml('file.shp','file.kml', 1,'central_meridian',45,'standard_parallel',70);");
     98        _pprintLine_("      [ret]=Shp2Kml('file.shp','file.kml',-1,'central_meridian', 0,'standard_parallel',71);");
     99        _pprintLine_("");
    100100}
  • issm/trunk/src/modules/StringToEnum/StringToEnum.cpp

    r12331 r12706  
    1212        /*checks on arguments on the matlab side: */
    1313        if(nrhs!=NRHS){
    14                 StringToEnumUsage(); _error_(" usage. See above");
     14                StringToEnumUsage(); _error2_("usage. See above");
    1515        }
    1616
     
    2727void StringToEnumUsage(void)
    2828{
    29         _printf_(true,"\n");
    30         _printf_(true,"   usage: %senum = StringToEnum(string);\n",__FUNCT__);
    31         _printf_(true,"\n");
     29        _pprintLine_("");
     30        _pprintLine_("   usage: " << __FUNCT__ << "enum = StringToEnum(string);");
     31        _pprintLine_("");
    3232}
  • issm/trunk/src/modules/TriMesh/TriMesh.cpp

    r12331 r12706  
    6363void TriMeshUsage(void) //{{{1
    6464{
    65         printf("\n");
    66         printf("   usage: [index,x,y,segments,segmentmarkers]=TriMesh(domainoutlinefilename,rifts,area) \n");
    67         printf("      where: index,x,y defines a triangulation, segments is an array made \n");
    68         printf("      of exterior segments to the mesh domain outline, segmentmarkers is an array flagging each segment, \n");
    69         printf("      outlinefilename an Argus domain outline file, \n");
    70         printf("      area is the maximum area desired for any element of the resulting mesh, \n");
    71         printf("\n");
     65        _printLine_("");
     66        _printLine_("   usage: [index,x,y,segments,segmentmarkers]=TriMesh(domainoutlinefilename,rifts,area) ");
     67        _printLine_("      where: index,x,y defines a triangulation, segments is an array made ");
     68        _printLine_("      of exterior segments to the mesh domain outline, segmentmarkers is an array flagging each segment, ");
     69        _printLine_("      outlinefilename an Argus domain outline file, ");
     70        _printLine_("      area is the maximum area desired for any element of the resulting mesh, ");
     71        _printLine_("");
    7272}
    7373//}}}
  • issm/trunk/src/modules/TriMeshProcessRifts/TriMeshProcessRifts.cpp

    r12331 r12706  
    6666                mexPrintf("   %s format error.\n", __FUNCT__);
    6767                TriMeshProcessRiftsUsage();
    68                 printf("   ");
    69                 mexErrMsgTxt(" ");
     68                _error_("bad usage");
    7069        }
    7170
     
    8281        }
    8382        else{
    84                 printf("%s%s\n",__FUNCT__," error message: first argument should be the element list!");
    85                 mexErrMsgTxt(" ");
     83                _error_("first argument should be the element list");
    8684        }
    8785
     
    9694        }
    9795        else{
    98                 printf("%s%s\n",__FUNCT__," error message: second argument should be the x corrdinate list!");
    99                 mexErrMsgTxt(" ");
     96                _error_("second argument should be the x corrdinate list");
    10097        }
    10198
     
    109106        }
    110107        else{
    111                 printf("%s%s\n",__FUNCT__," error message: third argument should be the y corrdinate list!");
    112                 mexErrMsgTxt(" ");
     108                _error_("third argument should be the y corrdinate list");
    113109        }       
    114110
     
    125121        }
    126122        else{
    127                 printf("%s%s\n",__FUNCT__," error message: fourth argument should be the segments list!");
    128                 mexErrMsgTxt(" ");
     123                _error_("fourth argument should be the segments list");
    129124        }
    130125
     
    138133        }
    139134        else{
    140                 printf("%s%s\n",__FUNCT__," error message: fourth argument should be the segmentmarkers list!");
    141                 mexErrMsgTxt(" ");
    142         }
    143 
    144         /*
    145         printf("Index: \n");
    146         for (i=0;i<nel;i++){
    147                 for(j=0;j<3;j++){
    148                         printf("%lf ",*(index_in+3*i+j));
    149                 }
    150                 printf("\n");
    151         }
    152         printf("x,y: \n");
    153         for (i=0;i<nods;i++){
    154                 printf("%16.16lf %16.16lf\n",x_in[i],y_in[i]);
    155         }
    156         printf("segments:\n");
    157         for (i=0;i<num_seg;i++){
    158                 for(j=0;j<3;j++){
    159                         printf("%lf ",*(segments_in+3*i+j));
    160                 }
    161                 printf("%lf ",segmentmarkers_in[i]);
    162                 printf("\n");
    163         }
    164         */
     135                _error_("fourth argument should be the segmentmarkers list");
     136        }
    165137
    166138        /*First, do some fixing on the existing mesh: we do not want any element belonging entirely to the segment list (ie:
     
    325297void TriMeshProcessRiftsUsage(void)
    326298{
    327         printf("\n");
    328         printf("   usage: [index2,x2,y2,segments2,segmentmarkers2,rifts2]=TriMeshProcessrifts(index1,x1,y1,segments1,segmentmarkers1) \n");
    329         printf("      where: (index1,x1,y1,segments1,segmentmarkers1) is an initial triangulation.\n");
    330         printf("      index2,x2,y2,segments2,segmentmarkers2,rifts2 is the resulting triangulation where rifts have been processed.\n");
     299        _printLine_("");
     300        _printLine_("   usage: [index2,x2,y2,segments2,segmentmarkers2,rifts2]=TriMeshProcessrifts(index1,x1,y1,segments1,segmentmarkers1) ");
     301        _printLine_("      where: (index1,x1,y1,segments1,segmentmarkers1) is an initial triangulation.");
     302        _printLine_("      index2,x2,y2,segments2,segmentmarkers2,rifts2 is the resulting triangulation where rifts have been processed.");
    331303}
  • issm/trunk/src/modules/TriaSearch/TriaSearch.cpp

    r12331 r12706  
    99
    1010        /*input: */
    11         double* index=NULL;
     11        int*    index=NULL;
    1212        int     nel;
    1313        int     dummy;
     
    3737        FetchData(&y0,&numberofnodes,Y0HANDLE);
    3838
    39         /* Echo: {{{1*/
    40         //printf("(x0,y0)=(%g,%g)\n",x0,y0);
    41         /*}}}*/
    42 
    4339        /* Run core computations: */
    4440        TriaSearchx(&tria,index,nel,x,y,nods,x0,y0,numberofnodes);
     
    5450}
    5551
    56 void TriaSearchUsage(void)
    57 {
    58         _printf_(true,"TriaSearch- find triangle holding a point (x0,y0) in a mesh\n");
    59         _printf_(true,"\n");
    60         _printf_(true,"   Usage:\n");
    61         _printf_(true,"         tria=TriaSearch(index,x,y,x0,y0);\n");
    62         _printf_(true,"      index,x,y: mesh triangulatrion\n");
    63         _printf_(true,"      x0,y0: coordinates of the point for which we are trying to find a triangle\n");
    64         _printf_(true,"      x0,y0 can be an array of points\n");
    65         _printf_(true,"\n");
     52void TriaSearchUsage(void){
     53        _pprintLine_("TriaSearch- find triangle holding a point (x0,y0) in a mesh");
     54        _pprintLine_("");
     55        _pprintLine_("   Usage:");
     56        _pprintLine_("         tria=TriaSearch(index,x,y,x0,y0);");
     57        _pprintLine_("      index,x,y: mesh triangulatrion");
     58        _pprintLine_("      x0,y0: coordinates of the point for which we are trying to find a triangle");
     59        _pprintLine_("      x0,y0 can be an array of points");
     60        _pprintLine_("");
    6661}
  • issm/trunk/src/modules/Xy2ll/Xy2ll.cpp

    r12331 r12706  
    2424        /*checks on arguments on the matlab side: */
    2525        if (nlhs > NLHS) {
    26                 Xy2llUsage(); _error_("Xy2ll usage error");
     26                Xy2llUsage(); _error2_("Xy2ll usage error");
    2727        }
    2828        if (nrhs < NRHS) {
    29                 Xy2llUsage(); _error_("Xy2ll usage error");
     29                Xy2llUsage(); _error2_("Xy2ll usage error");
    3030        }
    3131
     
    3939        if (options->GetOption("central_meridian") || options->GetOption("standard_parallel")) {
    4040                options->Get(&cm,"central_meridian");
    41                 if (verbose) printf("  cm=%g\n",cm);
     41                if (verbose) _printLine_("  cm=" << cm);
    4242                options->Get(&sp,"standard_parallel");
    43                 if (verbose) printf("  sp=%g\n",sp);
     43                if (verbose) _printLine_("  sp=" << sp);
    4444        }
    4545
    4646        /*some checks*/
    47         if   (nx != ny) _error_("Must have same number of x[%d] and y[%d] coordinates.",nx,ny);
     47        if   (nx != ny){_error2_("Must have same number of x[" << nx << "] and y[" << ny << "] coordinates.");}
    4848        else            ncoord=nx;
    49         if (sgn != +1 && sgn != -1) _error_("Hemisphere sgn=%d must be +1 (north) or -1 (south).",sgn);
    50         if (fabs(cm)      > 180.) _error_("Central meridian cm=%g must be between -180 (west) and +180 (east) degrees.",cm);
    51         if (sp < 0. || sp >  90.) _error_("Standard parallel sp=%g must be between 0 and 90 degrees (in specified hemisphere).",sp);
     49        if (sgn != +1 && sgn != -1) _error2_("Hemisphere sgn=" << sgn << " must be +1 (north) or -1 (south).");
     50        if (fabs(cm)      > 180.) _error2_("Central meridian cm=" << cm << " must be between -180 (west) and +180 (east) degrees.");
     51        if (sp < 0. || sp >  90.) _error2_("Standard parallel sp=" << sp << " must be between 0 and 90 degrees (in specified hemisphere).");
    5252
    5353        lat=(double*)mxMalloc(ncoord*sizeof(double));
     
    5555
    5656        /* Run core computations: */
    57         if (verbose) printf("Calling core:\n");
     57        if (verbose) _printLine_("Calling core:");
    5858        if (options->GetOption("central_meridian") && options->GetOption("standard_parallel"))
    5959                iret=Xy2llx(lat,lon,x,y,ncoord,sgn,cm,sp);
     
    7373
    7474void Xy2llUsage(void){
    75         _printf_(true,"Xy2ll - x/y to lat/long coordinate transformation module:\n");
    76         _printf_(true,"\n");
    77         _printf_(true,"   This module transforms x/y to lat/long coordinates.\n");
    78         _printf_(true,"\n");
    79         _printf_(true,"   Usage:\n");
    80         _printf_(true,"      [lat,lon]=Xy2ll(x,y,sgn,'param name',param,...);\n");
    81         _printf_(true,"\n");
    82         _printf_(true,"      x           x coordinates (double vector)\n");
    83         _printf_(true,"      y           y coordinates (double vector)\n");
    84         _printf_(true,"      sgn         sign for hemisphere (double, +1 (north) or -1 (south))\n");
    85         _printf_(true,"\n");
    86         _printf_(true,"      central_meridian     central meridian (double, optional, but must specify with sp)\n");
    87         _printf_(true,"      standard_parallel    standard parallel (double, optional, but must specify with cm)\n");
    88         _printf_(true,"\n");
    89         _printf_(true,"      lat         latitude coordinates (double vector)\n");
    90         _printf_(true,"      lon         longitude coordinates (double vector)\n");
    91         _printf_(true,"\n");
    92         _printf_(true,"   Examples:\n");
    93         _printf_(true,"      [lat,lon]=Xy2ll(x,y, 1);\n");
    94         _printf_(true,"      [lat,lon]=Xy2ll(x,y, 1,'central_meridian',45,'standard_parallel',70);\n");
    95         _printf_(true,"      [lat,lon]=Xy2ll(x,y,-1,'central_meridian', 0,'standard_parallel',71);\n");
    96         _printf_(true,"\n");
     75        _pprintLine_("Xy2ll - x/y to lat/long coordinate transformation module:");
     76        _pprintLine_("");
     77        _pprintLine_("   This module transforms x/y to lat/long coordinates.");
     78        _pprintLine_("");
     79        _pprintLine_("   Usage:");
     80        _pprintLine_("      [lat,lon]=Xy2ll(x,y,sgn,'param name',param,...);");
     81        _pprintLine_("");
     82        _pprintLine_("      x           x coordinates (double vector)");
     83        _pprintLine_("      y           y coordinates (double vector)");
     84        _pprintLine_("      sgn         sign for hemisphere (double, +1 (north) or -1 (south))");
     85        _pprintLine_("");
     86        _pprintLine_("      central_meridian     central meridian (double, optional, but must specify with sp)");
     87        _pprintLine_("      standard_parallel    standard parallel (double, optional, but must specify with cm)");
     88        _pprintLine_("");
     89        _pprintLine_("      lat         latitude coordinates (double vector)");
     90        _pprintLine_("      lon         longitude coordinates (double vector)");
     91        _pprintLine_("");
     92        _pprintLine_("   Examples:");
     93        _pprintLine_("      [lat,lon]=Xy2ll(x,y, 1);");
     94        _pprintLine_("      [lat,lon]=Xy2ll(x,y, 1,'central_meridian',45,'standard_parallel',70);");
     95        _pprintLine_("      [lat,lon]=Xy2ll(x,y,-1,'central_meridian', 0,'standard_parallel',71);");
     96        _pprintLine_("");
    9797}
    9898
  • issm/trunk/src/modules/matlab/Makefile.am

    r12331 r12706  
    1 INCLUDES = @MATLABINCL@ @PETSCINCL@ @MPIINCL@ @METISINCL@ @TRIANGLEINCL@ @CHACOINCL@ @SCOTCHINCL@ @SHAPELIBINCL@ @BOOSTINCL@ @PYTHONINCL@ @PYTHON_NUMPYINCL@
     1INCLUDES = @MATLABINCL@ @PETSCINCL@ @MPIINCL@ @SPOOLESINCL@ @METISINCL@ @TRIANGLEINCL@ @CHACOINCL@ @SCOTCHINCL@ @SHAPELIBINCL@ @BOOSTINCL@ @PYTHONINCL@ @PYTHON_NUMPYINCL@
    22EXEEXT=$(MATLABWRAPPEREXT)
    33#Bin programs {{{1
     
    4141#}}}
    4242#Flags and libraries {{{1
    43 LDADD = ../../c/libISSMCore.a ../../c/libISSMModules.a $(TRIANGLELIB) $(PETSCLIB) $(FLIBS) $(PLAPACKLIB) $(MUMPSLIB) $(SCALAPACKLIB) $(BLACSLIB) $(HYPRELIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(SHAPELIBLIB) $(GSLLIB)
     43LDADD = ../../c/libISSMCore.a ../../c/libISSMModules.a $(TRIANGLELIB) $(PETSCLIB) $(FLIBS) $(PLAPACKLIB) $(SPOOLESLIB) $(MUMPSLIB) $(SUPERLULIB) $(SPAILIB) $(PROMETHEUSLIB) $(PASTIXLIB) $(SCALAPACKLIB) $(BLACSLIB) $(HYPRELIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(SHAPELIBLIB) $(GSLLIB)
    4444
    4545#Triangle library
     
    5050AM_CXXFLAGS +=  -D_HAVE_MATLAB_MODULES_ -D_GNU_SOURCE -fPIC -fno-omit-frame-pointer -pthread
    5151LDADD       += $(MEXLIB) ../../c/libISSMMatlab.a
    52 
    53 LDADD       += ../../c/libISSMCore.a ../../c/libISSMModules.a
     52LDADD       += ../../c/libISSMCore.a
     53if CIRCULAR_DEPENDENCIES
     54LDADD       += $(TRIANGLELIB) $(PETSCLIB) $(FLIBS) $(PLAPACKLIB) $(SPOOLESLIB) $(MUMPSLIB) $(SUPERLULIB) $(SPAILIB) $(PROMETHEUSLIB) $(PASTIXLIB) $(SCALAPACKLIB) $(BLACSLIB) $(HYPRELIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(SHAPELIBLIB) $(GSLLIB)
     55endif
     56LDADD       += ../../c/libISSMModules.a
    5457
    5558#Optimization flags:
  • issm/trunk/src/modules/python/Makefile.am

    r12331 r12706  
    1717#Python part
    1818AM_LDFLAGS   = $(PYTHONLINK)
    19 AM_CXXFLAGS +=  -D_HAVE_PYTHON_MODULES_
     19AM_CXXFLAGS +=  -D_HAVE_PYTHON_MODULES_  -fPIC
    2020if PYTHON3
    2121AM_CXXFLAGS +=  -DNPY_NO_DEPRECATED_API
Note: See TracChangeset for help on using the changeset viewer.