aux.cpp
void data::read_data(const char *filename)
{
    /* Local variables. */
    FILE *fid;
    char str[1000];
    
    /* Open file and read header. */
    fid=fopen(filename,"r");
    
    fscanf(fid,"%d %lg %d",&nt,&dt,&nrec);
    fgets(str,1000,fid);
    
    /* Read traces. */
    for (int i=0; i<nrec; i++)
    {
        for (int j=0; j<nt; j++) fscanf(fid,"%lg",&(ux[i][j]));
        fgets(str,1000,fid);
        for (int j=0; j<nt; j++) fscanf(fid,"%lg",&(cx[i][j]));
        fgets(str,1000,fid);
        for (int j=0; j<nt; j++) fscanf(fid,"%lg",&(uy[i][j]));
        fgets(str,1000,fid);
        for (int j=0; j<nt; j++) fscanf(fid,"%lg",&(cy[i][j]));
        fgets(str,1000,fid);
        for (int j=0; j<nt; j++) fscanf(fid,"%lg",&(uz[i][j]));
        fgets(str,1000,fid);
        for (int j=0; j<nt; j++) fscanf(fid,"%lg",&(cz[i][j]));
        fgets(str,1000,fid);
    }
    
    /* Clean up. */
    fclose(fid);
}
/* Fill time series by reading data from a file. ----------------------------------*/
Fill time series by reading data from a file.
Fill time series by reading data from a file .
void data::read_data(const char *filename)
{
    FILE *fid;
    char str[1000];
    fid=fopen(filename,"r");
    fscanf(fid,"%d %lg %d",&nt,&dt,&nrec);
    fgets(str,1000,fid);
    for (int i=0; i<nrec; i++)
    {
        for (int j=0; j<nt; j++) fscanf(fid,"%lg",&(ux[i][j]));
        fgets(str,1000,fid);
        for (int j=0; j<nt; j++) fscanf(fid,"%lg",&(cx[i][j]));
        fgets(str,1000,fid);
        for (int j=0; j<nt; j++) fscanf(fid,"%lg",&(uy[i][j]));
        fgets(str,1000,fid);
        for (int j=0; j<nt; j++) fscanf(fid,"%lg",&(cy[i][j]));
        fgets(str,1000,fid);
        for (int j=0; j<nt; j++) fscanf(fid,"%lg",&(uz[i][j]));
        fgets(str,1000,fid);
        for (int j=0; j<nt; j++) fscanf(fid,"%lg",&(cz[i][j]));
        fgets(str,1000,fid);
    }
    fclose(fid);
}
void data :: read_data ( const char * filename ) { FILE * fid ; char str [ 1000 ] ; fid = fopen ( filename , " " ) ; fscanf ( fid , " " , & nt , & dt , & nrec ) ; fgets ( str , 1000 , fid ) ; for ( int i = 0 ; i < nrec ; i ++ ) { for ( int j = 0 ; j < nt ; j ++ ) fscanf ( fid , " " , & ( ux [ i ] [ j ] ) ) ; fgets ( str , 1000 , fid ) ; for ( int j = 0 ; j < nt ; j ++ ) fscanf ( fid , " " , & ( cx [ i ] [ j ] ) ) ; fgets ( str , 1000 , fid ) ; for ( int j = 0 ; j < nt ; j ++ ) fscanf ( fid , " " , & ( uy [ i ] [ j ] ) ) ; fgets ( str , 1000 , fid ) ; for ( int j = 0 ; j < nt ; j ++ ) fscanf ( fid , " " , & ( cy [ i ] [ j ] ) ) ; fgets ( str , 1000 , fid ) ; for ( int j = 0 ; j < nt ; j ++ ) fscanf ( fid , " " , & ( uz [ i ] [ j ] ) ) ; fgets ( str , 1000 , fid ) ; for ( int j = 0 ; j < nt ; j ++ ) fscanf ( fid , " " , & ( cz [ i ] [ j ] ) ) ; fgets ( str , 1000 , fid ) ; } fclose ( fid ) ; }
Fill time series by reading data from a file.
Fill time series by reading data from a file .
/* Local variables. */ /* Open file and read header. */ /* Read traces. */ /* Clean up. */