tem_variable_loadMapping_single Subroutine

public subroutine tem_variable_loadMapping_single(expectedName, conf, thandle, varDict, varSys, nComp, solverData_evalElem, ErrCode)

Loads the variable mapping from a table for single expected name. A variable mapping is used to link a user defined variable to a variable expected from, e.g., an equation system. These mappings are stored in varDict, which basically is a dictionary, whereas the key contains the name of the expected variable and the value contains the name of the user defined variable in the variable table.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: expectedName

Expected variable name from config file

type(flu_State), intent(in) :: conf

lua config file

integer, intent(in) :: thandle

table handle

type(grw_stringkeyvaluepairarray_type), intent(inout) :: varDict

The dictionary that contains the mapping between expected variables and the actual variables defined by the user.

type(tem_varSys_type), intent(inout) :: varSys

Variable system to append anonymous variables to.

integer, intent(in), optional :: nComp

Number of components we expect for this variable.

type(tem_varSys_solverData_evalElem_type), intent(in), optional :: solverData_evalElem

Routine to convert point information into an element representation.

integer, intent(out), optional :: ErrCode

Error code


Calls

proc~~tem_variable_loadmapping_single~~CallsGraph proc~tem_variable_loadmapping_single tem_variable_loadMapping_single aot_exists aot_exists proc~tem_variable_loadmapping_single->aot_exists aot_get_val aot_get_val proc~tem_variable_loadmapping_single->aot_get_val interface~append~4 append proc~tem_variable_loadmapping_single->interface~append~4 interface~tem_load_spacetime tem_load_spacetime proc~tem_variable_loadmapping_single->interface~tem_load_spacetime interface~tem_varsys_append_stfun tem_varSys_append_stfun proc~tem_variable_loadmapping_single->interface~tem_varsys_append_stfun proc~tem_spacetime_hash_id tem_spacetime_hash_id proc~tem_variable_loadmapping_single->proc~tem_spacetime_hash_id proc~append_ga_stringkeyvaluepair append_ga_stringkeyvaluepair interface~append~4->proc~append_ga_stringkeyvaluepair proc~append_ga_stringkeyvaluepair_vec append_ga_stringkeyvaluepair_vec interface~append~4->proc~append_ga_stringkeyvaluepair_vec proc~tem_load_spacetime_single tem_load_spacetime_single interface~tem_load_spacetime->proc~tem_load_spacetime_single proc~tem_load_spacetime_table tem_load_spacetime_table interface~tem_load_spacetime->proc~tem_load_spacetime_table proc~tem_varsys_append_stfun_raw tem_varSys_append_stFun_raw interface~tem_varsys_append_stfun->proc~tem_varsys_append_stfun_raw proc~tem_varsys_append_stfunvar tem_varSys_append_stFunVar interface~tem_varsys_append_stfun->proc~tem_varsys_append_stfunvar aot_fun_close aot_fun_close proc~tem_spacetime_hash_id->aot_fun_close aot_fun_id aot_fun_id proc~tem_spacetime_hash_id->aot_fun_id aot_fun_open aot_fun_open proc~tem_spacetime_hash_id->aot_fun_open interface~expand~3 expand proc~append_ga_stringkeyvaluepair->interface~expand~3 proc~append_ga_stringkeyvaluepair_vec->interface~expand~3 proc~tem_load_spacetime_single->aot_exists proc~tem_load_spacetime_single->aot_get_val proc~tem_load_spacetime_single->aot_fun_close proc~tem_load_spacetime_single->aot_fun_open proc~tem_load_spacetime_single->proc~tem_load_spacetime_single aot_reference_for aot_reference_for proc~tem_load_spacetime_single->aot_reference_for aot_table_open aot_table_open proc~tem_load_spacetime_single->aot_table_open aot_type_of aot_type_of proc~tem_load_spacetime_single->aot_type_of interface~tem_load_shape tem_load_shape proc~tem_load_spacetime_single->interface~tem_load_shape proc~load_spacetime_asconst load_spacetime_asConst proc~tem_load_spacetime_single->proc~load_spacetime_asconst proc~load_spacetime_predefined load_spacetime_predefined proc~tem_load_spacetime_single->proc~load_spacetime_predefined proc~tem_abort tem_abort proc~tem_load_spacetime_single->proc~tem_abort proc~tem_load_spacetime_table->proc~tem_load_spacetime_single aot_table_close aot_table_close proc~tem_load_spacetime_table->aot_table_close aot_table_length aot_table_length proc~tem_load_spacetime_table->aot_table_length proc~tem_load_spacetime_table->aot_table_open interface~append~29 append proc~tem_varsys_append_stfun_raw->interface~append~29 proc~tem_varsys_append_stfun_raw->proc~tem_abort proc~tem_varsys_append_dervar tem_varSys_append_derVar proc~tem_varsys_append_stfun_raw->proc~tem_varsys_append_dervar proc~tem_varsys_assignevaltype tem_varSys_assignEvalType proc~tem_varsys_append_stfun_raw->proc~tem_varsys_assignevaltype proc~tem_varsys_append_stfunvar->interface~append~29 proc~tem_varsys_append_stfunvar->proc~tem_abort proc~tem_varsys_append_stfunvar->proc~tem_varsys_append_dervar proc~tem_varsys_append_stfunvar->proc~tem_varsys_assignevaltype

