| Class | restart_surftemp_io | 
| In: | io/restart_surftemp_io.F90 | 
Note that Japanese and English are described in parallel.
地表面温度のリスタートデータもしくは初期値データの入出力を行います. 入力ファイル, 出力ファイル, データの出力の間隔は NAMELIST#restart_surftemp_io_nml で設定します.
リスタートデータの入力ファイルが指定されない場合, surface_data モジュールで生成された初期値データを取得します.
Restart data or initial data is input/output. Settings of input file, output file, and interval of data output is configured by "NAMELIST#restart_surftemp_io_nml".
If input file of restart data is not set, initial data is generated in "surface_data" module, and obtained data from the module.
| RestartSurfTempOpen : | リスタートファイルのオープン | 
| RestartSurfTempOutput : | リスタートファイルへのデータ出力 | 
| RestartSurfTempClose : | リスタートファイルのクローズ | 
| RestartSurfTempGet : | リスタートファイルの入力 | 
| ———— : | ———— | 
| RestartSurfTempOpen : | Open restart file | 
| RestartSurfTempOutput : | Data output to restart file | 
| RestartSurfTempClose : | Close restart file | 
| RestartSurfTempGet : | Input restart file | 
| Subroutine : | 
リスタートデータファイル出力の終了処理を行います.
Terminate restart data files output.
  subroutine RestartSurfTempClose
    !
    ! リスタートデータファイル出力の終了処理を行います. 
    !
    ! Terminate restart data files output. 
    ! モジュール引用 ; USE statements
    !
    ! gtool4 データ出力
    ! Gtool4 data output
    !
    use gtool_history, only: HistoryClose
    ! 宣言文 ; Declaration statements
    !
    implicit none
    ! 作業変数
    ! Work variables
    !
    ! 実行文 ; Executable statement
    !
    if ( .not. restart_surftemp_opened ) return
    call HistoryClose( history = gthst_rst ) ! (inout)
    restart_surftemp_opened = .false.
  end subroutine RestartSurfTempClose
          | Subroutine : | |||
| xy_SurfTemp(0:imax-1, 1:jmax) : | real(DP), intent(out) 
 | 
リスタートデータの入力を行います. リスタートデータが存在しない場合には, surface_data モジュールを用いて, 地表面温度データ生成を行います.
Input restart data. If restart data is not exist, surface temperature data is created by "surface_data".
  subroutine RestartSurfTempGet( xy_SurfTemp )
    !
    ! リスタートデータの入力を行います. 
    ! リスタートデータが存在しない場合には, 
    ! surface_data モジュールを用いて, 地表面温度データ生成を行います. 
    !
    ! Input restart data. 
    ! If restart data is not exist, 
    ! surface temperature data is created by "surface_data". 
    ! モジュール引用 ; USE statements
    !
    ! 地表面データ提供
    ! Prepare surface data
    !
    use surface_data, only: SurfDataGet
    ! 時刻管理
    ! Time control
    !
    use timeset, only: StartTime             ! 計算開始時刻. 
    ! gtool4 データ入力
    ! Gtool4 data input
    !
    use gtool_history, only: HistoryGet
    ! 日付および時刻の取り扱い
    ! Date and time handler
    !
    use dc_date, only: EvalByUnit
    ! 文字列操作
    ! Character handling
    !
    use dc_string, only: toChar
    ! 宣言文 ; Declaration statements
    !
    implicit none
    real(DP), intent(out):: xy_SurfTemp (0:imax-1, 1:jmax)
                              ! 地表面温度. 
                              ! Surface temperature
    ! 作業変数
    ! Work variables
    !
    character(TOKEN):: time_range
                              ! 時刻の指定. 
                              ! Specification of time
    logical:: flag_mpi_init
#ifdef LIB_MPI
    integer:: err_mpi
#endif
    ! 実行文 ; Executable statement
    !
    if ( .not. restart_surftemp_io_inited ) call RestartSurfTempInit
    ! データを surface_data モジュールから取得
    ! Data is input from "surface_data" module
    ! 
    if ( trim(InputFile) == '' .or. trim(InputName) == '' ) then
      call SurfDataGet( xy_SurfTemp = xy_SurfTemp )  ! (out) optional
    ! データを InputFile から取得
    ! Data is input from InputFile
    ! 
    else
      ! 時刻情報の取得
      ! Get time information
      !
      time_range = time_name // '=' // toChar( EvalbyUnit( StartTime, IntUnit ) )
