Ecological Landscape Modeling: Models Pages |
#include "globals.h"
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) |
ViewParm * | read_output_parms (void) |
Call the read_output_parms function. | |
ViewParm * | readOutlist (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, const char *units, int outstep, char *fileName) |
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):. | |
RPointList * | RPL_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). | |
PTSeriesList * | PTSL_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 | writeFloatMap (char *, char *, float *, int, unsigned char, int, char *, int) |
Write floating point data for spatial (map) output binary file (new v2.8.2). | |
void | writeFloatNetCDF (char *, char *, float *, int, unsigned char, int, char *, int) |
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. | |
int | ReadModExperimParms (char *s_parm_name, int s_parm_relval) |
Acquire the model parameters that are used in special model experiments - used only in special, research-oriented applications. (Added for v2.6). NOTE that this was quickly set up for the ELM Peer Review (2006) project, and (at least in v2.6.0) should be used in conjunction with the spatial interpolators for rain and pET inputs. (because this is intended for scales that are potentially incompatible w/ simultaneous use of gridIO inputs on SFWMM stage/depth that are expected w/ gridIO rain/pET). NOTE: this has not been specifically developed/tested for inclusion within the automated sensitivity analyses - thus only been used at this point for the ModExperimParms_NOM nominal parameter set (Nov 2006). . | |
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 |
UCHAR * | gTemp |
float * | floatOut |
float * | nc_dataRowRev |
float | offMap_float = -9999.0 |
char | gCArg [kCArgDepth][kCArgWidth] |
FILE * | Driver_outfile |
float | avg_Intvl |
SeriesParm | pSeries [MAX_PTSERIES] |
ViewParm * | view |
Point2D | dbgPt |
struct 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 |
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: June 2008
Definition in file driver_utilities.h.
#define Outlist_size 250 |
The (maximum) number of variables in model outlist
Definition at line 28 of file driver_utilities.h.
Referenced by read_output_parms().
VOIDP nalloc | ( | unsigned | mem_size, | |
const char | var_name[] | |||
) |
Allocate memory for a variable.
mem_size | The size of memory space | |
var_name | The variable's name |
Definition at line 1857 of file Driver_Utilities.c.
01858 { 01859 VOIDP rp; 01860 01861 01862 if(mem_size == 0) return(NULL); 01863 rp = (VOIDP)malloc( mem_size ); 01864 total_memory += mem_size; 01865 fasync(stderr); 01866 if( rp == NULL ) { 01867 fprintf(stderr,"Sorry, out of memory(%d): %s\n",mem_size,var_name); 01868 Exit(0); 01869 } 01870 fmulti(stderr); 01871 return(rp); 01872 }
void init_pvar | ( | VOIDP | Map, | |
UCHAR * | mask, | |||
unsigned char | Mtype, | |||
float | iv | |||
) |
Initialize a variable to a value.
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 1008 of file Driver_Utilities.c.
Referenced by alloc_hab_hist(), alloc_mem_stats(), alloc_memory(), Canal_Network_Init(), Channel_configure(), and setup_grid().
01009 { 01010 int i0, i1; 01011 01012 switch(Mtype) { 01013 case 'b' : /* added double for (non-map) basin (b) array budget calcs */ 01014 for(i0=0; i0<=numBasn; i0++) { 01015 ((double*)Map)[i0] = iv; 01016 } 01017 break; 01018 case 'l' : /* added double (l == letter "ell" ) for map arrays */ 01019 for(i0=0; i0<=s0+1; i0++) 01020 for(i1=0; i1<=s1+1; i1++) { 01021 if(mask==NULL) ((double*)Map)[T(i0,i1)] = iv; 01022 else if ( mask[T(i0,i1)] == 0 ) ((double*)Map)[T(i0,i1)] = 0; 01023 else ((double*)Map)[T(i0,i1)] = iv; 01024 } 01025 break; 01026 case 'f' : 01027 for(i0=0; i0<=s0+1; i0++) 01028 for(i1=0; i1<=s1+1; i1++) { 01029 if(mask==NULL) ((float*)Map)[T(i0,i1)] = iv; 01030 else if ( mask[T(i0,i1)] == 0 ) ((float*)Map)[T(i0,i1)] = 0; 01031 else ((float*)Map)[T(i0,i1)] = iv; 01032 } 01033 break; 01034 case 'i' : case 'd' : 01035 for(i0=0; i0<=s0+1; i0++) 01036 for(i1=0; i1<=s1+1; i1++) { 01037 if(mask==NULL) ((int*)Map)[T(i0,i1)] = (int)iv; 01038 else if ( mask[T(i0,i1)] == 0 ) ((int*)Map)[T(i0,i1)] = 0; 01039 else ((int*)Map)[T(i0,i1)] = (int)iv; 01040 } 01041 break; 01042 case 'c' : 01043 for(i0=0; i0<=s0+1; i0++) 01044 for(i1=0; i1<=s1+1; i1++) { 01045 if(mask==NULL) ((unsigned char*)Map)[T(i0,i1)] = (unsigned char) '\0' + (int) iv; 01046 else if ( mask[T(i0,i1)] == 0 ) ((unsigned char*)Map)[T(i0,i1)] = '\0'; 01047 else ((unsigned char*)Map)[T(i0,i1)] = (unsigned char) '\0' + (int) iv; 01048 } 01049 break; 01050 01051 default : 01052 printf(" in default case\n"); 01053 break; 01054 } 01055 }
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
filename | character string of the representative map (usually "Elevation") |
Definition at line 975 of file Driver_Utilities.c.
Referenced by get_map_dims().
00976 { 00977 FILE *file; 00978 00979 if (debug>3) { sprintf(msgStr,"Getting map dims: %s",filename); usrErr(msgStr);} 00980 if(Lprocnum == 1) { 00981 sprintf(modelFileName,"%s/%s/Data/Map_head/%s",ModelPath,ProjName,filename); 00982 file = fopen(modelFileName,"r"); 00983 if(file==NULL) { 00984 fprintf(stderr,"Unable to open map header file %s.\n",modelFileName); 00985 fflush(stderr); 00986 Exit(0); 00987 } 00988 scan_forward(file,"cols:"); 00989 fscanf(file,"%d",&gbl_size[1]); 00990 sprintf(msgStr,"cols = %d\n",gbl_size[1]); WriteMsg(msgStr,1); 00991 scan_forward(file,"rows:"); 00992 fscanf(file,"%d",&gbl_size[0]); 00993 sprintf(msgStr,"rows = %d\n",gbl_size[0]); WriteMsg(msgStr,1); 00994 fclose(file); 00995 } 00996 broadcastInt(gbl_size); /* does nothing in serial (non-parallel) implementation */ 00997 broadcastInt(gbl_size+1); /* does nothing in serial (non-parallel) implementation */ 00998 s0 = gbl_size[0]; 00999 s1 = gbl_size[1]; 01000 }
void read_model_parameters | ( | char * | s_parm_name, | |
int | s_parm_relval | |||
) |
Call functions to read model parameters from datafiles.
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 39 of file Driver_Utilities.c.
References msgStr, ReadGlobalParms(), ReadHabParms(), ReadModExperimParms(), usrErr(), usrErr0(), and WriteMsg().
00039 { 00040 00041 sprintf(msgStr,"Reading global parameters..."); 00042 WriteMsg(msgStr,1); 00043 usrErr0(msgStr); 00044 00045 ReadGlobalParms(s_parm_name, s_parm_relval); 00046 sprintf(msgStr,"done."); 00047 WriteMsg(msgStr,1); 00048 usrErr(msgStr); 00049 00050 sprintf(msgStr,"Reading habitat-specific parameters..."); 00051 WriteMsg(msgStr,1); 00052 usrErr0(msgStr); 00053 00054 ReadHabParms(s_parm_name, s_parm_relval); 00055 sprintf(msgStr,"done."); 00056 WriteMsg(msgStr,1); 00057 usrErr(msgStr); 00058 00059 /* v2.6 - don't write message to console until later (when determine if parm file is used or not) */ 00060 ReadModExperimParms(s_parm_name, s_parm_relval); 00061 00062 }
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.
Definition at line 66 of file Driver_Utilities.c.
References Outlist_size, and readOutlist().
00066 { 00067 /* need to change the Outlist_size (#defined in header) if adding outlist variables to the data struct in gen_output of UnitMod.c */ 00068 ViewParm* v = readOutlist(Outlist_size); 00069 return v; 00070 }
ViewParm* readOutlist | ( | int | size | ) |
Get the file to configure model output.
size | Outlist_size, the number of variables in model outlist |
Definition at line 75 of file Driver_Utilities.c.
References cnfgFile, H_OPSYS, modelFileName, ModelPath, msgStr, ProjName, readViewParms(), UNIX, and WriteMsg().
Referenced by read_output_parms().
00076 { 00077 int Npt; 00078 ViewParm* vp; 00079 FILE *cnfgFile; 00080 00081 if(H_OPSYS==UNIX) sprintf(modelFileName,"%s/%s/RunParms/Model.outList",ModelPath,ProjName); 00082 else sprintf(modelFileName,"%s%s:RunParms:Model.outList",ModelPath,ProjName); 00083 cnfgFile = fopen(modelFileName, "r"); 00084 if (cnfgFile == NULL) { 00085 sprintf(msgStr, "Error, can't open file %s", modelFileName); 00086 WriteMsg(msgStr, 1); exit(-1);} 00087 00088 Npt = readViewParms(cnfgFile,size, &vp); 00089 return vp; 00090 00091 }
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.
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 |
Definition at line 105 of file Driver_Utilities.c.
References avg_Intvl, viewParm::bounds, CalMonOut, debug, 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(), viewParm::varUnits, view, scale2::Vmax, scale2::Vmin, WriteMsg(), point3D::x, point3D::y, and point3D::z.
Referenced by readOutlist().
00106 { 00107 char test; 00108 char cmd; 00109 int index=0, ix, iy, iz, i, nArgs, precision, format=0, Ocmd; 00110 float x,y; 00111 ViewParm *vp, *view; 00112 00113 format = init_config_file(vpFile, '#', '*', '@', '~'); 00114 view = (ViewParm *)nalloc(size * sizeof(ViewParm), "view"); 00115 *ppview = view; 00116 00117 for (i = 0; i < size; i++) { 00118 vp = view+i; 00119 vp->scale.s = 1.0; 00120 vp->scale.o = 0.0; 00121 vp->step = 0; 00122 Ocmd=0; 00123 vp->nPoints = 0; 00124 vp->points = NULL; 00125 vp->maxPoints = 0; 00126 vp->mapType = 'N'; 00127 precision = 1; 00128 setPrecision(vp,precision); 00129 } 00130 00131 while(1) { 00132 index = parse_packet(vpFile, &nArgs, &test);/*fix*/ 00133 if( index == -1) break; 00134 if( index == -3) break; 00135 if(index >= size) { 00136 fprintf(stderr,"\n Read index Error in configuration: index out of range: %d ", index); 00137 break; 00138 } 00139 if( index == -2) break; 00140 else { 00141 vp = view+index; 00142 strncpy(vp->fileName,gCArg[0],23); 00143 vp->fileName[23]='\0'; 00144 if( test == '*' ) setFlag(vp,ISARRAY,1); 00145 else if (test == '@') setFlag(vp,ISARRAY,0); 00146 else { 00147 sprintf(msgStr," %s: Syntax Error in configuration, test char = %c ",gCArg[0],test); 00148 usrErr(msgStr); 00149 break; 00150 } 00151 if(debug && gCArg[1][0] != 'U') { 00152 sprintf(msgStr,"\nReading Output Config for %s: Nargs = %d, CMD0 = %c index = %d", 00153 gCArg[0],nArgs,gCArg[1][0],index); 00154 WriteMsg(msgStr,1); 00155 } 00156 cmd = gCArg[1][0]; 00157 switch (cmd) { 00158 case 'U': /* v2.8.2 - new "command" for variables' units; this is actually not a "command" for requesting output, but simply uses the command syntax to encapsulate the string of units */ 00159 strncpy(vp->varUnits,gCArg[2],23); 00160 vp->varUnits[23]='\0'; 00161 if(debug > 3) { 00162 sprintf(msgStr,"\n%s Output Config: Units= %s",gCArg[0],gCArg[2]); 00163 WriteMsg(msgStr,1); 00164 } 00165 00166 break; 00167 case 'O': 00168 if( isInteger(gCArg[2]) ) { ix = atoi(gCArg[2]); } 00169 else fprintf(stderr," %s: Syntax Error in configuration ",gCArg[0]); 00170 if(debug) { 00171 sprintf(msgStr,"\n%s Output Config: O(%d)",gCArg[0],ix); 00172 WriteMsg(msgStr,1); 00173 } 00174 vp->step = ix; Ocmd=1; 00175 /* TODO: develop flexible output of calendar-based and julian-based outsteps (jan 11, 2005) */ 00176 /* kluge here in checking use of Model.outList outstep relative to Driver.parm avg_Intvl */ 00177 if (vp->step == CalMonOut && avg_Intvl != 0) { 00178 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]); 00179 usrErr(msgStr); 00180 exit(-1); 00181 } 00182 00183 break; 00184 case 'A': 00185 if( isInteger(gCArg[2]) && nArgs > 2 ) { ix = atoi(gCArg[2]); } 00186 else { 00187 fprintf(stderr," %s: Syntax Error in configuration ",gCArg[0]); 00188 WriteMsg(msgStr,1); 00189 } 00190 if(debug) { 00191 sprintf(msgStr,"\n%s Output Config: A()",gCArg[0]); 00192 WriteMsg(msgStr,1); 00193 } 00194 vp->mapType = 'H'; 00195 if( Ocmd == 0 ) vp->step = 1; 00196 break; 00197 case 'G': 00198 if ( nArgs > 2 ) { 00199 if( isInteger(gCArg[2]) ) { 00200 vp->mapType = atoi(gCArg[2]); 00201 } 00202 else { vp->mapType =gCArg[2][0]; } 00203 } 00204 if ( nArgs > 3 ) 00205 if( isInteger(gCArg[3]) ) { 00206 precision = atoi(gCArg[3]); 00207 } 00208 if ( nArgs > 4 ) strcpy(vp->fileName,gCArg[4]); 00209 if( precision > 1 && precision < 5 ) setPrecision(vp,precision); 00210 if( Ocmd == 0 ) vp->step = 1; 00211 break; 00212 case 'B': 00213 if( isFloat(gCArg[2]) && isFloat(gCArg[3]) && nArgs > 3 ) { 00214 vp->bounds.Vmax = atof(gCArg[2]); 00215 vp->bounds.Vmin = atof(gCArg[3]); 00216 } 00217 if(debug) { 00218 sprintf(msgStr,"\n Output Config: G(%.1f,%.1f)", 00219 vp->bounds.Vmax, vp->bounds.Vmin); 00220 WriteMsg(msgStr,1); 00221 } 00222 break; 00223 case 'P': 00224 if( isInteger(gCArg[2]) && isInteger(gCArg[3]) && nArgs > 3 ) { 00225 if( (i = (++(vp->nPoints)-1)) >= (vp->maxPoints)) make_more_points(vp,7); 00226 ix = atoi(gCArg[2]); iy = atoi(gCArg[3]); 00227 } 00228 else fprintf(stderr," %s: Syntax Error in configuration ",gCArg[0]); 00229 if(debug) { 00230 sprintf(msgStr,"\n%s Output Config: P(%d,%d), index = %d",gCArg[0],ix,iy,i); 00231 WriteMsg(msgStr,1); 00232 } 00233 vp->points[i].x = ix; 00234 vp->points[i].y = iy; 00235 vp->points[i].type = 'p'; 00236 /* TODO: develop flexible output of calendar-based and julian-based outsteps (jan 11, 2005) */ 00237 /* kluge here in preventing use of point time series output using calendar-based outstep */ 00238 if (vp->step == CalMonOut) { 00239 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]); 00240 usrErr(msgStr); 00241 exit(-1); 00242 } 00243 break; 00244 case 'W': 00245 if( isInteger(gCArg[2]) && isInteger(gCArg[3]) && isInteger(gCArg[4]) && nArgs > 4 ) { 00246 if( (i = (++(vp->nPoints)-1)) >= (vp->maxPoints)) make_more_points(vp,7); 00247 ix = atoi(gCArg[2]); iy = atoi(gCArg[3]); iz = atoi(gCArg[4]); 00248 } 00249 else fprintf(stderr," %s: Syntax Error in configuration ",gCArg[0]); 00250 if( nArgs > 5 ) vp->points[i].format = gCArg[5][0]; 00251 vp->points[i].type = 'w'; 00252 vp->points[i].x = ix; 00253 vp->points[i].y = iy; 00254 vp->points[i].z = iz; 00255 if(debug) { 00256 sprintf(msgStr,"\n%s Output Config: W(%d,%d,%d,%c), index = %d", 00257 gCArg[0],ix,iy,iz,vp->points[i].format,i); 00258 WriteMsg(msgStr,1); 00259 } 00260 if( Ocmd == 0 ) vp->step = 1; 00261 break; 00262 case 'S': case 'C': 00263 if( gCArg[1][1] == 'm' || gCArg[1][0] == 'C' ) { 00264 if( isInteger(gCArg[2]) && isInteger(gCArg[3]) && isInteger(gCArg[4]) && nArgs > 5 ) { 00265 if( (i = (++(vp->nPoints)-1)) >= (vp->maxPoints)) make_more_points(vp,7); 00266 ix = atoi(gCArg[2]); iy = atoi(gCArg[3]); iz = atoi(gCArg[4]); 00267 vp->points[i].type = gCArg[5][0]; 00268 } 00269 else fprintf(stderr," %s: Syntax Error in configuration ",gCArg[0]); 00270 vp->points[i].x = ix; 00271 vp->points[i].y = iy; 00272 vp->points[i].z = iz; 00273 if(debug) { 00274 sprintf(msgStr,"\n%s Output Config: Sm(%d,%d,%d,%c), index = %d", 00275 gCArg[0],ix,iy,iz,gCArg[4][0],i); 00276 WriteMsg(msgStr,1); 00277 } 00278 if( Ocmd == 0 ) vp->step = 1; 00279 } 00280 else { 00281 if( nArgs > 2 ) { 00282 if( isFloat(gCArg[2]) ) { x = atof(gCArg[2]); } 00283 else fprintf(stderr," %s: Syntax Error in configuration ",gCArg[0]); 00284 } 00285 if( nArgs > 3 ) { 00286 if( isFloat(gCArg[3]) ) { y = atof(gCArg[3]); } 00287 else fprintf(stderr," %s: Syntax Error in configuration ",gCArg[0]); 00288 } 00289 if(debug) { 00290 sprintf(msgStr,"\n%s Output Config: S(%f,%f)",gCArg[0],x,y); 00291 WriteMsg(msgStr,1); 00292 } 00293 vp->scale.s = x; 00294 vp->scale.o = y; 00295 } 00296 break; 00297 } /* end of switch */ 00298 } /* end of else */ 00299 } /* end of while */ 00300 return size; 00301 }
void setPrecision | ( | ViewParm * | vp, | |
int | value | |||
) |
(Effectively unused).
Definition at line 1417 of file Driver_Utilities.c.
References viewParm::flags, PMASK1, and PMASK2.
Referenced by readViewParms().
01418 { 01419 if(value/3) vp->flags |= PMASK2; else vp->flags &= ~PMASK2; 01420 if((value-1)%2) vp->flags |= PMASK1; else vp->flags &= ~PMASK1; 01421 }
int write_map_file | ( | const char * | filename, | |
VOIDP | Map, | |||
char | Mtype, | |||
int | index, | |||
float | scale_value, | |||
float | offset_value, | |||
int | bSize, | |||
unsigned char | type, | |||
const char * | thisvarUnits, | |||
int | outstep, | |||
char * | ncFileName | |||
) |
Prepare the file and the data for writing output of map (array).
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 | |
thisvarUnits | Units of the output variable | |
outstep | The output interval time step | |
ncFileName | The filename for netCDF output |
Definition at line 473 of file Driver_Utilities.c.
References CASE, check_for(), simTime::da, dbgPt, debug, enc_Nb(), END, floatOut, gridSize, gTemp, gTempSize, H_OPSYS, HDF4, simTime::mo, modelFileName, msgStr, nalloc(), NCDF3, offMap_float, ON_MAP, OutputPath, ProjName, quick_look(), s0, s1, SimTime, T, UNIX, writeFloatMap(), writeMap(), WriteMsg(), point2D::x, point2D::y, and simTime::yr.
Referenced by write_output().
00476 { 00477 int i, j, pathType=0; 00478 char ftype[10], gSize; 00479 float ftmp; 00480 SLONG itmp, imax, imin; 00481 UCHAR *mPtr; 00482 char s_mo[3], s_da[3]; 00483 FILE* bFile; 00484 00485 /* below provides old (v1.0) increasing integer, non-date, appendage to filenames */ 00486 /* ftype[0] = '0' + (index / 100); */ 00487 /* ftype[1] = '0' + ((index%100) / 10); */ 00488 /* ftype[2] = '0' + (index % 10); */ 00489 /* ftype[8] = '\0'; */ 00490 00491 /* append the date (yyyymmdd) to the root filename*/ 00492 if (SimTime.mo[0]<10) sprintf(s_mo,"0%d", SimTime.mo[0]); 00493 else sprintf(s_mo,"%d", SimTime.mo[0]); 00494 if (SimTime.da[0]<10) sprintf(s_da,"0%d", SimTime.da[0]); 00495 else sprintf(s_da,"%d", SimTime.da[0]); 00496 sprintf(ftype,"%d%s%s\0",SimTime.yr[0],s_mo,s_da); 00497 00498 if( HDF4 && type=='H' ) sprintf(ftype,".hdf"); 00499 00500 if( NCDF3 && type=='C' ) sprintf(ftype,".nc"); 00501 00502 gSize = gridSize*bSize + 1; 00503 if( gSize > gTempSize ) { 00504 if(gTempSize) free((char*)gTemp); 00505 gTemp = (UCHAR*) nalloc( gSize, "gTemp" ); 00506 gTempSize = gSize; 00507 } 00508 00509 if( H_OPSYS == UNIX ){ 00510 if(check_for((char*)filename, "/", 0, CASE, END ) >= 0 ) { 00511 if(filename[0] != '/' ) pathType = 1; 00512 else pathType = 2; 00513 } 00514 } 00515 else { if(check_for ((char*)filename, ":", 0, CASE, END ) >= 0 ) { if( filename[0] == ':' ) pathType = 1; else pathType = 2; }} 00516 00517 if(type=='H') { /* HDF format */ 00518 switch(pathType) { 00519 case 0: /* No Path */ 00520 if(H_OPSYS==UNIX) sprintf(modelFileName,"%s/%s/Output/HDF/%s%s\0",OutputPath,ProjName,filename,ftype); 00521 else sprintf(modelFileName,"%s%s:Output:HDF:%s%s\0",OutputPath,ProjName,filename,ftype); 00522 break; 00523 case 1: /* Relative Path */ 00524 if(H_OPSYS==UNIX) sprintf(modelFileName,"%s/%s/Output/HDF/%s%s\0",OutputPath,ProjName,filename,ftype); 00525 else sprintf(modelFileName,"%s%s:Output:HDF:%s%s\0",OutputPath,ProjName,filename,ftype); 00526 break; 00527 case 2: /* Full Path */ 00528 sprintf(modelFileName,"%s.hdf\0",filename); 00529 break; 00530 } 00531 } 00532 00533 else if(type=='C') { /* netCDF format */ 00534 switch(pathType) { 00535 case 0: /* No Path */ 00536 if(H_OPSYS==UNIX) sprintf(modelFileName,"%s/%s/Output/NCDF/%s%s\0",OutputPath,ProjName,ncFileName,ftype); 00537 else sprintf(modelFileName,"%s%s:Output:NCDF:%s%s\0",OutputPath,ProjName,ncFileName,ftype); 00538 break; 00539 case 1: /* Relative Path */ 00540 if(H_OPSYS==UNIX) sprintf(modelFileName,"%s/%s/Output/NCDF/%s%s\0",OutputPath,ProjName,ncFileName,ftype); 00541 else sprintf(modelFileName,"%s%s:Output:NCDF:%s%s\0",OutputPath,ProjName,ncFileName,ftype); 00542 break; 00543 case 2: /* Full Path (not used) */ 00544 sprintf(modelFileName,"%s.hdf\0",filename); 00545 break; 00546 } 00547 } 00548 00549 else if(type=='M') { 00550 switch(pathType) { /* M==Map, generic binary (possibly larger than uchar size binary) Format */ 00551 case 0: /* No Path */ 00552 // v2.8.2 changed to varname-specific directory, must be existing directory (user will have to create, for now 00553 if(H_OPSYS==UNIX) sprintf(modelFileName,"%s/%s/Output/%s/%s%s\0",OutputPath,ProjName,filename,filename,ftype); 00554 else sprintf(modelFileName,"%s%s:Output:%s:%s%s\0",OutputPath,ProjName,filename,filename,ftype); 00555 break; 00556 case 1: /* Relative Path */ 00557 if(H_OPSYS==UNIX) sprintf(modelFileName,"%s/%s/Output/%s/%s%s\0",OutputPath,ProjName,filename,filename,ftype); 00558 else sprintf(modelFileName,"%s%s:Output:%s:%s%s\0",OutputPath,ProjName,filename,filename,ftype); 00559 break; 00560 case 2: /* Full Path */ 00561 sprintf(modelFileName,"%s%s\0",filename,ftype); 00562 break; 00563 } 00564 } 00565 else { 00566 bSize = 1; 00567 switch(pathType) { /* Generic Binary Format (uchar, 0-254 ints) */ 00568 case 0: /* No Path */ 00569 if(H_OPSYS==UNIX) sprintf(modelFileName,"%s/%s/Output/Animation%d/%s%s\0",OutputPath,ProjName,type,filename,ftype); 00570 else sprintf(modelFileName,"%s%s:Output:Animation%d:%s%s\0",OutputPath,ProjName,type,filename,ftype); 00571 break; 00572 case 1: /* Relative Path */ 00573 if(H_OPSYS==UNIX) sprintf(modelFileName,"%s/%s/Output/Animation%d/%s%s\0",OutputPath,ProjName,type,filename,ftype); 00574 else sprintf(modelFileName,"%s%s:Output:Animation%d:%s%s\0",OutputPath,ProjName,type,filename,ftype); 00575 break; 00576 case 2: /* Full Path */ 00577 sprintf(modelFileName,"%s%s\0",filename,ftype); 00578 break; 00579 } 00580 } 00581 00582 bSize = (bSize < 1) ? 1 : bSize; 00583 bSize = (bSize > 4) ? 4 : bSize; 00584 if( Mtype == 'c' ) bSize = 1; 00585 00586 /* New for v.2.8.2, providing capability to write (4 byte) floating point output maps. 00587 This may not be elegant, but will get it done for now. The issue is that 00588 the size of the arrays are actually s0+2, s1+2, which will later result in 00589 having larger array sizes for these output maps. Would need to use the equivalent 00590 of enc_Nb to consider only the data in s0,s1 array. */ 00591 if (bSize == 4) { 00592 00593 for (i=0; i< (s0+2); i++) { /* was trying to only resample within 0,s0, but gave up and using whole s0+2 array */ 00594 for (j=0; j< (s1+2); j++) { /* was trying to only resample within 0,s1, but gave up and using whole s1+2 array */ 00595 if( ON_MAP[T(i,j)] ) { /* for resampling, was using T(i+1,j+1) */ 00596 floatOut[T(i,j)] = (( (float*) Map)[T(i,j)]); 00597 } 00598 else { 00599 floatOut[T(i,j)] = offMap_float; /* for resampling */ 00600 // ( (float*) Map)[T(i,j)] = offMap_float; /* arrays were initialized to 0 */ 00601 } 00602 } 00603 } 00604 00605 if ( debug >3) { sprintf(msgStr,"\n\nWriting Float Map %s: no scaling should be used (scale and offset values are ignored, but should be 1 & 0, respectively) scale_value = %f, offset_value = %f, index = %d, filename = %s, type = %c, bSize = %d, pathType = %d, type = %d, units = %s\n", 00606 filename,scale_value,offset_value,index,modelFileName,Mtype,bSize,pathType,type,thisvarUnits); WriteMsg(msgStr,1); } 00607 00608 writeFloatMap(modelFileName,filename,floatOut,bSize,type,index,thisvarUnits,outstep); 00609 /* we're done with writing floats (no scaling done) */ 00610 return(0); 00611 } 00612 00613 00614 if(bSize == 1) { imax = 255; imin = 0; } 00615 else if(bSize == 2) { imax = 255*128; imin = -imax; } 00616 else if(bSize == 3) { imax = 256*256*128; imin = -imax; } 00617 mPtr = gTemp; 00618 00619 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", 00620 filename,scale_value,offset_value,index,modelFileName,Mtype,bSize,pathType,type); WriteMsg(msgStr,1); } 00621 00622 for (i=0; i<s0; i++) { 00623 for (j=0; j<s1; j++) { 00624 if( ON_MAP[T(i+1,j+1)] ) { 00625 switch(Mtype) { 00626 case 'l' : 00627 ftmp = ((( (double*) Map)[T(i+1,j+1)] - offset_value) / scale_value); /* v2.3.2 added double (casting to float ftmp) */ 00628 itmp = (int) ftmp; 00629 itmp = (itmp > imax-1) ? imax-1 : itmp; 00630 itmp = (itmp < imin) ? imin : itmp; 00631 break; 00632 case 'f' : 00633 ftmp = ((( (float*) Map)[T(i+1,j+1)] - offset_value) / scale_value); 00634 itmp = (int) ftmp; 00635 itmp = (itmp > imax-1) ? imax-1 : itmp; 00636 itmp = (itmp < imin) ? imin : itmp; 00637 break; 00638 case 'd' : case 'i' : 00639 ftmp = ((( (int*) Map)[T(i+1,j+1)] - offset_value) / scale_value); 00640 itmp = (int) ftmp; 00641 itmp = (itmp > imax-1) ? imax-1 : itmp; 00642 itmp = (itmp < imin) ? imin : itmp; 00643 break; 00644 case 'c' : 00645 itmp = ((unsigned char*) Map)[T(i+1,j+1)]; 00646 itmp = (itmp > imax-1) ? imax-1 : itmp; 00647 itmp = (itmp < imin) ? imin : itmp; 00648 break; 00649 } 00650 } 00651 else itmp = imax; 00652 00653 00654 enc_Nb(&mPtr,itmp,bSize); 00655 00656 } 00657 } 00658 00659 writeMap(modelFileName,gTemp,bSize,type,index); 00660 if(debug) quick_look(Map, (char*)filename, Mtype, dbgPt.x, dbgPt.y, 2,'E'); 00661 return(0); 00662 }
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).
filename | Input file name | |
Map | Model variable array data | |
Mtype | General data format type | |
scale_value | Variable-scaling multiplier | |
offset_value | Variable-scaling offset |
Definition at line 674 of file Driver_Utilities.c.
Referenced by init_dynam_data(), and init_static_data().
00677 { 00678 int i, j, k0, size; 00679 unsigned temp; 00680 UCHAR *tmpPtr, Dsize; 00681 00682 gridSize = (s0+2)*(s1+2); 00683 gTempSize = gridSize*8; 00684 00685 00686 size = gridSize*4 +1; 00687 if( size > gTempSize ) { 00688 if(gTemp) free((char*)gTemp); 00689 gTemp = (UCHAR*)nalloc( size, "gTemp" ); 00690 gTempSize = size; 00691 } 00692 00693 if(debug>2) { 00694 sprintf(msgStr,"Reading %s\n",filename); 00695 usrErr(msgStr); 00696 WriteMsg(msgStr,1); 00697 } 00698 00699 Dsize = readMap(filename,gTemp); 00700 00701 if(debug) { 00702 sprintf(msgStr,"name = %s, proc = %d, scale_value = %f, offset_value = %f, size = %x\n ", 00703 filename,procnum,scale_value,offset_value,Dsize); 00704 WriteMsg(msgStr,1); 00705 } 00706 for (i=1; i<=s0; i++) { 00707 for (j=1; j<=s1; j++) { 00708 k0 = Dsize*((i-1)*lcl_size[1] + (j-1)); 00709 tmpPtr = gTemp+k0; 00710 switch(Dsize) { 00711 case 1: temp = gTemp[k0]; break; 00712 case 2: temp = gTemp[k0]*256 + gTemp[k0+1]; break; 00713 case 3: temp = gTemp[k0]*65536 + gTemp[k0+1]*256 + gTemp[k0+2]; break; 00714 case 4: temp = gTemp[k0]*16777216 + gTemp[k0+1]*65536 + gTemp[k0+2]*256 + gTemp[k0+3]; break; 00715 default: fprintf(stderr,"ERROR, illegal size: %x\n",Dsize); temp = 0; 00716 } 00717 switch (Mtype) { 00718 case 'f' : 00719 ((float*)Map)[T(i,j)] = scale_value*((float)temp)+offset_value; 00720 break; 00721 case 'd' : case 'i' : 00722 ((int*)Map)[T(i,j)] = (int)(scale_value * (float)temp + offset_value); 00723 break; 00724 case 'c' : 00725 ((unsigned char*)Map)[T(i,j)] = (int)(scale_value * (unsigned char)temp); 00726 break; 00727 } 00728 } 00729 } 00730 if(debug) quick_look(Map, (char*)filename, Mtype, dbgPt.x, dbgPt.y, 2,'E'); 00731 link_edges(Map,Mtype); 00732 fflush(stderr); 00733 return Dsize; 00734 }
void print_loc_ave | ( | Point3D * | vt, | |
void * | Map, | |||
char | Mtype, | |||
char * | mName, | |||
int | tIndex | |||
) |
Calculate summary statistics to determine local average.
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 1065 of file Driver_Utilities.c.
References Combine(), kAVE, kAVECUM, kSUM, kSUMCUM, lcl_start, ON_MAP, s0, s1, T, point3D::type, point3D::x, point3D::y, and point3D::z.
Referenced by write_output().
01066 { 01067 int ix, iy, x, y, x0, y0, range, xmax, ymax, xmin, ymin, type = 11; 01068 float vout[4]; 01069 double sum = 0, normCoef = 0; 01070 01071 if(Mtype != 'f') { fprintf(stderr,"Warning: Wrong type in Loc Ave: %s(%c)\n",mName,Mtype); return; } 01072 x0 = vt->x; 01073 y0 = vt->y; 01074 range = vt->z; 01075 x = x0 - lcl_start[0]; 01076 y = y0 - lcl_start[1]; 01077 xmin = x - range; 01078 xmax = x + range; 01079 ymin = y - range; 01080 ymax = y + range; 01081 xmax = (xmax > (s0)) ? (s0) : xmax; 01082 xmin = (xmin < 0 ) ? 0 : xmin; 01083 ymax = (ymax > (s1)) ? (s1) : ymax; 01084 ymin = (ymin < 0 ) ? 0 : ymin; 01085 01086 for(ix=xmin; ix<xmax; ix++) { 01087 for(iy=ymin; iy<ymax; iy++) { 01088 if( ON_MAP[T(ix+1,iy+1)] ) sum += ((float*)Map)[T(ix+1,iy+1)]; 01089 normCoef += 1.0; 01090 } 01091 } 01092 01093 vout[0] = sum; vout[1] = normCoef; 01094 01095 switch (vt->type) { 01096 case 's' : Combine(vout,mName,1,kSUM,tIndex); break; /* Sum for all window cells at outStep iterations */ 01097 case 'a' : Combine(vout,mName,2,kAVE,tIndex); break; /* Average for all window cells at outStep iterations */ 01098 case 'A' : Combine(vout,mName,2,kAVECUM,tIndex); break; /* Cumulative average for all window cells over all outStep iterations */ 01099 case 'S' : Combine(vout,mName,1,kSUMCUM,tIndex); break; /* Cumulative sum for all window cells over all outStep iterations */ 01100 } 01101 }
void write_output | ( | int | index, | |
ViewParm * | vp, | |||
void * | Map, | |||
const char * | filename, | |||
char | Mtype, | |||
int | step | |||
) |
Determine which functions to call for model output.
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 output step |
Definition at line 435 of file Driver_Utilities.c.
Referenced by gen_output().
00437 { 00438 int i; Point3D point; 00439 00440 00441 if(vp->mapType != 'N' ) { 00442 write_map_file((char*)filename,Map,Mtype,index,vp->scale.s,vp->scale.o,getPrecision(vp),vp->mapType,vp->varUnits,vp->step,vp->fileName); /* v2.8.2 added varUnits, vp->step (which is outstep interval), and fileName for netCDF use */ 00443 if (debug > 3) calc_maxmin(vp,Map,Mtype,(char*)filename,step); 00444 } 00445 for(i=0; i< (vp->nPoints); i++ ) { 00446 point = vp->points[i]; 00447 if (debug > 3) { sprintf(msgStr,"\nwriting Out: %s(%d): %c(), index = %d, step=%d\n", filename, i, point.type, index, step ); 00448 WriteMsg(msgStr,1); 00449 } 00450 00451 switch( point.type ) { 00452 case 'm': case 'M': calc_maxmin( vp,Map,Mtype,(char*)filename,step); break; 00453 case 'w': quick_look( Map,(char*) filename, Mtype, point.x, point.y, point.z, point.format ); break; 00454 case 'a': case 's': case 'A': case 'S': print_loc_ave( &point, Map, Mtype, (char*)filename, step ); break; 00455 case 'p': print_point( vp, Map, Mtype, (char*)filename, step, i ); break; 00456 } 00457 } 00458 }
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).
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 929 of file Driver_Utilities.c.
References seriesParm::data, debug, fatal(), lcl_start, seriesParm::Length, seriesParm::Loc, MAX_PTSERIES, msgStr, N_iter, seriesParm::outstep, PListIndex, viewParm::points, pSeries, s0, s1, viewParm::step, T, usrErr(), WriteMsg(), point2D::x, point3D::x, point2D::y, point3D::y, and point3D::z.
Referenced by write_output().
00931 { 00932 int x, y; 00933 Point3D *pt; 00934 00935 pt = vp->points + vpindex; 00936 x = pt->x - lcl_start[0]; 00937 y = pt->y - lcl_start[1]; 00938 if( (x >= 0) && (x < s0) && (y >= 0) && (y < s1) ) { 00939 if(tIndex==0) { pt->z = PListIndex; pSeries[PListIndex].Length=0; 00940 } 00941 else PListIndex = pt->z; 00942 if(tIndex==0) { 00943 /* TODO: develop flexible output of calendar-based and julian-based outsteps (jan 11, 2005) */ 00944 if(PListIndex >= MAX_PTSERIES ) fatal("Too many Point series."); 00945 else if( pSeries[PListIndex].data == NULL ) pSeries[PListIndex].data = (float*) malloc( (N_iter*sizeof(float)/vp->step)+2 ); 00946 if( pSeries[PListIndex].data == NULL ) usrErr("out of Memory for Spatial Timeseries."); 00947 pSeries[PListIndex].Loc.x = pt->x; 00948 pSeries[PListIndex].Loc.y = pt->y; 00949 pSeries[PListIndex].outstep = vp->step; 00950 strcpy(pSeries[PListIndex].name,mName); 00951 if(debug >2) { 00952 sprintf(msgStr,"\nSetup Pointlist %d for %s(%d), step=%d, point=(%d,%d)\n", PListIndex, mName, vpindex, vp->step, x, y ); 00953 WriteMsg(msgStr,1); 00954 } 00955 } 00956 switch(Mtype) { 00957 case 'f' : pSeries[PListIndex].data[ pSeries[PListIndex].Length++ ] = ((float*)Map)[T(x+1,y+1)]; break; 00958 case 'i' : pSeries[PListIndex].data[ pSeries[PListIndex].Length++ ] = ((int*)Map)[T(x+1,y+1)]; break; 00959 case 'c' : pSeries[PListIndex].data[ pSeries[PListIndex].Length++ ] = ((unsigned char*)Map)[T(x+1,y+1)]; 00960 } 00961 if(debug >3) { 00962 sprintf(msgStr,"\nWriting Point %d for %s(%d), point=(%d,%d), value = %f, index = %d\n", 00963 PListIndex, mName, vpindex, x, y, ((float*)Map)[T(x+1,y+1)], pSeries[PListIndex].Length-1 ); 00964 WriteMsg(msgStr,1); 00965 } 00966 PListIndex++; 00967 } 00968 }
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.
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 843 of file Driver_Utilities.c.
References Copy(), gTemp, gTempSize, s1, T, and writeSeries().
Referenced by quick_look().
00846 { 00847 int mSize, size; 00848 char ctemp[200]; 00849 00850 switch(Mtype) { 00851 case 'l': size = sizeof(double); break; /* v2.3.2 added */ 00852 case 'f': case 'L': case 'E': size = sizeof(float); break; 00853 case 'd': case 'i': size = sizeof(int); break; 00854 case 'c': size = sizeof(char); break; 00855 } 00856 if( (mSize=size*N0*N1) > gTempSize ) { 00857 if(gTemp != NULL) free((char*)gTemp); 00858 gTemp = (UCHAR*)malloc(gTempSize=mSize); 00859 } 00860 00861 Copy(((UCHAR*)fValue)+T(x0,y0)*size, gTemp, N1*size, N0, (s1+2)*size, N1*size); 00862 sprintf(ctemp,"(%d)WIND: %s",index,vName); 00863 writeSeries(gTemp,ctemp,desc,N0,N1,Mtype,format); 00864 }
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.
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 344 of file Driver_Utilities.c.
References Combine(), viewParm::gScale, kMAXMIN, ON_MAP, s0, s1, T, scale2::Vmax, and scale2::Vmin.
Referenced by write_output().
00345 { 00346 int ix, iy; 00347 float vout[4], ftmp, fmax = -1000, fmin = 1000; 00348 00349 switch(Mtype) { 00350 case 'f' : 00351 for(ix=1; ix<=s0; ix++) 00352 for(iy=1; iy<=s1; iy++) { 00353 if( ON_MAP[T(ix,iy)] ) { 00354 if( (ftmp = ((float*)Map)[T(ix,iy)]) > fmax ) { 00355 fmax = ftmp; 00356 } 00357 if( ftmp < fmin ) fmin = ftmp; 00358 } 00359 } 00360 break; 00361 case 'i' : case 'd' : 00362 for(ix=1; ix<=s0; ix++) 00363 for(iy=1; iy<=s1; iy++) { 00364 if( ON_MAP[T(ix,iy)] ) { 00365 if((ftmp = ((int*)Map)[T(ix,iy)]) > fmax ) fmax = ftmp; 00366 if( ftmp < fmin ) fmin = ftmp; 00367 } 00368 } 00369 break; 00370 case 'c' : 00371 for(ix=1; ix<=s0; ix++) 00372 for(iy=1; iy<=s1; iy++) { 00373 if( ON_MAP[T(ix,iy)] ) { 00374 if( (ftmp = (float)((unsigned char*)Map)[T(ix,iy)]) > fmax ) fmax = ftmp; 00375 if( ftmp < fmin ) fmin = ftmp; 00376 } 00377 } 00378 break; 00379 } 00380 if(step==0) { 00381 vp->gScale.Vmax = fmax; 00382 vp->gScale.Vmin = fmin; 00383 } else { 00384 if( fmax > vp->gScale.Vmax ) vp->gScale.Vmax = fmax; 00385 if( fmin < vp->gScale.Vmin ) vp->gScale.Vmin = fmin; 00386 } 00387 vout[0] = fmax; vout[1] = vp->gScale.Vmax; vout[2] = fmin; vout[3] = vp->gScale.Vmin; 00388 Combine(vout,mName,4,kMAXMIN,step); /* Iterative and cumulative, maximum and minimum values for all window cells at outstep iterations */ 00389 }
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.
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 802 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().
00804 { 00805 int ymin, ymax, xmin, xmax, x, y, N0, N1; 00806 char* namePtr; 00807 00808 if (!on_this_proc(xc,yc)) return; 00809 x = xc - lcl_start[0] + 1; 00810 y = yc - lcl_start[1] + 1; 00811 xmin = x - range; 00812 xmax = x + range + 1; 00813 ymin = y - range; 00814 ymax = y + range + 1; 00815 xmax = iclip( xmax, 0, s0+2); 00816 xmin = iclip( xmin, 0, s0+2); 00817 ymax = iclip( ymax, 0, s1+2); 00818 ymin = iclip( ymin, 0, s1+2); 00819 N0 = xmax-xmin; 00820 N1 = ymax-ymin; 00821 namePtr = name_from_path(name); 00822 if (debug >3) { 00823 sprintf(msgStr,"Window to Map %s, s=%d, proc0 = %d, proc1 = %d; Corners(gbl): (%d,%d) (%d,%d)\n", 00824 namePtr,range,recpnum[0],recpnum[1],xc-range,yc-range,xc+range+1,yc+range+1); 00825 writeWindow(Map,namePtr,msgStr,xmin,ymin,N0,N1,istep,Mtype,format); 00826 } 00827 00828 }
int iclip | ( | int | x0, | |
int | min, | |||
int | max | |||
) |
Constrain x0 value within a min and a max.
x0 | number to work on | |
min | the minimum | |
max | the maximum |
Definition at line 872 of file Driver_Utilities.c.
Referenced by quick_look().
00873 { 00874 int rv; 00875 rv = ( x0 > max) ? max : x0; 00876 rv = ( rv < min) ? min : rv; 00877 return rv; 00878 }
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.
vp | Pointer to struct of ViewParm | |
ptIncr | number of points to increment |
Definition at line 312 of file Driver_Utilities.c.
References debug, viewParm::fileName, viewParm::maxPoints, msgStr, viewParm::points, point3D::type, WriteMsg(), point3D::x, point3D::y, and point3D::z.
Referenced by readViewParms().
00313 { 00314 Point3D *new_pts; 00315 int i; 00316 00317 new_pts = (Point3D *) malloc( (vp->maxPoints+ptIncr) * sizeof(Point3D) ); 00318 for(i=0; i < vp->maxPoints; i++) { 00319 new_pts[i].x = vp->points[i].x; 00320 new_pts[i].y = vp->points[i].y; 00321 new_pts[i].z = vp->points[i].z; 00322 new_pts[i].type = vp->points[i].type; 00323 } 00324 if( vp->points != NULL ) { free((char*)vp->points); } 00325 vp->points = new_pts; 00326 vp->maxPoints += ptIncr; 00327 if(debug) { 00328 sprintf(msgStr,"Made %d more points for %s for %d total points",ptIncr,vp->fileName,vp->maxPoints); 00329 WriteMsg(msgStr,1); 00330 } 00331 }
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.
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 761 of file Driver_Utilities.c.
Referenced by write_map_file().
00762 { 00763 UCHAR tmp[4]; 00764 switch(bytes) { 00765 case 1: 00766 *(*sptr)++ = value; 00767 break; 00768 case 2: 00769 *(*sptr)++ = (value >> 8); 00770 *(*sptr)++ = value; 00771 break; 00772 case 3: 00773 tmp[0] = value; 00774 tmp[1] = (value >>= 8); 00775 tmp[2] = (value >> 8); 00776 *(*sptr)++ = tmp[2]; 00777 *(*sptr)++ = tmp[1]; 00778 *(*sptr)++ = tmp[0]; 00779 break; 00780 case 4: 00781 tmp[0] = value; 00782 tmp[1] = (value >>= 8); 00783 tmp[2] = (value >>= 8); 00784 tmp[3] = (value >> 8); 00785 *(*sptr)++ = tmp[3]; 00786 *(*sptr)++ = tmp[2]; 00787 *(*sptr)++ = tmp[1]; 00788 *(*sptr)++ = tmp[0]; 00789 break; 00790 } 00791 }
Point Time Series interpolation (unused):.
Definition at line 1329 of file Driver_Utilities.c.
References RP_CopyFields().
Referenced by RPL_Sort().
01330 { 01331 RPoint temp; 01332 RP_CopyFields (&temp, thisStruct); 01333 RP_CopyFields (thisStruct, that); 01334 RP_CopyFields (that, &temp); 01335 }
Point Time Series interpolation (unused):.
Definition at line 1320 of file Driver_Utilities.c.
References rPoint::fr, rPoint::fValue, rPoint::fX, and rPoint::fY.
Referenced by RP_SwapFields(), and RPL_AddrPoint().
01321 { 01322 thisStruct->fX = that->fX; 01323 thisStruct->fY = that->fY; 01324 thisStruct->fr = that->fr; 01325 thisStruct->fValue = that->fValue; 01326 }
void RP_SetFields | ( | RPoint * | thisStruct, | |
int | ix, | |||
int | iy, | |||
float | r, | |||
float | value | |||
) |
Point Time Series interpolation (unused):.
Definition at line 1311 of file Driver_Utilities.c.
References rPoint::fr, rPoint::fValue, rPoint::fX, and rPoint::fY.
Referenced by RPL_AddrPoint().
01312 { 01313 thisStruct->fX = ix; 01314 thisStruct->fY = iy; 01315 thisStruct->fr = r; 01316 thisStruct->fValue = value; 01317 }
void RPL_AddrPoint | ( | RPointList * | thisStruct, | |
int | x, | |||
int | y, | |||
float | r, | |||
float | value | |||
) |
Point Time Series interpolation (unused):.
Definition at line 1349 of file Driver_Utilities.c.
References rPointList::fList, rPointList::fNPt, rPointList::fNPtUsed, RP_CopyFields(), and RP_SetFields().
Referenced by PTSL_GetInterpolatedValue1().
01350 { 01351 RPoint* pointListtemp; 01352 int i, newPoints; 01353 01354 if( thisStruct->fNPtUsed >= thisStruct->fNPt ) { 01355 newPoints = 20; 01356 thisStruct->fNPt += newPoints; 01357 pointListtemp = (RPoint*) malloc(sizeof(RPoint)*(thisStruct->fNPt)); 01358 for(i=0; i<thisStruct->fNPtUsed; i++) { 01359 RP_CopyFields(pointListtemp+i,thisStruct->fList+i); 01360 } 01361 if( thisStruct->fList != NULL ) free((char*)thisStruct->fList); 01362 thisStruct->fList = pointListtemp; 01363 } 01364 01365 RP_SetFields( thisStruct->fList + thisStruct->fNPtUsed, x, y, r, value); 01366 thisStruct->fNPtUsed++; 01367 }
void RPL_Sort | ( | RPointList * | thisStruct | ) |
Point Time Series interpolation (unused):.
Definition at line 1370 of file Driver_Utilities.c.
References rPointList::fList, rPointList::fNPtUsed, rPoint::fr, and RP_SwapFields().
Referenced by PTSL_GetInterpolatedValue1().
01371 { 01372 int i, go=1; 01373 01374 while(go) { 01375 go = 0; 01376 for(i=1; i<thisStruct->fNPtUsed; i++) if(thisStruct->fList[i-1].fr > thisStruct->fList[i].fr) { 01377 RP_SwapFields (thisStruct->fList+i-1, thisStruct->fList+i); 01378 go = 1; 01379 } 01380 } 01381 }
void RPL_Free | ( | RPointList * | thisStruct | ) |
Point Time Series interpolation (unused):.
Definition at line 1385 of file Driver_Utilities.c.
References rPointList::fList.
Referenced by PTSL_GetInterpolatedValue1().
01386 { 01387 if(thisStruct == NULL) return; 01388 if( thisStruct->fList != NULL ) free((char*)thisStruct->fList); 01389 free((char*)thisStruct); 01390 thisStruct = NULL; 01391 }
RPointList* RPL_Init | ( | int | nPoints | ) |
Point Time Series interpolation (unused):.
Definition at line 1338 of file Driver_Utilities.c.
References rPointList::fList, rPointList::fNPt, and rPointList::fNPtUsed.
Referenced by PTSL_GetInterpolatedValue1().
01339 { 01340 RPointList *thisStruct; 01341 thisStruct = (RPointList*) malloc(sizeof(RPointList)); 01342 thisStruct->fList = (RPoint*) malloc(sizeof(RPoint)*nPoints); 01343 thisStruct->fNPt = nPoints; 01344 thisStruct->fNPtUsed = 0; 01345 return thisStruct; 01346 }
Point Time Series interpolation (unused): copy fields.
Definition at line 1131 of file Driver_Utilities.c.
References pTSeries::fValue, pTSeries::fX, and pTSeries::fY.
Referenced by PTSL_AddpTSeries().
01132 { 01133 thisStruct->fX = pV.fX; 01134 thisStruct->fY = pV.fY; 01135 thisStruct->fValue = pV.fValue; 01136 }
void PTS_Free | ( | PTSeries * | thisStruct | ) |
Point Time Series interpolation (unused): free up memory.
Definition at line 1124 of file Driver_Utilities.c.
References pTSeries::fValue.
Referenced by PTSL_Free().
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 1105 of file Driver_Utilities.c.
References debug, pTSeries::fNpt, pTSeries::fTS, pTSeries::fValue, pTSeries::fX, pTSeries::fY, gNPtTs, gTS, modelFileName, msgStr, readSeriesCol(), and WriteMsg().
Referenced by PTSL_AddpTSeries().
01107 { 01108 float ptstep = 1.0, *value; 01109 int n0; 01110 01111 thisStruct->fX = ix; 01112 thisStruct->fY = iy; 01113 if(thisStruct->fValue) free((char*)thisStruct->fValue); 01114 01115 thisStruct->fValue = readSeriesCol(modelFileName,format,index,&n0,&ptstep,col); 01116 01117 gNPtTs = thisStruct->fNpt = n0; 01118 gTS = thisStruct->fTS = ptstep; 01119 value = thisStruct->fValue; 01120 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); } 01121 }
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 1154 of file Driver_Utilities.c.
References pTSeriesList::fFormat, pTSeriesList::fList, pTSeries::fNpt, pTSeriesList::fNptTS, pTSeriesList::fNSlots, pTSeriesList::fNSlotsUsed, pTSeries::fValue, Max, PTS_CopyFields(), and PTS_SetFields().
Referenced by PTSL_ReadLists().
01155 { 01156 PTSeries* valListtemp; 01157 int i, newSlots; 01158 01159 if( seriesNum >= thisStruct->fNSlots ) { 01160 newSlots = Max(20,(int)(thisStruct->fNSlots * 0.2)); 01161 thisStruct->fNSlots += newSlots; 01162 valListtemp = (PTSeries*) malloc(sizeof(PTSeries)*(thisStruct->fNSlots)); 01163 for(i=0; i<thisStruct->fNSlotsUsed; i++) { 01164 valListtemp[i].fNpt = thisStruct->fNptTS; 01165 PTS_CopyFields(valListtemp+i,thisStruct->fList[i]); 01166 } 01167 for(i=thisStruct->fNSlotsUsed; i<thisStruct->fNSlots; i++) valListtemp[i].fValue = NULL; 01168 if( thisStruct->fList != NULL ) free((char*)thisStruct->fList); 01169 thisStruct->fList = valListtemp; 01170 } 01171 01172 PTS_SetFields( thisStruct->fList + seriesNum, x, y, index, thisStruct->fFormat, col ); 01173 thisStruct->fNSlotsUsed = seriesNum; 01174 }
void PTSL_Free | ( | PTSeriesList * | thisStruct | ) |
Point Time Series interpolation (unused): free up memory.
Definition at line 1177 of file Driver_Utilities.c.
References pTSeriesList::fList, pTSeriesList::fNSlotsUsed, and PTS_Free().
01178 { 01179 int i; 01180 if(thisStruct == NULL) return; 01181 for(i=0; i<thisStruct->fNSlotsUsed; i++) PTS_Free( thisStruct->fList +i ); 01182 if( thisStruct->fList != NULL ) free((char*)thisStruct->fList); 01183 free((char*)thisStruct); 01184 thisStruct = NULL; 01185 }
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 1218 of file Driver_Utilities.c.
Referenced by PtInterp_read().
01220 { 01221 char pathname[150], infilename[60], ss[201], ret = '\n'; 01222 FILE* cfile; 01223 int ix, iy, tst, sCnt=0; 01224 if( Lprocnum == 1 ) { 01225 if(H_OPSYS==UNIX) sprintf(modelFileName,"%s/%s/Data/%s.pts",ModelPath,ProjName,ptsFileName); 01226 else sprintf(modelFileName,"%s%s:Data:%s.pts",ModelPath,ProjName,ptsFileName); 01227 cfile = fopen(modelFileName,"r"); 01228 if(cfile==NULL) {fprintf(stdout,"\nERROR: Unable to open timeseries file %s\n",modelFileName); Exit(1); } 01229 else { sprintf(msgStr,"\nReading file %s\n",modelFileName); WriteMsg(msgStr,1); } 01230 if (debug > 2) {sprintf(msgStr,"Reading %s timeseries, column %d",modelFileName, col); usrErr(msgStr);} 01231 01232 01233 01234 fgets(ss,200,cfile); /* skip header line */ 01235 } 01236 while(1) { 01237 if( Lprocnum == 1 ) { 01238 tst = fscanf(cfile,"%d",&ix); 01239 if( tst > 0 ) { 01240 fscanf(cfile,"%d",&iy); 01241 tst = fscanf(cfile,"%s",infilename); 01242 sprintf(modelFileName,"%s/%s/Data/%s",ModelPath,ProjName,infilename); 01243 } 01244 } 01245 broadcastInt(&tst); 01246 if(tst<1) break; 01247 broadcastInt(&ix); 01248 broadcastInt(&iy); 01249 PTSL_AddpTSeries(thisStruct, ix, iy, index, sCnt, col); 01250 sCnt++; 01251 } 01252 if( Lprocnum == 1 ) fclose(cfile); 01253 *nPtTS = gNPtTs; 01254 *timeStep = gTS; 01255 }
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 1258 of file Driver_Utilities.c.
Referenced by cell_dyn1().
01260 { 01261 int i0, i1; 01262 01263 switch(Mtype) { 01264 case 'f' : 01265 for(i0=0; i0<=s0+1; i0++) 01266 for(i1=0; i1<=s1+1; i1++) 01267 ((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 */; 01268 break; 01269 case 'i' : case 'd' : 01270 for(i0=0; i0<=s0+1; i0++) 01271 for(i1=0; i1<=s1+1; i1++) 01272 ((int*)Map)[T(i0,i1)] = (int) ( (ON_MAP[T(i0,i1)]) ? PTSL_GetInterpolatedValue0(pList,i0,i1,step)*scale : 0 ); 01273 break; 01274 case 'c' : 01275 for(i0=0; i0<=s0+1; i0++) 01276 for(i1=0; i1<=s1+1; i1++) 01277 ((unsigned char*)Map)[T(i0,i1)] = (unsigned char) '\0' + (int) ( (ON_MAP[T(i0,i1)]) ? PTSL_GetInterpolatedValue0(pList,i0,i1,step)*scale : 0 ); 01278 break; 01279 } 01280 }
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 1283 of file Driver_Utilities.c.
References pTSeriesList::fList, pTSeriesList::fNSlotsUsed, pTSeries::fValue, pTSeries::fX, pTSeries::fY, GP_IDW_pow, RPL_AddrPoint(), RPL_Free(), RPL_Init(), and RPL_Sort().
01284 { 01285 int i, dx, dy; 01286 PTSeries pV; 01287 RPointList *pList; 01288 float wpow; 01289 double weight, InterpValue=0.0, distance=0.0; 01290 long r; 01291 01292 pList = RPL_Init( 20 ); 01293 wpow = GP_IDW_pow; /* GP_IDW_pow is "adjustable" parameter in global parm input file */ 01294 for(i=0; i<thisStruct->fNSlotsUsed; i++) { 01295 pV = thisStruct->fList[i]; 01296 dx = (pV.fX-x); 01297 dy = (pV.fY-y); 01298 r = dx*dx + dy*dy; 01299 if( r == 0 ) return pV.fValue[step]; 01300 RPL_AddrPoint(pList, dx, dy, r, pV.fValue[step]); 01301 weight = (wpow == 1.0) ? ((double)1.0)/r : pow(r,-wpow); 01302 InterpValue += pV.fValue[step]*weight; 01303 distance += weight; 01304 } 01305 RPL_Sort(pList); 01306 RPL_Free(pList); 01307 return (float) InterpValue; 01308 }
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 1188 of file Driver_Utilities.c.
References pTSeriesList::fList, pTSeriesList::fNSlotsUsed, pTSeries::fValue, pTSeries::fX, pTSeries::fY, GP_IDW_pow, and lcl_start.
Referenced by PTSL_CreatePointMap().
01189 { 01190 int i, dx, dy, my_debug; 01191 PTSeries pV; 01192 float wpow; 01193 float weight, InterpValue=0.0, distance=0.0; /* was double in v1.0 */ 01194 int r; 01195 01196 wpow = GP_IDW_pow; /* GP_IDW_pow is "adjustable" parameter in global parm input file */ 01197 01198 01199 for(i=0; i<thisStruct->fNSlotsUsed; i++) { 01200 pV = thisStruct->fList[i]; 01201 dx = (pV.fX-(x+lcl_start[0])); 01202 dy = (pV.fY-(y+lcl_start[1])); 01203 r = (dx*dx + dy*dy); 01204 if( r == 0 ) return pV.fValue[step]; 01205 weight = (wpow == 1.0) ? (1.0)/r : 1.0/(r*r); 01206 /* the pow() and double was incredibly slow (signif slowed simualtion), so removed it 01207 and gave the choice of only inverse distance or inverse distance**2 weighting */ 01208 /* weight = (wpow == 1.0) ? ( (double)1.0)/r : pow(r,-wpow) ; */ 01209 InterpValue += pV.fValue[step]*weight; 01210 distance += weight; 01211 } 01212 if (distance > 0) InterpValue /= distance; 01213 else InterpValue = (thisStruct->fList[0]).fValue[step]; 01214 return (float) InterpValue; 01215 }
PTSeriesList* PTSL_Init | ( | int | nSlots, | |
int | format | |||
) |
Point Time Series interpolation (unused): initialize structure.
Definition at line 1139 of file Driver_Utilities.c.
References pTSeriesList::fFormat, pTSeriesList::fList, pTSeriesList::fNptTS, pTSeriesList::fNSlots, pTSeriesList::fNSlotsUsed, and pTSeries::fValue.
Referenced by PtInterp_read().
01140 { 01141 int i; 01142 PTSeriesList* thisStruct; 01143 thisStruct = (PTSeriesList*) malloc(sizeof(PTSeriesList)); 01144 thisStruct->fList = (PTSeries*) malloc(sizeof(PTSeries)*nSlots); 01145 for(i=0; i<nSlots; i++) thisStruct->fList[i].fValue = NULL; 01146 thisStruct->fNSlots = nSlots; 01147 thisStruct->fNSlotsUsed = 0; 01148 thisStruct->fNptTS = 0; 01149 thisStruct->fFormat = format; 01150 return(thisStruct); 01151 }
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.
jd | Julian day | |
m | Month | |
d | Day | |
y | Year | |
h | Hour | |
mi | Minute | |
sec | Second |
Definition at line 1630 of file Driver_Utilities.c.
01631 { 01632 static int ret[4]; 01633 01634 long j = (long)jd; 01635 double tmp, frac = jd - j; 01636 01637 if (frac >= 0.5) { 01638 frac = frac - 0.5; 01639 j++; 01640 } 01641 else { 01642 frac = frac + 0.5; 01643 } 01644 01645 ret[3] = (j + 1L) % 7L; 01646 j -= 1721119L; 01647 *y = (4L * j - 1L) / 146097L; 01648 j = 4L * j - 1L - 146097L * *y; 01649 *d = j / 4L; 01650 j = (4L * *d + 3L) / 1461L; 01651 *d = 4L * *d + 3L - 1461L * j; 01652 *d = (*d + 4L) / 4L; 01653 *m = (5L * *d - 3L) / 153L; 01654 *d = 5L * *d - 3 - 153L * *m; 01655 *d = (*d + 5L) / 5L; 01656 *y = 100L * *y + j; 01657 if (*m < 10) 01658 *m += 3; 01659 else { 01660 *m -= 9; 01661 *y += 1; 01662 } 01663 tmp = 3600.0 * (frac * 24.0); 01664 *h = (int) (tmp / 3600.0); 01665 tmp = tmp - *h * 3600.0; 01666 01667 *mi = (int) (tmp / 60.0); 01668 *sec = tmp - *mi * 60.0; 01669 }
double julday | ( | int | mon, | |
int | day, | |||
int | year, | |||
int | h, | |||
int | mi, | |||
double | se | |||
) |
Determine the Julian calendar day from a Gregorian date.
mon | Month | |
day | Day | |
year | Year | |
h | Hour | |
mi | Minute | |
se | Second |
Definition at line 1583 of file Driver_Utilities.c.
01584 { 01585 long m = mon, d = day, y = year; 01586 long c, ya, j; 01587 double seconds = h * 3600.0 + mi * 60 + se; 01588 01589 if (m > 2) 01590 m -= 3; 01591 else { 01592 m += 9; 01593 --y; 01594 } 01595 c = y / 100L; 01596 ya = y - (100L * c); 01597 j = (146097L * c) / 4L + (1461L * ya) / 4L + (153L * m + 2L) / 5L + d + 1721119L; 01598 if (seconds < 12 * 3600.0) { 01599 j--; 01600 seconds += 12.0 * 3600.0; 01601 } 01602 else { 01603 seconds = seconds - 12.0 * 3600.0; 01604 } 01605 return (j + (seconds / 3600.0) / 24.0); 01606 }
float FMOD | ( | float | x, | |
float | y | |||
) |
Modulus of a pair of (double) arguments.
x | Numerator | |
y | Denominator |
Definition at line 1675 of file Driver_Utilities.c.
void setup_grid | ( | ) |
Provide the 2D array size for the model domain.
Definition at line 392 of file Driver_Utilities.c.
References exgridsize(), floatOut, gbl_size, gridSize, gTemp, gTempSize, init_pvar(), lcl_size, lcl_start, msgStr, nalloc(), nc_dataRowRev, procnum, s0, s1, and WriteMsg().
00392 { 00393 00394 exgridsize(procnum,gbl_size,lcl_size,lcl_start); /* effectively unused in serial (non-parallel) implementation */ 00395 00396 /* s0 and s1 remain unchanged in serial (non-parallel) implementation */ 00397 s0 = lcl_size[0]; 00398 s1 = lcl_size[1]; 00399 00400 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) */ 00401 00402 sprintf(msgStr,"\nGRID DATA::[ gsize: (%d, %d), lstart: (%d, %d), lend: (%d, %d), lsize: (%d, %d) ]\n", 00403 gbl_size[0], gbl_size[1], lcl_start[0], 00404 lcl_start[1], lcl_start[0]+lcl_size[0]-1, 00405 lcl_start[1]+lcl_size[1]-1, lcl_size[0], lcl_size[1] ); 00406 WriteMsg(msgStr,1); 00407 sprintf(msgStr,"\nVP DATA:: size: (%d), Variable sizes: float: %d, int: %d, long: %d, double: %d\n", 00408 sizeof(ViewParm), sizeof(float),sizeof(int) ,sizeof(long) ,sizeof(double) ); 00409 WriteMsg(msgStr,1); 00410 00411 gTempSize = gridSize*8; 00412 gTemp = (UCHAR*) nalloc(gTempSize,"gTemp"); 00413 00414 /* v2.8.2 new temp array for output - all variables' arrays are 2 rows and 2 cols larger than the actual data 00415 this is used to hold only the size of s0, s1 */ 00416 floatOut = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"floatOut"); 00417 // init_pvar(floatOut,NULL,'f',0.0); 00418 00419 /* v2.8.2 new temp array for output - netCDF output files now have origin at lower (not upper) left */ 00420 nc_dataRowRev = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"nc_dataRowRev"); 00421 init_pvar(nc_dataRowRev,NULL,'f',0.0); 00422 00423 00424 }
void set_env_vars | ( | void | ) |
Acquire necessary environment variables.
Definition at line 900 of file Driver_Utilities.c.
References DriverPath, ModelPath, msgStr, OS_TYPE, ProjName, and usrErr().
00900 { 00901 00902 FILE *infile; 00903 char filename[100], ch; 00904 static long start; 00905 int i, maxLen =200; 00906 00907 ModelPath = getenv("ModelPath"); 00908 ProjName = getenv("ProjName"); 00909 DriverPath = getenv("DriverPath"); 00910 OS_TYPE = getenv("OSTYPE"); /* OSTYPE not used in code, only here for informational output */ 00911 00912 sprintf(msgStr,"OS type = %s ",OS_TYPE); 00913 usrErr(msgStr); 00914 00915 sprintf(msgStr,"Project Name = %s ",ProjName); 00916 usrErr(msgStr); 00917 00918 }
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 1551 of file Driver_Utilities.c.
Referenced by goto_index(), and print_point().
01552 { 01553 printf("%s",msg); 01554 fflush(stdout); 01555 Exit(9); 01556 }
void Exit | ( | int | code | ) |
Standard exit from program.
Definition at line 1548 of file Driver_Utilities.c.
Referenced by fatal(), get_global_parm(), get_modexperim_parm(), getCanalElev(), nalloc(), PTSL_ReadLists(), and read_map_dims().
void Copy | ( | void * | src, | |
void * | dst, | |||
int | w, | |||
int | n, | |||
int | sw, | |||
int | dw | |||
) |
Memory-copy data from large (global) domain to local domain.
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 |
Definition at line 889 of file Driver_Utilities.c.
Referenced by writeWindow().
00890 { 00891 int i; 00892 for(i=0; i<n; i++) 00893 memcpy( ((UCHAR*)dst)+i*dw, ((UCHAR*)src)+i*sw, w ); /* copy w chars from source to dest, return destination */ 00894 }
void getInt | ( | FILE * | inFile, | |
const char * | lString, | |||
int * | iValPtr | |||
) |
Get an integer following a specific string.
inFile | File that is open | |
lString | The string being read | |
iValPtr | The char value found |
Definition at line 1740 of file Driver_Utilities.c.
01741 { 01742 int test; 01743 UCHAR iEx=0; 01744 if(lString) 01745 scan_forward(inFile,lString); 01746 test = fscanf(inFile,"%d",iValPtr); 01747 if(test != 1) { 01748 fprintf(stderr,"Read Error (%d):",test); 01749 if(lString) fprintf(stderr,"%s\n",lString); 01750 *iValPtr = 0; 01751 iEx = 1; 01752 } 01753 if (iEx) exit(0); 01754 }
void getChar | ( | FILE * | inFile, | |
const char * | lString, | |||
char * | cValPtr | |||
) |
Get a character following a specific string.
inFile | File that is open | |
lString | The string being read | |
cValPtr | The char value found |
Definition at line 1702 of file Driver_Utilities.c.
01703 { 01704 int test; 01705 UCHAR iEx=0; 01706 if(lString) scan_forward(inFile,lString); 01707 test = fscanf(inFile,"%c",cValPtr); 01708 if(test != 1) { 01709 fprintf(stderr,"Read Error (%d):",test); 01710 if(lString) fprintf(stderr,"%s\n",lString); 01711 iEx = 1; 01712 *cValPtr = '\0'; 01713 } 01714 if (iEx) exit(0); 01715 }
void getString | ( | FILE * | inFile, | |
const char * | lString, | |||
char * | inString | |||
) |
Get a string following a specific string.
inFile | File that is open | |
lString | The string being read | |
inString | The string found |
Definition at line 1722 of file Driver_Utilities.c.
References scan_forward().
01723 { 01724 int test; 01725 UCHAR iEx=0; 01726 if(lString) scan_forward(inFile,lString); 01727 test = fscanf(inFile,"%s",inString); 01728 if(test != 1) { 01729 fprintf(stderr,"Read Error (%d):",test); 01730 if(lString) fprintf(stderr,"%s\n",lString); 01731 iEx = 1; 01732 } 01733 if (iEx) exit(0); 01734 }
void getFloat | ( | FILE * | inFile, | |
const char * | lString, | |||
float * | fValPtr | |||
) |
Get a float value following a specific string.
inFile | File that is open | |
lString | The string being read | |
fValPtr | The float number found |
Definition at line 1683 of file Driver_Utilities.c.
References scan_forward().
01684 { 01685 int test, fSize; 01686 UCHAR iEx=0; 01687 if(lString) scan_forward(inFile,lString); 01688 test = fscanf(inFile,"%f",fValPtr); 01689 if(test != 1) { 01690 fprintf(stderr,"Read Error (%d):",test); 01691 if(lString) fprintf(stderr,"%s\n",lString); 01692 *fValPtr = 0.0; 01693 iEx = 1; 01694 } 01695 if (iEx) exit(0); 01696 }
(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.
vp | struct of ViewParm w/ output configuration | |
mask | array mask | |
value | is always = 1 (is an array) |
Definition at line 1405 of file Driver_Utilities.c.
References viewParm::flags.
Referenced by readViewParms().
Unused (never called) function.
Definition at line 1411 of file Driver_Utilities.c.
References viewParm::flags.
01412 { 01413 if( vp->flags & mask ) return 1; else return 0; 01414 }
int getPrecision | ( | ViewParm * | vp | ) |
(Effectively unused).
Definition at line 1424 of file Driver_Utilities.c.
References viewParm::flags, PMASK1, and PMASK2.
Referenced by write_output().
01425 { 01426 int rv = 1; 01427 if(vp->flags & PMASK2) rv +=2; 01428 if(vp->flags & PMASK1) rv +=1; 01429 return rv; 01430 }
int isInteger | ( | char * | target_str | ) |
Determine if an integer is present in string.
target_str | Target string |
Definition at line 1475 of file Driver_Utilities.c.
Referenced by ReadStructures(), and readViewParms().
01475 { 01476 01477 int i=-1,first_num=0; 01478 char ch; 01479 01480 while( (ch=target_str[++i]) != '\0' ) { 01481 if( isdigit(ch) ) first_num=1; 01482 if( (ch=='-' || ch=='+') && first_num ) return(0); 01483 if( !( isspace(ch) || isdigit(ch) || ch=='-' || ch=='+') ) return(0); 01484 } 01485 return(1); 01486 }
int isFloat | ( | char * | target_str | ) |
Determine if a float is present in string.
target_str | Target string |
Definition at line 1493 of file Driver_Utilities.c.
Referenced by ReadStructures(), and readViewParms().
01493 { 01494 01495 int i=-1,first_num=0; 01496 char ch; 01497 01498 while( (ch=target_str[++i]) != '\0' ) { 01499 if( isdigit(ch) ) first_num=1; 01500 if( (ch=='-' || ch=='+') && first_num ) return(0); 01501 if( !( isspace(ch) || isdigit(ch) || ch=='-' || ch=='+' || ch=='.' || toupper(ch) == 'E') ) return(0); 01502 } 01503 return(1); 01504 }
int skip_white | ( | FILE * | infile | ) |
Skip white space(s) in a file.
infile |
Definition at line 1800 of file Driver_Utilities.c.
01801 { 01802 int ch; 01803 01804 while( isspace(ch=fgetc(infile)) ) {;} 01805 if(ch==EOF) return 0; 01806 ungetc(ch,infile); 01807 return 1; 01808 }
int scan_forward | ( | FILE * | infile, | |
const char * | tstring | |||
) |
Scan forward until a particular string is found.
infile | The file being read | |
tstring | The sought-after string |
Definition at line 1814 of file Driver_Utilities.c.
01815 { 01816 int sLen, i, cnt=0; 01817 char Input_string[100], test; 01818 01819 sLen = strlen(tstring); 01820 while( ( test = fgetc(infile) ) != EOF ) { 01821 for(i=0; i<(sLen-1); i++) 01822 Input_string[i] = Input_string[i+1]; 01823 Input_string[sLen-1] = test; 01824 Input_string[sLen] = '\0'; 01825 if(++cnt >= sLen) { 01826 test = strcmp(Input_string,tstring); 01827 if( test == 0 ) return 1; 01828 } 01829 } 01830 return(-1); 01831 }
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.
s0 | String array | |
s1 | String array | |
start | Starting position | |
cs | Case sensitivity | |
rp | Return pointer to beginning or not |
Definition at line 1443 of file Driver_Utilities.c.
Referenced by write_map_file().
01444 { 01445 /* Check for occurrences of string s1 in string s0 */ 01446 /* after position start. Return -1 if not found. */ 01447 /* if cs = CASE -> case sensitive, cs = NOCASE, not case sens. */ 01448 /* if rp = BEG -> return position of beginning of s1, */ 01449 /* otherwise return position of (next char following the) end of s1 */ 01450 int i, j=0, k=-1, Len1 = strlen(s1), Len0 = strlen(s0); 01451 char t1, t2; 01452 01453 while(k<0) { 01454 k=0; 01455 for(i=start; i< Len0; ++i) { 01456 t1 = s0[i]; 01457 t2 = s1[j]; 01458 if(cs==NOCASE) { t1 = tolower(t1); t2 = tolower(t2); } 01459 if (t1 == t2) j++; 01460 else {j=0; k=0;} 01461 if(j==Len1) { k=1; break; } 01462 } 01463 } 01464 if(k<=0) return(-1); 01465 else if(rp==BEG) return(i-Len1+1); 01466 else return(i+1); 01467 }
int find_char | ( | FILE * | infile, | |
char | tchar | |||
) |
Find a character.
infile | The file that is open | |
tchar | The character being sought |
Definition at line 1760 of file Driver_Utilities.c.
Referenced by get_Nth_parm(), and goto_index().
01761 { 01762 char test = '1', cchar = '#'; 01763 int in_c=0; 01764 01765 while( test != EOF ) { 01766 test = fgetc(infile); 01767 if(test == tchar && in_c==0 ) { return 1; } 01768 if(test == cchar ) in_c=1; 01769 if(test == '\n' ) in_c=0; 01770 } 01771 return(0); 01772 }
int Round | ( | float | x | ) |
truncate (not rounding) to an integer
x | the value being operated on |
Definition at line 1777 of file Driver_Utilities.c.
Referenced by Channel_configure().
char* name_from_path | ( | char * | name | ) |
Get the var name from a longer path/filename.
name | The var name & path |
Definition at line 1837 of file Driver_Utilities.c.
Referenced by quick_look().
01838 { 01839 char* namePtr; int i, slen; 01840 char dirCh; 01841 01842 namePtr = name; 01843 dirCh = '/'; 01844 slen = strlen(name); 01845 01846 for(i=0; i<slen; i++) { 01847 if( name[slen-i-1] == dirCh ) { namePtr = name+slen-i; break; } 01848 } 01849 return namePtr; 01850 }
char* Scip | ( | char * | s, | |
char | SYM | |||
) |
Skip ahead in a string until next field.
s | A character array | |
SYM | The specific symbol being used to skip over |
Definition at line 1788 of file Driver_Utilities.c.
Referenced by BIRinit(), get_hab_parm(), Read_schedule(), ReadStructFlow_PtSer(), ReadStructTP_PtSer(), ReadStructTS_PtSer(), and ReadStructures().
01789 { 01790 if(*s == SYM ) return ++s; 01791 while(*s != SYM && *s != EOS ) s++; 01792 if(*s != EOS) return ++s; 01793 else return s; 01794 }
void setup_platform | ( | ) |
Effectively unused in serial (non-parallel) implementation.
Definition at line 1937 of file Driver_Utilities.c.
References env, exgridcoord(), exgridinit(), exgridsplit(), exparam(), nprocs, nodenv::nprocs, nodenv::procnum, procnum, recpnum, and usrErr().
01937 { 01938 01939 exparam(&env); 01940 procnum = env.procnum; 01941 exgridsplit(env.nprocs, 2, nprocs); 01942 if( exgridinit(2, nprocs) < 0) { usrErr("Failed to Setup Grid"); exit(0); } 01943 exgridcoord(procnum, recpnum); 01944 }
void link_edges | ( | VOIDP | Map, | |
unsigned char | Mtype | |||
) |
Effectively unused in serial (non-parallel) implementation.
Definition at line 1924 of file Driver_Utilities.c.
References exchange_borders().
Referenced by read_map_file().
01925 { 01926 switch(Mtype) { 01927 case 'f' : 01928 exchange_borders((byte*)Map,sizeof(float)); break; 01929 case 'd' : case 'i' : 01930 exchange_borders((byte*)Map,sizeof(int)); break; 01931 case 'c' : 01932 exchange_borders((byte*)Map,sizeof(UCHAR)); break; 01933 } 01934 }
float Normal | ( | float | mean, | |
float | sd | |||
) |
Unused, never called. Normal distribution.
Definition at line 1875 of file Driver_Utilities.c.
References gRTable, and SMDRAND().
01876 { 01877 int table_loc ; 01878 double rand_num ; 01879 float sign ; 01880 float interval = .1 ; 01881 int n_interval = 40 ; 01882 float high, low ; 01883 float return_val = 0.0; 01884 01885 sign = SMDRAND(0.0, 1.0) ; 01886 sign = (sign < .5 ? -1 : 1) ; 01887 rand_num = SMDRAND(.5, 1.0); 01888 low = gRTable[0] ; 01889 for (table_loc=1; table_loc<n_interval; table_loc++) 01890 { 01891 high = gRTable[table_loc] ; 01892 if (high > rand_num + .5) 01893 { 01894 return_val = mean + sd * (sign * interval * (table_loc - 1 + 01895 (rand_num+.5-low)/(high-low))) ; 01896 return(return_val) ; 01897 } 01898 low = high ; 01899 } 01900 return(return_val) ; 01901 }
int Poisson | ( | float | mu | ) |
Unused, never called. Poisson distribution.
Definition at line 1904 of file Driver_Utilities.c.
References Exp, and SMDRAND().
01905 { 01906 int ix; 01907 float f0, r, Lp = 1, xf = 1, p=0; 01908 01909 p = f0 = Exp(-mu); 01910 r = SMDRAND(0.0,1.0); 01911 01912 for( ix=0; ix<500; ix++) { 01913 if( r < p ) return ix; 01914 Lp *= mu; 01915 if(ix>0) xf *= ix; 01916 p += (Lp*f0)/xf; 01917 } 01918 return ix; 01919 }
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.)
vpFile | Pointer to the (model outlist) configuration file | |
term1 | The character "#" | |
term2 | The character "*" | |
term3 | The character "@" | |
term4 | The character "~" |
Definition at line 1199 of file Serial.c.
Referenced by readViewParms().
01200 { 01201 char test; 01202 int format,size=-1; 01203 01204 gTerm[0] = term1; 01205 gTerm[1] = term2; 01206 gTerm[2] = term3; 01207 gTerm[3] = term4; 01208 skip_white(vpFile); 01209 test = fgetc(vpFile); 01210 if(test == gTerm[0]) 01211 fscanf(vpFile,"%d",&format); 01212 else 01213 format = -1; 01214 return format; 01215 }
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).
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="*") |
Definition at line 1248 of file Serial.c.
Referenced by readViewParms().
01249 { 01250 static int gVPindex = -1; 01251 static char gCnfg; 01252 01253 char ch = ' ', eChar = ' '; 01254 int btype=0, argc=2, go=1, i=0, j=0, new_name = 0; 01255 01256 if(vpFile == NULL) return -3; 01257 while (1) { 01258 if ( skip_cnfg_space(vpFile, &ch) < 0) return -3; j=0; 01259 if( ch == gTerm[1] || ch == gTerm[2] ) { 01260 gCnfg = ch; ch = ' '; 01261 if ( skip_cnfg_space(vpFile, &ch) < 0 ) return -3; 01262 while ( !isspace(ch) ) { cTemp[j++] = ch; ch=fgetc(vpFile); } 01263 cTemp[j++] = '\0'; new_name = 1; 01264 gVPindex++; 01265 } 01266 else break; 01267 } 01268 strcpy(gCArg[0],cTemp); 01269 *test = gCnfg; 01270 while ( isalnum( ch ) ) { gCArg[1][i++]=ch; ch=fgetc(vpFile); } 01271 gCArg[1][i]='\0'; i=0; 01272 01273 while( 1 ) { 01274 if( ch == '(' ) { eChar = ')'; break;} 01275 else if( ch == '[' ) { eChar = ']'; break;} 01276 else if( ch == '{' ) { eChar = '}'; break;} 01277 else if( !isspace(ch) ) { return -3;} 01278 ch=fgetc(vpFile); 01279 } 01280 while (go) { 01281 while( ch=fgetc(vpFile) ) { 01282 if( ch == ',' ) { argc++; break; } 01283 if( ch == ')' || ch == '}' || ch == ']') { 01284 if( ch == eChar ) { argc++; go=0; break;} 01285 else { printf( "\nWarning: Syntax error in parse_config, var: %s\n",gCArg[0]); return -2; } 01286 } 01287 gCArg[argc][i++]=ch; 01288 if( i==(kCArgWidth-1) ) break; 01289 } 01290 if(i==0) { printf( "\nWarning: Syntax error in parse_config, var: %s\n",gCArg[0]); return -2; } 01291 else { gCArg[argc-1][i]='\0'; i=0; } 01292 if(argc == kCArgDepth) { 01293 while( ch != eChar ) ch=fgetc(vpFile); 01294 go = 0; 01295 } 01296 } 01297 *nArgs = argc; 01298 if(argc==0) { printf( "\nWarning: Syntax error in parse_config, var: %s\n",gCArg[0]); return -2; } 01299 else return gVPindex; 01300 }
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.
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 1050 of file Serial.c.
Referenced by calc_maxmin(), and print_loc_ave().
01051 { 01052 int print, cIndex, i, cum; 01053 static int type = 11; 01054 char tmpStr[50]; 01055 if( ++type > 99) type = 11; 01056 01057 cum = ((cType == kAVECUM) || (cType == kSUMCUM)) ? 1 : 0; 01058 if(cum) { cIndex = getCombineIndex(label,step,cType,&print); } 01059 01060 switch(cType) { 01061 case kMAXMIN: 01062 sprintf(msgStr,"\nMAXMIN(%d) for %s:",step,label); 01063 for(i=0; i<nComp; i++) { sprintf(tmpStr," %f",fValue[i]); strcat(msgStr,tmpStr); } 01064 WriteMsg(msgStr,1); 01065 break; 01066 case kMAX: 01067 sprintf(msgStr,"\nMAX(%d) for %s:",step,label); 01068 for(i=0; i<nComp; i++) { sprintf(tmpStr," %f",fValue[i]); strcat(msgStr,tmpStr); } 01069 WriteMsg(msgStr,1); 01070 break; 01071 case kMIN: 01072 sprintf(msgStr,"\nMIN(%d) for %s:",step,label); 01073 for(i=0; i<nComp; i++) { sprintf(tmpStr," %f",fValue[i]); strcat(msgStr,tmpStr); } 01074 WriteMsg(msgStr,1); 01075 break; 01076 case kSUM: 01077 sprintf(msgStr,"\nSUM(%d) for %s:",step,label); 01078 for(i=0; i<nComp; i++) { sprintf(tmpStr," %f",fValue[i]); strcat(msgStr,tmpStr); } 01079 WriteMsg(msgStr,1); 01080 break; 01081 case kAVE: 01082 sprintf(msgStr,"\nAVE(%d) for %s:",step,label); 01083 for(i=0; i<nComp; i+=2) { sprintf(tmpStr," %f",fValue[i]/fValue[i+1]); strcat(msgStr,tmpStr); } 01084 WriteMsg(msgStr,1); 01085 break; 01086 case kSUMCUM: 01087 if( print == -1) { 01088 for(i=0; i<nComp; i++) ctable[cIndex].fvalue[i] = fValue[i]; 01089 01090 } else { 01091 for(i=0; i<nComp; i++) ctable[cIndex].fvalue[i] += fValue[i]; 01092 } 01093 if(print==1) { 01094 sprintf(msgStr,"\nSUMCUM(%d) for %s:",step,label); 01095 for(i=0; i<nComp; i++) { sprintf(tmpStr," %f",ctable[cIndex].fvalue[i]); strcat(msgStr,tmpStr); } 01096 WriteMsg(msgStr,1); 01097 } 01098 break; 01099 case kAVECUM: 01100 if( print == -1) { 01101 for(i=0; i<nComp; i++) ctable[cIndex].fvalue[i] = fValue[i]; 01102 01103 } else { 01104 for(i=0; i<nComp; i++) ctable[cIndex].fvalue[i] += fValue[i]; 01105 } 01106 if(print==1) { 01107 sprintf(msgStr,"\nAVECUM(%d) for %s:",step,label); 01108 for(i=0; i<nComp; i+=2) { sprintf(tmpStr," %f",ctable[cIndex].fvalue[i]/ctable[cIndex].fvalue[i+1]); strcat(msgStr,tmpStr); } 01109 WriteMsg(msgStr,1); 01110 } 01111 break; 01112 } 01113 }
void writeMap | ( | char * | filename, | |
void * | data, | |||
int | bSize, | |||
unsigned char | type, | |||
int | index | |||
) |
Write data for spatial (map) output binary file.
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 |
Definition at line 151 of file Serial.c.
Referenced by write_map_file().
00152 { 00153 int gsize, istat; 00154 FILE* bFile; 00155 00156 if (index == 0 && type=='M') write_header(filename,bSize); 00157 00158 if(type == 'H') { 00159 #if HDF4 00160 if(index==0) { istat = DFR8putimage(filename,(char*)data,s1,s0,0); } 00161 else { istat = DFR8addimage(filename,(char*)data,s1,s0,0); } 00162 if(istat != 0) printf("\nerror writing HDF file: %s\n",filename); 00163 #endif 00164 } 00165 00166 else if(type == 'C') { 00167 printf("\nError in configuring netCDF output, which can only be 4-byte floating point values: %s\n",filename); 00168 exit(0); 00169 } 00170 00171 else { 00172 if((bFile = fopen(filename,"wb") ) == NULL ) { 00173 fprintf(stderr,"Can't Open Mapfile: %s",filename); 00174 exit(0); 00175 } 00176 gsize = gbl_size[0]*gbl_size[1]*bSize; 00177 fwrite((char*)data, gsize, 1, bFile ); 00178 00179 fclose(bFile); 00180 } 00181 }
void writeFloatMap | ( | char * | filename, | |
char * | VARNAME, | |||
float * | data, | |||
int | bSize, | |||
unsigned char | type, | |||
int | index, | |||
char * | thisvarUnits, | |||
int | outstep | |||
) |
Write floating point data for spatial (map) output binary file (new v2.8.2).
filename | Filename (path and variable names) of data | |
VARNAME | The variable name of data | |
data | Data array of the variable | |
bSize | Byte size of data | |
type | Type, or format, of (binary) data | |
index | Index used in output sequence | |
thisvarUnits | Units of the output variable |
Definition at line 197 of file Serial.c.
Referenced by write_map_file().
00198 { 00199 int gsize; 00200 FILE* bFile; 00201 00202 00203 if(type == 'H') { /* HDF */ 00204 printf("\nError in configuring HDF output, which can only be 1-byte values (you requested 4): %s\n",filename); 00205 exit(0); 00206 } 00207 00208 else if(type == 'C') { /* netCDF */ 00209 writeFloatNetCDF(filename,VARNAME,data,bSize,type,index,thisvarUnits, outstep); 00210 00211 } 00212 else if(type == 'M') { /* generic binary Map */ 00213 if (index == 0) write_header(filename,bSize); 00214 00215 if((bFile = fopen(filename,"wb") ) == NULL ) { 00216 fprintf(stderr,"Can't Open output Mapfile: %s",filename); 00217 exit(0); 00218 } 00219 gsize = (gbl_size[0]+2)*(gbl_size[1]+2)*bSize; /* note size is 2 rows and 2 cols larger than standard input/output arrays */ 00220 fwrite(data, gsize, 1, bFile ); 00221 00222 fclose(bFile); 00223 } 00224 00225 else { /* this error shouldn't be reached, but it is possible */ 00226 printf("\nError in configuring 4-byte output request, which can only be netCDF ('C' argument in 'G' command) or generic map binary ('M' argument in 'G' command): output variable= %s\n",filename); 00227 } 00228 00229 }
void writeFloatNetCDF | ( | char * | , | |
char * | , | |||
float * | , | |||
int | , | |||
unsigned | char, | |||
int | , | |||
char * | , | |||
int | ||||
) |
Definition at line 252 of file Serial.c.
Referenced by writeFloatMap().
00253 { 00254 int retval; 00255 int ncid, dimids[NDIMS]; 00256 size_t start[NDIMS], count[NDIMS]; 00257 int time_dimid, x_dimid, y_dimid; 00258 int x_id, y_id, time_id, varid, date_id, TM_id; 00259 char s_mo[3], s_da[3], ELMdate[11], dateUnits[100], attribute_string[1000]; 00260 float north[s0+2],east[s1+2]; 00261 float northrev[s0+2]; /* for the reversal of the row ordering in having output w/ origin at lower left */ 00262 00263 time_t begin_sim, end_sim; /* Feb 2011 - just threw in here - poor practice!! */ 00264 struct tm *local_begin_time; /* struct holding real-time calendar time from standard time.h */ 00265 /* a couple of items that use the standard time.h to clock the simulation runtime*/ 00266 begin_sim = time(NULL); 00267 local_begin_time = localtime(&begin_sim); 00268 00269 00270 int i,j, irev; 00271 00272 /* this prevents code from being compiled when netCDF is not installed 00273 (If you do not have netCDF installed on your system, you must set NCDF3 to false in globals.h) */ 00274 #if NCDF3 00275 /* append the date (yyyymmdd) to the root filename*/ 00276 if (SimTime.mo[0]<10) sprintf(s_mo,"0%d", SimTime.mo[0]); 00277 else sprintf(s_mo,"%d", SimTime.mo[0]); 00278 if (SimTime.da[0]<10) sprintf(s_da,"0%d", SimTime.da[0]); 00279 else sprintf(s_da,"%d", SimTime.da[0]); 00280 sprintf(ELMdate,"%d-%s-%s",SimTime.yr[0],s_mo,s_da); 00281 00282 /* Coordinates used for the netCDF cell attributes are the centroids: 00283 float maps are 1-cell larger on each side, so 00284 subtract 1 cell width to start at western edge, and 00285 add 1 cell width to start at northern edge 00286 (remember that origin of SME/ELM is upper left, 00287 while UTM goes in positive direction from lower left) 00288 We then use the centroid (not upper and left edge) of each cell for coords, 00289 so (- celWid + 0.5*celWid) = (-0.5*celWid) */ 00290 for (i=0; i< (s0+2); i++) { 00291 for (j=0; j< (s1+2); j++) { 00292 // east[j] = UTMwest - 0.5 * celWid + (j * celWid); 00293 // north[i]= UTMnorth + 0.5 * celWid - (i * celWid); 00294 // Note that we've switched to having output in NAD83 horizontal datum - if you change this, be sure to alter the metadata strings below 00295 east[j] = UTMwestNAD83 - 0.5 * celWid + (j * celWid); 00296 north[i]= UTMnorthNAD83 + 0.5 * celWid - (i * celWid); 00297 } 00298 } 00299 00300 /* reverse row order (ELM origin is upper left, this outputs origin at lower left) */ 00301 for (i=0; i< (s0+2); i++) { 00302 for (j=0; j< (s1+2); j++) { 00303 irev = (s0+1) - i; 00304 nc_dataRowRev[T(irev,j)] = data[T(i,j)]; 00305 northrev[irev] = north[i]; 00306 } 00307 } 00308 00309 /* Create the file. The NC_CLOBBER parameter tells netCDF to 00310 * overwrite this file, if it already exists; NC_NOCLOBBER does not overwrite. */ 00311 if (index==0) { 00312 if ( (retval = nc_create(filename, NC_CLOBBER, &ncid))) 00313 ERR(retval); 00314 00315 /* Define the dimensions: x, y, and time outstep-number (sequence). NetCDF will hand back an ID for each. */ 00316 if ((retval = nc_def_dim(ncid, "time", NC_UNLIMITED, &time_dimid))) 00317 ERR(retval); 00318 if ((retval = nc_def_dim(ncid, "y", (s0+2), &y_dimid))) /* note the s0+2 array size */ 00319 ERR(retval); 00320 if ((retval = nc_def_dim(ncid, "x", (s1+2), &x_dimid))) /* note the s1+2 array size */ 00321 ERR(retval); 00322 00323 /* The dimids array is used to pass the IDs of the dimensions of 00324 * the variable. */ 00325 dimids[0] = time_dimid; 00326 dimids[1] = y_dimid; 00327 dimids[2] = x_dimid; 00328 00329 /* Define the model output variable, time, x, y, and transverse_mercator (required for EverVIEW application) variables. 00330 The type of the model output variable in this case is * NC_FLOAT (4-byte floating point). */ 00331 if ((retval = nc_def_var(ncid, "transverse_mercator", NC_CHAR, 0, 00332 0, &TM_id))) 00333 { printf("oops: %s",nc_strerror(retval) ); exit(-1); } 00334 00335 if ((retval = nc_def_var(ncid, VARNAME, NC_FLOAT, NDIMS, 00336 dimids, &varid))) 00337 ERR(retval); 00338 if ((retval = nc_def_var(ncid, "time", NC_FLOAT, 1, 00339 &time_dimid, &time_id))) 00340 ERR(retval); 00341 if ((retval = nc_def_var(ncid, "y", NC_FLOAT, 1, 00342 &y_dimid, &y_id))) 00343 ERR(retval); 00344 if ((retval = nc_def_var(ncid, "x", NC_FLOAT, 1, 00345 &x_dimid, &x_id))) 00346 ERR(retval); 00347 00348 /* #### Attributes of the time variable. #### */ 00349 if ((retval = nc_put_att_text(ncid, time_id, "long_name", 00350 strlen("model time"), "model time"))) 00351 ERR(retval); 00352 /* Assign units attributes to the julian time. In definition mode, the current date is initial day 0 of simulation */ 00353 sprintf(dateUnits,"days since %sT12:00:00Z",ELMdate); 00354 if ((retval = nc_put_att_text(ncid, time_id, "units", 00355 strlen(dateUnits), dateUnits))) 00356 ERR(retval); 00357 if ((retval = nc_put_att_text(ncid, time_id, "_CoordinateAxisType", 00358 strlen("Time"), "Time"))) 00359 ERR(retval); 00360 00361 00362 /* #### Attributes of the model output variable. #### */ 00363 /* Assign "long_name" attribute to the variable - to do this right, need to pass the variable's description into here. */ 00364 if ((retval = nc_put_att_text(ncid, varid, "long_name", 00365 strlen(VARNAME), VARNAME))) 00366 ERR(retval); 00367 if ((retval = nc_put_att_text(ncid, varid, "units", 00368 strlen(thisvarUnits), thisvarUnits))) 00369 ERR(retval); 00370 if ((retval = nc_put_att_float(ncid, varid, "missing_value", /* note that "_FillValue" is updated attribute, but EverVIEW didn't respond to that, so using deprecated "missing_value" */ 00371 NC_FLOAT, 1, &offMap_float))) 00372 ERR(retval); 00373 if ((retval = nc_put_att_int(ncid, varid, "OutputInterval_inDays", 00374 NC_INT, 1, &outstep))) 00375 ERR(retval); 00376 if ((retval = nc_put_att_text(ncid, varid, "coordinates", 00377 strlen("x y"), "x y"))) 00378 ERR(retval); 00379 if ((retval = nc_put_att_text(ncid, varid, "grid_mapping", 00380 strlen("transverse_mercator"), "transverse_mercator"))) 00381 ERR(retval); 00382 00383 /* for compatability with other south Florida models, we switched (only the netCDF) output to NAD83 (in the above spatial loop) */ 00384 sprintf(attribute_string,"PROJCS[\"NAD_1983_UTM_Zone_17N\",GEOGCS[\"GCS_North_American_1983\",DATUM[\"D_North_American_1983\",SPHEROID[\"GRS_1980\",6378137.0,298.257222101]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"False_Easting\",500000.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",-81.0],PARAMETER[\"Scale_Factor\",0.9996],PARAMETER[\"Latitude_Of_Origin\",0.0],UNIT[\"Meter\",1.0]]"); 00385 00386 if ((retval = nc_put_att_text(ncid, varid, "esri_pe_string", 00387 strlen(attribute_string), attribute_string))) 00388 ERR(retval); 00389 00390 /* #### Attributes of the UTM coordinate variables. #### */ 00391 if ((retval = nc_put_att_text(ncid, x_id, "long_name", 00392 strlen("easting (x) coordinate"), "easting (x) coordinate"))) 00393 ERR(retval); 00394 if ((retval = nc_put_att_text(ncid, y_id, "long_name", 00395 strlen("northing (y) coordinate"), "northing (y) coordinate"))) 00396 ERR(retval); 00397 if ((retval = nc_put_att_text(ncid, x_id, "standard_name", 00398 strlen("projection_x_coordinate"), "projection_x_coordinate"))) 00399 ERR(retval); 00400 if ((retval = nc_put_att_text(ncid, y_id, "standard_name", 00401 strlen("projection_y_coordinate"), "projection_y_coordinate"))) 00402 ERR(retval); 00403 if ((retval = nc_put_att_text(ncid, x_id, "units", 00404 strlen("m"), "m"))) 00405 ERR(retval); 00406 if ((retval = nc_put_att_text(ncid, y_id, "units", 00407 strlen("m"), "m"))) 00408 ERR(retval); 00409 if ((retval = nc_put_att_text(ncid, x_id, "_CoordinateAxisType", 00410 strlen("GeoX"), "GeoX"))) 00411 ERR(retval); 00412 if ((retval = nc_put_att_text(ncid, y_id, "_CoordinateAxisType", 00413 strlen("GeoY"), "GeoY"))) 00414 ERR(retval); 00415 if ((retval = nc_put_att_text(ncid, x_id, "CellRegistration", 00416 strlen("coords are at cell centroids"), "coords are at cell centroids"))) 00417 ERR(retval); 00418 if ((retval = nc_put_att_text(ncid, y_id, "CellRegistration", 00419 strlen("coords are at cell centroids"), "coords are at cell centroids"))) 00420 ERR(retval); 00421 00422 /* #### Attributes of the transverse_mercator variable (done only for EverVIEW application). #### */ 00423 if ((retval = nc_put_att_text(ncid, TM_id, "grid_mapping_name", 00424 strlen("transverse_mercator"), "transverse_mercator"))) 00425 ERR(retval); 00426 if ((retval = nc_put_att_text(ncid, TM_id, "longitude_of_central_meridian", 00427 strlen(" -81."), " -81."))) 00428 ERR(retval); 00429 if ((retval = nc_put_att_text(ncid, TM_id, "latitude_of_projection_origin", 00430 strlen("0."), "0."))) 00431 ERR(retval); 00432 if ((retval = nc_put_att_text(ncid, TM_id, "scale_factor_at_central_meridian", 00433 strlen("0.9996"), "0.9996"))) 00434 ERR(retval); 00435 if ((retval = nc_put_att_text(ncid, TM_id, "false_easting", 00436 strlen("500000."), "500000."))) 00437 ERR(retval); 00438 if ((retval = nc_put_att_text(ncid, TM_id, "false_northing", 00439 strlen("0."), "0."))) 00440 ERR(retval); 00441 if ((retval = nc_put_att_text(ncid, TM_id, "_CoordinateTransformType", 00442 strlen("Projection"), "Projection"))) 00443 ERR(retval); 00444 if ((retval = nc_put_att_text(ncid, TM_id, "_CoordinateAxisTypes", 00445 strlen("GeoX GeoY"), "GeoX GeoY"))) 00446 ERR(retval); 00447 if ((retval = nc_put_att_text(ncid, TM_id, "units", 00448 strlen("m"), "m"))) 00449 ERR(retval); 00450 00451 00452 /* #### Global attributes. #### */ 00453 if ((retval = nc_put_att_text(ncid, NC_GLOBAL, "title", 00454 strlen("Everglades Landscape Model output"), "Everglades Landscape Model output"))) 00455 ERR(retval); 00456 if ((retval = nc_put_att_text(ncid, NC_GLOBAL, "ModelName", 00457 strlen(modelName), modelName))) 00458 ERR(retval); 00459 if ((retval = nc_put_att_text(ncid, NC_GLOBAL, "ModelVersion", 00460 strlen(modelVers), modelVers))) 00461 ERR(retval); 00462 if ((retval = nc_put_att_text(ncid, NC_GLOBAL, "ScenarioType", 00463 strlen(SimAlt), SimAlt))) 00464 ERR(retval); 00465 if ((retval = nc_put_att_text(ncid, NC_GLOBAL, "Scenario", 00466 strlen(SimModif), SimModif))) 00467 ERR(retval); 00468 if ((retval = nc_put_att_text(ncid, NC_GLOBAL, "Day0_SimulationPeriod", 00469 strlen(initDateRead), initDateRead))) 00470 ERR(retval); 00471 if ((retval = nc_put_att_text(ncid, NC_GLOBAL, "Time_model_run_started", 00472 strlen(asctime(local_begin_time)), asctime(local_begin_time)))) 00473 ERR(retval); 00474 /* todo get rid of this hardcoding */ 00475 sprintf(attribute_string,"H. Carl Fitz, carlfitz3@gmail.com, EcoLandMod, Inc, http://www.ecolandmod.com"); 00476 00477 if ((retval = nc_put_att_text(ncid, NC_GLOBAL, "modelDeveloper", 00478 strlen(attribute_string), attribute_string))) 00479 ERR(retval); 00480 00481 00482 /* #### End define mode. This tells netCDF we are done defining metadata. #### */ 00483 if ((retval = nc_enddef(ncid))) 00484 ERR(retval); 00485 00486 00487 00488 /* Still on the first outstep, write the coordinate variable data. This will put the northings 00489 and eastings of our data grid into the netCDF file. */ 00490 if ((retval = nc_put_var_float(ncid, y_id, &northrev[0]))) /* note the use of reverse rows */ 00491 ERR(retval); 00492 if ((retval = nc_put_var_float(ncid, x_id, &east[0]))) 00493 ERR(retval); 00494 00495 if ((retval = nc_close(ncid))) 00496 ERR(retval); 00497 00498 00499 } /* end of all defs. Done once, prior to first writing of data; have a closed file */ 00500 00501 /* These settings tell netcdf to write one timestep of data. (The 00502 value of start[0] below tells netCDF which (index) 00503 timestep to write.) */ 00504 count[0] = 1; 00505 count[1] = s0+2; /* was s0+2 */ 00506 count[2] = s1+2; /* was s1+2 */ 00507 start[1] = 0; 00508 start[2] = 0; 00509 00510 start[0] = index; /* tried to use 'SimTime.TIME' , but it filled in multiple blank days */ 00511 /* now open the ncdf file, and write to it */ 00512 if ((retval = nc_open(filename, NC_WRITE, &ncid))) 00513 ERR(retval); 00514 if ((retval = nc_inq_varid(ncid, VARNAME, &varid))) 00515 ERR(retval); 00516 if ((retval = nc_inq_varid(ncid, "time", &time_id))) 00517 ERR(retval); 00518 00519 /* Write the data to the file. */ 00520 if ((retval = nc_put_vara_float(ncid, varid, start, count, nc_dataRowRev))) 00521 ERR(retval); 00522 if ((retval = nc_put_var1_float(ncid, time_id, start, &SimTime.TIME ))) 00523 ERR(retval); 00524 00525 /* Close the file. This frees up any internal netCDF resources 00526 * associated with the file, and flushes any buffers. */ 00527 if ((retval = nc_close(ncid))) 00528 ERR(retval); 00529 00530 /* end of netCDF code */ 00531 #else 00532 00533 printf("\nError in configuring 4-byte output request, you asked for netCDF ('C' argument in 'G' command) output, but your globals.h file has NCDF3 set to false: output variable= %s\n",filename); 00534 exit(0); 00535 00536 #endif 00537 }
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.
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 970 of file Serial.c.
Referenced by writeWindow().
00971 { 00972 /* check on these! (who wrote this? Why? (HCF Dec'04) )*/ 00973 int ix, iy; 00974 static unsigned char first_write = 1; 00975 long int ret, dimsizes[2]; 00976 unsigned short int refnum; 00977 if(format == 'H') { 00978 00979 /* NOTE: June 2008 (v2.8.2): do not #define HDF in globals.h to true until until the code here is updated - 00980 this code needs to be updated to HDF4 before it will compile and be used */ 00981 #if HDF 00982 dimsizes[0] = N0; 00983 dimsizes[1] = N1; 00984 sprintf(cTemp,"%s%s:Output:Windows.hdf",OutputPath,ProjName); 00985 DFSDclear(); 00986 00987 switch(Mtype) { 00988 case 'f': 00989 DFSDsetNT(DFNT_FLOAT32); break; 00990 case 'L': 00991 DFSDsetNT(DFNT_FLOAT32); break; 00992 case 'E': 00993 DFSDsetNT(DFNT_FLOAT32); break; 00994 case 'd': case 'i': 00995 DFSDsetNT(DFNT_INT32); break; 00996 case 'c': 00997 DFSDsetNT(DFNT_UINT8); break; 00998 } 00999 if(first_write) { 01000 ret = DFSDputdata(cTemp,2,dimsizes,fValue); 01001 first_write = 0; 01002 } else { 01003 ret = DFSDadddata(cTemp,2,dimsizes,fValue); 01004 } 01005 HDF_VERIFY("DFSDadddata"); 01006 refnum = DFSDlastref(); 01007 ret = DFANputlabel(cTemp,DFTAG_SDG,refnum,label); 01008 HDF_VERIFY("DFANputlabel"); 01009 ret = DFANputdesc(cTemp,DFTAG_SDG,refnum,desc,strlen(desc)); 01010 HDF_VERIFY("DFANputdesc"); 01011 #endif 01012 } 01013 else { 01014 fprintf(Driver_outfile,"\n_________%s\n",label); 01015 fprintf(Driver_outfile,"%s\n",desc); 01016 for (ix=0; ix<N0; ix++) { 01017 fprintf(Driver_outfile,"\n"); 01018 for (iy=0; iy<N1; iy++) { 01019 switch(Mtype) { 01020 case 'f': 01021 if(format=='L') fprintf(Driver_outfile,"%f ",*(((float*)fValue)+iy+ix*N1)); 01022 else if(format=='E') fprintf(Driver_outfile,"%.3E ",*(((float*)fValue)+iy+ix*N1)); 01023 else fprintf(Driver_outfile,"%.3f ",*(((float*)fValue)+iy+ix*N1)); 01024 break; 01025 case 'd': case 'i': 01026 fprintf(Driver_outfile,"%d ",*(((int*)fValue)+iy+ix*N1)); 01027 break; 01028 case 'c': 01029 fprintf(Driver_outfile,"%x ",*(((UCHAR*)fValue)+iy+ix*N1)); 01030 break; 01031 } 01032 } 01033 } 01034 } 01035 }
float* readSeriesCol | ( | char * | filename, | |
int | format, | |||
int | index, | |||
int * | Npt, | |||
float * | TStep, | |||
int | col | |||
) |
(Unused). Read time series input data for spatial interpolations
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 585 of file Serial.c.
Referenced by PTS_SetFields().
00586 { 00587 int line = 0, cread=1, itest, j, sLen = 372 ; 00588 FILE *cfile; 00589 char ctest, cmark[373], ret = '\n'; 00590 unsigned char cmove[373], cmv=0; 00591 char tfilename[200], date_read[20],ss[200]; 00592 int yyyy,mm, dd; 00593 double Jdate_read; 00594 float *tvar, *nullvar, first[10]; 00595 00596 sprintf(tfilename,"%s%d.ts",filename,index); 00597 if(debug>4) fprintf(dFile,"\nReading file %s, col %d, index = %d\n",tfilename,col,index); fflush(dFile); 00598 cfile = fopen(tfilename,"r"); 00599 if(cfile==NULL) { 00600 if( index > 0 ) { fprintf(stdout,"\nWARNING: Unable to open timeseries file %s, using %s0.ts\n",tfilename,filename); return 0; } 00601 else { fprintf(stdout,"\nERROR: Unable to open timeseries file %s\n",tfilename); exit(-1); } 00602 } 00603 00604 if (format != 2) { fprintf(stderr,"ERROR: only using floats in read_timeseries: %d\n",format); exit(0); } 00605 00606 sLen = PORnumday; /* read/determined in genericDriver */ 00607 tvar = (float*) nalloc( (sLen+2)*sizeof(float), "timeseries temp" ); 00608 scan_forward(cfile,"{END COMMENT}\n"); 00609 fgets(ss,200,cfile); /* skip the header line */ 00610 00611 do { 00612 fscanf(cfile, "%d %d %d %f %f %f %f", &yyyy,&mm,&dd,&first[1],&first[2],&first[3],&first[4] ); 00613 /* julian day, returns a double (args = month, day, year, hours, minutes, seconds) */ 00614 Jdate_read = julday(mm, dd, yyyy, 0, 0, 0); 00615 if (Jdate_read > Jdate_init) {printf (" \n***Error\nInit date in %s file > simulation start date.\n",tfilename); exit (-1);} 00616 if (feof(cfile)) { 00617 printf (" \n***Error\nNon-matching starting date for %s meteorological time series\n",tfilename); 00618 exit (-1); 00619 } 00620 } while (Jdate_read < Jdate_init); 00621 00622 tvar[0] = first[col]; /* have now read the first data record, assign to array */ 00623 if(debug>4) fprintf(dFile,"%d %d %d %f\n",yyyy,mm,dd,tvar[0]); 00624 for (line = 1; line<sLen; line++) { 00625 00626 /* each case for reading a different column */ 00627 switch (col) { 00628 case 1: 00629 itest = fscanf(cfile,"%d %d %d %f %f %f %f",&yyyy,&mm,&dd, &(tvar[ line ]),&nullvar, &nullvar, &nullvar); 00630 break; 00631 case 2: 00632 itest = fscanf(cfile,"%d %d %d %f %f %f %f",&yyyy,&mm,&dd,&nullvar, &(tvar[ line ]), &nullvar, &nullvar); 00633 break; 00634 case 3: 00635 itest = fscanf(cfile,"%d %d %d %f %f %f %f",&yyyy,&mm,&dd,&nullvar, &nullvar, &(tvar[ line ]), &nullvar); 00636 break; 00637 case 4: 00638 itest = fscanf(cfile,"%d %d %d %f %f %f %f",&yyyy,&mm,&dd,&nullvar, &nullvar, &nullvar, &(tvar[ line ])); 00639 break; 00640 default: 00641 printf ("\nError in interpolation time series data.\n"); 00642 exit(-1); 00643 break; 00644 } /* end switch */ 00645 00646 if(debug>4) fprintf(dFile,"%d %d %d %f\n",yyyy,mm,dd,tvar[ line ]); 00647 if (feof(cfile)) {printf (" \n***Error\nExceeded number of records for %s meteorological time series\n",tfilename); exit (-1); } 00648 } 00649 tvar[ sLen ] = *TStep; 00650 00651 if(debug>4) { fprintf(dFile,"\nDone Reading file %s\n",tfilename); fflush(dFile); } 00652 00653 fflush(stdout); 00654 fclose(cfile); 00655 *Npt = sLen; 00656 return tvar; 00657 }
byte readMap | ( | char * | filename, | |
void * | data | |||
) |
Read data for spatial (map) input binary file.
filename | data variable's name | |
data | variable's array data |
Definition at line 43 of file Serial.c.
Referenced by read_map_file().
00044 { 00045 int gsize, nbytes; byte bsize; 00046 FILE* bFile; 00047 char binFileName[300]; 00048 00049 bsize = read_header(filename); 00050 00051 sprintf(binFileName,"%s/%s/Data/Map_bin/%s",ModelPath,ProjName,filename); 00052 00053 if((bFile = fopen(binFileName,"rb") ) == NULL ) { 00054 fprintf(stderr,"Can't Open Mapfile: %s",binFileName); 00055 exit(0); 00056 } 00057 gsize = gbl_size[0] * gbl_size[1]; 00058 nbytes = fread((char*)data, (int)bsize, gsize, bFile ); 00059 if(debug) { 00060 fprintf(dFile," %d of %d items Read for %s, size = %x bytes ", 00061 nbytes,gsize,filename,bsize); 00062 } 00063 fclose(bFile); 00064 return bsize; 00065 }
int on_this_proc | ( | int | x, | |
int | y | |||
) |
Parallel code: does nothing in serial implementation).
Definition at line 1500 of file Serial.c.
Referenced by quick_look().
void exchange_borders | ( | UCHAR * | map, | |
int | size | |||
) |
Parallel code: does nothing in serial implementation).
Definition at line 1496 of file Serial.c.
Referenced by link_edges().
void exparam | ( | struct nodenv * | envInfo | ) |
void exgridsplit | ( | int | nprocs, | |
int | ndim, | |||
int | nprocs2[2] | |||
) |
Parallel code: effectively unused in serial implementation.
Definition at line 1453 of file Serial.c.
Referenced by setup_platform().
void exgridcoord | ( | int | pnum, | |
int | rnum[2] | |||
) |
Parallel code: effectively unused in serial implementation.
Definition at line 1460 of file Serial.c.
Referenced by setup_platform().
void exgridsize | ( | int | pnum, | |
int | gsize[2], | |||
int | lsize[2], | |||
int | lstart[2] | |||
) |
Parallel code: effectively unused in serial implementation.
Definition at line 1467 of file Serial.c.
Referenced by setup_grid().
01468 { 01469 int rem[2], i, j; 01470 for( i=0; i<2; i++ ) { 01471 lsize[i] = gsize[i]/nprocs[i]; 01472 rem[i] = gsize[i] - lsize[i]*nprocs[i]; 01473 if(recpnum[i]<rem[i]) lsize[i]++; 01474 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]; 01475 } 01476 }
void broadcastInt | ( | int * | iValPtr | ) |
int exgridinit | ( | int | dim, | |
int * | nprocs | |||
) |
Parallel code: does nothing in serial implementation).
Definition at line 1449 of file Serial.c.
Referenced by setup_platform().
void broadcastMsg | ( | UCHAR * | msgPtr | ) |
void fasync | ( | FILE * | file | ) |
void fmulti | ( | FILE * | file | ) |
int ReadGlobalParms | ( | char * | s_parm_name, | |
int | s_parm_relval | |||
) |
Acquire the model parameters that are global to the domain.
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 2532 of file UnitMod.c.
Referenced by read_model_parameters().
02533 { 02534 02535 /* Geography, hydrology */ 02536 GP_SOLOMEGA = get_global_parm(s_parm_name, s_parm_relval,"GP_SOLOMEGA"); 02537 GP_ALTIT = get_global_parm(s_parm_name, s_parm_relval,"GP_ALTIT"); 02538 GP_LATDEG = get_global_parm(s_parm_name, s_parm_relval,"GP_LATDEG"); 02539 GP_mannDepthPow = get_global_parm(s_parm_name, s_parm_relval,"GP_mannDepthPow"); 02540 GP_mannHeadPow = get_global_parm(s_parm_name, s_parm_relval,"GP_mannHeadPow"); 02541 GP_calibGWat = get_global_parm(s_parm_name, s_parm_relval,"GP_calibGWat"); 02542 GP_IDW_pow = get_global_parm(s_parm_name, s_parm_relval,"GP_IDW_pow"); 02543 GP_calibET = get_global_parm(s_parm_name, s_parm_relval,"GP_calibET"); 02544 GP_DATUM_DISTANCE = get_global_parm(s_parm_name, s_parm_relval,"GP_DATUM_DISTANCE"); 02545 GP_HYD_IC_SFWAT_ADD = get_global_parm(s_parm_name, s_parm_relval,"GP_HYD_IC_SFWAT_ADD"); 02546 GP_HYD_IC_UNSAT_ADD = get_global_parm(s_parm_name, s_parm_relval,"GP_HYD_IC_UNSAT_ADD"); 02547 GP_HYD_RCRECHG = get_global_parm(s_parm_name, s_parm_relval,"GP_HYD_RCRECHG"); 02548 GP_HYD_ICUNSATMOIST = get_global_parm(s_parm_name, s_parm_relval,"GP_HYD_ICUNSATMOIST"); 02549 GP_DetentZ = get_global_parm(s_parm_name, s_parm_relval,"GP_DetentZ"); 02550 GP_WQualMonitZ = get_global_parm(s_parm_name, s_parm_relval,"GP_WQualMonitZ"); 02551 GP_MinCheck = get_global_parm(s_parm_name, s_parm_relval,"GP_MinCheck"); 02552 GP_SLRise = get_global_parm(s_parm_name, s_parm_relval,"GP_SLRise"); 02553 GP_dispLenRef = get_global_parm(s_parm_name, s_parm_relval,"GP_dispLenRef"); 02554 GP_dispParm = get_global_parm(s_parm_name, s_parm_relval,"GP_dispParm"); 02555 02556 /* Periphyton/Algae */ 02557 GP_ALG_IC_MULT = get_global_parm(s_parm_name, s_parm_relval,"GP_ALG_IC_MULT"); 02558 GP_alg_uptake_coef = get_global_parm(s_parm_name, s_parm_relval,"GP_alg_uptake_coef"); 02559 GP_ALG_SHADE_FACTOR = get_global_parm(s_parm_name, s_parm_relval,"GP_ALG_SHADE_FACTOR"); 02560 GP_algMortDepth = get_global_parm(s_parm_name, s_parm_relval,"GP_algMortDepth"); 02561 GP_ALG_RC_MORT_DRY = get_global_parm(s_parm_name, s_parm_relval,"GP_ALG_RC_MORT_DRY"); 02562 GP_ALG_RC_MORT = get_global_parm(s_parm_name, s_parm_relval,"GP_ALG_RC_MORT"); 02563 GP_ALG_RC_PROD = get_global_parm(s_parm_name, s_parm_relval,"GP_ALG_RC_PROD"); 02564 GP_ALG_RC_RESP = get_global_parm(s_parm_name, s_parm_relval,"GP_ALG_RC_RESP"); 02565 GP_alg_R_accel = get_global_parm(s_parm_name, s_parm_relval,"GP_alg_R_accel"); 02566 GP_AlgComp = get_global_parm(s_parm_name, s_parm_relval,"GP_AlgComp"); 02567 GP_ALG_REF_MULT = get_global_parm(s_parm_name, s_parm_relval,"GP_ALG_REF_MULT"); 02568 GP_NC_ALG_KS_P = get_global_parm(s_parm_name, s_parm_relval,"GP_NC_ALG_KS_P"); 02569 GP_alg_alkP_min = get_global_parm(s_parm_name, s_parm_relval,"GP_alg_alkP_min"); 02570 GP_C_ALG_KS_P = get_global_parm(s_parm_name, s_parm_relval,"GP_C_ALG_KS_P"); 02571 GP_ALG_TEMP_OPT = get_global_parm(s_parm_name, s_parm_relval,"GP_ALG_TEMP_OPT"); 02572 GP_C_ALG_threshTP = get_global_parm(s_parm_name, s_parm_relval,"GP_C_ALG_threshTP"); 02573 GP_ALG_C_TO_OM = get_global_parm(s_parm_name, s_parm_relval,"GP_ALG_C_TO_OM"); 02574 GP_alg_light_ext_coef = get_global_parm(s_parm_name, s_parm_relval,"GP_alg_light_ext_coef"); 02575 GP_ALG_LIGHT_SAT = get_global_parm(s_parm_name, s_parm_relval,"GP_ALG_LIGHT_SAT"); 02576 GP_ALG_PC = get_global_parm(s_parm_name, s_parm_relval,"GP_ALG_PC"); 02577 02578 /* Soil */ 02579 GP_DOM_RCDECOMP = get_global_parm(s_parm_name, s_parm_relval,"GP_DOM_RCDECOMP"); 02580 GP_DOM_DECOMPRED = get_global_parm(s_parm_name, s_parm_relval,"GP_DOM_DECOMPRED"); 02581 GP_calibDecomp = get_global_parm(s_parm_name, s_parm_relval,"GP_calibDecomp"); 02582 GP_DOM_decomp_coef = get_global_parm(s_parm_name, s_parm_relval,"GP_DOM_decomp_coef"); 02583 GP_DOM_DECOMP_POPT = get_global_parm(s_parm_name, s_parm_relval,"GP_DOM_DECOMP_POPT"); 02584 GP_DOM_DECOMP_TOPT = get_global_parm(s_parm_name, s_parm_relval,"GP_DOM_DECOMP_TOPT"); 02585 GP_sorbToTP = get_global_parm(s_parm_name, s_parm_relval,"GP_sorbToTP"); 02586 GP_IC_ELEV_MULT = get_global_parm(s_parm_name, s_parm_relval,"GP_IC_ELEV_MULT"); 02587 GP_IC_BATHY_MULT = get_global_parm(s_parm_name, s_parm_relval,"GP_IC_BATHY_MULT"); 02588 GP_IC_DOM_BD_MULT = get_global_parm(s_parm_name, s_parm_relval,"GP_IC_DOM_BD_MULT"); 02589 GP_IC_BulkD_MULT = get_global_parm(s_parm_name, s_parm_relval,"GP_IC_BulkD_MULT"); 02590 GP_IC_TPtoSOIL_MULT = get_global_parm(s_parm_name, s_parm_relval,"GP_IC_TPtoSOIL_MULT"); 02591 02592 /* Macrophytes */ 02593 GP_MAC_IC_MULT = get_global_parm(s_parm_name, s_parm_relval,"GP_MAC_IC_MULT"); 02594 GP_MAC_REFUG_MULT = get_global_parm(s_parm_name, s_parm_relval,"GP_MAC_REFUG_MULT"); 02595 GP_mac_uptake_coef = get_global_parm(s_parm_name, s_parm_relval,"GP_mac_uptake_coef"); 02596 GP_mann_height_coef = get_global_parm(s_parm_name, s_parm_relval,"GP_mann_height_coef"); 02597 02598 /* Floc */ 02599 GP_Floc_BD = get_global_parm(s_parm_name, s_parm_relval,"GP_Floc_BD"); 02600 GP_FlocMax = get_global_parm(s_parm_name, s_parm_relval,"GP_FlocMax"); 02601 GP_TP_P_OM = get_global_parm(s_parm_name, s_parm_relval,"GP_TP_P_OM"); 02602 GP_Floc_rcSoil = get_global_parm(s_parm_name, s_parm_relval,"GP_Floc_rcSoil"); 02603 02604 /* Phosphorus */ 02605 GP_TP_DIFFCOEF = get_global_parm(s_parm_name, s_parm_relval,"GP_TP_DIFFCOEF"); 02606 GP_TP_K_INTER = get_global_parm(s_parm_name, s_parm_relval,"GP_TP_K_INTER"); 02607 GP_TP_K_SLOPE = get_global_parm(s_parm_name, s_parm_relval,"GP_TP_K_SLOPE"); 02608 GP_WQMthresh = get_global_parm(s_parm_name, s_parm_relval,"GP_WQMthresh"); 02609 GP_PO4toTP = get_global_parm(s_parm_name, s_parm_relval,"GP_PO4toTP"); 02610 GP_TP_IN_RAIN = get_global_parm(s_parm_name, s_parm_relval,"GP_TP_IN_RAIN"); 02611 GP_CL_IN_RAIN = get_global_parm(s_parm_name, s_parm_relval,"GP_CL_IN_RAIN"); 02612 GP_PO4toTPint = get_global_parm(s_parm_name, s_parm_relval,"GP_PO4toTPint"); 02613 GP_TP_ICSFWAT = get_global_parm(s_parm_name, s_parm_relval,"GP_TP_ICSFWAT"); 02614 GP_TP_ICSEDWAT = get_global_parm(s_parm_name, s_parm_relval,"GP_TP_ICSEDWAT"); 02615 GP_TPpart_thresh = get_global_parm(s_parm_name, s_parm_relval,"GP_TPpart_thresh"); 02616 GP_TP_DIFFDEPTH = get_global_parm(s_parm_name, s_parm_relval,"GP_TP_DIFFDEPTH"); 02617 GP_settlVel = get_global_parm(s_parm_name, s_parm_relval,"GP_settlVel"); 02618 02619 }
int ReadHabParms | ( | char * | s_parm_name, | |
int | s_parm_relval | |||
) |
Acquire the model parameters that are specific to different habitat types in the domain.
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 2463 of file UnitMod.c.
Referenced by read_model_parameters().
02464 { 02465 02466 /* Periphyton/Algae */ 02467 HP_ALG_MAX = get_hab_parm(s_parm_name, s_parm_relval, "HP_ALG_MAX"); 02468 02469 /* Soil */ 02470 HP_DOM_MAXDEPTH = get_hab_parm(s_parm_name, s_parm_relval,"HP_DOM_MAXDEPTH"); 02471 HP_DOM_AEROBTHIN = get_hab_parm(s_parm_name, s_parm_relval,"HP_DOM_AEROBTHIN"); 02472 02473 /* Phosphorus */ 02474 HP_TP_CONC_GRAD = get_hab_parm(s_parm_name, s_parm_relval,"HP_TP_CONC_GRAD"); 02475 02476 /* Salt/tracer */ 02477 HP_SALT_ICSEDWAT = get_hab_parm(s_parm_name, s_parm_relval,"HP_SALT_ICSEDWAT"); 02478 HP_SALT_ICSFWAT = get_hab_parm(s_parm_name, s_parm_relval,"HP_SALT_ICSFWAT"); 02479 02480 /* Macrophytes */ 02481 HP_PHBIO_MAX = get_hab_parm(s_parm_name, s_parm_relval,"HP_PHBIO_MAX"); 02482 HP_NPHBIO_MAX = get_hab_parm(s_parm_name, s_parm_relval,"HP_NPHBIO_MAX"); 02483 HP_MAC_MAXHT = get_hab_parm(s_parm_name, s_parm_relval,"HP_MAC_MAXHT"); 02484 HP_NPHBIO_ROOTDEPTH = get_hab_parm(s_parm_name, s_parm_relval,"HP_NPHBIO_ROOTDEPTH"); 02485 HP_MAC_MAXROUGH = get_hab_parm(s_parm_name, s_parm_relval,"HP_MAC_MAXROUGH"); 02486 HP_MAC_MINROUGH = get_hab_parm(s_parm_name, s_parm_relval,"HP_MAC_MINROUGH"); 02487 HP_MAC_MAXLAI = get_hab_parm(s_parm_name, s_parm_relval,"HP_MAC_MAXLAI"); 02488 HP_MAC_MAXCANOPCOND = get_hab_parm(s_parm_name, s_parm_relval,"HP_MAC_MAXCANOPCOND"); /* unused in ELMv2.2, 2.3 */ 02489 HP_MAC_CANOPDECOUP = get_hab_parm(s_parm_name, s_parm_relval,"HP_MAC_CANOPDECOUP"); /* unused in ELMv2.2, 2.3 */ 02490 HP_MAC_TEMPOPT = get_hab_parm(s_parm_name, s_parm_relval,"HP_MAC_TEMPOPT"); 02491 HP_MAC_LIGHTSAT = get_hab_parm(s_parm_name, s_parm_relval,"HP_MAC_LIGHTSAT"); 02492 HP_MAC_KSP = get_hab_parm(s_parm_name, s_parm_relval,"HP_MAC_KSP"); 02493 HP_PHBIO_RCNPP = get_hab_parm(s_parm_name, s_parm_relval,"HP_PHBIO_RCNPP"); 02494 HP_PHBIO_RCMORT = get_hab_parm(s_parm_name, s_parm_relval,"HP_PHBIO_RCMORT"); 02495 HP_MAC_WAT_TOLER = get_hab_parm(s_parm_name, s_parm_relval,"HP_MAC_WAT_TOLER"); 02496 HP_MAC_SALIN_THRESH = get_hab_parm(s_parm_name, s_parm_relval,"HP_MAC_SALIN_THRESH"); /* unused in ELMv2.2, 2.3 */ 02497 HP_PHBIO_IC_CTOOM = get_hab_parm(s_parm_name, s_parm_relval,"HP_PHBIO_IC_CTOOM"); 02498 HP_NPHBIO_IC_CTOOM = get_hab_parm(s_parm_name, s_parm_relval,"HP_NPHBIO_IC_CTOOM"); 02499 HP_PHBIO_IC_PC = get_hab_parm(s_parm_name, s_parm_relval,"HP_PHBIO_IC_PC"); 02500 HP_NPHBIO_IC_PC = get_hab_parm(s_parm_name, s_parm_relval,"HP_NPHBIO_IC_PC"); 02501 HP_MAC_TRANSLOC_RC = get_hab_parm(s_parm_name, s_parm_relval,"HP_MAC_TRANSLOC_RC"); 02502 02503 /* Hydrology */ 02504 HP_HYD_RCINFILT = get_hab_parm(s_parm_name, s_parm_relval,"HP_HYD_RCINFILT"); 02505 HP_HYD_SPEC_YIELD = get_hab_parm(s_parm_name, s_parm_relval,"HP_HYD_SPEC_YIELD"); 02506 HP_HYD_POROSITY = get_hab_parm(s_parm_name, s_parm_relval,"HP_HYD_POROSITY"); 02507 02508 /* Floc */ 02509 HP_FLOC_IC = get_hab_parm(s_parm_name, s_parm_relval,"HP_FLOC_IC"); 02510 HP_FLOC_IC_CTOOM = get_hab_parm(s_parm_name, s_parm_relval,"HP_FLOC_IC_CTOOM"); 02511 HP_FLOC_IC_PC = get_hab_parm(s_parm_name, s_parm_relval,"HP_FLOC_IC_PC"); 02512 02513 /* Habitat succession */ 02514 HP_SfDepthLo = get_hab_parm(s_parm_name, s_parm_relval,"HP_SfDepthLo"); 02515 HP_SfDepthHi = get_hab_parm(s_parm_name, s_parm_relval,"HP_SfDepthHi"); 02516 HP_SfDepthInt = get_hab_parm(s_parm_name, s_parm_relval,"HP_SfDepthInt"); 02517 HP_PhosLo = get_hab_parm(s_parm_name, s_parm_relval,"HP_PhosLo"); 02518 HP_PhosHi = get_hab_parm(s_parm_name, s_parm_relval,"HP_PhosHi"); 02519 HP_PhosInt = get_hab_parm(s_parm_name, s_parm_relval,"HP_PhosInt"); 02520 HP_FireInt = get_hab_parm(s_parm_name, s_parm_relval,"HP_FireInt"); 02521 HP_SalinLo = get_hab_parm(s_parm_name, s_parm_relval,"HP_SalinLo"); 02522 HP_SalinHi = get_hab_parm(s_parm_name, s_parm_relval,"HP_SalinHi"); 02523 HP_SalinInt = get_hab_parm(s_parm_name, s_parm_relval,"HP_SalinInt"); 02524 02525 }
int ReadModExperimParms | ( | char * | s_parm_name, | |
int | s_parm_relval | |||
) |
Acquire the model parameters that are used in special model experiments - used only in special, research-oriented applications. (Added for v2.6).
NOTE that this was quickly set up for the ELM Peer Review (2006) project, and (at least in v2.6.0) should be used in conjunction with the spatial interpolators for rain and pET inputs. (because this is intended for scales that are potentially incompatible w/ simultaneous use of gridIO inputs on SFWMM stage/depth that are expected w/ gridIO rain/pET).
NOTE: this has not been specifically developed/tested for inclusion within the automated sensitivity analyses - thus only been used at this point for the ModExperimParms_NOM nominal parameter set (Nov 2006).
.
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 2636 of file UnitMod.c.
Referenced by read_model_parameters().
02637 { 02638 if (isModExperim) { 02639 sprintf(msgStr,"####### Reading special model experiment parameters. \nYou should NOT be using gridIO spatial time series data for rain, pET, and SFWMM-output depth #######..."); 02640 WriteMsg(msgStr,1); 02641 usrErr0(msgStr); 02642 02643 GP_BC_SfWat_add = get_modexperim_parm(s_parm_name, s_parm_relval,"GP_BC_SfWat_add"); 02644 GP_BC_SfWat_addHi = get_modexperim_parm(s_parm_name, s_parm_relval,"GP_BC_SfWat_addHi"); 02645 GP_BC_SatWat_add = get_modexperim_parm(s_parm_name, s_parm_relval,"GP_BC_SatWat_add"); 02646 GP_BC_SfWat_targ = get_modexperim_parm(s_parm_name, s_parm_relval,"GP_BC_SfWat_targ"); 02647 GP_BC_InputRow = get_modexperim_parm(s_parm_name, s_parm_relval,"GP_BC_InputRow"); 02648 GP_BC_Pconc = get_modexperim_parm(s_parm_name, s_parm_relval,"GP_BC_Pconc"); /* ug/L */ 02649 GP_BC_Sconc = get_modexperim_parm(s_parm_name, s_parm_relval,"GP_BC_Sconc"); /* g/L */ 02650 02651 GP_BC_Pconc /= conv_kgTOmg; /* convert from ug/L to g/L (same as div by the kg->mg conversion) */ 02652 02653 sprintf(msgStr,"done."); 02654 WriteMsg(msgStr,1); 02655 usrErr(msgStr); 02656 } 02657 else { 02658 GP_BC_SfWat_add = 0.0; /* value of 0.0 has no effect on model results (adds nothing to boundary depth/stages) */ 02659 GP_BC_SfWat_addHi = 0.0; /* value of 0.0 has no effect on model results (adds nothing to boundary depth/stages) */ 02660 GP_BC_SatWat_add = 0.0; /* value of 0.0 has no effect on model results (adds nothing to boundary depth/stages) */ 02661 GP_BC_SfWat_targ = 0.0; /* value of 0.0 has no effect on model results (only used in Oct06 specialized model experiment - code doesn't use this parm otherwise) */ 02662 GP_BC_InputRow = 0; /* value of 0 has no effect on model results (only used in Oct06 specialized model experiment - code doesn't use this parm otherwise) */ 02663 GP_BC_Pconc = 0.0; 02664 GP_BC_Sconc = 0.0; 02665 } 02666 }
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 32 of file driver_utilities.h.
Referenced by gen_output(), and readViewParms().
char* ModelPath |
Definition at line 40 of file driver_utilities.h.
Referenced by BIRinit(), evap_data_wmm(), get_global_parm(), get_hab_parm(), get_modexperim_parm(), get_parmf(), ModExperim_test(), PTSL_ReadLists(), PTSL_test(), rain_data_wmm(), read_header(), read_map_dims(), Read_schedule(), ReadChanStruct(), readMap(), readOutlist(), ReadStructFlow_PtSer(), ReadStructTP_PtSer(), ReadStructTS_PtSer(), ReadStructures(), SensiParm_list(), set_env_vars(), and stage_data_wmm().
char * ProjName |
Definition at line 40 of file driver_utilities.h.
Referenced by BIRinit(), BIRoutfiles(), Canal_Network_Init(), cell_dyn1(), Channel_configure(), evap_data_wmm(), get_global_parm(), get_hab_parm(), get_modexperim_parm(), get_parmf(), main(), ModExperim_test(), open_debug_outFile(), open_point_lists(), PTSL_ReadLists(), PTSL_test(), rain_data_wmm(), read_header(), read_map_dims(), Read_schedule(), ReadChanStruct(), readMap(), readOutlist(), ReadStructFlow_PtSer(), ReadStructTP_PtSer(), ReadStructTS_PtSer(), ReadStructures(), send_point_lists2(), SensiParm_list(), set_env_vars(), stage_data_wmm(), write_map_file(), and writeSeries().
char * DriverPath |
char * OS_TYPE |
char* OutputPath |
base pathname for all model output (user input)
Definition at line 42 of file driver_utilities.h.
Referenced by BIRoutfiles(), Canal_Network_Init(), cell_dyn1(), Channel_configure(), get_parmf(), main(), open_debug_outFile(), open_point_lists(), send_point_lists2(), write_map_file(), and writeSeries().
char modelName[20] |
Definition at line 48 of file driver_utilities.h.
Referenced by BIRinit(), BIRoutfiles(), Canal_Network_Init(), get_parmf(), open_point_lists(), Read_schedule(), ReadChanStruct(), ReadStructures(), and writeFloatNetCDF().
char modelVers[10] |
Definition at line 48 of file driver_utilities.h.
Referenced by BIRoutfiles(), Canal_Network_Init(), get_parmf(), open_point_lists(), and writeFloatNetCDF().
char modelFileName[300] |
Generic string for input/output file name (overwritten/reused)
Definition at line 50 of file driver_utilities.h.
Referenced by BIRinit(), BIRoutfiles(), Canal_Network_Init(), Channel_configure(), get_global_parm(), get_hab_parm(), get_modexperim_parm(), PTS_SetFields(), PTSL_ReadLists(), read_map_dims(), Read_schedule(), ReadChanStruct(), readOutlist(), ReadStructFlow_PtSer(), ReadStructTP_PtSer(), ReadStructTS_PtSer(), ReadStructures(), SensiParm_list(), and write_map_file().
int gNPtTs |
Definition at line 52 of file driver_utilities.h.
Referenced by PTS_SetFields(), and PTSL_ReadLists().
int PListIndex = 0 |
int total_memory = 0 |
float* plot_array |
Definition at line 55 of file driver_utilities.h.
float gTS |
Definition at line 55 of file driver_utilities.h.
Referenced by PTS_SetFields(), and PTSL_ReadLists().
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 57 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 58 of file driver_utilities.h.
Referenced by read_map_file(), setup_grid(), write_map_file(), and writeWindow().
intermediate variable for model grid memory alloc
Definition at line 59 of file driver_utilities.h.
Referenced by read_map_file(), setup_grid(), write_map_file(), and writeWindow().
float* floatOut |
temporary array to hold an s0+2,s1+2 size array of any variable's floating point values for writing to generic binary map files output
Definition at line 62 of file driver_utilities.h.
Referenced by setup_grid(), and write_map_file().
float* nc_dataRowRev |
temporary array to hold an s0+2,s1+2 size array of any variable's floating point values for writing to netCDF time series file output
Definition at line 63 of file driver_utilities.h.
Referenced by setup_grid(), and writeFloatNetCDF().
float offMap_float = -9999.0 |
off-map values (i.e., missing_value in netCDF)
Definition at line 64 of file driver_utilities.h.
Referenced by write_map_file(), and writeFloatNetCDF().
char gCArg[kCArgDepth][kCArgWidth] |
Output command arguments, parsed from the output configuration file
Definition at line 55 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 61 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 71 of file generic_driver.h.
SeriesParm pSeries[MAX_PTSERIES] |
An array of SeriesParm structs for point time series output
Definition at line 96 of file generic_driver.h.
Referenced by get_parmf(), main(), print_point(), and setup().
struct of type Point2D, the grid location of a point
Definition at line 97 of file generic_driver.h.
Referenced by get_parmf(), read_map_file(), and write_map_file().
struct of nodenv, with parallel code info
Definition at line 99 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 46 of file generic_driver.h.
int lcl_size[2] |
int lcl_start[2] |
Definition at line 111 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 67 of file generic_driver.h.
Referenced by get_parmf(), main(), print_point(), and track_time().
int istep |
counter for number of model time iterations
Definition at line 68 of file generic_driver.h.
Referenced by main(), and quick_look().
int procnum |
Definition at line 111 of file generic_driver.h.
int Lprocnum |
Definition at line 111 of file generic_driver.h.
int nprocs[2] |
Definition at line 111 of file generic_driver.h.
int recpnum[2] |
Definition at line 111 of file generic_driver.h.
float gRTable[] |
data used in function Normal, which is unused
Definition at line 89 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) when running meteorological interpolations; no ELM-calculated interpolations in ELM v2.2 - v2.4
Definition at line 38 of file unitmod_globparms.h.
Referenced by PTSL_GetInterpolatedValue0(), PTSL_GetInterpolatedValue1(), and ReadGlobalParms().
int numBasn |
number of basins in model domain
Definition at line 33 of file budgstats.h.
Referenced by alloc_mem_stats(), BIRbudg_date(), BIRbudg_reset(), BIRbudg_sumFinal(), BIRinit(), BIRoutfiles(), BIRstats_date(), BIRstats_hydro_reset(), BIRstats_hydro_sumFinal(), BIRstats_reset(), BIRstats_sumFinal(), init_pvar(), and ReadChanStruct().