Rate This Document
Findability
Accuracy
Completeness
Readability

Fortran Process Ends Unexpectedly

Fault Locating

The program is running properly, but the output is different from the expected result. Figure 1 shows how to locate and rectify the fault.

Figure 1 Fault locating for the abnormal end of a Fortran process
  1. Confirm that the Fortran process ends unexpectedly.
  2. Modify the compilation script or enable the debugging macro to recompile a program that can be debugged.
  3. Enable the core dump function so that a core dump file can be generated when an exception occurs.
  4. Run the program. When the program stops unexpectedly, confirm that a core dump file is generated in the specified path.
  5. Use GDB to debug the core dump file and locate the cause.
  6. Modify the code. Compile the code again to verify the modification.
  7. If the problem is resolved, integrate the modification into the code.
  8. If the problem persists, run the program again and generate a core dump file for fault locating.

    If there is no location information, add the location information to the code, and recompile and run the code.

Case: Unexpected Program Stop Caused by Wild Pointers

Symptom

A Fortran program ends unexpectedly.

Fault Locating

  1. Run the top command to confirm the program exits.
  2. Compile a program version that can be debugged, enable core dump, and then run the new program again.
  3. Use GDB to debug the core dump file and locate the code where the exception occurs.

  4. The core dump file records the memory address qtt accessed by grb2_inq. Normally, grb2_inq reads the grb2 file memory based on input parameters. If the operation is successful, the memory address qtt is returned. It is possible that the read of grb2_inq fails, which makes qtt is a wild pointer.
  5. The GDB debugging information shows that the memory address of qtt in is not allocated. As a result, the access fails and a core dump occurs. (Note: In the C language, NULL is returned when the memory application fails. For the Fortran interface, a wild pointer is returned. Therefore, a core dump may or may not occur the next time the program accesses the memory.)