!c Description: 
!c   設定値を読み込む
!c
!c Current Code Owner: 
!c   sugiyama@gfd-dennou.org
!c
!c Copyright (C) SUGIYAMA Ko-ichiro, 2004, All rights reserved

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

  !--- save 属性
  save

  !--- 変数定義
  real(8)       :: CpDry
  real(8)       :: MolWtDry
  real(8)       :: TempSfc
  real(8)       :: PressSfc
  character(80) :: TempType
  character(80) :: PressType

  character(80) :: ExnerDistrbType
  real(8)       :: ExnerSigmaX
  real(8)       :: ExnerSigmaZ
  real(8)       :: ExnerMax
  real(8)       :: ExnerCenterX
  real(8)       :: ExnerCenterZ

  character(80) :: ThetaDistrbType
  real(8)       :: ThetaSigmaX
  real(8)       :: ThetaSigmaZ
  real(8)       :: ThetaMax
  real(8)       :: ThetaCenterX
  real(8)       :: ThetaCenterZ

  character(80) :: VelDistrbType
  real(8)       :: VelX
  real(8)       :: VelZ


contains
  subroutine gacchanprm_init
    !--- モジュール読み込み
    use fileset, only: cfgfile
    
    !--- NAMELIST の定義
    NAMELIST /gacchanprm/ &
         & TempSfc, PressSfc, CpDry, MolWtDry, TempType, PressType, &
         & ExnerDistrbType, ExnerMax, ExnerSigmaX, ExnerSigmaZ, &
         &                  ExnerCenterX, ExnerCenterZ, &
         & ThetaDistrbType, ThetaMax, ThetaSigmaX, ThetaSigmaZ, &
         &                  ThetaCenterX, ThetaCenterZ, &
         & VelDistrbType, VelX, VelZ

    !--- 変数の取り出し
    open (10, FILE=cfgfile)
    read(10, NML=gacchanprm)
    close(10)
    

    !--- 変数の値のチェック
    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 ( ThetaSigmaX > 1 )  then 
       write(*,*) "gacchanprm.f90: SigmaX is > 1. "
       stop
    end if

    if ( ThetaSigmaZ > 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 ( ThetaCenterX > 1 ) then 
       write(*,*) "gacchanprm.f90: CenterX is > 1. "
       stop
    end if

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

  end subroutine gacchanprm_init
  
end module gacchanprm
