Changeset 8913


Ignore:
Timestamp:
07/11/11 17:01:58 (14 years ago)
Author:
Eric.Larour
Message:

FetchData not needed anymore, folded into IoModelFetchData

Location:
issm/trunk/src/c
Files:
1 deleted
3 edited

Legend:

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

    r8910 r8913  
    406406                                        ./io/Disk/pfopen.cpp\
    407407                                        ./io/Disk/pfclose.cpp\
    408                                         ./io/Disk/FetchData.cpp\
    409408                                        ./io/Matlab/matlabio.h\
    410409                                        ./io/Matlab/WriteMatlabData.cpp\
     
    10801079                                        ./io/Disk/pfopen.cpp\
    10811080                                        ./io/Disk/pfclose.cpp\
    1082                                         ./io/Disk/FetchData.cpp\
    10831081                                        ./io/Matlab/matlabio.h\
    10841082                                        ./io/Matlab/WriteMatlabData.cpp\
  • issm/trunk/src/c/io/Disk/IoModelFetchData.cpp

    r8910 r8913  
    1515/*FUNCTION IoModelFetchData(double** pmatrix,int* pM,int* pN,FILE* model_handle,char* data_name){{{1*/
    1616void  IoModelFetchData(double** pmatrix,int* pM,int* pN,FILE* model_handle,char* data_name){
     17
     18        extern int my_rank;
     19        extern int num_procs;
     20
     21        /*output: */
     22        int M,N;
     23        double* matrix=NULL;
    1724       
    1825        FILE* fid=NULL;
     
    2229       
    2330        /*Now fetch: */
    24         FetchData(pmatrix,pM,pN,fid);
     31
     32        /*We have to read a matrix from disk. First read the dimensions of the matrix, then the whole matrix: */
     33        /*numberofelements: */
     34        if(my_rank==0){ 
     35                if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix ");
     36        }
     37
     38        MPI_Bcast(&M,1,MPI_INT,0,MPI_COMM_WORLD);
     39
     40        if(my_rank==0){ 
     41                if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix ");
     42        }
     43        MPI_Bcast(&N,1,MPI_INT,0,MPI_COMM_WORLD);
     44
     45        /*Now allocate matrix: */
     46        if(M*N){
     47                matrix=(double*)xmalloc(M*N*sizeof(double));
     48
     49                /*Read matrix on node 0, then broadcast: */
     50                if(my_rank==0){ 
     51                        if(fread(matrix,M*N*sizeof(double),1,fid)!=1) _error_("could not read matrix ");
     52                }
     53               
     54                MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,MPI_COMM_WORLD);
     55        }
     56
     57        /*Assign output pointers: */
     58        *pmatrix=matrix;
     59        if (pM)*pM=M;
     60        if (pN)*pN=N;
    2561
    2662}
     
    2965void  IoModelFetchData(char** pstring,FILE* model_handle,char* data_name){
    3066
    31         FILE* fid=NULL;
     67        extern int my_rank;
     68        extern int num_procs;
     69        FILE* fid=NULL;
     70
     71        /*output: */
     72        char* string=NULL;
     73        int   string_size;
    3274       
    3375        /*Set file pointer to beginning of the data: */
     
    3577       
    3678        /*Now fetch: */
    37         FetchData(pstring,fid);
     79       
     80        /*We have to read a string from disk. First read the dimensions of the string, then the string: */
     81        if(my_rank==0){ 
     82                if(fread(&string_size,sizeof(int),1,fid)!=1) _error_(" could not read length of string ");
     83        }
     84
     85        MPI_Bcast(&string_size,1,MPI_INT,0,MPI_COMM_WORLD);
     86
     87        /*Now allocate string: */
     88        if(string_size){
     89                string=(char*)xmalloc((string_size+1)*sizeof(char));
     90                string[string_size]='\0';
     91
     92                /*Read string on node 0, then broadcast: */
     93                if(my_rank==0){ 
     94                        if(fread(string,string_size*sizeof(char),1,fid)!=1)_error_("  could not read string ");
     95                }
     96                MPI_Bcast(string,string_size,MPI_CHAR,0,MPI_COMM_WORLD);
     97        }
     98        else{
     99                string=(char*)xmalloc(sizeof(char));
     100                string[0]='\0';
     101        }
     102
     103
     104        /*Assign output pointers: */
     105        *pstring=string;
    38106}
    39107/*}}}*/
     
    41109void  IoModelFetchData(double* pscalar,FILE* model_handle,char* data_name){
    42110
    43         FILE* fid=NULL;
    44        
    45         /*Set file pointer to beginning of the data: */
    46         fid=SetFilePointerToData(model_handle,data_name);
    47        
    48         /*Now fetch: */
    49         FetchData(pscalar,fid);
     111
     112        extern int my_rank;
     113        extern int num_procs;
     114        FILE* fid=NULL;
     115
     116        /*output: */
     117        double   scalar;
     118       
     119        /*Set file pointer to beginning of the data: */
     120        fid=SetFilePointerToData(model_handle,data_name);
     121       
     122        /*We have to read a scalar from disk. First read the dimensions of the scalar, then the scalar: */
     123        if(my_rank==0){
     124                if(fread(&scalar,sizeof(double),1,fid)!=1)_error_(" could not read scalar ");
     125        }
     126        MPI_Bcast(&scalar,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
     127
     128        /*Assign output pointers: */
     129        *pscalar=scalar;
     130                 
    50131}
    51132/*}}}*/
     
    53134void  IoModelFetchData(int* pinteger,FILE* model_handle,char* data_name){
    54135
    55         FILE* fid=NULL;
    56        
    57         /*Set file pointer to beginning of the data: */
    58         fid=SetFilePointerToData(model_handle,data_name);
    59        
    60         /*Now fetch: */
    61         FetchData(pinteger,fid);
     136        extern int my_rank;
     137        extern int num_procs;
     138        FILE* fid=NULL;
     139
     140        /*output: */
     141        int   integer;
     142       
     143        /*Set file pointer to beginning of the data: */
     144        fid=SetFilePointerToData(model_handle,data_name);
     145       
     146        /*We have to read a integer from disk. First read the dimensions of the integer, then the integer: */
     147        if(my_rank==0){ 
     148                if(fread(&integer,sizeof(int),1,fid)!=1) _error_(" could not read integer ");
     149        }
     150
     151        MPI_Bcast(&integer,1,MPI_INT,0,MPI_COMM_WORLD);
     152
     153        /*Assign output pointers: */
     154        *pinteger=integer;
     155
    62156}
    63157/*}}}*/
  • issm/trunk/src/c/io/Disk/diskio.h

    r8910 r8913  
    1616void  pfclose(FILE* fid,char* filename);
    1717
    18 void  FetchData(double** pmatrix, int* pM,int* pN,FILE* fid);
    19 void  FetchData(char** pstring,FILE* fid);
    20 void  FetchData(double* pscalar,FILE* fid);
    21 void  FetchData(int* pinteger,FILE* fid);
    22 
    2318void  IoModelFetchData(double** pmatrix,int* pM,int* pN,FILE* model_handle,char* data_name);
    2419void  IoModelFetchData(char** pstring,FILE* model_handle,char* data_name);
Note: See TracChangeset for help on using the changeset viewer.