You are on page 1of 12

c===============================================================================

=============
c===============================================================================
=============
c A FINITE ELEMENT CODE WHICH SOLVES A SECOND ORDER LINEAR ODE WITH BOUNDARY C
ONDITIONS
c===============================================================================
===========
c===============================================================================
============
C

THE GIVEN ODE IS MORE GENERALIZED EQUATION (self adjoint eqn).

C IN THE MAIN PART OF THE PROGRAMMING, ASSEMBLING,HANDLING THE BOUNDARY DATA


AND FINALLY
C OBTAING THE SOLUTION IS DONE. MESH GENERATION, ELEMENT STIFNESS MATRIX AND S
HAPE FUNCTIONS
C ARE HANDLED IN DIFFERENT SUBROUTINES. FIRST WE OBTAIN THE SOLUTION AT NODAL
POINTS AND
C FINALLY OBTAIN THE ERROR IN H1 NORM.
C------------------------------------------------------------------------------------------------C THIS CODE IS h-VERSION OF THE FEM AND MAXIMUM DEGREE OF APPROXIMATION "p" HERE
WE CONSIDER IS 3
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++
C
main programme
c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++
c
X1,X2----- end points of the domain
c
NELE------ the number of elements in the mesh
c
NP-------- degree of approximation
c
NUMDOF-----number of degrees of freedom = (NELE*NP+1)
c
GK---------global stiffness matrix after assembing
c
GF---------global load vector after assembling
c
GKBC-------global stiffness matrix after BC's are incorporated
c
GFBC-------global load vector after BC's are incorporated
c
XZ---------the solution at the nodal points
c===============================================================================
=============
C
GIVING NODAL NUMBERS, ASEMBLING LOCAL MATRICES WHICH ARE OBTAINED FROM E
LEMENTARY
C
CALUCLATIONS, CALLING BOUNDARY CONDITION DATA AND SOLVING SYSTEM BY CALL
ING SOLVER
c===============================================================================
==============
IMPLICIT REAL *8 (A-H,O-Z)
DIMENSION XI1(1001)
DIMENSION PSI(4),DPSI(4)
COMMON/CINT/XI(10),W(10)
COMMON/INTORDER/NL
DIMENSION EK(5,5),EF(5)
DIMENSION GK(1001,1001),GF(1001)
DIMENSION IELDOF(1001,1001)
DIMENSION GKL(1001,1001),GKU(1001,1001),Z(1001),XZ(1001)
DIMENSION GKBC(1001,1001),GFBC(1001)
DIMENSION XI2(1001)

c******************READING THE DATA OF THE PROBLEM******************************


***************
NL=5!the order of integration
CALL SETINT(NL)
c----------------------------------------------------------------------------------------------C
WRITE (*,*) "ENTER THE END POINTS OF INTERVAL X1,X2"
C
READ (*,*),X1,X2
C-------------------FOR PROBLEM 1-------------------------------------C
X1=0.0;X2=1.0
C
F1=-2.0;F2=0.0;F3=1.0;F4=0.0
C
A1=1.0;A2=0.0
C
C1=1.0;C2=0.0
C
BCTYPE=1
C
U1=0.0;U2=1.0
C----------------FOR PROBLEM 2------------------------------------------X1=0.0;X2=1.0
F1=0.0;F2=1.0;F3=0.0;F4=0.0
A1=1.0;A2=0.0
C1=1.0;C2=0.0
BCTYPE=1
U1=0.0;U2=0.0
C--------------------------------------------------------------------------------WRITE(*,*) "ENTER THE NO OF ELEMENT MESH IS TO BE DIVIDED"
READ (*,*) NELE
WRITE (*,*) "ENTER NP(1-3)"
READ (*,*),NP
C
C
C
C
C
C
C
C
C

WRITE(*,*) "ENTER THE COEFFICIENTS OF F,


