diff --git a/src/control.c b/src/control.c index 55240e830..b5053db23 100644 --- a/src/control.c +++ b/src/control.c @@ -78,6 +78,7 @@ void sort_output(OUTPUT *output, int sorted[]) { SORTED_OUTPUT sorted_output[MODULEOUTEND]; for (iOpt = 0; iOpt < MODULEOUTEND; iOpt++) { sorted_output[iOpt].index = iOpt; + sorted_output[iOpt].name=NULL; fvFormattedString(&sorted_output[iOpt].name, output[iOpt].cName); } qsort(sorted_output, MODULEOUTEND, sizeof(sorted_output[0]), @@ -93,13 +94,16 @@ void sort_output(OUTPUT *output, int sorted[]) { */ void InitializeFiles(FILES *files, int iNumBodies) { - int iBody; + int iBody,iOption; files->cLog = NULL; files->cExe = NULL; for (iBody = 0; iBody < iNumBodies; iBody++) { // Infile must be initilized in ReadBodyNames files->Outfile[iBody].cOut = NULL; + for (iOption=0;iOptionOutfile[iBody].caGrid[iOption] = NULL; + } } } @@ -299,8 +303,12 @@ void WriteDescription(char cLongDescr[], char cDescr[], int iMaxChars) { char **cLine; cLine = malloc(MAXARRAY * sizeof(char *)); + for (iWord=0;iWordiTime, cTmp); // strcat(cUnit, cTmp); - fvFormattedString(cUnit, cUnitLength, "^2/", cUnitTime); + fvFormattedString(cUnit, "%s^2/%s",cUnitLength,cUnitTime); free(cUnitLength); free(cUnitTime); } diff --git a/src/distorb.c b/src/distorb.c index 08103523c..efd06900c 100644 --- a/src/distorb.c +++ b/src/distorb.c @@ -476,7 +476,6 @@ double fndCalcLongA(double dLongP, double dArgP) { void VerifyOrbitModel(CONTROL *control, FILES *files, OPTIONS *options) { int iFile, iFound = 0; - char *cTmp; for (iFile = 0; iFile < files->iNumInputs; iFile++) { if (options[OPT_ORBITMODEL].iLine[iFile] >= 0) { @@ -499,6 +498,7 @@ void VerifyOrbitModel(CONTROL *control, FILES *files, OPTIONS *options) { } if (iFound == 0) { + char *cTmp; fvFormattedString(&cTmp, options[OPT_ORBITMODEL].cDefault); if (!memcmp(sLower(cTmp), "ll2", 3)) { control->Evolve.iDistOrbModel = LL2; @@ -513,8 +513,8 @@ void VerifyOrbitModel(CONTROL *control, FILES *files, OPTIONS *options) { /* Chicanery. Since I only want this set once, I will make it seem like the user set it. */ options[OPT_ORBITMODEL].iLine[0] = 1; + free(cTmp); } - free(cTmp); } diff --git a/src/eqtide.c b/src/eqtide.c index 66a90cb4a..12e18201e 100644 --- a/src/eqtide.c +++ b/src/eqtide.c @@ -1774,7 +1774,7 @@ void VerifyTideModel(CONTROL *control, FILES *files, OPTIONS *options) { } if (iFound == 0) { - char *cTmp; + char *cTmp=NULL; fvFormattedString(&cTmp, options[OPT_TIDEMODEL].cDefault); if (!memcmp(sLower(cTmp), "p2", 2)) { control->Evolve.iEqtideModel = CPL; diff --git a/src/flare.c b/src/flare.c index af6f14de1..624b47e0f 100644 --- a/src/flare.c +++ b/src/flare.c @@ -431,6 +431,7 @@ void InitializeOptionsFlare(OPTIONS *options, fnReadOption fnRead[]) { options[OPT_FLAREYINT].bMultiFile = 1; options[OPT_FLAREYINT].dNeg = 1.0 / DAYSEC; fvFormattedString(&options[OPT_FLAREYINT].cNeg, "1/day"); + fvFormattedString(&options[OPT_FLAREYINT].cDimension,"1/time"); fnRead[OPT_FLAREYINT] = &ReadFlareYInt; fvFormattedString(&options[OPT_FLAREYINT].cLongDescr, " Y-Intercept for flare frequency distribution. Where the curve " @@ -465,6 +466,7 @@ void InitializeOptionsFlare(OPTIONS *options, fnReadOption fnRead[]) { options[OPT_FLARESLOPE].bMultiFile = 1; options[OPT_FLARESLOPE].dNeg = 1.0 / (DAYSEC * log10(1.0e7)); fvFormattedString(&options[OPT_FLARESLOPE].cNeg, "1/day 1/log10(erg)"); + fvFormattedString(&options[OPT_FLARESLOPE].cDimension,"1/time/energy"); fnRead[OPT_FLARESLOPE] = &ReadFlareSlope; fvFormattedString( &options[OPT_FLARESLOPE].cLongDescr, @@ -501,6 +503,7 @@ void InitializeOptionsFlare(OPTIONS *options, fnReadOption fnRead[]) { options[OPT_FLAREMINENERGY].bMultiFile = 1; options[OPT_FLAREMINENERGY].dNeg = 1e-7; fvFormattedString(&options[OPT_FLAREMINENERGY].cNeg, "ergs"); + fvFormattedString(&options[OPT_FLAREMINENERGY].cDimension, "energy"); fnRead[OPT_FLAREMINENERGY] = &ReadFlareMinEnergy; fvFormattedString(&options[OPT_FLAREMAXENERGY].cName, "dFlareMaxEnergy"); @@ -512,6 +515,7 @@ void InitializeOptionsFlare(OPTIONS *options, fnReadOption fnRead[]) { options[OPT_FLAREMAXENERGY].bMultiFile = 1; options[OPT_FLAREMAXENERGY].dNeg = 1e-7; fvFormattedString(&options[OPT_FLAREMAXENERGY].cNeg, "ergs"); + fvFormattedString(&options[OPT_FLAREMAXENERGY].cDimension, "energy"); fnRead[OPT_FLAREMAXENERGY] = &ReadFlareMaxEnergy; fvFormattedString(&options[OPT_LXUVFLARECONST].cName, "dLXUVFlareConst"); @@ -537,6 +541,7 @@ void InitializeOptionsFlare(OPTIONS *options, fnReadOption fnRead[]) { options[OPT_FLAREENERGYBIN].bMultiFile = 1; options[OPT_FLAREENERGYBIN].dNeg = 1; fvFormattedString(&options[OPT_FLAREENERGYBIN].cNeg, "None"); + fvFormattedString(&options[OPT_FLAREENERGYBIN].cDimension,"energy"); fnRead[OPT_FLAREENERGYBIN] = &ReadFlareEnergyBin; fvFormattedString(&options[OPT_FLAREFFD].cName, "sFlareFFD"); diff --git a/src/options.c b/src/options.c index e01290e2e..99cd583ee 100644 --- a/src/options.c +++ b/src/options.c @@ -2669,13 +2669,16 @@ void ReadCosObl(BODY *body, CONTROL *control, FILES *files, OPTIONS *options, void ReadOutputOrder(FILES *files, MODULE *module, OPTIONS *options, OUTPUT *output, int iFile, int iVerbose) { - int i, j, count, iLen, iNumIndices = 0, bNeg[MAXARRAY], ok = 1, iNumGrid = 0; + int i, j, count, iLen, iNumIndices = 0, bNeg[MAXARRAY], ok = 1, iNumGrid = 0,iOption; int k, iOut = -1, *lTmp, iCol, jCol; char **saTmp, *cTmp = NULL, **cOption, *cOut; int iLen1, iLen2; lTmp = malloc(MAXLINES * sizeof(int)); cOption = malloc(MAXARRAY * sizeof(char *)); + for (iOption=0;iOptionInfile[iFile].cIn, options[OPT_OUTPUTORDER].cName, &saTmp, &iNumIndices, &files->Infile[iFile].iNumLines, @@ -2875,13 +2878,16 @@ void ReadOutputOrder(FILES *files, MODULE *module, OPTIONS *options, void ReadGridOutput(FILES *files, OPTIONS *options, OUTPUT *output, int iFile, int iVerbose) { - int i, j, count, iLen, iNumIndices = 0, bNeg[MAXARRAY], ok = 0, iNumGrid = 0; + int i, j, count, iLen, iNumIndices = 0, bNeg[MAXARRAY], ok = 0, iNumGrid = 0,iOption; int k, iOut = -1, *lTmp; - char **saTmp, *cTmp, **cOption, *cOut; + char **saTmp, *cTmp=NULL, **cOption, *cOut; int iLen1, iLen2; lTmp = malloc(MAXLINES * sizeof(int)); cOption = malloc(MAXARRAY * sizeof(char *)); + for (iOption=0;iOptionInfile[iFile].cIn, options[OPT_GRIDOUTPUT].cName, &saTmp, &iNumIndices, &files->Infile[iFile].iNumLines, @@ -2909,9 +2915,9 @@ void ReadGridOutput(FILES *files, OPTIONS *options, OUTPUT *output, int iFile, /* Check for ambiguity */ for (i = 0; i < iNumIndices; i++) { count = 0; /* Number of possibilities */ - for (j = 0; j < OPTLEN; j++) { - cTmp[j] = 0; - } + // for (j = 0; j < OPTLEN; j++) { + // cTmp[j] = 0; + // } fvFormattedString(&cTmp, saTmp[i]); for (j = 0; j < MODULEOUTEND; j++) { for (k = 0; k < OPTLEN; k++) { @@ -2930,7 +2936,7 @@ void ReadGridOutput(FILES *files, OPTIONS *options, OUTPUT *output, int iFile, if (output[j].bGrid == 1 || output[j].bGrid == 2) { iNumGrid += 1; } - j = MODULEOUTEND; /* Poor man's break! */ + j = MODULEOUTEND; /* Break! */ } else { if (iLen1 < iLen2) { iLen = iLen1; @@ -3001,7 +3007,7 @@ void ReadGridOutput(FILES *files, OPTIONS *options, OUTPUT *output, int iFile, fvFormattedString(&files->Outfile[iFile - 1].caCol[i], output[iOut].cName); } else { - memset(files->Outfile[iFile - 1].caGrid[iNumGrid - 1], '\0', OPTLEN); + //memset(files->Outfile[iFile - 1].caGrid[iNumGrid - 1], '\0', OPTLEN); fvFormattedString(&files->Outfile[iFile - 1].caGrid[iNumGrid - 1], output[iOut].cName); } @@ -3016,6 +3022,8 @@ void ReadGridOutput(FILES *files, OPTIONS *options, OUTPUT *output, int iFile, files->Outfile[iFile - 1].iNumGrid = iNumGrid; free(lTmp); + free(cTmp); + free(cOption); } void ReadOverwrite(BODY *body, CONTROL *control, FILES *files, OPTIONS *options, diff --git a/src/output.c b/src/output.c index 652bb1cc0..fef08f119 100644 --- a/src/output.c +++ b/src/output.c @@ -2218,7 +2218,7 @@ void WriteOutput(BODY *body, CONTROL *control, FILES *files, OUTPUT *output, int iBody, iCol, iOut, iSubOut, iExtra = 0, iGrid, iLat, jBody, j; double dCol[NUMOPT], *dTmp, dGrid[NUMOPT]; FILE *fp; - char *cUnit, *cPoiseGrid, *cLaplaceFunc; + char *cUnit, *cPoiseGrid=NULL, *cLaplaceFunc; /* Write out all data columns for each body. As some data may span more than 1 column, we search the input list sequentially, adding iExtra to the diff --git a/src/poise.c b/src/poise.c index eb0230cee..612a4b998 100644 --- a/src/poise.c +++ b/src/poise.c @@ -1153,6 +1153,7 @@ void InitializeOptionsPoise(OPTIONS *options, fnReadOption fnRead[]) { fvFormattedString(&options[OPT_PLANCKA].cName, "dPlanckA"); fvFormattedString(&options[OPT_PLANCKA].cDescr, "Constant 'A' used in OLR calculation"); fvFormattedString(&options[OPT_PLANCKA].cDefault, "203.3"); + fvFormattedString(&options[OPT_PLANCKA].cDimension, "nd"); options[OPT_PLANCKA].dDefault = 203.3; options[OPT_PLANCKA].iType = 2; options[OPT_PLANCKA].bMultiFile = 1; @@ -3331,7 +3332,7 @@ void WriteDailyInsol(BODY *body, CONTROL *control, OUTPUT *output, SYSTEM *system, UNITS *units, UPDATE *update, int iBody, double *dTmp, char **cUnit) { - char *cOut; + char *cOut=NULL; FILE *fp; int iLat, iDay; double dTime; @@ -3378,13 +3379,14 @@ void WriteDailyInsol(BODY *body, CONTROL *control, OUTPUT *output, } fclose(fp); + free(cOut); } void WritePlanckB(BODY *body, CONTROL *control, OUTPUT *output, SYSTEM *system, UNITS *units, UPDATE *update, int iBody, double *dTmp, char **cUnit) { - char *cOut; + char *cOut=NULL; FILE *fp; int iLat, iDay; double dTime; @@ -3432,13 +3434,14 @@ void WritePlanckB(BODY *body, CONTROL *control, OUTPUT *output, SYSTEM *system, } fclose(fp); + free(cOut); } void WriteSeasonalTemp(BODY *body, CONTROL *control, OUTPUT *output, SYSTEM *system, UNITS *units, UPDATE *update, int iBody, double *dTmp, char **cUnit) { - char *cOut; + char *cOut=NULL; FILE *fp; int iLat, iDay; double dTime; @@ -3488,13 +3491,14 @@ void WriteSeasonalTemp(BODY *body, CONTROL *control, OUTPUT *output, } fclose(fp); + free(cOut); } void WriteSeasonalFluxes(BODY *body, CONTROL *control, OUTPUT *output, SYSTEM *system, UNITS *units, UPDATE *update, int iBody, double *dTmp, char **cUnit) { - char *cOutM, *cOutI, *cOutO, *cOutD; + char *cOutM=NULL, *cOutI=NULL, *cOutO=NULL, *cOutD=NULL; FILE *fpM, *fpI, *fpO, *fpD; int iLat, iDay; double dTime; @@ -3584,13 +3588,17 @@ void WriteSeasonalFluxes(BODY *body, CONTROL *control, OUTPUT *output, fclose(fpI); fclose(fpO); fclose(fpD); + free(cOutM); + free(cOutI); + free(cOutO); + free(cOutD); } void WriteSeasonalIceBalance(BODY *body, CONTROL *control, OUTPUT *output, SYSTEM *system, UNITS *units, UPDATE *update, int iBody, double *dTmp, char **cUnit) { - char *cOut; + char *cOut=NULL; FILE *fp; int iLat, iDay; double dTime; @@ -3637,6 +3645,7 @@ void WriteSeasonalIceBalance(BODY *body, CONTROL *control, OUTPUT *output, } fclose(fp); + free(cOut); } void WriteFluxMerid(BODY *body, CONTROL *control, OUTPUT *output, diff --git a/src/vplanet.c b/src/vplanet.c index a01014b61..184a4f284 100644 --- a/src/vplanet.c +++ b/src/vplanet.c @@ -29,7 +29,6 @@ We need this wrapper so we can call `main_impl` from Python. int main_impl(int argc, char *argv[]) { #ifdef DEBUG #ifdef __x86_64__ - // feenableexcept(FE_INVALID | FE_OVERFLOW); _MM_SET_EXCEPTION_MASK(_MM_GET_EXCEPTION_MASK() & ~_MM_MASK_INVALID); _MM_SET_EXCEPTION_MASK(_MM_GET_EXCEPTION_MASK() & ~_MM_MASK_OVERFLOW); _MM_SET_EXCEPTION_MASK(_MM_GET_EXCEPTION_MASK() & ~_MM_MASK_DIV_ZERO); diff --git a/tests/Help/test_Help.py b/tests/Help/test_Help.py index 747282a00..3b6394506 100644 --- a/tests/Help/test_Help.py +++ b/tests/Help/test_Help.py @@ -7,7 +7,7 @@ def test_Help(): try: - subprocess.check_output("bin/vplanet -H", shell=True) + subprocess.check_output("../../bin/vplanet -H", shell=True) except subprocess.CalledProcessError: raise ValueError(f"Long help failed") else: