diff --git a/fftma_module/gen/example.py b/fftma_module/gen/example.py new file mode 100644 index 0000000..057c0f5 --- /dev/null +++ b/fftma_module/gen/example.py @@ -0,0 +1,31 @@ +from FFTMA import gen +import numpy as np +import sys + +N=int(sys.argv[1]) + +nx, ny, nz = N,N,N +dx, dy, dz = 1.0, 1.0, 1.0 +seed= 1548762 #rdi(10000,99999) +var=1 +vario=2 +alpha=1 +lcx=2 +lcy=4 +lcz=16 +ap1x=1 +ap1y=0 +ap1z=0 +ap2x=0 +ap2y=1 +ap2z=0 + +v1 = (var, vario, alpha, lcx, lcy, lcz, ap1x, ap1y, ap1z, ap2x, ap2y, ap2z) +variograms = [v1] + +mean=15.3245987 +variance=3.5682389 +typ=3 + +k=gen(nx, ny, nz, dx, dy, dz, seed, variograms, mean, variance, typ) +np.save(f"out_{N}.npy",k) \ No newline at end of file diff --git a/fftma_module/gen/fourt_temp b/fftma_module/gen/fourt_temp deleted file mode 100644 index 75d9bf2..0000000 Binary files a/fftma_module/gen/fourt_temp and /dev/null differ diff --git a/fftma_module/gen/lib_src/chunk_array.c b/fftma_module/gen/lib_src/chunk_array.c index 3b59ae0..7c390c4 100644 --- a/fftma_module/gen/lib_src/chunk_array.c +++ b/fftma_module/gen/lib_src/chunk_array.c @@ -3,6 +3,11 @@ #define MAX_CHUNK_SIZE 2048*2048 +int min(int value1, int value2) { + if (value1 < value2) return value1; + return value2; +} + void chunk_array_free(chunk_array_t* chunk_array) { fclose(chunk_array->fp); free(chunk_array->data); @@ -43,7 +48,9 @@ chunk_array_t* chunk_array_create(char* filename, size_t total_size) { } } - chunk_array->data = malloc(MAX_CHUNK_SIZE * sizeof(double)); + chunk_array->chunk_size = min(MAX_CHUNK_SIZE, total_size); + + chunk_array->data = malloc(chunk_array->chunk_size * sizeof(double)); if (MAX_CHUNK_SIZE > 0 && chunk_array->data == NULL) { free(chunk_array); @@ -54,7 +61,6 @@ chunk_array_t* chunk_array_create(char* filename, size_t total_size) { chunk_array->filename = filename; chunk_array->init_pos = 0; - chunk_array->chunk_size = MAX_CHUNK_SIZE; chunk_array->total_size = total_size; return chunk_array; }