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 trunk/NEMOGCM/NEMO/OPA_SRC/SBC – NEMO

source: trunk/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90 @ 2528

Last change on this file since 2528 was 2528, checked in by rblod, 13 years ago

Update NEMOGCM from branch nemo_v3_3_beta

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