I'm trying to create function that takes a number and returns a string representation of that number. This is what I've tried:
program test
print *, num2str(9.0)
end
character(len=128) function num2str(num)
real num
write(num2str,*) num
endfunction
But this returns the error:
num2str.f:1.22:
print *, num2str(9.0)
1
Error: Return type mismatch of function 'num2str' at (1) (INTEGER(4)/CHARACTER(1))
How could I solve this problem?