subroutine gridset_set(flag)
implicit none
!内部変数
logical, intent(in) :: flag
integer, parameter :: kind = 8 !精度を表す
integer :: i,k
!-----------------------------------------------------------------
! 格子点間隔計算
!-----------------------------------------------------------------
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) )
allocate( p_X(DimXMin:DimXMax), r_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
p_X = f_X
r_Z = f_Z
!-----------------------------------------------------------------
! 半格子ずれたグリッドの設定. 等間隔を前提にしている.
!-----------------------------------------------------------------
allocate( s_X(DimXMin: DimXMax), s_Z(DimZMin: DimZMax) )
allocate( x_X(DimXMin: DimXMax), z_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
x_X = s_X
z_Z = f_Z
!-----------------------------------------------------------------
! デバッグモードか否かで, ファイル出力に用いる変数の大きさを変える
!-----------------------------------------------------------------
! if (DebugOn) then
if (flag) 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_set