|
|
★ ★ ★ ★ 小木虫(金币+0.5):给个红包,谢谢回帖交流 jjdg(金币+1):辛苦了 2010-04-03 21:09 nono2009(金币+2, 程序强帖+1):鼓励应助! 2010-04-04 08:25
implicit real + common...这样下去迟早把beginner们都吓跑了...
全局变量可以用module来实现啊
module global_mod
implicit none
public
integer :: i_global
endmodule global_mod
subroutine main(a,b,c,d,e,f,g)
use global_mod
implicit none
...
do i_global=1,num
call sub_a(x,y)
enddo
endsubroutine
subroutine sub_a(xi,yi)
use global_mod
implicit none
....
if(i_global == 100) then
....
endif
endsubroutine
一般都是把全局变量放一个public 的module里写入一个单独的f90文件中
把功能相近的程序封到别的module中在放入单独的f90文件里,需要哪个module
就调哪个(use), 每个module都用implicit none确保变量有显性数值类型,能不用common就不用common,一定不用equivalence.
唉..中文的fortran教材都太烂,除了那本台湾教授的fortran95程序设计。
英文的fortran书,我强烈推荐Fortran 90 Programming, by T.M.R. Ellis, et. al, 不过似乎没有e版,我也花了N元买的纸版。
[ Last edited by figgers on 2010-4-3 at 15:51 ] |
|