! Test pt. ALL, ANY, COUNT
use dflib

real,allocatable :: x(:)
integer, allocatable :: ix(:)

logical any_gr_10, all_gr_10

integer imax(1), imin(1)

character(100) name, fname
logical pressed


!n =20

write(*,*) ' Introdu ordin tablou:'
read(*,*) n


allocate(x(n), ix(n))

call RANDOM_SEED()
call RANDOM_NUMBER(x)


write(*,*) ' Introdu nume fisier de rezultate (fara extensie):'
read(*,*) name


fname =trim(name)//'.rez'

open(1, file =fname, status ='unknown', form ='formatted')

!*
write(1, '(a)') ' x:'
do i =1,n
write(1,*) i, x(i)
enddo
!*

x =100*x
ix =nint(x)

deallocate(x)

write(1, '(/, a)') ' ix:'
do i =1,n
write(1,*) i, ix(i)
enddo

ixmax =maxval(ix)
imax =maxloc(ix)

ixmin =minval(ix)
imin =minloc(ix)

write(1,'(/, a, \)') ' ix Maxim (Loc; Max):'
write(1,*) imax, ixmax

write(1,'(/, a, \)') ' ix Minim (Loc; Min):'
write(1,*) imin, ixmin


! Any, etc.:

any_gr_10 =any(ix >10)

write(1,'(/, a, \)') ' ANY ix > 10:'
write(1,*) any_gr_10


all_gr_10 =all(ix >10)
write(1,'(/, a, \)') ' ALL ix > 10:'
write(1,*) all_gr_10

icount_lt_10 =count(ix <10)

write(1, '(/, a, \)') ' COUNT ix < 10:'
write(1,*) icount_lt_10

icount_gt_10 =count(ix >10)

write(1, '(/, a, \)') ' COUNT ix > 10:'
write(1,*) icount_gt_10

!icount_10 =count(ix ==10 .or. ix ==20)
icount_10 =count(mod(ix,10) ==0)

!write(1, '(/, a, \)') ' COUNT ix = 10 OR ix = 20:'
write(1, '(/, a, \)') ' COUNT ix divizibil cu 10:'
write(1,*) icount_10


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

!WRITE(*, '(//, a)') ' Apasa orice tasta pentru iesire'

!DO WHILE (.NOT. pressed)

!pressed = PEEKCHARQQ ( )

!END DO


END

