Skip to content

Commit

Permalink
fix all remaining variable array warnings except in error loggging
Browse files Browse the repository at this point in the history
  • Loading branch information
nip5 committed Feb 19, 2019
1 parent e544432 commit 2369858
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion SW_Defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ extern "C" {
#define swPI2 6.28318530717958
#define BARCONV 1024.
#define SEC_PER_DAY 86400. // the # of seconds in a day... (24 hrs * 60 mins/hr * 60 sec/min = 86400 seconds)

#define OVER_SIZE 999 // initialize (double) arrays to a size bigger than possible access

//was 256 & 1024...
#define MAX_FILENAMESIZE 512
Expand Down
17 changes: 10 additions & 7 deletions SW_Flow_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

#include <string.h>
#include "generic.h"
#include "filefuncs.h"
#include "SW_Defines.h"
Expand Down Expand Up @@ -282,7 +282,7 @@ void infiltrate_water_high(double swc[], double drain[], double *drainout, doubl

int i;
int j;
double d[nlyrs];
double d[OVER_SIZE];
double push, ksat_rel;

ST_RGR_VALUES *st = &stValues;
Expand Down Expand Up @@ -982,7 +982,7 @@ void infiltrate_water_low(double swc[], double drain[], double *drainout, unsign

unsigned int i;
int j;
double drainlw = 0.0, swc_avail, drainpot, d[nlyrs], push, kunsat_rel ;
double drainlw = 0.0, swc_avail, drainpot, d[OVER_SIZE], push, kunsat_rel ;

ST_RGR_VALUES *st = &stValues;

Expand Down Expand Up @@ -1056,8 +1056,8 @@ void hydraulic_redistribution(double swc[], double swcwp[], double lyrRootCo[],
**********************************************************************/

unsigned int i, j;
double swp[nlyrs], swpwp[nlyrs], relCondroot[nlyrs], hydredmat[nlyrs][nlyrs], Rx, swa,
hydred_sum, x;
double swp[OVER_SIZE], swpwp[OVER_SIZE], relCondroot[OVER_SIZE], hydredmat[OVER_SIZE][OVER_SIZE];
double Rx, swa, hydred_sum, x;


ST_RGR_VALUES *st = &stValues;
Expand Down Expand Up @@ -1214,7 +1214,8 @@ void lyrSoil_to_lyrTemp_temperature(unsigned int nlyrSoil, double depth_Soil[],
#ifdef SWDEBUG
int debug = 0;
#endif
double depth_Soil2[nlyrSoil + 1], sTemp2[nlyrSoil + 1];
double depth_Soil2[OVER_SIZE] = {0};
double sTemp2[OVER_SIZE] = {0};

//transfer data to include bottom conditions; do not include surface temperature in interpolations
for (i = 0; i < nlyrSoil; i++) {
Expand Down Expand Up @@ -1361,7 +1362,9 @@ void soil_temperature_init(double bDensity[], double width[], double oldsTemp[],
int debug = 0;
#endif
double d1 = 0.0, d2 = 0.0, acc = 0.0;
double fc_vwc[nlyrs], wp_vwc[nlyrs];
// double fc_vwc[nlyrs], wp_vwc[nlyrs];
double fc_vwc[OVER_SIZE] = {0};
double wp_vwc[OVER_SIZE] = {0};

// pointers
ST_RGR_VALUES *st = &stValues; // just for convenience, so I don't have to type as much
Expand Down
5 changes: 2 additions & 3 deletions SW_SoilWater.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,10 +483,9 @@ void get_dSWAbulk(int i){
float crit_val, prev_crit_val, smallestCritVal, vegFractionSum, newFraction;
float veg_type_in_use; // set to current veg type fraction value to avoid multiple if loops. should just need 1 instead of 3 now.
float inner_loop_veg_type; // set to inner loop veg type
int array_size = NVEGTYPES * NVEGTYPES;
smallestCritVal = SW_VegProd.critSoilWater[SW_VegProd.rank_SWPcrits[0]];
RealF dSWA_bulk[array_size][array_size][MAX_LAYERS];
RealF dSWA_bulk_repartioned[array_size][array_size][MAX_LAYERS];
RealF dSWA_bulk[NVEGTYPES * NVEGTYPES][NVEGTYPES * NVEGTYPES][MAX_LAYERS];
RealF dSWA_bulk_repartioned[NVEGTYPES * NVEGTYPES][NVEGTYPES * NVEGTYPES][MAX_LAYERS];

// need to initialize to 0
for(curr_vegType = 0; curr_vegType < NVEGTYPES; curr_vegType++){
Expand Down

0 comments on commit 2369858

Please sign in to comment.