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