| Path: | main/init_data.F90 | 
| Last Update: | Fri Jan 22 16:17:25 +0900 2010 | 
| Authors: | Yasuhiro MORIKAWA | 
| Version: | $Id: init_data.F90,v 1.8 2010-01-22 07:17:25 yot Exp $ | 
| Tag Name: | $Name: dcpam5-20100224 $ | 
| Copyright: | Copyright (C) GFD Dennou Club, 2008. All rights reserved. | 
| License: | See COPYRIGHT | 
| Main Program : | 
Note that Japanese and English are described in parallel.
初期値データファイルを生成します.
Initial data file is created.
program init_data
  !
  ! <b>Note that Japanese and English are described in parallel.</b>
  !
  ! 初期値データファイルを生成します. 
  !
  ! Initial data file is created. 
  !
  ! モジュール引用 ; USE statements
  !
  ! 初期値データ (リスタートデータ) 提供
  ! Prepare initial data (restart data)
  !
  use initial_data, only: SetInitData
  ! リスタートデータ入出力
  ! Restart data input/output
  !
  use restart_file_io, only: RestartFileOutPut
  ! 種別型パラメタ
  ! Kind type parameter
  !
  use dc_types, only: DP, STRING, TOKEN      ! キーワード.   Keywords. 
#ifdef LIB_MPI
  ! MPI ライブラリ
  ! MPI library
  !
  use mpi
#endif
  ! 宣言文 ; Declaration statements
  !
  implicit none
  ! 予報変数 (ステップ $ t-\Delta t $ , $ t $ , $ t+\Delta t $ )
  ! Prediction variables  (Step $ t-\Delta t $ , $ t $ , $ t+\Delta t $ )
  !
  real(DP), allocatable:: xyz_U (:,:,:)
                              ! $ u $ .   東西風速. Eastward wind
  real(DP), allocatable:: xyz_V (:,:,:)
                              ! $ v $ .   南北風速. Northward wind
  real(DP), allocatable:: xyz_Temp (:,:,:)
                              ! $ T $ .   温度. Temperature
  real(DP), allocatable:: xyz_QVap (:,:,:)
                              ! $ q $ .   比湿. Specific humidity
  real(DP), allocatable:: xy_Ps (:,:)
                              ! $ p_s $ . 地表面気圧. Surface pressure
  ! 作業変数
  ! Work variables
  !
  ! 実行文 ; Executable statement
  !
  ! 主プログラムの初期化 (内部サブルーチン)
  ! Initialization for the main program (Internal subroutine)
  !
  call MainInit
  ! 初期値データの作成
  ! Generate initial data
  !
  call SetInitData( xyz_U, xyz_V, xyz_Temp, xyz_QVap, xy_Ps )  ! (out)
  ! 初期値データの出力
  ! Output initial data
  !
  call RestartFileOutput( xyz_U, xyz_V, xyz_Temp, xyz_QVap, xy_Ps )  ! (in)
  ! 主プログラムの終了処理 (内部サブルーチン)
  ! Termination for the main program (Internal subroutine)
  !
  call MainTerminate
contains
  !-------------------------------------------------------------------
  subroutine MainInit
    !
    ! 主プログラムの初期化手続き. 
    !
    ! Initialization procedure for the main program. 
    !
#ifdef LIB_MPI
    ! メッセージ出力
    ! Message output
    !
    use dc_message, only: MessageSuppressMPI
#endif
    use dc_message, only: MessageNotify
    ! コマンドライン引数処理
    ! Command line option parser
    !
    use option_parser, only: OptParseInit
    ! NAMELIST ファイル入力に関するユーティリティ
    ! Utilities for NAMELIST file input
    !
    use namelist_util, only: NmlutilInit
    ! 時刻管理
    ! Time control
    !
    use timeset, only: TimesetInit
                              ! ステップ $ t $ の時刻. Time of step $ t $. 
    ! 出力ファイルの基本情報管理
    ! Management basic information for output files
    ! 
    use fileset, only: FilesetInit
    ! 格子点設定
    ! Grid points settings
    !
    use gridset, only: GridsetInit, imax, jmax, kmax    ! 鉛直層数. 
                               ! Number of vertical level
    ! 物理定数設定
    ! Physical constants settings
    !
    use constants, only: ConstantsInit
    ! 座標データ設定
    ! Axes data settings
    !
    use axesset, only: AxessetInit
    ! リスタートデータ入出力
    ! Restart data input/output
    !
    use restart_file_io, only: RestartFileOpen, RestartFileGet
    ! 宣言文 ; Declaration statements
    !
    implicit none
    character(*), parameter:: prog_name = 'init_data'
                              ! 主プログラム名. 
                              ! Main program name
    character(*), parameter:: version = '$Name: dcpam5-20100224 $' // '$Id: init_data.F90,v 1.8 2010-01-22 07:17:25 yot Exp $'
                              ! 主プログラムのバージョン
                              ! Main program version
    character(STRING):: brief
                              ! 実行ファイルの簡潔な説明
                              ! Brief account of executable file
