PDA

View Full Version : Fortran 95: formatting of output (ints and chars)


hetanquary
Oct13-11, 03:48 PM
Hello. I am a physics student working on research project which involves Fortran 95 code. I am very new to Fortran but I do have an intermediate knowledge of Java. The task I am attempting seems like it should be very simple but there are many subtleties to learning a new language that are making it very time consuming, so after attempting different things all day with no luck I thought I would try here.

Here is what I need to do:
At the top of my pre-existing output file I need to write the following exactly in this format:

text month/day/year hours:minutes:seconds
text B=value1 G B=value1 G
text Te=value1 KeV Te=value1 Kev
text Tau=value3 Tau=value3

where: text is an arbitrary character string (it's just for filler); month, day, year, hours, minutes, and seconds are integers; value1, value2, and value3 are reals; the units and the B=, Te= etc.... are just characters.

I am having many problems with this. Mainly working with trying to format combinations of data types and with how to tell it when to write on a new line and when not to.

swartzism
Oct25-11, 06:08 PM
Hello. I am a physics student working on research project which involves Fortran 95 code. I am very new to Fortran but I do have an intermediate knowledge of Java. The task I am attempting seems like it should be very simple but there are many subtleties to learning a new language that are making it very time consuming, so after attempting different things all day with no luck I thought I would try here.

Here is what I need to do:
At the top of my pre-existing output file I need to write the following exactly in this format:

text month/day/year hours:minutes:seconds
text B=value1 G B=value1 G
text Te=value1 KeV Te=value1 Kev
text Tau=value3 Tau=value3

where: text is an arbitrary character string (it's just for filler); month, day, year, hours, minutes, and seconds are integers; value1, value2, and value3 are reals; the units and the B=, Te= etc.... are just characters.

I am having many problems with this. Mainly working with trying to format combinations of data types and with how to tell it when to write on a new line and when not to.

I always refer to this website http://www.cs.mtu.edu/~shene/COURSES/cs201/NOTES/chap05/format.html (WFS) when I am having issues with FORTRAN I/O. See if it helps.

hetanquary
Oct25-11, 10:00 PM
Thank you, that is actually the site that I found most helpful as well! I ended up figuring out how to do it after lots of time and much trial and error. I guess that's what it takes! Thank you again. :)