Difference between revisions of "Howto"
(→... and NetCDF?) |
(→How to do Shell) |
||
Line 59: | Line 59: | ||
to find other operators you would want to use. For | to find other operators you would want to use. For | ||
more sophisticated math you would wanna use awk or Perl scripts. | more sophisticated math you would wanna use awk or Perl scripts. | ||
+ | |||
+ | === Screen === | ||
+ | Screen is a useful command for remote or batch processing. It allows you to log into and out of terminals without killing processes. You can operate many screens at once and monitor activity in each screen. Here are some commands to get you started. | ||
+ | |||
+ | <pre> | ||
+ | screen -S name | ||
+ | </pre> | ||
+ | |||
+ | This should open a screen with ''name''. It is not necessary to name your screen sessions, but it makes it easier to return to them if you know the name of the session. | ||
+ | |||
+ | <pre> | ||
+ | screen -r name | ||
+ | </pre> | ||
+ | |||
+ | Return to an existing screen. | ||
+ | |||
+ | Inside a screen there is no indication that anything has changed; it looks just like a terminal window. You can pass commands to the screen (as opposed to the command line) by using ctrl-a. Here are a couple useful commands for screen: | ||
+ | |||
+ | <pre> | ||
+ | ctrl-a d | ||
+ | </pre> | ||
+ | |||
+ | Detach from screen, leaves the process running. | ||
+ | |||
+ | <pre> | ||
+ | ctrl-a n | ||
+ | </pre> | ||
+ | |||
+ | Next screen, if you are running more than one screen at a time. | ||
+ | |||
+ | <pre> | ||
+ | ctrl-a ? | ||
+ | </pre> | ||
+ | |||
+ | Help screen, shows some useful screen commands. | ||
+ | |||
+ | <pre> | ||
+ | ctrl-a K | ||
+ | </pre> | ||
+ | |||
+ | Kill current screen. | ||
+ | |||
+ | <pre> | ||
+ | ctrl-a ctrl-\ | ||
+ | </pre> | ||
+ | |||
+ | Quit screen, this closes all screens. | ||
==How to do GMT== | ==How to do GMT== | ||
==How to do CrusDe== | ==How to do CrusDe== |
Revision as of 16:04, 25 June 2008
Contents
How to do Matlab
... batch processing?
To call Matlab from the command line or a shell script and have it execute a command or a Matlab script call:
matlab -nojvm -nosplash -r [x,y,z]=script -logfile script.log > /dev/null
This must be called in a directory that contains a file script.m
. Whatever Matlab usually dumps to its console ends up
in the file script.log
. To make sure it does not show up in your script output stdout is redirected to /dev/null
.
The [x,y,z]=
part is only necessary if your script returns results which you would want to use somehow.
IMPORTANT: make sure your script contains an 'exit;' as last command! Otherwise this Matlab instance would remain running which might end up
with really nasty performance results in a loop statement. If a bunch of matlab scripts are to be executed, compile a master .m
-file which calls them (and is the only one that contains the 'exit;'). This way Matlab is not closed and restarted for each script which might gain a significant performance gain.
... and NetCDF?
The MEXNC, SNCTOOLS and toolsUI packages are installed in /usr/local/matlab
. A tutorial describes which routines are
provided by the SNCTOOLS package: http://mexcdf.sourceforge.net/tutorial/index.html.
To make use of those, you might have to alter your path:
addpath('/usr/local/matlab/mexnc'); addpath('/usr/local/matlab/snctools'); javaaddpath ( '/usr/local/matlab/classes/toolsUI-4.0.jar' ); setpref ( 'SNCTOOLS', 'USE_JAVA', true );
How to do Shell
NOTE: Some commands might be specific for csh/tcsh. Adjustments to bash, sh etc should be straightforward.
... arithmetics?
You would want to use the command 'expr' which "evaluates basic expressions" to do basic arithmetics in the Shell. Try something like:
set X=`expr 100 + 50 '*' 3` echo $X
This should give you 250. The '`' denote that a subshell is opened in
which the command expr 100 + 50 '*' 3
is executed. The return value is
then stored in the variable X
. You can also use variables in your
expressions:
set X=`expr $X + 50 '*' 3` echo $X
This should return 400.
For the reason of '*' being interpreted als wildcard in the Shell the asterisk must be in single quotes: '*' otherwise you get a syntax error. Check
man expr
to find other operators you would want to use. For more sophisticated math you would wanna use awk or Perl scripts.
Screen
Screen is a useful command for remote or batch processing. It allows you to log into and out of terminals without killing processes. You can operate many screens at once and monitor activity in each screen. Here are some commands to get you started.
screen -S name
This should open a screen with name. It is not necessary to name your screen sessions, but it makes it easier to return to them if you know the name of the session.
screen -r name
Return to an existing screen.
Inside a screen there is no indication that anything has changed; it looks just like a terminal window. You can pass commands to the screen (as opposed to the command line) by using ctrl-a. Here are a couple useful commands for screen:
ctrl-a d
Detach from screen, leaves the process running.
ctrl-a n
Next screen, if you are running more than one screen at a time.
ctrl-a ?
Help screen, shows some useful screen commands.
ctrl-a K
Kill current screen.
ctrl-a ctrl-\
Quit screen, this closes all screens.