Fortran Error: Unexpected STATEMENT FUNCTION statement at (1) - fortran

I'm doing a fortran code to find the radial distribution function (RDF) with hard spheres in a cell model.
It's not finished yet, and now I have an error. I'm implementing the histogram. This is my code.
implicit double precision (a-h,o-z)
parameter(npart=3000)
dimension x(0:npart),y(0:npart),z(0:npart)
c n=Number of particules
c rcel=Radius of the cell
c rpart=Radius of the particules
pi=3.1415927
write(*,*)'n,rcel,rpart,dr?'
read(*,*)n,rcel,rpart,dr
write(*,*)'nstep,dp'
read(*,*)nstep,dp
rpart2=(2*rpart)
nfatmax=rcel/dr ! Number of bins
vtotal=(4/3)*pi*rcel*rcel*rcel
dentotal=n/vtotal
write(*,*)'Density of particles, volume and bins = '
write(*,*)dentotal,vtotal,nfatmax
x(0)=0
y(0)=0
z(0)=0
write(*,'(a,/)')'Generating start configurations'
counter1=0
counter2=0
counter3=0
k=0
do i=1,n
21 xx=rcel*(ran()-0.5)*2
yy=rcel*(ran()-0.5)*2
zz=rcel*(ran()-0.5)*2
rr=xx**2+yy**2+zz**2
dist=sqrt(rr)
if(dist.gt.(rcel-rpart2))then !Avoid particles outside the cell
counter1=counter1+1
go to 21
end if
if(dist.lt.rpart2)then ! Avoid overlap with central particle
counter2=counter2+1
go to 21
end if
if(i.ge.1)then
do j=1,i-1,1
sep2=(x(i)-x(j))**2+(y(i)-y(j))**2+(z(i)-z(j))**2
sep=sqrt(sep2)
if(sep.lt.rpart2)then
counter3=counter3+1
go to 21
end if
end do
end if
k=k+1
x(k)=xx
y(k)=yy
z(k)=zz
end do
write(*,*)'Starting config'
write(*,'(3f8.3)')(x(i),y(i),z(i),i=1,n)
counterA=counter1+counter2+counter3
write(*,*)'Rejection = '
write(*,*)counterA
c Monte Carlo loop
counter4=0
counter5=0
counter6=0
do i = 1,nfatmax
h(i) = 0 !!!! Error here!!!!!!
end do
nobs = 0
naccept = 0
do i=1,nstep
do j=1,n
nobs = nobs + 1
xil=x(j)+dp*(ran()-0.5)
yil=y(j)+dp*(ran()-0.5)
zil=z(j)+dp*(ran()-0.5)
r2=(xil**2)+(yil**2)+(zil**2)
r=sqrt(r2)
if(r.gt.(rcel-rpart2))then
counter4=counter4+1
go to 444 ! Avoid particles outside the cell
end if
if(r.lt.rpart2)then
counter5=counter5+1
go to 444 ! Avoid overlap with central particle
end if
do ii=1,j-1
dist2=(x(ii)-xil)**2+(y(ii)-yil)**2+(z(ii)-zil)**2
dist=sqrt(dist2)
if(dist.lt.rpart2)then
counter6=counter6+1
go to 444 ! Avoid overlap wit particles
end if
end do
c Accepted configuration
x(j)=xil
y(j)=yil
z(j)=zil
naccept = naccept + 1
c Rejected configuration
444 continue
do jj=1,n
dist2=(x(jj))**2+(y(jj))**2+(z(jj))**2
dist=sqrt(dist2)
k=(dist/dr)+1
h(k) = h(k)+1 !!!!!!!! Error here!!!!!!!!!
end do
enddo
end do
write(*,*)'Final config'
write(*,'(3f8.3)')(x(j),y(j),z(j),j=1,n)
counterB=counter4+counter5+counter6
write(*,*)'Rejection ='
write(*,*)counterB
stop
end

In your code, h is not declared...
From
do i = 1,nfatmax
h(i) = 0
end do
I assume it should be an array of length nfatmax:
dimension h(nfatmax)
As stated in High Performance Mark's comment, you could have found this error by using implicit none...

I see you dimensioning x, y and z but I see no such beastie for h.
Perhaps you might want to create the array before trying to put values into it.

Related

Explicit Forward-Difference Method in Fortran Programming(Gives Overflow)-(what inputs should be given)

