base Module

  • The Purdue Swiftest Team - David A. Minton, Carlisle A. Wishard, Jennifer L.L. Pouplin, and Jacob R. Elliott
  • 1457 statements
  • Source File

Base type definitions. This allows the collision and encounter modules to be defined before the swiftest module.


Uses

  • module~~base~~UsesGraph module~base base globals globals module~base->globals module~coarray coarray module~base->module~coarray module~coarray->globals

Used by

  • module~~base~~UsedByGraph module~base base module~collision collision module~collision->module~base module~encounter encounter module~collision->module~encounter module~encounter->module~base module~netcdf_io netcdf_io module~encounter->module~netcdf_io module~io_progress_bar io_progress_bar module~io_progress_bar->module~base module~netcdf_io->module~base module~solver solver module~solver->module~base module~swiftest swiftest module~swiftest->module~base module~swiftest->module~collision module~swiftest->module~encounter module~swiftest->module~io_progress_bar module~swiftest->module~netcdf_io module~swiftest->module~solver module~walltime walltime module~swiftest->module~walltime module~tides tides module~tides->module~base module~walltime->module~base module~bindings_module bindings_module module~bindings_module->module~swiftest module~fraggle fraggle module~fraggle->module~swiftest module~helio helio module~helio->module~swiftest module~whm whm module~helio->module~whm module~rmvs rmvs module~rmvs->module~swiftest module~rmvs->module~whm module~s_coarray_clone s_coarray_clone module~s_coarray_clone->module~swiftest module~s_coarray_collect s_coarray_collect module~s_coarray_collect->module~swiftest module~s_collision_check s_collision_check module~s_collision_check->module~collision module~s_collision_check->module~swiftest module~symba symba module~s_collision_check->module~symba module~s_collision_generate s_collision_generate module~s_collision_generate->module~collision module~s_collision_generate->module~swiftest module~s_collision_io s_collision_io module~s_collision_io->module~collision module~s_collision_io->module~swiftest module~s_collision_regime s_collision_regime module~s_collision_regime->module~collision module~s_collision_regime->module~swiftest module~s_collision_resolve s_collision_resolve module~s_collision_resolve->module~collision module~s_collision_resolve->module~swiftest module~s_collision_util s_collision_util module~s_collision_util->module~collision module~s_collision_util->module~swiftest module~s_encounter_check s_encounter_check module~s_encounter_check->module~encounter module~s_encounter_check->module~swiftest module~s_encounter_io s_encounter_io module~s_encounter_io->module~encounter module~s_encounter_io->module~swiftest module~s_encounter_util s_encounter_util module~s_encounter_util->module~encounter module~s_encounter_util->module~swiftest module~s_fraggle_generate s_fraggle_generate module~s_fraggle_generate->module~swiftest module~s_fraggle_generate->module~fraggle module~s_fraggle_generate->module~symba module~s_fraggle_util s_fraggle_util module~s_fraggle_util->module~swiftest module~s_fraggle_util->module~fraggle module~s_helio_drift s_helio_drift module~s_helio_drift->module~swiftest module~s_helio_drift->module~helio module~s_helio_gr s_helio_gr module~s_helio_gr->module~swiftest module~s_helio_gr->module~helio module~s_helio_kick s_helio_kick module~s_helio_kick->module~swiftest module~s_helio_kick->module~helio module~s_helio_step s_helio_step module~s_helio_step->module~swiftest module~s_helio_step->module~helio module~s_helio_util s_helio_util module~s_helio_util->module~swiftest module~s_helio_util->module~helio module~s_netcdf_io_implementations s_netcdf_io_implementations module~s_netcdf_io_implementations->module~netcdf_io module~s_operator_cross s_operator_cross module~s_operator_cross->module~swiftest module~s_rmvs_discard s_rmvs_discard module~s_rmvs_discard->module~swiftest module~s_rmvs_discard->module~rmvs module~s_rmvs_encounter_check s_rmvs_encounter_check module~s_rmvs_encounter_check->module~swiftest module~s_rmvs_encounter_check->module~rmvs module~s_rmvs_kick s_rmvs_kick module~s_rmvs_kick->module~swiftest module~s_rmvs_kick->module~rmvs module~s_rmvs_step s_rmvs_step module~s_rmvs_step->module~swiftest module~s_rmvs_step->module~rmvs module~s_rmvs_util s_rmvs_util module~s_rmvs_util->module~swiftest module~s_rmvs_util->module~rmvs module~s_shgrav_accel s_shgrav_accel module~s_shgrav_accel->module~swiftest module~shgrav shgrav module~s_shgrav_accel->module~shgrav module~s_shgrav_pot s_shgrav_pot module~s_shgrav_pot->module~swiftest module~s_shgrav_pot->module~shgrav module~s_swiftest_coarray s_swiftest_coarray module~s_swiftest_coarray->module~swiftest module~s_swiftest_discard s_swiftest_discard module~s_swiftest_discard->module~swiftest module~s_swiftest_drift s_swiftest_drift module~s_swiftest_drift->module~swiftest module~s_swiftest_driver s_swiftest_driver module~s_swiftest_driver->module~swiftest module~s_swiftest_gr s_swiftest_gr module~s_swiftest_gr->module~swiftest module~s_swiftest_io s_swiftest_io module~s_swiftest_io->module~swiftest module~s_swiftest_io->module~symba module~s_swiftest_kick s_swiftest_kick module~s_swiftest_kick->module~swiftest module~s_swiftest_obl s_swiftest_obl module~s_swiftest_obl->module~swiftest module~s_swiftest_obl->module~shgrav module~s_swiftest_orbel s_swiftest_orbel module~s_swiftest_orbel->module~swiftest module~s_swiftest_user s_swiftest_user module~s_swiftest_user->module~swiftest module~s_swiftest_util s_swiftest_util module~s_swiftest_util->module~swiftest module~s_swiftest_util->module~fraggle module~s_swiftest_util->module~helio module~s_swiftest_util->module~rmvs module~s_swiftest_util->module~symba module~s_swiftest_util->module~whm module~s_symba_discard s_symba_discard module~s_symba_discard->module~swiftest module~s_symba_discard->module~symba module~s_symba_drift s_symba_drift module~s_symba_drift->module~swiftest module~s_symba_drift->module~symba module~s_symba_encounter_check s_symba_encounter_check module~s_symba_encounter_check->module~swiftest module~s_symba_encounter_check->module~symba module~s_symba_gr s_symba_gr module~s_symba_gr->module~swiftest module~s_symba_gr->module~symba module~s_symba_kick s_symba_kick module~s_symba_kick->module~swiftest module~s_symba_kick->module~symba module~s_symba_step s_symba_step module~s_symba_step->module~swiftest module~s_symba_step->module~symba module~s_symba_util s_symba_util module~s_symba_util->module~swiftest module~s_symba_util->module~fraggle module~s_symba_util->module~symba module~s_tides_kick_getacch s_tides_kick_getacch module~s_tides_kick_getacch->module~swiftest module~s_tides_kick_getacch->module~tides module~s_tides_step_rot s_tides_step_rot module~s_tides_step_rot->module~swiftest module~s_tides_step_rot->module~tides module~s_walltime s_walltime module~s_walltime->module~swiftest module~s_walltime->module~walltime module~s_whm_coord s_whm_coord module~s_whm_coord->module~swiftest module~s_whm_coord->module~whm module~s_whm_gr s_whm_gr module~s_whm_gr->module~swiftest module~s_whm_gr->module~whm module~s_whm_kick s_whm_kick module~s_whm_kick->module~swiftest module~s_whm_kick->module~whm module~s_whm_step s_whm_step module~s_whm_step->module~swiftest module~s_whm_step->module~whm module~s_whm_util s_whm_util module~s_whm_util->module~swiftest module~s_whm_util->module~whm module~shgrav->module~swiftest module~symba->module~swiftest module~symba->module~helio module~whm->module~swiftest module~whm_drift whm_drift module~whm_drift->module~swiftest module~whm_drift->module~whm program~main main program~main->module~swiftest

Interfaces

