As before with your FORTRAN problems, you should preferably post all statements related to the problem. The ALLOCATABLE statements does nothing with respective ALLOCATE, and the segment fault probably occurs when you are using a memory range that wasn't properly allocated.
What I wonder is this: As you are apparently not very familiar with advanced FORTRAN features, won't it be better to restrict your coding to more basic FORTRAN constructs? Doesn't your PC have sufficient memory space to define the variable arrays statically? Focus on the actual calculation problem instead of practicing new FORTRAN language elements?
The idea of the code is to be applicable to any file with the same structure, knowing that the size of the matrices is not fixed. Any further suggestions are very welcome!
Thank you!