SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
ini_var_from_vegtype_data.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 ini_var_from_vegtype_data (DTCO, DTI, UG, U, &
7  hprogram,iluout,hname,pfield,pdef)
8 ! ##############################################################
9 !!
10 !! PURPOSE
11 !! -------
12 !! interpol field with n pts
13 !!
14 !! METHOD
15 !! ------
16 !!
17 !! EXTERNAL
18 !! --------
19 !!
20 !! IMPLICIT ARGUMENTS
21 !! ------------------
22 !!
23 !! REFERENCE
24 !! ---------
25 !!
26 !! AUTHOR
27 !! ------
28 !!
29 !! S. FAROUX Meteo-France
30 !!
31 !! MODIFICATION
32 !! ------------
33 !! Original 12/2010
34 !!
35 !----------------------------------------------------------------------------
36 !!* 0. DECLARATION
37 ! -----------
38 !
39 !
40 !
41 !
43 USE modd_data_isba_n, ONLY : data_isba_t
45 USE modd_surf_atm_n, ONLY : surf_atm_t
46 !
47 USE modd_surf_par, ONLY : xundef
48 !
49 USE modi_get_surf_mask_n
50 USE modi_interpol_field
53 !
54 USE yomhook ,ONLY : lhook, dr_hook
55 USE parkind1 ,ONLY : jprb
56 !
57 IMPLICIT NONE
58 !
59 !* 0.1 Declaration of arguments
60 ! ------------------------
61 !
62 !
63 TYPE(data_cover_t), INTENT(INOUT) :: dtco
64 TYPE(data_isba_t), INTENT(INOUT) :: dti
65 TYPE(surf_atm_grid_t), INTENT(INOUT) :: ug
66 TYPE(surf_atm_t), INTENT(INOUT) :: u
67 !
68  CHARACTER(LEN=6), INTENT(IN) :: hprogram ! host model
69 INTEGER, INTENT(IN ) :: iluout
70  CHARACTER(LEN=*), INTENT(IN ) :: hname
71 REAL, DIMENSION(:,:), INTENT(INOUT) :: pfield
72 REAL, DIMENSION(:), OPTIONAL, INTENT(IN ) :: pdef
73 !
74 !* 0.2 Declaration of local variables
75 ! ------------------------------
76 !
77 REAL, DIMENSION(:), ALLOCATABLE :: zfield_tot
78 INTEGER, DIMENSION(:), ALLOCATABLE :: imask ! mask for packing from complete field to nature field
79 INTEGER, DIMENSION(:), ALLOCATABLE :: nsize, nsize_tot
80 INTEGER :: ini, ivegtype
81 INTEGER :: jvegtype ! loop counter on vegtypes
82 !
83 REAL(KIND=JPRB) :: zhook_handle
84 !
85 !-------------------------------------------------------------------------------
86 !
87 !* 1. Initializations
88 ! ---------------
89 !
90 IF (lhook) CALL dr_hook('INI_VAR_FROM_VEGTYPE_DATA',0,zhook_handle)
91 !
92 ini=SIZE(pfield,1)
93 ivegtype=SIZE(pfield,2)
94 !
95 ALLOCATE(imask(ini))
96 ALLOCATE(nsize(ini))
97 ALLOCATE(nsize_tot(u%NSIZE_FULL))
98 ALLOCATE(zfield_tot(u%NSIZE_FULL))
99 !
100  CALL get_surf_mask_n(dtco, u, &
101  'NATURE',ini,imask,u%NSIZE_FULL,iluout)
102 !
103 DO jvegtype=1,ivegtype
104  nsize(:)=0
105  WHERE (pfield(:,jvegtype).NE.xundef) nsize(:)=1
106  WHERE (dti%XPAR_VEGTYPE(:,jvegtype)==0.) nsize(:)=-1
107  CALL unpack_same_rank(imask,nsize,nsize_tot,-1)
108  CALL unpack_same_rank(imask,pfield(:,jvegtype),zfield_tot)
109  IF(present(pdef))THEN
110  CALL interpol_field(ug, u, &
111  hprogram,iluout,nsize_tot,zfield_tot,hname,pdef=pdef(jvegtype))
112  ELSE
113  CALL interpol_field(ug, u, &
114  hprogram,iluout,nsize_tot,zfield_tot,hname)
115  ENDIF
116  CALL pack_same_rank(imask,zfield_tot,pfield(:,jvegtype))
117 ENDDO
118 !
119 DEALLOCATE(imask)
120 DEALLOCATE(nsize)
121 DEALLOCATE(nsize_tot)
122 DEALLOCATE(zfield_tot)
123 !
124 IF (lhook) CALL dr_hook('INI_VAR_FROM_VEGTYPE_DATA',1,zhook_handle)
125 !
126 !-------------------------------------------------------------------------------
127 !
128 END SUBROUTINE ini_var_from_vegtype_data
subroutine ini_var_from_vegtype_data(DTCO, DTI, UG, U, HPROGRAM, ILUOUT, HNAME, PFIELD, PDEF)
subroutine get_surf_mask_n(DTCO, U, HTYPE, KDIM, KMASK, KLU, KLUOUT)
subroutine interpol_field(UG, U, HPROGRAM, KLUOUT, KCODE, PFIELD, HFIELD, PDEF, KNPTS)