fortran66のブログ

fortran について書きます。

【メモ帳】Fortran90 に pointer と allocatable が重複してある理由

John K. Reid の講演より

fortran66.hatenablog.com

19 分からの発言 https://youtu.be/Frz_AF46a04?t=1138

Allocatables
When we were working with fortran90, the proposer for pointers tried to convince us that once we've got pointers in the language, we did't need allocatable arrays. But the argument was made that all these old-fashioned people who are using old FORTRAN would never understand pointers, never be able to use them successfully. What was needed was memory that was just dynamic, so what we put in the language was simply, the simplest case of all, allocatable arrays that could be allocated anew????? 云々

ということで、昔気質のおじちゃん達にはポインタは難しくてちゃんと使えなかろうから、極言すれば欲しいのは実行時の動的メモリー確保なのだから、動的メモリー確保機能のみに特化してメモリーリークが起きにくいように制限をきつくした allocatable 型を用意したようです。

Fortran90 の時点では、allocatable 型はサブルーチンを出る時などに自動解放されなかったので、return 前に手動で解放しなければ メモリーリークした上でその先使用不能になるという、pointer と大して変わらない厄介さでしたが、Fortran95 以降では自動解放機能がついて安全性が高まってゆきました。move_alloc と合わせて、最近のスマート・ポインタを先取りしていたとほざいておきましょう。

f:id:fortran66:20190523020539p:plain
JKR

Modern Fortran, with emphasis on coarrays (John Reid, JKR Associates/Rutherford Appleton Laboratory)

講演の前後の司会のいい声は Damian Rouson ではないかと思われます。

なお JK Reid ですが、女子高生 Reid と妄想するとはかどります。

Modern Fortran Explained: Incorporating Fortran 2018 (Numerical Mathematics and Scientific Computation)

Modern Fortran Explained: Incorporating Fortran 2018 (Numerical Mathematics and Scientific Computation)

Introduction to Programming with Fortran

Introduction to Programming with Fortran