Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving to file

Status
Not open for further replies.

DaPhil

Technical User
Jun 24, 2011
6
DE
Hello,
I have the following problem. I want to save my data to a file. When I do it like that

do l = 1, nt
write(100, *) t(l), real(E(l)), abs(Pt(l)), abs(Pe(l))
end do

I get a problem: fortran seems not to be able to write more than 3 coloumns in a file. That results in wrong format of my file where the 4th value is written in a new line! I tried it with a formatter like

100 format(e15.8, 3x, e15.8, 3x, e15.8, 3x, e15.8)

but in the file values with an exponent with 4 digits (like E+192) is converted to +192, e.g. the E is missing! That is why I used the way above to write the file, no such a bug there.

Can someone tell me how I can write more than 3 coloumns with the right format into a file?

Thanks
Phil
 
Try something like

100 format(100(e15.8e3,3x))

Such format writes up to 100 columns but may be used with less than 100 too. Notice the addition of "e3" pointing out that exponents have 3 digits.



François Jacq
 
Hi DaPhil

Note that in your write statement 100 is the unit number and you write in free format (with *).
Maybe it should rather look like this:
write(1,100) t(l), real(E(l)), abs(Pt(l)), abs(Pe(l))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top