tem_get_required_Lua Subroutine

public subroutine tem_get_required_Lua(L, fileList, labelList)

Obtain the recorded open files by track_rq from the Lua state.

The track_rq function tracks all requires that are made after its call and stores the corresponding filename along with the given module name. These two lists can be retrieved with this routine.

Arguments

Type IntentOptional Attributes Name
type(flu_State) :: L

Lua state to get the requires from

character(len=PathLen), intent(out), allocatable :: fileList(:)

List of required filenames in the Lua state.

character(len=LabelLen), intent(out), allocatable :: labelList(:)

List of the module names associated to the corresponding files.


Source Code

  subroutine tem_get_required_Lua(L, fileList, labelList)
    ! ---------------------------------------------------------------------------
    !> Lua state to get the requires from
    type(flu_State) :: L
    !> List of required filenames in the Lua state.
    character(len=PathLen), allocatable, intent(out) :: fileList(:)
    !> List of the module names associated to the corresponding files.
    character(len=LabelLen), allocatable, intent(out) :: labelList(:)
    ! ---------------------------------------------------------------------------
    integer :: track_handle
    integer :: of_handle
    integer :: list_handle
    integer :: nFiles
    integer :: iError
    integer :: i
    ! ---------------------------------------------------------------------------

    call aot_table_open( L       = L,                                          &
      &                  thandle = track_handle,                               &
      &                  key     = "track_rq" )
    call aot_table_open( L       = L,                                          &
      &                  parent  = track_handle,                               &
      &                  thandle = of_handle,                                  &
      &                  key     = "open_files" )
    call aot_get_val( L       = L,                                             &
      &               val     = nFiles,                                        &
      &               ErrCode = iError,                                        &
      &               thandle = of_handle,                                     &
      &               key     = "count" )
    allocate(fileList(nFiles))
    allocate(labelList(nFiles))

    call aot_table_open( L       = L,                                          &
      &                  parent  = of_handle,                                  &
      &                  thandle = list_handle,                                &
      &                  key     = "name" )
    do i=1,nFiles
      call aot_get_val( L       = L,                                           &
        &               val     = labelList(i),                                &
        &               ErrCode = iError,                                      &
        &               thandle = list_handle,                                 &
        &               pos     = i )
    end do
    call aot_table_close(L, list_handle)

    call aot_table_open( L       = L,                                          &
      &                  parent  = of_handle,                                  &
      &                  thandle = list_handle,                                &
      &                  key     = "file" )
    do i=1,nFiles
      call aot_get_val( L       = L,                                           &
        &               val     = fileList(i),                                 &
        &               ErrCode = iError,                                      &
        &               thandle = list_handle,                                 &
        &               pos     = i )
    end do
    call aot_table_close(L, list_handle)
    call aot_table_close(L, of_handle)
    call aot_table_close(L, track_handle)

  end subroutine tem_get_required_Lua