SURFEX v8.1
General documentation of Surfex
prep_hor_watflux_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_watflux_field (DTCO, U, GCP, KLAT, W, &
7  HPROGRAM,HSURF,HATMFILE,HATMFILETYPE,HPGDFILE,HPGDFILETYPE,YDCTL)
8 ! #################################################################################
9 !
10 !!**** *PREP_HOR_WATFLUX_FIELD* - Reads, interpolates and prepares a water field
11 !!
12 !! PURPOSE
13 !! -------
14 !
15 !!** METHOD
16 !! ------
17 !!
18 !! REFERENCE
19 !! ---------
20 !!
21 !!
22 !! AUTHOR
23 !! ------
24 !! S. Malardel
25 !!
26 !! MODIFICATIONS
27 !! -------------
28 !! Original 01/2004
29 !! P. Le Moigne 10/2005, Phasage Arome
30 !! P. Marguinaud10/2014, Support for a 2-part PREP
31 !!------------------------------------------------------------------
32 !
34 USE modd_surf_atm_n, ONLY : surf_atm_t
36 !
37 USE modd_watflux_n, ONLY : watflux_t
38 !
40 USE modd_surfex_mpi, ONLY : nrank, npio, ncomm, nproc
41 !
43 !
44 USE modd_grid_grib, ONLY : cinmodel
45 !
47 !
48 USE modi_prep_grib_grid
49 USE modi_read_prep_watflux_conf
50 USE modi_prep_watflux_grib
51 USE modi_prep_watflux_unif
52 USE modi_prep_watflux_buffer
53 USE modi_hor_interpol
54 USE modi_get_luout
55 USE modi_prep_watflux_extern
56 !
57 USE yomhook ,ONLY : lhook, dr_hook
58 USE parkind1 ,ONLY : jprb
59 !
60 USE modi_abor1_sfx
61 IMPLICIT NONE
62 !
63 #ifdef SFX_MPI
64 include "mpif.h"
65 #endif
66 !
67 !* 0.1 declarations of arguments
68 !
69 TYPE(data_cover_t), INTENT(INOUT) :: DTCO
70 TYPE(surf_atm_t), INTENT(INOUT) :: U
71 TYPE(grid_conf_proj_t),INTENT(INOUT) :: GCP
72 !
73 INTEGER, INTENT(IN) :: KLAT
74 TYPE(watflux_t), INTENT(INOUT) :: W
75 type(prep_ctl), INTENT (INOUT) :: ydctl
76 !
77  CHARACTER(LEN=6), INTENT(IN) :: HPROGRAM ! program calling surf. schemes
78  CHARACTER(LEN=7), INTENT(IN) :: HSURF ! type of field
79  CHARACTER(LEN=28), INTENT(IN) :: HATMFILE ! name of the Atmospheric file
80  CHARACTER(LEN=6), INTENT(IN) :: HATMFILETYPE! type of the Atmospheric file
81  CHARACTER(LEN=28), INTENT(IN) :: HPGDFILE ! name of the Atmospheric file
82  CHARACTER(LEN=6), INTENT(IN) :: HPGDFILETYPE! type of the Atmospheric file
83 !
84 !* 0.2 declarations of local variables
85 !
86  CHARACTER(LEN=6) :: YFILETYPE ! type of input file
87  CHARACTER(LEN=28) :: YFILE ! name of file
88  CHARACTER(LEN=6) :: YFILEPGDTYPE ! type of input file
89  CHARACTER(LEN=28) :: YFILEPGD ! name of file
90  type(date_time) :: tztime_grib ! current date and time
91 REAL, POINTER, DIMENSION(:,:) :: ZFIELDIN ! field to interpolate horizontally
92 REAL, POINTER, DIMENSION(:,:) :: ZFIELDOUT ! field interpolated horizontally
93 INTEGER :: ILUOUT ! output listing logical unit
94 !
95 LOGICAL :: GUNIF ! flag for prescribed uniform field
96 INTEGER :: INFOMPI, INL
97 REAL(KIND=JPRB) :: ZHOOK_HANDLE
98 !-------------------------------------------------------------------------------------
99 !
100 !
101 !* 1. Reading of input file name and type
102 !
103 IF (lhook) CALL dr_hook('PREP_HOR_WATFLUX_FIELD',0,zhook_handle)
104  CALL get_luout(hprogram,iluout)
105 !
106  CALL read_prep_watflux_conf(hprogram,hsurf,yfile,yfiletype,yfilepgd,yfilepgdtype,&
107  hatmfile,hatmfiletype,hpgdfile,hpgdfiletype,iluout,gunif)
108 !
109 cmask = 'WATER'
110 !
111 !-------------------------------------------------------------------------------------
112 !
113 !* 2. Reading of input configuration (Grid and interpolation type)
114 !
115 NULLIFY (zfieldin, zfieldout)
116 !
117 IF (ydctl%LPART1) THEN
118  IF (gunif) THEN
119  CALL prep_watflux_unif(iluout,hsurf,zfieldin)
120  ELSE IF (yfiletype=='GRIB ') THEN
121  CALL prep_grib_grid(yfile,iluout,cinmodel,cingrid_type,cinterp_type,tztime_grib)
122  IF (nrank==npio) CALL prep_watflux_grib(hprogram,hsurf,yfile,iluout,zfieldin)
123  ELSE IF (yfiletype=='MESONH' .OR. yfiletype=='ASCII ' .OR. yfiletype=='LFI '&
124  .OR. yfiletype=='FA '.OR. yfiletype=='AROME '.OR.yfiletype=='NC ') THEN
125  CALL prep_watflux_extern(gcp,hprogram,hsurf,yfile,yfiletype,yfilepgd,yfilepgdtype,iluout,zfieldin)
126  ELSE IF (yfiletype=='BUFFER') THEN
127  CALL prep_watflux_buffer(hprogram,hsurf,iluout,zfieldin)
128  ELSE
129  CALL abor1_sfx('PREP_HOR_WATFLUX_FIELD: data file type not supported : '//yfiletype)
130  END IF
131 ENDIF
132 !
133 !
134 !* 4. Horizontal interpolation
135 !
136  CALL prep_ctl_int_part2 (ydctl, hsurf, 'WATER', cmask, zfieldin)
137 !
138 IF (ydctl%LPART3) THEN
139 !
140  IF (nrank==npio) THEN
141  inl = SIZE(zfieldin,2)
142  ELSEIF (.NOT.ASSOCIATED(zfieldin)) THEN
143  ALLOCATE(zfieldin(0,0))
144  ENDIF
145  !
146  IF (nproc>1) THEN
147 #ifdef SFX_MPI
148  CALL mpi_bcast(inl,kind(inl)/4,mpi_integer,npio,ncomm,infompi)
149 #endif
150  ENDIF
151  ALLOCATE(zfieldout(klat,inl))
152  !
153  CALL hor_interpol(dtco, u, gcp, iluout,zfieldin,zfieldout)
154  !
155 ENDIF
156 !
157  CALL prep_ctl_int_part4 (ydctl, hsurf, 'WATER', cmask, zfieldin, zfieldout)
158 !
159 IF (ydctl%LPART5) THEN
160 !
161 !* 5. Return to historical variable
162 !
163  SELECT CASE (hsurf)
164  CASE('ZS ')
165  ALLOCATE(xzs_ls(SIZE(zfieldout,1)))
166  xzs_ls(:) = zfieldout(:,1)
167  CASE('TSWATER')
168  ALLOCATE(w%XTS(SIZE(zfieldout,1)))
169  w%XTS(:) = zfieldout(:,1)
170  END SELECT
171 !
172 ENDIF
173 !
174 !-------------------------------------------------------------------------------------
175 !
176 !* 6. Deallocations
177 !
178 IF (ASSOCIATED (zfieldin)) DEALLOCATE(zfieldin )
179 IF (ASSOCIATED (zfieldout)) DEALLOCATE(zfieldout)
180 IF (lhook) CALL dr_hook('PREP_HOR_WATFLUX_FIELD',1,zhook_handle)
181 !
182 !-------------------------------------------------------------------------------------
183 !
184 END SUBROUTINE prep_hor_watflux_field
subroutine prep_grib_grid(HGRIB, KLUOUT, HINMODEL, HGRIDTYPE, HINTERP_
character(len=10) cingrid_type
Definition: modd_prep.F90:39
subroutine prep_hor_watflux_field(DTCO, U, GCP, KLAT, W, HPROGRAM, HSURF, HATMFILE, HATMFILETYPE, HPGDFILE, HPGDFILETYPE, YDCTL)
real, dimension(:), allocatable xzs_ls
Definition: modd_prep.F90:45
character(len=6) cmask
Definition: modd_prep.F90:41
character(len=6) cinterp_type
Definition: modd_prep.F90:40
subroutine prep_watflux_unif(KLUOUT, HSURF, PFIELD)
subroutine abor1_sfx(YTEXT)
Definition: abor1_sfx.F90:7
character(len=6) cinmodel
subroutine hor_interpol(DTCO, U, GCP, KLUOUT, PFIELDIN, PFIELDOUT)
Definition: hor_interpol.F90:7
integer, parameter jprb
Definition: parkind1.F90:32
subroutine prep_watflux_buffer(HPROGRAM, HSURF, KLUOUT, PFIELD)
subroutine prep_watflux_grib(HPROGRAM, HSURF, HFILE, KLUOUT, PFIELD)
subroutine get_luout(HPROGRAM, KLUOUT)
Definition: get_luout.F90:7
logical lhook
Definition: yomhook.F90:15
subroutine read_prep_watflux_conf(HPROGRAM, HVAR, HFILE, HFILETYPE, HF
subroutine prep_watflux_extern(GCP, HPROGRAM, HSURF, HFILE, HFILETYPE, HFILEPGD, HFILEPGDTYPE, KLUOUT, PFIELD)