Fortran (gfortran) compiling error

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 3K views
zerne
Messages
1
Reaction score
0
Hello, I need help for programming my first program in Fortran, because it doesn't run. I think it's a problem with the compiler. What do you think?

This is my code
Code:
program Steifigkeitsmatrix
    implicit none
        real :: E,I,l,p                                      
        real, dimension(4,4) :: Ke                           
        real, dimension(4,4) :: KeI                          
        real, dimension(4,4) :: KeII                         
        real, dimension(4,4) :: KeIII                        
        real, dimension(8,8) :: K                            

        real :: u,v,w
                u = 2
                v = 3
                w = 4
            read(*,*)   E                                    
            write(*,*)  'E=', E                              
            read(*,*)   I                                    
            write(*,*)  'I=', I                              
            read(*,*)   l                                    
            write(*,*)  'l=', l                              


        p = (E*I)/((l**3)/3)                                 
                                                             
                                                             

        call stiffness(l,p,Ke)                               

        write(*,*) Ke                                        

        KeI   = u*Ke
        KeII  = v* Ke
        KeIII = w*Ke
        write(*,*) KeI

        call globalstiffness(KeI,KeII,KeIII,K)
        write(*,*) K
 end program Steifigkeitsmatrix


        subroutine stiffness(z,q,k)                          

                real, intent(in) :: z,q                      
                real, dimension(4,4), intent(out) :: k       
                integer :: i,j                               

                  do i=1,4
                                    do j=1,4

                                            k(1,1)= 12*q
                                            k(1,2)= 6*(z/3)*q
                                            k(1,3)= -12*q
                                            k(1,4)= 6*(z/3)*q
                                            k(2,1)= 6*(z/3)*q
                                            k(2,2)= 4*q*(z/3)**2
                                            k(2,3)= -6*(z/3)*q
                                            k(2,4)= 2*q*(z/3)**2
                                            k(3,1)= -12*q
                                            k(3,2)= -6*(z/3)*q
                                            k(3,3)= 12*q
                                            k(3,4)= -6*(z/3)*q
                                            k(4,1)= 6*(z/3)*q
                                            k(4,2)= 2*q*(z/3)**2
                                            k(4,3)= -6*q*(z/3)
                                            k(4,4)= 4*q*(z/3)**2
                                            write(*,*) 'Zeile:',i,'   Spalte: ', j,'   Wert: ',  k(i,j)
                                    end do
                  end  do

                 return

        end subroutine stiffness

        subroutine globalstiffness(x,y,z,r)

                    real, dimension(4,4), intent(in) :: x,y,z
                    real, dimension(8,8), intent(out) :: r
                    integer :: i,j

                        do i=1,3
                                    do j=1,8
                                            K(1,1)= x(1,1)
                                            K(1,2)= x(1,2)
                                            K(1,3)= x(1,3)
                                            K(1,4)= x(1,4)
                                            K(1,5)= 0
                                            K(1,6)= 0
                                            K(1,7)= 0
                                            K(1,8)= 0
                                            K(2,1)= x(2,1)
                                            K(2,2)= x(2,2)
                                            K(2,3)= x(2,3)
                                            K(2,4)= x(2,4)
                                            K(2,5)= 0
                                            K(2,6)= 0
                                            K(2,7)= 0
                                            K(2,8)= 0
                                            K(3,1)= x(3,1)
                                            K(3,2)= x(3,2)
                                            K(3,3)= x(3,3) + y(1,1)
                                            K(3,4)= x(3,4) + y(1,2)
                                            K(3,5)= y(1,3)
                                            K(3,6)= y(1,4)
                                            K(3,7)= 0
                                            K(3,8)= 0
                                            K(4,1)= x(4,1)
                                            K(4,2)= x(4,2)
                                            K(4,3)= x(4,3) + y(2,1)
                                            K(4,4)= x(4,4) + y(2,2)
                                            K(4,5)= y(2,3)
                                            K(4,6)= y(2,4)
                                            K(4,7)= 0
                                            K(4,8)= 0
                                            K(5,1)= 0
                                            K(5,2)= 0
                                            K(5,3)= y(3,1)
                                            K(5,4)= y(3,2)
                                            K(5,5)= y(3,3) + z(1,1)
                                            K(5,6)= y(3,4) + z(1,2)
                                            K(5,7)= 0
                                            K(5,8)= 0
                                            K(6,1)= 0
                                            K(6,2)= 0
                                            K(6,3)= y(4,1)
                                            K(6,4)= y(4,2)
                                            K(6,5)= y(4,3) + z(2,1)
                                            K(6,6)= y(4,4) + z(2,2)
                                            K(6,7)= z(2,3)
                                            K(6,8)= z(2,4)
                                            K(7,1)= 0
                                            K(7,2)= 0
                                            K(7,3)= 0
                                            K(7,4)= 0
                                            K(7,5)= z(3,1)
                                            K(7,6)= z(3,2)
                                            K(7,7)= z(3,3)
                                            K(7,8)= z(3,4)
                                            K(8,1)= 0
                                            K(8,2)= 0
                                            K(8,3)= 0
                                            K(8,4)= 0
                                            K(8,5)= z(4,1)
                                            K(8,6)= z(4,2)
                                            K(8,7)= z(4,3)
                                            K(8,8)= z(4,4)
                                        end do
                        end do
                        return

        end subroutine globalstiffness



Output
Code:
Description	Resource	Path	Location	Type
../Steifigkeitsmatrix.f90:105.44: Fatal Error: Error count reached limit of 25.	Steifigkeitsmatrix.f90	/FEM	line 105	C/C++ Problem
Description	Resource	Path	Location	Type
make: *** [Steifigkeitsmatrix.o] Error 1	FEM		 	C/C++ Problem
Description	Resource	Path	Location	Type
recipe for target `Steifigkeitsmatrix.o' failed	subdir.mk	/FEM/Debug	line 15	C/C++ Problem
Description	Resource	Path	Location	Type
Unclassifiable statement at (1)	FEM		 	C/C++ Problem


Thanks for help
 
Physics news on Phys.org
In subroutine 'globalstiffness', the array 'K' is not dimensioned. Also, why are the definitions for the entries in 'K' contained within the loops? All you are doing is redefining 'K' 24 times. The definitions of 'K' can be placed outside the loops, which apparently are used only to print the various entries in 'K'. This curiosity also occurs in subroutine 'stiffness' for matrix 'k', which is properly dimensioned.

It seems the compiler/linker is having trouble finding a program/routine called 'FEM'.