I have a problem in my fortran program. A variable changes after I call a subroutine, but I don't change this variable during the calling of the subroutine. In order to figure out, I put this variable into the subroutine(but it is not changed in the subroutine). I find that this variable is changed in the subroutine. I feel very strange about this. The subroutine is as following:
*******************************************
subroutine collc(nxf,nyf,wrf,nxc,nyc,wrc,funcd1,funcd0,fdd1,te)
implicit none
integer :: ic,jc,k,iff,jf,nxf,nyf,nxc,nyc
real*8, dimension(nxf,nyf,9) :: wrf,funcd1
real*8, dimension(nxc,nyc,9) :: wrc,funcd0,fdd1
real*8, intent(in) :: te
print *, te,11
pause
do k=1,9
do jc=1,nyc
do ic=1,nxc
wrc(ic,jc,k)=0.0
enddo
enddo
enddo
print *, te,22
pause
do k=1,9
do jc=2,nyc-1
do ic=2,nxc-1
iff=ic*2-1
jf=jc*2-1
wrc(ic,jc,k)=wrc(ic,jc,k)+wrf(iff, jf, k)/2.0
wrc(ic,jc,k)=wrc(ic,jc,k)+wrf(iff+1,jf, k)/4.0
wrc(ic,jc,k)=wrc(ic,jc,k)+wrf(iff-1,jf, k)/4.0
wrc(ic,jc,k)=wrc(ic,jc,k)+wrf(iff, jf+1,k)/4.0
wrc(ic,jc,k)=wrc(ic,jc,k)+wrf(iff, jf-1,k)/4.0
wrc(ic,jc,k)=wrc(ic,jc,k)+wrf(iff+1,jf+1,k)/8.0
wrc(ic,jc,k)=wrc(ic,jc,k)+wrf(iff+1,jf-1,k)/8.0
wrc(ic,jc,k)=wrc(ic,jc,k)+wrf(iff-1,jf+1,k)/8.0
wrc(ic,jc,k)=wrc(ic,jc,k)+wrf(iff-1,jf-1,k)/8.0
enddo
enddo
enddo
print *, te,33
pause
do k=1,9
do jc=1,nyc
do ic=1,nxc
funcd0(ic,jc,k)=funcd1(ic*2-1,jc*2-1,k)
fdd1(ic,jc,k)=funcd1(ic*2-1,jc*2-1,k)
enddo
enddo
enddo
print *, te,44
pause
return
end
*******************************************
And the result is as following:
0.000000000000000E+000 11
FORTRAN PAUSE
PAUSE prompt>
0.000000000000000E+000 22
FORTRAN PAUSE
PAUSE prompt>
0.000000000000000E+000 33
FORTRAN PAUSE
PAUSE prompt>
0.108468249176599 44
We can see that te changes from 0.0 (at 33) to 0.108 (at 44) . There is no overflow warning at all. Does anybody have an idea about this?
Thanks!
*******************************************
subroutine collc(nxf,nyf,wrf,nxc,nyc,wrc,funcd1,funcd0,fdd1,te)
implicit none
integer :: ic,jc,k,iff,jf,nxf,nyf,nxc,nyc
real*8, dimension(nxf,nyf,9) :: wrf,funcd1
real*8, dimension(nxc,nyc,9) :: wrc,funcd0,fdd1
real*8, intent(in) :: te
print *, te,11
pause
do k=1,9
do jc=1,nyc
do ic=1,nxc
wrc(ic,jc,k)=0.0
enddo
enddo
enddo
print *, te,22
pause
do k=1,9
do jc=2,nyc-1
do ic=2,nxc-1
iff=ic*2-1
jf=jc*2-1
wrc(ic,jc,k)=wrc(ic,jc,k)+wrf(iff, jf, k)/2.0
wrc(ic,jc,k)=wrc(ic,jc,k)+wrf(iff+1,jf, k)/4.0
wrc(ic,jc,k)=wrc(ic,jc,k)+wrf(iff-1,jf, k)/4.0
wrc(ic,jc,k)=wrc(ic,jc,k)+wrf(iff, jf+1,k)/4.0
wrc(ic,jc,k)=wrc(ic,jc,k)+wrf(iff, jf-1,k)/4.0
wrc(ic,jc,k)=wrc(ic,jc,k)+wrf(iff+1,jf+1,k)/8.0
wrc(ic,jc,k)=wrc(ic,jc,k)+wrf(iff+1,jf-1,k)/8.0
wrc(ic,jc,k)=wrc(ic,jc,k)+wrf(iff-1,jf+1,k)/8.0
wrc(ic,jc,k)=wrc(ic,jc,k)+wrf(iff-1,jf-1,k)/8.0
enddo
enddo
enddo
print *, te,33
pause
do k=1,9
do jc=1,nyc
do ic=1,nxc
funcd0(ic,jc,k)=funcd1(ic*2-1,jc*2-1,k)
fdd1(ic,jc,k)=funcd1(ic*2-1,jc*2-1,k)
enddo
enddo
enddo
print *, te,44
pause
return
end
*******************************************
And the result is as following:
0.000000000000000E+000 11
FORTRAN PAUSE
PAUSE prompt>
0.000000000000000E+000 22
FORTRAN PAUSE
PAUSE prompt>
0.000000000000000E+000 33
FORTRAN PAUSE
PAUSE prompt>
0.108468249176599 44
We can see that te changes from 0.0 (at 33) to 0.108 (at 44) . There is no overflow warning at all. Does anybody have an idea about this?
Thanks!