public interface util_append

  • public subroutine base_util_append_arr_char_string(arr, source, nold, lsource_mask)

    Author
    David A. Minton

    Append a single array of character string type onto another. If the destination array is not allocated, or is not big
    enough, this will allocate space for it.

    Arguments

    Type IntentOptional Attributes Name
    character(len=STRMAX), intent(inout), dimension(:), allocatable :: arr

    Destination array

    character(len=STRMAX), intent(in), dimension(:), allocatable :: source

    Array to append

    integer(kind=I4B), intent(in), optional :: nold

    Extent of original array. If passed, the source array will begin at arr(nold+1). Otherwise, the size of arr will be used.

    logical, intent(in), optional, dimension(:) :: lsource_mask

    Logical mask indicating which elements to append to

  • public subroutine base_util_append_arr_DP(arr, source, nold, lsource_mask)

    Author
    David A. Minton

    Append a single array of double precision type onto another. If the destination array is not allocated, or is not big
    enough, this will allocate space for it.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=DP), intent(inout), dimension(:), allocatable :: arr

    Destination array

    real(kind=DP), intent(in), dimension(:), allocatable :: source

    Array to append

    integer(kind=I4B), intent(in), optional :: nold

    Extent of original array. If passed, the source array will begin at arr(nold+1). Otherwise, the size of arr will be used.

    logical, intent(in), optional, dimension(:) :: lsource_mask

    Logical mask indicating which elements to append to

  • public subroutine base_util_append_arr_DPvec(arr, source, nold, lsource_mask)

    Author
    David A. Minton

    Append a single array of double precision vector type of size (NDIM, n) onto another. If the destination array is not
    allocated, or is not big enough, this will allocate space for it.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=DP), intent(inout), dimension(:,:), allocatable :: arr

    Destination array

    real(kind=DP), intent(in), dimension(:,:), allocatable :: source

    Array to append

    integer(kind=I4B), intent(in), optional :: nold

    Extent of original array. If passed, the source array will begin at arr(nold+1). Otherwise, the size of arr will be used.

    logical, intent(in), optional, dimension(:) :: lsource_mask

    Logical mask indicating which elements to append to

  • public subroutine base_util_append_arr_I4B(arr, source, nold, lsource_mask)

    Author
    David A. Minton

    Append a single array of integer(I4B) onto another. If the destination array is not allocated, or is not big enough, this will allocate space for it.

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=I4B), intent(inout), dimension(:), allocatable :: arr

    Destination array

    integer(kind=I4B), intent(in), dimension(:), allocatable :: source

    Array to append

    integer(kind=I4B), intent(in), optional :: nold

    Extent of original array. If passed, the source array will begin at arr(nold+1). Otherwise, the size of arr will be used.

    logical, intent(in), optional, dimension(:) :: lsource_mask

    Logical mask indicating which elements to append to

  • public subroutine base_util_append_arr_logical(arr, source, nold, lsource_mask)

    Author
    David A. Minton

    Append a single array of logical type onto another. If the destination array is not allocated, or is not big enough, this will allocate space for it.

    Arguments

    Type IntentOptional Attributes Name
    logical, intent(inout), dimension(:), allocatable :: arr

    Destination array

    logical, intent(in), dimension(:), allocatable :: source

    Array to append

    integer(kind=I4B), intent(in), optional :: nold

    Extent of original array. If passed, the source array will begin at arr(nold+1). Otherwise, the size of arr will be used.

    logical, intent(in), optional, dimension(:) :: lsource_mask

    Logical mask indicating which elements to append to

public interface util_fill

  • public subroutine base_util_fill_arr_char_string(keeps, inserts, lfill_list)

    Author
    David A. Minton

    Performs a fill operation on a single array of type character strings. This is the inverse of a spill operation

    Arguments

    Type IntentOptional Attributes Name
    character(len=STRMAX), intent(inout), dimension(:), allocatable :: keeps

    Array of values to keep

    character(len=STRMAX), intent(in), dimension(:), allocatable :: inserts

    Array of values to insert into keep

    logical, intent(in), dimension(:) :: lfill_list

    Logical array of bodies to merge into the keeps

  • public subroutine base_util_fill_arr_DP(keeps, inserts, lfill_list)

    Author
    David A. Minton

    Performs a fill operation on a single array of type DP. This is the inverse of a spill operation

    Arguments

    Type IntentOptional Attributes Name
    real(kind=DP), intent(inout), dimension(:), allocatable :: keeps

    Array of values to keep

    real(kind=DP), intent(in), dimension(:), allocatable :: inserts

    Array of values to insert into keep

    logical, intent(in), dimension(:) :: lfill_list

    Logical array of bodies to merge into the keeps

  • public subroutine base_util_fill_arr_DPvec(keeps, inserts, lfill_list)

    Author
    David A. Minton

    Performs a fill operation on a single array of DP vectors with shape (NDIM, n) This is the inverse of a spill operation

    Arguments

    Type IntentOptional Attributes Name
    real(kind=DP), intent(inout), dimension(:,:), allocatable :: keeps

    Array of values to keep

    real(kind=DP), intent(in), dimension(:,:), allocatable :: inserts

    Array of values to insert into keep

    logical, intent(in), dimension(:) :: lfill_list

    Logical array of bodies to merge into the keeps

  • public subroutine base_util_fill_arr_I4B(keeps, inserts, lfill_list)

    Author
    David A. Minton

    Performs a fill operation on a single array of type I4B This is the inverse of a spill operation

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=I4B), intent(inout), dimension(:), allocatable :: keeps

    Array of values to keep

    integer(kind=I4B), intent(in), dimension(:), allocatable :: inserts

    Array of values to insert into keep

    logical, intent(in), dimension(:) :: lfill_list

    Logical array of bodies to merge into the keeps

  • public subroutine base_util_fill_arr_logical(keeps, inserts, lfill_list)

    Author
    David A. Minton

    Performs a fill operation on a single array of logicals This is the inverse of a spill operation

    Arguments

    Type IntentOptional Attributes Name
    logical, intent(inout), dimension(:), allocatable :: keeps

    Array of values to keep

    logical, intent(in), dimension(:), allocatable :: inserts

    Array of values to insert into keep

    logical, intent(in), dimension(:) :: lfill_list

    Logical array of bodies to merge into the keeps

public interface util_resize

  • public subroutine base_util_resize_arr_char_string(arr, nnew)

    Author
    David A. Minton

    Resizes an array component of type character string. nnew = 0 will deallocate.

    Arguments

    Type IntentOptional Attributes Name
    character(len=STRMAX), intent(inout), dimension(:), allocatable :: arr

    Array to resize

    integer(kind=I4B), intent(in) :: nnew

    New size

  • public subroutine base_util_resize_arr_DP(arr, nnew)

    Author
    David A. Minton

    Resizes an array component of double precision type. Passing nnew = 0 will deallocate.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=DP), intent(inout), dimension(:), allocatable :: arr

    Array to resize

    integer(kind=I4B), intent(in) :: nnew

    New size

  • public subroutine base_util_resize_arr_DPvec(arr, nnew)

    Author
    David A. Minton

    Resizes an array component of double precision vectors of size (NDIM, n). Passing nnew = 0 will deallocate.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=DP), intent(inout), dimension(:,:), allocatable :: arr

    Array to resize

    integer(kind=I4B), intent(in) :: nnew

    New size

  • public subroutine base_util_resize_arr_I4B(arr, nnew)

    Author
    David A. Minton

    Resizes an array component of integer type. Passing nnew = 0 will deallocate.

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=I4B), intent(inout), dimension(:), allocatable :: arr

    Array to resize

    integer(kind=I4B), intent(in) :: nnew

    New size

  • public subroutine base_util_resize_arr_logical(arr, nnew)

    Author
    David A. Minton

    Resizes an array component of logical type. Passing nnew = 0 will deallocate.

    Arguments

    Type IntentOptional Attributes Name
    logical, intent(inout), dimension(:), allocatable :: arr

    Array to resize

    integer(kind=I4B), intent(in) :: nnew

    New size

