sbccpl.F90 133 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225
  1. MODULE sbccpl
  2. !!======================================================================
  3. !! *** MODULE sbccpl ***
  4. !! Surface Boundary Condition : momentum, heat and freshwater fluxes in coupled mode
  5. !!======================================================================
  6. !! History : 2.0 ! 2007-06 (R. Redler, N. Keenlyside, W. Park) Original code split into flxmod & taumod
  7. !! 3.0 ! 2008-02 (G. Madec, C Talandier) surface module
  8. !! 3.1 ! 2009_02 (G. Madec, S. Masson, E. Maisonave, A. Caubel) generic coupled interface
  9. !! 3.4 ! 2011_11 (C. Harris) more flexibility + multi-category fields
  10. !!----------------------------------------------------------------------
  11. !!----------------------------------------------------------------------
  12. !! namsbc_cpl : coupled formulation namlist
  13. !! sbc_cpl_init : initialisation of the coupled exchanges
  14. !! sbc_cpl_rcv : receive fields from the atmosphere over the ocean (ocean only)
  15. !! receive stress from the atmosphere over the ocean (ocean-ice case)
  16. !! sbc_cpl_ice_tau : receive stress from the atmosphere over ice
  17. !! sbc_cpl_ice_flx : receive fluxes from the atmosphere over ice
  18. !! sbc_cpl_snd : send fields to the atmosphere
  19. !!----------------------------------------------------------------------
  20. USE dom_oce ! ocean space and time domain
  21. USE sbc_oce ! Surface boundary condition: ocean fields
  22. USE sbc_ice ! Surface boundary condition: ice fields
  23. USE sbcapr
  24. USE sbcdcy ! surface boundary condition: diurnal cycle
  25. USE phycst ! physical constants
  26. #if defined key_lim3
  27. USE ice ! ice variables
  28. #endif
  29. #if defined key_lim2
  30. USE par_ice_2 ! ice parameters
  31. USE ice_2 ! ice variables
  32. #endif
  33. USE cpl_oasis3 ! OASIS3 coupling
  34. USE geo2ocean !
  35. USE oce , ONLY : tsn, un, vn, sshn, ub, vb, sshb, fraqsr_1lev
  36. USE albedo !
  37. USE in_out_manager ! I/O manager
  38. USE iom ! NetCDF library
  39. USE lib_mpp ! distribued memory computing library
  40. USE wrk_nemo ! work arrays
  41. USE timing ! Timing
  42. USE lbclnk ! ocean lateral boundary conditions (or mpp link)
  43. USE eosbn2
  44. USE sbcrnf , ONLY : l_rnfcpl
  45. USE sbcisf , ONLY : l_isfcpl
  46. #if defined key_cpl_carbon_cycle
  47. USE p4zflx, ONLY : oce_co2
  48. #endif
  49. #if defined key_cice
  50. USE ice_domain_size, only: ncat
  51. #endif
  52. #if defined key_lim3
  53. USE limthd_dh ! for CALL lim_thd_snwblow
  54. #endif
  55. USE fldread ! type FLD_N, FLD
  56. IMPLICIT NONE
  57. PRIVATE
  58. PUBLIC sbc_cpl_init ! routine called by sbcmod.F90
  59. PUBLIC sbc_cpl_rcv ! routine called by sbc_ice_lim(_2).F90
  60. PUBLIC sbc_cpl_snd ! routine called by step.F90
  61. PUBLIC sbc_cpl_ice_tau ! routine called by sbc_ice_lim(_2).F90
  62. PUBLIC sbc_cpl_ice_flx ! routine called by sbc_ice_lim(_2).F90
  63. PUBLIC sbc_cpl_alloc ! routine called in sbcice_cice.F90
  64. INTEGER, PARAMETER :: jpr_otx1 = 1 ! 3 atmosphere-ocean stress components on grid 1
  65. INTEGER, PARAMETER :: jpr_oty1 = 2 !
  66. INTEGER, PARAMETER :: jpr_otz1 = 3 !
  67. INTEGER, PARAMETER :: jpr_otx2 = 4 ! 3 atmosphere-ocean stress components on grid 2
  68. INTEGER, PARAMETER :: jpr_oty2 = 5 !
  69. INTEGER, PARAMETER :: jpr_otz2 = 6 !
  70. INTEGER, PARAMETER :: jpr_itx1 = 7 ! 3 atmosphere-ice stress components on grid 1
  71. INTEGER, PARAMETER :: jpr_ity1 = 8 !
  72. INTEGER, PARAMETER :: jpr_itz1 = 9 !
  73. INTEGER, PARAMETER :: jpr_itx2 = 10 ! 3 atmosphere-ice stress components on grid 2
  74. INTEGER, PARAMETER :: jpr_ity2 = 11 !
  75. INTEGER, PARAMETER :: jpr_itz2 = 12 !
  76. INTEGER, PARAMETER :: jpr_qsroce = 13 ! Qsr above the ocean
  77. INTEGER, PARAMETER :: jpr_qsrice = 14 ! Qsr above the ice
  78. INTEGER, PARAMETER :: jpr_qsrmix = 15
  79. INTEGER, PARAMETER :: jpr_qnsoce = 16 ! Qns above the ocean
  80. INTEGER, PARAMETER :: jpr_qnsice = 17 ! Qns above the ice
  81. INTEGER, PARAMETER :: jpr_qnsmix = 18
  82. INTEGER, PARAMETER :: jpr_rain = 19 ! total liquid precipitation (rain)
  83. INTEGER, PARAMETER :: jpr_snow = 20 ! solid precipitation over the ocean (snow)
  84. INTEGER, PARAMETER :: jpr_tevp = 21 ! total evaporation
  85. INTEGER, PARAMETER :: jpr_ievp = 22 ! solid evaporation (sublimation)
  86. INTEGER, PARAMETER :: jpr_sbpr = 23 ! sublimation - liquid precipitation - solid precipitation
  87. INTEGER, PARAMETER :: jpr_semp = 24 ! solid freshwater budget (sublimation - snow)
  88. INTEGER, PARAMETER :: jpr_oemp = 25 ! ocean freshwater budget (evap - precip)
  89. INTEGER, PARAMETER :: jpr_w10m = 26 ! 10m wind
  90. INTEGER, PARAMETER :: jpr_dqnsdt = 27 ! d(Q non solar)/d(temperature)
  91. INTEGER, PARAMETER :: jpr_rnf = 28 ! runoffs
  92. INTEGER, PARAMETER :: jpr_cal = 29 ! calving
  93. INTEGER, PARAMETER :: jpr_taum = 30 ! wind stress module
  94. INTEGER, PARAMETER :: jpr_co2 = 31
  95. INTEGER, PARAMETER :: jpr_topm = 32 ! topmeltn
  96. INTEGER, PARAMETER :: jpr_botm = 33 ! botmeltn
  97. INTEGER, PARAMETER :: jpr_sflx = 34 ! salt flux
  98. INTEGER, PARAMETER :: jpr_toce = 35 ! ocean temperature
  99. INTEGER, PARAMETER :: jpr_soce = 36 ! ocean salinity
  100. INTEGER, PARAMETER :: jpr_ocx1 = 37 ! ocean current on grid 1
  101. INTEGER, PARAMETER :: jpr_ocy1 = 38 !
  102. INTEGER, PARAMETER :: jpr_ssh = 39 ! sea surface height
  103. INTEGER, PARAMETER :: jpr_fice = 40 ! ice fraction
  104. INTEGER, PARAMETER :: jpr_e3t1st = 41 ! first T level thickness
  105. INTEGER, PARAMETER :: jpr_fraqsr = 42 ! fraction of solar net radiation absorbed in the first ocean level
  106. INTEGER, PARAMETER :: jpr_isf = 43
  107. INTEGER, PARAMETER :: jpr_icb = 44
  108. INTEGER, PARAMETER :: jprcv = 44 ! total number of fields received
  109. INTEGER, PARAMETER :: jps_fice = 1 ! ice fraction sent to the atmosphere
  110. INTEGER, PARAMETER :: jps_toce = 2 ! ocean temperature
  111. INTEGER, PARAMETER :: jps_tice = 3 ! ice temperature
  112. INTEGER, PARAMETER :: jps_tmix = 4 ! mixed temperature (ocean+ice)
  113. INTEGER, PARAMETER :: jps_albice = 5 ! ice albedo
  114. INTEGER, PARAMETER :: jps_albmix = 6 ! mixed albedo
  115. INTEGER, PARAMETER :: jps_hice = 7 ! ice thickness
  116. INTEGER, PARAMETER :: jps_hsnw = 8 ! snow thickness
  117. INTEGER, PARAMETER :: jps_ocx1 = 9 ! ocean current on grid 1
  118. INTEGER, PARAMETER :: jps_ocy1 = 10 !
  119. INTEGER, PARAMETER :: jps_ocz1 = 11 !
  120. INTEGER, PARAMETER :: jps_ivx1 = 12 ! ice current on grid 1
  121. INTEGER, PARAMETER :: jps_ivy1 = 13 !
  122. INTEGER, PARAMETER :: jps_ivz1 = 14 !
  123. INTEGER, PARAMETER :: jps_co2 = 15
  124. INTEGER, PARAMETER :: jps_soce = 16 ! ocean salinity
  125. INTEGER, PARAMETER :: jps_ssh = 17 ! sea surface height
  126. INTEGER, PARAMETER :: jps_qsroce = 18 ! Qsr above the ocean
  127. INTEGER, PARAMETER :: jps_qnsoce = 19 ! Qns above the ocean
  128. INTEGER, PARAMETER :: jps_oemp = 20 ! ocean freshwater budget (evap - precip)
  129. INTEGER, PARAMETER :: jps_sflx = 21 ! salt flux
  130. INTEGER, PARAMETER :: jps_otx1 = 22 ! 2 atmosphere-ocean stress components on grid 1
  131. INTEGER, PARAMETER :: jps_oty1 = 23 !
  132. INTEGER, PARAMETER :: jps_rnf = 24 ! runoffs
  133. INTEGER, PARAMETER :: jps_taum = 25 ! wind stress module
  134. INTEGER, PARAMETER :: jps_fice2 = 26 ! ice fraction sent to OPA (by SAS when doing SAS-OPA coupling)
  135. INTEGER, PARAMETER :: jps_e3t1st = 27 ! first level depth (vvl)
  136. INTEGER, PARAMETER :: jps_fraqsr = 28 ! fraction of solar net radiation absorbed in the first ocean level
  137. INTEGER, PARAMETER :: jpsnd = 28 ! total number of fields sended
  138. ! !!** namelist namsbc_cpl **
  139. TYPE :: FLD_C
  140. CHARACTER(len = 32) :: cldes ! desciption of the coupling strategy
  141. CHARACTER(len = 32) :: clcat ! multiple ice categories strategy
  142. CHARACTER(len = 32) :: clvref ! reference of vector ('spherical' or 'cartesian')
  143. CHARACTER(len = 32) :: clvor ! orientation of vector fields ('eastward-northward' or 'local grid')
  144. CHARACTER(len = 32) :: clvgrd ! grids on which is located the vector fields
  145. END TYPE FLD_C
  146. ! Send to the atmosphere !
  147. TYPE(FLD_C) :: sn_snd_temp, sn_snd_alb, sn_snd_thick, sn_snd_crt, sn_snd_co2
  148. ! Received from the atmosphere !
  149. TYPE(FLD_C) :: sn_rcv_w10m, sn_rcv_taumod, sn_rcv_tau, sn_rcv_dqnsdt, sn_rcv_qsr, sn_rcv_qns, sn_rcv_emp, sn_rcv_rnf
  150. TYPE(FLD_C) :: sn_rcv_cal, sn_rcv_iceflx, sn_rcv_co2, sn_rcv_icb, sn_rcv_isf
  151. ! Other namelist parameters !
  152. INTEGER :: nn_cplmodel ! Maximum number of models to/from which NEMO is potentialy sending/receiving data
  153. LOGICAL :: ln_usecplmask ! use a coupling mask file to merge data received from several models
  154. ! -> file cplmask.nc with the float variable called cplmask (jpi,jpj,nn_cplmodel)
  155. LOGICAL :: ln_force_windstress
  156. TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_tau_anom ! structure of input tau anomalies (file informations, fields read)
  157. TYPE :: DYNARR
  158. REAL(wp), POINTER, DIMENSION(:,:,:) :: z3
  159. END TYPE DYNARR
  160. TYPE( DYNARR ), SAVE, DIMENSION(jprcv) :: frcv ! all fields recieved from the atmosphere
  161. REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: albedo_oce_mix ! ocean albedo sent to atmosphere (mix clear/overcast sky)
  162. INTEGER , ALLOCATABLE, SAVE, DIMENSION( :) :: nrcvinfo ! OASIS info argument
  163. !! Substitution
  164. # include "domzgr_substitute.h90"
  165. # include "vectopt_loop_substitute.h90"
  166. !!----------------------------------------------------------------------
  167. !! NEMO/OPA 3.3 , NEMO Consortium (2010)
  168. !! $Id: sbccpl.F90 4990 2014-12-15 16:42:49Z timgraham $
  169. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  170. !!----------------------------------------------------------------------
  171. CONTAINS
  172. INTEGER FUNCTION sbc_cpl_alloc()
  173. !!----------------------------------------------------------------------
  174. !! *** FUNCTION sbc_cpl_alloc ***
  175. !!----------------------------------------------------------------------
  176. INTEGER :: ierr(3)
  177. !!----------------------------------------------------------------------
  178. ierr(:) = 0
  179. !
  180. ALLOCATE( albedo_oce_mix(jpi,jpj), nrcvinfo(jprcv), STAT=ierr(1) )
  181. #if ! defined key_lim3 && ! defined key_lim2 && ! defined key_cice
  182. ALLOCATE( a_i(jpi,jpj,1) , STAT=ierr(2) ) ! used in sbcice_if.F90 (done here as there is no sbc_ice_if_init)
  183. #endif
  184. ALLOCATE( xcplmask(jpi,jpj,0:nn_cplmodel) , STAT=ierr(3) )
  185. !
  186. sbc_cpl_alloc = MAXVAL( ierr )
  187. IF( lk_mpp ) CALL mpp_sum ( sbc_cpl_alloc )
  188. IF( sbc_cpl_alloc > 0 ) CALL ctl_warn('sbc_cpl_alloc: allocation of arrays failed')
  189. !
  190. END FUNCTION sbc_cpl_alloc
  191. SUBROUTINE sbc_cpl_init( k_ice )
  192. !!----------------------------------------------------------------------
  193. !! *** ROUTINE sbc_cpl_init ***
  194. !!
  195. !! ** Purpose : Initialisation of send and received information from
  196. !! the atmospheric component
  197. !!
  198. !! ** Method : * Read namsbc_cpl namelist
  199. !! * define the receive interface
  200. !! * define the send interface
  201. !! * initialise the OASIS coupler
  202. !!----------------------------------------------------------------------
  203. INTEGER, INTENT(in) :: k_ice ! ice management in the sbc (=0/1/2/3)
  204. !!
  205. INTEGER :: jn ! dummy loop index
  206. INTEGER :: ios ! Local integer output status for namelist read
  207. INTEGER :: inum
  208. INTEGER :: ierror ! Local integer output status for namelist read
  209. REAL(wp), POINTER, DIMENSION(:,:) :: zacs, zaos
  210. !!
  211. CHARACTER(len=256) :: cn_dir
  212. TYPE(FLD_N), DIMENSION(2) :: slf_i ! array of namelist informations on the fields to read
  213. TYPE(FLD_N) :: sn_tau_anom_u ! structure of input landfast ice mask (file informations, fields read)
  214. TYPE(FLD_N) :: sn_tau_anom_v
  215. !!
  216. NAMELIST/namsbc_cpl/ sn_snd_temp, sn_snd_alb , sn_snd_thick, sn_snd_crt , sn_snd_co2, &
  217. & sn_rcv_w10m, sn_rcv_taumod, sn_rcv_tau , sn_rcv_dqnsdt, sn_rcv_qsr, &
  218. & sn_rcv_qns , sn_rcv_emp , sn_rcv_rnf , sn_rcv_cal , sn_rcv_iceflx, &
  219. & sn_rcv_co2 , sn_rcv_icb , sn_rcv_isf, nn_cplmodel , ln_usecplmask, &
  220. & ln_force_windstress , cn_dir , sn_tau_anom_u , sn_tau_anom_v
  221. !!---------------------------------------------------------------------
  222. !
  223. IF( nn_timing == 1 ) CALL timing_start('sbc_cpl_init')
  224. !
  225. CALL wrk_alloc( jpi,jpj, zacs, zaos )
  226. ! ================================ !
  227. ! Namelist informations !
  228. ! ================================ !
  229. REWIND( numnam_ref ) ! Namelist namsbc_cpl in reference namelist : Variables for OASIS coupling
  230. READ ( numnam_ref, namsbc_cpl, IOSTAT = ios, ERR = 901)
  231. 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_cpl in reference namelist', lwp )
  232. REWIND( numnam_cfg ) ! Namelist namsbc_cpl in configuration namelist : Variables for OASIS coupling
  233. READ ( numnam_cfg, namsbc_cpl, IOSTAT = ios, ERR = 902 )
  234. 902 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_cpl in configuration namelist', lwp )
  235. IF(lwm) WRITE ( numond, namsbc_cpl )
  236. IF(lwp) THEN ! control print
  237. WRITE(numout,*)
  238. WRITE(numout,*)'sbc_cpl_init : namsbc_cpl namelist '
  239. WRITE(numout,*)'~~~~~~~~~~~~'
  240. ENDIF
  241. IF( lwp .AND. ln_cpl ) THEN ! control print
  242. WRITE(numout,*)' received fields (mutiple ice categogies)'
  243. WRITE(numout,*)' 10m wind module = ', TRIM(sn_rcv_w10m%cldes ), ' (', TRIM(sn_rcv_w10m%clcat ), ')'
  244. WRITE(numout,*)' stress module = ', TRIM(sn_rcv_taumod%cldes), ' (', TRIM(sn_rcv_taumod%clcat), ')'
  245. WRITE(numout,*)' surface stress = ', TRIM(sn_rcv_tau%cldes ), ' (', TRIM(sn_rcv_tau%clcat ), ')'
  246. WRITE(numout,*)' - referential = ', sn_rcv_tau%clvref
  247. WRITE(numout,*)' - orientation = ', sn_rcv_tau%clvor
  248. WRITE(numout,*)' - mesh = ', sn_rcv_tau%clvgrd
  249. WRITE(numout,*)' non-solar heat flux sensitivity = ', TRIM(sn_rcv_dqnsdt%cldes), ' (', TRIM(sn_rcv_dqnsdt%clcat), ')'
  250. WRITE(numout,*)' solar heat flux = ', TRIM(sn_rcv_qsr%cldes ), ' (', TRIM(sn_rcv_qsr%clcat ), ')'
  251. WRITE(numout,*)' non-solar heat flux = ', TRIM(sn_rcv_qns%cldes ), ' (', TRIM(sn_rcv_qns%clcat ), ')'
  252. WRITE(numout,*)' freshwater budget = ', TRIM(sn_rcv_emp%cldes ), ' (', TRIM(sn_rcv_emp%clcat ), ')'
  253. WRITE(numout,*)' runoffs = ', TRIM(sn_rcv_rnf%cldes ), ' (', TRIM(sn_rcv_rnf%clcat ), ')'
  254. WRITE(numout,*)' calving = ', TRIM(sn_rcv_cal%cldes ), ' (', TRIM(sn_rcv_cal%clcat ), ')'
  255. WRITE(numout,*)' iceberg = ', TRIM(sn_rcv_icb%cldes ), ' (', TRIM(sn_rcv_icb%clcat ), ')'
  256. WRITE(numout,*)' ice shelf = ', TRIM(sn_rcv_isf%cldes ), ' (', TRIM(sn_rcv_isf%clcat ), ')'
  257. WRITE(numout,*)' sea ice heat fluxes = ', TRIM(sn_rcv_iceflx%cldes), ' (', TRIM(sn_rcv_iceflx%clcat), ')'
  258. WRITE(numout,*)' atm co2 = ', TRIM(sn_rcv_co2%cldes ), ' (', TRIM(sn_rcv_co2%clcat ), ')'
  259. WRITE(numout,*)' sent fields (multiple ice categories)'
  260. WRITE(numout,*)' surface temperature = ', TRIM(sn_snd_temp%cldes ), ' (', TRIM(sn_snd_temp%clcat ), ')'
  261. WRITE(numout,*)' albedo = ', TRIM(sn_snd_alb%cldes ), ' (', TRIM(sn_snd_alb%clcat ), ')'
  262. WRITE(numout,*)' ice/snow thickness = ', TRIM(sn_snd_thick%cldes ), ' (', TRIM(sn_snd_thick%clcat ), ')'
  263. WRITE(numout,*)' surface current = ', TRIM(sn_snd_crt%cldes ), ' (', TRIM(sn_snd_crt%clcat ), ')'
  264. WRITE(numout,*)' - referential = ', sn_snd_crt%clvref
  265. WRITE(numout,*)' - orientation = ', sn_snd_crt%clvor
  266. WRITE(numout,*)' - mesh = ', sn_snd_crt%clvgrd
  267. WRITE(numout,*)' oce co2 flux = ', TRIM(sn_snd_co2%cldes ), ' (', TRIM(sn_snd_co2%clcat ), ')'
  268. WRITE(numout,*)' nn_cplmodel = ', nn_cplmodel
  269. WRITE(numout,*)' ln_usecplmask = ', ln_usecplmask
  270. WRITE(numout,*)' ln_force_windstress = ', ln_force_windstress
  271. IF ( ln_force_windstress ) THEN
  272. WRITE(numout,*)' path to anomalies files = ', TRIM(cn_dir)
  273. WRITE(numout,*)' type of anomalies files = ', TRIM(sn_tau_anom_u%cltype)
  274. WRITE(numout,*)' freq. of anomalies files = ', sn_tau_anom_u%nfreqh
  275. ENDIF
  276. ENDIF
  277. ! ! allocate sbccpl arrays
  278. IF( sbc_cpl_alloc() /= 0 ) CALL ctl_stop( 'STOP', 'sbc_cpl_alloc : unable to allocate arrays' )
  279. ! ================================ !
  280. ! Define the receive interface !
  281. ! ================================ !
  282. nrcvinfo(:) = OASIS_idle ! needed by nrcvinfo(jpr_otx1) if we do not receive ocean stress
  283. ! for each field: define the OASIS name (srcv(:)%clname)
  284. ! define receive or not from the namelist parameters (srcv(:)%laction)
  285. ! define the north fold type of lbc (srcv(:)%nsgn)
  286. ! default definitions of srcv
  287. srcv(:)%laction = .FALSE. ; srcv(:)%clgrid = 'T' ; srcv(:)%nsgn = 1. ; srcv(:)%nct = 1
  288. ! ! ------------------------- !
  289. ! ! ice and ocean wind stress !
  290. ! ! ------------------------- !
  291. ! ! Name
  292. srcv(jpr_otx1)%clname = 'O_OTaux1' ! 1st ocean component on grid ONE (T or U)
  293. srcv(jpr_oty1)%clname = 'O_OTauy1' ! 2nd - - - -
  294. srcv(jpr_otz1)%clname = 'O_OTauz1' ! 3rd - - - -
  295. srcv(jpr_otx2)%clname = 'O_OTaux2' ! 1st ocean component on grid TWO (V)
  296. srcv(jpr_oty2)%clname = 'O_OTauy2' ! 2nd - - - -
  297. srcv(jpr_otz2)%clname = 'O_OTauz2' ! 3rd - - - -
  298. !
  299. srcv(jpr_itx1)%clname = 'O_ITaux1' ! 1st ice component on grid ONE (T, F, I or U)
  300. srcv(jpr_ity1)%clname = 'O_ITauy1' ! 2nd - - - -
  301. srcv(jpr_itz1)%clname = 'O_ITauz1' ! 3rd - - - -
  302. srcv(jpr_itx2)%clname = 'O_ITaux2' ! 1st ice component on grid TWO (V)
  303. srcv(jpr_ity2)%clname = 'O_ITauy2' ! 2nd - - - -
  304. srcv(jpr_itz2)%clname = 'O_ITauz2' ! 3rd - - - -
  305. !
  306. ! Vectors: change of sign at north fold ONLY if on the local grid
  307. IF( TRIM( sn_rcv_tau%clvor ) == 'local grid' ) srcv(jpr_otx1:jpr_itz2)%nsgn = -1.
  308. ! ! Set grid and action
  309. SELECT CASE( TRIM( sn_rcv_tau%clvgrd ) ) ! 'T', 'U,V', 'U,V,I', 'U,V,F', 'T,I', 'T,F', or 'T,U,V'
  310. CASE( 'T' )
  311. srcv(jpr_otx1:jpr_itz2)%clgrid = 'T' ! oce and ice components given at T-point
  312. srcv(jpr_otx1:jpr_otz1)%laction = .TRUE. ! receive oce components on grid 1
  313. srcv(jpr_itx1:jpr_itz1)%laction = .TRUE. ! receive ice components on grid 1
  314. CASE( 'U,V' )
  315. srcv(jpr_otx1:jpr_otz1)%clgrid = 'U' ! oce components given at U-point
  316. srcv(jpr_otx2:jpr_otz2)%clgrid = 'V' ! and V-point
  317. srcv(jpr_itx1:jpr_itz1)%clgrid = 'U' ! ice components given at U-point
  318. srcv(jpr_itx2:jpr_itz2)%clgrid = 'V' ! and V-point
  319. srcv(jpr_otx1:jpr_itz2)%laction = .TRUE. ! receive oce and ice components on both grid 1 & 2
  320. CASE( 'U,V,T' )
  321. srcv(jpr_otx1:jpr_otz1)%clgrid = 'U' ! oce components given at U-point
  322. srcv(jpr_otx2:jpr_otz2)%clgrid = 'V' ! and V-point
  323. srcv(jpr_itx1:jpr_itz1)%clgrid = 'T' ! ice components given at T-point
  324. srcv(jpr_otx1:jpr_otz2)%laction = .TRUE. ! receive oce components on grid 1 & 2
  325. srcv(jpr_itx1:jpr_itz1)%laction = .TRUE. ! receive ice components on grid 1 only
  326. CASE( 'U,V,I' )
  327. srcv(jpr_otx1:jpr_otz1)%clgrid = 'U' ! oce components given at U-point
  328. srcv(jpr_otx2:jpr_otz2)%clgrid = 'V' ! and V-point
  329. srcv(jpr_itx1:jpr_itz1)%clgrid = 'I' ! ice components given at I-point
  330. srcv(jpr_otx1:jpr_otz2)%laction = .TRUE. ! receive oce components on grid 1 & 2
  331. srcv(jpr_itx1:jpr_itz1)%laction = .TRUE. ! receive ice components on grid 1 only
  332. CASE( 'U,V,F' )
  333. srcv(jpr_otx1:jpr_otz1)%clgrid = 'U' ! oce components given at U-point
  334. srcv(jpr_otx2:jpr_otz2)%clgrid = 'V' ! and V-point
  335. srcv(jpr_itx1:jpr_itz1)%clgrid = 'F' ! ice components given at F-point
  336. srcv(jpr_otx1:jpr_otz2)%laction = .TRUE. ! receive oce components on grid 1 & 2
  337. srcv(jpr_itx1:jpr_itz1)%laction = .TRUE. ! receive ice components on grid 1 only
  338. CASE( 'T,I' )
  339. srcv(jpr_otx1:jpr_itz2)%clgrid = 'T' ! oce and ice components given at T-point
  340. srcv(jpr_itx1:jpr_itz1)%clgrid = 'I' ! ice components given at I-point
  341. srcv(jpr_otx1:jpr_otz1)%laction = .TRUE. ! receive oce components on grid 1
  342. srcv(jpr_itx1:jpr_itz1)%laction = .TRUE. ! receive ice components on grid 1
  343. CASE( 'T,F' )
  344. srcv(jpr_otx1:jpr_itz2)%clgrid = 'T' ! oce and ice components given at T-point
  345. srcv(jpr_itx1:jpr_itz1)%clgrid = 'F' ! ice components given at F-point
  346. srcv(jpr_otx1:jpr_otz1)%laction = .TRUE. ! receive oce components on grid 1
  347. srcv(jpr_itx1:jpr_itz1)%laction = .TRUE. ! receive ice components on grid 1
  348. CASE( 'T,U,V' )
  349. srcv(jpr_otx1:jpr_otz1)%clgrid = 'T' ! oce components given at T-point
  350. srcv(jpr_itx1:jpr_itz1)%clgrid = 'U' ! ice components given at U-point
  351. srcv(jpr_itx2:jpr_itz2)%clgrid = 'V' ! and V-point
  352. srcv(jpr_otx1:jpr_otz1)%laction = .TRUE. ! receive oce components on grid 1 only
  353. srcv(jpr_itx1:jpr_itz2)%laction = .TRUE. ! receive ice components on grid 1 & 2
  354. CASE default
  355. CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_rcv_tau%clvgrd' )
  356. END SELECT
  357. !
  358. IF( TRIM( sn_rcv_tau%clvref ) == 'spherical' ) & ! spherical: 3rd component not received
  359. & srcv( (/jpr_otz1, jpr_otz2, jpr_itz1, jpr_itz2/) )%laction = .FALSE.
  360. !
  361. IF( TRIM( sn_rcv_tau%clvor ) == 'local grid' ) THEN ! already on local grid -> no need of the second grid
  362. srcv(jpr_otx2:jpr_otz2)%laction = .FALSE.
  363. srcv(jpr_itx2:jpr_itz2)%laction = .FALSE.
  364. srcv(jpr_oty1)%clgrid = srcv(jpr_oty2)%clgrid ! not needed but cleaner...
  365. srcv(jpr_ity1)%clgrid = srcv(jpr_ity2)%clgrid ! not needed but cleaner...
  366. ENDIF
  367. !
  368. IF( TRIM( sn_rcv_tau%cldes ) /= 'oce and ice' ) THEN ! 'oce and ice' case ocean stress on ocean mesh used
  369. srcv(jpr_itx1:jpr_itz2)%laction = .FALSE. ! ice components not received
  370. srcv(jpr_itx1)%clgrid = 'U' ! ocean stress used after its transformation
  371. srcv(jpr_ity1)%clgrid = 'V' ! i.e. it is always at U- & V-points for i- & j-comp. resp.
  372. ENDIF
  373. ! ! ------------------------- !
  374. ! ! freshwater budget ! E-P
  375. ! ! ------------------------- !
  376. ! we suppose that atmosphere modele do not make the difference between precipiration (liquide or solid)
  377. ! over ice of free ocean within the same atmospheric cell.cd
  378. srcv(jpr_rain)%clname = 'OTotRain' ! Rain = liquid precipitation
  379. srcv(jpr_snow)%clname = 'OTotSnow' ! Snow = solid precipitation
  380. srcv(jpr_tevp)%clname = 'OTotEvap' ! total evaporation (over oce + ice sublimation)
  381. srcv(jpr_ievp)%clname = 'OIceEvap' ! evaporation over ice = sublimation
  382. srcv(jpr_sbpr)%clname = 'OSubMPre' ! sublimation - liquid precipitation - solid precipitation
  383. srcv(jpr_semp)%clname = 'OISubMSn' ! ice solid water budget = sublimation - solid precipitation
  384. srcv(jpr_oemp)%clname = 'OOEvaMPr' ! ocean water budget = ocean Evap - ocean precip
  385. SELECT CASE( TRIM( sn_rcv_emp%cldes ) )
  386. CASE( 'none' ) ! nothing to do
  387. CASE( 'oce only' ) ; srcv( jpr_oemp )%laction = .TRUE.
  388. CASE( 'conservative' )
  389. srcv( (/jpr_rain, jpr_snow, jpr_ievp, jpr_tevp/) )%laction = .TRUE.
  390. IF ( k_ice <= 1 ) srcv(jpr_ievp)%laction = .FALSE.
  391. CASE( 'oce and ice' ) ; srcv( (/jpr_ievp, jpr_sbpr, jpr_semp, jpr_oemp/) )%laction = .TRUE.
  392. CASE default ; CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_rcv_emp%cldes' )
  393. END SELECT
  394. ! ! ---------------------------------------------------- !
  395. ! ! Runoffs, Calving, Iceberg, Iceshelf cavities !
  396. ! ! ---------------------------------------------------- !
  397. srcv(jpr_rnf )%clname = 'O_Runoff'
  398. IF( TRIM( sn_rcv_rnf%cldes ) == 'coupled' ) THEN
  399. srcv(jpr_rnf)%laction = .TRUE.
  400. l_rnfcpl = .TRUE. ! -> no need to read runoffs in sbcrnf
  401. ln_rnf = nn_components /= jp_iam_sas ! -> force to go through sbcrnf if not sas
  402. IF(lwp) WRITE(numout,*)
  403. IF(lwp) WRITE(numout,*) ' runoffs received from oasis -> force ln_rnf = ', ln_rnf
  404. ENDIF
  405. !
  406. srcv(jpr_cal)%clname = 'OCalving' ; IF( TRIM( sn_rcv_cal%cldes) == 'coupled' ) srcv(jpr_cal)%laction = .TRUE.
  407. srcv(jpr_isf)%clname = 'OIcshelf' ; IF( TRIM( sn_rcv_isf%cldes) == 'coupled' ) srcv(jpr_isf)%laction = .TRUE.
  408. srcv(jpr_icb)%clname = 'OIceberg' ; IF( TRIM( sn_rcv_icb%cldes) == 'coupled' ) srcv(jpr_icb)%laction = .TRUE.
  409. IF( srcv(jpr_isf)%laction .AND. nn_isf > 0 ) THEN
  410. l_isfcpl = .TRUE. ! -> no need to read isf in sbcisf
  411. IF(lwp) WRITE(numout,*)
  412. IF(lwp) WRITE(numout,*) ' iceshelf received from oasis '
  413. ENDIF
  414. ! ! ------------------------- !
  415. ! ! non solar radiation ! Qns
  416. ! ! ------------------------- !
  417. srcv(jpr_qnsoce)%clname = 'O_QnsOce'
  418. srcv(jpr_qnsice)%clname = 'O_QnsIce'
  419. srcv(jpr_qnsmix)%clname = 'O_QnsMix'
  420. SELECT CASE( TRIM( sn_rcv_qns%cldes ) )
  421. CASE( 'none' ) ! nothing to do
  422. CASE( 'oce only' ) ; srcv( jpr_qnsoce )%laction = .TRUE.
  423. CASE( 'conservative' ) ; srcv( (/jpr_qnsice, jpr_qnsmix/) )%laction = .TRUE.
  424. CASE( 'oce and ice' ) ; srcv( (/jpr_qnsice, jpr_qnsoce/) )%laction = .TRUE.
  425. CASE( 'mixed oce-ice' ) ; srcv( jpr_qnsmix )%laction = .TRUE.
  426. CASE default ; CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_rcv_qns%cldes' )
  427. END SELECT
  428. IF( TRIM( sn_rcv_qns%cldes ) == 'mixed oce-ice' .AND. jpl > 1 ) &
  429. CALL ctl_stop( 'sbc_cpl_init: sn_rcv_qns%cldes not currently allowed to be mixed oce-ice for multi-category ice' )
  430. ! ! ------------------------- !
  431. ! ! solar radiation ! Qsr
  432. ! ! ------------------------- !
  433. srcv(jpr_qsroce)%clname = 'O_QsrOce'
  434. srcv(jpr_qsrice)%clname = 'O_QsrIce'
  435. srcv(jpr_qsrmix)%clname = 'O_QsrMix'
  436. SELECT CASE( TRIM( sn_rcv_qsr%cldes ) )
  437. CASE( 'none' ) ! nothing to do
  438. CASE( 'oce only' ) ; srcv( jpr_qsroce )%laction = .TRUE.
  439. CASE( 'conservative' ) ; srcv( (/jpr_qsrice, jpr_qsrmix/) )%laction = .TRUE.
  440. CASE( 'oce and ice' ) ; srcv( (/jpr_qsrice, jpr_qsroce/) )%laction = .TRUE.
  441. CASE( 'mixed oce-ice' ) ; srcv( jpr_qsrmix )%laction = .TRUE.
  442. CASE default ; CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_rcv_qsr%cldes' )
  443. END SELECT
  444. IF( TRIM( sn_rcv_qsr%cldes ) == 'mixed oce-ice' .AND. jpl > 1 ) &
  445. CALL ctl_stop( 'sbc_cpl_init: sn_rcv_qsr%cldes not currently allowed to be mixed oce-ice for multi-category ice' )
  446. ! ! ------------------------- !
  447. ! ! non solar sensitivity ! d(Qns)/d(T)
  448. ! ! ------------------------- !
  449. srcv(jpr_dqnsdt)%clname = 'O_dQnsdT'
  450. IF( TRIM( sn_rcv_dqnsdt%cldes ) == 'coupled' ) srcv(jpr_dqnsdt)%laction = .TRUE.
  451. !
  452. ! non solar sensitivity mandatory for LIM ice model
  453. IF( TRIM( sn_rcv_dqnsdt%cldes ) == 'none' .AND. k_ice /= 0 .AND. k_ice /= 4 .AND. nn_components /= jp_iam_sas ) &
  454. CALL ctl_stop( 'sbc_cpl_init: sn_rcv_dqnsdt%cldes must be coupled in namsbc_cpl namelist' )
  455. ! non solar sensitivity mandatory for mixed oce-ice solar radiation coupling technique
  456. IF( TRIM( sn_rcv_dqnsdt%cldes ) == 'none' .AND. TRIM( sn_rcv_qns%cldes ) == 'mixed oce-ice' ) &
  457. CALL ctl_stop( 'sbc_cpl_init: namsbc_cpl namelist mismatch between sn_rcv_qns%cldes and sn_rcv_dqnsdt%cldes' )
  458. ! ! ------------------------- !
  459. ! ! 10m wind module !
  460. ! ! ------------------------- !
  461. srcv(jpr_w10m)%clname = 'O_Wind10' ; IF( TRIM(sn_rcv_w10m%cldes ) == 'coupled' ) srcv(jpr_w10m)%laction = .TRUE.
  462. !
  463. ! ! ------------------------- !
  464. ! ! wind stress module !
  465. ! ! ------------------------- !
  466. srcv(jpr_taum)%clname = 'O_TauMod' ; IF( TRIM(sn_rcv_taumod%cldes) == 'coupled' ) srcv(jpr_taum)%laction = .TRUE.
  467. lhftau = srcv(jpr_taum)%laction
  468. ! ! ------------------------- !
  469. ! ! Atmospheric CO2 !
  470. ! ! ------------------------- !
  471. srcv(jpr_co2 )%clname = 'O_AtmCO2' ; IF( TRIM(sn_rcv_co2%cldes ) == 'coupled' ) srcv(jpr_co2 )%laction = .TRUE.
  472. ! ! ------------------------- !
  473. ! ! topmelt and botmelt !
  474. ! ! ------------------------- !
  475. srcv(jpr_topm )%clname = 'OTopMlt'
  476. srcv(jpr_botm )%clname = 'OBotMlt'
  477. IF( TRIM(sn_rcv_iceflx%cldes) == 'coupled' ) THEN
  478. IF ( TRIM( sn_rcv_iceflx%clcat ) == 'yes' ) THEN
  479. srcv(jpr_topm:jpr_botm)%nct = jpl
  480. ELSE
  481. CALL ctl_stop( 'sbc_cpl_init: sn_rcv_iceflx%clcat should always be set to yes currently' )
  482. ENDIF
  483. srcv(jpr_topm:jpr_botm)%laction = .TRUE.
  484. ENDIF
  485. ! ! ------------------------------- !
  486. ! ! OPA-SAS coupling - rcv by opa !
  487. ! ! ------------------------------- !
  488. srcv(jpr_sflx)%clname = 'O_SFLX'
  489. srcv(jpr_fice)%clname = 'RIceFrc'
  490. !
  491. IF( nn_components == jp_iam_opa ) THEN ! OPA coupled to SAS via OASIS: force received field by OPA (sent by SAS)
  492. srcv(:)%laction = .FALSE. ! force default definition in case of opa <-> sas coupling
  493. srcv(:)%clgrid = 'T' ! force default definition in case of opa <-> sas coupling
  494. srcv(:)%nsgn = 1. ! force default definition in case of opa <-> sas coupling
  495. srcv( (/jpr_qsroce, jpr_qnsoce, jpr_oemp, jpr_sflx, jpr_fice, jpr_otx1, jpr_oty1, jpr_taum/) )%laction = .TRUE.
  496. srcv(jpr_otx1)%clgrid = 'U' ! oce components given at U-point
  497. srcv(jpr_oty1)%clgrid = 'V' ! and V-point
  498. ! Vectors: change of sign at north fold ONLY if on the local grid
  499. srcv( (/jpr_otx1,jpr_oty1/) )%nsgn = -1.
  500. sn_rcv_tau%clvgrd = 'U,V'
  501. sn_rcv_tau%clvor = 'local grid'
  502. sn_rcv_tau%clvref = 'spherical'
  503. sn_rcv_emp%cldes = 'oce only'
  504. !
  505. IF(lwp) THEN ! control print
  506. WRITE(numout,*)
  507. WRITE(numout,*)' Special conditions for SAS-OPA coupling '
  508. WRITE(numout,*)' OPA component '
  509. WRITE(numout,*)
  510. WRITE(numout,*)' received fields from SAS component '
  511. WRITE(numout,*)' ice cover '
  512. WRITE(numout,*)' oce only EMP '
  513. WRITE(numout,*)' salt flux '
  514. WRITE(numout,*)' mixed oce-ice solar flux '
  515. WRITE(numout,*)' mixed oce-ice non solar flux '
  516. WRITE(numout,*)' wind stress U,V on local grid and sperical coordinates '
  517. WRITE(numout,*)' wind stress module'
  518. WRITE(numout,*)
  519. ENDIF
  520. ENDIF
  521. ! ! -------------------------------- !
  522. ! ! OPA-SAS coupling - rcv by sas !
  523. ! ! -------------------------------- !
  524. srcv(jpr_toce )%clname = 'I_SSTSST'
  525. srcv(jpr_soce )%clname = 'I_SSSal'
  526. srcv(jpr_ocx1 )%clname = 'I_OCurx1'
  527. srcv(jpr_ocy1 )%clname = 'I_OCury1'
  528. srcv(jpr_ssh )%clname = 'I_SSHght'
  529. srcv(jpr_e3t1st)%clname = 'I_E3T1st'
  530. srcv(jpr_fraqsr)%clname = 'I_FraQsr'
  531. !
  532. IF( nn_components == jp_iam_sas ) THEN
  533. IF( .NOT. ln_cpl ) srcv(:)%laction = .FALSE. ! force default definition in case of opa <-> sas coupling
  534. IF( .NOT. ln_cpl ) srcv(:)%clgrid = 'T' ! force default definition in case of opa <-> sas coupling
  535. IF( .NOT. ln_cpl ) srcv(:)%nsgn = 1. ! force default definition in case of opa <-> sas coupling
  536. srcv( (/jpr_toce, jpr_soce, jpr_ssh, jpr_fraqsr, jpr_ocx1, jpr_ocy1/) )%laction = .TRUE.
  537. srcv( jpr_e3t1st )%laction = lk_vvl
  538. srcv(jpr_ocx1)%clgrid = 'U' ! oce components given at U-point
  539. srcv(jpr_ocy1)%clgrid = 'V' ! and V-point
  540. ! Vectors: change of sign at north fold ONLY if on the local grid
  541. srcv(jpr_ocx1:jpr_ocy1)%nsgn = -1.
  542. ! Change first letter to couple with atmosphere if already coupled OPA
  543. ! this is nedeed as each variable name used in the namcouple must be unique:
  544. ! for example O_Runoff received by OPA from SAS and therefore O_Runoff received by SAS from the Atmosphere
  545. DO jn = 1, jprcv
  546. IF ( srcv(jn)%clname(1:1) == "O" ) srcv(jn)%clname = "S"//srcv(jn)%clname(2:LEN(srcv(jn)%clname))
  547. END DO
  548. !
  549. IF(lwp) THEN ! control print
  550. WRITE(numout,*)
  551. WRITE(numout,*)' Special conditions for SAS-OPA coupling '
  552. WRITE(numout,*)' SAS component '
  553. WRITE(numout,*)
  554. IF( .NOT. ln_cpl ) THEN
  555. WRITE(numout,*)' received fields from OPA component '
  556. ELSE
  557. WRITE(numout,*)' Additional received fields from OPA component : '
  558. ENDIF
  559. WRITE(numout,*)' sea surface temperature (Celcius) '
  560. WRITE(numout,*)' sea surface salinity '
  561. WRITE(numout,*)' surface currents '
  562. WRITE(numout,*)' sea surface height '
  563. WRITE(numout,*)' thickness of first ocean T level '
  564. WRITE(numout,*)' fraction of solar net radiation absorbed in the first ocean level'
  565. WRITE(numout,*)
  566. ENDIF
  567. ENDIF
  568. ! =================================================== !
  569. ! Allocate all parts of frcv used for received fields !
  570. ! =================================================== !
  571. DO jn = 1, jprcv
  572. IF ( srcv(jn)%laction ) ALLOCATE( frcv(jn)%z3(jpi,jpj,srcv(jn)%nct) )
  573. END DO
  574. ! Allocate taum part of frcv which is used even when not received as coupling field
  575. IF ( .NOT. srcv(jpr_taum)%laction ) ALLOCATE( frcv(jpr_taum)%z3(jpi,jpj,srcv(jpr_taum)%nct) )
  576. ! Allocate w10m part of frcv which is used even when not received as coupling field
  577. IF ( .NOT. srcv(jpr_w10m)%laction ) ALLOCATE( frcv(jpr_w10m)%z3(jpi,jpj,srcv(jpr_w10m)%nct) )
  578. ! Allocate jpr_otx1 part of frcv which is used even when not received as coupling field
  579. IF ( .NOT. srcv(jpr_otx1)%laction ) ALLOCATE( frcv(jpr_otx1)%z3(jpi,jpj,srcv(jpr_otx1)%nct) )
  580. IF ( .NOT. srcv(jpr_oty1)%laction ) ALLOCATE( frcv(jpr_oty1)%z3(jpi,jpj,srcv(jpr_oty1)%nct) )
  581. ! Allocate itx1 and ity1 as they are used in sbc_cpl_ice_tau even if srcv(jpr_itx1)%laction = .FALSE.
  582. IF( k_ice /= 0 ) THEN
  583. IF ( .NOT. srcv(jpr_itx1)%laction ) ALLOCATE( frcv(jpr_itx1)%z3(jpi,jpj,srcv(jpr_itx1)%nct) )
  584. IF ( .NOT. srcv(jpr_ity1)%laction ) ALLOCATE( frcv(jpr_ity1)%z3(jpi,jpj,srcv(jpr_ity1)%nct) )
  585. END IF
  586. ! ================================ !
  587. ! Define the send interface !
  588. ! ================================ !
  589. ! for each field: define the OASIS name (ssnd(:)%clname)
  590. ! define send or not from the namelist parameters (ssnd(:)%laction)
  591. ! define the north fold type of lbc (ssnd(:)%nsgn)
  592. ! default definitions of nsnd
  593. ssnd(:)%laction = .FALSE. ; ssnd(:)%clgrid = 'T' ; ssnd(:)%nsgn = 1. ; ssnd(:)%nct = 1
  594. ! ! ------------------------- !
  595. ! ! Surface temperature !
  596. ! ! ------------------------- !
  597. ssnd(jps_toce)%clname = 'O_SSTSST'
  598. ssnd(jps_tice)%clname = 'O_TepIce'
  599. ssnd(jps_tmix)%clname = 'O_TepMix'
  600. SELECT CASE( TRIM( sn_snd_temp%cldes ) )
  601. CASE( 'none' ) ! nothing to do
  602. CASE( 'oce only' ) ; ssnd( jps_toce )%laction = .TRUE.
  603. CASE( 'oce and ice' , 'weighted oce and ice' )
  604. ssnd( (/jps_toce, jps_tice/) )%laction = .TRUE.
  605. IF ( TRIM( sn_snd_temp%clcat ) == 'yes' ) ssnd(jps_tice)%nct = jpl
  606. CASE( 'mixed oce-ice' ) ; ssnd( jps_tmix )%laction = .TRUE.
  607. CASE default ; CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_snd_temp%cldes' )
  608. END SELECT
  609. ! ! ------------------------- !
  610. ! ! Albedo !
  611. ! ! ------------------------- !
  612. ssnd(jps_albice)%clname = 'O_AlbIce'
  613. ssnd(jps_albmix)%clname = 'O_AlbMix'
  614. SELECT CASE( TRIM( sn_snd_alb%cldes ) )
  615. CASE( 'none' ) ! nothing to do
  616. CASE( 'ice' , 'weighted ice' ) ; ssnd(jps_albice)%laction = .TRUE.
  617. CASE( 'mixed oce-ice' ) ; ssnd(jps_albmix)%laction = .TRUE.
  618. CASE default ; CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_snd_alb%cldes' )
  619. END SELECT
  620. !
  621. ! Need to calculate oceanic albedo if
  622. ! 1. sending mixed oce-ice or ice albedo or
  623. ! 2. receiving mixed oce-ice solar radiation
  624. IF ( TRIM ( sn_snd_alb%cldes ) == 'mixed oce-ice' &
  625. & .OR. TRIM ( sn_snd_alb%cldes ) == 'ice' &
  626. & .OR. TRIM ( sn_rcv_qsr%cldes ) == 'mixed oce-ice' ) THEN
  627. CALL albedo_oce( zaos, zacs )
  628. ! Due to lack of information on nebulosity : mean clear/overcast sky
  629. albedo_oce_mix(:,:) = ( zacs(:,:) + zaos(:,:) ) * 0.5
  630. ENDIF
  631. ! ! ------------------------- !
  632. ! ! Ice fraction & Thickness !
  633. ! ! ------------------------- !
  634. ssnd(jps_fice)%clname = 'OIceFrc'
  635. ssnd(jps_hice)%clname = 'OIceTck'
  636. ssnd(jps_hsnw)%clname = 'OSnwTck'
  637. IF( k_ice /= 0 ) THEN
  638. ssnd(jps_fice)%laction = .TRUE. ! if ice treated in the ocean (even in climato case)
  639. ! Currently no namelist entry to determine sending of multi-category ice fraction so use the thickness entry for now
  640. IF ( TRIM( sn_snd_thick%clcat ) == 'yes' ) ssnd(jps_fice)%nct = jpl
  641. ENDIF
  642. SELECT CASE ( TRIM( sn_snd_thick%cldes ) )
  643. CASE( 'none' ) ! nothing to do
  644. CASE( 'ice and snow' )
  645. ssnd(jps_hice:jps_hsnw)%laction = .TRUE.
  646. IF ( TRIM( sn_snd_thick%clcat ) == 'yes' ) THEN
  647. ssnd(jps_hice:jps_hsnw)%nct = jpl
  648. ENDIF
  649. CASE ( 'weighted ice and snow' )
  650. ssnd(jps_hice:jps_hsnw)%laction = .TRUE.
  651. IF ( TRIM( sn_snd_thick%clcat ) == 'yes' ) ssnd(jps_hice:jps_hsnw)%nct = jpl
  652. CASE default ; CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_snd_thick%cldes' )
  653. END SELECT
  654. ! ! ------------------------- !
  655. ! ! Surface current !
  656. ! ! ------------------------- !
  657. ! ocean currents ! ice velocities
  658. ssnd(jps_ocx1)%clname = 'O_OCurx1' ; ssnd(jps_ivx1)%clname = 'O_IVelx1'
  659. ssnd(jps_ocy1)%clname = 'O_OCury1' ; ssnd(jps_ivy1)%clname = 'O_IVely1'
  660. ssnd(jps_ocz1)%clname = 'O_OCurz1' ; ssnd(jps_ivz1)%clname = 'O_IVelz1'
  661. !
  662. ssnd(jps_ocx1:jps_ivz1)%nsgn = -1. ! vectors: change of the sign at the north fold
  663. IF( sn_snd_crt%clvgrd == 'U,V' ) THEN
  664. ssnd(jps_ocx1)%clgrid = 'U' ; ssnd(jps_ocy1)%clgrid = 'V'
  665. ELSE IF( sn_snd_crt%clvgrd /= 'T' ) THEN
  666. CALL ctl_stop( 'sn_snd_crt%clvgrd must be equal to T' )
  667. ssnd(jps_ocx1:jps_ivz1)%clgrid = 'T' ! all oce and ice components on the same unique grid
  668. ENDIF
  669. ssnd(jps_ocx1:jps_ivz1)%laction = .TRUE. ! default: all are send
  670. IF( TRIM( sn_snd_crt%clvref ) == 'spherical' ) ssnd( (/jps_ocz1, jps_ivz1/) )%laction = .FALSE.
  671. IF( TRIM( sn_snd_crt%clvor ) == 'eastward-northward' ) ssnd(jps_ocx1:jps_ivz1)%nsgn = 1.
  672. SELECT CASE( TRIM( sn_snd_crt%cldes ) )
  673. CASE( 'none' ) ; ssnd(jps_ocx1:jps_ivz1)%laction = .FALSE.
  674. CASE( 'oce only' ) ; ssnd(jps_ivx1:jps_ivz1)%laction = .FALSE.
  675. CASE( 'weighted oce and ice' ) ! nothing to do
  676. CASE( 'mixed oce-ice' ) ; ssnd(jps_ivx1:jps_ivz1)%laction = .FALSE.
  677. CASE default ; CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_snd_crt%cldes' )
  678. END SELECT
  679. ! ! ------------------------- !
  680. ! ! CO2 flux !
  681. ! ! ------------------------- !
  682. ssnd(jps_co2)%clname = 'O_CO2FLX' ; IF( TRIM(sn_snd_co2%cldes) == 'coupled' ) ssnd(jps_co2 )%laction = .TRUE.
  683. ! ! ------------------------------- !
  684. ! ! OPA-SAS coupling - snd by opa !
  685. ! ! ------------------------------- !
  686. ssnd(jps_ssh )%clname = 'O_SSHght'
  687. ssnd(jps_soce )%clname = 'O_SSSal'
  688. ssnd(jps_e3t1st)%clname = 'O_E3T1st'
  689. ssnd(jps_fraqsr)%clname = 'O_FraQsr'
  690. !
  691. IF( nn_components == jp_iam_opa ) THEN
  692. ssnd(:)%laction = .FALSE. ! force default definition in case of opa <-> sas coupling
  693. ssnd( (/jps_toce, jps_soce, jps_ssh, jps_fraqsr, jps_ocx1, jps_ocy1/) )%laction = .TRUE.
  694. ssnd( jps_e3t1st )%laction = lk_vvl
  695. ! vector definition: not used but cleaner...
  696. ssnd(jps_ocx1)%clgrid = 'U' ! oce components given at U-point
  697. ssnd(jps_ocy1)%clgrid = 'V' ! and V-point
  698. sn_snd_crt%clvgrd = 'U,V'
  699. sn_snd_crt%clvor = 'local grid'
  700. sn_snd_crt%clvref = 'spherical'
  701. !
  702. IF(lwp) THEN ! control print
  703. WRITE(numout,*)
  704. WRITE(numout,*)' sent fields to SAS component '
  705. WRITE(numout,*)' sea surface temperature (T before, Celcius) '
  706. WRITE(numout,*)' sea surface salinity '
  707. WRITE(numout,*)' surface currents U,V on local grid and spherical coordinates'
  708. WRITE(numout,*)' sea surface height '
  709. WRITE(numout,*)' thickness of first ocean T level '
  710. WRITE(numout,*)' fraction of solar net radiation absorbed in the first ocean level'
  711. WRITE(numout,*)
  712. ENDIF
  713. ENDIF
  714. ! ! ------------------------------- !
  715. ! ! OPA-SAS coupling - snd by sas !
  716. ! ! ------------------------------- !
  717. ssnd(jps_sflx )%clname = 'I_SFLX'
  718. ssnd(jps_fice2 )%clname = 'IIceFrc'
  719. ssnd(jps_qsroce)%clname = 'I_QsrOce'
  720. ssnd(jps_qnsoce)%clname = 'I_QnsOce'
  721. ssnd(jps_oemp )%clname = 'IOEvaMPr'
  722. ssnd(jps_otx1 )%clname = 'I_OTaux1'
  723. ssnd(jps_oty1 )%clname = 'I_OTauy1'
  724. ssnd(jps_rnf )%clname = 'I_Runoff'
  725. ssnd(jps_taum )%clname = 'I_TauMod'
  726. !
  727. IF( nn_components == jp_iam_sas ) THEN
  728. IF( .NOT. ln_cpl ) ssnd(:)%laction = .FALSE. ! force default definition in case of opa <-> sas coupling
  729. ssnd( (/jps_qsroce, jps_qnsoce, jps_oemp, jps_fice2, jps_sflx, jps_otx1, jps_oty1, jps_taum/) )%laction = .TRUE.
  730. !
  731. ! Change first letter to couple with atmosphere if already coupled with sea_ice
  732. ! this is nedeed as each variable name used in the namcouple must be unique:
  733. ! for example O_SSTSST sent by OPA to SAS and therefore S_SSTSST sent by SAS to the Atmosphere
  734. DO jn = 1, jpsnd
  735. IF ( ssnd(jn)%clname(1:1) == "O" ) ssnd(jn)%clname = "S"//ssnd(jn)%clname(2:LEN(ssnd(jn)%clname))
  736. END DO
  737. !
  738. IF(lwp) THEN ! control print
  739. WRITE(numout,*)
  740. IF( .NOT. ln_cpl ) THEN
  741. WRITE(numout,*)' sent fields to OPA component '
  742. ELSE
  743. WRITE(numout,*)' Additional sent fields to OPA component : '
  744. ENDIF
  745. WRITE(numout,*)' ice cover '
  746. WRITE(numout,*)' oce only EMP '
  747. WRITE(numout,*)' salt flux '
  748. WRITE(numout,*)' mixed oce-ice solar flux '
  749. WRITE(numout,*)' mixed oce-ice non solar flux '
  750. WRITE(numout,*)' wind stress U,V components'
  751. WRITE(numout,*)' wind stress module'
  752. ENDIF
  753. ENDIF
  754. IF ( ln_force_windstress ) THEN
  755. slf_i(1) = sn_tau_anom_u ; slf_i(2) = sn_tau_anom_v
  756. ALLOCATE( sf_tau_anom(2), STAT=ierror )
  757. IF( ierror > 0 ) THEN
  758. CALL ctl_stop( 'sbc_cpl_init: unable to allocate sf_tau_anom structure' ) ; RETURN
  759. ENDIF
  760. DO jn= 1, 2
  761. ALLOCATE( sf_tau_anom(jn)%fnow(jpi,jpj,1) )
  762. IF( slf_i(jn)%ln_tint ) ALLOCATE( sf_tau_anom(jn)%fdta(jpi,jpj,1,2) )
  763. IF(lwp) WRITE(numout,*) jpi,jpj
  764. IF( TRIM(slf_i(jn)%clname) == 'NOT USED' ) sf_tau_anom(jn)%fnow(:,:,1) = 0._wp ! not used field (set to 0)
  765. END DO
  766. !
  767. CALL fld_fill( sf_tau_anom, slf_i, cn_dir, 'sbc_cpl_init', &
  768. & 'tau from anomalies data', 'sbccpl' )
  769. ENDIF
  770. !
  771. ! ================================ !
  772. ! initialisation of the coupler !
  773. ! ================================ !
  774. CALL cpl_define(jprcv, jpsnd, nn_cplmodel)
  775. IF (ln_usecplmask) THEN
  776. xcplmask(:,:,:) = 0.
  777. CALL iom_open( 'cplmask', inum )
  778. CALL iom_get( inum, jpdom_unknown, 'cplmask', xcplmask(1:nlci,1:nlcj,1:nn_cplmodel), &
  779. & kstart = (/ mig(1),mjg(1),1 /), kcount = (/ nlci,nlcj,nn_cplmodel /) )
  780. CALL iom_close( inum )
  781. ELSE
  782. xcplmask(:,:,:) = 1.
  783. ENDIF
  784. xcplmask(:,:,0) = 1. - SUM( xcplmask(:,:,1:nn_cplmodel), dim = 3 )
  785. !
  786. ncpl_qsr_freq = cpl_freq( 'O_QsrOce' ) + cpl_freq( 'O_QsrMix' ) + cpl_freq( 'I_QsrOce' ) + cpl_freq( 'I_QsrMix' )
  787. IF( ln_dm2dc .AND. ln_cpl .AND. ncpl_qsr_freq /= 86400 ) &
  788. & CALL ctl_stop( 'sbc_cpl_init: diurnal cycle reconstruction (ln_dm2dc) needs daily couping for solar radiation' )
  789. ncpl_qsr_freq = 86400 / ncpl_qsr_freq
  790. CALL wrk_dealloc( jpi,jpj, zacs, zaos )
  791. !
  792. IF( nn_timing == 1 ) CALL timing_stop('sbc_cpl_init')
  793. !
  794. END SUBROUTINE sbc_cpl_init
  795. SUBROUTINE sbc_cpl_rcv( kt, k_fsbc, k_ice )
  796. !!----------------------------------------------------------------------
  797. !! *** ROUTINE sbc_cpl_rcv ***
  798. !!
  799. !! ** Purpose : provide the stress over the ocean and, if no sea-ice,
  800. !! provide the ocean heat and freshwater fluxes.
  801. !!
  802. !! ** Method : - Receive all the atmospheric fields (stored in frcv array). called at each time step.
  803. !! OASIS controls if there is something do receive or not. nrcvinfo contains the info
  804. !! to know if the field was really received or not
  805. !!
  806. !! --> If ocean stress was really received:
  807. !!
  808. !! - transform the received ocean stress vector from the received
  809. !! referential and grid into an atmosphere-ocean stress in
  810. !! the (i,j) ocean referencial and at the ocean velocity point.
  811. !! The received stress are :
  812. !! - defined by 3 components (if cartesian coordinate)
  813. !! or by 2 components (if spherical)
  814. !! - oriented along geographical coordinate (if eastward-northward)
  815. !! or along the local grid coordinate (if local grid)
  816. !! - given at U- and V-point, resp. if received on 2 grids
  817. !! or at T-point if received on 1 grid
  818. !! Therefore and if necessary, they are successively
  819. !! processed in order to obtain them
  820. !! first as 2 components on the sphere
  821. !! second as 2 components oriented along the local grid
  822. !! third as 2 components on the U,V grid
  823. !!
  824. !! -->
  825. !!
  826. !! - In 'ocean only' case, non solar and solar ocean heat fluxes
  827. !! and total ocean freshwater fluxes
  828. !!
  829. !! ** Method : receive all fields from the atmosphere and transform
  830. !! them into ocean surface boundary condition fields
  831. !!
  832. !! ** Action : update utau, vtau ocean stress at U,V grid
  833. !! taum wind stress module at T-point
  834. !! wndm wind speed module at T-point over free ocean or leads in presence of sea-ice
  835. !! qns non solar heat fluxes including emp heat content (ocean only case)
  836. !! and the latent heat flux of solid precip. melting
  837. !! qsr solar ocean heat fluxes (ocean only case)
  838. !! emp upward mass flux [evap. - precip. (- runoffs) (- calving)] (ocean only case)
  839. !!----------------------------------------------------------------------
  840. INTEGER, INTENT(in) :: kt ! ocean model time step index
  841. INTEGER, INTENT(in) :: k_fsbc ! frequency of sbc (-> ice model) computation
  842. INTEGER, INTENT(in) :: k_ice ! ice management in the sbc (=0/1/2/3)
  843. !!
  844. LOGICAL :: llnewtx, llnewtau ! update wind stress components and module??
  845. INTEGER :: ji, jj, jn ! dummy loop indices
  846. INTEGER :: isec ! number of seconds since nit000 (assuming rdttra did not change since nit000)
  847. REAL(wp) :: zcumulneg, zcumulpos ! temporary scalars
  848. REAL(wp) :: zcoef ! temporary scalar
  849. REAL(wp) :: zrhoa = 1.22 ! Air density kg/m3
  850. REAL(wp) :: zcdrag = 1.5e-3 ! drag coefficient
  851. REAL(wp) :: zzx, zzy ! temporary variables
  852. REAL(wp), POINTER, DIMENSION(:,:) :: ztx, zty, zmsk, zemp, zqns, zqsr
  853. !!----------------------------------------------------------------------
  854. !
  855. IF( nn_timing == 1 ) CALL timing_start('sbc_cpl_rcv')
  856. !
  857. CALL wrk_alloc( jpi,jpj, ztx, zty, zmsk, zemp, zqns, zqsr )
  858. !
  859. IF( ln_mixcpl ) zmsk(:,:) = 1. - xcplmask(:,:,0)
  860. !
  861. ! ! ======================================================= !
  862. ! ! Receive all the atmos. fields (including ice information)
  863. ! ! ======================================================= !
  864. isec = ( kt - nit000 ) * NINT( rdttra(1) ) ! date of exchanges
  865. DO jn = 1, jprcv ! received fields sent by the atmosphere
  866. IF( srcv(jn)%laction ) CALL cpl_rcv( jn, isec, frcv(jn)%z3, xcplmask(:,:,1:nn_cplmodel), nrcvinfo(jn) )
  867. END DO
  868. ! ! ========================= !
  869. IF( srcv(jpr_otx1)%laction ) THEN ! ocean stress components !
  870. ! ! ========================= !
  871. ! define frcv(jpr_otx1)%z3(:,:,1) and frcv(jpr_oty1)%z3(:,:,1): stress at U/V point along model grid
  872. ! => need to be done only when we receive the field
  873. IF( nrcvinfo(jpr_otx1) == OASIS_Rcv ) THEN
  874. !
  875. IF( TRIM( sn_rcv_tau%clvref ) == 'cartesian' ) THEN ! 2 components on the sphere
  876. ! ! (cartesian to spherical -> 3 to 2 components)
  877. !
  878. CALL geo2oce( frcv(jpr_otx1)%z3(:,:,1), frcv(jpr_oty1)%z3(:,:,1), frcv(jpr_otz1)%z3(:,:,1), &
  879. & srcv(jpr_otx1)%clgrid, ztx, zty )
  880. frcv(jpr_otx1)%z3(:,:,1) = ztx(:,:) ! overwrite 1st comp. on the 1st grid
  881. frcv(jpr_oty1)%z3(:,:,1) = zty(:,:) ! overwrite 2nd comp. on the 1st grid
  882. !
  883. IF( srcv(jpr_otx2)%laction ) THEN
  884. CALL geo2oce( frcv(jpr_otx2)%z3(:,:,1), frcv(jpr_oty2)%z3(:,:,1), frcv(jpr_otz2)%z3(:,:,1), &
  885. & srcv(jpr_otx2)%clgrid, ztx, zty )
  886. frcv(jpr_otx2)%z3(:,:,1) = ztx(:,:) ! overwrite 1st comp. on the 2nd grid
  887. frcv(jpr_oty2)%z3(:,:,1) = zty(:,:) ! overwrite 2nd comp. on the 2nd grid
  888. ENDIF
  889. !
  890. ENDIF
  891. !
  892. IF( TRIM( sn_rcv_tau%clvor ) == 'eastward-northward' ) THEN ! 2 components oriented along the local grid
  893. ! ! (geographical to local grid -> rotate the components)
  894. CALL rot_rep( frcv(jpr_otx1)%z3(:,:,1), frcv(jpr_oty1)%z3(:,:,1), srcv(jpr_otx1)%clgrid, 'en->i', ztx )
  895. IF( srcv(jpr_otx2)%laction ) THEN
  896. CALL rot_rep( frcv(jpr_otx2)%z3(:,:,1), frcv(jpr_oty2)%z3(:,:,1), srcv(jpr_otx2)%clgrid, 'en->j', zty )
  897. ELSE
  898. CALL rot_rep( frcv(jpr_otx1)%z3(:,:,1), frcv(jpr_oty1)%z3(:,:,1), srcv(jpr_otx1)%clgrid, 'en->j', zty )
  899. ENDIF
  900. frcv(jpr_otx1)%z3(:,:,1) = ztx(:,:) ! overwrite 1st component on the 1st grid
  901. frcv(jpr_oty1)%z3(:,:,1) = zty(:,:) ! overwrite 2nd component on the 2nd grid
  902. ENDIF
  903. !
  904. IF( srcv(jpr_otx1)%clgrid == 'T' ) THEN
  905. DO jj = 2, jpjm1 ! T ==> (U,V)
  906. DO ji = fs_2, fs_jpim1 ! vector opt.
  907. frcv(jpr_otx1)%z3(ji,jj,1) = 0.5 * ( frcv(jpr_otx1)%z3(ji+1,jj ,1) + frcv(jpr_otx1)%z3(ji,jj,1) )
  908. frcv(jpr_oty1)%z3(ji,jj,1) = 0.5 * ( frcv(jpr_oty1)%z3(ji ,jj+1,1) + frcv(jpr_oty1)%z3(ji,jj,1) )
  909. END DO
  910. END DO
  911. CALL lbc_lnk( frcv(jpr_otx1)%z3(:,:,1), 'U', -1. ) ; CALL lbc_lnk( frcv(jpr_oty1)%z3(:,:,1), 'V', -1. )
  912. ENDIF
  913. llnewtx = .TRUE.
  914. ELSE
  915. llnewtx = .FALSE.
  916. ENDIF
  917. !
  918. IF( ln_force_windstress ) THEN
  919. CALL fld_read( kt, k_fsbc, sf_tau_anom )
  920. IF(lwp) THEN ! control print
  921. WRITE(numout,*)
  922. WRITE(numout,*) ' Overwrite tau_u and tau_v with anomalies files : '
  923. WRITE(numout,*) ' ocean model time step index and frequency of sbc '
  924. WRITE(numout,*) kt
  925. ENDIF
  926. DO jj = 1, jpj
  927. DO ji = 1, jpi
  928. frcv(jpr_otx1)%z3(ji,jj,1) = frcv(jpr_otx1)%z3(ji,jj,1) + sf_tau_anom(1)%fnow(ji,jj,1)
  929. frcv(jpr_oty1)%z3(ji,jj,1) = frcv(jpr_oty1)%z3(ji,jj,1) + sf_tau_anom(2)%fnow(ji,jj,1)
  930. END DO
  931. END DO
  932. ENDIF
  933. !
  934. ! ! ========================= !
  935. ELSE ! No dynamical coupling !
  936. ! ! ========================= !
  937. frcv(jpr_otx1)%z3(:,:,1) = 0.e0 ! here simply set to zero
  938. frcv(jpr_oty1)%z3(:,:,1) = 0.e0 ! an external read in a file can be added instead
  939. llnewtx = .TRUE.
  940. !
  941. ENDIF
  942. ! ! ========================= !
  943. ! ! wind stress module ! (taum)
  944. ! ! ========================= !
  945. !
  946. IF( .NOT. srcv(jpr_taum)%laction ) THEN ! compute wind stress module from its components if not received
  947. ! => need to be done only when otx1 was changed
  948. IF( llnewtx ) THEN
  949. !CDIR NOVERRCHK
  950. DO jj = 2, jpjm1
  951. !CDIR NOVERRCHK
  952. DO ji = fs_2, fs_jpim1 ! vect. opt.
  953. zzx = frcv(jpr_otx1)%z3(ji-1,jj ,1) + frcv(jpr_otx1)%z3(ji,jj,1)
  954. zzy = frcv(jpr_oty1)%z3(ji ,jj-1,1) + frcv(jpr_oty1)%z3(ji,jj,1)
  955. frcv(jpr_taum)%z3(ji,jj,1) = 0.5 * SQRT( zzx * zzx + zzy * zzy )
  956. END DO
  957. END DO
  958. CALL lbc_lnk( frcv(jpr_taum)%z3(:,:,1), 'T', 1. )
  959. llnewtau = .TRUE.
  960. ELSE
  961. llnewtau = .FALSE.
  962. ENDIF
  963. ELSE
  964. llnewtau = nrcvinfo(jpr_taum) == OASIS_Rcv
  965. ! Stress module can be negative when received (interpolation problem)
  966. IF( llnewtau ) THEN
  967. frcv(jpr_taum)%z3(:,:,1) = MAX( 0._wp, frcv(jpr_taum)%z3(:,:,1) )
  968. ENDIF
  969. ENDIF
  970. !
  971. ! ! ========================= !
  972. ! ! 10 m wind speed ! (wndm)
  973. ! ! ========================= !
  974. !
  975. IF( .NOT. srcv(jpr_w10m)%laction ) THEN ! compute wind spreed from wind stress module if not received
  976. ! => need to be done only when taumod was changed
  977. IF( llnewtau ) THEN
  978. zcoef = 1. / ( zrhoa * zcdrag )
  979. !CDIR NOVERRCHK
  980. DO jj = 1, jpj
  981. !CDIR NOVERRCHK
  982. DO ji = 1, jpi
  983. frcv(jpr_w10m)%z3(ji,jj,1) = SQRT( frcv(jpr_taum)%z3(ji,jj,1) * zcoef )
  984. END DO
  985. END DO
  986. ENDIF
  987. ENDIF
  988. ! u(v)tau and taum will be modified by ice model
  989. ! -> need to be reset before each call of the ice/fsbc
  990. IF( MOD( kt-1, k_fsbc ) == 0 ) THEN
  991. !
  992. IF( ln_mixcpl ) THEN
  993. utau(:,:) = utau(:,:) * xcplmask(:,:,0) + frcv(jpr_otx1)%z3(:,:,1) * zmsk(:,:)
  994. vtau(:,:) = vtau(:,:) * xcplmask(:,:,0) + frcv(jpr_oty1)%z3(:,:,1) * zmsk(:,:)
  995. taum(:,:) = taum(:,:) * xcplmask(:,:,0) + frcv(jpr_taum)%z3(:,:,1) * zmsk(:,:)
  996. wndm(:,:) = wndm(:,:) * xcplmask(:,:,0) + frcv(jpr_w10m)%z3(:,:,1) * zmsk(:,:)
  997. ELSE
  998. utau(:,:) = frcv(jpr_otx1)%z3(:,:,1)
  999. vtau(:,:) = frcv(jpr_oty1)%z3(:,:,1)
  1000. taum(:,:) = frcv(jpr_taum)%z3(:,:,1)
  1001. wndm(:,:) = frcv(jpr_w10m)%z3(:,:,1)
  1002. ENDIF
  1003. CALL iom_put( "taum_oce", taum ) ! output wind stress module
  1004. !
  1005. ENDIF
  1006. #if defined key_cpl_carbon_cycle
  1007. ! ! ================== !
  1008. ! ! atmosph. CO2 (ppm) !
  1009. ! ! ================== !
  1010. IF( srcv(jpr_co2)%laction ) atm_co2(:,:) = frcv(jpr_co2)%z3(:,:,1)
  1011. #endif
  1012. ! Fields received by SAS when OASIS coupling
  1013. ! (arrays no more filled at sbcssm stage)
  1014. ! ! ================== !
  1015. ! ! SSS !
  1016. ! ! ================== !
  1017. IF( srcv(jpr_soce)%laction ) THEN ! received by sas in case of opa <-> sas coupling
  1018. sss_m(:,:) = frcv(jpr_soce)%z3(:,:,1)
  1019. CALL iom_put( 'sss_m', sss_m )
  1020. ENDIF
  1021. !
  1022. ! ! ================== !
  1023. ! ! SST !
  1024. ! ! ================== !
  1025. IF( srcv(jpr_toce)%laction ) THEN ! received by sas in case of opa <-> sas coupling
  1026. sst_m(:,:) = frcv(jpr_toce)%z3(:,:,1)
  1027. IF( srcv(jpr_soce)%laction .AND. ln_useCT ) THEN ! make sure that sst_m is the potential temperature
  1028. sst_m(:,:) = eos_pt_from_ct( sst_m(:,:), sss_m(:,:) )
  1029. ENDIF
  1030. ENDIF
  1031. ! ! ================== !
  1032. ! ! SSH !
  1033. ! ! ================== !
  1034. IF( srcv(jpr_ssh )%laction ) THEN ! received by sas in case of opa <-> sas coupling
  1035. ssh_m(:,:) = frcv(jpr_ssh )%z3(:,:,1)
  1036. CALL iom_put( 'ssh_m', ssh_m )
  1037. ENDIF
  1038. ! ! ================== !
  1039. ! ! surface currents !
  1040. ! ! ================== !
  1041. IF( srcv(jpr_ocx1)%laction ) THEN ! received by sas in case of opa <-> sas coupling
  1042. ssu_m(:,:) = frcv(jpr_ocx1)%z3(:,:,1)
  1043. ub (:,:,1) = ssu_m(:,:) ! will be used in sbcice_lim in the call of lim_sbc_tau
  1044. un (:,:,1) = ssu_m(:,:) ! will be used in sbc_cpl_snd if atmosphere coupling
  1045. CALL iom_put( 'ssu_m', ssu_m )
  1046. ENDIF
  1047. IF( srcv(jpr_ocy1)%laction ) THEN
  1048. ssv_m(:,:) = frcv(jpr_ocy1)%z3(:,:,1)
  1049. vb (:,:,1) = ssv_m(:,:) ! will be used in sbcice_lim in the call of lim_sbc_tau
  1050. vn (:,:,1) = ssv_m(:,:) ! will be used in sbc_cpl_snd if atmosphere coupling
  1051. CALL iom_put( 'ssv_m', ssv_m )
  1052. ENDIF
  1053. ! ! ======================== !
  1054. ! ! first T level thickness !
  1055. ! ! ======================== !
  1056. IF( srcv(jpr_e3t1st )%laction ) THEN ! received by sas in case of opa <-> sas coupling
  1057. e3t_m(:,:) = frcv(jpr_e3t1st )%z3(:,:,1)
  1058. CALL iom_put( 'e3t_m', e3t_m(:,:) )
  1059. ENDIF
  1060. ! ! ================================ !
  1061. ! ! fraction of solar net radiation !
  1062. ! ! ================================ !
  1063. IF( srcv(jpr_fraqsr)%laction ) THEN ! received by sas in case of opa <-> sas coupling
  1064. frq_m(:,:) = frcv(jpr_fraqsr)%z3(:,:,1)
  1065. CALL iom_put( 'frq_m', frq_m )
  1066. ENDIF
  1067. ! ! ========================= !
  1068. IF( k_ice <= 1 .AND. MOD( kt-1, k_fsbc ) == 0 ) THEN ! heat & freshwater fluxes ! (Ocean only case)
  1069. ! ! ========================= !
  1070. !
  1071. ! ! total freshwater fluxes over the ocean (emp)
  1072. IF( srcv(jpr_oemp)%laction .OR. srcv(jpr_rain)%laction ) THEN
  1073. SELECT CASE( TRIM( sn_rcv_emp%cldes ) ) ! evaporation - precipitation
  1074. CASE( 'conservative' )
  1075. zemp(:,:) = frcv(jpr_tevp)%z3(:,:,1) - ( frcv(jpr_rain)%z3(:,:,1) + frcv(jpr_snow)%z3(:,:,1) )
  1076. CASE( 'oce only', 'oce and ice' )
  1077. zemp(:,:) = frcv(jpr_oemp)%z3(:,:,1)
  1078. CASE default
  1079. CALL ctl_stop( 'sbc_cpl_rcv: wrong definition of sn_rcv_emp%cldes' )
  1080. END SELECT
  1081. ELSE
  1082. zemp(:,:) = 0._wp
  1083. ENDIF
  1084. !
  1085. !
  1086. ! ! runoffs and calving (added in emp)
  1087. IF( srcv(jpr_rnf)%laction ) rnf(:,:) = frcv(jpr_rnf)%z3(:,:,1)
  1088. IF( srcv(jpr_cal)%laction ) zemp(:,:) = zemp(:,:) - frcv(jpr_cal)%z3(:,:,1)
  1089. IF( srcv(jpr_icb)%laction ) THEN
  1090. fwficb(:,:) = frcv(jpr_icb)%z3(:,:,1)
  1091. rnf(:,:) = rnf(:,:) + fwficb(:,:) ! iceberg added to runfofs
  1092. ENDIF
  1093. IF( srcv(jpr_isf)%laction ) fwfisf(:,:) = - frcv(jpr_isf)%z3(:,:,1) ! fresh water flux from the isf (fwfisf <0 mean melting)
  1094. IF( ln_mixcpl ) THEN ; emp(:,:) = emp(:,:) * xcplmask(:,:,0) + zemp(:,:) * zmsk(:,:)
  1095. ELSE ; emp(:,:) = zemp(:,:)
  1096. ENDIF
  1097. !
  1098. ! ! non solar heat flux over the ocean (qns)
  1099. IF( srcv(jpr_qnsoce)%laction ) THEN ; zqns(:,:) = frcv(jpr_qnsoce)%z3(:,:,1)
  1100. ELSE IF( srcv(jpr_qnsmix)%laction ) THEN ; zqns(:,:) = frcv(jpr_qnsmix)%z3(:,:,1)
  1101. ELSE ; zqns(:,:) = 0._wp
  1102. END IF
  1103. ! update qns over the free ocean with:
  1104. IF( nn_components /= jp_iam_opa ) THEN
  1105. zqns(:,:) = zqns(:,:) - zemp(:,:) * sst_m(:,:) * rcp ! remove heat content due to mass flux (assumed to be at SST)
  1106. IF( srcv(jpr_snow )%laction ) THEN
  1107. zqns(:,:) = zqns(:,:) - frcv(jpr_snow)%z3(:,:,1) * lfus ! energy for melting solid precipitation over the free ocean
  1108. ENDIF
  1109. ENDIF
  1110. !
  1111. IF( srcv(jpr_icb)%laction ) zqns(:,:) = zqns(:,:) - frcv(jpr_icb)%z3(:,:,1) * lfus ! remove heat content associated to iceberg melting
  1112. !
  1113. IF( ln_mixcpl ) THEN ; qns(:,:) = qns(:,:) * xcplmask(:,:,0) + zqns(:,:) * zmsk(:,:)
  1114. ELSE ; qns(:,:) = zqns(:,:)
  1115. ENDIF
  1116. ! ! solar flux over the ocean (qsr)
  1117. IF ( srcv(jpr_qsroce)%laction ) THEN ; zqsr(:,:) = frcv(jpr_qsroce)%z3(:,:,1)
  1118. ELSE IF( srcv(jpr_qsrmix)%laction ) then ; zqsr(:,:) = frcv(jpr_qsrmix)%z3(:,:,1)
  1119. ELSE ; zqsr(:,:) = 0._wp
  1120. ENDIF
  1121. IF( ln_dm2dc .AND. ln_cpl ) zqsr(:,:) = sbc_dcy( zqsr ) ! modify qsr to include the diurnal cycle
  1122. IF( ln_mixcpl ) THEN ; qsr(:,:) = qsr(:,:) * xcplmask(:,:,0) + zqsr(:,:) * zmsk(:,:)
  1123. ELSE ; qsr(:,:) = zqsr(:,:)
  1124. ENDIF
  1125. !
  1126. ! salt flux over the ocean (received by opa in case of opa <-> sas coupling)
  1127. IF( srcv(jpr_sflx )%laction ) sfx(:,:) = frcv(jpr_sflx )%z3(:,:,1)
  1128. ! Ice cover (received by opa in case of opa <-> sas coupling)
  1129. IF( srcv(jpr_fice )%laction ) fr_i(:,:) = frcv(jpr_fice )%z3(:,:,1)
  1130. !
  1131. ENDIF
  1132. !
  1133. CALL wrk_dealloc( jpi,jpj, ztx, zty, zmsk, zemp, zqns, zqsr )
  1134. !
  1135. IF( nn_timing == 1 ) CALL timing_stop('sbc_cpl_rcv')
  1136. !
  1137. END SUBROUTINE sbc_cpl_rcv
  1138. SUBROUTINE sbc_cpl_ice_tau( p_taui, p_tauj )
  1139. !!----------------------------------------------------------------------
  1140. !! *** ROUTINE sbc_cpl_ice_tau ***
  1141. !!
  1142. !! ** Purpose : provide the stress over sea-ice in coupled mode
  1143. !!
  1144. !! ** Method : transform the received stress from the atmosphere into
  1145. !! an atmosphere-ice stress in the (i,j) ocean referencial
  1146. !! and at the velocity point of the sea-ice model (cp_ice_msh):
  1147. !! 'C'-grid : i- (j-) components given at U- (V-) point
  1148. !! 'I'-grid : B-grid lower-left corner: both components given at I-point
  1149. !!
  1150. !! The received stress are :
  1151. !! - defined by 3 components (if cartesian coordinate)
  1152. !! or by 2 components (if spherical)
  1153. !! - oriented along geographical coordinate (if eastward-northward)
  1154. !! or along the local grid coordinate (if local grid)
  1155. !! - given at U- and V-point, resp. if received on 2 grids
  1156. !! or at a same point (T or I) if received on 1 grid
  1157. !! Therefore and if necessary, they are successively
  1158. !! processed in order to obtain them
  1159. !! first as 2 components on the sphere
  1160. !! second as 2 components oriented along the local grid
  1161. !! third as 2 components on the cp_ice_msh point
  1162. !!
  1163. !! Except in 'oce and ice' case, only one vector stress field
  1164. !! is received. It has already been processed in sbc_cpl_rcv
  1165. !! so that it is now defined as (i,j) components given at U-
  1166. !! and V-points, respectively. Therefore, only the third
  1167. !! transformation is done and only if the ice-grid is a 'I'-grid.
  1168. !!
  1169. !! ** Action : return ptau_i, ptau_j, the stress over the ice at cp_ice_msh point
  1170. !!----------------------------------------------------------------------
  1171. REAL(wp), INTENT(out), DIMENSION(:,:) :: p_taui ! i- & j-components of atmos-ice stress [N/m2]
  1172. REAL(wp), INTENT(out), DIMENSION(:,:) :: p_tauj ! at I-point (B-grid) or U & V-point (C-grid)
  1173. !!
  1174. INTEGER :: ji, jj ! dummy loop indices
  1175. INTEGER :: itx ! index of taux over ice
  1176. REAL(wp), POINTER, DIMENSION(:,:) :: ztx, zty
  1177. !!----------------------------------------------------------------------
  1178. !
  1179. IF( nn_timing == 1 ) CALL timing_start('sbc_cpl_ice_tau')
  1180. !
  1181. CALL wrk_alloc( jpi,jpj, ztx, zty )
  1182. IF( srcv(jpr_itx1)%laction ) THEN ; itx = jpr_itx1
  1183. ELSE ; itx = jpr_otx1
  1184. ENDIF
  1185. ! do something only if we just received the stress from atmosphere
  1186. IF( nrcvinfo(itx) == OASIS_Rcv ) THEN
  1187. ! ! ======================= !
  1188. IF( srcv(jpr_itx1)%laction ) THEN ! ice stress received !
  1189. ! ! ======================= !
  1190. !
  1191. IF( TRIM( sn_rcv_tau%clvref ) == 'cartesian' ) THEN ! 2 components on the sphere
  1192. ! ! (cartesian to spherical -> 3 to 2 components)
  1193. CALL geo2oce( frcv(jpr_itx1)%z3(:,:,1), frcv(jpr_ity1)%z3(:,:,1), frcv(jpr_itz1)%z3(:,:,1), &
  1194. & srcv(jpr_itx1)%clgrid, ztx, zty )
  1195. frcv(jpr_itx1)%z3(:,:,1) = ztx(:,:) ! overwrite 1st comp. on the 1st grid
  1196. frcv(jpr_ity1)%z3(:,:,1) = zty(:,:) ! overwrite 2nd comp. on the 1st grid
  1197. !
  1198. IF( srcv(jpr_itx2)%laction ) THEN
  1199. CALL geo2oce( frcv(jpr_itx2)%z3(:,:,1), frcv(jpr_ity2)%z3(:,:,1), frcv(jpr_itz2)%z3(:,:,1), &
  1200. & srcv(jpr_itx2)%clgrid, ztx, zty )
  1201. frcv(jpr_itx2)%z3(:,:,1) = ztx(:,:) ! overwrite 1st comp. on the 2nd grid
  1202. frcv(jpr_ity2)%z3(:,:,1) = zty(:,:) ! overwrite 2nd comp. on the 2nd grid
  1203. ENDIF
  1204. !
  1205. ENDIF
  1206. !
  1207. IF( TRIM( sn_rcv_tau%clvor ) == 'eastward-northward' ) THEN ! 2 components oriented along the local grid
  1208. ! ! (geographical to local grid -> rotate the components)
  1209. CALL rot_rep( frcv(jpr_itx1)%z3(:,:,1), frcv(jpr_ity1)%z3(:,:,1), srcv(jpr_itx1)%clgrid, 'en->i', ztx )
  1210. IF( srcv(jpr_itx2)%laction ) THEN
  1211. CALL rot_rep( frcv(jpr_itx2)%z3(:,:,1), frcv(jpr_ity2)%z3(:,:,1), srcv(jpr_itx2)%clgrid, 'en->j', zty )
  1212. ELSE
  1213. CALL rot_rep( frcv(jpr_itx1)%z3(:,:,1), frcv(jpr_ity1)%z3(:,:,1), srcv(jpr_itx1)%clgrid, 'en->j', zty )
  1214. ENDIF
  1215. frcv(jpr_itx1)%z3(:,:,1) = ztx(:,:) ! overwrite 1st component on the 1st grid
  1216. frcv(jpr_ity1)%z3(:,:,1) = zty(:,:) ! overwrite 2nd component on the 1st grid
  1217. ENDIF
  1218. ! ! ======================= !
  1219. ELSE ! use ocean stress !
  1220. ! ! ======================= !
  1221. frcv(jpr_itx1)%z3(:,:,1) = frcv(jpr_otx1)%z3(:,:,1)
  1222. frcv(jpr_ity1)%z3(:,:,1) = frcv(jpr_oty1)%z3(:,:,1)
  1223. !
  1224. ENDIF
  1225. ! ! ======================= !
  1226. ! ! put on ice grid !
  1227. ! ! ======================= !
  1228. !
  1229. ! j+1 j -----V---F
  1230. ! ice stress on ice velocity point (cp_ice_msh) ! |
  1231. ! (C-grid ==>(U,V) or B-grid ==> I or F) j | T U
  1232. ! | |
  1233. ! j j-1 -I-------|
  1234. ! (for I) | |
  1235. ! i-1 i i
  1236. ! i i+1 (for I)
  1237. SELECT CASE ( cp_ice_msh )
  1238. !
  1239. CASE( 'I' ) ! B-grid ==> I
  1240. SELECT CASE ( srcv(jpr_itx1)%clgrid )
  1241. CASE( 'U' )
  1242. DO jj = 2, jpjm1 ! (U,V) ==> I
  1243. DO ji = 2, jpim1 ! NO vector opt.
  1244. p_taui(ji,jj) = 0.5 * ( frcv(jpr_itx1)%z3(ji-1,jj ,1) + frcv(jpr_itx1)%z3(ji-1,jj-1,1) )
  1245. p_tauj(ji,jj) = 0.5 * ( frcv(jpr_ity1)%z3(ji ,jj-1,1) + frcv(jpr_ity1)%z3(ji-1,jj-1,1) )
  1246. END DO
  1247. END DO
  1248. CASE( 'F' )
  1249. DO jj = 2, jpjm1 ! F ==> I
  1250. DO ji = 2, jpim1 ! NO vector opt.
  1251. p_taui(ji,jj) = frcv(jpr_itx1)%z3(ji-1,jj-1,1)
  1252. p_tauj(ji,jj) = frcv(jpr_ity1)%z3(ji-1,jj-1,1)
  1253. END DO
  1254. END DO
  1255. CASE( 'T' )
  1256. DO jj = 2, jpjm1 ! T ==> I
  1257. DO ji = 2, jpim1 ! NO vector opt.
  1258. p_taui(ji,jj) = 0.25 * ( frcv(jpr_itx1)%z3(ji,jj ,1) + frcv(jpr_itx1)%z3(ji-1,jj ,1) &
  1259. & + frcv(jpr_itx1)%z3(ji,jj-1,1) + frcv(jpr_itx1)%z3(ji-1,jj-1,1) )
  1260. p_tauj(ji,jj) = 0.25 * ( frcv(jpr_ity1)%z3(ji,jj ,1) + frcv(jpr_ity1)%z3(ji-1,jj ,1) &
  1261. & + frcv(jpr_oty1)%z3(ji,jj-1,1) + frcv(jpr_ity1)%z3(ji-1,jj-1,1) )
  1262. END DO
  1263. END DO
  1264. CASE( 'I' )
  1265. p_taui(:,:) = frcv(jpr_itx1)%z3(:,:,1) ! I ==> I
  1266. p_tauj(:,:) = frcv(jpr_ity1)%z3(:,:,1)
  1267. END SELECT
  1268. IF( srcv(jpr_itx1)%clgrid /= 'I' ) THEN
  1269. CALL lbc_lnk( p_taui, 'I', -1. ) ; CALL lbc_lnk( p_tauj, 'I', -1. )
  1270. ENDIF
  1271. !
  1272. CASE( 'F' ) ! B-grid ==> F
  1273. SELECT CASE ( srcv(jpr_itx1)%clgrid )
  1274. CASE( 'U' )
  1275. DO jj = 2, jpjm1 ! (U,V) ==> F
  1276. DO ji = fs_2, fs_jpim1 ! vector opt.
  1277. p_taui(ji,jj) = 0.5 * ( frcv(jpr_itx1)%z3(ji,jj,1) + frcv(jpr_itx1)%z3(ji ,jj+1,1) )
  1278. p_tauj(ji,jj) = 0.5 * ( frcv(jpr_ity1)%z3(ji,jj,1) + frcv(jpr_ity1)%z3(ji+1,jj ,1) )
  1279. END DO
  1280. END DO
  1281. CASE( 'I' )
  1282. DO jj = 2, jpjm1 ! I ==> F
  1283. DO ji = 2, jpim1 ! NO vector opt.
  1284. p_taui(ji,jj) = frcv(jpr_itx1)%z3(ji+1,jj+1,1)
  1285. p_tauj(ji,jj) = frcv(jpr_ity1)%z3(ji+1,jj+1,1)
  1286. END DO
  1287. END DO
  1288. CASE( 'T' )
  1289. DO jj = 2, jpjm1 ! T ==> F
  1290. DO ji = 2, jpim1 ! NO vector opt.
  1291. p_taui(ji,jj) = 0.25 * ( frcv(jpr_itx1)%z3(ji,jj ,1) + frcv(jpr_itx1)%z3(ji+1,jj ,1) &
  1292. & + frcv(jpr_itx1)%z3(ji,jj+1,1) + frcv(jpr_itx1)%z3(ji+1,jj+1,1) )
  1293. p_tauj(ji,jj) = 0.25 * ( frcv(jpr_ity1)%z3(ji,jj ,1) + frcv(jpr_ity1)%z3(ji+1,jj ,1) &
  1294. & + frcv(jpr_ity1)%z3(ji,jj+1,1) + frcv(jpr_ity1)%z3(ji+1,jj+1,1) )
  1295. END DO
  1296. END DO
  1297. CASE( 'F' )
  1298. p_taui(:,:) = frcv(jpr_itx1)%z3(:,:,1) ! F ==> F
  1299. p_tauj(:,:) = frcv(jpr_ity1)%z3(:,:,1)
  1300. END SELECT
  1301. IF( srcv(jpr_itx1)%clgrid /= 'F' ) THEN
  1302. CALL lbc_lnk( p_taui, 'F', -1. ) ; CALL lbc_lnk( p_tauj, 'F', -1. )
  1303. ENDIF
  1304. !
  1305. CASE( 'C' ) ! C-grid ==> U,V
  1306. SELECT CASE ( srcv(jpr_itx1)%clgrid )
  1307. CASE( 'U' )
  1308. p_taui(:,:) = frcv(jpr_itx1)%z3(:,:,1) ! (U,V) ==> (U,V)
  1309. p_tauj(:,:) = frcv(jpr_ity1)%z3(:,:,1)
  1310. CASE( 'F' )
  1311. DO jj = 2, jpjm1 ! F ==> (U,V)
  1312. DO ji = fs_2, fs_jpim1 ! vector opt.
  1313. p_taui(ji,jj) = 0.5 * ( frcv(jpr_itx1)%z3(ji,jj,1) + frcv(jpr_itx1)%z3(ji ,jj-1,1) )
  1314. p_tauj(ji,jj) = 0.5 * ( frcv(jpr_ity1)%z3(jj,jj,1) + frcv(jpr_ity1)%z3(ji-1,jj ,1) )
  1315. END DO
  1316. END DO
  1317. CASE( 'T' )
  1318. DO jj = 2, jpjm1 ! T ==> (U,V)
  1319. DO ji = fs_2, fs_jpim1 ! vector opt.
  1320. p_taui(ji,jj) = 0.5 * ( frcv(jpr_itx1)%z3(ji+1,jj ,1) + frcv(jpr_itx1)%z3(ji,jj,1) )
  1321. p_tauj(ji,jj) = 0.5 * ( frcv(jpr_ity1)%z3(ji ,jj+1,1) + frcv(jpr_ity1)%z3(ji,jj,1) )
  1322. END DO
  1323. END DO
  1324. CASE( 'I' )
  1325. DO jj = 2, jpjm1 ! I ==> (U,V)
  1326. DO ji = 2, jpim1 ! NO vector opt.
  1327. p_taui(ji,jj) = 0.5 * ( frcv(jpr_itx1)%z3(ji+1,jj+1,1) + frcv(jpr_itx1)%z3(ji+1,jj ,1) )
  1328. p_tauj(ji,jj) = 0.5 * ( frcv(jpr_ity1)%z3(ji+1,jj+1,1) + frcv(jpr_ity1)%z3(ji ,jj+1,1) )
  1329. END DO
  1330. END DO
  1331. END SELECT
  1332. IF( srcv(jpr_itx1)%clgrid /= 'U' ) THEN
  1333. CALL lbc_lnk( p_taui, 'U', -1. ) ; CALL lbc_lnk( p_tauj, 'V', -1. )
  1334. ENDIF
  1335. END SELECT
  1336. ENDIF
  1337. !
  1338. CALL wrk_dealloc( jpi,jpj, ztx, zty )
  1339. !
  1340. IF( nn_timing == 1 ) CALL timing_stop('sbc_cpl_ice_tau')
  1341. !
  1342. END SUBROUTINE sbc_cpl_ice_tau
  1343. SUBROUTINE sbc_cpl_ice_flx( p_frld, palbi, psst, pist )
  1344. !!----------------------------------------------------------------------
  1345. !! *** ROUTINE sbc_cpl_ice_flx ***
  1346. !!
  1347. !! ** Purpose : provide the heat and freshwater fluxes of the ocean-ice system
  1348. !!
  1349. !! ** Method : transform the fields received from the atmosphere into
  1350. !! surface heat and fresh water boundary condition for the
  1351. !! ice-ocean system. The following fields are provided:
  1352. !! * total non solar, solar and freshwater fluxes (qns_tot,
  1353. !! qsr_tot and emp_tot) (total means weighted ice-ocean flux)
  1354. !! NB: emp_tot include runoffs and calving.
  1355. !! * fluxes over ice (qns_ice, qsr_ice, emp_ice) where
  1356. !! emp_ice = sublimation - solid precipitation as liquid
  1357. !! precipitation are re-routed directly to the ocean and
  1358. !! calving directly enter the ocean (runoffs are read but included in trasbc.F90)
  1359. !! * solid precipitation (sprecip), used to add to qns_tot
  1360. !! the heat lost associated to melting solid precipitation
  1361. !! over the ocean fraction.
  1362. !! * heat content of rain, snow and evap can also be provided,
  1363. !! otherwise heat flux associated with these mass flux are
  1364. !! guessed (qemp_oce, qemp_ice)
  1365. !!
  1366. !! - the fluxes have been separated from the stress as
  1367. !! (a) they are updated at each ice time step compare to
  1368. !! an update at each coupled time step for the stress, and
  1369. !! (b) the conservative computation of the fluxes over the
  1370. !! sea-ice area requires the knowledge of the ice fraction
  1371. !! after the ice advection and before the ice thermodynamics,
  1372. !! so that the stress is updated before the ice dynamics
  1373. !! while the fluxes are updated after it.
  1374. !!
  1375. !! ** Details
  1376. !! qns_tot = pfrld * qns_oce + ( 1 - pfrld ) * qns_ice => provided
  1377. !! + qemp_oce + qemp_ice => recalculated and added up to qns
  1378. !!
  1379. !! qsr_tot = pfrld * qsr_oce + ( 1 - pfrld ) * qsr_ice => provided
  1380. !!
  1381. !! emp_tot = emp_oce + emp_ice => calving is provided and added to emp_tot (and emp_oce).
  1382. !! runoff (which includes rivers+icebergs) and iceshelf
  1383. !! are provided but not included in emp here. Only runoff will
  1384. !! be included in emp in other parts of NEMO code
  1385. !! ** Action : update at each nf_ice time step:
  1386. !! qns_tot, qsr_tot non-solar and solar total heat fluxes
  1387. !! qns_ice, qsr_ice non-solar and solar heat fluxes over the ice
  1388. !! emp_tot total evaporation - precipitation(liquid and solid) (-calving)
  1389. !! emp_ice ice sublimation - solid precipitation over the ice
  1390. !! dqns_ice d(non-solar heat flux)/d(Temperature) over the ice
  1391. !! sprecip solid precipitation over the ocean
  1392. !!----------------------------------------------------------------------
  1393. REAL(wp), INTENT(in ), DIMENSION(:,:) :: p_frld ! lead fraction [0 to 1]
  1394. ! optional arguments, used only in 'mixed oce-ice' case
  1395. REAL(wp), INTENT(in ), DIMENSION(:,:,:), OPTIONAL :: palbi ! all skies ice albedo
  1396. REAL(wp), INTENT(in ), DIMENSION(:,: ), OPTIONAL :: psst ! sea surface temperature [Celsius]
  1397. REAL(wp), INTENT(in ), DIMENSION(:,:,:), OPTIONAL :: pist ! ice surface temperature [Kelvin]
  1398. !
  1399. INTEGER :: jl ! dummy loop index
  1400. REAL(wp), POINTER, DIMENSION(:,: ) :: zcptn, zcptrain, zcptsnw, zicefr, zmsk, zsnw
  1401. REAL(wp), POINTER, DIMENSION(:,: ) :: zemp_tot, zemp_ice, zemp_oce, ztprecip, zsprecip, zevap_oce, zevap_ice, zdevap_ice
  1402. REAL(wp), POINTER, DIMENSION(:,: ) :: zqns_tot, zqns_oce, zqsr_tot, zqsr_oce, zqprec_ice, zqemp_oce, zqemp_ice
  1403. REAL(wp), POINTER, DIMENSION(:,:,:) :: zqns_ice, zqsr_ice, zdqns_ice, zqevap_ice
  1404. !!----------------------------------------------------------------------
  1405. !
  1406. IF( nn_timing == 1 ) CALL timing_start('sbc_cpl_ice_flx')
  1407. !
  1408. CALL wrk_alloc( jpi,jpj, zcptn, zcptrain, zcptsnw, zicefr, zmsk, zsnw )
  1409. CALL wrk_alloc( jpi,jpj, zemp_tot, zemp_ice, zemp_oce, ztprecip, zsprecip, zevap_oce, zevap_ice, zdevap_ice )
  1410. CALL wrk_alloc( jpi,jpj, zqns_tot, zqns_oce, zqsr_tot, zqsr_oce, zqprec_ice, zqemp_oce, zqemp_ice )
  1411. CALL wrk_alloc( jpi,jpj,jpl, zqns_ice, zqsr_ice, zdqns_ice, zqevap_ice )
  1412. IF( ln_mixcpl ) zmsk(:,:) = 1. - xcplmask(:,:,0)
  1413. zicefr(:,:) = 1.- p_frld(:,:)
  1414. zcptn(:,:) = rcp * sst_m(:,:)
  1415. !
  1416. ! ! ========================= !
  1417. ! ! freshwater budget ! (emp_tot)
  1418. ! ! ========================= !
  1419. !
  1420. ! ! solid Precipitation (sprecip)
  1421. ! ! liquid + solid Precipitation (tprecip)
  1422. ! ! total Evaporation - total Precipitation (emp_tot)
  1423. ! ! sublimation - solid precipitation (cell average) (emp_ice)
  1424. SELECT CASE( TRIM( sn_rcv_emp%cldes ) )
  1425. CASE( 'conservative' ) ! received fields: jpr_rain, jpr_snow, jpr_ievp, jpr_tevp
  1426. zsprecip(:,:) = frcv(jpr_snow)%z3(:,:,1) ! May need to ensure positive here
  1427. ztprecip(:,:) = frcv(jpr_rain)%z3(:,:,1) + zsprecip(:,:) ! May need to ensure positive here
  1428. zemp_tot(:,:) = frcv(jpr_tevp)%z3(:,:,1) - ztprecip(:,:)
  1429. zemp_ice(:,:) = ( frcv(jpr_ievp)%z3(:,:,1) - frcv(jpr_snow)%z3(:,:,1) ) * zicefr(:,:)
  1430. CASE( 'oce and ice' ) ! received fields: jpr_sbpr, jpr_semp, jpr_oemp, jpr_ievp
  1431. zemp_tot(:,:) = p_frld(:,:) * frcv(jpr_oemp)%z3(:,:,1) + zicefr(:,:) * frcv(jpr_sbpr)%z3(:,:,1)
  1432. zemp_ice(:,:) = frcv(jpr_semp)%z3(:,:,1) * zicefr(:,:)
  1433. zsprecip(:,:) = frcv(jpr_ievp)%z3(:,:,1) - frcv(jpr_semp)%z3(:,:,1)
  1434. ztprecip(:,:) = frcv(jpr_semp)%z3(:,:,1) - frcv(jpr_sbpr)%z3(:,:,1) + zsprecip(:,:)
  1435. END SELECT
  1436. #if defined key_lim3
  1437. ! zsnw = snow fraction over ice after wind blowing (=zicefr if no blowing)
  1438. zsnw(:,:) = 0._wp ; CALL lim_thd_snwblow( p_frld, zsnw )
  1439. ! --- evaporation minus precipitation corrected (because of wind blowing on snow) --- !
  1440. zemp_ice(:,:) = zemp_ice(:,:) + zsprecip(:,:) * ( zicefr(:,:) - zsnw(:,:) ) ! emp_ice = A * sublimation - zsnw * sprecip
  1441. zemp_oce(:,:) = zemp_tot(:,:) - zemp_ice(:,:) ! emp_oce = emp_tot - emp_ice
  1442. ! --- evaporation over ocean (used later for qemp) --- !
  1443. zevap_oce(:,:) = frcv(jpr_tevp)%z3(:,:,1) - frcv(jpr_ievp)%z3(:,:,1) * zicefr(:,:)
  1444. ! --- evaporation over ice (kg/m2/s) --- !
  1445. zevap_ice(:,:) = frcv(jpr_ievp)%z3(:,:,1)
  1446. ! since the sensitivity of evap to temperature (devap/dT) is not prescribed by the atmosphere, we set it to 0
  1447. ! therefore, sublimation is not redistributed over the ice categories when no subgrid scale fluxes are provided by atm.
  1448. zdevap_ice(:,:) = 0._wp
  1449. ! --- Continental fluxes --- !
  1450. IF( srcv(jpr_rnf)%laction ) THEN ! runoffs (included in emp later on)
  1451. rnf(:,:) = frcv(jpr_rnf)%z3(:,:,1)
  1452. ENDIF
  1453. IF( srcv(jpr_cal)%laction ) THEN ! calving (put in emp_tot and emp_oce)
  1454. zemp_tot(:,:) = zemp_tot(:,:) - frcv(jpr_cal)%z3(:,:,1)
  1455. zemp_oce(:,:) = zemp_oce(:,:) - frcv(jpr_cal)%z3(:,:,1)
  1456. ENDIF
  1457. IF( srcv(jpr_icb)%laction ) THEN ! iceberg added to runoffs
  1458. fwficb(:,:) = frcv(jpr_icb)%z3(:,:,1)
  1459. rnf(:,:) = rnf(:,:) + fwficb(:,:)
  1460. ENDIF
  1461. IF( srcv(jpr_isf)%laction ) THEN ! iceshelf (fwfisf <0 mean melting)
  1462. fwfisf(:,:) = - frcv(jpr_isf)%z3(:,:,1)
  1463. ENDIF
  1464. IF( ln_mixcpl ) THEN
  1465. emp_tot(:,:) = emp_tot(:,:) * xcplmask(:,:,0) + zemp_tot(:,:) * zmsk(:,:)
  1466. emp_ice(:,:) = emp_ice(:,:) * xcplmask(:,:,0) + zemp_ice(:,:) * zmsk(:,:)
  1467. emp_oce(:,:) = emp_oce(:,:) * xcplmask(:,:,0) + zemp_oce(:,:) * zmsk(:,:)
  1468. sprecip(:,:) = sprecip(:,:) * xcplmask(:,:,0) + zsprecip(:,:) * zmsk(:,:)
  1469. tprecip(:,:) = tprecip(:,:) * xcplmask(:,:,0) + ztprecip(:,:) * zmsk(:,:)
  1470. DO jl=1,jpl
  1471. evap_ice (:,:,jl) = evap_ice (:,:,jl) * xcplmask(:,:,0) + zevap_ice (:,:) * zmsk(:,:)
  1472. devap_ice(:,:,jl) = devap_ice(:,:,jl) * xcplmask(:,:,0) + zdevap_ice(:,:) * zmsk(:,:)
  1473. ENDDO
  1474. ELSE
  1475. emp_tot(:,:) = zemp_tot(:,:)
  1476. emp_ice(:,:) = zemp_ice(:,:)
  1477. emp_oce(:,:) = zemp_oce(:,:)
  1478. sprecip(:,:) = zsprecip(:,:)
  1479. tprecip(:,:) = ztprecip(:,:)
  1480. DO jl=1,jpl
  1481. evap_ice (:,:,jl) = zevap_ice (:,:)
  1482. devap_ice(:,:,jl) = zdevap_ice(:,:)
  1483. ENDDO
  1484. ENDIF
  1485. #else
  1486. zsnw(:,:) = zicefr(:,:)
  1487. ! --- Continental fluxes --- !
  1488. IF( srcv(jpr_rnf)%laction ) THEN ! runoffs (included in emp later on)
  1489. rnf(:,:) = frcv(jpr_rnf)%z3(:,:,1)
  1490. ENDIF
  1491. IF( srcv(jpr_cal)%laction ) THEN ! calving (put in emp_tot)
  1492. zemp_tot(:,:) = zemp_tot(:,:) - frcv(jpr_cal)%z3(:,:,1)
  1493. ENDIF
  1494. IF( srcv(jpr_icb)%laction ) THEN ! iceberg added to runoffs
  1495. fwficb(:,:) = frcv(jpr_icb)%z3(:,:,1)
  1496. rnf(:,:) = rnf(:,:) + fwficb(:,:)
  1497. ENDIF
  1498. IF( srcv(jpr_isf)%laction ) THEN ! iceshelf (fwfisf <0 mean melting)
  1499. fwfisf(:,:) = - frcv(jpr_isf)%z3(:,:,1)
  1500. ENDIF
  1501. IF( ln_mixcpl ) THEN
  1502. emp_tot(:,:) = emp_tot(:,:) * xcplmask(:,:,0) + zemp_tot(:,:) * zmsk(:,:)
  1503. emp_ice(:,:) = emp_ice(:,:) * xcplmask(:,:,0) + zemp_ice(:,:) * zmsk(:,:)
  1504. sprecip(:,:) = sprecip(:,:) * xcplmask(:,:,0) + zsprecip(:,:) * zmsk(:,:)
  1505. tprecip(:,:) = tprecip(:,:) * xcplmask(:,:,0) + ztprecip(:,:) * zmsk(:,:)
  1506. ELSE
  1507. emp_tot(:,:) = zemp_tot(:,:)
  1508. emp_ice(:,:) = zemp_ice(:,:)
  1509. sprecip(:,:) = zsprecip(:,:)
  1510. tprecip(:,:) = ztprecip(:,:)
  1511. ENDIF
  1512. #endif
  1513. ! outputs
  1514. !! IF( srcv(jpr_rnf)%laction ) CALL iom_put( 'runoffs' , rnf(:,:) * tmask(:,:,1) ) ! runoff
  1515. !! IF( srcv(jpr_isf)%laction ) CALL iom_put( 'iceshelf_cea', -fwfisf(:,:) * tmask(:,:,1) ) ! iceshelf
  1516. IF( srcv(jpr_cal)%laction ) CALL iom_put( 'calving_cea' , frcv(jpr_cal)%z3(:,:,1) * tmask(:,:,1) ) ! calving
  1517. IF( srcv(jpr_icb)%laction ) CALL iom_put( 'iceberg_cea' , frcv(jpr_icb)%z3(:,:,1) * tmask(:,:,1) ) ! icebergs
  1518. IF( iom_use('snowpre') ) CALL iom_put( 'snowpre' , sprecip(:,:) ) ! Snow
  1519. IF( iom_use('precip') ) CALL iom_put( 'precip' , tprecip(:,:) ) ! total precipitation
  1520. IF( iom_use('rain') ) CALL iom_put( 'rain' , tprecip(:,:) - sprecip(:,:) ) ! liquid precipitation
  1521. IF( iom_use('snow_ao_cea') ) CALL iom_put( 'snow_ao_cea' , sprecip(:,:) * ( 1._wp - zsnw(:,:) ) ) ! Snow over ice-free ocean (cell average)
  1522. IF( iom_use('snow_ai_cea') ) CALL iom_put( 'snow_ai_cea' , sprecip(:,:) * zsnw(:,:) ) ! Snow over sea-ice (cell average)
  1523. IF( iom_use('rain_ao_cea') ) CALL iom_put( 'rain_ao_cea' , ( tprecip(:,:) - sprecip(:,:) ) * p_frld(:,:) ) ! liquid precipitation over ocean (cell average)
  1524. IF( iom_use('subl_ai_cea') ) CALL iom_put( 'subl_ai_cea' , frcv(jpr_ievp)%z3(:,:,1) * zicefr(:,:) * tmask(:,:,1) ) ! Sublimation over sea-ice (cell average)
  1525. IF( iom_use('evap_ao_cea') ) CALL iom_put( 'evap_ao_cea' , ( frcv(jpr_tevp)%z3(:,:,1) &
  1526. & - frcv(jpr_ievp)%z3(:,:,1) * zicefr(:,:) ) * tmask(:,:,1) ) ! ice-free oce evap (cell average)
  1527. ! note: runoff output is done in sbcrnf (which includes icebergs too) and iceshelf output is done in sbcisf
  1528. !
  1529. ! ! ========================= !
  1530. SELECT CASE( TRIM( sn_rcv_qns%cldes ) ) ! non solar heat fluxes ! (qns)
  1531. ! ! ========================= !
  1532. CASE( 'oce only' ) ! the required field is directly provided
  1533. zqns_tot(:,:) = frcv(jpr_qnsoce)%z3(:,:,1)
  1534. CASE( 'conservative' ) ! the required fields are directly provided
  1535. zqns_tot(:,:) = frcv(jpr_qnsmix)%z3(:,:,1)
  1536. IF ( TRIM(sn_rcv_qns%clcat) == 'yes' ) THEN
  1537. zqns_ice(:,:,1:jpl) = frcv(jpr_qnsice)%z3(:,:,1:jpl)
  1538. ELSE
  1539. DO jl=1,jpl
  1540. zqns_ice(:,:,jl) = frcv(jpr_qnsice)%z3(:,:,1) ! Set all category values equal
  1541. ENDDO
  1542. ENDIF
  1543. CASE( 'oce and ice' ) ! the total flux is computed from ocean and ice fluxes
  1544. zqns_tot(:,:) = p_frld(:,:) * frcv(jpr_qnsoce)%z3(:,:,1)
  1545. IF ( TRIM(sn_rcv_qns%clcat) == 'yes' ) THEN
  1546. DO jl=1,jpl
  1547. zqns_tot(:,: ) = zqns_tot(:,:) + a_i(:,:,jl) * frcv(jpr_qnsice)%z3(:,:,jl)
  1548. zqns_ice(:,:,jl) = frcv(jpr_qnsice)%z3(:,:,jl)
  1549. ENDDO
  1550. ELSE
  1551. qns_tot(:,:) = qns_tot(:,:) + zicefr(:,:) * frcv(jpr_qnsice)%z3(:,:,1)
  1552. DO jl=1,jpl
  1553. zqns_tot(:,: ) = zqns_tot(:,:) + zicefr(:,:) * frcv(jpr_qnsice)%z3(:,:,1)
  1554. zqns_ice(:,:,jl) = frcv(jpr_qnsice)%z3(:,:,1)
  1555. ENDDO
  1556. ENDIF
  1557. CASE( 'mixed oce-ice' ) ! the ice flux is cumputed from the total flux, the SST and ice informations
  1558. ! ** NEED TO SORT OUT HOW THIS SHOULD WORK IN THE MULTI-CATEGORY CASE - CURRENTLY NOT ALLOWED WHEN INTERFACE INITIALISED **
  1559. zqns_tot(:,: ) = frcv(jpr_qnsmix)%z3(:,:,1)
  1560. zqns_ice(:,:,1) = frcv(jpr_qnsmix)%z3(:,:,1) &
  1561. & + frcv(jpr_dqnsdt)%z3(:,:,1) * ( pist(:,:,1) - ( (rt0 + psst(:,: ) ) * p_frld(:,:) &
  1562. & + pist(:,:,1) * zicefr(:,:) ) )
  1563. END SELECT
  1564. IF( iom_use('qns_mix') ) CALL iom_put( 'qns_mix', zqns_tot(:,:) ) ! total qns_mix flux received
  1565. !
  1566. ! --- calving (removed from qns_tot) --- !
  1567. IF( srcv(jpr_cal)%laction ) zqns_tot(:,:) = zqns_tot(:,:) - frcv(jpr_cal)%z3(:,:,1) * lfus ! remove latent heat of calving
  1568. ! we suppose it melts at 0deg, though it should be temp. of surrounding ocean
  1569. ! --- iceberg (removed from qns_tot) --- !
  1570. IF( srcv(jpr_icb)%laction ) zqns_tot(:,:) = zqns_tot(:,:) - frcv(jpr_icb)%z3(:,:,1) * lfus ! remove latent heat of iceberg melting
  1571. #if defined key_lim3
  1572. ! --- non solar flux over ocean --- !
  1573. ! note: p_frld cannot be = 0 since we limit the ice concentration to amax
  1574. zqns_oce = 0._wp
  1575. WHERE( p_frld /= 0._wp ) zqns_oce(:,:) = ( zqns_tot(:,:) - SUM( a_i * zqns_ice, dim=3 ) ) / p_frld(:,:)
  1576. ! Heat content per unit mass of snow (J/kg)
  1577. WHERE( SUM( a_i, dim=3 ) > 1.e-10 ) ; zcptsnw(:,:) = cpic * SUM( (tn_ice - rt0) * a_i, dim=3 ) / SUM( a_i, dim=3 )
  1578. ELSEWHERE ; zcptsnw(:,:) = zcptn(:,:)
  1579. ENDWHERE
  1580. ! Heat content per unit mass of rain (J/kg)
  1581. zcptrain(:,:) = rcp * ( SUM( (tn_ice(:,:,:) - rt0) * a_i(:,:,:), dim=3 ) + sst_m(:,:) * p_frld(:,:) )
  1582. ! --- enthalpy of snow precip over ice in J/m3 (to be used in 1D-thermo) --- !
  1583. zqprec_ice(:,:) = rhosn * ( zcptsnw(:,:) - lfus )
  1584. ! --- heat content of evap over ice in W/m2 (to be used in 1D-thermo) --- !
  1585. DO jl = 1, jpl
  1586. zqevap_ice(:,:,jl) = 0._wp ! should be -evap * ( ( Tice - rt0 ) * cpic ) but atm. does not take it into account
  1587. END DO
  1588. ! --- heat flux associated with emp (W/m2) --- !
  1589. zqemp_oce(:,:) = - zevap_oce(:,:) * zcptn (:,:) & ! evap
  1590. & + ( ztprecip(:,:) - zsprecip(:,:) ) * zcptrain(:,:) & ! liquid precip
  1591. & + zsprecip(:,:) * ( 1._wp - zsnw ) * ( zcptsnw (:,:) - lfus ) ! solid precip over ocean + snow melting
  1592. zqemp_ice(:,:) = zsprecip(:,:) * zsnw * ( zcptsnw (:,:) - lfus ) ! solid precip over ice (qevap_ice=0 since atm. does not take it into account)
  1593. !! zqemp_ice(:,:) = - frcv(jpr_ievp)%z3(:,:,1) * zicefr(:,:) * zcptsnw (:,:) & ! ice evap
  1594. !! & + zsprecip(:,:) * zsnw * zqprec_ice(:,:) * r1_rhosn ! solid precip over ice
  1595. ! --- total non solar flux (including evap/precip) --- !
  1596. zqns_tot(:,:) = zqns_tot(:,:) + zqemp_ice(:,:) + zqemp_oce(:,:)
  1597. ! --- in case both coupled/forced are active, we must mix values --- !
  1598. IF( ln_mixcpl ) THEN
  1599. qns_tot(:,:) = qns_tot(:,:) * xcplmask(:,:,0) + zqns_tot(:,:)* zmsk(:,:)
  1600. qns_oce(:,:) = qns_oce(:,:) * xcplmask(:,:,0) + zqns_oce(:,:)* zmsk(:,:)
  1601. DO jl=1,jpl
  1602. qns_ice (:,:,jl) = qns_ice (:,:,jl) * xcplmask(:,:,0) + zqns_ice (:,:,jl)* zmsk(:,:)
  1603. qevap_ice(:,:,jl) = qevap_ice(:,:,jl) * xcplmask(:,:,0) + zqevap_ice(:,:,jl)* zmsk(:,:)
  1604. ENDDO
  1605. qprec_ice(:,:) = qprec_ice(:,:) * xcplmask(:,:,0) + zqprec_ice(:,:)* zmsk(:,:)
  1606. qemp_oce (:,:) = qemp_oce(:,:) * xcplmask(:,:,0) + zqemp_oce(:,:)* zmsk(:,:)
  1607. qemp_ice (:,:) = qemp_ice(:,:) * xcplmask(:,:,0) + zqemp_ice(:,:)* zmsk(:,:)
  1608. ELSE
  1609. qns_tot (:,: ) = zqns_tot (:,: )
  1610. qns_oce (:,: ) = zqns_oce (:,: )
  1611. qns_ice (:,:,:) = zqns_ice (:,:,:)
  1612. qevap_ice(:,:,:) = zqevap_ice(:,:,:)
  1613. qprec_ice(:,: ) = zqprec_ice(:,: )
  1614. qemp_oce (:,: ) = zqemp_oce (:,: )
  1615. qemp_ice (:,: ) = zqemp_ice (:,: )
  1616. ENDIF
  1617. #else
  1618. zcptsnw (:,:) = zcptn(:,:)
  1619. zcptrain(:,:) = zcptn(:,:)
  1620. ! clem: this formulation is certainly wrong... but better than it was...
  1621. zqns_tot(:,:) = zqns_tot(:,:) & ! zqns_tot update over free ocean with:
  1622. & - ( p_frld(:,:) * zsprecip(:,:) * lfus ) & ! remove the latent heat flux of solid precip. melting
  1623. & - ( zemp_tot(:,:) & ! remove the heat content of mass flux (assumed to be at SST)
  1624. & - zemp_ice(:,:) ) * zcptn(:,:)
  1625. IF( ln_mixcpl ) THEN
  1626. qns_tot(:,:) = qns(:,:) * p_frld(:,:) + SUM( qns_ice(:,:,:) * a_i(:,:,:), dim=3 ) ! total flux from blk
  1627. qns_tot(:,:) = qns_tot(:,:) * xcplmask(:,:,0) + zqns_tot(:,:)* zmsk(:,:)
  1628. DO jl=1,jpl
  1629. qns_ice(:,:,jl) = qns_ice(:,:,jl) * xcplmask(:,:,0) + zqns_ice(:,:,jl)* zmsk(:,:)
  1630. ENDDO
  1631. ELSE
  1632. qns_tot(:,: ) = zqns_tot(:,: )
  1633. qns_ice(:,:,:) = zqns_ice(:,:,:)
  1634. ENDIF
  1635. #endif
  1636. ! outputs
  1637. IF( srcv(jpr_cal)%laction ) CALL iom_put('hflx_cal_cea' , - frcv(jpr_cal)%z3(:,:,1) * lfus ) ! latent heat from calving
  1638. IF( srcv(jpr_icb)%laction ) CALL iom_put('hflx_icb_cea' , - frcv(jpr_icb)%z3(:,:,1) * lfus ) ! latent heat from icebergs melting
  1639. IF( iom_use('hflx_snow_cea') ) CALL iom_put('hflx_snow_cea', sprecip(:,:) * ( zcptsnw(:,:) - Lfus ) ) ! heat flux from snow (cell average)
  1640. IF( iom_use('hflx_rain_cea') ) CALL iom_put('hflx_rain_cea',( tprecip(:,:) - sprecip(:,:) ) * zcptrain(:,:) ) ! heat flux from rain (cell average)
  1641. IF( iom_use('hflx_evap_cea') ) CALL iom_put('hflx_evap_cea',(frcv(jpr_tevp)%z3(:,:,1)-frcv(jpr_ievp)%z3(:,:,1)*zicefr(:,:)) & ! heat flux from from evap (cell average)
  1642. & * zcptn(:,:) * tmask(:,:,1) )
  1643. IF( iom_use('hflx_prec_cea') ) CALL iom_put('hflx_prec_cea', sprecip(:,:) * ( zcptsnw(:,:) - Lfus ) + & ! heat flux from all precip (cell avg)
  1644. & ( tprecip(:,:) - sprecip(:,:) ) * zcptrain(:,:) )
  1645. IF( iom_use('hflx_snow_ao_cea') ) CALL iom_put('hflx_snow_ao_cea',sprecip(:,:) * (zcptsnw(:,:) - Lfus) * (1._wp - zsnw(:,:))) ! heat flux from snow (over ocean)
  1646. IF( iom_use('hflx_snow_ai_cea') ) CALL iom_put('hflx_snow_ai_cea',sprecip(:,:) * (zcptsnw(:,:) - Lfus) * zsnw(:,:) ) ! heat flux from snow (over ice)
  1647. ! note: hflx for runoff and iceshelf are done in sbcrnf and sbcisf resp.
  1648. !
  1649. ! ! ========================= !
  1650. SELECT CASE( TRIM( sn_rcv_qsr%cldes ) ) ! solar heat fluxes ! (qsr)
  1651. ! ! ========================= !
  1652. CASE( 'oce only' )
  1653. zqsr_tot(:,: ) = MAX( 0._wp , frcv(jpr_qsroce)%z3(:,:,1) )
  1654. CASE( 'conservative' )
  1655. zqsr_tot(:,: ) = frcv(jpr_qsrmix)%z3(:,:,1)
  1656. IF ( TRIM(sn_rcv_qsr%clcat) == 'yes' ) THEN
  1657. zqsr_ice(:,:,1:jpl) = frcv(jpr_qsrice)%z3(:,:,1:jpl)
  1658. ELSE
  1659. ! Set all category values equal for the moment
  1660. DO jl=1,jpl
  1661. zqsr_ice(:,:,jl) = frcv(jpr_qsrice)%z3(:,:,1)
  1662. ENDDO
  1663. ENDIF
  1664. zqsr_tot(:,: ) = frcv(jpr_qsrmix)%z3(:,:,1)
  1665. zqsr_ice(:,:,1) = frcv(jpr_qsrice)%z3(:,:,1)
  1666. CASE( 'oce and ice' )
  1667. zqsr_tot(:,: ) = p_frld(:,:) * frcv(jpr_qsroce)%z3(:,:,1)
  1668. IF ( TRIM(sn_rcv_qsr%clcat) == 'yes' ) THEN
  1669. DO jl=1,jpl
  1670. zqsr_tot(:,: ) = zqsr_tot(:,:) + a_i(:,:,jl) * frcv(jpr_qsrice)%z3(:,:,jl)
  1671. zqsr_ice(:,:,jl) = frcv(jpr_qsrice)%z3(:,:,jl)
  1672. ENDDO
  1673. ELSE
  1674. qsr_tot(:,: ) = qsr_tot(:,:) + zicefr(:,:) * frcv(jpr_qsrice)%z3(:,:,1)
  1675. DO jl=1,jpl
  1676. zqsr_tot(:,: ) = zqsr_tot(:,:) + zicefr(:,:) * frcv(jpr_qsrice)%z3(:,:,1)
  1677. zqsr_ice(:,:,jl) = frcv(jpr_qsrice)%z3(:,:,1)
  1678. ENDDO
  1679. ENDIF
  1680. CASE( 'mixed oce-ice' )
  1681. zqsr_tot(:,: ) = frcv(jpr_qsrmix)%z3(:,:,1)
  1682. ! ** NEED TO SORT OUT HOW THIS SHOULD WORK IN THE MULTI-CATEGORY CASE - CURRENTLY NOT ALLOWED WHEN INTERFACE INITIALISED **
  1683. ! Create solar heat flux over ice using incoming solar heat flux and albedos
  1684. ! ( see OASIS3 user guide, 5th edition, p39 )
  1685. zqsr_ice(:,:,1) = frcv(jpr_qsrmix)%z3(:,:,1) * ( 1.- palbi(:,:,1) ) &
  1686. & / ( 1.- ( albedo_oce_mix(:,: ) * p_frld(:,:) &
  1687. & + palbi (:,:,1) * zicefr(:,:) ) )
  1688. END SELECT
  1689. IF( ln_dm2dc .AND. ln_cpl ) THEN ! modify qsr to include the diurnal cycle
  1690. zqsr_tot(:,: ) = sbc_dcy( zqsr_tot(:,: ) )
  1691. DO jl=1,jpl
  1692. zqsr_ice(:,:,jl) = sbc_dcy( zqsr_ice(:,:,jl) )
  1693. ENDDO
  1694. ENDIF
  1695. #if defined key_lim3
  1696. ! --- solar flux over ocean --- !
  1697. ! note: p_frld cannot be = 0 since we limit the ice concentration to amax
  1698. zqsr_oce = 0._wp
  1699. WHERE( p_frld /= 0._wp ) zqsr_oce(:,:) = ( zqsr_tot(:,:) - SUM( a_i * zqsr_ice, dim=3 ) ) / p_frld(:,:)
  1700. IF( ln_mixcpl ) THEN ; qsr_oce(:,:) = qsr_oce(:,:) * xcplmask(:,:,0) + zqsr_oce(:,:)* zmsk(:,:)
  1701. ELSE ; qsr_oce(:,:) = zqsr_oce(:,:) ; ENDIF
  1702. #endif
  1703. IF( ln_mixcpl ) THEN
  1704. qsr_tot(:,:) = qsr(:,:) * p_frld(:,:) + SUM( qsr_ice(:,:,:) * a_i(:,:,:), dim=3 ) ! total flux from blk
  1705. qsr_tot(:,:) = qsr_tot(:,:) * xcplmask(:,:,0) + zqsr_tot(:,:)* zmsk(:,:)
  1706. DO jl=1,jpl
  1707. qsr_ice(:,:,jl) = qsr_ice(:,:,jl) * xcplmask(:,:,0) + zqsr_ice(:,:,jl)* zmsk(:,:)
  1708. ENDDO
  1709. ELSE
  1710. qsr_tot(:,: ) = zqsr_tot(:,: )
  1711. qsr_ice(:,:,:) = zqsr_ice(:,:,:)
  1712. ENDIF
  1713. ! ! ========================= !
  1714. SELECT CASE( TRIM( sn_rcv_dqnsdt%cldes ) ) ! d(qns)/dt !
  1715. ! ! ========================= !
  1716. CASE ('coupled')
  1717. IF ( TRIM(sn_rcv_dqnsdt%clcat) == 'yes' ) THEN
  1718. zdqns_ice(:,:,1:jpl) = frcv(jpr_dqnsdt)%z3(:,:,1:jpl)
  1719. ELSE
  1720. ! Set all category values equal for the moment
  1721. DO jl=1,jpl
  1722. zdqns_ice(:,:,jl) = frcv(jpr_dqnsdt)%z3(:,:,1)
  1723. ENDDO
  1724. ENDIF
  1725. END SELECT
  1726. IF( ln_mixcpl ) THEN
  1727. DO jl=1,jpl
  1728. dqns_ice(:,:,jl) = dqns_ice(:,:,jl) * xcplmask(:,:,0) + zdqns_ice(:,:,jl) * zmsk(:,:)
  1729. ENDDO
  1730. ELSE
  1731. dqns_ice(:,:,:) = zdqns_ice(:,:,:)
  1732. ENDIF
  1733. ! ! ========================= !
  1734. SELECT CASE( TRIM( sn_rcv_iceflx%cldes ) ) ! topmelt and botmelt !
  1735. ! ! ========================= !
  1736. CASE ('coupled')
  1737. topmelt(:,:,:)=frcv(jpr_topm)%z3(:,:,:)
  1738. botmelt(:,:,:)=frcv(jpr_botm)%z3(:,:,:)
  1739. END SELECT
  1740. ! Surface transimission parameter io (Maykut Untersteiner , 1971 ; Ebert and Curry, 1993 )
  1741. ! Used for LIM2 and LIM3
  1742. ! Coupled case: since cloud cover is not received from atmosphere
  1743. ! ===> used prescribed cloud fraction representative for polar oceans in summer (0.81)
  1744. fr1_i0(:,:) = ( 0.18 * ( 1.0 - cldf_ice ) + 0.35 * cldf_ice )
  1745. fr2_i0(:,:) = ( 0.82 * ( 1.0 - cldf_ice ) + 0.65 * cldf_ice )
  1746. CALL wrk_dealloc( jpi,jpj, zcptn, zcptrain, zcptsnw, zicefr, zmsk, zsnw )
  1747. CALL wrk_dealloc( jpi,jpj, zemp_tot, zemp_ice, zemp_oce, ztprecip, zsprecip, zevap_oce, zevap_ice, zdevap_ice )
  1748. CALL wrk_dealloc( jpi,jpj, zqns_tot, zqns_oce, zqsr_tot, zqsr_oce, zqprec_ice, zqemp_oce, zqemp_ice )
  1749. CALL wrk_dealloc( jpi,jpj,jpl, zqns_ice, zqsr_ice, zdqns_ice, zqevap_ice )
  1750. !
  1751. IF( nn_timing == 1 ) CALL timing_stop('sbc_cpl_ice_flx')
  1752. !
  1753. END SUBROUTINE sbc_cpl_ice_flx
  1754. SUBROUTINE sbc_cpl_snd( kt )
  1755. !!----------------------------------------------------------------------
  1756. !! *** ROUTINE sbc_cpl_snd ***
  1757. !!
  1758. !! ** Purpose : provide the ocean-ice informations to the atmosphere
  1759. !!
  1760. !! ** Method : send to the atmosphere through a call to cpl_snd
  1761. !! all the needed fields (as defined in sbc_cpl_init)
  1762. !!----------------------------------------------------------------------
  1763. INTEGER, INTENT(in) :: kt
  1764. !
  1765. INTEGER :: ji, jj, jl ! dummy loop indices
  1766. INTEGER :: isec, info ! local integer
  1767. REAL(wp) :: zumax, zvmax
  1768. REAL(wp), POINTER, DIMENSION(:,:) :: zfr_l, ztmp1, ztmp2, zotx1, zoty1, zotz1, zitx1, zity1, zitz1
  1769. REAL(wp), POINTER, DIMENSION(:,:,:) :: ztmp3, ztmp4
  1770. !!----------------------------------------------------------------------
  1771. !
  1772. IF( nn_timing == 1 ) CALL timing_start('sbc_cpl_snd')
  1773. !
  1774. CALL wrk_alloc( jpi,jpj, zfr_l, ztmp1, ztmp2, zotx1, zoty1, zotz1, zitx1, zity1, zitz1 )
  1775. CALL wrk_alloc( jpi,jpj,jpl, ztmp3, ztmp4 )
  1776. isec = ( kt - nit000 ) * NINT(rdttra(1)) ! date of exchanges
  1777. zfr_l(:,:) = 1.- fr_i(:,:)
  1778. ! ! ------------------------- !
  1779. ! ! Surface temperature ! in Kelvin
  1780. ! ! ------------------------- !
  1781. IF( ssnd(jps_toce)%laction .OR. ssnd(jps_tice)%laction .OR. ssnd(jps_tmix)%laction ) THEN
  1782. IF ( nn_components == jp_iam_opa ) THEN
  1783. ztmp1(:,:) = tsn(:,:,1,jp_tem) ! send temperature as it is (potential or conservative) -> use of ln_useCT on the received part
  1784. ELSE
  1785. ! we must send the surface potential temperature
  1786. IF( ln_useCT ) THEN ; ztmp1(:,:) = eos_pt_from_ct( tsn(:,:,1,jp_tem), tsn(:,:,1,jp_sal) )
  1787. ELSE ; ztmp1(:,:) = tsn(:,:,1,jp_tem)
  1788. ENDIF
  1789. !
  1790. SELECT CASE( sn_snd_temp%cldes)
  1791. CASE( 'oce only' ) ; ztmp1(:,:) = ztmp1(:,:) + rt0
  1792. CASE( 'oce and ice' ) ; ztmp1(:,:) = ztmp1(:,:) + rt0
  1793. SELECT CASE( sn_snd_temp%clcat )
  1794. CASE( 'yes' )
  1795. ztmp3(:,:,1:jpl) = tn_ice(:,:,1:jpl)
  1796. CASE( 'no' )
  1797. WHERE( SUM( a_i, dim=3 ) /= 0. )
  1798. ztmp3(:,:,1) = SUM( tn_ice * a_i, dim=3 ) / SUM( a_i, dim=3 )
  1799. ELSEWHERE
  1800. ztmp3(:,:,1) = rt0
  1801. END WHERE
  1802. CASE default ; CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_temp%clcat' )
  1803. END SELECT
  1804. CASE( 'weighted oce and ice' ) ; ztmp1(:,:) = ( ztmp1(:,:) + rt0 ) * zfr_l(:,:)
  1805. SELECT CASE( sn_snd_temp%clcat )
  1806. CASE( 'yes' )
  1807. ztmp3(:,:,1:jpl) = tn_ice(:,:,1:jpl) * a_i(:,:,1:jpl)
  1808. CASE( 'no' )
  1809. ztmp3(:,:,:) = 0.0
  1810. DO jl=1,jpl
  1811. ztmp3(:,:,1) = ztmp3(:,:,1) + tn_ice(:,:,jl) * a_i(:,:,jl)
  1812. ENDDO
  1813. CASE default ; CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_temp%clcat' )
  1814. END SELECT
  1815. CASE( 'mixed oce-ice' )
  1816. ztmp1(:,:) = ( ztmp1(:,:) + rt0 ) * zfr_l(:,:)
  1817. DO jl=1,jpl
  1818. ztmp1(:,:) = ztmp1(:,:) + tn_ice(:,:,jl) * a_i(:,:,jl)
  1819. ENDDO
  1820. CASE default ; CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_temp%cldes' )
  1821. END SELECT
  1822. ENDIF
  1823. IF( ssnd(jps_toce)%laction ) CALL cpl_snd( jps_toce, isec, RESHAPE ( ztmp1, (/jpi,jpj,1/) ), info )
  1824. IF( ssnd(jps_tice)%laction ) CALL cpl_snd( jps_tice, isec, ztmp3, info )
  1825. IF( ssnd(jps_tmix)%laction ) CALL cpl_snd( jps_tmix, isec, RESHAPE ( ztmp1, (/jpi,jpj,1/) ), info )
  1826. ENDIF
  1827. ! ! ------------------------- !
  1828. ! ! Albedo !
  1829. ! ! ------------------------- !
  1830. IF( ssnd(jps_albice)%laction ) THEN ! ice
  1831. SELECT CASE( sn_snd_alb%cldes )
  1832. CASE( 'ice' )
  1833. SELECT CASE( sn_snd_alb%clcat )
  1834. CASE( 'yes' )
  1835. ztmp3(:,:,1:jpl) = alb_ice(:,:,1:jpl)
  1836. CASE( 'no' )
  1837. WHERE( SUM( a_i, dim=3 ) /= 0. )
  1838. ztmp1(:,:) = SUM( alb_ice (:,:,1:jpl) * a_i(:,:,1:jpl), dim=3 ) / SUM( a_i(:,:,1:jpl), dim=3 )
  1839. ELSEWHERE
  1840. ztmp1(:,:) = albedo_oce_mix(:,:)
  1841. END WHERE
  1842. CASE default ; CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_alb%clcat' )
  1843. END SELECT
  1844. CASE( 'weighted ice' ) ;
  1845. SELECT CASE( sn_snd_alb%clcat )
  1846. CASE( 'yes' )
  1847. ztmp3(:,:,1:jpl) = alb_ice(:,:,1:jpl) * a_i(:,:,1:jpl)
  1848. CASE( 'no' )
  1849. WHERE( fr_i (:,:) > 0. )
  1850. ztmp1(:,:) = SUM ( alb_ice(:,:,1:jpl) * a_i(:,:,1:jpl), dim=3 )
  1851. ELSEWHERE
  1852. ztmp1(:,:) = 0.
  1853. END WHERE
  1854. CASE default ; CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_ice%clcat' )
  1855. END SELECT
  1856. CASE default ; CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_alb%cldes' )
  1857. END SELECT
  1858. SELECT CASE( sn_snd_alb%clcat )
  1859. CASE( 'yes' )
  1860. CALL cpl_snd( jps_albice, isec, ztmp3, info ) !-> MV this has never been checked in coupled mode
  1861. CASE( 'no' )
  1862. CALL cpl_snd( jps_albice, isec, RESHAPE ( ztmp1, (/jpi,jpj,1/) ), info )
  1863. END SELECT
  1864. ENDIF
  1865. IF( ssnd(jps_albmix)%laction ) THEN ! mixed ice-ocean
  1866. ztmp1(:,:) = albedo_oce_mix(:,:) * zfr_l(:,:)
  1867. DO jl=1,jpl
  1868. ztmp1(:,:) = ztmp1(:,:) + alb_ice(:,:,jl) * a_i(:,:,jl)
  1869. ENDDO
  1870. CALL cpl_snd( jps_albmix, isec, RESHAPE ( ztmp1, (/jpi,jpj,1/) ), info )
  1871. ENDIF
  1872. ! ! ------------------------- !
  1873. ! ! Ice fraction & Thickness !
  1874. ! ! ------------------------- !
  1875. ! Send ice fraction field to atmosphere
  1876. IF( ssnd(jps_fice)%laction ) THEN
  1877. SELECT CASE( sn_snd_thick%clcat )
  1878. CASE( 'yes' ) ; ztmp3(:,:,1:jpl) = a_i(:,:,1:jpl)
  1879. CASE( 'no' ) ; ztmp3(:,:,1 ) = fr_i(:,: )
  1880. CASE default ; CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_thick%clcat' )
  1881. END SELECT
  1882. IF( ssnd(jps_fice)%laction ) CALL cpl_snd( jps_fice, isec, ztmp3, info )
  1883. ENDIF
  1884. ! Send ice fraction field to OPA (sent by SAS in SAS-OPA coupling)
  1885. IF( ssnd(jps_fice2)%laction ) THEN
  1886. ztmp3(:,:,1) = fr_i(:,:)
  1887. IF( ssnd(jps_fice2)%laction ) CALL cpl_snd( jps_fice2, isec, ztmp3, info )
  1888. ENDIF
  1889. ! Send ice and snow thickness field
  1890. IF( ssnd(jps_hice)%laction .OR. ssnd(jps_hsnw)%laction ) THEN
  1891. SELECT CASE( sn_snd_thick%cldes)
  1892. CASE( 'none' ) ! nothing to do
  1893. CASE( 'weighted ice and snow' )
  1894. SELECT CASE( sn_snd_thick%clcat )
  1895. CASE( 'yes' )
  1896. ztmp3(:,:,1:jpl) = ht_i(:,:,1:jpl) * a_i(:,:,1:jpl)
  1897. ztmp4(:,:,1:jpl) = ht_s(:,:,1:jpl) * a_i(:,:,1:jpl)
  1898. CASE( 'no' )
  1899. ztmp3(:,:,:) = 0.0 ; ztmp4(:,:,:) = 0.0
  1900. DO jl=1,jpl
  1901. ztmp3(:,:,1) = ztmp3(:,:,1) + ht_i(:,:,jl) * a_i(:,:,jl)
  1902. ztmp4(:,:,1) = ztmp4(:,:,1) + ht_s(:,:,jl) * a_i(:,:,jl)
  1903. ENDDO
  1904. CASE default ; CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_thick%clcat' )
  1905. END SELECT
  1906. CASE( 'ice and snow' )
  1907. SELECT CASE( sn_snd_thick%clcat )
  1908. CASE( 'yes' )
  1909. ztmp3(:,:,1:jpl) = ht_i(:,:,1:jpl)
  1910. ztmp4(:,:,1:jpl) = ht_s(:,:,1:jpl)
  1911. CASE( 'no' )
  1912. WHERE( SUM( a_i, dim=3 ) /= 0. )
  1913. ztmp3(:,:,1) = SUM( ht_i * a_i, dim=3 ) / SUM( a_i, dim=3 )
  1914. ztmp4(:,:,1) = SUM( ht_s * a_i, dim=3 ) / SUM( a_i, dim=3 )
  1915. ELSEWHERE
  1916. ztmp3(:,:,1) = 0.
  1917. ztmp4(:,:,1) = 0.
  1918. END WHERE
  1919. CASE default ; CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_thick%clcat' )
  1920. END SELECT
  1921. CASE default ; CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_thick%cldes' )
  1922. END SELECT
  1923. IF( ssnd(jps_hice)%laction ) CALL cpl_snd( jps_hice, isec, ztmp3, info )
  1924. IF( ssnd(jps_hsnw)%laction ) CALL cpl_snd( jps_hsnw, isec, ztmp4, info )
  1925. ENDIF
  1926. !
  1927. #if defined key_cpl_carbon_cycle
  1928. ! ! ------------------------- !
  1929. ! ! CO2 flux from PISCES !
  1930. ! ! ------------------------- !
  1931. IF( ssnd(jps_co2)%laction ) CALL cpl_snd( jps_co2, isec, - RESHAPE ( oce_co2, (/jpi,jpj,1/) ) , info )
  1932. !
  1933. #endif
  1934. ! ! ------------------------- !
  1935. IF( ssnd(jps_ocx1)%laction ) THEN ! Surface current !
  1936. ! ! ------------------------- !
  1937. !
  1938. ! j+1 j -----V---F
  1939. ! surface velocity always sent from T point ! |
  1940. ! j | T U
  1941. ! | |
  1942. ! j j-1 -I-------|
  1943. ! (for I) | |
  1944. ! i-1 i i
  1945. ! i i+1 (for I)
  1946. IF( nn_components == jp_iam_opa ) THEN
  1947. zotx1(:,:) = un(:,:,1)
  1948. zoty1(:,:) = vn(:,:,1)
  1949. ELSE
  1950. SELECT CASE( TRIM( sn_snd_crt%cldes ) )
  1951. CASE( 'oce only' ) ! C-grid ==> T
  1952. DO jj = 2, jpjm1
  1953. DO ji = fs_2, fs_jpim1 ! vector opt.
  1954. zotx1(ji,jj) = 0.5 * ( un(ji,jj,1) + un(ji-1,jj ,1) )
  1955. zoty1(ji,jj) = 0.5 * ( vn(ji,jj,1) + vn(ji ,jj-1,1) )
  1956. END DO
  1957. END DO
  1958. CASE( 'weighted oce and ice' )
  1959. SELECT CASE ( cp_ice_msh )
  1960. CASE( 'C' ) ! Ocean and Ice on C-grid ==> T
  1961. DO jj = 2, jpjm1
  1962. DO ji = fs_2, fs_jpim1 ! vector opt.
  1963. zotx1(ji,jj) = 0.5 * ( un (ji,jj,1) + un (ji-1,jj ,1) ) * zfr_l(ji,jj)
  1964. zoty1(ji,jj) = 0.5 * ( vn (ji,jj,1) + vn (ji ,jj-1,1) ) * zfr_l(ji,jj)
  1965. zitx1(ji,jj) = 0.5 * ( u_ice(ji,jj ) + u_ice(ji-1,jj ) ) * fr_i(ji,jj)
  1966. zity1(ji,jj) = 0.5 * ( v_ice(ji,jj ) + v_ice(ji ,jj-1 ) ) * fr_i(ji,jj)
  1967. END DO
  1968. END DO
  1969. CASE( 'I' ) ! Ocean on C grid, Ice on I-point (B-grid) ==> T
  1970. DO jj = 2, jpjm1
  1971. DO ji = 2, jpim1 ! NO vector opt.
  1972. zotx1(ji,jj) = 0.5 * ( un(ji,jj,1) + un(ji-1,jj ,1) ) * zfr_l(ji,jj)
  1973. zoty1(ji,jj) = 0.5 * ( vn(ji,jj,1) + vn(ji ,jj-1,1) ) * zfr_l(ji,jj)
  1974. zitx1(ji,jj) = 0.25 * ( u_ice(ji+1,jj+1) + u_ice(ji,jj+1) &
  1975. & + u_ice(ji+1,jj ) + u_ice(ji,jj ) ) * fr_i(ji,jj)
  1976. zity1(ji,jj) = 0.25 * ( v_ice(ji+1,jj+1) + v_ice(ji,jj+1) &
  1977. & + v_ice(ji+1,jj ) + v_ice(ji,jj ) ) * fr_i(ji,jj)
  1978. END DO
  1979. END DO
  1980. CASE( 'F' ) ! Ocean on C grid, Ice on F-point (B-grid) ==> T
  1981. DO jj = 2, jpjm1
  1982. DO ji = 2, jpim1 ! NO vector opt.
  1983. zotx1(ji,jj) = 0.5 * ( un(ji,jj,1) + un(ji-1,jj ,1) ) * zfr_l(ji,jj)
  1984. zoty1(ji,jj) = 0.5 * ( vn(ji,jj,1) + vn(ji ,jj-1,1) ) * zfr_l(ji,jj)
  1985. zitx1(ji,jj) = 0.25 * ( u_ice(ji-1,jj-1) + u_ice(ji,jj-1) &
  1986. & + u_ice(ji-1,jj ) + u_ice(ji,jj ) ) * fr_i(ji,jj)
  1987. zity1(ji,jj) = 0.25 * ( v_ice(ji-1,jj-1) + v_ice(ji,jj-1) &
  1988. & + v_ice(ji-1,jj ) + v_ice(ji,jj ) ) * fr_i(ji,jj)
  1989. END DO
  1990. END DO
  1991. END SELECT
  1992. CALL lbc_lnk( zitx1, 'T', -1. ) ; CALL lbc_lnk( zity1, 'T', -1. )
  1993. CASE( 'mixed oce-ice' )
  1994. SELECT CASE ( cp_ice_msh )
  1995. CASE( 'C' ) ! Ocean and Ice on C-grid ==> T
  1996. DO jj = 2, jpjm1
  1997. DO ji = fs_2, fs_jpim1 ! vector opt.
  1998. zotx1(ji,jj) = 0.5 * ( un (ji,jj,1) + un (ji-1,jj ,1) ) * zfr_l(ji,jj) &
  1999. & + 0.5 * ( u_ice(ji,jj ) + u_ice(ji-1,jj ) ) * fr_i(ji,jj)
  2000. zoty1(ji,jj) = 0.5 * ( vn (ji,jj,1) + vn (ji ,jj-1,1) ) * zfr_l(ji,jj) &
  2001. & + 0.5 * ( v_ice(ji,jj ) + v_ice(ji ,jj-1 ) ) * fr_i(ji,jj)
  2002. END DO
  2003. END DO
  2004. CASE( 'I' ) ! Ocean on C grid, Ice on I-point (B-grid) ==> T
  2005. DO jj = 2, jpjm1
  2006. DO ji = 2, jpim1 ! NO vector opt.
  2007. zotx1(ji,jj) = 0.5 * ( un(ji,jj,1) + un(ji-1,jj ,1) ) * zfr_l(ji,jj) &
  2008. & + 0.25 * ( u_ice(ji+1,jj+1) + u_ice(ji,jj+1) &
  2009. & + u_ice(ji+1,jj ) + u_ice(ji,jj ) ) * fr_i(ji,jj)
  2010. zoty1(ji,jj) = 0.5 * ( vn(ji,jj,1) + vn(ji ,jj-1,1) ) * zfr_l(ji,jj) &
  2011. & + 0.25 * ( v_ice(ji+1,jj+1) + v_ice(ji,jj+1) &
  2012. & + v_ice(ji+1,jj ) + v_ice(ji,jj ) ) * fr_i(ji,jj)
  2013. END DO
  2014. END DO
  2015. CASE( 'F' ) ! Ocean on C grid, Ice on F-point (B-grid) ==> T
  2016. DO jj = 2, jpjm1
  2017. DO ji = 2, jpim1 ! NO vector opt.
  2018. zotx1(ji,jj) = 0.5 * ( un(ji,jj,1) + un(ji-1,jj ,1) ) * zfr_l(ji,jj) &
  2019. & + 0.25 * ( u_ice(ji-1,jj-1) + u_ice(ji,jj-1) &
  2020. & + u_ice(ji-1,jj ) + u_ice(ji,jj ) ) * fr_i(ji,jj)
  2021. zoty1(ji,jj) = 0.5 * ( vn(ji,jj,1) + vn(ji ,jj-1,1) ) * zfr_l(ji,jj) &
  2022. & + 0.25 * ( v_ice(ji-1,jj-1) + v_ice(ji,jj-1) &
  2023. & + v_ice(ji-1,jj ) + v_ice(ji,jj ) ) * fr_i(ji,jj)
  2024. END DO
  2025. END DO
  2026. END SELECT
  2027. END SELECT
  2028. CALL lbc_lnk( zotx1, ssnd(jps_ocx1)%clgrid, -1. ) ; CALL lbc_lnk( zoty1, ssnd(jps_ocy1)%clgrid, -1. )
  2029. !
  2030. ENDIF
  2031. !
  2032. !
  2033. IF( TRIM( sn_snd_crt%clvor ) == 'eastward-northward' ) THEN ! Rotation of the components
  2034. ! ! Ocean component
  2035. CALL rot_rep( zotx1, zoty1, ssnd(jps_ocx1)%clgrid, 'ij->e', ztmp1 ) ! 1st component
  2036. CALL rot_rep( zotx1, zoty1, ssnd(jps_ocx1)%clgrid, 'ij->n', ztmp2 ) ! 2nd component
  2037. zotx1(:,:) = ztmp1(:,:) ! overwrite the components
  2038. zoty1(:,:) = ztmp2(:,:)
  2039. IF( ssnd(jps_ivx1)%laction ) THEN ! Ice component
  2040. CALL rot_rep( zitx1, zity1, ssnd(jps_ivx1)%clgrid, 'ij->e', ztmp1 ) ! 1st component
  2041. CALL rot_rep( zitx1, zity1, ssnd(jps_ivx1)%clgrid, 'ij->n', ztmp2 ) ! 2nd component
  2042. zitx1(:,:) = ztmp1(:,:) ! overwrite the components
  2043. zity1(:,:) = ztmp2(:,:)
  2044. ENDIF
  2045. ENDIF
  2046. !
  2047. ! spherical coordinates to cartesian -> 2 components to 3 components
  2048. IF( TRIM( sn_snd_crt%clvref ) == 'cartesian' ) THEN
  2049. ztmp1(:,:) = zotx1(:,:) ! ocean currents
  2050. ztmp2(:,:) = zoty1(:,:)
  2051. CALL oce2geo ( ztmp1, ztmp2, 'T', zotx1, zoty1, zotz1 )
  2052. !
  2053. IF( ssnd(jps_ivx1)%laction ) THEN ! ice velocities
  2054. ztmp1(:,:) = zitx1(:,:)
  2055. ztmp1(:,:) = zity1(:,:)
  2056. CALL oce2geo ( ztmp1, ztmp2, 'T', zitx1, zity1, zitz1 )
  2057. ENDIF
  2058. ENDIF
  2059. !
  2060. IF( ssnd(jps_ocx1)%laction ) CALL cpl_snd( jps_ocx1, isec, RESHAPE ( zotx1, (/jpi,jpj,1/) ), info ) ! ocean x current 1st grid
  2061. IF( ssnd(jps_ocy1)%laction ) CALL cpl_snd( jps_ocy1, isec, RESHAPE ( zoty1, (/jpi,jpj,1/) ), info ) ! ocean y current 1st grid
  2062. IF( ssnd(jps_ocz1)%laction ) CALL cpl_snd( jps_ocz1, isec, RESHAPE ( zotz1, (/jpi,jpj,1/) ), info ) ! ocean z current 1st grid
  2063. !
  2064. IF( ssnd(jps_ivx1)%laction ) CALL cpl_snd( jps_ivx1, isec, RESHAPE ( zitx1, (/jpi,jpj,1/) ), info ) ! ice x current 1st grid
  2065. IF( ssnd(jps_ivy1)%laction ) CALL cpl_snd( jps_ivy1, isec, RESHAPE ( zity1, (/jpi,jpj,1/) ), info ) ! ice y current 1st grid
  2066. IF( ssnd(jps_ivz1)%laction ) CALL cpl_snd( jps_ivz1, isec, RESHAPE ( zitz1, (/jpi,jpj,1/) ), info ) ! ice z current 1st grid
  2067. !
  2068. ENDIF
  2069. !
  2070. !
  2071. ! Fields sent by OPA to SAS when doing OPA<->SAS coupling
  2072. ! ! SSH
  2073. IF( ssnd(jps_ssh )%laction ) THEN
  2074. ! ! removed inverse barometer ssh when Patm
  2075. ! forcing is used (for sea-ice dynamics)
  2076. IF( ln_apr_dyn ) THEN ; ztmp1(:,:) = sshb(:,:) - 0.5 * ( ssh_ib(:,:) + ssh_ibb(:,:) )
  2077. ELSE ; ztmp1(:,:) = sshn(:,:)
  2078. ENDIF
  2079. CALL cpl_snd( jps_ssh , isec, RESHAPE ( ztmp1 , (/jpi,jpj,1/) ), info )
  2080. ENDIF
  2081. ! ! SSS
  2082. IF( ssnd(jps_soce )%laction ) THEN
  2083. CALL cpl_snd( jps_soce , isec, RESHAPE ( tsn(:,:,1,jp_sal), (/jpi,jpj,1/) ), info )
  2084. ENDIF
  2085. ! ! first T level thickness
  2086. IF( ssnd(jps_e3t1st )%laction ) THEN
  2087. CALL cpl_snd( jps_e3t1st, isec, RESHAPE ( fse3t_n(:,:,1) , (/jpi,jpj,1/) ), info )
  2088. ENDIF
  2089. ! ! Qsr fraction
  2090. IF( ssnd(jps_fraqsr)%laction ) THEN
  2091. CALL cpl_snd( jps_fraqsr, isec, RESHAPE ( fraqsr_1lev(:,:) , (/jpi,jpj,1/) ), info )
  2092. ENDIF
  2093. !
  2094. ! Fields sent by SAS to OPA when OASIS coupling
  2095. ! ! Solar heat flux
  2096. IF( ssnd(jps_qsroce)%laction ) CALL cpl_snd( jps_qsroce, isec, RESHAPE ( qsr , (/jpi,jpj,1/) ), info )
  2097. IF( ssnd(jps_qnsoce)%laction ) CALL cpl_snd( jps_qnsoce, isec, RESHAPE ( qns , (/jpi,jpj,1/) ), info )
  2098. IF( ssnd(jps_oemp )%laction ) CALL cpl_snd( jps_oemp , isec, RESHAPE ( emp , (/jpi,jpj,1/) ), info )
  2099. IF( ssnd(jps_sflx )%laction ) CALL cpl_snd( jps_sflx , isec, RESHAPE ( sfx , (/jpi,jpj,1/) ), info )
  2100. IF( ssnd(jps_otx1 )%laction ) CALL cpl_snd( jps_otx1 , isec, RESHAPE ( utau, (/jpi,jpj,1/) ), info )
  2101. IF( ssnd(jps_oty1 )%laction ) CALL cpl_snd( jps_oty1 , isec, RESHAPE ( vtau, (/jpi,jpj,1/) ), info )
  2102. IF( ssnd(jps_rnf )%laction ) CALL cpl_snd( jps_rnf , isec, RESHAPE ( rnf , (/jpi,jpj,1/) ), info )
  2103. IF( ssnd(jps_taum )%laction ) CALL cpl_snd( jps_taum , isec, RESHAPE ( taum, (/jpi,jpj,1/) ), info )
  2104. CALL wrk_dealloc( jpi,jpj, zfr_l, ztmp1, ztmp2, zotx1, zoty1, zotz1, zitx1, zity1, zitz1 )
  2105. CALL wrk_dealloc( jpi,jpj,jpl, ztmp3, ztmp4 )
  2106. !
  2107. IF( nn_timing == 1 ) CALL timing_stop('sbc_cpl_snd')
  2108. !
  2109. END SUBROUTINE sbc_cpl_snd
  2110. !!======================================================================
  2111. END MODULE sbccpl