Changeset 18871
- Timestamp:
- 11/28/14 09:37:39 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/IndependentObject.cpp
r18064 r18871 70 70 71 71 /*IndependentObject methods: */ 72 void IndependentObject::FetchIndependent(IoModel* iomodel ){/*{{{*/72 void IndependentObject::FetchIndependent(IoModel* iomodel,int* pXcount,IssmPDouble* X){ /*{{{*/ 73 73 74 74 int my_rank; 75 75 FILE* fid=NULL; 76 int Xcount; 76 77 77 78 /*recover my_rank:*/ 78 79 my_rank=IssmComm::GetRank(); 80 81 /*recover Xcount if X is not NULL:*/ 82 if(X)Xcount=*pXcount; 79 83 80 84 #ifdef _HAVE_ADOLC_ //cannot come here unless you are running AD mode, from DeclaredIndependents: … … 98 102 if(fread(&pscalar,sizeof(IssmPDouble),1,fid)!=1)_error_("could not read scalar "); 99 103 100 /*Now, before we even broadcast this to other nodes, declare the scalar as an independent variable!: */ 101 scalar<<=pscalar; 104 /*Now, before we even broadcast this to other nodes, declare the scalar as an independent variable!. If we 105 *have been supplied an X vector, use it instead of what we just read: */ 106 if(X){ 107 scalar<<=X[Xcount]; 108 } 109 else{ 110 scalar<<=pscalar; 111 } 102 112 } 103 113 … … 113 123 iomodel->independents[name]=true; 114 124 125 /*increment offset into X vector, now that we have read 1 value:*/ 126 Xcount++; *pXcount=Xcount; 127 115 128 //finally, record the number of independents: 116 129 this->numberofindependents=1; … … 150 163 if(fread(buffer,M*N*sizeof(IssmPDouble),1,fid)!=1) _error_("could not read matrix "); 151 164 152 /*Now, before we even broadcast this to other nodes, declare the whole matrix as a independent variable!: */ 153 for (int i=0;i<M*N;++i) matrix[i]<<=buffer[i]; /*we use the <<= ADOLC overloaded operator to declare the independency*/ 165 /*Now, before we even broadcast this to other nodes, declare the whole matrix as a independent variable! 166 If we have been supplied an X vector, use it instead of what we just read: */ 167 if(X){ 168 for (int i=0;i<M*N;++i) matrix[i]<<=X[Xcount+i]; /*we use the <<= ADOLC overloaded operator to declare the independency*/ 169 } 170 else{ 171 for (int i=0;i<M*N;++i) matrix[i]<<=buffer[i]; /*we use the <<= ADOLC overloaded operator to declare the independency*/ 172 } 154 173 } 155 174 ISSM_MPI_Bcast(matrix,M*N,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); … … 165 184 iomodel->independents[name]=true; 166 185 186 187 /*increment offset into X vector, now that we have read M*N values:*/ 188 Xcount+=M*N; *pXcount=Xcount; 189 167 190 //Finally, record the number of independents created: 168 191 this->numberofindependents=M*N;
Note:
See TracChangeset
for help on using the changeset viewer.