/* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. */ /* * Copyright (c) 2011 Cisco Systems, Inc. All rights reserved. * */ import mpi.*; import java.net.InetAddress; class Hello { static public void main(String[] args) throws MPIException { MPI.Init(args); int myrank = MPI.COMM_WORLD.getRank(); int size = MPI.COMM_WORLD.getSize() ; InetAddress IP; try { IP = InetAddress.getLocalHost().getLocalHost(); System.out.println("Hello world from rank " + myrank + " of " + size+" I'm running on "+IP.getLocalHost()); } catch (Exception e) { } MPI.Finalize(); } }
$ module add chpc/openmpi/1.10.3/gcc-5.1.0_java-1.8.0_73 $ mpijavac Hello.java
#!/bin/bash #PBS -l select=2:ncpus=24:mpiprocs=24 #PBS -l walltime=00:01:00 #PBS -q normal #PBS -P SHORTNAME #PBS -M YOUREMAILADDRESS #PBS -m be #PBS -e /mnt/lustre/users/USERNAME/java_test/std_err.txt #PBS -o /mnt/lustre/users/USERNAME/java_test/std_out.txt #PBS -N JAVA_TEST module add chpc/openmpi/1.10.3/gcc-5.1.0_java-1.8.0_73 NP=`cat ${PBS_NODEFILE} | wc -l` cd /mnt/lustre/users/USERNAME/java_test mpirun -np ${NP} -machinefile ${PBS_NODEFILE} java Hello
$ qsub java_test.qsub
Notes:
USERNAME
with your user name.YOUREMAILADDRESS
with your email address.