reading two separate files
  Home FAQ Contact Sign in
comp.lang.fortran only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.fortran Profile…
 Up
reading two separate files         


Author: kipps
Date: Nov 5, 2007 07:39

May be a silly question! How do I read a second file based on the info
in the first file? rewinf unit5 or do i need a script file to bring in
both files first?
44 Comments
Re: reading two separate files         


Author: dpb
Date: Nov 5, 2007 07:44

kipps wrote:
> May be a silly question! How do I read a second file based on the info
> in the first file? rewinf unit5 or do i need a script file to bring in
> both files first?

If you're through with the first file, you could simply close it and
reuse the file number to open the second. If not, open the second file
with an unused file number and proceed.

--
no comments
Re: reading two separate files         


Author: kipps
Date: Nov 5, 2007 08:18

On Nov 5, 10:44 am, dpb non.net> wrote:
> kipps wrote:
>> May be a silly question! How do I read a second file based on the info
>> in the first file? rewinf unit5 or do i need a script file to bring in
>> both files first?
>
> If you're through with the first file, you could simply close it and
> reuse the file number to open the second. If not, open the second file
> with an unused file number and proceed.
>
> --
I did the following, after reading the first file [from default unit
5, I rewound and closed the unit and tried opening the same unit to
read the second file and got this compiler error!
rewind 5
CLOSE (UNIT = 05, ERR = 9904)

open (unit=5,filename=fn2)

Error on line 5139 of main.f: unknown iocontrol filename
Error on line 5139 of main.f: syntax error
1 Comment
Re: reading two separate files         


Author: deltaseq0
Date: Nov 5, 2007 08:26

"kipps" yahoo.com> wrote in message
news:1194279491.770194.46640@y42g2000hsy.googlegroups.com...
> On Nov 5, 10:44 am, dpb non.net> wrote:
>> kipps wrote:
>>> May be a silly question! How do I read a second file based on the info
>>> in the first file? rewinf unit5 or do i need a script file to bring in
>>> both files first?
>>
>> If you're through with the first file, you could simply close it and
>> reuse the file number to open the second. If not, open the second file
>> with an unused file number and proceed.
>>
>> --
> I did the following, after reading the first file [from default unit
> 5, I rewound and closed the unit and tried opening the same unit to
> read the second file and got this compiler error!
> rewind 5
> CLOSE (UNIT = 05, ERR = 9904)
>
> open (unit=5,filename=fn2) ...
Show full article (0.98Kb)
no comments
Re: reading two separate files         


Author: nospam
Date: Nov 5, 2007 07:54

deltaseq0 nospam.net> wrote:
> "kipps" yahoo.com> wrote in message
>> I did the following, after reading the first file [from default unit
>> 5, I rewound and closed the unit and tried opening the same unit to
>> read the second file and got this compiler error!
>> rewind 5
>> CLOSE (UNIT = 05, ERR = 9904)
>>
>> open (unit=5,filename=fn2)
>>
>> Error on line 5139 of main.f: unknown iocontrol filename
>> Error on line 5139 of main.f: syntax error
> Perhaps try file=fn2?
Show full article (1.36Kb)
no comments
Re: reading two separate files         


Date: Nov 5, 2007 09:06

On Nov 5, 10:18 am, kipps yahoo.com> wrote:
> On Nov 5, 10:44 am, dpb non.net> wrote:> kipps wrote:
>>> May be a silly question! How do I read a second file based on the info
>>> in the first file? rewinf unit5 or do i need a script file to bring in
>>> both files first?
>
>> If you're through with the first file, you could simply close it and
>> reuse the file number to open the second. If not, open the second file
>> with an unused file number and proceed.
>
>> --
>
> I did the following, after reading the first file [from default unit
> 5, I rewound and closed the unit and tried opening the same unit to
> read the second file and got this compiler error!
> rewind 5
> CLOSE (UNIT = 05, ERR = 9904)
>
> open (unit=5,filename=fn2)
> ...
Show full article (0.98Kb)
no comments
Re: reading two separate files         


Author: kipps
Date: Nov 5, 2007 10:56

On Nov 5, 12:06 pm, jomarbue...@hotmail.com wrote:
> On Nov 5, 10:18 am, kipps yahoo.com> wrote:
>
>
>
>> On Nov 5, 10:44 am, dpb non.net> wrote:> kipps wrote:
>>>> May be a silly question! How do I read a second file based on the info
>>>> in the first file? rewinf unit5 or do i need a script file to bring in
>>>> both files first?
>
>>> If you're through with the first file, you could simply close it and
>>> reuse the file number to open the second. If not, open the second file
>>> with an unused file number and proceed.
>
>>> --
>
>> I did the following, after reading the first file [from default unit
>> 5, I rewound and closed the unit and tried opening the same unit to
>> read the second file and got this compiler error!
>> rewind 5 ...
Show full article (1.22Kb)
no comments
Re: reading two separate files         


Author: dpb
Date: Nov 5, 2007 11:25

kipps wrote:
...
> It likes open (unit =5, file ='ftn2')
> At least no compiler errors, but it still cannot read the data in
> fn2!!

Whether it appears to "like" it or not, _strongly_ suggest following
Richard M's suggestion to change to something greater than 10.

There quite easily could be a problem here that is being masked by the
use of the preconnected unit and until eliminate that possible problem
speculating on others seems futile.

If fixing that doesn't resolve the issue, you'll need to post a more
complete description of the problems including any errors, the OPEN and
READ statements and the definitions/declarations of all pertinent
variables, at a minimum...

--
no comments
Re: reading two separate files         


Author: dpb
Date: Nov 5, 2007 11:40

dpb wrote:
> kipps wrote:
> ...
>> It likes open (unit =5, file ='ftn2')
>> At least no compiler errors, but it still cannot read the data in
>> fn2!!
>
> Whether it appears to "like" it or not, _strongly_ suggest following
> Richard M's suggestion to change to something greater than 10.
...

Oh, and do it for and and all files not expecting to read/write to a
preconnected unit, not just one instance...

--
no comments
Re: reading two separate files         


Author: Paul van Delst
Date: Nov 5, 2007 12:13

dpb wrote:
> dpb wrote:
>> kipps wrote:
>> ...
>>> It likes open (unit =5, file ='ftn2')
>>> At least no compiler errors, but it still cannot read the data in
>>> fn2!!
>>
>> Whether it appears to "like" it or not, _strongly_ suggest following
>> Richard M's suggestion to change to something greater than 10.
> ...
>
> Oh, and do it for and and all files not expecting to read/write to a
> preconnected unit, not just one instance...

To the OP,

FWIW, I use the f95 code below to grab a lun for file I/O. I've used it for years with no
problems but I haven't tested it too hard (e.g. no opening lots and lots and lots of files
to see where (if?) I get a -1 return value). Note that I start my search at lun=10 (nice
round numbah.)
Show full article (2.33Kb)
no comments
1 2 3 4 5