I/O のリダイレクト

XL Fortran プログラムへの入出力は、 コマンド行でリダイレクト演算子を使用してリダイレクトすることができます。 この演算子の指定および使用方法は、どのシェルを 実行しているかによって異なります。 以下に bash の例を挙げます。


$ cat redirect.f
        write (6,*) 'This goes to standard output'
        write (0,*) 'This goes to standard error'
        read (5,*) i
        print *,i
        end
$ xlf95 redirect.f
** _main    === End of Compilation 1 ===
1501-510  Compilation successful for file redirect.f.
$ # No redirection. Input comes from the terminal. Output goes to
$ # the screen.
$ a.out
 This goes to standard output
 This goes to standard error
4
 4
$ # Create an input file.
$ echo >stdin 2
$ # Redirect each standard I/O stream.
$ a.out >stdout 2>stderr <stdin
$ cat stdout
 This goes to standard output
 2
$ cat stderr
 This goes to standard error

リダイレクトの詳細については、man ページを参照してください。 IBM Copyright 2003