summaryrefslogtreecommitdiffstats
path: root/vms
diff options
context:
space:
mode:
authorElena Pourmal <epourmal@hdfgroup.org>2006-07-28 15:20:07 (GMT)
committerElena Pourmal <epourmal@hdfgroup.org>2006-07-28 15:20:07 (GMT)
commit4b72fd4f55de954384dd55c9d1ee458fdd06aec8 (patch)
treecf5f22977cbc72f29e258a1809b9c9395b26424d /vms
parentc7384f49e030fb296629300ac6b2ce9981a05cfd (diff)
downloadhdf5-4b72fd4f55de954384dd55c9d1ee458fdd06aec8.zip
hdf5-4b72fd4f55de954384dd55c9d1ee458fdd06aec8.tar.gz
hdf5-4b72fd4f55de954384dd55c9d1ee458fdd06aec8.tar.bz2
[svn-r12514] Scale+offset filter is not supported by h5repack; commented out the tests.
This command script cannot tell reliably if tests passed. More work is needed.
Diffstat (limited to 'vms')
-rw-r--r--vms/tools/h5repack/check_h5repack.com45
1 files changed, 26 insertions, 19 deletions
diff --git a/vms/tools/h5repack/check_h5repack.com b/vms/tools/h5repack/check_h5repack.com
index c482012..e2faeca 100644
--- a/vms/tools/h5repack/check_h5repack.com
+++ b/vms/tools/h5repack/check_h5repack.com
@@ -41,11 +41,11 @@ $ CALL TOOLTEST test3.h5
$ CALL TOOLTEST test4.h5
$ CALL TOOLTEST test5.h5
$
-$ # use test4.h5 to write some filters (this file has no filters)
+$! # use test4.h5 to write some filters (this file has no filters)
$
$! # gzip with individual object
$ CALL TOOLTEST test4.h5 "-f dset1:""GZIP""=1 -l dset1:""CHUNK""=20x10"
-$
+$!
$! # gzip for all
$ CALL TOOLTEST test4.h5 "-f ""GZIP""=1"
$!
@@ -54,7 +54,7 @@ $ CALL TOOLTEST test4.h5 "-f dset2:""SHUF"" -l dset2:""CHUNK""=20x10"
$!
$!
$! # shuffle for all
-$ CALL TOOLTEST test4.h5 "-f """HUF"""
+$ CALL TOOLTEST test4.h5 "-f ""SHUF"""
$!
$! # fletcher32 with individual object
$ CALL TOOLTEST test4.h5 "-f dset2:""FLET"" -l dset2:""CHUNK""=20x10"
@@ -94,13 +94,13 @@ $! # nbit add
$ CALL TOOLTEST test_nbit.h5 "-f dset_int31:""NBIT"""
$!
$! # scaleoffset add
-$ CALL TOOLTEST test_scaleoffset.h5 "-f dset_none:""S""+""O""=31"
+$! CALL TOOLTEST test_scaleoffset.h5 "-f dset_none:""S+O""=31"
$!
$! # scaleoffset copy
-$ CALL TOOLTEST test_scaleoffset.h5
+$! CALL TOOLTEST test_scaleoffset.h5
$!
$! # scaleoffset remove
-$ CALL TOOLTEST test_scaleoffset.h5 "-f dset_scaleoffset:""NONE"""
+$! CALL TOOLTEST test_scaleoffset.h5 "-f dset_scaleoffset:""NONE"""
$!
$! #limit
$ CALL TOOLTEST test4.h5 "-f ""GZIP""=1 -m 1024"
@@ -114,7 +114,7 @@ $! # layout options (these files have no filters)
$! #########################################################
$!
$ CALL TOOLTEST test4.h5 "-l dset2:""CHUNK""=20x10"
-$ CALL TOOLTEST test4.h5 "-l """HUNK""=20x10"
+$ CALL TOOLTEST test4.h5 "-l ""CHUNK""=20x10"
$ CALL TOOLTEST test4.h5 "-l dset2:""CONTI"""
$ CALL TOOLTEST test4.h5 "-l ""CONTI"""
$ CALL TOOLTEST test4.h5 "-l dset2:""COMPA"""
@@ -140,32 +140,39 @@ $TOOLTEST: SUBROUTINE
$ len = F$LENGTH(P1)
$ base = F$EXTRACT(0,len-3,P1)
-$ output = base + "out.h5"
+$ output_file = base + "out.h5"
$ output_err = base + ".err"
+$ output_out = base + ".out"
$
$ begin = "Testing h5repack"
$ !
$ ! Run the test and save output in the 'actual' file
$ !
-$ define/nolog sys$error 'output_err'
+$! define/nolog sys$error 'output_err'
+$! define/nolog sys$output 'output_out'
$ ON ERROR THEN CONTINUE
-$ h5repack -i 'P1 -o 'output' 'P2
-$ h5diff 'P1 'output'
-$ deassign sys$error
-$ if F$SEARCH(output_err) .NES. ""
-$ then
-$ result = "PASSED"
+$ h5repack -i 'P1 -o 'output_file' 'P2
+$ h5diff 'P1 'output_file'
+$! deassign sys$error
+$! deassign sys$output
+$! if F$SEARCH(output_err) .EQS. "" .AND. F$SEARCH(output_out) .EQS. ""
+$! then
+$! result = "PASSED"
+$! line = F$FAO("!16AS !20AS !43AS !70AS", begin, P1, P2, result)
+$! else
+$! result = "*FAILED*"
+$! line = F$FAO("!16AS !20AS !42AS !69AS", begin, P1, P2, result)
+$! endif
+$ result = "......"
$ line = F$FAO("!16AS !20AS !43AS !70AS", begin, P1, P2, result)
-$ else
-$ result = "*FAILED*"
-$ line = F$FAO("!16AS !20AS !42AS !69AS", begin, P1, P2, result)
-$ endif
+
$ !
$ ! Print test result
$ !
$ write sys$output line
$ !
$ del *out.h5;*
+$! del *.out;*
$ !
$ENDSUBROUTINE
00 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907
/*
 * Copyright (C) 2000-2001 NCSA
 *		           All rights reserved.
 *
 * Programmer: 	Quincey Koziol <koziol@ncsa.uiuc.edu>
 *	       	Thursday, September 28, 2000
 *
 * Purpose:	Provides I/O facilities for sequences of bytes stored with various 
 *      layout policies.  These routines are similar to the H5Farray.c routines,
 *      these deal in terms of byte offsets and lengths, not coordinates and
 *      hyperslab sizes.
 *
 */

