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

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

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

Last change on this file since 1226 was 1226, checked in by smasson, 15 years ago

bugfix of the coupling interface (commited during changeset:1218), see ticket:155

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