FV3 Bundle
gsw_sp_from_sa.f90
Go to the documentation of this file.
1 !==========================================================================
2 elemental function gsw_sp_from_sa (sa, p, long, lat)
3 !==========================================================================
4 !
5 ! Calculates Practical salinity, sp, from Absolute salinity, sa
6 !
7 ! sa : Absolute Salinity [g/kg]
8 ! p : sea pressure [dbar]
9 ! long : longitude [DEG E]
10 ! lat : latitude [DEG N]
11 !
12 ! gsw_sp_from_sa : Practical Salinity [unitless]
13 !--------------------------------------------------------------------------
14 
16 
18 
20 
21 use gsw_mod_kinds
22 
23 implicit none
24 
25 real (r8), intent(in) :: sa, p, long, lat
26 
27 real (r8) :: gsw_sp_from_sa
28 
29 real (r8) :: saar, sp_baltic
30 
31 character (*), parameter :: func_name = "gsw_sp_from_sa"
32 
33 sp_baltic = gsw_sp_from_sa_baltic(sa,long,lat)
34 
35 if (sp_baltic .lt. 1e10_r8) then
36 
37  gsw_sp_from_sa = sp_baltic
38 
39 else
40 
41  saar = gsw_saar(p,long,lat)
42  if (saar .gt. gsw_error_limit) then
43  gsw_sp_from_sa = gsw_error_code(1,func_name,saar)
44  else
45  gsw_sp_from_sa = (sa/gsw_ups)/(1.0_r8 + saar)
46  end if
47 
48 end if
49 
50 return
51 end function
52 
53 !--------------------------------------------------------------------------
integer, parameter, public long
Definition: Type_Kinds.f90:76
real(r8), parameter, public gsw_error_limit
elemental real(r8) function gsw_sp_from_sa(sa, p, long, lat)
elemental real(r8) function, public gsw_error_code(err_num, func_name, error_code)