snls1e.f 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. *DECK SNLS1E
  2. SUBROUTINE SNLS1E (FCN, IOPT, M, N, X, FVEC, TOL, NPRINT, INFO,
  3. + IW, WA, LWA)
  4. C***BEGIN PROLOGUE SNLS1E
  5. C***PURPOSE An easy-to-use code which minimizes the sum of the squares
  6. C of M nonlinear functions in N variables by a modification
  7. C of the Levenberg-Marquardt algorithm.
  8. C***LIBRARY SLATEC
  9. C***CATEGORY K1B1A1, K1B1A2
  10. C***TYPE SINGLE PRECISION (SNLS1E-S, DNLS1E-D)
  11. C***KEYWORDS EASY-TO-USE, LEVENBERG-MARQUARDT, NONLINEAR DATA FITTING,
  12. C NONLINEAR LEAST SQUARES
  13. C***AUTHOR Hiebert, K. L., (SNLA)
  14. C***DESCRIPTION
  15. C
  16. C 1. Purpose.
  17. C
  18. C The purpose of SNLS1E is to minimize the sum of the squares of M
  19. C nonlinear functions in N variables by a modification of the
  20. C Levenberg-Marquardt algorithm. This is done by using the more
  21. C general least-squares solver SNLS1. The user must provide a
  22. C subroutine which calculates the functions. The user has the
  23. C option of how the Jacobian will be supplied. The user can
  24. C supply the full Jacobian, or the rows of the Jacobian (to avoid
  25. C storing the full Jacobian), or let the code approximate the
  26. C Jacobian by forward-differencing. This code is the combination
  27. C of the MINPACK codes (Argonne) LMDER1, LMDIF1, and LMSTR1.
  28. C
  29. C
  30. C 2. Subroutine and Type Statements.
  31. C
  32. C SUBROUTINE SNLS1E(FCN,IOPT,M,N,X,FVEC,TOL,NPRINT,
  33. C * INFO,IW,WA,LWA)
  34. C INTEGER IOPT,M,N,NPRINT,INFO,LWA
  35. C INTEGER IW(N)
  36. C REAL TOL
  37. C REAL X(N),FVEC(M),WA(LWA)
  38. C EXTERNAL FCN
  39. C
  40. C
  41. C 3. Parameters.
  42. C
  43. C Parameters designated as input parameters must be specified on
  44. C entry to SNLS1E and are not changed on exit, while parameters
  45. C designated as output parameters need not be specified on entry
  46. C and are set to appropriate values on exit from SNLS1E.
  47. C
  48. C FCN is the name of the user-supplied subroutine which calculates
  49. C the functions. If the user wants to supply the Jacobian
  50. C (IOPT=2 or 3), then FCN must be written to calculate the
  51. C Jacobian, as well as the functions. See the explanation
  52. C of the IOPT argument below.
  53. C If the user wants the iterates printed (NPRINT positive), then
  54. C FCN must do the printing. See the explanation of NPRINT
  55. C below. FCN must be declared in an EXTERNAL statement in the
  56. C calling program and should be written as follows.
  57. C
  58. C
  59. C SUBROUTINE FCN(IFLAG,M,N,X,FVEC,FJAC,LDFJAC)
  60. C INTEGER IFLAG,LDFJAC,M,N
  61. C REAL X(N),FVEC(M)
  62. C ----------
  63. C FJAC and LDFJAC may be ignored , if IOPT=1.
  64. C REAL FJAC(LDFJAC,N) , if IOPT=2.
  65. C REAL FJAC(N) , if IOPT=3.
  66. C ----------
  67. C If IFLAG=0, the values in X and FVEC are available
  68. C for printing. See the explanation of NPRINT below.
  69. C IFLAG will never be zero unless NPRINT is positive.
  70. C The values of X and FVEC must not be changed.
  71. C RETURN
  72. C ----------
  73. C If IFLAG=1, calculate the functions at X and return
  74. C this vector in FVEC.
  75. C RETURN
  76. C ----------
  77. C If IFLAG=2, calculate the full Jacobian at X and return
  78. C this matrix in FJAC. Note that IFLAG will never be 2 unless
  79. C IOPT=2. FVEC contains the function values at X and must
  80. C not be altered. FJAC(I,J) must be set to the derivative
  81. C of FVEC(I) with respect to X(J).
  82. C RETURN
  83. C ----------
  84. C If IFLAG=3, calculate the LDFJAC-th row of the Jacobian
  85. C and return this vector in FJAC. Note that IFLAG will
  86. C never be 3 unless IOPT=3. FVEC contains the function
  87. C values at X and must not be altered. FJAC(J) must be
  88. C set to the derivative of FVEC(LDFJAC) with respect to X(J).
  89. C RETURN
  90. C ----------
  91. C END
  92. C
  93. C
  94. C The value of IFLAG should not be changed by FCN unless the
  95. C user wants to terminate execution of SNLS1E. In this case,
  96. C set IFLAG to a negative integer.
  97. C
  98. C
  99. C IOPT is an input variable which specifies how the Jacobian will
  100. C be calculated. If IOPT=2 or 3, then the user must supply the
  101. C Jacobian, as well as the function values, through the
  102. C subroutine FCN. If IOPT=2, the user supplies the full
  103. C Jacobian with one call to FCN. If IOPT=3, the user supplies
  104. C one row of the Jacobian with each call. (In this manner,
  105. C storage can be saved because the full Jacobian is not stored.)
  106. C If IOPT=1, the code will approximate the Jacobian by forward
  107. C differencing.
  108. C
  109. C M is a positive integer input variable set to the number of
  110. C functions.
  111. C
  112. C N is a positive integer input variable set to the number of
  113. C variables. N must not exceed M.
  114. C
  115. C X is an array of length N. On input, X must contain an initial
  116. C estimate of the solution vector. On output, X contains the
  117. C final estimate of the solution vector.
  118. C
  119. C FVEC is an output array of length M which contains the functions
  120. C evaluated at the output X.
  121. C
  122. C TOL is a non-negative input variable. Termination occurs when
  123. C the algorithm estimates either that the relative error in the
  124. C sum of squares is at most TOL or that the relative error
  125. C between X and the solution is at most TOL. Section 4 contains
  126. C more details about TOL.
  127. C
  128. C NPRINT is an integer input variable that enables controlled
  129. C printing of iterates if it is positive. In this case, FCN is
  130. C called with IFLAG = 0 at the beginning of the first iteration
  131. C and every NPRINT iterations thereafter and immediately prior
  132. C to return, with X and FVEC available for printing. Appropriate
  133. C print statements must be added to FCN (see example) and
  134. C FVEC should not be altered. If NPRINT is not positive, no
  135. C special calls of FCN with IFLAG = 0 are made.
  136. C
  137. C INFO is an integer output variable. If the user has terminated
  138. C execution, INFO is set to the (negative) value of IFLAG. See
  139. C description of FCN and JAC. Otherwise, INFO is set as follows.
  140. C
  141. C INFO = 0 improper input parameters.
  142. C
  143. C INFO = 1 algorithm estimates that the relative error in the
  144. C sum of squares is at most TOL.
  145. C
  146. C INFO = 2 algorithm estimates that the relative error between
  147. C X and the solution is at most TOL.
  148. C
  149. C INFO = 3 conditions for INFO = 1 and INFO = 2 both hold.
  150. C
  151. C INFO = 4 FVEC is orthogonal to the columns of the Jacobian to
  152. C machine precision.
  153. C
  154. C INFO = 5 number of calls to FCN has reached 100*(N+1)
  155. C for IOPT=2 or 3 or 200*(N+1) for IOPT=1.
  156. C
  157. C INFO = 6 TOL is too small. No further reduction in the sum
  158. C of squares is possible.
  159. C
  160. C INFO = 7 TOL is too small. No further improvement in the
  161. C approximate solution X is possible.
  162. C
  163. C Sections 4 and 5 contain more details about INFO.
  164. C
  165. C IW is an INTEGER work array of length N.
  166. C
  167. C WA is a work array of length LWA.
  168. C
  169. C LWA is a positive integer input variable not less than
  170. C N*(M+5)+M for IOPT=1 and 2 or N*(N+5)+M for IOPT=3.
  171. C
  172. C
  173. C 4. Successful Completion.
  174. C
  175. C The accuracy of SNLS1E is controlled by the convergence parame-
  176. C ter TOL. This parameter is used in tests which make three types
  177. C of comparisons between the approximation X and a solution XSOL.
  178. C SNLS1E terminates when any of the tests is satisfied. If TOL is
  179. C less than the machine precision (as defined by the function
  180. C R1MACH(4)), then SNLS1E only attempts to satisfy the test
  181. C defined by the machine precision. Further progress is not usu-
  182. C ally possible. Unless high precision solutions are required,
  183. C the recommended value for TOL is the square root of the machine
  184. C precision.
  185. C
  186. C The tests assume that the functions are reasonably well behaved,
  187. C and, if the Jacobian is supplied by the user, that the functions
  188. C and the Jacobian are coded consistently. If these conditions
  189. C are not satisfied, then SNLS1E may incorrectly indicate conver-
  190. C gence. If the Jacobian is coded correctly or IOPT=1,
  191. C then the validity of the answer can be checked, for example, by
  192. C rerunning SNLS1E with tighter tolerances.
  193. C
  194. C First Convergence Test. If ENORM(Z) denotes the Euclidean norm
  195. C of a vector Z, then this test attempts to guarantee that
  196. C
  197. C ENORM(FVEC) .LE. (1+TOL)*ENORM(FVECS),
  198. C
  199. C where FVECS denotes the functions evaluated at XSOL. If this
  200. C condition is satisfied with TOL = 10**(-K), then the final
  201. C residual norm ENORM(FVEC) has K significant decimal digits and
  202. C INFO is set to 1 (or to 3 if the second test is also satis-
  203. C fied).
  204. C
  205. C Second Convergence Test. If D is a diagonal matrix (implicitly
  206. C generated by SNLS1E) whose entries contain scale factors for
  207. C the variables, then this test attempts to guarantee that
  208. C
  209. C ENORM(D*(X-XSOL)) .LE. TOL*ENORM(D*XSOL).
  210. C
  211. C If this condition is satisfied with TOL = 10**(-K), then the
  212. C larger components of D*X have K significant decimal digits and
  213. C INFO is set to 2 (or to 3 if the first test is also satis-
  214. C fied). There is a danger that the smaller components of D*X
  215. C may have large relative errors, but the choice of D is such
  216. C that the accuracy of the components of X is usually related to
  217. C their sensitivity.
  218. C
  219. C Third Convergence Test. This test is satisfied when FVEC is
  220. C orthogonal to the columns of the Jacobian to machine preci-
  221. C sion. There is no clear relationship between this test and
  222. C the accuracy of SNLS1E, and furthermore, the test is equally
  223. C well satisfied at other critical points, namely maximizers and
  224. C saddle points. Therefore, termination caused by this test
  225. C (INFO = 4) should be examined carefully.
  226. C
  227. C
  228. C 5. Unsuccessful Completion.
  229. C
  230. C Unsuccessful termination of SNLS1E can be due to improper input
  231. C parameters, arithmetic interrupts, or an excessive number of
  232. C function evaluations.
  233. C
  234. C Improper Input Parameters. INFO is set to 0 if IOPT .LT. 1
  235. C or IOPT .GT. 3, or N .LE. 0, or M .LT. N, or TOL .LT. 0.E0,
  236. C or for IOPT=1 or 2 LWA .LT. N*(M+5)+M, or for IOPT=3
  237. C LWA .LT. N*(N+5)+M.
  238. C
  239. C Arithmetic Interrupts. If these interrupts occur in the FCN
  240. C subroutine during an early stage of the computation, they may
  241. C be caused by an unacceptable choice of X by SNLS1E. In this
  242. C case, it may be possible to remedy the situation by not evalu-
  243. C ating the functions here, but instead setting the components
  244. C of FVEC to numbers that exceed those in the initial FVEC.
  245. C
  246. C Excessive Number of Function Evaluations. If the number of
  247. C calls to FCN reaches 100*(N+1) for IOPT=2 or 3 or 200*(N+1)
  248. C for IOPT=1, then this indicates that the routine is converging
  249. C very slowly as measured by the progress of FVEC, and INFO is
  250. C set to 5. In this case, it may be helpful to restart SNLS1E,
  251. C thereby forcing it to disregard old (and possibly harmful)
  252. C information.
  253. C
  254. C
  255. C 6. Characteristics of the Algorithm.
  256. C
  257. C SNLS1E is a modification of the Levenberg-Marquardt algorithm.
  258. C Two of its main characteristics involve the proper use of
  259. C implicitly scaled variables and an optimal choice for the cor-
  260. C rection. The use of implicitly scaled variables achieves scale
  261. C invariance of SNLS1E and limits the size of the correction in
  262. C any direction where the functions are changing rapidly. The
  263. C optimal choice of the correction guarantees (under reasonable
  264. C conditions) global convergence from starting points far from the
  265. C solution and a fast rate of convergence for problems with small
  266. C residuals.
  267. C
  268. C Timing. The time required by SNLS1E to solve a given problem
  269. C depends on M and N, the behavior of the functions, the accu-
  270. C racy requested, and the starting point. The number of arith-
  271. C metic operations needed by SNLS1E is about N**3 to process
  272. C each evaluation of the functions (call to FCN) and to process
  273. C each evaluation of the Jacobian SNLS1E takes M*N**2 for IOPT=2
  274. C (one call to JAC), M*N**2 for IOPT=1 (N calls to FCN) and
  275. C 1.5*M*N**2 for IOPT=3 (M calls to FCN). Unless FCN
  276. C can be evaluated quickly, the timing of SNLS1E will be
  277. C strongly influenced by the time spent in FCN.
  278. C
  279. C Storage. SNLS1E requires (M*N + 2*M + 6*N) for IOPT=1 or 2 and
  280. C (N**2 + 2*M + 6*N) for IOPT=3 single precision storage
  281. C locations and N integer storage locations, in addition to
  282. C the storage required by the program. There are no internally
  283. C declared storage arrays.
  284. C
  285. C *Long Description:
  286. C
  287. C 7. Example.
  288. C
  289. C The problem is to determine the values of X(1), X(2), and X(3)
  290. C which provide the best fit (in the least squares sense) of
  291. C
  292. C X(1) + U(I)/(V(I)*X(2) + W(I)*X(3)), I = 1, 15
  293. C
  294. C to the data
  295. C
  296. C Y = (0.14,0.18,0.22,0.25,0.29,0.32,0.35,0.39,
  297. C 0.37,0.58,0.73,0.96,1.34,2.10,4.39),
  298. C
  299. C where U(I) = I, V(I) = 16 - I, and W(I) = MIN(U(I),V(I)). The
  300. C I-th component of FVEC is thus defined by
  301. C
  302. C Y(I) - (X(1) + U(I)/(V(I)*X(2) + W(I)*X(3))).
  303. C
  304. C **********
  305. C
  306. C PROGRAM TEST
  307. C C
  308. C C Driver for SNLS1E example.
  309. C C
  310. C INTEGER I,IOPT,M,N,NPRINT,JNFO,LWA,NWRITE
  311. C INTEGER IW(3)
  312. C REAL TOL,FNORM
  313. C REAL X(3),FVEC(15),WA(75)
  314. C REAL ENORM,R1MACH
  315. C EXTERNAL FCN
  316. C DATA NWRITE /6/
  317. C C
  318. C IOPT = 1
  319. C M = 15
  320. C N = 3
  321. C C
  322. C C The following starting values provide a rough fit.
  323. C C
  324. C X(1) = 1.E0
  325. C X(2) = 1.E0
  326. C X(3) = 1.E0
  327. C C
  328. C LWA = 75
  329. C NPRINT = 0
  330. C C
  331. C C Set TOL to the square root of the machine precision.
  332. C C Unless high precision solutions are required,
  333. C C this is the recommended setting.
  334. C C
  335. C TOL = SQRT(R1MACH(4))
  336. C C
  337. C CALL SNLS1E(FCN,IOPT,M,N,X,FVEC,TOL,NPRINT,
  338. C * INFO,IW,WA,LWA)
  339. C FNORM = ENORM(M,FVEC)
  340. C WRITE (NWRITE,1000) FNORM,INFO,(X(J),J=1,N)
  341. C STOP
  342. C 1000 FORMAT (5X,' FINAL L2 NORM OF THE RESIDUALS',E15.7 //
  343. C * 5X,' EXIT PARAMETER',16X,I10 //
  344. C * 5X,' FINAL APPROXIMATE SOLUTION' // 5X,3E15.7)
  345. C END
  346. C SUBROUTINE FCN(IFLAG,M,N,X,FVEC,DUM,IDUM)
  347. C C This is the form of the FCN routine if IOPT=1,
  348. C C that is, if the user does not calculate the Jacobian.
  349. C INTEGER M,N,IFLAG
  350. C REAL X(N),FVEC(M)
  351. C INTEGER I
  352. C REAL TMP1,TMP2,TMP3,TMP4
  353. C REAL Y(15)
  354. C DATA Y(1),Y(2),Y(3),Y(4),Y(5),Y(6),Y(7),Y(8),
  355. C * Y(9),Y(10),Y(11),Y(12),Y(13),Y(14),Y(15)
  356. C * /1.4E-1,1.8E-1,2.2E-1,2.5E-1,2.9E-1,3.2E-1,3.5E-1,3.9E-1,
  357. C * 3.7E-1,5.8E-1,7.3E-1,9.6E-1,1.34E0,2.1E0,4.39E0/
  358. C C
  359. C IF (IFLAG .NE. 0) GO TO 5
  360. C C
  361. C C Insert print statements here when NPRINT is positive.
  362. C C
  363. C RETURN
  364. C 5 CONTINUE
  365. C DO 10 I = 1, M
  366. C TMP1 = I
  367. C TMP2 = 16 - I
  368. C TMP3 = TMP1
  369. C IF (I .GT. 8) TMP3 = TMP2
  370. C FVEC(I) = Y(I) - (X(1) + TMP1/(X(2)*TMP2 + X(3)*TMP3))
  371. C 10 CONTINUE
  372. C RETURN
  373. C END
  374. C
  375. C
  376. C Results obtained with different compilers or machines
  377. C may be slightly different.
  378. C
  379. C FINAL L2 NORM OF THE RESIDUALS 0.9063596E-01
  380. C
  381. C EXIT PARAMETER 1
  382. C
  383. C FINAL APPROXIMATE SOLUTION
  384. C
  385. C 0.8241058E-01 0.1133037E+01 0.2343695E+01
  386. C
  387. C
  388. C For IOPT=2, FCN would be modified as follows to also
  389. C calculate the full Jacobian when IFLAG=2.
  390. C
  391. C SUBROUTINE FCN(IFLAG,M,N,X,FVEC,FJAC,LDFJAC)
  392. C C
  393. C C This is the form of the FCN routine if IOPT=2,
  394. C C that is, if the user calculates the full Jacobian.
  395. C C
  396. C INTEGER LDFJAC,M,N,IFLAG
  397. C REAL X(N),FVEC(M)
  398. C REAL FJAC(LDFJAC,N)
  399. C INTEGER I
  400. C REAL TMP1,TMP2,TMP3,TMP4
  401. C REAL Y(15)
  402. C DATA Y(1),Y(2),Y(3),Y(4),Y(5),Y(6),Y(7),Y(8),
  403. C * Y(9),Y(10),Y(11),Y(12),Y(13),Y(14),Y(15)
  404. C * /1.4E-1,1.8E-1,2.2E-1,2.5E-1,2.9E-1,3.2E-1,3.5E-1,3.9E-1,
  405. C * 3.7E-1,5.8E-1,7.3E-1,9.6E-1,1.34E0,2.1E0,4.39E0/
  406. C C
  407. C IF (IFLAG .NE. 0) GO TO 5
  408. C C
  409. C C Insert print statements here when NPRINT is positive.
  410. C C
  411. C RETURN
  412. C 5 CONTINUE
  413. C IF(IFLAG.NE.1) GO TO 20
  414. C DO 10 I = 1, M
  415. C TMP1 = I
  416. C TMP2 = 16 - I
  417. C TMP3 = TMP1
  418. C IF (I .GT. 8) TMP3 = TMP2
  419. C FVEC(I) = Y(I) - (X(1) + TMP1/(X(2)*TMP2 + X(3)*TMP3))
  420. C 10 CONTINUE
  421. C RETURN
  422. C C
  423. C C Below, calculate the full Jacobian.
  424. C C
  425. C 20 CONTINUE
  426. C C
  427. C DO 30 I = 1, M
  428. C TMP1 = I
  429. C TMP2 = 16 - I
  430. C TMP3 = TMP1
  431. C IF (I .GT. 8) TMP3 = TMP2
  432. C TMP4 = (X(2)*TMP2 + X(3)*TMP3)**2
  433. C FJAC(I,1) = -1.E0
  434. C FJAC(I,2) = TMP1*TMP2/TMP4
  435. C FJAC(I,3) = TMP1*TMP3/TMP4
  436. C 30 CONTINUE
  437. C RETURN
  438. C END
  439. C
  440. C
  441. C For IOPT = 3, FJAC would be dimensioned as FJAC(3,3),
  442. C LDFJAC would be set to 3, and FCN would be written as
  443. C follows to calculate a row of the Jacobian when IFLAG=3.
  444. C
  445. C SUBROUTINE FCN(IFLAG,M,N,X,FVEC,FJAC,LDFJAC)
  446. C C This is the form of the FCN routine if IOPT=3,
  447. C C that is, if the user calculates the Jacobian row by row.
  448. C INTEGER M,N,IFLAG
  449. C REAL X(N),FVEC(M)
  450. C REAL FJAC(N)
  451. C INTEGER I
  452. C REAL TMP1,TMP2,TMP3,TMP4
  453. C REAL Y(15)
  454. C DATA Y(1),Y(2),Y(3),Y(4),Y(5),Y(6),Y(7),Y(8),
  455. C * Y(9),Y(10),Y(11),Y(12),Y(13),Y(14),Y(15)
  456. C * /1.4E-1,1.8E-1,2.2E-1,2.5E-1,2.9E-1,3.2E-1,3.5E-1,3.9E-1,
  457. C * 3.7E-1,5.8E-1,7.3E-1,9.6E-1,1.34E0,2.1E0,4.39E0/
  458. C C
  459. C IF (IFLAG .NE. 0) GO TO 5
  460. C C
  461. C C Insert print statements here when NPRINT is positive.
  462. C C
  463. C RETURN
  464. C 5 CONTINUE
  465. C IF( IFLAG.NE.1) GO TO 20
  466. C DO 10 I = 1, M
  467. C TMP1 = I
  468. C TMP2 = 16 - I
  469. C TMP3 = TMP1
  470. C IF (I .GT. 8) TMP3 = TMP2
  471. C FVEC(I) = Y(I) - (X(1) + TMP1/(X(2)*TMP2 + X(3)*TMP3))
  472. C 10 CONTINUE
  473. C RETURN
  474. C C
  475. C C Below, calculate the LDFJAC-th row of the Jacobian.
  476. C C
  477. C 20 CONTINUE
  478. C
  479. C I = LDFJAC
  480. C TMP1 = I
  481. C TMP2 = 16 - I
  482. C TMP3 = TMP1
  483. C IF (I .GT. 8) TMP3 = TMP2
  484. C TMP4 = (X(2)*TMP2 + X(3)*TMP3)**2
  485. C FJAC(1) = -1.E0
  486. C FJAC(2) = TMP1*TMP2/TMP4
  487. C FJAC(3) = TMP1*TMP3/TMP4
  488. C RETURN
  489. C END
  490. C
  491. C***REFERENCES Jorge J. More, The Levenberg-Marquardt algorithm:
  492. C implementation and theory. In Numerical Analysis
  493. C Proceedings (Dundee, June 28 - July 1, 1977, G. A.
  494. C Watson, Editor), Lecture Notes in Mathematics 630,
  495. C Springer-Verlag, 1978.
  496. C***ROUTINES CALLED SNLS1, XERMSG
  497. C***REVISION HISTORY (YYMMDD)
  498. C 800301 DATE WRITTEN
  499. C 890206 REVISION DATE from Version 3.2
  500. C 891214 Prologue converted to Version 4.0 format. (BAB)
  501. C 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
  502. C 920501 Reformatted the REFERENCES section. (WRB)
  503. C***END PROLOGUE SNLS1E
  504. INTEGER M,N,NPRINT,INFO,LWA,IOPT
  505. INTEGER INDEX,IW(*)
  506. REAL TOL
  507. REAL X(*),FVEC(*),WA(*)
  508. EXTERNAL FCN
  509. INTEGER MAXFEV,MODE,NFEV,NJEV
  510. REAL FACTOR,FTOL,GTOL,XTOL,ZERO,EPSFCN
  511. SAVE FACTOR, ZERO
  512. DATA FACTOR,ZERO /1.0E2,0.0E0/
  513. C***FIRST EXECUTABLE STATEMENT SNLS1E
  514. INFO = 0
  515. C
  516. C CHECK THE INPUT PARAMETERS FOR ERRORS.
  517. C
  518. IF (IOPT .LT. 1 .OR. IOPT .GT. 3 .OR.
  519. 1 N .LE. 0 .OR. M .LT. N .OR. TOL .LT. ZERO
  520. 2 .OR. LWA .LT. N*(N+5) + M) GO TO 10
  521. IF (IOPT .LT. 3 .AND. LWA .LT. N*(M+5) + M) GO TO 10
  522. C
  523. C CALL SNLS1.
  524. C
  525. MAXFEV = 100*(N + 1)
  526. IF (IOPT .EQ. 1) MAXFEV = 2*MAXFEV
  527. FTOL = TOL
  528. XTOL = TOL
  529. GTOL = ZERO
  530. EPSFCN = ZERO
  531. MODE = 1
  532. INDEX = 5*N+M
  533. CALL SNLS1(FCN,IOPT,M,N,X,FVEC,WA(INDEX+1),M,FTOL,XTOL,GTOL,
  534. 1 MAXFEV,EPSFCN,WA(1),MODE,FACTOR,NPRINT,INFO,NFEV,NJEV,
  535. 2 IW,WA(N+1),WA(2*N+1),WA(3*N+1),WA(4*N+1),WA(5*N+1))
  536. IF (INFO .EQ. 8) INFO = 4
  537. 10 CONTINUE
  538. IF (INFO .EQ. 0) CALL XERMSG ('SLATEC', 'SNLS1E',
  539. + 'INVALID INPUT PARAMETER.', 2, 1)
  540. RETURN
  541. C
  542. C LAST CARD OF SUBROUTINE SNLS1E.
  543. C
  544. END