Main Page   Compound List   File List   Compound Members   File Members  

FireRoth1972Config.c

Go to the documentation of this file.
00001 
00025 #include "FireRoth1972Config.h"
00026 
00027 int InitRothFuelModelListFromProps(ChHashTable * proptbl, List ** fmlist)   {
00028     FuelModel * fm          = NULL;             /* instance of a FuelModel */
00029     char * fmd_fname        = NULL;             /* name of fmd fuel values file */
00030     List * brn_list         = NULL;             /* list of burnable model numbers */
00031     List * unbrn_list       = NULL;             /* list of unburnable model numbers */ 
00032     ListElmt * lel          = NULL;             /* single list element */
00033     KeyVal * entry          = NULL;             /* key/val instances from table */
00034     int * fmnum             = NULL;             /* fuel model number */
00035 
00036     if ( proptbl == NULL || (*fmlist = InitListEmpty(FreeFuelModel)) == NULL )  {
00037         ERR_ERROR("Unable to allocate memory for fuel model nums list. \n", ERR_ENOMEM);
00038         }
00039     
00040     /* ensure user specified RothFuelModel */   
00041     if ( ChHashTableRetrieve(proptbl, GetFireProp(PROP_FPTYP), (void *)&entry) ||
00042             (strcmp(entry->val, GetFireVal(VAL_ROTH)) != 0) )   {
00043         ERR_ERROR("FUEL_PROPS_TYPE property must be ROTH to create RothFuelModel. \n", ERR_EFAILED);
00044         }
00045 
00046     /* determine FMD_FILE */
00047     if ( ChHashTableRetrieve(proptbl, GetFireProp(PROP_FPFMD), (void *)&entry) ||
00048             strcmp(entry->val, GetFireVal(VAL_NULL)) == 0 ) {
00049         FreeList(*fmlist);
00050         ERR_ERROR("Unable to retrieve FMD_FILE property for fuels data. \n", ERR_EFAILED);
00051         }
00052     fmd_fname = (char *) entry->val;    
00053                                         
00054     /* determine NUMS_IMPORT */
00055     if ( ChHashTableRetrieve(proptbl, GetFireProp(PROP_FPIMP), (void *)&entry) )    {
00056         ERR_ERROR_CONTINUE("Unable to retrieve NUMS_IMPORT property for fuels data. \n", ERR_EFAILED);
00057         }
00058     brn_list = GetIntListFromLineFStreamIO((char *)entry->val, FIRE_ROTH1972_CONFIG_FUEL_SEP_CHARS);
00059 
00060     /* construct instances of BURNABLE FuelModels and place in fm list */
00061     lel = LIST_HEAD(brn_list);
00062     while (lel != NULL) {
00063         fmnum = LIST_GET_DATA(lel);     
00064         if ( fmnum != NULL && (fm = InitFuelModelFMDFile(*fmnum, NULL, NULL, fmd_fname, EnumRoth)) != NULL )    {
00065             /* set the fuel bed properties */
00066             if ( Roth1972FireSpreadSetFuelBed(fm->rfm) )    {
00067                 ERR_ERROR_CONTINUE("Fuels data not initialized. \n", ERR_EBADFUNC);
00068                 }
00069             else    {
00070                 ListInsertNext(*fmlist, NULL, fm);
00071                 }
00072             }                   
00073         lel = LIST_GET_NEXT_ELMT(lel);
00074         }
00075         
00076     /* must have at least one burnable fuel model to run simulation */
00077     if ( LIST_SIZE(*fmlist) < 1 )   {
00078         FreeList(*fmlist);
00079         ERR_ERROR("At least one BURNABLE FuelModel must be initialized to start simulation. \n", ERR_ESANITY);
00080         }
00081                         
00082     /* determine NUMS_UNBURNABLE */
00083     if ( ChHashTableRetrieve(proptbl, GetFireProp(PROP_FPUNB), (void *)&entry) )    {
00084         ERR_ERROR_CONTINUE("Unable to retrieve NUMS_UNBURNABLE property for fuels data. \n", ERR_EFAILED);
00085         }
00086     unbrn_list = GetIntListFromLineFStreamIO((char *)entry->val, FIRE_ROTH1972_CONFIG_FUEL_SEP_CHARS);
00087 
00088     /* construct instances of UNBURNABLE FuelModels and place in fm list */
00089     lel = LIST_HEAD(unbrn_list);
00090     while (lel != NULL) {
00091         fmnum = LIST_GET_DATA(lel);     
00092         if ( fmnum != NULL && (fm = InitFuelModelUnBurnable(*fmnum, NULL, NULL, EnumRoth)) != NULL ) {
00093             /* set the fuel bed properties */
00094             if ( Roth1972FireSpreadSetFuelBed(fm->rfm) )    {
00095                 ERR_ERROR_CONTINUE("Fuels data not initialized. \n", ERR_EBADFUNC);
00096                 }
00097             else    {       
00098                 ListInsertNext(*fmlist, NULL, fm);
00099                 }
00100             }
00101         lel = LIST_GET_NEXT_ELMT(lel);
00102         }
00103     
00104     /* free memory */
00105     FreeList(brn_list);
00106     FreeList(unbrn_list);   
00107                 
00108     return ERR_SUCCESS;
00109     }
00110      
00111 /* end of FireRothFuelModel.c */

Generated at Fri Jun 22 00:46:51 2001 for HFire by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000