! This file: http://ftp.aset.psu.edu/pub/ger/fortran/hdk/PackPick.f90 ! ! molagnon@ifremer.fr (Michel OLAGNON) ! F-Compiler compatible. program packpick integer, parameter :: DP = selected_real_kind(15) real(kind=DP), dimension(5) :: X integer :: i X=0 X(1)=1_DP X(3)=3_DP print *, "Vector subscripts of X where X is non-zero are:" print *, "Results of the next line should be indices 1 and 3." print *, pack((/(i, i = 1,size(X))/),(X /= 0)) end program packpick