What is wrong with this search for the character PV/PQ
  Home FAQ Contact Sign in
comp.lang.fortran only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.fortran Profile…
 Up
What is wrong with this search for the character PV/PQ         


Author: sara_patty
Date: Jan 17, 2008 14:17

program readcvcq
Implicit integer*2 (I-N)
character*8 C,'PV/PQ'
character*36 fn,fn1
character*8 cvocq (10)
parameter(fn='sxsoutfile')
parameter(fn1='dummy')
open (unit = 15, file=fn,status='old',access='sequential'
$ ,form='formatted')
open (unit = 16, file=fn1,status='old',access='sequential'
$ ,form='formatted')
do kount=1,1000
read (15,901,end=999) c,(cvocq(i),i=1,8)
c
c if (kount .gt. 163 .and. kount .lt. 170) write(16,902) c
c if (kount .gt. 163 .and. kount .lt. 170) write(6,*) kount
write (6,902) c,(cvocq(i), i=1,8)
if (c .eq. PV/PQ ) write (16,902) c,(cvocq(i), i=1,8)
enddo
c ...
Show full article (0.79Kb)
21 Comments
Re: What is wrong with this search for the character PV/PQ         


Author: glen herrmannsfeldt
Date: Jan 17, 2008 14:35

sara_patty wrote:
(snip)
> character*8 C,'PV/PQ'

(snip)
> if (c .eq. PV/PQ ) write (16,902) c,(cvocq(i), i=1,8)

I thought Fortran didn't allow comparing character variables
(like c) to numeric expressions (like PV divided by PQ).

In any case, it isn't likely that they are equal since PV and PQ
haven't been given values.

-- glen
no comments
Re: What is wrong with this search for the character PV/PQ         


Author: dpb
Date: Jan 17, 2008 14:45

sara_patty wrote:
> program readcvcq
> Implicit integer*2 (I-N)
> character*8 C,'PV/PQ'
...
> if (c .eq. PV/PQ ) write (16,902) c,(cvocq(i), i=1,8)

One problem is that PV/PQ isn't character, it's the ratio of two reals.

Try something like

if (c .eq. 'PV/PQ') write (16,902) c,(cvocq(i), i=1,8)

This works since the .eq. comparison pads the shorter of two unequal
character variables w/ blanks to equal the length of the longer.

You might also look at the INDEX() intrinsic and other character-related
intrinsic functions for more...

--
no comments
Re: What is wrong with this search for the character PV/PQ         


Author: e p chandler
Date: Jan 17, 2008 14:52

On Jan 17, 5:17 pm, sara_patty yahoo.com> wrote:
>          program readcvcq
>          Implicit integer*2 (I-N)
>         character*8 C,'PV/PQ'

'PV/PQ' is a character literal NOT a variable. It is not allowed here.
Even if you had wanted to initialize C to this value - that would make
no sense as you are over writing its contents later.
Show full article (1.57Kb)
no comments
Re: What is wrong with this search for the character PV/PQ         


Author: Reagan Revision
Date: Jan 17, 2008 19:38

"sara_patty" yahoo.com> wrote in message
news:f39293e3-7eb0-411f-b9f7-5529055261ff@21g2000hsj.googlegroups.com...
> program readcvcq
> Implicit integer*2 (I-N)
> character*8 C,'PV/PQ'
> character*36 fn,fn1
> character*8 cvocq (10)
> parameter(fn='sxsoutfile')
> parameter(fn1='dummy')
> open (unit = 15, file=fn,status='old',access='sequential'
> $ ,form='formatted')
> open (unit = 16, file=fn1,status='old',access='sequential'
> $ ,form='formatted')
> do kount=1,1000
> read (15,901,end=999) c,(cvocq(i),i=1,8)
> c
> c if (kount .gt. 163 .and. kount .lt. 170) write(16,902) c
> c if (kount .gt. 163 .and. kount .lt. 170) write(6,*) kount
> write (6,902) c,(cvocq(i), i=1,8)
> if (c .eq. PV/PQ ) write (16,902) c,(cvocq(i), i=1,8) ...
Show full article (1.81Kb)
no comments
Re: What is wrong with this search for the character PV/PQ         


Author: sara_patty
Date: Jan 18, 2008 06:26

