Fortran How to use a variable in format statement in Fortran?

  • Thread starter Thread starter manugv
  • Start date Start date
  • Tags Tags
    Fortran Program
AI Thread Summary
The discussion centers on a programming challenge in Fortran, specifically regarding the use of a variable in a format statement for output. The user is attempting to print a greeting that increases in length with each iteration of a loop, but encounters difficulties when trying to incorporate the loop variable 'I' into the format statement. It is noted that variable format specifiers are not supported by the GCC Fortran compiler, as indicated by the linked documentation. The output generated by the user's code shows a progressive display of the greeting, but without the desired formatting flexibility.
manugv
Messages
2
Reaction score
0
hello everyone!
I was do programming in fortran and i wanted to print my answer in the format below. I was not able to do it. I have written a part of my program also.
i.e,
#####
greeting = 'Good Morning!'
do 110 I = 1, 12
write (*,115) (greeting)
115 format (A<I>)
110 continue
end
#####
here i want to use a variable 'I' in the format statement i tried it doing but i failed. so please if anyone knows to use a variable in format statement tell me.
I use gcc-3.4.6 compiler.

output of the program
G
Go
Goo
Good
Good
Good M
Good Mo
Good Mor
Good Morn
Good Morni
Good Mornin
Good Morning
 
Last edited by a moderator:
Technology news on Phys.org
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...
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
25
Views
3K
Replies
4
Views
2K
Replies
2
Views
2K
Replies
59
Views
11K
Replies
6
Views
3K
Replies
5
Views
2K
Replies
2
Views
3K
Replies
6
Views
2K
Replies
16
Views
2K
Back
Top