/*
 * SUMMARY:      AggregateRadiation.c - calculate basin-wide radiation
 * USAGE:        part of DHSVM
 *
 * AUTHOR:       Bart Nijssen
 * ORG:          University of Washington, Department of Civil Engineering
 * E-MAIL:       nijssen@u.washington.edu
 * ORIG-DATE:    Apr-96
 * Last Change: Wed Jan 27 23:25:06 1999 by Bart Nijssen <nijssen@u.washington.edu>
 * DESCRIPTION:  Calculate basin-wide radiation
 * DESCRIP-END.
 * FUNCTIONS:    
 * COMMENTS:     
 */

#ifndef lint
static char vcid[] = "$Id: AggregateRadiation.c,v 1.2 2001/03/31 00:10:18 waichler Exp $";
#endif /* lint */

#include <stdio.h>
#include <stdlib.h>
#include "settings.h"
#include "data.h"
#include "massenergy.h"

/*****************************************************************************
  AggregateRadiation()
  
  In the current implementation the local radiation elements are not stored 
  for the entire area.  Therefore these components are aggregated here.  They
  are averaged over the basin in Aggregate()
*****************************************************************************/
void AggregateRadiation(int MaxVegLayers, int NVegL, PIXRAD *Rad, 
                        PIXRAD *TotalRad)
{
  int i;                        /* counter */
  
  /* aggregate radiation data */
  for (i = 0; i < NVegL; i++) {
    TotalRad->NetShort[i] += Rad->NetShort[i];
    TotalRad->LongIn[i]   += Rad->LongIn[i];
    TotalRad->LongOut[i]  += Rad->LongOut[i];
  }
  TotalRad->NetShort[MaxVegLayers] += Rad->NetShort[NVegL];
  TotalRad->LongIn[MaxVegLayers]   += Rad->LongIn[NVegL];
  TotalRad->LongOut[MaxVegLayers]  += Rad->LongOut[NVegL];
  TotalRad->PixelNetShort += Rad->PixelNetShort;
  TotalRad->PixelLongIn   += Rad->PixelLongIn;
  TotalRad->PixelLongOut  += Rad->PixelLongOut;

}
