[FORTRAN] Sorting matrix for 4 lowest values

Hi there,
That's my first post at forum, so i wanted to say hello to you all.
I'm from Poland and my English isn't very good, but i'll do my best.

Curentlly I'm working on application that will show 4 lowest values in matrix in the range <Amin,Amax> for my university. I have done all code but compiler shows some errors.

Here's the code:
Program Matrix
      implicit none
C	WYZNACZANIE CZTEREH MINIMALNYCH WARTOSCI MACIERZY Z PRZEDZIALU <Amin, Amax>
C
C	///Ustalanie zmiennych///
	REAL :: amin, amax, a1, a2, a3, a4
	REAL, allocatable,dimension(:,:) :: a
	INTEGER :: i1, i2, i3, i4, j1, j2, j3, j4, n, m, i, j
C	
C	///filling the matrix///
C	//collumns j->m//
C	//rows i->n//
	WRITE (*,*) 'Enter collumns'
	READ (*,*) m
	WRITE (*,*) 'Enter rows'
	READ (*,*) n
	WRITE (*,*) 'Enter Amin'
	READ (*,*) amin
	WRITE (*,*) 'Enter Amax'
	READ (*,*) amax
C	
	allocate(a(n,m))
	do i = 1, n
	do j = 1, m
	write(*,*) 'Enter element (', i,',', j,') of matrix'
	read(*,*) a(i,j)
	end do
	end do
	write(*,*) 'Your matrix:'
	do i = 1, n
	write(*,*) (a(i, j), j=1, m)
	end do
	pause
C	
C	///Searching four lowest values///
	  a1=amax
      i1=0
	  a2=amax
      i2=0
      a3=amax
      i3=0
	  a4=amax
      i4=0
	  i=1
45	  j=1
C	  
47	IF (a(i, j).GT.amax) THEN
		IF (a(i,j).GE.amin) THEN
			IF (a(i,j).GE.a1) THEN
            	IF (a(i,j).GE.a2) THEN
                	IF (a(i,j).GE.a3) THEN
                    	IF (a(i,j).GE.a4) THEN
                        	GOTO 94
                        END IF
                        a4=a(i,j)
						i4=i
						j4=j
                        GOTO 94
                    END IF
                    a4=a3
					i4=i3
					j4=j3
					a3=a(i,j)
					i3=i
					j3=j
                    GOTO 94
        		END IF
           		a4=a3
				i4=i3
				j4=j3
				a3=a2
				i3=i2
				j3=j2
				a2=a(i,j)
				i2=i
				j2=j
                GOTO 94
     		END IF
            a4=a3
			i4=i3
			j4=j3
			a3=a2
			i3=i2
			j3=j2
			a2=a1
			i2=i1
			j2=j1
			a1=a(i,j)
			i1=i
			j1=j
            GOTO 94
  		END IF
	END IF
94	j=j+1
		IF (j.LE.m) THEN 
			GOTO 47
		END IF
    	i=i+1
    	IF (i.LE.n) THEN
        	GOTO 45
        END IF
C	
C   	////Checking and printing///
		IF (a1.NE.amax) THEN
      		IF (a2.NE.amax) THEN
        		IF (a3.NE.amax) THEN
                	IF (a4.NE.amax) THEN
108                   	WRITE (*,*) 'WYZNACZONE WYRAZY'
                                WRITE (*,*) A1, 'Pozycja (', i1,',', j1,')'
                 		WRITE (*,*) A2, 'Pozycja (', i2,',', j2,')'
                 		WRITE (*,*) A3, 'Pozycja (', i3,',', j3,')'
                 		WRITE (*,*) A4, 'Pozycja (', i4,',', j4,')'
                        GOTO 152
                    ELSE 
                      IF (a4.EQ.0) THEN    
                        GOTO 123
                      ELSE 
                        GOTO 108
                      END IF
                    END IF
        		ELSE
                  IF (a3.NE.0) THEN
123				WRITE (*,*) 'WYZNACZONE WYRAZY'
                                WRITE (*,*) A1, 'Pozycja (', i1,',', j1,')'
                 		WRITE (*,*) A2, 'Pozycja (', i2,',', j2,')'
                 		WRITE (*,*) A3, 'Pozycja (', i3,',', j3,')'
                        GOTO 152
 				  ELSE
                  		GOTO 134
                  END IF
             	END IF
  			ELSE
              IF (a2.NE.0) THEN
134		 WRITE (*,*) 'WYZNACZONE WYRAZY'
                 WRITE (*,*) A1, 'Pozycja (', i1,',', j1,')'
                 WRITE (*,*) A2, 'Pozycja (', i2,',', j2,')'
                 GOTO 152
              ELSE
                		GOTO 144
              END IF
        	END IF
  		ELSE
          IF (a1.NE.0) THEN
144			WRITE (*,*) 'WYZNACZONY WYRAZ'
                 WRITE (*,*) A1, 'Pozycja (', i1,',', j1,')'
             GOTO 152 
          ELSE
             WRITE (*,*) 'NO RESULTS'
             GOTO 152
          END IF
        END IF
152	  PAUSE
	  END Program Matrix
                       
I tried to translate most important comments to english. That's my first application ever so sorry for the mess in code ;). But back to topic - those are these errors that compiler throw out:
Compiling file: mac.for
C:\Users\Kacper\Documents\mac.FOR(123) : error 70 - Unterminated character constant
C:\Users\Kacper\Documents\mac.FOR(134) : error 141 - Label 134 has been used outside the block IF starting on line 136
C:\Users\Kacper\Documents\mac.FOR(153) : warning 684 - There are (at least) 12 truncated line(s) in this file
Compilation failed.

I'm using Salford FTN95 compiler.
Sign In or Register to comment.