public interface util_sort

  • public pure subroutine base_util_sort_i4b(arr)

    Author
    David A. Minton

    Sort input integer array in place into ascending numerical order using quick sort. This algorithm works well for partially sorted arrays (which is usually the case here)

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=I4B), intent(inout), dimension(:) :: arr
  • public pure subroutine base_util_sort_index_I4B(arr, ind)

    Author
    David A. Minton

    Sort input integer array by index in ascending numerical order using quicksort. If ind is supplied already allocated, we assume it is an existing index array (e.g. a previously sorted array). If it is not allocated, this subroutine swiftest_allocates it.

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=I4B), intent(in), dimension(:) :: arr
    integer(kind=I4B), intent(inout), dimension(:), allocatable :: ind
  • public pure subroutine base_util_sort_index_I4B_I8Bind(arr, ind)

    Author
    David A. Minton

    Sort input integer array by index in ascending numerical order using quicksort. If ind is supplied already allocated, we assume it is an existing index array (e.g. a previously sorted array). If it is not allocated, this subroutine swiftest_allocates it.

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=I4B), intent(in), dimension(:) :: arr
    integer(kind=I8B), intent(inout), dimension(:), allocatable :: ind
  • public pure subroutine base_util_sort_index_I8B_I8Bind(arr, ind)

    Author
    David A. Minton

    Sort input integer array by index in ascending numerical order using quicksort. If ind is supplied already allocated, we assume it is an existing index array (e.g. a previously sorted array). If it is not allocated, this subroutine swiftest_allocates it.

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=I8B), intent(in), dimension(:) :: arr
    integer(kind=I8B), intent(inout), dimension(:), allocatable :: ind
  • public pure subroutine base_util_sort_sp(arr)

    Author
    David A. Minton

    Sort input DP precision array in place into ascending numerical order using quicksort.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=SP), intent(inout), dimension(:) :: arr
  • public pure subroutine base_util_sort_index_sp(arr, ind)

    Author
    David A. Minton

    Sort input DP precision array by index in ascending numerical order using quicksort. If ind is supplied already allocated, we assume it is an existing index array (e.g. a previously sorted array). If it is not allocated, this subroutine swiftest_allocates it.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=SP), intent(in), dimension(:) :: arr
    integer(kind=I4B), intent(inout), dimension(:), allocatable :: ind
  • public pure subroutine base_util_sort_dp(arr)

    Author
    David A. Minton

    Sort input DP precision array in place into ascending numerical order using quicksort.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=DP), intent(inout), dimension(:) :: arr
  • public pure subroutine base_util_sort_index_dp(arr, ind)

    Author
    David A. Minton

    Sort input DP precision array by index in ascending numerical order using quick sort. This algorithm works well for partially sorted arrays (which is usually the case here). If ind is supplied already allocated, we assume it is an existing index array (e.g. a previously sorted array). If it is not allocated, this subroutine swiftest_allocates it.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=DP), intent(in), dimension(:) :: arr
    integer(kind=I4B), intent(inout), dimension(:), allocatable :: ind

public interface util_sort_rearrange

  • public pure subroutine base_util_sort_rearrange_arr_char_string(arr, ind, n)

    Author
    David A. Minton

    Rearrange a single array of character string in-place from an index list.

    Arguments

    Type IntentOptional Attributes Name
    character(len=STRMAX), intent(inout), dimension(:), allocatable :: arr

    Destination array

    integer(kind=I4B), intent(in), dimension(:) :: ind

    Index to rearrange against

    integer(kind=I4B), intent(in) :: n

    Number of elements in arr and ind to rearrange

  • public pure subroutine base_util_sort_rearrange_arr_DP(arr, ind, n)

    Author
    David A. Minton

    Rearrange a single array of DP type in-place from an index list.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=DP), intent(inout), dimension(:), allocatable :: arr

    Destination array

    integer(kind=I4B), intent(in), dimension(:) :: ind

    Index to rearrange against

    integer(kind=I4B), intent(in) :: n

    Number of elements in arr and ind to rearrange

  • public pure subroutine base_util_sort_rearrange_arr_DPvec(arr, ind, n)

    Author
    David A. Minton

    Rearrange a single array of (NDIM,n) DP-type vectors in-place from an index list.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=DP), intent(inout), dimension(:,:), allocatable :: arr

    Destination array

    integer(kind=I4B), intent(in), dimension(:) :: ind

    Index to rearrange against

    integer(kind=I4B), intent(in) :: n

    Number of elements in arr and ind to rearrange

  • public pure subroutine base_util_sort_rearrange_arr_I4B(arr, ind, n)

    Author
    David A. Minton

    Rearrange a single array of integers in-place from an index list.

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=I4B), intent(inout), dimension(:), allocatable :: arr

    Destination array

    integer(kind=I4B), intent(in), dimension(:) :: ind

    Index to rearrange against

    integer(kind=I4B), intent(in) :: n

    Number of elements in arr and ind to rearrange

  • public pure subroutine base_util_sort_rearrange_arr_I4B_I8Bind(arr, ind, n)

    Author
    David A. Minton

    Rearrange a single array of integers in-place from an index list.

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=I4B), intent(inout), dimension(:), allocatable :: arr

    Destination array

    integer(kind=I8B), intent(in), dimension(:) :: ind

    Index to rearrange against

    integer(kind=I8B), intent(in) :: n

    Number of elements in arr and ind to rearrange

  • public pure subroutine base_util_sort_rearrange_arr_logical(arr, ind, n)

    Author
    David A. Minton

    Rearrange a single array of logicals in-place from an index list.

    Arguments

    Type IntentOptional Attributes Name
    logical, intent(inout), dimension(:), allocatable :: arr

    Destination array

    integer(kind=I4B), intent(in), dimension(:) :: ind

    Index to rearrange against

    integer(kind=I4B), intent(in) :: n

    Number of elements in arr and ind to rearrange

  • public pure subroutine base_util_sort_rearrange_arr_logical_I8Bind(arr, ind, n)

    Author
    David A. Minton

    Rearrange a single array of logicals in-place from an index list.

    Arguments

    Type IntentOptional Attributes Name
    logical, intent(inout), dimension(:), allocatable :: arr

    Destination array

    integer(kind=I8B), intent(in), dimension(:) :: ind

    Index to rearrange against

    integer(kind=I8B), intent(in) :: n

    Number of elements in arr and ind to rearrange

public interface util_spill

  • public subroutine base_util_spill_arr_char_string(keeps, discards, lspill_list, ldestructive)

    Author
    David A. Minton

    Performs a spill operation on a single array of type character strings This is the inverse of a spill operation

    Arguments

    Type IntentOptional Attributes Name
    character(len=STRMAX), intent(inout), dimension(:), allocatable :: keeps

    Array of values to keep

    character(len=STRMAX), intent(inout), dimension(:), allocatable :: discards

    Array of discards

    logical, intent(in), dimension(:) :: lspill_list

    Logical array of bodies to spill into the discards

    logical, intent(in) :: ldestructive

    Logical flag indicating whether or not this operation should alter the keeps array or not

  • public subroutine base_util_spill_arr_DP(keeps, discards, lspill_list, ldestructive)

    Author
    David A. Minton

    Performs a spill operation on a single array of type DP This is the inverse of a spill operation

    Arguments

    Type IntentOptional Attributes Name
    real(kind=DP), intent(inout), dimension(:), allocatable :: keeps

    Array of values to keep

    real(kind=DP), intent(inout), dimension(:), allocatable :: discards

    Array of discards

    logical, intent(in), dimension(:) :: lspill_list

    Logical array of bodies to spill into the discardss

    logical, intent(in) :: ldestructive

    Logical flag indicating whether or not this operation should alter the keeps array or not

  • public subroutine base_util_spill_arr_DPvec(keeps, discards, lspill_list, ldestructive)

    Author
    David A. Minton

    Performs a spill operation on a single array of DP vectors with shape (NDIM, n) This is the inverse of a spill operation

    Arguments

    Type IntentOptional Attributes Name
    real(kind=DP), intent(inout), dimension(:,:), allocatable :: keeps

    Array of values to keep

    real(kind=DP), intent(inout), dimension(:,:), allocatable :: discards

    Array discards

    logical, intent(in), dimension(:) :: lspill_list

    Logical array of bodies to spill into the discards

    logical, intent(in) :: ldestructive

    Logical flag indicating whether or not this operation should alter the keeps array or not

  • public subroutine base_util_spill_arr_I4B(keeps, discards, lspill_list, ldestructive)

    Author
    David A. Minton

    Performs a spill operation on a single array of type I4B This is the inverse of a spill operation

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=I4B), intent(inout), dimension(:), allocatable :: keeps

    Array of values to keep

    integer(kind=I4B), intent(inout), dimension(:), allocatable :: discards

    Array of discards

    logical, intent(in), dimension(:) :: lspill_list

    Logical array of bodies to spill into the discards

    logical, intent(in) :: ldestructive

    Logical flag indicating whether or not this operation should alter the keeps array or not

  • public subroutine base_util_spill_arr_I8B(keeps, discards, lspill_list, ldestructive)

    Author
    David A. Minton

    Performs a spill operation on a single array of type I4B This is the inverse of a spill operation

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=I8B), intent(inout), dimension(:), allocatable :: keeps

    Array of values to keep

    integer(kind=I8B), intent(inout), dimension(:), allocatable :: discards

    Array of discards

    logical, intent(in), dimension(:) :: lspill_list

    Logical array of bodies to spill into the discards

    logical, intent(in) :: ldestructive

    Logical flag indicating whether or not this operation should alter the keeps array or not

  • public subroutine base_util_spill_arr_logical(keeps, discards, lspill_list, ldestructive)

    Author
    David A. Minton

    Performs a spill operation on a single array of logicals This is the inverse of a spill operation

    Arguments

    Type IntentOptional Attributes Name
    logical, intent(inout), dimension(:), allocatable :: keeps

    Array of values to keep

    logical, intent(inout), dimension(:), allocatable :: discards

    Array of discards

    logical, intent(in), dimension(:) :: lspill_list

    Logical array of bodies to spill into the discards

    logical, intent(in) :: ldestructive

    Logical flag indicating whether or not this operation

    Read more…

