第1个回答 2009-12-08
如果你使用 Visual Fortran 的 Windows 版本,你可以这样:
write(* , '(<n>f10.4)') rArray(1:N)
尖括号不是 Fortran 的标准语法,但 Visual Fortran 支持它。
另外一个办法就是用动态格式。
program Index_Test
implicit none
integer n
real :: rArray(20) = 3.0
character(Len=9) :: cFmt = "(??f10.4)"
n=20
write( cFmt(2:3) , '(i2)' ) n
write( * , cFmt ) rArray(1:N)
end program Index_Test