-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
  • 597
  • 3
  • 5
  • 13

1 Answers1

1

The direct implementation of Your code would be something like:

program test

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

   score = 100

   write(line, '(a, i3)') "score = ", score

   print '(a)', line

end program test
Libavius
  • 535
  • 5
  • 14