Everglades Landscape Model (ELM) Home Page
Main Page | Data Structures | Directories | File List | Data Fields | Globals

driver_utilities.h File Reference

Header file for Driver Utilities. More...

#include "globals.h"

Include dependency graph for driver_utilities.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Defines

#define Outlist_size   250

Functions

VOIDP nalloc (unsigned mem_size, const char var_name[])
 Allocate memory for a variable.
void init_pvar (VOIDP Map, UCHAR *mask, unsigned char Mtype, float iv)
 Initialize a variable to a value.
void read_map_dims (const char *filename)
 Establish the number of rows and columns of the model.
void read_model_parameters (char *s_parm_name, int s_parm_relval)
 Call functions to read model parameters from datafiles.
float * get_DBase_parmOLD (const char *filename, int i0, int i1, int index)
float * get_DBase_parm (const char *filename, float *dArray)
ViewParmread_output_parms (void)
 Call the read_output_parms function.
ViewParmreadOutlist (int size)
 Get the file to configure model output.
int readViewParms (FILE *vpFileName, int size, ViewParm **ppview)
 Read/process the command-parameters to configure model output.
void setPrecision (ViewParm *vp, int value)
 (Effectively unused).
int write_map_file (const char *filename, VOIDP Map, char Mtype, int index, float scale_value, float offset_value, int bSize, unsigned char type)
 Prepare the file and the data for writing output of map (array).
int read_map_file (const char *filename, VOIDP Map, unsigned char Mtype, float scale_value, float offset_value)
 Get the file and read/convert the data of map (array).
void print_loc_ave (Point3D *vt, void *Map, char Mtype, char *mName, int tIndex)
 Calculate summary statistics to determine local average.
void write_output (int index, ViewParm *vp, void *Map, const char *filename, char Mtype, int step)
 Determine which functions to call for model output.
void print_point (ViewParm *vp, void *Map, char Mtype, char *mName, int tIndex, int vpindex)
 Print data at point locations to memory (not to file/disk yet).
void writeWindow (void *fValue, char *vName, char *desc, int x0, int y0, int N0, int N1, int index, UCHAR Mtype, UCHAR format)
 Prepare a local data set for writing a local data window in debug file.
void calc_maxmin (ViewParm *vp, void *Map, char Mtype, char *mName, int step)
 Calculate maximum & minimum values in model output arrays.
void quick_look (void *Map, char *name, unsigned char Mtype, int xc, int yc, int range, unsigned char format)
 Prepare data and write heading for writing a data window in debug file.
int iclip (int x0, int min, int max)
 Constrain x0 value within a min and a max.
void make_more_points (ViewParm *vp, int ptIncr)
 Allocate memory & set up another set of point-locations for output.
void enc_Nb (UCHAR **sptr, SLONG value, int bytes)
 Place data in bytes into a buffer to assemble a binary array.
void RP_SwapFields (RPoint *thisStruct, RPoint *that)
 Point Time Series interpolation (unused):.
void RP_CopyFields (RPoint *thisStruct, RPoint *that)
 Point Time Series interpolation (unused):.
void RP_SetFields (RPoint *thisStruct, int ix, int iy, float r, float value)
 Point Time Series interpolation (unused):.
void RPL_AddrPoint (RPointList *thisStruct, int x, int y, float r, float value)
 Point Time Series interpolation (unused):.
void RPL_Sort (RPointList *thisStruct)
 Point Time Series interpolation (unused):.
void RPL_Free (RPointList *thisStruct)
 Point Time Series interpolation (unused):.
RPointListRPL_Init (int nPoints)
 Point Time Series interpolation (unused):.
void PTS_CopyFields (PTSeries *thisStruct, PTSeries pV)
 Point Time Series interpolation (unused): copy fields.
void PTS_Free (PTSeries *thisStruct)
 Point Time Series interpolation (unused): free up memory.
void PTS_SetFields (PTSeries *thisStruct, int ix, int iy, int index, int format, int col)
 Point Time Series interpolation (unused): set up the fields.
void PTSL_AddpTSeries (PTSeriesList *thisStruct, int x, int y, int index, int seriesNum, int col)
 Point Time Series interpolation (unused): add to the series.
void PTSL_Free (PTSeriesList *thisStruct)
 Point Time Series interpolation (unused): free up memory.
void PTSL_ReadLists (PTSeriesList *thisStruct, const char *ptsFileName, int index, float *timeStep, int *nPtTS, int col)
 Point Time Series interpolation (unused): read raw point data.
void PTSL_CreatePointMap (PTSeriesList *pList, void *Map, unsigned char Mtype, int step, float scale)
 Point Time Series interpolation (unused): generate interpolated spatial (map) data.
float PTSL_GetInterpolatedValue1 (PTSeriesList *thisStruct, int x, int y, int step)
 Point Time Series interpolation (unused): at point, calculate inverse distance interpolation (unrestricted power of distance).
float PTSL_GetInterpolatedValue0 (PTSeriesList *thisStruct, int x, int y, int step)
 Point Time Series interpolation (unused): at point, calculate inverse distance squared interpolation (restricted, not using pow() function).
PTSeriesListPTSL_Init (int nSlots, int format)
 Point Time Series interpolation (unused): initialize structure.
void calcdate (double jd, int *m, int *d, int *y, int *h, int *mi, double *sec)
 Determine the Gregorian date from a Julian calendar day.
double julday (int mon, int day, int year, int h, int mi, double se)
 Determine the Julian calendar day from a Gregorian date.
float FMOD (float x, float y)
 Modulus of a pair of (double) arguments.
void setup_grid ()
 Provide the 2D array size for the model domain.
void set_env_vars (void)
 Acquire necessary environment variables.
void set_boundary (VOIDP Map, unsigned char Mtype, float bv)
void fatal (const char *msg)
 Exit (code=9) from program after sending a message.
void Exit (int code)
 Standard exit from program.
void Copy (void *src, void *dst, int w, int n, int sw, int dw)
 Memory-copy data from large (global) domain to local domain.
void getInt (FILE *inFile, const char *lString, int *iValPtr)
 Get an integer following a specific string.
void getChar (FILE *inFile, const char *lString, char *cValPtr)
 Get a character following a specific string.
void getString (FILE *inFile, const char *lString, char *inString)
 Get a string following a specific string.
void getFloat (FILE *inFile, const char *lString, float *fValPtr)
 Get a float value following a specific string.
void setFlag (ViewParm *vp, UINT mask, int value)
 (Effectively unused). From Model.outList data, set a flag indicating array or not
int getFlag (ViewParm *vp, UINT mask)
 Unused (never called) function.
int getPrecision (ViewParm *vp)
 (Effectively unused).
int isInteger (char *target_str)
 Determine if an integer is present in string.
int isFloat (char *target_str)
 Determine if a float is present in string.
int skip_white (FILE *infile)
 Skip white space(s) in a file.
int scan_forward (FILE *infile, const char *tstring)
 Scan forward until a particular string is found.
int check_for (char *s0, const char *s1, int start, int cs, int rp)
 Check for occurrences of string s1 in string s0 after position start.
int find_char (FILE *infile, char tchar)
 Find a character.
int Round (float x)
 truncate (not rounding) to an integer
char * name_from_path (char *name)
 Get the var name from a longer path/filename.
char * Scip (char *s, char SYM)
 Skip ahead in a string until next field.
void setup_platform ()
 Effectively unused in serial (non-parallel) implementation.
void link_edges (VOIDP Map, unsigned char Mtype)
 Effectively unused in serial (non-parallel) implementation.
float Normal (float mean, float sd)
 Unused, never called. Normal distribution.
int Poisson (float mu)
 Unused, never called. Poisson distribution.
int init_config_file (FILE *vpFile, char term1, char term2, char term3, char term4)
 Get format definition of output configuration file (does nothing effective!).
int parse_packet (FILE *vpFile, int *nArgs, char *test)
 Parse through a configuration fileline to obtain the configuration commands.
void Combine (float *fValue, char *label, int nComp, int cType, int step)
 A variety of stat summaries in a selected spatial window (debug-related).
void writeMap (char *, void *, int, unsigned char, int)
 Write data for spatial (map) output binary file.
void writeSeries (void *fValue, char *label, char *desc, int N0, int N1, byte Mtype, byte format)
 Write to a spatial data window in a debug file.
float * readSeriesCol (char *filename, int format, int index, int *Npt, float *TStep, int col)
 (Unused). Read time series input data for spatial interpolations
byte readMap (char *, void *)
 Read data for spatial (map) input binary file.
int on_this_proc (int x, int y)
 Parallel code: does nothing in serial implementation).
void exchange_borders (UCHAR *map, int size)
 Parallel code: does nothing in serial implementation).
void exparam (struct nodenv *envInfo)
 Parallel code: effectively unused in serial implementation.
void exgridsplit (int nprocs, int ndim, int nprocs2[2])
 Parallel code: effectively unused in serial implementation.
void exgridcoord (int pnum, int rnum[2])
 Parallel code: effectively unused in serial implementation.
void exgridsize (int pnum, int gsize[2], int lsize[2], int lstart[2])
 Parallel code: effectively unused in serial implementation.
void broadcastInt (int *iValPtr)
 Parallel code: does nothing in serial implementation).
int exgridinit (int dim, int *nprocs)
 Parallel code: does nothing in serial implementation).
void broadcastMsg (UCHAR *msgPtr)
 Parallel code: does nothing in serial implementation).
void fasync (FILE *file)
 Parallel code: does nothing in serial implementation).
void fmulti (FILE *file)
 Parallel code: does nothing in serial implementation).
int ReadGlobalParms (char *s_parm_name, int s_parm_relval)
 Acquire the model parameters that are global to the domain.
int ReadHabParms (char *s_parm_name, int s_parm_relval)
 Acquire the model parameters that are specific to different habitat types in the domain.

Variables

int CalMonOut = 99999
char * ModelPath
char * ProjName
char * DriverPath
char * OS_TYPE
char * OutputPath
char modelName [20]
char modelVers [10]
char modelFileName [300]
int gNPtTs
int PListIndex = 0
int total_memory = 0
float * plot_array
float gTS
int gridSize
int gTempSize
UCHARgTemp
char gCArg [kCArgDepth][kCArgWidth]
FILE * Driver_outfile
float avg_Intvl
SeriesParm pSeries [MAX_PTSERIES]
ViewParmview
Point2D dbgPt
nodenv env
int gbl_size [2]
int lcl_size [2]
int lcl_start [2]
int N_iter
int istep
int procnum
int Lprocnum
int nprocs [2]
int recpnum [2]
float gRTable []
float GP_IDW_pow
int numBasn


Detailed Description

Header file for Driver Utilities.

This defines or declares variables & functions that are global to Driver_Utilities.c.

Note: documented with Doxygen, which expects specific syntax within special comments.

The Everglades Landscape Model (ELM).
last updated: Dec 2004

Definition in file driver_utilities.h.


Define Documentation

#define Outlist_size   250
 

The (maximum) number of variables in model outlist

Definition at line 24 of file driver_utilities.h.

Referenced by read_output_parms().


Function Documentation

VOIDP nalloc unsigned  mem_size,
const char  var_name[]
 

Allocate memory for a variable.

Parameters:
mem_size The size of memory space
var_name The variable's name
Returns:
Pointer to that memory

Definition at line 1774 of file Driver_Utilities.c.

01775 {
01776   VOIDP rp;
01777 
01778   
01779   if(mem_size == 0) return(NULL);
01780   rp = (VOIDP)malloc( mem_size );
01781   total_memory += mem_size;
01782   fasync(stderr);
01783   if( rp == NULL ) {
01784     fprintf(stderr,"Sorry, out of memory(%d): %s\n",mem_size,var_name);
01785     Exit(0);
01786   }
01787   fmulti(stderr);
01788   return(rp);
01789 }

void init_pvar VOIDP  Map,
UCHAR mask,
unsigned char  Mtype,
float  iv
 

Initialize a variable to a value.

Parameters:
Map array of data
mask data mask
Mtype the data type of the map data
iv the value used to initialize variable

Definition at line 925 of file Driver_Utilities.c.

00926 {
00927   int i0, i1;
00928   
00929   switch(Mtype) {
00930   case 'b' :    /* added double for (non-map) basin (b) array budget calcs */
00931     for(i0=0; i0<=numBasn; i0++) {
00932         ((double*)Map)[i0] = iv;
00933       }
00934     break;
00935   case 'l' :    /* added double (l == letter "ell" ) for map arrays */
00936     for(i0=0; i0<=s0+1; i0++) 
00937       for(i1=0; i1<=s1+1; i1++) {
00938         if(mask==NULL) ((double*)Map)[T(i0,i1)] = iv;
00939         else if ( mask[T(i0,i1)] == 0 ) ((double*)Map)[T(i0,i1)] = 0;
00940         else ((double*)Map)[T(i0,i1)] = iv;
00941       }
00942     break;
00943   case 'f' :    
00944     for(i0=0; i0<=s0+1; i0++) 
00945       for(i1=0; i1<=s1+1; i1++) {
00946         if(mask==NULL) ((float*)Map)[T(i0,i1)] = iv;
00947         else if ( mask[T(i0,i1)] == 0 ) ((float*)Map)[T(i0,i1)] = 0;
00948         else ((float*)Map)[T(i0,i1)] = iv;
00949       }
00950     break;
00951   case 'i' :    case 'd' :      
00952     for(i0=0; i0<=s0+1; i0++) 
00953       for(i1=0; i1<=s1+1; i1++) {
00954         if(mask==NULL) ((int*)Map)[T(i0,i1)] = (int)iv;
00955         else if ( mask[T(i0,i1)] == 0 ) ((int*)Map)[T(i0,i1)] = 0;
00956         else ((int*)Map)[T(i0,i1)] = (int)iv;
00957       }
00958     break;
00959   case 'c' :    
00960     for(i0=0; i0<=s0+1; i0++) 
00961       for(i1=0; i1<=s1+1; i1++) {
00962         if(mask==NULL) ((unsigned char*)Map)[T(i0,i1)] = (unsigned char) '\0' + (int) iv;
00963         else if ( mask[T(i0,i1)] == 0 ) ((unsigned char*)Map)[T(i0,i1)] = '\0';
00964         else ((unsigned char*)Map)[T(i0,i1)] = (unsigned char) '\0' + (int) iv;
00965       } 
00966     break;
00967  
00968    default :
00969     printf(" in default case\n");
00970    break;
00971   }
00972 }

void read_map_dims const char *  filename  ) 
 

Establish the number of rows and columns of the model.

Read the map dimensions of the global model array, establishing #rows=s0 and #columns=s1

Parameters:
filename character string of the representative map (usually "Elevation")

Definition at line 892 of file Driver_Utilities.c.

00893 {
00894   FILE *file;
00895   
00896   if (debug>3) { sprintf(msgStr,"Getting map dims: %s",filename); usrErr(msgStr);} 
00897   if(Lprocnum == 1) {
00898     sprintf(modelFileName,"%s/%s/Data/Map_head/%s",ModelPath,ProjName,filename);
00899     file = fopen(modelFileName,"r");
00900     if(file==NULL) { 
00901       fprintf(stderr,"Unable to open map header file %s.\n",modelFileName); 
00902       fflush(stderr); 
00903       Exit(0);
00904     }
00905     scan_forward(file,"cols:");
00906     fscanf(file,"%d",&gbl_size[1]);
00907     sprintf(msgStr,"cols = %d\n",gbl_size[1]); WriteMsg(msgStr,1);
00908     scan_forward(file,"rows:");
00909     fscanf(file,"%d",&gbl_size[0]);
00910     sprintf(msgStr,"rows = %d\n",gbl_size[0]); WriteMsg(msgStr,1);
00911     fclose(file);
00912   }
00913   broadcastInt(gbl_size);   /* does nothing in serial (non-parallel) implementation */
00914   broadcastInt(gbl_size+1); /* does nothing in serial (non-parallel) implementation */
00915   s0 = gbl_size[0];
00916   s1 = gbl_size[1];
00917 }

void read_model_parameters char *  s_parm_name,
int  s_parm_relval
 

Call functions to read model parameters from datafiles.

Parameters:
s_parm_name Name of the sensitivity parameter being varied for this run
s_parm_relval Indicator of current value of relative range in sensitivity parm values: nominal (0), low (1), or high (2)

Definition at line 35 of file Driver_Utilities.c.

References msgStr, ReadGlobalParms(), ReadHabParms(), usrErr(), usrErr0(), and WriteMsg().

Referenced by main().

00035                                                                   {
00036 
00037     sprintf(msgStr,"Reading global parameters..."); 
00038     WriteMsg(msgStr,1); 
00039     usrErr0(msgStr);
00040 
00041         ReadGlobalParms(s_parm_name, s_parm_relval);
00042     sprintf(msgStr,"done."); 
00043     WriteMsg(msgStr,1); 
00044     usrErr(msgStr);
00045         
00046     sprintf(msgStr,"Reading habitat-specific parameters..."); 
00047     WriteMsg(msgStr,1); 
00048     usrErr0(msgStr);
00049 
00050         ReadHabParms(s_parm_name, s_parm_relval);
00051     sprintf(msgStr,"done."); 
00052     WriteMsg(msgStr,1); 
00053     usrErr(msgStr);
00054   
00055 }

Here is the call graph for this function:

float* get_DBase_parmOLD const char *  filename,
int  i0,
int  i1,
int  index
 

float* get_DBase_parm const char *  filename,
float *  dArray
 

ViewParm* read_output_parms void   ) 
 

Call the read_output_parms function.

Returns:
pointer to struct of ViewParm

Definition at line 59 of file Driver_Utilities.c.

References Outlist_size, readOutlist(), and ViewParm.

00059                               {
00060 /* need to change the Outlist_size (#defined in header) if adding outlist variables to the data struct in gen_output of UnitMod.c */
00061     ViewParm* v = readOutlist(Outlist_size);
00062     return v;
00063 } 

Here is the call graph for this function:

ViewParm* readOutlist int  size  ) 
 

Get the file to configure model output.

Parameters:
size Outlist_size, the number of variables in model outlist
Returns:
pointer to struct of ViewParm

Definition at line 68 of file Driver_Utilities.c.

References cnfgFile, H_OPSYS, modelFileName, ModelPath, msgStr, ProjName, readViewParms(), ViewParm, and WriteMsg().

Referenced by read_output_parms().

