This module set "Time" and "Step".
時刻や「計算ステップ」に関して設定するためのモジュールである。
use type_mod, only : REKIND, DBKIND, INTKIND, TOKEN, STRING
private
public :: time_init, time_progress, time_end, & ! subroutines
& InitTime, DelTime, & ! variables
& StepInterval, OutputStep, & ! variables
& CurrentTime, CurrentLoop, & ! variables
& tvar, ttype, tname, tunit ! variables
データ出力の際のステップ間隔や出力回数などに関する情報。 time_init で設定。
real(DBKIND) , save :: &
& InitTime = 0.0 , & ! 積分開始時刻
& DelTime = 300 ! 時間ステップ
integer(INTKIND) , save :: &
& StepInterval = 1 , & ! 出力ステップ間隔
& OutputStep = 1 ! 出力回数
character(STRING), save :: &
& tvar = 'time' , & ! 時刻変数名
& ttype = 'float' , & ! 時刻変数の型
& tname = 'time' , & ! 時刻の名称
& tunit = 'seconds' ! 時刻の単位
現在の時刻やループ回数を保持してある変数。 time_init で初期設定され、 time_progress で更新される。
real(DBKIND) , save :: CurrentTime = 0.0 ! 現在時刻 integer(INTKIND) , save :: CurrentLoop = 1 ! 現在のループ回数
モジュールを初期化し、NAMELIST から値を取得する。 NAMELIST から値が取得できないものに関しては上記のデフォルト値が 用いられる。
NAMELIST ファイルは、メインプログラムにて nmlfile_mod の nmlfile_init で指定されることが想定されているが、 もしもこの初期化ルーチンより以前に指定されていなければ、 nmlfile_init のデフォルトで指定される NAMELIST ファイルを 読む。
subroutine time_init
use type_mod, only : REKIND, DBKIND, INTKIND, TOKEN, STRING use nmlfile_mod, only : nmlfile_init, nmlfile_open, nmlfile_close use dc_trace, only : BeginSub, EndSub, DbgMessage use dc_message, only : MessageNotify
InitTime に与えられた数値に DelTime を加えた値が、 CurrentTime に代入される。
namelist /time_nml/ &
& InitTime , & ! 積分開始時刻
& DelTime , & ! 時間ステップ
& StepInterval , & ! 出力回数
& OutputStep , & ! 出力ステップ間隔
& tvar , & ! 時刻変数名
& ttype , & ! 時刻変数の型
& tname , & ! 時刻の名称
& tunit ! 時刻の単位
CurrentTime を time_init で指定された DelTime 分だけ進め、 CurrentLoop を 1 増やす。 今の所、時間を指定したり巻戻したりできない。
subroutine time_progress
use type_mod, only : STRING use dc_trace, only : BeginSub, EndSub, DbgMessage
NAMELIST から読み込んだ値を破棄し、各定数をデフォルトの値に戻す。
subroutine time_end
use type_mod, only : STRING use dc_trace, only : BeginSub, EndSub, DbgMessage