Prefijo Sustantivo
Prefijo Sustantivo

Reputation: 525

Fortran format, what does the symbol "1" mean?

Please consider this statement:

           *
format(2i4,1 12(f4.1,1x,a2,1x,a5))

Is my understanding that this line reads : 2 integers of 4 digits and 12 groups of:

- a 4 digits float with one decimal
- one format space
- an alphabetic string of two chars
- one format space
- an alphabetic string of five chars

But I don't understand the one in the middle (marked with a star on top of it), can someone please explain what it means?

The given expression is supposed to parse:

59 229 7.2 Ms HRV   7.3 Mw P&S   7.3 Ms P&S   7.1 Ms ISC   7.2 Ms PAS   7.4 Ms BRK   6.3 mb ISC   6.2 mb NEIS

thanks

Upvotes: 1

Views: 414

Answers (2)

Prefijo Sustantivo
Prefijo Sustantivo

Reputation: 525

found it: the symbol "1", quotes not part of the said symbol, means new line. Its just an odd, and if you ask me, antinatural, way to say \n.

thanks to everybody for helping.

Upvotes: 1

Glenn Randers-Pehrson
Glenn Randers-Pehrson

Reputation: 12465

The compiler recognizes "1 12", which is probably a typo, as "112". The compiler ignores the space and doesn't notice the error because the format statement is syntactically correct.

The sample input that you provided would be parsed correctly with "8" in place of the "1 12". "12" would work as well, and I'm guessing that's what the author intended.

If your corresponding "read" statement is only asking for 26 items, it'll work OK with 112 anyhow because it stops parsing when it has gotten all the items you asked for.

Upvotes: 2

Related Questions