Changeset 698

Show
Ignore:
Timestamp:
10/30/09 05:36:47 (3 weeks ago)
Author:
kgao
Message:

add the binding of iput_vara_all, iget_vara_all, waitall, wait in order to support multi-variable I/O operations on Fortran

Location:
trunk
Files:
12 modified

Legend:

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

    r687 r698  
    11201120  NCtype type = NC_UNSPECIFIED; 
    11211121  NC_var **vpp, **end; 
     1122  int i; 
    11221123 
    11231124  assert(gbp != NULL && gbp->pos != NULL); 
     
    12781279        } else {         
    12791280           for (i=0; i<nc_dim1->nelems; i++){ 
    1280               if (nc_dim1->value[i]->size != nc_dim2->value[i]->size){ 
     1281              if (nc_dim1->value[i]->size != nc_dim2->value[i]->size) 
    12811282                return NC_EDIMS_SIZE_MULTIDEFINE; 
    1282               } else { 
     1283#define METADATA_CONSISTENCY_CHECK 
     1284#ifdef METADATA_CONSISTENCY_CHECK 
     1285              else { 
    12831286                   if ((nc_dim1->value[i]->name->nchars != nc_dim1->value[i]->name->nchars)||(strcmp(nc_dim1->value[i]->name->cp, nc_dim2->value[i]->name->cp)!=0)){ 
    1284                       printf("Warning: The dimination name of NC definations on multiprocesses conflict. \nNOTE: Definitions across all processes must agree with one another\n"); 
     1287                      printf("Warning: The dimination name %s of NC definations on multiprocesses inconsistent.\n",nc_dim1->value[i]->name->cp); 
    12851288                   }  
    12861289             } 
     1290#endif 
    12871291           }  
    12881292 
     
    12931297int ncmpii_comp_attrs(NC_attrarray *nc_attr1, NC_attrarray *nc_attr2){ 
    12941298        int i; 
     1299#ifdef METADATA_CONSISTENCY_CHECK 
    12951300        if (nc_attr1->nelems != nc_attr2->nelems){ 
    1296            printf("Warning: The number of attributes of NC definations on multiprocesses conflict. \nNOTE: Definitions across all processes must agree with one another\n"); 
     1301           printf("Warning: The number of attributes (root=%d != %d) of NC definations on multiprocesses inconsistent.\n",nc_attr1->nelems,nc_attr2->nelems); 
    12971302        } else { 
    12981303                for (i=0; i<nc_attr1->nelems; i++){ 
    12991304                   if (nc_attr1->value[i]->xsz != nc_attr2->value[i]->xsz){ 
    1300                        printf("Warning: The size of attribute of NC definations on multiprocesses conflict. \nNOTE: Definitions across all processes must agree with one another\n"); 
     1305                       printf("Warning: The size of attribute (root=%d != %d) of NC definations on multiprocesses inconsistent.\n",nc_attr1->value[i]->xsz,nc_attr2->value[i]->xsz); 
    13011306                   } 
    13021307                   if ((nc_attr1->value[i]->name->nchars != nc_attr2->value[i]->name->nchars)||(strcmp(nc_attr1->value[i]->name->cp, nc_attr2->value[i]->name->cp))){ 
    1303                        printf("Warning: The name of attribute of NC definations on multiprocesses conflict. \nNOTE: Definitions across all processes must agree with one another\n"); 
     1308                       printf("Warning: The name of attribute (root=%s != %s) of NC definations on multiprocesses inconsistent.\n",nc_attr1->value[i]->name->cp,nc_attr2->value[i]->name->cp); 
    13041309                   } 
    13051310                   if (strcmp(nc_attr1->value[i]->xvalue, nc_attr2->value[i]->xvalue)){ 
    1306                     printf("Warning: The value of attribute of NC definations on multiprocesses conflict. \nNOTE: Definitions across all processes must agree with one another\n"); 
     1311                    printf("Warning: The value of attribute (root=%s !=%s) of NC definations on multiprocesses inconsistent.\n",nc_attr1->value[i]->xvalue, nc_attr2->value[i]->xvalue); 
    13071312                   }     
    13081313                   if (nc_attr1->value[i]->type != nc_attr2->value[i]->type){ 
    1309                     printf("Warning: The type of attribute of NC definations on multiprocesses conflict. \nNOTE: Definitions across all processes must agree with one another\n"); 
     1314                    printf("Warning: The type of attribute (root=%d != %d) of NC definations on multiprocesses inconsistent.\n",nc_attr1->value[i]->type,nc_attr2->value[i]->type); 
    13101315                   } 
    13111316                   if (nc_attr1->value[i]->nelems != nc_attr2->value[i]->nelems){ 
    1312                     printf("Warning: The length of attribute of NC definations on multiprocesses conflict. \nNOTE: Definitions across all processes must agree with one another\n"); 
     1317                    printf("Warning: The length of attribute (root=%d != %d) of NC definations on multiprocesses inconsistent.\n",nc_attr1->value[i]->nelems,nc_attr2->value[i]->nelems); 
    13131318                   } 
    13141319                } 
    13151320        }        
     1321#endif 
    13161322    return NC_NOERR; 
    13171323} 
     
    13231329        } else { 
    13241330                for (i=0; i<nc_var1->nelems; i++){ 
     1331#ifdef METADATA_CONSISTENCY_CHECK 
    13251332                   if ((nc_var1->value[i]->name->nchars !=  nc_var2->value[i]->name->nchars)||strcmp(nc_var1->value[i]->name->cp,nc_var2->value[i]->name->cp)) 
    13261333                   { 
    1327                     printf("Warning: The name of variable of NC definations on multiprocesses conflict. \nNOTE: Definitions across all processes must agree with one another\n"); 
     1334                    printf("Warning: The name of variable (root=%s) of NC definations on multiprocesses inconsistent.\n",nc_var1->value[i]->name->cp); 
    13281335                   } 
     1336#endif 
    13291337                   if ((nc_var1->value[i]->ndims != nc_var2->value[i]->ndims)){ 
    13301338                        return NC_EVARS_NDIMS_MULTIDEFINE; 
  • trunk/src/lib/mpinetcdf.c

    r693 r698  
    1322013220      (*request)->count[dim]=count[dim]; 
    1322113221  } 
    13222    
     13222  (*request)->rw_flag = 1;  
     13223  return NC_NOERR; 
     13224} 
     13225 
     13226int 
     13227ncmpi_iget_vara_all(int ncid, int varid, 
     13228                   const MPI_Offset start[], const MPI_Offset count[], 
     13229                   const void *buf, MPI_Offset bufcount, 
     13230                   MPI_Datatype datatype, NCMPI_Request *request) { 
     13231 
     13232  NC_var *varp; 
     13233  NC *ncp; 
     13234  int status = NC_NOERR; 
     13235  int dim; 
     13236 
     13237  status = ncmpii_NC_check_id(ncid, &ncp); 
     13238  if(status != NC_NOERR) 
     13239    return status; 
     13240 
     13241  varp = ncmpii_NC_lookupvar(ncp, varid); 
     13242  if(varp == NULL) 
     13243    return NC_ENOTVAR; 
     13244 
     13245 
     13246  *request = (NCMPI_Request)malloc(sizeof(struct NCMPI_Req)); 
     13247  if (*request == NULL) printf("no memory buffer\n"); 
     13248  (*request)->indep = 0; 
     13249  (*request)->ncid = ncid; 
     13250  (*request)->varid = varid; 
     13251  (*request)->ndim = varp->ndims; 
     13252  (*request)->start = (MPI_Offset *)malloc(varp->ndims*sizeof(MPI_Offset)); 
     13253  (*request)->count = (MPI_Offset *)malloc(varp->ndims*sizeof(MPI_Offset)); 
     13254  (*request)->buf = (void *)buf; 
     13255  (*request)->bufcount = bufcount; 
     13256  (*request)->vartype = datatype; 
     13257  (*request)->next_req = NULL; 
     13258  for (dim = 0; dim < varp->ndims; dim++){ 
     13259      (*request)->start[dim]=start[dim]; 
     13260      (*request)->count[dim]=count[dim]; 
     13261  } 
     13262  (*request)->rw_flag = 0; 
    1322313263  return NC_NOERR; 
    1322413264} 
     
    1322713267static int 
    1322813268ncmpi_coll_wait(NCMPI_Request request) { 
     13269  if (request->rw_flag == 1) 
    1322913270  return (ncmpi_put_vara_all(request->ncid, request->varid, 
     13271                   request->start, request->count, 
     13272                   request->buf, request->bufcount, 
     13273                   request->vartype)); 
     13274  if (request->rw_flag == 0) 
     13275  return (ncmpi_get_vara_all(request->ncid, request->varid, 
    1323013276                   request->start, request->count, 
    1323113277                   request->buf, request->bufcount, 
     
    1327013316        datatype[i] = array_of_requests[i]->vartype; 
    1327113317  } 
    13272  
     13318  if (array_of_requests[0]->rw_flag == 1) 
    1327313319  ncmpi_put_mvara_all(ncid, count, varids, 
    1327413320                   starts, counts, 
    1327513321                   buf, bufcount, 
    1327613322                   datatype); 
     13323 
     13324  if (array_of_requests[0]->rw_flag == 0) 
     13325  ncmpi_get_mvara_all(ncid, count, varids, 
     13326                   starts, counts, 
     13327                   buf, bufcount, 
     13328                   datatype); 
     13329 
     13330  free(starts); 
     13331  free(varids); 
     13332  free(counts); 
     13333  free(buf); 
     13334  free(bufcount); 
     13335  free(datatype); 
    1327713336  return NC_NOERR; 
    1327813337} 
  • trunk/src/lib/pnetcdf.h

    r691 r698  
    8686  MPI_Offset* start; 
    8787  MPI_Offset* count; 
     88  int rw_flag; 
    8889}; 
    8990typedef struct NCMPI_Req * NCMPI_Request; 
     91 
    9092#define NCMPI_REQUEST_NULL ((NCMPI_Request)NULL) 
    9193#define NCMPI_REQTYPE_READ      1 
     
    698700                   void **buffers, MPI_Offset *bufcounts, 
    699701                   MPI_Datatype *datatypes); 
    700 int 
    701 ncmpi_iput_vara_all(int ncid, int varid, 
     702 
     703int ncmpi_iput_vara_all(int ncid, int varid, 
    702704                   const MPI_Offset start[], const MPI_Offset count[], 
    703705                   const void *buf, MPI_Offset bufcount, 
     
    713715                   void **buffers, MPI_Offset *bufcounts, 
    714716                   MPI_Datatype *datatypes); 
     717 
     718int ncmpi_iget_vara_all(int ncid, int varid, 
     719                   const MPI_Offset start[], const MPI_Offset count[], 
     720                   const void *buf, MPI_Offset bufcount, 
     721                   MPI_Datatype datatype, NCMPI_Request *request); 
    715722 
    716723int ncmpi_put_vara(int ncid, int varid, 
  • trunk/src/libf/Makefile.in

    r688 r698  
    100100        issyserrf.c \ 
    101101        get_file_infof.c \ 
    102         deletef.c 
     102        deletef.c \ 
     103        iput_vara_allf.c \ 
     104        iget_vara_allf.c \ 
     105        waitallf.c \ 
     106        waitf.c \ 
     107        mvar.c 
    103108 
    104109LIB_FSRCS = strerrorf.f inq_libversf.f 
  • trunk/src/libf/createffiles

    r449 r698  
    55# It makes use of an interface builder developed for MPICH2 and a set of  
    66# NetCDF-specific descriptions in the file "defs". 
    7 mpich2SourceDir=${MPICH2SRC:-/home/gropp/projects/software/mpich2} 
     7mpich2SourceDir=${MPICH2SRC:-/home/kgao/ChomboIO/mpich2-1.1.1p1} 
    88 
    99if [ ! -d "$mpich2SourceDir" ] ; then 
  • trunk/src/libf/defs

    r635 r698  
    2121$free   = "free"; 
    2222$header_file = "mpinetcdf_impl.h"; 
     23 
     24$tof77{"NCMPI_Request*"} = "int *"; 
     25$tof77{"NCMPI_Request*"} = "int *"; 
     26$tof77{"NCMPI_Request\[\]"} = "int *"; 
     27$tof77{"MPI_Offset**"} = "MPI_Offset *"; 
    2328 
    2429# Error return handling 
     
    216221                'get_vara_all-3' => 'in:intToSizeTOffsetArr:ncmpixVardim(*v1,*v2-1)', 
    217222                'get_vara_all-4' => 'in:intToSizeTArr:ncmpixVardim(*v1,*v2-1)', 
     223              'iget_vara_all' => '2:3:4',  
     224                'iget_vara_all-2' => 'in:OffsetIndexIn', 
     225                'iget_vara_all-3' => 'in:intToSizeTOffsetArr:ncmpixVardim(*v1,*v2-1)', 
     226                'iget_vara_all-4' => 'in:intToSizeTArr:ncmpixVardim(*v1,*v2-1)', 
    218227              'get_vara' => '2:3:4',  
    219228                'get_vara-2' => 'in:OffsetIndexIn', 
     
    578587                'put_vara_all-3' => 'in:intToSizeTOffsetArr:ncmpixVardim(*v1,*v2-1)', 
    579588                'put_vara_all-4' => 'in:intToSizeTArr:ncmpixVardim(*v1,*v2-1)', 
     589              'put_mvara_all' => '3',  
     590                'put_mvara_all-3' => 'in:OffsetIndexIn', 
     591              'iput_vara_all' => '2:3:4',  
     592                'iput_vara_all-2' => 'in:OffsetIndexIn', 
     593                'iput_vara_all-3' => 'in:intToSizeTOffsetArr:ncmpixVardim(*v1,*v2-1)', 
     594                'iput_vara_all-4' => 'in:intToSizeTArr:ncmpixVardim(*v1,*v2-1)', 
    580595              'put_vara' => '2:3:4',  
    581596                'put_vara-2' => 'in:OffsetIndexIn', 
  • trunk/src/libf/mpifnetcdf.h

    r696 r698  
    2121extern FORTRAN_API int FORT_CALL nfmpi_end_indep_data_ ( int *v1 ); 
    2222extern FORTRAN_API int FORT_CALL nfmpi_close_ ( int *v1 ); 
    23 extern FORTRAN_API int FORT_CALL nfmpi_wait_ ( NCMPI_Request*v1 ); 
    24 extern FORTRAN_API int FORT_CALL nfmpi_waitall_ ( int *v1, NCMPI_Request v2[] ); 
     23extern FORTRAN_API int FORT_CALL nfmpi_wait_ ( MPI_Fint *v1 ); 
     24extern FORTRAN_API int FORT_CALL nfmpi_waitall_ ( int *v1, MPI_Fint * v2 ); 
    2525extern FORTRAN_API int FORT_CALL nfmpi_set_fill_ ( int *v1, int *v2, MPI_Fint *v3 ); 
    2626extern FORTRAN_API int FORT_CALL nfmpi_def_dim_ ( int *v1, char *v2 FORT_MIXED_LEN(d2), MPI_Offset *v3, MPI_Fint *v4 FORT_END_LEN(d2) ); 
     
    101101extern FORTRAN_API int FORT_CALL nfmpi_get_var_double_all_ ( int *v1, int *v2, double*v3 ); 
    102102extern FORTRAN_API int FORT_CALL nfmpi_put_vara_all_ ( int *v1, int *v2, MPI_Offset v3[], MPI_Offset v4[], void*v5, MPI_Offset *v6, MPI_Fint *v7 ); 
    103 extern FORTRAN_API int FORT_CALL nfmpi_put_mvara_all_ ( int *v1, int *v2, MPI_Fint v3[], MPI_Offset**starts v4, MPI_Offset**counts v5, void**buffers v6, MPI_Offset*v7, MPI_Fint *v8 ); 
     103extern FORTRAN_API int FORT_CALL nfmpi_put_mvara_all_ ( int *v1, int *v2, MPI_Fint v3[], MPI_Offset**v4, MPI_Offset**v5, void**v6, MPI_Offset*v7, MPI_Fint *v8 ); 
     104extern FORTRAN_API int FORT_CALL nfmpi_iput_vara_all_ ( int *v1, int *v2, MPI_Offset v3[], MPI_Offset v4[], void*v5, MPI_Offset *v6, MPI_Fint *v7, MPI_Fint *v8 ); 
    104105extern FORTRAN_API int FORT_CALL nfmpi_get_vara_all_ ( int *v1, int *v2, MPI_Offset v3[], MPI_Offset v4[], void*v5, MPI_Offset *v6, MPI_Fint *v7 ); 
    105 extern FORTRAN_API int FORT_CALL nfmpi_get_mvara_all_ ( int *v1, int *v2, MPI_Fint v3[], MPI_Offset**starts v4, MPI_Offset**counts v5, void**buffers v6, MPI_Offset*v7, MPI_Fint *v8 ); 
     106extern FORTRAN_API int FORT_CALL nfmpi_get_mvara_all_ ( int *v1, int *v2, MPI_Fint v3[], MPI_Offset**v4, MPI_Offset**v5, void**v6, MPI_Offset*v7, MPI_Fint *v8 ); 
     107extern FORTRAN_API int FORT_CALL nfmpi_iget_vara_all_ ( int *v1, int *v2, MPI_Offset v3[], MPI_Offset v4[], void*v5, MPI_Offset *v6, MPI_Fint *v7, MPI_Fint *v8 ); 
    106108extern FORTRAN_API int FORT_CALL nfmpi_put_vara_ ( int *v1, int *v2, MPI_Offset v3[], MPI_Offset v4[], void*v5, MPI_Offset *v6, MPI_Fint *v7 ); 
    107109extern FORTRAN_API int FORT_CALL nfmpi_get_vara_ ( int *v1, int *v2, MPI_Offset v3[], MPI_Offset v4[], void*v5, MPI_Offset *v6, MPI_Fint *v7 ); 
  • trunk/src/libf/mpinetcdf_impl.h

    r592 r698  
    6666/* Fortran logical values */ 
    6767 
     68 
    6869#endif 
    6970 
  • trunk/src/libf/put_mvara_allf.c

    r696 r698  
    2222/* Prototypes for the Fortran interfaces */ 
    2323#include "mpifnetcdf.h" 
    24 FORTRAN_API int FORT_CALL nfmpi_put_mvara_all_ ( int *v1, int *v2, MPI_Fint v3[], MPI_Offset**starts v4, MPI_Offset**counts v5, void**buffers v6, MPI_Offset*v7, MPI_Fint *v8 ){ 
     24FORTRAN_API int FORT_CALL nfmpi_put_mvara_all_ ( int *v1, int *v2, MPI_Fint v3[], MPI_Offset** v4, MPI_Offset** v5, void** v6, MPI_Offset*v7, MPI_Fint *v8 ){ 
    2525    int ierr; 
    26     ierr = ncmpi_put_mvara_all( *v1, *v2, v3, v4, v5, v6, v7, (fixme][ *)(v8) ); 
     26    int l3 = *v3 - 1; 
     27    ierr = ncmpi_put_mvara_all( *v1, *v2, l3, v4, v5, v6, v7, (fixme][ *)(v8) ); 
    2728    return ierr; 
    2829} 
  • trunk/src/libf/waitallf.c

    r696 r698  
    88 */ 
    99#include "mpinetcdf_impl.h" 
     10#include "mvar.h" 
    1011 
    1112 
     
    2223/* Prototypes for the Fortran interfaces */ 
    2324#include "mpifnetcdf.h" 
    24 FORTRAN_API int FORT_CALL nfmpi_waitall_ ( int *v1, NCMPI_Request v2[] ){ 
     25FORTRAN_API int FORT_CALL nfmpi_waitall_ ( int *v1, MPI_Fint * v2 ){ 
     26    extern lnc_req *req_head ; 
     27    extern lnc_req *req_tail ; 
    2528    int ierr; 
    26     ierr = ncmpi_waitall( *v1, *v2 ); 
     29    NCMPI_Request *l2_req; 
     30    int i,j; 
     31    lnc_req *tmp_req = NULL; 
     32    l2_req = malloc((*v1)*sizeof(NCMPI_Request)); 
     33    tmp_req = req_head; 
     34  
     35    i = 0; 
     36    while(tmp_req != NULL){ 
     37           l2_req[i]=  tmp_req->req;  
     38           tmp_req = tmp_req->next; 
     39           i++;  
     40    } 
     41   
     42    ierr = ncmpi_waitall( *v1, l2_req ); 
     43    
     44    while(req_head != NULL){ 
     45           tmp_req = req_head; 
     46           req_head = req_head->next; 
     47           free(tmp_req); 
     48    }     
     49        req_tail = NULL; 
     50 
     51    free(l2_req); 
     52         
    2753    return ierr; 
    2854} 
  • trunk/src/libf/waitf.c

    r696 r698  
    88 */ 
    99#include "mpinetcdf_impl.h" 
    10  
     10#include "mvar.h" 
    1111 
    1212#ifdef F77_NAME_UPPER 
     
    2222/* Prototypes for the Fortran interfaces */ 
    2323#include "mpifnetcdf.h" 
    24 FORTRAN_API int FORT_CALL nfmpi_wait_ ( NCMPI_Request*v1 ){ 
     24FORTRAN_API int FORT_CALL nfmpi_wait_ ( MPI_Fint *v1 ){ 
    2525    int ierr; 
    26     ierr = ncmpi_wait( v1 ); 
     26    lnc_req *tmp_req1 = NULL; 
     27    lnc_req *tmp_req2 = NULL; 
     28    NCMPI_Request l1_req; 
     29    extern lnc_req *req_head ; 
     30    extern lnc_req *req_tail ; 
     31//    l1_req = nc_requset_list[*v1] ; 
     32    tmp_req1 = req_head; 
     33    while(tmp_req1 != NULL){ 
     34        if (tmp_req1->reqid == *v1){ 
     35                break; 
     36        } else {  
     37           tmp_req2 = tmp_req1;  
     38           tmp_req1 = tmp_req1->next;  
     39        } 
     40    }   
     41    l1_req = tmp_req1->req; 
     42    ierr = ncmpi_wait( &tmp_req1->req ); 
     43    if (req_head->reqid == *v1){ 
     44        if (req_head->next == NULL){ 
     45                req_head = NULL; 
     46                req_tail = NULL; 
     47        } else { 
     48                req_head = req_head->next; 
     49        } 
     50        free(tmp_req1); 
     51    } else { 
     52        if (req_tail->reqid == tmp_req1->reqid) 
     53                req_tail = tmp_req2; 
     54        else  
     55        tmp_req2 = tmp_req1->next; 
     56        free(tmp_req1); 
     57    }  
     58 
    2759    return ierr; 
     60 
    2861} 
  • trunk/test/Makefile.in

    r678 r698  
    11srcdir = @srcdir@ 
    22VPATH = @srcdir@ 
    3 SUBDIRS = common test_double test_double_int test_float test_int test_dtype nc_test fandc nf_test largefile C mcoll_perf test_check_header testcases 
     3SUBDIRS = common test_double test_double_int test_float test_int test_dtype nc_test fandc nf_test largefile C mcoll_perf mcoll_fortran test_check_header testcases 
    44 
    55all: