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.
sbcice_cice.F90 in branches/2014/dev_r4650_UKMO13_CICE_changes_take2/NEMOGCM/NEMO/OPA_SRC/SBC – NEMO

source: branches/2014/dev_r4650_UKMO13_CICE_changes_take2/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_cice.F90 @ 4748

Last change on this file since 4748 was 4748, checked in by timgraham, 10 years ago

Added key_cice5 to select use of CICE5 model. This is used so that the correct variable names are used in the CICE5 version
Modified all references to key_cice to an "or" so that they will be triggered by the key_cice5 key as well (assuming the code sections don't require chanegs for CICE5).

File size: 39.0 KB
Line 
1MODULE sbcice_cice
2   !!======================================================================
3   !!                       ***  MODULE  sbcice_cice  ***
4   !! To couple with sea ice model CICE (LANL)
5   !!=====================================================================
6#if defined key_cice || defined key_cice5
7   !!----------------------------------------------------------------------
8   !!   'key_cice' :                                     CICE sea-ice model
9   !!----------------------------------------------------------------------
10   !!   sbc_ice_cice  : sea-ice model time-stepping and update ocean sbc over ice-covered area
11   !!   
12   !!   
13   !!----------------------------------------------------------------------
14   USE oce             ! ocean dynamics and tracers
15   USE dom_oce         ! ocean space and time domain
16   USE domvvl
17   USE phycst, only : rcp, rau0, r1_rau0, rhosn, rhoic
18   USE in_out_manager  ! I/O manager
19   USE lib_mpp         ! distributed memory computing library
20   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
21   USE wrk_nemo        ! work arrays
22   USE timing          ! Timing
23   USE daymod          ! calendar
24   USE fldread         ! read input fields
25   USE sbc_oce         ! Surface boundary condition: ocean fields
26   USE sbc_ice         ! Surface boundary condition: ice   fields
27   USE sbcblk_core     ! Surface boundary condition: CORE bulk
28   USE sbccpl
29
30   USE ice_kinds_mod
31   USE ice_blocks
32   USE ice_domain
33   USE ice_domain_size
34   USE ice_boundary
35   USE ice_constants
36   USE ice_gather_scatter
37   USE ice_calendar, only: dt
38   USE ice_state, only: aice,aicen,uvel,vvel,vsno,vsnon,vice,vicen
39# if defined key_cice5
40   USE ice_flux, only: strax,stray,strocnx,strocny,frain,fsnow,  &
41                sst,sss,uocn,vocn,ss_tltx,ss_tlty,fsalt_ai,     &
42                fresh_ai,fhocn_ai,fswthru_ai,frzmlt,          &
43                flatn_f,fsurfn_f,fcondtopn_f,                    &
44                uatm,vatm,wind,fsw,flw,Tair,potT,Qa,rhoa,zlvl,   &
45                swvdr,swvdf,swidr,swidf
46   USE ice_therm_shared, only: calc_Tsfc
47#else
48   USE ice_flux, only: strax,stray,strocnx,strocny,frain,fsnow,  &
49                sst,sss,uocn,vocn,ss_tltx,ss_tlty,fsalt_gbm,     &
50                fresh_gbm,fhocn_gbm,fswthru_gbm,frzmlt,          &
51                flatn_f,fsurfn_f,fcondtopn_f,                    &
52                uatm,vatm,wind,fsw,flw,Tair,potT,Qa,rhoa,zlvl,   &
53                swvdr,swvdf,swidr,swidf
54   USE ice_therm_vertical, only: calc_Tsfc
55#endif
56   USE ice_forcing, only: frcvdr,frcvdf,frcidr,frcidf
57   USE ice_atmo, only: calc_strair
58
59   USE CICE_InitMod
60   USE CICE_RunMod
61   USE CICE_FinalMod
62
63   IMPLICIT NONE
64   PRIVATE
65
66   !! * Routine accessibility
67   PUBLIC cice_sbc_init   ! routine called by sbc_init
68   PUBLIC cice_sbc_final  ! routine called by sbc_final
69   PUBLIC sbc_ice_cice    ! routine called by sbc
70
71   INTEGER             ::   ji_off
72   INTEGER             ::   jj_off
73
74   INTEGER , PARAMETER ::   jpfld   = 13   ! maximum number of files to read
75   INTEGER , PARAMETER ::   jp_snow = 1    ! index of snow file
76   INTEGER , PARAMETER ::   jp_rain = 2    ! index of rain file
77   INTEGER , PARAMETER ::   jp_sblm = 3    ! index of sublimation file
78   INTEGER , PARAMETER ::   jp_top1 = 4    ! index of category 1 topmelt file
79   INTEGER , PARAMETER ::   jp_top2 = 5    ! index of category 2 topmelt file
80   INTEGER , PARAMETER ::   jp_top3 = 6    ! index of category 3 topmelt file
81   INTEGER , PARAMETER ::   jp_top4 = 7    ! index of category 4 topmelt file
82   INTEGER , PARAMETER ::   jp_top5 = 8    ! index of category 5 topmelt file
83   INTEGER , PARAMETER ::   jp_bot1 = 9    ! index of category 1 botmelt file
84   INTEGER , PARAMETER ::   jp_bot2 = 10   ! index of category 2 botmelt file
85   INTEGER , PARAMETER ::   jp_bot3 = 11   ! index of category 3 botmelt file
86   INTEGER , PARAMETER ::   jp_bot4 = 12   ! index of category 4 botmelt file
87   INTEGER , PARAMETER ::   jp_bot5 = 13   ! index of category 5 botmelt file
88   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf    ! structure of input fields (file informations, fields read)
89
90   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:), PRIVATE ::   png     ! local array used in sbc_cice_ice
91
92   !! * Substitutions
93#  include "domzgr_substitute.h90"
94
95CONTAINS
96
97   INTEGER FUNCTION sbc_ice_cice_alloc()
98      !!----------------------------------------------------------------------
99      !!                ***  FUNCTION sbc_ice_cice_alloc  ***
100      !!----------------------------------------------------------------------
101      ALLOCATE( png(jpi,jpj,jpnij), STAT=sbc_ice_cice_alloc )
102      IF( lk_mpp                 )   CALL mpp_sum ( sbc_ice_cice_alloc )
103      IF( sbc_ice_cice_alloc > 0 )   CALL ctl_warn('sbc_ice_cice_alloc: allocation of arrays failed.')
104   END FUNCTION sbc_ice_cice_alloc
105
106   SUBROUTINE sbc_ice_cice( kt, nsbc )
107      !!---------------------------------------------------------------------
108      !!                  ***  ROUTINE sbc_ice_cice  ***
109      !!                   
110      !! ** Purpose :   update the ocean surface boundary condition via the
111      !!                CICE Sea Ice Model time stepping
112      !!
113      !! ** Method  : - Get any extra forcing fields for CICE 
114      !!              - Prepare forcing fields
115      !!              - CICE model time stepping
116      !!              - call the routine that computes mass and
117      !!                heat fluxes at the ice/ocean interface
118      !!
119      !! ** Action  : - time evolution of the CICE sea-ice model
120      !!              - update all sbc variables below sea-ice:
121      !!                utau, vtau, qns , qsr, emp , sfx
122      !!---------------------------------------------------------------------
123      INTEGER, INTENT(in) ::   kt      ! ocean time step
124      INTEGER, INTENT(in) ::   nsbc    ! surface forcing type
125      !!----------------------------------------------------------------------
126      !
127      IF( nn_timing == 1 )  CALL timing_start('sbc_ice_cice')
128      !
129      !                                        !----------------------!
130      IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN     !  Ice time-step only  !
131         !                                     !----------------------!
132
133         ! Make sure any fluxes required for CICE are set
134         IF ( nsbc == 2 )  THEN
135            CALL cice_sbc_force(kt)
136         ELSE IF ( nsbc == 5 ) THEN
137            CALL sbc_cpl_ice_flx( 1.0-fr_i  )
138         ENDIF
139
140         CALL cice_sbc_in ( kt, nsbc )
141         CALL CICE_Run
142         CALL cice_sbc_out ( kt, nsbc )
143
144         IF ( nsbc == 5 )  CALL cice_sbc_hadgam(kt+1)
145
146      ENDIF                                          ! End sea-ice time step only
147      !
148      IF( nn_timing == 1 )  CALL timing_stop('sbc_ice_cice')
149
150   END SUBROUTINE sbc_ice_cice
151
152   SUBROUTINE cice_sbc_init (nsbc)
153      !!---------------------------------------------------------------------
154      !!                    ***  ROUTINE cice_sbc_init  ***
155      !! ** Purpose: Initialise ice related fields for NEMO and coupling
156      !!
157      INTEGER, INTENT( in  ) ::   nsbc                ! surface forcing type
158      REAL(wp), DIMENSION(:,:), POINTER :: ztmp1, ztmp2
159      REAL(wp) ::   zcoefu, zcoefv, zcoeff            ! local scalar
160      INTEGER  ::   ji, jj, jl                        ! dummy loop indices
161      !!---------------------------------------------------------------------
162
163      IF( nn_timing == 1 )  CALL timing_start('cice_sbc_init')
164      !
165      CALL wrk_alloc( jpi,jpj, ztmp1, ztmp2 )
166      !
167      IF(lwp) WRITE(numout,*)'cice_sbc_init'
168
169      ji_off = INT ( (jpiglo - nx_global) / 2 )
170      jj_off = INT ( (jpjglo - ny_global) / 2 )
171
172! Initialize CICE
173      CALL CICE_Initialize
174
175! Do some CICE consistency checks
176      IF ( (nsbc == 2) .OR. (nsbc == 5) ) THEN
177         IF ( calc_strair .OR. calc_Tsfc ) THEN
178            CALL ctl_stop( 'STOP', 'cice_sbc_init : Forcing option requires calc_strair=F and calc_Tsfc=F in ice_in' )
179         ENDIF
180      ELSEIF (nsbc == 4) THEN
181         IF ( .NOT. (calc_strair .AND. calc_Tsfc) ) THEN
182            CALL ctl_stop( 'STOP', 'cice_sbc_init : Forcing option requires calc_strair=T and calc_Tsfc=T in ice_in' )
183         ENDIF
184      ENDIF
185
186
187! allocate sbc_ice and sbc_cice arrays
188      IF( sbc_ice_alloc()      /= 0 )   CALL ctl_stop( 'STOP', 'sbc_ice_cice_alloc : unable to allocate arrays' )
189      IF( sbc_ice_cice_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'sbc_ice_cice_alloc : unable to allocate cice arrays' )
190
191! Ensure ocean temperatures are nowhere below freezing if not a NEMO restart
192      IF( .NOT. ln_rstart ) THEN
193         tsn(:,:,:,jp_tem) = MAX (tsn(:,:,:,jp_tem),Tocnfrz)
194         tsb(:,:,:,jp_tem) = tsn(:,:,:,jp_tem)
195      ENDIF
196
197      fr_iu(:,:)=0.0
198      fr_iv(:,:)=0.0
199
200      CALL cice2nemo(aice,fr_i, 'T', 1. )
201      IF ( (nsbc == 2).OR.(nsbc == 5) ) THEN
202         DO jl=1,ncat
203            CALL cice2nemo(aicen(:,:,jl,:),a_i(:,:,jl), 'T', 1. )
204         ENDDO
205      ENDIF
206
207! T point to U point
208! T point to V point
209      DO jj=1,jpjm1
210         DO ji=1,jpim1
211            fr_iu(ji,jj)=0.5*(fr_i(ji,jj)+fr_i(ji+1,jj))*umask(ji,jj,1)
212            fr_iv(ji,jj)=0.5*(fr_i(ji,jj)+fr_i(ji,jj+1))*vmask(ji,jj,1)
213         ENDDO
214      ENDDO
215
216      CALL lbc_lnk ( fr_iu , 'U', 1. )
217      CALL lbc_lnk ( fr_iv , 'V', 1. )
218
219      !                                      ! embedded sea ice
220      IF( nn_ice_embd /= 0 ) THEN            ! mass exchanges between ice and ocean (case 1 or 2) set the snow+ice mass
221         CALL cice2nemo(vsno(:,:,:),ztmp1,'T', 1. )
222         CALL cice2nemo(vice(:,:,:),ztmp2,'T', 1. )
223         snwice_mass  (:,:) = ( rhosn * ztmp1(:,:) + rhoic * ztmp2(:,:)  )
224         snwice_mass_b(:,:) = snwice_mass(:,:)
225      ELSE
226         snwice_mass  (:,:) = 0.0_wp         ! no mass exchanges
227         snwice_mass_b(:,:) = 0.0_wp         ! no mass exchanges
228      ENDIF
229      IF( nn_ice_embd == 2 .AND.          &  ! full embedment (case 2) & no restart :
230         &   .NOT.ln_rstart ) THEN           ! deplete the initial ssh belew sea-ice area
231         sshn(:,:) = sshn(:,:) - snwice_mass(:,:) * r1_rau0
232         sshb(:,:) = sshb(:,:) - snwice_mass(:,:) * r1_rau0
233         !
234      ENDIF
235 
236      CALL wrk_dealloc( jpi,jpj, ztmp1, ztmp2 )
237      !
238      IF( nn_timing == 1 )  CALL timing_stop('cice_sbc_init')
239      !
240   END SUBROUTINE cice_sbc_init
241
242   
243   SUBROUTINE cice_sbc_in (kt, nsbc)
244      !!---------------------------------------------------------------------
245      !!                    ***  ROUTINE cice_sbc_in  ***
246      !! ** Purpose: Set coupling fields and pass to CICE
247      !!---------------------------------------------------------------------
248      INTEGER, INTENT(in   ) ::   kt   ! ocean time step
249      INTEGER, INTENT(in   ) ::   nsbc ! surface forcing type
250
251      INTEGER  ::   ji, jj, jl                   ! dummy loop indices     
252      REAL(wp), DIMENSION(:,:), POINTER :: ztmp, zpice
253      REAL(wp), DIMENSION(:,:,:), POINTER :: ztmpn
254      REAL(wp) ::   zintb, zintn  ! dummy argument
255      !!---------------------------------------------------------------------
256
257      IF( nn_timing == 1 )  CALL timing_start('cice_sbc_in')
258      !
259      CALL wrk_alloc( jpi,jpj, ztmp, zpice )
260      CALL wrk_alloc( jpi,jpj,ncat, ztmpn )
261
262      IF( kt == nit000 )  THEN
263         IF(lwp) WRITE(numout,*)'cice_sbc_in'
264      ENDIF
265
266      ztmp(:,:)=0.0
267
268! Aggregate ice concentration already set in cice_sbc_out (or cice_sbc_init on
269! the first time-step)
270
271! forced and coupled case
272
273      IF ( (nsbc == 2).OR.(nsbc == 5) ) THEN
274
275         ztmpn(:,:,:)=0.0
276
277! x comp of wind stress (CI_1)
278! U point to F point
279         DO jj=1,jpjm1
280            DO ji=1,jpi
281               ztmp(ji,jj) = 0.5 * (  fr_iu(ji,jj) * utau(ji,jj)      &
282                                    + fr_iu(ji,jj+1) * utau(ji,jj+1) ) * fmask(ji,jj,1)
283            ENDDO
284         ENDDO
285         CALL nemo2cice(ztmp,strax,'F', -1. )
286
287! y comp of wind stress (CI_2)
288! V point to F point
289         DO jj=1,jpj
290            DO ji=1,jpim1
291               ztmp(ji,jj) = 0.5 * (  fr_iv(ji,jj) * vtau(ji,jj)      &
292                                    + fr_iv(ji+1,jj) * vtau(ji+1,jj) ) * fmask(ji,jj,1)
293            ENDDO
294         ENDDO
295         CALL nemo2cice(ztmp,stray,'F', -1. )
296
297! Surface downward latent heat flux (CI_5)
298         IF (nsbc == 2) THEN
299            DO jl=1,ncat
300               ztmpn(:,:,jl)=qla_ice(:,:,1)*a_i(:,:,jl)
301            ENDDO
302         ELSE
303! emp_ice is set in sbc_cpl_ice_flx as sublimation-snow
304            qla_ice(:,:,1)= - ( emp_ice(:,:)+sprecip(:,:) ) * Lsub
305! End of temporary code
306            DO jj=1,jpj
307               DO ji=1,jpi
308                  IF (fr_i(ji,jj).eq.0.0) THEN
309                     DO jl=1,ncat
310                        ztmpn(ji,jj,jl)=0.0
311                     ENDDO
312                     ! This will then be conserved in CICE
313                     ztmpn(ji,jj,1)=qla_ice(ji,jj,1)
314                  ELSE
315                     DO jl=1,ncat
316                        ztmpn(ji,jj,jl)=qla_ice(ji,jj,1)*a_i(ji,jj,jl)/fr_i(ji,jj)
317                     ENDDO
318                  ENDIF
319               ENDDO
320            ENDDO
321         ENDIF
322         DO jl=1,ncat
323            CALL nemo2cice(ztmpn(:,:,jl),flatn_f(:,:,jl,:),'T', 1. )
324
325! GBM conductive flux through ice (CI_6)
326!  Convert to GBM
327            IF (nsbc == 2) THEN
328               ztmp(:,:) = botmelt(:,:,jl)*a_i(:,:,jl)
329            ELSE
330               ztmp(:,:) = botmelt(:,:,jl)
331            ENDIF
332            CALL nemo2cice(ztmp,fcondtopn_f(:,:,jl,:),'T', 1. )
333
334! GBM surface heat flux (CI_7)
335!  Convert to GBM
336            IF (nsbc == 2) THEN
337               ztmp(:,:) = (topmelt(:,:,jl)+botmelt(:,:,jl))*a_i(:,:,jl) 
338            ELSE
339               ztmp(:,:) = (topmelt(:,:,jl)+botmelt(:,:,jl))
340            ENDIF
341            CALL nemo2cice(ztmp,fsurfn_f(:,:,jl,:),'T', 1. )
342         ENDDO
343
344      ELSE IF (nsbc == 4) THEN
345
346! Pass CORE forcing fields to CICE (which will calculate heat fluxes etc itself)
347! x comp and y comp of atmosphere surface wind (CICE expects on T points)
348         ztmp(:,:) = wndi_ice(:,:)
349         CALL nemo2cice(ztmp,uatm,'T', -1. )
350         ztmp(:,:) = wndj_ice(:,:)
351         CALL nemo2cice(ztmp,vatm,'T', -1. )
352         ztmp(:,:) = SQRT ( wndi_ice(:,:)**2 + wndj_ice(:,:)**2 )
353         CALL nemo2cice(ztmp,wind,'T', 1. )    ! Wind speed (m/s)
354         ztmp(:,:) = qsr_ice(:,:,1)
355         CALL nemo2cice(ztmp,fsw,'T', 1. )     ! Incoming short-wave (W/m^2)
356         ztmp(:,:) = qlw_ice(:,:,1)
357         CALL nemo2cice(ztmp,flw,'T', 1. )     ! Incoming long-wave (W/m^2)
358         ztmp(:,:) = tatm_ice(:,:)
359         CALL nemo2cice(ztmp,Tair,'T', 1. )    ! Air temperature (K)
360         CALL nemo2cice(ztmp,potT,'T', 1. )    ! Potential temp (K)
361! Following line uses MAX(....) to avoid problems if tatm_ice has unset halo rows 
362         ztmp(:,:) = 101000. / ( 287.04 * MAX(1.0,tatm_ice(:,:)) )   
363                                               ! Constant (101000.) atm pressure assumed
364         CALL nemo2cice(ztmp,rhoa,'T', 1. )    ! Air density (kg/m^3)
365         ztmp(:,:) = qatm_ice(:,:)
366         CALL nemo2cice(ztmp,Qa,'T', 1. )      ! Specific humidity (kg/kg)
367         ztmp(:,:)=10.0
368         CALL nemo2cice(ztmp,zlvl,'T', 1. )    ! Atmos level height (m)
369
370! May want to check all values are physically realistic (as in CICE routine
371! prepare_forcing)?
372
373! Divide shortwave into spectral bands (as in prepare_forcing)
374         ztmp(:,:)=qsr_ice(:,:,1)*frcvdr       ! visible direct
375         CALL nemo2cice(ztmp,swvdr,'T', 1. )             
376         ztmp(:,:)=qsr_ice(:,:,1)*frcvdf       ! visible diffuse
377         CALL nemo2cice(ztmp,swvdf,'T', 1. )             
378         ztmp(:,:)=qsr_ice(:,:,1)*frcidr       ! near IR direct
379         CALL nemo2cice(ztmp,swidr,'T', 1. )
380         ztmp(:,:)=qsr_ice(:,:,1)*frcidf       ! near IR diffuse
381         CALL nemo2cice(ztmp,swidf,'T', 1. )
382
383      ENDIF
384
385! Snowfall
386! Ensure fsnow is positive (as in CICE routine prepare_forcing) 
387      ztmp(:,:)=MAX(fr_i(:,:)*sprecip(:,:),0.0) 
388      CALL nemo2cice(ztmp,fsnow,'T', 1. ) 
389
390! Rainfall
391      ztmp(:,:)=fr_i(:,:)*(tprecip(:,:)-sprecip(:,:))
392      CALL nemo2cice(ztmp,frain,'T', 1. ) 
393
394! Freezing/melting potential
395! Calculated over NEMO leapfrog timestep (hence 2*dt)
396      nfrzmlt(:,:)=rau0*rcp*fse3t_m(:,:)*(Tocnfrz-sst_m(:,:))/(2.0*dt)
397
398      ztmp(:,:) = nfrzmlt(:,:)
399      CALL nemo2cice(ztmp,frzmlt,'T', 1. )
400
401! SST  and SSS
402
403      CALL nemo2cice(sst_m,sst,'T', 1. )
404      CALL nemo2cice(sss_m,sss,'T', 1. )
405
406! x comp and y comp of surface ocean current
407! U point to F point
408      DO jj=1,jpjm1
409         DO ji=1,jpi
410            ztmp(ji,jj)=0.5*(ssu_m(ji,jj)+ssu_m(ji,jj+1))*fmask(ji,jj,1)
411         ENDDO
412      ENDDO
413      CALL nemo2cice(ztmp,uocn,'F', -1. )
414
415! V point to F point
416      DO jj=1,jpj
417         DO ji=1,jpim1
418            ztmp(ji,jj)=0.5*(ssv_m(ji,jj)+ssv_m(ji+1,jj))*fmask(ji,jj,1)
419         ENDDO
420      ENDDO
421      CALL nemo2cice(ztmp,vocn,'F', -1. )
422
423      IF( nn_ice_embd == 2 ) THEN             !== embedded sea ice: compute representative ice top surface ==!
424          !
425          ! average interpolation coeff as used in dynspg = (1/nn_fsbc) * {SUM[n/nn_fsbc], n=0,nn_fsbc-1}
426          !                                               = (1/nn_fsbc)^2 * {SUM[n], n=0,nn_fsbc-1}
427         zintn = REAL( nn_fsbc - 1 ) / REAL( nn_fsbc ) * 0.5_wp
428          !
429          ! average interpolation coeff as used in dynspg = (1/nn_fsbc) * {SUM[1-n/nn_fsbc], n=0,nn_fsbc-1}
430          !                                               = (1/nn_fsbc)^2 * (nn_fsbc^2 - {SUM[n], n=0,nn_fsbc-1})
431         zintb = REAL( nn_fsbc + 1 ) / REAL( nn_fsbc ) * 0.5_wp
432          !
433         zpice(:,:) = ssh_m(:,:) + (  zintn * snwice_mass(:,:) +  zintb * snwice_mass_b(:,:)  ) * r1_rau0
434          !
435         !
436      ELSE                                    !== non-embedded sea ice: use ocean surface for slope calculation ==!
437         zpice(:,:) = ssh_m(:,:)
438      ENDIF
439
440! x comp and y comp of sea surface slope (on F points)
441! T point to F point
442      DO jj=1,jpjm1
443         DO ji=1,jpim1
444            ztmp(ji,jj)=0.5 * (  (zpice(ji+1,jj  )-zpice(ji,jj  ))/e1u(ji,jj  )   &
445                               + (zpice(ji+1,jj+1)-zpice(ji,jj+1))/e1u(ji,jj+1) ) & 
446                            *  fmask(ji,jj,1)
447         ENDDO
448      ENDDO
449      CALL nemo2cice(ztmp,ss_tltx,'F', -1. )
450
451! T point to F point
452      DO jj=1,jpjm1
453         DO ji=1,jpim1
454            ztmp(ji,jj)=0.5 * (  (zpice(ji  ,jj+1)-zpice(ji  ,jj))/e2v(ji  ,jj)   &
455                               + (zpice(ji+1,jj+1)-zpice(ji+1,jj))/e2v(ji+1,jj) ) &
456                            *  fmask(ji,jj,1)
457         ENDDO
458      ENDDO
459      CALL nemo2cice(ztmp,ss_tlty,'F', -1. )
460
461      CALL wrk_dealloc( jpi,jpj, ztmp )
462      CALL wrk_dealloc( jpi,jpj,ncat, ztmpn )
463      !
464      IF( nn_timing == 1 )  CALL timing_stop('cice_sbc_in')
465      !
466   END SUBROUTINE cice_sbc_in
467
468
469   SUBROUTINE cice_sbc_out (kt,nsbc)
470      !!---------------------------------------------------------------------
471      !!                    ***  ROUTINE cice_sbc_out  ***
472      !! ** Purpose: Get fields from CICE and set surface fields for NEMO
473      !!---------------------------------------------------------------------
474      INTEGER, INTENT( in  ) ::   kt   ! ocean time step
475      INTEGER, INTENT( in  ) ::   nsbc ! surface forcing type
476     
477      INTEGER  ::   ji, jj, jl                 ! dummy loop indices
478      REAL(wp), DIMENSION(:,:), POINTER :: ztmp1, ztmp2
479      !!---------------------------------------------------------------------
480
481      IF( nn_timing == 1 )  CALL timing_start('cice_sbc_out')
482      !
483      CALL wrk_alloc( jpi,jpj, ztmp1, ztmp2 )
484     
485      IF( kt == nit000 )  THEN
486         IF(lwp) WRITE(numout,*)'cice_sbc_out'
487      ENDIF
488     
489! x comp of ocean-ice stress
490      CALL cice2nemo(strocnx,ztmp1,'F', -1. )
491      ss_iou(:,:)=0.0
492! F point to U point
493      DO jj=2,jpjm1
494         DO ji=2,jpim1
495            ss_iou(ji,jj) = 0.5 * ( ztmp1(ji,jj-1) + ztmp1(ji,jj) ) * umask(ji,jj,1)
496         ENDDO
497      ENDDO
498      CALL lbc_lnk( ss_iou , 'U', -1. )
499
500! y comp of ocean-ice stress
501      CALL cice2nemo(strocny,ztmp1,'F', -1. )
502      ss_iov(:,:)=0.0
503! F point to V point
504
505      DO jj=1,jpjm1
506         DO ji=2,jpim1
507            ss_iov(ji,jj) = 0.5 * ( ztmp1(ji-1,jj) + ztmp1(ji,jj) ) * vmask(ji,jj,1)
508         ENDDO
509      ENDDO
510      CALL lbc_lnk( ss_iov , 'V', -1. )
511
512! x and y comps of surface stress
513! Combine wind stress and ocean-ice stress
514! [Note that fr_iu hasn't yet been updated, so still from start of CICE timestep]
515
516      utau(:,:)=(1.0-fr_iu(:,:))*utau(:,:)-ss_iou(:,:)
517      vtau(:,:)=(1.0-fr_iv(:,:))*vtau(:,:)-ss_iov(:,:)     
518
519! Freshwater fluxes
520
521      IF (nsbc == 2) THEN
522! Note that emp from the forcing files is evap*(1-aice)-(tprecip-aice*sprecip)
523! What we want here is evap*(1-aice)-tprecip*(1-aice) hence manipulation below
524! Not ideal since aice won't be the same as in the atmosphere. 
525! Better to use evap and tprecip? (but for now don't read in evap in this case)
526         emp(:,:)  = emp(:,:)+fr_i(:,:)*(tprecip(:,:)-sprecip(:,:))
527      ELSE IF (nsbc == 4) THEN
528         emp(:,:)  = (1.0-fr_i(:,:))*emp(:,:)       
529      ELSE IF (nsbc ==5) THEN
530! emp_tot is set in sbc_cpl_ice_flx (called from cice_sbc_in above)
531! This is currently as required with the coupling fields from the UM atmosphere
532         emp(:,:) = emp_tot(:,:)+tprecip(:,:)*fr_i(:,:) 
533      ENDIF
534
535#if defined key_cice5
536      CALL cice2nemo(fresh_ai,ztmp1,'T', 1. )
537      CALL cice2nemo(fsalt_ai,ztmp2,'T', 1. )
538#else
539      CALL cice2nemo(fresh_gbm,ztmp1,'T', 1. )
540      CALL cice2nemo(fsalt_gbm,ztmp2,'T', 1. )
541#endif
542
543! Check to avoid unphysical expression when ice is forming (ztmp1 negative)
544! Otherwise we are effectively allowing ice of higher salinity than the ocean to form
545! which has to be compensated for by the ocean salinity potentially going negative
546! This check breaks conservation but seems reasonable until we have prognostic ice salinity
547! Note the 1000.0 below is to convert from kg salt to g salt (needed for PSU)
548      WHERE (ztmp1(:,:).lt.0.0) ztmp2(:,:)=MAX(ztmp2(:,:),ztmp1(:,:)*sss_m(:,:)/1000.0)
549      sfx(:,:)=ztmp2(:,:)*1000.0
550      emp(:,:)=emp(:,:)-ztmp1(:,:)
551 
552      CALL lbc_lnk( emp , 'T', 1. )
553      CALL lbc_lnk( sfx , 'T', 1. )
554
555! Solar penetrative radiation and non solar surface heat flux
556
557! Scale qsr and qns according to ice fraction (bulk formulae only)
558
559      IF (nsbc == 4) THEN
560         qsr(:,:)=qsr(:,:)*(1.0-fr_i(:,:))
561         qns(:,:)=qns(:,:)*(1.0-fr_i(:,:))
562      ENDIF
563! Take into account snow melting except for fully coupled when already in qns_tot
564      IF (nsbc == 5) THEN
565         qsr(:,:)= qsr_tot(:,:)
566         qns(:,:)= qns_tot(:,:)
567      ELSE
568         qns(:,:)= qns(:,:)-sprecip(:,:)*Lfresh*(1.0-fr_i(:,:))
569      ENDIF
570
571! Now add in ice / snow related terms
572! [fswthru will be zero unless running with calc_Tsfc=T in CICE]
573#if defined key_cice5
574      CALL cice2nemo(fswthru_ai,ztmp1,'T', 1. )
575#else
576      CALL cice2nemo(fswthru_gbm,ztmp1,'T', 1. )
577#endif
578      qsr(:,:)=qsr(:,:)+ztmp1(:,:)
579      CALL lbc_lnk( qsr , 'T', 1. )
580
581      DO jj=1,jpj
582         DO ji=1,jpi
583            nfrzmlt(ji,jj)=MAX(nfrzmlt(ji,jj),0.0)
584         ENDDO
585      ENDDO
586
587#if defined key_cice5
588      CALL cice2nemo(fhocn_ai,ztmp1,'T', 1. )
589#else
590      CALL cice2nemo(fhocn_gbm,ztmp1,'T', 1. )
591#endif
592      qns(:,:)=qns(:,:)+nfrzmlt(:,:)+ztmp1(:,:)
593
594      CALL lbc_lnk( qns , 'T', 1. )
595
596! Prepare for the following CICE time-step
597
598      CALL cice2nemo(aice,fr_i,'T', 1. )
599      IF ( (nsbc == 2).OR.(nsbc == 5) ) THEN
600         DO jl=1,ncat
601            CALL cice2nemo(aicen(:,:,jl,:),a_i(:,:,jl), 'T', 1. )
602         ENDDO
603      ENDIF
604
605! T point to U point
606! T point to V point
607      DO jj=1,jpjm1
608         DO ji=1,jpim1
609            fr_iu(ji,jj)=0.5*(fr_i(ji,jj)+fr_i(ji+1,jj))*umask(ji,jj,1)
610            fr_iv(ji,jj)=0.5*(fr_i(ji,jj)+fr_i(ji,jj+1))*vmask(ji,jj,1)
611         ENDDO
612      ENDDO
613
614      CALL lbc_lnk ( fr_iu , 'U', 1. )
615      CALL lbc_lnk ( fr_iv , 'V', 1. )
616
617      !                                      ! embedded sea ice
618      IF( nn_ice_embd /= 0 ) THEN            ! mass exchanges between ice and ocean (case 1 or 2) set the snow+ice mass
619         CALL cice2nemo(vsno(:,:,:),ztmp1,'T', 1. )
620         CALL cice2nemo(vice(:,:,:),ztmp2,'T', 1. )
621         snwice_mass  (:,:) = ( rhosn * ztmp1(:,:) + rhoic * ztmp2(:,:)  )
622         snwice_mass_b(:,:) = snwice_mass(:,:)
623         snwice_fmass (:,:) = ( snwice_mass(:,:) - snwice_mass_b(:,:) ) / dt
624      ENDIF
625
626! Release work space
627
628      CALL wrk_dealloc( jpi,jpj, ztmp1, ztmp2 )
629      !
630      IF( nn_timing == 1 )  CALL timing_stop('cice_sbc_out')
631      !
632   END SUBROUTINE cice_sbc_out
633
634
635#if defined key_oasis3 || defined key_oasis4
636   SUBROUTINE cice_sbc_hadgam( kt )
637      !!---------------------------------------------------------------------
638      !!                    ***  ROUTINE cice_sbc_hadgam  ***
639      !! ** Purpose: Prepare fields needed to pass to HadGAM3 atmosphere
640      !!
641      !!
642      INTEGER, INTENT( in  ) ::   kt   ! ocean time step
643      !!---------------------------------------------------------------------
644
645      INTEGER  ::   jl                        ! dummy loop index
646      INTEGER  ::   ierror
647
648      IF( nn_timing == 1 )  CALL timing_start('cice_sbc_hadgam')
649      !
650      IF( kt == nit000 )  THEN
651         IF(lwp) WRITE(numout,*)'cice_sbc_hadgam'
652         IF( sbc_cpl_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'sbc_cpl_alloc : unable to allocate arrays' )
653      ENDIF
654
655      !                                         ! =========================== !
656      !                                         !   Prepare Coupling fields   !
657      !                                         ! =========================== !
658
659! x and y comp of ice velocity
660
661      CALL cice2nemo(uvel,u_ice,'F', -1. )
662      CALL cice2nemo(vvel,v_ice,'F', -1. )
663
664! Ice concentration (CO_1) = a_i calculated at end of cice_sbc_out 
665
666! Snow and ice thicknesses (CO_2 and CO_3)
667
668      DO jl = 1,ncat
669         CALL cice2nemo(vsnon(:,:,jl,:),ht_s(:,:,jl),'T', 1. )
670         CALL cice2nemo(vicen(:,:,jl,:),ht_i(:,:,jl),'T', 1. )
671      ENDDO
672      !
673      IF( nn_timing == 1 )  CALL timing_stop('cice_sbc_hadgam')
674      !
675   END SUBROUTINE cice_sbc_hadgam
676
677#else
678   SUBROUTINE cice_sbc_hadgam( kt )    ! Dummy routine
679      INTEGER, INTENT( in  ) ::   kt   ! ocean time step
680      WRITE(*,*) 'cice_sbc_hadgam: You should not have seen this print! error?'
681   END SUBROUTINE cice_sbc_hadgam
682#endif
683
684   SUBROUTINE cice_sbc_final
685      !!---------------------------------------------------------------------
686      !!                    ***  ROUTINE cice_sbc_final  ***
687      !! ** Purpose: Finalize CICE
688      !!---------------------------------------------------------------------
689
690      IF(lwp) WRITE(numout,*)'cice_sbc_final'
691
692      CALL CICE_Finalize
693
694   END SUBROUTINE cice_sbc_final
695
696   SUBROUTINE cice_sbc_force (kt)
697      !!---------------------------------------------------------------------
698      !!                    ***  ROUTINE cice_sbc_force  ***
699      !! ** Purpose : Provide CICE forcing from files
700      !!
701      !!---------------------------------------------------------------------
702      !! ** Method  :   READ monthly flux file in NetCDF files
703      !!     
704      !!  snowfall   
705      !!  rainfall   
706      !!  sublimation rate   
707      !!  topmelt (category)
708      !!  botmelt (category)
709      !!
710      !! History :
711      !!----------------------------------------------------------------------
712      !! * Modules used
713      USE iom
714
715      !! * arguments
716      INTEGER, INTENT( in  ) ::   kt ! ocean time step
717
718      INTEGER  ::   ierror             ! return error code
719      INTEGER  ::   ifpr               ! dummy loop index
720      !!
721      CHARACTER(len=100) ::  cn_dir                            !   Root directory for location of CICE forcing files
722      TYPE(FLD_N), DIMENSION(jpfld) ::   slf_i                 ! array of namelist informations on the fields to read
723      TYPE(FLD_N) ::   sn_snow, sn_rain, sn_sblm               ! informations about the fields to be read
724      TYPE(FLD_N) ::   sn_top1, sn_top2, sn_top3, sn_top4, sn_top5
725      TYPE(FLD_N) ::   sn_bot1, sn_bot2, sn_bot3, sn_bot4, sn_bot5 
726
727      !!
728      NAMELIST/namsbc_cice/ cn_dir, sn_snow, sn_rain, sn_sblm,   &
729         &                          sn_top1, sn_top2, sn_top3, sn_top4, sn_top5,  &
730         &                          sn_bot1, sn_bot2, sn_bot3, sn_bot4, sn_bot5
731      INTEGER :: ios
732      !!---------------------------------------------------------------------
733
734      !                                         ! ====================== !
735      IF( kt == nit000 ) THEN                   !  First call kt=nit000  !
736         !                                      ! ====================== !
737         REWIND( numnam_ref )              ! Namelist namsbc_cice in reference namelist :
738         READ  ( numnam_ref, namsbc_cice, IOSTAT = ios, ERR = 901)
739901      IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_cice in reference namelist', lwp )
740
741         REWIND( numnam_cfg )              ! Namelist namsbc_cice in configuration namelist : Parameters of the run
742         READ  ( numnam_cfg, namsbc_cice, IOSTAT = ios, ERR = 902 )
743902      IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_cice in configuration namelist', lwp )
744         IF(lwm) WRITE ( numond, namsbc_cice )
745
746         ! store namelist information in an array
747         slf_i(jp_snow) = sn_snow   ;   slf_i(jp_rain) = sn_rain   ;   slf_i(jp_sblm) = sn_sblm
748         slf_i(jp_top1) = sn_top1   ;   slf_i(jp_top2) = sn_top2   ;   slf_i(jp_top3) = sn_top3
749         slf_i(jp_top4) = sn_top4   ;   slf_i(jp_top5) = sn_top5   ;   slf_i(jp_bot1) = sn_bot1
750         slf_i(jp_bot2) = sn_bot2   ;   slf_i(jp_bot3) = sn_bot3   ;   slf_i(jp_bot4) = sn_bot4
751         slf_i(jp_bot5) = sn_bot5
752         
753         ! set sf structure
754         ALLOCATE( sf(jpfld), STAT=ierror )
755         IF( ierror > 0 ) THEN
756            CALL ctl_stop( 'cice_sbc_force: unable to allocate sf structure' )   ;   RETURN
757         ENDIF
758
759         DO ifpr= 1, jpfld
760            ALLOCATE( sf(ifpr)%fnow(jpi,jpj,1) )
761            ALLOCATE( sf(ifpr)%fdta(jpi,jpj,1,2) )
762         END DO
763
764         ! fill sf with slf_i and control print
765         CALL fld_fill( sf, slf_i, cn_dir, 'cice_sbc_force', 'flux formulation for CICE', 'namsbc_cice' )
766         !
767      ENDIF
768
769      CALL fld_read( kt, nn_fsbc, sf )           ! Read input fields and provides the
770      !                                          ! input fields at the current time-step
771
772      ! set the fluxes from read fields
773      sprecip(:,:) = sf(jp_snow)%fnow(:,:,1)
774      tprecip(:,:) = sf(jp_snow)%fnow(:,:,1)+sf(jp_rain)%fnow(:,:,1)
775! May be better to do this conversion somewhere else
776      qla_ice(:,:,1) = -Lsub*sf(jp_sblm)%fnow(:,:,1)
777      topmelt(:,:,1) = sf(jp_top1)%fnow(:,:,1)
778      topmelt(:,:,2) = sf(jp_top2)%fnow(:,:,1)
779      topmelt(:,:,3) = sf(jp_top3)%fnow(:,:,1)
780      topmelt(:,:,4) = sf(jp_top4)%fnow(:,:,1)
781      topmelt(:,:,5) = sf(jp_top5)%fnow(:,:,1)
782      botmelt(:,:,1) = sf(jp_bot1)%fnow(:,:,1)
783      botmelt(:,:,2) = sf(jp_bot2)%fnow(:,:,1)
784      botmelt(:,:,3) = sf(jp_bot3)%fnow(:,:,1)
785      botmelt(:,:,4) = sf(jp_bot4)%fnow(:,:,1)
786      botmelt(:,:,5) = sf(jp_bot5)%fnow(:,:,1)
787
788      ! control print (if less than 100 time-step asked)
789      IF( nitend-nit000 <= 100 .AND. lwp ) THEN
790         WRITE(numout,*) 
791         WRITE(numout,*) '        read forcing fluxes for CICE OK'
792         CALL FLUSH(numout)
793      ENDIF
794
795   END SUBROUTINE cice_sbc_force
796
797   SUBROUTINE nemo2cice( pn, pc, cd_type, psgn)
798      !!---------------------------------------------------------------------
799      !!                    ***  ROUTINE nemo2cice  ***
800      !! ** Purpose :   Transfer field in NEMO array to field in CICE array. 
801#if defined key_nemocice_decomp
802      !!             
803      !!                NEMO and CICE PE sub domains are identical, hence
804      !!                there is no need to gather or scatter data from
805      !!                one PE configuration to another.
806#else
807      !!                Automatically gather/scatter between
808      !!                different processors and blocks
809      !! ** Method :    A. Ensure all haloes are filled in NEMO field (pn)
810      !!                B. Gather pn into global array (png)
811      !!                C. Map png into CICE global array (pcg)
812      !!                D. Scatter pcg to CICE blocks (pc) + update haloes 
813#endif
814      !!---------------------------------------------------------------------
815
816      CHARACTER(len=1), INTENT( in ) ::   &
817          cd_type       ! nature of pn grid-point
818          !             !   = T or F gridpoints
819      REAL(wp), INTENT( in ) ::   &
820          psgn          ! control of the sign change
821          !             !   =-1 , the sign is modified following the type of b.c. used
822          !             !   = 1 , no sign change
823      REAL(wp), DIMENSION(jpi,jpj) :: pn
824#if !defined key_nemocice_decomp
825      REAL(wp), DIMENSION(jpiglo,jpjglo) :: png2
826      REAL (kind=dbl_kind), dimension(nx_global,ny_global) :: pcg
827#endif
828      REAL (kind=dbl_kind), dimension(nx_block,ny_block,max_blocks) :: pc
829      INTEGER (int_kind) :: &
830         field_type,        &! id for type of field (scalar, vector, angle)
831         grid_loc            ! id for location on horizontal grid
832                            !  (center, NEcorner, Nface, Eface)
833
834      INTEGER  ::   ji, jj, jn                      ! dummy loop indices
835
836!     A. Ensure all haloes are filled in NEMO field (pn)
837
838      CALL lbc_lnk( pn , cd_type, psgn )
839
840#if defined key_nemocice_decomp
841
842      ! Copy local domain data from NEMO to CICE field
843      pc(:,:,1)=0.0
844      DO jj=2,ny_block-1
845         DO ji=2,nx_block-1
846            pc(ji,jj,1)=pn(ji-1+ji_off,jj-1+jj_off)
847         ENDDO
848      ENDDO
849
850#else
851
852!     B. Gather pn into global array (png)
853
854      IF ( jpnij > 1) THEN
855         CALL mppsync
856         CALL mppgather (pn,0,png) 
857         CALL mppsync
858      ELSE
859         png(:,:,1)=pn(:,:)
860      ENDIF
861
862!     C. Map png into CICE global array (pcg)
863
864! Need to make sure this is robust to changes in NEMO halo rows....
865! (may be OK but not 100% sure)
866
867      IF (nproc==0) THEN     
868!        pcg(:,:)=0.0
869         DO jn=1,jpnij
870            DO jj=nldjt(jn),nlejt(jn)
871               DO ji=nldit(jn),nleit(jn)
872                  png2(ji+nimppt(jn)-1,jj+njmppt(jn)-1)=png(ji,jj,jn)
873               ENDDO
874            ENDDO
875         ENDDO
876         DO jj=1,ny_global
877            DO ji=1,nx_global
878               pcg(ji,jj)=png2(ji+ji_off,jj+jj_off)
879            ENDDO
880         ENDDO
881      ENDIF
882
883#endif
884
885      SELECT CASE ( cd_type )
886         CASE ( 'T' )
887            grid_loc=field_loc_center
888         CASE ( 'F' )                             
889            grid_loc=field_loc_NEcorner
890      END SELECT
891
892      SELECT CASE ( NINT(psgn) )
893         CASE ( -1 )
894            field_type=field_type_vector
895         CASE ( 1 )                             
896            field_type=field_type_scalar
897      END SELECT
898
899#if defined key_nemocice_decomp
900      ! Ensure CICE halos are up to date
901      CALL ice_HaloUpdate (pc, halo_info, grid_loc, field_type)
902#else
903!     D. Scatter pcg to CICE blocks (pc) + update halos
904      CALL scatter_global(pc, pcg, 0, distrb_info, grid_loc, field_type)
905#endif
906
907   END SUBROUTINE nemo2cice
908
909   SUBROUTINE cice2nemo ( pc, pn, cd_type, psgn )
910      !!---------------------------------------------------------------------
911      !!                    ***  ROUTINE cice2nemo  ***
912      !! ** Purpose :   Transfer field in CICE array to field in NEMO array.
913#if defined key_nemocice_decomp
914      !!             
915      !!                NEMO and CICE PE sub domains are identical, hence
916      !!                there is no need to gather or scatter data from
917      !!                one PE configuration to another.
918#else 
919      !!                Automatically deal with scatter/gather between
920      !!                different processors and blocks
921      !! ** Method :    A. Gather CICE blocks (pc) into global array (pcg)
922      !!                B. Map pcg into NEMO global array (png)
923      !!                C. Scatter png into NEMO field (pn) for each processor
924      !!                D. Ensure all haloes are filled in pn
925#endif
926      !!---------------------------------------------------------------------
927
928      CHARACTER(len=1), INTENT( in ) ::   &
929          cd_type       ! nature of pn grid-point
930          !             !   = T or F gridpoints
931      REAL(wp), INTENT( in ) ::   &
932          psgn          ! control of the sign change
933          !             !   =-1 , the sign is modified following the type of b.c. used
934          !             !   = 1 , no sign change
935      REAL(wp), DIMENSION(jpi,jpj) :: pn
936
937#if defined key_nemocice_decomp
938      INTEGER (int_kind) :: &
939         field_type,        & ! id for type of field (scalar, vector, angle)
940         grid_loc             ! id for location on horizontal grid
941                              ! (center, NEcorner, Nface, Eface)
942#else
943      REAL (kind=dbl_kind), dimension(nx_global,ny_global) :: pcg
944#endif
945
946      REAL (kind=dbl_kind), dimension(nx_block,ny_block,max_blocks) :: pc
947
948      INTEGER  ::   ji, jj, jn                      ! dummy loop indices
949
950
951#if defined key_nemocice_decomp
952
953      SELECT CASE ( cd_type )
954         CASE ( 'T' )
955            grid_loc=field_loc_center
956         CASE ( 'F' )                             
957            grid_loc=field_loc_NEcorner
958      END SELECT
959
960      SELECT CASE ( NINT(psgn) )
961         CASE ( -1 )
962            field_type=field_type_vector
963         CASE ( 1 )                             
964            field_type=field_type_scalar
965      END SELECT
966
967      CALL ice_HaloUpdate (pc, halo_info, grid_loc, field_type)
968
969
970      pn(:,:)=0.0
971      DO jj=1,jpjm1
972         DO ji=1,jpim1
973            pn(ji,jj)=pc(ji+1-ji_off,jj+1-jj_off,1)
974         ENDDO
975      ENDDO
976
977#else
978
979!      A. Gather CICE blocks (pc) into global array (pcg)
980
981      CALL gather_global(pcg, pc, 0, distrb_info)
982
983!     B. Map pcg into NEMO global array (png)
984
985! Need to make sure this is robust to changes in NEMO halo rows....
986! (may be OK but not spent much time thinking about it)
987! Note that non-existent pcg elements may be used below, but
988! the lbclnk call on pn will replace these with sensible values
989
990      IF (nproc==0) THEN
991         png(:,:,:)=0.0
992         DO jn=1,jpnij
993            DO jj=nldjt(jn),nlejt(jn)
994               DO ji=nldit(jn),nleit(jn)
995                  png(ji,jj,jn)=pcg(ji+nimppt(jn)-1-ji_off,jj+njmppt(jn)-1-jj_off)
996               ENDDO
997            ENDDO
998         ENDDO
999      ENDIF
1000
1001!     C. Scatter png into NEMO field (pn) for each processor
1002
1003      IF ( jpnij > 1) THEN
1004         CALL mppsync
1005         CALL mppscatter (png,0,pn) 
1006         CALL mppsync
1007      ELSE
1008         pn(:,:)=png(:,:,1)
1009      ENDIF
1010
1011#endif
1012
1013!     D. Ensure all haloes are filled in pn
1014
1015      CALL lbc_lnk( pn , cd_type, psgn )
1016
1017   END SUBROUTINE cice2nemo
1018
1019#else
1020   !!----------------------------------------------------------------------
1021   !!   Default option           Dummy module         NO CICE sea-ice model
1022   !!----------------------------------------------------------------------
1023CONTAINS
1024
1025   SUBROUTINE sbc_ice_cice ( kt, nsbc )     ! Dummy routine
1026      WRITE(*,*) 'sbc_ice_cice: You should not have seen this print! error?', kt
1027   END SUBROUTINE sbc_ice_cice
1028
1029   SUBROUTINE cice_sbc_init (nsbc)    ! Dummy routine
1030      WRITE(*,*) 'cice_sbc_init: You should not have seen this print! error?'
1031   END SUBROUTINE cice_sbc_init
1032
1033   SUBROUTINE cice_sbc_final     ! Dummy routine
1034      WRITE(*,*) 'cice_sbc_final: You should not have seen this print! error?'
1035   END SUBROUTINE cice_sbc_final
1036
1037#endif
1038
1039   !!======================================================================
1040END MODULE sbcice_cice
Note: See TracBrowser for help on using the repository browser.