我有一个fortan函数,它在复数的虚部上执行模运算。在这里它将虚部减少到-.5
complex(KIND=dpc) function mod_2pi(z) result(mod_z)
complex(KIND=dpc), INTENT(IN) :: z
mod_z = z-iunit*nint(aimag(z))
end function mod_2pi
然而,当我通过gfortran编译器运行时,我收到以下警告
warning: ‘IMAGPART_EXPR <psi>’ may be used uninitialized in this function [-Wmaybe-uninitialized]
mod_z = z-iunit*nint(aimag(z))
^
warning: ‘REALPART_EXPR <psi>’ may be used uninitialized in this function [-Wmaybe-uninitialized]
mod_z = z-iunit*nint(aimag(z))
^
出了什么问题?到目前为止,我可以看到实部和虚部都将被初始化?是否有解决方法围绕此标志而不禁用它?