在 CentOS 7 中实现 MPI 发送/接收时出错

发布于 2025-01-19 09:29:54 字数 2793 浏览 0 评论 0原文

我正在编译这个 MPI 程序,但它给了我 15 个错误,我不知道问题是什么。我到处寻找解决方案但一无所获。我的代码如下,我使用 CentOS 7。我可以编译并运行 OPENMPI 中的其他示例,但这个示例给了我错误。

import mpi.*;
class Hello3 {
  static public void main(String[] args) {
  MPI.Init(args) ;

 int myrank = MPI.COMM_WORLD.getRank();  
 if(myrank == 0) {
    char[] message = “Hello, there”.toCharArray();  
   MPI.COMM_WORLD.send(message, 0, message.length, MPI.CHAR, 1, 99);
 }
 else {
 char[] message = new char [20];  

 MPI.COMM_WORLD.recv(message, 0, 20, MPI.CHAR, 0, 99) ;
 System.out.println(“received:” + new String(message) + “:”);
 }
 MPI.Finalize();
}

如果尝试编译它,我会收到以下错误:

 [centos@localhost Downloads]$ mpijavac hello3.java
 hello3.java:8: error: illegal character: '\u201c'
 char[] message = “Hello, there”.toCharArray();  
            ^
 hello3.java:8: error: not a statement
 char[] message = “Hello, there”.toCharArray();  
             ^
 hello3.java:8: error: ';' expected
 char[] message = “Hello, there”.toCharArray();  
                  ^
 hello3.java:8: error: illegal character: '\u201d'
 char[] message = “Hello, there”.toCharArray();  
                         ^
  hello3.java:8: error: not a statement
  char[] message = “Hello, there”.toCharArray();  
                    ^
  hello3.java:15: error: illegal character: '\u201c'
  System.out.println(“received:” + new String(message) + “:”);
              ^
  hello3.java:15: error: ';' expected
  System.out.println(“received:” + new String(message) + “:”);
               ^
   hello3.java:15: error: illegal start of expression
  System.out.println(“received:” + new String(message) + “:”);
                       ^
  hello3.java:15: error: illegal character: '\u201d'
  System.out.println(“received:” + new String(message) + “:”);
                        ^
  hello3.java:15: error: illegal character: '\u201c'
  System.out.println(“received:” + new String(message) + “:”);
                                                  ^
   hello3.java:15: error: not a statement
   System.out.println(“received:” + new String(message) + “:”);
                                                ^
    hello3.java:15: error: illegal start of expression
    System.out.println(“received:” + new String(message) + “:”);
                                                   ^
    hello3.java:15: error: illegal character: '\u201d'
     System.out.println(“received:” + new String(message) + “:”);
                                                    ^
    hello3.java:15: error: illegal start of expression
    System.out.println(“received:” + new String(message) + “:”);
                                                     ^
     hello3.java:18: error: reached end of file while parsing
     }
      ^
     15 errors
    [centos@localhost Downloads]$

有人能帮助我吗?

I am compiling this MPI program but it is giving me 15 errors and I cannot really what the problems are. I have searched for solutions everywhere but found nothing. My code is as follows and I using CentOS 7. I am able to compile and run other examples from OPENMPI but this one is giving me errors.

import mpi.*;
class Hello3 {
  static public void main(String[] args) {
  MPI.Init(args) ;

 int myrank = MPI.COMM_WORLD.getRank();  
 if(myrank == 0) {
    char[] message = “Hello, there”.toCharArray();  
   MPI.COMM_WORLD.send(message, 0, message.length, MPI.CHAR, 1, 99);
 }
 else {
 char[] message = new char [20];  

 MPI.COMM_WORLD.recv(message, 0, 20, MPI.CHAR, 0, 99) ;
 System.out.println(“received:” + new String(message) + “:”);
 }
 MPI.Finalize();
}

If try to compile this, I get the following errors:

 [centos@localhost Downloads]$ mpijavac hello3.java
 hello3.java:8: error: illegal character: '\u201c'
 char[] message = “Hello, there”.toCharArray();  
            ^
 hello3.java:8: error: not a statement
 char[] message = “Hello, there”.toCharArray();  
             ^
 hello3.java:8: error: ';' expected
 char[] message = “Hello, there”.toCharArray();  
                  ^
 hello3.java:8: error: illegal character: '\u201d'
 char[] message = “Hello, there”.toCharArray();  
                         ^
  hello3.java:8: error: not a statement
  char[] message = “Hello, there”.toCharArray();  
                    ^
  hello3.java:15: error: illegal character: '\u201c'
  System.out.println(“received:” + new String(message) + “:”);
              ^
  hello3.java:15: error: ';' expected
  System.out.println(“received:” + new String(message) + “:”);
               ^
   hello3.java:15: error: illegal start of expression
  System.out.println(“received:” + new String(message) + “:”);
                       ^
  hello3.java:15: error: illegal character: '\u201d'
  System.out.println(“received:” + new String(message) + “:”);
                        ^
  hello3.java:15: error: illegal character: '\u201c'
  System.out.println(“received:” + new String(message) + “:”);
                                                  ^
   hello3.java:15: error: not a statement
   System.out.println(“received:” + new String(message) + “:”);
                                                ^
    hello3.java:15: error: illegal start of expression
    System.out.println(“received:” + new String(message) + “:”);
                                                   ^
    hello3.java:15: error: illegal character: '\u201d'
     System.out.println(“received:” + new String(message) + “:”);
                                                    ^
    hello3.java:15: error: illegal start of expression
    System.out.println(“received:” + new String(message) + “:”);
                                                     ^
     hello3.java:18: error: reached end of file while parsing
     }
      ^
     15 errors
    [centos@localhost Downloads]$

Is anyone able to help me please?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文