Consider the following program
program foo
implicit none
real :: pi
pi = 3.1415923
print*, "The value of pi is", pi
end program foo
This gives the output as
The value of pi is 3.1415923
But I want the variable to be displayed only up to 2 decimal places, so I tried
print'(f4.2)', "The value of pi is", pi
This throws me an error.
Fortran runtime error: Expected REAL for item 1 in formatted transfer, got CHARACTER
(f4.2)
How do I achieve the following output
The value of pi is 3.14