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.
icbrun.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/icbrun.F90 @ 3339

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

NEMO branch dev_r3337_NOCS10_ICB: add new iceberg sub-directory ICB

File size: 8.1 KB
Line 
1MODULE icbrun
2
3   !!======================================================================
4   !!                       ***  MODULE  icbrun  ***
5   !! Ocean physics:  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
27   USE icb_oce        ! define iceberg arrays
28   USE icbini         ! iceberg initialisation routines
29   USE icbutl         ! iceberg utility routines
30   USE icbrst         ! iceberg restart routines
31   USE icbdyn         ! iceberg dynamics (ie advection) routines
32   USE icbclv         ! iceberg calving routines
33   USE icbthm         ! iceberg thermodynamics routines
34   USE icblbc         ! iceberg lateral boundary routines (including mpp)
35   USE icbtrj         ! iceberg trajectory I/O routines
36   USE icbdia         ! iceberg budget
37
38   IMPLICIT NONE
39   PRIVATE
40
41   PUBLIC   icb_stp        ! routine called in xxx.F90 module
42   PUBLIC   icb_end        ! routine called in xxx.F90 module
43
44CONTAINS
45
46   SUBROUTINE icb_stp( kt )
47      !!----------------------------------------------------------------------
48      !!                  ***  ROUTINE icb_stp  ***
49      !!
50      !! ** Purpose :   iceberg time stepping.
51      !!
52      !! ** Method  : - blah blah
53      !!----------------------------------------------------------------------
54      INTEGER, INTENT( in )           ::  kt
55      !
56      INTEGER                         ::   iyr, imon, iday, ihr, imin, isec
57      LOGICAL                         ::   lerr, sample_traj, l_budget, l_verbose
58      !!----------------------------------------------------------------------
59      !! start of timestep housekeeping
60
61      ktberg = kt
62
63      ! read calving data
64      IF( nn_test_icebergs < 0 ) THEN
65         !
66         CALL fld_read ( kt, 1, sf_icb )
67         p_calving(:,:)      = sf_icb(1)%fnow(:,:,1)    ! calving in km^3/year (water equivalent)
68         p_calving_hflx(:,:) = 0._wp                    ! NO heat flux for now
69         !
70      ENDIF
71
72      berg_grid%floating_melt(:,:) = 0._wp
73
74      ! anything that needs to be reset to zero each timestep for budgets is dealt with here
75      CALL icb_budget_step()
76
77      ! Manage time
78      ! Convert nemo time variables from dom_oce into local versions
79      ! Note that yearday function assumes 365 day year!!
80      iyr = nyear
81      imon = nmonth
82      iday = nday
83      ihr = INT(nsec_day/3600)
84      imin = INT((nsec_day-ihr*3600)/60)
85      isec = nsec_day - ihr*3600 - imin*60
86      current_year    = iyr
87      current_yearday = yearday(imon, iday, ihr, imin, isec)
88
89      l_verbose = .FALSE.
90      IF( nn_verbose_write .GT. 0 .AND. &
91          MOD(kt-1,nn_verbose_write ) == 0 ) l_verbose = nn_verbose_level >= 0
92      IF( l_verbose ) WRITE(numicb,9100) iyr, imon, iday, ihr, imin, isec, &
93                                        current_year, current_yearday
94 9100 FORMAT('y,m,d=',3i5,' h,m,s=',3i5,' yr,yrdy=',i5,f8.3)
95
96      ! copy nemo forcing arrays into iceberg versions with extra halo
97      ! only necessary for variables not on T points
98      CALL copy_flds()
99
100      !!----------------------------------------------------------------------
101      !! process icebergs
102
103      ! Accumulate ice from calving
104      CALL accumulate_calving( kt )
105
106      ! Calve excess stored ice into icebergs
107      CALL calve_icebergs()
108
109      !                               !==  For each berg, evolve  ==!
110      !
111      IF( ASSOCIATED(first_berg) )   CALL evolve_icebergs()     ! ice berg dynamics
112
113      IF( lk_mpp ) THEN
114                                      CALL mpp_send_bergs ()     ! Send bergs to other PEs
115      ELSE
116                                      CALL lbc_send_bergs()      ! Deal with any cyclic boundaries in non-mpp case
117      ENDIF
118
119      IF( ASSOCIATED(first_berg) )   CALL thermodynamics ( kt ) ! Ice berg thermodynamics (melting) + rolling
120
121      !!----------------------------------------------------------------------
122      !! end of timestep housekeeping
123
124      sample_traj = .FALSE.
125      IF( nn_sample_rate .GT. 0 .AND. MOD(kt-1,nn_sample_rate) == 0 )   sample_traj = .TRUE.
126      IF( sample_traj .AND.   &
127          ASSOCIATED(first_berg) )   CALL traj_write    ( kt )  ! For each berg, record trajectory
128
129      ! Gridded diagnostics
130      ! To get these iom_put's and those preceding to actually do something
131      ! use key_iomput in cpp file and create content for XML file
132
133      CALL iom_put( "calving"           , berg_grid%calving      (:,:)   )  ! 'calving mass input'
134      CALL iom_put( "berg_floating_melt", berg_grid%floating_melt(:,:)   )  ! 'Melt rate of icebergs + bits' , 'kg/m2/s'
135      CALL iom_put( "berg_stored_ice"   , berg_grid%stored_ice   (:,:,:) )  ! 'Accumulated ice mass by class', 'kg'
136
137      ! write out mean budgets - not sure why this happens before they are calculated - sga !
138      CALL icb_budget_put()
139
140      ! Dump icebergs to screen
141      if ( nn_verbose_level >= 2 ) CALL print_bergs( 'icb_stp, status', kt )
142
143      ! Diagnose budgets
144      l_budget = .FALSE.
145      IF( nn_verbose_write .GT. 0 .AND. MOD(kt-1,nn_verbose_write) == 0 )   l_budget = ln_bergdia
146      CALL icb_budget( l_budget )
147
148      IF( MOD(kt,nn_stock) == 0 ) THEN
149         CALL icebergs_write_restart( kt )
150         IF( nn_sample_rate .GT. 0 ) CALL traj_sync()
151      ENDIF
152
153      !
154   END SUBROUTINE icb_stp
155
156   !!-------------------------------------------------------------------------
157
158   SUBROUTINE icb_end( kt )
159
160      ! Arguments
161      INTEGER, INTENT( in )  :: kt
162      ! Local variables
163      TYPE(iceberg), POINTER :: this, next
164
165      ! expanded arrays for bilinear interpolation
166      DEALLOCATE( uo_e )
167      DEALLOCATE( vo_e )
168      DEALLOCATE( ff_e )
169      DEALLOCATE( ua_e )
170      DEALLOCATE( va_e )
171#if defined key_lim2 || defined key_lim3
172      DEALLOCATE( ui_e )
173      DEALLOCATE( vi_e )
174#endif
175      DEALLOCATE( ssh_e )
176
177      DEALLOCATE( icbfldpts )
178
179      IF( lk_mpp ) CALL dealloc_buffers()
180
181      IF (.NOT.ASSOCIATED(berg_grid)) RETURN
182
183      ! only write a restart if not done in icb_stp
184      IF( MOD(kt,nn_stock) .NE. 0 ) CALL icebergs_write_restart( kt )
185
186      ! finish with trajectories if they were written
187      IF( nn_sample_rate .GT. 0 ) CALL traj_end()
188
189      ! Delete bergs and structures
190      this=>first_berg
191      DO WHILE (ASSOCIATED(this))
192        next=>this%next
193        CALL destroy_iceberg(this)
194        this=>next
195      ENDDO
196
197      CALL icb_budget_end()
198
199      DEALLOCATE(berg_grid%calving)
200      DEALLOCATE(berg_grid%calving_hflx)
201      DEALLOCATE(berg_grid%stored_heat)
202      DEALLOCATE(berg_grid%floating_melt)
203      DEALLOCATE(berg_grid%maxclass)
204      DEALLOCATE(berg_grid%tmp)
205      DEALLOCATE(berg_grid%stored_ice)
206      DEALLOCATE(berg_grid)
207
208      DEALLOCATE(initial_width)
209      DEALLOCATE(initial_length)
210
211      IF (lwp) WRITE(numout,'(a,i6)') 'icebergs: icb_end complete',narea
212      CALL flush( numicb )
213      CLOSE( numicb )
214
215   END SUBROUTINE icb_end
216
217   !!-------------------------------------------------------------------------
218
219END MODULE icbrun
Note: See TracBrowser for help on using the repository browser.