#include "geostat.h" #include "log.h" #include #include #include #include #include #include #include /* prebuild_gwn */ /* Produce a first construction in real space of the Gaussian white noise */ /* grid: structure defining the grid */ /*n: vector with the number of cells along the */ /* X, Y and Z axes for the underlying grid */ /* i = [0 1 2] */ /* --> 0 0 0 : n will be computed and */ /* updated as output */ /* --> nx ny nz: these dimensions are used */ /*realin: structure defining a realization - */ /* must be a Gaussian white noise */ /*realization: structure defining a realization*/ void prebuild_gwn(struct grid_mod grid, int n[3], struct realization_mod* realin, double* realization, int solver) { clock_t t = clock(); int i, j, k, maille0, maille1; int ntot; log_info("RESULT = in progress, n[0] = %d, n[1] = %d, n[2] = %d, solver = %d", n[0], n[1], n[2], solver); ntot = n[0] * n[1] * n[2]; realization[0] = 0.; if (solver == 1) { for (i = 0; i < ntot; i++) { realization[i + 1] = (*realin).vector[i]; } } else { for (k = 1; k <= n[2]; k++) { for (j = 1; j <= n[1]; j++) { for (i = 1; i <= n[0]; i++) { maille1 = i + (j - 1 + (k - 1) * n[1]) * n[0]; if (i <= grid.NX && j <= grid.NY && k <= grid.NZ) { maille0 = i - 1 + (j - 1 + (k - 1) * grid.NY) * grid.NX; realization[maille1] = (*realin).vector[maille0]; } else { realization[maille1] = 0.; } } } } } t = clock() - t; double time_taken = ((double)t)/CLOCKS_PER_SEC; // calculate the elapsed time double* total_ram = malloc(sizeof(double)); getTotalVirtualMem(total_ram); double* used_ram = malloc(sizeof(double)); getVirtualMemUsed(used_ram); log_info("TOTAL VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM BY CURRENT PROCESS = %d MB", *total_ram, *used_ram, getVirtualMemUsedByCurrentProcess()); free(total_ram); free(used_ram); log_info("RESULT = success, ELAPSED = %f seconds", time_taken); }