0

I am trying to learn fortran. I wanted to replicate a certain step in a paper but I ran into trouble.

I compiled the file AERsimulation.f95 (I turned on all debugging functions in gfortran I am aware of) I could generate an .out file without any errors (a lot of warnings, however...)

When I tried to run the .out file I got the error message

Fortran runtime error: Index '0' of dimension 1 of array 'k' below lower bound of 1

Now, it is quite difficult for me to understand why exactly this happens. I guess, my question is, whether there is a better way of debugging, so that I can see and click through the code 'live' and see why the error occurs. (I am thinking of the matlab-debugger for instance...)

Any suggestion/hint is very welcome

The files I use are

AERsimulation.f95

AERDATANB.TXT

Thank you very much Best Derrick

2
  • 3
    Normally, gfortran also prints the line number, where the error happens. You can use some good text editor to point you there in the source code (I use kate, but mostly I go to the right place manually anyway). Be sure to use gfortran -g -fbacktrace -fcheck=all -Wall. Commented Nov 18, 2014 at 14:49
  • 3
    BTW, do not use .f95, use just .f90 for any free-form source. I suppose you do not want rename your file once you add a feature from f03 or f08. Commented Nov 18, 2014 at 14:50

1 Answer 1

2

The meaning of your error message is that you try to access an array element at the position 0 of the array. Arrays in Fortran start at 1 by default.

If you are looking for a better way to debug, try gdb (command line) or if you prefer a graphical interface you can try the Netbeans IDE. It has (limited) support for Fortran an a debugging mode where you can click line by line through the code and see the values of all variables and so on.

On command line try:

gdb name_of_executable
run

the debugger will stop at the line which causes the error.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.