|
Presentazione linguaggio Fortran
Praticamente il primo linguaggio di programmazione.
Il
FORTRAN è stato sviluppato da un gruppo di programmatori della
IBM
guidati da John Backus e pubblicato per la prima volta nel 1957.
Il FORmula TRANslator era stato progettato per facilitare la traduzione
in codice di formule matematiche.
Spesso definito come linguaggio scientifico, il FORTRAN è stato anche il
primo linguaggio di alto livello, e quello che ha per primo utilizzato
un compilatore.
Prima di allora i programmi andavano sviluppati esclusivamente in
linguaggio di macchina o assembly code.
L'obiettivo era di creare un linguaggio semplice da imparare,
impiegabile in un ampio raggio di esigenze, che fosse indipendente dalla
macchina, e che consentisse l'esecuzione di complesse funzioni
matematiche, scritte il più possibile in modo analogo a quello usato
normalmente.
Alcuni anni dopo la sua prima comparsa si sono
sviluppati diversi "dialetti" derivanti dal FORTRAN originale.
Data la sua semplicità di scrittura i programmatori riuscivano ad essere
fino a 500 volte più veloci in FORTRAN che in altri linguaggi, dedicando
così maggiormente la loro attenzione sui problemi
reali piuttosto che sulla trascrizione nel linguaggio.
Si può quindi affermare che FORTRAN è stato anche il primo linguaggio
"problem oriented" anzichè "machine oriented".
Anche per il FORTRAN, come per altri linguaggi, sono state redatte delle
specifiche di standardizzazione ANSI, ma che di volta in volta non hanno
scongiurato il proliferare di nuove versioni non proprio compatibili tra
loro.
Le funzioni principali del Fortran
-
Simple to learn
- when FORTRAN was design one of the objectives was to write a
language that was easy to learn and understand.
-
Machine
Independent - allows for easy transportation of a program
from one machine to another.
-
More natural
ways to express mathematical functions - FORTRAN permits
even severely complex mathematical functions to be expressed
similarly to regular algebraic notation.
-
Problem
orientated language
-
Remains close to
and exploits the available hardware
-
Efficient
execution - there is only an approximate 20% decrease in
efficiency as compared to assembly/machine code.
-
Ability to
control storage allocation -programmers were able to easily
control the allocation of storage (although this is considered to be
a dangerous practice today, it was quite important some time ago due
to limited memory.
-
More freedom in
code layout - unlike assembly/machine language, code does
not need to be laid out in rigidly defined columns, (though it still
must remain within the parameters of the FORTRAN source code form).
Aree applicative Fortran
-
Number crunching
- due to the more natural (like it's true algebraic form) way of
expressing complex mathematical functions and it's quick execution
time, FORTRAN is easy and efficient at processing mathematical
equations.
-
Scientific,
mathematical, statistical, and engineering type procedures
-due to it's rapid number-crunching ability FORTRAN is a good choice
for these type of applications
Esempi di programmi in Fortran:
1)
Hello world
******Ouput for Hellow World
WRITE(6,*)'Hello world'
STOP
END
2)
outputing THE FINITE AND INFINITE SUMS
******ERRORS INDUCED BY ARITHMETIC OPERATONS ON SAMLL NUMBERS
REAL SUM6,SUM7,SUM8,DIF6,DIF7,DIF8,SUMINF
*
OPEN(6,FILE='PRN')
SUM6=.9*(1.-0.1**6)/0.9
SUM7=.9*(1.-0.1**7)/0.9
SUM8=.9*(1.-0.1**8)/0.9
******COMPUTER SUM OF INFINITE TERMS
SUMINF=0.9/(1.0-0.1)
******COMPUTE DIFFERENCES BETWEEN FINITE & INFINITE SUMS
DIF6 = SUMINF - SUM6
DIF7 = SUMINF - SUM7
DIF8 = SUMINF - SUM8
WRITE(6,*) 'INFINITE SUM = ', SUMINF
WRITE(6,*) 'SUM6 = ', SUM6, ' INFINITE SUM - SUM6 = ',
DIF6
WRITE(6,*) 'SUM7 = ', SUM7, ' INFINITE SUM - SUM7 = ',
DIF7
WRITE(6,*) 'SUM8 = ', SUM8, ' INFINITE SUM - SUM8 = ',
DIF8
STOP
END
|