00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "ad_testfs.h"
00010 #include "adioi.h"
00011 #include "adio_extern.h"
00012
00013 void ADIOI_TESTFS_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t *fcntl_struct,
00014 int *error_code)
00015 {
00016 MPI_Datatype copy_etype, copy_filetype;
00017 int combiner, i, j, k, filetype_is_contig, err;
00018 ADIOI_Flatlist_node *flat_file;
00019
00020 int myrank, nprocs;
00021
00022 *error_code = MPI_SUCCESS;
00023
00024 MPI_Comm_size(fd->comm, &nprocs);
00025 MPI_Comm_rank(fd->comm, &myrank);
00026 FPRINTF(stdout, "[%d/%d] ADIOI_TESTFS_Fcntl called on %s\n",
00027 myrank, nprocs, fd->filename);
00028
00029 switch(flag) {
00030 case ADIO_FCNTL_SET_VIEW:
00031
00032
00033
00034 MPI_Type_get_envelope(fd->etype, &i, &j, &k, &combiner);
00035 if (combiner != MPI_COMBINER_NAMED) MPI_Type_free(&(fd->etype));
00036
00037 ADIOI_Datatype_iscontig(fd->filetype, &filetype_is_contig);
00038 if (!filetype_is_contig) ADIOI_Delete_flattened(fd->filetype);
00039
00040 MPI_Type_get_envelope(fd->filetype, &i, &j, &k, &combiner);
00041 if (combiner != MPI_COMBINER_NAMED) MPI_Type_free(&(fd->filetype));
00042
00043
00044 ADIO_SetInfo(fd, fcntl_struct->info, &err);
00045
00046
00047
00048 MPI_Type_get_envelope(fcntl_struct->etype, &i, &j, &k, &combiner);
00049 if (combiner == MPI_COMBINER_NAMED) fd->etype = fcntl_struct->etype;
00050 else {
00051 MPI_Type_contiguous(1, fcntl_struct->etype, ©_etype);
00052 MPI_Type_commit(©_etype);
00053 fd->etype = copy_etype;
00054 }
00055 MPI_Type_get_envelope(fcntl_struct->filetype, &i, &j, &k, &combiner);
00056 if (combiner == MPI_COMBINER_NAMED)
00057 fd->filetype = fcntl_struct->filetype;
00058 else {
00059 MPI_Type_contiguous(1, fcntl_struct->filetype, ©_filetype);
00060 MPI_Type_commit(©_filetype);
00061 fd->filetype = copy_filetype;
00062 ADIOI_Flatten_datatype(fd->filetype);
00063
00064
00065 }
00066
00067 MPI_Type_size(fd->etype, &(fd->etype_size));
00068 fd->disp = fcntl_struct->disp;
00069
00070
00071
00072
00073 ADIOI_Datatype_iscontig(fd->filetype, &filetype_is_contig);
00074 if (filetype_is_contig) fd->fp_ind = fcntl_struct->disp;
00075 else {
00076 flat_file = ADIOI_Flatlist;
00077 while (flat_file->type != fd->filetype)
00078 flat_file = flat_file->next;
00079 for (i=0; i<flat_file->count; i++) {
00080 if (flat_file->blocklens[i]) {
00081 fd->fp_ind = fcntl_struct->disp + flat_file->indices[i];
00082 break;
00083 }
00084 }
00085 }
00086 *error_code = MPI_SUCCESS;
00087 break;
00088
00089 case ADIO_FCNTL_GET_FSIZE:
00090 fcntl_struct->fsize = 0;
00091 *error_code = MPI_SUCCESS;
00092 break;
00093
00094 case ADIO_FCNTL_SET_DISKSPACE:
00095 *error_code = MPI_SUCCESS;
00096 break;
00097
00098 case ADIO_FCNTL_SET_IOMODE:
00099
00100
00101 if (fd->iomode != fcntl_struct->iomode) {
00102 fd->iomode = fcntl_struct->iomode;
00103 MPI_Barrier(MPI_COMM_WORLD);
00104 }
00105 *error_code = MPI_SUCCESS;
00106 break;
00107
00108 case ADIO_FCNTL_SET_ATOMICITY:
00109 fd->atomicity = (fcntl_struct->atomicity == 0) ? 0 : 1;
00110 *error_code = MPI_SUCCESS;
00111 break;
00112
00113 default:
00114 FPRINTF(stderr, "Unknown flag passed to ADIOI_TESTFS_Fcntl\n");
00115 MPI_Abort(MPI_COMM_WORLD, 1);
00116 }
00117 }