| 2128 | ******************************************************************/ |
| 2129 | |
| 2130 | static boole CVDoErrorTest(CVodeMem cv_mem, int *nflagPtr, int *kflagPtr, |
| 2131 | real saved_t, int *nefPtr, real *dsmPtr) |
| 2132 | { |
| 2133 | real dsm; |
| 2134 | |
| 2135 | dsm = acnrm / tq[2]; |
| 2136 | |
| 2137 | /* If est. local error norm dsm passes test, return TRUE */ |
| 2138 | *dsmPtr = dsm; |
| 2139 | if (dsm <= ONE) return(TRUE); |
| 2140 | |
| 2141 | /* Test failed; increment counters, set nflag, and restore zn array */ |
| 2142 | (*nefPtr)++; |
| 2143 | netf++; |
| 2144 | *nflagPtr = PREV_ERR_FAIL; |
| 2145 | CVRestore(cv_mem, saved_t); |
| 2146 | |
| 2147 | /* At MXNEF failures or |h| = hmin, return with kflag = REP_ERR_FAIL */ |
| 2148 | if ((ABS(h) <= hmin*ONEPSM) || (*nefPtr == MXNEF)) { |
| 2149 | *kflagPtr = REP_ERR_FAIL; |
| 2150 | return(FALSE); |
| 2151 | } |
| 2152 | |
| 2153 | /* Set etamax = 1 to prevent step size increase at end of this step */ |
| 2154 | etamax = ONE; |
| 2155 | |
| 2156 | /* Set h ratio eta from dsm, rescale, and return for retry of step */ |
| 2157 | if (*nefPtr <= MXNEF1) { |
| 2158 | eta = ONE / (RPowerR(BIAS2*dsm,ONE/L) + ADDON); |
| 2159 | eta = MAX(ETAMIN, MAX(eta, hmin / ABS(h))); |
| 2160 | if (*nefPtr >= SMALL_NEF) eta = MIN(eta, ETAMXF); |
| 2161 | CVRescale(cv_mem); |
| 2162 | return(FALSE); |
| 2163 | } |
| 2164 | |
| 2165 | /* After MXNEF1 failures, force an order reduction and retry step */ |
| 2166 | if (q > 1) { |
| 2167 | eta = MAX(ETAMIN, hmin / ABS(h)); |
| 2168 | CVAdjustOrder(cv_mem,-1); |
| 2169 | L = q; |
| 2170 | q--; |
| 2171 | qwait = L; |
| 2172 | CVRescale(cv_mem); |
| 2173 | return(FALSE); |
| 2174 | } |
| 2175 | |
| 2176 | /* If already at order 1, restart: reload zn from scratch */ |
| 2177 | eta = MAX(ETAMIN, hmin / ABS(h)); |
| 2178 | h *= eta; |
| 2179 | hscale = h; |
| 2180 | qwait = LONG_WAIT; |
| 2181 | f(N, tn, zn[0], tempv, f_data); |
| 2182 | nfe++; |
| 2183 | N_VScale(h, tempv, zn[1]); |
| 2184 | return(FALSE); |
| 2185 | } |
| 2186 | |
| 2187 | /*************** CVCompleteStep ********************************** |