Difference between revisions of "Howto"

From MyUbuntu
Jump to navigation Jump to search
 
(32 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
==How to use SSH without passwords==
 
==How to use SSH without passwords==
You want to enter from computer A into computer B using ssh without passwords
+
*You want to enter from computer A into computer B using ssh without passwords
 +
<ol>
 +
<li>
 
Generate the public keys in computer A
 
Generate the public keys in computer A
 +
<pre>
 
ssh-keygen -t dsa
 
ssh-keygen -t dsa
 
ssh-keygen -t rsa
 
ssh-keygen -t rsa
 +
</pre>
 
and follow the instructions
 
and follow the instructions
 
+
</li>
 +
<li>
 
Copy the public keys for computer A into a file authorized_keys_A
 
Copy the public keys for computer A into a file authorized_keys_A
 +
<pre>
 
cd; cd .ssh
 
cd; cd .ssh
 
cp id_dsa.pub authorized_keys_A
 
cp id_dsa.pub authorized_keys_A
 
cat id_rsa.pub >> authorized_keys_A
 
cat id_rsa.pub >> authorized_keys_A
 +
</pre>
 +
</li>
 +
<li>
 
Copy the file to computer B using your password
 
Copy the file to computer B using your password
 +
<pre>
 
scp authorized_keys_A user@Computer_B
 
scp authorized_keys_A user@Computer_B
 +
</pre>
 +
</li>
 +
<li>
 
Login into Computer B using your password
 
Login into Computer B using your password
Move the file to the directory .ssh. If this this the only computer you want to use move the file to authorized_keys
+
</li>
 +
<li>
 +
Move the file to the directory .ssh. If this is the only computer you want to use move the file to authorized_keys
 +
<pre>
 
cd .ssh
 
cd .ssh
 
mv authorized_keys_A authorized_keys
 
mv authorized_keys_A authorized_keys
 +
</pre>
 +
</li>
 +
<li>
 
If you want to do the same with other computers and have already an authorizes_keys file, then append it
 
If you want to do the same with other computers and have already an authorizes_keys file, then append it
 +
<pre>
 
cat authorized_keys_A >> authorized_keys
 
cat authorized_keys_A >> authorized_keys
 +
</pre>
 +
</li>
 +
<li>
 
If it fails (it happened with Ubuntu 18.04) after the procedure explained do in client side (computer A)
 
If it fails (it happened with Ubuntu 18.04) after the procedure explained do in client side (computer A)
 +
<pre>
 
ssh-add
 
ssh-add
 +
</pre>
 
Verify with
 
Verify with
 
+
<pre>
 
ssh-add -l
 
ssh-add -l
 +
</pre>
 +
</li>
 +
<li>
 
That is all. Now you can login from A to B without password and using ssh.
 
That is all. Now you can login from A to B without password and using ssh.
Main Page
+
</li>
 +
</ol>
 +
[[Main Page]]
  
 
==How to use the nodes@cftp==
 
==How to use the nodes@cftp==
What are the nodes
+
===What are the nodes (This information is obsolete)===
The nodes are 6 computers dedicated only for calculations. Each have 4 CPU's, in a total of 24 CPU's.
+
*The nodes are 6 computers dedicated only for calculations. Each have 4 CPU's, in a total of 24 CPU's.
They are different, so they are not good to use in parallel programming
+
*They are different, so they are not good to use in parallel programming
 
From the net you can only access node1:
 
From the net you can only access node1:
 +
<pre>
 
ssh user@node1.tecnico.ulisboa.pt
 
ssh user@node1.tecnico.ulisboa.pt
 +
</pre>
 
The others 5 are in a sub-net and can only be accessed from node1
 
The others 5 are in a sub-net and can only be accessed from node1
  
There is only one user directory in node1. It is automatically mounted on all the other nodes, so you will always see the same directory structure
+
*There is only one user directory in node1. It is automatically mounted on all the other nodes, so you will always see the same directory structure
You should not use the nodes running the programs directly. You should use the software Sun Grid Engine described below
+
*You should not use the nodes running the programs directly. You should use the software Sun Grid Engine described below
How to use the software Sun Grid Engine
+
 
The main idea is that you submit the jobs using a software that knows what are the free CPU's in each node and submits the job there
+
===How to use the software Sun Grid Engine (Not anymore installed)===
This is best done using scripts. I am going to show two basic scripts. For this suppose that you have a directory structure as follows
+
*The main idea is that you submit the jobs using a software that knows what are the free CPU's in each node and submits the job there
 +
*This is best done using scripts. I am going to show two basic scripts. For this suppose that you have a directory structure as follows
 +
<pre>
 
Examples
 
Examples
 
├── Dir1
 
├── Dir1
Line 50: Line 84:
 
├── job1.sh
 
├── job1.sh
 
└── job2.sh
 
└── job2.sh
This means that you have a base Directory Examples and two sub-directories Dir1 and Dir2.
+
</pre>
Inside each of these directories there are all the files needed to run the program, including the executable and any other necessary input. The final results will go also into these directories.
+
*This means that you have a base Directory Examples and two sub-directories Dir1 and Dir2.
In the base directories there are two scripts. They do the same thing, but they differ in a way I will explain below.
+
*Inside each of these directories there are all the files needed to run the program, including the executable and any other necessary input. The final results will go also into these directories.
Script job1.sh
+
*In the base directories there are two scripts. They do the same thing, but they differ in a way I will explain below.
 +
*<b>Script job1.sh</b>
 +
<pre>
 
#!/bin/bash -x                                                                   
 
#!/bin/bash -x                                                                   
 
#
 
#
Line 92: Line 128:
  
 
exit
 
exit
You run this script with the command
+
</pre>
 +
 
 +
*You run this script with the command
 +
<pre>
 
qsub job1.sh Dir1
 
qsub job1.sh Dir1
 +
</pre>
 
or
 
or
 
+
<pre>
 
qsub job1.sh Dir2
 
qsub job1.sh Dir2
When the program ends the results are in those directories
+
</pre>
If the program takes sometime, you can see if they are running with the command
+
*When the program ends the results are in those directories
 +
*If the program takes sometime, you can see if they are running with the command
 +
<pre>
 
qstat
 
qstat
The output is something like this
+
</pre>
 
+
*The output is something like this
 +
<pre>
 
node1$ qstat
 
node1$ qstat
 
job-ID  prior  name      user        state submit/start at    queue                          slots ja-task-ID  
 
job-ID  prior  name      user        state submit/start at    queue                          slots ja-task-ID  
Line 107: Line 150:
 
     244 0.55500 job1.sh    romao        r    06/07/2016 19:30:41 all.q@node6                        1         
 
     244 0.55500 job1.sh    romao        r    06/07/2016 19:30:41 all.q@node6                        1         
 
     245 0.55500 job1.sh    romao        r    06/07/2016 19:30:41 all.q@node3   
 
     245 0.55500 job1.sh    romao        r    06/07/2016 19:30:41 all.q@node3   
To kill a job, first get the job number with the command qstat, and then use
+
</pre>
 +
*To kill a job, first get the job number with the command qstat, and then use
 +
<pre>
 
qdel jobnumber1 jobnumber2 ...
 
qdel jobnumber1 jobnumber2 ...
 +
</pre>
 
You can delete several jobs with the same command
 
You can delete several jobs with the same command
  
Script job2.sh
+
*<b>Script job2.sh</b>
 +
<pre>
 
#!/bin/bash -x                                                                 
 
#!/bin/bash -x                                                                 
 
#                                                                               
 
#                                                                               
Line 175: Line 222:
  
 
exit
 
exit
This script does the same thing with one difference. In the first script the jobs are run inside the directories Dir1 and Dir2. These directories are physically in node1 and mounted by nfs on the other machines. If your job writes many times to the disk, these results have to transferred by nfs to the directory in node1 and this slows down the performance. The script job2.sh solves this problem by copying the program files in the /tmp directory in the nodes where you are running. Uses the scratch space there and only when the job end copies everything back to your directory.
+
</pre>
You have to change the names of the program files to suit your case
+
*This script does the same thing with one difference. In the first script the jobs are run inside the directories Dir1 and Dir2. These directories are physically in node1 and mounted by nfs on the other machines. If your job writes many times to the disk, these results have to transferred by nfs to the directory in node1 and this slows down the performance. The script job2.sh solves this problem by copying the program files in the /tmp directory in the nodes where you are running. Uses the scratch space there and only when the job end copies everything back to your directory.
Warning: To use this script you have to have ssh without passwords enabled between node1 and the other nodes. See above
+
*You have to change the names of the program files to suit your case
 +
*<b>Warning</b>: To use this script you have to have ssh without passwords enabled between node1 and the other nodes. See above
  
Main Page
+
[[Main Page]]
  
 
==Mathematica and Fortran==
 
==Mathematica and Fortran==
How to Enable debugging in ifort
+
===How to Enable debugging in ifort===
To be able to traceback where the error comes from one should compile with the options
+
*To be able to traceback where the error comes from one should compile with the options
 +
<pre>
 +
ifort -g -traceback ...
 +
</pre>
  
ifort -g -traceback ...
+
===How to Export data from Mathematica===
How to Export data from Mathematica
+
*Suppose that you have a list with several entries in mathematica. Let us consider an example
Suppose that you have a list with several entries in mathematica. Let us consider an example
+
<pre>
 
In[2]:= data = Table[{x, Sin[x], Cos[x]}, {x, 0., Pi, Pi/16}]
 
In[2]:= data = Table[{x, Sin[x], Cos[x]}, {x, 0., Pi, Pi/16}]
  
Line 209: Line 260:
  
 
)
 
)
You can export this data into a file by doing
+
</pre>
 +