#ifdef LIB_MPI
    integer :: myrank_mpi, nprocs_mpi, err_mpi
                              ! MPI の初期化の際に使用される変数. 
                              ! Variables used for initialization of MPI. 
#endif
    ! 実行文 ; Executable statement
    !
#ifdef LIB_MPI
    ! MPI 初期化
    ! Initialization of MPI
    !
    CALL MPI_Init(err_mpi)
    CALL MPI_Comm_Rank(mpi_comm_world, myrank_mpi, err_mpi)
    CALL MPI_Comm_Size(mpi_comm_world, nprocs_mpi, err_mpi)
#endif
#ifdef LIB_MPI
    ! メッセージ出力
    ! Message output
    !
    call MessageSuppressMPI( rank = 0 )
#endif
    brief = 'Initial data generation'
    call MessageNotify( 'M', prog_name, 'Run: %c', c1 = trim(brief) )
    call MessageNotify( 'M', prog_name, '-- version = %c', c1 = trim(version) )
    ! コマンドライン引数処理
    ! Command line option parser
    !
    call OptParseInit(prog_name, brief)
    ! NAMELIST ファイル名入力
    ! Input NAMELIST file name
    !
    call NmlutilInit
    ! 時刻管理
    ! Time control
    !
    call TimesetInit
    ! 出力ファイルの基本情報管理
    ! Management basic information for output files
    ! 
    call FilesetInit
    ! 格子点設定
    ! Grid points settings
    !
    call GridsetInit
    ! 物理定数設定
    ! Physical constants settings
    !
    call ConstantsInit
    ! 座標データ設定
    ! Axes data settings
    !
    call AxessetInit
    ! 予報変数の割付
    ! Allocation of prediction variables
    !
    allocate( xyz_U    (0:imax-1, 1:jmax, 1:kmax) )
    allocate( xyz_V    (0:imax-1, 1:jmax, 1:kmax) )
    allocate( xyz_Temp (0:imax-1, 1:jmax, 1:kmax) )
    allocate( xyz_QVap (0:imax-1, 1:jmax, 1:kmax) )
    allocate( xy_Ps    (0:imax-1, 1:jmax) )
    ! 初期値データ出力
    ! Initial data output
    !
    call RestartFileOpen( flag_init_data = .true. ) ! (in) optional
  end subroutine MainInit
  !-------------------------------------------------------------------
  subroutine MainTerminate
    !
    ! 主プログラムの終了処理手続き. 
    !
    ! Termination procedure for the main program. 
    !
    ! 時刻管理
    ! Time control
    !
    use timeset, only: TimesetClose
    ! リスタートデータ入出力
    ! Restart data input/output
    !
    use restart_file_io, only: RestartFileClose
    ! 宣言文 ; Declaration statements
    !
    implicit none
#ifdef LIB_MPI
    integer :: err_mpi
                              ! MPI の終了処理の際に使用される変数. 
                              ! Variable used for termination of MPI. 
#endif
    ! 実行文 ; Executable statement
    !
    ! リスタートデータファイルクローズ
    ! Close restart data input
    !
    call RestartFileClose
    ! 時刻管理終了処理
    ! Termination of time control
    !
    call TimesetClose
    ! 予報変数の割付解除
    ! Deallocation of prediction variables
    !
    deallocate( xyz_U    )
    deallocate( xyz_V    )
    deallocate( xyz_Temp )
    deallocate( xyz_QVap )
    deallocate( xy_Ps    )
#ifdef LIB_MPI
    ! MPI 終了処理
    ! Termination of MPI
    !
    call MPI_Finalize(err_mpi)
#endif
  end subroutine MainTerminate
end program init_data
          | Subroutine : | 
主プログラムの初期化手続き.
Initialization procedure for the main program.
  subroutine MainInit
    !
    ! 主プログラムの初期化手続き. 
    !
    ! Initialization procedure for the main program. 
    !
#ifdef LIB_MPI
    ! メッセージ出力
    ! Message output
    !
    use dc_message, only: MessageSuppressMPI
