I am not able to compile with MPI compiler with C++
Asked Answered
P

2

6

I was trying to compile a very simple MPI hello_world:

#include <stdio.h>
#include <mpi.h>

int main(int argc, char *argv[]) {
    int numprocs, rank, namelen;
    char processor_name[MPI_MAX_PROCESSOR_NAME];

    MPI_Init(&argc, &argv);
    MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    MPI_Get_processor_name(processor_name, &namelen);

    printf("Process %d on %s out of %d\n", rank, processor_name, numprocs);

    MPI_Finalize();
}

And got the following problem:

    Catastrophic error: could not set locale "" to allow processing of multibyte characters

I really don't know how to figure it out.

Psychiatry answered 14/11, 2012 at 19:20 Comment(4)
Does the error message give a filename and/or line number? Does your source file have non-ASCII characters in it? Is your source file encoded in UTF-16?Chefoo
Is that compiler error? Which line does it come from? Or is it runtime error, presumably generated by MPI_Get_processor_name, since that's the only one handling strings? Does it disappear if you remove string stuff?Goodish
You're on Mac OSX? They had an issue with locales being unavailable, IIRCTobytobye
You've shown all your code, but not your commands and not your full output.Pantia
G
18

Try defining environment variables

LANG=en_US.utf8
LC_ALL=en_US.utf8

Assuming you're on unix, also try man locale and locale -a at command line, and google for "utf locale" and similar searches.

Goodish answered 14/11, 2012 at 20:0 Comment(3)
Yes, That is the problem. The issue is my computer LANG=UTF-8 and when I ssh to the remote server, the server's LANG changed!!!Psychiatry
@user1819905, UTF-8 is not a valid language specification. It should be something like en_US.UTF-8 or de_DE.UTF-8. And yes, it could be propagated to the server environment over SSH if the SSH client is configured to do so. The SSH client in 10.7+ is.Granular
This works for me. Seems that I have different UTF encoding between my local machine and the remote server.Vermeil
D
0

Re-defining the environment variable LANG solved the problem for me, as pointed out (setting LANG=en_US.utf8).

I may say that I'm conecting to a foreign server, and there's where I get the problem compiling code with Intel compilers.

Delphinus answered 3/11, 2021 at 21:48 Comment(1)
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From ReviewKeystroke

© 2022 - 2024 — McMap. All rights reserved.