gatormm
Technical User
- Jan 2, 2009
- 2
I keep running into strange bugs while working on an ongoing project written in Fortran 77. In this bug, one the index variables in a loop is staying fixed at 1.
In my main program is a three-level nested do loop. Three double precision variables, are set to the values of of i,j,k in each iteration. These represent coordinate in space which will be used to sample the output of two particular functions referenced below.
some code:
do k=1,ndim
do j=1,ndim
do i=1,ndim
ri = DBLE(i)
rj = DBLE(j)
rk = DBLE(k)
call bumpy_img_one(ri,rj,rk,f_one_int,hold)
call bumpy_img_two(ri,rj,rk,r_two_int,hold)
...
The running program hung before this loop terminated because the value of k was not changing (the integer value k remained 1 for all iterations) and the behavior is dependendent on whether or not bumpy_img_two and bumpy_img_one is commented out. Bumpy_img_one actually calls bumpy_image_two in its implementation.
I could have sworn that when I first detected this bug only bumpy_img_two was causing the bug and considering what I wrote above this struck me as very strange. I checked again while writing this post and it now appears both cause the bug. The bummpy_img proecuedures are called once before the do loop is initiated and removal of these lines also remove the bug.
In the bumpy_image_two subroutine there is a single line which when commented out turns off the bug. In this line the 3rd and final element of a double precision array g is initialized to 0. In the main program the three element double precision array hold is passed into both bumpy_image routines and used as a dummy variable since this part of the program does not need to keep the output, normally g, at this point in the program.
I've run into similar strang bugs in fortran before and I get lucky and they just seem to disappear as quickly as thay appear. In fact, the code where this bug is now occuring is more than 5 months old but the bumpy_image routines have displayed strange bugs before.
The program is being compiled with the Intel Fortran Compiler on an Ubunutu 8.10 installation. The Installation is being run from a virtual machine (Sun VirtualBox). I thought maybe there were issues with the virtual machine not having enough memory but that had no noticeable affect on this error.
How do I specifically go about solving a bug like this. Furthermore, how can I prevent them. I will appreciate any and all feedback as I feel very out of my league.
Regards to all who read the post,
Matt
In my main program is a three-level nested do loop. Three double precision variables, are set to the values of of i,j,k in each iteration. These represent coordinate in space which will be used to sample the output of two particular functions referenced below.
some code:
do k=1,ndim
do j=1,ndim
do i=1,ndim
ri = DBLE(i)
rj = DBLE(j)
rk = DBLE(k)
call bumpy_img_one(ri,rj,rk,f_one_int,hold)
call bumpy_img_two(ri,rj,rk,r_two_int,hold)
...
The running program hung before this loop terminated because the value of k was not changing (the integer value k remained 1 for all iterations) and the behavior is dependendent on whether or not bumpy_img_two and bumpy_img_one is commented out. Bumpy_img_one actually calls bumpy_image_two in its implementation.
I could have sworn that when I first detected this bug only bumpy_img_two was causing the bug and considering what I wrote above this struck me as very strange. I checked again while writing this post and it now appears both cause the bug. The bummpy_img proecuedures are called once before the do loop is initiated and removal of these lines also remove the bug.
In the bumpy_image_two subroutine there is a single line which when commented out turns off the bug. In this line the 3rd and final element of a double precision array g is initialized to 0. In the main program the three element double precision array hold is passed into both bumpy_image routines and used as a dummy variable since this part of the program does not need to keep the output, normally g, at this point in the program.
I've run into similar strang bugs in fortran before and I get lucky and they just seem to disappear as quickly as thay appear. In fact, the code where this bug is now occuring is more than 5 months old but the bumpy_image routines have displayed strange bugs before.
The program is being compiled with the Intel Fortran Compiler on an Ubunutu 8.10 installation. The Installation is being run from a virtual machine (Sun VirtualBox). I thought maybe there were issues with the virtual machine not having enough memory but that had no noticeable affect on this error.
How do I specifically go about solving a bug like this. Furthermore, how can I prevent them. I will appreciate any and all feedback as I feel very out of my league.
Regards to all who read the post,
Matt