+----------------------------------------------+
|VALUE = hcreateg(global-name,basecommon,size) |
+----------------------------------------------+
Action: Function to create and map a global section .
The function first opens a file with UFO option (using HSTOPEN-GBL), then creates and maps the global section using SYS$CRMPSC. Open the file using SYS$SETDFPROT to set protection loose.
The function value returned is equal to the global section length (pages) if the procedure was successful or an errorcode <0 if an error occurred.
HCREATEG$DIR is a LOGICAL which, if defined, gives the directory for the mapping file of the global section. In this case, the file is not deleted upon closing.
+----------------------------------------------+
|VALUE = hmapg(global-name,base-common,offset) |
+----------------------------------------------+
Action: Function to dynamically map to an existing global section.
The function maps to the global section using SYS$MGBLSC, allocating pages in the p0 region with the sec$m_expreg option.
The function value returned is equal to the global section length (pages) if the procedure was successful or is an errorcode <0 if an error occurred.
+----------------------------------------------+
|VALUE = hfree(global-size,base-common,offset) |
+----------------------------------------------+
Action: Function to dynamically delete/unmap global section space using the service SYS$DELTVA.
The function value returned is equal to the global section length (pages) if the procedure was successful or is an errorcode <0 if an error occurred.
PROGRAM PRODUCE
PARAMETER MAXPAGES=100
COMMON/PAWC/IPAWC(128*MAXPAGES)
CHARACTER*8 GNAME
INTEGER*4 HCREATEG
*
GNAME='GTEST'
WAIT_TIME=1.
NUMEVT=1000
*.............. Create Global section
NPAGES=HCREATEG(GNAME,IPAWC,128*MAXPAGES)
IF(NPAGES.GT.0) THEN
PRINT 1000,GNAME
1000 FORMAT(' Global Section: ',A,' created')
ELSE
IERROR=-NPAGES
PRINT 2000,IERROR
2000 FORMAT(' Global Section Error', I6)
GO TO 99
ENDIF
CALL HLIMIT(128*NPAGES)
*............... Book histos.
CALL HBOOK1(10,'Test1$',50,-4.,4.,0.)
CALL HBOOK1(20,'Test2$',50,-4.,4.,0.)
*............... Fill histos.
DO 20 I=1,NUMEVT
DO 10 J=1,100
CALL RANNOR(A,B)
CALL HFILL(10,A,0.,1.)
CALL HFILL(20,B,0.,1.)
10 CONTINUE
CALL LIB$WAIT(WAIT_TIME)
20 CONTINUE
*
99 STOP
END
$ fort produce
$ link produce,SYS$INPUT/OPTIONS,-
cern$library:packlib/lib,kernlib/lib
PSECT=PAWC,PAGE
PAW > edit produce
macro produce ntimes=100
nt=[ntimes]
zone 1 2
histo/plot 10 K
histo/plot 20 K
loop:
histo/plot 10 U
histo/plot 20 U
wait ' ' 1
nt=[nt] -1
if nt>0 goto loop
return
PAW > global GTEST
PAW > exec produce ntimes=20
Figure: Visualise histograms in global section
In addition to the facilities described in the previous section, the standard version of PAW may be used as an online presenter on VMS systems using the mechanism of global sections. It is possible for two processes to reference the same histograms using global sections. For example, the first process may be a histogram producer (e.g. a monitoring task) and the second process PAW. As the histograms are being gradually filled by the first task, PAW can view them, and even reset them. To use the global sections, it is also necessary to "page align" the common which is in the global section. This is achieved in the "link step" when making the process (see example). The relevant statements are SYS$INPUT/OPTIONS to tell the linker that some options follow the link statement, and PSECT=PAWC,PAGE which is the option to page align the /PAWC/ common.