00069 {
00070   int Npt;
00071   ViewParm* vp;
00072   FILE   *cnfgFile;
00073   
00074   if(H_OPSYS==UNIX) sprintf(modelFileName,"%s/%s/RunParms/Model.outList",ModelPath,ProjName);
00075   else sprintf(modelFileName,"%s%s:RunParms:Model.outList",ModelPath,ProjName);
00076   cnfgFile = fopen(modelFileName, "r");
00077   if (cnfgFile == NULL) {
00078       sprintf(msgStr, "Error, can't open file %s", modelFileName);
00079       WriteMsg(msgStr, 1); exit(-1);}
00080   
00081   Npt = readViewParms(cnfgFile,size, &vp);
00082   return vp;
00083 
00084 }

Here is the call graph for this function:

int readViewParms FILE *  vpFile,
int  size,
ViewParm **  ppview
 

Read/process the command-parameters to configure model output.

The configuration file (Model.outList) is read to process the type (e.g., spatial maps, point time series, debug windows) and frequency (constant intervals of time) of model output.

Parameters:
vpFile Pointer to the Model.outList configuration file
size Outlist_size, the number of variables in model outlist
ppview Struct of ViewParm output configuration data
Returns:
value of Outlist_size

Definition at line 98 of file Driver_Utilities.c.

References avg_Intvl, viewParm::bounds, CalMonOut, viewParm::fileName, point3D::format, gCArg, init_config_file(), ISARRAY, isFloat(), isInteger(), make_more_points(), viewParm::mapType, viewParm::maxPoints, msgStr, nalloc(), viewParm::nPoints, scale1::o, parse_packet(), viewParm::points, scale1::s, viewParm::scale, setFlag(), setPrecision(), viewParm::step, point3D::type, usrErr(), view, ViewParm, scale2::Vmax, scale2::Vmin, WriteMsg(), point3D::x, point3D::y, and point3D::z.

Referenced by readOutlist().

00099 {
00100   char test;
00101   char cmd;
00102   int index=0, ix, iy, iz, i, nArgs, precision, format=0, Ocmd;
00103   float x,y;
00104   ViewParm *vp, *view;
00105 
00106   format = init_config_file(vpFile, '#', '*', '@', '~');
00107   view = (ViewParm *)nalloc(size * sizeof(ViewParm), "view");
00108   *ppview = view;
00109   
00110   for (i = 0; i < size; i++) {
00111     vp = view+i;
00112     vp->scale.s = 1.0;
00113     vp->scale.o = 0.0;
00114     vp->step = 0;
00115     Ocmd=0;
00116     vp->nPoints = 0;
00117     vp->points = NULL;
00118     vp->maxPoints = 0;
00119     vp->mapType = 'N';
00120     precision = 1;
00121     setPrecision(vp,precision);
00122   }
00123 
00124   while(1) {
00125     index = parse_packet(vpFile, &nArgs, &test);/*fix*/
00126     if( index == -1)  break; 
00127     if( index == -3)  break; 
00128     if(index >= size) { 
00129       fprintf(stderr,"\n Read index Error in configuration: index out of range: %d ", index); 
00130       break; 
00131     }
00132     if( index == -2) break;
00133     else {
00134       vp = view+index;
00135       strncpy(vp->fileName,gCArg[0],23);
00136       vp->fileName[23]='\0';
00137       if( test == '*' ) setFlag(vp,ISARRAY,1); 
00138       else if (test == '@') setFlag(vp,ISARRAY,0);
00139       else { 
00140         sprintf(msgStr," %s: Syntax Error in configuration, test char = %c ",gCArg[0],test); 
00141         usrErr(msgStr);  
00142         break; 
00143       }
00144       if(debug) { 
00145         sprintf(msgStr,"\nReading Output Config for %s: Nargs = %d, CMD0 = %c index = %d",
00146                 gCArg[0],nArgs,gCArg[1][0],index);      
00147         WriteMsg(msgStr,1);  
00148       }                         
00149       cmd = gCArg[1][0]; 
00150       switch (cmd) {    
00151           case 'O':
00152               if( isInteger(gCArg[2])  ) { ix = atoi(gCArg[2]);  }
00153               else  fprintf(stderr," %s: Syntax Error in configuration ",gCArg[0]);     
00154               if(debug) { 
00155                   sprintf(msgStr,"\n%s Output Config: O(%d)",gCArg[0],ix);      
00156                   WriteMsg(msgStr,1); 
00157               }                         
00158               vp->step = ix; Ocmd=1;
00159               /* TODO: develop flexible output of calendar-based and julian-based outsteps (jan 11, 2005) */
00160               /* kluge here in checking use of Model.outList outstep relative to Driver.parm avg_Intvl */
00161               if (vp->step == CalMonOut && avg_Intvl != 0) {
00162                   sprintf(msgStr,"\n***ERROR in Model.outList & Driver.parm integration: Driver.parm's avg_Intvl must be 0 for calendar-based Outstep of %s.",gCArg[0]);        
00163                   usrErr(msgStr); 
00164                   exit(-1);
00165               }
00166               
00167               break;
00168           case 'A':
00169               if( isInteger(gCArg[2]) && nArgs > 2 ) { ix = atoi(gCArg[2]);  }
00170               else  { 
00171                   fprintf(stderr," %s: Syntax Error in configuration ",gCArg[0]);  
00172                   WriteMsg(msgStr,1); 
00173               } 
00174               if(debug) { 
00175                   sprintf(msgStr,"\n%s Output Config: A()",gCArg[0]); 
00176                   WriteMsg(msgStr,1); 
00177               }                                 
00178               vp->mapType = 'H';
00179               if( Ocmd == 0 ) vp->step = 1;
00180               break;
00181           case 'G':
00182               if ( nArgs > 2 )  { 
00183                   if( isInteger(gCArg[2])  ) { 
00184                       vp->mapType = atoi(gCArg[2]); 
00185                   } 
00186                   else { vp->mapType =gCArg[2][0]; } 
00187               }
00188               if ( nArgs > 3 ) 
00189                   if( isInteger(gCArg[3])  ) { 
00190                       precision = atoi(gCArg[3]); 
00191                   }
00192               if ( nArgs > 4 ) strcpy(vp->fileName,gCArg[4]);
00193               if( precision > 1 && precision < 5 ) setPrecision(vp,precision);
00194               if( Ocmd == 0 ) vp->step = 1;
00195               break;
00196           case 'B':
00197               if( isFloat(gCArg[2]) && isFloat(gCArg[3])  && nArgs > 3 ) { 
00198                   vp->bounds.Vmax = atof(gCArg[2]); 
00199                   vp->bounds.Vmin = atof(gCArg[3]); 
00200               }
00201               if(debug) { 
00202                   sprintf(msgStr,"\n Output Config: G(%.1f,%.1f)",
00203                           vp->bounds.Vmax, vp->bounds.Vmin); 
00204                   WriteMsg(msgStr,1); 
00205               } 
00206               break;
00207           case 'P':
00208               if( isInteger(gCArg[2]) &&  isInteger(gCArg[3]) && nArgs > 3 )  {         
00209                   if( (i = (++(vp->nPoints)-1)) >= (vp->maxPoints)) make_more_points(vp,7);
00210                   ix = atoi(gCArg[2]); iy = atoi(gCArg[3]);  
00211               }
00212               else  fprintf(stderr," %s: Syntax Error in configuration ",gCArg[0]);
00213               if(debug) { 
00214                   sprintf(msgStr,"\n%s Output Config: P(%d,%d), index = %d",gCArg[0],ix,iy,i); 
00215                   WriteMsg(msgStr,1);  
00216               }                         
00217               vp->points[i].x = ix; 
00218               vp->points[i].y = iy;
00219               vp->points[i].type = 'p';
00220               /* TODO: develop flexible output of calendar-based and julian-based outsteps (jan 11, 2005) */
00221               /* kluge here in preventing use of point time series output using calendar-based outstep  */
00222               if (vp->step == CalMonOut) {
00223                   sprintf(msgStr,"\n***ERROR in Model.outList: sorry, but you can't have point-time series output with calendar-based Outstep of %s.  Go yell at Carl!",gCArg[0]);      
00224                   usrErr(msgStr); 
00225                   exit(-1);
00226               }
00227               break;
00228           case 'W':
00229               if( isInteger(gCArg[2]) &&  isInteger(gCArg[3]) &&  isInteger(gCArg[4]) && nArgs > 4 ) {
00230                   if( (i = (++(vp->nPoints)-1)) >= (vp->maxPoints)) make_more_points(vp,7);
00231                   ix = atoi(gCArg[2]); iy = atoi(gCArg[3]); iz = atoi(gCArg[4]);  
00232               }
00233               else  fprintf(stderr," %s: Syntax Error in configuration ",gCArg[0]);
00234               if( nArgs > 5 )  vp->points[i].format = gCArg[5][0];
00235               vp->points[i].type = 'w';
00236               vp->points[i].x = ix;     
00237               vp->points[i].y = iy;     
00238               vp->points[i].z = iz;
00239               if(debug) { 
00240                   sprintf(msgStr,"\n%s Output Config: W(%d,%d,%d,%c), index = %d",
00241                           gCArg[0],ix,iy,iz,vp->points[i].format,i);    
00242                   WriteMsg(msgStr,1);  
00243               }                         
00244               if( Ocmd == 0 ) vp->step = 1;
00245               break;
00246           case 'S': case 'C':
00247               if( gCArg[1][1] == 'm' || gCArg[1][0] == 'C' ) {     
00248                   if( isInteger(gCArg[2]) &&  isInteger(gCArg[3]) &&  isInteger(gCArg[4]) && nArgs > 5 ) {
00249                       if( (i = (++(vp->nPoints)-1)) >= (vp->maxPoints)) make_more_points(vp,7);
00250                       ix = atoi(gCArg[2]); iy = atoi(gCArg[3]); iz = atoi(gCArg[4]); 
00251                       vp->points[i].type =  gCArg[5][0];
00252                   }
00253                   else  fprintf(stderr," %s: Syntax Error in configuration ",gCArg[0]);
00254                   vp->points[i].x = ix;         
00255                   vp->points[i].y = iy;         
00256                   vp->points[i].z = iz;
00257                   if(debug) { 
00258                       sprintf(msgStr,"\n%s Output Config: Sm(%d,%d,%d,%c), index = %d",
00259                               gCArg[0],ix,iy,iz,gCArg[4][0],i);  
00260                       WriteMsg(msgStr,1); 
00261                   }                             
00262                   if( Ocmd == 0 ) vp->step = 1; 
00263               } 
00264               else {                                                            
00265                   if( nArgs > 2 ) {
00266                       if( isFloat(gCArg[2]) ) { x = atof(gCArg[2]); }
00267                       else  fprintf(stderr," %s: Syntax Error in configuration ",gCArg[0]);
00268                   }
00269                   if( nArgs > 3 ) {
00270                       if( isFloat(gCArg[3]) ) { y = atof(gCArg[3]); }
00271                       else  fprintf(stderr," %s: Syntax Error in configuration ",gCArg[0]);
00272                   }
00273                   if(debug) { 
00274                       sprintf(msgStr,"\n%s Output Config: S(%f,%f)",gCArg[0],x,y); 
00275                       WriteMsg(msgStr,1); 
00276                   }                             
00277                   vp->scale.s = x; 
00278                   vp->scale.o = y;
00279               }
00280               break;
00281       } /* end of switch */
00282     } /* end of else */
00283   } /* end of while */
00284   return size;
00285 }

Here is the call graph for this function:

void setPrecision ViewParm vp,
int  value
 

(Effectively unused).

Definition at line 1334 of file Driver_Utilities.c.

References viewParm::flags, and ViewParm.

Referenced by readViewParms().

01335 {
01336   if(value/3) vp->flags |= PMASK2; else vp->flags &= ~PMASK2;
01337   if((value-1)%2) vp->flags |= PMASK1; else vp->flags &= ~PMASK1;
01338 }

int write_map_file const char *  filename,
VOIDP  Map,
char  Mtype,
int  index,
float  scale_value,
float  offset_value,
int  bSize,
unsigned char  type
 

Prepare the file and the data for writing output of map (array).

Parameters:
filename Output file name
Map Model variable array data
Mtype General output format type
index Count index of the output iteration for this variable (may be > step)
scale_value Variable-scaling multiplier
offset_value Variable-scaling offset
bSize The byte size of the output array
type The output map storage type

Definition at line 443 of file Driver_Utilities.c.

References CASE, check_for(), simTime::da, dbgPt, debug, enc_Nb(), END, gridSize, gTemp, gTempSize, H_OPSYS, HDF, simTime::mo, modelFileName, msgStr, nalloc(), ON_MAP, OutputPath, ProjName, quick_look(), SimTime, SLONG, T, UCHAR, writeMap(), WriteMsg(), point2D::x, point2D::y, and simTime::yr.

Referenced by write_output().

00446 {       
00447   int i, j, pathType=0;
00448   char /* ftype[7] */ftype[10], gSize;
00449   float ftmp; 
00450   SLONG itmp, imax, imin;
00451   UCHAR *mPtr;
00452   char s_mo[3], s_da[3];
00453   
00454 /* below provides old (v1.0) increasing integer, non-date, appendage to filenames */
00455 /*   ftype[0] = '0' + (index / 100); */
00456 /*   ftype[1] = '0' + ((index%100) / 10); */
00457 /*   ftype[2] = '0' + (index % 10); */
00458  /*  ftype[8] = '\0'; */
00459 
00460 /*  append the date (yyyymmdd) to the root filename*/
00461   if (SimTime.mo[0]<10) sprintf(s_mo,"0%d", SimTime.mo[0]);
00462   else sprintf(s_mo,"%d", SimTime.mo[0]);
00463   if (SimTime.da[0]<10) sprintf(s_da,"0%d", SimTime.da[0]);
00464   else sprintf(s_da,"%d", SimTime.da[0]);
00465   sprintf(ftype,"%d%s%s\0",SimTime.yr[0],s_mo,s_da);
00466   
00467   if( HDF && type=='H' ) sprintf(ftype,".hdf");
00468    
00469   gSize = gridSize*bSize + 1;
00470   if( gSize > gTempSize ) { 
00471     if(gTempSize) free((char*)gTemp); 
00472     gTemp = (UCHAR*) nalloc( gSize, "gTemp" );  
00473     gTempSize = gSize; 
00474   }
00475   
00476   if( H_OPSYS == UNIX ){ 
00477     if(check_for((char*)filename, "/", 0, CASE, END ) >= 0 ) { 
00478       if(filename[0] != '/' ) pathType = 1; 
00479       else pathType = 2; 
00480     }
00481   }
00482   else { if(check_for ((char*)filename, ":", 0, CASE, END ) >= 0 ) { if( filename[0] == ':' ) pathType = 1; else pathType = 2; }}
00483   
00484   if(type=='H') {                         /* HDF format */
00485     switch(pathType) {
00486     case 0:     /* No Path */
00487       if(H_OPSYS==UNIX) sprintf(modelFileName,"%s/%s/Output/Animation/%s%s\0",OutputPath,ProjName,filename,ftype);
00488       else sprintf(modelFileName,"%s%s:Output:Animation:%s%s\0",OutputPath,ProjName,filename,ftype);
00489       break;
00490     case 1:     /* Relative Path */
00491       if(H_OPSYS==UNIX) sprintf(modelFileName,"%s/%s/Output/Animation/%s%s\0",OutputPath,ProjName,filename,ftype);
00492       else sprintf(modelFileName,"%s%s:Output:Animation:%s%s\0",OutputPath,ProjName,filename,ftype);
00493       break;
00494     case 2:     /* Full Path */
00495       sprintf(modelFileName,"%s.hdf\0",filename);
00496       break;
00497     }
00498   }
00499   else if(type=='M') {  
00500     switch(pathType) {                   /* Map II (float, binary) Format */
00501     case 0:                                                             /* No Path */
00502       if(H_OPSYS==UNIX) sprintf(modelFileName,"%s/%s/Output/Maps/%s%s\0",OutputPath,ProjName,filename,ftype);
00503       else sprintf(modelFileName,"%s%s:Output:Maps:%s%s\0",OutputPath,ProjName,filename,ftype);
00504       break;
00505     case 1:     /* Relative Path */
00506       if(H_OPSYS==UNIX) sprintf(modelFileName,"%s/%s/Output/Maps/%s%s\0",OutputPath,ProjName,filename,ftype);
00507       else sprintf(modelFileName,"%s%s:Output:Maps:%s%s\0",OutputPath,ProjName,filename,ftype);
00508       break;
00509     case 2:     /* Full Path */
00510       sprintf(modelFileName,"%s%s\0",filename,ftype);
00511       break;
00512     }
00513   }
00514   else {
00515         bSize = 1;
00516     switch(pathType) {                   /* Generic Binary Format */
00517     case 0:                                                             /* No Path */
00518       if(H_OPSYS==UNIX) sprintf(modelFileName,"%s/%s/Output/Animation%d/%s%s\0",OutputPath,ProjName,type,filename,ftype);
00519       else sprintf(modelFileName,"%s%s:Output:Animation%d:%s%s\0",OutputPath,ProjName,type,filename,ftype);
00520       break;
00521     case 1:     /* Relative Path */
00522       if(H_OPSYS==UNIX) sprintf(modelFileName,"%s/%s/DriverOutput/Animation%d/%s%s\0",OutputPath,ProjName,type,filename,ftype);
00523       else sprintf(modelFileName,"%s%s:Output:Animation%d:%s%s\0",OutputPath,ProjName,type,filename,ftype);
00524       break;
00525     case 2:     /* Full Path */
00526       sprintf(modelFileName,"%s%s\0",filename,ftype);
00527       break;
00528     }
00529   }
00530   
00531   bSize = (bSize < 1) ? 1 : bSize;
00532   bSize = (bSize > 4) ? 4 : bSize;
00533   if( Mtype == 'c' ) bSize = 1;
00534   if(bSize == 1) { imax = 255; imin = 0; }
00535   else if(bSize == 2) { imax = 255*128; imin = -imax; }
00536   else if(bSize == 3) { imax = 256*256*128; imin = -imax; }
00537   mPtr = gTemp;
00538   
00539   if  ( debug >3) {  sprintf(msgStr,"\n\nWriting Map %s: scale_value = %f, offset_value = %f, index = %d, filename = %s, type = %c, bSize = %d, pathType = %d, type = %d\n",
00540                            filename,scale_value,offset_value,index,modelFileName,Mtype,bSize,pathType,type);   WriteMsg(msgStr,1); }
00541   
00542   for (i=0; i<s0; i++) {
00543     for (j=0; j<s1; j++) {
00544       if( ON_MAP[T(i+1,j+1)] ) {
00545         switch(Mtype) {
00546         case 'l' :
00547       ftmp = ((( (double*) Map)[T(i+1,j+1)] - offset_value) / scale_value); /* v2.3.2 added double (casting to float ftmp) */
00548           itmp = (int) ftmp;
00549           itmp = (itmp > imax-1) ? imax-1 : itmp;
00550           itmp = (itmp < imin) ? imin : itmp;
00551           break;
00552         case 'f' :                      
00553           ftmp = ((( (float*) Map)[T(i+1,j+1)] - offset_value) / scale_value); 
00554           itmp = (int) ftmp;
00555           itmp = (itmp > imax-1) ? imax-1 : itmp;
00556           itmp = (itmp < imin) ? imin : itmp;
00557           break;
00558         case 'd' : case 'i' :   
00559           ftmp = ((( (int*) Map)[T(i+1,j+1)] - offset_value) / scale_value); 
00560           itmp = (int) ftmp;
00561           itmp = (itmp > imax-1) ? imax-1 : itmp;
00562           itmp = (itmp < imin) ? imin : itmp;
00563           break;
00564         case 'c' :                              
00565           itmp = ((unsigned char*) Map)[T(i+1,j+1)];
00566           itmp = (itmp > imax-1) ? imax-1 : itmp;
00567           itmp = (itmp < imin) ? imin : itmp;
00568           break;
00569         }
00570       }
00571       else  itmp = imax;
00572       
00573       enc_Nb(&mPtr,itmp,bSize);
00574     }
00575   }     
00576   writeMap(modelFileName,gTemp,bSize,type,index);
00577   if(debug) quick_look(Map, (char*)filename, Mtype, dbgPt.x, dbgPt.y, 2,'E');
00578   return(0);
00579 }

