[Solved] Fortran Program Crashes when running


I ran your code through the NAG Fortran Compiler (on Linux). The version you have posted doesn’t compile for me:

> nagfor -mtrace=all -u -C=all -C=undefined valuefuncmat.f90
...
Error: valuefuncmat.f90, line 100: Syntax error
       detected at )@,
...

That of course is easy to rectify (i.e., change line 100 to write(*,'(20G12.4)') vOUT(i,:)).

With that done, recompiling and running reveals

> nagfor -mtrace=all -u -C=all -C=undefined valuefuncmat.f90 && ./a.out
NAG Fortran Compiler Release 6.0(Hibiya) Build 1050
Extension: valuefuncmat.f90, line 88: Line longer than 132 characters
Warning: valuefuncmat.f90, line 104: Unused local variable APOL
Questionable: valuefuncmat.f90, line 104: Variable INDEXA set but never referenced
Warning: valuefuncmat.f90, line 104: Unused local variable J
Warning: valuefuncmat.f90, line 104: Unused interface for procedure KRON
Warning: valuefuncmat.f90, line 104: Local variable ONESM is initialised but never used
Warning: valuefuncmat.f90, line 62: Unused PARAMETER A
Warning: valuefuncmat.f90, line 62: Unused PARAMETER ALPHA
[NAG Fortran Compiler normal termination, 8 warnings]
[Allocated item 1 (size 65537) = Z'2AE913113010']
[Allocated item 2 (size 65537) = Z'2AE913123030']
[Allocated item 3 (size 65537) = Z'2AE913133050']
[Allocated item 4 (size 14808) at line 88 of valuefuncmat.f90 = Z'2AE913143070']
[Allocated item 5 (size 27409608) at line 154 of valuefuncmat.f90 = Z'2AE913413010']
[Allocated item 6 (size 27409608) at line 154 of valuefuncmat.f90 = Z'2AE914E37010']
[Deallocated item 6 (size 27409608, at Z'2AE914E37010') at line 166 of valuefuncmat.f90]
[Allocated item 7 (size 27409608) at line 154 of valuefuncmat.f90 = Z'2AE914E37010']
[Allocated item 8 (size 27409608) at line 154 of valuefuncmat.f90 = Z'2AE91685B010']
[Deallocated item 8 (size 27409608, at Z'2AE91685B010') at line 166 of valuefuncmat.f90]
[Deallocated item 4 (size 14808, at Z'2AE913143070') at line 88 of valuefuncmat.f90]
[Deallocated item 5 (size 27409608, at Z'2AE913413010') at line 88 of valuefuncmat.f90]
[Deallocated item 7 (size 27409608, at Z'2AE914E37010') at line 88 of valuefuncmat.f90]
[Allocation (size 281732479017624) at line 170 of valuefuncmat.f90 failed]
Runtime Error: valuefuncmat.f90, line 170: Cannot allocate array temporary - out of memory
Program terminated by fatal error
[Deallocated item 2 (size 65537, at Z'2AE913123030')]
[Deallocated item 3 (size 65537, at Z'2AE913133050')]
[Deallocated item 1 (size 65537, at Z'2AE913113010')]
Abort (core dumped)

Let me highlight part of that memory-trace output:

[Allocation (size 281732479017624) at line 170 of valuefuncmat.f90 failed]

As roygvib noted in their comment, this appears to be the issue that you need to address.

solved Fortran Program Crashes when running