subroutine ps_Provenance_Get(ps,level,creator,date,&
annotation,number_of_input_files)
type(ps_t), intent(in) :: ps
integer , intent(in) :: level
character(len=*), intent(out), optional :: creator
character(len=*), intent(out), optional :: date
type(ps_annotation_t), intent(out), optional :: annotation
integer, intent(out), optional :: number_of_input_files
type(provenance_t), pointer :: p
logical :: found_level
! Here "level" means "record_number", with
! the oldest having a value of 1.
found_level = .false.
p => ps%provenance
do while (associated(p))
if (p%record_number == level) then
found_level = .true.
exit
endif
p => p%next
enddo
if (.not. found_level) call die("Cannot reach provenance level")
if (present(creator)) then
creator = p%creator
endif
if (present(date)) then
date = p%date
endif
if (present(number_of_input_files)) then
number_of_input_files = p%n_input_files
endif
if (present(annotation)) then
annotation = p%annotation
endif
end subroutine ps_Provenance_Get