00001
00002
00003
00004
00005
00006
00007
00008 #include "adio.h"
00009 #include "adio_extern.h"
00010
00011
00012
00013
00014
00015 void ADIO_Set_view(ADIO_File fd, ADIO_Offset disp, MPI_Datatype etype,
00016 MPI_Datatype filetype, MPI_Info info, int *error_code)
00017 {
00018 int combiner, i, j, k, err, filetype_is_contig;
00019 MPI_Datatype copy_etype, copy_filetype;
00020 ADIOI_Flatlist_node *flat_file;
00021
00022
00023
00024 MPI_Type_get_envelope(fd->etype, &i, &j, &k, &combiner);
00025 if (combiner != MPI_COMBINER_NAMED) MPI_Type_free(&(fd->etype));
00026
00027 ADIOI_Datatype_iscontig(fd->filetype, &filetype_is_contig);
00028 if (!filetype_is_contig) ADIOI_Delete_flattened(fd->filetype);
00029
00030 MPI_Type_get_envelope(fd->filetype, &i, &j, &k, &combiner);
00031 if (combiner != MPI_COMBINER_NAMED) MPI_Type_free(&(fd->filetype));
00032
00033
00034 ADIO_SetInfo(fd, info, &err);
00035
00036
00037
00038 MPI_Type_get_envelope(etype, &i, &j, &k, &combiner);
00039 if (combiner == MPI_COMBINER_NAMED) fd->etype = etype;
00040 else {
00041 MPI_Type_contiguous(1, etype, ©_etype);
00042 MPI_Type_commit(©_etype);
00043 fd->etype = copy_etype;
00044 }
00045 MPI_Type_get_envelope(filetype, &i, &j, &k, &combiner);
00046 if (combiner == MPI_COMBINER_NAMED)
00047 fd->filetype = filetype;
00048 else {
00049 MPI_Type_contiguous(1, filetype, ©_filetype);
00050 MPI_Type_commit(©_filetype);
00051 fd->filetype = copy_filetype;
00052 ADIOI_Flatten_datatype(fd->filetype);
00053
00054
00055 }
00056
00057 MPI_Type_size(fd->etype, &(fd->etype_size));
00058 fd->disp = disp;
00059
00060
00061
00062
00063 ADIOI_Datatype_iscontig(fd->filetype, &filetype_is_contig);
00064 if (filetype_is_contig) fd->fp_ind = disp;
00065 else {
00066 flat_file = CtvAccess(ADIOI_Flatlist);
00067 while (flat_file->type != fd->filetype)
00068 flat_file = flat_file->next;
00069 for (i=0; i<flat_file->count; i++) {
00070 if (flat_file->blocklens[i]) {
00071 fd->fp_ind = disp + flat_file->indices[i];
00072 break;
00073 }
00074 }
00075 }
00076 *error_code = MPI_SUCCESS;
00077 }