|
板凳
楼主 |
发表于 2015-4-14 14:42:57
|
只看该作者
大概是这样的:
原始的代码的定义数组部分是:
common /ustar/ use(ndn), usc2(ndn,ndl), us2(ndn), tausm(ndn), tause(ndn,ndl), &
us(ndn)
common /rsedi/ dk(ndl),dm(ndn),dm0(ndn),wk(ndl),bar(ndn),p0(ndn,ndl), &
qb(ndn),qbik(ndn,ndl),cijk(ndn,ndj,ndl),qs(ndn), &
qsik(ndn,ndl),qw(ndn),qwik(ndn,ndl),qbsub(ndn,ndl), &
qssub(ndn,ndl),qwsub(ndn,ndl),desik(ndn,ndl), &
dewik(ndn,ndl),chekin(ndn,ndl),pwh(n4)
common /rtrib/ bsub(nhs),sbsub(nhs),snsub(nhs),darmor(nhs),rqb(nhs), &
rqs(nhs),qbsub1(nhs,ndl),qssub1(nhs,ndl), &
qwsub1(nhs,ndl)
common /combsw/ tqb(ndn),tqs(ndn),tqw(ndn), &
tdb(ndn),tds(ndn),tdw(ndn),tqbswall(ndn,ndl), &
tqbsub(nhs),tqssub(nhs),tqwsub(nhs),tqbswsba(nhs,ndl)
common /comtqb/ tqbik(ndn,ndl),tqsik(ndn,ndl),tqwik(ndn,ndl)
common /chkerr/ ndzb
文本格式,文件名是main.com
主程序中调用的时候是include 'main.com'
我给修改成了
[Fortran] 纯文本查看 复制代码 module MAIN1
implicit none
real(kind=8),allocatable::use(:), usc2(:,:), us2(:), tausm(:), &
tause(:,:),us(:)
real(kind=8),allocatable::dk(:),dm(:),dm0(:),wk(:),bar(:), &
p0(:,:),qb(:),qbik(:,:),cijk(:,:,:),qs(:), &
qsik(:,:),qw(:),qwik(:,:),qbsub(:,:), &
qssub(:,:),qwsub(:,:),desik(:,:),dewik(:,:), &
chekin(:,:),pwh(:)
real(kind=8),allocatable::bsub(:),sbsub(:),snsub(:),darmor(:), &
rqb(:),rqs(:),qbsub1(:,:),qssub1(:,:), &
qwsub1(:,:)
real(kind=8),allocatable::tqb(:),tqs(:),tqw(:),tdb(:),tds(:), &
tdw(:),tqbswall(:,:),tqbsub(:),tqssub(:), &
tqwsub(:),tqbswsba(:,:)
real(kind=8),allocatable::tqbik(:,:),tqsik(:,:),tqwik(:,:)
integer::ndzb
end module MAIN1
定义数组的部分用一个子程序:
[Fortran] 纯文本查看 复制代码 subroutine alloca
use para
use MAIN1
implicit none
! ======== MAIN1 ========
allocate( use(ndn), usc2(ndn,ndl), us2(ndn), tausm(ndn), &
tause(ndn,ndl), us(ndn) )
allocate( dk(ndl),dm(ndn),dm0(ndn),wk(ndl),bar(ndn),p0(ndn,ndl), &
qb(ndn),qbik(ndn,ndl),cijk(ndn,ndj,ndl),qs(ndn), &
qsik(ndn,ndl),qw(ndn),qwik(ndn,ndl),qbsub(ndn,ndl), &
qssub(ndn,ndl),qwsub(ndn,ndl),desik(ndn,ndl), &
dewik(ndn,ndl),chekin(ndn,ndl),pwh(n4) )
allocate( bsub(nhs),sbsub(nhs),snsub(nhs),darmor(nhs),rqb(nhs), &
rqs(nhs),qbsub1(nhs,ndl),qssub1(nhs,ndl), &
qwsub1(nhs,ndl) )
allocate( tqb(ndn),tqs(ndn),tqw(ndn), &
tdb(ndn),tds(ndn),tdw(ndn),tqbswall(ndn,ndl), &
tqbsub(nhs),tqssub(nhs),tqwsub(nhs),tqbswsba(nhs,ndl) )
allocate( tqbik(ndn,ndl),tqsik(ndn,ndl),tqwik(ndn,ndl) )
! ======== initial ========
use=0.0; usc2=0.0; us2=0.0; tausm=0.0
tause=0.0;us=0.0
dk=0.0;dm=0.0;dm0=0.0;wk=0.0;bar=0.0;p0=0.0
qb=0.0;qbik=0.0;cijk=0.0;qs=0.0;qsik=0.0
qw=0.0;qwik=0.0;qbsub=0.0;qssub=0.0
qwsub=0.0;desik=0.0;dewik=0.0
chekin=0.0;pwh=0.0
bsub=0.0;sbsub=0.0;snsub=0.0;darmor=0.0;rqb=0.0
rqs=0.0;qbsub1=0.0;qssub1=0.0;qwsub1=0.0
tqb=0.0;tqs=0.0;tqw=0.0;tdb=0.0;tds=0.0;tdw=0.0
tqbswall=0.0;tqbsub=0.0;tqssub=0.0;tqwsub=0.0
tqbswsba=0.0
tqbik=0.0;tqsik=0.0;tqwik=0.0
ndzb=0
end subroutine alloca
主程序中是:
use main1
call alloca
然后其它子程序都是use main1
类似的。
结果是两者的计算大部分吻合,但有偏差。
|
|