Changeset 681

Show
Ignore:
Timestamp:
10/26/09 17:35:19 (4 weeks ago)
Author:
robl
Message:

move assertion on recsize check into own function, call from other members of
the set_var*_fileview family.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/mpinetcdf.c

    r679 r681  
    6161static int check_mpifh(NC* ncp, MPI_File *mpifh, MPI_Comm comm, 
    6262                       int collective); 
     63static int check_recsize_too_big(NC *ncp); 
    6364 
    6465/* Begin Of Dataset Functions */ 
     
    830831  return NC_NOERR; 
    831832} 
     833 
     834static void check_recsize_too_big(NC *ncp)  
     835{ 
     836    /* assertion: because recsize will be used to set up the file 
     837     * view, we must ensure there is no overflow when specifying 
     838     * how big a stride there is between items (think interleaved 
     839     * records).   
     840     * 
     841     * note: 'recsize' is the sum of the record size of all record 
     842     * variables in this dataset */ 
     843    if (ncp->recsize != (MPI_Aint)ncp->recsize) { 
     844            fprintf(stderr, "Type overflow: unable to read/write multiple records in this dataset\non this platform. Please either access records of this record variable\none-at-a-time or run on a 64 bit platform\n"); 
     845    } 
     846    /* the assert here might harsh, but without it, users will get corrupt 
     847     * data.  */ 
     848    assert (ncp->recsize == (MPI_Aint)ncp->recsize); 
     849} 
     850 
    832851 
    833852/* 
     
    975994 
    976995    if (IS_RECVAR(varp)) 
     996      /* no need to check recsize here: if MPI_Offset only 32 bits we 
     997       * will have had problems long before here */ 
    977998      offset += index[0] * ncp->recsize; 
    978999    else  
     
    10361057    if (ncp->numrecs == 0) 
    10371058            return(NC_NOERR); 
     1059    check_recsize_too_big(NC *ncp); 
    10381060 
    10391061#if (MPI_VERSION < 2) 
     
    11591181          MPI_Type_commit(&filetype); 
    11601182        } else { 
    1161             /* assertion: because recsize will be used to set up the file 
    1162              * view, we must ensure there is no overflow when specifying 
    1163              * how big a stride there is between items (think interleaved 
    1164              * records).   
    1165              * 
    1166              * note: 'recsize' is the sum of the record size of all record 
    1167              * variables in this dataset */ 
    1168             if (ncp->recsize != (MPI_Aint)ncp->recsize) { 
    1169                     fprintf(stderr, "Type overflow: unable to read/write multiple records in this dataset\non this platform. Please either access records of this record variable\none-at-a-time or run on a 64 bit platform\n"); 
    1170             } 
    1171             assert (ncp->recsize == (MPI_Aint)ncp->recsize); 
    1172  
     1183          check_recsize_too_big(ncp); 
    11731184          /* more than one record variables */ 
    11741185 
     
    14431454      blockcount[ndims - 1] = count[ndims - 1]; 
    14441455      if (ndims == 1 && IS_RECVAR(varp)) { 
     1456        check_recsize_too_big(ncp); 
    14451457        blockstride[ndims - 1] = stride[ndims - 1] * ncp->recsize; 
    14461458        offset += start[ndims - 1] * ncp->recsize;