summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2022-09-20 20:36:13 +0200
committerIgor Pashev <pashev.igor@gmail.com>2022-09-20 20:37:16 +0200
commitb70d57b1bb12cfb5b5923537cc1615fd268aecd9 (patch)
tree77bbf62aaa8a099a0f1866d47705ef192f443b80
parent7e77b68f6879917a27a0fa3426b9ceef242a9879 (diff)
downloadgcd-b70d57b1bb12cfb5b5923537cc1615fd268aecd9.tar.gz
Update Fortran
-rw-r--r--gcd.f90 (renamed from gcd.f03)14
1 files changed, 5 insertions, 9 deletions
diff --git a/gcd.f03 b/gcd.f90
index c2c585d..c17c61c 100644
--- a/gcd.f03
+++ b/gcd.f90
@@ -1,6 +1,6 @@
! SYNOPSIS:
!
-! # gfortran -o gcd-f gcd.f03
+! # gfortran -o gcd-f gcd.f90
! # ./gcd-f 11 22 33 121
!
@@ -9,25 +9,21 @@ program GCD
integer, allocatable :: ns(:)
integer :: i, n
- character*20 :: tmpstr
+ character(len=20) :: tmpstr
n = command_argument_count()
- allocate (ns(n)) ! allocate memory for numbers given in command line
+ allocate (ns(n))
do i = 1, n
call get_command_argument(i, tmpstr)
ns(i) = str2int(tmpstr)
end do
- print *, gcdn(ns)
+ print '(I0)', gcdn(ns)
deallocate (ns)
-! If we declare functions first,
-! we have to specify its types within
-! the `program' section.
-! See http://en.wikibooks.org/wiki/Fortran/Fortran_procedures_and_functions
contains
pure integer function str2int(s)
@@ -45,7 +41,7 @@ contains
end function gcd2
pure integer function gcdn(n)
- integer, intent(in) :: n(:) ! n is an array
+ integer, intent(in) :: n(:)
integer :: i
gcdn = n(1)
do i = 2, size(n)