Class | gridset |
In: |
setup/gridset.f90
|
引数に与えられた NAMELIST ファイルから, 格子点情報を取得し, 保管するための変数型モジュール
Subroutine : | |
cfgfile : | character(*), intent(in) |
NAMELIST から情報を得て, 格子点を計算する
This procedure input/output NAMELIST#gridset .
subroutine gridset_init(cfgfile) ! !NAMELIST から情報を得て, 格子点を計算する ! !モジュール読み込み use DebugSet, only: DebugOn !暗黙の型宣言禁止 implicit none !入力変数 character(*), intent(in) :: cfgfile !内部変数 integer :: i, k integer, parameter :: kind = 8 !精度を表す !----------------------------------------------------------------- ! NAMELIST から情報を取得 !----------------------------------------------------------------- NAMELIST /gridset/ NX, NZ, Xmin, Xmax, Zmin, Zmax, SpcNum open (10, FILE=cfgfile) read(10, NML=gridset) close(10) !----------------------------------------------------------------- ! 格子点間隔計算 !----------------------------------------------------------------- DelX = (Xmax - Xmin) / real(NX, kind) DelZ = (Zmax - Zmin) / real(NZ, kind) !----------------------------------------------------------------- ! 物理的に意味のある領域の上限・下限を決める !-----------------------------------------------------------------; RegXMin = 0 RegXMax = NX RegZMin = 0 RegZMax = NZ ! !----------------------------------------------------------------- ! ! 物理的に意味のある領域の上限・下限を決める ! !-----------------------------------------------------------------; ! RegXMin = 1 ! RegXMax = NX ! RegZMin = 1 ! RegZMax = NZ ! ! !----------------------------------------------------------------- ! ! 壁に対応する領域の配列添え字を保管 ! !-----------------------------------------------------------------; ! WallXMin = 0 ! WallXMax = NX ! WallZMin = 0 ! WallZMax = NZ !----------------------------------------------------------------- ! 配列の上限・下限を決める !----------------------------------------------------------------- DimXMin = RegXMin - MarginX DimXMax = RegXMax + MarginX DimZMin = RegZMin - MarginZ DimZMax = RegZMax + MarginZ !----------------------------------------------------------------- ! グリッドの設定 !----------------------------------------------------------------- allocate( f_X(DimXMin:DimXMax), f_Z(DimZMin:DimZMax) ) do i = DimXMin, DimXMax f_X(i) = Xmin + DelX * ( real(i, kind) - RegXMin ) end do do k = DimZMin, DimZMax f_Z(k) = Zmin + DelZ * ( real(k, kind) - RegZMin ) end do !----------------------------------------------------------------- ! 半格子ずれたグリッドの設定. 等間隔を前提にしている. !----------------------------------------------------------------- allocate( s_X(DimXMin: DimXMax), s_Z(DimZMin: DimZMax) ) s_X(DimXMin+1:DimXMax) = ( f_X(DimXMin+1:DimXMax) + f_X(DimXMin:DimXMax-1) ) * 5.0d-1 s_X(DimXMin) = s_X(DimXMin+1) - DelX s_Z(DimZMin+1:DimZMax) = ( f_Z(DimZMin+1:DimZMax) + f_Z(DimZMin:DimZMax-1) ) * 5.0d-1 s_Z(DimZMin) = s_Z(DimZMin+1) - DelZ !----------------------------------------------------------------- ! デバッグモードか否かで, ファイル出力に用いる変数の大きさを変える !----------------------------------------------------------------- if (DebugOn) then FileNX = size(f_X, 1) FileNZ = size(f_Z, 1) FileXMin = DimXMin FileXMax = DimXMax FileZMin = DimZMin FileZMax = DimZMax else FileNX = NX FileNZ = NZ FileXMin = RegXMin + 1 FileXMax = RegXMax FileZMin = RegZMin + 1 FileZMax = RegZMax end if !----------------------------------------------------------------- ! 確認 !----------------------------------------------------------------- call MessageNotify( "M", "gridset_init", "XMin = %f", d=(/XMin/) ) call MessageNotify( "M", "gridset_init", "XMax = %f", d=(/XMax/) ) call MessageNotify( "M", "gridset_init", "ZMin = %f", d=(/ZMin/) ) call MessageNotify( "M", "gridset_init", "ZMax = %f", d=(/ZMax/) ) call MessageNotify( "M", "gridset_init", "DelX = %f", d=(/DelX/) ) call MessageNotify( "M", "gridset_init", "DelZ = %f", d=(/DelZ/) ) call MessageNotify( "M", "gridset_init", "NX = %d", i=(/NX/) ) call MessageNotify( "M", "gridset_init", "NZ = %d", i=(/NZ/) ) call MessageNotify( "M", "gridset_init", "SpcNum = %d", i=(/SpcNum/) ) call MessageNotify( "M", "gridset_init", "MarginX = %d", i=(/MarginX/) ) call MessageNotify( "M", "gridset_init", "MarginZ = %d", i=(/MarginZ/) ) call MessageNotify( "M", "gridset_init", "DimXMin = %d", i=(/DimXMin/) ) call MessageNotify( "M", "gridset_init", "DimXMax = %d", i=(/DimXMax/) ) call MessageNotify( "M", "gridset_init", "DimZMin = %d", i=(/DimZMin/) ) call MessageNotify( "M", "gridset_init", "DimZMax = %d", i=(/DimZMax/) ) call MessageNotify( "M", "gridset_init", "RegXMin = %d", i=(/RegXMin/) ) call MessageNotify( "M", "gridset_init", "RegXMax = %d", i=(/RegXMax/) ) call MessageNotify( "M", "gridset_init", "RegZMin = %d", i=(/RegZMin/) ) call MessageNotify( "M", "gridset_init", "RegZMax = %d", i=(/RegZMax/) ) call MessageNotify( "M", "gridset_init", "FileNX = %d", i=(/FileNX/)) call MessageNotify( "M", "gridset_init", "FileNZ = %d", i=(/FileNZ/)) call MessageNotify( "M", "gridset_init", "FileXMin = %d", i=(/FileXMin/)) call MessageNotify( "M", "gridset_init", "FileXMax = %d", i=(/FileXMax/)) call MessageNotify( "M", "gridset_init", "FileZMin = %d", i=(/FileZMin/)) call MessageNotify( "M", "gridset_init", "FileZMax = %d", i=(/FileZMax/)) end subroutine gridset_init