Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这工作得很好:
program main integer,parameter,dimension(3) :: x = [1,2,3] print*,x end program main
就像这样:
program main integer,parameter,dimension(3) :: x = (/1,2,3/) print*,x end program main
是否有理由认为一种形式应该优于另一种形式(例如向后兼容性)?
方括号形式已添加到 Fortran 2003 中的语言中。如果您正在写入 Fortran 90(根据问题上的标签),那么方括号形式是语法错误(方括号不在 Fortran 90 字符集中) .
除了语言标准,这是个人喜好和风格的问题。