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

source: trunk/NEMOGCM/NEMO/OPA_SRC/DIA/diahsb.F90 @ 7753

Last change on this file since 7753 was 7753, checked in by mocavero, 7 years ago

Reverting trunk to remove OpenMP

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