2

I try to compile an old Fortran 90 program with gfortran but this doesn't work:

REAL(DP), DIMENSION(10,6) :: csCO2

csCO2(1,:) = (/DOUBLE PRECISION :: 0.0, 0.0, 0.18261340d7, &
0.79224365d2, 0.0, 0.0/)
csCO2(2,:) = (/DOUBLE PRECISION :: 0.0, 0.0, 0.0,&
0.66560660d-4, 0.57152798d-5, 0.3022236d-9/)

this give me the error:

csCO2(1,:) = (/DOUBLE PRECISION :: 0.0, 0.0, 0.18261340d7, &
           ^                                             
cf90-113 f90fe: ERROR FUGCO2, File = CO2EOS.f90, Line = 56, Column = 16 
  IMPLICIT NONE is specified in the local scope, therefore an explicit type 
must be specified for data object "DOUBLE".                      ^                                      
cf90-197 f90fe: ERROR FUGCO2, File = CO2EOS.f90, Line = 56, Column = 23 
  Unexpected syntax: "/)" was expected but found "P".

How can I resolve this?

5
  • 1
    Why do you use 'DOUBLE PRECISION :: ' in the initialization? Commented Sep 20, 2018 at 7:30
  • 1
    Which version of gfortran are you using? Commented Sep 20, 2018 at 7:31
  • 1
    Please provide a minimal reproducible example. We cannot help with so little information. Commented Sep 20, 2018 at 7:33
  • 1
    And that doesn't look much like a gfortran error message. Please show the output of the compiler version information. Commented Sep 20, 2018 at 7:43
  • 1
    It looks like the Cray Fortran compiler Commented Sep 20, 2018 at 8:15

2 Answers 2

2

The array constructor syntax

(/ type :: value, ... /)

is not a Fortran 90 feature. It was introduced in Fortran 2003.

The error from the compilation shows that your compiler does not recognize this syntax. You should use a later compiler with support for such array constructors.

You could modify the source code, in this case to,

 csCO2(1,:) = (/0.0_dp, 0.0_dp, 0.18261340e7_dp, 0.79224365e2_dp, 0.0_dp, 0.0_dp/)

etc., but you are much better off using a modern compiler.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you @francescalus, As I've answered at same time, changing compiler does the trick.
Still, even if you changed compiler, you should use the snippet provided by @francescalus. In the original code you are mixing a custom parameter kind (dp) with the intrinsic double precision. Stick to just one (the former, preferably)
0

Changed from gfortran to x86_64-w64-mingw32-gfortran.exe and it work

1 Comment

The error message shown above is not from gfortran. Please correct the post to reflect the actual compiler you used.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.