SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
vegtype_grid_to_patch_grid.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 vegtype_grid_to_patch_grid(KPATCH,PVEGTYPE_PATCH,PPATCH,PFIELDOUT,PW)
7 ! ################################################
8 !!
9 !!**** *VEGTYPE_GRID_TO_PATCH_GRID* averages fields from all (12) vegtypes
10 !! on only a few patches
11 !! PURPOSE
12 !! -------
13 !
14 !
15 !!** METHOD
16 !! ------
17 !!
18 !! REFERENCE
19 !! ---------
20 !!
21 !!
22 !! AUTHOR
23 !! ------
24 !!
25 !! V. Masson * Meteo-France *
26 !!
27 !! MODIFICATIONS
28 !! -------------
29 !! Original 01/2004
30 !!
31 !-------------------------------------------------------------------------------
32 
33 !
34 USE modd_surf_par, ONLY : xundef
35 USE modd_data_cover_par, ONLY : nvegtype
36 !
37 USE modi_vegtype_to_patch
38 !
39 !
40 USE yomhook ,ONLY : lhook, dr_hook
41 USE parkind1 ,ONLY : jprb
42 !
43 IMPLICIT NONE
44 !
45 !
46 !* 0.1 declarations of arguments
47 !
48 INTEGER, INTENT(IN) :: kpatch
49 REAL, DIMENSION(:,:,:), INTENT(IN) :: pvegtype_patch
50 REAL, DIMENSION(:,:), INTENT(IN) :: ppatch
51 REAL, DIMENSION(:,:,:), INTENT(IN) :: pfieldout
52 REAL, DIMENSION(:,:,:), INTENT(OUT) :: pw
53 !
54 !
55 !* 0.2 declarations of local variables
56 !
57 INTEGER :: jpatch ! loop on patches
58 INTEGER :: jvegtype ! loop on vegtypes
59 INTEGER :: jlayer ! loop on layers
60 REAL(KIND=JPRB) :: zhook_handle
61 !
62 !---------------------------------------------------------------------------
63 !
64 !* averages from vegtypes to chosen number of patches
65 IF (lhook) CALL dr_hook('VEGTYPE_GRID_TO_PATCH_GRID',0,zhook_handle)
66 pw(:,:,:) = 0.
67 DO jvegtype=1,nvegtype
68  jpatch = vegtype_to_patch(jvegtype,kpatch)
69  DO jlayer=1,SIZE(pw,2)
70  pw(:,jlayer,jpatch) = pw(:,jlayer,jpatch) &
71  + pvegtype_patch(:,jvegtype,jpatch) * pfieldout(:,jlayer,jvegtype)
72  END DO
73 END DO
74 !
75 !* insures undefined value when patch is not present
76 DO jpatch=1,kpatch
77  DO jlayer=1,SIZE(pw,2)
78  WHERE(ppatch(:,jpatch)==0.) pw(:,jlayer,jpatch) = xundef
79  END DO
80 END DO
81 WHERE( abs(pw-xundef)/xundef < 1.e-6 ) pw = xundef
82 IF (lhook) CALL dr_hook('VEGTYPE_GRID_TO_PATCH_GRID',1,zhook_handle)
83 !
84 !---------------------------------------------------------------------------
85 !
86 END SUBROUTINE vegtype_grid_to_patch_grid
integer function vegtype_to_patch(IVEGTYPE, INPATCH)
subroutine vegtype_grid_to_patch_grid(KPATCH, PVEGTYPE_PATCH, PPATCH, PFIELDOUT, PW)