chap06/kadai5.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='helix2.dat', action='read', &
 9       & form='unformatted', status='old')
10
11  if(ios /= 0) then
12    write(*, *) 'Failed to open file'
13    stop
14  endif
15
16  read(10) x
17  read(10) y
18  read(10) z
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