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 @ 888

Last change on this file since 888 was 888, checked in by ctlod, 16 years ago

merge dev_001_SBC branche with the trunk to include the New Surface Module package, see ticket: #113

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