27 CHARACTER (len=*),
PARAMETER ::
30 CHARACTER (len=*),
PARAMETER ::
33 CHARACTER (len=*),
PARAMETER ::
36 CHARACTER (len=*),
PARAMETER ::
49 REAL (rprec),
DIMENSION(:,:),
POINTER :: data_buffer => null()
52 REAL (rprec),
DIMENSION(:,:),
POINTER :: u_buffer => null()
54 REAL (rprec),
DIMENSION(:,:),
POINTER :: wvt_buffer => null()
58 INTEGER,
DIMENSION(:),
POINTER :: data_dim => null()
107 REAL (rprec),
DIMENSION(:,:),
INTENT(in) :: data_in
108 REAL (rprec),
INTENT(in) :: svd_cut_off
112 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: w_svd
113 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: svd_work
116 REAL (rprec) :: e_zero
125 IF (all(data_in .eq. 0.0))
THEN
136 IF (svd_cut_off .eq. 0.0)
THEN
142 ALLOCATE(svd_work(1))
143 ALLOCATE(w_svd(min(m,n)))
151 CALL dgesvd(
'All',
'All', m, n,
156 work_size = int(svd_work(1))
158 ALLOCATE(svd_work(work_size))
162 CALL dgesvd(
'All',
'All', m, n,
167 CALL assert_eq(0, status,
'dgesvd problem when compressing ' //
175 WHERE (w_svd .lt. 0.0)
182 e_zero = dot_product(w_svd, w_svd)
188 DO i = 1,
SIZE(w_svd)/2 + 1
189 e_r = e_r + w_svd(i)*w_svd(i)
191 IF ((1.0 - e_r/e_zero) .le. svd_cut_off)
THEN
225 e_r = work_size*m + work_size*n
263 & w_svd(1:work_size) *
293 INTEGER,
INTENT(in) :: ncid
294 CHARACTER (len=*),
INTENT(in) :: name
297 INTEGER,
DIMENSION(2) :: dim_lengths
307 IF (all(dim_lengths .gt. 0))
THEN
319 IF (all(dim_lengths .gt. 0))
THEN
326 CALL cdf_inquire(ncid,
360 TYPE (compression_class),
POINTER :: this
363 IF (
ASSOCIATED(this%data_buffer))
THEN
364 DEALLOCATE(this%data_buffer)
365 this%data_buffer => null()
368 IF (
ASSOCIATED(this%u_buffer))
THEN
369 DEALLOCATE(this%u_buffer)
370 this%u_buffer => null()
373 IF (
ASSOCIATED(this%wvt_buffer))
THEN
374 DEALLOCATE(this%wvt_buffer)
375 this%wvt_buffer => null()
403 IF (
ASSOCIATED(this%data_buffer))
THEN
405 ELSE IF (
ASSOCIATED(this%u_buffer))
THEN
407 ELSE IF (
ASSOCIATED(this%data_dim))
THEN
433 IF (
ASSOCIATED(this%data_buffer))
THEN
435 ELSE IF (
ASSOCIATED(this%u_buffer))
THEN
437 ELSE IF (
ASSOCIATED(this%data_dim))
THEN
463 TYPE (compression_class),
POINTER :: this
466 IF (
ASSOCIATED(this%data_buffer))
THEN
471 IF (
ASSOCIATED(this%data_dim))
THEN
473 ALLOCATE(this%data_buffer(this%data_dim(1),this%data_dim(2)))
474 this%data_buffer = 0.0
480 ALLOCATE(this%data_buffer(
SIZE(this%u_buffer, 1),
481 &
SIZE(this%wvt_buffer, 2)))
483 this%data_buffer = matmul(this%u_buffer, this%wvt_buffer)
500 TYPE (compression_class),
POINTER :: this
503 IF (
ASSOCIATED(this%data_dim) .or.
ASSOCIATED(this%u_buffer))
THEN
504 DEALLOCATE(this%data_buffer)
505 this%data_buffer => null()
529 TYPE (compression_class),
INTENT(in) :: this
530 INTEGER,
INTENT(in) :: ncid
531 CHARACTER (len=*),
INTENT(in) :: name
534 IF (
ASSOCIATED(this%data_buffer))
THEN
535 CALL cdf_define(ncid,
538 ELSE IF (
ASSOCIATED(this%u_buffer))
THEN
541 CALL cdf_define(ncid,
567 TYPE (compression_class),
INTENT(in) :: this
568 INTEGER,
INTENT(in) :: ncid
569 CHARACTER (len=*),
INTENT(in) :: name
572 IF (
ASSOCIATED(this%data_buffer))
THEN
578 ELSE IF (
ASSOCIATED(this%u_buffer))
THEN