An Introduction to Java
for FORTRAN 90 Programmers |
Prof. David Bernstein
|
Computer Science Department |
bernstdh@jmu.edu |
&
character
!
is a comment
(i.e., is ignored)
;
//
is a comment
as is everything betweem a /*
and */
{
and a }
POINTER
s and TARGET
s
Type |
INTEGER
|
REAL
|
CHARACTER
|
LOGICAL
|
Type | Memory | Range |
byte
|
1 byte | -128 to 127 |
short
|
2 bytes | -32,768 to 32,767 |
int
|
4 bytes | -2,147,483,648 to 2,147,483,647 |
float
|
4 bytes | |
double
|
8 bytes | |
char
|
2 bytes | Unicode |
boolean
|
1 bit | true or false |
REAL :: temperature, pressure
INTEGER :: month=1, year=2007
i,j,k,l,m,n
are implicitly integers)
double temperature, pressure;
int month=1, year=2007;
PARAMETER
attribute
REAL, PARAMETER :: pi=3.1415926
final
qualifier
final double pi=3.1415926;
+
)-
)*
)/
)**
)+
)-
)*
)/
)/
)%
)++
)--
)**
* /
+ -
++ --
* / %
+ -
.TRUE.
and .FALSE.
.NOT.
.AND.
, .OR.
, .EQV.
, .NEQV.
true
and false
!
&&
, ||
, ==
, !=
<
, <=
, >
, >=
, ==
, //=
<
, <=
, >
, >=
, ==
, !=
CHARACTER
type
CHARACTER :: gender='F'
char
type
char gender='F';
CHARACTER
type with
an additional len
CHARACTER(len=10) :: title='Prof.'
String
type
String title="Prof.";
////
operator
title(1:2)
returns 'P'
)
LEN(string)
, INDEX(substring, string)
and TRIM(string)
(e.g., LEN(title)
returns 10)
+
operator
title.substring(0,1);
returns "P"
)
length()
, indexOf(substring)
and trim()
(e.g., title.length()
returns 5)
(//
and //)
and are delimited by ,
(//1,5,9//)
{
and }
and are delimited by ,
{1,5,9}
INTEGER, DIMENSION(6) :: a
INTEGER, DIMENSION(4,2) :: b
REAL :: c(4:9)
int[] a;
a = new int[6];
int[][] b;
b = new int[4][2];
a(5)
b(1,1)
a[5]
b[1][1]
%
operator
.
operator
CYCLE
can be used to begin another iteration and
EXIT
can be used to "break out"
exit
can be used to "break out"
for
loop can be used like a DO
loop but can be used in many other ways as well
void
)
READ
and WRITE
statements
FORMAT
statement
(and edit descriptors including
I,F,E,ES,EN,D,G,L,A,H,T,TL,TR,X,P,BN,BZ,SP,SS,S,/,:,'
)