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

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

source: trunk/NEMO/OPA_SRC/SBC/sbccpl.F90 @ 2044

Last change on this file since 2044 was 2044, checked in by smasson, 14 years ago

small bugfix for coupled mode, see ticket:669

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