Skip to content

Commit a0a57a6

Browse files
committed
Fixes (some) formatting issues
1 parent 8b03f77 commit a0a57a6

File tree

1 file changed

+61
-63
lines changed

1 file changed

+61
-63
lines changed

sipnet.c

Lines changed: 61 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2282,47 +2282,47 @@ void updateTrackers(double oldSoilWater) {
22822282
// Process events for current location/year/day
22832283
void processEvents() {
22842284
#if EVENT_HANDLER
2285-
// If locEvent starts off NULL, this function will just fall through, as it should.
2286-
const int year = climate->year;
2287-
const int day = climate->day;
2288-
2289-
// The events file has been tested on read, so we know this event list should be in chrono
2290-
// order. However, we need to check to make sure the current event is not in the past, as
2291-
// that would indicate an event that did not have a corresponding climate file record.
2292-
while (locEvent != NULL && locEvent->year <= year && locEvent->day <= day) {
2293-
if (locEvent->year < year || locEvent->day < day) {
2294-
printf("Agronomic event found for loc: %d year: %d day: %d that does not have a corresponding record in the climate file\n", locEvent->year, locEvent->year, locEvent->day);
2295-
exit(1);
2296-
}
2297-
switch (locEvent->type) {
2298-
// Implementation TBD, as we enable the various event types
2299-
case IRRIGATION:
2300-
// TBD
2301-
printf("Irrigation events not yet implemented\n");
2302-
break;
2303-
case PLANTING:
2304-
// TBD
2305-
printf("Planting events not yet implemented\n");
2306-
break;
2307-
case HARVEST:
2308-
// TBD
2309-
printf("Harvest events not yet implemented\n");
2310-
break;
2311-
case TILLAGE:
2312-
// TBD
2313-
printf("Tillage events not yet implemented\n");
2314-
break;
2315-
case FERTILIZATION:
2316-
// TBD
2317-
printf("Fertilization events not yet implemented\n");
2318-
break;
2319-
default:
2320-
printf("Unknown event type (%d) in processEvents()\n", locEvent->type);
2321-
exit(1);
2322-
}
2285+
// If locEvent starts off NULL, this function will just fall through, as it should.
2286+
const int year = climate->year;
2287+
const int day = climate->day;
2288+
2289+
// The events file has been tested on read, so we know this event list should be in chrono
2290+
// order. However, we need to check to make sure the current event is not in the past, as
2291+
// that would indicate an event that did not have a corresponding climate file record.
2292+
while (locEvent != NULL && locEvent->year <= year && locEvent->day <= day) {
2293+
if (locEvent->year < year || locEvent->day < day) {
2294+
printf("Agronomic event found for loc: %d year: %d day: %d that does not have a corresponding record in the climate file\n", locEvent->year, locEvent->year, locEvent->day);
2295+
exit(1);
2296+
}
2297+
switch (locEvent->type) {
2298+
// Implementation TBD, as we enable the various event types
2299+
case IRRIGATION:
2300+
// TBD
2301+
printf("Irrigation events not yet implemented\n");
2302+
break;
2303+
case PLANTING:
2304+
// TBD
2305+
printf("Planting events not yet implemented\n");
2306+
break;
2307+
case HARVEST:
2308+
// TBD
2309+
printf("Harvest events not yet implemented\n");
2310+
break;
2311+
case TILLAGE:
2312+
// TBD
2313+
printf("Tillage events not yet implemented\n");
2314+
break;
2315+
case FERTILIZATION:
2316+
// TBD
2317+
printf("Fertilization events not yet implemented\n");
2318+
break;
2319+
default:
2320+
printf("Unknown event type (%d) in processEvents()\n", locEvent->type);
2321+
exit(1);
2322+
}
23232323

2324-
locEvent = locEvent->nextEvent;
2325-
}
2324+
locEvent = locEvent->nextEvent;
2325+
}
23262326
#endif
23272327
}
23282328

@@ -2332,7 +2332,7 @@ void processEvents() {
23322332
// calculate all fluxes and update state for this time step
23332333
// we calculate all fluxes before updating state in case flux calculations depend on the old state
23342334
void updateState() {
2335-
double npp; // net primary productivity, g C * m^-2 ground area * day^-1
2335+
double npp; // net primary productivity, g C * m^-2 ground area * day^-1
23362336
double oldSoilWater; // how much soil water was there before we updated it? Used in trackers
23372337
int err;
23382338
oldSoilWater = envi.soilWater;
@@ -2341,40 +2341,39 @@ void updateState() {
23412341

23422342
// update the stocks, with fluxes adjusted for length of time step:
23432343
envi.plantWoodC += (fluxes.photosynthesis + fluxes.woodCreation - fluxes.leafCreation - fluxes.woodLitter
2344-
- fluxes.rVeg-fluxes.coarseRootCreation-fluxes.fineRootCreation)* climate->length;
2344+
- fluxes.rVeg-fluxes.coarseRootCreation-fluxes.fineRootCreation)* climate->length;
23452345
envi.plantLeafC += (fluxes.leafCreation - fluxes.leafLitter) * climate->length;
23462346

2347-
soilDegradation(); // This updates all the soil functions
2347+
soilDegradation(); // This updates all the soil functions
23482348

2349-
#if MODEL_WATER // water pool updating happens here:
2349+
#if MODEL_WATER // water pool updating happens here:
23502350

2351-
#if LITTER_WATER // (2 soil water layers; litter water will only be on if complex water is also on)
2352-
envi.litterWater += (fluxes.rain + fluxes.snowMelt - fluxes.immedEvap - fluxes.fastFlow
2353-
- fluxes.evaporation - fluxes.topDrainage) * climate->length;
2354-
envi.soilWater += (fluxes.topDrainage - fluxes.transpiration - fluxes.bottomDrainage)
2355-
* climate->length;
2351+
#if LITTER_WATER // (2 soil water layers; litter water will only be on if complex water is also on)
2352+
envi.litterWater += (fluxes.rain + fluxes.snowMelt - fluxes.immedEvap - fluxes.fastFlow
2353+
- fluxes.evaporation - fluxes.topDrainage) * climate->length;
2354+
envi.soilWater += (fluxes.topDrainage - fluxes.transpiration - fluxes.bottomDrainage)
2355+
* climate->length;
23562356

2357-
#else // LITTER_WATER = 0 (only one soil water layer)
2358-
// note: some of these fluxes will always be 0 if complex water is off
2359-
envi.soilWater += (fluxes.rain + fluxes.snowMelt - fluxes.immedEvap - fluxes.fastFlow
2360-
- fluxes.evaporation - fluxes.transpiration - fluxes.bottomDrainage) * climate->length;
2361-
#endif // LITTER_WATER
2357+
#else // LITTER_WATER = 0 (only one soil water layer)
2358+
// note: some of these fluxes will always be 0 if complex water is off
2359+
envi.soilWater += (fluxes.rain + fluxes.snowMelt - fluxes.immedEvap - fluxes.fastFlow
2360+
- fluxes.evaporation - fluxes.transpiration - fluxes.bottomDrainage) * climate->length;
2361+
#endif // LITTER_WATER
23622362

2363-
// if COMPLEX_WATER = 0 or SNOW = 0, some or all of these fluxes will always be 0
2364-
envi.snow += (fluxes.snowFall - fluxes.snowMelt - fluxes.sublimation) * climate->length;
2363+
// if COMPLEX_WATER = 0 or SNOW = 0, some or all of these fluxes will always be 0
2364+
envi.snow += (fluxes.snowFall - fluxes.snowMelt - fluxes.sublimation) * climate->length;
23652365

2366-
#endif // MODEL_WATER
2366+
#endif // MODEL_WATER
23672367

23682368
ensureNonNegativeStocks();
23692369

23702370
#if EVENT_HANDLER
2371-
// Process events for this location/year/day, AFTER updates are made to fluxes and state
2372-
// variables above. Events are (currently, Jan 25) handled as instantaneous deltas to
2373-
// relevant state (envi and fluxes fields),
2374-
processEvents();
2371+
// Process events for this location/year/day, AFTER updates are made to fluxes and state
2372+
// variables above. Events are (currently, Jan 25) handled as instantaneous deltas to
2373+
// relevant state (envi and fluxes fields),
2374+
processEvents();
23752375
#endif
23762376

2377-
23782377
npp = fluxes.photosynthesis - fluxes.rVeg-fluxes.rCoarseRoot-fluxes.rFineRoot;
23792378

23802379
err = addValueToMeanTracker(meanNPP, npp, climate->length); // update running mean of NPP
@@ -2394,7 +2393,6 @@ void updateState() {
23942393
}
23952394

23962395
updateTrackers(oldSoilWater);
2397-
23982396
}
23992397

24002398

0 commit comments

Comments
 (0)