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

Overiding Slash Editing

cloneboy
Beginner
1,001 Views
I am having a problem reading certain data from a file, and was womdering if someone here had any idea how to solve the problem.
THe data I need is in an external file. I read the line in as a character string, and then read the data from that string. The string looks like:
0 1 CEN/4 -5.000000E-03 -1.407595E+06 -1.407595E+06 -7.747229E+05 -45.0000 -6.328721E+05 -2.182318E+06 1.944713E+06
and the data requred is the second value, and the last value. The problem is the slash in CEN/4, which tells FORTRAN to jump to the next line, and so the second value is not read. I have tried using the T command to move the pointer, to no avail. Is there any way of overriding the slash editing to enable me to read the last value?
Many thanks
David
0 Kudos
4 Replies
TimP
Honored Contributor III
1,001 Views
Surely there's a way. If you're simply trying to skip over it, doesn't a format specifying that field as a character string work?
0 Kudos
Steven_L_Intel1
Employee
1,001 Views
The slash doesn't mean anything in the input, but if you are using list-directed input (* format), then it will consider the slash to be a separator. If you are using an explicit format, then the slash is just another character. If all the fields are in the same columns, you should be able to use T to position within the record. What code are you using to read it?
0 Kudos
greldak
Beginner
1,001 Views
You could always split your string into 2 parts - the bit before and the bit after the slash and then just read from the substring - or even just have the second substring contain everything after the last space in the trimmed string.
0 Kudos
larsm
Beginner
1,001 Views

Just a note to add to Steve's reply about a slash being a separator for list-directed format. It's true, of course, but it also stops the processing that list. This is what the standard states:

Although a slash encountered in an input record is referred to as a separator, it actually causes termination of list-directed and namelist input statements; it does not actually separate two values.

If you have used list-directed input I guess this is the reason why you cannot read the last value, David.

LarsM

0 Kudos
Reply