1

I have a code that I run on several different clusters, which all have different combinations of MPI & LAPACK.

This can cause problems. For example I currently use ifort's "-i8" option, which works fine with LAPACK, but now all MPI calls are broken, because it expects integer(4), rather than integer(8).

Is there an elegant & flexible way to adapt the integer type based on the local MPI & LAPACK installation?

Hard coding the types for every specific call seems is just very cumbersome and inflexible.

3
  • 1
    Can't think of a way to do this. But why do you want -i8? It probably ends up breaking the Fortran standard, and as such should be best avoided. Commented Jun 7, 2018 at 10:00
  • -i8 means that all integer :: a declarations are 64bit by default rather than the standard 32bit Commented Jun 7, 2018 at 11:08
  • I know exactly what i8 does, and I agree with Valdimir that this may not be a good idea (in my experience it has never been a good idea). So why do you want to use i8? Why must all your integers be 64 bit? Commented Jun 7, 2018 at 11:54

1 Answer 1

6

MPI calls do not expect INTEGER(4) nor INTEGER(8), they expect just INTEGER. And, as always, remember what those (4) and (8) actually mean Fortran: integer*4 vs integer(4) vs integer(kind=4)

With -i8 you are changing what INTEGER means, to which kind it corresponds. You can do that, but you have to compile the MPI library with the same settings. The library may or may not be prepared to be compiled that way, but theoretically it should be possible.

You could also try passing integer(int32) instead of integer to MPI. If it is the correct kind which correspond to the default kind of the MPI library, the TKR checks and all other checks should pass OK. But it is not recommended.

To stay strictly within the Fortran standard, when you promote the default integer kind, you should also promote the default real and logical kind.

To stay portable use integers that correspond to the API of the library you use and make sure the library is meant to be used with that particular compiler and with that particular compiler configuration.

Usually, for portability one should not rely on promoting the default kinds but one should use specific kinds which suit the given purpose in the specific part of the code.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.