(	SUBROUTINE LIMIT2 (LSTART,I,J, IT,JT,L)BC_Titl  LIMIT2  Constrains or flags points in 2-dimensional arrays8C_Args  ***** two modes. arguments vary with mode ******1	LOGICAL LSTART	! [I] .true. means set boundaries.C			     .false. means constrain current point5C The  FOLLOWING are meanings when  LSTART is  FALSE.)	INTEGER I	! [I] value of the first index*	INTEGER J	! [I] value of the second index2	INTEGER IT	! [O] bounded value of the first index3	INTEGER JT	! [O] bounded value of the second indexF	LOGICAL L   ! [O] flag. .true. = point in-bounds or moved to boundary1C The following are meaning when  LSTART is  TRUECC	LOGICAL LSTART	! [I] .true.7	INTEGER	II	! [I] minimum allowed value for first index8	INTEGER	III	! [I] maximum allowed value for first index8	INTEGER	JJ	! [I] minimum allowed value for second index9	INTEGER	JJJ	! [I] maximum allowed value for second indexE	LOGICAL FLAGONLY ! [I] controls way out-of-bounds points are treated0C .true.  MEANS just flag point as out-of-bounds=C .false. means move out-of-bounds points to nearest boundary
C_DESCRIPTIONHC note: if  (I out_of_bounds .and.  FLAGONLY) then  J not tested at all.C_Hist	79apr24  Hugh_H_Kieffer:C	83jan07  R.MEHLMAN adapted with minor changes for  XXBIN$C	87oct14  HHK revise documentation.:C	87nov14  HHK, converted from use of  COMMON to argumentsC_End&	SAVE		! must save the setup arguments;	IF (LSTART) THEN	! save arguments, they are all input only		II = I			III = J			JJ = IT
		JJJ = JT		FLAGONLY = L		RETURN
	    ENDIFOC==============================================================================*	L = .TRUE.	! set to point being in-boundsC test this point 0	IF (I.LT.II) THEN	! test  I against lower bound)		IT=II			! if out, set to boundary value,		GO TO 25			!   and skip other side of test8	   ELSEIF (I.GT.III) THEN	! test  I against upper bound*		IT=III			! if out, set to boundary value			GOTO 25		   ENDIF+	GOTO 30		! was in bounds, goto other indexC25	IF (FLAGONLY) GO TO 70	!  I was out; if only flaging, then done.'	I=IT			!   else, rest  I to the borderC330	IF (J.LT.JJ) THEN	! test  J against lower border		JT=JJ
		GO TO 45	   ELSEIF (J.GT.JJJ) THEN		JT=JJJ			GOTO 45		   ENDIF	RETURN45	IF (FLAGONLY) GO TO 70	J=JT	RETURN*70	L=.FALSE.	! set flag to "out-of-bounds"	RETURN	END