New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
sbccpl.F90 in branches/CMIP5_IPSL/NEMO/OPA_SRC/SBC – NEMO

source: branches/CMIP5_IPSL/NEMO/OPA_SRC/SBC/sbccpl.F90 @ 8506

Last change on this file since 8506 was 1854, checked in by mafoipsl, 14 years ago

Apply in CMIP5_IPSL branch #1833 to solve NP-folding bug on stress in coupled model, see ticket:660

  • Property svn:keywords set to Id
File size: 86.6 KB
RevLine 
[888]1MODULE sbccpl
2   !!======================================================================
3   !!                       ***  MODULE  sbccpl  ***
[1218]4   !! Surface Boundary Condition :  momentum, heat and freshwater fluxes in coupled mode
5   !!======================================================================
6   !! History :  2.0  !  06-2007  (R. Redler, N. Keenlyside, W. Park) Original code split into flxmod & taumod
7   !!            3.0  !  02-2008  (G. Madec, C Talandier)  surface module
[1558]8   !!            3.1  !  02-2009  (G. Madec, S. Masson, E. Maisonave, A. Caubel) generic coupled interface
[888]9   !!----------------------------------------------------------------------
[1218]10#if defined key_oasis3 || defined key_oasis4
[888]11   !!----------------------------------------------------------------------
[1218]12   !!   'key_oasis3' or 'key_oasis4'   Coupled Ocean/Atmosphere formulation
[888]13   !!----------------------------------------------------------------------
[1218]14   !!   namsbc_cpl      : coupled formulation namlist
15   !!   sbc_cpl_init    : initialisation of the coupled exchanges
16   !!   sbc_cpl_rcv     : receive fields from the atmosphere over the ocean (ocean only)
17   !!                     receive stress from the atmosphere over the ocean (ocean-ice case)
18   !!   sbc_cpl_ice_tau : receive stress from the atmosphere over ice
19   !!   sbc_cpl_ice_flx : receive fluxes from the atmosphere over ice
20   !!   sbc_cpl_snd     : send     fields to the atmosphere
[888]21   !!----------------------------------------------------------------------
22   USE dom_oce         ! ocean space and time domain
[1218]23   USE sbc_oce         ! Surface boundary condition: ocean fields
24   USE sbc_ice         ! Surface boundary condition: ice fields
25#if defined key_lim3
26   USE par_ice         ! ice parameters
27#endif
[1226]28#if defined key_lim2
[1534]29   USE par_ice_2       ! ice parameters
30   USE ice_2           ! ice variables
[1226]31#endif
[1698]32#if defined key_oasis3
[1218]33   USE cpl_oasis3      ! OASIS3 coupling
[1698]34#endif
35#if defined key_oasis4
36   USE cpl_oasis4      ! OASIS4 coupling
37#endif
[1218]38   USE geo2ocean       !
39   USE restart         !
40   USE oce   , ONLY : tn, un, vn
[1766]41   USE phycst, ONLY : rt0, rcp
[1218]42   USE albedo          !
[888]43   USE in_out_manager  ! I/O manager
[1218]44   USE iom             ! NetCDF library
[888]45   USE lib_mpp         ! distribued memory computing library
46   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
[1742]47   USE phycst, ONLY : xlsn, rhosn, xlic, rhoic
[1534]48#if defined key_cpl_carbon_cycle
49   USE p4zflx, ONLY : oce_co2
50#endif
[1756]51   USE diaar5, ONLY :   lk_diaar5
[1218]52   IMPLICIT NONE
53   PRIVATE
[888]54
[1218]55   PUBLIC   sbc_cpl_rcv       ! routine called by sbc_ice_lim(_2).F90
56   PUBLIC   sbc_cpl_snd       ! routine called by step.F90
57   PUBLIC   sbc_cpl_ice_tau   ! routine called by sbc_ice_lim(_2).F90
58   PUBLIC   sbc_cpl_ice_flx   ! routine called by sbc_ice_lim(_2).F90
59   
60   INTEGER, PARAMETER ::   jpr_otx1   =  1            ! 3 atmosphere-ocean stress components on grid 1
61   INTEGER, PARAMETER ::   jpr_oty1   =  2            !
62   INTEGER, PARAMETER ::   jpr_otz1   =  3            !
63   INTEGER, PARAMETER ::   jpr_otx2   =  4            ! 3 atmosphere-ocean stress components on grid 2
64   INTEGER, PARAMETER ::   jpr_oty2   =  5            !
65   INTEGER, PARAMETER ::   jpr_otz2   =  6            !
66   INTEGER, PARAMETER ::   jpr_itx1   =  7            ! 3 atmosphere-ice   stress components on grid 1
67   INTEGER, PARAMETER ::   jpr_ity1   =  8            !
68   INTEGER, PARAMETER ::   jpr_itz1   =  9            !
69   INTEGER, PARAMETER ::   jpr_itx2   = 10            ! 3 atmosphere-ice   stress components on grid 2
70   INTEGER, PARAMETER ::   jpr_ity2   = 11            !
71   INTEGER, PARAMETER ::   jpr_itz2   = 12            !
72   INTEGER, PARAMETER ::   jpr_qsroce = 13            ! Qsr above the ocean
73   INTEGER, PARAMETER ::   jpr_qsrice = 14            ! Qsr above the ice
[1226]74   INTEGER, PARAMETER ::   jpr_qsrmix = 15 
75   INTEGER, PARAMETER ::   jpr_qnsoce = 16            ! Qns above the ocean
76   INTEGER, PARAMETER ::   jpr_qnsice = 17            ! Qns above the ice
77   INTEGER, PARAMETER ::   jpr_qnsmix = 18
78   INTEGER, PARAMETER ::   jpr_rain   = 19            ! total liquid precipitation (rain)
79   INTEGER, PARAMETER ::   jpr_snow   = 20            ! solid precipitation over the ocean (snow)
80   INTEGER, PARAMETER ::   jpr_tevp   = 21            ! total evaporation
81   INTEGER, PARAMETER ::   jpr_ievp   = 22            ! solid evaporation (sublimation)
[1232]82   INTEGER, PARAMETER ::   jpr_sbpr   = 23            ! sublimation - liquid precipitation - solid precipitation
[1226]83   INTEGER, PARAMETER ::   jpr_semp   = 24            ! solid freshwater budget (sublimation - snow)
84   INTEGER, PARAMETER ::   jpr_oemp   = 25            ! ocean freshwater budget (evap - precip)
[1696]85   INTEGER, PARAMETER ::   jpr_w10m   = 26            ! 10m wind
86   INTEGER, PARAMETER ::   jpr_dqnsdt = 27            ! d(Q non solar)/d(temperature)
87   INTEGER, PARAMETER ::   jpr_rnf    = 28            ! runoffs
88   INTEGER, PARAMETER ::   jpr_cal    = 29            ! calving
89   INTEGER, PARAMETER ::   jpr_taum   = 30            ! wind stress module
[1534]90#if ! defined key_cpl_carbon_cycle
[1696]91   INTEGER, PARAMETER ::   jprcv      = 30            ! total number of fields received
[1534]92#else
[1696]93   INTEGER, PARAMETER ::   jpr_co2    = 31
94   INTEGER, PARAMETER ::   jprcv      = 31            ! total number of fields received
[1534]95#endif   
[1218]96   INTEGER, PARAMETER ::   jps_fice   =  1            ! ice fraction
97   INTEGER, PARAMETER ::   jps_toce   =  2            ! ocean temperature
98   INTEGER, PARAMETER ::   jps_tice   =  3            ! ice   temperature
99   INTEGER, PARAMETER ::   jps_tmix   =  4            ! mixed temperature (ocean+ice)
100   INTEGER, PARAMETER ::   jps_albice =  5            ! ice   albedo
101   INTEGER, PARAMETER ::   jps_albmix =  6            ! mixed albedo
102   INTEGER, PARAMETER ::   jps_hice   =  7            ! ice  thickness
103   INTEGER, PARAMETER ::   jps_hsnw   =  8            ! snow thickness
104   INTEGER, PARAMETER ::   jps_ocx1   =  9            ! ocean current on grid 1
105   INTEGER, PARAMETER ::   jps_ocy1   = 10            !
106   INTEGER, PARAMETER ::   jps_ocz1   = 11            !
107   INTEGER, PARAMETER ::   jps_ivx1   = 12            ! ice   current on grid 1
108   INTEGER, PARAMETER ::   jps_ivy1   = 13            !
109   INTEGER, PARAMETER ::   jps_ivz1   = 14            !
[1534]110#if ! defined key_cpl_carbon_cycle
[1218]111   INTEGER, PARAMETER ::   jpsnd      = 14            ! total number of fields sended
[1534]112#else
113   INTEGER, PARAMETER ::   jps_co2    = 15
114   INTEGER, PARAMETER ::   jpsnd      = 15            ! total number of fields sended
115#endif   
[1218]116   !                                                         !!** namelist namsbc_cpl **
117   ! Send to the atmosphere                                   !
118   CHARACTER(len=100) ::   cn_snd_temperature = 'oce only'    ! 'oce only' 'weighted oce and ice' or 'mixed oce-ice'
119   CHARACTER(len=100) ::   cn_snd_albedo      = 'none'        ! 'none' 'weighted ice' or 'mixed oce-ice'
120   CHARACTER(len=100) ::   cn_snd_thickness   = 'none'        ! 'none' or 'weighted ice and snow'
121   CHARACTER(len=100) ::   cn_snd_crt_nature  = 'none'        ! 'none' 'oce only' 'weighted oce and ice' or 'mixed oce-ice'   
122   CHARACTER(len=100) ::   cn_snd_crt_refere  = 'spherical'   ! 'spherical' or 'cartesian'
123   CHARACTER(len=100) ::   cn_snd_crt_orient  = 'local grid'  ! 'eastward-northward' or 'local grid'
124   CHARACTER(len=100) ::   cn_snd_crt_grid    = 'T'           ! always at 'T' point
[1534]125#if defined key_cpl_carbon_cycle 
126   CHARACTER(len=100) ::   cn_snd_co2         = 'none'        ! 'none' or 'coupled'
127#endif
[1696]128   ! Received from the atmosphere                             !
[1218]129   CHARACTER(len=100) ::   cn_rcv_tau_nature  = 'oce only'    ! 'oce only' 'oce and ice' or 'mixed oce-ice'
130   CHARACTER(len=100) ::   cn_rcv_tau_refere  = 'spherical'   ! 'spherical' or 'cartesian'
131   CHARACTER(len=100) ::   cn_rcv_tau_orient  = 'local grid'  ! 'eastward-northward' or 'local grid'
132   CHARACTER(len=100) ::   cn_rcv_tau_grid    = 'T'           ! 'T', 'U,V', 'U,V,I', 'T,I', or 'T,U,V'
133   CHARACTER(len=100) ::   cn_rcv_w10m        = 'none'        ! 'none' or 'coupled'
134   CHARACTER(len=100) ::   cn_rcv_dqnsdt      = 'none'        ! 'none' or 'coupled'
135   CHARACTER(len=100) ::   cn_rcv_qsr         = 'oce only'    ! 'oce only' 'conservative' 'oce and ice' or 'mixed oce-ice'
136   CHARACTER(len=100) ::   cn_rcv_qns         = 'oce only'    ! 'oce only' 'conservative' 'oce and ice' or 'mixed oce-ice'
[1232]137   CHARACTER(len=100) ::   cn_rcv_emp         = 'oce only'    ! 'oce only' 'conservative' or 'oce and ice'
[1218]138   CHARACTER(len=100) ::   cn_rcv_rnf         = 'coupled'     ! 'coupled' 'climato' or 'mixed'
139   CHARACTER(len=100) ::   cn_rcv_cal         = 'none'        ! 'none' or 'coupled'
[1696]140   CHARACTER(len=100) ::   cn_rcv_taumod      = 'none'        ! 'none' or 'coupled'
[1534]141#if defined key_cpl_carbon_cycle 
142   CHARACTER(len=100) ::   cn_rcv_co2         = 'none'        ! 'none' or 'coupled'
143#endif
[888]144
[1218]145!!   CHARACTER(len=100), PUBLIC ::   cn_rcv_rnf   !: ???             ==>>  !!gm   treat this case in a different maner
146   
147   CHARACTER(len=100), DIMENSION(4) ::   cn_snd_crt           ! array combining cn_snd_crt_*
148   CHARACTER(len=100), DIMENSION(4) ::   cn_rcv_tau           ! array combining cn_rcv_tau_*
[888]149
[1218]150   REAL(wp), DIMENSION(jpi,jpj)       ::   albedo_oce_mix     ! ocean albedo sent to atmosphere (mix clear/overcast sky)
[888]151
[1218]152   REAL(wp), DIMENSION(jpi,jpj,jprcv) ::   frcv               ! all fields recieved from the atmosphere
153   INTEGER , DIMENSION(        jprcv) ::   nrcvinfo           ! OASIS info argument
[888]154
[1218]155   !! Substitution
156#  include "vectopt_loop_substitute.h90"
157   !!----------------------------------------------------------------------
158   !! NEMO/OPA 3.0 , LOCEAN-IPSL (2008)
[1226]159   !! $Id$
[1218]160   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
161   !!----------------------------------------------------------------------
[888]162
[1218]163CONTAINS
164 
165   SUBROUTINE sbc_cpl_init( k_ice )     
166      !!----------------------------------------------------------------------
167      !!             ***  ROUTINE sbc_cpl_init  ***
168      !!
169      !! ** Purpose :   Initialisation of send and recieved information from
170      !!                the atmospheric component
171      !!
172      !! ** Method  : * Read namsbc_cpl namelist
173      !!              * define the receive interface
174      !!              * define the send    interface
175      !!              * initialise the OASIS coupler
176      !!----------------------------------------------------------------------
177      INTEGER, INTENT(in) ::   k_ice    ! ice management in the sbc (=0/1/2/3)
178      !!
179      INTEGER                      ::   jn           ! dummy loop index
180      REAL(wp), DIMENSION(jpi,jpj) ::   zacs, zaos   ! 2D workspace (clear & overcast sky albedos)
181      !!
182      NAMELIST/namsbc_cpl/  cn_snd_temperature, cn_snd_albedo    , cn_snd_thickness,                 &         
[1710]183         cn_snd_crt_nature, cn_snd_crt_refere , cn_snd_crt_orient, cn_snd_crt_grid ,                 &
184         cn_rcv_w10m      , cn_rcv_taumod     ,                                                      &
[1218]185         cn_rcv_tau_nature, cn_rcv_tau_refere , cn_rcv_tau_orient, cn_rcv_tau_grid ,                 &
186         cn_rcv_dqnsdt    , cn_rcv_qsr        , cn_rcv_qns       , cn_rcv_emp      , cn_rcv_rnf , cn_rcv_cal
[1534]187#if defined key_cpl_carbon_cycle 
188      NAMELIST/namsbc_cpl_co2/  cn_snd_co2, cn_rcv_co2
189#endif
[1218]190      !!---------------------------------------------------------------------
[888]191
[1218]192      ! ================================ !
193      !      Namelist informations       !
194      ! ================================ !
[888]195
[1218]196      REWIND( numnam )                    ! ... read namlist namsbc_cpl
197      READ  ( numnam, namsbc_cpl )
[888]198
[1218]199      IF(lwp) THEN                        ! control print
200         WRITE(numout,*)
201         WRITE(numout,*)'sbc_cpl_init : namsbc_cpl namelist '
202         WRITE(numout,*)'~~~~~~~~~~~~'
203         WRITE(numout,*)'   received fields'
204         WRITE(numout,*)'       10m wind module                    cn_rcv_w10m        = ', cn_rcv_w10m 
205         WRITE(numout,*)'       surface stress - nature            cn_rcv_tau_nature  = ', cn_rcv_tau_nature
206         WRITE(numout,*)'                      - referential       cn_rcv_tau_refere  = ', cn_rcv_tau_refere
207         WRITE(numout,*)'                      - orientation       cn_rcv_tau_orient  = ', cn_rcv_tau_orient
208         WRITE(numout,*)'                      - mesh              cn_rcv_tau_grid    = ', cn_rcv_tau_grid
209         WRITE(numout,*)'       non-solar heat flux sensitivity    cn_rcv_dqnsdt      = ', cn_rcv_dqnsdt
210         WRITE(numout,*)'       solar heat flux                    cn_rcv_qsr         = ', cn_rcv_qsr 
211         WRITE(numout,*)'       non-solar heat flux                cn_rcv_qns         = ', cn_rcv_qns
212         WRITE(numout,*)'       freshwater budget                  cn_rcv_emp         = ', cn_rcv_emp
213         WRITE(numout,*)'       runoffs                            cn_rcv_rnf         = ', cn_rcv_rnf
214         WRITE(numout,*)'       calving                            cn_rcv_cal         = ', cn_rcv_cal 
[1696]215         WRITE(numout,*)'       stress module                      cn_rcv_taumod      = ', cn_rcv_taumod
[1218]216         WRITE(numout,*)'   sent fields'
217         WRITE(numout,*)'       surface temperature                cn_snd_temperature = ', cn_snd_temperature
218         WRITE(numout,*)'       albedo                             cn_snd_albedo      = ', cn_snd_albedo
219         WRITE(numout,*)'       ice/snow thickness                 cn_snd_thickness   = ', cn_snd_thickness 
220         WRITE(numout,*)'       surface current - nature           cn_snd_crt_nature  = ', cn_snd_crt_nature 
221         WRITE(numout,*)'                       - referential      cn_snd_crt_refere  = ', cn_snd_crt_refere 
222         WRITE(numout,*)'                       - orientation      cn_snd_crt_orient  = ', cn_snd_crt_orient
223         WRITE(numout,*)'                       - mesh             cn_snd_crt_grid    = ', cn_snd_crt_grid 
224      ENDIF
[888]225
[1534]226#if defined key_cpl_carbon_cycle 
227      REWIND( numnam )                    ! ... read namlist namsbc_cpl_co2
228      READ  ( numnam, namsbc_cpl_co2 )
229      IF(lwp) THEN                        ! control print
230         WRITE(numout,*)
231         WRITE(numout,*)'sbc_cpl_init : namsbc_cpl_co2 namelist '
232         WRITE(numout,*)'~~~~~~~~~~~~'
233         WRITE(numout,*)'   received fields'
234         WRITE(numout,*)'       atm co2                            cn_rcv_co2         = ', cn_rcv_co2
235         WRITE(numout,*)'   sent fields'
236         WRITE(numout,*)'      oce co2 flux                        cn_snd_co2         = ', cn_snd_co2
237          WRITE(numout,*)
238      ENDIF
239#endif
[1218]240      ! save current & stress in an array and suppress possible blank in the name
241      cn_snd_crt(1) = TRIM( cn_snd_crt_nature )   ;   cn_snd_crt(2) = TRIM( cn_snd_crt_refere )
242      cn_snd_crt(3) = TRIM( cn_snd_crt_orient )   ;   cn_snd_crt(4) = TRIM( cn_snd_crt_grid   )
243      cn_rcv_tau(1) = TRIM( cn_rcv_tau_nature )   ;   cn_rcv_tau(2) = TRIM( cn_rcv_tau_refere )
244      cn_rcv_tau(3) = TRIM( cn_rcv_tau_orient )   ;   cn_rcv_tau(4) = TRIM( cn_rcv_tau_grid   )
245     
246      ! ================================ !
247      !   Define the receive interface   !
248      ! ================================ !
[1698]249      nrcvinfo(:) = OASIS_idle   ! needed by nrcvinfo(jpr_otx1) if we do not receive ocean stress
[888]250
[1218]251      ! for each field: define the OASIS name                              (srcv(:)%clname)
252      !                 define receive or not from the namelist parameters (srcv(:)%laction)
253      !                 define the north fold type of lbc                  (srcv(:)%nsgn)
[888]254
[1218]255      ! default definitions of srcv
256      srcv(:)%laction = .FALSE.   ;   srcv(:)%clgrid = 'T'   ;   srcv(:)%nsgn = 1
[888]257
[1218]258      !                                                      ! ------------------------- !
259      !                                                      ! ice and ocean wind stress !   
260      !                                                      ! ------------------------- !
261      !                                                           ! Name
262      srcv(jpr_otx1)%clname = 'O_OTaux1'      ! 1st ocean component on grid ONE (T or U)
263      srcv(jpr_oty1)%clname = 'O_OTauy1'      ! 2nd   -      -         -     -
264      srcv(jpr_otz1)%clname = 'O_OTauz1'      ! 3rd   -      -         -     -
265      srcv(jpr_otx2)%clname = 'O_OTaux2'      ! 1st ocean component on grid TWO (V)
266      srcv(jpr_oty2)%clname = 'O_OTauy2'      ! 2nd   -      -         -     -
267      srcv(jpr_otz2)%clname = 'O_OTauz2'      ! 3rd   -      -         -     -
268      !
269      srcv(jpr_itx1)%clname = 'O_ITaux1'      ! 1st  ice  component on grid ONE (T, F, I or U)
270      srcv(jpr_ity1)%clname = 'O_ITauy1'      ! 2nd   -      -         -     -
271      srcv(jpr_itz1)%clname = 'O_ITauz1'      ! 3rd   -      -         -     -
272      srcv(jpr_itx2)%clname = 'O_ITaux2'      ! 1st  ice  component on grid TWO (V)
273      srcv(jpr_ity2)%clname = 'O_ITauy2'      ! 2nd   -      -         -     -
274      srcv(jpr_itz2)%clname = 'O_ITauz2'      ! 3rd   -      -         -     -
275      !
[1854]276      ! Vectors: change of sign at north fold ONLY if on the local grid
277      IF( TRIM( cn_rcv_tau(3) ) == 'local grid' )   srcv(jpr_otx1:jpr_itz2)%nsgn = -1. 
[1218]278     
279      !                                                           ! Set grid and action
280      SELECT CASE( TRIM( cn_rcv_tau(4) ) )      !  'T', 'U,V', 'U,V,I', 'U,V,F', 'T,I', 'T,F', or 'T,U,V'
281      CASE( 'T' ) 
282         srcv(jpr_otx1:jpr_itz2)%clgrid  = 'T'        ! oce and ice components given at T-point
283         srcv(jpr_otx1:jpr_otz1)%laction = .TRUE.     ! receive oce components on grid 1
284         srcv(jpr_itx1:jpr_itz1)%laction = .TRUE.     ! receive ice components on grid 1
285      CASE( 'U,V' ) 
286         srcv(jpr_otx1:jpr_otz1)%clgrid  = 'U'        ! oce components given at U-point
287         srcv(jpr_otx2:jpr_otz2)%clgrid  = 'V'        !           and           V-point
288         srcv(jpr_itx1:jpr_itz1)%clgrid  = 'U'        ! ice components given at U-point
289         srcv(jpr_itx2:jpr_itz2)%clgrid  = 'V'        !           and           V-point
290         srcv(jpr_otx1:jpr_itz2)%laction = .TRUE.     ! receive oce and ice components on both grid 1 & 2
291      CASE( 'U,V,T' )
292         srcv(jpr_otx1:jpr_otz1)%clgrid  = 'U'        ! oce components given at U-point
293         srcv(jpr_otx2:jpr_otz2)%clgrid  = 'V'        !           and           V-point
294         srcv(jpr_itx1:jpr_itz1)%clgrid  = 'T'        ! ice components given at T-point
295         srcv(jpr_otx1:jpr_otz2)%laction = .TRUE.     ! receive oce components on grid 1 & 2
296         srcv(jpr_itx1:jpr_itz1)%laction = .TRUE.     ! receive ice components on grid 1 only
297      CASE( 'U,V,I' )
298         srcv(jpr_otx1:jpr_otz1)%clgrid  = 'U'        ! oce components given at U-point
299         srcv(jpr_otx2:jpr_otz2)%clgrid  = 'V'        !           and           V-point
300         srcv(jpr_itx1:jpr_itz1)%clgrid  = 'I'        ! ice components given at I-point
301         srcv(jpr_otx1:jpr_otz2)%laction = .TRUE.     ! receive oce components on grid 1 & 2
302         srcv(jpr_itx1:jpr_itz1)%laction = .TRUE.     ! receive ice components on grid 1 only
303      CASE( 'U,V,F' )
304         srcv(jpr_otx1:jpr_otz1)%clgrid  = 'U'        ! oce components given at U-point
305         srcv(jpr_otx2:jpr_otz2)%clgrid  = 'V'        !           and           V-point
306         srcv(jpr_itx1:jpr_itz1)%clgrid  = 'F'        ! ice components given at F-point
307         srcv(jpr_otx1:jpr_otz2)%laction = .TRUE.     ! receive oce components on grid 1 & 2
308         srcv(jpr_itx1:jpr_itz1)%laction = .TRUE.     ! receive ice components on grid 1 only
309      CASE( 'T,I' ) 
310         srcv(jpr_otx1:jpr_itz2)%clgrid  = 'T'        ! oce and ice components given at T-point
311         srcv(jpr_itx1:jpr_itz1)%clgrid  = 'I'        ! ice components given at I-point
312         srcv(jpr_otx1:jpr_otz1)%laction = .TRUE.     ! receive oce components on grid 1
313         srcv(jpr_itx1:jpr_itz1)%laction = .TRUE.     ! receive ice components on grid 1
314      CASE( 'T,F' ) 
315         srcv(jpr_otx1:jpr_itz2)%clgrid  = 'T'        ! oce and ice components given at T-point
316         srcv(jpr_itx1:jpr_itz1)%clgrid  = 'F'        ! ice components given at F-point
317         srcv(jpr_otx1:jpr_otz1)%laction = .TRUE.     ! receive oce components on grid 1
318         srcv(jpr_itx1:jpr_itz1)%laction = .TRUE.     ! receive ice components on grid 1
319      CASE( 'T,U,V' )
320         srcv(jpr_otx1:jpr_otz1)%clgrid  = 'T'        ! oce components given at T-point
321         srcv(jpr_itx1:jpr_itz1)%clgrid  = 'U'        ! ice components given at U-point
322         srcv(jpr_itx2:jpr_itz2)%clgrid  = 'V'        !           and           V-point
323         srcv(jpr_otx1:jpr_otz1)%laction = .TRUE.     ! receive oce components on grid 1 only
324         srcv(jpr_itx1:jpr_itz2)%laction = .TRUE.     ! receive ice components on grid 1 & 2
325      CASE default   
326         CALL ctl_stop( 'sbc_cpl_init: wrong definition of cn_rcv_tau(4)' )
327      END SELECT
328      !
329      IF( TRIM( cn_rcv_tau(2) ) == 'spherical' )   &           ! spherical: 3rd component not received
330         &     srcv( (/jpr_otz1, jpr_otz2, jpr_itz1, jpr_itz2/) )%laction = .FALSE. 
331      !
332      IF( TRIM( cn_rcv_tau(1) ) /= 'oce and ice' ) THEN        ! 'oce and ice' case ocean stress on ocean mesh used
333         srcv(jpr_itx1:jpr_itz2)%laction = .FALSE.    ! ice components not received
334         srcv(jpr_itx1)%clgrid = 'U'                  ! ocean stress used after its transformation
335         srcv(jpr_ity1)%clgrid = 'V'                  ! i.e. it is always at U- & V-points for i- & j-comp. resp.
336      ENDIF
337       
338      !                                                      ! ------------------------- !
339      !                                                      !    freshwater budget      !   E-P
340      !                                                      ! ------------------------- !
341      ! we suppose that atmosphere modele do not make the difference between precipiration (liquide or solid)
342      ! over ice of free ocean within the same atmospheric cell.cd
343      srcv(jpr_rain)%clname = 'OTotRain'      ! Rain = liquid precipitation
344      srcv(jpr_snow)%clname = 'OTotSnow'      ! Snow = solid precipitation
345      srcv(jpr_tevp)%clname = 'OTotEvap'      ! total evaporation (over oce + ice sublimation)
346      srcv(jpr_ievp)%clname = 'OIceEvap'      ! evaporation over ice = sublimation
[1232]347      srcv(jpr_sbpr)%clname = 'OSubMPre'      ! sublimation - liquid precipitation - solid precipitation
348      srcv(jpr_semp)%clname = 'OISubMSn'      ! ice solid water budget = sublimation - solid precipitation
349      srcv(jpr_oemp)%clname = 'OOEvaMPr'      ! ocean water budget = ocean Evap - ocean precip
[1218]350      SELECT CASE( TRIM( cn_rcv_emp ) )
351      CASE( 'oce only'      )   ;   srcv(                                 jpr_oemp   )%laction = .TRUE. 
352      CASE( 'conservative'  )   ;   srcv( (/jpr_rain, jpr_snow, jpr_ievp, jpr_tevp/) )%laction = .TRUE.
[1232]353      CASE( 'oce and ice'   )   ;   srcv( (/jpr_ievp, jpr_sbpr, jpr_semp, jpr_oemp/) )%laction = .TRUE.
[1218]354      CASE default              ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of cn_rcv_emp' )
355      END SELECT
[888]356
[1218]357      !                                                      ! ------------------------- !
358      !                                                      !     Runoffs & Calving     !   
359      !                                                      ! ------------------------- !
360      srcv(jpr_rnf   )%clname = 'O_Runoff'   ;   IF( TRIM( cn_rcv_rnf ) == 'coupled' )   srcv(jpr_rnf)%laction = .TRUE.
361                                                 IF( TRIM( cn_rcv_rnf ) == 'climato' )   THEN   ;   ln_rnf = .TRUE.
362                                                 ELSE                                           ;   ln_rnf = .FALSE.
363                                                 ENDIF
364      srcv(jpr_cal   )%clname = 'OCalving'   ;   IF( TRIM( cn_rcv_cal ) == 'coupled' )   srcv(jpr_cal)%laction = .TRUE.
[888]365
[1218]366      !                                                      ! ------------------------- !
367      !                                                      !    non solar radiation    !   Qns
368      !                                                      ! ------------------------- !
369      srcv(jpr_qnsoce)%clname = 'O_QnsOce'
370      srcv(jpr_qnsice)%clname = 'O_QnsIce'
371      srcv(jpr_qnsmix)%clname = 'O_QnsMix'
372      SELECT CASE( TRIM( cn_rcv_qns ) )
373      CASE( 'oce only'      )   ;   srcv(               jpr_qnsoce   )%laction = .TRUE.
374      CASE( 'conservative'  )   ;   srcv( (/jpr_qnsice, jpr_qnsmix/) )%laction = .TRUE.
375      CASE( 'oce and ice'   )   ;   srcv( (/jpr_qnsice, jpr_qnsoce/) )%laction = .TRUE.
376      CASE( 'mixed oce-ice' )   ;   srcv(               jpr_qnsmix   )%laction = .TRUE. 
377      CASE default              ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of cn_rcv_qns' )
378      END SELECT
[888]379
[1218]380      !                                                      ! ------------------------- !
381      !                                                      !    solar radiation        !   Qsr
382      !                                                      ! ------------------------- !
383      srcv(jpr_qsroce)%clname = 'O_QsrOce'
384      srcv(jpr_qsrice)%clname = 'O_QsrIce'
385      srcv(jpr_qsrmix)%clname = 'O_QsrMix'
386      SELECT CASE( TRIM( cn_rcv_qsr ) )
387      CASE( 'oce only'      )   ;   srcv(               jpr_qsroce   )%laction = .TRUE.
388      CASE( 'conservative'  )   ;   srcv( (/jpr_qsrice, jpr_qsrmix/) )%laction = .TRUE.
389      CASE( 'oce and ice'   )   ;   srcv( (/jpr_qsrice, jpr_qsroce/) )%laction = .TRUE.
390      CASE( 'mixed oce-ice' )   ;   srcv(               jpr_qsrmix   )%laction = .TRUE. 
391      CASE default              ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of cn_rcv_qsr' )
392      END SELECT
393
394      !                                                      ! ------------------------- !
395      !                                                      !   non solar sensitivity   !   d(Qns)/d(T)
396      !                                                      ! ------------------------- !
397      srcv(jpr_dqnsdt)%clname = 'O_dQnsdT'   
398      IF( TRIM( cn_rcv_dqnsdt ) == 'coupled' )   srcv(jpr_dqnsdt)%laction = .TRUE.
[1232]399      !
400      ! non solar sensitivity mandatory for ice model
[1308]401      IF( TRIM( cn_rcv_dqnsdt ) == 'none' .AND. k_ice /= 0 ) &
402         CALL ctl_stop( 'sbc_cpl_init: cn_rcv_dqnsdt must be coupled in namsbc_cpl namelist' )
[1232]403      ! non solar sensitivity mandatory for mixed oce-ice solar radiation coupling technique
[1308]404      IF( TRIM( cn_rcv_dqnsdt ) == 'none' .AND. TRIM( cn_rcv_qns ) == 'mixed oce-ice' ) &
405         CALL ctl_stop( 'sbc_cpl_init: namsbc_cpl namelist mismatch between cn_rcv_qns and cn_rcv_dqnsdt' )
[1218]406      !                                                      ! ------------------------- !
407      !                                                      !    Ice Qsr penetration    !   
408      !                                                      ! ------------------------- !
409      ! fraction of net shortwave radiation which is not absorbed in the thin surface layer
410      ! and penetrates inside the ice cover ( Maykut and Untersteiner, 1971 ; Elbert anbd Curry, 1993 )
411      ! Coupled case: since cloud cover is not received from atmosphere
412      !               ===> defined as constant value -> definition done in sbc_cpl_init
413      fr1_i0(:,:) = 0.18
414      fr2_i0(:,:) = 0.82
415      !                                                      ! ------------------------- !
416      !                                                      !      10m wind module      !   
417      !                                                      ! ------------------------- !
[1696]418      srcv(jpr_w10m)%clname = 'O_Wind10'   ;   IF( TRIM(cn_rcv_w10m  ) == 'coupled' )   srcv(jpr_w10m)%laction = .TRUE. 
419      !
420      !                                                      ! ------------------------- !
421      !                                                      !   wind stress module      !   
422      !                                                      ! ------------------------- !
423      srcv(jpr_taum)%clname = 'O_TauMod'   ;   IF( TRIM(cn_rcv_taumod) == 'coupled' )   srcv(jpr_taum)%laction = .TRUE.
[1705]424      lhftau = srcv(jpr_taum)%laction
[1534]425
426#if defined key_cpl_carbon_cycle
427      !                                                      ! ------------------------- !
428      !                                                      !      Atmospheric CO2      !
429      !                                                      ! ------------------------- !
[1696]430      srcv(jpr_co2 )%clname = 'O_AtmCO2'   ;   IF( TRIM(cn_rcv_co2   ) == 'coupled' )    srcv(jpr_co2 )%laction = .TRUE.
[1534]431#endif
[1218]432     
433      ! ================================ !
434      !     Define the send interface    !
435      ! ================================ !
436      ! for each field: define the OASIS name                           (srcv(:)%clname)
437      !                 define send or not from the namelist parameters (srcv(:)%laction)
438      !                 define the north fold type of lbc               (srcv(:)%nsgn)
439     
440      ! default definitions of nsnd
441      ssnd(:)%laction = .FALSE.   ;   ssnd(:)%clgrid = 'T'   ;   ssnd(:)%nsgn = 1
442         
443      !                                                      ! ------------------------- !
444      !                                                      !    Surface temperature    !
445      !                                                      ! ------------------------- !
446      ssnd(jps_toce)%clname = 'O_SSTSST'
447      ssnd(jps_tice)%clname = 'O_TepIce'
448      ssnd(jps_tmix)%clname = 'O_TepMix'
449      SELECT CASE( TRIM( cn_snd_temperature ) )
450      CASE( 'oce only'             )   ;   ssnd(   jps_toce             )%laction = .TRUE.
451      CASE( 'weighted oce and ice' )   ;   ssnd( (/jps_toce, jps_tice/) )%laction = .TRUE.
452      CASE( 'mixed oce-ice'        )   ;   ssnd(   jps_tmix             )%laction = .TRUE.
[1308]453      CASE default   ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of cn_snd_temperature' )
[1218]454      END SELECT
455     
456      !                                                      ! ------------------------- !
457      !                                                      !          Albedo           !
458      !                                                      ! ------------------------- !
459      ssnd(jps_albice)%clname = 'O_AlbIce' 
460      ssnd(jps_albmix)%clname = 'O_AlbMix'
461      SELECT CASE( TRIM( cn_snd_albedo ) )
462      CASE( 'none'          )       ! nothing to do
463      CASE( 'weighted ice'  )   ;   ssnd(jps_albice)%laction = .TRUE.
464      CASE( 'mixed oce-ice' )   ;   ssnd(jps_albmix)%laction = .TRUE.
[1308]465      CASE default   ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of cn_snd_albedo' )
[1218]466      END SELECT
[1232]467      !
468      ! Need to calculate oceanic albedo if
469      !     1. sending mixed oce-ice albedo or
470      !     2. receiving mixed oce-ice solar radiation
471      IF ( TRIM ( cn_snd_albedo ) == 'mixed oce-ice' .OR. TRIM ( cn_rcv_qsr ) == 'mixed oce-ice' ) THEN
[1308]472         CALL albedo_oce( zaos, zacs )
473         ! Due to lack of information on nebulosity : mean clear/overcast sky
474         albedo_oce_mix(:,:) = ( zacs(:,:) + zaos(:,:) ) * 0.5
[1232]475      ENDIF
476
[1218]477      !                                                      ! ------------------------- !
478      !                                                      !  Ice fraction & Thickness !
479      !                                                      ! ------------------------- !
480      ssnd(jps_fice)%clname = 'OIceFrac'   
481      ssnd(jps_hice)%clname = 'O_IceTck'
482      ssnd(jps_hsnw)%clname = 'O_SnwTck'
483      IF( k_ice /= 0 )   ssnd(jps_fice)%laction = .TRUE.       ! if ice treated in the ocean (even in climato case)
484      IF( TRIM( cn_snd_thickness ) == 'weighted ice and snow' )   ssnd( (/jps_hice, jps_hsnw/) )%laction = .TRUE.
485         
486      !                                                      ! ------------------------- !
487      !                                                      !      Surface current      !
488      !                                                      ! ------------------------- !
489      !        ocean currents              !            ice velocities
490      ssnd(jps_ocx1)%clname = 'O_OCurx1'   ;   ssnd(jps_ivx1)%clname = 'O_IVelx1'
491      ssnd(jps_ocy1)%clname = 'O_OCury1'   ;   ssnd(jps_ivy1)%clname = 'O_IVely1'
492      ssnd(jps_ocz1)%clname = 'O_OCurz1'   ;   ssnd(jps_ivz1)%clname = 'O_IVelz1'
493      !
[1226]494      ssnd(jps_ocx1:jps_ivz1)%nsgn = -1    ! vectors: change of the sign at the north fold
[1218]495
496      IF( cn_snd_crt(4) /= 'T' )   CALL ctl_stop( 'cn_snd_crt(4) must be equal to T' )
[1226]497      ssnd(jps_ocx1:jps_ivz1)%clgrid  = 'T'      ! all oce and ice components on the same unique grid
[1218]498
[1226]499      ssnd(jps_ocx1:jps_ivz1)%laction = .TRUE.   ! default: all are send
500      IF( TRIM( cn_snd_crt(2) ) == 'spherical' )   ssnd( (/jps_ocz1, jps_ivz1/) )%laction = .FALSE. 
[1218]501      SELECT CASE( TRIM( cn_snd_crt(1) ) )
[1226]502      CASE( 'none'                 )   ;   ssnd(jps_ocx1:jps_ivz1)%laction = .FALSE.
503      CASE( 'oce only'             )   ;   ssnd(jps_ivx1:jps_ivz1)%laction = .FALSE.
[1218]504      CASE( 'weighted oce and ice' )   !   nothing to do
[1226]505      CASE( 'mixed oce-ice'        )   ;   ssnd(jps_ivx1:jps_ivz1)%laction = .FALSE.
[1308]506      CASE default   ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of cn_snd_crt(1)' )
[1218]507      END SELECT
508
[1534]509#if defined key_cpl_carbon_cycle
510      !                                                      ! ------------------------- !
511      !                                                      !          CO2 flux         !
512      !                                                      ! ------------------------- !
513      ssnd(jps_co2)%clname = 'O_CO2FLX' ;  IF( TRIM(cn_snd_co2) == 'coupled' )    ssnd(jps_co2 )%laction = .TRUE.
514#endif
515      !
[1218]516      ! ================================ !
517      !   initialisation of the coupler  !
518      ! ================================ !
[1226]519
520      CALL cpl_prism_define(jprcv, jpsnd)           
[1218]521      !
522   END SUBROUTINE sbc_cpl_init
523
524
525   SUBROUTINE sbc_cpl_rcv( kt, k_fsbc, k_ice )     
526      !!----------------------------------------------------------------------
527      !!             ***  ROUTINE sbc_cpl_rcv  ***
[888]528      !!
[1218]529      !! ** Purpose :   provide the stress over the ocean and, if no sea-ice,
530      !!                provide the ocean heat and freshwater fluxes.
[888]531      !!
[1218]532      !! ** Method  : - Receive all the atmospheric fields (stored in frcv array). called at each time step.
533      !!                OASIS controls if there is something do receive or not. nrcvinfo contains the info
534      !!                to know if the field was really received or not
[888]535      !!
[1218]536      !!              --> If ocean stress was really received:
[888]537      !!
[1218]538      !!                  - transform the received ocean stress vector from the received
539      !!                 referential and grid into an atmosphere-ocean stress in
540      !!                 the (i,j) ocean referencial and at the ocean velocity point.
541      !!                    The received stress are :
542      !!                     - defined by 3 components (if cartesian coordinate)
543      !!                            or by 2 components (if spherical)
544      !!                     - oriented along geographical   coordinate (if eastward-northward)
545      !!                            or  along the local grid coordinate (if local grid)
546      !!                     - given at U- and V-point, resp.   if received on 2 grids
547      !!                            or at T-point               if received on 1 grid
548      !!                    Therefore and if necessary, they are successively
549      !!                  processed in order to obtain them
550      !!                     first  as  2 components on the sphere
551      !!                     second as  2 components oriented along the local grid
552      !!                     third  as  2 components on the U,V grid
[888]553      !!
[1218]554      !!              -->
[888]555      !!
[1218]556      !!              - In 'ocean only' case, non solar and solar ocean heat fluxes
557      !!             and total ocean freshwater fluxes 
558      !!
559      !! ** Method  :   receive all fields from the atmosphere and transform
560      !!              them into ocean surface boundary condition fields
561      !!
562      !! ** Action  :   update  utau, vtau   ocean stress at U,V grid
[1695]563      !!                        taum, wndm   wind stres and wind speed module at T-point
[1218]564      !!                        qns , qsr    non solar and solar ocean heat fluxes   ('ocean only case)
565      !!                        emp = emps   evap. - precip. (- runoffs) (- calving) ('ocean only case)
[888]566      !!----------------------------------------------------------------------
[1218]567      INTEGER, INTENT(in) ::   kt       ! ocean model time step index
568      INTEGER, INTENT(in) ::   k_fsbc   ! frequency of sbc (-> ice model) computation
569      INTEGER, INTENT(in) ::   k_ice    ! ice management in the sbc (=0/1/2/3)
[888]570      !!
[1696]571      LOGICAL ::    llnewtx, llnewtau      ! update wind stress components and module??
[1218]572      INTEGER  ::   ji, jj, jn             ! dummy loop indices
573      INTEGER  ::   isec                   ! number of seconds since nit000 (assuming rdttra did not change since nit000)
574      REAL(wp) ::   zcumulneg, zcumulpos   ! temporary scalars     
[1226]575      REAL(wp) ::   zcoef                  ! temporary scalar
[1695]576      REAL(wp) ::   zrhoa  = 1.22          ! Air density kg/m3
577      REAL(wp) ::   zcdrag = 1.5e-3        ! drag coefficient
578      REAL(wp) ::   zzx, zzy               ! temporary variables
[1226]579      REAL(wp), DIMENSION(jpi,jpj) ::   ztx, zty   ! 2D workspace
[1218]580      !!----------------------------------------------------------------------
[888]581
[1218]582      IF( kt == nit000 )   CALL sbc_cpl_init( k_ice )          ! initialisation
[888]583
[1218]584      !                                                 ! Receive all the atmos. fields (including ice information)
585      isec = ( kt - nit000 ) * NINT( rdttra(1) )             ! date of exchanges
586      DO jn = 1, jprcv                                       ! received fields sent by the atmosphere
587         IF( srcv(jn)%laction )   CALL cpl_prism_rcv( jn, isec, frcv(:,:,jn), nrcvinfo(jn) )
588      END DO
[888]589
[1218]590      !                                                      ! ========================= !
[1696]591      IF( srcv(jpr_otx1)%laction ) THEN                      !  ocean stress components  !
[1218]592         !                                                   ! ========================= !
593         ! define frcv(:,:,jpr_otx1) and frcv(:,:,jpr_oty1): stress at U/V point along model grid
594         ! => need to be done only when we receive the field
[1698]595         IF(  nrcvinfo(jpr_otx1) == OASIS_Rcv ) THEN
[1218]596            !
597            IF( TRIM( cn_rcv_tau(2) ) == 'cartesian' ) THEN            ! 2 components on the sphere
598               !                                                       ! (cartesian to spherical -> 3 to 2 components)
599               !
600               CALL geo2oce( frcv(:,:,jpr_otx1), frcv(:,:,jpr_oty1), frcv(:,:,jpr_otz1),   &
601                  &          srcv(jpr_otx1)%clgrid, ztx, zty )
602               frcv(:,:,jpr_otx1) = ztx(:,:)   ! overwrite 1st comp. on the 1st grid
603               frcv(:,:,jpr_oty1) = zty(:,:)   ! overwrite 2nd comp. on the 1st grid
604               !
605               IF( srcv(jpr_otx2)%laction ) THEN
606                  CALL geo2oce( frcv(:,:,jpr_otx2), frcv(:,:,jpr_oty2), frcv(:,:,jpr_otz2),   &
607                     &          srcv(jpr_otx2)%clgrid, ztx, zty )
608                  frcv(:,:,jpr_otx2) = ztx(:,:)   ! overwrite 1st comp. on the 2nd grid
609                  frcv(:,:,jpr_oty2) = zty(:,:)   ! overwrite 2nd comp. on the 2nd grid
610               ENDIF
611               !
612            ENDIF
613            !
614            IF( TRIM( cn_rcv_tau(3) ) == 'eastward-northward' ) THEN   ! 2 components oriented along the local grid
615               !                                                       ! (geographical to local grid -> rotate the components)
616               CALL rot_rep( frcv(:,:,jpr_otx1), frcv(:,:,jpr_oty1), srcv(jpr_otx1)%clgrid, 'en->i', ztx )   
617               frcv(:,:,jpr_otx1) = ztx(:,:)      ! overwrite 1st component on the 1st grid
618               IF( srcv(jpr_otx2)%laction ) THEN
619                  CALL rot_rep( frcv(:,:,jpr_otx2), frcv(:,:,jpr_oty2), srcv(jpr_otx2)%clgrid, 'en->j', zty )   
620               ELSE
621                  CALL rot_rep( frcv(:,:,jpr_otx1), frcv(:,:,jpr_oty1), srcv(jpr_otx1)%clgrid, 'en->j', zty ) 
622               ENDIF
623               frcv(:,:,jpr_oty1) = zty(:,:)      ! overwrite 2nd component on the 2nd grid
624            ENDIF
625            !                             
626            IF( srcv(jpr_otx1)%clgrid == 'T' ) THEN
627               DO jj = 2, jpjm1                                          ! T ==> (U,V)
628                  DO ji = fs_2, fs_jpim1   ! vector opt.
629                     frcv(ji,jj,jpr_otx1) = 0.5 * ( frcv(ji+1,jj  ,jpr_otx1) + frcv(ji,jj,jpr_otx1) )
630                     frcv(ji,jj,jpr_oty1) = 0.5 * ( frcv(ji  ,jj+1,jpr_oty1) + frcv(ji,jj,jpr_oty1) )
631                  END DO
632               END DO
633               CALL lbc_lnk( frcv(:,:,jpr_otx1), 'U',  -1. )   ;   CALL lbc_lnk( frcv(:,:,jpr_oty1), 'V',  -1. )
634            ENDIF
[1696]635            llnewtx = .TRUE.
636         ELSE
637            llnewtx = .FALSE.
[1218]638         ENDIF
639         !                                                   ! ========================= !
640      ELSE                                                   !   No dynamical coupling   !
641         !                                                   ! ========================= !
642         frcv(:,:,jpr_otx1) = 0.e0                               ! here simply set to zero
643         frcv(:,:,jpr_oty1) = 0.e0                               ! an external read in a file can be added instead
[1696]644         llnewtx = .TRUE.
[1218]645         !
646      ENDIF
647     
[1696]648      !                                                      ! ========================= !
649      !                                                      !    wind stress module     !   (taum)
650      !                                                      ! ========================= !
651      !
652      IF( .NOT. srcv(jpr_taum)%laction ) THEN                    ! compute wind stress module from its components if not received
653         ! => need to be done only when otx1 was changed
654         IF( llnewtx ) THEN
[1695]655!CDIR NOVERRCHK
[1696]656            DO jj = 2, jpjm1
[1695]657!CDIR NOVERRCHK
[1696]658               DO ji = fs_2, fs_jpim1   ! vect. opt.
659                  zzx = frcv(ji-1,jj  ,jpr_otx1) + frcv(ji,jj,jpr_otx1) 
660                  zzy = frcv(ji  ,jj-1,jpr_oty1) + frcv(ji,jj,jpr_oty1) 
661                  frcv(ji,jj,jpr_taum) = 0.5 * SQRT( zzx * zzx + zzy * zzy )
662               END DO
[1695]663            END DO
[1696]664            CALL lbc_lnk( frcv(:,:,jpr_taum), 'T', 1. )
665            llnewtau = .TRUE.
666         ELSE
667            llnewtau = .FALSE.
668         ENDIF
669      ELSE
[1706]670         llnewtau = nrcvinfo(jpr_taum) == OASIS_Rcv
[1726]671         ! Stress module can be negative when received (interpolation problem)
672         IF( llnewtau ) THEN
673            DO jj = 1, jpj
674               DO ji = 1, jpi 
675                  frcv(ji,jj,jpr_taum) = MAX( 0.0e0, frcv(ji,jj,jpr_taum) )
676               END DO
677            END DO
678         ENDIF
[1696]679      ENDIF
680     
681      !                                                      ! ========================= !
682      !                                                      !      10 m wind speed      !   (wndm)
683      !                                                      ! ========================= !
684      !
685      IF( .NOT. srcv(jpr_w10m)%laction ) THEN                    ! compute wind spreed from wind stress module if not received 
686         ! => need to be done only when taumod was changed
687         IF( llnewtau ) THEN
[1695]688            zcoef = 1. / ( zrhoa * zcdrag ) 
[1697]689!CDIR NOVERRCHK
[1695]690            DO jj = 1, jpj
[1697]691!CDIR NOVERRCHK
[1695]692               DO ji = 1, jpi 
[1696]693                  frcv(ji,jj,jpr_w10m) = SQRT( frcv(ji,jj,jpr_taum) * zcoef )
[1695]694               END DO
695            END DO
696         ENDIF
[1696]697      ENDIF
698
699      ! u(v)tau and taum will be modified by ice model (wndm will be changed by PISCES)
700      ! -> need to be reset before each call of the ice/fsbc     
701      IF( MOD( kt-1, k_fsbc ) == 0 ) THEN
702         !
703         utau(:,:) = frcv(:,:,jpr_otx1)                   
704         vtau(:,:) = frcv(:,:,jpr_oty1)
705         taum(:,:) = frcv(:,:,jpr_taum)
706         wndm(:,:) = frcv(:,:,jpr_w10m)
[1705]707         CALL iom_put( "taum_oce", taum )   ! output wind stress module
[1695]708         
[1218]709      ENDIF
710      !                                                      ! ========================= !
[1226]711      IF( k_ice <= 1 ) THEN                                  !  heat & freshwater fluxes ! (Ocean only case)
[1218]712         !                                                   ! ========================= !
713         !
714         !                                                       ! non solar heat flux over the ocean (qns)
715         IF( srcv(jpr_qnsoce)%laction )   qns(:,:) = frcv(:,:,jpr_qnsoce)
716         IF( srcv(jpr_qnsmix)%laction )   qns(:,:) = frcv(:,:,jpr_qnsmix)       
[1226]717         !   energy for melting solid precipitation over free ocean
718         zcoef = xlsn / rhosn
719         qns(:,:) = qns(:,:) - frcv(:,:,jpr_snow) * zcoef
[1218]720         !                                                       ! solar flux over the ocean          (qsr)
721         IF( srcv(jpr_qsroce)%laction )   qsr(:,:) = frcv(:,:,jpr_qsroce) 
722         IF( srcv(jpr_qsrmix)%laction )   qsr(:,:) = frcv(:,:,jpr_qsrmix)
723         !
724         !                                                       ! total freshwater fluxes over the ocean (emp, emps)
725         SELECT CASE( TRIM( cn_rcv_emp ) )                                    ! evaporation - precipitation
726         CASE( 'conservative' )
727            emp(:,:) = frcv(:,:,jpr_tevp) - ( frcv(:,:,jpr_rain) + frcv(:,:,jpr_snow) )
[1308]728         CASE( 'oce only', 'oce and ice' )
[1218]729            emp(:,:) = frcv(:,:,jpr_oemp)
[1308]730         CASE default
731            CALL ctl_stop( 'sbc_cpl_rcv: wrong definition of cn_rcv_emp' )
[1218]732         END SELECT
733         !
734         !                                                        ! runoffs and calving (added in emp)
[1248]735         IF( srcv(jpr_rnf)%laction )   emp(:,:) = emp(:,:) - frcv(:,:,jpr_rnf)       
736         IF( srcv(jpr_cal)%laction )   emp(:,:) = emp(:,:) - frcv(:,:,jpr_cal)
[1218]737         !
738!!gm :  this seems to be internal cooking, not sure to need that in a generic interface
739!!gm                                       at least should be optional...
740!!         IF( TRIM( cn_rcv_rnf ) == 'coupled' ) THEN     ! add to the total freshwater budget
741!!            ! remove negative runoff
742!!            zcumulpos = SUM( MAX( frcv(:,:,jpr_rnf), 0.e0 ) * e1t(:,:) * e2t(:,:) * tmask_i(:,:) )
743!!            zcumulneg = SUM( MIN( frcv(:,:,jpr_rnf), 0.e0 ) * e1t(:,:) * e2t(:,:) * tmask_i(:,:) )
744!!            IF( lk_mpp )   CALL mpp_sum( zcumulpos )   ! sum over the global domain
745!!            IF( lk_mpp )   CALL mpp_sum( zcumulneg )
746!!            IF( zcumulpos /= 0. ) THEN                 ! distribute negative runoff on positive runoff grid points
747!!               zcumulneg = 1.e0 + zcumulneg / zcumulpos
748!!               frcv(:,:,jpr_rnf) = MAX( frcv(:,:,jpr_rnf), 0.e0 ) * zcumulneg
749!!            ENDIF     
750!!            ! add runoff to e-p
751!!            emp(:,:) = emp(:,:) - frcv(:,:,jpr_rnf)
752!!         ENDIF
753!!gm  end of internal cooking
754         !
755         emps(:,:) = emp(:,:)                                        ! concentration/dilution = emp
[1230]756 
757         !                                                           ! 10 m wind speed
758         IF( srcv(jpr_w10m)%laction )   wndm(:,:) = frcv(:,:,jpr_w10m)
[1218]759         !
[1534]760#if defined  key_cpl_carbon_cycle
761         !                                                              ! atmosph. CO2 (ppm)
762         IF( srcv(jpr_co2)%laction )   atm_co2(:,:) = frcv(:,:,jpr_co2)
763#endif
764
[1218]765      ENDIF
766      !
767   END SUBROUTINE sbc_cpl_rcv
768   
769
770   SUBROUTINE sbc_cpl_ice_tau( p_taui, p_tauj )     
771      !!----------------------------------------------------------------------
772      !!             ***  ROUTINE sbc_cpl_ice_tau  ***
773      !!
774      !! ** Purpose :   provide the stress over sea-ice in coupled mode
775      !!
776      !! ** Method  :   transform the received stress from the atmosphere into
777      !!             an atmosphere-ice stress in the (i,j) ocean referencial
[1466]778      !!             and at the velocity point of the sea-ice model (cigr_type):
[1218]779      !!                'C'-grid : i- (j-) components given at U- (V-) point
780      !!                'B'-grid : both components given at I-point
781      !!
782      !!                The received stress are :
783      !!                 - defined by 3 components (if cartesian coordinate)
784      !!                        or by 2 components (if spherical)
785      !!                 - oriented along geographical   coordinate (if eastward-northward)
786      !!                        or  along the local grid coordinate (if local grid)
787      !!                 - given at U- and V-point, resp.   if received on 2 grids
788      !!                        or at a same point (T or I) if received on 1 grid
789      !!                Therefore and if necessary, they are successively
790      !!             processed in order to obtain them
791      !!                 first  as  2 components on the sphere
792      !!                 second as  2 components oriented along the local grid
[1466]793      !!                 third  as  2 components on the cigr_type point
[1218]794      !!
795      !!                In 'oce and ice' case, only one vector stress field
796      !!             is received. It has already been processed in sbc_cpl_rcv
797      !!             so that it is now defined as (i,j) components given at U-
798      !!             and V-points, respectively. Therefore, here only the third
799      !!             transformation is done and only if the ice-grid is a 'B'-grid.
800      !!
[1466]801      !! ** Action  :   return ptau_i, ptau_j, the stress over the ice at cigr_type point
[1218]802      !!----------------------------------------------------------------------
803      REAL(wp), INTENT(out), DIMENSION(jpi,jpj) ::   p_taui   ! i- & j-components of atmos-ice stress [N/m2]
804      REAL(wp), INTENT(out), DIMENSION(jpi,jpj) ::   p_tauj   ! at I-point (B-grid) or U & V-point (C-grid)
805      !!
806      INTEGER ::   ji, jj                          ! dummy loop indices
807      INTEGER ::   itx                             ! index of taux over ice
[1226]808      REAL(wp), DIMENSION(jpi,jpj) ::   ztx, zty   ! 2D workspace
[1218]809      !!----------------------------------------------------------------------
810
811      IF( srcv(jpr_itx1)%laction ) THEN   ;   itx =  jpr_itx1   
812      ELSE                                ;   itx =  jpr_otx1
813      ENDIF
814
815      ! do something only if we just received the stress from atmosphere
[1698]816      IF(  nrcvinfo(itx) == OASIS_Rcv ) THEN
[1218]817
818         !                                                      ! ======================= !
819         IF( srcv(jpr_itx1)%laction ) THEN                      !   ice stress received   !
820            !                                                   ! ======================= !
821           
822            IF( TRIM( cn_rcv_tau(2) ) == 'cartesian' ) THEN            ! 2 components on the sphere
823               !                                                       ! (cartesian to spherical -> 3 to 2 components)
824               CALL geo2oce( frcv(:,:,jpr_itx1), frcv(:,:,jpr_ity1), frcv(:,:,jpr_itz1),   &
825                  &          srcv(jpr_itx1)%clgrid, ztx, zty )
826               frcv(:,:,jpr_itx1) = ztx(:,:)   ! overwrite 1st comp. on the 1st grid
827               frcv(:,:,jpr_itx1) = zty(:,:)   ! overwrite 2nd comp. on the 1st grid
828               !
829               IF( srcv(jpr_itx2)%laction ) THEN
830                  CALL geo2oce( frcv(:,:,jpr_itx2), frcv(:,:,jpr_ity2), frcv(:,:,jpr_itz2),   &
831                     &          srcv(jpr_itx2)%clgrid, ztx, zty )
832                  frcv(:,:,jpr_itx2) = ztx(:,:)   ! overwrite 1st comp. on the 2nd grid
833                  frcv(:,:,jpr_ity2) = zty(:,:)   ! overwrite 2nd comp. on the 2nd grid
834               ENDIF
835               !
[888]836            ENDIF
[1218]837            !
838            IF( TRIM( cn_rcv_tau(3) ) == 'eastward-northward' ) THEN   ! 2 components oriented along the local grid
839               !                                                       ! (geographical to local grid -> rotate the components)
840               CALL rot_rep( frcv(:,:,jpr_itx1), frcv(:,:,jpr_ity1), srcv(jpr_itx1)%clgrid, 'en->i', ztx )   
841               frcv(:,:,jpr_itx1) = ztx(:,:)      ! overwrite 1st component on the 1st grid
842               IF( srcv(jpr_itx2)%laction ) THEN
843                  CALL rot_rep( frcv(:,:,jpr_itx2), frcv(:,:,jpr_ity2), srcv(jpr_itx2)%clgrid, 'en->j', zty )   
844               ELSE
845                  CALL rot_rep( frcv(:,:,jpr_itx1), frcv(:,:,jpr_ity1), srcv(jpr_itx1)%clgrid, 'en->j', zty ) 
846               ENDIF
847               frcv(:,:,jpr_ity1) = zty(:,:)      ! overwrite 2nd component on the 1st grid
848            ENDIF
849            !                                                   ! ======================= !
850         ELSE                                                   !     use ocean stress    !
851            !                                                   ! ======================= !
852            frcv(:,:,jpr_itx1) = frcv(:,:,jpr_otx1)
853            frcv(:,:,jpr_ity1) = frcv(:,:,jpr_oty1)
854            !
855         ENDIF
[888]856
[1218]857         !                                                      ! ======================= !
858         !                                                      !     put on ice grid     !
859         !                                                      ! ======================= !
860         !   
861         !                                                  j+1   j     -----V---F
[1466]862         ! ice stress on ice velocity point (cigr_type)                  !       |
[1467]863         ! (C-grid ==>(U,V) or B-grid ==> I or F)                 j      |   T   U
[1218]864         !                                                               |       |
865         !                                                   j    j-1   -I-------|
866         !                                               (for I)         |       |
867         !                                                              i-1  i   i
868         !                                                               i      i+1 (for I)
[1466]869         SELECT CASE ( cigr_type )
[1218]870            !
[1467]871         CASE( 'I' )                                         ! B-grid ==> I
[1218]872            SELECT CASE ( srcv(jpr_itx1)%clgrid )
873            CASE( 'U' )
874               DO jj = 2, jpjm1                                   ! (U,V) ==> I
[1694]875                  DO ji = 2, jpim1   ! NO vector opt.
[1218]876                     p_taui(ji,jj) = 0.5 * ( frcv(ji-1,jj  ,jpr_itx1) + frcv(ji-1,jj-1,jpr_itx1) )
877                     p_tauj(ji,jj) = 0.5 * ( frcv(ji  ,jj-1,jpr_ity1) + frcv(ji-1,jj-1,jpr_ity1) )
878                  END DO
879               END DO
880            CASE( 'F' )
881               DO jj = 2, jpjm1                                   ! F ==> I
[1694]882                  DO ji = 2, jpim1   ! NO vector opt.
[1218]883                     p_taui(ji,jj) = frcv(ji-1,jj-1,jpr_itx1) 
884                     p_tauj(ji,jj) = frcv(ji-1,jj-1,jpr_ity1) 
885                  END DO
886               END DO
887            CASE( 'T' )
888               DO jj = 2, jpjm1                                   ! T ==> I
[1694]889                  DO ji = 2, jpim1   ! NO vector opt.
[1218]890                     p_taui(ji,jj) = 0.25 * ( frcv(ji,jj  ,jpr_itx1) + frcv(ji-1,jj  ,jpr_itx1)   &
891                        &                   + frcv(ji,jj-1,jpr_itx1) + frcv(ji-1,jj-1,jpr_itx1) ) 
892                     p_tauj(ji,jj) = 0.25 * ( frcv(ji,jj  ,jpr_ity1) + frcv(ji-1,jj  ,jpr_ity1)   &
893                        &                   + frcv(ji,jj-1,jpr_ity1) + frcv(ji-1,jj-1,jpr_ity1) )
894                  END DO
895               END DO
896            CASE( 'I' )
897               p_taui(:,:) = frcv(:,:,jpr_itx1)                   ! I ==> I
898               p_tauj(:,:) = frcv(:,:,jpr_ity1)
899            END SELECT
900            IF( srcv(jpr_itx1)%clgrid /= 'I' ) THEN
901               CALL lbc_lnk( p_taui, 'I',  -1. )   ;   CALL lbc_lnk( p_tauj, 'I',  -1. )
902            ENDIF
903            !
[1467]904         CASE( 'F' )                                         ! B-grid ==> F
905            SELECT CASE ( srcv(jpr_itx1)%clgrid )
906            CASE( 'U' )
907               DO jj = 2, jpjm1                                   ! (U,V) ==> F
908                  DO ji = fs_2, fs_jpim1   ! vector opt.
909                     p_taui(ji,jj) = 0.5 * ( frcv(ji,jj,jpr_itx1) + frcv(ji  ,jj+1,jpr_itx1) )
910                     p_tauj(ji,jj) = 0.5 * ( frcv(ji,jj,jpr_ity1) + frcv(ji+1,jj  ,jpr_ity1) )
911                  END DO
912               END DO
913            CASE( 'I' )
914               DO jj = 2, jpjm1                                   ! I ==> F
[1694]915                  DO ji = 2, jpim1   ! NO vector opt.
[1467]916                     p_taui(ji,jj) = frcv(ji+1,jj+1,jpr_itx1) 
917                     p_tauj(ji,jj) = frcv(ji+1,jj+1,jpr_ity1) 
918                  END DO
919               END DO
920            CASE( 'T' )
921               DO jj = 2, jpjm1                                   ! T ==> F
[1694]922                  DO ji = 2, jpim1   ! NO vector opt.
[1467]923                     p_taui(ji,jj) = 0.25 * ( frcv(ji,jj  ,jpr_itx1) + frcv(ji+1,jj  ,jpr_itx1)   &
924                        &                   + frcv(ji,jj+1,jpr_itx1) + frcv(ji+1,jj+1,jpr_itx1) ) 
925                     p_tauj(ji,jj) = 0.25 * ( frcv(ji,jj  ,jpr_ity1) + frcv(ji+1,jj  ,jpr_ity1)   &
926                        &                   + frcv(ji,jj+1,jpr_ity1) + frcv(ji+1,jj+1,jpr_ity1) )
927                  END DO
928               END DO
929            CASE( 'F' )
930               p_taui(:,:) = frcv(:,:,jpr_itx1)                   ! F ==> F
931               p_tauj(:,:) = frcv(:,:,jpr_ity1)
932            END SELECT
933            IF( srcv(jpr_itx1)%clgrid /= 'F' ) THEN
934               CALL lbc_lnk( p_taui, 'F',  -1. )   ;   CALL lbc_lnk( p_tauj, 'F',  -1. )
935            ENDIF
936            !
[1218]937         CASE( 'C' )                                         ! C-grid ==> U,V
938            SELECT CASE ( srcv(jpr_itx1)%clgrid )
939            CASE( 'U' )
940               p_taui(:,:) = frcv(:,:,jpr_itx1)                   ! (U,V) ==> (U,V)
941               p_tauj(:,:) = frcv(:,:,jpr_ity1)
942            CASE( 'F' )
943               DO jj = 2, jpjm1                                   ! F ==> (U,V)
944                  DO ji = fs_2, fs_jpim1   ! vector opt.
945                     p_taui(ji,jj) = 0.5 * ( frcv(ji,jj,jpr_itx1) + frcv(ji  ,jj-1,jpr_itx1) )
946                     p_tauj(ji,jj) = 0.5 * ( frcv(ji,jj,jpr_ity1) + frcv(ji-1,jj  ,jpr_ity1) )
947                  END DO
948               END DO
949            CASE( 'T' )
950               DO jj = 2, jpjm1                                   ! T ==> (U,V)
951                  DO ji = fs_2, fs_jpim1   ! vector opt.
952                     p_taui(ji,jj) = 0.5 * ( frcv(ji+1,jj  ,jpr_itx1) + frcv(ji,jj,jpr_itx1) )
953                     p_tauj(ji,jj) = 0.5 * ( frcv(ji  ,jj+1,jpr_ity1) + frcv(ji,jj,jpr_ity1) )
954                  END DO
955               END DO
956            CASE( 'I' )
957               DO jj = 2, jpjm1                                   ! I ==> (U,V)
[1694]958                  DO ji = 2, jpim1   ! NO vector opt.
[1218]959                     p_taui(ji,jj) = 0.5 * ( frcv(ji+1,jj+1,jpr_itx1) + frcv(ji+1,jj  ,jpr_itx1) )
960                     p_tauj(ji,jj) = 0.5 * ( frcv(ji+1,jj+1,jpr_ity1) + frcv(ji  ,jj+1,jpr_ity1) )
961                  END DO
962               END DO
963            END SELECT
964            IF( srcv(jpr_itx1)%clgrid /= 'U' ) THEN
965               CALL lbc_lnk( p_taui, 'U',  -1. )   ;   CALL lbc_lnk( p_tauj, 'V',  -1. )
966            ENDIF
967         END SELECT
968
969         !!gm Should be useless as sbc_cpl_ice_tau only called at coupled frequency
970         ! The receive stress are transformed such that in all case frcv(:,:,jpr_itx1), frcv(:,:,jpr_ity1)
971         ! become the i-component and j-component of the stress at the right grid point
972         !!gm  frcv(:,:,jpr_itx1) = p_taui(:,:)
973         !!gm  frcv(:,:,jpr_ity1) = p_tauj(:,:)
974         !!gm
975      ENDIF
976      !   
977   END SUBROUTINE sbc_cpl_ice_tau
978   
979
[1468]980   SUBROUTINE sbc_cpl_ice_flx( p_frld  ,                                  &
[1463]981      &                        pqns_tot, pqns_ice, pqsr_tot , pqsr_ice,   &
[1468]982      &                        pemp_tot, pemp_ice, pdqns_ice, psprecip,   &
983      &                        palbi   , psst    , pist                 )
[1218]984      !!----------------------------------------------------------------------
985      !!             ***  ROUTINE sbc_cpl_ice_flx_rcv  ***
986      !!
987      !! ** Purpose :   provide the heat and freshwater fluxes of the
988      !!              ocean-ice system.
989      !!
990      !! ** Method  :   transform the fields received from the atmosphere into
991      !!             surface heat and fresh water boundary condition for the
992      !!             ice-ocean system. The following fields are provided:
993      !!              * total non solar, solar and freshwater fluxes (qns_tot,
994      !!             qsr_tot and emp_tot) (total means weighted ice-ocean flux)
995      !!             NB: emp_tot include runoffs and calving.
996      !!              * fluxes over ice (qns_ice, qsr_ice, emp_ice) where
997      !!             emp_ice = sublimation - solid precipitation as liquid
998      !!             precipitation are re-routed directly to the ocean and
999      !!             runoffs and calving directly enter the ocean.
1000      !!              * solid precipitation (sprecip), used to add to qns_tot
1001      !!             the heat lost associated to melting solid precipitation
1002      !!             over the ocean fraction.
1003      !!       ===>> CAUTION here this changes the net heat flux received from
1004      !!             the atmosphere
1005      !!
1006      !!             N.B. - fields over sea-ice are passed in argument so that
1007      !!                 the module can be compile without sea-ice.
1008      !!                  - the fluxes have been separated from the stress as
1009      !!                 (a) they are updated at each ice time step compare to
1010      !!                 an update at each coupled time step for the stress, and
1011      !!                 (b) the conservative computation of the fluxes over the
1012      !!                 sea-ice area requires the knowledge of the ice fraction
1013      !!                 after the ice advection and before the ice thermodynamics,
1014      !!                 so that the stress is updated before the ice dynamics
1015      !!                 while the fluxes are updated after it.
1016      !!
1017      !! ** Action  :   update at each nf_ice time step:
1018      !!                   pqns_tot, pqsr_tot  non-solar and solar total heat fluxes
1019      !!                   pqns_ice, pqsr_ice  non-solar and solar heat fluxes over the ice
1020      !!                   pemp_tot            total evaporation - precipitation(liquid and solid) (-runoff)(-calving)
1021      !!                   pemp_ice            ice sublimation - solid precipitation over the ice
[1226]1022      !!                   pdqns_ice           d(non-solar heat flux)/d(Temperature) over the ice
1023      !!                   sprecip             solid precipitation over the ocean 
[1218]1024      !!----------------------------------------------------------------------
[1463]1025      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj,jpl) ::   p_frld     ! lead fraction                [0 to 1]
1026      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj    ) ::   pqns_tot   ! total non solar heat flux    [W/m2]
1027      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj,jpl) ::   pqns_ice   ! ice   non solar heat flux    [W/m2]
1028      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj    ) ::   pqsr_tot   ! total     solar heat flux    [W/m2]
1029      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj,jpl) ::   pqsr_ice   ! ice       solar heat flux    [W/m2]
1030      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj    ) ::   pemp_tot   ! total     freshwater budget        [Kg/m2/s]
1031      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj    ) ::   pemp_ice   ! solid freshwater budget over ice   [Kg/m2/s]
1032      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj    ) ::   psprecip   ! Net solid precipitation (=emp_ice) [Kg/m2/s]
1033      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj,jpl) ::   pdqns_ice  ! d(Q non solar)/d(Temperature) over ice
[1468]1034      ! optional arguments, used only in 'mixed oce-ice' case
1035      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj,jpl), OPTIONAL ::   palbi   ! ice albedo
1036      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj    ), OPTIONAL ::   psst    ! sea surface temperature     [Celcius]
1037      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj,jpl), OPTIONAL ::   pist    ! ice surface temperature     [Kelvin]
[1218]1038     !!
1039      INTEGER ::   ji, jj           ! dummy loop indices
1040      INTEGER ::   isec, info       ! temporary integer
1041      REAL(wp)::   zcoef, ztsurf    ! temporary scalar
[1756]1042      REAL(wp), DIMENSION(jpi,jpj    )::   zcptn    ! rcp * tn(:,:,1)
1043      REAL(wp), DIMENSION(jpi,jpj    )::   ztmp     ! temporary array
[1742]1044      REAL(wp), DIMENSION(jpi,jpj    )::   zsnow    ! snow precipitation
1045      REAL(wp), DIMENSION(jpi,jpj,jpl)::   zicefr   ! ice fraction
[1218]1046      !!----------------------------------------------------------------------
[1742]1047      zicefr(:,:,1) = 1.- p_frld(:,:,1)
[1756]1048      IF( lk_diaar5 )   zcptn(:,:) = rcp * tn(:,:,1)
[888]1049      !
[1218]1050      !                                                      ! ========================= !
1051      !                                                      !    freshwater budget      !   (emp)
1052      !                                                      ! ========================= !
[888]1053      !
[1218]1054      !                                                           ! total Precipitations - total Evaporation (emp_tot)
1055      !                                                           ! solid precipitation  - sublimation       (emp_ice)
1056      !                                                           ! solid Precipitation                      (sprecip)
1057      SELECT CASE( TRIM( cn_rcv_emp ) )
1058      CASE( 'conservative'  )   ! received fields: jpr_rain, jpr_snow, jpr_ievp, jpr_tevp
1059         pemp_tot(:,:) = frcv(:,:,jpr_tevp) - frcv(:,:,jpr_rain) - frcv(:,:,jpr_snow)
1060         pemp_ice(:,:) = frcv(:,:,jpr_ievp) - frcv(:,:,jpr_snow)
[1232]1061         zsnow   (:,:) = frcv(:,:,jpr_snow)
[1756]1062                           CALL iom_put( 'rain'         , frcv(:,:,jpr_rain)              )   ! liquid precipitation
1063         IF( lk_diaar5 )   CALL iom_put( 'hflx_rain_cea', frcv(:,:,jpr_rain) * zcptn(:,:) )   ! heat flux from liq. precip.
1064         ztmp(:,:) = frcv(:,:,jpr_tevp) - frcv(:,:,jpr_ievp) * zicefr(:,:,1)
1065                           CALL iom_put( 'evap_ao_cea'  , ztmp                            )   ! ice-free oce evap (cell average)
1066         IF( lk_diaar5 )   CALL iom_put( 'hflx_evap_cea', ztmp(:,:         ) * zcptn(:,:) )   ! heat flux from from evap (cell ave)
[1232]1067      CASE( 'oce and ice'   )   ! received fields: jpr_sbpr, jpr_semp, jpr_oemp
[1742]1068         pemp_tot(:,:) = p_frld(:,:,1) * frcv(:,:,jpr_oemp) + zicefr(:,:,1) * frcv(:,:,jpr_sbpr) 
[1218]1069         pemp_ice(:,:) = frcv(:,:,jpr_semp)
[1232]1070         zsnow   (:,:) = - frcv(:,:,jpr_semp) + frcv(:,:,jpr_ievp)
[1218]1071      END SELECT
[1232]1072      psprecip(:,:) = - pemp_ice(:,:)
[1756]1073      CALL iom_put( 'snowpre'    , zsnow                               )   ! Snow
1074      CALL iom_put( 'snow_ao_cea', zsnow(:,:         ) * p_frld(:,:,1) )   ! Snow        over ice-free ocean  (cell average)
1075      CALL iom_put( 'snow_ai_cea', zsnow(:,:         ) * zicefr(:,:,1) )   ! Snow        over sea-ice         (cell average)
1076      CALL iom_put( 'subl_ai_cea', frcv (:,:,jpr_ievp) * zicefr(:,:,1) )   ! Sublimation over sea-ice         (cell average)
[1218]1077      !   
1078      !                                                           ! runoffs and calving (put in emp_tot)
[1756]1079      IF( srcv(jpr_rnf)%laction ) THEN
1080         pemp_tot(:,:) = pemp_tot(:,:) - frcv(:,:,jpr_rnf)
1081                           CALL iom_put( 'runoffs'      , frcv(:,:,jpr_rnf )              )   ! rivers
1082         IF( lk_diaar5 )   CALL iom_put( 'hflx_rnf_cea' , frcv(:,:,jpr_rnf ) * zcptn(:,:) )   ! heat flux from rivers
1083      ENDIF
1084      IF( srcv(jpr_cal)%laction ) THEN
1085         pemp_tot(:,:) = pemp_tot(:,:) - frcv(:,:,jpr_cal)
1086         CALL iom_put( 'calving', frcv(:,:,jpr_cal) )
1087      ENDIF
[888]1088      !
[1218]1089!!gm :  this seems to be internal cooking, not sure to need that in a generic interface
1090!!gm                                       at least should be optional...
1091!!       ! remove negative runoff                            ! sum over the global domain
1092!!       zcumulpos = SUM( MAX( frcv(:,:,jpr_rnf), 0.e0 ) * e1t(:,:) * e2t(:,:) * tmask_i(:,:) )
1093!!       zcumulneg = SUM( MIN( frcv(:,:,jpr_rnf), 0.e0 ) * e1t(:,:) * e2t(:,:) * tmask_i(:,:) )
1094!!       IF( lk_mpp )   CALL mpp_sum( zcumulpos )
1095!!       IF( lk_mpp )   CALL mpp_sum( zcumulneg )
1096!!       IF( zcumulpos /= 0. ) THEN                          ! distribute negative runoff on positive runoff grid points
1097!!          zcumulneg = 1.e0 + zcumulneg / zcumulpos
1098!!          frcv(:,:,jpr_rnf) = MAX( frcv(:,:,jpr_rnf), 0.e0 ) * zcumulneg
1099!!       ENDIF     
1100!!       pemp_tot(:,:) = pemp_tot(:,:) - frcv(:,:,jpr_rnf)   ! add runoff to e-p
1101!!
1102!!gm  end of internal cooking
[888]1103
1104
[1218]1105      !                                                      ! ========================= !
1106      SELECT CASE( TRIM( cn_rcv_qns ) )                      !   non solar heat fluxes   !   (qns)
1107      !                                                      ! ========================= !
1108      CASE( 'conservative' )                                      ! the required fields are directly provided
[1463]1109         pqns_tot(:,:  ) = frcv(:,:,jpr_qnsmix)
1110         pqns_ice(:,:,1) = frcv(:,:,jpr_qnsice)
[1218]1111      CASE( 'oce and ice' )       ! the total flux is computed from ocean and ice fluxes
[1742]1112         pqns_tot(:,:  ) =  p_frld(:,:,1) * frcv(:,:,jpr_qnsoce) + zicefr(:,:,1) * frcv(:,:,jpr_qnsice)
[1463]1113         pqns_ice(:,:,1) =  frcv(:,:,jpr_qnsice)
[1218]1114      CASE( 'mixed oce-ice' )     ! the ice flux is cumputed from the total flux, the SST and ice informations
[1463]1115         pqns_tot(:,:  ) = frcv(:,:,jpr_qnsmix)
1116         pqns_ice(:,:,1) = frcv(:,:,jpr_qnsmix)    &
[1742]1117            &            + frcv(:,:,jpr_dqnsdt) * ( pist(:,:,1) - ( (rt0 + psst(:,:  ) ) * p_frld(:,:,1)   &
1118            &                                                   +          pist(:,:,1)   * zicefr(:,:,1) ) )
[1218]1119      END SELECT
1120      !                                                           ! snow melting heat flux ....
[1742]1121      !   energy for melting solid precipitation over ice-free ocean
[1218]1122      zcoef = xlsn / rhosn
[1756]1123      ztmp(:,:) = p_frld(:,:,1) * zsnow(:,:) * zcoef
1124      pqns_tot(:,:) = pqns_tot(:,:) - ztmp(:,:)
1125      IF( lk_diaar5 )   CALL iom_put( 'hflx_snow_cea', ztmp + zsnow(:,:) * zcptn(:,:) )   ! heat flux from snow (cell average)
[1218]1126!!gm
1127!!    currently it is taken into account in leads budget but not in the qns_tot, and thus not in
1128!!    the flux that enter the ocean....
1129!!    moreover 1 - it is not diagnose anywhere....
1130!!             2 - it is unclear for me whether this heat lost is taken into account in the atmosphere or not...
1131!!
1132!! similar job should be done for snow and precipitation temperature
[1742]1133      !                                                           ! Iceberg melting heat flux ....
1134      !   energy for iceberg melting
1135      IF( srcv(jpr_cal)%laction ) THEN
1136         zcoef = xlic / rhoic
[1756]1137         ztmp(:,:) = frcv(:,:,jpr_cal) * zcoef
1138         pqns_tot(:,:) = pqns_tot(:,:) - ztmp(:,:)
1139         IF( lk_diaar5 )   CALL iom_put( 'hflx_cal_cea', ztmp + frcv(:,:,jpr_cal) * zcptn(:,:) )   ! heat flux from calving
[1742]1140      ENDIF
[1218]1141
1142      !                                                      ! ========================= !
1143      SELECT CASE( TRIM( cn_rcv_qsr ) )                      !      solar heat fluxes    !   (qsr)
1144      !                                                      ! ========================= !
1145      CASE( 'conservative' )
[1463]1146         pqsr_tot(:,:  ) = frcv(:,:,jpr_qsrmix)
1147         pqsr_ice(:,:,1) = frcv(:,:,jpr_qsrice)
[1218]1148      CASE( 'oce and ice' )
[1742]1149         pqsr_tot(:,:  ) =  p_frld(:,:,1) * frcv(:,:,jpr_qsroce) + zicefr(:,:,1) * frcv(:,:,jpr_qsrice)
[1463]1150         pqsr_ice(:,:,1) =  frcv(:,:,jpr_qsrice)
[1218]1151      CASE( 'mixed oce-ice' )
[1463]1152         pqsr_tot(:,:  ) = frcv(:,:,jpr_qsrmix)
[1232]1153!       Create solar heat flux over ice using incoming solar heat flux and albedos
1154!       ( see OASIS3 user guide, 5th edition, p39 )
[1463]1155         pqsr_ice(:,:,1) = frcv(:,:,jpr_qsrmix) * ( 1.- palbi(:,:,1) )   &
[1742]1156            &            / (  1.- ( albedo_oce_mix(:,:  ) * p_frld(:,:,1)   &
1157            &                     + palbi         (:,:,1) * zicefr(:,:,1) ) )
[1218]1158      END SELECT
1159
[1226]1160      SELECT CASE( TRIM( cn_rcv_dqnsdt ) )
1161      CASE ('coupled')
[1463]1162          pdqns_ice(:,:,1) = frcv(:,:,jpr_dqnsdt)
[1226]1163      END SELECT
1164
1165   END SUBROUTINE sbc_cpl_ice_flx
[1218]1166   
1167   
1168   SUBROUTINE sbc_cpl_snd( kt )
1169      !!----------------------------------------------------------------------
1170      !!             ***  ROUTINE sbc_cpl_snd  ***
1171      !!
1172      !! ** Purpose :   provide the ocean-ice informations to the atmosphere
1173      !!
1174      !! ** Method  :   send to the atmosphere through a call to cpl_prism_snd
1175      !!              all the needed fields (as defined in sbc_cpl_init)
1176      !!----------------------------------------------------------------------
1177      INTEGER, INTENT(in) ::   kt
1178      !!
1179      INTEGER ::   ji, jj          ! dummy loop indices
1180      INTEGER ::   isec, info      ! temporary integer
1181      REAL(wp), DIMENSION(jpi,jpj) ::   zfr_l   ! 1. - fr_i(:,:)
1182      REAL(wp), DIMENSION(jpi,jpj) ::   ztmp1, ztmp2
1183      REAL(wp), DIMENSION(jpi,jpj) ::   zotx1 , zoty1 , zotz1, zitx1, zity1, zitz1
1184      !!----------------------------------------------------------------------
[888]1185
[1218]1186      isec = ( kt - nit000 ) * NINT(rdttra(1))        ! date of exchanges
[888]1187
[1218]1188      zfr_l(:,:) = 1.- fr_i(:,:)
[888]1189
[1218]1190      !                                                      ! ------------------------- !
1191      !                                                      !    Surface temperature    !   in Kelvin
1192      !                                                      ! ------------------------- !
1193      SELECT CASE( cn_snd_temperature)
1194      CASE( 'oce only'             )   ;   ztmp1(:,:) =   tn(:,:,1) + rt0
1195      CASE( 'weighted oce and ice' )   ;   ztmp1(:,:) = ( tn(:,:,1) + rt0 ) * zfr_l(:,:)   
[1463]1196                                           ztmp2(:,:) =   tn_ice(:,:,1)     *  fr_i(:,:)
1197      CASE( 'mixed oce-ice'        )   ;   ztmp1(:,:) = ( tn(:,:,1) + rt0 ) * zfr_l(:,:) + tn_ice(:,:,1) * fr_i(:,:)
[1308]1198      CASE default                     ;   CALL ctl_stop( 'sbc_cpl_snd: wrong definition of cn_snd_temperature' )
[1218]1199      END SELECT
1200      IF( ssnd(jps_toce)%laction )   CALL cpl_prism_snd( jps_toce, isec, ztmp1, info )
1201      IF( ssnd(jps_tice)%laction )   CALL cpl_prism_snd( jps_tice, isec, ztmp2, info )
1202      IF( ssnd(jps_tmix)%laction )   CALL cpl_prism_snd( jps_tmix, isec, ztmp1, info )
1203      !
1204      !                                                      ! ------------------------- !
1205      !                                                      !           Albedo          !
1206      !                                                      ! ------------------------- !
1207      IF( ssnd(jps_albice)%laction ) THEN                         ! ice
[1463]1208         ztmp1(:,:) = alb_ice(:,:,1) * fr_i(:,:)
[1226]1209         CALL cpl_prism_snd( jps_albice, isec, ztmp1, info )
[888]1210      ENDIF
[1218]1211      IF( ssnd(jps_albmix)%laction ) THEN                         ! mixed ice-ocean
[1463]1212         ztmp1(:,:) = albedo_oce_mix(:,:) * zfr_l(:,:) + alb_ice(:,:,1) * fr_i(:,:)
[1226]1213         CALL cpl_prism_snd( jps_albmix, isec, ztmp1, info )
[1218]1214      ENDIF
1215      !                                                      ! ------------------------- !
1216      !                                                      !  Ice fraction & Thickness !
1217      !                                                      ! ------------------------- !
[1226]1218      IF( ssnd(jps_fice)%laction )   CALL cpl_prism_snd( jps_fice, isec, fr_i                  , info )
1219      IF( ssnd(jps_hice)%laction )   CALL cpl_prism_snd( jps_hice, isec, hicif(:,:) * fr_i(:,:), info )
1220      IF( ssnd(jps_hsnw)%laction )   CALL cpl_prism_snd( jps_hsnw, isec, hsnif(:,:) * fr_i(:,:), info )
[1218]1221      !
[1534]1222#if defined key_cpl_carbon_cycle
[1218]1223      !                                                      ! ------------------------- !
[1534]1224      !                                                      !  CO2 flux from PISCES     !
1225      !                                                      ! ------------------------- !
1226      IF( ssnd(jps_co2)%laction )   CALL cpl_prism_snd( jps_co2, isec, oce_co2 , info )
1227      !
1228#endif
[1218]1229      IF( ssnd(jps_ocx1)%laction ) THEN                      !      Surface current      !
1230         !                                                   ! ------------------------- !
[1467]1231         !   
1232         !                                                  j+1   j     -----V---F
[1694]1233         ! surface velocity always sent from T point                     !       |
[1467]1234         !                                                        j      |   T   U
1235         !                                                               |       |
1236         !                                                   j    j-1   -I-------|
1237         !                                               (for I)         |       |
1238         !                                                              i-1  i   i
1239         !                                                               i      i+1 (for I)
[1218]1240         SELECT CASE( TRIM( cn_snd_crt(1) ) )
[1467]1241         CASE( 'oce only'             )      ! C-grid ==> T
[1218]1242            DO jj = 2, jpjm1
1243               DO ji = fs_2, fs_jpim1   ! vector opt.
1244                  zotx1(ji,jj) = 0.5 * ( un(ji,jj,1) + un(ji-1,jj  ,1) )
[1308]1245                  zoty1(ji,jj) = 0.5 * ( vn(ji,jj,1) + vn(ji  ,jj-1,1) ) 
[1218]1246               END DO
1247            END DO
1248         CASE( 'weighted oce and ice' )   
[1467]1249            SELECT CASE ( cigr_type )
1250            CASE( 'C' )                      ! Ocean and Ice on C-grid ==> T
[1218]1251               DO jj = 2, jpjm1
1252                  DO ji = fs_2, fs_jpim1   ! vector opt.
[1472]1253                     zotx1(ji,jj) = 0.5 * ( un   (ji,jj,1) + un   (ji-1,jj  ,1) ) * zfr_l(ji,jj) 
1254                     zoty1(ji,jj) = 0.5 * ( vn   (ji,jj,1) + vn   (ji  ,jj-1,1) ) * zfr_l(ji,jj)
1255                     zitx1(ji,jj) = 0.5 * ( u_ice(ji,jj  ) + u_ice(ji-1,jj    ) ) *  fr_i(ji,jj)
1256                     zity1(ji,jj) = 0.5 * ( v_ice(ji,jj  ) + v_ice(ji  ,jj-1  ) ) *  fr_i(ji,jj)
[1218]1257                  END DO
1258               END DO
[1467]1259            CASE( 'I' )                      ! Ocean on C grid, Ice on I-point (B-grid) ==> T
[1218]1260               DO jj = 2, jpjm1
[1694]1261                  DO ji = 2, jpim1   ! NO vector opt.
[1693]1262                     zotx1(ji,jj) = 0.5  * ( un(ji,jj,1)      + un(ji-1,jj  ,1) ) * zfr_l(ji,jj) 
[1472]1263                     zoty1(ji,jj) = 0.5  * ( vn(ji,jj,1)      + vn(ji  ,jj-1,1) ) * zfr_l(ji,jj) 
1264                     zitx1(ji,jj) = 0.25 * ( u_ice(ji+1,jj+1) + u_ice(ji,jj+1)                     &
1265                        &                  + u_ice(ji+1,jj  ) + u_ice(ji,jj  )  ) *  fr_i(ji,jj)
1266                     zity1(ji,jj) = 0.25 * ( v_ice(ji+1,jj+1) + v_ice(ji,jj+1)                     &
1267                        &                  + v_ice(ji+1,jj  ) + v_ice(ji,jj  )  ) *  fr_i(ji,jj)
[1218]1268                  END DO
1269               END DO
[1467]1270            CASE( 'F' )                      ! Ocean on C grid, Ice on F-point (B-grid) ==> T
1271               DO jj = 2, jpjm1
[1694]1272                  DO ji = 2, jpim1   ! NO vector opt.
[1693]1273                     zotx1(ji,jj) = 0.5  * ( un(ji,jj,1)      + un(ji-1,jj  ,1) ) * zfr_l(ji,jj) 
[1472]1274                     zoty1(ji,jj) = 0.5  * ( vn(ji,jj,1)      + vn(ji  ,jj-1,1) ) * zfr_l(ji,jj) 
1275                     zitx1(ji,jj) = 0.25 * ( u_ice(ji-1,jj-1) + u_ice(ji,jj-1)                     &
1276                        &                  + u_ice(ji-1,jj  ) + u_ice(ji,jj  )  ) *  fr_i(ji,jj)
1277                     zity1(ji,jj) = 0.25 * ( v_ice(ji-1,jj-1) + v_ice(ji,jj-1)                     &
1278                        &                  + v_ice(ji-1,jj  ) + v_ice(ji,jj  )  ) *  fr_i(ji,jj)
[1467]1279                  END DO
1280               END DO
1281            END SELECT
[1218]1282            CALL lbc_lnk( zitx1, 'T', -1. )   ;   CALL lbc_lnk( zity1, 'T', -1. )
1283         CASE( 'mixed oce-ice'        )
[1467]1284            SELECT CASE ( cigr_type )
1285            CASE( 'C' )                      ! Ocean and Ice on C-grid ==> T
[1218]1286               DO jj = 2, jpjm1
[1308]1287                  DO ji = fs_2, fs_jpim1   ! vector opt.
[1472]1288                     zotx1(ji,jj) = 0.5 * ( un   (ji,jj,1) + un   (ji-1,jj  ,1) ) * zfr_l(ji,jj)   &
1289                        &         + 0.5 * ( u_ice(ji,jj  ) + u_ice(ji-1,jj    ) ) *  fr_i(ji,jj)
1290                     zoty1(ji,jj) = 0.5 * ( vn   (ji,jj,1) + vn   (ji  ,jj-1,1) ) * zfr_l(ji,jj)   &
1291                        &         + 0.5 * ( v_ice(ji,jj  ) + v_ice(ji  ,jj-1  ) ) *  fr_i(ji,jj)
[1308]1292                  END DO
[1218]1293               END DO
[1467]1294            CASE( 'I' )                      ! Ocean on C grid, Ice on I-point (B-grid) ==> T
[1218]1295               DO jj = 2, jpjm1
[1694]1296                  DO ji = 2, jpim1   ! NO vector opt.
[1693]1297                     zotx1(ji,jj) = 0.5  * ( un(ji,jj,1)      + un(ji-1,jj  ,1) ) * zfr_l(ji,jj)   &   
[1472]1298                        &         + 0.25 * ( u_ice(ji+1,jj+1) + u_ice(ji,jj+1)                     &
1299                        &                  + u_ice(ji+1,jj  ) + u_ice(ji,jj  )  ) *  fr_i(ji,jj)
1300                     zoty1(ji,jj) = 0.5  * ( vn(ji,jj,1)      + vn(ji  ,jj-1,1) ) * zfr_l(ji,jj)   & 
1301                        &         + 0.25 * ( v_ice(ji+1,jj+1) + v_ice(ji,jj+1)                     &
1302                        &                  + v_ice(ji+1,jj  ) + v_ice(ji,jj  )  ) *  fr_i(ji,jj)
[1218]1303                  END DO
1304               END DO
[1467]1305            CASE( 'F' )                      ! Ocean on C grid, Ice on F-point (B-grid) ==> T
1306               DO jj = 2, jpjm1
[1694]1307                  DO ji = 2, jpim1   ! NO vector opt.
[1693]1308                     zotx1(ji,jj) = 0.5  * ( un(ji,jj,1)      + un(ji-1,jj  ,1) ) * zfr_l(ji,jj)   &   
[1472]1309                        &         + 0.25 * ( u_ice(ji-1,jj-1) + u_ice(ji,jj-1)                     &
1310                        &                  + u_ice(ji-1,jj  ) + u_ice(ji,jj  )  ) *  fr_i(ji,jj)
1311                     zoty1(ji,jj) = 0.5  * ( vn(ji,jj,1)      + vn(ji  ,jj-1,1) ) * zfr_l(ji,jj)   & 
1312                        &         + 0.25 * ( v_ice(ji-1,jj-1) + v_ice(ji,jj-1)                     &
1313                        &                  + v_ice(ji-1,jj  ) + v_ice(ji,jj  )  ) *  fr_i(ji,jj)
[1467]1314                  END DO
1315               END DO
1316            END SELECT
[1218]1317         END SELECT
1318         CALL lbc_lnk( zotx1, 'T', -1. )   ;   CALL lbc_lnk( zoty1, 'T', -1. )
[888]1319         !
[1218]1320         !
1321         IF( TRIM( cn_snd_crt(3) ) == 'eastward-northward' ) THEN             ! Rotation of the components
1322            !                                                                     ! Ocean component
1323            CALL rot_rep( zotx1, zoty1, ssnd(jps_ocx1)%clgrid, 'ij->e', ztmp1 )       ! 1st component
1324            CALL rot_rep( zotx1, zoty1, ssnd(jps_ocx1)%clgrid, 'ij->n', ztmp2 )       ! 2nd component
1325            zotx1(:,:) = ztmp1(:,:)                                                   ! overwrite the components
1326            zoty1(:,:) = ztmp2(:,:)
1327            IF( ssnd(jps_ivx1)%laction ) THEN                                     ! Ice component
1328               CALL rot_rep( zitx1, zity1, ssnd(jps_ivx1)%clgrid, 'ij->e', ztmp1 )    ! 1st component
1329               CALL rot_rep( zitx1, zity1, ssnd(jps_ivx1)%clgrid, 'ij->n', ztmp2 )    ! 2nd component
1330               zitx1(:,:) = ztmp1(:,:)                                                ! overwrite the components
1331               zity1(:,:) = ztmp2(:,:)
1332            ENDIF
1333         ENDIF
1334         !
1335         ! spherical coordinates to cartesian -> 2 components to 3 components
1336         IF( TRIM( cn_snd_crt(2) ) == 'cartesian' ) THEN
1337            ztmp1(:,:) = zotx1(:,:)                     ! ocean currents
1338            ztmp2(:,:) = zoty1(:,:)
[1226]1339            CALL oce2geo ( ztmp1, ztmp2, 'T', zotx1, zoty1, zotz1 )
[1218]1340            !
1341            IF( ssnd(jps_ivx1)%laction ) THEN           ! ice velocities
1342               ztmp1(:,:) = zitx1(:,:)
1343               ztmp1(:,:) = zity1(:,:)
[1226]1344               CALL oce2geo ( ztmp1, ztmp2, 'T', zitx1, zity1, zitz1 )
[1218]1345            ENDIF
1346         ENDIF
1347         !
1348         IF( ssnd(jps_ocx1)%laction )   CALL cpl_prism_snd( jps_ocx1, isec, zotx1, info )   ! ocean x current 1st grid
1349         IF( ssnd(jps_ocy1)%laction )   CALL cpl_prism_snd( jps_ocy1, isec, zoty1, info )   ! ocean y current 1st grid
1350         IF( ssnd(jps_ocz1)%laction )   CALL cpl_prism_snd( jps_ocz1, isec, zotz1, info )   ! ocean z current 1st grid
1351         !
1352         IF( ssnd(jps_ivx1)%laction )   CALL cpl_prism_snd( jps_ivx1, isec, zitx1, info )   ! ice   x current 1st grid
1353         IF( ssnd(jps_ivy1)%laction )   CALL cpl_prism_snd( jps_ivy1, isec, zity1, info )   ! ice   y current 1st grid
1354         IF( ssnd(jps_ivz1)%laction )   CALL cpl_prism_snd( jps_ivz1, isec, zitz1, info )   ! ice   z current 1st grid
[1534]1355         !
[888]1356      ENDIF
[1218]1357   !
[1226]1358   END SUBROUTINE sbc_cpl_snd
[1218]1359   
[888]1360#else
1361   !!----------------------------------------------------------------------
[1218]1362   !!   Dummy module                                            NO coupling
[888]1363   !!----------------------------------------------------------------------
[1218]1364   USE par_kind        ! kind definition
[888]1365CONTAINS
[1218]1366   SUBROUTINE sbc_cpl_snd( kt )
1367      WRITE(*,*) 'sbc_cpl_snd: You should not have seen this print! error?', kt
1368   END SUBROUTINE sbc_cpl_snd
1369   !
1370   SUBROUTINE sbc_cpl_rcv( kt, k_fsbc, k_ice )     
1371      WRITE(*,*) 'sbc_cpl_snd: You should not have seen this print! error?', kt, k_fsbc, k_ice
1372   END SUBROUTINE sbc_cpl_rcv
1373   !
1374   SUBROUTINE sbc_cpl_ice_tau( p_taui, p_tauj )     
1375      REAL(wp), INTENT(out), DIMENSION(:,:) ::   p_taui   ! i- & j-components of atmos-ice stress [N/m2]
1376      REAL(wp), INTENT(out), DIMENSION(:,:) ::   p_tauj   ! at I-point (B-grid) or U & V-point (C-grid)
1377      p_taui(:,:) = 0.   ;   p_tauj(:,:) = 0. ! stupid definition to avoid warning message when compiling...
1378      WRITE(*,*) 'sbc_cpl_snd: You should not have seen this print! error?'
1379   END SUBROUTINE sbc_cpl_ice_tau
1380   !
[1468]1381   SUBROUTINE sbc_cpl_ice_flx( p_frld  ,                                  &
[1463]1382      &                        pqns_tot, pqns_ice, pqsr_tot , pqsr_ice,   &
[1468]1383      &                        pemp_tot, pemp_ice, pdqns_ice, psprecip,   &
1384      &                        palbi   , psst    , pist                )
[1463]1385      REAL(wp), INTENT(in   ), DIMENSION(:,:,:) ::   p_frld     ! lead fraction                [0 to 1]
1386      REAL(wp), INTENT(  out), DIMENSION(:,:  ) ::   pqns_tot   ! total non solar heat flux    [W/m2]
1387      REAL(wp), INTENT(  out), DIMENSION(:,:,:) ::   pqns_ice   ! ice   non solar heat flux    [W/m2]
1388      REAL(wp), INTENT(  out), DIMENSION(:,:  ) ::   pqsr_tot   ! total     solar heat flux    [W/m2]
1389      REAL(wp), INTENT(  out), DIMENSION(:,:,:) ::   pqsr_ice   ! ice       solar heat flux    [W/m2]
1390      REAL(wp), INTENT(  out), DIMENSION(:,:  ) ::   pemp_tot   ! total     freshwater budget  [Kg/m2/s]
1391      REAL(wp), INTENT(  out), DIMENSION(:,:  ) ::   pemp_ice   ! ice solid freshwater budget  [Kg/m2/s]
1392      REAL(wp), INTENT(  out), DIMENSION(:,:,:) ::   pdqns_ice  ! d(Q non solar)/d(Temperature) over ice
1393      REAL(wp), INTENT(  out), DIMENSION(:,:  ) ::   psprecip   ! solid precipitation          [Kg/m2/s]
[1468]1394      REAL(wp), INTENT(in   ), DIMENSION(:,:,:), OPTIONAL ::   palbi   ! ice albedo
1395      REAL(wp), INTENT(in   ), DIMENSION(:,:  ), OPTIONAL ::   psst    ! sea surface temperature      [Celcius]
1396      REAL(wp), INTENT(in   ), DIMENSION(:,:,:), OPTIONAL ::   pist    ! ice surface temperature      [Kelvin]
[1557]1397      WRITE(*,*) 'sbc_cpl_snd: You should not have seen this print! error?', p_frld(1,1,1), palbi(1,1,1), psst(1,1), pist(1,1,1) 
[1218]1398      ! stupid definition to avoid warning message when compiling...
[1463]1399      pqns_tot(:,:) = 0. ; pqns_ice(:,:,:) = 0. ; pdqns_ice(:,:,:) = 0.
1400      pqsr_tot(:,:) = 0. ; pqsr_ice(:,:,:) = 0. 
1401      pemp_tot(:,:) = 0. ; pemp_ice(:,:)   = 0. ; psprecip(:,:) = 0.
[1218]1402   END SUBROUTINE sbc_cpl_ice_flx
1403   
[888]1404#endif
1405
1406   !!======================================================================
1407END MODULE sbccpl
Note: See TracBrowser for help on using the repository browser.