!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 basicprm
  implicit none 
  save

  real(8), allocatable  :: ss_DensBasicZ(:,:)  ! 乾燥大気の mol 当たりの質量
  real(8), allocatable  :: ss_CpBasicZ(:,:)    ! 定圧比熱
  real(8), allocatable  :: ss_CvBasicZ(:,:)    ! 定積比熱
  real(8), allocatable  :: ss_TempBasicZ(:,:)  ! 平均温度場
  real(8), allocatable  :: ss_PressBasicZ(:,:) ! 平均圧力場
  real(8), allocatable  :: ss_VthetaBasicZ(:,:)! 平均仮温位
  real(8), allocatable  :: ss_ExnerBasicZ(:,:) ! 平均場のエクスナー関数
  real(8), allocatable  :: ss_VelSoundBasicZ(:,:)   ! 平均場の音速の 2 乗
  real(8)               :: alpha

contains

  subroutine basicprm_init
    use gridset, only: DimXMin, DimXMax, DimZMin, DimZMax
    use physprm, only: GasR, TempRef, PressRef, MolWtWet, MolWtDry
    use if_display
    
    !--- 配列の初期化
    allocate( &
         & ss_DensBasicZ(DimXMin:DimXMax, DimZMin:DimZMax), &
         & ss_CpBasicZ(DimXMin:DimXMax, DimZMin:DimZMax), &
         & ss_CvBasicZ(DimXMin:DimXMax, DimZMin:DimZMax), &
         & ss_VthetaBasicZ(DimXMin:DimXMax, DimZMin:DimZMax), &
         & ss_TempBasicZ(DimXMin:DimXMax, DimZMin:DimZMax), &
         & ss_PressBasicZ(DimXMin:DimXMax, DimZMin:DimZMax), &
         & ss_ExnerBasicZ(DimXMin:DimXMax, DimZMin:DimZMax), &
         & ss_VelSoundBasicZ(DimXMin:DimXMax, DimZMin:DimZMax) )   
    
    !--- 音波減衰項の係数
!    alpha = 5.0d-6 * dx * dx / dts 
    alpha = 0.0d0

    !--- 比熱
    ss_CpBasicZ = 1.004d3    ! 定圧比熱
    ss_CvBasicZ = 7.17d2     ! 定積比熱

    !--- 温度
    ss_TempBasicZ = TempRef

    !--- 圧力
    ss_PressBasicZ = PressRef
    
    !--- エクスナー関数の平均
    ss_ExnerBasicZ = (ss_PressBasicZ / PressRef) ** ( GasR / ss_CpBasicZ)
!    call display(ss_ExnerBasicZ, "ss_ExnerBasicZ")
    
    !--- 仮温位
    ss_VthetaBasicZ = ss_TempBasicZ * MolWtWet / ( ss_ExnerBasicZ * MolWtDry )
!    call display(ss_VthetaBasicZ, "ss_VthetaBasicZ")
    
    !--- 密度
    ss_DensBasicZ &
         & = ss_PressBasicZ * ( ss_ExnerBasicZ ** (ss_CvBasicZ / GasR)) &
         &   / ( GasR * ss_VthetaBasicZ )
!    call display(ss_DensBasicZ, "ss_DensBasicZ")
    
    !--- 平均場の音速
    ss_VelSoundBasicZ &
         & = ss_CpBasicZ * GasR * ss_ExnerBasicZ * ss_VthetaBasicZ * MolWtDry &
         &   / ( ss_CvBasicZ * MolWtWet )
    ss_VelSoundBasicZ = sqrt( ss_VelSoundBasicZ )
    call display(ss_VelSoundBasicZ, "ss_VelSoundBasicZ")
    
  end subroutine basicprm_init

  
end module basicprm
