User Tools

Site Tools


howto:java

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
howto:java [2015/10/23 14:49]
dane created
howto:java [2021/12/09 16:42] (current)
Line 1: Line 1:
-Java blah blah+====== Using Java ====== 
 + 
 +=====Example Java Script===== 
 + 
 +<file java Hello.java> 
 +/* 
 +    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(); 
 +    } 
 +
 +</file> 
 + 
 +<code bash> 
 +$ module add chpc/openmpi/1.10.3/gcc-5.1.0_java-1.8.0_73 
 +$ mpijavac Hello.java 
 +</code> 
 + 
 +<file bash java_test.qsub> 
 +#!/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 
 +</file> 
 + 
 +<code bash> 
 +$ qsub java_test.qsub 
 +</code> 
 + 
 +**Notes:** 
 +  * Replace ''USERNAME'' with **your** user name. 
 +  * Replace ''YOUREMAILADDRESS'' with **your** email address.
/app/dokuwiki/data/attic/howto/java.1445604587.txt.gz · Last modified: 2021/12/09 16:42 (external edit)