Fortran Fortran (gfortran) compiling error

AI Thread Summary
The discussion revolves around troubleshooting a Fortran program that fails to compile, with the user suspecting a compiler issue. The provided code includes a main program and two subroutines for calculating stiffness matrices. Key errors identified include an uninitialized array 'K' in the 'globalstiffness' subroutine and unnecessary repetition of assignments within loops, which leads to inefficient code. Suggestions emphasize moving the matrix definitions outside the loops to avoid redundant calculations. Additionally, there is a mention of the compiler struggling to locate a program or routine named 'FEM', indicating potential linkage issues. The user is advised to address these structural problems in the code to resolve the compilation errors.
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
 
Technology 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'.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
What percentage of programmers have learned to touch type? Have you? Do you think it's important, not just for programming, but for more-than-casual computer users generally? ChatGPT didn't have much on it ("Research indicates that less than 20% of people can touch type fluently, with many relying on the hunt-and-peck method for typing ."). 'Hunt-and-peck method' made me smile. It added, "For programmers, touch typing is a valuable skill that can enhance speed, accuracy, and focus. While...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...
Back
Top