Changeset 1448
- Timestamp:
- 18/03/10 00:49:10 (2 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
src/napi5.c (modified) (8 diffs)
-
windows/nexus/nexus.vcproj (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/napi5.c
r1439 r1448 126 126 char *time_buffer = NULL; 127 127 char version_nr[10]; 128 int iRet;128 herr_t iRet; 129 129 unsigned int vers_major, vers_minor, vers_release, am1 ; 130 130 hid_t fapl = -1; … … 316 316 { 317 317 pNexusFile5 pFile = NULL; 318 int iRet;318 herr_t iRet; 319 319 320 320 pFile=NXI5assert(*fid); … … 363 363 { 364 364 pNexusFile5 pFile; 365 hid_t iRet, iVID; 365 herr_t iRet; 366 hid_t iVID; 366 367 hid_t attr1,aid1, aid2; 367 368 char pBuffer[1024] = ""; … … 419 420 420 421 pNexusFile5 pFile; 421 hid_t iRet, attr1, atype; 422 hid_t attr1, atype; 423 herr_t iRet; 422 424 char pBuffer[1024]; 423 425 char data[128]; … … 611 613 int compress_type, int chunk_size[]) 612 614 { 613 hid_t datatype1, dataspace, iNew, iRet; 614 hid_t type, cparms = -1; 615 pNexusFile5 pFile; 616 char pBuffer[256]; 617 int i, byte_zahl = 0; 618 hsize_t chunkdims[H5S_MAX_RANK]; 619 hsize_t mydim[H5S_MAX_RANK], mydim1[H5S_MAX_RANK]; 620 hsize_t size[H5S_MAX_RANK]; 621 hsize_t maxdims[H5S_MAX_RANK]; 622 int compress_level; 623 624 pFile = NXI5assert (fid); 625 626 for (i = 0; i < rank; i++) 627 { 628 chunkdims[i]=chunk_size[i]; 629 mydim[i] = dimensions[i]; 630 maxdims[i] = dimensions[i]; 631 size[i] = dimensions[i]; 632 } 633 634 type = nxToHDF5Type(datatype); 635 636 if (rank <= 0) { 637 sprintf (pBuffer, "ERROR: invalid rank specified %s", 638 name); 639 NXIReportError (NXpData, pBuffer); 640 return NX_ERROR; 641 } 642 /* 615 hid_t datatype1, dataspace, iNew; 616 herr_t iRet; 617 hid_t type, cparms = -1; 618 pNexusFile5 pFile; 619 char pBuffer[256]; 620 int i, byte_zahl = 0; 621 hsize_t chunkdims[H5S_MAX_RANK]; 622 hsize_t mydim[H5S_MAX_RANK], mydim1[H5S_MAX_RANK]; 623 hsize_t size[H5S_MAX_RANK]; 624 hsize_t maxdims[H5S_MAX_RANK]; 625 int compress_level; 626 627 pFile = NXI5assert (fid); 628 629 for (i = 0; i < rank; i++) 630 { 631 chunkdims[i]=chunk_size[i]; 632 mydim[i] = dimensions[i]; 633 maxdims[i] = dimensions[i]; 634 size[i] = dimensions[i]; 635 } 636 637 type = nxToHDF5Type(datatype); 638 639 if (rank <= 0) 640 { 641 sprintf (pBuffer, "ERROR: invalid rank specified %s", 642 name); 643 NXIReportError (NXpData, pBuffer); 644 return NX_ERROR; 645 } 646 /* 643 647 Check dimensions for consistency. The first dimension may be -1 644 648 thus denoting an unlimited dimension. 645 */ 646 for (i = 1; i < rank; i++) { 647 if (dimensions[i] <= 0) { 648 sprintf (pBuffer, 649 "ERROR: invalid dimension %d, value %d given for Dataset %s", 650 i, dimensions[i], name); 651 NXIReportError (NXpData, pBuffer); 652 return NX_ERROR; 653 } 654 } 655 if (datatype == NX_CHAR) 656 { 657 /* 658 * This assumes string lenght is in the last dimensions and 659 * the logic must be the same as used in NX5getslab and NX5getinfo 660 * 661 * search for tests on H5T_STRING 662 */ 663 byte_zahl=dimensions[rank-1]; 664 for(i = 0; i < rank; i++) 665 { 666 mydim1[i] = dimensions[i]; 667 } 668 mydim1[rank-1] = 1; 669 if (dimensions[rank-1] > 1) 670 { 671 mydim[rank-1] = maxdims[rank-1] = size[rank-1] = 1; 672 } 673 if (chunkdims[rank-1] > 1) 674 { 675 chunkdims[rank-1] = 1; 676 } 677 if (dimensions[0] == NX_UNLIMITED) 678 { 679 mydim1[0] = 1; 680 maxdims[0] = H5S_UNLIMITED; 681 } 682 dataspace=H5Screate_simple(rank,mydim1,maxdims); 683 } else { 649 */ 650 for (i = 1; i < rank; i++) 651 { 652 if (dimensions[i] <= 0) 653 { 654 sprintf (pBuffer, 655 "ERROR: invalid dimension %d, value %d given for Dataset %s", 656 i, dimensions[i], name); 657 NXIReportError (NXpData, pBuffer); 658 return NX_ERROR; 659 } 660 } 661 if (datatype == NX_CHAR) 662 { 663 /* 664 * This assumes string lenght is in the last dimensions and 665 * the logic must be the same as used in NX5getslab and NX5getinfo 666 * 667 * search for tests on H5T_STRING 668 */ 669 byte_zahl=dimensions[rank-1]; 670 for(i = 0; i < rank; i++) 671 { 672 mydim1[i] = dimensions[i]; 673 } 674 mydim1[rank-1] = 1; 675 if (dimensions[rank-1] > 1) 676 { 677 mydim[rank-1] = maxdims[rank-1] = size[rank-1] = 1; 678 } 679 if (chunkdims[rank-1] > 1) 680 { 681 chunkdims[rank-1] = 1; 682 } 683 if (dimensions[0] == NX_UNLIMITED) 684 { 685 mydim1[0] = 1; 686 maxdims[0] = H5S_UNLIMITED; 687 } 688 dataspace=H5Screate_simple(rank,mydim1,maxdims); 689 } 690 else 691 { 692 if (dimensions[0] == NX_UNLIMITED) 693 { 694 mydim[0] = 1; 695 maxdims[0] = H5S_UNLIMITED; 696 dataspace=H5Screate_simple(rank, mydim, maxdims); 697 } 698 else 699 { 700 /* dataset creation */ 701 dataspace=H5Screate_simple(rank, mydim, NULL); 702 } 703 } 704 datatype1=H5Tcopy(type); 705 if (datatype == NX_CHAR) 706 { 707 H5Tset_size(datatype1, byte_zahl); 708 /* H5Tset_strpad(H5T_STR_SPACEPAD); */ 709 } 710 compress_level = 6; 711 if ( (compress_type / 100) == NX_COMP_LZW ) 712 { 713 compress_level = compress_type % 100; 714 compress_type = NX_COMP_LZW; 715 } 716 if(compress_type == NX_COMP_LZW) 717 { 718 cparms = H5Pcreate(H5P_DATASET_CREATE); 719 iNew = H5Pset_chunk(cparms,rank,chunkdims); 720 if (iNew < 0) 721 { 722 NXIReportError (NXpData, "ERROR: Size of chunks could not be set!"); 723 return NX_ERROR; 724 } 725 H5Pset_deflate(cparms,compress_level); 726 iRet = H5Dcreate (pFile->iCurrentG, (char*)name, datatype1, 727 dataspace, cparms); 728 } 729 else if (compress_type == NX_COMP_NONE) 730 { 731 if (dimensions[0] == NX_UNLIMITED) 732 { 733 cparms = H5Pcreate(H5P_DATASET_CREATE); 734 iNew = H5Pset_chunk(cparms,rank,chunkdims); 735 if (iNew < 0) 736 { 737 NXIReportError (NXpData, 738 "ERROR: Size of chunks could not be set!"); 739 return NX_ERROR; 740 } 741 iRet = H5Dcreate (pFile->iCurrentG, (char*)name, datatype1, 742 dataspace, cparms); 743 } 744 else 745 { 746 iRet = H5Dcreate (pFile->iCurrentG, (char*)name, datatype1, 747 dataspace, H5P_DEFAULT); 748 } 749 } 750 else 751 { 752 NXIReportError (NXpData, 753 "HDF5 doesn't support selected compression method! Dataset was saved without compression"); 754 iRet = H5Dcreate (pFile->iCurrentG, (char*)name, datatype1, 755 dataspace, H5P_DEFAULT); 756 } 757 if (iRet < 0) 758 { 759 NXIReportError (NXpData, "ERROR: Creating chunked dataset failed!"); 760 return NX_ERROR; 761 } 762 else 763 { 764 pFile->iCurrentD = iRet; 765 } 684 766 if (dimensions[0] == NX_UNLIMITED) 685 { 686 mydim[0] = 1; 687 maxdims[0] = H5S_UNLIMITED; 688 dataspace=H5Screate_simple(rank, mydim, maxdims); 689 } else { 690 /* dataset creation */ 691 dataspace=H5Screate_simple(rank, mydim, NULL); 692 } 693 } 694 datatype1=H5Tcopy(type); 695 if (datatype == NX_CHAR) 696 { 697 H5Tset_size(datatype1, byte_zahl); 698 /* H5Tset_strpad(H5T_STR_SPACEPAD); */ 699 } 700 compress_level = 6; 701 if ( (compress_type / 100) == NX_COMP_LZW ) 702 { 703 compress_level = compress_type % 100; 704 compress_type = NX_COMP_LZW; 705 } 706 if(compress_type == NX_COMP_LZW) 707 { 708 cparms = H5Pcreate(H5P_DATASET_CREATE); 709 iNew = H5Pset_chunk(cparms,rank,chunkdims); 710 if (iNew < 0) { 711 NXIReportError (NXpData, "ERROR: Size of chunks could not be set!"); 712 return NX_ERROR; 713 } 714 H5Pset_deflate(cparms,compress_level); 715 iRet = H5Dcreate (pFile->iCurrentG, (char*)name, datatype1, 716 dataspace, cparms); 717 } else if (compress_type == NX_COMP_NONE) { 718 if (dimensions[0] == NX_UNLIMITED) { 719 cparms = H5Pcreate(H5P_DATASET_CREATE); 720 iNew = H5Pset_chunk(cparms,rank,chunkdims); 721 if (iNew < 0) { 722 NXIReportError (NXpData, 723 "ERROR: Size of chunks could not be set!"); 724 return NX_ERROR; 725 } 726 iRet = H5Dcreate (pFile->iCurrentG, (char*)name, datatype1, 727 dataspace, cparms); 728 } else { 729 iRet = H5Dcreate (pFile->iCurrentG, (char*)name, datatype1, 730 dataspace, H5P_DEFAULT); 731 } 732 } else { 733 NXIReportError (NXpData, 734 "HDF5 doesn't support selected compression method! Dataset was saved without compression"); 735 iRet = H5Dcreate (pFile->iCurrentG, (char*)name, datatype1, 736 dataspace, H5P_DEFAULT); 737 } 738 if (iRet < 0) { 739 NXIReportError (NXpData, "ERROR: Creating chunked dataset failed!"); 740 return NX_ERROR; 741 } else { 742 pFile->iCurrentD = iRet; 743 } 744 if (dimensions[0] == NX_UNLIMITED) 745 { 746 size[0] = 1; 747 iNew = H5Dextend (pFile->iCurrentD, size); 748 if (iNew < 0) { 749 sprintf (pBuffer, "ERROR: cannot create Dataset %s, check arguments", 750 name); 751 NXIReportError (NXpData, pBuffer); 752 return NX_ERROR; 753 } 754 } 755 if (cparms != -1) { 756 iRet = H5Pclose(cparms); 757 } 758 iRet = H5Sclose(dataspace); 759 iRet = H5Tclose(datatype1); 760 iRet = H5Dclose(pFile->iCurrentD); 761 pFile->iCurrentD = 0; 762 if (iRet < 0) { 763 NXIReportError (NXpData, "ERROR: HDF cannot close Dataset"); 764 return NX_ERROR; 765 } 766 return NX_OK; 767 { 768 size[0] = 1; 769 iNew = H5Dextend (pFile->iCurrentD, size); 770 if (iNew < 0) 771 { 772 sprintf (pBuffer, "ERROR: cannot create Dataset %s, check arguments", 773 name); 774 NXIReportError (NXpData, pBuffer); 775 return NX_ERROR; 776 } 777 } 778 if (cparms != -1) 779 { 780 iRet = H5Pclose(cparms); 781 } 782 iRet = H5Sclose(dataspace); 783 iRet = H5Tclose(datatype1); 784 iRet = H5Dclose(pFile->iCurrentD); 785 pFile->iCurrentD = 0; 786 if (iRet < 0) 787 { 788 NXIReportError (NXpData, "ERROR: HDF cannot close Dataset"); 789 return NX_ERROR; 790 } 791 return NX_OK; 767 792 } 768 793 … … 844 869 { 845 870 pNexusFile5 pFile; 846 int iRet;871 herr_t iRet; 847 872 848 873 pFile = NXI5assert (fid); … … 1867 1892 pNexusFile5 pFile; 1868 1893 hid_t attr_id; 1869 hid_t iRet, atype, aspace; 1894 hid_t atype, aspace; 1895 herr_t iRet; 1870 1896 int iPType,rank; 1871 1897 char *iname = NULL; … … 1944 1970 { 1945 1971 pNexusFile5 pFile; 1946 int iNew, iRet, vid, asize; 1972 int iNew, vid, asize; 1973 herr_t iRet; 1947 1974 hid_t type, atype = -1, glob; 1948 1975 char pBuffer[256]; -
trunk/windows/nexus/nexus.vcproj
r1440 r1448 42 42 Name="VCCLCompilerTool" 43 43 Optimization="0" 44 AdditionalIncludeDirectories=" E:\hdf5-1.8.4\src;..\..\include;..\..\Windows_extra\include"45 PreprocessorDefinitions="HDF5 ,H5_USE_16_API;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE"44 AdditionalIncludeDirectories="..\..\..\..\hdf5-1.8.4\src;..\..\include;..\..\Windows_extra\include" 45 PreprocessorDefinitions="HDF5;H5_USE_16_API;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE" 46 46 MinimalRebuild="true" 47 47 BasicRuntimeChecks="3"
Note: See TracChangeset
for help on using the changeset viewer.
