da_define_structures.f90

References to this file elsewhere.
1 module da_define_structures
2 
3     use module_domain, only: vp_type, x_type
4 
5     use da_control, only : anal_type_randomcv, stdout, max_fgat_time, &
6        vert_corr, global, num_pseudo, vert_evalue,print_detail_be, maxsensor, &
7        max_ob_levels,da_array_print, trace_use
8 
9     use da_tracing, only : da_trace_entry, da_trace_exit
10 
11     use da_reporting, only : da_error, message
12 
13    !---------------------------------------------------------------------------
14    ! Purpose: Collection of routines to define and allocate structures.
15    !---------------------------------------------------------------------------
16 
17    implicit none
18    
19    !--------------------------------------------------------------------------
20    ! [2.0] Background field structure definition:
21    !--------------------------------------------------------------------------
22 
23    type xbx_type
24 
25       character (len=4):: mminlu
26 
27       integer          :: fft_pad_i          ! Padding to get 2**p 3**q 5**r. (p>=1)
28       integer          :: fft_pad_j          ! Padding to get 2**p 3**q 5**r.
29 
30       integer          :: pad_num            ! Splitted fft_pad_i on this processor.
31       integer          :: pad_inc            ! Pad increment (split over v2y).
32       integer, pointer :: pad_loc(:)         ! pad location on this processor.
33       integer, pointer :: pad_pos(:)         ! pad position beyond ide for this processor.
34 
35       integer          :: fft_ix             ! x-direction FFT number, in 2**p 3**q 5**r.
36       integer          :: fft_jy             ! y-direction FFT number, in 2**p 3**q 5**r.
37 
38       integer, pointer :: fft_factors_x(:)   ! FFT factors in x direction.
39       integer, pointer :: fft_factors_y(:)   ! FFT factors in y direction.
40 
41       real, pointer    :: trig_functs_x(:)   ! Trig functions in x direction.
42       real, pointer    :: trig_functs_y(:)   ! Trig functions in y direction.
43 
44       real             :: psac_mean          ! Mean pressure.
45       real, pointer    :: latc_mean(:)       ! Mean latitude.
46 
47       real, pointer    :: fft_coeffs(:,:)    ! FFT Coefficients
48 
49       real             :: fft_adjoint_factor ! FFT Adjoint factor
50       ! spectral transform related variables
51       integer          :: inc                ! Vector array increment 
52       integer          :: ni
53       integer          :: nj
54       integer          :: nk
55       integer          :: max_wavenumber
56       integer          :: lenr
57       integer          :: lensav
58       integer          :: lenwrk
59       integer          :: alp_size
60       real, pointer       :: wsave(:)          ! Primes for FFT.
61       real, pointer       :: lon(:)            ! Longitude (radians).
62       real, pointer       :: sinlon(:)         ! sine(longitude).
63       real, pointer       :: coslon(:)         ! cosine(longitude).
64       real, pointer       :: lat(:)            ! Latitude (radians, from south).
65       real, pointer       :: sinlat(:)         ! sine(latitude).
66       real, pointer       :: coslat(:)         ! cosine(latitude).
67       real, pointer       :: int_wgts(:)       ! Legendre integration weights.
68       real, pointer       :: alp(:)            ! Associated Legendre Polynomial.
69    end type xbx_type
70 
71    !--------------------------------------------------------------------------
72    ! [3.0] Innovation vector structure definition:
73    !--------------------------------------------------------------------------
74 
75    ! [3.1] Generic sub-structures used in ob_type:
76 
77    type field_type
78       real                   :: inv             ! Innovation vector
79       integer                :: qc              ! Observation QC
80       real                   :: error           ! Observational error
81    end type field_type
82 
83    type model_loc_type
84       type (field_type)       :: slp            ! Pressure in Pa
85       ! type (field_type)       :: psfc           ! Pressure in Pa
86       ! Remove the following in future (needed now for obs i/o only):
87       type (field_type)       :: pw             ! Toatl precipitable water cm
88 
89       real                    :: x
90       real                    :: y
91       integer                 :: i
92       integer                 :: j
93       real                    :: dx
94       real                    :: dxm
95       real                    :: dy
96       real                    :: dym
97       logical                 :: proc_domain
98       ! obs_global_index is the original index of this obs in the serial 
99       ! code.  It is used to reassemble obs in serial-code-order to replicate 
100       ! summation order for bitwise-exact testing of distributed-memory 
101       ! parallel configurations.  
102       ! obs_global_report is the index in the input data file
103       integer                 :: obs_global_index
104       integer                 :: obs_global_report
105 
106       integer                 :: v_interp_optn  ! 0, not specified
107                                                 ! 1, vertical interpolate in pressure
108                                                 ! 2, vertical interpolate in height
109 
110    end type model_loc_type
111 
112    type each_level_type
113       real                    :: height         ! Height in m
114       integer                 :: height_qc      ! Height QC
115       real                    :: zk             ! k-coordinates
116       type (field_type)       :: u              ! Wind x-component in m/s
117       type (field_type)       :: v              ! Wind y-component in m/s
118       type (field_type)       :: p              ! Pressure in Pa
119       type (field_type)       :: t              ! Temperature in K
120       type (field_type)       :: q              ! Mixing ratio (kg/kg).
121       type (field_type)       :: rh             ! Relative humidity (%).
122       type (field_type)       :: td             ! dew-point in K
123       type (field_type)       :: Speed          ! Wind speed m/s
124    end type each_level_type
125 
126    type radar_each_level_type
127       real                   :: height         ! Height in m
128       integer                :: height_qc      ! Height QC
129       real                   :: zk             ! MM5 k-coordinates
130       type (field_type)      :: rv
131       type (field_type)      :: rf
132    end type radar_each_level_type
133 
134    type info_type
135       character (len = 40)   :: name          ! Station name
136       character (len = 12)   :: platform      ! Instrument platform
137       character (len =  5)   :: id            ! 5 digit station identifer
138       character (len = 19)   :: date_char     ! CCYY-MM-DD_HH:MM:SS date
139       integer                :: levels        ! number of levels
140       real                   :: lat           ! Latitude in degree
141       real                   :: lon           ! Longitude in degree
142       real                   :: elv           ! Elevation in m
143       real                   :: pstar         ! Surface pressure
144    end type info_type
145 
146    type stn_loc_type
147       real                    :: lon                  ! Radar site loc
148       real                    :: lat                  ! Radar site loc
149       real                    :: elv                  ! Radar site loc
150       real                    :: x                    ! Radar site loc
151       real                    :: y                    ! Radar site loc
152       real                    :: zk                   ! Radar site loc
153    end type stn_loc_type
154  
155    type radar_type
156       type (stn_loc_type)     :: stn_loc
157       type (info_type)        :: info
158       type (model_loc_type)   :: loc
159 
160       real                    :: model_p(max_ob_levels)
161       real                    :: model_rho(max_ob_levels)
162       real                    :: model_qrn(max_ob_levels)
163       real                    :: model_ps
164 
165       real                  , pointer :: height   (:) ! Height in m
166       integer               , pointer :: height_qc(:) ! Height QC
167       real                  , pointer :: zk       (:) ! MM5 k-coordinates
168 
169       type (field_type)     , pointer :: rv       (:) ! Radial Velocity
170       type (field_type)     , pointer :: rf       (:) ! Reflectivity
171    end type radar_type
172 
173    type multi_level_type
174       type (info_type)                        :: info
175       type (model_loc_type)                   :: loc
176       type (each_level_type)                  :: each(max_ob_levels)
177    end type multi_level_type
178 
179    type radar_stn_type
180       character (len = 5)    :: platform      ! Data type
181       character (len = 12)   :: name          ! Station name
182       character (len = 19)   :: date_char     ! CCYY-MM-DD_HH:MM:SS date
183       integer                :: numObs        ! number of Obs
184       integer                :: levels        ! number of levels
185       real                   :: lat           ! Latitude in degree
186       real                   :: lon           ! Longitude in degree
187       real                   :: elv           ! Elevation in m
188    end type radar_stn_type
189 
190    type radar_multi_level_type
191       type (radar_stn_type)                   :: stn
192       type (info_type)                        :: info
193       type (model_loc_type)                   :: loc
194       type (radar_each_level_type)            :: each(max_ob_levels)
195    end type radar_multi_level_type
196 
197    ! [3.2] Innovation vector structure:
198 
199    type airep_type
200       type (info_type)        :: info
201       type (model_loc_type)   :: loc
202 
203       real                  , pointer :: h        (:) ! Height in m
204       real                  , pointer :: p        (:) ! Height QC
205       real                  , pointer :: zk       (:) ! k-coordinates
206 
207       type (field_type)     , pointer :: u        (:) ! u-wind.
208       type (field_type)     , pointer :: v        (:) ! v-wind.
209       type (field_type)     , pointer :: t        (:) ! temperature.
210    end type airep_type
211 
212    type pilot_type
213       type (info_type)        :: info
214       type (model_loc_type)   :: loc
215 
216       real                  , pointer :: p        (:) ! Height in m
217       real                  , pointer :: zk       (:) ! k-coordinates
218 
219       type (field_type)     , pointer :: u        (:) ! u-wind.
220       type (field_type)     , pointer :: v        (:) ! v-wind.
221    end type pilot_type
222 
223    type bogus_type
224       type (info_type)        :: info
225       type (model_loc_type)   :: loc
226 
227       real                  , pointer :: h        (:) ! Height in m
228       real                  , pointer :: p        (:) ! pressure.
229       real                  , pointer :: zk       (:) ! k-coordinates
230 
231       type (field_type)     , pointer :: u        (:) ! u-wind.
232       type (field_type)     , pointer :: v        (:) ! v-wind.
233       type (field_type)     , pointer :: t        (:) ! temperature.
234       type (field_type)     , pointer :: q        (:) ! q.
235       type (field_type)               :: slp          ! sea level pressure.
236    end type bogus_type
237 
238    type satem_type
239       type (info_type)        :: info
240       type (model_loc_type)   :: loc
241 
242       real                            :: ref_p        ! Reference pressure
243       real                  , pointer :: p        (:) ! Multi-level pressure
244 
245       type (field_type)     , pointer :: thickness(:)     ! Thickness.
246       type (field_type)     , pointer :: org_thickness(:) ! To store original Thickness info.
247    end type satem_type
248 
249    type geoamv_type
250       type (info_type)        :: info
251       type (model_loc_type)   :: loc
252 
253       real                  , pointer :: p        (:) ! Height in Pa
254       real                  , pointer :: zk       (:) ! k-coordinates
255 
256       type (field_type)     , pointer :: u        (:) ! u-wind.
257       type (field_type)     , pointer :: v        (:) ! v-wind.
258    end type geoamv_type
259 
260    type polaramv_type
261       type (info_type)        :: info
262       type (model_loc_type)   :: loc
263 
264       real                  , pointer :: p        (:) ! Height in Pa
265       real                  , pointer :: zk       (:) ! k-coordinates
266 
267       type (field_type)     , pointer :: u        (:) ! u-wind.
268       type (field_type)     , pointer :: v        (:) ! v-wind.
269    end type polaramv_type
270 
271    type gpsref_type
272       type (info_type)        :: info
273       type (model_loc_type)   :: loc
274 
275       real             , pointer :: h  (:)      ! Multi-level height
276       real             , pointer :: zk (:)      ! k-coordinates
277 
278       type (field_type), pointer :: ref(:)      ! GPS Refractivity
279       type (field_type), pointer :: p  (:)      ! Retrieved P from Ref.
280       type (field_type), pointer :: t  (:)      ! Retrieved T from Ref.
281       type (field_type), pointer :: q  (:)      ! From NCEP analysis.
282    end type gpsref_type
283 
284    ! type metar_type
285    !    type (info_type)        :: info
286    !    type (model_loc_type)   :: loc
287 
288    !    real                    :: h              ! Height in m
289    !    real                    :: zk             ! k-coordinates
290 
291    !    type (field_type)       :: u              ! u-wind.
292    !    type (field_type)       :: v              ! v-wind.
293    !    type (field_type)       :: t              ! temperature.
294    !    type (field_type)       :: p              ! pressure.
295    !    type (field_type)       :: q              ! q.
296    ! end type metar_type
297 
298    ! type ships_type
299    !    type (info_type)        :: info
300    !    type (model_loc_type)   :: loc
301 
302    !    real                    :: h              ! Height in m
303    !    real                    :: zk             ! k-coordinates
304 
305    !    type (field_type)       :: u              ! u-wind.
306    !    type (field_type)       :: v              ! v-wind.
307    !    type (field_type)       :: t              ! temperature.
308    !    type (field_type)       :: p              ! pressure.
309    !    type (field_type)       :: q              ! q.
310    ! end type ships_type
311 
312    type synop_type
313       type (info_type)        :: info
314       type (model_loc_type)   :: loc
315 
316       real                    :: h              ! Height in m
317       real                    :: zk             ! k-coordinates
318 
319       type (field_type)       :: u              ! u-wind.
320       type (field_type)       :: v              ! v-wind.
321       type (field_type)       :: t              ! temperature.
322       type (field_type)       :: p              ! pressure.
323       type (field_type)       :: q              ! q.
324    end type synop_type
325 
326    type sound_type
327       type (info_type)      :: info
328       type (model_loc_type) :: loc
329 
330       real                  , pointer :: h        (:) ! Height in m
331       real                  , pointer :: p        (:) ! pressure.
332       real                  , pointer :: zk       (:) ! k-coordinates
333 
334       type (field_type)     , pointer :: u        (:) ! u-wind.
335       type (field_type)     , pointer :: v        (:) ! v-wind.
336       type (field_type)     , pointer :: t        (:) ! temperature.
337       type (field_type)     , pointer :: q        (:) ! q.
338    end type sound_type
339 
340    type airsr_type
341       type (info_type)      :: info
342       type (model_loc_type) :: loc
343 
344       real                  , pointer :: h        (:) ! Height in m
345       real                  , pointer :: p        (:) ! pressure.
346       real                  , pointer :: zk       (:) ! k-coordinates
347 
348       type (field_type)     , pointer :: t        (:) ! temperature.
349       type (field_type)     , pointer :: q        (:) ! q.
350    end type airsr_type
351 
352    type gpspw_type
353       type (info_type)        :: info
354       type (model_loc_type)   :: loc
355 
356       type (field_type)       :: tpw  ! Toatl precipitable water cm from GPS
357    end type gpspw_type
358 
359    type ssmi_retrieval_type
360       type (info_type)        :: info
361       type (model_loc_type)   :: loc
362 
363       type (field_type)       :: Speed          ! Wind speed in m/s
364       type (field_type)       :: tpw            ! Toatl precipitable water cm
365    end type ssmi_retrieval_type
366 
367    type ssmi_tb_type
368       type (info_type)        :: info
369       type (model_loc_type)   :: loc
370 
371       type (field_type)       :: tb19v          ! Brightness T (k) 19V
372       type (field_type)       :: tb19h          ! Brightness T (k) 19H
373       type (field_type)       :: tb22v          ! Brightness T (k) 22V
374       type (field_type)       :: tb37v          ! Brightness T (k) 37V
375       type (field_type)       :: tb37h          ! Brightness T (k) 37H
376       type (field_type)       :: tb85v          ! Brightness T (k) 85V
377       type (field_type)       :: tb85h          ! Brightness T (k) 85H
378    end type ssmi_tb_type
379    
380    type ssmt1_type
381       type (info_type)        :: info
382       type (model_loc_type)   :: loc
383       
384       real                  , pointer :: h        (:) ! Height in m
385       real                  , pointer :: p        (:) ! Pressure in Pa.
386       real                  , pointer :: zk       (:) ! k-coordinates
387 
388       type (field_type)     , pointer :: t        (:) ! temperature.
389    end type ssmt1_type
390 
391    type ssmt2_type
392       type (info_type)        :: info
393       type (model_loc_type)   :: loc
394       
395       real                  , pointer :: h        (:) ! Height in m
396       real                  , pointer :: p        (:) ! Pressure in Pa.
397       real                  , pointer :: zk       (:) ! k-coordinates
398 
399       type (field_type)     , pointer :: rh       (:) ! Relative humidity.
400    end type ssmt2_type
401 
402    type pseudo_type
403       type (info_type)        :: info
404       type (model_loc_type)   :: loc
405 
406       ! real                    :: h              ! Height in m
407       real                    :: zk             ! k-coordinates
408 
409       type (field_type)       :: u              ! u-wind.
410       type (field_type)       :: v              ! v-wind.
411       type (field_type)       :: t              ! Temperature.
412       type (field_type)       :: p              ! Pressure.
413       type (field_type)       :: q              ! Specific Humidity.
414    end type pseudo_type
415 
416    type qscat_type
417       type (info_type)        :: info
418       type (model_loc_type)   :: loc
419 
420       real                    :: h              ! Height in m
421       real                    :: zk             ! k-coordinates
422 
423       type (field_type)       :: u              ! u-wind.
424       type (field_type)       :: v              ! v-wind.
425    end type qscat_type
426 
427    type instid_type
428       ! Instrument triplet, follow the convension of RTTOV
429       integer              :: platform_id, satellite_id, sensor_id
430       character(len=20)    :: rttovid_string
431       integer              :: num_rad, nchan, nlevels
432       integer              :: nchannels, nfrequencies,nbtout
433       integer              :: num_rad_glo
434       integer, pointer     :: ichan(:)
435       logical, pointer     :: proc_domain(:)
436       integer, pointer     :: loc_i(:)
437       integer, pointer     :: loc_j(:)
438       integer, pointer     :: loc_k(:,:)
439       real,    pointer     :: loc_dx(:)  
440       real,    pointer     :: loc_dy(:)  
441       real,    pointer     :: loc_dz(:,:)  
442       real,    pointer     :: loc_dxm(:) 
443       real,    pointer     :: loc_dym(:) 
444       real,    pointer     :: loc_dzm(:,:) 
445       real,    pointer     :: zk(:,:) 
446       real,    pointer     :: tb_inv(:,:)
447       integer, pointer     :: tb_qc(:,:)
448       real,    pointer     :: tb_error(:,:)
449       real,    pointer     :: tb_xb(:,:) 
450       integer, pointer     :: scanpos(:)
451       integer, pointer     :: scanline(:)
452       integer, pointer     :: cloud_flag(:,:)
453       real,    pointer     :: satzen(:) 
454       real,    pointer     :: satazi(:) 
455       real,    pointer     :: solzen(:) 
456       real,    pointer     :: solazi(:) 
457       real,    pointer     :: t(:,:)
458       real,    pointer     :: q(:,:)
459       real,    pointer     :: mr(:,:)
460       real,    pointer     :: tm(:,:)
461       real,    pointer     :: qm(:,:)
462       real,    pointer     :: qrn(:,:)
463       real,    pointer     :: qcw(:,:)
464       real,    pointer     :: qci(:,:)
465       real,    pointer     :: qsn(:,:)
466       real,    pointer     :: qgr(:,:)
467       real,    pointer     :: pm(:,:)
468       real,    pointer     :: pf(:,:)  ! full level pressure for CRTM
469       real,    pointer     :: emiss(:,:)
470       real,    pointer     :: u10(:)
471       real,    pointer     :: v10(:)
472       real,    pointer     :: t2m(:)
473       real,    pointer     :: q2m(:)
474       real,    pointer     :: mr2m(:)
475       real,    pointer     :: psfc(:)
476       real,    pointer     :: ps(:)
477       real,    pointer     :: ts(:)
478       real,    pointer     :: smois(:)
479       real,    pointer     :: tslb(:)
480       real,    pointer     :: snowh(:)
481       integer, pointer     :: isflg(:)
482       integer, pointer     :: ifgat(:)
483       integer, pointer     :: landsea_mask(:)
484       real,    pointer     :: elevation(:)
485       real,    pointer     :: soiltyp(:)
486       real,    pointer     :: vegtyp(:)
487       real,    pointer     :: vegfra(:)
488       real,    pointer     :: clwp(:)
489       real,    pointer     :: ps_jacobian(:,:)
490       real,    pointer     :: t_jacobian(:,:,:)
491       real,    pointer     :: q_jacobian(:,:,:)
492       real,    pointer     :: water_coverage(:)
493       real,    pointer     :: land_coverage(:)
494       real,    pointer     :: ice_coverage(:)
495       real,    pointer     :: snow_coverage(:)
496 
497 
498       type (info_type), pointer   :: info(:)
499       type (model_loc_type), pointer   :: loc(:)
500    end type instid_type
501 
502    type ob_numb_type
503       integer :: total, &
504                  synop, & 
505                  sound, &
506                  geoamv,&
507                  polaramv,&
508                  pilot, &
509                  bogus, &
510                  satem, &
511                  airep, &
512                  metar, &
513                  ships, &
514                  gpspw, &
515                  gpsref, &
516                  ssmi_tb, &
517                  ssmi_retrieval, &
518                  ssmt1, &
519                  ssmt2, &
520                  pseudo, &
521                  qscat, &
522                  profiler, &
523                  buoy, &
524                  Radar, &
525                  radiance(maxsensor), &
526                  airsr
527    end type ob_numb_type
528 
529    type ob_type
530       type(ob_numb_type) :: ob_numb(0:max_fgat_time)
531 
532       integer :: current_ob_time
533 
534       integer :: total_obs, num_synop, num_airsr, &
535                  num_sound, num_geoamv, num_polaramv, &
536                  num_pilot, num_satem, &
537                  num_airep, num_metar, &
538                  num_ships, num_gpspw, &
539                  num_ssmi_tb, num_ssmi_retrieval, &
540                  num_ssmt1, num_ssmt2, num_pseudo, &
541                  num_qscat, num_profiler, num_buoy, &
542                  num_Radar, num_gpsref, num_bogus, &
543                  num_inst, total_rad_pixel, total_rad_channel
544 
545       integer :: num_synop_glo, num_airsr_glo, &
546                  num_sound_glo, num_geoamv_glo, num_polaramv_glo, &
547                  num_pilot_glo, num_satem_glo, &
548                  num_airep_glo, num_metar_glo, &
549                  num_ships_glo, num_gpspw_glo, &
550                  num_ssmi_tb_glo, num_ssmi_retrieval_glo, &
551                  num_ssmt1_glo, num_ssmt2_glo, num_pseudo_glo, &
552                  num_qscat_glo, num_profiler_glo, num_buoy_glo, &
553                  num_Radar_glo, num_gpsref_glo, num_bogus_glo, &
554                  num_inst_glo
555 
556       real    :: synop_ef_u, synop_ef_v, synop_ef_t, synop_ef_p, synop_ef_q
557       real    :: metar_ef_u, metar_ef_v, metar_ef_t, metar_ef_p, metar_ef_q
558       real    :: ships_ef_u, ships_ef_v, ships_ef_t, ships_ef_p, ships_ef_q
559       real    :: geoamv_ef_u, geoamv_ef_v
560       real    :: polaramv_ef_u, polaramv_ef_v
561       real    :: gpspw_ef_tpw
562       real    :: sound_ef_u, sound_ef_v, sound_ef_t, sound_ef_q
563       real    :: airep_ef_u, airep_ef_v, airep_ef_t
564       real    :: pilot_ef_u, pilot_ef_v
565       real    :: ssmir_ef_speed, ssmir_ef_tpw
566       real    :: satem_ef_thickness, ssmt1_ef_t, ssmt2_ef_rh
567       real    :: gpsref_ef_ref, gpsref_ef_p, gpsref_ef_t, gpsref_ef_q
568       real    :: qscat_ef_u, qscat_ef_v
569       real    :: profiler_ef_u, profiler_ef_v
570       real    :: buoy_ef_u, buoy_ef_v, buoy_ef_t, buoy_ef_p, buoy_ef_q
571       real    :: Radar_ef_rv, Radar_ef_rf
572       real    :: bogus_ef_u, bogus_ef_v, bogus_ef_t, bogus_ef_p, bogus_ef_q, bogus_ef_slp
573       real    :: airsr_ef_t,  airsr_ef_q
574 
575       type (airsr_type)         , pointer :: airsr(:)
576       type (sound_type)         , pointer :: sound(:)
577       type (synop_type)         , pointer :: sonde_sfc(:)
578       type (airep_type)         , pointer :: airep(:)
579       type (pilot_type)         , pointer :: pilot(:)
580       type (satem_type)         , pointer :: satem(:)
581       type (geoamv_type)        , pointer :: geoamv(:)
582       type (polaramv_type)        , pointer :: polaramv(:)
583       type (synop_type)         , pointer :: synop(:)
584       type (synop_type)         , pointer :: metar(:)
585       type (synop_type)         , pointer :: ships(:)
586       type (gpspw_type)         , pointer :: gpspw(:)
587       type (gpsref_type)        , pointer :: gpsref(:)
588       type (ssmi_tb_type)       , pointer :: ssmi_tb(:)
589       type (ssmi_retrieval_type), pointer :: ssmi_retrieval(:)
590       type (ssmt1_type)         , pointer :: ssmt1(:)
591       type (ssmt2_type)         , pointer :: ssmt2(:)
592       type (pseudo_type)        , pointer :: pseudo(:)
593       type (qscat_type)         , pointer :: qscat(:)
594       type (synop_type)         , pointer :: buoy(:)
595       type (pilot_type)         , pointer :: profiler(:)
596       type (bogus_type)         , pointer :: bogus(:)
597       type (Radar_type)         , pointer :: Radar(:)
598       type (instid_type)        , pointer :: instid(:)
599 
600       real :: missing
601       real :: ptop
602 
603    end type ob_type
604 
605    ! [3.3] Where are these used:?
606 
607    type number_type
608       integer                    :: bad
609       integer                    :: miss
610       integer                    :: use
611    end type number_type
612 
613    type bad_info_type
614       type (number_type)         :: num
615       integer                    :: nn(100000)
616       integer                    :: kk(100000)
617    END type bad_info_type
618 
619    type  bad_data_type
620       type (bad_info_type)       :: u
621       type (bad_info_type)       :: v
622       type (bad_info_type)       :: t
623       type (bad_info_type)       :: p
624       type (bad_info_type)       :: q
625       type (bad_info_type)       :: tpw
626       type (bad_info_type)       :: Speed
627       type (bad_info_type)       :: gpsref
628       type (bad_info_type)       :: thickness
629       type (bad_info_type)       :: rh
630       type (bad_info_type)       :: rv
631       type (bad_info_type)       :: rf
632       type (bad_info_type)       :: slp
633       type (bad_info_type)       :: rad
634    end type bad_data_type
635 
636    type count_obs_number_type
637         integer                                 :: num_used
638         integer                                 :: num_outside_iyjx
639         integer                                 :: num_max_err_chk
640         integer                                 :: num_missing
641    end type count_obs_number_type
642  
643    type count_obs_type
644 
645         type (count_obs_number_type)  :: total_obs, num_synop, num_airsr_obs,&
646                                          num_sound, num_geoamv, num_polaramv,&
647                                          num_pilot, num_satem, &
648                                          num_airep, num_metar, &
649                                          num_ships, num_gpspw, &
650                                          num_gpsref, &
651                                          num_ssmi_retrieval,   &
652                                          num_ssmi_tb, &
653                                          num_ssmt1, num_ssmt2, &
654                                          num_qscat, &
655                                          num_profiler, &
656                                          num_buoy, &
657                                          num_Radar, num_bogus, &
658                                          num_other  
659 
660    end type count_obs_type
661 
662    !--------------------------------------------------------------------------
663    ! [3.0] Observation/residual structure definition:
664    !--------------------------------------------------------------------------
665 
666    type residual_synop_type
667       real :: u                                 ! u-wind.
668       real :: v                                 ! v-wind.
669       real :: t                                 ! temperature.
670       real :: p                                 ! pressure.
671       real :: q                                 ! q.
672    end type residual_synop_type
673 
674    type residual_qscat_type
675       real :: u                                 ! u-wind.
676       real :: v                                 ! v-wind.
677    end type residual_qscat_type
678 
679    type residual_geoamv_type
680       real, pointer :: u(:)                     ! u-wind.
681       real, pointer :: v(:)                     ! v-wind.
682    end type residual_geoamv_type
683 
684    type residual_polaramv_type
685       real, pointer :: u(:)                     ! u-wind.
686       real, pointer :: v(:)                     ! v-wind.
687    end type residual_polaramv_type
688 
689    type residual_gpspw_type
690       real :: tpw                               ! Total precipitable water.
691    end type residual_gpspw_type
692 
693    type residual_sound_type
694       real, pointer :: u(:)                     ! u-wind.
695       real, pointer :: v(:)                     ! v-wind.
696       real, pointer :: t(:)                     ! temperature.
697       real, pointer :: q(:)                     ! specific humidity.
698    end type residual_sound_type
699 
700    type residual_airsr_type
701       real, pointer :: t(:)                     ! temperature.
702       real, pointer :: q(:)                     ! specific humidity.
703    end type residual_airsr_type
704 
705    type residual_airep_type
706       real, pointer :: u(:)                     ! u-wind.
707       real, pointer :: v(:)                     ! v-wind.
708       real, pointer :: t(:)                     ! temperature.
709    end type residual_airep_type
710 
711    type residual_pilot_type
712       real, pointer :: u(:)                     ! u-wind.
713       real, pointer :: v(:)                     ! v-wind.
714    end type residual_pilot_type
715 
716    type residual_bogus_type
717       real, pointer :: u(:)                     ! u-wind.
718       real, pointer :: v(:)                     ! v-wind.
719       real, pointer :: t(:)                     ! temperature.
720       real, pointer :: q(:)                     ! specific humidity.
721       real          :: slp                      ! sea-level pressure.
722    end type residual_bogus_type
723 
724    type residual_satem_type
725       real, pointer :: thickness(:)             ! Thickness.
726    end type residual_satem_type
727 
728    type residual_gpsref_type
729       real, pointer :: ref(:)         ! GPS Refractivity
730       real, pointer :: p  (:)         ! GPS Retrived p from Refractivity
731       real, pointer :: t  (:)         ! GPS Retrived t from Refractivity
732       real, pointer :: q  (:)         ! q from NCEP used by CDAAC in retrieval
733    end type residual_gpsref_type
734 
735    type residual_ssmi_retrieval_type
736         real                    :: tpw      ! Toatl precipitable water cm
737         real                    :: Speed    ! Wind speed m/s
738    end type residual_ssmi_retrieval_type
739 
740    type residual_ssmi_tb_type
741         real                    :: tb19v          ! Brightness T (k) 19V
742         real                    :: tb19h          ! Brightness T (k) 19H
743         real                    :: tb22v          ! Brightness T (k) 22V
744         real                    :: tb37v          ! Brightness T (k) 37V
745         real                    :: tb37h          ! Brightness T (k) 37H
746         real                    :: tb85v          ! Brightness T (k) 85V
747         real                    :: tb85h          ! Brightness T (k) 85H
748    end type residual_ssmi_tb_type
749    
750    type residual_ssmt1_type
751       real, pointer :: t(:)                       ! temperature.
752    end type residual_ssmt1_type
753    
754    type residual_ssmt2_type
755       real, pointer :: rh(:)                      ! Relative Humidity.
756    end type residual_ssmt2_type
757 
758    type residual_pseudo_type
759       real :: u                                   ! u-wind.
760       real :: v                                   ! v-wind.
761       real :: t                                   ! temperature.
762       real :: p                                   ! pressure.
763       real :: q                                   ! specific humidity.
764    end type residual_pseudo_type
765 
766    type residual_Radar_type
767       real, pointer :: rv(:)                    ! rv
768       real, pointer :: rf(:)                    ! rf
769    end type residual_Radar_type
770 
771    type residual_instid_type
772      integer                          :: num_rad
773      integer                          :: nchan
774      integer ,  pointer               :: ichan (:)
775      real, pointer                    :: tb(:,:)
776    end type residual_instid_type
777 
778    type y_type
779       type(ob_numb_type) :: ob_numb
780 
781       integer :: total_obs, num_synop, num_airsr, &
782                  num_sound, num_geoamv, num_polaramv, &
783                  num_pilot, num_satem, &
784                  num_airep, num_metar, &
785                  num_ships, num_gpspw, &
786                  num_ssmi_tb, num_ssmi_retrieval, &
787                  num_ssmt1, num_ssmt2, num_pseudo, &
788                  num_qscat, num_profiler, num_buoy, &
789                  num_Radar, num_gpsref, num_bogus, &
790                  num_inst
791 
792       type (residual_synop_type), pointer :: synop(:)
793       type (residual_synop_type), pointer :: metar(:) ! Same as synop type
794       type (residual_synop_type), pointer :: ships(:) ! Same as synop type
795       type (residual_geoamv_type), pointer :: geoamv(:)
796       type (residual_polaramv_type), pointer :: polaramv(:)
797       type (residual_gpspw_type ), pointer :: gpspw (:)
798       type (residual_gpsref_type), pointer :: gpsref(:)
799       type (residual_sound_type), pointer :: sound(:)
800       type (residual_airsr_type), pointer :: airsr(:)
801       type (residual_bogus_type), pointer :: bogus(:)
802       type (residual_synop_type), pointer :: sonde_sfc(:) ! Same as synop type
803       type (residual_airep_type), pointer :: airep(:)
804       type (residual_pilot_type), pointer :: pilot(:)
805       type (residual_satem_type), pointer :: satem(:)
806       type (residual_ssmi_tb_type), pointer        :: ssmi_tb(:)
807       type (residual_ssmi_retrieval_type), pointer :: ssmi_retrieval(:)
808       type (residual_ssmt1_type), pointer :: ssmt1(:)
809       type (residual_ssmt2_type), pointer :: ssmt2(:)
810       type (residual_pseudo_type), pointer:: pseudo(:)
811       type (residual_qscat_type), pointer :: qscat(:)
812       type (residual_synop_type),  pointer :: buoy(:) ! Same as synop type
813       type (residual_pilot_type), pointer :: profiler(:) ! Same as pilot type
814       type (residual_Radar_type), pointer :: Radar(:)
815       type (residual_instid_type), pointer :: instid(:)
816    end type y_type
817 
818    !--------------------------------------------------------------------------
819    ! [4.0] Control variable structure:
820    !--------------------------------------------------------------------------
821 
822    ! Max/Min type:
823 
824    type maxmin_type
825         real                       :: value
826         integer                    :: n, l
827    end type maxmin_type
828 
829    !--------------------------------------------------------------------------
830    ! [5.0] Control variable structure:
831    !--------------------------------------------------------------------------
832    
833    type jo_type_rad
834       integer, pointer :: num_ichan(:)
835       real, pointer    :: jo_ichan(:)
836    end type jo_type_rad
837 
838    type jo_type
839       real                :: total
840       real                :: synop_u, synop_v, synop_t, synop_p, synop_q
841       real                :: metar_u, metar_v, metar_t, metar_p, metar_q
842       real                :: ships_u, ships_v, ships_t, ships_p, ships_q
843       real                :: geoamv_u, geoamv_v
844       real                :: polaramv_u, polaramv_v
845       real                :: gpspw_tpw, satem_thickness, gpsref_ref
846       real                :: sound_u, sound_v, sound_t, sound_q
847       real                :: sonde_sfc_u, sonde_sfc_v, sonde_sfc_t, &
848                              sonde_sfc_p, sonde_sfc_q
849       real                :: airep_u, airep_v, airep_t
850       real                :: pilot_u, pilot_v
851       real                :: ssmir_speed, ssmir_tpw
852       real                :: ssmi_tb19v, ssmi_tb19h, ssmi_tb22v, ssmi_tb37v, &
853                              ssmi_tb37h, ssmi_tb85v, ssmi_tb85h
854       real                :: ssmt1_t, ssmt2_rh
855       real                :: pseudo_u, pseudo_v, pseudo_t, pseudo_p, pseudo_q
856       real                :: qscat_u, qscat_v
857       real                :: profiler_u, profiler_v
858       real                :: buoy_u, buoy_v, buoy_t, buoy_p, buoy_q
859       real                :: Radar_rv, Radar_rf
860       real                :: bogus_u, bogus_v, bogus_t, bogus_q, bogus_slp
861       real                :: airsr_t, airsr_q
862       type(jo_type_rad), pointer       :: rad(:)
863    end type jo_type
864 
865    type j_type
866       real             :: total
867       real             :: jb
868       real             :: jc
869       real             :: je
870       type (jo_type)   :: jo
871    end type j_type
872 
873    type cv_type
874       integer :: size        ! Total size of control variable.
875       integer :: size_jb     ! Size of CV array for Jb term.
876       integer :: size_je     ! Size of CV array for Je term.
877       integer :: size1c      ! Complex size of CV array of 1st variable error.
878       integer :: size2c      ! Complex size of CV array of 2nd variable error.
879       integer :: size3c      ! Complex size of CV array of 3rd variable error.
880       integer :: size4c      ! Complex size of CV array of 4th variable error.
881       integer :: size5c      ! Complex size of CV array of 5th variable error.
882       integer :: size_alphac ! Size of alpha control variable (complex).
883       integer :: size1       ! Size of CV array of 1st variable error.
884       integer :: size2       ! Size of CV array of 2nd variable error.
885       integer :: size3       ! Size of CV array of 3rd variable error.
886       integer :: size4       ! Size of CV array of 4th variable error.
887       integer :: size5       ! Size of CV array of 5th variable error.
888    end type cv_type
889 
890    type be_subtype
891       integer           :: mz          ! Vertical truncation of errors.
892       integer           :: max_wave    ! Global only - horizontal spectral truncation.
893       character*5       :: name        ! Variable name.
894       real, pointer     :: rf_alpha(:) ! RF scale length.
895       real, pointer     :: val(:,:)    ! Local Standard dev./sqrt(eigenvalue).
896       real, pointer     :: evec(:,:,:) ! Local Vertical eigenvectors.
897       real, pointer     :: val_g(:)    ! Global Standard dev./sqrt(eigenvalue).
898       real, pointer     :: evec_g(:,:) ! Global Vertical eigenvectors.
899       real, pointer     :: power(:,:)  ! Power spectrum
900    end type be_subtype
901 
902    type be_type
903       integer           :: ne
904       integer           :: max_wave           ! Smallest spectral mode (global).
905       integer           :: mix
906       integer           :: mjy
907       type (be_subtype) :: v1
908       type (be_subtype) :: v2
909       type (be_subtype) :: v3
910       type (be_subtype) :: v4
911       type (be_subtype) :: v5
912       type (be_subtype) :: alpha
913       real, pointer     :: pb_vert_reg(:,:,:)
914 
915       ! Control variable space errors:
916       type (cv_type)    :: cv
917 
918       real, pointer     :: reg_chi(:,:)
919       real, pointer     :: reg_t  (:,:,:)
920       real, pointer     :: reg_ps (:,:)
921    end type be_type
922 
923    ! Analysis_Stats maximum-minumum structure.
924 
925    type maxmin_field_type
926       real                         :: value
927       integer                      :: i, j
928    end type maxmin_field_type
929 
930 
931    ! vp_type is defined in the Registry
932    ! x_type  is defined in the Registry
933    ! The framework allocates the (local-grid) xa structure.
934    ! The framework allocates the (local-grid) xb structure.
935    ! The framework (de)allocates the vv structure.
936    ! The framework (de)allocates the vp structure.
937 
938 contains
939 
940 #include "da_allocate_background_errors.inc"
941 #include "da_allocate_observations.inc"
942 #include "da_allocate_y.inc"
943 #include "da_deallocate_background_errors.inc"
944 #include "da_deallocate_observations.inc"
945 #include "da_deallocate_y.inc"
946 #include "da_zero_x.inc"
947 #include "da_zero_vp_type.inc"
948 #include "da_initialize_cv.inc"
949 #include "da_gauss_noise.inc"
950 
951 end module da_define_structures
952