Linter to c files

milestone_5_without_improvements
chortas 3 years ago
parent 3210b268aa
commit 83d7d29273

@ -1,16 +1,16 @@
#include <Python.h>
#include <numpy/arrayobject.h>
#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include "Py_py-api.h"
#include "genlib.h"
#include "simpio.h"
#include "geostat.h"
#include "pressure.h"
#include "simpio.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>
#if PY_MAJOR_VERSION >= 3
#define PyIntObject PyLongObject
@ -40,7 +40,6 @@
#endif
#endif
int Py_getvalues(PyObject* args, long* seed, struct grid_mod* grid, struct vario_mod* variogram, struct statistic_mod* stat)
{
int i, varioNargs = 12, j = 0;
@ -51,10 +50,11 @@ int Py_getvalues(PyObject* args, long* seed,struct grid_mod* grid,struct vario_m
stat->nblock_mean = 1;
stat->nblock_var = 1;
stat->mean = (double*)malloc(stat->nblock_mean * sizeof(double));
if (stat->mean == NULL) return 0;
if (stat->mean == NULL)
return 0;
stat->variance = (double*)malloc(stat->nblock_var * sizeof(double));
if (stat->variance == NULL) return 0;
if (stat->variance == NULL)
return 0;
if (!PyArg_ParseTuple(args, "iiidddlO!ddi", /*"iiidddslO!ddi",*/
&(grid->NX),
@ -68,25 +68,30 @@ int Py_getvalues(PyObject* args, long* seed,struct grid_mod* grid,struct vario_m
&PyList_Type, &listvario,
stat->mean + 0,
stat->variance + 0,
&(stat->type))) return 0;
&(stat->type)))
return 0;
variogram->Nvario = PyList_Size(listvario);
variogram->var = (double*)malloc(variogram->Nvario * sizeof(double));
if(variogram->var==NULL) return 0;
if (variogram->var == NULL)
return 0;
variogram->vario = (int*)malloc(variogram->Nvario * sizeof(int));
if(variogram->vario==NULL) return 0;
if (variogram->vario == NULL)
return 0;
variogram->alpha = (double*)malloc(variogram->Nvario * sizeof(double));
if(variogram->alpha==NULL) return 0;
if (variogram->alpha == NULL)
return 0;
variogram->scf = (double*)malloc(3 * variogram->Nvario * sizeof(double));
if(variogram->var==NULL) return 0;
if (variogram->var == NULL)
return 0;
variogram->ap = (double*)malloc(9 * variogram->Nvario * sizeof(double));
if(variogram->var==NULL) return 0;
for(i=0;i<variogram->Nvario;i++)
{
if (variogram->var == NULL)
return 0;
for (i = 0; i < variogram->Nvario; i++) {
vgr = PyList_GetItem(listvario, i);
if(PyTuple_Size(vgr)!=12) return 0;
if (PyTuple_Size(vgr) != 12)
return 0;
(variogram->var)[i] = PyFloat_AsDouble(PyTuple_GetItem(vgr, j++));
(variogram->vario)[i] = (int)PyInt_AsLong(PyTuple_GetItem(vgr, j++));
(variogram->alpha)[i] = PyFloat_AsDouble(PyTuple_GetItem(vgr, j++));
@ -101,10 +106,5 @@ int Py_getvalues(PyObject* args, long* seed,struct grid_mod* grid,struct vario_m
(variogram->ap)[i * 9 + 5] = PyFloat_AsDouble(PyTuple_GetItem(vgr, j++));
}
return 1;
}

@ -1,16 +1,16 @@
#include <Python.h>
#include <numpy/arrayobject.h>
#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include "Py_py-api.h"
#include "genlib.h"
#include "simpio.h"
#include "geostat.h"
#include "toolsIO.h"
#include "simpio.h"
#include "toolsFFTMA.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>
/* kgeneration */
/* Z is the GWN with 0-mean and 1-variance */
@ -28,13 +28,8 @@ void Py_kgeneration(long seed,struct grid_mod grid,struct statistic_mod stat,st
n[1] = 0;
n[2] = 0;
generate(&seed, N, Z);
/*FFTMA*/
FFTMA2(variogram, grid, n, Z, Y);

@ -7,7 +7,6 @@ void axes(double *ap,double *scf,int N)
double sclpdt, r, eps = 1.E-6;
int i, j, k;
for (k = 0; k < N; k++) {
r = sqrt(ap[9 * k] * ap[9 * k] + ap[9 * k + 1] * ap[9 * k + 1] + ap[9 * k + 2] * ap[9 * k + 2]);
@ -34,8 +33,6 @@ void axes(double *ap,double *scf,int N)
}
}
}
}
return;
}

