Skip to content

Commit

Permalink
Code now compiles and one test simulation passes!
Browse files Browse the repository at this point in the history
  • Loading branch information
Rory Barnes committed Aug 8, 2024
1 parent 49bd690 commit 04465da
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
18 changes: 9 additions & 9 deletions src/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,7 @@ void fsUnitsAngMom(UNITS *units, char **cUnit) {
// strcat(cUnit, "^2/");
// fsUnitsTime(units->iTime, cTmp);
// strcat(cUnit, cTmp);
fvFormattedString(cUnit, cUnitMass, "*", cUnitLength, "^2/", cUnitTime);
fvFormattedString(cUnit, "%s*%s^2/%s", cUnitMass, cUnitLength, cUnitTime);
free(cUnitMass);
free(cUnitLength);
free(cUnitTime);
Expand All @@ -1079,7 +1079,7 @@ void fsUnitsDensity(UNITS *units, char **cUnit) {
// strcat(cUnit, "^3");
fsUnitsMass(units->iMass, &cUnitMass);
fsUnitsLength(units->iLength, &cUnitLength);
fvFormattedString(cUnit, cUnitMass, "/", cUnitLength, "^3");
fvFormattedString(cUnit, "%s/%s^3",cUnitMass, cUnitLength);
free(cUnitMass);
free(cUnitLength);
}
Expand All @@ -1093,7 +1093,7 @@ void fsUnitsVel(UNITS *units, char **cUnit) {
// strcat(cUnit, cTmp);
fsUnitsLength(units->iLength, &cUnitLength);
fsUnitsTime(units->iTime, &cUnitTime);
fvFormattedString(cUnit, cUnitLength, "/", cUnitTime);
fvFormattedString(cUnit, "%s/%s", cUnitLength, cUnitTime);
free(cUnitTime);
free(cUnitLength);
}
Expand All @@ -1105,7 +1105,7 @@ void fsUnitsRate(int iType, char **cUnit) {
// fsUnitsTime(iType, cTmp);
// strcat(cUnit, cTmp);
fsUnitsTime(iType, &cUnitTime);
fvFormattedString(cUnit, "/", cUnitTime);
fvFormattedString(cUnit, "/%s", cUnitTime);
free(cUnitTime);
}

Expand All @@ -1116,7 +1116,7 @@ void fsUnitsRateSquared(int iType, char **cUnit) {
// fsUnitsTime(iType, cTmp);
// strcat(cUnit, cTmp);
fsUnitsTime(iType, &cUnitTime);
fvFormattedString(cUnit, "/", cUnitTime, "^2");
fvFormattedString(cUnit, "/%s^2", cUnitTime);
free(cUnitTime);
}

Expand All @@ -1134,7 +1134,7 @@ void fsUnitsAngRate(UNITS *units, char **cUnit) {
// strcat(cUnit, cTmp);
fsUnitsAngle(units->iAngle, &cUnitAngle);
fsUnitsTime(units->iTime, &cUnitTime);
fvFormattedString(cUnit, cUnitAngle, "/", cUnitTime);
fvFormattedString(cUnit, "%s/%s", cUnitAngle, cUnitTime);
free(cUnitTime);
free(cUnitAngle);
}
Expand All @@ -1154,7 +1154,7 @@ void fsUnitsEnergy(UNITS *units, char **cUnit) {
// fsUnitsTime(units->iTime, cTmp);
// strcat(cUnit, cTmp);
// strcat(cUnit, "^2");
fvFormattedString(cUnit, cUnitMass, "*", cUnitLength, "^2/", cUnitTime, "^2");
fvFormattedString(cUnit, "%s*%s^2/%s^2", cUnitMass, cUnitLength, cUnitTime);
free(cUnitMass);
free(cUnitLength);
free(cUnitTime);
Expand Down Expand Up @@ -1182,7 +1182,7 @@ void fsUnitsPower(UNITS *units, char **cUnit) {
// fsUnitsTime(units->iTime, cTmp);
// strcat(cUnit, cTmp);
// strcat(cUnit, "^3");
fvFormattedString(cUnit, cUnitMass, "*", cUnitLength, "^2/", cUnitTime, "^3");
fvFormattedString(cUnit, "%s*%s^2/%s^3", cUnitMass, cUnitLength, cUnitTime);
free(cUnitMass);
free(cUnitLength);
free(cUnitTime);
Expand All @@ -1208,7 +1208,7 @@ void fsUnitsEnergyFlux(UNITS *units, char **cUnit) {
// fsUnitsTime(units->iTime, cTmp);
// strcat(cUnit, cTmp);
// strcat(cUnit, ")");
fvFormattedString(cUnit, cUnitMass, "/", cUnitTime, "^3");
fvFormattedString(cUnit, "%s/%s^3", cUnitMass, cUnitTime);
}

double fdUnitsEnergyFlux(int iTime, int iMass, int iLength) {
Expand Down
14 changes: 9 additions & 5 deletions src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ double dNegativeDouble(OPTIONS options, char cFile[], int iVerbose) {
void AddOptionStringArray(char *cFile, char *cOption, char ***saInput,
int *iNumIndices, int *iNumLines, int *iLine,
int iVerbose) {
char *cLine, cTmp[MAXARRAY][OPTLEN];
char *cLine, cTmp[MAXARRAY][OPTLEN], **saInputCopy;
int iPos, iWord, bContinue, iNumWords;
FILE *fp;

Expand All @@ -270,13 +270,18 @@ void AddOptionStringArray(char *cFile, char *cOption, char ***saInput,
GetLine(cFile, cOption, &cLine, &iLine[0], iVerbose);
GetWords(cLine, cTmp, &iNumWords, &bContinue);
*iNumLines = 1;
*saInput = malloc(MAXARRAY * sizeof(char *));
*saInput = (char **)malloc((iNumWords-1) * sizeof(char *));

for (iWord = 0; iWord < iNumWords - 1; iWord++) {
(*saInput)[iWord] = NULL;
}
saInputCopy = *saInput;

for (iWord = 0; iWord < iNumWords - 1; iWord++) {
*saInput[iWord] = NULL;
// memset(saInput[iWord], '\0', OPTLEN);

fvFormattedString(saInput[iWord], cTmp[iWord + 1]);
//fvFormattedString(saInput[iWord], cTmp[iWord + 1]);
fvFormattedString(&saInputCopy[iWord], cTmp[iWord + 1]);
/* Reset cTmp string: If the next time cTmp is filled, the
new string is longer than the old, then vestigial characters
can remain after a trailing $. */
Expand Down Expand Up @@ -1116,7 +1121,6 @@ void ReadSystemName(CONTROL *control, FILES *files, OPTIONS *options,
int lTmp = -1;
char cTmp[OPTLEN];

system->cName = NULL;
AddOptionString(files->Infile[iFile].cIn, options->cName, cTmp, &lTmp,
control->Io.iVerbose);
if (lTmp >= 0) {
Expand Down
6 changes: 3 additions & 3 deletions src/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -2008,9 +2008,9 @@ void LogOutputOrder(BODY *body, CONTROL *control, FILES *files, OUTPUT *output,
SYSTEM *system, UPDATE *update, fnWriteOutput fnWrite[],
FILE *fp, int iBody) {
int iCol, iOut, iSubOut, iExtra = 0;
char **cCol; // +2 for brackets
char **cCol;
double *dTmp;
char *cUnit=NULL, *cTmp;
char *cUnit=NULL, *cTmp=NULL;

cCol=malloc(MODULEOUTEND*sizeof(char*));
for (iCol = 0; iCol < files->Outfile[iBody].iNumCols; iCol++) {
Expand Down Expand Up @@ -2172,7 +2172,7 @@ void LogBody(BODY *body, CONTROL *control, FILES *files, MODULE *module,
void WriteLog(BODY *body, CONTROL *control, FILES *files, MODULE *module,
OPTIONS *options, OUTPUT *output, SYSTEM *system, UPDATE *update,
fnUpdateVariable ***fnUpdate, fnWriteOutput fnWrite[], int iEnd) {
char *cTime;
char *cTime=NULL;
FILE *fp;
double dTotTime;

Expand Down
2 changes: 2 additions & 0 deletions src/vplanet.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ int main_impl(int argc, char *argv[]) {
fvFormattedString(&control.sGitVersion, "Unknown");
#endif

system.cName=NULL;

/** Must initialize all options and outputs for all modules
independent of what is selected. This allows a complete
help screen as well as checks during ReadOptions. This
Expand Down

0 comments on commit 04465da

Please sign in to comment.