This is an old revision of the document!
/* 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 openmpi/openmpi-1.10.0_gcc-4.7.2
$ module mpijavac Hello.java
#!/bin/bash #PBS -l select=2:ncpus=8:mpiprocs=8 #PBS -l walltime=00:01:00 #PBS -q netboot #PBS -M YOUREMAILADDRESS #PBS -m be #PBS -V #PBS -e /lustre/SCRATCH5/users/USERNAME/java_test/std_err.txt #PBS -o /lustre/SCRATCH5/users/USERNAME/java_test/std_out.txt #PBS -N JAVA_TEST #PBS -mb MODULEPATH=/opt/gridware/bioinformatics/modules:$MODULEPATH source /etc/profile.d/modules.sh module add openmpi/openmpi-1.10.0_gcc-4.7.2 NP=`cat ${PBS_NODEFILE} | wc -l` cd /lustre/SCRATCH5/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.