Load spatial as constant
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rk), | allocatable | :: | const(:) |
value to be filled |
||
type(flu_State) | :: | conf |
lua state type |
|||
integer, | intent(out) | :: | errCode |
errCode = -1, if spatial function is not defined as constant |
||
integer, | intent(in) | :: | parent |
aotus parent handle |
||
character(len=*), | intent(in) | :: | key |
key is either "local_key" or "const" |
||
integer, | intent(in) | :: | nComp |
number of components of the variable |
subroutine load_spatial_asConst( const, conf, errCode, parent, key, nComp ) ! -------------------------------------------------------------------- ! !> value to be filled real(kind=rk), allocatable :: const(:) !> lua state type type(flu_State) :: conf !> errCode = -1, if spatial function is not defined as constant integer, intent(out) :: errCode !> aotus parent handle integer, intent(in) :: parent !> key is either "local_key" or "const" character(len=*), intent(in) :: key !> number of components of the variable integer, intent(in) :: nComp ! -------------------------------------------------------------------- ! integer, allocatable :: vError(:), vErr_NonExistent(:), vErr_WrongType(:) ! -------------------------------------------------------------------- ! errCode = 0 if (nComp == 1) then write(logUnit(5),*) 'Load spatial as single constant' allocate(const(nComp), vError(nComp)) call aot_get_val( L = conf, & & thandle = parent, & & val = const(1), & & key = key, & & ErrCode = vError(1) ) if (btest(vError(1), aoterr_NonExistent)) then ! if previous checks fails return errCode =-1 ! and set default kind = none and value = 1 write(logUnit(3),*) 'ERROR: Fatal error occured in loading ' & & // 'scalar constants' errCode = -1 return end if else !nComp > 1 write(logUnit(3),"(A,I0)") & & 'Load spatial as array of constant with nComp ', nComp !Try to load constant of nComp call aot_get_val( L = conf, & & thandle = parent, & & val = const, & & maxLength = nComp, & & key = key, & & ErrCode = vError ) if (size(const) == 0) then write(logUnit(3),*) 'Error loading array constant from key "'& & // trim(key) // '"' errCode = -1 return else ! if any error index is fatal then return errCode - 1 allocate(vErr_NonExistent(size(vError))) vErr_NonExistent = aoterr_NonExistent if(any(btest(vError, vErr_NonExistent))) then write(logUnit(3),*) 'ERROR: Fatal error occured in loading ' & & // 'array of constants with nComp:', nComp errCode = -1 return else if (size(const) /= nComp) then ! no fatal error but number of constant defined /= nComp write(logUnit(1),*) 'Spatial as constant. table size /= nComp', & & nComp call tem_abort() end if end if end if allocate(vErr_WrongType(size(vError))) vErr_WrongType = aoterr_WrongType if (any(btest(vError, vErr_WrongType))) then write(logUnit(1),*)'FATAL Error occured in definition of ' & & // 'the spatial' write(logUnit(1),*)'while retrieving spatial constant:' write(logUnit(1),*)'Variable has wrong type (should be a ' & & // 'real number)!' call tem_abort() end if end subroutine load_spatial_asConst