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

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

source: branches/DEV_r1837_mass_heat_salt_fluxes/NEMO/OPA_SRC/SBC/sbccpl.F90 @ 1859

Last change on this file since 1859 was 1859, checked in by gm, 14 years ago

ticket:#665 step 2 & 3: heat content in qns & new forcing terms

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