Archive for March, 2010

-g Compile with debugging symbols (does not affect optimization level in the Intel compilers).
-traceback (ifort only) produce traceback information at runtime if the code terminates abnormally.
-O0 Turn off optimizer.
-O[1-3] Turn on optimizer, level 1-3 aggressiveness (default is -O2; O1 and O2 are equivalent).
-no-prefetch Disable software prefetching (prefetching is turned on by default in ifort with -O3).
-scalar_rep (ifort only) Enable scalar replacement (scalar replacement is turned off by default in ifort with -O3).
-march=pentium4 (icc only) Generate code exclusively for a Pentium 4 or Xeon processor (employ SSE2 scalar instructions).
-unroll[n] Set maximum number of times to unroll loops. Omit n to use default heuristics. Use n=0 to disable loop unroller.
-xN Utilize SSE2 instructions (works only with Pentium 4 and higher); turns on auto-vectorizer.
-axN Same as above, but build “fat” executable that provides alternate instructions for non-P4 architecture.
-fno-alias Assume no pointer aliasing in program.
-fno-fnalias Assume no aliasing within functions, but assume aliasing across function calls.
-ansi_alias Assume ANSI compliance for optimization purposes (no out of bounds references, no casting of pointers to non-pointer types, no aliasing of objects with different types).
-alias_args Assume function arguments are not aliased.
-safe_cray_ptr (ifort only) Cray pointers do not alias with other variables.
-ip Enable single-file interprocedural optimizations.
Profile-Guided Optimization
-prof_gen Instrument program for profile-guided optimization.
-prof_use Enable use of PGO instrumentation during optimization (build with -prof_use after you have collected stats with a binary built with -prof_gen).
-pad (ifort only) Enable changing variable and array memory layout.
Floating Point
-fp-model precise Enables value-safe optimizations on floating-point data. Disables optimizations that can change the result of floating-point calculations.
-nolib-inline Disables inline expansion of standard library or intrinsic functions. This flag is sometimes required to maintain floating point consistency between -O0 and -O2 builds
Set precision of x87 FPU to 32 bits, 64 bits, or 80 bits by modifying the FPU control word (53-bit significand or approximately 16 significant digits) by default. Note that this can only be set for a program that includes a main() function or subroutine.
-fpe[0,1] (ifort only) Set floating point exception handler to flush underflows to zero and (-fpe0) error out on other exceptions or (-fpe1) continue processing after other exceptions.
Open MP
-openmp Turns on OpenMP.
-openmp_stubs Ignore OpenMP directives and functions by using stubs library.
Variable Treatment
-auto (ifort only) Make all local variables AUTOMATIC (default when using -openmp).
-auto_scalar (ifort only) Make only scalar local variables AUTOMATIC (default when not using -openmp).
-fpscomp logicals (ifort only) Very important if calling MPI subroutines that use logical arguments such as MPI_CART_SUB. Set internal representation of logical variables to use 1 for .TRUE. and 0 for .FALSE. instead of default.
Compiler Messages
-w Turn off warning messages.
-w95 (ifort only) Turn off warnings about Fortran 90/95 compliance.
-cm (ifort only) Turn off all comments.
-vec_report2 Indicate vectorized/non-vectorized loops.
-opt_report Generate an optimization report to stderr.
-fpp[0-3] (ifort only) Use Fortran preprocessor with level 0, 1, 2, or 3.
-static Create static executable.
-shared Create executable that uses shared libraries (default).

Typical Intel C debugging command line example:

$icc -g -O0 -oa.out programname.c

Typical Intel Fortran optimized command line example:

$ifort -O3 -xN -ip -fno-alias -safe_cray_ptr -oa.out programname.F

I personally use the following options for compilation:

$ifort -c -w -cm -tpp7 -save programname.F

and to create an executable:

$ifort -arW -align -w -cm -tpp7 -save programname.F  programname.x

see also https://computing.llnl.gov/linux/linux_basics.html, and


Read Full Post »

Python: help commands

To get more information about each module, there are a few methods:

1) using dir command

>>> import time

without arguments, ‘dir()‘ lists the names: variables, modules and functions you have defined currently:

>>> dir()
[‘__builtins__’, ‘__doc__’, ‘__name__’, ‘time’]

>>> dir(time)
[‘__doc__’, ‘__file__’, ‘__name__’, ‘accept2dyear’, ‘altzone’, ‘asctime’, ‘clock’, ‘ctime’, ‘daylight’, ‘gmtime’, ‘localtime’, ‘mktime’, ‘sleep’, ‘strftime’, ‘strptime’, ‘struct_time’, ‘time’, ‘timezone’, ‘tzname’, ‘tzset’]

To check if there is documents for the module or on of its functions, you can check __doc__

>>> print time.ctime.__doc__
ctime(seconds) -> string

Convert a time in seconds since the Epoch to a string in local time.
This is equivalent to asctime(localtime(seconds)). When the time tuple is
not present, current time as returned by localtime() is used.


to see the whole documentation on time() module, try

>>> print time.__doc__
This module provides various functions to manipulate time values.

There are two standard representations of time.  One is the number
of seconds since the Epoch, in UTC (a.k.a. GMT).  It may be an integer
or a floating point number (to represent fractions of seconds)….

The other representation is a tuple of 9 integers giving local time.
The tuple items are:
year (four digits, e.g. 1998)
month (1-12)


timezone — difference in seconds between UTC and local standard time
altzone — difference in  seconds between UTC and local DST time


time() — return current time in seconds since the Epoch as a float
clock() — return CPU time since process start as a float
sleep() — delay for a number of seconds given as a float


You can also get help using the help() function:

>>> help(time)



>>> help(time.sleep)

Help on built-in function sleep in module time:


Delay execution for a given number of seconds.  The argument may be
a floating point number for subsecond precision.

Read Full Post »


KAddressBook is an addressbook viewer / frontend for the K Desktop Environment.

Part of KAddressBook panel on my Debian/Lenny desktop.

KAddressbook  was integrated in KMail and KOrganizer even before the KDE Kontact project was started. It is a comfortable frontend to organize the addresses of your friends, business partners, etc.

Wizard of a new "To Do".

It allows you to import and export adressbook files, offers a function to search for adresses.

Read Full Post »

It happens quite often that you need to pass a variable to a program.  You have to use the sys module. It tells you about all the input variables including the file name itself. A simple program is the following:


import sys

if len(sys.argv) < 2:

print “Usage: script.py <number>”


numeric_arg = int(sys.argv[1])


print ‘1st argument must be numeric.’

if len(sys.argv) == 2:

print “The input number is”, int(sys.argv[1])


When you run it, the output is like this:

$ python file.py
Usage: script.py <number>
$ python file.py 5
The input number is 5

There are many things more that you can do with sys. For instance, it tells you the library search path. Python looks in several places when you try to import a module. Specifically, it looks in all the directories defined in sys.path. This is just a list, and you can easily view it or modify :

>>> import sys
>>> sys.path

[”, ‘/usr/lib/python2.5’, ‘/usr/lib/python2.5/plat-linux2’, …..]

Read Full Post »

Python: __main__

Python modules are objects and have several useful attributes. You can use this to easily test your modules as you write them, by including a special block of code that executes when you run the Python file on the command line.

if __name__ == ‘__main__’:

diffusion()    # name of the function defined above the if statement

So what makes this if statement special? Well, modules are objects, and all modules have a built-in attribute __name__. A module’s __name__ depends on how you’re using the module. If you import the module, then __name__ is the module’s filename, without a directory path or file extension.

>>> import time
>>> time.__name__

But you can also run the module directly as a standalone program, in which case __name__will be a special default value,__main__ . Python will evaluate this if statement, find a true expression, and execute the if code block. In this case, to print two values.

It helps you to write separate parts of your program as functions, and call tehm via a short main program. Finally, use the __main__ command to call/run the whole program. There are perhaps better ways to document it but I use it like this currently.

Read Full Post »