#define H5F_PACKAGE		/*suppress error about including H5Fpkg	  */

#include "H5private.h"
#include "H5Dprivate.h"
#include "H5Eprivate.h"
#include "H5Fpkg.h"
#include "H5FDprivate.h"	/*file driver				  */
#include "H5Iprivate.h"
#include "H5MFprivate.h"
#include "H5MMprivate.h"	/*memory management			  */
#include "H5Oprivate.h"
#include "H5Pprivate.h"
#include "H5Vprivate.h"

/* MPIO driver functions are needed for some special checks */
#include "H5FDmpio.h"

/* Interface initialization */
#define PABLO_MASK	H5Fseq_mask
#define INTERFACE_INIT	NULL
static intn interface_initialize_g = 0;


/*-------------------------------------------------------------------------
 * Function:	H5F_seq_read
 *
 * Purpose:	Reads a sequence of bytes from a file dataset into a buffer in
 *      in memory.  The data is read from file F and the array's size and
 *      storage information is in LAYOUT.  External files are described
 *      according to the external file list, EFL.  The sequence offset is 
 *      FILE_OFFSET in the file (offsets are
 *      in terms of bytes) and the size of the hyperslab is SEQ_LEN. The
 *		total size of the file array is implied in the LAYOUT argument.
 *
 * Return:	Non-negative on success/Negative on failure
 *
 * Programmer:	Quincey Koziol
 *              Thursday, September 28, 2000
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5F_seq_read(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout,
         const struct H5O_pline_t *pline, const H5O_fill_t *fill,
         const struct H5O_efl_t *efl, const H5S_t *file_space, size_t elmt_size,
         hsize_t seq_len, hsize_t file_offset, void *buf/*out*/)
{
    hsize_t	dset_dims[H5O_LAYOUT_NDIMS];	/* dataspace dimensions */
    hssize_t    coords[H5O_LAYOUT_NDIMS];	/* offset of hyperslab in dataspace */
    hsize_t	hslab_size[H5O_LAYOUT_NDIMS];	/* hyperslab size in dataspace*/
    hsize_t     down_size[H5O_LAYOUT_NDIMS];    /* Cumulative yperslab sizes (in elements) */
    hsize_t     acc;    /* Accumulator for hyperslab sizes (in elements) */
    intn ndims;
    hsize_t	max_data = 0;			/*bytes in dataset	*/
    haddr_t	addr=0;				/*address in file	*/
    uintn	u;				/*counters		*/
    intn	i,j;				/*counters		*/
#ifdef H5_HAVE_PARALLEL
    H5FD_mpio_xfer_t xfer_mode=H5FD_MPIO_INDEPENDENT;
#endif
   
    FUNC_ENTER(H5F_seq_read, FAIL);

    /* Check args */
    assert(f);
    assert(layout);
    assert(buf);

#ifdef H5_HAVE_PARALLEL
    {
        /* Get the transfer mode */
        H5D_xfer_t *dxpl;
        H5FD_mpio_dxpl_t *dx;

        if (H5P_DEFAULT!=dxpl_id && (dxpl=H5I_object(dxpl_id)) &&
                H5FD_MPIO==dxpl->driver_id && (dx=dxpl->driver_info) &&
                H5FD_MPIO_INDEPENDENT!=dx->xfer_mode) {
            xfer_mode = dx->xfer_mode;
        }
    }

    /* Collective MPIO access is unsupported for non-contiguous datasets */
    if (H5D_CONTIGUOUS!=layout->type && H5FD_MPIO_COLLECTIVE==xfer_mode) {
        HRETURN_ERROR (H5E_DATASET, H5E_READERROR, FAIL,
           "collective access on non-contiguous datasets not supported yet");
    }
#endif

    switch (layout->type) {
        case H5D_CONTIGUOUS:
            /* Filters cannot be used for contiguous data. */
            if (pline && pline->nfilters>0) {
                HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL,
                      "filters are not allowed for contiguous data");
            }
            
            /*
             * Initialize loop variables.  The loop is a multi-dimensional loop
             * that counts from SIZE down to zero and IDX is the counter.  Each
             * element of IDX is treated as a digit with IDX[0] being the least
             * significant digit.
             */
            if (efl && efl->nused>0) {
                addr = 0;
            } else {
                addr = layout->addr;

                /* Compute the size of the dataset in bytes */
                for(u=0, max_data=1; u<layout->ndims; u++)
                    max_data *= layout->dim[u];

                /* Adjust the maximum size of the data by the offset into it */
                max_data -= file_offset;
            }
            addr += file_offset;

            /*
             * Now begin to walk through the array, copying data from disk to
             * memory.
             */
#ifdef H5_HAVE_PARALLEL
            if (H5FD_MPIO_COLLECTIVE==xfer_mode) {
                /*
                 * Currently supports same number of collective access. Need to
                 * be changed LATER to combine all reads into one collective MPIO
                 * call.
                 */
                unsigned long max, min, temp;

                temp = seq_len;
                assert(temp==seq_len);	/* verify no overflow */
                MPI_Allreduce(&temp, &max, 1, MPI_UNSIGNED_LONG, MPI_MAX,
                      H5FD_mpio_communicator(f->shared->lf));
                MPI_Allreduce(&temp, &min, 1, MPI_UNSIGNED_LONG, MPI_MIN,
                      H5FD_mpio_communicator(f->shared->lf));
#ifdef AKC
                printf("seq_len=%lu, min=%lu, max=%lu\n", temp, min, max);
#endif
                if (max != min)
                    HRETURN_ERROR(H5E_DATASET, H5E_READERROR, FAIL,
                      "collective access with unequal number of blocks not supported yet");
            }
#endif

            /* Read directly from file if the dataset is in an external file */
            if (efl && efl->nused>0) {
                /* Note: We can't use data sieve buffers for datasets in external files
                 *  because the 'addr' of all external files is set to 0 (above) and
                 *  all datasets in external files would alias to the same set of
                 *  file offsets, totally mixing up the data sieve buffer information. -QAK
                 */
                if (H5O_efl_read(f, efl, addr, seq_len, buf)<0) {
                    HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL,
                          "external data read failed");
                }
            } else {
                if (H5F_contig_read(f, max_data, H5FD_MEM_DRAW, addr, seq_len, dxpl_id, buf)<0) {
                    HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL,
                              "block read failed");
                }
            } /* end else */
            break;

        case H5D_CHUNKED:
        {
            /*
             * This method is unable to access external raw data files 
             */
            if (efl && efl->nused>0) {
                HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL,
                      "chunking and external files are mutually exclusive");
            }
            /* Compute the file offset coordinates and hyperslab size */
            if((ndims=H5S_get_simple_extent_dims(file_space,dset_dims,NULL))<0)
                HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL, "unable to retrieve dataspace dimensions");
            
