!=========================================================================
! 一次元トレーサー移流モデル: dcl-5.0.1 モジュール
!
! 履歴	1997/10/16	小高正嗣
!	1997/10/22	小高正嗣
!	1997/11/18	小高正嗣
!=========================================================================
MODULE dcl_module
USE param_module
PUBLIC dennou_set,dennou_draw,dennou_cls

	CONTAINS
!=========================================================================
SUBROUTINE dennou_set

	CALL SGLSET( 'LCORNER', .FALSE. )
	CALL SWISET( 'IPOSX', 50 )
	CALL SWISET( 'IPOSY', 50 )
      	CALL SWLSET( 'LALT', .TRUE. )
      	CALL SWLSET( 'LWAIT', .FALSE. )
	CALL SGOPN( 1 )
	CALL SLDIV( 'Y', 2, 2 )

END SUBROUTINE dennou_set
!=========================================================================
SUBROUTINE dennou_draw( xplot, yplot, vplot, header )

	REAL,DIMENSION(:),INTENT(in)	:: xplot
	REAL,DIMENSION(:),INTENT(in)	:: yplot
	REAL,DIMENSION(:,:),INTENT(in)	:: vplot
	CHARACTER(LEN=9),INTENT(in)	:: header
	INTEGER				:: xdim, ydim

	REAL,PARAMETER :: VXMIN=-0.5, VXMAX=0.5, &
       &	          VYMIN=-0.5, VYMAX=0.5, &
       &                  VZMIN=-0.2, VZMAX=0.2 
	REAL,PARAMETER :: XVP3=-2.5, YVP3=-1., ZVP3=1.5
	REAL,PARAMETER :: XFC3=0.0,  YFC3=0.0, ZFC3=0.0

	REAL,PARAMETER :: ZMIN=-1.0, ZMAX=4.0
	REAL,DIMENSION(3) :: xp(3),yp(3),zp(3)

	xdim = SIZE(xplot)
	ydim = SIZE(yplot)

!-- X-Y PLAIN ----

	CALL SGFRM
	CALL SGSWND(  XMIN,  XMAX,  YMIN,  YMAX )
	CALL SGSVPT( VXMIN, VXMAX, VYMIN, VYMAX )
	CALL SGSTRN( 1 )
	CALL SGSTRF

	CALL SCSPLN( 1, 2, VZMIN)
	CALL SCSEYE( XVP3, YVP3, ZVP3 )
	CALL SCSOBJ( XFC3, YFC3, ZFC3 )
	CALL SCSPRJ

	CALL UXAXDV( 'B', 0.02, 0.1 )
	CALL UXAXDV( 'T', 0.02, 0.1 )
	CALL UXSTTL( 'B', 'X', 0. )
	CALL UYAXDV( 'L', 0.02, 0.1 )
	CALL UYAXDV( 'R', 0.02, 0.1 )
	CALL UYSTTL( 'L', 'Y', 0. )

!-- X-Z PLAIN ----

	CALL SGSWND(  XMIN,  XMAX,  ZMIN,  ZMAX )
	CALL SGSVPT( VXMIN, VXMAX, VZMIN, VZMAX )
	CALL SGSTRN( 1 )
	CALL SGSTRF

	CALL SCSPLN( 1, 3, VYMAX)
	CALL SCSPRJ

	CALL UZINIT
	CALL UXAXDV( 'T', 0.02, 0.1 )
	CALL UZLSET( 'LABELXB', .FALSE. )
	CALL UXAXDV( 'B', 0.02, 0.1 )
	CALL UYAXDV( 'L', 0.2, 1.0 )
	CALL UYAXDV( 'R', 0.2, 1.0 )
	CALL UYSTTL( 'L', 'AMPLITUDE', 0. )

!-- Y-Z PLAIN ----

	CALL SGSWND(  YMIN,  YMAX,  ZMIN,  ZMAX )
	CALL SGSVPT( VYMIN, VYMAX, VZMIN, VZMAX )
	CALL SGSTRN( 1 )
	CALL SGSTRF

	CALL SCSPLN( 2, 3, VXMAX)
	CALL SCSPRJ

	CALL UZINIT
	CALL UXAXDV( 'T', 0.02, 0.1 )
	CALL UXAXDV( 'B', 0.02, 0.1 )
	CALL UZLSET( 'LABELYL', .FALSE. )
	CALL UYAXDV( 'L', 0.2, 1.0 )
	CALL UYAXDV( 'R', 0.2, 1.0 )

!---------------- 3-D ------------------

	CALL SCSVPT(VXMIN, VXMAX, VYMIN, VYMAX, VZMIN, VZMAX)
	CALL SCSWND( XMIN,  XMAX,  YMIN,  YMAX,  ZMIN,  ZMAX)
	CALL SCSLOG(.FALSE., .FALSE., .FALSE.)
	CALL SCSTRN(1)
	CALL SCSTRF

	CALL SZL3OP(1)

	DO J=ydim-1, 1, -1
	  DO I=xdim-1, 1, -1
	     XP(1) = xplot(I)
	     YP(1) = yplot(J)
	     ZP(1) = vplot(I,J)
	     XP(2) = xplot(I)
	     YP(2) = yplot(J+1)
	     ZP(2) = vplot(I,J+1)
	     XP(3) = xplot(I+1)
	     YP(3) = yplot(J+1)
	     ZP(3) = vplot(I+1,J+1)

	     CALL SZL3ZU(3, XP, YP, ZP)

	     XP(1) = xplot(I+1)
	     YP(1) = yplot(J+1)
	     ZP(1) = vplot(I+1,J+1)
	     XP(2) = xplot(I+1)
	     YP(2) = yplot(J)
	     ZP(2) = vplot(I+1,J)
	     XP(3) = xplot(I)
	     YP(3) = yplot(J)
	     ZP(3) = vplot(I,J)

	     CALL SZL3ZU(3, XP, YP, ZP)
	   END DO
	END DO
	
	CALL SZL3CL

END SUBROUTINE dennou_draw
!=========================================================================
SUBROUTINE dennou_cls

	CALL SGCLS

END SUBROUTINE dennou_cls
!=========================================================================
END MODULE dcl_module