&(F=F1+F2*X+F3*X**2+F4*X*X**2) F1,F2,F3,F4"
READ (*,*) F1,F2,F3,F4
WRITE(*,*) "ENTER THE VALUES OF (A=A1+A2*X) A1,A2"
READ (*,*) A1,A2
WRITE(*,*) "ENTER THE VALUES OF (C=C1+C2*X) C1 ,C2"
READ (*,*) C1,C2
WRITE (*,*) "ENTER THE TYPE OF BC DIR(1),NEUMANN(2),ROBI(3)"
READ (*,*),BCTYPE

C
IF (BCTYPE.EQ.1) THEN
C
WRITE (*,*) "ENTER U1,U2"
C
READ (*,*),U1,U2
C
ELSE
C
WRITE (*,*) "ENTER P1,P2"
C
READ (*,*),P1,P2
C
END IF
C*************************END OF READING THE DATA*******************************
*******
C-----------------------------------------------------------------------------------C
NUMBERING OF NODES
C------------------------------------------------------------------------------------NR=0
DO 70 K=1,NELE
DO 19 J=1,NP+1
NR=NR+1

19
70

IELDOF(J,K)=NR
CONTINUE
NR=NR-1
CONTINUE
NUMDOF=(NELE*NP)+1
WRITE (*,*), 'NUBDOF',NUMDOF

118
119

WRITE (*,*),'NODAL NUMBERS'


DO 119 K=1,NELE
DO 118 J=1,NP+1
WRITE (*,*),IELDOF(J,K)
CONTINUE
CONTINUE

C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C BEGINING OF THE ASSEMBLING THE STIFFNESS MATRIX AND LOAD VECTOR
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C---------------------------------------------------------------------C
intializing global stiff matrix and load vector
C--------------------------------------------------------------------DO 22 I =1,NUMDOF
GF(I)=0.0
DO 22 J=1,NUMDOF
GK(I,J) =0.0
22
CONTINUE
DO 80 K=1,NELE
CALL MESHGEN(NELE,X1,X2,XI1)
CALL ELEMSTIFFLOAD(XI1,K,NP,A1,A2,C1,C2,F1,F2,F3,F4,EF,EK)
NUMLOC = NP+1
C

loop over rows and columns of element matrix


DO 10 JLOC=1,NUMLOC
JGLOB=IELDOF(JLOC,K)
GF(JGLOB)=GF(JGLOB)+EF(JLOC)
DO 20 KLOC=1,NUMLOC
KGLOB=IELDOF(KLOC,K)
GK(JGLOB,KGLOB)=GK(JGLOB,KGLOB)+EK(JLOC,KLOC)

20
CONTINUE
10
CONTINUE
80
CONTINUE
C++++++++++++++++++++++++++++++END OF ASSEMBLING++++++++++++++++++++++++++++++++
+
c
c
c
c50
c
c
c

WRITE (*,*),'GLOBAL LOAD VECTOR IS:'


DO 50 I = 1,NUMDOF
WRITE(*,*) GF(I)
CONTINUE
WRITE (*,*),'GLOBAL STIFF MATRIX IS'
DO 60 I = 1,NUMDOF
WRITE (*,*),(GK(I,J),J=1,NUMDOF)

c60

CONTINUE

C=======================CALLING BOUNDARY DATA===================================


========
CALL BCDATA(NUMDOF,NELE,BCTYPE,GK,GF,U1,U2,P1,P2,
&DEL1,DEL2,GKBC,GFBC)
c
c
c
c
c501

WRITE (*,*),'GLOBAL LOAD VECTOR IS:'

c
c
c
c601

WRITE (*,*),'GLOBAL STIFF MATRIX IS'


DO 601 I = 1,NUMDOF
WRITE (*,*),(GKBC(I,J),J=1,NUMDOF)
CONTINUE

DO 501 I = 1,NUMDOF
WRITE(*,*) GFBC(I)
CONTINUE

