Re: [AMBER] random number generators visible from nab: choice necessary?

From: M. L. Dodson <activesitedynamics.comcast.net>
Date: Mon, 7 Jun 2010 17:47:17 -0500

On Mon, Jun 07, 2010 at 06:10:47PM -0400, case wrote:
> On Mon, Jun 07, 2010, M. L. Dodson wrote:
> >
> > I have been investigating the random number generators available in nab
> > (for a project interfacing nab to a simulated annealing routine written
> > in Fortran) and find that the function gauss() is implemented in rand2.c
> > as
> >
> > REAL_T gauss( REAL_T *mean, REAL_T *sd ) {
> > etc.
> > }
> >
> > but it is also defined in random.f as
> >
> > !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> > !+ Default generator wrapper for gauss_gen
> > subroutine gauss(am,sd,v)
> > implicit none
> > #include "random.h"
> > _REAL_, intent (in) :: am, sd
> > _REAL_, intent (out) :: v
> > type (rand_gen_state) :: def_gen
> > common /raset1/ def_gen
> > call gauss_gen(def_gen, am, sd, v)
> > end subroutine gauss
>
> I'm pretty sure nab/sff never sees random.f. So, the gauss() routine in
> rand2.c is what would get called.
>

Hmmm... what I really wanted was to use the random.f code in place of
the Marsaglia generator included in the sa routine file. I think the
best way to proceed for this project would be the replacement of the
Marsaglia code included in the sa routine file with the random.f
wrapper for gauss(). As long as I link to the correct library
(libnab, I believe), I should be OK. As best I could tell there were
no other name clashes. I'll just edit the sa routine to call for
random numbers with the random.f (amber) routine names.

> That said, rand2.c needs a facelift: the comments are outdated, at the least,
> and the method of random number generation is not made clear. It would
> probably be good to port the algorithms in AmberTools/lib/random.f to
> ../sff/rand2.c
>
> >
> > PS, the SA routine has its own enclosed version of the Marsaglia
> > generator, but I would like to restrict the added code to the minimum
> > necessary.
>
> Given the comments above, you might want to consider using the Marsaglia
> generator, or proposing updates to rand2.c.
>

I might give some thought to porting over the random.f code (which, as
best I can tell is the standard amber random number generator, at
least the one in the AmberTools distribution is nearly identical to
one of the random.f files in amber9 which is all I had readily
available when I posted). I'll let you know if I come up with
something. I believe Marsaglia code in C is available for free (I
think I've even used it before. So many projects, so little memory
left! ;-)

> ...regards...dave
>
>

-- 
M. L. Dodson
Business Email: activesitedynamics-at-comcast-dot-net
Personal Email:	mldodson-at-comcast-dot-net
Phone:	eight_three_two-56_three-386_one
_______________________________________________
AMBER mailing list
AMBER.ambermd.org
http://lists.ambermd.org/mailman/listinfo/amber
Received on Mon Jun 07 2010 - 16:00:03 PDT
Custom Search