Linter to c files

milestone_5_without_improvements
chortas 3 years ago
parent 83d7d29273
commit 4fd1d5ddc6

@ -1,16 +1,15 @@
#include <Python.h>
#include <numpy/arrayobject.h>
#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include "genlib.h" #include "genlib.h"
#include "simpio.h"
#include "geostat.h" #include "geostat.h"
#include "pressure.h" #include "pressure.h"
#include "simpio.h"
#include "toolsIO.h" #include "toolsIO.h"
#include <Python.h>
#include <numpy/arrayobject.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int Py_getvalues(PyObject*, long*, struct grid_mod*, struct vario_mod*, struct statistic_mod*); int Py_getvalues(PyObject*, long*, struct grid_mod*, struct vario_mod*, struct statistic_mod*);
void Py_kgeneration(long,struct grid_mod,struct statistic_mod,struct vario_mod,struct realization_mod*,struct realization_mod*,struct realization_mod*, int [3]); void Py_kgeneration(long, struct grid_mod, struct statistic_mod, struct vario_mod, struct realization_mod*, struct realization_mod*, struct realization_mod*, int[3]);

@ -3,8 +3,6 @@
#ifndef _CONDOR_H_ #ifndef _CONDOR_H_
#define _CONDOR_H_ #define _CONDOR_H_
/*=======================================================*/ /*=======================================================*/
/*FUNCTIONS*/ /*FUNCTIONS*/
/*---------*/ /*---------*/
@ -23,8 +21,7 @@
/*grid: structure defining the grid */ /*grid: structure defining the grid */
/*OUTPUT */ /*OUTPUT */
/*realout: structure defining the output realization */ /*realout: structure defining the output realization */
void condit(int k,struct welldata_mod well,struct vario_mod variogram,struct grid_mod grid,struct realization_mod *realin,struct realization_mod *realout); void condit(int k, struct welldata_mod well, struct vario_mod variogram, struct grid_mod grid, struct realization_mod* realin, struct realization_mod* realout);
/*d_kriging */ /*d_kriging */
/*interpolation from ponctual data with simple dual */ /*interpolation from ponctual data with simple dual */
@ -38,8 +35,7 @@ void condit(int k,struct welldata_mod well,struct vario_mod variogram,struct gri
/*grid: structure defining the grid */ /*grid: structure defining the grid */
/*OUTPUT */ /*OUTPUT */
/*realout: structure defining the output realization */ /*realout: structure defining the output realization */
void d_kriging(int k,struct welldata_mod well,struct vario_mod variogram,struct grid_mod grid,struct realization_mod *realout); void d_kriging(int k, struct welldata_mod well, struct vario_mod variogram, struct grid_mod grid, struct realization_mod* realout);
/*dual_condit */ /*dual_condit */
/*conditioning of a Gaussian realization using */ /*conditioning of a Gaussian realization using */
@ -54,8 +50,7 @@ void d_kriging(int k,struct welldata_mod well,struct vario_mod variogram,struct
/*realin: structure defining the input realization */ /*realin: structure defining the input realization */
/*OUTPUT */ /*OUTPUT */
/*realout: structure defining the output realization */ /*realout: structure defining the output realization */
void dual_condit(int k,struct welldata_mod well,struct vario_mod variogram,struct grid_mod grid,struct realization_mod *realin,struct realization_mod *realout); void dual_condit(int k, struct welldata_mod well, struct vario_mod variogram, struct grid_mod grid, struct realization_mod* realin, struct realization_mod* realout);
/*dual_condit_gen */ /*dual_condit_gen */
/*conditioning of a Gaussian realization using */ /*conditioning of a Gaussian realization using */
@ -73,7 +68,7 @@ void dual_condit(int k,struct welldata_mod well,struct vario_mod variogram,struc
/*OUTPUT */ /*OUTPUT */
/*realout: structure defining the output realization */ /*realout: structure defining the output realization */
void dual_condit_gen(int k,struct welldata_mod wellin,struct vario_mod variogram,struct grid_mod grid,struct realization_mod *realin,struct statistic_mod stat, struct realization_mod *realout); void dual_condit_gen(int k, struct welldata_mod wellin, struct vario_mod variogram, struct grid_mod grid, struct realization_mod* realin, struct statistic_mod stat, struct realization_mod* realout);
/*FAST FOURIER TRANSFORM MOVING AVERAGE METHOD */ /*FAST FOURIER TRANSFORM MOVING AVERAGE METHOD */
/*PLUS GRADIENT CALCULATIONS - GRADIENTS ARE */ /*PLUS GRADIENT CALCULATIONS - GRADIENTS ARE */
@ -99,8 +94,7 @@ void dual_condit_gen(int k,struct welldata_mod wellin,struct vario_mod variogram
/*------- */ /*------- */
/*realout: structure defining a realization - */ /*realout: structure defining a realization - */
/*DYoverDRHO : structure with the output gradients */ /*DYoverDRHO : structure with the output gradients */
void FFTMA_gradient(struct vario_mod variogram,struct grid_mod grid,int n[3],struct realization_mod *realin,struct gradients_mod *DZoverDRHO,struct realization_mod *realout,struct gradients_mod *DYoverDRHO); void FFTMA_gradient(struct vario_mod variogram, struct grid_mod grid, int n[3], struct realization_mod* realin, struct gradients_mod* DZoverDRHO, struct realization_mod* realout, struct gradients_mod* DYoverDRHO);
/* GENERATION OF A GAUSSIAN WHITE NOISE VECTOR */ /* GENERATION OF A GAUSSIAN WHITE NOISE VECTOR */
/*input: */ /*input: */
@ -108,10 +102,9 @@ void FFTMA_gradient(struct vario_mod variogram,struct grid_mod grid,int n[3],str
/* n: number of components in the vector */ /* n: number of components in the vector */
/*output: */ /*output: */
/* realization: structure defining the realization*/ /* realization: structure defining the realization*/
void generate(long *seed, int n, struct realization_mod *realization); void generate(long* seed, int n, struct realization_mod* realization);
void ikrig(int option, struct statfacies_mod facies, int kk,struct welldata_mod data, struct variotable_mod variogram,struct grid_mod grid,float *krigout);
void ikrig(int option, struct statfacies_mod facies, int kk, struct welldata_mod data, struct variotable_mod variogram, struct grid_mod grid, float* krigout);
/*kriging */ /*kriging */
/*interpolation from ponctual data with simple */ /*interpolation from ponctual data with simple */
@ -125,8 +118,7 @@ void ikrig(int option, struct statfacies_mod facies, int kk,struct welldata_mod
/*grid: structure defining the grid */ /*grid: structure defining the grid */
/*OUTPUT */ /*OUTPUT */
/*realout: structure defining the output realization */ /*realout: structure defining the output realization */
void kriging(int k,struct welldata_mod data,struct vario_mod variogram,struct grid_mod grid,struct realization_mod *realout); void kriging(int k, struct welldata_mod data, struct vario_mod variogram, struct grid_mod grid, struct realization_mod* realout);
/*CHOLESKY SIMULATION TECHNIQUE - LUSIM */ /*CHOLESKY SIMULATION TECHNIQUE - LUSIM */
/*appropriate for regular grids and small number */ /*appropriate for regular grids and small number */
@ -137,10 +129,9 @@ void kriging(int k,struct welldata_mod data,struct vario_mod variogram,struct gr
/* must be a Gaussian white noise */ /* must be a Gaussian white noise */
/*output: */ /*output: */
/*realout: structure defining a realization - */ /*realout: structure defining a realization - */
void LUSIM(struct vario_mod variogram,struct grid_mod grid,struct realization_mod *realin,struct realization_mod *realout); void LUSIM(struct vario_mod variogram, struct grid_mod grid, struct realization_mod* realin, struct realization_mod* realout);
void nor2any(struct cdf_mod *pcumulf,struct realization_mod *realin,struct realization_mod *realout); void nor2any(struct cdf_mod* pcumulf, struct realization_mod* realin, struct realization_mod* realout);
/*TURNS NORMAL NUMBERS INTO LOGNORMAL NUMBERS */ /*TURNS NORMAL NUMBERS INTO LOGNORMAL NUMBERS */
/*input: */ /*input: */
@ -151,8 +142,7 @@ void nor2any(struct cdf_mod *pcumulf,struct realization_mod *realin,struct reali
/*output: */ /*output: */
/*realout: structure defining a realization - */ /*realout: structure defining a realization - */
/* lognormal numbers */ /* lognormal numbers */
void nor2log(struct realization_mod *realin, int typelog, struct realization_mod *realout); void nor2log(struct realization_mod* realin, int typelog, struct realization_mod* realout);
/*TURNS NORMAL NUMBERS INTO UNIFORM NUMBERS */ /*TURNS NORMAL NUMBERS INTO UNIFORM NUMBERS */
/*input: */ /*input: */
@ -161,8 +151,7 @@ void nor2log(struct realization_mod *realin, int typelog, struct realization_mod
/*output: */ /*output: */
/*realout: structure defining a realization - */ /*realout: structure defining a realization - */
/* uniform numbers */ /* uniform numbers */
void nor2unif(struct realization_mod *realin,struct realization_mod *realout); void nor2unif(struct realization_mod* realin, struct realization_mod* realout);
/*o_kriging */ /*o_kriging */
/*interpolation from ponctual data with ordinary kriging */ /*interpolation from ponctual data with ordinary kriging */
@ -175,8 +164,7 @@ void nor2unif(struct realization_mod *realin,struct realization_mod *realout);
/*grid: structure defining the grid */ /*grid: structure defining the grid */
/*OUTPUT */ /*OUTPUT */
/*realout: structure defining the kriged realization */ /*realout: structure defining the kriged realization */
void o_kriging(int k,struct vario_mod variogram,struct welldata_mod data,struct grid_mod grid,struct realization_mod *realout); void o_kriging(int k, struct vario_mod variogram, struct welldata_mod data, struct grid_mod grid, struct realization_mod* realout);
/*od_kriging */ /*od_kriging */
/*interpolation from ponctual data with ordinary dual*/ /*interpolation from ponctual data with ordinary dual*/
@ -190,8 +178,7 @@ void o_kriging(int k,struct vario_mod variogram,struct welldata_mod data,struct
/*grid: structure defining the grid */ /*grid: structure defining the grid */
/*OUTPUT */ /*OUTPUT */
/*realout: structure defining the output realization */ /*realout: structure defining the output realization */
void od_kriging(int k,struct welldata_mod well,struct vario_mod variogram,struct grid_mod grid,struct realization_mod *realout); void od_kriging(int k, struct welldata_mod well, struct vario_mod variogram, struct grid_mod grid, struct realization_mod* realout);
/*PLURIGAUSSIAN METHOD */ /*PLURIGAUSSIAN METHOD */
/*Starting from two independent Gaussian realizations Y1*/ /*Starting from two independent Gaussian realizations Y1*/
@ -212,8 +199,7 @@ void od_kriging(int k,struct welldata_mod well,struct vario_mod variogram,struct
/*Y2: second starting realization - same length as Y1 */ /*Y2: second starting realization - same length as Y1 */
/*OUTPUT: */ /*OUTPUT: */
/*Y: output realization */ /*Y: output realization */
void plurigau(struct statfacies_mod facies,struct inequalities_mod ineq,struct realization_mod *Y1, struct realization_mod *Y2, struct realization_mod *Y); void plurigau(struct statfacies_mod facies, struct inequalities_mod ineq, struct realization_mod* Y1, struct realization_mod* Y2, struct realization_mod* Y);
/*tr_kriging */ /*tr_kriging */
/*kriging with an external drift */ /*kriging with an external drift */
@ -229,8 +215,7 @@ void plurigau(struct statfacies_mod facies,struct inequalities_mod ineq,struct r
/*y: secondary external variable */ /*y: secondary external variable */
/*OUTPUT: */ /*OUTPUT: */
/*realout: kriged realization */ /*realout: kriged realization */
void tr_kriging(int k, struct vario_mod variogram,struct welldata_mod data,struct grid_mod grid,struct realization_mod *Y,struct realization_mod *realout); void tr_kriging(int k, struct vario_mod variogram, struct welldata_mod data, struct grid_mod grid, struct realization_mod* Y, struct realization_mod* realout);
/*truncat */ /*truncat */
/*TRUNCATES A STANDARD GAUSSIAN REALIZATION */ /*TRUNCATES A STANDARD GAUSSIAN REALIZATION */
@ -246,8 +231,7 @@ void tr_kriging(int k, struct vario_mod variogram,struct welldata_mod data,struc
/*realout: structure defining a realization - */ /*realout: structure defining a realization - */
/*thresholds: Gaussian thresholds corresponding*/ /*thresholds: Gaussian thresholds corresponding*/
/* to the facies volume fractions if*/ /* to the facies volume fractions if*/
void truncat(struct statfacies_mod facies,struct realization_mod *realin,struct realization_mod *realout, struct statfacies_mod *thresholds); void truncat(struct statfacies_mod facies, struct realization_mod* realin, struct realization_mod* realout, struct statfacies_mod* thresholds);
/*TURNS UNIFORM NUMBERS INTO NORMAL NUMBERS*/ /*TURNS UNIFORM NUMBERS INTO NORMAL NUMBERS*/
/*INPUT: */ /*INPUT: */
@ -256,8 +240,7 @@ void truncat(struct statfacies_mod facies,struct realization_mod *realin,struct
/*OUTPUT: */ /*OUTPUT: */
/*realout: structure defining a realization - */ /*realout: structure defining a realization - */
/* must have zero mean and unit variance */ /* must have zero mean and unit variance */
void unif2nor(struct realization_mod *realin,struct realization_mod *realout); void unif2nor(struct realization_mod* realin, struct realization_mod* realout);
/*Wany2nor */ /*Wany2nor */
/*converts any kind of continuous data to Gaussian data*/ /*converts any kind of continuous data to Gaussian data*/
@ -269,8 +252,7 @@ void unif2nor(struct realization_mod *realin,struct realization_mod *realout);
/*wellout: structure with the output well data */ /*wellout: structure with the output well data */
/*pcumulf: structure describing the experimental */ /*pcumulf: structure describing the experimental */
/* cumulative distribution */ /* cumulative distribution */
void Wany2nor(int k, struct welldata_mod wellin, long *seed,struct welldata_mod *wellout, struct cdf_mod *pcumulf); void Wany2nor(int k, struct welldata_mod wellin, long* seed, struct welldata_mod* wellout, struct cdf_mod* pcumulf);
/*Wfac2nor0 */ /*Wfac2nor0 */
/*turns the facies well measurements into Gaussian data */ /*turns the facies well measurements into Gaussian data */
@ -288,8 +270,7 @@ void Wany2nor(int k, struct welldata_mod wellin, long *seed,struct welldata_mod
/*output: */ /*output: */
/*wellout: structure defining well data - the kth vector*/ /*wellout: structure defining well data - the kth vector*/
/*of measures are converted to standard normal data */ /*of measures are converted to standard normal data */
void Wfac2nor0(int k,struct grid_mod grid,struct welldata_mod wellin,struct statfacies_mod facies,long *seed,struct welldata_mod *wellout); void Wfac2nor0(int k, struct grid_mod grid, struct welldata_mod wellin, struct statfacies_mod facies, long* seed, struct welldata_mod* wellout);
/*Wfac2nor1 */ /*Wfac2nor1 */
/*turns the facies well measurements into Gaussian data */ /*turns the facies well measurements into Gaussian data */
@ -308,8 +289,7 @@ void Wfac2nor0(int k,struct grid_mod grid,struct welldata_mod wellin,struct stat
/*output: */ /*output: */
/*wellout: structure defining well data - the kth vector*/ /*wellout: structure defining well data - the kth vector*/
/*of measures are converted to standard normal data */ /*of measures are converted to standard normal data */
void Wfac2nor1(int k,struct vario_mod variogram,struct grid_mod grid,struct welldata_mod wellin,struct statfacies_mod facies,long *seed,struct welldata_mod *wellout); void Wfac2nor1(int k, struct vario_mod variogram, struct grid_mod grid, struct welldata_mod wellin, struct statfacies_mod facies, long* seed, struct welldata_mod* wellout);
/*Wfac2norPG0 */ /*Wfac2norPG0 */
/*turns the facies well measurements into Gaussian data */ /*turns the facies well measurements into Gaussian data */
@ -332,8 +312,7 @@ void Wfac2nor1(int k,struct vario_mod variogram,struct grid_mod grid,struct well
/*OUTPUT: */ /*OUTPUT: */
/*wellout: structure defining well data - the kth vector*/ /*wellout: structure defining well data - the kth vector*/
/*of measures are converted to standard normal data */ /*of measures are converted to standard normal data */
void Wfac2norPG0(int k,struct inequalities_mod ineq,struct grid_mod grid,struct welldata_mod wellin,struct statfacies_mod facies,long *seed,int idreal,struct welldata_mod *wellout); void Wfac2norPG0(int k, struct inequalities_mod ineq, struct grid_mod grid, struct welldata_mod wellin, struct statfacies_mod facies, long* seed, int idreal, struct welldata_mod* wellout);
/*Wfac2norPG1 */ /*Wfac2norPG1 */
/*turns the facies well measurements into Gaussian data */ /*turns the facies well measurements into Gaussian data */
@ -361,8 +340,7 @@ void Wfac2norPG0(int k,struct inequalities_mod ineq,struct grid_mod grid,struct
/*realization 1 - the kth vector */ /*realization 1 - the kth vector */
/*wellout2: structure with converted well data for */ /*wellout2: structure with converted well data for */
/*realization 2 - the kth vector */ /*realization 2 - the kth vector */
void Wfac2norPG1(int k,struct inequalities_mod ineq,struct vario_mod variogram1,struct vario_mod variogram2,struct grid_mod grid,struct welldata_mod wellin,struct statfacies_mod facies,long *seed,struct welldata_mod *wellout1,struct welldata_mod *wellout2); void Wfac2norPG1(int k, struct inequalities_mod ineq, struct vario_mod variogram1, struct vario_mod variogram2, struct grid_mod grid, struct welldata_mod wellin, struct statfacies_mod facies, long* seed, struct welldata_mod* wellout1, struct welldata_mod* wellout2);
/*Wlog2nor */ /*Wlog2nor */
/*turns the log well measurements into std Gaussian data*/ /*turns the log well measurements into std Gaussian data*/
@ -377,8 +355,7 @@ void Wfac2norPG1(int k,struct inequalities_mod ineq,struct vario_mod variogram1,
/*output: */ /*output: */
/*wellout: structure defining well data - the kth vector*/ /*wellout: structure defining well data - the kth vector*/
/*of measures are converted to standard normal data */ /*of measures are converted to standard normal data */
void Wlog2nor(int k, struct welldata_mod wellin,struct grid_mod grid,struct statistic_mod stat,struct welldata_mod *wellout); void Wlog2nor(int k, struct welldata_mod wellin, struct grid_mod grid, struct statistic_mod stat, struct welldata_mod* wellout);
/*Wnor2nor */ /*Wnor2nor */
/*converts Well Normal numbers to the standard Gaussian */ /*converts Well Normal numbers to the standard Gaussian */
@ -390,8 +367,7 @@ void Wlog2nor(int k, struct welldata_mod wellin,struct grid_mod grid,struct stat
/*output: */ /*output: */
/*wellout: structure defining well data - the kth vector*/ /*wellout: structure defining well data - the kth vector*/
/*of measures are converted to standard normal data */ /*of measures are converted to standard normal data */
void Wnor2nor(int k, struct welldata_mod wellin,struct grid_mod grid,struct statistic_mod stat,struct welldata_mod *wellout); void Wnor2nor(int k, struct welldata_mod wellin, struct grid_mod grid, struct statistic_mod stat, struct welldata_mod* wellout);
/*Wunif2nor */ /*Wunif2nor */
/*converts Well uniform numbers to the standard Gaussian*/ /*converts Well uniform numbers to the standard Gaussian*/
@ -401,8 +377,6 @@ void Wnor2nor(int k, struct welldata_mod wellin,struct grid_mod grid,struct stat
/*output: */ /*output: */
/*wellout: structure defining well data - the kth vector*/ /*wellout: structure defining well data - the kth vector*/
/*of measures are converted to standard normal data */ /*of measures are converted to standard normal data */
void Wunif2nor(int k, struct welldata_mod wellin,struct welldata_mod *wellout); void Wunif2nor(int k, struct welldata_mod wellin, struct welldata_mod* wellout);
#endif // define _CONDOR_H_ #endif // define _CONDOR_H_

@ -25,9 +25,9 @@
#ifndef _genlib_h #ifndef _genlib_h
#define _genlib_h #define _genlib_h
#include <stddef.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stddef.h>
/* Section 1 -- Define new "primitive" types */ /* Section 1 -- Define new "primitive" types */
@ -45,20 +45,20 @@
*/ */
#ifdef THINK_C #ifdef THINK_C
typedef int bool; typedef int bool;
#else
#ifdef TRUE
#ifndef bool
#define bool int
#endif
#else
#ifdef bool
#define FALSE 0
#define TRUE 1
#else #else
# ifdef TRUE
# ifndef bool
# define bool int
# endif
# else
# ifdef bool
# define FALSE 0
# define TRUE 1
# else
// typedef enum {FALSE, TRUE} bool; // typedef enum {FALSE, TRUE} bool;
# endif #endif
# endif #endif
#endif #endif
/* /*
@ -72,7 +72,7 @@
* Declaring it as a string emphasizes this atomicity. * Declaring it as a string emphasizes this atomicity.
*/ */
typedef char *string; typedef char* string;
/* /*
* Constant: UNDEFINED * Constant: UNDEFINED
@ -84,7 +84,7 @@ typedef char *string;
* therefore inappropriate as a sentinel. * therefore inappropriate as a sentinel.
*/ */
#define UNDEFINED ((void *) undefined_object) #define UNDEFINED ((void*)undefined_object)
extern char undefined_object[]; extern char undefined_object[];
@ -111,7 +111,7 @@ extern char undefined_object[];
* no memory is available, GetBlock generates an error. * no memory is available, GetBlock generates an error.
*/ */
void *GetBlock(size_t nbytes); void* GetBlock(size_t nbytes);
/* /*
* Function: FreeBlock * Function: FreeBlock
@ -121,7 +121,7 @@ void *GetBlock(size_t nbytes);
* have been allocated using GetBlock, New, or NewArray. * have been allocated using GetBlock, New, or NewArray.
*/ */
void FreeBlock(void *ptr); void FreeBlock(void* ptr);
/* /*
* Macro: New * Macro: New
@ -135,7 +135,7 @@ void FreeBlock(void *ptr);
* target type. * target type.
*/ */
#define New(type) ((type) GetBlock(sizeof *((type) NULL))) #define New(type) ((type)GetBlock(sizeof *((type)NULL)))
/* /*
* Macro: NewArray * Macro: NewArray
@ -145,7 +145,7 @@ void FreeBlock(void *ptr);
* values of the specified element type. * values of the specified element type.
*/ */
#define NewArray(n, type) ((type *) GetBlock((n) * sizeof(type))) #define NewArray(n, type) ((type*)GetBlock((n) * sizeof(type)))
/* Section 3 -- Basic error handling */ /* Section 3 -- Basic error handling */

@ -1,8 +1,7 @@
#include <stdio.h> #include <stdarg.h>
#include <stddef.h> #include <stddef.h>
#include <stdio.h>
#include <string.h> #include <string.h>
#include <stdarg.h>
#ifndef _GEOSTAT_H #ifndef _GEOSTAT_H
#define _GEOSTAT_H #define _GEOSTAT_H
@ -27,7 +26,6 @@
/* cdf_mod */ /* cdf_mod */
/* realization_mod */ /* realization_mod */
/* List of functions: */ /* List of functions: */
/* ------------------ */ /* ------------------ */
@ -44,9 +42,6 @@
/* test_fract, trun1, trungasdev,vec_vec, */ /* test_fract, trun1, trungasdev,vec_vec, */
/* vf2gthres,polint */ /* vf2gthres,polint */
/*STRUCTURES*/ /*STRUCTURES*/
/*----------*/ /*----------*/
/*variogram */ /*variogram */
@ -67,16 +62,14 @@
/*scf: correlation lengths per variogram model */ /*scf: correlation lengths per variogram model */
/*var: normalized variance per variogram model(sum = 1)*/ /*var: normalized variance per variogram model(sum = 1)*/
struct vario_mod { struct vario_mod {
int Nvario; int Nvario;
int *vario; int* vario;
double *alpha; double* alpha;
double *ap; double* ap;
double *scf; double* scf;
double *var; double* var;
}; };
/*variogram table */ /*variogram table */
/*Nvario: number of combined variogram models */ /*Nvario: number of combined variogram models */
/*vario: model of variogram per variogram model */ /*vario: model of variogram per variogram model */
@ -95,20 +88,15 @@ struct vario_mod {
/*scf: correlation lengths per variogram model */ /*scf: correlation lengths per variogram model */
/*var: normalized variance per variogram model(sum = 1)*/ /*var: normalized variance per variogram model(sum = 1)*/
struct variotable_mod { struct variotable_mod {
int number_of_variograms; int number_of_variograms;
int *Nvario; int* Nvario;
int *vario; int* vario;
float *alpha; float* alpha;
float *ap; float* ap;
float *scf; float* scf;
float *var; float* var;
}; };
/*grid */ /*grid */
/*NX: number of gridblocks along the X axis*/ /*NX: number of gridblocks along the X axis*/
/*NY: number of gridblocks along the Y axis*/ /*NY: number of gridblocks along the Y axis*/
@ -120,12 +108,11 @@ struct variotable_mod {
/*Yo: Y-cell number of the origin cell */ /*Yo: Y-cell number of the origin cell */
/*Zo: Z-cell number of the origin cell */ /*Zo: Z-cell number of the origin cell */
struct grid_mod { struct grid_mod {
int NX, NY, NZ; int NX, NY, NZ;
double DX,DY,DZ; double DX, DY, DZ;
double Xo,Yo,Zo; double Xo, Yo, Zo;
}; };
/*well data */ /*well data */
/*nwell: number of wells */ /*nwell: number of wells */
/*n: number of measurement points per well */ /*n: number of measurement points per well */
@ -154,18 +141,16 @@ struct grid_mod {
/* type 2 : */ /* type 2 : */
/* i=[sum(n[k])... sum(n[k])+n[0]-1 ... 2*(sum(n[k])-1)]*/ /* i=[sum(n[k])... sum(n[k])+n[0]-1 ... 2*(sum(n[k])-1)]*/
struct welldata_mod { struct welldata_mod {
int nwell; int nwell;
int *n; int* n;
int ntype; int ntype;
int *code; int* code;
float *x; float* x;
float *y; float* y;
float *z; float* z;
float *measure; float* measure;
}; };
/*volume fractions for facies */ /*volume fractions for facies */
/*ncat: number of facies */ /*ncat: number of facies */
/*nblock: number of gridblocks with different */ /*nblock: number of gridblocks with different */
@ -175,12 +160,11 @@ struct welldata_mod {
/*vf: volume fractions for the first ncat-1 facies*/ /*vf: volume fractions for the first ncat-1 facies*/
/* i = [0...ncat-2]*nblock */ /* i = [0...ncat-2]*nblock */
struct statfacies_mod { struct statfacies_mod {
int ncat; int ncat;
int nblock; int nblock;
float *vf; float* vf;
}; };
/*inequalities for truncated plurigaussian realizations*/ /*inequalities for truncated plurigaussian realizations*/
/*only two basic realizations Y1 and Y2 are considered */ /*only two basic realizations Y1 and Y2 are considered */
/*Y1 and Y2 are independent */ /*Y1 and Y2 are independent */
@ -203,14 +187,13 @@ struct statfacies_mod {
/* the values in address_sY2 are integers */ /* the values in address_sY2 are integers */
/* ranging from 0 to n+1 with n = nsY1+nsY2*/ /* ranging from 0 to n+1 with n = nsY1+nsY2*/
struct inequalities_mod { struct inequalities_mod {
int nsY1; int nsY1;
int nsY2; int nsY2;
float *thresholds; float* thresholds;
int *address_sY1; int* address_sY1;
int *address_sY2; int* address_sY2;
}; };
/*statistical data */ /*statistical data */
/*type --> 0 : normal */ /*type --> 0 : normal */
/* --> 1 : natural log */ /* --> 1 : natural log */
@ -228,14 +211,13 @@ struct inequalities_mod {
/*variance: variance of the variable i = [0...nblock_var]*/ /*variance: variance of the variable i = [0...nblock_var]*/
/* DHF CHANGE: FOR TYPE 1 AND TYPE 2, VAR IS LOG VAR ! */ /* DHF CHANGE: FOR TYPE 1 AND TYPE 2, VAR IS LOG VAR ! */
struct statistic_mod { struct statistic_mod {
int type; int type;
int nblock_mean; int nblock_mean;
double *mean; double* mean;
int nblock_var; int nblock_var;
double *variance; double* variance;
}; };
/*gradual deformation parameters */ /*gradual deformation parameters */
/*Nadded: number of complementary realizations */ /*Nadded: number of complementary realizations */
/*NZONES: number of subregions */ /*NZONES: number of subregions */
@ -246,12 +228,11 @@ struct statistic_mod {
/*cellfin[NZONES*(0...2)] upper cell bound for */ /*cellfin[NZONES*(0...2)] upper cell bound for */
/*for subregions along axes X,Y,Z */ /*for subregions along axes X,Y,Z */
struct grad_mod { struct grad_mod {
int Nadded, NZONES; int Nadded, NZONES;
float *rho; float* rho;
int *cellini, *cellfin; int *cellini, *cellfin;
}; };
/*gradient structures */ /*gradient structures */
/*Nparam : number of parameters for which gradients are */ /*Nparam : number of parameters for which gradients are */
/* required */ /* required */
@ -264,24 +245,21 @@ struct grad_mod {
/* Ncells....2*Ncells-1 for the second parameter */ /* Ncells....2*Ncells-1 for the second parameter */
/* and so on */ /* and so on */
struct gradients_mod { struct gradients_mod {
int Nparam,Ncells; int Nparam, Ncells;
float *grad; float* grad;
}; };
/*description of discretized cumulative distributions */ /*description of discretized cumulative distributions */
/*n: number of points */ /*n: number of points */
/*x: values along the x axis i = [0...n-1] */ /*x: values along the x axis i = [0...n-1] */
/*fx: corresponding values for the cumulative */ /*fx: corresponding values for the cumulative */
/* distribution i = [0...n-1] */ /* distribution i = [0...n-1] */
struct cdf_mod { struct cdf_mod {
int n; int n;
float *x; float* x;
float *fx; float* fx;
}; };
/*realization */ /*realization */
/*n: number of components */ /*n: number of components */
/*code: status of the realization */ /*code: status of the realization */
@ -302,9 +280,9 @@ struct cdf_mod {
/* --> 14: conditional any type */ /* --> 14: conditional any type */
/*vector: realization vector i = [0...n-1] */ /*vector: realization vector i = [0...n-1] */
struct realization_mod { struct realization_mod {
int n; int n;
int code; int code;
double *vector; double* vector;
}; };
/*=====================================================*/ /*=====================================================*/
@ -312,18 +290,15 @@ struct realization_mod {
/*FUNCTIONS*/ /*FUNCTIONS*/
/*---------*/ /*---------*/
/*normalization of the anostropy axes */ /*normalization of the anostropy axes */
/*ap: anisotropy axes */ /*ap: anisotropy axes */
/*scf: correlation lengths */ /*scf: correlation lengths */
/* The returned normalized axes are in ap */ /* The returned normalized axes are in ap */
void axes(double *ap, double *scf, int N); void axes(double* ap, double* scf, int N);
/*cardsin covariance value for lag h*/ /*cardsin covariance value for lag h*/
double cardsin(double h); double cardsin(double h);
/*Cholesky decomposition of matrix C */ /*Cholesky decomposition of matrix C */
/* C : symetric positive-definite matrix recorded */ /* C : symetric positive-definite matrix recorded */
/* (per raws) as a vector with only components */ /* (per raws) as a vector with only components */
@ -331,8 +306,7 @@ double cardsin(double h);
/* n : dimension of matrix Cij */ /* n : dimension of matrix Cij */
/* */ /* */
/* C is turned into the lower triangular cholesky matrix*/ /* C is turned into the lower triangular cholesky matrix*/
void choldc(double *C, int n); void choldc(double* C, int n);
/*computes the coordinates of a given cell */ /*computes the coordinates of a given cell */
/*as numbers of cells along the X,Y and Z axes*/ /*as numbers of cells along the X,Y and Z axes*/
@ -342,8 +316,7 @@ void choldc(double *C, int n);
/*grid: structure defining the grid */ /*grid: structure defining the grid */
/*output: */ /*output: */
/*i: vector with the coordinates */ /*i: vector with the coordinates */
void coordinates(int maille, int i[3],struct grid_mod grid); void coordinates(int maille, int i[3], struct grid_mod grid);
/*builds the sampled covariance function */ /*builds the sampled covariance function */
/*dimensions are even */ /*dimensions are even */
@ -352,7 +325,7 @@ void coordinates(int maille, int i[3],struct grid_mod grid);
/*variogram: structure defined above */ /*variogram: structure defined above */
/*grid: structure defined above */ /*grid: structure defined above */
/*n: number of gridblocks along X,Y and Z*/ /*n: number of gridblocks along X,Y and Z*/
void covariance(double *covar,struct vario_mod variogram, struct grid_mod grid, int n[3]); void covariance(double* covar, struct vario_mod variogram, struct grid_mod grid, int n[3]);
/*computation of the covariance matrix for the well data*/ /*computation of the covariance matrix for the well data*/
/*well coordinates are given as a number of cells */ /*well coordinates are given as a number of cells */
@ -363,8 +336,7 @@ void covariance(double *covar,struct vario_mod variogram, struct grid_mod grid,
/*variogram: structure defined above */ /*variogram: structure defined above */
/*well: structure defined above */ /*well: structure defined above */
/*grid: structure defined above */ /*grid: structure defined above */
void cov_matrix(double *C, struct vario_mod variogram, struct welldata_mod well, struct grid_mod grid); void cov_matrix(double* C, struct vario_mod variogram, struct welldata_mod well, struct grid_mod grid);
/*calculation of the covariance value for a distance h */ /*calculation of the covariance value for a distance h */
/*defined by i,j,k */ /*defined by i,j,k */
@ -383,12 +355,11 @@ void cov_matrix(double *C, struct vario_mod variogram, struct welldata_mod well,
/*dj: distance along the Y axis */ /*dj: distance along the Y axis */
/*dk: distance along the Z axis */ /*dk: distance along the Z axis */
/* The returned value is the computed covariance value */ /* The returned value is the computed covariance value */
double cov_value(struct vario_mod variogram,double di,double dj,double dk); double cov_value(struct vario_mod variogram, double di, double dj, double dk);
/*cubic covariance value for lag h*/ /*cubic covariance value for lag h*/
double cubic(double h); double cubic(double h);
/*truncation of the power spectrum to remove */ /*truncation of the power spectrum to remove */
/*high frequencies - isotropic case */ /*high frequencies - isotropic case */
/*covar: power spectrum */ /*covar: power spectrum */
@ -396,8 +367,7 @@ double cubic(double h);
/*ky: number of cells to save along the y-axis */ /*ky: number of cells to save along the y-axis */
/*kz: number of cells to save along the z-axis */ /*kz: number of cells to save along the z-axis */
/*n[3]: number of cells along the X, Y and Z axes*/ /*n[3]: number of cells along the X, Y and Z axes*/
void cutspectr(float *covar, int kx, int ky, int kz, int n[3]); void cutspectr(float* covar, int kx, int ky, int kz, int n[3]);
/*defines the threshold interval for a facies x*/ /*defines the threshold interval for a facies x*/
/*lim_inf: lower bound */ /*lim_inf: lower bound */
@ -406,8 +376,7 @@ void cutspectr(float *covar, int kx, int ky, int kz, int n[3]);
/*thresholds: Gaussian threshold vector */ /*thresholds: Gaussian threshold vector */
/*facies: structure defined above */ /*facies: structure defined above */
/*nblock: gridcell number of point x */ /*nblock: gridcell number of point x */
void deflimit(double *plim_inf, double *plim_sup, float x, float *thresholds, struct statfacies_mod facies,int nblock); void deflimit(double* plim_inf, double* plim_sup, float x, float* thresholds, struct statfacies_mod facies, int nblock);
/*kriges the realization considering weights */ /*kriges the realization considering weights */
/*realin: input realization */ /*realin: input realization */
@ -417,14 +386,11 @@ void deflimit(double *plim_inf, double *plim_sup, float x, float *thresholds, st
/*grid: structure defined above */ /*grid: structure defined above */
/*D: weight vector of length Ndata, Di, i = 0...Ndata-1*/ /*D: weight vector of length Ndata, Di, i = 0...Ndata-1*/
/*The kriged realization is stored in realout */ /*The kriged realization is stored in realout */
void dual_kri(struct realization_mod *realin, struct vario_mod variogram,struct welldata_mod well, struct grid_mod grid, double *D,struct realization_mod *realout); void dual_kri(struct realization_mod* realin, struct vario_mod variogram, struct welldata_mod well, struct grid_mod grid, double* D, struct realization_mod* realout);
/*exponential covariance value for lag h*/ /*exponential covariance value for lag h*/
double exponential(double h); double exponential(double h);
/*Fast Fourier Transform - Cooley-Tukey algorithm */ /*Fast Fourier Transform - Cooley-Tukey algorithm */
/*datar: real part vector - to be transformed */ /*datar: real part vector - to be transformed */
/*datai: imaginary part vector - to be transformed */ /*datai: imaginary part vector - to be transformed */
@ -435,44 +401,36 @@ double exponential(double h);
/*workr: utility real part vector for storage */ /*workr: utility real part vector for storage */
/*worki: utility imaginary part vector for storage */ /*worki: utility imaginary part vector for storage */
/*The transformed data are returned in datar and datai*/ /*The transformed data are returned in datar and datai*/
void fourt(double *datar,double *datai, int nn[3], int ndim, int ifrwd, int icplx,double *workr,double *worki); void fourt(double* datar, double* datai, int nn[3], int ndim, int ifrwd, int icplx, double* workr, double* worki);
/*calculates F(x) = (1/a)*exp(-x*x/2)*/ /*calculates F(x) = (1/a)*exp(-x*x/2)*/
double funtrun1(double x); double funtrun1(double x);
/*cumulative standard normal value*/ /*cumulative standard normal value*/
float G(float x); float G(float x);
/*gamma covariance value for lag h and exponent alpha*/ /*gamma covariance value for lag h and exponent alpha*/
double gammf(double h, double alpha); double gammf(double h, double alpha);
/*returns the value ln(G(x))*/ /*returns the value ln(G(x))*/
float gammln(float xx); float gammln(float xx);
/*incomplete gamma fnction*/ /*incomplete gamma fnction*/
float gammp(float a, float x); float gammp(float a, float x);
/*returns a normally distributed deviate with 0 mean*/ /*returns a normally distributed deviate with 0 mean*/
/*and unit variance, using ran1(idum) as the source */ /*and unit variance, using ran1(idum) as the source */
/*of uniform deviates */ /*of uniform deviates */
/*idum: seed */ /*idum: seed */
double gasdev(long *idum, long *idum2, long *iy, long *iv, int *iset); double gasdev(long* idum, long* idum2, long* iy, long* iv, int* iset);
/*gaussian covariance value for lag h*/ /*gaussian covariance value for lag h*/
double gaussian(double h); double gaussian(double h);
/*incomplete gamma function evaluated by its continued */ /*incomplete gamma function evaluated by its continued */
/*fraction represented as gammcf, also returns ln(G(a))*/ /*fraction represented as gammcf, also returns ln(G(a))*/
/*as gln */ /*as gln */
void gcf(float *gammcf, float a, float x, float *gln); void gcf(float* gammcf, float a, float x, float* gln);
/*computation of the covariance matrix for the well data*/ /*computation of the covariance matrix for the well data*/
/*well coordinates have no specific unit */ /*well coordinates have no specific unit */
@ -483,8 +441,7 @@ void gcf(float *gammcf, float a, float x, float *gln);
/*and k = j+i(i+1)/2 */ /*and k = j+i(i+1)/2 */
/*variogram: structure defined above */ /*variogram: structure defined above */
/*well: structure defined above */ /*well: structure defined above */
void gen_cov_matrix(double *C, struct vario_mod variogram, struct welldata_mod well, int n); void gen_cov_matrix(double* C, struct vario_mod variogram, struct welldata_mod well, int n);
/*Ginv */ /*Ginv */
/*Computes the inverse of the standard normal cumulative*/ /*Computes the inverse of the standard normal cumulative*/
@ -495,7 +452,6 @@ void gen_cov_matrix(double *C, struct vario_mod variogram, struct welldata_mod w
/*p: cumulative probability value */ /*p: cumulative probability value */
float Ginv(float p); float Ginv(float p);
/*gradual combination of 1 realization + Nadded */ /*gradual combination of 1 realization + Nadded */
/*complementary realizations */ /*complementary realizations */
/*rho: gradual deformation parameters */ /*rho: gradual deformation parameters */
@ -511,8 +467,7 @@ float Ginv(float p);
/*n: number of components per realization */ /*n: number of components per realization */
/*NZONES: number of subregions */ /*NZONES: number of subregions */
/*grid: grid definition */ /*grid: grid definition */
void gradual(struct grad_mod grad,float *Zo,float *Z,float *Zfinal,int n,struct grid_mod grid); void gradual(struct grad_mod grad, float* Zo, float* Z, float* Zfinal, int n, struct grid_mod grid);
/*computes the size of the underlying grid for FFTs*/ /*computes the size of the underlying grid for FFTs*/
/*input: */ /*input: */
@ -527,8 +482,7 @@ void cgrid(struct vario_mod variogram, struct grid_mod grid, int n[3]);
/*incomplete gamma function evaluated by its series*/ /*incomplete gamma function evaluated by its series*/
/*representation as gamser, also returns ln(G(a)) */ /*representation as gamser, also returns ln(G(a)) */
/*as gln */ /*as gln */
void gser(float *gamser, float a, float x, float *gln); void gser(float* gamser, float a, float x, float* gln);
/*calculates x so that x = invF(u) */ /*calculates x so that x = invF(u) */
/*F is the cumulative density function for the */ /*F is the cumulative density function for the */
@ -539,18 +493,16 @@ void gser(float *gamser, float a, float x, float *gln);
/*C: normalizing constant */ /*C: normalizing constant */
double invtrun1(double u, double lim_inf, double lim_sup, double C); double invtrun1(double u, double lim_inf, double lim_sup, double C);
/*computes the kriging mean and variance*/ /*computes the kriging mean and variance*/
/*for the vector bi, i = [0...n-1] */ /*for the vector bi, i = [0...n-1] */
void krig_stat(float *b, int n, struct vario_mod variogram, struct welldata_mod well, float *mean, float *var); void krig_stat(float* b, int n, struct vario_mod variogram, struct welldata_mod well, float* mean, float* var);
/* computes the number of gridblocks for one dimension*/ /* computes the number of gridblocks for one dimension*/
/*N: initial number of gridblocks */ /*N: initial number of gridblocks */
/*i: considered direction */ /*i: considered direction */
/*scf: correlation length */ /*scf: correlation length */
/*ap: normalized anisotropy axes */ /*ap: normalized anisotropy axes */
int length(int N, int i, double *scf, double *ap, double D, int Nvari); int length(int N, int i, double* scf, double* ap, double D, int Nvari);
/*calculates L.Z/ /*calculates L.Z/
/* L : lower triangular matrix recorded */ /* L : lower triangular matrix recorded */
@ -561,7 +513,7 @@ int length(int N, int i, double *scf, double *ap, double D, int Nvari);
/* n : dimension of matrix Lij */ /* n : dimension of matrix Lij */
/* */ /* */
/* The solution vector is returned in b */ /* The solution vector is returned in b */
void LtimeZ(double *L, float *Z, float *b, int n); void LtimeZ(double* L, float* Z, float* b, int n);
/*determines the greatest prime factor of an integer*/ /*determines the greatest prime factor of an integer*/
int maxfactor(int n); int maxfactor(int n);
@ -571,40 +523,32 @@ int maxfactor(int n);
/*defined by the probability ratio "ratio". */ /*defined by the probability ratio "ratio". */
/*If ratio >= 1, metrop = 1(true), while if ratio < 1, */ /*If ratio >= 1, metrop = 1(true), while if ratio < 1, */
/*metrop is only true with probability "ratio" */ /*metrop is only true with probability "ratio" */
int metrop(double ratio,long *idum,long *idum2, long *iy, long *iv); int metrop(double ratio, long* idum, long* idum2, long* iy, long* iv);
/*2-norm of vector b */ /*2-norm of vector b */
/* b : vector */ /* b : vector */
/* n : length of b, bi, i = [0...n-1]*/ /* n : length of b, bi, i = [0...n-1]*/
/*returns the norm of b */ /*returns the norm of b */
double norm(double *b,int n); double norm(double* b, int n);
/*value of g(x) where g is the normal function*/ /*value of g(x) where g is the normal function*/
double normal(double x); double normal(double x);
/*nugget covariance value for lag h*/ /*nugget covariance value for lag h*/
double nugget(double h); double nugget(double h);
/*power covariance value for lag h and exponent alpha*/ /*power covariance value for lag h and exponent alpha*/
double power(double h,double alpha); double power(double h, double alpha);
/*generates uniform deviates between 0 and 1*/ /*generates uniform deviates between 0 and 1*/
/*idum: seed */ /*idum: seed */
double ran2(long *idum, long *idum2, long *iy, long *iv); double ran2(long* idum, long* idum2, long* iy, long* iv);
/*calculates bt.b */ /*calculates bt.b */
/* b : vector, bi, i = [0...n-1] */ /* b : vector, bi, i = [0...n-1] */
/* n : length of b */ /* n : length of b */
/*returns the scalar product of b*/ /*returns the scalar product of b*/
double scal_vec(double *b,int n); double scal_vec(double* b, int n);
/*solves the set of n linear equations Cx = D */ /*solves the set of n linear equations Cx = D */
/* C : symmetric positive-definite matrix recorded */ /* C : symmetric positive-definite matrix recorded */
@ -615,32 +559,26 @@ double scal_vec(double *b,int n);
/* */ /* */
/* The solution vector is returned in D */ /* The solution vector is returned in D */
/* CONJUGATE GRADIENT method */ /* CONJUGATE GRADIENT method */
void solve3(double *C, double *D, int n); void solve3(double* C, double* D, int n);
/*sorts an array [0...n-1] into ascending order using */ /*sorts an array [0...n-1] into ascending order using */
/*shell */ /*shell */
void sort(float n, float *arr); void sort(float n, float* arr);
/*spherical covariance value for lag h*/ /*spherical covariance value for lag h*/
double spherical(double h); double spherical(double h);
/*stable covariance value for lag h and exponent alpha*/ /*stable covariance value for lag h and exponent alpha*/
double stable(double h, double alpha); double stable(double h, double alpha);
/*conversion of log mean and variance to nor*/ /*conversion of log mean and variance to nor*/
void statlog2nor(struct statistic_mod *pstat); void statlog2nor(struct statistic_mod* pstat);
/*tries factor */ /*tries factor */
/*pnum: number to be decomposed */ /*pnum: number to be decomposed */
/*fact: suggested factor */ /*fact: suggested factor */
/*pmaxfac: memory to keep the greatest factor*/ /*pmaxfac: memory to keep the greatest factor*/
int test_fact(int *pnum, int fact, int *pmaxfac); int test_fact(int* pnum, int fact, int* pmaxfac);
/*calculates the integrale of an approximate function*/ /*calculates the integrale of an approximate function*/
/*for the Gaussian function over an interval defined */ /*for the Gaussian function over an interval defined */
@ -649,29 +587,25 @@ int test_fact(int *pnum, int fact, int *pmaxfac);
/*lim_sup: upper bound of the considered interval */ /*lim_sup: upper bound of the considered interval */
double trun1(double lim_inf, double lim_sup); double trun1(double lim_inf, double lim_sup);
/*draws a truncated gaussian variable between lim_inf*/ /*draws a truncated gaussian variable between lim_inf*/
/*and lim_sup */ /*and lim_sup */
/*idum: seed */ /*idum: seed */
double trungasdev(long *idum,double lim_inf,double lim_sup,long *idum2, long *iy, long iv[NTAB]); double trungasdev(long* idum, double lim_inf, double lim_sup, long* idum2, long* iy, long iv[NTAB]);
/* tb1.b2 */ /* tb1.b2 */
/* b1 : vector */ /* b1 : vector */
/* b2 : vector */ /* b2 : vector */
/* n : length of b1 and b2, bi, i = [0...n-1]*/ /* n : length of b1 and b2, bi, i = [0...n-1]*/
/*returns the norm the product tb1.b2 */ /*returns the norm the product tb1.b2 */
double vec_vec(double *b1, double *b2,int n); double vec_vec(double* b1, double* b2, int n);
/*turns the volume fractions into Gaussian thresholds */ /*turns the volume fractions into Gaussian thresholds */
/*facies: structure defined above */ /*facies: structure defined above */
/*thresholds: output threshold vector fot i = [0...n-1]*/ /*thresholds: output threshold vector fot i = [0...n-1]*/
/*where n is the number of facies-1 */ /*where n is the number of facies-1 */
/*USES normal*/ /*USES normal*/
void vf2gthres(struct statfacies_mod facies,float *thresholds); void vf2gthres(struct statfacies_mod facies, float* thresholds);
void polint(float xa[],float ya[],int n,float x, float *y,float *dy);
void polint(float xa[], float ya[], int n, float x, float* y, float* dy);
#endif #endif

@ -1,7 +1,7 @@
#include <stdlib.h>
#include <string.h>
#include "genlib.h" #include "genlib.h"
#include "geostat.h" #include "geostat.h"
#include <stdlib.h>
#include <string.h>
#ifndef _PRESSURE_H #ifndef _PRESSURE_H
#define _PRESSURE_H #define _PRESSURE_H
@ -14,8 +14,7 @@
/* y: macroscopic gradient value in x direction */ /* y: macroscopic gradient value in x direction */
/* z: macroscopic gradient value in x direction */ /* z: macroscopic gradient value in x direction */
struct pressure_mod { struct pressure_mod {
double x,y,z; double x, y, z;
}; };
#endif // define _PRESSURE_H #endif // define _PRESSURE_H

@ -23,7 +23,7 @@
*/ */
#ifndef RAND_MAX #ifndef RAND_MAX
# define RAND_MAX ((int) ((unsigned) ~0 >> 1)) #define RAND_MAX ((int)((unsigned)~0 >> 1))
#endif #endif
/* /*

@ -60,7 +60,7 @@
* internal representation are hidden from the client. * internal representation are hidden from the client.
*/ */
typedef struct scannerCDT *scannerADT; typedef struct scannerCDT* scannerADT;
/* /*
* Function: NewScanner * Function: NewScanner
@ -151,7 +151,8 @@ void SaveToken(scannerADT scanner, string token);
* of this option. * of this option.
*/ */
typedef enum { PreserveSpaces, IgnoreSpaces } spaceOptionT; typedef enum { PreserveSpaces,
IgnoreSpaces } spaceOptionT;
void SetScannerSpaceOption(scannerADT scanner, spaceOptionT option); void SetScannerSpaceOption(scannerADT scanner, spaceOptionT option);
spaceOptionT GetScannerSpaceOption(scannerADT scanner); spaceOptionT GetScannerSpaceOption(scannerADT scanner);

@ -70,6 +70,6 @@ string GetLine(void);
* is at the end-of-file position. * is at the end-of-file position.
*/ */
string ReadLine(FILE *infile); string ReadLine(FILE* infile);
#endif #endif

@ -22,7 +22,7 @@
* be changed by editing this definition line. * be changed by editing this definition line.
*/ */
typedef void *stackElementT; typedef void* stackElementT;
/* /*
* Type: stackADT * Type: stackADT
@ -34,7 +34,7 @@ typedef void *stackElementT;
* the underlying fields. * the underlying fields.
*/ */
typedef struct stackCDT *stackADT; typedef struct stackCDT* stackADT;
/* /*
* Function: NewStack * Function: NewStack

@ -15,7 +15,7 @@
* This type is the ADT used to represent a symbol table. * This type is the ADT used to represent a symbol table.
*/ */
typedef struct symtabCDT *symtabADT; typedef struct symtabCDT* symtabADT;
/* /*
* Type: symtabFnT * Type: symtabFnT
@ -24,8 +24,8 @@ typedef struct symtabCDT *symtabADT;
* map over the entries in a symbol table. * map over the entries in a symbol table.
*/ */
typedef void (*symtabFnT)(string key, void *value, typedef void (*symtabFnT)(string key, void* value,
void *clientData); void* clientData);
/* Exported entries */ /* Exported entries */
@ -55,7 +55,7 @@ void FreeSymbolTable(symtabADT table);
* Each call to Enter supersedes any previous definition for key. * Each call to Enter supersedes any previous definition for key.
*/ */
void Enter(symtabADT table, string key, void *value); void Enter(symtabADT table, string key, void* value);
/* /*
* Function: Lookup * Function: Lookup
@ -65,7 +65,7 @@ void Enter(symtabADT table, string key, void *value);
* table, or UNDEFINED, if no such value exists. * table, or UNDEFINED, if no such value exists.
*/ */
void *Lookup(symtabADT table, string key); void* Lookup(symtabADT table, string key);
/* /*
* Function: MapSymbolTable * Function: MapSymbolTable
@ -80,6 +80,6 @@ void *Lookup(symtabADT table, string key);
*/ */
void MapSymbolTable(symtabFnT fn, symtabADT table, void MapSymbolTable(symtabFnT fn, symtabADT table,
void *clientData); void* clientData);
#endif #endif

@ -1,7 +1,7 @@
#include <stdlib.h>
#include <string.h>
#include "genlib.h" #include "genlib.h"
#include "geostat.h" #include "geostat.h"
#include <stdlib.h>
#include <string.h>
#ifndef _TOOLSFFTMA_H #ifndef _TOOLSFFTMA_H
#define _TOOLSFFTMA_H #define _TOOLSFFTMA_H
@ -13,7 +13,6 @@
/* ------------------ */ /* ------------------ */
/* kgeneration, FFTMA2, prebuild_gwn, build_real, , clean_real */ /* kgeneration, FFTMA2, prebuild_gwn, build_real, , clean_real */
/*FAST FOURIER TRANSFORM Pressure Simulation */ /*FAST FOURIER TRANSFORM Pressure Simulation */
/*Turns a Gaussian white noise vector into a */ /*Turns a Gaussian white noise vector into a */
/*spatially correlated vector */ /*spatially correlated vector */
@ -37,7 +36,7 @@
/*realout4: structure defining a yvelocity field */ /*realout4: structure defining a yvelocity field */
/*realout5: structure defining a zvelocity field */ /*realout5: structure defining a zvelocity field */
void FFTMA2(struct vario_mod variogram,struct grid_mod grid,int n[3],struct realization_mod *realin,struct realization_mod *realout); void FFTMA2(struct vario_mod variogram, struct grid_mod grid, int n[3], struct realization_mod* realin, struct realization_mod* realout);
/* prebuild_gwn */ /* prebuild_gwn */
/* Produce a first construction in real space of the Gaussian white noise */ /* Produce a first construction in real space of the Gaussian white noise */
@ -52,7 +51,7 @@ void FFTMA2(struct vario_mod variogram,struct grid_mod grid,int n[3],struct real
/* must be a Gaussian white noise */ /* must be a Gaussian white noise */
/*realization: structure defining a realization*/ /*realization: structure defining a realization*/
void prebuild_gwn(struct grid_mod grid,int n[3],struct realization_mod *realin,double *realization,int solver); void prebuild_gwn(struct grid_mod grid, int n[3], struct realization_mod* realin, double* realization, int solver);
/* build_real */ /* build_real */
/* build a realization in the spectral domain */ /* build a realization in the spectral domain */
@ -66,8 +65,8 @@ void prebuild_gwn(struct grid_mod grid,int n[3],struct realization_mod *realin,d
/*realization: vector defining the real part */ /*realization: vector defining the real part */
/*ireal: vector defining the i-part */ /*ireal: vector defining the i-part */
void build_real(int n[3],int NTOT,double *covar,double *realization,double *ireal); void build_real(int n[3], int NTOT, double* covar, double* realization, double* ireal);
void clean_real(struct realization_mod *realin,int n[3],struct grid_mod grid,double *vectorresult,struct realization_mod *realout); void clean_real(struct realization_mod* realin, int n[3], struct grid_mod grid, double* vectorresult, struct realization_mod* realout);
#endif // define _TOOLSFFTMA_H #endif // define _TOOLSFFTMA_H

@ -1,7 +1,6 @@
#include <string.h>
#include "geostat.h" #include "geostat.h"
#include "pressure.h" #include "pressure.h"
#include <string.h>
#ifndef _TOOLSFFTPSIM_H #ifndef _TOOLSFFTPSIM_H
#define _TOOLSFFTPSIM_H #define _TOOLSFFTPSIM_H
@ -15,9 +14,9 @@
/*Functions */ /*Functions */
/*----------*/ /*----------*/
void FFTPSim(struct vario_mod variogram,struct statistic_mod stat,struct grid_mod grid,int n[3],struct realization_mod *realin,struct pressure_mod gradient,struct realization_mod *realout,struct realization_mod *realout2,struct realization_mod *realout3,struct realization_mod *realout4,struct realization_mod *realout5); void FFTPSim(struct vario_mod variogram, struct statistic_mod stat, struct grid_mod grid, int n[3], struct realization_mod* realin, struct pressure_mod gradient, struct realization_mod* realout, struct realization_mod* realout2, struct realization_mod* realout3, struct realization_mod* realout4, struct realization_mod* realout5);
void normAxes(double *vec, double *normed); void normAxes(double* vec, double* normed);
void waveVectorCompute1D(int n,double *vec); void waveVectorCompute1D(int n, double* vec);
#endif // define _TOOLSFFTPSIM_H #endif // define _TOOLSFFTPSIM_H

@ -1,8 +1,8 @@
#include <stdlib.h>
#include <string.h>
#include "genlib.h" #include "genlib.h"
#include "geostat.h" #include "geostat.h"
#include "pressure.h" #include "pressure.h"
#include <stdlib.h>
#include <string.h>
#ifndef _TOOLSIO_H #ifndef _TOOLSIO_H
#define _TOOLSIO_H #define _TOOLSIO_H
@ -14,11 +14,10 @@
/* ------------------ */ /* ------------------ */
/* testmemory */ /* testmemory */
/*FUNCTIONS*/ /*FUNCTIONS*/
/*----------*/ /*----------*/
/* Allocation test */ /* Allocation test */
void testmemory(double *realint); void testmemory(double* realint);
#endif // define _TOOLSIO_H #endif // define _TOOLSIO_H

@ -1,20 +1,20 @@
#include <Python.h>
#include <numpy/arrayobject.h>
#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include <math.h>
#include "Py_py-api.h" #include "Py_py-api.h"
#include "genlib.h"
#include "simpio.h"
#include "condor.h" #include "condor.h"
#include "genlib.h"
#include "geostat.h" #include "geostat.h"
#include "toolsIO.h"
#include "toolsFFTMA.h"
#include "pressure.h" #include "pressure.h"
#include "simpio.h"
#include "toolsFFTMA.h"
#include "toolsFFTPSIM.h" #include "toolsFFTPSIM.h"
#include "toolsIO.h"
#include <Python.h>
#include <math.h>
#include <numpy/arrayobject.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define NDIMENSIONS 3 #define NDIMENSIONS 3
/* Z is the GWN with 0-mean and 1-variance */ /* Z is the GWN with 0-mean and 1-variance */
@ -23,43 +23,38 @@
static PyObject* genFunc(PyObject* self, PyObject* args) static PyObject* genFunc(PyObject* self, PyObject* args)
{ {
int n[3]; int n[3];
struct realization_mod Z,Y,Y1; struct realization_mod Z, Y, Y1;
struct grid_mod grid; struct grid_mod grid;
struct vario_mod variogram; struct vario_mod variogram;
long seed; long seed;
struct statistic_mod stat; struct statistic_mod stat;
PyObject* out_array; PyObject* out_array;
npy_intp out_dims[NPY_MAXDIMS]; npy_intp out_dims[NPY_MAXDIMS];
if(!Py_getvalues(args, &seed, &grid, &variogram, &stat)) return NULL;
Py_kgeneration(seed,grid,stat,variogram,&Z,&Y,&Y1,n);
out_dims[0]=grid.NZ;
out_dims[1]=grid.NY;
out_dims[2]=grid.NX;
if (!Py_getvalues(args, &seed, &grid, &variogram, &stat))
return NULL;
Py_kgeneration(seed, grid, stat, variogram, &Z, &Y, &Y1, n);
out_array = PyArray_SimpleNewFromData(NDIMENSIONS,out_dims,NPY_DOUBLE,Y.vector); out_dims[0] = grid.NZ;
if (out_array == NULL) out_dims[1] = grid.NY;
return NULL; out_dims[2] = grid.NX;
PyArray_ENABLEFLAGS(out_array, NPY_ARRAY_OWNDATA); out_array = PyArray_SimpleNewFromData(NDIMENSIONS, out_dims, NPY_DOUBLE, Y.vector);
if (out_array == NULL)
return NULL;
return out_array; PyArray_ENABLEFLAGS(out_array, NPY_ARRAY_OWNDATA);
return out_array;
} }
static PyMethodDef FFTMAMethods[] = {
static PyMethodDef FFTMAMethods[]= { "gen", genFunc, METH_VARARGS, "Generates a permeability 3D field." },
{ { NULL, NULL, 0, NULL }
{"gen", genFunc, METH_VARARGS, "Generates a permeability 3D field."},
{NULL, NULL, 0, NULL}
}; };
static struct PyModuleDef cFFTMADef = static struct PyModuleDef cFFTMADef = {
{
PyModuleDef_HEAD_INIT, PyModuleDef_HEAD_INIT,
"FFTMA", "", "FFTMA", "",
-1, -1,
@ -69,6 +64,6 @@ static struct PyModuleDef cFFTMADef =
PyMODINIT_FUNC PyMODINIT_FUNC
PyInit_FFTMA(void) PyInit_FFTMA(void)
{ {
import_array(); import_array();
return PyModule_Create(&cFFTMADef); return PyModule_Create(&cFFTMADef);
} }

Loading…
Cancel
Save