pihm.c File Reference

This file is the main entrance of PIHM. More...

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include "sundials_types.h"
#include "sundials_dense.h"
#include "sundials_smalldense.h"
#include "sundials_math.h"
#include "cvode.h"
#include "cvode_spgmr.h"
#include "cvode_dense.h"
#include "nvector_serial.h"
#include "pihm.h"

Include dependency graph for pihm.c:

Go to the source code of this file.

Functions

void read_alloc (char *, Model_Data, Control_Data *)
 Function reads all the input files and initializes members of Model and Control Data Structure.
N_Vector N_VNew_Serial (int)
 CVODE::Set vector of initial values.
void initialize (char *, Model_Data, Control_Data *, N_Vector)
 Function initializes several dependent variables of Model and Control Data Structure.
void * CVodeCreate (int, int)
 CVODE::Create the CVODE memory block and specify the Solution Method.
int CVodeSetFdata (void *, void *)
 CVODE::Set Data for right-hand side function.
int CVodeSetInitStep (void *, realtype)
 CVODE::Set Initial step size.
int CVodeSetStabLimDet (void *, booleantype)
 CVODE::ON/OFF the BDF stability limit detection algorithm.
int CVodeSetMaxStep (void *, realtype)
 CVODE::Specify the maximum absolute value of the step size.
int CVodeMalloc (void *, CVRhsFn, realtype, N_Vector, int, realtype, void *)
 CVODE::provide required problem specifications, allocate internal memory for CVODE, and initialize CVODE.
int CVSpgmr (void *, int, int)
 CVODE::selects the CVSPGMR linear solver.
int CVSpilsSetGSType (void *, int)
 CVODE::specifies Gram-Schmidt orthogonalization to be used.
void calET_IS (realtype, realtype, Model_Data, N_Vector)
 Function Calculates Evaporation from Canopy & Interception Storage.
int CVode (void *, realtype, n_Vector, realtype *, int)
 CVODE::Advance solution in time.
int f (realtype, N_Vector, N_Vector, void *)
 Function calculates fluxes, right hand side leading to construction of ODE system.
void setTSDiCounter (Model_Data mData, realtype t)
 Function sets the marker of all the time series according to given time t.
realtype Interpolation (TSD *Data, realtype t)
void FPrintInit (Model_Data)
 Initializes several variables and allocates memory depending on output file mode and variables user wants to output.
void FPrint (Model_Data, N_Vector, realtype)
 This function calls different fuction depending on the Output File Mode and simulated variables user wants to print as declared in print.h file.
void FPrintInitFile (Model_Data, Control_Data, N_Vector, int)
 Print new .init file at the completion of simulation.
void FPrintCloseAll (void)
 Close all the files those were opened in function FPrintInit.
int main (int argc, char *argv[])

Variables

int satEle
int ovrEle


Detailed Description

This file is the main entrance of PIHM.

The whole PIHM module consists of 11 files including Makefile. The strategy followed here revolves around the basic setup for using CVODE Solver. In terms of procedural framework the steps those are accomplished are as follows:

1. read_alloc.c reads all the input files

2. initialize.c initializes the model and control data structure variables.

3. et_is.c computes interception and evaporation from the canopy

4. CVode() solves the system of ODE to output state variables at specified point of times

5. f.c computes the rate of change to state variables to form system of ODEs

6. state variables are passed on to print.c at the end of each timestep

This process (steps 3 to 6) of marching in time continues until it reaches the end of simulation time period.

Definition in file pihm.c.


Function Documentation

void calET_IS ( realtype  t,
realtype  stepsize,
Model_Data  MD,
N_Vector  VY 
)

Function Calculates Evaporation from Canopy & Interception Storage.

Parameters:
t is the time of simulation
stepsize is length of time marching
MD is pointer to model data structure
VY is state variable vector

Bhatt

Definition at line 62 of file et_is.c.

References element_type::Albedo, model_data_structure::Ele, model_data_structure::Ele2IS, model_data_structure::EleET, model_data_structure::EleIS, model_data_structure::EleISmax, model_data_structure::EleNetPrep, model_data_structure::ElePrep, model_data_structure::EleSnow, model_data_structure::EleTF, et0_CALIB, element_type::humidity, Interpolation(), is_CALIB, element_type::LAImax, element_type::LC, mf_CALIB, model_data_structure::NumEle, element_type::prep, element_type::pressure, element_type::Rn, setet0_CALIB(), setis_CALIB(), setmf_CALIB(), settf_CALIB(), model_data_structure::SIFactor, element_type::temp, tf_CALIB, model_data_structure::TSD_DH, model_data_structure::TSD_Humidity, model_data_structure::TSD_LAI, model_data_structure::TSD_MeltF, model_data_structure::TSD_Prep, model_data_structure::TSD_Pressure, model_data_structure::TSD_Rn, model_data_structure::TSD_Temp, model_data_structure::TSD_WindVel, element_type::VegFrac, element_type::windH, element_type::WindVel, and element_type::zmax.

