22
3 Basics of Geophysical Fluid Dynamics
3.5.3 The First SciLab Script
The following SciLab script displays the traditional message “Hello World” on the
display.
// My firs SciLab script
printf(“Hello world”);
The text editor within SciLab can be used to write this script, but make sure
that fil has the extension “.sce”. Once opened in SciLab, the script is executed by
clicking on “Execute” of the top menu of the editor window. Alternatively, SciLab
scripts can be run by entering “exec(‘c:\Folder\filename.sce’) in the SciLab command window with reference to name and location of your script.
3.5.4 A Quick-Start to SciLab
SciLab programming commands are similar to those in FORTRAN, but there are
some differences that are outlined in the following. In contrast to FORTRAN,
SciLab programming is case sensitive. This implies that internal functions have to be
called in lower case. FORTRAN “PROGRAM” and “END PROGRAM” statements
are not needed in SciLab, and “ENDDO” and “ENDIF” statements are just called
“end” statements in SciLab. Repetitive loops are called “for” loops in SciLab and
an example is:
for i = 1:30; a(i) = i; end; // a simple “for” loop
Text after two forward slashes (//) are treated as comments. Values are allocated
to arrays in two different ways. The following statement, for instance, define a
one-dimensional array with 30 elements each of a value of 10.0:
b(1:30) = 10.0;
Another option is the statement:
c = (0:1:30);
which produces a row vector of 31 elements with values c(0) = 0, c(1) = 1, . . .,
c(30) = 30. A column vector can be produced by adding an apostrophe; that is,
c = (0:1:30)’;
Without use of a semicolon, the result will be displayed in the SciLab command
window. If statements in SciLab are written as:
if g > 0; f = sqrt(g); end;
3 Basics of Geophysical Fluid Dynamics
3.5.3 The First SciLab Script
The following SciLab script displays the traditional message “Hello World” on the
display.
// My firs SciLab script
printf(“Hello world”);
The text editor within SciLab can be used to write this script, but make sure
that fil has the extension “.sce”. Once opened in SciLab, the script is executed by
clicking on “Execute” of the top menu of the editor window. Alternatively, SciLab
scripts can be run by entering “exec(‘c:\Folder\filename.sce’) in the SciLab command window with reference to name and location of your script.
3.5.4 A Quick-Start to SciLab
SciLab programming commands are similar to those in FORTRAN, but there are
some differences that are outlined in the following. In contrast to FORTRAN,
SciLab programming is case sensitive. This implies that internal functions have to be
called in lower case. FORTRAN “PROGRAM” and “END PROGRAM” statements
are not needed in SciLab, and “ENDDO” and “ENDIF” statements are just called
“end” statements in SciLab. Repetitive loops are called “for” loops in SciLab and
an example is:
for i = 1:30; a(i) = i; end; // a simple “for” loop
Text after two forward slashes (//) are treated as comments. Values are allocated
to arrays in two different ways. The following statement, for instance, define a
one-dimensional array with 30 elements each of a value of 10.0:
b(1:30) = 10.0;
Another option is the statement:
c = (0:1:30);
which produces a row vector of 31 elements with values c(0) = 0, c(1) = 1, . . .,
c(30) = 30. A column vector can be produced by adding an apostrophe; that is,
c = (0:1:30)’;
Without use of a semicolon, the result will be displayed in the SciLab command
window. If statements in SciLab are written as:
if g > 0; f = sqrt(g); end;
