2012年12月13日 星期四

cluster compiler 注意事項


gcc -O3 -lm -o 3d_ladder randistrs.c mtwist.c 3d_ladder.c

--
all:
        gcc -lm -O3 -o sse_unconvention mtwist.c randistrs.c sse_unconvention.c
run:
        ./sse_unconvention 20.0 1.0 10 10 1 10000 200000 50 A B C D E F
---

!NOTE
若make 出現 error 直接使用上述指令

make
make: Warning: File `Makefile' has modification time 1.1e+03 s in the future
gcc -lm -O3 -o 3d_ladder mtwist.c randistrs.c 3d_ladder.c
make: warning:  Clock skew detected.  Your build may be incomplete.

2012年12月10日 星期一

透過 putty 使用 X11 轉遠端畫面到本機顯示



Xming

步驟 :
安裝 Xming
執行 XLaunch
下一步到底
右下角會出現黑色X
執行 putty
Connection → SSH → Enable X11 forwarding 打勾 → 底下輸入 localhost:0
正常連入 SSH
輸入指令 ex.firefox
搞定


ref 
http://jakson.idv.tw/joomla/index.php?option=com_content&view=article&id=183:-putty-x11-&catid=63:linux-program&Itemid=121 

2012年11月22日 星期四

mathematica 陣列 放入 自訂變數函數

被括號搞死{ }

c1[{Lx_, Ly_, Lz_, beta1_, beta2_}] := (Lx*Ly*Lz)^(1/3)/beta1
c2[{Lx_, Ly_, Lz_, beta1_, beta2_}] := (Lx*Ly*Lz)^(1/3)/beta2
J3ab = {32, 32, 44, 15.25, 15.342};
J3c = {32, 32, 44, 15.25, 15.45};
J325 = {24, 24, 32, 11.35, 11.45};
J35 = {34, 34, 46, 15.95, 16.05};
J375 = {22, 22, 30, 10.22, 10.32};
J4 = {32, 32, 44, 14.48, 15.18};

c1[J3ab] 收工
但應該有更聰明的辦法

2012年11月19日 星期一

fortran & random_seed


       program test_seed
       implicit none
       real x
       integer jj
       call init_random_seed()
       do jj=1,10
       call random_number(x)  ! initial 之後 再call 即為 random ~~@@
       write(*,*) x
       enddo
       end program

       subroutine init_random_seed()
       INTEGER :: i, n, clock
       INTEGER,  ALLOCATABLE :: seed(:)

       CALL RANDOM_SEED(size = n)
       ALLOCATE(seed(n))
       CALL SYSTEM_CLOCK(COUNT=clock)
       seed = clock - 2047 * (/ (i - 1, i = 1, n) /)
       seed = seed * 1103515245 + 2531011
       CALL RANDOM_SEED(PUT = seed)
       DEALLOCATE(seed)
       end subroutine
----------------------------------------

program random_test
implicit none
  real*8 :: x(10)

!  call random_seed()
 call init_random_seed() !<- this line is for GFortran
  call random_number(x)
  write(*,'(F21.18)') x
end program

2012年11月16日 星期五

顯示 中間 幾行

sed -n '5,10p' filename 這样你就可以只查看文件的第5行到第10行。

除了 tail / head 之外 

2012年11月12日 星期一

找出某時間 作檔案的複製 等動作


find ./ -mtime 3 -exec cp {} ./renyi \;
大於3天 被異動的檔案 執行 拷貝到 子目錄 renyi 之下



find
功能:依照指定條件,找尋檔案或目錄。
語法:find start_directory [-選項]

常用選項及代表檔案條件:
-amin <min> 指定時間內曾被存取過的檔案,單位為分鐘
-atime <day> 指定時間內曾被存取過的檔案,單位為24小時
-exec <指令> 當找到符合條件的檔案,就執行該指令,指令結尾必須是";"
-mmin <min> 指定時間內曾異動過的檔案,單位為分鐘
-mtime <day> 指定時間內曾被異動過的檔案,單位為24小時
-nouser 檔案不屬於本機上之任何User的檔案
-ok <指令> 用法同-exec,唯每一個指令執行前均會詢問使用者
-print 將符合條件的檔案資料由終端機顯示出來
-size <檔案大小> 符合檔案大小的檔案,單位為512Byte(Block),檔案大小前加"+"號代表大於這個 size,"-"代表小於這個size
-user <username> 屬於"username"的檔案

如何讀paper

http://ginny1228.pixnet.net/blog/post/21755250-%E5%A6%82%E4%BD%95%E8%AE%80paper%3F

http://start0813.pixnet.net/blog/post/26834268-%E3%80%90%E5%A6%82%E4%BD%95%E5%AF%AB%E8%AB%96%E6%96%87%E3%80%91%E8%AE%80%E5%8E%9F%E6%96%87paper

http://ramihaha.pixnet.net/blog/post/26783956-%5B%E7%A2%A9%E5%A3%AB%5D-%E4%BB%80%E9%BA%BC%E6%98%AF%E7%9C%8Bpaper

http://blizzard.cs.uwaterloo.ca/keshav/home/Papers/data/07/paper-reading.pdf

http://blog.yam.com/izumi92/article/16920588

entangled

1211.2043
Entanglement signatures of phase transition in higher derivative quantum field theoris
複合量子系統即為entangled (inseparable) [不可分]state[糾纏態]. 這些可在子系統之間測量到non-local[非局域]的quantum correlation [量子關聯].


2012年11月8日 星期四

gnuplot a b 由資料作圖

之前作過的gnuplot
今天加了 希臘字母


#set terminal postscript  eps color enhanced"Helvetica" 20 #"paper small"
set terminal postscript  color enhanced"Helvetica" 20
set output "AG300pp.ps"
set grid
# set style data linespoints
set title "J=3.00"
set multiplot
# Figure 1

set yrange[52:64]

set xlabel"{/Symbol b}"
set ylabel"A B C G"
plot "App300" using 1:2:3 with  yerrorbars ti "A" lt 1 pt 1
replot "Bpp300" using 1:2:3 with  yerrorbars ti "B" lt 2 pt 2
replot "Cpp300" using 1:2:3 with  yerrorbars ti "C" lt 3 pt 3
replot "Gpp300" using 1:2:3 with  yerrorbars ti "G" lt 4 pt 4
unset multiplot


---------------------------------------
ref
http://ontublog.blogspot.tw/2009/09/greek-letters-in-gnuplot.html 

2012年11月7日 星期三

ifort install on linux

前幾週 成功幫HT 解決 ifort路徑環境變數的問題
當然是google 得到答案
有點忘記了
但就搜尋紀錄整理


下載


Intel Fortan Compiler簡稱ifort, Windows下的ifort是收費的,但是Linux系統下提供免費的ifort,可以在下面的鏈接中下載需要的版本(必須先註冊,隨後會收到官網發來的郵件,裡面提供了接下來安裝需要的series-number)http://software.intel.com/en-us/articles/non-commercial-software-download/

在Ubuntu下安裝ifort之前,需要先安裝一些軟件包
sudo apt-get install build-essential 
sudo apt-get install g++ 
sudo apt-get install gcc-multilib 
sudo apt-get install rpm 
sudo apt-get install openjdk-6- jre-headless

sudo apt-get install libstdc++6

將下載下來的文件解壓 tar -zxvf l...tgz

安裝
進入上面解壓過後的文件夾,sudo install.sh 
安裝一共分六步,根據自己的需要選擇設置信息,一般一路enter下去即可。

修改運行環境信息
將source /opt/intel/bin/ifortvars.sh ia32添加到~/.bashrc文件裡

檢測安裝是否成功
ifort -v或ifort -V


環境變數 

加上最後兩行 因為cluster權限只能放在自家家目錄下 所以

# .bashrc

if [ ! -f ~/.ssh/authorized_keys ]; then
        mkdir ~/.ssh
        ssh-keygen -t dsa -N "" -f ~/.ssh/id_dsa -q
        cp ~/.ssh/id_dsa.pub ~/.ssh/authorized_keys
fi

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# User specific aliases and functions
source ~/intel/bin/compilervars.sh ia32 <=32 bit
ia32  => intel64  <= 64 bit

改完需要 source .bashrc


環境變數 prime


安裝 Intel Fortran Composer XE 及 IMSL Fortran Library(FNL) on CentOS
環境:
- CentOS v6.2 64-bit
- Intel Fortran Composer XE 64-bit
- IMSL FNL v7.0 64-bit (for RedHat Linux 版 64-bit)
注意事項:
- 以下安裝執行步驟請在同一個 console 視窗操作
- 如果有裝 SELinux 必須先將 SELinux disable 再重開機,重開機後, 安裝 Intel
Fortran Composer XE 後,再將 SELinux 設回原設定值重開機即可
1. 安裝 Intel Fortran Composer XE
將 Intel Fortran Composer XE 的 tgz 檔, 解壓縮(tar -xzvf 檔名)到資料夾
解壓縮後到該資料夾, 執行 ./install.sh 開始安裝程序
安裝好後, 設定 Intel Fortran Composer XE 環境變數(64-bit 版)
source /opt/intel/composerxe-2011/mkl/bin/mklvars.sh intel64
如果是 32bit, 則為 intel32
設置成功後系統即可認得 ifort 命令
設定 Intel Fortran MKL 環境變數(64-bit 版)
source /opt/intel/composerxe-2011.1.107/mkl/bin/intel64/mklvars_intel64.sh
2. 安裝及設定 IMSL Fortran Library(FNL) v7.0
新增資料夾來存 IMSL FNL v7.0 tar 檔
mkdir /root/software (資料夾可自訂)
新增 IMSL 安裝目的資料夾及後續動作
mkdir /usr/local/vni
mv <tarfile> /root/software
cd /root/software
tar xf <tarfile>
cd tarfiles
tar xf install.tar
cd /root/software/tarfiles/imsl/install
./ftp_install  (執行 IMS 安裝檔)
當安裝程式提示安裝 tars 的位置時,請輸入/root/software/tarfiles (有 install.tar 的資
料夾)     /root/software/tarfiles
當安裝程式提示 Enter the directory where you want to install IMSL products.
請輸入/usr/local/vni
請確定路徑與檔名正確
安裝完畢後設定 IMSL 環境變數
source /usr/local/vni/imsl/fnl701/lnxin121e64/bin/fnlsetup.sh
lnxin121e64 是電腦名稱,每台電腦會有所不同,請檢查該資料夾名稱是
否正確。
取得電腦資訊, 以便申請正式 license key
cd /usr/local/vni/license/bin/
./get_host_info
此檔案會產生 hostinfo.<hostname>檔案,
正式 license 授權檔(檔名 license.lic)
請將 license.lic 檔存至 /usr/local/vni/license/
再取得正式 license.lic 檔前,  可以提供試用的 license.lic 授權檔
IMSL license 管理說明(for 正式 license 授權檔用, 試用 license 不需要)
到 /usr/local/vni/license/bin 下, 會有以下內容
./start_license 可以啟動 license manager
./lmdown 可以關閉 license manager
./lmreread 可以重新讀入 license.lic 授權檔
TIPS:
將以下指令加入環境變數設定檔 /etc/profile
在檔案最後貼上之前的設定環境變數指令(請注意路徑是否正確)
source /opt/intel/bin/compilervars.sh intel64
source /opt/intel/composerxe-2011.1.107/mkl/bin/intel64/mklvars_intel64.sh
source /usr/local/vni/imsl/fnl701/lnxin121e64/bin/fnlsetup.sh
下指令編譯程式
Shared Library
$F90 $F90FLAGS fnl.f90 -o fnl $LINK_FNL
Static Library
$F90 $F90FLAGS fnl.f90 -o fnl $LINK_FNL_STATIC 

2012年11月6日 星期二

vi memo

http://www.study-area.org/tips/vim/Vim-10.html


刪除全文空白行
:g/^[<Space><Tab>]*$/d

全域取代
:1,$s/ 舊 /新 /g

同時編輯兩文件 可複製超過100行
vi file1 file2
yy
:n
p
:N


vi技巧
d0                 delete 游標處到行頭
d^
dw                delete word
d3w
db
d$                 到行尾
:,$d                到文末

移動游標
f "G"  forward ?
F "a"
t "G"  trans ?

合併
xp 交換字元
J 合併兩行
:g/^/m0  內容反轉
ab string strings
r R
s S= bites of r R






awk link

AWK手冊  http://lalakiwe.myweb.hinet.net/Documents/awk/awk_1.html
awk工具
http://www.cyut.edu.tw/~dywang/linuxProgram/node1.html
shell script 入門
http://www.csie.nctu.edu.tw/~tsaiwn/course/introcs/history/linux/linux.tnc.edu.tw/techdoc/shell/book1.html


http://linux.vbird.org/linux_basic/0330regularex/awk.pdf

http://www.delightpress.com.tw/bookRead/skns00004_read.pdf

awk sed 處理欄位 列


刪除全文空白行  用 vi
:g/^[<Space><Tab>]*$/d  
:g/^[ ^I]*$/d


去除 在awk 螢幕輸出file 之後產生多餘的^M

:1,$s/<CTRL>+<v> <CTRL>+<m>//g

將多欄分開


325.sh script
awk '{printf $1 "\t" "\n"}' 325  > A325
awk ' NR%5==1;NR%5==4 {printf $1 "\t" "\n"}   NR%5!=1 {printf $2 "\t" "\n"}' 325 > B325
awk ' NR%5==1;NR%5==4 {printf $1 "\t" "\n"}   NR%5!=1 {printf $3 "\t" "\n"}' 325 > C325
awk ' NR%5==1;NR%5==4 {printf $1 "\t" "\n"}   NR%5!=1 {printf $4 "\t" "\n"}' 325 > D325
awk ' NR%5==1;NR%5==4 {printf $1 "\t" "\n"}   NR%5!=1 {printf $5 "\t" "\n"}' 325 > E325
awk ' NR%5==1;NR%5==4 {printf $1 "\t" "\n"}   NR%5!=1 {printf $6 "\t" "\n"}' 325 > F325
awk ' NR%5==1;NR%5==4 {printf $1 "\t" "\n"}   NR%5!=1 {printf $7 "\t" "\n"}' 325 > G325

325  file
--

OBS32510352432
   2.4146e+01   2.4191e+01   2.4269e+01   1.5132e-01   3.0528e-02   5.7997e+03   2.9464e+01
   5.0289e+00   4.9964e+00   5.0909e+00   1.1074e-02   3.4971e-03   6.6818e+02   3.0671e+00
140000
   1.3440e-02   1.3353e-02   1.3606e-02   2.9596e-05   9.3464e-06   1.7858e+00   8.1972e-03
OBS32510602432
   2.4761e+01   2.4774e+01   2.4784e+01   1.5144e-01   3.0568e-02   5.9472e+03   2.8755e+01
   5.1367e+00   5.1333e+00   5.1684e+00   1.1118e-02   3.5050e-03   6.8592e+02   3.0256e+00
140000
   1.3728e-02   1.3719e-02   1.3813e-02   2.9715e-05   9.3675e-06   1.8332e+00   8.0863e-03
.....
---

B325
--
2.5392e+01
5.2551e+00
140000

1.4045e-02
OBS32511152432
2.5989e+01
5.4133e+00
140000

1.4468e-02
...
---