Skip to content

Commit

Permalink
Fix a large number of gcc warnings with -Wall, mostly defined unused
Browse files Browse the repository at this point in the history
variables.
  • Loading branch information
Simeon Bird committed Mar 1, 2016
1 parent ca24032 commit 95cd502
Show file tree
Hide file tree
Showing 26 changed files with 71 additions and 125 deletions.
5 changes: 2 additions & 3 deletions GENIC/power.c
Expand Up @@ -212,11 +212,10 @@ void initialize_powerspectrum(void)

double PowerSpec_Tabulated(double k)
{
double logk, logD, P, u, dlogk, Delta2; //kold
int binlow, binhigh, binmid;
double logk, logD, P, u, dlogk; // Delta2; //kold

double mydlogk,dlogk_PowerTable;
int mybinhigh,mybinlow,mybinmid;
int mybinhigh,mybinlow;



Expand Down
6 changes: 0 additions & 6 deletions GENIC/zeldovich.c
Expand Up @@ -12,14 +12,11 @@
#include "walltime.h"

#define MESH2K(i) petapm_mesh_to_k(i)
static void diff_transfer(int64_t k2, pfft_complex * value);
static void density_transfer(int64_t k2, int kpos[3], pfft_complex * value);
static void disp_x_transfer(int64_t k2, int kpos[3], pfft_complex * value);
static void disp_y_transfer(int64_t k2, int kpos[3], pfft_complex * value);
static void disp_z_transfer(int64_t k2, int kpos[3], pfft_complex * value);
static void put_particle_to_mesh(int i, double * mesh, double weight);
static void readout_density(int i, double * mesh, double weight);
static void readout_potential(int i, double * mesh, double weight);
static void readout_force_x(int i, double * mesh, double weight);
static void readout_force_y(int i, double * mesh, double weight);
static void readout_force_z(int i, double * mesh, double weight);
Expand Down Expand Up @@ -412,9 +409,6 @@ static void disp_z_transfer(int64_t k2, int kpos[3], pfft_complex * value) {
/**************
* functions iterating over particle / mesh pairs
***************/
static void mark_all_mesh(int i, double * mesh, double weight) {
mesh[0] = 1.0;
}
static void readout_density(int i, double * mesh, double weight) {
P[i].Density += weight * mesh[0];
}
Expand Down
8 changes: 5 additions & 3 deletions begrun.c
Expand Up @@ -917,8 +917,8 @@ static int parse_multichoice(struct multichoice * table, char * strchoices) {
int value = 0;
struct multichoice * p = table;
char * delim = ",;&| \t";
char * token = strtok(strchoices, delim);
for(token; token ; token = strtok(NULL, delim)) {
char * token;
for(token = strtok(strchoices, delim); token ; token = strtok(NULL, delim)) {
for(p = table; p->name; p++) {
if(strcasecmp(token, p->name) == 0) {
value |= p->value;
Expand Down Expand Up @@ -1005,7 +1005,7 @@ void read_parameter_file(char *fname)
void *addr[MAXTAGS];
struct multichoice * choices[MAXTAGS];
char tag[MAXTAGS][50];
int pnum, errorFlag = 0;
int errorFlag = 0;

All.StarformationOn = 0; /* defaults */

Expand Down Expand Up @@ -2030,6 +2030,8 @@ void read_parameter_file(char *fname)

*buf = 0;
ret = fgets(buf, 200, fd);
if(ret == NULL)
continue;
if(sscanf(buf, "%s%s%s", buf1, buf2, buf3) < 2)
continue;

Expand Down
12 changes: 7 additions & 5 deletions cooling.c
Expand Up @@ -308,7 +308,7 @@ double DoInstabilityCooling(double m_old, double u, double rho, double dt, doubl

void cool_test(void)
{
double uin, rhoin, tempin, muin, nein;
double uin, rhoin, muin, nein;

//tempin = 34.0025;
uin = 6.01329e+09;
Expand All @@ -333,7 +333,7 @@ static double convert_u_to_temp(double u, double nHcgs, struct UVBG * uvbg, stru
double mu;
struct rates r;
int iter = 0;
double u_input, rho_input, ne_input;
/* double u_input, rho_input, ne_input; */

mu = (1 + 4 * yhelium) / (1 + yhelium + y->ne);
temp = GAMMA_MINUS1 / BOLTZMANN * u * PROTONMASS * mu;
Expand Down Expand Up @@ -380,7 +380,7 @@ static void find_abundances_and_rates(double logT, double nHcgs, struct UVBG * u
int j, niter;
double flow, fhi, t;

double logT_input, rho_input, ne_input;
/* double logT_input, rho_input, ne_input; */

if(logT <= Tmin) /* everything neutral */
{
Expand Down Expand Up @@ -925,7 +925,6 @@ static float inlogz[TABLESIZE];
static float gH0[TABLESIZE], gHe[TABLESIZE], gHep[TABLESIZE];
static float eH0[TABLESIZE], eHe[TABLESIZE], eHep[TABLESIZE];
static int nheattab; /* length of table */
static double CurrentReionizedFraction;

void ReadIonizeParams(char *fname)
{
Expand Down Expand Up @@ -1138,7 +1137,7 @@ static void InitMetalCooling() {
//This is never used
double * tabbedmet = h5readdouble(All.MetalCoolFile, "MetallicityInSolar_bins", &size);

if(ThisTask == 0 && size != 1 || tabbedmet[0] != 0.0) {
if(ThisTask == 0 && (size != 1 || tabbedmet[0] != 0.0)) {
fprintf(stderr, "MetalCool file %s is wrongly tabulated\n", All.MetalCoolFile);
endrun(124214);
}
Expand Down Expand Up @@ -1245,6 +1244,8 @@ static void InitUVF(void) {
interp_init_dim(&UVF.interp, 2, XYZ_Bins[0], XYZ_Bins[Nside - 1]);
free(XYZ_Bins);
}

#if 0
/* Fraction of total universe that is ionized.
* currently unused. Unclear if the UVBG in Treecool shall be adjusted
* by the factor or not. seems to be NOT after reading Giguere's paper.
Expand All @@ -1261,6 +1262,7 @@ static double GetReionizedFraction(double time) {
if(status[0] > 0) return 1.0;
return fraction;
}
#endif


/*
Expand Down
10 changes: 4 additions & 6 deletions density.c
Expand Up @@ -158,14 +158,14 @@ void density(void)
ev.ev_datain_elsize = sizeof(struct densdata_in);
ev.ev_dataout_elsize = sizeof(struct densdata_out);

int i, j, k, npleft, iter = 0;
int i, npleft, iter = 0;

int64_t ntot = 0;

double timeall = 0;
double timecomp, timecomp3 = 0, timecomm, timewait;

double dt_entr, tstart, tend;
double tstart, tend;

#if defined(EULERPOTENTIALS) || defined(VECT_PRO_CLEAN) || defined(TRACEDIVB) || defined(VECT_POTENTIAL)
double efak;
Expand Down Expand Up @@ -244,7 +244,7 @@ void density(void)
if(iter >= MAXITER - 10)
{
printf
("i=%d task=%d ID=%llu Hsml=%g Left=%g Right=%g Ngbs=%g Right-Left=%g\n pos=(%g|%g|%g)\n",
("i=%d task=%d ID=%lu Hsml=%g Left=%g Right=%g Ngbs=%g Right-Left=%g\n pos=(%g|%g|%g)\n",
queue[p], ThisTask, P[p].ID, P[p].Hsml, Left[p], Right[p],
(float) P[p].n.NumNgb, Right[p] - Left[p], P[p].Pos[0], P[p].Pos[1], P[p].Pos[2]);
fflush(stdout);
Expand Down Expand Up @@ -533,8 +533,6 @@ static int density_evaluate(int target, int mode,
int ninteractions = 0;
int nnodesinlist = 0;

int k;

density_kernel_t kernel;
#ifdef BLACK_HOLES
density_kernel_t bh_feedback_kernel;
Expand Down Expand Up @@ -1024,14 +1022,14 @@ static void density_post_process(int i) {
dt_step = P[i].dt_step;
#endif

int dt_entr = (All.Ti_Current - (P[i].Ti_begstep + dt_step / 2)) * All.Timebase_interval;
#ifndef EOS_DEGENERATE
#ifndef MHM
#ifndef SOFTEREQS
#ifndef TRADITIONAL_SPH_FORMULATION
#ifdef DENSITY_INDEPENDENT_SPH
SPHP(i).Pressure = pow(SPHP(i).EntVarPred*SPHP(i).EgyWtDensity,GAMMA);
#else
int dt_entr = (All.Ti_Current - (P[i].Ti_begstep + dt_step / 2)) * All.Timebase_interval;
SPHP(i).Pressure =
(SPHP(i).Entropy + SPHP(i).e.DtEntropy * dt_entr) * pow(SPHP(i).Density, GAMMA);
#endif // DENSITY_INDEPENDENT_SPH
Expand Down
1 change: 0 additions & 1 deletion densitykernel.c
Expand Up @@ -143,7 +143,6 @@ void density_kernel_init_with_type(density_kernel_t * kernel, int type, double H
kernel->H = H;
kernel->HH = H * H;
kernel->Hinv = 1. / H;
int nDim;
kernel->type = type;
double support = KERNELS[kernel->type].support;
double sigma = KERNELS[kernel->type].sigma[NUMDIMS - 1];
Expand Down
6 changes: 3 additions & 3 deletions domain.c
Expand Up @@ -339,7 +339,7 @@ double domain_particle_costfactor(int i)
int domain_decompose(void)
{

int i, no, status;
int i, status;
int64_t sumload;
int maxload;
double sumwork, sumcpu, sumcost, maxwork, cadj_SpeedFac;
Expand Down Expand Up @@ -665,7 +665,7 @@ static void domain_exchange_once(int (*layoutfunc)(int p))
*offset, *offset_sph, *offset_bh;
int *count_recv, *count_recv_sph, *count_recv_bh,
*offset_recv, *offset_recv_sph, *offset_recv_bh;
int i, n, ngrp, no, target;
int i, n, target;
struct particle_data *partBuf;
struct sph_particle_data *sphBuf;
struct bh_particle_data *bhBuf;
Expand Down Expand Up @@ -1323,7 +1323,7 @@ static int domain_countToGo(ptrdiff_t nlimit, int (*layoutfunc)(int p))
MPI_Allgather(&N_bh, 1, MPI_INT, list_N_bh, 1, MPI_INT, MPI_COMM_WORLD);
MPI_Allgather(&N_sph, 1, MPI_INT, list_N_sph, 1, MPI_INT, MPI_COMM_WORLD);

int flag, flagsum, ntoomany, ta, i, target;
int flag, flagsum, ntoomany, ta, i;
int count_togo, count_toget, count_togo_bh, count_toget_bh, count_togo_sph, count_toget_sph;

do
Expand Down
9 changes: 3 additions & 6 deletions evaluator.c
Expand Up @@ -32,6 +32,7 @@ void ev_init_thread(Evaluator * ev, LocalEvaluator * lv) {
}

void ev_begin(Evaluator * ev) {
/* This is weird because of the comma on line 40*/
All.BunchSize =
(int) ((All.BufferSize * 1024 * 1024) / (sizeof(struct data_index) +
sizeof(struct data_nodelist) +
Expand Down Expand Up @@ -256,7 +257,6 @@ void ev_secondary(Evaluator * ev) {
#pragma omp parallel
{
int j;
int thread_id = omp_get_thread_num();
LocalEvaluator lv;
void * extradata = NULL;
if(ev->ev_alloc)
Expand Down Expand Up @@ -356,9 +356,6 @@ void ev_run(Evaluator * ev) {

static void ev_im_or_ex(void * sendbuf, void * recvbuf, size_t elsize, int tag, int import) {
/* if import is 1, import the results from neigbhours */
int ngrp;
char * sp = sendbuf;
char * rp = recvbuf;
MPI_Datatype type;
MPI_Type_contiguous(elsize, MPI_BYTE, &type);
MPI_Type_commit(&type);
Expand Down Expand Up @@ -394,7 +391,6 @@ void ev_get_remote(Evaluator * ev, int tag) {
int place = DataIndexTable[j].Index;
/* the convention is to have nodelist at the beginning */
if(ev->UseNodeList) {
int c = 0;
int * nl = DataNodeList[DataIndexTable[j].IndexGet].NodeList;
memcpy(sendbuf + j * ev->ev_datain_elsize, nl, sizeof(int) * NODELISTLENGTH);
}
Expand Down Expand Up @@ -483,13 +479,14 @@ void ev_reduce_result(Evaluator * ev, int tag) {
myfree(ev->dataget);
}

#if 0
static int ev_task_cmp_by_top_node(const void * p1, const void * p2) {
const struct ev_task * t1 = p1, * t2 = p2;
if(t1->top_node > t2->top_node) return 1;
if(t1->top_node < t2->top_node) return -1;
return 0;
}

#endif

static void fill_task_queue (Evaluator * ev, struct ev_task * tq, int * pq, int length) {
int i;
Expand Down
11 changes: 4 additions & 7 deletions fof.c
Expand Up @@ -40,13 +40,12 @@ static struct fofdata_in
}
*FoFDataIn, *FoFDataGet;

static struct fofdata_out
struct fofdata_out
{
MyFloat Distance;
MyIDType MinID;
MyIDType MinIDTask;
}
*FoFDataResult, *FoFDataOut;
};


static struct fof_particle_list
Expand Down Expand Up @@ -1182,9 +1181,8 @@ static void fof_radix_FOF_GList_ExtCountMinID(const void * a, void * radix, void

void fof_save_groups(int num)
{
int i, j, start, lenloc, nprocgroup, masterTask, groupTask, ngr, totlen;
int i, j, start, lenloc, ngr, totlen;
int64_t totNids;
char buf[500];
double t0, t1;

if(ThisTask == 0)
Expand Down Expand Up @@ -1361,9 +1359,8 @@ static int fof_nearest_evaluate(int target, int mode,
LocalEvaluator * lv, int *ngblist);
void fof_find_nearest_dmparticle(void)
{
int i, j, n, dummy;
int i, n, iter;
int64_t ntot;
int ndone, ndone_flag, ngrp, recvTask, place, nexport, nimport, iter;
Evaluator ev = {0};
ev.ev_label = "FOF_FIND_NEAREST";
ev.ev_evaluate = (ev_ev_func) fof_nearest_evaluate;
Expand Down
10 changes: 6 additions & 4 deletions fofpetaio.c
Expand Up @@ -24,9 +24,6 @@ static void build_buffer_fof(BigArray * array, IOTableEntry * ent);
static void fof_return_particles();
static void fof_distribute_particles();

static int fof_select_particle(int i) {
return P[i].GrNr > 0;
}
static int fof_cmp_argind(const void *p1, const void * p2) {
const int * i1 = p1;
const int * i2 = p2;
Expand Down Expand Up @@ -140,7 +137,11 @@ static void fof_radix_origin(const void * c1, void * out, void * arg) {
const struct PartIndex * pi = c1;
*u = pi->origin;
}

#if 0
/*Unused functions*/
static int fof_select_particle(int i) {
return P[i].GrNr > 0;
}
static int fof_cmp_sortkey(const void * c1, const void * c2) {
const struct PartIndex * p1 = c1;
const struct PartIndex * p2 = c2;
Expand All @@ -151,6 +152,7 @@ static int fof_cmp_origin(const void * c1, const void * c2) {
const struct PartIndex * p2 = c2;
return (p1->origin > p2->origin) - (p1->origin < p2->origin);
}
#endif

static void fof_distribute_particles() {
int i;
Expand Down

0 comments on commit 95cd502

Please sign in to comment.