obs_conv_functions.h90 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. !!----------------------------------------------------------------------
  2. !! NEMO/OPA 3.3 , NEMO Consortium (2010)
  3. !! $Id: obs_conv_functions.h90 2287 2010-10-18 07:53:52Z smasson $
  4. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  5. !!----------------------------------------------------------------------
  6. REAL(KIND=wp) FUNCTION potemp( ps, pt, pp, ppr )
  7. !!----------------------------------------------------------------------
  8. !! *** FUNCTION potemp ***
  9. !!
  10. !! ** Purpose : Compute potential temperature
  11. !!
  12. !! ** Method : A regression formula is used.
  13. !!
  14. !! ** Action : The code is kept as close to the F77 code as possible
  15. !! Check value: potemp(35,20,2000,0) = 19.621967
  16. !!
  17. !! References : T. J. Mcdougall, D. R. Jackett, D. G. Wright
  18. !! and R. Feistel
  19. !! Accurate and computationally efficient algoritms for
  20. !! potential temperatures and density of seawater
  21. !! Journal of atmospheric and oceanic technology
  22. !! Vol 20, 2003, pp 730-741
  23. !!
  24. !!
  25. !! History :
  26. !! ! 07-05 (K. Mogensen) Original code
  27. !!----------------------------------------------------------------------
  28. !! * Arguments
  29. REAL(KIND=wp), INTENT(IN) :: ps
  30. REAL(KIND=wp), INTENT(IN) :: pt
  31. REAL(KIND=wp), INTENT(IN) :: pp
  32. REAL(KIND=wp), INTENT(IN) :: ppr
  33. !! * Local declarations
  34. REAL(KIND=wp) :: zpol
  35. REAL(KIND=wp), PARAMETER :: a1 = 1.067610e-05
  36. REAL(KIND=wp), PARAMETER :: a2 = -1.434297e-06
  37. REAL(KIND=wp), PARAMETER :: a3 = -7.566349e-09
  38. REAL(KIND=wp), PARAMETER :: a4 = -8.535585e-06
  39. REAL(KIND=wp), PARAMETER :: a5 = 3.074672e-08
  40. REAL(KIND=wp), PARAMETER :: a6 = 1.918639e-08
  41. REAL(KIND=wp), PARAMETER :: a7 = 1.788718e-10
  42. zpol = a1 + a2 * ps + a3 * ( pp + ppr ) + a4 * pt &
  43. & + a5 * ps * pt + a6 * pt * pt + a7 * pt * ( pp + ppr )
  44. potemp = pt + ( pp - ppr ) * zpol
  45. END FUNCTION potemp
  46. REAL(KIND=wp) FUNCTION fspott( pft, pfs, pfp )
  47. !!----------------------------------------------------------------------
  48. !! *** FUNCTION fspott ***
  49. !!
  50. !! ** Purpose : Compute potential temperature
  51. !!
  52. !! ** Method : A regression formula is used.
  53. !!
  54. !! ** Action : Check value: fspott(10,25,1000) = 8.4678516
  55. !!
  56. !! References : A. E. Gill
  57. !! Atmosphere-Ocean Dynamics
  58. !! Volume 30 (International Geophysics)
  59. !!
  60. !! History :
  61. !! ! 07-05 (K. Mogensen) NEMO adopting of OPAVAR code.
  62. !!----------------------------------------------------------------------
  63. !! * Arguments
  64. REAL(KIND=wp) :: pft ! in situ temperature in degrees celcius
  65. REAL(KIND=wp) :: pfs ! salinity in psu
  66. REAL(KIND=wp) :: pfp ! pressure in bars
  67. fspott = &
  68. & pft - pfp * ( ( 3.6504e-4 &
  69. & + pft * ( 8.3198e-5 &
  70. & + pft * ( -5.4065e-7 &
  71. & + pft * 4.0274e-9 ) ) ) &
  72. & + ( pfs - 35.0 ) * ( 1.7439e-5 &
  73. & - pft * 2.9778e-7 ) &
  74. & + pfp * ( 8.9309e-7 &
  75. & + pft * ( -3.1628e-8 &
  76. & + pft * 2.1987e-10 ) &
  77. & - ( pfs - 35.0 ) * 4.1057e-9 &
  78. & + pfp * ( -1.6056e-10 &
  79. & + pft * 5.0484e-12 ) ) )
  80. END FUNCTION fspott
  81. REAL(KIND=wp) FUNCTION atg( p_s, p_t, p_p )
  82. !!----------------------------------------------------------------------
  83. !! *** FUNCTION atg ***
  84. !!
  85. !! ** Purpose : Compute adiabatic temperature gradient deg c per decibar
  86. !!
  87. !! ** Method : A regression formula is used
  88. !!
  89. !! ** Action : The code is kept as close to the F77 code as possible
  90. !! Check value: atg(40,40,10000) = 3.255974e-4
  91. !!
  92. !! References : N. P. Fotonoff and R.C. Millard jr.,
  93. !! Algoritms for computation of fundamental
  94. !! properties of seawater
  95. !! Unesco technical papers in marine science 44
  96. !! Unesco 1983
  97. !!
  98. !! History :
  99. !! ! 07-05 (K. Mogensen) Original code based on the F77 code.
  100. !!----------------------------------------------------------------------
  101. !! * Arguments
  102. REAL(KIND=wp), INTENT(IN) :: p_s ! Salinity in PSU
  103. REAL(KIND=wp), INTENT(IN) :: p_t ! Temperature in centigrades
  104. REAL(KIND=wp), INTENT(IN) :: p_p ! Pressure in decibars.
  105. !! * Local declarations
  106. REAL(KIND=wp) :: z_ds
  107. z_ds = p_s - 35.0
  108. atg = ((( -2.1687e-16 * p_t + 1.8676e-14 ) * p_t - 4.6206e-13 ) * p_p &
  109. & + (( 2.7759e-12 * p_t - 1.1351e-10 ) * z_ds + (( - 5.4481e-14 * p_t &
  110. & + 8.733e-12 ) * p_t - 6.7795e-10 ) * p_t + 1.8741e-8)) * p_p &
  111. & + ( -4.2393e-8 * p_t + 1.8932e-6 ) * z_ds &
  112. & + (( 6.6228e-10 * p_t - 6.836e-8 ) * p_t + 8.5258e-6 ) * p_t + 3.5803e-5
  113. END FUNCTION atg
  114. REAL(KIND=wp) FUNCTION theta( p_s, p_t0, p_p0, p_pr )
  115. !!----------------------------------------------------------------------
  116. !! *** FUNCTION theta ***
  117. !!
  118. !! ** Purpose : Compute potential temperature
  119. !!
  120. !! ** Method : A regression formula is used.
  121. !!
  122. !! ** Action : The code is kept as close to the F77 code as possible
  123. !! Check value: theta(40,40,10000,0) = 36.89073
  124. !!
  125. !! References : N. P. Fotonoff and R.C. Millard jr.,
  126. !! Algoritms for computation of fundamental
  127. !! properties of seawater
  128. !! Unesco technical papers in marine science 44
  129. !! Unesco 1983
  130. !!
  131. !! History :
  132. !! ! 07-05 (K. Mogensen) Original code based on the F77 code.
  133. !!----------------------------------------------------------------------
  134. !! * Arguments
  135. REAL(KIND=wp), INTENT(IN) :: p_s
  136. REAL(KIND=wp), INTENT(IN) :: p_t0
  137. REAL(KIND=wp), INTENT(IN) :: p_p0
  138. REAL(KIND=wp), INTENT(IN) :: p_pr
  139. !! * Local declarations
  140. REAL(KIND=wp) :: z_p
  141. REAL(KIND=wp) :: z_t
  142. REAL(KIND=wp) :: z_h
  143. REAL(KIND=wp) :: z_xk
  144. REAL(KIND=wp) :: z_q
  145. z_p = p_p0
  146. z_t = p_t0
  147. z_h = p_pr - z_p
  148. z_xk = z_h * atg( p_s, z_t, z_p )
  149. Z_t = z_t + 0.5 * z_xk
  150. z_q = z_xk
  151. z_p = z_p + 0.5 * z_h
  152. z_xk = z_h * atg( p_s, z_t, z_p )
  153. z_t = z_t + 0.29289322 * ( z_xk - z_q )
  154. z_q = 0.58578644 * z_xk + 0.121320344 * z_q
  155. z_xk = z_h * atg( p_s, z_t, z_p )
  156. z_t = z_t + 1.707106781 * ( z_xk - z_q )
  157. z_q = 3.414213562 * z_xk - 4.121320244 * z_q
  158. z_p = z_p + 0.5 * z_h
  159. z_xk = z_h * atg( p_s, z_t, z_p )
  160. theta = z_t + ( z_xk - 2.0 * z_q ) / 6.0
  161. END FUNCTION theta
  162. REAL(KIND=wp) FUNCTION depth( p_p, p_lat )
  163. !!----------------------------------------------------------------------
  164. !! *** FUNCTION depth ***
  165. !!
  166. !! ** Purpose : Compute depth from pressure and latitudes
  167. !!
  168. !! ** Method : A regression formula is used.
  169. !!
  170. !! ** Action : The code is kept as close to the F77 code as possible
  171. !! Check value: depth(10000,30) = 9712.653
  172. !!
  173. !! References : N. P. Fotonoff and R.C. Millard jr.,
  174. !! Algoritms for computation of fundamental
  175. !! properties of seawater
  176. !! Unesco technical papers in marine science 44
  177. !! Unesco 1983
  178. !!
  179. !! History :
  180. !! ! 07-05 (K. Mogensen) Original code based on the F77 code.
  181. !!----------------------------------------------------------------------
  182. !! * Arguments
  183. REAL(KIND=wp), INTENT(IN) :: p_p ! Pressure in decibars
  184. REAL(KIND=wp), INTENT(IN) :: p_lat ! Latitude in degrees
  185. !! * Local declarations
  186. REAL(KIND=wp) :: z_x
  187. REAL(KIND=wp) :: z_gr
  188. z_x = SIN( p_lat / 57.29578 )
  189. z_x = z_x * z_x
  190. z_gr = 9.780318 * ( 1.0 + ( 5.2788e-3 + 2.36e-5 * z_x ) * z_x ) + 1.092e-6 * p_p
  191. depth = ((( -1.82e-15 * p_p + 2.279e-10 ) * p_p - 2.2512e-5 ) * p_p + 9.72659 ) * p_p
  192. depth = depth / z_gr
  193. END FUNCTION depth
  194. REAL(KIND=wp) FUNCTION p_to_dep( p_p, p_lat )
  195. !!----------------------------------------------------------------------
  196. !! *** FUNCTION p_to_dep ***
  197. !!
  198. !! ** Purpose : Compute depth from pressure and latitudes
  199. !!
  200. !! ** Method : A regression formula is used. This version is less
  201. !! accurate the "depth" but invertible.
  202. !!
  203. !! ** Action :
  204. !!
  205. !! References : P.M Saunders
  206. !! Pratical conversion of pressure to depth
  207. !! Journal of physical oceanography Vol 11, 1981, pp 573-574
  208. !!
  209. !! History :
  210. !! ! 07-05 (K. Mogensen) Original code
  211. !!----------------------------------------------------------------------
  212. !! * Arguments
  213. REAL(KIND=wp), INTENT(IN) :: p_p ! Pressure in decibars
  214. REAL(KIND=wp), INTENT(IN) :: p_lat ! Latitude in degrees
  215. !! * Local declarations
  216. REAL(KIND=wp) :: z_x
  217. REAL(KIND=wp) :: z_c1
  218. REAL(KIND=wp) :: z_c2
  219. z_x = SIN( p_lat / 57.29578 )
  220. z_x = z_x * z_x
  221. z_c1 = ( 5.92 + 5.25 * z_x ) * 1e-3
  222. z_c2 = 2.21e-6
  223. p_to_dep = (1 - z_c1) * p_p - z_c2 * p_p * p_p
  224. END FUNCTION p_to_dep
  225. REAL(KIND=wp) FUNCTION dep_to_p( p_dep, p_lat )
  226. !!----------------------------------------------------------------------
  227. !! *** FUNCTION dep_to_p ***
  228. !!
  229. !! ** Purpose : Compute depth from pressure and latitudes
  230. !!
  231. !! ** Method : The expression used in p_to_dep is inverted.
  232. !!
  233. !! ** Action :
  234. !!
  235. !! References : P.M Saunders
  236. !! Pratical conversion of pressure to depth
  237. !! Journal of physical oceanography Vol 11, 1981, pp 573-574
  238. !!
  239. !! History :
  240. !! ! 07-05 (K. Mogensen) Original code
  241. !!----------------------------------------------------------------------
  242. !! * Arguments
  243. REAL(KIND=wp), INTENT(IN) :: p_dep ! Depth in meters
  244. REAL(KIND=wp), INTENT(IN) :: p_lat ! Latitude in degrees
  245. !! * Local declarations
  246. REAL(KIND=wp) :: z_x
  247. REAL(KIND=wp) :: z_c1
  248. REAL(KIND=wp) :: z_c2
  249. REAL(KIND=wp) :: z_d
  250. z_x = SIN( p_lat / 57.29578 )
  251. z_x = z_x * z_x
  252. z_c1 = ( 5.92 + 5.25 * z_x ) * 1e-3
  253. z_c2 = 2.21e-6
  254. z_d = ( z_c1 - 1 ) * ( z_c1 - 1 ) - 4 * z_c2 * p_dep
  255. dep_to_p = (( 1 - z_c1 ) - SQRT( z_d )) / ( 2 * z_c2 )
  256. END FUNCTION dep_to_p