Load the stencil configuration from the lua file
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_stencilHeader_type) | :: | stencil |
stencil type to fill |
|||
integer, | intent(in) | :: | parent_handle |
handle of the parent table |
||
type(flu_State) | :: | conf |
lua state type |
subroutine tem_loadStencil( stencil, parent_handle, conf )
! -------------------------------------------------------------------- !
!> stencil type to fill
type(tem_stencilHeader_type) :: stencil
!> handle of the parent table
integer, intent(in) :: parent_handle
!> lua state type
type(flu_State) :: conf
! -------------------------------------------------------------------- !
integer :: nCartDiscVel, iCartDiscVel
integer :: nDiscreteVel, iDiscreteVel
integer :: discVel_handle
integer :: discVel_cart_handle
integer :: iError
! -------------------------------------------------------------------- !
! Usually, the stencil to read applies for all elements
! (Compute stencil)
stencil%useAll = .true.
! read the number of discrete velocities QQ
! @todo{ MH: Do we really need to read QQ explicitly?
! Isn't it enough to just count the number of entries below?}
call aot_get_val( L = conf, &
& thandle = parent_handle, &
& val = stencil%QQ, &
& ErrCode = iError, &
& key = 'QQ' )
! read the discrete velocities
call aot_table_open( L = conf, &
& parent = parent_handle, &
& thandle = discVel_handle, &
& key = 'disc_vel' )
! Check the length of the discrete velocity table
nDiscreteVel = aot_table_length( L = conf, &
& thandle = discVel_handle )
if (nDiscreteVel == stencil%QQ ) then
! If the number of discrete velocities matches the given stencil QQ
call init_stencilHeader( me = stencil, &
& QQN = stencil%QQN, &
& QQ = stencil%QQ, &
& useAll = .true. )
do iDiscreteVel = 1, nDiscreteVel
call aot_table_open( L = conf, &
& parent = discVel_handle, &
& thandle = discVel_cart_handle, &
& pos = iDiscreteVel )
nCartDiscVel = aot_table_length( L = conf, &
& thandle = discVel_cart_handle )
if (nCartDiscVel == 3) then
do iCartDiscVel = 1, nCartDiscVel
call aot_get_val( &
& L = conf, &
& thandle = discVel_cart_handle, &
& val = stencil%cxDir( iCartDiscVel, iDiscreteVel ), &
& ErrCode = iError, &
& pos = iCartDiscVel )
stencil%cxDirRK(iCartDiscVel, iDiscreteVel) &
& = real( stencil%cxDir(iCartDiscVel, iDiscreteVel), rk )
end do ! iCartDiscVel
else
write(logUnit(1),*) "Not every velocity has three cartesian " &
& //"coordinates!!"
end if
end do ! iDiscreteVel
call aot_table_close( L = conf, &
& thandle = discVel_cart_handle )
else
write(logUnit(1),*) "The number of discrete velocities for the " &
& //"new stencil does not match QQ!!"
STOP
end if
end subroutine tem_loadStencil