00001
00002
00009 #include <cstdio>
00010 #include <iostream>
00011 #include <cassert>
00012
00013 namespace ot {
00014
00015 int readRmatType2Stencil(double ****&lut) {
00016 typedef double*** double3Ptr;
00017 typedef double** double2Ptr;
00018 typedef double* doublePtr;
00019 FILE* infile;
00020 char fname[100];
00021 sprintf(fname,"RmatType2Stencils.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 double3Ptr[8];
00028 for(int j=0;j<8;j++) {
00029 lut[j] = new double2Ptr[18];
00030 for(int k=0;k<18;k++) {
00031 lut[j][k] = new doublePtr[8];
00032 for(int m=0;m<8;m++) {
00033 lut[j][k][m] = new double[8];
00034 for(int n=0;n<8;n++) {
00035 fscanf(infile,"%lf",&(lut[j][k][m][n]));
00036 }
00037 }
00038 }
00039 }
00040
00041 fclose(infile);
00042 return 1;
00043 }
00044
00045 int IreadRmatType2Stencil(double ****&lut, int rank) {
00046 typedef double*** double3Ptr;
00047 typedef double** double2Ptr;
00048 typedef double* doublePtr;
00049 FILE* infile;
00050 char fname[250];
00051 sprintf(fname,"RmatType2Stencils_%d.inp", rank);
00052 infile = fopen(fname,"r");
00053 if(!infile) {
00054 std::cout<<"The file "<<fname<<" is not good for reading."<<std::endl;
00055 assert(false);
00056 }
00057 lut = new double3Ptr[8];
00058 for(int j=0;j<8;j++) {
00059 lut[j] = new double2Ptr[18];
00060 for(int k=0;k<18;k++) {
00061 lut[j][k] = new doublePtr[8];
00062 for(int m=0;m<8;m++) {
00063 lut[j][k][m] = new double[8];
00064 for(int n=0;n<8;n++) {
00065 fscanf(infile,"%lf",&(lut[j][k][m][n]));
00066 }
00067 }
00068 }
00069 }
00070
00071 fclose(infile);
00072 return 1;
00073 }
00074
00075 int destroyRmatType2Stencil(double ****&lut) {
00076 for(int j=0;j<8;j++) {
00077 for(int k=0;k<18;k++) {
00078 for(int m=0;m<8;m++) {
00079 delete [] lut[j][k][m];
00080 lut[j][k][m] = NULL;
00081 }
00082 delete [] lut[j][k];
00083 lut[j][k] = NULL;
00084 }
00085 delete [] lut[j];
00086 lut[j] = NULL;
00087 }
00088 delete [] lut;
00089 lut = NULL;
00090 return 1;
00091 }
00092
00093 }
00094
00095
00096