#ifdef QAK
            /* The library shouldn't be reading partial elements currently */
            assert(seq_len%elmt_size!=0);
            assert(addr%elmt_size!=0);
#endif /* QAK */

#ifdef QAK
/* Print out the file offsets & hyperslab sizes */
{
    static int count=0;

    if(count<1000000) {
        printf("%s: elmt_size=%d, addr=%d, seq_len=%d\n",FUNC,(int)elmt_size,(int)addr,(int)seq_len);
        printf("%s: file_offset=%d\n",FUNC,(int)file_offset);
        count++;
    }
}
#endif /* QAK */
            /* Set location in dataset from the file_offset */
            addr=file_offset;

            /* Convert the bytes into elements */
            seq_len/=elmt_size;
            addr/=elmt_size;

            /* Build the array of cumulative hyperslab sizes */
            for(acc=1, i=(ndims-1); i>=0; i--) {
                down_size[i]=acc;
                acc*=dset_dims[i];
#ifdef QAK
printf("%s: acc=%ld, down_size[%d]=%ld\n",FUNC,(long)acc,i,(long)down_size[i]);
#endif /* QAK */
            } /* end for */

            /* Compute the hyperslab offset from the address given */
            for(i=ndims-1; i>=0; i--) {
                coords[i]=addr%dset_dims[i];
                addr/=dset_dims[i];
#ifdef QAK
printf("%s: addr=%lu, coords[%d]=%ld\n",FUNC,(unsigned long)addr,i,(long)coords[i]);
#endif /* QAK */
            } /* end for */
            coords[ndims]=0;   /* No offset for element info */
#ifdef QAK
printf("%s: addr=%lu, coords[%d]=%ld\n",FUNC,(unsigned long)addr,ndims,(long)coords[ndims]);
#endif /* QAK */

            /*
             * Peel off initial partial hyperslabs until we've got a hyperslab which starts
             *      at coord[n]==0 for dimensions 1->(ndims-1)  (i.e. starting at coordinate
             *      zero for all dimensions except the slowest changing one
             */
            for(i=ndims-1; i>0 && seq_len>=down_size[i]; i--) {
                hsize_t partial_size;       /* Size of the partial hyperslab in bytes */

                /* Check if we have a partial hyperslab in this lower dimension */
                if(coords[i]>0) {
#ifdef QAK
printf("%s: Need to get hyperslab, seq_len=%ld, coords[%d]=%ld\n",FUNC,(long)seq_len,i,(long)coords[i]);
#endif /* QAK */
                    /* Reset the partial hyperslab size */
                    partial_size=1;

                    /* Build the partial hyperslab information */
                    for(j=0; j<ndims; j++) {
                        if(i==j)
                            hslab_size[j]=MIN(seq_len/down_size[i],dset_dims[i]-coords[i]);
                        else
                            if(j>i)
                                hslab_size[j]=dset_dims[j];
                            else
                                hslab_size[j]=1;
                        partial_size*=hslab_size[j];
#ifdef QAK
printf("%s: partial_size=%lu, hslab_size[%d]=%ld\n",FUNC,(unsigned long)partial_size,j,(long)hslab_size[j]);
#endif /* QAK */
                    } /* end for */
                    hslab_size[ndims]=elmt_size;   /* basic hyperslab size is the element */
#ifdef QAK
printf("%s: partial_size=%lu, hslab_size[%d]=%ld\n",FUNC,(unsigned long)partial_size,ndims,(long)hslab_size[ndims]);
#endif /* QAK */

                    /* Read in the partial hyperslab */
                    if (H5F_istore_read(f, dxpl_id, layout, pline, fill, coords,
                                 hslab_size, buf)<0) {
                        HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "chunked read failed");
                    }

                    /* Increment the buffer offset */
                    buf=(unsigned char *)buf+partial_size;

                    /* Decrement the length of the sequence to read */
                    seq_len-=partial_size;

                    /* Correct the coords array */
                    coords[i]=0;
                    coords[i-1]++;
                } /* end if */
            } /* end for */
#ifdef QAK
printf("%s: after reading initial partial hyperslabs, seq_len=%lu\n",FUNC,(unsigned long)seq_len);
#endif /* QAK */

            /* Check if there is more than just a partial hyperslab to read */
            if(seq_len>=down_size[0]) {
                hsize_t tmp_seq_len;    /* Temp. size of the sequence in elements */
                hsize_t full_size;      /* Size of the full hyperslab in bytes */

                /* Get the sequence length for computing the hyperslab sizes */
                tmp_seq_len=seq_len;

                /* Reset the size of the hyperslab read in */
                full_size=1;

                /* Compute the hyperslab size from the length given */
                for(i=ndims-1; i>=0; i--) {
                    /* Check if the hyperslab is wider than the width of the dimension */
                    if(tmp_seq_len>dset_dims[i]) {
                        assert(0==coords[i]);
                        hslab_size[i]=dset_dims[i];
                    } /* end if */
                    else 
                        hslab_size[i]=tmp_seq_len;

                    /* compute the number of elements read in */
                    full_size*=hslab_size[i];

                    /* Fold the length into the length in the next highest dimension */
                    tmp_seq_len/=dset_dims[i];
#ifdef QAK
printf("%s: tmp_seq_len=%lu, hslab_size[%d]=%ld\n",FUNC,(unsigned long)tmp_seq_len,i,(long)hslab_size[i]);
#endif /* QAK */

                    /* Make certain the hyperslab sizes don't go less than 1 for dimensions less than 0*/
                    assert(tmp_seq_len>=1 || i==0);
                } /* end for */
                hslab_size[ndims]=elmt_size;   /* basic hyperslab size is the element */

#ifdef QAK
/* Print out the file offsets & hyperslab sizes */
{
    static int count=0;

    if(count<1000000) {
        printf("%s: elmt_size=%d, addr=%d, full_size=%ld, tmp_seq_len=%ld seq_len=%ld\n",FUNC,(int)elmt_size,(int)addr,(long)full_size,(long)tmp_seq_len,(long)seq_len);
        for(i=0; i<ndims; i++)
            printf("%s: dset_dims[%d]=%d\n",FUNC,i,(int)dset_dims[i]);
        for(i=0; i<=ndims; i++)
            printf("%s: coords[%d]=%d, hslab_size[%d]=%d\n",FUNC,i,(int)coords[i],(int)i,(int)hslab_size[i]);
        count++;
    }
}
#endif /* QAK */

                /* Read the full hyperslab in */
                if (H5F_istore_read(f, dxpl_id, layout, pline, fill, coords,
                             hslab_size, buf)<0) {
                    HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "chunked read failed");
                }

                /* Increment the buffer offset */
                buf=(unsigned char *)buf+full_size;

                /* Decrement the sequence length left */
                seq_len-=full_size;

                /* Increment coordinate of slowest changing dimension */
                coords[0]+=hslab_size[0];

            } /* end if */
