         subroutine replo1(npo,xnorm, v1,v2,ichoix,IERR)
c .......................................................
c     npo   : nombre de points a considerer
c     xnorm : tableau des normales pour  les points de l'element
c             xnorm(3,npo)
c     v1,v2 : repere local, rempli element/element
c             attention el isoparametrique noeuds et points coincident!
c ......................................................
c
      dimension ip(3)
      character*100 IERR
      double precision xnorm(3,npo),v1(3,npo),v2(3,npo), delta,e(3)
      data ip /2,3,1/
      data ipas/0/
      save ipas
      do 1 n = 1,npo
          if (ichoix .ge. 0) then

c            ---------------------------------------------------
c
c            choix regularise
c
c            ---------------------------------------------------
c            ^ vectoriel
c            e= x au depart
c
             e(1) = 1.
             e(2) = 0.
             e(3) = 0.

          else if (ichoix .eq. -1) then
c
c            e = x
c
             e(1) = 1.
             e(2) = 0.
             e(3) = 0. 

          else if (ichoix .eq. -2) then
c
c            e = y
c
             e(1) = 0.
             e(2) = 1.
             e(3) = 0. 

          else if (ichoix .eq. -3) then
c
c            e = z
c
             e(1) = 0.
             e(2) = 0.
             e(3) = 1. 
          endif
c
 102      v1(1,n) = xnorm(2,n)*e(3)-xnorm(3,n)*e(2)
          v1(2,n) = -xnorm(1,n)*e(3)+xnorm(3,n)*e(1)
          v1(3,n) = xnorm(1,n)*e(2)-xnorm(2,n)*e(1)
c
          delta =  sqrt(v1(1,n)**2+v1(2,n)**2+v1(3,n)**2)
c
c         verifier que v1 n est pas nul (e//n)
c
          if (delta .le. 0.001) then
c         mise en commentaire suite a l'utilisation de mexWarnMsgTxt
c             if (ipas.eq.0) print 100,n,e(1),e(2),e(3)
c 100         format( 'attention noeud local : ',i2,' direction ',
c     *       3(e8.2,1x), 'parallele a la normale ')
 100         call mexPrintf('attention direction parallele normale')
             do 101 i = 1,3
                if (e(i) .ne. 0.) then
                    e(i)     = 0
                    e(ip(i)) = 1
c         mise en commentaire suite a l'utilisation de mexWarnMsgTxt
c                     if (ipas.eq.0) print 110, ip(i)
c 110                format(' nouvel axe privilegie e_',i1)
 110                call mexPrintf(' nouvel axe privilegie e_')
                    go to 102
                 endif
 101         continue
             ipas=ipas+1
          endif
          v1(1,n) = v1(1,n)/delta
          v1(2,n) = v1(2,n)/delta
          v1(3,n) = v1(3,n)/delta
c         ---------------------------------------------------
c
c         calculer v2 = n^v1
c
          v2(1,n) = xnorm(2,n)*v1(3,n) -  xnorm(3,n)*v1(2,n)
          v2(2,n) = xnorm(3,n)*v1(1,n) -  xnorm(1,n)*v1(3,n)
          v2(3,n) = xnorm(1,n)*v1(2,n) -  xnorm(2,n)*v1(1,n)
          delta =  sqrt(v2(1,n)**2+v2(2,n)**2+v2(3,n)**2)
c
          v2(1,n) = v2(1,n)/delta
          v2(2,n) = v2(2,n)/delta
          v2(3,n) = v2(3,n)/delta

 1    continue
      end
