Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Help read the file

Status
Not open for further replies.

ninhchubeach

Marine/Ocean
Aug 6, 2008
5
Dear all
I need to read the data file to the variables: Date, time, Value1,Value2,Value3. The variables are array with dimension n arbitrary. Inside the file likes:
06/05/2008 21:00:10.000 1.0123980E+0001 5.0372083E-0004 2.6052687E+0001
06/05/2008 21:30:10.000 1.0127100E+0001 8.8555174E-0004 2.6146746E+0001
06/05/2008 22:00:10.000 1.0129192E+0001 8.2108111E-0004 2.6269987E+0001
06/05/2008 22:30:10.000 1.0132229E+0001 7.4600358E-0004 2.6247709E+0001
...
...

Thanks alot in advance

ninhchubeach
 
Homework postings are not allowed.

TTFN

FAQ731-376
 
You can read them but how do you want to store them?

Date and time are not standard items in Fortran (and most computing languages). Some places store the date as days since 1st Jan 1970. Some store the time as seconds since midnight. Some store the date and time together, the time being a fraction of a day.
 
Thank you very much, xwb.
I wrote some code to convert the data and time format to the serial number (since 1st Jan. 1900) so the store data and time format is OK.
My problem is I can not read the other values at the next column after time column (value1, value2, value3). I'd like to use those values for my calculation.
Please help me how to read them?
Thank you in advance and sorry for my response to late!:)
 
At a guess, you're reading the date and time in one statement and the 3 values in a subsequent statement. You can't do that if they're all on the same line: Fortran is line based. Try something like
Code:
read (10, 1000) datedd, datemm, dateyyyy, timehh, timemm, timess, value1, value2, value3
1000 format (I2,1X,I2,1X,I4, 1X,I2,1X,I2,1X, F6.3, 3G17.8)
I don't know if I'm counting correctly but the numbers, including spaces are about 17 chars wide to 8 DP.
 
Thank you very much, xwb!
I will try reading that file in you ways!
 
Reading date and time format in Fortran
Dear All,
I have a problem concerning reading date and time from the data file in fortran. The data file have 10 'column field'. I'd like to read the data file to variables: Dateset, Date, Time, realdata(1:7). Because of slash (/) character of Date field, which fortran recognize as: 'go to the next line' so I couldn't read the next data after '/' character. My data file like:
1 16/05/2008 11:11:35 10.385770 106.866953 0.00 29.61 0.02 0.02 70.00 1173.26 0.02
2 16/05/2008 11:11:35 10.389513 106.867763 0.00 29.59 0.02 0.01 70.00 1173.10 0.03
3 16/05/2008 11:11:35 10.389513 106.867763 0.00 29.57 0.02 0.01 70.00 1173.10 0.03
4 16/05/2008 11:11:36 10.389513 106.867763 -0.02 29.58 0.02 0.01 70.00 1173.26 0.03
5 16/05/2008 11:11:36 10.389513 106.867763 0.00 29.58 0.02 0.01 70.00 1173.10 0.04
6 16/05/2008 11:11:36 10.389513 106.867763 -0.01 29.60 0.02 0.01 70.00 1172.95 0.04
...
...

I would be appreciated if someone can help me to find the way to read such data.

Best regards,
Ninhchubeach

 
What does your format statement look like?
 
Dear xwb,
I can store the date and time as the character or whatever. If we can read the data of this file and if data and time are the variables of character(10) and character(8) or the variables of integer, I can convert data and time to Time Series (the number since Jan., 1st 1900).
So my problem is how to read the data inside the file.
Pleas help me to do this
Thank you very much
Regards
Ninhchubeach
 
Is this for school?

TTFN

FAQ731-376
 
Question still stands: what does your format statement look like? I can't see how a / in the input stream causes your program to skip to the next line. It will only cause a skip if it is in the format statement. If you say what your format statement is, we can go forward.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor