subroutine write_file( file_name, nx, ny, rec_num, var, mode ) ! 解析出力ルーチン ! 本ルーチンでは, ダイレクトアクセスを読み出す際, 1 変数のバイト数を 4 バイト ! と仮定して読み出すので, 4 バイト以外のファイルを読み出すときは, ! やはりソースファイルの書き換えが必要となる(要修正) implicit none integer, intent(in) :: nx ! データの x 方向の個数 integer, intent(in) :: ny ! データの y 方向の個数 integer, intent(in) :: rec_num ! 読み出すデータのレコード番号 character(*), intent(in) :: file_name ! 読み出すデータファイル名 real, intent(inout) :: var(nx,ny) ! 読み出すデータ character(*), optional, intent(in) :: mode ! ファイルの書き出しオプション integer :: i, j, er, k ! 作業用配列 character(10) :: cmode if(present(mode))then cmode=mode else cmode='old' end if open(unit=11, file=file_name, access='direct', recl=4*nx*ny, status=cmode) write(11,rec=rec_num) ((var(i,j),i=1,nx),j=1,ny) close(unit=11, status='keep') end subroutine write_file