1 | MODULE diaobs |
---|
2 | !!====================================================================== |
---|
3 | !! *** MODULE diaobs *** |
---|
4 | !! Observation diagnostics: Computation of the misfit between data and |
---|
5 | !! their model equivalent |
---|
6 | !!====================================================================== |
---|
7 | !! History : 1.0 ! 2006-03 (K. Mogensen) Original code |
---|
8 | !! - ! 2006-05 (K. Mogensen, A. Weaver) Reformatted |
---|
9 | !! - ! 2006-10 (A. Weaver) Cleaning and add controls |
---|
10 | !! - ! 2007-03 (K. Mogensen) General handling of profiles |
---|
11 | !! - ! 2007-04 (G. Smith) Generalized surface operators |
---|
12 | !! 2.0 ! 2008-10 (M. Valdivieso) obs operator for velocity profiles |
---|
13 | !! 3.4 ! 2014-08 (J. While) observation operator for profiles in all vertical coordinates |
---|
14 | !! - ! Incorporated SST bias correction |
---|
15 | !! 3.6 ! 2015-02 (M. Martin) Simplification of namelist and code |
---|
16 | !! - ! 2015-08 (M. Martin) Combined surface/profile routines. |
---|
17 | !! 4.0 ! 2017-11 (G. Madec) style only |
---|
18 | !!---------------------------------------------------------------------- |
---|
19 | |
---|
20 | !!---------------------------------------------------------------------- |
---|
21 | !! dia_obs_init : Reading and prepare observations |
---|
22 | !! dia_obs : Compute model equivalent to observations |
---|
23 | !! dia_obs_wri : Write observational diagnostics |
---|
24 | !! calc_date : Compute the date of timestep in YYYYMMDD.HHMMSS format |
---|
25 | !! ini_date : Compute the initial date YYYYMMDD.HHMMSS |
---|
26 | !! fin_date : Compute the final date YYYYMMDD.HHMMSS |
---|
27 | !!---------------------------------------------------------------------- |
---|
28 | USE par_kind ! Precision variables |
---|
29 | USE in_out_manager ! I/O manager |
---|
30 | USE par_oce ! ocean parameter |
---|
31 | USE dom_oce ! Ocean space and time domain variables |
---|
32 | USE sbc_oce ! Sea-ice fraction |
---|
33 | ! |
---|
34 | USE obs_read_prof ! Reading and allocation of profile obs |
---|
35 | USE obs_read_surf ! Reading and allocation of surface obs |
---|
36 | USE obs_sstbias ! Bias correction routine for SST |
---|
37 | USE obs_readmdt ! Reading and allocation of MDT for SLA. |
---|
38 | USE obs_prep ! Preparation of obs. (grid search etc). |
---|
39 | USE obs_oper ! Observation operators |
---|
40 | USE obs_write ! Writing of observation related diagnostics |
---|
41 | USE obs_grid ! Grid searching |
---|
42 | USE obs_read_altbias ! Bias treatment for altimeter |
---|
43 | USE obs_profiles_def ! Profile data definitions |
---|
44 | USE obs_surf_def ! Surface data definitions |
---|
45 | USE obs_types ! Definitions for observation types |
---|
46 | ! |
---|
47 | USE mpp_map ! MPP mapping |
---|
48 | USE lib_mpp ! For ctl_warn/stop |
---|
49 | |
---|
50 | IMPLICIT NONE |
---|
51 | PRIVATE |
---|
52 | |
---|
53 | PUBLIC dia_obs_init ! Initialize and read observations |
---|
54 | PUBLIC dia_obs ! Compute model equivalent to observations |
---|
55 | PUBLIC dia_obs_wri ! Write model equivalent to observations |
---|
56 | PUBLIC dia_obs_dealloc ! Deallocate dia_obs data |
---|
57 | PUBLIC calc_date ! Compute the date of a timestep |
---|
58 | |
---|
59 | LOGICAL, PUBLIC :: ln_diaobs !: Logical switch for the obs operator |
---|
60 | LOGICAL :: ln_sstnight ! Logical switch for night mean SST obs |
---|
61 | LOGICAL :: ln_default_fp_indegs ! T=> Default obs footprint size specified in degrees, F=> in metres |
---|
62 | LOGICAL :: ln_sla_fp_indegs ! T=> SLA obs footprint size specified in degrees, F=> in metres |
---|
63 | LOGICAL :: ln_sst_fp_indegs ! T=> SST obs footprint size specified in degrees, F=> in metres |
---|
64 | LOGICAL :: ln_sss_fp_indegs ! T=> SSS obs footprint size specified in degrees, F=> in metres |
---|
65 | LOGICAL :: ln_sic_fp_indegs ! T=> sea-ice obs footprint size specified in degrees, F=> in metres |
---|
66 | |
---|
67 | REAL(wp) :: rn_default_avglamscl ! E/W diameter of SLA observation footprint (metres) |
---|
68 | REAL(wp) :: rn_default_avgphiscl ! N/S diameter of SLA observation footprint (metre |
---|
69 | REAL(wp) :: rn_sla_avglamscl ! E/W diameter of SLA observation footprint (metres) |
---|
70 | REAL(wp) :: rn_sla_avgphiscl ! N/S diameter of SLA observation footprint (metres) |
---|
71 | REAL(wp) :: rn_sst_avglamscl ! E/W diameter of SST observation footprint (metres) |
---|
72 | REAL(wp) :: rn_sst_avgphiscl ! N/S diameter of SST observation footprint (metres) |
---|
73 | REAL(wp) :: rn_sss_avglamscl ! E/W diameter of SSS observation footprint (metres) |
---|
74 | REAL(wp) :: rn_sss_avgphiscl ! N/S diameter of SSS observation footprint (metres) |
---|
75 | REAL(wp) :: rn_sic_avglamscl ! E/W diameter of sea-ice observation footprint (metres) |
---|
76 | REAL(wp) :: rn_sic_avgphiscl ! N/S diameter of sea-ice observation footprint (metres) |
---|
77 | |
---|
78 | INTEGER :: nn_1dint ! Vertical interpolation method |
---|
79 | INTEGER :: nn_2dint_default ! Default horizontal interpolation method |
---|
80 | INTEGER :: nn_2dint_sla ! SLA horizontal interpolation method |
---|
81 | INTEGER :: nn_2dint_sst ! SST horizontal interpolation method |
---|
82 | INTEGER :: nn_2dint_sss ! SSS horizontal interpolation method |
---|
83 | INTEGER :: nn_2dint_sic ! Seaice horizontal interpolation method |
---|
84 | INTEGER, DIMENSION(imaxavtypes) :: nn_profdavtypes ! Profile data types representing a daily average |
---|
85 | INTEGER :: nproftypes ! Number of profile obs types |
---|
86 | INTEGER :: nsurftypes ! Number of surface obs types |
---|
87 | INTEGER , DIMENSION(:), ALLOCATABLE :: nvarsprof, nvarssurf ! Number of profile & surface variables |
---|
88 | INTEGER , DIMENSION(:), ALLOCATABLE :: nextrprof, nextrsurf ! Number of profile & surface extra variables |
---|
89 | INTEGER , DIMENSION(:), ALLOCATABLE :: n2dintsurf ! Interpolation option for surface variables |
---|
90 | REAL(wp), DIMENSION(:), ALLOCATABLE :: zavglamscl, zavgphiscl ! E/W & N/S diameter of averaging footprint for surface variables |
---|
91 | LOGICAL , DIMENSION(:), ALLOCATABLE :: lfpindegs ! T=> surface obs footprint size specified in degrees, F=> in metres |
---|
92 | LOGICAL , DIMENSION(:), ALLOCATABLE :: llnightav ! Logical for calculating night-time averages |
---|
93 | |
---|
94 | TYPE(obs_surf), PUBLIC, POINTER, DIMENSION(:) :: surfdata !: Initial surface data |
---|
95 | TYPE(obs_surf), PUBLIC, POINTER, DIMENSION(:) :: surfdataqc !: Surface data after quality control |
---|
96 | TYPE(obs_prof), PUBLIC, POINTER, DIMENSION(:) :: profdata !: Initial profile data |
---|
97 | TYPE(obs_prof), PUBLIC, POINTER, DIMENSION(:) :: profdataqc !: Profile data after quality control |
---|
98 | |
---|
99 | CHARACTER(len=lca), PUBLIC, DIMENSION(:), ALLOCATABLE :: cobstypesprof, cobstypessurf !: Profile & surface obs types |
---|
100 | |
---|
101 | # include "domzgr_substitute.h90" |
---|
102 | !!---------------------------------------------------------------------- |
---|
103 | !! NEMO/OCE 4.0 , NEMO Consortium (2018) |
---|
104 | !! $Id$ |
---|
105 | !! Software governed by the CeCILL license (see ./LICENSE) |
---|
106 | !!---------------------------------------------------------------------- |
---|
107 | CONTAINS |
---|
108 | |
---|
109 | SUBROUTINE dia_obs_init( Kmm ) |
---|
110 | !!---------------------------------------------------------------------- |
---|
111 | !! *** ROUTINE dia_obs_init *** |
---|
112 | !! |
---|
113 | !! ** Purpose : Initialize and read observations |
---|
114 | !! |
---|
115 | !! ** Method : Read the namelist and call reading routines |
---|
116 | !! |
---|
117 | !! ** Action : Read the namelist and call reading routines |
---|
118 | !! |
---|
119 | !!---------------------------------------------------------------------- |
---|
120 | INTEGER, INTENT(in) :: Kmm ! ocean time level indices |
---|
121 | INTEGER, PARAMETER :: jpmaxnfiles = 1000 ! Maximum number of files for each obs type |
---|
122 | INTEGER, DIMENSION(:), ALLOCATABLE :: ifilesprof, ifilessurf ! Number of profile & surface files |
---|
123 | INTEGER :: ios ! Local integer output status for namelist read |
---|
124 | INTEGER :: jtype ! Counter for obs types |
---|
125 | INTEGER :: jvar ! Counter for variables |
---|
126 | INTEGER :: jfile ! Counter for files |
---|
127 | INTEGER :: jnumsstbias ! Number of SST bias files to read and apply |
---|
128 | INTEGER :: n2dint_type ! Local version of nn_2dint* |
---|
129 | ! |
---|
130 | CHARACTER(len=128), DIMENSION(jpmaxnfiles) :: & |
---|
131 | & cn_profbfiles, & ! T/S profile input filenames |
---|
132 | & cn_sstfbfiles, & ! Sea surface temperature input filenames |
---|
133 | & cn_sssfbfiles, & ! Sea surface salinity input filenames |
---|
134 | & cn_slafbfiles, & ! Sea level anomaly input filenames |
---|
135 | & cn_sicfbfiles, & ! Seaice concentration input filenames |
---|
136 | & cn_velfbfiles, & ! Velocity profile input filenames |
---|
137 | & cn_sstbiasfiles ! SST bias input filenames |
---|
138 | CHARACTER(LEN=128) :: & |
---|
139 | & cn_altbiasfile ! Altimeter bias input filename |
---|
140 | CHARACTER(len=128), DIMENSION(:,:), ALLOCATABLE :: & |
---|
141 | & clproffiles, & ! Profile filenames |
---|
142 | & clsurffiles ! Surface filenames |
---|
143 | CHARACTER(len=8), DIMENSION(:), ALLOCATABLE :: & |
---|
144 | & clvars ! Expected variable names |
---|
145 | ! |
---|
146 | LOGICAL :: ln_t3d ! Logical switch for temperature profiles |
---|
147 | LOGICAL :: ln_s3d ! Logical switch for salinity profiles |
---|
148 | LOGICAL :: ln_sla ! Logical switch for sea level anomalies |
---|
149 | LOGICAL :: ln_sst ! Logical switch for sea surface temperature |
---|
150 | LOGICAL :: ln_sss ! Logical switch for sea surface salinity |
---|
151 | LOGICAL :: ln_sic ! Logical switch for sea ice concentration |
---|
152 | LOGICAL :: ln_vel3d ! Logical switch for velocity (u,v) obs |
---|
153 | LOGICAL :: ln_nea ! Logical switch to remove obs near land |
---|
154 | LOGICAL :: ln_altbias ! Logical switch for altimeter bias |
---|
155 | LOGICAL :: ln_sstbias ! Logical switch for bias corection of SST |
---|
156 | LOGICAL :: ln_ignmis ! Logical switch for ignoring missing files |
---|
157 | LOGICAL :: ln_s_at_t ! Logical switch to compute model S at T obs |
---|
158 | LOGICAL :: ln_bound_reject ! Logical to remove obs near boundaries in LAMs. |
---|
159 | LOGICAL :: ltype_fp_indegs ! Local version of ln_*_fp_indegs |
---|
160 | LOGICAL :: ltype_night ! Local version of ln_sstnight (false for other variables) |
---|
161 | LOGICAL, DIMENSION(:), ALLOCATABLE :: llvar ! Logical for profile variable read |
---|
162 | LOGICAL, DIMENSION(jpmaxnfiles) :: lmask ! Used for finding number of sstbias files |
---|
163 | ! |
---|
164 | REAL(dp) :: rn_dobsini ! Obs window start date YYYYMMDD.HHMMSS |
---|
165 | REAL(dp) :: rn_dobsend ! Obs window end date YYYYMMDD.HHMMSS |
---|
166 | REAL(wp) :: ztype_avglamscl ! Local version of rn_*_avglamscl |
---|
167 | REAL(wp) :: ztype_avgphiscl ! Local version of rn_*_avgphiscl |
---|
168 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: zglam ! Model longitudes for profile variables |
---|
169 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: zgphi ! Model latitudes for profile variables |
---|
170 | REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE :: zmask ! Model land/sea mask associated with variables |
---|
171 | !! |
---|
172 | NAMELIST/namobs/ln_diaobs, ln_t3d, ln_s3d, ln_sla, & |
---|
173 | & ln_sst, ln_sic, ln_sss, ln_vel3d, & |
---|
174 | & ln_altbias, ln_sstbias, ln_nea, & |
---|
175 | & ln_grid_global, ln_grid_search_lookup, & |
---|
176 | & ln_ignmis, ln_s_at_t, ln_bound_reject, & |
---|
177 | & ln_sstnight, ln_default_fp_indegs, & |
---|
178 | & ln_sla_fp_indegs, ln_sst_fp_indegs, & |
---|
179 | & ln_sss_fp_indegs, ln_sic_fp_indegs, & |
---|
180 | & cn_profbfiles, cn_slafbfiles, & |
---|
181 | & cn_sstfbfiles, cn_sicfbfiles, & |
---|
182 | & cn_velfbfiles, cn_sssfbfiles, & |
---|
183 | & cn_sstbiasfiles, cn_altbiasfile, & |
---|
184 | & cn_gridsearchfile, rn_gridsearchres, & |
---|
185 | & rn_dobsini, rn_dobsend, & |
---|
186 | & rn_default_avglamscl, rn_default_avgphiscl, & |
---|
187 | & rn_sla_avglamscl, rn_sla_avgphiscl, & |
---|
188 | & rn_sst_avglamscl, rn_sst_avgphiscl, & |
---|
189 | & rn_sss_avglamscl, rn_sss_avgphiscl, & |
---|
190 | & rn_sic_avglamscl, rn_sic_avgphiscl, & |
---|
191 | & nn_1dint, nn_2dint_default, & |
---|
192 | & nn_2dint_sla, nn_2dint_sst, & |
---|
193 | & nn_2dint_sss, nn_2dint_sic, & |
---|
194 | & nn_msshc, rn_mdtcorr, rn_mdtcutoff, & |
---|
195 | & nn_profdavtypes |
---|
196 | !----------------------------------------------------------------------- |
---|
197 | |
---|
198 | !----------------------------------------------------------------------- |
---|
199 | ! Read namelist parameters |
---|
200 | !----------------------------------------------------------------------- |
---|
201 | ! Some namelist arrays need initialising |
---|
202 | cn_profbfiles (:) = '' |
---|
203 | cn_slafbfiles (:) = '' |
---|
204 | cn_sstfbfiles (:) = '' |
---|
205 | cn_sicfbfiles (:) = '' |
---|
206 | cn_velfbfiles (:) = '' |
---|
207 | cn_sssfbfiles (:) = '' |
---|
208 | cn_sstbiasfiles(:) = '' |
---|
209 | nn_profdavtypes(:) = -1 |
---|
210 | |
---|
211 | CALL ini_date( rn_dobsini ) |
---|
212 | CALL fin_date( rn_dobsend ) |
---|
213 | |
---|
214 | ! Read namelist namobs : control observation diagnostics |
---|
215 | READ ( numnam_ref, namobs, IOSTAT = ios, ERR = 901) |
---|
216 | 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namobs in reference namelist' ) |
---|
217 | READ ( numnam_cfg, namobs, IOSTAT = ios, ERR = 902 ) |
---|
218 | 902 IF( ios > 0 ) CALL ctl_nam ( ios , 'namobs in configuration namelist' ) |
---|
219 | IF(lwm) WRITE ( numond, namobs ) |
---|
220 | |
---|
221 | IF( .NOT.ln_diaobs ) THEN |
---|
222 | IF(lwp) WRITE(numout,*) |
---|
223 | IF(lwp) WRITE(numout,*) 'dia_obs_init : NO Observation diagnostic used' |
---|
224 | IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~' |
---|
225 | RETURN |
---|
226 | ENDIF |
---|
227 | |
---|
228 | IF(lwp) THEN |
---|
229 | WRITE(numout,*) |
---|
230 | WRITE(numout,*) 'dia_obs_init : Observation diagnostic initialization' |
---|
231 | WRITE(numout,*) '~~~~~~~~~~~~' |
---|
232 | WRITE(numout,*) ' Namelist namobs : set observation diagnostic parameters' |
---|
233 | WRITE(numout,*) ' Logical switch for T profile observations ln_t3d = ', ln_t3d |
---|
234 | WRITE(numout,*) ' Logical switch for S profile observations ln_s3d = ', ln_s3d |
---|
235 | WRITE(numout,*) ' Logical switch for SLA observations ln_sla = ', ln_sla |
---|
236 | WRITE(numout,*) ' Logical switch for SST observations ln_sst = ', ln_sst |
---|
237 | WRITE(numout,*) ' Logical switch for Sea Ice observations ln_sic = ', ln_sic |
---|
238 | WRITE(numout,*) ' Logical switch for velocity observations ln_vel3d = ', ln_vel3d |
---|
239 | WRITE(numout,*) ' Logical switch for SSS observations ln_sss = ', ln_sss |
---|
240 | WRITE(numout,*) ' Global distribution of observations ln_grid_global = ', ln_grid_global |
---|
241 | WRITE(numout,*) ' Logical switch for obs grid search lookup ln_grid_search_lookup = ', ln_grid_search_lookup |
---|
242 | IF (ln_grid_search_lookup) & |
---|
243 | WRITE(numout,*) ' Grid search lookup file header cn_gridsearchfile = ', cn_gridsearchfile |
---|
244 | WRITE(numout,*) ' Initial date in window YYYYMMDD.HHMMSS rn_dobsini = ', rn_dobsini |
---|
245 | WRITE(numout,*) ' Final date in window YYYYMMDD.HHMMSS rn_dobsend = ', rn_dobsend |
---|
246 | WRITE(numout,*) ' Type of vertical interpolation method nn_1dint = ', nn_1dint |
---|
247 | WRITE(numout,*) ' Default horizontal interpolation method nn_2dint_default = ', nn_2dint_default |
---|
248 | WRITE(numout,*) ' Type of horizontal interpolation method for SLA nn_2dint_sla = ', nn_2dint_sla |
---|
249 | WRITE(numout,*) ' Type of horizontal interpolation method for SST nn_2dint_sst = ', nn_2dint_sst |
---|
250 | WRITE(numout,*) ' Type of horizontal interpolation method for SSS nn_2dint_sss = ', nn_2dint_sss |
---|
251 | WRITE(numout,*) ' Type of horizontal interpolation method for SIC nn_2dint_sic = ', nn_2dint_sic |
---|
252 | WRITE(numout,*) ' Default E/W diameter of obs footprint rn_default_avglamscl = ', rn_default_avglamscl |
---|
253 | WRITE(numout,*) ' Default N/S diameter of obs footprint rn_default_avgphiscl = ', rn_default_avgphiscl |
---|
254 | WRITE(numout,*) ' Default obs footprint in deg [T] or m [F] ln_default_fp_indegs = ', ln_default_fp_indegs |
---|
255 | WRITE(numout,*) ' SLA E/W diameter of obs footprint rn_sla_avglamscl = ', rn_sla_avglamscl |
---|
256 | WRITE(numout,*) ' SLA N/S diameter of obs footprint rn_sla_avgphiscl = ', rn_sla_avgphiscl |
---|
257 | WRITE(numout,*) ' SLA obs footprint in deg [T] or m [F] ln_sla_fp_indegs = ', ln_sla_fp_indegs |
---|
258 | WRITE(numout,*) ' SST E/W diameter of obs footprint rn_sst_avglamscl = ', rn_sst_avglamscl |
---|
259 | WRITE(numout,*) ' SST N/S diameter of obs footprint rn_sst_avgphiscl = ', rn_sst_avgphiscl |
---|
260 | WRITE(numout,*) ' SST obs footprint in deg [T] or m [F] ln_sst_fp_indegs = ', ln_sst_fp_indegs |
---|
261 | WRITE(numout,*) ' SIC E/W diameter of obs footprint rn_sic_avglamscl = ', rn_sic_avglamscl |
---|
262 | WRITE(numout,*) ' SIC N/S diameter of obs footprint rn_sic_avgphiscl = ', rn_sic_avgphiscl |
---|
263 | WRITE(numout,*) ' SIC obs footprint in deg [T] or m [F] ln_sic_fp_indegs = ', ln_sic_fp_indegs |
---|
264 | WRITE(numout,*) ' Rejection of observations near land switch ln_nea = ', ln_nea |
---|
265 | WRITE(numout,*) ' Rejection of obs near open bdys ln_bound_reject = ', ln_bound_reject |
---|
266 | WRITE(numout,*) ' MSSH correction scheme nn_msshc = ', nn_msshc |
---|
267 | WRITE(numout,*) ' MDT correction rn_mdtcorr = ', rn_mdtcorr |
---|
268 | WRITE(numout,*) ' MDT cutoff for computed correction rn_mdtcutoff = ', rn_mdtcutoff |
---|
269 | WRITE(numout,*) ' Logical switch for alt bias ln_altbias = ', ln_altbias |
---|
270 | WRITE(numout,*) ' Logical switch for sst bias ln_sstbias = ', ln_sstbias |
---|
271 | WRITE(numout,*) ' Logical switch for ignoring missing files ln_ignmis = ', ln_ignmis |
---|
272 | WRITE(numout,*) ' Daily average types nn_profdavtypes = ', nn_profdavtypes |
---|
273 | WRITE(numout,*) ' Logical switch for night-time SST obs ln_sstnight = ', ln_sstnight |
---|
274 | ENDIF |
---|
275 | !----------------------------------------------------------------------- |
---|
276 | ! Set up list of observation types to be used |
---|
277 | ! and the files associated with each type |
---|
278 | !----------------------------------------------------------------------- |
---|
279 | |
---|
280 | nproftypes = COUNT( (/ln_t3d .OR. ln_s3d, ln_vel3d /) ) |
---|
281 | nsurftypes = COUNT( (/ln_sla, ln_sst, ln_sic, ln_sss /) ) |
---|
282 | |
---|
283 | IF( ln_sstbias ) THEN |
---|
284 | lmask(:) = .FALSE. |
---|
285 | WHERE( cn_sstbiasfiles(:) /= '' ) lmask(:) = .TRUE. |
---|
286 | jnumsstbias = COUNT(lmask) |
---|
287 | lmask(:) = .FALSE. |
---|
288 | ENDIF |
---|
289 | |
---|
290 | IF( nproftypes == 0 .AND. nsurftypes == 0 ) THEN |
---|
291 | CALL ctl_warn( 'dia_obs_init: ln_diaobs is set to true, but all obs operator logical flags', & |
---|
292 | & ' (ln_t3d, ln_s3d, ln_sla, ln_sst, ln_sic, ln_vel3d)', & |
---|
293 | & ' are set to .FALSE. so turning off calls to dia_obs' ) |
---|
294 | ln_diaobs = .FALSE. |
---|
295 | RETURN |
---|
296 | ENDIF |
---|
297 | |
---|
298 | IF( nproftypes > 0 ) THEN |
---|
299 | ! |
---|
300 | ALLOCATE( cobstypesprof(nproftypes) ) |
---|
301 | ALLOCATE( ifilesprof (nproftypes) ) |
---|
302 | ALLOCATE( clproffiles (nproftypes,jpmaxnfiles) ) |
---|
303 | ! |
---|
304 | jtype = 0 |
---|
305 | IF( ln_t3d .OR. ln_s3d ) THEN |
---|
306 | jtype = jtype + 1 |
---|
307 | cobstypesprof(jtype) = 'prof' |
---|
308 | clproffiles(jtype,:) = cn_profbfiles |
---|
309 | ENDIF |
---|
310 | IF( ln_vel3d ) THEN |
---|
311 | jtype = jtype + 1 |
---|
312 | cobstypesprof(jtype) = 'vel' |
---|
313 | clproffiles(jtype,:) = cn_velfbfiles |
---|
314 | ENDIF |
---|
315 | ! |
---|
316 | CALL obs_settypefiles( nproftypes, jpmaxnfiles, ifilesprof, cobstypesprof, clproffiles ) |
---|
317 | ! |
---|
318 | ENDIF |
---|
319 | |
---|
320 | IF( nsurftypes > 0 ) THEN |
---|
321 | ! |
---|
322 | ALLOCATE( cobstypessurf(nsurftypes) ) |
---|
323 | ALLOCATE( ifilessurf (nsurftypes) ) |
---|
324 | ALLOCATE( clsurffiles (nsurftypes,jpmaxnfiles) ) |
---|
325 | ALLOCATE( n2dintsurf (nsurftypes) ) |
---|
326 | ALLOCATE( zavglamscl (nsurftypes) ) |
---|
327 | ALLOCATE( zavgphiscl (nsurftypes) ) |
---|
328 | ALLOCATE( lfpindegs (nsurftypes) ) |
---|
329 | ALLOCATE( llnightav (nsurftypes) ) |
---|
330 | ! |
---|
331 | jtype = 0 |
---|
332 | IF( ln_sla ) THEN |
---|
333 | jtype = jtype + 1 |
---|
334 | cobstypessurf(jtype) = 'sla' |
---|
335 | clsurffiles(jtype,:) = cn_slafbfiles |
---|
336 | ENDIF |
---|
337 | IF( ln_sst ) THEN |
---|
338 | jtype = jtype + 1 |
---|
339 | cobstypessurf(jtype) = 'sst' |
---|
340 | clsurffiles(jtype,:) = cn_sstfbfiles |
---|
341 | ENDIF |
---|
342 | #if defined key_si3 || defined key_cice |
---|
343 | IF( ln_sic ) THEN |
---|
344 | jtype = jtype + 1 |
---|
345 | cobstypessurf(jtype) = 'sic' |
---|
346 | clsurffiles(jtype,:) = cn_sicfbfiles |
---|
347 | ENDIF |
---|
348 | #endif |
---|
349 | IF( ln_sss ) THEN |
---|
350 | jtype = jtype + 1 |
---|
351 | cobstypessurf(jtype) = 'sss' |
---|
352 | clsurffiles(jtype,:) = cn_sssfbfiles |
---|
353 | ENDIF |
---|
354 | ! |
---|
355 | CALL obs_settypefiles( nsurftypes, jpmaxnfiles, ifilessurf, cobstypessurf, clsurffiles ) |
---|
356 | |
---|
357 | DO jtype = 1, nsurftypes |
---|
358 | |
---|
359 | IF ( TRIM(cobstypessurf(jtype)) == 'sla' ) THEN |
---|
360 | IF ( nn_2dint_sla == -1 ) THEN |
---|
361 | n2dint_type = nn_2dint_default |
---|
362 | ELSE |
---|
363 | n2dint_type = nn_2dint_sla |
---|
364 | ENDIF |
---|
365 | ztype_avglamscl = rn_sla_avglamscl |
---|
366 | ztype_avgphiscl = rn_sla_avgphiscl |
---|
367 | ltype_fp_indegs = ln_sla_fp_indegs |
---|
368 | ltype_night = .FALSE. |
---|
369 | ELSE IF ( TRIM(cobstypessurf(jtype)) == 'sst' ) THEN |
---|
370 | IF ( nn_2dint_sst == -1 ) THEN |
---|
371 | n2dint_type = nn_2dint_default |
---|
372 | ELSE |
---|
373 | n2dint_type = nn_2dint_sst |
---|
374 | ENDIF |
---|
375 | ztype_avglamscl = rn_sst_avglamscl |
---|
376 | ztype_avgphiscl = rn_sst_avgphiscl |
---|
377 | ltype_fp_indegs = ln_sst_fp_indegs |
---|
378 | ltype_night = ln_sstnight |
---|
379 | ELSE IF ( TRIM(cobstypessurf(jtype)) == 'sic' ) THEN |
---|
380 | IF ( nn_2dint_sic == -1 ) THEN |
---|
381 | n2dint_type = nn_2dint_default |
---|
382 | ELSE |
---|
383 | n2dint_type = nn_2dint_sic |
---|
384 | ENDIF |
---|
385 | ztype_avglamscl = rn_sic_avglamscl |
---|
386 | ztype_avgphiscl = rn_sic_avgphiscl |
---|
387 | ltype_fp_indegs = ln_sic_fp_indegs |
---|
388 | ltype_night = .FALSE. |
---|
389 | ELSE IF ( TRIM(cobstypessurf(jtype)) == 'sss' ) THEN |
---|
390 | IF ( nn_2dint_sss == -1 ) THEN |
---|
391 | n2dint_type = nn_2dint_default |
---|
392 | ELSE |
---|
393 | n2dint_type = nn_2dint_sss |
---|
394 | ENDIF |
---|
395 | ztype_avglamscl = rn_sss_avglamscl |
---|
396 | ztype_avgphiscl = rn_sss_avgphiscl |
---|
397 | ltype_fp_indegs = ln_sss_fp_indegs |
---|
398 | ltype_night = .FALSE. |
---|
399 | ELSE |
---|
400 | n2dint_type = nn_2dint_default |
---|
401 | ztype_avglamscl = rn_default_avglamscl |
---|
402 | ztype_avgphiscl = rn_default_avgphiscl |
---|
403 | ltype_fp_indegs = ln_default_fp_indegs |
---|
404 | ltype_night = .FALSE. |
---|
405 | ENDIF |
---|
406 | |
---|
407 | CALL obs_setinterpopts( nsurftypes, jtype, TRIM(cobstypessurf(jtype)), & |
---|
408 | & nn_2dint_default, n2dint_type, & |
---|
409 | & ztype_avglamscl, ztype_avgphiscl, & |
---|
410 | & ltype_fp_indegs, ltype_night, & |
---|
411 | & n2dintsurf, zavglamscl, zavgphiscl, & |
---|
412 | & lfpindegs, llnightav ) |
---|
413 | |
---|
414 | END DO |
---|
415 | ! |
---|
416 | ENDIF |
---|
417 | |
---|
418 | |
---|
419 | !----------------------------------------------------------------------- |
---|
420 | ! Obs operator parameter checking and initialisations |
---|
421 | !----------------------------------------------------------------------- |
---|
422 | ! |
---|
423 | IF( ln_vel3d .AND. .NOT.ln_grid_global ) THEN |
---|
424 | CALL ctl_stop( 'Velocity data only works with ln_grid_global=.true.' ) |
---|
425 | RETURN |
---|
426 | ENDIF |
---|
427 | ! |
---|
428 | IF( ln_grid_global ) THEN |
---|
429 | CALL ctl_warn( 'dia_obs_init: ln_grid_global=T may cause memory issues when used with a large number of processors' ) |
---|
430 | ENDIF |
---|
431 | ! |
---|
432 | IF( nn_1dint < 0 .OR. nn_1dint > 1 ) THEN |
---|
433 | CALL ctl_stop('dia_obs_init: Choice of vertical (1D) interpolation method is not available') |
---|
434 | ENDIF |
---|
435 | ! |
---|
436 | IF( nn_2dint_default < 0 .OR. nn_2dint_default > 6 ) THEN |
---|
437 | CALL ctl_stop('dia_obs_init: Choice of default horizontal (2D) interpolation method is not available') |
---|
438 | ENDIF |
---|
439 | ! |
---|
440 | CALL obs_typ_init |
---|
441 | IF( ln_grid_global ) CALL mppmap_init |
---|
442 | ! |
---|
443 | CALL obs_grid_setup( ) |
---|
444 | |
---|
445 | !----------------------------------------------------------------------- |
---|
446 | ! Depending on switches read the various observation types |
---|
447 | !----------------------------------------------------------------------- |
---|
448 | ! |
---|
449 | IF( nproftypes > 0 ) THEN |
---|
450 | ! |
---|
451 | ALLOCATE( profdata (nproftypes) , nvarsprof (nproftypes) ) |
---|
452 | ALLOCATE( profdataqc(nproftypes) , nextrprof (nproftypes) ) |
---|
453 | ! |
---|
454 | DO jtype = 1, nproftypes |
---|
455 | ! |
---|
456 | IF ( TRIM(cobstypesprof(jtype)) == 'prof' ) THEN |
---|
457 | nvarsprof(jtype) = 2 |
---|
458 | nextrprof(jtype) = 1 |
---|
459 | ALLOCATE( llvar (nvarsprof(jtype)) ) |
---|
460 | ALLOCATE( clvars(nvarsprof(jtype)) ) |
---|
461 | ALLOCATE( zglam(jpi, jpj, nvarsprof(jtype)) ) |
---|
462 | ALLOCATE( zgphi(jpi, jpj, nvarsprof(jtype)) ) |
---|
463 | ALLOCATE( zmask(jpi, jpj, jpk, nvarsprof(jtype)) ) |
---|
464 | llvar(1) = ln_t3d |
---|
465 | llvar(2) = ln_s3d |
---|
466 | clvars(1) = 'POTM' |
---|
467 | clvars(2) = 'PSAL' |
---|
468 | zglam(:,:,1) = glamt(:,:) |
---|
469 | zglam(:,:,2) = glamt(:,:) |
---|
470 | zgphi(:,:,1) = gphit(:,:) |
---|
471 | zgphi(:,:,2) = gphit(:,:) |
---|
472 | zmask(:,:,:,1) = tmask(:,:,:) |
---|
473 | zmask(:,:,:,2) = tmask(:,:,:) |
---|
474 | ELSE IF ( TRIM(cobstypesprof(jtype)) == 'vel' ) THEN |
---|
475 | nvarsprof(jtype) = 2 |
---|
476 | nextrprof(jtype) = 2 |
---|
477 | ALLOCATE( llvar (nvarsprof(jtype)) ) |
---|
478 | ALLOCATE( clvars(nvarsprof(jtype)) ) |
---|
479 | ALLOCATE( zglam(jpi, jpj, nvarsprof(jtype)) ) |
---|
480 | ALLOCATE( zgphi(jpi, jpj, nvarsprof(jtype)) ) |
---|
481 | ALLOCATE( zmask(jpi, jpj, jpk, nvarsprof(jtype)) ) |
---|
482 | llvar(1) = ln_vel3d |
---|
483 | llvar(2) = ln_vel3d |
---|
484 | clvars(1) = 'UVEL' |
---|
485 | clvars(2) = 'VVEL' |
---|
486 | zglam(:,:,1) = glamu(:,:) |
---|
487 | zglam(:,:,2) = glamv(:,:) |
---|
488 | zgphi(:,:,1) = gphiu(:,:) |
---|
489 | zgphi(:,:,2) = gphiv(:,:) |
---|
490 | zmask(:,:,:,1) = umask(:,:,:) |
---|
491 | zmask(:,:,:,2) = vmask(:,:,:) |
---|
492 | ELSE |
---|
493 | nvarsprof(jtype) = 1 |
---|
494 | nextrprof(jtype) = 0 |
---|
495 | ALLOCATE( llvar (nvarsprof(jtype)) ) |
---|
496 | ALLOCATE( clvars(nvarsprof(jtype)) ) |
---|
497 | ALLOCATE( zglam(jpi, jpj, nvarsprof(jtype)) ) |
---|
498 | ALLOCATE( zgphi(jpi, jpj, nvarsprof(jtype)) ) |
---|
499 | ALLOCATE( zmask(jpi, jpj, jpk, nvarsprof(jtype)) ) |
---|
500 | llvar(1) = .TRUE. |
---|
501 | zglam(:,:,1) = glamt(:,:) |
---|
502 | zgphi(:,:,1) = gphit(:,:) |
---|
503 | zmask(:,:,:,1) = tmask(:,:,:) |
---|
504 | ENDIF |
---|
505 | ! |
---|
506 | ! Read in profile or profile obs types |
---|
507 | CALL obs_rea_prof( profdata(jtype), ifilesprof(jtype), & |
---|
508 | & clproffiles(jtype,1:ifilesprof(jtype)), & |
---|
509 | & nvarsprof(jtype), nextrprof(jtype), nitend-nit000+2, & |
---|
510 | & rn_dobsini, rn_dobsend, llvar, & |
---|
511 | & ln_ignmis, ln_s_at_t, .FALSE., clvars, & |
---|
512 | & kdailyavtypes = nn_profdavtypes ) |
---|
513 | ! |
---|
514 | DO jvar = 1, nvarsprof(jtype) |
---|
515 | CALL obs_prof_staend( profdata(jtype), jvar ) |
---|
516 | END DO |
---|
517 | ! |
---|
518 | CALL obs_pre_prof( profdata(jtype), profdataqc(jtype), & |
---|
519 | & llvar, & |
---|
520 | & jpi, jpj, jpk, & |
---|
521 | & zmask, zglam, zgphi, & |
---|
522 | & ln_nea, ln_bound_reject, Kmm, & |
---|
523 | & kdailyavtypes = nn_profdavtypes ) |
---|
524 | ! |
---|
525 | DEALLOCATE( llvar, clvars, zglam, zgphi, zmask ) |
---|
526 | ! |
---|
527 | END DO |
---|
528 | ! |
---|
529 | DEALLOCATE( ifilesprof, clproffiles ) |
---|
530 | ! |
---|
531 | ENDIF |
---|
532 | ! |
---|
533 | IF( nsurftypes > 0 ) THEN |
---|
534 | ! |
---|
535 | ALLOCATE( surfdata (nsurftypes) , nvarssurf(nsurftypes) ) |
---|
536 | ALLOCATE( surfdataqc(nsurftypes) , nextrsurf(nsurftypes) ) |
---|
537 | ! |
---|
538 | DO jtype = 1, nsurftypes |
---|
539 | ! |
---|
540 | nvarssurf(jtype) = 1 |
---|
541 | nextrsurf(jtype) = 0 |
---|
542 | llnightav(jtype) = .FALSE. |
---|
543 | IF( TRIM(cobstypessurf(jtype)) == 'sla' ) nextrsurf(jtype) = 2 |
---|
544 | IF( TRIM(cobstypessurf(jtype)) == 'sst' ) llnightav(jtype) = ln_sstnight |
---|
545 | ! |
---|
546 | ALLOCATE( clvars( nvarssurf(jtype) ) ) |
---|
547 | IF ( TRIM(cobstypessurf(jtype)) == 'sla' ) THEN |
---|
548 | clvars(1) = 'SLA' |
---|
549 | ELSE IF ( TRIM(cobstypessurf(jtype)) == 'sst' ) THEN |
---|
550 | clvars(1) = 'SST' |
---|
551 | ELSE IF ( TRIM(cobstypessurf(jtype)) == 'sic' ) THEN |
---|
552 | clvars(1) = 'ICECONC' |
---|
553 | ELSE IF ( TRIM(cobstypessurf(jtype)) == 'sss' ) THEN |
---|
554 | clvars(1) = 'SSS' |
---|
555 | ENDIF |
---|
556 | ! |
---|
557 | ! Read in surface obs types |
---|
558 | CALL obs_rea_surf( surfdata(jtype), ifilessurf(jtype), & |
---|
559 | & clsurffiles(jtype,1:ifilessurf(jtype)), & |
---|
560 | & nvarssurf(jtype), nextrsurf(jtype), nitend-nit000+2, & |
---|
561 | & rn_dobsini, rn_dobsend, ln_ignmis, .FALSE., llnightav(jtype), & |
---|
562 | & clvars ) |
---|
563 | ! |
---|
564 | CALL obs_pre_surf( surfdata(jtype), surfdataqc(jtype), ln_nea, ln_bound_reject ) |
---|
565 | ! |
---|
566 | IF( TRIM(cobstypessurf(jtype)) == 'sla' ) THEN |
---|
567 | CALL obs_rea_mdt( surfdataqc(jtype), n2dintsurf(jtype), Kmm ) |
---|
568 | IF( ln_altbias ) & |
---|
569 | & CALL obs_rea_altbias ( surfdataqc(jtype), n2dintsurf(jtype), cn_altbiasfile ) |
---|
570 | ENDIF |
---|
571 | ! |
---|
572 | IF( TRIM(cobstypessurf(jtype)) == 'sst' .AND. ln_sstbias ) THEN |
---|
573 | jnumsstbias = 0 |
---|
574 | DO jfile = 1, jpmaxnfiles |
---|
575 | IF( TRIM(cn_sstbiasfiles(jfile)) /= '' ) jnumsstbias = jnumsstbias + 1 |
---|
576 | END DO |
---|
577 | IF( jnumsstbias == 0 ) CALL ctl_stop("ln_sstbias set but no bias files to read in") |
---|
578 | ! |
---|
579 | CALL obs_app_sstbias( surfdataqc(jtype), n2dintsurf(jtype) , & |
---|
580 | & jnumsstbias , cn_sstbiasfiles(1:jnumsstbias) ) |
---|
581 | ENDIF |
---|
582 | ! |
---|
583 | DEALLOCATE( clvars ) |
---|
584 | END DO |
---|
585 | ! |
---|
586 | DEALLOCATE( ifilessurf, clsurffiles ) |
---|
587 | ! |
---|
588 | ENDIF |
---|
589 | ! |
---|
590 | END SUBROUTINE dia_obs_init |
---|
591 | |
---|
592 | |
---|
593 | SUBROUTINE dia_obs( kstp, Kmm ) |
---|
594 | !!---------------------------------------------------------------------- |
---|
595 | !! *** ROUTINE dia_obs *** |
---|
596 | !! |
---|
597 | !! ** Purpose : Call the observation operators on each time step |
---|
598 | !! |
---|
599 | !! ** Method : Call the observation operators on each time step to |
---|
600 | !! compute the model equivalent of the following data: |
---|
601 | !! - Profile data, currently T/S or U/V |
---|
602 | !! - Surface data, currently SST, SLA or sea-ice concentration. |
---|
603 | !! |
---|
604 | !! ** Action : |
---|
605 | !!---------------------------------------------------------------------- |
---|
606 | USE phycst , ONLY : rday ! Physical constants |
---|
607 | USE oce , ONLY : ts, uu, vv, ssh ! Ocean dynamics and tracers variables (Kmm time-level only) |
---|
608 | USE phycst , ONLY : rday ! Physical constants |
---|
609 | #if defined key_si3 |
---|
610 | USE ice , ONLY : at_i ! SI3 Ice model variables |
---|
611 | #endif |
---|
612 | #if defined key_cice |
---|
613 | USE sbc_oce, ONLY : fr_i ! ice fraction |
---|
614 | #endif |
---|
615 | |
---|
616 | IMPLICIT NONE |
---|
617 | |
---|
618 | !! * Arguments |
---|
619 | INTEGER, INTENT(IN) :: kstp ! Current timestep |
---|
620 | INTEGER, INTENT(in) :: Kmm ! ocean time level indices |
---|
621 | !! * Local declarations |
---|
622 | INTEGER :: idaystp ! Number of timesteps per day |
---|
623 | INTEGER :: jtype ! Data loop variable |
---|
624 | INTEGER :: jvar ! Variable number |
---|
625 | INTEGER :: ji, jj, jk ! Loop counters |
---|
626 | REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE :: & |
---|
627 | & zprofvar ! Model values for variables in a prof ob |
---|
628 | REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE :: & |
---|
629 | & zprofmask ! Mask associated with zprofvar |
---|
630 | REAL(wp), DIMENSION(jpi,jpj) :: & |
---|
631 | & zsurfvar, & ! Model values equivalent to surface ob. |
---|
632 | & zsurfmask ! Mask associated with surface variable |
---|
633 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: & |
---|
634 | & zglam, & ! Model longitudes for prof variables |
---|
635 | & zgphi ! Model latitudes for prof variables |
---|
636 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: zdept, zdepw |
---|
637 | |
---|
638 | !----------------------------------------------------------------------- |
---|
639 | |
---|
640 | IF(lwp) THEN |
---|
641 | WRITE(numout,*) |
---|
642 | WRITE(numout,*) 'dia_obs : Call the observation operators', kstp |
---|
643 | WRITE(numout,*) '~~~~~~~' |
---|
644 | ENDIF |
---|
645 | |
---|
646 | idaystp = NINT( rday / rn_Dt ) |
---|
647 | |
---|
648 | !----------------------------------------------------------------------- |
---|
649 | ! Call the profile and surface observation operators |
---|
650 | !----------------------------------------------------------------------- |
---|
651 | |
---|
652 | IF ( nproftypes > 0 ) THEN |
---|
653 | |
---|
654 | ALLOCATE( zdept(jpi,jpj,jpk), zdepw(jpi,jpj,jpk) ) |
---|
655 | DO jk = 1, jpk |
---|
656 | zdept(:,:,jk) = gdept(:,:,jk,Kmm) |
---|
657 | zdepw(:,:,jk) = gdepw(:,:,jk,Kmm) |
---|
658 | END DO |
---|
659 | |
---|
660 | DO jtype = 1, nproftypes |
---|
661 | |
---|
662 | ! Allocate local work arrays |
---|
663 | ALLOCATE( zprofvar (jpi, jpj, jpk, profdataqc(jtype)%nvar) ) |
---|
664 | ALLOCATE( zprofmask(jpi, jpj, jpk, profdataqc(jtype)%nvar) ) |
---|
665 | ALLOCATE( zglam (jpi, jpj, profdataqc(jtype)%nvar) ) |
---|
666 | ALLOCATE( zgphi (jpi, jpj, profdataqc(jtype)%nvar) ) |
---|
667 | |
---|
668 | ! Defaults which might change |
---|
669 | DO jvar = 1, profdataqc(jtype)%nvar |
---|
670 | zprofmask(:,:,:,jvar) = tmask(:,:,:) |
---|
671 | zglam(:,:,jvar) = glamt(:,:) |
---|
672 | zgphi(:,:,jvar) = gphit(:,:) |
---|
673 | END DO |
---|
674 | |
---|
675 | SELECT CASE ( TRIM(cobstypesprof(jtype)) ) |
---|
676 | CASE('prof') |
---|
677 | zprofvar(:,:,:,1) = ts(:,:,:,jp_tem,Kmm) |
---|
678 | zprofvar(:,:,:,2) = ts(:,:,:,jp_sal,Kmm) |
---|
679 | CASE('vel') |
---|
680 | zprofvar(:,:,:,1) = uu(:,:,:,Kmm) |
---|
681 | zprofvar(:,:,:,2) = vv(:,:,:,Kmm) |
---|
682 | zprofmask(:,:,:,1) = umask(:,:,:) |
---|
683 | zprofmask(:,:,:,2) = vmask(:,:,:) |
---|
684 | zglam(:,:,1) = glamu(:,:) |
---|
685 | zglam(:,:,2) = glamv(:,:) |
---|
686 | zgphi(:,:,1) = gphiu(:,:) |
---|
687 | zgphi(:,:,2) = gphiv(:,:) |
---|
688 | CASE DEFAULT |
---|
689 | CALL ctl_stop( 'Unknown profile observation type '//TRIM(cobstypesprof(jtype))//' in dia_obs' ) |
---|
690 | END SELECT |
---|
691 | |
---|
692 | DO jvar = 1, profdataqc(jtype)%nvar |
---|
693 | CALL obs_prof_opt( profdataqc(jtype), kstp, jpi, jpj, jpk, & |
---|
694 | & nit000, idaystp, jvar, & |
---|
695 | & zprofvar(:,:,:,jvar), & |
---|
696 | & zdept(:,:,:), zdepw(:,:,:), & |
---|
697 | & zprofmask(:,:,:,jvar), & |
---|
698 | & zglam(:,:,jvar), zgphi(:,:,jvar), & |
---|
699 | & nn_1dint, nn_2dint_default, & |
---|
700 | & kdailyavtypes = nn_profdavtypes ) |
---|
701 | END DO |
---|
702 | |
---|
703 | DEALLOCATE( zprofvar, zprofmask, zglam, zgphi ) |
---|
704 | |
---|
705 | END DO |
---|
706 | |
---|
707 | DEALLOCATE( zdept, zdepw ) |
---|
708 | |
---|
709 | ENDIF |
---|
710 | |
---|
711 | IF ( nsurftypes > 0 ) THEN |
---|
712 | |
---|
713 | DO jtype = 1, nsurftypes |
---|
714 | |
---|
715 | !Defaults which might be changed |
---|
716 | zsurfmask(:,:) = tmask(:,:,1) |
---|
717 | |
---|
718 | SELECT CASE ( TRIM(cobstypessurf(jtype)) ) |
---|
719 | CASE('sst') |
---|
720 | zsurfvar(:,:) = ts(:,:,1,jp_tem,Kmm) |
---|
721 | CASE('sla') |
---|
722 | zsurfvar(:,:) = ssh(:,:,Kmm) |
---|
723 | CASE('sss') |
---|
724 | zsurfvar(:,:) = ts(:,:,1,jp_sal,Kmm) |
---|
725 | CASE('sic') |
---|
726 | IF ( kstp == 0 ) THEN |
---|
727 | IF ( lwp .AND. surfdataqc(jtype)%nsstpmpp(1) > 0 ) THEN |
---|
728 | CALL ctl_warn( 'Sea-ice not initialised on zeroth '// & |
---|
729 | & 'time-step but some obs are valid then.' ) |
---|
730 | WRITE(numout,*)surfdataqc(jtype)%nsstpmpp(1), & |
---|
731 | & ' sea-ice obs will be missed' |
---|
732 | ENDIF |
---|
733 | surfdataqc(jtype)%nsurfup = surfdataqc(jtype)%nsurfup + & |
---|
734 | & surfdataqc(jtype)%nsstp(1) |
---|
735 | CYCLE |
---|
736 | ELSE |
---|
737 | #if defined key_cice || defined key_si3 |
---|
738 | zsurfvar(:,:) = fr_i(:,:) |
---|
739 | #else |
---|
740 | CALL ctl_stop( ' Trying to run sea-ice observation operator', & |
---|
741 | & ' but no sea-ice model appears to have been defined' ) |
---|
742 | #endif |
---|
743 | ENDIF |
---|
744 | |
---|
745 | END SELECT |
---|
746 | |
---|
747 | CALL obs_surf_opt( surfdataqc(jtype), kstp, jpi, jpj, & |
---|
748 | & nit000, idaystp, zsurfvar, zsurfmask, & |
---|
749 | & n2dintsurf(jtype), llnightav(jtype), & |
---|
750 | & zavglamscl(jtype), zavgphiscl(jtype), & |
---|
751 | & lfpindegs(jtype) ) |
---|
752 | |
---|
753 | END DO |
---|
754 | |
---|
755 | ENDIF |
---|
756 | |
---|
757 | END SUBROUTINE dia_obs |
---|
758 | |
---|
759 | SUBROUTINE dia_obs_wri |
---|
760 | !!---------------------------------------------------------------------- |
---|
761 | !! *** ROUTINE dia_obs_wri *** |
---|
762 | !! |
---|
763 | !! ** Purpose : Call observation diagnostic output routines |
---|
764 | !! |
---|
765 | !! ** Method : Call observation diagnostic output routines |
---|
766 | !! |
---|
767 | !! ** Action : |
---|
768 | !! |
---|
769 | !! History : |
---|
770 | !! ! 06-03 (K. Mogensen) Original code |
---|
771 | !! ! 06-05 (K. Mogensen) Reformatted |
---|
772 | !! ! 06-10 (A. Weaver) Cleaning |
---|
773 | !! ! 07-03 (K. Mogensen) General handling of profiles |
---|
774 | !! ! 08-09 (M. Valdivieso) Velocity component (U,V) profiles |
---|
775 | !! ! 15-08 (M. Martin) Combined writing for prof and surf types |
---|
776 | !!---------------------------------------------------------------------- |
---|
777 | !! * Modules used |
---|
778 | USE obs_rot_vel ! Rotation of velocities |
---|
779 | |
---|
780 | IMPLICIT NONE |
---|
781 | |
---|
782 | !! * Local declarations |
---|
783 | INTEGER :: jtype ! Data set loop variable |
---|
784 | INTEGER :: jo, jvar, jk |
---|
785 | REAL(wp), DIMENSION(:), ALLOCATABLE :: & |
---|
786 | & zu, & |
---|
787 | & zv |
---|
788 | |
---|
789 | !----------------------------------------------------------------------- |
---|
790 | ! Depending on switches call various observation output routines |
---|
791 | !----------------------------------------------------------------------- |
---|
792 | |
---|
793 | IF ( nproftypes > 0 ) THEN |
---|
794 | |
---|
795 | DO jtype = 1, nproftypes |
---|
796 | |
---|
797 | IF ( TRIM(cobstypesprof(jtype)) == 'vel' ) THEN |
---|
798 | |
---|
799 | ! For velocity data, rotate the model velocities to N/S, E/W |
---|
800 | ! using the compressed data structure. |
---|
801 | ALLOCATE( & |
---|
802 | & zu(profdataqc(jtype)%nvprot(1)), & |
---|
803 | & zv(profdataqc(jtype)%nvprot(2)) & |
---|
804 | & ) |
---|
805 | |
---|
806 | CALL obs_rotvel( profdataqc(jtype), nn_2dint_default, zu, zv ) |
---|
807 | |
---|
808 | DO jo = 1, profdataqc(jtype)%nprof |
---|
809 | DO jvar = 1, 2 |
---|
810 | DO jk = profdataqc(jtype)%npvsta(jo,jvar), profdataqc(jtype)%npvend(jo,jvar) |
---|
811 | |
---|
812 | IF ( jvar == 1 ) THEN |
---|
813 | profdataqc(jtype)%var(jvar)%vmod(jk) = zu(jk) |
---|
814 | ELSE |
---|
815 | profdataqc(jtype)%var(jvar)%vmod(jk) = zv(jk) |
---|
816 | ENDIF |
---|
817 | |
---|
818 | END DO |
---|
819 | END DO |
---|
820 | END DO |
---|
821 | |
---|
822 | DEALLOCATE( zu ) |
---|
823 | DEALLOCATE( zv ) |
---|
824 | |
---|
825 | END IF |
---|
826 | |
---|
827 | CALL obs_prof_decompress( profdataqc(jtype), & |
---|
828 | & profdata(jtype), .TRUE., numout ) |
---|
829 | |
---|
830 | CALL obs_wri_prof( profdata(jtype) ) |
---|
831 | |
---|
832 | END DO |
---|
833 | |
---|
834 | ENDIF |
---|
835 | |
---|
836 | IF ( nsurftypes > 0 ) THEN |
---|
837 | |
---|
838 | DO jtype = 1, nsurftypes |
---|
839 | |
---|
840 | CALL obs_surf_decompress( surfdataqc(jtype), & |
---|
841 | & surfdata(jtype), .TRUE., numout ) |
---|
842 | |
---|
843 | CALL obs_wri_surf( surfdata(jtype) ) |
---|
844 | |
---|
845 | END DO |
---|
846 | |
---|
847 | ENDIF |
---|
848 | |
---|
849 | END SUBROUTINE dia_obs_wri |
---|
850 | |
---|
851 | SUBROUTINE dia_obs_dealloc |
---|
852 | IMPLICIT NONE |
---|
853 | !!---------------------------------------------------------------------- |
---|
854 | !! *** ROUTINE dia_obs_dealloc *** |
---|
855 | !! |
---|
856 | !! ** Purpose : To deallocate data to enable the obs_oper online loop. |
---|
857 | !! Specifically: dia_obs_init --> dia_obs --> dia_obs_wri |
---|
858 | !! |
---|
859 | !! ** Method : Clean up various arrays left behind by the obs_oper. |
---|
860 | !! |
---|
861 | !! ** Action : |
---|
862 | !! |
---|
863 | !!---------------------------------------------------------------------- |
---|
864 | ! obs_grid deallocation |
---|
865 | CALL obs_grid_deallocate |
---|
866 | |
---|
867 | ! diaobs deallocation |
---|
868 | IF ( nproftypes > 0 ) & |
---|
869 | & DEALLOCATE( cobstypesprof, profdata, profdataqc, nvarsprof, nextrprof ) |
---|
870 | |
---|
871 | IF ( nsurftypes > 0 ) & |
---|
872 | & DEALLOCATE( cobstypessurf, surfdata, surfdataqc, nvarssurf, nextrsurf, & |
---|
873 | & n2dintsurf, zavglamscl, zavgphiscl, lfpindegs, llnightav ) |
---|
874 | |
---|
875 | END SUBROUTINE dia_obs_dealloc |
---|
876 | |
---|
877 | SUBROUTINE calc_date( kstp, ddobs ) |
---|
878 | !!---------------------------------------------------------------------- |
---|
879 | !! *** ROUTINE calc_date *** |
---|
880 | !! |
---|
881 | !! ** Purpose : Get date in double precision YYYYMMDD.HHMMSS format |
---|
882 | !! |
---|
883 | !! ** Method : Get date in double precision YYYYMMDD.HHMMSS format |
---|
884 | !! |
---|
885 | !! ** Action : Get date in double precision YYYYMMDD.HHMMSS format |
---|
886 | !! |
---|
887 | !! ** Action : Get initial date in double precision YYYYMMDD.HHMMSS format |
---|
888 | !! |
---|
889 | !! History : |
---|
890 | !! ! 06-03 (K. Mogensen) Original code |
---|
891 | !! ! 06-05 (K. Mogensen) Reformatted |
---|
892 | !! ! 06-10 (A. Weaver) Cleaning |
---|
893 | !! ! 06-10 (G. Smith) Calculates initial date the same as method for final date |
---|
894 | !! ! 10-05 (D. Lea) Update to month length calculation for NEMO vn3.2 |
---|
895 | !! ! 2014-09 (D. Lea) New generic routine now deals with arbitrary initial time of day |
---|
896 | !!---------------------------------------------------------------------- |
---|
897 | USE phycst, ONLY : & ! Physical constants |
---|
898 | & rday |
---|
899 | USE dom_oce, ONLY : & ! Ocean space and time domain variables |
---|
900 | & rn_Dt |
---|
901 | |
---|
902 | IMPLICIT NONE |
---|
903 | |
---|
904 | !! * Arguments |
---|
905 | REAL(KIND=dp), INTENT(OUT) :: ddobs ! Date in YYYYMMDD.HHMMSS |
---|
906 | INTEGER :: kstp |
---|
907 | |
---|
908 | !! * Local declarations |
---|
909 | INTEGER :: iyea ! date - (year, month, day, hour, minute) |
---|
910 | INTEGER :: imon |
---|
911 | INTEGER :: iday |
---|
912 | INTEGER :: ihou |
---|
913 | INTEGER :: imin |
---|
914 | INTEGER :: imday ! Number of days in month. |
---|
915 | REAL(wp) :: zdayfrc ! Fraction of day |
---|
916 | |
---|
917 | INTEGER, DIMENSION(12) :: imonth_len !: length in days of the months of the current year |
---|
918 | |
---|
919 | !!---------------------------------------------------------------------- |
---|
920 | !! Initial date initialization (year, month, day, hour, minute) |
---|
921 | !!---------------------------------------------------------------------- |
---|
922 | iyea = ndate0 / 10000 |
---|
923 | imon = ( ndate0 - iyea * 10000 ) / 100 |
---|
924 | iday = ndate0 - iyea * 10000 - imon * 100 |
---|
925 | ihou = nn_time0 / 100 |
---|
926 | imin = ( nn_time0 - ihou * 100 ) |
---|
927 | |
---|
928 | !!---------------------------------------------------------------------- |
---|
929 | !! Compute number of days + number of hours + min since initial time |
---|
930 | !!---------------------------------------------------------------------- |
---|
931 | zdayfrc = kstp * rn_Dt / rday |
---|
932 | zdayfrc = zdayfrc - aint(zdayfrc) |
---|
933 | imin = imin + int( zdayfrc * 24 * 60 ) |
---|
934 | DO WHILE (imin >= 60) |
---|
935 | imin=imin-60 |
---|
936 | ihou=ihou+1 |
---|
937 | END DO |
---|
938 | DO WHILE (ihou >= 24) |
---|
939 | ihou=ihou-24 |
---|
940 | iday=iday+1 |
---|
941 | END DO |
---|
942 | iday = iday + kstp * rn_Dt / rday |
---|
943 | |
---|
944 | !----------------------------------------------------------------------- |
---|
945 | ! Convert number of days (iday) into a real date |
---|
946 | !---------------------------------------------------------------------- |
---|
947 | |
---|
948 | CALL calc_month_len( iyea, imonth_len ) |
---|
949 | |
---|
950 | DO WHILE ( iday > imonth_len(imon) ) |
---|
951 | iday = iday - imonth_len(imon) |
---|
952 | imon = imon + 1 |
---|
953 | IF ( imon > 12 ) THEN |
---|
954 | imon = 1 |
---|
955 | iyea = iyea + 1 |
---|
956 | CALL calc_month_len( iyea, imonth_len ) ! update month lengths |
---|
957 | ENDIF |
---|
958 | END DO |
---|
959 | |
---|
960 | !---------------------------------------------------------------------- |
---|
961 | ! Convert it into YYYYMMDD.HHMMSS format. |
---|
962 | !---------------------------------------------------------------------- |
---|
963 | ddobs = iyea * 10000_dp + imon * 100_dp + & |
---|
964 | & iday + ihou * 0.01_dp + imin * 0.0001_dp |
---|
965 | |
---|
966 | END SUBROUTINE calc_date |
---|
967 | |
---|
968 | SUBROUTINE ini_date( ddobsini ) |
---|
969 | !!---------------------------------------------------------------------- |
---|
970 | !! *** ROUTINE ini_date *** |
---|
971 | !! |
---|
972 | !! ** Purpose : Get initial date in double precision YYYYMMDD.HHMMSS format |
---|
973 | !! |
---|
974 | !! ** Method : |
---|
975 | !! |
---|
976 | !! ** Action : |
---|
977 | !! |
---|
978 | !! History : |
---|
979 | !! ! 06-03 (K. Mogensen) Original code |
---|
980 | !! ! 06-05 (K. Mogensen) Reformatted |
---|
981 | !! ! 06-10 (A. Weaver) Cleaning |
---|
982 | !! ! 10-05 (D. Lea) Update to month length calculation for NEMO vn3.2 |
---|
983 | !! ! 2014-09 (D. Lea) Change to call generic routine calc_date |
---|
984 | !!---------------------------------------------------------------------- |
---|
985 | |
---|
986 | IMPLICIT NONE |
---|
987 | |
---|
988 | !! * Arguments |
---|
989 | REAL(KIND=dp), INTENT(OUT) :: ddobsini ! Initial date in YYYYMMDD.HHMMSS |
---|
990 | |
---|
991 | CALL calc_date( nit000 - 1, ddobsini ) |
---|
992 | |
---|
993 | END SUBROUTINE ini_date |
---|
994 | |
---|
995 | SUBROUTINE fin_date( ddobsfin ) |
---|
996 | !!---------------------------------------------------------------------- |
---|
997 | !! *** ROUTINE fin_date *** |
---|
998 | !! |
---|
999 | !! ** Purpose : Get final date in double precision YYYYMMDD.HHMMSS format |
---|
1000 | !! |
---|
1001 | !! ** Method : |
---|
1002 | !! |
---|
1003 | !! ** Action : |
---|
1004 | !! |
---|
1005 | !! History : |
---|
1006 | !! ! 06-03 (K. Mogensen) Original code |
---|
1007 | !! ! 06-05 (K. Mogensen) Reformatted |
---|
1008 | !! ! 06-10 (A. Weaver) Cleaning |
---|
1009 | !! ! 10-05 (D. Lea) Update to month length calculation for NEMO vn3.2 |
---|
1010 | !! ! 2014-09 (D. Lea) Change to call generic routine calc_date |
---|
1011 | !!---------------------------------------------------------------------- |
---|
1012 | |
---|
1013 | IMPLICIT NONE |
---|
1014 | |
---|
1015 | !! * Arguments |
---|
1016 | REAL(dp), INTENT(OUT) :: ddobsfin ! Final date in YYYYMMDD.HHMMSS |
---|
1017 | |
---|
1018 | CALL calc_date( nitend, ddobsfin ) |
---|
1019 | |
---|
1020 | END SUBROUTINE fin_date |
---|
1021 | |
---|
1022 | SUBROUTINE obs_settypefiles( ntypes, jpmaxnfiles, ifiles, cobstypes, cfiles ) |
---|
1023 | |
---|
1024 | INTEGER, INTENT(IN) :: ntypes ! Total number of obs types |
---|
1025 | INTEGER, INTENT(IN) :: jpmaxnfiles ! Maximum number of files allowed for each type |
---|
1026 | INTEGER, DIMENSION(ntypes), INTENT(OUT) :: & |
---|
1027 | & ifiles ! Out number of files for each type |
---|
1028 | CHARACTER(len=lca), DIMENSION(ntypes), INTENT(IN) :: & |
---|
1029 | & cobstypes ! List of obs types |
---|
1030 | CHARACTER(len=128), DIMENSION(ntypes, jpmaxnfiles), INTENT(IN) :: & |
---|
1031 | & cfiles ! List of files for all types |
---|
1032 | |
---|
1033 | !Local variables |
---|
1034 | INTEGER :: jfile |
---|
1035 | INTEGER :: jtype |
---|
1036 | |
---|
1037 | DO jtype = 1, ntypes |
---|
1038 | |
---|
1039 | ifiles(jtype) = 0 |
---|
1040 | DO jfile = 1, jpmaxnfiles |
---|
1041 | IF ( trim(cfiles(jtype,jfile)) /= '' ) & |
---|
1042 | ifiles(jtype) = ifiles(jtype) + 1 |
---|
1043 | END DO |
---|
1044 | |
---|
1045 | IF ( ifiles(jtype) == 0 ) THEN |
---|
1046 | CALL ctl_stop( 'Logical for observation type '//TRIM(cobstypes(jtype))// & |
---|
1047 | & ' set to true but no files available to read' ) |
---|
1048 | ENDIF |
---|
1049 | |
---|
1050 | IF(lwp) THEN |
---|
1051 | WRITE(numout,*) ' '//cobstypes(jtype)//' input observation file names:' |
---|
1052 | DO jfile = 1, ifiles(jtype) |
---|
1053 | WRITE(numout,*) ' '//TRIM(cfiles(jtype,jfile)) |
---|
1054 | END DO |
---|
1055 | ENDIF |
---|
1056 | |
---|
1057 | END DO |
---|
1058 | |
---|
1059 | END SUBROUTINE obs_settypefiles |
---|
1060 | |
---|
1061 | SUBROUTINE obs_setinterpopts( ntypes, jtype, ctypein, & |
---|
1062 | & n2dint_default, n2dint_type, & |
---|
1063 | & ravglamscl_type, ravgphiscl_type, & |
---|
1064 | & lfp_indegs_type, lavnight_type, & |
---|
1065 | & n2dint, ravglamscl, ravgphiscl, & |
---|
1066 | & lfpindegs, lavnight ) |
---|
1067 | |
---|
1068 | INTEGER, INTENT(IN) :: ntypes ! Total number of obs types |
---|
1069 | INTEGER, INTENT(IN) :: jtype ! Index of the current type of obs |
---|
1070 | INTEGER, INTENT(IN) :: n2dint_default ! Default option for interpolation type |
---|
1071 | INTEGER, INTENT(IN) :: n2dint_type ! Option for interpolation type |
---|
1072 | REAL(wp), INTENT(IN) :: & |
---|
1073 | & ravglamscl_type, & !E/W diameter of obs footprint for this type |
---|
1074 | & ravgphiscl_type !N/S diameter of obs footprint for this type |
---|
1075 | LOGICAL, INTENT(IN) :: lfp_indegs_type !T=> footprint in degrees, F=> in metres |
---|
1076 | LOGICAL, INTENT(IN) :: lavnight_type !T=> obs represent night time average |
---|
1077 | CHARACTER(len=8), INTENT(IN) :: ctypein |
---|
1078 | |
---|
1079 | INTEGER, DIMENSION(ntypes), INTENT(INOUT) :: & |
---|
1080 | & n2dint |
---|
1081 | REAL(wp), DIMENSION(ntypes), INTENT(INOUT) :: & |
---|
1082 | & ravglamscl, ravgphiscl |
---|
1083 | LOGICAL, DIMENSION(ntypes), INTENT(INOUT) :: & |
---|
1084 | & lfpindegs, lavnight |
---|
1085 | |
---|
1086 | lavnight(jtype) = lavnight_type |
---|
1087 | |
---|
1088 | IF ( (n2dint_type >= 0) .AND. (n2dint_type <= 6) ) THEN |
---|
1089 | n2dint(jtype) = n2dint_type |
---|
1090 | ELSE IF ( n2dint_type == -1 ) THEN |
---|
1091 | n2dint(jtype) = n2dint_default |
---|
1092 | ELSE |
---|
1093 | CALL ctl_stop(' Choice of '//TRIM(ctypein)//' horizontal (2D) interpolation method', & |
---|
1094 | & ' is not available') |
---|
1095 | ENDIF |
---|
1096 | |
---|
1097 | ! For averaging observation footprints set options for size of footprint |
---|
1098 | IF ( (n2dint(jtype) > 4) .AND. (n2dint(jtype) <= 6) ) THEN |
---|
1099 | IF ( ravglamscl_type > 0._wp ) THEN |
---|
1100 | ravglamscl(jtype) = ravglamscl_type |
---|
1101 | ELSE |
---|
1102 | CALL ctl_stop( 'Incorrect value set for averaging footprint '// & |
---|
1103 | 'scale (ravglamscl) for observation type '//TRIM(ctypein) ) |
---|
1104 | ENDIF |
---|
1105 | |
---|
1106 | IF ( ravgphiscl_type > 0._wp ) THEN |
---|
1107 | ravgphiscl(jtype) = ravgphiscl_type |
---|
1108 | ELSE |
---|
1109 | CALL ctl_stop( 'Incorrect value set for averaging footprint '// & |
---|
1110 | 'scale (ravgphiscl) for observation type '//TRIM(ctypein) ) |
---|
1111 | ENDIF |
---|
1112 | |
---|
1113 | lfpindegs(jtype) = lfp_indegs_type |
---|
1114 | |
---|
1115 | ENDIF |
---|
1116 | |
---|
1117 | ! Write out info |
---|
1118 | IF(lwp) THEN |
---|
1119 | IF ( n2dint(jtype) <= 4 ) THEN |
---|
1120 | WRITE(numout,*) ' '//TRIM(ctypein)// & |
---|
1121 | & ' model counterparts will be interpolated horizontally' |
---|
1122 | ELSE IF ( n2dint(jtype) <= 6 ) THEN |
---|
1123 | WRITE(numout,*) ' '//TRIM(ctypein)// & |
---|
1124 | & ' model counterparts will be averaged horizontally' |
---|
1125 | WRITE(numout,*) ' '//' with E/W scale: ',ravglamscl(jtype) |
---|
1126 | WRITE(numout,*) ' '//' with N/S scale: ',ravgphiscl(jtype) |
---|
1127 | IF ( lfpindegs(jtype) ) THEN |
---|
1128 | WRITE(numout,*) ' '//' (in degrees)' |
---|
1129 | ELSE |
---|
1130 | WRITE(numout,*) ' '//' (in metres)' |
---|
1131 | ENDIF |
---|
1132 | ENDIF |
---|
1133 | ENDIF |
---|
1134 | |
---|
1135 | END SUBROUTINE obs_setinterpopts |
---|
1136 | |
---|
1137 | END MODULE diaobs |
---|