#ifdef LIB_MPI
      ! MPI における初期化が行われているかを確認する. 
      ! Confirm initialization of MPI
      !
      call MPI_Initialized(flag_mpi_init, err_mpi)
#else
      flag_mpi_init = .false.
#endif
      ! データ入力
      ! Data input
      ! 
      call HistoryGet( InputFile, InputName, range = time_range, array = xy_SurfTemp, flag_mpi_split = flag_mpi_init )             ! (in) optional
    end if
  end subroutine RestartSurfTempGet
          | Subroutine : | |||
| flag_init_data : | logical, intent(in), optional 
 | 
リスタートファイルをオープンします.
A restart file is opened.
  subroutine RestartSurfTempOpen( flag_init_data )
    !
    ! リスタートファイルをオープンします. 
    !
    ! A restart file is opened. 
    !
    ! モジュール引用 ; USE statements
    !
    ! 出力ファイルの基本情報
    ! Basic information for output files
    ! 
    use fileset, only: FileTitle, FileSource, FileInstitution
                              ! データファイルを最終的に変更した組織/個人. 
                              ! Institution or person that changes data files for the last time
    ! 物理定数設定
    ! Physical constants settings
    !
    use constants, only: PI   ! $ \pi $ .
                              ! 円周率.  Circular constant
    ! 座標データ設定
    ! Axes data settings
    !
    use axesset, only: x_Lon, x_Lon_Weight, y_Lat, y_Lat_Weight
                              ! $ \Delta \varphi $ [rad.] . 
                              ! 緯度座標重み. 
                              ! Weight of latitude
    ! 時刻管理
    ! Time control
    !
    use timeset, only: DelTime, StartTime, StartDate, StartDateValid        ! 計算開始日時の有効性. 
                              ! Validation of start date of calculation
    ! gtool4 データ出力
    ! Gtool4 data output
    !
    use gtool_history, only: HistoryCreate, HistoryAddVariable, HistoryPut, HistoryAddAttr
    ! 文字列操作
    ! Character handling
    !
    use dc_string, only: StoA, CPrintf, LChar
    ! 日付および時刻の取り扱い
    ! Date and time handler
    !
    use dc_date, only: toChar, EvalByUnit, operator(+)
    ! 組み込み関数 PRESENT の拡張版関数
    ! Extended functions of intrinsic function "PRESENT"
    !
    use dc_present, only: present_and_true
    ! 宣言文 ; Declaration statements
    !
    implicit none
    logical, intent(in), optional:: flag_init_data
                              ! 初期値データを作成する場合は, 
                              ! この引数に .true. を与えます. 
                              ! 
                              ! If initial data is created, 
                              ! give ".true." to this argument. 
    ! 作業変数
    ! Work variables
    !
    character(STRING):: title_msg
                              ! 表題に付加するメッセージ. 
                              ! Message added to title
    real:: origin_time
                              ! 計算開始時刻. 
                              ! Start time of calculation
    character(STRING):: time_unit
                              ! 日時の単位. Units of date and time
    logical:: flag_mpi_init
#ifdef LIB_MPI
    integer:: err_mpi
#endif
    ! 実行文 ; Executable statement
    !
    ! 初期化
    ! Initialization
    !
    flag_init_data_save = present_and_true( flag_init_data )
    if ( .not. restart_surftemp_io_inited ) call RestartSurfTempInit
    if ( restart_surftemp_opened ) return
    ! 表題に付加するメッセージの設定
    ! Configure message added to title
    !
    if ( .not. flag_init_data_save ) then
      title_msg = ' restart data of surface temperature'
    else
      title_msg = ' initial data of surface temperature'
    end if
    ! 時刻情報の取得
    ! Get time information
    !
    if ( .not. flag_init_data_save ) then
      origin_time = EvalByUnit( StartTime + IntTime, IntUnit )
    else
      origin_time = EvalByUnit( StartTime, IntUnit )
    end if
    if ( StartDateValid ) then
      time_unit = trim(IntUnit) // ' since ' // toChar(StartDate)
    else
      time_unit = IntUnit
    end if
#ifdef LIB_MPI
    ! MPI における初期化が行われているかを確認する. 
    ! Confirm initialization of MPI
    !
    call MPI_Initialized(flag_mpi_init, err_mpi)
#else
    flag_mpi_init = .false.
