mapper.f90
I suggest you either typed this as it appears into the compiler, or as
an easier way, just copy and paste it!
Note: I do not claim
the program will 100% work, but I give it my best. If it doesn't, try tweaking
it yourself, or email me about it, and I'll modify and post the improved version
later. Good luck!
!WARNING.....PLEASE COPY THEFILE SMOOTHED.DAT FROM THE DISK INTO THE COMPUTER LOCATION WHERE
! mapper IS TO BE RUN
PROGRAM mapper
IMPLICIT NONE
CHARACTER(LEN=1), DIMENSION(3,3) :: mapped, mapped2
INTEGER, DIMENSION(3,3) :: imagefromfile, imageforfile
INTEGER :: i, j
!Opens the image.dat file
OPEN(UNIT=10, FILE="smoothed.dat", STATUS="old", ACTION="READ")
PRINT*, "Image from file before mapping..."
READ(UNIT=10, FMT=11) imagefromfile
!To confirm/display the image from the file
WRITE(UNIT=*, FMT=11) imagefromfile
!Changing the value of data in imagefromfile into character type
DO i=1,3
DO j=1,3
SELECT CASE (imagefromfile(i,j))
CASE (0:14)
mapped(i,j)=ACHAR(imagefromfile(i,j)) !----->Changes the corresponding number into
mapped(i,j)=ACHAR(32) !character values using ACHAR.
CASE (15:28)
mapped(i,j)=ACHAR(imagefromfile(i,j))
mapped(i,j)=ACHAR(46) !--------------------->Changes the character to the character
CASE (29:42) !required.
mapped(i,j)=ACHAR(imagefromfile(i,j))
mapped(i,j)=ACHAR(44)
CASE (43:57)
mapped(i,j)=ACHAR(imagefromfile(i,j))
mapped(i,j)=ACHAR(111)
CASE (58:71)
mapped(i,j)=ACHAR(imagefromfile(i,j))
mapped(i,j)=ACHAR(79)
CASE (72:85)
mapped(i,j)=ACHAR(imagefromfile(i,j))
mapped(i,j)=ACHAR(56)
CASE (86:100)
mapped(i,j)=ACHAR(imagefromfile(i,j))
mapped(i,j)=ACHAR(42)
!A useless CASE DEFAULT statement; it does nothing
CASE DEFAULT
PRINT*, "Sorry, no such thing..."
END SELECT
END DO
END DO
!Prints out the changed image
PRINT*, "After mapping..."
WRITE(UNIT=*, FMT=12) mapped
CLOSE(UNIT=10)
!Two different format for two different type
11 FORMAT (3I3)
12 FORMAT (3A3)
END PROGRAM mapper