rtsIDe (1158448), страница 21
Текст из файла (страница 21)
The group of remote element buffers can be deleted by delig_ function only if it was created in the current subtask and in the current program block (or its sub-block) (see sections 8 and 10).
To delete the buffer group the function delobj_ can also be used (see section 17.5).
The function returns zero.
16Input/Output
16.1Analogies to functions of C language standard library
All functions discussed below is intended for usage for input/output of the replicated variables (all copies of each variable are equal). The implementaôion of these functions is based on the execution of the standard C functions on the processor, called "I/O processor". The result (if one exists) of the functions is sent to all the processors. For example, the execution of the function dvm_prinf results in single printing from the I/O processor. The execution of the function printf results in multiple printing from each processor. It is possible to determine if the current processor is I/O processor with the help of the function tstio_ (see section 17.6).
Note, that it is possible to use in the user program the I/O functions of the standard C language library (ANSI), which have no corresponding functions in the list below and have no undesirable effect of multiple execution.
16.1.1High level input/output functions
ANSI:
| void | dvm_clearerr | (DVMFILE *StreamPtr); |
| int | dvm_fclose | (DVMFILE *StreamPtr); |
| int | dvm_feof | (DVMFILE *StreamPtr); |
| int | dvm_ferror | (DVMFILE *StreamPtr); |
| int | dvm_fflush | (DVMFILE *StreamPtr); |
| int | dvm_fgetc | (DVMFILE *StreamPtr); |
| int | dvm_fgetpos | (DVMFILE *StreamPtr, fpos_t *PosPtr); |
| char | *dvm_fgets | (char *StringPtr, int n, DVMFILE *StreamPtr); |
| DVMFILE | *dvm_fopen | (const char *FileNamePtr, const char *TypePtr); |
| int | dvm_fprintf | (DVMFILE *StreamPtr, const char *FormatPtr [,Argument,...]); |
| void | dvm_void_fprintf | (DVMFILE *StreamPtr, const char *FormatPtr [,Argument,...]); |
| int | dvm_fputc | (int c,DVMFILE *StreamPtr); |
| int | dvm_fputs | (const char *StringPtr, DVMFILE *StreamPtr); |
| int | dvm_fread | (void *BufferPtr, size_t Size, size_t Count, DVMFILE *StreamPtr); |
| DVMFILE | *dvm_freopen | (const char *FileNamePtr, const char *TypePtr, DVMFILE *StreamPtr); |
| int | dvm_fscanf | (DVMFILE *StreamPtr, const char *FormatPtr [,ArgumentPtr,...]); |
| int | dvm_fseek | (DVMFILE *StreamPtr, long Offset, int Origin); |
| int | dvm_fsetpos | (DVMFILE *StreamPtr, const fpos_t *PosPtr); |
| long | dvm_ftell | (DVMFILE *StreamPtr); |
| int | dvm_fwrite | (const void *BufferPtr, size_t Size, size_t Count, DVMFILE *StreamPtr); |
| int | ävm_getc | (DVM_FILE *StreamPtr); |
| int | dvm_getchar | (void); |
| char | *dvm_gets | (char *BufferPtr); |
| int | dvm_printf | (const char *FormatPtr, ... ); |
| void | dvm_void_printf | (const char *FormatPtr, ... ); |
| int | dvm_putc | (int c, DVMFILE *StreamPtr); |
| int | dvm_putchar | (int c); |
| int | dvm_puts | (char const *StringPtr); |
| void | dvm_rewind | (DVMFILE *StreamPtr); |
| int | dvm_scanf | (const char *FormatPtr, [,ArgumentPtr,...]); |
| void | dvm_setbuf | (DVMFILE *StreamPtr, char *BufferPtr); |
| int | dvm_setvbuf | (DVMFILE *StreamPtr, char *BufferPtr, int Type, int Size); |
| DVMFILE | *dvm_tmpfile | (void); |
| int | ävm_ungetc | (int c,DVMFILE *StreamPtr); |
| int | dvm_vfprintf | (DVMFILE *StreamPtr, const char *FormatPtr, va_list ArgList); |
| void | dvm_void_vfprintf | (DVMFILE *StreamPtr, const char *FormatPtr, va_list ArgList); |
| int | dvm_vprintf | (const char *FormatPtr, va_list ArgList); |
| void | dvm_void_vprintf | (const char *FormatPtr, va_list ArgList); |
BORLAND-C & MICROSOFT-C:
| int | dvm_fgetchar | (void); |
| int | dvm_fputchar | (int c); |
BORLAND-C:
| int | dvm_vfscanf | (DVMFILE *StreamPtr, const char *FormatPtr, |
| int | dvm_vscanf | (const char *FormatPtr, va_list ArgList); |
In the functions above to specify standard streams the following pointers can be used:
| DVMFILE *DVMSTDIN | | standard input stream; |
| DVMFILE *DVMSTDOUT | | standard output stream; |
| DVMFILE *DVMSTDERR | | standard error stream; |
| DVMFILE *DVMSTDAUX | | standard com port; |
| DVMFILE *DVMSTDPRN | | standard printer port. |
Note1. The distinction (in the realization) between the functions dvm_void_printf, dvm_void_fprintf, dvm_void_vprintf, dvm_void_vfprintf are the functions dvm_printf, dvm_fprintf, dvm_vprintf, dvm_vfprintf is that the I/O processor does not send the return values of the functions printf, fprintf, vprintf and vfprintf to another processors, i.e. their is difference in the execution time. The full analogues of the standard functions printf, fprintf, vprintf and vfprintf are the functions dvm_printf, dvm_fprintf, dvm_vprintf and dvm_.
Note2. The functions dvm_fread and dvm_fwrite can be used to read/write the distributed array. In this case, the BufferPtr pointer has to point to the header of the distributed array. The size of the array element is assumed to be equal to *TypeSizePtr (that is value used at the array creation with the function crtda_), not Size. The number of the elements to read/write is assumed to be equal to the minimum of Count*Size/(*TypeSizePtr) and the number of the elements in the distributed array (also see the description of the functions dvm_dfread and dvm_dfwrite in sections 16.2 and 16.3).
Distributed array, specified in dvm_fread and dvm_fwrite function call must be mapped on the processor system, all elements of which must belong to the current processor system.
Note 3. Access to standard stdaux (stdprn) stream using DVMSTDAUX (DVMSTDPRN) pointer is possible only if Run-Time System was compiled with defined compilation variable _DVM_STDAUX_ (_DVM_STDPRN_).
16.1.2Low lewel I/O functions
BORLAND-C & MICROSOFT-C & PORTLAND GROUP-C:
| int | dvm_close | (DVMHANDLE *HandlePtr); |
| int | dvm_fstat | (DVMHANDLE *HandlePtr, struct stat *BufferPtr); |
| long | dvm_lseek | (DVMHANDLE *HandlePtr, long Offset,int Origin); |
| DVMHANDLE | *dvm_open | (const char *FileNamePtr, int OFlag, int Pmode); |
| int | dvm_read | (DVMHANDLE *HandlePtr, char *BufferPtr, unsigned int Count); |
| int | dvm_write | (DVMHANDLE *HandlePtr, const void *BufferPtr, unsigned int Count); |
To access to standard I/O streams in low level I/O functions the following pointers may be used:
| DVMSTREAM0 | | standard input stream; |
| DVMSTREAM1 | | standard output stream; |
| DVMSTREAM2 | | standard error stream; |
| DVMSTREAM3 | | standard com port; |
| DVMSTREAM4 | | standard printer port |
16.1.3Operations with directories and files
ANSI:
| int | dvm_remove | (const char *FileNamePtr); |
| int | dvm_rename | (const char *OldNamePtr, const char NewNamePtr); |
| char | *dvm_tmpnam | (char *FileNamePtr); |
BORLAND-C & MICROSOFT-C & PORTLAND GROUP-C:
| int | dvm_access | (const char *FileNamePtr, int Mode); |
| int | dvm_stat | (const char *FileName, struct stat *BufferPtr); |
| int | dvm_unlink | (const char *FileNamePtr); |
Note. A user program can use low level I/O functions and the functions dvm_access and dvm_stat only in the case, if C compiler library contains corresponding functions. To use low level input/output functions Run-Time System and user program should be compiled with defined compilation variable _DVM_LLIO_. To link function dvm_access (dvm_stat) the compilation should be done with defined variable _ACCESS_FUN_ (_STRUCT_STAT_).
When working in WINDOWS+MPI+MICROSOFT_C (WINDOWS+MICROSOFT_C) environment to link all functions above Run-Time System and user ðrogram must be compiled with defined compilation variable _WIN_MPI_ (_DVM_MSC_).
16.2Reading from file to sub-array of distributed array
| long DisArrRead( | DVMFILE | *StreamPtr, |















