premiere testouille

This commit is contained in:
tTh 2022-12-01 12:03:22 +01:00
parent ba2c9f653c
commit 8607ff35b7
4 changed files with 57 additions and 6 deletions

5
Modules/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
chkpixels
*.pgm

View File

@ -8,3 +8,11 @@ GFOPT = -Wall -Wextra -time -g -O
spitpgm.o: spitpgm.f90 Makefile
gfortran $(GFOPT) -c $< -o $@
#
# programmes de testouille
#
chkpixels: chkpixels.f90 Makefile spitpgm.o
gfortran $(GFOPT) $< spitpgm.o -o $@

36
Modules/chkpixels.f90 Normal file
View File

@ -0,0 +1,36 @@
program chkpixels
use spitpgm
implicit none
write(0, *) "------ CHKPIXELS ------"
call test_alpha()
STOP 'BECAUSE NO CPU AVAILABLE'
contains
!-------------------------------------------------------------------
!-
subroutine test_alpha()
integer, parameter :: SZ = 32
integer, dimension(SZ, SZ) :: greymap
integer :: ix, iy, value
value = 0
do iy=1, SZ
do ix=1, SZ
greymap(ix, iy) = value
value = value + 1
enddo
enddo
call spit_as_pgm_16 (greymap, 'a.pgm')
call spit_as_pgm_eq (greymap, 'b.pgm')
call spit_as_pgm_8 (greymap, 'c.pgm')
end subroutine
end program
!-------------------------------------------------------------------

View File

@ -19,7 +19,7 @@ subroutine spit_as_pgm_eq(pic, fname)
integer :: ix, iy
real :: fk, fpix
write(0, '(1X, A)') "> spit_as_pgm to " // trim(fname)
write(0, '(1X, A)') "> spit_as_pgm_eq to " // trim(fname)
open(newunit=io, file=fname)
write (io, '(a2)') "P2"
@ -33,8 +33,8 @@ subroutine spit_as_pgm_eq(pic, fname)
write (io, "(i0)") 0
enddo
else
fk = float(foo) / 65535.0
print *, " max pix value", foo, " fk = ", fk
fk = float(foo) / 65535.01
write (0, *) " max pix value", foo, " fk ", fk
do iy = 1, ubound(pic, 2)
do ix = 1, ubound(pic, 1)
fpix = float(pic(ix, iy)) / fk
@ -58,13 +58,15 @@ subroutine spit_as_pgm_16(pic, fname)
open(newunit=io, file=fname)
write (io, '(a2)') "P2"
write (io, '("# size:", I9)') size(pic)
write (io, '(i0," ",i0)') size(pic, 1), size(pic, 2)
write (io, '(i0)') 65535
do iy=1,ubound(pic, 2)
do ix=1, ubound(pic, 1)
foo = pic(ix, iy)
if (foo .GT. 65535) foo = 65530
write(io, "(i5)") foo
if (foo .GT. 65535) foo = 65535
write(io, "(i0)") foo
enddo
enddo
close(io)
@ -90,7 +92,7 @@ subroutine spit_as_pgm_8(pic, fname)
do ix=1, ubound(pic, 1)
foo = pic(ix, iy)
if (foo .GT. 255) foo = 255
write(io, "(i3)") foo
write(io, "(i0)") foo
enddo
enddo
close(io)