Skip to content

Commit

Permalink
Merge pull request #258 from VirtualPlanetaryLaboratory/Warnings
Browse files Browse the repository at this point in the history
Fixed numerous compiler warnings on Linux.
  • Loading branch information
RoryBarnes authored Jan 6, 2024
2 parents 8b05134 + 45d26ee commit 3960012
Show file tree
Hide file tree
Showing 15 changed files with 128 additions and 162 deletions.
46 changes: 17 additions & 29 deletions src/atmesc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1692,6 +1692,22 @@ void fnForceBehaviorAtmEsc(BODY *body, MODULE *module, EVOLVE *evolve, IO *io,
}
}

void AuxPropsLehmer17(BODY *body,int iBody) {
if (body[iBody].bAutoThermTemp) {
body[iBody].dThermTemp = fdThermalTemp(body, iBody);
}
body[iBody].dGravAccel = BIGG *
(body[iBody].dMass - body[iBody].dEnvelopeMass) /
(body[iBody].dRadSolid * body[iBody].dRadSolid);
body[iBody].dScaleHeight = body[iBody].dAtmGasConst *
body[iBody].dThermTemp / body[iBody].dGravAccel;
body[iBody].dPresSurf =
fdLehmerPres(body[iBody].dEnvelopeMass, body[iBody].dGravAccel,
body[iBody].dRadSolid);
body[iBody].dRadXUV = fdLehmerRadius(body, iBody);
body[iBody].dRadius = body[iBody].dRadXUV / body[iBody].dXFrac;
}


/**
Initializes several helper variables and properties used in the integration.
Expand All @@ -1707,41 +1723,13 @@ Initializes several helper variables and properties used in the integration.
void fnPropsAuxAtmEsc(BODY *body, EVOLVE *evolve, IO *io, UPDATE *update,
int iBody) {

/*
#ifdef DEBUG
if (body[iBody].dMass < 0) {
fprintf(stderr,"ERROR: %s's mass is %.5e at %.5e
years.\n",body[iBody].cName, body[iBody].dMass,evolve->dTime/YEARSEC);
exit(EXIT_INT);
}
#endif
*/

if (body[iBody].iPlanetRadiusModel == ATMESC_LEHMER17) {
if (body[iBody].bAutoThermTemp) {
body[iBody].dThermTemp = fdThermalTemp(body, iBody);
}
body[iBody].dGravAccel = BIGG *
(body[iBody].dMass - body[iBody].dEnvelopeMass) /
(body[iBody].dRadSolid * body[iBody].dRadSolid);
body[iBody].dScaleHeight = body[iBody].dAtmGasConst *
body[iBody].dThermTemp / body[iBody].dGravAccel;
body[iBody].dPresSurf =
fdLehmerPres(body[iBody].dEnvelopeMass, body[iBody].dGravAccel,
body[iBody].dRadSolid);
body[iBody].dRadXUV = fdLehmerRadius(body, iBody);
body[iBody].dRadius = body[iBody].dRadXUV / body[iBody].dXFrac;
AuxPropsLehmer17(body,iBody);
}

// Compute various radii of interest
body[iBody].dBondiRadius = fdBondiRadius(body, iBody);
body[iBody].dRocheRadius = fdRocheRadius(body, iBody);

// Ktide (due to body zero only). WARNING: not suited for binary...
/* xi = (pow(body[iBody].dMass / (3. * body[0].dMass), (1. / 3)) *
body[iBody].dSemi) /
(body[iBody].dRadius * body[iBody].dXFrac);
*/
body[iBody].dAtmEscXi = fdAtmEscXi(body, iBody);
body[iBody].dKTide = fdKTide(body, io, iBody);

Expand Down
8 changes: 4 additions & 4 deletions src/body.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,16 +665,16 @@ double fdImK2Total(BODY *body, int iBody) {
@return Upper mantle k2 Love number
*/
double fdK2Man(BODY *body, int iBody) {
// return 1.5/(1+9.5*body[iBody].dShmodUMan/(STIFFNESS));
return 1.5 / (1 + 9.5 * body[iBody].dShmodUMan / body[iBody].dStiffness);
double dK2Man = 1.5 / (1 + 9.5 * body[iBody].dShmodUMan / body[iBody].dStiffness);
return dK2Man;
}

double fdTidalQMan(BODY *body, int iBody) {
double ShmodUManArr;
ShmodUManArr = body[iBody].dShmodUMan * body[iBody].dMeltfactorUMan;
// return body[iBody].dDynamViscos*body[iBody].dMeanMotion/ShmodUManArr;
return body[iBody].dDynamViscos * body[iBody].dMeanMotion /
double dTidalQMan = body[iBody].dDynamViscos * body[iBody].dMeanMotion /
body[iBody].dShmodUMan;
return dTidalQMan;
}

double fdImK2ManThermint(BODY *body, int iBody) {
Expand Down
14 changes: 12 additions & 2 deletions src/distorb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1645,7 +1645,7 @@ int fniHaltHillStab(BODY *body, EVOLVE *evolve, HALT *halt, IO *io,
gamma2 = sqrt(1 - (body[iBody].dHecc * body[iBody].dHecc +
body[iBody].dKecc * body[iBody].dKecc));
delta = sqrt(body[iBody].dSemi / body[jBody].dSemi);
} else if (body[jBody].dSemi > body[iBody].dSemi) {
} else {
// jBody is the outer planet
mu2 = body[jBody].dMass / body[0].dMass;
mu1 = body[iBody].dMass / body[0].dMass;
Expand Down Expand Up @@ -2557,6 +2557,9 @@ void HessEigen(double **amat, int origsize, double real[], double imag[]) {
q /= lrcorner;
r /= lrcorner;
}
} else {
fprintf(stderr,"ERROR: k=m in distorb.c:HessEigen.");
exit(EXIT_INT);
}
value = sqrt(p * p + q * q + r * r);
s = (double)fiSign(p) * value;
Expand Down Expand Up @@ -2653,6 +2656,7 @@ void HessReduce(double **a, int size) {

for (r = 0; r < size; r++) {
max = 0;
rmax = r+1;
for (rp = r + 1; rp < size; rp++) {
if (fabs(a[rp][r]) > max) {
max = fabs(a[rp][r]);
Expand Down Expand Up @@ -3043,6 +3047,9 @@ void RecalcLaplace(BODY *body, EVOLVE *evolve, SYSTEM *system, int iVerbose) {
alpha1 = body[iBody].dSemi / body[jBody].dSemi;
} else if (body[iBody].dSemi > body[jBody].dSemi) {
alpha1 = body[jBody].dSemi / body[iBody].dSemi;
} else {
fprintf(stderr,"ERROR: Semi-major axes cannot be identical in RecalcLaplace.");
exit(EXIT_INPUT);
}

for (j = 0; j < 26; j++) {
Expand Down Expand Up @@ -3076,14 +3083,17 @@ Recalculates eigenvalues in case where LL2 solution is coupled to eqtide
*/
void RecalcEigenVals(BODY *body, EVOLVE *evolve, SYSTEM *system) {
int iBody, jBody, j, done = 0;
double alpha1, dalpha = -1, dalphaTmp;
double alpha1 = 0, dalpha = -1, dalphaTmp;

for (iBody = 1; iBody < evolve->iNumBodies - 1; iBody++) {
for (jBody = iBody + 1; jBody < evolve->iNumBodies; jBody++) {
if (body[iBody].dSemi < body[jBody].dSemi) {
alpha1 = body[iBody].dSemi / body[jBody].dSemi;
} else if (body[iBody].dSemi > body[jBody].dSemi) {
alpha1 = body[jBody].dSemi / body[iBody].dSemi;
} else {
fprintf(stderr,"ERROR: Semi-major axes cannot be identical in RecalcEigenVals.");
exit(EXIT_INPUT);
}
for (j = 0; j < 2; j++) {
dalphaTmp =
Expand Down
12 changes: 9 additions & 3 deletions src/distrot.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,10 @@ void VerifyOrbitData(BODY *body, CONTROL *control, OPTIONS *options,
exit(EXIT_INPUT);
}
// Check file has exactly 7 columns
fgets(cLine, LINE, fileorb);
if (fgets(cLine, LINE, fileorb) == NULL) {
fprintf(stderr,"ERROR: Unable to read line from orbit data file.");
exit(EXIT_INPUT);
}
GetWords(cLine, cFoo, &iNumColsFound, &bFoo);
if (iNumCols != iNumColsFound) {
if (control->Io.iVerbose >= VERBERR) {
Expand Down Expand Up @@ -456,8 +459,11 @@ void VerifyOrbitData(BODY *body, CONTROL *control, OPTIONS *options,

iLine = 0;
while (feof(fileorb) == 0) {
fscanf(fileorb, "%lf %lf %lf %lf %lf %lf %lf\n", &dttmp, &datmp, &detmp,
&ditmp, &daptmp, &dlatmp, &dmatmp);
if (fscanf(fileorb, "%lf %lf %lf %lf %lf %lf %lf\n", &dttmp, &datmp, &detmp,
&ditmp, &daptmp, &dlatmp, &dmatmp) != 7) {
fprintf(stderr,"ERROR: Incorrect number of columns in orbit file.");
exit(EXIT_INPUT);
}
body[iBody].daTimeSeries[iLine] =
dttmp * fdUnitsTime(control->Units[iBody + 1].iTime);
body[iBody].daSemiSeries[iLine] =
Expand Down
11 changes: 7 additions & 4 deletions src/eqtide.c
Original file line number Diff line number Diff line change
Expand Up @@ -4618,11 +4618,13 @@ double fdDB15DsemiDt(BODY *body, SYSTEM *system, int *iaBody) {
if (iBody > 0) { // Also means iBody is the orbiter
double imk2;
/* Set imk2 using appropriate model */
/* XXX This switch is not understood -- deprecate for v3.0 */
if (body[iBody].dImK2ManOrbModel == 1) {
imk2 = body[iBody].dImK2Man;
}
if (body[iBody].dImK2ManOrbModel == 2) {
} else if (body[iBody].dImK2ManOrbModel == 2) {
imk2 = -body[iBody].dK2Man / body[iBody].dTidalQMan;
} else {
imk2 = body[iBody].dImK2Man; // To eliminate compiler warnings.
}
return 21 * imk2 * body[iBody].dSemi * body[iPert].dMass /
body[iBody].dMass *
Expand All @@ -4642,9 +4644,10 @@ double fdDB15DeccDt(BODY *body, UPDATE *update, int *iaBody) {
/* Set imk2 using appropriate model */
if (body[iBody].dImK2ManOrbModel == 1) {
imk2 = body[iBody].dImK2Man;
}
if (body[iBody].dImK2ManOrbModel == 2) {
} else if (body[iBody].dImK2ManOrbModel == 2) {
imk2 = -body[iBody].dK2Man / body[iBody].dTidalQMan;
} else {
imk2 = body[iBody].dImK2Man; // To eliminate compiler warnings.
}
return 21 / 2. * imk2 * pow(body[iPert].dMass, 3. / 2) * pow(BIGG, 1. / 2) *
pow(body[iBody].dRadius, 5) * body[iBody].dEcc / body[iBody].dMass /
Expand Down
12 changes: 0 additions & 12 deletions src/evolve.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,9 @@ void fdGetUpdateInfo(BODY *body, CONTROL *control, SYSTEM *system,

int iBody, iVar, iEqn, iNumBodies, iNumVars,
iNumEqns; // Dummy counting variables
EVOLVE
integr; // Dummy EVOLVE struct so we don't have to dereference control a lot
double dVarNow, dMinNow, dMin = dHUGE,
dVarTotal; // Intermediate storage variables

integr = control->Evolve;

iNumBodies = control->Evolve.iNumBodies;
for (iBody = 0; iBody < iNumBodies; iBody++) {
if (update[iBody].iNumVars > 0) {
Expand Down Expand Up @@ -416,8 +412,6 @@ void RungeKutta4Step(BODY *body, CONTROL *control, SYSTEM *system,

evolve->dCurrentDt = *dDt;
iNumBodies = evolve->iNumBodies;
#pragma omp parallel for num_threads(NUM_THREADS) private(iNumVars, iNumEqns, \
iVar, iEqn)
for (iBody = 0; iBody < iNumBodies; iBody++) {
// int thread_num = omp_get_thread_num();
// int cpu_num = sched_getcpu();
Expand Down Expand Up @@ -463,8 +457,6 @@ void RungeKutta4Step(BODY *body, CONTROL *control, SYSTEM *system,
fdGetUpdateInfo(evolve->tmpBody, control, system, evolve->tmpUpdate,
fnUpdate);

#pragma omp parallel for num_threads(NUM_THREADS) private(iNumVars, iNumEqns, \
iVar, iEqn)
for (iBody = 0; iBody < iNumBodies; iBody++) {
iNumVars = update[iBody].iNumVars;
double daDerivVar;
Expand Down Expand Up @@ -508,8 +500,6 @@ void RungeKutta4Step(BODY *body, CONTROL *control, SYSTEM *system,
fdGetUpdateInfo(evolve->tmpBody, control, system, evolve->tmpUpdate,
fnUpdate);

#pragma omp parallel for num_threads(NUM_THREADS) private(iNumVars, iNumEqns, \
iVar, iEqn)
for (iBody = 0; iBody < iNumBodies; iBody++) {
iNumVars = update[iBody].iNumVars;
double daDerivVar;
Expand Down Expand Up @@ -553,8 +543,6 @@ void RungeKutta4Step(BODY *body, CONTROL *control, SYSTEM *system,
fdGetUpdateInfo(evolve->tmpBody, control, system, evolve->tmpUpdate,
fnUpdate);

#pragma omp parallel for num_threads(NUM_THREADS) private(iNumVars, iNumEqns, \
iVar, iEqn)
for (iBody = 0; iBody < iNumBodies; iBody++) {
double daDerivVar;
iNumVars = update[iBody].iNumVars;
Expand Down
16 changes: 1 addition & 15 deletions src/flare.c
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ void VerifyFlare(BODY *body,
already inputed the XUV luminosity by flares and the flare module doesn't need
this information anymore*/
if (body[iBody].iFlareFFD == FLARE_FFD_NONE) {
int iCol, bError = 0;
int iCol;
for (iCol = 0; iCol < files->Outfile[iBody].iNumCols; iCol++) {
if (memcmp(files->Outfile[iBody].caCol[iCol],
output[OUT_FLAREFREQ1].cName,
Expand All @@ -765,7 +765,6 @@ void VerifyFlare(BODY *body,
"WARNING: Output option %s only allowed with FFD model "
"DAVENPORT or LACY \n",
output[OUT_FLAREFREQ1].cName);
bError = 1;
}
if (memcmp(files->Outfile[iBody].caCol[iCol],
output[OUT_FLAREFREQ2].cName,
Expand All @@ -775,7 +774,6 @@ void VerifyFlare(BODY *body,
"WARNING: Output option %s only allowed with FFD model "
"DAVENPORT or LACY \n",
output[OUT_FLAREFREQ2].cName);
bError = 1;
}
if (memcmp(files->Outfile[iBody].caCol[iCol],
output[OUT_FLAREFREQ3].cName,
Expand All @@ -785,7 +783,6 @@ void VerifyFlare(BODY *body,
"WARNING: Output option %s only allowed with FFD model "
"DAVENPORT or LACY \n",
output[OUT_FLAREFREQ3].cName);
bError = 1;
}
if (memcmp(files->Outfile[iBody].caCol[iCol],
output[OUT_FLAREFREQ4].cName,
Expand All @@ -795,7 +792,6 @@ void VerifyFlare(BODY *body,
"WARNING: Output option %s only allowed with FFD model "
"DAVENPORT or LACY \n",
output[OUT_FLAREFREQ4].cName);
bError = 1;
}
if (memcmp(files->Outfile[iBody].caCol[iCol],
output[OUT_FLAREFREQMIN].cName,
Expand All @@ -805,7 +801,6 @@ void VerifyFlare(BODY *body,
"WARNING: Output option %s only allowed with FFD model "
"DAVENPORT or LACY \n",
output[OUT_FLAREFREQMIN].cName);
bError = 1;
}
if (memcmp(files->Outfile[iBody].caCol[iCol],
output[OUT_FLAREFREQMID].cName,
Expand All @@ -815,7 +810,6 @@ void VerifyFlare(BODY *body,
"WARNING: Output option %s only allowed with FFD model "
"DAVENPORT or LACY \n",
output[OUT_FLAREFREQMID].cName);
bError = 1;
}
if (memcmp(files->Outfile[iBody].caCol[iCol],
output[OUT_FLAREFREQMAX].cName,
Expand All @@ -825,7 +819,6 @@ void VerifyFlare(BODY *body,
"WARNING: Output option %s only allowed with FFD model "
"DAVENPORT or LACY \n",
output[OUT_FLAREFREQMAX].cName);
bError = 1;
}
if (memcmp(files->Outfile[iBody].caCol[iCol],
output[OUT_FLAREENERGY1].cName,
Expand All @@ -835,7 +828,6 @@ void VerifyFlare(BODY *body,
"WARNING: Output option %s only allowed with FFD model "
"DAVENPORT or LACY \n",
output[OUT_FLAREENERGY1].cName);
bError = 1;
}
if (memcmp(files->Outfile[iBody].caCol[iCol],
output[OUT_FLAREENERGY2].cName,
Expand All @@ -845,7 +837,6 @@ void VerifyFlare(BODY *body,
"WARNING: Output option %s only allowed with FFD model "
"DAVENPORT or LACY \n",
output[OUT_FLAREENERGY2].cName);
bError = 1;
}
if (memcmp(files->Outfile[iBody].caCol[iCol],
output[OUT_FLAREENERGY3].cName,
Expand All @@ -855,7 +846,6 @@ void VerifyFlare(BODY *body,
"WARNING: Output option %s only allowed with FFD model "
"DAVENPORT or LACY \n",
output[OUT_FLAREENERGY3].cName);
bError = 1;
}
if (memcmp(files->Outfile[iBody].caCol[iCol],
output[OUT_FLAREENERGY4].cName,
Expand All @@ -865,7 +855,6 @@ void VerifyFlare(BODY *body,
"WARNING: Output option %s only allowed with FFD model "
"DAVENPORT or LACY \n",
output[OUT_FLAREENERGY4].cName);
bError = 1;
}
if (memcmp(files->Outfile[iBody].caCol[iCol],
output[OUT_FLAREENERGYMIN].cName,
Expand All @@ -875,7 +864,6 @@ void VerifyFlare(BODY *body,
"WARNING: Output option %s only allowed with FFD model "
"DAVENPORT or LACY \n",
output[OUT_FLAREENERGYMIN].cName);
bError = 1;
}
if (memcmp(files->Outfile[iBody].caCol[iCol],
output[OUT_FLAREENERGYMID].cName,
Expand All @@ -885,7 +873,6 @@ void VerifyFlare(BODY *body,
"WARNING: Output option %s only allowed with FFD model "
"DAVENPORT or LACY \n",
output[OUT_FLAREENERGYMID].cName);
bError = 1;
}
if (memcmp(files->Outfile[iBody].caCol[iCol],
output[OUT_FLAREENERGYMAX].cName,
Expand All @@ -895,7 +882,6 @@ void VerifyFlare(BODY *body,
"WARNING: Output option %s only allowed with FFD model "
"DAVENPORT or LACY \n",
output[OUT_FLAREENERGYMAX].cName);
bError = 1;
}
}
}
Expand Down
Loading

0 comments on commit 3960012

Please sign in to comment.