Commit b9056d1e authored by niklas.thiel's avatar niklas.thiel

parallised wavefield separation

parent d6833638
......@@ -816,6 +816,17 @@ int main(int argc, char **argv){
MPI_Barrier(MPI_COMM_WORLD);
/* MPI split for processors used for pup parallelisation */
int myid_pup, pupid=0;
MPI_Comm MPI_COMM_PUP;
if (MYID<=7) pupid = 1;
else pupid = 0;
MPI_Comm_split(MPI_COMM_WORLD, pupid, MYID, &MPI_COMM_PUP);
MPI_Comm_rank(MPI_COMM_PUP, &myid_pup);
/* end of MPI split for processors with ntr>0 */
SHOTINC=1;
RECINC=1;
......@@ -1384,7 +1395,7 @@ int main(int argc, char **argv){
/* wavefield separation for forward modelling of STF*/
if (WAVESEP==1) {
if (MYID == 0) fprintf(FP,"\n start wavefield separation...");
if (MYID == 0 || MYID==1) pup(fulldata_p, fulldata_vy, ntr_glob,recpos,ishot,ns,iter);
if (pupid) pup(fulldata_p, fulldata_vy, ntr_glob,recpos,ishot,ns,iter,MPI_COMM_PUP,myid_pup);
if ((VERBOSE==1)&&(MYID == 0)) fprintf(FP,"\n wavefield separation finished"); /* save pup*/
if (VERBOSE==1 && MYID==0) {
fprintf(FP,"Write PUP data to file...\n ");
......@@ -1939,7 +1950,7 @@ int main(int argc, char **argv){
/* wavefield separation*/
if (WAVESEP==1) {
if (MYID == 0) fprintf(FP,"\n start wavefield separation...");
if (MYID == 0 || MYID==1) pup(fulldata_p, fulldata_vy, ntr_glob,recpos,ishot,ns,iter);
if (pupid) pup(fulldata_p, fulldata_vy, ntr_glob,recpos,ishot,ns,iter,MPI_COMM_PUP,myid_pup);
if ((VERBOSE==1)&&(MYID == 0)) fprintf(FP,"\n wavefield separation finished"); /* save pup*/
if (VERBOSE==1 && MYID==0) {
fprintf(FP,"Write PUP data to file...\n ");
......@@ -3542,7 +3553,7 @@ int main(int argc, char **argv){
catseis(sectionvy, fulldata_vy, recswitch, ntr_glob, MPI_COMM_WORLD);
catseis(sectionp, fulldata_p, recswitch, ntr_glob, MPI_COMM_WORLD);
if (MYID == 0) fprintf(FP,"\n start wavefield separation...");
if (MYID == 0 || MYID==1) pup(fulldata_p, fulldata_vy, ntr_glob,recpos,ishot,ns,iter);
if (pupid) pup(fulldata_p, fulldata_vy, ntr_glob,recpos,ishot,ns,iter,MPI_COMM_PUP,myid_pup);
if ((VERBOSE==1)&&(MYID == 0)) fprintf(FP,"\n wavefield separation finished"); /* save pup*/
if (VERBOSE==1 && MYID==0) {
fprintf(FP,"Write PUP data to file...\n ");
......
......@@ -19,7 +19,7 @@ EXEC= ../bin
# LINUX with OpenMPI / IntelMPI and INTEL Compiler
# Use icc whenever possible, this will be much faster than gcc
CC=mpicc
CC=mpiicc
LFLAGS=-lm -lcseife -lstfinv -laff -lfourierxx -lfftw3 -lstdc++
CFLAGS=-O3
SFLAGS=-L./../contrib/libcseife -L./../contrib/bin
......@@ -183,8 +183,7 @@ IFOS2D= \
create_trkill_table.c \
filter_frequencies.c \
pup.c \
fft2_filt.c \
fft2d.c
fft.c
# -------------
# Targes
......
......@@ -180,8 +180,10 @@ double calc_misfit(float **sectiondata, float **section, int ntr, int ns, int LN
abs_sectiondata+=intseis_sectiondata[i][j]*intseis_sectiondata[i][j];
abs_section+=intseis_section[i][j]*intseis_section[i][j];
}
abs_sectiondata=sqrt(abs_sectiondata);
abs_section=sqrt(abs_section);
if (abs_sectiondata==0) abs_sectiondata=1;
else abs_sectiondata=sqrt(abs_sectiondata);
if (abs_section==0) abs_section==1;
else abs_section=sqrt(abs_section);
}
/* calculate L2 residuals */
......
......@@ -207,8 +207,10 @@ double calc_res(float **sectiondata, float **section, float **sectiondiff, float
abs_section+=intseis_section[i][j]*intseis_section[i][j];
sectiondata_mult_section+=intseis_sectiondata[i][j]*intseis_section[i][j]; /* calculation of dot product for measured (section) and synthetic (sectiondata) data*/
}
abs_sectiondata=sqrt(abs_sectiondata);
abs_section=sqrt(abs_section);
if (abs_sectiondata==0) abs_sectiondata=1;
else abs_sectiondata=sqrt(abs_sectiondata);
if (abs_section==0) abs_section==1;
else abs_section=sqrt(abs_section);
}
/* calculate residual seismograms and norm */
......
......@@ -25,29 +25,6 @@
#define REQUEST_COUNT 4
#define WORKFLOW_MAX_VAR 13
/***************/
/* FFT2D stuff */
/***************/
typedef struct {float re; float im;} COMPLEX;
typedef struct {double re; double im;} DCOMPLEX;
#ifndef ERROR
#define ERROR -1
#define NO_ERROR 0
#endif
#define FFT_FORWARD 0
#define FFT_INVERSE 1
#define TWOPI 6.2831853071795865 /* 2.0 * PI */
#define HALFPI 1.5707963267948966 /* PI / 2.0 */
#define PI8 0.392699081698724 /* PI / 8.0 */
#define RT2 1.4142135623731 /* sqrt(2.0) */
#define IRT2 0.707106781186548 /* 1.0/sqrt(2.0) */
extern int forward_fft2f(COMPLEX *array, int rows, int cols); /* Perform forward 2D transform on a COMPLEX array. */
extern int inverse_fft2f(COMPLEX *array, int rows, int cols); /* Perform inverse 2D transform on a COMPLEX array. */
/****************************/
/* declaration of functions */
/****************************/
......@@ -156,9 +133,9 @@ void FFT_filt(float ** data, float freqshift, int ntr, int ns,int method);
/*short FFT(short int dir,long m,float *x,float *y);*/
void FFT(int isign, unsigned long nlog, float *re, float *im); /* NR version*/
// void FFT(int isign, unsigned long nlog, float *re, float *im); /* NR version*/
void fft2(float **array, float **arrayim, int NYG, int NXG, int dir); /* 2d fft filtering*/
void fft(float *array, float *arrayim, int npad, int dir); /* 1d fft*/
float *filter_frequencies(int *nfrq);
......@@ -236,7 +213,7 @@ void psource(int nt, float ** sxx, float ** syy, float ** sp,
void psource_rsg(int nt, float ** sxx, float ** syy,
float ** srcpos_loc, float ** signals, int nsrc);
void pup(float** data_p, float** data_vy, int ntr_glob, int** recpos, int ishot, int ns, int iter );
void pup(float** data_p, float** data_vy, int ntr_glob, int** recpos, int ishot, int ns, int iter, MPI_Comm newcomm_nodentr, int myid_pup );
float *rd_sour(int *nts,FILE* fp_source);
......@@ -500,7 +477,6 @@ void declare_error(char err_text[]);
void warning(char warn_text[]);
double maximum(float **a, int nx, int ny);
float *vector(int nl, int nh);
COMPLEX *cplxvector(int nstart, int nend);
int *ivector(int nl, int nh);
double *dvector(int nl, int nh);
float **fmatrix(int nrl, int nrh, int ncl, int nch);
......@@ -510,7 +486,6 @@ float **matrix(int nrl, int nrh, int ncl, int nch);
int **imatrix(int nrl, int nrh, int ncl, int nch);
float ***f3tensor(int nrl, int nrh, int ncl, int nch,int ndl, int ndh);
void free_vector(float *v, int nl, int nh);
void free_cplxvector(COMPLEX *v, int nstart, int nend);
void free_dvector(double *v, int nl, int nh);
void free_ivector(int *v, int nl, int nh);
void free_matrix(float **m, int nrl, int nrh, int ncl, int nch);
......
/*-----------------------------------------------------------------------------------------
* Copyright (C) 2016 For the list of authors, see file AUTHORS.
*
* This file is part of IFOS.
*
* IFOS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 2.0 of the License only.
*
* IFOS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with IFOS. See file COPYING and/or <http://www.gnu.org/licenses/gpl-2.0.html>.
-----------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------
* 1D-FFT
* ----------------------------------------------------------------------*/
#include "fd.h"
#include <fftw3.h>
void fft(float *array, float *arrayim, int npad, int dir) {
/* declaration of local variables */
int i,j;
/* declaration of variables for FFTW3*/
fftw_complex *in,*out;
fftw_plan p;
in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * npad);
out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * npad);
for (j=0;j<npad;j++){
in[j][0]=array[j+1];
in[j][1]=arrayim[j+1];
}
if (dir==1) { p = fftw_plan_dft_1d(npad, in, out, FFTW_FORWARD, FFTW_ESTIMATE); }
else { p = fftw_plan_dft_1d(npad, in, out, FFTW_BACKWARD, FFTW_ESTIMATE); }
fftw_execute(p);
/* write output into data matrix */
for(j=0;j<npad;j++){
array[j+1] = out[j][0];
arrayim[j+1] = out[j][1];
}
fftw_free(in);
fftw_free(out);
fftw_destroy_plan(p);
}
This diff is collapsed.
......@@ -89,9 +89,6 @@ float maximum_m(float **mat, int nx, int ny)
return maxm;
}
float *vector(int ni, int nj){
float *a;
int k;
......@@ -102,22 +99,6 @@ float *vector(int ni, int nj){
return a-ni+SHIFT_IND;
}
COMPLEX *cplxvector(int nstart, int nend){
/* allocate a complex vector with subscript range v[nstart..nend] and initializing
this vector, eg. vector[nstart..nend]=0.0 */
COMPLEX *v;
int i;
v=(COMPLEX *)malloc((size_t) ((nend-nstart+1+SHIFT_IND)*sizeof(COMPLEX)));
if (!v) err("allocation failure in function cplxvector()");
for (i=0;i<(nend-nstart+1+SHIFT_IND);i++){
v[i].re=0.0;
v[i].im=0.0;
}
return v-nstart+SHIFT_IND;
}
int *ivector(int ni, int nj){
int *a;
......@@ -364,11 +345,6 @@ void free_vector(float *a, int ni, int nj){
free((FREE_ARGUMENT) (a+ni-SHIFT_IND));
}
void free_cplxvector(COMPLEX *v, int nstart, int nend){
/* free a complex vector allocated with vector() */
free((char*) (v+nstart-SHIFT_IND));
}
void free_ivector(int *a, int ni, int nj){
free((FREE_ARGUMENT) (a+ni-SHIFT_IND));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment