premiere testouille
This commit is contained in:
parent
ba2c9f653c
commit
8607ff35b7
5
Modules/.gitignore
vendored
Normal file
5
Modules/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
chkpixels
|
||||||
|
|
||||||
|
*.pgm
|
||||||
|
|
@ -8,3 +8,11 @@ GFOPT = -Wall -Wextra -time -g -O
|
|||||||
|
|
||||||
spitpgm.o: spitpgm.f90 Makefile
|
spitpgm.o: spitpgm.f90 Makefile
|
||||||
gfortran $(GFOPT) -c $< -o $@
|
gfortran $(GFOPT) -c $< -o $@
|
||||||
|
|
||||||
|
#
|
||||||
|
# programmes de testouille
|
||||||
|
#
|
||||||
|
|
||||||
|
chkpixels: chkpixels.f90 Makefile spitpgm.o
|
||||||
|
gfortran $(GFOPT) $< spitpgm.o -o $@
|
||||||
|
|
||||||
|
36
Modules/chkpixels.f90
Normal file
36
Modules/chkpixels.f90
Normal 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
|
||||||
|
|
||||||
|
!-------------------------------------------------------------------
|
@ -19,7 +19,7 @@ subroutine spit_as_pgm_eq(pic, fname)
|
|||||||
integer :: ix, iy
|
integer :: ix, iy
|
||||||
real :: fk, fpix
|
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)
|
open(newunit=io, file=fname)
|
||||||
write (io, '(a2)') "P2"
|
write (io, '(a2)') "P2"
|
||||||
@ -33,8 +33,8 @@ subroutine spit_as_pgm_eq(pic, fname)
|
|||||||
write (io, "(i0)") 0
|
write (io, "(i0)") 0
|
||||||
enddo
|
enddo
|
||||||
else
|
else
|
||||||
fk = float(foo) / 65535.0
|
fk = float(foo) / 65535.01
|
||||||
print *, " max pix value", foo, " fk = ", fk
|
write (0, *) " max pix value", foo, " fk ", fk
|
||||||
do iy = 1, ubound(pic, 2)
|
do iy = 1, ubound(pic, 2)
|
||||||
do ix = 1, ubound(pic, 1)
|
do ix = 1, ubound(pic, 1)
|
||||||
fpix = float(pic(ix, iy)) / fk
|
fpix = float(pic(ix, iy)) / fk
|
||||||
@ -58,13 +58,15 @@ subroutine spit_as_pgm_16(pic, fname)
|
|||||||
|
|
||||||
open(newunit=io, file=fname)
|
open(newunit=io, file=fname)
|
||||||
write (io, '(a2)') "P2"
|
write (io, '(a2)') "P2"
|
||||||
|
write (io, '("# size:", I9)') size(pic)
|
||||||
write (io, '(i0," ",i0)') size(pic, 1), size(pic, 2)
|
write (io, '(i0," ",i0)') size(pic, 1), size(pic, 2)
|
||||||
write (io, '(i0)') 65535
|
write (io, '(i0)') 65535
|
||||||
|
|
||||||
do iy=1,ubound(pic, 2)
|
do iy=1,ubound(pic, 2)
|
||||||
do ix=1, ubound(pic, 1)
|
do ix=1, ubound(pic, 1)
|
||||||
foo = pic(ix, iy)
|
foo = pic(ix, iy)
|
||||||
if (foo .GT. 65535) foo = 65530
|
if (foo .GT. 65535) foo = 65535
|
||||||
write(io, "(i5)") foo
|
write(io, "(i0)") foo
|
||||||
enddo
|
enddo
|
||||||
enddo
|
enddo
|
||||||
close(io)
|
close(io)
|
||||||
@ -90,7 +92,7 @@ subroutine spit_as_pgm_8(pic, fname)
|
|||||||
do ix=1, ubound(pic, 1)
|
do ix=1, ubound(pic, 1)
|
||||||
foo = pic(ix, iy)
|
foo = pic(ix, iy)
|
||||||
if (foo .GT. 255) foo = 255
|
if (foo .GT. 255) foo = 255
|
||||||
write(io, "(i3)") foo
|
write(io, "(i0)") foo
|
||||||
enddo
|
enddo
|
||||||
enddo
|
enddo
|
||||||
close(io)
|
close(io)
|
||||||
|
Loading…
Reference in New Issue
Block a user