1 subroutine da_setup_obs_structures_lightning( grid, ob, iv )
3 !-------------------------------------------------------------------------
4 ! Purpose: Define, allocate and read lightning observation structure.
5 ! Authors: Z Chen (zchen@fjnu.edu.cn), Jenny Sun (NCAR), X Qie (IAP)
6 !-------------------------------------------------------------------------
10 type (y_type), intent(out) :: ob ! Observation structure.
11 type (iv_type), intent(inout) :: iv ! O-B structure.
12 type (domain), intent(inout) :: grid ! First guess structure
14 character(len=filename_len) :: filename
16 integer :: istart,iend,jstart,jend
19 if (trace_use) call da_trace_entry("da_setup_obs_structures_lightning")
21 call init_constants_derived
23 !--------------------------------------------------------------------------
24 ! [1.0] Scan lightning observation header and get number of obs:
25 !--------------------------------------------------------------------------
26 if (num_fgat_time > 1) then
32 ! scan lightning observation file
33 write(filename(1:10), fmt='(a, i2.2, a)') 'ob', n,'.lightning'
34 call da_scan_obs_lightning(iv, filename, grid)
36 iv%info(lightning)%plocal(n) = iv%info(lightning)%nlocal
37 iv%info(lightning)%ptotal(n) = iv%info(lightning)%ntotal
41 ! scan main body of lightning observation file
42 call da_scan_obs_lightning(iv, 'ob.lightning', grid)
43 iv%info(lightning)%plocal(iv%time) = iv%info(lightning)%nlocal
44 iv%info(lightning)%ptotal(iv%time) = iv%info(lightning)%ntotal
47 !--------------------------------------------------------------------------
48 ! Allocate based on input number of obs:
49 !--------------------------------------------------------------------------
50 ! This logic was originally found in da_allocate_observations; moved here
51 if (iv%info(lightning)%nlocal > 0) allocate(iv%lightning (1:iv%info(lightning)%nlocal))
52 if (iv%info(lightning)%nlocal > 0) then
53 allocate (iv%info(lightning)%name(iv%info(lightning)%nlocal))
54 allocate (iv%info(lightning)%platform(iv%info(lightning)%nlocal))
55 allocate (iv%info(lightning)%id(iv%info(lightning)%nlocal))
56 allocate (iv%info(lightning)%date_char(iv%info(lightning)%nlocal))
57 allocate (iv%info(lightning)%levels(iv%info(lightning)%nlocal))
58 allocate (iv%info(lightning)%lat(iv%info(lightning)%max_lev,iv%info(lightning)%nlocal))
59 allocate (iv%info(lightning)%lon(iv%info(lightning)%max_lev,iv%info(lightning)%nlocal))
60 allocate (iv%info(lightning)%elv(iv%info(lightning)%nlocal))
61 allocate (iv%info(lightning)%pstar(iv%info(lightning)%nlocal))
63 allocate (iv%info(lightning)%slp(iv%info(lightning)%nlocal))
64 allocate (iv%info(lightning)%pw(iv%info(lightning)%nlocal))
66 allocate (iv%info(lightning)%x (kms:kme,iv%info(lightning)%nlocal))
67 allocate (iv%info(lightning)%y (kms:kme,iv%info(lightning)%nlocal))
68 allocate (iv%info(lightning)%i (kms:kme,iv%info(lightning)%nlocal))
69 allocate (iv%info(lightning)%j (kms:kme,iv%info(lightning)%nlocal))
70 allocate (iv%info(lightning)%dx (kms:kme,iv%info(lightning)%nlocal))
71 allocate (iv%info(lightning)%dxm(kms:kme,iv%info(lightning)%nlocal))
72 allocate (iv%info(lightning)%dy (kms:kme,iv%info(lightning)%nlocal))
73 allocate (iv%info(lightning)%dym(kms:kme,iv%info(lightning)%nlocal))
74 allocate (iv%info(lightning)%k (iv%info(lightning)%max_lev,iv%info(lightning)%nlocal))
75 allocate (iv%info(lightning)%dz (iv%info(lightning)%max_lev,iv%info(lightning)%nlocal))
76 allocate (iv%info(lightning)%dzm(iv%info(lightning)%max_lev,iv%info(lightning)%nlocal))
77 allocate (iv%info(lightning)%zk (iv%info(lightning)%max_lev,iv%info(lightning)%nlocal))
78 allocate (iv%info(lightning)%proc_domain(iv%info(lightning)%max_lev,iv%info(lightning)%nlocal))
79 allocate (iv%info(lightning)%obs_global_index(iv%info(lightning)%nlocal))
80 allocate (iv%info(lightning)%thinned(iv%info(lightning)%max_lev,iv%info(lightning)%nlocal))
82 iv%info(lightning)%proc_domain(:,:) = .false.
83 iv%info(lightning)%thinned(:,:) = .false.
84 iv%info(lightning)%zk(:,:) = missing_r
87 if (num_fgat_time > 1) then
93 ! read lightning observation file
94 write(filename(1:10), fmt='(a, i2.2, a)') 'ob', n,'.lightning'
95 call da_read_obs_lightning(iv, filename, grid)
101 ! read lightning observation file
102 call da_read_obs_lightning(iv, 'ob.lightning', grid)
105 !--------------------------------------------------------------------------
106 ! [3.0] Calculate innovation vector (O-B) and create (smaller) ob structure:
107 !--------------------------------------------------------------------------
109 call da_fill_obs_structures_lightning(iv, ob)
113 if (trace_use) call da_trace_exit("da_setup_obs_structures_lightning")
114 end subroutine da_setup_obs_structures_lightning