lookup_cell_cache Subroutine

public subroutine lookup_cell_cache(plan, nanchor, required, cached_cells, cached_blocks, have, lock)

required のセルを cache から読む。足りなければ cache ディレクトリを作ってロックを取り、待つ間に他の job が 足したセルを読み直す。それでも足りなければロックを保持したまま返し、呼び出し側が作ったセルを publish_cell_cache_and_unlock で書く。have は cache から得たセル。

Arguments

Type IntentOptional Attributes Name
type(fmm_plan_type), intent(in) :: plan
integer(kind=i32), intent(in) :: nanchor
logical, intent(in) :: required(:)
integer(kind=i32), intent(out), allocatable :: cached_cells(:)
real(kind=dp), intent(out), allocatable :: cached_blocks(:,:,:)
logical, intent(out) :: have(:)
type(periodic_cell_cache_lock_type), intent(out) :: lock

Calls

proc~~lookup_cell_cache~~CallsGraph proc~lookup_cell_cache lookup_cell_cache proc~acquire_file_lock acquire_file_lock proc~lookup_cell_cache->proc~acquire_file_lock proc~create_directories create_directories proc~lookup_cell_cache->proc~create_directories proc~read_periodic_operator_cache read_periodic_operator_cache proc~lookup_cell_cache->proc~read_periodic_operator_cache proc~release_file_lock release_file_lock proc~lookup_cell_cache->proc~release_file_lock proc~periodic_operator_checksum periodic_operator_checksum proc~read_periodic_operator_cache->proc~periodic_operator_checksum

Called by

proc~~lookup_cell_cache~~CalledByGraph proc~lookup_cell_cache lookup_cell_cache proc~precompute_periodic_root_operator precompute_periodic_root_operator proc~precompute_periodic_root_operator->proc~lookup_cell_cache proc~core_complete_plan_impl core_complete_plan_impl proc~core_complete_plan_impl->proc~precompute_periodic_root_operator proc~core_build_panel_plan_impl core_build_panel_plan_impl proc~core_build_panel_plan_impl->proc~core_complete_plan_impl proc~core_build_plan_impl core_build_plan_impl proc~core_build_plan_impl->proc~core_complete_plan_impl

Source Code

  subroutine lookup_cell_cache(plan, nanchor, required, cached_cells, cached_blocks, have, lock)
    type(fmm_plan_type), intent(in) :: plan
    integer(i32), intent(in) :: nanchor
    logical, intent(in) :: required(:)
    integer(i32), allocatable, intent(out) :: cached_cells(:)
    real(dp), allocatable, intent(out) :: cached_blocks(:, :, :)
    logical, intent(out) :: have(:)
    type(periodic_cell_cache_lock_type), intent(out) :: lock
    integer(i32) :: ncell
    integer :: directory_status, lock_status

    ncell = int(size(required), i32)
    call read_cell_cache(plan, nanchor, ncell, cached_cells, cached_blocks)
    have = .false.
    have(cached_cells) = .true.
    if (.not. any(required .and. .not. have)) return
    call create_directories(trim(plan%options%periodic_cache_dir), directory_status)
    if (directory_status /= filesystem_success) error stop 'Failed to create periodic operator cache directory.'
    call acquire_file_lock(trim(plan%periodic_cache_path)//'.lock', lock%fd, lock_status)
    if (lock_status /= filesystem_success) error stop 'Failed to lock periodic operator cache.'
    lock%held = .true.
    ! Another job may have added cells while this one waited for the lock.
    call read_cell_cache(plan, nanchor, ncell, cached_cells, cached_blocks)
    have = .false.
    have(cached_cells) = .true.
    if (.not. any(required .and. .not. have)) call release_cell_cache_lock(lock)
  end subroutine lookup_cell_cache