Takuya Miyashita
This site
Web
Start:
*inquire文について [#xbfac96e]
inquire はその名の通りいろいろ問い合わせて確認できるらし...
今のところよく使うのはopenedくらい.
***ファイルが開かれているか確認する(opened) [#o78a1b1c]
#codeprettify(lang-fortran){{
inquire(unit=fileID,opened=TFopen)
}}
で,装置番号 fileID が既に展開されているか確認できる.TFo...
何に使うのかといえば,subroutine でファイルに出力する時と...
以下に例示する.
#codeprettify(lang-fortran){{
subroutine FOOBARSUB(...,fileID,...)
implicit none
!!! input arguments
integer, intent(in) :: fileID
!!! local variables
logical :: TFopen
!*** write out if already opened
inquire(unit=fileID,err=900,opened=TFopen)
if(TFopen)then
write(fileID,101) hoge
else
write(*,*) fileID,'なんてものはない.'
endif
101 format(...)
! ... others ...
return
!!エラー時の処理
900 write(*,*) 'inquireでエラー'
end subroutine
}}
errをつけているのは,しょうもないミスで計算が止まるのを防...
End:
*inquire文について [#xbfac96e]
inquire はその名の通りいろいろ問い合わせて確認できるらし...
今のところよく使うのはopenedくらい.
***ファイルが開かれているか確認する(opened) [#o78a1b1c]
#codeprettify(lang-fortran){{
inquire(unit=fileID,opened=TFopen)
}}
で,装置番号 fileID が既に展開されているか確認できる.TFo...
何に使うのかといえば,subroutine でファイルに出力する時と...
以下に例示する.
#codeprettify(lang-fortran){{
subroutine FOOBARSUB(...,fileID,...)
implicit none
!!! input arguments
integer, intent(in) :: fileID
!!! local variables
logical :: TFopen
!*** write out if already opened
inquire(unit=fileID,err=900,opened=TFopen)
if(TFopen)then
write(fileID,101) hoge
else
write(*,*) fileID,'なんてものはない.'
endif
101 format(...)
! ... others ...
return
!!エラー時の処理
900 write(*,*) 'inquireでエラー'
end subroutine
}}
errをつけているのは,しょうもないミスで計算が止まるのを防...
Page:
Edit with a page name which already exists