-1

I want to assign a formatted string to a variable. For example, I would write the following in Python:

my_score = 100
line = "score = %d" % my_score 
print(line)

This will print the following:

score = 100 

How to write the same in Fortran?

Wei Li
  • 485
  • 1
  • 5
  • 12

1 Answers1

1

The direct implementation of Your code would be something like:

program test
implicit none

integer :: score
character(len=30) :: line

score = 100

write(line, '(A,I3)') "score = ", score

write(*,'(A)') line

end program test
Libavius
  • 474
  • 4
  • 11