[AMBER-Developers] Bounds checking warning from gfortran with (-g3 -O0 -fbounds-check -Wuninitialized ) in dhfr_cmap_pbc test case

From: Mark Williamson <mjw.sdsc.edu>
Date: Wed, 11 Nov 2009 15:45:05 -0800

>
> Hi Ross,
>>
>> Just to be clear this is a very different issue than being able to use
>> AmberTools 1.2. In v1.2 divcon is used for the charge calculations in
>> Antechamber. In v1.3 it uses sqm so the code paths are completely
>> different.
> ... I did not know this. Sorry I've raised a false alarm. The many
> instances where valgrind complains about test-runs might have made me a
> bit paranoid.
> (And these valgrind warnings and the (putative) bugs behind them seem to
> date back quite some time - so I thought this might have been a dormant
> bug).
>
> Anyway, I've seen something similar in
> $AMBERHOME/test/chamber/dhfr_cmap_pbc
> where the chamber exits with
> At line 317 of file _molnt.f
> Fortran runtime error: Array reference out of bounds for array
> 'atom_to_molecule_map', lower bound of dimension 1 exceeded (0 < 1)
>
> when all runtime checks (I'm aware of) are turned on.
> ...might be another false alarm but it seems better to err on the side of
> caution.
>
> best,
> Andreas
>


Hi Andreas,

Explanation
============

Bounds checking warning from gfortran with (-g3 -O0 -fbounds-check
-Wuninitialized ) in dhfr_cmap_pbc test case.

  EXTented file format is being used
  At line 317 of file _molnt.f
  Fortran runtime error: Array reference out of bounds for array
'atom_to_molecule_map', lower bound of dimension 1 exceeded (0 < 1)


This was being trigger in the situation when current_bonded_atom = 0 in
molnt.f:tag_atoms_in_same_molecule()

    !Ensure that a) there actually is a bonded atom here
    ! b) has not already been tagged as being part of a molecule
    if( ( current_bonded_atom .ne. 0 ) .and. &
        ( atom_to_molecule_map(current_bonded_atom ) .eq. 0 ) ) then


Here, the second evaluation within the if statement would be an issue
since the array atom_to_molecule_map has been assigned
atom_to_molecule_map(1:natom). Attempting to access position 0;
atom_to_molecule_map(0), will cause problems. A solution is to prevent
such an evaluation by introducing another if clause:


    !Ensure that a) there actually is a bonded atom here
    ! b) has not already been tagged as being part of a molecule
    if( current_bonded_atom .ne. 0 ) then
      if( atom_to_molecule_map(current_bonded_atom ) .eq. 0 ) then


I've put this fix into CVS and thank you again for flagging this one up.

regards,

Mark




_______________________________________________
AMBER-Developers mailing list
AMBER-Developers.ambermd.org
http://lists.ambermd.org/mailman/listinfo/amber-developers
Received on Wed Nov 11 2009 - 16:00:02 PST
Custom Search