Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/common/modelParams.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ void checkAllRead(ModelParams *ModelParams) {
}

if (!okay) {
exit(1);
logError("Some required parameters were not read from file\n");
exit(EXIT_CODE_INPUT_FILE_ERROR);
}
}

Expand Down Expand Up @@ -109,7 +110,7 @@ void initializeOneModelParam(ModelParams *modelParams, char *name,
"parameters\n",
name, modelParams->maxParams);
logError("Check value of maxParams passed into newModelParams function\n");
exit(1);
exit(EXIT_CODE_INTERNAL_ERROR);
}

// otherwise, get the index of the next uninitialized parameter
Expand Down Expand Up @@ -221,7 +222,7 @@ void readModelParams(ModelParams *modelParams, FILE *paramFile) {
if (ferror(paramFile)) {
logError("reading file in readModelParams\n");
logError("ferror = %d\n", ferror(paramFile));
exit(1);
exit(EXIT_CODE_FILE_OPEN_OR_READ_ERROR);
}

checkAllRead(modelParams); // terminate program if some required parameters
Expand Down
20 changes: 10 additions & 10 deletions src/sipnet/cli.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#include "cli.h"

#include "common/exitCodes.h"
Expand Down Expand Up @@ -127,11 +127,11 @@
break;
case 'f':
if (strlen(optarg) >= FILENAME_MAXLEN) {
printf("ERROR: filename %s exceeds maximum length of %d\n", optarg,
FILENAME_MAXLEN);
printf("Either change the name or increase INPUT_MAXNAME in "
"frontend.c\n");
exit(1);
logError("filename %s exceeds maximum length of %d\n", optarg,
FILENAME_MAXLEN);
logError("Either change the name or increase INPUT_MAXNAME in "
"frontend.c\n");
exit(EXIT_CODE_BAD_CLI_ARGUMENT);
}
updateCharContext("fileName", optarg, CTX_COMMAND_LINE);
break;
Expand All @@ -140,11 +140,11 @@
exit(EXIT_CODE_SUCCESS);
case 'i':
if (strlen(optarg) >= FILENAME_MAXLEN) {
printf("ERROR: input filename %s exceeds maximum length of %d\n",
optarg, FILENAME_MAXLEN);
printf("Either change the name or increase INPUT_MAXNAME in "
"frontend.c\n");
exit(1);
logError("input filename %s exceeds maximum length of %d\n",
optarg, FILENAME_MAXLEN);
logError("Either change the name or increase INPUT_MAXNAME in "
"frontend.c\n");
exit(EXIT_CODE_BAD_CLI_ARGUMENT);
}
updateCharContext("inputFile", optarg, CTX_COMMAND_LINE);
break;
Expand Down
2 changes: 1 addition & 1 deletion src/sipnet/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ EventNode *createEventNode(int year, int day, int eventType,
default:
// Unknown type, error and exit
logError("reading newEvent file: unknown newEvent type %d\n", eventType);
exit(1);
exit(EXIT_CODE_UNKNOWN_EVENT_TYPE_OR_PARAM);
}

newEvent->nextEvent = NULL;
Expand Down
9 changes: 5 additions & 4 deletions src/sipnet/outputItems.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <stdlib.h>
#include "outputItems.h"
#include "common/util.h"
#include "common/logging.h"
#include "common/exitCodes.h"

// Private/helper functions: not defined in outputItems.h:

Expand All @@ -19,10 +21,9 @@ SingleOutputItem *newSingleOutputItem(char *name, double *ptr) {
SingleOutputItem *singleOutputItem;

if (strlen(name) >= OUTPUT_ITEMS_MAXNAME) {
printf("ERROR in newSingleOutputItem: name '%s' exceeds maximum length of "
"%d\n",
name, OUTPUT_ITEMS_MAXNAME);
exit(1);
logError("newSingleOutputItem: name '%s' exceeds maximum length of %d\n",
name, OUTPUT_ITEMS_MAXNAME);
exit(EXIT_CODE_INTERNAL_ERROR);
}

singleOutputItem = (SingleOutputItem *)malloc(sizeof(SingleOutputItem));
Expand Down
26 changes: 13 additions & 13 deletions src/sipnet/sipnet.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/* SIPNET: Simplified PnET

Author: Bill Sacks wsacks@wisc.edu
Expand Down Expand Up @@ -1588,24 +1588,24 @@
err = addValueToMeanTracker(meanNPP, npp, climate->length); // update running
// mean of NPP
if (err != 0) {
printf("******* Error type %d while trying to add value to NPP mean "
"tracker in sipnet:updateState() *******\n",
err);
printf("npp = %f, climate->length = %f\n", npp, climate->length);
printf("Suggestion: try changing MEAN_NPP_MAX_ENTRIES in sipnet.c\n");
exit(1);
logError("Error type %d while trying to add value to NPP mean tracker in "
"sipnet:updateMeanTrackers()\n",
err);
logError("npp = %f, climate->length = %f\n", npp, climate->length);
logError("Suggestion: try changing MEAN_NPP_MAX_ENTRIES in sipnet.c\n");
exit(EXIT_CODE_INTERNAL_ERROR);
}

err = addValueToMeanTracker(meanGPP, fluxes.photosynthesis,
climate->length); // update running mean of GPP
if (err != 0) {
printf("******* Error type %d while trying to add value to GPP mean "
"tracker in sipnet:updateState() *******\n",
err);
printf("GPP = %f, climate->length = %f\n", fluxes.photosynthesis,
climate->length);
printf("Suggestion: try changing MEAN_GPP_SOIL_MAX_ENTRIES in sipnet.c\n");
exit(1);
logError("Error type %d while trying to add value to GPP mean tracker in "
"sipnet:updateMeanTrackers()\n",
err);
logError("GPP = %f, climate->length = %f\n", fluxes.photosynthesis,
climate->length);
logError("Suggestion: try changing MEAN_GPP_SOIL_MAX_ENTRIES in sipnet.c\n");
exit(EXIT_CODE_INTERNAL_ERROR);
}
}

Expand Down
Loading