Fortraneries/Fraktalism/mods/points3d.f90

61 lines
1.7 KiB
Fortran
Raw Normal View History

2022-03-08 10:36:32 +01:00
module points3d
implicit none
!-----------------------------------------------------
type t_point3d
double precision :: x, y, z
integer :: seq
end type t_point3d
!-----------------------------------------------------
contains
2022-03-30 08:42:39 +02:00
!-----------------------------------------------------
2022-03-08 10:36:32 +01:00
subroutine list_points3d(array, start, length)
type(t_point3d), dimension(:), intent(in) :: array
integer, intent(in) :: start, length
2022-03-27 04:37:14 +02:00
integer :: sz, i, j
2022-03-08 10:36:32 +01:00
2022-03-27 04:37:14 +02:00
write(0, '(1X, A15, 2I9)') "list pt3d ", start, length
2022-03-08 10:36:32 +01:00
sz = ubound(array, 1)
if ((start+length) .GT. sz) then
2022-03-27 04:37:14 +02:00
STOP ' : LIST P3D, OUT OF BOUND'
2022-03-08 10:36:32 +01:00
endif
2022-03-27 04:37:14 +02: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 10:36:32 +01:00
enddo
end subroutine list_points3d
!-----------------------------------------------------
2022-03-27 04:37:14 +02: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 08:42:39 +02:00
! write(0, '(1X, A15, 2I9)') "write pt3d ", start, length
2022-03-27 04:37:14 +02: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-28 21:53:57 +02:00
write(io, '(3F12.6, I8)') &
array(j)%x, array(j)%y, array(j)%z, array(j)%seq
2022-03-27 04:37:14 +02:00
enddo
close(io)
end subroutine write_points3d
!-----------------------------------------------------
2022-03-08 10:36:32 +01:00
end module points3d