code by L. Girault and A.Gadel