eosbn2.F90 74 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679
  1. MODULE eosbn2
  2. !!==============================================================================
  3. !! *** MODULE eosbn2 ***
  4. !! Ocean diagnostic variable : equation of state - in situ and potential density
  5. !! - Brunt-Vaisala frequency
  6. !!==============================================================================
  7. !! History : OPA ! 1989-03 (O. Marti) Original code
  8. !! 6.0 ! 1994-07 (G. Madec, M. Imbard) add bn2
  9. !! 6.0 ! 1994-08 (G. Madec) Add Jackett & McDougall eos
  10. !! 7.0 ! 1996-01 (G. Madec) statement function for e3
  11. !! 8.1 ! 1997-07 (G. Madec) density instead of volumic mass
  12. !! - ! 1999-02 (G. Madec, N. Grima) semi-implicit pressure gradient
  13. !! 8.2 ! 2001-09 (M. Ben Jelloul) bugfix on linear eos
  14. !! NEMO 1.0 ! 2002-10 (G. Madec) add eos_init
  15. !! - ! 2002-11 (G. Madec, A. Bozec) partial step, eos_insitu_2d
  16. !! - ! 2003-08 (G. Madec) F90, free form
  17. !! 3.0 ! 2006-08 (G. Madec) add tfreez function (now eos_fzp function)
  18. !! 3.3 ! 2010-05 (C. Ethe, G. Madec) merge TRC-TRA
  19. !! - ! 2010-10 (G. Nurser, G. Madec) add alpha/beta used in ldfslp
  20. !! 3.7 ! 2012-03 (F. Roquet, G. Madec) add primitive of alpha and beta used in PE computation
  21. !! - ! 2012-05 (F. Roquet) add Vallis and original JM95 equation of state
  22. !! - ! 2013-04 (F. Roquet, G. Madec) add eos_rab, change bn2 computation and reorganize the module
  23. !! - ! 2014-09 (F. Roquet) add TEOS-10, S-EOS, and modify EOS-80
  24. !! - ! 2015-06 (P.A. Bouttier) eos_fzp functions changed to subroutines for AGRIF
  25. !!----------------------------------------------------------------------
  26. !!----------------------------------------------------------------------
  27. !! eos : generic interface of the equation of state
  28. !! eos_insitu : Compute the in situ density
  29. !! eos_insitu_pot : Compute the insitu and surface referenced potential volumic mass
  30. !! eos_insitu_2d : Compute the in situ density for 2d fields
  31. !! bn2 : Compute the Brunt-Vaisala frequency
  32. !! eos_rab : generic interface of in situ thermal/haline expansion ratio
  33. !! eos_rab_3d : compute in situ thermal/haline expansion ratio
  34. !! eos_rab_2d : compute in situ thermal/haline expansion ratio for 2d fields
  35. !! eos_fzp_2d : freezing temperature for 2d fields
  36. !! eos_fzp_0d : freezing temperature for scalar
  37. !! eos_init : set eos parameters (namelist)
  38. !!----------------------------------------------------------------------
  39. USE dom_oce ! ocean space and time domain
  40. USE phycst ! physical constants
  41. !
  42. USE in_out_manager ! I/O manager
  43. USE lib_mpp ! MPP library
  44. USE lib_fortran ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
  45. USE prtctl ! Print control
  46. USE wrk_nemo ! Memory Allocation
  47. USE lbclnk ! ocean lateral boundary conditions
  48. USE timing ! Timing
  49. USE stopar ! Stochastic T/S fluctuations
  50. USE stopts ! Stochastic T/S fluctuations
  51. IMPLICIT NONE
  52. PRIVATE
  53. ! !! * Interface
  54. INTERFACE eos
  55. MODULE PROCEDURE eos_insitu, eos_insitu_pot, eos_insitu_2d
  56. END INTERFACE
  57. !
  58. INTERFACE eos_rab
  59. MODULE PROCEDURE rab_3d, rab_2d, rab_0d
  60. END INTERFACE
  61. !
  62. INTERFACE eos_fzp
  63. MODULE PROCEDURE eos_fzp_2d, eos_fzp_0d
  64. END INTERFACE
  65. !
  66. PUBLIC eos ! called by step, istate, tranpc and zpsgrd modules
  67. PUBLIC bn2 ! called by step module
  68. PUBLIC eos_rab ! called by ldfslp, zdfddm, trabbl
  69. PUBLIC eos_pt_from_ct ! called by sbcssm
  70. PUBLIC eos_fzp ! called by traadv_cen2 and sbcice_... modules
  71. PUBLIC eos_pen ! used for pe diagnostics in trdpen module
  72. PUBLIC eos_init ! called by istate module
  73. ! !!* Namelist (nameos) *
  74. INTEGER , PUBLIC :: nn_eos ! = 0/1/2 type of eq. of state and Brunt-Vaisala frequ.
  75. LOGICAL , PUBLIC :: ln_useCT ! determine if eos_pt_from_ct is used to compute sst_m
  76. ! !!! simplified eos coefficients
  77. ! default value: Vallis 2006
  78. REAL(wp) :: rn_a0 = 1.6550e-1_wp ! thermal expansion coeff.
  79. REAL(wp) :: rn_b0 = 7.6554e-1_wp ! saline expansion coeff.
  80. REAL(wp) :: rn_lambda1 = 5.9520e-2_wp ! cabbeling coeff. in T^2
  81. REAL(wp) :: rn_lambda2 = 5.4914e-4_wp ! cabbeling coeff. in S^2
  82. REAL(wp) :: rn_mu1 = 1.4970e-4_wp ! thermobaric coeff. in T
  83. REAL(wp) :: rn_mu2 = 1.1090e-5_wp ! thermobaric coeff. in S
  84. REAL(wp) :: rn_nu = 2.4341e-3_wp ! cabbeling coeff. in theta*salt
  85. ! TEOS10/EOS80 parameters
  86. REAL(wp) :: r1_S0, r1_T0, r1_Z0, rdeltaS
  87. ! EOS parameters
  88. REAL(wp) :: EOS000 , EOS100 , EOS200 , EOS300 , EOS400 , EOS500 , EOS600
  89. REAL(wp) :: EOS010 , EOS110 , EOS210 , EOS310 , EOS410 , EOS510
  90. REAL(wp) :: EOS020 , EOS120 , EOS220 , EOS320 , EOS420
  91. REAL(wp) :: EOS030 , EOS130 , EOS230 , EOS330
  92. REAL(wp) :: EOS040 , EOS140 , EOS240
  93. REAL(wp) :: EOS050 , EOS150
  94. REAL(wp) :: EOS060
  95. REAL(wp) :: EOS001 , EOS101 , EOS201 , EOS301 , EOS401
  96. REAL(wp) :: EOS011 , EOS111 , EOS211 , EOS311
  97. REAL(wp) :: EOS021 , EOS121 , EOS221
  98. REAL(wp) :: EOS031 , EOS131
  99. REAL(wp) :: EOS041
  100. REAL(wp) :: EOS002 , EOS102 , EOS202
  101. REAL(wp) :: EOS012 , EOS112
  102. REAL(wp) :: EOS022
  103. REAL(wp) :: EOS003 , EOS103
  104. REAL(wp) :: EOS013
  105. ! ALPHA parameters
  106. REAL(wp) :: ALP000 , ALP100 , ALP200 , ALP300 , ALP400 , ALP500
  107. REAL(wp) :: ALP010 , ALP110 , ALP210 , ALP310 , ALP410
  108. REAL(wp) :: ALP020 , ALP120 , ALP220 , ALP320
  109. REAL(wp) :: ALP030 , ALP130 , ALP230
  110. REAL(wp) :: ALP040 , ALP140
  111. REAL(wp) :: ALP050
  112. REAL(wp) :: ALP001 , ALP101 , ALP201 , ALP301
  113. REAL(wp) :: ALP011 , ALP111 , ALP211
  114. REAL(wp) :: ALP021 , ALP121
  115. REAL(wp) :: ALP031
  116. REAL(wp) :: ALP002 , ALP102
  117. REAL(wp) :: ALP012
  118. REAL(wp) :: ALP003
  119. ! BETA parameters
  120. REAL(wp) :: BET000 , BET100 , BET200 , BET300 , BET400 , BET500
  121. REAL(wp) :: BET010 , BET110 , BET210 , BET310 , BET410
  122. REAL(wp) :: BET020 , BET120 , BET220 , BET320
  123. REAL(wp) :: BET030 , BET130 , BET230
  124. REAL(wp) :: BET040 , BET140
  125. REAL(wp) :: BET050
  126. REAL(wp) :: BET001 , BET101 , BET201 , BET301
  127. REAL(wp) :: BET011 , BET111 , BET211
  128. REAL(wp) :: BET021 , BET121
  129. REAL(wp) :: BET031
  130. REAL(wp) :: BET002 , BET102
  131. REAL(wp) :: BET012
  132. REAL(wp) :: BET003
  133. ! PEN parameters
  134. REAL(wp) :: PEN000 , PEN100 , PEN200 , PEN300 , PEN400
  135. REAL(wp) :: PEN010 , PEN110 , PEN210 , PEN310
  136. REAL(wp) :: PEN020 , PEN120 , PEN220
  137. REAL(wp) :: PEN030 , PEN130
  138. REAL(wp) :: PEN040
  139. REAL(wp) :: PEN001 , PEN101 , PEN201
  140. REAL(wp) :: PEN011 , PEN111
  141. REAL(wp) :: PEN021
  142. REAL(wp) :: PEN002 , PEN102
  143. REAL(wp) :: PEN012
  144. ! ALPHA_PEN parameters
  145. REAL(wp) :: APE000 , APE100 , APE200 , APE300
  146. REAL(wp) :: APE010 , APE110 , APE210
  147. REAL(wp) :: APE020 , APE120
  148. REAL(wp) :: APE030
  149. REAL(wp) :: APE001 , APE101
  150. REAL(wp) :: APE011
  151. REAL(wp) :: APE002
  152. ! BETA_PEN parameters
  153. REAL(wp) :: BPE000 , BPE100 , BPE200 , BPE300
  154. REAL(wp) :: BPE010 , BPE110 , BPE210
  155. REAL(wp) :: BPE020 , BPE120
  156. REAL(wp) :: BPE030
  157. REAL(wp) :: BPE001 , BPE101
  158. REAL(wp) :: BPE011
  159. REAL(wp) :: BPE002
  160. !! * Substitutions
  161. # include "domzgr_substitute.h90"
  162. # include "vectopt_loop_substitute.h90"
  163. !!----------------------------------------------------------------------
  164. !! NEMO/OPA 3.7 , NEMO Consortium (2014)
  165. !! $Id: eosbn2.F90 5540 2015-07-02 15:11:23Z jchanut $
  166. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  167. !!----------------------------------------------------------------------
  168. CONTAINS
  169. SUBROUTINE eos_insitu( pts, prd, pdep )
  170. !!----------------------------------------------------------------------
  171. !! *** ROUTINE eos_insitu ***
  172. !!
  173. !! ** Purpose : Compute the in situ density (ratio rho/rau0) from
  174. !! potential temperature and salinity using an equation of state
  175. !! defined through the namelist parameter nn_eos.
  176. !!
  177. !! ** Method : prd(t,s,z) = ( rho(t,s,z) - rau0 ) / rau0
  178. !! with prd in situ density anomaly no units
  179. !! t TEOS10: CT or EOS80: PT Celsius
  180. !! s TEOS10: SA or EOS80: SP TEOS10: g/kg or EOS80: psu
  181. !! z depth meters
  182. !! rho in situ density kg/m^3
  183. !! rau0 reference density kg/m^3
  184. !!
  185. !! nn_eos = -1 : polynomial TEOS-10 equation of state is used for rho(t,s,z).
  186. !! Check value: rho = 1028.21993233072 kg/m^3 for z=3000 dbar, ct=3 Celcius, sa=35.5 g/kg
  187. !!
  188. !! nn_eos = 0 : polynomial EOS-80 equation of state is used for rho(t,s,z).
  189. !! Check value: rho = 1028.35011066567 kg/m^3 for z=3000 dbar, pt=3 Celcius, sp=35.5 psu
  190. !!
  191. !! nn_eos = 1 : simplified equation of state
  192. !! prd(t,s,z) = ( -a0*(1+lambda/2*(T-T0)+mu*z+nu*(S-S0))*(T-T0) + b0*(S-S0) ) / rau0
  193. !! linear case function of T only: rn_alpha<>0, other coefficients = 0
  194. !! linear eos function of T and S: rn_alpha and rn_beta<>0, other coefficients=0
  195. !! Vallis like equation: use default values of coefficients
  196. !!
  197. !! ** Action : compute prd , the in situ density (no units)
  198. !!
  199. !! References : Roquet et al, Ocean Modelling, in preparation (2014)
  200. !! Vallis, Atmospheric and Oceanic Fluid Dynamics, 2006
  201. !! TEOS-10 Manual, 2010
  202. !!----------------------------------------------------------------------
  203. REAL(wp), DIMENSION(jpi,jpj,jpk,jpts), INTENT(in ) :: pts ! 1 : potential temperature [Celcius]
  204. ! ! 2 : salinity [psu]
  205. REAL(wp), DIMENSION(jpi,jpj,jpk ), INTENT( out) :: prd ! in situ density [-]
  206. REAL(wp), DIMENSION(jpi,jpj,jpk ), INTENT(in ) :: pdep ! depth [m]
  207. !
  208. INTEGER :: ji, jj, jk ! dummy loop indices
  209. REAL(wp) :: zt , zh , zs , ztm ! local scalars
  210. REAL(wp) :: zn , zn0, zn1, zn2, zn3 ! - -
  211. !!----------------------------------------------------------------------
  212. !
  213. IF( nn_timing == 1 ) CALL timing_start('eos-insitu')
  214. !
  215. SELECT CASE( nn_eos )
  216. !
  217. CASE( -1, 0 ) !== polynomial TEOS-10 / EOS-80 ==!
  218. !
  219. DO jk = 1, jpkm1
  220. DO jj = 1, jpj
  221. DO ji = 1, jpi
  222. !
  223. zh = pdep(ji,jj,jk) * r1_Z0 ! depth
  224. zt = pts (ji,jj,jk,jp_tem) * r1_T0 ! temperature
  225. zs = SQRT( ABS( pts(ji,jj,jk,jp_sal) + rdeltaS ) * r1_S0 ) ! square root salinity
  226. ztm = tmask(ji,jj,jk) ! tmask
  227. !
  228. zn3 = EOS013*zt &
  229. & + EOS103*zs+EOS003
  230. !
  231. zn2 = (EOS022*zt &
  232. & + EOS112*zs+EOS012)*zt &
  233. & + (EOS202*zs+EOS102)*zs+EOS002
  234. !
  235. zn1 = (((EOS041*zt &
  236. & + EOS131*zs+EOS031)*zt &
  237. & + (EOS221*zs+EOS121)*zs+EOS021)*zt &
  238. & + ((EOS311*zs+EOS211)*zs+EOS111)*zs+EOS011)*zt &
  239. & + (((EOS401*zs+EOS301)*zs+EOS201)*zs+EOS101)*zs+EOS001
  240. !
  241. zn0 = (((((EOS060*zt &
  242. & + EOS150*zs+EOS050)*zt &
  243. & + (EOS240*zs+EOS140)*zs+EOS040)*zt &
  244. & + ((EOS330*zs+EOS230)*zs+EOS130)*zs+EOS030)*zt &
  245. & + (((EOS420*zs+EOS320)*zs+EOS220)*zs+EOS120)*zs+EOS020)*zt &
  246. & + ((((EOS510*zs+EOS410)*zs+EOS310)*zs+EOS210)*zs+EOS110)*zs+EOS010)*zt &
  247. & + (((((EOS600*zs+EOS500)*zs+EOS400)*zs+EOS300)*zs+EOS200)*zs+EOS100)*zs+EOS000
  248. !
  249. zn = ( ( zn3 * zh + zn2 ) * zh + zn1 ) * zh + zn0
  250. !
  251. prd(ji,jj,jk) = ( zn * r1_rau0 - 1._wp ) * ztm ! density anomaly (masked)
  252. !
  253. END DO
  254. END DO
  255. END DO
  256. !
  257. CASE( 1 ) !== simplified EOS ==!
  258. !
  259. DO jk = 1, jpkm1
  260. DO jj = 1, jpj
  261. DO ji = 1, jpi
  262. zt = pts (ji,jj,jk,jp_tem) - 10._wp
  263. zs = pts (ji,jj,jk,jp_sal) - 35._wp
  264. zh = pdep (ji,jj,jk)
  265. ztm = tmask(ji,jj,jk)
  266. !
  267. zn = - rn_a0 * ( 1._wp + 0.5_wp*rn_lambda1*zt + rn_mu1*zh ) * zt &
  268. & + rn_b0 * ( 1._wp - 0.5_wp*rn_lambda2*zs - rn_mu2*zh ) * zs &
  269. & - rn_nu * zt * zs
  270. !
  271. prd(ji,jj,jk) = zn * r1_rau0 * ztm ! density anomaly (masked)
  272. END DO
  273. END DO
  274. END DO
  275. !
  276. END SELECT
  277. !
  278. IF(ln_ctl) CALL prt_ctl( tab3d_1=prd, clinfo1=' eos-insitu : ', ovlap=1, kdim=jpk )
  279. !
  280. IF( nn_timing == 1 ) CALL timing_stop('eos-insitu')
  281. !
  282. END SUBROUTINE eos_insitu
  283. SUBROUTINE eos_insitu_pot( pts, prd, prhop, pdep )
  284. !!----------------------------------------------------------------------
  285. !! *** ROUTINE eos_insitu_pot ***
  286. !!
  287. !! ** Purpose : Compute the in situ density (ratio rho/rau0) and the
  288. !! potential volumic mass (Kg/m3) from potential temperature and
  289. !! salinity fields using an equation of state defined through the
  290. !! namelist parameter nn_eos.
  291. !!
  292. !! ** Action : - prd , the in situ density (no units)
  293. !! - prhop, the potential volumic mass (Kg/m3)
  294. !!
  295. !!----------------------------------------------------------------------
  296. REAL(wp), DIMENSION(jpi,jpj,jpk,jpts), INTENT(in ) :: pts ! 1 : potential temperature [Celcius]
  297. ! ! 2 : salinity [psu]
  298. REAL(wp), DIMENSION(jpi,jpj,jpk ), INTENT( out) :: prd ! in situ density [-]
  299. REAL(wp), DIMENSION(jpi,jpj,jpk ), INTENT( out) :: prhop ! potential density (surface referenced)
  300. REAL(wp), DIMENSION(jpi,jpj,jpk ), INTENT(in ) :: pdep ! depth [m]
  301. !
  302. INTEGER :: ji, jj, jk, jsmp ! dummy loop indices
  303. INTEGER :: jdof
  304. REAL(wp) :: zt , zh , zstemp, zs , ztm ! local scalars
  305. REAL(wp) :: zn , zn0, zn1, zn2, zn3 ! - -
  306. REAL(wp), DIMENSION(:), ALLOCATABLE :: zn0_sto, zn_sto, zsign ! local vectors
  307. !!----------------------------------------------------------------------
  308. !
  309. IF( nn_timing == 1 ) CALL timing_start('eos-pot')
  310. !
  311. SELECT CASE ( nn_eos )
  312. !
  313. CASE( -1, 0 ) !== polynomial TEOS-10 / EOS-80 ==!
  314. !
  315. ! Stochastic equation of state
  316. IF ( ln_sto_eos ) THEN
  317. ALLOCATE(zn0_sto(1:2*nn_sto_eos))
  318. ALLOCATE(zn_sto(1:2*nn_sto_eos))
  319. ALLOCATE(zsign(1:2*nn_sto_eos))
  320. DO jsmp = 1, 2*nn_sto_eos, 2
  321. zsign(jsmp) = 1._wp
  322. zsign(jsmp+1) = -1._wp
  323. END DO
  324. !
  325. DO jk = 1, jpkm1
  326. DO jj = 1, jpj
  327. DO ji = 1, jpi
  328. !
  329. ! compute density (2*nn_sto_eos) times:
  330. ! (1) for t+dt, s+ds (with the random TS fluctutation computed in sto_pts)
  331. ! (2) for t-dt, s-ds (with the opposite fluctuation)
  332. DO jsmp = 1, nn_sto_eos*2
  333. jdof = (jsmp + 1) / 2
  334. zh = pdep(ji,jj,jk) * r1_Z0 ! depth
  335. zt = (pts (ji,jj,jk,jp_tem) + pts_ran(ji,jj,jk,jp_tem,jdof) * zsign(jsmp)) * r1_T0 ! temperature
  336. zstemp = pts (ji,jj,jk,jp_sal) + pts_ran(ji,jj,jk,jp_sal,jdof) * zsign(jsmp)
  337. zs = SQRT( ABS( zstemp + rdeltaS ) * r1_S0 ) ! square root salinity
  338. ztm = tmask(ji,jj,jk) ! tmask
  339. !
  340. zn3 = EOS013*zt &
  341. & + EOS103*zs+EOS003
  342. !
  343. zn2 = (EOS022*zt &
  344. & + EOS112*zs+EOS012)*zt &
  345. & + (EOS202*zs+EOS102)*zs+EOS002
  346. !
  347. zn1 = (((EOS041*zt &
  348. & + EOS131*zs+EOS031)*zt &
  349. & + (EOS221*zs+EOS121)*zs+EOS021)*zt &
  350. & + ((EOS311*zs+EOS211)*zs+EOS111)*zs+EOS011)*zt &
  351. & + (((EOS401*zs+EOS301)*zs+EOS201)*zs+EOS101)*zs+EOS001
  352. !
  353. zn0_sto(jsmp) = (((((EOS060*zt &
  354. & + EOS150*zs+EOS050)*zt &
  355. & + (EOS240*zs+EOS140)*zs+EOS040)*zt &
  356. & + ((EOS330*zs+EOS230)*zs+EOS130)*zs+EOS030)*zt &
  357. & + (((EOS420*zs+EOS320)*zs+EOS220)*zs+EOS120)*zs+EOS020)*zt &
  358. & + ((((EOS510*zs+EOS410)*zs+EOS310)*zs+EOS210)*zs+EOS110)*zs+EOS010)*zt &
  359. & + (((((EOS600*zs+EOS500)*zs+EOS400)*zs+EOS300)*zs+EOS200)*zs+EOS100)*zs+EOS000
  360. !
  361. zn_sto(jsmp) = ( ( zn3 * zh + zn2 ) * zh + zn1 ) * zh + zn0_sto(jsmp)
  362. END DO
  363. !
  364. ! compute stochastic density as the mean of the (2*nn_sto_eos) densities
  365. prhop(ji,jj,jk) = 0._wp ; prd(ji,jj,jk) = 0._wp
  366. DO jsmp = 1, nn_sto_eos*2
  367. prhop(ji,jj,jk) = prhop(ji,jj,jk) + zn0_sto(jsmp) ! potential density referenced at the surface
  368. !
  369. prd(ji,jj,jk) = prd(ji,jj,jk) + ( zn_sto(jsmp) * r1_rau0 - 1._wp ) ! density anomaly (masked)
  370. END DO
  371. prhop(ji,jj,jk) = 0.5_wp * prhop(ji,jj,jk) * ztm / nn_sto_eos
  372. prd (ji,jj,jk) = 0.5_wp * prd (ji,jj,jk) * ztm / nn_sto_eos
  373. END DO
  374. END DO
  375. END DO
  376. DEALLOCATE(zn0_sto,zn_sto,zsign)
  377. ! Non-stochastic equation of state
  378. ELSE
  379. DO jk = 1, jpkm1
  380. DO jj = 1, jpj
  381. DO ji = 1, jpi
  382. !
  383. zh = pdep(ji,jj,jk) * r1_Z0 ! depth
  384. zt = pts (ji,jj,jk,jp_tem) * r1_T0 ! temperature
  385. zs = SQRT( ABS( pts(ji,jj,jk,jp_sal) + rdeltaS ) * r1_S0 ) ! square root salinity
  386. ztm = tmask(ji,jj,jk) ! tmask
  387. !
  388. zn3 = EOS013*zt &
  389. & + EOS103*zs+EOS003
  390. !
  391. zn2 = (EOS022*zt &
  392. & + EOS112*zs+EOS012)*zt &
  393. & + (EOS202*zs+EOS102)*zs+EOS002
  394. !
  395. zn1 = (((EOS041*zt &
  396. & + EOS131*zs+EOS031)*zt &
  397. & + (EOS221*zs+EOS121)*zs+EOS021)*zt &
  398. & + ((EOS311*zs+EOS211)*zs+EOS111)*zs+EOS011)*zt &
  399. & + (((EOS401*zs+EOS301)*zs+EOS201)*zs+EOS101)*zs+EOS001
  400. !
  401. zn0 = (((((EOS060*zt &
  402. & + EOS150*zs+EOS050)*zt &
  403. & + (EOS240*zs+EOS140)*zs+EOS040)*zt &
  404. & + ((EOS330*zs+EOS230)*zs+EOS130)*zs+EOS030)*zt &
  405. & + (((EOS420*zs+EOS320)*zs+EOS220)*zs+EOS120)*zs+EOS020)*zt &
  406. & + ((((EOS510*zs+EOS410)*zs+EOS310)*zs+EOS210)*zs+EOS110)*zs+EOS010)*zt &
  407. & + (((((EOS600*zs+EOS500)*zs+EOS400)*zs+EOS300)*zs+EOS200)*zs+EOS100)*zs+EOS000
  408. !
  409. zn = ( ( zn3 * zh + zn2 ) * zh + zn1 ) * zh + zn0
  410. !
  411. prhop(ji,jj,jk) = zn0 * ztm ! potential density referenced at the surface
  412. !
  413. prd(ji,jj,jk) = ( zn * r1_rau0 - 1._wp ) * ztm ! density anomaly (masked)
  414. END DO
  415. END DO
  416. END DO
  417. ENDIF
  418. CASE( 1 ) !== simplified EOS ==!
  419. !
  420. DO jk = 1, jpkm1
  421. DO jj = 1, jpj
  422. DO ji = 1, jpi
  423. zt = pts (ji,jj,jk,jp_tem) - 10._wp
  424. zs = pts (ji,jj,jk,jp_sal) - 35._wp
  425. zh = pdep (ji,jj,jk)
  426. ztm = tmask(ji,jj,jk)
  427. ! ! potential density referenced at the surface
  428. zn = - rn_a0 * ( 1._wp + 0.5_wp*rn_lambda1*zt ) * zt &
  429. & + rn_b0 * ( 1._wp - 0.5_wp*rn_lambda2*zs ) * zs &
  430. & - rn_nu * zt * zs
  431. prhop(ji,jj,jk) = ( rau0 + zn ) * ztm
  432. ! ! density anomaly (masked)
  433. zn = zn - ( rn_a0 * rn_mu1 * zt + rn_b0 * rn_mu2 * zs ) * zh
  434. prd(ji,jj,jk) = zn * r1_rau0 * ztm
  435. !
  436. END DO
  437. END DO
  438. END DO
  439. !
  440. END SELECT
  441. !
  442. IF(ln_ctl) CALL prt_ctl( tab3d_1=prd, clinfo1=' eos-pot: ', tab3d_2=prhop, clinfo2=' pot : ', ovlap=1, kdim=jpk )
  443. !
  444. IF( nn_timing == 1 ) CALL timing_stop('eos-pot')
  445. !
  446. END SUBROUTINE eos_insitu_pot
  447. SUBROUTINE eos_insitu_2d( pts, pdep, prd )
  448. !!----------------------------------------------------------------------
  449. !! *** ROUTINE eos_insitu_2d ***
  450. !!
  451. !! ** Purpose : Compute the in situ density (ratio rho/rau0) from
  452. !! potential temperature and salinity using an equation of state
  453. !! defined through the namelist parameter nn_eos. * 2D field case
  454. !!
  455. !! ** Action : - prd , the in situ density (no units) (unmasked)
  456. !!
  457. !!----------------------------------------------------------------------
  458. REAL(wp), DIMENSION(jpi,jpj,jpts), INTENT(in ) :: pts ! 1 : potential temperature [Celcius]
  459. ! ! 2 : salinity [psu]
  460. REAL(wp), DIMENSION(jpi,jpj) , INTENT(in ) :: pdep ! depth [m]
  461. REAL(wp), DIMENSION(jpi,jpj) , INTENT( out) :: prd ! in situ density
  462. !
  463. INTEGER :: ji, jj, jk ! dummy loop indices
  464. REAL(wp) :: zt , zh , zs ! local scalars
  465. REAL(wp) :: zn , zn0, zn1, zn2, zn3 ! - -
  466. !!----------------------------------------------------------------------
  467. !
  468. IF( nn_timing == 1 ) CALL timing_start('eos2d')
  469. !
  470. prd(:,:) = 0._wp
  471. !
  472. SELECT CASE( nn_eos )
  473. !
  474. CASE( -1, 0 ) !== polynomial TEOS-10 / EOS-80 ==!
  475. !
  476. DO jj = 1, jpjm1
  477. DO ji = 1, fs_jpim1 ! vector opt.
  478. !
  479. zh = pdep(ji,jj) * r1_Z0 ! depth
  480. zt = pts (ji,jj,jp_tem) * r1_T0 ! temperature
  481. zs = SQRT( ABS( pts(ji,jj,jp_sal) + rdeltaS ) * r1_S0 ) ! square root salinity
  482. !
  483. zn3 = EOS013*zt &
  484. & + EOS103*zs+EOS003
  485. !
  486. zn2 = (EOS022*zt &
  487. & + EOS112*zs+EOS012)*zt &
  488. & + (EOS202*zs+EOS102)*zs+EOS002
  489. !
  490. zn1 = (((EOS041*zt &
  491. & + EOS131*zs+EOS031)*zt &
  492. & + (EOS221*zs+EOS121)*zs+EOS021)*zt &
  493. & + ((EOS311*zs+EOS211)*zs+EOS111)*zs+EOS011)*zt &
  494. & + (((EOS401*zs+EOS301)*zs+EOS201)*zs+EOS101)*zs+EOS001
  495. !
  496. zn0 = (((((EOS060*zt &
  497. & + EOS150*zs+EOS050)*zt &
  498. & + (EOS240*zs+EOS140)*zs+EOS040)*zt &
  499. & + ((EOS330*zs+EOS230)*zs+EOS130)*zs+EOS030)*zt &
  500. & + (((EOS420*zs+EOS320)*zs+EOS220)*zs+EOS120)*zs+EOS020)*zt &
  501. & + ((((EOS510*zs+EOS410)*zs+EOS310)*zs+EOS210)*zs+EOS110)*zs+EOS010)*zt &
  502. & + (((((EOS600*zs+EOS500)*zs+EOS400)*zs+EOS300)*zs+EOS200)*zs+EOS100)*zs+EOS000
  503. !
  504. zn = ( ( zn3 * zh + zn2 ) * zh + zn1 ) * zh + zn0
  505. !
  506. prd(ji,jj) = zn * r1_rau0 - 1._wp ! unmasked in situ density anomaly
  507. !
  508. END DO
  509. END DO
  510. !
  511. CALL lbc_lnk( prd, 'T', 1. ) ! Lateral boundary conditions
  512. !
  513. CASE( 1 ) !== simplified EOS ==!
  514. !
  515. DO jj = 1, jpjm1
  516. DO ji = 1, fs_jpim1 ! vector opt.
  517. !
  518. zt = pts (ji,jj,jp_tem) - 10._wp
  519. zs = pts (ji,jj,jp_sal) - 35._wp
  520. zh = pdep (ji,jj) ! depth at the partial step level
  521. !
  522. zn = - rn_a0 * ( 1._wp + 0.5_wp*rn_lambda1*zt + rn_mu1*zh ) * zt &
  523. & + rn_b0 * ( 1._wp - 0.5_wp*rn_lambda2*zs - rn_mu2*zh ) * zs &
  524. & - rn_nu * zt * zs
  525. !
  526. prd(ji,jj) = zn * r1_rau0 ! unmasked in situ density anomaly
  527. !
  528. END DO
  529. END DO
  530. !
  531. CALL lbc_lnk( prd, 'T', 1. ) ! Lateral boundary conditions
  532. !
  533. END SELECT
  534. !
  535. IF(ln_ctl) CALL prt_ctl( tab2d_1=prd, clinfo1=' eos2d: ' )
  536. !
  537. IF( nn_timing == 1 ) CALL timing_stop('eos2d')
  538. !
  539. END SUBROUTINE eos_insitu_2d
  540. SUBROUTINE rab_3d( pts, pab )
  541. !!----------------------------------------------------------------------
  542. !! *** ROUTINE rab_3d ***
  543. !!
  544. !! ** Purpose : Calculates thermal/haline expansion ratio at T-points
  545. !!
  546. !! ** Method : calculates alpha / beta at T-points
  547. !!
  548. !! ** Action : - pab : thermal/haline expansion ratio at T-points
  549. !!----------------------------------------------------------------------
  550. REAL(wp), DIMENSION(jpi,jpj,jpk,jpts), INTENT(in ) :: pts ! pot. temperature & salinity
  551. REAL(wp), DIMENSION(jpi,jpj,jpk,jpts), INTENT( out) :: pab ! thermal/haline expansion ratio
  552. !
  553. INTEGER :: ji, jj, jk ! dummy loop indices
  554. REAL(wp) :: zt , zh , zs , ztm ! local scalars
  555. REAL(wp) :: zn , zn0, zn1, zn2, zn3 ! - -
  556. !!----------------------------------------------------------------------
  557. !
  558. IF( nn_timing == 1 ) CALL timing_start('rab_3d')
  559. !
  560. SELECT CASE ( nn_eos )
  561. !
  562. CASE( -1, 0 ) !== polynomial TEOS-10 / EOS-80 ==!
  563. !
  564. DO jk = 1, jpkm1
  565. DO jj = 1, jpj
  566. DO ji = 1, jpi
  567. !
  568. zh = fsdept(ji,jj,jk) * r1_Z0 ! depth
  569. zt = pts (ji,jj,jk,jp_tem) * r1_T0 ! temperature
  570. zs = SQRT( ABS( pts(ji,jj,jk,jp_sal) + rdeltaS ) * r1_S0 ) ! square root salinity
  571. ztm = tmask(ji,jj,jk) ! tmask
  572. !
  573. ! alpha
  574. zn3 = ALP003
  575. !
  576. zn2 = ALP012*zt + ALP102*zs+ALP002
  577. !
  578. zn1 = ((ALP031*zt &
  579. & + ALP121*zs+ALP021)*zt &
  580. & + (ALP211*zs+ALP111)*zs+ALP011)*zt &
  581. & + ((ALP301*zs+ALP201)*zs+ALP101)*zs+ALP001
  582. !
  583. zn0 = ((((ALP050*zt &
  584. & + ALP140*zs+ALP040)*zt &
  585. & + (ALP230*zs+ALP130)*zs+ALP030)*zt &
  586. & + ((ALP320*zs+ALP220)*zs+ALP120)*zs+ALP020)*zt &
  587. & + (((ALP410*zs+ALP310)*zs+ALP210)*zs+ALP110)*zs+ALP010)*zt &
  588. & + ((((ALP500*zs+ALP400)*zs+ALP300)*zs+ALP200)*zs+ALP100)*zs+ALP000
  589. !
  590. zn = ( ( zn3 * zh + zn2 ) * zh + zn1 ) * zh + zn0
  591. !
  592. pab(ji,jj,jk,jp_tem) = zn * r1_rau0 * ztm
  593. !
  594. ! beta
  595. zn3 = BET003
  596. !
  597. zn2 = BET012*zt + BET102*zs+BET002
  598. !
  599. zn1 = ((BET031*zt &
  600. & + BET121*zs+BET021)*zt &
  601. & + (BET211*zs+BET111)*zs+BET011)*zt &
  602. & + ((BET301*zs+BET201)*zs+BET101)*zs+BET001
  603. !
  604. zn0 = ((((BET050*zt &
  605. & + BET140*zs+BET040)*zt &
  606. & + (BET230*zs+BET130)*zs+BET030)*zt &
  607. & + ((BET320*zs+BET220)*zs+BET120)*zs+BET020)*zt &
  608. & + (((BET410*zs+BET310)*zs+BET210)*zs+BET110)*zs+BET010)*zt &
  609. & + ((((BET500*zs+BET400)*zs+BET300)*zs+BET200)*zs+BET100)*zs+BET000
  610. !
  611. zn = ( ( zn3 * zh + zn2 ) * zh + zn1 ) * zh + zn0
  612. !
  613. pab(ji,jj,jk,jp_sal) = zn / zs * r1_rau0 * ztm
  614. !
  615. END DO
  616. END DO
  617. END DO
  618. !
  619. CASE( 1 ) !== simplified EOS ==!
  620. !
  621. DO jk = 1, jpkm1
  622. DO jj = 1, jpj
  623. DO ji = 1, jpi
  624. zt = pts (ji,jj,jk,jp_tem) - 10._wp ! pot. temperature anomaly (t-T0)
  625. zs = pts (ji,jj,jk,jp_sal) - 35._wp ! abs. salinity anomaly (s-S0)
  626. zh = fsdept(ji,jj,jk) ! depth in meters at t-point
  627. ztm = tmask(ji,jj,jk) ! land/sea bottom mask = surf. mask
  628. !
  629. zn = rn_a0 * ( 1._wp + rn_lambda1*zt + rn_mu1*zh ) + rn_nu*zs
  630. pab(ji,jj,jk,jp_tem) = zn * r1_rau0 * ztm ! alpha
  631. !
  632. zn = rn_b0 * ( 1._wp - rn_lambda2*zs - rn_mu2*zh ) - rn_nu*zt
  633. pab(ji,jj,jk,jp_sal) = zn * r1_rau0 * ztm ! beta
  634. !
  635. END DO
  636. END DO
  637. END DO
  638. !
  639. CASE DEFAULT
  640. IF(lwp) WRITE(numout,cform_err)
  641. IF(lwp) WRITE(numout,*) ' bad flag value for nn_eos = ', nn_eos
  642. nstop = nstop + 1
  643. !
  644. END SELECT
  645. !
  646. IF(ln_ctl) CALL prt_ctl( tab3d_1=pab(:,:,:,jp_tem), clinfo1=' rab_3d_t: ', &
  647. & tab3d_2=pab(:,:,:,jp_sal), clinfo2=' rab_3d_s : ', ovlap=1, kdim=jpk )
  648. !
  649. IF( nn_timing == 1 ) CALL timing_stop('rab_3d')
  650. !
  651. END SUBROUTINE rab_3d
  652. SUBROUTINE rab_2d( pts, pdep, pab )
  653. !!----------------------------------------------------------------------
  654. !! *** ROUTINE rab_2d ***
  655. !!
  656. !! ** Purpose : Calculates thermal/haline expansion ratio for a 2d field (unmasked)
  657. !!
  658. !! ** Action : - pab : thermal/haline expansion ratio at T-points
  659. !!----------------------------------------------------------------------
  660. REAL(wp), DIMENSION(jpi,jpj,jpts) , INTENT(in ) :: pts ! pot. temperature & salinity
  661. REAL(wp), DIMENSION(jpi,jpj) , INTENT(in ) :: pdep ! depth [m]
  662. REAL(wp), DIMENSION(jpi,jpj,jpts) , INTENT( out) :: pab ! thermal/haline expansion ratio
  663. !
  664. INTEGER :: ji, jj, jk ! dummy loop indices
  665. REAL(wp) :: zt , zh , zs ! local scalars
  666. REAL(wp) :: zn , zn0, zn1, zn2, zn3 ! - -
  667. !!----------------------------------------------------------------------
  668. !
  669. IF( nn_timing == 1 ) CALL timing_start('rab_2d')
  670. !
  671. pab(:,:,:) = 0._wp
  672. !
  673. SELECT CASE ( nn_eos )
  674. !
  675. CASE( -1, 0 ) !== polynomial TEOS-10 / EOS-80 ==!
  676. !
  677. DO jj = 1, jpj
  678. DO ji = 1, jpi
  679. !
  680. zh = pdep(ji,jj) * r1_Z0 ! depth
  681. zt = pts (ji,jj,jp_tem) * r1_T0 ! temperature
  682. zs = SQRT( ABS( pts(ji,jj,jp_sal) + rdeltaS ) * r1_S0 ) ! square root salinity
  683. !
  684. ! alpha
  685. zn3 = ALP003
  686. !
  687. zn2 = ALP012*zt + ALP102*zs+ALP002
  688. !
  689. zn1 = ((ALP031*zt &
  690. & + ALP121*zs+ALP021)*zt &
  691. & + (ALP211*zs+ALP111)*zs+ALP011)*zt &
  692. & + ((ALP301*zs+ALP201)*zs+ALP101)*zs+ALP001
  693. !
  694. zn0 = ((((ALP050*zt &
  695. & + ALP140*zs+ALP040)*zt &
  696. & + (ALP230*zs+ALP130)*zs+ALP030)*zt &
  697. & + ((ALP320*zs+ALP220)*zs+ALP120)*zs+ALP020)*zt &
  698. & + (((ALP410*zs+ALP310)*zs+ALP210)*zs+ALP110)*zs+ALP010)*zt &
  699. & + ((((ALP500*zs+ALP400)*zs+ALP300)*zs+ALP200)*zs+ALP100)*zs+ALP000
  700. !
  701. zn = ( ( zn3 * zh + zn2 ) * zh + zn1 ) * zh + zn0
  702. !
  703. pab(ji,jj,jp_tem) = zn * r1_rau0
  704. !
  705. ! beta
  706. zn3 = BET003
  707. !
  708. zn2 = BET012*zt + BET102*zs+BET002
  709. !
  710. zn1 = ((BET031*zt &
  711. & + BET121*zs+BET021)*zt &
  712. & + (BET211*zs+BET111)*zs+BET011)*zt &
  713. & + ((BET301*zs+BET201)*zs+BET101)*zs+BET001
  714. !
  715. zn0 = ((((BET050*zt &
  716. & + BET140*zs+BET040)*zt &
  717. & + (BET230*zs+BET130)*zs+BET030)*zt &
  718. & + ((BET320*zs+BET220)*zs+BET120)*zs+BET020)*zt &
  719. & + (((BET410*zs+BET310)*zs+BET210)*zs+BET110)*zs+BET010)*zt &
  720. & + ((((BET500*zs+BET400)*zs+BET300)*zs+BET200)*zs+BET100)*zs+BET000
  721. !
  722. zn = ( ( zn3 * zh + zn2 ) * zh + zn1 ) * zh + zn0
  723. !
  724. pab(ji,jj,jp_sal) = zn / zs * r1_rau0
  725. !
  726. !
  727. END DO
  728. END DO
  729. !
  730. CASE( 1 ) !== simplified EOS ==!
  731. !
  732. DO jj = 1, jpj
  733. DO ji = 1, jpi
  734. !
  735. zt = pts (ji,jj,jp_tem) - 10._wp ! pot. temperature anomaly (t-T0)
  736. zs = pts (ji,jj,jp_sal) - 35._wp ! abs. salinity anomaly (s-S0)
  737. zh = pdep (ji,jj) ! depth at the partial step level
  738. !
  739. zn = rn_a0 * ( 1._wp + rn_lambda1*zt + rn_mu1*zh ) + rn_nu*zs
  740. pab(ji,jj,jp_tem) = zn * r1_rau0 ! alpha
  741. !
  742. zn = rn_b0 * ( 1._wp - rn_lambda2*zs - rn_mu2*zh ) - rn_nu*zt
  743. pab(ji,jj,jp_sal) = zn * r1_rau0 ! beta
  744. !
  745. END DO
  746. END DO
  747. !
  748. CASE DEFAULT
  749. IF(lwp) WRITE(numout,cform_err)
  750. IF(lwp) WRITE(numout,*) ' bad flag value for nn_eos = ', nn_eos
  751. nstop = nstop + 1
  752. !
  753. END SELECT
  754. !
  755. IF(ln_ctl) CALL prt_ctl( tab2d_1=pab(:,:,jp_tem), clinfo1=' rab_2d_t: ', &
  756. & tab2d_2=pab(:,:,jp_sal), clinfo2=' rab_2d_s : ' )
  757. !
  758. IF( nn_timing == 1 ) CALL timing_stop('rab_2d')
  759. !
  760. END SUBROUTINE rab_2d
  761. SUBROUTINE rab_0d( pts, pdep, pab )
  762. !!----------------------------------------------------------------------
  763. !! *** ROUTINE rab_0d ***
  764. !!
  765. !! ** Purpose : Calculates thermal/haline expansion ratio for a 2d field (unmasked)
  766. !!
  767. !! ** Action : - pab : thermal/haline expansion ratio at T-points
  768. !!----------------------------------------------------------------------
  769. REAL(wp), DIMENSION(jpts) , INTENT(in ) :: pts ! pot. temperature & salinity
  770. REAL(wp), INTENT(in ) :: pdep ! depth [m]
  771. REAL(wp), DIMENSION(jpts) , INTENT( out) :: pab ! thermal/haline expansion ratio
  772. !
  773. REAL(wp) :: zt , zh , zs ! local scalars
  774. REAL(wp) :: zn , zn0, zn1, zn2, zn3 ! - -
  775. !!----------------------------------------------------------------------
  776. !
  777. IF( nn_timing == 1 ) CALL timing_start('rab_2d')
  778. !
  779. pab(:) = 0._wp
  780. !
  781. SELECT CASE ( nn_eos )
  782. !
  783. CASE( -1, 0 ) !== polynomial TEOS-10 / EOS-80 ==!
  784. !
  785. !
  786. zh = pdep * r1_Z0 ! depth
  787. zt = pts (jp_tem) * r1_T0 ! temperature
  788. zs = SQRT( ABS( pts(jp_sal) + rdeltaS ) * r1_S0 ) ! square root salinity
  789. !
  790. ! alpha
  791. zn3 = ALP003
  792. !
  793. zn2 = ALP012*zt + ALP102*zs+ALP002
  794. !
  795. zn1 = ((ALP031*zt &
  796. & + ALP121*zs+ALP021)*zt &
  797. & + (ALP211*zs+ALP111)*zs+ALP011)*zt &
  798. & + ((ALP301*zs+ALP201)*zs+ALP101)*zs+ALP001
  799. !
  800. zn0 = ((((ALP050*zt &
  801. & + ALP140*zs+ALP040)*zt &
  802. & + (ALP230*zs+ALP130)*zs+ALP030)*zt &
  803. & + ((ALP320*zs+ALP220)*zs+ALP120)*zs+ALP020)*zt &
  804. & + (((ALP410*zs+ALP310)*zs+ALP210)*zs+ALP110)*zs+ALP010)*zt &
  805. & + ((((ALP500*zs+ALP400)*zs+ALP300)*zs+ALP200)*zs+ALP100)*zs+ALP000
  806. !
  807. zn = ( ( zn3 * zh + zn2 ) * zh + zn1 ) * zh + zn0
  808. !
  809. pab(jp_tem) = zn * r1_rau0
  810. !
  811. ! beta
  812. zn3 = BET003
  813. !
  814. zn2 = BET012*zt + BET102*zs+BET002
  815. !
  816. zn1 = ((BET031*zt &
  817. & + BET121*zs+BET021)*zt &
  818. & + (BET211*zs+BET111)*zs+BET011)*zt &
  819. & + ((BET301*zs+BET201)*zs+BET101)*zs+BET001
  820. !
  821. zn0 = ((((BET050*zt &
  822. & + BET140*zs+BET040)*zt &
  823. & + (BET230*zs+BET130)*zs+BET030)*zt &
  824. & + ((BET320*zs+BET220)*zs+BET120)*zs+BET020)*zt &
  825. & + (((BET410*zs+BET310)*zs+BET210)*zs+BET110)*zs+BET010)*zt &
  826. & + ((((BET500*zs+BET400)*zs+BET300)*zs+BET200)*zs+BET100)*zs+BET000
  827. !
  828. zn = ( ( zn3 * zh + zn2 ) * zh + zn1 ) * zh + zn0
  829. !
  830. pab(jp_sal) = zn / zs * r1_rau0
  831. !
  832. !
  833. !
  834. CASE( 1 ) !== simplified EOS ==!
  835. !
  836. zt = pts(jp_tem) - 10._wp ! pot. temperature anomaly (t-T0)
  837. zs = pts(jp_sal) - 35._wp ! abs. salinity anomaly (s-S0)
  838. zh = pdep ! depth at the partial step level
  839. !
  840. zn = rn_a0 * ( 1._wp + rn_lambda1*zt + rn_mu1*zh ) + rn_nu*zs
  841. pab(jp_tem) = zn * r1_rau0 ! alpha
  842. !
  843. zn = rn_b0 * ( 1._wp - rn_lambda2*zs - rn_mu2*zh ) - rn_nu*zt
  844. pab(jp_sal) = zn * r1_rau0 ! beta
  845. !
  846. CASE DEFAULT
  847. IF(lwp) WRITE(numout,cform_err)
  848. IF(lwp) WRITE(numout,*) ' bad flag value for nn_eos = ', nn_eos
  849. nstop = nstop + 1
  850. !
  851. END SELECT
  852. !
  853. IF( nn_timing == 1 ) CALL timing_stop('rab_2d')
  854. !
  855. END SUBROUTINE rab_0d
  856. SUBROUTINE bn2( pts, pab, pn2 )
  857. !!----------------------------------------------------------------------
  858. !! *** ROUTINE bn2 ***
  859. !!
  860. !! ** Purpose : Compute the local Brunt-Vaisala frequency at the
  861. !! time-step of the input arguments
  862. !!
  863. !! ** Method : pn2 = grav * (alpha dk[T] + beta dk[S] ) / e3w
  864. !! where alpha and beta are given in pab, and computed on T-points.
  865. !! N.B. N^2 is set one for all to zero at jk=1 in istate module.
  866. !!
  867. !! ** Action : pn2 : square of the brunt-vaisala frequency at w-point
  868. !!
  869. !!----------------------------------------------------------------------
  870. REAL(wp), DIMENSION(jpi,jpj,jpk,jpts), INTENT(in ) :: pts ! pot. temperature and salinity [Celcius,psu]
  871. REAL(wp), DIMENSION(jpi,jpj,jpk,jpts), INTENT(in ) :: pab ! thermal/haline expansion coef. [Celcius-1,psu-1]
  872. REAL(wp), DIMENSION(jpi,jpj,jpk ), INTENT( out) :: pn2 ! Brunt-Vaisala frequency squared [1/s^2]
  873. !
  874. INTEGER :: ji, jj, jk ! dummy loop indices
  875. REAL(wp) :: zaw, zbw, zrw ! local scalars
  876. !!----------------------------------------------------------------------
  877. !
  878. IF( nn_timing == 1 ) CALL timing_start('bn2')
  879. !
  880. DO jk = 2, jpkm1 ! interior points only (2=< jk =< jpkm1 )
  881. DO jj = 1, jpj ! surface and bottom value set to zero one for all in istate.F90
  882. DO ji = 1, jpi
  883. zrw = ( fsdepw(ji,jj,jk ) - fsdept(ji,jj,jk) ) &
  884. & / ( fsdept(ji,jj,jk-1) - fsdept(ji,jj,jk) )
  885. !
  886. zaw = pab(ji,jj,jk,jp_tem) * (1. - zrw) + pab(ji,jj,jk-1,jp_tem) * zrw
  887. zbw = pab(ji,jj,jk,jp_sal) * (1. - zrw) + pab(ji,jj,jk-1,jp_sal) * zrw
  888. !
  889. pn2(ji,jj,jk) = grav * ( zaw * ( pts(ji,jj,jk-1,jp_tem) - pts(ji,jj,jk,jp_tem) ) &
  890. & - zbw * ( pts(ji,jj,jk-1,jp_sal) - pts(ji,jj,jk,jp_sal) ) ) &
  891. & / fse3w(ji,jj,jk) * tmask(ji,jj,jk)
  892. END DO
  893. END DO
  894. END DO
  895. !
  896. IF(ln_ctl) CALL prt_ctl( tab3d_1=pn2, clinfo1=' bn2 : ', ovlap=1, kdim=jpk )
  897. !
  898. IF( nn_timing == 1 ) CALL timing_stop('bn2')
  899. !
  900. END SUBROUTINE bn2
  901. FUNCTION eos_pt_from_ct( ctmp, psal ) RESULT( ptmp )
  902. !!----------------------------------------------------------------------
  903. !! *** ROUTINE eos_pt_from_ct ***
  904. !!
  905. !! ** Purpose : Compute pot.temp. from cons. temp. [Celcius]
  906. !!
  907. !! ** Method : rational approximation (5/3th order) of TEOS-10 algorithm
  908. !! checkvalue: pt=20.02391895 Celsius for sa=35.7g/kg, ct=20degC
  909. !!
  910. !! Reference : TEOS-10, UNESCO
  911. !! Rational approximation to TEOS10 algorithm (rms error on WOA13 values: 4.0e-5 degC)
  912. !!----------------------------------------------------------------------
  913. REAL(wp), DIMENSION(jpi,jpj), INTENT(in ) :: ctmp ! Cons. Temp [Celcius]
  914. REAL(wp), DIMENSION(jpi,jpj), INTENT(in ) :: psal ! salinity [psu]
  915. ! Leave result array automatic rather than making explicitly allocated
  916. REAL(wp), DIMENSION(jpi,jpj) :: ptmp ! potential temperature [Celcius]
  917. !
  918. INTEGER :: ji, jj ! dummy loop indices
  919. REAL(wp) :: zt , zs , ztm ! local scalars
  920. REAL(wp) :: zn , zd ! local scalars
  921. REAL(wp) :: zdeltaS , z1_S0 , z1_T0
  922. !!----------------------------------------------------------------------
  923. !
  924. IF ( nn_timing == 1 ) CALL timing_start('eos_pt_from_ct')
  925. !
  926. zdeltaS = 5._wp
  927. z1_S0 = 0.875_wp/35.16504_wp
  928. z1_T0 = 1._wp/40._wp
  929. !
  930. DO jj = 1, jpj
  931. DO ji = 1, jpi
  932. !
  933. zt = ctmp (ji,jj) * z1_T0
  934. zs = SQRT( ABS( psal(ji,jj) + zdeltaS ) * r1_S0 )
  935. ztm = tmask(ji,jj,1)
  936. !
  937. zn = ((((-2.1385727895e-01_wp*zt &
  938. & - 2.7674419971e-01_wp*zs+1.0728094330_wp)*zt &
  939. & + (2.6366564313_wp*zs+3.3546960647_wp)*zs-7.8012209473_wp)*zt &
  940. & + ((1.8835586562_wp*zs+7.3949191679_wp)*zs-3.3937395875_wp)*zs-5.6414948432_wp)*zt &
  941. & + (((3.5737370589_wp*zs-1.5512427389e+01_wp)*zs+2.4625741105e+01_wp)*zs &
  942. & +1.9912291000e+01_wp)*zs-3.2191146312e+01_wp)*zt &
  943. & + ((((5.7153204649e-01_wp*zs-3.0943149543_wp)*zs+9.3052495181_wp)*zs &
  944. & -9.4528934807_wp)*zs+3.1066408996_wp)*zs-4.3504021262e-01_wp
  945. !
  946. zd = (2.0035003456_wp*zt &
  947. & -3.4570358592e-01_wp*zs+5.6471810638_wp)*zt &
  948. & + (1.5393993508_wp*zs-6.9394762624_wp)*zs+1.2750522650e+01_wp
  949. !
  950. ptmp(ji,jj) = ( zt / z1_T0 + zn / zd ) * ztm
  951. !
  952. END DO
  953. END DO
  954. !
  955. IF( nn_timing == 1 ) CALL timing_stop('eos_pt_from_ct')
  956. !
  957. END FUNCTION eos_pt_from_ct
  958. SUBROUTINE eos_fzp_2d( psal, ptf, pdep )
  959. !!----------------------------------------------------------------------
  960. !! *** ROUTINE eos_fzp ***
  961. !!
  962. !! ** Purpose : Compute the freezing point temperature [Celcius]
  963. !!
  964. !! ** Method : UNESCO freezing point (ptf) in Celcius is given by
  965. !! ptf(t,z) = (-.0575+1.710523e-3*sqrt(abs(s))-2.154996e-4*s)*s - 7.53e-4*z
  966. !! checkvalue: tf=-2.588567 Celsius for s=40psu, z=500m
  967. !!
  968. !! Reference : UNESCO tech. papers in the marine science no. 28. 1978
  969. !!----------------------------------------------------------------------
  970. REAL(wp), DIMENSION(jpi,jpj), INTENT(in ) :: psal ! salinity [psu]
  971. REAL(wp), DIMENSION(jpi,jpj), INTENT(in ), OPTIONAL :: pdep ! depth [m]
  972. REAL(wp), DIMENSION(jpi,jpj), INTENT(out ) :: ptf ! freezing temperature [Celcius]
  973. !
  974. INTEGER :: ji, jj ! dummy loop indices
  975. REAL(wp) :: zt, zs ! local scalars
  976. !!----------------------------------------------------------------------
  977. !
  978. SELECT CASE ( nn_eos )
  979. !
  980. CASE ( -1, 1 ) !== CT,SA (TEOS-10 formulation) ==!
  981. !
  982. DO jj = 1, jpj
  983. DO ji = 1, jpi
  984. zs= SQRT( ABS( psal(ji,jj) ) / 35.16504_wp ) ! square root salinity
  985. ptf(ji,jj) = ((((1.46873e-03_wp*zs-9.64972e-03_wp)*zs+2.28348e-02_wp)*zs &
  986. & - 3.12775e-02_wp)*zs+2.07679e-02_wp)*zs-5.87701e-02_wp
  987. END DO
  988. END DO
  989. ptf(:,:) = ptf(:,:) * psal(:,:)
  990. !
  991. IF( PRESENT( pdep ) ) ptf(:,:) = ptf(:,:) - 7.53e-4 * pdep(:,:)
  992. !
  993. CASE ( 0 ) !== PT,SP (UNESCO formulation) ==!
  994. !
  995. ptf(:,:) = ( - 0.0575_wp + 1.710523e-3_wp * SQRT( psal(:,:) ) &
  996. & - 2.154996e-4_wp * psal(:,:) ) * psal(:,:)
  997. !
  998. IF( PRESENT( pdep ) ) ptf(:,:) = ptf(:,:) - 7.53e-4 * pdep(:,:)
  999. !
  1000. CASE DEFAULT
  1001. IF(lwp) WRITE(numout,cform_err)
  1002. IF(lwp) WRITE(numout,*) ' bad flag value for nn_eos = ', nn_eos
  1003. nstop = nstop + 1
  1004. !
  1005. END SELECT
  1006. !
  1007. END SUBROUTINE eos_fzp_2d
  1008. SUBROUTINE eos_fzp_0d( psal, ptf, pdep )
  1009. !!----------------------------------------------------------------------
  1010. !! *** ROUTINE eos_fzp ***
  1011. !!
  1012. !! ** Purpose : Compute the freezing point temperature [Celcius]
  1013. !!
  1014. !! ** Method : UNESCO freezing point (ptf) in Celcius is given by
  1015. !! ptf(t,z) = (-.0575+1.710523e-3*sqrt(abs(s))-2.154996e-4*s)*s - 7.53e-4*z
  1016. !! checkvalue: tf=-2.588567 Celsius for s=40psu, z=500m
  1017. !!
  1018. !! Reference : UNESCO tech. papers in the marine science no. 28. 1978
  1019. !!----------------------------------------------------------------------
  1020. REAL(wp), INTENT(in ) :: psal ! salinity [psu]
  1021. REAL(wp), INTENT(in ), OPTIONAL :: pdep ! depth [m]
  1022. REAL(wp), INTENT(out) :: ptf ! freezing temperature [Celcius]
  1023. !
  1024. REAL(wp) :: zs ! local scalars
  1025. !!----------------------------------------------------------------------
  1026. !
  1027. SELECT CASE ( nn_eos )
  1028. !
  1029. CASE ( -1, 1 ) !== CT,SA (TEOS-10 formulation) ==!
  1030. !
  1031. zs = SQRT( ABS( psal ) / 35.16504_wp ) ! square root salinity
  1032. ptf = ((((1.46873e-03_wp*zs-9.64972e-03_wp)*zs+2.28348e-02_wp)*zs &
  1033. & - 3.12775e-02_wp)*zs+2.07679e-02_wp)*zs-5.87701e-02_wp
  1034. ptf = ptf * psal
  1035. !
  1036. IF( PRESENT( pdep ) ) ptf = ptf - 7.53e-4 * pdep
  1037. !
  1038. CASE ( 0 ) !== PT,SP (UNESCO formulation) ==!
  1039. !
  1040. ptf = ( - 0.0575_wp + 1.710523e-3_wp * SQRT( psal ) &
  1041. & - 2.154996e-4_wp * psal ) * psal
  1042. !
  1043. IF( PRESENT( pdep ) ) ptf = ptf - 7.53e-4 * pdep
  1044. !
  1045. CASE DEFAULT
  1046. IF(lwp) WRITE(numout,cform_err)
  1047. IF(lwp) WRITE(numout,*) ' bad flag value for nn_eos = ', nn_eos
  1048. nstop = nstop + 1
  1049. !
  1050. END SELECT
  1051. !
  1052. END SUBROUTINE eos_fzp_0d
  1053. SUBROUTINE eos_pen( pts, pab_pe, ppen )
  1054. !!----------------------------------------------------------------------
  1055. !! *** ROUTINE eos_pen ***
  1056. !!
  1057. !! ** Purpose : Calculates nonlinear anomalies of alpha_PE, beta_PE and PE at T-points
  1058. !!
  1059. !! ** Method : PE is defined analytically as the vertical
  1060. !! primitive of EOS times -g integrated between 0 and z>0.
  1061. !! pen is the nonlinear bsq-PE anomaly: pen = ( PE - rau0 gz ) / rau0 gz - rd
  1062. !! = 1/z * /int_0^z rd dz - rd
  1063. !! where rd is the density anomaly (see eos_rhd function)
  1064. !! ab_pe are partial derivatives of PE anomaly with respect to T and S:
  1065. !! ab_pe(1) = - 1/(rau0 gz) * dPE/dT + drd/dT = - d(pen)/dT
  1066. !! ab_pe(2) = 1/(rau0 gz) * dPE/dS + drd/dS = d(pen)/dS
  1067. !!
  1068. !! ** Action : - pen : PE anomaly given at T-points
  1069. !! : - pab_pe : given at T-points
  1070. !! pab_pe(:,:,:,jp_tem) is alpha_pe
  1071. !! pab_pe(:,:,:,jp_sal) is beta_pe
  1072. !!----------------------------------------------------------------------
  1073. REAL(wp), DIMENSION(jpi,jpj,jpk,jpts), INTENT(in ) :: pts ! pot. temperature & salinity
  1074. REAL(wp), DIMENSION(jpi,jpj,jpk,jpts), INTENT( out) :: pab_pe ! alpha_pe and beta_pe
  1075. REAL(wp), DIMENSION(jpi,jpj,jpk) , INTENT( out) :: ppen ! potential energy anomaly
  1076. !
  1077. INTEGER :: ji, jj, jk ! dummy loop indices
  1078. REAL(wp) :: zt , zh , zs , ztm ! local scalars
  1079. REAL(wp) :: zn , zn0, zn1, zn2 ! - -
  1080. !!----------------------------------------------------------------------
  1081. !
  1082. IF( nn_timing == 1 ) CALL timing_start('eos_pen')
  1083. !
  1084. SELECT CASE ( nn_eos )
  1085. !
  1086. CASE( -1, 0 ) !== polynomial TEOS-10 / EOS-80 ==!
  1087. !
  1088. DO jk = 1, jpkm1
  1089. DO jj = 1, jpj
  1090. DO ji = 1, jpi
  1091. !
  1092. zh = fsdept(ji,jj,jk) * r1_Z0 ! depth
  1093. zt = pts (ji,jj,jk,jp_tem) * r1_T0 ! temperature
  1094. zs = SQRT( ABS( pts(ji,jj,jk,jp_sal) + rdeltaS ) * r1_S0 ) ! square root salinity
  1095. ztm = tmask(ji,jj,jk) ! tmask
  1096. !
  1097. ! potential energy non-linear anomaly
  1098. zn2 = (PEN012)*zt &
  1099. & + PEN102*zs+PEN002
  1100. !
  1101. zn1 = ((PEN021)*zt &
  1102. & + PEN111*zs+PEN011)*zt &
  1103. & + (PEN201*zs+PEN101)*zs+PEN001
  1104. !
  1105. zn0 = ((((PEN040)*zt &
  1106. & + PEN130*zs+PEN030)*zt &
  1107. & + (PEN220*zs+PEN120)*zs+PEN020)*zt &
  1108. & + ((PEN310*zs+PEN210)*zs+PEN110)*zs+PEN010)*zt &
  1109. & + (((PEN400*zs+PEN300)*zs+PEN200)*zs+PEN100)*zs+PEN000
  1110. !
  1111. zn = ( zn2 * zh + zn1 ) * zh + zn0
  1112. !
  1113. ppen(ji,jj,jk) = zn * zh * r1_rau0 * ztm
  1114. !
  1115. ! alphaPE non-linear anomaly
  1116. zn2 = APE002
  1117. !
  1118. zn1 = (APE011)*zt &
  1119. & + APE101*zs+APE001
  1120. !
  1121. zn0 = (((APE030)*zt &
  1122. & + APE120*zs+APE020)*zt &
  1123. & + (APE210*zs+APE110)*zs+APE010)*zt &
  1124. & + ((APE300*zs+APE200)*zs+APE100)*zs+APE000
  1125. !
  1126. zn = ( zn2 * zh + zn1 ) * zh + zn0
  1127. !
  1128. pab_pe(ji,jj,jk,jp_tem) = zn * zh * r1_rau0 * ztm
  1129. !
  1130. ! betaPE non-linear anomaly
  1131. zn2 = BPE002
  1132. !
  1133. zn1 = (BPE011)*zt &
  1134. & + BPE101*zs+BPE001
  1135. !
  1136. zn0 = (((BPE030)*zt &
  1137. & + BPE120*zs+BPE020)*zt &
  1138. & + (BPE210*zs+BPE110)*zs+BPE010)*zt &
  1139. & + ((BPE300*zs+BPE200)*zs+BPE100)*zs+BPE000
  1140. !
  1141. zn = ( zn2 * zh + zn1 ) * zh + zn0
  1142. !
  1143. pab_pe(ji,jj,jk,jp_sal) = zn / zs * zh * r1_rau0 * ztm
  1144. !
  1145. END DO
  1146. END DO
  1147. END DO
  1148. !
  1149. CASE( 1 ) !== Vallis (2006) simplified EOS ==!
  1150. !
  1151. DO jk = 1, jpkm1
  1152. DO jj = 1, jpj
  1153. DO ji = 1, jpi
  1154. zt = pts(ji,jj,jk,jp_tem) - 10._wp ! temperature anomaly (t-T0)
  1155. zs = pts (ji,jj,jk,jp_sal) - 35._wp ! abs. salinity anomaly (s-S0)
  1156. zh = fsdept(ji,jj,jk) ! depth in meters at t-point
  1157. ztm = tmask(ji,jj,jk) ! tmask
  1158. zn = 0.5_wp * zh * r1_rau0 * ztm
  1159. ! ! Potential Energy
  1160. ppen(ji,jj,jk) = ( rn_a0 * rn_mu1 * zt + rn_b0 * rn_mu2 * zs ) * zn
  1161. ! ! alphaPE
  1162. pab_pe(ji,jj,jk,jp_tem) = - rn_a0 * rn_mu1 * zn
  1163. pab_pe(ji,jj,jk,jp_sal) = rn_b0 * rn_mu2 * zn
  1164. !
  1165. END DO
  1166. END DO
  1167. END DO
  1168. !
  1169. CASE DEFAULT
  1170. IF(lwp) WRITE(numout,cform_err)
  1171. IF(lwp) WRITE(numout,*) ' bad flag value for nn_eos = ', nn_eos
  1172. nstop = nstop + 1
  1173. !
  1174. END SELECT
  1175. !
  1176. IF( nn_timing == 1 ) CALL timing_stop('eos_pen')
  1177. !
  1178. END SUBROUTINE eos_pen
  1179. SUBROUTINE eos_init
  1180. !!----------------------------------------------------------------------
  1181. !! *** ROUTINE eos_init ***
  1182. !!
  1183. !! ** Purpose : initializations for the equation of state
  1184. !!
  1185. !! ** Method : Read the namelist nameos and control the parameters
  1186. !!----------------------------------------------------------------------
  1187. INTEGER :: ios ! local integer
  1188. !!
  1189. NAMELIST/nameos/ nn_eos, ln_useCT, rn_a0, rn_b0, rn_lambda1, rn_mu1, &
  1190. & rn_lambda2, rn_mu2, rn_nu
  1191. !!----------------------------------------------------------------------
  1192. !
  1193. REWIND( numnam_ref ) ! Namelist nameos in reference namelist : equation of state
  1194. READ ( numnam_ref, nameos, IOSTAT = ios, ERR = 901 )
  1195. 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'nameos in reference namelist', lwp )
  1196. !
  1197. REWIND( numnam_cfg ) ! Namelist nameos in configuration namelist : equation of state
  1198. READ ( numnam_cfg, nameos, IOSTAT = ios, ERR = 902 )
  1199. 902 IF( ios /= 0 ) CALL ctl_nam ( ios , 'nameos in configuration namelist', lwp )
  1200. IF(lwm) WRITE( numond, nameos )
  1201. !
  1202. rau0 = 1026._wp !: volumic mass of reference [kg/m3]
  1203. rcp = 3991.86795711963_wp !: heat capacity [J/K]
  1204. !
  1205. IF(lwp) THEN ! Control print
  1206. WRITE(numout,*)
  1207. WRITE(numout,*) 'eos_init : equation of state'
  1208. WRITE(numout,*) '~~~~~~~~'
  1209. WRITE(numout,*) ' Namelist nameos : set eos parameters'
  1210. WRITE(numout,*) ' flag for eq. of state and N^2 nn_eos = ', nn_eos
  1211. IF( ln_useCT ) THEN
  1212. WRITE(numout,*) ' model uses Conservative Temperature'
  1213. WRITE(numout,*) ' Important: model must be initialized with CT and SA fields'
  1214. ELSE
  1215. WRITE(numout,*) ' model does not use Conservative Temperature'
  1216. ENDIF
  1217. ENDIF
  1218. !
  1219. ! Consistency check on ln_useCT and nn_eos
  1220. IF ((nn_eos .EQ. -1) .AND. (.NOT. ln_useCT)) THEN
  1221. CALL ctl_stop("ln_useCT should be set to True if using TEOS-10 (nn_eos=-1)")
  1222. ELSE IF ((nn_eos .NE. -1) .AND. (ln_useCT)) THEN
  1223. CALL ctl_stop("ln_useCT should be set to False if using TEOS-80 or simplified equation of state (nn_eos=0 or nn_eos=1)")
  1224. ENDIF
  1225. !
  1226. SELECT CASE( nn_eos ) ! check option
  1227. !
  1228. CASE( -1 ) !== polynomial TEOS-10 ==!
  1229. IF(lwp) WRITE(numout,*)
  1230. IF(lwp) WRITE(numout,*) ' use of TEOS-10 equation of state (cons. temp. and abs. salinity)'
  1231. !
  1232. rdeltaS = 32._wp
  1233. r1_S0 = 0.875_wp/35.16504_wp
  1234. r1_T0 = 1._wp/40._wp
  1235. r1_Z0 = 1.e-4_wp
  1236. !
  1237. EOS000 = 8.0189615746e+02_wp
  1238. EOS100 = 8.6672408165e+02_wp
  1239. EOS200 = -1.7864682637e+03_wp
  1240. EOS300 = 2.0375295546e+03_wp
  1241. EOS400 = -1.2849161071e+03_wp
  1242. EOS500 = 4.3227585684e+02_wp
  1243. EOS600 = -6.0579916612e+01_wp
  1244. EOS010 = 2.6010145068e+01_wp
  1245. EOS110 = -6.5281885265e+01_wp
  1246. EOS210 = 8.1770425108e+01_wp
  1247. EOS310 = -5.6888046321e+01_wp
  1248. EOS410 = 1.7681814114e+01_wp
  1249. EOS510 = -1.9193502195_wp
  1250. EOS020 = -3.7074170417e+01_wp
  1251. EOS120 = 6.1548258127e+01_wp
  1252. EOS220 = -6.0362551501e+01_wp
  1253. EOS320 = 2.9130021253e+01_wp
  1254. EOS420 = -5.4723692739_wp
  1255. EOS030 = 2.1661789529e+01_wp
  1256. EOS130 = -3.3449108469e+01_wp
  1257. EOS230 = 1.9717078466e+01_wp
  1258. EOS330 = -3.1742946532_wp
  1259. EOS040 = -8.3627885467_wp
  1260. EOS140 = 1.1311538584e+01_wp
  1261. EOS240 = -5.3563304045_wp
  1262. EOS050 = 5.4048723791e-01_wp
  1263. EOS150 = 4.8169980163e-01_wp
  1264. EOS060 = -1.9083568888e-01_wp
  1265. EOS001 = 1.9681925209e+01_wp
  1266. EOS101 = -4.2549998214e+01_wp
  1267. EOS201 = 5.0774768218e+01_wp
  1268. EOS301 = -3.0938076334e+01_wp
  1269. EOS401 = 6.6051753097_wp
  1270. EOS011 = -1.3336301113e+01_wp
  1271. EOS111 = -4.4870114575_wp
  1272. EOS211 = 5.0042598061_wp
  1273. EOS311 = -6.5399043664e-01_wp
  1274. EOS021 = 6.7080479603_wp
  1275. EOS121 = 3.5063081279_wp
  1276. EOS221 = -1.8795372996_wp
  1277. EOS031 = -2.4649669534_wp
  1278. EOS131 = -5.5077101279e-01_wp
  1279. EOS041 = 5.5927935970e-01_wp
  1280. EOS002 = 2.0660924175_wp
  1281. EOS102 = -4.9527603989_wp
  1282. EOS202 = 2.5019633244_wp
  1283. EOS012 = 2.0564311499_wp
  1284. EOS112 = -2.1311365518e-01_wp
  1285. EOS022 = -1.2419983026_wp
  1286. EOS003 = -2.3342758797e-02_wp
  1287. EOS103 = -1.8507636718e-02_wp
  1288. EOS013 = 3.7969820455e-01_wp
  1289. !
  1290. ALP000 = -6.5025362670e-01_wp
  1291. ALP100 = 1.6320471316_wp
  1292. ALP200 = -2.0442606277_wp
  1293. ALP300 = 1.4222011580_wp
  1294. ALP400 = -4.4204535284e-01_wp
  1295. ALP500 = 4.7983755487e-02_wp
  1296. ALP010 = 1.8537085209_wp
  1297. ALP110 = -3.0774129064_wp
  1298. ALP210 = 3.0181275751_wp
  1299. ALP310 = -1.4565010626_wp
  1300. ALP410 = 2.7361846370e-01_wp
  1301. ALP020 = -1.6246342147_wp
  1302. ALP120 = 2.5086831352_wp
  1303. ALP220 = -1.4787808849_wp
  1304. ALP320 = 2.3807209899e-01_wp
  1305. ALP030 = 8.3627885467e-01_wp
  1306. ALP130 = -1.1311538584_wp
  1307. ALP230 = 5.3563304045e-01_wp
  1308. ALP040 = -6.7560904739e-02_wp
  1309. ALP140 = -6.0212475204e-02_wp
  1310. ALP050 = 2.8625353333e-02_wp
  1311. ALP001 = 3.3340752782e-01_wp
  1312. ALP101 = 1.1217528644e-01_wp
  1313. ALP201 = -1.2510649515e-01_wp
  1314. ALP301 = 1.6349760916e-02_wp
  1315. ALP011 = -3.3540239802e-01_wp
  1316. ALP111 = -1.7531540640e-01_wp
  1317. ALP211 = 9.3976864981e-02_wp
  1318. ALP021 = 1.8487252150e-01_wp
  1319. ALP121 = 4.1307825959e-02_wp
  1320. ALP031 = -5.5927935970e-02_wp
  1321. ALP002 = -5.1410778748e-02_wp
  1322. ALP102 = 5.3278413794e-03_wp
  1323. ALP012 = 6.2099915132e-02_wp
  1324. ALP003 = -9.4924551138e-03_wp
  1325. !
  1326. BET000 = 1.0783203594e+01_wp
  1327. BET100 = -4.4452095908e+01_wp
  1328. BET200 = 7.6048755820e+01_wp
  1329. BET300 = -6.3944280668e+01_wp
  1330. BET400 = 2.6890441098e+01_wp
  1331. BET500 = -4.5221697773_wp
  1332. BET010 = -8.1219372432e-01_wp
  1333. BET110 = 2.0346663041_wp
  1334. BET210 = -2.1232895170_wp
  1335. BET310 = 8.7994140485e-01_wp
  1336. BET410 = -1.1939638360e-01_wp
  1337. BET020 = 7.6574242289e-01_wp
  1338. BET120 = -1.5019813020_wp
  1339. BET220 = 1.0872489522_wp
  1340. BET320 = -2.7233429080e-01_wp
  1341. BET030 = -4.1615152308e-01_wp
  1342. BET130 = 4.9061350869e-01_wp
  1343. BET230 = -1.1847737788e-01_wp
  1344. BET040 = 1.4073062708e-01_wp
  1345. BET140 = -1.3327978879e-01_wp
  1346. BET050 = 5.9929880134e-03_wp
  1347. BET001 = -5.2937873009e-01_wp
  1348. BET101 = 1.2634116779_wp
  1349. BET201 = -1.1547328025_wp
  1350. BET301 = 3.2870876279e-01_wp
  1351. BET011 = -5.5824407214e-02_wp
  1352. BET111 = 1.2451933313e-01_wp
  1353. BET211 = -2.4409539932e-02_wp
  1354. BET021 = 4.3623149752e-02_wp
  1355. BET121 = -4.6767901790e-02_wp
  1356. BET031 = -6.8523260060e-03_wp
  1357. BET002 = -6.1618945251e-02_wp
  1358. BET102 = 6.2255521644e-02_wp
  1359. BET012 = -2.6514181169e-03_wp
  1360. BET003 = -2.3025968587e-04_wp
  1361. !
  1362. PEN000 = -9.8409626043_wp
  1363. PEN100 = 2.1274999107e+01_wp
  1364. PEN200 = -2.5387384109e+01_wp
  1365. PEN300 = 1.5469038167e+01_wp
  1366. PEN400 = -3.3025876549_wp
  1367. PEN010 = 6.6681505563_wp
  1368. PEN110 = 2.2435057288_wp
  1369. PEN210 = -2.5021299030_wp
  1370. PEN310 = 3.2699521832e-01_wp
  1371. PEN020 = -3.3540239802_wp
  1372. PEN120 = -1.7531540640_wp
  1373. PEN220 = 9.3976864981e-01_wp
  1374. PEN030 = 1.2324834767_wp
  1375. PEN130 = 2.7538550639e-01_wp
  1376. PEN040 = -2.7963967985e-01_wp
  1377. PEN001 = -1.3773949450_wp
  1378. PEN101 = 3.3018402659_wp
  1379. PEN201 = -1.6679755496_wp
  1380. PEN011 = -1.3709540999_wp
  1381. PEN111 = 1.4207577012e-01_wp
  1382. PEN021 = 8.2799886843e-01_wp
  1383. PEN002 = 1.7507069098e-02_wp
  1384. PEN102 = 1.3880727538e-02_wp
  1385. PEN012 = -2.8477365341e-01_wp
  1386. !
  1387. APE000 = -1.6670376391e-01_wp
  1388. APE100 = -5.6087643219e-02_wp
  1389. APE200 = 6.2553247576e-02_wp
  1390. APE300 = -8.1748804580e-03_wp
  1391. APE010 = 1.6770119901e-01_wp
  1392. APE110 = 8.7657703198e-02_wp
  1393. APE210 = -4.6988432490e-02_wp
  1394. APE020 = -9.2436260751e-02_wp
  1395. APE120 = -2.0653912979e-02_wp
  1396. APE030 = 2.7963967985e-02_wp
  1397. APE001 = 3.4273852498e-02_wp
  1398. APE101 = -3.5518942529e-03_wp
  1399. APE011 = -4.1399943421e-02_wp
  1400. APE002 = 7.1193413354e-03_wp
  1401. !
  1402. BPE000 = 2.6468936504e-01_wp
  1403. BPE100 = -6.3170583896e-01_wp
  1404. BPE200 = 5.7736640125e-01_wp
  1405. BPE300 = -1.6435438140e-01_wp
  1406. BPE010 = 2.7912203607e-02_wp
  1407. BPE110 = -6.2259666565e-02_wp
  1408. BPE210 = 1.2204769966e-02_wp
  1409. BPE020 = -2.1811574876e-02_wp
  1410. BPE120 = 2.3383950895e-02_wp
  1411. BPE030 = 3.4261630030e-03_wp
  1412. BPE001 = 4.1079296834e-02_wp
  1413. BPE101 = -4.1503681096e-02_wp
  1414. BPE011 = 1.7676120780e-03_wp
  1415. BPE002 = 1.7269476440e-04_wp
  1416. !
  1417. CASE( 0 ) !== polynomial EOS-80 formulation ==!
  1418. !
  1419. IF(lwp) WRITE(numout,*)
  1420. IF(lwp) WRITE(numout,*) ' use of EOS-80 equation of state (pot. temp. and pract. salinity)'
  1421. !
  1422. rdeltaS = 20._wp
  1423. r1_S0 = 1._wp/40._wp
  1424. r1_T0 = 1._wp/40._wp
  1425. r1_Z0 = 1.e-4_wp
  1426. !
  1427. EOS000 = 9.5356891948e+02_wp
  1428. EOS100 = 1.7136499189e+02_wp
  1429. EOS200 = -3.7501039454e+02_wp
  1430. EOS300 = 5.1856810420e+02_wp
  1431. EOS400 = -3.7264470465e+02_wp
  1432. EOS500 = 1.4302533998e+02_wp
  1433. EOS600 = -2.2856621162e+01_wp
  1434. EOS010 = 1.0087518651e+01_wp
  1435. EOS110 = -1.3647741861e+01_wp
  1436. EOS210 = 8.8478359933_wp
  1437. EOS310 = -7.2329388377_wp
  1438. EOS410 = 1.4774410611_wp
  1439. EOS510 = 2.0036720553e-01_wp
  1440. EOS020 = -2.5579830599e+01_wp
  1441. EOS120 = 2.4043512327e+01_wp
  1442. EOS220 = -1.6807503990e+01_wp
  1443. EOS320 = 8.3811577084_wp
  1444. EOS420 = -1.9771060192_wp
  1445. EOS030 = 1.6846451198e+01_wp
  1446. EOS130 = -2.1482926901e+01_wp
  1447. EOS230 = 1.0108954054e+01_wp
  1448. EOS330 = -6.2675951440e-01_wp
  1449. EOS040 = -8.0812310102_wp
  1450. EOS140 = 1.0102374985e+01_wp
  1451. EOS240 = -4.8340368631_wp
  1452. EOS050 = 1.2079167803_wp
  1453. EOS150 = 1.1515380987e-01_wp
  1454. EOS060 = -2.4520288837e-01_wp
  1455. EOS001 = 1.0748601068e+01_wp
  1456. EOS101 = -1.7817043500e+01_wp
  1457. EOS201 = 2.2181366768e+01_wp
  1458. EOS301 = -1.6750916338e+01_wp
  1459. EOS401 = 4.1202230403_wp
  1460. EOS011 = -1.5852644587e+01_wp
  1461. EOS111 = -7.6639383522e-01_wp
  1462. EOS211 = 4.1144627302_wp
  1463. EOS311 = -6.6955877448e-01_wp
  1464. EOS021 = 9.9994861860_wp
  1465. EOS121 = -1.9467067787e-01_wp
  1466. EOS221 = -1.2177554330_wp
  1467. EOS031 = -3.4866102017_wp
  1468. EOS131 = 2.2229155620e-01_wp
  1469. EOS041 = 5.9503008642e-01_wp
  1470. EOS002 = 1.0375676547_wp
  1471. EOS102 = -3.4249470629_wp
  1472. EOS202 = 2.0542026429_wp
  1473. EOS012 = 2.1836324814_wp
  1474. EOS112 = -3.4453674320e-01_wp
  1475. EOS022 = -1.2548163097_wp
  1476. EOS003 = 1.8729078427e-02_wp
  1477. EOS103 = -5.7238495240e-02_wp
  1478. EOS013 = 3.8306136687e-01_wp
  1479. !
  1480. ALP000 = -2.5218796628e-01_wp
  1481. ALP100 = 3.4119354654e-01_wp
  1482. ALP200 = -2.2119589983e-01_wp
  1483. ALP300 = 1.8082347094e-01_wp
  1484. ALP400 = -3.6936026529e-02_wp
  1485. ALP500 = -5.0091801383e-03_wp
  1486. ALP010 = 1.2789915300_wp
  1487. ALP110 = -1.2021756164_wp
  1488. ALP210 = 8.4037519952e-01_wp
  1489. ALP310 = -4.1905788542e-01_wp
  1490. ALP410 = 9.8855300959e-02_wp
  1491. ALP020 = -1.2634838399_wp
  1492. ALP120 = 1.6112195176_wp
  1493. ALP220 = -7.5817155402e-01_wp
  1494. ALP320 = 4.7006963580e-02_wp
  1495. ALP030 = 8.0812310102e-01_wp
  1496. ALP130 = -1.0102374985_wp
  1497. ALP230 = 4.8340368631e-01_wp
  1498. ALP040 = -1.5098959754e-01_wp
  1499. ALP140 = -1.4394226233e-02_wp
  1500. ALP050 = 3.6780433255e-02_wp
  1501. ALP001 = 3.9631611467e-01_wp
  1502. ALP101 = 1.9159845880e-02_wp
  1503. ALP201 = -1.0286156825e-01_wp
  1504. ALP301 = 1.6738969362e-02_wp
  1505. ALP011 = -4.9997430930e-01_wp
  1506. ALP111 = 9.7335338937e-03_wp
  1507. ALP211 = 6.0887771651e-02_wp
  1508. ALP021 = 2.6149576513e-01_wp
  1509. ALP121 = -1.6671866715e-02_wp
  1510. ALP031 = -5.9503008642e-02_wp
  1511. ALP002 = -5.4590812035e-02_wp
  1512. ALP102 = 8.6134185799e-03_wp
  1513. ALP012 = 6.2740815484e-02_wp
  1514. ALP003 = -9.5765341718e-03_wp
  1515. !
  1516. BET000 = 2.1420623987_wp
  1517. BET100 = -9.3752598635_wp
  1518. BET200 = 1.9446303907e+01_wp
  1519. BET300 = -1.8632235232e+01_wp
  1520. BET400 = 8.9390837485_wp
  1521. BET500 = -1.7142465871_wp
  1522. BET010 = -1.7059677327e-01_wp
  1523. BET110 = 2.2119589983e-01_wp
  1524. BET210 = -2.7123520642e-01_wp
  1525. BET310 = 7.3872053057e-02_wp
  1526. BET410 = 1.2522950346e-02_wp
  1527. BET020 = 3.0054390409e-01_wp
  1528. BET120 = -4.2018759976e-01_wp
  1529. BET220 = 3.1429341406e-01_wp
  1530. BET320 = -9.8855300959e-02_wp
  1531. BET030 = -2.6853658626e-01_wp
  1532. BET130 = 2.5272385134e-01_wp
  1533. BET230 = -2.3503481790e-02_wp
  1534. BET040 = 1.2627968731e-01_wp
  1535. BET140 = -1.2085092158e-01_wp
  1536. BET050 = 1.4394226233e-03_wp
  1537. BET001 = -2.2271304375e-01_wp
  1538. BET101 = 5.5453416919e-01_wp
  1539. BET201 = -6.2815936268e-01_wp
  1540. BET301 = 2.0601115202e-01_wp
  1541. BET011 = -9.5799229402e-03_wp
  1542. BET111 = 1.0286156825e-01_wp
  1543. BET211 = -2.5108454043e-02_wp
  1544. BET021 = -2.4333834734e-03_wp
  1545. BET121 = -3.0443885826e-02_wp
  1546. BET031 = 2.7786444526e-03_wp
  1547. BET002 = -4.2811838287e-02_wp
  1548. BET102 = 5.1355066072e-02_wp
  1549. BET012 = -4.3067092900e-03_wp
  1550. BET003 = -7.1548119050e-04_wp
  1551. !
  1552. PEN000 = -5.3743005340_wp
  1553. PEN100 = 8.9085217499_wp
  1554. PEN200 = -1.1090683384e+01_wp
  1555. PEN300 = 8.3754581690_wp
  1556. PEN400 = -2.0601115202_wp
  1557. PEN010 = 7.9263222935_wp
  1558. PEN110 = 3.8319691761e-01_wp
  1559. PEN210 = -2.0572313651_wp
  1560. PEN310 = 3.3477938724e-01_wp
  1561. PEN020 = -4.9997430930_wp
  1562. PEN120 = 9.7335338937e-02_wp
  1563. PEN220 = 6.0887771651e-01_wp
  1564. PEN030 = 1.7433051009_wp
  1565. PEN130 = -1.1114577810e-01_wp
  1566. PEN040 = -2.9751504321e-01_wp
  1567. PEN001 = -6.9171176978e-01_wp
  1568. PEN101 = 2.2832980419_wp
  1569. PEN201 = -1.3694684286_wp
  1570. PEN011 = -1.4557549876_wp
  1571. PEN111 = 2.2969116213e-01_wp
  1572. PEN021 = 8.3654420645e-01_wp
  1573. PEN002 = -1.4046808820e-02_wp
  1574. PEN102 = 4.2928871430e-02_wp
  1575. PEN012 = -2.8729602515e-01_wp
  1576. !
  1577. APE000 = -1.9815805734e-01_wp
  1578. APE100 = -9.5799229402e-03_wp
  1579. APE200 = 5.1430784127e-02_wp
  1580. APE300 = -8.3694846809e-03_wp
  1581. APE010 = 2.4998715465e-01_wp
  1582. APE110 = -4.8667669469e-03_wp
  1583. APE210 = -3.0443885826e-02_wp
  1584. APE020 = -1.3074788257e-01_wp
  1585. APE120 = 8.3359333577e-03_wp
  1586. APE030 = 2.9751504321e-02_wp
  1587. APE001 = 3.6393874690e-02_wp
  1588. APE101 = -5.7422790533e-03_wp
  1589. APE011 = -4.1827210323e-02_wp
  1590. APE002 = 7.1824006288e-03_wp
  1591. !
  1592. BPE000 = 1.1135652187e-01_wp
  1593. BPE100 = -2.7726708459e-01_wp
  1594. BPE200 = 3.1407968134e-01_wp
  1595. BPE300 = -1.0300557601e-01_wp
  1596. BPE010 = 4.7899614701e-03_wp
  1597. BPE110 = -5.1430784127e-02_wp
  1598. BPE210 = 1.2554227021e-02_wp
  1599. BPE020 = 1.2166917367e-03_wp
  1600. BPE120 = 1.5221942913e-02_wp
  1601. BPE030 = -1.3893222263e-03_wp
  1602. BPE001 = 2.8541225524e-02_wp
  1603. BPE101 = -3.4236710714e-02_wp
  1604. BPE011 = 2.8711395266e-03_wp
  1605. BPE002 = 5.3661089288e-04_wp
  1606. !
  1607. CASE( 1 ) !== Simplified EOS ==!
  1608. IF(lwp) THEN
  1609. WRITE(numout,*)
  1610. WRITE(numout,*) ' use of simplified eos: rhd(dT=T-10,dS=S-35,Z) = '
  1611. WRITE(numout,*) ' [-a0*(1+lambda1/2*dT+mu1*Z)*dT + b0*(1+lambda2/2*dT+mu2*Z)*dS - nu*dT*dS]/rau0'
  1612. WRITE(numout,*)
  1613. WRITE(numout,*) ' thermal exp. coef. rn_a0 = ', rn_a0
  1614. WRITE(numout,*) ' saline cont. coef. rn_b0 = ', rn_b0
  1615. WRITE(numout,*) ' cabbeling coef. rn_lambda1 = ', rn_lambda1
  1616. WRITE(numout,*) ' cabbeling coef. rn_lambda2 = ', rn_lambda2
  1617. WRITE(numout,*) ' thermobar. coef. rn_mu1 = ', rn_mu1
  1618. WRITE(numout,*) ' thermobar. coef. rn_mu2 = ', rn_mu2
  1619. WRITE(numout,*) ' 2nd cabbel. coef. rn_nu = ', rn_nu
  1620. WRITE(numout,*) ' Caution: rn_beta0=0 incompatible with ddm parameterization '
  1621. ENDIF
  1622. !
  1623. CASE DEFAULT !== ERROR in nn_eos ==!
  1624. WRITE(ctmp1,*) ' bad flag value for nn_eos = ', nn_eos
  1625. CALL ctl_stop( ctmp1 )
  1626. !
  1627. END SELECT
  1628. !
  1629. rau0_rcp = rau0 * rcp
  1630. r1_rau0 = 1._wp / rau0
  1631. r1_rcp = 1._wp / rcp
  1632. r1_rau0_rcp = 1._wp / rau0_rcp
  1633. !
  1634. IF(lwp) WRITE(numout,*)
  1635. IF(lwp) WRITE(numout,*) ' volumic mass of reference rau0 = ', rau0 , ' kg/m^3'
  1636. IF(lwp) WRITE(numout,*) ' 1. / rau0 r1_rau0 = ', r1_rau0, ' m^3/kg'
  1637. IF(lwp) WRITE(numout,*) ' ocean specific heat rcp = ', rcp , ' J/Kelvin'
  1638. IF(lwp) WRITE(numout,*) ' rau0 * rcp rau0_rcp = ', rau0_rcp
  1639. IF(lwp) WRITE(numout,*) ' 1. / ( rau0 * rcp ) r1_rau0_rcp = ', r1_rau0_rcp
  1640. !
  1641. END SUBROUTINE eos_init
  1642. !!======================================================================
  1643. END MODULE eosbn2