public interface util_unique

  • public subroutine base_util_unique_DP(input_array, output_array, index_map)

    Author
    David A. Minton

    Takes an input unsorted integer array and returns a new array of sorted, unique values (DP version)

    Arguments

    Type IntentOptional Attributes Name
    real(kind=DP), intent(in), dimension(:) :: input_array

    Unsorted input array

    real(kind=DP), intent(out), dimension(:), allocatable :: output_array

    Sorted array of unique values

    integer(kind=I4B), intent(out), dimension(:), allocatable :: index_map

    An array of the same size as input_array that such that any for any index i,
    output_array(index_map(i)) = input_array(i)

  • public subroutine base_util_unique_I4B(input_array, output_array, index_map)

    Author
    David A. Minton

    Takes an input unsorted integer array and returns a new array of sorted, unique values (I4B version)

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=I4B), intent(in), dimension(:) :: input_array

    Unsorted input array

    integer(kind=I4B), intent(out), dimension(:), allocatable :: output_array

    Sorted array of unique values

    integer(kind=I4B), intent(out), dimension(:), allocatable :: index_map

    An array of the same size as input_array that such that any for any index i,
    output_array(index_map(i)) = input_array(i)


Abstract Interfaces

abstract interface

  • public subroutine abstract_io_dump_param(self, param_file_name)

    Arguments

    Type IntentOptional Attributes Name
    class(base_parameters), intent(in) :: self

    Output collection of parameters

    character(len=*), intent(in) :: param_file_name

    Parameter input file name (i.e. param.in)

abstract interface

  • public subroutine abstract_io_param_reader(self, unit, iotype, v_list, iostat, iomsg)

    Arguments

    Type IntentOptional Attributes Name
    class(base_parameters), intent(inout) :: self

    Collection of parameters

    integer(kind=I4B), intent(in) :: unit

    File unit number

    character(len=*), intent(in) :: iotype

    Dummy argument passed to the input/output procedure contains the text from the char-literal-constant, prefixed with DT. If you do not include a char-literal-constant, the iotype argument contains only DT.

    character(len=*), intent(in) :: v_list(:)

    The first element passes the integrator code to the reader

    integer(kind=I4B), intent(out) :: iostat

    IO status code

    character(len=*), intent(inout) :: iomsg

    Message to pass if iostat /= 0

abstract interface

  • public subroutine abstract_io_param_writer(self, unit, iotype, v_list, iostat, iomsg)

    Arguments

    Type IntentOptional Attributes Name
    class(base_parameters), intent(in) :: self

    Collection of parameters

    integer(kind=I4B), intent(in) :: unit

    File unit number

    character(len=*), intent(in) :: iotype

    Dummy argument passed to the input/output procedure contains the

    text from the char-literal-constant, prefixed with DT. If you do

    not include a char-literal-constant, the iotype argument contains

    only DT.

    integer(kind=I4B), intent(in) :: v_list(:)

    Not used in this procedure

    integer(kind=I4B), intent(out) :: iostat

    IO status code

    character(len=*), intent(inout) :: iomsg

    Message to pass if iostat /= 0

abstract interface

  • public subroutine abstract_io_read_in_param(self, param_file_name)

    Arguments

    Type IntentOptional Attributes Name
    class(base_parameters), intent(inout) :: self

    Current run configuration parameters

    character(len=*), intent(in) :: param_file_name

    Parameter input file name (i.e. param.in)

abstract interface

  • public subroutine abstract_util_dealloc_object(self)

    Arguments

    Type IntentOptional Attributes Name
    class(base_object), intent(inout) :: self

    Generic Swiftest object type


Derived Types

type, public, abstract ::  base_kinship

Class definition for the kinship relationships used in bookkeeping multiple collisions bodies in a single time step.

type, public, abstract ::  base_nbody_system

An abstract class for a basic Swiftest nbody system

type, public, abstract ::  base_object

An abstract class for a generic collection of Swiftest bodies

Type-Bound Procedures

procedure(abstract_util_dealloc_object), public, deferred :: dealloc

type, public, abstract ::  base_parameters

User defined parameters that are read in from the parameters input file. Each paramter is initialized to a default values.

Components

Type Visibility Attributes Name Initial
real(kind=QP), public :: DU2M = -1.0_QP

Converts distance unit to centimeters

real(kind=DP), public :: E_collisions = 0.0_DP

Energy lost from system due to collisions

real(kind=DP), public :: E_orbit_orig = 0.0_DP

Initial orbital energy

real(kind=DP), public :: E_untracked = 0.0_DP

Energy gained from system due to escaped bodies

real(kind=DP), public :: GMTINY = -1.0_DP

Smallest G*mass that is fully gravitating

real(kind=DP), public :: GMescape = 0.0_DP

Mass of bodies that escaped the system (used for bookeeping)

real(kind=DP), public :: GMtot_orig = 0.0_DP

Initial system mass

real(kind=DP), public :: GU = -1.0_DP

Universal gravitational constant in the system units

real(kind=DP), public, dimension(NDIM) :: L_escape = 0.0_DP

Angular momentum of escaped bodies (used for bookeeping)

real(kind=DP), public, dimension(NDIM) :: L_orbit_orig = 0.0_DP

Initial orbital angular momentum

real(kind=DP), public, dimension(NDIM) :: L_rot_orig = 0.0_DP

Initial rotational angular momentum vector

real(kind=DP), public, dimension(NDIM) :: L_total_orig = 0.0_DP

Initial total angular momentum vector

real(kind=QP), public :: MU2KG = -1.0_QP

Converts mass units to grams

real(kind=QP), public :: TU2S = -1.0_QP

Converts time units to seconds

character(len=STRMAX), public :: collision_model = "MERGE"

The Coll

character(len=NAMELEN), public :: display_style

Style of the output display [{“PROGRESS”}, “CLASSIC”, “QUIET”, “COMPACT”]).

integer(kind=I4B), public :: display_unit = OUTPUT_UNIT

File unit number for display (either to stdout or to a log file)

real(kind=DP), public :: dt = -1.0_DP

Time step

integer(kind=I4B), public :: dump_cadence = 10

Number of output steps between dumping simulation data to file

character(len=NAMELEN), public :: encounter_check_plpl = "ADAPTIVE"

Method used to compute pl-pl encounter checks.
Options are “TRIANGULAR”, “SORTSWEEP”, or “ADAPTIVE”

character(len=NAMELEN), public :: encounter_check_pltp = "ADAPTIVE"

Method used to compute pl-tp encounter checks.
Options are “TRIANGULAR”, “SORTSWEEP”, or “ADAPTIVE”

character(len=STRMAX), public :: encounter_save = "NONE"

Indicate if and how encounter data should be saved

real(kind=DP), public :: fstep_out = 1.0_DP

The output step time stretching factor

integer(kind=I4B), public :: idump = 0

Dump cadence counter

integer(kind=I8B), public :: iloop = 0_I8B

Main loop counter

character(len=STRMAX), public :: in_form = "XV"

Format of input data files (“EL” or [“XV”])

character(len=STRMAX), public :: in_type = "NETCDF_DOUBLE"

Data representation type of input data files

character(len=STRMAX), public :: incbfile = CB_INFILE

