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 3193 for branches/2011/dev_NEMO_MERGE_2011/NEMOGCM – NEMO

Ignore:
Timestamp:
2011-12-05T17:31:39+01:00 (12 years ago)
Author:
charris
Message:

Added timing calls in main CICE interface routines and tidied up indentation of lines etc. Also minor change to lib_mpp to allow NEMO-CICE to run without key_nemocice_decomp.

Location:
branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90

    r3186 r3193  
    6464   PUBLIC   mpp_min, mpp_max, mpp_sum, mpp_minloc, mpp_maxloc 
    6565   PUBLIC   mpp_lnk_3d, mpp_lnk_3d_gather, mpp_lnk_2d, mpp_lnk_2d_e 
     66   PUBLIC   mppscatter, mppgather 
    6667   PUBLIC   mppobc, mpp_ini_ice, mpp_ini_znl 
    6768   PUBLIC   mppsize 
  • branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_cice.F90

    r3189 r3193  
    1919   USE lbclnk          ! ocean lateral boundary conditions (or mpp link) 
    2020   USE wrk_nemo        ! work arrays 
     21   USE timing          ! Timing 
    2122   USE daymod          ! calendar 
    2223   USE fldread         ! read input fields 
     
    110111      INTEGER, INTENT(in) ::   nsbc    ! surface forcing type 
    111112      !!---------------------------------------------------------------------- 
    112  
     113      ! 
     114      IF( nn_timing == 1 )  CALL timing_start('sbc_ice_cice') 
     115      ! 
    113116      !                                        !----------------------! 
    114117      IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN     !  Ice time-step only  ! 
     
    129132 
    130133      ENDIF                                          ! End sea-ice time step only 
     134      ! 
     135      IF( nn_timing == 1 )  CALL timing_stop('sbc_ice_cice') 
    131136 
    132137   END SUBROUTINE sbc_ice_cice 
     
    142147      INTEGER  ::   ji, jj, jpl                        ! dummy loop indices 
    143148 
     149      IF( nn_timing == 1 )  CALL timing_start('cice_sbc_init') 
     150      ! 
    144151      IF(lwp) WRITE(numout,*)'cice_sbc_init' 
    145152 
     
    148155 
    149156! Do some CICE consistency checks 
    150      IF ( (nsbc == 2) .OR. (nsbc == 5) ) THEN 
    151         IF ( calc_strair .OR. calc_Tsfc ) THEN 
    152            CALL ctl_stop( 'STOP', 'cice_sbc_init : Forcing option requires calc_strair=F and calc_Tsfc=F in ice_in' ) 
    153         ENDIF 
    154      ELSEIF (nsbc == 4) THEN 
    155         IF ( .NOT. (calc_strair .AND. calc_Tsfc) ) THEN 
    156            CALL ctl_stop( 'STOP', 'cice_sbc_init : Forcing option requires calc_strair=T and calc_Tsfc=T in ice_in' ) 
    157         ENDIF 
    158      ENDIF 
     157      IF ( (nsbc == 2) .OR. (nsbc == 5) ) THEN 
     158         IF ( calc_strair .OR. calc_Tsfc ) THEN 
     159            CALL ctl_stop( 'STOP', 'cice_sbc_init : Forcing option requires calc_strair=F and calc_Tsfc=F in ice_in' ) 
     160         ENDIF 
     161      ELSEIF (nsbc == 4) THEN 
     162         IF ( .NOT. (calc_strair .AND. calc_Tsfc) ) THEN 
     163            CALL ctl_stop( 'STOP', 'cice_sbc_init : Forcing option requires calc_strair=T and calc_Tsfc=T in ice_in' ) 
     164         ENDIF 
     165      ENDIF 
    159166 
    160167 
     
    169176      ENDIF 
    170177 
    171      fr_iu(:,:)=0.0 
    172      fr_iv(:,:)=0.0 
    173  
    174      CALL cice2nemo(aice,fr_i, 'T', 1. ) 
    175      IF ( (nsbc == 2).OR.(nsbc == 5) ) THEN 
    176         DO jpl=1,ncat 
    177            CALL cice2nemo(aicen(:,:,jpl,:),a_i(:,:,jpl), 'T', 1. ) 
    178         ENDDO 
    179      ENDIF 
     178      fr_iu(:,:)=0.0 
     179      fr_iv(:,:)=0.0 
     180 
     181      CALL cice2nemo(aice,fr_i, 'T', 1. ) 
     182      IF ( (nsbc == 2).OR.(nsbc == 5) ) THEN 
     183         DO jpl=1,ncat 
     184            CALL cice2nemo(aicen(:,:,jpl,:),a_i(:,:,jpl), 'T', 1. ) 
     185         ENDDO 
     186      ENDIF 
    180187 
    181188! T point to U point 
    182189! T point to V point 
    183      DO jj=1,jpjm1 
    184         DO ji=1,jpim1 
    185            fr_iu(ji,jj)=0.5*(fr_i(ji,jj)+fr_i(ji+1,jj))*umask(ji,jj,1) 
    186            fr_iv(ji,jj)=0.5*(fr_i(ji,jj)+fr_i(ji,jj+1))*vmask(ji,jj,1) 
    187         ENDDO 
    188      ENDDO 
    189  
    190      CALL lbc_lnk ( fr_iu , 'U', 1. ) 
    191      CALL lbc_lnk ( fr_iv , 'V', 1. ) 
    192  
     190      DO jj=1,jpjm1 
     191         DO ji=1,jpim1 
     192            fr_iu(ji,jj)=0.5*(fr_i(ji,jj)+fr_i(ji+1,jj))*umask(ji,jj,1) 
     193            fr_iv(ji,jj)=0.5*(fr_i(ji,jj)+fr_i(ji,jj+1))*vmask(ji,jj,1) 
     194         ENDDO 
     195      ENDDO 
     196 
     197      CALL lbc_lnk ( fr_iu , 'U', 1. ) 
     198      CALL lbc_lnk ( fr_iv , 'V', 1. ) 
     199      ! 
     200      IF( nn_timing == 1 )  CALL timing_stop('cice_sbc_init') 
     201      ! 
    193202   END SUBROUTINE cice_sbc_init 
    194203 
     
    207216      !!--------------------------------------------------------------------- 
    208217 
     218      IF( nn_timing == 1 )  CALL timing_start('cice_sbc_in') 
     219      ! 
    209220      CALL wrk_alloc( jpi,jpj, ztmp ) 
    210221      CALL wrk_alloc( jpi,jpj,ncat, ztmpn ) 
    211222 
    212      IF( kt == nit000 )  THEN 
     223      IF( kt == nit000 )  THEN 
    213224         IF(lwp) WRITE(numout,*)'cice_sbc_in' 
    214      ENDIF 
    215  
    216      ztmp(:,:)=0.0 
     225      ENDIF 
     226 
     227      ztmp(:,:)=0.0 
    217228 
    218229! Aggregate ice concentration already set in cice_sbc_out (or cice_sbc_init on  
     
    221232! forced and coupled case  
    222233 
    223      IF ( (nsbc == 2).OR.(nsbc == 5) ) THEN 
    224  
    225      ztmpn(:,:,:)=0.0 
     234      IF ( (nsbc == 2).OR.(nsbc == 5) ) THEN 
     235 
     236         ztmpn(:,:,:)=0.0 
    226237 
    227238! x comp of wind stress (CI_1) 
    228239! U point to F point 
    229      DO jj=1,jpjm1 
    230         DO ji=1,jpi 
    231            ztmp(ji,jj)=0.5*(fr_iu(ji,jj)*utau(ji,jj)      & 
    232                               +fr_iu(ji,jj+1)*utau(ji,jj+1))*fmask(ji,jj,1) 
    233         ENDDO 
    234      ENDDO 
    235      CALL nemo2cice(ztmp,strax,'F', -1. ) 
     240         DO jj=1,jpjm1 
     241            DO ji=1,jpi 
     242               ztmp(ji,jj) = 0.5 * (  fr_iu(ji,jj) * utau(ji,jj)      & 
     243                                    + fr_iu(ji,jj+1) * utau(ji,jj+1) ) * fmask(ji,jj,1) 
     244            ENDDO 
     245         ENDDO 
     246         CALL nemo2cice(ztmp,strax,'F', -1. ) 
    236247 
    237248! y comp of wind stress (CI_2) 
    238249! V point to F point 
    239      DO jj=1,jpj 
    240         DO ji=1,jpim1 
    241            ztmp(ji,jj)=0.5*(fr_iv(ji,jj)*vtau(ji,jj)      & 
    242                               +fr_iv(ji+1,jj)*vtau(ji+1,jj))*fmask(ji,jj,1) 
    243         ENDDO 
    244      ENDDO 
    245      CALL nemo2cice(ztmp,stray,'F', -1. ) 
     250         DO jj=1,jpj 
     251            DO ji=1,jpim1 
     252               ztmp(ji,jj) = 0.5 * (  fr_iv(ji,jj) * vtau(ji,jj)      & 
     253                                    + fr_iv(ji+1,jj) * vtau(ji+1,jj) ) * fmask(ji,jj,1) 
     254            ENDDO 
     255         ENDDO 
     256         CALL nemo2cice(ztmp,stray,'F', -1. ) 
    246257 
    247258! Surface downward latent heat flux (CI_5) 
    248     IF (nsbc == 2) THEN 
    249         DO jpl=1,ncat 
    250            ztmpn(:,:,jpl)=qla_ice(:,:,1)*a_i(:,:,jpl) 
    251         ENDDO 
    252      ELSE 
     259         IF (nsbc == 2) THEN 
     260            DO jpl=1,ncat 
     261               ztmpn(:,:,jpl)=qla_ice(:,:,1)*a_i(:,:,jpl) 
     262            ENDDO 
     263         ELSE 
    253264! emp_ice is set in sbc_cpl_ice_flx as sublimation-snow 
    254         qla_ice(:,:,1)= - ( emp_ice(:,:)+sprecip(:,:) ) * Lsub 
     265            qla_ice(:,:,1)= - ( emp_ice(:,:)+sprecip(:,:) ) * Lsub 
    255266! End of temporary code 
    256         DO jj=1,jpj 
    257            DO ji=1,jpi 
    258               IF (fr_i(ji,jj).eq.0.0) THEN 
    259                  DO jpl=1,ncat 
    260                     ztmpn(ji,jj,jpl)=0.0 
    261                  ENDDO 
    262                  ! This will then be conserved in CICE 
    263                  ztmpn(ji,jj,1)=qla_ice(ji,jj,1) 
    264               ELSE 
    265                  DO jpl=1,ncat 
    266                     ztmpn(ji,jj,jpl)=qla_ice(ji,jj,1)*a_i(ji,jj,jpl)/fr_i(ji,jj) 
    267                  ENDDO 
    268               ENDIF 
    269            ENDDO 
    270         ENDDO 
    271      ENDIF 
    272      DO jpl=1,ncat 
    273         CALL nemo2cice(ztmpn(:,:,jpl),flatn_f(:,:,jpl,:),'T', 1. ) 
     267            DO jj=1,jpj 
     268               DO ji=1,jpi 
     269                  IF (fr_i(ji,jj).eq.0.0) THEN 
     270                     DO jpl=1,ncat 
     271                        ztmpn(ji,jj,jpl)=0.0 
     272                     ENDDO 
     273                     ! This will then be conserved in CICE 
     274                     ztmpn(ji,jj,1)=qla_ice(ji,jj,1) 
     275                  ELSE 
     276                     DO jpl=1,ncat 
     277                        ztmpn(ji,jj,jpl)=qla_ice(ji,jj,1)*a_i(ji,jj,jpl)/fr_i(ji,jj) 
     278                     ENDDO 
     279                  ENDIF 
     280               ENDDO 
     281            ENDDO 
     282         ENDIF 
     283         DO jpl=1,ncat 
     284            CALL nemo2cice(ztmpn(:,:,jpl),flatn_f(:,:,jpl,:),'T', 1. ) 
    274285 
    275286! GBM conductive flux through ice (CI_6) 
    276287!  Convert to GBM 
    277         IF (nsbc == 2) THEN 
    278            ztmp(:,:) = botmelt(:,:,jpl)*a_i(:,:,jpl) 
    279         ELSE 
    280            ztmp(:,:) = botmelt(:,:,jpl) 
    281         ENDIF 
    282         CALL nemo2cice(ztmp,fcondtopn_f(:,:,jpl,:),'T', 1. ) 
     288            IF (nsbc == 2) THEN 
     289               ztmp(:,:) = botmelt(:,:,jpl)*a_i(:,:,jpl) 
     290            ELSE 
     291               ztmp(:,:) = botmelt(:,:,jpl) 
     292            ENDIF 
     293            CALL nemo2cice(ztmp,fcondtopn_f(:,:,jpl,:),'T', 1. ) 
    283294 
    284295! GBM surface heat flux (CI_7) 
    285296!  Convert to GBM 
    286         IF (nsbc == 2) THEN 
    287            ztmp(:,:) = (topmelt(:,:,jpl)+botmelt(:,:,jpl))*a_i(:,:,jpl)  
    288         ELSE 
    289            ztmp(:,:) = (topmelt(:,:,jpl)+botmelt(:,:,jpl)) 
    290         ENDIF 
    291         CALL nemo2cice(ztmp,fsurfn_f(:,:,jpl,:),'T', 1. ) 
    292      ENDDO 
    293  
    294      ELSE IF (nsbc == 4) THEN 
     297            IF (nsbc == 2) THEN 
     298               ztmp(:,:) = (topmelt(:,:,jpl)+botmelt(:,:,jpl))*a_i(:,:,jpl)  
     299            ELSE 
     300               ztmp(:,:) = (topmelt(:,:,jpl)+botmelt(:,:,jpl)) 
     301            ENDIF 
     302            CALL nemo2cice(ztmp,fsurfn_f(:,:,jpl,:),'T', 1. ) 
     303         ENDDO 
     304 
     305      ELSE IF (nsbc == 4) THEN 
    295306 
    296307! Pass CORE forcing fields to CICE (which will calculate heat fluxes etc itself) 
    297308! x comp and y comp of atmosphere surface wind (CICE expects on T points) 
    298         ztmp(:,:) = wndi_ice(:,:) 
    299         CALL nemo2cice(ztmp,uatm,'T', -1. ) 
    300         ztmp(:,:) = wndj_ice(:,:) 
    301         CALL nemo2cice(ztmp,vatm,'T', -1. ) 
    302         ztmp(:,:) = SQRT ( wndi_ice(:,:)**2 + wndj_ice(:,:)**2 ) 
    303         CALL nemo2cice(ztmp,wind,'T', 1. )        ! Wind speed (m/s) 
    304         ztmp(:,:) = qsr_ice(:,:,1) 
    305         CALL nemo2cice(ztmp,fsw,'T', 1. )      ! Incoming short-wave (W/m^2) 
    306         ztmp(:,:) = qlw_ice(:,:,1) 
    307         CALL nemo2cice(ztmp,flw,'T', 1. )      ! Incoming long-wave (W/m^2) 
    308         ztmp(:,:) = tatm_ice(:,:) 
    309         CALL nemo2cice(ztmp,Tair,'T', 1. )    ! Air temperature (K) 
    310         CALL nemo2cice(ztmp,potT,'T', 1. )    ! Potential temp (K) 
     309         ztmp(:,:) = wndi_ice(:,:) 
     310         CALL nemo2cice(ztmp,uatm,'T', -1. ) 
     311         ztmp(:,:) = wndj_ice(:,:) 
     312         CALL nemo2cice(ztmp,vatm,'T', -1. ) 
     313         ztmp(:,:) = SQRT ( wndi_ice(:,:)**2 + wndj_ice(:,:)**2 ) 
     314         CALL nemo2cice(ztmp,wind,'T', 1. )    ! Wind speed (m/s) 
     315         ztmp(:,:) = qsr_ice(:,:,1) 
     316         CALL nemo2cice(ztmp,fsw,'T', 1. )     ! Incoming short-wave (W/m^2) 
     317         ztmp(:,:) = qlw_ice(:,:,1) 
     318         CALL nemo2cice(ztmp,flw,'T', 1. )     ! Incoming long-wave (W/m^2) 
     319         ztmp(:,:) = tatm_ice(:,:) 
     320         CALL nemo2cice(ztmp,Tair,'T', 1. )    ! Air temperature (K) 
     321         CALL nemo2cice(ztmp,potT,'T', 1. )    ! Potential temp (K) 
    311322! Following line uses MAX(....) to avoid problems if tatm_ice has unset halo rows   
    312         ztmp(:,:) = 101000. / ( 287.04 * MAX(1.0,tatm_ice(:,:)) )     
    313                                                   ! Constant (101000.) atm pressure assumed 
    314         CALL nemo2cice(ztmp,rhoa,'T', 1. )        ! Air density (kg/m^3) 
    315         ztmp(:,:) = qatm_ice(:,:) 
    316         CALL nemo2cice(ztmp,Qa,'T', 1. )      ! Specific humidity (kg/kg) 
    317         ztmp(:,:)=10.0 
    318         CALL nemo2cice(ztmp,zlvl,'T', 1. )        ! Atmos level height (m) 
     323         ztmp(:,:) = 101000. / ( 287.04 * MAX(1.0,tatm_ice(:,:)) )     
     324                                               ! Constant (101000.) atm pressure assumed 
     325         CALL nemo2cice(ztmp,rhoa,'T', 1. )    ! Air density (kg/m^3) 
     326         ztmp(:,:) = qatm_ice(:,:) 
     327         CALL nemo2cice(ztmp,Qa,'T', 1. )      ! Specific humidity (kg/kg) 
     328         ztmp(:,:)=10.0 
     329         CALL nemo2cice(ztmp,zlvl,'T', 1. )    ! Atmos level height (m) 
    319330 
    320331! May want to check all values are physically realistic (as in CICE routine  
     
    322333 
    323334! Divide shortwave into spectral bands (as in prepare_forcing) 
    324          ztmp(:,:)=qsr_ice(:,:,1)*frcvdr                ! visible direct 
     335         ztmp(:,:)=qsr_ice(:,:,1)*frcvdr       ! visible direct 
    325336         CALL nemo2cice(ztmp,swvdr,'T', 1. )              
    326          ztmp(:,:)=qsr_ice(:,:,1)*frcvdf                ! visible diffuse 
     337         ztmp(:,:)=qsr_ice(:,:,1)*frcvdf       ! visible diffuse 
    327338         CALL nemo2cice(ztmp,swvdf,'T', 1. )               
    328          ztmp(:,:)=qsr_ice(:,:,1)*frcidr                ! near IR direct 
     339         ztmp(:,:)=qsr_ice(:,:,1)*frcidr       ! near IR direct 
    329340         CALL nemo2cice(ztmp,swidr,'T', 1. ) 
    330          ztmp(:,:)=qsr_ice(:,:,1)*frcidf                ! near IR diffuse 
     341         ztmp(:,:)=qsr_ice(:,:,1)*frcidf       ! near IR diffuse 
    331342         CALL nemo2cice(ztmp,swidf,'T', 1. ) 
    332343 
     
    335346! Snowfall 
    336347! Ensure fsnow is positive (as in CICE routine prepare_forcing)   
    337      ztmp(:,:)=MAX(fr_i(:,:)*sprecip(:,:),0.0)   
    338      CALL nemo2cice(ztmp,fsnow,'T', 1. )  
     348      ztmp(:,:)=MAX(fr_i(:,:)*sprecip(:,:),0.0)   
     349      CALL nemo2cice(ztmp,fsnow,'T', 1. )  
    339350 
    340351! Rainfall 
    341      ztmp(:,:)=fr_i(:,:)*(tprecip(:,:)-sprecip(:,:)) 
    342      CALL nemo2cice(ztmp,frain,'T', 1. )  
     352      ztmp(:,:)=fr_i(:,:)*(tprecip(:,:)-sprecip(:,:)) 
     353      CALL nemo2cice(ztmp,frain,'T', 1. )  
    343354 
    344355! Freezing/melting potential 
     
    347358! May be better using sst_m if not coupling to CICE every time-step 
    348359 
    349 !     nfrzmlt(:,:)=rau0*rcp*fse3t(:,:,1)*(Tocnfrz-sst_m(:,:))/(2.0*dt) 
    350      nfrzmlt(:,:)=rau0*rcp*fse3t(:,:,1)*(Tocnfrz-tsb(:,:,1,jp_tem))/(2.0*dt) 
    351  
    352      ztmp(:,:) = nfrzmlt(:,:) 
    353      CALL nemo2cice(ztmp,frzmlt,'T', 1. ) 
     360!      nfrzmlt(:,:)=rau0*rcp*fse3t(:,:,1)*(Tocnfrz-sst_m(:,:))/(2.0*dt) 
     361      nfrzmlt(:,:)=rau0*rcp*fse3t(:,:,1)*(Tocnfrz-tsb(:,:,1,jp_tem))/(2.0*dt) 
     362 
     363      ztmp(:,:) = nfrzmlt(:,:) 
     364      CALL nemo2cice(ztmp,frzmlt,'T', 1. ) 
    354365 
    355366! SST  and SSS 
    356367 
    357      CALL nemo2cice(sst_m,sst,'T', 1. ) 
    358      CALL nemo2cice(sss_m,sss,'T', 1. ) 
     368      CALL nemo2cice(sst_m,sst,'T', 1. ) 
     369      CALL nemo2cice(sss_m,sss,'T', 1. ) 
    359370 
    360371! x comp and y comp of surface ocean current 
    361372! U point to F point 
    362      DO jj=1,jpjm1 
    363         DO ji=1,jpi 
    364            ztmp(ji,jj)=0.5*(ssu_m(ji,jj)+ssu_m(ji,jj+1))*fmask(ji,jj,1) 
    365         ENDDO 
    366      ENDDO 
    367      CALL nemo2cice(ztmp,uocn,'F', -1. ) 
     373      DO jj=1,jpjm1 
     374         DO ji=1,jpi 
     375            ztmp(ji,jj)=0.5*(ssu_m(ji,jj)+ssu_m(ji,jj+1))*fmask(ji,jj,1) 
     376         ENDDO 
     377      ENDDO 
     378      CALL nemo2cice(ztmp,uocn,'F', -1. ) 
    368379 
    369380! V point to F point 
    370      DO jj=1,jpj 
    371         DO ji=1,jpim1 
    372            ztmp(ji,jj)=0.5*(ssv_m(ji,jj)+ssv_m(ji+1,jj))*fmask(ji,jj,1) 
    373         ENDDO 
    374      ENDDO 
    375      CALL nemo2cice(ztmp,vocn,'F', -1. ) 
     381      DO jj=1,jpj 
     382         DO ji=1,jpim1 
     383            ztmp(ji,jj)=0.5*(ssv_m(ji,jj)+ssv_m(ji+1,jj))*fmask(ji,jj,1) 
     384         ENDDO 
     385      ENDDO 
     386      CALL nemo2cice(ztmp,vocn,'F', -1. ) 
    376387 
    377388! x comp and y comp of sea surface slope (on F points) 
    378389! T point to F point 
    379      DO jj=1,jpjm1 
    380         DO ji=1,jpim1 
    381            ztmp(ji,jj)=0.5 * (  (ssh_m(ji+1,jj  )-ssh_m(ji,jj  ))/e1u(ji,jj  )   & 
    382                               + (ssh_m(ji+1,jj+1)-ssh_m(ji,jj+1))/e1u(ji,jj+1) ) &  
    383                            *  fmask(ji,jj,1) 
    384         ENDDO 
    385      ENDDO 
    386      CALL nemo2cice(ztmp,ss_tltx,'F', -1. ) 
     390      DO jj=1,jpjm1 
     391         DO ji=1,jpim1 
     392            ztmp(ji,jj)=0.5 * (  (ssh_m(ji+1,jj  )-ssh_m(ji,jj  ))/e1u(ji,jj  )   & 
     393                               + (ssh_m(ji+1,jj+1)-ssh_m(ji,jj+1))/e1u(ji,jj+1) ) &  
     394                            *  fmask(ji,jj,1) 
     395         ENDDO 
     396      ENDDO 
     397      CALL nemo2cice(ztmp,ss_tltx,'F', -1. ) 
    387398 
    388399! T point to F point 
    389      DO jj=1,jpjm1 
    390         DO ji=1,jpim1 
    391            ztmp(ji,jj)=0.5 * (  (ssh_m(ji  ,jj+1)-ssh_m(ji  ,jj))/e2v(ji  ,jj)   & 
    392                               + (ssh_m(ji+1,jj+1)-ssh_m(ji+1,jj))/e2v(ji+1,jj) ) & 
    393                            *  fmask(ji,jj,1) 
    394         ENDDO 
    395      ENDDO 
    396      CALL nemo2cice(ztmp,ss_tlty,'F', -1. ) 
     400      DO jj=1,jpjm1 
     401         DO ji=1,jpim1 
     402            ztmp(ji,jj)=0.5 * (  (ssh_m(ji  ,jj+1)-ssh_m(ji  ,jj))/e2v(ji  ,jj)   & 
     403                               + (ssh_m(ji+1,jj+1)-ssh_m(ji+1,jj))/e2v(ji+1,jj) ) & 
     404                            *  fmask(ji,jj,1) 
     405         ENDDO 
     406      ENDDO 
     407      CALL nemo2cice(ztmp,ss_tlty,'F', -1. ) 
    397408 
    398409      CALL wrk_dealloc( jpi,jpj, ztmp ) 
    399410      CALL wrk_dealloc( jpi,jpj,ncat, ztmpn ) 
    400      ! 
     411      ! 
     412      IF( nn_timing == 1 )  CALL timing_stop('cice_sbc_in') 
     413      ! 
    401414   END SUBROUTINE cice_sbc_in 
    402415 
     
    414427      !!--------------------------------------------------------------------- 
    415428 
     429      IF( nn_timing == 1 )  CALL timing_start('cice_sbc_out') 
     430      ! 
    416431      CALL wrk_alloc( jpi,jpj, ztmp ) 
    417432       
     
    421436       
    422437! x comp of ocean-ice stress  
    423      CALL cice2nemo(strocnx,ztmp,'F', -1. ) 
    424      ss_iou(:,:)=0.0 
     438      CALL cice2nemo(strocnx,ztmp,'F', -1. ) 
     439      ss_iou(:,:)=0.0 
    425440! F point to U point 
    426      DO jj=2,jpjm1 
    427         DO ji=2,jpim1 
    428            ss_iou(ji,jj)=0.5*( ztmp(ji,jj-1) + ztmp(ji,jj) ) * umask(ji,jj,1) 
    429         ENDDO 
    430      ENDDO 
    431      CALL lbc_lnk( ss_iou , 'U', -1. ) 
     441      DO jj=2,jpjm1 
     442         DO ji=2,jpim1 
     443            ss_iou(ji,jj) = 0.5 * ( ztmp(ji,jj-1) + ztmp(ji,jj) ) * umask(ji,jj,1) 
     444         ENDDO 
     445      ENDDO 
     446      CALL lbc_lnk( ss_iou , 'U', -1. ) 
    432447 
    433448! y comp of ocean-ice stress  
    434      CALL cice2nemo(strocny,ztmp,'F', -1. ) 
    435      ss_iov(:,:)=0.0 
     449      CALL cice2nemo(strocny,ztmp,'F', -1. ) 
     450      ss_iov(:,:)=0.0 
    436451! F point to V point 
    437452 
    438      DO jj=1,jpjm1 
    439         DO ji=2,jpim1 
    440            ss_iov(ji,jj)=0.5*( ztmp(ji-1,jj) + ztmp(ji,jj) ) * vmask(ji,jj,1) 
    441         ENDDO 
    442      ENDDO 
    443      CALL lbc_lnk( ss_iov , 'V', -1. ) 
     453      DO jj=1,jpjm1 
     454         DO ji=2,jpim1 
     455            ss_iov(ji,jj) = 0.5 * ( ztmp(ji-1,jj) + ztmp(ji,jj) ) * vmask(ji,jj,1) 
     456         ENDDO 
     457      ENDDO 
     458      CALL lbc_lnk( ss_iov , 'V', -1. ) 
    444459 
    445460! x and y comps of surface stress 
     
    447462! [Note that fr_iu hasn't yet been updated, so still from start of CICE timestep] 
    448463 
    449      utau(:,:)=(1.0-fr_iu(:,:))*utau(:,:)-ss_iou(:,:) 
    450      vtau(:,:)=(1.0-fr_iv(:,:))*vtau(:,:)-ss_iov(:,:)      
     464      utau(:,:)=(1.0-fr_iu(:,:))*utau(:,:)-ss_iou(:,:) 
     465      vtau(:,:)=(1.0-fr_iv(:,:))*vtau(:,:)-ss_iov(:,:)      
    451466 
    452467! Freshwater fluxes  
    453468 
    454      IF (nsbc == 2) THEN 
     469      IF (nsbc == 2) THEN 
    455470! Note that emp from the forcing files is evap*(1-aice)-(tprecip-aice*sprecip) 
    456471! What we want here is evap*(1-aice)-tprecip*(1-aice) hence manipulation below 
    457472! Not ideal since aice won't be the same as in the atmosphere.   
    458473! Better to use evap and tprecip? (but for now don't read in evap in this case) 
    459         emp(:,:)  = emp(:,:)+fr_i(:,:)*(tprecip(:,:)-sprecip(:,:)) 
    460      ELSE IF (nsbc == 4) THEN 
    461         emp(:,:)  = (1.0-fr_i(:,:))*emp(:,:)         
    462      ELSE IF (nsbc ==5) THEN 
     474         emp(:,:)  = emp(:,:)+fr_i(:,:)*(tprecip(:,:)-sprecip(:,:)) 
     475      ELSE IF (nsbc == 4) THEN 
     476         emp(:,:)  = (1.0-fr_i(:,:))*emp(:,:)         
     477      ELSE IF (nsbc ==5) THEN 
    463478! emp_tot is set in sbc_cpl_ice_flx (call from cice_sbc_in above)  
    464         emp(:,:) = emp_tot(:,:)+tprecip(:,:)*fr_i(:,:)  
    465      ENDIF 
     479         emp(:,:) = emp_tot(:,:)+tprecip(:,:)*fr_i(:,:)  
     480      ENDIF 
    466481 
    467482! Subtract fluxes from CICE to get freshwater equivalent flux used in  
    468483! salinity calculation 
    469      CALL cice2nemo(fresh_gbm,ztmp,'T', 1. ) 
    470      emps(:,:)=emp(:,:)-ztmp(:,:) 
     484      CALL cice2nemo(fresh_gbm,ztmp,'T', 1. ) 
     485      emps(:,:)=emp(:,:)-ztmp(:,:) 
    471486! Note the 1000.0 is to convert from kg salt to g salt (needed for PSU) 
    472      CALL cice2nemo(fsalt_gbm,ztmp,'T', 1. ) 
    473      DO jj=1,jpj 
    474         DO ji=1,jpi 
    475            IF (sss_m(ji,jj).gt.0.0) THEN 
    476            emps(ji,jj)=emps(ji,jj)+ztmp(ji,jj)*1000.0/sss_m(ji,jj) 
    477            ENDIF 
    478         ENDDO 
    479      ENDDO 
     487      CALL cice2nemo(fsalt_gbm,ztmp,'T', 1. ) 
     488      DO jj=1,jpj 
     489         DO ji=1,jpi 
     490            IF (sss_m(ji,jj).gt.0.0) THEN 
     491               emps(ji,jj)=emps(ji,jj)+ztmp(ji,jj)*1000.0/sss_m(ji,jj) 
     492            ENDIF 
     493         ENDDO 
     494      ENDDO 
    480495 
    481496! No longer remove precip over ice from free surface calculation on basis that the 
     
    487502! ocean rather than floating on top 
    488503 
    489      emp(:,:)  = emp(:,:) - tprecip(:,:)*fr_i(:,:) 
     504      emp(:,:)  = emp(:,:) - tprecip(:,:)*fr_i(:,:) 
    490505 
    491506! Take sublimation into account 
    492      IF (nsbc == 5 ) THEN  
    493         emp(:,:) = emp(:,:) + ( emp_ice(:,:) + sprecip(:,:) ) 
    494      ELSE IF (nsbc == 2 ) THEN 
    495         emp(:,:) = emp(:,:) - qla_ice(:,:,1) / Lsub 
    496      ENDIF 
    497  
    498      CALL lbc_lnk( emp , 'T', 1. ) 
    499      CALL lbc_lnk( emps , 'T', 1. ) 
     507      IF (nsbc == 5 ) THEN  
     508         emp(:,:) = emp(:,:) + ( emp_ice(:,:) + sprecip(:,:) ) 
     509      ELSE IF (nsbc == 2 ) THEN 
     510         emp(:,:) = emp(:,:) - qla_ice(:,:,1) / Lsub 
     511      ENDIF 
     512 
     513      CALL lbc_lnk( emp , 'T', 1. ) 
     514      CALL lbc_lnk( emps , 'T', 1. ) 
    500515 
    501516! Solar penetrative radiation and non solar surface heat flux 
     
    503518! Scale qsr and qns according to ice fraction (bulk formulae only) 
    504519 
    505      IF (nsbc == 4) THEN 
    506         qsr(:,:)=qsr(:,:)*(1.0-fr_i(:,:)) 
    507         qns(:,:)=qns(:,:)*(1.0-fr_i(:,:)) 
    508      ENDIF 
     520      IF (nsbc == 4) THEN 
     521         qsr(:,:)=qsr(:,:)*(1.0-fr_i(:,:)) 
     522         qns(:,:)=qns(:,:)*(1.0-fr_i(:,:)) 
     523      ENDIF 
    509524! Take into account snow melting except for fully coupled when already in qns_tot 
    510      IF (nsbc == 5) THEN 
    511         qsr(:,:)= qsr_tot(:,:) 
    512         qns(:,:)= qns_tot(:,:) 
    513      ELSE 
    514         qns(:,:)= qns(:,:)-sprecip(:,:)*Lfresh*(1.0-fr_i(:,:)) 
    515      ENDIF 
     525      IF (nsbc == 5) THEN 
     526         qsr(:,:)= qsr_tot(:,:) 
     527         qns(:,:)= qns_tot(:,:) 
     528      ELSE 
     529         qns(:,:)= qns(:,:)-sprecip(:,:)*Lfresh*(1.0-fr_i(:,:)) 
     530      ENDIF 
    516531 
    517532! Now add in ice / snow related terms 
    518533! [fswthru will be zero unless running with calc_Tsfc=T in CICE] 
    519      CALL cice2nemo(fswthru_gbm,ztmp,'T', 1. ) 
    520      qsr(:,:)=qsr(:,:)+ztmp(:,:) 
    521      CALL lbc_lnk( qsr , 'T', 1. ) 
    522  
    523      DO jj=1,jpj 
    524         DO ji=1,jpi 
     534      CALL cice2nemo(fswthru_gbm,ztmp,'T', 1. ) 
     535      qsr(:,:)=qsr(:,:)+ztmp(:,:) 
     536      CALL lbc_lnk( qsr , 'T', 1. ) 
     537 
     538      DO jj=1,jpj 
     539         DO ji=1,jpi 
    525540            nfrzmlt(ji,jj)=MAX(nfrzmlt(ji,jj),0.0) 
    526         ENDDO 
    527      ENDDO 
    528  
    529      CALL cice2nemo(fhocn_gbm,ztmp,'T', 1. ) 
    530      qns(:,:)=qns(:,:)+nfrzmlt(:,:)+ztmp(:,:) 
    531  
    532      CALL lbc_lnk( qns , 'T', 1. ) 
     541         ENDDO 
     542      ENDDO 
     543 
     544      CALL cice2nemo(fhocn_gbm,ztmp,'T', 1. ) 
     545      qns(:,:)=qns(:,:)+nfrzmlt(:,:)+ztmp(:,:) 
     546 
     547      CALL lbc_lnk( qns , 'T', 1. ) 
    533548 
    534549! Prepare for the following CICE time-step 
    535550 
    536      CALL cice2nemo(aice,fr_i,'T', 1. ) 
    537      IF ( (nsbc == 2).OR.(nsbc == 5) ) THEN 
    538         DO jpl=1,ncat 
    539            CALL cice2nemo(aicen(:,:,jpl,:),a_i(:,:,jpl), 'T', 1. ) 
    540         ENDDO 
    541      ENDIF 
     551      CALL cice2nemo(aice,fr_i,'T', 1. ) 
     552      IF ( (nsbc == 2).OR.(nsbc == 5) ) THEN 
     553         DO jpl=1,ncat 
     554            CALL cice2nemo(aicen(:,:,jpl,:),a_i(:,:,jpl), 'T', 1. ) 
     555         ENDDO 
     556      ENDIF 
    542557 
    543558! T point to U point 
    544559! T point to V point 
    545      DO jj=1,jpjm1 
    546         DO ji=1,jpim1 
    547            fr_iu(ji,jj)=0.5*(fr_i(ji,jj)+fr_i(ji+1,jj))*umask(ji,jj,1) 
    548            fr_iv(ji,jj)=0.5*(fr_i(ji,jj)+fr_i(ji,jj+1))*vmask(ji,jj,1) 
    549         ENDDO 
    550      ENDDO 
    551  
    552      CALL lbc_lnk ( fr_iu , 'U', 1. ) 
    553      CALL lbc_lnk ( fr_iv , 'V', 1. ) 
     560      DO jj=1,jpjm1 
     561         DO ji=1,jpim1 
     562            fr_iu(ji,jj)=0.5*(fr_i(ji,jj)+fr_i(ji+1,jj))*umask(ji,jj,1) 
     563            fr_iv(ji,jj)=0.5*(fr_i(ji,jj)+fr_i(ji,jj+1))*vmask(ji,jj,1) 
     564         ENDDO 
     565      ENDDO 
     566 
     567      CALL lbc_lnk ( fr_iu , 'U', 1. ) 
     568      CALL lbc_lnk ( fr_iv , 'V', 1. ) 
    554569 
    555570! Release work space 
    556571 
    557572      CALL wrk_dealloc( jpi,jpj, ztmp ) 
    558      ! 
     573      ! 
     574      IF( nn_timing == 1 )  CALL timing_stop('cice_sbc_out') 
     575      ! 
    559576   END SUBROUTINE cice_sbc_out 
    560577 
     
    570587      !!--------------------------------------------------------------------- 
    571588 
    572      INTEGER  ::   jpl                        ! dummy loop index 
    573      INTEGER  ::   ierror 
    574  
    575      IF( kt == nit000 )  THEN 
     589      INTEGER  ::   jpl                        ! dummy loop index 
     590      INTEGER  ::   ierror 
     591 
     592      IF( nn_timing == 1 )  CALL timing_start('cice_sbc_hadgam') 
     593      ! 
     594      IF( kt == nit000 )  THEN 
    576595         IF(lwp) WRITE(numout,*)'cice_sbc_hadgam' 
    577596         IF( sbc_cpl_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'sbc_cpl_alloc : unable to allocate arrays' ) 
    578      ENDIF 
     597      ENDIF 
    579598 
    580599      !                                         ! =========================== ! 
     
    584603! x and y comp of ice velocity 
    585604 
    586         CALL cice2nemo(uvel,u_ice,'F', -1. ) 
    587         CALL cice2nemo(vvel,v_ice,'F', -1. ) 
     605      CALL cice2nemo(uvel,u_ice,'F', -1. ) 
     606      CALL cice2nemo(vvel,v_ice,'F', -1. ) 
    588607 
    589608! Ice concentration (CO_1) = a_i calculated at end of cice_sbc_out   
     
    591610! Snow and ice thicknesses (CO_2 and CO_3) 
    592611 
    593      DO jpl = 1,ncat 
    594         CALL cice2nemo(vsnon(:,:,jpl,:),ht_s(:,:,jpl),'T', 1. ) 
    595         CALL cice2nemo(vicen(:,:,jpl,:),ht_i(:,:,jpl),'T', 1. ) 
    596      ENDDO 
    597  
     612      DO jpl = 1,ncat 
     613         CALL cice2nemo(vsnon(:,:,jpl,:),ht_s(:,:,jpl),'T', 1. ) 
     614         CALL cice2nemo(vicen(:,:,jpl,:),ht_i(:,:,jpl),'T', 1. ) 
     615      ENDDO 
     616      ! 
     617      IF( nn_timing == 1 )  CALL timing_stop('cice_sbc_hadgam') 
     618      ! 
    598619   END SUBROUTINE cice_sbc_hadgam 
    599620 
     
    613634      IF(lwp) WRITE(numout,*)'cice_sbc_final' 
    614635 
    615       call CICE_Finalize 
     636      CALL CICE_Finalize 
    616637 
    617638   END SUBROUTINE cice_sbc_final 
     
    750771      !!--------------------------------------------------------------------- 
    751772 
    752      CHARACTER(len=1), INTENT( in ) ::   & 
    753          cd_type       ! nature of pn grid-point 
    754          !             !   = T or F gridpoints 
    755      REAL(wp), INTENT( in ) ::   & 
    756          psgn          ! control of the sign change 
    757          !             !   =-1 , the sign is modified following the type of b.c. used 
    758          !             !   = 1 , no sign change 
    759      REAL(wp), DIMENSION(jpi,jpj) :: pn 
     773      CHARACTER(len=1), INTENT( in ) ::   & 
     774          cd_type       ! nature of pn grid-point 
     775          !             !   = T or F gridpoints 
     776      REAL(wp), INTENT( in ) ::   & 
     777          psgn          ! control of the sign change 
     778          !             !   =-1 , the sign is modified following the type of b.c. used 
     779          !             !   = 1 , no sign change 
     780      REAL(wp), DIMENSION(jpi,jpj) :: pn 
    760781#if !defined key_nemocice_decomp 
    761      REAL (kind=dbl_kind), dimension(nx_global,ny_global) :: pcg 
     782      REAL (kind=dbl_kind), dimension(nx_global,ny_global) :: pcg 
    762783#endif 
    763      REAL (kind=dbl_kind), dimension(nx_block,ny_block,max_blocks) :: pc 
    764      INTEGER (int_kind) :: & 
    765         field_type,        &! id for type of field (scalar, vector, angle) 
    766         grid_loc            ! id for location on horizontal grid 
     784      REAL (kind=dbl_kind), dimension(nx_block,ny_block,max_blocks) :: pc 
     785      INTEGER (int_kind) :: & 
     786         field_type,        &! id for type of field (scalar, vector, angle) 
     787         grid_loc            ! id for location on horizontal grid 
    767788                            !  (center, NEcorner, Nface, Eface) 
    768789 
    769      INTEGER  ::   ji, jj, jn                      ! dummy loop indices 
    770  
    771 !    A. Ensure all haloes are filled in NEMO field (pn) 
    772  
    773      CALL lbc_lnk( pn , cd_type, psgn ) 
     790      INTEGER  ::   ji, jj, jn                      ! dummy loop indices 
     791 
     792!     A. Ensure all haloes are filled in NEMO field (pn) 
     793 
     794      CALL lbc_lnk( pn , cd_type, psgn ) 
    774795 
    775796#if defined key_nemocice_decomp 
    776797 
    777      ! Copy local domain data from NEMO to CICE field 
    778      pc(:,:,1)=0.0 
    779      DO jj=2,ny_block 
    780         DO ji=2,nx_block 
    781            pc(ji,jj,1)=pn(ji,jj-1) 
    782         ENDDO 
    783      ENDDO 
     798      ! Copy local domain data from NEMO to CICE field 
     799      pc(:,:,1)=0.0 
     800      DO jj=2,ny_block 
     801         DO ji=2,nx_block 
     802            pc(ji,jj,1)=pn(ji,jj-1) 
     803         ENDDO 
     804      ENDDO 
    784805 
    785806#else 
    786807 
    787 !    B. Gather pn into global array (png) 
    788  
    789      IF ( jpnij > 1) THEN 
    790         CALL mppsync 
    791         CALL mppgather (pn,0,png)  
    792         CALL mppsync 
    793      ELSE 
    794         png(:,:,1)=pn(:,:) 
    795      ENDIF 
    796  
    797 !    C. Map png into CICE global array (pcg) 
     808!     B. Gather pn into global array (png) 
     809 
     810      IF ( jpnij > 1) THEN 
     811         CALL mppsync 
     812         CALL mppgather (pn,0,png)  
     813         CALL mppsync 
     814      ELSE 
     815         png(:,:,1)=pn(:,:) 
     816      ENDIF 
     817 
     818!     C. Map png into CICE global array (pcg) 
    798819 
    799820! Need to make sure this is robust to changes in NEMO halo rows.... 
    800821! (may be OK but not 100% sure) 
    801822 
    802      IF (nproc==0) THEN      
     823      IF (nproc==0) THEN      
    803824!        pcg(:,:)=0.0 
    804         DO jn=1,jpnij 
    805            DO jj=1,nlcjt(jn)-1 
    806               DO ji=2,nlcit(jn)-1 
    807                  pcg(ji+nimppt(jn)-2,jj+njmppt(jn)-1)=png(ji,jj,jn)        
    808               ENDDO 
    809            ENDDO 
    810         ENDDO 
    811      ENDIF 
     825         DO jn=1,jpnij 
     826            DO jj=1,nlcjt(jn)-1 
     827               DO ji=2,nlcit(jn)-1 
     828                  pcg(ji+nimppt(jn)-2,jj+njmppt(jn)-1)=png(ji,jj,jn)        
     829               ENDDO 
     830            ENDDO 
     831         ENDDO 
     832      ENDIF 
    812833 
    813834#endif 
    814835 
    815      SELECT CASE ( cd_type ) 
    816         CASE ( 'T' ) 
    817            grid_loc=field_loc_center 
    818         CASE ( 'F' )                               
    819            grid_loc=field_loc_NEcorner 
    820      END SELECT 
    821  
    822      SELECT CASE ( NINT(psgn) ) 
    823         CASE ( -1 ) 
    824            field_type=field_type_vector 
    825         CASE ( 1 )                               
    826            field_type=field_type_scalar 
    827      END SELECT 
     836      SELECT CASE ( cd_type ) 
     837         CASE ( 'T' ) 
     838            grid_loc=field_loc_center 
     839         CASE ( 'F' )                               
     840            grid_loc=field_loc_NEcorner 
     841      END SELECT 
     842 
     843      SELECT CASE ( NINT(psgn) ) 
     844         CASE ( -1 ) 
     845            field_type=field_type_vector 
     846         CASE ( 1 )                               
     847            field_type=field_type_scalar 
     848      END SELECT 
    828849 
    829850#if defined key_nemocice_decomp 
    830      ! Ensure CICE halos are up to date 
    831      call ice_HaloUpdate (pc, halo_info, grid_loc, field_type) 
     851      ! Ensure CICE halos are up to date 
     852      CALL ice_HaloUpdate (pc, halo_info, grid_loc, field_type) 
    832853#else 
    833 !    D. Scatter pcg to CICE blocks (pc) + update halos 
    834      call scatter_global(pc, pcg, 0, distrb_info, grid_loc, field_type) 
     854!     D. Scatter pcg to CICE blocks (pc) + update halos 
     855      CALL scatter_global(pc, pcg, 0, distrb_info, grid_loc, field_type) 
    835856#endif 
    836857 
     
    856877      !!--------------------------------------------------------------------- 
    857878 
    858      CHARACTER(len=1), INTENT( in ) ::   & 
    859          cd_type       ! nature of pn grid-point 
    860          !             !   = T or F gridpoints 
    861      REAL(wp), INTENT( in ) ::   & 
    862          psgn          ! control of the sign change 
    863          !             !   =-1 , the sign is modified following the type of b.c. used 
    864          !             !   = 1 , no sign change 
    865      REAL(wp), DIMENSION(jpi,jpj) :: pn 
     879      CHARACTER(len=1), INTENT( in ) ::   & 
     880          cd_type       ! nature of pn grid-point 
     881          !             !   = T or F gridpoints 
     882      REAL(wp), INTENT( in ) ::   & 
     883          psgn          ! control of the sign change 
     884          !             !   =-1 , the sign is modified following the type of b.c. used 
     885          !             !   = 1 , no sign change 
     886      REAL(wp), DIMENSION(jpi,jpj) :: pn 
    866887 
    867888#if defined key_nemocice_decomp 
    868      INTEGER (int_kind) :: & 
    869         field_type,        & ! id for type of field (scalar, vector, angle) 
    870         grid_loc             ! id for location on horizontal grid 
    871                              ! (center, NEcorner, Nface, Eface) 
     889      INTEGER (int_kind) :: & 
     890         field_type,        & ! id for type of field (scalar, vector, angle) 
     891         grid_loc             ! id for location on horizontal grid 
     892                              ! (center, NEcorner, Nface, Eface) 
    872893#else 
    873      REAL (kind=dbl_kind), dimension(nx_global,ny_global) :: pcg 
     894      REAL (kind=dbl_kind), dimension(nx_global,ny_global) :: pcg 
    874895#endif 
    875896 
    876      REAL (kind=dbl_kind), dimension(nx_block,ny_block,max_blocks) :: pc 
    877  
    878      INTEGER  ::   ji, jj, jn                      ! dummy loop indices 
     897      REAL (kind=dbl_kind), dimension(nx_block,ny_block,max_blocks) :: pc 
     898 
     899      INTEGER  ::   ji, jj, jn                      ! dummy loop indices 
    879900 
    880901 
    881902#if defined key_nemocice_decomp 
    882903 
    883      SELECT CASE ( cd_type ) 
    884         CASE ( 'T' ) 
    885            grid_loc=field_loc_center 
    886         CASE ( 'F' )                               
    887            grid_loc=field_loc_NEcorner 
    888      END SELECT 
    889  
    890      SELECT CASE ( NINT(psgn) ) 
    891         CASE ( -1 ) 
    892            field_type=field_type_vector 
    893         CASE ( 1 )                               
    894            field_type=field_type_scalar 
    895      END SELECT 
    896  
    897      call ice_HaloUpdate (pc, halo_info, grid_loc, field_type) 
    898  
    899  
    900      pn(:,:)=0.0 
    901      DO jj=1,jpjm1 
    902         DO ji=1,jpim1 
    903            pn(ji,jj)=pc(ji,jj+1,1) 
    904         ENDDO 
    905      ENDDO 
     904      SELECT CASE ( cd_type ) 
     905         CASE ( 'T' ) 
     906            grid_loc=field_loc_center 
     907         CASE ( 'F' )                               
     908            grid_loc=field_loc_NEcorner 
     909      END SELECT 
     910 
     911      SELECT CASE ( NINT(psgn) ) 
     912         CASE ( -1 ) 
     913            field_type=field_type_vector 
     914         CASE ( 1 )                               
     915            field_type=field_type_scalar 
     916      END SELECT 
     917 
     918      CALL ice_HaloUpdate (pc, halo_info, grid_loc, field_type) 
     919 
     920 
     921      pn(:,:)=0.0 
     922      DO jj=1,jpjm1 
     923         DO ji=1,jpim1 
     924            pn(ji,jj)=pc(ji,jj+1,1) 
     925         ENDDO 
     926      ENDDO 
    906927 
    907928#else 
    908929 
    909 !     A. Gather CICE blocks (pc) into global array (pcg)  
    910  
    911      call gather_global(pcg, pc, 0, distrb_info) 
     930!      A. Gather CICE blocks (pc) into global array (pcg)  
     931 
     932      CALL gather_global(pcg, pc, 0, distrb_info) 
    912933 
    913934!     B. Map pcg into NEMO global array (png) 
     
    916937! (may be OK but not spent much time thinking about it) 
    917938 
    918      IF (nproc==0) THEN 
    919         png(:,:,:)=0.0 
    920         DO jn=1,jpnij 
    921            DO jj=1,nlcjt(jn)-1 
    922               DO ji=2,nlcit(jn)-1 
    923                  png(ji,jj,jn)=pcg(ji+nimppt(jn)-2,jj+njmppt(jn)-1)       
    924               ENDDO 
    925            ENDDO 
    926         ENDDO 
    927      ENDIF 
    928  
    929 !    C. Scatter png into NEMO field (pn) for each processor 
    930  
    931      IF ( jpnij > 1) THEN 
    932         CALL mppsync 
    933         CALL mppscatter (png,0,pn)  
    934         CALL mppsync 
    935      ELSE 
    936         pn(:,:)=png(:,:,1) 
    937      ENDIF 
     939      IF (nproc==0) THEN 
     940         png(:,:,:)=0.0 
     941         DO jn=1,jpnij 
     942            DO jj=1,nlcjt(jn)-1 
     943               DO ji=2,nlcit(jn)-1 
     944                  png(ji,jj,jn)=pcg(ji+nimppt(jn)-2,jj+njmppt(jn)-1)       
     945               ENDDO 
     946            ENDDO 
     947         ENDDO 
     948      ENDIF 
     949 
     950!     C. Scatter png into NEMO field (pn) for each processor 
     951 
     952      IF ( jpnij > 1) THEN 
     953         CALL mppsync 
     954         CALL mppscatter (png,0,pn)  
     955         CALL mppsync 
     956      ELSE 
     957         pn(:,:)=png(:,:,1) 
     958      ENDIF 
    938959 
    939960#endif 
    940961 
    941 !    D. Ensure all haloes are filled in pn 
    942  
    943      CALL lbc_lnk( pn , cd_type, psgn ) 
     962!     D. Ensure all haloes are filled in pn 
     963 
     964      CALL lbc_lnk( pn , cd_type, psgn ) 
    944965 
    945966   END SUBROUTINE cice2nemo 
Note: See TracChangeset for help on using the changeset viewer.