00001 /* dchhre.f -- translated by f2c (version 20030320). 00002 You must link the resulting object file with the libraries: 00003 -lf2c -lm (in that order) 00004 */ 00005 00006 #ifdef __cplusplus 00007 extern "C" { 00008 #endif 00009 #include "f2c.h" 00010 00011 /* Table of constant values */ 00012 00013 static integer c__2 = 2; 00014 00015 /* Subroutine */ int dchhre_(integer *maxdim, integer *ndim, integer *numfun, 00016 integer *mdiv, doublereal *a, doublereal *b, integer *minpts, integer 00017 *maxpts, doublereal *epsabs, doublereal *epsrel, integer *key, 00018 integer *nw, integer *restar, integer *num, integer *maxsub, integer * 00019 minsub, integer *keyf, integer *ifail, integer *wtleng) 00020 { 00021 /* System generated locals */ 00022 integer i__1; 00023 00024 /* Builtin functions */ 00025 integer pow_ii(integer *, integer *); 00026 00027 /* Local variables */ 00028 static integer j, limit; 00029 00030 /* ***BEGIN PROLOGUE DCHHRE */ 00031 /* ***PURPOSE DCHHRE checks the validity of the */ 00032 /* input parameters to DCUHRE. */ 00033 /* ***DESCRIPTION */ 00034 /* DCHHRE computes NUM, MAXSUB, MINSUB, KEYF, WTLENG and */ 00035 /* IFAIL as functions of the input parameters to DCUHRE, */ 00036 /* and checks the validity of the input parameters to DCUHRE. */ 00037 00038 /* ON ENTRY */ 00039 00040 /* MAXDIM Integer. */ 00041 /* The maximum allowed number of dimensions. */ 00042 /* NDIM Integer. */ 00043 /* Number of variables. 1 < NDIM <= MAXDIM. */ 00044 /* NUMFUN Integer. */ 00045 /* Number of components of the integral. */ 00046 /* MDIV Integer. */ 00047 /* MDIV is the number of subregions that are divided in */ 00048 /* each subdivision step in DADHRE. */ 00049 /* MDIV is chosen default to 1. */ 00050 /* For efficient execution on parallel computers */ 00051 /* with NPROC processors MDIV should be set equal to */ 00052 /* the smallest integer such that MOD(2*MDIV,NPROC) = 0. */ 00053 /* A Real array of dimension NDIM. */ 00054 /* Lower limits of integration. */ 00055 /* B Real array of dimension NDIM. */ 00056 /* Upper limits of integration. */ 00057 /* MINPTS Integer. */ 00058 /* Minimum number of function evaluations. */ 00059 /* MAXPTS Integer. */ 00060 /* Maximum number of function evaluations. */ 00061 /* The number of function evaluations over each subregion */ 00062 /* is NUM. */ 00063 /* If (KEY = 0 or KEY = 1) and (NDIM = 2) Then */ 00064 /* NUM = 65 */ 00065 /* Elseif (KEY = 0 or KEY = 2) and (NDIM = 3) Then */ 00066 /* NUM = 127 */ 00067 /* Elseif (KEY = 0 and NDIM > 3) or (KEY = 3) Then */ 00068 /* NUM = 1 + 4*2*NDIM + 2*NDIM*(NDIM-1) + 4*NDIM*(NDIM-1) + */ 00069 /* 4*NDIM*(NDIM-1)*(NDIM-2)/3 + 2**NDIM */ 00070 /* Elseif (KEY = 4) Then */ 00071 /* NUM = 1 + 3*2*NDIM + 2*NDIM*(NDIM-1) + 2**NDIM */ 00072 /* MAXPTS >= 3*NUM and MAXPTS >= MINPTS */ 00073 /* EPSABS Real. */ 00074 /* Requested absolute error. */ 00075 /* EPSREL Real. */ 00076 /* Requested relative error. */ 00077 /* KEY Integer. */ 00078 /* Key to selected local integration rule. */ 00079 /* KEY = 0 is the default value. */ 00080 /* For NDIM = 2 the degree 13 rule is selected. */ 00081 /* For NDIM = 3 the degree 11 rule is selected. */ 00082 /* For NDIM > 3 the degree 9 rule is selected. */ 00083 /* KEY = 1 gives the user the 2 dimensional degree 13 */ 00084 /* integration rule that uses 65 evaluation points. */ 00085 /* KEY = 2 gives the user the 3 dimensional degree 11 */ 00086 /* integration rule that uses 127 evaluation points. */ 00087 /* KEY = 3 gives the user the degree 9 integration rule. */ 00088 /* KEY = 4 gives the user the degree 7 integration rule. */ 00089 /* This is the recommended rule for problems that */ 00090 /* require great adaptivity. */ 00091 /* NW Integer. */ 00092 /* Defines the length of the working array WORK. */ 00093 /* Let MAXSUB denote the maximum allowed number of subregions */ 00094 /* for the given values of MAXPTS, KEY and NDIM. */ 00095 /* MAXSUB = (MAXPTS-NUM)/(2*NUM) + 1 */ 00096 /* NW should be greater or equal to */ 00097 /* MAXSUB*(2*NDIM+2*NUMFUN+2) + 17*NUMFUN + 1 */ 00098 /* For efficient execution on parallel computers */ 00099 /* NW should be chosen greater or equal to */ 00100 /* MAXSUB*(2*NDIM+2*NUMFUN+2) + 17*NUMFUN*MDIV + 1 */ 00101 /* where MDIV is the number of subregions that are divided in */ 00102 /* each subdivision step. */ 00103 /* MDIV is default set internally in DCUHRE equal to 1. */ 00104 /* For efficient execution on parallel computers */ 00105 /* with NPROC processors MDIV should be set equal to */ 00106 /* the smallest integer such that MOD(2*MDIV,NPROC) = 0. */ 00107 /* RESTAR Integer. */ 00108 /* If RESTAR = 0, this is the first attempt to compute */ 00109 /* the integral. */ 00110 /* If RESTAR = 1, then we restart a previous attempt. */ 00111 00112 /* ON RETURN */ 00113 00114 /* NUM Integer. */ 00115 /* The number of function evaluations over each subregion. */ 00116 /* MAXSUB Integer. */ 00117 /* The maximum allowed number of subregions for the */ 00118 /* given values of MAXPTS, KEY and NDIM. */ 00119 /* MINSUB Integer. */ 00120 /* The minimum allowed number of subregions for the given */ 00121 /* values of MINPTS, KEY and NDIM. */ 00122 /* IFAIL Integer. */ 00123 /* IFAIL = 0 for normal exit. */ 00124 /* IFAIL = 2 if KEY is less than 0 or KEY greater than 4. */ 00125 /* IFAIL = 3 if NDIM is less than 2 or NDIM greater than */ 00126 /* MAXDIM. */ 00127 /* IFAIL = 4 if KEY = 1 and NDIM not equal to 2. */ 00128 /* IFAIL = 5 if KEY = 2 and NDIM not equal to 3. */ 00129 /* IFAIL = 6 if NUMFUN less than 1. */ 00130 /* IFAIL = 7 if volume of region of integration is zero. */ 00131 /* IFAIL = 8 if MAXPTS is less than 3*NUM. */ 00132 /* IFAIL = 9 if MAXPTS is less than MINPTS. */ 00133 /* IFAIL = 10 if EPSABS < 0 and EPSREL < 0. */ 00134 /* IFAIL = 11 if NW is too small. */ 00135 /* IFAIL = 12 if unlegal RESTAR. */ 00136 /* KEYF Integer. */ 00137 /* Key to selected integration rule. */ 00138 /* WTLENG Integer. */ 00139 /* The number of generators of the chosen integration rule. */ 00140 00141 /* ***ROUTINES CALLED-NONE */ 00142 /* ***END PROLOGUE DCHHRE */ 00143 00144 /* Global variables. */ 00145 00146 00147 /* Local variables. */ 00148 00149 00150 /* ***FIRST EXECUTABLE STATEMENT DCHHRE */ 00151 00152 /* Parameter adjustments */ 00153 --b; 00154 --a; 00155 00156 /* Function Body */ 00157 *ifail = 0; 00158 00159 /* Check on legal KEY. */ 00160 00161 if (*key < 0 || *key > 4) { 00162 *ifail = 2; 00163 goto L999; 00164 } 00165 00166 /* Check on legal NDIM. */ 00167 00168 if (*ndim < 2 || *ndim > *maxdim) { 00169 *ifail = 3; 00170 goto L999; 00171 } 00172 00173 /* For KEY = 1, NDIM must be equal to 2. */ 00174 00175 if (*key == 1 && *ndim != 2) { 00176 *ifail = 4; 00177 goto L999; 00178 } 00179 00180 /* For KEY = 2, NDIM must be equal to 3. */ 00181 00182 if (*key == 2 && *ndim != 3) { 00183 *ifail = 5; 00184 goto L999; 00185 } 00186 00187 /* For KEY = 0, we point at the selected integration rule. */ 00188 00189 if (*key == 0) { 00190 if (*ndim == 2) { 00191 *keyf = 1; 00192 } else if (*ndim == 3) { 00193 *keyf = 2; 00194 } else { 00195 *keyf = 3; 00196 } 00197 } else { 00198 *keyf = *key; 00199 } 00200 00201 /* Compute NUM and WTLENG as a function of KEYF and NDIM. */ 00202 00203 if (*keyf == 1) { 00204 *num = 65; 00205 *wtleng = 14; 00206 } else if (*keyf == 2) { 00207 *num = 127; 00208 *wtleng = 13; 00209 } else if (*keyf == 3) { 00210 *num = (*ndim << 3) + 1 + (*ndim << 1) * (*ndim - 1) + (*ndim << 2) * 00211 (*ndim - 1) + (*ndim << 2) * (*ndim - 1) * (*ndim - 2) / 3 + 00212 pow_ii(&c__2, ndim); 00213 *wtleng = 9; 00214 if (*ndim == 2) { 00215 *wtleng = 8; 00216 } 00217 } else if (*keyf == 4) { 00218 *num = *ndim * 6 + 1 + (*ndim << 1) * (*ndim - 1) + pow_ii(&c__2, 00219 ndim); 00220 *wtleng = 6; 00221 } 00222 00223 /* Compute MAXSUB. */ 00224 00225 *maxsub = (*maxpts - *num) / (*num << 1) + 1; 00226 00227 /* Compute MINSUB. */ 00228 00229 *minsub = (*minpts - *num) / (*num << 1) + 1; 00230 if ((*minpts - *num) % (*num << 1) != 0) { 00231 ++(*minsub); 00232 } 00233 *minsub = max(2,*minsub); 00234 00235 /* Check on positive NUMFUN. */ 00236 00237 if (*numfun < 1) { 00238 *ifail = 6; 00239 goto L999; 00240 } 00241 00242 /* Check on legal upper and lower limits of integration. */ 00243 00244 i__1 = *ndim; 00245 for (j = 1; j <= i__1; ++j) { 00246 if (a[j] - b[j] == 0.) { 00247 *ifail = 7; 00248 goto L999; 00249 } 00250 /* L10: */ 00251 } 00252 00253 /* Check on MAXPTS < 3*NUM. */ 00254 00255 if (*maxpts < *num * 3) { 00256 *ifail = 8; 00257 goto L999; 00258 } 00259 00260 /* Check on MAXPTS >= MINPTS. */ 00261 00262 if (*maxpts < *minpts) { 00263 *ifail = 9; 00264 goto L999; 00265 } 00266 00267 /* Check on legal accuracy requests. */ 00268 00269 if (*epsabs < 0. && *epsrel < 0.) { 00270 *ifail = 10; 00271 goto L999; 00272 } 00273 00274 /* Check on big enough double precision workspace. */ 00275 00276 limit = *maxsub * ((*ndim << 1) + (*numfun << 1) + 2) + *mdiv * 17 * * 00277 numfun + 1; 00278 if (*nw < limit) { 00279 *ifail = 11; 00280 goto L999; 00281 } 00282 00283 /* Check on legal RESTAR. */ 00284 00285 if (*restar != 0 && *restar != 1) { 00286 *ifail = 12; 00287 goto L999; 00288 } 00289 L999: 00290 return 0; 00291 00292 /* ***END DCHHRE */ 00293 00294 } /* dchhre_ */ 00295 00296 #ifdef __cplusplus 00297 } 00298 #endif