Two Questions About Fortran:

  • #1

Main Question or Discussion Point

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
 

Answers and Replies

  • #2
minger
Science Advisor
1,495
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 Threads on Two Questions About Fortran:

  • Last Post
Replies
4
Views
2K
Replies
1
Views
2K
Replies
1
Views
2K
Replies
5
Views
3K
Replies
12
Views
952
Replies
1
Views
3K
Replies
1
Views
16K
  • Last Post
Replies
16
Views
3K
  • Last Post
Replies
6
Views
2K
  • Last Post
Replies
2
Views
2K
Top