简体   繁体   English

如何在fortran 90中声明复杂类型数组

[英]How to declare a complex type array in fortran 90

I need some help to initialize a complex type 1-D array in Fortran on linux 我需要一些帮助来在Linux上的Fortran中初始化复杂的1-D数组

complex(kind=dp),dimension(8),public:: zc = (/(0.0_dp,0.0_dp) ,(-3.496991526333D001,0.0_dp) ,
( -3.944481647220D+000 , 0.0_dp ) , (-4.294180799072D+000 , 0.0_dp ) , 
(-4.294180799072D+000, -1.0_dp) , ( -3.944481647220D+000,-1.0_dp ) , 
(-3.496991526333D-           001,-1.0_dp ) , (0.0_dp,-1.0_dp)/) ! z computational 

Above statement works in Fortran Power Station( for Windows ) but not on Linux. 以上声明适用于Fortran Power Station(Windows版),但不适用于Linux。 It gives the following error 它给出了以下错误

Missing ')' in statement at or before (1) 

NOTE : The '1' is the comma b/w 3rd and 4th complex no. 注意: “ 1”是黑白的第3和第4个复数。 The extension of the program is .f90 该程序的扩展名为.f90

You must use the correct way of continuing lines. 您必须使用正确的续行方式。 If you use fixed form (usually .f , .form ) place any character on the sixth column of the new line and then your statement. 如果您使用固定形式(通常是.f.form ),请将任何字符放在新行的第六列,然后是语句。 You probably use this, otherwise -3.496991526333D- 001 coudn't work, because spaces are important in the free form. 您可能会使用它,否则-3.496991526333D- 001无法正常工作,因为空格对于自由格式很重要。 But ! 但是! denotes comments in the free form. 表示自由格式的注释。 If you use the free form, correct the number. 如果您使用自由格式,请更正数字。 Be sure to not go past column 72 in the fixed form. 确保不要以固定格式越过第72栏。

For example: 例如:

      complex(kind=dp),dimension(8),public:: zc = (/(0.0_dp,0.0_dp) ,(-3.496991526333D001,0.0_dp) ,
     *  ( -3.944481647220D+000 , 0.0_dp ) , (-4.294180799072D+000 , 0.0_dp ) , 
     *  (-4.294180799072D+000, -1.0_dp) , ( -3.944481647220D+000,-1.0_dp ) , 
     *  (-3.496991526333D-001,-1.0_dp ) , (0.0_dp,-1.0_dp)/) 
C z computational 

In the free form (usually .f90 ) use & at the of the line to continue on the next one. 以自由格式(通常为.f90&在该行的&处继续下一个。

complex(kind=dp),dimension(8),public:: zc = (/(0.0_dp,0.0_dp) ,(-3.496991526333D001,0.0_dp) , &
( -3.944481647220D+000 , 0.0_dp ) , (-4.294180799072D+000 , 0.0_dp ) , &
(-4.294180799072D+000, -1.0_dp) , ( -3.944481647220D+000,-1.0_dp ) , &
(-3.496991526333D-001,-1.0_dp ) , (0.0_dp,-1.0_dp)/) !z computational

You should read more about the correct soource form in any Fortran tutorial. 您应该在任何Fortran教程中阅读有关正确的来源表格的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM