root/ompi/mca/io/romio321/romio/adio/common/ad_set_view.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. ADIO_Set_view

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
   2 /* 
   3  *
   4  *   Copyright (C) 1997 University of Chicago. 
   5  *   See COPYRIGHT notice in top-level directory.
   6  */
   7 
   8 #include "adio.h"
   9 #include "adio_extern.h"
  10 
  11 /* this used to be implemented in every file system as an fcntl.  It makes
  12  * deferred open easier if we know ADIO_Fcntl will always need a file to really
  13  * be open. set_view doesn't modify anything related to the open files.
  14  */
  15 void ADIO_Set_view(ADIO_File fd, ADIO_Offset disp, MPI_Datatype etype, 
  16                 MPI_Datatype filetype, MPI_Info info,  int *error_code) 
  17 {
  18         int combiner, i, j, k, err, filetype_is_contig;
  19         MPI_Datatype copy_etype, copy_filetype;
  20         ADIOI_Flatlist_node *flat_file;
  21         /* free copies of old etypes and filetypes and delete flattened 
  22        version of filetype if necessary */
  23 
  24         MPI_Type_get_envelope(fd->etype, &i, &j, &k, &combiner);
  25         if (combiner != MPI_COMBINER_NAMED) MPI_Type_free(&(fd->etype));
  26 
  27         ADIOI_Datatype_iscontig(fd->filetype, &filetype_is_contig);
  28         if (!filetype_is_contig) ADIOI_Delete_flattened(fd->filetype);
  29 
  30         MPI_Type_get_envelope(fd->filetype, &i, &j, &k, &combiner);
  31         if (combiner != MPI_COMBINER_NAMED) MPI_Type_free(&(fd->filetype));
  32 
  33         /* set new info */
  34         ADIO_SetInfo(fd, info, &err);
  35 
  36         /* set new etypes and filetypes */
  37 
  38         ADIOI_Type_get_envelope(etype, &i, &j, &k, &combiner);
  39         if (combiner == MPI_COMBINER_NAMED) fd->etype = etype;
  40         else {
  41             MPI_Type_contiguous(1, etype, &copy_etype);
  42             MPI_Type_commit(&copy_etype);
  43             fd->etype = copy_etype;
  44         }
  45         ADIOI_Type_get_envelope(filetype, &i, &j, &k, &combiner);
  46         if (combiner == MPI_COMBINER_NAMED) 
  47             fd->filetype = filetype;
  48         else {
  49             MPI_Type_contiguous(1, filetype, &copy_filetype);
  50             MPI_Type_commit(&copy_filetype);
  51             fd->filetype = copy_filetype;
  52             ADIOI_Flatten_datatype(fd->filetype);
  53             /* this function will not flatten the filetype if it turns out
  54                to be all contiguous. */
  55         }
  56 
  57         MPI_Type_size_x(fd->etype, &(fd->etype_size));
  58         fd->disp = disp;
  59 
  60         /* reset MPI-IO file pointer to point to the first byte that can
  61            be accessed in this view. */
  62 
  63         ADIOI_Datatype_iscontig(fd->filetype, &filetype_is_contig);
  64         if (filetype_is_contig) fd->fp_ind = disp;
  65         else {
  66             flat_file = ADIOI_Flatlist;
  67             while (flat_file->type != fd->filetype) 
  68                 flat_file = flat_file->next;
  69             for (i=0; i<flat_file->count; i++) {
  70                 if (flat_file->blocklens[i]) {
  71                     fd->fp_ind = disp + flat_file->indices[i];
  72                     break;
  73                 }
  74             }
  75         }
  76         *error_code = MPI_SUCCESS;
  77 }

/* [<][>][^][v][top][bottom][index][help] */