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

source: branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90 @ 5357

Last change on this file since 5357 was 5357, checked in by clem, 9 years ago

LIM3: change the interface between the ice and atm for both coupled and forced modes. Some work still needs to be done to deal with sublimation in coupled mode.

  • Property svn:keywords set to Id
File size: 118.0 KB
RevLine 
[888]1MODULE sbccpl
2   !!======================================================================
3   !!                       ***  MODULE  sbccpl  ***
[1218]4   !! Surface Boundary Condition :  momentum, heat and freshwater fluxes in coupled mode
5   !!======================================================================
[2528]6   !! History :  2.0  ! 2007-06  (R. Redler, N. Keenlyside, W. Park) Original code split into flxmod & taumod
7   !!            3.0  ! 2008-02  (G. Madec, C Talandier)  surface module
8   !!            3.1  ! 2009_02  (G. Madec, S. Masson, E. Maisonave, A. Caubel) generic coupled interface
[3294]9   !!            3.4  ! 2011_11  (C. Harris) more flexibility + multi-category fields
[888]10   !!----------------------------------------------------------------------
11   !!----------------------------------------------------------------------
[1218]12   !!   namsbc_cpl      : coupled formulation namlist
13   !!   sbc_cpl_init    : initialisation of the coupled exchanges
14   !!   sbc_cpl_rcv     : receive fields from the atmosphere over the ocean (ocean only)
15   !!                     receive stress from the atmosphere over the ocean (ocean-ice case)
16   !!   sbc_cpl_ice_tau : receive stress from the atmosphere over ice
17   !!   sbc_cpl_ice_flx : receive fluxes from the atmosphere over ice
18   !!   sbc_cpl_snd     : send     fields to the atmosphere
[888]19   !!----------------------------------------------------------------------
20   USE dom_oce         ! ocean space and time domain
[1218]21   USE sbc_oce         ! Surface boundary condition: ocean fields
22   USE sbc_ice         ! Surface boundary condition: ice fields
[5220]23   USE sbcapr
[2528]24   USE sbcdcy          ! surface boundary condition: diurnal cycle
[1860]25   USE phycst          ! physical constants
[1218]26#if defined key_lim3
[2528]27   USE ice             ! ice variables
[1218]28#endif
[1226]29#if defined key_lim2
[1534]30   USE par_ice_2       ! ice parameters
31   USE ice_2           ! ice variables
[1226]32#endif
[1218]33   USE cpl_oasis3      ! OASIS3 coupling
34   USE geo2ocean       !
[5352]35   USE oce   , ONLY : tsn, un, vn, sshn, ub, vb, tsb, sshb
[1218]36   USE albedo          !
[888]37   USE in_out_manager  ! I/O manager
[1218]38   USE iom             ! NetCDF library
[888]39   USE lib_mpp         ! distribued memory computing library
[3294]40   USE wrk_nemo        ! work arrays
41   USE timing          ! Timing
[888]42   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
[5220]43   USE eosbn2
[1534]44#if defined key_cpl_carbon_cycle
45   USE p4zflx, ONLY : oce_co2
46#endif
[3294]47#if defined key_cice
48   USE ice_domain_size, only: ncat
49#endif
[5357]50#if defined key_lim3
51   USE limthd_dh       ! for CALL lim_thd_snwblow
52#endif
53
[1218]54   IMPLICIT NONE
55   PRIVATE
[5220]56
[4990]57   PUBLIC   sbc_cpl_init       ! routine called by sbcmod.F90
[2715]58   PUBLIC   sbc_cpl_rcv        ! routine called by sbc_ice_lim(_2).F90
59   PUBLIC   sbc_cpl_snd        ! routine called by step.F90
60   PUBLIC   sbc_cpl_ice_tau    ! routine called by sbc_ice_lim(_2).F90
61   PUBLIC   sbc_cpl_ice_flx    ! routine called by sbc_ice_lim(_2).F90
[5009]62   PUBLIC   sbc_cpl_alloc      ! routine called in sbcice_cice.F90
[2715]63
[1218]64   INTEGER, PARAMETER ::   jpr_otx1   =  1            ! 3 atmosphere-ocean stress components on grid 1
65   INTEGER, PARAMETER ::   jpr_oty1   =  2            !
66   INTEGER, PARAMETER ::   jpr_otz1   =  3            !
67   INTEGER, PARAMETER ::   jpr_otx2   =  4            ! 3 atmosphere-ocean stress components on grid 2
68   INTEGER, PARAMETER ::   jpr_oty2   =  5            !
69   INTEGER, PARAMETER ::   jpr_otz2   =  6            !
70   INTEGER, PARAMETER ::   jpr_itx1   =  7            ! 3 atmosphere-ice   stress components on grid 1
71   INTEGER, PARAMETER ::   jpr_ity1   =  8            !
72   INTEGER, PARAMETER ::   jpr_itz1   =  9            !
73   INTEGER, PARAMETER ::   jpr_itx2   = 10            ! 3 atmosphere-ice   stress components on grid 2
74   INTEGER, PARAMETER ::   jpr_ity2   = 11            !
75   INTEGER, PARAMETER ::   jpr_itz2   = 12            !
76   INTEGER, PARAMETER ::   jpr_qsroce = 13            ! Qsr above the ocean
77   INTEGER, PARAMETER ::   jpr_qsrice = 14            ! Qsr above the ice
[1226]78   INTEGER, PARAMETER ::   jpr_qsrmix = 15 
79   INTEGER, PARAMETER ::   jpr_qnsoce = 16            ! Qns above the ocean
80   INTEGER, PARAMETER ::   jpr_qnsice = 17            ! Qns above the ice
81   INTEGER, PARAMETER ::   jpr_qnsmix = 18
82   INTEGER, PARAMETER ::   jpr_rain   = 19            ! total liquid precipitation (rain)
83   INTEGER, PARAMETER ::   jpr_snow   = 20            ! solid precipitation over the ocean (snow)
84   INTEGER, PARAMETER ::   jpr_tevp   = 21            ! total evaporation
85   INTEGER, PARAMETER ::   jpr_ievp   = 22            ! solid evaporation (sublimation)
[1232]86   INTEGER, PARAMETER ::   jpr_sbpr   = 23            ! sublimation - liquid precipitation - solid precipitation
[1226]87   INTEGER, PARAMETER ::   jpr_semp   = 24            ! solid freshwater budget (sublimation - snow)
88   INTEGER, PARAMETER ::   jpr_oemp   = 25            ! ocean freshwater budget (evap - precip)
[1696]89   INTEGER, PARAMETER ::   jpr_w10m   = 26            ! 10m wind
90   INTEGER, PARAMETER ::   jpr_dqnsdt = 27            ! d(Q non solar)/d(temperature)
91   INTEGER, PARAMETER ::   jpr_rnf    = 28            ! runoffs
92   INTEGER, PARAMETER ::   jpr_cal    = 29            ! calving
93   INTEGER, PARAMETER ::   jpr_taum   = 30            ! wind stress module
94   INTEGER, PARAMETER ::   jpr_co2    = 31
[3294]95   INTEGER, PARAMETER ::   jpr_topm   = 32            ! topmeltn
96   INTEGER, PARAMETER ::   jpr_botm   = 33            ! botmeltn
[5220]97   INTEGER, PARAMETER ::   jpr_sflx   = 34            ! salt flux
98   INTEGER, PARAMETER ::   jpr_toce   = 35            ! ocean temperature
99   INTEGER, PARAMETER ::   jpr_soce   = 36            ! ocean salinity
100   INTEGER, PARAMETER ::   jpr_ocx1   = 37            ! ocean current on grid 1
101   INTEGER, PARAMETER ::   jpr_ocy1   = 38            !
102   INTEGER, PARAMETER ::   jpr_ssh    = 39            ! sea surface height
103   INTEGER, PARAMETER ::   jpr_fice   = 40            ! ice fraction         
[5299]104   INTEGER, PARAMETER ::   jpr_e3t1st = 41            ! first T level thickness
105   INTEGER, PARAMETER ::   jpr_fraqsr = 42            ! fraction of solar net radiation absorbed in the first ocean level
106   INTEGER, PARAMETER ::   jprcv      = 42            ! total number of fields received
[3294]107
[5299]108   INTEGER, PARAMETER ::   jps_fice   =  1            ! ice fraction sent to the atmosphere
[1218]109   INTEGER, PARAMETER ::   jps_toce   =  2            ! ocean temperature
110   INTEGER, PARAMETER ::   jps_tice   =  3            ! ice   temperature
111   INTEGER, PARAMETER ::   jps_tmix   =  4            ! mixed temperature (ocean+ice)
112   INTEGER, PARAMETER ::   jps_albice =  5            ! ice   albedo
113   INTEGER, PARAMETER ::   jps_albmix =  6            ! mixed albedo
114   INTEGER, PARAMETER ::   jps_hice   =  7            ! ice  thickness
115   INTEGER, PARAMETER ::   jps_hsnw   =  8            ! snow thickness
116   INTEGER, PARAMETER ::   jps_ocx1   =  9            ! ocean current on grid 1
117   INTEGER, PARAMETER ::   jps_ocy1   = 10            !
118   INTEGER, PARAMETER ::   jps_ocz1   = 11            !
119   INTEGER, PARAMETER ::   jps_ivx1   = 12            ! ice   current on grid 1
120   INTEGER, PARAMETER ::   jps_ivy1   = 13            !
121   INTEGER, PARAMETER ::   jps_ivz1   = 14            !
[1534]122   INTEGER, PARAMETER ::   jps_co2    = 15
[5220]123   INTEGER, PARAMETER ::   jps_soce   = 16            ! ocean salinity
124   INTEGER, PARAMETER ::   jps_ssh    = 17            ! sea surface height
125   INTEGER, PARAMETER ::   jps_qsroce = 18            ! Qsr above the ocean
126   INTEGER, PARAMETER ::   jps_qnsoce = 19            ! Qns above the ocean
127   INTEGER, PARAMETER ::   jps_oemp   = 20            ! ocean freshwater budget (evap - precip)
128   INTEGER, PARAMETER ::   jps_sflx   = 21            ! salt flux
129   INTEGER, PARAMETER ::   jps_otx1   = 22            ! 2 atmosphere-ocean stress components on grid 1
130   INTEGER, PARAMETER ::   jps_oty1   = 23            !
131   INTEGER, PARAMETER ::   jps_rnf    = 24            ! runoffs
132   INTEGER, PARAMETER ::   jps_taum   = 25            ! wind stress module
[5299]133   INTEGER, PARAMETER ::   jps_fice2  = 26            ! ice fraction sent to OPA (by SAS when doing SAS-OPA coupling)
134   INTEGER, PARAMETER ::   jps_e3t1st = 27            ! first level depth (vvl)
135   INTEGER, PARAMETER ::   jps_fraqsr = 28            ! fraction of solar net radiation absorbed in the first ocean level
136   INTEGER, PARAMETER ::   jpsnd      = 28            ! total number of fields sended
[3294]137
[1218]138   !                                                         !!** namelist namsbc_cpl **
[3294]139   TYPE ::   FLD_C
140      CHARACTER(len = 32) ::   cldes                  ! desciption of the coupling strategy
141      CHARACTER(len = 32) ::   clcat                  ! multiple ice categories strategy
142      CHARACTER(len = 32) ::   clvref                 ! reference of vector ('spherical' or 'cartesian')
143      CHARACTER(len = 32) ::   clvor                  ! orientation of vector fields ('eastward-northward' or 'local grid')
144      CHARACTER(len = 32) ::   clvgrd                 ! grids on which is located the vector fields
145   END TYPE FLD_C
146   ! Send to the atmosphere                           !
147   TYPE(FLD_C) ::   sn_snd_temp, sn_snd_alb, sn_snd_thick, sn_snd_crt, sn_snd_co2                       
148   ! Received from the atmosphere                     !
149   TYPE(FLD_C) ::   sn_rcv_w10m, sn_rcv_taumod, sn_rcv_tau, sn_rcv_dqnsdt, sn_rcv_qsr, sn_rcv_qns, sn_rcv_emp, sn_rcv_rnf
150   TYPE(FLD_C) ::   sn_rcv_cal, sn_rcv_iceflx, sn_rcv_co2                       
[4990]151   ! Other namelist parameters                        !
152   INTEGER     ::   nn_cplmodel            ! Maximum number of models to/from which NEMO is potentialy sending/receiving data
153   LOGICAL     ::   ln_usecplmask          !  use a coupling mask file to merge data received from several models
154                                           !   -> file cplmask.nc with the float variable called cplmask (jpi,jpj,nn_cplmodel)
[3294]155   TYPE ::   DYNARR     
156      REAL(wp), POINTER, DIMENSION(:,:,:)    ::   z3   
157   END TYPE DYNARR
[888]158
[3294]159   TYPE( DYNARR ), SAVE, DIMENSION(jprcv) ::   frcv                      ! all fields recieved from the atmosphere
160
[2715]161   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   albedo_oce_mix     ! ocean albedo sent to atmosphere (mix clear/overcast sky)
[888]162
[2715]163   INTEGER , ALLOCATABLE, SAVE, DIMENSION(    :) ::   nrcvinfo           ! OASIS info argument
[888]164
[1218]165   !! Substitution
[5299]166#  include "domzgr_substitute.h90"
[1218]167#  include "vectopt_loop_substitute.h90"
168   !!----------------------------------------------------------------------
[2528]169   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
[1226]170   !! $Id$
[2715]171   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
[1218]172   !!----------------------------------------------------------------------
[888]173
[1218]174CONTAINS
175 
[2715]176   INTEGER FUNCTION sbc_cpl_alloc()
177      !!----------------------------------------------------------------------
178      !!             ***  FUNCTION sbc_cpl_alloc  ***
179      !!----------------------------------------------------------------------
[4990]180      INTEGER :: ierr(3)
[2715]181      !!----------------------------------------------------------------------
182      ierr(:) = 0
183      !
[3294]184      ALLOCATE( albedo_oce_mix(jpi,jpj), nrcvinfo(jprcv),  STAT=ierr(1) )
[4990]185     
186#if ! defined key_lim3 && ! defined key_lim2 && ! defined key_cice
187      ALLOCATE( a_i(jpi,jpj,1) , STAT=ierr(2) )  ! used in sbcice_if.F90 (done here as there is no sbc_ice_if_init)
188#endif
[5220]189      ALLOCATE( xcplmask(jpi,jpj,0:nn_cplmodel) , STAT=ierr(3) )
[2715]190      !
191      sbc_cpl_alloc = MAXVAL( ierr )
192      IF( lk_mpp            )   CALL mpp_sum ( sbc_cpl_alloc )
193      IF( sbc_cpl_alloc > 0 )   CALL ctl_warn('sbc_cpl_alloc: allocation of arrays failed')
194      !
195   END FUNCTION sbc_cpl_alloc
196
197
[1218]198   SUBROUTINE sbc_cpl_init( k_ice )     
199      !!----------------------------------------------------------------------
200      !!             ***  ROUTINE sbc_cpl_init  ***
201      !!
[4990]202      !! ** Purpose :   Initialisation of send and received information from
[1218]203      !!                the atmospheric component
204      !!
205      !! ** Method  : * Read namsbc_cpl namelist
206      !!              * define the receive interface
207      !!              * define the send    interface
208      !!              * initialise the OASIS coupler
209      !!----------------------------------------------------------------------
[5220]210      INTEGER, INTENT(in) ::   k_ice       ! ice management in the sbc (=0/1/2/3)
[1218]211      !!
[2715]212      INTEGER ::   jn   ! dummy loop index
[4147]213      INTEGER ::   ios  ! Local integer output status for namelist read
[4990]214      INTEGER ::   inum 
[3294]215      REAL(wp), POINTER, DIMENSION(:,:) ::   zacs, zaos
[1218]216      !!
[4990]217      NAMELIST/namsbc_cpl/  sn_snd_temp, sn_snd_alb   , sn_snd_thick, sn_snd_crt   , sn_snd_co2,      &
218         &                  sn_rcv_w10m, sn_rcv_taumod, sn_rcv_tau  , sn_rcv_dqnsdt, sn_rcv_qsr,      &
219         &                  sn_rcv_qns , sn_rcv_emp   , sn_rcv_rnf  , sn_rcv_cal   , sn_rcv_iceflx,   &
220         &                  sn_rcv_co2 , nn_cplmodel  , ln_usecplmask
[1218]221      !!---------------------------------------------------------------------
[3294]222      !
223      IF( nn_timing == 1 )  CALL timing_start('sbc_cpl_init')
224      !
225      CALL wrk_alloc( jpi,jpj, zacs, zaos )
[888]226
[1218]227      ! ================================ !
228      !      Namelist informations       !
229      ! ================================ !
[888]230
[4147]231      REWIND( numnam_ref )              ! Namelist namsbc_cpl in reference namelist : Variables for OASIS coupling
232      READ  ( numnam_ref, namsbc_cpl, IOSTAT = ios, ERR = 901)
233901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_cpl in reference namelist', lwp )
[3294]234
[4147]235      REWIND( numnam_cfg )              ! Namelist namsbc_cpl in configuration namelist : Variables for OASIS coupling
236      READ  ( numnam_cfg, namsbc_cpl, IOSTAT = ios, ERR = 902 )
237902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_cpl in configuration namelist', lwp )
[4624]238      IF(lwm) WRITE ( numond, namsbc_cpl )
[888]239
[5299]240      IF(lwp) THEN                        ! control print
[1218]241         WRITE(numout,*)
242         WRITE(numout,*)'sbc_cpl_init : namsbc_cpl namelist '
243         WRITE(numout,*)'~~~~~~~~~~~~'
[5299]244      ENDIF
245      IF( lwp .AND. nn_components /= jp_iam_opa .AND. ln_cpl ) THEN                        ! control print
[3294]246         WRITE(numout,*)'  received fields (mutiple ice categogies)'
247         WRITE(numout,*)'      10m wind module                 = ', TRIM(sn_rcv_w10m%cldes  ), ' (', TRIM(sn_rcv_w10m%clcat  ), ')'
248         WRITE(numout,*)'      stress module                   = ', TRIM(sn_rcv_taumod%cldes), ' (', TRIM(sn_rcv_taumod%clcat), ')'
249         WRITE(numout,*)'      surface stress                  = ', TRIM(sn_rcv_tau%cldes   ), ' (', TRIM(sn_rcv_tau%clcat   ), ')'
250         WRITE(numout,*)'                     - referential    = ', sn_rcv_tau%clvref
251         WRITE(numout,*)'                     - orientation    = ', sn_rcv_tau%clvor
252         WRITE(numout,*)'                     - mesh           = ', sn_rcv_tau%clvgrd
253         WRITE(numout,*)'      non-solar heat flux sensitivity = ', TRIM(sn_rcv_dqnsdt%cldes), ' (', TRIM(sn_rcv_dqnsdt%clcat), ')'
254         WRITE(numout,*)'      solar heat flux                 = ', TRIM(sn_rcv_qsr%cldes   ), ' (', TRIM(sn_rcv_qsr%clcat   ), ')'
255         WRITE(numout,*)'      non-solar heat flux             = ', TRIM(sn_rcv_qns%cldes   ), ' (', TRIM(sn_rcv_qns%clcat   ), ')'
256         WRITE(numout,*)'      freshwater budget               = ', TRIM(sn_rcv_emp%cldes   ), ' (', TRIM(sn_rcv_emp%clcat   ), ')'
257         WRITE(numout,*)'      runoffs                         = ', TRIM(sn_rcv_rnf%cldes   ), ' (', TRIM(sn_rcv_rnf%clcat   ), ')'
258         WRITE(numout,*)'      calving                         = ', TRIM(sn_rcv_cal%cldes   ), ' (', TRIM(sn_rcv_cal%clcat   ), ')'
259         WRITE(numout,*)'      sea ice heat fluxes             = ', TRIM(sn_rcv_iceflx%cldes), ' (', TRIM(sn_rcv_iceflx%clcat), ')'
260         WRITE(numout,*)'      atm co2                         = ', TRIM(sn_rcv_co2%cldes   ), ' (', TRIM(sn_rcv_co2%clcat   ), ')'
261         WRITE(numout,*)'  sent fields (multiple ice categories)'
262         WRITE(numout,*)'      surface temperature             = ', TRIM(sn_snd_temp%cldes  ), ' (', TRIM(sn_snd_temp%clcat  ), ')'
263         WRITE(numout,*)'      albedo                          = ', TRIM(sn_snd_alb%cldes   ), ' (', TRIM(sn_snd_alb%clcat   ), ')'
264         WRITE(numout,*)'      ice/snow thickness              = ', TRIM(sn_snd_thick%cldes ), ' (', TRIM(sn_snd_thick%clcat ), ')'
265         WRITE(numout,*)'      surface current                 = ', TRIM(sn_snd_crt%cldes   ), ' (', TRIM(sn_snd_crt%clcat   ), ')'
266         WRITE(numout,*)'                      - referential   = ', sn_snd_crt%clvref 
267         WRITE(numout,*)'                      - orientation   = ', sn_snd_crt%clvor
268         WRITE(numout,*)'                      - mesh          = ', sn_snd_crt%clvgrd
269         WRITE(numout,*)'      oce co2 flux                    = ', TRIM(sn_snd_co2%cldes   ), ' (', TRIM(sn_snd_co2%clcat   ), ')'
[4990]270         WRITE(numout,*)'  nn_cplmodel                         = ', nn_cplmodel
271         WRITE(numout,*)'  ln_usecplmask                       = ', ln_usecplmask
[1218]272      ENDIF
[888]273
[3294]274      !                                   ! allocate sbccpl arrays
[2715]275      IF( sbc_cpl_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'sbc_cpl_alloc : unable to allocate arrays' )
[1218]276     
277      ! ================================ !
278      !   Define the receive interface   !
279      ! ================================ !
[1698]280      nrcvinfo(:) = OASIS_idle   ! needed by nrcvinfo(jpr_otx1) if we do not receive ocean stress
[888]281
[1218]282      ! for each field: define the OASIS name                              (srcv(:)%clname)
283      !                 define receive or not from the namelist parameters (srcv(:)%laction)
284      !                 define the north fold type of lbc                  (srcv(:)%nsgn)
[888]285
[1218]286      ! default definitions of srcv
[3294]287      srcv(:)%laction = .FALSE.   ;   srcv(:)%clgrid = 'T'   ;   srcv(:)%nsgn = 1.   ;   srcv(:)%nct = 1
[888]288
[1218]289      !                                                      ! ------------------------- !
290      !                                                      ! ice and ocean wind stress !   
291      !                                                      ! ------------------------- !
292      !                                                           ! Name
293      srcv(jpr_otx1)%clname = 'O_OTaux1'      ! 1st ocean component on grid ONE (T or U)
294      srcv(jpr_oty1)%clname = 'O_OTauy1'      ! 2nd   -      -         -     -
295      srcv(jpr_otz1)%clname = 'O_OTauz1'      ! 3rd   -      -         -     -
296      srcv(jpr_otx2)%clname = 'O_OTaux2'      ! 1st ocean component on grid TWO (V)
297      srcv(jpr_oty2)%clname = 'O_OTauy2'      ! 2nd   -      -         -     -
298      srcv(jpr_otz2)%clname = 'O_OTauz2'      ! 3rd   -      -         -     -
299      !
300      srcv(jpr_itx1)%clname = 'O_ITaux1'      ! 1st  ice  component on grid ONE (T, F, I or U)
301      srcv(jpr_ity1)%clname = 'O_ITauy1'      ! 2nd   -      -         -     -
302      srcv(jpr_itz1)%clname = 'O_ITauz1'      ! 3rd   -      -         -     -
303      srcv(jpr_itx2)%clname = 'O_ITaux2'      ! 1st  ice  component on grid TWO (V)
304      srcv(jpr_ity2)%clname = 'O_ITauy2'      ! 2nd   -      -         -     -
305      srcv(jpr_itz2)%clname = 'O_ITauz2'      ! 3rd   -      -         -     -
306      !
[1833]307      ! Vectors: change of sign at north fold ONLY if on the local grid
[3294]308      IF( TRIM( sn_rcv_tau%clvor ) == 'local grid' )   srcv(jpr_otx1:jpr_itz2)%nsgn = -1.
[1218]309     
310      !                                                           ! Set grid and action
[3294]311      SELECT CASE( TRIM( sn_rcv_tau%clvgrd ) )      !  'T', 'U,V', 'U,V,I', 'U,V,F', 'T,I', 'T,F', or 'T,U,V'
[1218]312      CASE( 'T' ) 
313         srcv(jpr_otx1:jpr_itz2)%clgrid  = 'T'        ! oce and ice components given at T-point
314         srcv(jpr_otx1:jpr_otz1)%laction = .TRUE.     ! receive oce components on grid 1
315         srcv(jpr_itx1:jpr_itz1)%laction = .TRUE.     ! receive ice components on grid 1
316      CASE( 'U,V' ) 
317         srcv(jpr_otx1:jpr_otz1)%clgrid  = 'U'        ! oce components given at U-point
318         srcv(jpr_otx2:jpr_otz2)%clgrid  = 'V'        !           and           V-point
319         srcv(jpr_itx1:jpr_itz1)%clgrid  = 'U'        ! ice components given at U-point
320         srcv(jpr_itx2:jpr_itz2)%clgrid  = 'V'        !           and           V-point
321         srcv(jpr_otx1:jpr_itz2)%laction = .TRUE.     ! receive oce and ice components on both grid 1 & 2
322      CASE( 'U,V,T' )
323         srcv(jpr_otx1:jpr_otz1)%clgrid  = 'U'        ! oce components given at U-point
324         srcv(jpr_otx2:jpr_otz2)%clgrid  = 'V'        !           and           V-point
325         srcv(jpr_itx1:jpr_itz1)%clgrid  = 'T'        ! ice components given at T-point
326         srcv(jpr_otx1:jpr_otz2)%laction = .TRUE.     ! receive oce components on grid 1 & 2
327         srcv(jpr_itx1:jpr_itz1)%laction = .TRUE.     ! receive ice components on grid 1 only
328      CASE( 'U,V,I' )
329         srcv(jpr_otx1:jpr_otz1)%clgrid  = 'U'        ! oce components given at U-point
330         srcv(jpr_otx2:jpr_otz2)%clgrid  = 'V'        !           and           V-point
331         srcv(jpr_itx1:jpr_itz1)%clgrid  = 'I'        ! ice components given at I-point
332         srcv(jpr_otx1:jpr_otz2)%laction = .TRUE.     ! receive oce components on grid 1 & 2
333         srcv(jpr_itx1:jpr_itz1)%laction = .TRUE.     ! receive ice components on grid 1 only
334      CASE( 'U,V,F' )
335         srcv(jpr_otx1:jpr_otz1)%clgrid  = 'U'        ! oce components given at U-point
336         srcv(jpr_otx2:jpr_otz2)%clgrid  = 'V'        !           and           V-point
337         srcv(jpr_itx1:jpr_itz1)%clgrid  = 'F'        ! ice components given at F-point
338         srcv(jpr_otx1:jpr_otz2)%laction = .TRUE.     ! receive oce components on grid 1 & 2
339         srcv(jpr_itx1:jpr_itz1)%laction = .TRUE.     ! receive ice components on grid 1 only
340      CASE( 'T,I' ) 
341         srcv(jpr_otx1:jpr_itz2)%clgrid  = 'T'        ! oce and ice components given at T-point
342         srcv(jpr_itx1:jpr_itz1)%clgrid  = 'I'        ! ice components given at I-point
343         srcv(jpr_otx1:jpr_otz1)%laction = .TRUE.     ! receive oce components on grid 1
344         srcv(jpr_itx1:jpr_itz1)%laction = .TRUE.     ! receive ice components on grid 1
345      CASE( 'T,F' ) 
346         srcv(jpr_otx1:jpr_itz2)%clgrid  = 'T'        ! oce and ice components given at T-point
347         srcv(jpr_itx1:jpr_itz1)%clgrid  = 'F'        ! ice components given at F-point
348         srcv(jpr_otx1:jpr_otz1)%laction = .TRUE.     ! receive oce components on grid 1
349         srcv(jpr_itx1:jpr_itz1)%laction = .TRUE.     ! receive ice components on grid 1
350      CASE( 'T,U,V' )
351         srcv(jpr_otx1:jpr_otz1)%clgrid  = 'T'        ! oce components given at T-point
352         srcv(jpr_itx1:jpr_itz1)%clgrid  = 'U'        ! ice components given at U-point
353         srcv(jpr_itx2:jpr_itz2)%clgrid  = 'V'        !           and           V-point
354         srcv(jpr_otx1:jpr_otz1)%laction = .TRUE.     ! receive oce components on grid 1 only
355         srcv(jpr_itx1:jpr_itz2)%laction = .TRUE.     ! receive ice components on grid 1 & 2
356      CASE default   
[3294]357         CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_rcv_tau%clvgrd' )
[1218]358      END SELECT
359      !
[3294]360      IF( TRIM( sn_rcv_tau%clvref ) == 'spherical' )   &           ! spherical: 3rd component not received
[1218]361         &     srcv( (/jpr_otz1, jpr_otz2, jpr_itz1, jpr_itz2/) )%laction = .FALSE. 
362      !
[3680]363      IF( TRIM( sn_rcv_tau%clvor  ) == 'local grid' ) THEN        ! already on local grid -> no need of the second grid
364            srcv(jpr_otx2:jpr_otz2)%laction = .FALSE. 
365            srcv(jpr_itx2:jpr_itz2)%laction = .FALSE. 
366            srcv(jpr_oty1)%clgrid = srcv(jpr_oty2)%clgrid   ! not needed but cleaner...
367            srcv(jpr_ity1)%clgrid = srcv(jpr_ity2)%clgrid   ! not needed but cleaner...
368      ENDIF
369      !
[3294]370      IF( TRIM( sn_rcv_tau%cldes ) /= 'oce and ice' ) THEN        ! 'oce and ice' case ocean stress on ocean mesh used
[4162]371         srcv(jpr_itx1:jpr_itz2)%laction = .FALSE.    ! ice components not received
[1218]372         srcv(jpr_itx1)%clgrid = 'U'                  ! ocean stress used after its transformation
373         srcv(jpr_ity1)%clgrid = 'V'                  ! i.e. it is always at U- & V-points for i- & j-comp. resp.
374      ENDIF
375       
376      !                                                      ! ------------------------- !
377      !                                                      !    freshwater budget      !   E-P
378      !                                                      ! ------------------------- !
379      ! we suppose that atmosphere modele do not make the difference between precipiration (liquide or solid)
380      ! over ice of free ocean within the same atmospheric cell.cd
381      srcv(jpr_rain)%clname = 'OTotRain'      ! Rain = liquid precipitation
382      srcv(jpr_snow)%clname = 'OTotSnow'      ! Snow = solid precipitation
383      srcv(jpr_tevp)%clname = 'OTotEvap'      ! total evaporation (over oce + ice sublimation)
384      srcv(jpr_ievp)%clname = 'OIceEvap'      ! evaporation over ice = sublimation
[1232]385      srcv(jpr_sbpr)%clname = 'OSubMPre'      ! sublimation - liquid precipitation - solid precipitation
386      srcv(jpr_semp)%clname = 'OISubMSn'      ! ice solid water budget = sublimation - solid precipitation
387      srcv(jpr_oemp)%clname = 'OOEvaMPr'      ! ocean water budget = ocean Evap - ocean precip
[3294]388      SELECT CASE( TRIM( sn_rcv_emp%cldes ) )
[5220]389      CASE( 'none'          )       ! nothing to do
[1218]390      CASE( 'oce only'      )   ;   srcv(                                 jpr_oemp   )%laction = .TRUE. 
[4162]391      CASE( 'conservative'  )
392         srcv( (/jpr_rain, jpr_snow, jpr_ievp, jpr_tevp/) )%laction = .TRUE.
[4393]393         IF ( k_ice <= 1 )  srcv(jpr_ievp)%laction = .FALSE.
[1232]394      CASE( 'oce and ice'   )   ;   srcv( (/jpr_ievp, jpr_sbpr, jpr_semp, jpr_oemp/) )%laction = .TRUE.
[3294]395      CASE default              ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_rcv_emp%cldes' )
[1218]396      END SELECT
[888]397
[1218]398      !                                                      ! ------------------------- !
399      !                                                      !     Runoffs & Calving     !   
400      !                                                      ! ------------------------- !
[3294]401      srcv(jpr_rnf   )%clname = 'O_Runoff'   ;   IF( TRIM( sn_rcv_rnf%cldes ) == 'coupled' )   srcv(jpr_rnf)%laction = .TRUE.
402! This isn't right - really just want ln_rnf_emp changed
403!                                                 IF( TRIM( sn_rcv_rnf%cldes ) == 'climato' )   THEN   ;   ln_rnf = .TRUE.
404!                                                 ELSE                                                 ;   ln_rnf = .FALSE.
405!                                                 ENDIF
406      srcv(jpr_cal   )%clname = 'OCalving'   ;   IF( TRIM( sn_rcv_cal%cldes ) == 'coupled' )   srcv(jpr_cal)%laction = .TRUE.
[888]407
[1218]408      !                                                      ! ------------------------- !
409      !                                                      !    non solar radiation    !   Qns
410      !                                                      ! ------------------------- !
411      srcv(jpr_qnsoce)%clname = 'O_QnsOce'
412      srcv(jpr_qnsice)%clname = 'O_QnsIce'
413      srcv(jpr_qnsmix)%clname = 'O_QnsMix'
[3294]414      SELECT CASE( TRIM( sn_rcv_qns%cldes ) )
[5220]415      CASE( 'none'          )       ! nothing to do
[1218]416      CASE( 'oce only'      )   ;   srcv(               jpr_qnsoce   )%laction = .TRUE.
417      CASE( 'conservative'  )   ;   srcv( (/jpr_qnsice, jpr_qnsmix/) )%laction = .TRUE.
418      CASE( 'oce and ice'   )   ;   srcv( (/jpr_qnsice, jpr_qnsoce/) )%laction = .TRUE.
419      CASE( 'mixed oce-ice' )   ;   srcv(               jpr_qnsmix   )%laction = .TRUE. 
[3294]420      CASE default              ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_rcv_qns%cldes' )
[1218]421      END SELECT
[3294]422      IF( TRIM( sn_rcv_qns%cldes ) == 'mixed oce-ice' .AND. jpl > 1 ) &
423         CALL ctl_stop( 'sbc_cpl_init: sn_rcv_qns%cldes not currently allowed to be mixed oce-ice for multi-category ice' )
[1218]424      !                                                      ! ------------------------- !
425      !                                                      !    solar radiation        !   Qsr
426      !                                                      ! ------------------------- !
427      srcv(jpr_qsroce)%clname = 'O_QsrOce'
428      srcv(jpr_qsrice)%clname = 'O_QsrIce'
429      srcv(jpr_qsrmix)%clname = 'O_QsrMix'
[3294]430      SELECT CASE( TRIM( sn_rcv_qsr%cldes ) )
[5220]431      CASE( 'none'          )       ! nothing to do
[1218]432      CASE( 'oce only'      )   ;   srcv(               jpr_qsroce   )%laction = .TRUE.
433      CASE( 'conservative'  )   ;   srcv( (/jpr_qsrice, jpr_qsrmix/) )%laction = .TRUE.
434      CASE( 'oce and ice'   )   ;   srcv( (/jpr_qsrice, jpr_qsroce/) )%laction = .TRUE.
435      CASE( 'mixed oce-ice' )   ;   srcv(               jpr_qsrmix   )%laction = .TRUE. 
[3294]436      CASE default              ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_rcv_qsr%cldes' )
[1218]437      END SELECT
[3294]438      IF( TRIM( sn_rcv_qsr%cldes ) == 'mixed oce-ice' .AND. jpl > 1 ) &
439         CALL ctl_stop( 'sbc_cpl_init: sn_rcv_qsr%cldes not currently allowed to be mixed oce-ice for multi-category ice' )
[1218]440      !                                                      ! ------------------------- !
441      !                                                      !   non solar sensitivity   !   d(Qns)/d(T)
442      !                                                      ! ------------------------- !
443      srcv(jpr_dqnsdt)%clname = 'O_dQnsdT'   
[3294]444      IF( TRIM( sn_rcv_dqnsdt%cldes ) == 'coupled' )   srcv(jpr_dqnsdt)%laction = .TRUE.
[1232]445      !
[3294]446      ! non solar sensitivity mandatory for LIM ice model
[5220]447      IF( TRIM( sn_rcv_dqnsdt%cldes ) == 'none' .AND. k_ice /= 0 .AND. k_ice /= 4 .AND. nn_components /= jp_iam_sas ) &
[3294]448         CALL ctl_stop( 'sbc_cpl_init: sn_rcv_dqnsdt%cldes must be coupled in namsbc_cpl namelist' )
[1232]449      ! non solar sensitivity mandatory for mixed oce-ice solar radiation coupling technique
[3294]450      IF( TRIM( sn_rcv_dqnsdt%cldes ) == 'none' .AND. TRIM( sn_rcv_qns%cldes ) == 'mixed oce-ice' ) &
451         CALL ctl_stop( 'sbc_cpl_init: namsbc_cpl namelist mismatch between sn_rcv_qns%cldes and sn_rcv_dqnsdt%cldes' )
[1218]452      !                                                      ! ------------------------- !
453      !                                                      !      10m wind module      !   
454      !                                                      ! ------------------------- !
[3294]455      srcv(jpr_w10m)%clname = 'O_Wind10'   ;   IF( TRIM(sn_rcv_w10m%cldes  ) == 'coupled' )   srcv(jpr_w10m)%laction = .TRUE. 
[1696]456      !
457      !                                                      ! ------------------------- !
458      !                                                      !   wind stress module      !   
459      !                                                      ! ------------------------- !
[3294]460      srcv(jpr_taum)%clname = 'O_TauMod'   ;   IF( TRIM(sn_rcv_taumod%cldes) == 'coupled' )   srcv(jpr_taum)%laction = .TRUE.
[1705]461      lhftau = srcv(jpr_taum)%laction
[1534]462
463      !                                                      ! ------------------------- !
464      !                                                      !      Atmospheric CO2      !
465      !                                                      ! ------------------------- !
[3294]466      srcv(jpr_co2 )%clname = 'O_AtmCO2'   ;   IF( TRIM(sn_rcv_co2%cldes   ) == 'coupled' )    srcv(jpr_co2 )%laction = .TRUE.
467      !                                                      ! ------------------------- !
468      !                                                      !   topmelt and botmelt     !   
469      !                                                      ! ------------------------- !
470      srcv(jpr_topm )%clname = 'OTopMlt'
471      srcv(jpr_botm )%clname = 'OBotMlt'
472      IF( TRIM(sn_rcv_iceflx%cldes) == 'coupled' ) THEN
473         IF ( TRIM( sn_rcv_iceflx%clcat ) == 'yes' ) THEN
474            srcv(jpr_topm:jpr_botm)%nct = jpl
475         ELSE
476            CALL ctl_stop( 'sbc_cpl_init: sn_rcv_iceflx%clcat should always be set to yes currently' )
477         ENDIF
478         srcv(jpr_topm:jpr_botm)%laction = .TRUE.
479      ENDIF
[5220]480      !                                                      ! ------------------------------- !
481      !                                                      !   OPA-SAS coupling - rcv by opa !   
482      !                                                      ! ------------------------------- !
483      srcv(jpr_sflx)%clname = 'O_SFLX'
484      srcv(jpr_fice)%clname = 'RIceFrc'
[5299]485      !
[5220]486      IF( nn_components == jp_iam_opa ) THEN    ! OPA coupled to SAS via OASIS: force received field by OPA (sent by SAS)
487         srcv(:)%laction = .FALSE.   ! force default definition in case of opa <-> sas coupling
[5299]488         srcv( (/jpr_qsroce, jpr_qnsoce, jpr_oemp, jpr_sflx, jpr_fice, jpr_otx1, jpr_oty1, jpr_taum/) )%laction = .TRUE.
489         srcv(jpr_otx1)%clgrid = 'U'        ! oce components given at U-point
490         srcv(jpr_oty1)%clgrid = 'V'        !           and           V-point
[5343]491         ! Vectors: change of sign at north fold ONLY if on the local grid
492         srcv( (/jpr_otx1,jpr_oty1/) )%nsgn = -1.
[5220]493         sn_rcv_tau%clvgrd = 'U,V'
494         sn_rcv_tau%clvor = 'local grid'
495         sn_rcv_tau%clvref = 'spherical'
496         sn_rcv_emp%cldes = 'oce only'
[5299]497         !
[5220]498         IF(lwp) THEN                        ! control print
499            WRITE(numout,*)
500            WRITE(numout,*)'               Special conditions for SAS-OPA coupling  '
501            WRITE(numout,*)'               OPA component  '
502            WRITE(numout,*)
503            WRITE(numout,*)'  received fields from SAS component '
504            WRITE(numout,*)'                  ice cover '
505            WRITE(numout,*)'                  oce only EMP  '
506            WRITE(numout,*)'                  salt flux  '
507            WRITE(numout,*)'                  mixed oce-ice solar flux  '
508            WRITE(numout,*)'                  mixed oce-ice non solar flux  '
509            WRITE(numout,*)'                  wind stress U,V on local grid and sperical coordinates '
510            WRITE(numout,*)'                  wind stress module'
511            WRITE(numout,*)
512         ENDIF
[5299]513      ENDIF
514      !                                                      ! -------------------------------- !
515      !                                                      !   OPA-SAS coupling - rcv by sas  !   
516      !                                                      ! -------------------------------- !
517      srcv(jpr_toce  )%clname = 'I_SSTSST'
518      srcv(jpr_soce  )%clname = 'I_SSSal'
519      srcv(jpr_ocx1  )%clname = 'I_OCurx1'
520      srcv(jpr_ocy1  )%clname = 'I_OCury1'
521      srcv(jpr_ssh   )%clname = 'I_SSHght'
522      srcv(jpr_e3t1st)%clname = 'I_E3T1st'   
523      srcv(jpr_fraqsr)%clname = 'I_FraQsr'   
524      !
525      IF( nn_components == jp_iam_sas ) THEN
[5220]526         IF( .NOT. ln_cpl ) srcv(:)%laction = .FALSE.   ! force default definition in case of opa <-> sas coupling
[5305]527         srcv( (/jpr_toce, jpr_soce, jpr_ssh, jpr_e3t1st, jpr_fraqsr, jpr_ocx1, jpr_ocy1/) )%laction = .TRUE.
[5220]528         ! Vectors: change of sign at north fold ONLY if on the local grid
529         srcv(jpr_ocx1:jpr_ocy1)%nsgn = -1.
530         ! Change first letter to couple with atmosphere if already coupled with sea_ice
531         DO jn = 1, jprcv
532            IF ( srcv(jn)%clname(1:1) == "O" ) srcv(jn)%clname = "S"//srcv(jn)%clname(2:LEN(srcv(jn)%clname))
533         END DO
[5299]534         !
[5220]535         IF(lwp) THEN                        ! control print
[5299]536            WRITE(numout,*)
537            WRITE(numout,*)'               Special conditions for SAS-OPA coupling  '
538            WRITE(numout,*)'               SAS component  '
539            WRITE(numout,*)
[5220]540            IF( .NOT. ln_cpl ) THEN
541               WRITE(numout,*)'  received fields from OPA component '
542            ELSE
543               WRITE(numout,*)'  Additional received fields from OPA component : '
544            ENDIF
[5299]545            WRITE(numout,*)'               sea surface temperature (Celcius) '
[5220]546            WRITE(numout,*)'               sea surface salinity ' 
547            WRITE(numout,*)'               surface currents ' 
548            WRITE(numout,*)'               sea surface height ' 
[5299]549            WRITE(numout,*)'               thickness of first ocean T level '       
550            WRITE(numout,*)'               fraction of solar net radiation absorbed in the first ocean level'
[5220]551            WRITE(numout,*)
552         ENDIF
553      ENDIF
[5299]554     
555      ! =================================================== !
556      ! Allocate all parts of frcv used for received fields !
557      ! =================================================== !
[3294]558      DO jn = 1, jprcv
559         IF ( srcv(jn)%laction ) ALLOCATE( frcv(jn)%z3(jpi,jpj,srcv(jn)%nct) )
560      END DO
561      ! Allocate taum part of frcv which is used even when not received as coupling field
[4990]562      IF ( .NOT. srcv(jpr_taum)%laction ) ALLOCATE( frcv(jpr_taum)%z3(jpi,jpj,srcv(jpr_taum)%nct) )
[5220]563      ! Allocate w10m part of frcv which is used even when not received as coupling field
564      IF ( .NOT. srcv(jpr_w10m)%laction ) ALLOCATE( frcv(jpr_w10m)%z3(jpi,jpj,srcv(jpr_w10m)%nct) )
[5299]565      ! Allocate jpr_otx1 part of frcv which is used even when not received as coupling field
566      IF ( .NOT. srcv(jpr_otx1)%laction ) ALLOCATE( frcv(jpr_otx1)%z3(jpi,jpj,srcv(jpr_otx1)%nct) )
567      IF ( .NOT. srcv(jpr_oty1)%laction ) ALLOCATE( frcv(jpr_oty1)%z3(jpi,jpj,srcv(jpr_oty1)%nct) )
[4162]568      ! Allocate itx1 and ity1 as they are used in sbc_cpl_ice_tau even if srcv(jpr_itx1)%laction = .FALSE.
569      IF( k_ice /= 0 ) THEN
[4990]570         IF ( .NOT. srcv(jpr_itx1)%laction ) ALLOCATE( frcv(jpr_itx1)%z3(jpi,jpj,srcv(jpr_itx1)%nct) )
571         IF ( .NOT. srcv(jpr_ity1)%laction ) ALLOCATE( frcv(jpr_ity1)%z3(jpi,jpj,srcv(jpr_ity1)%nct) )
[4162]572      END IF
[3294]573
[1218]574      ! ================================ !
575      !     Define the send interface    !
576      ! ================================ !
[3294]577      ! for each field: define the OASIS name                           (ssnd(:)%clname)
578      !                 define send or not from the namelist parameters (ssnd(:)%laction)
579      !                 define the north fold type of lbc               (ssnd(:)%nsgn)
[1218]580     
581      ! default definitions of nsnd
[3294]582      ssnd(:)%laction = .FALSE.   ;   ssnd(:)%clgrid = 'T'   ;   ssnd(:)%nsgn = 1.  ; ssnd(:)%nct = 1
[1218]583         
584      !                                                      ! ------------------------- !
585      !                                                      !    Surface temperature    !
586      !                                                      ! ------------------------- !
587      ssnd(jps_toce)%clname = 'O_SSTSST'
588      ssnd(jps_tice)%clname = 'O_TepIce'
589      ssnd(jps_tmix)%clname = 'O_TepMix'
[3294]590      SELECT CASE( TRIM( sn_snd_temp%cldes ) )
[3680]591      CASE( 'none'         )       ! nothing to do
[1218]592      CASE( 'oce only'             )   ;   ssnd(   jps_toce             )%laction = .TRUE.
[3294]593      CASE( 'weighted oce and ice' )
594         ssnd( (/jps_toce, jps_tice/) )%laction = .TRUE.
595         IF ( TRIM( sn_snd_temp%clcat ) == 'yes' )  ssnd(jps_tice)%nct = jpl
[1218]596      CASE( 'mixed oce-ice'        )   ;   ssnd(   jps_tmix             )%laction = .TRUE.
[3294]597      CASE default   ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_snd_temp%cldes' )
[1218]598      END SELECT
[5220]599           
[1218]600      !                                                      ! ------------------------- !
601      !                                                      !          Albedo           !
602      !                                                      ! ------------------------- !
603      ssnd(jps_albice)%clname = 'O_AlbIce' 
604      ssnd(jps_albmix)%clname = 'O_AlbMix'
[3294]605      SELECT CASE( TRIM( sn_snd_alb%cldes ) )
[1218]606      CASE( 'none'          )       ! nothing to do
607      CASE( 'weighted ice'  )   ;   ssnd(jps_albice)%laction = .TRUE.
608      CASE( 'mixed oce-ice' )   ;   ssnd(jps_albmix)%laction = .TRUE.
[3294]609      CASE default   ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_snd_alb%cldes' )
[1218]610      END SELECT
[1232]611      !
612      ! Need to calculate oceanic albedo if
613      !     1. sending mixed oce-ice albedo or
614      !     2. receiving mixed oce-ice solar radiation
[3294]615      IF ( TRIM ( sn_snd_alb%cldes ) == 'mixed oce-ice' .OR. TRIM ( sn_rcv_qsr%cldes ) == 'mixed oce-ice' ) THEN
[1308]616         CALL albedo_oce( zaos, zacs )
617         ! Due to lack of information on nebulosity : mean clear/overcast sky
618         albedo_oce_mix(:,:) = ( zacs(:,:) + zaos(:,:) ) * 0.5
[1232]619      ENDIF
620
[1218]621      !                                                      ! ------------------------- !
622      !                                                      !  Ice fraction & Thickness !
623      !                                                      ! ------------------------- !
[3294]624      ssnd(jps_fice)%clname = 'OIceFrc'
625      ssnd(jps_hice)%clname = 'OIceTck'
626      ssnd(jps_hsnw)%clname = 'OSnwTck'
627      IF( k_ice /= 0 ) THEN
628         ssnd(jps_fice)%laction = .TRUE.                  ! if ice treated in the ocean (even in climato case)
629! Currently no namelist entry to determine sending of multi-category ice fraction so use the thickness entry for now
630         IF ( TRIM( sn_snd_thick%clcat ) == 'yes' ) ssnd(jps_fice)%nct = jpl
631      ENDIF
[5220]632     
[3294]633      SELECT CASE ( TRIM( sn_snd_thick%cldes ) )
[3680]634      CASE( 'none'         )       ! nothing to do
635      CASE( 'ice and snow' ) 
[3294]636         ssnd(jps_hice:jps_hsnw)%laction = .TRUE.
637         IF ( TRIM( sn_snd_thick%clcat ) == 'yes' ) THEN
638            ssnd(jps_hice:jps_hsnw)%nct = jpl
639         ELSE
640            IF ( jpl > 1 ) THEN
[3680]641CALL ctl_stop( 'sbc_cpl_init: use weighted ice and snow option for sn_snd_thick%cldes if not exchanging category fields' )
[3294]642            ENDIF
643         ENDIF
644      CASE ( 'weighted ice and snow' ) 
645         ssnd(jps_hice:jps_hsnw)%laction = .TRUE.
646         IF ( TRIM( sn_snd_thick%clcat ) == 'yes' ) ssnd(jps_hice:jps_hsnw)%nct = jpl
647      CASE default   ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_snd_thick%cldes' )
648      END SELECT
649
[1218]650      !                                                      ! ------------------------- !
651      !                                                      !      Surface current      !
652      !                                                      ! ------------------------- !
653      !        ocean currents              !            ice velocities
654      ssnd(jps_ocx1)%clname = 'O_OCurx1'   ;   ssnd(jps_ivx1)%clname = 'O_IVelx1'
655      ssnd(jps_ocy1)%clname = 'O_OCury1'   ;   ssnd(jps_ivy1)%clname = 'O_IVely1'
656      ssnd(jps_ocz1)%clname = 'O_OCurz1'   ;   ssnd(jps_ivz1)%clname = 'O_IVelz1'
657      !
[2090]658      ssnd(jps_ocx1:jps_ivz1)%nsgn = -1.   ! vectors: change of the sign at the north fold
[1218]659
[3294]660      IF( sn_snd_crt%clvgrd == 'U,V' ) THEN
661         ssnd(jps_ocx1)%clgrid = 'U' ; ssnd(jps_ocy1)%clgrid = 'V'
662      ELSE IF( sn_snd_crt%clvgrd /= 'T' ) THEN 
663         CALL ctl_stop( 'sn_snd_crt%clvgrd must be equal to T' )
664         ssnd(jps_ocx1:jps_ivz1)%clgrid  = 'T'      ! all oce and ice components on the same unique grid
665      ENDIF
[1226]666      ssnd(jps_ocx1:jps_ivz1)%laction = .TRUE.   ! default: all are send
[3294]667      IF( TRIM( sn_snd_crt%clvref ) == 'spherical' )   ssnd( (/jps_ocz1, jps_ivz1/) )%laction = .FALSE. 
668      IF( TRIM( sn_snd_crt%clvor ) == 'eastward-northward' ) ssnd(jps_ocx1:jps_ivz1)%nsgn = 1.
669      SELECT CASE( TRIM( sn_snd_crt%cldes ) )
[1226]670      CASE( 'none'                 )   ;   ssnd(jps_ocx1:jps_ivz1)%laction = .FALSE.
671      CASE( 'oce only'             )   ;   ssnd(jps_ivx1:jps_ivz1)%laction = .FALSE.
[1218]672      CASE( 'weighted oce and ice' )   !   nothing to do
[1226]673      CASE( 'mixed oce-ice'        )   ;   ssnd(jps_ivx1:jps_ivz1)%laction = .FALSE.
[3294]674      CASE default   ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_snd_crt%cldes' )
[1218]675      END SELECT
676
[1534]677      !                                                      ! ------------------------- !
678      !                                                      !          CO2 flux         !
679      !                                                      ! ------------------------- !
[3294]680      ssnd(jps_co2)%clname = 'O_CO2FLX' ;  IF( TRIM(sn_snd_co2%cldes) == 'coupled' )    ssnd(jps_co2 )%laction = .TRUE.
[5220]681
682      !                                                      ! ------------------------------- !
683      !                                                      !   OPA-SAS coupling - snd by opa !   
684      !                                                      ! ------------------------------- !
[5299]685      ssnd(jps_ssh   )%clname = 'O_SSHght' 
686      ssnd(jps_soce  )%clname = 'O_SSSal' 
687      ssnd(jps_e3t1st)%clname = 'O_E3T1st'   
688      ssnd(jps_fraqsr)%clname = 'O_FraQsr'
689      !
[5220]690      IF( nn_components == jp_iam_opa ) THEN
691         ssnd(:)%laction = .FALSE.   ! force default definition in case of opa <-> sas coupling
[5299]692         ssnd( (/jps_toce, jps_soce, jps_ssh, jps_e3t1st, jps_fraqsr, jps_ocx1, jps_ocy1/) )%laction = .TRUE.
693         ! vector definition: not used but cleaner...
[5220]694         ssnd(jps_ocx1)%clgrid  = 'U'        ! oce components given at U-point
695         ssnd(jps_ocy1)%clgrid  = 'V'        !           and           V-point
696         sn_snd_crt%clvgrd = 'U,V'
697         sn_snd_crt%clvor = 'local grid'
698         sn_snd_crt%clvref = 'spherical'
[5299]699         !
[5220]700         IF(lwp) THEN                        ! control print
701            WRITE(numout,*)
702            WRITE(numout,*)'  sent fields to SAS component '
703            WRITE(numout,*)'               sea surface temperature (T before, Celcius) '
704            WRITE(numout,*)'               sea surface salinity ' 
705            WRITE(numout,*)'               surface currents U,V on local grid and spherical coordinates' 
706            WRITE(numout,*)'               sea surface height ' 
[5299]707            WRITE(numout,*)'               thickness of first ocean T level '       
708            WRITE(numout,*)'               fraction of solar net radiation absorbed in the first ocean level'
[5220]709            WRITE(numout,*)
710         ENDIF
[5299]711      ENDIF
712      !                                                      ! ------------------------------- !
713      !                                                      !   OPA-SAS coupling - snd by sas !   
714      !                                                      ! ------------------------------- !
715      ssnd(jps_sflx  )%clname = 'I_SFLX'     
716      ssnd(jps_fice2 )%clname = 'IIceFrc'
717      ssnd(jps_qsroce)%clname = 'I_QsrOce'   
718      ssnd(jps_qnsoce)%clname = 'I_QnsOce'   
719      ssnd(jps_oemp  )%clname = 'IOEvaMPr' 
720      ssnd(jps_otx1  )%clname = 'I_OTaux1'   
721      ssnd(jps_oty1  )%clname = 'I_OTauy1'   
722      ssnd(jps_rnf   )%clname = 'I_Runoff'   
723      ssnd(jps_taum  )%clname = 'I_TauMod'   
724      !
725      IF( nn_components == jp_iam_sas ) THEN
[5220]726         IF( .NOT. ln_cpl ) ssnd(:)%laction = .FALSE.   ! force default definition in case of opa <-> sas coupling
[5299]727         ssnd( (/jps_qsroce, jps_qnsoce, jps_oemp, jps_fice2, jps_sflx, jps_otx1, jps_oty1, jps_taum/) )%laction = .TRUE.
728         !
[5220]729         ! Change first letter to couple with atmosphere if already coupled with sea_ice
[5299]730         ! this is nedeed as each variable name used in the namcouple must be unique:
731         ! for example O_SSTSST sent by OPA to SAS and therefore S_SSTSST sent by SAS to the Atmosphere
[5220]732         DO jn = 1, jpsnd
733            IF ( ssnd(jn)%clname(1:1) == "O" ) ssnd(jn)%clname = "S"//ssnd(jn)%clname(2:LEN(ssnd(jn)%clname))
734         END DO
[5299]735         !
[5220]736         IF(lwp) THEN                        ! control print
[5299]737            WRITE(numout,*)
[5220]738            IF( .NOT. ln_cpl ) THEN
739               WRITE(numout,*)'  sent fields to OPA component '
740            ELSE
741               WRITE(numout,*)'  Additional sent fields to OPA component : '
742            ENDIF
[5299]743            WRITE(numout,*)'                  ice cover '
744            WRITE(numout,*)'                  oce only EMP  '
745            WRITE(numout,*)'                  salt flux  '
746            WRITE(numout,*)'                  mixed oce-ice solar flux  '
747            WRITE(numout,*)'                  mixed oce-ice non solar flux  '
748            WRITE(numout,*)'                  wind stress U,V components'
749            WRITE(numout,*)'                  wind stress module'
[5220]750         ENDIF
751      ENDIF
752
[1534]753      !
[1218]754      ! ================================ !
755      !   initialisation of the coupler  !
756      ! ================================ !
[1226]757
[5220]758      CALL cpl_define(jprcv, jpsnd, nn_cplmodel)           
[4990]759      IF (ln_usecplmask) THEN
760         xcplmask(:,:,:) = 0.
761         CALL iom_open( 'cplmask', inum )
762         CALL iom_get( inum, jpdom_unknown, 'cplmask', xcplmask(1:nlci,1:nlcj,1:nn_cplmodel),   &
763            &          kstart = (/ mig(1),mjg(1),1 /), kcount = (/ nlci,nlcj,nn_cplmodel /) )
764         CALL iom_close( inum )
765      ELSE
766         xcplmask(:,:,:) = 1.
767      ENDIF
[5220]768      xcplmask(:,:,0) = 1. - SUM( xcplmask(:,:,1:nn_cplmodel), dim = 3 )
[1218]769      !
[5220]770      IF( ln_dm2dc .AND. &
771         &   ( cpl_freq( 'O_QsrOce' ) + cpl_freq( 'O_QsrMix' ) + cpl_freq( 'S_QsrOce' ) + cpl_freq( 'S_QsrMix' ) ) /= 86400 )   &
[2528]772         &   CALL ctl_stop( 'sbc_cpl_init: diurnal cycle reconstruction (ln_dm2dc) needs daily couping for solar radiation' )
773
[3294]774      CALL wrk_dealloc( jpi,jpj, zacs, zaos )
[2715]775      !
[3294]776      IF( nn_timing == 1 )  CALL timing_stop('sbc_cpl_init')
777      !
[1218]778   END SUBROUTINE sbc_cpl_init
779
780
781   SUBROUTINE sbc_cpl_rcv( kt, k_fsbc, k_ice )     
782      !!----------------------------------------------------------------------
783      !!             ***  ROUTINE sbc_cpl_rcv  ***
[888]784      !!
[1218]785      !! ** Purpose :   provide the stress over the ocean and, if no sea-ice,
786      !!                provide the ocean heat and freshwater fluxes.
[888]787      !!
[1218]788      !! ** Method  : - Receive all the atmospheric fields (stored in frcv array). called at each time step.
789      !!                OASIS controls if there is something do receive or not. nrcvinfo contains the info
790      !!                to know if the field was really received or not
[888]791      !!
[1218]792      !!              --> If ocean stress was really received:
[888]793      !!
[1218]794      !!                  - transform the received ocean stress vector from the received
795      !!                 referential and grid into an atmosphere-ocean stress in
796      !!                 the (i,j) ocean referencial and at the ocean velocity point.
797      !!                    The received stress are :
798      !!                     - defined by 3 components (if cartesian coordinate)
799      !!                            or by 2 components (if spherical)
800      !!                     - oriented along geographical   coordinate (if eastward-northward)
801      !!                            or  along the local grid coordinate (if local grid)
802      !!                     - given at U- and V-point, resp.   if received on 2 grids
803      !!                            or at T-point               if received on 1 grid
804      !!                    Therefore and if necessary, they are successively
805      !!                  processed in order to obtain them
806      !!                     first  as  2 components on the sphere
807      !!                     second as  2 components oriented along the local grid
808      !!                     third  as  2 components on the U,V grid
[888]809      !!
[1218]810      !!              -->
[888]811      !!
[1218]812      !!              - In 'ocean only' case, non solar and solar ocean heat fluxes
813      !!             and total ocean freshwater fluxes 
814      !!
815      !! ** Method  :   receive all fields from the atmosphere and transform
816      !!              them into ocean surface boundary condition fields
817      !!
818      !! ** Action  :   update  utau, vtau   ocean stress at U,V grid
[4990]819      !!                        taum         wind stress module at T-point
820      !!                        wndm         wind speed  module at T-point over free ocean or leads in presence of sea-ice
[3625]821      !!                        qns          non solar heat fluxes including emp heat content    (ocean only case)
822      !!                                     and the latent heat flux of solid precip. melting
823      !!                        qsr          solar ocean heat fluxes   (ocean only case)
824      !!                        emp          upward mass flux [evap. - precip. (- runoffs) (- calving)] (ocean only case)
[888]825      !!----------------------------------------------------------------------
[5220]826      INTEGER, INTENT(in)           ::   kt          ! ocean model time step index
827      INTEGER, INTENT(in)           ::   k_fsbc      ! frequency of sbc (-> ice model) computation
828      INTEGER, INTENT(in)           ::   k_ice       ! ice management in the sbc (=0/1/2/3)
829
[888]830      !!
[5220]831      LOGICAL  ::   llnewtx, llnewtau      ! update wind stress components and module??
[1218]832      INTEGER  ::   ji, jj, jn             ! dummy loop indices
833      INTEGER  ::   isec                   ! number of seconds since nit000 (assuming rdttra did not change since nit000)
834      REAL(wp) ::   zcumulneg, zcumulpos   ! temporary scalars     
[1226]835      REAL(wp) ::   zcoef                  ! temporary scalar
[1695]836      REAL(wp) ::   zrhoa  = 1.22          ! Air density kg/m3
837      REAL(wp) ::   zcdrag = 1.5e-3        ! drag coefficient
838      REAL(wp) ::   zzx, zzy               ! temporary variables
[5220]839      REAL(wp), POINTER, DIMENSION(:,:) ::   ztx, zty, zmsk, zemp, zqns, zqsr
[1218]840      !!----------------------------------------------------------------------
[3294]841      !
842      IF( nn_timing == 1 )  CALL timing_start('sbc_cpl_rcv')
843      !
[5220]844      CALL wrk_alloc( jpi,jpj, ztx, zty, zmsk, zemp, zqns, zqsr )
845      !
846      IF( ln_mixcpl )   zmsk(:,:) = 1. - xcplmask(:,:,0)
847      !
848      !                                                      ! ======================================================= !
849      !                                                      ! Receive all the atmos. fields (including ice information)
850      !                                                      ! ======================================================= !
851      isec = ( kt - nit000 ) * NINT( rdttra(1) )                ! date of exchanges
852      DO jn = 1, jprcv                                          ! received fields sent by the atmosphere
853         IF( srcv(jn)%laction )   CALL cpl_rcv( jn, isec, frcv(jn)%z3, xcplmask(:,:,1:nn_cplmodel), nrcvinfo(jn) )
[1218]854      END DO
[888]855
[1218]856      !                                                      ! ========================= !
[1696]857      IF( srcv(jpr_otx1)%laction ) THEN                      !  ocean stress components  !
[1218]858         !                                                   ! ========================= !
[3294]859         ! define frcv(jpr_otx1)%z3(:,:,1) and frcv(jpr_oty1)%z3(:,:,1): stress at U/V point along model grid
[1218]860         ! => need to be done only when we receive the field
[1698]861         IF(  nrcvinfo(jpr_otx1) == OASIS_Rcv ) THEN
[1218]862            !
[3294]863            IF( TRIM( sn_rcv_tau%clvref ) == 'cartesian' ) THEN            ! 2 components on the sphere
[1218]864               !                                                       ! (cartesian to spherical -> 3 to 2 components)
865               !
[3294]866               CALL geo2oce( frcv(jpr_otx1)%z3(:,:,1), frcv(jpr_oty1)%z3(:,:,1), frcv(jpr_otz1)%z3(:,:,1),   &
[1218]867                  &          srcv(jpr_otx1)%clgrid, ztx, zty )
[3294]868               frcv(jpr_otx1)%z3(:,:,1) = ztx(:,:)   ! overwrite 1st comp. on the 1st grid
869               frcv(jpr_oty1)%z3(:,:,1) = zty(:,:)   ! overwrite 2nd comp. on the 1st grid
[1218]870               !
871               IF( srcv(jpr_otx2)%laction ) THEN
[3294]872                  CALL geo2oce( frcv(jpr_otx2)%z3(:,:,1), frcv(jpr_oty2)%z3(:,:,1), frcv(jpr_otz2)%z3(:,:,1),   &
[1218]873                     &          srcv(jpr_otx2)%clgrid, ztx, zty )
[3294]874                  frcv(jpr_otx2)%z3(:,:,1) = ztx(:,:)   ! overwrite 1st comp. on the 2nd grid
875                  frcv(jpr_oty2)%z3(:,:,1) = zty(:,:)   ! overwrite 2nd comp. on the 2nd grid
[1218]876               ENDIF
877               !
878            ENDIF
879            !
[3294]880            IF( TRIM( sn_rcv_tau%clvor ) == 'eastward-northward' ) THEN   ! 2 components oriented along the local grid
[1218]881               !                                                       ! (geographical to local grid -> rotate the components)
[3294]882               CALL rot_rep( frcv(jpr_otx1)%z3(:,:,1), frcv(jpr_oty1)%z3(:,:,1), srcv(jpr_otx1)%clgrid, 'en->i', ztx )   
[1218]883               IF( srcv(jpr_otx2)%laction ) THEN
[3294]884                  CALL rot_rep( frcv(jpr_otx2)%z3(:,:,1), frcv(jpr_oty2)%z3(:,:,1), srcv(jpr_otx2)%clgrid, 'en->j', zty )   
885               ELSE 
886                  CALL rot_rep( frcv(jpr_otx1)%z3(:,:,1), frcv(jpr_oty1)%z3(:,:,1), srcv(jpr_otx1)%clgrid, 'en->j', zty ) 
[1218]887               ENDIF
[3632]888               frcv(jpr_otx1)%z3(:,:,1) = ztx(:,:)      ! overwrite 1st component on the 1st grid
[3294]889               frcv(jpr_oty1)%z3(:,:,1) = zty(:,:)      ! overwrite 2nd component on the 2nd grid
[1218]890            ENDIF
891            !                             
892            IF( srcv(jpr_otx1)%clgrid == 'T' ) THEN
893               DO jj = 2, jpjm1                                          ! T ==> (U,V)
894                  DO ji = fs_2, fs_jpim1   ! vector opt.
[3294]895                     frcv(jpr_otx1)%z3(ji,jj,1) = 0.5 * ( frcv(jpr_otx1)%z3(ji+1,jj  ,1) + frcv(jpr_otx1)%z3(ji,jj,1) )
896                     frcv(jpr_oty1)%z3(ji,jj,1) = 0.5 * ( frcv(jpr_oty1)%z3(ji  ,jj+1,1) + frcv(jpr_oty1)%z3(ji,jj,1) )
[1218]897                  END DO
898               END DO
[3294]899               CALL lbc_lnk( frcv(jpr_otx1)%z3(:,:,1), 'U',  -1. )   ;   CALL lbc_lnk( frcv(jpr_oty1)%z3(:,:,1), 'V',  -1. )
[1218]900            ENDIF
[1696]901            llnewtx = .TRUE.
902         ELSE
903            llnewtx = .FALSE.
[1218]904         ENDIF
905         !                                                   ! ========================= !
906      ELSE                                                   !   No dynamical coupling   !
907         !                                                   ! ========================= !
[3294]908         frcv(jpr_otx1)%z3(:,:,1) = 0.e0                               ! here simply set to zero
909         frcv(jpr_oty1)%z3(:,:,1) = 0.e0                               ! an external read in a file can be added instead
[1696]910         llnewtx = .TRUE.
[1218]911         !
912      ENDIF
[1696]913      !                                                      ! ========================= !
914      !                                                      !    wind stress module     !   (taum)
915      !                                                      ! ========================= !
916      !
917      IF( .NOT. srcv(jpr_taum)%laction ) THEN                    ! compute wind stress module from its components if not received
918         ! => need to be done only when otx1 was changed
919         IF( llnewtx ) THEN
[1695]920!CDIR NOVERRCHK
[1696]921            DO jj = 2, jpjm1
[1695]922!CDIR NOVERRCHK
[1696]923               DO ji = fs_2, fs_jpim1   ! vect. opt.
[3294]924                  zzx = frcv(jpr_otx1)%z3(ji-1,jj  ,1) + frcv(jpr_otx1)%z3(ji,jj,1)
925                  zzy = frcv(jpr_oty1)%z3(ji  ,jj-1,1) + frcv(jpr_oty1)%z3(ji,jj,1)
926                  frcv(jpr_taum)%z3(ji,jj,1) = 0.5 * SQRT( zzx * zzx + zzy * zzy )
[1696]927               END DO
[1695]928            END DO
[3294]929            CALL lbc_lnk( frcv(jpr_taum)%z3(:,:,1), 'T', 1. )
[1696]930            llnewtau = .TRUE.
931         ELSE
932            llnewtau = .FALSE.
933         ENDIF
934      ELSE
[1706]935         llnewtau = nrcvinfo(jpr_taum) == OASIS_Rcv
[1726]936         ! Stress module can be negative when received (interpolation problem)
937         IF( llnewtau ) THEN
[3625]938            frcv(jpr_taum)%z3(:,:,1) = MAX( 0._wp, frcv(jpr_taum)%z3(:,:,1) )
[1726]939         ENDIF
[1696]940      ENDIF
[5299]941      !
[1696]942      !                                                      ! ========================= !
943      !                                                      !      10 m wind speed      !   (wndm)
944      !                                                      ! ========================= !
945      !
946      IF( .NOT. srcv(jpr_w10m)%laction ) THEN                    ! compute wind spreed from wind stress module if not received 
947         ! => need to be done only when taumod was changed
948         IF( llnewtau ) THEN
[1695]949            zcoef = 1. / ( zrhoa * zcdrag ) 
[1697]950!CDIR NOVERRCHK
[1695]951            DO jj = 1, jpj
[1697]952!CDIR NOVERRCHK
[1695]953               DO ji = 1, jpi 
[5220]954                  frcv(jpr_w10m)%z3(ji,jj,1) = SQRT( frcv(jpr_taum)%z3(ji,jj,1) * zcoef )
[1695]955               END DO
956            END DO
957         ENDIF
[1696]958      ENDIF
959
[3294]960      ! u(v)tau and taum will be modified by ice model
[1696]961      ! -> need to be reset before each call of the ice/fsbc     
962      IF( MOD( kt-1, k_fsbc ) == 0 ) THEN
963         !
[5220]964         IF( ln_mixcpl ) THEN
965            utau(:,:) = utau(:,:) * xcplmask(:,:,0) + frcv(jpr_otx1)%z3(:,:,1) * zmsk(:,:)
966            vtau(:,:) = vtau(:,:) * xcplmask(:,:,0) + frcv(jpr_oty1)%z3(:,:,1) * zmsk(:,:)
967            taum(:,:) = taum(:,:) * xcplmask(:,:,0) + frcv(jpr_taum)%z3(:,:,1) * zmsk(:,:)
968            wndm(:,:) = wndm(:,:) * xcplmask(:,:,0) + frcv(jpr_w10m)%z3(:,:,1) * zmsk(:,:)
969         ELSE
970            utau(:,:) = frcv(jpr_otx1)%z3(:,:,1)
971            vtau(:,:) = frcv(jpr_oty1)%z3(:,:,1)
972            taum(:,:) = frcv(jpr_taum)%z3(:,:,1)
973            wndm(:,:) = frcv(jpr_w10m)%z3(:,:,1)
974         ENDIF
[1705]975         CALL iom_put( "taum_oce", taum )   ! output wind stress module
[1695]976         
[1218]977      ENDIF
[3294]978
979#if defined key_cpl_carbon_cycle
[5220]980      !                                                      ! ================== !
981      !                                                      ! atmosph. CO2 (ppm) !
982      !                                                      ! ================== !
[3294]983      IF( srcv(jpr_co2)%laction )   atm_co2(:,:) = frcv(jpr_co2)%z3(:,:,1)
984#endif
985
[5220]986      !  Fields received by ice model when OASIS coupling
987      !  (arrays no more filled at sbcssm stage)
988      !                                                      ! ================== !
989      !                                                      !        SSS         !
990      !                                                      ! ================== !
991      IF( srcv(jpr_soce)%laction ) THEN                      ! received by sas in case of opa <-> sas coupling
992         sss_m(:,:) = frcv(jpr_soce)%z3(:,:,1)
993         tsn(:,:,1,jp_sal) = sss_m(:,:)
994      ENDIF
[5343]995      !                                               
[5220]996      !                                                      ! ================== !
[5343]997      !                                                      !        SST         !
998      !                                                      ! ================== !
999      IF( srcv(jpr_toce)%laction ) THEN                      ! received by sas in case of opa <-> sas coupling
1000         sst_m(:,:) = frcv(jpr_toce)%z3(:,:,1)
1001         tsn(:,:,1,jp_tem) = sst_m(:,:)                      ! keep the received (potential or conservative) temperature in tsn
1002         IF( srcv(jpr_soce)%laction .AND. ln_useCT ) THEN    ! make sure that sst_m is the potential temperature
1003            sst_m(:,:) = eos_pt_from_ct( sst_m(:,:), sss_m(:,:) )
1004         ENDIF
1005      ENDIF
1006      !                                                      ! ================== !
[5220]1007      !                                                      !        SSH         !
1008      !                                                      ! ================== !
[5299]1009      IF( srcv(jpr_ssh )%laction ) THEN                      ! received by sas in case of opa <-> sas coupling
1010         ssh_m(:,:) = frcv(jpr_ssh )%z3(:,:,1)
1011         sshn( :,:) = ssh_m(:,:)
1012      ENDIF
[5220]1013      !                                                      ! ================== !
1014      !                                                      !  surface currents  !
1015      !                                                      ! ================== !
[5299]1016      IF( srcv(jpr_ocx1)%laction ) THEN                      ! received by sas in case of opa <-> sas coupling
[5220]1017         ssu_m(:,:) = frcv(jpr_ocx1)%z3(:,:,1)
[5299]1018         ub (:,:,1) = ssu_m(:,:)
[5220]1019      ENDIF
1020      IF( srcv(jpr_ocy1)%laction ) THEN
1021         ssv_m(:,:) = frcv(jpr_ocy1)%z3(:,:,1)
[5299]1022         vb (:,:,1) = ssv_m(:,:)
[5220]1023      ENDIF
[5299]1024      !                                                      ! ======================== !
1025      !                                                      !  first T level thickness !
1026      !                                                      ! ======================== !
1027      IF( srcv(jpr_e3t1st )%laction ) THEN                   ! received by sas in case of opa <-> sas coupling
1028         fse3t_m(:,:) = frcv(jpr_e3t1st )%z3(:,:,1)
1029      ENDIF
1030      !                                                      ! ================================ !
1031      !                                                      !  fraction of solar net radiation !
1032      !                                                      ! ================================ !
[5352]1033      IF( srcv(jpr_fraqsr)%laction ) THEN                    ! received by sas in case of opa <-> sas coupling
1034         frq_m(:,:) = frcv(jpr_fraqsr)%z3(:,:,1)
[5299]1035      ENDIF
[5220]1036     
[1218]1037      !                                                      ! ========================= !
[5220]1038      IF( k_ice <= 1 .AND. MOD( kt-1, k_fsbc ) == 0 ) THEN   !  heat & freshwater fluxes ! (Ocean only case)
[1218]1039         !                                                   ! ========================= !
1040         !
[3625]1041         !                                                       ! total freshwater fluxes over the ocean (emp)
[5220]1042         IF( srcv(jpr_oemp)%laction .OR. srcv(jpr_rain)%laction ) THEN
1043            SELECT CASE( TRIM( sn_rcv_emp%cldes ) )                                    ! evaporation - precipitation
1044            CASE( 'conservative' )
1045               zemp(:,:) = frcv(jpr_tevp)%z3(:,:,1) - ( frcv(jpr_rain)%z3(:,:,1) + frcv(jpr_snow)%z3(:,:,1) )
1046            CASE( 'oce only', 'oce and ice' )
1047               zemp(:,:) = frcv(jpr_oemp)%z3(:,:,1)
1048            CASE default
1049               CALL ctl_stop( 'sbc_cpl_rcv: wrong definition of sn_rcv_emp%cldes' )
1050            END SELECT
1051         ELSE
1052            zemp(:,:) = 0._wp
1053         ENDIF
[1218]1054         !
1055         !                                                        ! runoffs and calving (added in emp)
[5220]1056         IF( srcv(jpr_rnf)%laction )   zemp(:,:) = zemp(:,:) - frcv(jpr_rnf)%z3(:,:,1)
1057         IF( srcv(jpr_cal)%laction )   zemp(:,:) = zemp(:,:) - frcv(jpr_cal)%z3(:,:,1)
1058         
1059         IF( ln_mixcpl ) THEN   ;   emp(:,:) = emp(:,:) * xcplmask(:,:,0) + zemp(:,:) * zmsk(:,:)
1060         ELSE                   ;   emp(:,:) =                              zemp(:,:)
1061         ENDIF
[1218]1062         !
[3625]1063         !                                                       ! non solar heat flux over the ocean (qns)
[5220]1064         IF(      srcv(jpr_qnsoce)%laction ) THEN   ;   zqns(:,:) = frcv(jpr_qnsoce)%z3(:,:,1)
1065         ELSE IF( srcv(jpr_qnsmix)%laction ) THEN   ;   zqns(:,:) = frcv(jpr_qnsmix)%z3(:,:,1)
1066         ELSE                                       ;   zqns(:,:) = 0._wp
1067         END IF
[4990]1068         ! update qns over the free ocean with:
[5343]1069         IF( nn_components /= jp_iam_opa ) THEN
1070            zqns(:,:) =  zqns(:,:) - zemp(:,:) * sst_m(:,:) * rcp         ! remove heat content due to mass flux (assumed to be at SST)
1071            IF( srcv(jpr_snow  )%laction ) THEN
1072               zqns(:,:) = zqns(:,:) - frcv(jpr_snow)%z3(:,:,1) * lfus    ! energy for melting solid precipitation over the free ocean
1073            ENDIF
[3625]1074         ENDIF
[5220]1075         IF( ln_mixcpl ) THEN   ;   qns(:,:) = qns(:,:) * xcplmask(:,:,0) + zqns(:,:) * zmsk(:,:)
1076         ELSE                   ;   qns(:,:) =                              zqns(:,:)
1077         ENDIF
[3625]1078
1079         !                                                       ! solar flux over the ocean          (qsr)
[5220]1080         IF     ( srcv(jpr_qsroce)%laction ) THEN   ;   zqsr(:,:) = frcv(jpr_qsroce)%z3(:,:,1)
1081         ELSE IF( srcv(jpr_qsrmix)%laction ) then   ;   zqsr(:,:) = frcv(jpr_qsrmix)%z3(:,:,1)
1082         ELSE                                       ;   zqsr(:,:) = 0._wp
1083         ENDIF
[5343]1084         IF( ln_dm2dc .AND. nn_components /= jp_iam_opa )   zqsr(:,:) = sbc_dcy( zqsr )   ! modify qsr to include the diurnal cycle
[5220]1085         IF( ln_mixcpl ) THEN   ;   qsr(:,:) = qsr(:,:) * xcplmask(:,:,0) + zqsr(:,:) * zmsk(:,:)
1086         ELSE                   ;   qsr(:,:) =                              zqsr(:,:)
1087         ENDIF
[3625]1088         !
[5220]1089         ! salt flux over the ocean (received by opa in case of opa <-> sas coupling)
1090         IF( srcv(jpr_sflx )%laction )   sfx(:,:) = frcv(jpr_sflx  )%z3(:,:,1)
1091         ! Ice cover  (received by opa in case of opa <-> sas coupling)
1092         IF( srcv(jpr_fice )%laction )   fr_i(:,:) = frcv(jpr_fice )%z3(:,:,1)
1093         !
1094
[1218]1095      ENDIF
1096      !
[5220]1097      CALL wrk_dealloc( jpi,jpj, ztx, zty, zmsk, zemp, zqns, zqsr )
[2715]1098      !
[3294]1099      IF( nn_timing == 1 )  CALL timing_stop('sbc_cpl_rcv')
1100      !
[1218]1101   END SUBROUTINE sbc_cpl_rcv
1102   
1103
1104   SUBROUTINE sbc_cpl_ice_tau( p_taui, p_tauj )     
1105      !!----------------------------------------------------------------------
1106      !!             ***  ROUTINE sbc_cpl_ice_tau  ***
1107      !!
1108      !! ** Purpose :   provide the stress over sea-ice in coupled mode
1109      !!
1110      !! ** Method  :   transform the received stress from the atmosphere into
1111      !!             an atmosphere-ice stress in the (i,j) ocean referencial
[2528]1112      !!             and at the velocity point of the sea-ice model (cp_ice_msh):
[1218]1113      !!                'C'-grid : i- (j-) components given at U- (V-) point
[2528]1114      !!                'I'-grid : B-grid lower-left corner: both components given at I-point
[1218]1115      !!
1116      !!                The received stress are :
1117      !!                 - defined by 3 components (if cartesian coordinate)
1118      !!                        or by 2 components (if spherical)
1119      !!                 - oriented along geographical   coordinate (if eastward-northward)
1120      !!                        or  along the local grid coordinate (if local grid)
1121      !!                 - given at U- and V-point, resp.   if received on 2 grids
1122      !!                        or at a same point (T or I) if received on 1 grid
1123      !!                Therefore and if necessary, they are successively
1124      !!             processed in order to obtain them
1125      !!                 first  as  2 components on the sphere
1126      !!                 second as  2 components oriented along the local grid
[2528]1127      !!                 third  as  2 components on the cp_ice_msh point
[1218]1128      !!
[4148]1129      !!                Except in 'oce and ice' case, only one vector stress field
[1218]1130      !!             is received. It has already been processed in sbc_cpl_rcv
1131      !!             so that it is now defined as (i,j) components given at U-
[4148]1132      !!             and V-points, respectively. Therefore, only the third
[2528]1133      !!             transformation is done and only if the ice-grid is a 'I'-grid.
[1218]1134      !!
[2528]1135      !! ** Action  :   return ptau_i, ptau_j, the stress over the ice at cp_ice_msh point
[1218]1136      !!----------------------------------------------------------------------
[2715]1137      REAL(wp), INTENT(out), DIMENSION(:,:) ::   p_taui   ! i- & j-components of atmos-ice stress [N/m2]
1138      REAL(wp), INTENT(out), DIMENSION(:,:) ::   p_tauj   ! at I-point (B-grid) or U & V-point (C-grid)
1139      !!
[1218]1140      INTEGER ::   ji, jj                          ! dummy loop indices
1141      INTEGER ::   itx                             ! index of taux over ice
[3294]1142      REAL(wp), POINTER, DIMENSION(:,:) ::   ztx, zty 
[1218]1143      !!----------------------------------------------------------------------
[3294]1144      !
1145      IF( nn_timing == 1 )  CALL timing_start('sbc_cpl_ice_tau')
1146      !
1147      CALL wrk_alloc( jpi,jpj, ztx, zty )
[1218]1148
[4990]1149      IF( srcv(jpr_itx1)%laction ) THEN   ;   itx =  jpr_itx1   
[1218]1150      ELSE                                ;   itx =  jpr_otx1
1151      ENDIF
1152
1153      ! do something only if we just received the stress from atmosphere
[1698]1154      IF(  nrcvinfo(itx) == OASIS_Rcv ) THEN
[1218]1155
[4990]1156         !                                                      ! ======================= !
1157         IF( srcv(jpr_itx1)%laction ) THEN                      !   ice stress received   !
1158            !                                                   ! ======================= !
[1218]1159           
[3294]1160            IF( TRIM( sn_rcv_tau%clvref ) == 'cartesian' ) THEN            ! 2 components on the sphere
[1218]1161               !                                                       ! (cartesian to spherical -> 3 to 2 components)
[3294]1162               CALL geo2oce(  frcv(jpr_itx1)%z3(:,:,1), frcv(jpr_ity1)%z3(:,:,1), frcv(jpr_itz1)%z3(:,:,1),   &
[1218]1163                  &          srcv(jpr_itx1)%clgrid, ztx, zty )
[3294]1164               frcv(jpr_itx1)%z3(:,:,1) = ztx(:,:)   ! overwrite 1st comp. on the 1st grid
1165               frcv(jpr_ity1)%z3(:,:,1) = zty(:,:)   ! overwrite 2nd comp. on the 1st grid
[1218]1166               !
1167               IF( srcv(jpr_itx2)%laction ) THEN
[3294]1168                  CALL geo2oce( frcv(jpr_itx2)%z3(:,:,1), frcv(jpr_ity2)%z3(:,:,1), frcv(jpr_itz2)%z3(:,:,1),   &
[1218]1169                     &          srcv(jpr_itx2)%clgrid, ztx, zty )
[3294]1170                  frcv(jpr_itx2)%z3(:,:,1) = ztx(:,:)   ! overwrite 1st comp. on the 2nd grid
1171                  frcv(jpr_ity2)%z3(:,:,1) = zty(:,:)   ! overwrite 2nd comp. on the 2nd grid
[1218]1172               ENDIF
1173               !
[888]1174            ENDIF
[1218]1175            !
[3294]1176            IF( TRIM( sn_rcv_tau%clvor ) == 'eastward-northward' ) THEN   ! 2 components oriented along the local grid
[1218]1177               !                                                       ! (geographical to local grid -> rotate the components)
[3294]1178               CALL rot_rep( frcv(jpr_itx1)%z3(:,:,1), frcv(jpr_ity1)%z3(:,:,1), srcv(jpr_itx1)%clgrid, 'en->i', ztx )   
[1218]1179               IF( srcv(jpr_itx2)%laction ) THEN
[3294]1180                  CALL rot_rep( frcv(jpr_itx2)%z3(:,:,1), frcv(jpr_ity2)%z3(:,:,1), srcv(jpr_itx2)%clgrid, 'en->j', zty )   
[1218]1181               ELSE
[3294]1182                  CALL rot_rep( frcv(jpr_itx1)%z3(:,:,1), frcv(jpr_ity1)%z3(:,:,1), srcv(jpr_itx1)%clgrid, 'en->j', zty ) 
[1218]1183               ENDIF
[3632]1184               frcv(jpr_itx1)%z3(:,:,1) = ztx(:,:)      ! overwrite 1st component on the 1st grid
[3294]1185               frcv(jpr_ity1)%z3(:,:,1) = zty(:,:)      ! overwrite 2nd component on the 1st grid
[1218]1186            ENDIF
1187            !                                                   ! ======================= !
1188         ELSE                                                   !     use ocean stress    !
1189            !                                                   ! ======================= !
[3294]1190            frcv(jpr_itx1)%z3(:,:,1) = frcv(jpr_otx1)%z3(:,:,1)
1191            frcv(jpr_ity1)%z3(:,:,1) = frcv(jpr_oty1)%z3(:,:,1)
[1218]1192            !
1193         ENDIF
1194         !                                                      ! ======================= !
1195         !                                                      !     put on ice grid     !
1196         !                                                      ! ======================= !
1197         !   
1198         !                                                  j+1   j     -----V---F
[2528]1199         ! ice stress on ice velocity point (cp_ice_msh)                 !       |
[1467]1200         ! (C-grid ==>(U,V) or B-grid ==> I or F)                 j      |   T   U
[1218]1201         !                                                               |       |
1202         !                                                   j    j-1   -I-------|
1203         !                                               (for I)         |       |
1204         !                                                              i-1  i   i
1205         !                                                               i      i+1 (for I)
[2528]1206         SELECT CASE ( cp_ice_msh )
[1218]1207            !
[1467]1208         CASE( 'I' )                                         ! B-grid ==> I
[1218]1209            SELECT CASE ( srcv(jpr_itx1)%clgrid )
1210            CASE( 'U' )
1211               DO jj = 2, jpjm1                                   ! (U,V) ==> I
[1694]1212                  DO ji = 2, jpim1   ! NO vector opt.
[3294]1213                     p_taui(ji,jj) = 0.5 * ( frcv(jpr_itx1)%z3(ji-1,jj  ,1) + frcv(jpr_itx1)%z3(ji-1,jj-1,1) )
1214                     p_tauj(ji,jj) = 0.5 * ( frcv(jpr_ity1)%z3(ji  ,jj-1,1) + frcv(jpr_ity1)%z3(ji-1,jj-1,1) )
[1218]1215                  END DO
1216               END DO
1217            CASE( 'F' )
1218               DO jj = 2, jpjm1                                   ! F ==> I
[1694]1219                  DO ji = 2, jpim1   ! NO vector opt.
[3294]1220                     p_taui(ji,jj) = frcv(jpr_itx1)%z3(ji-1,jj-1,1)
1221                     p_tauj(ji,jj) = frcv(jpr_ity1)%z3(ji-1,jj-1,1)
[1218]1222                  END DO
1223               END DO
1224            CASE( 'T' )
1225               DO jj = 2, jpjm1                                   ! T ==> I
[1694]1226                  DO ji = 2, jpim1   ! NO vector opt.
[3294]1227                     p_taui(ji,jj) = 0.25 * ( frcv(jpr_itx1)%z3(ji,jj  ,1) + frcv(jpr_itx1)%z3(ji-1,jj  ,1)   &
1228                        &                   + frcv(jpr_itx1)%z3(ji,jj-1,1) + frcv(jpr_itx1)%z3(ji-1,jj-1,1) ) 
1229                     p_tauj(ji,jj) = 0.25 * ( frcv(jpr_ity1)%z3(ji,jj  ,1) + frcv(jpr_ity1)%z3(ji-1,jj  ,1)   &
1230                        &                   + frcv(jpr_oty1)%z3(ji,jj-1,1) + frcv(jpr_ity1)%z3(ji-1,jj-1,1) )
[1218]1231                  END DO
1232               END DO
1233            CASE( 'I' )
[3294]1234               p_taui(:,:) = frcv(jpr_itx1)%z3(:,:,1)                   ! I ==> I
1235               p_tauj(:,:) = frcv(jpr_ity1)%z3(:,:,1)
[1218]1236            END SELECT
1237            IF( srcv(jpr_itx1)%clgrid /= 'I' ) THEN
1238               CALL lbc_lnk( p_taui, 'I',  -1. )   ;   CALL lbc_lnk( p_tauj, 'I',  -1. )
1239            ENDIF
1240            !
[1467]1241         CASE( 'F' )                                         ! B-grid ==> F
1242            SELECT CASE ( srcv(jpr_itx1)%clgrid )
1243            CASE( 'U' )
1244               DO jj = 2, jpjm1                                   ! (U,V) ==> F
1245                  DO ji = fs_2, fs_jpim1   ! vector opt.
[3294]1246                     p_taui(ji,jj) = 0.5 * ( frcv(jpr_itx1)%z3(ji,jj,1) + frcv(jpr_itx1)%z3(ji  ,jj+1,1) )
1247                     p_tauj(ji,jj) = 0.5 * ( frcv(jpr_ity1)%z3(ji,jj,1) + frcv(jpr_ity1)%z3(ji+1,jj  ,1) )
[1467]1248                  END DO
1249               END DO
1250            CASE( 'I' )
1251               DO jj = 2, jpjm1                                   ! I ==> F
[1694]1252                  DO ji = 2, jpim1   ! NO vector opt.
[3294]1253                     p_taui(ji,jj) = frcv(jpr_itx1)%z3(ji+1,jj+1,1)
1254                     p_tauj(ji,jj) = frcv(jpr_ity1)%z3(ji+1,jj+1,1)
[1467]1255                  END DO
1256               END DO
1257            CASE( 'T' )
1258               DO jj = 2, jpjm1                                   ! T ==> F
[1694]1259                  DO ji = 2, jpim1   ! NO vector opt.
[3294]1260                     p_taui(ji,jj) = 0.25 * ( frcv(jpr_itx1)%z3(ji,jj  ,1) + frcv(jpr_itx1)%z3(ji+1,jj  ,1)   &
1261                        &                   + frcv(jpr_itx1)%z3(ji,jj+1,1) + frcv(jpr_itx1)%z3(ji+1,jj+1,1) ) 
1262                     p_tauj(ji,jj) = 0.25 * ( frcv(jpr_ity1)%z3(ji,jj  ,1) + frcv(jpr_ity1)%z3(ji+1,jj  ,1)   &
1263                        &                   + frcv(jpr_ity1)%z3(ji,jj+1,1) + frcv(jpr_ity1)%z3(ji+1,jj+1,1) )
[1467]1264                  END DO
1265               END DO
1266            CASE( 'F' )
[3294]1267               p_taui(:,:) = frcv(jpr_itx1)%z3(:,:,1)                   ! F ==> F
1268               p_tauj(:,:) = frcv(jpr_ity1)%z3(:,:,1)
[1467]1269            END SELECT
1270            IF( srcv(jpr_itx1)%clgrid /= 'F' ) THEN
1271               CALL lbc_lnk( p_taui, 'F',  -1. )   ;   CALL lbc_lnk( p_tauj, 'F',  -1. )
1272            ENDIF
1273            !
[1218]1274         CASE( 'C' )                                         ! C-grid ==> U,V
1275            SELECT CASE ( srcv(jpr_itx1)%clgrid )
1276            CASE( 'U' )
[3294]1277               p_taui(:,:) = frcv(jpr_itx1)%z3(:,:,1)                   ! (U,V) ==> (U,V)
1278               p_tauj(:,:) = frcv(jpr_ity1)%z3(:,:,1)
[1218]1279            CASE( 'F' )
1280               DO jj = 2, jpjm1                                   ! F ==> (U,V)
1281                  DO ji = fs_2, fs_jpim1   ! vector opt.
[3294]1282                     p_taui(ji,jj) = 0.5 * ( frcv(jpr_itx1)%z3(ji,jj,1) + frcv(jpr_itx1)%z3(ji  ,jj-1,1) )
1283                     p_tauj(ji,jj) = 0.5 * ( frcv(jpr_ity1)%z3(jj,jj,1) + frcv(jpr_ity1)%z3(ji-1,jj  ,1) )
[1218]1284                  END DO
1285               END DO
1286            CASE( 'T' )
1287               DO jj = 2, jpjm1                                   ! T ==> (U,V)
1288                  DO ji = fs_2, fs_jpim1   ! vector opt.
[3294]1289                     p_taui(ji,jj) = 0.5 * ( frcv(jpr_itx1)%z3(ji+1,jj  ,1) + frcv(jpr_itx1)%z3(ji,jj,1) )
1290                     p_tauj(ji,jj) = 0.5 * ( frcv(jpr_ity1)%z3(ji  ,jj+1,1) + frcv(jpr_ity1)%z3(ji,jj,1) )
[1218]1291                  END DO
1292               END DO
1293            CASE( 'I' )
1294               DO jj = 2, jpjm1                                   ! I ==> (U,V)
[1694]1295                  DO ji = 2, jpim1   ! NO vector opt.
[3294]1296                     p_taui(ji,jj) = 0.5 * ( frcv(jpr_itx1)%z3(ji+1,jj+1,1) + frcv(jpr_itx1)%z3(ji+1,jj  ,1) )
1297                     p_tauj(ji,jj) = 0.5 * ( frcv(jpr_ity1)%z3(ji+1,jj+1,1) + frcv(jpr_ity1)%z3(ji  ,jj+1,1) )
[1218]1298                  END DO
1299               END DO
1300            END SELECT
1301            IF( srcv(jpr_itx1)%clgrid /= 'U' ) THEN
1302               CALL lbc_lnk( p_taui, 'U',  -1. )   ;   CALL lbc_lnk( p_tauj, 'V',  -1. )
1303            ENDIF
1304         END SELECT
1305
1306      ENDIF
1307      !   
[3294]1308      CALL wrk_dealloc( jpi,jpj, ztx, zty )
[2715]1309      !
[3294]1310      IF( nn_timing == 1 )  CALL timing_stop('sbc_cpl_ice_tau')
1311      !
[1218]1312   END SUBROUTINE sbc_cpl_ice_tau
1313   
1314
[5220]1315   SUBROUTINE sbc_cpl_ice_flx( p_frld, palbi, psst, pist )
[1218]1316      !!----------------------------------------------------------------------
[3294]1317      !!             ***  ROUTINE sbc_cpl_ice_flx  ***
[1218]1318      !!
1319      !! ** Purpose :   provide the heat and freshwater fluxes of the
1320      !!              ocean-ice system.
1321      !!
1322      !! ** Method  :   transform the fields received from the atmosphere into
1323      !!             surface heat and fresh water boundary condition for the
1324      !!             ice-ocean system. The following fields are provided:
1325      !!              * total non solar, solar and freshwater fluxes (qns_tot,
1326      !!             qsr_tot and emp_tot) (total means weighted ice-ocean flux)
1327      !!             NB: emp_tot include runoffs and calving.
1328      !!              * fluxes over ice (qns_ice, qsr_ice, emp_ice) where
1329      !!             emp_ice = sublimation - solid precipitation as liquid
1330      !!             precipitation are re-routed directly to the ocean and
1331      !!             runoffs and calving directly enter the ocean.
1332      !!              * solid precipitation (sprecip), used to add to qns_tot
1333      !!             the heat lost associated to melting solid precipitation
1334      !!             over the ocean fraction.
1335      !!       ===>> CAUTION here this changes the net heat flux received from
1336      !!             the atmosphere
1337      !!
1338      !!                  - the fluxes have been separated from the stress as
1339      !!                 (a) they are updated at each ice time step compare to
1340      !!                 an update at each coupled time step for the stress, and
1341      !!                 (b) the conservative computation of the fluxes over the
1342      !!                 sea-ice area requires the knowledge of the ice fraction
1343      !!                 after the ice advection and before the ice thermodynamics,
1344      !!                 so that the stress is updated before the ice dynamics
1345      !!                 while the fluxes are updated after it.
1346      !!
1347      !! ** Action  :   update at each nf_ice time step:
[3294]1348      !!                   qns_tot, qsr_tot  non-solar and solar total heat fluxes
1349      !!                   qns_ice, qsr_ice  non-solar and solar heat fluxes over the ice
1350      !!                   emp_tot            total evaporation - precipitation(liquid and solid) (-runoff)(-calving)
1351      !!                   emp_ice            ice sublimation - solid precipitation over the ice
1352      !!                   dqns_ice           d(non-solar heat flux)/d(Temperature) over the ice
[1226]1353      !!                   sprecip             solid precipitation over the ocean 
[1218]1354      !!----------------------------------------------------------------------
[3294]1355      REAL(wp), INTENT(in   ), DIMENSION(:,:)   ::   p_frld     ! lead fraction                [0 to 1]
[1468]1356      ! optional arguments, used only in 'mixed oce-ice' case
[5220]1357      REAL(wp), INTENT(in   ), DIMENSION(:,:,:), OPTIONAL ::   palbi      ! all skies ice albedo
1358      REAL(wp), INTENT(in   ), DIMENSION(:,:  ), OPTIONAL ::   psst       ! sea surface temperature     [Celsius]
1359      REAL(wp), INTENT(in   ), DIMENSION(:,:,:), OPTIONAL ::   pist       ! ice surface temperature     [Kelvin]
[3294]1360      !
[5220]1361      INTEGER ::   jl         ! dummy loop index
1362      REAL(wp), POINTER, DIMENSION(:,:  ) ::   zcptn, ztmp, zicefr, zmsk
1363      REAL(wp), POINTER, DIMENSION(:,:  ) ::   zemp_tot, zemp_ice, zsprecip, ztprecip, zqns_tot, zqsr_tot
1364      REAL(wp), POINTER, DIMENSION(:,:,:) ::   zqns_ice, zqsr_ice, zdqns_ice
[5357]1365      REAL(wp), POINTER, DIMENSION(:,:  ) ::   zevap, zsnw, zqns_oce, zqprec_ice, zqemp_oce ! for LIM3
[1218]1366      !!----------------------------------------------------------------------
[3294]1367      !
1368      IF( nn_timing == 1 )  CALL timing_start('sbc_cpl_ice_flx')
1369      !
[5220]1370      CALL wrk_alloc( jpi,jpj,     zcptn, ztmp, zicefr, zmsk, zemp_tot, zemp_ice, zsprecip, ztprecip, zqns_tot, zqsr_tot )
1371      CALL wrk_alloc( jpi,jpj,jpl, zqns_ice, zqsr_ice, zdqns_ice )
[2715]1372
[5220]1373      IF( ln_mixcpl )   zmsk(:,:) = 1. - xcplmask(:,:,0)
[3294]1374      zicefr(:,:) = 1.- p_frld(:,:)
[3625]1375      zcptn(:,:) = rcp * sst_m(:,:)
[888]1376      !
[1218]1377      !                                                      ! ========================= !
1378      !                                                      !    freshwater budget      !   (emp)
1379      !                                                      ! ========================= !
[888]1380      !
[5220]1381      !                                                           ! total Precipitation - total Evaporation (emp_tot)
1382      !                                                           ! solid precipitation - sublimation       (emp_ice)
1383      !                                                           ! solid Precipitation                     (sprecip)
1384      !                                                           ! liquid + solid Precipitation            (tprecip)
[3294]1385      SELECT CASE( TRIM( sn_rcv_emp%cldes ) )
[1218]1386      CASE( 'conservative'  )   ! received fields: jpr_rain, jpr_snow, jpr_ievp, jpr_tevp
[5220]1387         zsprecip(:,:) = frcv(jpr_snow)%z3(:,:,1)                  ! May need to ensure positive here
1388         ztprecip(:,:) = frcv(jpr_rain)%z3(:,:,1) + zsprecip(:,:)  ! May need to ensure positive here
1389         zemp_tot(:,:) = frcv(jpr_tevp)%z3(:,:,1) - ztprecip(:,:)
1390         zemp_ice(:,:) = frcv(jpr_ievp)%z3(:,:,1) - frcv(jpr_snow)%z3(:,:,1)
[4990]1391            CALL iom_put( 'rain'         , frcv(jpr_rain)%z3(:,:,1)              )   ! liquid precipitation
1392         IF( iom_use('hflx_rain_cea') )   &
1393            CALL iom_put( 'hflx_rain_cea', frcv(jpr_rain)%z3(:,:,1) * zcptn(:,:) )   ! heat flux from liq. precip.
1394         IF( iom_use('evap_ao_cea') .OR. iom_use('hflx_evap_cea') )   &
1395            ztmp(:,:) = frcv(jpr_tevp)%z3(:,:,1) - frcv(jpr_ievp)%z3(:,:,1) * zicefr(:,:)
1396         IF( iom_use('evap_ao_cea'  ) )   &
1397            CALL iom_put( 'evap_ao_cea'  , ztmp                   )   ! ice-free oce evap (cell average)
1398         IF( iom_use('hflx_evap_cea') )   &
1399            CALL iom_put( 'hflx_evap_cea', ztmp(:,:) * zcptn(:,:) )   ! heat flux from from evap (cell average)
[3294]1400      CASE( 'oce and ice'   )   ! received fields: jpr_sbpr, jpr_semp, jpr_oemp, jpr_ievp
[5220]1401         zemp_tot(:,:) = p_frld(:,:) * frcv(jpr_oemp)%z3(:,:,1) + zicefr(:,:) * frcv(jpr_sbpr)%z3(:,:,1)
1402         zemp_ice(:,:) = frcv(jpr_semp)%z3(:,:,1)
1403         zsprecip(:,:) = frcv(jpr_ievp)%z3(:,:,1) - frcv(jpr_semp)%z3(:,:,1)
1404         ztprecip(:,:) = frcv(jpr_semp)%z3(:,:,1) - frcv(jpr_sbpr)%z3(:,:,1) + zsprecip(:,:)
[1218]1405      END SELECT
[3294]1406
[4990]1407      IF( iom_use('subl_ai_cea') )   &
1408         CALL iom_put( 'subl_ai_cea', frcv(jpr_ievp)%z3(:,:,1) * zicefr(:,:) )   ! Sublimation over sea-ice         (cell average)
[1218]1409      !   
1410      !                                                           ! runoffs and calving (put in emp_tot)
[1756]1411      IF( srcv(jpr_rnf)%laction ) THEN
[5220]1412         zemp_tot(:,:) = zemp_tot(:,:) - frcv(jpr_rnf)%z3(:,:,1)
[4990]1413            CALL iom_put( 'runoffs'      , frcv(jpr_rnf)%z3(:,:,1)              )   ! rivers
1414         IF( iom_use('hflx_rnf_cea') )   &
1415            CALL iom_put( 'hflx_rnf_cea' , frcv(jpr_rnf)%z3(:,:,1) * zcptn(:,:) )   ! heat flux from rivers
[1756]1416      ENDIF
1417      IF( srcv(jpr_cal)%laction ) THEN
[5220]1418         zemp_tot(:,:) = zemp_tot(:,:) - frcv(jpr_cal)%z3(:,:,1)
[3294]1419         CALL iom_put( 'calving', frcv(jpr_cal)%z3(:,:,1) )
[1756]1420      ENDIF
[888]1421
[5220]1422      IF( ln_mixcpl ) THEN
1423         emp_tot(:,:) = emp_tot(:,:) * xcplmask(:,:,0) + zemp_tot(:,:) * zmsk(:,:)
1424         emp_ice(:,:) = emp_ice(:,:) * xcplmask(:,:,0) + zemp_ice(:,:) * zmsk(:,:)
1425         sprecip(:,:) = sprecip(:,:) * xcplmask(:,:,0) + zsprecip(:,:) * zmsk(:,:)
1426         tprecip(:,:) = tprecip(:,:) * xcplmask(:,:,0) + ztprecip(:,:) * zmsk(:,:)
1427      ELSE
1428         emp_tot(:,:) =                                  zemp_tot(:,:)
1429         emp_ice(:,:) =                                  zemp_ice(:,:)
1430         sprecip(:,:) =                                  zsprecip(:,:)
1431         tprecip(:,:) =                                  ztprecip(:,:)
1432      ENDIF
1433
1434         CALL iom_put( 'snowpre'    , sprecip                                )   ! Snow
1435      IF( iom_use('snow_ao_cea') )   &
1436         CALL iom_put( 'snow_ao_cea', sprecip(:,:) * p_frld(:,:)             )   ! Snow        over ice-free ocean  (cell average)
1437      IF( iom_use('snow_ai_cea') )   &
1438         CALL iom_put( 'snow_ai_cea', sprecip(:,:) * zicefr(:,:)             )   ! Snow        over sea-ice         (cell average)
1439
[1218]1440      !                                                      ! ========================= !
[3294]1441      SELECT CASE( TRIM( sn_rcv_qns%cldes ) )                !   non solar heat fluxes   !   (qns)
[1218]1442      !                                                      ! ========================= !
[3294]1443      CASE( 'oce only' )                                     ! the required field is directly provided
[5220]1444         zqns_tot(:,:  ) = frcv(jpr_qnsoce)%z3(:,:,1)
[1218]1445      CASE( 'conservative' )                                      ! the required fields are directly provided
[5220]1446         zqns_tot(:,:  ) = frcv(jpr_qnsmix)%z3(:,:,1)
[3294]1447         IF ( TRIM(sn_rcv_qns%clcat) == 'yes' ) THEN
[5220]1448            zqns_ice(:,:,1:jpl) = frcv(jpr_qnsice)%z3(:,:,1:jpl)
[3294]1449         ELSE
1450            ! Set all category values equal for the moment
1451            DO jl=1,jpl
[5220]1452               zqns_ice(:,:,jl) = frcv(jpr_qnsice)%z3(:,:,1)
[3294]1453            ENDDO
1454         ENDIF
[1218]1455      CASE( 'oce and ice' )       ! the total flux is computed from ocean and ice fluxes
[5220]1456         zqns_tot(:,:  ) =  p_frld(:,:) * frcv(jpr_qnsoce)%z3(:,:,1)
[3294]1457         IF ( TRIM(sn_rcv_qns%clcat) == 'yes' ) THEN
1458            DO jl=1,jpl
[5220]1459               zqns_tot(:,:   ) = zqns_tot(:,:) + a_i(:,:,jl) * frcv(jpr_qnsice)%z3(:,:,jl)   
1460               zqns_ice(:,:,jl) = frcv(jpr_qnsice)%z3(:,:,jl)
[3294]1461            ENDDO
1462         ELSE
[5146]1463            qns_tot(:,:   ) = qns_tot(:,:) + zicefr(:,:) * frcv(jpr_qnsice)%z3(:,:,1)
[3294]1464            DO jl=1,jpl
[5220]1465               zqns_tot(:,:   ) = zqns_tot(:,:) + zicefr(:,:) * frcv(jpr_qnsice)%z3(:,:,1)
1466               zqns_ice(:,:,jl) = frcv(jpr_qnsice)%z3(:,:,1)
[3294]1467            ENDDO
1468         ENDIF
[1218]1469      CASE( 'mixed oce-ice' )     ! the ice flux is cumputed from the total flux, the SST and ice informations
[3294]1470! ** NEED TO SORT OUT HOW THIS SHOULD WORK IN THE MULTI-CATEGORY CASE - CURRENTLY NOT ALLOWED WHEN INTERFACE INITIALISED **
[5220]1471         zqns_tot(:,:  ) = frcv(jpr_qnsmix)%z3(:,:,1)
1472         zqns_ice(:,:,1) = frcv(jpr_qnsmix)%z3(:,:,1)    &
[3294]1473            &            + frcv(jpr_dqnsdt)%z3(:,:,1) * ( pist(:,:,1) - ( (rt0 + psst(:,:  ) ) * p_frld(:,:)   &
1474            &                                                   +          pist(:,:,1)   * zicefr(:,:) ) )
[1218]1475      END SELECT
1476!!gm
[5220]1477!!    currently it is taken into account in leads budget but not in the zqns_tot, and thus not in
[1218]1478!!    the flux that enter the ocean....
1479!!    moreover 1 - it is not diagnose anywhere....
1480!!             2 - it is unclear for me whether this heat lost is taken into account in the atmosphere or not...
1481!!
1482!! similar job should be done for snow and precipitation temperature
[1860]1483      !                                     
1484      IF( srcv(jpr_cal)%laction ) THEN                            ! Iceberg melting
[3294]1485         ztmp(:,:) = frcv(jpr_cal)%z3(:,:,1) * lfus               ! add the latent heat of iceberg melting
[5220]1486         zqns_tot(:,:) = zqns_tot(:,:) - ztmp(:,:)
[4990]1487         IF( iom_use('hflx_cal_cea') )   &
1488            CALL iom_put( 'hflx_cal_cea', ztmp + frcv(jpr_cal)%z3(:,:,1) * zcptn(:,:) )   ! heat flux from calving
[1742]1489      ENDIF
[1218]1490
[5357]1491      ztmp(:,:) = p_frld(:,:) * zsprecip(:,:) * lfus
1492      IF( iom_use('hflx_snow_cea') )    CALL iom_put( 'hflx_snow_cea', ztmp + sprecip(:,:) * zcptn(:,:) )   ! heat flux from snow (cell average)
1493
1494#if defined key_lim3
1495      CALL wrk_alloc( jpi,jpj, zevap, zsnw, zqns_oce, zqprec_ice, zqemp_oce ) 
1496
1497      ! --- evaporation --- !
1498      ! clem: evap_ice is set to 0 for LIM3 since we still do not know what to do with sublimation
1499      ! the problem is: the atm. imposes both mass evaporation and heat removed from the snow/ice
1500      !                 but it is incoherent WITH the ice model 
1501      DO jl=1,jpl
1502         evap_ice(:,:,jl) = 0._wp  ! should be: frcv(jpr_ievp)%z3(:,:,1)
1503      ENDDO
1504      zevap(:,:) = zemp_tot(:,:) + ztprecip(:,:) ! evaporation over ocean
1505
1506      ! --- evaporation minus precipitation --- !
1507      emp_oce(:,:) = emp_tot(:,:) - emp_ice(:,:)
1508
1509      ! --- non solar flux over ocean --- !
1510      !         note: p_frld cannot be = 0 since we limit the ice concentration to amax
1511      zqns_oce = 0._wp
1512      WHERE( p_frld /= 0._wp )  zqns_oce(:,:) = ( zqns_tot(:,:) - SUM( a_i * zqns_ice, dim=3 ) ) / p_frld(:,:)
1513
1514      ! --- heat flux associated with emp --- !
1515      CALL lim_thd_snwblow( p_frld, zsnw )  ! snow distribution over ice after wind blowing
1516      zqemp_oce(:,:) = -      zevap(:,:)                   * p_frld(:,:)      *   zcptn(:,:)   &      ! evap
1517         &             + ( ztprecip(:,:) - zsprecip(:,:) )                    *   zcptn(:,:)   &      ! liquid precip
1518         &             +   zsprecip(:,:)                   * ( 1._wp - zsnw ) * ( zcptn(:,:) - lfus ) ! solid precip over ocean
1519      qemp_ice(:,:)  = -   frcv(jpr_ievp)%z3(:,:,1)        * zicefr(:,:)      *   zcptn(:,:)   &      ! ice evap
1520         &             +   zsprecip(:,:)                   * zsnw             * ( zcptn(:,:) - lfus ) ! solid precip over ice
1521
1522      ! --- heat content of precip over ice in J/m3 (to be used in 1D-thermo) --- !
1523      zqprec_ice(:,:) = rhosn * ( zcptn(:,:) - lfus )
1524
1525      ! --- total non solar flux --- !
1526      zqns_tot(:,:) = zqns_tot(:,:) + qemp_ice(:,:) + zqemp_oce(:,:)
1527
1528      ! --- in case both coupled/forced are active, we must mix values --- !
[5220]1529      IF( ln_mixcpl ) THEN
[5357]1530         qns_tot(:,:) = qns_tot(:,:) * xcplmask(:,:,0) + zqns_tot(:,:)* zmsk(:,:)
1531         qns_oce(:,:) = qns_oce(:,:) * xcplmask(:,:,0) + zqns_oce(:,:)* zmsk(:,:)
1532         DO jl=1,jpl
1533            qns_ice(:,:,jl) = qns_ice(:,:,jl) * xcplmask(:,:,0) +  zqns_ice(:,:,jl)* zmsk(:,:)
1534         ENDDO
1535         qprec_ice(:,:) = qprec_ice(:,:) * xcplmask(:,:,0) + zqprec_ice(:,:)* zmsk(:,:)
1536         qemp_oce(:,:) = qemp_oce(:,:) * xcplmask(:,:,0) + zqemp_oce(:,:)* zmsk(:,:)
1537!!clem         evap_ice(:,:) = evap_ice(:,:) * xcplmask(:,:,0)
1538      ELSE
1539         qns_tot  (:,:  ) = zqns_tot  (:,:  )
1540         qns_oce  (:,:  ) = zqns_oce  (:,:  )
1541         qns_ice  (:,:,:) = zqns_ice  (:,:,:)
1542         qprec_ice(:,:)   = zqprec_ice(:,:)
1543         qemp_oce (:,:)   = zqemp_oce (:,:)
1544      ENDIF
1545
1546      CALL wrk_dealloc( jpi,jpj, zevap, zsnw, zqns_oce, zqprec_ice, zqemp_oce ) 
1547
1548#else
1549
1550      ! clem: this formulation is certainly wrong.
1551      zqns_tot(:,:) = zqns_tot(:,:)                       &            ! zqns_tot update over free ocean with:
1552         &          - ztmp(:,:)                           &            ! remove the latent heat flux of solid precip. melting
1553         &          - (  zemp_tot(:,:)                    &            ! remove the heat content of mass flux (assumed to be at SST)
1554         &             - zemp_ice(:,:) * zicefr(:,:)  ) * zcptn(:,:) 
1555
1556     IF( ln_mixcpl ) THEN
[5220]1557         qns_tot(:,:) = qns(:,:) * p_frld(:,:) + SUM( qns_ice(:,:,:) * a_i(:,:,:), dim=3 )   ! total flux from blk
1558         qns_tot(:,:) = qns_tot(:,:) * xcplmask(:,:,0) +  zqns_tot(:,:)* zmsk(:,:)
1559         DO jl=1,jpl
1560            qns_ice(:,:,jl) = qns_ice(:,:,jl) * xcplmask(:,:,0) +  zqns_ice(:,:,jl)* zmsk(:,:)
1561         ENDDO
1562      ELSE
1563         qns_tot(:,:  ) = zqns_tot(:,:  )
1564         qns_ice(:,:,:) = zqns_ice(:,:,:)
1565      ENDIF
1566
[5357]1567#endif
1568
[1218]1569      !                                                      ! ========================= !
[3294]1570      SELECT CASE( TRIM( sn_rcv_qsr%cldes ) )                !      solar heat fluxes    !   (qsr)
[1218]1571      !                                                      ! ========================= !
[3294]1572      CASE( 'oce only' )
[5220]1573         zqsr_tot(:,:  ) = MAX( 0._wp , frcv(jpr_qsroce)%z3(:,:,1) )
[1218]1574      CASE( 'conservative' )
[5220]1575         zqsr_tot(:,:  ) = frcv(jpr_qsrmix)%z3(:,:,1)
[3294]1576         IF ( TRIM(sn_rcv_qsr%clcat) == 'yes' ) THEN
[5220]1577            zqsr_ice(:,:,1:jpl) = frcv(jpr_qsrice)%z3(:,:,1:jpl)
[3294]1578         ELSE
1579            ! Set all category values equal for the moment
1580            DO jl=1,jpl
[5220]1581               zqsr_ice(:,:,jl) = frcv(jpr_qsrice)%z3(:,:,1)
[3294]1582            ENDDO
1583         ENDIF
[5220]1584         zqsr_tot(:,:  ) = frcv(jpr_qsrmix)%z3(:,:,1)
1585         zqsr_ice(:,:,1) = frcv(jpr_qsrice)%z3(:,:,1)
[1218]1586      CASE( 'oce and ice' )
[5220]1587         zqsr_tot(:,:  ) =  p_frld(:,:) * frcv(jpr_qsroce)%z3(:,:,1)
[3294]1588         IF ( TRIM(sn_rcv_qsr%clcat) == 'yes' ) THEN
1589            DO jl=1,jpl
[5220]1590               zqsr_tot(:,:   ) = zqsr_tot(:,:) + a_i(:,:,jl) * frcv(jpr_qsrice)%z3(:,:,jl)   
1591               zqsr_ice(:,:,jl) = frcv(jpr_qsrice)%z3(:,:,jl)
[3294]1592            ENDDO
1593         ELSE
[5146]1594            qsr_tot(:,:   ) = qsr_tot(:,:) + zicefr(:,:) * frcv(jpr_qsrice)%z3(:,:,1)
[3294]1595            DO jl=1,jpl
[5220]1596               zqsr_tot(:,:   ) = zqsr_tot(:,:) + zicefr(:,:) * frcv(jpr_qsrice)%z3(:,:,1)
1597               zqsr_ice(:,:,jl) = frcv(jpr_qsrice)%z3(:,:,1)
[3294]1598            ENDDO
1599         ENDIF
[1218]1600      CASE( 'mixed oce-ice' )
[5220]1601         zqsr_tot(:,:  ) = frcv(jpr_qsrmix)%z3(:,:,1)
[3294]1602! ** NEED TO SORT OUT HOW THIS SHOULD WORK IN THE MULTI-CATEGORY CASE - CURRENTLY NOT ALLOWED WHEN INTERFACE INITIALISED **
[1232]1603!       Create solar heat flux over ice using incoming solar heat flux and albedos
1604!       ( see OASIS3 user guide, 5th edition, p39 )
[5220]1605         zqsr_ice(:,:,1) = frcv(jpr_qsrmix)%z3(:,:,1) * ( 1.- palbi(:,:,1) )   &
[3294]1606            &            / (  1.- ( albedo_oce_mix(:,:  ) * p_frld(:,:)       &
1607            &                     + palbi         (:,:,1) * zicefr(:,:) ) )
[1218]1608      END SELECT
[2528]1609      IF( ln_dm2dc ) THEN   ! modify qsr to include the diurnal cycle
[5220]1610         zqsr_tot(:,:  ) = sbc_dcy( zqsr_tot(:,:  ) )
[3294]1611         DO jl=1,jpl
[5220]1612            zqsr_ice(:,:,jl) = sbc_dcy( zqsr_ice(:,:,jl) )
[3294]1613         ENDDO
[2528]1614      ENDIF
[1218]1615
[5220]1616      IF( ln_mixcpl ) THEN
1617         qsr_tot(:,:) = qsr(:,:) * p_frld(:,:) + SUM( qsr_ice(:,:,:) * a_i(:,:,:), dim=3 )   ! total flux from blk
1618         qsr_tot(:,:) = qsr_tot(:,:) * xcplmask(:,:,0) +  zqsr_tot(:,:)* zmsk(:,:)
1619         DO jl=1,jpl
1620            qsr_ice(:,:,jl) = qsr_ice(:,:,jl) * xcplmask(:,:,0) +  zqsr_ice(:,:,jl)* zmsk(:,:)
1621         ENDDO
1622      ELSE
1623         qsr_tot(:,:  ) = zqsr_tot(:,:  )
1624         qsr_ice(:,:,:) = zqsr_ice(:,:,:)
1625      ENDIF
1626
[4990]1627      !                                                      ! ========================= !
1628      SELECT CASE( TRIM( sn_rcv_dqnsdt%cldes ) )             !          d(qns)/dt        !
1629      !                                                      ! ========================= !
[1226]1630      CASE ('coupled')
[3294]1631         IF ( TRIM(sn_rcv_dqnsdt%clcat) == 'yes' ) THEN
[5220]1632            zdqns_ice(:,:,1:jpl) = frcv(jpr_dqnsdt)%z3(:,:,1:jpl)
[3294]1633         ELSE
1634            ! Set all category values equal for the moment
1635            DO jl=1,jpl
[5220]1636               zdqns_ice(:,:,jl) = frcv(jpr_dqnsdt)%z3(:,:,1)
[3294]1637            ENDDO
1638         ENDIF
[1226]1639      END SELECT
[5220]1640     
1641      IF( ln_mixcpl ) THEN
1642         DO jl=1,jpl
1643            dqns_ice(:,:,jl) = dqns_ice(:,:,jl) * xcplmask(:,:,0) + zdqns_ice(:,:,jl) * zmsk(:,:)
1644         ENDDO
1645      ELSE
1646         dqns_ice(:,:,:) = zdqns_ice(:,:,:)
1647      ENDIF
1648     
[4990]1649      !                                                      ! ========================= !
1650      SELECT CASE( TRIM( sn_rcv_iceflx%cldes ) )             !    topmelt and botmelt    !
1651      !                                                      ! ========================= !
[3294]1652      CASE ('coupled')
1653         topmelt(:,:,:)=frcv(jpr_topm)%z3(:,:,:)
1654         botmelt(:,:,:)=frcv(jpr_botm)%z3(:,:,:)
1655      END SELECT
1656
[4990]1657      ! Surface transimission parameter io (Maykut Untersteiner , 1971 ; Ebert and Curry, 1993 )
1658      ! Used for LIM2 and LIM3
[4162]1659      ! Coupled case: since cloud cover is not received from atmosphere
[4990]1660      !               ===> used prescribed cloud fraction representative for polar oceans in summer (0.81)
1661      fr1_i0(:,:) = ( 0.18 * ( 1.0 - cldf_ice ) + 0.35 * cldf_ice )
1662      fr2_i0(:,:) = ( 0.82 * ( 1.0 - cldf_ice ) + 0.65 * cldf_ice )
[4162]1663
[5220]1664      CALL wrk_dealloc( jpi,jpj,     zcptn, ztmp, zicefr, zmsk, zemp_tot, zemp_ice, zsprecip, ztprecip, zqns_tot, zqsr_tot )
1665      CALL wrk_dealloc( jpi,jpj,jpl, zqns_ice, zqsr_ice, zdqns_ice )
[2715]1666      !
[3294]1667      IF( nn_timing == 1 )  CALL timing_stop('sbc_cpl_ice_flx')
1668      !
[1226]1669   END SUBROUTINE sbc_cpl_ice_flx
[1218]1670   
1671   
1672   SUBROUTINE sbc_cpl_snd( kt )
1673      !!----------------------------------------------------------------------
1674      !!             ***  ROUTINE sbc_cpl_snd  ***
1675      !!
1676      !! ** Purpose :   provide the ocean-ice informations to the atmosphere
1677      !!
[4990]1678      !! ** Method  :   send to the atmosphere through a call to cpl_snd
[1218]1679      !!              all the needed fields (as defined in sbc_cpl_init)
1680      !!----------------------------------------------------------------------
1681      INTEGER, INTENT(in) ::   kt
[2715]1682      !
[3294]1683      INTEGER ::   ji, jj, jl   ! dummy loop indices
[2715]1684      INTEGER ::   isec, info   ! local integer
[5299]1685      REAL(wp) ::   zumax, zvmax
[3294]1686      REAL(wp), POINTER, DIMENSION(:,:)   ::   zfr_l, ztmp1, ztmp2, zotx1, zoty1, zotz1, zitx1, zity1, zitz1
1687      REAL(wp), POINTER, DIMENSION(:,:,:) ::   ztmp3, ztmp4   
[1218]1688      !!----------------------------------------------------------------------
[3294]1689      !
1690      IF( nn_timing == 1 )  CALL timing_start('sbc_cpl_snd')
1691      !
1692      CALL wrk_alloc( jpi,jpj, zfr_l, ztmp1, ztmp2, zotx1, zoty1, zotz1, zitx1, zity1, zitz1 )
1693      CALL wrk_alloc( jpi,jpj,jpl, ztmp3, ztmp4 )
[888]1694
[1218]1695      isec = ( kt - nit000 ) * NINT(rdttra(1))        ! date of exchanges
[888]1696
[1218]1697      zfr_l(:,:) = 1.- fr_i(:,:)
1698      !                                                      ! ------------------------- !
1699      !                                                      !    Surface temperature    !   in Kelvin
1700      !                                                      ! ------------------------- !
[3680]1701      IF( ssnd(jps_toce)%laction .OR. ssnd(jps_tice)%laction .OR. ssnd(jps_tmix)%laction ) THEN
[5343]1702         
[5220]1703         IF ( nn_components == jp_iam_opa ) THEN
[5343]1704            ztmp1(:,:) = tsn(:,:,1,jp_tem)   ! send temperature as it is (potential or conservative) -> use of ln_useCT on the received part
[5220]1705         ELSE
[5343]1706            ! we must send the surface potential temperature
1707            IF( ln_useCT )  THEN    ;   ztmp1(:,:) = eos_pt_from_ct( tsn(:,:,1,jp_tem), tsn(:,:,1,jp_sal) )
1708            ELSE                    ;   ztmp1(:,:) = tsn(:,:,1,jp_tem)
1709            ENDIF
1710            !
[5220]1711            SELECT CASE( sn_snd_temp%cldes)
[5343]1712            CASE( 'oce only'             )   ;   ztmp1(:,:) =   ztmp1(:,:) + rt0
1713            CASE( 'weighted oce and ice' )   ;   ztmp1(:,:) = ( ztmp1(:,:) + rt0 ) * zfr_l(:,:)   
[5220]1714               SELECT CASE( sn_snd_temp%clcat )
1715               CASE( 'yes' )   
1716                  ztmp3(:,:,1:jpl) = tn_ice(:,:,1:jpl) * a_i(:,:,1:jpl)
1717               CASE( 'no' )
1718                  ztmp3(:,:,:) = 0.0
1719                  DO jl=1,jpl
1720                     ztmp3(:,:,1) = ztmp3(:,:,1) + tn_ice(:,:,jl) * a_i(:,:,jl)
1721                  ENDDO
1722               CASE default                  ;   CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_temp%clcat' )
1723               END SELECT
1724            CASE( 'mixed oce-ice'        )   
[5343]1725               ztmp1(:,:) = ( ztmp1(:,:) + rt0 ) * zfr_l(:,:) 
[3680]1726               DO jl=1,jpl
[5220]1727                  ztmp1(:,:) = ztmp1(:,:) + tn_ice(:,:,jl) * a_i(:,:,jl)
[3680]1728               ENDDO
[5220]1729            CASE default                     ;   CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_temp%cldes' )
[3680]1730            END SELECT
[5220]1731         ENDIF
[4990]1732         IF( ssnd(jps_toce)%laction )   CALL cpl_snd( jps_toce, isec, RESHAPE ( ztmp1, (/jpi,jpj,1/) ), info )
1733         IF( ssnd(jps_tice)%laction )   CALL cpl_snd( jps_tice, isec, ztmp3, info )
1734         IF( ssnd(jps_tmix)%laction )   CALL cpl_snd( jps_tmix, isec, RESHAPE ( ztmp1, (/jpi,jpj,1/) ), info )
[3680]1735      ENDIF
[1218]1736      !                                                      ! ------------------------- !
1737      !                                                      !           Albedo          !
1738      !                                                      ! ------------------------- !
1739      IF( ssnd(jps_albice)%laction ) THEN                         ! ice
[3294]1740         ztmp3(:,:,1:jpl) = alb_ice(:,:,1:jpl) * a_i(:,:,1:jpl)
[4990]1741         CALL cpl_snd( jps_albice, isec, ztmp3, info )
[888]1742      ENDIF
[1218]1743      IF( ssnd(jps_albmix)%laction ) THEN                         ! mixed ice-ocean
[3294]1744         ztmp1(:,:) = albedo_oce_mix(:,:) * zfr_l(:,:)
1745         DO jl=1,jpl
1746            ztmp1(:,:) = ztmp1(:,:) + alb_ice(:,:,jl) * a_i(:,:,jl)
1747         ENDDO
[4990]1748         CALL cpl_snd( jps_albmix, isec, RESHAPE ( ztmp1, (/jpi,jpj,1/) ), info )
[1218]1749      ENDIF
1750      !                                                      ! ------------------------- !
1751      !                                                      !  Ice fraction & Thickness !
1752      !                                                      ! ------------------------- !
[5299]1753      ! Send ice fraction field to atmosphere
1754      IF( ssnd(jps_fice)%laction ) THEN
[3680]1755         SELECT CASE( sn_snd_thick%clcat )
1756         CASE( 'yes' )   ;   ztmp3(:,:,1:jpl) =  a_i(:,:,1:jpl)
1757         CASE( 'no'  )   ;   ztmp3(:,:,1    ) = fr_i(:,:      )
1758         CASE default    ;   CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_thick%clcat' )
1759         END SELECT
[5299]1760         IF( ssnd(jps_fice)%laction )   CALL cpl_snd( jps_fice, isec, ztmp3, info )
1761      ENDIF
1762     
1763      ! Send ice fraction field to OPA (sent by SAS in SAS-OPA coupling)
1764      IF( ssnd(jps_fice2)%laction ) THEN
1765         ztmp3(:,:,1) = fr_i(:,:)
[5220]1766         IF( ssnd(jps_fice2)%laction )   CALL cpl_snd( jps_fice2, isec, ztmp3, info )
[3680]1767      ENDIF
[3294]1768
1769      ! Send ice and snow thickness field
[3680]1770      IF( ssnd(jps_hice)%laction .OR. ssnd(jps_hsnw)%laction ) THEN
1771         SELECT CASE( sn_snd_thick%cldes)
1772         CASE( 'none'                  )       ! nothing to do
1773         CASE( 'weighted ice and snow' )   
1774            SELECT CASE( sn_snd_thick%clcat )
1775            CASE( 'yes' )   
1776               ztmp3(:,:,1:jpl) =  ht_i(:,:,1:jpl) * a_i(:,:,1:jpl)
1777               ztmp4(:,:,1:jpl) =  ht_s(:,:,1:jpl) * a_i(:,:,1:jpl)
1778            CASE( 'no' )
1779               ztmp3(:,:,:) = 0.0   ;  ztmp4(:,:,:) = 0.0
1780               DO jl=1,jpl
1781                  ztmp3(:,:,1) = ztmp3(:,:,1) + ht_i(:,:,jl) * a_i(:,:,jl)
1782                  ztmp4(:,:,1) = ztmp4(:,:,1) + ht_s(:,:,jl) * a_i(:,:,jl)
1783               ENDDO
1784            CASE default                  ;   CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_thick%clcat' )
1785            END SELECT
1786         CASE( 'ice and snow'         )   
1787            ztmp3(:,:,1:jpl) = ht_i(:,:,1:jpl)
1788            ztmp4(:,:,1:jpl) = ht_s(:,:,1:jpl)
1789         CASE default                     ;   CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_thick%cldes' )
[3294]1790         END SELECT
[4990]1791         IF( ssnd(jps_hice)%laction )   CALL cpl_snd( jps_hice, isec, ztmp3, info )
1792         IF( ssnd(jps_hsnw)%laction )   CALL cpl_snd( jps_hsnw, isec, ztmp4, info )
[3680]1793      ENDIF
[1218]1794      !
[1534]1795#if defined key_cpl_carbon_cycle
[1218]1796      !                                                      ! ------------------------- !
[1534]1797      !                                                      !  CO2 flux from PISCES     !
1798      !                                                      ! ------------------------- !
[4990]1799      IF( ssnd(jps_co2)%laction )   CALL cpl_snd( jps_co2, isec, RESHAPE ( oce_co2, (/jpi,jpj,1/) ) , info )
[1534]1800      !
1801#endif
[3294]1802      !                                                      ! ------------------------- !
[1218]1803      IF( ssnd(jps_ocx1)%laction ) THEN                      !      Surface current      !
1804         !                                                   ! ------------------------- !
[1467]1805         !   
1806         !                                                  j+1   j     -----V---F
[1694]1807         ! surface velocity always sent from T point                     !       |
[1467]1808         !                                                        j      |   T   U
1809         !                                                               |       |
1810         !                                                   j    j-1   -I-------|
1811         !                                               (for I)         |       |
1812         !                                                              i-1  i   i
1813         !                                                               i      i+1 (for I)
[5220]1814         IF( nn_components == jp_iam_opa ) THEN
[5299]1815            zotx1(:,:) = un(:,:,1) 
1816            zoty1(:,:) = vn(:,:,1) 
[5220]1817         ELSE       
1818            SELECT CASE( TRIM( sn_snd_crt%cldes ) )
1819            CASE( 'oce only'             )      ! C-grid ==> T
[1218]1820               DO jj = 2, jpjm1
1821                  DO ji = fs_2, fs_jpim1   ! vector opt.
[5220]1822                     zotx1(ji,jj) = 0.5 * ( un(ji,jj,1) + un(ji-1,jj  ,1) )
1823                     zoty1(ji,jj) = 0.5 * ( vn(ji,jj,1) + vn(ji  ,jj-1,1) ) 
[1218]1824                  END DO
1825               END DO
[5220]1826            CASE( 'weighted oce and ice' )   
1827               SELECT CASE ( cp_ice_msh )
1828               CASE( 'C' )                      ! Ocean and Ice on C-grid ==> T
1829                  DO jj = 2, jpjm1
1830                     DO ji = fs_2, fs_jpim1   ! vector opt.
1831                        zotx1(ji,jj) = 0.5 * ( un   (ji,jj,1) + un   (ji-1,jj  ,1) ) * zfr_l(ji,jj) 
1832                        zoty1(ji,jj) = 0.5 * ( vn   (ji,jj,1) + vn   (ji  ,jj-1,1) ) * zfr_l(ji,jj)
1833                        zitx1(ji,jj) = 0.5 * ( u_ice(ji,jj  ) + u_ice(ji-1,jj    ) ) *  fr_i(ji,jj)
1834                        zity1(ji,jj) = 0.5 * ( v_ice(ji,jj  ) + v_ice(ji  ,jj-1  ) ) *  fr_i(ji,jj)
1835                     END DO
[1218]1836                  END DO
[5220]1837               CASE( 'I' )                      ! Ocean on C grid, Ice on I-point (B-grid) ==> T
1838                  DO jj = 2, jpjm1
1839                     DO ji = 2, jpim1   ! NO vector opt.
1840                        zotx1(ji,jj) = 0.5  * ( un(ji,jj,1)      + un(ji-1,jj  ,1) ) * zfr_l(ji,jj) 
1841                        zoty1(ji,jj) = 0.5  * ( vn(ji,jj,1)      + vn(ji  ,jj-1,1) ) * zfr_l(ji,jj) 
1842                        zitx1(ji,jj) = 0.25 * ( u_ice(ji+1,jj+1) + u_ice(ji,jj+1)                     &
1843                           &                  + u_ice(ji+1,jj  ) + u_ice(ji,jj  )  ) *  fr_i(ji,jj)
1844                        zity1(ji,jj) = 0.25 * ( v_ice(ji+1,jj+1) + v_ice(ji,jj+1)                     &
1845                           &                  + v_ice(ji+1,jj  ) + v_ice(ji,jj  )  ) *  fr_i(ji,jj)
1846                     END DO
[1467]1847                  END DO
[5220]1848               CASE( 'F' )                      ! Ocean on C grid, Ice on F-point (B-grid) ==> T
1849                  DO jj = 2, jpjm1
1850                     DO ji = 2, jpim1   ! NO vector opt.
1851                        zotx1(ji,jj) = 0.5  * ( un(ji,jj,1)      + un(ji-1,jj  ,1) ) * zfr_l(ji,jj) 
1852                        zoty1(ji,jj) = 0.5  * ( vn(ji,jj,1)      + vn(ji  ,jj-1,1) ) * zfr_l(ji,jj) 
1853                        zitx1(ji,jj) = 0.25 * ( u_ice(ji-1,jj-1) + u_ice(ji,jj-1)                     &
1854                           &                  + u_ice(ji-1,jj  ) + u_ice(ji,jj  )  ) *  fr_i(ji,jj)
1855                        zity1(ji,jj) = 0.25 * ( v_ice(ji-1,jj-1) + v_ice(ji,jj-1)                     &
1856                           &                  + v_ice(ji-1,jj  ) + v_ice(ji,jj  )  ) *  fr_i(ji,jj)
1857                     END DO
[1308]1858                  END DO
[5220]1859               END SELECT
1860               CALL lbc_lnk( zitx1, 'T', -1. )   ;   CALL lbc_lnk( zity1, 'T', -1. )
1861            CASE( 'mixed oce-ice'        )
1862               SELECT CASE ( cp_ice_msh )
1863               CASE( 'C' )                      ! Ocean and Ice on C-grid ==> T
1864                  DO jj = 2, jpjm1
1865                     DO ji = fs_2, fs_jpim1   ! vector opt.
1866                        zotx1(ji,jj) = 0.5 * ( un   (ji,jj,1) + un   (ji-1,jj  ,1) ) * zfr_l(ji,jj)   &
1867                           &         + 0.5 * ( u_ice(ji,jj  ) + u_ice(ji-1,jj    ) ) *  fr_i(ji,jj)
1868                        zoty1(ji,jj) = 0.5 * ( vn   (ji,jj,1) + vn   (ji  ,jj-1,1) ) * zfr_l(ji,jj)   &
1869                           &         + 0.5 * ( v_ice(ji,jj  ) + v_ice(ji  ,jj-1  ) ) *  fr_i(ji,jj)
1870                     END DO
[1218]1871                  END DO
[5220]1872               CASE( 'I' )                      ! Ocean on C grid, Ice on I-point (B-grid) ==> T
1873                  DO jj = 2, jpjm1
1874                     DO ji = 2, jpim1   ! NO vector opt.
1875                        zotx1(ji,jj) = 0.5  * ( un(ji,jj,1)      + un(ji-1,jj  ,1) ) * zfr_l(ji,jj)   &   
1876                           &         + 0.25 * ( u_ice(ji+1,jj+1) + u_ice(ji,jj+1)                     &
1877                           &                  + u_ice(ji+1,jj  ) + u_ice(ji,jj  )  ) *  fr_i(ji,jj)
1878                        zoty1(ji,jj) = 0.5  * ( vn(ji,jj,1)      + vn(ji  ,jj-1,1) ) * zfr_l(ji,jj)   & 
1879                           &         + 0.25 * ( v_ice(ji+1,jj+1) + v_ice(ji,jj+1)                     &
1880                           &                  + v_ice(ji+1,jj  ) + v_ice(ji,jj  )  ) *  fr_i(ji,jj)
1881                     END DO
[1467]1882                  END DO
[5220]1883               CASE( 'F' )                      ! Ocean on C grid, Ice on F-point (B-grid) ==> T
1884                  DO jj = 2, jpjm1
1885                     DO ji = 2, jpim1   ! NO vector opt.
1886                        zotx1(ji,jj) = 0.5  * ( un(ji,jj,1)      + un(ji-1,jj  ,1) ) * zfr_l(ji,jj)   &   
1887                           &         + 0.25 * ( u_ice(ji-1,jj-1) + u_ice(ji,jj-1)                     &
1888                           &                  + u_ice(ji-1,jj  ) + u_ice(ji,jj  )  ) *  fr_i(ji,jj)
1889                        zoty1(ji,jj) = 0.5  * ( vn(ji,jj,1)      + vn(ji  ,jj-1,1) ) * zfr_l(ji,jj)   & 
1890                           &         + 0.25 * ( v_ice(ji-1,jj-1) + v_ice(ji,jj-1)                     &
1891                           &                  + v_ice(ji-1,jj  ) + v_ice(ji,jj  )  ) *  fr_i(ji,jj)
1892                     END DO
1893                  END DO
1894               END SELECT
[1467]1895            END SELECT
[5220]1896            CALL lbc_lnk( zotx1, ssnd(jps_ocx1)%clgrid, -1. )   ;   CALL lbc_lnk( zoty1, ssnd(jps_ocy1)%clgrid, -1. )
1897            !
1898         ENDIF
[888]1899         !
[1218]1900         !
[3294]1901         IF( TRIM( sn_snd_crt%clvor ) == 'eastward-northward' ) THEN             ! Rotation of the components
[1218]1902            !                                                                     ! Ocean component
1903            CALL rot_rep( zotx1, zoty1, ssnd(jps_ocx1)%clgrid, 'ij->e', ztmp1 )       ! 1st component
1904            CALL rot_rep( zotx1, zoty1, ssnd(jps_ocx1)%clgrid, 'ij->n', ztmp2 )       ! 2nd component
1905            zotx1(:,:) = ztmp1(:,:)                                                   ! overwrite the components
1906            zoty1(:,:) = ztmp2(:,:)
1907            IF( ssnd(jps_ivx1)%laction ) THEN                                     ! Ice component
1908               CALL rot_rep( zitx1, zity1, ssnd(jps_ivx1)%clgrid, 'ij->e', ztmp1 )    ! 1st component
1909               CALL rot_rep( zitx1, zity1, ssnd(jps_ivx1)%clgrid, 'ij->n', ztmp2 )    ! 2nd component
1910               zitx1(:,:) = ztmp1(:,:)                                                ! overwrite the components
1911               zity1(:,:) = ztmp2(:,:)
1912            ENDIF
1913         ENDIF
1914         !
1915         ! spherical coordinates to cartesian -> 2 components to 3 components
[3294]1916         IF( TRIM( sn_snd_crt%clvref ) == 'cartesian' ) THEN
[1218]1917            ztmp1(:,:) = zotx1(:,:)                     ! ocean currents
1918            ztmp2(:,:) = zoty1(:,:)
[1226]1919            CALL oce2geo ( ztmp1, ztmp2, 'T', zotx1, zoty1, zotz1 )
[1218]1920            !
1921            IF( ssnd(jps_ivx1)%laction ) THEN           ! ice velocities
1922               ztmp1(:,:) = zitx1(:,:)
1923               ztmp1(:,:) = zity1(:,:)
[1226]1924               CALL oce2geo ( ztmp1, ztmp2, 'T', zitx1, zity1, zitz1 )
[1218]1925            ENDIF
1926         ENDIF
1927         !
[4990]1928         IF( ssnd(jps_ocx1)%laction )   CALL cpl_snd( jps_ocx1, isec, RESHAPE ( zotx1, (/jpi,jpj,1/) ), info )   ! ocean x current 1st grid
1929         IF( ssnd(jps_ocy1)%laction )   CALL cpl_snd( jps_ocy1, isec, RESHAPE ( zoty1, (/jpi,jpj,1/) ), info )   ! ocean y current 1st grid
1930         IF( ssnd(jps_ocz1)%laction )   CALL cpl_snd( jps_ocz1, isec, RESHAPE ( zotz1, (/jpi,jpj,1/) ), info )   ! ocean z current 1st grid
[1218]1931         !
[4990]1932         IF( ssnd(jps_ivx1)%laction )   CALL cpl_snd( jps_ivx1, isec, RESHAPE ( zitx1, (/jpi,jpj,1/) ), info )   ! ice   x current 1st grid
1933         IF( ssnd(jps_ivy1)%laction )   CALL cpl_snd( jps_ivy1, isec, RESHAPE ( zity1, (/jpi,jpj,1/) ), info )   ! ice   y current 1st grid
1934         IF( ssnd(jps_ivz1)%laction )   CALL cpl_snd( jps_ivz1, isec, RESHAPE ( zitz1, (/jpi,jpj,1/) ), info )   ! ice   z current 1st grid
[1534]1935         !
[888]1936      ENDIF
[2715]1937      !
[5220]1938      !
[5299]1939      !  Fields sent to SAS by OPA when doing OPA<->SAS coupling
[5220]1940      !                                                        ! SSH
1941      IF( ssnd(jps_ssh )%laction )  THEN
1942         !                          ! removed inverse barometer ssh when Patm
1943         !                          forcing is used (for sea-ice dynamics)
1944         IF( ln_apr_dyn ) THEN   ;   ztmp1(:,:) = sshb(:,:) - 0.5 * ( ssh_ib(:,:) + ssh_ibb(:,:) )
[5299]1945         ELSE                    ;   ztmp1(:,:) = sshn(:,:)
[5220]1946         ENDIF
[5352]1947         CALL cpl_snd( jps_ssh   , isec, RESHAPE ( ztmp1            , (/jpi,jpj,1/) ), info )
[5220]1948
1949      ENDIF
1950      !                                                        ! SSS
[5299]1951      IF( ssnd(jps_soce  )%laction )  THEN
[5352]1952         CALL cpl_snd( jps_soce  , isec, RESHAPE ( tsn(:,:,1,jp_sal), (/jpi,jpj,1/) ), info )
[5220]1953      ENDIF
[5299]1954      !                                                        ! first T level thickness
1955      IF( ssnd(jps_e3t1st )%laction )  THEN
[5352]1956         CALL cpl_snd( jps_e3t1st, isec, RESHAPE ( fse3t_n(:,:,1)   , (/jpi,jpj,1/) ), info )
[5299]1957      ENDIF
1958      !                                                        ! Qsr fraction
1959      IF( ssnd(jps_fraqsr)%laction )  THEN
[5352]1960         CALL cpl_snd( jps_fraqsr, isec, RESHAPE ( frq_m            , (/jpi,jpj,1/) ), info )
[5299]1961      ENDIF
[5220]1962      !
1963      !  Fields sent to ocean by ice model when OASIS coupling
1964      !                                                        ! Solar heat flux
1965      IF( ssnd(jps_qsroce)%laction )  CALL cpl_snd( jps_qsroce, isec, RESHAPE ( qsr , (/jpi,jpj,1/) ), info )
1966      IF( ssnd(jps_qnsoce)%laction )  CALL cpl_snd( jps_qnsoce, isec, RESHAPE ( qns , (/jpi,jpj,1/) ), info )
1967      IF( ssnd(jps_oemp  )%laction )  CALL cpl_snd( jps_oemp  , isec, RESHAPE ( emp , (/jpi,jpj,1/) ), info )
1968      IF( ssnd(jps_sflx  )%laction )  CALL cpl_snd( jps_sflx  , isec, RESHAPE ( sfx , (/jpi,jpj,1/) ), info )
1969      IF( ssnd(jps_otx1  )%laction )  CALL cpl_snd( jps_otx1  , isec, RESHAPE ( utau, (/jpi,jpj,1/) ), info )
1970      IF( ssnd(jps_oty1  )%laction )  CALL cpl_snd( jps_oty1  , isec, RESHAPE ( vtau, (/jpi,jpj,1/) ), info )
1971      IF( ssnd(jps_rnf   )%laction )  CALL cpl_snd( jps_rnf   , isec, RESHAPE ( rnf , (/jpi,jpj,1/) ), info )
1972      IF( ssnd(jps_taum  )%laction )  CALL cpl_snd( jps_taum  , isec, RESHAPE ( taum, (/jpi,jpj,1/) ), info )
1973
[3294]1974      CALL wrk_dealloc( jpi,jpj, zfr_l, ztmp1, ztmp2, zotx1, zoty1, zotz1, zitx1, zity1, zitz1 )
1975      CALL wrk_dealloc( jpi,jpj,jpl, ztmp3, ztmp4 )
[2715]1976      !
[3294]1977      IF( nn_timing == 1 )  CALL timing_stop('sbc_cpl_snd')
1978      !
[1226]1979   END SUBROUTINE sbc_cpl_snd
[1218]1980   
[888]1981   !!======================================================================
1982END MODULE sbccpl
Note: See TracBrowser for help on using the repository browser.