#include "geostat.h" #include "log.h" #include #include /*computes the size of the grid for FFTs*/ /*input: */ /*variogram: structure defining the variogram model*/ /*grid: structure defining the actual grid */ /*output: */ /*n: vector with the number of cells along the */ /* X, Y and Z axes for the underlying grid */ /* i = [0 1 2] */ void cgrid(struct vario_mod variogram, struct grid_mod grid, int n[3]) { clock_t t = clock(); int i, N; double D; log_info("RESULT = in progress"); if (n == NULL || n[0] == 0 || n[1] == 0 || n[2] == 0) { for (i = 0; i < 3; i++) { switch (i) { case 0: N = grid.NX; D = grid.DX; break; case 1: N = grid.NY; D = grid.DY; break; case 2: N = grid.NZ; D = grid.DZ; break; } n[i] = length(N, i, variogram.scf, variogram.ap, D, variogram.Nvario); } } else { if ((n[0] < grid.NX) || (n[1] < grid.NY) || (n[2] < grid.NZ)) { log_error("RESULT = failed - Indicated dimensions are inappropriate in cgrid"); exit; } } 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, n[0] = %d, n[1] = %d, n[2] = %d, ELAPSED = %f seconds", n[0], n[1], n[2], time_taken); }