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.
Changeset 9987 for branches/UKMO/dev_r5518_obs_oper_update_icethick/NEMOGCM/NEMO/OPA_SRC/SBC – NEMO

Ignore:
Timestamp:
2018-07-23T11:33:03+02:00 (6 years ago)
Author:
emmafiedler
Message:

Merge with GO6 FOAMv14 package branch r9288

Location:
branches/UKMO/dev_r5518_obs_oper_update_icethick/NEMOGCM/NEMO/OPA_SRC/SBC
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • branches/UKMO/dev_r5518_obs_oper_update_icethick/NEMOGCM/NEMO/OPA_SRC/SBC/albedo.F90

    r7960 r9987  
    99   !!             -   ! 2001-06  (M. Vancoppenolle) LIM 3.0 
    1010   !!             -   ! 2006-08  (G. Madec)  cleaning for surface module 
     11   !!            3.6  ! 2016-01  (C. Rousset) new parameterization for sea ice albedo 
    1112   !!---------------------------------------------------------------------- 
    1213 
     
    2930 
    3031   INTEGER  ::   albd_init = 0      !: control flag for initialization 
    31    REAL(wp) ::   zzero     = 0.e0   ! constant values 
    32    REAL(wp) ::   zone      = 1.e0   !    "       " 
    33  
    34    REAL(wp) ::   c1     = 0.05    ! constants values 
    35    REAL(wp) ::   c2     = 0.10    !    "        " 
    36    REAL(wp) ::   rmue   = 0.40    !  cosine of local solar altitude 
    37  
     32   
     33   REAL(wp) ::   rmue     = 0.40    !  cosine of local solar altitude 
     34   REAL(wp) ::   ralb_oce = 0.066   ! ocean or lead albedo (Pegau and Paulson, Ann. Glac. 2001) 
     35   REAL(wp) ::   c1       = 0.05    ! snow thickness (only for nn_ice_alb=0) 
     36   REAL(wp) ::   c2       = 0.10    !  "        " 
     37   REAL(wp) ::   rcloud   = 0.06    ! cloud effect on albedo (only-for nn_ice_alb=0) 
     38  
    3839   !                             !!* namelist namsbc_alb 
    39    REAL(wp) ::   rn_cloud         !  cloudiness effect on snow or ice albedo (Grenfell & Perovich, 1984) 
    40 #if defined key_lim3 
    41    REAL(wp) ::   rn_albice        !  albedo of melting ice in the arctic and antarctic (Shine & Hendersson-Sellers) 
    42 #else 
    43    REAL(wp) ::   rn_albice        !  albedo of melting ice in the arctic and antarctic (Shine & Hendersson-Sellers) 
    44 #endif 
    45    REAL(wp) ::   rn_alphd         !  coefficients for linear interpolation used to compute 
    46    REAL(wp) ::   rn_alphdi        !  albedo between two extremes values (Pyane, 1972) 
    47    REAL(wp) ::   rn_alphc         !  
     40   INTEGER  ::   nn_ice_alb 
     41   REAL(wp) ::   rn_albice 
    4842 
    4943   !!---------------------------------------------------------------------- 
     
    5953      !!           
    6054      !! ** Purpose :   Computation of the albedo of the snow/ice system  
    61       !!                as well as the ocean one 
    6255      !!        
    63       !! ** Method  : - Computation of the albedo of snow or ice (choose the  
    64       !!                rignt one by a large number of tests 
    65       !!              - Computation of the albedo of the ocean 
    66       !! 
    67       !! References :   Shine and Hendersson-Sellers 1985, JGR, 90(D1), 2243-2250. 
     56      !! ** Method  :   Two schemes are available (from namelist parameter nn_ice_alb) 
     57      !!                  0: the scheme is that of Shine & Henderson-Sellers (JGR 1985) for clear-skies 
     58      !!                  1: the scheme is "home made" (for cloudy skies) and based on Brandt et al. (J. Climate 2005) 
     59      !!                                                                           and Grenfell & Perovich (JGR 2004) 
     60      !!                Description of scheme 1: 
     61      !!                  1) Albedo dependency on ice thickness follows the findings from Brandt et al (2005) 
     62      !!                     which are an update of Allison et al. (JGR 1993) ; Brandt et al. 1999 
     63      !!                     0-5cm  : linear function of ice thickness 
     64      !!                     5-150cm: log    function of ice thickness 
     65      !!                     > 150cm: constant 
     66      !!                  2) Albedo dependency on snow thickness follows the findings from Grenfell & Perovich (2004) 
     67      !!                     i.e. it increases as -EXP(-snw_thick/0.02) during freezing and -EXP(-snw_thick/0.03) during melting 
     68      !!                  3) Albedo dependency on clouds is speculated from measurements of Grenfell and Perovich (2004) 
     69      !!                     i.e. cloudy-clear albedo depend on cloudy albedo following a 2d order polynomial law 
     70      !!                  4) The needed 4 parameters are: dry and melting snow, freezing ice and bare puddled ice 
     71      !! 
     72      !! ** Note    :   The parameterization from Shine & Henderson-Sellers presents several misconstructions: 
     73      !!                  1) ice albedo when ice thick. tends to 0 is different than ocean albedo 
     74      !!                  2) for small ice thick. covered with some snow (<3cm?), albedo is larger  
     75      !!                     under melting conditions than under freezing conditions 
     76      !!                  3) the evolution of ice albedo as a function of ice thickness shows   
     77      !!                     3 sharp inflexion points (at 5cm, 100cm and 150cm) that look highly unrealistic 
     78      !! 
     79      !! References :   Shine & Henderson-Sellers 1985, JGR, 90(D1), 2243-2250. 
     80      !!                Brandt et al. 2005, J. Climate, vol 18 
     81      !!                Grenfell & Perovich 2004, JGR, vol 109  
    6882      !!---------------------------------------------------------------------- 
    6983      REAL(wp), INTENT(in   ), DIMENSION(:,:,:) ::   pt_ice      !  ice surface temperature (Kelvin) 
     
    7387      REAL(wp), INTENT(  out), DIMENSION(:,:,:) ::   pa_ice_os   !  albedo of ice under overcast sky 
    7488      !! 
    75       INTEGER  ::   ji, jj, jl    ! dummy loop indices 
    76       INTEGER  ::   ijpl          ! number of ice categories (3rd dim of ice input arrays) 
    77       REAL(wp) ::   zalbpsnm      ! albedo of ice under clear sky when snow is melting 
    78       REAL(wp) ::   zalbpsnf      ! albedo of ice under clear sky when snow is freezing 
    79       REAL(wp) ::   zalbpsn       ! albedo of snow/ice system when ice is coverd by snow 
    80       REAL(wp) ::   zalbpic       ! albedo of snow/ice system when ice is free of snow 
    81       REAL(wp) ::   zithsn        ! = 1 for hsn >= 0 ( ice is cov. by snow ) ; = 0 otherwise (ice is free of snow) 
    82       REAL(wp) ::   zitmlsn       ! = 1 freezinz snow (pt_ice >=rt0_snow) ; = 0 melting snow (pt_ice<rt0_snow) 
    83       REAL(wp) ::   zihsc1        ! = 1 hsn <= c1 ; = 0 hsn > c1 
    84       REAL(wp) ::   zihsc2        ! = 1 hsn >= c2 ; = 0 hsn < c2 
    85       !! 
    86       REAL(wp), POINTER, DIMENSION(:,:,:) ::   zalbfz    ! = rn_alphdi for freezing ice ; = rn_albice for melting ice 
    87       REAL(wp), POINTER, DIMENSION(:,:,:) ::   zficeth   !  function of ice thickness 
     89      INTEGER  ::   ji, jj, jl         ! dummy loop indices 
     90      INTEGER  ::   ijpl               ! number of ice categories (3rd dim of ice input arrays) 
     91      REAL(wp)            ::   ralb_im, ralb_sf, ralb_sm, ralb_if 
     92      REAL(wp)            ::   zswitch, z1_c1, z1_c2 
     93      REAL(wp)                            ::   zalb_sm, zalb_sf, zalb_st ! albedo of snow melting, freezing, total 
     94      REAL(wp), POINTER, DIMENSION(:,:,:) ::   zalb, zalb_it             ! intermediate variable & albedo of ice (snow free) 
    8895      !!--------------------------------------------------------------------- 
    89        
     96 
    9097      ijpl = SIZE( pt_ice, 3 )                     ! number of ice categories 
    91  
    92       CALL wrk_alloc( jpi,jpj,ijpl, zalbfz, zficeth ) 
     98       
     99      CALL wrk_alloc( jpi,jpj,ijpl, zalb, zalb_it ) 
    93100 
    94101      IF( albd_init == 0 )   CALL albedo_init      ! initialization  
    95102 
    96       !--------------------------- 
    97       !  Computation of  zficeth 
    98       !--------------------------- 
    99       ! ice free of snow and melts 
    100       WHERE     ( ph_snw == 0._wp .AND. pt_ice >= rt0_ice )   ;   zalbfz(:,:,:) = rn_albice 
    101       ELSE WHERE                                              ;   zalbfz(:,:,:) = rn_alphdi 
    102       END  WHERE 
    103  
    104       WHERE     ( 1.5  < ph_ice                     )  ;  zficeth = zalbfz 
    105       ELSE WHERE( 1.0  < ph_ice .AND. ph_ice <= 1.5 )  ;  zficeth = 0.472  + 2.0 * ( zalbfz - 0.472 ) * ( ph_ice - 1.0 ) 
    106       ELSE WHERE( 0.05 < ph_ice .AND. ph_ice <= 1.0 )  ;  zficeth = 0.2467 + 0.7049 * ph_ice              & 
    107          &                                                                 - 0.8608 * ph_ice * ph_ice     & 
    108          &                                                                 + 0.3812 * ph_ice * ph_ice * ph_ice 
    109       ELSE WHERE                                       ;  zficeth = 0.1    + 3.6    * ph_ice 
    110       END WHERE 
    111  
    112 !!gm old code 
    113 !      DO jl = 1, ijpl 
    114 !         DO jj = 1, jpj 
    115 !            DO ji = 1, jpi 
    116 !               IF( ph_ice(ji,jj,jl) > 1.5 ) THEN 
    117 !                  zficeth(ji,jj,jl) = zalbfz(ji,jj,jl) 
    118 !               ELSEIF( ph_ice(ji,jj,jl) > 1.0  .AND. ph_ice(ji,jj,jl) <= 1.5 ) THEN 
    119 !                  zficeth(ji,jj,jl) = 0.472 + 2.0 * ( zalbfz(ji,jj,jl) - 0.472 ) * ( ph_ice(ji,jj,jl) - 1.0 ) 
    120 !               ELSEIF( ph_ice(ji,jj,jl) > 0.05 .AND. ph_ice(ji,jj,jl) <= 1.0 ) THEN 
    121 !                  zficeth(ji,jj,jl) = 0.2467 + 0.7049 * ph_ice(ji,jj,jl)                               & 
    122 !                     &                    - 0.8608 * ph_ice(ji,jj,jl) * ph_ice(ji,jj,jl)                 & 
    123 !                     &                    + 0.3812 * ph_ice(ji,jj,jl) * ph_ice(ji,jj,jl) * ph_ice (ji,jj,jl) 
    124 !               ELSE 
    125 !                  zficeth(ji,jj,jl) = 0.1 + 3.6 * ph_ice(ji,jj,jl)  
    126 !               ENDIF 
    127 !            END DO 
    128 !         END DO 
    129 !      END DO 
    130 !!gm end old code 
    131        
    132       !-----------------------------------------------  
    133       !    Computation of the snow/ice albedo system  
    134       !-------------------------- --------------------- 
    135        
    136       !    Albedo of snow-ice for clear sky. 
    137       !-----------------------------------------------     
    138       DO jl = 1, ijpl 
    139          DO jj = 1, jpj 
    140             DO ji = 1, jpi 
    141                !  Case of ice covered by snow.              
    142                !                                        !  freezing snow         
    143                zihsc1   = 1.0 - MAX( zzero , SIGN( zone , - ( ph_snw(ji,jj,jl) - c1 ) ) ) 
    144                zalbpsnf = ( 1.0 - zihsc1 ) * (  zficeth(ji,jj,jl)                                             & 
    145                   &                           + ph_snw(ji,jj,jl) * ( rn_alphd - zficeth(ji,jj,jl) ) / c1  )   & 
    146                   &     +         zihsc1   * rn_alphd   
    147                !                                        !  melting snow                 
    148                zihsc2   = MAX( zzero , SIGN( zone , ph_snw(ji,jj,jl) - c2 ) ) 
    149                zalbpsnm = ( 1.0 - zihsc2 ) * ( rn_albice + ph_snw(ji,jj,jl) * ( rn_alphc - rn_albice ) / c2 )   & 
    150                   &     +         zihsc2   *   rn_alphc  
    151                ! 
    152                zitmlsn  =  MAX( zzero , SIGN( zone , pt_ice(ji,jj,jl) - rt0_snow ) )    
    153                zalbpsn  =  zitmlsn * zalbpsnm + ( 1.0 - zitmlsn ) * zalbpsnf 
    154              
    155                !  Case of ice free of snow. 
    156                zalbpic  = zficeth(ji,jj,jl)  
    157              
    158                ! albedo of the system    
    159                zithsn   = 1.0 - MAX( zzero , SIGN( zone , - ph_snw(ji,jj,jl) ) ) 
    160                pa_ice_cs(ji,jj,jl) =  zithsn * zalbpsn + ( 1.0 - zithsn ) *  zalbpic 
     103       
     104      SELECT CASE ( nn_ice_alb ) 
     105 
     106      !------------------------------------------ 
     107      !  Shine and Henderson-Sellers (1985) 
     108      !------------------------------------------ 
     109      CASE( 0 ) 
     110        
     111         ralb_sf = 0.80       ! dry snow 
     112         ralb_sm = 0.65       ! melting snow 
     113         ralb_if = 0.72       ! bare frozen ice 
     114         ralb_im = rn_albice  ! bare puddled ice  
     115          
     116         !  Computation of ice albedo (free of snow) 
     117         WHERE     ( ph_snw == 0._wp .AND. pt_ice >= rt0_ice )   ;   zalb(:,:,:) = ralb_im 
     118         ELSE WHERE                                              ;   zalb(:,:,:) = ralb_if 
     119         END  WHERE 
     120       
     121         WHERE     ( 1.5  < ph_ice                     )  ;  zalb_it = zalb 
     122         ELSE WHERE( 1.0  < ph_ice .AND. ph_ice <= 1.5 )  ;  zalb_it = 0.472  + 2.0 * ( zalb - 0.472 ) * ( ph_ice - 1.0 ) 
     123         ELSE WHERE( 0.05 < ph_ice .AND. ph_ice <= 1.0 )  ;  zalb_it = 0.2467 + 0.7049 * ph_ice              & 
     124            &                                                                 - 0.8608 * ph_ice * ph_ice     & 
     125            &                                                                 + 0.3812 * ph_ice * ph_ice * ph_ice 
     126         ELSE WHERE                                       ;  zalb_it = 0.1    + 3.6    * ph_ice 
     127         END WHERE 
     128      
     129         DO jl = 1, ijpl 
     130            DO jj = 1, jpj 
     131               DO ji = 1, jpi 
     132                  ! freezing snow 
     133                  ! no effect of underlying ice layer IF snow thickness > c1. Albedo does not depend on snow thick if > c2 
     134                  !                                        !  freezing snow         
     135                  zswitch   = 1._wp - MAX( 0._wp , SIGN( 1._wp , - ( ph_snw(ji,jj,jl) - c1 ) ) ) 
     136                  zalb_sf   = ( 1._wp - zswitch ) * (  zalb_it(ji,jj,jl)  & 
     137                     &                           + ph_snw(ji,jj,jl) * ( ralb_sf - zalb_it(ji,jj,jl) ) / c1  )   & 
     138                     &        +         zswitch   * ralb_sf   
     139 
     140                  ! melting snow 
     141                  ! no effect of underlying ice layer. Albedo does not depend on snow thick IF > c2 
     142                  zswitch   = MAX( 0._wp , SIGN( 1._wp , ph_snw(ji,jj,jl) - c2 ) ) 
     143                  zalb_sm = ( 1._wp - zswitch ) * ( ralb_im + ph_snw(ji,jj,jl) * ( ralb_sm - ralb_im ) / c2 )   & 
     144                      &     +         zswitch   *   ralb_sm  
     145                  ! 
     146                  ! snow albedo 
     147                  zswitch  =  MAX( 0._wp , SIGN( 1._wp , pt_ice(ji,jj,jl) - rt0_snow ) )    
     148                  zalb_st  =  zswitch * zalb_sm + ( 1._wp - zswitch ) * zalb_sf 
     149                
     150                  ! Ice/snow albedo 
     151                  zswitch   = 1._wp - MAX( 0._wp , SIGN( 1._wp , - ph_snw(ji,jj,jl) ) ) 
     152                  pa_ice_cs(ji,jj,jl) =  zswitch * zalb_st + ( 1._wp - zswitch ) * zalb_it(ji,jj,jl) 
     153                  ! 
     154               END DO 
    161155            END DO 
    162156         END DO 
    163       END DO 
    164        
    165       !    Albedo of snow-ice for overcast sky. 
    166       !----------------------------------------------   
    167       pa_ice_os(:,:,:) = pa_ice_cs(:,:,:) + rn_cloud       ! Oberhuber correction 
    168       ! 
    169       CALL wrk_dealloc( jpi,jpj,ijpl, zalbfz, zficeth ) 
     157 
     158         pa_ice_os(:,:,:) = pa_ice_cs(:,:,:) + rcloud       ! Oberhuber correction for overcast sky 
     159 
     160      !------------------------------------------ 
     161      !  New parameterization (2016) 
     162      !------------------------------------------ 
     163      CASE( 1 )  
     164 
     165         ralb_im = rn_albice  ! bare puddled ice 
     166! compilation of values from literature 
     167         ralb_sf = 0.85      ! dry snow 
     168         ralb_sm = 0.75      ! melting snow 
     169         ralb_if = 0.60      ! bare frozen ice 
     170! Perovich et al 2002 (Sheba) => the only dataset for which all types of ice/snow were retrieved 
     171!         ralb_sf = 0.85       ! dry snow 
     172!         ralb_sm = 0.72       ! melting snow 
     173!         ralb_if = 0.65       ! bare frozen ice 
     174! Brandt et al 2005 (East Antarctica) 
     175!         ralb_sf = 0.87      ! dry snow 
     176!         ralb_sm = 0.82      ! melting snow 
     177!         ralb_if = 0.54      ! bare frozen ice 
     178!  
     179         !  Computation of ice albedo (free of snow) 
     180         z1_c1 = 1. / ( LOG(1.5) - LOG(0.05) )  
     181         z1_c2 = 1. / 0.05 
     182         WHERE     ( ph_snw == 0._wp .AND. pt_ice >= rt0_ice )   ;   zalb = ralb_im 
     183         ELSE WHERE                                              ;   zalb = ralb_if 
     184         END  WHERE 
     185          
     186         WHERE     ( 1.5  < ph_ice                     )  ;  zalb_it = zalb 
     187         ELSE WHERE( 0.05 < ph_ice .AND. ph_ice <= 1.5 )  ;  zalb_it = zalb     + ( 0.18 - zalb     ) * z1_c1 *  & 
     188            &                                                                     ( LOG(1.5) - LOG(ph_ice) ) 
     189         ELSE WHERE                                       ;  zalb_it = ralb_oce + ( 0.18 - ralb_oce ) * z1_c2 * ph_ice 
     190         END WHERE 
     191 
     192         z1_c1 = 1. / 0.02 
     193         z1_c2 = 1. / 0.03 
     194         !  Computation of the snow/ice albedo 
     195         DO jl = 1, ijpl 
     196            DO jj = 1, jpj 
     197               DO ji = 1, jpi 
     198                  zalb_sf = ralb_sf - ( ralb_sf - zalb_it(ji,jj,jl)) * EXP( - ph_snw(ji,jj,jl) * z1_c1 ); 
     199                  zalb_sm = ralb_sm - ( ralb_sm - zalb_it(ji,jj,jl)) * EXP( - ph_snw(ji,jj,jl) * z1_c2 ); 
     200 
     201                   ! snow albedo 
     202                  zswitch = MAX( 0._wp , SIGN( 1._wp , pt_ice(ji,jj,jl) - rt0_snow ) )    
     203                  zalb_st = zswitch * zalb_sm + ( 1._wp - zswitch ) * zalb_sf 
     204 
     205                  ! Ice/snow albedo    
     206                  zswitch             = MAX( 0._wp , SIGN( 1._wp , - ph_snw(ji,jj,jl) ) ) 
     207                  pa_ice_os(ji,jj,jl) = ( 1._wp - zswitch ) * zalb_st + zswitch *  zalb_it(ji,jj,jl) 
     208 
     209              END DO 
     210            END DO 
     211         END DO 
     212         ! Effect of the clouds (2d order polynomial) 
     213         pa_ice_cs = pa_ice_os - ( - 0.1010 * pa_ice_os * pa_ice_os + 0.1933 * pa_ice_os - 0.0148 );  
     214 
     215      END SELECT 
     216       
     217      CALL wrk_dealloc( jpi,jpj,ijpl, zalb, zalb_it ) 
    170218      ! 
    171219   END SUBROUTINE albedo_ice 
     
    181229      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pa_oce_cs   !  albedo of ocean under clear sky 
    182230      !! 
    183       REAL(wp) ::   zcoef   ! local scalar 
    184       !!---------------------------------------------------------------------- 
    185       ! 
    186       zcoef = 0.05 / ( 1.1 * rmue**1.4 + 0.15 )      ! Parameterization of Briegled and Ramanathan, 1982  
    187       pa_oce_cs(:,:) = zcoef                
    188       pa_oce_os(:,:)  = 0.06                         ! Parameterization of Kondratyev, 1969 and Payne, 1972 
     231      REAL(wp) :: zcoef  
     232      !!---------------------------------------------------------------------- 
     233      ! 
     234      zcoef = 0.05 / ( 1.1 * rmue**1.4 + 0.15 )   ! Parameterization of Briegled and Ramanathan, 1982 
     235      pa_oce_cs(:,:) = zcoef  
     236      pa_oce_os(:,:) = 0.06                       ! Parameterization of Kondratyev, 1969 and Payne, 1972 
    189237      ! 
    190238   END SUBROUTINE albedo_oce 
     
    200248      !!---------------------------------------------------------------------- 
    201249      INTEGER  ::   ios                 ! Local integer output status for namelist read 
    202       NAMELIST/namsbc_alb/ rn_cloud, rn_albice, rn_alphd, rn_alphdi, rn_alphc 
     250      NAMELIST/namsbc_alb/ nn_ice_alb, rn_albice  
    203251      !!---------------------------------------------------------------------- 
    204252      ! 
     
    219267         WRITE(numout,*) '~~~~~~~' 
    220268         WRITE(numout,*) '   Namelist namsbc_alb : albedo ' 
    221          WRITE(numout,*) '      correction for snow and ice albedo                  rn_cloud  = ', rn_cloud 
    222          WRITE(numout,*) '      albedo of melting ice in the arctic and antarctic   rn_albice = ', rn_albice 
    223          WRITE(numout,*) '      coefficients for linear                             rn_alphd  = ', rn_alphd 
    224          WRITE(numout,*) '      interpolation used to compute albedo                rn_alphdi = ', rn_alphdi 
    225          WRITE(numout,*) '      between two extremes values (Pyane, 1972)           rn_alphc  = ', rn_alphc 
     269         WRITE(numout,*) '      choose the albedo parameterization                  nn_ice_alb = ', nn_ice_alb 
     270         WRITE(numout,*) '      albedo of bare puddled ice                          rn_albice  = ', rn_albice 
    226271      ENDIF 
    227272      ! 
  • branches/UKMO/dev_r5518_obs_oper_update_icethick/NEMOGCM/NEMO/OPA_SRC/SBC/cpl_oasis3.F90

    r7960 r9987  
    3131   USE in_out_manager               ! I/O manager 
    3232   USE lbclnk                       ! ocean lateral boundary conditions (or mpp link) 
    33  
     33    
    3434   IMPLICIT NONE 
    3535   PRIVATE 
     
    4141   PUBLIC   cpl_freq 
    4242   PUBLIC   cpl_finalize 
     43#if defined key_mpp_mpi 
     44   INCLUDE 'mpif.h' 
     45#endif 
     46    
     47   INTEGER, PARAMETER         :: localRoot  = 0 
     48   LOGICAL                    :: commRank            ! true for ranks doing OASIS communication 
     49#if defined key_cpl_rootexchg 
     50   LOGICAL                    :: rootexchg =.true.   ! logical switch  
     51#else 
     52   LOGICAL                    :: rootexchg =.false.  ! logical switch  
     53#endif  
    4354 
    4455   INTEGER, PUBLIC            ::   OASIS_Rcv  = 1    !: return code if received field 
     
    8293 
    8394   REAL(wp), DIMENSION(:,:), ALLOCATABLE ::   exfld   ! Temporary buffer for receiving 
    84  
     95   INTEGER, PUBLIC :: localComm  
     96       
    8597   !!---------------------------------------------------------------------- 
    8698   !! NEMO/OPA 3.3 , NEMO Consortium (2010) 
     
    120132      IF ( nerror /= OASIS_Ok ) & 
    121133         CALL oasis_abort (ncomp_id, 'cpl_init','Failure in oasis_get_localcomm' ) 
     134      localComm = kl_comm  
    122135      ! 
    123136   END SUBROUTINE cpl_init 
     
    177190      IF( nerror > 0 ) THEN 
    178191         CALL oasis_abort ( ncomp_id, 'cpl_define', 'Failure in allocating exfld')   ;   RETURN 
    179       ENDIF 
     192      ENDIF       
    180193      ! 
    181194      ! ----------------------------------------------------------------- 
    182195      ! ... Define the partition  
    183196      ! ----------------------------------------------------------------- 
    184        
     197             
    185198      paral(1) = 2                                              ! box partitioning 
    186199      paral(2) = jpiglo * (nldj-1+njmpp-1) + (nldi-1+nimpp-1)   ! NEMO lower left corner global offset     
     
    196209      ENDIF 
    197210       
    198       CALL oasis_def_partition ( id_part, paral, nerror ) 
     211      CALL oasis_def_partition ( id_part, paral, nerror, jpiglo*jpjglo) 
    199212      ! 
    200213      ! ... Announce send variables.  
     
    241254            END DO 
    242255         ENDIF 
    243       END DO 
     256      END DO       
    244257      ! 
    245258      ! ... Announce received variables.  
     
    373386            IF( srcv(kid)%nid(jc,jm) /= -1 ) THEN 
    374387 
    375                CALL oasis_get ( srcv(kid)%nid(jc,jm), kstep, exfld, kinfo )          
     388               CALL oasis_get ( srcv(kid)%nid(jc,jm), kstep, exfld, kinfo )    
    376389                
    377390               llaction =  kinfo == OASIS_Recvd   .OR. kinfo == OASIS_FromRest .OR.   & 
     
    384397                  kinfo = OASIS_Rcv 
    385398                  IF( llfisrt ) THEN  
    386                      pdata(nldi:nlei,nldj:nlej,jc) =                                 exfld(:,:) * pmask(nldi:nlei,nldj:nlej,jm) 
     399                     pdata(nldi:nlei,nldj:nlej,jc) =                                 exfld(:,:) * pmask(nldi:nlei,nldj:nlej,jm)  
    387400                     llfisrt = .FALSE. 
    388401                  ELSE 
     
    463476         CALL oasis_get_freqs(id, mop, 1, itmp, info) 
    464477#else 
     478#if defined key_oasis3  
     479         itmp(1) = namflddti( id ) 
     480#else 
    465481         CALL oasis_get_freqs(id,      1, itmp, info) 
     482#endif 
    466483#endif 
    467484         cpl_freq = itmp(1) 
     
    514531   END SUBROUTINE oasis_get_localcomm 
    515532 
    516    SUBROUTINE oasis_def_partition(k1,k2,k3) 
     533   SUBROUTINE oasis_def_partition(k1,k2,k3,K4) 
    517534      INTEGER     , INTENT(  out) ::  k1,k3 
    518535      INTEGER     , INTENT(in   ) ::  k2(5) 
     536      INTEGER     , OPTIONAL, INTENT(in   ) ::  k4 
    519537      k1 = k2(1) ; k3 = k2(5) 
    520538      WRITE(numout,*) 'oasis_def_partition: Error you sould not be there...' 
  • branches/UKMO/dev_r5518_obs_oper_update_icethick/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90

    r7960 r9987  
    3232   PUBLIC   fld_map    ! routine called by tides_init 
    3333   PUBLIC   fld_read, fld_fill   ! called by sbc... modules 
     34   PUBLIC   fld_clopn 
    3435 
    3536   TYPE, PUBLIC ::   FLD_N      !: Namelist field informations 
     
    815816         imonth = kmonth 
    816817         iday = kday 
     818         IF ( sdjf%cltype(1:4) == 'week' ) THEN             ! find the day of the beginning of the week 
     819            isec_week = ksec_week( sdjf%cltype(6:8) )- (86400 * 8 )   
     820            llprevmth  = isec_week > nsec_month             ! longer time since beginning of the week than the month 
     821            llprevyr   = llprevmth .AND. nmonth == 1 
     822            iyear  = nyear  - COUNT((/llprevyr /)) 
     823            imonth = nmonth - COUNT((/llprevmth/)) + 12 * COUNT((/llprevyr /)) 
     824            iday   = nday   + nmonth_len(nmonth-1) * COUNT((/llprevmth/)) - isec_week / NINT(rday) 
     825         ENDIF 
    817826      ELSE                                                  ! use current day values 
    818827         IF ( sdjf%cltype(1:4) == 'week' ) THEN             ! find the day of the beginning of the week 
     
    12811290      CHARACTER(LEN=*)          , INTENT(in   ) ::   lsmfile ! land sea mask file name 
    12821291      !!  
    1283       REAL(wp),DIMENSION(:,:,:),ALLOCATABLE     ::   ztmp_fly_dta,zfieldo                  ! temporary array of values on input grid 
     1292      REAL(wp),DIMENSION(:,:,:),ALLOCATABLE     ::   ztmp_fly_dta                          ! temporary array of values on input grid 
    12841293      INTEGER, DIMENSION(3)                     ::   rec1,recn                             ! temporary arrays for start and length 
    12851294      INTEGER, DIMENSION(3)                     ::   rec1_lsm,recn_lsm                     ! temporary arrays for start and length in case of seaoverland 
     
    13471356 
    13481357 
    1349          itmpi=SIZE(ztmp_fly_dta(jpi1_lsm:jpi2_lsm,jpj1_lsm:jpj2_lsm,:),1) 
    1350          itmpj=SIZE(ztmp_fly_dta(jpi1_lsm:jpi2_lsm,jpj1_lsm:jpj2_lsm,:),2) 
     1358         itmpi=jpi2_lsm-jpi1_lsm+1 
     1359         itmpj=jpj2_lsm-jpj1_lsm+1 
    13511360         itmpz=kk 
    13521361         ALLOCATE(ztmp_fly_dta(itmpi,itmpj,itmpz)) 
  • branches/UKMO/dev_r5518_obs_oper_update_icethick/NEMOGCM/NEMO/OPA_SRC/SBC/geo2ocean.F90

    r7960 r9987  
    5151 
    5252   SUBROUTINE repcmo ( pxu1, pyu1, pxv1, pyv1,   & 
    53                        px2 , py2 ) 
     53                       px2 , py2 , kchoix  ) 
    5454      !!---------------------------------------------------------------------- 
    5555      !!                  ***  ROUTINE repcmo  *** 
     
    6868      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   py2          ! j-componante (defined at v-point) 
    6969      !!---------------------------------------------------------------------- 
    70        
    71       ! Change from geographic to stretched coordinate 
    72       ! ---------------------------------------------- 
    73       CALL rot_rep( pxu1, pyu1, 'U', 'en->i',px2 ) 
    74       CALL rot_rep( pxv1, pyv1, 'V', 'en->j',py2 ) 
    75        
     70      INTEGER, INTENT( IN ) ::   & 
     71         kchoix   ! type of transformation 
     72                  ! = 1 change from geographic to model grid. 
     73                  ! =-1 change from model to geographic grid 
     74      !!---------------------------------------------------------------------- 
     75  
     76      SELECT CASE (kchoix) 
     77      CASE ( 1) 
     78        ! Change from geographic to stretched coordinate 
     79        ! ---------------------------------------------- 
     80      
     81        CALL rot_rep( pxu1, pyu1, 'U', 'en->i',px2 ) 
     82        CALL rot_rep( pxv1, pyv1, 'V', 'en->j',py2 ) 
     83      CASE (-1) 
     84       ! Change from stretched to geographic coordinate 
     85       ! ---------------------------------------------- 
     86      
     87       CALL rot_rep( pxu1, pyu1, 'U', 'ij->e',px2 ) 
     88       CALL rot_rep( pxv1, pyv1, 'V', 'ij->n',py2 ) 
     89     END SELECT 
     90      
    7691   END SUBROUTINE repcmo 
    7792 
  • branches/UKMO/dev_r5518_obs_oper_update_icethick/NEMOGCM/NEMO/OPA_SRC/SBC/sbc_ice.F90

    r7960 r9987  
    8080   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   qemp_oce       !: heat flux of precip and evap over ocean     [W/m2] 
    8181   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   qemp_ice       !: heat flux of precip and evap over ice       [W/m2] 
    82    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   qprec_ice      !: heat flux of precip over ice                [J/m3] 
     82   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   qevap_ice      !: heat flux of evap over ice                  [W/m2] 
     83   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   qprec_ice      !: enthalpy of precip over ice                 [J/m3] 
    8384   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   emp_oce        !: evap - precip over ocean                 [kg/m2/s] 
    8485#endif 
     
    101102   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   fr_iu              !: ice fraction at NEMO U point 
    102103   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   fr_iv              !: ice fraction at NEMO V point 
    103     
     104   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   sstfrz             !: sea surface freezing temperature 
     105   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   tsfc_ice           !: sea-ice surface skin temperature (on categories) 
     106   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   kn_ice             !: sea-ice surface layer thermal conductivity (on cats) 
     107 
    104108   ! variables used in the coupled interface 
    105109   INTEGER , PUBLIC, PARAMETER ::   jpl = ncat 
    106110   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   u_ice, v_ice          ! jpi, jpj 
     111   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::  a_p, ht_p ! Meltpond fraction and depth 
     112    
     113   ! 
     114    
     115   ! 
     116#if defined key_asminc 
     117   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   ndaice_da          !: NEMO fresh water flux to ocean due to data assim 
     118   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   nfresh_da          !: NEMO salt flux to ocean due to data assim 
     119   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   nfsalt_da          !: NEMO ice concentration change/second from data assim 
     120#endif 
     121       
    107122#endif 
    108123    
     
    144159#endif 
    145160#if defined key_lim3 
    146          &      evap_ice(jpi,jpj,jpl) , devap_ice(jpi,jpj,jpl) , qprec_ice(jpi,jpj) ,  & 
    147          &      qemp_ice(jpi,jpj)     , qemp_oce(jpi,jpj)      ,                       & 
    148          &      qns_oce (jpi,jpj)     , qsr_oce (jpi,jpj)      , emp_oce (jpi,jpj)  ,  & 
     161         &      evap_ice(jpi,jpj,jpl) , devap_ice(jpi,jpj,jpl) , qprec_ice(jpi,jpj) ,   & 
     162         &      qemp_ice(jpi,jpj)     , qevap_ice(jpi,jpj,jpl) , qemp_oce (jpi,jpj) ,   & 
     163         &      qns_oce (jpi,jpj)     , qsr_oce  (jpi,jpj)     , emp_oce (jpi,jpj)  ,   & 
    149164#endif 
    150165         &      emp_ice(jpi,jpj)      ,  STAT= ierr(1) ) 
     
    152167 
    153168#if defined key_cice 
    154       ALLOCATE( qla_ice(jpi,jpj,1)    , qlw_ice(jpi,jpj,1)    , qsr_ice(jpi,jpj,1)    , & 
     169      ALLOCATE( qla_ice(jpi,jpj,ncat) , qlw_ice(jpi,jpj,1)    , qsr_ice(jpi,jpj,1)    , & 
    155170                wndi_ice(jpi,jpj)     , tatm_ice(jpi,jpj)     , qatm_ice(jpi,jpj)     , & 
    156171                wndj_ice(jpi,jpj)     , nfrzmlt(jpi,jpj)      , ss_iou(jpi,jpj)       , & 
    157172                ss_iov(jpi,jpj)       , fr_iu(jpi,jpj)        , fr_iv(jpi,jpj)        , & 
    158173                a_i(jpi,jpj,ncat)     , topmelt(jpi,jpj,ncat) , botmelt(jpi,jpj,ncat) , & 
    159                 STAT= ierr(1) ) 
    160       IF( ln_cpl )   ALLOCATE( u_ice(jpi,jpj)        , fr1_i0(jpi,jpj)       , tn_ice (jpi,jpj,1)    , & 
     174#if defined key_asminc 
     175                ndaice_da(jpi,jpj)    , nfresh_da(jpi,jpj)    , nfsalt_da(jpi,jpj)    , & 
     176#endif 
     177                sstfrz(jpi,jpj)       , STAT= ierr(1) ) 
     178   ! Alex West: Allocating tn_ice with 5 categories.  When NEMO is used with CICE, this variable 
     179   ! represents top layer ice temperature, which is multi-category. 
     180      IF( ln_cpl )   ALLOCATE( u_ice(jpi,jpj)        , fr1_i0(jpi,jpj)       , tn_ice (jpi,jpj,jpl)  , & 
    161181         &                     v_ice(jpi,jpj)        , fr2_i0(jpi,jpj)       , alb_ice(jpi,jpj,1)    , & 
    162182         &                     emp_ice(jpi,jpj)      , qns_ice(jpi,jpj,1)    , dqns_ice(jpi,jpj,1)   , & 
    163          &                     STAT= ierr(2) ) 
     183         &                     a_p(jpi,jpj,jpl)      , ht_p(jpi,jpj,jpl)     , tsfc_ice(jpi,jpj,jpl) , & 
     184         &                     kn_ice(jpi,jpj,jpl) ,    STAT=ierr(2) ) 
    164185       
    165186#endif 
  • branches/UKMO/dev_r5518_obs_oper_update_icethick/NEMOGCM/NEMO/OPA_SRC/SBC/sbc_oce.F90

    r7960 r9987  
    125125#endif 
    126126   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: xcplmask          !: coupling mask for ln_mixcpl (warning: allocated in sbccpl) 
     127   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   greenland_icesheet_mass_array, greenland_icesheet_mask 
     128   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   antarctica_icesheet_mass_array, antarctica_icesheet_mask 
    127129 
    128130   !!---------------------------------------------------------------------- 
     
    137139   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   e3t_m     !: mean (nn_fsbc time-step) sea surface layer thickness       [m] 
    138140   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   frq_m     !: mean (nn_fsbc time-step) fraction of solar net radiation absorbed in the 1st T level [-] 
     141    
     142   !!---------------------------------------------------------------------- 
     143   !!  Surface scalars of total ice sheet mass for Greenland and Antarctica,  
     144   !! passed from atmosphere to be converted to dvol and hence a freshwater  
     145   !! flux  by using old values. New values are saved in the dump, to become 
     146   !! old values next coupling timestep. Freshwater fluxes split between  
     147   !! sub iceshelf melting and iceberg calving, scalled to flux per second 
     148   !!---------------------------------------------------------------------- 
     149    
     150   REAL(wp), PUBLIC  :: greenland_icesheet_mass, greenland_icesheet_mass_rate_of_change, greenland_icesheet_timelapsed  
     151   REAL(wp), PUBLIC  :: antarctica_icesheet_mass, antarctica_icesheet_mass_rate_of_change, antarctica_icesheet_timelapsed 
     152 
     153   ! sbccpl namelist parameters associated with icesheet freshwater input code. Included here rather than in sbccpl.F90 to  
     154   ! avoid circular dependencies. 
     155   INTEGER, PUBLIC     ::   nn_coupled_iceshelf_fluxes     ! =0 : total freshwater input from iceberg calving and ice shelf basal melting  
     156                                                           ! taken from climatologies used (no action in coupling routines). 
     157                                                           ! =1 :  use rate of change of mass of Greenland and Antarctic icesheets to set the  
     158                                                           ! combined magnitude of the iceberg calving and iceshelf melting freshwater fluxes. 
     159                                                           ! =2 :  specify constant freshwater inputs in this namelist to set the combined 
     160                                                           ! magnitude of iceberg calving and iceshelf melting freshwater fluxes. 
     161   LOGICAL, PUBLIC     ::   ln_iceshelf_init_atmos         ! If true force ocean to initialise iceshelf masses from atmospheric values rather 
     162                                                           ! than values in ocean restart (applicable if nn_coupled_iceshelf_fluxes=1). 
     163   REAL(wp), PUBLIC    ::   rn_greenland_total_fw_flux    ! Constant total rate of freshwater input (kg/s) for Greenland (if nn_coupled_iceshelf_fluxes=2)  
     164   REAL(wp), PUBLIC    ::   rn_greenland_calving_fraction  ! Set fraction of total freshwater flux for iceberg calving - remainder goes to iceshelf melting. 
     165   REAL(wp), PUBLIC    ::   rn_antarctica_total_fw_flux   ! Constant total rate of freshwater input (kg/s) for Antarctica (if nn_coupled_iceshelf_fluxes=2)  
     166   REAL(wp), PUBLIC    ::   rn_antarctica_calving_fraction ! Set fraction of total freshwater flux for iceberg calving - remainder goes to iceshelf melting. 
     167   REAL(wp), PUBLIC    ::   rn_iceshelf_fluxes_tolerance   ! Absolute tolerance for detecting differences in icesheet masses.  
    139168 
    140169   !! * Substitutions 
     
    172201         &      ssu_m  (jpi,jpj) , sst_m(jpi,jpj) , frq_m(jpi,jpj) ,      & 
    173202         &      ssv_m  (jpi,jpj) , sss_m(jpi,jpj) , ssh_m(jpi,jpj) , STAT=ierr(4) ) 
     203      ALLOCATE( greenland_icesheet_mass_array(jpi,jpj) , antarctica_icesheet_mass_array(jpi,jpj) ) 
     204      ALLOCATE( greenland_icesheet_mask(jpi,jpj) , antarctica_icesheet_mask(jpi,jpj) ) 
    174205         ! 
    175206#if defined key_vvl 
  • branches/UKMO/dev_r5518_obs_oper_update_icethick/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_clio.F90

    r7960 r9987  
    684684      qprec_ice(:,:) = rhosn * ( ( MIN( sf(jp_tair)%fnow(:,:,1), rt0_snow ) - rt0 ) * cpic * tmask(:,:,1) - lfus ) 
    685685 
     686      ! --- heat content of evap over ice in W/m2 (to be used in 1D-thermo) --- ! 
     687      DO jl = 1, jpl 
     688         qevap_ice(:,:,jl) = 0._wp ! should be -evap_ice(:,:,jl)*( ( Tice - rt0 ) * cpic * tmask(:,:,1) - lfus ) 
     689                                   ! but then qemp_ice should also include sublimation  
     690      END DO 
     691 
    686692      CALL wrk_dealloc( jpi,jpj, zevap, zsnw )  
    687693#endif 
  • branches/UKMO/dev_r5518_obs_oper_update_icethick/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_core.F90

    r7960 r9987  
    9191   REAL(wp) ::   rn_zqt      ! z(q,t) : height of humidity and temperature measurements 
    9292   REAL(wp) ::   rn_zu       ! z(u)   : height of wind measurements 
     93   REAL(wp), PUBLIC :: rn_sfac ! multiplication factor for snow precipitation over sea-ice 
    9394 
    9495   !! * Substitutions 
     
    151152         &                  sn_wndi, sn_wndj, sn_humi  , sn_qsr ,           & 
    152153         &                  sn_qlw , sn_tair, sn_prec  , sn_snow,           & 
    153          &                  sn_tdif, rn_zqt,  rn_zu 
     154         &                  sn_tdif, rn_zqt,  rn_zu, rn_sfac 
    154155      !!--------------------------------------------------------------------- 
    155156      ! 
     
    158159         !                                      ! ====================== ! 
    159160         ! 
     161         rn_sfac = 1._wp       ! Default to one if missing from namelist  
    160162         REWIND( numnam_ref )              ! Namelist namsbc_core in reference namelist : CORE bulk parameters 
    161163         READ  ( numnam_ref, namsbc_core, IOSTAT = ios, ERR = 901) 
     
    206208      IF( MOD( kt - 1, nn_fsbc ) == 0 )   THEN 
    207209         qlw_ice(:,:,1)   = sf(jp_qlw)%fnow(:,:,1)  
    208          qsr_ice(:,:,1)   = sf(jp_qsr)%fnow(:,:,1) 
     210         IF( ln_dm2dc ) THEN ; qsr_ice(:,:,1) = sbc_dcy( sf(jp_qsr)%fnow(:,:,1) ) 
     211         ELSE                ; qsr_ice(:,:,1) =          sf(jp_qsr)%fnow(:,:,1) 
     212         ENDIF 
    209213         tatm_ice(:,:)    = sf(jp_tair)%fnow(:,:,1)          
    210214         qatm_ice(:,:)    = sf(jp_humi)%fnow(:,:,1) 
     
    403407         CALL iom_put( "qsr_oce" ,   qsr  )                 ! output downward solar heat over the ocean 
    404408         CALL iom_put( "qt_oce"  ,   qns+qsr )              ! output total downward heat over the ocean 
     409         tprecip(:,:) = sf(jp_prec)%fnow(:,:,1) * rn_pfac   ! output total precipitation [kg/m2/s] 
     410         sprecip(:,:) = sf(jp_snow)%fnow(:,:,1) * rn_pfac   ! output solid precipitation [kg/m2/s] 
     411         CALL iom_put( 'snowpre', sprecip * 86400. )        ! Snow 
     412         CALL iom_put( 'precip' , tprecip * 86400. )        ! Total precipitation 
    405413      ENDIF 
    406414      ! 
     
    608616      ! --- evaporation --- ! 
    609617      z1_lsub = 1._wp / Lsub 
    610       evap_ice (:,:,:) = qla_ice (:,:,:) * z1_lsub ! sublimation 
    611       devap_ice(:,:,:) = dqla_ice(:,:,:) * z1_lsub 
    612       zevap    (:,:)   = emp(:,:) + tprecip(:,:)   ! evaporation over ocean 
     618      evap_ice (:,:,:) = rn_efac * qla_ice (:,:,:) * z1_lsub    ! sublimation 
     619      devap_ice(:,:,:) = rn_efac * dqla_ice(:,:,:) * z1_lsub    ! d(sublimation)/dT 
     620      zevap    (:,:)   = rn_efac * ( emp(:,:) + tprecip(:,:) )  ! evaporation over ocean 
    613621 
    614622      ! --- evaporation minus precipitation --- ! 
     
    633641      ! --- heat content of precip over ice in J/m3 (to be used in 1D-thermo) --- ! 
    634642      qprec_ice(:,:) = rhosn * ( ( MIN( sf(jp_tair)%fnow(:,:,1), rt0_snow ) - rt0 ) * cpic * tmask(:,:,1) - lfus ) 
     643 
     644      ! --- heat content of evap over ice in W/m2 (to be used in 1D-thermo) --- ! 
     645      DO jl = 1, jpl 
     646         qevap_ice(:,:,jl) = 0._wp ! should be -evap_ice(:,:,jl)*( ( Tice - rt0 ) * cpic * tmask(:,:,1) ) 
     647                                   ! But we do not have Tice => consider it at 0°C => evap=0  
     648      END DO 
    635649 
    636650      CALL wrk_dealloc( jpi,jpj, zevap, zsnw )  
  • branches/UKMO/dev_r5518_obs_oper_update_icethick/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90

    r7960 r9987  
    3333   USE cpl_oasis3      ! OASIS3 coupling 
    3434   USE geo2ocean       !  
    35    USE oce   , ONLY : tsn, un, vn, sshn, ub, vb, sshb, fraqsr_1lev 
     35   USE oce   , ONLY : tsn, un, vn, sshn, ub, vb, sshb, fraqsr_1lev,            & 
     36                      CO2Flux_out_cpl, DMS_out_cpl, chloro_out_cpl,            &  
     37                      PCO2a_in_cpl, Dust_in_cpl, & 
     38                      ln_medusa 
    3639   USE albedo          ! 
    3740   USE in_out_manager  ! I/O manager 
     
    4649   USE p4zflx, ONLY : oce_co2 
    4750#endif 
    48 #if defined key_cice 
    49    USE ice_domain_size, only: ncat 
    50 #endif 
    5151#if defined key_lim3 
    5252   USE limthd_dh       ! for CALL lim_thd_snwblow 
    5353#endif 
     54   USE lib_fortran, ONLY: glob_sum 
    5455 
    5556   IMPLICIT NONE 
     
    105106   INTEGER, PARAMETER ::   jpr_e3t1st = 41            ! first T level thickness  
    106107   INTEGER, PARAMETER ::   jpr_fraqsr = 42            ! fraction of solar net radiation absorbed in the first ocean level 
    107    INTEGER, PARAMETER ::   jprcv      = 42            ! total number of fields received 
     108   INTEGER, PARAMETER ::   jpr_ts_ice = 43            ! skin temperature of sea-ice (used for melt-ponds) 
     109   INTEGER, PARAMETER ::   jpr_grnm   = 44            ! Greenland ice mass 
     110   INTEGER, PARAMETER ::   jpr_antm   = 45            ! Antarctic ice mass 
     111   INTEGER, PARAMETER ::   jpr_atm_pco2 = 46          ! Incoming atm CO2 flux 
     112   INTEGER, PARAMETER ::   jpr_atm_dust = 47          ! Incoming atm aggregate dust  
     113   INTEGER, PARAMETER ::   jprcv      = 47            ! total number of fields received 
    108114 
    109115   INTEGER, PARAMETER ::   jps_fice   =  1            ! ice fraction sent to the atmosphere 
     
    135141   INTEGER, PARAMETER ::   jps_e3t1st = 27            ! first level depth (vvl) 
    136142   INTEGER, PARAMETER ::   jps_fraqsr = 28            ! fraction of solar net radiation absorbed in the first ocean level 
    137    INTEGER, PARAMETER ::   jpsnd      = 28            ! total number of fields sended 
     143   INTEGER, PARAMETER ::   jps_a_p    = 29            ! meltpond fraction   
     144   INTEGER, PARAMETER ::   jps_ht_p   = 30            ! meltpond depth (m)  
     145   INTEGER, PARAMETER ::   jps_kice   = 31            ! ice surface layer thermal conductivity 
     146   INTEGER, PARAMETER ::   jps_sstfrz = 32            ! sea-surface freezing temperature 
     147   INTEGER, PARAMETER ::   jps_fice1  = 33            ! first-order ice concentration (for time-travelling ice coupling) 
     148   INTEGER, PARAMETER ::   jps_bio_co2 = 34           ! MEDUSA air-sea CO2 flux 
     149   INTEGER, PARAMETER ::   jps_bio_dms = 35           ! MEDUSA DMS surface concentration 
     150   INTEGER, PARAMETER ::   jps_bio_chloro = 36        ! MEDUSA chlorophyll surface concentration 
     151   INTEGER, PARAMETER ::   jpsnd      = 36            ! total number of fields sent 
     152 
     153   REAL(wp), PARAMETER :: dms_unit_conv = 1.0e+6      ! Coversion factor to get outgong DMS in standard units for coupling 
     154                                                 ! i.e. specifically nmol/L (= umol/m3) 
    138155 
    139156   !                                                         !!** namelist namsbc_cpl ** 
     
    146163   END TYPE FLD_C 
    147164   ! Send to the atmosphere                           ! 
    148    TYPE(FLD_C) ::   sn_snd_temp, sn_snd_alb, sn_snd_thick, sn_snd_crt, sn_snd_co2                         
     165   TYPE(FLD_C) ::   sn_snd_temp, sn_snd_alb, sn_snd_thick, sn_snd_crt, sn_snd_co2, sn_snd_cond, sn_snd_mpnd, sn_snd_sstfrz, sn_snd_thick1 
     166   TYPE(FLD_C) ::   sn_snd_bio_co2, sn_snd_bio_dms, sn_snd_bio_chloro                    
     167 
    149168   ! Received from the atmosphere                     ! 
    150169   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 
    151    TYPE(FLD_C) ::   sn_rcv_cal, sn_rcv_iceflx, sn_rcv_co2                         
     170   TYPE(FLD_C) ::   sn_rcv_cal, sn_rcv_iceflx, sn_rcv_co2, sn_rcv_ts_ice, sn_rcv_grnm, sn_rcv_antm 
     171   TYPE(FLD_C) ::   sn_rcv_atm_pco2, sn_rcv_atm_dust                          
     172 
    152173   ! Other namelist parameters                        ! 
    153174   INTEGER     ::   nn_cplmodel            ! Maximum number of models to/from which NEMO is potentialy sending/receiving data 
     
    188209      ALLOCATE( a_i(jpi,jpj,1) , STAT=ierr(2) )  ! used in sbcice_if.F90 (done here as there is no sbc_ice_if_init) 
    189210#endif 
    190       ALLOCATE( xcplmask(jpi,jpj,0:nn_cplmodel) , STAT=ierr(3) ) 
     211      !ALLOCATE( xcplmask(jpi,jpj,0:nn_cplmodel) , STAT=ierr(3) ) 
     212      ! Hardwire only two models as nn_cplmodel has not been read in 
     213      ! from the namelist yet. 
     214      ALLOCATE( xcplmask(jpi,jpj,0:2) , STAT=ierr(3) )    
    191215      ! 
    192216      sbc_cpl_alloc = MAXVAL( ierr ) 
     
    216240      REAL(wp), POINTER, DIMENSION(:,:) ::   zacs, zaos 
    217241      !! 
    218       NAMELIST/namsbc_cpl/  sn_snd_temp, sn_snd_alb   , sn_snd_thick, sn_snd_crt   , sn_snd_co2,      & 
    219          &                  sn_rcv_w10m, sn_rcv_taumod, sn_rcv_tau  , sn_rcv_dqnsdt, sn_rcv_qsr,      & 
    220          &                  sn_rcv_qns , sn_rcv_emp   , sn_rcv_rnf  , sn_rcv_cal   , sn_rcv_iceflx,   & 
    221          &                  sn_rcv_co2 , nn_cplmodel  , ln_usecplmask 
     242      NAMELIST/namsbc_cpl/  sn_snd_temp, sn_snd_alb   , sn_snd_thick , sn_snd_crt   , sn_snd_co2,     & 
     243         &                  sn_snd_cond, sn_snd_mpnd  , sn_snd_sstfrz, sn_snd_thick1,                 & 
     244         &                  sn_rcv_w10m, sn_rcv_taumod, sn_rcv_tau   , sn_rcv_dqnsdt, sn_rcv_qsr,     & 
     245         &                  sn_rcv_qns , sn_rcv_emp   , sn_rcv_rnf   , sn_rcv_cal   , sn_rcv_iceflx,  & 
     246         &                  sn_rcv_co2 , sn_rcv_grnm  , sn_rcv_antm  , sn_rcv_ts_ice, nn_cplmodel  ,  & 
     247         &                  ln_usecplmask, nn_coupled_iceshelf_fluxes, ln_iceshelf_init_atmos,        & 
     248         &                  rn_greenland_total_fw_flux, rn_greenland_calving_fraction, & 
     249         &                  rn_antarctica_total_fw_flux, rn_antarctica_calving_fraction, rn_iceshelf_fluxes_tolerance 
    222250      !!--------------------------------------------------------------------- 
     251 
     252      ! Add MEDUSA related fields to namelist 
     253      NAMELIST/namsbc_cpl/  sn_snd_bio_co2, sn_snd_bio_dms, sn_snd_bio_chloro,                        & 
     254         &                  sn_rcv_atm_pco2, sn_rcv_atm_dust 
     255 
     256      !!--------------------------------------------------------------------- 
     257 
    223258      ! 
    224259      IF( nn_timing == 1 )  CALL timing_start('sbc_cpl_init') 
     
    245280      ENDIF 
    246281      IF( lwp .AND. ln_cpl ) THEN                        ! control print 
    247          WRITE(numout,*)'  received fields (mutiple ice categogies)' 
     282         WRITE(numout,*)'  received fields (mutiple ice categories)' 
    248283         WRITE(numout,*)'      10m wind module                 = ', TRIM(sn_rcv_w10m%cldes  ), ' (', TRIM(sn_rcv_w10m%clcat  ), ')' 
    249284         WRITE(numout,*)'      stress module                   = ', TRIM(sn_rcv_taumod%cldes), ' (', TRIM(sn_rcv_taumod%clcat), ')' 
     
    258293         WRITE(numout,*)'      runoffs                         = ', TRIM(sn_rcv_rnf%cldes   ), ' (', TRIM(sn_rcv_rnf%clcat   ), ')' 
    259294         WRITE(numout,*)'      calving                         = ', TRIM(sn_rcv_cal%cldes   ), ' (', TRIM(sn_rcv_cal%clcat   ), ')' 
     295         WRITE(numout,*)'      Greenland ice mass              = ', TRIM(sn_rcv_grnm%cldes  ), ' (', TRIM(sn_rcv_grnm%clcat  ), ')' 
     296         WRITE(numout,*)'      Antarctica ice mass             = ', TRIM(sn_rcv_antm%cldes  ), ' (', TRIM(sn_rcv_antm%clcat  ), ')' 
    260297         WRITE(numout,*)'      sea ice heat fluxes             = ', TRIM(sn_rcv_iceflx%cldes), ' (', TRIM(sn_rcv_iceflx%clcat), ')' 
    261298         WRITE(numout,*)'      atm co2                         = ', TRIM(sn_rcv_co2%cldes   ), ' (', TRIM(sn_rcv_co2%clcat   ), ')' 
     299         WRITE(numout,*)'      atm pco2                        = ', TRIM(sn_rcv_atm_pco2%cldes), ' (', TRIM(sn_rcv_atm_pco2%clcat), ')' 
     300         WRITE(numout,*)'      atm dust                        = ', TRIM(sn_rcv_atm_dust%cldes), ' (', TRIM(sn_rcv_atm_dust%clcat), ')' 
    262301         WRITE(numout,*)'  sent fields (multiple ice categories)' 
    263302         WRITE(numout,*)'      surface temperature             = ', TRIM(sn_snd_temp%cldes  ), ' (', TRIM(sn_snd_temp%clcat  ), ')' 
     
    268307         WRITE(numout,*)'                      - orientation   = ', sn_snd_crt%clvor 
    269308         WRITE(numout,*)'                      - mesh          = ', sn_snd_crt%clvgrd 
     309         WRITE(numout,*)'      bio co2 flux                    = ', TRIM(sn_snd_bio_co2%cldes), ' (', TRIM(sn_snd_bio_co2%clcat), ')' 
     310         WRITE(numout,*)'      bio dms flux                    = ', TRIM(sn_snd_bio_dms%cldes), ' (', TRIM(sn_snd_bio_dms%clcat), ')' 
     311         WRITE(numout,*)'      bio dms chlorophyll             = ', TRIM(sn_snd_bio_chloro%cldes), ' (', TRIM(sn_snd_bio_chloro%clcat), ')' 
    270312         WRITE(numout,*)'      oce co2 flux                    = ', TRIM(sn_snd_co2%cldes   ), ' (', TRIM(sn_snd_co2%clcat   ), ')' 
     313         WRITE(numout,*)'      ice effective conductivity      = ', TRIM(sn_snd_cond%cldes   ), ' (', TRIM(sn_snd_cond%clcat   ), ')' 
     314         WRITE(numout,*)'      meltponds fraction & depth      = ', TRIM(sn_snd_mpnd%cldes  ), ' (', TRIM(sn_snd_mpnd%clcat   ), ')' 
     315         WRITE(numout,*)'      sea surface freezing temp       = ', TRIM(sn_snd_sstfrz%cldes   ), ' (', TRIM(sn_snd_sstfrz%clcat   ), ')' 
     316 
    271317         WRITE(numout,*)'  nn_cplmodel                         = ', nn_cplmodel 
    272318         WRITE(numout,*)'  ln_usecplmask                       = ', ln_usecplmask 
     319         WRITE(numout,*)'  nn_coupled_iceshelf_fluxes          = ', nn_coupled_iceshelf_fluxes 
     320         WRITE(numout,*)'  ln_iceshelf_init_atmos              = ', ln_iceshelf_init_atmos 
     321         WRITE(numout,*)'  rn_greenland_total_fw_flux         = ', rn_greenland_total_fw_flux 
     322         WRITE(numout,*)'  rn_antarctica_total_fw_flux        = ', rn_antarctica_total_fw_flux 
     323         WRITE(numout,*)'  rn_greenland_calving_fraction       = ', rn_greenland_calving_fraction 
     324         WRITE(numout,*)'  rn_antarctica_calving_fraction      = ', rn_antarctica_calving_fraction 
     325         WRITE(numout,*)'  rn_iceshelf_fluxes_tolerance        = ', rn_iceshelf_fluxes_tolerance 
    273326      ENDIF 
    274327 
    275328      !                                   ! allocate sbccpl arrays 
    276       IF( sbc_cpl_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'sbc_cpl_alloc : unable to allocate arrays' ) 
     329      !IF( sbc_cpl_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'sbc_cpl_alloc : unable to allocate arrays' ) 
    277330      
    278331      ! ================================ ! 
     
    337390         srcv(jpr_otx2:jpr_otz2)%clgrid  = 'V'        !           and           V-point 
    338391         srcv(jpr_itx1:jpr_itz1)%clgrid  = 'F'        ! ice components given at F-point 
    339          srcv(jpr_otx1:jpr_otz2)%laction = .TRUE.     ! receive oce components on grid 1 & 2 
     392         !srcv(jpr_otx1:jpr_otz2)%laction = .TRUE.     ! receive oce components on grid 1 & 2 
     393! Currently needed for HadGEM3 - but shouldn't affect anyone else for the moment 
     394         srcv(jpr_otx1)%laction = .TRUE.  
     395         srcv(jpr_oty1)%laction = .TRUE. 
     396! 
    340397         srcv(jpr_itx1:jpr_itz1)%laction = .TRUE.     ! receive ice components on grid 1 only 
    341398      CASE( 'T,I' )  
     
    383440      srcv(jpr_snow)%clname = 'OTotSnow'      ! Snow = solid precipitation 
    384441      srcv(jpr_tevp)%clname = 'OTotEvap'      ! total evaporation (over oce + ice sublimation) 
    385       srcv(jpr_ievp)%clname = 'OIceEvap'      ! evaporation over ice = sublimation 
     442      srcv(jpr_ievp)%clname = 'OIceEvp'      ! evaporation over ice = sublimation 
    386443      srcv(jpr_sbpr)%clname = 'OSubMPre'      ! sublimation - liquid precipitation - solid precipitation  
    387444      srcv(jpr_semp)%clname = 'OISubMSn'      ! ice solid water budget = sublimation - solid precipitation 
     
    396453      CASE default              ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_rcv_emp%cldes' ) 
    397454      END SELECT 
    398  
     455      !Set the number of categories for coupling of sublimation 
     456      IF ( TRIM( sn_rcv_emp%clcat ) == 'yes' ) srcv(jpr_ievp)%nct = jpl 
     457      ! 
    399458      !                                                      ! ------------------------- ! 
    400459      !                                                      !     Runoffs & Calving     !    
     
    410469      ! 
    411470      srcv(jpr_cal   )%clname = 'OCalving'   ;   IF( TRIM( sn_rcv_cal%cldes ) == 'coupled' )   srcv(jpr_cal)%laction = .TRUE. 
     471      srcv(jpr_grnm  )%clname = 'OGrnmass'   ;   IF( TRIM( sn_rcv_grnm%cldes ) == 'coupled' )   srcv(jpr_grnm)%laction = .TRUE. 
     472      srcv(jpr_antm  )%clname = 'OAntmass'   ;   IF( TRIM( sn_rcv_antm%cldes ) == 'coupled' )   srcv(jpr_antm)%laction = .TRUE. 
     473 
    412474 
    413475      !                                                      ! ------------------------- ! 
     
    470532      !                                                      ! ------------------------- ! 
    471533      srcv(jpr_co2 )%clname = 'O_AtmCO2'   ;   IF( TRIM(sn_rcv_co2%cldes   ) == 'coupled' )    srcv(jpr_co2 )%laction = .TRUE. 
     534 
     535 
     536      !                                                      ! --------------------------------------- !     
     537      !                                                      ! Incoming CO2 and DUST fluxes for MEDUSA ! 
     538      !                                                      ! --------------------------------------- !   
     539      srcv(jpr_atm_pco2)%clname = 'OATMPCO2' 
     540 
     541      IF (TRIM(sn_rcv_atm_pco2%cldes) == 'medusa') THEN 
     542        srcv(jpr_atm_pco2)%laction = .TRUE. 
     543      END IF 
     544                
     545      srcv(jpr_atm_dust)%clname = 'OATMDUST'    
     546      IF (TRIM(sn_rcv_atm_dust%cldes) == 'medusa')  THEN 
     547        srcv(jpr_atm_dust)%laction = .TRUE. 
     548      END IF 
     549     
    472550      !                                                      ! ------------------------- ! 
    473551      !                                                      !   topmelt and botmelt     !    
     
    483561         srcv(jpr_topm:jpr_botm)%laction = .TRUE. 
    484562      ENDIF 
     563       
     564#if defined key_cice && ! defined key_cice4 
     565      !                                                      ! ----------------------------- ! 
     566      !                                                      !  sea-ice skin temperature     !    
     567      !                                                      !  used in meltpond scheme      ! 
     568      !                                                      !  May be calculated in Atm     ! 
     569      !                                                      ! ----------------------------- ! 
     570      srcv(jpr_ts_ice)%clname = 'OTsfIce' 
     571      IF ( TRIM( sn_rcv_ts_ice%cldes ) == 'ice' ) srcv(jpr_ts_ice)%laction = .TRUE. 
     572      IF ( TRIM( sn_rcv_ts_ice%clcat ) == 'yes' ) srcv(jpr_ts_ice)%nct = jpl 
     573      !TODO: Should there be a consistency check here? 
     574#endif 
     575 
    485576      !                                                      ! ------------------------------- ! 
    486577      !                                                      !   OPA-SAS coupling - rcv by opa !    
     
    600691      !                                                      ! ------------------------- ! 
    601692      ssnd(jps_toce)%clname = 'O_SSTSST' 
    602       ssnd(jps_tice)%clname = 'O_TepIce' 
     693      ssnd(jps_tice)%clname = 'OTepIce' 
    603694      ssnd(jps_tmix)%clname = 'O_TepMix' 
    604695      SELECT CASE( TRIM( sn_snd_temp%cldes ) ) 
    605696      CASE( 'none'                                 )       ! nothing to do 
    606697      CASE( 'oce only'                             )   ;   ssnd( jps_toce )%laction = .TRUE. 
    607       CASE( 'oce and ice' , 'weighted oce and ice' ) 
     698      CASE( 'oce and ice' , 'weighted oce and ice' , 'oce and weighted ice') 
    608699         ssnd( (/jps_toce, jps_tice/) )%laction = .TRUE. 
    609700         IF ( TRIM( sn_snd_temp%clcat ) == 'yes' )  ssnd(jps_tice)%nct = jpl 
     
    634725 
    635726      !                                                      ! ------------------------- ! 
    636       !                                                      !  Ice fraction & Thickness !  
     727      !                                                      !  Ice fraction & Thickness  
    637728      !                                                      ! ------------------------- ! 
    638729      ssnd(jps_fice)%clname = 'OIceFrc' 
    639730      ssnd(jps_hice)%clname = 'OIceTck' 
    640731      ssnd(jps_hsnw)%clname = 'OSnwTck' 
     732      ssnd(jps_a_p)%clname  = 'OPndFrc' 
     733      ssnd(jps_ht_p)%clname = 'OPndTck' 
     734      ssnd(jps_fice1)%clname = 'OIceFrd' 
    641735      IF( k_ice /= 0 ) THEN 
    642736         ssnd(jps_fice)%laction = .TRUE.                  ! if ice treated in the ocean (even in climato case) 
     737         ssnd(jps_fice1)%laction = .TRUE.                 ! First-order regridded ice concentration, to be used 
     738                                                     ! in producing atmos-to-ice fluxes 
    643739! Currently no namelist entry to determine sending of multi-category ice fraction so use the thickness entry for now 
    644740         IF ( TRIM( sn_snd_thick%clcat ) == 'yes' ) ssnd(jps_fice)%nct = jpl 
     741         IF ( TRIM( sn_snd_thick1%clcat ) == 'yes' ) ssnd(jps_fice1)%nct = jpl 
    645742      ENDIF 
    646743       
     
    657754      CASE default   ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_snd_thick%cldes' ) 
    658755      END SELECT 
     756 
     757      !                                                      ! ------------------------- ! 
     758      !                                                      ! Ice Meltponds             ! 
     759      !                                                      ! ------------------------- ! 
     760#if defined key_cice && ! defined key_cice4 
     761      ! Meltponds only CICE5  
     762      ssnd(jps_a_p)%clname = 'OPndFrc'    
     763      ssnd(jps_ht_p)%clname = 'OPndTck'    
     764      SELECT CASE ( TRIM( sn_snd_mpnd%cldes ) ) 
     765      CASE ( 'none' ) 
     766         ssnd(jps_a_p)%laction = .FALSE. 
     767         ssnd(jps_ht_p)%laction = .FALSE. 
     768      CASE ( 'ice only' )  
     769         ssnd(jps_a_p)%laction = .TRUE. 
     770         ssnd(jps_ht_p)%laction = .TRUE. 
     771         IF ( TRIM( sn_snd_mpnd%clcat ) == 'yes' ) THEN 
     772            ssnd(jps_a_p)%nct = jpl 
     773            ssnd(jps_ht_p)%nct = jpl 
     774         ELSE 
     775            IF ( jpl > 1 ) THEN 
     776               CALL ctl_stop( 'sbc_cpl_init: use weighted ice option for sn_snd_mpnd%cldes if not exchanging category fields' ) 
     777            ENDIF 
     778         ENDIF 
     779      CASE ( 'weighted ice' )  
     780         ssnd(jps_a_p)%laction = .TRUE. 
     781         ssnd(jps_ht_p)%laction = .TRUE. 
     782         IF ( TRIM( sn_snd_mpnd%clcat ) == 'yes' ) THEN 
     783            ssnd(jps_a_p)%nct = jpl  
     784            ssnd(jps_ht_p)%nct = jpl  
     785         ENDIF 
     786      CASE default   ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_snd_mpnd%cldes' ) 
     787      END SELECT 
     788#else 
     789      IF( TRIM( sn_snd_mpnd%cldes ) /= 'none' ) THEN 
     790         CALL ctl_stop('Meltponds can only be used with CICEv5') 
     791      ENDIF 
     792#endif 
    659793 
    660794      !                                                      ! ------------------------- ! 
     
    689823      !                                                      ! ------------------------- ! 
    690824      ssnd(jps_co2)%clname = 'O_CO2FLX' ;  IF( TRIM(sn_snd_co2%cldes) == 'coupled' )    ssnd(jps_co2 )%laction = .TRUE. 
     825      ! 
     826 
     827      !                                                      ! ------------------------- ! 
     828      !                                                      !   MEDUSA output fields    ! 
     829      !                                                      ! ------------------------- ! 
     830      ! Surface dimethyl sulphide from Medusa 
     831      ssnd(jps_bio_dms)%clname = 'OBioDMS'    
     832      IF( TRIM(sn_snd_bio_dms%cldes) == 'medusa' )    ssnd(jps_bio_dms )%laction = .TRUE. 
     833 
     834      ! Surface CO2 flux from Medusa 
     835      ssnd(jps_bio_co2)%clname = 'OBioCO2'    
     836      IF( TRIM(sn_snd_bio_co2%cldes) == 'medusa' )    ssnd(jps_bio_co2 )%laction = .TRUE. 
     837       
     838      ! Surface chlorophyll from Medusa 
     839      ssnd(jps_bio_chloro)%clname = 'OBioChlo'    
     840      IF( TRIM(sn_snd_bio_chloro%cldes) == 'medusa' )    ssnd(jps_bio_chloro )%laction = .TRUE. 
     841 
     842      !                                                      ! ------------------------- ! 
     843      !                                                      ! Sea surface freezing temp ! 
     844      !                                                      ! ------------------------- ! 
     845      ssnd(jps_sstfrz)%clname = 'O_SSTFrz' ; IF( TRIM(sn_snd_sstfrz%cldes) == 'coupled' )  ssnd(jps_sstfrz)%laction = .TRUE. 
     846      ! 
     847      !                                                      ! ------------------------- ! 
     848      !                                                      !    Ice conductivity       ! 
     849      !                                                      ! ------------------------- ! 
     850      ! Note that ultimately we will move to passing an ocean effective conductivity as well so there 
     851      ! will be some changes to the parts of the code which currently relate only to ice conductivity 
     852      ssnd(jps_kice )%clname = 'OIceKn' 
     853      SELECT CASE ( TRIM( sn_snd_cond%cldes ) ) 
     854      CASE ( 'none' ) 
     855         ssnd(jps_kice)%laction = .FALSE. 
     856      CASE ( 'ice only' ) 
     857         ssnd(jps_kice)%laction = .TRUE. 
     858         IF ( TRIM( sn_snd_cond%clcat ) == 'yes' ) THEN 
     859            ssnd(jps_kice)%nct = jpl 
     860         ELSE 
     861            IF ( jpl > 1 ) THEN 
     862               CALL ctl_stop( 'sbc_cpl_init: use weighted ice option for sn_snd_cond%cldes if not exchanging category fields' ) 
     863            ENDIF 
     864         ENDIF 
     865      CASE ( 'weighted ice' ) 
     866         ssnd(jps_kice)%laction = .TRUE. 
     867         IF ( TRIM( sn_snd_cond%clcat ) == 'yes' ) ssnd(jps_kice)%nct = jpl 
     868      CASE default   ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_snd_cond%cldes' ) 
     869      END SELECT 
     870      ! 
     871       
    691872 
    692873      !                                                      ! ------------------------------- ! 
     
    785966      ncpl_qsr_freq = 86400 / ncpl_qsr_freq 
    786967 
     968      IF( nn_coupled_iceshelf_fluxes .gt. 0 ) THEN 
     969          ! Crude masks to separate the Antarctic and Greenland icesheets. Obviously something 
     970          ! more complicated could be done if required. 
     971          greenland_icesheet_mask = 0.0 
     972          WHERE( gphit >= 0.0 ) greenland_icesheet_mask = 1.0 
     973          antarctica_icesheet_mask = 0.0 
     974          WHERE( gphit < 0.0 ) antarctica_icesheet_mask = 1.0 
     975 
     976          ! initialise other variables 
     977          greenland_icesheet_mass_array(:,:) = 0.0 
     978          antarctica_icesheet_mass_array(:,:) = 0.0 
     979 
     980          IF( .not. ln_rstart ) THEN 
     981             greenland_icesheet_mass = 0.0  
     982             greenland_icesheet_mass_rate_of_change = 0.0  
     983             greenland_icesheet_timelapsed = 0.0 
     984             antarctica_icesheet_mass = 0.0  
     985             antarctica_icesheet_mass_rate_of_change = 0.0  
     986             antarctica_icesheet_timelapsed = 0.0 
     987          ENDIF 
     988 
     989      ENDIF 
     990 
    787991      CALL wrk_dealloc( jpi,jpj, zacs, zaos ) 
    788992      ! 
     
    8431047      !! 
    8441048      LOGICAL  ::   llnewtx, llnewtau      ! update wind stress components and module?? 
    845       INTEGER  ::   ji, jj, jn             ! dummy loop indices 
     1049      INTEGER  ::   ji, jj, jl, jn         ! dummy loop indices 
    8461050      INTEGER  ::   isec                   ! number of seconds since nit000 (assuming rdttra did not change since nit000) 
     1051      INTEGER  ::   ikchoix 
    8471052      REAL(wp) ::   zcumulneg, zcumulpos   ! temporary scalars      
     1053      REAL(wp) ::   zgreenland_icesheet_mass_in, zantarctica_icesheet_mass_in 
     1054      REAL(wp) ::   zgreenland_icesheet_mass_b, zantarctica_icesheet_mass_b 
     1055      REAL(wp) ::   zmask_sum, zepsilon       
    8481056      REAL(wp) ::   zcoef                  ! temporary scalar 
    8491057      REAL(wp) ::   zrhoa  = 1.22          ! Air density kg/m3 
    8501058      REAL(wp) ::   zcdrag = 1.5e-3        ! drag coefficient 
    8511059      REAL(wp) ::   zzx, zzy               ! temporary variables 
    852       REAL(wp), POINTER, DIMENSION(:,:) ::   ztx, zty, zmsk, zemp, zqns, zqsr 
     1060      REAL(wp), POINTER, DIMENSION(:,:) ::   ztx, zty, zmsk, zemp, zqns, zqsr, ztx2, zty2 
    8531061      !!---------------------------------------------------------------------- 
     1062 
    8541063      ! 
    8551064      IF( nn_timing == 1 )  CALL timing_start('sbc_cpl_rcv') 
    8561065      ! 
    857       CALL wrk_alloc( jpi,jpj, ztx, zty, zmsk, zemp, zqns, zqsr ) 
     1066      CALL wrk_alloc( jpi,jpj, ztx, zty, zmsk, zemp, zqns, zqsr, ztx2, zty2 ) 
    8581067      ! 
    8591068      IF( ln_mixcpl )   zmsk(:,:) = 1. - xcplmask(:,:,0) 
     
    8931102            IF( TRIM( sn_rcv_tau%clvor ) == 'eastward-northward' ) THEN   ! 2 components oriented along the local grid 
    8941103               !                                                       ! (geographical to local grid -> rotate the components) 
    895                CALL rot_rep( frcv(jpr_otx1)%z3(:,:,1), frcv(jpr_oty1)%z3(:,:,1), srcv(jpr_otx1)%clgrid, 'en->i', ztx )    
    896                IF( srcv(jpr_otx2)%laction ) THEN 
    897                   CALL rot_rep( frcv(jpr_otx2)%z3(:,:,1), frcv(jpr_oty2)%z3(:,:,1), srcv(jpr_otx2)%clgrid, 'en->j', zty )    
    898                ELSE   
    899                   CALL rot_rep( frcv(jpr_otx1)%z3(:,:,1), frcv(jpr_oty1)%z3(:,:,1), srcv(jpr_otx1)%clgrid, 'en->j', zty )   
     1104               IF( srcv(jpr_otx1)%clgrid == 'U' .AND. (.NOT. srcv(jpr_otx2)%laction) ) THEN 
     1105                  ! Temporary code for HadGEM3 - will be removed eventually. 
     1106        ! Only applies when we have only taux on U grid and tauy on V grid 
     1107             DO jj=2,jpjm1 
     1108                DO ji=2,jpim1 
     1109                     ztx(ji,jj)=0.25*vmask(ji,jj,1)                & 
     1110                        *(frcv(jpr_otx1)%z3(ji,jj,1)+frcv(jpr_otx1)%z3(ji-1,jj,1)    & 
     1111                        +frcv(jpr_otx1)%z3(ji,jj+1,1)+frcv(jpr_otx1)%z3(ji-1,jj+1,1)) 
     1112                     zty(ji,jj)=0.25*umask(ji,jj,1)                & 
     1113                        *(frcv(jpr_oty1)%z3(ji,jj,1)+frcv(jpr_oty1)%z3(ji+1,jj,1)    & 
     1114                        +frcv(jpr_oty1)%z3(ji,jj-1,1)+frcv(jpr_oty1)%z3(ji+1,jj-1,1)) 
     1115                ENDDO 
     1116             ENDDO 
     1117                    
     1118             ikchoix = 1 
     1119             CALL repcmo (frcv(jpr_otx1)%z3(:,:,1),zty,ztx,frcv(jpr_oty1)%z3(:,:,1),ztx2,zty2,ikchoix) 
     1120             CALL lbc_lnk (ztx2,'U', -1. ) 
     1121             CALL lbc_lnk (zty2,'V', -1. ) 
     1122             frcv(jpr_otx1)%z3(:,:,1)=ztx2(:,:) 
     1123             frcv(jpr_oty1)%z3(:,:,1)=zty2(:,:) 
     1124          ELSE 
     1125             CALL rot_rep( frcv(jpr_otx1)%z3(:,:,1), frcv(jpr_oty1)%z3(:,:,1), srcv(jpr_otx1)%clgrid, 'en->i', ztx )    
     1126             frcv(jpr_otx1)%z3(:,:,1) = ztx(:,:)      ! overwrite 1st component on the 1st grid 
     1127             IF( srcv(jpr_otx2)%laction ) THEN 
     1128                CALL rot_rep( frcv(jpr_otx2)%z3(:,:,1), frcv(jpr_oty2)%z3(:,:,1), srcv(jpr_otx2)%clgrid, 'en->j', zty )    
     1129             ELSE 
     1130                CALL rot_rep( frcv(jpr_otx1)%z3(:,:,1), frcv(jpr_oty1)%z3(:,:,1), srcv(jpr_otx1)%clgrid, 'en->j', zty )  
     1131             ENDIF 
     1132          frcv(jpr_oty1)%z3(:,:,1) = zty(:,:)      ! overwrite 2nd component on the 2nd grid   
    9001133               ENDIF 
    901                frcv(jpr_otx1)%z3(:,:,1) = ztx(:,:)      ! overwrite 1st component on the 1st grid 
    902                frcv(jpr_oty1)%z3(:,:,1) = zty(:,:)      ! overwrite 2nd component on the 2nd grid 
    9031134            ENDIF 
    9041135            !                               
     
    9901221      ENDIF 
    9911222 
     1223      IF (ln_medusa) THEN 
     1224        IF( srcv(jpr_atm_pco2)%laction) PCO2a_in_cpl(:,:) = frcv(jpr_atm_pco2)%z3(:,:,1) 
     1225        IF( srcv(jpr_atm_dust)%laction) Dust_in_cpl(:,:) = frcv(jpr_atm_dust)%z3(:,:,1) 
     1226      ENDIF 
     1227 
    9921228#if defined key_cpl_carbon_cycle 
    9931229      !                                                      ! ================== ! 
     
    9951231      !                                                      ! ================== ! 
    9961232      IF( srcv(jpr_co2)%laction )   atm_co2(:,:) = frcv(jpr_co2)%z3(:,:,1) 
     1233#endif 
     1234 
     1235#if defined key_cice && ! defined key_cice4 
     1236      !  ! Sea ice surface skin temp: 
     1237      IF( srcv(jpr_ts_ice)%laction ) THEN 
     1238        DO jl = 1, jpl 
     1239          DO jj = 1, jpj 
     1240            DO ji = 1, jpi 
     1241              IF (frcv(jpr_ts_ice)%z3(ji,jj,jl) > 0.0) THEN 
     1242                tsfc_ice(ji,jj,jl) = 0.0 
     1243              ELSE IF (frcv(jpr_ts_ice)%z3(ji,jj,jl) < -60.0) THEN 
     1244                tsfc_ice(ji,jj,jl) = -60.0 
     1245              ELSE 
     1246                tsfc_ice(ji,jj,jl) = frcv(jpr_ts_ice)%z3(ji,jj,jl) 
     1247              ENDIF 
     1248            END DO 
     1249          END DO 
     1250        END DO 
     1251      ENDIF 
    9971252#endif 
    9981253 
     
    10291284         ssu_m(:,:) = frcv(jpr_ocx1)%z3(:,:,1) 
    10301285         ub (:,:,1) = ssu_m(:,:)                             ! will be used in sbcice_lim in the call of lim_sbc_tau 
     1286         un (:,:,1) = ssu_m(:,:)                             ! will be used in sbc_cpl_snd if atmosphere coupling 
    10311287         CALL iom_put( 'ssu_m', ssu_m ) 
    10321288      ENDIF 
     
    10341290         ssv_m(:,:) = frcv(jpr_ocy1)%z3(:,:,1) 
    10351291         vb (:,:,1) = ssv_m(:,:)                             ! will be used in sbcice_lim in the call of lim_sbc_tau 
     1292         vn (:,:,1) = ssv_m(:,:)                             ! will be used in sbc_cpl_snd if atmosphere coupling 
    10361293         CALL iom_put( 'ssv_m', ssv_m ) 
    10371294      ENDIF 
     
    11101367 
    11111368      ENDIF 
    1112       ! 
    1113       CALL wrk_dealloc( jpi,jpj, ztx, zty, zmsk, zemp, zqns, zqsr ) 
     1369       
     1370      !                                                        ! land ice masses : Greenland 
     1371      zepsilon = rn_iceshelf_fluxes_tolerance 
     1372 
     1373 
     1374      ! See if we need zmask_sum... 
     1375      IF ( srcv(jpr_grnm)%laction .OR. srcv(jpr_antm)%laction ) THEN 
     1376         zmask_sum = glob_sum( tmask(:,:,1) ) 
     1377      ENDIF 
     1378 
     1379      IF( srcv(jpr_grnm)%laction .AND. nn_coupled_iceshelf_fluxes == 1 ) THEN 
     1380         greenland_icesheet_mass_array(:,:) = frcv(jpr_grnm)%z3(:,:,1) 
     1381         ! take average over ocean points of input array to avoid cumulative error over time 
     1382         ! The following must be bit reproducible over different PE decompositions 
     1383         zgreenland_icesheet_mass_in = glob_sum( greenland_icesheet_mass_array(:,:) * tmask(:,:,1) ) 
     1384 
     1385         zgreenland_icesheet_mass_in = zgreenland_icesheet_mass_in / zmask_sum 
     1386         greenland_icesheet_timelapsed = greenland_icesheet_timelapsed + rdt          
     1387 
     1388         IF( ln_iceshelf_init_atmos .AND. kt == 1 ) THEN 
     1389            ! On the first timestep (of an NRUN) force the ocean to ignore the icesheet masses in the ocean restart 
     1390            ! and take them from the atmosphere to avoid problems with using inconsistent ocean and atmosphere restarts. 
     1391            zgreenland_icesheet_mass_b = zgreenland_icesheet_mass_in 
     1392            greenland_icesheet_mass = zgreenland_icesheet_mass_in 
     1393         ENDIF 
     1394 
     1395         IF( ABS( zgreenland_icesheet_mass_in - greenland_icesheet_mass ) > zepsilon ) THEN 
     1396            zgreenland_icesheet_mass_b = greenland_icesheet_mass 
     1397             
     1398            ! Only update the mass if it has increased. 
     1399            IF ( (zgreenland_icesheet_mass_in - greenland_icesheet_mass) > 0.0 ) THEN 
     1400               greenland_icesheet_mass = zgreenland_icesheet_mass_in 
     1401            ENDIF 
     1402             
     1403            IF( zgreenland_icesheet_mass_b /= 0.0 ) & 
     1404           &     greenland_icesheet_mass_rate_of_change = ( greenland_icesheet_mass - zgreenland_icesheet_mass_b ) / greenland_icesheet_timelapsed  
     1405            greenland_icesheet_timelapsed = 0.0_wp        
     1406         ENDIF 
     1407         IF(lwp) WRITE(numout,*) 'Greenland icesheet mass (kg) read in is ', zgreenland_icesheet_mass_in 
     1408         IF(lwp) WRITE(numout,*) 'Greenland icesheet mass (kg) used is    ', greenland_icesheet_mass 
     1409         IF(lwp) WRITE(numout,*) 'Greenland icesheet mass rate of change (kg/s) is ', greenland_icesheet_mass_rate_of_change 
     1410         IF(lwp) WRITE(numout,*) 'Greenland icesheet seconds lapsed since last change is ', greenland_icesheet_timelapsed 
     1411      ELSE IF ( nn_coupled_iceshelf_fluxes == 2 ) THEN 
     1412         greenland_icesheet_mass_rate_of_change = rn_greenland_total_fw_flux 
     1413      ENDIF 
     1414 
     1415      !                                                        ! land ice masses : Antarctica 
     1416      IF( srcv(jpr_antm)%laction .AND. nn_coupled_iceshelf_fluxes == 1 ) THEN 
     1417         antarctica_icesheet_mass_array(:,:) = frcv(jpr_antm)%z3(:,:,1) 
     1418         ! take average over ocean points of input array to avoid cumulative error from rounding errors over time 
     1419         ! The following must be bit reproducible over different PE decompositions 
     1420         zantarctica_icesheet_mass_in = glob_sum( antarctica_icesheet_mass_array(:,:) * tmask(:,:,1) ) 
     1421 
     1422         zantarctica_icesheet_mass_in = zantarctica_icesheet_mass_in / zmask_sum 
     1423         antarctica_icesheet_timelapsed = antarctica_icesheet_timelapsed + rdt          
     1424 
     1425         IF( ln_iceshelf_init_atmos .AND. kt == 1 ) THEN 
     1426            ! On the first timestep (of an NRUN) force the ocean to ignore the icesheet masses in the ocean restart 
     1427            ! and take them from the atmosphere to avoid problems with using inconsistent ocean and atmosphere restarts. 
     1428            zantarctica_icesheet_mass_b = zantarctica_icesheet_mass_in 
     1429            antarctica_icesheet_mass = zantarctica_icesheet_mass_in 
     1430         ENDIF 
     1431 
     1432         IF( ABS( zantarctica_icesheet_mass_in - antarctica_icesheet_mass ) > zepsilon ) THEN 
     1433            zantarctica_icesheet_mass_b = antarctica_icesheet_mass 
     1434             
     1435            ! Only update the mass if it has increased. 
     1436            IF ( (zantarctica_icesheet_mass_in - antarctica_icesheet_mass) > 0.0 ) THEN 
     1437               antarctica_icesheet_mass = zantarctica_icesheet_mass_in 
     1438            END IF 
     1439             
     1440            IF( zantarctica_icesheet_mass_b /= 0.0 ) & 
     1441          &      antarctica_icesheet_mass_rate_of_change = ( antarctica_icesheet_mass - zantarctica_icesheet_mass_b ) / antarctica_icesheet_timelapsed  
     1442            antarctica_icesheet_timelapsed = 0.0_wp        
     1443         ENDIF 
     1444         IF(lwp) WRITE(numout,*) 'Antarctica icesheet mass (kg) read in is ', zantarctica_icesheet_mass_in 
     1445         IF(lwp) WRITE(numout,*) 'Antarctica icesheet mass (kg) used is    ', antarctica_icesheet_mass 
     1446         IF(lwp) WRITE(numout,*) 'Antarctica icesheet mass rate of change (kg/s) is ', antarctica_icesheet_mass_rate_of_change 
     1447         IF(lwp) WRITE(numout,*) 'Antarctica icesheet seconds lapsed since last change is ', antarctica_icesheet_timelapsed 
     1448      ELSE IF ( nn_coupled_iceshelf_fluxes == 2 ) THEN 
     1449         antarctica_icesheet_mass_rate_of_change = rn_antarctica_total_fw_flux 
     1450      ENDIF 
     1451 
     1452      ! 
     1453      CALL wrk_dealloc( jpi,jpj, ztx, zty, zmsk, zemp, zqns, zqsr, ztx2, zty2 ) 
    11141454      ! 
    11151455      IF( nn_timing == 1 )  CALL timing_stop('sbc_cpl_rcv') 
     
    13331673      !!             ***  ROUTINE sbc_cpl_ice_flx  *** 
    13341674      !! 
    1335       !! ** Purpose :   provide the heat and freshwater fluxes of the  
    1336       !!              ocean-ice system. 
     1675      !! ** Purpose :   provide the heat and freshwater fluxes of the ocean-ice system 
    13371676      !! 
    13381677      !! ** Method  :   transform the fields received from the atmosphere into 
    13391678      !!             surface heat and fresh water boundary condition for the  
    13401679      !!             ice-ocean system. The following fields are provided: 
    1341       !!              * total non solar, solar and freshwater fluxes (qns_tot,  
     1680      !!               * total non solar, solar and freshwater fluxes (qns_tot,  
    13421681      !!             qsr_tot and emp_tot) (total means weighted ice-ocean flux) 
    13431682      !!             NB: emp_tot include runoffs and calving. 
    1344       !!              * fluxes over ice (qns_ice, qsr_ice, emp_ice) where 
     1683      !!               * fluxes over ice (qns_ice, qsr_ice, emp_ice) where 
    13451684      !!             emp_ice = sublimation - solid precipitation as liquid 
    13461685      !!             precipitation are re-routed directly to the ocean and  
    1347       !!             runoffs and calving directly enter the ocean. 
    1348       !!              * solid precipitation (sprecip), used to add to qns_tot  
     1686      !!             calving directly enter the ocean (runoffs are read but included in trasbc.F90) 
     1687      !!               * solid precipitation (sprecip), used to add to qns_tot  
    13491688      !!             the heat lost associated to melting solid precipitation 
    13501689      !!             over the ocean fraction. 
    1351       !!       ===>> CAUTION here this changes the net heat flux received from 
    1352       !!             the atmosphere 
    1353       !! 
    1354       !!                  - the fluxes have been separated from the stress as 
    1355       !!                 (a) they are updated at each ice time step compare to 
    1356       !!                 an update at each coupled time step for the stress, and 
    1357       !!                 (b) the conservative computation of the fluxes over the 
    1358       !!                 sea-ice area requires the knowledge of the ice fraction 
    1359       !!                 after the ice advection and before the ice thermodynamics, 
    1360       !!                 so that the stress is updated before the ice dynamics 
    1361       !!                 while the fluxes are updated after it. 
     1690      !!               * heat content of rain, snow and evap can also be provided, 
     1691      !!             otherwise heat flux associated with these mass flux are 
     1692      !!             guessed (qemp_oce, qemp_ice) 
     1693      !! 
     1694      !!             - the fluxes have been separated from the stress as 
     1695      !!               (a) they are updated at each ice time step compare to 
     1696      !!               an update at each coupled time step for the stress, and 
     1697      !!               (b) the conservative computation of the fluxes over the 
     1698      !!               sea-ice area requires the knowledge of the ice fraction 
     1699      !!               after the ice advection and before the ice thermodynamics, 
     1700      !!               so that the stress is updated before the ice dynamics 
     1701      !!               while the fluxes are updated after it. 
     1702      !! 
     1703      !! ** Details 
     1704      !!             qns_tot = pfrld * qns_oce + ( 1 - pfrld ) * qns_ice   => provided 
     1705      !!                     + qemp_oce + qemp_ice                         => recalculated and added up to qns 
     1706      !! 
     1707      !!             qsr_tot = pfrld * qsr_oce + ( 1 - pfrld ) * qsr_ice   => provided 
     1708      !! 
     1709      !!             emp_tot = emp_oce + emp_ice                           => calving is provided and added to emp_tot (and emp_oce) 
     1710      !!                                                                      river runoff (rnf) is provided but not included here 
    13621711      !! 
    13631712      !! ** Action  :   update at each nf_ice time step: 
    13641713      !!                   qns_tot, qsr_tot  non-solar and solar total heat fluxes 
    13651714      !!                   qns_ice, qsr_ice  non-solar and solar heat fluxes over the ice 
    1366       !!                   emp_tot            total evaporation - precipitation(liquid and solid) (-runoff)(-calving) 
    1367       !!                   emp_ice            ice sublimation - solid precipitation over the ice 
    1368       !!                   dqns_ice           d(non-solar heat flux)/d(Temperature) over the ice 
    1369       !!                   sprecip             solid precipitation over the ocean   
     1715      !!                   emp_tot           total evaporation - precipitation(liquid and solid) (-calving) 
     1716      !!                   emp_ice           ice sublimation - solid precipitation over the ice 
     1717      !!                   dqns_ice          d(non-solar heat flux)/d(Temperature) over the ice 
     1718      !!                   sprecip           solid precipitation over the ocean   
    13701719      !!---------------------------------------------------------------------- 
    13711720      REAL(wp), INTENT(in   ), DIMENSION(:,:)   ::   p_frld     ! lead fraction                [0 to 1] 
     
    13761725      ! 
    13771726      INTEGER ::   jl         ! dummy loop index 
    1378       REAL(wp), POINTER, DIMENSION(:,:  ) ::   zcptn, ztmp, zicefr, zmsk 
    1379       REAL(wp), POINTER, DIMENSION(:,:  ) ::   zemp_tot, zemp_ice, zsprecip, ztprecip, zqns_tot, zqsr_tot 
    1380       REAL(wp), POINTER, DIMENSION(:,:,:) ::   zqns_ice, zqsr_ice, zdqns_ice 
    1381       REAL(wp), POINTER, DIMENSION(:,:  ) ::   zevap, zsnw, zqns_oce, zqsr_oce, zqprec_ice, zqemp_oce ! for LIM3 
     1727      REAL(wp), POINTER, DIMENSION(:,:  ) ::   zcptn, ztmp, zicefr, zmsk, zsnw 
     1728      REAL(wp), POINTER, DIMENSION(:,:  ) ::   zemp_tot, zemp_ice, zemp_oce, ztprecip, zsprecip, zevap_oce, zevap_ice, zdevap_ice 
     1729      REAL(wp), POINTER, DIMENSION(:,:  ) ::   zqns_tot, zqns_oce, zqsr_tot, zqsr_oce, zqprec_ice, zqemp_oce, zqemp_ice 
     1730      REAL(wp), POINTER, DIMENSION(:,:,:) ::   zqns_ice, zqsr_ice, zdqns_ice, zqevap_ice 
    13821731      !!---------------------------------------------------------------------- 
    13831732      ! 
    13841733      IF( nn_timing == 1 )  CALL timing_start('sbc_cpl_ice_flx') 
    13851734      ! 
    1386       CALL wrk_alloc( jpi,jpj,     zcptn, ztmp, zicefr, zmsk, zemp_tot, zemp_ice, zsprecip, ztprecip, zqns_tot, zqsr_tot ) 
    1387       CALL wrk_alloc( jpi,jpj,jpl, zqns_ice, zqsr_ice, zdqns_ice ) 
     1735      CALL wrk_alloc( jpi,jpj,     zcptn, ztmp, zicefr, zmsk, zsnw ) 
     1736      CALL wrk_alloc( jpi,jpj,     zemp_tot, zemp_ice, zemp_oce, ztprecip, zsprecip, zevap_oce, zevap_ice, zdevap_ice ) 
     1737      CALL wrk_alloc( jpi,jpj,     zqns_tot, zqns_oce, zqsr_tot, zqsr_oce, zqprec_ice, zqemp_oce, zqemp_ice ) 
     1738      CALL wrk_alloc( jpi,jpj,jpl, zqns_ice, zqsr_ice, zdqns_ice, zqevap_ice ) 
    13881739 
    13891740      IF( ln_mixcpl )   zmsk(:,:) = 1. - xcplmask(:,:,0) 
     
    13921743      ! 
    13931744      !                                                      ! ========================= ! 
    1394       !                                                      !    freshwater budget      !   (emp) 
     1745      !                                                      !    freshwater budget      !   (emp_tot) 
    13951746      !                                                      ! ========================= ! 
    13961747      ! 
    1397       !                                                           ! total Precipitation - total Evaporation (emp_tot) 
    1398       !                                                           ! solid precipitation - sublimation       (emp_ice) 
    1399       !                                                           ! solid Precipitation                     (sprecip) 
    1400       !                                                           ! liquid + solid Precipitation            (tprecip) 
     1748      !                                                           ! solid Precipitation                                (sprecip) 
     1749      !                                                           ! liquid + solid Precipitation                       (tprecip) 
     1750      !                                                           ! total Evaporation - total Precipitation            (emp_tot) 
     1751      !                                                           ! sublimation - solid precipitation (cell average)   (emp_ice) 
    14011752      SELECT CASE( TRIM( sn_rcv_emp%cldes ) ) 
    14021753      CASE( 'conservative'  )   ! received fields: jpr_rain, jpr_snow, jpr_ievp, jpr_tevp 
    14031754         zsprecip(:,:) = frcv(jpr_snow)%z3(:,:,1)                  ! May need to ensure positive here 
    14041755         ztprecip(:,:) = frcv(jpr_rain)%z3(:,:,1) + zsprecip(:,:)  ! May need to ensure positive here 
    1405          zemp_tot(:,:) = frcv(jpr_tevp)%z3(:,:,1) - ztprecip(:,:) 
    1406          zemp_ice(:,:) = frcv(jpr_ievp)%z3(:,:,1) - frcv(jpr_snow)%z3(:,:,1) 
    1407             CALL iom_put( 'rain'         , frcv(jpr_rain)%z3(:,:,1)              )   ! liquid precipitation  
     1756         zemp_tot(:,:) = frcv(jpr_tevp)%z3(:,:,1) - ztprecip(:,:)          
     1757#if defined key_cice 
     1758         IF ( TRIM(sn_rcv_emp%clcat) == 'yes' ) THEN 
     1759            ! zemp_ice is the sum of frcv(jpr_ievp)%z3(:,:,1) over all layers - snow 
     1760            zemp_ice(:,:) = - frcv(jpr_snow)%z3(:,:,1) 
     1761            DO jl=1,jpl 
     1762               zemp_ice(:,:   ) = zemp_ice(:,:) + frcv(jpr_ievp)%z3(:,:,jl) 
     1763            ENDDO 
     1764            ! latent heat coupled for each category in CICE 
     1765            qla_ice(:,:,1:jpl) = - frcv(jpr_ievp)%z3(:,:,1:jpl) * lsub 
     1766         ELSE 
     1767            ! If CICE has multicategories it still expects coupling fields for 
     1768            ! each even if we treat as a single field 
     1769            ! The latent heat flux is split between the ice categories according 
     1770            ! to the fraction of the ice in each category 
     1771            zemp_ice(:,:) = frcv(jpr_ievp)%z3(:,:,1) - frcv(jpr_snow)%z3(:,:,1) 
     1772            WHERE ( zicefr(:,:) /= 0._wp )  
     1773               ztmp(:,:) = 1./zicefr(:,:) 
     1774            ELSEWHERE  
     1775               ztmp(:,:) = 0.e0 
     1776            END WHERE   
     1777            DO jl=1,jpl 
     1778               qla_ice(:,:,jl) = - a_i(:,:,jl) * ztmp(:,:) * frcv(jpr_ievp)%z3(:,:,1) * lsub  
     1779            END DO 
     1780            WHERE ( zicefr(:,:) == 0._wp )  qla_ice(:,:,1) = -frcv(jpr_ievp)%z3(:,:,1) * lsub  
     1781         ENDIF 
     1782#else          
     1783         zemp_ice(:,:) = ( frcv(jpr_ievp)%z3(:,:,1) - frcv(jpr_snow)%z3(:,:,1) ) * zicefr(:,:) 
     1784#endif                   
     1785         CALL iom_put( 'rain'         , frcv(jpr_rain)%z3(:,:,1) * tmask(:,:,1)      )   ! liquid precipitation  
     1786         CALL iom_put( 'rain_ao_cea'  , frcv(jpr_rain)%z3(:,:,1)* p_frld(:,:) * tmask(:,:,1)      )   ! liquid precipitation  
    14081787         IF( iom_use('hflx_rain_cea') )   & 
    1409             CALL iom_put( 'hflx_rain_cea', frcv(jpr_rain)%z3(:,:,1) * zcptn(:,:) )   ! heat flux from liq. precip.  
     1788            &  CALL iom_put( 'hflx_rain_cea', frcv(jpr_rain)%z3(:,:,1) * zcptn(:,:) * tmask(:,:,1))   ! heat flux from liq. precip.  
     1789         IF( iom_use('hflx_prec_cea') )   & 
     1790            & CALL iom_put( 'hflx_prec_cea', ztprecip * zcptn(:,:) * tmask(:,:,1) * p_frld(:,:) )   ! heat content flux from all precip  (cell avg) 
    14101791         IF( iom_use('evap_ao_cea') .OR. iom_use('hflx_evap_cea') )   & 
    1411             ztmp(:,:) = frcv(jpr_tevp)%z3(:,:,1) - frcv(jpr_ievp)%z3(:,:,1) * zicefr(:,:) 
     1792            & ztmp(:,:) = frcv(jpr_tevp)%z3(:,:,1) - frcv(jpr_ievp)%z3(:,:,1) * zicefr(:,:) 
    14121793         IF( iom_use('evap_ao_cea'  ) )   & 
    1413             CALL iom_put( 'evap_ao_cea'  , ztmp                   )   ! ice-free oce evap (cell average) 
     1794            &  CALL iom_put( 'evap_ao_cea'  , ztmp * tmask(:,:,1)                  )   ! ice-free oce evap (cell average) 
    14141795         IF( iom_use('hflx_evap_cea') )   & 
    1415             CALL iom_put( 'hflx_evap_cea', ztmp(:,:) * zcptn(:,:) )   ! heat flux from from evap (cell average) 
    1416       CASE( 'oce and ice'   )   ! received fields: jpr_sbpr, jpr_semp, jpr_oemp, jpr_ievp 
     1796            &  CALL iom_put( 'hflx_evap_cea', ztmp(:,:) * zcptn(:,:) * tmask(:,:,1) )   ! heat flux from from evap (cell average) 
     1797      CASE( 'oce and ice' )   ! received fields: jpr_sbpr, jpr_semp, jpr_oemp, jpr_ievp 
    14171798         zemp_tot(:,:) = p_frld(:,:) * frcv(jpr_oemp)%z3(:,:,1) + zicefr(:,:) * frcv(jpr_sbpr)%z3(:,:,1) 
    1418          zemp_ice(:,:) = frcv(jpr_semp)%z3(:,:,1) 
     1799         zemp_ice(:,:) = frcv(jpr_semp)%z3(:,:,1) * zicefr(:,:) 
    14191800         zsprecip(:,:) = frcv(jpr_ievp)%z3(:,:,1) - frcv(jpr_semp)%z3(:,:,1) 
    14201801         ztprecip(:,:) = frcv(jpr_semp)%z3(:,:,1) - frcv(jpr_sbpr)%z3(:,:,1) + zsprecip(:,:) 
    14211802      END SELECT 
    14221803 
    1423       IF( iom_use('subl_ai_cea') )   & 
    1424          CALL iom_put( 'subl_ai_cea', frcv(jpr_ievp)%z3(:,:,1) * zicefr(:,:) )   ! Sublimation over sea-ice         (cell average) 
    1425       !    
    1426       !                                                           ! runoffs and calving (put in emp_tot) 
     1804#if defined key_lim3 
     1805      ! zsnw = snow fraction over ice after wind blowing 
     1806      zsnw(:,:) = 0._wp  ;  CALL lim_thd_snwblow( p_frld, zsnw ) 
     1807       
     1808      ! --- evaporation minus precipitation corrected (because of wind blowing on snow) --- ! 
     1809      zemp_ice(:,:) = zemp_ice(:,:) + zsprecip(:,:) * ( zicefr(:,:) - zsnw(:,:) )  ! emp_ice = A * sublimation - zsnw * sprecip 
     1810      zemp_oce(:,:) = zemp_tot(:,:) - zemp_ice(:,:)                                ! emp_oce = emp_tot - emp_ice 
     1811 
     1812      ! --- evaporation over ocean (used later for qemp) --- ! 
     1813      zevap_oce(:,:) = frcv(jpr_tevp)%z3(:,:,1) - frcv(jpr_ievp)%z3(:,:,1) * zicefr(:,:) 
     1814 
     1815      ! --- evaporation over ice (kg/m2/s) --- ! 
     1816      zevap_ice(:,:) = frcv(jpr_ievp)%z3(:,:,1) 
     1817      ! since the sensitivity of evap to temperature (devap/dT) is not prescribed by the atmosphere, we set it to 0 
     1818      ! therefore, sublimation is not redistributed over the ice categories in case no subgrid scale fluxes are provided by atm. 
     1819      zdevap_ice(:,:) = 0._wp 
     1820       
     1821      ! --- runoffs (included in emp later on) --- ! 
    14271822      IF( srcv(jpr_rnf)%laction )   rnf(:,:) = frcv(jpr_rnf)%z3(:,:,1) 
     1823 
     1824      ! --- calving (put in emp_tot and emp_oce) --- ! 
     1825      IF( srcv(jpr_cal)%laction ) THEN  
     1826         zemp_tot(:,:) = zemp_tot(:,:) - frcv(jpr_cal)%z3(:,:,1) 
     1827         zemp_oce(:,:) = zemp_oce(:,:) - frcv(jpr_cal)%z3(:,:,1) 
     1828         CALL iom_put( 'calving_cea', frcv(jpr_cal)%z3(:,:,1) ) 
     1829      ENDIF 
     1830 
     1831      IF( ln_mixcpl ) THEN 
     1832         emp_tot(:,:) = emp_tot(:,:) * xcplmask(:,:,0) + zemp_tot(:,:) * zmsk(:,:) 
     1833         emp_ice(:,:) = emp_ice(:,:) * xcplmask(:,:,0) + zemp_ice(:,:) * zmsk(:,:) 
     1834         emp_oce(:,:) = emp_oce(:,:) * xcplmask(:,:,0) + zemp_oce(:,:) * zmsk(:,:) 
     1835         sprecip(:,:) = sprecip(:,:) * xcplmask(:,:,0) + zsprecip(:,:) * zmsk(:,:) 
     1836         tprecip(:,:) = tprecip(:,:) * xcplmask(:,:,0) + ztprecip(:,:) * zmsk(:,:) 
     1837         DO jl=1,jpl 
     1838            evap_ice (:,:,jl) = evap_ice (:,:,jl) * xcplmask(:,:,0) + zevap_ice (:,:) * zmsk(:,:) 
     1839            devap_ice(:,:,jl) = devap_ice(:,:,jl) * xcplmask(:,:,0) + zdevap_ice(:,:) * zmsk(:,:) 
     1840         ENDDO 
     1841      ELSE 
     1842         emp_tot(:,:) =         zemp_tot(:,:) 
     1843         emp_ice(:,:) =         zemp_ice(:,:) 
     1844         emp_oce(:,:) =         zemp_oce(:,:)      
     1845         sprecip(:,:) =         zsprecip(:,:) 
     1846         tprecip(:,:) =         ztprecip(:,:) 
     1847         DO jl=1,jpl 
     1848            evap_ice (:,:,jl) = zevap_ice (:,:) 
     1849            devap_ice(:,:,jl) = zdevap_ice(:,:) 
     1850         ENDDO 
     1851      ENDIF 
     1852 
     1853      IF( iom_use('subl_ai_cea') )   CALL iom_put( 'subl_ai_cea', zevap_ice(:,:) * zicefr(:,:)         )  ! Sublimation over sea-ice (cell average) 
     1854                                     CALL iom_put( 'snowpre'    , sprecip(:,:)                         )  ! Snow 
     1855      IF( iom_use('snow_ao_cea') )   CALL iom_put( 'snow_ao_cea', sprecip(:,:) * ( 1._wp - zsnw(:,:) ) )  ! Snow over ice-free ocean  (cell average) 
     1856      IF( iom_use('snow_ai_cea') )   CALL iom_put( 'snow_ai_cea', sprecip(:,:) *           zsnw(:,:)   )  ! Snow over sea-ice         (cell average) 
     1857#else 
     1858      ! runoffs and calving (put in emp_tot) 
     1859      IF( srcv(jpr_rnf)%laction )   rnf(:,:) = frcv(jpr_rnf)%z3(:,:,1) 
     1860      IF( iom_use('hflx_rnf_cea') )   & 
     1861         CALL iom_put( 'hflx_rnf_cea' , rnf(:,:) * zcptn(:,:) ) 
    14281862      IF( srcv(jpr_cal)%laction ) THEN  
    14291863         zemp_tot(:,:) = zemp_tot(:,:) - frcv(jpr_cal)%z3(:,:,1) 
     
    14431877      ENDIF 
    14441878 
    1445          CALL iom_put( 'snowpre'    , sprecip                                )   ! Snow 
    1446       IF( iom_use('snow_ao_cea') )   & 
    1447          CALL iom_put( 'snow_ao_cea', sprecip(:,:) * p_frld(:,:)             )   ! Snow        over ice-free ocean  (cell average) 
    1448       IF( iom_use('snow_ai_cea') )   & 
    1449          CALL iom_put( 'snow_ai_cea', sprecip(:,:) * zicefr(:,:)             )   ! Snow        over sea-ice         (cell average) 
     1879      IF( iom_use('subl_ai_cea') )  CALL iom_put( 'subl_ai_cea', frcv(jpr_ievp)%z3(:,:,1) * zicefr(:,:) )  ! Sublimation over sea-ice (cell average) 
     1880                                    CALL iom_put( 'snowpre'    , sprecip(:,:)               )   ! Snow 
     1881      IF( iom_use('snow_ao_cea') )  CALL iom_put( 'snow_ao_cea', sprecip(:,:) * p_frld(:,:) )   ! Snow over ice-free ocean  (cell average) 
     1882      IF( iom_use('snow_ai_cea') )  CALL iom_put( 'snow_ai_cea', sprecip(:,:) * zicefr(:,:) )   ! Snow over sea-ice         (cell average) 
     1883#endif 
    14501884 
    14511885      !                                                      ! ========================= ! 
    14521886      SELECT CASE( TRIM( sn_rcv_qns%cldes ) )                !   non solar heat fluxes   !   (qns) 
    14531887      !                                                      ! ========================= ! 
    1454       CASE( 'oce only' )                                     ! the required field is directly provided 
    1455          zqns_tot(:,:  ) = frcv(jpr_qnsoce)%z3(:,:,1) 
    1456       CASE( 'conservative' )                                      ! the required fields are directly provided 
    1457          zqns_tot(:,:  ) = frcv(jpr_qnsmix)%z3(:,:,1) 
     1888      CASE( 'oce only' )         ! the required field is directly provided 
     1889         zqns_tot(:,:) = frcv(jpr_qnsoce)%z3(:,:,1) 
     1890      CASE( 'conservative' )     ! the required fields are directly provided 
     1891         zqns_tot(:,:) = frcv(jpr_qnsmix)%z3(:,:,1) 
    14581892         IF ( TRIM(sn_rcv_qns%clcat) == 'yes' ) THEN 
    14591893            zqns_ice(:,:,1:jpl) = frcv(jpr_qnsice)%z3(:,:,1:jpl) 
    14601894         ELSE 
    1461             ! Set all category values equal for the moment 
    14621895            DO jl=1,jpl 
    1463                zqns_ice(:,:,jl) = frcv(jpr_qnsice)%z3(:,:,1) 
     1896               zqns_ice(:,:,jl) = frcv(jpr_qnsice)%z3(:,:,1) ! Set all category values equal 
    14641897            ENDDO 
    14651898         ENDIF 
    1466       CASE( 'oce and ice' )       ! the total flux is computed from ocean and ice fluxes 
    1467          zqns_tot(:,:  ) =  p_frld(:,:) * frcv(jpr_qnsoce)%z3(:,:,1) 
     1899      CASE( 'oce and ice' )      ! the total flux is computed from ocean and ice fluxes 
     1900         zqns_tot(:,:) =  p_frld(:,:) * frcv(jpr_qnsoce)%z3(:,:,1) 
    14681901         IF ( TRIM(sn_rcv_qns%clcat) == 'yes' ) THEN 
    14691902            DO jl=1,jpl 
     
    14721905            ENDDO 
    14731906         ELSE 
    1474             qns_tot(:,:   ) = qns_tot(:,:) + zicefr(:,:) * frcv(jpr_qnsice)%z3(:,:,1) 
     1907            qns_tot(:,:) = qns_tot(:,:) + zicefr(:,:) * frcv(jpr_qnsice)%z3(:,:,1) 
    14751908            DO jl=1,jpl 
    14761909               zqns_tot(:,:   ) = zqns_tot(:,:) + zicefr(:,:) * frcv(jpr_qnsice)%z3(:,:,1) 
     
    14781911            ENDDO 
    14791912         ENDIF 
    1480       CASE( 'mixed oce-ice' )     ! the ice flux is cumputed from the total flux, the SST and ice informations 
     1913      CASE( 'mixed oce-ice' )    ! the ice flux is cumputed from the total flux, the SST and ice informations 
    14811914! ** NEED TO SORT OUT HOW THIS SHOULD WORK IN THE MULTI-CATEGORY CASE - CURRENTLY NOT ALLOWED WHEN INTERFACE INITIALISED ** 
    14821915         zqns_tot(:,:  ) = frcv(jpr_qnsmix)%z3(:,:,1) 
    14831916         zqns_ice(:,:,1) = frcv(jpr_qnsmix)%z3(:,:,1)    & 
    14841917            &            + frcv(jpr_dqnsdt)%z3(:,:,1) * ( pist(:,:,1) - ( (rt0 + psst(:,:  ) ) * p_frld(:,:)   & 
    1485             &                                                   +          pist(:,:,1)  * zicefr(:,:) ) ) 
     1918            &                                           + pist(:,:,1) * zicefr(:,:) ) ) 
    14861919      END SELECT 
    14871920!!gm 
     
    14931926!! similar job should be done for snow and precipitation temperature 
    14941927      !                                      
    1495       IF( srcv(jpr_cal)%laction ) THEN                            ! Iceberg melting  
    1496          ztmp(:,:) = frcv(jpr_cal)%z3(:,:,1) * lfus               ! add the latent heat of iceberg melting  
    1497          zqns_tot(:,:) = zqns_tot(:,:) - ztmp(:,:) 
    1498          IF( iom_use('hflx_cal_cea') )   & 
    1499             CALL iom_put( 'hflx_cal_cea', ztmp + frcv(jpr_cal)%z3(:,:,1) * zcptn(:,:) )   ! heat flux from calving 
    1500       ENDIF 
    1501  
    1502       ztmp(:,:) = p_frld(:,:) * zsprecip(:,:) * lfus 
    1503       IF( iom_use('hflx_snow_cea') )    CALL iom_put( 'hflx_snow_cea', ztmp + sprecip(:,:) * zcptn(:,:) )   ! heat flux from snow (cell average) 
    1504  
    1505 #if defined key_lim3 
    1506       CALL wrk_alloc( jpi,jpj, zevap, zsnw, zqns_oce, zqprec_ice, zqemp_oce )  
    1507  
    1508       ! --- evaporation --- ! 
    1509       ! clem: evap_ice is set to 0 for LIM3 since we still do not know what to do with sublimation 
    1510       ! the problem is: the atm. imposes both mass evaporation and heat removed from the snow/ice 
    1511       !                 but it is incoherent WITH the ice model   
    1512       DO jl=1,jpl 
    1513          evap_ice(:,:,jl) = 0._wp  ! should be: frcv(jpr_ievp)%z3(:,:,1) 
    1514       ENDDO 
    1515       zevap(:,:) = zemp_tot(:,:) + ztprecip(:,:) ! evaporation over ocean 
    1516  
    1517       ! --- evaporation minus precipitation --- ! 
    1518       emp_oce(:,:) = emp_tot(:,:) - emp_ice(:,:) 
    1519  
     1928      IF( srcv(jpr_cal)%laction ) THEN   ! Iceberg melting  
     1929         zqns_tot(:,:) = zqns_tot(:,:) - frcv(jpr_cal)%z3(:,:,1) * lfus  ! add the latent heat of iceberg melting 
     1930                                                                         ! we suppose it melts at 0deg, though it should be temp. of surrounding ocean 
     1931         IF( iom_use('hflx_cal_cea') )   CALL iom_put( 'hflx_cal_cea', - frcv(jpr_cal)%z3(:,:,1) * lfus )   ! heat flux from calving 
     1932      ENDIF 
     1933 
     1934#if defined key_lim3       
    15201935      ! --- non solar flux over ocean --- ! 
    15211936      !         note: p_frld cannot be = 0 since we limit the ice concentration to amax 
     
    15231938      WHERE( p_frld /= 0._wp )  zqns_oce(:,:) = ( zqns_tot(:,:) - SUM( a_i * zqns_ice, dim=3 ) ) / p_frld(:,:) 
    15241939 
    1525       ! --- heat flux associated with emp --- ! 
    1526       zsnw(:,:) = 0._wp 
    1527       CALL lim_thd_snwblow( p_frld, zsnw )  ! snow distribution over ice after wind blowing 
    1528       zqemp_oce(:,:) = -      zevap(:,:)                   * p_frld(:,:)      *   zcptn(:,:)   &      ! evap 
    1529          &             + ( ztprecip(:,:) - zsprecip(:,:) )                    *   zcptn(:,:)   &      ! liquid precip 
    1530          &             +   zsprecip(:,:)                   * ( 1._wp - zsnw ) * ( zcptn(:,:) - lfus ) ! solid precip over ocean 
    1531       qemp_ice(:,:)  = -   frcv(jpr_ievp)%z3(:,:,1)        * zicefr(:,:)      *   zcptn(:,:)   &      ! ice evap 
    1532          &             +   zsprecip(:,:)                   * zsnw             * ( zcptn(:,:) - lfus ) ! solid precip over ice 
    1533  
    1534       ! --- heat content of precip over ice in J/m3 (to be used in 1D-thermo) --- ! 
     1940      ! --- heat flux associated with emp (W/m2) --- ! 
     1941      zqemp_oce(:,:) = -  zevap_oce(:,:)                                      *   zcptn(:,:)   &       ! evap 
     1942         &             + ( ztprecip(:,:) - zsprecip(:,:) )                    *   zcptn(:,:)   &       ! liquid precip 
     1943         &             +   zsprecip(:,:)                   * ( 1._wp - zsnw ) * ( zcptn(:,:) - lfus )  ! solid precip over ocean + snow melting 
     1944!      zqemp_ice(:,:) = -   frcv(jpr_ievp)%z3(:,:,1)        * zicefr(:,:)      *   zcptn(:,:)   &      ! ice evap 
     1945!         &             +   zsprecip(:,:)                   * zsnw             * ( zcptn(:,:) - lfus ) ! solid precip over ice 
     1946      zqemp_ice(:,:) =      zsprecip(:,:)                   * zsnw             * ( zcptn(:,:) - lfus ) ! solid precip over ice (only) 
     1947                                                                                                       ! qevap_ice=0 since we consider Tice=0degC 
     1948       
     1949      ! --- enthalpy of snow precip over ice in J/m3 (to be used in 1D-thermo) --- ! 
    15351950      zqprec_ice(:,:) = rhosn * ( zcptn(:,:) - lfus ) 
    15361951 
    1537       ! --- total non solar flux --- ! 
    1538       zqns_tot(:,:) = zqns_tot(:,:) + qemp_ice(:,:) + zqemp_oce(:,:) 
     1952      ! --- heat content of evap over ice in W/m2 (to be used in 1D-thermo) --- ! 
     1953      DO jl = 1, jpl 
     1954         zqevap_ice(:,:,jl) = 0._wp ! should be -evap * ( ( Tice - rt0 ) * cpic ) but we do not have Tice, so we consider Tice=0degC 
     1955      END DO 
     1956 
     1957      ! --- total non solar flux (including evap/precip) --- ! 
     1958      zqns_tot(:,:) = zqns_tot(:,:) + zqemp_ice(:,:) + zqemp_oce(:,:) 
    15391959 
    15401960      ! --- in case both coupled/forced are active, we must mix values --- !  
     
    15431963         qns_oce(:,:) = qns_oce(:,:) * xcplmask(:,:,0) + zqns_oce(:,:)* zmsk(:,:) 
    15441964         DO jl=1,jpl 
    1545             qns_ice(:,:,jl) = qns_ice(:,:,jl) * xcplmask(:,:,0) +  zqns_ice(:,:,jl)* zmsk(:,:) 
     1965            qns_ice  (:,:,jl) = qns_ice  (:,:,jl) * xcplmask(:,:,0) +  zqns_ice  (:,:,jl)* zmsk(:,:) 
     1966            qevap_ice(:,:,jl) = qevap_ice(:,:,jl) * xcplmask(:,:,0) +  zqevap_ice(:,:,jl)* zmsk(:,:) 
    15461967         ENDDO 
    15471968         qprec_ice(:,:) = qprec_ice(:,:) * xcplmask(:,:,0) + zqprec_ice(:,:)* zmsk(:,:) 
    15481969         qemp_oce (:,:) =  qemp_oce(:,:) * xcplmask(:,:,0) +  zqemp_oce(:,:)* zmsk(:,:) 
    1549 !!clem         evap_ice(:,:) = evap_ice(:,:) * xcplmask(:,:,0) 
     1970         qemp_ice (:,:) =  qemp_ice(:,:) * xcplmask(:,:,0) +  zqemp_ice(:,:)* zmsk(:,:) 
    15501971      ELSE 
    15511972         qns_tot  (:,:  ) = zqns_tot  (:,:  ) 
    15521973         qns_oce  (:,:  ) = zqns_oce  (:,:  ) 
    15531974         qns_ice  (:,:,:) = zqns_ice  (:,:,:) 
    1554          qprec_ice(:,:)   = zqprec_ice(:,:) 
    1555          qemp_oce (:,:)   = zqemp_oce (:,:) 
    1556       ENDIF 
    1557  
    1558       CALL wrk_dealloc( jpi,jpj, zevap, zsnw, zqns_oce, zqprec_ice, zqemp_oce )  
     1975         qevap_ice(:,:,:) = zqevap_ice(:,:,:) 
     1976         qprec_ice(:,:  ) = zqprec_ice(:,:  ) 
     1977         qemp_oce (:,:  ) = zqemp_oce (:,:  ) 
     1978         qemp_ice (:,:  ) = zqemp_ice (:,:  ) 
     1979      ENDIF 
     1980 
     1981      !! clem: we should output qemp_oce and qemp_ice (at least) 
     1982      IF( iom_use('hflx_snow_cea') )   CALL iom_put( 'hflx_snow_cea', sprecip(:,:) * ( zcptn(:,:) - Lfus ) )   ! heat flux from snow (cell average) 
     1983      !! these diags are not outputed yet 
     1984!!      IF( iom_use('hflx_rain_cea') )   CALL iom_put( 'hflx_rain_cea', ( tprecip(:,:) - sprecip(:,:) ) * zcptn(:,:) )   ! heat flux from rain (cell average) 
     1985!!      IF( iom_use('hflx_snow_ao_cea') ) CALL iom_put( 'hflx_snow_ao_cea', sprecip(:,:) * ( zcptn(:,:) - Lfus ) * (1._wp - zsnw(:,:)) ) ! heat flux from snow (cell average) 
     1986!!      IF( iom_use('hflx_snow_ai_cea') ) CALL iom_put( 'hflx_snow_ai_cea', sprecip(:,:) * ( zcptn(:,:) - Lfus ) * zsnw(:,:) ) ! heat flux from snow (cell average) 
     1987 
    15591988#else 
    1560  
    15611989      ! clem: this formulation is certainly wrong... but better than it was... 
     1990       
    15621991      zqns_tot(:,:) = zqns_tot(:,:)                       &            ! zqns_tot update over free ocean with: 
    1563          &          - ztmp(:,:)                           &            ! remove the latent heat flux of solid precip. melting 
     1992         &          - (p_frld(:,:) * zsprecip(:,:) * lfus)  &          ! remove the latent heat flux of solid precip. melting 
    15641993         &          - (  zemp_tot(:,:)                    &            ! remove the heat content of mass flux (assumed to be at SST) 
    1565          &             - zemp_ice(:,:) * zicefr(:,:)  ) * zcptn(:,:)  
     1994         &             - zemp_ice(:,:) ) * zcptn(:,:)  
    15661995 
    15671996     IF( ln_mixcpl ) THEN 
     
    15752004         qns_ice(:,:,:) = zqns_ice(:,:,:) 
    15762005      ENDIF 
    1577  
    15782006#endif 
    15792007 
     
    16262054 
    16272055#if defined key_lim3 
    1628       CALL wrk_alloc( jpi,jpj, zqsr_oce )  
    16292056      ! --- solar flux over ocean --- ! 
    16302057      !         note: p_frld cannot be = 0 since we limit the ice concentration to amax 
     
    16342061      IF( ln_mixcpl ) THEN   ;   qsr_oce(:,:) = qsr_oce(:,:) * xcplmask(:,:,0) +  zqsr_oce(:,:)* zmsk(:,:) 
    16352062      ELSE                   ;   qsr_oce(:,:) = zqsr_oce(:,:)   ;   ENDIF 
    1636  
    1637       CALL wrk_dealloc( jpi,jpj, zqsr_oce )  
    16382063#endif 
    16392064 
     
    16862111      fr2_i0(:,:) = ( 0.82 * ( 1.0 - cldf_ice ) + 0.65 * cldf_ice ) 
    16872112 
    1688       CALL wrk_dealloc( jpi,jpj,     zcptn, ztmp, zicefr, zmsk, zemp_tot, zemp_ice, zsprecip, ztprecip, zqns_tot, zqsr_tot ) 
    1689       CALL wrk_dealloc( jpi,jpj,jpl, zqns_ice, zqsr_ice, zdqns_ice ) 
     2113      CALL wrk_dealloc( jpi,jpj,     zcptn, ztmp, zicefr, zmsk, zsnw ) 
     2114      CALL wrk_dealloc( jpi,jpj,     zemp_tot, zemp_ice, zemp_oce, ztprecip, zsprecip, zevap_oce, zevap_ice, zdevap_ice ) 
     2115      CALL wrk_dealloc( jpi,jpj,     zqns_tot, zqns_oce, zqsr_tot, zqsr_oce, zqprec_ice, zqemp_oce, zqemp_ice ) 
     2116      CALL wrk_dealloc( jpi,jpj,jpl, zqns_ice, zqsr_ice, zdqns_ice, zqevap_ice ) 
    16902117      ! 
    16912118      IF( nn_timing == 1 )  CALL timing_stop('sbc_cpl_ice_flx') 
     
    17062133      ! 
    17072134      INTEGER ::   ji, jj, jl   ! dummy loop indices 
     2135      INTEGER ::   ikchoix 
    17082136      INTEGER ::   isec, info   ! local integer 
    17092137      REAL(wp) ::   zumax, zvmax 
    17102138      REAL(wp), POINTER, DIMENSION(:,:)   ::   zfr_l, ztmp1, ztmp2, zotx1, zoty1, zotz1, zitx1, zity1, zitz1 
     2139      REAL(wp), POINTER, DIMENSION(:,:)   ::   zotx1_in, zoty1_in 
    17112140      REAL(wp), POINTER, DIMENSION(:,:,:) ::   ztmp3, ztmp4    
    17122141      !!---------------------------------------------------------------------- 
     
    17152144      ! 
    17162145      CALL wrk_alloc( jpi,jpj, zfr_l, ztmp1, ztmp2, zotx1, zoty1, zotz1, zitx1, zity1, zitz1 ) 
     2146      CALL wrk_alloc( jpi,jpj, zotx1_in, zoty1_in) 
    17172147      CALL wrk_alloc( jpi,jpj,jpl, ztmp3, ztmp4 ) 
    17182148 
     
    17432173                     ztmp3(:,:,1) = SUM( tn_ice * a_i, dim=3 ) / SUM( a_i, dim=3 ) 
    17442174                  ELSEWHERE 
    1745                      ztmp3(:,:,1) = rt0 ! TODO: Is freezing point a good default? (Maybe SST is better?) 
     2175                     ztmp3(:,:,1) = rt0 
    17462176                  END WHERE 
    17472177               CASE default   ;   CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_temp%clcat' ) 
     
    17582188               CASE default                  ;   CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_temp%clcat' ) 
    17592189               END SELECT 
     2190            CASE( 'oce and weighted ice' )   ;   ztmp1(:,:) =   tsn(:,:,1,jp_tem) + rt0  
     2191               SELECT CASE( sn_snd_temp%clcat ) 
     2192               CASE( 'yes' )    
     2193           ztmp3(:,:,1:jpl) = tn_ice(:,:,1:jpl) * a_i(:,:,1:jpl) 
     2194               CASE( 'no' ) 
     2195           ztmp3(:,:,:) = 0.0 
     2196           DO jl=1,jpl 
     2197                     ztmp3(:,:,1) = ztmp3(:,:,1) + tn_ice(:,:,jl) * a_i(:,:,jl) 
     2198           ENDDO 
     2199               CASE default                  ;   CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_temp%clcat' ) 
     2200               END SELECT 
    17602201            CASE( 'mixed oce-ice'        )    
    17612202               ztmp1(:,:) = ( ztmp1(:,:) + rt0 ) * zfr_l(:,:)  
     
    17742215      !                                                      ! ------------------------- ! 
    17752216      IF( ssnd(jps_albice)%laction ) THEN                         ! ice  
    1776          SELECT CASE( sn_snd_alb%cldes ) 
    1777          CASE( 'ice'          )   ; ztmp3(:,:,1:jpl) = alb_ice(:,:,1:jpl) 
    1778          CASE( 'weighted ice' )   ; ztmp3(:,:,1:jpl) = alb_ice(:,:,1:jpl) * a_i(:,:,1:jpl) 
    1779          CASE default             ; CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_alb%cldes' ) 
     2217          SELECT CASE( sn_snd_alb%cldes ) 
     2218          CASE( 'ice' ) 
     2219             SELECT CASE( sn_snd_alb%clcat ) 
     2220             CASE( 'yes' )    
     2221                ztmp3(:,:,1:jpl) = alb_ice(:,:,1:jpl) 
     2222             CASE( 'no' ) 
     2223                WHERE( SUM( a_i, dim=3 ) /= 0. ) 
     2224                   ztmp1(:,:) = SUM( alb_ice (:,:,1:jpl) * a_i(:,:,1:jpl), dim=3 ) / SUM( a_i(:,:,1:jpl), dim=3 ) 
     2225                ELSEWHERE 
     2226                   ztmp1(:,:) = albedo_oce_mix(:,:) 
     2227                END WHERE 
     2228             CASE default   ;   CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_alb%clcat' ) 
     2229             END SELECT 
     2230          CASE( 'weighted ice' )   ; 
     2231             SELECT CASE( sn_snd_alb%clcat ) 
     2232             CASE( 'yes' )    
     2233                ztmp3(:,:,1:jpl) =  alb_ice(:,:,1:jpl) * a_i(:,:,1:jpl) 
     2234             CASE( 'no' ) 
     2235                WHERE( fr_i (:,:) > 0. ) 
     2236                   ztmp1(:,:) = SUM (  alb_ice(:,:,1:jpl) * a_i(:,:,1:jpl), dim=3 ) 
     2237                ELSEWHERE 
     2238                   ztmp1(:,:) = 0. 
     2239                END WHERE 
     2240             CASE default   ;   CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_ice%clcat' ) 
     2241             END SELECT 
     2242          CASE default      ;   CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_alb%cldes' ) 
    17802243         END SELECT 
    1781          CALL cpl_snd( jps_albice, isec, ztmp3, info ) 
    1782       ENDIF 
     2244 
     2245         SELECT CASE( sn_snd_alb%clcat ) 
     2246            CASE( 'yes' )    
     2247               CALL cpl_snd( jps_albice, isec, ztmp3, info )      !-> MV this has never been checked in coupled mode 
     2248            CASE( 'no'  )    
     2249               CALL cpl_snd( jps_albice, isec, RESHAPE ( ztmp1, (/jpi,jpj,1/) ), info )  
     2250         END SELECT 
     2251      ENDIF 
     2252 
    17832253      IF( ssnd(jps_albmix)%laction ) THEN                         ! mixed ice-ocean 
    17842254         ztmp1(:,:) = albedo_oce_mix(:,:) * zfr_l(:,:) 
     
    17992269         END SELECT 
    18002270         IF( ssnd(jps_fice)%laction )   CALL cpl_snd( jps_fice, isec, ztmp3, info ) 
     2271      ENDIF 
     2272       
     2273      ! Send ice fraction field (first order interpolation), for weighting UM fluxes to be passed to NEMO 
     2274      IF (ssnd(jps_fice1)%laction) THEN 
     2275         SELECT CASE (sn_snd_thick1%clcat) 
     2276         CASE( 'yes' )   ;   ztmp3(:,:,1:jpl) =  a_i(:,:,1:jpl) 
     2277         CASE( 'no' )    ;   ztmp3(:,:,1) = fr_i(:,:) 
     2278         CASE default    ;   CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_thick1%clcat' ) 
     2279    END SELECT 
     2280         CALL cpl_snd (jps_fice1, isec, ztmp3, info) 
    18012281      ENDIF 
    18022282       
     
    18452325      ENDIF 
    18462326      ! 
     2327#if defined key_cice && ! defined key_cice4 
     2328      ! Send meltpond fields  
     2329      IF( ssnd(jps_a_p)%laction .OR. ssnd(jps_ht_p)%laction ) THEN 
     2330         SELECT CASE( sn_snd_mpnd%cldes)  
     2331         CASE( 'weighted ice' )  
     2332            SELECT CASE( sn_snd_mpnd%clcat )  
     2333            CASE( 'yes' )  
     2334               ztmp3(:,:,1:jpl) =  a_p(:,:,1:jpl) * a_i(:,:,1:jpl)  
     2335               ztmp4(:,:,1:jpl) =  ht_p(:,:,1:jpl) * a_i(:,:,1:jpl)  
     2336            CASE( 'no' )  
     2337               ztmp3(:,:,:) = 0.0  
     2338               ztmp4(:,:,:) = 0.0  
     2339               DO jl=1,jpl  
     2340                 ztmp3(:,:,1) = ztmp3(:,:,1) + a_p(:,:,jpl) * a_i(:,:,jpl)  
     2341                 ztmp4(:,:,1) = ztmp4(:,:,1) + ht_p(:,:,jpl) * a_i(:,:,jpl)  
     2342               ENDDO  
     2343            CASE default    ;   CALL ctl_stop( 'sbc_cpl_mpd: wrong definition of sn_snd_mpnd%clcat' )  
     2344            END SELECT  
     2345         CASE( 'ice only' )     
     2346            ztmp3(:,:,1:jpl) = a_p(:,:,1:jpl)  
     2347            ztmp4(:,:,1:jpl) = ht_p(:,:,1:jpl)  
     2348         END SELECT  
     2349         IF( ssnd(jps_a_p)%laction )   CALL cpl_snd( jps_a_p, isec, ztmp3, info )     
     2350         IF( ssnd(jps_ht_p)%laction )   CALL cpl_snd( jps_ht_p, isec, ztmp4, info )     
     2351         ! 
     2352         ! Send ice effective conductivity 
     2353         SELECT CASE( sn_snd_cond%cldes) 
     2354         CASE( 'weighted ice' )    
     2355            SELECT CASE( sn_snd_cond%clcat ) 
     2356            CASE( 'yes' )    
     2357               ztmp3(:,:,1:jpl) =  kn_ice(:,:,1:jpl) * a_i(:,:,1:jpl) 
     2358            CASE( 'no' ) 
     2359               ztmp3(:,:,:) = 0.0 
     2360               DO jl=1,jpl 
     2361                 ztmp3(:,:,1) = ztmp3(:,:,1) + kn_ice(:,:,jl) * a_i(:,:,jl) 
     2362               ENDDO 
     2363            CASE default                  ;   CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_cond%clcat' ) 
     2364            END SELECT 
     2365         CASE( 'ice only' )    
     2366           ztmp3(:,:,1:jpl) = kn_ice(:,:,1:jpl) 
     2367         END SELECT 
     2368         IF( ssnd(jps_kice)%laction )   CALL cpl_snd( jps_kice, isec, ztmp3, info ) 
     2369      ENDIF 
     2370#endif 
     2371      ! 
     2372      ! 
    18472373#if defined key_cpl_carbon_cycle 
    18482374      !                                                      ! ------------------------- ! 
     
    18522378      ! 
    18532379#endif 
     2380 
     2381 
     2382 
     2383      IF (ln_medusa) THEN 
     2384      !                                                      ! ---------------------------------------------- ! 
     2385      !                                                      !  CO2 flux, DMS and chlorophyll from MEDUSA     !  
     2386      !                                                      ! ---------------------------------------------- ! 
     2387         IF ( ssnd(jps_bio_co2)%laction ) THEN 
     2388            CALL cpl_snd( jps_bio_co2, isec, RESHAPE( CO2Flux_out_cpl, (/jpi,jpj,1/) ), info ) 
     2389         ENDIF 
     2390 
     2391         IF ( ssnd(jps_bio_dms)%laction )  THEN 
     2392            CALL cpl_snd( jps_bio_dms, isec, RESHAPE( DMS_out_cpl, (/jpi,jpj,1/) ), info ) 
     2393         ENDIF 
     2394 
     2395         IF ( ssnd(jps_bio_chloro)%laction )  THEN 
     2396            CALL cpl_snd( jps_bio_chloro, isec, RESHAPE( chloro_out_cpl, (/jpi,jpj,1/) ), info ) 
     2397         ENDIF 
     2398      ENDIF 
     2399 
    18542400      !                                                      ! ------------------------- ! 
    18552401      IF( ssnd(jps_ocx1)%laction ) THEN                      !      Surface current      ! 
     
    18582404         !                                                  j+1   j     -----V---F 
    18592405         ! surface velocity always sent from T point                     !       | 
    1860          !                                                        j      |   T   U 
     2406         ! [except for HadGEM3]                                   j      |   T   U 
    18612407         !                                                               |       | 
    18622408         !                                                   j    j-1   -I-------| 
     
    18672413            zotx1(:,:) = un(:,:,1)   
    18682414            zoty1(:,:) = vn(:,:,1)   
    1869          ELSE         
     2415         ELSE 
    18702416            SELECT CASE( TRIM( sn_snd_crt%cldes ) ) 
    18712417            CASE( 'oce only'             )      ! C-grid ==> T 
    1872                DO jj = 2, jpjm1 
    1873                   DO ji = fs_2, fs_jpim1   ! vector opt. 
    1874                      zotx1(ji,jj) = 0.5 * ( un(ji,jj,1) + un(ji-1,jj  ,1) ) 
    1875                      zoty1(ji,jj) = 0.5 * ( vn(ji,jj,1) + vn(ji  ,jj-1,1) )  
     2418               IF ( TRIM( sn_snd_crt%clvgrd ) == 'T' ) THEN 
     2419                  DO jj = 2, jpjm1 
     2420                     DO ji = fs_2, fs_jpim1   ! vector opt. 
     2421                        zotx1(ji,jj) = 0.5 * ( un(ji,jj,1) + un(ji-1,jj  ,1) ) 
     2422                        zoty1(ji,jj) = 0.5 * ( vn(ji,jj,1) + vn(ji  ,jj-1,1) )  
     2423                     END DO 
    18762424                  END DO 
    1877                END DO 
     2425               ELSE 
     2426! Temporarily Changed for UKV 
     2427                  DO jj = 2, jpjm1 
     2428                     DO ji = 2, jpim1 
     2429                        zotx1(ji,jj) = un(ji,jj,1) 
     2430                        zoty1(ji,jj) = vn(ji,jj,1) 
     2431                     END DO 
     2432                  END DO 
     2433               ENDIF  
    18782434            CASE( 'weighted oce and ice' )    
    18792435               SELECT CASE ( cp_ice_msh ) 
     
    19342490                  END DO 
    19352491               CASE( 'F' )                      ! Ocean on C grid, Ice on F-point (B-grid) ==> T 
    1936                   DO jj = 2, jpjm1 
    1937                      DO ji = 2, jpim1   ! NO vector opt. 
    1938                         zotx1(ji,jj) = 0.5  * ( un(ji,jj,1)      + un(ji-1,jj  ,1) ) * zfr_l(ji,jj)   &    
    1939                            &         + 0.25 * ( u_ice(ji-1,jj-1) + u_ice(ji,jj-1)                     & 
    1940                            &                  + u_ice(ji-1,jj  ) + u_ice(ji,jj  )  ) *  fr_i(ji,jj) 
    1941                         zoty1(ji,jj) = 0.5  * ( vn(ji,jj,1)      + vn(ji  ,jj-1,1) ) * zfr_l(ji,jj)   &  
    1942                            &         + 0.25 * ( v_ice(ji-1,jj-1) + v_ice(ji,jj-1)                     & 
    1943                            &                  + v_ice(ji-1,jj  ) + v_ice(ji,jj  )  ) *  fr_i(ji,jj) 
     2492                  IF ( TRIM( sn_snd_crt%clvgrd ) == 'T' ) THEN 
     2493                     DO jj = 2, jpjm1 
     2494                        DO ji = 2, jpim1   ! NO vector opt. 
     2495                           zotx1(ji,jj) = 0.5  * ( un(ji,jj,1)      + un(ji-1,jj,1) ) * zfr_l(ji,jj)   &    
     2496                                &         + 0.25 * ( u_ice(ji-1,jj-1) + u_ice(ji,jj-1)                     & 
     2497                                &                  + u_ice(ji-1,jj  ) + u_ice(ji,jj  )  ) *  fr_i(ji,jj) 
     2498                           zoty1(ji,jj) = 0.5  * ( vn(ji,jj,1)      + vn(ji,jj-1,1) ) * zfr_l(ji,jj)   & 
     2499                                &         + 0.25 * ( v_ice(ji-1,jj-1) + v_ice(ji,jj-1)                     & 
     2500                                &                  + v_ice(ji-1,jj  ) + v_ice(ji,jj  )  ) *  fr_i(ji,jj) 
     2501                        END DO 
    19442502                     END DO 
    1945                   END DO 
     2503#if defined key_cice 
     2504                  ELSE 
     2505! Temporarily Changed for HadGEM3 
     2506                     DO jj = 2, jpjm1 
     2507                        DO ji = 2, jpim1   ! NO vector opt. 
     2508                           zotx1(ji,jj) = (1.0-fr_iu(ji,jj)) * un(ji,jj,1)             & 
     2509                                &              + fr_iu(ji,jj) * 0.5 * ( u_ice(ji,jj-1) + u_ice(ji,jj) )  
     2510                           zoty1(ji,jj) = (1.0-fr_iv(ji,jj)) * vn(ji,jj,1)             & 
     2511                                &              + fr_iv(ji,jj) * 0.5 * ( v_ice(ji-1,jj) + v_ice(ji,jj) )  
     2512                        END DO 
     2513                     END DO 
     2514#endif 
     2515                  ENDIF 
    19462516               END SELECT 
    19472517            END SELECT 
     
    19532523         IF( TRIM( sn_snd_crt%clvor ) == 'eastward-northward' ) THEN             ! Rotation of the components 
    19542524            !                                                                     ! Ocean component 
    1955             CALL rot_rep( zotx1, zoty1, ssnd(jps_ocx1)%clgrid, 'ij->e', ztmp1 )       ! 1st component  
    1956             CALL rot_rep( zotx1, zoty1, ssnd(jps_ocx1)%clgrid, 'ij->n', ztmp2 )       ! 2nd component  
    1957             zotx1(:,:) = ztmp1(:,:)                                                   ! overwrite the components  
    1958             zoty1(:,:) = ztmp2(:,:) 
    1959             IF( ssnd(jps_ivx1)%laction ) THEN                                     ! Ice component 
    1960                CALL rot_rep( zitx1, zity1, ssnd(jps_ivx1)%clgrid, 'ij->e', ztmp1 )    ! 1st component  
    1961                CALL rot_rep( zitx1, zity1, ssnd(jps_ivx1)%clgrid, 'ij->n', ztmp2 )    ! 2nd component  
    1962                zitx1(:,:) = ztmp1(:,:)                                                ! overwrite the components  
    1963                zity1(:,:) = ztmp2(:,:) 
    1964             ENDIF 
     2525            IF ( TRIM( sn_snd_crt%clvgrd ) == 'T' ) THEN 
     2526               CALL rot_rep( zotx1, zoty1, ssnd(jps_ocx1)%clgrid, 'ij->e', ztmp1 )       ! 1st component 
     2527               CALL rot_rep( zotx1, zoty1, ssnd(jps_ocx1)%clgrid, 'ij->n', ztmp2 )       ! 2nd component 
     2528               zotx1(:,:) = ztmp1(:,:)                                                   ! overwrite the components 
     2529               zoty1(:,:) = ztmp2(:,:) 
     2530               IF( ssnd(jps_ivx1)%laction ) THEN                                  ! Ice component 
     2531                  CALL rot_rep( zitx1, zity1, ssnd(jps_ivx1)%clgrid, 'ij->e', ztmp1 )    ! 1st component 
     2532                  CALL rot_rep( zitx1, zity1, ssnd(jps_ivx1)%clgrid, 'ij->n', ztmp2 )    ! 2nd component 
     2533                  zitx1(:,:) = ztmp1(:,:)                                                ! overwrite the components 
     2534                  zity1(:,:) = ztmp2(:,:) 
     2535               ENDIF 
     2536            ELSE 
     2537               ! Temporary code for HadGEM3 - will be removed eventually. 
     2538               ! Only applies when we want uvel on U grid and vvel on V grid 
     2539               ! Rotate U and V onto geographic grid before sending. 
     2540 
     2541               DO jj=2,jpjm1 
     2542                  DO ji=2,jpim1 
     2543                     ztmp1(ji,jj)=0.25*vmask(ji,jj,1)                  & 
     2544                          *(zotx1(ji,jj)+zotx1(ji-1,jj)    & 
     2545                          +zotx1(ji,jj+1)+zotx1(ji-1,jj+1)) 
     2546                     ztmp2(ji,jj)=0.25*umask(ji,jj,1)                  & 
     2547                          *(zoty1(ji,jj)+zoty1(ji+1,jj)    & 
     2548                          +zoty1(ji,jj-1)+zoty1(ji+1,jj-1)) 
     2549                  ENDDO 
     2550               ENDDO 
     2551 
     2552               ! Ensure any N fold and wrap columns are updated 
     2553               CALL lbc_lnk(ztmp1, 'V', -1.0) 
     2554               CALL lbc_lnk(ztmp2, 'U', -1.0) 
     2555                             
     2556               ikchoix = -1 
     2557               ! We need copies of zotx1 and zoty2 in order to avoid problems  
     2558               ! caused by INTENTs used in the following subroutine.  
     2559               zotx1_in(:,:) = zotx1(:,:) 
     2560               zoty1_in(:,:) = zoty1(:,:) 
     2561               CALL repcmo (zotx1_in,ztmp2,ztmp1,zoty1_in,zotx1,zoty1,ikchoix) 
     2562           ENDIF 
    19652563         ENDIF 
    19662564         ! 
     
    20232621      IF( ssnd(jps_rnf   )%laction )  CALL cpl_snd( jps_rnf   , isec, RESHAPE ( rnf , (/jpi,jpj,1/) ), info ) 
    20242622      IF( ssnd(jps_taum  )%laction )  CALL cpl_snd( jps_taum  , isec, RESHAPE ( taum, (/jpi,jpj,1/) ), info ) 
    2025  
     2623       
     2624#if defined key_cice 
     2625      ztmp1(:,:) = sstfrz(:,:) + rt0 
     2626      IF( ssnd(jps_sstfrz)%laction )  CALL cpl_snd( jps_sstfrz, isec, RESHAPE ( ztmp1, (/jpi,jpj,1/) ), info ) 
     2627#endif 
     2628      ! 
    20262629      CALL wrk_dealloc( jpi,jpj, zfr_l, ztmp1, ztmp2, zotx1, zoty1, zotz1, zitx1, zity1, zitz1 ) 
     2630      CALL wrk_dealloc( jpi,jpj, zotx1_in, zoty1_in ) 
    20272631      CALL wrk_dealloc( jpi,jpj,jpl, ztmp3, ztmp4 ) 
    20282632      ! 
  • branches/UKMO/dev_r5518_obs_oper_update_icethick/NEMOGCM/NEMO/OPA_SRC/SBC/sbcfwb.F90

    r7960 r9987  
    108108         ! 
    109109         IF( MOD( kt-1, kn_fsbc ) == 0 ) THEN 
    110             z_fwf = glob_sum( e1e2t(:,:) * ( emp(:,:) - rnf(:,:) + rdivisf * fwfisf(:,:) - snwice_fmass(:,:) ) ) / area   ! sum over the global domain 
     110            z_fwf = glob_sum( e1e2t(:,:) * ( emp(:,:) - rnf(:,:) + fwfisf(:,:) - snwice_fmass(:,:) ) ) / area   ! sum over the global domain 
    111111            zcoef = z_fwf * rcp 
    112112            emp(:,:) = emp(:,:) - z_fwf              * tmask(:,:,1) 
     
    162162            zsurf_pos = glob_sum( e1e2t(:,:)*ztmsk_pos(:,:) ) 
    163163            !                                                  ! fwf global mean (excluding ocean to ice/snow exchanges)  
    164             z_fwf     = glob_sum( e1e2t(:,:) * ( emp(:,:) - rnf(:,:) + rdivisf * fwfisf(:,:) - snwice_fmass(:,:) ) ) / area 
     164            z_fwf     = glob_sum( e1e2t(:,:) * ( emp(:,:) - rnf(:,:) + fwfisf(:,:) - snwice_fmass(:,:) ) ) / area 
    165165            !             
    166166            IF( z_fwf < 0._wp ) THEN         ! spread out over >0 erp area to increase evaporation 
  • branches/UKMO/dev_r5518_obs_oper_update_icethick/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_cice.F90

    r7960 r9987  
    1515   USE dom_oce         ! ocean space and time domain 
    1616   USE domvvl 
    17    USE phycst, only : rcp, rau0, r1_rau0, rhosn, rhoic 
     17   USE eosbn2, only : eos_fzp ! Function to calculate freezing point of seawater 
     18   USE phycst, only : rcp, rau0, r1_rau0, rhosn, rhoic, rt0 
    1819   USE in_out_manager  ! I/O manager 
    1920   USE iom, ONLY : iom_put,iom_use              ! I/O manager library !!Joakim edit 
     
    3738   USE ice_gather_scatter 
    3839   USE ice_calendar, only: dt 
     40# if defined key_cice4 
    3941   USE ice_state, only: aice,aicen,uvel,vvel,vsno,vsnon,vice,vicen 
    40 # if defined key_cice4 
    4142   USE ice_flux, only: strax,stray,strocnx,strocny,frain,fsnow,  & 
    4243                strocnxT,strocnyT,                               &  
     
    4546                flatn_f,fsurfn_f,fcondtopn_f,                    & 
    4647                uatm,vatm,wind,fsw,flw,Tair,potT,Qa,rhoa,zlvl,   & 
    47                 swvdr,swvdf,swidr,swidf 
     48                swvdr,swvdf,swidr,swidf,Tf 
    4849   USE ice_therm_vertical, only: calc_Tsfc 
    4950#else 
     51   USE ice_state, only: aice,aicen,uvel,nt_hpnd,trcrn,vvel,vsno,& 
     52                vsnon,vice,vicen,nt_Tsfc 
    5053   USE ice_flux, only: strax,stray,strocnx,strocny,frain,fsnow,  & 
    5154                strocnxT,strocnyT,                               &  
    52                 sst,sss,uocn,vocn,ss_tltx,ss_tlty,fsalt_ai,     & 
    53                 fresh_ai,fhocn_ai,fswthru_ai,frzmlt,          & 
     55                sst,sss,uocn,vocn,ss_tltx,ss_tlty,fsalt_ai,      & 
     56                fresh_ai,fhocn_ai,fswthru_ai,frzmlt,             & 
    5457                flatn_f,fsurfn_f,fcondtopn_f,                    & 
     58#ifdef key_asminc 
     59                daice_da,fresh_da,fsalt_da,                    & 
     60#endif 
    5561                uatm,vatm,wind,fsw,flw,Tair,potT,Qa,rhoa,zlvl,   & 
    56                 swvdr,swvdf,swidr,swidf 
    57    USE ice_therm_shared, only: calc_Tsfc 
     62                swvdr,swvdf,swidr,swidf,Tf,                      & 
     63      !! When using NEMO with CICE, this change requires use of  
     64      !! one of the following two CICE branches: 
     65      !! - at CICE5.0,   hadax/r1015_GSI8_with_GSI7 
     66      !! - at CICE5.1.2, hadax/vn5.1.2_GSI8 
     67                keffn_top,Tn_top 
     68 
     69   USE ice_therm_shared, only: calc_Tsfc, heat_capacity 
     70   USE ice_shortwave, only: apeffn 
    5871#endif 
    5972   USE ice_forcing, only: frcvdr,frcvdf,frcidr,frcidf 
     
    161174      INTEGER, INTENT( in  ) ::   ksbc                ! surface forcing type 
    162175      REAL(wp), DIMENSION(:,:), POINTER :: ztmp1, ztmp2 
    163       REAL(wp) ::   zcoefu, zcoefv, zcoeff            ! local scalar 
     176      REAL(wp), DIMENSION(:,:,:), POINTER :: ztfrz3d 
    164177      INTEGER  ::   ji, jj, jl, jk                    ! dummy loop indices 
    165178      !!--------------------------------------------------------------------- 
     
    174187      jj_off = INT ( (jpjglo - ny_global) / 2 ) 
    175188 
    176 #if defined key_nemocice_decomp 
    177       ! Pass initial SST from NEMO to CICE so ice is initialised correctly if 
    178       ! there is no restart file. 
    179       ! Values from a CICE restart file would overwrite this 
    180       IF ( .NOT. ln_rstart ) THEN     
    181          CALL nemo2cice( tsn(:,:,1,jp_tem) , sst , 'T' , 1.)  
    182       ENDIF   
    183 #endif 
    184  
    185 ! Initialize CICE 
     189      ! Initialize CICE 
    186190      CALL CICE_Initialize 
    187191 
    188 ! Do some CICE consistency checks 
     192      ! Do some CICE consistency checks 
    189193      IF ( (ksbc == jp_flx) .OR. (ksbc == jp_purecpl) ) THEN 
    190194         IF ( calc_strair .OR. calc_Tsfc ) THEN 
     
    198202 
    199203 
    200 ! allocate sbc_ice and sbc_cice arrays 
    201       IF( sbc_ice_alloc()      /= 0 )   CALL ctl_stop( 'STOP', 'sbc_ice_cice_alloc : unable to allocate arrays' ) 
     204      ! allocate sbc_ice and sbc_cice arrays 
     205      IF( sbc_ice_alloc()      /= 0 )   CALL ctl_stop( 'STOP', 'sbc_ice_alloc : unable to allocate arrays' ) 
    202206      IF( sbc_ice_cice_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'sbc_ice_cice_alloc : unable to allocate cice arrays' ) 
    203207 
    204 ! Ensure ocean temperatures are nowhere below freezing if not a NEMO restart 
     208      ! Ensure that no temperature points are below freezing if not a NEMO restart 
    205209      IF( .NOT. ln_rstart ) THEN 
    206          tsn(:,:,:,jp_tem) = MAX (tsn(:,:,:,jp_tem),Tocnfrz) 
     210 
     211         CALL wrk_alloc( jpi,jpj,jpk, ztfrz3d )  
     212         DO jk=1,jpk 
     213             CALL eos_fzp( tsn(:,:,jk,jp_sal), ztfrz3d(:,:,jk), fsdept_n(:,:,jk) ) 
     214         ENDDO 
     215         tsn(:,:,:,jp_tem) = MAX( tsn(:,:,:,jp_tem), ztfrz3d ) 
    207216         tsb(:,:,:,jp_tem) = tsn(:,:,:,jp_tem) 
    208       ENDIF 
    209  
    210       fr_iu(:,:)=0.0 
    211       fr_iv(:,:)=0.0 
     217         CALL wrk_dealloc( jpi,jpj,jpk, ztfrz3d )  
     218 
     219#if defined key_nemocice_decomp 
     220         ! Pass initial SST from NEMO to CICE so ice is initialised correctly if 
     221         ! there is no restart file. 
     222         ! Values from a CICE restart file would overwrite this 
     223         CALL nemo2cice( tsn(:,:,1,jp_tem) , sst , 'T' , 1.)  
     224#endif 
     225 
     226      ENDIF   
     227 
     228      ! calculate surface freezing temperature and send to CICE 
     229      CALL  eos_fzp(sss_m(:,:), sstfrz(:,:), fsdept_n(:,:,1))  
     230      CALL nemo2cice(sstfrz,Tf, 'T', 1. ) 
    212231 
    213232      CALL cice2nemo(aice,fr_i, 'T', 1. ) 
     
    220239! T point to U point 
    221240! T point to V point 
     241      fr_iu(:,:)=0.0 
     242      fr_iv(:,:)=0.0 
    222243      DO jj=1,jpjm1 
    223244         DO ji=1,jpim1 
     
    283304  
    284305      CALL wrk_dealloc( jpi,jpj, ztmp1, ztmp2 ) 
    285       ! 
     306 
     307#if defined key_asminc 
     308      ! Initialize fresh water and salt fluxes from data assim    
     309      !  and data assimilation index to cice  
     310      nfresh_da(:,:) = 0.0    
     311      nfsalt_da(:,:) = 0.0    
     312      ndaice_da(:,:) = 0.0          
     313#endif 
     314      ! 
     315      ! In coupled mode get extra fields from CICE for passing back to atmosphere 
     316  
     317      IF ( ksbc == jp_purecpl ) CALL cice_sbc_hadgam(nit000) 
     318      !  
    286319      IF( nn_timing == 1 )  CALL timing_stop('cice_sbc_init') 
    287320      ! 
     
    343376         CALL nemo2cice(ztmp,stray,'F', -1. ) 
    344377 
     378 
     379! Alex West: From configuration GSI8 onwards, when NEMO is used with CICE in 
     380! HadGEM3 the 'time-travelling ice' coupling approach is used, whereby  
     381! atmosphere-ice fluxes are passed as pseudo-local values, formed by dividing 
     382! gridbox mean fluxes in the UM by future ice concentration obtained through   
     383! OASIS.  This allows for a much more realistic apportionment of energy through 
     384! the ice - and conserves energy. 
     385! Therefore the fluxes are now divided by ice concentration in the coupled 
     386! formulation (jp_purecpl) as well as for jp_flx.  This NEMO branch should only 
     387! be used at UM10.2 onwards (unless an explicit GSI8 UM branch is included), at 
     388! which point the GSI8 UM changes were committed. 
     389 
    345390! Surface downward latent heat flux (CI_5) 
    346391         IF (ksbc == jp_flx) THEN 
     
    348393               ztmpn(:,:,jl)=qla_ice(:,:,1)*a_i(:,:,jl) 
    349394            ENDDO 
    350          ELSE 
    351 ! emp_ice is set in sbc_cpl_ice_flx as sublimation-snow 
    352             qla_ice(:,:,1)= - ( emp_ice(:,:)+sprecip(:,:) ) * Lsub 
    353 ! End of temporary code 
    354             DO jj=1,jpj 
    355                DO ji=1,jpi 
    356                   IF (fr_i(ji,jj).eq.0.0) THEN 
    357                      DO jl=1,ncat 
    358                         ztmpn(ji,jj,jl)=0.0 
    359                      ENDDO 
    360                      ! This will then be conserved in CICE 
    361                      ztmpn(ji,jj,1)=qla_ice(ji,jj,1) 
    362                   ELSE 
    363                      DO jl=1,ncat 
    364                         ztmpn(ji,jj,jl)=qla_ice(ji,jj,1)*a_i(ji,jj,jl)/fr_i(ji,jj) 
    365                      ENDDO 
    366                   ENDIF 
    367                ENDDO 
     395         ELSE IF (ksbc == jp_purecpl) THEN 
     396            DO jl=1,ncat 
     397               ztmpn(:,:,jl)=qla_ice(:,:,jl)*a_i(:,:,jl) 
    368398            ENDDO 
     399    ELSE 
     400           !In coupled mode - qla_ice calculated in sbc_cpl for each category 
     401           ztmpn(:,:,1:ncat)=qla_ice(:,:,1:ncat) 
    369402         ENDIF 
     403 
    370404         DO jl=1,ncat 
    371405            CALL nemo2cice(ztmpn(:,:,jl),flatn_f(:,:,jl,:),'T', 1. ) 
     
    373407! GBM conductive flux through ice (CI_6) 
    374408!  Convert to GBM 
    375             IF (ksbc == jp_flx) THEN 
     409            IF (ksbc == jp_flx .OR. ksbc == jp_purecpl) THEN 
    376410               ztmp(:,:) = botmelt(:,:,jl)*a_i(:,:,jl) 
    377411            ELSE 
     
    382416! GBM surface heat flux (CI_7) 
    383417!  Convert to GBM 
    384             IF (ksbc == jp_flx) THEN 
     418            IF (ksbc == jp_flx .OR. ksbc == jp_purecpl) THEN 
    385419               ztmp(:,:) = (topmelt(:,:,jl)+botmelt(:,:,jl))*a_i(:,:,jl)  
    386420            ELSE 
     
    431465      ENDIF 
    432466 
     467#if defined key_asminc 
     468!Ice concentration change (from assimilation) 
     469      ztmp(:,:)=ndaice_da(:,:)*tmask(:,:,1) 
     470      Call nemo2cice(ztmp,daice_da,'T', 1. ) 
     471#endif  
     472 
    433473! Snowfall 
    434474! Ensure fsnow is positive (as in CICE routine prepare_forcing) 
    435475      IF( iom_use('snowpre') )   CALL iom_put('snowpre',MAX( (1.0-fr_i(:,:))*sprecip(:,:) ,0.0)) !!Joakim edit   
    436       ztmp(:,:)=MAX(fr_i(:,:)*sprecip(:,:),0.0)   
     476      IF( kt == nit000 .AND. lwp )  THEN 
     477         WRITE(numout,*) 'sprecip weight, rn_sfac=', rn_sfac 
     478      ENDIF 
     479      ztmp(:,:)=MAX(fr_i(:,:)*rn_sfac*sprecip(:,:),0.0)   
    437480      CALL nemo2cice(ztmp,fsnow,'T', 1. )  
    438481 
     
    442485      CALL nemo2cice(ztmp,frain,'T', 1. )  
    443486 
     487! Recalculate freezing temperature and send to CICE  
     488      CALL eos_fzp(sss_m(:,:), sstfrz(:,:), fsdept_n(:,:,1))  
     489      CALL nemo2cice(sstfrz,Tf,'T', 1. ) 
     490 
    444491! Freezing/melting potential 
    445492! Calculated over NEMO leapfrog timestep (hence 2*dt) 
    446       nfrzmlt(:,:)=rau0*rcp*fse3t_m(:,:)*(Tocnfrz-sst_m(:,:))/(2.0*dt) 
    447  
    448       ztmp(:,:) = nfrzmlt(:,:) 
    449       CALL nemo2cice(ztmp,frzmlt,'T', 1. ) 
     493      nfrzmlt(:,:)=rau0*rcp*fse3t_m(:,:)*(sstfrz(:,:)-sst_m(:,:))/(2.0*dt)  
     494      CALL nemo2cice(nfrzmlt,frzmlt,'T', 1. ) 
    450495 
    451496! SST  and SSS 
     
    453498      CALL nemo2cice(sst_m,sst,'T', 1. ) 
    454499      CALL nemo2cice(sss_m,sss,'T', 1. ) 
     500 
     501      IF( ksbc == jp_purecpl ) THEN 
     502! Sea ice surface skin temperature 
     503         DO jl=1,ncat 
     504           CALL nemo2cice(tsfc_ice(:,:,jl), trcrn(:,:,nt_tsfc,jl,:),'T',1.) 
     505         ENDDO  
     506      ENDIF 
    455507 
    456508! x comp and y comp of surface ocean current 
     
    685737      ENDIF 
    686738 
     739#if defined key_asminc 
     740! Import fresh water and salt flux due to seaice da 
     741      CALL cice2nemo(fresh_da, nfresh_da,'T',1.0) 
     742      CALL cice2nemo(fsalt_da, nfsalt_da,'T',1.0) 
     743#endif 
     744 
    687745! Release work space 
    688746 
     
    708766      IF( nn_timing == 1 )  CALL timing_start('cice_sbc_hadgam') 
    709767      ! 
    710       IF( kt == nit000 )  THEN 
    711          IF(lwp) WRITE(numout,*)'cice_sbc_hadgam' 
    712          IF( sbc_cpl_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'sbc_cpl_alloc : unable to allocate arrays' ) 
    713       ENDIF 
    714  
    715768      !                                         ! =========================== ! 
    716769      !                                         !   Prepare Coupling fields   ! 
     
    730783         CALL cice2nemo(vicen(:,:,jl,:),ht_i(:,:,jl),'T', 1. ) 
    731784      ENDDO 
     785 
     786#if ! defined key_cice4 
     787! Meltpond fraction and depth 
     788      DO jl = 1,ncat 
     789         CALL cice2nemo(apeffn(:,:,jl,:),a_p(:,:,jl),'T', 1. ) 
     790         CALL cice2nemo(trcrn(:,:,nt_hpnd,jl,:),ht_p(:,:,jl),'T', 1. ) 
     791      ENDDO 
     792#endif 
     793 
     794 
     795! If using multilayers thermodynamics in CICE then get top layer temperature 
     796! and effective conductivity        
     797!! When using NEMO with CICE, this change requires use of  
     798!! one of the following two CICE branches: 
     799!! - at CICE5.0,   hadax/r1015_GSI8_with_GSI7 
     800!! - at CICE5.1.2, hadax/vn5.1.2_GSI8 
     801      IF (heat_capacity) THEN 
     802         DO jl = 1,ncat 
     803            CALL cice2nemo(Tn_top(:,:,jl,:),tn_ice(:,:,jl),'T', 1. ) 
     804            CALL cice2nemo(keffn_top(:,:,jl,:),kn_ice(:,:,jl),'T', 1. ) 
     805         ENDDO 
     806! Convert surface temperature to Kelvin 
     807         tn_ice(:,:,:)=tn_ice(:,:,:)+rt0 
     808      ELSE 
     809         tn_ice(:,:,:) = 0.0 
     810         kn_ice(:,:,:) = 0.0 
     811      ENDIF        
     812 
    732813      ! 
    733814      IF( nn_timing == 1 )  CALL timing_stop('cice_sbc_hadgam') 
  • branches/UKMO/dev_r5518_obs_oper_update_icethick/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_if.F90

    r7960 r9987  
    103103                                 ! ( d rho / dt ) / ( d rho / ds )      ( s = 34, t = -1.8 ) 
    104104          
    105          fr_i(:,:) = eos_fzp( sss_m ) * tmask(:,:,1)      ! sea surface freezing temperature [Celcius] 
     105         CALL eos_fzp( sss_m(:,:), fr_i(:,:) )       ! sea surface freezing temperature [Celcius] 
     106         fr_i(:,:) = fr_i(:,:) * tmask(:,:,1) 
    106107 
    107108         IF( ln_cpl )   a_i(:,:,1) = fr_i(:,:)          
  • branches/UKMO/dev_r5518_obs_oper_update_icethick/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_lim.F90

    r7960 r9987  
    110110      INTEGER  ::   jl                 ! dummy loop index 
    111111      REAL(wp), POINTER, DIMENSION(:,:,:)   ::   zalb_os, zalb_cs  ! ice albedo under overcast/clear sky 
    112       REAL(wp), POINTER, DIMENSION(:,:,:)   ::   zalb_ice          ! mean ice albedo (for coupled) 
    113112      REAL(wp), POINTER, DIMENSION(:,:  )   ::   zutau_ice, zvtau_ice  
    114113      !!---------------------------------------------------------------------- 
     
    126125          
    127126         ! masked sea surface freezing temperature [Kelvin] (set to rt0 over land) 
    128          t_bo(:,:) = ( eos_fzp( sss_m ) + rt0 ) * tmask(:,:,1) + rt0 * ( 1._wp - tmask(:,:,1) )   
    129           
     127         CALL eos_fzp( sss_m(:,:) , t_bo(:,:) ) 
     128         t_bo(:,:) = ( t_bo(:,:) + rt0 ) * tmask(:,:,1) + rt0 * ( 1._wp - tmask(:,:,1) ) 
     129           
    130130         ! Mask sea ice surface temperature (set to rt0 over land) 
    131131         DO jl = 1, jpl 
     
    196196         ! fr1_i0  , fr2_i0   : 1sr & 2nd fraction of qsr penetration in ice             [%] 
    197197         !---------------------------------------------------------------------------------------- 
    198          CALL wrk_alloc( jpi,jpj,jpl, zalb_os, zalb_cs, zalb_ice ) 
     198         CALL wrk_alloc( jpi,jpj,jpl, zalb_os, zalb_cs ) 
    199199         CALL albedo_ice( t_su, ht_i, ht_s, zalb_cs, zalb_os ) ! cloud-sky and overcast-sky ice albedos 
    200200 
     
    202202         CASE( jp_clio )                                       ! CLIO bulk formulation 
    203203            ! In CLIO the cloud fraction is read in the climatology and the all-sky albedo  
    204             ! (zalb_ice) is computed within the bulk routine 
    205             CALL blk_ice_clio_flx( t_su, zalb_cs, zalb_os, zalb_ice ) 
    206             IF( ln_mixcpl      ) CALL sbc_cpl_ice_flx( p_frld=pfrld, palbi=zalb_ice, psst=sst_m, pist=t_su ) 
    207             IF( nn_limflx /= 2 ) CALL ice_lim_flx( t_su, zalb_ice, qns_ice, qsr_ice, dqns_ice, evap_ice, devap_ice, nn_limflx ) 
     204            ! (alb_ice) is computed within the bulk routine 
     205                                 CALL blk_ice_clio_flx( t_su, zalb_cs, zalb_os, alb_ice ) 
     206            IF( ln_mixcpl      ) CALL sbc_cpl_ice_flx( p_frld=pfrld, palbi=alb_ice, psst=sst_m, pist=t_su ) 
     207            IF( nn_limflx /= 2 ) CALL ice_lim_flx( t_su, alb_ice, qns_ice, qsr_ice, dqns_ice, evap_ice, devap_ice, nn_limflx ) 
    208208         CASE( jp_core )                                       ! CORE bulk formulation 
    209209            ! albedo depends on cloud fraction because of non-linear spectral effects 
    210             zalb_ice(:,:,:) = ( 1. - cldf_ice ) * zalb_cs(:,:,:) + cldf_ice * zalb_os(:,:,:) 
    211             CALL blk_ice_core_flx( t_su, zalb_ice ) 
    212             IF( ln_mixcpl      ) CALL sbc_cpl_ice_flx( p_frld=pfrld, palbi=zalb_ice, psst=sst_m, pist=t_su ) 
    213             IF( nn_limflx /= 2 ) CALL ice_lim_flx( t_su, zalb_ice, qns_ice, qsr_ice, dqns_ice, evap_ice, devap_ice, nn_limflx ) 
     210            alb_ice(:,:,:) = ( 1. - cldf_ice ) * zalb_cs(:,:,:) + cldf_ice * zalb_os(:,:,:) 
     211                                 CALL blk_ice_core_flx( t_su, alb_ice ) 
     212            IF( ln_mixcpl      ) CALL sbc_cpl_ice_flx( p_frld=pfrld, palbi=alb_ice, psst=sst_m, pist=t_su ) 
     213            IF( nn_limflx /= 2 ) CALL ice_lim_flx( t_su, alb_ice, qns_ice, qsr_ice, dqns_ice, evap_ice, devap_ice, nn_limflx ) 
    214214         CASE ( jp_purecpl ) 
    215215            ! albedo depends on cloud fraction because of non-linear spectral effects 
    216             zalb_ice(:,:,:) = ( 1. - cldf_ice ) * zalb_cs(:,:,:) + cldf_ice * zalb_os(:,:,:) 
    217                                  CALL sbc_cpl_ice_flx( p_frld=pfrld, palbi=zalb_ice, psst=sst_m, pist=t_su ) 
    218             ! clem: evap_ice is forced to 0 in coupled mode for now  
    219             !       but it needs to be changed (along with modif in limthd_dh) once heat flux from evap will be avail. from atm. models 
    220             evap_ice  (:,:,:) = 0._wp   ;   devap_ice (:,:,:) = 0._wp 
    221             IF( nn_limflx == 2 ) CALL ice_lim_flx( t_su, zalb_ice, qns_ice, qsr_ice, dqns_ice, evap_ice, devap_ice, nn_limflx ) 
     216            alb_ice(:,:,:) = ( 1. - cldf_ice ) * zalb_cs(:,:,:) + cldf_ice * zalb_os(:,:,:) 
     217                                 CALL sbc_cpl_ice_flx( p_frld=pfrld, palbi=alb_ice, psst=sst_m, pist=t_su ) 
     218            IF( nn_limflx == 2 ) CALL ice_lim_flx( t_su, alb_ice, qns_ice, qsr_ice, dqns_ice, evap_ice, devap_ice, nn_limflx ) 
    222219         END SELECT 
    223          CALL wrk_dealloc( jpi,jpj,jpl, zalb_os, zalb_cs, zalb_ice ) 
     220         CALL wrk_dealloc( jpi,jpj,jpl, zalb_os, zalb_cs ) 
    224221 
    225222         !----------------------------! 
     
    264261      !!---------------------------------------------------------------------- 
    265262      INTEGER :: ierr 
     263      INTEGER :: ji, jj 
    266264      !!---------------------------------------------------------------------- 
    267265      IF(lwp) WRITE(numout,*) 
     
    320318      tn_ice(:,:,:) = t_su(:,:,:)       ! initialisation of surface temp for coupled simu 
    321319      ! 
     320      DO jj = 1, jpj 
     321         DO ji = 1, jpi 
     322            IF( gphit(ji,jj) > 0._wp ) THEN  ;  rn_amax_2d(ji,jj) = rn_amax_n  ! NH 
     323            ELSE                             ;  rn_amax_2d(ji,jj) = rn_amax_s  ! SH 
     324            ENDIF 
     325        ENDDO 
     326      ENDDO  
     327      ! 
    322328      nstart = numit  + nn_fsbc       
    323329      nitrun = nitend - nit000 + 1  
     
    342348      INTEGER  ::   ios                 ! Local integer output status for namelist read 
    343349      NAMELIST/namicerun/ jpl, nlay_i, nlay_s, cn_icerst_in, cn_icerst_indir, cn_icerst_out, cn_icerst_outdir,  & 
    344          &                ln_limdyn, rn_amax, ln_limdiahsb, ln_limdiaout, ln_icectl, iiceprt, jiceprt   
     350         &                ln_limdyn, rn_amax_n, rn_amax_s, ln_limdiahsb, ln_limdiaout, ln_icectl, iiceprt, jiceprt   
    345351      !!------------------------------------------------------------------- 
    346352      !                     
     
    363369         WRITE(numout,*) '   number of snow layers                                   = ', nlay_s 
    364370         WRITE(numout,*) '   switch for ice dynamics (1) or not (0)      ln_limdyn   = ', ln_limdyn 
    365          WRITE(numout,*) '   maximum ice concentration                               = ', rn_amax  
     371         WRITE(numout,*) '   maximum ice concentration for NH                        = ', rn_amax_n  
     372         WRITE(numout,*) '   maximum ice concentration for SH                        = ', rn_amax_s 
    366373         WRITE(numout,*) '   Diagnose heat/salt budget or not          ln_limdiahsb  = ', ln_limdiahsb 
    367374         WRITE(numout,*) '   Output   heat/salt budget or not          ln_limdiaout  = ', ln_limdiaout 
     
    578585      sfx_bog(:,:) = 0._wp   ;   sfx_dyn(:,:) = 0._wp 
    579586      sfx_bom(:,:) = 0._wp   ;   sfx_sum(:,:) = 0._wp 
    580       sfx_res(:,:) = 0._wp 
     587      sfx_res(:,:) = 0._wp   ;   sfx_sub(:,:) = 0._wp 
    581588       
    582589      wfx_snw(:,:) = 0._wp   ;   wfx_ice(:,:) = 0._wp 
     
    594601      hfx_spr(:,:) = 0._wp   ;   hfx_dif(:,:) = 0._wp  
    595602      hfx_err(:,:) = 0._wp   ;   hfx_err_rem(:,:) = 0._wp 
    596       hfx_err_dif(:,:) = 0._wp   ; 
    597  
     603      hfx_err_dif(:,:) = 0._wp 
     604      wfx_err_sub(:,:) = 0._wp 
     605       
    598606      afx_tot(:,:) = 0._wp   ; 
    599607      afx_dyn(:,:) = 0._wp   ;   afx_thd(:,:) = 0._wp 
  • branches/UKMO/dev_r5518_obs_oper_update_icethick/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_lim_2.F90

    r7960 r9987  
    150150 
    151151         ! ... masked sea surface freezing temperature [Kelvin] (set to rt0 over land) 
    152          tfu(:,:) = eos_fzp( sss_m ) +  rt0  
     152         CALL eos_fzp( sss_m(:,:), tfu(:,:) ) 
     153         tfu(:,:) = tfu(:,:) + rt0 
    153154 
    154155         zsist (:,:,1) = sist (:,:) + rt0 * ( 1. - tmask(:,:,1) ) 
  • branches/UKMO/dev_r5518_obs_oper_update_icethick/NEMOGCM/NEMO/OPA_SRC/SBC/sbcisf.F90

    r7960 r9987  
    2626   USE zdfbfr 
    2727   USE fldread         ! read input field at current time step 
    28  
    29  
     28   USE lib_fortran, ONLY: glob_sum 
    3029 
    3130   IMPLICIT NONE 
     
    5352   REAL(wp)   , PUBLIC, ALLOCATABLE, SAVE, DIMENSION (:,:)     ::  risfLeff               !:effective length (Leff) BG03 nn_isf==2 
    5453   REAL(wp)   , PUBLIC, ALLOCATABLE, SAVE, DIMENSION (:,:)     ::  ttbl, stbl, utbl, vtbl !:top boundary layer variable at T point 
    55 #if defined key_agrif 
    56    ! AGRIF can not handle these arrays as integers. The reason is a mystery but problems avoided by declaring them as reals 
    57    REAL(wp),    PUBLIC, ALLOCATABLE, SAVE, DIMENSION (:,:)     ::  misfkt, misfkb         !:Level of ice shelf base 
    58                                                                                           !: (first wet level and last level include in the tbl) 
    59 #else 
    6054   INTEGER,    PUBLIC, ALLOCATABLE, SAVE, DIMENSION (:,:)     ::  misfkt, misfkb         !:Level of ice shelf base 
    61 #endif 
    6255 
    6356 
     
    9083    INTEGER                      ::   ji, jj, jk, ijkmin, inum, ierror 
    9184    INTEGER                      ::   ikt, ikb   ! top and bottom level of the isf boundary layer 
     85    REAL(wp)                     ::   zgreenland_fwfisf_sum, zantarctica_fwfisf_sum 
    9286    REAL(wp)                     ::   rmin 
    9387    REAL(wp)                     ::   zhk 
    94     CHARACTER(len=256)           ::   cfisf, cvarzisf, cvarhisf   ! name for isf file 
     88    REAL(wp)                     ::   zt_frz, zpress 
     89    CHARACTER(len=256)           ::   cfisf , cvarzisf, cvarhisf   ! name for isf file 
    9590    CHARACTER(LEN=256)           :: cnameis                     ! name of iceshelf file 
    9691    CHARACTER (LEN=32)           :: cvarLeff                    ! variable name for efficient Length scale 
    9792    INTEGER           ::   ios           ! Local integer output status for namelist read 
     93 
     94    REAL(wp), DIMENSION(:,:,:), POINTER :: zfwfisf3d, zqhcisf3d, zqlatisf3d 
     95    REAL(wp), DIMENSION(:,:  ), POINTER :: zqhcisf2d 
    9896      ! 
    9997      !!--------------------------------------------------------------------- 
     
    176174              DO jj = 1, jpj 
    177175                  jk = 2 
    178                   DO WHILE ( jk .LE. mbkt(ji,jj) .AND. fsdepw(ji,jj,jk) < rzisf_tbl(ji,jj) ) ;  jk = jk + 1 ;  END DO 
     176                  DO WHILE ( jk .LE. mbkt(ji,jj) .AND. gdepw_0(ji,jj,jk) < rzisf_tbl(ji,jj) ) ;  jk = jk + 1 ;  END DO 
    179177                  misfkt(ji,jj) = jk-1 
    180178               END DO 
     
    194192         END IF 
    195193          
     194         ! save initial top boundary layer thickness          
    196195         rhisf_tbl_0(:,:) = rhisf_tbl(:,:) 
     196 
     197      END IF 
     198 
     199      !                                            ! ---------------------------------------- ! 
     200      IF( kt /= nit000 ) THEN                      !          Swap of forcing fields          ! 
     201         !                                         ! ---------------------------------------- ! 
     202         fwfisf_b  (:,:  ) = fwfisf  (:,:  )               ! Swap the ocean forcing fields except at nit000 
     203         risf_tsc_b(:,:,:) = risf_tsc(:,:,:)               ! where before fields are set at the end of the routine 
     204         ! 
     205      ENDIF 
     206 
     207      IF( MOD( kt-1, nn_fsbc) == 0 ) THEN 
    197208 
    198209         ! compute bottom level of isf tbl and thickness of tbl below the ice shelf 
     
    205216 
    206217               ! determine the deepest level influenced by the boundary layer 
    207                ! test on tmask useless ????? 
    208218               DO jk = ikt, mbkt(ji,jj) 
    209219                  IF ( (SUM(fse3t_n(ji,jj,ikt:jk-1)) .LT. rhisf_tbl(ji,jj)) .AND. (tmask(ji,jj,jk) == 1) ) ikb = jk 
     
    217227            END DO 
    218228         END DO 
    219           
    220       END IF 
    221  
    222       !                                            ! ---------------------------------------- ! 
    223       IF( kt /= nit000 ) THEN                      !          Swap of forcing fields          ! 
    224          !                                         ! ---------------------------------------- ! 
    225          fwfisf_b  (:,:  ) = fwfisf  (:,:  )               ! Swap the ocean forcing fields except at nit000 
    226          risf_tsc_b(:,:,:) = risf_tsc(:,:,:)               ! where before fields are set at the end of the routine 
    227          ! 
    228       ENDIF 
    229  
    230       IF( MOD( kt-1, nn_fsbc) == 0 ) THEN 
    231  
    232229 
    233230         ! compute salf and heat flux 
     
    256253            CALL fld_read ( kt, nn_fsbc, sf_rnfisf   ) 
    257254            fwfisf(:,:) = - sf_rnfisf(1)%fnow(:,:,1)         ! fresh water flux from the isf (fwfisf <0 mean melting)  
     255 
     256            IF( lk_oasis) THEN 
     257            ! nn_coupled_iceshelf_fluxes uninitialised unless lk_oasis=true 
     258            IF( nn_coupled_iceshelf_fluxes .gt. 0 ) THEN 
     259 
     260              ! Adjust total iceshelf melt rates so that sum of iceberg calving and iceshelf melting in the northern 
     261              ! and southern hemispheres equals rate of increase of mass of greenland and antarctic ice sheets 
     262              ! to preserve total freshwater conservation in coupled models without an active ice sheet model. 
     263  
     264              ! All related global sums must be done bit reproducibly 
     265               zgreenland_fwfisf_sum = glob_sum( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * greenland_icesheet_mask(:,:) ) 
     266 
     267               ! use ABS function because we need to preserve the sign of fwfisf 
     268               WHERE( greenland_icesheet_mask(:,:) == 1.0 )                                                                  & 
     269              &    fwfisf(:,:) = fwfisf(:,:)  * ABS( greenland_icesheet_mass_rate_of_change * (1.0-rn_greenland_calving_fraction) & 
     270              &                           / ( zgreenland_fwfisf_sum + 1.0e-10_wp ) ) 
     271 
     272               ! check 
     273               IF(lwp) WRITE(numout, *) 'Greenland iceshelf melting climatology (kg/s) : ',zgreenland_fwfisf_sum 
     274 
     275               zgreenland_fwfisf_sum = glob_sum( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * greenland_icesheet_mask(:,:) ) 
     276 
     277               IF(lwp) WRITE(numout, *) 'Greenland iceshelf melting adjusted value (kg/s) : ',zgreenland_fwfisf_sum 
     278 
     279               zantarctica_fwfisf_sum = glob_sum( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * antarctica_icesheet_mask(:,:) ) 
     280 
     281               ! use ABS function because we need to preserve the sign of fwfisf 
     282               WHERE( antarctica_icesheet_mask(:,:) == 1.0 ) & 
     283              &    fwfisf(:,:) = fwfisf(:,:)  * ABS( antarctica_icesheet_mass_rate_of_change * (1.0-rn_antarctica_calving_fraction) & 
     284              &                           / ( zantarctica_fwfisf_sum + 1.0e-10_wp ) ) 
     285       
     286               ! check 
     287               IF(lwp) WRITE(numout, *) 'Antarctica iceshelf melting climatology (kg/s) : ',zantarctica_fwfisf_sum 
     288 
     289               zantarctica_fwfisf_sum = glob_sum( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * antarctica_icesheet_mask(:,:) ) 
     290 
     291               IF(lwp) WRITE(numout, *) 'Antarctica iceshelf melting adjusted value (kg/s) : ',zantarctica_fwfisf_sum 
     292 
     293            ENDIF 
     294            ENDIF 
     295 
    258296            qisf(:,:)   = fwfisf(:,:) * lfusisf              ! heat        flux 
    259297            stbl(:,:)   = soce 
     
    264302            !CALL fld_read ( kt, nn_fsbc, sf_qisf   ) 
    265303            fwfisf(:,:) = sf_fwfisf(1)%fnow(:,:,1)            ! fwf 
     304 
     305            IF( lk_oasis) THEN 
     306            ! nn_coupled_iceshelf_fluxes uninitialised unless lk_oasis=true 
     307            IF( nn_coupled_iceshelf_fluxes .gt. 0 ) THEN 
     308 
     309              ! Adjust total iceshelf melt rates so that sum of iceberg calving and iceshelf melting in the northern 
     310              ! and southern hemispheres equals rate of increase of mass of greenland and antarctic ice sheets 
     311              ! to preserve total freshwater conservation in coupled models without an active ice sheet model. 
     312 
     313              ! All related global sums must be done bit reproducibly 
     314               zgreenland_fwfisf_sum = glob_sum( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * greenland_icesheet_mask(:,:) ) 
     315 
     316               ! use ABS function because we need to preserve the sign of fwfisf 
     317               WHERE( greenland_icesheet_mask(:,:) == 1.0 )                                                                  & 
     318              &    fwfisf(:,:) = fwfisf(:,:)  * ABS( greenland_icesheet_mass_rate_of_change * (1.0-rn_greenland_calving_fraction) & 
     319              &                           / ( zgreenland_fwfisf_sum + 1.0e-10_wp ) ) 
     320 
     321               ! check 
     322               IF(lwp) WRITE(numout, *) 'Greenland iceshelf melting climatology (kg/s) : ',zgreenland_fwfisf_sum 
     323 
     324               zgreenland_fwfisf_sum = glob_sum( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * greenland_icesheet_mask(:,:) ) 
     325 
     326               IF(lwp) WRITE(numout, *) 'Greenland iceshelf melting adjusted value (kg/s) : ',zgreenland_fwfisf_sum 
     327 
     328               zantarctica_fwfisf_sum = glob_sum( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * antarctica_icesheet_mask(:,:) ) 
     329 
     330               ! use ABS function because we need to preserve the sign of fwfisf 
     331               WHERE( antarctica_icesheet_mask(:,:) == 1.0 ) & 
     332              &    fwfisf(:,:) = fwfisf(:,:)  * ABS( antarctica_icesheet_mass_rate_of_change * (1.0-rn_antarctica_calving_fraction) & 
     333              &                           / ( zantarctica_fwfisf_sum + 1.0e-10_wp ) ) 
     334       
     335               ! check 
     336               IF(lwp) WRITE(numout, *) 'Antarctica iceshelf melting climatology (kg/s) : ',zantarctica_fwfisf_sum 
     337 
     338               zantarctica_fwfisf_sum = glob_sum( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * antarctica_icesheet_mask(:,:) ) 
     339 
     340               IF(lwp) WRITE(numout, *) 'Antarctica iceshelf melting adjusted value (kg/s) : ',zantarctica_fwfisf_sum 
     341 
     342            ENDIF 
     343            ENDIF 
     344 
    266345            qisf(:,:)   = fwfisf(:,:) * lfusisf              ! heat        flux 
    267346            !qisf(:,:)   = sf_qisf(1)%fnow(:,:,1)              ! heat flux 
     
    270349         END IF 
    271350         ! compute tsc due to isf 
    272          ! WARNING water add at temp = 0C, correction term is added in trasbc, maybe better here but need a 3D variable). 
    273          risf_tsc(:,:,jp_tem) = qisf(:,:) * r1_rau0_rcp ! 
     351         ! WARNING water add at temp = 0C, correction term is added, maybe better here but need a 3D variable). 
     352!         zpress = grav*rau0*fsdept(ji,jj,jk)*1.e-04 
     353         zt_frz = -1.9 !eos_fzp( tsn(ji,jj,jk,jp_sal), zpress ) 
     354         risf_tsc(:,:,jp_tem) = qisf(:,:) * r1_rau0_rcp - rdivisf * fwfisf(:,:) * zt_frz * r1_rau0 ! 
    274355          
    275356         ! salt effect already take into account in vertical advection 
    276357         risf_tsc(:,:,jp_sal) = (1.0_wp-rdivisf) * fwfisf(:,:) * stbl(:,:) * r1_rau0 
    277            
     358 
     359         ! output 
     360         IF( iom_use('qlatisf' ) )   CALL iom_put('qlatisf', qisf) 
     361         IF( iom_use('fwfisf'  ) )   CALL iom_put('fwfisf' , fwfisf * stbl(:,:) / soce ) 
     362 
     363         ! if apply only on the trend and not as a volume flux (rdivisf = 0), fwfisf have to be set to 0 now 
     364         fwfisf(:,:) = rdivisf * fwfisf(:,:)          
     365  
    278366         ! lbclnk 
    279367         CALL lbc_lnk(risf_tsc(:,:,jp_tem),'T',1.) 
     
    281369         CALL lbc_lnk(fwfisf(:,:)   ,'T',1.) 
    282370         CALL lbc_lnk(qisf(:,:)     ,'T',1.) 
     371 
     372!============================================================================================================================================= 
     373         IF ( iom_use('fwfisf3d') .OR. iom_use('qlatisf3d') .OR. iom_use('qhcisf3d') .OR. iom_use('qhcisf')) THEN 
     374            CALL wrk_alloc( jpi,jpj,jpk, zfwfisf3d, zqhcisf3d, zqlatisf3d ) 
     375            CALL wrk_alloc( jpi,jpj,     zqhcisf2d                        ) 
     376 
     377            zfwfisf3d(:,:,:) = 0.0_wp                         ! 3d ice shelf melting (kg/m2/s) 
     378            zqhcisf3d(:,:,:) = 0.0_wp                         ! 3d heat content flux (W/m2) 
     379            zqlatisf3d(:,:,:)= 0.0_wp                         ! 3d ice shelf melting latent heat flux (W/m2) 
     380            zqhcisf2d(:,:)   = fwfisf(:,:) * zt_frz * rcp     ! 2d heat content flux (W/m2) 
     381 
     382            DO jj = 1,jpj 
     383               DO ji = 1,jpi 
     384                  ikt = misfkt(ji,jj) 
     385                  ikb = misfkb(ji,jj) 
     386                  DO jk = ikt, ikb - 1 
     387                     zfwfisf3d (ji,jj,jk) = zfwfisf3d (ji,jj,jk) + fwfisf   (ji,jj) * r1_hisf_tbl(ji,jj) * fse3t(ji,jj,jk) 
     388                     zqhcisf3d (ji,jj,jk) = zqhcisf3d (ji,jj,jk) + zqhcisf2d(ji,jj) * r1_hisf_tbl(ji,jj) * fse3t(ji,jj,jk) 
     389                     zqlatisf3d(ji,jj,jk) = zqlatisf3d(ji,jj,jk) + qisf     (ji,jj) * r1_hisf_tbl(ji,jj) * fse3t(ji,jj,jk) 
     390                  END DO 
     391                  zfwfisf3d (ji,jj,jk) = zfwfisf3d (ji,jj,jk) + fwfisf   (ji,jj) * r1_hisf_tbl(ji,jj) * ralpha(ji,jj) * fse3t(ji,jj,jk) 
     392                  zqhcisf3d (ji,jj,jk) = zqhcisf3d (ji,jj,jk) + zqhcisf2d(ji,jj) * r1_hisf_tbl(ji,jj) * ralpha(ji,jj) * fse3t(ji,jj,jk) 
     393                  zqlatisf3d(ji,jj,jk) = zqlatisf3d(ji,jj,jk) + qisf     (ji,jj) * r1_hisf_tbl(ji,jj) * ralpha(ji,jj) * fse3t(ji,jj,jk) 
     394               END DO 
     395            END DO 
     396 
     397            CALL iom_put('fwfisf3d' , zfwfisf3d (:,:,:)) 
     398            CALL iom_put('qlatisf3d', zqlatisf3d(:,:,:)) 
     399            CALL iom_put('qhcisf3d' , zqhcisf3d (:,:,:)) 
     400            CALL iom_put('qhcisf'   , zqhcisf2d (:,:  )) 
     401 
     402            CALL wrk_dealloc( jpi,jpj,jpk, zfwfisf3d, zqhcisf3d, zqlatisf3d ) 
     403            CALL wrk_dealloc( jpi,jpj,     zqhcisf2d                        ) 
     404         END IF 
     405!============================================================================================================================================= 
    283406 
    284407         IF( kt == nit000 ) THEN                          !   set the forcing field at nit000 - 1    ! 
     
    295418         ENDIF 
    296419         !  
    297          ! output 
    298          CALL iom_put('qisf'  , qisf) 
    299          IF( iom_use('fwfisf') )   CALL iom_put('fwfisf', fwfisf * stbl(:,:) / soce ) 
    300420      END IF 
    301421   
     
    370490             ! Calculate freezing temperature 
    371491                zpress = grav*rau0*fsdept(ji,jj,ik)*1.e-04  
    372                 zt_frz = eos_fzp(tsb(ji,jj,ik,jp_sal), zpress)  
     492                CALL eos_fzp(tsb(ji,jj,ik,jp_sal), zt_frz, zpress)  
    373493                zt_sum = zt_sum + (tsn(ji,jj,ik,jp_tem)-zt_frz) * fse3t(ji,jj,ik) * tmask(ji,jj,ik)  ! sum temp 
    374494             ENDDO 
     
    452572      zti(:,:)=tinsitu( ttbl, stbl, zpress ) 
    453573! Calculate freezing temperature 
    454       zfrz(:,:)=eos_fzp( sss_m(:,:), zpress ) 
     574      CALL eos_fzp( sss_m(:,:), zfrz(:,:), zpress ) 
    455575 
    456576       
     
    472592 
    473593                     nit = nit + 1 
    474                      IF (nit .GE. 100) THEN 
    475                         !WRITE(numout,*) "sbcisf : too many iteration ... ", zhtflx, zhtflx_b,zgammat, rn_gammat0, rn_tfri2, nn_gammablk, ji,jj 
    476                         !WRITE(numout,*) "sbcisf : too many iteration ... ", (zhtflx - zhtflx_b)/zhtflx 
    477                         CALL ctl_stop( 'STOP', 'sbc_isf_hol99 : too many iteration ...' ) 
    478                      END IF 
     594                     IF (nit .GE. 100) CALL ctl_stop( 'STOP', 'sbc_isf_hol99 : too many iteration ...' ) 
     595 
    479596! save gammat and compute zhtflx_b 
    480597                     zgammat2d(ji,jj)=zgammat 
     
    794911               ! test on tmask useless ????? 
    795912               DO jk = ikt, mbkt(ji,jj) 
    796 !                  IF ( (SUM(fse3t(ji,jj,ikt:jk-1)) .LT. rhisf_tbl(ji,jj)) .AND. (tmask(ji,jj,jk) == 1) ) ikb = jk 
     913                  IF ( (SUM(fse3t(ji,jj,ikt:jk-1)) .LT. rhisf_tbl(ji,jj)) .AND. (tmask(ji,jj,jk) == 1) ) ikb = jk 
    797914               END DO 
    798915               rhisf_tbl(ji,jj) = MIN(rhisf_tbl(ji,jj), SUM(fse3t(ji,jj,ikt:ikb)))  ! limit the tbl to water thickness. 
  • branches/UKMO/dev_r5518_obs_oper_update_icethick/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90

    r7960 r9987  
    179179 
    180180      !                          ! Checks: 
    181       IF( nn_isf .EQ. 0 ) THEN                      ! no specific treatment in vicinity of ice shelf  
     181      IF( nn_isf .EQ. 0 ) THEN                      ! variable initialisation if no ice shelf  
    182182         IF( sbc_isf_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'sbc_init : unable to allocate sbc_isf arrays' ) 
    183          fwfisf  (:,:) = 0.0_wp 
    184          fwfisf_b(:,:) = 0.0_wp 
     183         fwfisf  (:,:)   = 0.0_wp ; fwfisf_b  (:,:)   = 0.0_wp 
     184         risf_tsc(:,:,:) = 0.0_wp ; risf_tsc_b(:,:,:) = 0.0_wp 
     185         rdivisf       = 0.0_wp 
    185186      END IF 
    186187      IF( nn_ice == 0 .AND. nn_components /= jp_iam_opa )   fr_i(:,:) = 0.e0 ! no ice in the domain, ice fraction is always zero 
     
    265266      ENDIF 
    266267      ! 
    267       IF( lk_oasis )   CALL sbc_cpl_init (nn_ice)   ! OASIS initialisation. must be done before: (1) first time step 
    268       !                                                     !                                            (2) the use of nn_fsbc 
     268      IF( lk_oasis ) THEN 
     269         IF( sbc_cpl_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'sbc_cpl_alloc : unable to allocate arrays' )          
     270         CALL sbc_cpl_init (nn_ice)   ! OASIS initialisation. must be done before: (1) first time step 
     271                                      !                                            (2) the use of nn_fsbc 
     272      ENDIF 
    269273 
    270274!     nn_fsbc initialization if OPA-SAS coupling via OASIS 
     
    339343         emp_b(:,:) = emp(:,:) 
    340344         sfx_b(:,:) = sfx(:,:) 
     345         IF ( ln_rnf ) THEN 
     346            rnf_b    (:,:  ) = rnf    (:,:  ) 
     347            rnf_tsc_b(:,:,:) = rnf_tsc(:,:,:) 
     348         ENDIF 
    341349      ENDIF 
    342350      !                                            ! ---------------------------------------- ! 
     
    455463      !                                                ! ---------------------------------------- ! 
    456464      IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN 
    457          CALL iom_put( "empmr" , emp  - rnf )                   ! upward water flux 
     465         CALL iom_put( "empmr"  , emp    - rnf )                ! upward water flux 
     466         CALL iom_put( "empbmr" , emp_b  - rnf )                ! before upward water flux ( needed to recalculate the time evolution of ssh in offline ) 
    458467         CALL iom_put( "saltflx", sfx  )                        ! downward salt flux   
    459468                                                                ! (includes virtual salt flux beneath ice  
  • branches/UKMO/dev_r5518_obs_oper_update_icethick/NEMOGCM/NEMO/OPA_SRC/SBC/sbcrnf.F90

    r7960 r9987  
    5252   REAL(wp)                   ::   rn_hrnf         !: runoffs, depth over which enhanced vertical mixing is used 
    5353   REAL(wp)          , PUBLIC ::   rn_avt_rnf      !: runoffs, value of the additional vertical mixing coef. [m2/s] 
    54    REAL(wp)                  ::   rn_rfact        !: multiplicative factor for runoff 
     54   REAL(wp)          , PUBLIC ::   rn_rfact        !: multiplicative factor for runoff 
    5555 
    5656   LOGICAL           , PUBLIC ::   l_rnfcpl = .false.       ! runoffs recieved from oasis 
     
    109109      ! 
    110110      CALL wrk_alloc( jpi,jpj, ztfrz) 
    111  
    112       !                                            ! ---------------------------------------- ! 
    113       IF( kt /= nit000 ) THEN                      !          Swap of forcing fields          ! 
    114          !                                         ! ---------------------------------------- ! 
    115          rnf_b    (:,:  ) = rnf    (:,:  )               ! Swap the ocean forcing fields except at nit000 
    116          rnf_tsc_b(:,:,:) = rnf_tsc(:,:,:)               ! where before fields are set at the end of the routine 
    117          ! 
    118       ENDIF 
    119  
     111      ! 
    120112      !                                            !-------------------! 
    121113      !                                            !   Update runoff   ! 
     
    126118      IF(   ln_rnf_sal   )   CALL fld_read ( kt, nn_fsbc, sf_s_rnf )    ! idem for runoffs salinity    if required 
    127119      ! 
    128       ! Runoff reduction only associated to the ORCA2_LIM configuration 
    129       ! when reading the NetCDF file runoff_1m_nomask.nc 
    130       IF( cp_cfg == 'orca' .AND. jp_cfg == 2 .AND. .NOT. l_rnfcpl )   THEN 
    131          WHERE( 40._wp < gphit(:,:) .AND. gphit(:,:) < 65._wp ) 
    132             sf_rnf(1)%fnow(:,:,1) = 0.85 * sf_rnf(1)%fnow(:,:,1) 
    133          END WHERE 
    134       ENDIF 
    135       ! 
    136120      IF( MOD( kt - 1, nn_fsbc ) == 0 ) THEN 
    137121         ! 
    138122         IF( .NOT. l_rnfcpl )   rnf(:,:) = rn_rfact * ( sf_rnf(1)%fnow(:,:,1) )       ! updated runoff value at time step kt 
     123         CALL lbc_lnk(rnf(:,:), 'T', 1._wp) 
    139124         ! 
    140125         !                                                     ! set temperature & salinity content of runoffs 
  • branches/UKMO/dev_r5518_obs_oper_update_icethick/NEMOGCM/NEMO/OPA_SRC/SBC/updtide.F90

    r7960 r9987  
    3131CONTAINS 
    3232 
    33    SUBROUTINE upd_tide( kt, kit, kbaro, koffset ) 
     33   SUBROUTINE upd_tide( kt, kit, time_offset ) 
    3434      !!---------------------------------------------------------------------- 
    3535      !!                 ***  ROUTINE upd_tide  *** 
     
    4242      !!----------------------------------------------------------------------       
    4343      INTEGER, INTENT(in)           ::   kt      ! ocean time-step index 
    44       INTEGER, INTENT(in), OPTIONAL ::   kit     ! external mode sub-time-step index (lk_dynspg_ts=T only) 
    45       INTEGER, INTENT(in), OPTIONAL ::   kbaro   ! number of sub-time-step           (lk_dynspg_ts=T only) 
    46       INTEGER, INTENT(in), OPTIONAL ::   koffset ! time offset in number  
    47                                                  ! of sub-time-steps                 (lk_dynspg_ts=T only) 
     44      INTEGER, INTENT(in), OPTIONAL ::   kit     ! external mode sub-time-step index (lk_dynspg_ts=T) 
     45      INTEGER, INTENT(in), OPTIONAL ::   time_offset ! time offset in number  
     46                                                     ! of internal steps             (lk_dynspg_ts=F) 
     47                                                     ! of external steps             (lk_dynspg_ts=T) 
    4848      ! 
    4949      INTEGER  ::   joffset      ! local integer 
     
    5757      ! 
    5858      joffset = 0 
    59       IF( PRESENT( koffset ) )   joffset = koffset 
     59      IF( PRESENT( time_offset ) )   joffset = time_offset 
    6060      ! 
    61       IF( PRESENT( kit ) .AND. PRESENT( kbaro ) )   THEN 
    62          zt = zt + ( kit + 0.5_wp * ( joffset - 1 ) ) * rdt / REAL( kbaro, wp ) 
     61      IF( PRESENT( kit ) )   THEN 
     62         zt = zt + ( kit +  joffset - 1 ) * rdt / REAL( nn_baro, wp ) 
    6363      ELSE 
    6464         zt = zt + joffset * rdt 
     
    7474      IF( ln_tide_ramp ) THEN         ! linear increase if asked 
    7575         zt = ( kt - nit000 ) * rdt 
    76          IF( PRESENT( kit ) .AND. PRESENT( kbaro ) )   zt = zt + kit * rdt / REAL( kbaro, wp ) 
     76         IF( PRESENT( kit ) )   zt = zt + ( kit + joffset -1) * rdt / REAL( nn_baro, wp ) 
    7777         zramp = MIN(  MAX( zt / (rdttideramp*rday) , 0._wp ) , 1._wp  ) 
    7878         pot_astro(:,:) = zramp * pot_astro(:,:) 
     
    8686  !!---------------------------------------------------------------------- 
    8787CONTAINS 
    88   SUBROUTINE upd_tide( kt, kit, kbaro, koffset )          ! Empty routine 
     88  SUBROUTINE upd_tide( kt, kit, time_offset )  ! Empty routine 
    8989    INTEGER, INTENT(in)           ::   kt      !  integer  arg, dummy routine 
    9090    INTEGER, INTENT(in), OPTIONAL ::   kit     !  optional arg, dummy routine 
    91     INTEGER, INTENT(in), OPTIONAL ::   kbaro   !  optional arg, dummy routine 
    92     INTEGER, INTENT(in), OPTIONAL ::   koffset !  optional arg, dummy routine 
     91    INTEGER, INTENT(in), OPTIONAL ::   time_offset !  optional arg, dummy routine 
    9392    WRITE(*,*) 'upd_tide: You should not have seen this print! error?', kt 
    9493  END SUBROUTINE upd_tide 
Note: See TracChangeset for help on using the changeset viewer.