Load space time function as constant
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_spacetime_fun_type), | intent(inout) | :: | me |
spacetime fun information |
||
type(flu_State) | :: | conf |
lua state type |
|||
integer, | intent(out) | :: | errCode |
errCode = -1, if space time function is not defined as constant |
||
integer, | intent(in), | optional | :: | parent |
aotus parent handle |
|
character(len=*), | intent(in), | optional | :: | key |
name of the variable which is defined as spacetime function |
|
integer, | intent(in), | optional | :: | pos |
position of spacetime fun in a table |
|
integer, | intent(in), | optional | :: | nComp |
number of components of the variable |
subroutine load_spacetime_asConst( me, conf, errCode, parent, key, pos, &
& nComp )
! -------------------------------------------------------------------- !
!> spacetime fun information
type(tem_spacetime_fun_type), intent(inout) :: me
!> lua state type
type(flu_State) :: conf
!> errCode = -1, if space time function is not defined as constant
integer, intent(out) :: errCode
!> aotus parent handle
integer, intent(in), optional :: parent
!> name of the variable which is defined as spacetime function
character(len=*), intent(in), optional :: key
!> position of spacetime fun in a table
integer, intent(in), optional :: pos
!> number of components of the variable
integer, optional, intent(in) :: nComp
! -------------------------------------------------------------------- !
integer, allocatable :: vError(:)
logical :: check_varlen
! -------------------------------------------------------------------- !
errCode = 0
check_varlen = .true.
if (allocated(me%const)) deallocate(me%const)
if (present(nComp)) then
! There is a given number of components expected to be filled.
if (nComp > 1) then
! Only load the fixed sized vector if more than a single component is
! expected. Otherwise, we use the loading for arrays of unknown length
! below, as that als takes care of scalar number definitions.
check_varlen = .false. ! Check for fixed sized array.
allocate(me%const(nComp), vError(nComp))
write(logUnit(9),"(A,I0,A)") 'Trying to read constant as a vector with ', &
& nComp, ' components.'
if (present(key)) write(logUnit(9),*) ' key ', trim(key)
call aot_get_val( L = conf, &
& thandle = parent, &
& val = me%const, &
& key = key, &
& pos = pos, &
& ErrCode = vError )
if ( any(btest(vError, aoterr_Fatal)) ) then
write(logUnit(6),*) 'Attempted interpretation of spacetime function'
write(logUnit(6),*) 'as a vectorial constant failed.'
errCode = -1
else
me%fun_kind = 'const'
end if
end if
end if
if (check_varlen) then
! If ncomp is not provided, or ncomp == 1, we proceed and try to
! load the constant as a vector of unknown length.
write(logUnit(9),*) 'Trying to read constant as a vector'
write(logUnit(9),*) 'with unknown or at most 1 components.'
call aot_get_val( L = conf, &
& thandle = parent, &
& maxLength = 10000, &
& val = me%const, &
& key = key, &
& pos = pos, &
& ErrCode = vError )
if ( any(btest(vError, aoterr_Fatal)) ) then
write(logUnit(6),*) 'Attempted interpretation of spacetime function'
write(logUnit(6),*) 'as a vectorial constant failed.'
errCode = -1
else
me%fun_kind = 'const'
end if
end if
! If a certain number of components has been requested, ensure that we
! got exactly that number of components.
if (present(nComp)) then
if (.not. nComp == size(me%const)) then
me%fun_kind = 'none'
errCode = -1
end if
end if
end subroutine load_spacetime_asConst