1 subroutine da_1d_eigendecomposition( bx, e, l, k )
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 integer, intent(in) :: k
13 real, dimension(k,k), intent(in) :: bx ! Global vert. background error.
14 real, dimension(k,k), intent(out) :: e ! Eigenvectors of Bx.
15 real, dimension(k), intent(out) :: l ! Global eigenvalues of Bx.
17 integer :: kz ! Size of 3rd dimension.
18 integer :: m ! Loop counters
19 integer :: work ! Size of work array.
20 integer :: info ! Info code.
22 real, allocatable :: ecopy(:,:)
23 real, allocatable :: lcopy(:)
24 real, allocatable :: work_array(:)
26 ! if (trace_use_dull) call da_trace_entry("da_1d_eigendecomposition")
28 !-------------------------------------------------------------------------
30 !-------------------------------------------------------------------------
34 !-------------------------------------------------------------------------
35 ! [5.0]: Perform global eigenvalue decomposition using LAPACK software:
36 !-------------------------------------------------------------------------
39 allocate( work_array(1:work) )
41 allocate( ecopy(1:kz,1:kz) )
42 allocate( lcopy(1:kz) )
48 call dsyev( 'V', 'U', kz, ecopy, kz, lcopy, &
49 work_array, work, info )
51 ! if ( info /= 0 ) then
52 ! write(unit=message(1),fmt='(A,I4,A)') &
53 ! ' da_1d_eigendecomposition: info = ', &
54 ! info,' - error in decomposition.'
55 ! call da_error(__FILE__,__LINE__,message(1:1))
58 !--Swap order of eigenvalues, vectors so 1st is one with most
63 e(1:kz,m) = ecopy(1:kz,kz+1-m)
66 deallocate (work_array)
70 ! if (trace_use_dull) call da_trace_exit("da_1d_eigendecomposition")
72 end subroutine da_1d_eigendecomposition