#endif
    use dc_message, only: MessageNotify
    ! コマンドライン引数処理
    ! Command line option parser
    !
    use option_parser, only: OptParseInit
    ! NAMELIST ファイル入力に関するユーティリティ
    ! Utilities for NAMELIST file input
    !
    use namelist_util, only: NmlutilInit
    ! 時刻管理
    ! Time control
    !
    use timeset, only: TimesetInit
                              ! ステップ $ t $ の時刻. Time of step $ t $. 
    ! 出力ファイルの基本情報管理
    ! Management basic information for output files
    ! 
    use fileset, only: FilesetInit
    ! 格子点設定
    ! Grid points settings
    !
    use gridset, only: GridsetInit, imax, jmax, kmax    ! 鉛直層数. 
                               ! Number of vertical level
    ! 物理定数設定
    ! Physical constants settings
    !
    use constants, only: ConstantsInit
    ! 座標データ設定
    ! Axes data settings
    !
    use axesset, only: AxessetInit
    ! リスタートデータ入出力
    ! Restart data input/output
    !
    use restart_file_io, only: RestartFileOpen, RestartFileGet
    ! 宣言文 ; Declaration statements
    !
    implicit none
    character(*), parameter:: prog_name = 'init_data'
                              ! 主プログラム名. 
                              ! Main program name
    character(*), parameter:: version = '$Name: dcpam5-20100224 $' // '$Id: init_data.F90,v 1.8 2010-01-22 07:17:25 yot Exp $'
                              ! 主プログラムのバージョン
                              ! Main program version
    character(STRING):: brief
                              ! 実行ファイルの簡潔な説明
                              ! Brief account of executable file
#ifdef LIB_MPI
    integer :: myrank_mpi, nprocs_mpi, err_mpi
                              ! MPI の初期化の際に使用される変数. 
                              ! Variables used for initialization of MPI. 
#endif
    ! 実行文 ; Executable statement
    !
#ifdef LIB_MPI
    ! MPI 初期化
    ! Initialization of MPI
    !
    CALL MPI_Init(err_mpi)
    CALL MPI_Comm_Rank(mpi_comm_world, myrank_mpi, err_mpi)
    CALL MPI_Comm_Size(mpi_comm_world, nprocs_mpi, err_mpi)
#endif
#ifdef LIB_MPI
    ! メッセージ出力
    ! Message output
    !
    call MessageSuppressMPI( rank = 0 )
#endif
    brief = 'Initial data generation'
    call MessageNotify( 'M', prog_name, 'Run: %c', c1 = trim(brief) )
    call MessageNotify( 'M', prog_name, '-- version = %c', c1 = trim(version) )
    ! コマンドライン引数処理
    ! Command line option parser
    !
    call OptParseInit(prog_name, brief)
    ! NAMELIST ファイル名入力
    ! Input NAMELIST file name
    !
    call NmlutilInit
    ! 時刻管理
    ! Time control
    !
    call TimesetInit
    ! 出力ファイルの基本情報管理
    ! Management basic information for output files
    ! 
    call FilesetInit
    ! 格子点設定
    ! Grid points settings
    !
    call GridsetInit
    ! 物理定数設定
    ! Physical constants settings
    !
    call ConstantsInit
    ! 座標データ設定
    ! Axes data settings
    !
    call AxessetInit
    ! 予報変数の割付
    ! Allocation of prediction variables
    !
    allocate( xyz_U    (0:imax-1, 1:jmax, 1:kmax) )
    allocate( xyz_V    (0:imax-1, 1:jmax, 1:kmax) )
    allocate( xyz_Temp (0:imax-1, 1:jmax, 1:kmax) )
    allocate( xyz_QVap (0:imax-1, 1:jmax, 1:kmax) )
    allocate( xy_Ps    (0:imax-1, 1:jmax) )
    ! 初期値データ出力
    ! Initial data output
    !
    call RestartFileOpen( flag_init_data = .true. ) ! (in) optional
  end subroutine MainInit
          | Subroutine : | 
主プログラムの終了処理手続き.
Termination procedure for the main program.
  subroutine MainTerminate
    !
    ! 主プログラムの終了処理手続き. 
    !
    ! Termination procedure for the main program. 
    !
    ! 時刻管理
    ! Time control
    !
    use timeset, only: TimesetClose
    ! リスタートデータ入出力
    ! Restart data input/output
    !
    use restart_file_io, only: RestartFileClose
    ! 宣言文 ; Declaration statements
    !
    implicit none
#ifdef LIB_MPI
    integer :: err_mpi
                              ! MPI の終了処理の際に使用される変数. 
                              ! Variable used for termination of MPI. 
#endif
    ! 実行文 ; Executable statement
    !
    ! リスタートデータファイルクローズ
    ! Close restart data input
    !
    call RestartFileClose
    ! 時刻管理終了処理
    ! Termination of time control
    !
    call TimesetClose
    ! 予報変数の割付解除
    ! Deallocation of prediction variables
    !
    deallocate( xyz_U    )
    deallocate( xyz_V    )
    deallocate( xyz_Temp )
    deallocate( xyz_QVap )
    deallocate( xy_Ps    )
#ifdef LIB_MPI
    ! MPI 終了処理
    ! Termination of MPI
    !
    call MPI_Finalize(err_mpi)
#endif
  end subroutine MainTerminate