Name of input file for the central body

character(len=STRMAX), public :: inplfile = PL_INFILE

Name of input file for massive bodies

character(len=STRMAX), public :: integrator

Name of the nbody integrator used

character(len=NAMELEN), public :: interaction_loops = "ADAPTIVE"

Method used to compute interaction loops.
Options are “TRIANGULAR”, “FLAT”, or “ADAPTIVE”

character(len=STRMAX), public :: intpfile = TP_INFILE

Name of input file for test particles

real(kind=DP), public :: inv_c2 = -1.0_DP

Inverse speed of light squared in the system units

integer(kind=I4B), public :: iout = 0

Output cadence counter

integer(kind=I8B), public :: istart = 0_I8B

Starting index for loop counter

integer(kind=I4B), public :: istep = 0

Current value of istep (used for time stretching)

integer(kind=I4B), public :: istep_out = -1

Number of time steps between saved outputs

logical, public :: lbig_discard = .false.

Save big bodies on every discard

logical, public :: lclose = .false.

Turn on close encounters

logical, public :: lcoarray = .false.

Use Coarrays for test particle parallelization.

logical, public :: lenc_save_closest = .false.

Indicates that when encounters are saved, the closest approach distance between pairs of bodies is saved

logical, public :: lenc_save_trajectory = .false.

Indicates that when encounters are saved, the full trajectory through recursion steps are saved

logical, public :: lencounter_sas_plpl = .false.

Use the Sort and Sweep algorithm to prune the encounter list before checking for close encounters

logical, public :: lencounter_sas_pltp = .false.

Use the Sort and Sweep algorithm to prune the encounter list before checking for close encounters

logical, public :: lenergy = .false.

Track the total energy of the system

logical, public :: lextra_force = .false.

User defined force function turned on

logical, public :: lfirstenergy = .true.

This is the first time computing energe

logical, public :: lfirstkick = .true.

Initiate the first kick in a symplectic step

logical, public :: lflatten_interactions = .false.

Use the flattened upper triangular matrix for pl-pl interaction loops

logical, public :: lgr = .false.

Turn on GR

logical, public :: lmtiny_pl = .false.

Include semi-interacting massive bodies

logical, public :: lnon_spherical_cb = .false.

Calculate acceleration from oblate central body (automatically turns true if nonzero J2, J4, or c_lm is input)

logical, public :: log_output = .false.

Logs the output to file instead of displaying it on the terminal

logical, public :: lrestart = .false.

Indicates whether or not this is a restarted run

logical, public :: lrhill_present = .false.

Hill radii are given as an input rather than calculated by the code (can be used to inflate close encounter regions manually)

logical, public :: lrotation = .false.

Include rotation states of big bodies

logical, public :: ltides = .false.

Include tidal dissipation

logical, public :: ltstretch = .false.

Whether to employ time stretching or not

logical, public :: lyarkovsky = .false.

Turn on Yarkovsky effect

logical, public :: lyorp = .false.

Turn on YORP effect

real(kind=DP), public :: min_GMfrag = -1.0_DP

Smallest G*mass that can be produced in a fragmentation event

character(len=STRMAX), public :: nc_in = NC_INFILE

Name of system input file for NetCDF input

real(kind=DP), public :: nfrag_reduction = 30.0_DP

Reduction factor for limiting the number of collision fragments

integer(kind=I8B), public :: nloops = 0_I8B

Total number of loops to execute

integer(kind=I4B), public :: nout = 0

Current output step

integer(kind=I4B), public :: nstep_out = -1

Total number of saved outputs

character(len=STRMAX), public :: out_form = "XVEL"

Data to write to output file

character(len=STRMAX), public :: out_stat = 'NEW'

Open status for output binary file

character(len=STRMAX), public :: out_type = "NETCDF_DOUBLE"

Binary format of output file

character(len=STRMAX), public :: outfile = BIN_OUTFILE

Name of output binary file

character(len=STRMAX), public :: param_file_name

The name of the parameter file

real(kind=DP), public :: qmin = -1.0_DP

Minimum pericenter distance for test particle

real(kind=DP), public :: qmin_ahi = -1.0_DP

Maximum semimajor axis for qmin

real(kind=DP), public :: qmin_alo = -1.0_DP

Minimum semimajor axis for qmin

character(len=STRMAX), public :: qmin_coord = "HELIO"

Coordinate frame to use for qmin ([“HELIO”] or “BARY”)

real(kind=DP), public :: rmax = -1.0_DP

Maximum heliocentric radius for test particle

real(kind=DP), public :: rmaxu = -1.0_DP

Maximum unbound heliocentric radius for test particle

real(kind=DP), public :: rmin = -1.0_DP

Minimum heliocentric radius for test particle

integer(kind=I4B), public, dimension(:), allocatable :: seed

Random seeds for fragmentation modeling

real(kind=DP), public :: t0 = 0.0_DP

Integration reference time

real(kind=DP), public :: tstart = -1.0_DP

Integration start time

real(kind=DP), public :: tstop = -1.0_DP

Integration stop time

Type-Bound Procedures

procedure, public :: dealloc => base_util_dealloc_param
procedure(abstract_io_dump_param), public, deferred :: dump
procedure(abstract_io_read_in_param), public, deferred :: read_in
procedure(abstract_io_param_reader), public, deferred :: reader
procedure(abstract_io_param_writer), public, deferred :: writer

type, public, abstract ::  base_particle_info

Class definition for the particle origin information object. This object is used to track time, location, and collisional regime of fragments produced in collisional events.

type, public, abstract ::  base_storage

An class that establishes the pattern for various storage objects

Components

Type Visibility Attributes Name Initial
type(base_storage_frame), public, dimension(:), allocatable :: frame

Array of stored frames

integer(kind=I4B), public, dimension(:), allocatable :: idmap

The id value -> index map

integer(kind=I4B), public, dimension(:), allocatable :: idvals

The set of unique id values contained in the snapshots

integer(kind=I4B), public :: iframe = 0

Index of the last frame stored in the system

integer(kind=I4B), public :: nframes

Total number of frames that can be stored An class that establishes the pattern for various storage objects

integer(kind=I4B), public :: nid

Number of unique id values in all saved snapshots

integer(kind=I4B), public :: nt

Number of unique time values in all saved snapshots

integer(kind=I4B), public, dimension(:), allocatable :: tmap

The t value -> index map

real(kind=DP), public, dimension(:), allocatable :: tvals

The set of unique time values contained in the snapshots

Type-Bound Procedures

procedure, public :: dealloc => base_util_dealloc_storage

Deallocates all allocatables

procedure, public :: reset => base_util_reset_storage

Resets the storage object back to its original state by removing all of the saved items from the storage frames

procedure, public :: resize => base_util_resize_storage

Resizes storage if it is too small

procedure, public :: save => base_util_snapshot_save

Takes a snapshot of the current system

procedure, public :: setup => base_util_setup_storage

Sets up a storage system with a set number of frames

type, public ::  base_storage_frame

Components

Type Visibility Attributes Name Initial
class(*), public, allocatable :: item

Finalizations Procedures

final :: base_final_storage_frame

Type-Bound Procedures

generic, public :: assignment(=) => store
procedure, public :: store => base_util_copy_store

Stores a snapshot of the nbody system so that later it can be

Read more…

Subroutines

public subroutine base_final_storage(self)

Author
David A. Minton

Finalizer for the storage object

Arguments

Type IntentOptional Attributes Name
class(base_storage), intent(inout) :: self

public subroutine base_final_storage_frame(self)

Author
David A. Minton

Finalizer for the storage frame data type

Arguments

Type IntentOptional Attributes Name
type(base_storage_frame) :: self

public subroutine base_util_append_arr_DP(arr, source, nold, lsource_mask)

Author
David A. Minton

Append a single array of double precision type onto another. If the destination array is not allocated, or is not big
enough, this will allocate space for it.

Arguments

Type IntentOptional Attributes Name
real(kind=DP), intent(inout), dimension(:), allocatable :: arr

Destination array

real(kind=DP), intent(in), dimension(:), allocatable :: source

Array to append

integer(kind=I4B), intent(in), optional :: nold

Extent of original array. If passed, the source array will begin at arr(nold+1). Otherwise, the size of arr will be used.

logical, intent(in), optional, dimension(:) :: lsource_mask

Logical mask indicating which elements to append to

public subroutine base_util_append_arr_DPvec(arr, source, nold, lsource_mask)

