1 /*
2    (C) 2004 by Argonne National Laboratory.
3        See COPYRIGHT in top-level directory.
4 */
5 #include "collchk.h"
6 
MPI_File_read_at_all_begin(MPI_File fh,MPI_Offset offset,void * buff,int cnt,MPI_Datatype dtype)7 int MPI_File_read_at_all_begin(MPI_File fh, MPI_Offset offset, void *buff,
8                                int cnt, MPI_Datatype dtype)
9 {
10     int g2g = 1;
11     char call[COLLCHK_SM_STRLEN];
12     char err_str[COLLCHK_STD_STRLEN];
13     MPI_Comm comm;
14 
15     sprintf(call, "FILE_READ_AT_ALL_BEGIN");
16 
17     /* Check if init has been called */
18     g2g = CollChk_is_init();
19 
20     if(g2g) {
21         /* get the communicator */
22         if (!CollChk_get_fh(fh, &comm)) {
23             return CollChk_err_han("File has not been opened",
24                                    COLLCHK_ERR_FILE_NOT_OPEN,
25                                    call, MPI_COMM_WORLD);
26         }
27 
28         /* check for call consistancy */
29         CollChk_same_call(comm, call);
30 
31         /* check for previous begin */
32         if(COLLCHK_CALLED_BEGIN) {
33             sprintf(err_str, "Previous MPI_File_%s_begin called, "
34                              "must call MPI_File_%s_end first.",
35                              CollChk_begin_str, CollChk_begin_str);
36             return CollChk_err_han(err_str, COLLCHK_ERR_PREVIOUS_BEGIN,
37                                    call, comm);
38         }
39         else {
40             CollChk_set_begin("READ_AT_ALL");
41         }
42 
43         /* make the call */
44         return PMPI_File_read_at_all_begin(fh, offset, buff, cnt, dtype);
45     }
46     else {
47         /* init not called */
48         return CollChk_err_han("MPI_Init() has not been called!",
49                                COLLCHK_ERR_NOT_INIT, call, MPI_COMM_WORLD);
50     }
51 }
52