con qualche cenno di FORTRAN90/95/2003/2008
1 integer(kind=4) :: num_raggi
2 real(kind=4), parameter :: pigreco=3.14
3 real(kind=8), dimension(10) :: vettore
è equivalente a
1 integer*4 num_raggi
2 real*4 pigreco
3 parameter(pigreco=3.14)
4 real*8 vettore(10)
Perché?
1 type ruota ! definizione di tipo
2 integer(kind=4) :: num_raggi
3 character(len=15) :: materiale
4 real(kind=4) :: diametro
5 end type
6
7 type bici
8 CHARACTER(LEN=80) :: descrizione(100)
9 TYPE(ruota) :: ruotaant, ruotapost
10 real(kind=4) :: peso
11 ! attenzione devo fare una allocazione per ogni tipo(bici) che
12 ! definisco
13 REAL , ALLOCATABLE , DIMENSION(:) :: tempi
14 INTEGER , DIMENSION(100) :: codici
15 end type
16
17 type(bici) :: lamiabici ! la mia bici
18 type(bici) :: latuabici ! la tua bici
19
20 type(bici), dimension(10) :: parco_bici ! ho 10 bici
in quest'ultimo caso avrò bisogno di allocare 10 vettori tempi
1 do i=1,10
2 allocate( parcobici(i)%tempi(200) ) ! tempi sarà un vettore di
3 ! 200 posti
4 end do
stampa il numero di raggi della ruota anteriore della mia bici
1 print *, lamiabici%ruotaant%num_raggi
e da ora sarà uguale al numero di raggi della ruota posteriore della tua
1 lamiabici%ruotaant%num_raggi=latuabici%ruotapost%num_raggi
ma posso anche comprarmela uguale, la bici
1 lamiabici=latuabici
e può anche succedere che la tua bici sia uguale alla terza del mio parco bici
1 latuabici=parco_bici(3)
1 lamiabici%tempi(52:53) = (/ 123.4, 98.7 /)
2 ! il peso delle 3 bici più nuove (ovviamente size(piunuove)>=3)
3 piunuove = parcobici(7:)%peso
inizializzazione esplicita
1 type(ruota)::a
2 a=ruota(38,'alluminio',26)
3 ! fortran 2003
4 a=ruota(materiale='alluminio', diametro=24, num_raggi=34)
5 ! ne cambio 2 e la terza di default
6 a=ruota(materiale='alluminio', diametro=24)
inizializazione implicita
1 type ruota ! definizione di tipo
2 integer(kind=4) :: num_raggi=36
3 character(len=15) :: materiale='acciaio inox'
4 real(kind=4) :: diametro=28
5 end type
1 type dumpfile
2 character*(dump_filename_length) filename
3 character*50 comment
4 integer itype ! itype: 0 - ORM generated, 1 - IG2
5 integer lpoints ! number of sweeps of the scan
6 real*8 chi2 ! In case we have an ORM generated dump file
7 logical lconv ! In case we have an ORM generated dump file
8 logical lqual ! In case we have an ORM generated dump file
9 integer itgh(maxnpoints) ! Number of the l1b tgh to which the point refers
10 real*8 rzprof(maxnpoints) ! Altitude of profile
11 real*8 oc(maxnpoints) ! Orbital coordinate of profile
12 real*8 rvmrprof(maxnpoints) ! Profile value
13 real*8 rproferr(maxnpoints) ! Error of the profile
14 real*8 rpprof(maxnpoints) !Pressure of the profile
15 integer dflag(maxnpoints) ! dflag - Indicator of gradients
16 ! 0 - No gradients
17 ! 1 - Only left gradient
18 ! 2 - Only right gradient
19 ! 3 - Both left and right gradients
20 ! 4 - Gradients generated from the ORM (may be extrapolated)
21 real*8 rvmrgrad(maxnpoints,IL:IR) ! left and right gradient, -9999.9 for unassigned
22 end type dumpfile
23
24 type dump_table
25 integer*4 ndumps
26 type(dumpfile) pr(1:imxtypes)
27 end type dump_table
| Tipi derivati in FORTRAN | 1 |
|---|---|
| Brevi istruzioni per l'uso | 2 |
| I tipi derivati servono a... | 3 |
| Dichiarazioni | 4 |
| Le componenti | 5 |
| Inizializzazioni | 6 |
| La struttura dumpfile | 7 |
| Table of Contents | t |
|---|---|
| Exposé | ESC |
| Full screen slides | e |
| Presenter View | p |
| Source Files | s |
| Slide Numbers | n |
| Toggle screen blanking | b |
| Show/hide slide context | c |
| Notes | 2 |
| Help | h |