Taiwan is a independent country. Chinese are forbidden into,台灣是我的國家,不是他媽中國的一部分,去你媽的中國人
2008/9/25
Conditional operator <-> ternary operator
C = A > B ? V1: V2;
if (A>B) C = V1;
elese C =V2;
2008/9/24
Distribution Data (DA)
Gets information about a given distributed array.
Synopsis
#include "petscda.h"
PetscErrorCode PETSCDM_DLLEXPORT DAGetInfo(DA da,PetscInt *dim,PetscInt *M,PetscInt *N,PetscInt *P,PetscInt *m,PetscInt *n,PetscInt *p,PetscInt *dof,PetscInt *s,DAPeriodicType *wrap,DAStencilType *st)
Input Parameter
da -the distributed array
Output Parameters
dim - dimension of the distributed array (1, 2, or 3)
M, N, P - global dimension in each direction of the array
m, n, p - corresponding number of procs in each dimension
dof - number of degrees of freedom per node
s - stencil width
wrap - type of periodicity, one of DA_NONPERIODIC, DA_XPERIODIC, DA_YPERIODIC, DA_XYPERIODIC, DA_XYZPERIODIC, DA_XZPERIODIC, DA_YZPERIODIC,DA_ZPERIODIC
st - stencil type, either DA_STENCIL_STAR or DA_STENCIL_BOX
Note
Use PETSC_NULL (PETSC_NULL_INTEGER in Fortran) in place of any output parameter that is not of interest.
DAGetCorners
Returns the global (x,y,z) indices of the lower left corner of the local region, excluding ghost points.
Synopsis
#include "petscda.h"
PetscErrorCode PETSCDM_DLLEXPORT DAGetCorners(DA da,PetscInt *x,PetscInt *y,PetscInt *z,PetscInt *m,PetscInt *n,PetscInt *p)
Input Parameter
da -the distributed array
Output Parameters
x,y,z - the corner indices (where y and z are optional; these are used for 2D and 3D problems)
m,n,p - widths in the corresponding directions (where n and p are optional; these are used for 2D and 3D problems)
Note
The corner information is independent of the number of degrees of freedom per node set with the DACreateXX() routine. Thus the x, y, z, and m, n, p can be thought of as coordinates on a logical grid, where each grid point has (potentially) several degrees of freedom. Any of y, z, n, and p can be passed in as PETSC_NULL if not needed.
2008/9/17
Data Visualizer
homepage: http://mayavi.sourceforge.net/index.html
- Visualize computational grids.
- Visualize scalar, vector and tensor data.

Homepage: http://www.paraview.org/New/index.html
ParaView is an open-source, multi-platform application designed to visualize data sets of size varying from small to very large. The goals of the ParaView project include the following:
- Develop an open-source, multi-platform visualization application.
- Support distributed computation models to process large data sets.
- Create an open, flexible, and intuitive user interface.
- Develop an extensible architecture based on open standards.

Homepage: http://www.opendx.org/
OpenDX gives you new control over your data...and new insights into their meaning. Yet OpenDX is easy to use because it lets you visualize data in ways you've never dreamed of--without getting bogged down in the technology.

2008/9/11
PetscBarrier
Blocks until this routine is executed by all processors owning the object A.
Synopsis
#include "petsc.h"
PetscErrorCode PetscBarrier(PetscObject obj)
Input Parameters
A -PETSc object (Mat, Vec, IS, SNES etc...) Must be caste with a (PetscObject), can use PETSC_NULL (for MPI_COMM_WORLD)
Easy usage: PetscBarrier(PETSC_NULL)
C++ command-line arguments
For instant, if our program name is a.out, we may type in ./a.out -m 20 -n 30 -z 90 -haha happy from the terminal, and the string "may" would automatically be passed as a parameter to the main routine of our
a.out
program.To use these parameters, we must specify in our main routine what the parameter names and types are, and the format is exactly as follows:
int main(int argc, char *argv[])
Each argument is passed as a seperate character array, so argv[1] points to the first argument text, argv[2] points to the second argument text, etc. (argv[0] gives you the name of the executable file for the program itself)
example

