This source file includes following definitions.
- ADIO_Close
1
2
3
4
5
6
7
8 #include "adio.h"
9 #include "adio_extern.h"
10 #ifdef HAVE_UNISTD_H
11 #include <unistd.h>
12 #endif
13
14 void ADIO_Close(ADIO_File fd, int *error_code)
15 {
16 int i, j, k, combiner, myrank, err, is_contig;
17 static char myname[] = "ADIO_CLOSE";
18
19 if (fd->async_count) {
20 *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
21 myname, __LINE__, MPI_ERR_IO, "**io",
22 "**io %s", strerror(errno));
23 return;
24 }
25
26
27
28
29
30
31
32
33
34
35
36
37 if (fd->hints->deferred_open && fd->is_agg) {
38 (*(fd->fns->ADIOI_xxx_Close))(fd, error_code);
39 } else {
40 if(fd->is_open) {
41 (*(fd->fns->ADIOI_xxx_Close))(fd, error_code);
42 } else {
43 *error_code = MPI_SUCCESS;
44 }
45
46 }
47
48 if (fd->access_mode & ADIO_DELETE_ON_CLOSE) {
49
50
51
52 MPI_Comm_rank(fd->comm, &myrank);
53 if (myrank == fd->hints->ranklist[0]) {
54 ADIO_Delete(fd->filename, &err);
55 }
56 MPI_Barrier(fd->comm);
57 }
58
59 if (fd->fortran_handle != -1) {
60 ADIOI_Ftable[fd->fortran_handle] = MPI_FILE_NULL;
61 }
62
63 if (fd->hints) ADIOI_Free(fd->hints->ranklist);
64 if (fd->hints && fd->hints->cb_config_list) ADIOI_Free(fd->hints->cb_config_list);
65
66
67
68
69
70
71
72
73 #ifdef BGQPLATFORM
74 if (fd->hints && fd->hints->fs_hints.bg.bridgelist) ADIOI_Free(fd->hints->fs_hints.bg.bridgelist);
75 if (fd->hints && fd->hints->fs_hints.bg.bridgelistnum) ADIOI_Free(fd->hints->fs_hints.bg.bridgelistnum);
76 #endif
77
78
79 if (fd->hints->cb_pfr == ADIOI_HINT_ENABLE) {
80
81 if (1) {
82 ADIOI_Delete_flattened (fd->file_realm_types[0]);
83 MPI_Type_free (&fd->file_realm_types[0]);
84 }
85 else {
86 for (i=0; i<fd->hints->cb_nodes; i++) {
87 ADIOI_Datatype_iscontig(fd->file_realm_types[i], &is_contig);
88 if (!is_contig)
89 ADIOI_Delete_flattened(fd->file_realm_types[i]);
90 MPI_Type_free (&fd->file_realm_types[i]);
91 }
92 }
93 ADIOI_Free(fd->file_realm_st_offs);
94 ADIOI_Free(fd->file_realm_types);
95 }
96 ADIOI_Free(fd->hints);
97
98
99
100 MPI_Comm_free(&(fd->comm));
101 ADIOI_Free(fd->filename);
102
103 MPI_Type_get_envelope(fd->etype, &i, &j, &k, &combiner);
104 if (combiner != MPI_COMBINER_NAMED) MPI_Type_free(&(fd->etype));
105
106 ADIOI_Datatype_iscontig(fd->filetype, &is_contig);
107 if (!is_contig) ADIOI_Delete_flattened(fd->filetype);
108
109 MPI_Type_get_envelope(fd->filetype, &i, &j, &k, &combiner);
110 if (combiner != MPI_COMBINER_NAMED) MPI_Type_free(&(fd->filetype));
111
112 MPI_Info_free(&(fd->info));
113
114 ADIOI_Free(fd->io_buf);
115 ADIOI_OneSidedCleanup(fd);
116
117
118 }