load_spacetime_asConst Subroutine

private subroutine load_spacetime_asConst(me, conf, errCode, parent, key, pos, nComp)

Load space time function as constant

Arguments

Type IntentOptional 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


Calls

proc~~load_spacetime_asconst~~CallsGraph proc~load_spacetime_asconst load_spacetime_asConst proc~aot_get_val~2 aot_get_val proc~load_spacetime_asconst->proc~aot_get_val~2

Called by

proc~~load_spacetime_asconst~~CalledByGraph proc~load_spacetime_asconst load_spacetime_asConst proc~tem_load_spacetime_single tem_load_spacetime_single proc~tem_load_spacetime_single->proc~load_spacetime_asconst proc~tem_load_spacetime_single->proc~tem_load_spacetime_single proc~tem_load_spacetime_table tem_load_spacetime_table proc~tem_load_spacetime_table->proc~tem_load_spacetime_single interface~tem_load_spacetime tem_load_spacetime interface~tem_load_spacetime->proc~tem_load_spacetime_single interface~tem_load_spacetime->proc~tem_load_spacetime_table proc~tem_variable_loadmapping_single tem_variable_loadMapping_single proc~tem_variable_loadmapping_single->interface~tem_load_spacetime proc~tem_variable_load_single tem_variable_load_single proc~tem_variable_load_single->interface~tem_load_spacetime proc~tem_variable_loadmapping_vector tem_variable_loadMapping_vector proc~tem_variable_loadmapping_vector->proc~tem_variable_loadmapping_single interface~tem_variable_loadmapping tem_variable_loadMapping interface~tem_variable_loadmapping->proc~tem_variable_loadmapping_single interface~tem_variable_load tem_variable_load interface~tem_variable_load->proc~tem_variable_load_single proc~tem_variable_load_vector tem_variable_load_vector proc~tem_variable_load_vector->proc~tem_variable_load_single

Contents


Source Code

  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