Program Met_Muller_IMSL
! Main for 'muller'
use IMSL

external f	!, zanly

character(80) text(0:2)
character(1) w
logical new_root, exist_p
character(260) fname0, fname
integer width
common p

integer info(3)
complex f, zinit(3), rad(3)


10 format(a, \)

print 10,' Functia f(x) include parametrul "p" (Y / char) ?: '
read'(a)',w
exist_p =(w =='Y' .or. w =='y')

if(exist_p) then
print 10,' p=? : '
read*,p
endif

print 10, ' Nume fisier rezultate (Fara extensie): '
read *, fname0
fname =trim(fname0)//'.rez'
open(1, file =fname, form ='formatted', status ='unknown')

write(1, '(a,/)') ' Metoda MULLER'
if(exist_p) then
write(1,*) 'p:', p
endif


! Input values:
100 print 10,' Numar de radacini: '
read *, nrad

print 10, ' Aproximatii initiale: '
read*, zinit(1:nrad)

! Test if any input is a root:

! Input values:
print 10,' eps, lnit: '
read *, eps, lnit

!print 10, ' Introdu cod de tiparire iteratii (0/#0): '
!read *, ktip


write(1,*) 'Aproximatii initiale:', zinit(1:nrad)

iwlnit =width(lnit)
write(1, '(a, 1pG10.3, a, I<iwlnit>)') ' EPS:', EPS, '; LNIT: ', lnit

! Subroutine call:
errel =eps
nknown =0
nnew =nrad

!call muller(f, x0, x1, x2, eps, iter, rad, kod)

call ZANLY(f, eps, errel, nknown, nnew, nguess, zinit(1:nrad), lnit, rad, info)

200 continue
! Output values:
iwnrad =width(nrad)
iwlnit =width(lnit)

write(1, '(/, a)') ' Radacini:'
do ir =1, nrad
write(1, '(1x, I<iwnrad>, a2, \)') ir, ': '
write(1,*) rad(ir)
enddo

write(1, '(/, a)') ' Numar de iteratii:'

do ir =1, nrad
write(1, '(1x, I<iwnrad>, a2, I<iwlnit>)'), ir, ': ', info(ir)
enddo

write(1, '(/, a)') ' f(Radacina):'
do ir =1, nrad
write(1, '(1x, I<iwnrad>, a2, \)') ir, ': '
write(1,*) f(rad(ir))
enddo

close(1)

print '(/, a, a, /)', ' * Fisier de rezultate: ', trim(fname)

END program Met_Muller_IMSL
