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/2017/dev_r8600_xios_write/NEMOGCM/NEMO/OPA_SRC/DIA – NEMO

source: branches/2017/dev_r8600_xios_write/NEMOGCM/NEMO/OPA_SRC/DIA/diahsb.F90 @ 8651

Last change on this file since 8651 was 8651, checked in by andmirek, 6 years ago

change names of the new subroutines

  • Property svn:keywords set to Id
File size: 21.0 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 restart         ! ocean restart
26   USE bdy_oce   , ONLY: ln_bdy
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 : lwxios
35
36   IMPLICIT NONE
37   PRIVATE
38
39   PUBLIC   dia_hsb        ! routine called by step.F90
40   PUBLIC   dia_hsb_init   ! routine called by nemogcm.F90
41
42   LOGICAL, PUBLIC ::   ln_diahsb   !: check the heat and salt budgets
43
44   REAL(wp) ::   surf_tot              ! ocean surface
45   REAL(wp) ::   frc_t, frc_s, frc_v   ! global forcing trends
46   REAL(wp) ::   frc_wn_t, frc_wn_s    ! global forcing trends
47   !
48   REAL(wp), DIMENSION(:,:)  , ALLOCATABLE ::   surf 
49   REAL(wp), DIMENSION(:,:)  , ALLOCATABLE ::   surf_ini      , ssh_ini          !
50   REAL(wp), DIMENSION(:,:)  , ALLOCATABLE ::   ssh_hc_loc_ini, ssh_sc_loc_ini   !
51   REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   hc_loc_ini, sc_loc_ini, e3t_ini  !
52
53   !! * Substitutions
54#  include "vectopt_loop_substitute.h90"
55   !!----------------------------------------------------------------------
56   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
57   !! $Id$
58   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
59   !!----------------------------------------------------------------------
60CONTAINS
61
62   SUBROUTINE dia_hsb( kt )
63      !!---------------------------------------------------------------------------
64      !!                  ***  ROUTINE dia_hsb  ***
65      !!     
66      !! ** Purpose: Compute the ocean global heat content, salt content and volume conservation
67      !!
68      !! ** Method : - Compute the deviation of heat content, salt content and volume
69      !!             at the current time step from their values at nit000
70      !!             - Compute the contribution of forcing and remove it from these deviations
71      !!
72      !!---------------------------------------------------------------------------
73      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
74      !
75      INTEGER    ::   ji, jj, jk                  ! dummy loop indice
76      REAL(wp)   ::   zdiff_hc    , zdiff_sc      ! heat and salt content variations
77      REAL(wp)   ::   zdiff_hc1   , zdiff_sc1     !  -         -     -        -
78      REAL(wp)   ::   zdiff_v1    , zdiff_v2      ! volume variation
79      REAL(wp)   ::   zerr_hc1    , zerr_sc1      ! heat and salt content misfit
80      REAL(wp)   ::   zvol_tot                    ! volume
81      REAL(wp)   ::   z_frc_trd_t , z_frc_trd_s   !    -     -
82      REAL(wp)   ::   z_frc_trd_v                 !    -     -
83      REAL(wp)   ::   z_wn_trd_t , z_wn_trd_s     !    -     -
84      REAL(wp)   ::   z_ssh_hc , z_ssh_sc         !    -     -
85      REAL(wp), DIMENSION(:,:), POINTER ::   z2d0, z2d1
86      !!---------------------------------------------------------------------------
87      IF( nn_timing == 1 )   CALL timing_start('dia_hsb')     
88      !
89      CALL wrk_alloc( jpi,jpj,   z2d0, z2d1 )
90      !
91      tsn(:,:,:,1) = tsn(:,:,:,1) * tmask(:,:,:) ; tsb(:,:,:,1) = tsb(:,:,:,1) * tmask(:,:,:) ;
92      tsn(:,:,:,2) = tsn(:,:,:,2) * tmask(:,:,:) ; tsb(:,:,:,2) = tsb(:,:,:,2) * tmask(:,:,:) ;
93      ! ------------------------- !
94      ! 1 - Trends due to forcing !
95      ! ------------------------- !
96      z_frc_trd_v = r1_rau0 * glob_sum( - ( emp(:,:) - rnf(:,:) + fwfisf(:,:) ) * surf(:,:) ) ! volume fluxes
97      z_frc_trd_t =           glob_sum( sbc_tsc(:,:,jp_tem) * surf(:,:) )                               ! heat fluxes
98      z_frc_trd_s =           glob_sum( sbc_tsc(:,:,jp_sal) * surf(:,:) )                               ! salt fluxes
99      ! Add runoff    heat & salt input
100      IF( ln_rnf    )   z_frc_trd_t = z_frc_trd_t + glob_sum( rnf_tsc(:,:,jp_tem) * surf(:,:) )
101      IF( ln_rnf_sal)   z_frc_trd_s = z_frc_trd_s + glob_sum( rnf_tsc(:,:,jp_sal) * surf(:,:) )
102      ! Add ice shelf heat & salt input
103      IF( ln_isf    ) z_frc_trd_t = z_frc_trd_t + glob_sum( risf_tsc(:,:,jp_tem) * surf(:,:) )
104      ! Add penetrative solar radiation
105      IF( ln_traqsr )   z_frc_trd_t = z_frc_trd_t + r1_rau0_rcp * glob_sum( qsr     (:,:) * surf(:,:) )
106      ! Add geothermal heat flux
107      IF( ln_trabbc )   z_frc_trd_t = z_frc_trd_t +               glob_sum( qgh_trd0(:,:) * surf(:,:) )
108      !
109      IF( ln_linssh ) THEN
110         IF( ln_isfcav ) THEN
111            DO ji=1,jpi
112               DO jj=1,jpj
113                  z2d0(ji,jj) = surf(ji,jj) * wn(ji,jj,mikt(ji,jj)) * tsb(ji,jj,mikt(ji,jj),jp_tem)
114                  z2d1(ji,jj) = surf(ji,jj) * wn(ji,jj,mikt(ji,jj)) * tsb(ji,jj,mikt(ji,jj),jp_sal)
115               END DO
116            END DO
117         ELSE
118            z2d0(:,:) = surf(:,:) * wn(:,:,1) * tsb(:,:,1,jp_tem)
119            z2d1(:,:) = surf(:,:) * wn(:,:,1) * tsb(:,:,1,jp_sal)
120         END IF
121         z_wn_trd_t = - glob_sum( z2d0 ) 
122         z_wn_trd_s = - glob_sum( z2d1 )
123      ENDIF
124
125      frc_v = frc_v + z_frc_trd_v * rdt
126      frc_t = frc_t + z_frc_trd_t * rdt
127      frc_s = frc_s + z_frc_trd_s * rdt
128      !                                          ! Advection flux through fixed surface (z=0)
129      IF( ln_linssh ) THEN
130         frc_wn_t = frc_wn_t + z_wn_trd_t * rdt
131         frc_wn_s = frc_wn_s + z_wn_trd_s * rdt
132      ENDIF
133
134      ! ------------------------ !
135      ! 2 -  Content variations !
136      ! ------------------------ !
137      ! glob_sum_full is needed because you keep the full interior domain to compute the sum (iscpl)
138      zdiff_v2 = 0._wp
139      zdiff_hc = 0._wp
140      zdiff_sc = 0._wp
141
142      ! volume variation (calculated with ssh)
143      zdiff_v1 = glob_sum_full( surf(:,:) * sshn(:,:) - surf_ini(:,:) * ssh_ini(:,:) )
144
145      ! heat & salt content variation (associated with ssh)
146      IF( ln_linssh ) THEN
147         IF( ln_isfcav ) THEN
148            DO ji = 1, jpi
149               DO jj = 1, jpj
150                  z2d0(ji,jj) = surf(ji,jj) * ( tsn(ji,jj,mikt(ji,jj),jp_tem) * sshn(ji,jj) - ssh_hc_loc_ini(ji,jj) ) 
151                  z2d1(ji,jj) = surf(ji,jj) * ( tsn(ji,jj,mikt(ji,jj),jp_sal) * sshn(ji,jj) - ssh_sc_loc_ini(ji,jj) ) 
152               END DO
153            END DO
154         ELSE
155            z2d0(:,:) = surf(:,:) * ( tsn(:,:,1,jp_tem) * sshn(:,:) - ssh_hc_loc_ini(:,:) ) 
156            z2d1(:,:) = surf(:,:) * ( tsn(:,:,1,jp_sal) * sshn(:,:) - ssh_sc_loc_ini(:,:) ) 
157         END IF
158         z_ssh_hc = glob_sum_full( z2d0 ) 
159         z_ssh_sc = glob_sum_full( z2d1 ) 
160      ENDIF
161
162      DO jk = 1, jpkm1
163         ! volume variation (calculated with scale factors)
164         zdiff_v2 = zdiff_v2 + glob_sum_full( surf(:,:) * tmask(:,:,jk)            &
165            &                           * e3t_n(:,:,jk) - surf_ini(:,:) * e3t_ini(:,:,jk) )
166         ! heat content variation
167         zdiff_hc = zdiff_hc + glob_sum_full(  surf(:,:) * tmask(:,:,jk)                                   & 
168            &                           * e3t_n(:,:,jk) * tsn(:,:,jk,jp_tem) - surf_ini(:,:) * hc_loc_ini(:,:,jk) ) 
169         ! salt content variation
170         zdiff_sc = zdiff_sc + glob_sum_full( surf    (:,:) * tmask(:,:,jk)                           &
171                                        * e3t_n(:,:,jk) * tsn(:,:,jk,jp_sal) - surf_ini(:,:) * sc_loc_ini(:,:,jk) )
172      ENDDO
173
174      ! ------------------------ !
175      ! 3 -  Drifts              !
176      ! ------------------------ !
177      zdiff_v1 = zdiff_v1 - frc_v
178      IF( .NOT.ln_linssh )   zdiff_v2 = zdiff_v2 - frc_v
179      zdiff_hc = zdiff_hc - frc_t
180      zdiff_sc = zdiff_sc - frc_s
181      IF( ln_linssh ) THEN
182         zdiff_hc1 = zdiff_hc + z_ssh_hc 
183         zdiff_sc1 = zdiff_sc + z_ssh_sc
184         zerr_hc1  = z_ssh_hc - frc_wn_t
185         zerr_sc1  = z_ssh_sc - frc_wn_s
186      ENDIF
187
188      ! ----------------------- !
189      ! 4 - Diagnostics writing !
190      ! ----------------------- !
191      zvol_tot = 0._wp                    ! total ocean volume (calculated with scale factors)
192      DO jk = 1, jpkm1
193         zvol_tot  = zvol_tot + glob_sum_full( surf(:,:) * tmask(:,:,jk) * e3t_n(:,:,jk) )
194      END DO
195
196!!gm to be added ?
197!      IF( ln_linssh ) THEN            ! fixed volume, add the ssh contribution
198!        zvol_tot = zvol_tot + glob_sum( surf(:,:) * sshn(:,:) )
199!      ENDIF
200!!gm end
201
202      CALL iom_put(   'bgfrcvol' , frc_v    * 1.e-9    )              ! vol - surface forcing (km3)
203      CALL iom_put(   'bgfrctem' , frc_t    * rau0 * rcp * 1.e-20 )   ! hc  - surface forcing (1.e20 J)
204      CALL iom_put(   'bgfrchfx' , frc_t    * rau0 * rcp /  &         ! hc  - surface forcing (W/m2)
205         &                       ( surf_tot * kt * rdt )        )
206      CALL iom_put(   'bgfrcsal' , frc_s    * 1.e-9    )              ! sc  - surface forcing (psu*km3)
207
208      IF( .NOT. ln_linssh ) THEN
209        CALL iom_put( 'bgtemper' , zdiff_hc / zvol_tot )              ! Temperature drift     (C)
210        CALL iom_put( 'bgsaline' , zdiff_sc / zvol_tot )              ! Salinity    drift     (pss)
211        CALL iom_put( 'bgheatco' , zdiff_hc * 1.e-20 * rau0 * rcp )   ! Heat content drift    (1.e20 J)
212        CALL iom_put( 'bgheatfx' , zdiff_hc * rau0 * rcp /  &         ! Heat flux drift       (W/m2)
213           &                       ( surf_tot * kt * rdt )        )
214        CALL iom_put( 'bgsaltco' , zdiff_sc * 1.e-9    )              ! Salt content drift    (psu*km3)
215        CALL iom_put( 'bgvolssh' , zdiff_v1 * 1.e-9    )              ! volume ssh drift      (km3) 
216        CALL iom_put( 'bgvole3t' , zdiff_v2 * 1.e-9    )              ! volume e3t drift      (km3) 
217      ELSE
218        CALL iom_put( 'bgtemper' , zdiff_hc1 / zvol_tot)              ! Heat content drift    (C)
219        CALL iom_put( 'bgsaline' , zdiff_sc1 / zvol_tot)              ! Salt content drift    (pss)
220        CALL iom_put( 'bgheatco' , zdiff_hc1 * 1.e-20 * rau0 * rcp )  ! Heat content drift    (1.e20 J)
221        CALL iom_put( 'bgheatfx' , zdiff_hc1 * rau0 * rcp /  &        ! Heat flux drift       (W/m2)
222           &                       ( surf_tot * kt * rdt )         )
223        CALL iom_put( 'bgsaltco' , zdiff_sc1 * 1.e-9    )             ! Salt content drift    (psu*km3)
224        CALL iom_put( 'bgvolssh' , zdiff_v1 * 1.e-9    )              ! volume ssh drift      (km3) 
225        CALL iom_put( 'bgmistem' , zerr_hc1 / zvol_tot )              ! hc  - error due to free surface (C)
226        CALL iom_put( 'bgmissal' , zerr_sc1 / zvol_tot )              ! sc  - error due to free surface (psu)
227      ENDIF
228      !
229      IF( lrst_oce )   CALL dia_hsb_rst( kt, 'WRITE' )
230      !
231      CALL wrk_dealloc( jpi,jpj,   z2d0, z2d1 )
232      !
233      IF( nn_timing == 1 )   CALL timing_stop('dia_hsb')
234      !
235   END SUBROUTINE dia_hsb
236
237
238   SUBROUTINE dia_hsb_rst( kt, cdrw )
239     !!---------------------------------------------------------------------
240     !!                   ***  ROUTINE dia_hsb_rst  ***
241     !!                     
242     !! ** Purpose :   Read or write DIA file in restart file
243     !!
244     !! ** Method  :   use of IOM library
245     !!----------------------------------------------------------------------
246     INTEGER         , INTENT(in) ::   kt     ! ocean time-step
247     CHARACTER(len=*), INTENT(in) ::   cdrw   ! "READ"/"WRITE" flag
248     !
249     INTEGER ::   ji, jj, jk   ! dummy loop indices
250     !!----------------------------------------------------------------------
251     !
252     IF( TRIM(cdrw) == 'READ' ) THEN        ! Read/initialise
253        IF( ln_rstart ) THEN                   !* Read the restart file
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 )
259           CALL iom_get( numror, 'frc_t', frc_t )
260           CALL iom_get( numror, 'frc_s', frc_s )
261           IF( ln_linssh ) THEN
262              CALL iom_get( numror, 'frc_wn_t', frc_wn_t )
263              CALL iom_get( numror, 'frc_wn_s', frc_wn_s )
264           ENDIF
265           CALL iom_get( numror, jpdom_autoglo, 'surf_ini', surf_ini ) ! ice sheet coupling
266           CALL iom_get( numror, jpdom_autoglo, 'ssh_ini', ssh_ini(:,:) )
267           CALL iom_get( numror, jpdom_autoglo, 'e3t_ini', e3t_ini(:,:,:) )
268           CALL iom_get( numror, jpdom_autoglo, 'hc_loc_ini', hc_loc_ini(:,:,:) )
269           CALL iom_get( numror, jpdom_autoglo, 'sc_loc_ini', sc_loc_ini(:,:,:) )
270           IF( ln_linssh ) THEN
271              CALL iom_get( numror, jpdom_autoglo, 'ssh_hc_loc_ini', ssh_hc_loc_ini(:,:) )
272              CALL iom_get( numror, jpdom_autoglo, 'ssh_sc_loc_ini', ssh_sc_loc_ini(:,:) )
273           ENDIF
274       ELSE
275          IF(lwp) WRITE(numout,*) '~~~~~~~'
276          IF(lwp) WRITE(numout,*) ' dia_hsb at initial state '
277          IF(lwp) WRITE(numout,*) '~~~~~~~'
278          surf_ini(:,:) = e1e2t(:,:) * tmask_i(:,:)         ! initial ocean surface
279          ssh_ini(:,:) = sshn(:,:)                          ! initial ssh
280          DO jk = 1, jpk
281             ! if ice sheet/oceqn coupling, need to mask ini variables here (mask could change at the next NEMO instance).
282             e3t_ini   (:,:,jk) = e3t_n(:,:,jk)                      * tmask(:,:,jk)  ! initial vertical scale factors
283             hc_loc_ini(:,:,jk) = tsn(:,:,jk,jp_tem) * e3t_n(:,:,jk) * tmask(:,:,jk)  ! initial heat content
284             sc_loc_ini(:,:,jk) = tsn(:,:,jk,jp_sal) * e3t_n(:,:,jk) * tmask(:,:,jk)  ! initial salt content
285          END DO
286          frc_v = 0._wp                                           ! volume       trend due to forcing
287          frc_t = 0._wp                                           ! heat content   -    -   -    -   
288          frc_s = 0._wp                                           ! salt content   -    -   -    -       
289          IF( ln_linssh ) THEN
290             IF ( ln_isfcav ) THEN
291                DO ji=1,jpi
292                   DO jj=1,jpj
293                      ssh_hc_loc_ini(ji,jj) = tsn(ji,jj,mikt(ji,jj),jp_tem) * sshn(ji,jj)   ! initial heat content in ssh
294                      ssh_sc_loc_ini(ji,jj) = tsn(ji,jj,mikt(ji,jj),jp_sal) * sshn(ji,jj)   ! initial salt content in ssh
295                   ENDDO
296                ENDDO
297             ELSE
298                ssh_hc_loc_ini(:,:) = tsn(:,:,1,jp_tem) * sshn(:,:)   ! initial heat content in ssh
299                ssh_sc_loc_ini(:,:) = tsn(:,:,1,jp_sal) * sshn(:,:)   ! initial salt content in ssh
300             END IF
301             frc_wn_t = 0._wp                                       ! initial heat content misfit due to free surface
302             frc_wn_s = 0._wp                                       ! initial salt content misfit due to free surface
303          ENDIF
304       ENDIF
305
306     ELSEIF( TRIM(cdrw) == 'WRITE' ) THEN   ! Create restart file
307        !                                   ! -------------------
308        IF(lwp) WRITE(numout,*) '~~~~~~~'
309        IF(lwp) WRITE(numout,*) ' dia_hsb_rst at it= ', kt,' date= ', ndastp
310        IF(lwp) WRITE(numout,*) '~~~~~~~'
311        IF( lwxios ) CALL iom_swap(      wxios_context          )
312        CALL iom_rstput( kt, nitrst, numrow, 'frc_v'   , frc_v, lxios = lwxios)
313        CALL iom_rstput( kt, nitrst, numrow, 'frc_t'   , frc_t, lxios = lwxios)
314        CALL iom_rstput( kt, nitrst, numrow, 'frc_s'   , frc_s, lxios = lwxios)
315        IF( ln_linssh ) THEN
316           CALL iom_rstput( kt, nitrst, numrow, 'frc_wn_t', frc_wn_t, lxios = lwxios)
317           CALL iom_rstput( kt, nitrst, numrow, 'frc_wn_s', frc_wn_s, lxios = lwxios )
318        ENDIF
319        CALL iom_rstput( kt, nitrst, numrow, 'surf_ini', surf_ini, lxios = lwxios )      ! ice sheet coupling
320        CALL iom_rstput( kt, nitrst, numrow, 'ssh_ini', ssh_ini(:,:), lxios = lwxios )
321        CALL iom_rstput( kt, nitrst, numrow, 'e3t_ini', e3t_ini(:,:,:), lxios = lwxios )
322        CALL iom_rstput( kt, nitrst, numrow, 'hc_loc_ini', hc_loc_ini(:,:,:), lxios = lwxios )
323        CALL iom_rstput( kt, nitrst, numrow, 'sc_loc_ini', sc_loc_ini(:,:,:), lxios = lwxios )
324        IF( ln_linssh ) THEN
325           CALL iom_rstput( kt, nitrst, numrow, 'ssh_hc_loc_ini', ssh_hc_loc_ini(:,:), lxios = lwxios )
326           CALL iom_rstput( kt, nitrst, numrow, 'ssh_sc_loc_ini', ssh_sc_loc_ini(:,:), lxios = lwxios )
327        ENDIF
328        !
329        IF( lwxios ) CALL iom_swap(      cxios_context          )
330     ENDIF
331     !
332   END SUBROUTINE dia_hsb_rst
333
334
335   SUBROUTINE dia_hsb_init
336      !!---------------------------------------------------------------------------
337      !!                  ***  ROUTINE dia_hsb  ***
338      !!     
339      !! ** Purpose: Initialization for the heat salt volume budgets
340      !!
341      !! ** Method : Compute initial heat content, salt content and volume
342      !!
343      !! ** Action : - Compute initial heat content, salt content and volume
344      !!             - Initialize forcing trends
345      !!             - Compute coefficients for conversion
346      !!---------------------------------------------------------------------------
347      INTEGER ::   ierror   ! local integer
348      INTEGER ::   ios
349      !!
350      NAMELIST/namhsb/ ln_diahsb
351      !!----------------------------------------------------------------------
352      !
353      REWIND( numnam_ref )              ! Namelist namhsb in reference namelist
354      READ  ( numnam_ref, namhsb, IOSTAT = ios, ERR = 901)
355901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namhsb in reference namelist', lwp )
356
357      REWIND( numnam_cfg )              ! Namelist namhsb in configuration namelist
358      READ  ( numnam_cfg, namhsb, IOSTAT = ios, ERR = 902 )
359902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namhsb in configuration namelist', lwp )
360      IF(lwm) WRITE ( numond, namhsb )
361
362      IF(lwp) THEN
363         WRITE(numout,*)
364         WRITE(numout,*) 'dia_hsb_init'
365         WRITE(numout,*) '~~~~~~~~ '
366         WRITE(numout,*) '  check the heat and salt budgets (T) or not (F)       ln_diahsb = ', ln_diahsb
367      ENDIF
368      !
369      IF( .NOT. ln_diahsb )   RETURN
370
371      IF(lwxios) THEN
372! define variables in restart file when writing with XIOS
373        CALL iom_set_rstw_var_active('frc_v')
374        CALL iom_set_rstw_var_active('frc_t')
375        CALL iom_set_rstw_var_active('frc_s')
376        IF( ln_linssh ) THEN
377           CALL iom_set_rstw_var_active('frc_wn_t')
378           CALL iom_set_rstw_var_active('frc_wn_s')
379        ENDIF
380        CALL iom_set_rstw_var_active('surf_ini')
381        CALL iom_set_rstw_var_active('ssh_ini')
382        CALL iom_set_rstw_var_active('e3t_ini')
383        CALL iom_set_rstw_var_active('hc_loc_ini')
384        CALL iom_set_rstw_var_active('sc_loc_ini')
385        IF( ln_linssh ) THEN
386           CALL iom_set_rstw_var_active('ssh_hc_loc_ini')
387           CALL iom_set_rstw_var_active('ssh_sc_loc_ini')
388        ENDIF
389      ENDIF
390      ! ------------------- !
391      ! 1 - Allocate memory !
392      ! ------------------- !
393      ALLOCATE( hc_loc_ini(jpi,jpj,jpk), sc_loc_ini(jpi,jpj,jpk), surf_ini(jpi,jpj), &
394         &      e3t_ini(jpi,jpj,jpk), surf(jpi,jpj),  ssh_ini(jpi,jpj), STAT=ierror  )
395      IF( ierror > 0 ) THEN
396         CALL ctl_stop( 'dia_hsb_init: unable to allocate hc_loc_ini' )   ;   RETURN
397      ENDIF
398
399      IF( ln_linssh )   ALLOCATE( ssh_hc_loc_ini(jpi,jpj), ssh_sc_loc_ini(jpi,jpj),STAT=ierror )
400      IF( ierror > 0 ) THEN
401         CALL ctl_stop( 'dia_hsb: unable to allocate ssh_hc_loc_ini' )   ;   RETURN
402      ENDIF
403
404      ! ----------------------------------------------- !
405      ! 2 - Time independant variables and file opening !
406      ! ----------------------------------------------- !
407      surf(:,:) = e1t(:,:) * e2t(:,:) * tmask_i(:,:)      ! masked surface grid cell area
408      surf_tot  = glob_sum( surf(:,:) )                   ! total ocean surface area
409
410      IF( ln_bdy ) CALL ctl_warn( 'dia_hsb_init: heat/salt budget does not consider open boundary fluxes' )         
411      !
412      ! ---------------------------------- !
413      ! 4 - initial conservation variables !
414      ! ---------------------------------- !
415      CALL dia_hsb_rst( nit000, 'READ' )  !* read or initialize all required files
416      !
417   END SUBROUTINE dia_hsb_init
418
419   !!======================================================================
420END MODULE diahsb
Note: See TracBrowser for help on using the repository browser.