I tried to make the output format dynamically in the sense that the number of variables to be printed out could be varied dynamically. I had done some experiment with the following two methods (see the context below), but both of them led to a error message like this:
forrtl: error (63): output conversion error, unit 1016, file /panfs/roc/Node_ 16.txt
The first method uses a string to specify the output format, for example,
real a(4) = [1 2 3 4]
int size = 4
write(string,'(a,i3,a)') '(a,',size,'(f9.4))'
write(*, string) a(:)
The second method is what I just learnt from the Internet, which occupies only one line, but it didn't work either:
write(*,'(a,<size>f9.4)') a(:)
Please help me with this format setting. Thanks.
EDIT: I found the culprit of the problem. In my real project, some element of the array "a" is pretty huge such that f9.4 is not suitable to display the full array. To fix the problem, I replace f9.4 with something like e11.3.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…