Skip to content
This repository was archived by the owner on Oct 23, 2020. It is now read-only.

Fix issue with halo exchanges of integer fields when running with RKIND=4 #931

Merged

Conversation

mgduda
Copy link
Contributor

@mgduda mgduda commented May 1, 2016

This merge corrects an issue in the new group halo exchange routines for integers when running in single precision.

The mpas_dmpar_exch_group_unpack_buffer_fieldNd_integer and mpas_dmpar_exch_group_pack_buffer_fieldNd_integer routines previously packed integer fields into a default real-kind (RKIND) buffer when performing halo exchanges for integer fields. However, this packing and unpacking was done using type conversions. This leads to incorrect results for integers that cannot be exactly represented when converted to a 32-bit real (potentially affecting integers greater than 2^24, or 16777216, in magnitude).

Instead of type conversion, we now use the Fortran TRANSFER intrinsic to type cast integers to and from reals, since the halo exchange code in no way depends on the values stored in the exchange buffers.

…ND=4

The mpas_dmpar_exch_group_unpack_buffer_fieldNd_integer and
mpas_dmpar_exch_group_pack_buffer_fieldNd_integer routines previously packed
integer fields into a default real-kind (RKIND) buffer when performing halo
exchanges for integer fields. However, this packing and unpacking was done
using type conversions. This leads to incorrect results for integers that
cannot be exactly represented when converted to a 32-bit real (potentially
affecting integers greater than 2^24, or 16777216, in magnitude).

Instead of type conversion, we now use the Fortran TRANSFER intrinsic to
type cast integers to and from reals, since the halo exchange code in no way
depends on the values stored in the exchange buffers.
@douglasjacobsen douglasjacobsen merged commit 419117c into MPAS-Dev:develop May 5, 2016
@douglasjacobsen douglasjacobsen deleted the framework/int_halo_exch_fix branch May 5, 2016 15:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants