From 8607ff35b7caba8f47abfea6f89388398b142b5c Mon Sep 17 00:00:00 2001 From: tTh Date: Thu, 1 Dec 2022 12:03:22 +0100 Subject: [PATCH] premiere testouille --- Modules/.gitignore | 5 +++++ Modules/Makefile | 8 ++++++++ Modules/chkpixels.f90 | 36 ++++++++++++++++++++++++++++++++++++ Modules/spitpgm.f90 | 14 ++++++++------ 4 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 Modules/.gitignore create mode 100644 Modules/chkpixels.f90 diff --git a/Modules/.gitignore b/Modules/.gitignore new file mode 100644 index 0000000..706050e --- /dev/null +++ b/Modules/.gitignore @@ -0,0 +1,5 @@ + +chkpixels + +*.pgm + diff --git a/Modules/Makefile b/Modules/Makefile index af1edae..d01a345 100644 --- a/Modules/Makefile +++ b/Modules/Makefile @@ -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 $@ + diff --git a/Modules/chkpixels.f90 b/Modules/chkpixels.f90 new file mode 100644 index 0000000..8e87e39 --- /dev/null +++ b/Modules/chkpixels.f90 @@ -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 + +!------------------------------------------------------------------- diff --git a/Modules/spitpgm.f90 b/Modules/spitpgm.f90 index 2d2a62c..439f540 100644 --- a/Modules/spitpgm.f90 +++ b/Modules/spitpgm.f90 @@ -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)