npz_names

  • Austin C Bullock

interface npz_names

Description: Subroutine for listing the names of the arrays in a NumPy .npz archive.

call npz_names(file, names [, stat, errmsg])
  • file is of type character(len=*)
  • names is of type type(String), allocatable, dimension(:)
  • stat is optional and of type integer
  • errmsg is optional and of type character(len=*)

names gets one element for each array, in the order the arrays are stored, which is the order they were added. Each name is the one to_file and from_file take as name, which is the name of the file in the archive without .npy, as NumPy gives it.

type(String), allocatable :: names(:)
integer :: i

call npz_names("data.npz", names)

do i = 1, size(names)
    write(*,*) names(i)%as_str()
end do

Note

A missing file, or one that isn't a ZIP archive, is an IOFL_READ_ERR, and names then has size 0.