@ -1,10 +1,10 @@
#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include "geostat.h"
#include <math.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "geostat.h"
#include <string.h>
/* build_real */
/* build a realization in the spectral domain */

@ -1,6 +1,6 @@
#include <stdio.h>
#include <math.h>
#include "genlib.h"
#include <math.h>
#include <stdio.h>
/*cardsin covariance function*/
double cardsin(double h)

@ -1,6 +1,5 @@
#include <stdlib.h>
#include "geostat.h"
#include <stdlib.h>
/*computes the size of the grid for FFTs*/
/*input: */

@ -1,10 +1,10 @@
#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include "geostat.h"
#include <math.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "geostat.h"
#include <string.h>
void clean_real(struct realization_mod* realin, int n[3], struct grid_mod grid, double* vectorresult, struct realization_mod* realout)
{
@ -15,11 +15,9 @@ void clean_real(struct realization_mod *realin,int n[3],struct grid_mod grid,dou
/*is the output realization already allocated?*/
/*if not, memory allocation*/
if ((*realout).vector == NULL || (*realout).n != (*realin).n)
{
if ((*realout).vector == NULL || (*realout).n != (*realin).n) {
(*realout).vector = (double*)malloc((*realin).n * sizeof(double));
if ((*realout).vector == NULL)
{
if ((*realout).vector == NULL) {
printf("Clean_real.c: No memory available\n");
exit;
}

@ -1,6 +1,6 @@
#include <math.h>
#include "geostat.h"
#include "genlib.h"
#include "geostat.h"
#include <math.h>
/*selection of model covariance*/
double cov_value(struct vario_mod variogram, double di, double dj, double dk)
@ -18,7 +18,6 @@ double cov_value(struct vario_mod variogram,double di,double dj,double dk)
hz = di * variogram.ap[9 * k + 6] + dj * variogram.ap[9 * k + 7] + dk * variogram.ap[9 * k + 8];
h = sqrt(hx * hx + hy * hy + hz * hz);
switch (variogram.vario[k]) {
case 1:
cov += variogram.var[k] * exponential(h);

@ -15,7 +15,6 @@ void covariance(double *covar, struct vario_mod variogram, struct grid_mod mesh,
for (j = 0; j <= n2[1]; j++) {
for (k = 0; k <= n2[2]; k++) {
/*area 1*/
maille = 1 + i + n[0] * (j + n[1] * k);
di = (double)i * mesh.DX;
@ -23,14 +22,12 @@ void covariance(double *covar, struct vario_mod variogram, struct grid_mod mesh,
dk = (double)k * mesh.DZ;
covar[maille] = (double)cov_value(variogram, di, dj, dk);
if (k > 0 && k < n2[2] && j > 0 && j < n2[1] && i > 0 && i < n2[0]) {
/*area 2*/
symmetric = 1 + n[0] - i + n[0] * (n[1] - j + n[1] * (n[2] - k));
covar[symmetric] = covar[maille];
}
if (i > 0 && i < n2[0]) {
/*area 4*/
di = -(double)i * mesh.DX;
@ -40,14 +37,12 @@ void covariance(double *covar, struct vario_mod variogram, struct grid_mod mesh,
covar[maille] = (double)cov_value(variogram, di, dj, dk);
}
if (k > 0 && k < n2[2] && j > 0 && j < n2[1]) {
/*area 8*/
symmetric = 1 + i + n[0] * (n[1] - j + n[1] * (n[2] - k));
covar[symmetric] = covar[maille];
}
if (i > 0 && i < n2[0] && j > 0 && j < n2[1]) {
/*area 5*/
di = -(double)i * mesh.DX;
@ -57,14 +52,12 @@ void covariance(double *covar, struct vario_mod variogram, struct grid_mod mesh,
covar[maille] = (double)cov_value(variogram, di, dj, dk);
}
if (k > 0 && k < n2[2]) {
/*area 6*/
symmetric = 1 + i + n[0] * (j + n[1] * (n[2] - k));
covar[symmetric] = covar[maille];
}
if (j > 0 && j < n2[1]) {
/*area 3*/
di = (double)i * mesh.DX;
@ -74,13 +67,11 @@ void covariance(double *covar, struct vario_mod variogram, struct grid_mod mesh,
covar[maille] = (double)cov_value(variogram, di, dj, dk);
}
if (k > 0 && k < n2[2] && i > 0 && i < n2[0]) {
/*area 7*/
symmetric = 1 + n[0] - i + n[0] * (j + n[1] * (n[2] - k));
covar[symmetric] = covar[maille];
}
}
}
}

@ -1,7 +1,6 @@
#include <stdio.h>
#include <math.h>
#include "genlib.h"
#include <math.h>
#include <stdio.h>
/*cubic covariance function*/
double cubic(double h)

@ -1,6 +1,6 @@
#include <stdio.h>
#include <math.h>
#include "genlib.h"
#include <math.h>
#include <stdio.h>
/*exponential covariance function*/
double exponential(double h)

@ -1,8 +1,7 @@
#include "geostat.h"
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "geostat.h"
/*FAST FOURIER TRANSFORM MOVING AVERAGE METHOD */
/*Turns a Gaussian white noise vector into a */
@ -87,7 +86,6 @@ void FFTMA2(struct vario_mod variogram,struct grid_mod grid,int n[3],struct real
/*backward fourier transform*/
fourt(realization, ireal, n, NDIM, 0, 1, workr, worki);
free(ireal);
free(workr);
free(worki);
@ -99,7 +97,3 @@ void FFTMA2(struct vario_mod variogram,struct grid_mod grid,int n[3],struct real
return;
}

@ -1,5 +1,5 @@
#include <stdio.h>
#include <math.h>
#include <stdio.h>
/*fast fourier transform */
/* THE COOLEY-TUKEY FAST FOURIER TRANSFORM */
@ -89,7 +89,6 @@
/* PROGRAM MODIFIED FROM A SUBROUTINE OF BRENNER */
/* 10-06-2000, MLR */
void fourt(double* datar, double* datai, int nn[3], int ndim, int ifrwd, int icplx, double* workr, double* worki)
{
int ifact[21], ntot, idim, np1, n, np2, m, ntwo, iff, idiv, iquot, irem, inon2, non2p, np0, nprev, icase, ifmin, i, j, jmax, np2hf, i2, i1max, i3, j3, i1, ifp1, ifp2, i2max, i1rng, istep, imin, imax, mmax, mmin, mstep, j1, j2max, j2, jmin, j3max, nhalf;
@ -161,7 +160,6 @@ void fourt(double *datar,double *datai, int nn[3], int ndim, int ifrwd, int icpl
L70:
non2p = np2 / ntwo;
/*SEPARATE FOUR CASES--
1. COMPLEX TRANSFORM
2. REAL TRANSFORM FOR THE 2ND, 3RD, ETC. DIMENSION. METHOD: TRANSFORM HALF THE DATA, SUPPLYING THE OTHER HALF BY CONJUGATE SYMMETRY.
@ -225,7 +223,6 @@ void fourt(double *datar,double *datai, int nn[3], int ndim, int ifrwd, int icpl
if (m >= np1)
goto L140;
}
}
goto L300;
@ -262,7 +259,6 @@ void fourt(double *datar,double *datai, int nn[3], int ndim, int ifrwd, int icpl
datai[i2] = worki[i];
i++;
}
}
}

@ -1,7 +1,6 @@
#include <stdio.h>
#include <math.h>
#include "genlib.h"
#include <math.h>
#include <stdio.h>
/*gamma covariance function*/
double gammf(double h, double alpha)
@ -13,4 +12,3 @@ double gammf(double h, double alpha)
z = 1. / (double)(pow(1. + h * delta, alpha));
return (z);
}

@ -1,5 +1,5 @@
#include <math.h>
#include "genlib.h"
#include <math.h>
#define NTAB 32

@ -1,7 +1,6 @@
#include <stdio.h>
#include <math.h>
#include "genlib.h"
#include <math.h>
#include <stdio.h>
/*gaussian covariance function*/
double gaussian(double h)

@ -1,7 +1,6 @@
#include <stdlib.h>
#include <math.h>
#include "geostat.h"
#include <math.h>
#include <stdlib.h>
/* GENERATION OF A GAUSSIAN WHITE NOISE VECTOR */
/*input: */
@ -38,6 +37,3 @@ void generate(long *seed, int n, struct realization_mod *realization)
return;
}

@ -7,10 +7,10 @@
* interface description in genlib.h for details.
*/
#include <stdio.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include "genlib.h"
@ -39,7 +39,8 @@ void *GetBlock(size_t nbytes)
void* result;
result = malloc(nbytes);
if (result == NULL) Error("No memory available");
if (result == NULL)
Error("No memory available");
return (result);
}

@ -25,9 +25,9 @@
#ifndef _genlib_h
#define _genlib_h
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
/* Section 1 -- Define new "primitive" types */
@ -56,7 +56,8 @@
#define FALSE 0
#define TRUE 1
#else
typedef enum {FALSE, TRUE} bool;
typedef enum { FALSE,
TRUE } bool;
#endif
#endif
#endif

@ -1,8 +1,7 @@
#include <stdio.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#ifndef _GEOSTAT_H
#define _GEOSTAT_H
@ -27,7 +26,6 @@
/* cdf_mod */
/* realization_mod */
/* List of functions: */
/* ------------------ */
@ -44,9 +42,6 @@
/* test_fract, trun1, trungasdev,vec_vec, */
/* vf2gthres,polint */
/*STRUCTURES*/
/*----------*/
/*variogram */
@ -75,8 +70,6 @@ struct vario_mod {
double* var;
};
/*variogram table */
/*Nvario: number of combined variogram models */
/*vario: model of variogram per variogram model */
@ -104,9 +97,6 @@ struct variotable_mod {
float* var;
};
/*grid */
/*NX: number of gridblocks along the X axis*/
/*NY: number of gridblocks along the Y axis*/
@ -123,7 +113,6 @@ struct grid_mod {
double Xo, Yo, Zo;
};
/*well data */
/*nwell: number of wells */
/*n: number of measurement points per well */
@ -163,8 +152,6 @@ struct welldata_mod {
float* measure;
};
/*volume fractions for facies */
/*ncat: number of facies */
/*nblock: number of gridblocks with different */
@ -179,7 +166,6 @@ struct statfacies_mod {
float* vf;
};
/*inequalities for truncated plurigaussian realizations*/
/*only two basic realizations Y1 and Y2 are considered */
/*Y1 and Y2 are independent */
@ -209,7 +195,6 @@ struct inequalities_mod {
int* address_sY2;
};
/*statistical data */
/*type --> 0 : normal */
/* --> 1 : natural log */
@ -234,7 +219,6 @@ struct statistic_mod {
double* variance;
};
/*gradual deformation parameters */
/*Nadded: number of complementary realizations */
/*NZONES: number of subregions */
@ -250,7 +234,6 @@ struct grad_mod {
int *cellini, *cellfin;
};
/*gradient structures */
/*Nparam : number of parameters for which gradients are */
/* required */
@ -267,8 +250,6 @@ struct gradients_mod {
float* grad;
};
/*description of discretized cumulative distributions */
/*n: number of points */
/*x: values along the x axis i = [0...n-1] */
@ -280,7 +261,6 @@ struct cdf_mod {
float* fx;
};
/*realization */
/*n: number of components */
/*code: status of the realization */
@ -311,18 +291,15 @@ struct realization_mod {
/*FUNCTIONS*/
/*---------*/
/*normalization of the anostropy axes */
/*ap: anisotropy axes */
/*scf: correlation lengths */
/* The returned normalized axes are in ap */
void axes(double* ap, double* scf, int N);
/*cardsin covariance value for lag h*/
double cardsin(double h);
/*Cholesky decomposition of matrix C */
/* C : symetric positive-definite matrix recorded */
/* (per raws) as a vector with only components */
@ -332,7 +309,6 @@ double cardsin(double h);
/* C is turned into the lower triangular cholesky matrix*/
void choldc(double* C, int n);
/*computes the coordinates of a given cell */
/*as numbers of cells along the X,Y and Z axes*/
/*maille = i[0]+1+i[1]*NX+i[2]*NX*NY */
@ -343,7 +319,6 @@ void choldc(double *C, int n);
/*i: vector with the coordinates */
void coordinates(int maille, int i[3], struct grid_mod grid);
/*builds the sampled covariance function */
/*dimensions are even */
/*covar: covariance array, vector of size*/
@ -364,7 +339,6 @@ void covariance(double *covar,struct vario_mod variogram, struct grid_mod grid,
/*grid: structure defined above */
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 */
/*defined by i,j,k */
/*available variogram model: */
@ -387,7 +361,6 @@ double cov_value(struct vario_mod variogram,double di,double dj,double dk);
/*cubic covariance value for lag h*/
double cubic(double h);
/*truncation of the power spectrum to remove */
/*high frequencies - isotropic case */
/*covar: power spectrum */
@ -397,7 +370,6 @@ double cubic(double h);
/*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]);
/*defines the threshold interval for a facies x*/
/*lim_inf: lower bound */
/*lim_sup: upper bound */
@ -407,7 +379,6 @@ void cutspectr(float *covar, int kx, int ky, int kz, int n[3]);
/*nblock: gridcell number of point x */
void deflimit(double* plim_inf, double* plim_sup, float x, float* thresholds, struct statfacies_mod facies, int nblock);
/*kriges the realization considering weights */
/*realin: input realization */
/*variogram: structure defining the variogram */
@ -418,12 +389,9 @@ void deflimit(double *plim_inf, double *plim_sup, float x, float *thresholds, st
/*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);
/*exponential covariance value for lag h*/
double exponential(double h);
/*Fast Fourier Transform - Cooley-Tukey algorithm */
/*datar: real part vector - to be transformed */
/*datai: imaginary part vector - to be transformed */
@ -436,27 +404,21 @@ double exponential(double h);
/*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);
/*calculates F(x) = (1/a)*exp(-x*x/2)*/
double funtrun1(double x);
/*cumulative standard normal value*/
float G(float x);
/*gamma covariance value for lag h and exponent alpha*/
double gammf(double h, double alpha);
/*returns the value ln(G(x))*/
float gammln(float xx);
/*incomplete gamma fnction*/
float gammp(float a, float x);
/*returns a normally distributed deviate with 0 mean*/
/*and unit variance, using ran1(idum) as the source */
/*of uniform deviates */
@ -466,13 +428,11 @@ double gasdev(long *idum, long *idum2, long *iy, long *iv, int *iset);
/*gaussian covariance value for lag h*/
double gaussian(double h);
/*incomplete gamma function evaluated by its continued */
/*fraction represented as gammcf, also returns ln(G(a))*/
/*as gln */
void gcf(float* gammcf, float a, float x, float* gln);
/*computation of the covariance matrix for the well data*/
/*well coordinates have no specific unit */
/*The dimension of C is given by n */
@ -484,7 +444,6 @@ void gcf(float *gammcf, float a, float x, float *gln);
/*well: structure defined above */
void gen_cov_matrix(double* C, struct vario_mod variogram, struct welldata_mod well, int n);
/*Ginv */
/*Computes the inverse of the standard normal cumulative*/
/*distribution function with a numerical approximation */
@ -494,7 +453,6 @@ void gen_cov_matrix(double *C, struct vario_mod variogram, struct welldata_mod w
/*p: cumulative probability value */
float Ginv(float p);
/*gradual combination of 1 realization + Nadded */
/*complementary realizations */
/*rho: gradual deformation parameters */
@ -512,7 +470,6 @@ float Ginv(float p);
/*grid: grid definition */
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*/
/*input: */
/*variogram: structure defining the variogram model*/
@ -528,7 +485,6 @@ void cgrid(struct vario_mod variogram, struct grid_mod grid, int n[3]);
/*as gln */
void gser(float* gamser, float a, float x, float* gln);
/*calculates x so that x = invF(u) */
/*F is the cumulative density function for the */
/*function approximating the Gaussian function */
@ -538,12 +494,10 @@ void gser(float *gamser, float a, float x, float *gln);
/*C: normalizing constant */
double invtrun1(double u, double lim_inf, double lim_sup, double C);
/*computes the kriging mean and variance*/
/*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);
/* computes the number of gridblocks for one dimension*/
/*N: initial number of gridblocks */
/*i: considered direction */
@ -572,39 +526,31 @@ int maxfactor(int n);
/*metrop is only true with probability "ratio" */
int metrop(double ratio, long* idum, long* idum2, long* iy, long* iv);
/*2-norm of vector b */
/* b : vector */
/* n : length of b, bi, i = [0...n-1]*/
/*returns the norm of b */
double norm(double* b, int n);
/*value of g(x) where g is the normal function*/
double normal(double x);
/*nugget covariance value for lag h*/
double nugget(double h);
/*power covariance value for lag h and exponent alpha*/
double power(double h, double alpha);
/*generates uniform deviates between 0 and 1*/
/*idum: seed */
double ran2(long* idum, long* idum2, long* iy, long* iv);
/*calculates bt.b */
/* b : vector, bi, i = [0...n-1] */
/* n : length of b */
/*returns the scalar product of b*/
double scal_vec(double* b, int n);
/*solves the set of n linear equations Cx = D */
/* C : symmetric positive-definite matrix recorded */
/* (per raws) as a vector with only components */
@ -616,31 +562,25 @@ double scal_vec(double *b,int n);
/* CONJUGATE GRADIENT method */
void solve3(double* C, double* D, int n);
/*sorts an array [0...n-1] into ascending order using */
/*shell */
void sort(float n, float* arr);
/*spherical covariance value for lag h*/
double spherical(double h);
/*stable covariance value for lag h and exponent alpha*/
double stable(double h, double alpha);
/*conversion of log mean and variance to nor*/
void statlog2nor(struct statistic_mod* pstat);
/*tries factor */
/*pnum: number to be decomposed */
/*fact: suggested factor */
/*pmaxfac: memory to keep the greatest factor*/
int test_fact(int* pnum, int fact, int* pmaxfac);
/*calculates the integrale of an approximate function*/
/*for the Gaussian function over an interval defined */
/*by lim_inf and lim_sup */
@ -648,7 +588,6 @@ int test_fact(int *pnum, int fact, int *pmaxfac);
/*lim_sup: upper bound of the considered interval */
double trun1(double lim_inf, double lim_sup);
/*draws a truncated gaussian variable between lim_inf*/
/*and lim_sup */
/*idum: seed */
@ -661,7 +600,6 @@ double trungasdev(long *idum,double lim_inf,double lim_sup,long *idum2, long *iy
/*returns the norm the product tb1.b2 */
double vec_vec(double* b1, double* b2, int n);
/*turns the volume fractions into Gaussian thresholds */
/*facies: structure defined above */
/*thresholds: output threshold vector fot i = [0...n-1]*/
@ -671,6 +609,4 @@ void vf2gthres(struct statfacies_mod facies,float *thresholds);
void polint(float xa[], float ya[], int n, float x, float* y, float* dy);
#endif

@ -1,7 +1,6 @@
#include <stdlib.h>
#include <math.h>
#include "geostat.h"
#include <math.h>
#include <stdlib.h>
/*TURNS NORMAL NUMBERS INTO LOGNORMAL NUMBERS */
/*input: */
@ -19,10 +18,8 @@ void nor2log(struct realization_mod *realin, int typelog, struct realization_mod
int i;
double coeff;
coeff = log(10.0);
/*Is the output realization allocated ?*/
/*is its length equal to realin.n?*/
if ((*realout).vector == NULL || (*realout).n != (*realin).n) {
@ -34,7 +31,6 @@ void nor2log(struct realization_mod *realin, int typelog, struct realization_mod
}
(*realout).n = (*realin).n;
switch ((*realin).code) {
case 0:
case 1:
@ -55,7 +51,6 @@ void nor2log(struct realization_mod *realin, int typelog, struct realization_mod
break;
}
/*anamorphose*/
for (i = 0; i < (*realin).n; i++) {
switch (typelog) {

@ -1,7 +1,6 @@
#include <stdio.h>
#include <math.h>
#include "genlib.h"
#include <math.h>
#include <stdio.h>
/*nugget covariance function*/
double nugget(double h)

@ -1,7 +1,6 @@
#include <stdio.h>
#include <math.h>
#include "genlib.h"
#include <math.h>
#include <stdio.h>
/*power covariance function*/
double power(double h, double alpha)

@ -1,10 +1,10 @@
#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include "geostat.h"
#include <math.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "geostat.h"
#include <string.h>
/* prebuild_gwn */
/* Produce a first construction in real space of the Gaussian white noise */
@ -27,15 +27,11 @@ void prebuild_gwn(struct grid_mod grid,int n[3],struct realization_mod *realin,d
ntot = n[0] * n[1] * n[2];
realization[0] = 0.;
if (solver==1)
{
for (i=0;i<ntot;i++)
{
if (solver == 1) {
for (i = 0; i < ntot; i++) {
realization[i + 1] = (*realin).vector[i];
}
}
else
{
} else {
for (k = 1; k <= n[2]; k++) {
for (j = 1; j <= n[1]; j++) {
for (i = 1; i <= n[0]; i++) {

@ -1,7 +1,7 @@
#include <stdlib.h>
#include <string.h>
#include "genlib.h"
#include "geostat.h"
#include <stdlib.h>
#include <string.h>
#ifndef _PRESSURE_H
#define _PRESSURE_H
@ -17,5 +17,4 @@ struct pressure_mod {
double x, y, z;
};
#endif // define _PRESSURE_H

@ -23,28 +23,37 @@ double ran2(long *idum, long *idum2, long *iy, long iv[NTAB])
double temp;
if (*idum <= 0) {
if (-(*idum) < 1) *idum = 1;
else *idum = -(*idum);
if (-(*idum) < 1)
*idum = 1;
else
*idum = -(*idum);
*idum2 = (*idum);
for (j = NTAB + 7; j >= 0; j--) {
k = (*idum) / IQ1;
*idum = IA1 * (*idum - k * IQ1) - k * IR1;
if (*idum < 0) *idum += IM1;
if (j < NTAB) iv[j] = *idum;
if (*idum < 0)
*idum += IM1;
if (j < NTAB)
iv[j] = *idum;
}
*iy = iv[0];
}
k = (*idum) / IQ1;
*idum = IA1 * (*idum - k * IQ1) - k * IR1;
if (*idum < 0) *idum += IM1;
if (*idum < 0)
*idum += IM1;
k = *idum2 / IQ2;
*idum2 = IA2 * (*idum2 - k * IQ2) - k * IR2;
if (*idum2 < 0) *idum2 += IM2;
if (*idum2 < 0)
*idum2 += IM2;
j = (*iy) / NDIV;
*iy = iv[j] - (*idum2);
iv[j] = *idum;
if (*iy < 1) (*iy) += IMM1;
if ((temp = AM*(*iy)) > RNMX) return (RNMX);
else return (temp);
if (*iy < 1)
(*iy) += IMM1;
if ((temp = AM * (*iy)) > RNMX)
return (RNMX);
else
return (temp);
}

@ -4,11 +4,11 @@
* This file implements the scanadt.h interface.
*/
#include <stdio.h>
#include <ctype.h>
#include "scanadt.h"
#include "genlib.h"
#include "strlib.h"
#include "scanadt.h"
#include <ctype.h>
#include <stdio.h>
/*
* Type: scannerCDT
@ -53,13 +53,15 @@ scannerADT NewScanner(void)
void FreeScanner(scannerADT scanner)
{
if (scanner->str != NULL) FreeBlock(scanner->str);
if (scanner->str != NULL)
FreeBlock(scanner->str);
FreeBlock(scanner);
}
void SetScannerString(scannerADT scanner, string str)
{
if (scanner->str != NULL) FreeBlock(scanner->str);
if (scanner->str != NULL)
FreeBlock(scanner->str);
scanner->str = CopyString(str);
scanner->len = StringLength(str);
scanner->cp = 0;
@ -80,9 +82,11 @@ string ReadToken(scannerADT scanner)
scanner->savedToken = NULL;
return (token);
}
if (scanner->spaceOption == IgnoreSpaces) SkipSpaces(scanner);
if (scanner->spaceOption == IgnoreSpaces)
SkipSpaces(scanner);
start = finish = scanner->cp;
if (start >= scanner->len) return (CopyString(""));
if (start >= scanner->len)
return (CopyString(""));
ch = scanner->str[scanner->cp];
if (isalnum(ch)) {
finish = ScanToEndOfIdentifier(scanner);
@ -100,7 +104,8 @@ bool MoreTokensExist(scannerADT scanner)
if (scanner->savedToken != NULL) {
return (!StringEqual(scanner->savedToken, ""));
}
if (scanner->spaceOption == IgnoreSpaces) SkipSpaces(scanner);
if (scanner->spaceOption == IgnoreSpaces)
SkipSpaces(scanner);
return (scanner->cp < scanner->len);
}

@ -151,7 +151,8 @@ void SaveToken(scannerADT scanner, string token);
* of this option.
*/
typedef enum { PreserveSpaces, IgnoreSpaces } spaceOptionT;
typedef enum { PreserveSpaces,
IgnoreSpaces } spaceOptionT;
void SetScannerSpaceOption(scannerADT scanner, spaceOptionT option);
spaceOptionT GetScannerSpaceOption(scannerADT scanner);

@ -10,8 +10,8 @@
#include <string.h>
#include "genlib.h"
#include "strlib.h"
#include "simpio.h"
#include "strlib.h"
/*
* Constants:

@ -1,7 +1,6 @@
#include <stdio.h>
#include <math.h>
#include "genlib.h"
#include <math.h>
#include <stdio.h>
/*spherical covariance function*/
double spherical(double h)

@ -1,7 +1,6 @@
#include <stdio.h>
#include <math.h>
#include "genlib.h"
#include <math.h>
#include <stdio.h>
/*stable covariance function*/
double stable(double h, double alpha)

@ -7,9 +7,9 @@
* the type name stackElementT.
*/
#include <stdio.h>
#include "genlib.h"
#include "stack.h"
#include "genlib.h"
#include <stdio.h>
/*
* Constant: InitialStackSize
@ -63,13 +63,15 @@ void FreeStack(stackADT stack)
void Push(stackADT stack, stackElementT element)
{
if (stack->count == stack->size) ExpandStack(stack);
if (stack->count == stack->size)
ExpandStack(stack);
stack->elements[stack->count++] = element;
}
stackElementT Pop(stackADT stack)
{
if (StackIsEmpty(stack)) Error("Pop of an empty stack");
if (StackIsEmpty(stack))
Error("Pop of an empty stack");
return (stack->elements[--stack->count]);
}

@ -17,9 +17,9 @@
* interface.
*/
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "genlib.h"
#include "strlib.h"
@ -59,7 +59,8 @@ char IthChar(string s, int i)
{
int len;
if (s == NULL) Error("NULL string passed to IthChar");
if (s == NULL)
Error("NULL string passed to IthChar");
len = strlen(s);
if (i < 0 || i > len) {
Error("Index outside of string range in IthChar");
@ -72,12 +73,16 @@ string SubString(string s, int p1, int p2)
int len;
string result;
if (s == NULL) Error("NULL string passed to SubString");
if (s == NULL)
Error("NULL string passed to SubString");
len = strlen(s);
if (p1 < 0) p1 = 0;
if (p2 >= len) p2 = len - 1;
if (p1 < 0)
p1 = 0;
if (p2 >= len)
p2 = len - 1;
len = p2 - p1 + 1;
if (len < 0) len = 0;
if (len < 0)
len = 0;
result = CreateString(len);
strncpy(result, s + p1, len);
result[len] = '\0';
@ -96,7 +101,8 @@ string CharToString(char ch)
int StringLength(string s)
{
if (s == NULL) Error("NULL string passed to StringLength");
if (s == NULL)
Error("NULL string passed to StringLength");
return (strlen(s));
}
@ -104,7 +110,8 @@ string CopyString(string s)
{
string newstr;
if (s == NULL) Error("NULL string passed to CopyString");
if (s == NULL)
Error("NULL string passed to CopyString");
newstr = CreateString(strlen(s));
strcpy(newstr, s);
return (newstr);
@ -134,11 +141,15 @@ int FindChar(char ch, string text, int start)
{
char* cptr;
if (text == NULL) Error("NULL string passed to FindChar");
if (start < 0) start = 0;
if (start > strlen(text)) return (-1);
if (text == NULL)
Error("NULL string passed to FindChar");
if (start < 0)
start = 0;
if (start > strlen(text))
return (-1);
cptr = strchr(text + start, ch);
if (cptr == NULL) return (-1);
if (cptr == NULL)
return (-1);
return ((int)(cptr - text));
}
@ -146,12 +157,17 @@ int FindString(string str, string text, int start)
{
char* cptr;
if (str == NULL) Error("NULL pattern string in FindString");
if (text == NULL) Error("NULL text string in FindString");
if (start < 0) start = 0;
if (start > strlen(text)) return (-1);
if (str == NULL)
Error("NULL pattern string in FindString");
if (text == NULL)
Error("NULL text string in FindString");
if (start < 0)
start = 0;
if (start > strlen(text))
return (-1);
cptr = strstr(text + start, str);
if (cptr == NULL) return (-1);
if (cptr == NULL)
return (-1);
return ((int)(cptr - text));
}
@ -166,7 +182,8 @@ string ConvertToLowerCase(string s)
Error("NULL string passed to ConvertToLowerCase");
}
result = CreateString(strlen(s));
for (i = 0; s[i] != '\0'; i++) result[i] = tolower(s[i]);
for (i = 0; s[i] != '\0'; i++)
result[i] = tolower(s[i]);
result[i] = '\0';
return (result);
}
@ -180,7 +197,8 @@ string ConvertToUpperCase(string s)
Error("NULL string passed to ConvertToUpperCase");
}
result = CreateString(strlen(s));
for (i = 0; s[i] != '\0'; i++) result[i] = toupper(s[i]);
for (i = 0; s[i] != '\0'; i++)
result[i] = toupper(s[i]);
result[i] = '\0';
return (result);
}
@ -222,7 +240,8 @@ double StringToReal(string s)
double result;
char dummy;
if (s == NULL) Error("NULL string passed to StringToReal");
if (s == NULL)
Error("NULL string passed to StringToReal");
if (sscanf(s, " %lg %c", &result, &dummy) != 1) {
Error("StringToReal called on illegal number %s", s);
}

@ -4,10 +4,10 @@
* This file implements the symbol table abstraction.
*/
#include <stdio.h>
#include "symtab.h"
#include "genlib.h"
#include "strlib.h"
#include "symtab.h"
#include <stdio.h>
/*
* Constants
@ -97,7 +97,8 @@ void *Lookup(symtabADT table, string key)
bucket = Hash(key, NBuckets);
cp = FindCell(table->buckets[bucket], key);
if (cp == NULL) return(UNDEFINED);
if (cp == NULL)
return (UNDEFINED);
return (cp->value);
}

@ -22,5 +22,3 @@ int test_fact(int *pnum, int fact, int *pmaxfac)
return (0);
}

@ -1,9 +1,9 @@
#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include <math.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
void testmemory(double* realint)
{

Loading…
Cancel
Save