Question Link-(https://drive.google.com/file/d/1A9Vf-e1qbdNZxa_UQ2cy8K4LiEfubU6X/view?usp=sharing)
The problem is with inputs when I give the inputs it gives me overflow error
Code That is written for solving the problem:-
COMMON/VARI/U(0:101),V(0:101)
REAL K,KP
DATA T,X1,X2,KP/0,0,1,1/
P(T)= 0
Q(T)= 0
F(X)= 100*SIN(PI*X)
E(X,T)=100*EXP(-PI*PI*T)*SIN(PI*X)
PRINT*,'ENTER TMAX,N,K'
READ*,TMAX,N,K
H=(X2-X1)/N
R=(KP*K)/(H*H)
PI = 4*ATAN(1.0)
! SET INITIAL CONDITION============================================
DO I =0,N
X=X1+I*H
V(I)=F(X)
END DO
! DEFINE TRADITIONAL LINEAR SYSTEM==
15 DO I=1,N-1
U(I)=V(I)+R*(V(I-1)-2*V(I)+V(I+1))
END DO
T=T+K
U(0)=P(T)
U(N)=Q(T)
! WRITE U OVER V TO PREPARE FOR NEXT TIME STEP==
DO I =0,N
V(I)= U(I)
END DO
!IF T IS LESS THAN TMAX , TAKE A TIME STEP===
IF(ABS(TMAX-T).GT.K/2) GOTO 15
! OTHERWISE PRINT RESULT
WRITE (2,110) N,K,TMAX,T
WRITE (3,120)
DO I=0,N
X=X1+I*H
EXACT=E(X,T)
ER=ABS(EXACT-U(I))
WRITE(6,130)X,U(I),EXACT,ER
END DO
110 FORMAT(2x,'N=',I4,2x,'K=',F8.6,2x,'TMAX=',F5.2,2x,'implT=',F5.2/)
120 FORMAT(2x,'x=',F5.2,5x,'NUMERICAL',F10.2,5X,'EXAT',5X,'ER',/)
130 FORMAT(3x,F4.2,2x,3F13.6)
STOP
END

alternatives of using real as array index

I wish to solve the schrodinger time dependent equation . In my code, I introduced two arrays, namely yc and yr, for the complex and real part of wavefunction . Later I tried to store the values in the array in the format yc(x(i),t(j)) as y(x,t) function .There is a warning showing that I am using real as index of an array . I understand where the problem lies, but what is the way out ? Can I define a function whose values I can assign during my program discreetly as an alternative to that array ?
I have googled about this could not find any solution .
function v(x) result(s)
real::s,x
if (x<0) then
s=0
else
s=1
end if
end function v
real::t(10000),x(10000),yc(10000,10000),yr(10000,10000),tf,xi,xf,d
integer::i,j,k,l,m
write(*,*) "tf,xi,xf,step size"
read(*,*) tf,xi,xf,d
x(1)=xi
t(1)=0
i=1
1 if(x(i).lt.xf) then
x(i+1)=x(i)+d
i=i+1
goto 1
end if
do j=1,i
yr(x(j),0)=exp(-x(j)**2) !initial wavefunction
yc(x(j),0)=0
end do
do l=1,i
k=1
3 if(t(k).lt.tf) then
yr(x(l),t(k+1))=yr(x(l),t(k))-(yc(x(l)+2*d,t(k))-2*yc(x(l)+d,t(k))+yc(x(l),t(k)))/d&
+v(x(l))*yc(x(l),t(k))*d
yc(x(l),t(k+1))=yc(x(l),t(k))+(yr(x(l)+2*d,t(k))-2*yr(x(l)+d,t(k))+yr(x(l),t(k)))/d&
-v(x(l))*yr(x(l),t(k))*d
k=k+1
goto 3
end if
end do
open(1,file="q.dat")
do m=1,i
write(1,*) x(m),yr(x(m),t(1))**2+yc(x(m),t(1))**2
end do
close(1)
end
expected result :$ yi(x,t)^2+yc(x,t)^2 versus x at different t
obtained error :
yr(x(j),0)=exp(-x(j)**2) !initial wavefunction
1
Warning: Legacy Extension: REAL array index at (1)
schrodinger.f90:27:8:
yr(x(j),0)=exp(-x(j)**2) !initial wavefunction
1
Warning: Array reference at (1) is out of bounds (0 < 1) in dimension 2
schrodinger.f90:28:3: and so on`enter code here`
I have googled how to use real as index but no use .
function v(x) result(s)
real::s,x
if (x<0) then
s=0
else
s=1
end if
end function v
real::t(10000),x(10000),yc(10000,10000),yr(10000,10000),tf,xi,xf,d
integer::i,j,k,l,m
write(*,*) "tf,xi,xf,step size"
read(*,*) tf,xi,xf,d
x(1)=xi
t(1)=0
i=1
1 if(x(i).lt.xf) then
x(i+1)=x(i)+d
i=i+1
goto 1
end if
do j=1,i
yr(x(j),0)=exp(-x(j)**2) !initial wavefunction
yc(x(j),0)=0
end do
do l=1,i
k=1
3 if(t(k).lt.tf) then
yr(x(l),t(k+1))=yr(x(l),t(k))-(yc(x(l)+2*d,t(k))-2*yc(x(l)+d,t(k))+yc(x(l),t(k)))/d&
+v(x(l))*yc(x(l),t(k))*d
yc(x(l),t(k+1))=yc(x(l),t(k))+(yr(x(l)+2*d,t(k))-2*yr(x(l)+d,t(k))+yr(x(l),t(k)))/d&
-v(x(l))*yr(x(l),t(k))*d
k=k+1
goto 3
end if
end do
open(1,file="q.dat")
do m=1,i
write(1,*) x(m),yr(x(m),t(1))**2+yc(x(m),t(1))**2
end do
close(1)
end
expected : data files with wavefunction at different time .
obtained : warning - using real as indices
Just reference your arrays using the integers i,j etc. If you have x(i),t(j) then yr(i,j) is the corresponding value. To get the offsets of +2*d etc you only need to use use +2 instead. e.g. yr(l+2,k) rather than yr(x(l)+2*d,t(k)).
Also, please use implicit none for a start and get a hold of a modern Fortran reference book or similar. All those go tos are a bit hard on the eyes.

Fortran error when calculating cosx

I was assigned the following problem:
Make a Fortran program which will be able to read a degree[0-360] checking validity range(not type) and it will be able to calculate and print the cos(x) from the following equation, where x is in radians:
cos(x)=1-x^2/2! + x^4/4!-x^6/6!+x^8/8!-...
As a convergence criteria assume 10^(-5) using the absolute error between two successive repeats (I suppose it means do's).
For the calculation of the ! the greatest possible kind of integer should be used. Finally the total number of repeats should be printed on screen.
So my code is this:
program ex6_pr2
implicit none
!Variables and Constants
integer::i
real*8::fact,fact2 !fact=factorial
real,parameter::pi=3.14159265
double precision::degree,radiants,cosradiants,s,oldcosradiants,difference !degree,radiants=angle
print*,'This program reads and calculates an angle`s co-sinus'
print*,'Please input the degrees of the angle'
read*,degree
do while(degree<0 .or. degree>360) !number range
read*,degree
print*,'Error input degree'
cycle
end do
radiants=(degree*pi/180)
fact=1
fact2=1
s=0
cosradiants=0
!repeat structure
do i=2,200,1
fact=fact*i
fact2=fact2*(i+2)
oldcosradiants=cosradiants
cosradiants=(-(radiants)**i/fact)+(((radiants)**(i+2))/fact2)
difference=cosradiants-oldcosradiants
s=s+cosradiants
if(abs(difference)<1e-5) exit
end do
!Printing results
print*,s+1.
end program
I get right results for angles such as 45 degrees (or pi/4) and wrong for other for example 90 degrees or 180.
I have checked my factorials where I believe the error is hidden (at least for me).
Well I created another code which seems unable to run due to the following error:FUNCTION name,(RESULT of PROJECT2_EX6~FACT),used where not expected,perhaps missing '()'
program project2_ex6
implicit none
integer(kind=3)::degrees,i,sign
integer::n
double precision::x,err_limit,s_old,s
real,parameter::pi=3.14159265359
print*,'This program calculates the cos(x)'
print*,"Enter the angle's degrees"
read*,degrees
do
if(degrees<0.or.degrees>360) then
print*,'Degrees must be between 0-360'
else
x=pi*degrees/180
exit
end if
end do
sign=1
sign=sign*(-1)
err_limit=1e-5
n=0
s=0
s_old=0
do
do i=1,n
end do
s=(((-1.)**n/(fact(2.*n)))*x**(2.*n))*sign
s=s+s_old
n=n+1
if(abs(s-s_old)<1e-5) then
exit
else
s_old=s
cycle
end if
end do
print*,s,i,n
contains
real function fact(i)
double precision::fact
integer::i
if(i>=1) then
fact=i*fact(i-1)
else
fact=1
end if
return
end function
end program
Although it is your homework, I will help you here. The first thing which is wrong is ýour factorial which you need to replace with
fact = 1
do j = 1,i
fact = fact*j
enddo
second it is easier if you let your do loop do the job so run it as
do i=4,200,2
and predefine cosradians outside the do loob with
cosradiants = 1-radiants**2/2
additionally you need to take into account the changing sign which you can do in the loop using
sign = sign*(-1)
and starting it off with sign = 1 before the loop
in the loop its then
cosradiants= cosradiants+sign*radiants**i/fact
If you have included these things it should work (at least with my code it does)

least squares minimisation fortran 77

Trying to get a one-parameter least squares minimisation working in fortran77. Here's the code; it compiles and seems to work except....it gets caught in an infinite loop between values of h1= 1.8E-2 and 3.5E-2.
Having a look now but, odds are, I'm not going to have much luck sussing the issue on my own. All help welcome!
PROGRAM assignment
! A program designed to fit experiemental data, using the method
! of least squares to minimise the associated chi-squared and
! obtain the four control parameters A,B,h1 and h2.
!*****************************************************************
IMPLICIT NONE
INTEGER i
DOUBLE PRECISION t(17),Ct(17),eCt(17)
DOUBLE PRECISION h1loop1,h1loop2,deltah,Cs
DOUBLE PRECISION chisqa,chisqb,dchisq
OPEN(21, FILE='data.txt', FORM='FORMATTED', STATUS='OLD')
DO i=1,17
READ(21,*)t(i),Ct(i),eCt(i)
END DO
CLOSE(21)
!Read in data.txt as three one dimensional arrays.
!*****************************************************************
!OPEN(21, FILE='outtest.txt', FORM='FORMATTED', STATUS='NEW')
!DO i=1,17
! WRITE(21,*)t(i),Ct(i),eCt(i)
!END DO
!CLOSE(21)
!
!Just to check input file is being read correctly.
!*****************************************************************
!**********************Minimising Lamda1 (h1)*********************
deltah= 0.0001
h1loop2= 0.001
h1loop1= 0.0 !Use initial value of 0 to calculate start-point chisq
DO 10
chisqa= 0.0
DO 20 i= 1, 17
Cs= exp(-h1loop1*t(i))
chisqa= chisqa + ((Ct(i) - Cs)/eCt(i))**2
20 END DO
chisqb= 0.0
DO 30 i= 1, 17
h1loop2= h1loop2 + deltah
Cs= exp(-h1loop2*t(i))
chisqb= chisqb + ((Ct(i) - Cs)/eCt(i))**2
30 END DO
!Print the two calculated chisq values to screen.
WRITE(6,*) 'Chi-squared a=',chisqa,'for Lamda1=',h1loop1
WRITE(6,*) 'Chi-squared b=',chisqb,'for Lamda1=',h1loop2
dchisq= chisqa - chisqb
IF (dchisq.GT.0.0) THEN
h1loop1= h1loop2
ELSE
deltah= deltah - ((deltah*2)/100)
END IF
IF (chisqb.LE.6618.681) EXIT
10 END DO
WRITE(6,*) 'Chi-squared is', chisqb,' for Lamda1 = ', h1loop2
END PROGRAM assignment
EDIT: Having looked at it again I've decided I have no clue what's screwing it up. Should be getting a chi-squared of 6618.681 from this, but it's just stuck between 6921.866 and 6920.031. Help!
do i=1
is not starting a loop, for a loop you need to specify an upper bound as well:
do i=1,ub
that's why you get the error message about the doi not having a type, in fixed format spaces are insignificant...
Edit: If you want to have an infinite loop, just skip the "i=" declaration completely. You can use an exit statement to leave the loop, when a certain criterion has been reached:
do
if (min_reached) EXIT
end do
Edit2: I don't know why you stick to F77 fixed format. Here is your program in free format, with some fixes of places, which looked weird, without digging too much into the details:
PROGRAM assignment
! A program designed to fit experiemental data, using the method
! of least squares to minimise the associated chi-squared and
! obtain the four control parameters A,B,h1 and h2.
!*****************************************************************
IMPLICIT NONE
integer, parameter :: rk = selected_real_kind(15)
integer, parameter :: nd = 17
integer :: i,t0
real(kind=rk) :: t(nd),t2(nd),Ct(nd),eCt(nd),Ctdiff(nd),c(nd)
real(kind=rk) :: Aa,Ab,Ba,Bb,h1a,h1b,h2a,h2b,chisqa,chisqb,dchisq
real(kind=rk) :: deltah,Cs(nd)
OPEN(21, FILE='data.txt', FORM='FORMATTED', STATUS='OLD')
DO i=1,nd
READ(21,*) t(i),Ct(i),eCt(i)
END DO
CLOSE(21)
!Read in data.txt as three one dimensional arrays.
!*****************************************************************
!OPEN(21, FILE='outtest.txt', FORM='FORMATTED', STATUS='NEW')
!DO i=1,17
! WRITE(21,*)t(i),Ct(i),eCt(i)
!END DO
!CLOSE(21)
!
!Just to check input file is being read correctly.
!*****************************************************************
!****************************Parameters***************************
Aa= 0
Ba= 0
h1a= 0
h2a= 0
!**********************Minimising Lamda1 (h1)*********************
deltah= 0.001_rk
h1b= deltah
minloop: DO
chisqa= 0
DO i= 1,nd
Cs(i)= exp(-h1a*t(i))!*Aa !+ Ba*exp(-h2a*t(i))
Ctdiff(i)= Ct(i) - Cs(i)
c(i)= Ctdiff(i)**2/eCt(i)**2
chisqa= chisqa + c(i)
h1a= h1a + deltah
END DO
! Use initial h1 value of 0 to calculate start-point chisq.
chisqb= 0
DO i= 1,nd
h1b= h1b + deltah
Cs(i)= exp(-h1b*t(i))!*Ab !+ Bb*exp(-h2b*t(i))
Ctdiff(i)= Ct(i) - Cs(i)
c(i)= Ctdiff(i)**2/eCt(i)**2
chisqb= chisqb + c(i)
END DO
! First-step h1 used to find competing chisq for comparison.
WRITE(6,*) 'Chi-squared a=', chisqa,'for Lamda1=',h1a
WRITE(6,*) 'Chi-squared b=', chisqb,'for Lamda1=',h1b
! Prints the two calculated chisq values to screen.
dchisq= chisqa - chisqb
IF (dchisq.GT.0) THEN
h1a= h1b
ELSE IF (dchisq.LE.0) THEN
deltah= (-deltah*2)/10
END IF
IF (chisqb.LE.6000) EXIT minloop
END DO minloop
WRITE(6,*) 'Chi-squared is', chisqb,'for Lamda1=',h1b
END PROGRAM assignment

"Error: The shapes of the array expressions do not conform"

This is my program to solve a problem of three dimensional cylindrical fin. But when i run this program in Fortran 6.2 this error shows up:
Error: The shapes of the array expressions do not conform. [T]"
Now i don't understand why this is happening. I need quick assistance. Anyone please help me.
PROGRAM CYLINDRICAL FIN
DIMENSION T(500,500,500), OLDT(500,500,500),ERR(500,500,500)
DIMENSION R(500),Y(500),Z(500)
REAL CC,H,DR,DY,DZ,A,D,RY,YZ,ZR,B,E,TA,RL,YL,ZL
+P,AC,QF,MF,Q,EF,EFF,QMAX,AS,LC,QT,QF1,QF2
INTEGER I,J,K,M,N,L,M1,N1,L1,M2,M4,M34,N2,N4,N34,L2,L4,L34
RL=0.5
YL=6.283
ZL=0.04
M=100
N=40
L=20
M2=((M/2)+1)
M4=((M/4)+1)
M34=((3*M/4)+1)
N2=((N/2)+1)
N4=((N/4)+1)
N34=((3*N/4)+1)
L2=((L/2)+1)
L4=((L/4)+1)
L34=((3*L/4)+1)
DR=RL/M
DY=YL/N
DZ=ZL/L
CC=400.0
H=10.0
TA=25
M1=M-1
N1=N-1
L1=L-1
************VARIABLES************
A=DR*DY*DZ
D=DR+DY+DZ
RY=DR*DY
YZ=DY*DZ
ZR=DZ*DR
E=RY+YZ+ZR
************VARIABLES FOR EFFICIENCY AND EFFECTIVENESS (CROSS-SECTION AREA,PERIMETER,M,SURFACE AREA OF FIN)************
AC=3.1416*DR**2
P=2*(3.1416*DR+DZ)
MF=((H*P)/(CC*AC))**(0.5)
AS=2*3.1416*DR*DZ+3.1416*DR**2
************************************** distance discritization ******************
R(1)=0.0
Y(1)=0.0
Z(1)=0.0
R(M+1)=RL
Y(N+1)=YL
Z(L+1)=ZL
DO I=2,M
R(I)=R(I-1)+DR
END DO
DO J=2,N
Y(J)=Y(J-1)+DY
END DO
DO K=2,L
Z(K)=Z(K-1)+DZ
END DO
DO I=1,M
DO J=1,N
DO K=1,L
T(I,J,K)=0.0
END DO
END DO
END DO
DO I=1,M
DO J=1,N
T(I,J,1)=400
END DO
END DO
ITER=0.0
READ(*,*) LAST
31 CONTINUE
ITER=ITER+1
*************************************** FORMULAS**********************************
DO I=2,M1
DO J=2,N1
DO K=2,L1
T(I,J,K)=((R*DR*T(I+1,J,K)*(YZ)**2.0)-((T(I+1,J,K)+T(I-1,J,K))*
+(R*YZ)**2.0)-((T(I,J+1,K)+T(I,J-1,K))*(ZR**2.0))-((T(I,J,K+1)+
+T(I,J,K-1))*(R*RY)**2.0))/((R*DR*(YZ)**2.0)-(2.0*(R*YZ)**2.0)-
+(2.0*(ZR)**2.0)-(2.0*(R*RY)**2.0))
END DO
END DO
END DO
*************************************** END OF ITERATIONG FORMULAS****************
DO I=1,M
DO J=1,N
DO K=1,L
OLDT(I,J,K)=T(I,J,K)
END DO
END DO
END DO
DO I=1,M
DO J=1,N
DO K=1,L
ERR(I,J,K)=T(I,J,K)-OLDT(I,J,K)
END DO
END DO
END DO
EMAX=0.0
EMAX=MAX(EMAX,ERR(I,J,K))
WRITE(*,*) ITER, EMAX
IF (ITER.LT.LAST) GOTO 31
WRITE(*,*) DR,A,B,E
END PROGRAM CYLINDRICAL FIN
In your long formula you have R without index. But R is a vector so that's why you get the error.
DO I=1,M
DO J=1,N
T(I,J,1)=400
END DO
END DO
can be written more swiftly as
T(1:M,1:N,1) = 400
also 400 is an integer so you better use 400.
I quickly converted the program to free-format and compiled it with gfortran. The problem line is:
T(I,J,K)=((R*DR*T(I+1,J,K)*(YZ)**2.0)-((T(I+1,J,K)+T(I-1,J,K))* &
(R*YZ)**2.0)-((T(I,J+1,K)+T(I,J-1,K))*(ZR**2.0))-((T(I,J,K+1)+ &
T(I,J,K-1))*(R*RY)**2.0))/((R*DR*(YZ)**2.0)-(2.0*(R*YZ)**2.0)- &
(2.0*(ZR)**2.0)-(2.0*(R*RY)**2.0))
The gfortran error message is:
"Error: Incompatible ranks 0 and 1 in assignment at (1)"
with the (1) designation the "T" on the LHS. Obviously the T(I,J,K) is a scaler of rank 0. Somewhere on the RHS you have an array of rank 1 -- identified by Azrael3000 as "R".
P.S. I recommend using "implicit none" and typing all of your variables. Implicit typing is pernicious, e.g., it allows typos in variable names to be accepted by the compiler.
Your problem comes from the array operation you are trying to perform.
If you simplify the line:
T(I,J,K)=((R*DR*T(I+1,J,K)*(YZ)**2.0)-((T(I+1,J,K)+T(I-1,J,K))*
+(R*YZ)**2.0)-((T(I,J+1,K)+T(I,J-1,K))*(ZR**2.0))-((T(I,J,K+1)+
+T(I,J,K-1))*(R*RY)**2.0))/((R*DR*(YZ)**2.0)-(2.0*(R*YZ)**2.0)-
+(2.0*(ZR)**2.0)-(2.0*(R*RY)**2.0))
You can end up with this other line that also shows the same error:
T(I,J,K)= T(I,J,K-1)*R
The shapes of the array expressions do not conform. [T]
So you can see that your problem comes from trying to assign an array R to a scalar T(I,J,K).