Here is the call graph for this function:

int read_map_file const char *  filename,
VOIDP  Map,
unsigned char  Mtype,
float  scale_value,
float  offset_value
 

Get the file and read/convert the data of map (array).

Parameters:
filename Input file name
Map Model variable array data
Mtype General data format type
scale_value Variable-scaling multiplier
offset_value Variable-scaling offset
Returns:
byte size of data values

Definition at line 591 of file Driver_Utilities.c.

00594 {
00595   int i, j, k0, size;
00596   unsigned temp;
00597   UCHAR *tmpPtr, Dsize;
00598   
00599 gridSize = (s0+2)*(s1+2);
00600 gTempSize = gridSize*8;
00601 
00602 
00603   size = gridSize*4 +1;
00604   if( size > gTempSize ) { 
00605     if(gTemp) free((char*)gTemp); 
00606     gTemp = (UCHAR*)nalloc( size, "gTemp" );    
00607     gTempSize = size; 
00608   }
00609   
00610   if(debug>2) { 
00611     sprintf(msgStr,"Reading %s\n",filename);  
00612     usrErr(msgStr); 
00613     WriteMsg(msgStr,1); 
00614   } 
00615   
00616   Dsize = readMap(filename,gTemp);
00617   
00618   if(debug) { 
00619     sprintf(msgStr,"name = %s, proc = %d, scale_value = %f, offset_value = %f, size = %x\n ",
00620             filename,procnum,scale_value,offset_value,Dsize);  
00621     WriteMsg(msgStr,1); 
00622   } 
00623   for (i=1; i<=s0; i++) {
00624     for (j=1; j<=s1; j++) {
00625       k0 = Dsize*((i-1)*lcl_size[1] + (j-1));
00626       tmpPtr = gTemp+k0;
00627       switch(Dsize) {
00628         case 1: temp = gTemp[k0]; break;
00629         case 2: temp = gTemp[k0]*256 + gTemp[k0+1]; break;
00630         case 3: temp = gTemp[k0]*65536 + gTemp[k0+1]*256 + gTemp[k0+2]; break;
00631         case 4: temp = gTemp[k0]*16777216 + gTemp[k0+1]*65536 + gTemp[k0+2]*256 + gTemp[k0+3]; break;
00632         default: fprintf(stderr,"ERROR, illegal size: %x\n",Dsize); temp = 0;
00633       }                                         
00634       switch (Mtype) {
00635         case 'f' :
00636           ((float*)Map)[T(i,j)] = scale_value*((float)temp)+offset_value; 
00637         break;
00638         case 'd' : case 'i' :
00639           ((int*)Map)[T(i,j)] = (int)(scale_value * (float)temp + offset_value); 
00640         break;
00641         case 'c' :
00642           ((unsigned char*)Map)[T(i,j)] = (int)(scale_value * (unsigned char)temp); 
00643         break;
00644       }
00645     }
00646   }
00647   if(debug) quick_look(Map, (char*)filename, Mtype, dbgPt.x, dbgPt.y, 2,'E');
00648   link_edges(Map,Mtype);
00649   fflush(stderr);
00650   return Dsize;
00651 }

void print_loc_ave Point3D vt,
void *  Map,
char  Mtype,
char *  mName,
int  tIndex
 

Calculate summary statistics to determine local average.

Parameters:
vt struct of cell points
Map Model variable data array
Mtype the data type of the map data
mName variable name
tIndex the current iteration number

Definition at line 982 of file Driver_Utilities.c.

References Combine(), kAVE, kAVECUM, kSUM, kSUMCUM, lcl_start, ON_MAP, Point3D, T, point3D::type, point3D::x, point3D::y, and point3D::z.

Referenced by write_output().

00983 {
00984   int ix, iy, x, y, x0, y0, range, xmax, ymax, xmin, ymin, type = 11;
00985   float vout[4];
00986   double sum = 0, normCoef = 0;
00987   
00988   if(Mtype != 'f') { fprintf(stderr,"Warning: Wrong type in Loc Ave: %s(%c)\n",mName,Mtype); return; }  
00989   x0 = vt->x;
00990   y0 = vt->y;
00991   range = vt->z;
00992   x = x0 - lcl_start[0]; 
00993   y = y0 - lcl_start[1];
00994   xmin = x - range;
00995   xmax = x + range;
00996   ymin = y - range;
00997   ymax = y + range;
00998   xmax = (xmax > (s0)) ? (s0) : xmax;
00999   xmin = (xmin <  0  ) ?   0  : xmin;
01000   ymax = (ymax > (s1)) ? (s1) : ymax;
01001   ymin = (ymin <  0  ) ?   0  : ymin;
01002   
01003   for(ix=xmin; ix<xmax; ix++)  {
01004     for(iy=ymin; iy<ymax; iy++) { 
01005       if( ON_MAP[T(ix+1,iy+1)] ) sum += ((float*)Map)[T(ix+1,iy+1)];                    
01006       normCoef += 1.0;
01007     }
01008   }
01009   
01010   vout[0] = sum; vout[1] = normCoef;
01011   
01012   switch (vt->type) {
01013      case 's' :  Combine(vout,mName,1,kSUM,tIndex); break; /* Sum for all window cells at outStep iterations */
01014      case 'a' :  Combine(vout,mName,2,kAVE,tIndex); break; /* Average for all window cells at outStep iterations */
01015      case 'A' :  Combine(vout,mName,2,kAVECUM,tIndex); break; /* Cumulative average for all window cells over all outStep iterations */
01016      case 'S' :  Combine(vout,mName,1,kSUMCUM,tIndex); break; /* Cumulative sum for all window cells over all outStep iterations */
01017   }  
01018 }

Here is the call graph for this function:

void write_output int  index,
ViewParm vp,
void *  Map,
const char *  filename,
char  Mtype,
int  step
 

Determine which functions to call for model output.

Parameters:
index Count index of the output iteration for this variable (may be > step)
vp A struct of ViewParm, outlist configuration
Map Model variable array data
filename Output file name
Mtype General output format type
step The current iteration number

Definition at line 408 of file Driver_Utilities.c.

Referenced by gen_output().

00410 {
00411         int i; Point3D point;
00412         
00413 
00414         if(vp->mapType != 'N' ) {
00415                         write_map_file((char*)filename,Map,Mtype,index,vp->scale.s,vp->scale.o,getPrecision(vp),vp->mapType);
00416                         if (debug > 3) calc_maxmin(vp,Map,Mtype,(char*)filename,step);
00417         }
00418         for(i=0; i< (vp->nPoints); i++ ) {
00419                 point = vp->points[i];
00420             if (debug > 3) { sprintf(msgStr,"\nwriting Out: %s(%d): %c(), index = %d, step=%d\n", filename, i, point.type, index, step ); 
00421             WriteMsg(msgStr,1); 
00422             }
00423             
00424                 switch( point.type ) {  
00425                     case 'm': case 'M': calc_maxmin( vp,Map,Mtype,(char*)filename,step); break; 
00426                     case 'w': quick_look( Map,(char*) filename, Mtype, point.x, point.y, point.z, point.format ); break;
00427                     case 'a': case 's': case 'A': case 'S': print_loc_ave( &point, Map, Mtype, (char*)filename, step ); break;
00428                     case 'p': print_point( vp, Map, Mtype, (char*)filename, step, i ); break;
00429                 }
00430         }
00431 }

void print_point ViewParm vp,
void *  Map,
char  Mtype,
char *  mName,
int  tIndex,
int  vpindex
 

Print data at point locations to memory (not to file/disk yet).

Parameters:
vp struct of ViewParm output configuration
Map Array data of variable
Mtype General output format type
mName The name of the variable
tIndex Current model iteration number
vpindex Index of the current point number

Definition at line 846 of file Driver_Utilities.c.

References seriesParm::data, debug, fatal(), lcl_start, seriesParm::Length, seriesParm::Loc, msgStr, N_iter, seriesParm::outstep, PListIndex, Point3D, viewParm::points, pSeries, viewParm::step, T, usrErr(), ViewParm, WriteMsg(), point3D::x, point2D::x, point3D::y, point2D::y, and point3D::z.

Referenced by write_output().

00848 {
00849         int x, y;
00850         Point3D *pt;
00851   
00852         pt = vp->points + vpindex;
00853     x = pt->x - lcl_start[0];
00854     y = pt->y - lcl_start[1];
00855     if(  (x >= 0) && (x < s0)  &&  (y >= 0) && (y < s1)  ) {
00856       if(tIndex==0) { pt->z = PListIndex; pSeries[PListIndex].Length=0; 
00857     }
00858     else PListIndex = pt->z; 
00859     if(tIndex==0) {                     
00860               /* TODO: develop flexible output of calendar-based and julian-based outsteps (jan 11, 2005) */
00861           if(PListIndex >= MAX_PTSERIES ) fatal("Too many Point series.");
00862           else if( pSeries[PListIndex].data == NULL ) pSeries[PListIndex].data = (float*) malloc( (N_iter*sizeof(float)/vp->step)+2 );
00863       if( pSeries[PListIndex].data == NULL ) usrErr("out of Memory for Spatial Timeseries.");
00864           pSeries[PListIndex].Loc.x = pt->x;
00865           pSeries[PListIndex].Loc.y = pt->y;
00866           pSeries[PListIndex].outstep = vp->step; 
00867           strcpy(pSeries[PListIndex].name,mName);
00868           if(debug >2) { 
00869                         sprintf(msgStr,"\nSetup Pointlist %d for %s(%d), step=%d, point=(%d,%d)\n", PListIndex, mName, vpindex, vp->step, x, y ); 
00870                         WriteMsg(msgStr,1); 
00871             }
00872      }
00873       switch(Mtype) {
00874                   case 'f' :  pSeries[PListIndex].data[ pSeries[PListIndex].Length++ ] = ((float*)Map)[T(x+1,y+1)];     break;          
00875                   case 'i' :    pSeries[PListIndex].data[ pSeries[PListIndex].Length++ ] = ((int*)Map)[T(x+1,y+1)]; break;
00876                   case 'c' :  pSeries[PListIndex].data[ pSeries[PListIndex].Length++ ] = ((unsigned char*)Map)[T(x+1,y+1)];
00877       }
00878           if(debug >3) { 
00879                   sprintf(msgStr,"\nWriting Point %d for %s(%d), point=(%d,%d), value = %f, index = %d\n", 
00880                                                         PListIndex, mName, vpindex, x, y, ((float*)Map)[T(x+1,y+1)], pSeries[PListIndex].Length-1 ); 
00881                   WriteMsg(msgStr,1); 
00882           }
00883       PListIndex++;
00884     }
00885 }

Here is the call graph for this function:

void writeWindow void *  fValue,
char *  vName,
char *  desc,
int  x0,
int  y0,
int  N0,
int  N1,
int  index,
UCHAR  Mtype,
UCHAR  format
 

Prepare a local data set for writing a local data window in debug file.

Parameters:
fValue Model variable array data
vName Model variable name
desc Message describing the output
x0 Lower x (row!) value
y0 Lower y (col!) value
N0 Range in x (row!) values
N1 Range in y (col!) values
index Current iteration number
Mtype General output format type
format Numeric format type

Definition at line 760 of file Driver_Utilities.c.

References Copy(), gTemp, gTempSize, s1, T, UCHAR, and writeSeries().

Referenced by quick_look().

00763 {
00764   int mSize, size;
00765   char ctemp[200];
00766   
00767   switch(Mtype) {
00768   case 'l':                             size = sizeof(double); break; /* v2.3.2 added */
00769   case 'f': case 'L': case 'E':         size = sizeof(float); break;
00770   case 'd': case 'i':                   size = sizeof(int);  break;
00771   case 'c':                             size = sizeof(char); break;
00772   }
00773   if( (mSize=size*N0*N1) > gTempSize ) {
00774     if(gTemp != NULL) free((char*)gTemp);
00775     gTemp = (UCHAR*)malloc(gTempSize=mSize);
00776   }
00777   
00778   Copy(((UCHAR*)fValue)+T(x0,y0)*size, gTemp, N1*size, N0, (s1+2)*size, N1*size);
00779   sprintf(ctemp,"(%d)WIND: %s",index,vName);
00780   writeSeries(gTemp,ctemp,desc,N0,N1,Mtype,format);
00781 }

Here is the call graph for this function:

void calc_maxmin ViewParm vp,
void *  Map,
char  Mtype,
char *  mName,
int  step
 

Calculate maximum & minimum values in model output arrays.

For each model variable to be output (info in ViewParm struct), calculate the maximum and minimum values across the variable's spatial array.

Parameters:
vp struct of ViewParm data
Map Model variable array data
Mtype General output format type
mName Variable name
step The current iteration number

Definition at line 328 of file Driver_Utilities.c.

References Combine(), viewParm::gScale, kMAXMIN, ON_MAP, T, ViewParm, scale2::Vmax, and scale2::Vmin.

Referenced by write_output().

00329 {
00330   int ix, iy;
00331   float vout[4], ftmp, fmax = -1000, fmin = 1000;
00332   
00333   switch(Mtype) {
00334   case 'f' :    
00335     for(ix=1; ix<=s0; ix++) 
00336       for(iy=1; iy<=s1; iy++) {
00337         if( ON_MAP[T(ix,iy)] ) {
00338           if( (ftmp = ((float*)Map)[T(ix,iy)]) > fmax ) {
00339             fmax = ftmp; 
00340           }
00341           if( ftmp < fmin ) fmin = ftmp;
00342         }
00343       }
00344     break;
00345   case 'i' :    case 'd' :      
00346     for(ix=1; ix<=s0; ix++) 
00347       for(iy=1; iy<=s1; iy++) {
00348         if( ON_MAP[T(ix,iy)] ) {
00349           if((ftmp = ((int*)Map)[T(ix,iy)]) > fmax ) fmax = ftmp;
00350           if( ftmp < fmin ) fmin = ftmp;
00351         }
00352       }
00353     break;
00354   case 'c' :    
00355     for(ix=1; ix<=s0; ix++) 
00356       for(iy=1; iy<=s1; iy++) {
00357         if( ON_MAP[T(ix,iy)] ) {
00358           if( (ftmp = (float)((unsigned char*)Map)[T(ix,iy)]) > fmax ) fmax = ftmp;
00359           if( ftmp < fmin ) fmin = ftmp;
00360         }
00361       } 
00362     break;
00363   }
00364   if(step==0) {
00365     vp->gScale.Vmax = fmax;
00366     vp->gScale.Vmin = fmin;
00367   } else {
00368     if( fmax > vp->gScale.Vmax ) vp->gScale.Vmax = fmax;
00369     if( fmin < vp->gScale.Vmin ) vp->gScale.Vmin = fmin;
00370   }
00371   vout[0] = fmax; vout[1] = vp->gScale.Vmax; vout[2] = fmin; vout[3] = vp->gScale.Vmin;
00372   Combine(vout,mName,4,kMAXMIN,step); /* Iterative and cumulative, maximum and minimum values for all window cells at outstep iterations */
00373 }

Here is the call graph for this function:

void quick_look void *  Map,
char *  name,
unsigned char  Mtype,
int  xc,
int  yc,
int  range,
unsigned char  format
 

Prepare data and write heading for writing a data window in debug file.

Parameters:
Map Model variable array data
name Model variable name
Mtype General output format type
xc Point location x (row!)
yc Point location y (col!)
range Size range (cells) of window
format Numeric format type

Definition at line 719 of file Driver_Utilities.c.

References debug, iclip(), istep, lcl_start, msgStr, name_from_path(), on_this_proc(), recpnum, s0, s1, and writeWindow().

Referenced by read_map_file(), write_map_file(), and write_output().

00721 {
00722   int ymin, ymax, xmin, xmax, x, y, N0, N1;
00723   char* namePtr;
00724 
00725   if (!on_this_proc(xc,yc)) return;
00726   x = xc - lcl_start[0] + 1;
00727   y = yc - lcl_start[1] + 1;
00728   xmin = x - range;
00729   xmax = x + range + 1;
00730   ymin = y - range;
00731   ymax = y + range + 1;
00732   xmax = iclip( xmax, 0, s0+2);
00733   xmin = iclip( xmin, 0, s0+2);
00734   ymax = iclip( ymax, 0, s1+2);
00735   ymin = iclip( ymin, 0, s1+2);
00736   N0 = xmax-xmin;
00737   N1 = ymax-ymin;
00738   namePtr = name_from_path(name);
00739   if (debug >3) {
00740     sprintf(msgStr,"Window to Map %s, s=%d, proc0 = %d, proc1 = %d; Corners(gbl): (%d,%d) (%d,%d)\n",
00741             namePtr,range,recpnum[0],recpnum[1],xc-range,yc-range,xc+range+1,yc+range+1);
00742     writeWindow(Map,namePtr,msgStr,xmin,ymin,N0,N1,istep,Mtype,format);
00743   }
00744   
00745 }

