Distinguishing between characters and numbers
  Home FAQ Contact Sign in
comp.lang.fortran only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.fortran Profile…
 Up
Distinguishing between characters and numbers         


Author: SimonG
Date: Apr 22, 2008 01:53

I have built the following program with both ifort (Intel) and g95 but
they yield different results:

program ex
implicit none
real(8) :: x
integer :: n
character(10) :: buff

do
write(6,'(a)',advance='no') '> '
read(5,*) buff
read(buff,*,err=900) x
write(6,'(2a)') 'Number:',trim(buff)
cycle
900 continue
write(6,'(2a)') 'Command:',trim(buff)

end do

end program ex
Show full article (0.70Kb)
14 Comments
Re: Distinguishing between characters and numbers         


Author: Arjen Markus
Date: Apr 22, 2008 02:06

On 22 apr, 10:53, SimonG whiteowl.co.uk> wrote:
> I have built the following program with both ifort (Intel) and g95 but
> they yield different results:
>
> program ex
>   implicit none
>   real(8) :: x
>   integer :: n
>   character(10) :: buff
>
>   do
>      write(6,'(a)',advance='no') '> '
>      read(5,*) buff
>      read(buff,*,err=900) x
>      write(6,'(2a)') 'Number:',trim(buff)
>      cycle
> 900  continue
>      write(6,'(2a)') 'Command:',trim(buff)
>
>   end do ...
Show full article (1.11Kb)
no comments
Re: Distinguishing between characters and numbers         


Author: fj
Date: Apr 22, 2008 02:07

On 22 avr, 10:53, SimonG whiteowl.co.uk> wrote:
> I have built the following program with both ifort (Intel) and g95 but
> they yield different results:
>
> program ex
> implicit none
> real(8) :: x
> integer :: n
> character(10) :: buff
>
> do
> write(6,'(a)',advance='no') '> '
> read(5,*) buff
> read(buff,*,err=900) x
> write(6,'(2a)') 'Number:',trim(buff)
> cycle
> 900 continue
> write(6,'(2a)') 'Command:',trim(buff)
>
> end do ...
Show full article (0.97Kb)
no comments
Re: Distinguishing between characters and numbers         


Author: FX
Date: Apr 22, 2008 02:12

> I expected the Intel result but perhaps the standard is ambiguous on
> this. Is this a g95 bug?

I'd have the same expectation that you have, so I guess there's
> A second question: how do I enter a '/' character?

Well, you have a .co.uk address, so the '/' key should be on the left of
your right shift key ;-)

Hum, more seriously, you need to change your read's into:

read(5,'(a)') buff
read(buff,'(f20.0)',err=900) x

(Oh, and doing that fixes the issue with g95, apparently.)

--
FX
no comments
Re: Distinguishing between characters and numbers         


Author: FX
Date: Apr 22, 2008 02:12

> I expected the Intel result but perhaps the standard is ambiguous on
> this. Is this a g95 bug?

I'd have the same expectation that you have, so I guess there's a
bugreport to make (or at least feature request, as lots of other
compilers behave the other way).
> A second question: how do I enter a '/' character?

Well, you have a .co.uk address, so the '/' key should be on the left of
your right shift key ;-)

Hum, more seriously, you need to change your read's into:

read(5,'(a)') buff
read(buff,'(f20.0)',err=900) x

(Oh, and doing that fixes the issue with g95, apparently.)

--
FX
no comments
Re: Distinguishing between characters and numbers         


Author: SimonG
Date: Apr 22, 2008 03:09

On Apr 22, 10:12 am, "FX" alussinan.org> wrote:
>> I expected the Intel result but perhaps the standard is ambiguous on
>> this. Is this a g95 bug?
>
> I'd have the same expectation that you have, so I guess there's a
> bugreport to make (or at least feature request, as lots of other
> compilers behave the other way).
>
>> A second question: how do I enter a '/' character?
>
> Well, you have a .co.uk address, so the '/' key should be on the left of
> your right shift key ;-)
>
> Hum, more seriously, you need to change your read's into:
>
> read(5,'(a)') buff
> read(buff,'(f20.0)',err=900) x
>
> (Oh, and doing that fixes the issue with g95, apparently.)
> ...
Show full article (2.07Kb)
no comments
Re: Distinguishing between characters and numbers         


Author: Gordon Sande
Date: Apr 22, 2008 05:22

On 2008-04-22 07:09:19 -0300, SimonG whiteowl.co.uk> said:
> On Apr 22, 10:12 am, "FX" alussinan.org> wrote:
>>> I expected the Intel result but perhaps the standard is ambiguous on
>>> this. Is this a g95 bug?
>>
>> I'd have the same expectation that...
Show full article (2.91Kb)
no comments
Re: Distinguishing between characters and numbers         


Author: Gary Scott
Date: Apr 22, 2008 05:36

Gordon Sande wrote:
> On 2008-04-22 07:09:19 -0300, SimonG whiteowl.co.uk> said:
>
>> On Apr 22, 10:12 am, "FX" alussinan.org> wrote:
>>
>>>> I expected the Intel result but perhaps the standard is ambiguous...
Show full article (2.10Kb)
no comments
Re: Distinguishing between characters and numbers         


Author: Dick Hendrickson
Date: Apr 22, 2008 05:42

SimonG wrote:
> On Apr 22, 10:12 am, "FX" alussinan.org> wrote:
>>> I expected the Intel result but perhaps the standard is ambiguous on
>>> this. Is this a g95 bug?
>> I'd have the same expectation that you have, so I guess there's a
>> bugreport to make (or at least feature request, as lots of other
>> compilers behave the other way).
>>
>>> A second question: how do I enter a '/' character?
>> Well, you have a .co.uk address, so the '/' key should be on the left of
>> your right shift key ;-)
>>
>> Hum, more seriously, you need to change your read's into:
>>
>> read(5,'(a)') buff
>> read(buff,'(f20.0)',err=900) x
>>
>> (Oh, and doing that fixes the issue with g95, apparently.)
>>
>> -- ...
Show full article (3.38Kb)
no comments
Re: Distinguishing between characters and numbers         


Author: SimonG
Date: Apr 22, 2008 06:18

On Apr 22, 1:42 pm, Dick Hendrickson att.net> wrote:
> SimonG wrote:
>> On Apr 22, 10:12 am, "FX" alussinan.org> wrote:
>>>> I expected the Intel result but perhaps the standard is ambiguous on
>>>> this. Is this a g95 bug?
>>> I'd have the same expectation that you have, so I guess there's a
>>> bugreport to make (or at least feature request, as lots of other
>>> compilers behave the other way).
>
>>>> A second question: how do I enter a '/' character?
>>> Well, you have a .co.uk address, so the '/' key should be on the left of
>>> your right shift key ;-)
>
>>> Hum, more seriously, you need to change your read's into:
>
>>> read(5,'(a)') buff
>>> read(buff,'(f20.0)',err=900) x
>
>>> (Oh, and doing that fixes the issue with g95, apparently.)
> ...
Show full article (4.26Kb)
no comments

RELATED THREADS
SubjectArticles qty Group
Standard number format and number of digitscomp.sys.hp48 ·
1 2