34 real (r8), 
intent(in) :: rho, sa, p
    35 real (r8), 
intent(out) :: ct
    36 real (r8), 
intent(out), 
optional :: ct_multiple
    38 integer :: number_of_iterations
    39 real (r8) :: a, alpha_freezing, alpha_mean, b, c, ct_a, ct_b, ct_diff
    40 real (r8) :: ct_freezing, ct_max_rho, ct_mean, ct_old
    41 real (r8) :: delta_ct, delta_v, factor, factorqa, factorqb
    42 real (r8) :: rho_40, rho_extreme, rho_freezing, rho_max, rho_mean
    43 real (r8) :: rho_old, sqrt_disc, top, v_ct, v_lab
    45 character (*), 
parameter :: func_name = 
"gsw_ct_from_rho"    50 real (r8), 
parameter :: alpha_limit = 1e-5_r8
    55 real (r8), 
parameter :: rec_half_rho_tt = -110.0_r8
    58 if (rho .lt. rho_40) 
then    60     if (
present(ct_multiple)) ct_multiple = ct
    65 rho_max = 
gsw_rho(sa,ct_max_rho,p)
    74 if (ct_freezing .gt. ct_max_rho) rho_extreme = rho_freezing
    76 if (rho .gt. rho_extreme) 
then    78     if (
present(ct_multiple)) ct_multiple = ct
    82 if (alpha_freezing .gt. alpha_limit) 
then    84     ct_diff = 40.0_r8 - ct_freezing
    85     top = rho_40 - rho_freezing + rho_freezing*alpha_freezing*ct_diff
    86     a = top/(ct_diff*ct_diff)
    87     b = -rho_freezing*alpha_freezing
    88     c = rho_freezing - rho
    89     sqrt_disc = sqrt(b*b - 4*a*c)
    90     ct = ct_freezing + 0.5_r8*(-b - sqrt_disc)/a
    94     ct_diff = 40.0_r8 - ct_max_rho
    95     factor = (rho_max - rho)/(rho_max - rho_40)
    96     delta_ct = ct_diff*sqrt(factor)
    98     if (delta_ct .gt. 5.0_r8) 
then   100         ct = ct_max_rho + delta_ct
   105         ct_a = ct_max_rho + sqrt(rec_half_rho_tt*(rho - rho_max))       
   106         do number_of_iterations = 1, 7
   109             factorqa = (rho_max - rho)/(rho_max - rho_old)
   110             ct_a = ct_max_rho + (ct_old - ct_max_rho)*sqrt(factorqa)
   113         if (ct_freezing - ct_a .lt. 0.0_r8) 
then   115             if (
present(ct_multiple)) ct_multiple = ct
   120         if (.not. 
present(ct_multiple)) 
return   123         ct_b = ct_max_rho - sqrt(rec_half_rho_tt*(rho - rho_max))    
   124         do number_of_iterations = 1, 7
   127             factorqb = (rho_max - rho)/(rho_max - rho_old)
   128             ct_b = ct_max_rho + (ct_old - ct_max_rho)*sqrt(factorqb)
   134         if (ct_freezing - ct_b .lt. 0.0_r8) 
then   136             if (
present(ct_multiple)) ct_multiple = ct
   151 v_ct = alpha_mean/rho_mean
   153 do number_of_iterations = 1, 3
   156     ct = ct_old - delta_v/v_ct
   157     ct_mean = 0.5_r8*(ct + ct_old)
   159     v_ct = alpha_mean/rho_mean
   160     ct = ct_old - delta_v/v_ct 
   166 if (
present(ct_multiple)) ct_multiple = 
gsw_error_code(5,func_name)
 
real(r8), parameter, public gsw_error_limit
elemental subroutine gsw_ct_from_rho(rho, sa, p, ct, ct_multiple)
elemental real(r8) function, public gsw_error_code(err_num, func_name, error_code)