@@ -35,13 +35,16 @@ subroutine ngfilter(yt, ymiss, timevar, zt, tt, rtv, qt, a1, p1,p1inf, u, theta,
3535 double precision , intent (inout ), dimension ((p-1 )* smoothy+1 ,(p-1 )* smoothy+1 ,(n-1 )* smoothy+1 ) :: yvar
3636 double precision , intent (inout ), dimension ((p-1 )* smooths+1 ,(n-1 )* smooths+1 ) :: thetahat
3737 double precision , intent (inout ), dimension ((p-1 )* smooths+1 ,(p-1 )* smooths+1 ,(n-1 )* smooths+1 ) :: thetavar
38- double precision , dimension (smootha* m+ (1 - smootha)* p,n,4 * nsim) :: sim
39- double precision , dimension (smootha* p+ (1 - smootha),n,4 * nsim* smootha+ (1 - smootha)) :: osim
40- double precision , dimension (n,4 * nsim) :: w
4138 double precision , dimension (p,m) :: pm
42- double precision , external :: ddot
39+ double precision , dimension (:,:,:), allocatable :: sim
40+ double precision , dimension (:,:,:), allocatable :: osim
41+ double precision , dimension (:,:), allocatable :: w
4342
43+ double precision , external :: ddot
4444 external isamplefilter, covmeanwprotect, dgemv, dsymm, dgemm, covmeanw
45+
46+ allocate (w(n,4 * nsim))
47+ allocate (sim(smootha* m+ (1 - smootha)* p,n,4 * nsim))
4548
4649 if (smootha.EQ. 1 ) then
4750
@@ -67,6 +70,7 @@ subroutine ngfilter(yt, ymiss, timevar, zt, tt, rtv, qt, a1, p1,p1inf, u, theta,
6770 end if
6871
6972 if (smoothy.EQ. 1 ) then
73+ allocate (osim(smootha* p+ (1 - smootha),n,4 * nsim* smootha+ (1 - smootha)))
7074 do t = 1 , n
7175 do j = 1 ,p
7276 call dgemv(' t' ,m,4 * nsim,1.0d0 ,sim(:,t,:),m,zt(j,:,(t-1 )* timevar(1 )+ 1 ),1 ,0.0d0 ,osim(j,t,:),1 )
@@ -90,6 +94,7 @@ subroutine ngfilter(yt, ymiss, timevar, zt, tt, rtv, qt, a1, p1,p1inf, u, theta,
9094 do t= 1 ,n
9195 call covmeanw(osim(:,t,:),w(t,:),p,1 ,4 * nsim,yhat(:,t),yvar(:,:,t))
9296 end do
97+ deallocate (osim)
9398 end if
9499 else
95100 call isamplefilter(yt, ymiss, timevar, zt, tt, rtv, qt, a1, p1,p1inf, u, dist, &
@@ -129,6 +134,7 @@ subroutine ngfilter(yt, ymiss, timevar, zt, tt, rtv, qt, a1, p1,p1inf, u, theta,
129134 call covmeanw(sim(:,t,:),w(t,:),p,1 ,4 * nsim,yhat(:,t),yvar(:,:,t))
130135 end do
131136 end if
132-
133137 end if
138+ deallocate (sim)
139+ deallocate (w)
134140end subroutine ngfilter
0 commit comments