intermediate commit

milestone_5_without_improvements
Oli 3 years ago
parent de5f4c8fe6
commit 028d0a8d9f

@ -9,18 +9,6 @@
/*FUNCTIONS*/ /*FUNCTIONS*/
/*---------*/ /*---------*/
/*addstat */
/*adds mean and variance effects to the N(0,1) realization*/
/*input: */
/*realin: structure defining a realization - */
/* must have zero mean and unit variance */
/*stat: structure defining the mean and variance */
/*output: */
/*realout: structure defining a realization - */
void addstat(struct realization_mod *realin,struct statistic_mod stat ,struct realization_mod *realout);
/*condit */ /*condit */
/*conditioning of a Gaussian realization using */ /*conditioning of a Gaussian realization using */
/*the primal kriging approach */ /*the primal kriging approach */
@ -87,28 +75,6 @@ void dual_condit(int k,struct welldata_mod well,struct vario_mod variogram,struc
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 */
/*Turns a Gaussian white noise vector into a */
/*spatially correlated vector */
/*input: */
/*variogram: structure defining the variogram */
/* model */
/*grid: structure defining the grid */
/*n: vector with the number of cells along the */
/* X, Y and Z axes for the underlying grid */
/* i = [0 1 2] */
/* --> 0 0 0 : n will be computed and */
/* updated as output */
/* --> nx ny nz: these dimensions are used */
/*realin: structure defining a realization - */
/* must be a Gaussian white noise */
/*output: */
/*realout: structure defining a realization - */
void FFTMA(struct vario_mod variogram,struct grid_mod grid,int n[3],struct realization_mod *realin,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 */
/*CALCULATED FOR THE GRADUAL DEFORMATION PARAMETERS */ /*CALCULATED FOR THE GRADUAL DEFORMATION PARAMETERS */

@ -11,7 +11,7 @@
/* List of functions: */ /* List of functions: */
/* ------------------ */ /* ------------------ */
/* kgeneration, FFTMA2, prebuild_gwn, build_real, addstat2, clean_real */ /* kgeneration, FFTMA2, prebuild_gwn, build_real, , clean_real */
/*FUNCTIONS*/ /*FUNCTIONS*/
@ -75,8 +75,6 @@ void prebuild_gwn(struct grid_mod grid,int n[3],struct realization_mod *realin,d
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 addstat2(struct realization_mod *realin,struct statistic_mod stat ,struct realization_mod *realout,struct realization_mod *realout2);
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

@ -24,7 +24,7 @@ void pgeneration2(int n[3],struct grid_mod grid,struct statistic_mod stat,
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 FFTPressure(int n[3],struct grid_mod grid,struct realization_mod *realin,struct statistic_mod stat,struct pressure_mod gradient,struct realization_mod *realout,struct realization_mod *realout2,struct realization_mod *realout3,struct realization_mod *realout4, int solver); //void FFTPressure(int n[3],struct grid_mod grid,struct realization_mod *realin,struct statistic_mod stat,struct pressure_mod gradient,struct realization_mod *realout,struct realization_mod *realout2,struct realization_mod *realout3,struct realization_mod *realout4, int solver);
void build_pressure(int n[3],struct grid_mod grid,struct pressure_mod gradient,double *realization,double *ireal,double *pressure,double *ipressure); void build_pressure(int n[3],struct grid_mod grid,struct pressure_mod gradient,double *realization,double *ireal,double *pressure,double *ipressure);
@ -47,15 +47,11 @@ void total_pressure(struct grid_mod grid,struct pressure_mod gradient,struct rea
void total_velocity(struct grid_mod grid,double mean,int direction,struct pressure_mod gradient,struct realization_mod *realout); void total_velocity(struct grid_mod grid,double mean,int direction,struct pressure_mod gradient,struct realization_mod *realout);
void clean_real2(struct realization_mod *realin,int n[3],struct grid_mod grid,int solver,double *vectorresult,struct realization_mod *realout);
void normAxes(double *vec, double *normed); void normAxes(double *vec, double *normed);
void waveVectorCompute1D(int n,double *vec); void waveVectorCompute1D(int n,double *vec);
void waveVectorCompute3D(int nX,int nY, int nZ, /*float dX, float dY, float dZ,*/ double nDir[3], double *waveVect); void waveVectorCompute3D(int nX,int nY, int nZ, /*float dX, float dY, float dZ,*/ double nDir[3], double *waveVect);
void derivReal(struct realization_mod *Z, struct realization_mod *dZ, double *dir, struct grid_mod *grid, struct vario_mod vario);
void mat_vec(double *C, double *x, double *b, int n); void mat_vec(double *C, double *x, double *b, int n);

@ -1,110 +0,0 @@
#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 */
/*spatially correlated vector */
/*input: */
/*variogram: structure defining the variogram */
/* model */
/*grid: structure defining the grid */
/*n: vector with the number of cells along the */
/* X, Y and Z axes for the underlying grid */
/* i = [0 1 2] */
/* --> 0 0 0 : n will be computed and */
/* updated as output */
/* --> nx ny nz: these dimensions are used */
/*realin: structure defining a realization - */
/* must be a Gaussian white noise */
/*output: */
/*realout: structure defining a realization - */
void FFTMA2(struct vario_mod variogram,struct grid_mod grid,int n[3],struct realization_mod *realin,struct realization_mod *realout)
{
int NTOT,i,j,k,NMAX,NDIM,ntot,nmax,NXYZ,nxyz,maille0,maille1;
int solver;
double temp;
double *ireal,*covar,*workr,*worki,*realization;
string variable;
/*covariance axis normalization*/
axes(variogram.ap,variogram.scf,variogram.Nvario);
/*pseudo-grid definition*/
cgrid(variogram,grid,n);
/*constant definition*/
NTOT = n[0]*n[1]*n[2];
ntot = NTOT+1;
NMAX = n[0];
NDIM = 3;
for (i=1;i<3;i++) {
if (n[i] > NMAX)
NMAX = n[i];
if (n[i] == 1)
NDIM--;
}
nmax = NMAX+1;
NXYZ = grid.NX*grid.NY*grid.NZ;
nxyz = NXYZ+1;
/*array initialization*/
covar = (double *) malloc(ntot * sizeof(double));
/* testmemory(covar); */
allouememoire(covar,'covar');
ireal = (double *) malloc(ntot * sizeof(double));
testmemory(ireal);
realization = (double *) malloc(ntot * sizeof(double));
testmemory(realization);
workr = (double *) malloc(nmax * sizeof(double));
testmemory(workr);
worki = (double *) malloc(nmax * sizeof(double));
testmemory(worki);
/*covariance function creation*/
covariance(covar,variogram,grid,n);
/*power spectrum*/
fourt(covar,ireal,n,NDIM,1,0,workr,worki);
/*organization of the input Gaussian white noise*/
solver=0;
prebuild_gwn(grid,n,realin,realization,solver);
/*forward fourier transform of the GWN*/
fourt(realization,ireal,n,NDIM,1,0,workr,worki);
/* build realization in spectral domain */
build_real(n,NTOT,covar,realization,ireal);
free(covar);
/*backward fourier transform*/
fourt(realization,ireal,n,NDIM,0,1,workr,worki);
free(ireal);
free(workr);
free(worki);
/*output realization*/
clean_real(realin,n,grid,realization,realout);
free(realization);
return;
}

@ -1,162 +0,0 @@
#include <stdlib.h>
#include <math.h>
#include "geostat.h"
#include "toolsludo.h"
/*FAST FOURIER TRANSFORM Pressure Simulation */
/*Turns a Gaussian white noise vector into a */
/*spatially correlated vector */
/*input: */
/*variogram: structure defining the variogram */
/* model */
/*grid: structure defining the grid */
/*n: vector with the number of cells along the */
/* X, Y and Z axes for the underlying grid */
/* i = [0 1 2] */
/* --> 0 0 0 : n will be computed and */
/* updated as output */
/* --> nx ny nz: these dimensions are used */
/*realin: structure defining a realization - */
/* must be a Gaussian white noise */
/*gradient: macroscopic gradient pression vector */
/*output: */
/*realout: structure defining a realization - */
/*realout2: structure defining a pressure field */
/*realout3: structure defining a xvelocity field */
/*realout4: structure defining a yvelocity field */
/*realout5: structure defining a zvelocity field */
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)
{
int NTOT,i,j,k,NMAX,NDIM,ntot,nmax,NXYZ,nxyz,maille0,maille1;
double *workr,*worki,temp,temp2,coeff;
double *covar,*realization,*pressure;
double *icovar,*ireal,*ipressure;
double *xvelocity,*ixvelocity,*yvelocity,*iyvelocity,*zvelocity,*izvelocity;
double ki,kj,kk;
/*covariance axis normalization*/
axes(variogram.ap,variogram.scf,variogram.Nvario);
/*pseudo-grid definition*/
cgrid(variogram,grid,n);
/*constant definition*/
NTOT = n[0]*n[1]*n[2];
ntot = NTOT+1;
NMAX = n[0];
NDIM = 3;
for (i=1;i<3;i++) {
if (n[i] > NMAX)
NMAX = n[i];
if (n[i] == 1)
NDIM--;
}
nmax = NMAX+1;
NXYZ = grid.NX*grid.NY*grid.NZ;
nxyz = NXYZ+1;
/*array initialization*/
covar = (double *) malloc(ntot * sizeof(double));
testmemory(covar);
icovar = (double *) malloc(ntot * sizeof(double));
testmemory(icovar);
realization = (double *) malloc(ntot * sizeof(double));
testmemory(realization);
ireal = (double *) malloc(ntot * sizeof(double));
testmemory(ireal);
pressure = (double *) malloc(ntot * sizeof(double));
testmemory(pressure);
ipressure = (double *) malloc(ntot * sizeof(double));
testmemory(ipressure);
xvelocity = (double *) malloc(ntot * sizeof(double));
testmemory(xvelocity);
ixvelocity = (double *) malloc(ntot * sizeof(double));
testmemory(ixvelocity);
yvelocity = (double *) malloc(ntot * sizeof(double));
testmemory(yvelocity);
iyvelocity = (double *) malloc(ntot * sizeof(double));
testmemory(iyvelocity);
zvelocity = (double *) malloc(ntot * sizeof(double));
testmemory(zvelocity);
izvelocity = (double *) malloc(ntot * sizeof(double));
testmemory(izvelocity);
workr = (double *) malloc(nmax * sizeof(double));
testmemory(workr);
worki = (double *) malloc(nmax * sizeof(double));
testmemory(worki);
/*covariance function creation*/
covariance(covar,variogram,grid,n);
/*power spectrum*/
fourt(covar,icovar,n,NDIM,1,0,workr,worki);
/*organization of the input Gaussian white noise*/
prebuild_gwn(grid,n,realin,realization);
/*forward fourier transform of the GWN*/
fourt(realization,ireal,n,NDIM,1,0,workr,worki);
/* build realization in spectral domain */
build_real(n,NTOT,covar,realization,ireal);
free(covar);
/* pressure calculation in the spectral domain*/
build_pressure(n,grid,gradient,realization,ireal,pressure,ipressure);
build_velocity(n,grid,stat,gradient,realization,ireal,xvelocity,ixvelocity,1);
build_velocity(n,grid,stat,gradient,realization,ireal,yvelocity,iyvelocity,2);
build_velocity(n,grid,stat,gradient,realization,ireal,zvelocity,izvelocity,3);
/*backward fourier transform*/
fourt(realization,ireal,n,NDIM,0,1,workr,worki);
fourt(pressure,ipressure,n,NDIM,0,1,workr,worki);
fourt(xvelocity,ixvelocity,n,NDIM,0,1,workr,worki);
fourt(yvelocity,iyvelocity,n,NDIM,0,1,workr,worki);
fourt(zvelocity,izvelocity,n,NDIM,0,1,workr,worki);
free(ireal);
free(ipressure);
free(ixvelocity);
free(iyvelocity);
free(izvelocity);
free(workr);
free(worki);
/*output realization*/
/*is the output realization already allocated?*/
/*if not, memory allocation*/
clean_real(realin,n,grid,realization,realout);
clean_real(realin,n,grid,pressure,realout2);
clean_real(realin,n,grid,xvelocity,realout3);
clean_real(realin,n,grid,yvelocity,realout4);
clean_real(realin,n,grid,zvelocity,realout5);
free(realization);
free(pressure);
free(xvelocity);
free(yvelocity);
free(zvelocity);
return;
}

@ -1,157 +0,0 @@
#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include <math.h>
#include "geostat.h"
#include "pressure.h"
/*FAST FOURIER TRANSFORM Pressure Simulation */
/*Turns a Gaussian white noise vector into a */
/*spatially correlated vector */
/*input: */
/*variogram: structure defining the variogram */
/* model */
/*grid: structure defining the grid */
/*n: vector with the number of cells along the */
/* X, Y and Z axes for the underlying grid */
/* i = [0 1 2] */
/* --> 0 0 0 : n will be computed and */
/* updated as output */
/* --> nx ny nz: these dimensions are used */
/*realin: structure defining a realization - */
/* must be a Gaussian white noise */
/*gradient: macroscopic gradient pression vector */
/*output: */
/*realout: structure defining a realization - */
/*realout2: structure defining a pressure field */
/*realout3: structure defining a xvelocity field */
/*realout4: structure defining a yvelocity field */
/*realout5: structure defining a zvelocity field */
void FFTPressure(int n[3],struct grid_mod grid,struct realization_mod *realin,struct statistic_mod stat,struct pressure_mod gradient,struct realization_mod *realout,struct realization_mod *realout2,struct realization_mod *realout3,struct realization_mod *realout4,int solver)
{
int NTOT,i,j,k,NMAX,NDIM,ntot,nmax,NXYZ,nxyz,maille0,maille1;
double *workr,*worki,temp,temp2,coeff;
double *realization,*pressure;
double *ireal,*ipressure;
double *xvelocity,*ixvelocity,*yvelocity,*iyvelocity,*zvelocity,*izvelocity;
double ki,kj,kk;
FILE *fp;
/* string nomfichier; */
/*constant definition*/
NTOT = n[0]*n[1]*n[2];
ntot = NTOT+1;
NMAX = n[0];
NDIM = 3;
for (i=1;i<3;i++) {
if (n[i] > NMAX)
NMAX = n[i];
if (n[i] == 1)
NDIM--;
}
nmax = NMAX+1;
NXYZ = grid.NX*grid.NY*grid.NZ;
nxyz = NXYZ+1;
realization = (double *) malloc(ntot * sizeof(double));
testmemory(realization);
ireal = (double *) malloc(ntot * sizeof(double));
testmemory(ireal);
pressure = (double *) malloc(ntot * sizeof(double));
testmemory(pressure);
ipressure = (double *) malloc(ntot * sizeof(double));
testmemory(ipressure);
xvelocity = (double *) malloc(ntot * sizeof(double));
testmemory(xvelocity);
ixvelocity = (double *) malloc(ntot * sizeof(double));
testmemory(ixvelocity);
yvelocity = (double *) malloc(ntot * sizeof(double));
testmemory(yvelocity);
iyvelocity = (double *) malloc(ntot * sizeof(double));
testmemory(iyvelocity);
zvelocity = (double *) malloc(ntot * sizeof(double));
testmemory(zvelocity);
izvelocity = (double *) malloc(ntot * sizeof(double));
testmemory(izvelocity);
workr = (double *) malloc(nmax * sizeof(double));
testmemory(workr);
worki = (double *) malloc(nmax * sizeof(double));
testmemory(worki);
/*organization of the realization*/
prebuild_gwn(grid,n,realin,realization,solver);
/*forward fourier transform of the GWN*/
fourt(realization,ireal,n,NDIM,1,0,workr,worki);
/* pressure calculation in the spectral domain*/
build_pressure(n,grid,gradient,realization,ireal,pressure,ipressure);
build_velocity(n,grid,stat,gradient,realization,ireal,xvelocity,ixvelocity,1);
build_velocity(n,grid,stat,gradient,realization,ireal,yvelocity,iyvelocity,2);
build_velocity(n,grid,stat,gradient,realization,ireal,zvelocity,izvelocity,3);
/*backward fourier transform*/
fourt(realization,ireal,n,NDIM,0,1,workr,worki);
fourt(pressure,ipressure,n,NDIM,0,1,workr,worki);
fourt(xvelocity,ixvelocity,n,NDIM,0,1,workr,worki);
fourt(yvelocity,iyvelocity,n,NDIM,0,1,workr,worki);
fourt(zvelocity,izvelocity,n,NDIM,0,1,workr,worki);
free(ireal);
free(ipressure);
free(ixvelocity);
free(iyvelocity);
free(izvelocity);
free(workr);
free(worki);
for (i=1;i<=NTOT;i++)
realization[i]=realization[i]/(double) NTOT;
fp = fopen("realization.test", "w");
for (i=1;i<=NTOT;i++)
fprintf(fp,"%f\n",realization[i]);
fclose(fp);
/* nomfichier="pression.test"; */
fp = fopen("pression.test", "w");
for (i=1;i<=NTOT;i++)
fprintf(fp,"%f\n",pressure[i]);
fclose(fp);
/*output realization*/
/*is the output realization already allocated?*/
/*if not, memory allocation*/
clean_real2(realin,n,grid,solver,pressure,realout);
clean_real2(realin,n,grid,solver,xvelocity,realout2);
clean_real2(realin,n,grid,solver,yvelocity,realout3);
clean_real2(realin,n,grid,solver,zvelocity,realout4);
/* free(realization); */
/* free(pressure); */
/* free(xvelocity); */
/* free(yvelocity); */
/* free(zvelocity); */
return;
}

@ -1,68 +0,0 @@
#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include <math.h>
#include "geostat.h"
/*FAST FOURIER TRANSFORM Test */
void FFTtest(int n[3],struct grid_mod grid,struct realization_mod *realin,struct realization_mod *realout,int solver)
{
int NTOT,i,j,k,NMAX,NDIM,ntot,nmax,NXYZ,nxyz,maille0,maille1;
double *workr,*worki,temp,temp2,coeff;
double *realization;
double *ireal;
double ki,kj,kk;
FILE *fp;
/*constant definition*/
NTOT = n[0]*n[1]*n[2];
ntot = NTOT+1;
NMAX = n[0];
NDIM = 3;
for (i=1;i<3;i++) {
if (n[i] > NMAX)
NMAX = n[i];
if (n[i] == 1)
NDIM--;
}
nmax = NMAX+1;
NXYZ = grid.NX*grid.NY*grid.NZ;
nxyz = NXYZ+1;
realization = (double *) malloc(ntot * sizeof(double));
testmemory(realization);
ireal = (double *) malloc(ntot * sizeof(double));
testmemory(ireal);
workr = (double *) malloc(nmax * sizeof(double));
testmemory(workr);
worki = (double *) malloc(nmax * sizeof(double));
testmemory(worki);
/*organization of the realization*/
prebuild_gwn(grid,n,realin,realization,solver);
fp = fopen("perm.test", "w");
for (i=1;i<=NTOT;i++)
fprintf(fp,"%f\n",realization[i]);
fclose(fp);
/*forward fourier transform of the GWN*/
fourt(realization,ireal,n,NDIM,1,0,workr,worki);
/*backward fourier transform*/
fourt(realization,ireal,n,NDIM,0,1,workr,worki);
fp = fopen("perm2.test", "w");
for (i=1;i<=NTOT;i++)
fprintf(fp,"%f\n",realization[i]);
fclose(fp);
return;
}

@ -1,13 +0,0 @@
CC = cc
CCFLAG =
LIB = libCS106X_${ARCH}.a
%.o: %.c
$(CC) $(CCFLAG) -c $<
$(LIB) : genlib.o random.o simpio.o strlib.o symtab.o scanadt.o stack.o
ar r $@ $?
clean :
rm *.o

@ -1,30 +0,0 @@
########################################################################
#
# Makefile for library
#
########################################################################
INTERFACE = ../include
INCLUDE = -I${INTERFACE}
LIBS = -lm -L../lib
CC = cc
CCFLAGS =
LIB = libFFTMA_${ARCH}.a
NOBJS= gammf.o fftma.o addstat.o axes.o cgrid.o covariance.o fourt.o length.o maxfactor.o test_fact.o cov_value.o generate.o gasdev.o ran2.o stable.o gaussian.o power.o cubic.o spherical.o nugget.o exponential.o cardsin.o nor2log.o
.c.o:
${CC} $(INCLUDE) $(CCFLAGS) -c $<
# LIBRARY
$(LIB) : $(NOBJS)
ar cr $(LIB) $(NOBJS)
ranlib $(LIB)
clean :
rm *.o

@ -1,30 +0,0 @@
########################################################################
#
# Makefile for library
#
########################################################################
INTERFACE = ../include
INCLUDE = -I${INTERFACE}
LIBS = -lm -L../lib
CC = cc
CCFLAGS =
LIB = libFFTMA2_${ARCH}.a
NOBJS= kgeneration.o kgeneration2.o fftma2.o prebuild_gwn.o build_real.o addstat2.o clean_real.o
.c.o:
${CC} $(INCLUDE) $(CCFLAGS) -c $<
# LIBRARY
$(LIB) : $(NOBJS)
ar cr $(LIB) $(NOBJS)
ranlib $(LIB)
clean :
rm *.o

@ -1,34 +0,0 @@
########################################################################
#
# Makefile for library
#
########################################################################
#INTERFACE = ${BOSSE}/CODES/LIBS_C/Interface
#INTERFACE2= ${BOSSE}/CODES/Geostat/FFTPSim/Version_binaire2/src/Interface
INTERFACE = ../include
#INTERFACE2= ../Interface
INCLUDE = -I${INTERFACE}
LIBS = -lm -L../lib
CCFLAGS =
CC = cc
LIB = libFFTPSIM_${ARCH}.a
NOBJS= pgeneration.o pgeneration2.o FFTPressure.o FFTtest.o build_pressure.o build_velocity.o total_pressure.o total_velocity.o clean_real2.o waveVectorCompute3D.o mat_vec.o derivReal.o
.c.o:
${CC} $(INCLUDE) $(CCFLAGS) -c $<
# LIBRARY
$(LIB) : $(NOBJS)
ar cr $(LIB) $(NOBJS)
ranlib $(LIB)
clean :
rm *.o

@ -1,31 +0,0 @@
#
########################################################################
#
# Makefile for library
#
########################################################################
#
#INTERFACE = ${BOSSE}/CODES/LIBS_C/Interface
INTERFACE = ../include
INCLUDE = -I${INTERFACE}
CC = cc
CCFLAGS =
LIB = libIO_${ARCH}.a
NOBJS= inputdata.o inputfiledata.o debuginput.o readdata.o readfile_bin.o writefile.o writefile_bin.o testmemory.o testopenfile.o readdata2.o readdata3.o
.c.o:
${CC} $(INCLUDE) $(CCFLAGS) -c $<
# LIBRARY
$(LIB) : $(NOBJS)
ar cr $(LIB) $(NOBJS)
ranlib $(LIB)
clean :
rm *.o

@ -1,21 +0,0 @@
# CC = gcc
# CCFLAG =
ifeq (${ARCH},sun)
CC = cc
CCFLAG = -g
endif
ifeq (${ARCH},linux)
CC = gcc
CCFLAG = -g
endif
LIB = libCS106X_debug_${ARCH}.a
%.o: %.c
$(CC) $(CCFLAG) -c $<
$(LIB) : genlib.o random.o simpio.o strlib.o symtab.o scanadt.o stack.o
ar r $@ $?
clean :
rm *.o

@ -47,8 +47,8 @@ void Py_kgeneration(long seed,struct grid_mod grid,struct statistic_mod stat,st
FFTMA2(variogram,grid,n,Z,Y); FFTMA2(variogram,grid,n,Z,Y);
/*add the statistics*/ /*add the statistics*/
if (stat.mean[0] != 0 || stat.variance[0]!= 1) //if (stat.mean[0] != 0 || stat.variance[0]!= 1)
addstat2(Y,stat,Y1,Y); //addstat2(Y,stat,Y1,Y);
/* make a log normal realization */ /* make a log normal realization */
if (stat.type==1 || stat.type==2){ if (stat.type==1 || stat.type==2){

@ -1,106 +0,0 @@
#include <stdio.h>
#include <math.h>
#include "geostat.h"
#include "genlib.h"
/*addstat */
/*adds mean and variance effects to the N(0,1) realization*/
/*input: */
/*realin: structure defining a realization - */
/* must have zeio mean and unit variance */
/*stat: structure defining the mean and variance */
/*output: */
/*realout: structure defining a realization - */
void addstat(struct realization_mod *realin,struct statistic_mod stat ,struct realization_mod *realout)
{
int i,nblockm,nblockv;
double r,moy,var;
/*Is the output realization allocated ?*/
/*is its length equal to realin.n?*/
if ((*realout).vector == NULL || (*realout).n != (*realin).n) {
(*realout).vector = (double *) malloc((*realin).n * sizeof(double));
if ((*realout).vector == NULL)
Error("No memory available");
}
(*realout).n = (*realin).n;
/*test over the input realization*/
switch ((*realin).code) {
case 0:
case 1:
(*realout).code = 2;
break;
case 6:
(*realout).code = 7;
break;
default:
(*realout).code = (*realin).code;
break;
}
for (i = 0; i < (*realin).n; i++) {
/*mean*/
switch (stat.nblock_mean) {
case 1:
/*stationary case*/
nblockm = 1;
break;
default:
/*number of the cell - nonstationary case*/
nblockm = i+1;
break;
}
/*variance*/
switch (stat.nblock_var) {
case 1:
/*stationary case*/
nblockv = 1;
break;
default:
/*number of the cell - nonstationary case*/
nblockv = i+1;
break;
}
switch (stat.type) {
case 0:
/*normal case*/
moy = stat.mean[nblockm-1];
var = stat.variance[nblockv-1];
break;
case 1:
/*lognormal (natural) case*/
r = (double)sqrt(stat.variance[nblockv-1])/stat.mean[nblockm-1];
r *= r;
moy = (double)log(stat.mean[nblockm-1]/sqrt(1.0+r));
var = (double)log(1.0+r);
break;
case 2:
/*lognormal (log10) case*/
r = (double)sqrt(stat.variance[nblockv-1])/stat.mean[nblockm-1];
r *= r;
moy = (double)log10(stat.mean[nblockm-1]/sqrt(1.0+r));
var = (double)log10(1.0+r);
break;
default:
Error("Type not defined in addstat");
break;
}
(*realout).vector[i] = (double)sqrt(var)*(*realin).vector[i]+moy;
}
return;
}

@ -1,119 +0,0 @@
#include <stdio.h>
#include <math.h>
#include "genlib.h"
#include "geostat.h"
/*addstat */
/*adds mean and variance effects to the N(0,1) realization*/
/*input: */
/*realin: structure defining a realization - */
/* must have zeio mean and unit variance */
/*stat: structure defining the mean and variance */
/*output: */
/*realout: structure defining a realization - */
void addstat2(struct realization_mod *realin,struct statistic_mod stat ,struct realization_mod *realout,struct realization_mod *realout2)
{
int i,nblockm,nblockv;
double r,moy,var;
/*Is the output realization allocated ?*/
/*is its length equal to realin.n?*/
if ((*realout).vector == NULL || (*realout).n != (*realin).n) {
(*realout).vector = (double *) malloc((*realin).n * sizeof(double));
if ((*realout).vector == NULL)
Error("No memory available");
}
(*realout).n = (*realin).n;
if ((*realout2).vector == NULL || (*realout2).n != (*realin).n) {
(*realout2).vector = (double *) malloc((*realin).n * sizeof(double));
if ((*realout2).vector == NULL)
Error("No memory available");
}
(*realout2).n = (*realin).n;
/*test over the input realization*/
switch ((*realin).code) {
case 0:
case 1:
(*realout).code = 2;
(*realout2).code = 2;
break;
case 6:
(*realout).code = 7;
(*realout2).code = 7;
break;
default:
(*realout).code = (*realin).code;
(*realout2).code = (*realin).code;
break;
}
for (i = 0; i < (*realin).n; i++) {
/*mean*/
switch (stat.nblock_mean) {
case 1:
/*stationary case*/
nblockm = 1;
break;
default:
/*number of the cell - nonstationary case*/
nblockm = i+1;
break;
}
/*variance*/
switch (stat.nblock_var) {
case 1:
/*stationary case*/
nblockv = 1;
break;
default:
/*number of the cell - nonstationary case*/
nblockv = i+1;
break;
}
/* switch (stat.type) { */
/* case 0: */
/*normal case*/
moy = stat.mean[nblockm-1];
var = stat.variance[nblockv-1];
/* break; */
/* case 1: */
/*lognormal (natural) case*/
/* r = (double)sqrt(stat.variance[nblockv-1])/stat.mean[nblockm-1]; */
/* r *= r; */
/* moy = (double)log(stat.mean[nblockm-1]/sqrt(1.0+r)); */
/* var = (double)log(1.0+r); */
/* break; */
/* case 2: */
/*lognormal (log10) case*/
/* r = (double)sqrt(stat.variance[nblockv-1])/stat.mean[nblockm-1]; */
/* r *= r; */
/* moy = (double)log10(stat.mean[nblockm-1]/sqrt(1.0+r)); */
/* var = (double)log10(1.0+r); */
/* break; */
/* default: */
/* Error("Type not defined in addstat"); */
/* break; */
/* } */
(*realout).vector[i] = (double)sqrt(var)*(*realin).vector[i];
(*realout2).vector[i] = (double)sqrt(var)*(*realin).vector[i]+moy;
}
return;
}

@ -1,16 +0,0 @@
#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include <math.h>
void allouememoire(double *realint, string variable)
{
if (realint == NULL) {
printf("Testmemory.c: No memory available for %s\n",variable);
exit;
}
return;
}

@ -16,6 +16,8 @@ void build_pressure(int n[3],struct grid_mod grid,struct pressure_mod gradient,d
double ki,kj,kk; double ki,kj,kk;
double coeff,temp,temp2; double coeff,temp,temp2;
printf("build pressure pdslis\n");
/* pressure calculation in the spectral domain*/ /* pressure calculation in the spectral domain*/
for ( k = 1; k <= n[2]; k++) { for ( k = 1; k <= n[2]; k++) {
for (j = 1; j <= n[1]; j++) { for (j = 1; j <= n[1]; j++) {

@ -23,6 +23,8 @@ void build_real(int n[3],int NTOT,double *covar,double *realization,double *irea
int i,j,k,maille1; int i,j,k,maille1;
double temp; double temp;
printf("build real\n");
/*decomposition and multiplication in the spectral domain*/ /*decomposition and multiplication in the spectral domain*/
for ( k = 1; k <= n[2]; k++) { for ( k = 1; k <= n[2]; k++) {

@ -18,6 +18,8 @@ void build_velocity(int n[3],struct grid_mod grid,struct statistic_mod stat,stru
double coeff,temp,temp2; double coeff,temp,temp2;
double grad; double grad;
printf("build velocity\n");
/* x-direction velocity calculation in the spectral domain*/ /* x-direction velocity calculation in the spectral domain*/
switch(direction) switch(direction)
{ {

@ -5,6 +5,7 @@
/*cardsin covariance function*/ /*cardsin covariance function*/
double cardsin(double h) double cardsin(double h)
{ {
printf("cardsin\n");
float delta = 20.371; float delta = 20.371;
double z; double z;

@ -15,6 +15,8 @@ void cgrid(struct vario_mod variogram, struct grid_mod grid, int n[3])
int i,N; int i,N;
double D; double D;
printf("cgrid\n");
if (n == NULL || n[0] == 0 || n[1] == 0 || n[2] == 0) { if (n == NULL || n[0] == 0 || n[1] == 0 || n[2] == 0) {
for (i = 0; i<3; i++) { for (i = 0; i<3; i++) {
switch (i) { switch (i) {

@ -11,6 +11,8 @@ void clean_real(struct realization_mod *realin,int n[3],struct grid_mod grid,dou
int i,j,k,maille0,maille1; int i,j,k,maille0,maille1;
double NTOT; double NTOT;
printf("clean_real\n");
NTOT=n[0]*n[1]*n[2]; NTOT=n[0]*n[1]*n[2];
/*is the output realization already allocated?*/ /*is the output realization already allocated?*/
/*if not, memory allocation*/ /*if not, memory allocation*/

@ -1,50 +0,0 @@
#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include <math.h>
#include "geostat.h"
void clean_real2(struct realization_mod *realin,int n[3],struct grid_mod grid,int solver,double *vectorresult,struct realization_mod *realout)
{
int i,j,k,maille0,maille1;
double NTOT;
NTOT=n[0]*n[1]*n[2];
/*is the output realization already allocated?*/
/*if not, memory allocation*/
if ((*realout).vector == NULL || (*realout).n != (*realin).n)
{
(*realout).vector = (double *) malloc((*realin).n * sizeof(double));
if ((*realout).vector == NULL)
{
printf("Clean_real2.c: No memory available\n");
exit;
}
}
(*realout).n = (*realin).n;
(*realout).code = 1;
if (solver==1)
{
for ( k = 1; k <= NTOT;k++)
{
(*realout).vector[k-1] = vectorresult[k]/(double) NTOT;
}
}
else
{
for ( k = 1; k <= grid.NZ; k++) {
for (j = 1; j <= grid.NY; j++) {
for (i = 1; i <= grid.NX; i++) {
maille1 = i+(j-1+(k-1)*n[1])*n[0];
maille0 = i-1+(j-1+(k-1)*grid.NY)*grid.NX;
(*realout).vector[maille0] = vectorresult[maille1]/(double) NTOT;
}
}
}
}
return;
}

@ -9,6 +9,8 @@ double cov_value(struct vario_mod variogram,double di,double dj,double dk)
double cov; double cov;
int k; int k;
printf("cov_valueds\n");
cov = 0.; cov = 0.;

@ -8,6 +8,8 @@ void covariance(double *covar, struct vario_mod variogram, struct grid_mod mesh,
int i,j,k,maille,n2[3],symmetric; int i,j,k,maille,n2[3],symmetric;
double di,dj,dk; double di,dj,dk;
printf("covaridsadsncdse\n");
for (i=0;i<3;i++) for (i=0;i<3;i++)
n2[i] = n[i]/2; n2[i] = n[i]/2;

@ -8,6 +8,8 @@ double cubic(double h)
{ {
double z; double z;
printf("cubidsc\n");
if (h >= 1.) { if (h >= 1.) {
z = 0.; z = 0.;
} else { } else {

@ -1,216 +0,0 @@
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include "condor.h"
#include "geostat.h"
/* Private functions */
void normAxes(double *vec, double *normed);
void derivReal(struct realization_mod *Z, struct realization_mod *dZ, double *dir, struct grid_mod *grid, struct vario_mod vario) {
int n[3],i,j,k,maille,extMaille;
int NTOT,ntot,NMAX,nmax,NDIM;
// int NXYZ,nxyz;
double nDir[3];
double *table,*workr,*worki,*realization,*waveVect;
int Ngrid;
double tmp;
double *ExtendedWaveVect;
/* Test the input real*/
/* if ((*Z).code != 1) { */
/* printf("Realization should be Standard Normal\n"); */
/* return; */
/* } */
printf("grid.Nx = %d\n",(*grid).NX);
printf("grid.Ny = %d\n",(*grid).NY);
printf("grid.Nz = %d\n",(*grid).NZ);
printf("vario.Nvario = %d\n",vario.Nvario);
for(i=0; i<vario.Nvario;i++) {
printf("Component %d:\n",i);
printf("Type: %d\n",vario.vario[i]);
printf("Exponent: %f\n",vario.alpha[i]);
printf("Anisotropy axes:");
for(j=0; j<6; j++) {
printf(" %f",vario.ap[6*i+j]);
}
printf("\nCorrelation length:\n");
for(j=0;j<3;j++) {
printf("axe%d :%f\n",j+1,vario.scf[3*i+j]);
}
printf("Variance: %f\n",vario.var[i]);
}
/* covariance axis normalisation */
axes(vario.ap,vario.scf,vario.Nvario);
n[0]=0;
n[1]=0;
n[2]=0;
/* pseudo-grid definition */
cgrid(vario,*grid,n);
printf("n[0] = %d\n", n[0]);
printf("n[1] = %d\n", n[1]);
printf("n[2] = %d\n", n[2]);
/* constants definition */
NTOT = n[0]*n[1]*n[2];
ntot = NTOT + 1;
NDIM = 3;
NMAX = n[0];
Ngrid = (*grid).NX*(*grid).NY*(*grid).NZ;
for (i=1;i<3;i++) {
if (n[i] > NMAX) NMAX = n[i];
if (n[i] == 1) NDIM = NDIM-1;
}
nmax = NMAX+1;
printf("NTOT = %d, ntot = %d, NMAX = %d\n",NTOT,ntot,NMAX);
/* wave vector computation */
normAxes(dir,nDir);
printf("Derivation direction (normed) %f %f %f\n",nDir[0],nDir[1],nDir[2]);
waveVect = (double *) malloc(Ngrid*sizeof(double));
if (waveVect == NULL) {
printf("waveVectCompute.cpp : No memory available for waveVect\n");
return;
}
waveVectorCompute3D((*grid).NX,(*grid).NY,(*grid).NZ,nDir,waveVect);
/* memory allocation */
table = (double *) malloc(ntot * sizeof(double));
if (table == NULL) {
printf("derivReal.cpp: No memory availble for table\n");
return;
}
realization = (double *) malloc(ntot * sizeof(double));
if (realization == NULL) {
printf("derivReal.cpp: No memory availble for realization\n");
return;
}
ExtendedWaveVect = (double *) malloc(ntot * sizeof(double));
if (ExtendedWaveVect == NULL) {
printf("derivReal.cpp: No memory availble for realization\n");
return;
}
workr = (double *) malloc(nmax * sizeof(double));
if (workr == NULL) {
printf("derivReal.cpp: No memory available for workr\n");
return;
}
worki = (double *) malloc(nmax * sizeof(double));
if (worki == NULL) {
printf("derivReal.cpp: No memory available for worki\n");
return;
}
extMaille =0;
/* organization of the extended realization */
for (k=1;k<=n[2];k++) {
for (j=1;j<=n[1];j++) {
for (i=1;i<=n[0];i++) {
extMaille = i + ((j-1) + (((k-1) * n[1]) * n[0]));
if (i <= (*grid).NX && j <= (*grid).NY && k <= (*grid).NZ) {
maille = i-1 + ((j-1) + ((k-1) * (*grid).NY) * (*grid).NX);
realization[extMaille] = (*Z).vector[maille];
ExtendedWaveVect[extMaille] = waveVect[maille];
} else {
realization[extMaille] = 0.0;
ExtendedWaveVect[extMaille] = 0.0;
}
}
}
}
/* forward fourier transform of the realization */
fourt(realization,table,n,NDIM,1,0,workr,worki);
FILE *wave;
wave = fopen("/home/irsrvshare1/R03/UPS_FLEX/waveVector.eas","w");
for (i=1;i<ntot;i++) {
tmp = realization[i];
realization[i] = - ExtendedWaveVect[i]*table[i];
table[i] = - ExtendedWaveVect[i]*tmp;
fprintf(wave,"%f\n", ExtendedWaveVect[i]);
}
fclose(wave);
free(waveVect);
/* backward fourier tranform */
fourt(realization,table,n,NDIM,0,1,workr,worki);
/* free the memory */
free(table);
free(workr);
free(worki);
printf("after second fourt \n");
(*dZ).n = (*Z).n;
(*dZ).code = (*Z).code;
(*dZ).vector = (double *) malloc(Ngrid*sizeof(double));
FILE *real;
FILE *derReal;
real = fopen("/home/irsrvshare1/R03/UPS_FLEX/realization.eas","w");
derReal = fopen("/home/irsrvshare1/R03/UPS_FLEX/derivative.eas","w");
printf("before saving file \n");
for(k=1;k<=(*grid).NZ;k++) {
for(j=1;j<=(*grid).NY;j++) {
for(i=1;i<=(*grid).NX;i++) {
extMaille = i+(j-1+(k-1)*n[1])*n[0];
maille = i-1+(j-1+(k-1)*(*grid).NY)*(*grid).NX;
(*dZ).vector[maille] = realization[extMaille]/(double)NTOT;
// printf("Z[%d] = %f, dZ[%d] = %f\n",maille,(*Z).vector[maille],maille,(*dZ).vector[maille]);
fprintf(real,"%f\n",(*Z).vector[maille]);
fprintf(derReal,"%f\n",(*dZ).vector[maille]);
}
}
}
printf("after saving file \n");
fclose(real);
fclose(derReal);
free(realization);
}
void normAxes(double *vec, double *normed) {
int i;
double r;
r = sqrt(vec[0]*vec[0]+vec[1]*vec[1]+vec[2]*vec[2]);
if (normed == NULL) {
normed = (double *)malloc(3*sizeof(double));
if (normed == NULL) {
printf("derivReal.c: No memory available for normed\n");
}
}
for (i=0;i<3;i++) {
normed[i] = vec[i]/r;
}
}

@ -5,5 +5,6 @@
/*exponential covariance function*/ /*exponential covariance function*/
double exponential(double h) double exponential(double h)
{ {
//printf("exponential\n");
return (exp(-3.*(double)h)); return (exp(-3.*(double)h));
} }

@ -1,185 +0,0 @@
#include <stdlib.h>
#include <math.h>
#include "geostat.h"
/*FAST FOURIER TRANSFORM MOVING AVERAGE METHOD */
/*Turns a Gaussian white noise vector into a */
/*spatially correlated vector */
/*input: */
/*variogram: structure defining the variogram */
/* model */
/*grid: structure defining the grid */
/*n: vector with the number of cells along the */
/* X, Y and Z axes for the underlying grid */
/* i = [0 1 2] */
/* --> 0 0 0 : n will be computed and */
/* updated as output */
/* --> nx ny nz: these dimensions are used */
/*realin: structure defining a realization - */
/* must be a Gaussian white noise */
/*output: */
/*realout: structure defining a realization - */
void FFTMA(struct vario_mod variogram,struct grid_mod grid,int n[3],struct realization_mod *realin,struct realization_mod *realout)
{
int NTOT,i,j,k,NMAX,NDIM,ntot,nmax,NXYZ,nxyz,maille0,maille1;
double *table,*covar,*workr,*worki,*realization,temp;
/*test over the input realization*/
/*if ((*realin).code != 0) {
printf("Input realizations in FFTMA must be Gaussian white noises");
exit;
}*/
/*covariance axis normalization*/
axes(variogram.ap,variogram.scf,variogram.Nvario);
/*pseudo-grid definition*/
cgrid(variogram,grid,n);
/*constant definition*/
NTOT = n[0]*n[1]*n[2];
ntot = NTOT+1;
NMAX = n[0];
NDIM = 3;
for (i=1;i<3;i++) {
if (n[i] > NMAX)
NMAX = n[i];
if (n[i] == 1)
NDIM--;
}
nmax = NMAX+1;
NXYZ = grid.NX*grid.NY*grid.NZ;
nxyz = NXYZ+1;
/*array initialization*/
covar = (double *) malloc(ntot * sizeof(double));
if (covar == NULL) {
printf("FFTMA.c: No memory available for covar");
exit;
}
table = (double *) malloc(ntot * sizeof(double));
if (table == NULL) {
printf("FFTMA.c: No memory available for table");
exit;
}
realization = (double *) malloc(ntot * sizeof(double));
if (realization == NULL) {
printf("FFTMA.c: No memory available for realization");
exit;
}
workr = (double *) malloc(nmax * sizeof(double));
if (workr == NULL) {
printf("FFTMA.c: No memory available for workr");
exit;
}
worki = (double *) malloc(nmax * sizeof(double));
if (worki == NULL) {
printf("FFTMA.c: No memory available for worki");
exit;
}
/*covariance function creation*/
covariance(covar,variogram,grid,n);
/*power spectrum*/
fourt(covar,table,n,NDIM,1,0,workr,worki);
/*organization of the input Gaussian white noise*/
for ( k = 1; k <= n[2]; k++) {
for (j = 1; j <= n[1]; j++) {
for (i = 1; i <= n[0]; i++) {
maille1 = i+(j-1+(k-1)*n[1])*n[0];
if (i <= grid.NX && j <= grid.NY && k <= grid.NZ) {
maille0 = i-1+(j-1+(k-1)*grid.NY)*grid.NX;
realization[maille1] = (*realin).vector[maille0];
} else {
realization[maille1] = 0.;
}
}
}
}
/*forward fourier transform of the GWN*/
fourt(realization,table,n,NDIM,1,0,workr,worki);
/*decomposition and multiplication in the spectral domain*/
for ( k = 1; k <= n[2]; k++) {
for (j = 1; j <= n[1]; j++) {
for (i = 1; i <= n[0]; i++) {
maille1 = i+(j-1+(k-1)*n[1])*n[0];
temp = covar[maille1];
if (temp > 0.) {
temp = sqrt(temp)/(double) NTOT;
} else if (temp < 0.) {
temp = sqrt(-temp)/(double) NTOT;
}
realization[maille1] *= temp;
table[maille1] *= temp;
}
}
}
free(covar);
/*backward fourier transform*/
fourt(realization,table,n,NDIM,0,1,workr,worki);
free(table);
free(workr);
free(worki);
/*output realization*/
/*is the output realization already allocated?*/
/*if not, memory allocation*/
if ((*realout).vector == NULL || (*realout).n != (*realin).n) {
(*realout).vector = (double *) malloc((*realin).n * sizeof(double));
if ((*realout).vector == NULL) {
printf("FFTMA.c: No memory available");
exit;
}
}
(*realout).n = (*realin).n;
(*realout).code = 1;
for ( k = 1; k <= grid.NZ; k++) {
for (j = 1; j <= grid.NY; j++) {
for (i = 1; i <= grid.NX; i++) {
maille1 = i+(j-1+(k-1)*n[1])*n[0];
maille0 = i-1+(j-1+(k-1)*grid.NY)*grid.NX;
(*realout).vector[maille0] = realization[maille1];
}
}
}
free(realization);
return;
}

@ -95,6 +95,7 @@ void fourt(double *datar,double *datai, int nn[3], int ndim, int ifrwd, int icpl
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; 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;
double theta,wstpr,wstpi,wminr,wmini,wr,wi,wtemp,thetm,wmstr,wmsti,twowr,sr,si,oldsr,oldsi,stmpr,stmpi,tempr,tempi,difi,difr,sumr,sumi,TWOPI = 6.283185307179586476925286766559; double theta,wstpr,wstpi,wminr,wmini,wr,wi,wtemp,thetm,wmstr,wmsti,twowr,sr,si,oldsr,oldsi,stmpr,stmpi,tempr,tempi,difi,difr,sumr,sumi,TWOPI = 6.283185307179586476925286766559;
printf("fourt\n");
ntot = 1; ntot = 1;
for (idim = 0; idim < ndim; idim++) { for (idim = 0; idim < ndim; idim++) {
ntot *= nn[idim]; ntot *= nn[idim];

@ -6,6 +6,7 @@
/*gamma covariance function*/ /*gamma covariance function*/
double gammf(double h, double alpha) double gammf(double h, double alpha)
{ {
printf("gadsmmf\n");
float delta; float delta;
double z; double z;

@ -8,6 +8,7 @@ double gasdev(long *idum,long *idum2, long *iy, long iv[NTAB])
/*and unit variance, using ran2(idum) as the source */ /*and unit variance, using ran2(idum) as the source */
/*of uniform deviates */ /*of uniform deviates */
{ {
printf("gasdev\n");
double ran2(long *idum,long *idum2, long *iy, long iv[NTAB]); double ran2(long *idum,long *idum2, long *iy, long iv[NTAB]);
static int iset = 0; static int iset = 0;
static double gset; static double gset;

@ -26,7 +26,7 @@ void inputdata(long *seed,struct grid_mod *grid,string filename[7],struct vario_
/*seed*/ /*seed*/
printf("Starting seed (integer): \n"); printf("Starting sedsdsed (integer): \n");
*seed = GetInteger(); *seed = GetInteger();
/*Grid description*/ /*Grid description*/

@ -54,8 +54,8 @@ void kgeneration(long seed,struct grid_mod grid,struct statistic_mod stat,struc
/* writefile(file1,Y); */ /* writefile(file1,Y); */
/*add the statistics*/ /*add the statistics*/
if (stat.mean[0] != 0 || stat.variance[0]!= 1) //if (stat.mean[0] != 0 || stat.variance[0]!= 1)
addstat2(Y,stat,Y1,Y); //addstat2(Y,stat,Y1,Y);
/* file2="prout2"; */ /* file2="prout2"; */
/* writefile(file2,Y); */ /* writefile(file2,Y); */

@ -51,8 +51,8 @@ void kgeneration2(long seed,struct grid_mod grid,struct statistic_mod stat,stru
FFTMA2(variogram,grid,n,Z,Y); FFTMA2(variogram,grid,n,Z,Y);
/*add the statistics*/ /*add the statistics*/
if (stat.mean[0] != 0 || stat.variance[0]!= 1) //if (stat.mean[0] != 0 || stat.variance[0]!= 1)
addstat2(Y,stat,Y1,Y); //addstat2(Y,stat,Y1,Y);
/* make a log normal realization */ /* make a log normal realization */
if (stat.type==1 || stat.type==2){ if (stat.type==1 || stat.type==2){

@ -1,36 +0,0 @@
#
########################################################################
#
# Makefile for library
#
########################################################################
#
INCLUDE = -I./
LIBS = -lm -L./
# CCFLAGS = -fast
ifeq (${ARCH},sun)
CC = cc
CCFLAGS = -g
endif
ifeq (${ARCH},linux)
CC = gcc
CCFLAGS = -g
endif
LIB = libFFTMA_debug_${ARCH}.a
NOBJS= gammf.o FFTMA.o addstat.o axes.o cgrid.o covariance.o fourt.o length.o maxfactor.o test_fact.o cov_value.o generate.o gasdev.o ran2.o stable.o gaussian.o power.o cubic.o spherical.o nugget.o exponential.o cardsin.o nor2log.o
.c.o:
${CC} $(INCLUDE) $(CCFLAGS) -c $<
# LIBRARY
$(LIB) : $(NOBJS)
ar cr $(LIB) $(NOBJS)
ranlib $(LIB)
clean :
rm *.o

@ -14,7 +14,7 @@ void pgeneration(int n[3],struct grid_mod grid,struct statistic_mod stat,struct
int i,ntot; int i,ntot;
struct realization_mod GP; struct realization_mod GP;
FFTPressure(n,grid,Y,stat,pression,P,VX,VY,VZ,solver); //FFTPressure(n,grid,Y,stat,pression,P,VX,VY,VZ,solver);
/*save the delta-pressure realization*/ /*save the delta-pressure realization*/
writefile(filename[2],P); writefile(filename[2],P);

@ -14,7 +14,7 @@ void pgeneration2(int n[3],struct grid_mod grid,struct statistic_mod stat,struc
int i,ntot; int i,ntot;
struct realization_mod GP; struct realization_mod GP;
FFTPressure(n,grid,Y,stat,pression,P,VX,VY,VZ,solver); //FFTPressure(n,grid,Y,stat,pression,P,VX,VY,VZ,solver);
/*save the delta-pressure realization*/ /*save the delta-pressure realization*/
switch (format_file) switch (format_file)

@ -42,13 +42,13 @@ void prebuild_gwn(struct grid_mod grid,int n[3],struct realization_mod *realin,d
for (j = 1; j <= n[1]; j++) { for (j = 1; j <= n[1]; j++) {
for (i = 1; i <= n[0]; i++) { for (i = 1; i <= n[0]; i++) {
maille1 = i+(j-1+(k-1)*n[1])*n[0]; maille1 = i+(j-1+(k-1)*n[1])*n[0];
printf("n[1] es %d y grid.NY %d\n", n[1], grid.NY); //printf("n[1] es %d y grid.NY %d\n", n[1], grid.NY);
printf("n[0] es %d y grid.NX %d\n", n[0], grid.NX); //printf("n[0] es %d y grid.NX %d\n", n[0], grid.NX);
if (i <= grid.NX && j <= grid.NY && k <= grid.NZ) { if (i <= grid.NX && j <= grid.NY && k <= grid.NZ) {
maille0 = i-1+(j-1+(k-1)*grid.NY)*grid.NX; maille0 = i-1+(j-1+(k-1)*grid.NY)*grid.NX;
printf("maille0: %d\n", maille0); //printf("maille0: %d\n", maille0);
realization[maille1] = (*realin).vector[maille0]; realization[maille1] = (*realin).vector[maille0];
printf("en realization maille1 %d pos guarde %f\n", maille1, realization[maille1]); //printf("en realization maille1 %d pos guarde %f\n", maille1, realization[maille1]);
} else { } else {
realization[maille1] = 0.; realization[maille1] = 0.;
} }

@ -21,7 +21,7 @@ void readdata(long *seed,struct grid_mod *grid,string filename[8],struct vario_m
file1=argv[1]; file1=argv[1];
file2=argv[2]; file2=argv[2];
/* Ouverture du fichier de données principal */ /* Ouverture du fichier de donn<EFBFBD>es principal */
if ((fp=fopen(file1,"r")) == NULL) if ((fp=fopen(file1,"r")) == NULL)
{ {
@ -48,7 +48,7 @@ void readdata(long *seed,struct grid_mod *grid,string filename[8],struct vario_m
} }
n=(*grid).NX*(*grid).NY*(*grid).NZ; n=(*grid).NX*(*grid).NY*(*grid).NZ;
/* Ouverture du fichier de données sur le champ de perméabilité */ /* Ouverture du fichier de donn<EFBFBD>es sur le champ de perm<72>abilit<69> */
if ((fp=fopen(file2,"r")) == NULL) if ((fp=fopen(file2,"r")) == NULL)
{ {
@ -120,7 +120,7 @@ void readdata(long *seed,struct grid_mod *grid,string filename[8],struct vario_m
break; break;
case 1: case 1:
file3=argv[3]; file3=argv[3];
/* Ouverture du fichier de données de pression*/ /* Ouverture du fichier de donn<EFBFBD>es de pression*/
if ((fp=fopen(file3,"r")) == NULL) if ((fp=fopen(file3,"r")) == NULL)
{ {
fprintf(stderr,"%s :impossible d'ouvrir %s\n",prog, file3); fprintf(stderr,"%s :impossible d'ouvrir %s\n",prog, file3);
@ -158,7 +158,7 @@ void readdata(long *seed,struct grid_mod *grid,string filename[8],struct vario_m
break; break;
case 2: case 2:
/* Ouverture du fichier de données de pression */ /* Ouverture du fichier de donn<EFBFBD>es de pression */
file3=argv[3]; file3=argv[3];
if ((fp=fopen(file3,"r")) == NULL) if ((fp=fopen(file3,"r")) == NULL)
{ {

@ -21,7 +21,7 @@ void readdata2(long *seed,struct grid_mod *grid,string filename[8],struct vario_
file1=argv[1]; file1=argv[1];
file2=argv[2]; file2=argv[2];
/* Ouverture du fichier de données principal */ /* Ouverture du fichier de donn<EFBFBD>es principal */
if ((fp=fopen(file1,"r")) == NULL) if ((fp=fopen(file1,"r")) == NULL)
{ {
@ -49,7 +49,7 @@ void readdata2(long *seed,struct grid_mod *grid,string filename[8],struct vario_
} }
n=(*grid).NX*(*grid).NY*(*grid).NZ; n=(*grid).NX*(*grid).NY*(*grid).NZ;
/* Ouverture du fichier de données sur le champ de perméabilité */ /* Ouverture du fichier de donn<EFBFBD>es sur le champ de perm<72>abilit<69> */
if ((fp=fopen(file2,"r")) == NULL) if ((fp=fopen(file2,"r")) == NULL)
{ {
@ -121,7 +121,7 @@ void readdata2(long *seed,struct grid_mod *grid,string filename[8],struct vario_
break; break;
case 1: case 1:
file3=argv[3]; file3=argv[3];
/* Ouverture du fichier de données de pression*/ /* Ouverture du fichier de donn<EFBFBD>es de pression*/
if ((fp=fopen(file3,"r")) == NULL) if ((fp=fopen(file3,"r")) == NULL)
{ {
fprintf(stderr,"%s :impossible d'ouvrir %s\n",prog, file3); fprintf(stderr,"%s :impossible d'ouvrir %s\n",prog, file3);
@ -159,7 +159,7 @@ void readdata2(long *seed,struct grid_mod *grid,string filename[8],struct vario_
break; break;
case 2: case 2:
/* Ouverture du fichier de données de pression */ /* Ouverture du fichier de donn<EFBFBD>es de pression */
file3=argv[3]; file3=argv[3];
if ((fp=fopen(file3,"r")) == NULL) if ((fp=fopen(file3,"r")) == NULL)
{ {

@ -21,7 +21,7 @@ void readdata3(long *seed,struct grid_mod *grid,string filename[8],struct vario_
file1=argv[1]; file1=argv[1];
file2=argv[2]; file2=argv[2];
/* Ouverture du fichier de données principal */ /* Ouverture du fichier de donn<EFBFBD>es principal */
if ((fp=fopen(file1,"r")) == NULL) if ((fp=fopen(file1,"r")) == NULL)
{ {
@ -50,7 +50,7 @@ void readdata3(long *seed,struct grid_mod *grid,string filename[8],struct vario_
} }
n=(*grid).NX*(*grid).NY*(*grid).NZ; n=(*grid).NX*(*grid).NY*(*grid).NZ;
/* Ouverture du fichier de données sur le champ de perméabilité */ /* Ouverture du fichier de donn<EFBFBD>es sur le champ de perm<72>abilit<69> */
if ((fp=fopen(file2,"r")) == NULL) if ((fp=fopen(file2,"r")) == NULL)
{ {
@ -122,7 +122,7 @@ void readdata3(long *seed,struct grid_mod *grid,string filename[8],struct vario_
break; break;
case 1: case 1:
file3=argv[3]; file3=argv[3];
/* Ouverture du fichier de données de pression*/ /* Ouverture du fichier de donn<EFBFBD>es de pression*/
if ((fp=fopen(file3,"r")) == NULL) if ((fp=fopen(file3,"r")) == NULL)
{ {
fprintf(stderr,"%s :impossible d'ouvrir %s\n",prog, file3); fprintf(stderr,"%s :impossible d'ouvrir %s\n",prog, file3);
@ -160,7 +160,7 @@ void readdata3(long *seed,struct grid_mod *grid,string filename[8],struct vario_
break; break;
case 2: case 2:
/* Ouverture du fichier de données de pression */ /* Ouverture du fichier de donn<EFBFBD>es de pression */
file3=argv[3]; file3=argv[3];
if ((fp=fopen(file3,"r")) == NULL) if ((fp=fopen(file3,"r")) == NULL)
{ {

@ -53,12 +53,14 @@ scannerADT NewScanner(void)
void FreeScanner(scannerADT scanner) void FreeScanner(scannerADT scanner)
{ {
printf("FreeScanner llama a FreeBlock\n");
if (scanner->str != NULL) FreeBlock(scanner->str); if (scanner->str != NULL) FreeBlock(scanner->str);
FreeBlock(scanner); FreeBlock(scanner);
} }
void SetScannerString(scannerADT scanner, string str) void SetScannerString(scannerADT scanner, string str)
{ {
printf("SetScannerString llama a FreeBlock\n");
if (scanner->str != NULL) FreeBlock(scanner->str); if (scanner->str != NULL) FreeBlock(scanner->str);
scanner->str = CopyString(str); scanner->str = CopyString(str);
scanner->len = StringLength(str); scanner->len = StringLength(str);

@ -44,6 +44,7 @@ int GetInteger(void)
line = GetLine(); line = GetLine();
switch (sscanf(line, " %d %c", &value, &termch)) { switch (sscanf(line, " %d %c", &value, &termch)) {
case 1: case 1:
printf("GetInteger llama a FreeBlock\n");
FreeBlock(line); FreeBlock(line);
return (value); return (value);
case 2: case 2:
@ -53,6 +54,7 @@ int GetInteger(void)
printf("Please enter an integer\n"); printf("Please enter an integer\n");
break; break;
} }
printf("GetInteger llama a FreeBlock\n");
FreeBlock(line); FreeBlock(line);
printf("Retry: "); printf("Retry: ");
} }
@ -77,6 +79,7 @@ long GetLong(void)
printf("Please enter an integer\n"); printf("Please enter an integer\n");
break; break;
} }
printf("GetLong llama a FreeBlock\n");
FreeBlock(line); FreeBlock(line);
printf("Retry: "); printf("Retry: ");
} }
@ -101,6 +104,7 @@ double GetReal(void)
printf("Please enter a real number\n"); printf("Please enter a real number\n");
break; break;
} }
printf("GetReal llama a FreeBlock\n");
FreeBlock(line); FreeBlock(line);
printf("Retry: "); printf("Retry: ");
} }

@ -11,7 +11,7 @@
/* List of functions: */ /* List of functions: */
/* ------------------ */ /* ------------------ */
/* kgeneration, FFTMA2, prebuild_gwn, build_real, addstat2, clean_real */ /* kgeneration, FFTMA2, prebuild_gwn, build_real, clean_real */
/*FUNCTIONS*/ /*FUNCTIONS*/
@ -75,8 +75,6 @@ void prebuild_gwn(struct grid_mod grid,int n[3],struct realization_mod *realin,d
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 addstat2(struct realization_mod *realin,struct statistic_mod stat ,struct realization_mod *realout,struct realization_mod *realout2);
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

@ -21,7 +21,7 @@ void pgeneration2(int n[3],struct grid_mod grid,struct statistic_mod stat,struc
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 FFTPressure(int n[3],struct grid_mod grid,struct realization_mod *realin,struct statistic_mod stat,struct pressure_mod gradient,struct realization_mod *realout,struct realization_mod *realout2,struct realization_mod *realout3,struct realization_mod *realout4, int solver); //void FFTPressure(int n[3],struct grid_mod grid,struct realization_mod *realin,struct statistic_mod stat,struct pressure_mod gradient,struct realization_mod *realout,struct realization_mod *realout2,struct realization_mod *realout3,struct realization_mod *realout4, int solver);
void build_pressure(int n[3],struct grid_mod grid,struct pressure_mod gradient,double *realization,double *ireal,double *pressure,double *ipressure); void build_pressure(int n[3],struct grid_mod grid,struct pressure_mod gradient,double *realization,double *ireal,double *pressure,double *ipressure);
@ -44,15 +44,11 @@ void total_pressure(struct grid_mod grid,struct pressure_mod gradient,struct rea
void total_velocity(struct grid_mod grid,double mean,int direction,struct pressure_mod gradient,struct realization_mod *realout); void total_velocity(struct grid_mod grid,double mean,int direction,struct pressure_mod gradient,struct realization_mod *realout);
void clean_real2(struct realization_mod *realin,int n[3],struct grid_mod grid,int solver,double *vectorresult,struct realization_mod *realout);
void normAxes(double *vec, double *normed); void normAxes(double *vec, double *normed);
void waveVectorCompute1D(int n,double *vec); void waveVectorCompute1D(int n,double *vec);
void waveVectorCompute3D(int nX,int nY, int nZ, /*float dX, float dY, float dZ,*/ double nDir[3], double *waveVect); void waveVectorCompute3D(int nX,int nY, int nZ, /*float dX, float dY, float dZ,*/ double nDir[3], double *waveVect);
void derivReal(struct realization_mod *Z, struct realization_mod *dZ, double *dir, struct grid_mod *grid, struct vario_mod vario);
void mat_vec(double *C, double *x, double *b, int n); void mat_vec(double *C, double *x, double *b, int n);

@ -32,7 +32,7 @@ static PyObject* genFunc(PyObject* self, PyObject* args)
PyObject* out_array; PyObject* out_array;
npy_intp out_dims[NPY_MAXDIMS]; npy_intp out_dims[NPY_MAXDIMS];
printf("estoy en genfunc"); printf("estoy edsn genfunc");
if(!Py_getvalues(args, &seed, &grid, &variogram, &stat)) return NULL; if(!Py_getvalues(args, &seed, &grid, &variogram, &stat)) return NULL;

@ -8,7 +8,6 @@ module_FFTMA = Extension(
"moduleFFTMA.c", "moduleFFTMA.c",
"./lib_src/Py_getvalues.c", "./lib_src/Py_getvalues.c",
"./lib_src/Py_kgeneration.c", "./lib_src/Py_kgeneration.c",
"./lib_src/genlib.c",
"./lib_src/random.c", "./lib_src/random.c",
"./lib_src/simpio.c", "./lib_src/simpio.c",
"./lib_src/strlib.c", "./lib_src/strlib.c",
@ -16,8 +15,6 @@ module_FFTMA = Extension(
"./lib_src/scanadt.c", "./lib_src/scanadt.c",
"./lib_src/stack.c", "./lib_src/stack.c",
"./lib_src/gammf.c", "./lib_src/gammf.c",
"./lib_src/fftma.c",
"./lib_src/addstat.c",
"./lib_src/axes.c", "./lib_src/axes.c",
"./lib_src/cgrid.c", "./lib_src/cgrid.c",
"./lib_src/covariance.c", "./lib_src/covariance.c",
@ -43,20 +40,15 @@ module_FFTMA = Extension(
"./lib_src/fftma2.c", "./lib_src/fftma2.c",
"./lib_src/prebuild_gwn.c", "./lib_src/prebuild_gwn.c",
"./lib_src/build_real.c", "./lib_src/build_real.c",
"./lib_src/addstat2.c",
"./lib_src/clean_real.c", "./lib_src/clean_real.c",
"./lib_src/pgeneration.c", "./lib_src/pgeneration.c",
"./lib_src/pgeneration2.c", "./lib_src/pgeneration2.c",
"./lib_src/FFTPressure.c",
"./lib_src/FFTtest.c",
"./lib_src/build_pressure.c", "./lib_src/build_pressure.c",
"./lib_src/build_velocity.c", "./lib_src/build_velocity.c",
"./lib_src/total_pressure.c", "./lib_src/total_pressure.c",
"./lib_src/total_velocity.c", "./lib_src/total_velocity.c",
"./lib_src/clean_real2.c",
"./lib_src/waveVectorCompute3D.c", "./lib_src/waveVectorCompute3D.c",
"./lib_src/mat_vec.c", "./lib_src/mat_vec.c",
"./lib_src/derivReal.c",
"./lib_src/inputdata.c", "./lib_src/inputdata.c",
"./lib_src/inputfiledata.c", "./lib_src/inputfiledata.c",
"./lib_src/debuginput.c", "./lib_src/debuginput.c",

Loading…
Cancel
Save