Search the web
Sign In
New User? Sign Up
Fortran · Fortran Q/A's, info, lib and fans
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want your group to be featured on the Yahoo! Groups website? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Help needed in solving an error in 'write' statement.   Message List  
Reply | Forward Message #469 of 516 |
Hello,

I;m a new user of Fortran 77 and I'm trying to write a subroutine
where i have to read a bunch of data from an input database file. I
have written code, but when i try to write those values in a file as
a check i get the error saying that the Output file Unit already
exists. i have double checked everything, but still keep getting the
same error. Please help where i'm going wrong. I have pasted my code
and a sample of the input file.
--------------------------------------------------------------
c
c
c

PROGRAM WIMTRUCK
c
Real s(12),w(13)
CHARACTER*46 dfirst
Character Input*80
Character InputV*30,TestoutputV*30
Integer LengthLine

c
c
c PROMPT USER FOR INPUT FILE NAME
c
Write(*,10)
10 FORMAT (1X, 'Enter input file name:'
+ /'(Liger_xxx_xxx.txt file)- must be at least 6 char.')
READ (*,'(A)') Input
Print*,
CC
CC
CC BASED ON INPUT VALUE, OUTPUT FILE WILL BE AUTOMATICALLY NAMED
C
LengthLine=Len(Input)
InputV = Input(6:LengthLine)
TestoutputV= 'Testoutput'//InputV


c OPEN INPUT FILE(Liger_xxx_yyy.txt)

OPEN (UNIT=9,FILE=Input,status='old')


c OPEN OUTPUT FILE (Testoutput_xxx_yyy.txt)

OPEN (UNIT=17,FILE=TestoutputV,status='new')

DO 115 i=0,300000

READ(9,2200,end=900) dfirst,ispeed,dgvw,dlength,ilngth,inaxle,
+ w(1),w(2),w(3),w(4),w(5),w(6),w(7),w(8),w(9),w(10),w(11),
+ w(12),w(13),
+ s(1),s(2),s(3),s(4),s(5),s(6),s(7),s(8),s(9),s(10),s(11),
+ s(12), iTruckN

2200 FORMAT(A45,I2,2X,F5.1,2X,F5.1,6X,I3,3X,I2,11X,13(1X,F4.1),122X,
+ F4.1),2X,I6)

c
WRITE (17,221) dfirst,ispeed,dgvw,dlength,ilngth,inaxle,w(1),
+ w(2),w(3),w(4),w(5),w(6),w(7),w(8),w(9),w(10),w(11),
+ w(12),w(13),
+ s(1),s(2),s(3),s(4),s(5),s(6),s(7),s(8),s(9),s(10),s(11),
+ s(12),iTruckN

221 Format(A45,I2,2X,F5.1,2X,F5.1,6X,I3,3X,I2,11X,13(1X,F4.1),
+ 12(2X,F4.1),2X,I6)
c
115 Continue

900 Continue
STOP
END

-------------------------------------------------------------------
Input file name is Liger_WBNB_July05.txt


Input headers:

DATE TIME YEAR TYPELANE SPEED GVW SumLen
LENGTH NO. ESAL AXL1 AXL2 AXL3 AXL4 AXL5 AXL6
AXL7 AXL8 AXL9 AX10 AX11 AX12 AX13 SPC1 SPC2
SPC3 SPC4 SPC5 SPC6 SPC7 SPC8 SPC9 SP10 SP11
SP12 Truck #


respective values:( 3 input lines in a .txt file)

Fri Jul 01 00:01:01.20 2005 11 1 60 73.8
59.9 69 5 2.923 11.2 15.7 15.4 15.5 16.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 20.2
4.3 31.2 4.2 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 1


Fri Jul 01 00:01:26.34 2005 11 1 60 80.1 59.5
68 5 3.984 12.5 16.3 16.1 17.1 18.1 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 18.3 4.4 32.6 4.2 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 2



Fri Jul 01 00:02:06.02 2005 11 1 59 53.3 68.0
75 5 0.928 12.1 12.4 12.4 7.7 8.7 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 24.0 4.4 35.6 4.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 3




and this is the error i keep getting:


? Fortran Runtime Errors
? Status 'New" specified for an existing file
? Open <Unit=17.....

no matter what unit number i specify, i keep getting the same error.
I know this is really confusing. but if someone can please look at
the code and let me know where i'm going wrong, i would really
appreciate it. This is for my thesis defense which is next month and
I'm running out of time. I just want to make sure that the Read
statement is reading the input file in the format specified.


Thanks a lot
-Aruna




Sat May 24, 2008 1:14 am

saruna26
Offline Offline
Send Email Send Email

Forward
Message #469 of 516 |
Expand Messages Author Sort by Date

Hello, I;m a new user of Fortran 77 and I'm trying to write a subroutine where i have to read a bunch of data from an input database file. I have written code,...
saruna26
Offline Send Email
May 28, 2008
8:35 pm

hi, The open statement for output file you have entered is as follows, OPEN (UNIT=17,FILE=TestoutputV,status='new') In this statement is says that the status...
Sunil Gurrapu
sunil_gurappu
Offline Send Email
May 29, 2008
4:58 pm

hi, i am also a learner.. i hav some doubts in your code.. 1st one is there is no close -statement for both the files. 2nd one is y u are giving continue in...
Ramachandran murugan
pecram_24
Offline Send Email
May 30, 2008
4:41 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help