1 subroutine da_1d_eigendecomposition( bx, e, l )
3 !------------------------------------------------------------------------------
4 ! Purpose: Compute eigenvectors E and eigenvalues L of vertical covariance matrix
5 ! B_{x} defined by equation: E^{T} B_{x} E = L, given input 3D field of
6 ! errors (sum over all horizontal locations).
7 !------------------------------------------------------------------------------
11 real, intent(in) :: bx(:,:) ! Global vert. background error.
13 real, intent(out) :: e(:,:) ! Eigenvectors of Bx.
14 real, intent(out) :: l(:) ! Global eigenvalues of Bx.
16 integer :: kz ! Size of 3rd dimension.
17 integer :: m ! Loop counters
18 integer :: work ! Size of work array.
19 integer :: info ! Info code.
21 real*8, allocatable :: ecopy(:,:)
22 real*8, allocatable :: lcopy(:)
23 real*8, allocatable :: work_array(:)
25 if (trace_use_dull) call da_trace_entry("da_1d_eigendecomposition")
27 !-------------------------------------------------------------------------
29 !-------------------------------------------------------------------------
33 !-------------------------------------------------------------------------
34 ! [5.0]: Perform global eigenvalue decomposition using LAPACK software:
35 !-------------------------------------------------------------------------
38 allocate( work_array(1:work) )
40 allocate( ecopy(1:kz,1:kz) )
41 allocate( lcopy(1:kz) )
47 call dsyev( 'V', 'U', kz, ecopy, kz, lcopy, &
48 work_array, work, info )
51 write(unit=message(1),fmt='(A,I4,A)') &
52 ' da_1d_eigendecomposition: info = ', &
53 info,' - error in decomposition.'
54 call da_error(__FILE__,__LINE__,message(1:1))
57 !--Swap order of eigenvalues, vectors so 1st is one with most
62 e(1:kz,m) = ecopy(1:kz,kz+1-m)
65 deallocate (work_array)
69 if (trace_use_dull) call da_trace_exit("da_1d_eigendecomposition")
71 end subroutine da_1d_eigendecomposition