diff --git a/src/pio.h b/src/pio.h index 85ffda93ee2..9c90b6b14e5 100644 --- a/src/pio.h +++ b/src/pio.h @@ -36,7 +36,7 @@ #define PIO_OFFSET MPI_OFFSET #define PIO_Offset MPI_Offset #define PIO_MAX_VARS NC_MAX_VARS -#define PIO_MAX_REQUESTS 100*PIO_MAX_VARS +#define PIO_MAX_REQUESTS 100 /** @@ -50,11 +50,9 @@ typedef struct var_desc_t { int record; int ndims; - int type; - bool distributed; - int request; // used for pnetcdf iput calls - int fillrequest; //used for fill in pnetcdf iput for subset rearranger + int request[PIO_MAX_REQUESTS]; // used for pnetcdf iput calls + int nreqs; void *fillbuf; void *iobuf; diff --git a/src/pio_c_put_template.c b/src/pio_c_put_template.c index 3a52029c12b..5e5c7c4c5e8 100644 --- a/src/pio_c_put_template.c +++ b/src/pio_c_put_template.c @@ -50,11 +50,17 @@ int PIO_function() #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_function(); }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; diff --git a/src/pio_darray.c b/src/pio_darray.c index 91e7e4a17cf..b7cf3bc0f13 100644 --- a/src/pio_darray.c +++ b/src/pio_darray.c @@ -270,17 +270,18 @@ void compute_buffer_init(iosystem_desc_t ios) // printf("%s %d %d %ld %ld\n",__FILE__,__LINE__,ios->io_rank,iodesc->llen, tdsize); // ierr = ncmpi_put_varn_all(ncid, vid, iodesc->maxregions, startlist, countlist, // IOBUF, iodesc->llen, iodesc->basetype); - - if(vdesc->request != NC_REQ_NULL){ - printf("%s %d %d\n",__FILE__,__LINE__,vid); + int reqn=0; + + while(vdesc->request[reqn] != NC_REQ_NULL){ + reqn++; } - vdesc->distributed = true; + ierr = ncmpi_bput_varn(ncid, vid, rrcnt, startlist, countlist, - IOBUF, iodesc->llen, iodesc->basetype, &(vdesc->request)); - if(vdesc->request == NC_REQ_NULL){ - vdesc->request = PIO_REQ_NULL; //keeps wait calls in sync + IOBUF, iodesc->llen, iodesc->basetype, vdesc->request+reqn); + if(vdesc->request[reqn] == NC_REQ_NULL){ + vdesc->request[reqn] = PIO_REQ_NULL; //keeps wait calls in sync } - + vdesc->nreqs = reqn; // printf("%s %d %X %d\n",__FILE__,__LINE__,IOBUF,request); for(i=0;irequest != NC_REQ_NULL){ - printf("%s %d %d\n",__FILE__,__LINE__,vid[nv]); - } - vdesc->distributed = true; - + int reqn=0; + while(vdesc->request[reqn] != NC_REQ_NULL){ + reqn++; + } ierr = ncmpi_iput_varn(ncid, vid[nv], rrcnt, startlist, countlist, - bufptr, llen, basetype, &(vdesc->request)); + bufptr, llen, basetype, vdesc->request+reqn); /* ierr = ncmpi_bput_varn(ncid, vid[nv], rrcnt, startlist, countlist, bufptr, llen, basetype, &(vdesc->request)); */ - if(vdesc->request == NC_REQ_NULL){ - vdesc->request = PIO_REQ_NULL; //keeps wait calls in sync + if(vdesc->request[reqn] == NC_REQ_NULL){ + vdesc->request[reqn] = PIO_REQ_NULL; //keeps wait calls in sync } - + vdesc->nreqs = reqn; + printf("%s %d %d %d\n",__FILE__,__LINE__,vdesc->nreqs,vdesc->request[reqn-1]); } for(i=0;imaxfillregions, iodesc->fillregion, iodesc->holegridsize, iodesc->holegridsize, iodesc->num_aiotasks, vdesc0->fillbuf, frame); - for(int nv=0;nvvarlist+vid[nv]; - vdesc->fillrequest = vdesc->request; - vdesc->request = NC_REQ_NULL; - } - } ierr = pio_write_darray_multi_nc(file, nvars, vid, @@ -794,7 +789,7 @@ int PIOc_write_darray_multi(const int ncid, const int vid[], const int ioid, con wmb = wmb->next; } /* flush the previous record before starting a new one. this is collective */ - if((vdesc->request != NC_REQ_NULL) || + if((vdesc->request[0] != NC_REQ_NULL) || (wmb->frame != NULL && vdesc->record != wmb->frame[0])){ needsflush = 2; // flush to disk } @@ -1191,8 +1186,8 @@ int pio_read_darray_nc(file_desc_t *file, io_desc_t *iodesc, const int vid, void } if(tmp_bufsize>0){ - startlist[rrlen] = (PIO_Offset *) malloc(fndims * sizeof(PIO_Offset)); - countlist[rrlen] = (PIO_Offset *) malloc(fndims * sizeof(PIO_Offset)); + startlist[rrlen] = (PIO_Offset *) bget(fndims * sizeof(PIO_Offset)); + countlist[rrlen] = (PIO_Offset *) bget(fndims * sizeof(PIO_Offset)); for(int j=0;jfh, vid, rrlen, startlist, countlist, IOBUF, iodesc->llen, iodesc->basetype); for(i=0;i0 && (prev_type != vdesc->type || - prev_dist != vdesc->distributed || - prev_record != vdesc->record || - (vdesc->request == NC_REQ_NULL && - vdesc->fillrequest == NC_REQ_NULL))){ + if(rcnt>0 && (prev_record != vdesc->record || + vdesc->nreqs==0)){ if(file->iosystem->io_rank==0) printf("%s %d %d\n",__FILE__,__LINE__,rcnt); ierr = ncmpi_wait_all(file->fh, rcnt, request,status); rcnt=0; } prev_record = vdesc->record; - prev_dist = vdesc->distributed; - prev_type = vdesc->type; #endif - // printf("%s %d %d %d %d %d \n",__FILE__,__LINE__,i,rcnt,vdesc->request,vdesc->fillrequest); - - if(vdesc->request != NC_REQ_NULL){ - // if(file->iosystem->io_rank==0) printf("%s %d %d %d %d %d %d\n",__FILE__,__LINE__,i,vdesc->request,vdesc->distributed, vdesc->record, vdesc->type); - request[rcnt++] = max(vdesc->request,NC_REQ_NULL); - vdesc->request = NC_REQ_NULL; - } - if(vdesc->fillrequest != NC_REQ_NULL){ - //if(file->iosystem->io_rank==0) printf("%s %d %d %d %d\n",__FILE__,__LINE__,i,vdesc->fillrequest, vdesc->distributed); - request[rcnt++]=max(vdesc->fillrequest,NC_REQ_NULL); - vdesc->fillrequest = NC_REQ_NULL; + // printf("%s %d %d %d %d %d \n",__FILE__,__LINE__,i,rcnt,vdesc->request,vdesc->fillrequest); + int reqcnt=0; + while(vdesc->request[reqcnt] != NC_REQ_NULL) { + // if(file->iosystem->io_rank==0) printf("%s %d %d %d %d %d %d\n",__FILE__,__LINE__,i,vdesc->request,vdesc->distributed, vdesc->record, vdesc->type); + printf("%s %d %d %d\n",__FILE__,__LINE__,i,vdesc->request[0]); + request[rcnt++] = max(vdesc->request[reqcnt],NC_REQ_NULL); + vdesc->request[reqcnt] = NC_REQ_NULL; + reqcnt++; } + vdesc->nreqs=0; // if(file->iosystem->io_rank < 2) printf("%s %d varid=%d\n",__FILE__,__LINE__,i); #ifdef FLUSH_EVERY_VAR ierr = ncmpi_wait_all(file->fh, rcnt, request,status); @@ -1353,6 +1341,9 @@ int flush_output_buffer(file_desc_t *file, bool force, PIO_Offset addsize) #endif } + if(file->iosystem->io_rank==0){ + printf("%s %d %d\n",__FILE__,__LINE__,rcnt); + } if(rcnt>0){ if(file->iosystem->io_rank==0){ printf("%s %d %d\n",__FILE__,__LINE__,rcnt); diff --git a/src/pio_file.c b/src/pio_file.c index ba8aa17850c..a06898c2434 100644 --- a/src/pio_file.c +++ b/src/pio_file.c @@ -43,10 +43,10 @@ int PIOc_openfile(const int iosysid, int *ncidp, int *iotype, file->varlist[i].record = -1; file->varlist[i].ndims = -1; #ifdef _PNETCDF - file->varlist[i].request = NC_REQ_NULL; - file->varlist[i].fillrequest = NC_REQ_NULL; - file->varlist[i].distributed = false; - file->varlist[i].type = 0; + for(int req=0;reqvarlist[i].request[req] = NC_REQ_NULL; + } + file->varlist[i].nreqs=0; #endif file->varlist[i].fillbuf = NULL; file->varlist[i].iobuf = NULL; @@ -164,10 +164,10 @@ int PIOc_createfile(const int iosysid, int *ncidp, int *iotype, file->varlist[i].record = -1; file->varlist[i].ndims = -1; #ifdef _PNETCDF - file->varlist[i].request = NC_REQ_NULL; - file->varlist[i].fillrequest = NC_REQ_NULL; - file->varlist[i].distributed = false; - file->varlist[i].type = 0; + for(int req=0;reqvarlist[i].request[req] = NC_REQ_NULL; + } + file->varlist[i].nreqs=0; #endif file->varlist[i].fillbuf = NULL; file->varlist[i].iobuf = NULL; diff --git a/src/pio_nc.c b/src/pio_nc.c index 30ce67c8aae..b532b40fa88 100644 --- a/src/pio_nc.c +++ b/src/pio_nc.c @@ -347,11 +347,8 @@ int PIOc_def_var (int ncid, const char *name, nc_type xtype, int ndims, const in ierr = iotype_error(file->iotype,__FILE__,__LINE__); } } -if(ierr != PIO_NOERR) - printf("%s %d %s\n",__FILE__,__LINE__,name); ierr = check_netcdf(file, ierr, errstr,__LINE__); mpierr = MPI_Bcast(varidp , 1, MPI_INT, ios->ioroot, ios->my_comm); - file->varlist[*varidp].type = xtype; return ierr; } diff --git a/src/pio_put_nc.c b/src/pio_put_nc.c index 3435e1c1b44..5bda3ea0287 100644 --- a/src/pio_put_nc.c +++ b/src/pio_put_nc.c @@ -53,11 +53,17 @@ int PIOc_put_vars_uchar (int ncid, int varid, const PIO_Offset start[], const PI #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_vars_uchar(file->fh, varid, start, count, stride, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -124,11 +130,17 @@ int PIOc_put_vars_ushort (int ncid, int varid, const PIO_Offset start[], const P #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_vars_ushort(file->fh, varid, start, count, stride, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -195,11 +207,17 @@ int PIOc_put_vars_ulonglong (int ncid, int varid, const PIO_Offset start[], cons #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_vars_ulonglong(file->fh, varid, start, count, stride, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -266,11 +284,17 @@ int PIOc_put_varm (int ncid, int varid, const PIO_Offset start[], const PIO_Offs #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_varm(file->fh, varid, start, count, stride, imap, buf, bufcount, buftype, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -337,11 +361,17 @@ int PIOc_put_vars_uint (int ncid, int varid, const PIO_Offset start[], const PIO #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_vars_uint(file->fh, varid, start, count, stride, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -408,11 +438,17 @@ int PIOc_put_varm_uchar (int ncid, int varid, const PIO_Offset start[], const PI #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_varm_uchar(file->fh, varid, start, count, stride, imap, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -479,11 +515,17 @@ int PIOc_put_var_ushort (int ncid, int varid, const unsigned short *op) #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_var_ushort(file->fh, varid, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -550,11 +592,17 @@ int PIOc_put_var1_longlong (int ncid, int varid, const PIO_Offset index[], const #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_var1_longlong(file->fh, varid, index, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -621,11 +669,17 @@ int PIOc_put_vara_uchar (int ncid, int varid, const PIO_Offset start[], const PI #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_vara_uchar(file->fh, varid, start, count, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -692,11 +746,17 @@ int PIOc_put_varm_short (int ncid, int varid, const PIO_Offset start[], const PI #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_varm_short(file->fh, varid, start, count, stride, imap, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -763,11 +823,17 @@ int PIOc_put_var1_long (int ncid, int varid, const PIO_Offset index[], const lon #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_var1_long(file->fh, varid, index, ip, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -834,11 +900,17 @@ int PIOc_put_vars_long (int ncid, int varid, const PIO_Offset start[], const PIO #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_vars_long(file->fh, varid, start, count, stride, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -905,11 +977,17 @@ int PIOc_put_var_short (int ncid, int varid, const short *op) #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_var_short(file->fh, varid, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -976,11 +1054,17 @@ int PIOc_put_vara_int (int ncid, int varid, const PIO_Offset start[], const PIO_ #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_vara_int(file->fh, varid, start, count, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -1047,11 +1131,17 @@ int PIOc_put_var1_ushort (int ncid, int varid, const PIO_Offset index[], const u #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_var1_ushort(file->fh, varid, index, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -1118,11 +1208,17 @@ int PIOc_put_vara_text (int ncid, int varid, const PIO_Offset start[], const PIO #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_vara_text(file->fh, varid, start, count, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -1189,11 +1285,17 @@ int PIOc_put_varm_text (int ncid, int varid, const PIO_Offset start[], const PIO #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_varm_text(file->fh, varid, start, count, stride, imap, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -1260,11 +1362,17 @@ int PIOc_put_varm_ushort (int ncid, int varid, const PIO_Offset start[], const P #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_varm_ushort(file->fh, varid, start, count, stride, imap, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -1331,11 +1439,17 @@ int PIOc_put_var_ulonglong (int ncid, int varid, const unsigned long long *op) #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_var_ulonglong(file->fh, varid, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -1402,11 +1516,17 @@ int PIOc_put_var_int (int ncid, int varid, const int *op) #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_var_int(file->fh, varid, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -1473,11 +1593,17 @@ int PIOc_put_var_longlong (int ncid, int varid, const long long *op) #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_var_longlong(file->fh, varid, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -1544,11 +1670,17 @@ int PIOc_put_var_schar (int ncid, int varid, const signed char *op) #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_var_schar(file->fh, varid, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -1615,11 +1747,17 @@ int PIOc_put_var_uint (int ncid, int varid, const unsigned int *op) #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_var_uint(file->fh, varid, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -1686,11 +1824,17 @@ int PIOc_put_var (int ncid, int varid, const void *buf, PIO_Offset bufcount, MPI #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_var(file->fh, varid, buf, bufcount, buftype, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -1757,11 +1901,17 @@ int PIOc_put_vara_ushort (int ncid, int varid, const PIO_Offset start[], const P #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_vara_ushort(file->fh, varid, start, count, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -1828,11 +1978,17 @@ int PIOc_put_vars_short (int ncid, int varid, const PIO_Offset start[], const PI #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_vars_short(file->fh, varid, start, count, stride, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -1899,11 +2055,17 @@ int PIOc_put_vara_uint (int ncid, int varid, const PIO_Offset start[], const PIO #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_vara_uint(file->fh, varid, start, count, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -1970,11 +2132,17 @@ int PIOc_put_vara_schar (int ncid, int varid, const PIO_Offset start[], const PI #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_vara_schar(file->fh, varid, start, count, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -2041,11 +2209,17 @@ int PIOc_put_varm_ulonglong (int ncid, int varid, const PIO_Offset start[], cons #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_varm_ulonglong(file->fh, varid, start, count, stride, imap, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -2112,11 +2286,17 @@ int PIOc_put_var1_uchar (int ncid, int varid, const PIO_Offset index[], const un #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_var1_uchar(file->fh, varid, index, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -2183,11 +2363,17 @@ int PIOc_put_varm_int (int ncid, int varid, const PIO_Offset start[], const PIO_ #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_varm_int(file->fh, varid, start, count, stride, imap, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -2254,11 +2440,17 @@ int PIOc_put_vars_schar (int ncid, int varid, const PIO_Offset start[], const PI #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_vars_schar(file->fh, varid, start, count, stride, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -2325,11 +2517,17 @@ int PIOc_put_var1 (int ncid, int varid, const PIO_Offset index[], const void *bu #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_var1(file->fh, varid, index, buf, bufcount, buftype, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -2396,11 +2594,17 @@ int PIOc_put_vara_float (int ncid, int varid, const PIO_Offset start[], const PI #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_vara_float(file->fh, varid, start, count, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -2467,11 +2671,17 @@ int PIOc_put_var1_float (int ncid, int varid, const PIO_Offset index[], const fl #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_var1_float(file->fh, varid, index, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -2538,11 +2748,17 @@ int PIOc_put_varm_float (int ncid, int varid, const PIO_Offset start[], const PI #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_varm_float(file->fh, varid, start, count, stride, imap, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -2609,11 +2825,17 @@ int PIOc_put_var1_text (int ncid, int varid, const PIO_Offset index[], const cha #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_var1_text(file->fh, varid, index, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -2680,11 +2902,17 @@ int PIOc_put_vars_text (int ncid, int varid, const PIO_Offset start[], const PIO #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_vars_text(file->fh, varid, start, count, stride, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -2751,11 +2979,17 @@ int PIOc_put_varm_long (int ncid, int varid, const PIO_Offset start[], const PIO #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_varm_long(file->fh, varid, start, count, stride, imap, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -2822,11 +3056,17 @@ int PIOc_put_vars_double (int ncid, int varid, const PIO_Offset start[], const P #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_vars_double(file->fh, varid, start, count, stride, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -2893,11 +3133,17 @@ int PIOc_put_vara_longlong (int ncid, int varid, const PIO_Offset start[], const #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_vara_longlong(file->fh, varid, start, count, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -2964,11 +3210,17 @@ int PIOc_put_var_double (int ncid, int varid, const double *op) #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_var_double(file->fh, varid, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -3035,11 +3287,17 @@ int PIOc_put_var_float (int ncid, int varid, const float *op) #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_var_float(file->fh, varid, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -3106,11 +3364,17 @@ int PIOc_put_var1_ulonglong (int ncid, int varid, const PIO_Offset index[], cons #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_var1_ulonglong(file->fh, varid, index, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -3177,11 +3441,17 @@ int PIOc_put_varm_uint (int ncid, int varid, const PIO_Offset start[], const PIO #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_varm_uint(file->fh, varid, start, count, stride, imap, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -3248,11 +3518,17 @@ int PIOc_put_var1_uint (int ncid, int varid, const PIO_Offset index[], const uns #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_var1_uint(file->fh, varid, index, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -3319,11 +3595,17 @@ int PIOc_put_var1_int (int ncid, int varid, const PIO_Offset index[], const int #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_var1_int(file->fh, varid, index, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -3390,11 +3672,17 @@ int PIOc_put_vars_float (int ncid, int varid, const PIO_Offset start[], const PI #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_vars_float(file->fh, varid, start, count, stride, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -3461,11 +3749,17 @@ int PIOc_put_vara_short (int ncid, int varid, const PIO_Offset start[], const PI #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_vara_short(file->fh, varid, start, count, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -3532,11 +3826,17 @@ int PIOc_put_var1_schar (int ncid, int varid, const PIO_Offset index[], const si #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_var1_schar(file->fh, varid, index, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -3603,11 +3903,17 @@ int PIOc_put_vara_ulonglong (int ncid, int varid, const PIO_Offset start[], cons #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_vara_ulonglong(file->fh, varid, start, count, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -3674,11 +3980,17 @@ int PIOc_put_varm_double (int ncid, int varid, const PIO_Offset start[], const P #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_varm_double(file->fh, varid, start, count, stride, imap, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -3745,11 +4057,17 @@ int PIOc_put_vara (int ncid, int varid, const PIO_Offset start[], const PIO_Offs #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_vara(file->fh, varid, start, count, buf, bufcount, buftype, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -3816,11 +4134,17 @@ int PIOc_put_vara_long (int ncid, int varid, const PIO_Offset start[], const PIO #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_vara_long(file->fh, varid, start, count, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -3887,11 +4211,17 @@ int PIOc_put_var1_double (int ncid, int varid, const PIO_Offset index[], const d #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_var1_double(file->fh, varid, index, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -3958,11 +4288,17 @@ int PIOc_put_varm_schar (int ncid, int varid, const PIO_Offset start[], const PI #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_varm_schar(file->fh, varid, start, count, stride, imap, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -4029,11 +4365,17 @@ int PIOc_put_var_text (int ncid, int varid, const char *op) #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_var_text(file->fh, varid, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -4100,11 +4442,17 @@ int PIOc_put_vars_int (int ncid, int varid, const PIO_Offset start[], const PIO_ #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_vars_int(file->fh, varid, start, count, stride, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -4171,11 +4519,17 @@ int PIOc_put_var1_short (int ncid, int varid, const PIO_Offset index[], const sh #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_var1_short(file->fh, varid, index, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -4242,11 +4596,17 @@ int PIOc_put_vars_longlong (int ncid, int varid, const PIO_Offset start[], const #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_vars_longlong(file->fh, varid, start, count, stride, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -4313,11 +4673,17 @@ int PIOc_put_vara_double (int ncid, int varid, const PIO_Offset start[], const P #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_vara_double(file->fh, varid, start, count, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -4384,11 +4750,17 @@ int PIOc_put_vars (int ncid, int varid, const PIO_Offset start[], const PIO_Offs #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_vars(file->fh, varid, start, count, stride, buf, bufcount, buftype, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -4455,11 +4827,17 @@ int PIOc_put_var_uchar (int ncid, int varid, const unsigned char *op) #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_var_uchar(file->fh, varid, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -4526,11 +4904,17 @@ int PIOc_put_var_long (int ncid, int varid, const long *op) #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_var_long(file->fh, varid, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; @@ -4597,11 +4981,17 @@ int PIOc_put_varm_longlong (int ncid, int varid, const PIO_Offset start[], const #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: vdesc = file->varlist + varid; + int reqn; + reqn = vdesc->nreqs; + request = vdesc->request; + while(*request != NC_REQ_NULL){ + reqn++; + request = vdesc->request+reqn; + } if(ios->io_rank==0){ - request = &(vdesc->request); ierr = ncmpi_bput_varm_longlong(file->fh, varid, start, count, stride, imap, op, request);; }else{ - vdesc->request = PIO_REQ_NULL; + *request = PIO_REQ_NULL; } flush_output_buffer(file, false, 0); break; diff --git a/src/pionfput_mod.F90.in b/src/pionfput_mod.F90.in index 55d1145049f..e555010cd9a 100644 --- a/src/pionfput_mod.F90.in +++ b/src/pionfput_mod.F90.in @@ -109,9 +109,10 @@ contains type (File_desc_t), intent(inout) :: File integer, intent(in) :: varid, index(:) character(len=*), intent(in) :: ival + character, allocatable :: cval(:) + integer :: i #ifdef DOTHIS integer :: clen, i - character, allocatable :: cval(:) integer(C_SIZE_T), allocatable :: cindex(:) interface integer(C_INT) function PIOc_put_var1_text(ncid, varid, index, op) & @@ -153,7 +154,14 @@ contains allocate(count(ndims)) count = 1 count(1) = len(ival) - ierr = put_vara_1d_text(File,varid, index, count, (/ival/)) + allocate(cval(count(1)+1)) + cval = C_NULL_CHAR + do i=1,len_trim(ival) + cval(i) = ival(i:i) + end do + +!print *,__FILE__,__LINE__,index,count,ival + ierr = put_vara_1d_text(File,varid, index, count, cval) deallocate(count) #endif end function put_var1_text @@ -473,6 +481,7 @@ contains sd = size(ival) allocate(cval(clen*sd)) call Fstring2Cstring_{DIMS}d (ival, cval) + ierr = PIOc_put_vara_text(file%fh, varid-1, cstart, ccount, cval) deallocate(cval, cstart, ccount)