BISMG:SarahS/handy stuff

Checking for memory leaks using valgrind

 * Compile code using -g debugging flag
 * Run code valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes /path/to/exe
 * Extra valgrind flags that might be handy --leak-check for a detailed memory checker and --track-origins=yes to find the location of un-initialised variables
 * Watch out for these messages definitely lost, probably lost and Conditional jump or move depends on uninitialised value

Count number of files in directory
ls -l. | egrep -c '^-'

Map a symbolic link to bluepeta on aramis home space
ln -s /projects/AMR_ice_sheet_calculations/ggsrs /home/ggsrs/bluepeta

Map drive to glaciology scratch space
\\aramis.ggy.bris.ac.uk\data-glacio1

Map to g drive
\\ads.bris.ac.uk\filestore\Geography\Geog2\ggsrs

Map drive to bluepeta
\\rdsfcifs.acrc.bris.ac.uk\AMR_ice_sheet_calculations

How to map windows drive to /home/ggsrs on aramis

 * Map a network drive on windows
 * \\aramis.ggy.bris.ac.uk\homes

How to install stuff on the Ubuntu VM

 * apt-get install synaptic
 * synaptic

How to map a network drive in the Ubuntu VM (Example map to bluepeta)

 * Install this : sudo apt-get install sshfs
 * mkdir bluepeta
 * sshfs ggsrs@bluecrystalp2.bris.ac.uk:/projects/AMR_ice_sheet_calculations/ggsrs bluepeta

Find and replace string in all files in a directory but ignore .svn stuff
find. -path '*/.svn' -prune -o -type f -exec sed -i 's/old_string/new_string/g' {} +

NoHUP
nohup /path/to/.exe &> messages.log

Matlab help
If using pcolor matlab will not print .eps even though the output is called .eps. It will print an .eps that is really a bitmap. It seems to change the default renderer to bmp. To make sure a real eps is printed type print(h, '-depsc', '-painters', 'filename.eps');

Convert 3d shapefile into 2d in arcmap 10

 * Matlab can not read 3d shapefiles so convert to 2d
 * Read in shapefile (e.g. SouthWestAsia.shp)
 * ArcToolbox, conversion tools, to geodatabase, feature class to feature class
 * Input features, (select the current shapefile from the dropdown box e.g. SouthWestAsia.shp)
 * Output location =G:\JULES\Glacier Inventory\Randolf
 * Output feature class (the output file name e.g. SouthWestAsia2d.shp)
 * Environments M and Z (select output has M and Z disabled)

How to setup a Cron job

 * Use holocene as it communitates with the outside world
 * In the home directory open crontab using : crontab -e or (-l to list what is in crontab)
 * Alternatively, crontab file is located in /tmp
 * Specify the editor : export EDITOR=/usr/bin/emacs to get editor for crontab
 * Set the time to run the script by filling in the blocks. For example run send and email at 18:10 everyday
 * 18 10 * * * /home/ggsrs/automat/send_an_email.sh

Handy commands

 * find . -iname '*.xml'
 * list the number words and lines in a file wc -filename
 * killall my program
 * Search for functions with a binary nm simple_glide | grep functionname

Compress and un-compressing using tar (.tgz)

 * find all files with size > 100k and write to a list find: ./tests/*/*/*.nc -size +100 -print > test_filenames


 * Compress all files in the list: tar -cvzf mytarfile.tgz -T test_filenames


 * Un-compress files : tar xvzf mytarfile.tgz

Finding info on machine architecture

 * cat /proc/cpuinfo
 * Return the number of CPU's grep 'physical id' /proc/cpuinfo | sort | uniq | wc -l
 * Return the number of nodes cat /proc/cpuinfo | grep processor | wc -l
 * Note cpuinfo is very confusing because nodes are called processors.

Using rsync
To copy files from local drive to unix box use rcync
 * Log on to mobaxterm
 * cd /drives/ will show local drives
 * cd e:/
 * rsync --progress -azv akagc.zip ggsrs@dartagnan.ggy.bris.ac.uk:/bluepeta/ggsrs/jules_forcing/highnoon/jules_nc copies akagc.zip from drive e to bluepeta

==Install CDO on porthos.ggy.bris.ac.uk

Run configure with

./configure --prefix=/home/ggsrs/cdo --with-netcdf=/usr --with-hdf5=/usr/