http://climate-cms.wikis.unsw.edu.au/api.php?action=feedcontributions&user=Ravdanny&feedformat=atomclimate-cms wikis.unsw.edu.au - User contributions [en]2024-03-28T21:47:26ZUser contributionsMediaWiki 1.31.0http://climate-cms.wikis.unsw.edu.au/index.php?title=FortranIntro&diff=146FortranIntro2018-12-20T23:27:38Z<p>Ravdanny: Imported from Wikispaces</p>
<hr />
<div><br />
=Introduction to Fortran= <br />
<br />
In the world of high-performance computing there are two main choices of programming language, C and Fortran. Highly tuned compilers are available for both languages, along with function libraries which help in creating parallel programs.<br />
<br />
Each language has different strengths, Fortran's array syntax allows for computations over large datasets to be done efficiently and trivially parallelised, while C gives you control over memory to make use of more complicated data structures. Both languages are continuing to be improved, the last release of the Fortran standard was in 2008, mainly adding co-arrays for shared memory programming.<br />
<br />
Many models in the Earth Sciences are programmed in Fortran, including the Met Office Unified Model and MOM amongst others.<br />
<br />
==Compiling== <br />
<br />
A basic Fortran program is<br />
<syntaxhighlight lang=fortran><br />
! hello.f90<br />
program hello<br />
implicit none<br />
<br />
write(*,*) 'Hello'<br />
end program<br />
</syntaxhighlight><br />
<br />
This program simply writes 'Hello' to the console.<br />
<br />
On NCI Fortran programs are compiled using the ifort compiler.<br />
<syntaxhighlight lang=bash><br />
$ module load intel-fc<br />
$ ifort -warn all -warn errors hello.f90<br />
$ ./a.out<br />
Hello<br />
</syntaxhighlight><br />
<br />
The <span style="font-family:monospace">module}} command makes ifort available for use. The default program name when you compile using ifort is {{a.out}}, you can change what the filename is by adding {{-o OUTPUT}} to the ifort command. The warning flags {{-warn all -warn errors</span> makes sure that ifort checks for any programming errors, make sure to fix them!<br />
<br />
==Variables== <br />
<br />
Variables in Fortran are declared like<br />
<syntaxhighlight lang=fortran><br />
type(kind=4), options :: name<br />
</syntaxhighlight><br />
<br />
<span style="font-family:monospace">type}} is the variable type, usually one of {{integer}}, {{real}} or {{logical}}. To change how many bytes are used in a variable change the kind, for instance {{real(kind=8)</span> is a 64 bit (8 byte) ieee floating point number. The kind is optional, the default value is platform specific but should be at least 4 bytes. Usually you won't worry about kinds.<br />
<br />
Various options are possible, for instance <span style="font-family:monospace">dimension(2,3)}} makes the variable a 2x3 array, {{parameter</span> ensures the variable is unchanged by the program (it's value must be set in the declaration)<br />
<br />
Fortran programs and functions have two main sections, variable declaration and the program proper. All variables used should be declared, the command <span style="font-family:monospace">implicit none</span> at the start of a function ensures this. Variable declaration cannot be mixed with program statements.<br />
<br />
<syntaxhighlight lang=fortran><br />
program variables<br />
implicit none<br />
integer(kind=8) :: run_count<br />
real, dimension(4) :: x, y<br />
real, dimension(4,4) :: temperature<br />
real, parameter :: pi = 3.1415926<br />
<br />
...<br />
end program<br />
</syntaxhighlight><br />
<br />
==Types== <br />
<br />
<syntaxhighlight lang=fortran><br />
type field<br />
integer :: nx,ny<br />
real, allocable :: x(:), y(:)<br />
real, allocable :: data(:,:)<br />
end type<br />
</syntaxhighlight><br />
<br />
==Functions & Subroutines== <br />
<br />
==Modules==</div>Ravdannyhttp://climate-cms.wikis.unsw.edu.au/index.php?title=Gadi&diff=286Gadi2018-08-10T03:58:46Z<p>Ravdanny: Imported from Wikispaces</p>
<hr />
<div><br />
**Raijin''' is NCI's primary supercomputer, which was brought into service in July 2013. It has 3592 compute nodes, each containing two 8-core Intel Sandy-Bridge processors. The majority of nodes have 32GB of memory, with ~1000 having 64 GB.<br />
<br />
NCI have a [http://nci.org.au/nci-systems/national-facility/peak-system/raijin/user-guides | user guide for Raijin] available on their website which you should also read through.<br />
<br />
=Getting an account= <br />
<br />
If you don't already have a NCI account you should [http://nci.org.au/access/getting-access-to-the-national-facility/register-as-new-user/ | apply for one]. You'll also need to be connected to a NCI project for accounting purposes, your CI or supervisor should be able to give you the project code to use in the [http://nci.org.au/access/getting-access-to-the-national-facility/connect-to-existing-project/ | connection form]. NCI will send you a password via SMS once your application has been processed, this usually takes under a day to do.<br />
<br />
=Connecting to Raijin= <br />
<br />
To connect to Raijin you'll need to use a SSH connection to <span style="font-family:monospace">raijin.nci.org.au}}. If you're using Windows you'll need to use something like [http://www.putty.org/ | PuTTY], or if you're connecting from linux or mac run on the commandline (substitute {{abc123</span> with your own username)<br />
<syntaxhighlight><br />
ssh -Y abc123@raijin.nci.org.au<br />
</syntaxhighlight><br />
<br />
You can make a shortcut for this by editing the file <span style="font-family:monospace">~/.ssh/config</span> and adding the lines:<br />
<syntaxhighlight><br />
Host raijin<br />
HostName raijin.nci.org.au<br />
User abc123<br />
ForwardX11 true<br />
ForwardX11Trusted true<br />
</syntaxhighlight><br />
This way you just need to type '<span style="font-family:monospace">ssh raijin</span>' to connect.<br />
<br />
If you want to use VNC instead of X11 Forwarding, see this guide: [[VNC to Raijin]]<br />
<br />
=Swapping Projects= <br />
<br />
If you use more than one project you can swap between them with the command '<span style="font-family:monospace">switchproj</span>', e.g.<br />
<syntaxhighlight><br />
switchproj w35<br />
</syntaxhighlight><br />
will change your current project to w35.<br />
<br />
You can also change your default project by editing the file on Raijin <span style="font-family:monospace">~/.rashrc</span>, it should have a line like<br />
<syntaxhighlight><br />
setenv PROJECT w35<br />
</syntaxhighlight><br />
<br />
=Resources on Raijin= <br />
<br />
To see how much compute time you have available run the command<br />
<syntaxhighlight><br />
nci_account -P $PROJECT -q 2013.q3<br />
</syntaxhighlight><br />
<br />
To see how much storage space you have available run the command<br />
<syntaxhighlight><br />
lquota -P $PROJECT<br />
</syntaxhighlight><br />
<br />
=Submitting Jobs= <br />
<br />
To run a job on the supercomputer you submit it to a job queue using the '<span style="font-family:monospace">qsub</span>' command. Jobs are shell script files, they contain special markers to say what resources the job needs.<br />
<br />
As an example the script "hello.sh"<br />
<syntaxhighlight><br />
#!/bin/bash<br />
#PBS -l ncpus=2<br />
#PBS -l walltime=10:00<br />
#PBS -l mem=1gb<br />
#PBS -v PROJECT<br />
<br />
echo "Hello"<br />
</syntaxhighlight><br />
says to run with 2 cpus for a maximum time of 10 minutes. The job can use up to 1 GB of memory. Anything after the <span style="font-family:monospace">#PBS}} lines is what gets run on the supercomputer, in this instance it just prints "Hello" (any output goes to files in the directory you submitted the job named like "hello.sh.o123456", error messages go to files named like "hello.sh.e123456). The command '{{-v PROJECT}}' means run using the current project, you can also specify a project to use like '{{-v PROJECT=w35</span>'.<br />
<br />
If the job tries to use more resources than it's asked for it will be automatically stopped. The less resources you ask for the more likely it is that your job will run quickly however, you should try to request an amount close to what the job actually uses.<br />
<br />
=Managing Jobs= <br />
<br />
To see a list of your submitted & currently running jobs run<br />
<syntaxhighlight><br />
nqstat<br />
</syntaxhighlight><br />
This also shows how much resources each job has requested & is currently using.<br />
<br />
Each job in the queue has a run id number associated with it (this is also printed when you submit a job with <span style="font-family:monospace">qsub</span>). To get more information on a job run<br />
<syntaxhighlight><br />
qstat -s 123456 # Show any status information, e.g. why the job isn't currently running<br />
qstat -f 123456 # Show full information, including resources requested & environment variables<br />
</syntaxhighlight><br />
To remove a job from the queue use <span style="font-family:monospace">qdel</span><br />
<syntaxhighlight><br />
qdel 123456 # Remove the job 123456 from the queue<br />
</syntaxhighlight><br />
<br />
=Changes from Vayu= <br />
<br />
Vayu was NCI's previous supercomputer. There are some changes that need to be made to run jobs designed for Vayu run on Raijin.<br />
<br />
The PBS flags<br />
<syntaxhighlight><br />
#PBS -l vmem=2gb<br />
#PBS -wd<br />
</syntaxhighlight><br />
should be changed to<br />
<syntaxhighlight><br />
#PBS -l mem=2gb<br />
#PBS -l wd<br />
</syntaxhighlight><br />
<br />
The environment variable $PROJECT should be set before submitting a job, or a line like<br />
<syntaxhighlight><br />
#PBS -v PROJECT=w35<br />
</syntaxhighlight><br />
should be added to scripts.<br />
<br />
Shared ACCESS data that used to be in the path<br />
<syntaxhighlight><br />
/data/projects/access<br />
</syntaxhighlight><br />
is now available under<br />
<syntaxhighlight><br />
~access/data<br />
</syntaxhighlight></div>Ravdannyhttp://climate-cms.wikis.unsw.edu.au/index.php?title=Running_Jupyter_Notebook&diff=301Running Jupyter Notebook2018-07-12T05:24:09Z<p>Ravdanny: Imported from Wikispaces</p>
<hr />
<div>=On VDI= <br />
<br />
Currently, the easiest way to run IPython Notebook is on NCI's [http://nci.org.au/services/vdi/ | Virtual Desktop Infrastructure (VDI)]. For a guide to set up and use VDI, click [https://opus.nci.org.au/display/Help/VDI+User+Guide | here].<br />
<br />
Within VDI, open a Linux terminal ('''Applications menu''' -> '''System Tools''' -> '''Terminal''').<br />
Inside the Terminal, load the conda environment<br />
<syntaxhighlight lang=bash><br />
module use /g/data3/hh5/public/modules<br />
module load conda<br />
<br />
</syntaxhighlight><br />
You should then be able to start the notebook with<br />
<syntaxhighlight lang=bash><br />
jupyter notebook<br />
</syntaxhighlight><br />
<span style="background-color: #ffffff; color: #333333; display: block; font-family: &quot;Helvetica Neue&quot;,Helvetica,Arial,sans-serif; font-size: 14px;"><br />
----<br />
</span><span style="background-color: #ffffff; display: block; font-family: Arial,Helvetica,sans-serif;"><br />
=On Raijin= <br />
<br />
If you don't have access to VDI, you can still run IPython Notebook from Raijin in a browser on your local computer. Currently these instructions show how to run the notebook from the login node - '''which is not recommended''' - and, as such, are just a demonstration of what is possible. Ideally the notebook should be run from an interactive session.<br />
</span><br />
Log in to raijin using SSH, forwarding your ports as you go (you might have to sudo this)<br />
<syntaxhighlight lang=bash><br />
ssh -L 8889:localhost:8889 [USERNAME]@raijin.nci.org.au<br />
</syntaxhighlight><br />
Load the conda environment<br />
<syntaxhighlight lang=bash><br />
module use /g/data3/hh5/public/modules<br />
module load conda<br />
</syntaxhighlight><br />
<br />
Set up an ipython profile that serves your notebooks (adapted from [[https://ipython.org/ipython-doc/dev/notebook/public_server.html]])<br />
<syntaxhighlight lang=bash><br />
ipython profile create nbserver<br />
</syntaxhighlight><br />
<br />
Then modify the Notebook config file in ~/.ipython/profile_nbserver/ipython_config.py (or create that file if it wasn't generated) so that it reads:<br />
<syntaxhighlight lang=python><br />
c = get_config()<br />
c.NotebookApp.open_browser = False<br />
# It is a good idea to put it on a known, fixed port - must match port used to ssh in.<br />
c.NotebookApp.port = 8889<br />
c.NotebookApp.base_project_url = 'ipython'<br />
<br />
# The following can be used to set up a password,<br />
# from here: https://ipython.org/ipython-doc/dev/notebook/public_server.html<br />
# c.NotebookApp.certfile = u'/absolute/path/to/your/certificate/mycert.pem'<br />
# c.NotebookApp.ip = '*'<br />
# c.NotebookApp.password = u'sha1:bcd259ccf...[your hashed password here]'<br />
<br />
</syntaxhighlight><br />
The dependencies required for ipython have been installed and should load automatically when the ipython module is loaded.<br />
<br />
You should be able to start the notebook with<br />
<syntaxhighlight lang=bash><br />
ipython notebook --profile=nbserver<br />
</syntaxhighlight><br />
<br />
On your local computer, direct your browser to [[http://127.0.0.1:8889/ipython/]] and you should have access to the notebook.<br />
<br />
If another user is already running an ipython session using the port number above, the ipython process will tell you with a message like this:<br />
<syntaxhighlight><br />
[I 11:06:03.545 NotebookApp] The port 8899 is already in use, trying another random port.<br />
</syntaxhighlight><br />
and it will tell you which port it has chosen instead:<br />
<syntaxhighlight><br />
[I 11:06:03.552 NotebookApp] The IPython Notebook is running at: http://localhost:8900/ipython/<br />
</syntaxhighlight><br />
<br />
Unfortunately the ssh connection will only forward the port you specified when you logged in. You should edit the ~/.ipython/profile_nbserver/ipython_config.py file, change the port number to the one ipython chose (or another higher number less than 65535), log out and log back in, using the new port number.<br />
<syntaxhighlight lang=bash><br />
ssh -L 8889:localhost:8890 [USERNAME]@raijin.nci.org.au<br />
</syntaxhighlight><br />
The first port number is the one you connect to on your local computer, and can remain unchanged.<br />
[[Category:python]][[Category:ipython]][[Category:ipython notebook]]</div>Ravdannyhttp://climate-cms.wikis.unsw.edu.au/index.php?title=CLEX_projects_at_NCI&diff=77CLEX projects at NCI2018-06-22T03:16:31Z<p>Ravdanny: Imported from Wikispaces</p>
<hr />
<div>The projects are:<br />
{| <br />
! Project code !! Research Program (RP) !! Lead CI <br />
|-<br />
| v45 || Extra-tropical variability || Andy Hogg <br />
|-<br />
| w35 || Drought || Claire Carouge <br />
|-<br />
| w40 || Extreme Rainfall || Todd Lane <br />
|-<br />
| w42 || Extreme Rainfall || Steven Sherwood <br />
|-<br />
| w48 || Tropical Variability || Dietmar Dommenget <br />
|-<br />
| w97 || Heatwaves || Jason Evans <br />
|-<br />
|}<br />
===Which project to join if part of several RPs=== <br />
We recommend people join all relevant projects but choose one project to work from. This will help people to collaborate with researchers from all the RPs they are part of.<br />
<br />
===Setup default project on Raijin=== <br />
* Check your default project. Connect to raijin. Then type:<br />
<syntaxhighlight><br />
echo $PROJECT<br />
</syntaxhighlight><br />
* Change your default project. If the output from the previous step is not what you want, you need to open the ~/.rashrc file in a text editor. Change the project ID in this file then save and close the file. EXIT your login session (and all others you may have currently open) and log in back. Your default project should have changed (check as in step 1).</div>Ravdanny