SURFEX v8.1
General documentation of Surfex
treat_global_lake_depth.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 treat_global_lake_depth (DTCO, UG, U, USS, &
7  HPROGRAM,PDEPTH,KSTATUS)
8 ! ##############################################################
9 !
10 !!**** *TREAT_GLOBAL_LAKE_DEPTH* monitor for averaging and interpolations of ISBA physiographic fields
11 !!
12 !! PURPOSE
13 !! -------
14 !!
15 !! METHOD
16 !! ------
17 !!
18 !
19 !! EXTERNAL
20 !! --------
21 !!
22 !! IMPLICIT ARGUMENTS
23 !! ------------------
24 !!
25 !! REFERENCE
26 !! ---------
27 !!
28 !! AUTHOR
29 !! ------
30 !!
31 !! S. Faroux Meteo-France
32 !!
33 !! MODIFICATION
34 !! ------------
35 !!
36 !! Original 17/02/11
37 !!
38 !----------------------------------------------------------------------------
39 !
40 !* 0. DECLARATION
41 ! -----------
42 !
43 USE modd_surfex_mpi, ONLY : nrank, npio
44 !
47 USE modd_surf_atm_n, ONLY : surf_atm_t
48 USE modd_sso_n, ONLY : sso_t
49 !
50 USE modd_surf_par, ONLY : xundef
51 USE modd_pgd_grid, ONLY : nl
54 !
55 USE modi_get_luout
56 USE modi_treat_field
58 !
59 USE yomhook ,ONLY : lhook, dr_hook
60 USE parkind1 ,ONLY : jprb
61 !
62 USE modi_abor1_sfx
63 USE modi_get_surf_mask_n
64 USE modi_get_type_dim_n
65 !
66 IMPLICIT NONE
67 !
68 !* 0.1 Declaration of arguments
69 ! ------------------------
70 !
71 !
72 TYPE(data_cover_t), INTENT(INOUT) :: DTCO
73 TYPE(surf_atm_grid_t), INTENT(INOUT) :: UG
74 TYPE(surf_atm_t), INTENT(INOUT) :: U
75 TYPE(sso_t), INTENT(INOUT) :: USS
76 !
77  CHARACTER(LEN=6), INTENT(IN) :: HPROGRAM ! Type of program
78 REAL, DIMENSION(:),INTENT(OUT):: PDEPTH ! physiographic field
79 INTEGER, DIMENSION(:),INTENT(OUT):: KSTATUS ! physiographic field
80 !
81 !
82 !* 0.2 Declaration of local variables
83 ! ------------------------------
84 !
85 INTEGER :: ILU ! expected physical size of full surface array
86 INTEGER :: ILUOUT ! output listing logical unit
87 INTEGER, DIMENSION(:), POINTER :: IMASK ! mask for packing from complete field to nature field
88 INTEGER :: IDIM !
89 INTEGER :: JI
90 !
91  CHARACTER(LEN=6) :: YMASK
92 INTEGER, DIMENSION(NL) :: ISTATUS
93 REAL, DIMENSION(NL,1) :: ZDEPTH, ZSTATUS ! physiographic field on full grid
94 REAL(KIND=JPRB) :: ZHOOK_HANDLE
95 !-------------------------------------------------------------------------------
96 !
97 !* 1. Initializations
98 ! ---------------
99 !
100 IF (lhook) CALL dr_hook('TREAT_GLOBAL_LAKE_DEPTH',0,zhook_handle)
101 zdepth(:,:) = xundef
102 zstatus(:,:) = xundef
103 !-------------------------------------------------------------------------------
104 !
105 !* 2. Output listing logical unit
106 ! ---------------------------
107 !
108  CALL get_luout(hprogram,iluout)
109 !
110 !-------------------------------------------------------------------------------
111 !
112 !* 4. Averages the field
113 ! ------------------
114 !
115 ALLOCATE(nsize_all(u%NDIM_FULL,1))
116 ALLOCATE(xall(u%NDIM_FULL,ngraddepth_ldb,1))
117 !
118 nsize_all(:,:) = 0.
119 xall(:,:,:) = 0.
120 !
121  CALL treat_field(ug, u, uss, &
122  hprogram,'SURF ','DIRECT','A_LDBD', clakeldb, &
123  'water depth ',zdepth )
124 !
125 DEALLOCATE(xsumval)
126 DEALLOCATE(nsize)
127 !
128 ALLOCATE(nsize_all(u%NDIM_FULL,1))
129 ALLOCATE(xall(u%NDIM_FULL,ngradstatus_ldb,1))
130 !
131 nsize_all(:,:) = 0.
132 xall(:,:,:) = 0.
133 !
134  CALL treat_field(ug, u, uss, &
135  hprogram,'SURF ','DIRECT','A_LDBS', cstatusldb, &
136  'water status ',zstatus )
137 !
138 istatus = nint(zstatus(:,1))
139 !
140 DEALLOCATE(xsumval)
141 DEALLOCATE(nsize)
142 !
143 !-------------------------------------------------------------------------------
144 !
145 !* 5. Consistancy check
146 ! ------------------
147 !
148 DO ji = 1, SIZE(zdepth,1)
149  IF (u%XWATER(ji).GT.0.) THEN
150  IF (istatus(ji).LE.2) zdepth(ji,1) = 10.
151  IF (istatus(ji)==3.AND.zdepth(ji,1)==0.) zdepth(ji,1) = 10.
152  ELSE
153  zdepth(ji,1) = 0.
154  ENDIF
155 ENDDO
156 !
157 !* 6. Mask for the field
158 ! ------------------
159 !
160 ymask='WATER '
161  CALL get_type_dim_n(dtco, u, &
162  ymask,idim)
163 IF (idim/=SIZE(pdepth) .OR. idim/=SIZE(kstatus)) THEN
164  WRITE(iluout,*)'Wrong dimension of MASK: ',idim,SIZE(pdepth),SIZE(kstatus)
165  CALL abor1_sfx('TREAT_GLOBAL_LAKE_DEPTH: WRONG DIMENSION OF MASK')
166 ENDIF
167 
168 ALLOCATE(imask(idim))
169 ilu=0
170  CALL get_surf_mask_n(dtco, u, &
171  ymask,idim,imask,ilu,iluout)
172  CALL pack_same_rank(imask,zdepth(:,1),pdepth(:))
173  CALL pack_same_rank(imask,istatus(:),kstatus(:))
174 DEALLOCATE(imask)
175 !
176 IF (lhook) CALL dr_hook('TREAT_GLOBAL_LAKE_DEPTH',1,zhook_handle)
177 !
178 !-------------------------------------------------------------------------------
179 !
180 END SUBROUTINE treat_global_lake_depth
subroutine get_type_dim_n(DTCO, U, HTYPE, KDIM)
integer, dimension(:,:), allocatable nsize_all
integer, parameter ngraddepth_ldb
real, dimension(:,:,:), allocatable xall
subroutine abor1_sfx(YTEXT)
Definition: abor1_sfx.F90:7
real, parameter xundef
subroutine get_surf_mask_n(DTCO, U, HTYPE, KDIM, KMASK, KLU, KLUOUT)
integer, parameter jprb
Definition: parkind1.F90:32
real, dimension(:,:), allocatable xsumval
subroutine get_luout(HPROGRAM, KLUOUT)
Definition: get_luout.F90:7
subroutine treat_global_lake_depth(DTCO, UG, U, USS, HPROGRAM, PDEPTH, KSTATUS)
logical lhook
Definition: yomhook.F90:15
character(len=80), parameter clakeldb
integer, dimension(:,:), allocatable nsize
integer, parameter ngradstatus_ldb
character(len=80), parameter cstatusldb
subroutine treat_field(UG, U, USS, HPROGRAM, HSCHEME, HFILETYPE, HSUBROUTINE, HFILENAME, HFIELD, PPGDARRAY)
Definition: treat_field.F90:10