#ifdef QAK
printf("%s: after reading 'middle' full hyperslabs, seq_len=%lu\n",FUNC,(unsigned long)seq_len);
#endif /* QAK */

            /*
             * Peel off final partial hyperslabs until we've finished reading all the data
             */
            if(seq_len>0) {
                hsize_t partial_size;       /* Size of the partial hyperslab in bytes */

                /*
                 * Peel off remaining partial hyperslabs, from the next-slowest dimension
                 *  on down to the next-to-fastest changing dimension
                 */
                for(i=1; i<(ndims-1); i++) {
                    /* Check if there are enough elements to read in a row in this dimension */
                    if(seq_len>=down_size[i]) {
#ifdef QAK
printf("%s: seq_len=%ld, down_size[%d]=%ld\n",FUNC,(long)seq_len,i+1,(long)down_size[i+1]);
#endif /* QAK */
                        /* Reset the partial hyperslab size */
                        partial_size=1;

                        /* Build the partial hyperslab information */
                        for(j=0; j<ndims; j++) {
                            if(j<i)
                                hslab_size[j]=1;
                            else
                                if(j==i)
                                    hslab_size[j]=seq_len/down_size[j];
                                else
                                    hslab_size[j]=dset_dims[j];

                            partial_size*=hslab_size[j];
#ifdef QAK
printf("%s: partial_size=%lu, coords[%d]=%ld, hslab_size[%d]=%ld\n",FUNC,(unsigned long)partial_size,j,(long)coords[j],j,(long)hslab_size[j]);
#endif /* QAK */
                        } /* end for */
                        hslab_size[ndims]=elmt_size;   /* basic hyperslab size is the element */
#ifdef QAK
printf("%s: partial_size=%lu, coords[%d]=%ld, hslab_size[%d]=%ld\n",FUNC,(unsigned long)partial_size,ndims,(long)coords[ndims],ndims,(long)hslab_size[ndims]);
#endif /* QAK */

                        /* Read in the partial hyperslab */
                        if (H5F_istore_read(f, dxpl_id, layout, pline, fill, coords,
                                     hslab_size, buf)<0) {
                            HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "chunked read failed");
                        }

                        /* Increment the buffer offset */
                        buf=(unsigned char *)buf+partial_size;

                        /* Decrement the length of the sequence to read */
                        seq_len-=partial_size;

                        /* Correct the coords array */
                        coords[i]=hslab_size[i];
                    } /* end if */
                } /* end for */
#ifdef QAK
printf("%s: after reading trailing hyperslabs for all but the last dimension, seq_len=%ld\n",FUNC,(long)seq_len);
#endif /* QAK */

                /* Handle fastest changing dimension if there are any elements left */
                if(seq_len>0) {
#ifdef QAK
printf("%s: i=%d, seq_len=%ld\n",FUNC,ndims-1,(long)seq_len);
#endif /* QAK */
                    assert(seq_len<dset_dims[ndims-1]);

                    /* Reset the partial hyperslab size */
                    partial_size=1;

                    /* Build the partial hyperslab information */
                    for(j=0; j<ndims; j++) {
                        if(j==(ndims-1))
                            hslab_size[j]=seq_len;
                        else
                            hslab_size[j]=1;

                        partial_size*=hslab_size[j];
#ifdef QAK
printf("%s: partial_size=%lu, coords[%d]=%ld, hslab_size[%d]=%ld\n",FUNC,(unsigned long)partial_size,j,(long)coords[j],j,(long)hslab_size[j]);
#endif /* QAK */
                    } /* end for */
                    hslab_size[ndims]=elmt_size;   /* basic hyperslab size is the element */
#ifdef QAK
printf("%s: partial_size=%lu, coords[%d]=%ld, hslab_size[%d]=%ld\n",FUNC,(unsigned long)partial_size,ndims,(long)coords[ndims],ndims,(long)hslab_size[ndims]);
#endif /* QAK */

                    /* Read in the partial hyperslab */
                    if (H5F_istore_read(f, dxpl_id, layout, pline, fill, coords,
                                 hslab_size, buf)<0) {
                        HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "chunked read failed");
                    }

                    /* Double-check the amount read in */
                    assert(seq_len==partial_size);
                } /* end if */
            } /* end if */
        }
            break;

        default:
            assert("not implemented yet" && 0);
            HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL, "unsupported storage layout");
    }   /* end switch() */

    FUNC_LEAVE(SUCCEED);
}   /* H5F_seq_read() */


/*-------------------------------------------------------------------------
 * Function:	H5F_seq_write
 *
 * Purpose:	Writes a sequence of bytes to a file dataset from a buffer in
 *      in memory.  The data is written to file F and the array's size and
 *      storage information is in LAYOUT.  External files are described
 *      according to the external file list, EFL.  The sequence offset is 
 *      FILE_OFFSET in the file (offsets are
 *      in terms of bytes) and the size of the hyperslab is SEQ_LEN. The
 *		total size of the file array is implied in the LAYOUT argument.
 *
 * Return:	Non-negative on success/Negative on failure
 *
 * Programmer:	Quincey Koziol
 *              Monday, October 9, 2000
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5F_seq_write(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout,
         const struct H5O_pline_t *pline, const H5O_fill_t *fill,
         const struct H5O_efl_t *efl, const H5S_t *file_space, size_t elmt_size,
         hsize_t seq_len, hsize_t file_offset, const void *buf)
{
    hsize_t	dset_dims[H5O_LAYOUT_NDIMS];	/* dataspace dimensions */
    hssize_t    coords[H5O_LAYOUT_NDIMS];	/* offset of hyperslab in dataspace */
    hsize_t	hslab_size[H5O_LAYOUT_NDIMS];	/* hyperslab size in dataspace*/
    hsize_t     down_size[H5O_LAYOUT_NDIMS];    /* Cumulative hyperslab sizes (in elements) */
    hsize_t     acc;            /* Accumulator for hyperslab sizes (in elements) */
    intn ndims;
    hsize_t	max_data = 0;			/*bytes in dataset	*/
    haddr_t	addr;				/*address in file	*/
    uintn	u;				/*counters		*/
    intn	i,j;				/*counters		*/
