To install LAPACK and BLAS library on Ubuntu, just type :
sudo apt-get install liblapack-dev
This automatically installs the LAPACK and BLAS library.
In my computer, this library was installed in this address: /usr/lib/lapack/
In order to use the lapack library to compile and run the code, one needs
to use the following command:
ifort ProgranmName.f90 -L /usr/lib/lapack/ -llapack
Another useful command to check the existence of subroutines and functions
in the LAPACK and BLAS library, we can use
readelf -s /usr/lib/lapack/liblapack.so.* | grep -i NameOfSubroutine
Useful links for more infos: Link1, Link2
Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts
Sunday, September 24, 2017
Tuesday, September 19, 2017
35 - How to install Anaconda on Ubuntu 16
The following tutorial of Anaconda is taken from HERE.
Anaconda is an open-source package manager,
environment manager, and distribution of the Python and R programming
languages. It is commonly used for large-scale data processing,
scientific computing, and predictive analytics, serving data scientists,
developers, business analysts, and those working in DevOps.
Anaconda offers a collection of over 720 open-source packages, and is
available in both free and paid versions. The Anaconda distribution
ships with the
conda command-line utility. You can learn more about Anaconda and conda by reading the Anaconda Documentation pages.
This tutorial will guide you through installing the Python 3 version of Anaconda on an Ubuntu 16.04 server.
Prerequisites
Before you begin with this guide, you should have a non-root user
with sudo privileges set up on your server. You can learn how to do this
by completing our Ubuntu 16.04 initial server setup guide.
Installing Anaconda
The best way to install Anaconda is to download the latest Anaconda installer bash script, verify it, and then run it.
Find the latest version of Anaconda for Python 3 at the Anaconda Downloads page. At the time of writing, the latest version is 4.2.0, but you should use a later stable version if it is available.
Next, change to the
/tmp directory on your server. This
is a good directory to download ephemeral items, like the Anaconda bash
script, which we won't need after running it.cd /tmp
Use
curl to download the link that you copied from the Anaconda website:
- curl -O https://repo.continuum.io/archive/Anaconda3-4.2.0-Linux-x86_64.sh
We can now verify the data integrity of the installer with
cryptographic hash verification through the SHA-256 checksum. We’ll use
the
sha256sum command along with the filename of the script:
- sha256sum Anaconda3-4.2.0-Linux-x86_64.sh
You’ll receive output that looks similar to this:
Output
73b51715a12b6382dd4df3dd1905b531bd6792d4aa7273b2377a0436d45f0e78 Anaconda3-4.2.0-Linux-x86_64.sh
You should check the output against the hashes available at the Anaconda with Python 3 on 64-bit Linux page for your appropriate Anaconda version. As long as your output matches the hash displayed in the
sha2561 row then you’re good to go.
Now we can run the script:
- bash Anaconda3-4.2.0-Linux-x86_64.s
You’ll receive the following output:
Output
Welcome to Anaconda3 4.2.0 (by Continuum Analytics, Inc.)
In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
Press
ENTER to continue and then press ENTER to read through the license. Once you’re done reading the license, you’ll be prompted to approve the license terms:Output
Do you approve the license terms? [yes|no]
As long as you agree, type
yes.
At this point, you’ll be prompted to choose the location of the installation. You can press
ENTER to accept the default location, or specify a different location to modify it.Output
Anaconda3 will now be installed into this location:
/home/sammy/anaconda3
- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below
[/home/sammy/anaconda3] >>>
The installation process will continue, it may take some time.
Once it’s complete you’ll receive the following output:
Output
...
installation finished.
Do you wish the installer to prepend the Anaconda3 install location
to PATH in your /home/sammy/.bashrc ? [yes|no]
[no] >>>
Type
yes so that you can use the conda command. You’ll next see the following output:Output
Prepending PATH=/home/sammy/anaconda3/bin to PATH in /home/sammy/.bashrc
A backup will be made to: /home/sammy/.bashrc-anaconda3.bak
...
In order to activate the installation, you should source the
~/.bashrc file:
- source ~/.bashrc
Once you have done that, you can verify your install by making use of the
conda command, for example with list:
- conda list
You’ll receive output of all the packages you have available through the Anaconda installation:
Output
# packages in environment at /home/sammy/anaconda3:
#
_license 1.1 py35_1
_nb_ext_conf 0.3.0 py35_0
alabaster 0.7.9 py35_0
...
Now that Anaconda is installed, we can go on to setting up Anaconda environments.
Setting Up Anaconda Environments
Anaconda virtual environments allow you to keep projects organized by
Python versions and packages needed. For each Anaconda environment you
set up, you can specify which version of Python to use and can keep all
of your related programming files together within that directory.
First, we can check to see which versions of Python are available for us to use:
- conda search "^python$"
You’ll receive output with the different versions of Python that you
can target, including both Python 3 and Python 2 versions. Since we are
using the Anaconda with Python 3 in this tutorial, you will have access
only to the Python 3 versions of packages.
Let’s create an environment using the most recent version of Python 3. We can achieve this by assigning version 3 to the
python argument. We’ll call the environment my_env,
but you’ll likely want to use a more descriptive name for your
environment especially if you are using environments to access more than
one version of Python.- conda create --name my_env python=3
We’ll receive output with information about what is downloaded and
which packages will be installed, and then be prompted to proceed with
y or n. As long as you agree, type y.
The
conda utility will now fetch the packages for the environment and let you know when it’s complete.
You can activate your new environment by typing the following:
- source activate my_env
With your environment activated, your command prompt prefix will change:
(my_env)sammy@ubuntu:~$
Within the environment, you can verify that you’re using the version of Python that you had intended to use:
(my_env)sammy@ubuntu:~$python --version
Output
Python 3.6.0 :: Continuum Analytics, Inc.
When you’re ready to deactivate your Anaconda environment, you can do so by typing:
(my_env)sammy@ubuntu:~$source deactivate
Note that you can replace the word
source with . to achieve the same results.
To target a more specific version of Python, you can pass a specific version to the
python argument, like 3.5, for example:- conda create -n my_env35 python=3.5
You can update your version of Python along the same branch (as in
updating Python 3.5.1 to Python 3.5.2) within a respective environment
with the following command:
(my_env)sammy@ubuntu:~$conda update python
If you would like to target a more specific version of Python, you can pass that to the
python argument, as in python=3.3.2.
You can inspect all of the environments you have set up with this command:
conda info --envs
Output
# conda environments:
#
my_env /home/sammy/anaconda3/envs/my_env
my_env35 /home/sammy/anaconda3/envs/my_env35
root * /home/sammy/anaconda3
The asterisk indicates the current active environment.
Each environment you create with
conda create will come with several default packages:opensslpippythonreadlinesetuptoolssqlitetkwheelxzzlib
You can add additional packages, such as
numpy for example, with the following command:- conda install --name my_env35 numpy
If you know you would like a
numpy environment upon creation, you can target it in your conda create command:- conda create --name my_env python=3 numpy
If you are no longer working on a specific project and have no
further need for the associated environment, you can remove it. To do
so, type the following:
- conda remove --name my_env35 --all
Now, when you type the
conda info --envs command, the environment that you removed will no longer be listed.
Updating Anaconda
You should regularly ensure that Anaconda is up-to-date so that you are working with all the latest package releases.
To do this, you should first update the
conda utility:- conda update conda
When prompted to do so, type
y to proceed with the update.
Once the update of
conda is complete, you can update the Anaconda distribution:- conda update anaconda
Again when prompted to do so, type
y to proceed.
This will ensure that you are using the latest releases of
conda and Anaconda.
Uninstalling Anaconda
If you are no longer using Anaconda and find that you need to uninstall it, you should start with the
anaconda-clean module which will remove configuration files for when you uninstall Anaconda. - conda install anaconda-clean
Type
y when prompted to do so.
Once it is installed, you can run the following command. You will be prompted to answer
y before deleting each one. If you would prefer not to be prompted, add --yes to the end of your command:anaconda-clean
This will also create a backup folder called
.anaconda_backup in your home directory:Output
Backup directory: /home/sammy/.anaconda_backup/2017-01-25T191831
You can now remove your entire Anaconda directory by entering the following command:
rm -rf ~/anaconda3
Finally, you can remove the PATH line from your
.bashrc file that Anaconda added. To do so, first open nano:- nano ~/.bashrc
Then scroll down to the end of the file (if this is a recent install) or type
CTRL + W to search for Anaconda. Delete or comment out the following lines:
/home/sammy/.bashrc
# added by Anaconda3 4.2.0 installer
export PATH="/home/sammy/anaconda3/bin:$PATH"
When you’re done editing the file, type
CTRL + X to exit and y to save changes.
Anaconda is now removed from your server.
Friday, June 24, 2016
34. Counting number of column of a data file in linux
In order to count number of columns of a data file, one could simply type the following command in the terminal:
head -n 1 file.name | awk'{print NF; exit}'
Sunday, May 3, 2015
33. Installing fonts on ubuntu 14.04
Once you have your favorite fonts (FontName.ttf):
1. Copy them to this address: /usr/share/fonts/truetype/ with the following command:
> sudo cp FontNamd.ttf /usr/share/fonts/truetype/
2. To scan the font directories on the system and build font information, type in the terminal:
> fc-cache -v /usr/share/fonts/truetype/
1. Copy them to this address: /usr/share/fonts/truetype/ with the following command:
> sudo cp FontNamd.ttf /usr/share/fonts/truetype/
2. To scan the font directories on the system and build font information, type in the terminal:
> fc-cache -v /usr/share/fonts/truetype/
Wednesday, August 21, 2013
31 - Finiding same files in two different directories:
Suppose we have two directories D1 and D2 which have a lot of different files.
To find which files are in common in these two directories we can use the following command in linux:
> comm -12 < (ls D1/) < (ls D2/)
To find which files are in common in these two directories we can use the following command in linux:
> comm -12 < (ls D1/) < (ls D2/)
Saturday, June 15, 2013
30 - Installing phython libraries in Ubuntu 12.04
To install numpy, scipy and matplotlib one needs to write the following lines in the terminal:
sudo apt-get update
sudo apt-get install python-numpy python-scipy python-matplotlib
sudo apt-get update
sudo apt-get install python-numpy python-scipy python-matplotlib
Tuesday, May 21, 2013
28 - Counting repetitious lines in a file:
If there are some lines in a file which are duplicated, one can count and sort them with using the following command:
$ cat filename | sort | uniq -c | sort -nr
If someone interested to delete the repetitious line from the file, the following command would be useful:
$ sort filename | uniq > filename_2
$ cat filename | sort | uniq -c | sort -nr
If someone interested to delete the repetitious line from the file, the following command would be useful:
$ sort filename | uniq > filename_2
Monday, April 8, 2013
27 - restart internet connection without rebooting computer in Ubuntu
Network interface in ubuntu is down with
$ sudo ifconfig eth0 down
and it is up by
$ sudo ifconfig eth0 up
$ sudo ifconfig eth0 down
and it is up by
$ sudo ifconfig eth0 up
Monday, March 25, 2013
24 - Counting number of lines in a file within FORTRAN code
If you want to determine the number of line in a given file within your FORTRAN code,
you can do this following nice trick!
program count_lines
implicit none
integer:: n
character(len=60):: cmd
cmd = "cat file_name.dat | grep '[^ ]' | wc -l > nlines.txt"
call system(cmd)
open(1,file='nlines.txt')
read(1,*) n
print*, "Number of lines are", n
cmd = 'rm nlines.txt'
call system(cmd)
end program
This simple code, uses linux command to find the number of lines.
Notice that cat file_name.dat | grep '[^ ]' | wc -l returns the number of lines in a file with ignoting the blank lines.
you can do this following nice trick!
program count_lines
implicit none
integer:: n
character(len=60):: cmd
cmd = "cat file_name.dat | grep '[^ ]' | wc -l > nlines.txt"
call system(cmd)
open(1,file='nlines.txt')
read(1,*) n
print*, "Number of lines are", n
cmd = 'rm nlines.txt'
call system(cmd)
end program
This simple code, uses linux command to find the number of lines.
Notice that cat file_name.dat | grep '[^ ]' | wc -l returns the number of lines in a file with ignoting the blank lines.
Sunday, January 13, 2013
22 - Comment out all line in the file at once with vim editor
If you want to comment out all (some) lines in your file, you can use the following recipe:
1. press ctrl+v and select the lines
2. press I for all highlighted lines
3. type # (for shell script) of ! (for .f90 files)
4. press Esc
5. press Esc
1. press ctrl+v and select the lines
2. press I for all highlighted lines
3. type # (for shell script) of ! (for .f90 files)
4. press Esc
5. press Esc
Saturday, January 12, 2013
21 - Installing Latex in Ubuntu
To install Latex type in terminal:
> sudo apt -get install texlive-full
To install an appropriate editor for using Latex:
> sudo apt -get install texmarker
The command "texmarker" is what you need to open this editor.
> sudo apt -get install texlive-full
To install an appropriate editor for using Latex:
> sudo apt -get install texmarker
The command "texmarker" is what you need to open this editor.
Wednesday, October 17, 2012
18 - tar an untar command in linux
For creating a tar gzipped archive we need to use tar command:
tar -cvzf File_name.tar.gz directory_name/
In this command,
c is create a new archive,
v is verbosely list files which are processed,
z is filter the archive through gzip,
f is following is the archive file name.
tar -cvzf File_name.tar.gz directory_name/
In this command,
c is create a new archive,
v is verbosely list files which are processed,
z is filter the archive through gzip,
f is following is the archive file name.
For extracting a gzipped tar archive (*.tar.gz) we need to use again tar command, but with appropriate option:
tar -xvzf archive_name.tar.gz
in this command,
x is extracting files from the archive file.
Sunday, August 26, 2012
15 - Line by line comparing of two files
If you want to check two different files line by line, you can use the following command:
> vimdiff file1 file2
In this way, in vim editor, you can see different colors (pink and red) if these two files are different.
The red color tells you that these files are different in that line.
> vimdiff file1 file2
In this way, in vim editor, you can see different colors (pink and red) if these two files are different.
The red color tells you that these files are different in that line.
Monday, August 13, 2012
13. Adding your own command in terminal:
For adding your own command which is doing an specific job for you, in the terminal of your Macbook, write
1. vim ~/.profile
2. alias your_command_name = "add you optional command you needed"
for example I did like this:
alias line = "tail -n 100 Myfile.dat > out.dat"
this means that, if I write the new command, line, in the terminal, I can find the last 100 lines of the Myfile.dat in the out.dat
3. source ~/.profile
1. vim ~/.profile
2. alias your_command_name = "add you optional command you needed"
for example I did like this:
alias line = "tail -n 100 Myfile.dat > out.dat"
this means that, if I write the new command, line, in the terminal, I can find the last 100 lines of the Myfile.dat in the out.dat
3. source ~/.profile
Wednesday, October 19, 2011
8- run paralel code in cluster with using nohoup command:
To run a paralel code, we should use this command:
mpirun -np 96 ./a.out
(96 = number of processors)
If you want to use nohoup command to run this code you have to
use following command to avoid unexpectable problems.
mpirun -np 96 ./a.out < /dev/null &
In this case, some additional and sucks lines will not appear in nouhup or
output files.
For example, I am using a job script to run the code. One of the lines in my job
script is :
mpirun -np $number ~/bin/dmft.cluster >> $out < /dev/null &
where dmft.cluster is executable file and output data will store in "out" file.
Wednesday, September 7, 2011
7. Why is swap space important in Linux?
I already faced with a problem about shortage of random access memory when I ran my code.
In this case Swap space can help us to overcome this problem (perhaps!).
Here is what swap is and what its applications is:
In this case Swap space can help us to overcome this problem (perhaps!).
Here is what swap is and what its applications is:
Linux divides its physical RAM (random access memory) into chucks of memory called pages. Swapping is the process whereby a page of memory is copied to the preconfigured space on the hard disk, called swap space, to free up that page of memory. The combined sizes of the physical memory and the swap space is the amount of virtual memory available.
Swapping is necessary for two important reasons. First, when the system requires more memory than is physically available, the kernel swaps out less used pages and gives memory to the current application (process) that needs the memory immediately. Second, a significant number of the pages used by an application during its startup phase may only be used for initialization and then never used again. The system can swap out those pages and free the memory for other applications or even for the disk cache.
More Info can be found in this 'website'
Sunday, September 4, 2011
6. Delete columns in a file via vim editor
For instans in a special file, you have lots of data which have been sorted by columns like this:
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
Now, we want to keep first and second columns and delete the rest ones.
To do this
1. press Ctrl+v (virtual block mod)
2. press G (to go to the end of the file)
3. press d (to delete highlighted columns)
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
Now, we want to keep first and second columns and delete the rest ones.
To do this
1. press Ctrl+v (virtual block mod)
2. press G (to go to the end of the file)
3. press d (to delete highlighted columns)
5. Sum useful commands in vim editor:
Where grep came from (RE being Regular Expression): :g/RE/p Delete lines 10 to 20 inclusive: :10,20d or with marks a and b: :'a,'bd Delete lines that contain pattern: :g/pattern/d Delete all empty lines: :g/^$/d Delete lines in range that contain pattern: :20,30/pattern/d or with marks a and b: :'a,'b/pattern/d Substitute all lines for first occurance of pattern: :%s/pattern/new/ :1,$s/pattern/new/ Substitute all lines for pattern globally (more than once on the line): :%s/pattern/new/g :1,$s/pattern/new/g Find all lines containing pattern and then append -new to the end of each line: :%s/\(.*pattern.*\)/\1-new/g Substitute range: :20,30s/pattern/new/g with marks a and b: :'a,'bs/pattern/new/g
More info can be found in these "website1" and "website2".
Sunday, June 5, 2011
2. Search an exact word in (a) file(s) with grep command.
For searching an expression, word, file and ... we can use 'grep' command in linux.
To find an exact word in a file(s) use 'grep' command as follows:
$ grep -w "one" *.f90
searching of 'one' in all .f90 files in the directory is the result of this command in terminal.
more info can be found in this website.
To find an exact word in a file(s) use 'grep' command as follows:
$ grep -w "one" *.f90
searching of 'one' in all .f90 files in the directory is the result of this command in terminal.
more info can be found in this website.
Friday, May 27, 2011
1. Copy file from server to my laptop computer and vice versa
Use scp command. for example I have a file in /usr/users/iff_th3/kiani/Mpi_test/example-KCuF3 named 'readme' and I want to copy it to my laptop computer in this address: /Users/kiani/Desktop.
scp kiani@ifflinux:/usr/users/iff_th3/kiani/Mpi_test/example-KCuF3/readme /Users/kiani/Desktop
And if I want to copy a file called 'Makefile' in my laptop computer to my home in cluster, I should use this command while I am in the directory where 'Makefile' exists:
scp Makefile kiani@ifflinux://usr/users/iff_th3/kiani
more details can be found in this webpage.
scp kiani@ifflinux:/usr/users/iff_th3/kiani/Mpi_test/example-KCuF3/readme /Users/kiani/Desktop
And if I want to copy a file called 'Makefile' in my laptop computer to my home in cluster, I should use this command while I am in the directory where 'Makefile' exists:
scp Makefile kiani@ifflinux://usr/users/iff_th3/kiani
more details can be found in this webpage.
Subscribe to:
Comments (Atom)