このコードは、Intel と GNU の下で問題なくコンパイルおよび実行されます。
program simplarray
implicit none
real, allocatable, dimension(:,:,:) :: a
character(len=32) :: cmdarg
integer :: n = 0
call get_command_argument(1, cmdarg)
read(cmdarg,'(i)') n
print '("n=",i5)', n
call flush(6)
allocate(a(n,n,2))
print '("a is dimensioned ", 3i5)', shape(a)
deallocate(a)
end program
出力:
> ./a.out 50
n= 50
a is dimensioned 50 50 2
しかし、Cray はそれがまったく好きではありません。
> ./a.out 10
n= 10
Illegal instruction (core dumped)
さて、キッカーは次のとおりです。コマンド ライン入力を n の単純な設定だけに置き換えると、すべて問題ありません。
integer :: n = 10
! call get_command_argument(1, cmdarg)
! read(cmdarg,'(i)') n
今私は得る
./a.out
n= 10
a is dimensioned 10 10 2
更新:通常のテキストファイルから読み込もうとしました:
integer :: n
open(unit=11, file='size.txt')
read(11,*) n
close(11)
クレイもそれが気に入らない。同じ問題。
したがって、n
コマンド ラインからの場合、Cray は を読み取ることができますn
。を整数と見なしn
、その値を書き出すことさえできます。n
ただし、allocate
ステートメントでは使用できません。(ところで、私はステートメントの形式についていくつかの方法で実験しましたが、read
役に立ちませんでした。) 何が起こっているのでしょうか?
いくつかのコメントに応じた更新:
まず、バグを発見した可能性はありますか? これを別の Cray プラットフォームに移動したところ、問題なく動作しました。両方のマシンの Cray のバージョンは 12.0.3 です。
第二に、私のビルドは非常に単純でした。
ftn simplarray.F90
Intel Broadwell であるログイン ノードでビルドおよびコンパイルしています。