INTEGER or REAL?

Angelo Graziosi angelo.graziosi@alice.it
Sun Aug 22 23:00:00 GMT 2010


Sorry, but I do not understand why gfortran does not compile this code:

$ cat dp_test.f90
program dp_test
   implicit none
   integer, parameter :: DP = selected_real_kind(12,60)
   call foo(0_DP)
contains
   subroutine foo(x)
     real(DP), intent(in) :: x
     print *, x
   end subroutine foo
end program dp_test

$ gfortran dp_test.f90
dp_test.f90:4.11:

   call foo(0_DP)
            1
Error: Type mismatch in argument 'x' at (1); passed INTEGER(8) to REAL(8)

WHY is '0_DP' interpreted as an 'INTEGER(8)' and not as a REAL(DP)?

For example, I can omit the dot in '0D0', '1D0' etc. WHY can't I do the 
same with '_DP' ('0_DP', '1_DP' etc.)?

Sorry, I am just curious...

Ciao,
Angelo.



More information about the Fortran mailing list