fortran66のブログ

fortran について書きます。

【メモ帳】bit の Fortran 規格関連記事

bit 共立出版のコンピュータ雑誌 2001年廃刊

bit の表紙と目次をスキャンしているページがあります。
Server error

Fortran 規格関連記事

  1. 1971年 4月号68頁 JIS FORTRAN と ALGOL の改定        菅忠義
  2. 1972年 2月号41頁 JIS FORTRAN と ALGOL の改正        菅忠義
  3. 1974年 5月号73頁 JIS FORTRAN と ALGOL の改正について    菅忠義
  4. 1977年 6月号44頁 アメリカ規格 FORTRAN の改訂       西村恕彦
  5. 1978年 9月号10頁 BASIC,FORTRAN,・・・             西村恕彦
  6. 1982年 7月号30頁 JIS FORTRANの改正  FORTRAN77 の JIS 化  菅忠義
  7. 1985年12月号 8頁 FORTRAN 8Xの紹介             菅忠義
  8. 1993年12月号23頁 Fortran 90 の概要              高田正之
  9. 1996年12月号12頁 Fortran95――次期 Fortran 規格の概要     高田正之

(改定・改正・改訂は原文ママ

その他

計算機よもやま話

  • 1977年 3月号 FORTRAN はいつ亡びるか? -第1回-   木村泉
  • 1977年 4月号 FORTRAN はいつ亡びるか? -第2回-   木村泉
  • 1977年 5月号 FORTRAN はいつ亡びるか? -第3回-   木村泉
  • 1977年 6月号 FORTRAN はいつ亡びるか?  -完-     木村泉

冗漫で無価値

Modern Fortran Explained (Numerical Mathematics and Scientific Computation)

Modern Fortran Explained (Numerical Mathematics and Scientific Computation)

  • 作者: Michael Metcalf,John Reid,Malcolm Cohen
  • 出版社/メーカー: Oxford University Press, U.S.A.
  • 発売日: 2011/05/08
  • メディア: ペーパーバック
  • この商品を含むブログを見る
Modern Fortran: Style and Usage

Modern Fortran: Style and Usage

Modern Fortran in Practice

Modern Fortran in Practice

Introduction to Modern Fortran for the Earth System Sciences (Springerbriefs in Earth System Sciences)

Introduction to Modern Fortran for the Earth System Sciences (Springerbriefs in Earth System Sciences)

Numerical Computing with Modern Fortran (Applied Mathematics)

Numerical Computing with Modern Fortran (Applied Mathematics)

メモ帳:goto controversy 特集号

goto論争


bit vol.7 (1975) 5.
ダイクストラの手紙の日本語訳、および米学会でのパネルディスカッションの講演・質疑の日本語訳、編者による参考資料が載っています。

参考資料部分では、BLOCK-IF や CASE、WHILE, REPEAT-UNTIL 構文などが「比較的目新しい構文」とされて解説されています。


下記の ACM 電子版では質疑の部分が欠けているようです。

ACM SIGPLAN Notices - Special issue on control structures in programming languages
Volume 7 Issue 11, November 1972
ACM SIGPLAN Notices - Special issue on control structures in programming languages

Control structures in programming languages - Part II (Panel Session): “The GOTO controversy”
Control structures in programming languages - Part II (Panel Session)

バッカス関数型言語 FP について語っていますw

f:id:fortran66:20170922021557p:plain
f:id:fortran66:20170923011053p:plain

Guide to Fortran 2008 Programming

Guide to Fortran 2008 Programming

Introduction to Programming with Fortran: With Coverage of Fortran 90, 95, 2003, 2008 and 77

Introduction to Programming with Fortran: With Coverage of Fortran 90, 95, 2003, 2008 and 77

Intel Fortran Ver.18 出る!

Intel Fortran v.18.0  2018

ベータ版を配っていた Intel Fortran v.18 が正式版となってリリースされました。

coarray を少しいじってみましたが、なかなか思い通りに使えません。あびゃー


メモ帳

イメージ1番が、任意の順番で来るイメージ2以降に、先着順に着順を与えるプログラムを書きました。本当は先着1名様に景品を与え、2番目以降には豪華粗品を与えるプログラムを書きたかったのですが、難航したので番号で。

実行結果

           1           0
           2           5
           3           6
           4           3
           7           4
           8           7
           6           1
           5           2

  0
  6
  5
  4
  7
  2
  3
  8
  1
  2 text from 1           5
  3 text from 1           6
  4 text from 1           3
  5 text from 1           2
  6 text from 1           1
  7 text from 1           4
  8 text from 1           7
続行するには何かキーを押してください . . .

ソース・プログラム

critical でも lock でもいいが、critical 中では sync 等が使えない。イメージ1側のループでは、sync memory がないとうまくゆかない。

    program caflock
      use, intrinsic :: iso_fortran_env 
      implicit none
      type(lock_type) :: lock[*]
      integer :: i = 1, me, ne, no = 0, nn[*] = 0
      integer, allocatable :: mm(:)[:]
      character(len = 80) :: text[*], buff
      me = this_image()
      ne = num_images()
      allocate(mm(ne)[*]) ! implicitly sync all
      if (me /= 1) then
        critical
!         lock(lock[1])   
          no = nn[1] + 1
          nn[1] = no
          mm(no + 1)[1] = me
!         unlock(lock[1]) 
        end critical
      else
        do
          sync memory  
          if (nn >= i) then
            if (mm(i + 1) == 0) cycle
            write(buff, *) 'text from 1', i  
            i = i + 1
            text[mm(i)] = buff
          end if  
          sync memory
          if (i == ne) exit  
        end do
      end if    
      sync all
      print *, me, no   
      sync all
      if (me == 1) print '(/(i3))', mm
      if (me > 1) sync images(me - 1)
        print '(i3, a)', me, trim(text)
      if (me < ne) sync images(me + 1)
    end program caflock

メモ帳: OpenCoarrays インストール

bash on windows に OpenCoarrays インストール

OpenCoarrays + gfortran の組み合わせで、Fortran 2015 での coarray 拡張機能が使えるようなので、試してみます。


github.com

ここの Installation Script の項目に従って実行した。
問題点は、デフォルトの gcc/gfortran のバージョンが 5.2 で古すぎて、コンパイルできないこと。したがって、バージョン6の gcc/gfortran を入れてから、これを使うように指示して make する。

下準備

適当に

sudo apt install gcc-6
sudo apt install g++-6
sudo apt gfortran-6

本番

適当なディレクトリにソースを取ってきて展開。

git clone https://github.com/sourceryinstitute/OpenCoarrays
cd OpenCoarrays
./install.sh -j 4 -c gcc-6 -C g++-6 -f gfortran-6

  • j 4 は4スレッドで実行のこと。スレッドを増やすと早い。

インストール

できたバイナリをパスの効いたところへコピー。(スクリプトのオプションでも行ける。)

cd prerequisites/installations/opencoarrays/
cp -R * /usr/opt

細部は忘れたので、間違ってたらゴメンw

実行

ソース・プログラム

リダクション演算が入りました。

      program test
        implicit none
        integer ::  m[*]
        m = this_image()
        print *, m
        call co_sum(m, result_image = 1)
        if (this_image() == 1) then
          print *, 'sum=', m
        end if
      end program test

コンパイル&実行

O@VM10:~$ caf coa.f90
O@VM10:~$ cafrun -n 10 ./a.out
           4
           6
           8
           2
           5
           7
           9
          10
           1
 sum=          55
           3
O@VM10:~$

ソース・プログラム

      module m_caf2
        implicit none
      contains
        pure integer function mul(ia, ib)
          integer, intent(in) :: ia, ib
          mul = ia * ib
        end function mul
      end module m_caf2

      program caf2
        use m_caf2
        implicit none
        integer :: m[*]
        m = this_image()
        call co_min(m, result_image = 1)
        if (this_image() == 1) print *, m

        sync all
        call co_broadcast(m, source_image = num_images())
        m = m / num_images()
        sync all
        call co_sum(m, result_image = 1)
        if (this_image() == 1) print *, m

        sync all
        m = this_image()
        call co_reduce(m, mul, result_image = 1)
        if (this_image() == 1) print *, m
      end program caf2

実行結果

O@VM10:~$ caf coa2.f90
O@VM10:~$ cafrun -n 4 ./a.out
           1
           4
          24

メモ帳 flang llvm 解説記事

斯様な記事が出ていますが、コンパイラドライバの解説のようで煩雑です。

Walk-through flang – Part 1 | Think In Geek
Walk-through flang – Part 2 | Think In Geek
Walk-through flang – Part 3 | Think In Geek
Walk-through flang – Part 4 | Think In Geek

flang 実行例

github.com

flang では、代入時の reallocation は、F95 的振る舞いがデフォルト設定のようです。自動 reallocation のためには -Mallocatable=03 のオプションが必要です。 

プログラム例

パスカルの三角形の偶奇性によりシェルピンスキーの三角形を書きます。

    program pascal
      implicit none
      integer, parameter :: n = 32
      integer, allocatable :: pas(:)
      integer :: i
      character (len = 132) :: fmt
      pas = [1]
      do i = 1, n
        write(fmt, *) '(t', n - i + 1, ', *(i2))'
        print fmt, mod(pas, 2)
        pas = [pas, 0] + [0, pas]
      end do
    end program pascal
O@VM10:~$ flang -Mallocatable=03 pascal.f90
O@VM10:~$ ./a.out
                                1
                               1 1
                              1 0 1
                             1 1 1 1
                            1 0 0 0 1
                           1 1 0 0 1 1
                          1 0 1 0 1 0 1
                         1 1 1 1 1 1 1 1
                        1 0 0 0 0 0 0 0 1
                       1 1 0 0 0 0 0 0 1 1
                      1 0 1 0 0 0 0 0 1 0 1
                     1 1 1 1 0 0 0 0 1 1 1 1
                    1 0 0 0 1 0 0 0 1 0 0 0 1
                   1 1 0 0 1 1 0 0 1 1 0 0 1 1
                  1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
                 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
                1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
               1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1
              1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1
             1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1
            1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1
           1 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 1
          1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1
         1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
        1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1
       1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1
      1 0 1 0 0 0 0 0 1 0 1 0 0 0 0 0 1 0 1 0 0 0 0 0 1 0 1
     1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
    1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1
   1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1
  1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

予言によると Fortran 滅亡は 2077 年!

Programming Language Born Expected Death
Go 2009 2025
C# 2000 2034
Java 1995 2039
Python 1991 2043
Haskell 1990 2044
C 1972 2062
Lisp 1959 2075
FORTRAN 1954 2077

jaxenter.com

Lindy Effect という、今後の余命はこれまでの年齢に比例するという仮定により見積もった、各言語の寿命予測による滅亡の予言のようです。

余りにガバガバな仮定ですが、これによると Fortran は干支二回り120年もつようです。

メモ帳:LINK集

並列コンピュータの歴史

www.hpjava.org

簡潔で易しい。

archive of Thinking Machines Connection Machine CM-5 manuals and documents

Index of /bradley/cm5docs
Bradley C. Kuszmaul

Parallel Computing Works

Parallel Computing Works!

Parallel Computing Works!

Parallel Computing Works


その他

Fortran Specialist Group Annual General Meeting 2016

BCS Fortran Specialist Group Annual General Meeting 2016 Agenda

Fortran At 60 Still Going Strong (2016)

www.i-programmer.info

きん注

www.youtube.com