Re: Fortran Features
- From: "Jugoslav Dujic" <jdujic@xxxxxxxxx>
- Date: Fri, 10 Feb 2006 12:29:49 +0100
Paul Van Delst wrote:
| I haven't needed to use a label (for GOTOing, END=, or ERR=) for years[*]. I
| can't think what else you'd need them for without a current f95 construct
| being more natural (although I haven't thought too hard about it).
Error handling. Consider:
open(somefile)
open(anotherfile)
allocate(someglobal)
allocate(anotherglobal)
allocate(bunchastuff)
do...
call foo(ierror)
if (ierror/=0) then
write(*,*) "Error code: ", ierror
close(somefile)
close(anotherfile)
deallocate(someglobal)
deallocate(anotherglobal)
deallocate(bunchastuff)
return
end if
call bar(ierror)
if (ierror/=0) then
write(*,*) "Error code: ", ierror
close(somefile)
close(anotherfile)
deallocate(someglobal)
deallocate(anotherglobal)
deallocate(bunchastuff)
return
end if
call baz(ierror)
if (ierror/=0) then
write(*,*) "Error code: ", ierror
close(somefile)
close(anotherfile)
deallocate(someglobal)
deallocate(anotherglobal)
deallocate(bunchastuff)
return
end if
...
end do
end subroutine
==========================================
compare with:
open(somefile)
open(anotherfile)
allocate(someglobal)
allocate(anotherglobal)
allocate(bunchastuff)
do...
call foo(ierror)
if (ierror/=0) goto 100
call bar(ierror)
if (ierror/=0) goto 100
call bar(ierror)
if (ierror/=0) goto 100
end do
return
100 continue
write(*,*) "Error code: ", ierror
close(somefile)
close(anotherfile)
deallocate(someglobal)
deallocate(anotherglobal)
deallocate(bunchastuff)
end subroutine
I think even Dijkstra would agree :-).
--
Jugoslav
___________
www.xeffort.com
Please reply to the newsgroup.
You can find my real e-mail on my home page above.
.
- Follow-Ups:
- Re: Fortran Features
- From: robin
- Re: Fortran Features
- From: James Giles
- Re: Fortran Features
- From: Paul Van Delst
- Re: Fortran Features
- References:
- Fortran Features
- From: Joe
- Re: Fortran Features
- From: James Van Buskirk
- Re: Fortran Features
- From: Joe
- Re: Fortran Features
- From: James Van Buskirk
- Re: Fortran Features
- From: Joe
- Re: Fortran Features
- From: Paul Van Delst
- Fortran Features
- Prev by Date: Re: command line input and output
- Next by Date: Re: command line input and output
- Previous by thread: Re: Fortran Features
- Next by thread: Re: Fortran Features
- Index(es):
Relevant Pages
|