SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
prep_hor_flake_field.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 ! #########
6 SUBROUTINE prep_hor_flake_field (DTCO, UG, U, USS, &
7  fg, f, &
8  hprogram,hsurf,hatmfile,hatmfiletype,&
9  hpgdfile,hpgdfiletype,onovalue)
10 ! #################################################################################
11 !
12 !!**** *PREP_HOR_FLAKE_FIELD* - Reads, interpolates and prepares a water field
13 !!
14 !! PURPOSE
15 !! -------
16 !
17 !!** METHOD
18 !! ------
19 !!
20 !! REFERENCE
21 !! ---------
22 !!
23 !!
24 !! AUTHOR
25 !! ------
26 !! S. Malardel
27 !!
28 !! MODIFICATIONS
29 !! -------------
30 !! Original 01/2004
31 !! P. Le Moigne 10/2005, Phasage Arome
32 !! E. Kourzeneva 09/2010, Make possible to interpolate
33 !! only lake surface temperature,
34 !! but not profiles
35 !!------------------------------------------------------------------
36 !
37 !
38 !
39 !
40 !
41 !
42 !
43 !
46 USE modd_surf_atm_n, ONLY : surf_atm_t
48 !
50 USE modd_flake_n, ONLY : flake_t
51 !
52 USE modd_surf_par, ONLY : xundef
53 USE modd_prep, ONLY : cingrid_type, cinterp_type, xzs_ls, xlat_out, xlon_out, &
54  xx_out, xy_out, cmask
55 !
56 !
57 USE modd_csts, ONLY : xtt
58 USE modd_prep_flake, ONLY : lclim_lake
59 !
60 USE modi_read_prep_flake_conf
61 USE modi_prep_flake_grib
62 USE modi_prep_flake_ascllv
63 USE modi_prep_flake_unif
64 USE modi_prep_flake_buffer
65 USE modi_hor_interpol
66 USE modi_get_luout
67 USE modi_prep_flake_extern
68 !
69 USE yomhook ,ONLY : lhook, dr_hook
70 USE parkind1 ,ONLY : jprb
71 !
72 USE modi_abor1_sfx
73 IMPLICIT NONE
74 !
75 !* 0.1 declarations of arguments
76 !
77 !
78 !
79 TYPE(data_cover_t), INTENT(INOUT) :: dtco
80 TYPE(surf_atm_grid_t), INTENT(INOUT) :: ug
81 TYPE(surf_atm_t), INTENT(INOUT) :: u
82 TYPE(surf_atm_sso_t), INTENT(INOUT) :: uss
83 !
84 TYPE(flake_grid_t), INTENT(INOUT) :: fg
85 TYPE(flake_t), INTENT(INOUT) :: f
86 !
87  CHARACTER(LEN=6), INTENT(IN) :: hprogram ! program calling surf. schemes
88  CHARACTER(LEN=7), INTENT(IN) :: hsurf ! type of field
89  CHARACTER(LEN=28), INTENT(IN) :: hatmfile ! name of the Atmospheric file
90  CHARACTER(LEN=6), INTENT(IN) :: hatmfiletype! type of the Atmospheric file
91  CHARACTER(LEN=28), INTENT(IN) :: hpgdfile ! name of the Atmospheric file
92  CHARACTER(LEN=6), INTENT(IN) :: hpgdfiletype! type of the Atmospheric file
93 LOGICAL, OPTIONAL, INTENT(OUT) :: onovalue ! flag for the not given value
94 !
95 !
96 !* 0.2 declarations of local variables
97 !
98  CHARACTER(LEN=6) :: yfiletype ! type of input file
99  CHARACTER(LEN=28) :: yfile ! name of file
100  CHARACTER(LEN=6) :: yfilepgdtype ! type of input file
101  CHARACTER(LEN=28) :: yfilepgd ! name of file
102 REAL, POINTER, DIMENSION(:,:) :: zfieldin ! field to interpolate horizontally
103 REAL, ALLOCATABLE, DIMENSION(:,:) :: zfieldout ! field interpolated horizontally
104 INTEGER :: iluout ! output listing logical unit
105 !
106 LOGICAL :: gunif ! flag for prescribed uniform field
107 LOGICAL :: gdefault ! flag for prescribed default field
108 REAL(KIND=JPRB) :: zhook_handle
109 !-------------------------------------------------------------------------------------
110 !
111 !
112 !* 1. Reading of input file name and type
113 !
114 IF (lhook) CALL dr_hook('PREP_HOR_FLAKE_FIELD',0,zhook_handle)
115  CALL get_luout(hprogram,iluout)
116 !
117  CALL read_prep_flake_conf(hprogram,hsurf,yfile,yfiletype,yfilepgd,yfilepgdtype,&
118  hatmfile,hatmfiletype,hpgdfile,hpgdfiletype,iluout,gunif)
119 !
120  cmask = 'WATER'
121 !
122 gdefault = (yfiletype==' ' .OR. (hsurf(1:2)/='ZS' .AND. hsurf(1:2)/='TS' &
123  .AND. SIZE(fg%XLAT).NE.1)) .AND. .NOT.gunif
124 IF (present(onovalue)) onovalue = gdefault
125 !
126 IF (.NOT. gdefault) THEN
127 !
128 !-------------------------------------------------------------------------------------
129 !
130 !* 2. Reading of input configuration (Grid and interpolation type)
131 !
132  IF (gunif) THEN
133  CALL prep_flake_unif(iluout,hsurf,zfieldin)
134  ELSE IF (yfiletype=='ASCLLV') THEN
135  CALL prep_flake_ascllv(dtco, ug, u, uss, &
136  hprogram,hsurf,iluout,zfieldin)
137  ELSE IF (yfiletype=='GRIB ') THEN
138  CALL prep_flake_grib(hprogram,hsurf,yfile,iluout,zfieldin)
139  ELSE IF (yfiletype=='MESONH' .OR. yfiletype=='ASCII ' .OR. yfiletype=='LFI '.OR. yfiletype=='FA ') THEN
140  CALL prep_flake_extern(&
141  hprogram,hsurf,yfile,yfiletype,yfilepgd,yfilepgdtype,iluout,zfieldin)
142  ELSE IF (yfiletype=='BUFFER') THEN
143  CALL prep_flake_buffer(hprogram,hsurf,iluout,zfieldin)
144  ELSE
145  CALL abor1_sfx('PREP_HOR_FLAKE_FIELD: data file type not supported : '//yfiletype)
146  END IF
147 !
148 !
149 !* 4. Horizontal interpolation
150 !
151  !ALLOCATE(ZFIELDOUT(SIZE(XLAT),SIZE(ZFIELDIN,2)))
152  ALLOCATE(zfieldout(SIZE(fg%XLAT),1))
153 !
154 !Impossible to interpolate lake profiles, only the lake surface temperature!
155 !But in uniform case and 1 point case
156  IF(gunif .OR. SIZE(fg%XLAT).EQ.1) THEN
157  CALL hor_interpol(dtco, u, &
158  iluout,zfieldin,zfieldout)
159  ELSE IF(hsurf(1:2)=='ZS' .OR. hsurf(1:2)=='TS') THEN
160  WRITE(iluout,*) "WARNING! Impossible to interpolate lake profiles in horisontal!"
161  WRITE(iluout,*) "So, interoplate only surface temperature and start from lakes mixed down to the bottom"
162  CALL hor_interpol(dtco, u, &
163  iluout,zfieldin,zfieldout)
164  END IF
165 !
166 !* 5. Return to historical variable
167 !
168  SELECT CASE (hsurf)
169  CASE('ZS ')
170  ALLOCATE(xzs_ls(SIZE(zfieldout,1)))
171  xzs_ls(:) = zfieldout(:,1)
172  CASE('TS ')
173  ALLOCATE(f%XTS(SIZE(zfieldout,1)))
174  f%XTS(:) = zfieldout(:,1)
175  CASE('T_SNOW ')
176  ALLOCATE(f%XT_SNOW(SIZE(zfieldout,1)))
177  f%XT_SNOW(:) = zfieldout(:,1)
178  CASE('T_ICE ')
179  ALLOCATE(f%XT_ICE(SIZE(zfieldout,1)))
180  f%XT_ICE(:) = zfieldout(:,1)
181  CASE('T_WML ')
182  ALLOCATE(f%XT_WML(SIZE(zfieldout,1)))
183  f%XT_WML(:) = zfieldout(:,1)
184  CASE('T_BOT ')
185  ALLOCATE(f%XT_BOT(SIZE(zfieldout,1)))
186  f%XT_BOT(:) = zfieldout(:,1)
187  CASE('T_B1 ')
188  ALLOCATE(f%XT_B1(SIZE(zfieldout,1)))
189  f%XT_B1(:) = zfieldout(:,1)
190  CASE('CT ')
191  ALLOCATE(f%XCT(SIZE(zfieldout,1)))
192  f%XCT(:) = zfieldout(:,1)
193  CASE('H_SNOW ')
194  ALLOCATE(f%XH_SNOW(SIZE(zfieldout,1)))
195  f%XH_SNOW(:) = zfieldout(:,1)
196  CASE('H_ICE ')
197  ALLOCATE(f%XH_ICE(SIZE(zfieldout,1)))
198  f%XH_ICE(:) = zfieldout(:,1)
199  CASE('H_ML ')
200  ALLOCATE(f%XH_ML(SIZE(zfieldout,1)))
201  f%XH_ML(:) = zfieldout(:,1)
202  CASE('H_B1 ')
203  ALLOCATE(f%XH_B1(SIZE(zfieldout,1)))
204  f%XH_B1(:) = zfieldout(:,1)
205  END SELECT
206 !* 6. Deallocations
207 !
208  IF (all(zfieldout==xundef)) gdefault = .true.
209 !
210  DEALLOCATE(zfieldin )
211  DEALLOCATE(zfieldout)
212 !
213 END IF
214 
215 !
216 IF (gdefault) THEN
217 !
218 !* 7. Initial values of FLAKE variables are computed from TS
219 ! when uniform values are not prescribed
220  IF (hsurf(1:2)/='ZS') WRITE(iluout,*) 'NO FILE FOR FIELD ',hsurf, &
221  ': UNIFORM DEFAULT FIELD IS PRESCRIBED'
222 
223 END IF
224 !
225 IF (lhook) CALL dr_hook('PREP_HOR_FLAKE_FIELD',1,zhook_handle)
226 !
227 !-------------------------------------------------------------------------------------
228 !
229 END SUBROUTINE prep_hor_flake_field
subroutine prep_flake_unif(KLUOUT, HSURF, PFIELD)
subroutine prep_flake_extern(HPROGRAM, HSURF, HFILE, HFILETYPE, HFILEPGD, HFILEPGDTYPE, KLUOUT, PFIELD)
subroutine prep_hor_flake_field(DTCO, UG, U, USS, FG, F, HPROGRAM, HSURF, HATMFILE, HATMFILETYPE, HPGDFILE, HPGDFILETYPE, ONOVALUE)
subroutine abor1_sfx(YTEXT)
Definition: abor1_sfx.F90:6
subroutine prep_flake_grib(HPROGRAM, HSURF, HFILE, KLUOUT, PFIELD)
subroutine hor_interpol(DTCO, U, KLUOUT, PFIELDIN, PFIELDOUT)
Definition: hor_interpol.F90:6
subroutine read_prep_flake_conf(HPROGRAM, HVAR, HFILE, HFILETYPE, HFILEPGD, HFILEPGDTYPE, HATMFILE, HATMFILETYPE, HPGDFILE, HPGDFILETYPE, KLUOUT, OUNIF)
subroutine get_luout(HPROGRAM, KLUOUT)
Definition: get_luout.F90:6
subroutine prep_flake_buffer(HPROGRAM, HSURF, KLUOUT, PFIELD)
subroutine prep_flake_ascllv(DTCO, UG, U, USS, HPROGRAM, HSURF, KLUOUT, PFIELD)