Skip to content

Commit

Permalink
Move default paremeters into declaration
Browse files Browse the repository at this point in the history
Some member variables of the `parameters` struct were set to default
values in an unrelated function. Moved the default initialization to
the declaration of the struct.
  • Loading branch information
bcaddy committed Sep 14, 2023
1 parent e2affb4 commit 9ab72fe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 27 deletions.
16 changes: 0 additions & 16 deletions src/global/global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,22 +131,6 @@ void parse_params(char *param_file, struct parameters *parms, int argc, char **a
exit(1);
return;
}
// set default hydro file output parameter
parms->n_hydro = 1;
parms->n_particle = 1;
parms->n_slice = 1;
parms->n_projection = 1;
parms->n_rotated_projection = 1;

#ifdef ROTATED_PROJECTION
// initialize rotation parameters to zero
parms->delta = 0;
parms->theta = 0;
parms->phi = 0;
parms->n_delta = 0;
parms->ddelta_dt = 0;
parms->flag_delta = 0;
#endif /*ROTATED_PROJECTION*/

#ifdef COSMOLOGY
// Initialize file name as an empty string
Expand Down
23 changes: 12 additions & 11 deletions src/global/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@ struct parameters {
Real gamma;
char init[MAXLEN];
int nfile;
int n_hydro;
int n_particle;
int n_projection;
int n_rotated_projection;
int n_slice;
int n_hydro = 1;
int n_particle = 1;
int n_projection = 1;
int n_rotated_projection = 1;
int n_slice = 1;
int n_out_float32 = 0;
int out_float32_density = 0;
int out_float32_momentum_x = 0;
Expand Down Expand Up @@ -275,16 +275,17 @@ struct parameters {
char snr_filename[MAXLEN];
#endif
#ifdef ROTATED_PROJECTION
// initialize rotation parameters to zero
int nxr;
int nzr;
Real delta;
Real theta;
Real phi;
Real delta = 0;
Real theta = 0;
Real phi = 0;
Real Lx;
Real Lz;
int n_delta;
Real ddelta_dt;
int flag_delta;
int n_delta = 0;
Real ddelta_dt = 0;
int flag_delta = 0;
#endif /*ROTATED_PROJECTION*/
#ifdef COSMOLOGY
Real H0;
Expand Down

0 comments on commit 9ab72fe

Please sign in to comment.