Compare commits

..

No commits in common. "c2d6abdedbda26a5de2f0c038a270490a0e0682d" and "aace571169b857e82f943f3a36c51cad803e03d2" have entirely different histories.

10 changed files with 60 additions and 153 deletions

View File

@ -21,8 +21,7 @@ trigofest: trigofest.f90 Makefile vue3axes.o utils_ga.o
utils_ga.o -o $@
noisepic: noisepic.f90 Makefile
gfortran $(GFOPT) $< ../Modules/spitpgm.o ../Modules/pixrgb.o \
-o $@
gfortran $(GFOPT) $< ../Modules/spitpgm.o -o $@
# ---- modules locaux

View File

@ -1,7 +1,6 @@
program noisepic
use spitpgm
use pixrgb
implicit none
integer :: numframe = 0
@ -17,15 +16,12 @@ program noisepic
read (arg, *) numframe
endif
call make_noise_color_pic(numframe)
call make_noise_pic(numframe)
contains
!-- ------------------------------------------------------------------
!-
!- Black & White
!-
subroutine make_noise_bw_pic (value)
implicit none
subroutine make_noise_pic (value)
integer, intent(in) :: value
integer :: foo
@ -34,20 +30,20 @@ subroutine make_noise_bw_pic (value)
allocate(pic(320, 240))
pic = 30 !- clear the picz
pic = 0
call srand(value+34)
foo = irand()
print *, 'val=', value, ' rnd=', foo
call plot_noise_bw_pic(pic, 15000)
call plot_noise_pic(pic, 15000)
write (filename, "(a, i5.5, a)") "", value, ".pgm"
call spit_as_pgm_8(pic, trim(filename))
end subroutine
!-- ------------------------------------------------------------------
subroutine plot_noise_bw_pic(picz, nbre)
implicit none
subroutine plot_noise_pic(picz, nbre)
integer, dimension(:,:), intent(inout) :: picz
integer, intent(in) :: nbre
@ -55,63 +51,23 @@ subroutine plot_noise_bw_pic(picz, nbre)
integer :: width, height
integer :: quux, ix, iy, iv
width = ubound(picz, 1) ; height = ubound(picz, 2)
! print *, 'sz picz', width, height
do quux=1, nbre
ix = 1 + mod ( irand(), width )
iy = 1 + mod ( irand(), height )
iv = mod ( irand(), 256 )
! print *, ix, iy
picz(ix, iy) = iv
enddo
end subroutine
!-- ------------------------------------------------------------------
!-
!- Colorized
!-
subroutine make_noise_color_pic (value)
implicit none
integer, intent(in) :: value
integer :: foo
type(t_pixrgb), dimension(:,:), allocatable :: pix
character (len=280) :: filename
allocate(pix(320, 240))
call rgbpix_set_to_rgb(pix, 30, 30, 60)
call srand(value+34)
foo = irand()
print *, 'val=', value, ' rnd=', foo
call plot_noise_color_pic(pix, 15000)
write (filename, "(a, i5.5, a)") "./", value, ".pnm"
call rgbpix_spit_as_pnm_8(pix, trim(filename))
end subroutine
!-- ------------------------------------------------------------------
subroutine plot_noise_color_pic(prgb, nbre)
implicit none
type(t_pixrgb), dimension(:,:), intent(inout) :: prgb
integer, intent(in) :: nbre
integer :: quux, ix, iy, width, height
width = ubound(prgb, 1) ; height = ubound(prgb, 2)
do quux=1, nbre
ix = 1 + mod ( irand(), width )
iy = 1 + mod ( irand(), height )
prgb(ix, iy)%r = 64 + mod ( irand(), 127 )
prgb(ix, iy)%g = 64 + mod ( irand(), 127 )
prgb(ix, iy)%b = 64 + mod ( irand(), 127 )
enddo
end subroutine
!-- ------------------------------------------------------------------
end program

2
Modules/.gitignore vendored
View File

@ -1,7 +1,5 @@
chkpixels
t
trnd
*.pgm
*.pnm

View File

