SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
modi_glt_getatmf.F90
Go to the documentation of this file.
1 !SFX_LIC Copyright 1994-2014 CNRS, Meteo-France and Universite Paul Sabatier
2 !SFX_LIC This is part of the SURFEX software governed by the CeCILL-C licence
3 !SFX_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt
4 !SFX_LIC for details. version 1.
5 !GLT_LIC The GELATO model is a seaice model used in stand-alone or embedded mode.
6 !GLT_LIC It has been developed by Meteo-France. The holder of GELATO is Meteo-France.
7 !GLT_LIC
8 !GLT_LIC This software is governed by the CeCILL-C license under French law and biding
9 !GLT_LIC by the rules of distribution of free software. See the CeCILL-C_V1-en.txt
10 !GLT_LIC (English) and CeCILL-C_V1-fr.txt (French) for details. The CeCILL is a free
11 !GLT_LIC software license, explicitly compatible with the GNU GPL
12 !GLT_LIC (see http://www.gnu.org/licenses/license-list.en.html#CeCILL)
13 !GLT_LIC
14 !GLT_LIC The CeCILL-C licence agreement grants users the right to modify and re-use the
15 !GLT_LIC software governed by this free software license. The exercising of this right
16 !GLT_LIC is conditional upon the obligation to make available to the community the
17 !GLT_LIC modifications made to the source code of the software so as to contribute to
18 !GLT_LIC its evolution.
19 !GLT_LIC
20 !GLT_LIC In consideration of access to the source code and the rights to copy, modify
21 !GLT_LIC and redistribute granted by the license, users are provided only with a limited
22 !GLT_LIC warranty and the software's author, the holder of the economic rights, and the
23 !GLT_LIC successive licensors only have limited liability. In this respect, the risks
24 !GLT_LIC associated with loading, using, modifying and/or developing or reproducing the
25 !GLT_LIC software by the user are brought to the user's attention, given its Free
26 !GLT_LIC Software status, which may make it complicated to use, with the result that its
27 !GLT_LIC use is reserved for developers and experienced professionals having in-depth
28 !GLT_LIC computer knowledge. Users are therefore encouraged to load and test the
29 !GLT_LIC suitability of the software as regards their requirements in conditions enabling
30 !GLT_LIC the security of their systems and/or data to be ensured and, more generally, to
31 !GLT_LIC use and operate it in the same conditions of security.
32 !GLT_LIC
33 !GLT_LIC The GELATO sofware is cureently distibuted with the SURFEX software, available at
34 !GLT_LIC http://www.cnrm.meteo.fr/surfex. The fact that you download the software deemed that
35 !GLT_LIC you had knowledge of the CeCILL-C license and that you accept its terms.
36 !GLT_LIC Attempts to use this software in a way not complying with CeCILL-C license
37 !GLT_LIC may lead to prosecution.
38 !GLT_LIC
39 ! =======================================================================
40 ! ========================= MODULE modi_glt_getatmf =========================
41 ! =======================================================================
42 !
43 ! This routine was created for Gelato version 3, i.e. Gelato is under the
44 ! form of a routine inserted in the OPA 8 code.
45 ! It allows Gelato to get the needed forcing from the main routine input
46 ! atmospheric fields.
47 !
48 ! Created : 10/1999 (D. Salas y Melia)
49 ! Modified: 06/2009 (D. Salas y Melia)
50 ! Patch (non energy-conserving) to discard unrealistic non-solar
51 ! heat fluxes in the "single physics" approach
52 ! Modified: 08/2009 (D. Salas y Melia)
53 ! Manages single or double physics
54 ! Modified: 12/2012 (D. Salas y Melia)
55 ! Parallelism & super-type
56 !
57 ! --------------------- BEGIN MODULE modi_glt_getatmf -----------------------
58 !
59 !THXS_SFX!MODULE modi_glt_getatmf
60 !THXS_SFX!INTERFACE
61 !THXS_SFX!!
62 !THXS_SFX!SUBROUTINE glt_getatmf( tpglt )
63 !THXS_SFX! USE modd_types_glt
64 !THXS_SFX! USE modd_glt_param
65 !THXS_SFX! TYPE(t_glt), INTENT(inout) :: &
66 !THXS_SFX! tpglt
67 !THXS_SFX!END SUBROUTINE glt_getatmf
68 !THXS_SFX!!
69 !THXS_SFX!END INTERFACE
70 !THXS_SFX!END MODULE modi_glt_getatmf
71 !
72 ! ---------------------- END MODULE modi_glt_getatmf ------------------------
73 !
74 !
75 ! -----------------------------------------------------------------------
76 ! ----------------------- SUBROUTINE glt_getatmf ----------------------------
77 
78 SUBROUTINE glt_getatmf( tpglt )
79  USE modd_types_glt
81  USE modd_glt_param
82 #if ! defined in_surfex
83  USE mode_gltools_bound
84 #endif
86 !
87  IMPLICIT NONE
88 !
89  TYPE(t_glt), INTENT(inout) :: &
90  tpglt
91 !
92  INTEGER, PARAMETER :: jkmax=3 ! Order of the mask
93  INTEGER :: &
94  ji,jj,jk
95  INTEGER, DIMENSION(jkmax,SIZE(tpglt%dom,1),SIZE(tpglt%dom,2)) :: &
96  itmk
97  INTEGER, DIMENSION(nt,SIZE(tpglt%dom,1),SIZE(tpglt%dom,2)) :: &
98  itmk0
99  REAL, DIMENSION(SIZE(tpglt%dom,1),SIZE(tpglt%dom,2)) :: &
100  zfsit,ztsfm,zalbm, &
101  zfsite,ztmke,ztmke0,zwork2
102  TYPE(t_sit), &
103  DIMENSION(SIZE(tpglt%sit,1),SIZE(tpglt%sit,2),SIZE(tpglt%sit,3)) :: &
104  tzsit
105 !
106 !
107 ! TO BE INCORPORATED PROPERLY LATER ON (WITH AN OPTION)
108 ! *** First, correct short wave and non-solar fluxes.
109 ! In case the input short wave is negative (normally, slightly...),
110 ! add this negative short wave flux to the non-solar, and set the
111 ! short wave to zero. This ensures that energy is conserved.
112 ! If this is not done, serious problems may arise:
113 ! - if there is a snow layer, this layer totally absorbs the
114 ! negative solar short wave
115 ! - it this snow layer is extremely thin, the temperature trend
116 ! can reach O(10^6) K / day !
117 ! - since the code has no criterion to correct a very low
118 ! temperature, it will normally fail in the vertical heat diffusion
119 ! scheme afterwards.
120 ! It would be better however to let the user choose whether this
121 ! operation (convert negative short wave to non-solar) is legal.
122 ! A flag in the namelist will be made available later on. The
123 ! alternative is to stop if a negative short wave flux is
124 ! encountered.
125 !
126 ! znsf(:,:) = pnsf(:,:)
127 ! zswa(:,:) = pswa(:,:)
128 ! WHERE( pswa(:,:)<0. )
129 ! znsf(:,:) = pnsf(:,:)+pswa(:,:)
130 ! zswa(:,:) = 0.
131 ! ENDWHERE
132 !
133 !
134 ! .. Recreate the following quantities for all considered types_glt of
135 ! surfaces:
136 ! - non solar heat flux (W.m-2), positive if it is supposed to
137 ! warm up the surface
138 ! - solar short wave heat flux (W.m-2)
139 ! - derivative of non solar heat flux (W.m-2.K-1)
140 ! - evaporation flux. Sorry, we don't have the derivative of this
141 ! flux by temperature, so we will merely assume this flux is
142 ! the same for all surfaces.
143 ! .. This process depends on whether we are in single or double physics
144 ! mode
145 !
146 ! Get ice state (just for better code readibility...)
147 !
148  tzsit = tpglt%sit
149 !
150 ! Compute total sea ice concentration
151 !
152  zfsit(:,:) = sum( tzsit(:,:,:)%fsi,dim=1 )
153 !
154 !
155 ! 1. Double physics case
156 ! =======================
157 !
158 ! 1.1. Repartition of fluxes on sea ice
159 ! --------------------------------------
160 !
161 ! .. The repartition of solar, non-solar heat fluxes and evaporation
162 ! between water and ice is already done. However, this repartition has
163 ! to be done on ice among the different ice categories, if only one
164 ! flux has been provided (case nnflxin=1)
165 ! _
166 ! .. Note that the average X of an extensive quantity X computed
167 ! over the ice part of the grid cell (this ice part covers a fraction f_tot
168 ! that is generally not equal to 1) is:
169 ! _
170 ! X = 1./f_tot * SUM ( f_i * X_i ),
171 !
172 ! where f_i and X_i are respectively the fraction and value of X for
173 ! ice category index i, and
174 !
175 ! f_tot = SUM ( f_i )
176 ! _
177 ! If F is the average non-solar flux over ice, the flux for ice category i
178 ! (with temperature T_i), F_i can be written as (linear approximation):
179 ! _ _
180 ! F_i = F + dF/dT * ( T_i - T ),
181 !
182 ! where dF/dT is the non-solar heat flux derivative by surface temperature
183 ! and
184 ! _
185 ! T = 1./f_tot * SUM ( f_i * T_i ).
186 !
187 ! It can be showed that the following equation is true:
188 ! _
189 ! F = 1./f_tot * SUM ( f_i * F_i )
190 !
191  IF ( nnflxin/=0 ) THEN
192 !
193  IF (lp1) THEN
194  WRITE(noutlu,*) '*********************************************'
195  WRITE(noutlu,*) ' DOUBLE / MULTIPLE FLUX MODE (INPUT)'
196  ENDIF
197 !
198 ! Ice average temperature and albedo
199  WHERE( zfsit(:,:)>epsil1 )
200  ztsfm(:,:) = sum( tzsit(:,:,:)%fsi*tzsit(:,:,:)%tsf,dim=1 ) / &
201  zfsit(:,:)
202  zalbm(:,:) = sum( tzsit(:,:,:)%fsi*tzsit(:,:,:)%asn,dim=1 ) / &
203  zfsit(:,:)
204  ENDWHERE
205  WHERE( zfsit(:,:)<=epsil1 )
206  ztsfm(:,:) = tpglt%tml(:,:)%mlf
207  zalbm(:,:) = albi
208  ENDWHERE
209 !
210 ! == First case: only one flux is provided for all sea ice categories
211 !
212  IF ( nnflxin==1 ) THEN
213 !
214  IF (lp1) THEN
215  WRITE(noutlu,*) ' (only 1 flux provided for all ice cats)'
216  WRITE(noutlu,*) '*********************************************'
217  ENDIF
218 !
219  DO jk=1,nt
220 !
221 ! Non-solar heat flux
222  tpglt%blki(jk,:,:)%nsf = tpglt%atm_ice(1,:,:)%nsf + &
223  tpglt%atm_ice(1,:,:)%dfl * &
224  ( tzsit(jk,:,:)%tsf-ztsfm(:,:) )
225 ! Solar heat flux
226  tpglt%blki(jk,:,:)%swa = tpglt%atm_ice(1,:,:)%swa * &
227  ( 1.-tzsit(jk,:,:)%asn ) / ( 1.-zalbm(:,:) )
228 !
229 ! Derivative of non solar heat flux
230  tpglt%blki(jk,:,:)%dfl = tpglt%atm_ice(1,:,:)%dfl
231 !
232 ! Evaporation
233 ! - The water fluxes are now in kg.m-2.s-1 throughout the code
234  tpglt%blki(jk,:,:)%eva = tpglt%atm_ice(1,:,:)%eva
235 !
236  END DO
237 !
238  ELSE
239 !
240  IF (lwg) THEN
241  WRITE(noutlu,*) ' (1 flux provided for every ice cat)'
242  WRITE(noutlu,*) '*****************************************'
243  ENDIF
244 !
245 ! == Second case: one flux is provided per sea ice category
246 !
247 ! Non-solar heat flux
248  tpglt%blki(:,:,:)%nsf = tpglt%atm_ice(:,:,:)%nsf
249 !
250 ! Solar heat flux
251  tpglt%blki(:,:,:)%swa = tpglt%atm_ice(:,:,:)%swa
252 !
253 ! Derivative of non solar heat flux
254  tpglt%blki(:,:,:)%dfl = tpglt%atm_ice(:,:,:)%dfl
255 !
256 ! Evaporation
257 ! - The water fluxes are now in kg.m-2.s-1 throughout the code
258  tpglt%blki(:,:,:)%eva = tpglt%atm_ice(:,:,:)%eva
259  ENDIF
260 !
261 !
262 ! 1.2. Fluxes on water
263 ! ---------------------
264 !
265 ! Non-solar heat flux
266  tpglt%blkw(:,:)%nsf = tpglt%atm_wat(:,:)%nsf
267 !
268 ! Solar heat flux
269  tpglt%blkw(:,:)%swa = tpglt%atm_wat(:,:)%swa
270 !
271 ! Derivative of non solar heat flux
272  tpglt%blkw(:,:)%dfl = tpglt%atm_wat(:,:)%dfl
273 
274 ! * Evaporation
275 ! - The water fluxes are now in kg.m-2.s-1 throughout the code
276  tpglt%blkw(:,:)%eva = tpglt%atm_wat(:,:)%eva
277 !
278  ELSE
279 !
280 !
281 ! 2. Single physics case
282 ! =======================
283 !
284  IF (lwg) THEN
285  WRITE(noutlu,*) '*****************************************'
286  WRITE(noutlu,*) ' SINGLE PHYSICS MODE'
287  WRITE(noutlu,*) '*****************************************'
288  ENDIF
289 !
290 !
291 ! 2.1. Compute average surface quantities
292 ! ----------------------------------------
293 !
294 ! Surface average temperature and albedo
295  ztsfm(:,:) = sum( tzsit(:,:,:)%fsi*tzsit(:,:,:)%tsf,dim=1 ) + &
296  ( 1.-zfsit(:,:) )*tpglt%tml(:,:)%tml
297  zalbm(:,:) = sum( tzsit(:,:,:)%fsi*tzsit(:,:,:)%asn,dim=1 ) + &
298  ( 1.-zfsit(:,:) )*albw
299 !
300 !
301 ! 2.2. Fluxes on sea ice
302 ! -----------------------
303 !
304 ! .. The repartition of solar, non-solar heat fluxes and evaporation
305 ! between water and ice is not done yet. This repartition can be
306 ! applied following the same principles as for double physics. The
307 ! surface we deal with is not only ice, but ice+water (total fraction
308 ! ftot is now always 1)
309 !
310  DO jk=1,nt
311 !
312 ! Non-solar heat flux
313  tpglt%blki(jk,:,:)%nsf = tpglt%atm_mix(1,:,:)%nsf + &
314  tpglt%atm_mix(1,:,:)%dfl * &
315  ( tzsit(jk,:,:)%tsf-ztsfm(:,:) )
316 !
317 ! Solar heat flux
318  tpglt%blki(jk,:,:)%swa = tpglt%atm_mix(1,:,:)%swa * &
319  ( 1.-tzsit(jk,:,:)%asn ) / ( 1.-zalbm(:,:) )
320 !
321 !
322 ! Derivative of non solar heat flux
323  tpglt%blki(jk,:,:)%dfl = tpglt%atm_mix(1,:,:)%dfl
324 !
325 ! Evaporation
326 ! - The water fluxes are now in kg.m-2.s-1 throughout the code
327  tpglt%blki(jk,:,:)%eva = tpglt%atm_mix(1,:,:)%eva
328 !
329  END DO
330 !
331 !
332 ! 2.3. Modify unrealistic fluxes (near ice edge)
333 ! -----------------------------------------------
334 ! TO BE TRANSFORMED INTO A ROUTINE LATER ON
335 !
336 ! BEGIN FUTURE ROUTINE
337 !
338 ! First iteration
339 !
340  zfsite(:,:)=zfsit(:,:)
341 !
342  ztmke0(:,:) = float(tpglt%dom%tmk)
343  itmk(1,:,:)=1
344  WHERE( zfsite(:,:)<0.5 .OR. ztmke0(:,:)<0.5 )
345  itmk(1,:,:) = 0
346  ENDWHERE
347 !
348 ! More iterations
349  DO jk=2,jkmax
350  ztmke=float(itmk(jk-1,:,:))
351  DO jj=2,ny-1
352  DO ji=2,nx-1
353  IF( any( ( zfsite(ji-1:ji+1,jj-1:jj+1)<0.5 .OR. &
354  itmk(jk-1,ji-1:ji+1,jj-1:jj+1)==0 ).AND. &
355  ztmke0(ji-1:ji+1,jj-1:jj+1)>0.5 ) ) THEN
356  ztmke(ji,jj)=0.
357  ENDIF
358  END DO
359  END DO
360 #if ! defined in_surfex
361  CALL gltools_bound( 'T','scalar',ztmke )
362 #endif
363  itmk(jk,:,:)=int(ztmke)
364  END DO
365 !
366 ! Now we have a mask defining which points are not too close to the
367 ! ice edge
368  itmk0 = spread( itmk(jkmax,:,:),1,nt )
369 !
370 ! END FUTURE ROUTINE
371 !
372 ! * Correct unrealistic non-solar heat flux
373  WHERE( tzsit(:,:,:)%tsf<245.-t0deg .AND. tzsit(:,:,:)%fsi>epsil1 .AND. &
374  itmk0==0 )
375  tpglt%blki(:,:,:)%nsf = amax1( &
376  tpglt%blki(:,:,:)%nsf, &
377  tpglt%blki(:,:,:)%dfl*amax1( tzsit(:,:,:)%tsf-(233.-t0deg),0. ) )
378  ENDWHERE
379 !
380 !
381 ! 2.4. Fluxes on water
382 ! ---------------------
383 !
384 ! Non solar heat flux
385  tpglt%blkw(:,:)%nsf = tpglt%atm_mix(1,:,:)%nsf + &
386  tpglt%atm_mix(1,:,:)%dfl * ( tpglt%tml(:,:)%tml-ztsfm(:,:) )
387 !
388 ! Solar heat flux
389  tpglt%blkw(:,:)%swa = tpglt%atm_mix(1,:,:)%swa * &
390  ( 1.-albw ) / ( 1.-zalbm(:,:) )
391 !
392 ! Derivative of non solar heat flux
393  tpglt%blkw(:,:)%dfl = tpglt%atm_mix(1,:,:)%dfl
394 
395 ! * Evaporation
396 ! - The water fluxes are now in kg.m-2.s-1 throughout the code
397  tpglt%blkw(:,:)%eva = tpglt%atm_mix(1,:,:)%eva
398 !
399  ENDIF
400 !
401 !
402 ! 2.5. Diagnostics
403 ! -----------------
404 !
405 ! Diagnose the total Input Fresh Water flux
406  tpglt%dia(:,:)%ifw = tpglt%atm_all(:,:)%sop + tpglt%atm_all(:,:)%lip + &
407  ( 1.-zfsit(:,:) )*tpglt%blkw(:,:)%eva + &
408  sum( tzsit(:,:,:)%fsi*tpglt%blki(:,:,:)%eva, dim=1 )
409 !
410 ! Diagnose the Input Solar Flux to Sea Ice
411  tpglt%dia(:,:)%swi = sum( tzsit(:,:,:)%fsi*tpglt%blki(:,:,:)%swa, dim=1 )
412 !
413 ! Diagnose the Input Solar Flux to Leads
414  tpglt%dia(:,:)%sww = ( 1.-zfsit(:,:) )*tpglt%blkw(:,:)%swa
415 !
416 END SUBROUTINE glt_getatmf
417 !
418 ! --------------------- END SUBROUTINE glt_getatmf --------------------------
419 ! -----------------------------------------------------------------------
subroutine glt_getatmf(tpglt)