⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 put_data.c

📁 超强的大尺度水文模拟工具
💻 C
📖 第 1 页 / 共 2 页
字号:
#include <stdio.h>#include <stdlib.h>#include <vicNl.h>static char vcid[] = "$Id: put_data.c,v 4.2.2.3 2004/05/06 19:08:10 tbohn Exp $";void put_data(dist_prcp_struct  *prcp,	      atmos_data_struct *atmos,	      veg_con_struct    *veg_con,              outfiles_struct   *outfiles,              double            *depth,	      double            *dz,	      double             dp,	      double            *AreaFract,	      char              *AboveTreeLine,	      dmy_struct        *dmy,              int                rec,	      int                dt,	      int                Nnodes,	      int                skipyear)/**********************************************************************	put_data.c	Dag Lohmann		January 1996  This routine converts data units, and stores finalized values  in an array for later output to the output files.  modifications:  06-24-98  modified for new distributed presipitation data structures KAC  01-20-00 modified to deal with simplified frozen soil moisture layers           and frost depth / thaw depth accounting                 KAC  03-08-00 modified to eliminate extra lines for storing bare           soil variables.                                         KAC  03-12-03 modified to add additional energy balance variable storage            when output of snow bands is selected.                  KAC  03-12-03 Modifed to add AboveTreeLine to soil_con_struct so that           the model can make use of the computed treeline.     KAC**********************************************************************/{  extern veg_lib_struct  *veg_lib;  extern option_struct    options;#if LINK_DEBUG  extern debug_struct     debug;#endif#if OPTIMIZE  static int              prtdt;  static double           runoff;  static double           baseflow;#endif  out_data_struct        *out_data;  int                     veg;  int                     index;  int                     Ndist;  int                     dist;  int                     band;  int                     Nbands;  double                  Cv;  double                  mu;  double                  tmp_evap;  double                  tmp_moist;  double                  tmp_ice;  double                  rad_temp;  double                  surf_temp;  double                  inflow;  double                  outflow;  double                  storage;  double                  TreeAdjustFactor[MAX_BANDS];  cell_data_struct     ***cell;  snow_data_struct      **snow;  energy_bal_struct     **energy;  veg_var_struct       ***veg_var;  if(options.DIST_PRCP)     Ndist = 2;  else     Ndist = 1;  Nbands = options.SNOW_BAND;  // Compute treeline adjustment factors  for ( band = 0; band < Nbands; band++ ) {    if ( AboveTreeLine[band] ) {      Cv = 0;      for ( veg = 0 ; veg < veg_con[0].vegetat_type_num ; veg++ ) {	if ( veg_lib[veg_con[veg].veg_class].overstory )	  Cv += veg_con[veg].Cv;      }      TreeAdjustFactor[band] = 1. / ( 1. - Cv );    }    else TreeAdjustFactor[band] = 1.;    if ( TreeAdjustFactor[band] != 1 && rec == 0 )      fprintf( stderr, "WARNING: Tree adjust factor for band %i is equal to %f.\n", band, TreeAdjustFactor[band] );  }  /** Initialize Output Data Array **/  out_data = (out_data_struct *) calloc(1,sizeof(out_data_struct));     out_data->snow_canopy[0] = 0.0;  out_data->prec           = atmos->out_prec;  out_data->wind           = atmos->wind[NR];  out_data->air_temp       = atmos->air_temp[NR];  out_data->rel_humid      = 100.*atmos->vp[NR]/(atmos->vp[NR]+atmos->vpd[NR]);  out_data->surf_temp      = 0.;   /*************************************************    Store Output for Precipitation Distribution Type    *************************************************/  cell    = prcp->cell;  veg_var = prcp->veg_var;  snow    = prcp->snow;  energy  = prcp->energy;    /****************************************    Store Output for all Vegetation Types  ****************************************/  for ( veg = 0 ; veg <= veg_con[0].vegetat_type_num ; veg++) {        if ( veg < veg_con[0].vegetat_type_num )       Cv = veg_con[veg].Cv;    else      Cv = (1.0 - veg_con[0].Cv_sum);    if ( Cv > 0 ) {      /*******************************************************        Compute Average Variables from Wet and Dry Fractions      *******************************************************/      for ( dist = 0; dist < Ndist; dist++ ) {	if(dist==0) 	  mu = prcp[0].mu[veg];	else 	  mu = 1. - prcp[0].mu[veg];	/*********************************          Record Water Balance Variables 	*********************************/	/** record total evaporation **/	for(band=0;band<Nbands;band++) {	  if(AreaFract[band] > 0. && ( veg == veg_con[0].vegetat_type_num || ( !AboveTreeLine[band] || (AboveTreeLine[band] && !veg_lib[veg_con[veg].veg_class].overstory)))) {	    #if !OPTIMIZE	    	    tmp_evap = 0.0;	    for(index=0;index<options.Nlayer;index++)	      tmp_evap += cell[dist][veg][band].layer[index].evap;	    if ( veg < veg_con[0].vegetat_type_num )	      out_data->evap_veg += tmp_evap * Cv * mu * AreaFract[band] * TreeAdjustFactor[band];	    else 	      out_data->evap_bare += tmp_evap * Cv * mu * AreaFract[band] * TreeAdjustFactor[band];	    tmp_evap += snow[veg][band].vapor_flux * 1000.;	    out_data->sub_snow += snow[veg][band].vapor_flux * 1000. 	      * Cv * mu * AreaFract[band] * TreeAdjustFactor[band]; 	    if ( veg <= veg_con[0].vegetat_type_num ) {	      tmp_evap += snow[veg][band].canopy_vapor_flux * 1000.;	      out_data->sub_canop += snow[veg][band].canopy_vapor_flux 		* 1000. * Cv * mu * AreaFract[band] * TreeAdjustFactor[band]; 	    }	    if ( veg < veg_con[0].vegetat_type_num ) {	      tmp_evap += veg_var[dist][veg][band].canopyevap;	      out_data->evap_canop += veg_var[dist][veg][band].canopyevap 		* Cv * mu * AreaFract[band] * TreeAdjustFactor[band]; 	    }	    out_data->evap += tmp_evap * Cv * mu * AreaFract[band] * TreeAdjustFactor[band]; #endif	  	    /** record runoff **/	    out_data->runoff   += cell[dist][veg][band].runoff 	      * Cv * mu * AreaFract[band] * TreeAdjustFactor[band];	    	    /** record baseflow **/	    out_data->baseflow += cell[dist][veg][band].baseflow 	      * Cv * mu * AreaFract[band] * TreeAdjustFactor[band]; 	    #if ! OPTIMIZE	    	    /** record inflow **/	    if ( veg < veg_con[0].vegetat_type_num ) 	      out_data->inflow += (cell[dist][veg][band].inflow 				   + veg_var[dist][veg][band].canopyevap) 		* Cv * mu * AreaFract[band] * TreeAdjustFactor[band];	    else 	      out_data->inflow += (cell[dist][veg][band].inflow) 		* Cv * mu * AreaFract[band] * TreeAdjustFactor[band];	    	    /** record canopy interception **/	    if ( veg < veg_con[0].vegetat_type_num ) 	      out_data->Wdew += veg_var[dist][veg][band].Wdew 		* Cv * mu * AreaFract[band] * TreeAdjustFactor[band];	  	    /** record aerodynamic resistance **/	    out_data->aero_resist += cell[WET][veg][0].aero_resist[0] 	      * Cv * mu * AreaFract[band] * TreeAdjustFactor[band];	    	    /** recored layer moistures **/	    for(index=0;index<options.Nlayer;index++) {	      tmp_moist = cell[dist][veg][band].layer[index].moist;	      tmp_ice   = cell[dist][veg][band].layer[index].ice;	      tmp_moist -= tmp_ice;	      if(options.MOISTFRACT) {		tmp_moist /= depth[index] * 1000.;		tmp_ice /= depth[index] * 1000.;	      }	      tmp_moist *= Cv * mu * AreaFract[band] * TreeAdjustFactor[band];	      tmp_ice *= Cv * mu * AreaFract[band] * TreeAdjustFactor[band];	      out_data->moist[index] += tmp_moist;	      out_data->ice[index]   += tmp_ice;	    }#endif	  }	}      }#if !OPTIMIZE      for(band=0;band<Nbands;band++) {	if(AreaFract[band] > 0. && ( veg == veg_con[0].vegetat_type_num || ( !AboveTreeLine[band] || (AboveTreeLine[band] && !veg_lib[veg_con[veg].veg_class].overstory)))) {	  /**********************************	    Record Frozen Soil Variables	  **********************************/	  /** record freezing and thawing front depths **/	  if(options.FROZEN_SOIL) {	    for(index = 0; index < MAX_FRONTS; index++) {	      if(energy[veg][band].fdepth[index] != MISSING)		out_data->fdepth[index] += energy[veg][band].fdepth[index] 		  * Cv * 100. * AreaFract[band] * TreeAdjustFactor[band];	      if(energy[veg][band].tdepth[index] != MISSING)		out_data->tdepth[index] += energy[veg][band].tdepth[index] 		  * Cv * 100. * AreaFract[band] * TreeAdjustFactor[band];	    }	  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -