Help me with deciphering continuation within DATA statement

I’m new to Fortran and trying to compile this code using pgf90.
The code is partially written in F77 and the rest is in F90, which compiled happily using gfortran, but pgfortran wasn’t very happy, and I did a bit of clean up, made pgfortran mostly happy except this one.


!C *****************************************************                           
!C *                   GAMMA FUNCTION                  *                           
!C *                IN DOUBLE PRECISION                *                           
!C *      COPYRIGHT : M.MORI  JUNE 30 1989  V.1        *                           
!C *****************************************************                           
      IMPLICIT REAL*8 (A-H,O-Z)                                                 

      DIMENSION C(0:19)                                                         
      DATA IN / 19 /                                                            

!C     ---- FOR SINGLE PRECISION ----                                            
!C     DATA IN / 10 /                                                            

      DATA C /  1.0                   D0,  
     1         -0.42278 43350 98467 1 D0, 
     2         -0.23309 37364 21786 7 D0,
     3          0.19109 11013 87691 5 D0,
     4         -0.24552 49000 54000 2 D-1,
     5         -0.17645 24455 01443 2 D-1,
     6          0.80232 73022 26734 7 D-2,
     7         -0.80432 97756 04247 0 D-3,
     8         -0.36083 78162 548     D-3,
     9          0.14559 61421 399     D-3,
     1         -0.17545 85975 17      D-4,
     1         -0.25889 95022 4       D-5,
     2          0.13385 01546 6       D-5,
     3         -0.20547 43152         D-6,
     4         -0.15952 68            D-9,
     5          0.62756 218           D-8,
     6         -0.12736 143           D-8,
     7          0.92339 7             D-10,
     8          0.12002 8             D-10,
     9         -0.42202               D-11 /



$ pgf90 -Mextend hb_high_v5.4.5_np2mm+.F90
PGF90-S-0034-Syntax error at or near identifier d0 (hb_high_v5.4.5_np2mm+.F90: 2387)
PGF90-S-0034-Syntax error at or near - (hb_high_v5.4.5_np2mm+.F90: 2388)
PGF90-S-0034-Syntax error at or near - (hb_high_v5.4.5_np2mm+.F90: 2389)
PGF90-S-0034-Syntax error at or near real constant -6.5804832E+33 (hb_high_v5.4.5_np2mm+.F90: 2390)
PGF90-S-0034-Syntax error at or near - (hb_high_v5.4.5_np2mm+.F90: 2391)
PGF90-S-0034-Syntax error at or near - (hb_high_v5.4.5_np2mm+.F90: 2392)
PGF90-S-0034-Syntax error at or near real constant -6.5804832E+33 (hb_high_v5.4.5_np2mm+.F90: 2393)
PGF90-S-0034-Syntax error at or near - (hb_high_v5.4.5_np2mm+.F90: 2394)
PGF90-S-0034-Syntax error at or near - (hb_high_v5.4.5_np2mm+.F90: 2395)
PGF90-S-0034-Syntax error at or near real constant -6.5804832E+33 (hb_high_v5.4.5_np2mm+.F90: 2396)
PGF90-S-0034-Syntax error at or near - (hb_high_v5.4.5_np2mm+.F90: 2397)
PGF90-S-0034-Syntax error at or near - (hb_high_v5.4.5_np2mm+.F90: 2398)
PGF90-S-0034-Syntax error at or near real constant -6.5804832E+33 (hb_high_v5.4.5_np2mm+.F90: 2399)
PGF90-S-0034-Syntax error at or near - (hb_high_v5.4.5_np2mm+.F90: 2400)
PGF90-S-0034-Syntax error at or near - (hb_high_v5.4.5_np2mm+.F90: 2401)
PGF90-S-0034-Syntax error at or near real constant -6.5804832E+33 (hb_high_v5.4.5_np2mm+.F90: 2402)
PGF90-S-0034-Syntax error at or near - (hb_high_v5.4.5_np2mm+.F90: 2403)
PGF90-S-0034-Syntax error at or near real constant -6.5804832E+33 (hb_high_v5.4.5_np2mm+.F90: 2404)
PGF90-S-0034-Syntax error at or near real constant -6.5804832E+33 (hb_high_v5.4.5_np2mm+.F90: 2405)
PGF90-S-0034-Syntax error at or near - (hb_high_v5.4.5_np2mm+.F90: 2406)
  0 inform,   0 warnings,  20 severes, 0 fatal for dgamm

I can see that C is an array of size 20, where C(0)=1.0, and each value in the DATA statement assigned to C(1), C(2) etc.

But what C(1) is supposed to be? What are the heading numbers in the DATA statement doing? ie., 1, 2,3, 4, 5, 6, 7, 8, 9, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9? I guess they are just there with no effect, but as a visual aid to indicate the index, and as a result

C(1)=-0.4227843350984671 (D0 means no decimal place movement)

Now, any idea how I can compile this code? I tried to add & at the end of each line, and it made some difference, not entirely.

      DATA C /  1.0                   D0, & 
     1         -0.42278 43350 98467 1 D0, &
     2         -0.23309 37364 21786 7 D0, &
     3          0.19109 11013 87691 5 D0, &
     4         -0.24552 49000 54000 2 D-1, &
     5         -0.17645 24455 01443 2 D-1, &
     6          0.80232 73022 26734 7 D-2, &
     7         -0.80432 97756 04247 0 D-3, &
     8         -0.36083 78162 548     D-3, &
     9          0.14559 61421 399     D-3, &
     1         -0.17545 85975 17      D-4, &
     1         -0.25889 95022 4       D-5, &
     2          0.13385 01546 6       D-5, &
     3         -0.20547 43152         D-6, &
     4         -0.15952 68            D-9, &
     5          0.62756 218           D-8, &
     6         -0.12736 143           D-8, &
     7          0.92339 7             D-10, &
     8          0.12002 8             D-10, &
     9         -0.42202               D-11 /



$ pgf90 -Mextend hb_high_v5.4.5_np2mm+.F90
PGF90-S-0034-Syntax error at or near identifier d0 (hb_high_v5.4.5_np2mm+.F90: 2387)
  0 inform,   0 warnings,   1 severes, 0 fatal for dgamm

Thanks in advance!

Hello,

You are running into the differences between fixed formatting of
fortran 77 and free formatting of fortran 90 (and newer). pgfortran
supports both, but not in the same source file.

pgfortran -c foo.f ! assumes fixed formatting ie -Mfixed
pgfortran -c foo.F ! assumes fixed and preprocessing ie -Mfixed -Mpreprocess

pgfortran -c foo.f90 ! assumes free formatting ie -Mfree
pgfortran -c foo.F90 ! assumes free and preprocessing ie -Mfree -Mpreprocess

Continuation in fixed format
everything up to column 72 is read. This continues to next
line if there is a character in column 6. Code begins in column 7,
line numbers 1-5. To read beyond column 72 to column 132, add
-Mextend.

Continuation in free format
everything up to column 132 is read. This continues to next
line if there is a ‘&’ character at the end of the line. Code begins in any column.


So decide if you are fixed or free. You probably want free, so either
change the extensions, or add -Mfree to the compile line. Also, use
‘&’ at end of line and NOT a character in column 6.

In other words, what you need in free format is the following DATA statement:

      DATA C /  1.0D0,   &
               -0.4227843350984671D0,   &
               -0.2330937364217867D0,   &
                0.1910911013876915D0,   &
               -0.2455249000540002D-1,  &
               -0.1764524455014432D-1,  &
                0.8023273022267347D-2,  &
               -0.8043297756042470D-3,  &
               -0.3608378162548D-3,     &
                0.1455961421399D-3,     &
               -0.175458597517D-4,      &
               -0.25889950224D-5,       &
                0.13385015466D-5,       &
               -0.2054743152D-6,        &
               -0.1595268D-9,           &
                0.62756218D-8,          &
               -0.12736143D-8,          &
                0.923397D-10,           &
                0.120028D-10,           &
               -0.42202D-11 /

(corrected by removing embedded blanks in numbers)

Yes, that would be the way to write it in free form.

dave

Contrary to previous advice, formatting lines such as

      DATA C /  1.0                   D0,   &
               -0.42278 43350 98467 1 D0,   &

is not how to prepare free-form source. Your compiler should reject such source.

In free-form source, spaces are significant and cannot appear in the middle of a real literal constant.

You should instead write something like

      DATA C /  1.0D0,   &
               -0.4227843350984671D0,   &

or use zeros for padding.

Many people would like free-form source to allow such splitting of real literal constant lumps, for readability, but it is not currently allowed.

Yes, I missed that. Thanks for the correction.

In free-form you can’t have white space in variables
and data, like you can in fixed form. So you need to remove the white
spaces, or use the fixed format ‘column 6 character’ method.

dave