Author
David A. Minton

Append a single array of double precision vector type of size (NDIM, n) onto another. If the destination array is not
allocated, or is not big enough, this will allocate space for it.

Arguments

Type IntentOptional Attributes Name
real(kind=DP), intent(inout), dimension(:,:), allocatable :: arr

Destination array

real(kind=DP), intent(in), dimension(:,:), allocatable :: source

Array to append

integer(kind=I4B), intent(in), optional :: nold

Extent of original array. If passed, the source array will begin at arr(nold+1). Otherwise, the size of arr will be used.

logical, intent(in), optional, dimension(:) :: lsource_mask

Logical mask indicating which elements to append to

public subroutine base_util_append_arr_I4B(arr, source, nold, lsource_mask)

Author
David A. Minton

Append a single array of integer(I4B) onto another. If the destination array is not allocated, or is not big enough, this will allocate space for it.

Arguments

Type IntentOptional Attributes Name
integer(kind=I4B), intent(inout), dimension(:), allocatable :: arr

Destination array

integer(kind=I4B), intent(in), dimension(:), allocatable :: source

Array to append

integer(kind=I4B), intent(in), optional :: nold

Extent of original array. If passed, the source array will begin at arr(nold+1). Otherwise, the size of arr will be used.

logical, intent(in), optional, dimension(:) :: lsource_mask

Logical mask indicating which elements to append to

public subroutine base_util_append_arr_char_string(arr, source, nold, lsource_mask)

Author
David A. Minton

Append a single array of character string type onto another. If the destination array is not allocated, or is not big
enough, this will allocate space for it.

Arguments

Type IntentOptional Attributes Name
character(len=STRMAX), intent(inout), dimension(:), allocatable :: arr

Destination array

character(len=STRMAX), intent(in), dimension(:), allocatable :: source

Array to append

integer(kind=I4B), intent(in), optional :: nold

Extent of original array. If passed, the source array will begin at arr(nold+1). Otherwise, the size of arr will be used.

logical, intent(in), optional, dimension(:) :: lsource_mask

Logical mask indicating which elements to append to

public subroutine base_util_append_arr_logical(arr, source, nold, lsource_mask)

Author
David A. Minton

Append a single array of logical type onto another. If the destination array is not allocated, or is not big enough, this will allocate space for it.

Arguments

Type IntentOptional Attributes Name
logical, intent(inout), dimension(:), allocatable :: arr

Destination array

logical, intent(in), dimension(:), allocatable :: source

Array to append

integer(kind=I4B), intent(in), optional :: nold

Extent of original array. If passed, the source array will begin at arr(nold+1). Otherwise, the size of arr will be used.

logical, intent(in), optional, dimension(:) :: lsource_mask

Logical mask indicating which elements to append to

public subroutine base_util_copy_store(self, source)

Author
David A. Minton

Stores a snapshot of the nbody system so that later it can be retrieved for saving to file.

Arguments

Type IntentOptional Attributes Name
class(base_storage_frame), intent(inout) :: self

Swiftest storage frame object

class(*), intent(in) :: source

Swiftest n-body system object

public subroutine base_util_dealloc_param(self)

Author
David A. Minton

Deallocates all allocatables

Arguments

Type IntentOptional Attributes Name
class(base_parameters), intent(inout) :: self

Collection of parameters

public subroutine base_util_dealloc_storage(self)

Author
David A. Minton

Resets a storage object by deallocating all items and resetting the frame counter to 0

Arguments

Type IntentOptional Attributes Name
class(base_storage), intent(inout) :: self

Swiftest storage object

public subroutine base_util_exit(code, unit)

Author
David A. Minton

Print termination message and exit program

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=I4B), intent(in) :: code
integer(kind=I4B), intent(in), optional :: unit

public subroutine base_util_fill_arr_DP(keeps, inserts, lfill_list)

Author
David A. Minton

Performs a fill operation on a single array of type DP. This is the inverse of a spill operation

Arguments

Type IntentOptional Attributes Name
real(kind=DP), intent(inout), dimension(:), allocatable :: keeps

Array of values to keep

real(kind=DP), intent(in), dimension(:), allocatable :: inserts

Array of values to insert into keep

logical, intent(in), dimension(:) :: lfill_list

Logical array of bodies to merge into the keeps

public subroutine base_util_fill_arr_DPvec(keeps, inserts, lfill_list)

Author
David A. Minton

Performs a fill operation on a single array of DP vectors with shape (NDIM, n) This is the inverse of a spill operation

Arguments

Type IntentOptional Attributes Name
real(kind=DP), intent(inout), dimension(:,:), allocatable :: keeps

Array of values to keep

real(kind=DP), intent(in), dimension(:,:), allocatable :: inserts

Array of values to insert into keep

logical, intent(in), dimension(:) :: lfill_list

Logical array of bodies to merge into the keeps

public subroutine base_util_fill_arr_I4B(keeps, inserts, lfill_list)

Author
David A. Minton

Performs a fill operation on a single array of type I4B This is the inverse of a spill operation

Arguments

Type IntentOptional Attributes Name
integer(kind=I4B), intent(inout), dimension(:), allocatable :: keeps

Array of values to keep

integer(kind=I4B), intent(in), dimension(:), allocatable :: inserts

Array of values to insert into keep

logical, intent(in), dimension(:) :: lfill_list

Logical array of bodies to merge into the keeps

public subroutine base_util_fill_arr_char_string(keeps, inserts, lfill_list)

Author
David A. Minton

Performs a fill operation on a single array of type character strings. This is the inverse of a spill operation

Arguments

Type IntentOptional Attributes Name
character(len=STRMAX), intent(inout), dimension(:), allocatable :: keeps

Array of values to keep

character(len=STRMAX), intent(in), dimension(:), allocatable :: inserts

Array of values to insert into keep

logical, intent(in), dimension(:) :: lfill_list

Logical array of bodies to merge into the keeps

public subroutine base_util_fill_arr_logical(keeps, inserts, lfill_list)

Author
David A. Minton

Performs a fill operation on a single array of logicals This is the inverse of a spill operation

Arguments

Type IntentOptional Attributes Name
logical, intent(inout), dimension(:), allocatable :: keeps

Array of values to keep

logical, intent(in), dimension(:), allocatable :: inserts

Array of values to insert into keep

logical, intent(in), dimension(:) :: lfill_list

Logical array of bodies to merge into the keeps

public subroutine base_util_reset_storage(self)

Author
David A. Minton

Resets the storage object back to its original state by removing all of the saved items from the storage frames, but
does not deallocate the frames

Arguments

Type IntentOptional Attributes Name
class(base_storage), intent(inout) :: self

public subroutine base_util_resize_arr_DP(arr, nnew)

Author
David A. Minton

Resizes an array component of double precision type. Passing nnew = 0 will deallocate.

Arguments

Type IntentOptional Attributes Name
real(kind=DP), intent(inout), dimension(:), allocatable :: arr

Array to resize

integer(kind=I4B), intent(in) :: nnew

New size

public subroutine base_util_resize_arr_DPvec(arr, nnew)

Author
David A. Minton

Resizes an array component of double precision vectors of size (NDIM, n). Passing nnew = 0 will deallocate.

Arguments

Type IntentOptional Attributes Name
real(kind=DP), intent(inout), dimension(:,:), allocatable :: arr

Array to resize

integer(kind=I4B), intent(in) :: nnew

New size

public subroutine base_util_resize_arr_I4B(arr, nnew)

Author
David A. Minton

Resizes an array component of integer type. Passing nnew = 0 will deallocate.

Arguments

Type IntentOptional Attributes Name
integer(kind=I4B), intent(inout), dimension(:), allocatable :: arr

Array to resize

integer(kind=I4B), intent(in) :: nnew

New size

public subroutine base_util_resize_arr_char_string(arr, nnew)

Author
David A. Minton

Resizes an array component of type character string. nnew = 0 will deallocate.

Arguments

Type IntentOptional Attributes Name
character(len=STRMAX), intent(inout), dimension(:), allocatable :: arr

Array to resize

integer(kind=I4B), intent(in) :: nnew

New size

public subroutine base_util_resize_arr_logical(arr, nnew)

Author
David A. Minton

Resizes an array component of logical type. Passing nnew = 0 will deallocate.

Arguments

Type IntentOptional Attributes Name
logical, intent(inout), dimension(:), allocatable :: arr

