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.
icbini.F90 in NEMO/branches/2019/fix_ticket2238_solution1/src/OCE/ICB – NEMO

source: NEMO/branches/2019/fix_ticket2238_solution1/src/OCE/ICB/icbini.F90 @ 10696

Last change on this file since 10696 was 10696, checked in by mathiot, 5 years ago

move extended array tt_e,uo_e (...) initialisation to 0. in icbini.F90 and chnage hicth name to hi_e

  • Property svn:keywords set to Id
File size: 23.2 KB
Line 
1MODULE icbini
2   !!======================================================================
3   !!                       ***  MODULE  icbini  ***
4   !! Icebergs:  initialise variables for iceberg tracking
5   !!======================================================================
6   !! History :   -   !  2010-01  (T. Martin & A. Adcroft)  Original code
7   !!            3.3  !  2011-03  (G. Madec)  Part conversion to NEMO form ; Removal of mapping from another grid
8   !!             -   !  2011-04  (S. Alderson)  Split into separate modules ; Restore restart routines
9   !!             -   !  2011-05  (S. Alderson)  generate_test_icebergs restored ; new forcing arrays with extra halo ;
10   !!             -   !                          north fold exchange arrays added
11   !!----------------------------------------------------------------------
12   !!----------------------------------------------------------------------
13   !!   icb_init     : initialise icebergs
14   !!   icb_ini_gen  : generate test icebergs
15   !!   icb_nam      : read iceberg namelist
16   !!----------------------------------------------------------------------
17   USE dom_oce        ! ocean domain
18   USE in_out_manager ! IO routines and numout in particular
19   USE lib_mpp        ! mpi library and lk_mpp in particular
20   USE sbc_oce        ! ocean  : surface boundary condition
21   USE sbc_ice        ! sea-ice: surface boundary condition
22   USE iom            ! IOM library
23   USE fldread        ! field read
24   USE lbclnk         ! lateral boundary condition - MPP link
25   !
26   USE icb_oce        ! define iceberg arrays
27   USE icbutl         ! iceberg utility routines
28   USE icbrst         ! iceberg restart routines
29   USE icbtrj         ! iceberg trajectory I/O routines
30   USE icbdia         ! iceberg budget routines
31
32   IMPLICIT NONE
33   PRIVATE
34
35   PUBLIC   icb_init  ! routine called in nemogcm.F90 module
36
37   CHARACTER(len=100)                                 ::   cn_dir = './'   !: Root directory for location of icb files
38   TYPE(FLD_N)                                        ::   sn_icb          !: information about the calving file to be read
39   TYPE(FLD), PUBLIC, ALLOCATABLE     , DIMENSION(:)  ::   sf_icb          !: structure: file information, fields read
40                                                                           !: used in icbini and icbstp
41   !!----------------------------------------------------------------------
42   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
43   !! $Id$
44   !! Software governed by the CeCILL license (see ./LICENSE)
45   !!----------------------------------------------------------------------
46CONTAINS
47
48   SUBROUTINE icb_init( pdt, kt )
49      !!----------------------------------------------------------------------
50      !!                  ***  ROUTINE dom_init  ***
51      !!
52      !! ** Purpose :   iceberg initialization.
53      !!
54      !! ** Method  : - read the iceberg namelist
55      !!              - find non-overlapping processor interior since we can only
56      !!                have one instance of a particular iceberg
57      !!              - calculate the destinations for north fold exchanges
58      !!              - setup either test icebergs or calving file
59      !!----------------------------------------------------------------------
60      REAL(wp), INTENT(in) ::   pdt   ! iceberg time-step (rdt*nn_fsbc)
61      INTEGER , INTENT(in) ::   kt    ! time step number
62      !
63      INTEGER ::   ji, jj, jn               ! dummy loop indices
64      INTEGER ::   i1, i2, i3               ! local integers
65      INTEGER ::   ii, inum, ivar           !   -       -
66      INTEGER ::   istat1, istat2, istat3   !   -       -
67      CHARACTER(len=300) ::   cl_sdist      ! local character
68      !!----------------------------------------------------------------------
69      !
70      CALL icb_nam               ! Read and print namelist parameters
71      !
72      IF( .NOT. ln_icebergs )   RETURN
73
74      !                          ! allocate gridded fields
75      IF( icb_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'icb_alloc : unable to allocate arrays' )
76      !
77      !                          ! initialised variable with extra haloes to zero
78      uo_e(:,:) = 0._wp   ;   vo_e(:,:) = 0._wp   ;
79      ua_e(:,:) = 0._wp   ;   va_e(:,:) = 0._wp   ;
80      ff_e(:,:) = 0._wp   ;   tt_e(:,:) = 0._wp   ;
81      fr_e(:,:) = 0._wp   ;   hi_e(:,:) = 0._wp   ;
82      ui_e(:,:) = 0._wp   ;   vi_e(:,:) = 0._wp   ;
83      ssh_e(:,:) = 0._wp  ; 
84      !
85      !                          ! open ascii output file or files for iceberg status information
86      !                          ! note that we choose to do this on all processors since we cannot
87      !                          ! predict where icebergs will be ahead of time
88      IF( nn_verbose_level > 0) THEN
89         CALL ctl_opn( numicb, 'icebergs.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
90      ENDIF
91
92      ! set parameters (mostly from namelist)
93      !
94      berg_dt         = pdt
95      first_width (:) = SQRT(  rn_initial_mass(:) / ( rn_LoW_ratio * rn_rho_bergs * rn_initial_thickness(:) )  )
96      first_length(:) = rn_LoW_ratio * first_width(:)
97
98      berg_grid%calving      (:,:)   = 0._wp
99      berg_grid%calving_hflx (:,:)   = 0._wp
100      berg_grid%stored_heat  (:,:)   = 0._wp
101      berg_grid%floating_melt(:,:)   = 0._wp
102      berg_grid%maxclass     (:,:)   = nclasses
103      berg_grid%stored_ice   (:,:,:) = 0._wp
104      berg_grid%tmp          (:,:)   = 0._wp
105      src_calving            (:,:)   = 0._wp
106      src_calving_hflx       (:,:)   = 0._wp
107
108      !                          ! domain for icebergs
109      IF( lk_mpp .AND. jpni == 1 )   CALL ctl_stop( 'icbinit: having ONE processor in x currently does not work' )
110      ! NB: the issue here is simply that cyclic east-west boundary condition have not been coded in mpp case
111      ! for the north fold we work out which points communicate by asking
112      ! lbc_lnk to pass processor number (valid even in single processor case)
113      ! borrow src_calving arrays for this
114      !
115      ! pack i and j together using a scaling of a power of 10
116      nicbpack = 10000
117      IF( jpiglo >= nicbpack )   CALL ctl_stop( 'icbini: processor index packing failure' )
118      nicbfldproc(:) = -1
119
120      DO jj = 1, jpj
121         DO ji = 1, jpi
122            src_calving_hflx(ji,jj) = narea
123            src_calving     (ji,jj) = nicbpack * mjg(jj) + mig(ji)
124         END DO
125      END DO
126      CALL lbc_lnk( 'icbini', src_calving_hflx, 'T', 1._wp )
127      CALL lbc_lnk( 'icbini', src_calving     , 'T', 1._wp )
128
129      ! work out interior of processor from exchange array
130      ! first entry with narea for this processor is left hand interior index
131      ! last  entry                               is right hand interior index
132      jj = nlcj/2
133      nicbdi = -1
134      nicbei = -1
135      DO ji = 1, jpi
136         i3 = INT( src_calving(ji,jj) )
137         i2 = INT( i3/nicbpack )
138         i1 = i3 - i2*nicbpack
139         i3 = INT( src_calving_hflx(ji,jj) )
140         IF( i1 == mig(ji) .AND. i3 == narea ) THEN
141            IF( nicbdi < 0 ) THEN   ;   nicbdi = ji
142            ELSE                    ;   nicbei = ji
143            ENDIF
144         ENDIF
145      END DO
146      !
147      ! repeat for j direction
148      ji = nlci/2
149      nicbdj = -1
150      nicbej = -1
151      DO jj = 1, jpj
152         i3 = INT( src_calving(ji,jj) )
153         i2 = INT( i3/nicbpack )
154         i1 = i3 - i2*nicbpack
155         i3 = INT( src_calving_hflx(ji,jj) )
156         IF( i2 == mjg(jj) .AND. i3 == narea ) THEN
157            IF( nicbdj < 0 ) THEN   ;   nicbdj = jj
158            ELSE                    ;   nicbej = jj
159            ENDIF
160         ENDIF
161      END DO
162      !   
163      ! special for east-west boundary exchange we save the destination index
164      i1 = MAX( nicbdi-1, 1)
165      i3 = INT( src_calving(i1,nlcj/2) )
166      jj = INT( i3/nicbpack )
167      ricb_left = REAL( i3 - nicbpack*jj, wp )
168      i1 = MIN( nicbei+1, jpi )
169      i3 = INT( src_calving(i1,nlcj/2) )
170      jj = INT( i3/nicbpack )
171      ricb_right = REAL( i3 - nicbpack*jj, wp )
172     
173      ! north fold
174      IF( npolj > 0 ) THEN
175         !
176         ! icebergs in row nicbej+1 get passed across fold
177         nicbfldpts(:)  = INT( src_calving(:,nicbej+1) )
178         nicbflddest(:) = INT( src_calving_hflx(:,nicbej+1) )
179         !
180         ! work out list of unique processors to talk to
181         ! pack them into a fixed size array where empty slots are marked by a -1
182         DO ji = nicbdi, nicbei
183            ii = nicbflddest(ji)
184            IF( ii .GT. 0 ) THEN     ! Needed because land suppression can mean
185                                     ! that unused points are not set in edge haloes
186               DO jn = 1, jpni
187                  ! work along array until we find an empty slot
188                  IF( nicbfldproc(jn) == -1 ) THEN
189                     nicbfldproc(jn) = ii
190                     EXIT                             !!gm EXIT should be avoided: use DO WHILE expression instead
191                  ENDIF
192                  ! before we find an empty slot, we may find processor number is already here so we exit
193                  IF( nicbfldproc(jn) == ii ) EXIT
194               END DO
195            ENDIF
196         END DO
197      ENDIF
198      !
199      IF( nn_verbose_level > 0) THEN
200         WRITE(numicb,*) 'processor ', narea
201         WRITE(numicb,*) 'jpi, jpj   ', jpi, jpj
202         WRITE(numicb,*) 'nldi, nlei ', nldi, nlei
203         WRITE(numicb,*) 'nldj, nlej ', nldj, nlej
204         WRITE(numicb,*) 'berg i interior ', nicbdi, nicbei
205         WRITE(numicb,*) 'berg j interior ', nicbdj, nicbej
206         WRITE(numicb,*) 'berg left       ', ricb_left
207         WRITE(numicb,*) 'berg right      ', ricb_right
208         jj = nlcj/2
209         WRITE(numicb,*) "central j line:"
210         WRITE(numicb,*) "i processor"
211         WRITE(numicb,*) (INT(src_calving_hflx(ji,jj)), ji=1,jpi)
212         WRITE(numicb,*) "i point"
213         WRITE(numicb,*) (INT(src_calving(ji,jj)), ji=1,jpi)
214         ji = nlci/2
215         WRITE(numicb,*) "central i line:"
216         WRITE(numicb,*) "j processor"
217         WRITE(numicb,*) (INT(src_calving_hflx(ji,jj)), jj=1,jpj)
218         WRITE(numicb,*) "j point"
219         WRITE(numicb,*) (INT(src_calving(ji,jj)), jj=1,jpj)
220         IF( npolj > 0 ) THEN
221            WRITE(numicb,*) 'north fold destination points '
222            WRITE(numicb,*) nicbfldpts
223            WRITE(numicb,*) 'north fold destination procs  '
224            WRITE(numicb,*) nicbflddest
225            WRITE(numicb,*) 'north fold destination proclist  '
226            WRITE(numicb,*) nicbfldproc
227         ENDIF
228         CALL flush(numicb)
229      ENDIF
230     
231      src_calving     (:,:) = 0._wp
232      src_calving_hflx(:,:) = 0._wp
233
234      ! assign each new iceberg with a unique number constructed from the processor number
235      ! and incremented by the total number of processors
236      num_bergs(:) = 0
237      num_bergs(1) = narea - jpnij
238
239      ! when not generating test icebergs we need to setup calving file
240      IF( nn_test_icebergs < 0 .OR. ln_use_calving ) THEN
241         !
242         ! maximum distribution class array does not change in time so read it once
243         cl_sdist = TRIM( cn_dir )//TRIM( sn_icb%clname )
244         CALL iom_open ( cl_sdist, inum )                              ! open file
245         ivar = iom_varid( inum, 'maxclass', ldstop=.FALSE. )
246         IF( ivar > 0 ) THEN
247            CALL iom_get  ( inum, jpdom_data, 'maxclass', src_calving )   ! read the max distribution array
248            berg_grid%maxclass(:,:) = INT( src_calving )
249            src_calving(:,:) = 0._wp
250         ENDIF
251         CALL iom_close( inum )                                     ! close file
252         !
253         IF( nn_verbose_level > 0) THEN
254            WRITE(numicb,*)
255            WRITE(numicb,*) '          calving read in a file'
256         ENDIF
257         ALLOCATE( sf_icb(1), STAT=istat1 )         ! Create sf_icb structure (calving)
258         ALLOCATE( sf_icb(1)%fnow(jpi,jpj,1), STAT=istat2 )
259         ALLOCATE( sf_icb(1)%fdta(jpi,jpj,1,2), STAT=istat3 )
260         IF( istat1+istat2+istat3 > 0 ) THEN
261            CALL ctl_stop( 'sbc_icb: unable to allocate sf_icb structure' )   ;   RETURN
262         ENDIF
263         !                                          ! fill sf_icb with the namelist (sn_icb) and control print
264         CALL fld_fill( sf_icb, (/ sn_icb /), cn_dir, 'icb_init', 'read calving data', 'namicb' )
265         !
266      ENDIF
267
268      IF( .NOT.ln_rstart ) THEN
269         IF( nn_test_icebergs > 0 )   CALL icb_ini_gen()
270      ELSE
271         IF( nn_test_icebergs > 0 ) THEN
272            CALL icb_ini_gen()
273         ELSE
274            CALL icb_rst_read()
275            l_restarted_bergs = .TRUE.
276         ENDIF
277      ENDIF
278      !
279      IF( nn_sample_rate .GT. 0 ) CALL icb_trj_init( nitend )
280      !
281      CALL icb_dia_init()
282      !
283      IF( nn_verbose_level >= 2 )   CALL icb_utl_print('icb_init, initial status', nit000-1)
284      !
285   END SUBROUTINE icb_init
286
287
288   SUBROUTINE icb_ini_gen()
289      !!----------------------------------------------------------------------
290      !!                  ***  ROUTINE icb_ini_gen  ***
291      !!
292      !! ** Purpose :   iceberg generation
293      !!
294      !! ** Method  : - at each grid point of the test box supplied in the namelist
295      !!                generate an iceberg in one class determined by the value of
296      !!                parameter nn_test_icebergs
297      !!----------------------------------------------------------------------
298      INTEGER                         ::   ji, jj, ibergs
299      TYPE(iceberg)                   ::   localberg ! NOT a pointer but an actual local variable
300      TYPE(point)                     ::   localpt
301      INTEGER                         ::   iyr, imon, iday, ihr, imin, isec
302      INTEGER                         ::   iberg
303      !!----------------------------------------------------------------------
304
305      ! For convenience
306      iberg = nn_test_icebergs
307
308      ! call get_date(Time, iyr, imon, iday, ihr, imin, isec)
309      ! Convert nemo time variables from dom_oce into local versions
310      iyr  = nyear
311      imon = nmonth
312      iday = nday
313      ihr = INT(nsec_day/3600)
314      imin = INT((nsec_day-ihr*3600)/60)
315      isec = nsec_day - ihr*3600 - imin*60
316
317      ! no overlap for icebergs since we want only one instance of each across the whole domain
318      ! so restrict area of interest
319      ! use tmask here because tmask_i has been doctored on one side of the north fold line
320
321      DO jj = nicbdj, nicbej
322         DO ji = nicbdi, nicbei
323            IF( tmask(ji,jj,1) > 0._wp        .AND.                                       &
324                rn_test_box(1) < glamt(ji,jj) .AND. glamt(ji,jj) < rn_test_box(2) .AND.   &
325                rn_test_box(3) < gphit(ji,jj) .AND. gphit(ji,jj) < rn_test_box(4) ) THEN
326               localberg%mass_scaling = rn_mass_scaling(iberg)
327               localpt%xi = REAL( mig(ji), wp )
328               localpt%yj = REAL( mjg(jj), wp )
329               localpt%lon = icb_utl_bilin(glamt, localpt%xi, localpt%yj, 'T' )
330               localpt%lat = icb_utl_bilin(gphit, localpt%xi, localpt%yj, 'T' )
331               localpt%mass      = rn_initial_mass     (iberg)
332               localpt%thickness = rn_initial_thickness(iberg)
333               localpt%width  = first_width (iberg)
334               localpt%length = first_length(iberg)
335               localpt%year = iyr
336               localpt%day = REAL(iday,wp)+(REAL(ihr,wp)+REAL(imin,wp)/60._wp)/24._wp
337               localpt%mass_of_bits = 0._wp
338               localpt%heat_density = 0._wp
339               localpt%uvel = 0._wp
340               localpt%vvel = 0._wp
341               CALL icb_utl_incr()
342               localberg%number(:) = num_bergs(:)
343               call icb_utl_add(localberg, localpt)
344            ENDIF
345         END DO
346      END DO
347      !
348      ibergs = icb_utl_count()
349      CALL mpp_sum('icbini', ibergs)
350      IF( nn_verbose_level > 0) THEN
351         WRITE(numicb,'(a,i6,a)') 'diamonds, icb_ini_gen: ',ibergs,' were generated'
352      ENDIF
353      !
354   END SUBROUTINE icb_ini_gen
355
356
357   SUBROUTINE icb_nam
358      !!----------------------------------------------------------------------
359      !!                     ***  ROUTINE icb_nam  ***
360      !!
361      !! ** Purpose :   read iceberg namelist and print the variables.
362      !!
363      !! ** input   : - namberg namelist
364      !!----------------------------------------------------------------------
365      INTEGER  ::   jn      ! dummy loop indices
366      INTEGER  ::   ios     ! Local integer output status for namelist read
367      REAL(wp) ::   zfact   ! local scalar
368      !
369      NAMELIST/namberg/ ln_icebergs    , ln_bergdia     , nn_sample_rate      , rn_initial_mass      ,   &
370         &              rn_distribution, rn_mass_scaling, rn_initial_thickness, nn_verbose_write     ,   &
371         &              rn_rho_bergs   , rn_LoW_ratio   , nn_verbose_level    , ln_operator_splitting,   &
372         &              rn_bits_erosion_fraction        , rn_sicn_shift       , ln_passive_mode      ,   &
373         &              ln_time_average_weight          , nn_test_icebergs    , rn_test_box          ,   &
374         &              ln_use_calving , rn_speed_limit , cn_dir, sn_icb
375      !!----------------------------------------------------------------------
376
377#if defined key_agrif
378      IF(lwp) THEN
379         WRITE(numout,*)
380         WRITE(numout,*) 'icb_nam : AGRIF is not compatible with namelist namberg :  '
381         WRITE(numout,*) '~~~~~~~   definition of rn_initial_mass(nclasses) with nclasses as PARAMETER '
382         WRITE(numout,*)
383         WRITE(numout,*) '   ==>>>   force  NO icebergs used. The namelist namberg is not read'
384      ENDIF
385      ln_icebergs = .false.     
386      RETURN
387#else
388      IF(lwp) THEN
389         WRITE(numout,*)
390         WRITE(numout,*) 'icb_nam : iceberg initialization through namberg namelist read'
391         WRITE(numout,*) '~~~~~~~~ '
392      ENDIF
393#endif   
394      !                             !==  read namelist  ==!
395      REWIND( numnam_ref )              ! Namelist namberg in reference namelist : Iceberg parameters
396      READ  ( numnam_ref, namberg, IOSTAT = ios, ERR = 901)
397901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namberg in reference namelist', lwp )
398      REWIND( numnam_cfg )              ! Namelist namberg in configuration namelist : Iceberg parameters
399      READ  ( numnam_cfg, namberg, IOSTAT = ios, ERR = 902 )
400902   IF( ios >  0 ) CALL ctl_nam ( ios , 'namberg in configuration namelist', lwp )
401      IF(lwm) WRITE ( numond, namberg )
402      !
403      IF(lwp) WRITE(numout,*)
404      IF( ln_icebergs ) THEN
405         IF(lwp) WRITE(numout,*) '   ==>>>   icebergs are used'
406      ELSE
407         IF(lwp) WRITE(numout,*) '   ==>>>   No icebergs used'
408         RETURN
409      ENDIF
410      !
411      IF( nn_test_icebergs > nclasses ) THEN
412         IF(lwp) WRITE(numout,*)
413         IF(lwp) WRITE(numout,*) '   ==>>>   Resetting of nn_test_icebergs to ', nclasses
414         nn_test_icebergs = nclasses
415      ENDIF
416      !
417      IF( nn_test_icebergs < 0 .AND. .NOT. ln_use_calving ) THEN
418         IF(lwp) WRITE(numout,*)
419         IF(lwp) WRITE(numout,*) '   ==>>>   Resetting ln_use_calving to .true. since we are not using test icebergs'
420         ln_use_calving = .true.
421      ENDIF
422      !
423      IF(lwp) THEN                  ! control print
424         WRITE(numout,*)
425         WRITE(numout,*) 'icb_nam : iceberg initialization through namberg namelist read'
426         WRITE(numout,*) '~~~~~~~~ '
427         WRITE(numout,*) '   Calculate budgets                                            ln_bergdia       = ', ln_bergdia
428         WRITE(numout,*) '   Period between sampling of position for trajectory storage   nn_sample_rate = ', nn_sample_rate
429         WRITE(numout,*) '   Mass thresholds between iceberg classes (kg)                 rn_initial_mass     ='
430         DO jn = 1, nclasses
431            WRITE(numout,'(a,f15.2)') '                                                                ', rn_initial_mass(jn)
432         ENDDO
433         WRITE(numout,*) '   Fraction of calving to apply to this class (non-dim)         rn_distribution     ='
434         DO jn = 1, nclasses
435            WRITE(numout,'(a,f10.4)') '                                                                ', rn_distribution(jn)
436         END DO
437         WRITE(numout,*) '   Ratio between effective and real iceberg mass (non-dim)      rn_mass_scaling     = '
438         DO jn = 1, nclasses
439            WRITE(numout,'(a,f10.2)') '                                                                ', rn_mass_scaling(jn)
440         END DO
441         WRITE(numout,*) '   Total thickness of newly calved bergs (m)                    rn_initial_thickness = '
442         DO jn = 1, nclasses
443            WRITE(numout,'(a,f10.2)') '                                                                ', rn_initial_thickness(jn)
444         END DO
445         WRITE(numout,*) '   Timesteps between verbose messages                           nn_verbose_write    = ', nn_verbose_write
446
447         WRITE(numout,*) '   Density of icebergs                           rn_rho_bergs  = ', rn_rho_bergs
448         WRITE(numout,*) '   Initial ratio L/W for newly calved icebergs   rn_LoW_ratio  = ', rn_LoW_ratio
449         WRITE(numout,*) '   Turn on more verbose output                          level  = ', nn_verbose_level
450         WRITE(numout,*) '   Use first order operator splitting for thermodynamics    ',   &
451            &                    'use_operator_splitting = ', ln_operator_splitting
452         WRITE(numout,*) '   Fraction of erosion melt flux to divert to bergy bits    ',   &
453            &                    'bits_erosion_fraction = ', rn_bits_erosion_fraction
454
455         WRITE(numout,*) '   Shift of sea-ice concentration in erosion flux modulation ',   &
456            &                    '(0<sicn_shift<1)    rn_sicn_shift  = ', rn_sicn_shift
457         WRITE(numout,*) '   Do not add freshwater flux from icebergs to ocean                ',   &
458            &                    '                  passive_mode            = ', ln_passive_mode
459         WRITE(numout,*) '   Time average the weight on the ocean   time_average_weight       = ', ln_time_average_weight
460         WRITE(numout,*) '   Create icebergs in absence of a restart file   nn_test_icebergs  = ', nn_test_icebergs
461         WRITE(numout,*) '                   in lon/lat box                                   = ', rn_test_box
462         WRITE(numout,*) '   Use calving data even if nn_test_icebergs > 0    ln_use_calving  = ', ln_use_calving
463         WRITE(numout,*) '   CFL speed limit for a berg            speed_limit                = ', rn_speed_limit
464         WRITE(numout,*) '   Writing Iceberg status information to icebergs.stat file        '
465      ENDIF
466      !
467      ! ensure that the sum of berg input distribution is equal to one
468      zfact = SUM( rn_distribution )
469      IF( zfact /= 1._wp .AND. 0_wp /= zfact ) THEN
470         rn_distribution(:) = rn_distribution(:) / zfact
471         IF(lwp) THEN
472            WRITE(numout,*)
473            WRITE(numout,*) '      ==>>> CAUTION:    sum of berg input distribution = ', zfact
474            WRITE(numout,*) '            *******     redistribution has been rescaled'
475            WRITE(numout,*) '                        updated berg distribution is :'
476            DO jn = 1, nclasses
477               WRITE(numout,'(a,f10.4)') '                                   ',rn_distribution(jn)
478            END DO
479         ENDIF
480      ENDIF
481      IF( MINVAL( rn_distribution(:) ) < 0._wp ) THEN
482         CALL ctl_stop( 'icb_nam: a negative rn_distribution value encountered ==>> change your namelist namberg' )
483      ENDIF
484      !
485   END SUBROUTINE icb_nam
486
487   !!======================================================================
488END MODULE icbini
Note: See TracBrowser for help on using the repository browser.