-
Notifications
You must be signed in to change notification settings - Fork 0
/
func_atmos_energy_bal.c
47 lines (34 loc) · 1.27 KB
/
func_atmos_energy_bal.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
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <vicNl.h>
static char vcid[] = "$Id$";
double func_atmos_energy_bal(double Tcanopy, va_list ap) {
/**********************************************************************
func_atmos_energy_bal.c Keith Cherkauer February 6, 2001
This routine solves the atmospheric exchange energy balance.
**********************************************************************/
double LatentHeat;
double NetRadiation;
double Ra;
double Tair;
double atmos_density;
double InSensible;
double *SensibleHeat;
// internal routine variables
double Error;
// extract variables from va_arg
LatentHeat = (double) va_arg(ap, double);
NetRadiation = (double) va_arg(ap, double);
Ra = (double) va_arg(ap, double);
Tair = (double) va_arg(ap, double);
atmos_density = (double) va_arg(ap, double);
InSensible = (double) va_arg(ap, double);
SensibleHeat = (double *)va_arg(ap, double *);
// compute sensible heat flux between canopy and atmosphere
(*SensibleHeat) = atmos_density * Cp * (Tair - Tcanopy) / Ra;
// compute energy balance error
//Error = NetRadiation + LatentHeat + (*SensibleHeat);
Error = InSensible - (*SensibleHeat);
return ( Error );
}