Fortraneries/Fraktalism/mods/points3d.f90

61 lines
1.7 KiB
Fortran
Raw Permalink Normal View History

2022-03-08 20:36:32 +11:00
module points3d
implicit none
!-----------------------------------------------------
type t_point3d
double precision :: x, y, z
integer :: seq
end type t_point3d
!-----------------------------------------------------
contains
2022-03-30 17:42:39 +11:00
!-----------------------------------------------------
2022-03-08 20:36:32 +11:00
subroutine list_points3d(array, start, length)
type(t_point3d), dimension(:), intent(in) :: array
integer, intent(in) :: start, length
2022-03-27 13:37:14 +11:00
integer :: sz, i, j
2022-03-08 20:36:32 +11:00
2022-03-27 13:37:14 +11:00
write(0, '(1X, A15, 2I9)') "list pt3d ", start, length
2022-03-08 20:36:32 +11:00
sz = ubound(array, 1)
if ((start+length) .GT. sz) then
2022-03-27 13:37:14 +11:00
STOP ' : LIST P3D, OUT OF BOUND'
2022-03-08 20:36:32 +11:00
endif
2022-03-27 13:37:14 +11:00
! send values to stdout.
do i = 1, length
j = i + start
print *, array(j)%x, array(j)%y, array(j)%z, array(j)%seq
2022-03-08 20:36:32 +11:00
enddo
end subroutine list_points3d
!-----------------------------------------------------
2022-03-27 13:37:14 +11:00
subroutine write_points3d(array, start, length, fname)
type(t_point3d), dimension(:), intent(in) :: array
integer, intent(in) :: start, length
character(*), intent(in) :: fname
integer :: sz, i, j, io
2022-03-30 17:42:39 +11:00
! write(0, '(1X, A15, 2I9)') "write pt3d ", start, length
2022-03-27 13:37:14 +11:00
sz = ubound(array, 1)
if ((start+length) .GT. sz) then
STOP ' : WRITE P3D, OUT OF BOUND'
endif
open(newunit=io, file=fname)
do i = 1, length
j = i + start
2022-10-29 06:53:57 +11:00
write(io, '(3F12.6, I8)') &
array(j)%x, array(j)%y, array(j)%z, array(j)%seq
2022-03-27 13:37:14 +11:00
enddo
close(io)
end subroutine write_points3d
!-----------------------------------------------------
2022-03-08 20:36:32 +11:00
end module points3d