@ -1,44 +1,29 @@
#
# * Fortraneries from tTh *
# * Fortraneries *
#
# Makefile for the general purpose moduls
#
GFOPT = -Wall -Wextra -g -I.
GFOPT = -Wall -Wextra -time -g
all: chkpixels t
all: chkpixels
# -----------------------------------------------
spitpgm.o: spitpgm.f90 Makefile
gfortran $(GFOPT) -c $<
gfortran $(GFOPT) -c $< -o $@
pixrgb.o: pixrgb.f90 Makefile
gfortran $(GFOPT) -c $<
centermag.o: centermag.f90 Makefile
gfortran $(GFOPT) -c $<
dummy.o: dummy.f90 Makefile
gfortran $(GFOPT) -c $<
gfortran $(GFOPT) -c $< -o $@
trials.o: trials.f90 Makefile
gfortran $(GFOPT) -c $<
mathstuff2.o: mathstuff2.f90 Makefile
gfortran $(GFOPT) -c $<
gfortran $(GFOPT) -c $< -o $@
#
# programmes de testouille
#
OBJS = trials.o spitpgm.o pixrgb.o centermag.o dummy.o \
mathstuff2.o
OBJS = trials.o spitpgm.o pixrgb.o
chkpixels: chkpixels.f90 Makefile $(OBJS)
gfortran $(GFOPT) $< $(OBJS) -o $@
t: t.f90 Makefile $(OBJS)
gfortran $(GFOPT) $< $(OBJS) -o $@
trnd: trnd.f90 Makefile $(OBJS)
gfortran $(GFOPT) $< $(OBJS) -o $@

View File

@ -1,29 +1,14 @@
# General purpose modules
## Compiler un module
Mmmmm...
## Modules disponibles
### spitpgm
## spitpgm
Write gray level 2d buffer (aka picture) to disk in the NetPNM format.
### pixrgb
## pixrgb
Write 8 bits RGB pictures to PNM format.
### trials
## trials
Experimental WIPs from hell.
### dummy
A "do nothing" useless module. But you cas use it to fool an optimizing
compiler, or have a sane place to put a breakpoint with gdb
## TODO
- écrire la doc !

View File

@ -1,6 +1,5 @@
!-
! This module try to write PNM complient RGB files
! ONLY ASCII MODE IS SUPPORTED !
!-
module pixrgb
implicit none
@ -27,23 +26,6 @@ subroutine rgbpix_set_to_zero(pic)
enddo
enddo
end subroutine
!-------------------------------------------------------------------
!-
! set all the pixels to a RGB value
!-
subroutine rgbpix_set_to_rgb(pic, r, g, b)
type(t_pixrgb), intent(out) :: pic(:,:)
integer, intent(in) :: r, g, b
integer :: ix, iy
do iy=1, ubound(pic, 2)
do ix=1, ubound(pic, 1)
pic(ix, iy)%r = r
pic(ix, iy)%g = g
pic(ix, iy)%b = b
enddo
enddo
end subroutine
!-------------------------------------------------------------------
!-
! NOT TESTED !!!

View File

@ -1,35 +0,0 @@
program t
use centermag
implicit none
type(t_centermag) :: cmag
print *, '====== programme de test ======'
cmag%wscr = 800
cmag%hscr = 600
call essai_centermag(cmag)
print *
STOP ': PAF LE CHIEN ?'
! --------------
contains
! --------------
subroutine essai_centermag(cm)
type(t_centermag), intent(in) :: cm
real :: rx, ry
call print_centermag (cm)
print *
call centermag_scr2real(1, 1, rx, ry)
print *, 'to real :', rx, ry
end subroutine
! --------------
end program

View File

@ -4,13 +4,17 @@
GFOPT = -Wall -Wextra -g -time
all: displaykinds
all: essai displaykinds
# -----------------------------------------------------
mathstuff2.o: mathstuff2.f90 Makefile
gfortran $(GFOPT) -c $<
# -----------------------------------------------------
essai: essai.f90 Makefile mathstuff2.o
gfortran $(GFOPT) $< mathstuff2.o -o $@
displaykinds: displaykinds.f90 Makefile
gfortran $(GFOPT) $< -o $@

View File

@ -0,0 +1,33 @@
module mathstuff2
! XXX This module was a copy of mathstuff.f90 fromthe BloubWorld
! XXX wil be moved in an other place some day...
implicit none
contains
! ----------------------------------------------------------------
! really quick'n'dirty hack
! not really tested yet...
subroutine init_random_seed()
integer, dimension(3) :: tarray
integer :: t3, foo
real :: dummy
call itime(tarray)
t3 = 3600*tarray(1) + 60*tarray(2) + tarray(3)
! write(0, '(A,3I3,A,I6)') "sranding: ", tarray, " --> ", t3
call srand(t3)
! after initializing the random generator engine,
! you MUST use it for initializing the initializer
do foo=1, tarray(1)+5
dummy = rand()
enddo
end subroutine
! ----------------------------------------------------------------
end module mathstuff2