大佬教程收集整理的这篇文章主要介绍了linux – Gfortran警告抱怨“Wmaybe -ininitialized”,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
在main.f90中
program main use modTest implicit none real(kind = 8),dimension(:,:),allocatable :: output real(kind = 8),:,allocatable :: input allocate(input(22,33,20),output(22,33)) input = 2.0 call test(input,output) end program main
在test.f90中
@H_21_23@module modTest contains subroutIne test(inputValue,outvalue) use modGlobal implicit none real(kind = 8),intent(in) :: inputValue real(kind = 8),intent(out) :: outValue Integer :: nR,nX,nM,iM,ALLOCATESTATUS real,allocatable :: cosMPhi nR = size(inputValue,1) nX = size(inputValue,2) nM = size(inputValue,3) - 1 allocate(cosMPhi(nR,0:nM),stat=ALLOCATESTATUS) call checkStatus(ALLOCATESTATUS) do iM = 0,nM cosMPhi(:,iM) = cos(iM * 1.0) end do outValue = sum(inputValue * cosMPhi,3) end subroutIne end module
在global.f90中
@H_21_23@module modGlobal contains subroutIne checkStatus(stat) implicit none Integer,intent(in) :: stat if(stat /= 0) then print *,"alLOCATIOn Failed" stop end if end subroutIne end module
使用gfortran -O2 -Wall test.f90 main.f90 -o run编译时,会出现以下警告:
test.f90: In function 'test': test.f90:9:0: warning: 'cosmphi.dim[2].Stride' may be used uninitialized in this function [-Wmaybe-uninitialized] real,allocatable :: cosMPhi ^ test.f90:9:0: warning: 'cosmphi.dim[1].ubound' may be used uninitialized in this function [-Wmaybe-uninitialized] test.f90:9:0: warning: 'cosmphi.dim[1].Stride' may be used uninitialized in this function [-Wmaybe-uninitialized] test.f90:9:0: warning: 'cosmphi.dim[0].ubound' may be used uninitialized in this function [-Wmaybe-uninitialized] test.f90:9:0: warning: 'cosmphi.offset' may be used uninitialized in this function [-Wmaybe-uninitialized]
虽然我试图谷歌这个问题一段时间,但我仍然没有找到一个好的答案.一些相关网站是:
(1)https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58410
(2)https://groups.google.com/forum/m/#!topic/comp.lang.fortran/RRYoulcSR1k
(3)GCC -Wuninitialized / -Wmaybe-uninitialized issues
我使用gfortran 4.8.5测试了示例代码,警告仍然存在.@R_801_10950@在代码中做错了吗?任何帮助将不胜感激.提前致谢!
以上是大佬教程为你收集整理的linux – Gfortran警告抱怨“Wmaybe -ininitialized”全部内容,希望文章能够帮你解决linux – Gfortran警告抱怨“Wmaybe -ininitialized”所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。