nafiz27me
nafiz27me

Reputation: 31

"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

Upvotes: 2

Views: 10498

Answers (3)

Eduardo
Eduardo

Reputation: 21

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).

Upvotes: 0

M. S. B.
M. S. B.

Reputation: 29401

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.

Upvotes: 2

Azrael3000
Azrael3000

Reputation: 1897

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.

Upvotes: 5

Related Questions