count_killed_traces.c 2.64 KB
Newer Older
Tilman Steinweg's avatar
Tilman Steinweg committed
1
/*-----------------------------------------------------------------------------------------
Florian Wittkamp's avatar
Florian Wittkamp committed
2
 * Copyright (C) 2016  For the list of authors, see file AUTHORS.
Tilman Steinweg's avatar
Tilman Steinweg committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
 *
 * 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>.
-----------------------------------------------------------------------------------------*/

/*------------------------------------------------------------------------
 *   Calculate number of killed traces                                  
 *   last update 11/07/12, L. Groos
 *  ----------------------------------------------------------------------*/
#include "fd.h"

void count_killed_traces(int ntr, int swstestshot, int ntr_glob, int **recpos_loc, int nsrc_glob, int ishot, int* ptr_killed_traces, int* ptr_killed_traces_testshots){

/* declaration of variables */
28
extern int USE_WORKFLOW, WORKFLOW_STAGE;
Tilman Steinweg's avatar
Tilman Steinweg committed
29 30 31 32 33 34 35 36 37 38 39 40 41
extern char TRKILL_FILE[STRING_SIZE];
int i,j,h;


/* declaration of variables for trace killing */
int ** kill_tmp, *kill_vector;
char trace_kill_file[STRING_SIZE];	
FILE *ftracekill;
  

kill_tmp = imatrix(1,ntr_glob,1,nsrc_glob);
kill_vector = ivector(1,ntr);

42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
    if(USE_WORKFLOW){
        sprintf(trace_kill_file,"%s_%i.dat",TRKILL_FILE,WORKFLOW_STAGE);
        ftracekill=fopen(trace_kill_file,"r");
        if (ftracekill==NULL){
            sprintf(trace_kill_file,"%s.dat",TRKILL_FILE);
            ftracekill=fopen(trace_kill_file,"r");
            if (ftracekill==NULL){
                err(" Trace kill file could not be opened!");
            }
        }
    }else{
        sprintf(trace_kill_file,"%s.dat",TRKILL_FILE);
        ftracekill=fopen(trace_kill_file,"r");
        if (ftracekill==NULL){
            err(" Trace kill file could not be opened!");
        }
    }
Tilman Steinweg's avatar
Tilman Steinweg committed
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76

for(i=1;i<=ntr_glob;i++){
	for(j=1;j<=nsrc_glob;j++){
		fscanf(ftracekill,"%d",&kill_tmp[i][j]);
	}
}

fclose(ftracekill);

h=1;
for(i=1;i<=ntr;i++){
   kill_vector[h] = kill_tmp[recpos_loc[3][i]][ishot];
   if (kill_vector[h]==1) *ptr_killed_traces=*ptr_killed_traces+1;
   if ((kill_vector[h]==1) && (swstestshot==1)) *ptr_killed_traces_testshots=*ptr_killed_traces_testshots+1;
   h++;
}
}