older/c90_nr.htm
Home Up C94.00 Other versions Revision history The future etcetera Acknowledgements Contacts, Mailing list Links Site map, search

 

Home
Up

 

Numerical Recipes Software in Cloudy

Redistribution of Numerical Recipes Software

Cloudy can be used in an optimization mode in which several input parameters are varied to obtain a best fit to observed lines or column densities. This requires the Amoeba subroutine from Numerical Recipes. Numerical Recipes Software do not permit their codes to be freely redistributed over the internet, so the required subroutine is empty in the version of Cloudy in this account. (Versions 90 and later of Cloudy include a far superior public domain optimizer, but also can call the NR routine.)

Modifying your licensed copy of the NR software

You must obtain your own licensed copy of Amoeba and make a few changes. The following (written by Jason Ferguson) describes how to do this. In the following common blocks which are part of the Cloudy distribution are indicated by INCLUDE statements. Where these occur you should replace the INCLUDE with the Cloudy common block of the same name. That is, the line
include "qq.com"
should be replaced with the pair of lines
integer qq
common/qq/ qq

For the routine AMOEBA:

bulletChange all "funk" occurrences to "func"
bulletChange all "iter" occurrences to "iteram". (this prevents conflicts with other parts of cloudy)
bulletPlace the following statements after the "subroutine amoeba" statement:
include "itoptm.com"
include "limext.par"
include "limpar.par"
include "vparm.com"
include "qq.com"
bulletAfter the following statement:
rtol=2.*abs(y(ihi)-y(ilo))/(abs(y(ihi))+abs(y(ilo)))
Insert:
rtol2 = min(y(ihi),y(ilo))
bulletReplace:
if (rtol.lt.ftol) then
with:
if ( (iteram.gt.1.and.rtol.lt.0.001) .or. rtol2.lt.ftol) then
bulletThe previous two change the stopping criteria that amoeba uses. Rather than have the routine stop after the function value changes by a small tolerance (ftol) we want the function itself to be below that value. This change avoids unnecessary calls to cloudy.
bulletReplace the following:
if (iteram.ge.ITMAX) pause 'ITMAX exceeded in amoeba'
with:
if(iteram.ge.ITOPTM) then
write(QQ, '('' Optimizer exceeding maximum iterations.''/
$ '' This can be reset with the OPTIMZE ITERATIONS command.'')')
return
endif
This uses "cloudy language" in stopping the routine after too many calls to cloudy.
bulletAfter the following statement:
psum(j)=0.5*(p(i,j)+p(ilo,j))
Insert:
VPARM(j,1) = psum(j)
(this statement tells cloudy the new set of parameters)
bulletFor the function AMOTRY
bulletChange all "funk" occurrences to "func".
bulletAfter the function AMOTRY statement place the following:
include "limext.par"
include "limpar.par"
include "vparm.com"


Return to the Cloudy Home Page.
Copyright 1978-2003 Gary J. Ferland