DAVID LEAL wrote
>A simple examples:
>1.
>--------------------------
>program fo
>real, dimension(2):: a=(/1.0,2.2/)
>write(*,'(i3,1x,f4.1)') a
>end
>--------------------------
>it works under HP-UX but under DVF the execution
>exits because it is waiting for a real format, so it is not
>posible to write a real variable in a integer format even if
>I know previously that it has an integer value(a(1)=1). Is
>that restriction standard?
>
I *think* that this is nonstandard. If you know that the
value will be integer, and want it printed as an
integer, why not cast it to integer?
write(*,'(i3,1x,f4.1)') int(a(1)), a(2)
Or print it with '(f3.0, 1x, f4.1)'?
You get a pretty period after the number, making it
look as if you want an itemised list :)
>2. About logical expresions
>-------------------------
>program fo
>ion(2):: a=(/1.0,2.2/)
>flag=.true.
>if(flag .eq. .true.)print*, 'hola' ! 1
>if(flag)print*, 'hola' !2
>flag=.false.
>if(flag .eq. .false.)print*, 'hola' !3
>if(.not. flag)print*, 'hola' !4
>end
>
>It works under HP-UX, but under DVF if gives me errors with
>the lines !1 and !3, why? Is this logical operation
>nonstandard("flag .eq. .true." or "flag .eq. false")?
>
Yes, it is nonstandard. LOGICAL should be
compared using .EQV. rather than .EQ.
The logical comparisons .EQV. have low priority;
A .EQ. B .OR. C .EQ. D
is equivalent to
(A .EQ. B) .OR. (C .EQ. D)
A .EQV. B . OR. C .EQV. D
is equivalent to
(A .EQV. (B .OR. C)) .EQV. D
I wasted several days debugging a program, because
I assumed that .EQ. and .EQV. had comparable priority
levels.
Regards,
Jeremy Dudley
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|