tem_load_temporal Subroutine

public subroutine tem_load_temporal(me, conf, parent, key)

This subroutine load temporal table defined for a boundary.\n

If temporal is defined as lua function then set kind = temporal_lua else if temporal block is defined then load temporal table for predefined Fortran function variables and set kind = temporal_\a function_name else temporal is a constant value and set kind = temporal_const.\n \n Valid definitions: \li Constant ~~~~~~~~~~~~~~~~~~~~~{.lua} temporal = 1.0 ~~~~~~~~~~~~~~~~~~~~~ \li lua_function ~~~~~~~~~~~~~~~~~~~~~ temporal = 'linear' ~~~~~~~~~~~~~~~~~~~~~ Example: \a linear lua function \verbatim function linear(iTime) local to_time = 1000 if iTime < to_time then return iTime/to_time else return 1.0 end end \endverbatim \li Predefined Fortran function ~~~~~~~~~~~~~~~~~~~~~{.lua} temporal = {predefined="Fortranfun_name", min_factor = 0.0, max_factor = 1.0, from_time = 0.0, to_time = 1000.0} ~~~~~~~~~~~~~~~~~~~~~ \li Data from a file (periodic data supported) ~~~~~~~~~~~~~~~~~~~~~{.lua} temporal = {predefined="datafile", filename='data.dat', -- path/name of the datafile intp='linear', -- interpolation between the time tics ('linear','none') periodic= true} -- is the data periodic? ~~~~~~~~~~~~~~~~~~~~~ \n

Arguments

Type IntentOptional Attributes Name
type(tem_temporal_type), intent(out) :: me

boundary temporal type

type(flu_State) :: conf

lua state

integer, intent(in) :: parent

parent handle contains temporal table

character(len=*), intent(in), optional :: key

state variable key string defined in lua


Calls

proc~~tem_load_temporal~~CallsGraph proc~tem_load_temporal tem_load_temporal proc~aot_table_open aot_table_open proc~tem_load_temporal->proc~aot_table_open proc~load_temporal_cos load_temporal_cos proc~tem_load_temporal->proc~load_temporal_cos proc~load_temporal_from_file load_temporal_from_file proc~tem_load_temporal->proc~load_temporal_from_file proc~aot_fun_open aot_fun_open proc~tem_load_temporal->proc~aot_fun_open proc~aot_get_val~2 aot_get_val proc~tem_load_temporal->proc~aot_get_val~2 proc~aot_reference_for aot_reference_for proc~tem_load_temporal->proc~aot_reference_for proc~aot_fun_close aot_fun_close proc~tem_load_temporal->proc~aot_fun_close proc~load_temporal_linear load_temporal_linear proc~tem_load_temporal->proc~load_temporal_linear proc~tem_abort tem_abort proc~tem_load_temporal->proc~tem_abort proc~load_temporal_cos->proc~aot_get_val~2 proc~load_temporal_cos->proc~tem_abort proc~load_temporal_from_file->proc~aot_table_open proc~load_temporal_from_file->proc~aot_get_val~2 proc~load_temporal_from_file->proc~tem_abort proc~load_datafile load_datafile proc~load_temporal_from_file->proc~load_datafile proc~load_temporal_linear->proc~aot_get_val~2 proc~load_temporal_linear->proc~tem_abort mpi_abort mpi_abort proc~tem_abort->mpi_abort proc~load_datafile->proc~tem_abort interface~init~22 init proc~load_datafile->interface~init~22 interface~append~23 append proc~load_datafile->interface~append~23 proc~tem_open tem_open proc~load_datafile->proc~tem_open proc~init_ga2d_real init_ga2d_real interface~init~22->proc~init_ga2d_real proc~append_arrayga2d_real append_arrayga2d_real interface~append~23->proc~append_arrayga2d_real proc~append_singlega2d_real append_singlega2d_real interface~append~23->proc~append_singlega2d_real proc~tem_open->proc~tem_abort proc~upper_to_lower upper_to_lower proc~tem_open->proc~upper_to_lower proc~newunit newunit proc~tem_open->proc~newunit

Called by