*You can export this data into a file by doing
 +
<pre>
 
In[3]:= Export["datafile.dat", data,"TSV"]
 
In[3]:= Export["datafile.dat", data,"TSV"]
  
 
Out[3]= datafile.dat
 
Out[3]= datafile.dat
The file will look like
+
</pre>
 +
*The file will look like
 +
<pre>
 
0. 0. 1.
 
0. 0. 1.
 
0.19634954084936207 0.19509032201612825 0.9807852804032304
 
0.19634954084936207 0.19509032201612825 0.9807852804032304
Line 231: Line 286:
 
2.945243112740431 0.1950903220161286 -0.9807852804032304
 
2.945243112740431 0.1950903220161286 -0.9807852804032304
 
3.141592653589793 1.2246467991473532e-16 -1.
 
3.141592653589793 1.2246467991473532e-16 -1.
How to Import data into Mathematica
+
</pre>
Data can be imported into Mathematica with the command
+
 
 +
===How to Import data into Mathematica===
 +
*Data can be imported into Mathematica with the command
 +
<pre>
 
newdata = Import["datafile.dat"]
 
newdata = Import["datafile.dat"]
This produces the output
+
</pre>
 +
*This produces the output
 +
<pre>
 
In[1] =newdata
 
In[1] =newdata
 
Out[1]=(0. 0. 1.
 
Out[1]=(0. 0. 1.
Line 255: Line 315:
  
 
)
 
)
How to Export from Mathematica into Fortran
+
</pre>
It is many times useful to output the results of Mathematica into a Fortran file. To export in a format compatible with Fortran 77 we can use the method here described. Suppose we calculate the following expression in Mathematica
+
 
 +
===How to Export from Mathematica into Fortran===
 +
*It is many times useful to output the results of Mathematica into a Fortran file. To export in a format compatible with Fortran 77 we can use the method here described. Suppose we calculate the following expression in Mathematica
 +
<pre>
 
In[2]:= res = (x + y + z)^10 // Expand
 
In[2]:= res = (x + y + z)^10 // Expand
  
 
Out[2]= x^10+10 x^9 y+10 x^9 z+45 x^8 y^2+90 x^8 y z+45 x^8 z^2+120 x^7 y^3+360 x^7 y^2 z+360 x^7 y z^2+120 x^7 z^3+210 x^6 y^4+840 x^6 y^3 z+1260 x^6 y^2 z^2+840 x^6 y z^3+210 x^6 z^4+252 x^5 y^5+1260 x^5 y^4 z+2520 x^5 y^3 z^2+2520 x^5 y^2 z^3+1260 x^5 y z^4+252 x^5 z^5+210 x^4 y^6+1260 x^4 y^5 z+3150 x^4 y^4 z^2+4200 x^4 y^3 z^3+3150 x^4 y^2 z^4+1260 x^4 y z^5+210 x^4 z^6+120 x^3 y^7+840 x^3 y^6 z+2520 x^3 y^5 z^2+4200 x^3 y^4 z^3+4200 x^3 y^3 z^4+2520 x^3 y^2 z^5+840 x^3 y z^6+120 x^3 z^7+45 x^2 y^8+360 x^2 y^7 z+1260 x^2 y^6 z^2+2520 x^2 y^5 z^3+3150 x^2 y^4 z^4+2520 x^2 y^3 z^5+1260 x^2 y^2 z^6+360 x^2 y z^7+45 x^2 z^8+10 x y^9+90 x y^8 z+360 x y^7 z^2+840 x y^6 z^3+1260 x y^5 z^4+1260 x y^4 z^5+840 x y^3 z^6+360 x y^2 z^7+90 x y z^8+10 x z^9+y^10+10 y^9 z+45 y^8 z^2+120 y^7 z^3+210 y^6 z^4+252 y^5 z^5+210 y^4 z^6+120 y^3 z^7+45 y^2 z^8+10 y z^9+z^10  
 
Out[2]= x^10+10 x^9 y+10 x^9 z+45 x^8 y^2+90 x^8 y z+45 x^8 z^2+120 x^7 y^3+360 x^7 y^2 z+360 x^7 y z^2+120 x^7 z^3+210 x^6 y^4+840 x^6 y^3 z+1260 x^6 y^2 z^2+840 x^6 y z^3+210 x^6 z^4+252 x^5 y^5+1260 x^5 y^4 z+2520 x^5 y^3 z^2+2520 x^5 y^2 z^3+1260 x^5 y z^4+252 x^5 z^5+210 x^4 y^6+1260 x^4 y^5 z+3150 x^4 y^4 z^2+4200 x^4 y^3 z^3+3150 x^4 y^2 z^4+1260 x^4 y z^5+210 x^4 z^6+120 x^3 y^7+840 x^3 y^6 z+2520 x^3 y^5 z^2+4200 x^3 y^4 z^3+4200 x^3 y^3 z^4+2520 x^3 y^2 z^5+840 x^3 y z^6+120 x^3 z^7+45 x^2 y^8+360 x^2 y^7 z+1260 x^2 y^6 z^2+2520 x^2 y^5 z^3+3150 x^2 y^4 z^4+2520 x^2 y^3 z^5+1260 x^2 y^2 z^6+360 x^2 y z^7+45 x^2 z^8+10 x y^9+90 x y^8 z+360 x y^7 z^2+840 x y^6 z^3+1260 x y^5 z^4+1260 x y^4 z^5+840 x y^3 z^6+360 x y^2 z^7+90 x y z^8+10 x z^9+y^10+10 y^9 z+45 y^8 z^2+120 y^7 z^3+210 y^6 z^4+252 y^5 z^5+210 y^4 z^6+120 y^3 z^7+45 y^2 z^8+10 y z^9+z^10  
To export into a Fortran file you do the following
+
</pre>
 +
