2009年5月24日星期日

段错误Segmentation fault with ifort -openmp

在运行使用ifort加openmp参数编译出来的程序时,有时候报segmentation fault段错误。比较烦,因为同样的代码用pfg90编译出来的就没事。所以怀疑不是程序的问题,在网上查到intel论坛里有人对这个问题找到了解决方法。
现在就使用最简单的在shell中设置“ulimit -s unlimited”的方法。下面是引自intel论坛的两段话段话。
---------Segmentation fault with ifort -openmp------------------

I am replying to my thread Since I found the solution

It was a stack overflow.

I could remedy it by using

ulimit -s 2048000 (you can choose an appropriarte) number ... then changing the same in /etc/security/limits.conf (to have it changed permanently).

then export KMP_STACKSIZE=2048000000 (i chose very high value, since it is only a limit)


A few notes to add to Micah's
1) if 'ulimit -s unlimited' fails it means that the kernel is configured with a hard limit to the size of the stack for user shell processes. This limit needs to be removed by a root user.
2) 32bit Linux distros have a static pthread library (libpthread.a) that will set the user stack to 2MB at runtime during the startup of your program linked statically with libpthread. Thus, anything you do to ulimit is ignored. Keep in mind, this only affects 32bit linux distros and only if you link statically. Unfortunately, if you use
ifort -fast .... or icc -fast
the -fast option includes -static which will do a static link
To avoid this issue, either don't use -fast and call out -O3 and -ax explicitly. See -fast for all the options included therein.
3) Some batch and runtime systems used on clusters often ignore your current limits for the remote processes. Thus, you'll need to put the unlimit command inside your .bashrc and/or your .profile
4) I've had to move around a LOT of systems over the years, so when I create my programs, in my startup I call a C function "unlimit_stack()" to bump my stack up as high as it'll go (unlimited in most cases). Here is that C code:

#include // perror

#include // exit

#include // setrlimit

#include // setrlimit

#include // setrlimit

void unlimit_stack_(void) {

struct rlimit rlim = { RLIM_INFINITY, RLIM_INFINITY };

if ( setrlimit(RLIMIT_STACK, &rlim) == -1 ) {

perror("setrlimit error");

exit(1);

}

}

Yes, a Fortran programmer who can write C too. and here's how to call it from Fortran:

Program main

external unlimit_stack

call unlimit_stack()

...etc...

end

Hope this helps. If not, I have some code to determine at runtime the stacksize seen by your program.

-------------------------------------------------------------

另一个关于Segmentation fault的帖子

2009年5月9日星期六

在日本买车养车的费用计算

摘自:http://liuxue.kantsuu.com/200712/20071227110442_99495.shtml

在日本要买一辆私家车,大致可以通过以下3种方法。
1 通过正规车行购买新车,一般都是市场定价,根据车种不同,价格也不等,便宜的车种一般100万日元起。
2 通过二手车行。因为是二手车,价格也当然要便宜许多,很多车行还有代办车辆登记等手续。便宜的车种一般30万日元起。
3 通过个人买卖,或者是废车整理工厂。价格最便宜,但是不适合对车辆一窍不通的人。

私家车的税金问题
私家车须交车辆买价的5%,轻自动车须交车辆买价的3%的所得税。但是,50万日元以下不作为缴税对象。
消费税是车辆买价的5%.

回收再利用费用
购入车辆或第一次车检时交付再利用费,大约是1万日元-2万日元。

车库证明
车库证明是证明你有可以停车地方。这张证明在购买新车以及车辆转让时都需出示。 可以先到所住管辖警察署的交通管理课领取申请表。填好有关事项后提交,同时缴纳2600日元的收入印纸。一般4个工作日后便可领取车库证明。

车检(自赔责+重量税)
买车容易养车难。根据自己的经济能力来选一辆适合自己的车是很重要的。 法律规定必须2年进行一次车检,不通过车检,或是车间期限已过期的车辆不能在公道上行驶。 新车购入时第一次车检可以用3年,而二手车的话需要每两年,或者每年车检一次。车检费用可以委托经销商,民间私营车检场等,但根据使用年数和车种而会有很大的不同。自赔责和重量税的排气量是一律一样的,但由于手续费,配备料,换部件费用等,车检的价格会有很大的差异。


自赔责任保险料(一交两年)
全称自动车损害责任保险。 这是日本国家强制保险,有加入的义务。 基本上24个月的保险料轻自动车是22540日元,私家用乘用车是27630日元。

自动车重量税(一交两年)
每次车检时必须缴付的税金。 期限两年,轻自动车8800日元,私家乘用车按车身重量每500公斤缴付12600日元,普通乘用车一般在1-2吨左右。

500公斤以下 12600日元

501公斤-1吨 25200日元

1吨-1.5吨 37800日元

1.5吨-2吨 50400日元

以此类推。

另外,废车之后已经缴付的自动车重量税可以返还

自动车税(一交一年)
每年的4月1日,支付4月到来年3月的自动车税,一年一交。另外,轻车使用11年以上,普通车使用13年以上,会另外加收“10%的重课”。(对于新型低尾气排放车辆还有25%或50%的轻课。)
轻自动车7200日元(7920日元),私家乘用车

661cc-1000cc 29500日元(32400日元)

1001cc-1500cc 34500日元(37900日元)

1501cc-2000cc 39500日元(43400日元)

2001cc-2500cc 45000日元 (49500日元)

2501cc-3000cc 51000日元(56100日元)

3000cc以上略。

另外还有汽油费,公寓住宅的停车费,任意保险费(便宜的可以一年4、5万日元)等等。
买车之前,建议量力而为,三思而行。

两年车检固定养车费用举例

轻自动车:自赔责22540+重量税8800+自动车税7200×2=45740

2000cc的普通乘用车:自赔责27630+重量税37800+自动车税39500×2=144430

任意保险就算50000×2=100000

因此,不算油费和停车费的话,如果是2000cc的车的话,光养车两年就要先准备25万日元左右的固定支出。而轻自动车却可以节省出大概10万日元左右,买车时这个一定要考虑进去。