#ifdef H5_HAVE_PARALLEL
    H5FD_mpio_xfer_t xfer_mode=H5FD_MPIO_INDEPENDENT;
#endif
   
    FUNC_ENTER(H5F_seq_write, FAIL);

    /* Check args */
    assert(f);
    assert(layout);
    assert(buf);

#ifdef H5_HAVE_PARALLEL
    {
        /* Get the transfer mode */
        H5D_xfer_t *dxpl;
        H5FD_mpio_dxpl_t *dx;

        if (H5P_DEFAULT!=dxpl_id && (dxpl=H5I_object(dxpl_id)) &&
                H5FD_MPIO==dxpl->driver_id && (dx=dxpl->driver_info) &&
                H5FD_MPIO_INDEPENDENT!=dx->xfer_mode) {
            xfer_mode = dx->xfer_mode;
        }
    }

    /* Collective MPIO access is unsupported for non-contiguous datasets */
    if (H5D_CONTIGUOUS!=layout->type && H5FD_MPIO_COLLECTIVE==xfer_mode) {
        HRETURN_ERROR (H5E_DATASET, H5E_WRITEERROR, FAIL,
           "collective access on non-contiguous datasets not supported yet");
    }
#endif

    switch (layout->type) {
        case H5D_CONTIGUOUS:
            /* Filters cannot be used for contiguous data. */
            if (pline && pline->nfilters>0) {
                HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
                      "filters are not allowed for contiguous data");
            }
            
            /*
             * Initialize loop variables.  The loop is a multi-dimensional loop
             * that counts from SIZE down to zero and IDX is the counter.  Each
             * element of IDX is treated as a digit with IDX[0] being the least
             * significant digit.
             */
            if (efl && efl->nused>0) {
                addr = 0;
            } else {
                addr = layout->addr;

                /* Compute the size of the dataset in bytes */
                for(u=0, max_data=1; u<layout->ndims; u++)
                    max_data *= layout->dim[u];

                /* Adjust the maximum size of the data by the offset into it */
                max_data -= file_offset;
            }
            addr += file_offset;

            /*
             * Now begin to walk through the array, copying data from disk to
             * memory.
             */
#ifdef H5_HAVE_PARALLEL
            if (H5FD_MPIO_COLLECTIVE==xfer_mode) {
                /*
                 * Currently supports same number of collective access. Need to
                 * be changed LATER to combine all reads into one collective MPIO
                 * call.
                 */
                unsigned long max, min, temp;

                temp = seq_len;
                assert(temp==seq_len);	/* verify no overflow */
                MPI_Allreduce(&temp, &max, 1, MPI_UNSIGNED_LONG, MPI_MAX,
                      H5FD_mpio_communicator(f->shared->lf));
                MPI_Allreduce(&temp, &min, 1, MPI_UNSIGNED_LONG, MPI_MIN,
                      H5FD_mpio_communicator(f->shared->lf));
#ifdef AKC
                printf("seq_len=%lu, min=%lu, max=%lu\n", temp, min, max);
#endif
                if (max != min)
                    HRETURN_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL,
                      "collective access with unequal number of blocks not supported yet");
            }
#endif

            /* Write directly to file if the dataset is in an external file */
            if (efl && efl->nused>0) {
                /* Note: We can't use data sieve buffers for datasets in external files
                 *  because the 'addr' of all external files is set to 0 (above) and
                 *  all datasets in external files would alias to the same set of
                 *  file offsets, totally mixing up the data sieve buffer information. -QAK
                 */
                if (H5O_efl_write(f, efl, addr, seq_len, buf)<0) {
                    HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
                          "external data write failed");
                }
            } else {
                if (H5F_contig_write(f, max_data, H5FD_MEM_DRAW, addr, seq_len, dxpl_id, buf)<0) {
                    HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
                              "block write failed");
                }
            } /* end else */
            break;

        case H5D_CHUNKED:
        {
            /*
             * This method is unable to access external raw data files 
             */
            if (efl && efl->nused>0) {
                HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL,
                      "chunking and external files are mutually exclusive");
            }
            /* Compute the file offset coordinates and hyperslab size */
            if((ndims=H5S_get_simple_extent_dims(file_space,dset_dims,NULL))<0)
                HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL, "unable to retrieve dataspace dimensions");
            
#ifdef QAK
/* Print out the file offsets & hyperslab sizes */
{
    static int count=0;

    if(count<1000000) {
        printf("%s: elmt_size=%d, addr=%d, seq_len=%lu\n",FUNC,(int)elmt_size,(int)addr,(unsigned long)seq_len);
        printf("%s: file_offset=%d\n",FUNC,(int)file_offset);
        count++;
    }
}
#endif /* QAK */
#ifdef QAK
            /* The library shouldn't be reading partial elements currently */
            assert((seq_len%elmt_size)!=0);
            assert((addr%elmt_size)!=0);
