F is a
modular
Broadly speaking, modularity is the degree to which a system's components may be separated and recombined, often with the benefit of flexibility and variety in use. The concept of modularity is used primarily to reduce complexity by breaking a s ...
, compiled, numeric programming language, designed for
scientific programming and scientific computation.
F was developed as a modern
Fortran, thus making it a subset of
Fortran 95.
It combines both numerical and
data abstraction
In software engineering and computer science, abstraction is:
* The process of removing or generalizing physical, spatial, or temporal details or attributes in the study of objects or systems to focus attention on details of greater importance ...
features from these languages. F is also backwards compatible with
Fortran 77, allowing calls to
Fortran 77 programs. F was first included in the
g95 compiler.
Overview
F is designed to be a minimal subset of Fortran, with only about one hundred intrinsic procedures.
Language keywords and intrinsic function names are reserved keywords in F and no other names may take this exact form. F contains the same character set used in
Fortran 90/
95 with a limit of 132 characters. Reserved words are always written in lowercase. Any uppercase letter may appear in a character constant. Variable names do not have restriction and can include upper and lowercase characters.
Operators
F supports many of the standard operators used in Fortran. The operators supported by F are:
* Arithmetic operators:
+
,
-
,
*
,
/
,
**
* Relational operators:
<
,
<=
,
,
/=
,
>
,
>=
* Logical operators:
.not.
,
.and.
,
.or.
,
.eqv.
,
.neqv.
* character concatenation:
//
The assignment operator is denoted by the equal sign
=
. In addition, pointer assignment is denoted by
=>
. Comments are denoted by the
!
symbol:
variable = expression ! assignment
pointer => target ! pointer assignment
Data types
Similar to
Fortran, the type specification is made up of a type, a list of attributes for the declared variables, and the variable list.
F provides all the same types as Fortran as well, with the sole exception of
doubles
Men's doubles, Women's doubles or Mixed doubles are sports having two players per side, including;
* Beach volleyball
* Doubles badminton
* Doubles curling
* Footvolley
* Doubles pickleball
* Doubles squash
* Doubles table tennis
* Doubles te ...
:
! type attribute list:: entity declaration list
real :: x, y ! declaring variables of type real x,y without an attribute list
integer (kind = long), dimension (100) :: x ! declaring variable of type big integer array with the identifier x
character (len = 100) :: student_name ! declaring a character type variable with len 100
F does not have intrinsic support for
object-oriented programming
Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which can contain data and code. The data is in the form of fields (often known as attributes or ''properties''), and the code is in the form of ...
, but it does allow for
records
A record, recording or records may refer to:
An item or collection of data Computing
* Record (computer science), a data structure
** Record, or row (database), a set of fields in a database related to one entity
** Boot sector or boot record, r ...
:
type, public :: City
character (len = 100) :: name
character (len = 50) :: state
end type City
Variable declarations are followed by an attribute list. The attributes allowed are
parameter
,
public
,
private
,
allocatable
,
dimension
,
intent
,
optional
,
pointer
,
save
and
target
. The attribute list is followed by
::
, which is part of the syntax. F also allows for optional initialization in the list of objects. All items in a list will have the same attributes in a given type declaration statement. In addition, declarations are attribute oriented instead of entity oriented.
Statement and control flow
F supports 3 statements for
control flow
In computer science, control flow (or flow of control) is the order in which individual statements, instructions or function calls of an imperative program are executed or evaluated. The emphasis on explicit control flow distinguishes an '' ...
:
if
, a basic
conditional
Conditional (if then) may refer to:
*Causal conditional, if X then Y, where X is a cause of Y
*Conditional probability, the probability of an event A given that another event B has occurred
*Conditional proof, in logic: a proof that asserts a co ...
,
case
, a
switch statement
In computer programming languages, a switch statement is a type of selection control mechanism used to allow the value of a variable or expression to change the control flow of program execution via search and map.
Switch statements function s ...
, and
do
, a conditional
while loop
In most computer programming languages, a while loop is a control flow statement that allows code to be executed repeatedly based on a given Boolean condition. The ''while'' loop can be thought of as a repeating if statement.
Overview
The ' ...
. The
return
,
stop
,
cycle
, and
exit
statements from Fortran may be used to break control flow.
real :: x
do i = 100
x += i
print i
cycle
end do
max : do
if (x > y) then
exit max:
end if
x = y;
end max
stop
if (x < y) then
x = x + y;
else if ( x > y) then
x = y - x;
end if
select case (maximum):
case (0)
x = 0
case (1)
x = 1
case (5)
x = 5
case default
x = 10
end select
F places a heavy emphasis on
modular programming
Modular programming is a software design technique that emphasizes separating the functionality of a Computer program, program into independent, interchangeable modules, such that each contains everything necessary to execute only one aspect of th ...
. Modules in F are called "programs":
program main
! Insert code here
end program main
Placing procedures outside of a module is prohibited. F supports most of the modules and subroutines found in the Fortran 95 standard library. All procedures in F are external by default, and require a result clause that returns the value of a function.
F supports
recursion
Recursion (adjective: ''recursive'') occurs when a thing is defined in terms of itself or of its type. Recursion is used in a variety of disciplines ranging from linguistics to logic. The most common application of recursion is in mathematic ...
.
All of the intrinsic procedures found in Fortran 95 may be used in F, with the exceptions of
achar
,
iachar
,
lge
,
lgt
,
lle
,
llt
,
transfer
,
dble
,
dim
,
dprod
, and
mod
.
References
External links
F Programming Language Homepage
g95 compiler
{{Authority control
Fortran programming language family
Programming languages