Fortraneries/GrafAnim/usegenplot.f90

124 lines
3.0 KiB
Fortran
Raw Normal View History

2022-10-28 22:18:39 +02:00
module usegenplot
implicit none
2022-11-22 08:58:56 +01:00
integer, private :: color = 4
2023-02-11 20:29:07 +01:00
integer, private :: iochannel = -1
2022-11-22 08:58:56 +01:00
logical, private :: initialised = .FALSE.
2023-02-11 20:29:07 +01:00
2022-10-28 22:18:39 +02:00
contains
! -------------------------------------------------------------------
subroutine init_genplot(filename)
2022-11-13 23:47:45 +01:00
character(*), intent(in) :: filename
2023-02-11 20:29:07 +01:00
integer :: errcode
2022-11-13 23:47:45 +01:00
write(0, *) '--> init genplot "', filename, '"'
2023-02-11 20:29:07 +01:00
open(newunit=iochannel, file=filename, iostat=errcode)
write(0, *) 'iochannel', iochannel, 'errcode', errcode
2022-11-22 08:58:56 +01:00
initialised = .TRUE.
color = 4
2022-11-13 23:47:45 +01:00
2023-02-11 20:29:07 +01:00
! XXX STOP 'ABEND'
2022-11-13 23:47:45 +01:00
end subroutine
2022-11-22 08:58:56 +01:00
subroutine end_genplot(message)
character(*), intent(in) :: message
2023-02-11 20:29:07 +01:00
integer :: errcode
2022-11-22 08:58:56 +01:00
write(0, *) '--> end genplot "', message, '"'
initialised = .FALSE.
2023-02-11 20:29:07 +01:00
close(unit=iochannel, iostat=errcode)
write(0, *) 'close errcode', errcode
2022-11-22 08:58:56 +01:00
end subroutine
! -------------------------------------------------------------------
2022-11-26 13:01:37 +01:00
subroutine do_initialise_once(motif)
character(*), intent(in) :: motif
write(0, *) '--> do initialise once "', motif, '", flag is ', initialised
call init_genplot('a.scratch')
end subroutine
! -------------------------------------------------------------------
2023-02-11 20:29:07 +01:00
!- getter, setter, wtf ?
2022-11-22 08:58:56 +01:00
subroutine gplt_setcol(col)
integer, intent(in) :: col
color = col
end subroutine
function gplt_getcol()
integer gplt_getcol
gplt_getcol = color
end function
2022-11-13 23:47:45 +01:00
! -------------------------------------------------------------------
subroutine gplt_move(x, y)
2022-11-26 13:01:37 +01:00
integer, intent(in) :: x, y
if (.NOT. initialised) then
call do_initialise_once('in gplt_move')
endif
2023-02-11 20:29:07 +01:00
write(iochannel, '(3I8)') x, y, 0
2022-11-13 23:47:45 +01:00
end subroutine
! -------------------------------------------------------------------
subroutine gplt_draw(x, y)
2022-11-26 13:01:37 +01:00
integer, intent(in) :: x, y
if (.NOT. initialised) then
call do_initialise_once('in gplt_draw')
endif
2023-02-11 20:29:07 +01:00
write(iochannel, '(3I8)') x, y, color
2022-11-13 23:47:45 +01:00
end subroutine
! -------------------------------------------------------------------
subroutine gplt_line(x1, y1, x2, y2)
integer, intent(in) :: x1, y1, x2, y2
call gplt_move(x1, y1)
call gplt_draw(x2, y2)
end subroutine
! -------------------------------------------------------------------
2023-02-11 20:29:07 +01:00
!-
! sx, sy
! +-------------------+
! | x2,y2 |
! | |
! | |
! | x1,y1 |
! +-------------------+
! 0,0
2022-11-22 08:58:56 +01:00
2022-11-13 23:47:45 +01:00
subroutine gplt_rect(x1, y1, x2, y2)
2022-11-22 08:58:56 +01:00
integer, intent(in) :: x1, y1, x2, y2
2023-02-11 20:29:07 +01:00
if (.NOT. initialised) then
call do_initialise_once('in gplt_rect')
endif
2022-11-22 08:58:56 +01:00
call gplt_move(x1, y1)
call gplt_draw(x2, y1)
call gplt_draw(x2, y2)
call gplt_draw(x1, y2)
call gplt_draw(x1, y1)
2022-10-28 22:18:39 +02:00
end subroutine
2022-11-22 08:58:56 +01:00
! -------------------------------------------------------------------
2022-10-28 22:18:39 +02:00
! -------------------------------------------------------------------
end module