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_write_all_end = PMPI_File_write_all_end
14 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
15 #pragma _HP_SECONDARY_DEF PMPI_File_write_all_end MPI_File_write_all_end
16 #elif defined(HAVE_PRAGMA_CRI_DUP)
17 #pragma _CRI duplicate MPI_File_write_all_end as PMPI_File_write_all_end
18 /* end of weak pragmas */
19 #elif defined(HAVE_WEAK_ATTRIBUTE)
20 int MPI_File_write_all_end(MPI_File fh, const void *buf, MPI_Status *status) __attribute__((weak,alias("PMPI_File_write_all_end")));
21 #endif
22 
23 /* Include mapping from MPI->PMPI */
24 #define MPIO_BUILD_PROFILING
25 #include "mpioprof.h"
26 #endif
27 
28 /*@
29     MPI_File_write_all_end - Complete a split collective write using individual file pointer
30 
31 Input Parameters:
32 . fh - file handle (handle)
33 
34 Output Parameters:
35 . buf - initial address of buffer (choice)
36 . status - status object (Status)
37 
38 .N fortran
39 @*/
MPI_File_write_all_end(MPI_File fh,ROMIO_CONST void * buf,MPI_Status * status)40 int MPI_File_write_all_end(MPI_File fh, ROMIO_CONST void *buf, MPI_Status *status)
41 {
42     int error_code;
43     static char myname[] = "MPI_FILE_WRITE_ALL_END";
44 
45     error_code = MPIOI_File_write_all_end(fh, buf, myname, status);
46 
47     return error_code;
48 }
49 
50 /* prevent multiple definitions of this routine */
51 #ifdef MPIO_BUILD_PROFILING
MPIOI_File_write_all_end(MPI_File fh,const void * buf,char * myname,MPI_Status * status)52 int MPIOI_File_write_all_end(MPI_File fh,
53 			     const void *buf,
54 			     char *myname,
55 			     MPI_Status *status)
56 {
57     int error_code;
58     ADIO_File adio_fh;
59 
60     MPIU_UNREFERENCED_ARG(buf);
61 
62     ROMIO_THREAD_CS_ENTER();
63 
64     adio_fh = MPIO_File_resolve(fh);
65 
66     /* --BEGIN ERROR HANDLING-- */
67     MPIO_CHECK_FILE_HANDLE(adio_fh, myname, error_code);
68 
69     if (!(adio_fh->split_coll_count))
70     {
71 	error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
72 					  myname, __LINE__, MPI_ERR_IO,
73 					  "**iosplitcollnone", 0);
74 	error_code = MPIO_Err_return_file(adio_fh, error_code);
75 	goto fn_exit;
76     }
77     /* --END ERROR HANDLING-- */
78 
79 #ifdef HAVE_STATUS_SET_BYTES
80     /* FIXME - we should really ensure that the split_datatype remains
81        valid by incrementing the ref count in the write_allb.c routine
82        and decrement it here after setting the bytes */
83     if (status != MPI_STATUS_IGNORE)
84        *status = adio_fh->split_status;
85 #endif
86     adio_fh->split_coll_count = 0;
87 
88     error_code = MPI_SUCCESS;
89 
90 fn_exit:
91     ROMIO_THREAD_CS_EXIT();
92 
93     return error_code;
94 }
95 #endif
96