Array to resize

integer(kind=I4B), intent(in) :: nnew

New size

public subroutine base_util_resize_storage(self, nnew)

Author
David A. Minton

Checks the current size of a Swiftest against the requested size and resizes it if it is too small.

Arguments

Type IntentOptional Attributes Name
class(base_storage), intent(inout) :: self

Storage object

integer(kind=I4B), intent(in) :: nnew

New size

public subroutine base_util_setup_storage(self, n)

Author
David A. Minton

Checks the current size of a Swiftest against the requested size and resizes it if it is too small.

Arguments

Type IntentOptional Attributes Name
class(base_storage), intent(inout) :: self

Storage object

integer(kind=I4B), intent(in) :: n

New size

public subroutine base_util_snapshot_save(self, snapshot)

Author
David A. Minton

Checks the current size of the storage object against the required size and extends it by a factor of 2 more than
requested if it is too small.
Note: The reason to extend it by a factor of 2 is for performance. When there are many enounters per step, resizing
every time you want to add an encounter takes significant computational effort. Resizing by a factor of 2 is a tradeoff
between performance (fewer resize calls) and memory managment. Memory usage grows by a factor of 2 each time it fills
up, but no more.

Arguments

Type IntentOptional Attributes Name
class(base_storage), intent(inout) :: self

Storage encounter storage object

class(*), intent(in) :: snapshot

Object to snapshot

public pure subroutine base_util_sort_dp(arr)

Author
David A. Minton

Sort input DP precision array in place into ascending numerical order using quicksort.

Arguments

Type IntentOptional Attributes Name
real(kind=DP), intent(inout), dimension(:) :: arr

public pure subroutine base_util_sort_i4b(arr)

Author
David A. Minton

Sort input integer array in place into ascending numerical order using quick sort. This algorithm works well for partially sorted arrays (which is usually the case here)

Arguments

Type IntentOptional Attributes Name
integer(kind=I4B), intent(inout), dimension(:) :: arr

public pure subroutine base_util_sort_index_I4B(arr, ind)

Author
David A. Minton

Sort input integer array by index in ascending numerical order using quicksort. If ind is supplied already allocated, we assume it is an existing index array (e.g. a previously sorted array). If it is not allocated, this subroutine swiftest_allocates it.

Arguments

Type IntentOptional Attributes Name
integer(kind=I4B), intent(in), dimension(:) :: arr
integer(kind=I4B), intent(inout), dimension(:), allocatable :: ind

public pure subroutine base_util_sort_index_I4B_I8Bind(arr, ind)

Author
David A. Minton

Sort input integer array by index in ascending numerical order using quicksort. If ind is supplied already allocated, we assume it is an existing index array (e.g. a previously sorted array). If it is not allocated, this subroutine swiftest_allocates it.

Arguments

Type IntentOptional Attributes Name
integer(kind=I4B), intent(in), dimension(:) :: arr
integer(kind=I8B), intent(inout), dimension(:), allocatable :: ind

public pure subroutine base_util_sort_index_I8B_I8Bind(arr, ind)

Author
David A. Minton

Sort input integer array by index in ascending numerical order using quicksort. If ind is supplied already allocated, we assume it is an existing index array (e.g. a previously sorted array). If it is not allocated, this subroutine swiftest_allocates it.

Arguments

Type IntentOptional Attributes Name
integer(kind=I8B), intent(in), dimension(:) :: arr
integer(kind=I8B), intent(inout), dimension(:), allocatable :: ind

public pure subroutine base_util_sort_index_dp(arr, ind)

Author
David A. Minton

Sort input DP precision array by index in ascending numerical order using quick sort. This algorithm works well for partially sorted arrays (which is usually the case here). If ind is supplied already allocated, we assume it is an existing index array (e.g. a previously sorted array). If it is not allocated, this subroutine swiftest_allocates it.

Arguments

Type IntentOptional Attributes Name
real(kind=DP), intent(in), dimension(:) :: arr
integer(kind=I4B), intent(inout), dimension(:), allocatable :: ind

public pure subroutine base_util_sort_index_sp(arr, ind)

Author
David A. Minton

Sort input DP precision array by index in ascending numerical order using quicksort. If ind is supplied already allocated, we assume it is an existing index array (e.g. a previously sorted array). If it is not allocated, this subroutine swiftest_allocates it.

Arguments

Type IntentOptional Attributes Name
real(kind=SP), intent(in), dimension(:) :: arr
integer(kind=I4B), intent(inout), dimension(:), allocatable :: ind

public pure subroutine base_util_sort_partition_DP(arr, marker, ind)

Author
David A. Minton

Partition function for quicksort on DP type

Arguments

Type IntentOptional Attributes Name
real(kind=DP), intent(inout), dimension(:) :: arr
integer(kind=I4B), intent(out) :: marker
integer(kind=I4B), intent(inout), optional, dimension(:) :: ind

public pure subroutine base_util_sort_partition_I4B(arr, marker, ind)

Author
David A. Minton

Partition function for quicksort on I4B type

Arguments

Type IntentOptional Attributes Name
integer(kind=I4B), intent(inout), dimension(:) :: arr
integer(kind=I4B), intent(out) :: marker
integer(kind=I4B), intent(inout), optional, dimension(:) :: ind

public pure subroutine base_util_sort_partition_I4B_I8Bind(arr, marker, ind)

Author
David A. Minton

Partition function for quicksort on I4B type

Arguments

Type IntentOptional Attributes Name
integer(kind=I4B), intent(inout), dimension(:) :: arr
integer(kind=I8B), intent(out) :: marker
integer(kind=I8B), intent(inout), optional, dimension(:) :: ind

public pure subroutine base_util_sort_partition_I8B_I8Bind(arr, marker, ind)

Author
David A. Minton

Partition function for quicksort on I8B type with I8B index

Arguments

Type IntentOptional Attributes Name
integer(kind=I8B), intent(inout), dimension(:) :: arr
integer(kind=I8B), intent(out) :: marker
integer(kind=I8B), intent(inout), optional, dimension(:) :: ind

public pure subroutine base_util_sort_partition_SP(arr, marker, ind)

Author
David A. Minton

Partition function for quicksort on SP type

Arguments

Type IntentOptional Attributes Name
real(kind=SP), intent(inout), dimension(:) :: arr
integer(kind=I4B), intent(out) :: marker
integer(kind=I4B), intent(inout), optional, dimension(:) :: ind

public pure recursive subroutine base_util_sort_qsort_DP(arr, ind)

Author
David A. Minton

Sort input DP precision array by index in ascending numerical order using quicksort sort.

Arguments

Type IntentOptional Attributes Name
real(kind=DP), intent(inout), dimension(:) :: arr
integer(kind=I4B), intent(out), optional, dimension(:) :: ind

public pure recursive subroutine base_util_sort_qsort_I4B(arr, ind)

Author
David A. Minton

Sort input I4B array by index in ascending numerical order using quicksort.

Arguments

Type IntentOptional Attributes Name
integer(kind=I4B), intent(inout), dimension(:) :: arr
integer(kind=I4B), intent(out), optional, dimension(:) :: ind

public pure recursive subroutine base_util_sort_qsort_I4B_I8Bind(arr, ind)

Author
David A. Minton

Sort input I4B array by index in ascending numerical order using quicksort.

Arguments

Type IntentOptional Attributes Name
integer(kind=I4B), intent(inout), dimension(:) :: arr
integer(kind=I8B), intent(out), optional, dimension(:) :: ind

public pure recursive subroutine base_util_sort_qsort_I8B_I8Bind(arr, ind)

Author
David A. Minton

Sort input I8B array by index in ascending numerical order using quicksort.

Arguments

Type IntentOptional Attributes Name
integer(kind=I8B), intent(inout), dimension(:) :: arr
integer(kind=I8B), intent(out), optional, dimension(:) :: ind

public pure recursive subroutine base_util_sort_qsort_SP(arr, ind)

Author
David A. Minton

Sort input DP precision array by index in ascending numerical order using quicksort.

Arguments

Type IntentOptional Attributes Name
real(kind=SP), intent(inout), dimension(:) :: arr
integer(kind=I4B), intent(out), optional, dimension(:) :: ind

public pure subroutine base_util_sort_rearrange_arr_DP(arr, ind, n)

Author
David A. Minton

Rearrange a single array of DP type in-place from an index list.

Arguments

