chap06/kadai3.f90
1program answer
2 implicit none
3
4 integer, parameter :: n = 32
5 integer :: i, ios
6 real(8) :: x(n), y(n), z(n)
7
8 open(unit=10, iostat=ios, file='helix1.dat', action='read', &
9 & form='formatted', status='old')
10
11 if(ios /= 0) then
12 write(*, *) 'Failed to open a file'
13 stop
14 endif
15
16 do i = 1, n
17 read(10, *) x(i), y(i), z(i)
18 enddo
19
20 close(10)
21
22 do i = 1, n
23 write(*, '(f5.2, 1x, f5.2, 1x, f5.2)') x(i), y(i), z(i)
24 enddo
25
26 stop
27endprogram answer