Changeset 20977
- Timestamp:
- 07/21/16 15:00:50 (9 years ago)
- Location:
- issm/trunk-jpl/src/c/classes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/IoModel.cpp
r20976 r20977 412 412 413 413 bool autodiff,iscontrol; 414 int num_independent_objects ;414 int num_independent_objects,temp; 415 415 int Xcount=0; 416 416 … … 427 427 this->FetchData(&num_independent_objects,"md.autodiff.num_independent_objects"); 428 428 if(num_independent_objects){ 429 this->FetchData(&names,NULL,"md.autodiff.independent_object_names"); 429 this->FetchData(&names,&temp,"md.autodiff.independent_object_names"); 430 _assert_(temp==num_independent_objects); 430 431 this->FetchData(&types,NULL,NULL,"md.autodiff_independent_object_types"); 431 432 … … 980 981 } 981 982 /*}}}*/ 983 void IoModel::FetchData(char*** pstrings,int* pnumstrings,const char* data_name){/*{{{*/ 984 985 /*output: */ 986 char** strings = NULL; 987 char* string = NULL; 988 int numstrings; 989 int string_size; 990 int code; 991 992 /*recover my_rank:*/ 993 int my_rank=IssmComm::GetRank(); 994 995 /*Set file pointer to beginning of the data: */ 996 fid=this->SetFilePointerToData(&code,NULL,data_name); 997 998 if(code!=9)_error_("expecting a string array for \""<<data_name<<"\""); 999 1000 /*Now fetch: */ 1001 1002 if(my_rank==0){ 1003 if(fread(&numstrings,sizeof(int),1,fid)!=1) _error_("could not read length of string array"); 1004 } 1005 ISSM_MPI_Bcast(&numstrings,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 1006 1007 /*Now allocate string array: */ 1008 if(numstrings){ 1009 strings=xNew<char*>(numstrings); 1010 for(int i=0;i<numstrings;i++) strings[i]=NULL; 1011 1012 /*Go through strings, and read: */ 1013 for(int i=0;i<numstrings;i++){ 1014 1015 if(my_rank==0){ 1016 if(fread(&string_size,sizeof(int),1,fid)!=1) _error_("could not read length of string "); 1017 } 1018 ISSM_MPI_Bcast(&string_size,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 1019 if(string_size){ 1020 string=xNew<char>((string_size+1)); 1021 string[string_size]='\0'; 1022 if(my_rank==0){ 1023 if(fread(string,string_size*sizeof(char),1,fid)!=1)_error_(" could not read string "); 1024 } 1025 ISSM_MPI_Bcast(string,string_size,ISSM_MPI_CHAR,0,IssmComm::GetComm()); 1026 } 1027 else{ 1028 string=xNew<char>(1); 1029 string[0]='\0'; 1030 } 1031 strings[i]=string; 1032 } 1033 } 1034 1035 /*Assign output pointers: */ 1036 *pstrings = strings; 1037 if(pnumstrings) *pnumstrings = numstrings; 1038 } 1039 /*}}}*/ 982 1040 void IoModel::FetchData(int** pmatrix,int* pM,int* pN,const char* data_name){/*{{{*/ 983 1041 int i,j; -
issm/trunk-jpl/src/c/classes/IoModel.h
r20840 r20977 121 121 void FetchData(IssmDouble* pscalar,const char* data_name); 122 122 void FetchData(char** pstring,const char* data_name); 123 void FetchData(char*** pstrings,int* pnumstrings,const char* data_name); 123 124 void FetchData(int** pmatrix,int* pM,int* pN,const char* data_name); 124 125 void FetchData(IssmDouble** pscalarmatrix,int* pM,int* pN,const char* data_name);
Note:
See TracChangeset
for help on using the changeset viewer.