c*********************************************
c  zvrmpxdc5w.f  
c      draw multi-pixel planes for type-d data 
c      with subroutine zvrsubde32.f
c      ( men no kazu : 40x40x80)
c*********************************************
c
C  P V B  V x-y x-z heimen ni natteiru
C      earg2621.f  /EARTH/TEST261  OGNBB91  FILE NAME / MHD3CD / OGNBB91
C*     use subroutine sub3ahm.f (sub3ahm.o)
c      frt -O zvrmpxdc5w.f zvrsubde3.o
c*     long flow lines and contour lines
c
       PARAMETER (NX= 268,NY= 134,NZ= 134)
c
       PARAMETER (XXL= 80.00,YYL= 40.00,ZZL= 40.00)
       PARAMETER (NX2=NX+2,NY2=NY+2,NZ2=NZ+2)
       PARAMETER (KK=NX2*NY2)
       PARAMETER (KK2=KK*2)
       PARAMETER (ipx0=4)
c
c      parameter (tra=0.10,iviewp=100)
       parameter (tra=0.40,iviewp=100)
c      parameter (tra=0.15,iviewp=100)
c      parameter (tra=0.50,iviewp=100)
c      parameter (tra=0.75,iviewp=100)
c      parameter (tra=0.90,iviewp=100)
c       *** tra:transparency of pixel planes
c      parameter (ipnzx=40,icc=1)
c      parameter (ipnyz=80,icc=2)
c      parameter (ipnxy=40,icc=3)
c       *** ipn:number of planes 
c       *** icc:kind of planes(1:zx 2:yz 3:xy)
       parameter (ipnzx=40,ipnyz=80,ipnxy=40)
       parameter (myouso=4)
       
c      myouso:ewo kaku yousono bangou

       parameter (usecut=0)
c      box no itibudakewo kakutoki usecut=1
c      zenbu kakunara usecut=0

       parameter (nxbe=22,nxen=270,nybe=17,nyen=119,nzbe=17,nzen=119)
       
       DIMENSION U(KK2),F(NX2,NY2,NZ2,myouso)

       open(11,file='out.data',
     1         access='sequential',form='unformatted')

c *** each bottom points of simulation box 
       xb=-20
       yb=-yyl/2
       zb=-zzl/2
       
c *** byougasuru box no ookisa
       xxl2=xxl
       yyl2=yyl
       zzl2=zzl
c
       call initvrml
       call viewp(iviewp)
c
       itap=11
c *** file read ***
       DO 170 M=1,myouso
       DO 170 K=1,NZ2
        read(itap) F(1:nx2,1:ny2,k,m)
  170  CONTINUE
c *** end fileread ***
          
c *** vmax,vmin kettei
       if((myouso.eq.1).or.(myouso.eq.3))then
        vmax=0.00002
       else if((myouso.eq.2).or.(myouso.eq.4))then
        vmax=0.000005
       else
       	vmax=0.02
       end if

c ***  zettaitiwo tukawazu kaku toki ***
       if((myouso.ne.4).and.(myouso.ne.6))then
       	vmin=-vmax
       	ico=9
       else
c ***  zettaitiwo tukatte kaku toki(ecj and omegaperp) ***
        vmin=0
        ico=3
       end if
       
       write(10,*) '#vmin=',vmin,' vmax=',vmax,' myouso=',myouso
       write(*,*) '#vmin=',vmin,'vmax=',vmax,'m=',myouso
c *** vmax,vmin kettei owari
       
       if(usecut.eq.1)then
c ***  box no itibuwo kakutokino shori ***
        mxbe=nxbe
        mxen=nxen
        mybe=nybe
        myen=nyen
        mzbe=nzbe
        mzen=nzen
        
        mx=mxen-mxbe+1
        my=myen-mybe+1
        mz=mzen-mzbe+1
        
        ipnzx2=min(ipnzx,my)
        ipnyz2=min(ipnyz,mx)
        ipnxy2=min(ipnxy,mz)
        
        xb=xb+xxl*mxbe/nx2
        yb=yb+yyl*mybe/ny2
        zb=zb+zzl*mzbe/nz2
        
        xxl2=xxl*mx/nx2
        yyl2=yyl*my/ny2
        zzl2=zzl*mz/nz2
       else
        mxbe=1
        mybe=1
        mzbe=1
        mxen=nx2
        myen=ny2
        mzen=nz2
        mx=nx2
        my=ny2
        mz=nz2
        ipnzx2=ipnzx
        ipnyz2=ipnyz
        ipnxy2=ipnxy
       end if
       
c *** kokokara menwo kaku ***

       DO 100 icc=1,3
       
c *** zx heimenwo kaku shori ***
       if (icc.eq.1) then
        do 512 j=1,ipnzx2
         irmen=int(mybe+((my-1)*(j-1))/(ipnzx2-1))
         do 510 k=mzbe,mzen
          do 510 i=mxbe,mxen
           u((i-mxbe+1)+(k-mzbe)*mx)=F(i,irmen,k,myouso)
  510    continue
         zcc=yb+(j-1)*yyl2/(ipnzx2-1)
         call pixel1(mx,my,xb,zb,xxl2,zzl2,ipx0,ico,icc,zcc,vmin,vmax,
     1                 tra,u)
  512   continue

c *** yz heimenwo kaku shori ***
       else if (icc.eq.2) then
        do 522 i=1,ipnyz2
         irmen=int(mxbe+((mx-1)*(i-1))/(ipnyz2-1))
         do 520 j=mybe,myen
          do 520 k=mzbe,mzen
           u((k-mzbe+1)+(j-mybe)*mz)=F(irmen,j,k,myouso)
  520    continue
         zcc=xb+(i-1)*xxl2/(ipnyz2-1)
         call pixel1(my,mz,yb,zb,yyl2,zzl2,ipx0,ico,icc,zcc,vmin,vmax,
     1                 tra,u)
  522   continue

c *** xy heimenwo kaku shori ***
       else if (icc.eq.3) then
        do 532 k=1,ipnxy2
         irmen=int(mzbe+((mz-1)*(k-1))/(ipnxy2-1))
         do 530 j=mybe,myen
          do 530 i=mxbe,mxen
           u((i-mxbe+1)+(j-mybe)*mx)=F(I,J,irmen,myouso)
  530    continue
         zcc=zb+(k-1)*zzl2/(ipnxy2-1)
         call pixel1(mx,my,xb,yb,xxl2,yyl2,ipx0,ico,icc,zcc,vmin,vmax,
     1                tra,u)
  532   continue
       end if
  100  continue
    9  continue
       end
