Home > Archive > Fortran > June 2005 > Something amiss
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| lone_eagle 2005-06-10, 8:57 pm |
| Hi all,
I came across a little strange situation while I was coding sometime
back. The following is the snippet of the code which I thougt was
behaving strangely.
maxvx = 10D-3; minvx = -10E-3
maxvy = 10D-3; minvy = -10E-3
maxvz = 10D-3; minvz = -10E-3
delv = 0.5D-3
vxbns = anint((maxvx - minvx) / delv)
vybns = anint((maxvy - minvy) / delv)
vzbns = anint((maxvz - minvz) / delv)
write (*, *) vxbns, vybns, vzbns
allocate (fvx(1:vxbns), fvy(1:vybns), fvz(1:vzbns), stat=ok)
if (ok /= 0) then
write (*, *) 'Allocation for velociy distrib failed'
stop
endif
write (*, *) size(fvx)
fvx(51) = 0.98
write (*,*) fvx(51)
Output (Compiled with ifort 8) and the same result with Absoft Pro 9
too.
40 40 40
40
0.980000019073486
As you can see from the code above that even though I have explicitly
alloted the array indices from 1 to vxbns (1 to 40), I could still
assign a value to fvx(51) I get no complaints. What's happening here?
Am I missing on something?
Regards,
Chaitanya.
| |
| beliavsky@aol.com 2005-06-10, 8:57 pm |
| lone_eagle wrote:
<snip>
> As you can see from the code above that even though I have explicitly
> alloted the array indices from 1 to vxbns (1 to 40), I could still
> assign a value to fvx(51) I get no complaints. What's happening here?
> Am I missing on something?
The Fortran standard does not require bounds checking by compilers, but
most compilers have options to do this. Compaq Visual Fortran (and I
assume Intel Fortran as well) has the /check:bounds option. Absoft
probably has an analogous option.
| |
| Another Jake 2005-06-11, 3:57 am |
| Yes, in Absoft V8.2 anyway. Your V9.0 is likely the same.
Set File Options ... Options Subset ... Compatibility.
Check the Array Boundaries box. (and Array Conformance?)
The -Rb and -Rc options in the command line.
Be aware that this may increase your compile time substantially.
And there still is a bug that may prevent your particular case
from compiling at all if you have a large number of array accesses
because the compiler generates a huge amount of extra code
to perform these runtime checks.
-- AJ, FD
<beliavsky@aol.com> wrote in message
news:1118434105.547208.138570@o13g2000cwo.googlegroups.com...
> lone_eagle wrote:
>
> <snip>
>
explicitly[color=darkred]
here?[color=darkred]
>
> The Fortran standard does not require bounds checking by compilers,
but
> most compilers have options to do this. Compaq Visual Fortran (and I
> assume Intel Fortran as well) has the /check:bounds option. Absoft
> probably has an analogous option.
>
|
|
|
|
|