Commit 744ec46b authored by Florian Wittkamp's avatar Florian Wittkamp

Changed order of NX and NY loops

parent 584deaa7
......@@ -180,7 +180,7 @@ $(call CHECKVAR,INCINSTALLPATH)
$(INCINSTALLPATH)/%.h: %.h
@mkdir -vp $(dir $@)
-@rm -fv $@
@/bin/cp -vpd $< $@
@/bin/cp -vp $< $@
# install header files
.PHONY: install-include
......
......@@ -209,7 +209,7 @@ include $(patsubst %.cc,%.d,$(SRC))
$(INCINSTALLPATH)/%.h: %.h
@mkdir -vp $(dir $@)
-@rm -fv $@
@/bin/cp -vpd $< $@
@/bin/cp -vp $< $@
# install header files
.PHONY: install-include
......
......@@ -183,7 +183,7 @@ libstfinv.a: $(patsubst %.cc,%.o,$(LIBCCSRC)) \
$(INCINSTALLPATH)/%.h: %.h
mkdir -p $(INCINSTALLPATH)
-rm -fv $@
/bin/cp -vpd $< $@
/bin/cp -vp $< $@
.PHONY: install-include
install-include: $(INSTHEADER)
......
......@@ -112,7 +112,7 @@
"EPRECOND_ITER" : "0",
"Workflow" : "comment",
"USE_WORKFLOW" : "1",
"USE_WORKFLOW" : "0",
"FILE_WORKFLOW" : "workflow.txt",
"Inversion for density" : "comment",
......
......@@ -35,4 +35,4 @@ make denise MODEL=../genmod/toy_example_start.c
# starting DENISE
#lamboot
mpirun -np 4 ../bin/denise in_and_out/toy_example/toy_example_INV.json | tee in_and_out/toy_example/toy_example_INV.out
mpirun -np 4 ../bin/denise in_and_out/toy_example/toy_example_INV_SH.json | tee in_and_out/toy_example/toy_example_INV_SH.out
......@@ -83,8 +83,8 @@ void calc_mat_change_test(float ** waveconv, float ** waveconv_rho, float *
pimax = 0.0;
gradmax = 0.0;
for (i=1;i<=NX;i++){
for (j=1;j<=NY;j++){
for (j=1;j<=NY;j++){
for (i=1;i<=NX;i++){
Zp = pi[j][i];
......@@ -105,8 +105,8 @@ void calc_mat_change_test(float ** waveconv, float ** waveconv_rho, float *
umax = 0.0;
gradmax_u = 0.0;
for (i=1;i<=NX;i++){
for (j=1;j<=NY;j++){
for (j=1;j<=NY;j++){
for (i=1;i<=NX;i++){
Zs = u[j][i];
......@@ -127,8 +127,8 @@ void calc_mat_change_test(float ** waveconv, float ** waveconv_rho, float *
rhomax = 0.0;
gradmax_rho = 0.0;
for (i=1;i<=NX;i++){
for (j=1;j<=NY;j++){
for (j=1;j<=NY;j++){
for (i=1;i<=NX;i++){
if(rho[j][i]>rhomax){rhomax=rho[j][i];}
......
This diff is collapsed.
......@@ -6,8 +6,8 @@ void eprecond(float ** W, float ** vx, float ** vy){
extern int NX, NY, IDX, IDY;
int i, j;
for (i=1;i<=NX;i=i+IDX){
for (j=1;j<=NY;j=j+IDY){
for (j=1;j<=NY;j=j+IDY){
for (i=1;i<=NX;i=i+IDX){
W[j][i]+=((vx[j][i]*vx[j][i])+(vy[j][i]*vy[j][i]));
......@@ -21,8 +21,8 @@ void eprecond_SH(float ** W, float ** vz){
extern int NX, NY, IDX, IDY;
int i, j;
for (i=1;i<=NX;i=i+IDX){
for (j=1;j<=NY;j=j+IDY){
for (j=1;j<=NY;j=j+IDY){
for (i=1;i<=NX;i=i+IDX){
W[j][i]+=((vz[j][i]*vz[j][i]));
......
......@@ -17,8 +17,8 @@ void eprecond1(float ** We, float ** Ws, float ** Wr){
if(EPRECOND==1){
/* calculate energy weighting */
for (i=1;i<=NX;i=i+IDX){
for (j=1;j<=NY;j=j+IDY){
for (j=1;j<=NY;j=j+IDY){
for (i=1;i<=NX;i=i+IDX){
We[j][i]=sqrt(Ws[j][i]*Wr[j][i]); /* energy weighted source and receiver contribution */
......@@ -33,8 +33,8 @@ void eprecond1(float ** We, float ** Ws, float ** Wr){
if(EPRECOND==3){
/* Forward wavefield + approximation of the receiver Greens function (Plessix and Mulder, 2004) */
for (i=1;i<=NX;i=i+IDX){
for (j=1;j<=NY;j=j+IDY){
for (j=1;j<=NY;j=j+IDY){
for (i=1;i<=NX;i=i+IDX){
/* calculate global coordinates */
ii=i+POS[1]*NX;
......@@ -57,8 +57,8 @@ void eprecond1(float ** We, float ** Ws, float ** Wr){
/* estimate maximum of We */
MPI_Allreduce(&maxWetmp,&maxWe,1,MPI_FLOAT,MPI_MAX,MPI_COMM_WORLD);
/* regularize energy weighting to avoid divison by zero */
for (i=1;i<=NX;i=i+IDX){
for (j=1;j<=NY;j=j+IDY){
for (j=1;j<=NY;j=j+IDY){
for (i=1;i<=NX;i=i+IDX){
We[j][i] = We[j][i] + (EPSILON_WE*maxWe);
......
......@@ -48,19 +48,19 @@ float ** joint_inversion_grad ( float ** gradiant_1,float ** gradiant_2, float a
extern int NPROCX, NPROCY, MYID;
extern FILE *FP;
switch (joint_type) {
case 1:
/* joint_type=1: Normalize both and take the arithmetic mean */
max1=global_maximum(gradiant_1);
max2=global_maximum(gradiant_2);
for (i=1;i<=NX;i++){
/* joint_type=1: Normalize both and take the arithmetic mean */
max1=global_maximum(gradiant_1);
max2=global_maximum(gradiant_2);
for (j=1;j<=NY;j++){
gradiant_1[j][i]=((1-alpha)*gradiant_1[j][i]/max1+alpha*gradiant_2[j][i]/max2);
for (i=1;i<=NX;i++){
gradiant_1[j][i]=((1-alpha)*gradiant_1[j][i]/max1+alpha*gradiant_2[j][i]/max2);
}
}
}
joint_gradiant=gradiant_1;
break;
joint_gradiant=gradiant_1;
break;
}
return joint_gradiant;
};
......
......@@ -55,9 +55,8 @@ float global_maximum(float ** gradiant_1) {
int i, j;
float max=0.0,max1=0.0;
extern int NX, NY;
for (i=1;i<=NX;i++){
for (j=1;j<=NY;j++){
for (j=1;j<=NY;j++){
for (i=1;i<=NX;i++){
if((i*j == 1) || (max == 0.0)) {
max = fabs(gradiant_1[j][i]);
} else {
......@@ -84,8 +83,8 @@ float average_matrix(float ** matrix){
float buf1=0, buf2=0;
float average;
for (i=1;i<=NX;i=i+IDX){
for (j=1;j<=NY;j=j+IDY){
for (j=1;j<=NY;j=j+IDY){
for (i=1;i<=NX;i=i+IDX){
local_sum+=matrix[j][i];
}
}
......@@ -111,8 +110,8 @@ float matrix_product(float ** matrix1, float **matrix2) {
float buf1=0, buf2=0;
int i,j;
for (i=1;i<=NX;i=i+IDX){
for (j=1;j<=NY;j=j+IDY){
for (j=1;j<=NY;j=j+IDY){
for (i=1;i<=NX;i=i+IDX){
local_sum+=(matrix1[j][i]*matrix2[j][i]);
}
}
......
......@@ -51,9 +51,9 @@ void max_grad(float ** waveconv, float ** waveconv_rho, float ** waveconv_
/* find maximum of Zp and gradient waveconv */
pimax = 0.0;
gradmax = 0.0;
for (j=1;j<=NY;j++){
for (i=1;i<=NX;i++){
for (j=1;j<=NY;j++){
Zp = sqrt((pi[j][i] + 2.0 * u[j][i])*rho[j][i]);
......@@ -75,8 +75,8 @@ void max_grad(float ** waveconv, float ** waveconv_rho, float ** waveconv_
umax = 0.0;
gradmax_u = 0.0;
for (i=1;i<=NX;i++){
for (j=1;j<=NY;j++){
for (j=1;j<=NY;j++){
for (i=1;i<=NX;i++){
Zs = sqrt(u[j][i]*rho[j][i]);
......@@ -101,8 +101,8 @@ void max_grad(float ** waveconv, float ** waveconv_rho, float ** waveconv_
rhomax = 0.0;
gradmax_rho = 0.0;
for (i=1;i<=NX;i++){
for (j=1;j<=NY;j++){
for (j=1;j<=NY;j++){
for (i=1;i<=NX;i++){
if(rho[j][i]>rhomax){rhomax=rho[j][i];}
......@@ -165,8 +165,8 @@ void max_grad(float ** waveconv, float ** waveconv_rho, float ** waveconv_
/* apply scaling factors */
/* --------------------- */
for (i=1;i<=NX;i++){
for (j=1;j<=NY;j++){
for (j=1;j<=NY;j++){
for (i=1;i<=NX;i++){
waveconv[j][i] = EPSILON * waveconv[j][i];
waveconv_u[j][i] = EPSILON_u * waveconv_u[j][i];
......
......@@ -2,22 +2,22 @@
* Copyright (C) 2013 For the list of authors, see file AUTHORS.
*
* This file is part of DENISE.
*
*
* DENISE 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.
*
*
* DENISE 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 DENISE. See file COPYING and/or <http://www.gnu.org/licenses/gpl-2.0.html>.
-----------------------------------------------------------------------------------------*/
-----------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------
* write local model to file
* write local model to file
* last update 16/02/02 T. Bohlen
*
* ----------------------------------------------------------------------*/
......@@ -26,28 +26,28 @@
void writemod(char modfile[STRING_SIZE], float ** array, int format){
/* extern variables */
extern int MYID, NX, NY, POS[3], IDX, IDY,VERBOSE;
extern FILE *FP;
/* extern variables */
extern int MYID, NX, NY, POS[3], IDX, IDY,VERBOSE;
extern FILE *FP;
extern int VERBOSE;
int i, j;
FILE *fpmod;
char file[STRING_SIZE];
if(VERBOSE) fprintf(FP,"\n\n PE %d is writing model to \n",MYID);
sprintf(file,"%s.%i.%i",modfile,POS[1],POS[2]);
if(VERBOSE) fprintf(FP,"\t%s\n\n", file);
fpmod=fopen(file,"w");
for (i=1;i<=NX;i+=IDX)
for (j=1;j<=NY;j+=IDY)
writedsk(fpmod,array[j][i],format);
int i, j;
FILE *fpmod;
char file[STRING_SIZE];
if(VERBOSE) fprintf(FP,"\n\n PE %d is writing model to \n",MYID);
sprintf(file,"%s.%i.%i",modfile,POS[1],POS[2]);
if(VERBOSE) fprintf(FP,"\t%s\n\n", file);
fpmod=fopen(file,"w");
for (i=1;i<=NX;i+=IDX)
for (j=1;j<=NY;j+=IDY)
writedsk(fpmod,array[j][i],format);
fclose(fpmod);
fclose(fpmod);
}
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