Here is the call graph for this function:

int iclip int  x0,
int  min,
int  max
 

Constrain x0 value within a min and a max.

Parameters:
x0 number to work on
min the minimum
max the maximum
Returns:
result

Definition at line 789 of file Driver_Utilities.c.

Referenced by quick_look().

00790 {
00791   int rv;
00792   rv = ( x0 > max) ?  max : x0;
00793   rv = ( rv < min) ?  min : rv;
00794   return rv;
00795 }

void make_more_points ViewParm vp,
int  ptIncr
 

Allocate memory & set up another set of point-locations for output.

For each model variable to be output (info in ViewParm struct), increment the number of point-locations (cells) based on the number requested in the model output configuration file.

Parameters:
vp Pointer to struct of ViewParm
ptIncr number of points to increment

Definition at line 296 of file Driver_Utilities.c.

References viewParm::fileName, viewParm::maxPoints, msgStr, Point3D, viewParm::points, point3D::type, ViewParm, WriteMsg(), point3D::x, point3D::y, and point3D::z.

Referenced by readViewParms().

00297 {
00298         Point3D *new_pts;
00299         int i;
00300         
00301         new_pts = (Point3D *) malloc( (vp->maxPoints+ptIncr) * sizeof(Point3D) );
00302         for(i=0; i < vp->maxPoints; i++) {
00303                 new_pts[i].x = vp->points[i].x;
00304                 new_pts[i].y = vp->points[i].y;
00305                 new_pts[i].z = vp->points[i].z;
00306                 new_pts[i].type = vp->points[i].type;
00307         }
00308         if( vp->points != NULL ) { free((char*)vp->points); }
00309         vp->points = new_pts;
00310         vp->maxPoints += ptIncr;
00311         if(debug) {
00312                 sprintf(msgStr,"Made %d more points for %s for %d total points",ptIncr,vp->fileName,vp->maxPoints); 
00313                 WriteMsg(msgStr,1);
00314         }
00315 }

Here is the call graph for this function:

void enc_Nb UCHAR **  sptr,
SLONG  value,
int  bytes
 

Place data in bytes into a buffer to assemble a binary array.

Place a 1,2,3, or 4 (N) byte signed value into the specified buffer and advance the buffer pointer past the placed object.

Parameters:
sptr a pointer to pointer to UCHAR (the buffer)
value The value to place in the buffer
bytes Number of bytes in data

Definition at line 678 of file Driver_Utilities.c.

References UCHAR.

Referenced by write_map_file().

00679 {
00680   UCHAR tmp[4];
00681   switch(bytes) {
00682   case 1:
00683     *(*sptr)++ = value;
00684     break;
00685   case 2:
00686     *(*sptr)++ = (value >> 8);
00687     *(*sptr)++ = value;
00688     break;
00689   case 3:
00690     tmp[0] = value;
00691     tmp[1] = (value >>= 8);
00692     tmp[2] = (value >> 8);
00693     *(*sptr)++ = tmp[2];
00694     *(*sptr)++ = tmp[1];
00695     *(*sptr)++ = tmp[0];
00696     break;
00697   case 4:
00698     tmp[0] = value;
00699     tmp[1] = (value >>= 8);
00700     tmp[2] = (value >>= 8);
00701     tmp[3] = (value >> 8);
00702     *(*sptr)++ = tmp[3];
00703     *(*sptr)++ = tmp[2];
00704     *(*sptr)++ = tmp[1];
00705     *(*sptr)++ = tmp[0];
00706     break;
00707   }
00708 }

void RP_SwapFields RPoint thisStruct,
RPoint that
 

Point Time Series interpolation (unused):.

Definition at line 1246 of file Driver_Utilities.c.

References RP_CopyFields(), and RPoint.

Referenced by RPL_Sort().

01247 {
01248   RPoint temp;
01249   RP_CopyFields (&temp, thisStruct);
01250   RP_CopyFields (thisStruct, that);
01251   RP_CopyFields (that, &temp);
01252 }

Here is the call graph for this function:

void RP_CopyFields RPoint thisStruct,
RPoint that
 

Point Time Series interpolation (unused):.

Definition at line 1237 of file Driver_Utilities.c.

References rPoint::fr, rPoint::fValue, rPoint::fX, rPoint::fY, and RPoint.

Referenced by RP_SwapFields(), and RPL_AddrPoint().

01238 {
01239   thisStruct->fX = that->fX;
01240   thisStruct->fY = that->fY;
01241   thisStruct->fr = that->fr;
01242   thisStruct->fValue = that->fValue;
01243 }

void RP_SetFields RPoint thisStruct,
int  ix,
int  iy,
float  r,
float  value
 

Point Time Series interpolation (unused):.

Definition at line 1228 of file Driver_Utilities.c.

References rPoint::fr, rPoint::fValue, rPoint::fX, rPoint::fY, and RPoint.

Referenced by RPL_AddrPoint().

01229 {
01230   thisStruct->fX = ix;
01231   thisStruct->fY = iy;
01232   thisStruct->fr = r;
01233   thisStruct->fValue = value;   
01234 }

void RPL_AddrPoint RPointList thisStruct,
int  x,
int  y,
float  r,
float  value
 

Point Time Series interpolation (unused):.

Definition at line 1266 of file Driver_Utilities.c.

References rPointList::fList, rPointList::fNPt, rPointList::fNPtUsed, RP_CopyFields(), RP_SetFields(), RPoint, and RPointList.

Referenced by PTSL_GetInterpolatedValue1().

01267 {
01268   RPoint* pointListtemp;
01269   int i, newPoints;
01270   
01271   if( thisStruct->fNPtUsed >= thisStruct->fNPt ) {
01272     newPoints = 20;
01273     thisStruct->fNPt += newPoints;
01274     pointListtemp = (RPoint*) malloc(sizeof(RPoint)*(thisStruct->fNPt));
01275     for(i=0; i<thisStruct->fNPtUsed; i++) {
01276       RP_CopyFields(pointListtemp+i,thisStruct->fList+i);
01277     }
01278     if( thisStruct->fList != NULL ) free((char*)thisStruct->fList);
01279     thisStruct->fList = pointListtemp;
01280   }
01281   
01282   RP_SetFields( thisStruct->fList + thisStruct->fNPtUsed, x, y, r, value);
01283   thisStruct->fNPtUsed++;
01284 }

Here is the call graph for this function:

void RPL_Sort RPointList thisStruct  ) 
 

Point Time Series interpolation (unused):.

Definition at line 1287 of file Driver_Utilities.c.

References rPointList::fList, rPointList::fNPtUsed, rPoint::fr, RP_SwapFields(), and RPointList.

Referenced by PTSL_GetInterpolatedValue1().

01288 {
01289   int i, go=1;
01290   
01291   while(go) {
01292     go = 0;
01293     for(i=1; i<thisStruct->fNPtUsed; i++) if(thisStruct->fList[i-1].fr > thisStruct->fList[i].fr) {
01294       RP_SwapFields (thisStruct->fList+i-1, thisStruct->fList+i);
01295       go = 1;
01296     }
01297   }             
01298 }

Here is the call graph for this function:

void RPL_Free RPointList thisStruct  ) 
 

Point Time Series interpolation (unused):.

Definition at line 1302 of file Driver_Utilities.c.

References rPointList::fList, and RPointList.

Referenced by PTSL_GetInterpolatedValue1().

01303 {
01304   if(thisStruct == NULL) return;
01305    if( thisStruct->fList != NULL ) free((char*)thisStruct->fList);
01306   free((char*)thisStruct);
01307   thisStruct = NULL;
01308 }

RPointList* RPL_Init int  nPoints  ) 
 

Point Time Series interpolation (unused):.

Definition at line 1255 of file Driver_Utilities.c.

References rPointList::fList, rPointList::fNPt, rPointList::fNPtUsed, RPoint, and RPointList.

Referenced by PTSL_GetInterpolatedValue1().

01256 {
01257   RPointList *thisStruct;
01258   thisStruct = (RPointList*) malloc(sizeof(RPointList));
01259   thisStruct->fList = (RPoint*) malloc(sizeof(RPoint)*nPoints);
01260   thisStruct->fNPt = nPoints;
01261   thisStruct->fNPtUsed = 0;
01262   return thisStruct;
01263 }

void PTS_CopyFields PTSeries thisStruct,
PTSeries  pV
 

Point Time Series interpolation (unused): copy fields.

Definition at line 1048 of file Driver_Utilities.c.

References pTSeries::fValue, pTSeries::fX, pTSeries::fY, and PTSeries.

Referenced by PTSL_AddpTSeries().

01049 {
01050   thisStruct->fX = pV.fX;
01051   thisStruct->fY = pV.fY;
01052   thisStruct->fValue = pV.fValue;
01053 }

void PTS_Free PTSeries thisStruct  ) 
 

Point Time Series interpolation (unused): free up memory.

Definition at line 1041 of file Driver_Utilities.c.

References pTSeries::fValue, and PTSeries.

Referenced by PTSL_Free().

01042 {
01043   if(thisStruct->fValue) free((char*)thisStruct->fValue);
01044 }

void PTS_SetFields PTSeries thisStruct,
int  ix,
int  iy,
int  index,
int  format,
int  col
 

Point Time Series interpolation (unused): set up the fields.

Definition at line 1022 of file Driver_Utilities.c.

References debug, pTSeries::fNpt, pTSeries::fTS, pTSeries::fValue, pTSeries::fX, pTSeries::fY, gNPtTs, gTS, modelFileName, msgStr, PTSeries, readSeriesCol(), and WriteMsg().

01024 {
01025   float ptstep = 1.0, *value; 
01026   int n0;
01027   
01028   thisStruct->fX = ix;
01029   thisStruct->fY = iy;
01030   if(thisStruct->fValue) free((char*)thisStruct->fValue); 
01031 
01032   thisStruct->fValue = readSeriesCol(modelFileName,format,index,&n0,&ptstep,col);
01033   
01034   gNPtTs = thisStruct->fNpt = n0;
01035   gTS = thisStruct->fTS = ptstep;
01036   value = thisStruct->fValue;
01037   if  ( debug>2 ) {  sprintf(msgStr,"\nPTS_SetFields: TSVals: %f %f %f, TS: %f, NPt: %d \n",value[0],value[1],value[2],ptstep,n0);  WriteMsg(msgStr,1); }
01038 }

Here is the call graph for this function:

void PTSL_AddpTSeries PTSeriesList thisStruct,
int  x,
int  y,
int  index,
int  seriesNum,
int  col
 

Point Time Series interpolation (unused): add to the series.

Definition at line 1071 of file Driver_Utilities.c.

References pTSeriesList::fList, pTSeries::fNpt, pTSeriesList::fNptTS, pTSeriesList::fNSlots, pTSeriesList::fNSlotsUsed, pTSeries::fValue, Max, PTS_CopyFields(), PTSeries, and PTSeriesList.

Referenced by PTSL_ReadLists().

01072 {
01073   PTSeries* valListtemp;
01074   int i, newSlots;
01075   
01076   if( seriesNum >= thisStruct->fNSlots ) {
01077     newSlots = Max(20,(int)(thisStruct->fNSlots * 0.2));
01078     thisStruct->fNSlots += newSlots;
01079     valListtemp = (PTSeries*) malloc(sizeof(PTSeries)*(thisStruct->fNSlots));
01080     for(i=0; i<thisStruct->fNSlotsUsed; i++) {
01081       valListtemp[i].fNpt = thisStruct->fNptTS;
01082       PTS_CopyFields(valListtemp+i,thisStruct->fList[i]);
01083     }
01084     for(i=thisStruct->fNSlotsUsed; i<thisStruct->fNSlots; i++) valListtemp[i].fValue = NULL;
01085     if( thisStruct->fList != NULL ) free((char*)thisStruct->fList);
01086     thisStruct->fList = valListtemp;
01087   }
01088   
01089   PTS_SetFields( thisStruct->fList + seriesNum, x, y, index, thisStruct->fFormat, col );
01090   thisStruct->fNSlotsUsed = seriesNum;
01091 }

Here is the call graph for this function:

void PTSL_Free PTSeriesList thisStruct  ) 
 

Point Time Series interpolation (unused): free up memory.

Definition at line 1094 of file Driver_Utilities.c.

References pTSeriesList::fList, pTSeriesList::fNSlotsUsed, PTS_Free(), and PTSeriesList.

01095 {
01096   int i;
01097   if(thisStruct == NULL) return;
01098   for(i=0; i<thisStruct->fNSlotsUsed; i++) PTS_Free( thisStruct->fList +i );
01099   if( thisStruct->fList != NULL ) free((char*)thisStruct->fList);
01100   free((char*)thisStruct);
01101   thisStruct = NULL;
01102 }

Here is the call graph for this function:

void PTSL_ReadLists PTSeriesList thisStruct,
const char *  ptsFileName,
int  index,
float *  timeStep,
int *  nPtTS,
int  col
 

Point Time Series interpolation (unused): read raw point data.

Definition at line 1135 of file Driver_Utilities.c.

References broadcastInt(), debug, Exit(), H_OPSYS, Lprocnum, modelFileName, ModelPath, msgStr, ProjName, PTSeriesList, PTSL_AddpTSeries(), usrErr(), and WriteMsg().

01137 {
01138   char pathname[150], infilename[60], ss[201], ret = '\n';
01139   FILE* cfile;
01140   int ix, iy, tst, sCnt=0;
01141   if( Lprocnum == 1 ) {
01142     if(H_OPSYS==UNIX) sprintf(modelFileName,"%s/%s/Data/%s.pts",ModelPath,ProjName,ptsFileName);
01143     else sprintf(modelFileName,"%s%s:Data:%s.pts",ModelPath,ProjName,ptsFileName); 
01144     cfile = fopen(modelFileName,"r");
01145     if(cfile==NULL) {fprintf(stdout,"\nERROR: Unable to open timeseries file %s\n",modelFileName); Exit(1); }
01146     else { sprintf(msgStr,"\nReading file %s\n",modelFileName); WriteMsg(msgStr,1); } 
01147     if (debug > 2) {sprintf(msgStr,"Reading %s timeseries, column %d",modelFileName, col); usrErr(msgStr);}
01148     
01149   
01150 
01151     fgets(ss,200,cfile); /* skip header line */
01152   }
01153   while(1) {
01154     if( Lprocnum == 1 ) {
01155       tst = fscanf(cfile,"%d",&ix);
01156       if( tst > 0  ) {
01157         fscanf(cfile,"%d",&iy); 
01158         tst = fscanf(cfile,"%s",infilename); 
01159         sprintf(modelFileName,"%s/%s/Data/%s",ModelPath,ProjName,infilename);
01160       }
01161     }
01162     broadcastInt(&tst); 
01163     if(tst<1) break;
01164     broadcastInt(&ix); 
01165     broadcastInt(&iy); 
01166     PTSL_AddpTSeries(thisStruct, ix, iy, index, sCnt, col);
01167     sCnt++;
01168   }
01169   if( Lprocnum == 1 ) fclose(cfile);  
01170   *nPtTS = gNPtTs;
01171   *timeStep = gTS;
01172 } 

Here is the call graph for this function:

void PTSL_CreatePointMap PTSeriesList pList,
void *  Map,
unsigned char  Mtype,
int  step,
float  scale
 

Point Time Series interpolation (unused): generate interpolated spatial (map) data.

Definition at line 1175 of file Driver_Utilities.c.

References ON_MAP, PTSeriesList, PTSL_GetInterpolatedValue0(), s0, s1, and T.

01177 {
01178   int i0, i1;
01179   
01180   switch(Mtype) {
01181   case 'f' :    
01182     for(i0=0; i0<=s0+1; i0++) 
01183       for(i1=0; i1<=s1+1; i1++) 
01184         ((float*)Map)[T(i0,i1)] = (ON_MAP[T(i0,i1)]) ? PTSL_GetInterpolatedValue0(pList,i0,i1,step)*scale : 0.0 /*was this value (v0.5beta) -0.012 */; 
01185     break;
01186   case 'i' :    case 'd' :      
01187     for(i0=0; i0<=s0+1; i0++) 
01188       for(i1=0; i1<=s1+1; i1++) 
01189         ((int*)Map)[T(i0,i1)] = (int)  ( (ON_MAP[T(i0,i1)]) ? PTSL_GetInterpolatedValue0(pList,i0,i1,step)*scale : 0 );
01190     break;
01191   case 'c' :    
01192     for(i0=0; i0<=s0+1; i0++) 
01193       for(i1=0; i1<=s1+1; i1++) 
01194         ((unsigned char*)Map)[T(i0,i1)] = (unsigned char) '\0' + (int)  ( (ON_MAP[T(i0,i1)]) ? PTSL_GetInterpolatedValue0(pList,i0,i1,step)*scale : 0 );
01195     break;
01196   }
01197 }

Here is the call graph for this function:

float PTSL_GetInterpolatedValue1 PTSeriesList thisStruct,
int  x,
int  y,
int  step
 

Point Time Series interpolation (unused): at point, calculate inverse distance interpolation (unrestricted power of distance).

Definition at line 1200 of file Driver_Utilities.c.

References pTSeriesList::fList, pTSeriesList::fNSlotsUsed, pTSeries::fValue, pTSeries::fX, pTSeries::fY, PTSeries, PTSeriesList, RPL_AddrPoint(), RPL_Free(), RPL_Init(), RPL_Sort(), and RPointList.

01201 {
01202   int i,  dx, dy;
01203   PTSeries pV;
01204   RPointList *pList;
01205   float  wpow;
01206   double weight, InterpValue=0.0, distance=0.0;
01207   long r;
01208   
01209   pList = RPL_Init( 20 );
01210   wpow = GP_IDW_pow; /* GP_IDW_pow is "adjustable" parameter in global parm input file */
01211   for(i=0; i<thisStruct->fNSlotsUsed; i++) {
01212     pV = thisStruct->fList[i];
01213     dx = (pV.fX-x);
01214     dy = (pV.fY-y);
01215     r = dx*dx + dy*dy;
01216     if( r == 0 ) return pV.fValue[step];
01217     RPL_AddrPoint(pList, dx, dy, r, pV.fValue[step]);
01218     weight = (wpow == 1.0) ? ((double)1.0)/r : pow(r,-wpow);
01219     InterpValue += pV.fValue[step]*weight;
01220     distance += weight;
01221   }
01222   RPL_Sort(pList);
01223   RPL_Free(pList);
01224   return (float) InterpValue;
01225 }