Referenced by main().

Here is the call graph for this function:

int CVode ( void *  ,
realtype  ,
n_Vector  ,
realtype *  ,
int   
)

CVODE::Advance solution in time.

Referenced by main().

void* CVodeCreate ( int  ,
int   
)

CVODE::Create the CVODE memory block and specify the Solution Method.

Referenced by main().

int CVodeMalloc ( void *  ,
CVRhsFn  ,
realtype  ,
N_Vector  ,
int  ,
realtype  ,
void *   
)

CVODE::provide required problem specifications, allocate internal memory for CVODE, and initialize CVODE.

Referenced by main().

int CVodeSetFdata ( void *  ,
void *   
)

CVODE::Set Data for right-hand side function.

Referenced by main().

int CVodeSetInitStep ( void *  ,
realtype   
)

CVODE::Set Initial step size.

Referenced by main().

int CVodeSetMaxStep ( void *  ,
realtype   
)

CVODE::Specify the maximum absolute value of the step size.

Referenced by main().

int CVodeSetStabLimDet ( void *  ,
booleantype   
)

CVODE::ON/OFF the BDF stability limit detection algorithm.

Referenced by main().

int CVSpgmr ( void *  ,
int  ,
int   
)

CVODE::selects the CVSPGMR linear solver.

Referenced by main().

int CVSpilsSetGSType ( void *  ,
int   
)

CVODE::specifies Gram-Schmidt orthogonalization to be used.

Referenced by main().

int f ( realtype  t,
N_Vector  CV_Y,
N_Vector  CV_Ydot,
void *  DS 
)

Function calculates fluxes, right hand side leading to construction of ODE system.

Parameters:
t is the time of simulation
CV_Y is state variable vector
CV_Ydot is vector of rate of change of state variables
DS is pointer to model data structure

Definition at line 83 of file f.c.

References ABS_TOL, model_data_structure::Ele, et1_CALIB, et2_CALIB, Kh_CALIB, mp_MULTFH, mp_MULTFV, mpArea_CALIB, model_data_structure::NumEle, model_data_structure::NumRiv, ovl_THRESH_H, ovl_THRESH_V, Rec_CALIB, rivK_CALIB, rzd_CALIB, sat_THRESH, setet1_CALIB(), setet2_CALIB(), setKh_CALIB(), setmp_MULTFH(), setmp_MULTFV(), setmpArea_CALIB(), setovl_THRESH_H(), setovl_THRESH_V(), setRec_CALIB(), setrivK_CALIB(), setrzd_CALIB(), setsat_THRESH(), setVic_CALIB(), Vic_CALIB, element_type::zmax, and element_type::zmin.

Referenced by main().

Here is the call graph for this function:

void FPrint ( Model_Data  mData,
N_Vector  CV_Y,
realtype  t 
)

This function calls different fuction depending on the Output File Mode and simulated variables user wants to print as declared in print.h file.

Parameters:
mData is pointer to model data structure
CV_Y is state variable vector
t is time of current simulation

Definition at line 101 of file print.c.

References CDF, ET0, et0_varid, et0ID, et0Ptr, ET1, et1_varid, et1ID, et1Ptr, ET2, et2_varid, et2ID, et2Ptr, FPRINT_MODE, Infil, infil_varid, infilID, infilPtr, ISState, isState_varid, isStateID, isStatePtr, NetPpt, netPrecip_varid, netPrecipID, netPrecipPtr, printET0(), printET0cdf(), printET1(), printET1cdf(), printET2(), printET2cdf(), printInfil(), printInfilcdf(), printIS(), printIScdf(), printNetPpt(), printNetPptcdf(), printRecharge(), printRechargecdf(), printRiverBase(), printRiverBasecdf(), printRiverFlow(), printRiverFlowcdf(), printRiverHead(), printRiverHeadcdf(), printRiverSurf(), printRiverSurfcdf(), printSatState(), printSatStatecdf(), printSurfState(), printSurfStatecdf(), printUsatState(), printUsatStatecdf(), RECHARGE, recharge_varid, rechargeID, rechargePtr, RivBase, rivBase_varid, rivBaseID, rivBasePtr, RivFlow, rivFlow_varid, rivFlowID, rivFlowPtr, RivHead, rivHead_varid, rivHeadID, rivHeadPtr, RivSurf, rivSurf_varid, rivSurfID, rivSurfPtr, SatState, satState_varid, satStateID, satStatePtr, SurfState, surfState_varid, surfStateID, surfStatePtr, TXT, UsatState, usatState_varid, usatStateID, usatStatePtr, and YEA.

Referenced by main().

Here is the call graph for this function:

void FPrintCloseAll ( void   ) 

Close all the files those were opened in function FPrintInit.

Definition at line 730 of file print.c.

void FPrintInit ( Model_Data  mData  ) 

Initializes several variables and allocates memory depending on output file mode and variables user wants to output.

Parameters:
mData is pointer to model data structure

Definition at line 247 of file print.c.

Referenced by main().

