Title here
Summary here
Our first program will demonstrate various value types including strings, integers, floats, and booleans. Here’s the full source code:
program values
implicit none
! Strings, which can be concatenated using //
print *, "co" // "array"
! Integers and floats
print *, "1+1 =", 1 + 1
print *, "7.0/3.0 =", 7.0 / 3.0
! Booleans, with logical operators as you'd expect
print *, .true. .and. .false.
print *, .true. .or. .false.
print *, .not. .true.
end program values
To run the program, save the code in a file named values.f90
and use your Fortran compiler. For example, if you’re using gfortran:
$ gfortran values.f90 -o values
$ ./values
coarray
1+1 = 2
7.0/3.0 = 2.3333333333333335
F
T
F
In this example:
//
operator..and.
, .or.
, and .not.
instead of symbols..true.
and .false.
for boolean values.print *
statement is used for output, similar to fmt.Println
in the original example.Note that Fortran is case-insensitive, so TRUE
and true
would be equivalent. Also, Fortran has no built-in boolean type, instead using logical type which can be .true.
or .false.
.
This example demonstrates basic value types and operations in Fortran, providing a foundation for more complex programs.