Here is the call graph for this function:

float PTSL_GetInterpolatedValue0 PTSeriesList thisStruct,
int  x,
int  y,
int  step
 

Point Time Series interpolation (unused): at point, calculate inverse distance squared interpolation (restricted, not using pow() function).

Definition at line 1105 of file Driver_Utilities.c.

References pTSeriesList::fList, pTSeriesList::fNSlotsUsed, pTSeries::fValue, pTSeries::fX, pTSeries::fY, lcl_start, PTSeries, and PTSeriesList.

Referenced by PTSL_CreatePointMap().

01106 {
01107   int i,  dx, dy, my_debug;
01108   PTSeries pV;
01109   float  wpow;
01110   float weight, InterpValue=0.0, distance=0.0; /* was double in v1.0 */
01111   int r;
01112   
01113   wpow = GP_IDW_pow; /* GP_IDW_pow is "adjustable" parameter in global parm input file */
01114 
01115   
01116   for(i=0; i<thisStruct->fNSlotsUsed; i++) {
01117     pV = thisStruct->fList[i];
01118     dx = (pV.fX-(x+lcl_start[0]));
01119     dy = (pV.fY-(y+lcl_start[1]));
01120     r = (dx*dx + dy*dy);
01121     if( r == 0 ) return pV.fValue[step];
01122     weight = (wpow == 1.0) ? (1.0)/r : 1.0/(r*r);
01123         /* the pow() and double was incredibly slow (signif slowed simualtion), so removed it
01124            and gave the choice of only inverse distance or inverse distance**2 weighting */
01125     /* weight = (wpow == 1.0) ? ( (double)1.0)/r : pow(r,-wpow) ; */
01126     InterpValue += pV.fValue[step]*weight;
01127     distance += weight;
01128   }
01129   if (distance > 0) InterpValue /= distance;
01130   else InterpValue = (thisStruct->fList[0]).fValue[step];
01131   return (float) InterpValue;
01132 }

PTSeriesList* PTSL_Init int  nSlots,
int  format
 

Point Time Series interpolation (unused): initialize structure.

Definition at line 1056 of file Driver_Utilities.c.

References pTSeriesList::fFormat, pTSeriesList::fList, pTSeriesList::fNptTS, pTSeriesList::fNSlots, pTSeriesList::fNSlotsUsed, pTSeries::fValue, PTSeries, and PTSeriesList.

01057 {
01058   int i;
01059   PTSeriesList* thisStruct;
01060   thisStruct = (PTSeriesList*) malloc(sizeof(PTSeriesList));
01061   thisStruct->fList = (PTSeries*) malloc(sizeof(PTSeries)*nSlots);
01062   for(i=0; i<nSlots; i++) thisStruct->fList[i].fValue = NULL;
01063   thisStruct->fNSlots = nSlots;
01064   thisStruct->fNSlotsUsed = 0;
01065   thisStruct->fNptTS = 0;
01066   thisStruct->fFormat = format;
01067   return(thisStruct);
01068 }

void calcdate double  jd,
int *  m,
int *  d,
int *  y,
int *  h,
int *  mi,
double *  sec
 

Determine the Gregorian date from a Julian calendar day.

Julian date converter. Takes a julian date (the number of days since some distant epoch or other), and returns an int pointer to static space. ip[0] = month; ip[1] = day of month; ip[2] = year (actual year, like 1977, not 77 unless it was 77 a.d.); ip[3] = day of week (0->Sunday to 6->Saturday) These are Gregorian. Copied from Algorithm 199 in Collected algorithms of the CACM Author: Robert G. Tantzen, Translator: Nat Howard. All taken (unmodified) from SFWMD HSM's /vol/hsm/src/libs/xmgr_julday/ directory.

Parameters:
jd Julian day
m Month
d Day
y Year
h Hour
mi Minute
sec Second

Definition at line 1547 of file Driver_Utilities.c.

01548 {
01549   static int ret[4];
01550 
01551   long j = (long)jd;
01552   double tmp, frac = jd - j;
01553 
01554   if (frac >= 0.5) {
01555     frac = frac - 0.5;
01556     j++;
01557   } 
01558   else {
01559     frac = frac + 0.5;
01560   }
01561 
01562   ret[3] = (j + 1L) % 7L;
01563   j -= 1721119L;
01564   *y  = (4L * j - 1L) / 146097L;
01565   j = 4L * j - 1L - 146097L * *y;
01566   *d  = j / 4L;
01567   j = (4L * *d + 3L) / 1461L;
01568   *d = 4L * *d + 3L - 1461L * j;
01569   *d = (*d + 4L) / 4L;
01570   *m = (5L * *d - 3L) / 153L;
01571   *d = 5L * *d - 3 - 153L * *m;
01572   *d = (*d + 5L) / 5L;
01573   *y = 100L * *y + j;
01574   if (*m < 10)
01575     *m += 3;
01576   else {
01577     *m -= 9;
01578     *y += 1;
01579   }
01580   tmp = 3600.0 * (frac * 24.0);
01581   *h = (int) (tmp / 3600.0);
01582   tmp = tmp - *h * 3600.0;
01583 
01584   *mi = (int) (tmp / 60.0);
01585   *sec = tmp - *mi * 60.0;
01586 }

double julday int  mon,
int  day,
int  year,
int  h,
int  mi,
double  se
 

Determine the Julian calendar day from a Gregorian date.

Returns:
julian day + hms as a real number
Takes a date, and returns a Julian day. A Julian day is the number of days since some base date (in the very distant past). Handy for getting date of x number of days after a given Julian date (use jdate to get that from the Gregorian date). Author: Robert G. Tantzen, translator: Nat Howard Translated from the algol original in Collected Algorithms of CACM (This and jdate are algorithm 199). All taken (unmodified) from SFWMD HSM's /vol/hsm/src/libs/xmgr_julday/ directory.

Parameters:
mon Month
day Day
year Year
h Hour
mi Minute
se Second
Returns:
Julian day

Definition at line 1500 of file Driver_Utilities.c.

01501 {
01502   long m = mon, d = day, y = year;
01503   long c, ya, j;
01504   double seconds = h * 3600.0 + mi * 60 + se;
01505 
01506   if (m > 2)
01507     m -= 3;
01508   else {
01509     m += 9;
01510     --y;
01511   }
01512   c = y / 100L;
01513   ya = y - (100L * c);
01514   j = (146097L * c) / 4L + (1461L * ya) / 4L + (153L * m + 2L) / 5L + d + 1721119L;
01515   if (seconds < 12 * 3600.0) {
01516     j--;
01517     seconds += 12.0 * 3600.0;
01518   } 
01519   else {
01520     seconds = seconds - 12.0 * 3600.0;
01521   }
01522   return (j + (seconds / 3600.0) / 24.0);
01523 }

float FMOD float  x,
float  y
 

Modulus of a pair of (double) arguments.

Parameters:
x Numerator
y Denominator
Returns:
modulus (float) result

Definition at line 1592 of file Driver_Utilities.c.

01592                              { 
01593 return (float)fmod((double)x, (double)y); 
01594 } 

void setup_grid  ) 
 

Provide the 2D array size for the model domain.

Definition at line 376 of file Driver_Utilities.c.

References exgridsize(), gbl_size, gridSize, gTemp, gTempSize, lcl_size, lcl_start, msgStr, nalloc(), procnum, s0, s1, UCHAR, ViewParm, and WriteMsg().

00376                   {
00377   
00378   exgridsize(procnum,gbl_size,lcl_size,lcl_start); /* effectively unused in serial (non-parallel) implementation */
00379 
00380   /*  s0 and s1 remain unchanged in serial (non-parallel) implementation */
00381   s0 = lcl_size[0];
00382   s1 = lcl_size[1];
00383   
00384   gridSize = (s0+2)*(s1+2); /* the gridSize is increased by 2 in each dimension for buffer strips around processor domain(s) (functional mainly to parallel implementation) */
00385   
00386   sprintf(msgStr,"\nGRID DATA::[ gsize: (%d, %d), lstart: (%d, %d), lend: (%d, %d), lsize: (%d, %d) ]\n",
00387           gbl_size[0], gbl_size[1], lcl_start[0], 
00388           lcl_start[1], lcl_start[0]+lcl_size[0]-1, 
00389           lcl_start[1]+lcl_size[1]-1, lcl_size[0], lcl_size[1] );
00390   WriteMsg(msgStr,1);  
00391   sprintf(msgStr,"\nVP DATA:: size: (%d), Variable sizes: float: %d, int: %d, long: %d,  double: %d\n", 
00392             sizeof(ViewParm), sizeof(float),sizeof(int) ,sizeof(long) ,sizeof(double)   );
00393   WriteMsg(msgStr,1);
00394 
00395   gTempSize = gridSize*8;
00396   gTemp = (UCHAR*) nalloc(gTempSize,"gTemp");  
00397 }

Here is the call graph for this function:

void set_env_vars void   ) 
 

Acquire necessary environment variables.

Definition at line 817 of file Driver_Utilities.c.

References DriverPath, ModelPath, msgStr, OS_TYPE, ProjName, and usrErr().

00817                         {
00818   
00819   FILE *infile;
00820   char filename[100], ch;
00821   static long start;
00822   int i, maxLen =200;
00823   
00824     ModelPath = getenv("ModelPath"); 
00825     ProjName = getenv("ProjName");
00826     DriverPath = getenv("DriverPath");
00827     OS_TYPE = getenv("OSTYPE"); /* OSTYPE not used in code, only here for informational output */
00828 
00829         sprintf(msgStr,"OS type = %s ",OS_TYPE); 
00830     usrErr(msgStr);
00831     
00832         sprintf(msgStr,"Project Name = %s ",ProjName); 
00833     usrErr(msgStr);
00834  
00835 }

Here is the call graph for this function:

void set_boundary VOIDP  Map,
unsigned char  Mtype,
float  bv
 

void fatal const char *  msg  ) 
 

Exit (code=9) from program after sending a message.

Definition at line 1468 of file Driver_Utilities.c.

01469 {
01470   printf("%s",msg);
01471   fflush(stdout);
01472   Exit(9);
01473 }

void Exit int  code  ) 
 

Standard exit from program.

Definition at line 1465 of file Driver_Utilities.c.

Referenced by fatal(), get_global_parm(), nalloc(), PTSL_ReadLists(), and read_map_dims().

01465 { exit(code); }

void Copy void *  src,
void *  dst,
int  w,
int  n,
int  sw,
int  dw
 

Memory-copy data from large (global) domain to local domain.

Parameters:
src The source of info
dst The destination of info
w The number of characters
n The number of (row) repetitions
sw The source size in col direction
dw The destination size in col direction
Returns:
resulting (destination) copy

Definition at line 806 of file Driver_Utilities.c.

References UCHAR.

Referenced by writeWindow().

00807 {
00808   int i;
00809   for(i=0; i<n; i++) 
00810     memcpy( ((UCHAR*)dst)+i*dw, ((UCHAR*)src)+i*sw, w ); /* copy w chars from source to dest, return destination */
00811 }

void getInt FILE *  inFile,
const char *  lString,
int *  iValPtr
 

Get an integer following a specific string.

Parameters:
inFile File that is open
lString The string being read
iValPtr The char value found

Definition at line 1657 of file Driver_Utilities.c.

01658 {
01659   int test;
01660   UCHAR iEx=0;
01661   if(lString)  
01662     scan_forward(inFile,lString);
01663   test = fscanf(inFile,"%d",iValPtr);
01664   if(test != 1) {
01665     fprintf(stderr,"Read Error (%d):",test);
01666     if(lString) fprintf(stderr,"%s\n",lString);
01667     *iValPtr = 0;
01668     iEx = 1;
01669   }
01670   if (iEx) exit(0);
01671 }

void getChar FILE *  inFile,
const char *  lString,
char *  cValPtr
 

Get a character following a specific string.

Parameters:
inFile File that is open
lString The string being read
cValPtr The char value found

Definition at line 1619 of file Driver_Utilities.c.

01620 {
01621   int test;
01622   UCHAR iEx=0;
01623   if(lString)  scan_forward(inFile,lString);
01624   test = fscanf(inFile,"%c",cValPtr);
01625   if(test != 1) {
01626     fprintf(stderr,"Read Error (%d):",test);
01627     if(lString) fprintf(stderr,"%s\n",lString);
01628     iEx = 1;
01629     *cValPtr = '\0';
01630   }
01631   if (iEx) exit(0);
01632 }

void getString FILE *  inFile,
const char *  lString,
char *  inString
 

Get a string following a specific string.

Parameters:
inFile File that is open
lString The string being read
inString The string found

Definition at line 1639 of file Driver_Utilities.c.

References scan_forward(), and UCHAR.

Referenced by get_parmf().

01640 {
01641   int test;
01642   UCHAR iEx=0;
01643   if(lString)  scan_forward(inFile,lString);
01644   test = fscanf(inFile,"%s",inString);
01645   if(test != 1) {
01646     fprintf(stderr,"Read Error (%d):",test);
01647     if(lString) fprintf(stderr,"%s\n",lString);
01648     iEx = 1;
01649   }
01650   if (iEx) exit(0);
01651 }

Here is the call graph for this function:

void getFloat FILE *  inFile,
const char *  lString,
float *  fValPtr
 

Get a float value following a specific string.

Parameters:
inFile File that is open
lString The string being read
fValPtr The float number found

Definition at line 1600 of file Driver_Utilities.c.

References scan_forward(), and UCHAR.

Referenced by get_parmf().

01601 {
01602   int test, fSize;
01603   UCHAR iEx=0;
01604   if(lString)  scan_forward(inFile,lString);
01605   test = fscanf(inFile,"%f",fValPtr);
01606   if(test != 1) {
01607     fprintf(stderr,"Read Error (%d):",test);
01608     if(lString) fprintf(stderr,"%s\n",lString);
01609     *fValPtr = 0.0;
01610     iEx = 1;
01611   }
01612   if (iEx) exit(0);
01613 }

Here is the call graph for this function:

void setFlag ViewParm vp,
UINT  mask,
int  value
 

(Effectively unused). From Model.outList data, set a flag indicating array or not

In reading the Model.outList, each line pertain to either a 2D array (variable) or a non-array varible/parameter. This function pertains to very early version of ELM (translating Stella models), and Model.outList always refers to variables that are arrays.

Parameters:
vp struct of ViewParm w/ output configuration
mask array mask
value is always = 1 (is an array)

Definition at line 1322 of file Driver_Utilities.c.

References viewParm::flags, and ViewParm.

Referenced by readViewParms().

01323  { 
01324   if(value) vp->flags |= mask; else vp->flags &= ~mask;
01325 }

int getFlag ViewParm vp,
UINT  mask
 

Unused (never called) function.

Definition at line 1328 of file Driver_Utilities.c.

References viewParm::flags, and ViewParm.

01329 { 
01330   if( vp->flags & mask ) return 1; else return 0;
01331 }

int getPrecision ViewParm vp  ) 
 

(Effectively unused).

Definition at line 1341 of file Driver_Utilities.c.

References viewParm::flags, and ViewParm.

Referenced by write_output().

01342  { 
01343   int rv = 1;
01344   if(vp->flags & PMASK2) rv +=2;
01345   if(vp->flags & PMASK1) rv +=1;
01346   return rv;
01347 }

int isInteger char *  target_str  ) 
 

Determine if an integer is present in string.

Parameters:
target_str Target string
Returns:
true or false (found int or not)

Definition at line 1392 of file Driver_Utilities.c.

01392                                  {
01393 
01394         int i=-1,first_num=0;
01395         char ch;
01396 
01397         while( (ch=target_str[++i]) != '\0' ) { 
01398                         if( isdigit(ch) ) first_num=1;
01399                         if( (ch=='-' || ch=='+') && first_num ) return(0);  
01400                         if( !( isspace(ch) || isdigit(ch) || ch=='-' || ch=='+') ) return(0);  
01401         }
01402         return(1);              
01403 }

int isFloat char *  target_str  ) 
 

Determine if a float is present in string.

Parameters:
target_str Target string
Returns:
true or false (found float or not)

Definition at line 1410 of file Driver_Utilities.c.

01410                                {
01411 
01412         int i=-1,first_num=0;
01413         char ch;
01414 
01415         while( (ch=target_str[++i]) != '\0' ) { 
01416                         if( isdigit(ch) ) first_num=1;
01417                         if( (ch=='-' || ch=='+') && first_num ) return(0);  
01418                         if( !( isspace(ch) || isdigit(ch) || ch=='-' || ch=='+' || ch=='.' || toupper(ch) == 'E') ) return(0);  
01419         }
01420         return(1);              
01421 }

int skip_white FILE *  infile  ) 
 

Skip white space(s) in a file.

Parameters:
infile 
Returns:
success/failure

Definition at line 1717 of file Driver_Utilities.c.

01718 {
01719   int ch;
01720   
01721   while( isspace(ch=fgetc(infile)) ) {;}
01722   if(ch==EOF) return 0;
01723   ungetc(ch,infile);
01724   return 1;             
01725 }  

int scan_forward FILE *  infile,
const char *  tstring
 

Scan forward until a particular string is found.

Parameters:
infile The file being read
tstring The sought-after string
Returns:
Success/failure

Definition at line 1731 of file Driver_Utilities.c.

01732 {
01733   int sLen, i, cnt=0;
01734   char Input_string[100], test;
01735   
01736   sLen = strlen(tstring);
01737   while( ( test = fgetc(infile) ) != EOF ) {
01738     for(i=0; i<(sLen-1); i++) 
01739         Input_string[i] = Input_string[i+1];
01740     Input_string[sLen-1] = test;
01741     Input_string[sLen] = '\0';
01742     if(++cnt >= sLen) {
01743       test =  strcmp(Input_string,tstring);
01744       if( test == 0 ) return 1;
01745     }
01746   }
01747   return(-1);
01748 }

int check_for char *  s0,
const char *  s1,
int  start,
int  cs,
int  rp
 

