subroutine bscset_init(cfgfile)
!暗黙の型宣言禁止
implicit none
!変数の定義
character(*), intent(in) :: cfgfile
real(8) :: xz_DensBasicZ(DimXMin:DimXMax, DimZMin:DimZMax)
real(8) :: xz_PressBasicZ(DimXMin:DimXMax, DimZMin:DimZMax)
real(8) :: xz_ExnerBasicZ(DimXMin:DimXMax, DimZMin:DimZMax)
real(8) :: xz_TempBasicZ(DimXMin:DimXMax, DimZMin:DimZMax)
real(8) :: xz_PotTempBasicZ(DimXMin:DimXMax, DimZMin:DimZMax)
real(8) :: xz_VelSoundBasicZ(DimXMin:DimXMax, DimZMin:DimZMax)
real(8) :: xza_MixRtBasicZ(DimXMin:DimXMax, DimZMin:DimZMax, SpcNum)
real(8) :: xz_EffMolWtBasicZ(DimXMin:DimXMax, DimZMin:DimZMax)
real(8) :: z_TempBasicZ(DimZMin:DimZMax)
real(8) :: z_PressBasicZ(DimZMin:DimZMax)
real(8) :: MolFrIni(SpcNum)
real(8) :: xza_MolFr(DimXMin:DimXMax, DimZMin:DimZMax, SpcNum)
real(8) :: za_MolFr(DimZMin:DimZMax, SpcNum)
real(8) :: xza_MixRtDivMolWt(DimXMin:DimXMax, DimZMin:DimZMax, SpcNum)
real(8) :: Humidity = 0.0d0 !相対湿度
character(20) :: Type = "" !基本場の温度設定, 'Dry' or 'Moist'
real(8) :: TempStrat = 200.0d0 !成層圏の温度 [k]
real(8) :: Dhight = 5.0d3 !重み関数のパラメータ [m]
real(8) :: z_llhum(DimZMin:DimZMax)
integer :: i, s
!---------------------------------------------------------------
! NAMELIST の定義
!---------------------------------------------------------------
NAMELIST /basicenv/ Type, Humidity, TempStrat, Dhight
!---------------------------------------------------------------
! 配列の初期化
!---------------------------------------------------------------
xz_PressBasicZ = 0.0d0
xz_ExnerBasicZ = 0.0d0
xz_TempBasicZ = 0.0d0
xz_PotTempBasicZ = 0.0d0
xz_VelSoundBasicZ = 0.0d0
xza_MixRtBasicZ = 0.0d0
xz_EffMolWtBasicZ = 0.0d0
z_TempBasicZ = 0.0d0
z_PressBasicZ = 0.0d0
za_MolFr = 0.0d0
!---------------------------------------------------------------
! Type を元に, 温度, 圧力, 組成を決める
!---------------------------------------------------------------
MolFrIni = SpcWetMolFr(1:SpcNum)
open (10, FILE=cfgfile)
read(10, NML=basicenv)
close(10)
select case(Type)
case("Dry") ! 乾燥断熱的な初期場
call ECCM_Dry( MolFrIni, Humidity, z_TempBasicZ, z_PressBasicZ, za_MolFr )
call bscset_upper(Humidity, TempStrat, Dhight, z_TempBasicZ, z_PressBasicZ)
case("Wet") ! 湿潤断熱的な初期場
call ECCM_Wet( MolFrIni, Humidity, z_TempBasicZ, z_PressBasicZ, za_MolFr )
call bscset_upper(Humidity, TempStrat, Dhight, z_TempBasicZ, z_PressBasicZ)
case("Yamasaki1983") ! Yamasaki(1983)の温度と相対湿度の観測値を使用する場合
call ECCM_Ymazaki1983( z_TempBasicZ, z_PressBasicZ, za_MolFr )
case("Takemi2007") ! Takemi(2007)の基本場を使用する場合
call ECCM_Takemi2007( z_TempBasicZ, z_PressBasicZ, za_MolFr, z_llhum )
end select
! 2 次元配列に格納
do i = DimXMin, DimXMax
xz_TempBasicZ(i,:) = z_TempBasicZ
xz_PressBasicZ(i,:) = z_PressBasicZ
end do
!境界条件
call BoundaryXCyc_xz( xz_TempBasicZ )
call BoundaryZSym_xz( xz_TempBasicZ )
call BoundaryXCyc_xz( xz_PressBasicZ )
call BoundaryZSym_xz( xz_PressBasicZ )
!---------------------------------------------------------------
! 混合比
!---------------------------------------------------------------
!水平方向には一様
do i = DimXMin, DimXMax
xza_MolFr(i,:,:) = za_MolFr
end do
!気相のモル比を混合比に変換
do s = 1, SpcNum
xza_MixRtBasicZ(:,:,s) = xza_MolFr(:,:,s) * MolWtWet(s) / MolWtDry
end do
!境界条件
call BoundaryXCyc_xza( xza_MixRtBasicZ )
call BoundaryZSym_xza( xza_MixRtBasicZ )
!---------------------------------------------------------------
! 分子量の効果
!---------------------------------------------------------------
do s = 1, SpcNum
xza_MixRtDivMolWt(:,:,s) = xza_MixRtBasicZ(:,:,s) / MolWtWet(s)
end do
xz_EffMolWtBasicZ = (1.0d0 + sum(xza_MixRtBasicZ,3) ) / ( MolWtDry * ((1.0d0 / MolWtDry) + sum(xza_MixRtDivMolWt,3)) )
!境界条件
call BoundaryXCyc_xz( xz_EffMolWtBasicZ )
call BoundaryZSym_xz( xz_EffMolWtBasicZ )
!---------------------------------------------------------------
! 温位
!---------------------------------------------------------------
xz_PotTempBasicZ = xz_TempBasicZ * (PressBasis / xz_PressBasicZ) ** (GasRDry / CpDry)
!境界条件
call BoundaryXCyc_xz( xz_PotTempBasicZ )
call BoundaryZSym_xz( xz_PotTempBasicZ )
!---------------------------------------------------------------
! エクスナー関数
!---------------------------------------------------------------
xz_ExnerBasicZ = xz_TempBasicZ / xz_PotTempBasicZ
!境界条件
call BoundaryXCyc_xz( xz_ExnerBasicZ )
call BoundaryZSym_xz( xz_ExnerBasicZ )
!---------------------------------------------------------------
! 密度
!---------------------------------------------------------------
xz_DensBasicZ = PressBasis * (xz_ExnerBasicZ ** (CvDry / GasRDry)) / (GasRDry * xz_PotTempBasicZ / xz_EffMolWtBasicZ)
!境界条件
call BoundaryXCyc_xz( xz_DensBasicZ )
call BoundaryZSym_xz( xz_DensBasicZ )
!---------------------------------------------------------------
! 音速
!---------------------------------------------------------------
xz_VelSoundBasicZ = sqrt ( CpDry * GasRDry * xz_ExnerBasicZ * xz_PotTempBasicZ / (CvDry * xz_EffMolWtBasicZ) )
!境界条件
call BoundaryXCyc_xz( xz_VelSoundBasicZ )
call BoundaryZSym_xz( xz_VelSoundBasicZ )
!----------------------------------------------------------
! BasicSet モジュールに値を設定
!----------------------------------------------------------
call BasicSetArray_Init( xz_PressBasicZ, xz_ExnerBasicZ, xz_TempBasicZ, xz_PotTempBasicZ, xz_DensBasicZ, xz_VelSoundBasicZ, xza_MixRtBasicZ, xz_EffMolWtBasicZ )
end subroutine bscset_init