I am getting stack overflow when executing the following code in Compac Fortran. Specially for the line:
DIMENSION IZ(NX,NY),VX(NX-1,NY-1),VY(NX-1,NY-1),VZ(NX-1,NY-1)
What I am doing is to read the NX,NY,DX,DY from a parameter file.
Any suggestions?
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
NOTE: Changing from (NGMAX=30000)
to (NGMAX=30)
did not help.
Yes I have changed all the instances of NGMAX to 30.
The new version is listed below.
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)
I am so sorry: I worked on the code all the day and finally its working. Howevere, declaring NX and NY, is what we do not need. I want to to read these parameters from the parameter file. The code is as follows:
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