在 Compac Fortran 中执行以下代码时出现堆栈溢出。专线:
DIMENSION IZ(NX,NY),VX(NX-1,NY-1),VY(NX-1,NY-1),VZ(NX-1,NY-1)
我正在做的是从参数文件中读取 NX、NY、DX、DY。
有什么建议么?
PARAMETER(NGMAX=30000)
INTEGER NX,NY,DX,DY
OPEN(6,FILE='MGSTAOriggroup15.asc',STATUS='old')
OPEN(7,FILE='Gravity.asc',STATUS='old')
OPEN(8,FILE='Gravity200.nor',STATUS='old')
OPEN(9,FILE='linana.para',STATUS='old')
OPEN(10,FILE='MGSTAOriggroup15coord.dat',STATUS='unknown')
OPEN(12,FILE='MGSTAOriggroup15ncoord.dat',STATUS='unknown')
OPEN(11,FILE='linana.fsn',STATUS='unknown')
READ(9,*) NX,NY,DX,DY
CALL ANALYSIS(NX,NY)
Close(6)
Close(7)
Close(8)
Close(9)
Close(10)
Close(11)
Close(12)
C
STOP
END
C
SUBROUTINE ANALYSIS(NX,NY)
INTEGER NX,NY,DX,DY
COMMON/COM1/ DX,DY
PARAMETER(NGMAX=30000)
DIMENSION KO(NGMAX)
DIMENSION XLS(NGMAX,100),XLE(NGMAX,100),
& YLS(NGMAX,100),YLE(NGMAX,100)
DIMENSION IZ(NX,NY),VX(NX-1,NY-1),VY(NX-1,NY-1),VZ(NX-1,NY-1)
""""""""""""""""""""""""""""""""""""""""""""
To the end
注意:从 更改(NGMAX=30000)
为(NGMAX=30)
没有帮助。
是的,我已将 NGMAX 的所有实例更改为 30。
下面列出了新版本。
INTEGER NX,NY,DX,DY
PARAMETER(NGMAX=30)
COMMON /CM1/ FX(NGMAX),FY(NGMAX),FZ(NGMAX),FR(NGMAX),IL(NGMAX)
COMMON /CM2/ JST(NGMAX),KST(NGMAX),JDP(NGMAX),KDP(NGMAX)
COMMON /CM3/ XC(NGMAX),YC(NGMAX),ZC(NGMAX),KTYP(NGMAX)
COMMON /CM4/ A(4,4),B(4),U(4)
COMMON /CM5/ KO(NGMAX)
COMMON /CM6/ XLS(NGMAX,10),XLE(NGMAX,10),
& YLS(NGMAX,10),YLE(NGMAX,10)
OPEN(6,FILE='MGSTAOriggroup15.asc',STATUS='old')
OPEN(7,FILE='Gravity.asc',STATUS='old')
OPEN(8,FILE='Gravity200.nor',STATUS='old')
OPEN(9,FILE='linana.para',STATUS='old')
OPEN(10,FILE='MGSTAOriggroup15coord.dat',STATUS='unknown')
OPEN(12,FILE='MGSTAOriggroup15ncoord.dat',STATUS='unknown')
OPEN(11,FILE='linana.fsn',STATUS='unknown')
READ(9,*) NX,NY,DX,DY
CALL ANALYSIS(NX,NY)
Close(6)
Close(7)
Close(8)
Close(9)
Close(10)
Close(11)
Close(12)
C
STOP
END
C
SUBROUTINE ANALYSIS(NX,NY)
INTEGER NX,NY,DX,DY
COMMON/COM1/ DX,DY
PARAMETER(NGMAX=30)
COMMON /CM1/ FX(NGMAX),FY(NGMAX),FZ(NGMAX),FR(NGMAX),IL(NGMAX)
COMMON /CM2/ JST(NGMAX),KST(NGMAX),JDP(NGMAX),KDP(NGMAX)
COMMON /CM3/ XC(NGMAX),YC(NGMAX),ZC(NGMAX),KTYP(NGMAX)
COMMON /CM4/ A(4,4),B(4),U(4)
COMMON /CM5/ KO(NGMAX)
COMMON /CM6/ XLS(NGMAX,10),XLE(NGMAX,10),
& YLS(NGMAX,10),YLE(NGMAX,10)
DIMENSION IZ(NX,NY),VX(NX-1,NY-1),VY(NX-1,NY-1),VZ(NX-1,NY-1)
我很抱歉:我整天都在编写代码,最后它工作了。但是,我们不需要声明 NX 和 NY。我想从参数文件中读取这些参数。代码如下:
PARAMETER(NX=322,NY=399,NGMAX=30000)
C I need to change NX and NY to read from the parameter file
CHARACTER infile1*80,infile2*80,infile3*80,outfile1*80
&,outfile2*80,outfile3*80
DIMENSION KO(NGMAX)
DIMENSION XLS(NGMAX,100),XLE(NGMAX,100),
& YLS(NGMAX,100),YLE(NGMAX,100)
DIMENSION IZ(NX,NY),VX(NX-1,NY-1),VY(NX-1,NY-1),VZ(NX-1,NY-1)
DIMENSION FX(NGMAX),FY(NGMAX),FZ(NGMAX),FR(NGMAX),IL(NGMAX)
DIMENSION JST(NGMAX),KST(NGMAX),JDP(NGMAX),KDP(NGMAX)
DIMENSION XC(NGMAX),YC(NGMAX),ZC(NGMAX),KTYP(NGMAX)
DIMENSION A(4,4),B(4),U(4)
C
CALL getenv('INFILE1',infile1)
CALL getenv('INFILE2',infile2)
CALL getenv('INFILE3',infile3)
CALL getenv('OUTFILE1',outfile1)
CALL getenv('OUTFILE2',outfile2)
CALL getenv('OUTFILE3',outfile3)
OPEN(1,FILE='Alaa1.para',STATUS='old')
READ(1,*)DX,DY,infile1,infile2,infile3,outfile1,outfile2
&,outfile3
C
OPEN(6,FILE=infile1,STATUS='old')
OPEN(7,FILE=infile2,STATUS='old')
OPEN(8,FILE=infile3,STATUS='old')
OPEN(10,FILE=outfile1,STATUS='unknown')
OPEN(12,FILE=outfile2,STATUS='unknown')
OPEN(11,FILE=outfile3,STATUS='unknown')
TO THE END