Skip to content

Commit

Permalink
(phantom) bug fix reading itype from files after changes for apr_level
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljprice committed Mar 4, 2024
1 parent 6c51d4c commit 552bd47
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/read_data_sphNG.f90
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ subroutine read_header(iunit,iverbose,debug,doubleprec,&
integer :: i,ierr1,ierr2,ierrs(4)
integer :: nints,ninttypes,nreal4s,nreal8s
integer :: n2,nreassign,naccrete,nkill
integer, allocatable :: npartoftype_tmp(:)

! initialise empty tag array
tags(:) = ''
Expand Down Expand Up @@ -537,12 +538,15 @@ subroutine read_header(iunit,iverbose,debug,doubleprec,&
if (phantomdump) then
call extract('ntypes',ntypes,intarr,tags,nints,ierr)
if (ierr /= 0) return

allocate(npartoftype_tmp(ntypes))
call extract('npartoftype',npartoftype_tmp(1:ntypes),intarr,tags,nints,ierr)
if (ntypes > maxparttypes) then
if (iverbose > 0) &
if (iverbose > 0 .and. any(npartoftype_tmp(maxparttypes+1:) > 0)) &
print "(a,i2)",' WARNING: number of particle types exceeds array limits: ignoring types > ',maxparttypes
ntypes = maxparttypes
endif
call extract('npartoftype',npartoftypei(1:ntypes),intarr,tags,nints,ierr)
npartoftypei(1:ntypes) = npartoftype_tmp(1:ntypes)
if (ierr /= 0) return
endif
if (phantomdump .and. nints < 7) ntypes = nints - 1
Expand Down Expand Up @@ -712,6 +716,7 @@ subroutine read_header(iunit,iverbose,debug,doubleprec,&
print "(a)",' WARNING: could not read magnetic units from dump file'
endif
if (debug) print*,' number of array sizes = ',narrsizes
if (allocated(npartoftype_tmp)) deallocate(npartoftype_tmp)

end subroutine read_header

Expand Down Expand Up @@ -1867,7 +1872,7 @@ subroutine read_data_sphNG(rootname,indexstart,iposn,nstepsread)
else
if (tagged) read(iunit,end=33,iostat=ierr) tagtmp
select case(tagtmp)
case('iphase')
case('iphase','itype')
gotiphase = .true.
read(iunit,end=33,iostat=ierr) iphase(i1:i2)
!--skip remaining integer arrays
Expand Down

0 comments on commit 552bd47

Please sign in to comment.