chap09/kadai2.f90

サンプルコードのダウンロード

 1module mod_const
 2  implicit none
 3
 4  real(8), parameter :: pi = 4.0_8 * atan(1.0_8)
 5  real(8), parameter :: sqrtpi = sqrt(pi)
 6  real(8), parameter :: e = exp(1.0_8)
 7  real(8), parameter :: log2 = log10(2.0_8)
 8
 9endmodule mod_const
10
11program answer
12  use mod_const
13  !use mod_const, only: pi
14  !use mod_const, only: e => log2
15  implicit none
16
17  write(*, '(a20, ":", e12.4)') 'pi', pi
18  write(*, '(a20, ":", e12.4)') 'sqrt(pi)', sqrtpi
19  write(*, '(a20, ":", e12.4)') 'e', e
20  write(*, '(a20, ":", e12.4)') 'log10(2)', log2
21
22  stop
23endprogram answer