Skip to content

Commit

Permalink
Write datasets with native endianness.
Browse files Browse the repository at this point in the history
  • Loading branch information
abensonca committed May 26, 2015
1 parent 478c97c commit cfcdd18
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions HDF5/Dataset.pm
Expand Up @@ -3,6 +3,7 @@ package PDL::IO::HDF5::Dataset;
use Carp;

use strict;
use Config;

# Global mapping variables
our ($H5T_STRING, $H5T_REFERENCE, %PDLtoHDF5internalTypeMapping, %HDF5toPDLfileMapping, %PDLtoHDF5fileMapping);
Expand Down Expand Up @@ -193,15 +194,28 @@ B<Usage:>
# Mapping of PDL types to what types they are written to in the HDF5 file.
# For 64 Bit machines, we might need to modify this with some smarts to determine
# what is appropriate
%PDLtoHDF5fileMapping = (
my %PDLtoHDF5fileMapping;
if ( $Config{byteorder} =~ m/4321$/ ) {
# Big endian.
%PDLtoHDF5fileMapping = (
$PDL::Types::PDL_B => PDL::IO::HDF5::H5T_STD_I8BE(),
$PDL::Types::PDL_S => PDL::IO::HDF5::H5T_STD_I16BE(),
$PDL::Types::PDL_L => PDL::IO::HDF5::H5T_STD_I32BE(),
$PDL::Types::PDL_LL => PDL::IO::HDF5::H5T_STD_I64BE(),
$PDL::Types::PDL_F => PDL::IO::HDF5::H5T_IEEE_F32BE(),
$PDL::Types::PDL_D => PDL::IO::HDF5::H5T_IEEE_F64BE(),
);

);
} else {
# Little endian.
%PDLtoHDF5fileMapping = (
$PDL::Types::PDL_B => PDL::IO::HDF5::H5T_STD_I8LE(),
$PDL::Types::PDL_S => PDL::IO::HDF5::H5T_STD_I16LE(),
$PDL::Types::PDL_L => PDL::IO::HDF5::H5T_STD_I32LE(),
$PDL::Types::PDL_LL => PDL::IO::HDF5::H5T_STD_I64LE(),
$PDL::Types::PDL_F => PDL::IO::HDF5::H5T_IEEE_F32LE(),
$PDL::Types::PDL_D => PDL::IO::HDF5::H5T_IEEE_F64LE(),
);
}


sub set{
Expand Down

0 comments on commit cfcdd18

Please sign in to comment.