ind2sub Subroutine

public subroutine ind2sub(dims, ind, subs)

Calculate the subscripts subs into an array with dimensions dims given the corresponding linear index ind

Arguments

Type IntentOptional AttributesName
integer, intent(in), dimension(:):: dims

Dimensions of array

integer, intent(in) :: ind

Linear index

integer, intent(out), dimension(:):: subs

Subscripts corresponding to the linear index


Called by

proc~~ind2sub~~CalledByGraph proc~ind2sub ind2sub proc~pnpa_f pnpa_f proc~pnpa_f->proc~ind2sub proc~dcx_spec dcx_spec proc~dcx_spec->proc~ind2sub proc~dcx dcx proc~dcx->proc~ind2sub proc~fida_weights_mc fida_weights_mc proc~fida_weights_mc->proc~ind2sub proc~halo_spec halo_spec proc~halo_spec->proc~ind2sub proc~make_diagnostic_grids make_diagnostic_grids proc~make_diagnostic_grids->proc~ind2sub proc~fida_f fida_f proc~fida_f->proc~ind2sub proc~cold_spec cold_spec proc~cold_spec->proc~ind2sub proc~nbi_spec nbi_spec proc~nbi_spec->proc~ind2sub proc~npa_f npa_f proc~npa_f->proc~ind2sub proc~halo halo proc~halo->proc~ind2sub proc~read_equilibrium read_equilibrium proc~read_equilibrium->proc~ind2sub proc~pfida_f pfida_f proc~pfida_f->proc~ind2sub program~fidasim fidasim program~fidasim->proc~pnpa_f program~fidasim->proc~dcx_spec program~fidasim->proc~dcx program~fidasim->proc~fida_weights_mc program~fidasim->proc~halo_spec program~fidasim->proc~make_diagnostic_grids program~fidasim->proc~fida_f program~fidasim->proc~cold_spec program~fidasim->proc~nbi_spec program~fidasim->proc~npa_f program~fidasim->proc~halo program~fidasim->proc~read_equilibrium program~fidasim->proc~pfida_f

Contents

Source Code


Source Code

subroutine ind2sub(dims,ind,subs)
    !+ Calculate the subscripts `subs` into an array with dimensions `dims`
    !+ given the corresponding linear index `ind`
    integer, dimension(:), intent(in)  :: dims
        !+ Dimensions of array
    integer, intent(in)                :: ind
        !+ Linear index
    integer, dimension(:), intent(out) :: subs
        !+ Subscripts corresponding to the linear index

    integer :: i, ndims, ind1, ind2

    ind1=ind
    ndims = size(dims)
    do i=1,ndims-1
        ind2 = (ind1-1)/dims(i) + 1
        subs(i) = ind1 - dims(i)*(ind2-1)
        ind1 = ind2
    enddo
    subs(ndims) = ind1

end subroutine ind2sub