From 9ab72fe7ae04f7e0fe4413f442191d473c58d004 Mon Sep 17 00:00:00 2001 From: Bob Caddy Date: Wed, 13 Sep 2023 15:47:50 -0400 Subject: [PATCH] Move default paremeters into declaration 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. --- src/global/global.cpp | 16 ---------------- src/global/global.h | 23 ++++++++++++----------- 2 files changed, 12 insertions(+), 27 deletions(-) diff --git a/src/global/global.cpp b/src/global/global.cpp index a4c697d3c..2cdb508d1 100644 --- a/src/global/global.cpp +++ b/src/global/global.cpp @@ -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 diff --git a/src/global/global.h b/src/global/global.h index b037c931d..75fee01fb 100644 --- a/src/global/global.h +++ b/src/global/global.h @@ -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; @@ -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;