proc~~tem_load_temporal~~CalledByGraph proc~tem_load_temporal tem_load_temporal proc~load_spacetime_predefined load_spacetime_predefined proc~load_spacetime_predefined->proc~tem_load_temporal proc~tem_load_spacetime_single tem_load_spacetime_single proc~tem_load_spacetime_single->proc~load_spacetime_predefined 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

Contents

Source Code


Source Code

  subroutine tem_load_temporal( me, conf, parent, key )
    ! ---------------------------------------------------------------------------
    !> boundary temporal type
    type(tem_temporal_type), intent(out) :: me
    !> lua state
    type(flu_State) :: conf
    !> parent handle contains temporal table
    integer, intent(in) :: parent
    !> state variable key string defined in lua
    character(len=*), intent(in), optional :: key
    ! ---------------------------------------------------------------------------
    type(aot_fun_type) :: fun
    integer :: thandle
    integer :: iError
    character(len=labelLen) :: local_key
    ! ---------------------------------------------------------------------------

    if(present(key)) then
      local_key = trim(key)
    else
      local_key = 'temporal'
    endif

    ! First test for a lua function
    call aot_fun_open( L      = conf,                                          &
      &                parent = parent,                                        &
      &                fun    = fun,                                           &
      &                key    = trim( local_key ))

    me%conf = conf

    if (fun%handle /= 0) then
      ! This temporal modifier is defined as a Lua function
      me%kind = 'lua_fun'
      me%lua_fun_ref = aot_reference_for(conf)
      write(logUnit(1),*)'    Defined lua temporal function'
      call aot_fun_close( L = conf, fun = fun )
    else
      ! It is not defined as a function, try to interpret it as a table
      call aot_table_open( L       = conf,                                     &
        &                  thandle = thandle,                                  &
        &                  parent  = parent,                                   &
        &                  key     = trim( local_key ))
      if (thandle /= 0) then
        call aot_get_val( L       = conf,                                      &
          &               thandle = thandle,                                   &
          &               key     = 'predefined',                              &
          &               val     = me%kind,                                   &
          &               default = 'unknown',                                 &
          &               ErrCode = iError)

        write(logUnit(1),*)'   A predefined temporal function is chosen: '&
          &                //trim(me%kind)
        select case(trim(me%kind))
        case('linear', 'smooth')
          ! Load the standard parameters necessary to describe the
          ! temporal behavior of the BC.
          call load_temporal_linear( me      = me%linear, &
            &                         conf    = conf,          &
            &                         thandle = thandle )
        case('datafile')
          ! Load the filename for the datafile
          call load_temporal_from_file( me      = me%from_file,               &
            &                            conf    = conf,                       &
            &                            thandle = thandle )
        case('cos')
          call load_temporal_cos( freq    = me%freq,&
            &                      phi     = me%phi, &
            &                      offset  = me%offset, &
            &                      conf    = conf,   &
            &                      thandle = thandle )
        case default
          write(logUnit(1),*)'ERROR in definition of the temporal '//         &
            &            ' boundary Conditions:'
          write(logUnit(1),*)'Selected an unknown temporal boundary'
          write(logUnit(1),*)trim(me%kind)
          call tem_abort()
        end select
      else
        ! As the entry for the variable is neither a function nor a table, try
        ! to interpret it as a constant variable
        call aot_get_val( L       = conf,                                      &
          &               thandle = parent,                                    &
          &               key     = trim(local_key),                           &
          &               val     = me%const,                                  &
          &               ErrCode = iError )
        if (btest(iError, aoterr_WrongType)) then
          write(logUnit(1),*)'FATAL Error occured in definition of the '//     &
            &                'temporal boundary conditions'
          write(logUnit(1),*)'while retrieving temporal constant:'
          write(logUnit(1),*)'Variable has wrong type (should be a '//         &
            &                'real number)!'
          write(logUnit(1),*)'STOPPING'
          call tem_abort()
        end if
        if (btest(iError, aoterr_NonExistent)) then
          ! "temporal" variable not specified
          me%kind = 'none'
          me%const = 1.0_rk
        else
          me%kind = 'const'
        end if
      end if
    end if

  end subroutine tem_load_temporal