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

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

source: branches/dev_r1821_sbccpl_icecat/NEMO/OPA_SRC/SBC/sbccpl.F90 @ 2063

Last change on this file since 2063 was 2063, checked in by charris, 14 years ago

First set of changes in prepration for multi-category ice fields, see ticket #662

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