RE: amber-developers: Compile AMBER9 on SGI

From: Ross Walker <ross.rosswalker.co.uk>
Date: Tue, 8 Nov 2005 18:43:54 -0700

> I am pretty reluctant to require a Fortran 2003-compliant compiler for
> Amber 9. Is there any easy way to not have to use
> allocatable arrays inside
> user-defined types?

I think this can be done with pointers instead of 'traditional'
allocatable
arrays. E.g.

type chang_miller_type
  _REAL_, allocatable :: q( :)
  _REAL_, allocatable :: d( :)
  _REAL_, allocatable :: k(:,:)
.
.
.
end type

becomes:

type chang_miller_type
  _REAL_, pointer :: q( :)
  _REAL_, pointer :: d( :)
  _REAL_, pointer :: k(:,:)
.
.
.
end type

This 'should' be completely compatible and, assuming they don't use:

if(allocated(blah))

then no other changes are necessary. If they do use the allocated() call
then you need to go through and set every pointer initially to null and
then
instead of if (allocated()) just check if the pointer is still null.

Pointers are also much more versatile since you can use the pointer
assignment command to flip arrays rather than doing a copy. E.g.

Instead of
do
 ! fill p with data based on pold and new stuff...
 ...
 ! copy p into pold to use as the starting point for next time...
 pold(1:natom) = p(1:natom)
end do

Or similar pseudo code... You can do

_REAL_, dimension(:), pointer :: temp_ptr
do
 ! fill p with data based on pold and new stuff...
 ...
 ! copy p into pold to use as the starting point for next time...
 !Store the pointer to p
 temp_ptr => p
 p => pold
 pold => temp_ptr
end do

This allows you to flip flop back and forth between the two arrays without
actually doing an array copy.

Any volunteers for going through all the evb code???

All the best
Ross

/\
\/
|\oss Walker

| Department of Molecular Biology TPC15 |
| The Scripps Research Institute |
| Tel: +1 858 784 8889 | EMail:- ross.rosswalker.co.uk |
| http://www.rosswalker.co.uk | PGP Key available on request |

Note: Electronic Mail is not secure, has no guarantee of delivery, may not
be read every day, and should not be used for urgent or sensitive issues.
Received on Wed Apr 05 2006 - 23:49:51 PDT
Custom Search