Type IntentOptional Attributes Name
real(kind=DP), intent(inout), dimension(:), allocatable :: arr

Destination array

integer(kind=I4B), intent(in), dimension(:) :: ind

Index to rearrange against

integer(kind=I4B), intent(in) :: n

Number of elements in arr and ind to rearrange

public pure subroutine base_util_sort_rearrange_arr_DPvec(arr, ind, n)

Author
David A. Minton

Rearrange a single array of (NDIM,n) DP-type vectors in-place from an index list.

Arguments

Type IntentOptional Attributes Name
real(kind=DP), intent(inout), dimension(:,:), allocatable :: arr

Destination array

integer(kind=I4B), intent(in), dimension(:) :: ind

Index to rearrange against

integer(kind=I4B), intent(in) :: n

Number of elements in arr and ind to rearrange

public pure subroutine base_util_sort_rearrange_arr_I4B(arr, ind, n)

Author
David A. Minton

Rearrange a single array of integers in-place from an index list.

Arguments

Type IntentOptional Attributes Name
integer(kind=I4B), intent(inout), dimension(:), allocatable :: arr

Destination array

integer(kind=I4B), intent(in), dimension(:) :: ind

Index to rearrange against

integer(kind=I4B), intent(in) :: n

Number of elements in arr and ind to rearrange

public pure subroutine base_util_sort_rearrange_arr_I4B_I8Bind(arr, ind, n)

Author
David A. Minton

Rearrange a single array of integers in-place from an index list.

Arguments

Type IntentOptional Attributes Name
integer(kind=I4B), intent(inout), dimension(:), allocatable :: arr

Destination array

integer(kind=I8B), intent(in), dimension(:) :: ind

Index to rearrange against

integer(kind=I8B), intent(in) :: n

Number of elements in arr and ind to rearrange

public pure subroutine base_util_sort_rearrange_arr_char_string(arr, ind, n)

Author
David A. Minton

Rearrange a single array of character string in-place from an index list.

Arguments

Type IntentOptional Attributes Name
character(len=STRMAX), intent(inout), dimension(:), allocatable :: arr

Destination array

integer(kind=I4B), intent(in), dimension(:) :: ind

Index to rearrange against

integer(kind=I4B), intent(in) :: n

Number of elements in arr and ind to rearrange

public pure subroutine base_util_sort_rearrange_arr_logical(arr, ind, n)

Author
David A. Minton

Rearrange a single array of logicals in-place from an index list.

Arguments

Type IntentOptional Attributes Name
logical, intent(inout), dimension(:), allocatable :: arr

Destination array

integer(kind=I4B), intent(in), dimension(:) :: ind

Index to rearrange against

integer(kind=I4B), intent(in) :: n

Number of elements in arr and ind to rearrange

public pure subroutine base_util_sort_rearrange_arr_logical_I8Bind(arr, ind, n)

Author
David A. Minton

Rearrange a single array of logicals in-place from an index list.

Arguments

Type IntentOptional Attributes Name
logical, intent(inout), dimension(:), allocatable :: arr

Destination array

integer(kind=I8B), intent(in), dimension(:) :: ind

Index to rearrange against

integer(kind=I8B), intent(in) :: n

Number of elements in arr and ind to rearrange

public pure subroutine base_util_sort_sp(arr)

Author
David A. Minton

Sort input DP precision array in place into ascending numerical order using quicksort.

Arguments

Type IntentOptional Attributes Name
real(kind=SP), intent(inout), dimension(:) :: arr

public subroutine base_util_spill_arr_DP(keeps, discards, lspill_list, ldestructive)

Author
David A. Minton

Performs a spill operation on a single array of type DP This is the inverse of a spill operation

Arguments

Type IntentOptional Attributes Name
real(kind=DP), intent(inout), dimension(:), allocatable :: keeps

Array of values to keep

real(kind=DP), intent(inout), dimension(:), allocatable :: discards

Array of discards

logical, intent(in), dimension(:) :: lspill_list

Logical array of bodies to spill into the discardss

logical, intent(in) :: ldestructive

Logical flag indicating whether or not this operation should alter the keeps array or not

public subroutine base_util_spill_arr_DPvec(keeps, discards, lspill_list, ldestructive)

Author
David A. Minton

Performs a spill operation on a single array of DP vectors with shape (NDIM, n) This is the inverse of a spill operation

Arguments

Type IntentOptional Attributes Name
real(kind=DP), intent(inout), dimension(:,:), allocatable :: keeps

Array of values to keep

real(kind=DP), intent(inout), dimension(:,:), allocatable :: discards

Array discards

logical, intent(in), dimension(:) :: lspill_list

Logical array of bodies to spill into the discards

logical, intent(in) :: ldestructive

Logical flag indicating whether or not this operation should alter the keeps array or not

public subroutine base_util_spill_arr_I4B(keeps, discards, lspill_list, ldestructive)

Author
David A. Minton

Performs a spill operation on a single array of type I4B This is the inverse of a spill operation

Arguments

Type IntentOptional Attributes Name
integer(kind=I4B), intent(inout), dimension(:), allocatable :: keeps

Array of values to keep

integer(kind=I4B), intent(inout), dimension(:), allocatable :: discards

Array of discards

logical, intent(in), dimension(:) :: lspill_list

Logical array of bodies to spill into the discards

logical, intent(in) :: ldestructive

Logical flag indicating whether or not this operation should alter the keeps array or not

public subroutine base_util_spill_arr_I8B(keeps, discards, lspill_list, ldestructive)

Author
David A. Minton

Performs a spill operation on a single array of type I4B This is the inverse of a spill operation

Arguments

Type IntentOptional Attributes Name
integer(kind=I8B), intent(inout), dimension(:), allocatable :: keeps

Array of values to keep

integer(kind=I8B), intent(inout), dimension(:), allocatable :: discards

Array of discards

logical, intent(in), dimension(:) :: lspill_list

Logical array of bodies to spill into the discards

logical, intent(in) :: ldestructive

Logical flag indicating whether or not this operation should alter the keeps array or not

public subroutine base_util_spill_arr_char_string(keeps, discards, lspill_list, ldestructive)

Author
David A. Minton

Performs a spill operation on a single array of type character strings This is the inverse of a spill operation

Arguments

Type IntentOptional Attributes Name
character(len=STRMAX), intent(inout), dimension(:), allocatable :: keeps

Array of values to keep

character(len=STRMAX), intent(inout), dimension(:), allocatable :: discards

Array of discards

logical, intent(in), dimension(:) :: lspill_list

Logical array of bodies to spill into the discards

logical, intent(in) :: ldestructive

Logical flag indicating whether or not this operation should alter the keeps array or not

public subroutine base_util_spill_arr_logical(keeps, discards, lspill_list, ldestructive)

Author
David A. Minton

Performs a spill operation on a single array of logicals This is the inverse of a spill operation

Arguments

Type IntentOptional Attributes Name
logical, intent(inout), dimension(:), allocatable :: keeps

Array of values to keep

logical, intent(inout), dimension(:), allocatable :: discards

Array of discards

logical, intent(in), dimension(:) :: lspill_list

Logical array of bodies to spill into the discards

logical, intent(in) :: ldestructive

Logical flag indicating whether or not this operation

Read more…

public subroutine base_util_unique_DP(input_array, output_array, index_map)

Author
David A. Minton

Takes an input unsorted integer array and returns a new array of sorted, unique values (DP version)

Arguments

Type IntentOptional Attributes Name
real(kind=DP), intent(in), dimension(:) :: input_array

Unsorted input array

real(kind=DP), intent(out), dimension(:), allocatable :: output_array

Sorted array of unique values

integer(kind=I4B), intent(out), dimension(:), allocatable :: index_map

An array of the same size as input_array that such that any for any index i,
output_array(index_map(i)) = input_array(i)

public subroutine base_util_unique_I4B(input_array, output_array, index_map)

Author
David A. Minton

Takes an input unsorted integer array and returns a new array of sorted, unique values (I4B version)

Arguments

Type IntentOptional Attributes Name
integer(kind=I4B), intent(in), dimension(:) :: input_array

Unsorted input array

integer(kind=I4B), intent(out), dimension(:), allocatable :: output_array

Sorted array of unique values

integer(kind=I4B), intent(out), dimension(:), allocatable :: index_map

An array of the same size as input_array that such that any for any index i,
output_array(index_map(i)) = input_array(i)