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.
sbcfwb.F90 in trunk/NEMO/OPA_SRC/SBC – NEMO

source: trunk/NEMO/OPA_SRC/SBC/sbcfwb.F90 @ 1245

Last change on this file since 1245 was 1245, checked in by ctlod, 15 years ago

write a message and stop if parameter kn_fwb is set to zero, see ticket: #288

  • Property svn:keywords set to Id
File size: 6.9 KB
Line 
1MODULE sbcfwb
2   !!======================================================================
3   !!                       ***  MODULE  sbcfwb  ***
4   !! Ocean fluxes   : domain averaged freshwater budget
5   !!======================================================================
6   !! History :  8.2  !  01-02  (E. Durand)  Original code
7   !!            8.5  !  02-06  (G. Madec)  F90: Free form and module
8   !!            9.0  !  06-08  (G. Madec)  Surface module
9   !!----------------------------------------------------------------------
10
11   !!----------------------------------------------------------------------
12   !!   sbc_fwb      : freshwater budget for global ocean configurations
13   !!                  in free surface and forced mode
14   !!----------------------------------------------------------------------
15   USE oce             ! ocean dynamics and tracers
16   USE dom_oce         ! ocean space and time domain
17   USE sbc_oce         ! surface ocean boundary condition
18   USE phycst          ! physical constants
19   USE sbcrnf          ! ocean runoffs
20   USE daymod          ! calendar
21   USE in_out_manager  ! I/O manager
22   USE lib_mpp         ! distribued memory computing library
23
24   IMPLICIT NONE
25   PRIVATE
26
27   PUBLIC   sbc_fwb      ! routine called by step
28
29   REAL(wp) ::   a_fwb_b            ! annual domain averaged freshwater budget
30   REAL(wp) ::   a_fwb              ! for 2 year before (_b) and before year.
31   REAL(wp) ::   empold             ! empold to be suppressed
32   REAL(wp) ::   area               ! global mean ocean surface (interior domain)
33
34   REAL(wp), DIMENSION(jpi,jpj) ::   e1e2_i    ! area of the interior domain (e1t*e2t*tmask_i)
35
36   !! * Substitutions
37#  include "domzgr_substitute.h90"
38#  include "vectopt_loop_substitute.h90"
39   !!----------------------------------------------------------------------
40   !!  OPA 9.0 , LOCEAN-IPSL (2006)
41   !! $Id$
42   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
43   !!----------------------------------------------------------------------
44CONTAINS
45
46   SUBROUTINE sbc_fwb( kt, kn_fwb, kn_fsbc )
47      !!---------------------------------------------------------------------
48      !!                  ***  ROUTINE sbc_fwb  ***
49      !!
50      !! ** Purpose :   Control the mean sea surface drift
51      !!
52      !! ** Method  :   several ways  depending on kn_fwb
53      !!                =0 no control
54      !!                =1 global mean of emp set to zero at each nn_fsbc time step
55      !!                =2 annual global mean corrected from previous year
56      !!----------------------------------------------------------------------
57      INTEGER, INTENT( in ) ::   kt       ! ocean time-step index
58      INTEGER, INTENT( in ) ::   kn_fsbc  !
59      INTEGER, INTENT( in ) ::   kn_fwb   ! ocean time-step index
60      !!
61      INTEGER  ::   inum                  ! temporary logical unit
62      INTEGER  ::   ikty, iyear           !
63      CHARACTER (len=32) ::   clname 
64      REAL(wp) ::   z_emp                 ! temporary scalars
65      !!----------------------------------------------------------------------
66      !
67      IF( kt == nit000 ) THEN
68         !
69         IF(lwp) THEN
70            WRITE(numout,*)
71            WRITE(numout,*) 'sbc_fwb : FreshWater Budget correction'
72            WRITE(numout,*) '~~~~~~~'
73            IF( kn_fwb == 1 )   WRITE(numout,*) '          instantaneously set to zero'
74            IF( kn_fwb == 2 )   WRITE(numout,*) '          adjusted from previous year budget'
75         ENDIF
76         !
77         e1e2_i(:,:) = e1t(:,:) * e2t(:,:) * tmask_i(:,:)
78         area = SUM( e1e2_i(:,:) )
79         IF( lk_mpp )   CALL  mpp_sum( area    )   ! sum over the global domain
80         !
81      ENDIF
82     
83
84      SELECT CASE ( kn_fwb )
85      !
86      CASE ( 0 )                               
87         WRITE(ctmp1,*)'sbc_fwb : nn_fwb = ', kn_fwb, ' is not yet associated to an option, choose either 1/2'
88         CALL ctl_stop( ctmp1 )
89         !
90         
91      !
92      CASE ( 1 )                               ! global mean emp set to zero
93         IF( MOD( kt-1, kn_fsbc ) == 0 ) THEN
94            z_emp = SUM( e1e2_i(:,:) * emp(:,:) ) / area
95            IF( lk_mpp )   CALL  mpp_sum( z_emp    )   ! sum over the global domain
96            emp (:,:) = emp (:,:) - z_emp
97            emps(:,:) = emps(:,:) - z_emp
98         ENDIF
99         !
100      CASE ( 2 )                               ! emp budget adjusted from the previous year
101         ! initialisation
102         IF( kt == nit000 ) THEN
103            ! Read the corrective factor on precipitations (empold)
104            clname = 'EMPave_old.dat'
105            CALL ctlopn( inum, clname, 'OLD', 'FORMATTED', 'SEQUENTIAL',   &
106               &           1, numout, .FALSE., 1 )
107
108            READ ( inum, "(24X,I8,2ES24.16)" ) iyear, a_fwb_b, a_fwb
109            CLOSE( inum )
110            empold = a_fwb                  ! current year freshwater budget correction
111            !                               ! estimate from the previous year budget
112            IF(lwp)WRITE(numout,*)
113            IF(lwp)WRITE(numout,*)'sbc_fwb : year = ',iyear  , ' freshwater budget correction = ', empold
114            IF(lwp)WRITE(numout,*)'          year = ',iyear-1, ' freshwater budget read       = ', a_fwb
115            IF(lwp)WRITE(numout,*)'          year = ',iyear-2, ' freshwater budget read       = ', a_fwb_b
116         ENDIF   
117         !
118         ! Update empold if new year start
119         ikty = 365 * 86400 / rdttra(1)    !!bug  use of 365 days leap year or 360d year !!!!!!!
120         IF( MOD( kt, ikty ) == 0 ) THEN
121            a_fwb_b = a_fwb
122            a_fwb   = SUM( e1e2_i(:,:) * sshn(:,:) )
123            IF( lk_mpp )   CALL  mpp_sum( a_fwb    )   ! sum over the global domain
124            a_fwb   = a_fwb * 1.e+3 / ( area * 86400. * 365. )     ! convert in Kg/m3/s = mm/s
125!!gm        !                                                      !!bug 365d year
126            empold =  a_fwb                 ! current year freshwater budget correction
127            !                               ! estimate from the previous year budget
128         ENDIF
129         !
130         ! correct the freshwater fluxes
131         IF( MOD( kt-1, kn_fsbc ) == 0 ) THEN
132            emp (:,:) = emp (:,:) + empold
133            emps(:,:) = emps(:,:) + empold
134         ENDIF
135         !
136         ! save empold value in a file
137         IF( kt == nitend .AND. lwp ) THEN
138            clname = 'EMPav.dat'   
139            CALL ctlopn( inum, clname, 'UNKNOWN', 'FORMATTED', 'SEQUENTIAL',   &
140               &           1, numout, .FALSE., 0 )
141            WRITE(inum, "(24X,I8,2ES24.16)" ) nyear, a_fwb_b, a_fwb
142         ENDIF
143         !
144      CASE DEFAULT    ! you should never be there
145         WRITE(ctmp1,*)'sbc_fwb : nn_fwb = ', kn_fwb, ' is not permitted for the FreshWater Budget correction, choose either 1/2'
146         CALL ctl_stop( ctmp1 )
147         !
148      END SELECT
149      !
150   END SUBROUTINE sbc_fwb
151
152   !!======================================================================
153END MODULE sbcfwb
Note: See TracBrowser for help on using the repository browser.