From 459817378f0c4a565c699f3fafedca351dec0307 Mon Sep 17 00:00:00 2001
From: "joeri.brackenhoff" <joeri.brackenhoff@login0.ogun.local>
Date: Wed, 27 Mar 2019 07:23:31 -0300
Subject: [PATCH] 3D

---
 FFTlib/cc1fft.c             | 3 +--
 FFTlib/ccmfft.c             | 3 ++-
 FFTlib/cr1fft.c             | 3 ++-
 FFTlib/crmfft.c             | 3 ++-
 FFTlib/rc1fft.c             | 3 ++-
 FFTlib/rcmfft.c             | 3 ++-
 marchenko3D/getFileInfo3D.c | 4 ++--
 marchenko3D/makeWindow3D.c  | 2 +-
 marchenko3D/marchenko3D.c   | 7 +++----
 9 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/FFTlib/cc1fft.c b/FFTlib/cc1fft.c
index 2fc4e63..dadadc5 100644
--- a/FFTlib/cc1fft.c
+++ b/FFTlib/cc1fft.c
@@ -64,9 +64,8 @@ void cc1fft(complex *data, int n, int sign)
 	static DFTI_DESCRIPTOR_HANDLE handle[MAX_NUMTHREADS];
 	static int nprev[MAX_NUMTHREADS];
     MKL_LONG Status;
-	int id;
 #endif
-
+	int id;
 #ifdef _OPENMP
 	id = omp_get_thread_num();
 #else
diff --git a/FFTlib/ccmfft.c b/FFTlib/ccmfft.c
index fbbfde3..c566f67 100644
--- a/FFTlib/ccmfft.c
+++ b/FFTlib/ccmfft.c
@@ -67,8 +67,9 @@ void ccmfft(complex *data, int n1, int n2, int ld1, int sign)
 	static DFTI_DESCRIPTOR_HANDLE handle[MAX_NUMTHREADS];
 	static int nprev[MAX_NUMTHREADS];
     MKL_LONG Status;
-	int j, id;
+	int j;
 #endif
+    int id;
 
 #ifdef _OPENMP
 	id = omp_get_thread_num();
diff --git a/FFTlib/cr1fft.c b/FFTlib/cr1fft.c
index 4831beb..9f20a51 100644
--- a/FFTlib/cr1fft.c
+++ b/FFTlib/cr1fft.c
@@ -61,8 +61,9 @@ void cr1fft(complex *cdata, REAL *rdata, int n, int sign)
 	static int nprev[MAX_NUMTHREADS];
 	REAL *tmp;
     MKL_LONG Status;
-	int i, id;
+	int i;
 #endif
+    int id;
 
 #ifdef _OPENMP
 	id = omp_get_thread_num();
