Thursday, September 30, 2010

Tips and tricks of using OPENSUSE linux

I do my research work on Acer aspire 4530 laptop with opensuse 11.3, 64 bit version. In this post I will keep on compiling various tips and tricks which I have gathered during the course of my work.

Convert video from flv to avi format
ffmpeg -i [<filename>].flv [<filename>].avi

Copy files over SSH
scp <local file> username@host:[<filename>]


Convert LaTeX to MS-Word
First move all LaTeX files to a separate folder and issue following command.
htlatex <filename.tex> 'html,word,pic-m' 'symbol^!'
It will genereate filename.html. Open this file using MS-word, embed the pictures into file, break the links to pictures. Do touch up work and finally, save with version control on.


Compiling and debugging FORTRAN programs
gfortran -fdefault-real-8 -fdefault-integer-8 -fno-automatic -ff2c -fbounds-check -fimplicit-none -ggdb programfile.f -o programfile.o
To generate optimised code (after debugging), remove -ggdb and insert -O3.

Some useful gdb commands:
r = run the program from beginning
b <function name> |<line number> = create breakpoint
delete <n> = delete nth breakpoint, if n not given delete all breakpoints
c = continue (after breakpoint)
n = continue to next line (will not enter inside subroutines)
s = continue and step inside subroutines
p <varname> = print value of <varname>

How to join multiple avi files created by ABAQUS
mencoder -oac copy -ovc copy p1.avi p2.avi ... -o big.avi [-forceidx]


How to split and merge large files

Use the split command to do this:

split --bytes=1024m bigfile.iso small_file_

That command will split bigfile.iso into files that are 1024 MB in size (1GB) and name the various parts small_file_aa, small_file_ab, etc. You can specify b for bytes, k for Kilobytes and m for Megabytes to specify sizes.

To join the files back together on Linux:

cat small_file_* > joined_file.iso

Similarly to join the split files on a Windows machine, use the copy command:

copy /b small_file_* joined_file.iso


Ref: http://linuxpoison.blogspot.com/2008/09/split-and-merge-large-files.html



How to convert avi file to animated gif file
mplayer  <inputfile.avi>  -vo gif89a  -vf scale=<x:y>  -frames <n>
note: scale= creates to image size of x:y pixels; -frames converts first n frames

How to copy files from multiple directories to a single directory
find <search path> -iname 'search pattern' -exec cp {} <dest path> \;

How to extract pages from pdf
pdftk <input file> cat n1-n2 output <output fie>
where n1-n2 is page range

Some useful opensource scientific programs
jabref = bibliography management in bibtex format
qtiplot = Create various types of graphs
geany = Programmer's editor with syntax highlighting, etc.
kile = LaTex editor
engauge = digitizer to convert graph image into (x,y) file
octave = mathematics program, similar to matlab
inkscape = illustrations in vector format

QEMU
/usr/bin/qemu-kvm -monitor stdio  -m 1024 -localtime -cdrom /dev/cdrom -hda /datastorage/virtualbox/hdd1 -hdb /datastorage/virtualbox/hdd2 -boot c -net nic,vlan=0 -net user,vlan=0,hostname=xp-qemu -name "winxp" -smb /home/raykar/qemu
USB support in qemu
Get <vendor:product> code for usb device using "lsusb" command.
In qemu session press ctrl+alt+2 to get console panel and type usb_add host:vendor:product. Press ctrl+alt+1 to return back to qemu session.

How to monitor content of a continuously updated file (such as .sta file during ABAQUS run)
tail -f <filename>

Monday, September 20, 2010

How to debug ABAQUS user subroutines using gdb

This post describes the way to debug an user subroutine (e.g. USDFLD) with ABAQUS using gdb on opensuse linux platform.

First, you have to include -ggdb switch in the compiler section of abaqus_v6.env file. This file can be copied from <abaqus install dir>/6.6-1/site/ into working directory. A sample file is attached at the end of this post.

Next submit your job with following command:
<abaqus install dir>/Commands/abaqus job=<jobname> user=<user subrotine file>

Get the process id of this job with following command:
ps -A | grep standard

Now start gdb attached to above process as follows:
gdb -p <PID>

The gdb will start and pause the job wherever it is at the time of starting gdb session. Define your break points with "b" command and resume job execution with "c" command.

That's all!

Sample abaqus_v6.env file on opensuse linux:

#
#        System-Wide ABAQUS Environment File
#       -------------------------------------
pre_memory = "3000 mb"
standard_memory = "3000 mb"
standard_parallel = ALL
mp_mode = MPI
mp_file_system = (DETECT,DETECT)
mp_environment_export = ('ABA_CM_BUFFERING',
                         'ABA_DDM_DEBUG',
                         'ABA_ELP_SURFACE_SPLIT',
                         'ABA_ELP_SUSPEND',
                         'ABA_MEMORY_MODE',
                         'ABA_MPI_MESSAGE_TRACKING',
                         'ABA_MPI_VERBOSE_LEVEL',
                         'ABA_PATH',
                         'ABA_RESOURCE_MONITOR',
                         'ABA_RESOURCE_USEMALLINFO',
                         'ABAQUS_LANG',
                         'ABAQUSLM_LICENSE_FILE',
                         'ABQ_CRTMALLOC',
                         'ABQ_DATACHECK',
                         'ABQ_RECOVER',
                         'ABQ_RESTART',
                         'ABQ_SPLITFILE',
                         'ABQ_XPL_WINDOWDUMP',
                         'ABQ_XPL_PARTITIONSIZE',
                         'ABQLMHANGLIMIT',
                         'ABQLMQUEUE',
                         'ABQLMUSER',
             'CCI_INITIAL_EXCHANGE',
                         'ABAQUS_CCI_DEBUG',
             'CCI_RENDEZVOUS',
                         'DOMAIN',
                         'DOMAIN_CPUS',
                         'FLEXLM_DIAGNOSTICS',
                         'FOR0006',
                         'FOR0064',
                         'LD_PRELOAD',
                         'MP_NUMBER_OF_THREADS',
                         'MPC_GANG',
                         'MPI_PROPAGATE_TSTP',
                         'MPI_SOCKBUFSIZE',
                         'MPI_WORKDIR',
                         'NCPUS',
                         'OMP_DYNAMIC',
                         'OMP_NUM_THREADS',
                         'PAIDUP',
                         'PARALLEL_METHOD',
                         'RAIDEV_NDREG_LAZYMEM')