Called by

proc~~tem_variable_loadmapping_single~~CalledByGraph proc~tem_variable_loadmapping_single tem_variable_loadMapping_single interface~tem_variable_loadmapping tem_variable_loadMapping interface~tem_variable_loadmapping->proc~tem_variable_loadmapping_single proc~tem_variable_loadmapping_vector tem_variable_loadMapping_vector interface~tem_variable_loadmapping->proc~tem_variable_loadmapping_vector proc~tem_variable_loadmapping_vector->proc~tem_variable_loadmapping_single proc~tem_load_bc_state tem_load_bc_state proc~tem_load_bc_state->interface~tem_variable_loadmapping

Source Code

  subroutine tem_variable_loadMapping_single( expectedName, conf, thandle, &
    &                                         varDict, varSys, ncomp,      &
    &                                         solverData_evalElem, ErrCode )
    ! --------------------------------------------------------------------------
    !> Expected variable name from config file
    character(len=*), intent(in) :: expectedName
    !> lua config file
    type(flu_state), intent(in) :: conf
    !> table handle
    integer, intent(in) :: thandle
    !> The dictionary that contains the mapping between expected variables
    !! and the actual variables defined by the user.
    type(grw_stringKeyValuePairArray_type), intent(inout) :: varDict
    !> Variable system to append anonymous variables to.
    type(tem_varSys_type), intent(inout) :: varSys
    !> Number of components we expect for this variable.
    integer, optional, intent(in) :: nComp

    !> Routine to convert point information into an element representation.
    type(tem_varSys_solverData_evalElem_type), &
      &  optional, intent(in) :: solverData_evalElem

    !> Error code
    integer, optional, intent(out) :: ErrCode
    ! --------------------------------------------------------------------------
    character(len=labelLen) :: varname
    character(len=labelLen) :: anony_name
    logical :: varExist
    integer :: errorCode
    type(tem_stringKeyValuePair_type) :: kvp
    type(tem_spacetime_fun_type), pointer :: stfun(:)
    real(kind=rk) :: numtest
    logical :: check_stfun
    ! --------------------------------------------------------------------------

    varExist = aot_exists( L       = conf,        &
      &                    thandle = thandle,     &
      &                    key     = expectedName )

    check_stfun = varExist

    ! if variable exist load space time function for that variable
    if (varExist) then
      write(logUnit(3),* ) 'Expected variable '  &
        & // trim(expectedName) // ' is defined'
      ! First check, whether this variable definition is a number.
      ! (They also satisfy strings).
      ! We do not accept numbers as variable names, instead this
      ! will be read as constant stfun.
      call aot_get_val( L       = conf,         &
        &               thandle = thandle,      &
        &               key     = expectedName, &
        &               val     = numtest,      &
        &               ErrCode = errorCode     )
      if (btest(errorCode, aoterr_WrongType)) then
        ! Not a number, try to interpret it as a string.
        call aot_get_val( L       = conf,         &
          &               thandle = thandle,      &
          &               key     = expectedName, &
          &               val     = varname,      &
          &               ErrCode = errorCode     )
        if (errorCode == 0) then
          ! Found a string, use it to refer to a variable.
          write(logUnit(1),*) 'Corresponding variable for ' &
            & // trim(expectedName) // ' found: ' // trim(varname)
          check_stfun = .false.
          kvp%key = expectedName
          kvp%value = varname
          call append(me = varDict, val = kvp)
        end if
      end if
      ! If the variable is not defined yet, try to get it as an anonymous
      ! variable in a space-time function.
      if (check_stfun) then
        write(logUnit(3),*) 'Did not find a variable name for ' &
          &                 // trim(expectedName)
        write(logUnit(3),*) 'Trying to load it as an anonymous space' &
          &                 // ' time function'
        allocate(stfun(1))
        call tem_load_spacetime(me      = stfun(1),           &
          &                     conf    = conf,               &
          &                     parent  = thandle,            &
          &                     key     = trim(expectedName), &
          &                     nComp   = nComp,              &
          &                     errCode = errorCode           )
        ! use global mesh for anonymous variable
        stfun(1)%subTree%useGlobalMesh = .true.
        if (errorCode == 0) then
          kvp%key = expectedName
          anony_name = tem_spacetime_hash_id(me=stfun(1), conf=conf)
          kvp%value = 'anon_' // trim(anony_name)
          call tem_varSys_append_stFun(                   &
            & varSys              = varSys,               &
            & stfun               = stfun,                &
            & varname             = kvp%value,            &
            & nComp               = nComp,                &
            & evalType            = 'firstonly_asglobal', &
            & solverData_evalElem = solverData_evalElem   )
          call append(me = varDict, val = kvp)
          write(logUnit(1),*) 'Found a spacetime function for ' &
            &                 // trim(expectedName)
        else
          write(logUnit(1),* ) 'Expected variable ' // trim(expectedName) &
            & // ' is NOT defined'
          deallocate(stfun)
        end if
      end if
    else
      write(logUnit(1),* ) 'Expected variable ' // trim(expectedName) &
        &                  // ' is NOT defined'
      errorCode = -1
    end if

    if (present(ErrCode)) ErrCode = errorCode

  end subroutine tem_variable_loadMapping_single