Re: The joy of FORTRAN

Liste des GroupesRevenir à col misc 
Sujet : Re: The joy of FORTRAN
De : bowman (at) *nospam* montana.com (rbowman)
Groupes : alt.folklore.computers comp.os.linux.misc
Date : 19. Oct 2024, 04:03:55
Autres entêtes
Message-ID : <lnglsrFs9nrU7@mid.individual.net>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
User-Agent : Pan/0.149 (Bellevue; 4c157ba)
On Fri, 18 Oct 2024 05:41:41 -0000 (UTC), Lawrence D'Oliveiro wrote:

On 18 Oct 2024 04:35:09 GMT, rbowman wrote:
 
Our source tree still has vestiges of Fortran that go back more than 20
years and are strictly f77.
 
  recnum = 1 read(adrich,15,rec=recnum) totrec
15   format(i10)
 
100 if(recnum.gt.totrec) goto 500
  read(adrich,105,rec=recnum+1) ch
105 format(1a1)
 
You know that Fortran 77 introduced if-then and do-while, right?

In fact the continuation of the snippet is

105 format(1a1)
  if(ch.ge.'A' .and. ch.le.'Z') then
    index = ichar(ch) - 64
  else if(ch.ge.'1' .and. ch.le.'9') then
    index = ichar(ch) - 22
  else
    index = 36
  endif

All the DO constructs are variations on

DO 11 k=1,strlen
  STNAME(k) = ' '
11 CONTINUE

I'm not about to argue the niceties of ANSI Fortran 77 but

https://web.stanford.edu/class/me200c/tutorial_77/09_loops.html

while-loops
The most intuitive way to write a while-loop is

      while (logical expr) do
         statements
      enddo
or alternatively,

      do while (logical expr)
         statements
      enddo
The program will alternate testing the condition and executing the
statements in the body as long as the condition in the while statement is
true. Even though this syntax is accepted by many compilers, it is not
ANSI Fortran 77. The correct way is to use if and goto:

label if (logical expr) then
         statements
         goto label
      endif




Date Sujet#  Auteur
9 Jul 25 o 

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal