Calling a subroutine in Fortran (Segmentation fault)

故事扮演 提交于 2019-12-02 01:24:14

When you call a subroutine which has assumed shape dummy arguments (as is the case in this program), an explicit interface is required. The easiest way to achieve this, is to put the subroutine in a module, and use the module in the main program.

It might be helpful to use standard Fortran 90 syntax, specifically in how you declare and initialize arrays.

 program main 
 implicit none 
 integer, dimension(3):: a, b ,c
 a=(/3, 4, 5/)
 b=(/1, 2, 3 /)
 call sub(a,b,c)
 write(*,*)'a+b = ',c 
 end program main
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!