Commit b4270168 authored by Tyson Littenberg's avatar Tyson Littenberg
Browse files

fix compiler warnings

parent d9aaa53a
......@@ -34,7 +34,7 @@ echo "Installing to ${install_dir}"
START=${PWD}
cd src
autoreconf --verbose --force --install --make
./configure --prefix ${install_dir}
./configure --prefix ${install_dir} CFLAGS="-Wno-format-truncation"
make install
cd ${START}
......
......@@ -1824,7 +1824,7 @@ static void phase_blind_time_shift(double *corr, double *corrf, double *data1, d
static void SineGaussianC(double *hs, double *sigpar, double Tobs, int NMAX)
{
double f0, t0, Q, sf;
double f0, Q, sf;
double fmax, fmin, fac;
double f;
double tau, dt;
......@@ -1834,7 +1834,6 @@ static void SineGaussianC(double *hs, double *sigpar, double Tobs, int NMAX)
// Torrence and Compo
t0 = sigpar[0];
f0 = sigpar[1];
Q = sigpar[2];
......@@ -1904,7 +1903,7 @@ static double f_nwip(double *a, double *b, int n)
static void TransformC(double *a, double *freqs, double **tf, double **tfR, double **tfI, double Q, double Tobs, int n, int m)
{
int i, j;
double f, dt, df;
double f;
double *AC, *AF;
double *b;
double *params;
......@@ -1918,10 +1917,7 @@ static void TransformC(double *a, double *freqs, double **tf, double **tfR, doub
params[2] = Q;
params[3] = 1.0;
params[4] = 0.0;
dt = Tobs/(double)n;
df = 1.0/Tobs;
AC=double_vector(n-1);
AF=double_vector(n-1);
......@@ -2397,7 +2393,7 @@ void blstart(double *data, double *residual, int N, double dt, double fmin, int
int imin, imax;
double SNR, max;
double Tobs, f, df, x, dx;
double fmax, Q, fny, scale, dlnf;
double fmax, Q, fny, scale;
double *freqs;
double *Draw;
double *D;
......@@ -2407,7 +2403,7 @@ void blstart(double *data, double *residual, int N, double dt, double fmin, int
int subscale, octaves;
double SNRold;
double alpha;
double t_rise, s1, s2, fac, Dfmax;
double t_rise, s1, s2, fac;
double *linew;
int modelprint;
......@@ -2417,7 +2413,6 @@ void blstart(double *data, double *residual, int N, double dt, double fmin, int
FILE *out;
Q = Qs; // Q of transform
Dfmax = 8.0; // width of smoothing window in Hz
Tobs = (double)(N)*dt; // duration
// Tukey window parameter. Flat for (1-alpha) of data
......@@ -2470,7 +2465,6 @@ void blstart(double *data, double *residual, int N, double dt, double fmin, int
freqs = (double*)malloc(sizeof(double)* (Nf)); // frequencies used in the analysis
sqf = (double*)malloc(sizeof(double)* (Nf));
dx = log(2.0)/(double)(subscale);
dlnf = dx;
x = log(fmin);
for(i=0; i< Nf; i++)
{
......
......@@ -10,7 +10,6 @@
#include <math.h>
#include <sys/stat.h>
#include "BayesWave.h"
#include "BayesLine.h"
#include "BayesWaveIO.h"
......@@ -35,8 +34,8 @@ int main(int argc, char *argv[])
/* Variable declaration */
int i, j, ic, ifo, imin,imax;
char filename[100];
char modelname[128];
char filename[MAXSTRINGSIZE];
char modelname[MAXSTRINGSIZE];
/* LAL data structure that will contain all of the data from the frame files */
LALInferenceRunState *runState = XLALCalloc(1,sizeof(LALInferenceRunState));
......
......@@ -66,6 +66,8 @@
#define SPRD 4 // width of outer part of proximity proposal
#define HLW 1 // width of hollowed-out region
#define MAXSTRINGSIZE 1024
/* ********************************************************************************** */
/* */
/* Data structures */
......
......@@ -27,6 +27,7 @@
/************* PROTOTYPE DECLARATIONS FOR INTERNAL FUNCTIONS **************/
#define REQARG 12
#define MAXSTRINGSIZE 1024
struct Data
{
......@@ -35,15 +36,15 @@ struct Data
//Set data products from command line
char ifo[4]; //interferometer (e.g V1);
char fr_cache[1024];//cache file (e.g. V1.cache)
char fr_chanl[1024];//channel type (e.g. V1:Hrec_hoft_16384Hz)
char fr_type[1024]; //frame type (e.g. V1_llhoft)
char fr_cache[MAXSTRINGSIZE];//cache file (e.g. V1.cache)
char fr_chanl[MAXSTRINGSIZE];//channel type (e.g. V1:Hrec_hoft_16384Hz)
char fr_type[MAXSTRINGSIZE]; //frame type (e.g. V1_llhoft)
double fr_seglen; //frame segment length
double fr_start; //frame start time
double fr_srate; //frame sampling rate
char bw_model[1024]; //bayeswave glitch model
char bw_model[MAXSTRINGSIZE]; //bayeswave glitch model
double bw_seglen; //bayeswave segment length
double bw_start; //bayeswave start time
......@@ -131,13 +132,13 @@ int main(int argc, char *argv[])
char * version="T1700406_v3";
char outframeType[128];
char outframeChannel[128];
char outframeGlitchChannel[128];
char outframeType[MAXSTRINGSIZE];
char outframeChannel[MAXSTRINGSIZE];
char outframeGlitchChannel[MAXSTRINGSIZE];
sprintf(outframeType, "%s_%s", data->fr_type, version);
sprintf(outframeChannel,"%s_%s", data->fr_chanl, version);
sprintf(outframeGlitchChannel,"%s_glitch", data->fr_chanl);
snprintf(outframeType, MAXSTRINGSIZE, "%s_%s", data->fr_type, version);
snprintf(outframeChannel, MAXSTRINGSIZE, "%s_%s", data->fr_chanl, version);
snprintf(outframeGlitchChannel, MAXSTRINGSIZE, "%s_glitch", data->fr_chanl);
/* set the channel name */
strncpy(timeData->name, data->fr_chanl, LALNameLength);
......@@ -178,8 +179,8 @@ int main(int argc, char *argv[])
if(data->medianFlag)
{
//split glitch model file name
char start[1024];
char extension[1024];
char start[MAXSTRINGSIZE];
char extension[MAXSTRINGSIZE];
j = 0;
while(data->bw_model[j]!='1')
{
......@@ -198,7 +199,7 @@ int main(int argc, char *argv[])
//burn off next two digits
j+=3;
i=0;
while(j<1024)
while(j<MAXSTRINGSIZE)
{
extension[i]=data->bw_model[j];
j++;
......@@ -210,7 +211,7 @@ int main(int argc, char *argv[])
fprintf(stdout,"\n");
//read all waveform reconstruction into array
char filename[1024];
char filename[MAXSTRINGSIZE];
for(j=0; j<100; j++)
{
sprintf(filename,"%s%i%s",start,100+j,extension);
......
......@@ -195,11 +195,11 @@ void InjectFromMDC(ProcessParamsTable *commandLine, LALInferenceIFOData *IFOdata
/* Inject into FD data stream and calculate optimal SNR */
while(data){
char foutname[50]="";
char foutname[MAXSTRINGSIZE]="";
sprintf(foutname,"MDC_freq_%s_%d",data->name,epoch.gpsSeconds);
FILE * fout = fopen(foutname,"w");
char outname[50]="";
char outname[MAXSTRINGSIZE]="";
sprintf(outname,"MDC_time_%s_%d",data->name,epoch.gpsSeconds);
FILE * out = fopen(outname,"w");
......@@ -264,7 +264,7 @@ void BayesWaveInjection(ProcessParamsTable *commandLine, struct Data *data, stru
int signalFlag = data->signalFlag;
int glitchFlag = data->glitchFlag;
char filename[1000];
char filename[MAXSTRINGSIZE];
char burnrows[100000];
//User-friendly arrays for PSD, signal, and injected waveform
......@@ -281,22 +281,22 @@ void BayesWaveInjection(ProcessParamsTable *commandLine, struct Data *data, stru
//Command line options
ProcessParamsTable *ppt = NULL;
char injmodel[10];
char injname[100];
char injpath[1000];
char injmodel[MAXSTRINGSIZE];
char injname[MAXSTRINGSIZE];
char injpath[MAXSTRINGSIZE];
//which model?
ppt = LALInferenceGetProcParamVal(commandLine, "--BW-inject");
sprintf(injmodel,"%s",ppt->value);
snprintf(injmodel,MAXSTRINGSIZE,"%s",ppt->value);
//name of chain file?
ppt = LALInferenceGetProcParamVal(commandLine, "--BW-injName");
if(ppt) sprintf(injname,"%s_",ppt->value);
if(ppt) snprintf(injname,MAXSTRINGSIZE,"%s_",ppt->value);
else injname[0]=0;
//path to chain file?
ppt = LALInferenceGetProcParamVal(commandLine, "--BW-path");
if(ppt)sprintf(injpath,"%s",ppt->value);
if(ppt)snprintf(injpath,MAXSTRINGSIZE,"%s",ppt->value);
else sprintf(injpath,"./chains");
//which sample from chain file?
......@@ -467,7 +467,7 @@ void getChannels(ProcessParamsTable *commandLine, char **channel)
{
ProcessParamsTable *ppt = NULL;
char ifo[4];
char arg[128];
char arg[MAXSTRINGSIZE];
ProcessParamsTable *argument=commandLine;
......@@ -480,7 +480,7 @@ void getChannels(ProcessParamsTable *commandLine, char **channel)
{
//Get name of one of the interferferometers (channel name is preceeded by IFO name)
ppt = LALInferenceGetProcParamVal(commandLine, "--ifo");
sprintf(ifo,"%s",argument->value);
snprintf(ifo,4,"%s",argument->value);
fprintf(stdout,"Detector %s: ",ifo);
//Get channel name of interferometers
......@@ -515,7 +515,7 @@ void getChannels(ProcessParamsTable *commandLine, char **channel)
void write_gnuplot_script_header(FILE *script, char modelname[])
{
char filename[100];
char filename[MAXSTRINGSIZE];
sprintf(filename,"waveforms/%s_waveforms_animate.gpi",modelname);
script=fopen(filename,"w");
fprintf(script,"set terminal gif giant enhanced size 800,600 animate delay 1 \n");
......@@ -534,7 +534,7 @@ void write_gnuplot_script_frame (FILE *script, char modelname[], int signal, int
{
int i;
char datafile[100];
char datafile[MAXSTRINGSIZE];
sprintf(datafile,"%s_data_%i.dat.%i", modelname,cycle,0);
......@@ -584,7 +584,7 @@ void write_bayeswave_gnuplot_script_frame(FILE *script, char modelname[], double
{
int i;
char datafile[100];
char datafile[MAXSTRINGSIZE];
sprintf(datafile,"%s_data_%i.dat.%i", modelname,cycle,0);
fprintf(script,"set multiplot \n");
......@@ -920,10 +920,8 @@ void print_model(FILE *fptr, struct Data *data, struct Chain *chain, struct Mode
fprintf(fptr,"%d ", model->signal[0]->size);
for(ifo=0; ifo<NI; ifo++) fprintf(fptr,"%d ", model->glitch[ifo]->size);
for(ifo=0; ifo<NI; ifo++) fprintf(fptr, "%f ",model->Sn[ifo]);
// fprintf(fptr, "%f %f ",logZ, sqrt(varZ));
if(data->stochasticFlag)
fprintf(fptr,"%f %f ",model->background->logamp,model->background->index);
fprintf(fptr,"%f %f ",model->logL,model->logLnorm);
if(data->stochasticFlag) fprintf(fptr,"%f %f ",model->background->logamp,model->background->index);
fprintf(fptr,"%f %f ",model->logL,model->logLnorm);
fprintf(fptr,"\n");
}
......@@ -1787,7 +1785,7 @@ void dump_time_domain_waveform(struct Data *data, struct Model *model, struct Pr
int d;
int i;
int ifo;
char filename[128];
char filename[MAXSTRINGSIZE];
//TODO: HACKED signal pointer
struct Wavelet *signal = model->signal[0];
......@@ -1829,7 +1827,7 @@ void export_cleaned_data(struct Data *data, struct Model *model)
FILE *asdFile;
FILE *resFile;
char filename[128];
char filename[MAXSTRINGSIZE];
for(ifo=0; ifo<NI; ifo++)
{
......
......@@ -903,8 +903,8 @@ void RJMCMC(struct Data *data, struct Model **model, struct BayesLineParams ***b
double logPost;
double logPostMap=-1e60;
char filename[100];
char modelname[100];
char filename[MAXSTRINGSIZE];
char modelname[MAXSTRINGSIZE];
// parameters to control how many frames are output to model animations
int frame=0;
......@@ -970,20 +970,20 @@ void RJMCMC(struct Data *data, struct Model **model, struct BayesLineParams ***b
*/
//give output files common name
if(data->runPhase==0)sprintf(modelname,"%sclean",data->runName);
if(data->runPhase==0)snprintf(modelname,MAXSTRINGSIZE,"%sclean",data->runName);
else
{
if(!data->glitchFlag && !data->signalFlag)
sprintf(modelname,"%snoise",data->runName);
snprintf(modelname,MAXSTRINGSIZE,"%snoise",data->runName);
else if(data->glitchFlag && !data->signalFlag)
sprintf(modelname,"%sglitch",data->runName);
snprintf(modelname,MAXSTRINGSIZE,"%sglitch",data->runName);
else if(!data->glitchFlag && data->signalFlag)
sprintf(modelname,"%ssignal",data->runName);
snprintf(modelname,MAXSTRINGSIZE,"%ssignal",data->runName);
else
sprintf(modelname,"%sfull",data->runName);
snprintf(modelname,MAXSTRINGSIZE,"%sfull",data->runName);
}
/******************************************************************************/
......
......@@ -51,8 +51,6 @@ struct Moments
double *duration90percentinterval;
double *tl;
double *th;
};
void print_help_message(void);
......@@ -93,7 +91,6 @@ double get_rhot_net(int N, double **a, double deltaT, double *arg, int NI);
void whiten_data(int imin, int imax, double *a, double *Snf);
void write_time_freq_samples(struct Data *data);
void window_fourier_waveform(LALInferenceRunState *runState, struct Data *data, double **hinj, double **winhinj);
void print_single_waveform(struct Data *data, double **h, double **psd, FILE *ofile);
......@@ -119,7 +116,7 @@ int main(int argc, char *argv[])
/* Variable declaration */
int i, ifo, imin, ii;//, imax;
char filename[100];
char filename[MAXSTRINGSIZE];
/* LAL data structure that will contain all of the data from the frame files */
LALInferenceRunState *runState = XLALCalloc(1,sizeof(LALInferenceRunState));
......@@ -229,11 +226,11 @@ int main(int argc, char *argv[])
/*
OUTPUT DIRECTORY
*/
char outdir[100];
char outdir[MAXSTRINGSIZE];
sprintf(outdir,"%spost",data->runName);
mkdir(outdir,S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
char wavedir[100];
char wavedir[MAXSTRINGSIZE];
sprintf(wavedir,"%s/waveforms",outdir);
mkdir(wavedir,S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
......@@ -593,7 +590,7 @@ int main(int argc, char *argv[])
double **invPSD = double_matrix(NI-1,data->N/2-1);
char datadir[100];
char datadir[MAXSTRINGSIZE];
sprintf(datadir,"%spost/data",data->runName);
mkdir(datadir,S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
......@@ -743,16 +740,13 @@ int main(int argc, char *argv[])
double **windowed_injection = malloc(NI*sizeof(double*));
for(ifo=0; ifo<NI; ifo++) windowed_injection[ifo] = malloc(N*sizeof(double));
//Window and output hinj in the time domain
window_fourier_waveform(runState, data, hinj, windowed_injection);
print_waveforms(data, windowed_injection, psd, injWhitenedWaveformFile);
print_waveforms(data, windowed_injection, one, injColoredWaveformFile);
print_spectrum(data, windowed_injection, injWhitenedSpectrumFile);
//Window and output hinjPlus in the time domain
window_fourier_waveform(runState, data, hinjPlus, windowed_injection);
print_waveforms(data, windowed_injection, psd, injPlusWhitenedWaveformFile);
print_waveforms(data, windowed_injection, one, injPlusColoredWaveformFile);
//Window and output hinjCross in the time domain
window_fourier_waveform(runState, data, hinjCross, windowed_injection);
print_waveforms(data, windowed_injection, psd, injCrossWhitenedWaveformFile);
print_waveforms(data, windowed_injection, one, injCrossColoredWaveformFile);
......@@ -893,7 +887,7 @@ int main(int argc, char *argv[])
if(data->nukeFlag)
{
fprintf(stdout, " ======= rm'ing chains/ and checkpoint/ ======\n");
char command[128];
char command[MAXSTRINGSIZE];
sprintf(command,"rm -rvf chains checkpoint");
system(command);
}
......@@ -1389,7 +1383,7 @@ void free_moments(struct Moments *m)
void setup_output_files(int NI, int injectionFlag, char *outdir, char *model, char *weighting, FILE **momentsOut, struct Data *data)
{
int ifo;
char filename[100];
char filename[MAXSTRINGSIZE];
//Open files
if(NI<0)
......@@ -1960,7 +1954,7 @@ void print_spectrograms(struct Data *data, char outdir[], char type[], char *ifo
double Qlist[3] = {4,8,16};
FILE *QscanFile;
char filename[128];
char filename[MAXSTRINGSIZE];
for(n=0; n<NQ; n++)
{
......@@ -2028,7 +2022,7 @@ void print_stats(struct Data *data, LIGOTimeGPS GPS, int injectionFlag, char *ou
FILE *momentsfile = NULL;
FILE *statsfile = NULL;
char filename[100];
char filename[MAXSTRINGSIZE];
char filerow[10000];
int count;
......@@ -2588,7 +2582,7 @@ void write_time_freq_samples(struct Data *data)
double Tobs = data->Tobs;
double deltaF = 1./data->Tobs;
char filename[100];
char filename[MAXSTRINGSIZE];
sprintf(filename,"%spost/timesamp.dat",data->runName);
FILE *timesamp = fopen(filename, "w");
sprintf(filename,"%spost/freqsamp.dat",data->runName);
......@@ -2612,13 +2606,13 @@ void write_time_freq_samples(struct Data *data)
int post_process_model(char model_name[], char model_type[], struct Data *data, struct Model *model, struct Chain *chain, double **hdata, double **hoft, double **psd, double **one, double **hinj, int **dimension, int injectionFlag, LIGOTimeGPS GPStrig, bool lite)
{
char outdir[100];
char outdir[MAXSTRINGSIZE];
sprintf(outdir,"%spost/%s",data->runName,model_name);
mkdir(outdir,S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
int i, ii, n,ifo;
int COUNT,BURNIN;
char filename[128];
char filename[MAXSTRINGSIZE];
double norm;
// Shortcut pointers to different members of the Model structre
......@@ -2676,14 +2670,12 @@ int post_process_model(char model_name[], char model_type[], struct Data *data,
initialize_moments(coloredFullMoments, NI);
int fullFlag = 0;
int noiseFlag = 0;
int glitchFlag = 0;
int signalFlag = 0;
// If noise-only model is in use, check for files
if(!strcmp(model_type,"noise"))
{
noiseFlag=1;
//File containing noise-only PSD parameters
sprintf(filename,"chains/%s%s_spline_%s.dat.0",data->runName, model_name,data->ifos[0]);
if( fopen(filename,"r") == NULL)
......@@ -3121,7 +3113,7 @@ int post_process_model(char model_name[], char model_type[], struct Data *data,
//// residual spectrograms /////
for (ii = 0; ii < data->N; ii++) residual[ifo][ii] = hdata[ifo][ii] - hoft_median[ifo][ii];
char qscan_type[128];
char qscan_type[MAXSTRINGSIZE];
sprintf(qscan_type,"%s_residual",model_type);
if(!lite){
......@@ -3251,7 +3243,7 @@ void print_anderson_darling_p_values(char *outDir, int Nsamp)
double dA = (Amax-Amin)/(double)nA;
double A2;
char filename[128];
char filename[MAXSTRINGSIZE];
sprintf(filename,"%s/anderson_darling_p_values.dat",outDir);
FILE *ADfile = fopen(filename,"w");
for(i=0;i<nA; i++)
......@@ -3264,7 +3256,7 @@ void print_anderson_darling_p_values(char *outDir, int Nsamp)
void anderson_darling_test(char *outdir, int ifo, double fmin, double Tobs, char *model, char **ifos)
{
char filename[1024];
char filename[MAXSTRINGSIZE];
FILE *dFile;
FILE *nFile;
......@@ -3361,12 +3353,6 @@ void anderson_darling_test(char *outdir, int ifo, double fmin, double Tobs, char
reim /= (double)(Nsamp/2);
imim /= (double)(Nsamp/2);
double matrix[2][2];
matrix[0][0]=rere;
matrix[1][1]=imim;
matrix[0][1]=reim;
matrix[1][0]=reim;
double det = rere*imim - reim*reim;
double tr = rere+imim;
......@@ -3388,13 +3374,7 @@ void anderson_darling_test(char *outdir, int ifo, double fmin, double Tobs, char
norm = sqrt(evector2[0]*evector2[0]+evector2[1]*evector2[1]);
evector2[0]/=norm;
evector2[1]/=norm;
double inverse[2][2];
inverse[0][0] = matrix[1][1]/det;
inverse[1][1] = matrix[0][0]/det;
inverse[0][1] = -matrix[0][1]/det;
inverse[1][0] = -matrix[1][0]/det;
double theta = atan2(evector1[1],evector1[0]);
double Rx = sqrt(lambda1);
double Ry = sqrt(lambda2);
......
......@@ -519,18 +519,16 @@ void intrinsic_fisher_matrix(double *params, struct FisherMatrix *fisher, int NW
{
double **analytic_fisher = fisher->matrix;
double t, f, Q, A, phi, beta = 0.0;
double f, Q, A, beta = 0.0;
//double f, Q, A, beta=0.0;
int ii, jj, Nparams;
//TODO: intrinsic_fisher_matrix has hard-coded D-wavelet!
Nparams = NW;
t = params[0];
f = params[1];
Q = params[2];
A = params[3];
phi = params[4];
if(NW>5) beta = params[5];
//precomput repeated constants
......
......@@ -246,7 +246,7 @@ void ChirpletFourier(double *hs, double *sigpar, int N, int flag, double Tobs)
double f0, t0, Q, sf, sx, Amp, beta;
double fmax, fmin, fac;
double phi, f;
double dn, dnx, trm, phz;
double dn, trm, phz;
double tau, delta,re, im;
int imin, imax, istart, istop, iend, even, odd;
double invTobs = 1.0/Tobs;
......@@ -287,7 +287,6 @@ void ChirpletFourier(double *hs, double *sigpar, int N, int flag, double Tobs)
// Some definitions
dn = (1.0+LAL_PI*LAL_PI*beta*beta);
dnx = pow(dn,0.25);
delta = 0.5*atan(LAL_PI*beta);
trm = LAL_PI*LAL_PI*LAL_PI*beta*tau*tau/dn;
fac = sqrt(Tobs);
......@@ -382,16 +381,13 @@ void ChirpletFourier(double *hs, double *sigpar, int N, int flag, double Tobs)
void ChirpletFisher(double *params, struct FisherMatrix *fisher)
{
double t, f, Q, A, phi, beta;
double f, Q, beta;
int ii, jj, Nparams;
Nparams = 6;
t = params[0];
f = params[1];
Q = params[2];
A = params[3];
phi = params[4];
beta = params[5];
......
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