Check for occurrences of string s1 in string s0 after position start.

After position start, check for occurrences of string s1 in string s0.

Parameters:
s0 String array
s1 String array
start Starting position
cs Case sensitivity
rp Return pointer to beginning or not
Returns:
location in string

Definition at line 1360 of file Driver_Utilities.c.

References s0, and s1.

Referenced by write_map_file().

01361 {
01362   /*  Check for occurrences of string s1 in string s0   */
01363   /*  after position start. Return -1 if not found.             */
01364   /* if cs = CASE -> case sensitive, cs = NOCASE, not case sens.        */
01365   /* if rp = BEG -> return position of beginning of s1,         */
01366   /*                    otherwise return position of (next char following the) end of s1                */
01367   int i, j=0, k=-1, Len1 = strlen(s1), Len0 = strlen(s0);
01368   char t1, t2;
01369   
01370   while(k<0) {
01371     k=0;
01372     for(i=start; i< Len0; ++i) { 
01373       t1 = s0[i];
01374       t2 = s1[j];
01375       if(cs==NOCASE) { t1 = tolower(t1); t2 = tolower(t2); }   
01376       if (t1 == t2)  j++;
01377       else {j=0; k=0;}
01378       if(j==Len1) { k=1; break; }
01379     }
01380   }
01381   if(k<=0)              return(-1);
01382   else if(rp==BEG)      return(i-Len1+1);
01383   else                  return(i+1);
01384 }

int find_char FILE *  infile,
char  tchar
 

Find a character.

Parameters:
infile The file that is open
tchar The character being sought
Returns:
true/false (0 or 1)

Definition at line 1677 of file Driver_Utilities.c.

01678 {
01679   char test = '1', cchar = '#';
01680   int in_c=0;
01681 
01682   while( test != EOF ) {
01683     test = fgetc(infile);
01684     if(test == tchar && in_c==0 ) { return 1; }
01685     if(test == cchar ) in_c=1;
01686     if(test == '\n' )  in_c=0;
01687   }
01688   return(0);
01689 }

int Round float  x  ) 
 

truncate (not rounding) to an integer

Parameters:
x the value being operated on
Returns:
result

Definition at line 1694 of file Driver_Utilities.c.

01695 { 
01696   int i = (int)x;
01697   return (i);
01698 }

char* name_from_path char *  name  ) 
 

Get the var name from a longer path/filename.

Parameters:
name The var name & path
Returns:
Pointer to var name alone

Definition at line 1754 of file Driver_Utilities.c.

Referenced by quick_look().

01755 {
01756   char* namePtr; int i, slen;
01757   char dirCh;
01758   
01759   namePtr = name;
01760   dirCh = '/';
01761   slen = strlen(name);
01762   
01763   for(i=0; i<slen; i++) {
01764         if( name[slen-i-1] == dirCh ) { namePtr = name+slen-i; break; }
01765   }
01766   return namePtr;  
01767 }

char* Scip char *  s,
char  SYM
 

Skip ahead in a string until next field.

Parameters:
s A character array
SYM The specific symbol being used to skip over
Returns:
Location in string

Definition at line 1705 of file Driver_Utilities.c.

01706 {
01707   if(*s == SYM ) return ++s;
01708   while(*s != SYM && *s != EOS ) s++;
01709   if(*s != EOS) return ++s;
01710   else  return s;
01711 }

void setup_platform  ) 
 

Effectively unused in serial (non-parallel) implementation.

Definition at line 1854 of file Driver_Utilities.c.

References env, exgridcoord(), exgridinit(), exgridsplit(), exparam(), nodenv::nprocs, nprocs, procnum, nodenv::procnum, recpnum, and usrErr().

01854                       {
01855  
01856   exparam(&env);
01857   procnum = env.procnum;
01858   exgridsplit(env.nprocs, 2, nprocs);
01859   if( exgridinit(2, nprocs) < 0) { usrErr("Failed to Setup Grid"); exit(0); }
01860   exgridcoord(procnum, recpnum);
01861 }

Here is the call graph for this function:

void link_edges VOIDP  Map,
unsigned char  Mtype
 

Effectively unused in serial (non-parallel) implementation.

Definition at line 1841 of file Driver_Utilities.c.

References byte, exchange_borders(), and UCHAR.

Referenced by read_map_file().

01842 {
01843   switch(Mtype) {
01844   case 'f' :    
01845     exchange_borders((byte*)Map,sizeof(float)); break;
01846   case 'd' : case 'i' : 
01847     exchange_borders((byte*)Map,sizeof(int)); break;
01848   case 'c' :    
01849     exchange_borders((byte*)Map,sizeof(UCHAR)); break;
01850   }     
01851 }

Here is the call graph for this function:

float Normal float  mean,
float  sd
 

Unused, never called. Normal distribution.

Definition at line 1792 of file Driver_Utilities.c.

References gRTable, and SMDRAND().

01793 {
01794     int table_loc ;
01795     double rand_num ;
01796     float sign ;
01797     float interval = .1 ;
01798     int n_interval = 40 ;
01799     float high, low ;
01800     float return_val = 0.0;
01801 
01802     sign = SMDRAND(0.0, 1.0) ;
01803     sign = (sign < .5 ? -1 : 1) ;
01804     rand_num = SMDRAND(.5, 1.0);
01805     low = gRTable[0] ;
01806     for (table_loc=1; table_loc<n_interval; table_loc++)
01807     {
01808         high = gRTable[table_loc] ;
01809         if (high > rand_num + .5)
01810         {
01811             return_val = mean + sd * (sign  * interval * (table_loc - 1 +
01812                                                           (rand_num+.5-low)/(high-low))) ;
01813             return(return_val) ;
01814         }
01815         low = high ;
01816     }
01817     return(return_val) ;
01818 }

Here is the call graph for this function:

int Poisson float  mu  ) 
 

Unused, never called. Poisson distribution.

Definition at line 1821 of file Driver_Utilities.c.

References Exp, and SMDRAND().

01822 {
01823   int ix;
01824   float f0, r, Lp = 1, xf = 1, p=0;
01825   
01826   p = f0 = Exp(-mu);
01827   r = SMDRAND(0.0,1.0);
01828   
01829   for( ix=0; ix<500; ix++) {
01830     if( r < p ) return ix;
01831     Lp *= mu;
01832     if(ix>0) xf *= ix;
01833     p += (Lp*f0)/xf;
01834   }
01835   return ix;    
01836 }

Here is the call graph for this function:

int init_config_file FILE *  vpFile,
char  term1,
char  term2,
char  term3,
char  term4
 

Get format definition of output configuration file (does nothing effective!).

Identifies the leading characters in the Model.outlist output configuration file that define its format, which will never change from it's value of "#2". (This is another SME component of past flexibility.)

Parameters:
vpFile Pointer to the (model outlist) configuration file
term1 The character "#"
term2 The character "*"
term3 The character "@"
term4 The character "~"
Returns:
The (integer) format of the configuration file

Definition at line 747 of file Serial.c.

00748 {
00749   char test;
00750   int format,size=-1;
00751 
00752   gTerm[0] = term1;
00753   gTerm[1] = term2;  
00754   gTerm[2] = term3;  
00755   gTerm[3] = term4;  
00756   skip_white(vpFile);
00757   test = fgetc(vpFile);
00758   if(test == gTerm[0])
00759       fscanf(vpFile,"%d",&format);
00760   else
00761       format = -1;
00762   return format;
00763 }

int parse_packet FILE *  vpFile,
int *  nArgs,
char *  test
 

Parse through a configuration fileline to obtain the configuration commands.

Populates gCArg[][] with command info. In very early versions of ELM, this was used in reading the configuration file that translated "Stella" model equations into spatial (SME) code. Thus, much of the detail here is unused (ELM v1.0 and later) when reading the output (e.g., Model.outList) configuration file (both w/ similar syntax).

Parameters:
vpFile Pointer to the (model outlist) configuration file
nArgs Number of arguments in command
test A character that will be used to indicate an array (in outlist, always is array, char="*")
Returns:
The index (aka index sequence of variables) of the ViewParm

Definition at line 796 of file Serial.c.

00797 {
00798     static      int     gVPindex = -1;
00799     static      char    gCnfg;
00800     
00801         char ch = ' ', eChar = ' '; 
00802         int btype=0, argc=2, go=1, i=0, j=0, new_name = 0;
00803 
00804         if(vpFile == NULL) return -3;
00805         while (1) {
00806                 if ( skip_cnfg_space(vpFile, &ch) < 0) return -3; j=0;
00807                 if( ch == gTerm[1] || ch == gTerm[2] ) {
00808                     gCnfg = ch; ch = ' ';
00809                         if ( skip_cnfg_space(vpFile, &ch) < 0 ) return -3;
00810                         while ( !isspace(ch) ) { cTemp[j++] = ch; ch=fgetc(vpFile); }
00811                         cTemp[j++] = '\0'; new_name = 1;
00812                         gVPindex++;
00813                 }
00814                 else break;
00815         }
00816         strcpy(gCArg[0],cTemp);
00817         *test = gCnfg;
00818         while ( isalnum( ch ) ) { gCArg[1][i++]=ch; ch=fgetc(vpFile); }
00819         gCArg[1][i]='\0'; i=0;
00820         while( 1 ) {
00821                 if( ch == '(' ) { eChar = ')'; break;} 
00822                 else if( ch == '[' ) { eChar = ']'; break;} 
00823                 else if( ch == '{' ) { eChar = '}'; break;} 
00824                 else if( !isspace(ch) ) { return -3;}
00825                 ch=fgetc(vpFile);
00826         }
00827         while (go) {
00828                 while( ch=fgetc(vpFile) ) {
00829                         if( ch == ',' ) { argc++; break; }
00830                         if( ch == ')' ||  ch == '}' ||  ch == ']')  { 
00831                                 if( ch == eChar ) {  argc++; go=0; break;} 
00832                                 else { printf( "\nWarning: Syntax error in parse_config, var: %s\n",gCArg[0]); return -2; } 
00833                         }
00834                         gCArg[argc][i++]=ch;
00835                         if( i==(kCArgWidth-1) ) break;
00836                 }
00837                 if(i==0) { printf( "\nWarning: Syntax error in parse_config, var: %s\n",gCArg[0]); return -2; } 
00838                 else { gCArg[argc-1][i]='\0'; i=0; }
00839                 if(argc == kCArgDepth) { 
00840                         while( ch != eChar ) ch=fgetc(vpFile);  
00841                         go = 0; 
00842                 }
00843         }
00844         *nArgs = argc;
00845         if(argc==0) { printf( "\nWarning: Syntax error in parse_config, var: %s\n",gCArg[0]); return -2; }
00846         else return gVPindex;           
00847 } 

void Combine float *  fValue,
char *  label,
int  nComp,
int  cType,
int  step
 

A variety of stat summaries in a selected spatial window (debug-related).

This determines maximum, minimum, sum, average, either cumulatively over iterations or not cumulatively. This Model.outList command has not been used in ELM, and has not been verified for accuracy.

Parameters:
fValue Model variable (local) array data
label variable name
nComp number of comps
cType The combination (stats) type
step The current iteration number

Definition at line 598 of file Serial.c.

00599 {
00600         int print, cIndex, i, cum;
00601         static int type = 11;
00602         char tmpStr[50];
00603         if( ++type > 99) type = 11;
00604 
00605         cum = ((cType == kAVECUM) || (cType == kSUMCUM)) ? 1 : 0;       
00606         if(cum) { cIndex = getCombineIndex(label,step,cType,&print); }
00607         
00608         switch(cType) {
00609                 case kMAXMIN: 
00610                         sprintf(msgStr,"\nMAXMIN(%d) for %s:",step,label); 
00611                         for(i=0; i<nComp; i++) { sprintf(tmpStr," %f",fValue[i]); strcat(msgStr,tmpStr); }
00612                         WriteMsg(msgStr,1);
00613                 break;
00614                 case kMAX:
00615                         sprintf(msgStr,"\nMAX(%d) for %s:",step,label); 
00616                         for(i=0; i<nComp; i++) { sprintf(tmpStr," %f",fValue[i]); strcat(msgStr,tmpStr); }
00617                         WriteMsg(msgStr,1);
00618                 break;
00619                 case kMIN:
00620                         sprintf(msgStr,"\nMIN(%d) for %s:",step,label); 
00621                         for(i=0; i<nComp; i++) { sprintf(tmpStr," %f",fValue[i]); strcat(msgStr,tmpStr); }
00622                         WriteMsg(msgStr,1);
00623                 break;
00624                 case kSUM:
00625                         sprintf(msgStr,"\nSUM(%d) for %s:",step,label); 
00626                         for(i=0; i<nComp; i++) { sprintf(tmpStr," %f",fValue[i]); strcat(msgStr,tmpStr); }
00627                         WriteMsg(msgStr,1);
00628                 break;
00629                 case kAVE:
00630                         sprintf(msgStr,"\nAVE(%d) for %s:",step,label); 
00631                         for(i=0; i<nComp; i+=2) { sprintf(tmpStr," %f",fValue[i]/fValue[i+1]); strcat(msgStr,tmpStr); }
00632                         WriteMsg(msgStr,1);
00633                 break;
00634                 case kSUMCUM:
00635                         if( print == -1) {
00636                                 for(i=0; i<nComp; i++) ctable[cIndex].fvalue[i] = fValue[i]; 
00637                         
00638                         } else {
00639                                 for(i=0; i<nComp; i++) ctable[cIndex].fvalue[i] += fValue[i]; 
00640                         }
00641                         if(print==1) {                          
00642                                 sprintf(msgStr,"\nSUMCUM(%d) for %s:",step,label); 
00643                                 for(i=0; i<nComp; i++) { sprintf(tmpStr," %f",ctable[cIndex].fvalue[i]); strcat(msgStr,tmpStr); }
00644                                 WriteMsg(msgStr,1);
00645                         }
00646                 break;
00647                 case kAVECUM:
00648                         if( print == -1) {
00649                                 for(i=0; i<nComp; i++) ctable[cIndex].fvalue[i] = fValue[i]; 
00650                         
00651                         } else {
00652                                 for(i=0; i<nComp; i++) ctable[cIndex].fvalue[i] += fValue[i]; 
00653                         }
00654                         if(print==1) {                          
00655                                 sprintf(msgStr,"\nAVECUM(%d) for %s:",step,label); 
00656                                 for(i=0; i<nComp; i+=2) { sprintf(tmpStr," %f",ctable[cIndex].fvalue[i]/ctable[cIndex].fvalue[i+1]); strcat(msgStr,tmpStr); }
00657                                 WriteMsg(msgStr,1);
00658                         }
00659                 break;
00660         }
00661 }       

void writeMap char *  filename,
void *  data,
int  bSize,
unsigned char  type,
int  index
 

Write data for spatial (map) output binary file.

Parameters:
filename Filename (variable name) of data
data Data array
bSize Byte size of data
type Type, or format, of (binary) data
index Index used in HDF output (which is unused)

Definition at line 125 of file Serial.c.

00126 {
00127   int gsize, istat;
00128   FILE* bFile; 
00129   
00130   if(type=='M') write_header(filename,bSize);
00131   
00132   if(type == 'H') {
00133 #if HDF
00134     if(index==0) { istat = DFR8putimage(filename,(char*)data,s1,s0,0); }
00135     else { istat = DFR8addimage(filename,(char*)data,s1,s0,0); }
00136     if(istat != 0) printf("\nerror writing HDF file: %s\n",filename);
00137 #endif
00138   } 
00139   else {
00140     if((bFile = fopen(filename,"wb") ) == NULL ) { 
00141       fprintf(stderr,"Can't Open Mapfile: %s",filename); 
00142       exit(0); 
00143     }
00144     gsize = gbl_size[0]*gbl_size[1]*bSize;
00145     fwrite((char*)data, gsize, 1, bFile );
00146     fclose(bFile);
00147   }
00148 }

void writeSeries void *  fValue,
char *  label,
char *  desc,
int  N0,
int  N1,
byte  Mtype,
byte  format
 

Write to a spatial data window in a debug file.

Parameters:
fValue Model variable (local) array data
label Output message label (w/ variable name)
desc Message describing the output
N0 Range in x (row!) values
N1 Range in y (col!) values
Mtype General output format type
format Numeric format type

Definition at line 520 of file Serial.c.

00521 {
00522         /* check on these! (who wrote this? Why? (HCF Dec'04) )*/
00523   int ix, iy; 
00524   static unsigned char first_write = 1;
00525   long int  ret, dimsizes[2];
00526   unsigned short int refnum;
00527   if(format == 'H') {
00528   
00529 #if HDF   
00530           dimsizes[0] = N0;
00531           dimsizes[1] = N1;
00532           sprintf(cTemp,"%s%s:Output:Windows.hdf",OutputPath,ProjName);
00533           DFSDclear();
00534           
00535           switch(Mtype) {
00536                  case 'f': 
00537                     DFSDsetNT(DFNT_FLOAT32);  break;
00538                  case 'L': 
00539                     DFSDsetNT(DFNT_FLOAT32);  break;
00540                  case 'E': 
00541                     DFSDsetNT(DFNT_FLOAT32);  break;
00542                  case 'd': case 'i': 
00543                     DFSDsetNT(DFNT_INT32);  break;
00544                  case 'c': 
00545                     DFSDsetNT(DFNT_UINT8);  break;
00546           }
00547           if(first_write) {
00548                 ret = DFSDputdata(cTemp,2,dimsizes,fValue);
00549                 first_write = 0;
00550           } else {
00551                 ret = DFSDadddata(cTemp,2,dimsizes,fValue);
00552           }
00553           HDF_VERIFY("DFSDadddata");
00554           refnum = DFSDlastref();
00555           ret = DFANputlabel(cTemp,DFTAG_SDG,refnum,label);
00556           HDF_VERIFY("DFANputlabel");
00557           ret = DFANputdesc(cTemp,DFTAG_SDG,refnum,desc,strlen(desc));
00558           HDF_VERIFY("DFANputdesc");
00559 #endif
00560   }
00561   else {
00562     fprintf(Driver_outfile,"\n_________%s\n",label);    
00563     fprintf(Driver_outfile,"%s\n",desc);        
00564     for (ix=0; ix<N0; ix++) {
00565       fprintf(Driver_outfile,"\n");
00566       for (iy=0; iy<N1; iy++) {
00567         switch(Mtype) {
00568           case 'f': 
00569                 if(format=='L')                 fprintf(Driver_outfile,"%f ",*(((float*)fValue)+iy+ix*N1)); 
00570                 else if(format=='E')    fprintf(Driver_outfile,"%.3E ",*(((float*)fValue)+iy+ix*N1)); 
00571                         else                            fprintf(Driver_outfile,"%.3f ",*(((float*)fValue)+iy+ix*N1));
00572                         break;
00573         case 'd': case 'i': 
00574                         fprintf(Driver_outfile,"%d ",*(((int*)fValue)+iy+ix*N1)); 
00575                         break;
00576         case 'c': 
00577                         fprintf(Driver_outfile,"%x ",*(((UCHAR*)fValue)+iy+ix*N1)); 
00578                         break;
00579         }
00580       }
00581     }  
00582   }
00583 }

