Monday, June 30, 2008

Full Screen Figures in Matlab

Matlab's native figure command does not give you an option to make your figure full screen in 1 step. Instead first you have to find the screen resolution and then give your figure command the size of the screen.

First thing you want to do is:

screen_size = get(0, 'ScreenSize');

This will return a 4 element array: (left, bottom, width, height);
The ones we are interested are the "width" and "height".

Now we have the size of the screen, we can make our figure full screen:

f1 = figure(1);
set(f1, 'Position', [0 0 screen_size(3) screen_size(4) ] );

Now you should have a figure that is full screen.

Saturday, June 14, 2008

Changing the SMTP port number in Evolution

I started using evolution email client in Ubuntu. However, my service provider requires me to use a different port for SMTP. When you first check the tab where you set the options for SMTP, you can not find a field about the port number of SMTP. I was looking for a field because Thunderbird has a field for port.
The solution is this :

smtp.hostname.com --> Assumes you are using port 25.

smtp.hostname.com:587 --> You set the SMTP port to 587.

I think this is not a good way to handle ports, but I am happy since I found a soluton.

Wednesday, June 04, 2008

A simple problem with LLNL's VisIt

Recently I found the LLNL's visualization software called VisIt. It has many capabilities and the graphics looked promising from their screenshots. So I wanted to give it a try. However, I had a problem and found the solution with a trial and error way. Since VisIt is developed to be working on distributed systems and parallel systems, it is always using sockets to connect to its server part even you are using them on the same computer.

So when you call the main program with gui,

>visit.exe

It will generate the following commands

Running: "C:\Program Files\LLNL\VisIt 1.9.0\gui"
Running: "C:\Program Files\LLNL\VisIt 1.9.0\viewer" -geometry 1272x1020+408+0 -borders 22,4,4,4 -shift 4,22 -p
reshift 4,22 -defer -host your.hostname -port 5600
Running: "C:\Program Files\LLNL\VisIt 1.9.0\mdserver" -host your.hostname -port 5602

So if you are running it the first time, Windows will ask you to open the ports given above to be unblocked. I unblocked them.

Then suddenly at 32%, mdserver crashed.

After several forum messages and trials, I was still getting the same error.

Later, I installed VisIt to my home computer also and it worked without a problem. Therefore, I started looking for the differences between my two computers. The first and the most obvious difference was with the network connections. At my home computer I had VMWare installed. When you install VMWare, it creates several different network connections, which were enabled by default. Even though they are not real connections, VisIt still handled them according to their IP adresses.

Finally, I disabled all my network connections created by VMWare. Give one more try to VisIt and it started working.

I think the fix will be considered with the next release of VisIt.

Export figures in Matlab without displaying them

Assuming you have a lot of figures to plot, but you do not want to wait and see them in Matlab's figure window. There is a way you can export all of your figures without displaying them. This might also save you some time, since you are drawing them on the screen.

Here is how :

% Create a figure with visibility off
f = figure('Visible','off');
% Then do your plot
plot
% Finally export the plot as an image
print('-dpng', 'test.png');

You can also make this in a loop (Which is very probable if you have too many figures).
Do this

for i:1, n
f = figure('Visible','off');
plot
filename = sprintf('plot-%d',i);
print('-dpng', filename);
end

This will give you 'n' png images with your plots in it.

Tuesday, February 19, 2008

Timing background jobs to a file

If you are running a lengthy simulation or a compilation, sometimes you might have to close/logout of your terminal. However, if you just use the "time" command with out redirecting it is output to a file, you will not see the output of time command. For example you run a job and left terminal like following:

$>time ./my_job > my_job_output &

This will run "my_job" in the background and send its output to "my_job_output". If you do leave your terminal open, you will see your run time information on the terminal screen. However, if you close your terminal window, you will not see this information since your strerr is now not available.
For this purpose, you can send your program output and time output to different files. Then, even if you close your terminal, you will still see your time command output:

$> (time ./my_job >my_job_output) >& time.out &

This way you will run your job in the background, see your time command output and you can close your terminal.

Thursday, January 31, 2008

Convert ADCIRC grid to Tecplot data file

I created this utility to convert ADCIRC compatible grids in to Tecplot files. The program is written in Perl. I also added comments. If you need it, enjoy :). If you want to see the code it self you can look at this file.

Saturday, January 26, 2008

How to install LAMP on Ubuntu Gutsy Gibbon (Desktop Version)

If you are using Ubuntu Gutsy Gibbon (7.10) Desktop edition and you want to install the "LAMP" (actually you want to install AMP part :)). Just do the following:

Never forget this before installing something.

$>sudo apt-get update

and

$>sudo apt-get install apache2 libapache2-mod-php5 libapache2-mod-auth-mysql mysql-server php5 php5-mysql

You will be asked to type the mysql password for the "root" user. Pick something you would not forget :).

Viola, you should be able to access your setup in no time...