1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3 *
4 * Copyright (C) 1997 University of Chicago.
5 * See COPYRIGHT notice in top-level directory.
6 */
7
8 #include "mpioimpl.h"
9
10 #ifdef HAVE_WEAK_SYMBOLS
11
12 #if defined(HAVE_PRAGMA_WEAK)
13 #pragma weak MPI_File_get_view = PMPI_File_get_view
14 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
15 #pragma _HP_SECONDARY_DEF PMPI_File_get_view MPI_File_get_view
16 #elif defined(HAVE_PRAGMA_CRI_DUP)
17 #pragma _CRI duplicate MPI_File_get_view as PMPI_File_get_view
18 /* end of weak pragmas */
19 #elif defined(HAVE_WEAK_ATTRIBUTE)
20 int MPI_File_get_view(MPI_File fh, MPI_Offset *disp, MPI_Datatype *etype, MPI_Datatype *filetype,
21 char *datarep) __attribute__((weak,alias("PMPI_File_get_view")));
22 #endif
23
24 /* Include mapping from MPI->PMPI */
25 #define MPIO_BUILD_PROFILING
26 #include "mpioprof.h"
27 #endif
28 #ifdef MPISGI
29 #include "mpisgi2.h"
30 #endif
31
32 /*@
33 MPI_File_get_view - Returns the file view
34
35 Input Parameters:
36 . fh - file handle (handle)
37
38 Output Parameters:
39 . disp - displacement (nonnegative integer)
40 . etype - elementary datatype (handle)
41 . filetype - filetype (handle)
42 . datarep - data representation (string)
43
44 .N fortran
45 @*/
MPI_File_get_view(MPI_File fh,MPI_Offset * disp,MPI_Datatype * etype,MPI_Datatype * filetype,char * datarep)46 int MPI_File_get_view(MPI_File fh, MPI_Offset *disp, MPI_Datatype *etype,
47 MPI_Datatype *filetype, char *datarep)
48 {
49 int error_code;
50 ADIO_File adio_fh;
51 static char myname[] = "MPI_FILE_GET_VIEW";
52 int i, j, k, combiner;
53 MPI_Datatype copy_etype, copy_filetype;
54
55 MPIU_THREAD_CS_ENTER(ALLFUNC,);
56
57 adio_fh = MPIO_File_resolve(fh);
58
59 /* --BEGIN ERROR HANDLING-- */
60 MPIO_CHECK_FILE_HANDLE(adio_fh, myname, error_code);
61
62 if (datarep <= (char *) 0)
63 {
64 error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
65 myname, __LINE__, MPI_ERR_ARG,
66 "**iodatarepnomem", 0);
67 error_code = MPIO_Err_return_file(adio_fh, error_code);
68 goto fn_exit;
69 }
70 /* --END ERROR HANDLING-- */
71
72 *disp = adio_fh->disp;
73 ADIOI_Strncpy(datarep,
74 (adio_fh->is_external32 ? "external32": "native"), MPI_MAX_DATAREP_STRING);
75
76 MPI_Type_get_envelope(adio_fh->etype, &i, &j, &k, &combiner);
77 if (combiner == MPI_COMBINER_NAMED) *etype = adio_fh->etype;
78 else {
79 /* FIXME: It is wrong to use MPI_Type_contiguous; the user could choose to
80 re-implement MPI_Type_contiguous in an unexpected way. Either use
81 MPIR_Barrier_impl as in MPICH or PMPI_Type_contiguous */
82 MPI_Type_contiguous(1, adio_fh->etype, ©_etype);
83
84 /* FIXME: Ditto for MPI_Type_commit - use NMPI or PMPI */
85 MPI_Type_commit(©_etype);
86 *etype = copy_etype;
87 }
88 /* FIXME: Ditto for MPI_Type_xxx - use NMPI or PMPI */
89 MPI_Type_get_envelope(adio_fh->filetype, &i, &j, &k, &combiner);
90 if (combiner == MPI_COMBINER_NAMED) *filetype = adio_fh->filetype;
91 else {
92 MPI_Type_contiguous(1, adio_fh->filetype, ©_filetype);
93
94 MPI_Type_commit(©_filetype);
95 *filetype = copy_filetype;
96 }
97
98 fn_exit:
99 MPIU_THREAD_CS_EXIT(ALLFUNC,);
100
101 return MPI_SUCCESS;
102 }
103