#endif
    ! リスタートファイルのオープン
    ! Open a restart file
    !
    call HistoryCreate( file = OutputFile, title = trim(FileTitle) // trim(title_msg), source = FileSource, institution = FileInstitution, dims = StoA( 'lon', 'lat', time_name ), dimsizes = (/ imax, jmax, 0 /), longnames = StoA( 'longitude', 'latitude', time_name ), units = StoA( 'degree_east', 'degree_north', time_unit ), origin = origin_time, interval = IntValue, flag_mpi_split = flag_mpi_init, history = gthst_rst )          ! (out) optional
    ! 座標データの設定
    ! Axes data settings
    !
    call HistoryAddAttr( varname = 'lon', attrname = 'standard_name', value = 'longitude', history = gthst_rst )                            ! (inout)
    call HistoryAddAttr( varname = 'lat', attrname = 'standard_name', value = 'latitude', history = gthst_rst )                            ! (inout)
    call HistoryAddAttr( varname = time_name, attrname = 'standard_name', value = 'time', history = gthst_rst )                            ! (inout)
    call HistoryPut( varname = 'lon', array = x_Lon / PI * 180.0_DP, history = gthst_rst )            ! (inout)
    call HistoryPut( varname = 'lat', array = y_Lat / PI * 180.0_DP, history = gthst_rst )            ! (inout)
    ! 座標重みの設定
    ! Axes weights settings
    !
    call HistoryAddVariable( varname = 'lon_weight', dims = StoA('lon'), longname = 'weight for integration in longitude', units = 'radian', xtype = 'double', history = gthst_rst )                               ! (inout)
    call HistoryAddAttr( varname = 'lon', attrname = 'gt_calc_weight', value = 'lon_weight', history = gthst_rst )                               ! (inout)
    call HistoryPut( varname = 'lon_weight', array = x_Lon_Weight, history = gthst_rst )                               ! (inout)
    call HistoryAddVariable( varname = 'lat_weight', dims = StoA('lat'), longname = 'weight for integration in latitude', units = 'radian', xtype = 'double', history = gthst_rst )                               ! (inout)
    call HistoryAddAttr( varname = 'lat', attrname = 'gt_calc_weight', value = 'lat_weight', history = gthst_rst )                               ! (inout)
    call HistoryPut( varname = 'lat_weight', array = y_Lat_Weight, history = gthst_rst )                               ! (inout)
    ! 予報変数の設定
    ! Predictional variables settings
    !
    call HistoryAddVariable( varname = 'SurfTemp', dims = StoA('lon', 'lat', time_name), longname = 'surface temperature', units = 'K', xtype = 'double', history = gthst_rst )                     ! (inout)
    restart_surftemp_opened = .true.
  end subroutine RestartSurfTempOpen
          | Subroutine : | |||
| xy_SurfTemp(0:imax-1, 1:jmax) : | real(DP), intent(in) 
 | 
リスタートデータの出力を行います.
Output restart data
  subroutine RestartSurfTempOutput( xy_SurfTemp )
    !
    ! リスタートデータの出力を行います. 
    !
    ! Output restart data
    ! モジュール引用 ; USE statements
    !
    ! gtool4 データ出力
    ! Gtool4 data output
    !
    use gtool_history, only: HistoryPut, HistorySetTime
    ! 時刻管理
    ! Time control
    !
    use timeset, only: TimeN, EndTime               ! 計算終了時刻. 
                              ! End time of calculation
    ! 組み込み関数 PRESENT の拡張版関数
    ! Extended functions of intrinsic function "PRESENT"
    !
    use dc_present, only: present_and_true
    ! 日付および時刻の取り扱い
    ! Date and time handler
    !
    use dc_date, only: operator(+), operator(<), operator(-), operator(==), operator(>=), DCDiffTimePutLine
    ! 宣言文 ; Declaration statements
    !
    implicit none
    real(DP), intent(in):: xy_SurfTemp (0:imax-1, 1:jmax)
                              ! 地表面温度. 
                              ! Surface temperature
    ! 作業変数
    ! Work variables
    !
    logical:: flag_output
                              ! 出力のフラグ. 
                              ! Flag for output
    ! 実行文 ; Executable statement
    !
    if ( .not. restart_surftemp_opened ) call RestartSurfTempOpen
    ! 出力タイミングのチェック
    ! Check output timing
    !
    flag_output = TimeN - PrevOutputTime >= IntTime
    if ( TimeN >= EndTime .and. .not. flag_output_end ) then
      flag_output = .true.
      flag_output_end = .true.
    end if
    flag_output = ( .not. TimeN == PrevOutputTime ) .and. flag_output
    flag_output = flag_init_data_save .or. flag_output
    if ( .not. flag_output ) return
    ! 次回用に, 今回の出力 (希望) 時刻 を保存
    ! Save output time (expected) in this time, for next time
    !
    PrevOutputTime = PrevOutputTime + IntTime
    ! 時刻の設定
    ! Set time
    !
    call HistorySetTime( difftime = TimeN, history = gthst_rst )
    ! データ出力
    ! Data output
    !
    call HistoryPut( 'SurfTemp', xy_SurfTemp, history = gthst_rst ) ! (in)
  end subroutine RestartSurfTempOutput
          | Variable : | |||
| restart_surftemp_io_inited = .false. : | logical, save, public 
 | 
| Variable : | |||
| restart_surftemp_opened = .false. : | logical, save, public 
 | 
| Subroutine : | 
依存モジュールの初期化チェック
Check initialization of dependency modules
  subroutine InitCheck
    !
    ! 依存モジュールの初期化チェック
    !
    ! Check initialization of dependency modules
    ! モジュール引用 ; USE statements
    !
    ! NAMELIST ファイル入力に関するユーティリティ
    ! Utilities for NAMELIST file input
    !
    use namelist_util, only: namelist_util_inited
    ! 出力ファイルの基本情報管理
    ! Management basic information for output files
    !
    use fileset, only: fileset_inited
    ! 格子点設定
    ! Grid points settings
    !
    use gridset, only: gridset_inited
    ! 物理定数設定
    ! Physical constants settings
    !
    use constants, only: constants_inited
    ! 座標データ設定
    ! Axes data settings
    !
    use axesset, only: axesset_inited
    ! 時刻管理
    ! Time control
    !
    use timeset, only: timeset_inited
    ! 実行文 ; Executable statement
    !
    if ( .not. namelist_util_inited ) call MessageNotify( 'E', module_name, '"namelist_util" module is not initialized.' )
    if ( .not. fileset_inited ) call MessageNotify( 'E', module_name, '"fileset" module is not initialized.' )
    if ( .not. gridset_inited ) call MessageNotify( 'E', module_name, '"gridset" module is not initialized.' )
    if ( .not. constants_inited ) call MessageNotify( 'E', module_name, '"constants" module is not initialized.' )
    if ( .not. axesset_inited ) call MessageNotify( 'E', module_name, '"axesset" module is not initialized.' )
    if ( .not. timeset_inited ) call MessageNotify( 'E', module_name, '"timeset" module is not initialized.' )
  end subroutine InitCheck
          | Variable : | |||
| InputFile : | character(STRING), save 
 | 
| Variable : | |||
| InputName : | character(TOKEN), save 
 | 
| Variable : | |||
| IntTime : | type(DC_DIFFTIME), save 
 | 
| Variable : | |||
| IntUnit : | character(TOKEN) 
 | 
| Variable : | |||
| OutputFile : | character(STRING), save 
 | 
| Subroutine : | 
restart_surftemp_io モジュールの初期化を行います. NAMELIST#restart_surftemp_io_nml の読み込みはこの手続きで行われます.
"restart_surftemp_io" module is initialized. "NAMELIST#restart_surftemp_io_nml" is loaded in this procedure.
This procedure input/output NAMELIST#restart_surftemp_io_nml .
  subroutine RestartSurfTempInit
    !
    ! restart_surftemp_io モジュールの初期化を行います. 
    ! NAMELIST#restart_surftemp_io_nml の読み込みはこの手続きで行われます. 
    !
    ! "restart_surftemp_io" module is initialized. 
    ! "NAMELIST#restart_surftemp_io_nml" is loaded in this procedure. 
    !
    ! モジュール引用 ; USE statements
    !
    ! リスタートデータ入出力
    ! Restart data input/output
    !
    use restart_file_io, only: restart_file_io_inited, RestartFileIntValue => IntValue, RestartFileIntUnit  => IntUnit
                              ! リスタートデータの出力間隔の単位. 
                              ! Unit for interval of restart data output
    ! 時刻管理
    ! Time control
    !
    use timeset, only: StartTime             ! 計算開始時刻. 
                              ! Start time of calculation
    ! NAMELIST ファイル入力に関するユーティリティ
    ! Utilities for NAMELIST file input
    !
    use namelist_util, only: namelist_filename, NmlutilMsg
    ! 日付および時刻の取り扱い
    ! Date and time handler
    !
    use dc_date, only: DCDiffTimeCreate, operator(-)
    ! ファイル入出力補助
    ! File I/O support
    !
    use dc_iounit, only: FileOpen
    ! 種別型パラメタ
    ! Kind type parameter
    !
    use dc_types, only: STDOUT ! 標準出力の装置番号. Unit number of standard output
    ! 宣言文 ; Declaration statements
    !
    implicit none
    ! 作業変数
    ! Work variables
    !
    integer:: unit_nml        ! NAMELIST ファイルオープン用装置番号. 
                              ! Unit number for NAMELIST file open
    integer:: iostat_nml      ! NAMELIST 読み込み時の IOSTAT. 
                              ! IOSTAT of NAMELIST read
    ! NAMELIST 変数群
    ! NAMELIST group name
    !
    namelist /restart_surftemp_io_nml/ InputFile, InputName, OutputFile, IntValue, IntUnit
          !
          ! デフォルト値については初期化手続 "restart_surftemp_io#RestartSurfTempInit" 
          ! のソースコードを参照のこと. 
          !
          ! Refer to source codes in the initialization procedure
          ! "restart_surftemp_io#RestartSurfTempInit" for the default values. 
          !
    ! 実行文 ; Executable statement
    !
    if ( restart_surftemp_io_inited ) return
    call InitCheck
    ! デフォルト値の設定
    ! Default values settings
    !
    InputFile  = ''
    InputName  = 'SurfTemp'
    if ( .not. flag_init_data_save ) then
      OutputFile = 'restart_sst.nc'
    else
      OutputFile = 'sst.nc'
    end if
    if ( restart_file_io_inited ) then
      IntValue   = RestartFileIntValue
      IntUnit    = RestartFileIntUnit
    else
      IntValue   = 1.0
      IntUnit    = 'day'
    end if
    ! NAMELIST の読み込み
    ! NAMELIST is input
    !
    if ( trim(namelist_filename) /= '' ) then
      call FileOpen( unit_nml, namelist_filename, mode = 'r' ) ! (in)
      rewind( unit_nml )
      read( unit_nml, nml = restart_surftemp_io_nml, iostat = iostat_nml ) ! (out)
      close( unit_nml )
      call NmlutilMsg( iostat_nml, module_name ) ! (in)
      if ( iostat_nml == 0 ) write( STDOUT, nml = restart_surftemp_io_nml )
    end if
    ! 出力時間間隔の設定
    ! Configure time interval of output
    !
    call DCDiffTimeCreate( IntTime, IntValue, IntUnit )           ! (in)
    PrevOutputTime = StartTime
    ! フラグの初期化
    ! Initialize flag
    !
    flag_output_end = .false.
    ! 印字 ; Print
    !
    call MessageNotify( 'M', module_name, '----- Initialization Messages -----' )
    call MessageNotify( 'M', module_name, 'Input:: ' )
    call MessageNotify( 'M', module_name, '  InputFile  = %c', c1 = trim(InputFile) )
    call MessageNotify( 'M', module_name, '  InputName  = %c', c1 = trim(InputName) )
    call MessageNotify( 'M', module_name, 'Output:: ' )
    call MessageNotify( 'M', module_name, '  OutputFile = %c', c1 = trim(OutputFile) )
    call MessageNotify( 'M', module_name, '  IntTime    = %r [%c]', r = (/ IntValue /), c1 = trim(IntUnit) )
    call MessageNotify( 'M', module_name, '-- version = %c', c1 = trim(version) )
    restart_surftemp_io_inited = .true.
  end subroutine RestartSurfTempInit
          | Constant : | |||
| deltime_name = ‘deltime‘ : | character(*), parameter 
 | 
| Variable : | |||
| flag_init_data_save : | logical, save 
 | 
| Variable : | |||
| flag_output_end : | logical, save 
 | 
| Variable : | |||
| gthst_rst : | type(GT_HISTORY), save 
 | 
| Constant : | |||
| module_name = ‘restart_surftemp_io‘ : | character(*), parameter 
 | 
| Constant : | |||
| time_name = ‘time‘ : | character(*), parameter 
 | 
| Constant : | |||
| version = ’$Name: dcpam5-20090317 $’ // ’$Id: restart_surftemp_io.F90,v 1.3 2009-02-09 05:56:09 morikawa Exp $’ : | character(*), parameter 
 |