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

rain_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         
00016 */
00017 #include "rain.h"
00018 
00019 
00020 /* \brief Get spatial input time series of rainfall 
00021 
00022         Using the grid_map functions, this obtains rain, at ELM (i.e., SME) grid scale. 
00023         
00024         \param rainSME Rainfall data array (tenths mm) at the ELM grid scale
00025         \return success         */
00026 int rain_data_wmm(float* rainSME)           /* array of float of size s0*s1 */
00027 {
00028 
00029   int i,j,k; 
00030   int success = 1, fail = -1;
00031   int stat = success;
00032   char gridmapfilename[135];
00033 
00034   if(SimTime.TIME==0)  {      
00035 
00036      // cleanUp(*elm_wmm_map, rainSME);
00037       
00038                 /* elm_OG_map is data structure containing the mapping attributes at two scales */
00039       elm_wmm_map = elm_OG_map;
00040 
00041       if(elm_wmm_map == NULL) {
00042           sprintf(msgStr, "Mapping grids and setting up rain data...");
00043           usrErr (msgStr);
00044           
00045           sprintf(gridmapfilename, "%s%s/Data/gridmapping.txt", ModelPath, ProjName );   
00046           stat = mapGrids(gridmapfilename);
00047           elm_wmm_map = elm_OG_map;
00048       }
00049 
00050       if(debug > 4) {
00051           printGridMap();
00052           sprintf(msgStr,"rain_data_wmm==> Finished mapping grids");
00053           usrErr (msgStr);
00054       }
00055 
00056       sprintf(rain_binfilename, "%s%s/Data/rain.BIN", ModelPath, ProjName );
00057     /* initializing data structures, move pointer to initial date (gridmap.c) */
00058       stat = initDataStruct(rain_binfilename,&rain_struct);
00059 
00060       if(debug > 4) {
00061               /* printELM2Grid_io(); */
00062               /*drawELM2Grid_io(); */
00063           sprintf(msgStr,"rain_data_wmm==> Finished initializing");
00064           usrErr (msgStr); 
00065       }
00066 
00067   } /* end of SimTime.TIME=0 */
00068   
00069   
00070   if(rain_struct.day >= rain_struct.recRead) {      /* process the data in batch */
00071       sprintf(msgStr,"Processing batch of rain data...");
00072       usrErr (msgStr); 
00073       stat = processData(rain_binfilename,&rain_struct);
00074 
00075       if(debug > 4 ) {
00076               /*printBatchData(rainWMM,gridio_batch_len,widCnt);*/ /* TODO: remove this printBatchData function when sure is no longer needed */
00077           sprintf(msgStr,"rain_data_wmm==> Finished processing data");
00078           usrErr (msgStr); 
00079       }
00080   } /* end of if */
00081 
00082 
00083   if (rain_struct.day < rain_struct.recRead) {      /* pass the data day by day */
00084     returnData(rainSME,&rain_struct);   
00085     /* change the unit here */
00086     for(i = 0; i < s0; i++) {
00087       for(j = 0; j < s1; j++) {
00088         k = i*s1+j;
00089         rainSME[T((i+1),(j+1))] = rain_struct.dataELM[k] * conv_inTOtenths_mm;  /* convert data from inches to tenths of mm */
00090       }
00091     } 
00092 
00093     if(debug > 4) {
00094       sprintf(msgStr,"rain_data_wmm==> Finished returning data");
00095       usrErr (msgStr); 
00096     }
00097 
00098   } /* end of if */
00099     
00100   return success;
00101 }
00102 

Generated on Thu Jul 6 11:17:48 2006 for ELM source code by  doxygen 1.3.9.1