tem_spatial_lua_for_index Function

private function tem_spatial_lua_for_index(fun_ref, conf, grwPnt, idx, nVals) result(res)

This function invokes the Lua function, which takes tem_grwPoints_type and evaluate a function at a point of given idx in grwPnt.

Lua function defined in the script is connected to the conf handle and return the result of the function. The Lua function takes barycentric coordinate as input argument i.e fun_name(x,y,z)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: fun_ref

Lua reference to the function to evaluate.

type(flu_State) :: conf

lua state

type(tem_grwPoints_type), intent(in) :: grwPnt

growing array of all spatial point of a variable

integer, intent(in) :: idx(nVals)

Index position to return a pre-store value or to compute

integer, intent(in) :: nVals

number of return values

Return Value real(kind=rk), (nVals)

return value


Calls

proc~~tem_spatial_lua_for_index~~CallsGraph proc~tem_spatial_lua_for_index tem_spatial_lua_for_index aot_fun_close aot_fun_close proc~tem_spatial_lua_for_index->aot_fun_close aot_fun_do aot_fun_do proc~tem_spatial_lua_for_index->aot_fun_do aot_fun_open aot_fun_open proc~tem_spatial_lua_for_index->aot_fun_open aot_fun_put aot_fun_put proc~tem_spatial_lua_for_index->aot_fun_put aot_top_get_val aot_top_get_val proc~tem_spatial_lua_for_index->aot_top_get_val proc~tem_abort tem_abort proc~tem_spatial_lua_for_index->proc~tem_abort mpi_abort mpi_abort proc~tem_abort->mpi_abort

Called by

proc~~tem_spatial_lua_for_index~~CalledByGraph proc~tem_spatial_lua_for_index tem_spatial_lua_for_index interface~tem_spatial_lua_for tem_spatial_lua_for interface~tem_spatial_lua_for->proc~tem_spatial_lua_for_index proc~tem_spatial_for_coord tem_spatial_for_coord proc~tem_spatial_for_coord->interface~tem_spatial_lua_for proc~tem_spatial_for_treeids tem_spatial_for_treeIDs proc~tem_spatial_for_treeids->interface~tem_spatial_lua_for proc~tem_spatial_scalar_for_index tem_spatial_scalar_for_index proc~tem_spatial_scalar_for_index->interface~tem_spatial_lua_for proc~tem_spatial_scalar_for_index->proc~tem_spatial_for_coord proc~tem_spatial_vector_for_coord tem_spatial_vector_for_coord proc~tem_spatial_vector_for_coord->interface~tem_spatial_lua_for proc~tem_spatial_vector_for_index tem_spatial_vector_for_index proc~tem_spatial_vector_for_index->interface~tem_spatial_lua_for proc~tem_spatial_vector_for_index->proc~tem_spatial_vector_for_coord proc~tem_spatial_vector_for_treeids tem_spatial_vector_for_treeIDs proc~tem_spatial_vector_for_treeids->interface~tem_spatial_lua_for interface~tem_spatial_for tem_spatial_for interface~tem_spatial_for->proc~tem_spatial_for_coord interface~tem_spatial_for->proc~tem_spatial_for_treeids interface~tem_spatial_for->proc~tem_spatial_scalar_for_index interface~tem_spatial_for->proc~tem_spatial_vector_for_coord interface~tem_spatial_for->proc~tem_spatial_vector_for_index interface~tem_spatial_for->proc~tem_spatial_vector_for_treeids proc~tem_spacetime_for_coord tem_spacetime_for_coord proc~tem_spacetime_for_coord->interface~tem_spatial_for proc~tem_spacetime_for_treeids tem_spacetime_for_treeIDs proc~tem_spacetime_for_treeids->interface~tem_spatial_for proc~tem_spacetime_scalar_for_index tem_spacetime_scalar_for_index proc~tem_spacetime_scalar_for_index->interface~tem_spatial_for proc~tem_spacetime_vector_for_coord tem_spacetime_vector_for_coord proc~tem_spacetime_vector_for_coord->interface~tem_spatial_for proc~tem_spacetime_vector_for_index tem_spacetime_vector_for_index proc~tem_spacetime_vector_for_index->interface~tem_spatial_for proc~tem_spacetime_vector_for_treeids tem_spacetime_vector_for_treeIDs proc~tem_spacetime_vector_for_treeids->interface~tem_spatial_for proc~tem_spatial_scalar_storeval tem_spatial_scalar_storeVal proc~tem_spatial_scalar_storeval->interface~tem_spatial_for proc~tem_spatial_vector_storeval tem_spatial_vector_storeVal proc~tem_spatial_vector_storeval->interface~tem_spatial_for

Source Code

  function tem_spatial_lua_for_index( fun_ref, conf, grwPnt, idx, nVals ) &
    &                                 result(res)
    ! -------------------------------------------------------------------- !
    !> Lua reference to the function to evaluate.
    integer, intent(in) :: fun_ref
    !> number of return values
    integer, intent(in) :: nVals
    !> growing array of all spatial point of a variable
    type(tem_grwPoints_type), intent(in) :: grwPnt
    !> Index position to return a pre-store value or to compute
    integer, intent(in) :: idx(nVals)
    !> lua state
    type(flu_State) :: conf
    !> return value
    real(kind=rk) :: res(nVals)
    ! -------------------------------------------------------------------- !
    type(aot_fun_type) :: fun
    integer :: iError
    integer :: iDir, jDir
    real(kind=rk) :: coord(3)
    ! -------------------------------------------------------------------- !

    call aot_fun_open(L=conf, fun=fun, ref=fun_ref)

    do iDir = 1, nVals
      coord(:) =  (/ grwPnt%coordX%val( idx(iDir) ), &
        &            grwPnt%coordY%val( idx(iDir) ), &
        &            grwPnt%coordZ%val( idx(iDir) ) /)
      do jDir = 1, 3
        call aot_fun_put( L=conf, fun=fun, arg=coord(jDir) )
      end do
      call aot_fun_do(L=conf, fun=fun, nresults=1)
      call aot_top_get_val(L=conf, val=res(iDir), ErrCode=iError)
      if ( btest(iError,aoterr_Fatal) ) then
        write(logunit(0),*) "ERROR Obtaining a spatial function"
        write(logunit(0),*) "Probably wrong number of components returned"
        write(logunit(0),*) "or a scalar was return as a lua table"
        write(logunit(0),*) 'Expected nComp: 1'
        write(logunit(0),*) 'ErrorCodes: ', iError
        write(logunit(0),*) "Check return values of your Lua functions!"
        call tem_abort()
      end if
    end do

    call aot_fun_close(L=conf, fun=fun)

  end function tem_spatial_lua_for_index