00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "adio.h"
00010 #ifdef MPISGI
00011 #include "mpisgi2.h"
00012 #endif
00013
00014 void ADIO_Close(ADIO_File fd, int *error_code)
00015 {
00016 int i, j, k, combiner, myrank, err, is_contig;
00017 #ifndef PRINT_ERR_MSG
00018 static char myname[] = "ADIO_CLOSE";
00019 #endif
00020
00021 if (fd->async_count) {
00022 #ifdef PRINT_ERR_MSG
00023 FPRINTF(stderr, "ADIO_Close: Error! There are outstanding nonblocking I/O operations on this file.\n");
00024 MPI_Abort(MPI_COMM_WORLD, 1);
00025 #else
00026 *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ERR_ASYNC_OUTSTANDING,
00027 myname, (char *) 0, (char *) 0);
00028 ADIOI_Error(fd, *error_code, myname);
00029 return;
00030 #endif
00031 }
00032
00033 (*(fd->fns->ADIOI_xxx_Close))(fd, error_code);
00034
00035 if (fd->access_mode & ADIO_DELETE_ON_CLOSE) {
00036 MPI_Comm_rank(fd->comm, &myrank);
00037 MPI_Barrier(fd->comm);
00038 if (!myrank) ADIO_Delete(fd->filename, &err);
00039 }
00040
00041 ADIOI_Free(fd->fns);
00042 MPI_Comm_free(&(fd->comm));
00043 free(fd->filename);
00044
00045
00046 MPI_Type_get_envelope(fd->etype, &i, &j, &k, &combiner);
00047 if (combiner != MPI_COMBINER_NAMED) MPI_Type_free(&(fd->etype));
00048
00049 ADIOI_Datatype_iscontig(fd->filetype, &is_contig);
00050 if (!is_contig) ADIOI_Delete_flattened(fd->filetype);
00051
00052 MPI_Type_get_envelope(fd->filetype, &i, &j, &k, &combiner);
00053 if (combiner != MPI_COMBINER_NAMED) MPI_Type_free(&(fd->filetype));
00054
00055 MPI_Info_free(&(fd->info));
00056
00057 ADIOI_Free(fd);
00058 }