C$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$
C
NOW WE HAVE COMPLETE GLOBAL STIFFNESS MATRIX AND LOAD VECTOR
C
THEREFORE WE CAN SOLVE FOR THE NODAL VALUES USING LU DECOMPOSITION
C$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$
CALL LU(GKBC,GKL,GKU,Z,XZ,GFBC,NUMDOF)
WRITE (*,*)'THE SOLUTION VECTOR IS'
WRITE (*,*) (XZ(I),I=1,NUMDOF)
C-----------CALCULATING ERROR IN H1NORM------------------GERROR=0.0
DO L=1,NELE
ERROR=0.0
CALL H1NORM(L,NP,XI1,XZ,ERROR)
GERROR=GERROR+ERROR
END DO
WRITE (*,*) "GERROR",SQRT(GERROR)
c-------------------------------------------------------------STOP
END
C%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%END OF THE MAIN PROGRAMME%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%
C----------------------- SUBROUTINE STARTS-----------------------------------------------C======= THE FOLLOWING SUBROUTINE CALUCULATES THE ELEMENT STIFFNESS MATRIX======
==========
c
c
c
c
c
c
c
c

PSI---------the values of the basis functions at the integration points


DPSI--------the values of the derivatives of the basis functions
EK----------element stiffness matrix
EF----------element load vector
XI----------integration points
W-----------wieghts in the numerical integration
A,C,F-------the data at integration points
DX----------jacobian of the linear map from master element to the eleme

nt in the mesh
c
XI1---------end points of the elements in the mesh
c===============================================================================
===============
SUBROUTINE ELEMSTIFFLOAD(XI1,K,NP,A1,A2,C1,C2,
&F1,F2,F3,F4,EF,EK)
IMPLICIT REAL *8 (A-H,O-Z)
DIMENSION PSI(4),DPSI(4)
DIMENSION EK(5,5),EF(5)
DIMENSION XI1(1001)
COMMON/CINT/XI(10),W(10)
COMMON/INTORDER/NL
DIMENSION A(5),C(5),F(5)
REAL NL1
REAL X(5)
DIMENSION PI(12)
C

10

INITIALIZING ELEMENT ARRAYS


DO 10 I=1,NP+1
EF(I)=0.0
DO 10 J=1,NP+1
EK(I,J)=0.0
CONTINUE

CALL NOINT(A1,A2,C1,C2,F1,F2,F3,F4,NP,PBAR)

NL1 = (PBAR+1)*0.5

C
C

NL = NL1+0.5
DX = (XI1(K+1)-XI1(K))/2

CALL SETINT(NL)

BEGIN INTEGRATION LOOP


DO 20 L=1,NL
CALL MATERIALDATA(XI1,L,K,A1,A2,C1,C2,F1,F2,F3,F4,A,C,F)
CALL CSHAPE(L,NP,PSI,DPSI)
DO 30 I=1,NP+1
EF(I)=EF(I)+F(L)*W(L)*PSI(I)*DX
DO 40 J=1,NP+1
EK(I,J)= EK(I,J)+((A(L)*DPSI(I)*DPSI(J)/DX)+
&(C(L)*PSI(I)*PSI(J)*DX))*W(L)

40
30
20

CONTINUE
CONTINUE
CONTINUE

RETURN
END
C==========END OF THE SUBROUTINE ELEMAT=========================================

======
c===============================================================================
=======
C
A SUBroutine OF INTEGERATION POINTS AND WT FUNCTIONS
C
USED IN FEM ELEMENTWISE CALUCLATIONS
C===============================================================================
========
SUBROUTINE SETINT(NL)
IMPLICIT REAL *8 (A-H,O-Z)
COMMON/CINT/XI(10),W(10)
X1 =-1.0
X2 = 1.0
M=(NL+1)/2
XM=.5*(X2+X1)
XL=.5*(X2-X1)
DO 12 I =1,M
Z=COS(3.141592654*((I-.25)/(NL+.5)))
13

11

P1=1.
P2=0.
DO 11 J = 1,NL
P3=P2
P2=P1
P1=((2.*J-1.)*Z*P2-(J-1.)*P3)/J
CONTINUE
PP=NL*(Z*P1-P2)/(Z*Z-1.)
Z1=Z
Z=Z1-P1/PP
IF (ABS(Z-Z1) .GT. (3.E-14)) GOTO 13
XI(I) = XM-XL*Z
XI(NL+1-I) = XM+XL*Z
W(I) = 2.*XL/((1.-Z*Z)*PP*PP)
W(NL+1-I)= W(I)

