Fortran textbook

I have an open source C++/Fortran textbook. See https://theartofhpc.com/ and go to volume 3. Comments always welcome.

17 Likes

The books are nicely formatted with beautiful color schemes. However, reading https://github.com/VictorEijkhout/TheArtofHPC_pdfs/blob/main/vol3/EijkhoutIntroSciProgramming-book.pdf I see some confusions.

  1. The book is about Fortran 2008 but it does not mention 2008 standards but 2003. For instance

Remark 32 In Fortran77, 19 continuation lines were allowed. In Fortran95 this number was 40. As of the Fortran2003 standard, a line can be continued 256 times.

Remark 33 In Fortran66 there was a limit of six characters to the length of a variable name, though many compilers had extensions to this. As of the Fortran2003 standard, a variable name can be 63 characters long.

1 Like

Page.413


program main
   implicit none
   integer,parameter::n=5
   real(8),dimension(2:N+1) :: Afrom1 = & !Aform2 -> Aform1
             [1,2,3,4,5] 
   integer::lo,hi,i
   lo = lbound(Afrom1,1)
   hi = ubound(Afrom1,1)
   print *,lo,hi
   print '(i3,":",f5.3)',  &
           (i,Afrom1(i),i=lo,hi)
end program main

the result should be

            2            6
  2:1.000
  3:2.000
  4:3.000
  5:4.000
  6:5.000
2 Likes