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