SURFEX v8.1
General documentation of Surfex
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 (GCP,HPROGRAM,HSURF,HFILE,HFILETYPE,HFILEPGD,HFILEPGDTYPE,KLUOUT,PFIELD)
7 ! #################################################################################
8 !
9 !
11 !
13 USE modd_surfex_mpi, ONLY : nrank,npio
14 !
16 !
17 USE modi_prep_grid_extern
19 USE modi_open_aux_io_surf
20 USE modi_close_aux_io_surf
21 USE modi_abor1_sfx
22 USE modi_get_luout
23 !
24 USE modd_surf_par, ONLY : xundef
25 !
26 USE yomhook ,ONLY : lhook, dr_hook
27 USE parkind1 ,ONLY : jprb
28 !
29 IMPLICIT NONE
30 !
31 !* 0.1 declarations of arguments
32 !
33 TYPE(grid_conf_proj_t),INTENT(INOUT) :: GCP
34 !
35  CHARACTER(LEN=6), INTENT(IN) :: HPROGRAM ! program calling surf. schemes
36  CHARACTER(LEN=7), INTENT(IN) :: HSURF ! type of field
37  CHARACTER(LEN=28), INTENT(IN) :: HFILE ! name of file
38  CHARACTER(LEN=6), INTENT(IN) :: HFILETYPE ! type of input file
39  CHARACTER(LEN=28), INTENT(IN) :: HFILEPGD ! name of file
40  CHARACTER(LEN=6), INTENT(IN) :: HFILEPGDTYPE ! type of input file
41 INTEGER, INTENT(IN) :: KLUOUT ! logical unit of output listing
42 REAL,DIMENSION(:,:), POINTER :: PFIELD ! field to interpolate horizontally
43 !
44 !* 0.2 declarations of local variables
45 !
46 !
47 REAL, DIMENSION(:), ALLOCATABLE :: ZMASK
48  CHARACTER(LEN=12) :: YRECFM ! Name of the article to be read
49 INTEGER :: IRESP ! reading return code
50 INTEGER :: ILUOUT
51 INTEGER :: IDIM_WATER
52 !
53 INTEGER :: IVERSION ! total 1D dimension
54 INTEGER :: INI ! total 1D dimension
55 REAL(KIND=JPRB) :: ZHOOK_HANDLE
56 !
57 !-------------------------------------------------------------------------------------
58 !
59 !* 1. Preparation of IO for reading in the file
60 ! -----------------------------------------
61 !
62 !* Note that all points are read, even those without physical meaning.
63 ! These points will not be used during the horizontal interpolation step.
64 ! Their value must be defined as XUNDEF.
65 !
66 IF (lhook) CALL dr_hook('PREP_WATFLUX_EXTERN',0,zhook_handle)
67 !
68 !-------------------------------------------------------------------------------------
69 !
70 !* 2. Reading of grid
71 ! ---------------
72 !
73  CALL open_aux_io_surf(hfilepgd,hfilepgdtype,'FULL ')
74  CALL prep_grid_extern(gcp,hfilepgdtype,kluout,cingrid_type,cinterp_type,ini)
75 !
76  CALL read_surf(hfilepgdtype,'DIM_WATER',idim_water,iresp,hdir='-')
77 !
78 yrecfm='VERSION'
79  CALL read_surf(hfilepgdtype,yrecfm,iversion,iresp)
80 !
81 IF (nrank/=npio) ini = 0
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 IF (nrank/=npio) ini=0
102 !
103 !---------------------------------------------------------------------------------------
104 SELECT CASE(hsurf)
105 !---------------------------------------------------------------------------------------
106 !
107 !* 3. Orography
108 ! ---------
109 !
110  CASE('ZS ')
111  ALLOCATE(pfield(ini,1))
112  yrecfm='ZS'
113  CALL read_surf(hfilepgdtype,yrecfm,pfield(:,1),iresp,hdir='E')
114  CALL close_aux_io_surf(hfilepgd,hfilepgdtype)
115 !
116 !* 4. Sea surface temperature
117 ! -----------------------
118 !
119  CASE('TSWATER')
120  ALLOCATE(pfield(ini,1))
121  yrecfm='TS_WATER'
122  CALL close_aux_io_surf(hfilepgd,hfilepgdtype)
123  CALL open_aux_io_surf(hfile,hfiletype,'WATER ')
124  CALL read_surf(hfiletype,yrecfm,pfield(:,1),iresp,hdir='E')
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
character(len=10) cingrid_type
Definition: modd_prep.F90:39
character(len=6) cinterp_type
Definition: modd_prep.F90:40
subroutine close_aux_io_surf(HFILE, HFILETYPE)
subroutine prep_grid_extern(GCP, HFILETYPE, KLUOUT, HGRIDTYPE, HINTER
subroutine abor1_sfx(YTEXT)
Definition: abor1_sfx.F90:7
real, parameter xundef
integer, parameter jprb
Definition: parkind1.F90:32
subroutine get_luout(HPROGRAM, KLUOUT)
Definition: get_luout.F90:7
logical lhook
Definition: yomhook.F90:15
subroutine open_aux_io_surf(HFILE, HFILETYPE, HMASK, HDIR)
subroutine prep_watflux_extern(GCP, HPROGRAM, HSURF, HFILE, HFILETYPE, HFILEPGD, HFILEPGDTYPE, KLUOUT, PFIELD)