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

Merge master into pup

Merge branch 'master' of git.scc.kit.edu:GPIAG-Software/IFOS2D into pup

Conflicts:
	src/Makefile
parents 2a316380 0e8335b9
......@@ -166,7 +166,9 @@ libaff.so: $(INSTHEADER) $(LIBOBS)
> $@; \
[ -s $@ ] || rm -f $@'
ifneq ($(MAKECMDGOALS),clean)
include $(patsubst %.cc,%.d,$(SRC))
endif
# this include will be used once we initiate the precompiled library version
# until then it's just waiting here
......
......@@ -200,7 +200,9 @@ libfourierxx.so: install-include libfourier.a $(LIBOBSXX)
> $@; \
[ -s $@ ] || rm -f $@'
ifneq ($(MAKECMDGOALS),clean)
include $(patsubst %.cc,%.d,$(SRC))
endif
#======================================================================
# header files
......
......@@ -113,14 +113,16 @@ SUBS=$(patsubst %.f,%.o,$(wildcard subs/*.f))
# Fortran include dependencies
%.d: %.f
echo $<: $(addprefix subs/,$(shell cat $< | egrep '^ +include' | cut -f 2 -d \' | sort | uniq)) > $@
include $(patsubst %.f,%.d,$(wildcard subs/*.f))
ifneq ($(MAKECMDGOALS),clean)
include $(patsubst %.f,%.d,$(wildcard subs/*.f))
endif
#======================================================================
$(INCINSTALLPATH)/%.h: %.h
mkdir -p $(INCINSTALLPATH)
-rm -fv $@
/bin/cp -vpd $< $@
/bin/cp -vp $< $@
.PHONY: install-include
install-include: $(INSTHEADER)
......@@ -152,7 +154,9 @@ reinstall:
# library part
# ------------
ifneq ($(MAKECMDGOALS),clean)
include $(patsubst %.c,%.d,$(CLIBSRC))
endif
libcseife.a: $(patsubst %.c,%.o,$(CLIBSRC))
libseife.a: $(SUBS)
......
......@@ -170,8 +170,10 @@ clean: ;
# library part
# ------------
ifneq ($(MAKECMDGOALS),clean)
include $(patsubst %.cc,%.d,$(LIBCCSRC) $(TESTCCSRC)) \
$(patsubst %.c,%.d,$(LIBCSRC) $(TESTCSRC))
endif
libstfinv.a: $(patsubst %.cc,%.o,$(LIBCCSRC)) \
$(patsubst %.c,%.o,$(LIBCSRC))
......
......@@ -46,7 +46,7 @@ void model_acoustic(float ** rho, float ** pi){
/*-----------------------------------------------------------------------*/
y=h/DH;
if(y==NYG) err(" \n y is equal NYG !! see src/model_grad.c \n ");
if(y==NYG) declare_error(" \n y is equal NYG !! see src/model_grad.c \n ");
grad1=(vp2-vp1)/y;
grad3=(rho2-rho1)/y;
......
......@@ -46,7 +46,7 @@ void model_elastic(float ** rho, float ** pi, float ** u){
/*-----------------------------------------------------------------------*/
y=h/DH;
if(y==NYG) err(" \n y is equal NYG !! see src/model_grad.c \n ");
if(y==NYG) declare_error(" \n y is equal NYG !! see src/model_grad.c \n ");
grad1=(vp2-vp1)/y;
grad2=(vs2-vs1)/y;
grad3=(rho2-rho1)/y;
......
......@@ -52,7 +52,7 @@ void model(float ** rho, float ** pi, float ** u, float ** taus, float **
y=h/DH;
if(y==NYG) err(" \n y is equal NYG !! see src/model_grad.c \n ");
if(y==NYG) declare_error(" \n y is equal NYG !! see src/model_grad.c \n ");
grad1=(vp2-vp1)/y;
grad2=(vs2-vs1)/y;
grad3=(rho2-rho1)/y;
......
......@@ -52,7 +52,7 @@ void model_viscac(float ** rho, float ** pi, float ** taup, float * eta){
y=h/DH;
if(y==NYG) err(" \n y is equal NYG !! see src/model_grad.c \n ");
if(y==NYG) declare_error(" \n y is equal NYG !! see src/model_grad.c \n ");
grad1=(vp2-vp1)/y;
grad3=(rho2-rho1)/y;
......
......@@ -38,7 +38,7 @@ void model_elastic(float ** rho, float ** pi, float ** u){
/* local variables */
float rhov, muv, piv, vp, vs;
float rhov, vp, vs;
float vp0, vs0, rho0, gvp, gvs, grho;
int i, j, ii, jj;
FILE *fp_vs, *fp_vp, *fp_rho;
......@@ -66,18 +66,18 @@ void model_elastic(float ** rho, float ** pi, float ** u){
fprintf(FP,"\t Vp:\n\t %s.vp\n\n",MFILE);
sprintf(filename,"%s.vp",MFILE);
fp_vp=fopen(filename,"r");
if (fp_vp==NULL) err(" Could not open model file for Vp ! ");
if (fp_vp==NULL) declare_error(" Could not open model file for Vp ! ");
fprintf(FP,"\t Vs:\n\t %s.vs\n\n",MFILE);
sprintf(filename,"%s.vs",MFILE);
fp_vs=fopen(filename,"r");
if (fp_vs==NULL) err(" Could not open model file for Vs ! ");
if (fp_vs==NULL) declare_error(" Could not open model file for Vs ! ");
fprintf(FP,"\t Density:\n\t %s.rho\n\n",MFILE);
sprintf(filename,"%s.rho",MFILE);
fp_rho=fopen(filename,"r");
if (fp_rho==NULL) err(" Could not open model file for densities ! ");
if (fp_rho==NULL) declare_error(" Could not open model file for densities ! ");
}
/* read density and Lame parameters */
......@@ -86,18 +86,18 @@ void model_elastic(float ** rho, float ** pi, float ** u){
fprintf(FP,"\t Lame parameter lambda:\n\t %s.lam\n\n",MFILE);
sprintf(filename,"%s.lam",MFILE);
fp_vp=fopen(filename,"r");
if (fp_vp==NULL) err(" Could not open model file for Lame parameter lambda ! ");
if (fp_vp==NULL) declare_error(" Could not open model file for Lame parameter lambda ! ");
fprintf(FP,"\t Lame parameter mu:\n\t %s.vs\n\n",MFILE);
sprintf(filename,"%s.mu",MFILE);
fp_vs=fopen(filename,"r");
if (fp_vs==NULL) err(" Could not open model file for Lame parameter mu ! ");
if (fp_vs==NULL) declare_error(" Could not open model file for Lame parameter mu ! ");
fprintf(FP,"\t Density:\n\t %s.rho\n\n",MFILE);
sprintf(filename,"%s.rho",MFILE);
fp_rho=fopen(filename,"r");
if (fp_rho==NULL) err(" Could not open model file for densities ! ");
if (fp_rho==NULL) declare_error(" Could not open model file for densities ! ");
}
......
......@@ -67,7 +67,7 @@ void model(float ** rho, float ** pi, float ** u, float ** taus, float **
/*read FL nodes from File*/
flfile=fopen("model/final.mod.flnodes.Q20","r");
if (flfile==NULL) err(" FL-file could not be opened !");
if (flfile==NULL) declare_error(" FL-file could not be opened !");
......
......@@ -33,7 +33,7 @@ void model(float ** rho, float ** pi, float ** u, float ** taus, float **
extern char INV_MODELFILE[STRING_SIZE];
extern float DH, *FL, TAU, DT;
/* local variables */
float vp, vs, rhov, grad, y1, y2, ts, tp, muv, piv, *pts;
float vp, vs, rhov, grad, y1, y2, ts, tp, *pts;
int i, j, ii, jj, l;
char modfile[STRING_SIZE];
......@@ -53,7 +53,7 @@ void model(float ** rho, float ** pi, float ** u, float ** taus, float **
y1=h/DH;
y2=layer/DH;
if(y1==NYG) err(" \n y is equal NYG !! see src/model_grad.c \n ");
if(y1==NYG) declare_error(" \n y is equal NYG !! see src/model_grad.c \n ");
grad=(vs2-vs1)/y1;
......
......@@ -57,7 +57,7 @@ void model_acoustic(float **rho, float **pi){
if(SWS_TAPER_FILE) taper=matrix(-nd+1,NY+nd,-nd+1,NX+nd);
flfile=fopen("model_true/flnodes.toy_example_ac.start","r");
if (flfile==NULL) err(" FL-file could not be opened !");
if (flfile==NULL) declare_error(" FL-file could not be opened !");
/* Read parameters */
for (l=1;l<=nodes;l++){
......@@ -187,7 +187,7 @@ void model_acoustic(float **rho, float **pi){
flrho=vector(1,nodes);
flvp=vector(1,nodes);
flfile=fopen("model_true/flnodes.toy_example_ac","r");
if (flfile==NULL) err(" FL-file could not be opened !");
if (flfile==NULL) declare_error(" FL-file could not be opened !");
/* Read parameters */
for (l=1;l<=nodes;l++){
......
......@@ -63,7 +63,7 @@ void model_acoustic(float **rho, float **pi){
/*read FL nodes from File*/
flfile=fopen("model_true/flnodes.toy_example_ac","r");
if (flfile==NULL) err(" FL-file could not be opened !");
if (flfile==NULL) declare_error(" FL-file could not be opened !");
for (l=1;l<=nodes;l++){
......
/*-----------------------------------------------------------------------------------------
* Copyright (C) 2016
*
* This file is part of IFOS2D.
*
* IFOS2D 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.
*
* IFOS2D 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 IFOS2D. See file COPYING and/or <http://www.gnu.org/licenses/gpl-2.0.html>.
-----------------------------------------------------------------------------------------*/
#include "fd.h"
void model_elastic(float ** rho, float ** pi, float ** u){
/*--------------------------------------------------------------------------*/
/* extern variables */
extern int NX, NY, NXG, NYG, POS[3], MYID, L;
extern float DH, DT, *FL, TAU;
extern char MFILE[STRING_SIZE];
extern char INV_MODELFILE[STRING_SIZE];
/* local variables */
float muv, piv, vp, vs, rhov, ts, tp, *pts;
int i, j, ii, jj, l;
char modfile[STRING_SIZE];
FILE *flfile;
int nodes;
char cline[256];
float *fldepth, *flrho, *flvp, *flvs;
/**************************************************/
/* creation of shear wave velocity and TAU models */
/**************************************************/
/*read FL nodes from File*/
nodes=3;
fldepth=vector(1,nodes);
flvs=vector(1,nodes);
flrho=vector(1,nodes);
flvp=vector(1,nodes);
flfile=fopen("model_true/flnodes.toy_example.start","r");
if (flfile==NULL) declare_error(" FL-file could not be opened !");
for (l=1;l<=nodes;l++){
fgets(cline,255,flfile);
if (cline[0]!='#'){
sscanf(cline,"%f%f%f%f",&fldepth[l], &flrho[l], &flvp[l], &flvs[l]);
}
else l=l-1;
}
if(MYID==0){
printf(" ------------------------------------------------------------------ \n\n");
printf(" Information of FL nodes: \n\n");
printf(" \t depth \t vs \n\n");
for (l=1;l<=nodes;l++){
printf(" \t %f \t %f\n\n",fldepth[l],flvs[l]);
}
printf(" ------------------------------------------------------------------ \n\n");
}
/* loop over global grid */
for (i=1;i<=NXG;i++){
for (l=1;l<nodes;l++){
if (fldepth[l]==fldepth[l+1]){
if ((i==1) && (MYID==0)){
printf("depth: %f m: double node\n",fldepth[l]);}}
else{
for (j=(int)(fldepth[l]/DH)+1;j<=(int)(fldepth[l+1]/DH);j++){
vs=0.0;
vs=(DH*(j-1)-fldepth[l])*(flvs[l+1]-flvs[l])/(fldepth[l+1]-fldepth[l])+flvs[l];
vs=vs*1000.0;
muv=vs;
ts=TAU;
tp=TAU;
/* only the PE which belongs to the current global gridpoint
is saving model parameters in his local arrays */
if ((POS[1]==((i-1)/NX)) &&
(POS[2]==((j-1)/NY))){
ii=i-POS[1]*NX;
jj=j-POS[2]*NY;
u[jj][ii]=muv;
}
}
}
}
for (j=(int)(fldepth[nodes]/DH)+1;j<=NYG;j++){
vs=0.0;
vs=flvs[nodes]*1000.0;
muv=vs;
/* only the PE which belongs to the current global gridpoint
is saving model parameters in his local arrays */
if ((POS[1]==((i-1)/NX)) &&
(POS[2]==((j-1)/NY))){
ii=i-POS[1]*NX;
jj=j-POS[2]*NY;
u[jj][ii]=muv;
}
}
}
free_vector(fldepth,1,nodes);
free_vector(flrho,1,nodes);
free_vector(flvp,1,nodes);
free_vector(flvs,1,nodes);
/**************************************************/
/* creation of P wave velocity and density models */
/**************************************************/
/*read FL nodes from File*/
nodes=7;
fldepth=vector(1,nodes);
flvs=vector(1,nodes);
flrho=vector(1,nodes);
flvp=vector(1,nodes);
flfile=fopen("model_true/flnodes.toy_example","r");
flfile=fopen("model_true/flnodes.toy_example.start","r");
if (flfile==NULL) declare_error(" FL-file could not be opened !");
for (l=1;l<=nodes;l++){
fgets(cline,255,flfile);
if (cline[0]!='#'){
sscanf(cline,"%f%f%f%f",&fldepth[l], &flrho[l], &flvp[l], &flvs[l]);
}
else l=l-1;
}
if(MYID==0){
printf(" ------------------------------------------------------------------ \n\n");
printf(" Information of FL nodes: \n\n");
printf(" \t depth \t vp \t rho \n\n");
for (l=1;l<=nodes;l++){
printf(" \t %f \t %f \t %f \n\n",fldepth[l],flvp[l],flrho[l]);
}
printf(" ------------------------------------------------------------------ \n\n");
}
/* loop over global grid */
for (i=1;i<=NXG;i++){
for (l=1;l<nodes;l++){
if (fldepth[l]==fldepth[l+1]){
if ((i==1) && (MYID==0)){
printf("depth: %f m: double node\n",fldepth[l]);}}
else{
for (j=(int)(fldepth[l]/DH)+1;j<=(int)(fldepth[l+1]/DH);j++){
vp=0.0; rhov=0.0;
vp=(DH*(j-1)-fldepth[l])*(flvp[l+1]-flvp[l])/(fldepth[l+1]-fldepth[l])+flvp[l];
vp=vp*1000.0;
rhov=(DH*(j-1)-fldepth[l])*(flrho[l+1]-flrho[l])/(fldepth[l+1]-fldepth[l])+flrho[l];
rhov=rhov*1000.0;
piv=vp;
/* only the PE which belongs to the current global gridpoint
is saving model parameters in his local arrays */
if ((POS[1]==((i-1)/NX)) &&
(POS[2]==((j-1)/NY))){
ii=i-POS[1]*NX;
jj=j-POS[2]*NY;
rho[jj][ii]=rhov;
pi[jj][ii]=piv;
}
}
}
}
for (j=(int)(fldepth[nodes]/DH)+1;j<=NYG;j++){
vp=0.0; rhov=0.0;
vp=flvp[nodes]*1000.0; rhov=flrho[nodes]*1000.0;
piv=vp;
/* only the PE which belongs to the current global gridpoint
is saving model parameters in his local arrays */
if ((POS[1]==((i-1)/NX)) &&
(POS[2]==((j-1)/NY))){
ii=i-POS[1]*NX;
jj=j-POS[2]*NY;
rho[jj][ii]=rhov;
pi[jj][ii]=piv;
}
}
}
// free_vector(fldepth,1,nodes);
// free_vector(flrho,1,nodes);
// free_vector(flvp,1,nodes);
// free_vector(flvs,1,nodes);
//
sprintf(modfile,"%s_rho_it0.bin",INV_MODELFILE);
writemod(modfile,rho,3);
MPI_Barrier(MPI_COMM_WORLD);
if (MYID==0) mergemod(modfile,3);
MPI_Barrier(MPI_COMM_WORLD);
sprintf(modfile,"%s_rho_it0.bin.%i%i",INV_MODELFILE,POS[1],POS[2]);
remove(modfile);
sprintf(modfile,"%s_vs_it0.bin",INV_MODELFILE);
writemod(modfile,u,3);
MPI_Barrier(MPI_COMM_WORLD);
if (MYID==0) mergemod(modfile,3);
MPI_Barrier(MPI_COMM_WORLD);
sprintf(modfile,"%s_vs_it0.bin.%i%i",INV_MODELFILE,POS[1],POS[2]);
remove(modfile);
sprintf(modfile,"%s_vp_it0.bin",INV_MODELFILE);
writemod(modfile,pi,3);
MPI_Barrier(MPI_COMM_WORLD);
if (MYID==0) mergemod(modfile,3);
MPI_Barrier(MPI_COMM_WORLD);
sprintf(modfile,"%s_vp_it0.bin.%i%i",INV_MODELFILE,POS[1],POS[2]);
remove(modfile);
// free_vector(pts,1,L);
}
......@@ -38,7 +38,7 @@ void model_elastic(float ** rho, float ** pi, float ** u){
extern char INV_MODELFILE[STRING_SIZE];
/* local variables */
float muv, piv, vp, vs, rhov, ts, tp, *pts;
float muv, piv, vp, vs, rhov, ts, tp;
int i, j, ii, jj, l;
char modfile[STRING_SIZE];
......@@ -62,7 +62,7 @@ void model_elastic(float ** rho, float ** pi, float ** u){
flrho=vector(1,nodes);
flvp=vector(1,nodes);
flfile=fopen("model_true/flnodes.toy_example.start","r");
if (flfile==NULL) err(" FL-file could not be opened !");
if (flfile==NULL) declare_error(" FL-file could not be opened !");
......@@ -154,7 +154,7 @@ void model_elastic(float ** rho, float ** pi, float ** u){
flrho=vector(1,nodes);
flvp=vector(1,nodes);
flfile=fopen("model_true/flnodes.toy_example","r");
if (flfile==NULL) err(" FL-file could not be opened !");
if (flfile==NULL) declare_error(" FL-file could not be opened !");
for (l=1;l<=nodes;l++){
fgets(cline,255,flfile);
......
......@@ -55,7 +55,7 @@ void model_elastic(float ** rho, float ** pi, float ** u){
/*read FL nodes from File*/
flfile=fopen("model_true/flnodes.toy_example","r");
if (flfile==NULL) err(" FL-file could not be opened !");
if (flfile==NULL) declare_error(" FL-file could not be opened !");
......
......@@ -67,7 +67,7 @@ void model(float ** rho, float ** pi, float ** u, float ** taus, float **
flrho=vector(1,nodes);
flvp=vector(1,nodes);
flfile=fopen("model_true/flnodes.toy_example.start","r");
if (flfile==NULL) err(" FL-file could not be opened !");
if (flfile==NULL) declare_error(" FL-file could not be opened !");
......@@ -165,7 +165,7 @@ void model(float ** rho, float ** pi, float ** u, float ** taus, float **
flrho=vector(1,nodes);
flvp=vector(1,nodes);
flfile=fopen("model_true/flnodes.toy_example","r");
if (flfile==NULL) err(" FL-file could not be opened !");
if (flfile==NULL) declare_error(" FL-file could not be opened !");
for (l=1;l<=nodes;l++){
fgets(cline,255,flfile);
......
......@@ -65,7 +65,7 @@ void model(float ** rho, float ** pi, float ** u, float ** taus, float **
/*read FL nodes from File*/
flfile=fopen("model_true/flnodes.toy_example","r");
if (flfile==NULL) err(" FL-file could not be opened !");
if (flfile==NULL) declare_error(" FL-file could not be opened !");
......
......@@ -25,12 +25,21 @@ else
$(MAKE) -C ../src/ IFOS2D
endif
.PHONY: install
install: clean-bin IFOS2D
.PHONY: clean
clean:
rm -rf ../bin/IFOS2D
rm -rf ../bin/*
$(MAKE) -C ../contrib/aff clean
$(MAKE) -C ../contrib/fourier clean
$(MAKE) -C ../contrib/stfinv clean
$(MAKE) -C ../contrib/libcseife clean
$(MAKE) -C ../src/ clean
.PHONY: clean-bin
clean-bin:
rm -rf ../bin/*
.PHONY: reinstall
reinstall: clean IFOS2D
\ No newline at end of file
#-----------------------------------------------------------------
# JSON PARAMETER FILE FOR IFOS
#-----------------------------------------------------------------
# description:
# description/name of the model: 2 layer example, model grid created by ../genmod/2layer.c
#
{
"Domain Decomposition" : "comment",
"NPROCX" : "4",
......@@ -68,5 +61,5 @@
"FORWARD_ONLY" : "10",
"Verbose mode" : "comment",
"VERBOSE" : "0",
"VERBOSE" : "0"
}
#-----------------------------------------------------------------
# JSON PARAMETER FILE FOR IFOS
#-----------------------------------------------------------------
# description:
# description/name of the model: 2 layer example, model grid created by ../genmod/2layer.c
#
{
"Domain Decomposition" : "comment",
"NPROCX" : "4",
......@@ -105,5 +98,5 @@
"FORWARD_ONLY" : "10",
"Verbose mode" : "comment",
"VERBOSE" : "0",
"VERBOSE" : "0"
}
#-----------------------------------------------------------------
# JSON PARAMETER FILE FOR IFOS
#-----------------------------------------------------------------
# description:
# description/name of the model: 2 layer example, model grid created by ../genmod/2layer.c
#
{
"Domain Decomposition" : "comment",
"NPROCX" : "4",
......@@ -99,5 +92,5 @@
"PRO" : "0.01",
"Verbose mode" : "comment",
"VERBOSE" : "0",
"VERBOSE" : "0"
}
#-----------------------------------------------------------------
# JSON PARAMETER FILE FOR IFOS
#-----------------------------------------------------------------
# description:
# description/name of the model: 2 layer example, model grid created by ../genmod/2layer.c
#
{
"Domain Decomposition" : "comment",
"NPROCX" : "4",
......@@ -170,7 +163,9 @@
"N_STF_START" : "1",
"TAPER_STF" : "0",
"TRKILL_STF" : "0",
"TRKILL_FILE_STF" : "./trace_kill/trace_kill.dat",
"TRKILL_STF_OFFSET" : "0",
"TRKILL_STF_OFFSET_LOWER , TRKILL_STF_OFFSET_UPPER" : "0 , 10",
"TRKILL_FILE_STF" : "./trace_kill/trace_kill",
"Frequency filtering during inversion" : "comment",
"TIME_FILT" : "0",
......@@ -196,6 +191,8 @@
"Trace killing" : "comment",
"TRKILL" : "0",
"TRKILL_OFFSET" : "0",
"TRKILL_OFFSET_LOWER , TRKILL_OFFSET_UPPER" : "0 , 10",
"TRKILL_FILE" : "./trace_kill/trace_kill",
"Definition of a gradient taper" : "comment",
......@@ -245,5 +242,5 @@
"FILT_SIZE" : "5",
"Verbose mode" : "comment",
"VERBOSE" : "0",
"VERBOSE" : "0"
}
#-----------------------------------------------------------------
# JSON PARAMETER FILE FOR IFOS
#-----------------------------------------------------------------
# description:
# description/name of the model: toy_example_true.c with flnodes.toy_example
#
{
"Domain Decomposition" : "comment",
"NPROCX" : "4",
......@@ -83,5 +76,5 @@
"FORWARD_ONLY" : "10",
"Verbose mode" : "comment",
"VERBOSE" : "0",
"VERBOSE" : "0"
}
#-----------------------------------------------------------------
# JSON PARAMETER FILE FOR IFOS
#-----------------------------------------------------------------
# description: