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:
 | Change all "funk" occurrences to "func" |
 | Change all "iter" occurrences to "iteram". (this prevents conflicts with
other parts of cloudy) |
 | Place the following statements after the "subroutine amoeba" statement:
include "itoptm.com"
include "limext.par"
include "limpar.par"
include "vparm.com"
include "qq.com"
|
 | After the following statement:
rtol=2.*abs(y(ihi)-y(ilo))/(abs(y(ihi))+abs(y(ilo)))
Insert:
rtol2 = min(y(ihi),y(ilo))
|
 | Replace:
if (rtol.lt.ftol) then
with:
if ( (iteram.gt.1.and.rtol.lt.0.001) .or. rtol2.lt.ftol) then
|
 | The 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. |
 | Replace 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. |
 | After 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) |
 | For the function AMOTRY |
 | Change all "funk" occurrences to "func". |
 | After the function AMOTRY statement place the following:
include "limext.par"
include "limpar.par"
include "vparm.com" |