float* readSeriesCol char *  filename,
int  format,
int  index,
int *  Npt,
float *  TStep,
int  col
 

(Unused). Read time series input data for spatial interpolations

Parameters:
filename Filename of data
format Always float data format
index Unused. Was used to concatenate multiple files over time
Npt Number of time points
TStep Time step
col column ID (for different variables)

Definition at line 182 of file Serial.c.

00183 {
00184     int line = 0, cread=1, itest, j, sLen = 372 ;
00185     FILE *cfile;
00186     char  ctest, cmark[373], ret = '\n';
00187     unsigned char cmove[373], cmv=0;
00188     char tfilename[200], date_read[20],ss[200];
00189     int yyyy,mm, dd;
00190     double Jdate_read; 
00191     float  *tvar, *nullvar, first[10];
00192 
00193     sprintf(tfilename,"%s%d.ts",filename,index);
00194     if(debug>4) fprintf(dFile,"\nReading file %s, col %d, index = %d\n",tfilename,col,index); fflush(dFile);
00195     cfile = fopen(tfilename,"r"); 
00196     if(cfile==NULL) {  
00197         if( index > 0 ) {  fprintf(stdout,"\nWARNING: Unable to open timeseries file %s, using %s0.ts\n",tfilename,filename); return 0; } 
00198         else { fprintf(stdout,"\nERROR: Unable to open timeseries file %s\n",tfilename); exit(-1); } 
00199     }
00200 
00201     if (format != 2) { fprintf(stderr,"ERROR: only using floats in read_timeseries: %d\n",format); exit(0); }
00202     
00203            sLen = PORnumday; /* read/determined in genericDriver */
00204             tvar = (float*) nalloc( (sLen+2)*sizeof(float), "timeseries temp" );
00205             scan_forward(cfile,"{END COMMENT}\n");
00206             fgets(ss,200,cfile); /* skip  the header line */
00207             
00208             do {
00209                 fscanf(cfile, "%d %d %d %f %f %f %f", &yyyy,&mm,&dd,&first[1],&first[2],&first[3],&first[4] ); 
00210         /* julian day, returns a double (args = month, day, year, hours, minutes, seconds) */
00211                 Jdate_read = julday(mm, dd, yyyy, 0, 0, 0); 
00212                 if (Jdate_read > Jdate_init) {printf (" \n***Error\nInit date in %s file > simulation start date.\n",tfilename); exit (-1);}
00213                 if (feof(cfile)) {
00214         printf (" \n***Error\nNon-matching starting date for %s meteorological time series\n",tfilename); 
00215                         exit (-1);
00216                 }
00217             } while (Jdate_read < Jdate_init);
00218             
00219             tvar[0] = first[col]; /* have now read the first data record, assign to array */
00220             if(debug>4) fprintf(dFile,"%d %d %d %f\n",yyyy,mm,dd,tvar[0]);
00221             for (line = 1; line<sLen; line++) {
00222             
00223             /* each case for reading a different column */
00224                 switch (col) {
00225                     case 1:
00226                         itest = fscanf(cfile,"%d %d %d %f %f %f %f",&yyyy,&mm,&dd, &(tvar[ line ]),&nullvar, &nullvar, &nullvar);
00227                         break;
00228                     case 2:
00229                         itest = fscanf(cfile,"%d %d %d %f %f %f %f",&yyyy,&mm,&dd,&nullvar, &(tvar[ line ]), &nullvar, &nullvar);
00230                         break;
00231                     case 3:
00232                         itest = fscanf(cfile,"%d %d %d %f %f %f %f",&yyyy,&mm,&dd,&nullvar, &nullvar, &(tvar[ line ]), &nullvar);
00233                         break;
00234                     case 4:
00235                         itest = fscanf(cfile,"%d %d %d %f %f %f %f",&yyyy,&mm,&dd,&nullvar, &nullvar, &nullvar, &(tvar[ line ]));
00236                         break;
00237                     default:
00238                         printf ("\nError in interpolation time series data.\n"); 
00239                         exit(-1);
00240                         break;
00241                 } /* end switch */
00242 
00243                 if(debug>4) fprintf(dFile,"%d %d %d %f\n",yyyy,mm,dd,tvar[ line ]);
00244                 if (feof(cfile)) {printf (" \n***Error\nExceeded number of records for %s meteorological time series\n",tfilename); exit (-1);}
00245             }
00246             tvar[ sLen ] = *TStep;
00247  
00248     if(debug>4) { fprintf(dFile,"\nDone Reading file %s\n",tfilename); fflush(dFile); }
00249     
00250     fflush(stdout);
00251     fclose(cfile);
00252     *Npt = sLen;
00253     return tvar;
00254 }

byte readMap char *  filename,
void *  data
 

Read data for spatial (map) input binary file.

Parameters:
filename data variable's name
data variable's array data
Returns:
byte size of data values

Definition at line 38 of file Serial.c.

00039 {
00040   int gsize, nbytes; byte bsize;
00041   FILE* bFile;
00042   char binFileName[300];
00043   
00044   bsize = read_header(filename);
00045 
00046   sprintf(binFileName,"%s/%s/Data/Map_bin/%s",ModelPath,ProjName,filename);
00047 
00048   if((bFile = fopen(binFileName,"rb") ) == NULL ) { 
00049     fprintf(stderr,"Can't Open Mapfile: %s",binFileName); 
00050     exit(0); 
00051   }
00052   gsize = gbl_size[0] * gbl_size[1];
00053   nbytes = fread((char*)data, (int)bsize, gsize, bFile );
00054   if(debug) { 
00055     fprintf(dFile," %d of %d items Read for %s, size = %x bytes ",
00056             nbytes,gsize,filename,bsize); 
00057   }
00058   fclose(bFile);
00059   return bsize;
00060 }

int on_this_proc int  x,
int  y
 

Parallel code: does nothing in serial implementation).

Definition at line 1047 of file Serial.c.

01048 { return 1; }

void exchange_borders UCHAR map,
int  size
 

Parallel code: does nothing in serial implementation).

Definition at line 1043 of file Serial.c.

01044 {return;}

void exparam struct nodenv envInfo  ) 
 

Parallel code: effectively unused in serial implementation.

Definition at line 986 of file Serial.c.

00987 {       
00988         envInfo->procnum = 1;
00989         envInfo->nprocs = 1;
00990         envInfo->groupid = 0;
00991         envInfo->taskid = 0;
00992  
00993 }

void exgridsplit int  nprocs,
int  ndim,
int  nprocs2[2]
 

Parallel code: effectively unused in serial implementation.

Definition at line 1000 of file Serial.c.

01001 {
01002   nprocs2[0] = 1;
01003   nprocs2[1] = 1;
01004 }

void exgridcoord int  pnum,
int  rnum[2]
 

Parallel code: effectively unused in serial implementation.

Definition at line 1007 of file Serial.c.

01008 {
01009     tramNum[0] = rnum[0] = 0;
01010     tramNum[1] = rnum[1] = 0;
01011 }

void exgridsize int  pnum,
int  gsize[2],
int  lsize[2],
int  lstart[2]
 

Parallel code: effectively unused in serial implementation.

Definition at line 1014 of file Serial.c.

01015 {
01016         int rem[2], i, j;
01017         for( i=0; i<2; i++ ) {
01018                 lsize[i] = gsize[i]/nprocs[i];
01019                 rem[i] = gsize[i] - lsize[i]*nprocs[i];
01020                 if(recpnum[i]<rem[i]) lsize[i]++;
01021                 for(j=0; j<recpnum[i]; j++) if( j<rem[i] && recpnum[i] >= rem[i] ) lstart[i] += (lsize[i]+1); else lstart[i] += lsize[i];
01022         }
01023 }

void broadcastInt int *  iValPtr  ) 
 

Parallel code: does nothing in serial implementation).

Definition at line 1059 of file Serial.c.

01060 {}

int exgridinit int  dim,
int *  nprocs
 

Parallel code: does nothing in serial implementation).

Definition at line 996 of file Serial.c.

00997 { return 0;}

void broadcastMsg UCHAR msgPtr  ) 
 

Parallel code: does nothing in serial implementation).

Definition at line 1055 of file Serial.c.

01056 {}

void fasync FILE *  file  ) 
 

Parallel code: does nothing in serial implementation).

Definition at line 1038 of file Serial.c.

01039 { return;}

void fmulti FILE *  file  ) 
 

Parallel code: does nothing in serial implementation).

Definition at line 1030 of file Serial.c.

01031 { return;}

int ReadGlobalParms char *  s_parm_name,
int  s_parm_relval
 

Acquire the model parameters that are global to the domain.

Parameters:
s_parm_name Name of the sensitivity parameter being varied for this run
s_parm_relval Indicator of current value of relative range in sensitivity parm values: nominal (0), low (1), or high (2)

Definition at line 2414 of file UnitMod.c.

02415  {
02416      
02417 /* Geography, hydrology */
02418     GP_SOLOMEGA = get_global_parm(s_parm_name, s_parm_relval,"GP_SOLOMEGA"); 
02419     GP_ALTIT = get_global_parm(s_parm_name, s_parm_relval,"GP_ALTIT"); 
02420     GP_LATDEG = get_global_parm(s_parm_name, s_parm_relval,"GP_LATDEG"); 
02421     GP_mannDepthPow = get_global_parm(s_parm_name, s_parm_relval,"GP_mannDepthPow"); 
02422     GP_mannHeadPow = get_global_parm(s_parm_name, s_parm_relval,"GP_mannHeadPow"); 
02423     GP_calibGWat = get_global_parm(s_parm_name, s_parm_relval,"GP_calibGWat"); 
02424     GP_IDW_pow = get_global_parm(s_parm_name, s_parm_relval,"GP_IDW_pow"); 
02425     GP_calibET = get_global_parm(s_parm_name, s_parm_relval,"GP_calibET"); 
02426     GP_DATUM_DISTANCE = get_global_parm(s_parm_name, s_parm_relval,"GP_DATUM_DISTANCE"); 
02427     GP_HYD_IC_SFWAT_ADD = get_global_parm(s_parm_name, s_parm_relval,"GP_HYD_IC_SFWAT_ADD"); 
02428     GP_HYD_IC_UNSAT_ADD = get_global_parm(s_parm_name, s_parm_relval,"GP_HYD_IC_UNSAT_ADD"); 
02429     GP_HYD_RCRECHG = get_global_parm(s_parm_name, s_parm_relval,"GP_HYD_RCRECHG"); 
02430     GP_HYD_ICUNSATMOIST = get_global_parm(s_parm_name, s_parm_relval,"GP_HYD_ICUNSATMOIST"); 
02431     GP_DetentZ = get_global_parm(s_parm_name, s_parm_relval,"GP_DetentZ"); 
02432     GP_MinCheck = get_global_parm(s_parm_name, s_parm_relval,"GP_MinCheck"); 
02433     GP_SLRise = get_global_parm(s_parm_name, s_parm_relval,"GP_SLRise"); 
02434     GP_dispLenRef = get_global_parm(s_parm_name, s_parm_relval,"GP_dispLenRef"); 
02435     GP_dispParm = get_global_parm(s_parm_name, s_parm_relval,"GP_dispParm"); 
02436  
02437  /* Periphyton/Algae */
02438     GP_ALG_IC_MULT = get_global_parm(s_parm_name, s_parm_relval,"GP_ALG_IC_MULT"); 
02439     GP_alg_uptake_coef = get_global_parm(s_parm_name, s_parm_relval,"GP_alg_uptake_coef"); 
02440     GP_ALG_SHADE_FACTOR = get_global_parm(s_parm_name, s_parm_relval,"GP_ALG_SHADE_FACTOR"); 
02441     GP_algMortDepth = get_global_parm(s_parm_name, s_parm_relval,"GP_algMortDepth"); 
02442     GP_ALG_RC_MORT_DRY = get_global_parm(s_parm_name, s_parm_relval,"GP_ALG_RC_MORT_DRY"); 
02443     GP_ALG_RC_MORT = get_global_parm(s_parm_name, s_parm_relval,"GP_ALG_RC_MORT"); 
02444     GP_ALG_RC_PROD = get_global_parm(s_parm_name, s_parm_relval,"GP_ALG_RC_PROD"); 
02445     GP_ALG_RC_RESP = get_global_parm(s_parm_name, s_parm_relval,"GP_ALG_RC_RESP"); 
02446     GP_alg_R_accel = get_global_parm(s_parm_name, s_parm_relval,"GP_alg_R_accel"); 
02447     GP_AlgComp = get_global_parm(s_parm_name, s_parm_relval,"GP_AlgComp"); 
02448     GP_ALG_REF_MULT = get_global_parm(s_parm_name, s_parm_relval,"GP_ALG_REF_MULT"); 
02449     GP_NC_ALG_KS_P = get_global_parm(s_parm_name, s_parm_relval,"GP_NC_ALG_KS_P"); 
02450     GP_alg_alkP_min = get_global_parm(s_parm_name, s_parm_relval,"GP_alg_alkP_min"); 
02451     GP_C_ALG_KS_P = get_global_parm(s_parm_name, s_parm_relval,"GP_C_ALG_KS_P"); 
02452     GP_ALG_TEMP_OPT = get_global_parm(s_parm_name, s_parm_relval,"GP_ALG_TEMP_OPT"); 
02453     GP_C_ALG_threshTP = get_global_parm(s_parm_name, s_parm_relval,"GP_C_ALG_threshTP"); 
02454     GP_ALG_C_TO_OM = get_global_parm(s_parm_name, s_parm_relval,"GP_ALG_C_TO_OM"); 
02455     GP_alg_light_ext_coef = get_global_parm(s_parm_name, s_parm_relval,"GP_alg_light_ext_coef"); 
02456     GP_ALG_LIGHT_SAT = get_global_parm(s_parm_name, s_parm_relval,"GP_ALG_LIGHT_SAT"); 
02457     GP_ALG_PC = get_global_parm(s_parm_name, s_parm_relval,"GP_ALG_PC"); 
02458 
02459 /* Soil */
02460     GP_DOM_RCDECOMP = get_global_parm(s_parm_name, s_parm_relval,"GP_DOM_RCDECOMP"); 
02461     GP_DOM_DECOMPRED = get_global_parm(s_parm_name, s_parm_relval,"GP_DOM_DECOMPRED"); 
02462     GP_calibDecomp = get_global_parm(s_parm_name, s_parm_relval,"GP_calibDecomp"); 
02463     GP_DOM_decomp_coef = get_global_parm(s_parm_name, s_parm_relval,"GP_DOM_decomp_coef"); 
02464     GP_DOM_DECOMP_POPT = get_global_parm(s_parm_name, s_parm_relval,"GP_DOM_DECOMP_POPT"); 
02465     GP_DOM_DECOMP_TOPT = get_global_parm(s_parm_name, s_parm_relval,"GP_DOM_DECOMP_TOPT"); 
02466     GP_sorbToTP = get_global_parm(s_parm_name, s_parm_relval,"GP_sorbToTP"); 
02467     GP_IC_ELEV_MULT = get_global_parm(s_parm_name, s_parm_relval,"GP_IC_ELEV_MULT"); 
02468     GP_IC_BATHY_MULT = get_global_parm(s_parm_name, s_parm_relval,"GP_IC_BATHY_MULT"); 
02469     GP_IC_DOM_BD_MULT = get_global_parm(s_parm_name, s_parm_relval,"GP_IC_DOM_BD_MULT"); 
02470     GP_IC_BulkD_MULT = get_global_parm(s_parm_name, s_parm_relval,"GP_IC_BulkD_MULT"); 
02471     GP_IC_TPtoSOIL_MULT = get_global_parm(s_parm_name, s_parm_relval,"GP_IC_TPtoSOIL_MULT"); 
02472  
02473 /* Macrophytes */
02474     GP_MAC_IC_MULT = get_global_parm(s_parm_name, s_parm_relval,"GP_MAC_IC_MULT"); 
02475     GP_MAC_REFUG_MULT = get_global_parm(s_parm_name, s_parm_relval,"GP_MAC_REFUG_MULT"); 
02476     GP_mac_uptake_coef = get_global_parm(s_parm_name, s_parm_relval,"GP_mac_uptake_coef"); 
02477     GP_mann_height_coef = get_global_parm(s_parm_name, s_parm_relval,"GP_mann_height_coef"); 
02478 
02479 /* Floc */
02480     GP_Floc_BD = get_global_parm(s_parm_name, s_parm_relval,"GP_Floc_BD"); 
02481     GP_FlocMax = get_global_parm(s_parm_name, s_parm_relval,"GP_FlocMax"); 
02482     GP_TP_P_OM = get_global_parm(s_parm_name, s_parm_relval,"GP_TP_P_OM"); 
02483     GP_Floc_rcSoil = get_global_parm(s_parm_name, s_parm_relval,"GP_Floc_rcSoil"); 
02484                 
02485 /* Phosphorus */
02486     GP_TP_DIFFCOEF = get_global_parm(s_parm_name, s_parm_relval,"GP_TP_DIFFCOEF"); 
02487     GP_TP_K_INTER = get_global_parm(s_parm_name, s_parm_relval,"GP_TP_K_INTER"); 
02488     GP_TP_K_SLOPE = get_global_parm(s_parm_name, s_parm_relval,"GP_TP_K_SLOPE"); 
02489     GP_WQMthresh = get_global_parm(s_parm_name, s_parm_relval,"GP_WQMthresh"); 
02490     GP_PO4toTP = get_global_parm(s_parm_name, s_parm_relval,"GP_PO4toTP"); 
02491     GP_TP_IN_RAIN = get_global_parm(s_parm_name, s_parm_relval,"GP_TP_IN_RAIN"); 
02492     GP_PO4toTPint = get_global_parm(s_parm_name, s_parm_relval,"GP_PO4toTPint"); 
02493     GP_TP_ICSFWAT = get_global_parm(s_parm_name, s_parm_relval,"GP_TP_ICSFWAT"); 
02494     GP_TP_ICSEDWAT = get_global_parm(s_parm_name, s_parm_relval,"GP_TP_ICSEDWAT"); 
02495     GP_TPpart_thresh = get_global_parm(s_parm_name, s_parm_relval,"GP_TPpart_thresh"); 
02496     GP_TP_DIFFDEPTH = get_global_parm(s_parm_name, s_parm_relval,"GP_TP_DIFFDEPTH"); 
02497     GP_settlVel = get_global_parm(s_parm_name, s_parm_relval,"GP_settlVel"); 
02498     
02499 }

