!=====================================================================
! NGST: Streamlines, A Field Flow Visualization Utility
!=====================================================================
!
! STREAMLINES, designed to allow a user to plot a streamline
! representation of field flow given two arrays containing the
! components of the field vectors on a uniform grid in a user-defined
! coordinate system.
!
! ~~~~~~~~~~~~~~~~~~~~~~~~~~~
! set/Get internal parameters
! ~~~~~~~~~~~~~~~~~~~~~~~~~~~
!
! NG_STRSET to reset all parameters to their default values.
!
! NG_STSETC to give a value of type CHARACTER to a parameter.
! NG_STSETI to give a value of type INTEGER to a parameter.
! NG_STSETR to give a value of type REAL to a parameter.
!
! NG_STGETC to get a value of type CHARACTER.
! NG_STGETI to get a value of type INTEGER.
! NG_STGETR to get a value of type REAL.
!
! NG_STGETMAPINFO to get information from the mapping common data
! available to the user subroutines STUMXY, STUIXY,
! and STUMTA
!
! ~~~~~~~~~~~~~~~~
! Working Routines
! ~~~~~~~~~~~~~~~~
!
! NG_STINIT to perform the initialization
!
! NG_STREAM to render the streamline field flow plot
!
! NG_STUMSL, Example version of user masked drawing program
!
! ~~~~~~~~~~~~~~~~
! Obsolete Entries
! ~~~~~~~~~~~~~~~~
!
! NG_EZSTRM to plot a streamline field in a single call.
!
! NG_STRMLN to plot a streamline field in a single call.
!
!---------------------------------------
!
! Note: CNCARG adding three "optional dummy subprogram arguments",
! STUMXY, STUIXY, and, STUMTA,
! to the STREAMLINES routine:
!
! NG_STREAM( U, V, P, IAM, STUMSL, WRK, STUMXY, STUIXY, STUMTA, ver423 )
!
! add optional "ver423" (to solve trouble in examples STEX01 and FFEX04)
!
!---------------------------------------------------------------------
! Parameter Brief description Fortran type
!---------------------------------------------------------------------
! AGD Arrow GriD increment Integer
! ARL ARrow head Length Real
! CDS Critical DiSplacement Real
! CKP ChecK Progress count Integer
! CKX ChecK (X) crossover count Integer
! CYK CYclical data flag Integer
! CPM ComPatibility Mode Integer
! DFM DiFferential Magnitude Real
! LWD Streamline Line WiDth Real
! MAP MAP transformation code Integer
! MSK MaSK to area map flag Integer
! PLR PoLaR input mode Integer
! SET SET call flag Integer
! SGD Stream starting GriD Integer
! SSP Streamline SPacing value Real
! SST Streamline STatistics output Integer
! SVF Special Value Flag Integer
! TRP InTeRPolation method Integer
! TRT TRansformation Type Integer
! USV U array Special Value Real
! VNL Vector NormaLization value Real
! VPB ViewPort Bottom Real
! VPL ViewPort Left Real
! VPR ViewPort Right Real
! VPS ViewPort Shape Real
! VPT ViewPort Top Real
! VSV V array Special Value Real
! WDB WinDow Bottom Real
! WDL WinDow Left Real
! WDR WinDow Right Real
! WDT WinDow Top Real
! XC1 X Coordinate at index 1 Real
! XCM X Coordinate at index M Real
! YC1 Y Coordinate at index 1 Real
! YCN Y Coordinate at index N Real
!=====================================================================
! Refer "NCAR menu" for interfacing STREAMLINES in detail
!=====================================================================
!=====================================================================
! STLINE: Old version of NG Streamlines Package (revised by chiangtp)
!=====================================================================
!
! SUBROUTINE NG_STLRST() ! reset parameters to its default
!
! SUBROUTINE NG_STLSET( INITA , INITB , AROWL , AROWB ,&
! ICODE , ITERP , ITERC , IGFLG ,&
! IMSG , UVMSG , ICYC , &
! DISPL , DISPC , CSTOP , &
! ArrowHeadOnly )
!
! SUBROUTINE NG_STLGET( INITA , INITB , AROWL , AROWB ,&
! ICODE , ITERP , ITERC , IGFLG ,&
! IMSG , UVMSG , ICYC , &
! DISPL , DISPC , CSTOP , &
! ArrowHeadOnly )
!
! SUBROUTINE NG_STLINE( VP, U, V, NX, NY )
!
!---------------------------------------------------------------------
!
! SUBROUTINE NG_STLINE( VP, U, V, NX, NY )
!
! Routine to draw a streamline representation of the flow field.
! the representation is independent of the flow speed.
!
! Variables :
!
! VP : REAL, with dimension (4)
! The viewport, in fractional coordinate, of streamlines plot
! Array elements ordered as (/xl, xr, yb, yt/)
!
! U : REAL, with dimension (NX,NY), INTENT(IN)
! The two dimensional array containing the X-dir velocity.
!
! V : REAL, with dimension (NX,NY), INTENT(IN)
! The two dimensional array containing the Y-dir velocity.
! the vector at the point (I,J) has magnitude
! SQRT( U(I,J)**2 + V(I,J)**2 ) and direction
! ATAN2( V(I,J), U(I,J) ).
!
! NX : INTEGER, INTENT(IN)
! The number of data values to be plotted in the X-direction
! (the first subscript direction).
!
! NY : INTEGER, INTENT(IN)
! the number of data values to be plotted in the Y-direction
! (the second subscript direction).
!
! Notes :
!
! 1) when the routine is called with ICYC.NE.0 and the data are not
! cyclic. (ICYC is an internal parameter and is described below.)
! in this case the routine will draw the streamlines with the
! non-cyclic interpolation formulas.
!
! 2) Velocity components are normalized to the value of DISPL. then
! the least significant two bits of the work array are utilized
! as flags for each grid box. flag 1 indicates whether any
! streamline has previously passed through this box. flag 2
! indicates whether a directional arrow has already appeared in
! a box. judicious use of these flags prevents overcrowding of
! streamlines and directional arrows. Experience indicates that
! a final pleasing picture is produced when streamlines are
! initiated in the center of a grid box. the streamlines are
! drawn in one direction then in the opposite direction.
!
!---------------------------------------------------------------------
!
! ~~~~~~~~~~~~~~~~~~~
! Internal parameters
! ~~~~~~~~~~~~~~~~~~~
!
! INTEGER :: INITA = 2 (default)
! Used to precondition grid boxes to be eligible to start a
! streamline. (e.g., a value of four means that every fourth grid
! box is eligible; a value of 2 means that every other grid box is
! eligible.)
!
! INTEGER :: INITB = 2
! Used to precondition grid boxes to be eligible for directional
! arrows. (if the user changes the default values of inita and/or
! INITB it should be done such that MOD(INITA,INITB) = 0 . if the
! user has a reasonably dense grid try INITA = 4 , INITB = 2 . it
! will cut cpu time down.)
!
! REAL :: AROWL = 0.012
! Length of directional arrows in fractional coordinate.
!
! REAL :: AROWB = 0.3333333 ! 1.0/3.0
! Width scale factor of directional arrows, relative to the length
! of arrows.
!
! LOGICAL :: ArrowHeadOnly = .FALSE.
! Flag to draw arrow head only
!
! INTEGER :: ICODE = 6
! Integer to specifying the type of arrowhhead. A two-digit decimal
! code "IJ" where:
! I=0 : no line is desired from XPAGE,YPAGE to the arrowhead at
! XTIP,YTIP;
! =1 : if a line is desired;
! =2 : if a line is desired and a second arrowhead pointing in
! the opposite direction, is desired at XPAGE,YPAGE.
! J : from 1 to 7, specifying the type of arrowhead desired
! (Calcomp AROHD).
! If ICODE=0, not draw the the arrowhead.
!
! INTEGER :: ITERP = 35
! Every "ITERP" iterations the streamline progress is checked.
!
! INTEGER :: ITERC = -99
! The default value of this parameter is such that it has no effect
! on the code. when set to some positive value the program will check
! for streamline crossover every "ITERC" iterations. (the routine
! currently does this every time it enters a new grid box.) caution :
! when this parameter is activated cpu time will increase.
!
! INTEGER :: IGFLG = 0
! A value of zero means that the sixteen point bessel interpolation
! formula will be utilized where possible. when near the grid edges
! quadratic and blinear interpolation will be used. this mixing of
! interpolation scheme can cause slight raggedness near the grid edges.
! this, however, does not occur very often. if IGFLG .NE. 0 then the
! bilinear interpolation formula (only) is to be used. this will
! result in slightly faster plot times. however, in general the
! plots will be less pleasing.
!
! INTEGER :: IMSG = 0
! If zero then no missing U and V components are present. if .NE. 0
! then strmln will utilize the bi-linear interpolation scheme and if
! any of the points are missing the streamline will be terminated.
!
! REAL :: UVMSG = 1.7E+38
! Value assigned to a missing point.
!
! INTEGER :: ICYC = 0
! Zero means the data are non-cyclic in the X direction. if .NE. 0
! then the cyclic interpolation formulas will be used. (note: even
! if the data are cyclic in X leaving ICYC = 0 will do no harm.)
!
! REAL :: DISPL = 0.3333333 ! 1.0/3.0
! The wind speed is normalized to this value. (see below for a
! discussion of the DISPL, DISPC and CSTOP parameters.)
!
! REAL :: DISPC = 0.6666667 ! 2.0/3.0
! The critical displacement. if after "ITERP" iterations the
! streamline has not moved this distance then the streamline will
! be terminated.
!
! REAL :: CSTOP = 0.50
! This parameter controls the spacing between streamlines. the
! checking is done when a new grid box is entered.
!
! Notes : Discussion of DISPL, DISPC and CSTOP
!
! 1) Assume a value of 0.33 for DISPL. this means that it will take
! three steps to move across one grid box if the flow was all in
! X direction. if the flow is zonal then a larger value of DISPL
! is in order. if , however , the flow is highly turbulent then
! a smaller value is in order. (the smaller DISPL the more the
! computer time)
!
! 2) A value of 2 to 4 times DISPL is a reasonable value for DISPC.
! DISPC should always be greater than DISPL.
!
! 3) A value of 0.33 for CSTOP would mean that a maximum of three
! streamlines will be drawn per grid box. this maximum will
! normally only occur in areas of singular points.
!-------------------------------------------------------------------