- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear All,
Why is it that if I declare an array and then reference outside the bounds of the array, no error comes up?
e.g. If I do
real example(100,100)
example(400,400)=1.5
My compiler seems to think that this is ok? I can then use the value stored in example (400,400) in further calculations.
I just don't understand why my compiler doesn't flag this up?? Is there a way to make it flag it up?
I'm using Intel fortran compiler on a linux server.
Cheers.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try adding: -check bounds
[cpp]program sample real example(100,100) example(400,400)=1.5 end[/cpp]
$ ifort -V -check bounds example.f90
Intel Fortran Compiler for applications running on IA-32, Version 10.1 Build 20080801 Package ID: l_fc_p_10.1.018
Copyright (C) 1985-2008 Intel Corporation. All rights reserved.
Intel Fortran 10.1-2051
fortcom: Error: example.f90, line 3: Subscript #2 of the array EXAMPLE has value 400 which is greater than the upper bound of 100
example(400,400)=1.5
^
fortcom: Error: example.f90, line 3: Subscript #1 of the array EXAMPLE has value 400 which is greater than the upper bound of 100
example(400,400)=1.5
^
compilation aborted for example.f90 (code 1)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Cheers, and sorry for the newbie question!
Try adding: -check bounds
[cpp]program sample
real example(100,100)
example(400,400)=1.5
end[/cpp]
$ ifort -V -check bounds example.f90
Intel Fortran Compiler for applications running on IA-32, Version 10.1 Build 20080801 Package ID: l_fc_p_10.1.018
Copyright (C) 1985-2008 Intel Corporation. All rights reserved.
Intel Fortran 10.1-2051
fortcom: Error: example.f90, line 3: Subscript #2 of the array EXAMPLE has value 400 which is greater than the upper bound of 100
example(400,400)=1.5
^
fortcom: Error: example.f90, line 3: Subscript #1 of the array EXAMPLE has value 400 which is greater than the upper bound of 100
example(400,400)=1.5
^
compilation aborted for example.f90 (code 1)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No apology is necessary. We welcome all questions.
Also, Welcome to the Intel Software Network User Forums!

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page