Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed
arrows point from an interface to procedures which implement that interface.
This could include the module procedures in a generic interface or the
implementation in a submodule of an interface in a parent module.
Source Code
recursive function gammarnd(shape,scale)result(ans)real(8)::shape,scale,u,w,d,c,x,xsq,g,v,ansif(shape<=0d0)then write(*,*)"GAMMARND: Shape parameter must be positive"end if if(scale<=0d0)then write(*,*)"GAMMARND: Scale parameter must be positive"end if! ## Implementation based on "A Simple Method for Generating Gamma Variables"! ## by George Marsaglia and Wai Wan Tsang. ! ## ACM Transactions on Mathematical Software! ## Vol 26, No 3, September 2000, pages 363-372.if(shape>=1d0)thend=shape-1d0/3d0c=1d0/(9d0*d)**0.5d0do while(.true.)x=normalrnd(0d0,1d0)v=1.d0+c*xdo while(v<=0d0)x=normalrnd(0d0,1d0)v=1d0+c*xend dov=v*v*vu=mersenne()xsq=x*xif((u<1d0-.0331d0*xsq*xsq).or.(log(u)<0.5d0*xsq+d*(1d0-v+log(v))))thenans=scale*d*vreturn end if end do elseg=gammarnd(shape+1d0,1d0)w=mersenne()ans=scale*g*(w)**(1d0/shape)return end ifend function gammarnd