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