Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fortran script only runs when print statement added

Tags:

fortran

I am running an atmospheric model, and need to compile an executable to convert some files. If I compile the code as supplied, it runs but it gets stuck and doesn't ever complete. It doesn't give an error or anything like that.

After doing some testing by adding print statements to see where it was getting stuck, I've found that the executable only runs if I compile the code with a print statement in one of the subroutines.

The piece of code in question is the one here. Specifically, the code fails to run unless I put a print statement somewhere in the get_bottom_top_dim subroutine.

Does anyone know why this might be? It doesn't matter what the print statement is (currently I'm using print*, '!'). but as soon as I remove it or comment it out, the code no longer works.

I'm assuming it must have something to do with my machine or compiler (ifort 12.1.0), but I'm stumped as to what the problem is!


1 Answers

This is an extended comment rather than an answer:

The situation you describe, inserting a print statement which apparently fixes a program, often arises when the underlying problem is due to either

a) an attempt to access an element outside the declared bounds of an array; or

b) a mismatch between dummy and actual arguments to some procedure.

Recompile your program with the compiler options to check interfaces at compile-time and to check array bounds at run-time.

like image 168
High Performance Mark Avatar answered Oct 30 '25 03:10

High Performance Mark



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!