safer MPI int types + allow -fdefault-integer-8: modified 54 .f90 files + Makefile;

Declined
#249 · Created  · Last updated

Declined pull request

I'm declining my own pull request in favour of a single-commit pull request, which is now pull request #251. The URL of the replacement pull request is https://bitbucket.org/rteyssie/ramses/pull-requests/251/single-commit-squash-of-2d6f91cd-ad79705d/diff .

Closed by: ·2017-08-14

Description

TITLE: safer MPI int types + allow 64-bit integer with -fdefault-integer-8

DESCRIPTION:

Running RAMSES with a 64-bit integer default type is obviously needed for N-body simulations with 2048^3 or more particles, and might be needed with 512^3 simulations (see ramses-scalav 512^3 bug). This pull request modifies 54 .f90 files and adds a section to the Makefile, with the aim of making the use of 64-bit integers a Makefile-level decision for RAMSES users.

Much of the RAMSES code has generic integer types, so switching to 64-bit integer types with a compile flag (e.g. gcc: -fdefault-integer-8) should work correctly with much of the code, except that MPI, at least with the openmpi-2.0.2-2 implementation of Debian/stretch, does not have specific versions of generic functions for all the possibilities of 64-bit integer arguments. Using "include 'mpif.h'" gives runtime errors for some of these (e.g. reqrecv, reqsend in amr/virtual_boundaries.f90), while using use mpi_f08 (which is recommended in 17.1.1 of the mpi 3.0 standard) gives compile time errors. So there are many small edits in amr/virtual_boundaries.f90 in this pull request - the aim is to (at least to some degree) update this file to more modern MPI fortran standards.

Apart from amr/virtual_boundaries.f90, most files only have the edit s/MPI_INTEGER/RAMMPI_DEFAULT_INT_TYPE/, where RAMMPI_DEFAULT_INT_TYPE is a macro that must be defined in the Makefile.

Some files have a simplification from a LONGINT-dependent choice of MPI_INTEGER vs MPI_INTEGER8 to RAMMPI_I8B_TYPE (again, a default is defined in the new section in the Makefile); this reduces 5 lines to 1 line in each case.

Since the "i8b" and "i4b" notations are key to these integer types, amr/amr_parameters.f90 has also been updated to give portable definitions of these (kind=4 and kind=8 mean byte numbers to gcc, but this is a compiler choice, not a fortran standard).

Whitespace: my emacs settings have removed some end-of-line and end-of-file superfluous whitespace from the files that I edited by hand.

ENABLING 64-bit in the Makefile:

The default settings of the Makefile retain the 32-bit standard (as of e.g. 2017 for gcc on an x86_64 architecture) integers. To change to 64-bit:

  • comment out: DEFINES += -DRAMMPI_DEFAULT_INT_TYPE=MPI_INTEGER

  • enable: DEFINES += -DRAMMPI_DEFAULT_INT_TYPE=MPI_INTEGER8

  • enable: DEFINES += -fdefault-integer-8

TESTS:

This pull request has been tested on the tube1d demo namelist and output file, and on small-scale ramses-scalav simulations, both for the 32-bit (default) case and the 64-bit case, giving numerically similar physical results in both cases, and similarly with either one or four cores; the mpi thread ordering and timings varied a bit between different runs.

DELAY:

Please delay merging this pull request for the moment, for two reasons (apart from the fact that it affects a big number of files):

  • amr/virtual_boundaries should be made compilable on systems where use mpi_f08 is not yet available (commit ad79705 does this);

  • there are other mpi routines that are likely to depend on handles that are sensitive to 32 vs 64 bit integer types, e.g. routines that call mpi_irecv, mpi_waitall, mpi_recv.

This work is not yet finished... :(

0 attachments

0 comments

Loading commits...