On Jan 17, 11:38 pm, "Reagan Revision" invalid.net> wrote:
> "sara_patty" yahoo.com> wrote in message
>
> news:f39293e3-7eb0-411f-b9f7-5529055261ff@21g2000hsj.googlegroups.com...
>
>> program readcvcq
>> Implicit integer*2 (I-N)
>> character*8 C,'PV/PQ'
>> character*36 fn,fn1
>> character*8 cvocq (10)
>> parameter(fn='sxsoutfile')
>> parameter(fn1='dummy')
>> open (unit = 15, file=fn,status='old',access='sequential'
>> $ ,form='formatted')
>> open (unit = 16, file=fn1,status='old',access='sequential'
>> $ ,form='formatted')
>> do kount=1,1000
>> read (15,901,end=999) c,(cvocq(i),i=1,8)
>> c
>> c if (kount .gt. 163 .and. kount .lt. 170) write(16,902) c ...
Show full article (2.77Kb)
no comments
Re: What is wrong with this search for the character PV/PQ         


Author: Michel Olagnon
Date: Jan 18, 2008 06:47

sara_patty wrote:
>
> I tried this simpler search for a variable called CQN with numerical
> values in a file of 500 lines of output, not working so far!
> cat readcvcq.f
>
> program readcvcq
> Implicit integer*2 (I-N)
> character*36 CB,CQN
> character*36 fn,fn1
> character*8 cvocq (10)
> parameter(fn='infile')
> parameter(fn1='dummy')
> open (unit = 15, file=fn,status='old',access='sequential'
> $ ,form='formatted')
> open (unit = 16, file=fn1,status='old',access='sequential'
> $ ,form='formatted')
> do kount=1,1000
> read (15,901,end=999) CB,(cvocq(i),i=1,8)
> c ...
Show full article (0.87Kb)
no comments
Re: What is wrong with this search for the character PV/PQ         


Author: e p chandler
Date: Jan 18, 2008 07:13

On Jan 18, 9:26 am, sara_patty yahoo.com> wrote:
> On Jan 17, 11:38 pm, "Reagan Revision" invalid.net> wrote:
>
>
>
>
>
>> "sara_patty" yahoo.com> wrote in message
>
>>news:f39293e3-7eb0-411f-b9f7-5529055261ff@21g2000hsj.googlegroups.com...
>
>>>         program readcvcq
>>>         Implicit integer*2 (I-N)
>>>        character*8 C,'PV/PQ'
>>>        character*36 fn,fn1
>>>        character*8  cvocq (10)
>>>        parameter(fn='sxsoutfile')
>>>        parameter(fn1='dummy')
>>>        open (unit = 15, file=fn,status='old',access='sequential'
>>>     $ ,form='formatted') ...
Show full article (2.64Kb)
no comments
Re: What is wrong with this search for the character PV/PQ         


Author: sara_patty
Date: Jan 18, 2008 07:19

On Jan 18, 11:13 am, e p chandler juno.com> wrote:
> On Jan 18, 9:26 am, sara_patty yahoo.com> wrote:
>
>
>
>> On Jan 17, 11:38 pm, "Reagan Revision" invalid.net> wrote:
>
>>> "sara_patty" yahoo.com> wrote in message
>
>>>news:f39293e3-7eb0-411f-b9f7-5529055261ff@21g2000hsj.googlegroups.com...
>
>>>> program readcvcq
>>>> Implicit integer*2 (I-N)
>>>> character*8 C,'PV/PQ'
>>>> character*36 fn,fn1
>>>> character*8 cvocq (10)
>>>> parameter(fn='sxsoutfile')
>>>> parameter(fn1='dummy')
>>>> open (unit = 15, file=fn,status='old',access='sequential'
>>>> $ ,form='formatted') ...
Show full article (3.19Kb)
no comments
Re: What is wrong with this search for the character PV/PQ         


Author: e p chandler
Date: Jan 18, 2008 07:38

On Jan 18, 10:19 am, sara_patty yahoo.com> wrote:
> On Jan 18, 11:13 am, e p chandler juno.com> wrote:
>
>
>
>
>
>> On Jan 18, 9:26 am, sara_patty yahoo.com> wrote:
>
>>> On Jan 17, 11:38 pm, "Reagan Revision" invalid.net> wrote:
>
>>>> "sara_patty" yahoo.com> wrote in message
>
>>>>news:f39293e3-7eb0-411f-b9f7-5529055261ff@21g2000hsj.googlegroups.com...
>
>>>>>         program readcvcq
>>>>>         Implicit integer*2 (I-N)
>>>>>        character*8 C,'PV/PQ'
>>>>>        character*36 fn,fn1
>>>>>        character*8  cvocq (10) ...
Show full article (4.40Kb)
no comments
1 2 3