Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Help read the file

Help read the file

Help read the file

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


RE: Help read the file

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.

RE: Help read the file

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!smile

RE: Help read the file

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


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.

RE: Help read the file

Thank you very much, xwb!
I will try reading that file in you ways!

RE: Help read the file

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,


RE: Help read the file

What does  your format statement look like?

RE: Help read the file

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

RE: Help read the file

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close