./a.out -n 30 -m 40
2008/9/10
vector function in PETSc
Creates an empty vector object
Synopsis
#include "petscvec.h"
VecCreate(MPI_Comm comm, Vec *vec)
VecSetSizes
Sets the local and global sizes, and checks to determine compatibility
Synopsis
#include "petscvec.h"
PetscErrorCode PETSCVEC_DLLEXPORT VecSetSizes(Vec v, PetscInt n, PetscInt N)
Parameter
v-the vector
n-localsize
N-Globalsize
MPI function in PETCs
MPI_Comm_rank
#include "mpi.h"int MPI_Comm_rank ( MPI_Comm comm, int *rank)
Determines the rank of the calling process in the communicator
2008/9/9
Sone definition of PETSc parameter
- PetscMPIInt = int {typedef int PetscMPIInt}
- PetscErrorCode = int {typedef int PetscErrorCode}
- PetscInt = int {no 64bit }
- PetscInt = long long {64bit}
- PetscErrorCode = int {typedef int PetscErrorCode}
2008/9/8
C++除錯用cerr
2008/9/2
兩個程式檔.cpp的全域變數的宣告
object global_value=xxx;
int main(){
.......
}
In function.cpp
extern object global_value;
int function(){
}
How to compiler PETSc's program and run
include ${PETSC_DIR}/bmake/common/base
include ${PETSC_DIR}/bmake/common/test
print.out: p-hellow.o
${CLINKER} -o print.out p-hellow.o ${PETSC_LIB}
Note: It will find correspond file name automatically.
For example: p-hellow.o -> p-hellow.cpp
runfile:
${PETSC_DIR}/bin/petscmpiexec -np 2 ./print.out
OR
mpirun -np 2 ./print.out
2008/8/31
FreeBSD DNS - How to work
# /etc/rc.d/named start
# ndc start
A DNS server in FreeBSD relies on the BIND daemon. This daemon is called 'named' for obvious reasons.
named - the bind daemon
ndc - name daemon control program
/etc/namedb - directory where all the bind information resides
/etc/namedb/named.conf - daemon configuration file
zone files are usually contained within the /etc/namedb directory, and contain the information (query answers from your site) served by your name server.
2008/8/28
2008/8/22
play rmvb file in linux
I go to mplayer homepage: http://www.mplayerhq.hu/design7/news.html
Then download binary code. It says that move the extract file from the essential-20071007.tar.bz2 to
/usr/lib/codecs/ or /usr/local/lib/codecs/ or /usr/lib/win32
finally, replay mplayer. It is ok!
However, it does not work for my OS.
Option 2 Helix Player
Helix Player homepage: https://player.helixcommunity.org/2007/releases/HelixPlayer/ReleaseNotes.html
You can use urpmi helixplayer
Or download rpm from download page
It also does not work
hxplay XXX.rmvb
Option 3 RealPlayer
http://www.real.com/linux download RealPlayer11GOLD.bin
Then chmod 744 RealPlayer11GOLD.bin
./RealPlayer11GOLD.bin
realplay XXX.rmvb
It work.
2008/8/19
自家網頁的認証
- 在~/public_html建個目錄: $ mkdir ~/public_html/protect
- 在~/下: $ htpasswd -c ~/apache.passwd user
- 在~/public_html/protect/下: $ touch .htaccess
- vi .htaccess
- 加入
Authtype Basic
AuthUserFile /home/user/apache.passwd
require valid-user
打完收工,接著把要連結的網頁或檔案放進~/public_html/protect/
你會發現居然要輸入user和password
free FTP and sFTP solution in LINUX
How to install:
$ yum or urpmi filezilla (remember to su root)
Homepage: http://filezilla-project.org/index.php
linux 上的翻譯軟體
free software但是我還是簡單介紹一下好了
You can use yum(Fedora) or urpmi(Mandriva) to simply install like that
$ urpmi stardict
It is very easy. Or go to Stardict homepage: http://stardict.sourceforge.net/index.php
additionally, you can download many dictionary from homepage then
Install Dictionaries in Linux:
1. To download these tarball dictionaries,
2. do this: tar -xjvf a.tar.bz2
3. mv a /usr/share/stardict/dic
More detail please visit 重灌狂人: http://briian.com/
However, it operates in windows XP. You can do the same in LINUX.
2008/7/8
some useful physical constant
Ar: 6.63352e-26 Kg
Xe: 2.1801e-25 kg
1 bar = 750.06 Torr
R=62.36367 L·Torr·K-1·mol-1
= 8.20574587 × 10-5 m3·atm·K-1·mol-1
1 Torr = 3.21875E22 particle/m^3
2008/6/24
2008/6/20
ssh login no password
- modify the /etc/ssh/sshd_conf
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
ssh-keygen -t rsa
- cd $home/.ssh
cp /.ssh/identity.pub /.ssh/authorized_keys
- restart sshd
ssh-agent $SHELL
ssh-add
2008/6/19
2008/6/11
2008/6/10
在linux上用msn
目前小弟我是用KMess(KDE)
之前,也有用過amsn但是推薦在Fedora上或Gnome桌面使用
或是pidgin (gaim的後來計劃)都還不錯
Mandriva 2007 英文作業系統上audacious要顯示中文歌曲
終於,首先KDE的相關套件全裝,然後開啟audacious的preference->playlist->character encoding
填入 big5就可以
網路上說法Auto character encoding 選chinese可惜英文版不能選, 只好在他下方的地方填入big5就可以了
2008/6/8
How to install or setup PETSc
Intel MKL on Windows or Linux (/usr/opt/int/mkl)
Assume I had install MPICH and BLAS & LAPACK.
Therefore, if you want to install single computer PETSc without MPICH
- PETSC_DIR=$PWD; export PETSC_DIR
- ./config/configure.py --with-cc=/opt/intel/cc/10.0.14/bin/icc --with-cxx=/opt/intel/cc/10.0.14/bin/icpc --with-fc=/opt/intel/fc/10.0.14/bin/ifort --with-blas-lapack-dir=/usr/opt/intel/mkl/10.0.1.014 --with-mpi=0
- make all
- make test
- Install PETSc with MPICH
- PETSC_DIR=$PWD; export PETSC_DIR
- ./config/configure.py --with-blas-lapack-dir=/usr/opt/intel/mkl/10.0.1.014 --with-mpi-dir=/usr/opt/mpich --with-clanguage=cxx --with-cxx=/usr/opt/mpich/bin/mpicxx
- make
- make test
BLAS/LAPACK: these packages provide some basic numeric kernels used by PETSc.
- /usr/lib/libblas.a,liblapack.a
- Intel MKL on Windows or Linux
- sunperf on solaris
- VecLib on Macs
- IBM ESSL
- --with-blas-lapack-lib=libsunperf.a
- --with-blas-lib=libblas.a --with-lapack-lib=liblapack.a
- --with-blas-lapack-dir=opt/intel/mkl72
. /config/configure.py --with-mpi-dir=/path-to-mpich-install
MPICH configure
2008/6/7
快被氣死的Mandriva 2007 & 2008 security
normal user 不能 reboot,poweroff 和使用 /usr/bin
搞了半天原來是 "安全性" 調成了 High 或 Higher
urpmi Usage
list my configured media sources :
urpmq --list-media
add any local directory I like as a package source:
urpmi.addmedia --update "some_name" file:///some/directory/path
automatically update everything that needs updating:
urpmi --auto-select (note: this will NOT update your kernel!)
detail website: http://speculation.org/garrick/urpmifaq.txt
2008/6/6
nvidia driver install on Mandriva 2007
easy urpmi website: http://easyurpmi.zarb.org/
video card : Geforce4 Magic
***************************************
* Note: Do not forget installing kernel source *
***************************************
1. Add urpmi media using easy urpmi
urpmi.addmedia main http://ftp.twaren.net/Linux/Mandrake/official/2007.1/i586/media/main/release with media_info/hdlist.cz
urpmi.addmedia --update main_updates http://ftp.twaren.net/Linux/Mandrake/official/2007.1/i586/media/main/updates with media_info/hdlist.cz
urpmi.addmedia contrib http://ftp.twaren.net/Linux/Mandrake/official/2007.1/i586/media/contrib/release with media_info/hdlist.cz
urpmi.addmedia --update contrib_updates http://ftp.twaren.net/Linux/Mandrake/official/2007.1/i586/media/contrib/updates with media_info/hdlist.cz
urpmi.addmedia --update plf-free http://mdk.linux.org.tw/ftp/pub/plf/mandriva/2007.1/free/release/binary/i586/ with media_info/hdlist.cz
urpmi.addmedia --update plf-nonfree http://mdk.linux.org.tw/ftp/pub/plf/mandriva/2007.1/non-free/release/binary/i586/ with media_info/hdlist.cz
2. Install nvidia driver
you can use the mandriva control centre to choose the packages
urpmi nvidia
Then it automatically choose
dkms-2.0.16-1.1mdv2007.1.noarch
dkms-minimal-2.0.16-1.1mdv2007.1.noarch
dkms-nvidia97xx-1.0-9755.2plf2007.1.i586
nvidia97xx-1.0-9755.2plf2007.1.i586
3. setup nvidia driver
After drivers are installed you can install them by typing (as root)
XFdrake
- now select your card - this should be done automatically but please check.
- save settings and reboot - you may not need to but sometimes the nvidia module doesn't load until a reboot.
4. Check nvidia 3d is working
Test the 3D by trying to run a game/screensaver
5. Enable XGL
- login to MCC
- choose hardware - configure 3D desktop effects
you should be able to choose XGL
- reboot and you should have a shiny 3D desktop
NVidia drivers installation
The thing that’s probably missing is a NVidia proprietary driver that supports the composite extension needed by Xgl (the default free driver nv
unfortunately does not support it). Installing the driver in Mandriva is as easy as typing as root urpmi nvidia
in the system console. If everything goes properly a table like this should appear:
More information about nvidia-8774-4plf2007.0.x86_64 IMPORTANT NOTE: This PLF provided NVIDIA driver must be configured differently than the one available from NVIDIA, so please follow the instructions below: If you are upgrading from a Mandriva Club or PLF provided NVIDIA driver, reconfiguring is usually unnecessary.
You can reconfigure X to use the new NVIDIA driver either automatically:
Run XFdrake as root.
Go to the Graphics Card list
Select your card (it is usually already autoselected).
Answer any questions asked and then quit.
OR you can do it manually by editing /etc/X11/xorg.conf:
Change the Driver to "nvidia" in the Device section.
Remove any Load "glx" lines from the Module section.
Add the following line to the Module section: Load "/usr/lib64/xorg/modules/extensions/nvidia/libglx.so"
Run "update-alternatives --config gl_conf" and select nvidia.conf.
So, now all we need to do is to follow the instructions provided by the manufacturer. I used a text editor called VIM, so I typed vim /etc/X11/xorg.conf
and applied the suggestions above.
2008/6/5
ATi and nvidia dirver 在mandriva的安裝
先用easy urpmi加入plf站台
再登入root,使用urpmi
nvidia 或 urpmi ati
Easy urpmi: 加入更多套件來源
要指定加入套件來源的地址,用指令會比用進入MCC圖形介面更加容易。PLF的網站有一個介面叫 Easy urpmi,可以把你準備加入的站台的程序指令以文字形式顯示出來,只要以 root 身份把它給你的一行行指令用老鼠剪貼到到終端機去執行就可以了。
以 MDV2008 比方來說,通常先把 DVD 或 CD 媒體 的"啟用"取消(MCC 下執行,或終端機下執行urpmi.removemedia -a) 後,用喜歡的瀏覽器 (如mozilla-firefox)開啟 easyurpmi.zarb.org 網址 ,它會問你一些問題,然後會給你要用到的指令
1.在網頁第一個步驟 (Select your system) 中指定使用版本,機種,跟管理機制,比如Mandriva 2008.0 ,x86_64 (表示AMD 的 64 bit,跟Intel 的 64bit, i586 都不一樣),跟 urpmi,及要不要 Select the mirror separately for every source 。然後按 "proceed to step 2"。
2. 指定站台地址: main、contrib 和 update 的 mirror 站台地址。Main 是正式支援的自由軟體套件,有些非自由軟體會放到 non-free下,contrib 是其它人協助包裝但沒有正式支援的,對這三者而言: XXX_update 是發行後更新套件,XXX_backport 是半官方版本更新套件(有相容風險)。有裝 YYY 來源的話,YYY_update 最好也加入。以新增Main媒體為例,就把mirror 站下拉選成喜歡的(如twaren.net ),然後打勾。PLF 這是 PLF 自己的套件的 mirror 站台地址。
最後按 proceed to step 3。
3.以 root 用老鼠剪貼它顯示的指令到到終端機去執行,以新增Main媒體為例,如下:
urpmi.addmedia --update main_updates http://ftp.twaren.net/Linux/Mandrake/official/2008.0/x86_64/media/main/updates with media_info/hdlist.cz
要是 64 bit 環境要混用 i586套件,只要回到步驟一把架構換成 i586,重複加入更多的套件來源即可。這樣就可以在圖形介面 (rpmdrake) 或文字模式介面 (urpmi) 中選取安裝喜歡的軟件了。
使用管理
裝好後後可以用
- urpmq 套件名稱
查詢是否已安裝某個套件。
-p 查詢還沒安裝套件檔案的資訊
-i 顯示套件的功用資訊
-l 列出包含了那些檔案
-a 列出系統內所有的套件
分頁輸出用rpm -qa | less - urpmi 套件名稱
來安裝你想要的套件, - urpmf 檔案名稱
可以查詢某個檔案是在那個套件裡面。 - urpme 檔案名稱
移除某個套件
即使在文字模式介面下,只要套件來源設好,要是需要安裝相依套件,urpmi也 會警告套件相依,在使用者同意後自行滿足安裝相依,十分方便。
安裝更新管理
新版在軟體有更新時,在gnome 工具列上也會提醒安裝更新。可以自行參考 /etc/urpmi/urpmi.cfg 的格式修改設定自動更新安裝。往後定期跑 urpmi.update -a 更新所有媒體資訊,文字模式介面下,每天也只要執行
urpmi --auto-select --media updates
就可以很簡單完成重大更新安裝。
不過有時候mirror 站會出問題卡住(其他如Ubuntu 也會),還是不建議完全倚賴用自動更新。
相依(dependency)問題
想把其他家的 RPM 套件裝到 Mandriva 上經常可能會遇到相依問題, 特別是出現 "找不到某某 .so 檔" ( shared objects: 動態聯結程式庫,) 之類的錯誤訊息。可能要到sophie/rpmfind 網上搜尋那個套件裡面提供欠缺的 .so程式庫,。 找不到同樣版本的話,有時到 /lib 或 /lib64 下建立 symbolic link 欺騙系統也許能成功。如
ln -s 某某.so.現有版 某某.so.需要版
不過32 位元 跟 64 位元程式庫通常是無法互用的。
Reference: Shelandy