12
CONTINUE
c--------------------------------------------------------------------------RETURN
END
C===========================================================================
C
A PROGRAM TO DEFINE ELEMENTARY SHAPE FUNCTION AT THE INTEGRATION POINTS
C
OF FEM DEPENDING UPON DEGREE OF APPROXIMATION
C===========================================================================
SUBROUTINE CSHAPE(L,NP,PSI,DPSI)
IMPLICIT REAL *8 (A-H,O-Z)
COMMON/CINT/XI(10),W(10)
DIMENSION PSI(4),DPSI(4)
IF (NP.EQ.1) THEN
GOTO 10
ELSE IF( NP.EQ.2) THEN
GOTO 20

ELSE
GOTO 30
ENDIF
c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
LINEAR SHAPE FUNCTIONS AND THEIR DERIVATIVES
c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
10

PSI(1)=.5*(1.-XI(L))
PSI(2)=.5*(1.+XI(L))
DPSI(1)=-.5
DPSI(2)=.5
RETURN
c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
QUADARTIC SHAPE FUNCTIONS AND THEIR DERIVATIVES
c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
20
PSI(1)=.5*XI(L)*(XI(L)-1.)
PSI(2)=1.-(XI(L)**2)
PSI(3)=.5*XI(L)*(XI(L)+1.)
DPSI(1)=XI(L)-.5
DPSI(2)=-2.*XI(L)
DPSI(3)=XI(L)+.5
RETURN
c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
CUBIC SHAPE FUNCTIONS AND THEIR DERIVATIVES
c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
30

PSI(1)=(9./16.)*((1./9.)-(XI(L)**2))*(XI(L)-1.)
PSI(2)=(27./16.)*(1.-(XI(L)**2))*((1./3.)-XI(L))
PSI(3)=(27./16.)*(1.-(XI(L)**2))*((1./3.)+XI(L))
PSI(4)=(-9./16.)*((1./9.)-(XI(L)**2))*(XI(L)+1.)
DPSI(1)=(-9./16.)*(3.*(XI(L)**2)-(2.*XI(L))-(1./9.))
DPSI(2)=(27./16.)*(3.*(XI (L)**2)-2./3.*XI(L)-1.)
DPSI(3)=(27./16.)*(-3.*(XI(L)**2)-((2./3.)*(XI(L)))+1.)
DPSI(4)=(-9./16.)*(-3.*(XI(L)**2)-(2.*XI(L))+(1./9.))

RETURN
END
C========================================================================
C
A SUBROUTINE TO GENERATE A MESH FOR FINITE ELEMENT METHOD
C========================================================================
SUBROUTINE MESHGEN(NELE,X1,X2,XI1)
IMPLICIT REAL *8 (A-H,O-Z)
DIMENSION XI1(NELE+1)
A1=NELE
H=(X2-X1)/(A1)

11

12

DO 11 I=1,50
XI1(I)=0
CONTINUE
XIN=0.0
XI1(1)=X1
DO 12 I=2,NELE+1
XI1(I)=XIN+H
XIN=XIN+H
CONTINUE

RETURN
END
C============================================================================