#endif /* QAK */

            /* Set location in dataset from the file_offset */
            addr=file_offset;

            /* Convert the bytes into elements */
            seq_len/=elmt_size;
            addr/=elmt_size;

            /* Build the array of cumulative hyperslab sizes */
            for(acc=1, i=(ndims-1); i>=0; i--) {
                down_size[i]=acc;
                acc*=dset_dims[i];
#ifdef QAK
printf("%s: acc=%ld, down_size[%d]=%ld\n",FUNC,(long)acc,i,(long)down_size[i]);
#endif /* QAK */
            } /* end for */

            /* Compute the hyperslab offset from the address given */
            for(i=ndims-1; i>=0; i--) {
                coords[i]=addr%dset_dims[i];
                addr/=dset_dims[i];
#ifdef QAK
printf("%s: addr=%lu, dset_dims[%d]=%ld, coords[%d]=%ld\n",FUNC,(unsigned long)addr,i,(long)dset_dims[i],i,(long)coords[i]);
#endif /* QAK */
            } /* end for */
            coords[ndims]=0;   /* No offset for element info */
#ifdef QAK
printf("%s: addr=%lu, coords[%d]=%ld\n",FUNC,(unsigned long)addr,ndims,(long)coords[ndims]);
#endif /* QAK */

            /*
             * Peel off initial partial hyperslabs until we've got a hyperslab which starts
             *      at coord[n]==0 for dimensions 1->(ndims-1)  (i.e. starting at coordinate
             *      zero for all dimensions except the slowest changing one
             */
            for(i=ndims-1; i>0 && seq_len>=down_size[i]; i--) {
                hsize_t partial_size;       /* Size of the partial hyperslab in bytes */

                /* Check if we have a partial hyperslab in this lower dimension */
                if(coords[i]>0) {
#ifdef QAK
printf("%s: Need to get hyperslab, seq_len=%ld, coords[%d]=%ld\n",FUNC,(long)seq_len,i,(long)coords[i]);
#endif /* QAK */
                    /* Reset the partial hyperslab size */
                    partial_size=1;

                    /* Build the partial hyperslab information */
                    for(j=0; j<ndims; j++) {
                        if(i==j)
                            hslab_size[j]=MIN(seq_len/down_size[i],dset_dims[i]-coords[i]);
                        else
                            if(j>i)
                                hslab_size[j]=dset_dims[j];
                            else
                                hslab_size[j]=1;
                        partial_size*=hslab_size[j];
#ifdef QAK
printf("%s: partial_size=%lu, hslab_size[%d]=%ld\n",FUNC,(unsigned long)partial_size,j,(long)hslab_size[j]);
#endif /* QAK */
                    } /* end for */
                    hslab_size[ndims]=elmt_size;   /* basic hyperslab size is the element */
#ifdef QAK
printf("%s: partial_size=%lu, hslab_size[%d]=%ld\n",FUNC,(unsigned long)partial_size,ndims,(long)hslab_size[ndims]);
#endif /* QAK */

                    /* Write out the partial hyperslab */
                    if (H5F_istore_write(f, dxpl_id, layout, pline, fill, coords,
                                 hslab_size, buf)<0) {
                        HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "chunked write failed");
                    }

                    /* Increment the buffer offset */
                    buf=(const unsigned char *)buf+partial_size;

                    /* Decrement the length of the sequence to read */
                    seq_len-=partial_size;

                    /* Correct the coords array */
                    coords[i]=0;
                    coords[i-1]++;
                } /* end if */
            } /* end for */
#ifdef QAK
printf("%s: seq_len=%lu\n",FUNC,(unsigned long)seq_len);
#endif /* QAK */

            /* Check if there is more than just a partial hyperslab to read */
            if(seq_len>=down_size[0]) {
                hsize_t tmp_seq_len;    /* Temp. size of the sequence in elements */
                hsize_t full_size;      /* Size of the full hyperslab in bytes */

                /* Get the sequence length for computing the hyperslab sizes */
                tmp_seq_len=seq_len;

                /* Reset the size of the hyperslab read in */
                full_size=1;

                /* Compute the hyperslab size from the length given */
                for(i=ndims-1; i>=0; i--) {
                    /* Check if the hyperslab is wider than the width of the dimension */
                    if(tmp_seq_len>dset_dims[i]) {
                        assert(0==coords[i]);
                        hslab_size[i]=dset_dims[i];
                    } /* end if */
                    else 
                        hslab_size[i]=tmp_seq_len;

                    /* compute the number of elements read in */
                    full_size*=hslab_size[i];

                    /* Fold the length into the length in the next highest dimension */
                    tmp_seq_len/=dset_dims[i];
#ifdef QAK
printf("%s: tmp_seq_len=%lu, hslab_size[%d]=%ld\n",FUNC,(unsigned long)tmp_seq_len,i,(long)hslab_size[i]);
#endif /* QAK */

                    /* Make certain the hyperslab sizes don't go less than 1 for dimensions less than 0*/
                    assert(tmp_seq_len>=1 || i==0);
                } /* end for */
                hslab_size[ndims]=elmt_size;   /* basic hyperslab size is the element */

#ifdef QAK
/* Print out the file offsets & hyperslab sizes */
{
    static int count=0;

    if(count<1000000) {
        printf("%s: elmt_size=%d, addr=%d, full_size=%ld, tmp_seq_len=%ld seq_len=%ld\n",FUNC,(int)elmt_size,(int)addr,(long)full_size,(long)tmp_seq_len,(long)seq_len);
        for(i=0; i<ndims; i++)
            printf("%s: dset_dims[%d]=%d\n",FUNC,i,(int)dset_dims[i]);
        for(i=0; i<=ndims; i++)
            printf("%s: coords[%d]=%d, hslab_size[%d]=%d\n",FUNC,i,(int)coords[i],(int)i,(int)hslab_size[i]);
        count++;
    }
}
#endif /* QAK */

                /* Write the full hyperslab in */
                if (H5F_istore_write(f, dxpl_id, layout, pline, fill, coords,
                             hslab_size, buf)<0) {
                    HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "chunked write failed");
                }

                /* Increment the buffer offset */
                buf=(const unsigned char *)buf+full_size;

                /* Decrement the sequence length left */
                seq_len-=full_size;

                /* Increment coordinate of slowest changing dimension */
                coords[0]+=hslab_size[0];

            } /* end if */
