Inspired by the redundant parentheses thread, I looked up the rules for complex literals.
If both parts of the literal constant are of type real, the kind type parameter of the literal constant is the kind parameter of the part with the greater precision, and the kind type parameter of the part with lower precision is converted to that of the other part.
If both parts are of type integer, they are each converted to type default real. If one part is of type integer and the other is of type real, the integer is converted to type real with the precision of the real part.
They surprised me. Good tweet material . Here is an illustrative program.
program complex_numbers
implicit none
integer, parameter :: dp = kind(1.0d0)
real :: r1=2.0, r2 = 3.0
real, parameter :: c1 = 2.0, c2 = 3.0
real(kind=dp), parameter :: d1 = 2.0_dp, d2 = 3.0_dp
! line below invalid since r1 and r2 are not constants
! print*,(r1,r2)
print*,"r1,r2",r1,r2
print*,"c1,c2",c1,c2
print*,"d1,d2",d1,d2
print*,"(c1,c2)",(c1,c2)
print*,"(2.0,3.0)",(2.0,3.0)
print*,"(2,3)",(2,3),"integers converted to default real in complex constructor"
print*,"(2,3.0)",(2,3.0),"both parts of complex number are default real"
print*,"(2.0d0,3.0)",(2.0d0,3.0),"both parts have the higher precision"
print*,"cmplx(r1,r2)",cmplx(r1,r2),"complex number where the real and imaginary parts are variables"
print*,"cmplx(d1,d2)",cmplx(d1,d2),"single precision complex number, because no kind specified!"
print*,"cmplx(d1,d2,kind=dp)",cmplx(d1,d2,kind=dp),"double precision complex number"
end program complex_numbers
output:
r1,r2 2.00000000 3.00000000
c1,c2 2.00000000 3.00000000
d1,d2 2.0000000000000000 3.0000000000000000
(c1,c2) (2.00000000,3.00000000)
(2.0,3.0) (2.00000000,3.00000000)
(2,3) (2.00000000,3.00000000) integers converted to default real in complex constructor
(2,3.0) (2.00000000,3.00000000) both parts of complex number are default real
(2.0d0,3.0) (2.0000000000000000,3.0000000000000000) both parts have the higher precision
cmplx(r1,r2) (2.00000000,3.00000000) complex number where the real and imaginary parts are variables
cmplx(d1,d2) (2.00000000,3.00000000) single precision complex number, because no kind specified!
cmplx(d1,d2,kind=dp) (2.0000000000000000,3.0000000000000000) double precision complex number