C
CALUCLATING THE INTEGERTION POINTS ACCORDING TO DATA
C=============================================================================
SUBROUTINE NOINT(A1,A2,C1,C2,F1,F2,F3,F4,NP,PBAR)
IMPLICIT REAL *8 (A-H,O-Z)
c------------------------------------------------------------------------------IF ((C1 .EQ. 0) .AND. (C2 .EQ. 0) .AND. (A1 .EQ. 0) .AND.
&(A2 .EQ. 0)) THEN
WRITE(*,*) 'DATA IS INSUFFICIENT'
ELSE IF (C2 .NE. 0) THEN
PBAR = 2*NP+1
ELSE IF (F4 .NE. 0) THEN
PBAR = NP+3
ELSE IF (C1 .NE. 0) THEN
PBAR = 2*NP
ELSE IF (F3 .NE. 0) THEN
PBAR = NP+2
ELSE IF (A2 .NE. 0) THEN
PBAR = 2*NP-1
ELSE IF (F2 .NE. 0) THEN
PBAR = NP+1
ELSE
PBAR = NP
END IF
c---------------------------------------------------------------------RETURN
END
C=====================================================================
C
A PRORAM TO OBTAIN THE MATERIAL DATA AT THE INTEGRATION POINTS
C======================================================================
SUBROUTINE MATERIALDATA(XI1,L,K,A1,A2,C1,C2,F1,F2,F3,F4,A,C,F)
IMPLICIT REAL *8 (A-H,O-Z)
DIMENSION A(5),C(5),F(5)
DIMENSION XI1(1001),X(10)
COMMON/CINT/XI(10),W(10)
XX1=(1-XI(L))*XI1(K)+(1+XI(L))*XI1(K+1)
XX=XX1/2
A(L)=A1+(A2*XX)
C(L)=C1+(C2*XX)
F(L)=F1+(F2*XX)+(F3*(XX**2))+(F4*(XX**3))
RETURN
END
C======================================================================
C
BOUNDARY CONDITION DATA
C
WE HAVE TWO ENDS AND THREEE TYPE OF CONDITIONS
C
TYPES DIRICHLET (1),NEUMANN(2),MIXED(3)
C=======================================================================
SUBROUTINE BCDATA(NUMDOF,NELE,BCTYPE,GK,GF,U1,U2,P1,P2,
&DEL1,DEL2,GKBC,GFBC)
IMPLICIT REAL *8 (A-H,O-Z)
DIMENSION GK(1001,1001),GF(1001),GKBC(1001,1001),GFBC(1001)

IF (BCTYPE.EQ.1) THEN
C
C
C

CONDITIONS IN CASE OF DIRICHLET BC


GENARAL FORM (U(L)=U2,U(0)=U1)
INTIALISATION TO THE BV

102

GF(1)=U1
GK(1,1)=1.0
DO 101 I=2,NUMDOF
GF(I)=GF(I)-(GK(I,1)*U1)
GK(I,1)=0.0
CONTINUE
DO 102 J=2,NUMDOF
GK(1,J)=0.0
CONTINUE

CHANGES AT OTHER END

101

DO 103 I=2,NUMDOF
GF(I)=GF(I)-(GK(I,NUMDOF)*U2)
GK(I,NUMDOF)=0.0
103
CONTINUE
DO 104 J=2,NUMDOF
GK(NUMDOF,J)=0.0
104
CONTINUE
GF(NUMDOF)=U2
GK(NUMDOF,NUMDOF)=1.0
c------------------------------------------------------------C
C

CONDITION SECOND STARTS


GENRAL FORM (A*DU(X)/L=P2,A*DU(X)/0=-P1)

ELSE!for the boundary condition


c-------------------------------------------------------------C

CORRESPOINDING CHANGES IN GLOBAL MATRIX


GF(1)=GF(1)-P1
GF(NUMDOF)=GF(NUMDOF)+P2
ENDIF!for BC

5000
4000

DO 4000 I=1,NUMDOF
GFBC(I)=GF(I)
DO 5000 J=1,NUMDOF
GKBC(I,J)=GK(I,J)
CONTINUE
CONTINUE

RETURN
END
C======================================================================
C
SOLVER OF THE GLOBAL SYSTEM LU DECOMPOSITION
C======================================================================
SUBROUTINE LU(GKBC,GKL,GKU,Z,XZ,GFBC,NUMDOF)
IMPLICIT REAL *8 (A-H,O-Z)
DIMENSION GKBC(1001,1001),GFBC(1001)
DIMENSION GKL(1001,1001),GKU(1001,1001),Z(1001),XZ(1001)
C***************generating the upper and lower triangualr matrices.

1150

DO 1150 I=1,NUMDOF
DO 1150 J=1,NUMDOF
GKL(I,J)=0.0
GKU(I,J)=0.0
CONTINUE

1160

DO 1160 I=1,NUMDOF
GKU(I,I)=1.0
GKL(I,1)=GKBC(I,1)
GKU(1,I)=GKBC(1,I)/GKL(1,1)

1130
1120

