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.
icbstp.F90 in branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB – NEMO

source: branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icbstp.F90 @ 3387

Last change on this file since 3387 was 3387, checked in by sga, 12 years ago

NEMO branch dev_r3337_NOCS10_ICB: add timing routines around whole iceberg calculation - how bad can it get?

File size: 7.2 KB
Line 
1MODULE icbstp
2
3   !!======================================================================
4   !!                       ***  MODULE  icbstp  ***
5   !! Icebergs:  initialise variables for iceberg tracking
6   !!======================================================================
7   !! History : 3.3.1 !  2010-01  (Martin&Adcroft) Original code
8   !!            -    !  2011-03  (Madec)          Part conversion to NEMO form
9   !!            -    !                            Removal of mapping from another grid
10   !!            -    !  2011-04  (Alderson)       Split into separate modules
11   !!            -    !                            Move budgets to icbdia routine
12   !!            -    !  2011-05  (Alderson)       Add call to copy forcing arrays
13   !!            -    !                            into icb copies with haloes
14   !!----------------------------------------------------------------------
15   !!----------------------------------------------------------------------
16   !!   icb_stp       : start iceberg tracking
17   !!   icb_end       : end   iceberg tracking
18   !!----------------------------------------------------------------------
19   USE par_oce        ! nemo parameters
20   USE dom_oce        ! ocean domain
21   USE sbc_oce        ! ocean surface forcing
22   USE phycst
23   USE in_out_manager ! nemo IO
24   USE lib_mpp
25   USE iom
26   USE timing         ! timing
27
28   USE icb_oce        ! define iceberg arrays
29   USE icbini         ! iceberg initialisation routines
30   USE icbutl         ! iceberg utility routines
31   USE icbrst         ! iceberg restart routines
32   USE icbdyn         ! iceberg dynamics (ie advection) routines
33   USE icbclv         ! iceberg calving routines
34   USE icbthm         ! iceberg thermodynamics routines
35   USE icblbc         ! iceberg lateral boundary routines (including mpp)
36   USE icbtrj         ! iceberg trajectory I/O routines
37   USE icbdia         ! iceberg budget
38
39   IMPLICIT NONE
40   PRIVATE
41
42   PUBLIC   icb_stp        ! routine called in sbcmod.F90 module
43   PUBLIC   icb_end        ! routine called in nemogcm.F90 module
44
45   !!----------------------------------------------------------------------
46   !! NEMO/OPA 3.3 , NEMO Consortium (2011)
47   !! $Id:$
48   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
49   !!----------------------------------------------------------------------
50CONTAINS
51
52   SUBROUTINE icb_stp( kt )
53      !!----------------------------------------------------------------------
54      !!                  ***  ROUTINE icb_stp  ***
55      !!
56      !! ** Purpose :   iceberg time stepping.
57      !!
58      !! ** Method  : - top level routine to do things in the correct order
59      !!----------------------------------------------------------------------
60      INTEGER, INTENT(in) ::   kt   ! time step index
61      !
62      LOGICAL ::   ll_sample_traj, ll_budget, ll_verbose   ! local logical
63      !!----------------------------------------------------------------------
64      !
65      IF( nn_timing == 1 ) CALL timing_start('icb_stp')
66
67      !! start of timestep housekeeping
68
69      nktberg = kt
70
71      IF( nn_test_icebergs < 0 ) THEN      ! read calving data
72         !
73         CALL fld_read ( kt, 1, sf_icb )
74         src_calving(:,:)      = sf_icb(1)%fnow(:,:,1)    ! calving in km^3/year (water equivalent)
75         src_calving_hflx(:,:) = 0._wp                    ! NO heat flux for now
76         !
77      ENDIF
78
79      berg_grid%floating_melt(:,:) = 0._wp
80
81      ! anything that needs to be reset to zero each timestep for budgets is dealt with here
82      CALL icb_dia_step()
83
84      ll_verbose = .FALSE.
85      IF( nn_verbose_write > 0 .AND. &
86          MOD(kt-1,nn_verbose_write ) == 0 )   ll_verbose = nn_verbose_level >= 0
87
88      ! write out time
89      IF( ll_verbose ) WRITE(numicb,9100) nktberg, ndastp, nsec_day
90 9100 FORMAT('kt= ',i8, ' day= ',i8,' secs=',i8)
91
92      ! copy nemo forcing arrays into iceberg versions with extra halo
93      ! only necessary for variables not on T points
94      CALL icb_utl_copy()
95
96      !!----------------------------------------------------------------------
97      !! process icebergs
98
99                                     CALL icb_clv_flx( kt )   ! Accumulate ice from calving
100
101                                     CALL icb_clv()           ! Calve excess stored ice into icebergs
102
103
104!                               !==  For each berg, evolve  ==!
105      !
106      IF( ASSOCIATED(first_berg) )   CALL icb_dyn()           ! ice berg dynamics
107
108      IF( lk_mpp ) THEN          ;   CALL icb_lbc_mpp()       ! Send bergs to other PEs
109      ELSE                       ;   CALL icb_lbc()           ! Deal with any cyclic boundaries in non-mpp case
110      ENDIF
111
112      IF( ASSOCIATED(first_berg) )   CALL icb_thm( kt )       ! Ice berg thermodynamics (melting) + rolling
113
114      !!----------------------------------------------------------------------
115      !! end of timestep housekeeping
116
117      ll_sample_traj = .FALSE.
118      IF( nn_sample_rate > 0 .AND. MOD(kt-1,nn_sample_rate) == 0 )   ll_sample_traj = .TRUE.
119      IF( ll_sample_traj .AND.   &
120          ASSOCIATED(first_berg) )   CALL icb_trj_write( kt )  ! For each berg, record trajectory
121
122      ! Gridded diagnostics
123      ! To get these iom_put's and those preceding to actually do something
124      ! use key_iomput in cpp file and create content for XML file
125
126      CALL iom_put( "calving"           , berg_grid%calving      (:,:)   )  ! 'calving mass input'
127      CALL iom_put( "berg_floating_melt", berg_grid%floating_melt(:,:)   )  ! 'Melt rate of icebergs + bits' , 'kg/m2/s'
128      CALL iom_put( "berg_stored_ice"   , berg_grid%stored_ice   (:,:,:) )  ! 'Accumulated ice mass by class', 'kg'
129
130      ! store mean budgets
131      CALL icb_dia_put()
132
133      ! Dump icebergs to screen
134      if ( nn_verbose_level >= 2 )   CALL icb_utl_print( 'icb_stp, status', kt )
135
136      ! Diagnose budgets
137      ll_budget = .FALSE.
138      IF( nn_verbose_write > 0 .AND. MOD(kt-1,nn_verbose_write) == 0 )   ll_budget = ln_bergdia
139      CALL icb_dia( ll_budget )
140
141      IF( MOD(kt,nn_stock) == 0 ) THEN
142         CALL icb_rst_write( kt )
143         IF( nn_sample_rate > 0 )   CALL icb_trj_sync()
144      ENDIF
145
146      IF( nn_timing == 1 ) CALL timing_stop('icb_stp')
147      !
148   END SUBROUTINE icb_stp
149
150
151   SUBROUTINE icb_end( kt )
152      !!----------------------------------------------------------------------
153      !!                  ***  ROUTINE icb_end  ***
154      !!
155      !! ** Purpose :   close iceberg files
156      !!
157      !!----------------------------------------------------------------------
158      INTEGER, INTENT( in )  :: kt
159      !!----------------------------------------------------------------------
160
161      ! only write a restart if not done in icb_stp
162      IF( MOD(kt,nn_stock) .NE. 0 ) CALL icb_rst_write( kt )
163
164      ! finish with trajectories if they were written
165      IF( nn_sample_rate .GT. 0 ) CALL icb_trj_end()
166
167      IF(lwp)   WRITE(numout,'(a,i6)') 'icebergs: icb_end complete', narea
168      CALL flush( numicb )
169      CLOSE( numicb )
170      !
171   END SUBROUTINE icb_end
172
173   !!-------------------------------------------------------------------------
174
175END MODULE icbstp
Note: See TracBrowser for help on using the repository browser.