diff --git a/src/field_descriptor.cpp b/src/field_descriptor.cpp index 8fb6fee95bbb20ada7f215901fdcade3a289e3c7..59550a6dd7b16be0085c4eb1fa668e4a6d4ebde1 100644 --- a/src/field_descriptor.cpp +++ b/src/field_descriptor.cpp @@ -86,6 +86,9 @@ field_descriptor::field_descriptor( tsubsizes[i] = this->subsizes[i]; tstarts[i] = this->starts[i]; } + tsizes[ndims-1] *= sizeof(float); + tsubsizes[ndims-1] *= sizeof(float); + tstarts[ndims-1] *= sizeof(float); if (this->mpi_dtype == MPI_COMPLEX8) { tsizes[ndims-1] *= 2; @@ -160,7 +163,7 @@ field_descriptor::field_descriptor( tsubsizes, tstarts, MPI_ORDER_C, - MPI_FLOAT, + MPI_UNSIGNED_CHAR, &this->mpi_array_dtype); MPI_Type_commit(&this->mpi_array_dtype); } @@ -210,15 +213,14 @@ field_descriptor::~field_descriptor() int field_descriptor::read( const char *fname, - void *buffer, - const char *datarep) + void *buffer) { if (this->subsizes[0] > 0) { MPI_Info info; MPI_Info_create(&info); MPI_File f; - int read_size = this->local_size; + int read_size = this->local_size*sizeof(float); char ffname[200]; if (this->mpi_dtype == MPI_COMPLEX8) read_size *= 2; @@ -233,15 +235,15 @@ int field_descriptor::read( MPI_File_set_view( f, 0, - MPI_FLOAT, + MPI_UNSIGNED_CHAR, this->mpi_array_dtype, - datarep, + "native", info); MPI_File_read_all( f, buffer, read_size, - MPI_FLOAT, + MPI_UNSIGNED_CHAR, MPI_STATUS_IGNORE); MPI_File_close(&f); } @@ -250,15 +252,14 @@ int field_descriptor::read( int field_descriptor::write( const char *fname, - void *buffer, - const char *datarep) + void *buffer) { if (this->subsizes[0] > 0) { MPI_Info info; MPI_Info_create(&info); MPI_File f; - int read_size = this->local_size; + int read_size = this->local_size*sizeof(float); char ffname[200]; if (this->mpi_dtype == MPI_COMPLEX8) read_size *= 2; @@ -273,15 +274,15 @@ int field_descriptor::write( MPI_File_set_view( f, 0, - MPI_FLOAT, + MPI_UNSIGNED_CHAR, this->mpi_array_dtype, - datarep, + "native", info); MPI_File_write_all( f, buffer, read_size, - MPI_FLOAT, + MPI_UNSIGNED_CHAR, MPI_STATUS_IGNORE); MPI_File_close(&f); } diff --git a/src/field_descriptor.hpp b/src/field_descriptor.hpp index ce856ae0ef1c6688540f141f09f0ef189bdd4122..29b8c292488c87073cf20c6d7ca8ba95d8acc838 100644 --- a/src/field_descriptor.hpp +++ b/src/field_descriptor.hpp @@ -57,12 +57,10 @@ class field_descriptor * */ int read( const char *fname, - void *buffer, - const char *datarep = "native"); + void *buffer); int write( const char *fname, - void *buffer, - const char *datarep = "native"); + void *buffer); /* a function that generates the transposed descriptor. * don't forget to delete the result once you're done with it. @@ -103,5 +101,17 @@ int fftwf_clip_zero_padding( field_descriptor *f, float *a); +inline float btle(const float be) + { + float le; + char *befloat = (char *) & be; + char *lefloat = (char *) & le; + lefloat[0] = befloat[3]; + lefloat[1] = befloat[2]; + lefloat[2] = befloat[1]; + lefloat[3] = befloat[0]; + return le; + } + #endif//FIELD_DESCRIPTOR diff --git a/test3.ipynb b/test3.ipynb index 918ca459c297ac7d1f987349d623931a5fe82afc..1cacdb0eec355b0e550a9b03f64cade04a18378c 100644 --- a/test3.ipynb +++ b/test3.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:41b656323632ba5dd67fcd6f67d6e62ab479be1edf0adc21548c493eb5da9b1d" + "signature": "sha256:966c6344a3d90cdf5a7423c96eebbfd82f41bd0e6556fcce769383cb4e93116c" }, "nbformat": 3, "nbformat_minor": 0, @@ -63,8 +63,16 @@ ], "language": "python", "metadata": {}, - "outputs": [], - "prompt_number": 20 + "outputs": [ + { + "output_type": "stream", + "stream": "stderr", + "text": [ + "-c:15: RuntimeWarning: divide by zero encountered in true_divide\n" + ] + } + ], + "prompt_number": 2 }, { "cell_type": "code", @@ -147,7 +155,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 56 + "prompt_number": 3 }, { "cell_type": "code", @@ -200,7 +208,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 52 + "prompt_number": 5 }, { "cell_type": "code", @@ -241,11 +249,11 @@ "text": [ "0.0\n", "distance is small\n", - "14.9705\n" + "14.4104\n" ] } ], - "prompt_number": 57 + "prompt_number": 6 }, { "cell_type": "code",