Ecological Landscape Modeling: Models Pages

stage_inp.c

Go to the documentation of this file.
00001 
00012 /* General notes on revisions to this source file. 
00013        Nov/Dec 2004 v2.3.2: documentation upgrade 
00014                 - Doxygen tags added 
00015        Mar 2008: documentation upgrade (removed reference to NGVD vert datum) 
00016         
00017 */
00018 #include "stage.h"
00019 
00020 
00021 /* \brief Get spatial input time series of water depth (NOT stage)
00022 
00023         Using the grid_map functions, this returns surface water depth, at ELM (i.e., SME) grid scale, for ELM domain boundary cells.
00024         This function was originally **intended** to return stage data (from model base datum) at ELM (SME) grid scale.
00025         However, this current version (ELMv2.3, Nov '04) uses the SFWMM (positive/negative) water depth relative to a SFWMM grid cell elevation (ft),
00026         converts it to the ELM grid scale, and converts that value to meters of water depth relative to that land surface elevation.
00027         This is (stage - land_surface_elev = water depth).
00028         
00029         \param stageSME Depth (stage misnamed) data array (m) at the ELM/SME grid scale
00030         \return success         */
00031 int stage_data_wmm(float* stageSME)           /* array of float of size s0*s1 */
00032 {
00033 
00034   int i,j,k;
00035   int success = 1, fail = -1;
00036   int stat = success;
00037   char gridmapfilename[335];
00038 
00039   if(SimTime.TIME==0)  {      
00040 /* elm_OG_map is data structure containing the mapping attributes at two scales */
00041     elm_wmm_map = elm_OG_map;
00042 
00043     if(elm_wmm_map == NULL) {
00044       sprintf(msgStr, "Mapping grids and setting up stage data...");
00045       usrErr (msgStr);
00046 
00047       sprintf(gridmapfilename, "%s%s/Data/gridmapping.txt", ModelPath, ProjName );   
00048       stat = mapGrids(gridmapfilename);
00049       elm_wmm_map = elm_OG_map;
00050     }
00051 
00052     if(debug > 4) {
00053       printGridMap();
00054       sprintf(msgStr,"stage_data_wmm==> Finished mapping grids");
00055       usrErr (msgStr);
00056     }
00057 
00058     sprintf(stage_binfilename, "%s%s/Data/BoundCond_stage.BIN", ModelPath, ProjName );
00059     /* initializing data structures, move pointer to initial date (gridmap.c) */
00060     stat = initDataStruct(stage_binfilename,&stage_struct);  
00061 
00062     if(debug > 4) {
00063       /*printELM2Grid_io(); */
00064       /*drawELM2Grid_io(); */
00065       sprintf(msgStr,"stage_data_wmm==> Finished initializing");
00066       usrErr (msgStr); 
00067     }
00068 
00069   } /* end of SimTime.TIME=0 */
00070   
00071   
00072   if(stage_struct.day >= stage_struct.recRead) {      /* process the data in batch */
00073       sprintf(msgStr,"Processing batch of stage data...");
00074       usrErr (msgStr); 
00075       stat = processData(stage_binfilename,&stage_struct);
00076 
00077       if(debug > 4 ) {
00078         /*printBatchData(stageWMM,gridio_batch_len,widCnt);*/ /* TODO: remove this printBatchData function when sure is no longer needed */
00079         sprintf(msgStr,"stage_data_wmm==> Finished processing data");
00080         usrErr (msgStr); 
00081       }
00082   } /* end of if */
00083 
00084 
00085   if(stage_struct.day < stage_struct.recRead) {      /* pass the data day by day */
00086     returnData(stageSME,&stage_struct); 
00087 
00088     for(i = 0; i < s0; i++) {
00089       for(j = 0; j < s1; j++) {
00090         k = i*s1+j;
00091         stageSME[T((i+1),(j+1))] = stage_struct.dataELM[k] * conv_ftTOm;  /* convert data from feet to meters */
00092       }
00093     } 
00094 
00095     if(debug > 4) {
00096       sprintf(msgStr,"stage_data_wmm==> Finished returning data");
00097       usrErr (msgStr); 
00098     }
00099 
00100   } /* end of if */
00101     
00102   return success;
00103 }
00104 
00105 

Generated on Sat Jan 7 14:04:15 2012 for ELM source code by  doxygen 1.5.6