crsdom.F90 111 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306
  1. MODULE crsdom
  2. !!===================================================================
  3. !! *** crs.F90 ***
  4. !! Purpose: Interface for calculating quantities from a
  5. !! higher-resolution grid for the coarse grid.
  6. !!
  7. !! Method: Given the user-defined reduction factor,
  8. !! the averaging bins are set:
  9. !! - nn_binref = 0, starting from the north
  10. !! to the south in the model interior domain,
  11. !! in this way the north fold and redundant halo cells
  12. !! could be handled in a consistent manner and
  13. !! the irregularities of bin size can be handled
  14. !! more naturally by the presence of land
  15. !! in the southern boundary. Thus the southernmost bin
  16. !! could be of an irregular bin size.
  17. !! Information on the parent grid is retained, specifically,
  18. !! each coarse grid cell's volume and ocean surface
  19. !! at the faces, relative to the parent grid.
  20. !! - nn_binref = 1 (not yet available), starting
  21. !! at a centralized bin at the equator, being only
  22. !! truly centered for odd-numbered j-direction reduction
  23. !! factors.
  24. !! References: Aumont, O., J.C. Orr, D. Jamous, P. Monfray
  25. !! O. Marti and G. Madec, 1998. A degradation
  26. !! approach to accelerate simulations to steady-state
  27. !! in a 3-D tracer transport model of the global ocean.
  28. !! Climate Dynamics, 14:101-116.
  29. !! History:
  30. !! Original. May 2012. (J. Simeon, C. Calone, G. Madec, C. Ethe)
  31. !!===================================================================
  32. USE dom_oce ! ocean space and time domain and to get jperio
  33. USE wrk_nemo ! work arrays
  34. USE crs ! domain for coarse grid
  35. USE in_out_manager
  36. USE par_kind
  37. USE crslbclnk
  38. USE lib_mpp
  39. IMPLICIT NONE
  40. PRIVATE
  41. PUBLIC crs_dom_ope
  42. PUBLIC crs_dom_e3, crs_dom_sfc, crs_dom_msk, crs_dom_hgr, crs_dom_coordinates
  43. PUBLIC crs_dom_facvol, crs_dom_def, crs_dom_bat
  44. INTERFACE crs_dom_ope
  45. MODULE PROCEDURE crs_dom_ope_3d, crs_dom_ope_2d
  46. END INTERFACE
  47. REAL(wp) :: r_inf = 1e+36
  48. !! Substitutions
  49. # include "domzgr_substitute.h90"
  50. !! $Id: crsdom.F90 2422 2015-06-05 12:04:13Z ufla $
  51. CONTAINS
  52. SUBROUTINE crs_dom_msk
  53. INTEGER :: ji, jj, jk ! dummy loop indices
  54. INTEGER :: ijie,ijis,ijje,ijjs,ij,je_2
  55. REAL(wp) :: zmask
  56. ! Initialize
  57. tmask_crs(:,:,:) = 0.0
  58. vmask_crs(:,:,:) = 0.0
  59. umask_crs(:,:,:) = 0.0
  60. fmask_crs(:,:,:) = 0.0
  61. IF( nldj_crs == 1 .AND. ( ( mje_crs(2) - mjs_crs(2) ) < 2 ) ) THEN !!cc bande du sud style ORCA2
  62. IF( mje_crs(2) - mjs_crs(2) == 1 ) THEN
  63. je_2 = mje_crs(2) ; ij = je_2
  64. ENDIF
  65. ELSE
  66. je_2 = mje_crs(2) ; ij = mjs_crs(2)
  67. ENDIF
  68. DO jk = 1, jpkm1
  69. DO ji = 2, nlei_crs
  70. ijis = mis_crs(ji) ; ijie = mie_crs(ji)
  71. !
  72. zmask = 0.0
  73. zmask = SUM( tmask(ijis:ijie,ij:je_2,jk) )
  74. IF ( zmask > 0.0 ) tmask_crs(ji,2,jk) = 1.0
  75. zmask = 0.0
  76. zmask = SUM( vmask(ijis:ijie,je_2 ,jk) )
  77. IF ( zmask > 0.0 ) vmask_crs(ji,2,jk) = 1.0
  78. zmask = 0.0
  79. zmask = SUM(umask(ijie,ij:je_2,jk))
  80. IF ( zmask > 0.0 ) umask_crs(ji,2,jk) = 1.0
  81. fmask_crs(ji,je_2,jk) = fmask(ijie,2,jk)
  82. ENDDO
  83. ENDDO
  84. !
  85. DO jk = 1, jpkm1
  86. DO ji = 2, nlei_crs
  87. ijis = mis_crs(ji) ; ijie = mie_crs(ji)
  88. DO jj = 3, nlej_crs
  89. ijjs = mjs_crs(jj) ; ijje = mje_crs(jj)
  90. zmask = 0.0
  91. zmask = SUM( tmask(ijis:ijie,ijjs:ijje,jk) )
  92. IF ( zmask > 0.0 ) tmask_crs(ji,jj,jk) = 1.0
  93. zmask = 0.0
  94. zmask = SUM( vmask(ijis:ijie,ijje ,jk) )
  95. IF ( zmask > 0.0 ) vmask_crs(ji,jj,jk) = 1.0
  96. zmask = 0.0
  97. zmask = SUM( umask(ijie ,ijjs:ijje,jk) )
  98. IF ( zmask > 0.0 ) umask_crs(ji,jj,jk) = 1.0
  99. fmask_crs(ji,jj,jk) = fmask(ijie,ijje,jk)
  100. ENDDO
  101. ENDDO
  102. ENDDO
  103. !
  104. CALL crs_lbc_lnk( tmask_crs, 'T', 1.0 )
  105. CALL crs_lbc_lnk( vmask_crs, 'V', 1.0 )
  106. CALL crs_lbc_lnk( umask_crs, 'U', 1.0 )
  107. CALL crs_lbc_lnk( fmask_crs, 'F', 1.0 )
  108. !
  109. END SUBROUTINE crs_dom_msk
  110. SUBROUTINE crs_dom_coordinates( p_gphi, p_glam, cd_type, p_gphi_crs, p_glam_crs )
  111. !!----------------------------------------------------------------
  112. !! *** SUBROUTINE crs_coordinates ***
  113. !! ** Purpose : Determine the coordinates for the coarse grid
  114. !!
  115. !! ** Method : From the parent grid subset, search for the central
  116. !! point. For an odd-numbered reduction factor,
  117. !! the coordinate will be that of the central T-cell.
  118. !! For an even-numbered reduction factor, of a non-square
  119. !! coarse grid box, the coordinate will be that of
  120. !! the east or north face or more likely. For a square
  121. !! coarse grid box, the coordinate will be that of
  122. !! the central f-corner.
  123. !!
  124. !! ** Input : p_gphi = parent grid gphi[t|u|v|f]
  125. !! p_glam = parent grid glam[t|u|v|f]
  126. !! cd_type = grid type (T,U,V,F)
  127. !! ** Output : p_gphi_crs = coarse grid gphi[t|u|v|f]
  128. !! p_glam_crs = coarse grid glam[t|u|v|f]
  129. !!
  130. !! History. 1 Jun.
  131. !!----------------------------------------------------------------
  132. !! Arguments
  133. REAL(wp), DIMENSION(jpi,jpj) , INTENT(in) :: p_gphi ! Parent grid latitude
  134. REAL(wp), DIMENSION(jpi,jpj) , INTENT(in) :: p_glam ! Parent grid longitude
  135. CHARACTER(len=1), INTENT(in) :: cd_type ! grid type (T,U,V,F)
  136. REAL(wp), DIMENSION(jpi_crs,jpj_crs), INTENT(out) :: p_gphi_crs ! Coarse grid latitude
  137. REAL(wp), DIMENSION(jpi_crs,jpj_crs), INTENT(out) :: p_glam_crs ! Coarse grid longitude
  138. !! Local variables
  139. INTEGER :: ji, jj, jk ! dummy loop indices
  140. INTEGER :: ijis, ijjs
  141. SELECT CASE ( cd_type )
  142. CASE ( 'T' )
  143. DO jj = nldj_crs, nlej_crs
  144. ijjs = mjs_crs(jj) + mybinctr
  145. DO ji = 2, nlei_crs
  146. ijis = mis_crs(ji) + mxbinctr
  147. p_gphi_crs(ji,jj) = p_gphi(ijis,ijjs)
  148. p_glam_crs(ji,jj) = p_glam(ijis,ijjs)
  149. ENDDO
  150. ENDDO
  151. CASE ( 'U' )
  152. DO jj = nldj_crs, nlej_crs
  153. ijjs = mjs_crs(jj) + mybinctr
  154. DO ji = 2, nlei_crs
  155. ijis = mis_crs(ji)
  156. p_gphi_crs(ji,jj) = p_gphi(ijis,ijjs)
  157. p_glam_crs(ji,jj) = p_glam(ijis,ijjs)
  158. ENDDO
  159. ENDDO
  160. CASE ( 'V' )
  161. DO jj = nldj_crs, nlej_crs
  162. ijjs = mjs_crs(jj)
  163. DO ji = 2, nlei_crs
  164. ijis = mis_crs(ji) + mxbinctr
  165. p_gphi_crs(ji,jj) = p_gphi(ijis,ijjs)
  166. p_glam_crs(ji,jj) = p_glam(ijis,ijjs)
  167. ENDDO
  168. ENDDO
  169. CASE ( 'F' )
  170. DO jj = nldj_crs, nlej_crs
  171. ijjs = mjs_crs(jj)
  172. DO ji = 2, nlei_crs
  173. ijis = mis_crs(ji)
  174. p_gphi_crs(ji,jj) = p_gphi(ijis,ijjs)
  175. p_glam_crs(ji,jj) = p_glam(ijis,ijjs)
  176. ENDDO
  177. ENDDO
  178. END SELECT
  179. ! Retroactively add back the boundary halo cells.
  180. CALL crs_lbc_lnk( p_gphi_crs, cd_type, 1.0 )
  181. CALL crs_lbc_lnk( p_glam_crs, cd_type, 1.0 )
  182. ! Fill up jrow=1 which is zeroed out or not handled by lbc_lnk and lbc_nfd
  183. SELECT CASE ( cd_type )
  184. CASE ( 'T', 'V' )
  185. DO ji = 2, nlei_crs
  186. ijis = mis_crs(ji) + mxbinctr
  187. p_gphi_crs(ji,1) = p_gphi(ijis,1)
  188. p_glam_crs(ji,1) = p_glam(ijis,1)
  189. ENDDO
  190. CASE ( 'U', 'F' )
  191. DO ji = 2, nlei_crs
  192. ijis = mis_crs(ji)
  193. p_gphi_crs(ji,1) = p_gphi(ijis,1)
  194. p_glam_crs(ji,1) = p_glam(ijis,1)
  195. ENDDO
  196. END SELECT
  197. !
  198. END SUBROUTINE crs_dom_coordinates
  199. SUBROUTINE crs_dom_hgr( p_e1, p_e2, cd_type, p_e1_crs, p_e2_crs )
  200. !!----------------------------------------------------------------
  201. !! *** SUBROUTINE crs_dom_hgr ***
  202. !!
  203. !! ** Purpose : Get coarse grid horizontal scale factors and unmasked fraction
  204. !!
  205. !! ** Method : For grid types T,U,V,Fthe 2D scale factors of
  206. !! the coarse grid are the sum of the east or north faces of the
  207. !! parent grid subset comprising the coarse grid box.
  208. !! - e1,e2 Scale factors
  209. !! Valid arguments:
  210. !! ** Inputs : p_e1, p_e2 = parent grid e1 or e2 (t,u,v,f)
  211. !! cd_type = grid type (T,U,V,F) for scale factors; for velocities (U or V)
  212. !! ** Outputs : p_e1_crs, p_e2_crs = parent grid e1 or e2 (t,u,v,f)
  213. !!
  214. !! History. 4 Jun. Write for WGT and scale factors only
  215. !!----------------------------------------------------------------
  216. !!
  217. !! Arguments
  218. REAL(wp), DIMENSION(jpi,jpj) , INTENT(in) :: p_e1 ! Parent grid U,V scale factors (e1)
  219. REAL(wp), DIMENSION(jpi,jpj) , INTENT(in) :: p_e2 ! Parent grid U,V scale factors (e2)
  220. CHARACTER(len=1) , INTENT(in) :: cd_type ! grid type U,V
  221. REAL(wp), DIMENSION(jpi_crs,jpj_crs), INTENT(out) :: p_e1_crs ! Coarse grid box 2D quantity
  222. REAL(wp), DIMENSION(jpi_crs,jpj_crs), INTENT(out) :: p_e2_crs ! Coarse grid box 2D quantity
  223. !! Local variables
  224. INTEGER :: ji, jj, jk ! dummy loop indices
  225. INTEGER :: ijie,ijje,ijrs
  226. !!----------------------------------------------------------------
  227. ! Initialize
  228. DO jk = 1, jpk
  229. DO ji = 2, nlei_crs
  230. ijie = mie_crs(ji)
  231. DO jj = nldj_crs, nlej_crs
  232. ijje = mje_crs(jj) ; ijrs = mje_crs(jj) - mjs_crs(jj)
  233. ! Only for a factro 3 coarsening
  234. SELECT CASE ( cd_type )
  235. CASE ( 'T' )
  236. IF( ijrs == 0 .OR. ijrs == 1 ) THEN
  237. ! Si à la frontière sud on a pas assez de maille de la grille mère
  238. p_e1_crs(ji,jj) = p_e1(ijie-1,ijje) * nn_factx
  239. p_e2_crs(ji,jj) = p_e2(ijie-1,ijje) * nn_facty
  240. ELSE
  241. p_e1_crs(ji,jj) = p_e1(ijie-1,ijje-1) * nn_factx
  242. p_e2_crs(ji,jj) = p_e2(ijie-1,ijje-1) * nn_facty
  243. ENDIF
  244. CASE ( 'U' )
  245. IF( ijrs == 0 .OR. ijrs == 1 ) THEN
  246. ! Si à la frontière sud on a pas assez de maille de la grille mère
  247. p_e1_crs(ji,jj) = p_e1(ijie,ijje) * nn_factx
  248. p_e2_crs(ji,jj) = p_e2(ijie,ijje) * nn_facty
  249. ELSE
  250. p_e1_crs(ji,jj) = p_e1(ijie,ijje-1) * nn_factx
  251. p_e2_crs(ji,jj) = p_e2(ijie,ijje-1) * nn_facty
  252. ENDIF
  253. CASE ( 'V' )
  254. p_e1_crs(ji,jj) = p_e1(ijie-1,ijje) * nn_factx
  255. p_e2_crs(ji,jj) = p_e2(ijie-1,ijje) * nn_facty
  256. CASE ( 'F' )
  257. p_e1_crs(ji,jj) = p_e1(ijie,ijje) * nn_factx
  258. p_e2_crs(ji,jj) = p_e2(ijie,ijje) * nn_facty
  259. END SELECT
  260. ENDDO
  261. ENDDO
  262. ENDDO
  263. CALL crs_lbc_lnk( p_e1_crs, cd_type, 1.0, pval=1.0 )
  264. CALL crs_lbc_lnk( p_e2_crs, cd_type, 1.0, pval=1.0 )
  265. END SUBROUTINE crs_dom_hgr
  266. SUBROUTINE crs_dom_facvol( p_mask, cd_type, p_e1, p_e2, p_e3, p_fld1_crs, p_fld2_crs )
  267. !!----------------------------------------------------------------
  268. !! *** SUBROUTINE crsfun_wgt ***
  269. !! ** Purpose : Three applications.
  270. !! 1) SUM. Get coarse grid horizontal scale factors and unmasked fraction
  271. !! 2) VOL. Get coarse grid box volumes
  272. !! 3) WGT. Weighting multiplier for volume-weighted and/or
  273. !! area-weighted averages.
  274. !! Weights (i.e. the denominator) calculated here
  275. !! to avoid IF-tests and division.
  276. !! ** Method : 1) SUM. For grid types T,U,V,F (and W) the 2D scale factors of
  277. !! the coarse grid are the sum of the east or north faces of the
  278. !! parent grid subset comprising the coarse grid box.
  279. !! The fractions of masked:total surface (3D) on the east,
  280. !! north and top faces is, optionally, also output.
  281. !! - Top face area sum
  282. !! Valid arguments: cd_type, cd_op='W', p_pmask, p_e1, p_e2
  283. !! - Top face ocean surface fraction
  284. !! Valid arguments: cd_type, cd_op='W', p_pmask, p_e1, p_e2
  285. !! - e1,e2 Scale factors
  286. !! Valid arguments:
  287. !! 2) VOL. For grid types W and T, the coarse grid box
  288. !! volumes are output. Also optionally, the fraction of
  289. !! masked:total volume of the parent grid subset is output (i.e. facvol).
  290. !! 3) WGT. Based on the grid type, the denominator is pre-determined here to
  291. !! perform area- or volume- weighted averages,
  292. !! to avoid IF-tests and divisions.
  293. !! ** Inputs : p_e1, p_e2 = parent grid e1 or e2 (t,u,v,f)
  294. !! p_pmask = parent grid mask (T,U,V,F)
  295. !! cd_type = grid type (T,U,V,F) for scale factors; for velocities (U or V)
  296. !! cd_op = applied operation (SUM, VOL, WGT)
  297. !! p_fse3 = (Optional) parent grid vertical level thickness (fse3u or fse3v)
  298. !! ** Outputs : p_cfield2d_1 = (Optional) 2D field on coarse grid
  299. !! p_cfield2d_2 = (Optional) 2D field on coarse grid
  300. !! p_cfield3d_1 = (Optional) 3D field on coarse grid
  301. !! p_cfield3d_2 = (Optional) 3D field on coarse grid
  302. !!
  303. !! History. 4 Jun. Write for WGT and scale factors only
  304. !!----------------------------------------------------------------
  305. !!
  306. !! Arguments
  307. CHARACTER(len=1), INTENT(in) :: cd_type ! grid type U,V
  308. REAL(wp), DIMENSION(jpi,jpj,jpk) , INTENT(in) :: p_mask ! Parent grid U,V mask
  309. REAL(wp), DIMENSION(jpi,jpj) , INTENT(in) :: p_e1 ! Parent grid U,V scale factors (e1)
  310. REAL(wp), DIMENSION(jpi,jpj) , INTENT(in) :: p_e2 ! Parent grid U,V scale factors (e2)
  311. REAL(wp), DIMENSION(jpi,jpj,jpk) , INTENT(in) :: p_e3 ! Parent grid vertical level thickness (fse3u, fse3v)
  312. REAL(wp), DIMENSION(jpi_crs,jpj_crs,jpk), INTENT(out) :: p_fld1_crs ! Coarse grid box 3D quantity
  313. REAL(wp), DIMENSION(jpi_crs,jpj_crs,jpk), INTENT(out) :: p_fld2_crs ! Coarse grid box 3D quantity
  314. !! Local variables
  315. REAL(wp) :: zdAm
  316. INTEGER :: ji, jj, jk , ii, ij, je_2
  317. REAL(wp), DIMENSION(:,:,:), POINTER :: zvol, zmask
  318. !!----------------------------------------------------------------
  319. CALL wrk_alloc( jpi, jpj, jpk, zvol, zmask )
  320. p_fld1_crs(:,:,:) = 0.0
  321. p_fld2_crs(:,:,:) = 0.0
  322. DO jk = 1, jpk
  323. zvol(:,:,jk) = p_e1(:,:) * p_e2(:,:) * p_e3(:,:,jk)
  324. ENDDO
  325. zmask(:,:,:) = 0.0
  326. IF( cd_type == 'W' ) THEN
  327. zmask(:,:,1) = p_mask(:,:,1)
  328. DO jk = 2, jpk
  329. zmask(:,:,jk) = p_mask(:,:,jk-1)
  330. ENDDO
  331. ELSE
  332. DO jk = 1, jpk
  333. zmask(:,:,jk) = p_mask(:,:,jk)
  334. ENDDO
  335. ENDIF
  336. IF( nldj_crs == 1 .AND. ( ( mje_crs(2) - mjs_crs(2) ) < 2 ) ) THEN !!cc bande du sud style ORCA2
  337. IF( mje_crs(2) - mjs_crs(2) == 1 ) THEN
  338. je_2 = mje_crs(2)
  339. DO jk = 1, jpk
  340. DO ji = nistr, niend, nn_factx
  341. ii = ( ji - mis_crs(2) ) * rfactx_r + 2 ! cordinate in parent grid
  342. p_fld1_crs(ii,2,jk) = zvol(ji,je_2 ,jk) + zvol(ji+1,je_2 ,jk) + zvol(ji+2,je_2 ,jk) &
  343. & + zvol(ji,je_2-1,jk) + zvol(ji+1,je_2-1,jk) + zvol(ji+2,je_2-1,jk)
  344. !
  345. zdAm = zvol(ji ,je_2,jk) * zmask(ji ,je_2,jk) &
  346. & + zvol(ji+1,je_2,jk) * zmask(ji+1,je_2,jk) &
  347. & + zvol(ji+2,je_2,jk) * zmask(ji+2,je_2,jk)
  348. !
  349. p_fld2_crs(ii,2,jk) = zdAm / p_fld1_crs(ii,2,jk)
  350. ENDDO
  351. ENDDO
  352. ENDIF
  353. ELSE
  354. je_2 = mjs_crs(2)
  355. DO jk = 1, jpk
  356. DO ji = nistr, niend, nn_factx
  357. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  358. p_fld1_crs(ii,2,jk) = zvol(ji,je_2 ,jk) + zvol(ji+1,je_2 ,jk) + zvol(ji+2,je_2 ,jk) &
  359. & + zvol(ji,je_2+1,jk) + zvol(ji+1,je_2+1,jk) + zvol(ji+2,je_2+1,jk) &
  360. & + zvol(ji,je_2+2,jk) + zvol(ji+1,je_2+2,jk) + zvol(ji+2,je_2+2,jk)
  361. !
  362. zdAm = zvol(ji ,je_2 ,jk) * zmask(ji ,je_2 ,jk) &
  363. & + zvol(ji+1,je_2 ,jk) * zmask(ji+1,je_2 ,jk) &
  364. & + zvol(ji+2,je_2 ,jk) * zmask(ji+2,je_2 ,jk) &
  365. & + zvol(ji ,je_2+1,jk) * zmask(ji ,je_2+1,jk) &
  366. & + zvol(ji+1,je_2+1,jk) * zmask(ji+1,je_2+1,jk) &
  367. & + zvol(ji+2,je_2+1,jk) * zmask(ji+2,je_2+1,jk) &
  368. & + zvol(ji ,je_2+2,jk) * zmask(ji ,je_2+2,jk) &
  369. & + zvol(ji+1,je_2+2,jk) * zmask(ji+1,je_2+2,jk) &
  370. & + zvol(ji+2,je_2+2,jk) * zmask(ji+2,je_2+2,jk)
  371. !
  372. p_fld2_crs(ii,2,jk) = zdAm / p_fld1_crs(ii,2,jk)
  373. ENDDO
  374. ENDDO
  375. ENDIF
  376. DO jk = 1, jpk
  377. DO jj = njstr, njend, nn_facty
  378. DO ji = nistr, niend, nn_factx
  379. ii = ( ji - mis_crs(2) ) * rfactx_r + 2 ! cordinate in parent grid
  380. ij = ( jj - njstr ) * rfacty_r + 3
  381. !
  382. p_fld1_crs(ii,ij,jk) = zvol(ji,jj ,jk) + zvol(ji+1,jj ,jk) + zvol(ji+2,jj ,jk) &
  383. & + zvol(ji,jj+1,jk) + zvol(ji+1,jj+1,jk) + zvol(ji+2,jj+1,jk) &
  384. & + zvol(ji,jj+2,jk) + zvol(ji+1,jj+2,jk) + zvol(ji+2,jj+2,jk)
  385. !
  386. zdAm = zvol(ji ,jj ,jk) * zmask(ji ,jj ,jk) &
  387. & + zvol(ji+1,jj ,jk) * zmask(ji+1,jj ,jk) &
  388. & + zvol(ji+2,jj ,jk) * zmask(ji+2,jj ,jk) &
  389. & + zvol(ji ,jj+1,jk) * zmask(ji ,jj+1,jk) &
  390. & + zvol(ji+1,jj+1,jk) * zmask(ji+1,jj+1,jk) &
  391. & + zvol(ji+2,jj+1,jk) * zmask(ji+2,jj+1,jk) &
  392. & + zvol(ji ,jj+2,jk) * zmask(ji ,jj+2,jk) &
  393. & + zvol(ji+1,jj+2,jk) * zmask(ji+1,jj+2,jk) &
  394. & + zvol(ji+2,jj+2,jk) * zmask(ji+2,jj+2,jk)
  395. !
  396. p_fld2_crs(ii,ij,jk) = zdAm / p_fld1_crs(ii,ij,jk)
  397. ENDDO
  398. ENDDO
  399. ENDDO
  400. ! ! Retroactively add back the boundary halo cells.
  401. CALL crs_lbc_lnk( p_fld1_crs, cd_type, 1.0 )
  402. CALL crs_lbc_lnk( p_fld2_crs, cd_type, 1.0 )
  403. !
  404. CALL wrk_dealloc( jpi, jpj, jpk, zvol, zmask )
  405. !
  406. END SUBROUTINE crs_dom_facvol
  407. SUBROUTINE crs_dom_ope_3d( p_fld, cd_op, cd_type, p_mask, p_fld_crs, p_e12, p_e3, p_surf_crs, p_mask_crs, psgn )
  408. !!----------------------------------------------------------------
  409. !! *** SUBROUTINE crsfun_UV ***
  410. !! ** Purpose : Average, area-weighted, of U or V on the east and north faces
  411. !!
  412. !! ** Method : The U and V velocities (3D) are determined as the area-weighted averages
  413. !! on the east and north faces, respectively,
  414. !! of the parent grid subset comprising the coarse grid box.
  415. !! In the case of the V and F grid, the last jrow minus 1 is spurious.
  416. !! ** Inputs : p_e1_e2 = parent grid e1 or e2 (t,u,v,f)
  417. !! cd_type = grid type (T,U,V,F) for scale factors; for velocities (U or V)
  418. !! psgn = sign change over north fold (See lbclnk.F90)
  419. !! p_pmask = parent grid mask (T,U,V,F) for scale factors;
  420. !! for velocities (U or V)
  421. !! p_fse3 = parent grid vertical level thickness (fse3u or fse3v)
  422. !! p_pfield = U or V on the parent grid
  423. !! p_surf_crs = (Optional) Coarse grid weight for averaging
  424. !! ** Outputs : p_cfield3d = 3D field on coarse grid
  425. !!
  426. !! History. 29 May. completed draft.
  427. !! 4 Jun. Revision for WGT
  428. !! 5 Jun. Streamline for area-weighted average only ; separate scale factor and weights.
  429. !!----------------------------------------------------------------
  430. !!
  431. !! Arguments
  432. REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in) :: p_fld ! T, U, V or W on parent grid
  433. CHARACTER(len=3), INTENT(in) :: cd_op ! Operation SUM, MAX or MIN
  434. CHARACTER(len=1), INTENT(in) :: cd_type ! grid type U,V
  435. REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in) :: p_mask ! Parent grid T,U,V mask
  436. REAL(wp), DIMENSION(jpi,jpj), INTENT(in), OPTIONAL :: p_e12 ! Parent grid T,U,V scale factors (e1 or e2)
  437. REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in), OPTIONAL :: p_e3 ! Parent grid vertical level thickness (fse3u, fse3v)
  438. REAL(wp), DIMENSION(jpi_crs,jpj_crs,jpk), INTENT(in), OPTIONAL :: p_surf_crs ! Coarse grid area-weighting denominator
  439. REAL(wp), DIMENSION(jpi_crs,jpj_crs,jpk), INTENT(in), OPTIONAL :: p_mask_crs ! Coarse grid T,U,V maska
  440. REAL(wp), INTENT(in) :: psgn ! sign
  441. REAL(wp), DIMENSION(jpi_crs,jpj_crs,jpk), INTENT(out) :: p_fld_crs ! Coarse grid box 3D quantity
  442. !! Local variables
  443. INTEGER :: ji, jj, jk
  444. INTEGER :: ii, ij, ijie, ijje, je_2
  445. REAL(wp) :: zflcrs, zsfcrs
  446. REAL(wp), DIMENSION(:,:,:), POINTER :: zsurf, zsurfmsk, zmask
  447. !!----------------------------------------------------------------
  448. p_fld_crs(:,:,:) = 0.0
  449. SELECT CASE ( cd_op )
  450. CASE ( 'VOL' )
  451. CALL wrk_alloc( jpi, jpj, jpk, zsurf, zsurfmsk )
  452. SELECT CASE ( cd_type )
  453. CASE( 'T', 'W' )
  454. IF( cd_type == 'T' ) THEN
  455. DO jk = 1, jpk
  456. zsurf (:,:,jk) = p_e12(:,:) * p_e3(:,:,jk) * p_mask(:,:,jk)
  457. zsurfmsk(:,:,jk) = zsurf(:,:,jk)
  458. ENDDO
  459. ELSE
  460. zsurf (:,:,1) = p_e12(:,:) * p_e3(:,:,1)
  461. zsurfmsk(:,:,1) = zsurf(:,:,1) * p_mask(:,:,1)
  462. DO jk = 2, jpk
  463. zsurf (:,:,jk) = p_e12(:,:) * p_e3(:,:,jk)
  464. zsurfmsk(:,:,jk) = zsurf(:,:,jk) * p_mask(:,:,jk-1)
  465. ENDDO
  466. ENDIF
  467. IF( nldj_crs == 1 .AND. ( ( mje_crs(2) - mjs_crs(2) ) < 2 ) ) THEN !!cc bande du sud style ORCA2
  468. IF( mje_crs(2) - mjs_crs(2) == 1 ) THEN
  469. je_2 = mje_crs(2)
  470. DO jk = 1, jpk
  471. DO ji = nistr, niend, nn_factx
  472. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  473. zflcrs = p_fld(ji ,je_2,jk) * zsurfmsk(ji ,je_2,jk) &
  474. & + p_fld(ji+1,je_2,jk) * zsurfmsk(ji+1,je_2,jk) &
  475. & + p_fld(ji+2,je_2,jk) * zsurfmsk(ji+2,je_2,jk)
  476. zsfcrs = zsurf(ji,je_2,jk) + zsurf(ji+1,je_2,jk) + zsurf(ji+2,je_2,jk)
  477. !
  478. p_fld_crs(ii,2,jk) = zflcrs
  479. IF( zsfcrs /= 0.0 ) p_fld_crs(ii,2,jk) = zflcrs / zsfcrs
  480. ENDDO
  481. ENDDO
  482. ENDIF
  483. ELSE
  484. je_2 = mjs_crs(2)
  485. DO jk = 1, jpk
  486. DO ji = nistr, niend, nn_factx
  487. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  488. zflcrs = p_fld(ji ,je_2 ,jk) * zsurfmsk(ji ,je_2 ,jk) &
  489. & + p_fld(ji+1,je_2 ,jk) * zsurfmsk(ji+1,je_2 ,jk) &
  490. & + p_fld(ji+2,je_2 ,jk) * zsurfmsk(ji+2,je_2 ,jk) &
  491. & + p_fld(ji ,je_2+1,jk) * zsurfmsk(ji ,je_2+1,jk) &
  492. & + p_fld(ji+1,je_2+1,jk) * zsurfmsk(ji+1,je_2+1,jk) &
  493. & + p_fld(ji+2,je_2+1,jk) * zsurfmsk(ji+2,je_2+1,jk) &
  494. & + p_fld(ji ,je_2+2,jk) * zsurfmsk(ji ,je_2+2,jk) &
  495. & + p_fld(ji+1,je_2+2,jk) * zsurfmsk(ji+1,je_2+2,jk) &
  496. & + p_fld(ji+2,je_2+2,jk) * zsurfmsk(ji+2,je_2+2,jk)
  497. zsfcrs = zsurf(ji,je_2 ,jk) + zsurf(ji+1,je_2 ,jk) + zsurf(ji+2,je_2 ,jk) &
  498. & + zsurf(ji,je_2+1,jk) + zsurf(ji+1,je_2+1,jk) + zsurf(ji+2,je_2+1,jk) &
  499. & + zsurf(ji,je_2+2,jk) + zsurf(ji+1,je_2+2,jk) + zsurf(ji+2,je_2+2,jk)
  500. !
  501. p_fld_crs(ii,2,jk) = zflcrs
  502. IF( zsfcrs /= 0.0 ) p_fld_crs(ii,2,jk) = zflcrs / zsfcrs
  503. ENDDO
  504. ENDDO
  505. ENDIF
  506. !
  507. DO jk = 1, jpk
  508. DO jj = njstr, njend, nn_facty
  509. DO ji = nistr, niend, nn_factx
  510. ii = ( ji - mis_crs(2) ) * rfactx_r + 2 ! cordinate in parent grid
  511. ij = ( jj - njstr ) * rfacty_r + 3
  512. zflcrs = p_fld(ji ,jj ,jk) * zsurfmsk(ji ,jj ,jk) &
  513. & + p_fld(ji+1,jj ,jk) * zsurfmsk(ji+1,jj ,jk) &
  514. & + p_fld(ji+2,jj ,jk) * zsurfmsk(ji+2,jj ,jk) &
  515. & + p_fld(ji ,jj+1,jk) * zsurfmsk(ji ,jj+1,jk) &
  516. & + p_fld(ji+1,jj+1,jk) * zsurfmsk(ji+1,jj+1,jk) &
  517. & + p_fld(ji+2,jj+1,jk) * zsurfmsk(ji+2,jj+1,jk) &
  518. & + p_fld(ji ,jj+2,jk) * zsurfmsk(ji ,jj+2,jk) &
  519. & + p_fld(ji+1,jj+2,jk) * zsurfmsk(ji+1,jj+2,jk) &
  520. & + p_fld(ji+2,jj+2,jk) * zsurfmsk(ji+2,jj+2,jk)
  521. zsfcrs = zsurf(ji,jj ,jk) + zsurf(ji+1,jj ,jk) + zsurf(ji+2,jj ,jk) &
  522. & + zsurf(ji,jj+1,jk) + zsurf(ji+1,jj+1,jk) + zsurf(ji+2,jj+1,jk) &
  523. & + zsurf(ji,jj+2,jk) + zsurf(ji+1,jj+2,jk) + zsurf(ji+2,jj+2,jk)
  524. !
  525. p_fld_crs(ii,ij,jk) = zflcrs
  526. IF( zsfcrs /= 0.0 ) p_fld_crs(ii,ij,jk) = zflcrs / zsfcrs
  527. ENDDO
  528. ENDDO
  529. ENDDO
  530. CASE DEFAULT
  531. STOP
  532. END SELECT
  533. CALL wrk_dealloc( jpi, jpj, jpk, zsurf, zsurfmsk )
  534. CASE ( 'SUM' )
  535. CALL wrk_alloc( jpi, jpj, jpk, zsurfmsk )
  536. SELECT CASE ( cd_type )
  537. CASE( 'W' )
  538. IF( PRESENT( p_e3 ) ) THEN
  539. zsurfmsk(:,:,1) = p_e12(:,:) * p_e3(:,:,1) * p_mask(:,:,1)
  540. DO jk = 2, jpk
  541. zsurfmsk(:,:,jk) = p_e12(:,:) * p_e3(:,:,jk) * p_mask(:,:,jk-1)
  542. ENDDO
  543. ELSE
  544. zsurfmsk(:,:,1) = p_e12(:,:) * p_mask(:,:,1)
  545. DO jk = 2, jpk
  546. zsurfmsk(:,:,jk) = p_e12(:,:) * p_mask(:,:,jk-1)
  547. ENDDO
  548. ENDIF
  549. CASE DEFAULT
  550. IF( PRESENT( p_e3 ) ) THEN
  551. DO jk = 1, jpk
  552. zsurfmsk(:,:,jk) = p_e12(:,:) * p_e3(:,:,jk) * p_mask(:,:,jk)
  553. ENDDO
  554. ELSE
  555. DO jk = 1, jpk
  556. zsurfmsk(:,:,jk) = p_e12(:,:) * p_mask(:,:,jk)
  557. ENDDO
  558. ENDIF
  559. END SELECT
  560. SELECT CASE ( cd_type )
  561. CASE( 'T', 'W' )
  562. IF( nldj_crs == 1 .AND. ( ( mje_crs(2) - mjs_crs(2) ) < 2 ) ) THEN !!cc bande du sud style ORCA2
  563. IF( mje_crs(2) - mjs_crs(2) == 1 ) THEN
  564. je_2 = mje_crs(2)
  565. DO jk = 1, jpk
  566. DO ji = nistr, niend, nn_factx
  567. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  568. zflcrs = p_fld(ji ,je_2,jk) * zsurfmsk(ji ,je_2,jk) &
  569. & + p_fld(ji+1,je_2,jk) * zsurfmsk(ji+1,je_2,jk) &
  570. & + p_fld(ji+2,je_2,jk) * zsurfmsk(ji+2,je_2,jk)
  571. !
  572. p_fld_crs(ii,2,jk) = zflcrs
  573. ENDDO
  574. ENDDO
  575. ENDIF
  576. ELSE
  577. je_2 = mjs_crs(2)
  578. DO jk = 1, jpk
  579. DO ji = nistr, niend, nn_factx
  580. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  581. zflcrs = p_fld(ji ,je_2 ,jk) * zsurfmsk(ji ,je_2 ,jk) &
  582. & + p_fld(ji+1,je_2 ,jk) * zsurfmsk(ji+1,je_2 ,jk) &
  583. & + p_fld(ji+2,je_2 ,jk) * zsurfmsk(ji+2,je_2 ,jk) &
  584. & + p_fld(ji ,je_2+1,jk) * zsurfmsk(ji ,je_2+1,jk) &
  585. & + p_fld(ji+1,je_2+1,jk) * zsurfmsk(ji+1,je_2+1,jk) &
  586. & + p_fld(ji+2,je_2+1,jk) * zsurfmsk(ji+2,je_2+1,jk) &
  587. & + p_fld(ji ,je_2+2,jk) * zsurfmsk(ji ,je_2+2,jk) &
  588. & + p_fld(ji+1,je_2+2,jk) * zsurfmsk(ji+1,je_2+2,jk) &
  589. & + p_fld(ji+2,je_2+2,jk) * zsurfmsk(ji+2,je_2+2,jk)
  590. !
  591. p_fld_crs(ii,2,jk) = zflcrs
  592. ENDDO
  593. ENDDO
  594. ENDIF
  595. !
  596. DO jk = 1, jpk
  597. DO jj = njstr, njend, nn_facty
  598. DO ji = nistr, niend, nn_factx
  599. ii = ( ji - mis_crs(2) ) * rfactx_r + 2 ! cordinate in parent grid
  600. ij = ( jj - njstr ) * rfacty_r + 3
  601. zflcrs = p_fld(ji ,jj ,jk) * zsurfmsk(ji ,jj ,jk) &
  602. & + p_fld(ji+1,jj ,jk) * zsurfmsk(ji+1,jj ,jk) &
  603. & + p_fld(ji+2,jj ,jk) * zsurfmsk(ji+2,jj ,jk) &
  604. & + p_fld(ji ,jj+1,jk) * zsurfmsk(ji ,jj+1,jk) &
  605. & + p_fld(ji+1,jj+1,jk) * zsurfmsk(ji+1,jj+1,jk) &
  606. & + p_fld(ji+2,jj+1,jk) * zsurfmsk(ji+2,jj+1,jk) &
  607. & + p_fld(ji ,jj+2,jk) * zsurfmsk(ji ,jj+2,jk) &
  608. & + p_fld(ji+1,jj+2,jk) * zsurfmsk(ji+1,jj+2,jk) &
  609. & + p_fld(ji+2,jj+2,jk) * zsurfmsk(ji+2,jj+2,jk)
  610. !
  611. p_fld_crs(ii,ij,jk) = zflcrs
  612. !
  613. ENDDO
  614. ENDDO
  615. ENDDO
  616. CASE( 'V' )
  617. IF( nldj_crs == 1 .AND. ( ( mje_crs(2) - mjs_crs(2) ) < 2 ) ) THEN !!cc bande du sud style ORCA2
  618. IF( mje_crs(2) - mjs_crs(2) == 1 ) THEN
  619. ijje = mje_crs(2)
  620. ENDIF
  621. ELSE
  622. ijje = mjs_crs(2)
  623. ENDIF
  624. !
  625. DO jk = 1, jpk
  626. DO ji = nistr, niend, nn_factx
  627. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  628. zflcrs = p_fld(ji ,ijje,jk) * zsurfmsk(ji ,ijje,jk) &
  629. & + p_fld(ji+1,ijje,jk) * zsurfmsk(ji+1,ijje,jk) &
  630. & + p_fld(ji+2,ijje,jk) * zsurfmsk(ji+2,ijje,jk)
  631. !
  632. p_fld_crs(ii,2,jk) = zflcrs
  633. ENDDO
  634. ENDDO
  635. !
  636. DO jk = 1, jpk
  637. DO jj = njstr, njend, nn_facty
  638. DO ji = nistr, niend, nn_factx
  639. ii = ( ji - mis_crs(2) ) * rfactx_r + 2 ! cordinate in parent grid
  640. ij = ( jj - njstr ) * rfacty_r + 3
  641. ijje = mje_crs(ij)
  642. zflcrs = p_fld(ji ,ijje,jk) * zsurfmsk(ji ,ijje,jk) &
  643. & + p_fld(ji+1,ijje,jk) * zsurfmsk(ji+1,ijje,jk) &
  644. & + p_fld(ji+2,ijje,jk) * zsurfmsk(ji+2,ijje,jk)
  645. !
  646. p_fld_crs(ii,ij,jk) = zflcrs
  647. !
  648. ENDDO
  649. ENDDO
  650. ENDDO
  651. CASE( 'U' )
  652. IF( nldj_crs == 1 .AND. ( ( mje_crs(2) - mjs_crs(2) ) < 2 ) ) THEN !!cc bande du sud style ORCA2
  653. IF( mje_crs(2) - mjs_crs(2) == 1 ) THEN
  654. je_2 = mje_crs(2)
  655. DO jk = 1, jpk
  656. DO ji = nistr, niend, nn_factx
  657. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  658. ijie = mie_crs(ii)
  659. zflcrs = p_fld(ijie,je_2,jk) * zsurfmsk(ijie,je_2,jk)
  660. p_fld_crs(ii,2,jk) = zflcrs
  661. ENDDO
  662. ENDDO
  663. ENDIF
  664. ELSE
  665. je_2 = mjs_crs(2)
  666. DO jk = 1, jpk
  667. DO ji = nistr, niend, nn_factx
  668. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  669. ijie = mie_crs(ii)
  670. zflcrs = p_fld(ijie,je_2 ,jk) * zsurfmsk(ijie,je_2 ,jk) &
  671. & + p_fld(ijie,je_2+1,jk) * zsurfmsk(ijie,je_2+1,jk) &
  672. & + p_fld(ijie,je_2+2,jk) * zsurfmsk(ijie,je_2+2,jk)
  673. p_fld_crs(ii,2,jk) = zflcrs
  674. ENDDO
  675. ENDDO
  676. ENDIF
  677. !
  678. DO jk = 1, jpk
  679. DO jj = njstr, njend, nn_facty
  680. DO ji = nistr, niend, nn_factx
  681. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  682. ij = ( jj - njstr ) * rfacty_r + 3
  683. ijie = mie_crs(ii)
  684. zflcrs = p_fld(ijie,jj ,jk) * zsurfmsk(ijie,jj ,jk) &
  685. & + p_fld(ijie,jj+1,jk) * zsurfmsk(ijie,jj+1,jk) &
  686. & + p_fld(ijie,jj+2,jk) * zsurfmsk(ijie,jj+2,jk)
  687. !
  688. p_fld_crs(ii,ij,jk) = zflcrs
  689. !
  690. ENDDO
  691. ENDDO
  692. ENDDO
  693. END SELECT
  694. IF( PRESENT( p_surf_crs ) ) THEN
  695. WHERE ( p_surf_crs /= 0.0 ) p_fld_crs(:,:,:) = p_fld_crs(:,:,:) / p_surf_crs(:,:,:)
  696. ENDIF
  697. CALL wrk_dealloc( jpi, jpj, jpk, zsurfmsk )
  698. CASE ( 'MAX' ) ! search the max of unmasked grid cells
  699. CALL wrk_alloc( jpi, jpj, jpk, zmask )
  700. SELECT CASE ( cd_type )
  701. CASE( 'W' )
  702. zmask(:,:,1) = p_mask(:,:,1)
  703. DO jk = 2, jpk
  704. zmask(:,:,jk) = p_mask(:,:,jk-1)
  705. ENDDO
  706. CASE ( 'T' )
  707. DO jk = 1, jpk
  708. zmask(:,:,jk) = p_mask(:,:,jk)
  709. ENDDO
  710. END SELECT
  711. SELECT CASE ( cd_type )
  712. CASE( 'T', 'W' )
  713. IF( nldj_crs == 1 .AND. ( ( mje_crs(2) - mjs_crs(2) ) < 2 ) ) THEN !!cc bande du sud style ORCA2
  714. IF( mje_crs(2) - mjs_crs(2) == 1 ) THEN
  715. je_2 = mje_crs(2)
  716. DO jk = 1, jpk
  717. DO ji = nistr, niend, nn_factx
  718. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  719. zflcrs = &
  720. & MAX( p_fld(ji ,je_2,jk) * zmask(ji ,je_2,jk) - ( 1.- zmask(ji ,je_2,jk) ) * r_inf , &
  721. & p_fld(ji+1,je_2,jk) * zmask(ji+1,je_2,jk) - ( 1.- zmask(ji+1,je_2,jk) ) * r_inf , &
  722. & p_fld(ji+2,je_2,jk) * zmask(ji+2,je_2,jk) - ( 1.- zmask(ji+2,je_2,jk) ) * r_inf )
  723. !
  724. p_fld_crs(ii,2,jk) = zflcrs
  725. ENDDO
  726. ENDDO
  727. ENDIF
  728. ELSE
  729. je_2 = mjs_crs(2)
  730. DO jk = 1, jpk
  731. DO ji = nistr, niend, nn_factx
  732. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  733. zflcrs = &
  734. & MAX( p_fld(ji ,je_2 ,jk) * zmask(ji ,je_2 ,jk) - ( 1.- zmask(ji ,je_2 ,jk) ) * r_inf , &
  735. & p_fld(ji+1,je_2 ,jk) * zmask(ji+1,je_2 ,jk) - ( 1.- zmask(ji+1,je_2 ,jk) ) * r_inf , &
  736. & p_fld(ji+2,je_2 ,jk) * zmask(ji+2,je_2 ,jk) - ( 1.- zmask(ji+2,je_2 ,jk) ) * r_inf , &
  737. & p_fld(ji ,je_2+1,jk) * zmask(ji ,je_2+1,jk) - ( 1.- zmask(ji ,je_2+1,jk) ) * r_inf , &
  738. & p_fld(ji+1,je_2+1,jk) * zmask(ji+1,je_2+1,jk) - ( 1.- zmask(ji+1,je_2+1,jk) ) * r_inf , &
  739. & p_fld(ji+2,je_2+1,jk) * zmask(ji+2,je_2+1,jk) - ( 1.- zmask(ji+2,je_2+1,jk) ) * r_inf , &
  740. & p_fld(ji ,je_2+2,jk) * zmask(ji ,je_2+2,jk) - ( 1.- zmask(ji ,je_2+2,jk) ) * r_inf , &
  741. & p_fld(ji+1,je_2+2,jk) * zmask(ji+1,je_2+2,jk) - ( 1.- zmask(ji+1,je_2+2,jk) ) * r_inf , &
  742. & p_fld(ji+2,je_2+2,jk) * zmask(ji+2,je_2+2,jk) - ( 1.- zmask(ji+2,je_2+2,jk) ) * r_inf )
  743. !
  744. p_fld_crs(ii,2,jk) = zflcrs
  745. ENDDO
  746. ENDDO
  747. ENDIF
  748. !
  749. DO jk = 1, jpk
  750. DO jj = njstr, njend, nn_facty
  751. DO ji = nistr, niend, nn_factx
  752. ii = ( ji - mis_crs(2) ) * rfactx_r + 2 ! cordinate in parent grid
  753. ij = ( jj - njstr ) * rfacty_r + 3
  754. zflcrs = &
  755. & MAX( p_fld(ji ,jj ,jk) * zmask(ji ,jj ,jk) - ( 1.- zmask(ji ,jj ,jk) ) * r_inf , &
  756. & p_fld(ji+1,jj ,jk) * zmask(ji+1,jj ,jk) - ( 1.- zmask(ji+1,jj ,jk) ) * r_inf , &
  757. & p_fld(ji+2,jj ,jk) * zmask(ji+2,jj ,jk) - ( 1.- zmask(ji+2,jj ,jk) ) * r_inf , &
  758. & p_fld(ji ,jj+1,jk) * zmask(ji ,jj+1,jk) - ( 1.- zmask(ji ,jj+1,jk) ) * r_inf , &
  759. & p_fld(ji+1,jj+1,jk) * zmask(ji+1,jj+1,jk) - ( 1.- zmask(ji+1,jj+1,jk) ) * r_inf , &
  760. & p_fld(ji+2,jj+1,jk) * zmask(ji+2,jj+1,jk) - ( 1.- zmask(ji+2,jj+1,jk) ) * r_inf , &
  761. & p_fld(ji ,jj+2,jk) * zmask(ji ,jj+2,jk) - ( 1.- zmask(ji ,jj+2,jk) ) * r_inf , &
  762. & p_fld(ji+1,jj+2,jk) * zmask(ji+1,jj+2,jk) - ( 1.- zmask(ji+1,jj+2,jk) ) * r_inf , &
  763. & p_fld(ji+2,jj+2,jk) * zmask(ji+2,jj+2,jk) - ( 1.- zmask(ji+2,jj+2,jk) ) * r_inf )
  764. !
  765. p_fld_crs(ii,ij,jk) = zflcrs
  766. !
  767. ENDDO
  768. ENDDO
  769. ENDDO
  770. CASE( 'V' )
  771. IF( nldj_crs == 1 .AND. ( ( mje_crs(2) - mjs_crs(2) ) < 2 ) ) THEN !!cc bande du sud style ORCA2
  772. IF( mje_crs(2) - mjs_crs(2) == 1 ) THEN
  773. ijje = mje_crs(2)
  774. ENDIF
  775. ELSE
  776. ijje = mjs_crs(2)
  777. ENDIF
  778. DO jk = 1, jpk
  779. DO ji = nistr, niend, nn_factx
  780. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  781. zflcrs = &
  782. & MAX( p_fld(ji ,ijje,jk) * p_mask(ji ,ijje,jk) - ( 1.- p_mask(ji,ijje,jk) ) * r_inf , &
  783. & p_fld(ji+1,ijje,jk) * p_mask(ji+1,ijje,jk) - ( 1.- p_mask(ji,ijje,jk) ) * r_inf , &
  784. & p_fld(ji+2,ijje,jk) * p_mask(ji+2,ijje,jk) - ( 1.- p_mask(ji,ijje,jk) ) * r_inf )
  785. !
  786. p_fld_crs(ii,2,jk) = zflcrs
  787. ENDDO
  788. ENDDO
  789. !
  790. DO jk = 1, jpk
  791. DO jj = njstr, njend, nn_facty
  792. DO ji = nistr, niend, nn_factx
  793. ii = ( ji - mis_crs(2) ) * rfactx_r + 2 ! cordinate in parent grid
  794. ij = ( jj - njstr ) * rfacty_r + 3
  795. ijje = mje_crs(ij)
  796. !
  797. zflcrs = &
  798. & MAX( p_fld(ji ,ijje,jk) * p_mask(ji ,ijje,jk) - ( 1.- p_mask(ji,ijje,jk) ) * r_inf , &
  799. & p_fld(ji+1,ijje,jk) * p_mask(ji+1,ijje,jk) - ( 1.- p_mask(ji,ijje,jk) ) * r_inf , &
  800. & p_fld(ji+2,ijje,jk) * p_mask(ji+2,ijje,jk) - ( 1.- p_mask(ji,ijje,jk) ) * r_inf )
  801. !
  802. p_fld_crs(ii,ij,jk) = zflcrs
  803. !
  804. ENDDO
  805. ENDDO
  806. ENDDO
  807. CASE( 'U' )
  808. IF( nldj_crs == 1 .AND. ( ( mje_crs(2) - mjs_crs(2) ) < 2 ) ) THEN !!cc bande du sud style ORCA2
  809. IF( mje_crs(2) - mjs_crs(2) == 1 ) THEN
  810. je_2 = mje_crs(2)
  811. DO jk = 1, jpk
  812. DO ji = nistr, niend, nn_factx
  813. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  814. ijie = mie_crs(ii)
  815. zflcrs = p_fld(ijie,je_2,jk) * p_mask(ijie,je_2,jk) - ( 1.- p_mask(ijie,je_2,jk) ) * r_inf
  816. !
  817. p_fld_crs(ii,2,jk) = zflcrs
  818. ENDDO
  819. ENDDO
  820. ENDIF
  821. ELSE
  822. je_2 = mjs_crs(2)
  823. DO jk = 1, jpk
  824. DO ji = nistr, niend, nn_factx
  825. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  826. ijie = mie_crs(ii)
  827. zflcrs = &
  828. & MAX( p_fld(ijie,je_2 ,jk) * p_mask(ijie,je_2 ,jk) - ( 1.- p_mask(ijie,je_2,jk) ) * r_inf , &
  829. & p_fld(ijie,je_2+1,jk) * p_mask(ijie,je_2+1,jk) - ( 1.- p_mask(ijie,je_2,jk) ) * r_inf , &
  830. & p_fld(ijie,je_2+2,jk) * p_mask(ijie,je_2+2,jk) - ( 1.- p_mask(ijie,je_2,jk) ) * r_inf )
  831. !
  832. p_fld_crs(ii,2,jk) = zflcrs
  833. ENDDO
  834. ENDDO
  835. ENDIF
  836. !
  837. DO jk = 1, jpk
  838. DO jj = njstr, njend, nn_facty
  839. DO ji = nistr, niend, nn_factx
  840. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  841. ij = ( jj - njstr ) * rfacty_r + 3
  842. ijie = mie_crs(ii)
  843. zflcrs = &
  844. & MAX( p_fld(ijie,jj ,jk) * p_mask(ijie,jj ,jk) - ( 1.- p_mask(ijie,jj,jk) ) * r_inf , &
  845. & p_fld(ijie,jj+1,jk) * p_mask(ijie,jj+1,jk) - ( 1.- p_mask(ijie,jj,jk) ) * r_inf , &
  846. & p_fld(ijie,jj+2,jk) * p_mask(ijie,jj+2,jk) - ( 1.- p_mask(ijie,jj,jk) ) * r_inf )
  847. !
  848. p_fld_crs(ii,ij,jk) = zflcrs
  849. !
  850. ENDDO
  851. ENDDO
  852. ENDDO
  853. END SELECT
  854. CALL wrk_dealloc( jpi, jpj, jpk, zmask )
  855. CASE ( 'MIN' ) ! Search the min of unmasked grid cells
  856. CALL wrk_alloc( jpi, jpj, jpk, zmask )
  857. SELECT CASE ( cd_type )
  858. CASE( 'W' )
  859. zmask(:,:,1) = p_mask(:,:,1)
  860. DO jk = 2, jpk
  861. zmask(:,:,jk) = p_mask(:,:,jk-1)
  862. ENDDO
  863. CASE ( 'T' )
  864. DO jk = 1, jpk
  865. zmask(:,:,jk) = p_mask(:,:,jk)
  866. ENDDO
  867. END SELECT
  868. SELECT CASE ( cd_type )
  869. CASE( 'T', 'W' )
  870. IF( nldj_crs == 1 .AND. ( ( mje_crs(2) - mjs_crs(2) ) < 2 ) ) THEN !!cc bande du sud style ORCA2
  871. IF( mje_crs(2) - mjs_crs(2) == 1 ) THEN
  872. je_2 = mje_crs(2)
  873. DO jk = 1, jpk
  874. DO ji = nistr, niend, nn_factx
  875. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  876. zflcrs = &
  877. & MIN( p_fld(ji ,je_2,jk) * zmask(ji ,je_2,jk) + ( 1.- zmask(ji ,je_2,jk) ) * r_inf , &
  878. & p_fld(ji+1,je_2,jk) * zmask(ji+1,je_2,jk) + ( 1.- zmask(ji+1,je_2,jk) ) * r_inf , &
  879. & p_fld(ji+2,je_2,jk) * zmask(ji+2,je_2,jk) + ( 1.- zmask(ji+2,je_2,jk) ) * r_inf )
  880. !
  881. p_fld_crs(ii,2,jk) = zflcrs
  882. ENDDO
  883. ENDDO
  884. ENDIF
  885. ELSE
  886. je_2 = mjs_crs(2)
  887. DO jk = 1, jpk
  888. DO ji = nistr, niend, nn_factx
  889. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  890. zflcrs = &
  891. & MIN( p_fld(ji ,je_2 ,jk) * zmask(ji ,je_2 ,jk) + ( 1.- zmask(ji ,je_2 ,jk) ) * r_inf , &
  892. & p_fld(ji+1,je_2 ,jk) * zmask(ji+1,je_2 ,jk) + ( 1.- zmask(ji+1,je_2 ,jk) ) * r_inf , &
  893. & p_fld(ji+2,je_2 ,jk) * zmask(ji+2,je_2 ,jk) + ( 1.- zmask(ji+2,je_2 ,jk) ) * r_inf , &
  894. & p_fld(ji ,je_2+1,jk) * zmask(ji ,je_2+1,jk) + ( 1.- zmask(ji ,je_2+1,jk) ) * r_inf , &
  895. & p_fld(ji+1,je_2+1,jk) * zmask(ji+1,je_2+1,jk) + ( 1.- zmask(ji+1,je_2+1,jk) ) * r_inf , &
  896. & p_fld(ji+2,je_2+1,jk) * zmask(ji+2,je_2+1,jk) + ( 1.- zmask(ji+2,je_2+1,jk) ) * r_inf , &
  897. & p_fld(ji ,je_2+2,jk) * zmask(ji ,je_2+2,jk) + ( 1.- zmask(ji ,je_2+2,jk) ) * r_inf , &
  898. & p_fld(ji+1,je_2+2,jk) * zmask(ji+1,je_2+2,jk) + ( 1.- zmask(ji+1,je_2+2,jk) ) * r_inf , &
  899. & p_fld(ji+2,je_2+2,jk) * zmask(ji+2,je_2+2,jk) + ( 1.- zmask(ji+2,je_2+2,jk) ) * r_inf )
  900. !
  901. p_fld_crs(ii,2,jk) = zflcrs
  902. ENDDO
  903. ENDDO
  904. ENDIF
  905. !
  906. DO jk = 1, jpk
  907. DO jj = njstr, njend, nn_facty
  908. DO ji = nistr, niend, nn_factx
  909. ii = ( ji - mis_crs(2) ) * rfactx_r + 2 ! cordinate in parent grid
  910. ij = ( jj - njstr ) * rfacty_r + 3
  911. zflcrs = &
  912. & MIN( p_fld(ji ,jj ,jk) * zmask(ji ,jj ,jk) + ( 1.- zmask(ji ,jj ,jk) ) * r_inf , &
  913. & p_fld(ji+1,jj ,jk) * zmask(ji+1,jj ,jk) + ( 1.- zmask(ji+1,jj ,jk) ) * r_inf , &
  914. & p_fld(ji+2,jj ,jk) * zmask(ji+2,jj ,jk) + ( 1.- zmask(ji+2,jj ,jk) ) * r_inf , &
  915. & p_fld(ji ,jj+1,jk) * zmask(ji ,jj+1,jk) + ( 1.- zmask(ji ,jj+1,jk) ) * r_inf , &
  916. & p_fld(ji+1,jj+1,jk) * zmask(ji+1,jj+1,jk) + ( 1.- zmask(ji+1,jj+1,jk) ) * r_inf , &
  917. & p_fld(ji+2,jj+1,jk) * zmask(ji+2,jj+1,jk) + ( 1.- zmask(ji+2,jj+1,jk) ) * r_inf , &
  918. & p_fld(ji ,jj+2,jk) * zmask(ji ,jj+2,jk) + ( 1.- zmask(ji ,jj+2,jk) ) * r_inf , &
  919. & p_fld(ji+1,jj+2,jk) * zmask(ji+1,jj+2,jk) + ( 1.- zmask(ji+1,jj+2,jk) ) * r_inf , &
  920. & p_fld(ji+2,jj+2,jk) * zmask(ji+2,jj+2,jk) + ( 1.- zmask(ji+2,jj+2,jk) ) * r_inf )
  921. !
  922. p_fld_crs(ii,ij,jk) = zflcrs
  923. !
  924. ENDDO
  925. ENDDO
  926. ENDDO
  927. CASE( 'V' )
  928. IF( nldj_crs == 1 .AND. ( ( mje_crs(2) - mjs_crs(2) ) < 2 ) ) THEN !!cc bande du sud style ORCA2
  929. IF( mje_crs(2) - mjs_crs(2) == 1 ) THEN
  930. ijje = mje_crs(2)
  931. ENDIF
  932. ELSE
  933. ijje = mjs_crs(2)
  934. ENDIF
  935. DO jk = 1, jpk
  936. DO ji = nistr, niend, nn_factx
  937. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  938. zflcrs = &
  939. & MIN( p_fld(ji ,ijje,jk) * p_mask(ji ,ijje,jk) + ( 1.- p_mask(ji,ijje,jk) ) * r_inf , &
  940. & p_fld(ji+1,ijje,jk) * p_mask(ji+1,ijje,jk) + ( 1.- p_mask(ji,ijje,jk) ) * r_inf , &
  941. & p_fld(ji+2,ijje,jk) * p_mask(ji+2,ijje,jk) + ( 1.- p_mask(ji,ijje,jk) ) * r_inf )
  942. !
  943. p_fld_crs(ii,2,jk) = zflcrs
  944. ENDDO
  945. ENDDO
  946. !
  947. DO jk = 1, jpk
  948. DO jj = njstr, njend, nn_facty
  949. DO ji = nistr, niend, nn_factx
  950. ii = ( ji - mis_crs(2) ) * rfactx_r + 2 ! cordinate in parent grid
  951. ij = ( jj - njstr ) * rfacty_r + 3
  952. ijje = mje_crs(ij)
  953. zflcrs = &
  954. & MIN( p_fld(ji ,ijje,jk) * p_mask(ji ,ijje,jk) + ( 1.- p_mask(ji,ijje,jk) ) * r_inf , &
  955. & p_fld(ji+1,ijje,jk) * p_mask(ji+1,ijje,jk) + ( 1.- p_mask(ji,ijje,jk) ) * r_inf , &
  956. & p_fld(ji+2,ijje,jk) * p_mask(ji+2,ijje,jk) + ( 1.- p_mask(ji,ijje,jk) ) * r_inf )
  957. !
  958. p_fld_crs(ii,ij,jk) = zflcrs
  959. !
  960. ENDDO
  961. ENDDO
  962. ENDDO
  963. CASE( 'U' )
  964. IF( nldj_crs == 1 .AND. ( ( mje_crs(2) - mjs_crs(2) ) < 2 ) ) THEN !!cc bande du sud style ORCA2
  965. IF( mje_crs(2) - mjs_crs(2) == 1 ) THEN
  966. je_2 = mje_crs(2)
  967. DO jk = 1, jpk
  968. DO ji = nistr, niend, nn_factx
  969. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  970. ijie = mie_crs(ii)
  971. zflcrs = p_fld(ijie,je_2,jk) * p_mask(ijie,je_2,jk) + ( 1.- p_mask(ijie,je_2,jk) ) * r_inf
  972. !
  973. p_fld_crs(ii,2,jk) = zflcrs
  974. ENDDO
  975. ENDDO
  976. ENDIF
  977. ELSE
  978. je_2 = mjs_crs(2)
  979. DO jk = 1, jpk
  980. DO ji = nistr, niend, nn_factx
  981. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  982. ijie = mie_crs(ii)
  983. zflcrs = &
  984. & MIN( p_fld(ijie,je_2 ,jk) * p_mask(ijie,je_2 ,jk) + ( 1.- p_mask(ijie,je_2,jk) ) * r_inf , &
  985. & p_fld(ijie,je_2+1,jk) * p_mask(ijie,je_2+1,jk) + ( 1.- p_mask(ijie,je_2,jk) ) * r_inf , &
  986. & p_fld(ijie,je_2+2,jk) * p_mask(ijie,je_2+2,jk) + ( 1.- p_mask(ijie,je_2,jk) ) * r_inf )
  987. !
  988. p_fld_crs(ii,2,jk) = zflcrs
  989. ENDDO
  990. ENDDO
  991. ENDIF
  992. !
  993. DO jk = 1, jpk
  994. DO jj = njstr, njend, nn_facty
  995. DO ji = nistr, niend, nn_factx
  996. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  997. ij = ( jj - njstr ) * rfacty_r + 3
  998. ijie = mie_crs(ii)
  999. zflcrs = &
  1000. & MIN( p_fld(ijie,jj ,jk) * p_mask(ijie,jj ,jk) + ( 1.- p_mask(ijie,jj,jk) ) * r_inf , &
  1001. & p_fld(ijie,jj+1,jk) * p_mask(ijie,jj+1,jk) + ( 1.- p_mask(ijie,jj,jk) ) * r_inf , &
  1002. & p_fld(ijie,jj+2,jk) * p_mask(ijie,jj+2,jk) + ( 1.- p_mask(ijie,jj,jk) ) * r_inf )
  1003. !
  1004. p_fld_crs(ii,ij,jk) = zflcrs
  1005. !
  1006. ENDDO
  1007. ENDDO
  1008. ENDDO
  1009. END SELECT
  1010. !
  1011. CALL wrk_dealloc( jpi, jpj, jpk, zmask )
  1012. !
  1013. END SELECT
  1014. !
  1015. CALL crs_lbc_lnk( p_fld_crs, cd_type, psgn )
  1016. !
  1017. END SUBROUTINE crs_dom_ope_3d
  1018. SUBROUTINE crs_dom_ope_2d( p_fld, cd_op, cd_type, p_mask, p_fld_crs, p_e12, p_e3, p_surf_crs, p_mask_crs, psgn )
  1019. !!----------------------------------------------------------------
  1020. !! *** SUBROUTINE crsfun_UV ***
  1021. !! ** Purpose : Average, area-weighted, of U or V on the east and north faces
  1022. !!
  1023. !! ** Method : The U and V velocities (3D) are determined as the area-weighted averages
  1024. !! on the east and north faces, respectively,
  1025. !! of the parent grid subset comprising the coarse grid box.
  1026. !! In the case of the V and F grid, the last jrow minus 1 is spurious.
  1027. !! ** Inputs : p_e1_e2 = parent grid e1 or e2 (t,u,v,f)
  1028. !! cd_type = grid type (T,U,V,F) for scale factors; for velocities (U or V)
  1029. !! psgn = sign change over north fold (See lbclnk.F90)
  1030. !! p_pmask = parent grid mask (T,U,V,F) for scale factors;
  1031. !! for velocities (U or V)
  1032. !! p_fse3 = parent grid vertical level thickness (fse3u or fse3v)
  1033. !! p_pfield = U or V on the parent grid
  1034. !! p_surf_crs = (Optional) Coarse grid weight for averaging
  1035. !! ** Outputs : p_cfield3d = 3D field on coarse grid
  1036. !!
  1037. !! History. 29 May. completed draft.
  1038. !! 4 Jun. Revision for WGT
  1039. !! 5 Jun. Streamline for area-weighted average only ; separate scale factor and weights.
  1040. !!----------------------------------------------------------------
  1041. !!
  1042. !! Arguments
  1043. REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: p_fld ! T, U, V or W on parent grid
  1044. CHARACTER(len=3), INTENT(in) :: cd_op ! Operation SUM, MAX or MIN
  1045. CHARACTER(len=1), INTENT(in) :: cd_type ! grid type U,V
  1046. REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in) :: p_mask ! Parent grid T,U,V mask
  1047. REAL(wp), DIMENSION(jpi,jpj), INTENT(in), OPTIONAL :: p_e12 ! Parent grid T,U,V scale factors (e1 or e2)
  1048. REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in), OPTIONAL :: p_e3 ! Parent grid vertical level thickness (fse3u, fse3v)
  1049. REAL(wp), DIMENSION(jpi_crs,jpj_crs) , INTENT(in), OPTIONAL :: p_surf_crs ! Coarse grid area-weighting denominator
  1050. REAL(wp), DIMENSION(jpi_crs,jpj_crs,jpk), INTENT(in), OPTIONAL :: p_mask_crs ! Coarse grid T,U,V mask
  1051. REAL(wp), INTENT(in) :: psgn
  1052. REAL(wp), DIMENSION(jpi_crs,jpj_crs) , INTENT(out) :: p_fld_crs ! Coarse grid box 3D quantity
  1053. !! Local variables
  1054. INTEGER :: ji, jj, jk ! dummy loop indices
  1055. INTEGER :: ijie, ijje, ii, ij, je_2
  1056. REAL(wp) :: zflcrs, zsfcrs
  1057. REAL(wp), DIMENSION(:,:), POINTER :: zsurfmsk
  1058. !!----------------------------------------------------------------
  1059. p_fld_crs(:,:) = 0.0
  1060. SELECT CASE ( cd_op )
  1061. CASE ( 'VOL' )
  1062. CALL wrk_alloc( jpi, jpj, zsurfmsk )
  1063. zsurfmsk(:,:) = p_e12(:,:) * p_e3(:,:,1) * p_mask(:,:,1)
  1064. IF( nldj_crs == 1 .AND. ( ( mje_crs(2) - mjs_crs(2) ) < 2 ) ) THEN !!cc bande du sud style ORCA2
  1065. IF( mje_crs(2) - mjs_crs(2) == 1 ) THEN
  1066. je_2 = mje_crs(2)
  1067. DO ji = nistr, niend, nn_factx
  1068. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  1069. zflcrs = p_fld(ji ,je_2) * zsurfmsk(ji ,je_2) &
  1070. & + p_fld(ji+1,je_2) * zsurfmsk(ji+1,je_2) &
  1071. & + p_fld(ji+2,je_2) * zsurfmsk(ji+2,je_2)
  1072. zsfcrs = zsurfmsk(ji,je_2) + zsurfmsk(ji+1,je_2) + zsurfmsk(ji+2,je_2)
  1073. !
  1074. p_fld_crs(ii,2) = zflcrs
  1075. IF( zsfcrs /= 0.0 ) p_fld_crs(ii,2) = zflcrs / zsfcrs
  1076. ENDDO
  1077. ENDIF
  1078. ELSE
  1079. je_2 = mjs_crs(2)
  1080. DO ji = nistr, niend, nn_factx
  1081. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  1082. zflcrs = p_fld(ji ,je_2 ) * zsurfmsk(ji ,je_2 ) &
  1083. & + p_fld(ji+1,je_2 ) * zsurfmsk(ji+1,je_2 ) &
  1084. & + p_fld(ji+2,je_2 ) * zsurfmsk(ji+2,je_2 ) &
  1085. & + p_fld(ji ,je_2+1) * zsurfmsk(ji ,je_2+1) &
  1086. & + p_fld(ji+1,je_2+1) * zsurfmsk(ji+1,je_2+1) &
  1087. & + p_fld(ji+2,je_2+1) * zsurfmsk(ji+2,je_2+1) &
  1088. & + p_fld(ji ,je_2+2) * zsurfmsk(ji ,je_2+2) &
  1089. & + p_fld(ji+1,je_2+2) * zsurfmsk(ji+1,je_2+2) &
  1090. & + p_fld(ji+2,je_2+2) * zsurfmsk(ji+2,je_2+2)
  1091. zsfcrs = zsurfmsk(ji,je_2 ) + zsurfmsk(ji+1,je_2 ) + zsurfmsk(ji+2,je_2 ) &
  1092. & + zsurfmsk(ji,je_2+1) + zsurfmsk(ji+1,je_2+1) + zsurfmsk(ji+2,je_2+1) &
  1093. & + zsurfmsk(ji,je_2+2) + zsurfmsk(ji+1,je_2+2) + zsurfmsk(ji+2,je_2+2)
  1094. !
  1095. p_fld_crs(ii,2) = zflcrs
  1096. IF( zsfcrs /= 0.0 ) p_fld_crs(ii,2) = zflcrs / zsfcrs
  1097. ENDDO
  1098. ENDIF
  1099. !
  1100. DO jj = njstr, njend, nn_facty
  1101. DO ji = nistr, niend, nn_factx
  1102. ii = ( ji - mis_crs(2) ) * rfactx_r + 2 ! cordinate in parent grid
  1103. ij = ( jj - njstr ) * rfacty_r + 3
  1104. zflcrs = p_fld(ji ,jj ) * zsurfmsk(ji ,jj ) &
  1105. & + p_fld(ji+1,jj ) * zsurfmsk(ji+1,jj ) &
  1106. & + p_fld(ji+2,jj ) * zsurfmsk(ji+2,jj ) &
  1107. & + p_fld(ji ,jj+1) * zsurfmsk(ji ,jj+1) &
  1108. & + p_fld(ji+1,jj+1) * zsurfmsk(ji+1,jj+1) &
  1109. & + p_fld(ji+2,jj+1) * zsurfmsk(ji+2,jj+1) &
  1110. & + p_fld(ji ,jj+2) * zsurfmsk(ji ,jj+2) &
  1111. & + p_fld(ji+1,jj+2) * zsurfmsk(ji+1,jj+2) &
  1112. & + p_fld(ji+2,jj+2) * zsurfmsk(ji+2,jj+2)
  1113. zsfcrs = zsurfmsk(ji,jj ) + zsurfmsk(ji+1,jj ) + zsurfmsk(ji+2,jj ) &
  1114. & + zsurfmsk(ji,jj+1) + zsurfmsk(ji+1,jj+1) + zsurfmsk(ji+2,jj+1) &
  1115. & + zsurfmsk(ji,jj+2) + zsurfmsk(ji+1,jj+2) + zsurfmsk(ji+2,jj+2)
  1116. !
  1117. p_fld_crs(ii,ij) = zflcrs
  1118. IF( zsfcrs /= 0.0 ) p_fld_crs(ii,ij) = zflcrs / zsfcrs
  1119. ENDDO
  1120. ENDDO
  1121. CALL wrk_dealloc( jpi, jpj, zsurfmsk )
  1122. CASE ( 'SUM' )
  1123. CALL wrk_alloc( jpi, jpj, zsurfmsk )
  1124. IF( PRESENT( p_e3 ) ) THEN
  1125. zsurfmsk(:,:) = p_e12(:,:) * p_e3(:,:,1) * p_mask(:,:,1)
  1126. ELSE
  1127. zsurfmsk(:,:) = p_e12(:,:) * p_mask(:,:,1)
  1128. ENDIF
  1129. SELECT CASE ( cd_type )
  1130. CASE( 'T', 'W' )
  1131. IF( nldj_crs == 1 .AND. ( ( mje_crs(2) - mjs_crs(2) ) < 2 ) ) THEN !!cc bande du sud style ORCA2
  1132. IF( mje_crs(2) - mjs_crs(2) == 1 ) THEN
  1133. je_2 = mje_crs(2)
  1134. DO ji = nistr, niend, nn_factx
  1135. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  1136. zflcrs = p_fld(ji ,je_2) * zsurfmsk(ji ,je_2) &
  1137. & + p_fld(ji+1,je_2) * zsurfmsk(ji+1,je_2) &
  1138. & + p_fld(ji+2,je_2) * zsurfmsk(ji+2,je_2)
  1139. !
  1140. p_fld_crs(ii,2) = zflcrs
  1141. ENDDO
  1142. ENDIF
  1143. ELSE
  1144. je_2 = mjs_crs(2)
  1145. DO ji = nistr, niend, nn_factx
  1146. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  1147. zflcrs = p_fld(ji ,je_2 ) * zsurfmsk(ji ,je_2 ) &
  1148. & + p_fld(ji+1,je_2 ) * zsurfmsk(ji+1,je_2 ) &
  1149. & + p_fld(ji+2,je_2 ) * zsurfmsk(ji+2,je_2 ) &
  1150. & + p_fld(ji ,je_2+1) * zsurfmsk(ji ,je_2+1) &
  1151. & + p_fld(ji+1,je_2+1) * zsurfmsk(ji+1,je_2+1) &
  1152. & + p_fld(ji+2,je_2+1) * zsurfmsk(ji+2,je_2+1) &
  1153. & + p_fld(ji ,je_2+2) * zsurfmsk(ji ,je_2+2) &
  1154. & + p_fld(ji+1,je_2+2) * zsurfmsk(ji+1,je_2+2) &
  1155. & + p_fld(ji+2,je_2+2) * zsurfmsk(ji+2,je_2+2)
  1156. !
  1157. p_fld_crs(ii,2) = zflcrs
  1158. ENDDO
  1159. ENDIF
  1160. !
  1161. DO jj = njstr, njend, nn_facty
  1162. DO ji = nistr, niend, nn_factx
  1163. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  1164. ij = ( jj - njstr ) * rfacty_r + 3
  1165. zflcrs = p_fld(ji ,jj ) * zsurfmsk(ji ,jj ) &
  1166. & + p_fld(ji+1,jj ) * zsurfmsk(ji+1,jj ) &
  1167. & + p_fld(ji+2,jj ) * zsurfmsk(ji+2,jj ) &
  1168. & + p_fld(ji ,jj+1) * zsurfmsk(ji ,jj+1) &
  1169. & + p_fld(ji+1,jj+1) * zsurfmsk(ji+1,jj+1) &
  1170. & + p_fld(ji+2,jj+1) * zsurfmsk(ji+2,jj+1) &
  1171. & + p_fld(ji ,jj+2) * zsurfmsk(ji ,jj+2) &
  1172. & + p_fld(ji+1,jj+2) * zsurfmsk(ji+1,jj+2) &
  1173. & + p_fld(ji+2,jj+2) * zsurfmsk(ji+2,jj+2)
  1174. !
  1175. p_fld_crs(ii,ij) = zflcrs
  1176. !
  1177. ENDDO
  1178. ENDDO
  1179. CASE( 'V' )
  1180. IF( nldj_crs == 1 .AND. ( ( mje_crs(2) - mjs_crs(2) ) < 2 ) ) THEN !!cc bande du sud style ORCA2
  1181. IF( mje_crs(2) - mjs_crs(2) == 1 ) THEN
  1182. ijje = mje_crs(2)
  1183. ENDIF
  1184. ELSE
  1185. ijje = mjs_crs(2)
  1186. ENDIF
  1187. DO ji = nistr, niend, nn_factx
  1188. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  1189. zflcrs = p_fld(ji ,ijje) * zsurfmsk(ji ,ijje) &
  1190. & + p_fld(ji+1,ijje) * zsurfmsk(ji+1,ijje) &
  1191. & + p_fld(ji+2,ijje) * zsurfmsk(ji+2,ijje)
  1192. !
  1193. p_fld_crs(ii,2) = zflcrs
  1194. ENDDO
  1195. DO jj = njstr, njend, nn_facty
  1196. DO ji = nistr, niend, nn_factx
  1197. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  1198. ij = ( jj - njstr ) * rfacty_r + 3
  1199. ijje = mje_crs(ij)
  1200. zflcrs = p_fld(ji ,ijje) * zsurfmsk(ji ,ijje) &
  1201. & + p_fld(ji+1,ijje) * zsurfmsk(ji+1,ijje) &
  1202. & + p_fld(ji+2,ijje) * zsurfmsk(ji+2,ijje)
  1203. !
  1204. p_fld_crs(ii,ij) = zflcrs
  1205. !
  1206. ENDDO
  1207. ENDDO
  1208. CASE( 'U' )
  1209. IF( nldj_crs == 1 .AND. ( ( mje_crs(2) - mjs_crs(2) ) < 2 ) ) THEN !!cc bande du sud style ORCA2
  1210. IF( mje_crs(2) - mjs_crs(2) == 1 ) THEN
  1211. je_2 = mje_crs(2)
  1212. DO ji = nistr, niend, nn_factx
  1213. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  1214. ijie = mie_crs(ii)
  1215. zflcrs = p_fld(ijie,je_2) * zsurfmsk(ijie,je_2)
  1216. p_fld_crs(ii,2) = zflcrs
  1217. ENDDO
  1218. ENDIF
  1219. ELSE
  1220. je_2 = mjs_crs(2)
  1221. DO ji = nistr, niend, nn_factx
  1222. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  1223. ijie = mie_crs(ii)
  1224. zflcrs = p_fld(ijie,je_2 ) * zsurfmsk(ijie,je_2 ) &
  1225. & + p_fld(ijie,je_2+1) * zsurfmsk(ijie,je_2+1) &
  1226. & + p_fld(ijie,je_2+2) * zsurfmsk(ijie,je_2+2)
  1227. p_fld_crs(ii,2) = zflcrs
  1228. ENDDO
  1229. ENDIF
  1230. DO jj = njstr, njend, nn_facty
  1231. DO ji = nistr, niend, nn_factx
  1232. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  1233. ij = ( jj - njstr ) * rfacty_r + 3
  1234. ijie = mie_crs(ii)
  1235. zflcrs = p_fld(ijie,jj ) * zsurfmsk(ijie,jj ) &
  1236. & + p_fld(ijie,jj+1) * zsurfmsk(ijie,jj+1) &
  1237. & + p_fld(ijie,jj+2) * zsurfmsk(ijie,jj+2)
  1238. !
  1239. p_fld_crs(ii,ij) = zflcrs
  1240. !
  1241. ENDDO
  1242. ENDDO
  1243. END SELECT
  1244. IF( PRESENT( p_surf_crs ) ) THEN
  1245. WHERE ( p_surf_crs /= 0.0 ) p_fld_crs(:,:) = p_fld_crs(:,:) / p_surf_crs(:,:)
  1246. ENDIF
  1247. CALL wrk_dealloc( jpi, jpj, zsurfmsk )
  1248. CASE ( 'MAX' )
  1249. SELECT CASE ( cd_type )
  1250. CASE( 'T', 'W' )
  1251. IF( nldj_crs == 1 .AND. ( ( mje_crs(2) - mjs_crs(2) ) < 2 ) ) THEN !!cc bande du sud style ORCA2
  1252. IF( mje_crs(2) - mjs_crs(2) == 1 ) THEN
  1253. je_2 = mje_crs(2)
  1254. DO ji = nistr, niend, nn_factx
  1255. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  1256. zflcrs = &
  1257. & MAX( p_fld(ji ,je_2) * p_mask(ji ,je_2,1) - ( 1.- p_mask(ji ,je_2,1) ) * r_inf , &
  1258. & p_fld(ji+1,je_2) * p_mask(ji+1,je_2,1) - ( 1.- p_mask(ji+1,je_2,1) ) * r_inf , &
  1259. & p_fld(ji+2,je_2) * p_mask(ji+2,je_2,1) - ( 1.- p_mask(ji+2,je_2,1) ) * r_inf )
  1260. !
  1261. p_fld_crs(ii,2) = zflcrs
  1262. ENDDO
  1263. ENDIF
  1264. ELSE
  1265. je_2 = mjs_crs(2)
  1266. zflcrs = &
  1267. & MAX( p_fld(ji ,je_2 ) * p_mask(ji ,je_2 ,1) - ( 1.- p_mask(ji ,je_2 ,1) ) * r_inf , &
  1268. & p_fld(ji+1,je_2 ) * p_mask(ji+1,je_2 ,1) - ( 1.- p_mask(ji+1,je_2 ,1) ) * r_inf , &
  1269. & p_fld(ji+2,je_2 ) * p_mask(ji+2,je_2 ,1) - ( 1.- p_mask(ji+2,je_2 ,1) ) * r_inf , &
  1270. & p_fld(ji ,je_2+1) * p_mask(ji ,je_2+1,1) - ( 1.- p_mask(ji ,je_2+1,1) ) * r_inf , &
  1271. & p_fld(ji+1,je_2+1) * p_mask(ji+1,je_2+1,1) - ( 1.- p_mask(ji+1,je_2+1,1) ) * r_inf , &
  1272. & p_fld(ji+2,je_2+1) * p_mask(ji+2,je_2+1,1) - ( 1.- p_mask(ji+2,je_2+1,1) ) * r_inf , &
  1273. & p_fld(ji ,je_2+2) * p_mask(ji ,je_2+2,1) - ( 1.- p_mask(ji ,je_2+2,1) ) * r_inf , &
  1274. & p_fld(ji+1,je_2+2) * p_mask(ji+1,je_2+2,1) - ( 1.- p_mask(ji+1,je_2+2,1) ) * r_inf , &
  1275. & p_fld(ji+2,je_2+2) * p_mask(ji+2,je_2+2,1) - ( 1.- p_mask(ji+2,je_2+2,1) ) * r_inf )
  1276. !
  1277. p_fld_crs(ii,2) = zflcrs
  1278. ENDIF
  1279. DO jj = njstr, njend, nn_facty
  1280. DO ji = nistr, niend, nn_factx
  1281. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  1282. ij = ( jj - njstr ) * rfacty_r + 3
  1283. zflcrs = &
  1284. & MAX( p_fld(ji ,jj ) * p_mask(ji ,jj ,1) - ( 1.- p_mask(ji ,jj ,1) ) * r_inf , &
  1285. & p_fld(ji+1,jj ) * p_mask(ji+1,jj ,1) - ( 1.- p_mask(ji+1,jj ,1) ) * r_inf , &
  1286. & p_fld(ji+2,jj ) * p_mask(ji+2,jj ,1) - ( 1.- p_mask(ji+2,jj ,1) ) * r_inf , &
  1287. & p_fld(ji ,jj+1) * p_mask(ji ,jj+1,1) - ( 1.- p_mask(ji ,jj+1,1) ) * r_inf , &
  1288. & p_fld(ji+1,jj+1) * p_mask(ji+1,jj+1,1) - ( 1.- p_mask(ji+1,jj+1,1) ) * r_inf , &
  1289. & p_fld(ji+2,jj+1) * p_mask(ji+2,jj+1,1) - ( 1.- p_mask(ji+2,jj+1,1) ) * r_inf , &
  1290. & p_fld(ji ,jj+2) * p_mask(ji ,jj+2,1) - ( 1.- p_mask(ji ,jj+2,1) ) * r_inf , &
  1291. & p_fld(ji+1,jj+2) * p_mask(ji+1,jj+2,1) - ( 1.- p_mask(ji+1,jj+2,1) ) * r_inf , &
  1292. & p_fld(ji+2,jj+2) * p_mask(ji+2,jj+2,1) - ( 1.- p_mask(ji+2,jj+2,1) ) * r_inf )
  1293. !
  1294. p_fld_crs(ii,ij) = zflcrs
  1295. !
  1296. ENDDO
  1297. ENDDO
  1298. CASE( 'V' )
  1299. IF( nldj_crs == 1 .AND. ( ( mje_crs(2) - mjs_crs(2) ) < 2 ) ) THEN !!cc bande du sud style ORCA2
  1300. IF( mje_crs(2) - mjs_crs(2) == 1 ) THEN
  1301. ijje = mje_crs(2)
  1302. ENDIF
  1303. ELSE
  1304. ijje = mjs_crs(2)
  1305. ENDIF
  1306. DO ji = nistr, niend, nn_factx
  1307. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  1308. zflcrs = MAX( p_fld(ji ,ijje) * p_mask(ji ,ijje,1) - ( 1.- p_mask(ji,ijje,1) ) * r_inf , &
  1309. & p_fld(ji+1,ijje) * p_mask(ji+1,ijje,1) - ( 1.- p_mask(ji,ijje,1) ) * r_inf , &
  1310. & p_fld(ji+2,ijje) * p_mask(ji+2,ijje,1) - ( 1.- p_mask(ji,ijje,1) ) * r_inf )
  1311. !
  1312. p_fld_crs(ii,2) = zflcrs
  1313. ENDDO
  1314. DO jj = njstr, njend, nn_facty
  1315. DO ji = nistr, niend, nn_factx
  1316. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  1317. ij = ( jj - njstr ) * rfacty_r + 3
  1318. ijje = mje_crs(ij)
  1319. !
  1320. zflcrs = MAX( p_fld(ji ,ijje) * p_mask(ji ,ijje,1) - ( 1.- p_mask(ji,ijje,1) ) * r_inf , &
  1321. & p_fld(ji+1,ijje) * p_mask(ji+1,ijje,1) - ( 1.- p_mask(ji,ijje,1) ) * r_inf , &
  1322. & p_fld(ji+2,ijje) * p_mask(ji+2,ijje,1) - ( 1.- p_mask(ji,ijje,1) ) * r_inf )
  1323. !
  1324. p_fld_crs(ii,ij) = zflcrs
  1325. !
  1326. ENDDO
  1327. ENDDO
  1328. CASE( 'U' )
  1329. IF( nldj_crs == 1 .AND. ( ( mje_crs(2) - mjs_crs(2) ) < 2 ) ) THEN !!cc bande du sud style ORCA2
  1330. IF( mje_crs(2) - mjs_crs(2) == 1 ) THEN
  1331. je_2 = mje_crs(2)
  1332. DO ji = nistr, niend, nn_factx
  1333. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  1334. ijie = mie_crs(ii)
  1335. zflcrs = p_fld(ijie,je_2) * p_mask(ijie,je_2,1) - ( 1.- p_mask(ijie,je_2,1) ) * r_inf
  1336. p_fld_crs(ii,2) = zflcrs
  1337. ENDDO
  1338. ENDIF
  1339. ELSE
  1340. je_2 = mjs_crs(2)
  1341. DO ji = nistr, niend, nn_factx
  1342. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  1343. ijie = mie_crs(ii)
  1344. zflcrs = &
  1345. & MAX( p_fld(ijie,je_2 ) * p_mask(ijie,je_2 ,1) - ( 1.- p_mask(ijie,je_2,1) ) * r_inf , &
  1346. & p_fld(ijie,je_2+1) * p_mask(ijie,je_2+1,1) - ( 1.- p_mask(ijie,je_2,1) ) * r_inf , &
  1347. & p_fld(ijie,je_2+2) * p_mask(ijie,je_2+2,1) - ( 1.- p_mask(ijie,je_2,1) ) * r_inf )
  1348. p_fld_crs(ii,2) = zflcrs
  1349. ENDDO
  1350. ENDIF
  1351. DO jj = njstr, njend, nn_facty
  1352. DO ji = nistr, niend, nn_factx
  1353. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  1354. ij = ( jj - njstr ) * rfacty_r + 3
  1355. ijie = mie_crs(ii)
  1356. zflcrs = &
  1357. & MAX( p_fld(ijie,jj ) * p_mask(ijie,jj ,1) - ( 1.- p_mask(ijie,jj,1) ) * r_inf , &
  1358. & p_fld(ijie,jj+1) * p_mask(ijie,jj+1,1) - ( 1.- p_mask(ijie,jj,1) ) * r_inf , &
  1359. & p_fld(ijie,jj+2) * p_mask(ijie,jj+2,1) - ( 1.- p_mask(ijie,jj,1) ) * r_inf )
  1360. p_fld_crs(ii,ij) = zflcrs
  1361. !
  1362. ENDDO
  1363. ENDDO
  1364. END SELECT
  1365. CASE ( 'MIN' ) ! Search the min of unmasked grid cells
  1366. SELECT CASE ( cd_type )
  1367. CASE( 'T', 'W' )
  1368. IF( nldj_crs == 1 .AND. ( ( mje_crs(2) - mjs_crs(2) ) < 2 ) ) THEN !!cc bande du sud style ORCA2
  1369. IF( mje_crs(2) - mjs_crs(2) == 1 ) THEN
  1370. je_2 = mje_crs(2)
  1371. DO ji = nistr, niend, nn_factx
  1372. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  1373. zflcrs = &
  1374. & MIN( p_fld(ji ,je_2) * p_mask(ji ,je_2,1) + ( 1.- p_mask(ji ,je_2,1) ) * r_inf , &
  1375. & p_fld(ji+1,je_2) * p_mask(ji+1,je_2,1) + ( 1.- p_mask(ji+1,je_2,1) ) * r_inf , &
  1376. & p_fld(ji+2,je_2) * p_mask(ji+2,je_2,1) + ( 1.- p_mask(ji+2,je_2,1) ) * r_inf )
  1377. !
  1378. p_fld_crs(ii,2) = zflcrs
  1379. ENDDO
  1380. ENDIF
  1381. ELSE
  1382. je_2 = mjs_crs(2)
  1383. zflcrs = &
  1384. & MIN( p_fld(ji ,je_2 ) * p_mask(ji ,je_2 ,1) + ( 1.- p_mask(ji ,je_2 ,1) ) * r_inf , &
  1385. & p_fld(ji+1,je_2 ) * p_mask(ji+1,je_2 ,1) + ( 1.- p_mask(ji+1,je_2 ,1) ) * r_inf , &
  1386. & p_fld(ji+2,je_2 ) * p_mask(ji+2,je_2 ,1) + ( 1.- p_mask(ji+2,je_2 ,1) ) * r_inf , &
  1387. & p_fld(ji ,je_2+1) * p_mask(ji ,je_2+1,1) + ( 1.- p_mask(ji ,je_2+1,1) ) * r_inf , &
  1388. & p_fld(ji+1,je_2+1) * p_mask(ji+1,je_2+1,1) + ( 1.- p_mask(ji+1,je_2+1,1) ) * r_inf , &
  1389. & p_fld(ji+2,je_2+1) * p_mask(ji+2,je_2+1,1) + ( 1.- p_mask(ji+2,je_2+1,1) ) * r_inf , &
  1390. & p_fld(ji ,je_2+2) * p_mask(ji ,je_2+2,1) + ( 1.- p_mask(ji ,je_2+2,1) ) * r_inf , &
  1391. & p_fld(ji+1,je_2+2) * p_mask(ji+1,je_2+2,1) + ( 1.- p_mask(ji+1,je_2+2,1) ) * r_inf , &
  1392. & p_fld(ji+2,je_2+2) * p_mask(ji+2,je_2+2,1) + ( 1.- p_mask(ji+2,je_2+2,1) ) * r_inf )
  1393. !
  1394. p_fld_crs(ii,2) = zflcrs
  1395. ENDIF
  1396. DO jj = njstr, njend, nn_facty
  1397. DO ji = nistr, niend, nn_factx
  1398. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  1399. ij = ( jj - njstr ) * rfacty_r + 3
  1400. zflcrs = &
  1401. & MIN( p_fld(ji ,jj ) * p_mask(ji ,jj ,1) + ( 1.- p_mask(ji ,jj ,1) ) * r_inf , &
  1402. & p_fld(ji+1,jj ) * p_mask(ji+1,jj ,1) + ( 1.- p_mask(ji+1,jj ,1) ) * r_inf , &
  1403. & p_fld(ji+2,jj ) * p_mask(ji+2,jj ,1) + ( 1.- p_mask(ji+2,jj ,1) ) * r_inf , &
  1404. & p_fld(ji ,jj+1) * p_mask(ji ,jj+1,1) + ( 1.- p_mask(ji ,jj+1,1) ) * r_inf , &
  1405. & p_fld(ji+1,jj+1) * p_mask(ji+1,jj+1,1) + ( 1.- p_mask(ji+1,jj+1,1) ) * r_inf , &
  1406. & p_fld(ji+2,jj+1) * p_mask(ji+2,jj+1,1) + ( 1.- p_mask(ji+2,jj+1,1) ) * r_inf , &
  1407. & p_fld(ji ,jj+2) * p_mask(ji ,jj+2,1) + ( 1.- p_mask(ji ,jj+2,1) ) * r_inf , &
  1408. & p_fld(ji+1,jj+2) * p_mask(ji+1,jj+2,1) + ( 1.- p_mask(ji+1,jj+2,1) ) * r_inf , &
  1409. & p_fld(ji+2,jj+2) * p_mask(ji+2,jj+2,1) + ( 1.- p_mask(ji+2,jj+2,1) ) * r_inf )
  1410. !
  1411. p_fld_crs(ii,ij) = zflcrs
  1412. !
  1413. ENDDO
  1414. ENDDO
  1415. CASE( 'V' )
  1416. IF( nldj_crs == 1 .AND. ( ( mje_crs(2) - mjs_crs(2) ) < 2 ) ) THEN !!cc bande du sud style ORCA2
  1417. IF( mje_crs(2) - mjs_crs(2) == 1 ) THEN
  1418. ijje = mje_crs(2)
  1419. ENDIF
  1420. ELSE
  1421. ijje = mjs_crs(2)
  1422. ENDIF
  1423. DO ji = nistr, niend, nn_factx
  1424. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  1425. zflcrs = MIN( p_fld(ji ,ijje) * p_mask(ji ,ijje,1) + ( 1.- p_mask(ji,ijje,1) ) * r_inf , &
  1426. & p_fld(ji+1,ijje) * p_mask(ji+1,ijje,1) + ( 1.- p_mask(ji,ijje,1) ) * r_inf , &
  1427. & p_fld(ji+2,ijje) * p_mask(ji+2,ijje,1) + ( 1.- p_mask(ji,ijje,1) ) * r_inf )
  1428. !
  1429. p_fld_crs(ii,2) = zflcrs
  1430. ENDDO
  1431. DO jj = njstr, njend, nn_facty
  1432. DO ji = nistr, niend, nn_factx
  1433. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  1434. ij = ( jj - njstr ) * rfacty_r + 3
  1435. ijje = mje_crs(ij)
  1436. !
  1437. zflcrs = MIN( p_fld(ji ,ijje) * p_mask(ji ,ijje,1) + ( 1.- p_mask(ji,ijje,1) ) * r_inf , &
  1438. & p_fld(ji+1,ijje) * p_mask(ji+1,ijje,1) + ( 1.- p_mask(ji,ijje,1) ) * r_inf , &
  1439. & p_fld(ji+2,ijje) * p_mask(ji+2,ijje,1) + ( 1.- p_mask(ji,ijje,1) ) * r_inf )
  1440. !
  1441. p_fld_crs(ii,ij) = zflcrs
  1442. !
  1443. ENDDO
  1444. ENDDO
  1445. CASE( 'U' )
  1446. IF( nldj_crs == 1 .AND. ( ( mje_crs(2) - mjs_crs(2) ) < 2 ) ) THEN !!cc bande du sud style ORCA2
  1447. IF( mje_crs(2) - mjs_crs(2) == 1 ) THEN
  1448. je_2 = mje_crs(2)
  1449. DO ji = nistr, niend, nn_factx
  1450. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  1451. ijie = mie_crs(ii)
  1452. zflcrs = p_fld(ijie,je_2) * p_mask(ijie,je_2,1) + ( 1.- p_mask(ijie,je_2,1) ) * r_inf
  1453. p_fld_crs(ii,2) = zflcrs
  1454. ENDDO
  1455. ENDIF
  1456. ELSE
  1457. je_2 = mjs_crs(2)
  1458. DO ji = nistr, niend, nn_factx
  1459. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  1460. ijie = mie_crs(ii)
  1461. zflcrs = &
  1462. & MIN( p_fld(ijie,je_2 ) * p_mask(ijie,je_2 ,1) + ( 1.- p_mask(ijie,je_2,1) ) * r_inf , &
  1463. & p_fld(ijie,je_2+1) * p_mask(ijie,je_2+1,1) + ( 1.- p_mask(ijie,je_2,1) ) * r_inf , &
  1464. & p_fld(ijie,je_2+2) * p_mask(ijie,je_2+2,1) + ( 1.- p_mask(ijie,je_2,1) ) * r_inf )
  1465. p_fld_crs(ii,2) = zflcrs
  1466. ENDDO
  1467. ENDIF
  1468. DO jj = njstr, njend, nn_facty
  1469. DO ji = nistr, niend, nn_factx
  1470. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  1471. ij = ( jj - njstr ) * rfacty_r + 3
  1472. ijie = mie_crs(ii)
  1473. zflcrs = &
  1474. & MIN( p_fld(ijie,jj ) * p_mask(ijie,jj ,1) + ( 1.- p_mask(ijie,jj,1) ) * r_inf , &
  1475. & p_fld(ijie,jj+1) * p_mask(ijie,jj+1,1) + ( 1.- p_mask(ijie,jj,1) ) * r_inf , &
  1476. & p_fld(ijie,jj+2) * p_mask(ijie,jj+2,1) + ( 1.- p_mask(ijie,jj,1) ) * r_inf )
  1477. p_fld_crs(ii,ij) = zflcrs
  1478. !
  1479. ENDDO
  1480. ENDDO
  1481. END SELECT
  1482. !
  1483. END SELECT
  1484. !
  1485. CALL crs_lbc_lnk( p_fld_crs, cd_type, psgn )
  1486. !
  1487. END SUBROUTINE crs_dom_ope_2d
  1488. SUBROUTINE crs_dom_e3( p_e1, p_e2, p_e3, p_sfc_crs, cd_type, p_mask, p_e3_crs, p_e3_max_crs)
  1489. !!----------------------------------------------------------------
  1490. !! Arguments
  1491. CHARACTER(len=1), INTENT(in) :: cd_type ! grid type T, W ( U, V, F)
  1492. REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in) :: p_mask ! Parent grid T mask
  1493. REAL(wp), DIMENSION(jpi,jpj) , INTENT(in) :: p_e1, p_e2 ! 2D tracer T or W on parent grid
  1494. REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in) :: p_e3 ! 3D tracer T or W on parent grid
  1495. REAL(wp), DIMENSION(jpi_crs,jpj_crs,jpk), INTENT(in) :: p_sfc_crs ! Coarse grid box east or north face quantity
  1496. REAL(wp), DIMENSION(jpi_crs,jpj_crs,jpk), INTENT(inout) :: p_e3_crs ! Coarse grid box east or north face quantity
  1497. REAL(wp), DIMENSION(jpi_crs,jpj_crs,jpk), INTENT(inout) :: p_e3_max_crs ! Coarse grid box east or north face quantity
  1498. !! Local variables
  1499. INTEGER :: ji, jj, jk ! dummy loop indices
  1500. INTEGER :: ijie, ijje, ii, ij, je_2
  1501. REAL(wp) :: ze3crs
  1502. REAL(wp), DIMENSION(:,:,:), POINTER :: zmask, zsurf
  1503. !!----------------------------------------------------------------
  1504. p_e3_crs (:,:,:) = 0.
  1505. p_e3_max_crs(:,:,:) = 1.
  1506. CALL wrk_alloc( jpi, jpj, jpk, zmask, zsurf )
  1507. SELECT CASE ( cd_type )
  1508. CASE( 'W' )
  1509. zmask(:,:,1) = p_mask(:,:,1)
  1510. DO jk = 2, jpk
  1511. zmask(:,:,jk) = p_mask(:,:,jk-1)
  1512. ENDDO
  1513. CASE DEFAULT
  1514. DO jk = 1, jpk
  1515. zmask(:,:,jk) = p_mask(:,:,jk)
  1516. ENDDO
  1517. END SELECT
  1518. DO jk = 1, jpk
  1519. zsurf(:,:,jk) = p_e1(:,:) * p_e2(:,:) * p_e3(:,:,jk)
  1520. ENDDO
  1521. IF( nldj_crs == 1 .AND. ( ( mje_crs(2) - mjs_crs(2) ) < 2 ) ) THEN !!cc bande du sud style ORCA2
  1522. IF( mje_crs(2) - mjs_crs(2) == 1 ) THEN
  1523. je_2 = mje_crs(2)
  1524. DO jk = 1 , jpk
  1525. DO ji = nistr, niend, nn_factx
  1526. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  1527. ze3crs = zsurf(ji ,je_2,jk) * zmask(ji ,je_2,jk) &
  1528. & + zsurf(ji+1,je_2,jk) * zmask(ji+1,je_2,jk) &
  1529. & + zsurf(ji+2,je_2,jk) * zmask(ji+2,je_2,jk)
  1530. p_e3_crs(ii,2,jk) = ze3crs / p_sfc_crs(ii,ij,jk)
  1531. !
  1532. ze3crs = MAX( p_e3(ji ,je_2,jk) * zmask(ji ,je_2,jk), &
  1533. & p_e3(ji+1,je_2,jk) * zmask(ji+1,je_2,jk), &
  1534. & p_e3(ji+2,je_2,jk) * zmask(ji+2,je_2,jk) )
  1535. !
  1536. p_e3_max_crs(ii,2,jk) = ze3crs
  1537. ENDDO
  1538. ENDDO
  1539. ENDIF
  1540. ELSE
  1541. je_2 = mjs_crs(2)
  1542. DO jk = 1 , jpk
  1543. DO ji = nistr, niend, nn_factx
  1544. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  1545. ze3crs = zsurf(ji ,je_2 ,jk) * zmask(ji ,je_2 ,jk) &
  1546. & + zsurf(ji+1,je_2 ,jk) * zmask(ji+1,je_2 ,jk) &
  1547. & + zsurf(ji+2,je_2 ,jk) * zmask(ji+2,je_2 ,jk) &
  1548. & + zsurf(ji ,je_2+1,jk) * zmask(ji ,je_2+1,jk) &
  1549. & + zsurf(ji+1,je_2+1,jk) * zmask(ji+1,je_2+1,jk) &
  1550. & + zsurf(ji+2,je_2+1,jk) * zmask(ji+2,je_2+1,jk) &
  1551. & + zsurf(ji ,je_2+2,jk) * zmask(ji ,je_2+2,jk) &
  1552. & + zsurf(ji+1,je_2+2,jk) * zmask(ji+1,je_2+2,jk) &
  1553. & + zsurf(ji+2,je_2+2,jk) * zmask(ji+2,je_2+2,jk)
  1554. p_e3_crs(ii,2,jk) = ze3crs / p_sfc_crs(ii,2,jk)
  1555. !
  1556. ze3crs = MAX( p_e3(ji ,je_2 ,jk) * zmask(ji ,je_2 ,jk), &
  1557. & p_e3(ji+1,je_2 ,jk) * zmask(ji+1,je_2 ,jk), &
  1558. & p_e3(ji+2,je_2 ,jk) * zmask(ji+2,je_2 ,jk), &
  1559. & p_e3(ji ,je_2+1,jk) * zmask(ji ,je_2+1,jk), &
  1560. & p_e3(ji+1,je_2+1,jk) * zmask(ji+1,je_2+1,jk), &
  1561. & p_e3(ji+2,je_2+1,jk) * zmask(ji+2,je_2+1,jk), &
  1562. & p_e3(ji ,je_2+2,jk) * zmask(ji ,je_2+2,jk), &
  1563. & p_e3(ji+1,je_2+2,jk) * zmask(ji+1,je_2+2,jk), &
  1564. & p_e3(ji+2,je_2+2,jk) * zmask(ji+2,je_2+2,jk) )
  1565. p_e3_max_crs(ii,2,jk) = ze3crs
  1566. ENDDO
  1567. ENDDO
  1568. ENDIF
  1569. DO jk = 1 , jpk
  1570. DO jj = njstr, njend, nn_facty
  1571. DO ji = nistr, niend, nn_factx
  1572. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  1573. ij = ( jj - njstr ) * rfacty_r + 3
  1574. ze3crs = zsurf(ji ,jj ,jk) * zmask(ji ,jj ,jk) &
  1575. & + zsurf(ji+1,jj ,jk) * zmask(ji+1,jj ,jk) &
  1576. & + zsurf(ji+2,jj ,jk) * zmask(ji+2,jj ,jk) &
  1577. & + zsurf(ji ,jj+1,jk) * zmask(ji ,jj+1,jk) &
  1578. & + zsurf(ji+1,jj+1,jk) * zmask(ji+1,jj+1,jk) &
  1579. & + zsurf(ji+2,jj+1,jk) * zmask(ji+2,jj+1,jk) &
  1580. & + zsurf(ji ,jj+2,jk) * zmask(ji ,jj+2,jk) &
  1581. & + zsurf(ji+1,jj+2,jk) * zmask(ji+1,jj+2,jk) &
  1582. & + zsurf(ji+2,jj+2,jk) * zmask(ji+2,jj+2,jk)
  1583. p_e3_crs(ii,ij,jk) = ze3crs / p_sfc_crs(ii,ij,jk)
  1584. !
  1585. ze3crs = MAX( p_e3(ji ,jj ,jk) * zmask(ji ,jj ,jk), &
  1586. & p_e3(ji+1,jj ,jk) * zmask(ji+1,jj ,jk), &
  1587. & p_e3(ji+2,jj ,jk) * zmask(ji+2,jj ,jk), &
  1588. & p_e3(ji ,jj+1,jk) * zmask(ji ,jj+1,jk), &
  1589. & p_e3(ji+1,jj+1,jk) * zmask(ji+1,jj+1,jk), &
  1590. & p_e3(ji+2,jj+1,jk) * zmask(ji+2,jj+1,jk), &
  1591. & p_e3(ji ,jj+2,jk) * zmask(ji ,jj+2,jk), &
  1592. & p_e3(ji+1,jj+2,jk) * zmask(ji+1,jj+2,jk), &
  1593. & p_e3(ji+2,jj+2,jk) * zmask(ji+2,jj+2,jk) )
  1594. p_e3_max_crs(ii,ij,jk) = ze3crs
  1595. ENDDO
  1596. ENDDO
  1597. ENDDO
  1598. CALL crs_lbc_lnk( p_e3_crs , cd_type, 1.0, pval=1.0 )
  1599. CALL crs_lbc_lnk( p_e3_max_crs, cd_type, 1.0, pval=1.0 )
  1600. !
  1601. CALL wrk_dealloc( jpi, jpj, jpk, zsurf, zmask )
  1602. !
  1603. END SUBROUTINE crs_dom_e3
  1604. SUBROUTINE crs_dom_sfc( p_mask, cd_type, p_surf_crs, p_surf_crs_msk, p_e1, p_e2, p_e3 )
  1605. !! Arguments
  1606. CHARACTER(len=1), INTENT(in) :: cd_type ! grid type T, W ( U, V, F)
  1607. REAL(wp), DIMENSION(jpi,jpj,jpk) , INTENT(in) :: p_mask ! Parent grid T mask
  1608. REAL(wp), DIMENSION(jpi,jpj) , INTENT(in), OPTIONAL :: p_e1, p_e2 ! 3D tracer T or W on parent grid
  1609. REAL(wp), DIMENSION(jpi,jpj,jpk) , INTENT(in), OPTIONAL :: p_e3 ! 3D tracer T or W on parent grid
  1610. REAL(wp), DIMENSION(jpi_crs,jpj_crs,jpk), INTENT(out) :: p_surf_crs ! Coarse grid box east or north face quantity
  1611. REAL(wp), DIMENSION(jpi_crs,jpj_crs,jpk), INTENT(out) :: p_surf_crs_msk ! Coarse grid box east or north face quantity
  1612. !! Local variables
  1613. INTEGER :: ji, jj, jk ! dummy loop indices
  1614. INTEGER :: ii, ij, je_2
  1615. REAL(wp), DIMENSION(:,:,:), POINTER :: zsurf, zsurfmsk
  1616. !!----------------------------------------------------------------
  1617. ! Initialize
  1618. CALL wrk_alloc( jpi, jpj, jpk, zsurf, zsurfmsk )
  1619. !
  1620. SELECT CASE ( cd_type )
  1621. CASE ('W')
  1622. DO jk = 1, jpk
  1623. zsurf(:,:,jk) = p_e1(:,:) * p_e2(:,:)
  1624. ENDDO
  1625. zsurfmsk(:,:,1) = zsurf(:,:,1) * p_mask(:,:,1)
  1626. DO jk = 2, jpk
  1627. zsurfmsk(:,:,jk) = zsurf(:,:,jk) * p_mask(:,:,jk-1)
  1628. ENDDO
  1629. CASE ('V')
  1630. DO jk = 1, jpk
  1631. zsurf(:,:,jk) = p_e1(:,:) * p_e3(:,:,jk)
  1632. ENDDO
  1633. DO jk = 1, jpk
  1634. zsurfmsk(:,:,jk) = zsurf(:,:,jk) * p_mask(:,:,jk)
  1635. ENDDO
  1636. CASE ('U')
  1637. DO jk = 1, jpk
  1638. zsurf(:,:,jk) = p_e2(:,:) * p_e3(:,:,jk)
  1639. ENDDO
  1640. DO jk = 1, jpk
  1641. zsurfmsk(:,:,jk) = zsurf(:,:,jk) * p_mask(:,:,jk)
  1642. ENDDO
  1643. CASE DEFAULT
  1644. DO jk = 1, jpk
  1645. zsurf(:,:,jk) = p_e1(:,:) * p_e2(:,:)
  1646. ENDDO
  1647. DO jk = 1, jpk
  1648. zsurfmsk(:,:,jk) = zsurf(:,:,jk) * p_mask(:,:,jk)
  1649. ENDDO
  1650. END SELECT
  1651. IF( nldj_crs == 1 .AND. ( ( mje_crs(2) - mjs_crs(2) ) < 2 ) ) THEN !!cc bande du sud style ORCA2
  1652. IF( mje_crs(2) - mjs_crs(2) == 1 ) THEN
  1653. je_2 = mje_crs(2)
  1654. DO jk = 1, jpk
  1655. DO ji = nistr, niend, nn_factx
  1656. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  1657. !
  1658. p_surf_crs (ii,2,jk) = zsurf(ji,je_2 ,jk) + zsurf(ji+1,je_2 ,jk) + zsurf(ji+2,je_2 ,jk) &
  1659. & + zsurf(ji,je_2-1,jk) + zsurf(ji+1,je_2-1,jk) + zsurf(ji+2,je_2-1,jk) ! Why ?????
  1660. !
  1661. p_surf_crs_msk(ii,2,jk) = zsurfmsk(ji,je_2,jk) + zsurfmsk(ji+1,je_2,jk) + zsurfmsk(ji+2,je_2,jk)
  1662. !
  1663. ENDDO
  1664. ENDDO
  1665. ENDIF
  1666. ELSE
  1667. je_2 = mjs_crs(2)
  1668. DO jk = 1, jpk
  1669. DO ji = nistr, niend, nn_factx
  1670. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  1671. !
  1672. p_surf_crs (ii,2,jk) = zsurf(ji,je_2 ,jk) + zsurf(ji+1,je_2 ,jk) + zsurf(ji+2,je_2 ,jk) &
  1673. & + zsurf(ji,je_2+1,jk) + zsurf(ji+1,je_2+1,jk) + zsurf(ji+2,je_2+1,jk) &
  1674. & + zsurf(ji,je_2+2,jk) + zsurf(ji+1,je_2+2,jk) + zsurf(ji+2,je_2+2,jk)
  1675. p_surf_crs_msk(ii,2,jk) = zsurfmsk(ji,je_2 ,jk) + zsurfmsk(ji+1,je_2 ,jk) + zsurfmsk(ji+2,je_2 ,jk) &
  1676. & + zsurfmsk(ji,je_2+1,jk) + zsurfmsk(ji+1,je_2+1,jk) + zsurfmsk(ji+2,je_2+1,jk) &
  1677. & + zsurfmsk(ji,je_2+2,jk) + zsurfmsk(ji+1,je_2+2,jk) + zsurfmsk(ji+2,je_2+2,jk)
  1678. ENDDO
  1679. ENDDO
  1680. ENDIF
  1681. DO jk = 1, jpk
  1682. DO jj = njstr, njend, nn_facty
  1683. DO ji = nistr, niend, nn_factx
  1684. ii = ( ji - mis_crs(2) ) * rfactx_r + 2
  1685. ij = ( jj - njstr ) * rfacty_r + 3
  1686. !
  1687. p_surf_crs (ii,ij,jk) = zsurf(ji,jj ,jk) + zsurf(ji+1,jj ,jk) + zsurf(ji+2,jj ,jk) &
  1688. & + zsurf(ji,jj+1,jk) + zsurf(ji+1,jj+1,jk) + zsurf(ji+2,jj+1,jk) &
  1689. & + zsurf(ji,jj+2,jk) + zsurf(ji+1,jj+2,jk) + zsurf(ji+2,jj+2,jk)
  1690. p_surf_crs_msk(ii,ij,jk) = zsurfmsk(ji,jj ,jk) + zsurfmsk(ji+1,jj ,jk) + zsurfmsk(ji+2,jj ,jk) &
  1691. & + zsurfmsk(ji,jj+1,jk) + zsurfmsk(ji+1,jj+1,jk) + zsurfmsk(ji+2,jj+1,jk) &
  1692. & + zsurfmsk(ji,jj+2,jk) + zsurfmsk(ji+1,jj+2,jk) + zsurfmsk(ji+2,jj+2,jk)
  1693. ENDDO
  1694. ENDDO
  1695. ENDDO
  1696. CALL crs_lbc_lnk( p_surf_crs , cd_type, 1.0, pval=1.0 )
  1697. CALL crs_lbc_lnk( p_surf_crs_msk, cd_type, 1.0, pval=1.0 )
  1698. CALL wrk_dealloc( jpi, jpj, jpk, zsurfmsk, zsurf )
  1699. END SUBROUTINE crs_dom_sfc
  1700. SUBROUTINE crs_dom_def
  1701. !!----------------------------------------------------------------
  1702. !! *** SUBROUTINE crs_dom_def ***
  1703. !! ** Purpose : Three applications.
  1704. !! 1) Define global domain indice of the croasening grid
  1705. !! 2) Define local domain indice of the croasening grid
  1706. !! 3) Define the processor domain indice for a croasening grid
  1707. !!----------------------------------------------------------------
  1708. !!
  1709. !! local variables
  1710. INTEGER :: ji,jj,jk,ijjgloT,ijis,ijie,ijjs,ijje,jn ! dummy indices
  1711. INTEGER :: ierr ! allocation error status
  1712. ! 1.a. Define global domain indices : take into account the interior domain only ( removes i/j=1 , i/j=jpiglo/jpjglo ) then add 2/3 grid points
  1713. jpiglo_crs = INT( (jpiglo - 2) / nn_factx ) + 2
  1714. ! jpjglo_crs = INT( (jpjglo - 2) / nn_facty ) + 2 ! the -2 removes j=1, j=jpj
  1715. ! jpjglo_crs = INT( (jpjglo - 2) / nn_facty ) + 3
  1716. jpjglo_crs = INT( (jpjglo - MOD(jpjglo, nn_facty)) / nn_facty ) + 3
  1717. jpiglo_crsm1 = jpiglo_crs - 1
  1718. jpjglo_crsm1 = jpjglo_crs - 1
  1719. jpi_crs = ( jpiglo_crs - 2 * jpreci + (jpni-1) ) / jpni + 2 * jpreci
  1720. jpj_crs = ( jpjglo_crsm1 - 2 * jprecj + (jpnj-1) ) / jpnj + 2 * jprecj
  1721. IF( noso < 0 ) jpj_crs = jpj_crs + 1 ! add a local band on southern processors
  1722. jpi_crsm1 = jpi_crs - 1
  1723. jpj_crsm1 = jpj_crs - 1
  1724. nperio_crs = jperio
  1725. npolj_crs = npolj
  1726. ierr = crs_dom_alloc() ! allocate most coarse grid arrays
  1727. ! 2.a Define processor domain
  1728. IF( .NOT. lk_mpp ) THEN
  1729. nimpp_crs = 1
  1730. njmpp_crs = 1
  1731. nlci_crs = jpi_crs
  1732. nlcj_crs = jpj_crs
  1733. nldi_crs = 1
  1734. nldj_crs = 1
  1735. nlei_crs = jpi_crs
  1736. nlej_crs = jpj_crs
  1737. ELSE
  1738. ! Initialisation of most local variables -
  1739. nimpp_crs = 1
  1740. njmpp_crs = 1
  1741. nlci_crs = jpi_crs
  1742. nlcj_crs = jpj_crs
  1743. nldi_crs = 1
  1744. nldj_crs = 1
  1745. nlei_crs = jpi_crs
  1746. nlej_crs = jpj_crs
  1747. ! Calculs suivant une découpage en j
  1748. DO jn = 1, jpnij, jpni
  1749. IF( jn < ( jpnij - jpni + 1 ) ) THEN
  1750. nlejt_crs(jn) = AINT( REAL( ( jpjglo - (njmppt(jn ) - 1) ) / nn_facty, wp ) ) &
  1751. & - AINT( REAL( ( jpjglo - (njmppt(jn+jpni) - 1) ) / nn_facty, wp ) )
  1752. ELSE
  1753. nlejt_crs(jn) = AINT( REAL( nlejt(jn) / nn_facty, wp ) ) + 1
  1754. ENDIF
  1755. IF( noso < 0 ) nlejt_crs(jn) = nlejt_crs(jn) + 1
  1756. SELECT CASE( ibonjt(jn) )
  1757. CASE ( -1 )
  1758. IF( MOD( jpjglo - njmppt(jn), nn_facty) > 0 ) nlejt_crs(jn) = nlejt_crs(jn) + 1
  1759. nlcjt_crs(jn) = nlejt_crs(jn) + jprecj
  1760. nldjt_crs(jn) = nldjt(jn)
  1761. CASE ( 0 )
  1762. nldjt_crs(jn) = nldjt(jn)
  1763. IF( nldjt(jn) == 1 ) nlejt_crs(jn) = nlejt_crs(jn) + 1
  1764. nlejt_crs(jn) = nlejt_crs(jn) + jprecj
  1765. nlcjt_crs(jn) = nlejt_crs(jn) + jprecj
  1766. CASE ( 1, 2 )
  1767. nlejt_crs(jn) = nlejt_crs(jn) + jprecj
  1768. nlcjt_crs(jn) = nlejt_crs(jn)
  1769. nldjt_crs(jn) = nldjt(jn)
  1770. CASE DEFAULT
  1771. STOP
  1772. END SELECT
  1773. IF( nlcjt_crs(jn) > jpj_crs ) jpj_crs = jpj_crs + 1
  1774. IF(nldjt_crs(jn) == 1 ) THEN
  1775. njmppt_crs(jn) = 1
  1776. ELSE
  1777. njmppt_crs(jn) = 2 + ANINT(REAL((njmppt(jn) + 1 - MOD( jpjglo , nn_facty )) / nn_facty, wp ) )
  1778. ENDIF
  1779. DO jj = jn + 1, jn + jpni - 1
  1780. nlejt_crs(jj) = nlejt_crs(jn)
  1781. nlcjt_crs(jj) = nlcjt_crs(jn)
  1782. nldjt_crs(jj) = nldjt_crs(jn)
  1783. njmppt_crs(jj)= njmppt_crs(jn)
  1784. ENDDO
  1785. ENDDO
  1786. nlej_crs = nlejt_crs(nproc + 1)
  1787. nlcj_crs = nlcjt_crs(nproc + 1)
  1788. nldj_crs = nldjt_crs(nproc + 1)
  1789. njmpp_crs = njmppt_crs(nproc + 1)
  1790. ! Calcul suivant un decoupage en i
  1791. DO jn = 1, jpni
  1792. IF( jn == 1 ) THEN
  1793. nleit_crs(jn) = AINT( REAL( ( nimppt(jn ) - 1 + nlcit(jn ) ) / nn_factx, wp) )
  1794. ELSE
  1795. nleit_crs(jn) = AINT( REAL( ( nimppt(jn ) - 1 + nlcit(jn ) ) / nn_factx, wp) ) &
  1796. & - AINT( REAL( ( nimppt(jn-1) - 1 + nlcit(jn-1) ) / nn_factx, wp) )
  1797. ENDIF
  1798. SELECT CASE( ibonit(jn) )
  1799. CASE ( -1 )
  1800. nleit_crs(jn) = nleit_crs(jn) + jpreci
  1801. nlcit_crs(jn) = nleit_crs(jn) + jpreci
  1802. nldit_crs(jn) = nldit(jn)
  1803. CASE ( 0 )
  1804. nleit_crs(jn) = nleit_crs(jn) + jpreci
  1805. nlcit_crs(jn) = nleit_crs(jn) + jpreci
  1806. nldit_crs(jn) = nldit(jn)
  1807. CASE ( 1, 2 )
  1808. IF( MOD( jpiglo - nimppt(jn), nn_factx) > 0 ) nleit_crs(jn) = nleit_crs(jn) + 1
  1809. nleit_crs(jn) = nleit_crs(jn) + jpreci
  1810. nlcit_crs(jn) = nleit_crs(jn)
  1811. nldit_crs(jn) = nldit(jn)
  1812. CASE DEFAULT
  1813. STOP
  1814. END SELECT
  1815. nimppt_crs(jn) = ANINT( REAL( (nimppt(jn) + 1 ) / nn_factx, wp ) ) + 1
  1816. DO jj = jn + jpni , jpnij, jpni
  1817. nleit_crs(jj) = nleit_crs(jn)
  1818. nlcit_crs(jj) = nlcit_crs(jn)
  1819. nldit_crs(jj) = nldit_crs(jn)
  1820. nimppt_crs(jj)= nimppt_crs(jn)
  1821. ENDDO
  1822. ENDDO
  1823. nlei_crs = nleit_crs(nproc + 1)
  1824. nlci_crs = nlcit_crs(nproc + 1)
  1825. nldi_crs = nldit_crs(nproc + 1)
  1826. nimpp_crs = nimppt_crs(nproc + 1)
  1827. ! No coarsening with zoom
  1828. IF( jpizoom /= 1 .OR. jpjzoom /= 1) STOP
  1829. DO ji = 1, jpi_crs
  1830. mig_crs(ji) = ji + nimpp_crs - 1
  1831. ENDDO
  1832. DO jj = 1, jpj_crs
  1833. mjg_crs(jj) = jj + njmpp_crs - 1!
  1834. ENDDO
  1835. DO ji = 1, jpiglo_crs
  1836. mi0_crs(ji) = MAX( 1, MIN( ji - nimpp_crs + 1 , jpi_crs + 1 ) )
  1837. mi1_crs(ji) = MAX( 0, MIN( ji - nimpp_crs + 1 , jpi_crs ) )
  1838. ENDDO
  1839. DO jj = 1, jpjglo_crs
  1840. mj0_crs(jj) = MAX( 1, MIN( jj - njmpp_crs + 1 , jpj_crs + 1 ) )
  1841. mj1_crs(jj) = MAX( 0, MIN( jj - njmpp_crs + 1 , jpj_crs ) )
  1842. ENDDO
  1843. ENDIF
  1844. ! Save the parent grid information
  1845. jpi_full = jpi
  1846. jpj_full = jpj
  1847. jpim1_full = jpim1
  1848. jpjm1_full = jpjm1
  1849. nperio_full = nperio
  1850. npolj_full = npolj
  1851. jpiglo_full = jpiglo
  1852. jpjglo_full = jpjglo
  1853. nlcj_full = nlcj
  1854. nlci_full = nlci
  1855. nldi_full = nldi
  1856. nldj_full = nldj
  1857. nlei_full = nlei
  1858. nlej_full = nlej
  1859. nimpp_full = nimpp
  1860. njmpp_full = njmpp
  1861. nlcit_full(:) = nlcit(:)
  1862. nldit_full(:) = nldit(:)
  1863. nleit_full(:) = nleit(:)
  1864. nimppt_full(:) = nimppt(:)
  1865. nlcjt_full(:) = nlcjt(:)
  1866. nldjt_full(:) = nldjt(:)
  1867. nlejt_full(:) = nlejt(:)
  1868. njmppt_full(:) = njmppt(:)
  1869. CALL dom_grid_crs !swich de grille
  1870. IF(lwp) THEN
  1871. WRITE(numout,*)
  1872. WRITE(numout,*) 'crs_init : coarse grid dimensions'
  1873. WRITE(numout,*) '~~~~~~~ coarse domain global j-dimension jpjglo = ', jpjglo
  1874. WRITE(numout,*) '~~~~~~~ coarse domain global i-dimension jpiglo = ', jpiglo
  1875. WRITE(numout,*) '~~~~~~~ coarse domain local i-dimension jpi = ', jpi
  1876. WRITE(numout,*) '~~~~~~~ coarse domain local j-dimension jpj = ', jpj
  1877. WRITE(numout,*)
  1878. WRITE(numout,*) ' nproc = ' , nproc
  1879. WRITE(numout,*) ' nlci = ' , nlci
  1880. WRITE(numout,*) ' nlcj = ' , nlcj
  1881. WRITE(numout,*) ' nldi = ' , nldi
  1882. WRITE(numout,*) ' nldj = ' , nldj
  1883. WRITE(numout,*) ' nlei = ' , nlei
  1884. WRITE(numout,*) ' nlej = ' , nlej
  1885. WRITE(numout,*) ' nlei_full=' , nlei_full
  1886. WRITE(numout,*) ' nldi_full=' , nldi_full
  1887. WRITE(numout,*) ' nimpp = ' , nimpp
  1888. WRITE(numout,*) ' njmpp = ' , njmpp
  1889. WRITE(numout,*) ' njmpp_full = ', njmpp_full
  1890. WRITE(numout,*)
  1891. ENDIF
  1892. CALL dom_grid_glo
  1893. mxbinctr = INT( nn_factx * 0.5 )
  1894. mybinctr = INT( nn_facty * 0.5 )
  1895. nrestx = MOD( nn_factx, 2 ) ! check if even- or odd- numbered reduction factor
  1896. nresty = MOD( nn_facty, 2 )
  1897. IF ( nrestx == 0 ) THEN
  1898. mxbinctr = mxbinctr - 1
  1899. ENDIF
  1900. IF ( nresty == 0 ) THEN
  1901. mybinctr = mybinctr - 1
  1902. IF ( jperio == 3 .OR. jperio == 4 ) nperio_crs = jperio + 2
  1903. IF ( jperio == 5 .OR. jperio == 6 ) nperio_crs = jperio - 2
  1904. IF ( npolj == 3 ) npolj_crs = 5
  1905. IF ( npolj == 5 ) npolj_crs = 3
  1906. ENDIF
  1907. rfactxy = nn_factx * nn_facty
  1908. ! 2.b. Set up bins for coarse grid, horizontal only.
  1909. ierr = crs_dom_alloc2()
  1910. mis2_crs(:) = 0 ; mie2_crs(:) = 0
  1911. mjs2_crs(:) = 0 ; mje2_crs(:) = 0
  1912. SELECT CASE ( nn_binref )
  1913. CASE ( 0 )
  1914. SELECT CASE ( nperio )
  1915. CASE ( 0, 1, 3, 4 ) ! 3, 4 : T-Pivot at North Fold
  1916. DO ji = 2, jpiglo_crsm1
  1917. ijie = ( ji * nn_factx ) - nn_factx !cc
  1918. ijis = ijie - nn_factx + 1
  1919. mis2_crs(ji) = ijis
  1920. mie2_crs(ji) = ijie
  1921. ENDDO
  1922. IF ( jpiglo - 1 - mie2_crs(jpiglo_crsm1) <= nn_factx ) mie2_crs(jpiglo_crsm1) = jpiglo - 2
  1923. ! Handle first the northernmost bin
  1924. IF ( nn_facty == 2 ) THEN ; ijjgloT = jpjglo - 1
  1925. ELSE ; ijjgloT = jpjglo
  1926. ENDIF
  1927. DO jj = 2, jpjglo_crs
  1928. ijje = ijjgloT - nn_facty * ( jj - 3 )
  1929. ijjs = ijje - nn_facty + 1
  1930. mjs2_crs(jpjglo_crs-jj+2) = ijjs
  1931. mje2_crs(jpjglo_crs-jj+2) = ijje
  1932. ENDDO
  1933. CASE ( 2 )
  1934. WRITE(numout,*) 'crs_init, jperio=2 not supported'
  1935. CASE ( 5, 6 ) ! F-pivot at North Fold
  1936. DO ji = 2, jpiglo_crsm1
  1937. ijie = ( ji * nn_factx ) - nn_factx
  1938. ijis = ijie - nn_factx + 1
  1939. mis2_crs(ji) = ijis
  1940. mie2_crs(ji) = ijie
  1941. ENDDO
  1942. IF ( jpiglo - 1 - mie2_crs(jpiglo_crsm1) <= nn_factx ) mie_crs(jpiglo_crsm1) = jpiglo - 2
  1943. ! Treat the northernmost bin separately.
  1944. jj = 2
  1945. ijje = jpj - nn_facty * ( jj - 2 )
  1946. IF ( nn_facty == 3 ) THEN ; ijjs = ijje - 1
  1947. ELSE ; ijjs = ijje - nn_facty + 1
  1948. ENDIF
  1949. mjs2_crs(jpj_crs-jj+1) = ijjs
  1950. mje2_crs(jpj_crs-jj+1) = ijje
  1951. ! Now bin the rest, any remainder at the south is lumped in the southern bin
  1952. DO jj = 3, jpjglo_crsm1
  1953. ijje = jpjglo - nn_facty * ( jj - 2 )
  1954. ijjs = ijje - nn_facty + 1
  1955. IF ( ijjs <= nn_facty ) ijjs = 2
  1956. mjs2_crs(jpj_crs-jj+1) = ijjs
  1957. mje2_crs(jpj_crs-jj+1) = ijje
  1958. ENDDO
  1959. CASE DEFAULT
  1960. WRITE(numout,*) 'crs_init. Only jperio = 0, 1, 3, 4, 5, 6 supported'
  1961. END SELECT
  1962. CASE (1 )
  1963. WRITE(numout,*) 'crs_init. Equator-centered bins option not yet available'
  1964. END SELECT
  1965. ! Pad the boundaries, do not know if it is necessary
  1966. mis2_crs(2) = 1 ; mis2_crs(jpiglo_crs) = mie2_crs(jpiglo_crs - 1) + 1
  1967. mie2_crs(2) = nn_factx ; mie2_crs(jpiglo_crs) = jpiglo
  1968. !
  1969. mjs2_crs(1) = 1
  1970. mje2_crs(1) = 1
  1971. !
  1972. mje2_crs(2) = mjs2_crs(3)-1 ; mje2_crs(jpjglo_crs) = jpjglo
  1973. mjs2_crs(2) = 1 ; mjs2_crs(jpjglo_crs) = mje2_crs(jpjglo_crs) - nn_facty + 1
  1974. IF( .NOT. lk_mpp ) THEN
  1975. mis_crs(:) = mis2_crs(:)
  1976. mie_crs(:) = mie2_crs(:)
  1977. mjs_crs(:) = mjs2_crs(:)
  1978. mje_crs(:) = mje2_crs(:)
  1979. ELSE
  1980. DO jj = 1, nlej_crs
  1981. mjs_crs(jj) = mjs2_crs(mjg_crs(jj)) - njmpp + 1
  1982. mje_crs(jj) = mje2_crs(mjg_crs(jj)) - njmpp + 1
  1983. ENDDO
  1984. DO ji = 1, nlei_crs
  1985. mis_crs(ji) = mis2_crs(mig_crs(ji)) - nimpp + 1
  1986. mie_crs(ji) = mie2_crs(mig_crs(ji)) - nimpp + 1
  1987. ENDDO
  1988. ENDIF
  1989. !
  1990. nistr = mis_crs(2) ; niend = mis_crs(nlci_crs - 1)
  1991. njstr = mjs_crs(3) ; njend = mjs_crs(nlcj_crs - 1)
  1992. !
  1993. END SUBROUTINE crs_dom_def
  1994. SUBROUTINE crs_dom_bat
  1995. !!----------------------------------------------------------------
  1996. !! *** SUBROUTINE crs_dom_bat ***
  1997. !! ** Purpose : coarsenig bathy
  1998. !!----------------------------------------------------------------
  1999. !!
  2000. !! local variables
  2001. INTEGER :: ji,jj,jk ! dummy indices
  2002. REAL(wp), DIMENSION(:,:) , POINTER :: zmbk
  2003. !!----------------------------------------------------------------
  2004. CALL wrk_alloc( jpi_crs, jpj_crs, zmbk )
  2005. mbathy_crs(:,:) = jpkm1
  2006. mbkt_crs(:,:) = 1
  2007. mbku_crs(:,:) = 1
  2008. mbkv_crs(:,:) = 1
  2009. DO jj = 1, jpj_crs
  2010. DO ji = 1, jpi_crs
  2011. jk = 0
  2012. DO WHILE( tmask_crs(ji,jj,jk+1) > 0.)
  2013. jk = jk + 1
  2014. ENDDO
  2015. mbathy_crs(ji,jj) = float( jk )
  2016. ENDDO
  2017. ENDDO
  2018. zmbk(:,:) = 0.0
  2019. zmbk(:,:) = REAL( mbathy_crs(:,:), wp ) ; CALL crs_lbc_lnk(zmbk,'T',1.0) ; mbathy_crs(:,:) = INT( zmbk(:,:) )
  2020. !
  2021. IF(lwp) WRITE(numout,*)
  2022. IF(lwp) WRITE(numout,*) ' crsini : mbkt is ocean bottom k-index of T-, U-, V- and W-levels '
  2023. IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~'
  2024. !
  2025. mbkt_crs(:,:) = MAX( mbathy_crs(:,:) , 1 ) ! bottom k-index of T-level (=1 over land)
  2026. ! ! bottom k-index of W-level = mbkt+1
  2027. DO jj = 1, jpj_crsm1 ! bottom k-index of u- (v-) level
  2028. DO ji = 1, jpi_crsm1
  2029. mbku_crs(ji,jj) = MIN( mbkt_crs(ji+1,jj ) , mbkt_crs(ji,jj) )
  2030. mbkv_crs(ji,jj) = MIN( mbkt_crs(ji ,jj+1) , mbkt_crs(ji,jj) )
  2031. END DO
  2032. END DO
  2033. ! convert into REAL to use lbc_lnk ; impose a min value of 1 as a zero can be set in lbclnk
  2034. zmbk(:,:) = 1.e0;
  2035. zmbk(:,:) = REAL( mbku_crs(:,:), wp ) ; CALL crs_lbc_lnk(zmbk,'U',1.0) ; mbku_crs (:,:) = MAX( INT( zmbk(:,:) ), 1 )
  2036. zmbk(:,:) = REAL( mbkv_crs(:,:), wp ) ; CALL crs_lbc_lnk(zmbk,'V',1.0) ; mbkv_crs (:,:) = MAX( INT( zmbk(:,:) ), 1 )
  2037. !
  2038. CALL wrk_dealloc( jpi_crs, jpj_crs, zmbk )
  2039. !
  2040. END SUBROUTINE crs_dom_bat
  2041. END MODULE crsdom