Re: What is wrong with this search for the character PV/PQ
- From: dpb <none@xxxxxxx>
- Date: Fri, 18 Jan 2008 11:53:11 -0600
sara_patty wrote:
....
The following works fine!!!!
Implicit integer*2 (I-N)
As a general practice, I'd suggest getting rid of the implicit statement in favor of "implicit none" and explicit declarations of variables used in order to minimize accidental type errors and aid the compiler in its efforts to help you write correct code
implicit none
integer :: kount
Unless you have some other reason not shown, there's little reason to have asked for a 16-bit integer rather than the default size here.
character CB(80)
This specifies an array of single characters of size 80, not a character string of 80 character length. (I sorta' get the idea you figured that out later on, but it's probably not the easiest way to work for most cases if you have a recent compiler).
....
read (15,901,end=999) CB> if (CB(3) .eq. 'C' .and. cb(4) .eq. 'V') write (16,902)
> (CB(i),i=1,80)
> if (CB(4) .eq. 'C' .and. cb(5) .eq. 'V') write (16,902)
> (CB(i),i=1,80)
This does read the record into the array, but as you show, you then had to deal w/ each character individually. That's inconvenient at best.
You also were having problems with which column the data starts in apparently -- which of the two statements above was actually executed--do you know? It appeared to me from your earlier posting there were two leading spaces in the record but that wasn't possible to be determined conclusively from the formatting of the post...
character(len=80) :: CB
...
read(15,'(A)') CB
' assume the two spaces was correct then you _could_ do
if(CB(4:6) == 'CVB') write(16,*) CB
but to make things a little easier so you wouldn't have to count the spacing you could do
if(index(CB,'CVB') > 0) write(16,*)CB
and let the character-handling intrinsics help you...
hth...
--
.
- Follow-Ups:
- References:
- What is wrong with this search for the character PV/PQ
- From: sara_patty
- Re: What is wrong with this search for the character PV/PQ
- From: Reagan Revision
- Re: What is wrong with this search for the character PV/PQ
- From: sara_patty
- Re: What is wrong with this search for the character PV/PQ
- From: e p chandler
- Re: What is wrong with this search for the character PV/PQ
- From: sara_patty
- Re: What is wrong with this search for the character PV/PQ
- From: e p chandler
- Re: What is wrong with this search for the character PV/PQ
- From: sara_patty
- What is wrong with this search for the character PV/PQ
- Prev by Date: Re: recursion, stack, fortran
- Next by Date: Re: What is wrong with this search for the character PV/PQ
- Previous by thread: Re: What is wrong with this search for the character PV/PQ
- Next by thread: Re: What is wrong with this search for the character PV/PQ
- Index(es):
Relevant Pages
|
|