Can You Loop Numbers and Write an Output File in Fortran?

  • Fortran
  • Thread starter ƒ(x) → ∞
  • Start date
  • Tags
    Fortran
In summary, the conversation discusses the possibility of looping a set of numbers and how to write an output file in Fortran. The suggested solution for looping involves using a do loop and writing the numbers to the screen. For writing to a file, the suggestion is to parse each character in a line and concatenate them into one string before writing to the file.
  • #1
ƒ(x) → ∞
25
0
Is it possible to loop a set of numbers?

For example I wish to run a set of number 1,2,3,4,5...52 but when we get to 52 I wish to go back to 1 and start looping again.

How do write an output file in Fortran?

I have opened a file and moved each character so that each letter has moved for example d to e...x to y... How could I write this new series of characters to a file
 
Technology news on Phys.org
  • #2
Not sure what you mean by "run" a set of numbers. If you just wish to print them, then something easy enough like this should work:
Code:
do i=1,n !-- number of times you wish you loop
 do j=1,52
    write(6,*) j
 end do
end do

As far as the second question, you might be best parsing each character in a line, and then concatenating them all to one text string and writing that entire line to file (rather than character by character).
 

Related to Can You Loop Numbers and Write an Output File in Fortran?

1. What is Fortran and what is it used for?

Fortran is a high-level programming language developed in the 1950s primarily for scientific and engineering applications. It is used for writing efficient and reliable code for numerical calculations.

2. What are the advantages of using Fortran over other programming languages?

Fortran is specifically designed for scientific computing, making it well-suited for complex mathematical operations. It also has a long history and a large community of users, making it a well-supported and stable language.

3. Is Fortran still relevant in modern programming?

Yes, Fortran is still widely used in scientific and engineering fields, especially in fields such as weather forecasting, computational fluid dynamics, and nuclear engineering. It is also continuously updated and improved, with the latest version being released in 2018.

4. What are the main features of Fortran?

Some of the main features of Fortran include its ability to handle complex mathematical operations, its high performance and efficiency, its strong typing system, and its compatibility with other programming languages.

5. Can Fortran be used for non-scientific applications?

While Fortran is primarily used for scientific and engineering applications, it can also be used for other types of programming. However, it may not be the most suitable language for non-scientific applications due to its focus on numerical computations.

Similar threads

  • Programming and Computer Science
Replies
8
Views
2K
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
5
Views
4K
  • Programming and Computer Science
2
Replies
35
Views
2K
  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
Replies
3
Views
2K
  • Programming and Computer Science
Replies
6
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
2K
  • Programming and Computer Science
2
Replies
57
Views
4K
  • Programming and Computer Science
Replies
19
Views
6K
Back
Top