*To export into a Fortran file you do the following
 +
<pre>
 
stmp = OpenWrite["expression.f", FormatType -> FortranForm, PageWidth -> 60];
 
stmp = OpenWrite["expression.f", FormatType -> FortranForm, PageWidth -> 60];
 
Write[stmp, exp];
 
Write[stmp, exp];
 
Close[stmp];
 
Close[stmp];
The file will look like
+
</pre>
 +
*The file will look like
 +
<pre>
 
         "res="x**10 + 10*x**9*y + 45*x**8*y**2 +  
 
         "res="x**10 + 10*x**9*y + 45*x**8*y**2 +  
 
     -  120*x**7*y**3 + 210*x**6*y**4 + 252*x**5*y**5 +  
 
     -  120*x**7*y**3 + 210*x**6*y**4 + 252*x**5*y**5 +  
Line 291: Line 358:
 
     -  90*x*y*z**8 + 45*y**2*z**8 + 10*x*z**9 +  
 
     -  90*x*y*z**8 + 45*y**2*z**8 + 10*x*z**9 +  
 
     -  10*y*z**9 + z**10
 
     -  10*y*z**9 + z**10
To use in a program you should take out the "" and it is better to change the continuation character in something that is not used in Fortran like the &. The file will then look like
+
</pre>
 +
*To use in a program you should take out the "" and it is better to change the continuation character in something that is not used in Fortran like the &. The file will then look like
 +
<pre>
 
         res=x**10 + 10*x**9*y + 45*x**8*y**2 +  
 
         res=x**10 + 10*x**9*y + 45*x**8*y**2 +  
 
     &  120*x**7*y**3 + 210*x**6*y**4 + 252*x**5*y**5 +  
 
     &  120*x**7*y**3 + 210*x**6*y**4 + 252*x**5*y**5 +  
Line 318: Line 387:
 
     &  90*x*y*z**8 + 45*y**2*z**8 + 10*x*z**9 +  
 
     &  90*x*y*z**8 + 45*y**2*z**8 + 10*x*z**9 +  
 
     &  10*y*z**9 + z**10
 
     &  10*y*z**9 + z**10
One can use PageWidth up to 72 in Fortran 77. I prefer to be below because this way the file looks more clear
+
</pre>
One can then convert into Fortran 90, using some standard converter
+
*One can use PageWidth up to 72 in Fortran 77. I prefer to be below because this way the file looks more clear
How to Export from Mathematica into Fortran Using Format.m
+
*One can then convert into Fortran 90, using some standard converter
Format.m is a program to produce a nice output into Fortran, including arrays. It was done by M. Sofroniou. It can be obtained here
+
 
If you try to load it as is, it will complain about not finding Utilities`FilterOptions`, a package that no longer ships with Mathematica 10. To fix this:
+
===How to Export from Mathematica into Fortran Using Format.m===
 +
*Format.m is a program to produce a nice output into Fortran, including arrays. It was done by M. Sofroniou. It can be obtained here
 +
*If you try to load it as is, it will complain about not finding Utilities`FilterOptions`, a package that no longer ships with Mathematica 10. To fix this:
 +
<ol>
 +
<li>
 
Change
 
Change
 +
<pre>
 
  BeginPackage["Format`", "Utilities`FilterOptions`"]
 
  BeginPackage["Format`", "Utilities`FilterOptions`"]
 +
</pre>
 
to
 
to
 
+
<pre>
 
BeginPackage["Format`"].
 
BeginPackage["Format`"].
 +
</pre>
 +
</li>
 +
<li>
 
Add
 
Add
 +
<pre>
 
FilterOptions[fun_, opts___] := Sequence@@FilterRules[{opts}, Options[fun]]
 
FilterOptions[fun_, opts___] := Sequence@@FilterRules[{opts}, Options[fun]]
 +
</pre>
 
right after
 
right after
 +
<pre>
 +
Begin["Private`"].
 +
</pre>
 +
</li>
 +
</ol>
  
Begin["Private`"].
+
===How to use Mathematica in batch mode===
How to use Mathematica in batch mode
+
*first use
first use
+
<pre>
 
at now
 
at now
Then at the prompt do
+
</pre>
 +
*Then at the prompt do
 +
<pre>
 
>math -noprompt -script input_file
 
>math -noprompt -script input_file
 +
</pre>
 
Get out with CTRL D
 
Get out with CTRL D
  
Main Page
+
[[Main Page]]
  
 
==Mathematica and OneLoop in FeynCalc==
 
==Mathematica and OneLoop in FeynCalc==
Use of TID instead of OneLoop
+
*Use of TID instead of OneLoop
 +
<pre>
 
