SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
prep_watflux_extern.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_watflux_extern (&
7  hprogram,hsurf,hfile,hfiletype,hfilepgd,hfilepgdtype,kluout,pfield)
8 ! #################################################################################
9 !
10 !
11 !
12 !
14 !
15 USE modi_prep_grid_extern
17 USE modi_open_aux_io_surf
18 USE modi_close_aux_io_surf
19 USE modi_abor1_sfx
20 USE modi_get_luout
21 !
22 USE modd_surf_par, ONLY : xundef
23 USE modd_prep, ONLY : cingrid_type, cinterp_type
24 !
25 USE yomhook ,ONLY : lhook, dr_hook
26 USE parkind1 ,ONLY : jprb
27 !
28 IMPLICIT NONE
29 !
30 !* 0.1 declarations of arguments
31 !
32 !
33 !
34  CHARACTER(LEN=6), INTENT(IN) :: hprogram ! program calling surf. schemes
35  CHARACTER(LEN=7), INTENT(IN) :: hsurf ! type of field
36  CHARACTER(LEN=28), INTENT(IN) :: hfile ! name of file
37  CHARACTER(LEN=6), INTENT(IN) :: hfiletype ! type of input file
38  CHARACTER(LEN=28), INTENT(IN) :: hfilepgd ! name of file
39  CHARACTER(LEN=6), INTENT(IN) :: hfilepgdtype ! type of input file
40 INTEGER, INTENT(IN) :: kluout ! logical unit of output listing
41 REAL,DIMENSION(:,:), POINTER :: pfield ! field to interpolate horizontally
42 !
43 !* 0.2 declarations of local variables
44 !
45 !
46 REAL, DIMENSION(:), ALLOCATABLE :: zmask
47  CHARACTER(LEN=12) :: yrecfm ! Name of the article to be read
48 INTEGER :: iresp ! reading return code
49 INTEGER :: iluout
50 INTEGER :: idim_water
51 !
52 INTEGER :: iversion ! total 1D dimension
53 INTEGER :: ini ! total 1D dimension
54 REAL(KIND=JPRB) :: zhook_handle
55 !
56 !-------------------------------------------------------------------------------------
57 !
58 !* 1. Preparation of IO for reading in the file
59 ! -----------------------------------------
60 !
61 !* Note that all points are read, even those without physical meaning.
62 ! These points will not be used during the horizontal interpolation step.
63 ! Their value must be defined as XUNDEF.
64 !
65 IF (lhook) CALL dr_hook('PREP_WATFLUX_EXTERN',0,zhook_handle)
66 !
67 !-------------------------------------------------------------------------------------
68 !
69 !* 2. Reading of grid
70 ! ---------------
71 !
72  CALL open_aux_io_surf(&
73  hfilepgd,hfilepgdtype,'FULL ')
74  CALL prep_grid_extern(&
75  hfilepgdtype,kluout,cingrid_type,cinterp_type,ini)
76 !
77  CALL read_surf(&
78  hfilepgdtype,'DIM_WATER',idim_water,iresp)
79 !
80 yrecfm='VERSION'
81  CALL read_surf(hfilepgdtype,yrecfm,iversion,iresp)
82 !
83 ALLOCATE(zmask(ini))
84 IF (iversion>=7) THEN
85  yrecfm='FRAC_WATER'
86  CALL read_surf(hfilepgdtype,yrecfm,zmask,iresp,hdir='A')
87 ELSE
88  zmask(:) = 1.
89 ENDIF
90 !
91 IF (idim_water==0) THEN
92  CALL get_luout(hprogram,iluout)
93  WRITE(iluout,*) ' '
94  WRITE(iluout,*) 'No inland water data available in input file ',hfile
95  WRITE(iluout,*) 'Please change your input file '
96  WRITE(iluout,*) ' or '
97  WRITE(iluout,*) 'specify inland water temperature XTS_WATER_UNIF'
98  CALL abor1_sfx('PREP_WATFLUX_EXTERN: No inland water data available in input file')
99 END IF
100 !---------------------------------------------------------------------------------------
101 SELECT CASE(hsurf)
102 !---------------------------------------------------------------------------------------
103 !
104 !* 3. Orography
105 ! ---------
106 !
107  CASE('ZS ')
108  ALLOCATE(pfield(ini,1))
109  yrecfm='ZS'
110  CALL read_surf(&
111  hfilepgdtype,yrecfm,pfield(:,1),iresp,hdir='A')
112  CALL close_aux_io_surf(hfilepgd,hfilepgdtype)
113 !
114 !* 4. Sea surface temperature
115 ! -----------------------
116 !
117  CASE('TSWATER')
118  ALLOCATE(pfield(ini,1))
119  yrecfm='TS_WATER'
120  CALL close_aux_io_surf(hfilepgd,hfilepgdtype)
121  CALL open_aux_io_surf(&
122  hfile,hfiletype,'WATER ')
123  CALL read_surf(&
124  hfiletype,yrecfm,pfield(:,1),iresp,hdir='A')
125  CALL close_aux_io_surf(hfile,hfiletype)
126  WHERE (zmask(:)==0.) pfield(:,1) = xundef
127 !
128 !---------------------------------------------------------------------------------------
129 END SELECT
130 !-------------------------------------------------------------------------------------
131 !
132 DEALLOCATE(zmask)
133 !
134 !* 6. End of IO
135 ! ---------
136 !
137 IF (lhook) CALL dr_hook('PREP_WATFLUX_EXTERN',1,zhook_handle)
138 !
139 !---------------------------------------------------------------------------------------
140 !
141 END SUBROUTINE prep_watflux_extern
subroutine close_aux_io_surf(HFILE, HFILETYPE)
subroutine prep_watflux_extern(HPROGRAM, HSURF, HFILE, HFILETYPE, HFILEPGD, HFILEPGDTYPE, KLUOUT, PFIELD)
subroutine abor1_sfx(YTEXT)
Definition: abor1_sfx.F90:6
subroutine open_aux_io_surf(HFILE, HFILETYPE, HMASK)
subroutine get_luout(HPROGRAM, KLUOUT)
Definition: get_luout.F90:6
subroutine prep_grid_extern(HFILETYPE, KLUOUT, HGRIDTYPE, HINTERP_TYPE, KNI)