SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
read_seafluxn.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_seaflux_n (DTCO, SG, S, U, &
7  hprogram,kluout)
8 ! #########################################
9 !
10 !!**** *READ_SEAFLUX_n* - read SEAFLUX varaibles
11 !!
12 !!
13 !! PURPOSE
14 !! -------
15 !!
16 !!** METHOD
17 !! ------
18 !!
19 !! EXTERNAL
20 !! --------
21 !!
22 !!
23 !! IMPLICIT ARGUMENTS
24 !! ------------------
25 !!
26 !! REFERENCE
27 !! ---------
28 !!
29 !!
30 !! AUTHOR
31 !! ------
32 !! V. Masson *Meteo France*
33 !!
34 !! MODIFICATIONS
35 !! -------------
36 !! Original 01/2003
37 !! Modified 02/2008 Add oceanic variables initialisation
38 !! S. Belamari 04/2014 Suppress LMERCATOR
39 !! R. Séférian 01/2015 introduce new ocean surface albedo
40 !-------------------------------------------------------------------------------
41 !
42 !* 0. DECLARATIONS
43 ! ------------
44 !
45 !
46 !
47 !
50 USE modd_seaflux_n, ONLY : seaflux_t
51 USE modd_surf_atm_n, ONLY : surf_atm_t
52 !
53 USE modd_surf_par, ONLY : xundef
54 !
56 USE modi_interpol_sst_mth
57 !
58 USE modi_get_type_dim_n
59 USE modi_abor1_sfx
60 !
61 USE yomhook ,ONLY : lhook, dr_hook
62 USE parkind1 ,ONLY : jprb
63 !
64 IMPLICIT NONE
65 !
66 !* 0.1 Declarations of arguments
67 ! -------------------------
68 !
69 !
70 TYPE(data_cover_t), INTENT(INOUT) :: dtco
71 TYPE(seaflux_grid_t), INTENT(INOUT) :: sg
72 TYPE(seaflux_t), INTENT(INOUT) :: s
73 TYPE(surf_atm_t), INTENT(INOUT) :: u
74 !
75  CHARACTER(LEN=6), INTENT(IN) :: hprogram ! calling program
76 INTEGER, INTENT(IN) :: kluout
77 !
78 !* 0.2 Declarations of local variables
79 ! -------------------------------
80 !
81 INTEGER :: jmth, inmth
82  CHARACTER(LEN=2 ) :: ymth
83 !
84 INTEGER :: ilu ! 1D physical dimension
85 !
86 INTEGER :: iresp ! Error code after redding
87 !
88  CHARACTER(LEN=12) :: yrecfm ! Name of the article to be read
89 !
90 INTEGER :: iversion ! surface version
91 !
92 REAL(KIND=JPRB) :: zhook_handle
93 !
94 !-------------------------------------------------------------------------------
95 !
96 !* 1D physical dimension
97 !
98 IF (lhook) CALL dr_hook('READ_SEAFLUX_N',0,zhook_handle)
99 !
100 yrecfm='SIZE_SEA'
101  CALL get_type_dim_n(dtco, u, &
102  'SEA ',ilu)
103 !
104 !* 2. Prognostic fields:
105 ! -----------------
106 !
107 !* water temperature
108 !
109 ALLOCATE(s%XSST(ilu))
110 !
111 IF(s%LINTERPOL_SST)THEN
112 !
113 ! Precedent, Current, Next, and Second-next Monthly SST
114  inmth=4
115 !
116  ALLOCATE(s%XSST_MTH(SIZE(s%XSST),inmth))
117  DO jmth=1,inmth
118  WRITE(ymth,'(I2)') (jmth-1)
119  yrecfm='SST_MTH'//adjustl(ymth(:len_trim(ymth)))
120  CALL read_surf(&
121  hprogram,yrecfm,s%XSST_MTH(:,jmth),iresp)
122  ENDDO
123 !
124  CALL interpol_sst_mth(s, &
125  s%TTIME%TDATE%YEAR,s%TTIME%TDATE%MONTH,s%TTIME%TDATE%DAY,'T',s%XSST)
126 !
127 ELSE
128 !
129  ALLOCATE(s%XSST_MTH(0,0))
130 !
131  yrecfm='SST'
132  CALL read_surf(&
133  hprogram,yrecfm,s%XSST(:),iresp)
134 !
135 ENDIF
136 !
137 !* stochastic flux perturbation pattern
138 !
139 ALLOCATE(s%XPERTFLUX(ilu))
140 IF( s%LPERTFLUX ) THEN
141  CALL read_surf(&
142  hprogram,'PERTSEAFLUX',s%XPERTFLUX(:),iresp)
143 ELSE
144  s%XPERTFLUX(:) = 0.
145 ENDIF
146 !
147 !-------------------------------------------------------------------------------
148 !
149 !* 3. Semi-prognostic fields:
150 ! ----------------------
151 !
152 !* roughness length
153 !
154 ALLOCATE(s%XZ0(ilu))
155 yrecfm='Z0SEA'
156 s%XZ0(:) = 0.001
157  CALL read_surf(&
158  hprogram,yrecfm,s%XZ0(:),iresp)
159 !
160 !* flag to use or not the SeaIce model
161 !
162  CALL read_surf(&
163  hprogram,'VERSION',iversion,iresp)
164 IF (iversion <8) THEN
165  s%LHANDLE_SIC=.false.
166 ELSE
167  CALL read_surf(&
168  hprogram,'HANDLE_SIC',s%LHANDLE_SIC,iresp)
169 ENDIF
170 !
171 !
172 ! * sea surface salinity
173 !
174 ALLOCATE(s%XSSS(ilu))
175 s%XSSS(:)=0.0
176 !
177 !* Sea surface salinity nudging data
178 !
179 IF(s%LINTERPOL_SSS)THEN
180  !
181  ! Precedent, Current, Next, and Second-next Monthly SSS
182  inmth=4
183  !
184  ALLOCATE(s%XSSS_MTH(ilu,inmth))
185  DO jmth=1,inmth
186  WRITE(ymth,'(I2)') (jmth-1)
187  yrecfm='SSS_MTH'//adjustl(ymth(:len_trim(ymth)))
188  CALL read_surf(&
189  hprogram,yrecfm,s%XSSS_MTH(:,jmth),iresp)
190  CALL check_sea(yrecfm,s%XSSS_MTH(:,jmth))
191  ENDDO
192  !
193  CALL interpol_sst_mth(s, &
194  s%TTIME%TDATE%YEAR,s%TTIME%TDATE%MONTH,s%TTIME%TDATE%DAY,'S',s%XSSS)
195  !
196 ELSEIF (iversion>=8) THEN
197  !
198  ALLOCATE(s%XSSS_MTH(0,0))
199  !
200  yrecfm='SSS'
201  CALL read_surf(&
202  hprogram,yrecfm,s%XSSS,iresp)
203  IF(s%LHANDLE_SIC)THEN
204  CALL check_sea(yrecfm,s%XSSS(:))
205  ENDIF
206  !
207 ENDIF
208 !
209 !* ocean surface albedo (direct and diffuse fraction)
210 !
211 ALLOCATE(s%XDIR_ALB (ilu))
212 ALLOCATE(s%XSCA_ALB (ilu))
213 !
214 IF(s%CSEA_ALB=='RS14')THEN
215 !
216  yrecfm='OSA_DIR'
217  CALL read_surf(&
218  hprogram,yrecfm,s%XDIR_ALB(:),iresp)
219 !
220  yrecfm='OSA_SCA'
221  CALL read_surf(&
222  hprogram,yrecfm,s%XSCA_ALB(:),iresp)
223 !
224 ELSE
225 !
226  s%XDIR_ALB(:)=0.065
227  s%XSCA_ALB(:)=0.065
228 !
229 ENDIF
230 !
231 IF (lhook) CALL dr_hook('READ_SEAFLUX_N',1,zhook_handle)
232 !
233 !-------------------------------------------------------------------------------
234  CONTAINS
235 !-------------------------------------------------------------------------------
236 !
237 SUBROUTINE check_sea(HFIELD,PFIELD)
238 !
239 !
240 IMPLICIT NONE
241 !
242  CHARACTER(LEN=12), INTENT(IN) :: hfield
243 REAL, DIMENSION(:), INTENT(IN) :: pfield
244 !
245 REAL :: zmax,zmin
246 INTEGER :: ji, ierrc
247 !
248 REAL(KIND=JPRB) :: zhook_handle
249 !
250 IF (lhook) CALL dr_hook('READ_SEAFLUX_N:CHECK_SEA',0,zhook_handle)
251 !
252 zmin=-1.0e10
253 zmax=1.0e10
254 !
255 ierrc=0
256 !
257 DO ji=1,ilu
258  IF(pfield(ji)>zmax.OR.pfield(ji)<zmin)THEN
259  ierrc=ierrc+1
260  WRITE(kluout,*)'PROBLEM FIELD '//trim(hfield)//' =',pfield(ji),&
261  'NOT REALISTIC AT LOCATION (LAT/LON)',sg%XLAT(ji),sg%XLON(ji)
262  ENDIF
263 ENDDO
264 !
265 IF(ierrc>0) CALL abor1_sfx('READ_SEAFLUX_N: FIELD '//trim(hfield)//' NOT REALISTIC')
266 !
267 IF (lhook) CALL dr_hook('READ_SEAFLUX_N:CHECK_SEA',1,zhook_handle)
268 
269 END SUBROUTINE check_sea
270 !
271 !------------------------------------------------------------------------------
272 END SUBROUTINE read_seaflux_n
subroutine get_type_dim_n(DTCO, U, HTYPE, KDIM)
subroutine read_seaflux_n(DTCO, SG, S, U, HPROGRAM, KLUOUT)
subroutine abor1_sfx(YTEXT)
Definition: abor1_sfx.F90:6
subroutine check_sea(HCOMMENT, PFIELD)
subroutine interpol_sst_mth(S, KYEAR, KMONTH, KDAY, HFLAG, POUT)