Fortranを学ぶ

  • Manjaro linuxを入れたので、その上でFortranを使ってみよう

C&Fortran による数値計算プログラミング入門 改訂版

C&Fortran による数値計算プログラミング入門 改訂版

c---+----1----+----2----+----3----+----4----+----5----+----6----+-
      program calc
c
      integer Number1, Number2
      integer Sum, Diff, Multiply, Div, Power
c
      write(6,*) ' Input the Number 1:'
      read(5,*) Number1
      write(6,*) 'Input the Number 2:'
      read(5,*) Number2
c
      Sum =Number1 + Number2
      Diff = Number1 - Number2
      Multiply = Number1 * Number2
      Div = Number1 / Number2
      Power = Number1 ** Number2
c
      write(6,*) Number1, ' + ' , Number2, ' = ', Sum
      write(6,*) Number1, ' - ' , Number2, ' = ', Diff
      write(6,*) Number1, ' * ' , Number2, ' = ', Multiply
      write(6,*) Number1, ' / ' , Number2, ' = ', Div
      write(6,*) Number1, ' ** ' , Number2, ' = ', Power
c
      stop
      end
gfortran myprogram.f
./a.out
c---+----1----+----2----+----3----+----4----+----5----+----6----+-
      program main
      complex x,y
      write(6,*) 'Input x:'
      read(5,*) x
      write(6,*) 'Input y:'
      read(5,*) y
      write(6,*) 'x**y=', x**y
      stop
      end