DO 1110 J=2,NUMDOF
DO 1120 I=J,NUMDOF
SUM=0.0
DO 1130 K=1,J-1
SUM =SUM+GKL(I,K)*GKU(K,J)
GKL(I,J)=GKBC(I,J)-SUM

1170
1140
1110

IF(J .LT. NUMDOF) THEN


DO 1140 JJ = J+1,NUMDOF
SUM=0.0
DO 1170 KK =1,J-1
SUM=SUM+GKL(J,KK)*GKU(KK,JJ)
GKU(J,JJ)=(GKBC(J,JJ)-SUM)/GKL(J,J)
END IF
CONTINUE

C***************solve GKLZ=GF using forward substitution


Z(1)=GFBC(1)/GKL(1,1)
DO 1180 I =2,NUMDOF
SUM =0.0
DO 1190 K=1,I-1
1190
SUM=SUM+GKL(I,K)*Z(K)
1180
Z(I)=(GFBC(I)-SUM)/GKL(I,I)
C***************solve GKUX=Z by backward substitution

2110
2000

XZ(NUMDOF)=Z(NUMDOF)
DO 2000 I=2,NUMDOF
L=NUMDOF-I+1
SUM=0.0
DO 2110 K=L+1,NUMDOF
SUM=SUM+GKU(L,K)*XZ(K)
XZ(L)=Z(L)-SUM

RETURN
END
C========================================================================
c A SUBROUTINE TO OBTAIN THE ERROR IN THE APPROXIMATION IN H1 NORM
C========================================================================
SUBROUTINE H1NORM(L,NP,XI1,XZ,ERROR)
C-----------------------------------------------------------------------C
L--------------ELEMENT NUMBER
C
X1,X2----END POINTS OF THE PARTICULAR ELEMENT L
C
XZ-------THE VALUES OF APPROXIMATION SOLUTION AT NODAL POINTS
C
ND1------THE NODE NUMBER OF FIRST NODE IN THE ELEMENT L
C
UNV-------THE NODAL VALUES IN THE ELEMENT L
C-------------------------------------------------------------------------

IMPLICIT REAL *8 (A-H,O-Z)


DIMENSION XZ(1001),UNV(10),PSI(4),DPSI(4)
DIMENSION XI1(1001)
COMMON/CINT/XI(10),W(10)
COMMON/INTORDER/NL
C------------------------------------------------------------------------SUM=0.0
DX=(XI1(L+1)-XI1(L))/2.0
X1=XI1(L)!LEFT END POINT OF THE ELEMENT l
X2=XI1(L+1)!RIGHT END POINT OF THE ELEMENT L
C----------NODAL NUMBERING IN PARTICULAR ELEMNT---------------ND1=(L-1)*NP
C
ND2=L*NP+1
c........NODAL VALUES IN PARTICULAR ELEMENT----------------------DO J=1,NP+1
I1=ND1+J
UNV(J)=XZ(I1)
END DO
I1=0
C--------------------------------------------------------------DO I=1,NL!LOOP OVER INTEGRATION POINTS
APP=0.0
DAPP=0.0
XX=(X1*(1.0-XI(I))+X2*(1+XI(I)))*0.5
c.......problem no 1--------------------------c
EXACT=XX**2.0
c
DEXACT=2.0*XX
c-----------------------------------------------c-------problem 2-------------------------------VA=0.5*(EXP(1.0)-EXP(-1.0))
EXACT=XX-(EXP(XX)-EXP(-XX))*0.5/VA
DEXACT=1.0-(EXP(XX)+EXP(-XX))*0.5/VA
c-------------------------------------------------CALL CSHAPE(I,NP,PSI,DPSI)
DO K=1,NP+1!FOR DEGREE OF POLY
APP=APP+UNV(K)*PSI(K)
DAPP=DAPP+UNV(K)*DPSI(K)/DX
END DO
SUM=SUM+DX*W(I)*(((DEXACT-DAPP)**2)+((EXACT-APP)**2))
END DO!FOR I
ERROR=SUM
RETURN
END
C-------------END OF SUBROUTINE ERROR------------------------------------------C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
C
END OF THE PROGRAMME
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

+
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+