void FPrintInitFile ( Model_Data  mData,
Control_Data  cData,
N_Vector  CV_Y,
int  i 
)

Print new .init file at the completion of simulation.

Parameters:
mData is pointer to model data structure
cData is pointer to control data structure
CV_Y is state variable vector
i is the index of cData.Tout

Definition at line 215 of file print.c.

References model_data_structure::EleIS, model_data_structure::EleSnow, initFile, initPtr, model_data_structure::NumEle, model_data_structure::NumRiv, setFileName(), and control_data_structure::Tout.

Here is the call graph for this function:

void initialize ( char *  filename,
Model_Data  DS,
Control_Data CS,
N_Vector  CV_Y 
)

Function initializes several dependent variables of Model and Control Data Structure.

Parameters:
filename is Identifier of input files
DS is pointer to model data structure
CS is pointer to control data structure
CV_Y is state variable vector

Definition at line 49 of file initialize.c.

References br_CALIB, model_data_structure::Ele, icsat_CALIB, element_type::node, model_data_structure::Node, model_data_structure::NumEle, poros_CALIB, rivEle_CALIB, satD_CALIB, setbr_CALIB(), seticsat_CALIB(), setporos_CALIB(), setrivEle_CALIB(), setsatD_CALIB(), nodes_type::x, nodes_type::y, nodes_type::zmax, and nodes_type::zmin.

Referenced by main().

Here is the call graph for this function:

realtype Interpolation ( TSD Data,
realtype  t 
)

int main ( int  argc,
char *  argv[] 
)

Definition at line 127 of file pihm.c.

References control_data_structure::abstol, calET_IS(), CVode(), CVodeCreate(), CVodeMalloc(), CVodeSetFdata(), CVodeSetInitStep(), CVodeSetMaxStep(), CVodeSetStabLimDet(), CVSpgmr(), CVSpilsSetGSType(), control_data_structure::ETStep, f(), FPrint(), FPrintInit(), initialize(), control_data_structure::InitStep, Interpolation(), control_data_structure::MaxStep, N_VNew_Serial(), control_data_structure::NumSteps, read_alloc(), control_data_structure::reltol, setFileName(), setTSDiCounter(), control_data_structure::StartTime, control_data_structure::Tout, and Tsteps.

Here is the call graph for this function:

N_Vector N_VNew_Serial ( int   ) 

CVODE::Set vector of initial values.

Referenced by main().

void read_alloc ( char *  filename,
Model_Data  DS,
Control_Data CS 
)

Function reads all the input files and initializes members of Model and Control Data Structure.

Parameters:
filename is Identifier of input files
DS is pointer to model data structure
CS is pointer to control data structure

< Enum value TVal1.

Definition at line 44 of file read_alloc.c.

References albedo_CALIB, soils_type::Alpha, alpha_CALIB, soils_type::base, element_type::BC, soils_type::Beta, model_data_structure::Ele, model_data_structure::Ele_IC, element_type::G, soils_type::gama, element_type::humidity, element_type::index, nodes_type::index, soils_type::index, TSD_type::index, soils_type::Inf, element_IC_type::interception, soils_type::Ksat, lai_CALIB, element_type::LC, TSD_type::length, soils_type::Macropore, element_type::nabr, TSD_type::name, model_data_structure::Node, element_type::node, model_data_structure::NumEle, model_data_structure::NumInc, model_data_structure::NumNode, model_data_structure::NumSoil, element_type::prep, element_type::pressure, rivCoeff_CALIB, rivDepth_CALIB, element_type::Rn, roughEle_CALIB, roughRiv_CALIB, soils_type::RzD, element_IC_type::sat, set_MP, setalbedo_CALIB(), setalpha_CALIB(), setlai_CALIB(), setrivCoeff_CALIB(), setrivDepth_CALIB(), setroughEle_CALIB(), setroughRiv_CALIB(), setset_MP(), setvegfrac_CALIB(), soils_type::Sf, soils_type::SitaR, soils_type::SitaS, element_IC_type::snow, element_type::soil, model_data_structure::Soil, element_type::source, element_IC_type::surf, element_type::temp, TSD_type::TS, model_data_structure::TSD_Inc, element_IC_type::unsat, vegfrac_CALIB, element_type::WindVel, nodes_type::x, nodes_type::y, nodes_type::zmax, and nodes_type::zmin.

Referenced by main().

Here is the call graph for this function:

void setTSDiCounter ( Model_Data  mData,
realtype  t 
)

Function sets the marker of all the time series according to given time t.

Parameters:
mData is pointer to model data structure
t is time of simulation

Definition at line 390 of file pihm.c.

References TSD_type::iCounter, TSD_type::length, model_data_structure::NumPrep, TSD_type::TS, and model_data_structure::TSD_Prep.

Referenced by main().


Variable Documentation

int ovrEle

Definition at line 124 of file pihm.c.

int satEle

Definition at line 124 of file pihm.c.


Generated on Thu Jul 12 14:34:20 2007 for PIHM by  doxygen 1.5.2