Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

RmatType1StencilsAux.C

Go to the documentation of this file.
00001 
00008 #include <cstdio>
00009 #include <iostream>
00010 #include <cassert>
00011 
00012 namespace ot {
00013 
00014   int readRmatType1Stencil(double *****&lut) {
00015     typedef double**** double4Ptr;
00016     typedef double*** double3Ptr;
00017     typedef double** double2Ptr;
00018     typedef double* doublePtr;
00019     FILE* infile;
00020     char fname[100];
00021     sprintf(fname,"RmatType1Stencils.inp");
00022     infile = fopen(fname,"r");
00023     if(!infile) {
00024       std::cout<<"The file "<<fname<<" is not good for reading."<<std::endl;
00025       assert(false);
00026     }
00027     lut = new double4Ptr[8];
00028     for(int i=0;i<8;i++) {
00029       lut[i] = new double3Ptr[8];
00030       for(int j=0;j<8;j++) {
00031         lut[i][j] = new double2Ptr[18];
00032         for(int k=0;k<18;k++) {
00033           lut[i][j][k] = new doublePtr[8];
00034           for(int l=0;l<8;l++) {
00035             lut[i][j][k][l] = new double[8];
00036             for(int m=0;m<8;m++) {
00037               fscanf(infile,"%lf",&(lut[i][j][k][l][m]));
00038             }//end for m
00039           }//end for l
00040         }//end for k
00041       }//end for j
00042     }//end for i
00043 
00044     fclose(infile);
00045     return 1;
00046   }//end of function
00047 
00048   int IreadRmatType1Stencil(double *****&lut, int rank) {
00049     typedef double**** double4Ptr;
00050     typedef double*** double3Ptr;
00051     typedef double** double2Ptr;
00052     typedef double* doublePtr;
00053     FILE* infile;
00054     char fname[250];
00055     sprintf(fname,"RmatType1Stencils_%d.inp",rank);
00056     infile = fopen(fname,"r");
00057     if(!infile) {
00058       std::cout<<"The file "<<fname<<" is not good for reading."<<std::endl;
00059       assert(false);
00060     }
00061     lut = new double4Ptr[8];
00062     for(int i=0;i<8;i++) {
00063       lut[i] = new double3Ptr[8];
00064       for(int j=0;j<8;j++) {
00065         lut[i][j] = new double2Ptr[18];
00066         for(int k=0;k<18;k++) {
00067           lut[i][j][k] = new doublePtr[8];
00068           for(int l=0;l<8;l++) {
00069             lut[i][j][k][l] = new double[8];
00070             for(int m=0;m<8;m++) {
00071               fscanf(infile,"%lf",&(lut[i][j][k][l][m]));
00072             }//end for m
00073           }//end for l
00074         }//end for k
00075       }//end for j
00076     }//end for i
00077 
00078     fclose(infile);
00079     return 1;
00080   }//end of function
00081 
00082 
00083   int destroyRmatType1Stencil(double *****&lut) {
00084     for(int i=0;i<8;i++) {
00085       for(int j=0;j<8;j++) {
00086         for(int k=0;k<18;k++) {
00087           for(int l=0;l<8;l++) {
00088             delete [] lut[i][j][k][l];
00089             lut[i][j][k][l] = NULL;
00090           }//end for l
00091           delete [] lut[i][j][k];
00092           lut[i][j][k] = NULL;
00093         }//end for k
00094         delete [] lut[i][j];
00095         lut[i][j] = NULL;
00096       }//end for j
00097       delete [] lut[i]; 
00098       lut[i] = NULL;
00099     }//end for i
00100     delete [] lut;
00101     lut = NULL;
00102     return 1;
00103   }//end of function
00104 
00105 }//end namespace
00106 
00107 

Generated on Tue Mar 24 16:14:06 2009 for DENDRO by  doxygen 1.3.9.1