2014-11-25 82 views
1

使用众所周知的DCMPLX内在函数,gfortran -g -std=f2008 -Wall -Wextra -O2返回Warning: The intrinsic 'dcmplx' at (1) is not included in the selected standard but a GNU Fortran extension and 'dcmplx' will be treated as if declared EXTERNAL. Use an appropriate -std=* option or define -fall-intrinsics to allow this intrinsic。是否有一种操纵双精度复数的现代交叉编译器方式?DCMPLX的现代等价物?

回答

2

您可以使用:

CMPLX(X, Y, kind=REAL64) 

要使用REAL64,你需要导入模块ISO_FORTRAN_ENV

这在Fortran 2008标准(草案)中的13.7.36中定义。

+4

不!请不要使用'kind = 8'!使用'ISO_Fortran_env'和像'REAL64'这样的参数,或者像'selected_real_kind()'这样的参数。否则,你的代码是不可移植的。 – 2014-11-25 15:37:11

+0

@AlexanderVogt感谢提醒我...我的思想是在快速代码模式下。 – Stefan 2014-11-25 18:20:09

5

如果你想转换为双精度种,它具有任何种类数,使用

cmplx(real_part, imaginary_part, kind=kind(1.0d0)) 

通常你应该存储在名为不变样数量。如果实际上不需要双精度,而是固定存储大小,请使用模块iso_fortran_env中的命名常量,或使用指定精度的旧方法selected_real_kind()