datapool(5)
DATAPOOL - Fortran Interprocess Data Sharing
As shipped in IRIX 6.5.5. Last changed in IRIX 6.5.5.
NAME DATAPOOL - Fortran Interprocess Data Sharing IMPLEMENTATION IRIX systems DESCRIPTION This man page describes Fortran datapool usage. The information on this man page is intended for use with the MIPSpro Fortran 77 compiler. The man page can be used as both a quick reference and a source of detailed information on datapool usage. Datapool definition and syntax The DATAPOOL statement is a way for different processes to access the same pool of common symbols, or datapool. Any processes can access the shared datapool by linking with the datapool DSO (Dynamic Shared Object). A DATAPOOL statement has the following syntax: DATAPOOL [/[dp/] nlist [[,]/[dp]/ nlist] ... where dp is the datapool name and nlist is a list of variable names, array names, array declarators, or records. A blank datapool, which is unique by itself, is defined by omitting the dp argument. A datapool has similar syntactic form to a common block declaration. However, in a common block, the common block variables are associated with the same common block declared in other program units by their relative position in the common block, regardless of the declared symbolic names. In a datapool, the datapool variables are associated with declarations in other program units by their symbolic names, regardless of the relative order, sizes, and number of variables declared in the datapool for that particular program unit. Also, no datapool variables can be initialized with a DATA statement. Datapool Usage Follow these steps to use datapools: 1. Put each blockdata containing one or more datapool definitions in a Fortran source file. 2. Compile the Fortran source file to create the object file (.o file) using the -G0 option. 3. Run the ld command: ld -soname dpf.so -shared -noivpad -G0 -o dpf.so -init _init_dp_dpf_ -fini _unmap_dp__ dpf.o where dpf is the name of the Fortran source file without the .f extension. This creates the datapool DSO file dpf.so. 4. Compile the rest of the Fortran program with the -G0 option. 5. Link all the Fortran objects with the selected datapool DSO's. The .o files created from the datapool source files do need to be linked to create the executable. 6. When the program is run, the default directory for the shared mapped data is /usr/tmp. The user can change this by setting the DATAPOOL_DIR environment variable to point to the desired directory. Datapool Details Each datapool item, when compiled, is turned into a separate external symbol so it can be correctly associated with the same symbol declared in other program units without being affected by its relative order in the datapool. In one blockdata subprogram, and in only one, a datapool must be defined as to its exact number of items, sizes, and relative order. This will be used as the basis for sharing the datapool with other processes wishing to access the same data. Each blockdata can contain definitions for one or more datapools. However, each Fortran source file can contain only one such blockdata. Each of those source files is turned into a DSO which any program can link to if the datapools defined in that blockdata need to be accessed. In other words, all datapools defined in a single blockdata always go together as a single shared unit. If you want to choose the datapools separately, they have to be defined in different blockdata, and put into separate Fortran source files. All datapool variables defined in the blockdata are mapped to a data file which is shared between different processes. The name of the mapped data file is the name of the corresponding Fortran source files preceded by DP_. This file is put into the /usr/tmp/ directory as the default, but this default directory can be changed with the DATAPOOL_DIR environment variable. For example, datapools /a/, /b/, and /c/ are defined in blockdata dp_abc_def which is in the Fortran source file dpabc.f. After compilation, the file dpabc.f is converted into dpabc.so which an application can link with to share the datapools /a/, /b/, and /c/. At runtime, a mapped data file, /usr/tmp/DP_dpabc, is created as the default. After all processes sharing this mapped datapool have terminated, the mapped file is removed automatically. However, if for any reason a process using the datapool aborts abnormally before it can run to completion, then the mapped file remains and the user must remove the file; otherwise, the next fresh process using the datapool will pick up the values that have been mapped into that file. NOTES * The following lines can be added to the MAKEFILE to create a datapool DSO from the Fortran source file: .SUFFIXES : .so FFLAGS = -G 0 LDFLAGS = -G 0 .f.so: $(FC) $(FFLAGS) -c $*.f $(LD) $(LDFLAGS) -soname $@ -shared -noivpad -o $@ \ -init _init_dp_$*_ -fini _unmap_dp__ $*.o * For applications which rely on datapool variables being set to zeroes at the beginning of execution, it is prudent to check for the existence of the mapped data files /usr/tmp/DP_*, which might remain after an abnormal termination in previous runs. * Programs running on different machines can share datapools across NFS by setting DATAPOOL_DIR to point to the same physical directory. However, because I/O operations are buffered across NFS, changing a datapool variable on one system does not cause the new value to be written immediately in the data file and so it is not known by a different process on another system. It will be up to the user to create his own datapool status variable to ensure the update of the datapool variables by another process on a different system. * At runtime, the datapool DSOs must be in the search path of rld for them to be found. The default search path can be changed by setting the environment variable LD_LIBRARY_PATH. * The datapool DSOs cannot be used with IRIX releases before 5.1.1. You receive an error message that the DSO's are not found when a datapool application is run on those releases even when the DSOs exist. EXAMPLES :::::::::::::: testdp.f :::::::::::::: C C NAME C testdp.f - Shared DATAPOOL test case C C Note that both the sizes and the relative order of the datapool C items are different from the defined sizes and order in the C blockdata datapool /hello/ c, b, arr(100,100,3) real*8 arr print *, 'Read arr(1,1,1)', arr(1,1,1) if (arr(1,1,1) .ne. 42) then arr(1,1,1) = 42 endif print *, "Address Offset = ", %loc(b)-%loc(arr), %loc(c) -%loc(b) call sleep(10) end :::::::::::::: hello.f :::::::::::::: blockdata hellodef C The relative positions and sizes of the datapool items are C defined in this blockdata and nowhere else. real*8 arr datapool /hello/ arr(100,100,30), b, c end :::::::::::::: Makefile :::::::::::::: .SUFFIXES : .so CFLAGS = -G 0 FFLAGS = -G 0 FFILES = testdp.f hello.f default: testdp testdp: testdp.o hello.so $(FC) $(FFLAGS) -o testdp testdp.o hello.so .f.so: $(FC) $(FFLAGS) -c $*.f $(LD) -soname $@ -shared -noivpad $*.o -G 0 -o $@ \ -init _init_dp_$*_ -fini _unmap_dp__ test: default testdp & @ sleep 1 testdp & clean: rm -f *.o core a.out *.so clobber: clean rm -f testdp so_locations SEE ALSO f77(1), dso(5), ld(1), rld(1) MIPSpro Fortran 77 Programmer's Guide This man page is available only online.