forked from jhamman/DHSVM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
InitAggregated.c
executable file
·66 lines (53 loc) · 2.18 KB
/
InitAggregated.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* SUMMARY: InitAggregated.c - Initialize basin-wide values
* USAGE: Part of DHSVM
*
* AUTHOR: Bart Nijssen
* ORG: University of Washington, Department of Civil Engineering
* E-MAIL: [email protected]
* ORIG-DATE: Apr-96
* DESCRIPTION: Initialize basin-wide values
* DESCRIP-END.
* FUNCTIONS: InitAggregated()
* COMMENTS:
* $Id: InitAggregated.c,v 1.4 2003/07/01 21:26:15 olivier Exp $
*/
#include <stdio.h>
#include <stdlib.h>
#include "settings.h"
#include "data.h"
#include "DHSVMerror.h"
#include "functions.h"
#include "constants.h"
/*****************************************************************************
InitAggregated()
Allocates memory for the structure that will hold basin total and/or basin
average values
*****************************************************************************/
void InitAggregated(int MaxVegLayers, int MaxSoilLayers, AGGREGATED * Total)
{
int i; /* counter */
if (!(Total->Evap.EPot = (float *) calloc(MaxVegLayers + 1, sizeof(float))))
ReportError("InitAggregated()", 1);
if (!(Total->Evap.EAct = (float *) calloc(MaxVegLayers + 1, sizeof(float))))
ReportError("InitAggregated()", 1);
if (!(Total->Evap.EInt = (float *) calloc(MaxVegLayers, sizeof(float))))
ReportError("InitAggregated()", 1);
if (!(Total->Evap.ESoil = (float **) calloc(MaxVegLayers, sizeof(float *))))
ReportError("InitAggregated()", 1);
for (i = 0; i < MaxVegLayers; i++) {
if (!(Total->Evap.ESoil[i] =
(float *) calloc(MaxSoilLayers, sizeof(float))))
ReportError("InitAggregated()", 1);
}
if (!(Total->Precip.IntRain = (float *) calloc(MaxVegLayers, sizeof(float))))
ReportError("InitAggregated()", 1);
if (!(Total->Precip.IntSnow = (float *) calloc(MaxVegLayers, sizeof(float))))
ReportError("InitAggregated()", 1);
if (!(Total->Soil.Moist = (float *) calloc(MaxSoilLayers + 1, sizeof(float))))
ReportError("InitAggregated()", 1);
if (!(Total->Soil.Perc = (float *) calloc(MaxSoilLayers, sizeof(float))))
ReportError("InitAggregated()", 1);
if (!(Total->Soil.Temp = (float *) calloc(MaxSoilLayers, sizeof(float))))
ReportError("InitAggregated()", 1);
}