FV3 Bundle
FtnTriDiagSpectrum.F90
Go to the documentation of this file.
1 ! (C) Copyright 2009-2016 ECMWF.
2 !
3 ! This software is licensed under the terms of the Apache Licence Version 2.0
4 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5 ! In applying this licence, ECMWF does not waive the privileges and immunities
6 ! granted to it by virtue of its status as an intergovernmental organisation nor
7 ! does it submit to any jurisdiction.
8 
9 !> Interfaces to be called from C++ for Fortran computation of eigenvalues
10 !> and eigenvectors of symetric tri-diagonal matrix.
11 
12 ! ------------------------------------------------------------------------------
13 
14 subroutine tridiagev(nn, diag, subd, eval, evec) bind(c,name='FtnTriDiagSpectrum')
15 
16 use iso_c_binding
17 use kinds
18 
19 implicit none
20 integer(c_int), intent(in) :: nn !< Size of matrix
21 real(c_double), intent(in) :: diag(nn) !< Diagonal elements
22 real(c_double), intent(in) :: subd(nn-1) !< Sub-diagonal elements
23 real(c_double), intent(inout) :: eval(nn) !< Eigenvalues
24 real(c_double), intent(inout) :: evec(nn,nn) !< Eigenvectors
25 
26 real(kind=kind_real) :: zdiag(nn)
27 real(kind=kind_real) :: zsubd(nn-1)
28 real(kind=kind_real) :: zvecs(nn, nn)
29 real(kind=kind_real) :: zwork(2*nn)
30 integer :: ii, info
31 
32 ii = nn
33 zdiag(:) = diag(:)
34 zsubd(:) = subd(:)
35 
36 call dsteqr('I', ii, zdiag, zsubd, zvecs, ii, zwork, info)
37 
38 if (info/=0) call abor1_ftn("tridiagev: Error in dsteqr")
39 
40 eval(:) = zdiag(:)
41 evec(:,:) = zvecs(:,:)
42 
43 end subroutine tridiagev
44 
45 ! ------------------------------------------------------------------------------
46 
subroutine tridiagev(nn, diag, subd, eval, evec)
Interfaces to be called from C++ for Fortran computation of eigenvalues and eigenvectors of symetric ...