#ifdef QAK
printf("%s: seq_len=%lu\n",FUNC,(unsigned long)seq_len);
#endif /* QAK */

            /*
             * Peel off final partial hyperslabs until we've finished reading all the data
             */
            if(seq_len>0) {
                hsize_t partial_size;       /* Size of the partial hyperslab in bytes */

                /*
                 * Peel off remaining partial hyperslabs, from the next-slowest dimension
                 *  on down to the next-to-fastest changing dimension
                 */
                for(i=1; i<(ndims-1); i++) {
                    /* Check if there are enough elements to read in a row in this dimension */
                    if(seq_len>=down_size[i]) {
#ifdef QAK
printf("%s: seq_len=%ld, down_size[%d]=%ld\n",FUNC,(long)seq_len,i+1,(long)down_size[i+1]);
#endif /* QAK */
                        /* Reset the partial hyperslab size */
                        partial_size=1;

                        /* Build the partial hyperslab information */
                        for(j=0; j<ndims; j++) {
                            if(j<i)
                                hslab_size[j]=1;
                            else
                                if(j==i)
                                    hslab_size[j]=seq_len/down_size[j];
                                else
                                    hslab_size[j]=dset_dims[j];

                            partial_size*=hslab_size[j];
#ifdef QAK
printf("%s: partial_size=%lu, coords[%d]=%ld, hslab_size[%d]=%ld\n",FUNC,(unsigned long)partial_size,j,(long)coords[j],j,(long)hslab_size[j]);
#endif /* QAK */
                        } /* end for */
                        hslab_size[ndims]=elmt_size;   /* basic hyperslab size is the element */
#ifdef QAK
printf("%s: partial_size=%lu, coords[%d]=%ld, hslab_size[%d]=%ld\n",FUNC,(unsigned long)partial_size,ndims,(long)coords[ndims],ndims,(long)hslab_size[ndims]);
#endif /* QAK */

                        /* Write out the partial hyperslab */
                        if (H5F_istore_write(f, dxpl_id, layout, pline, fill, coords,
                                     hslab_size, buf)<0) {
                            HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "chunked write failed");
                        }

                        /* Increment the buffer offset */
                        buf=(const unsigned char *)buf+partial_size;

                        /* Decrement the length of the sequence to read */
                        seq_len-=partial_size;

                        /* Correct the coords array */
                        coords[i]=hslab_size[i];
                    } /* end if */
                } /* end for */

                /* Handle fastest changing dimension if there are any elements left */
                if(seq_len>0) {
#ifdef QAK
printf("%s: i=%d, seq_len=%ld\n",FUNC,ndims-1,(long)seq_len);
#endif /* QAK */
                    assert(seq_len<dset_dims[ndims-1]);

                    /* Reset the partial hyperslab size */
                    partial_size=1;

                    /* Build the partial hyperslab information */
                    for(j=0; j<ndims; j++) {
                        if(j==(ndims-1))
                            hslab_size[j]=seq_len;
                        else
                            hslab_size[j]=1;

                        partial_size*=hslab_size[j];
#ifdef QAK
printf("%s: partial_size=%lu, coords[%d]=%ld, hslab_size[%d]=%ld\n",FUNC,(unsigned long)partial_size,j,(long)coords[j],j,(long)hslab_size[j]);
#endif /* QAK */
                    } /* end for */
                    hslab_size[ndims]=elmt_size;   /* basic hyperslab size is the element */
#ifdef QAK
printf("%s: partial_size=%lu, coords[%d]=%ld, hslab_size[%d]=%ld\n",FUNC,(unsigned long)partial_size,ndims,(long)coords[ndims],ndims,(long)hslab_size[ndims]);
#endif /* QAK */

                    /* Write in the final partial hyperslab */
                    if (H5F_istore_write(f, dxpl_id, layout, pline, fill, coords,
                                 hslab_size, buf)<0) {
                        HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "chunked write failed");
                    }

                    /* Double-check the amount read in */
                    assert(seq_len==partial_size);
                } /* end if */
            } /* end if */
        }
            break;

        default:
            assert("not implemented yet" && 0);
            HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL, "unsupported storage layout");
    }   /* end switch() */

    FUNC_LEAVE(SUCCEED);
}   /* H5F_seq_write() */