- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
According to the standard of F2018, a procedure, except a character(len= *) procedure, is intrinsically recursive, unless qualified with NON_RECURSIVE.
It is said that the intel fortran compiler fully supports F2018, but the well-known example below will not compile unless the attribute RECURSIVE is explicitly written.
program tes_recursive_routine
implicit none
integer :: n
do
write(*, '(/, a)', advance= 'no')'n= ' ; read(*,*)n
write(*, '(g0, a, g0)')n, '!= ', fat(n)
end do
CONTAINS
function fat(n) result (nfat)
integer :: nfat
integer, intent(in) :: n
if(n == 0)then
nfat= 1
else
nfat= n*fat(n - 1)
end if
return
end function fat
end program tes_recursive_routine
Compilation with ifort returns:
>ifort tes_recursive_routine.f90
tes_recursive_routine.f90(17): error #6437: A subroutine or function is calling itself recursively. [FAT]
nfat= n*fat(n - 1)
--------------^
compilation aborted for tes_recursive_routine.f90 (code 1)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Intel is quite (rightly so IMO) conservative of standards changes that change the behaviour of old (existing) code as in some case that can break working code. There are a number of later standards options that as Arjen noted get lumped into the standard-semantics option.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It is available via a compile option: -assume:recursion or -standard-semantics (which turns on a number of such options)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Intel is quite (rightly so IMO) conservative of standards changes that change the behaviour of old (existing) code as in some case that can break working code. There are a number of later standards options that as Arjen noted get lumped into the standard-semantics option.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
LISP is naturally recursive, so one writes in one fashion, adding recursion to Fortran late does cause potential problems for older code, this is not a natural change and so the change over needs to be sensitive to this fact. One also has the problem that with old Fortran code, the developers are retired or deceased and so fixing this code for straight recursion is a significant time problem.
Why recursion was not added before was always an interesting question, but all languages have problems, see Turing famous imitation paper for a great discussion on these types of challenging problems.
Think of US and metric, if you take an American to China and then at 2 am in the morning they need to provide a medicine to a child and this creates a huge problem as they try and sort out the conversions. Been there and you need someone who understands both systems or you can hurt the child. CHILDREN DIE IN THE US FROM THIS MEDICAL MISTAKE EVERY DAY.
So change is slow.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page