Commit 7797c6b2 authored by Florian Wittkamp's avatar Florian Wittkamp

WORKFLOW_STAGE now global variable

parent cbe2810e
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include "fd.h" #include "fd.h"
void apply_workflow(float ** workflow,int workflow_lines,char workflow_header[STRING_SIZE],int workflow_line_current ,int *iter,float *FC,int wavetype_start, int * change_wavetype_iter, int * LBFGS_iter_start){ void apply_workflow(float ** workflow,int workflow_lines,char workflow_header[STRING_SIZE],int *iter,float *FC,int wavetype_start, int * change_wavetype_iter, int * LBFGS_iter_start){
/* local variables */ /* local variables */
int x; int x;
...@@ -39,6 +39,7 @@ void apply_workflow(float ** workflow,int workflow_lines,char workflow_header[ST ...@@ -39,6 +39,7 @@ void apply_workflow(float ** workflow,int workflow_lines,char workflow_header[ST
extern int EPRECOND; extern int EPRECOND;
extern float EPSILON_WE; extern float EPSILON_WE;
extern int GRAD_METHOD; extern int GRAD_METHOD;
extern int WORKFLOW_STAGE;
/******************/ /******************/
/* Apply Workflow */ /* Apply Workflow */
...@@ -49,13 +50,13 @@ void apply_workflow(float ** workflow,int workflow_lines,char workflow_header[ST ...@@ -49,13 +50,13 @@ void apply_workflow(float ** workflow,int workflow_lines,char workflow_header[ST
printf("\n ---------- Applying Workflow -----------\n"); printf("\n ---------- Applying Workflow -----------\n");
printf(" %s ",workflow_header); printf(" %s ",workflow_header);
for(x=1;x<=WORKFLOW_MAX_VAR;x++){ for(x=1;x<=WORKFLOW_MAX_VAR;x++){
printf("%.2f\t",workflow[workflow_line_current][x]); printf("%.2f\t",workflow[WORKFLOW_STAGE][x]);
} }
} }
/* Inversion of material parameter */ /* Inversion of material parameter */
if(workflow[workflow_line_current][2]!=-1) { if(workflow[WORKFLOW_STAGE][2]!=-1) {
if(workflow[workflow_line_current][2]==1) { if(workflow[WORKFLOW_STAGE][2]==1) {
if(INV_VS_ITER>*iter) INV_VS_ITER=*iter; if(INV_VS_ITER>*iter) INV_VS_ITER=*iter;
} else { } else {
/* detect change and reset LBFGS */ /* detect change and reset LBFGS */
...@@ -64,8 +65,8 @@ void apply_workflow(float ** workflow,int workflow_lines,char workflow_header[ST ...@@ -64,8 +65,8 @@ void apply_workflow(float ** workflow,int workflow_lines,char workflow_header[ST
} }
} }
if(workflow[workflow_line_current][3]!=-1){ if(workflow[WORKFLOW_STAGE][3]!=-1){
if(workflow[workflow_line_current][3]==1) { if(workflow[WORKFLOW_STAGE][3]==1) {
if(INV_VP_ITER>*iter) INV_VP_ITER=*iter; if(INV_VP_ITER>*iter) INV_VP_ITER=*iter;
} else { } else {
/* detect change and reset LBFGS */ /* detect change and reset LBFGS */
...@@ -74,8 +75,8 @@ void apply_workflow(float ** workflow,int workflow_lines,char workflow_header[ST ...@@ -74,8 +75,8 @@ void apply_workflow(float ** workflow,int workflow_lines,char workflow_header[ST
} }
} }
if(workflow[workflow_line_current][4]!=-1){ if(workflow[WORKFLOW_STAGE][4]!=-1){
if(workflow[workflow_line_current][4]==1) { if(workflow[WORKFLOW_STAGE][4]==1) {
if(INV_RHO_ITER>*iter) INV_RHO_ITER=*iter; if(INV_RHO_ITER>*iter) INV_RHO_ITER=*iter;
} else { } else {
/* detect change and reset LBFGS */ /* detect change and reset LBFGS */
...@@ -84,41 +85,41 @@ void apply_workflow(float ** workflow,int workflow_lines,char workflow_header[ST ...@@ -84,41 +85,41 @@ void apply_workflow(float ** workflow,int workflow_lines,char workflow_header[ST
} }
} }
PRO=workflow[workflow_line_current][5]; PRO=workflow[WORKFLOW_STAGE][5];
/* Frequency filtering */ /* Frequency filtering */
if(TIME_FILT==1) { if(TIME_FILT==1) {
TIME_FILT=workflow[workflow_line_current][6]; TIME_FILT=workflow[WORKFLOW_STAGE][6];
if(*FC>workflow[workflow_line_current][7]&&(workflow[workflow_line_current][6]>0)) { if(*FC>workflow[WORKFLOW_STAGE][7]&&(workflow[WORKFLOW_STAGE][6]>0)) {
if(MYID==0)printf("\n Due to the abort criteriom FC is already higher than specified in workflow\n"); if(MYID==0)printf("\n Due to the abort criteriom FC is already higher than specified in workflow\n");
if(MYID==0)printf(" therefore instead of %.2f HZ FC=%.2f HZ is used\n",workflow[workflow_line_current][7],*FC); if(MYID==0)printf(" therefore instead of %.2f HZ FC=%.2f HZ is used\n",workflow[WORKFLOW_STAGE][7],*FC);
} else { } else {
if(*FC!=workflow[workflow_line_current][7]) *LBFGS_iter_start=*iter; if(*FC!=workflow[WORKFLOW_STAGE][7]) *LBFGS_iter_start=*iter;
*FC=workflow[workflow_line_current][7]; *FC=workflow[WORKFLOW_STAGE][7];
} }
} else { } else {
if(MYID==0)printf("\n TIME_FILT cannot be activated due to it is not activated in the JSON File \n"); if(MYID==0)printf("\n TIME_FILT cannot be activated due to it is not activated in the JSON File \n");
} }
/* Change of wavetype */ /* Change of wavetype */
if(wavetype_start!=3&&(WAVETYPE!=workflow[workflow_line_current][8])){ if(wavetype_start!=3&&(WAVETYPE!=workflow[WORKFLOW_STAGE][8])){
if(MYID==0)printf("\n Sorry, change of WAVETYPE with workflow only possible if WAVETYPE==3 in *.json"); if(MYID==0)printf("\n Sorry, change of WAVETYPE with workflow only possible if WAVETYPE==3 in *.json");
if(MYID==0)printf("\n WAVETYPE will remain unchanged %i",WAVETYPE); if(MYID==0)printf("\n WAVETYPE will remain unchanged %i",WAVETYPE);
} else { } else {
/* detect change and reset some things */ /* detect change and reset some things */
if(WAVETYPE!=workflow[workflow_line_current][8]) { if(WAVETYPE!=workflow[WORKFLOW_STAGE][8]) {
*change_wavetype_iter=*iter; *change_wavetype_iter=*iter;
*LBFGS_iter_start=*iter; *LBFGS_iter_start=*iter;
} }
WAVETYPE=workflow[workflow_line_current][8]; WAVETYPE=workflow[WORKFLOW_STAGE][8];
} }
/* Joint inversion PSV and SH */ /* Joint inversion PSV and SH */
JOINT_INVERSION_PSV_SH_ALPHA_VS=workflow[workflow_line_current][9]; JOINT_INVERSION_PSV_SH_ALPHA_VS=workflow[WORKFLOW_STAGE][9];
JOINT_INVERSION_PSV_SH_ALPHA_RHO=workflow[workflow_line_current][10]; JOINT_INVERSION_PSV_SH_ALPHA_RHO=workflow[WORKFLOW_STAGE][10];
/* Approx. Hessian */ /* Approx. Hessian */
EPRECOND=workflow[workflow_line_current][11]; EPRECOND=workflow[WORKFLOW_STAGE][11];
EPSILON_WE=workflow[workflow_line_current][12]; EPSILON_WE=workflow[WORKFLOW_STAGE][12];
if(*LBFGS_iter_start==*iter && GRAD_METHOD==2){ if(*LBFGS_iter_start==*iter && GRAD_METHOD==2){
if(MYID==0)printf("\n L-BFGS will be used from iteration %d on.",*LBFGS_iter_start+1); if(MYID==0)printf("\n L-BFGS will be used from iteration %d on.",*LBFGS_iter_start+1);
......
...@@ -154,11 +154,12 @@ int main(int argc, char **argv){ ...@@ -154,11 +154,12 @@ int main(int argc, char **argv){
int min_iter_help=0; int min_iter_help=0;
float ** workflow=NULL; float ** workflow=NULL;
int workflow_line_current=1;
int workflow_lines; int workflow_lines;
char workflow_header[STRING_SIZE]; char workflow_header[STRING_SIZE];
int change_wavetype_iter=-10; /* Have to be inialized negative */ int change_wavetype_iter=-10; /* Have to be inialized negative */
int wavetype_start; /* We need this due to MPI Comm */ int wavetype_start; /* We need this due to MPI Comm */
int buf1=0, buf2=0;
WORKFLOW_STAGE=1;
/* variable for time domain filtering */ /* variable for time domain filtering */
float FC; float FC;
...@@ -946,7 +947,7 @@ int main(int argc, char **argv){ ...@@ -946,7 +947,7 @@ int main(int argc, char **argv){
// At each iteration the workflow is applied // At each iteration the workflow is applied
if(USE_WORKFLOW&&(INVMAT==0)){ if(USE_WORKFLOW&&(INVMAT==0)){
apply_workflow(workflow,workflow_lines,workflow_header,workflow_line_current,&iter,&FC,wavetype_start,&change_wavetype_iter,&LBFGS_iter_start); apply_workflow(workflow,workflow_lines,workflow_header,&iter,&FC,wavetype_start,&change_wavetype_iter,&LBFGS_iter_start);
} }
...@@ -3751,7 +3752,7 @@ int main(int argc, char **argv){ ...@@ -3751,7 +3752,7 @@ int main(int argc, char **argv){
/* ------------------------------------------- */ /* ------------------------------------------- */
if(USE_WORKFLOW && (diff<=pro || wolfe_SLS_failed)){ if(USE_WORKFLOW && (diff<=pro || wolfe_SLS_failed)){
if(workflow_lines==workflow_line_current){ if(workflow_lines==WORKFLOW_STAGE){
fprintf(FP,"\n Reached the abort criterion of pro = %4.2f: diff = %4.2f \n",pro,diff); fprintf(FP,"\n Reached the abort criterion of pro = %4.2f: diff = %4.2f \n",pro,diff);
fprintf(FP,"\n No new line in workflow file"); fprintf(FP,"\n No new line in workflow file");
break; break;
...@@ -3761,7 +3762,13 @@ int main(int argc, char **argv){ ...@@ -3761,7 +3762,13 @@ int main(int argc, char **argv){
if(wolfe_SLS_failed) fprintf(FP,"\n Wolfe step length search failed \n"); if(wolfe_SLS_failed) fprintf(FP,"\n Wolfe step length search failed \n");
fprintf(FP,"\n Switching to next line in workflow"); fprintf(FP,"\n Switching to next line in workflow");
workflow_line_current++; WORKFLOW_STAGE++;
/* Sync WORKFLOW_STAGE on all PEs */
buf1=WORKFLOW_STAGE;
buf2=0;
MPI_Allreduce(&buf1,&buf2, 1,MPI_INT,MPI_MAX,MPI_COMM_WORLD);
WORKFLOW_STAGE=buf2;
alpha_SL_old=1; alpha_SL_old=1;
......
...@@ -526,7 +526,7 @@ void read_workflow(char file_in[STRING_SIZE],float *** workflow, int *workflow_l ...@@ -526,7 +526,7 @@ void read_workflow(char file_in[STRING_SIZE],float *** workflow, int *workflow_l
float ** joint_inversion_grad ( float ** gradiant_1,float ** gradiant_2, float alpha, int joint_type); float ** joint_inversion_grad ( float ** gradiant_1,float ** gradiant_2, float alpha, int joint_type);
void snap_SH(FILE *fp,int nt, int nsnap, float ** vz, float **u, float **pi, float *hc,int ishot); void snap_SH(FILE *fp,int nt, int nsnap, float ** vz, float **u, float **pi, float *hc,int ishot);
void apply_workflow(float ** workflow,int workflow_lines,char workflow_header[STRING_SIZE],int workflow_line_current ,int *iter,float *FC,int wavetype_start, int * change_wavetype_iter, int * LBFGS_iter_start); void apply_workflow(float ** workflow,int workflow_lines,char workflow_header[STRING_SIZE],int *iter,float *FC,int wavetype_start, int * change_wavetype_iter, int * LBFGS_iter_start);
void eprecond(float ** W, float ** vx, float ** vy); void eprecond(float ** W, float ** vx, float ** vy);
void eprecond_SH(float ** W, float ** vz); void eprecond_SH(float ** W, float ** vz);
......
...@@ -38,6 +38,7 @@ char JACOBIAN[STRING_SIZE], DATA_DIR[STRING_SIZE], FREQ_FILE[STRING_SIZE]; ...@@ -38,6 +38,7 @@ char JACOBIAN[STRING_SIZE], DATA_DIR[STRING_SIZE], FREQ_FILE[STRING_SIZE];
int USE_WORKFLOW; int USE_WORKFLOW;
char FILE_WORKFLOW[STRING_SIZE]; char FILE_WORKFLOW[STRING_SIZE];
int WORKFLOW_STAGE;
int TAPER, TAPERLENGTH, INVTYPE; int TAPER, TAPERLENGTH, INVTYPE;
int GRADT1,GRADT2,GRADT3,GRADT4; int GRADT1,GRADT2,GRADT3,GRADT4;
......
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