Fortran Help with formatted output in fortran

Hello,

I am trying to print in formatted output using the format specifiers but I am not able to get the correct output.
I am trying to print an array with 11 reals, followed by one more real number and finally an integer.

When I skip the integer, the format statement works and but when I add the integer I get an error.
Code:
C  Works with array of 11 reals followed by another real
write(9,326,REC=NF),(X(I),I=1,N),F
format((2X,5D15.6),1PD18.10)
Code:
write(9,326,REC=NF),(X(I),I=1,N),F,NF
format((2X,5D15.6),1PD18.10,I6)
I get this error:
Code:
Fortran runtime error: Expected INTEGER for item 8 in formatted transfer, got REAL
((2X,5D15.6),1PD18.10,I6)
Can someone please guide me the correct way to print this output and explain what I am doing wrong in the above format ? Thanks

Nikhil
 

DrClaude

Mentor
6,807
2,923
(2X,5D15.6) is two blank spaces followed by 5 floats, not "2 times 5 floats." The format should be changed to something like
Fortran:
format(2(2X,5D15.6),1PD18.10,I6)
 

Want to reply to this thread?

"Help with formatted output in fortran" You must log in or register to reply here.

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving
Top