Merge remote-tracking branch 'origin/release-v4.6.1'
[WRF.git] / var / da / da_radiance / da_read_simulated_rad.inc
blobf611e892dbac6143d2b5a60fffa7da7c25f3679f
1 subroutine da_read_simulated_rad (iv)
3    !---------------------------------------------------------------------------
4    !  Purpose: Generate simulated radiances for every model grid point and 
5    !           every channel
6    !
7    !  Called from 
8    !
9    !  HISTORY: 12/12/2008 - Creation                        Tom Auligne
10    !---------------------------------------------------------------------------
12    use da_control
14    implicit none
16    type (iv_type),  intent (inout) :: iv
18    ! Instrument triplet, follow the convension of RTTOV 
19    integer   :: platform_id, satellite_id, sensor_id
21    type (datalink_type) :: p
23    logical :: outside, outside_all
24    integer :: i,j,k,nchan,inst, alloc_stat
25    type(info_type)       ::  info
26    type(model_loc_type)  ::  loc
28    call da_trace_entry("da_read_simulated_rad")
30    ! Initialize variables
32    platform_id  = pseudo_rad_platid
33    satellite_id = pseudo_rad_satid
34    sensor_id    = pseudo_rad_senid
35    if (sensor_id == 0) then
36       nchan=19 !nchan_hirs
37    else if (sensor_id == 1) then
38       nchan=nchan_msu
39    else if (sensor_id == 3) then
40       nchan=nchan_amsua
41    else if (sensor_id == 4)  then
42       nchan=nchan_amsub
43    else if (sensor_id == 15)  then
44       nchan=nchan_mhs
45    else if (sensor_id == 10)  then
46       nchan=nchan_ssmis
47    else if (sensor_id == 11)  then
48       nchan=nchan_airs
49    end if
51    inst = 1    ! single instrument
53    iv%info(radiance)%ntotal    = (ide - ids + 1) * (jde - jds + 1)
54    iv%info(radiance)%nlocal    = (min(ipe+simulated_rad_ngrid,ide) - max(ips-simulated_rad_ngrid,ids) + 1) * &
55                                  (min(jpe+simulated_rad_ngrid,jde) - max(jps-simulated_rad_ngrid,jds) + 1)
56    iv%info(radiance)%ptotal(1) = iv%info(radiance)%ntotal
57    iv%instid(inst)%num_rad     = iv%info(radiance)%nlocal
58    iv%instid(inst)%info%nlocal = iv%info(radiance)%nlocal
60    !  5.0 allocate innovation radiance structure
61    !----------------------------------------------------------------  
62    
63    if ( iv%instid(inst)%num_rad > 0 ) then
65       call da_allocate_rad_iv(inst,nchan,iv)
67       !  6.0 assign sequential structure to innovation structure
68       !-------------------------------------------------------------
70       allocate (p%tb_inv(1:nchan), stat=alloc_stat)
71       if ( alloc_stat /= 0 ) CALL da_error(__FILE__,__LINE__,(/"error allocating"/))
73       p%info%date_char   = "0000-00-00_00:00:00"         
74       p%landsea_mask     = 1
75       p%scanpos          = 1
76       p%satzen           = 0.0
77       p%satazi           = 0.0
78       p%solzen           = 0.0
79       p%tb_inv(1:nchan)  = pseudo_rad_inv
80       p%sensor_index     = inst          
81       p%ifgat            = 1
82      
83       k = 0
84       do i = ids, ide
85          do j = jds, jde
86             if ((i<ips-simulated_rad_ngrid).or.(i>ipe+simulated_rad_ngrid).or. &
87                 (j<jps-simulated_rad_ngrid).or.(j>jpe+simulated_rad_ngrid)) cycle
88             k = k + 1
89             call da_xyll(map_info, i*1.0, j*1.0, p%info%lat, p%info%lon)
90             p%loc%x   = float(i)
91             p%loc%y   = float(j)
92             p%loc%i   = i
93             p%loc%j   = j
94             p%loc%dx  = 0.0
95             p%loc%dxm = 1.0
96             p%loc%dy  = 0.0
97             p%loc%dym = 1.0         
98             call da_initialize_rad_iv (inst, k, iv, p)
99          end do
100       end do
102       iv%instid(inst)%tb_error(:,:) = pseudo_rad_err
103       iv%instid(inst)%tb_qc(:,:)    = qc_good
105       deallocate(p%tb_inv)
106    end if
108       write(UNIT=stdout,FMT='(a,i3,2x,a,3x,i10)') &
109         'Allocating space for radiance innov structure', &
110          inst, iv%instid(inst)%rttovid_string, iv%instid(inst)%num_rad
112    call da_trace_exit("da_read_simulated_rad")
113    
115 end subroutine da_read_simulated_rad