Changeset 24364
- Timestamp:
- 11/19/19 21:26:05 (5 years ago)
- Location:
- issm/trunk-jpl/src/c/classes/Inputs2
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/Inputs2/ArrayInput2.cpp
r24360 r24364 17 17 18 18 this->numberofelements_local = -1; 19 this->N = -1;19 this->N = NULL; 20 20 this->values = NULL; 21 21 22 22 }/*}}}*/ 23 ArrayInput2::ArrayInput2(int nbe_in ,int N_in){/*{{{*/23 ArrayInput2::ArrayInput2(int nbe_in){/*{{{*/ 24 24 25 25 _assert_(nbe_in>0); 26 26 _assert_(nbe_in<1e11); 27 27 this->numberofelements_local = nbe_in; 28 this->N = N_in;29 this->values = xNewZeroInit<IssmDouble >(this->numberofelements_local*this->N);28 this->N = xNewZeroInit<int>(this->numberofelements_local); 29 this->values = xNewZeroInit<IssmDouble*>(this->numberofelements_local); 30 30 31 31 }/*}}}*/ 32 32 ArrayInput2::~ArrayInput2(){/*{{{*/ 33 if(this->values) xDelete<IssmDouble>(this->values); 33 if(this->values){ 34 for(int i=0;i<this->numberofelements_local;i++) if(this->values[i]) xDelete<IssmDouble>(this->values[i]); 35 xDelete<IssmDouble>(this->values); 36 } 37 if(this->N) xDelete<int>(this->N); 34 38 } 35 39 /*}}}*/ … … 38 42 Input2* ArrayInput2::copy() {/*{{{*/ 39 43 40 ArrayInput2* output = new ArrayInput2(this->numberofelements_local,this->N); 41 xMemCpy<IssmDouble>(output->values,this->values,this->numberofelements_local*this->N); 44 ArrayInput2* output = new ArrayInput2(this->numberofelements_local); 45 46 output->N = xNew<int>(this->numberofelements_local); 47 xMemCpy<int>(output->N,this->N,this->numberofelements_local); 48 49 output->values = xNew<IssmDouble*>(this->numberofelements_local); 50 for(int i=0;i<this->numberofelements_local;i++){ 51 if(this->values[i]){ 52 _assert_(this->N[i]>0); 53 output->values[i] = xNew<IssmDouble>(this->N[i]); 54 xMemCpy<IssmDouble>(output->values[i],this->values[i],this->N[i]); 55 } 56 else{ 57 output->values[i] = NULL; 58 } 59 } 42 60 43 61 return output; … … 46 64 void ArrayInput2::DeepEcho(void){/*{{{*/ 47 65 _printf_("ArrayInput2 Echo:\n"); 48 _printf_(" Size: "<<N<<"\n");66 ///_printf_(" Size: "<<N<<"\n"); 49 67 //printarray(this->values,this->M,this->N); 50 68 //_printf_(setw(15)<<" ArrayInput2 "<<setw(25)<<left<<EnumToStringx(this->enum_type)<<" "<<(value?"true":"false") << "\n"); … … 62 80 MARSHALLING_ENUM(ArrayInput2Enum); 63 81 MARSHALLING(this->numberofelements_local); 64 MARSHALLING(this->N); 65 if(this->numberofelements_local*this->N){ 66 MARSHALLING_DYNAMIC(this->values,IssmDouble,this->numberofelements_local*this->N); 82 if(this->numberofelements_local){ 83 MARSHALLING_DYNAMIC(this->N,int,this->numberofelements_local); 84 for(int i=0;i<this->numberofelements_local;i++){ 85 if(this->values[i]){ 86 MARSHALLING_DYNAMIC(this->values[i],IssmDouble,this->N[i]); 87 } 88 } 67 89 } 68 else this->values = NULL; 90 else{ 91 this->N = NULL; 92 this->values = NULL; 93 } 69 94 70 95 } … … 79 104 80 105 _assert_(this); 81 _assert_(this->N==numindices); 82 for(int i=0;i<numindices;i++) this->values[row*this->N+i] = values_in[i]; 106 _assert_(row>=0 && row<this->numberofelements_local); 107 108 if(this->N[row] != numindices){ 109 if(this->values[row]) xDelete<IssmDouble>(this->values[row]); 110 this->values[row] = xNew<IssmDouble>(numindices); 111 } 112 113 IssmDouble *el_values = this->values[row]; 114 for(int i=0;i<numindices;i++) el_values[i] = values_in[i]; 115 116 this->N[row] = numindices; 83 117 } 84 118 /*}}}*/ … … 88 122 _assert_(row>=0 && row<this->numberofelements_local); 89 123 if(pvalues){ 90 IssmDouble* outvalues = xNew<IssmDouble>(this->N );91 xMemCpy<IssmDouble>(outvalues,this->values ,this->N);124 IssmDouble* outvalues = xNew<IssmDouble>(this->N[row]); 125 xMemCpy<IssmDouble>(outvalues,this->values[row],this->N[row]); 92 126 *pvalues = outvalues; 93 127 } 94 128 if(pN){ 95 *pN = this->N ;129 *pN = this->N[row]; 96 130 } 97 131 } -
issm/trunk-jpl/src/c/classes/Inputs2/ArrayInput2.h
r24360 r24364 9 9 private: 10 10 int numberofelements_local; 11 int 12 IssmDouble* values;11 int* N; 12 IssmDouble** values; 13 13 14 14 public: 15 15 /*ArrayInput2 constructors, destructors: {{{*/ 16 16 ArrayInput2(); 17 ArrayInput2(int nbe_in ,int N_in);17 ArrayInput2(int nbe_in); 18 18 ~ArrayInput2(); 19 19 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Inputs2/Inputs2.cpp
r24360 r24364 554 554 555 555 if(recreate){ 556 this->inputs[id] = new ArrayInput2(this->numberofelements_local ,numlayers);556 this->inputs[id] = new ArrayInput2(this->numberofelements_local); 557 557 } 558 558
Note:
See TracChangeset
for help on using the changeset viewer.