diff --git a/src/input_xml.F90 b/src/input_xml.F90 index 14b49292ee..9bedbc8b3c 100644 --- a/src/input_xml.F90 +++ b/src/input_xml.F90 @@ -414,7 +414,7 @@ contains n_tracks = n_tracks/3 allocate(track_identifiers(3,n_tracks)) do i=1, n_tracks - track_identifiers(1:3,i) = track_(3*(i-1)+1 : 3*(i-1)+4) + track_identifiers(1:3,i) = track_(3*(i-1)+1 : 3*(i-1)+3) end do end if diff --git a/src/track_output.F90 b/src/track_output.F90 index 8b9c17b89a..021cbb8ca6 100644 --- a/src/track_output.F90 +++ b/src/track_output.F90 @@ -24,7 +24,6 @@ contains subroutine initialize_particle_track() n_tracks = 0 - allocate(coords(1,1)) end subroutine initialize_particle_track !=============================================================================== @@ -34,13 +33,17 @@ contains subroutine write_particle_track(p) type(Particle), intent(in) :: p - real(8), allocatable :: new_coords(:, :) + real(8), allocatable :: new_coords(:, :) - ! Add another column to coords. + ! Add another column to coords n_tracks = n_tracks + 1 - allocate(new_coords(3, n_tracks)) - new_coords(:, 1:n_tracks-1) = coords - call move_alloc(FROM=new_coords, TO=coords) + if (allocated(coords)) then + allocate(new_coords(3, n_tracks)) + new_coords(:, 1:n_tracks-1) = coords + call move_alloc(FROM=new_coords, TO=coords) + else + allocate(coords(3,1)) + end if ! Write current coordinates into the newest column. coords(:, n_tracks) = p % coord0 % xyz