da_rescale_background_errors.inc

References to this file elsewhere.
1 subroutine da_rescale_background_errors (var_scaling, len_scaling, &
2                                           ds, s, be_sub)
3 
4    !---------------------------------------------------------------------------
5    ! Purpose: Rescale wrfvar background errors.
6    !
7    ! Method:  Empirical scaling and inclusion of recursive filter rescaling.
8    !---------------------------------------------------------------------------
9 
10    implicit none
11 
12    real, intent(in)                 :: var_scaling       ! Variance factor.
13    real, intent(in)                 :: len_scaling       ! Lengthscale factor.
14    real, intent(in)                 :: ds                ! Resolution (m)
15    real, intent(inout)              :: s(:)              ! RF lengthscale.
16    type (be_subtype), intent(inout) :: be_sub            ! Backgrd error struct.
17     
18    integer                          :: mz                ! Vertical truncation.
19    integer                          :: m
20    real, allocatable                :: rf_scale_factor(:)! RF rescaling.
21 
22    if (trace_use_dull) call da_trace_entry("da_rescale_background_errors")
23 
24    !--------------------------------------------------------------------------
25    ! [1.0] Initialise:
26    !--------------------------------------------------------------------------
27 
28    mz = be_sub % mz
29 
30    !--------------------------------------------------------------------------
31    ! [2.0] Perform various rescalings:
32    !--------------------------------------------------------------------------
33 
34    if (mz > 0) then
35 
36       ! [2.1] Empirical rescaling of lengthscales:
37       s(1:mz) = len_scaling * s(1:mz)
38    
39       if (print_detail_be) then
40          write(unit=stdout,fmt='(a,a)')trim(be_sub % name), ' Error Lengthscales (m):'
41          do m = 1, mz
42             write(unit=stdout,fmt='(a,i4,1pe13.5)')be_sub % name, m, s(m)
43          end do
44       end if
45       
46       ! [2.2] Make lengthscale nondimensional:
47       s(1:mz) = s(1:mz) / ds
48 
49       ! [2.3] Empirical rescaling of variances:
50       be_sub % val(:,:) = var_scaling * be_sub % val(:,:)
51 
52       ! Calculate recursive filter rescaling:
53 
54       allocate(rf_scale_factor(1:mz))
55 
56       call da_calculate_rf_factors(s(:), be_sub % rf_alpha(:), &
57                                     rf_scale_factor(:))
58 
59       do m = 1, mz
60          be_sub % val(:,m) = rf_scale_factor(m) * be_sub % val(:,m)
61       end do
62                                        
63       deallocate (rf_scale_factor)   
64 
65    end if
66 
67    if (trace_use_dull) call da_trace_exit("da_rescale_background_errors")
68 
69 end subroutine da_rescale_background_errors
70 
71