w = sqrt(z) for the double precision complex number z
z and w are interpreted as double precision complex numbers.
it is assumed that z(1) and z(2) are the real and imaginary
parts of the complex number z, and that w(1) and w(2) are
the real and imaginary parts of w.
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.
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
subroutine dcsqrt(z,w)real(wp),intent(in)::z(2)real(wp),intent(out)::w(2)real(wp)::x,y,rx=z(1)y=z(2)if(x<0)then if(y/=0.0_wp)thenr=dcpabs(x,y)w(2)=sqrt(0.5_wp*(r-x))w(2)=sign(w(2),y)w(1)=0.5_wp*y/w(2)elsew(1)=0.0_wpw(2)=sqrt(abs(x))endif elseif(x==0.0_wp)then if(y/=0.0_wp)thenw(1)=sqrt(0.5_wp*abs(y))w(2)=sign(w(1),y)elsew(1)=0.0_wpw(2)=0.0_wpendif elseif(y/=0.0_wp)thenr=dcpabs(x,y)w(1)=sqrt(0.5_wp*(r+x))w(2)=0.5_wp*y/w(1)elsew(1)=sqrt(x)w(2)=0.0_wpendif end subroutine dcsqrt