1 | MODULE 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 | !!---------------------------------------------------------------------- |
---|
45 | CONTAINS |
---|
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 ! temporary logical unit |
---|
63 | INTEGER :: ikty, iyear ! |
---|
64 | CHARACTER (len=32) :: clname |
---|
65 | REAL(wp) :: z_emp ! temporary scalars |
---|
66 | !!---------------------------------------------------------------------- |
---|
67 | ! |
---|
68 | IF( kt == nit000 ) THEN |
---|
69 | ! |
---|
70 | IF(lwp) THEN |
---|
71 | WRITE(numout,*) |
---|
72 | WRITE(numout,*) 'sbc_fwb : FreshWater Budget correction' |
---|
73 | WRITE(numout,*) '~~~~~~~' |
---|
74 | IF( kn_fwb == 1 ) WRITE(numout,*) ' instantaneously set to zero' |
---|
75 | IF( kn_fwb == 2 ) WRITE(numout,*) ' adjusted from previous year budget' |
---|
76 | ENDIF |
---|
77 | ! |
---|
78 | e1e2_i(:,:) = e1t(:,:) * e2t(:,:) * tmask_i(:,:) |
---|
79 | area = SUM( e1e2_i(:,:) ) |
---|
80 | IF( lk_mpp ) CALL mpp_sum( area ) ! sum over the global domain |
---|
81 | ! |
---|
82 | ENDIF |
---|
83 | |
---|
84 | |
---|
85 | SELECT CASE ( kn_fwb ) |
---|
86 | ! |
---|
87 | CASE ( 1 ) ! global mean emp set to zero |
---|
88 | IF( MOD( kt-1, kn_fsbc ) == 0 ) THEN |
---|
89 | z_emp = SUM( e1e2_i(:,:) * emp(:,:) ) / area |
---|
90 | IF( lk_mpp ) CALL mpp_sum( z_emp ) ! sum over the global domain |
---|
91 | emp (:,:) = emp (:,:) - z_emp |
---|
92 | emps(:,:) = emps(:,:) - z_emp |
---|
93 | ENDIF |
---|
94 | ! |
---|
95 | CASE ( 2 ) ! emp budget adjusted from the previous year |
---|
96 | ! initialisation |
---|
97 | IF( kt == nit000 ) THEN |
---|
98 | ! Read the corrective factor on precipitations (empold) |
---|
99 | clname = 'EMPave_old.dat' |
---|
100 | CALL ctlopn( inum, clname, 'OLD', 'FORMATTED', 'SEQUENTIAL', & |
---|
101 | & 1, numout, .FALSE., 1 ) |
---|
102 | |
---|
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 | ENDIF |
---|
112 | ! |
---|
113 | ! Update empold if new year start |
---|
114 | ikty = 365 * 86400 / rdttra(1) !!bug use of 365 days leap year or 360d year !!!!!!! |
---|
115 | IF( MOD( kt, ikty ) == 0 ) THEN |
---|
116 | a_fwb_b = a_fwb |
---|
117 | a_fwb = SUM( e1e2_i(:,:) * sshn(:,:) ) |
---|
118 | IF( lk_mpp ) CALL mpp_sum( a_fwb ) ! sum over the global domain |
---|
119 | a_fwb = a_fwb * 1.e+3 / ( area * 86400. * 365. ) ! convert in Kg/m3/s = mm/s |
---|
120 | !!gm ! !!bug 365d year |
---|
121 | empold = a_fwb ! current year freshwater budget correction |
---|
122 | ! ! estimate from the previous year budget |
---|
123 | ENDIF |
---|
124 | ! |
---|
125 | ! correct the freshwater fluxes |
---|
126 | IF( MOD( kt-1, kn_fsbc ) == 0 ) THEN |
---|
127 | emp (:,:) = emp (:,:) - empold |
---|
128 | emps(:,:) = emps(:,:) - empold |
---|
129 | ENDIF |
---|
130 | ! |
---|
131 | ! save empold value in a file |
---|
132 | IF( kt == nitend .AND. lwp ) THEN |
---|
133 | clname = 'EMPav.dat' |
---|
134 | CALL ctlopn( inum, clname, 'UNKNOWN', 'FORMATTED', 'SEQUENTIAL', & |
---|
135 | & 1, numout, .FALSE., 0 ) |
---|
136 | WRITE(inum, "(24X,I8,2ES24.16)" ) nyear, a_fwb_b, a_fwb |
---|
137 | ENDIF |
---|
138 | ! |
---|
139 | CASE DEFAULT ! you should never be there |
---|
140 | WRITE(ctmp1,*)'sbc_fwb : nn_fwb = ', kn_fwb, ' is not permitted for the FreshWater Budget correction, choose either 0/1/2' |
---|
141 | CALL ctl_stop( ctmp1 ) |
---|
142 | ! |
---|
143 | END SELECT |
---|
144 | ! |
---|
145 | END SUBROUTINE sbc_fwb |
---|
146 | |
---|
147 | !!====================================================================== |
---|
148 | END MODULE sbcfwb |
---|