#
# Linux (Opteron/EM64T) Settings:
#
# Compile and Link command for user subroutines.
# Compile_cpp and link_exe for ABAQUS/Make.
#
import os, uti, re, driverUtils, glob

fortDefPath = "/"
ccDefPath = "/"
fortCompiler = "gfortran"
cppCompiler = "gcc"

if os.path.exists(os.path.join(fortDefPath, fortCompiler)):
    fortCmd = os.path.join(fortDefPath, fortCompiler)
else:
    fortCmd = fortCompiler

if os.path.exists(os.path.join(ccDefPath, cppCompiler)):
    cppCmd = os.path.join(ccDefPath, cppCompiler)
else:
    cppCmd = cppCompiler

os.environ['ABA_GNU'] = 'on'
if os.environ.has_key('ABA_GNU'):
    import string, os, uti
    plat = string.upper(uti.getPlatform())
    if uti.getVersion()[:3] == '6.5':
        libPath = os.path.join(os.environ['ABA_HOME'], 'cae', 'External ')
    else:
        libPath = os.path.join(os.environ['ABA_HOME'], 'External ')
    
    if plat == 'LINUX':
            plat = 'LINUX32'
#    print "libPath= ",libPath,"plat= (new)",plat
    
    compile_cpp = ('g++ -c -DABQ_LINUX -DABQ_%s -DABQ_IO_STANDARDS ' %(plat) +
                           '-DABQ_USE_STANDARD_HEADER -DFOR_TRAIL -DHAS_BOOL ' +
                           '-DASSERT_ENABLED -D_BSD_TYPES -D_BSD_SOURCE -D_GNU_SOURCE ' +
                           '-D_POSIX_SOURCE -D_XOPEN_SOURCE_EXTENDED -D_XOPEN_SOURCE -DHAVE_OPENGL ' +
                           '-D_POSIX_SOURCE -D_XOPEN_SOURCE_EXTENDED -D_XOPEN_SOURCE -DHAVE_OPENGL ' +
                           '-DHKS_OPEN_GL -DTYPENAME=typename -DGL_GLEXT_PROTOTYPES ' +
                           '-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -w -O0 -I%I')
                           
    compile_fortran = ( "gfortran -c -O -fPIC -fno-second-underscore -I%I -ggdb" )
    
#    link_sl = ( 'gfortran -Wl,-warn-once -Wl,-export-dynamic -shared %E -Wl,-soname,%U -o ' +
#                        '%U %F %A %B -Wl,-Bdynamic -L' + libPath +
#                        '-lifport -lifcoremt -lgcc -lg2c -lm -lc' )
#
#    link_exe = ('gfortran -o %J %F %M %L %B %O -L' + libPath +
#                '-lifport -lifcoremt -lgcc -lg2c -lm -lc' )

    link_sl = ( 'gfortran -Wl,-warn-once -Wl,-export-dynamic -shared %E -Wl,-soname,%U -o ' +
                        '%U %F %A %B -Wl,-Bdynamic -L' + libPath +
                        '-lifport -lifcoremt -lgcc -lgfortran -lm -lc' )

    link_exe = ('gfortran -o %J %F %M %L %B %O -L' + libPath +
                '-lifport -lifcoremt -lgcc -lgfortran -lm -lc' )

    del plat, libPath

mp_rsh_command = 'rsh -n -l %U %H %C'

# Remove the temporary names from the namespace
del cppCmd
del fortCmd
del ccDefPath
del cppCompiler
del fortDefPath
del fortCompiler

import driverUtils, os
graphicsEnv = driverUtils.locateFile(os.environ['ABA_PATH'],'site','graphicsConfig','env')
if graphicsEnv:
    execfile(graphicsEnv)
else:
    raise 'Cannot find the graphics configuration environment file (graphicsConfig.env)'

del driverUtils, os, graphicsEnv
abaquslm_license_file="27000@nilesh-laptop"

doc_root="http://nilesh-laptop:2080/v6.6"

Sunday, September 19, 2010

Beginning of a blog

Modelling of Environmentally Assisted Cracking (EAC) is the title of my doctoral work. I am working on this topic for more than a year now and I have started to understand the subject a little bit. Well, through this blog I intend to share my learning. As I imagine, this blog will have articles related to EAC, fracture mechanics, simulation, and tips-n-tricks using FEM softtware (ABAQUS).

cheers,

Nilesh