eosbn2.F90 77 KB

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