da_initialize_h.inc

References to this file elsewhere.
1 subroutine da_initialize_h(ni, nj, max_wavenumber, lensav, alp_size, &
2                             wsave, lon, sinlon, coslon, lat, sinlat, coslat, &
3                             int_wgts, alp)
4 
5    !-----------------------------------------------------------------------
6    ! Purpose: TBD
7    !-----------------------------------------------------------------------
8 
9    implicit none
10 
11    integer, intent(in) :: ni                         ! Number of longitudes.
12    integer, intent(in) :: nj                         ! Number of latitudes.
13    integer, intent(in) :: max_wavenumber             ! Smallest scale required (ni/2 - 1).
14    integer, intent(in) :: lensav                     ! Size of FFTs wsave array.
15    integer, intent(in):: alp_size                   ! Size of ALP array.
16    real, intent(out)   :: wsave(1:lensav)            ! Primes for FFT.
17    real, intent(out)   :: lon(1:ni)                  ! Longitude (radians).
18    real, intent(out)   :: sinlon(1:ni)               ! sine(longitude).
19    real, intent(out)   :: coslon(1:ni)               ! cosine(longitude).
20    real, intent(out)   :: lat(1:nj)                  ! Latitude (radians, from south).
21    real, intent(out)   :: sinlat(1:nj)               ! sine(latitude).
22    real, intent(out)   :: coslat(1:nj)               ! cosine(latitude).
23    real, intent(out)   :: int_wgts(1:nj)             ! Legendre integration weights.
24    real, intent(out)   :: alp(1:alp_size)            ! Associated Legendre Polynomial.
25 
26    integer             :: i                          ! Loop counters.
27 
28    !----------------------------------------------------------------------------
29    ! [1] Initialize FFT coefficients.'
30    !----------------------------------------------------------------------------
31 
32    wsave(:) = 0.0
33 #ifdef FFTPACK
34    call rfft1i(ni, wsave, lensav, ierr)
35 #else
36    call da_error(__FILE__,__LINE__,(/"Needs to be compiled with FFTPACK"/))
37 #endif
38 
39    if (ierr /= 0) then
40      write(unit=message(1),fmt='(A,I4)') &
41         "Fourier initialization failed. ierr = ", ierr
42      call da_error(__FILE__,__LINE__,message(1:1))
43    end if
44 
45    !----------------------------------------------------------------------------
46    ! [2] Calculate latitudes, and their sines/cosines.'
47    !---------------------------------------------------------------------------
48  
49    if (gaussian_lats) then
50       call da_get_gausslats(nj, lat, int_wgts, sinlat, coslat)
51    else
52       call da_get_reglats(nj, lat, sinlat, coslat, int_wgts)
53    end if
54 
55    do i = 1, ni
56       lon(i) = 2.0 * pi / real(ni) * real(i - 1)
57       sinlon(i) = sin(lon(i))
58       coslon(i) = cos(lon(i))
59    end do
60 
61    !----------------------------------------------------------------------------
62    ! [3] Initialize Legendre coefficients.'
63    !----------------------------------------------------------------------------
64 
65    call da_setlegpol(nj, max_wavenumber, alp_size, sinlat, coslat, alp)
66 
67 end subroutine da_initialize_h
68 
69