result=(-I / Pi^2) ( amp // TID[#, k, ToPaVe -> True] & )  
 
result=(-I / Pi^2) ( amp // TID[#, k, ToPaVe -> True] & )  
Do not forget the parethesis
+
</pre>
 +
Do not forget the parenthesis
  
Main Page
+
[[Main Page]]
  
 
==Managing my Library of Papers==
 
==Managing my Library of Papers==
The papers in MyLibary are organized by keywords. Here is a list of those keywords:
+
*The papers in MyLibary are organized by keywords. Here is a list of those keywords:
 +
<pre>
 
switch ($ACT) {
 
switch ($ACT) {
 
  case 0:
 
  case 0:
Line 469: Line 560:
 
     $TITLE="Papers for work 4";
 
     $TITLE="Papers for work 4";
 
         break;
 
         break;
 +
</pre>
  
 
+
[[Main Page]]
Main Page
 
  
 
==Tips on Unix commands==
 
==Tips on Unix commands==
sort
+
===sort===
If your locale does not use . as the numeric separator, like
+
*If your locale does not use . as the numeric separator, like
 +
<pre>
 
$ locale
 
$ locale
 
LANG=en_US.UTF-8
 
LANG=en_US.UTF-8
Line 482: Line 574:
 
LC_TIME=pt_PT.UTF-8
 
LC_TIME=pt_PT.UTF-8
 
LC_MONETARY=pt_PT.UTF-8
 
LC_MONETARY=pt_PT.UTF-8
 +
</pre>
 
then numeric sort does not work
 
then numeric sort does not work
  
To solve this use the following command
+
*To solve this use the following command
 +
<pre>
 
sort -g <(sed 's/\./,/' file) | sed 's/\,/./'  
 
sort -g <(sed 's/\./,/' file) | sed 's/\,/./'  
For sorting reverse
+
</pre>
 +
 
 +
*For sorting reverse
 +
<pre>
 
sort -gr <(sed 's/\./,/' file) | sed 's/\,/./'  
 
sort -gr <(sed 's/\./,/' file) | sed 's/\,/./'  
 
+
</pre>
 
Main Page
 
Main Page
  
 
==Tips Gnuplot==
 
==Tips Gnuplot==
Output files
+
===Output files===
Postscript output
+
*Postscript output
 +
<pre>
 
set size 0.895,0.5
 
set size 0.895,0.5
 
set term postscript portrait enhanced color solid lw 2  
 
set term postscript portrait enhanced color solid lw 2  
 
set output "plot.eps"  
 
set output "plot.eps"  
PNG output with approximately the same ratio
+
</pre>
 +
*PNG output with approximately the same ratio
 +
<pre>
 
set size 0.8,0.5
 
set size 0.8,0.5
 
set terminal pngcairo dashed enhanced font "arial,20" lw 2 crop  size 900,1200
 
set terminal pngcairo dashed enhanced font "arial,20" lw 2 crop  size 900,1200
set output "plot.png"  
+
set output "plot.png"
Syntax for labels
+
</pre>
 +
 
 +
[[Main Page]]
 +
 
 +
===Syntax for labels===
 +
<pre>
 
set label 1 at 200,3e-5 font "*,16" "label"
 
set label 1 at 200,3e-5 font "*,16" "label"
Use of awk
+
</pre>
Sometimes one wants to make cuts in the data. One simple way to make cuts is to use awk. The syntax is
+
 
 +
===Use of awk===
 +
*Sometimes one wants to make cuts in the data. One simple way to make cuts is to use awk. The syntax is
 +
<pre>
 
plot "<awk -f cuts.awk datafile.dat" with lines ls 1
 
plot "<awk -f cuts.awk datafile.dat" with lines ls 1
An example of the cuts.awk file could be
+
</pre>
 +
*An example of the cuts.awk file could be
 +
<pre>
 
     function minvec(vec,  i, ret)
 
     function minvec(vec,  i, ret)
 
     {
 
     {
Line 545: Line 655:
 
     if(c1==1) print $23,(pot2(246)*$30/tan($18))
 
     if(c1==1) print $23,(pot2(246)*$30/tan($18))
 
}
 
}
 +
</pre>
 +
 +
[[Main Page]]
  
Make 1D histograms with gnuplot
+
===Make 1D histograms with gnuplot===
 +
<pre>
 
binwidth=2
 
binwidth=2
 
bin(x,width)=width*floor(x/width)
 
bin(x,width)=width*floor(x/width)
 
plot 'file.dat' using (bin($1,binwidth)):(1.0) smooth freq with boxes
 
plot 'file.dat' using (bin($1,binwidth)):(1.0) smooth freq with boxes
Fill Region defined by points
+
</pre>
Suppose you have a region defined by a set of points. For instance in file.dat you have (the first point must be equal to the last one)
+
 
 +
===Fill Region defined by points===
 +
*Suppose you have a region defined by a set of points. For instance in file.dat you have (the first point must be equal to the last one)
 +
<pre>
 
1  1
 
1  1
 
1  3
 
1  3
Line 557: Line 674:
 
3  1
 
3  1
 
1  1
 
1  1
To fill the inside of the region you do
+
</pre>
 +
*To fill the inside of the region you do
 +
<pre>
 
gnuplot> set xrange [0:4]
 
gnuplot> set xrange [0:4]
 
gnuplot> set yrange [0:4]
 
gnuplot> set yrange [0:4]
 
gnuplot> plot "file.dat" with filledcurves ls 1
 
gnuplot> plot "file.dat" with filledcurves ls 1
One can make it less solid with the command
+
</pre>
 +
*One can make it less solid with the command
 +
<pre>
 
set style fill solid 0.2
 
set style fill solid 0.2
The number can be in the interval 0 (white) 1 (full color) Main Page
+
</pre>
 +
The number can be in the interval 0 (white) 1 (full color)  
 +
 
 +
[[Main Page]]
  
 
==Tips LaTeX==
 
==Tips LaTeX==
feynmp-auto LaTeX package
+
===feynmp-auto LaTeX package===
Using feynmp-auto LaTeX package. The standard code is like
+
*Using feynmp-auto LaTeX package. The standard code is like
 +
<pre>
 
\documentclass[a4paper,12pt,twoside]{report}  
 
\documentclass[a4paper,12pt,twoside]{report}  
 
   
 
   
Line 602: Line 727:
 
\end{figure}  
 
\end{figure}  
 
%  
 
%  
\end{document}  
+
\end{document}
Now if you want to put an arrow in the W line you define a wiggly line with an arrow
+
</pre>
 
+
*Now if you want to put an arrow in the W line you define a wiggly line with an arrow
 +
<pre>
 
\documentclass[a4paper,12pt,twoside]{report}  
 
\documentclass[a4paper,12pt,twoside]{report}  
 
   
 
   
Line 649: Line 775:
  
 
\end{document}  
 
\end{document}  
Of course you have to use mpost
+
</pre>
 
+
*Of course you have to use mpost
 +
<pre>
 
latex file.tex
 
latex file.tex
 
mpost 5.mp
 
mpost 5.mp
 
latex file.tex
 
latex file.tex
Arial Fonts in PDFLaTeX
+
</pre>
To use Arial fonts in LaTeX use the hevet package. Here is an example
+
 
 +
[[Main Page]]
 +
 
 +
===Arial Fonts in PDFLaTeX===
 +
*To use Arial fonts in LaTeX use the hevet package. Here is an example
 +
<pre>
 
\documentclass[12pt]{article}
 
\documentclass[12pt]{article}
 
\usepackage{graphicx}
 
\usepackage{graphicx}
Line 699: Line 831:
  
 
\end{document}
 
\end{document}
This example also shows how to modify labels using pdflatex. Im summary
+
</pre>
Use a blank fig to supperimpose on the label
+
*This example also shows how to modify labels using pdflatex. In summary
Then right on top of the blank figure
+
**Use a blank fig to superimpose on the label
 +
**Then right on top of the blank figure
  
Main Page
+
[[Main Page]]
  
 
==Tips on Windows OS==
 
==Tips on Windows OS==
Repair unreadable disk
+
===Repair unreadable disk===
 
Run the command
 
Run the command
 
+
<pre>
 
chkdsk /f d:
 
chkdsk /f d:
 +
</pre>
 
where d is the drive letter you want to check
 
where d is the drive letter you want to check
  
 
==Go Back to Main Page==
 
==Go Back to Main Page==
 
[[Main Page]]
 
[[Main Page]]

Latest revision as of 20:21, 17 October 2020

How to use SSH without passwords

  • You want to enter from computer A into computer B using ssh without passwords
  1. Generate the public keys in computer A
    ssh-keygen -t dsa
    ssh-keygen -t rsa
    

    and follow the instructions

  2. Copy the public keys for computer A into a file authorized_keys_A
    cd; cd .ssh
    cp id_dsa.pub authorized_keys_A
    cat id_rsa.pub >> authorized_keys_A
    
  3. Copy the file to computer B using your password
    scp authorized_keys_A user@Computer_B
    
  4. Login into Computer B using your password
  5. Move the file to the directory .ssh. If this is the only computer you want to use move the file to authorized_keys
    cd .ssh
    mv authorized_keys_A authorized_keys
    
  6. If you want to do the same with other computers and have already an authorizes_keys file, then append it
    cat authorized_keys_A >> authorized_keys
    
  7. If it fails (it happened with Ubuntu 18.04) after the procedure explained do in client side (computer A)
    ssh-add
    

    Verify with

    ssh-add -l
    
  8. That is all. Now you can login from A to B without password and using ssh.

Main Page

How to use the nodes@cftp

What are the nodes (This information is obsolete)

  • The nodes are 6 computers dedicated only for calculations. Each have 4 CPU's, in a total of 24 CPU's.
  • They are different, so they are not good to use in parallel programming

From the net you can only access node1:

ssh user@node1.tecnico.ulisboa.pt

The others 5 are in a sub-net and can only be accessed from node1

  • There is only one user directory in node1. It is automatically mounted on all the other nodes, so you will always see the same directory structure
  • You should not use the nodes running the programs directly. You should use the software Sun Grid Engine described below

How to use the software Sun Grid Engine (Not anymore installed)

  • The main idea is that you submit the jobs using a software that knows what are the free CPU's in each node and submits the job there
  • This is best done using scripts. I am going to show two basic scripts. For this suppose that you have a directory structure as follows
Examples
├── Dir1
│   ├── example.dat
│   ├── ProgTest
│   └── ProgTest.f
├── Dir2
│   ├── example.dat
│   ├── ProgTest
│   └── ProgTest.f
├── job1.sh
└── job2.sh
  • This means that you have a base Directory Examples and two sub-directories Dir1 and Dir2.
  • Inside each of these directories there are all the files needed to run the program, including the executable and any other necessary input. The final results will go also into these directories.
  • In the base directories there are two scripts. They do the same thing, but they differ in a way I will explain below.
  • Script job1.sh
#!/bin/bash -x                                                                  
#
# request Bourne shell as shell for job                                         
#$ -S /bin/sh                                                                   

usage(){
echo
echo "DESCRIPTION: Job File for qsub. "
echo
echo "USAGE: qsub job1.sh subdir "
echo
echo  "           -h         Print usage."
echo
}

if [[ $# == 0 || "$1" == "-h" ]]; then
    usage
    exit
fi


# Start Date
date

BASE=/home/romao/Examples
DIR=$BASE/$1
PATH=$PATH:$DIR
export PATH

cd $DIR

./ProgTest


# End Date
date

exit
  • You run this script with the command
qsub job1.sh Dir1

or

qsub job1.sh Dir2
  • When the program ends the results are in those directories
  • If the program takes sometime, you can see if they are running with the command
qstat
  • The output is something like this
node1$ qstat
job-ID  prior   name       user         state submit/start at     queue                          slots ja-task-ID 
-----------------------------------------------------------------------------------------------------------------
    244 0.55500 job1.sh    romao        r     06/07/2016 19:30:41 all.q@node6                        1        
    245 0.55500 job1.sh    romao        r     06/07/2016 19:30:41 all.q@node3   
  • To kill a job, first get the job number with the command qstat, and then use
qdel jobnumber1 jobnumber2 ...

You can delete several jobs with the same command

  • Script job2.sh
#!/bin/bash -x                                                                 
#                                                                               
# request Bourne shell as shell for job                                         
#$ -S /bin/sh                                                                   


usage(){
echo
echo "DESCRIPTION: Job File for qsub. "
echo
echo "USAGE: qsub job2.sh subdir "
echo
echo  "           -h         Print usage."
echo
}

if [[ $# == 0 || "$1" == "-h" ]]; then
    usage
    exit
fi



# Start Date                                                                    
date

BASE=/home/romao/Examples
DIR=$BASE/$1
PATH=$PATH:$DIR
export PATH


if [ -d /tmp/romao/$1 ]; then

cd /tmp/romao
rm -fr $1

cp -pLR $DIR/ProgTest /tmp/romao/$1/

else

mkdirhier /tmp/romao/$1

cp -pLR $DIR/ProgTest /tmp/romao/$1/


fi;

cd /tmp/romao/$1

time ./ProgTest



cp example.dat $DIR/

cd /tmp/romao
rm -fr $1

# End Date                                                                      
date

exit
  • This script does the same thing with one difference. In the first script the jobs are run inside the directories Dir1 and Dir2. These directories are physically in node1 and mounted by nfs on the other machines. If your job writes many times to the disk, these results have to transferred by nfs to the directory in node1 and this slows down the performance. The script job2.sh solves this problem by copying the program files in the /tmp directory in the nodes where you are running. Uses the scratch space there and only when the job end copies everything back to your directory.
  • You have to change the names of the program files to suit your case
  • Warning: To use this script you have to have ssh without passwords enabled between node1 and the other nodes. See above

Main Page

Mathematica and Fortran

How to Enable debugging in ifort

  • To be able to traceback where the error comes from one should compile with the options
ifort -g -traceback ...

How to Export data from Mathematica

  • Suppose that you have a list with several entries in mathematica. Let us consider an example
In[2]:= data = Table[{x, Sin[x], Cos[x]}, {x, 0., Pi, Pi/16}]

Out[2]= (0.	0.	1.
0.19635	0.19509	0.980785
0.392699 0.382683 0.92388
0.589049 0.55557 0.83147
0.785398 0.707107 0.707107
0.981748 0.83147 0.55557
1.1781	0.92388	0.382683
1.37445	0.980785 0.19509
1.5708	1. 6.12323*10^-17
1.76715	0.980785 -0.19509
1.9635	0.92388	-0.382683
2.15984	0.83147	-0.55557
2.35619	0.707107 -0.707107
2.55254	0.55557	-0.83147
2.74889	0.382683 -0.92388
2.94524	0.19509	-0.980785
3.14159	1.22465*10^-16	-1.

)
  • You can export this data into a file by doing
In[3]:= Export["datafile.dat", data,"TSV"]

Out[3]= datafile.dat
  • The file will look like
0.	0.	1.
0.19634954084936207	0.19509032201612825	0.9807852804032304
0.39269908169872414	0.3826834323650898	0.9238795325112867
0.5890486225480862	0.5555702330196022	0.8314696123025452
0.7853981633974483	0.7071067811865475	0.7071067811865476
0.9817477042468103	0.8314696123025452	0.5555702330196023
1.1780972450961724	0.9238795325112867	0.38268343236508984
1.3744467859455345	0.9807852804032304	0.19509032201612833
1.5707963267948966	1.	6.123233995736766e-17
1.7671458676442586	0.9807852804032304	-0.1950903220161282
1.9634954084936207	0.9238795325112867	-0.3826834323650897
2.1598449493429825	0.8314696123025455	-0.555570233019602
2.356194490192345	0.7071067811865476	-0.7071067811865475
2.552544031041707	0.5555702330196022	-0.8314696123025453
2.748893571891069	0.3826834323650899	-0.9238795325112867
2.945243112740431	0.1950903220161286	-0.9807852804032304
3.141592653589793	1.2246467991473532e-16	-1.

How to Import data into Mathematica

  • Data can be imported into Mathematica with the command
newdata = Import["datafile.dat"]
  • This produces the output
In[1] =newdata
Out[1]=(0.	0.	1.
0.19635	0.19509	0.980785
0.392699	0.382683	0.92388
0.589049	0.55557	0.83147
0.785398	0.707107	0.707107
0.981748	0.83147	0.55557
1.1781	0.92388	0.382683
1.37445	0.980785	0.19509
1.5708	1.	6.12323*10^-17
1.76715	0.980785	-0.19509
1.9635	0.92388	-0.382683
2.15984	0.83147	-0.55557
2.35619	0.707107	-0.707107
2.55254	0.55557	-0.83147
2.74889	0.382683	-0.92388
2.94524	0.19509	-0.980785
3.14159	1.22465*10^-16	-1.

)

How to Export from Mathematica into Fortran

  • It is many times useful to output the results of Mathematica into a Fortran file. To export in a format compatible with Fortran 77 we can use the method here described. Suppose we calculate the following expression in Mathematica
In[2]:= res = (x + y + z)^10 // Expand

Out[2]= x^10+10 x^9 y+10 x^9 z+45 x^8 y^2+90 x^8 y z+45 x^8 z^2+120 x^7 y^3+360 x^7 y^2 z+360 x^7 y z^2+120 x^7 z^3+210 x^6 y^4+840 x^6 y^3 z+1260 x^6 y^2 z^2+840 x^6 y z^3+210 x^6 z^4+252 x^5 y^5+1260 x^5 y^4 z+2520 x^5 y^3 z^2+2520 x^5 y^2 z^3+1260 x^5 y z^4+252 x^5 z^5+210 x^4 y^6+1260 x^4 y^5 z+3150 x^4 y^4 z^2+4200 x^4 y^3 z^3+3150 x^4 y^2 z^4+1260 x^4 y z^5+210 x^4 z^6+120 x^3 y^7+840 x^3 y^6 z+2520 x^3 y^5 z^2+4200 x^3 y^4 z^3+4200 x^3 y^3 z^4+2520 x^3 y^2 z^5+840 x^3 y z^6+120 x^3 z^7+45 x^2 y^8+360 x^2 y^7 z+1260 x^2 y^6 z^2+2520 x^2 y^5 z^3+3150 x^2 y^4 z^4+2520 x^2 y^3 z^5+1260 x^2 y^2 z^6+360 x^2 y z^7+45 x^2 z^8+10 x y^9+90 x y^8 z+360 x y^7 z^2+840 x y^6 z^3+1260 x y^5 z^4+1260 x y^4 z^5+840 x y^3 z^6+360 x y^2 z^7+90 x y z^8+10 x z^9+y^10+10 y^9 z+45 y^8 z^2+120 y^7 z^3+210 y^6 z^4+252 y^5 z^5+210 y^4 z^6+120 y^3 z^7+45 y^2 z^8+10 y z^9+z^10 
  • To export into a Fortran file you do the following
stmp = OpenWrite["expression.f", FormatType -> FortranForm, PageWidth -> 60];
Write[stmp, exp];
Close[stmp];
  • The file will look like
        "res="x**10 + 10*x**9*y + 45*x**8*y**2 + 
     -   120*x**7*y**3 + 210*x**6*y**4 + 252*x**5*y**5 + 
     -   210*x**4*y**6 + 120*x**3*y**7 + 45*x**2*y**8 + 
     -   10*x*y**9 + y**10 + 10*x**9*z + 90*x**8*y*z + 
     -   360*x**7*y**2*z + 840*x**6*y**3*z + 
     -   1260*x**5*y**4*z + 1260*x**4*y**5*z + 
     -   840*x**3*y**6*z + 360*x**2*y**7*z + 90*x*y**8*z + 
     -   10*y**9*z + 45*x**8*z**2 + 360*x**7*y*z**2 + 
     -   1260*x**6*y**2*z**2 + 2520*x**5*y**3*z**2 + 
     -   3150*x**4*y**4*z**2 + 2520*x**3*y**5*z**2 + 
     -   1260*x**2*y**6*z**2 + 360*x*y**7*z**2 + 
     -   45*y**8*z**2 + 120*x**7*z**3 + 840*x**6*y*z**3 + 
     -   2520*x**5*y**2*z**3 + 4200*x**4*y**3*z**3 + 
     -   4200*x**3*y**4*z**3 + 2520*x**2*y**5*z**3 + 
     -   840*x*y**6*z**3 + 120*y**7*z**3 + 210*x**6*z**4 + 
     -   1260*x**5*y*z**4 + 3150*x**4*y**2*z**4 + 
     -   4200*x**3*y**3*z**4 + 3150*x**2*y**4*z**4 + 
     -   1260*x*y**5*z**4 + 210*y**6*z**4 + 252*x**5*z**5 + 
     -   1260*x**4*y*z**5 + 2520*x**3*y**2*z**5 + 
     -   2520*x**2*y**3*z**5 + 1260*x*y**4*z**5 + 
     -   252*y**5*z**5 + 210*x**4*z**6 + 840*x**3*y*z**6 + 
     -   1260*x**2*y**2*z**6 + 840*x*y**3*z**6 + 
     -   210*y**4*z**6 + 120*x**3*z**7 + 360*x**2*y*z**7 + 
     -   360*x*y**2*z**7 + 120*y**3*z**7 + 45*x**2*z**8 + 
     -   90*x*y*z**8 + 45*y**2*z**8 + 10*x*z**9 + 
     -   10*y*z**9 + z**10
  • To use in a program you should take out the "" and it is better to change the continuation character in something that is not used in Fortran like the &. The file will then look like
         res=x**10 + 10*x**9*y + 45*x**8*y**2 + 
     &   120*x**7*y**3 + 210*x**6*y**4 + 252*x**5*y**5 + 
     &   210*x**4*y**6 + 120*x**3*y**7 + 45*x**2*y**8 + 
     &   10*x*y**9 + y**10 + 10*x**9*z + 90*x**8*y*z + 
     &   360*x**7*y**2*z + 840*x**6*y**3*z + 
     &   1260*x**5*y**4*z + 1260*x**4*y**5*z + 
     &   840*x**3*y**6*z + 360*x**2*y**7*z + 90*x*y**8*z + 
     &   10*y**9*z + 45*x**8*z**2 + 360*x**7*y*z**2 + 
     &   1260*x**6*y**2*z**2 + 2520*x**5*y**3*z**2 + 
     &   3150*x**4*y**4*z**2 + 2520*x**3*y**5*z**2 + 
     &   1260*x**2*y**6*z**2 + 360*x*y**7*z**2 + 
     &   45*y**8*z**2 + 120*x**7*z**3 + 840*x**6*y*z**3 + 
     &   2520*x**5*y**2*z**3 + 4200*x**4*y**3*z**3 + 
     &   4200*x**3*y**4*z**3 + 2520*x**2*y**5*z**3 + 
     &   840*x*y**6*z**3 + 120*y**7*z**3 + 210*x**6*z**4 + 
     &   1260*x**5*y*z**4 + 3150*x**4*y**2*z**4 + 
     &   4200*x**3*y**3*z**4 + 3150*x**2*y**4*z**4 + 
     &   1260*x*y**5*z**4 + 210*y**6*z**4 + 252*x**5*z**5 + 
     &   1260*x**4*y*z**5 + 2520*x**3*y**2*z**5 + 
     &   2520*x**2*y**3*z**5 + 1260*x*y**4*z**5 + 
     &   252*y**5*z**5 + 210*x**4*z**6 + 840*x**3*y*z**6 + 
     &   1260*x**2*y**2*z**6 + 840*x*y**3*z**6 + 
     &   210*y**4*z**6 + 120*x**3*z**7 + 360*x**2*y*z**7 + 
     &   360*x*y**2*z**7 + 120*y**3*z**7 + 45*x**2*z**8 + 
     &   90*x*y*z**8 + 45*y**2*z**8 + 10*x*z**9 + 
     &   10*y*z**9 + z**10
  • One can use PageWidth up to 72 in Fortran 77. I prefer to be below because this way the file looks more clear
  • One can then convert into Fortran 90, using some standard converter

How to Export from Mathematica into Fortran Using Format.m

  • Format.m is a program to produce a nice output into Fortran, including arrays. It was done by M. Sofroniou. It can be obtained here
  • If you try to load it as is, it will complain about not finding Utilities`FilterOptions`, a package that no longer ships with Mathematica 10. To fix this:
  1. Change
     BeginPackage["Format`", "Utilities`FilterOptions`"]
    

    to

    BeginPackage["Format`"].
    
  2. Add
    FilterOptions[fun_, opts___] := Sequence@@FilterRules[{opts}, Options[fun]]
    

    right after

    Begin["Private`"].
    

How to use Mathematica in batch mode

  • first use
at now
  • Then at the prompt do
>math -noprompt -script input_file

Get out with CTRL D

Main Page

Mathematica and OneLoop in FeynCalc

  • Use of TID instead of OneLoop
result=(-I / Pi^2) ( amp // TID[#, k, ToPaVe -> True] & ) 

Do not forget the parenthesis

Main Page

Managing my Library of Papers

  • The papers in MyLibary are organized by keywords. Here is a list of those keywords:
switch ($ACT) {
 case 0:
   echo "";
   break;
 case 1:

   $statement = $connection->query("SELECT * FROM database_name WHERE authors LIKE '%romao%' ORDER BY year $sort, spires $sort ");
   $TITLE="Papers by Jorge Romão";
   break;

 case 2:
   $statement =$connection->query("SELECT * FROM database_name WHERE  project LIKE
   '%mylib-sm%' ORDER BY year $sort,firstauthor");
   $TITLE="Articles on the Standard Model";
   break;

 case 3:
   $statement = $connection->query("SELECT * FROM database_name WHERE  project LIKE '%mylib-review%' ORDER BY year $sort,firstauthor");
   $TITLE="Review Articles";
   break;
 case 4:
   $statement=$connection->query("SELECT * FROM database_name WHERE  project LIKE '%mylib-susy%' ORDER BY year $sort,firstauthor");
   $TITLE="SUSY (General)";
   break;
 case 5:
   $statement =$connection->query("SELECT * FROM database_name WHERE  project LIKE '%mylib-mssm%'  ORDER BY year $sort,firstauthor");
   $TITLE="Articles on the MSSM";
   break;

  case 6:
   $statement = $connection->query("SELECT * FROM database_name WHERE  project LIKE '%mylib-rparity%' ORDER BY year $sort,firstauthor ");
   $TITLE="Articles on R-Parity";
   break;

 case 7:
   $statement=$connection->query("SELECT * FROM database_name WHERE  project LIKE '%mylib-nmssm%' ORDER BY year $sort,firstauthor ");
   $TITLE="Articles on the NMSSM";
   break;

 case 8:
   $statement =$connection->query("SELECT * FROM database_name WHERE  project LIKE '%mylib-lfv%' ORDER BY year $sort,firstauthor ");
   $TITLE="Articles on Lepton Flavour Violation";
   break;

 case 9:
   $statement = $connection->query("SELECT * FROM database_name WHERE  project LIKE '%mylib-neutrinos%' ORDER BY year $sort,firstauthor ");
   $TITLE="Articles on Neutrinos";
   break;

 case 10:
   $statement = $connection->query("SELECT * FROM database_name WHERE  project LIKE '%mylib-darkmatter%' ORDER BY year $sort,firstauthor");
   $TITLE="Articles on Dark Matter";
   break;

 case 11:
   $statement = $connection->query("SELECT * FROM database_name WHERE  project LIKE '%mylib-gut%' ORDER BY year $sort,firstauthor");
   $TITLE="Articles on GUT";
   break;

 case 12:
   $statement = $connection->query("SELECT * FROM database_name WHERE  project LIKE '%mylib-seesaw%'  ORDER BY year $sort,firstauthor");
   $TITLE="Articles on Seesaw Models";
   break;
   
 case 13:
   $statement = $connection->query("SELECT * FROM database_name WHERE  project LIKE '%mylib-leptogenesis%'  ORDER BY year $sort,firstauthor");
   $TITLE="Articles on Leptogenesis";
   break;

 case 14:
   $statement = $connection->query("SELECT * FROM database_name WHERE  project LIKE '%mylib-electromagnetism%' ORDER BY year $sort,firstauthor");
   $TITLE="Articles on Electromagnetism";
   break;

 case 15:
   $statement = $connection->query("SELECT * FROM database_name WHERE  project LIKE '%mylib-quantum-mechanics%' ORDER BY year $sort,firstauthor ");
   $TITLE="Articles on Quantum Mechanics";
   break;

 case 16:
   $statement = $connection->query("SELECT * FROM database_name WHERE  project LIKE '%mylib-field-theory%' ORDER BY year $sort,firstauthor");
   $TITLE="Articles on Quantum Field Theory";
   break;

 case 17:
   $statement = $connection->query("SELECT * FROM database_name WHERE  project LIKE '%mylib-gravity%' ORDER BY year $sort,firstauthor");
   $TITLE="Articles on Gravitation";
   break;

 case 18:
   $statement = $connection->query("SELECT * FROM database_name WHERE  project LIKE '%mylib-divulgacao%' ORDER BY year $sort,firstauthor");
   $TITLE="Articles on Science Divulgation";
   break;

 case 19;
 $statement = $connection->query("SELECT * FROM database_name WHERE authors LIKE '%romao%' OR project LIKE '%mylib%' ORDER BY year $sort,firstauthor");
 $TITLE="All papers in My Library";
 break;

 case 20:
   $statement = $connection->query("SELECT * FROM database_name WHERE  project LIKE '%mylib-atwork1%' ORDER BY year $sort,firstauthor");
   $TITLE="Papers for work 1";
   break;

 case 21:
     $statement = $connection->query("SELECT * FROM database_name WHERE  project LIKE '%mylib-atwork2%' ORDER BY year $sort,firstauthor");
     $TITLE="Papers for work 2";
        break;

 case 22:
     $statement = $connection->query("SELECT * FROM database_name WHERE  project LIKE '%mylib-atwork3%' ORDER BY year $sort,firstauthor");
     $TITLE="Papers for work 3";
        break;

 case 23:
     $statement = $connection->query("SELECT * FROM database_name WHERE  project LIKE '%mylib-atwork4%' ORDER BY year $sort,firstauthor");
     $TITLE="Papers for work 4";
        break;

Main Page

Tips on Unix commands

sort

  • If your locale does not use . as the numeric separator, like
$ locale
LANG=en_US.UTF-8
LC_CTYPE=pt_PT.UTF-8
LC_NUMERIC=pt_PT.UTF-8
LC_TIME=pt_PT.UTF-8
LC_MONETARY=pt_PT.UTF-8

then numeric sort does not work

  • To solve this use the following command
sort -g <(sed 's/\./,/' file) | sed 's/\,/./' 
  • For sorting reverse
sort -gr <(sed 's/\./,/' file) | sed 's/\,/./' 

Main Page

Tips Gnuplot

Output files

  • Postscript output
set size 0.895,0.5
set term postscript portrait enhanced color solid lw 2 
set output "plot.eps" 
  • PNG output with approximately the same ratio
set size 0.8,0.5
set terminal pngcairo dashed enhanced font "arial,20" lw 2 crop  size 900,1200
set output "plot.png"

Main Page

Syntax for labels

set label 1 at 200,3e-5 font "*,16" "label"

Use of awk

  • Sometimes one wants to make cuts in the data. One simple way to make cuts is to use awk. The syntax is
plot "<awk -f cuts.awk datafile.dat" with lines ls 1
  • An example of the cuts.awk file could be
    function minvec(vec,   i, ret)
    {
	for (i in vec) {
	    if (ret == "" || vec[i] < ret)
		ret = vec[i]
	}
	return ret
    }
   
    function tan(x,ret)
    {
	ret=sin(x)/cos(x)
	return ret
    }
   
    function pot2(x,ret)
    {
	ret=x*x
	return ret
    }

    function abs(x,ret)
    {
	ret=sqrt(x*x)
	return ret
    }
      function sgn(x,ret)
    {
	ret=x/abs(x)
	return ret
    }
  

{
    if(abs($3-1) < 0.2)  {c1=1} else {c1=0}  

    if(c1==1) print $23,(pot2(246)*$30/tan($18))
}

Main Page

Make 1D histograms with gnuplot

binwidth=2
bin(x,width)=width*floor(x/width)
plot 'file.dat' using (bin($1,binwidth)):(1.0) smooth freq with boxes

Fill Region defined by points

  • Suppose you have a region defined by a set of points. For instance in file.dat you have (the first point must be equal to the last one)
1  1
1  3
3  3
3  1
1  1
  • To fill the inside of the region you do
gnuplot> set xrange [0:4]
gnuplot> set yrange [0:4]
gnuplot> plot "file.dat" with filledcurves ls 1
  • One can make it less solid with the command
set style fill solid 0.2

The number can be in the interval 0 (white) 1 (full color)

Main Page

Tips LaTeX

feynmp-auto LaTeX package

  • Using feynmp-auto LaTeX package. The standard code is like
\documentclass[a4paper,12pt,twoside]{report} 
 
\usepackage{subcaption} 
\usepackage{feynmp-auto} 
 
\makeatletter 
\setlength{\@fptop}{10pt} 
\makeatother 

\pagestyle{empty}
\begin{document} 
 
\begin{figure}[htp] 
\centering 
% 
\begin{subfigure}{2.5cm} 
\begin{fmffile}{5} 
\begin{fmfgraph*}(100,100)
\fmfset{arrow_len}{3mm} 
\fmfset{arrow_ang}{20} 
\fmfleft{nJ1} 
\fmflabel{$Z$}{nJ1} 
\fmfright{nJ2,nJ4} 
\fmf{photon,tension=4}{nJ1,J4J1nJ1} 
\fmf{fermion,label=$b$,label.side=right,tension=4}{nJ2J5J2,nJ2} 
\fmf{fermion,label=$b$,label.side=right,tension=4}{nJ4,J6nJ4J3} 
\fmf{photon,label=$W^{+}$,label.side=left,tension=1,label.dist=3thick}{nJ2J5J2,J4J1nJ1} 
\fmf{scalar,label=$H_a^{+}$,label.side=left,tension=1,label.dist=3thick}{J4J1nJ1,J6nJ4J3} 
\fmf{fermion,label=$t$,label.side=left,tension=1,label.dist=3thick}{J6nJ4J3,nJ2J5J2} 
\end{fmfgraph*} 
\end{fmffile} 
\end{subfigure} 
\end{figure} 
% 
\end{document}
  • Now if you want to put an arrow in the W line you define a wiggly line with an arrow
\documentclass[a4paper,12pt,twoside]{report} 
 
\usepackage{subcaption} 
\usepackage{feynmp-auto} 
 
\makeatletter 
\setlength{\@fptop}{10pt} 
\makeatother 
 

\pagestyle{empty}
\begin{document} 
 
\begin{figure}[htp] 
\centering 
% 
\begin{subfigure}{2.5cm} 
\begin{fmffile}{5} 
\begin{fmfgraph*}(100,100)
\fmfcmd{%
style_def wiggly_arrow expr p =
cdraw (wiggly p);
shrink (1);
cfill (arrow p);
endshrink;
enddef;}
\fmfset{arrow_len}{3mm} 
\fmfset{arrow_ang}{20} 
\fmfleft{nJ1} 
\fmflabel{$Z$}{nJ1} 
\fmfright{nJ2,nJ4} 
\fmf{photon,tension=4}{nJ1,J4J1nJ1} 
\fmf{fermion,label=$b$,label.side=right,tension=4}{nJ2J5J2,nJ2} 
\fmf{fermion,label=$b$,label.side=right,tension=4}{nJ4,J6nJ4J3} 
\fmf{wiggly_arrow,label=$W^{+}$,label.side=left,tension=1,label.dist=3thick}{nJ2J5J2,J4J1nJ1} 
\fmf{scalar,label=$H_a^{+}$,label.side=left,tension=1,label.dist=3thick}{J4J1nJ1,J6nJ4J3} 
\fmf{fermion,label=$t$,label.side=left,tension=1,label.dist=3thick}{J6nJ4J3,nJ2J5J2} 
\end{fmfgraph*} 
\end{fmffile} 
\end{subfigure} 
\end{figure} 
% 

\end{document} 
  • Of course you have to use mpost
latex file.tex
mpost 5.mp
latex file.tex

Main Page

Arial Fonts in PDFLaTeX

  • To use Arial fonts in LaTeX use the hevet package. Here is an example
\documentclass[12pt]{article}
\usepackage{graphicx}
%
% For arial in math mode
%
\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}
\usepackage{
            newtxsf,
            textcomp,
            amsmath
           }
\usepackage[bold]{mathastext}

\usepackage{geometry}
 \geometry{
 papersize={248.5mm,196.5mm},
 total={250mm,197mm},
 left=0mm,
 top=0mm,
 }
\setlength{\unitlength}{1mm}
\pagestyle{empty}

\begin{document}

\begin{minipage}{1.0\linewidth}
\begin{picture}(248.5,196.5)(6.25,-0.)
 \includegraphics[scale=1]{./Ratios-DgR-MZ-Neutrals-v2.pdf}   
\end{picture}
 \put(-260,119){\includegraphics[scale=0.3]{blank.pdf}}
 \put(-260,105){\includegraphics[scale=0.3]{blank.pdf}}
 \put(-260,100){\includegraphics[scale=0.3]{blank.pdf}}
 \put(-260,90){\includegraphics[scale=0.3]{blank.pdf}}
\put(-253,105){\scalebox{2.1}{\rotatebox{90}{$\mathbf{R_{ g_{Rb}^n}}$}}}
\put(-108,0){\includegraphics[scale=0.3]{blank.pdf}}
\put(-121,0){\includegraphics[scale=0.3]{blank.pdf}}
\put(-130,0){\includegraphics[scale=0.3]{blank.pdf}}
\put(-140,0){\includegraphics[scale=0.3]{blank.pdf}}
\put(-140,6){\scalebox{2.1}{\bf$\mathbf{m_3}$ (GeV)}}
\end{minipage}

\end{document}
  • This example also shows how to modify labels using pdflatex. In summary
    • Use a blank fig to superimpose on the label
    • Then right on top of the blank figure

Main Page

Tips on Windows OS

Repair unreadable disk

Run the command

chkdsk /f d:

where d is the drive letter you want to check

Go Back to Main Page

Main Page