module triangle1 { # triangle smoothing
  use helicon
  use polydiv
  logical, parameter, private             :: T = .true., F = .false.
  type( filter),      private             :: aa, bb
  real,    dimension (ndat), allocatable  :: tmp1, tmp2
#%_init (nbox,ndat)
   integer nbox, ndat
   call allocatehelix( aa, 1)
   call allocatehelix( bb, 1)
   aa%flt = -1.;   aa%lag = nbox
   bb%flt = -1.;   bb%lag = 1
   call helicon_init( aa)
   call polydiv_init(ndat, bb)
#%_lop (mod, dat)
   integer stat1, stat2
    if (adj) {
       stat1 = helicon_lop (T, F, tmp1, dat)
       stat2 = polydiv_lop (T, F, tmp2, tmp1)
       stat2 = polydiv_lop (F, F, tmp2, tmp1)
       stat1 = helicon_lop (F, T, tmp1, mod)
    } else {
       stat1 = helicon_lop (T, F, tmp1, mod)
       stat2 = polydiv_lop (T, F, tmp2, tmp1)
       stat2 = polydiv_lop (F, F, tmp2, tmp1)
       stat1 = helicon_lop (F, T, tmp1, dat)
    }
#%_close 
   call deallocatehelix( aa)
   call deallocatehelix( bb)
   call polydiv_close()
}


