flang f18
llvm 11 を試すつもりで llvm 11 一式のバイナリを落としてきましたが、flang が入っておらず、仕方が無いのでソースから build しようと思ったら llvm がらみのあれこれが足りぬと叱られるので、llvm 一式ソースから作るかと指示通りに git clone してコンパイルしてみたら、もう llvm 12 系統に入れ替わっていて flang 12 が出来てしまいましたw 出鼻をくじかれてやる気なくした!
https://llvm.org/docs/GettingStarted.html#checkout
なお f18 などは文法チェックの上、入力を大文字の Fortran プログラムに直して画面に吐き出してくれるます。大きいことはいいことだ!
文法対応状況
付属の test 集を実行させると、まだエラーが少し出るようです。
私が試したところ Fortran 2018 の import, none は対応しているようですが、Fortran 2008 の pointer function はまだ未対応のようです。左辺に関数は来ないという単なる文法エラーを出します。まだこの二つしか見ていません。Finalizer や parameterized derived type もどうなのか知りたいところです。
まだ intel の方が文法対応状況が良い気がします。そのインテルもコンパイラを llvm 化していますが・・・
import, none は OK
Enter Fortran source Use EOF character (^D) to end file implicit none integer :: i = 1 block import, none integer :: i = 2 print *, i end block end Parse tree comprises 120 objects and occupies 10033 total bytes. IMPLICIT NONE INTEGER :: i = 1_4 BLOCK IMPORT, NONE INTEGER :: i = 2_4 PRINT *, i END BLOCK END PROGRAM
Enter Fortran source Use EOF character (^D) to end file implicit none integer :: i = 1 block import, none print *, i end block end Parse tree comprises 92 objects and occupies 7857 total bytes. standard input:6:13: error: No explicit type declared for 'i' print *, i ^ f18: semantic errors in -
pointer function は NG
変数っぽく扱える pointer function - fortran66のブログ
module m_sub implicit none contains function storage(key) result(loc) integer, intent(in) :: key integer, pointer :: loc integer, target :: m(100) = 0 loc => m(key) end function storage end module m_sub program Console2 use m_sub implicit none integer :: i do i = 1, 10 storage(i) = i**2 end do do i = 1, 10 print *, storage(i) end do end program Console2 Parse tree comprises 403 objects and occupies 32812 total bytes. standard input:17:9: error: Left-hand side of assignment is not modifiable storage(i) = i**2 ^^^^^^^^^^ standard input:17:9: Expression is not a variable storage(i) = i**2 ^^^^^^^^^^ f18: semantic errors in -
ポインター関数の使用例 fortran66.hatenablog.com

Modern Fortran: Building efficient parallel applications
- 作者:Curcic, Milan
- 発売日: 2020/11/24
- メディア: ペーパーバック

How to learn Applied Mathematics through modern FORTRAN
- 作者:Hernandez Ramos, Juan Antonio,Escoto Lopez, Javier
- 発売日: 2020/02/23
- メディア: ペーパーバック