safer MPI int types + allow -fdefault-integer-8: modified 54 .f90 files + Makefile;
Boud Roukema
Branch: broukema/ramses-use-mpif08:allow_64bit_int
Branch: rteyssie/ramses:master
Declined
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: Boud Roukema·2017-08-14
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 inamr/virtual_boundaries.f90
), while usinguse 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 inamr/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 edits/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
andkind=8
mean byte numbers togcc
, 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-scaleramses-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 whereuse mpi_f08
is not yet available (commitad79705
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... :(