Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Современный Фортран_учебник

.pdf
Скачиваний:
31
Добавлен:
23.03.2015
Размер:
1.61 Mб
Скачать

СОВРЕМЕННЫЙ ФОРТАН

 

 

 

3

 

 

4

 

 

1.

IDE Studio......................................................

5

 

1.1. DevStudio, FPS 4.0....................................

6

 

1.2. Visual Studio..............................................

7

 

1.3. Plato IDE Studio ........................................

9

2.

.............................................................................

10

 

2.1. ...............................................................

10

 

2.2. If Do .................................................................

20

 

2.3. - . 30

 

2.4.

...................................

40

 

2.5.

......................................

48

 

2.6.

! ..................................

57

 

2.7. " # #...............................................

71

3.

$ .....................................

75

 

3.1. % .......................................................

75

 

3.2. , ..........................................

76

 

3.3. & ...................................................................

81

 

3.4. If Do ................................................................

82

 

3.5. ' ! where forall ....................................

87

4.

.......................................................................

95

 

4.1. ............................................................................

95

 

4.2. ( #.......................................................................

97

 

4.3. write format............................

97

5.

" ...................................................................................................

 

 

99

 

5.1. ) .................................................................

99

 

5.2. * !+ ................................

101

 

5.3. # / ......

102

6.

', # .........................

103

 

6.1. ( # ............................................

104

 

6.2. % ,# .................................................

106

 

6.3. ! .................................

107

 

6.4. & .............................................................

109

7.

..........................................................

112

 

7.1. - .........................................................................

113

 

7.2. ........................................................

113

8.

........................................................................

119

 

8.1. ' Agrapher ...................................

120

 

8.2. % # # ...................

122

 

8.3. % ................

123

 

8.4. ' + # , .....

128

9.

 

.............................................................................................

 

129

4

“ ” –

. . , ? & ,

. . / , . ?

-. , 66, 77, 90, 95, 03, 08;

-. , ;

-! + ,

, - + -77;

-. , ! ,

MS Fortran, Intel Fortran Compiler, GNU-Fortran, Plato IDE;

-. , ;

-. , # ;

-. , ! ! ! -

! , , Intel Fortran Compiler;

-. , ! , ,

# !+ !+;

-, . -95.

% !+ + : !

, ! , ! ,

! , !, !, !, ! -

! !. ,

, Fortran - . . 0

Formula Translator – .

– . . 0 -

. 1 - ,

- , . 0-

, , !+, - . - *. «!», -

! !, # ! # -

+:

-1954, – , ( 2., IBM;

-66, – ! ! !;

-77, , +;

- 90/ 95, # :

-, , , ,

! , , ;

-! , # #;

-03, 08 – 3- , coarrays.

xx – # , . -

, !, +*, *, ! ,:

-58 , # ;

-! # ;

--

# # * ;

5

-,

, - , *;

-(IMSL, NAG, LAPACK, BLAS, Intel MKL), ! (MPI, PVM), -

(Quickwin, FORTRAN/TK);

-: 95, 03

. Intel Fortran Compiler, ifc-9, ifc-10, ifc-11, ifc-12 -

# !+ !+,

Linux; Plato Silverfrost Ltd. Studio; 9095 – Fortran Power Station 4.0 5, 6 Compaq; GNU Fortran.

&:

-www.fortran.com,

-www.npac.syr.edu ,

-netlib.org – ,

-www.j3 – fortran.org – ,

-– twcad.ifmo.ru,

-parallel.ru/tech/tech_dev/newfortran.html,

-free compilers –www.thefreecountry.com/compilers/fortran.shtml.

' , , , .

1. IDE Studio

Integrated Developer Studio (IDE) – . -

. & . ! , -

# # #. & + # -

+ # , * ,

*.for,

- *.f90 *.f03.

' , # ,# - +* .

MS Developer Studio, 1996 – ( 110 ") -

Fortran, C++. 4 5

110 " – . * 3, Developer Studio,

Fortran, ,# *. 0: , Debug

! Windows-XP. #, # & #-

! Debug, ! Release. -

! . MS Developer

! # : DEC, HP.

MS Visual Studio, 2010 – . & Debug Windows-7 Vista. - + Visual Studio (400 ") , , C++ C#,

Intel. Intel Fortran Compiler # ifc- 9, ifc-10, ifc-11, ifc-12 ( 500 ".). ifc-9, ifc-10, ifc-11, ifc-12 -

+ ! ! -

. 1 ! Windows, Linux.

6

Plato Silverfrost Ltd. Studio, 2011 – . .

' Fortran, C++. & Debug Windows- 7. . / -

! ! ! # ,

# #.

GNU Fortran – . Fortran. 1 !

Windows, Linux.

( * ! #

, , d:/PROJ, . ! !

# .

1.1. DevStudio, FPS 4.0

/ (110 ") MS Developer Studio (DevStudio) ! Fortran Power Station (FPS 4.0)

C ++.

DevStudio , ,

*, , ! Windows-XP. -

Release Windows-Vista, Windows-7. Debug|Release + :

-Release – ( <Ctrl>+<F5>);

-Debug – ( <F5>);

-+ ! Release, +

Debug ! Windows-XP.

, #

! ! . d:/PROJ/myProj

File|New|Project WorkSpace|Console Application:

-# myProj;

-<Browse> *

myProj d:/PROJ;

-<Create> – ! , #

<Save all>;

-! # ! + - +, ! , * #-

.

+ d:/PROJ/myProj:

1.+ ! + lab.f90 +

Insert | File into project ==> ! ! d:/PROJ/myProj;

2.! Lab.f90 DevStudio, + , :

-! + File|New|Text;

-! ;

-File|Save as ==> ! Lab1.f90;

-* ! Compile -

, «+ ! -

?» - ! ! .

7

' # ,

! . c . 4 + ! +*

*.txt:

-# !, + Insert | File into project ==> ! myProj/in.txt, -

+ *

, open;

-! , open.

% ! .

FPS40 – # MS Developer Studio.

(+

Windows):

-. ;

-<Ctrl>+<F5>, + Build|execute Lab1.exe -

.

( Windows-XP):

-* <F5>, FPS40 , -

;

-, <F5>, « » ( -

+* ! «go»).

( ! ( Windows-XP):

-<F8> – ,

-<F10> – <F8>, «!» ,

-<F7> – , ,

-<F7> , <F8>, <F10> «#» ,

-+ – , .

1.2. Visual Studio

0 MS Visual Studio (600 "-1000

") ! Fortran, C ++ C#. $ MS Visual Studio,

C++, C# + Intel Fortran compiler (500 ").

Visual Studio , ,

*, . :

- File|New|New Project|Intel Visual Fortran|Console Application;

-Name;

-<Browse> Location * -

myProj;

-<Ok> – ! .

+

:

1.+ ! + lab.f90 +

Source|File project ==> ! lab.f90;

2.! lab.f90 Visual Studio + ! .

8

lab.f90 Visual Studio:

-! + Source|New|Text;

-! ;

-! lab1.f90 ! *-

myProj;

-* , ! +

Compile .

4 + ! +* :

-# , !,

+ Insert|File into project, myProj/in.txt

!, ,

open;

-! , open.

, , , !

txt, + . % ! .

- . MS Visual Studio. -

! # ! + +,

! , * #

.

' # ! .

– + ! Debug|Release:

-Debug – ( <F5>) ;

-Release – ( <Ctrl>+<F5>).

:

-* “

– ,

;

-, “ ”, <F5> . ( ! :

-Start Debug – ! ( <F5>) ;

- <F10> – , «#» ;

-<F11> – <F10>, «!» ;

-Run to Cursor – , -

;

-<F10> , Run to Cursor, <F11>, <F5> «#» ;

-+ – , ;

& (Debug) Windows-Vista

Windows-7.

( ! :

-<Ctrl>+<F5>;

-+ Build|execute lab1.exe .

9

1.3.Plato IDE Studio

Plato IDE Studio Fortran. -

Plato IDE , , *-

, . :

d:/PROJ # ;

d:/PROJ myProj ;

! ! .

myProj File|New Project|Fortran Application:

Name;

<Browse> Location *

myProj d:/PROJ <Open>, !

.

+ :

1)! Lab.f90 Plato IDE Studio

+ ! ;

2)+ ! + labac.f90

+ Source Files | Add existing item ==> ! labac.f90.

Lab.f90

Project Explorer Source Files | New Item:

Name;

<Browse> Location *

lab.f90 d:/PROJ/myProj Open, -

! ;

! ;

* ! – Compile !

+.

4 + ! +* :

− # + Source Files|Add existing item

==> ! myProject/in.txt, -

! *

, open;

− ! – , open.

, , , ! txt,

+ . % -

! .

– Plato IDE. - !

# ! + +, ! , *

# . ' #

! .

– + ! Debug|Release:

Debug – , <F7>;

Release – , <Ctrl>+<F5>.

10

:

-Step Info, ,

* <F7>, ,

, ! ;

-Start run, , <Ctrl>+<F5>, ! -

, ;

( ! :

-<F6> – Continue, ! ;

-<F7> – Step Info, ,

-<F8> – Step Over, , « » ,

-<Ctrl>+<F10> – Goto Cursor, , -

,

-<F7> , <F8>, <Ctrl>+<F10> «#» ,

-(Debug) WindowsVista Windows-7.

2.

 

2.1.

 

 

 

! , :

 

1.

# . # #

 

 

y1 y2 z1 z2, !

 

 

# # #.

 

2.

out.txt # ! .

:

a).,

# # # # ;

b)! , -

+* 6-7 !+ real;

c)# ! ! ,

#, # # , sec x;

d)! * !, !

! ( ) .

1.0 ! .

2., , .

3.% , ,

! .

4.& # (&(5) # y1, y2.

5." # # (

! + ).

11

6.!

# # #.

' * ! ! .

1.' #

( ) %.1.

% 1. ' #

 

 

 

 

 

 

 

 

1

 

 

 

 

!

**

 

2

 

 

 

 

4,

*,

/

3

 

 

 

 

,

+,

4

 

 

 

 

: + ( ).

2.# #

%. 2; - Sqrt(x)

# .

% 2.

# #

-

sin

 

Sin(x)

 

 

 

 

cos

 

Cos(x)

 

 

 

 

 

 

 

sec

 

1/Сos(х)

 

 

 

 

 

b

 

Abs(b)

 

 

 

 

 

 

 

-

 

 

 

 

 

Tg

Tan(x)

 

 

Ctg

Cotan(x)

 

 

arcsin x

Аsin(x)

 

 

π2*Аsin(1.)

 

 

 

-

 

 

 

 

2

Sqrt(2.)

 

 

>0 Sqrt(x)

 

x

<0

 

 

Sqrt(cmplx(x))

 

 

>0

 

 

x**(1./n)

n

x

<0 n .

-(-x)**(1./n)

 

 

<0 n

 

 

cmplx(x)**(1./n)

3.% ! ( *-

) , -

. # :