Fortran Fortran 95: formatting of output (ints and chars)

  • Thread starter Thread starter hetanquary
  • Start date Start date
  • Tags Tags
    Fortran Output
AI Thread Summary
A physics student new to Fortran 95 is working on a research project that requires formatting output in a specific way. The task involves writing a series of lines to an output file, including date and time, and various values with specific formatting. The student faces challenges with data type combinations and managing line breaks in the output. They reference a helpful website for Fortran I/O issues and eventually find success after extensive trial and error. The discussion highlights the common difficulties encountered when learning a new programming language and the importance of perseverance in problem-solving.
hetanquary
Messages
2
Reaction score
0
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.
 
Technology news on Phys.org
hetanquary said:
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.
 
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. :)
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
What percentage of programmers have learned to touch type? Have you? Do you think it's important, not just for programming, but for more-than-casual computer users generally? ChatGPT didn't have much on it ("Research indicates that less than 20% of people can touch type fluently, with many relying on the hunt-and-peck method for typing ."). 'Hunt-and-peck method' made me smile. It added, "For programmers, touch typing is a valuable skill that can enhance speed, accuracy, and focus. While...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...

Similar threads

Replies
3
Views
3K
Replies
59
Views
11K
Replies
2
Views
1K
Replies
2
Views
2K
Replies
29
Views
5K
Replies
6
Views
2K
Replies
4
Views
2K
Replies
1
Views
2K
Back
Top