Ecological Landscape Modeling: Models Pages |
#include "multi_run.h"
Go to the source code of this file.
Functions | |
int | numRuns (int SParmNum, int NumSRunsPerSet) |
Determine the number of simulation runs per program execution. | |
int | SensiParm_list (char *sparm_name) |
Get the parameter list for a multi-parameter sensitivity analysis. | |
void | alloc_mem_runs (int SParmNum) |
Allocate memory for data structs used in multiple-run sensitivity analyses. |
Currently used in an integrated sensitivity analysis of model. Anticipate uses may include formal uncertainty analyses and stochastic ecological (e.g., fire) processes.
This source file contains several functions to acquire and set up a multi-run execution.
Note: documented with Doxygen, which expects specific syntax within special comments.
The Everglades Landscape Model (ELM).
last updated: Feb 2005
Definition in file MultiRun.c.
int numRuns | ( | int | SParmNum, | |
int | NumSRunsPerSet | |||
) |
Determine the number of simulation runs per program execution.
SParmNum | the number of parameters to be evaluated in a sensitivity analysis | |
NumSRunsPerSet | The number of simulation runs per set of parameter-evaluations (currently using one low-parameter, one high-parameter value) |
Definition at line 32 of file MultiRun.c.
Referenced by main().
00033 { 00034 int numberRuns; 00035 00036 numberRuns = (1+NumSRunsPerSet*SParmNum); 00037 00038 return numberRuns; 00039 }
int SensiParm_list | ( | char * | sparm_name | ) |
Get the parameter list for a multi-parameter sensitivity analysis.
This does not check to ensure that a parameter in the list is actually a parameter found in the model. If there is a typo in a parameter in this input list, the program will merely make a set of runs with all-nominal values of the intended parameter. Therefore: use the list of parameters that is generated from the GlobalParms.xls and HabParms_defs.xls (OpenOffice) workbooks. Yes, we can/will provide some checking at some point.
sparm_name | Name of the sensitivity parameter being varied for this run |
Definition at line 55 of file MultiRun.c.
References modelFileName, ModelPath, msgStr, ProgExec, ProjName, RunList, prog_attr::S_ParmName, prog_attr::S_ParmRelVal, usrErr(), and WriteMsg().
Referenced by main().
00056 { 00057 FILE *SParm_listFile; 00058 char filename[20]; 00059 char modelFileName[300]; 00060 char ss[422], *line; 00061 int SParmNum = 0; 00062 00063 if (strcmp(sparm_name,"ALL")!=0) return(1) ; 00064 00065 sprintf(filename,"SensiParm_list"); 00066 sprintf( modelFileName, "%s/%s/Data/%s", ModelPath, ProjName, filename ); 00067 00068 /* Open file with list of parameters for Sensitivity Analysis */ 00069 if ( ( SParm_listFile = fopen( modelFileName, "r" ) ) == NULL ) 00070 { 00071 printf( "Can't open %s file!\n", modelFileName ) ; 00072 exit(-1) ; 00073 } 00074 00075 sprintf(msgStr, "Sensitivity Analysis Parameters: ") ; 00076 WriteMsg(msgStr,1); 00077 usrErr(msgStr); 00078 00079 fgets( ss, 420, SParm_listFile ); 00080 fgets( ss, 420, SParm_listFile ); 00081 fgets( ss, 420, SParm_listFile ); /* skip header lines */ 00082 00083 while ( fgets( ss, 420, SParm_listFile ) != NULL && !feof( SParm_listFile ) ) 00084 { 00085 /* Allocate memory for next parm set (initially, we have already gotten the info for the nominal run into the struct w/ SParmNum = 0) */ 00086 if ( (ProgExec = ( ProgAttr *) malloc( (size_t) sizeof( ProgAttr ))) == NULL ) { 00087 sprintf(msgStr, "Failed to allocate memory for next struct defining multiple simulation runs.\n ") ; 00088 usrErr(msgStr); 00089 exit( -2 ) ; 00090 } 00091 line = ss; 00092 sscanf (line, "%s", &ProgExec->S_ParmName); 00093 00094 SParmNum++; /* count the number of parms to be evaluated in sensi */ 00095 RunList[SParmNum] = ProgExec; 00096 ProgExec->S_ParmRelVal = 0; /* init to 0 for all */ 00097 00098 sprintf(msgStr, "%d: %s", SParmNum, ProgExec->S_ParmName) ; 00099 WriteMsg(msgStr,1); 00100 usrErr(msgStr); 00101 00102 00103 00104 } /* end of reading basin lines */ 00105 00106 fclose(SParm_listFile); 00107 return (SParmNum); 00108 00109 }
void alloc_mem_runs | ( | int | SParmNum | ) |
Allocate memory for data structs used in multiple-run sensitivity analyses.
SParmNum | the number of parameters to be evaluated in a sensitivity analysis |
Definition at line 116 of file MultiRun.c.
References msgStr, ProgExec, RunList, and usrErr().
Referenced by get_parmf().
00117 { 00118 if ( (ProgExec = ( ProgAttr *) malloc( (size_t) sizeof( ProgAttr ))) == NULL ) { 00119 sprintf(msgStr, "Failed to allocate memory for first struct defining (possibly multiple) simulation run(s).\n ") ; 00120 usrErr(msgStr); 00121 exit( -2 ) ; 00122 } 00123 /* allocate memory for array of pointers to simulation run attributes */ 00124 if ( (RunList = ( ProgAttr **) malloc( (size_t) sizeof( ProgAttr *) * (SParmNum+1) ) ) == NULL ) 00125 { 00126 printf( "Failed to allocate memory for RunList of simulation attributes \n " ); 00127 exit( -2 ); 00128 } 00129 00130 00131 }