#include #include #include #include #define EPSILON 0.00001 #define N 1000 #define time_steps 100 int main (int argc, char *argv[]) { int i,j; int step; int threads; double time; double eps, enew; double time_max = 3.0; double alpha = 0.06; double dx = 1.0/N; double dy = 1.0/time_steps; double dt = time_max/time_steps; double dxinv = 1.0/dx; double dyinv = 1.0/dy; double dtinv = 1.0/dt; double divinv = 1.0/(dtinv + 2 * alpha * (dxinv * dxinv + dyinv * dyinv)); double **t,*tS; double **told,*toldS; double minval, maxval; double start, end; char fname[40]; FILE *out; if (argc < 2) threads = 1; else threads = atoi(argv[1]); if (!omp_get_dynamic()) { //Set the number of threads omp_set_num_threads(threads); } else { printf("ERROR: set OMP_DYNAMIC=FALSE\n"); exit(0); } start = omp_get_wtime(); tS = (double *) malloc(N * N * sizeof(double)); toldS = (double *) malloc(N * N * sizeof(double)); t = (double **) malloc(N * sizeof(double *)); told = (double **) malloc(N * sizeof(double *)); #pragma omp parallel for for (i=0; i eps) { eps = enew; } } } #pragma omp parallel for private(j) for (i=0; i EPSILON); // Dump raster date to a file minval = 0.0; maxval = 0.0; for (i=0; i maxval) { maxval = t[i][j]; } } sprintf(fname,"Output\\heat%03d.raw",step); out = fopen(fname,"w+b"); for (i=0; i