SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
read_surf_isba_parn.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 read_surf_isba_par_n (DTCO, U, I, &
7  hprogram,hrec,kluout,ksize,pfield,kresp,kversion,hcomment,hdir)
8 ! #######################
9 !
10 !
11 !
12 !
13 !
14 !
16 USE modd_surf_atm_n, ONLY : surf_atm_t
17 !
18 !
19 USE modd_isba_n, ONLY : isba_t
20 !
21 USE modd_data_cover_par, ONLY : nvegtype
22 !
24 USE modi_hor_interpol
25 USE modi_put_on_all_vegtypes
26 USE modi_vegtype_to_patch
27 !
28 USE yomhook ,ONLY : lhook, dr_hook
29 USE parkind1 ,ONLY : jprb
30 !
31 IMPLICIT NONE
32 !
33 !
34 !
35 !
36 TYPE(data_cover_t), INTENT(INOUT) :: dtco
37 TYPE(surf_atm_t), INTENT(INOUT) :: u
38 !
39 !
40 TYPE(isba_t), INTENT(INOUT) :: i
41 !
42  CHARACTER(LEN=6), INTENT(IN) :: hprogram ! calling program
43  CHARACTER(LEN=*), INTENT(IN) :: hrec ! name of the article to be read
44 !
45 INTEGER, INTENT(IN) :: kluout
46 INTEGER, INTENT(IN) :: ksize
47 REAL, DIMENSION(:,:), INTENT(OUT):: pfield ! array containing the data field
48 
49 INTEGER ,INTENT(OUT) :: kresp ! KRESP : return-code if a problem appears
50 INTEGER, INTENT(IN) :: kversion
51  CHARACTER(LEN=*),OPTIONAL,INTENT(OUT) :: hcomment ! name of the article to be read
52  CHARACTER(LEN=1),OPTIONAL,INTENT(IN) :: hdir ! type of field :
53 ! ! 'H' : field with
54 ! ! horizontal spatial dim.
55 ! ! '-' : no horizontal dim.
56 !
57 !* local variables
58 ! ---------------
59 !
60 REAL, DIMENSION(KSIZE, NVEGTYPE) :: zfield
61 REAL, DIMENSION(SIZE(PFIELD,1),1,I%NPATCH) :: zfield_patch
62 REAL, DIMENSION(SIZE(PFIELD,1),1,NVEGTYPE) :: zfield_vegtype
63  CHARACTER(LEN=1) :: ydir
64 INTEGER :: ini, jpatch, ipatch, jvegtype
65 REAL(KIND=JPRB) :: zhook_handle
66 !
67 !-------------------------------------------------------------------
68 IF (lhook) CALL dr_hook('READ_SURF_ISBA_PAR_n',0,zhook_handle)
69 !
70 ydir = 'H'
71 IF (present(hdir)) ydir = hdir
72 !
73 ini = SIZE(pfield,1)
74 !
75 IF (kversion<7) THEN
76  CALL read_surf(&
77  hprogram,hrec,zfield(:,1:i%NPATCH),kresp,hcomment=hcomment,hdir=ydir)
78  IF (ini.NE.ksize) THEN
79  CALL hor_interpol(dtco, u, &
80  kluout,zfield(:,1:i%NPATCH),pfield(:,1:i%NPATCH))
81  ELSE
82  pfield(:,1:i%NPATCH) = zfield(:,1:i%NPATCH)
83  ENDIF
84  DO jpatch = 1, i%NPATCH
85  zfield_patch(:,1,jpatch) = pfield(:,jpatch)
86  ENDDO
87  CALL put_on_all_vegtypes(ini,1,i%NPATCH,nvegtype,zfield_patch,zfield_vegtype)
88  pfield(:,:) = zfield_vegtype(:,1,:)
89 ELSE
90  CALL read_surf(&
91  hprogram,hrec,zfield(:,:),kresp,hcomment=hcomment,hdir=ydir)
92  IF (ini.NE.ksize) THEN
93  CALL hor_interpol(dtco, u, &
94  kluout,zfield(:,:),zfield_vegtype(:,1,:))
95  ELSE
96  zfield_vegtype(:,1,:) = zfield(:,:)
97  ENDIF
98  IF (SIZE(pfield,2).NE.nvegtype) THEN
99  ipatch = SIZE(pfield,2)
100  pfield(:,:) = 0.
101  DO jvegtype = 1, nvegtype
102  jpatch = vegtype_to_patch(jvegtype,ipatch)
103  IF (jpatch<=ipatch) pfield(:,jpatch) = max(pfield(:,jpatch),zfield_vegtype(:,1,jvegtype))
104  ENDDO
105  ELSE
106  pfield(:,:) = zfield_vegtype(:,1,:)
107  ENDIF
108 ENDIF
109 !
110 IF (lhook) CALL dr_hook('READ_SURF_ISBA_PAR_n',1,zhook_handle)
111 !-------------------------------------------------------------------
112 !
113 END SUBROUTINE read_surf_isba_par_n
integer function vegtype_to_patch(IVEGTYPE, INPATCH)
subroutine read_surf_isba_par_n(DTCO, U, I, HPROGRAM, HREC, KLUOUT, KSIZE, PFIELD, KRESP, KVERSION, HCOMMENT, HDIR)
subroutine hor_interpol(DTCO, U, KLUOUT, PFIELDIN, PFIELDOUT)
Definition: hor_interpol.F90:6
subroutine put_on_all_vegtypes(KNI, KLAYER, KPATCH, KVEGTYPE, PFIELD_PATCH, PFIELD_VEGTYPE)