Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

read multiple data

zxu4
Beginner
450 Views
Hi,
I tried to read multiple data from one line in my datafile.

Data format is :

0.3,0.9,1.2,2.3

Comma is used to separate each of them, but I don't know how many in one line. I want to use an array to read all of them, like,

read(10,'(f5.2)')value(1),value(2),...

How to make it happen to my array value?

Thanks!

Roy
0 Kudos
1 Reply
anthonyrichards
New Contributor III
450 Views

Pasted from CVF help found using 'comma' in the 'Index':

Code:

Using Commas to Separate Input Data

You can use a comma to terminate a short data field. 
The comma has no effect on the d part (the number of
characters to the right of the decimal point) of the specification. The comma overrides the w specified for the I, B, O, Z, F, E, D,
EN, ES, G, and L edit descriptors. For example, suppose the
following statements are executed: READ (5,100) I,J,A,B 100 FORMAT (2I6,2F10.2) Suppose a record containing the following values is read: 1, -2, 1.0, 35 The following assignments occur: I = 1 J = -2 A = 1.0 B = 0.35 A comma can only terminate fields less than w characters long.
If a comma follows a field of w or more characters, the comma
is considered part of the next field. A null (zero-length) field is designated by two successive
commas, or by a comma after a field of w characters. Depending
on the field descriptor specified, the resulting value assigned
is 0, 0.0, 0.0D0, 0.0Q0, or .FALSE..



0 Kudos
Reply