From: Berfux on
Hello,

consider the following program :

program diag

implicit none

complex :: z
real :: x
integer :: i

z = cmplx(1.5,2.5)
print*, "z=",z

x = z
print*, "x=",x

z = x
print*,"z=",z

i = x
print*,"i=",i

end program diag

In g95 (with option -Wall) I got two warnings :

x = z
1
Warning (140): Implicit conversion at (1) may cause precision loss

Iin the following compilers (Sun, Intel, gfortran) I could not find
such an option. Does it exist ? If not, do you think there is a good
reason ?

I ask the question because I have to modify a F90 software so that
some arguments can be complex instead of real. Such an option in the
compiler would help me check I my modifications.

Best regards
From: Harald Anlauf on
On Feb 15, 10:09 pm, Berfux <ber...(a)gmail.com> wrote:
> In g95 (with option -Wall) I got two warnings :
>
> x = z
>     1
> Warning (140): Implicit conversion at (1) may cause precision loss

The warning are correct.

> Iin the following compilers (Sun, Intel, gfortran) I could not find
> such an option. Does it exist ? If not, do you think there is a good
> reason ?

With gfortran, try -Wconversion to see implicit conversions in
expressions
and assignments.

> I ask the question because I have to modify a F90 software so that
> some arguments can be complex instead of real. Such an option in the
> compiler would help me check I my modifications.

Can you be more specific? It looks like you're after something
different.
The implicit conversions above do not apply to arguments passed to
procedures.
From: dpb on
Berfux wrote:
> Hello,
>
> consider the following program :
>
> program diag
>
> implicit none
>
> complex :: z
> real :: x
> integer :: i
>
> z = cmplx(1.5,2.5)
> print*, "z=",z
>
> x = z
> print*, "x=",x
>
> z = x
> print*,"z=",z
>
> i = x
> print*,"i=",i
>
> end program diag
>
> In g95 (with option -Wall) I got two warnings :
>
> x = z
> 1
> Warning (140): Implicit conversion at (1) may cause precision loss
>
> Iin the following compilers (Sun, Intel, gfortran) I could not find
> such an option. Does it exist ? If not, do you think there is a good
> reason ?
>
> I ask the question because I have to modify a F90 software so that
> some arguments can be complex instead of real. Such an option in the
> compiler would help me check I my modifications.

While I can could see a reason why you'd like to be able to find
instances of implicit type conversion as you've shown, I don't see that
it necessarily would warrant a warning as it can be intended. Hence I'm
not at all surprised many compilers don't include it in their warnings.

You might look at Understand for Fortran from Scitools and see if it's
clever enough to find such. If not, in my previous usage/evaluation w/
them I found them very amenable to adding features if they weren't very
difficult to do.

<www.scitools.com>

--
From: feenberg on
On Feb 15, 4:09 pm, Berfux <ber...(a)gmail.com> wrote:
> Hello,
>
> consider the following program :
>
> program diag
>
> implicit none
>
> complex :: z
> real    :: x
> integer :: i
>
> z = cmplx(1.5,2.5)
> print*, "z=",z
>
> x = z
> print*, "x=",x
>
> z = x
> print*,"z=",z
>
> i = x
> print*,"i=",i
>
> end program diag
>
> In g95 (with option -Wall) I got two warnings :
>
> x = z
>     1
> Warning (140): Implicit conversion at (1) may cause precision loss
>
> Iin the following compilers (Sun, Intel, gfortran) I could not find
> such an option. Does it exist ? If not, do you think there is a good
> reason ?
>
> I ask the question because I have to modify a F90 software so that
> some arguments can be complex instead of real. Such an option in the
> compiler would help me check I my modifications.
>
> Best regards

Can you suppress the message by making the conversion explicit?

http://gcc.gnu.org/onlinedocs/gcc-3.3.6/g77/RealPart-Intrinsic.html

Daniel Feenberg
From: JB on
On 2010-02-16, feenberg <feenberg(a)gmail.com> wrote:
> On Feb 15, 4:09�pm, Berfux <ber...(a)gmail.com> wrote:
>> I ask the question because I have to modify a F90 software so that
>> some arguments can be complex instead of real. Such an option in the
>> compiler would help me check I my modifications.
>>
>> Best regards
>
> Can you suppress the message by making the conversion explicit?
>
> http://gcc.gnu.org/onlinedocs/gcc-3.3.6/g77/RealPart-Intrinsic.html

Considering that the OP explicitly stated that he/she is working on a
F90 program, perhaps a more appropriate reference would be to the
documentation of a compiler that is actually a F90+ compiler, such as
g77's successor gfortran:

http://gcc.gnu.org/onlinedocs/gcc-4.4.3/gfortran/REAL.html

While gfortran does support the g77 REALPART intrinsic, the
documentation quite properly discourages it's use instead of the
standard REAL intrinsic.

While the comment in the g77 manual about using REALPART instead of
REAL due to inconsistent behavior of REAL might have made sense at
some point in the past, I find it very difficult to believe that any
of the widely available production quality F90 compilers today would
get this wrong anymore.

--
JB