module arquivo

use variaveis
use portlib

implicit none

integer :: ver

contains

!-----------------------------------
subroutine entrada

ver = system('notepad entrada.txt')

open(3,file='entrada.txt')

read(3,*) y
read(3,*) n

close(3)

end subroutine entrada

!-----------------------------------

subroutine saida

open(5,file='saida.txt')

write(5,1) y,x,n
write(5,2)

do i = 1, n
	write(5,3) i, c(i)
end do

write(5,4) dcos(x),soma

close(5)

ver = system('notepad saida.txt')

1 format('ângulo em graus',   t20, 1pe15.4, /, &
         'ângulo em radianos',t20, 1pe15.4, /, &
		 'número de termos',  t20, i4 )
2 format(t2,'termo', t15, 'valor')
3 format(i4, t6, 1pe24.15 )
4 format('cosseno de x',       t20, 1pe24.15, /, &
         'cosseno aproximado', t20, 1pe24.15 )

end subroutine saida

!-----------------------------------

end module arquivo