<!-- hamlet
<!-- copytar
examples/                                                                                           0040755 0002611 0000666 00000000000 06036534576 0013703 5                                                                                                    ustar 00hamlet                          hamlet                          377777770001017                                                                                                                                                                        examples/sroot1.f                                                                                   0100644 0002611 0000666 00000001151 06032335623 0015260 0                                                                                                    ustar 00hamlet                          hamlet                          377777770001017                                                                                                                                                                        C Created:  Joe Zachary, October 26, 1992
C Modified:

C This function takes a real number "X" as an argument and computes
C its square root using an approximation algorithm.

      REAL FUNCTION SROOT (X, COUNT)

      IMPLICIT NONE
      REAL X, GUESS
      INTEGER COUNT, I

      GUESS = 1
      DO I = 1, COUNT
         GUESS = (GUESS + X/GUESS) / 2
      ENDDO

      SROOT = GUESS
      RETURN
      END



      PROGRAM TEST

      IMPLICIT NONE
      REAL SROOT, X

      PRINT *, 'Please enter a positive real number'
      READ *, X

      PRINT *, 'The square root is ', SROOT(X, 5)

      STOP
      END
                                                                                                                                                                                                                                                                                                                                                                                                                       examples/search2.f                                                                                  0100644 0002611 0000666 00000001577 06032335623 0015374 0                                                                                                    ustar 00hamlet                          hamlet                          377777770001017                                                                                                                                                                        C Another version of the SEARCH function

C Created:  Joe Zachary, November 4, 1992
C Modified:


C This function returns 1 if the array DATA contains the number N,
C and returns 0 otherwise.

      INTEGER FUNCTION SEARCH (DATA, SIZE, N)

      IMPLICIT NONE
      INTEGER SIZE, DATA(SIZE), N
      INTEGER I

      DO I = 1, SIZE
         IF (DATA(I) .EQ. N) THEN
            SEARCH = 1
            RETURN
         ENDIF
      ENDDO

      SEARCH = 0
      RETURN

      END



      PROGRAM TEST

      IMPLICIT NONE
      INTEGER SIZE, SEARCH
      PARAMETER (SIZE=5)
      INTEGER A(SIZE), I

      DO I = 1, SIZE
         A(I) = I*I
      ENDDO

      PRINT *, 'Please enter an integer'
      READ *, I

      IF (SEARCH(A, SIZE, I) .EQ. 1) THEN
         PRINT *, 'The number is in the array'
      ELSE
         PRINT *, 'The number is not in the array'
      ENDIF

      STOP
      END
                                                                                                                                 examples/search1.f                                                                                  0100644 0002611 0000666 00000001623 06032335623 0015363 0                                                                                                    ustar 00hamlet                          hamlet                          377777770001017                                                                                                                                                                        C Illustrates the structured use of GOTO

C Created:  Joe Zachary, November 4, 1992
C Modified:


C This function returns 1 if the array DATA contains the number N,
C and returns 0 otherwise.

      INTEGER FUNCTION SEARCH (DATA, SIZE, N)

      IMPLICIT NONE
      INTEGER SIZE, DATA(SIZE), N
      INTEGER I

      DO I = 1, SIZE
         IF (DATA(I) .EQ. N) GOTO 20
      ENDDO

 20   IF (I .GT. SIZE) THEN
         SEARCH = 0
      ELSE
         SEARCH = 1
      ENDIF

      RETURN
      END



      PROGRAM TEST

      IMPLICIT NONE
      INTEGER SIZE, SEARCH
      PARAMETER (SIZE=5)
      INTEGER A(SIZE), I

      DO I = 1, SIZE
         A(I) = I*I
      ENDDO

      PRINT *, 'Please enter an integer'
      READ *, I

      IF (SEARCH(A, SIZE, I) .EQ. 1) THEN
         PRINT *, 'The number is in the array'
      ELSE
         PRINT *, 'The number is not in the array'
      ENDIF

      STOP
      END
                                                                                                             examples/sroot2.f                                                                                   0100644 0002611 0000666 00000001205 06032335623 0015261 0                                                                                                    ustar 00hamlet                          hamlet                          377777770001017                                                                                                                                                                        C Created:  Joe Zachary, October 26, 1992
C Modified:

C This function takes a real number "X" as an argument and computes
C its square root using an approximation algorithm.

      REAL FUNCTION SROOT (X, PRECISION)

      IMPLICIT NONE
      REAL X, GUESS, PRECISION

      GUESS = 1

      DO WHILE (ABS(X - GUESS*GUESS) .GT. PRECISION)
        GUESS = (GUESS + X/GUESS) / 2
      ENDDO

      SROOT = GUESS
      RETURN
      END



      PROGRAM TEST

      IMPLICIT NONE
      REAL SROOT, X

      PRINT *, 'Please enter a positive real number'
      READ *, X

      PRINT *, 'The square root is ', SROOT(X, .00001)

      STOP
      END
   A(I) = I*I
      ENDDO

      PRINT *, 'Please enter an integer'
      READ *, I

      IF (SEARCH(A, SIZE, I) .EQ. 1) THEN
         PRINT *, 'The number is in the array'
      ELSE
         PRINT *, 'The number is not in the array'
      ENDIF

      STOP
      END
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             