
                               					 7-Jan-1983 13:29:02	VAX-11 FORTRAN V3.1-23              Page   1
								 5-Jan-1983 13:09:43	SYS$SYSROOT:[CAMAC.CTS]CTSSHOW.FOR;63       

0001    C+++
0002    C
0003    C	CTSSHOW.FOR
0004    C
0005    C This module contains the source for the SHOW command of the CAMAC Topology
0006    C Supervisor.  In addition, two utility subroutines (MAKE_REF and
0007    C MAKE_SPECIFIER) are included.
0008    C
0009    C
0010    C   Date	By		Comments
0011    C 10/06/82	D.E.Greenwood	Added comments; insure that UIC returned by
0012    C				MAKE_REF is padded with spaces
0013    C 10/15/82	D.E.Greenwood	Added /BRIEF & /FULL qualifiers; handle errors
0014    C				when doing file open when /OUTPUT specified
0015    C  1/05/82	D.E.Greenwood	Full wildcards added (using WCMATCH subroutine);
0016    C				spec list accepted;  default order is logical;
0017    C				/NOLOGICAL, /NOPHYSICAL qualifiers permitted
0018    C
0019    C---
0020    C
0021    C

                               					 7-Jan-1983 13:29:02	VAX-11 FORTRAN V3.1-23              Page   2
								 5-Jan-1983 13:09:43	SYS$SYSROOT:[CAMAC.CTS]CTSSHOW.FOR;63       

0022    	SUBROUTINE SHOW
0023    C
0024    	CHARACTER LINE*132, MATCH*32, MIN_MATCH*32, OUT_FILE*64,
0025         &		REFERENCE_UIC*15, PHY_SPEC*9
0026    	CHARACTER TEMP_STR*2
0027    	INTEGER*2 COLON_LOC, FILE_LEN, LOG_LEN, MATCH_LEN, MIN_MATCH_LEN,
0028         &		PHY_LEN, PRCNT_LOC, RECORD_COUNT, STAR_LOC, TEMP_VALUE
0029    	INTEGER*4 CLI$GET_VALUE, CLI$PRESENT, ERROR_STATUS, WCMATCH
0030    	LOGICAL FIRST_SPEC, FULL_DESC
0031    	EXTERNAL CLI$_NEGATED
0032    	INCLUDE 'CTSDEF'
0075    	FIRST_SPEC = .TRUE.
0076    C
0077    C Get the output file if one was specified
0078    C
0079    	IF (CLI$PRESENT('OUTPUT')) THEN
0080    	  CALL CLI$GET_VALUE('OUTPUT',OUT_FILE)
0081    	  CALL STR$TRIM(OUT_FILE,OUT_FILE,FILE_LEN)
0082    	  OPEN (2, FILE=OUT_FILE(1:FILE_LEN), DEFAULTFILE='CTS.LIS',
0083    	1	ERR=80000, STATUS='UNKNOWN')
0084    	  FULL_DESC = .TRUE.
0085    	ELSE
0086    	  OPEN (2, FILE='SYS$OUTPUT', STATUS='UNKNOWN')
0087    	  FULL_DESC = .FALSE.
0088    	END IF
0089    C
0090    C Determine if /full or /brief was entered
0091    C
0092    	IF (CLI$PRESENT('BRIEF')) FULL_DESC = .FALSE.
0093    	IF (CLI$PRESENT('FULL')) FULL_DESC = .TRUE.
0094    C
0095    C Get the (next) match specification and the minimum number of characters
0096    C required to match.
0097    C
0098    100	IF (.NOT. CLI$GET_VALUE('NAME',MATCH)) RETURN
0099    	CALL STR$UPCASE(MATCH,MATCH)
0100    	CALL STR$TRIM(MATCH,MATCH,MATCH_LEN)
0101    	STAR_LOC = INDEX(MATCH,'*')
0102    	PRCNT_LOC = INDEX(MATCH,'%')
0103    	MIN_MATCH_LEN = MATCH_LEN
0104    	IF (STAR_LOC .GT. 0) MIN_MATCH_LEN = STAR_LOC - 1
0105    	IF (PRCNT_LOC .GT. 0 .AND. PRCNT_LOC-1 .LT. MIN_MATCH_LEN)
0106         &		MIN_MATCH_LEN = PRCNT_LOC - 1
0107    	MIN_MATCH = MATCH(1:MIN_MATCH_LEN)
0108    	IF (MIN_MATCH_LEN .EQ. 0) MIN_MATCH = ' '
0109    C
0110    C Determine the sorting order (logical name order, unless "/physical" was
0111    C specified.
0112    C
0113    	IF (CLI$PRESENT('PHYSICAL') .OR.
0114         &		(CLI$PRESENT('LOGICAL') .EQ. %LOC(CLI$_NEGATED))) GOTO 2000
0115    C
0116    C Present list in logical name order.
0117    C
0118    1000	IF (FIRST_SPEC) THEN
0119    	    IF (FULL_DESC) THEN
0120    	      WRITE (2,90100)

SHOW                           					 7-Jan-1983 13:29:02	VAX-11 FORTRAN V3.1-23              Page   3
								 5-Jan-1983 13:09:43	SYS$SYSROOT:[CAMAC.CTS]CTSSHOW.FOR;63       

0121    	    ELSE
0122    	      WRITE (2,90120)
0123    	    ENDIF
0124    	    FIRST_SPEC = .FALSE.
0125    	ENDIF
0126    	RECORD_COUNT = 0
0127    	READ (1,KEYGE=MIN_MATCH,KEYID=0,ERR=89000) CAMDEF_RECORD
0128    	UNLOCK 1
0129    C
0130    	DO WHILE (MIN_MATCH_LEN .EQ. 0 .OR.
0131         &		LOGICAL_NAME(1:MIN_MATCH_LEN) .EQ. MIN_MATCH)
0132    	  CALL MAKE_SPECIFIER(CAMDEF_RECORD,PHY_SPEC)
0133    	  CALL STR$TRIM(LOGICAL_NAME,LOGICAL_NAME,LOG_LEN)
0134    	  IF (MATCH_LEN .EQ. 0 .OR.
0135         &		WCMATCH( MATCH(1:MATCH_LEN), LOGICAL_NAME(1:LOG_LEN))) THEN
0136    	      IF (FULL_DESC) THEN
0137    		CALL MAKE_REF(CAMDEF_RECORD,REFERENCE_UIC)
0138    		ENCODE (132,90110,LINE) LOGICAL_NAME,PHY_SPEC,REFERENCE_UIC,
0139         &			COMMENT
0140    	      ELSE
0141    		ENCODE (132,90130,LINE) LOGICAL_NAME,PHY_SPEC,COMMENT
0142    	      ENDIF
0143    	      CALL STR$TRIM(LINE,LINE,LINE_LEN)
0144    	      WRITE (2,90000) LINE(1:LINE_LEN)
0145    	      RECORD_COUNT = RECORD_COUNT + 1
0146    	  ENDIF
0147    	  READ (1,END=89000) CAMDEF_RECORD
0148    	  UNLOCK 1
0149    	END DO
0150    C
0151    	GOTO 89000
0152    C
0153    C Present list in physical specifier order.
0154    C
0155    2000	IF (FIRST_SPEC) THEN
0156    	    IF (FULL_DESC) THEN
0157    	      WRITE (2,90200)
0158    	    ELSE
0159    	      WRITE (2,90240)
0160    	    ENDIF
0161    	    FIRST_SPEC = .FALSE.
0162    	ENDIF
0163    	IF (MIN_MATCH_LEN .GT. 3) THEN			! This kludge req'd
0164    	    MIN_MATCH_LEN = 3				!  because crate may be
0165    	    MIN_MATCH(4:) = ' '				!  either 1 or 2 chars
0166    	ENDIF						!  long
0167    	RECORD_COUNT = 0
0168    	READ (1,KEYGE=MIN_MATCH(1:11),KEYID=1,ERR=89000) CAMDEF_RECORD
0169    	UNLOCK 1
0170    C
0171    	DO WHILE (.TRUE.)
0172    	  CALL MAKE_SPECIFIER(CAMDEF_RECORD,PHY_SPEC)
0173    	  IF (MIN_MATCH_LEN .GT. 0 .AND.
0174         &		PHY_SPEC(1:MIN_MATCH_LEN) .GT. MIN_MATCH) GOTO 89000
0175    	  CALL STR$TRIM(PHY_SPEC,PHY_SPEC,PHY_LEN)
0176    	  IF (MATCH_LEN .EQ. 0 .OR.
0177         &		WCMATCH(MATCH(1:MATCH_LEN),PHY_SPEC(1:PHY_LEN))) THEN

SHOW                           					 7-Jan-1983 13:29:02	VAX-11 FORTRAN V3.1-23              Page   4
								 5-Jan-1983 13:09:43	SYS$SYSROOT:[CAMAC.CTS]CTSSHOW.FOR;63       

0178    	    IF (FULL_DESC) THEN
0179    	      CALL MAKE_REF(CAMDEF_RECORD,REFERENCE_UIC)
0180    	      ENCODE (132,90210,LINE) PHY_SPEC,LOGICAL_NAME,REFERENCE_UIC,
0181         &			COMMENT
0182    	    ELSE
0183    	      ENCODE (132,90250,LINE) PHY_SPEC,LOGICAL_NAME,COMMENT
0184    	    ENDIF
0185    	    CALL STR$TRIM(LINE,LINE,LINE_LEN)
0186    	    WRITE (2,90000) LINE(1:LINE_LEN)
0187    	    RECORD_COUNT = RECORD_COUNT + 1
0188    	  ENDIF
0189    	  READ (1,END=89000) CAMDEF_RECORD
0190    	  UNLOCK 1
0191    	END DO
0192    	GOTO 89000
0193    C
0194    C Open error - complain
0195    C
0196    80000	CALL ERRSNS(,,,,ERROR_STATUS)			! Get VAX cond. value
0197    	CALL REPORT(ERROR_STATUS)
0198    	GOTO 89900
0199    C
0200    89000	IF (RECORD_COUNT .EQ. 0) THEN
0201    	    IF (CLI$PRESENT('PHYSICAL')) THEN
0202    		WRITE (2,98910), MATCH(1:MATCH_LEN)
0203    	    ELSE
0204    		WRITE (2,98900), MATCH(1:MATCH_LEN)
0205    	    ENDIF
0206    	ENDIF
0207    89900	GOTO 100
0208    C
0209    90000	FORMAT(1X,A)
0210    90100	FORMAT('0Logical name',21X,'Specifier',T45,'Reference uic',3X,
0211    	1	'Comment',/)
0212    90110	FORMAT(A32,1X,A,T44,A15,1X,A40)
0213    90120	FORMAT('0Logical name',21X,'Specifier',T45,'Comment',/)
0214    90130	FORMAT(A32,1X,A,T44,A40)
0215    90200	FORMAT('0Specifier',T12,'Logical name',21X,'Reference uic',3X,
0216    	1	'Comment',/)
0217    90210	FORMAT(A,T11,A32,1X,A15,1X,A40)
0218    90220	FORMAT(I)
0219    90230	FORMAT(I2)
0220    90240	FORMAT('0Specifier',T12,'Logical name',21X,'Comment',/)
0221    90250	FORMAT(A,T11,A32,1X,A40)
0222    98900	FORMAT(1X,'%CTS-E-NOLOGMATCH, no logical name matches: ',A)
0223    98910	FORMAT(1X,'%CTS-E-NOPHYMATCH, no physical specifier matches: ',A)
0224    	END

SHOW                           					 7-Jan-1983 13:29:02	VAX-11 FORTRAN V3.1-23              Page   5
								 5-Jan-1983 13:09:43	SYS$SYSROOT:[CAMAC.CTS]CTSSHOW.FOR;63       

PROGRAM SECTIONS

    Name				 Bytes   Attributes

  0 $CODE                                 1336   PIC CON REL LCL   SHR   EXE   RD NOWRT LONG
  1 $PDATA                                 419   PIC CON REL LCL   SHR NOEXE   RD NOWRT LONG
  2 $LOCAL                                 968   PIC CON REL LCL NOSHR NOEXE   RD   WRT LONG

    Total Space Allocated                 2723


ENTRY POINTS

    Address  Type  Name          

  0-00000000       SHOW          


VARIABLES

    Address  Type  Name                                Address  Type  Name                            

  2-00000010  CHAR CAMDEF_RECORD                     2-000001AC  I*2  COLON_LOC                       
  2-00000045  CHAR COMMENT                           2-00000039  CHAR CR_COLON                        
  2-00000034  CHAR CSU                               2-00000036  CHAR CSU_CONTROLLER                  
  2-00000034  CHAR CSU_DEVICE                        2-000001A6  CHAR CSU_NAME                        
  2-00000037  CHAR CSU_UNIT                          2-000001C0  I*4  ERROR_STATUS                    
  2-000001AE  I*2  FILE_LEN                          2-000001C4  L*4  FIRST_SPEC                      
  2-000001C8  L*4  FULL_DESC                         2-00000088  CHAR LINE                            
  2-000001CC  I*4  LINE_LEN                          2-00000010  CHAR LOGICAL_NAME                    
  2-000001B0  I*2  LOG_LEN                           2-0000010C  CHAR MATCH                           
  2-000001B2  I*2  MATCH_LEN                         2-0000012C  CHAR MIN_MATCH                       
  2-000001B4  I*2  MIN_MATCH_LEN                     2-0000014C  CHAR OUT_FILE                        
  2-000001B6  I*2  PHY_LEN                           2-0000019B  CHAR PHY_SPEC                        
  2-00000000  I*4  PM_RUG                            2-00000004  I*4  PM_RUM                          
  2-0000000C  I*4  PM_STATION                        2-00000008  I*4  PM_UNIT                         
  2-000001B8  I*2  PRCNT_LOC                         2-000001BA  I*2  RECORD_COUNT                    
  2-0000018C  CHAR REFERENCE_UIC                     2-0000003D  I*4  REF_UIC_GROUP                   
  2-00000041  I*4  REF_UIC_MEMBER                    2-00000034  CHAR SPECIFIER                       
  2-000001BC  I*2  STAR_LOC                          2-0000003A  CHAR STATION                         
  2-000001A4  CHAR TEMP_STR                          2-000001BE  I*2  TEMP_VALUE                      


ARRAYS

    Address  Type  Name                Bytes  Dimensions

  2-00000000  I*4  PHY_MOD                16  (4)


LABELS

    Address   Label       Address   Label       Address   Label       Address   Label       Address   Label       Address   Label   

  0-00000077  100           **      1000      0-000002D9  2000      0-000004AC  80000     0-000004C0  89000     0-00000535  89900   
  1-0000003F  90000'    1-00000043  90100'    1-0000007D  90110'    1-0000008B  90120'    1-000000B4  90130'    1-000000BE  90200'  
  1-000000F8  90210'        **      90220'        **      90230'    1-00000106  90240'    1-0000012F  90250'    1-00000139  98900'  

SHOW                           					 7-Jan-1983 13:29:02	VAX-11 FORTRAN V3.1-23              Page   6
								 5-Jan-1983 13:09:43	SYS$SYSROOT:[CAMAC.CTS]CTSSHOW.FOR;63       

  1-0000016B  98910'  


FUNCTIONS AND SUBROUTINES REFERENCED

  Type  Name                              Type  Name                              Type  Name                            

   I*4  CLI$GET_VALUE                      I*4  CLI$PRESENT                             CLI$_NEGATED                    
        FOR$ERRSNS                              FOR$OPEN                           I*4  LIB$INDEX                       
        MAKE_REF                                MAKE_SPECIFIER                          REPORT                          
        STR$TRIM                                STR$UPCASE                         I*4  WCMATCH                         

                               					 7-Jan-1983 13:29:02	VAX-11 FORTRAN V3.1-23              Page   7
								 5-Jan-1983 13:09:43	SYS$SYSROOT:[CAMAC.CTS]CTSSHOW.FOR;63       

0001    C	MAKE_REF
0002    C
0003    C This subroutine makes and returns a string reference uic from the numeric
0004    C version stored in the cts database record.
0005    C
0006    C
0007    C Calling sequence:
0008    C
0009    C	CALL MAKE_REF(RECORD,UIC)
0010    C   where:
0011    C	RECORD	is the address of the cts database record string descriptor
0012    C	UIC	is the address of a character string descriptor defining where
0013    C		the reference UIC will be placed
0014    C
0015    C
0016    	SUBROUTINE MAKE_REF(RECORD,UIC)
0017    C
0018    	CHARACTER RECORD*(*),UIC*(*)
0019    	INCLUDE 'CTSDEF'
0062    C
0063    	CAMDEF_RECORD = RECORD
0064    	UIC = ' '
0065    	IF (REF_UIC_GROUP .LT. 0) THEN
0066    	  UIC = '[*,'
0067    	  GROUP_LEN = 3
0068    	ELSE
0069    	  ENCODE (5,90010,UIC) REF_UIC_GROUP
0070    	  GROUP_LEN = 5
0071    	END IF
0072    	IF (REF_UIC_MEMBER .LT. 0) THEN
0073    	  UIC = UIC(1:GROUP_LEN)//'*]'
0074    	ELSE
0075    	  ENCODE (4,90020,UIC(GROUP_LEN+1:)) REF_UIC_MEMBER
0076    	END IF
0077    	IF (UIC .EQ. '[*,*]') UIC = ' '
0078    	RETURN
0079    C
0080    90010	FORMAT('[',O3,',')
0081    90020	FORMAT(O3,']')
0082    	END

MAKE_REF                       					 7-Jan-1983 13:29:02	VAX-11 FORTRAN V3.1-23              Page   8
								 5-Jan-1983 13:09:43	SYS$SYSROOT:[CAMAC.CTS]CTSSHOW.FOR;63       

PROGRAM SECTIONS

    Name				 Bytes   Attributes

  0 $CODE                                  236   PIC CON REL LCL   SHR   EXE   RD NOWRT LONG
  1 $PDATA                                  23   PIC CON REL LCL   SHR NOEXE   RD NOWRT LONG
  2 $LOCAL                                 164   PIC CON REL LCL NOSHR NOEXE   RD   WRT LONG

    Total Space Allocated                  423


ENTRY POINTS

    Address  Type  Name          

  0-00000000       MAKE_REF      


VARIABLES

    Address  Type  Name                                Address  Type  Name                            

  2-00000010  CHAR CAMDEF_RECORD                     2-00000045  CHAR COMMENT                         
  2-00000039  CHAR CR_COLON                          2-00000034  CHAR CSU                             
  2-00000036  CHAR CSU_CONTROLLER                    2-00000034  CHAR CSU_DEVICE                      
  2-00000088  CHAR CSU_NAME                          2-00000037  CHAR CSU_UNIT                        
  2-00000090  R*4  GROUP_LEN                         2-00000010  CHAR LOGICAL_NAME                    
  2-00000000  I*4  PM_RUG                            2-00000004  I*4  PM_RUM                          
  2-0000000C  I*4  PM_STATION                        2-00000008  I*4  PM_UNIT                         
 AP-00000004@ CHAR RECORD                            2-0000003D  I*4  REF_UIC_GROUP                   
  2-00000041  I*4  REF_UIC_MEMBER                    2-00000034  CHAR SPECIFIER                       
  2-0000003A  CHAR STATION                          AP-00000008@ CHAR UIC                             


ARRAYS

    Address  Type  Name                Bytes  Dimensions

  2-00000000  I*4  PHY_MOD                16  (4)


LABELS

    Address   Label       Address   Label   

  1-00000000  90010'    1-00000009  90020'  

                               					 7-Jan-1983 13:29:02	VAX-11 FORTRAN V3.1-23              Page   9
								 5-Jan-1983 13:09:43	SYS$SYSROOT:[CAMAC.CTS]CTSSHOW.FOR;63       

0001    C	MAKE_SPECIFIER
0002    C
0003    C This subroutine makes a physical specifier (without a reference UIC) from
0004    C the data stored in a cts database record
0005    C
0006    C
0007    C Calling sequence:
0008    C
0009    C	CALL MAKE_SPECIFIER(RECORD,PHY_SPEC)
0010    C   where:
0011    C	RECORD		is the address of the cts database record string
0012    C			descriptor
0013    C	PHY_SPEC	is the address of a string descriptor defining where
0014    C			the specifier is to be placed
0015    C
0016    C
0017    	SUBROUTINE MAKE_SPECIFIER(RECORD,PHY_SPEC)
0018    C
0019    	CHARACTER RECORD*(*),PHY_SPEC*(*),TEMP_SPEC*11
0020    	INTEGER*4 SPACE_LOC,SPEC_LEN
0021    	INCLUDE 'CTSDEF'
0064    C
0065    	CAMDEF_RECORD = RECORD
0066    	TEMP_SPEC = SPECIFIER
0067    	SPEC_LEN = LEN(TEMP_SPEC)
0068    C
0069    10000	SPACE_LOC = INDEX(TEMP_SPEC(1:SPEC_LEN),' ')
0070    	IF (SPACE_LOC .EQ. 0) GOTO 89000
0071    	TEMP_SPEC = TEMP_SPEC(:SPACE_LOC-1)//TEMP_SPEC(SPACE_LOC+1:SPEC_LEN)
0072    	SPEC_LEN = SPEC_LEN-1
0073    	GOTO 10000
0074    C
0075    89000	PHY_SPEC = TEMP_SPEC
0076    	RETURN
0077    	END

MAKE_SPECIFIER                 					 7-Jan-1983 13:29:02	VAX-11 FORTRAN V3.1-23              Page  10
								 5-Jan-1983 13:09:43	SYS$SYSROOT:[CAMAC.CTS]CTSSHOW.FOR;63       

PROGRAM SECTIONS

    Name				 Bytes   Attributes

  0 $CODE                                  154   PIC CON REL LCL   SHR   EXE   RD NOWRT LONG
  1 $PDATA                                   2   PIC CON REL LCL   SHR NOEXE   RD NOWRT LONG
  2 $LOCAL                                 208   PIC CON REL LCL NOSHR NOEXE   RD   WRT LONG

    Total Space Allocated                  364


ENTRY POINTS

    Address  Type  Name                            

  0-00000000       MAKE_SPECIFIER                  


VARIABLES

    Address  Type  Name                                Address  Type  Name                            

  2-00000010  CHAR CAMDEF_RECORD                     2-00000045  CHAR COMMENT                         
  2-00000039  CHAR CR_COLON                          2-00000034  CHAR CSU                             
  2-00000036  CHAR CSU_CONTROLLER                    2-00000034  CHAR CSU_DEVICE                      
  2-00000093  CHAR CSU_NAME                          2-00000037  CHAR CSU_UNIT                        
  2-00000010  CHAR LOGICAL_NAME                     AP-00000008@ CHAR PHY_SPEC                        
  2-00000000  I*4  PM_RUG                            2-00000004  I*4  PM_RUM                          
  2-0000000C  I*4  PM_STATION                        2-00000008  I*4  PM_UNIT                         
 AP-00000004@ CHAR RECORD                            2-0000003D  I*4  REF_UIC_GROUP                   
  2-00000041  I*4  REF_UIC_MEMBER                    2-0000009C  I*4  SPACE_LOC                       
  2-00000034  CHAR SPECIFIER                         2-000000A0  I*4  SPEC_LEN                        
  2-0000003A  CHAR STATION                           2-00000088  CHAR TEMP_SPEC                       


ARRAYS

    Address  Type  Name                Bytes  Dimensions

  2-00000000  I*4  PHY_MOD                16  (4)


LABELS

    Address   Label       Address   Label   

  0-00000040  10000     0-00000089  89000   


FUNCTIONS AND SUBROUTINES REFERENCED

  Type  Name          

   I*4  LIB$INDEX     

MAKE_SPECIFIER                 					 7-Jan-1983 13:29:02	VAX-11 FORTRAN V3.1-23              Page  11
								 5-Jan-1983 13:09:43	SYS$SYSROOT:[CAMAC.CTS]CTSSHOW.FOR;63       

COMMAND QUALIFIERS

  FORTRAN /LIS CTS,CTSASSIGN,CTSDEASGN,CTSMODIFY,CTSSET,CTSSHOW,WCCOPY,WCMATCH

  /CHECK=(NOBOUNDS,OVERFLOW,NOUNDERFLOW)
  /DEBUG=(NOSYMBOLS,TRACEBACK)
  /STANDARD=(NOSYNTAX,NOSOURCE_FORM)
  /SHOW=(NOPREPROCESSOR,NOINCLUDE,MAP)
  /F77  /NOG_FLOATING  /I4  /OPTIMIZE  /WARNINGS  /NOD_LINES  /NOCROSS_REFERENCE  /NOMACHINE_CODE  /CONTINUATIONS=19


COMPILATION STATISTICS

  Run Time:           5.07 seconds
  Elapsed Time:       5.64 seconds
  Page Faults:        1
  Dynamic Memory:     382 pages