int ReadHabParms char *  s_parm_name,
int  s_parm_relval
 

Acquire the model parameters that are specific to different habitat types in the domain.

Remarks:
The get_hab_parm function called during initialization expects the appropriate habitat-specific parameter to have a first header line that has parameter names that exactly match those in this code.
The ordering of function calls to read the parameters is unimportant; the ordering of the modules in the datafile is unimportant. However, the sequence of the column-field parameter names in header must (obviously?) correspond to the data columns.

Definition at line 2348 of file UnitMod.c.

02349 {
02350 
02351  /* Periphyton/Algae */
02352   HP_ALG_MAX = get_hab_parm(s_parm_name, s_parm_relval, "HP_ALG_MAX"); 
02353 
02354 /* Soil */
02355   HP_DOM_MAXDEPTH = get_hab_parm(s_parm_name, s_parm_relval,"HP_DOM_MAXDEPTH");  
02356   HP_DOM_AEROBTHIN = get_hab_parm(s_parm_name, s_parm_relval,"HP_DOM_AEROBTHIN"); 
02357 
02358 /* Phosphorus */
02359   HP_TP_CONC_GRAD = get_hab_parm(s_parm_name, s_parm_relval,"HP_TP_CONC_GRAD"); 
02360 
02361 /* Salt/tracer */
02362   HP_SALT_ICSEDWAT = get_hab_parm(s_parm_name, s_parm_relval,"HP_SALT_ICSEDWAT"); 
02363   HP_SALT_ICSFWAT = get_hab_parm(s_parm_name, s_parm_relval,"HP_SALT_ICSFWAT"); 
02364         
02365 /* Macrophytes */
02366   HP_PHBIO_MAX = get_hab_parm(s_parm_name, s_parm_relval,"HP_PHBIO_MAX"); 
02367   HP_NPHBIO_MAX = get_hab_parm(s_parm_name, s_parm_relval,"HP_NPHBIO_MAX"); 
02368   HP_MAC_MAXHT = get_hab_parm(s_parm_name, s_parm_relval,"HP_MAC_MAXHT"); 
02369   HP_NPHBIO_ROOTDEPTH = get_hab_parm(s_parm_name, s_parm_relval,"HP_NPHBIO_ROOTDEPTH"); 
02370   HP_MAC_MAXROUGH = get_hab_parm(s_parm_name, s_parm_relval,"HP_MAC_MAXROUGH"); 
02371   HP_MAC_MINROUGH = get_hab_parm(s_parm_name, s_parm_relval,"HP_MAC_MINROUGH"); 
02372   HP_MAC_MAXLAI = get_hab_parm(s_parm_name, s_parm_relval,"HP_MAC_MAXLAI"); 
02373   HP_MAC_MAXCANOPCOND = get_hab_parm(s_parm_name, s_parm_relval,"HP_MAC_MAXCANOPCOND"); /* unused in ELMv2.2, 2.3 */ 
02374   HP_MAC_CANOPDECOUP = get_hab_parm(s_parm_name, s_parm_relval,"HP_MAC_CANOPDECOUP"); /* unused in ELMv2.2, 2.3 */ 
02375   HP_MAC_TEMPOPT = get_hab_parm(s_parm_name, s_parm_relval,"HP_MAC_TEMPOPT"); 
02376   HP_MAC_LIGHTSAT = get_hab_parm(s_parm_name, s_parm_relval,"HP_MAC_LIGHTSAT"); 
02377   HP_MAC_KSP = get_hab_parm(s_parm_name, s_parm_relval,"HP_MAC_KSP"); 
02378   HP_PHBIO_RCNPP = get_hab_parm(s_parm_name, s_parm_relval,"HP_PHBIO_RCNPP"); 
02379   HP_PHBIO_RCMORT = get_hab_parm(s_parm_name, s_parm_relval,"HP_PHBIO_RCMORT"); 
02380   HP_MAC_WAT_TOLER = get_hab_parm(s_parm_name, s_parm_relval,"HP_MAC_WAT_TOLER"); 
02381   HP_MAC_SALIN_THRESH = get_hab_parm(s_parm_name, s_parm_relval,"HP_MAC_SALIN_THRESH"); /* unused in ELMv2.2, 2.3 */ 
02382   HP_PHBIO_IC_CTOOM = get_hab_parm(s_parm_name, s_parm_relval,"HP_PHBIO_IC_CTOOM"); 
02383   HP_NPHBIO_IC_CTOOM = get_hab_parm(s_parm_name, s_parm_relval,"HP_NPHBIO_IC_CTOOM"); 
02384   HP_PHBIO_IC_PC = get_hab_parm(s_parm_name, s_parm_relval,"HP_PHBIO_IC_PC"); 
02385   HP_NPHBIO_IC_PC = get_hab_parm(s_parm_name, s_parm_relval,"HP_NPHBIO_IC_PC"); 
02386   HP_MAC_TRANSLOC_RC = get_hab_parm(s_parm_name, s_parm_relval,"HP_MAC_TRANSLOC_RC"); 
02387 
02388 /* Hydrology */
02389   HP_HYD_RCINFILT = get_hab_parm(s_parm_name, s_parm_relval,"HP_HYD_RCINFILT"); 
02390   HP_HYD_SPEC_YIELD = get_hab_parm(s_parm_name, s_parm_relval,"HP_HYD_SPEC_YIELD");  
02391   HP_HYD_POROSITY = get_hab_parm(s_parm_name, s_parm_relval,"HP_HYD_POROSITY"); 
02392 
02393 /* Floc */
02394   HP_FLOC_IC = get_hab_parm(s_parm_name, s_parm_relval,"HP_FLOC_IC"); 
02395   HP_FLOC_IC_CTOOM = get_hab_parm(s_parm_name, s_parm_relval,"HP_FLOC_IC_CTOOM"); 
02396   HP_FLOC_IC_PC = get_hab_parm(s_parm_name, s_parm_relval,"HP_FLOC_IC_PC"); 
02397 
02398 /* Habitat succession */
02399   HP_SfDepthLo = get_hab_parm(s_parm_name, s_parm_relval,"HP_SfDepthLo"); 
02400   HP_SfDepthHi = get_hab_parm(s_parm_name, s_parm_relval,"HP_SfDepthHi"); 
02401   HP_SfDepthInt = get_hab_parm(s_parm_name, s_parm_relval,"HP_SfDepthInt"); 
02402   HP_PhosLo = get_hab_parm(s_parm_name, s_parm_relval,"HP_PhosLo"); 
02403   HP_PhosHi = get_hab_parm(s_parm_name, s_parm_relval,"HP_PhosHi"); 
02404   HP_PhosInt = get_hab_parm(s_parm_name, s_parm_relval,"HP_PhosInt"); 
02405   HP_FireInt = get_hab_parm(s_parm_name, s_parm_relval,"HP_FireInt"); 
02406   
02407 }


Variable Documentation

int CalMonOut = 99999
 

The outstep interval (in Model.outList input file) used to denote output intervals of 1-calendar-month instead of selectable-julian-day

Definition at line 28 of file driver_utilities.h.

Referenced by readViewParms().

char* ModelPath
 

Environment variables used in model

ModelPath environment variable, base pathname for executable and input data
ProjName environment variable, the name of the model project
DriverPath environment variable, base pathname for source code
OS_TYPE environment variable, the type of operating system being used (informational purpose only, not used in code)

Definition at line 36 of file driver_utilities.h.

char * ProjName
 

Environment variables used in model

ModelPath environment variable, base pathname for executable and input data
ProjName environment variable, the name of the model project
DriverPath environment variable, base pathname for source code
OS_TYPE environment variable, the type of operating system being used (informational purpose only, not used in code)

Definition at line 36 of file driver_utilities.h.

char * DriverPath
 

Environment variables used in model

ModelPath environment variable, base pathname for executable and input data
ProjName environment variable, the name of the model project
DriverPath environment variable, base pathname for source code
OS_TYPE environment variable, the type of operating system being used (informational purpose only, not used in code)

Definition at line 36 of file driver_utilities.h.

Referenced by set_env_vars().

char * OS_TYPE
 

Environment variables used in model

ModelPath environment variable, base pathname for executable and input data
ProjName environment variable, the name of the model project
DriverPath environment variable, base pathname for source code
OS_TYPE environment variable, the type of operating system being used (informational purpose only, not used in code)

Definition at line 36 of file driver_utilities.h.

Referenced by main(), and set_env_vars().

char* OutputPath
 

base pathname for all model output (user input)

Definition at line 38 of file driver_utilities.h.

char modelName[20]
 

Model name/version (user input)

modelName Name given to model implementation (user input)
modelVers Version given to model implementation (e.g., v.2.1) (user input)

Definition at line 44 of file driver_utilities.h.

char modelVers[10]
 

Model name/version (user input)

modelName Name given to model implementation (user input)
modelVers Version given to model implementation (e.g., v.2.1) (user input)

Definition at line 44 of file driver_utilities.h.

char modelFileName[300]
 

Generic string for input/output file name (overwritten/reused)

Definition at line 46 of file driver_utilities.h.

Referenced by BIRinit(), BIRoutfiles(), Canal_Network_Init(), Channel_configure(), get_global_parm(), get_hab_parm(), PTS_SetFields(), PTSL_ReadLists(), read_map_dims(), Read_schedule(), ReadChanStruct(), readOutlist(), ReadStructures(), SensiParm_list(), and write_map_file().

int gNPtTs
 

Definition at line 48 of file driver_utilities.h.

Referenced by PTS_SetFields().

int PListIndex = 0
 

Definition at line 49 of file driver_utilities.h.

Referenced by print_point().

int total_memory = 0
 

Definition at line 50 of file driver_utilities.h.

Referenced by nalloc().

float* plot_array
 

Definition at line 51 of file driver_utilities.h.

float gTS
 

Definition at line 51 of file driver_utilities.h.

Referenced by PTS_SetFields().

int gridSize
 

row x col size of model grid domain, adding 2 to each dimension for local grid buffer (intended primarily for parallel implementation)

Definition at line 53 of file driver_utilities.h.

Referenced by read_map_file(), setup_grid(), and write_map_file().

int gTempSize
 

intermediate variable for model grid memory alloc

Definition at line 54 of file driver_utilities.h.

Referenced by read_map_file(), setup_grid(), write_map_file(), and writeWindow().

UCHAR* gTemp
 

intermediate variable for model grid memory alloc

Definition at line 55 of file driver_utilities.h.

Referenced by read_map_file(), setup_grid(), write_map_file(), and writeWindow().

char gCArg[kCArgDepth][kCArgWidth]
 

Output command arguments, parsed from the output configuration file

Definition at line 51 of file serial.h.

Referenced by parse_packet(), and readViewParms().

FILE* Driver_outfile
 

File pointer to (Driver0.out, or DriverX.out (for X'th simulation run)) debug file(s)

Definition at line 57 of file serial.h.

Referenced by open_debug_outFile(), WriteMsg(), and writeSeries().

float avg_Intvl
 

time (day) interval between recurring-average summaries

Definition at line 64 of file generic_driver.h.

SeriesParm pSeries[MAX_PTSERIES]
 

An array of SeriesParm structs for point time series output

Definition at line 87 of file generic_driver.h.

Referenced by get_parmf(), main(), open_point_lists(), print_point(), send_point_lists2(), and setup().

ViewParm* view
 

Definition at line 86 of file generic_driver.h.

Referenced by main(), and readViewParms().

Point2D dbgPt
 

struct of type Point2D, the grid location of a point

Definition at line 88 of file generic_driver.h.

Referenced by get_parmf(), read_map_file(), and write_map_file().

struct nodenv env
 

struct of nodenv, with parallel code info

Definition at line 90 of file generic_driver.h.

Referenced by setup_platform().

int gbl_size[2]
 

row [0] and column [1] dimensions of model grid domain, serial implementation

Definition at line 39 of file generic_driver.h.

int lcl_size[2]
 

Data for parallel implementation, basically ignore

Lprocnum NA for serial implementation (=1)
procnum NA for serial implementation (also see nodenv struct)
nprocs NA for serial implementation (also see nodenv struct)
recpnum NA for serial implementation
tramType NA for serial implementation
tramNum NA for serial implementation
lcl_size used in serial code, but not really pertinent: in serial implementation, rows lcl_size[0]=s0 and columns lcl_size[1]=s1, dimensions of model grid domain local to one processor (for parallel implementation)
lcl_start used in serial code, but not really pertinent: in serial implementation, starting row lcl_start[0]=0 and starting column lcl_start[1]=0 in model grid domain local to one processor (for parallel implementation)

Definition at line 102 of file generic_driver.h.

Referenced by read_map_file(), and setup_grid().

int lcl_start[2]
 

Data for parallel implementation, basically ignore

Lprocnum NA for serial implementation (=1)
procnum NA for serial implementation (also see nodenv struct)
nprocs NA for serial implementation (also see nodenv struct)
recpnum NA for serial implementation
tramType NA for serial implementation
tramNum NA for serial implementation
lcl_size used in serial code, but not really pertinent: in serial implementation, rows lcl_size[0]=s0 and columns lcl_size[1]=s1, dimensions of model grid domain local to one processor (for parallel implementation)
lcl_start used in serial code, but not really pertinent: in serial implementation, starting row lcl_start[0]=0 and starting column lcl_start[1]=0 in model grid domain local to one processor (for parallel implementation)

Definition at line 102 of file generic_driver.h.

Referenced by print_loc_ave(), print_point(), PTSL_GetInterpolatedValue0(), quick_look(), and setup_grid().

int N_iter
 

count of maximum number of model time iterations

Definition at line 60 of file generic_driver.h.

Referenced by get_parmf(), print_point(), and track_time().

int istep
 

counter for number of model time iterations

Definition at line 61 of file generic_driver.h.

Referenced by main(), quick_look(), and track_time().

int procnum
 

Data for parallel implementation, basically ignore

Lprocnum NA for serial implementation (=1)
procnum NA for serial implementation (also see nodenv struct)
nprocs NA for serial implementation (also see nodenv struct)
recpnum NA for serial implementation
tramType NA for serial implementation
tramNum NA for serial implementation
lcl_size used in serial code, but not really pertinent: in serial implementation, rows lcl_size[0]=s0 and columns lcl_size[1]=s1, dimensions of model grid domain local to one processor (for parallel implementation)
lcl_start used in serial code, but not really pertinent: in serial implementation, starting row lcl_start[0]=0 and starting column lcl_start[1]=0 in model grid domain local to one processor (for parallel implementation)

Definition at line 102 of file generic_driver.h.

int Lprocnum
 

Data for parallel implementation, basically ignore

Lprocnum NA for serial implementation (=1)
procnum NA for serial implementation (also see nodenv struct)
nprocs NA for serial implementation (also see nodenv struct)
recpnum NA for serial implementation
tramType NA for serial implementation
tramNum NA for serial implementation
lcl_size used in serial code, but not really pertinent: in serial implementation, rows lcl_size[0]=s0 and columns lcl_size[1]=s1, dimensions of model grid domain local to one processor (for parallel implementation)
lcl_start used in serial code, but not really pertinent: in serial implementation, starting row lcl_start[0]=0 and starting column lcl_start[1]=0 in model grid domain local to one processor (for parallel implementation)

Definition at line 102 of file generic_driver.h.

int nprocs[2]
 

Data for parallel implementation, basically ignore

Lprocnum NA for serial implementation (=1)
procnum NA for serial implementation (also see nodenv struct)
nprocs NA for serial implementation (also see nodenv struct)
recpnum NA for serial implementation
tramType NA for serial implementation
tramNum NA for serial implementation
lcl_size used in serial code, but not really pertinent: in serial implementation, rows lcl_size[0]=s0 and columns lcl_size[1]=s1, dimensions of model grid domain local to one processor (for parallel implementation)
lcl_start used in serial code, but not really pertinent: in serial implementation, starting row lcl_start[0]=0 and starting column lcl_start[1]=0 in model grid domain local to one processor (for parallel implementation)

Definition at line 102 of file generic_driver.h.

int recpnum[2]
 

Data for parallel implementation, basically ignore

Lprocnum NA for serial implementation (=1)
procnum NA for serial implementation (also see nodenv struct)
nprocs NA for serial implementation (also see nodenv struct)
recpnum NA for serial implementation
tramType NA for serial implementation
tramNum NA for serial implementation
lcl_size used in serial code, but not really pertinent: in serial implementation, rows lcl_size[0]=s0 and columns lcl_size[1]=s1, dimensions of model grid domain local to one processor (for parallel implementation)
lcl_start used in serial code, but not really pertinent: in serial implementation, starting row lcl_start[0]=0 and starting column lcl_start[1]=0 in model grid domain local to one processor (for parallel implementation)

Definition at line 102 of file generic_driver.h.

float gRTable[]
 

data used in function Normal, which is unused

Definition at line 80 of file generic_driver.h.

Referenced by Normal().

float GP_IDW_pow
 

Global parameter. _Units_: dimless; _Brief_: ***power for (all) inverse distance^parm interpolations; _Extended_: have always used IDW^2 (parm=2.0)

Definition at line 36 of file unitmod_globparms.h.

Referenced by ReadGlobalParms().

int numBasn
 

number of basins in model domain

Definition at line 32 of file budgstats.h.

Referenced by alloc_mem_stats(), BIRbudg_date(), BIRbudg_reset(), BIRinit(), BIRoutfiles(), BIRstats_date(), and BIRstats_reset().


Generated on Thu Jul 6 11:18:49 2006 for ELM source code by  doxygen 1.3.9.1