fortran - 在fortran中使用dreal函数
问题描述
我在 Fortran 中有一个 complex(8) 矩阵 A(-n:n,-m:m),它的许多元素实际上为零,例如 10e-8 等。我想让这些小值等于零。我输入:
do i=-n,n
do j=-m,m
if (dreal(A(i,j))<=cutoff) dreal(A(i,j))=0.0d0
if (dimag(A(i,j))<=cutoff) dimag(A(i,j))=0.0d0
end do
end do
其中 cutoff 已被声明为值为 0.00000010d0 的 real(8) 类型,但出现错误:
error #6512: A scalar-valued expression is required in this context.
error #6408: This name has already been used as an intrinsic function name. [DREAL]
error #6515: This function, which is specified as the left side of an assignment statement, is invalid. [DREAL]
任何想法如何解决这一问题?
更新:@francescalus 注意到这个问题之前已经被问过。根据答案,我将代码更改为:
do i=-n,n
do j=-m,m
ar= A(i,j)%re; ai=A(i,j)%im;
if (ar <cutoff) A(i,j)%re=0.0d0
if (ai<cutoff) A(i,j)%im=0.0d0
end do
end do
但我仍然收到第一个错误:
error #6512: A scalar-valued expression is required in this context.
解决方案
推荐阅读
- node.js - WebStorm 找不到节点解释器
- spring-boot - Spring Boot with H2 每次 web 应用启动时都会运行 data.sql,这正常吗?
- parsing - LR 解析表中有哪些列?
- asp.net-core - Blazor/API 路由问题 - 入门
- xcode - 如何在此类中使用可观察对象?
- javascript - 我不知道为什么我的函数无法读取引号数据
- python - 如何将最后六张最新图像制作成 GIF 动画?
- python-3.x - 如何在不同的应用程序更新数据库后刷新表单字段和视图?姜戈,蟒蛇
- git - Github 操作:Git diff master...HEAD 致命:没有合并基础
- javascript - 在渲染时将默认道具绑定到组件