1
subroutine optml2(feq,jacl2,neq,q,nch,w,iw)
3
C Routine de recherche de minimum du probleme d'approximation L2
4
C par lsoda ( Lsoda = routine de resolution d'equa diff )
6
C subroutine optml2(feq,jacl2,neq,q,nch,w,iw)
9
C double precision q(*),w(*)
13
C - feq est la subroutine qui calcule le gradient,
14
C oppose de la derivee premiere de la fonction phi.
15
c - neq. tableau entier de taille 3+(npara+1)*(npara+2)
16
c neq(1)=nq est le degre effectif du polynome q.
17
c neq(2)=ng est le nombre de coefficient de fourier
18
c neq(3)=dgmax degre maximum pour q (l'adresse des coeff de fourier dans
20
C - neq est le degre du polynome q
21
c - tq. tableau reel de taille au moins
22
c 6+dgmax+5*nq+6*ng+nq*ng+nq**2*(ng+1)
23
c tq(1:nq+1) est le tableau des coefficients du polynome q.
24
c tq(dgmax+2:dgmax+ng+2) est le tableau des coefficients
26
c tq(dgmax+ng+3:) est un tableau de travail de taille au moins
27
c 5+5*nq+5*ng+nq*ng+nq**2*(ng+1)
28
C - nch est l indice (valant 1 ou 2) qui classifie l
29
C appel comme etant soit celui de la recherche et de la
30
C localisation d un minimum local, soit de la
31
C confirmation d un minimum local.
34
C - neq est toujours le degre du polynome q (il peut avoir varie).
35
C - q est le polynome (ou plutot le tableau contenant
36
C ses coefficients) qui resulte de la recherche ,il peut
37
C etre du meme degre que le polynome initial mais aussi
38
C de degre inferieur dans le cas d'une sortie de face.
41
C - w de taille 25+26*nq+ng+nq**2
42
C - iw de taille 20+nq
45
implicit double precision (a-h,o-y)
46
dimension q(*), w(*), iw(*), xx(1)
48
double precision x,phi0,phi,gnrm
52
common /comall/ nall1 /sortie/ io,info,ll
59
c taille des tableaux de travail necessaires a lsode
60
lrw = nq**2 + 9*nq + 22
63
C decoupage du tableau de travail w
69
lfree = lwork + 24+22*nq+ng+nq**2
73
C decoupage du tableau de travail iw
79
C --- Initialisation de lsode ------------------------
81
if (nch .eq. 1) t = 0.0d+0
88
ntol = int((nq-1)/3) + 5
90
ntol = int((nq-7)/2) + 7
92
call dset(nq,10.0d+0**(-(ntol)),w(lrtol),1)
93
call dset(nq,10.0d+0**(-(ntol+2)),w(latol),1)
96
if (nch .eq. 1) istate = 1
97
if (nch .eq. 2) istate = 3
101
C --- Initialisation du nombre maximal d'iteration ---
105
nlsode = 11 + 2*(nq-1)
115
C --- Appel de lsode --------------------------------
117
210 do 290 i = 1,nlsode
119
220 ilcom = ilcom + 1
121
C -- Reinitialisation de la Tolerance --
123
if (ilcom.eq.2 .and. nch.eq.1) then
124
call dset(nq,1.0d-05,w(lrtol),1)
125
call dset(nq,1.0d-07,w(latol),1)
127
elseif (ilcom.eq.2 .and. nch.eq.2) then
132
w(lrtol+nq-1) = 1.0d-05
133
w(latol+nq-1) = 1.0d-07
141
C --------------------------------------
143
call dcopy(nq+1,q,1,w(lqi),1)
147
if (info .gt. 1) call outl2(30,nq,nq,q,xx,t,tout)
150
call lsode(feq,neq,q,t,tout,itol,w(lrtol),w(latol),itask,
151
& istate,iopt,w(lwork),lrw,iw(liww),liw,jacl2,mf)
153
call front(nq,q,nbout,w(lw))
155
call feq(neq,t,q,w(lqdot))
156
dnorm0 = dnrm2(nq,w(lqdot),1)
157
if (info .gt. 1) call outl2(31,nq,nbout,q,dnorm0,t,tout)
159
C -- test pour degre1 -----------
160
if (nall1.gt.0 .and. nq.eq.1 .and. nbout.gt.0) return
163
C -- Istate de lsode ------------
165
if (istate .eq. -5) then
166
if (info .gt. 0) call outl2(32,nq,nq,xx,xx,x,x)
167
call dscal(nq,0.10d+0,w(lrtol),1)
168
call dscal(nq,0.10d+0,w(latol),1)
169
if (t .eq. 0.0d+0) istate = 1
170
if (t .ne. 0.0d+0) istate = 3
175
if (istate .eq. -6) then
176
C echec de l'integration appel avec de nouvelles tolerances
177
if (info .gt. 0) call outl2(33,nq,nq,xx,xx,x,x)
179
& call outl2(34,nq,itol,w(latol),w(lrtol),t,tout)
182
call dset(nq,0.10d-05,w(lrtol),1)
183
call dset(nq,0.10d-05,w(latol),1)
184
if (info .gt. 1) call outl2(35,nq,itol,w(latol),w(lrtol),x,x)
185
if (info .gt. 0) call outl2(36,nq,nq,xx,xx,x,x)
187
if (t .ne. tout) goto 220
190
if (istate.lt.-1 .and. istate.ne.-6 .and. istate.ne.-5) then
191
if (info .gt. 0) call outl2(37,nq,iopt,xx,xx,x,x)
196
C -------------------------------
198
C -- Sortie de face -------------
200
if (nbout.gt.0 .and. nbout.ne.99) then
201
call domout(neq,q,w(lqi),nbout,ti,t,itol,w(lrtol),
202
& w(latol),itask,istate,iopt,w(lwork),lrw,iw(liww),liw,
205
if (job .eq. -1) then
206
C anomalie dans la recherche de l'intersection
216
C -------------------------------
218
C -- test sur le gradient -------
220
epstop = (1.0d-06)**nch
221
call feq(neq,t,q,w(lqdot))
222
dnorm0 = dnrm2(nq,w(lqdot),1)
223
if (dnorm0 .lt. epstop) goto 299
225
C -------------------------------
227
C -- Istate de lsode (suite) ----
229
if (istate.eq.-1 .and. t.ne.tout) then
230
if (info .gt. 0) call outl2(38,nq,nq,xx,xx,x,x)
235
C -------------------------------
237
tt = sqrt(10.0d+0) * tt
242
if (nch.eq.2 .and. dnorm0.gt.(1.0d-06)) then
244
if (ipass .lt. 5) then
245
if (info .gt. 0) then
246
call lq(nq,q,w(lw),q(ltg),ng)
248
call dscal(nq,x,w(lw),1)
249
call outl2(14,nq,nq,q,w(lw),x,x)
251
phi0= abs(phi(q,nq,q(ltg),ng,w(lw)))
252
call feq(neq,t,q,w(lqdot))
253
call outl2(17,nq,nq,q,w(lqdot),phi0,x)
257
if (info .gt. 0) call outl2(39,nq,nq,xx,xx,x,x)