diff --git a/FFTlib/crmfft.c b/FFTlib/crmfft.c
index e4dad54..10ee07b 100644
--- a/FFTlib/crmfft.c
+++ b/FFTlib/crmfft.c
@@ -75,8 +75,9 @@ void crmfft(complex *cdata, REAL *rdata, int n1, int n2, int ldc, int ldr, int s
 	static int nprev[MAX_NUMTHREADS];
     REAL *tmp;
     MKL_LONG Status;
-	int i, j, id;
+	int i, j;
 #endif
+    int id;
 
 #ifdef _OPENMP
 	id = omp_get_thread_num();
diff --git a/FFTlib/rc1fft.c b/FFTlib/rc1fft.c
index 9968442..733786c 100644
--- a/FFTlib/rc1fft.c
+++ b/FFTlib/rc1fft.c
@@ -60,8 +60,9 @@ void rc1fft(REAL *rdata, complex *cdata, int n, int sign)
 	static DFTI_DESCRIPTOR_HANDLE handle[MAX_NUMTHREADS];
 	static int nprev[MAX_NUMTHREADS];
     MKL_LONG Status;
-	int i, id;
+	int i;
 #endif
+    int id;
 
 #ifdef _OPENMP
 	id = omp_get_thread_num();
diff --git a/FFTlib/rcmfft.c b/FFTlib/rcmfft.c
index 574de30..da085ca 100644
--- a/FFTlib/rcmfft.c
+++ b/FFTlib/rcmfft.c
@@ -72,8 +72,9 @@ void rcmfft(REAL *rdata, complex *cdata, int n1, int n2, int ldr, int ldc, int s
 	static DFTI_DESCRIPTOR_HANDLE handle[MAX_NUMTHREADS];
 	static int nprev[MAX_NUMTHREADS];
     MKL_LONG Status;
-	int i, j, id;
+	int i, j;
 #endif
+    int id;
 
 #ifdef _OPENMP
 	id = omp_get_thread_num();
diff --git a/marchenko3D/getFileInfo3D.c b/marchenko3D/getFileInfo3D.c
index cdf0000..fd00cee 100644
--- a/marchenko3D/getFileInfo3D.c
+++ b/marchenko3D/getFileInfo3D.c
@@ -176,7 +176,7 @@ long getFileInfo3D(char *filename, long *n1, long *n2, long *n3, long *ngath, fl
                 itrace++;
             }
             if (itrace>1) {
-                *n2 = itrace/igy;
+                *n2 = MAX(itrace/igy,*n2);
                 *n3 = igy;
                 if (*n2>1) {
                     dxrcv  = (float)(gx_end - gx_start)/(float)(*n2-1);
@@ -194,7 +194,7 @@ long getFileInfo3D(char *filename, long *n1, long *n2, long *n3, long *ngath, fl
                 dysrc = (float)(hdr.sy - sy_shot)*scl;
             }
             else {
-                *n2 = MAX(hdr.trwf, 1);
+                *n2 = MAX(MAX(hdr.trwf, 1),*n2);
                 *n3 = 1;
                 *d2 = hdr.d2;
                 *d3 = 1.0;
diff --git a/marchenko3D/makeWindow3D.c b/marchenko3D/makeWindow3D.c
index bd5ba82..2d2d553 100644
--- a/marchenko3D/makeWindow3D.c
+++ b/marchenko3D/makeWindow3D.c
@@ -59,7 +59,7 @@ void makeWindow3D(char *file_ray, char *file_amp, char *file_wav, float dt, floa
 	    wavtmp = (float *)calloc(ntwav,sizeof(float));
         readData3D(fp, wavtmp, &hdr, ntwav);
         //Fit the wavelet into the same time-axis as the Marchenko scheme
-        for (i=0; i<ntwav; i++) {
+        for (i=0; i<(ntfft/2); i++) {
             wavelet[i] = wavtmp[i];
             wavelet[ntfft-1-i] = wavtmp[ntwav-1-i];
         }
diff --git a/marchenko3D/marchenko3D.c b/marchenko3D/marchenko3D.c
index 8569691..037f247 100644
--- a/marchenko3D/marchenko3D.c
+++ b/marchenko3D/marchenko3D.c
@@ -282,7 +282,7 @@ int main (int argc, char **argv)
 /* G_d = p_0^+ = G_d (-t) ~ Tinv */
     if (file_ray!=NULL) {
         makeWindow3D(file_ray, file_amp, file_wav, dt, xrcvsyn, yrcvsyn, xsyn, ysyn, zsyn, 
-            xnxsyn, Nfoc, nx, ny, ntfft, muteW, G_d, verbose);
+            xnxsyn, Nfoc, nxs, nys, ntfft, muteW, G_d, verbose);
     }
     else {
         mode=-1; /* apply complex conjugate to read in data */
@@ -330,8 +330,7 @@ int main (int argc, char **argv)
     if (yrcvsyn[0] != 0 || yrcvsyn[nys*nxs-1] != 0 )  fysb = yrcvsyn[0];
     if (nxs>1) { 
         fxse = fxsb + (float)(nxs-1)*dxs;
-        dxf = (xrcvsyn[nys*nxs-1] - xrcvsyn[0])/(float)(nxs-1);
-        vmess("fxsb%.3f fxse:%.3f dxf:%.3f",fxsb,fxse,dxf);
+        dxf = (fxse - fxsb)/(float)(nxs-1);
     }
     else {
         fxse = fxsb;
@@ -342,7 +341,7 @@ int main (int argc, char **argv)
     }
     if (nys>1) {
         fyse = fysb + (float)(nys-1)*dys;
-        dyf = (yrcvsyn[nys*nxs-1] - yrcvsyn[0])/(float)(nys-1);
+        dyf = (fyse - fysb)/(float)(nys-1);
     }
     else {
         fyse = fysb;
-- 
GitLab