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.
diahsb.F90 in branches/UKMO/test_moci_test_suite/NEMOGCM/NEMO/OPA_SRC/DIA – NEMO

source: branches/UKMO/test_moci_test_suite/NEMOGCM/NEMO/OPA_SRC/DIA/diahsb.F90 @ 8243

Last change on this file since 8243 was 8243, checked in by andmirek, 7 years ago

#1914 working XIOS read, XIOS write and single processor read

File size: 20.5 KB
Line 
1MODULE diahsb
2   !!======================================================================
3   !!                       ***  MODULE  diahsb  ***
4   !! Ocean diagnostics: Heat, salt and volume budgets
5   !!======================================================================
6   !! History :  3.3  ! 2010-09  (M. Leclair)  Original code
7   !!                 ! 2012-10  (C. Rousset)  add iom_put
8   !!----------------------------------------------------------------------
9
10   !!----------------------------------------------------------------------
11   !!   dia_hsb       : Diagnose the conservation of ocean heat and salt contents, and volume
12   !!   dia_hsb_rst   : Read or write DIA file in restart file
13   !!   dia_hsb_init  : Initialization of the conservation diagnostic
14   !!----------------------------------------------------------------------
15   USE oce             ! ocean dynamics and tracers
16   USE dom_oce         ! ocean space and time domain
17   USE phycst          ! physical constants
18   USE sbc_oce         ! surface thermohaline fluxes
19   USE sbcrnf          ! river runoff
20   USE sbcisf          ! ice shelves
21   USE domvvl          ! vertical scale factors
22   USE traqsr          ! penetrative solar radiation
23   USE trabbc          ! bottom boundary condition
24   USE trabbc          ! bottom boundary condition
25   USE bdy_par         ! (for lk_bdy)
26   USE restart         ! ocean restart
27   !
28   USE iom             ! I/O manager
29   USE in_out_manager  ! I/O manager
30   USE lib_fortran     ! glob_sum
31   USE lib_mpp         ! distributed memory computing library
32   USE timing          ! preformance summary
33   USE wrk_nemo        ! work arrays
34   USE iom_def, ONLY : lxios_read
35   USE iom_def, ONLY : lwxios
36
37   IMPLICIT NONE
38   PRIVATE
39
40   PUBLIC   dia_hsb        ! routine called by step.F90
41   PUBLIC   dia_hsb_init   ! routine called by nemogcm.F90
42   PUBLIC   dia_hsb_rst    ! routine called by step.F90
43
44   LOGICAL, PUBLIC ::   ln_diahsb   !: check the heat and salt budgets
45
46   REAL(wp) ::   surf_tot              ! ocean surface
47   REAL(wp) ::   frc_t, frc_s, frc_v   ! global forcing trends
48   REAL(wp) ::   frc_wn_t, frc_wn_s    ! global forcing trends
49   !
50   REAL(wp), DIMENSION(:,:)  , ALLOCATABLE ::   surf          , ssh_ini          !
51   REAL(wp), DIMENSION(:,:)  , ALLOCATABLE ::   ssh_hc_loc_ini, ssh_sc_loc_ini   !
52   REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   hc_loc_ini, sc_loc_ini, e3t_ini  !
53
54   !! * Substitutions
55#  include "domzgr_substitute.h90"
56#  include "vectopt_loop_substitute.h90"
57   !!----------------------------------------------------------------------
58   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
59   !! $Id$
60   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
61   !!----------------------------------------------------------------------
62CONTAINS
63
64   SUBROUTINE dia_hsb( kt )
65      !!---------------------------------------------------------------------------
66      !!                  ***  ROUTINE dia_hsb  ***
67      !!     
68      !! ** Purpose: Compute the ocean global heat content, salt content and volume conservation
69      !!
70      !! ** Method : - Compute the deviation of heat content, salt content and volume
71      !!             at the current time step from their values at nit000
72      !!             - Compute the contribution of forcing and remove it from these deviations
73      !!
74      !!---------------------------------------------------------------------------
75      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
76      !
77      INTEGER    ::   ji, jj, jk                  ! dummy loop indice
78      REAL(wp)   ::   zdiff_hc    , zdiff_sc      ! heat and salt content variations
79      REAL(wp)   ::   zdiff_hc1   , zdiff_sc1     !  -         -     -        -
80      REAL(wp)   ::   zdiff_v1    , zdiff_v2      ! volume variation
81      REAL(wp)   ::   zerr_hc1    , zerr_sc1      ! heat and salt content misfit
82      REAL(wp)   ::   zvol_tot                    ! volume
83      REAL(wp)   ::   z_frc_trd_t , z_frc_trd_s   !    -     -
84      REAL(wp)   ::   z_frc_trd_v                 !    -     -
85      REAL(wp)   ::   z_wn_trd_t , z_wn_trd_s     !    -     -
86      REAL(wp)   ::   z_ssh_hc , z_ssh_sc         !    -     -
87      REAL(wp), DIMENSION(:,:), POINTER ::   z2d0, z2d1
88      !!---------------------------------------------------------------------------
89      IF( nn_timing == 1 )   CALL timing_start('dia_hsb')     
90      CALL wrk_alloc( jpi,jpj,   z2d0, z2d1 )
91      !
92      tsn(:,:,:,1) = tsn(:,:,:,1) * tmask(:,:,:) ; tsb(:,:,:,1) = tsb(:,:,:,1) * tmask(:,:,:) ;
93      tsn(:,:,:,2) = tsn(:,:,:,2) * tmask(:,:,:) ; tsb(:,:,:,2) = tsb(:,:,:,2) * tmask(:,:,:) ;
94      ! ------------------------- !
95      ! 1 - Trends due to forcing !
96      ! ------------------------- !
97      z_frc_trd_v = r1_rau0 * glob_sum( - ( emp(:,:) - rnf(:,:) + fwfisf(:,:) ) * surf(:,:) ) ! volume fluxes
98      z_frc_trd_t =           glob_sum( sbc_tsc(:,:,jp_tem) * surf(:,:) )                               ! heat fluxes
99      z_frc_trd_s =           glob_sum( sbc_tsc(:,:,jp_sal) * surf(:,:) )                               ! salt fluxes
100      ! Add runoff    heat & salt input
101      IF( ln_rnf    )   z_frc_trd_t = z_frc_trd_t + glob_sum( rnf_tsc(:,:,jp_tem) * surf(:,:) )
102      IF( ln_rnf_sal)   z_frc_trd_s = z_frc_trd_s + glob_sum( rnf_tsc(:,:,jp_sal) * surf(:,:) )
103      ! Add ice shelf heat & salt input
104      IF( nn_isf .GE. 1 )  THEN
105          z_frc_trd_t = z_frc_trd_t + glob_sum( risf_tsc(:,:,jp_tem) * surf(:,:) )
106          z_frc_trd_s = z_frc_trd_s + glob_sum( risf_tsc(:,:,jp_sal) * surf(:,:) )
107      ENDIF
108
109      ! Add penetrative solar radiation
110      IF( ln_traqsr )   z_frc_trd_t = z_frc_trd_t + r1_rau0_rcp * glob_sum( qsr     (:,:) * surf(:,:) )
111      ! Add geothermal heat flux
112      IF( ln_trabbc )   z_frc_trd_t = z_frc_trd_t +               glob_sum( qgh_trd0(:,:) * surf(:,:) )
113      !
114      IF( .NOT. lk_vvl ) THEN
115         IF ( ln_isfcav ) THEN
116            DO ji=1,jpi
117               DO jj=1,jpj
118                  z2d0(ji,jj) = surf(ji,jj) * wn(ji,jj,mikt(ji,jj)) * tsb(ji,jj,mikt(ji,jj),jp_tem)
119                  z2d1(ji,jj) = surf(ji,jj) * wn(ji,jj,mikt(ji,jj)) * tsb(ji,jj,mikt(ji,jj),jp_sal)
120               ENDDO
121            ENDDO
122         ELSE
123            z2d0(:,:) = surf(:,:) * wn(:,:,1) * tsb(:,:,1,jp_tem)
124            z2d1(:,:) = surf(:,:) * wn(:,:,1) * tsb(:,:,1,jp_sal)
125         END IF
126         z_wn_trd_t = - glob_sum( z2d0 ) 
127         z_wn_trd_s = - glob_sum( z2d1 )
128      ENDIF
129
130      frc_v = frc_v + z_frc_trd_v * rdt
131      frc_t = frc_t + z_frc_trd_t * rdt
132      frc_s = frc_s + z_frc_trd_s * rdt
133      !                                          ! Advection flux through fixed surface (z=0)
134      IF( .NOT. lk_vvl ) THEN
135         frc_wn_t = frc_wn_t + z_wn_trd_t * rdt
136         frc_wn_s = frc_wn_s + z_wn_trd_s * rdt
137      ENDIF
138
139      ! ------------------------ !
140      ! 2 -  Content variations !
141      ! ------------------------ !
142      zdiff_v2 = 0._wp
143      zdiff_hc = 0._wp
144      zdiff_sc = 0._wp
145
146      ! volume variation (calculated with ssh)
147      zdiff_v1 = glob_sum( surf(:,:) * ( sshn(:,:) - ssh_ini(:,:) ) )
148
149      ! heat & salt content variation (associated with ssh)
150      IF( .NOT. lk_vvl ) THEN
151         IF ( ln_isfcav ) THEN
152            DO ji = 1, jpi
153               DO jj = 1, jpj
154                  z2d0(ji,jj) = surf(ji,jj) * ( tsn(ji,jj,mikt(ji,jj),jp_tem) * sshn(ji,jj) - ssh_hc_loc_ini(ji,jj) ) 
155                  z2d1(ji,jj) = surf(ji,jj) * ( tsn(ji,jj,mikt(ji,jj),jp_sal) * sshn(ji,jj) - ssh_sc_loc_ini(ji,jj) ) 
156               END DO
157            END DO
158         ELSE
159            z2d0(:,:) = surf(:,:) * ( tsn(:,:,1,jp_tem) * sshn(:,:) - ssh_hc_loc_ini(:,:) ) 
160            z2d1(:,:) = surf(:,:) * ( tsn(:,:,1,jp_sal) * sshn(:,:) - ssh_sc_loc_ini(:,:) ) 
161         END IF
162         z_ssh_hc = glob_sum( z2d0 ) 
163         z_ssh_sc = glob_sum( z2d1 ) 
164      ENDIF
165
166      DO jk = 1, jpkm1
167         ! volume variation (calculated with scale factors)
168         zdiff_v2 = zdiff_v2 + glob_sum( surf(:,:) * tmask(:,:,jk) &
169            &                           * ( fse3t_n(:,:,jk) - e3t_ini(:,:,jk) ) )
170         ! heat content variation
171         zdiff_hc = zdiff_hc + glob_sum(  surf(:,:) * tmask(:,:,jk) & 
172            &                           * ( fse3t_n(:,:,jk) * tsn(:,:,jk,jp_tem) - hc_loc_ini(:,:,jk) ) )
173         ! salt content variation
174         zdiff_sc = zdiff_sc + glob_sum(  surf(:,:) * tmask(:,:,jk)   &
175            &                           * ( fse3t_n(:,:,jk) * tsn(:,:,jk,jp_sal) - sc_loc_ini(:,:,jk) ) )
176      ENDDO
177
178      ! Substract forcing from heat content, salt content and volume variations
179      zdiff_v1 = zdiff_v1 - frc_v
180      IF( lk_vvl )   zdiff_v2 = zdiff_v2 - frc_v
181      zdiff_hc = zdiff_hc - frc_t
182      zdiff_sc = zdiff_sc - frc_s
183      IF( .NOT. lk_vvl ) THEN
184         zdiff_hc1 = zdiff_hc + z_ssh_hc 
185         zdiff_sc1 = zdiff_sc + z_ssh_sc
186         zerr_hc1  = z_ssh_hc - frc_wn_t
187         zerr_sc1  = z_ssh_sc - frc_wn_s
188      ENDIF
189
190      ! ----------------------- !
191      ! 3 - Diagnostics writing !
192      ! ----------------------- !
193      zvol_tot = 0._wp                    ! total ocean volume (calculated with scale factors)
194      DO jk = 1, jpkm1
195         zvol_tot  = zvol_tot + glob_sum( surf(:,:) * tmask(:,:,jk) * fse3t_n(:,:,jk) )
196      END DO
197
198!!gm to be added ?
199!      IF( .NOT. lk_vvl ) THEN            ! fixed volume, add the ssh contribution
200!        zvol_tot = zvol_tot + glob_sum( surf(:,:) * sshn(:,:) )
201!      ENDIF
202!!gm end
203
204      IF( lk_vvl ) THEN
205        CALL iom_put( 'bgtemper' , zdiff_hc / zvol_tot )              ! Temperature variation (C)
206        CALL iom_put( 'bgsaline' , zdiff_sc / zvol_tot )              ! Salinity    variation (psu)
207        CALL iom_put( 'bgheatco' , zdiff_hc * 1.e-20 * rau0 * rcp )   ! Heat content variation (1.e20 J)
208        CALL iom_put( 'bgsaltco' , zdiff_sc * 1.e-9    )              ! Salt content variation (psu*km3)
209        CALL iom_put( 'bgvolssh' , zdiff_v1 * 1.e-9    )              ! volume ssh variation (km3) 
210        CALL iom_put( 'bgvole3t' , zdiff_v2 * 1.e-9    )              ! volume e3t variation (km3) 
211        CALL iom_put( 'bgfrcvol' , frc_v    * 1.e-9    )              ! vol - surface forcing (km3)
212        CALL iom_put( 'bgfrctem' , frc_t / zvol_tot    )              ! hc  - surface forcing (C)
213        CALL iom_put( 'bgfrcsal' , frc_s / zvol_tot    )              ! sc  - surface forcing (psu)
214      ELSE
215        CALL iom_put( 'bgtemper' , zdiff_hc1 / zvol_tot)              ! Heat content variation (C)
216        CALL iom_put( 'bgsaline' , zdiff_sc1 / zvol_tot)              ! Salt content variation (psu)
217        CALL iom_put( 'bgheatco' , zdiff_hc1 * 1.e-20 * rau0 * rcp )  ! Heat content variation (1.e20 J)
218        CALL iom_put( 'bgsaltco' , zdiff_sc1 * 1.e-9    )             ! Salt content variation (psu*km3)
219        CALL iom_put( 'bgvolssh' , zdiff_v1 * 1.e-9    )              ! volume ssh variation (km3) 
220        CALL iom_put( 'bgfrcvol' , frc_v    * 1.e-9    )              ! vol - surface forcing (km3)
221        CALL iom_put( 'bgfrctem' , frc_t / zvol_tot    )              ! hc  - surface forcing (C)
222        CALL iom_put( 'bgfrcsal' , frc_s / zvol_tot    )              ! sc  - surface forcing (psu)
223        CALL iom_put( 'bgmistem' , zerr_hc1 / zvol_tot )              ! hc  - error due to free surface (C)
224        CALL iom_put( 'bgmissal' , zerr_sc1 / zvol_tot )              ! sc  - error due to free surface (psu)
225      ENDIF
226      !
227      IF( lrst_oce )   CALL dia_hsb_rst( kt, 'WRITE' )
228
229      CALL wrk_dealloc( jpi,jpj,   z2d0, z2d1 )
230
231      IF( nn_timing == 1 )   CALL timing_stop('dia_hsb')
232      !
233   END SUBROUTINE dia_hsb
234
235
236   SUBROUTINE dia_hsb_rst( kt, cdrw )
237     !!---------------------------------------------------------------------
238     !!                   ***  ROUTINE limdia_rst  ***
239     !!                     
240     !! ** Purpose :   Read or write DIA file in restart file
241     !!
242     !! ** Method  :   use of IOM library
243     !!----------------------------------------------------------------------
244     INTEGER         , INTENT(in) ::   kt     ! ocean time-step
245     CHARACTER(len=*), INTENT(in) ::   cdrw   ! "READ"/"WRITE" flag
246     !
247     INTEGER ::   ji, jj, jk   ! dummy loop indices
248     INTEGER ::   id1          ! local integers
249     !!----------------------------------------------------------------------
250     !
251     IF( TRIM(cdrw) == 'READ' ) THEN        ! Read/initialise
252        IF( ln_rstart ) THEN                   !* Read the restart file
253           !id1 = iom_varid( numror, 'frc_vol'  , ldstop = .FALSE. )
254           !
255           IF(lwp) WRITE(numout,*) '~~~~~~~'
256           IF(lwp) WRITE(numout,*) ' dia_hsb_rst at it= ', kt,' date= ', ndastp
257           IF(lwp) WRITE(numout,*) '~~~~~~~'
258           CALL iom_get( numror, 'frc_v', frc_v, lrxios = lxios_read  )
259           CALL iom_get( numror, 'frc_t', frc_t, lrxios = lxios_read )
260           CALL iom_get( numror, 'frc_s', frc_s, lrxios = lxios_read )
261           IF( .NOT. lk_vvl ) THEN
262              CALL iom_get( numror, 'frc_wn_t', frc_wn_t, lrxios = lxios_read )
263              CALL iom_get( numror, 'frc_wn_s', frc_wn_s, lrxios = lxios_read )
264           ENDIF
265           CALL iom_get( numror, jpdom_autoglo, 'ssh_ini', ssh_ini, lrxios = lxios_read )
266           CALL iom_get( numror, jpdom_autoglo, 'e3t_ini', e3t_ini, lrxios = lxios_read )
267           CALL iom_get( numror, jpdom_autoglo, 'hc_loc_ini', hc_loc_ini, lrxios = lxios_read )
268           CALL iom_get( numror, jpdom_autoglo, 'sc_loc_ini', sc_loc_ini, lrxios = lxios_read )
269           IF( .NOT. lk_vvl ) THEN
270              CALL iom_get( numror, jpdom_autoglo, 'ssh_hc_loc_ini', ssh_hc_loc_ini, lrxios = lxios_read )
271              CALL iom_get( numror, jpdom_autoglo, 'ssh_sc_loc_ini', ssh_sc_loc_ini, lrxios = lxios_read )
272           ENDIF
273       ELSE
274          IF(lwp) WRITE(numout,*) '~~~~~~~'
275          IF(lwp) WRITE(numout,*) ' dia_hsb at initial state '
276          IF(lwp) WRITE(numout,*) '~~~~~~~'
277          ssh_ini(:,:) = sshn(:,:)                                       ! initial ssh
278          DO jk = 1, jpk
279             e3t_ini   (:,:,jk) = fse3t_n(:,:,jk)                        ! initial vertical scale factors
280             hc_loc_ini(:,:,jk) = tsn(:,:,jk,jp_tem) * fse3t_n(:,:,jk)   ! initial heat content
281             sc_loc_ini(:,:,jk) = tsn(:,:,jk,jp_sal) * fse3t_n(:,:,jk)   ! initial salt content
282          END DO
283          frc_v = 0._wp                                           ! volume       trend due to forcing
284          frc_t = 0._wp                                           ! heat content   -    -   -    -   
285          frc_s = 0._wp                                           ! salt content   -    -   -    -       
286          IF( .NOT. lk_vvl ) THEN
287             IF ( ln_isfcav ) THEN
288                DO ji=1,jpi
289                   DO jj=1,jpj
290                      ssh_hc_loc_ini(ji,jj) = tsn(ji,jj,mikt(ji,jj),jp_tem) * sshn(ji,jj)   ! initial heat content in ssh
291                      ssh_sc_loc_ini(ji,jj) = tsn(ji,jj,mikt(ji,jj),jp_sal) * sshn(ji,jj)   ! initial salt content in ssh
292                   ENDDO
293                ENDDO
294             ELSE
295                ssh_hc_loc_ini(:,:) = tsn(:,:,1,jp_tem) * sshn(:,:)   ! initial heat content in ssh
296                ssh_sc_loc_ini(:,:) = tsn(:,:,1,jp_sal) * sshn(:,:)   ! initial salt content in ssh
297             END IF
298             frc_wn_t = 0._wp                                       ! initial heat content misfit due to free surface
299             frc_wn_s = 0._wp                                       ! initial salt content misfit due to free surface
300          ENDIF
301       ENDIF
302
303     ELSEIF( TRIM(cdrw) == 'WRITE' ) THEN   ! Create restart file
304        !                                   ! -------------------
305        IF(lwp) WRITE(numout,*) '~~~~~~~'
306        IF(lwp) WRITE(numout,*) ' dia_hsb_rst at it= ', kt,' date= ', ndastp
307        IF(lwp) WRITE(numout,*) '~~~~~~~'
308        IF( lwxios ) CALL iom_swap(      wxios_context          )
309        CALL iom_rstput( kt, nitrst, numrow, 'frc_v'   , frc_v, lxios = lwxios)
310        CALL iom_rstput( kt, nitrst, numrow, 'frc_t'   , frc_t, lxios = lwxios)
311        CALL iom_rstput( kt, nitrst, numrow, 'frc_s'   , frc_s, lxios = lwxios)
312        IF( .NOT. lk_vvl ) THEN
313           CALL iom_rstput( kt, nitrst, numrow, 'frc_wn_t', frc_wn_t, lxios = lwxios)
314           CALL iom_rstput( kt, nitrst, numrow, 'frc_wn_s', frc_wn_s, lxios = lwxios )
315        ENDIF
316        CALL iom_rstput( kt, nitrst, numrow, 'ssh_ini', ssh_ini, lxios = lwxios)
317        CALL iom_rstput( kt, nitrst, numrow, 'e3t_ini', e3t_ini, lxios = lwxios)
318        CALL iom_rstput( kt, nitrst, numrow, 'hc_loc_ini', hc_loc_ini, lxios = lwxios)
319        CALL iom_rstput( kt, nitrst, numrow, 'sc_loc_ini', sc_loc_ini, lxios = lwxios)
320        IF( .NOT. lk_vvl ) THEN
321           CALL iom_rstput( kt, nitrst, numrow, 'ssh_hc_loc_ini', ssh_hc_loc_ini, lxios = lwxios )
322           CALL iom_rstput( kt, nitrst, numrow, 'ssh_sc_loc_ini', ssh_sc_loc_ini, lxios = lwxios )
323        ENDIF
324        !
325        IF( lwxios ) CALL iom_swap(      cxios_context          )
326     ENDIF
327     !
328   END SUBROUTINE dia_hsb_rst
329
330
331   SUBROUTINE dia_hsb_init
332      !!---------------------------------------------------------------------------
333      !!                  ***  ROUTINE dia_hsb  ***
334      !!     
335      !! ** Purpose: Initialization for the heat salt volume budgets
336      !!
337      !! ** Method : Compute initial heat content, salt content and volume
338      !!
339      !! ** Action : - Compute initial heat content, salt content and volume
340      !!             - Initialize forcing trends
341      !!             - Compute coefficients for conversion
342      !!---------------------------------------------------------------------------
343      INTEGER ::   jk       ! dummy loop indice
344      INTEGER ::   ierror   ! local integer
345      INTEGER ::   ios
346      !
347      NAMELIST/namhsb/ ln_diahsb
348      !!----------------------------------------------------------------------
349
350      IF(lwp) THEN
351         WRITE(numout,*)
352         WRITE(numout,*) 'dia_hsb_init : check the heat and salt budgets'
353         WRITE(numout,*) '~~~~~~~~ '
354      ENDIF
355
356      REWIND( numnam_ref )              ! Namelist namhsb in reference namelist
357      READ  ( numnam_ref, namhsb, IOSTAT = ios, ERR = 901)
358901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namhsb in reference namelist', lwp )
359
360      REWIND( numnam_cfg )              ! Namelist namhsb in configuration namelist
361      READ  ( numnam_cfg, namhsb, IOSTAT = ios, ERR = 902 )
362902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namhsb in configuration namelist', lwp )
363      IF(lwm) WRITE ( numond, namhsb )
364
365      !
366      IF(lwp) THEN                   ! Control print
367         WRITE(numout,*)
368         WRITE(numout,*) 'dia_hsb_init : check the heat and salt budgets'
369         WRITE(numout,*) '~~~~~~~~~~~~'
370         WRITE(numout,*) '   Namelist namhsb : set hsb parameters'
371         WRITE(numout,*) '      Switch for hsb diagnostic (T) or not (F)  ln_diahsb  = ', ln_diahsb
372         WRITE(numout,*)
373      ENDIF
374
375      IF( .NOT. ln_diahsb )   RETURN
376         !      IF( .NOT. lk_mpp_rep ) &
377         !        CALL ctl_stop (' Your global mpp_sum if performed in single precision - 64 bits -', &
378         !             &         ' whereas the global sum to be precise must be done in double precision ',&
379         !             &         ' please add key_mpp_rep')
380
381      ! ------------------- !
382      ! 1 - Allocate memory !
383      ! ------------------- !
384      ALLOCATE( hc_loc_ini(jpi,jpj,jpk), sc_loc_ini(jpi,jpj,jpk), &
385         &      e3t_ini(jpi,jpj,jpk), surf(jpi,jpj),  ssh_ini(jpi,jpj), STAT=ierror )
386      IF( ierror > 0 ) THEN
387         CALL ctl_stop( 'dia_hsb: unable to allocate hc_loc_ini' )   ;   RETURN
388      ENDIF
389
390      IF(.NOT. lk_vvl ) ALLOCATE( ssh_hc_loc_ini(jpi,jpj), ssh_sc_loc_ini(jpi,jpj),STAT=ierror )
391      IF( ierror > 0 ) THEN
392         CALL ctl_stop( 'dia_hsb: unable to allocate hc_loc_ini' )   ;   RETURN
393      ENDIF
394
395      ! ----------------------------------------------- !
396      ! 2 - Time independant variables and file opening !
397      ! ----------------------------------------------- !
398      IF(lwp) WRITE(numout,*) "dia_hsb: heat salt volume budgets activated"
399      IF(lwp) WRITE(numout,*) '~~~~~~~'
400      surf(:,:) = e1t(:,:) * e2t(:,:) * tmask_i(:,:)      ! masked surface grid cell area
401      surf_tot  = glob_sum( surf(:,:) )                                       ! total ocean surface area
402
403      IF( lk_bdy ) CALL ctl_warn( 'dia_hsb does not take open boundary fluxes into account' )         
404      !
405      ! ---------------------------------- !
406      ! 4 - initial conservation variables !
407      ! ---------------------------------- !
408      CALL dia_hsb_rst( nit000, 'READ' )  !* read or initialize all required files
409      !
410   END SUBROUTINE dia_hsb_init
411
412   !!======================================================================
413END MODULE diahsb
Note: See TracBrowser for help on using the repository browser.