!---------------------------------------------------------------------
!     Copyright (C) GFD Dennou Club, 2004. All rights reserved.
!---------------------------------------------------------------------
                                                                 !=begin
!= Module DistrbPrm
!
!   * Developer: SUGIYAMA Ko-ichiro (sugiyama@gfd-dennou.org)
!   * Version: $Id: distrbprm.f90,v 1.2 2005/01/28 12:41:21 sugiyama Exp $ 
!   * Tag Name: $Name:  $
!   * Change History: 
!
!== Overview 
!
!擾乱場の初期値を作成するプログラム distrb の初期値を設定する. 
!
!== Error Handling
!
!== Known Bugs
!
!== Note
!
!== Future Plans
!
!エラー処理に gf4f90io を利用
!
                                                                 !=end

module distrbprm
  !--- 暗黙の型宣言禁止
  implicit none

  !--- save 属性
  save
                                                                 !=begin
  !--- 変数定義
  real(8)       :: CpDry            !比熱
  real(8)       :: MolWtDry         !分子量

  character(80) :: ExnerDistrbType  !無次元圧力の擾乱 (DistrbType.f90 参照)
  real(8)       :: ExnerSigmaX      !擾乱の幅 (X 方向)
  real(8)       :: ExnerSigmaZ      !擾乱の幅 (Z 方向)
  real(8)       :: ExnerMax         !擾乱の最大値
  real(8)       :: ExnerCenterX     !擾乱の中心 (X 方向)
  real(8)       :: ExnerCenterZ     !擾乱の中心 (X 方向)

  character(80) :: PotTempDistrbType  !温位の擾乱 (DistrbType.f90 参照)
  real(8)       :: PotTempSigmaX      !擾乱の幅 (X 方向)
  real(8)       :: PotTempSigmaZ      !擾乱の幅 (X 方向)
  real(8)       :: PotTempMax         !擾乱の最大値
  real(8)       :: PotTempCenterX     !擾乱の中心 (X 方向)
  real(8)       :: PotTempCenterZ     !擾乱の中心 (X 方向)

  character(80) :: VelDistrbType    !速度の擾乱 (DistrbType.f90 参照)
  real(8)       :: VelX             !速度 u 
  real(8)       :: VelZ             !速度 w

  character(80) :: distrbfile       !出力ファイル名
                                                                 !=end

contains
                                                                 !=begin
  !== Procedure Interface 
  !
  !=== Initialize module and acquire NAMELIST
  !
  !NAMELIST から擾乱場の初期値生成プログラム distrb の設定を読み取る. 
  !
  subroutine distrbprm_init(cfgfile)

    !=== Input
    character(*), intent(in) :: cfgfile

    !=== NAMELIST
    NAMELIST /distrbprm/ &
         & distrbfile, CpDry, MolWtDry, &
         & ExnerDistrbType, ExnerMax, ExnerSigmaX, ExnerSigmaZ, &
         &                  ExnerCenterX, ExnerCenterZ, &
         & PotTempDistrbType, PotTempMax, PotTempSigmaX, PotTempSigmaZ, &
         &                  PotTempCenterX, PotTempCenterZ, &
         & VelDistrbType, VelX, VelZ

    open (10, FILE=cfgfile)
    read(10, NML=distrbprm)
    close(10)
                                                                 !=end    
    !--- 変数の値のチェック
    if ( ExnerSigmaX > 1 )  then 
       write(*,*) "gacchanprm.f90: SigmaX is > 1. "
       stop
    end if

    if ( ExnerSigmaZ > 1 )  then
       write(*,*) "gacchanprm.f90: SigmaZ is > 1. "
       stop
    end if

    if ( PotTempSigmaX > 1 )  then 
       write(*,*) "gacchanprm.f90: SigmaX is > 1. "
       stop
    end if

    if ( PotTempSigmaZ > 1 )  then
       write(*,*) "gacchanprm.f90: SigmaZ is > 1. "
       stop
    end if

    if ( ExnerCenterX > 1 ) then 
       write(*,*) "gacchanprm.f90: CenterX is > 1. "
       stop
    end if

    if ( ExnerCenterZ > 1 ) then
       write(*,*) "gacchanprm.f90: CenterZ is > 1. "
       stop
    end if

    if ( PotTempCenterX > 1 ) then 
       write(*,*) "gacchanprm.f90: CenterX is > 1. "
       stop
    end if

    if ( PotTempCenterZ > 1 ) then
       write(*,*) "gacchanprm.f90: CenterZ is > 1. "
       stop
    end if

  end subroutine distrbprm_init
  
end module distrbprm
