fork download
  1.  
  2.  
  3. program GCD
  4.  
  5. module types
  6. integer, parameter :: dp=selected_integer_kind(15)
  7. end module
  8. program GCDenom
  9. use types
  10. implicit none
  11. interface
  12. function GCD(a,b)
  13. use types
  14. integer::q,r
  15. integer, intent(in)::a,b
  16. end function
  17. end interface
  18.  
  19. integer(dp) ::a,b,c, n, i
  20. integer dimensions(:,:) allocatable::gamma
  21.  
  22. write(*,*) "How many integers to compare?"
  23. read(*,*) n
  24. allocate (gamma(n))
  25. write(*,*) "Enter Values"
  26. read(*,*) gamma(n)
  27. a=gamma(1)
  28. b=gamma(2)
  29.  
  30. if (n<3) then
  31. c=gcd(a,b)
  32. write(*,*) "GCD =", c
  33. else
  34. do i= 3,n
  35. c=gcd(a,b)
  36. a=c
  37. b=gamma(i)
  38. end do
  39. end if
  40. write(*,*) "GCD = ", c
  41.  
  42. stop
  43. end program GCdenom
  44.  
  45. function GCD(a,b)
  46. use types
  47. implicit none
  48. real(dp)::q,r
  49. integer, intent(in)::a,b
  50. do
  51. if (b==0) then
  52. gcd=a
  53. return
  54. else
  55. q=floor(real(a)/real(b))
  56. r=((b*q)/a)
  57. a=b
  58. b=r
  59. end if
  60. end do
  61.  
  62. end function
  63.  
  64.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
3
6,15,8

compilation info
prog.f95:5.12:

module types
            1
Error: Unexpected MODULE statement at (1)
prog.f95:6.25:

integer, parameter :: dp=selected_integer_kind(15)
                         1
Error: Function 'selected_integer_kind' in initialization expression at (1) must be an intrinsic or a specification function
prog.f95:7.3:

end module
   1
Error: Expecting END PROGRAM statement at (1)
prog.f95:8.15:

program GCDenom
               1
Error: Unexpected PROGRAM statement at (1)
prog.f95:9.9:

use types
         1
Error: Unexpected USE statement at (1)
prog.f95:10.13:

implicit none
             1
Error: Unexpected IMPLICIT NONE statement at (1)
prog.f95:11.9:

interface
         1
Error: Unexpected INTERFACE statement at (1)
prog.f95:12:

function GCD(a,b)
1
Error: Unclassifiable statement at (1)
prog.f95:13.18:

         use types
                  1
Error: Unexpected USE statement at (1)
prog.f95:14.21:

         integer::q,r
                     1
Error: Unexpected data declaration statement at (1)
prog.f95:15.33:

         integer, intent(in)::a,b
                                 1
Error: Unexpected data declaration statement at (1)
prog.f95:16.12:

         end function
            1
Error: Expecting END PROGRAM statement at (1)
prog.f95:17.12:

         end interface
            1
Error: Expecting END PROGRAM statement at (1)
prog.f95:19.8:

integer(dp) ::a,b,c, n, i
        1
Error: Parameter 'dp' at (1) has not been declared or is a variable, which does not reduce to a constant expression
prog.f95:20.23:

integer dimensions(:,:) allocatable::gamma
                       1
Error: Syntax error in data declaration at (1)
prog.f95:24.15:

allocate (gamma(n))
               1
Error: Syntax error in ALLOCATE statement at (1)
prog.f95:26.18:

   read(*,*) gamma(n)
                  1
Error: Syntax error in READ statement at (1)
prog.f95:31.9:

    c=gcd(a,b)
         1
Error: Symbol at (1) is not appropriate for an expression
prog.f95:35.8:

   c=gcd(a,b)
        1
Error: Symbol at (1) is not appropriate for an expression
prog.f95:43.22:

   end program GCdenom
                      1
Error: Expected label 'gcd' for END PROGRAM statement at (1)
prog.f95:45:

function GCD(a,b)
1
Error: Unclassifiable statement at (1)
prog.f95:46.9:

use types
         1
Error: Unexpected USE statement at (1)
prog.f95:47.13:

implicit none
             1
Error: Unexpected IMPLICIT NONE statement at (1)
prog.f95:48.5:

real(dp)::q,r
     1
Error: Parameter 'dp' at (1) has not been declared or is a variable, which does not reduce to a constant expression
prog.f95:49.24:

integer, intent(in)::a,b
                        1
Error: Unexpected data declaration statement at (1)
Fatal Error: Error count reached limit of 25.
stdout
Standard output is empty