Commit 6c502b25 authored by Florian Wittkamp's avatar Florian Wittkamp

Workflow now includes a header

Workflow file now includes a header.
parent b48e692b
# VS VP RHO PRO FIL FC WT J J EPRE EPSI
1 1 0 0 0.01 0 0 2 0 0 0 0.005 1 1 0 0 0.01 0 0 2 0 0 0 0.005
2 1 0 0 0.01 0 0 2 0 0 0 0.005 2 1 0 0 0.01 0 0 2 0 0 0 0.005
3 1 0 0 0.01 0 0 2 0 0 0 0.005 3 1 0 0 0.01 0 0 2 0 0 0 0.005
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include "fd.h" #include "fd.h"
void apply_workflow(float ** workflow,int workflow_lines,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 workflow_line_current ,int *iter,float *FC,int wavetype_start, int * change_wavetype_iter, int * LBFGS_iter_start){
/* local variables */ /* local variables */
int x; int x;
...@@ -47,7 +47,7 @@ void apply_workflow(float ** workflow,int workflow_lines,int workflow_line_curre ...@@ -47,7 +47,7 @@ void apply_workflow(float ** workflow,int workflow_lines,int workflow_line_curre
/* Print current workflow */ /* Print current workflow */
if(MYID==0){ if(MYID==0){
printf("\n ---------- Applying Workflow -----------\n"); printf("\n ---------- Applying Workflow -----------\n");
printf(" ITER\tINV_VS\tINV_VP\tINV_RHO\tPRO\tTI_FILT\tFC\tWT\n "); 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_line_current][x]);
} }
......
...@@ -156,6 +156,7 @@ int main(int argc, char **argv){ ...@@ -156,6 +156,7 @@ int main(int argc, char **argv){
float ** workflow=NULL; float ** workflow=NULL;
int workflow_line_current=1; int workflow_line_current=1;
int workflow_lines; int workflow_lines;
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 */
...@@ -896,7 +897,7 @@ int main(int argc, char **argv){ ...@@ -896,7 +897,7 @@ int main(int argc, char **argv){
nsrc_glob=nsrc; nsrc_glob=nsrc;
if(INVMAT==0&&USE_WORKFLOW){ if(INVMAT==0&&USE_WORKFLOW){
read_workflow(FILE_WORKFLOW,&workflow, &workflow_lines); read_workflow(FILE_WORKFLOW,&workflow, &workflow_lines,workflow_header);
} }
/* create model grids */ /* create model grids */
...@@ -980,7 +981,7 @@ int main(int argc, char **argv){ ...@@ -980,7 +981,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_line_current,&iter,&FC,wavetype_start,&change_wavetype_iter,&LBFGS_iter_start); apply_workflow(workflow,workflow_lines,workflow_header,workflow_line_current,&iter,&FC,wavetype_start,&change_wavetype_iter,&LBFGS_iter_start);
} }
......
...@@ -522,11 +522,11 @@ void exchange_p(float ** sp, float ** bufferlef_to_rig, float ** bufferrig_to_le ...@@ -522,11 +522,11 @@ void exchange_p(float ** sp, float ** bufferlef_to_rig, float ** bufferrig_to_le
MPI_Request * req_send, MPI_Request * req_rec); MPI_Request * req_send, MPI_Request * req_rec);
void read_workflow(char file_in[STRING_SIZE],float *** workflow, int *workflow_lines); void read_workflow(char file_in[STRING_SIZE],float *** workflow, int *workflow_lines, char header[STRING_SIZE]);
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,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 workflow_line_current ,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);
......
...@@ -28,13 +28,14 @@ ...@@ -28,13 +28,14 @@
#include "fd.h" #include "fd.h"
void read_workflow(char file_in[STRING_SIZE],float *** workflow, int *workflow_lines){ void read_workflow(char file_in[STRING_SIZE],float *** workflow, int *workflow_lines, char header[STRING_SIZE]){
/* workflow is a pointer to a pointer, keep care... */ /* workflow is a pointer to a pointer, keep care... */
/* intern variables */ /* intern variables */
int i, c; int i, c;
int nw=0,x,y; int nw=0,x,y;
FILE *fwork; FILE *fwork;
/* extern variables */ /* extern variables */
extern FILE *FP; extern FILE *FP;
...@@ -47,11 +48,13 @@ void read_workflow(char file_in[STRING_SIZE],float *** workflow, int *workflow_l ...@@ -47,11 +48,13 @@ void read_workflow(char file_in[STRING_SIZE],float *** workflow, int *workflow_l
if (fwork==NULL) err(" Workflow file could no be opened !"); if (fwork==NULL) err(" Workflow file could no be opened !");
/* Count how many lines the work flow file has */ /* Count how many lines the work flow file has */
fgets(header, 200, fwork); /* Read header */
while(!feof(fwork)) { while(!feof(fwork)) {
c = fgetc(fwork); c = fgetc(fwork);
if(c == '\n'){nw++;} if(c == '\n'){nw++;}
} }
fseek(fwork, SEEK_SET, 0); fseek(fwork, SEEK_SET, 0); /* Reset */
fgets(header, 200, fwork); /* Read header */
fprintf(FP," Number of lines in workflow file: %i\n",nw); fprintf(FP," Number of lines in workflow file: %i\n",nw);
...@@ -60,7 +63,7 @@ void read_workflow(char file_in[STRING_SIZE],float *** workflow, int *workflow_l ...@@ -60,7 +63,7 @@ void read_workflow(char file_in[STRING_SIZE],float *** workflow, int *workflow_l
if ((*workflow)==NULL) err(" Was not able to allocate memory for workflow file !"); if ((*workflow)==NULL) err(" Was not able to allocate memory for workflow file !");
/* Read workflow */ /* Read workflow */
fprintf(FP," ITER\tINV_VS\tINV_VP\tINV_RHO\tPRO\tTIME_FILT\tFC\tFREE\n"); fprintf(FP,"\n %s",header);
fprintf(FP," "); fprintf(FP," ");
for(y=1;y<=nw;y++){ for(y=1;y<=nw;y++){
for(x=1;x<=WORKFLOW_MAX_VAR;x++){ for(x=1;x<=WORKFLOW_MAX_VAR;x++){
......
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