1 | MODULE limcat_2D |
---|
2 | !!====================================================================== |
---|
3 | !! *** MODULE limcat_2D *** |
---|
4 | !! Used for LIM3 to convert cell averages of ice thickness, snow thickness |
---|
5 | !! and ice cover into a prescribed distribution over the cell. |
---|
6 | !! (Example of application: BDY forcings when input are cell averaged) |
---|
7 | !!====================================================================== |
---|
8 | !! History : - ! Original code from M. Vancoppenolle (?) |
---|
9 | !! ! 2011-12 (C. Rousset) rewritten for clarity |
---|
10 | !!---------------------------------------------------------------------- |
---|
11 | #if defined key_lim3 |
---|
12 | !!---------------------------------------------------------------------- |
---|
13 | !! 'key_lim3' : LIM3 sea-ice model |
---|
14 | !!---------------------------------------------------------------------- |
---|
15 | !! lim_cat : main subroutine |
---|
16 | !!---------------------------------------------------------------------- |
---|
17 | !! Modules used |
---|
18 | USE phycst |
---|
19 | USE oce ! dynamics and tracers variables |
---|
20 | USE dom_oce |
---|
21 | USE sbc_oce ! Surface boundary condition: ocean fields |
---|
22 | USE par_ice ! ice parameters |
---|
23 | USE ice ! ice variables |
---|
24 | USE eosbn2 ! equation of state |
---|
25 | USE in_out_manager |
---|
26 | USE dom_ice |
---|
27 | USE ice |
---|
28 | USE lbclnk |
---|
29 | |
---|
30 | IMPLICIT NONE |
---|
31 | PRIVATE |
---|
32 | |
---|
33 | !! Accessibility |
---|
34 | PUBLIC lim_cat_2D |
---|
35 | |
---|
36 | CONTAINS |
---|
37 | |
---|
38 | SUBROUTINE lim_cat_2D(zhti,zhts,zai,zht_i,zht_s,za_i) |
---|
39 | !! Local variables |
---|
40 | INTEGER :: ji, jj, jk, jl ! dummy loop indices |
---|
41 | INTEGER :: ijpi, ijpj, i_fill, jl0, ztest_1, ztest_2, ztest_3, ztest_4, ztests |
---|
42 | REAL(wp) :: zarg, zV, zconv |
---|
43 | REAL(wp), DIMENSION(:,:), INTENT(in) :: zhti, zhts, zai ! input ice/snow variables |
---|
44 | REAL(wp), DIMENSION(:,:,:), INTENT(inout) :: zht_i, zht_s, za_i ! output ice/snow variables |
---|
45 | REAL(wp) :: epsi06 = 1.0e-6 |
---|
46 | |
---|
47 | !-------------------------------------------------------------------- |
---|
48 | ! initialisation of variables |
---|
49 | !-------------------------------------------------------------------- |
---|
50 | ijpi = SIZE(zhti,1) |
---|
51 | ijpj = SIZE(zhti,2) |
---|
52 | zht_i(1:ijpi,1:ijpj,1:jpl) = 0.d0 |
---|
53 | zht_s(1:ijpi,1:ijpj,1:jpl) = 0.d0 |
---|
54 | za_i (1:ijpi,1:ijpj,1:jpl) = 0.d0 |
---|
55 | |
---|
56 | !------------------------------------------------------------------------------------ |
---|
57 | ! Distribute ice concentration and thickness into the categories |
---|
58 | !------------------------------------------------------------------------------------ |
---|
59 | ! Method: we first try to fill the jpl ice categories bounded by thicknesses |
---|
60 | ! hmax(0:jpl) with a gaussian distribution, and check whether the distribution |
---|
61 | ! fulfills volume and area conservation, positivity and ice categories bounds. |
---|
62 | ! In other words, if ice input is too thin, the last category (jpl) |
---|
63 | ! cannot be filled, so we try to fill jpl-1 categories... |
---|
64 | ! And so forth iteratively until the number of categories filled |
---|
65 | ! fulfills ice volume concervation between input and output (ztests=4) |
---|
66 | !-------------------------------------------------------------------------------------- |
---|
67 | |
---|
68 | ! ---------------------------------------- |
---|
69 | ! distribution over the jpl ice categories |
---|
70 | ! ---------------------------------------- |
---|
71 | DO jj = 1, ijpj |
---|
72 | DO ji = 1, ijpi |
---|
73 | |
---|
74 | ! snow thickness in each category |
---|
75 | zht_s(ji,jj,1:jpl) = zhts(ji,jj) |
---|
76 | |
---|
77 | ! initialisation of tests |
---|
78 | ztest_1 = 0 |
---|
79 | ztest_2 = 0 |
---|
80 | ztest_3 = 0 |
---|
81 | ztest_4 = 0 |
---|
82 | ztests = 0 |
---|
83 | |
---|
84 | i_fill = jpl + 1 !==================================== |
---|
85 | DO WHILE ( ( ztests /= 4 ) .AND. ( i_fill >= 2 ) ) ! iterative loop on i_fill categories |
---|
86 | ! iteration !==================================== |
---|
87 | i_fill = i_fill - 1 |
---|
88 | |
---|
89 | ! initialisation of ice variables for each try |
---|
90 | zht_i(ji,jj,1:jpl) = 0.d0 |
---|
91 | za_i (ji,jj,1:jpl) = 0.d0 |
---|
92 | |
---|
93 | ! *** case very thin ice: fill only category 1 |
---|
94 | IF ( i_fill == 1 ) THEN |
---|
95 | zht_i(ji,jj,1) = zhti(ji,jj) |
---|
96 | za_i (ji,jj,1) = zai (ji,jj) |
---|
97 | |
---|
98 | ! *** case ice is thicker: fill categories >1 |
---|
99 | ELSE |
---|
100 | |
---|
101 | ! Fill ice thicknesses except the last one (i_fill) by (hmax-hmin)/2 |
---|
102 | DO jl = 1, i_fill - 1 |
---|
103 | zht_i(ji,jj,jl) = ( hi_max(jl) + hi_max(jl-1) ) / 2. |
---|
104 | END DO |
---|
105 | |
---|
106 | ! find which category (jl0) the input ice thickness falls into |
---|
107 | jl0 = i_fill |
---|
108 | DO jl = 1, i_fill |
---|
109 | IF ( ( zhti(ji,jj) >= hi_max(jl-1) ) .AND. ( zhti(ji,jj) < hi_max(jl) ) ) THEN |
---|
110 | jl0 = jl |
---|
111 | CYCLE |
---|
112 | ENDIF |
---|
113 | END DO |
---|
114 | |
---|
115 | ! Concentrations in the (i_fill-1) categories |
---|
116 | za_i(ji,jj,jl0) = zai(ji,jj) / SQRT(REAL(jpl)) |
---|
117 | DO jl = 1, i_fill - 1 |
---|
118 | IF ( jl == jl0 ) CYCLE |
---|
119 | zarg = ( zht_i(ji,jj,jl) - zhti(ji,jj) ) / ( zhti(ji,jj) / 2. ) |
---|
120 | za_i(ji,jj,jl) = za_i (ji,jj,jl0) * EXP(-zarg**2) |
---|
121 | END DO |
---|
122 | |
---|
123 | ! Concentration in the last (i_fill) category |
---|
124 | za_i(ji,jj,i_fill) = zai(ji,jj) - SUM( za_i(ji,jj,1:i_fill-1) ) |
---|
125 | |
---|
126 | ! Ice thickness in the last (i_fill) category |
---|
127 | zV = SUM( za_i(ji,jj,1:i_fill-1) * zht_i(ji,jj,1:i_fill-1) ) |
---|
128 | zht_i(ji,jj,i_fill) = ( zhti(ji,jj)*zai(ji,jj) - zV ) / za_i(ji,jj,i_fill) |
---|
129 | |
---|
130 | ENDIF ! case ice is thick or thin |
---|
131 | |
---|
132 | !--------------------- |
---|
133 | ! Compatibility tests |
---|
134 | !--------------------- |
---|
135 | ! Test 1: area conservation |
---|
136 | zconv = ABS( zai(ji,jj) - SUM( za_i(ji,jj,1:jpl) ) ) |
---|
137 | IF ( zconv < epsi06 ) ztest_1 = 1 |
---|
138 | |
---|
139 | ! Test 2: volume conservation |
---|
140 | zconv = ABS( zhti(ji,jj)*zai(ji,jj) - SUM( za_i(ji,jj,1:jpl)*zht_i(ji,jj,1:jpl) ) ) |
---|
141 | IF ( zconv < epsi06 ) ztest_2 = 1 |
---|
142 | |
---|
143 | ! Test 3: thickness of the last category is in-bounds ? |
---|
144 | IF ( zht_i(ji,jj,i_fill) >= hi_max(i_fill-1) ) ztest_3 = 1 |
---|
145 | |
---|
146 | ! Test 4: positivity of ice concentrations |
---|
147 | ztest_4 = 1 |
---|
148 | DO jl = 1, i_fill |
---|
149 | IF ( za_i(ji,jj,jl) < 0.0d0 ) ztest_4 = 0 |
---|
150 | END DO |
---|
151 | |
---|
152 | ztests = ztest_1 + ztest_2 + ztest_3 + ztest_4 |
---|
153 | !============================ |
---|
154 | END DO ! end iteration on categories |
---|
155 | !============================ |
---|
156 | ! Check if tests have passed (i.e. volume conservation...) |
---|
157 | !IF ( ztests .NE. 4 ) THEN |
---|
158 | ! WRITE(numout,*) ' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ' |
---|
159 | ! WRITE(numout,*) ' !! ALERT categories distribution !!' |
---|
160 | ! WRITE(numout,*) ' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ' |
---|
161 | ! WRITE(numout,*) ' *** ztests is not equal to 4 ' |
---|
162 | ! WRITE(numout,*) ' *** ztest (1:4) = ', ztest_1, ztest_2, ztest_3, ztest_4 |
---|
163 | !ENDIF |
---|
164 | |
---|
165 | END DO ! i loop |
---|
166 | END DO ! j loop |
---|
167 | |
---|
168 | END SUBROUTINE lim_cat_2D |
---|
169 | |
---|
170 | #else |
---|
171 | !!---------------------------------------------------------------------- |
---|
172 | !! Default option : Empty module NO LIM sea-ice model |
---|
173 | !!---------------------------------------------------------------------- |
---|
174 | CONTAINS |
---|
175 | SUBROUTINE lim_cat_2D ! Empty routine |
---|
176 | END SUBROUTINE lim_cat_2D |
---|
177 | #endif |
---|
178 | |
---|
179 | !!====================================================================== |
---|
180 | END MODULE limcat_2D |
---|