Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with the output file

Status
Not open for further replies.

john02

Technical User
Mar 12, 2012
4
GR
Hi,
I have made the attached program in Fortran 90....
I have already created a listfile which is named LISTFILES in which contains the input files MM5F10030406_18u10 and MM5F10030406_18v10. The results should be written in output files OUT_1, 2 and 3 respectively. The programm seems to run, but the outputs are wrote in twice.
e.g.
54 38 37.76573 20.87003 16.000 -0.001 9.665 2.483
54 39 37.75933 20.94826 16.000 -0.001 10.643 2.692
54 40 37.75284 21.02647 16.000 -0.001 11.157 2.760
... ... ....... ........ ...... ...... ...... .....
54 38 37.76573 20.87003 16.000 -0.001 9.665 2.483
54 39 37.75933 20.94826 16.000 -0.001 10.643 2.692
54 40 37.75284 21.02647 16.000 -0.001 11.157 2.760

I cannot understand what is going wrong!!!

May I have your help, please???

Any help could be appreciated

Thank in advance

 
What happens if you run the program again? Do you get a third copy? If so, you have opened the file for appending.
 
Dear sir/madam,

when I run the program, a warning message is appeared which says:
"PGFIO-F-208/OPEN/unit=66/'NEW' specified for file which already exists. File name= OUT_1"

so it seems that it is not an "appending" problem.....

Any other idea?????

Thanks in advance
 
john,

if you just copy your code to your post and include it in 'code and '/code' tags, both enclosed in [] instead of '', then it would be much easier to handle.

To your problem:

For each execution of your loop

do kk = 1, 5000000

your writing loops essentially write the same data to their files, the only variation being the varu and varv arrays. Are you sure that there is no doubling of data in there ? This could happen if the names in LISTFILE are listed more than once or the varu / varv arrays are the same in the files read in.

To debug I would strip down to say 10 inputfiles, where you can compare the data printed to the data read.

Norbert


The optimist believes we live in the best of all possible worlds - the pessimist fears this might be true.
 
This errormessage is created as you open your file as 'NEW'. So if you have a file named OUT_1 existing on your disc - as you may have from a prior testrun - this is considered an error. Just skip the status = 'new' clause for your output files and the files will be superceded any time your program runs.

Norbert


The optimist believes we live in the best of all possible worlds - the pessimist fears this might be true.
 
Dear Nobert,

thanks for your advices...

But the problem has not been solved yet....
The only exception is the status 'new', which I changed it....

I tried to run the program creating two LISTFILES....
LISTFILE_U.....where the MM5F10030406_18u10 is included and the
LISTFILE_V.....where th MM5F10030406_18v10 is included.

Changing the reading, I added one more open and read and the program is modified as:

open(15,file='LISTFILE_U',form='formatted')
open(16,file='LISTFILE_V',form='formatted')

do kk=1,500000
read(15,1555,end=2) dum1,iy,......

read(16,1555,end=2) dum1,iy,.......

in same do loop and the program run successfully....

However, I would like to merge input files in one LISTFILE list......

 
... so you should compare what is in LISTFILE_U, LISTFILE_V to what is in LISTFILE. Could it be that you have

LISTFILE_U:
name1_u
name2_u
.
.

LISTFILE_V
name1_v
name2_v
.
.

LISTFILE
name1_v
name1_u
name2_v
name2_u
.
.

At least, this situation would explain the different results you encountered by just redoing the read statement.

Norbert

The optimist believes we live in the best of all possible worlds - the pessimist fears this might be true.
 
Dear Nobert,

despite the fact that I examined carefully your advice, the problem has not been solved....

Anyway, I would like to thank you for your time and your patience...

If you will have any other idea, please let me know...

Thanks again....
 
How can you append to a new file? (Maybe if you rewind it, don't know). Anyway...

Change:
Code:
       open(66,file='OUT_1',form='formatted',status='NEW',
     &position='append')
to
Code:
       open(66,file='OUT_1',form='formatted',status='REPLACE')

That will do I guess
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top