CH-Earth / summa

Structure for Unifying Multiple Modeling Alternatives:
http://www.ral.ucar.edu/projects/summa
GNU General Public License v3.0
80 stars 104 forks source link

Allocatable variables can lead to segmentation faults with older Intel compilers #414

Open wknoben opened 4 years ago

wknoben commented 4 years ago

I initially compiled SUMMA v3.0 with ifort (IFORT) 16.0.4 2016081. Code compiles without errors, but a segmentation fault occurs during runtime:

forrtl: severe (408): fort: (8): Attempt to fetch from allocatable variable WRITECHUNK when it is not allocated

Image              PC                Routine            Line        Source
summa.exe          00000000009B5FF6  Unknown               Unknown  Unknown
summa.exe          0000000000557C1C  def_output_module         334  def_output.f90
summa.exe          0000000000553ABA  def_output_module         165  def_output.f90
summa.exe          00000000008593D3  summa_defineoutpu         125  summa_defineOutput.f90
summa.exe          00000000008D9F85  summa_writeoutput         210  summa_writeOutput.f90
summa.exe          000000000085DBE6  MAIN__                     97  summa_driver.f90
summa.exe          000000000040DDEE  Unknown               Unknown  Unknown
libc.so.6          00002B10B111F2E0  Unknown               Unknown  Unknown
summa.exe          000000000040DCEA  Unknown               Unknown  Unknown

This relates to the following code: call cloneStruc(dimensionIDs, lowerBound=1, source=(/Timestep_DimID/),err=err,message=cmessage); writechunk=(/ timeChunk /). There are multiple of such occurrences in this file alone, unsure about other files.

Solution 1: use a more recent compiler Switching to a newer compiler ifort (IFORT) 19.0.3.199 20190206 makes this problem go away, and all test cases run without problems.

Possible solution 2: update the code to use the INTERFACE command I found some documentation that seems to relate to this particular issue and contains a suggestion for how code can be reworked to avoid this, but I have not tested this: https://docs.computecanada.ca/wiki/Fortran#Segmentation_faults