Skip to content

Commit d399982

Browse files
committed
Inline harmonic analysis
Minor update to HA_solver
1 parent 9e0ca30 commit d399982

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

src/diagnostics/MOM_harmonic_analysis.F90

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -388,23 +388,16 @@ subroutine HA_solver(ha1, nc, FtF, x)
388388
type(HA_type), pointer, intent(in) :: ha1 !< Control structure for the current field
389389
integer, intent(in) :: nc !< Number of harmonic constituents
390390
real, dimension(:,:), intent(in) :: FtF !< Accumulator of (F' * F) for all fields [nondim]
391-
real, dimension(:,:,:), allocatable, intent(out) :: x !< Solution vector of harmonic constants [A]
391+
real, dimension(ha1%is:ha1%ie,ha1%js:ha1%je,2*nc+1), &
392+
intent(out) :: x !< Solution vector of harmonic constants [A]
392393

393394
! Local variables
394395
real :: tmp0 !< Temporary variable for Cholesky decomposition [nondim]
395-
real, dimension(:,:), allocatable :: L !< Lower triangular matrix of Cholesky decomposition [nondim]
396-
real, dimension(:), allocatable :: tmp1 !< Inverse of the diagonal entries of L [nondim]
397-
real, dimension(:,:), allocatable :: tmp2 !< 2D temporary array involving FtSSH [A]
398-
real, dimension(:,:,:), allocatable :: y !< 3D temporary array, i.e., L' * x [A]
399-
integer :: k, m, n, is, ie, js, je
400-
401-
is = ha1%is ; ie = ha1%ie ; js = ha1%js ; je = ha1%je
402-
403-
allocate(L(1:2*nc+1,1:2*nc+1), source=0.0)
404-
allocate(tmp1(1:2*nc+1), source=0.0)
405-
allocate(tmp2(is:ie,js:je), source=0.0)
406-
allocate(x(is:ie,js:je,2*nc+1), source=0.0)
407-
allocate(y(is:ie,js:je,2*nc+1), source=0.0)
396+
real, dimension(2*nc+1,2*nc+1) :: L !< Lower triangular matrix of Cholesky decomposition [nondim]
397+
real, dimension(2*nc+1) :: tmp1 !< Inverse of the diagonal entries of L [nondim]
398+
real, dimension(ha1%is:ha1%ie,ha1%js:ha1%je) :: tmp2 !< 2D temporary array involving FtSSH [A]
399+
real, dimension(ha1%is:ha1%ie,ha1%js:ha1%je,2*nc+1) :: y !< 3D temporary array, i.e., L' * x [A]
400+
integer :: k, m, n
408401

409402
! Cholesky decomposition
410403
do m=1,2*nc+1
@@ -445,11 +438,6 @@ subroutine HA_solver(ha1, nc, FtF, x)
445438
x(:,:,k) = (y(:,:,k) - tmp2(:,:)) * tmp1(k)
446439
enddo
447440

448-
deallocate(tmp1)
449-
deallocate(tmp2)
450-
deallocate(L)
451-
deallocate(y)
452-
453441
end subroutine HA_solver
454442

455443
!> \namespace harmonic_analysis

0 commit comments

Comments
 (0)