.0" ...3!0" ! Œ. 1#&"..*02. 0Œ# " 2" 10. Œ Œ) 2 Œ!)! )" #Œ 0" 2! 1. Œ " )0 1 )! 12 $0& Œ #

Size: px
Start display at page:

Download ".0" ...3!0" ! Œ. 1#&"..*02. 0Œ# " 2" 10. Œ Œ) 2 Œ!)! )" #Œ 0" 2! 1. Œ " )0 1 )! 12 $0& Œ #"

Transcription

1 " Œ)" 2 # 03.. #.#2 * 0.. Œ.! # ".Œ" Œ)" 02.2" 12 FORTRAN Œ # $ # 2 /#.2)22...Œ 0* # ) # þ 2" 1*020" 02.2" Œ.0" Œ # $ # 2 /#.2)22...Œ 0* # Œ.!.Œ&.Œ). 2" 12 2 # þ 1*020" 02.2" 0. Œ * $!10" 12 0Œ00!.1. 0 # Œ #" /0/ & 1& 0* & Œ!! $+ Œ #...*1 # #2) ò$ 2." / #2) !0" 2!1) 2 #Œ..! 1/ +0. ùœ Œ! 200" /* ) #". 2 #" Œ #" $!1 Œ *0 Œ.0". )$.Œ" 02.2"...3!0" ! Œ. 1#&"..*02. 0Œ#1." 11" 0 Œ.0".!0". Œ " 2" 10. Œ Œ) 2 Œ!)! )" Œ!!.2 ". 03.0" $0. 0)" Œ... 0Œ00! $0. 0)" Œ.. /./ " $0. 0)" Œ.. Œ # $ #. 1#0! /)22.. #Œ 0" 2! 1. Œ " )0 1 )! 12 $0& Œ #. Œ * Œ. /)22. )$. #Œ 0" 2 0$ $0 0)" Œ.. / ". Œ.. 10.* #1. 3 #1. 10! " )0" 2" Œ! *00" 0Œ00!.10" 10 /* Œ0!11)20! #" Œ.0" 2.#2)$!.. 1#20" ). 2. Œ! * Œ#1 0)" Œ!..2 * Œ!.2 " 1

2 ò 0" 0/.."!1)" Œ.. û02" ñ! 1. Œ " )0 1 ")! " ü$12-12 ù* #1.-3 #1. 10!.)1 3#1./." implied do 12.2)" Œ.." /#.)" Œ.." ALLOCATE, DEALLOCATE, ALLOCATABLE ü1.&".!.2!10" #2)..1$ *0 0..Œ) 2" Œ 0/.3! #10" / " /0/ & 12 FORTRAN 2 #" Œ.0" Œ.0" 0. 1*020" / " /0/ & Œ #." / # 2 /#.2)22...Œ 0*1 #0 0 /. Œ! 3! # þ 0. 0$&!12) )... /02 Œ #. Œ! 1/! # 12 $0 # /. þ #" )2." / # 2 /#.2)22....*1 #0 2. /0/..#2 0*. 1&..#+10& loops üœ0/ 2. /0/..#2.Œ 0* $&!12" 10" 2" " 2 # þ Œ! *0. $ #0 Œ!) #2 $&!". $! /.1 #0 Œ.0" $ # 0#!*2.20" 03.! " 10 Œ!.2. 0*!01" 0.$12 #- 012 # 1 #)! # 2.)1" Œ 2 Œ!+2 0)22..!1 # # Œ.... Œ! 1Œ.1 #0...*1 #0 2 $!1)22. 2 #" 2 /0*20! 0)22...1$ * !. 2& /12.2& Œ& 1#0!....3! #0 Œ+" & 12 $0& 10. Œ.. 0Œ00!.1. 2& 12 $0& 2 # Œ & 12 $0& 0)" Œ.. 2

3 0. Œ.0". Œ *$!0 2. ü$.0 1# ".Œ" 02.2" &". 1 2" " 2 # þ Œ. $0. 1#0! ).. /$02..1#0! 2*Œ /0/ &. 0/ 2&.Œ $.0 $&! *Œ /0/ & Œ # /$ !2"..3.!2" 02.2" Œ)" 2&.Œ Œ! 1&!.Œ 0#1 Œ &.Œ 20012&! 0 #..2.0" 2.0Œ!0. 2&.Œ !1. Œ! )Œ. *10" 2 Œ.!.2& 11 : û!.12!)22..!.30 Œ!)!.. Œ 03)1 /.10.! *" x 1, x2,..., x 12 1#$0.. #Œ n µ n i= = 1 n x i. 2 2#Œ.Œ)1 S = n i= 1 ( x ) 2 i µ n 1. õœ&" /.Œ12&10".Œ) 2 0Œ#1 2" Œ.!.Œ& /!.12!)22.". Œ!Œ0 10 2& &12+ 0)/&. /.1 #0 /* 3!" 2. /0/. Œ! 0 #. *1 # Œ!+2 3!. Œ!Œ0. /. #0 2" 2" Œ #.." /+10." 02.2" Œ #...12 /$02. ) $!12" 2 # Œ!!.2 " 1&. 2. 1#0Œ+" )" #0.. *!. 2 $02. Œ. /0*20! 3!. Œ!Œ0.../.1 #0 2" 2" 1&." 02.2" 12& Œ.. #Œ 1 #0 2 2#Œ.Œ)1 Œ.!.Œ& Œ!). /0. Œ! #Œ20. Œ! *1.0..Œ 0*1 #0 )0" 2" 2" Œ #." / # " X i #0Œ+" 02 2.Œ 0#1 2& 2+ 12" 02.2". Œ! *1.0. $!1 Œ 1 #0 2" 2".#2" )10" 3!" #0 ò. 0Œ1" 1.2) Œ!). 2 Œ..Œ.2 *10 2.Œ 0# " Œ! 2 $!1 Œ 1 2 #" 0. 2.)1 0)" 1#0! # Œ #".!+ 3

4 0Œ#1 Œ! 2& )Œ&" 2. Œ.!.Œ&!$02.. *10 FORTRAN & 2& Œ&..." 0..1* Œ #.2..0 Œ.!.Œ&.Œ) # þ $0. 1#0! ).. /$02.. 1#0! 2*Œ /0/ &. ).2. 2& Œ&. # * 2 #" / #".)0" 0.#2 2&.Œ Œ.0" )Œ&"..Œ" 02.2" $&! !2 *"..3.!2 *" *Œ 2& /0/ & Œ # /$ 2.. /.$&!1)" 2 #" / 2!)Œ / 0 2" /&2" 02 " REAL, INTEGER Œ 02.2" ùœ" *020".0" ù!2" ù3.!2" ù!2" ù3.!2" $. ü/ FORTRAN. 1 2& 12 $0& Œ.. 2 Œ! 1/!& & /02+ ò21. $&..!2) Œ.. 0 ). ù Œ # #0$)00" 10" 12 2 # þ...3!. 12 Œ!+2 12 $0 2 #Œ ). ù 12 /0*20! 0 2 ). ù 4

5 +.. #Œ!0 )&" 1*$#1.Œ) 0/ ". 0&! *0 )2 2 Œ!+2 12 $0 2 #Œ ù. )$ 2 ù 2 /0*20! 2 ù. )$ 2 ù /02" 0)" Œ.. Œ! ! 02.2 Œ.!12.1 Œ #Œ.!0.!.0" 2". 3#1 /0. Œ!Œ0. 0Œ0! 2. )!. 2" /12.1" 2 # Œ.. Œ$ ù ùk), A(2*L-3). #0" ). 2 $!1 2& Œ& 0. 0" 1. þ $!1 Œ 1 2& /0/ & Œ.!.Œ&.Œ). 3! /0" û!.12!) þ.œ 0#1 2& /0/ & Œ! 2 $!1 Œ 1 2 #" ù Œ).".Œ) 2 #" Œ.!.Œ& ) #" 1#2!$0 12 Œ!). 1 # 2)20. Œ!Œ0. $!1 Œ 10" Œ.0".2 0Œ#1 2 # þ 1#" /./.1. 0Œ#1" Œ! 2& Œ # Œ0!. # Œ.0".Œ.!202..Œ) 2. Œ.!.2& 2110! !1)" Œ.. 2. ü1.& 12 $0& 12 Œ.. 3. üœ00! $0& Œ.. 0*!01 Œ #".! 1.2 ". # 12 $0& Œ #. Œ * Œ. 1# )$ 0*!01!)20! #-0.*20! # 2.)1 12 $0& 10.* #1. 3 #1. 10!. 4. ü31.œ 20012&. 12 $0& 2 #Œ # Œ 1 2& Œ.!.Œ& 2&..1$ *0 12 1#$0. 12" /.3!02".2!0" Œ& /12.2 -Œ.0" /* /.1210& Œ 2.2. û#. Œ.0" Œ.0" 0 $&! /* 00".2!0" 2 #" 12.2 *" Œ.0". 2 #" /#. *" Œ.0" þ.1 /.3! 2 #" !)Œ /.$0!1" 2" " 2 # þ þ /12.1 2&

6 Œ&! !$ 2 # Œ!!.2 " #0! Œ 1) ". ) 2 /!0. 2 # Œ!!.2 " ù#2) $0 &".Œ /10#1 0 #! #" 2" " 2 # þ 2 #" /#. *" Œ.0" 0+ Œ.." / !$ 2 # Œ!!.2 " / #! /! " 2 # Œ!!.2 " Œ) #0! " " 2 # þ 2 1#$0.. /0 $!002. Œ..".#2)" Œ! * !1 #0.Œ /010* 2." 2 1#0! 2 2" " 2 # þ. 0" 02 #!0".0" 2.2 û#. û!.. û.$&!1)" 2& Œ& 7.3 /12.2 Œ.0" 2 0)22..#2..1$ * !. 2& /12.2& Œ& &12+.Œ) &" /.*1.2. 1#0! " 2 0)22..# #Œ! $0.. Œ... 0Œ00! $0..# #$ Œ " 11". ) 2 Œ.. +"! #0. Œ..!. $!1 Œ 1 #0. Œ Œ!)!... Œ!Œ0. 2!1 #0.!.2&..3! #0 2 #" /* 2!)Œ #" 0 2 #" Œ #"! #0. Œ..!+2 " 2!)Œ "! #0 2 Œ DIMENSION 1# /0#)0.Œ) 2 2*Œ 2& /0/ & Œ # /$02. Œ.." )Œ&". Œ.!/0. REAL, DIMENSION(10) :: A INTEGER, DIMENSION(1980:1990) :: YEAR 2 Œ!+2!.! #0. Œ.. ù Œ ". $0 10" 0+ 2*Œ " /0/ & Œ #. /$ Œ!..2.!

7 12 Œ # #0! 02 /010* $! " 2" " )Œ #..Œ 0#20 Œ! 1&! Œ.." 2 /0*20!!.! #0. Œ.. YEAR Œ ". $0 10" 0+ 2*Œ " /0/ & Œ #. /$ !..! /020" 2& 12 $0& 2 #Œ !.Œ) 2 &" 2!1)" 2& /#.+ Œ& 02. 0/.3!02) 2!)Œ 1#0!. 12.!$ 2 # Œ!!.2 "! #0 2 ). 2 # Œ # Œ " /.1210& Œ!/ REAL, DIMENSION(:), ALLOCATABLE :: A 2 1#$0. )2.. $!0.12 *0 2 Œ.. /+ #0 2 / # ALLOCATE Œ!/ ALLOCATE ( A(10) ) õ2. /0 $!0.).120 Œ. 2 Œ... #0..Œ /010*1 # " " Œ #.2..0 $!1 Œ * DEALLOCATE Œ!/ DEALLOCATE( A ) û0*20! "!)Œ "! #0 2 Œ.. 1& /& )Œ&". Œ.!/0. ù!2.0" INTEGER A(10), B(20) ù!.0" 2" REAL, ALLOCATABLE :: N(:) û#.)" Œ.." 0 Œ!..2" 2" DOUBLE PRECISION VEL(30)!..2.! /Œ".!0." COMPLEX I(100)./" 2" ù3.!2.0" CHARACTER (LEN=20) :: CODE(10) ù3.!2" 2" #" LOGICAL TR(5) " 2" 2!)Œ " Œ #. $!1 Œ *0.Œ) /&. 12 0". Œ " Œ! &".*20! " 0. Œ!+2 " /./ DIMENSION. 7

8 .!.2!1 õ2.! #0 2 Œ.. 0..Œ) 2 #" Œ.!.Œ& /* 2!)Œ #" ù Œ.." 0..!2)" $ #0.#2).2 /01) )& 2& 12 $0& 2 # ù Œ.." 0..3.!2)" ). 2 # $0. $ # /0) " 0" 1# 10!"! 0 #. 00" !10". Œ.. Œ! 1Œ " 2" Œ.!.2& /* /!.12!)220" û!.12!) " Œ #. 1#020$. ).2. Œ " 2& %3& Œ # Œ!0 2 0 ). #0. 2 Œ Œ.. ù..œ) 2" Œ.!.2& /&2" 02 " Œ120*0" )2 0. Œ.2..!10" 2 Œ.. ù.) REAL ) INTEGER ) DOUBLE PRECISION /) COMPLEX 0 CHARACTER 12 LOGICAL û!.12!) Œ " 0201" 2 # Œ.!.2& Œ!!.2 " INTEGER A(3) S=A(2)+1 PRINT*,S. / Œ 2. þ /..Œ #. #" þ 0 S 12 ù 8

9 +" 2 Œ 02 *0 2" 10. Œ.. þ.2.$+! Œ... Œ! *10. $&! /* Œ0!Œ2+10" õ2. &! #0 0 2& Œ! 2!& 2" 2" Œ #. $0 Œ.." õ2. $!12" 2 # Œ!!.2 ".010 2" 12 Œ /!0. 2 # Œ!!.2 " 0 )0" 2" Œ0!Œ2+10" Œ #. # * $!1 Œ *0 2 /0#02.&1...Œ Œ 1 #0 2.Œ.!./0.2. ù#2) /0 1.0 )2 /0 Œ!+. $!1 Œ 1&. 2 /0#02.&1 (READ-FORMAT). +" 01 #0 2" 10. Œ /! " 2 # Œ!!.2 ",. Œ! 1Œ.1 #0 Œ.!.2& 1& 0)" Œ.!./0.2 ". Œ! 20 #0 2!)Œ #" 01.&" Œ /! " 2 # Œ!!.2 ".!/0..!.30 Œ!)!.. 2 Œ. /.0 Œ!..2 *".! *"..2 #".2.$&!0 10. Œ.. ù 2". / 2..Œ) 2 $!12 ùœ21 üœ0/ /0 &! #0 2 #".! *". 2 #" 21 # READ. 1 "!)Œ " 0 $!1 2" 02 " DO- REAL A(10) DO I=1,10 READ*,A(I) 9

10 2 "!)Œ ".Œ0#0.".&1 2 # ù REAL, DIMENSION(10) :: A READ*,A þ 0!3.&1" 2& Œ& P 1, P2,..., P 0. n READ(u2,f) P1,P2,,Pn )Œ # u f 0..!)" 2" format. f /0 $ #0 /." format). P1,P2,,PN 0. ).2. Œ& 3 "!)Œ " 0 implied do) REAL, DIMENSION(10) :: A READ*,(A(I),I=1,10).Œ " 0201" 2 #Œ.!.Œ& Œ!!.2 " 0. ü2!+2 û #!. 10&. 2 Œ.. ù 0 /0" 2" û0*20!-.2.$+! $0. ùÿ 2 #Œ... ÿ «Œ!+2 ". 2!2 " 2!)Œ " 1# #" 0" ) #" Œ! *0. 2 Œ 021 #0 2". Œ 0".Œ) 2" 10" 2 #Œ... )$)0" )Œ&" 1#.0 02 /0*20! 2!)Œ ü. Œ.2 " 2!)Œ ".. /.1 #0 0#! Œ 021 #0 10. Œ.. 10

11 .!.2& / #0. Œ.!/0. 01.&" 12 $0& 10 /* Œ.0" 2.#2)$!..2.. Œ # 0/.0 12 Œ! *0 Œ.!/0..!/0...!.30 Œ!)!.. Œ #. /.0 0#!. 2+ Œ #..212 $ * 10 ). Œ)"..212 $" 0!! Œ /* Œ.0".212 $. ùœ21 ò12& TOWN 2 ). 2 # Œ.. Œ #. /$02. 2" Œ)0". TEMP 2 ). 2 # Œ.. Œ #. /$02. 2" 0!!.10",. Œ!Œ0 Œ!+2.. /+1 #0 2 #" Œ.0".#2 *" Œ!+2 ". /$02. $.!.2!0" 0+ /0*20! " Œ!..2 *".! *" 2 1#$ #0 2" 2" 0..Œ) 2 #" 2!)Œ #" Œ # Œ.! # Œ! *0 Œ.!/0. &12 *1 1. CHARACTER (LEN=20), DIMENSION(15) :: TOWN REAL, DIMENSION(15) :: TEMP DO I=1,15 READ*,TOWN(I),TEMP(I) &12 *1 CHARACTER (LEN=20), DIMENSION(15) :: TOWN REAL, DIMENSION(15) :: TEMP READ*,(TOWN(I),TEMP(I),I=1,15) " *1 CHARACTER (LEN=20), DIMENSION(15) :: TOWN REAL, DIMENSION(15) :: TEMP READ*,TOWN,TEMP 2 200#2.. Œ0!Œ2&1. Œ! 1Œ.10 2 Œ!)!... Œ!0 2" Œ!+20" 2" / 2. Œ!+2. 0* Œ).. 2" 11

12 2 Œ Œ.. TOWN. 2" #Œ) Œ0" 2". 2" 2 Œ Œ.. TEMP 0 1#Œ0.. / #!0 /. Œ 2" 0201" 2 # Œ!!.2 ".2 2 Œ! 1Œ0. 01.&" 1# 10!+ 10 Œ.. Œ # /$02..!2" 2" û!.12!) / #!10" Œ!)!.. Œ # ).2. 2&. 2 Œ " 2& %3& Œ # 1#2!&1. 12" 0 " 2 # 10 /* Œ.0".212 $../0/.. / 2..Œ) 2 $!12 2 # Œ!!.2 ". 0* +" 01 #0 2" 10. Œ.. 1..Œ) 2 Œ!)!.. 2 Œ! *0 0)22. 0/.0 Œ+" Œ! *0. /+1 #0 2 /#.2) $!12 2 # Œ!!.2 " ".2 2 /! " 2 # Œ!!.2 " Œ!$ # )&" Œ0!Œ2+10" )Œ # 2. /0/. 0. &12 0 2& Œ! 2!& Œ$.Œ )" Œ0!.2 ". &. 0201& 2 Œ!)!.. 0/. 2. /0/..#2 2 Œ0!Œ2&1.#2 01.& /0/ & 0 2 #" Œ.!.Œ& 2!)Œ #" 0# 0 /* #" )Œ&" 01.& 0)" #" /0/ # Œ$ 2 #Œ02 12 *.Œ) /0/. Œ #..Œ.2 * # Œ!!.2 ".Œ) 2.!$ Œ#1 Œ) 22 & Œ! 2& $!1 Œ * DATA. ü1.& /0/ & DATA. þ 0!3 2" 02 " 0. DATA !+ 12

13 Œ.!.2& Œ.!/0.. 0 Œ 02 " !3 2" Œ.!.Œ&.!/0.. 2 Œ 02 * 2" 10. Œ.. ù ùœ21. INTEGER A(5) DATA A /15,23,34,56,78/ 02 $!1 2" implied do INTEGER A(5) '$7$ ùÿ,. Œ.!.Œ& /0/.. Œ! *1. 0Œ1". / * 0 2 0" 2!)Œ A=(/15,23,34,56,78/) $!1 Œ +2." 2 1*2. õ. Œ &1 þ 02 DATA $!1 Œ 02. 1#&" 12.!$ 2 # Œ!!.2 " 0.Œ+20! 12)$. /+10 2" 12" 02.2" Œ #. $!1 Œ * 12 1#$0..Œ) 2 Œ!)!.. 0 0)20!0" 0/)10" 2" FORTRAN Œ! Œ " DATA +. 2 ).#2). 2. 1#02).1#1 #0. 12 Œ.!.Œ& 1*2.! 1Œ10. 0" $!1 2" 02 " DATA 12 Œ.!.2& û!.12!)22. û!.12!) / #!10" Œ!)!.. Œ # $0. 2 #Œ.!.2& Œ.. 10/* Œ.0" $!1 Œ +2." 2 02 DATA. ),0!!.1. û!

14 !!0" 14, ñ0" Œ0!Œ2+10".!.2&..3! #0 Œ.!./0.2. )Œ #." 2 *. 2 Œ 021 #0 2" 10. Œ.. Œ 0". Œ * Œ. /)22..!/0. Œ " 2" «10. Œ.. ù ùœ21!+2.! #0 2 Œ.. 10& ù. 12 1#$ $!1 2" 02 " DO-. 2& /02+ 2" 2 Œ 02 *0 2" 2" 12 Œ.. 1#0!. Œ.!.2! *0 ) ù Œ!Œ0. 2 Œ 021 #0 2 2 ) ù Œ!Œ0.2 Œ 021 # Œ ùÿ Œ!Œ0.2 Œ 021 #0 2 2 ÿ ò21 $ #0 INTEGER, DIMENSION(100) :: A DO I=1,100 A(I)=I. /0*20! * Œ.!.2& : INTEGER, DIMENSION(100) :: A A=(/(I,I=1,100)/)!1 Œ +2." 2 Œ.!.2& 1*2. õ. Œ.. 1#!21ÿÿ.!$ >.@.!/0. ò12& ù." Œ!..2)" Œ.." 0 / Œ " Œ!+20" 10" 2 #Œ / " #Œ) Œ0" 14

15 ùœ21 Œ! *0. $!1 Œ 1 # '$7$ '2-. 1 " 2!)Œ " REAL, DIMENSION(100) :: A DATA (A(I),I=1,50),(A(I),I=51,100) /50*1,50*0/ 2 " 2!)Œ " REAL, DIMENSION(100) :: A DO I=1,50 A(I)=1 DO I=51,100 A(I)=0 3 " 2!)Œ " REAL, DIMENSION(100) :: A A=(/(1,I=1,50),(0,I=51,100)/) þ Œ.!.2& /!.12!) "!!..$0" Œ+" & /0/ & 1..Œ) 2 Œ!)!.. 10 Œ0!Œ2+10" Œ # 2" Œ # #0. 2 Œ 021 #0. Œ * Œ. /)22.. 1#0Œ+" Œ! *. 2 Œ 02 * '2-. û!.12!) Œ 210 2" 2" «10. Œ.. ù +" 03. # $0. 0)" Œ.. ù. 2 0Œ)0 12/ & 12 $0& 10. Œ Œ00!.1. 2& 12 $0& 2 # Œ #$ & 12 $0& 2 # Œ.. 00". ) #" 0#."...30! *0 Œ! & 12 $0& 2 #Œ.. *! " ) ". 2 0Œ.#2 )Œ&". /0".Œ.!.2& 0. )2031 2& 12 $0& 2 # Œ.. 0 Œ!. Œ * 0 2.&1 2& 12 $0& 2 # 15

16 Œ.. þ *!. /.3! )2 12.&1 $!1 Œ READ *Œ&1 $!1 Œ PRINT WRITE..!.2& / #0. Œ.!/0. 031" 2& 12 $0& 0)" Œ.. õœ&"..3! Œ! *0 0)22. Œ! *0 0*.. $!1 Œ 1 #0. 2 /0#02 02*Œ&1 WRITE-FORMAT, PRINT-FORMAT.2 2".Œ" PRINT WRITE..!/0. ò12& )2." Œ.." ù Œ0!$0 2" 2".!3 * 02 " Œ #. 03. # 2" 2" 2 # Œ.. ù ùœ21 2!)Œ " Œ.! #1.1" 2& /0/ & 0. Œ.!) " 0 2.&1 2& /0/ & 0 2 /.3! )2.2 2" 02 " READ $!1 Œ * WRITE PRINT. 1 " 2!)Œ " 0 DO-CONTINUE) DO I=1,5 PRINT*,A(I) ( WRITE(6,*) A(I)) þ031 2& 2+ 2 # Œ.. 12 ). 0. 0" " 2!)Œ " 0 implied DO) 35,17$,ÿ :5,7( $,ÿ þ031 2& 2+ 2 # Œ.. 12 ). 0. 0" " 2!)Œ ".Œ0#0." ) 2 Œ.. PRINT*,A ( WRITE(6,*) A) þ031 2& 2+ 2 # Œ.. 12 ). 0. 0"

17 þ 0!3 031" 2& Œ& P 1, P2,..., P 0 2 2!)Œ.#2) 0. n WRITE(u1,f) P1,P2,,PN )Œ # u f 0..!)" 2" format. f /0 $ #0 /." format). P1,P2,,PN 0. ).2. Œ&,. Œ!)20.. $!1 Œ *0..Œ) 2 #" /* Œ!+2 #" 2!)Œ #". 2 #" 0" ) #" Œ! * #0 2". Œ 0".Œ) 2" 10" 2 # Œ... )$ )0" Œ #1# !2 2!)Œ ü. Œ.2 " 2!)Œ " #0 0#!. 2+.Œ) /* Œ.0".!/ *. 0* 2. Œ! $0..Œ) 2. 2& Œ& ù. ú A = 21 ; B = ùœ21 1 " 2!)Œ " 0 $!1 2" DO-) DO I=1,3 PRINT*,A(I),B(I) ( WRITE(6,*) A(I),B(I)) þ031 2& 2+ 2 # Œ.. 12 ). 0. 0"

18 2 " 2!)Œ " 0 implied DO). PRINT*,(A(I),B(I),I=1,3) ( WRITE(6,*) (A(I),B(I),I=1,15) þ031 2& 2+ 2 # Œ.. 12 ). 0. 0" " 2!)Œ ". PRINT*, A,B ( WRITE(6,*) A,B) /) Œ!+2. )0" 2" 2" 2 # Œ.. ù.02 )0" 2" 2" 2 #Œ.. ú þ031 2& 2+ 2 # Œ.. 12 ). 0. 0" " " $0. 0)" Œ " 2" /* Œ.!.2& /!.12!)220" û!.12!) !) Œ!)!.. 2" û!.12!)22." 2".20" 02 " * /* Œ.0" 0 2!3 Œ # " /!.12!)22." û!.12!) Œ & 02#Œ+10& 2& Œ.!.2& Œ!!.2& 18

19 ù) INTEGER K, LIST(8) DO K=1,8 LIST(K)=K**2-1 PRINT*, LIST ú) INTEGER J REAL, DIMENSION(20) :: TIME TIME(1)=1.0 DO J=2,20 TIME(J)=TIME(J-1)+0.5 PRINT*, (TIME(J),J=1,20,4) üœ00!.1. 2& 12 $0& 0)" Œ...!.2!10" &"2+!. 2 2!)Œ 0 2 Œ 01 #0 2" 10. Œ...+". 2 2!)Œ 0 2 Œ 03. #0.#2" 2" 2" Œ 1.2)! " )&" )& 2& Œ! 2&.3! 2 0Œ00!.1. 2& 12 $0& 2 # Œ..! 0 #..230" Œ+" 0Œ*02.. 0! " Œ! 2& Œ # $0 &" Œ00! $0& 0)" Œ... /.2#Œ+1 #0 2. Œ!.2..#2 10.2!0" )Œ&". Œ.!/0. 0*!01 0.$12 #-012 # 12 $0 # 2.)1Œ..Œ +" 03. # $0. 0)" Œ.. Œ #. Œ * Œ. /)22. 2" Œ0!Œ2+10".#2"." /02.." Œ..". 12 1#$0.." 2 * # $0. 2 # Œ.. Œ #. Œ * Œ. /)22..).. 2" 10" 2 #Œ.. 12" Œ 0"! $0..#2 û #0..2Œ! 1&Œ0#2) Œ.!/0. Œ.!.2&.!/0..!.30 Œ!)!.. 2 Œ 03)1. /.0.! *". 2 #" 2 Œ Œ #$0. 03)1 #Œ ". 2 #".! *" Œ # 0. &.Œ) 2 /12. >@ 2 1 2& 12 $0& 2 #Œ.. Œ # $ # 2 ùœ21 þ0œ#1 2 # Œ!.2 "$0 &"0" ù 0!!.3 01)/ #-0)/ # ü1 / ".! Œ #. 2 Œ 02 * 12 Œ.. 12& ù ò / "

20 ú ù)! " Œ!.2 " ù I=1(1)10 û ùÿ I=1(1)10 ù" A( I) [ 5,15] ü310 2 ùÿ 0#/" I=1(1)10 ù" A( I) = 30 ü310 2 ÿ 0#/" 20

21 +!)!.. PROGRAM EYRESH IMPLICIT NONE INTEGER, DIMENSION(3) :: A INTEGER :: I READ*,(A(I),I=1,30)! PRINT*," ÿü ÿù ù [5,15]" DO I=1,30 IF (A(I).LT.5.OR.A(I).GT.15) THEN PRINT*,A(I) END IF! ,17,üüÿ ÿù ù ü ÿþ DO I=1,30 IF (A(I).EQ.30) THEN PRINT*,I END IF END 0&1 #0" Œ 0" 0. Œ * $!10" # 0/ #" Œ!.2. / Œ.!.2& Œ.. x! /12. >ùú@ (X.GE.A.AND.X.LE.B) ((X>=A).AND.(X<=B)) To x! )" 2 # /.12.2 " (X.LT.A.OR.X.GT.B) >ùú@ ((X<A).OR.(X>B)) x 0. Œ.Œ1 2 # a (MOD(X,A).EQ.0) (MOD(X,A)==0) x 0. 02).!2) (X.GT.0) ( (X.LT.0) ) (X>0) ( (X<0) ) 21

22 x !) a x 0. /3! 2 # a (X.EQ.A) (X==A) (X.NE.A) (X/=A) ". Œ!0". 03.!)10" 2 Œ.!.Œ& 20$ Œ! 1Œ10. 0Œ*10" 2 Œ.!.2& /!.12!)22. û!.12!) !%0" Œ!)!.. 2 Œ 03)1./.10 2 #" 1 #" )! #".2+ +#.1 #. 2 #" 2 Œ Œ.. ù ". 2 #". *" Œ # 0. 0.*20! 1 2 # 2" 10" 2&.+ Œ # 0. 0.*20! 1 2 # +" #Œ #0 2! 1. )0 Œ " 1 )! 2& 12 $0& 0)" Œ.. Œ #. Œ * Œ. /)22. #$ "." 2 *. #Œ 1 #0.! 1.2. Œ )0. 12 $0& Œ #. Œ * )$ Œ. /)22. û #0. Œ.!/0. )Œ # ).2.Œ.!.Œ& Œ!.2..!/0.. /..12 *.!..!.. 2 Œ 02 * 10. Œ.. ù.!0 * *. 2 Œ " 2&.!+ Œ #!1 2. &.Œ) 2 /12. >-10,10], 2 )0 2&.!+ Œ # 0. /3! 2 #/0)".! /12. >-1,1], 2! 1. 2&.!+ Œ # 0. Œ.Œ1. 2 # / 1 ")! "2&!2&.!+ ùœ21 ù 0!!.3 01)/ #-0)/ # ü1 / ".! Œ #. 2 Œ 02 * 12.!. Œ.. ù ò / " / 22

23 ú ù)! " Œ!.2 " ù I=1(1)30 û ùÿ 3/ / I=1(1)30 ù" A( I) [ 10,10] 3/ 3/ 0#/" ù" [ 1,0 ) ( 0,1 ] A( I) 3 3$, 0#/" ù" A( I) = 5k 6 6$, 0#/" ù" A( I) = 2k 6 6$, 3/ 3/ 0#/" ü /36 PL2 =0 ü310 û0 #Œ!$ #!2 ü310 63/ 7 23

24 +!)!.. PROGRAM EXAMPLE! IMPLICIT NONE REAL :: S1,S2,MO,P INTEGER :: I,PL1,PL2 INTEGER, DIMENSION(30) :: A READ*, (A(I),I=1,30)! PL1=0 P=1 S1=0 S2=0 PL2=0! DO I=1,30 IF (A(I).LT.-10.OR.A(I).GT.10) PL1=PL1+1 IF ((A(I).GE.-1.AND.A(I).LE.1).AND.(A(I).NE.0)) P=P*A(I) IF (MOD(A(I),5).EQ.0) S1=S1+A(I) IF (MOD(A(I),2).EQ.0) THEN S2=S2+A(I) PL2=PL2+1 END IF! ,17 ".!+ &.Œ) 2 >-10,10]=",PL1 35,17+)0 /0+.! >-1,1] =",P 35,17ñ! 1. Œ.Œ.1& 2 # 6! IF (PL2.EQ.0) THEN 35,17û0 #Œ!$ #!2 ELSE MO=S2/PL2 35,171 " )! "!2&.!

25 END IF END.!.2&. $0" 2 /#.2) " 2 0!3 2 #.! # Œ # $!1 Œ * # 0/ #" Œ!.2. û.2*œ&1 0 *.! # ú.!1)" Œ.. ù. 2& # Œ!!.2 " ú. ù!$ Œ 1 Œ.!.2!&,2& S=0 (.! 12" Œ # $!1 Œ 02. )2.." 2 *! 1..!+ P=1 (Œ.Œ.1.12" Œ # $!1 Œ 02. )2.." 2 * )0.!+ PL=0 (02!2" Œ #" Œ # $!1 Œ 02. )2.." 2 * 2 Œ ".!+ Œ #. Œ * Œ. 1# 0 Œ0!Œ2&1 Œ #." 2 * Œ.!.Œ&.Œ)..! 1.2. )0. Œ Œ! *0. $!1 Œ 1 #0 Œ.!.Œ&.Œ)..! 12" S1,S2 Œ.Œ.1.12" P1,P 02!2" (PL1,PL2,..) ú..+" 2 ÿ Œ.!0 2".Œ) 2 &" 2 Œ " 2& 10& 2 # Œ.. 0Œ..0 2.Œ.!.2&.2. üœ00!.1. 2& /0/ & Œ." 1#" 020 $&!" 1#ª &!" 1# ù $!0. 2! 1. Œ &.!+ $!1 Œ ùÿ )0 2&.!+ Œ # &. 0Œ00!.12+ $!1 Œ ùÿ 0 1# ù $!0. 2! 1. Œ &.!+ Œ #. Œ * Œ. 1#ª $!1 Œ IF «1#» S=S+A(I) ù $!0. 2 )0 Œ &.!+ Œ #. Œ * Œ. 1#ª $!1 Œ IF «1#» P=P*A(I) 25

26 ù $!0. 2 Œ " Œ &.!+ Œ #. Œ * Œ. 1#ª $!1 Œ IF 1#ª PL=PL+1 ú. ü3.& 2..Œ ÿ,þ þ! 2 loop ü2)" loop ü2)" loop ñ! 1. S=0 6 6ùÿ PRINT*,S +)0 P=1 P=P*ù(ÿ) PRINT*,P 1 " õ! " S1=0 6 6ùÿ MO=S1/PL1 PRINT*,MO ü,þ þ! 2 loop ü2)" loop ü2)" loop ñ! 1. S=0,) 1#ª 6 6ùÿ PRINT*,S +)0 P=1 IF 1#ª P=Pùÿ PRINT*,P " PL=0 IF 1#ª PL=PL+1 PRINT*,PL 1 " õ! " S1=0 PL1=0,) 1#ª 7+(1 6 6ùÿ PL1=PL1+1 END IF IF (PL1.EQ.0) THEN PRINT ûü ÿýü ùÿ ELSE MO=S1/PL1 PRINT*,MO END IF ü). )".)." 0&1. 0ŒŒ 1# Œ # Œ! *!01 2 # 1 #)! #0)" Œ #" 12 $0& Œ #. Œ * Œ. 1# 2 Œ0!Œ2&1.#2. Œ!Œ0.!& 2 Œ " 2& 12 $0& Œ #. Œ * 2 1# 12& PL 2! 1. 2& 12 $0&.#2+ 12& S. 12 1#$0.. #Œ 1& 2 1 )! Œ #. 0. S/PL. 2 PL 0. /3! 2 #/0)" +.. /.Œ12+10".2 Œ)1 Œ!0". 03.!)10" ). 2. Œ.!.Œ& 12 Œ! Œ! 1Œ10. 0Œ*10" 2 Œ.!.2& /!.12!)22. 26

27 û!.12!) !%0" Œ!)!.. Œ #. 2 Œ #".!. #".! *" 20, -10, 37,, Œ.. ù 2 1#$0. 2 Œ!)!... #Œ )! 2& 12 $0& 2 # Œ.. +" #Œ #0 2 0$ $0 0)" Œ.. Œ 1#$ 03.)0 Œ!). 12 Œ!!..21) þ 0. 0*!01 2 # 0.$12 #. 2 # 012 # 0)" Œ #" 12 $0& 0Œ#1 2 # Œ!.2 ".#2 * #0 12 0)22..#2! )&" Œ! $&!10" $ 0" 0 2 Œ.!.2& /!.12!)22. û!.12!) Œ.!.2& 1$. #Œ!$ # 1#!2! #!2! #Œ!$0.".!)" ò12& )2 1#!2.!!..# # Œ!0".. 0" ) 2. 1#!2! 0 3!.. Œ0" Œ ".!)" 0. 2 Œ 02 " #2) Œ!0". Œ0!!%0". 20$..!0" 2 0$12.Œ) 2 #" Œ.!.Œ&.! *" 0&1 # /02. /#.2)22.. $!1 Œ 10". $.!2 )Œ # Œ!0".!30" )..!).3 * 110" Œ!+2. )Œ.!) #Œ!$0 12 $.!2.#2) 27

28 ò$ 2." Œ.!.Œ& /!.12!) Œ Œ * 0*. Œ! $&!10" 12 0Œ#1 2 # Œ!.2 " 0*!01" 0.$12 #- 012 #, Œ!. Œ * 12 1#$0. Œ.!.1)" 2" 1#!2.!!." 0. Œ.. 10& 0+ 2 # $.!2 * 0..! Œ. Œ!0./.2!10. Œ1. 12 )..!).!/0..!.30 Œ!)!.. 2 Œ 03)1./.0.! *". 2 #" 2 Œ Œ.. ù. 12 1#$0.. 02#Œ+0 2 0$ & 12 $0&.#2+ ùœ21 ù 0!!.3 01)/ #-0)/ # ü1 / ".! Œ #. 2 Œ 02 * 12 Œ.. ù ò / " þ0$ &.# #Œ.. ù ú.!/ $!.!& 2 Œ!+2.!) 2 # Œ.. ùù. 2 0&!+ &" 0$12 2 1#$0. Œ.!& 2 /0*20!.!) ù. 0$&. 0.!)20! ".Œ).#2) Œ # 0&! *1. &" 0$12 ù 0. 2)20 0&!+ 2. *!.#2).!) &" 0$12 2 1#$0. Œ.!& 2 2!2.!) ù. 0$&. 0.!)20! ".Œ).#2) Œ # 0&! *1. &" 0$12. ù 0. 2)20 0&!+ 2. *!.#2).!) &" 0$12 + ù)! " Œ!.2 " ú.!& 2 Œ.. ù. 2" 02.2" # ú. û.& 2" 2" 2 # Œ.. ù READ 03)1 /0 0. &12" 0 2& Œ! 2!& ú.,2& &".!$ 2 2 # 12 # 2 ù. &".!$ 2 2 # 0$12 # 2 ù ú. üœ...& 2 Œ.!.2& /./.1..+" 2 ÿ Œ.!0 2".Œ) &" ú.. ù ùÿ 0.!)20! ".Œ).#2) Œ # 0&! *1. &" 0$12 2& # 0$12 # 2.!).#2) ú. ù ùÿ 0. 0.*20! ".Œ).#2) Œ # 0&! *1. &" 12 2& # 12 # 2.!).#2) 28

29 ú. ü2#œ+& $12 ù, û ùÿ 0,1 $ 0$; $ I=2(1)5 A I) > MAX ù" ( 0$; $, 0#/" ù" ( 0,1 $, A I) < MIN 0#/" ü ÿ0$; 7 29

30 û!)!.. PROGRAM EXAMPLE3! REAL A(5),MAX,MIN READ*,(A(I),I=1,5)! MAX=A(1) MIN=A(1)! DO I=1,5 IF (A(I).LT.MIN) MIN=A(I) IF (A(I).GT.MAX) MAX=A(I)! PRINT*,"ü$12 =",MIN PRINT*,"12 =",MAX END H Fortran /.20 1#.!210". 2 #Œ 1) 2 # 0$12 # 12 #.+". 2& 10& 2 #" 10. Œ.. 2" Œ 0" Œ.!.2 #0 Œ.!.2& õ. MAXLOC). Œ.. 0!!.3 Œ # 12 # 12 $0 # 0)" Œ.. Œ!/ MAXLOC(A #Œ # 12 # 12 $0 # 12 Œ.. ù MINLOC). Œ.. MAXVAL). Œ.. Œ # 0$12 # 12 $0 # 0)" Œ.. Œ!/ MINLOC(A #Œ # 0$12 # 12 $0 # 12 Œ.. ù Œ $0 0)" Œ.. Œ!/ MAXVAL(A #Œ $0 2 #Œ.. ù MINVAL). Œ.. Œ 0 2 0$12 12 $0 0)" Œ.. Œ!/ MINVAL(A #Œ 0 2 0$12 12 $0 2 # Œ.. ù 30

31 +" 2. * $0. 0)" Œ....Œ) 2" Œ $!10" 03.! " 2 # þ )1 12 $0& /./ 12 2 Œ 21 0)" 1#) # 12 $0& 10. /.20! 10! þ 10!.# * #1..Œ) 2!)20! Œ! " 2 0.*20! #1..Œ) 2 0.*20! Œ! " 2!)20! 1 Œ)" 2" 2.)1" 0. /0#)#1 2"..21" 12 $0& 2.0! & 2.)1 $ # & *".2.) #" 0 2 )& 2" 0" $!1)22." 2" 2.)1" $ #..Œ2#$0. Œ.)!. 2 0Œ#1 2 # Œ!.2 ".#2 * üœ0/ *! " 1 Œ)" 2 # # & 12 Œ!!..21)...3! #0. 0* )! 2.)1" Œ # )1 3#1./." bubble sort.2 2.!)20!. 12 $0..0. # 1. 3#1./0" 12.!$ 2" 12." 2& 12 $0&.!/0..!.30 Œ!)!.. Œ # 03)1 2 Œ #".! *" 10. Œ.. ù 12 1#$ Œ.. 10.* #1. 10! ùœ21 ù 0!!.3 01)/ #-0)/ # ü1 / ".! Œ #. 2 Œ 02 * 12 Œ.. ù ò / ". 12 $0. 2 #Œ.. ù2...2.* #1. 10! ú.!/ $! $12 2 ù. %$&.!& 2 Œ!+2.!).Œ) 2 ù &" 2 ù Œ # 0.!)20! ".Œ).#2) ù!& & 0 2 ù #0$& 0 2 #" #Œ) Œ #".! *" &" 2 ù. & 2 / 31

32 02.Œ).#2 2 /./.1. $0 2 Œ ù!)20! ".!)" üœ...& 2 /./.1..#2 0+2." 2+!..Œ) 2 ù / %$&.!& 2 Œ!+2.!).Œ) 2 ù &" 2 ù Œ # 0.!)20! ".Œ).#2) ù!& & 02 ù 02.Œ).#2 2 /./.1. $0 2 Œ ù!)20! ".!)".Œ) 2 ù &" 2 ù üœ...& 2 /./ " 2+!..Œ) 2 ù.#2 32

33 .!.2!+ 0Œ1" )2.+" 2 ÿ 2 J )2. 2 ÿ 2)20 2 J=3,4,5, )2. 2 ÿ 2)20 2 J. 2 " )2. 2 ÿ 2)20 2 J ù /./ 0$. N.! *" 2 ÿ. Œ.!0 2" « J. Œ.!0 2" ÿÿ«+ ù)! " Œ!.2 " Bubble sort) ú.!& 2 Œ.. ù 0 10". 2" 02.2" 2 # Œ!!.2 " ú. û.& 2" 2" 2 # Œ.. ù DATA 03)1 0. &12" 0 2& Œ! 2!& ú..+" 2 ÿ Œ.!0 2".Œ) &". - 0Œ...& 2 Œ.!.2& /./.1. ú.. ü$& $0 ùj )Œ # 2 J Œ.!0 2".Œ) ÿ &" 0.!)20! 2 # ùi ù. 2)20.& ùÿ. ùj 0 2" 02 " K=A(I),A(I)=A(J),A(J)=K. ú. ü2#œ+& 2 Œ.. ù 33

34 ù, 1 û.10 2 ùÿ I=1(1)N-1 J=I+1(1)N A ( I) > A( J) ù" ù $, $- 0#/", 1 ü310 2 ùÿ 34

35 û!)!.. PROGRAM EXAMPLE4! IMPLICIT NONE INTEGER :: I,J,K,N, REAL A(5) A=(/4,7,1,5,2/) N=5! DO I=1,N-1 DO J=I+1,N IF (A(I)>A(J)) THEN K=A(I) A(I)=A(J) A(J)=K END IF! DO I=1,N PRINT*,A(I) END 0&1 ù112 * )1.2 3 #1. 10! 2)20.1)22.! 12 block if. Œ!0Œ )22. /./ IF (A(I)<A(J)) THEN K=A(I) A(I)=A(J) A(J)=K END IF 35

36 0&1 Œ.!.Œ& Œ!)!.. 2.)1" Œ!0. $!1 Œ 0.. Œ.0" Œ #/$ 2..3.!2" 12.0!". )$ ).! *" )Œ&". Œ.!/ )1 2 Œ * #1. 10! /./.Œ) 2 ù Œ! " 2 2& ò00.2 Œ)1 Œ!0". 03.!)10" 2 Œ.!.Œ&.)! 12" Œ.!.2& /!.12!)220" û!.12!) ! 1Œ " 0 *. $.!2 2 #".! *" $!1 Œ +2." 2 / 2.)1" 2" 3#1./." û!.12!) /..12 * ).2. Œ)0&. 12 1#$0. 03)1 2 Œ 02 * 10 Œ * ! +" Œ! *0. 0Œ00!.12 *0 Œ.0" 012 $0..Œ) 2.#2)$!. /*. Œ0!11)20! #" Œ.0" 012 $0..Œ).. *! 2*Œ /0/ & 0.*20!! " 2& Œ! 2& Œ # 1# Œ!!..21) 2& þ.œ #2)$! 0Œ00!.1. /*. Œ0!11 2!& Œ& Œ).#2) Œ.!.2&. 0/02) Œ.!/0.! )&" Œ! $&!10" Œ.!.2& 1 # 1#12+.../.10" 2" 0)220" - )& 2 # )2 0Œ#1 Œ! 2& 0 /* Œ.0".Œ.20 2" +10" 0Œ00!.1." 12 $0& 0)" Œ.. Œ #.30!. Œ.!.Œ& 36

37 .!/0. û02. Œ.!.2&Œ.."1".."0!!.1.".2 2.",0!!.1. ÿ. #! " 5-0! #! " 10!2 " 12 ùœ! " 17 " 19 ÿ * " 20 ÿ * " 29 ù* #12 " 29 0Œ2! " 24 2+! " 19! " 15 û0! " 5.!.30 Œ!)!.. Œ #. #Œ 0 2 0$ !!.1..+". 2 #" 0".2 2 #" Œ #" ".#2" ùœ21 ù 0!!.3 01)/ #-0)/ # ü1 / " 0". 0!!.10" ò / " þ0$ &.#2+ +.+". 0".2 2 #" Œ #" ú.!/ $! õœ&". 12 Œ! *0 Œ.!/0. Œ!+2..!& 2 0$12 Œ$ Œ$ 2& + 2 1#$0. Œ!+2.. %&.!& 10 Œ #" 0" $12 2 Œ$ û0! " ÿ. #! ". 12 1#$0. 10Œ #" 0" Œ$ ÿ * " ù* #12 " + ù)! " Œ!.2 " 37

38 ,. $!1 Œ 1 #0 2 Œ.. MONTH Œ #. /$ ).2. 2& +. 2 Œ.. EMP Œ #. /$02. 2".212 $0" 0!!.10" ù, û , 7(03, 0,1 7(03 0$; 7(03 I=2(1)12 ù" 7(03,!0$; 0$; 7(03, 0#/" 7(03,0,1 ù" 0,1 7(03, 0#/" I=1(1)12 7(03, 0$; ù" ü , 0#/" I=1(1)12 7(03, 0,1 ù" ü , 0#/" 7 38

39 û!)!.. PROGRAM EXAMPLE5! IMPLICIT NONE CHARACTER (LEN=20), DIMENSION(12) :: MONTH REAL, DIMENSION(12) :: TEMP INTEGER :: I REAL :: MIN,MAX! MONTH=(/"ÿùùÿ", "-üúùÿ", "ù ÿ", & & "ùÿÿ", "ùÿ", "ÿÿ" ÿÿ ù+ ü üúÿ úÿ üúÿ ûü üúÿ TEMP=(/5,10,12,17,19,20,29,29,24,19,15,5/)! MAX=TEMP(1) MIN=TEMP(1)! DO I=2,12 IF (TEMP(I)>MAX) MAX=TEMP(I) IF (TEMP(I)<MIN) MIN=TEMP(I)! PRINTþ 12 0!! MAX DO I=1,12 IF (TEMP(I)==MAX) PRINT*,MONTH(I)! ,17þ 0$12 0!! ,1 DO I=1,12 IF (TEMP(I)==MIN) PRINT*,MONTH(I) END 39

40 ù#2) Œ # 0 0/.3! #1. 2 Œ! * )2 )2. $ #0 Œ.! 0Œ00!.1. Œ&.+" 0Œ00! $0. 2 # 0)" Œ.. 2.#2)$!. 0Œ00! $0. 2 # /0*20! # Œ.. þ Œ.!.Œ& 11. Œ! *10. #0 $!1 Œ +2.". Œ.. 2 # Œ # $0...Œ 20 *2..Œ).. *! 2*Œ /0/ & 12& TEMPS 2 # Œ # $ ). 2 #. 12& þ. 2 ). 2" 0!!.1." 12& TEMP. PROGRAM EXAMPLE5! IMPLICIT NONE TYPE TEMPS CHARACTER (LEN=20) :: MONTH REAL :: TEMP END TYPE TEMPS TYPE (TEMPS), DIMENSION(12) :: MONTEMP REAL :: MIN,MAX INTEGER :: I! (03 7(036ÿùù 7(036-üúùÿ 7(036ù ÿ 7(036ùÿÿ 7(036ùÿ 7(036ÿÿ 7(036ÿÿ 7(036ù+ 7(036ü üúÿ 7(036 úÿ 7(036üúÿ 7(036ûü üúÿ! MAX=MONTEMP(1).TEMP MIN=MONTEMP(1).TEMP! DO I=2,12 IF ((MONTEMP(I).TEMP)>MAX) MAX= MONTEMP(I).TEMP IF ((MONTEMP(I).TEMP)<MIN) MIN= MONTEMP(I).TEMP 40

41 ! PRINTþ 12 0!! MAX DO I=1,12 IF ((MONTEMP(I).TEMP)==MAX) THEN PRINT*, MONTEMP(I).MONTH END IF! PRINTþ 0$12 0!! MIN DO I=1,12 IF ((MONTEMP(I).TEMP)==MIN) THEN PRINT*, MONTEMP(I).MONTH END IF ünd DO ü1'! 1Œ10 2+!.. 03.!)10" 2 0 /. 2" Œ! *0" 11".+". 2.)! 2.)1" Œ #.0" Œ)0 /!.12!)22. û!.12!)22. þ.2. 2& 00!+ /.1+ 1#02.! &!.3 /.0!1.2. //02..Œ) 2 Œ.!.2& Œ.. ùù +0&!.3 û.0!1.2. ù!)" û.1+ #& 1,ù þ 33 2 ùù ÿ þ ù üûÿù 68 3 ü ÿ þ ù üûÿù 62 4 û ÿ þ ù üûÿù 35 5 þüÿ 60 6,üùÿù 87 7 üüù üùûù 91 8 üþ 10 9 þÿù 0.!%0" Œ!)!.. Œ # Œ.!.Œ& 0&!.3 /.0! #1. 10! &" Œ! " 2.!) 2& û.1+ #02.!1+ 41

42 #/12.2 Œ.0" 2 0)22..#2..1$ * !. 2& Œ& Œ # $ # 2 0.*20! 2" /." Œ #/12.2 Œ.0" )Œ # 0 2 )! 2 0 *0 2 Œ " 2& /.1210& 2 # Œ..!)02. /./. 2 #.Œ *" Œ.0" Œ # &! # * Œ& *20!.Œ) A = " 02 B 1 = ; B 8 1ij 2ij 2 = 4 1.." üœœ $.!.2!12 2& Œ& 02)".Œ) #" 2 Œ " 2& 12 $0& 2 #" 10 0 /12.1 Œ!/ ù $ ú $0.!3 2 #" /./ #" 12. /* Œ.0" 0 2 /.!3 2. 1*!3. )Œ&". / *0 Œ.!.2& Œ!+. 2 #" 0Œ00!.12+ Œ 0*. 2 0 " 2 #" /./ 2 1# ) Œ " 2& 12 $0& 2 #" Œ!/ 12 Œ.!.Œ& Œ0!Œ2&1 ù $0 0 " 0+ ú þ / 2" 0)22.".#2" 0. /. 0 2 Œ! *0 0)22. Œ #.3! Œ.0" ) /.3! )2 0. Œ Œ0!Œ2 0 Œ ) 2!)Œ.Œ 0*02.." Œ.." 12 2 # þ þ )RUWUDQ.!0 )2 / Œ.. 2 Œ 02 * $0. 0)" Œ $0 2 # þ 0. &" Œ! " 120" 42

43 C C = C. /0 1$ $+!.Œ 0#1" C C C C C11 C 21 C12 C 22 C13 C 23...!/0. Œ.." C = Œ " 12 2 # þ /..#2)". Œ!Œ !)Œ " Œ #. Œ!Œ0./ $0. 2 # Œ.. $!12". 20 $!1 Œ 1 # &1" 5($'& +"! #0. Œ..!1)" 2& Œ #/12.2& Œ& #" / #" 2!)Œ #" Œ #..3! Œ! *0 0)22.!+2 " 2!)Œ "! #0 2 Œ ',0(16,21 1# /0#)0.Œ) 2 2*Œ 2& /0/ & Œ # /$02. Œ.." )Œ&". Œ.!/0. ÿ17(*(5 ',0(16,21 ù INTEGER, DIMENSION(1980:1982,1 ú 2 Œ!+2!.! #0.Œ.. ù Œ ". $ /..Œ Œ)!.". 120" 0+ 2*Œ " /0/ & Œ #. /$ !..! 2 /0*20!!."! #0. Œ.. ú Œ " /./ 1*!3 "Œ! "2 Œ.. ù 0+ 2*Œ " /0/ &Œ #./$ !..! /020" 2&!.+. 0 *.Œ) &". 0+ /020" 2& 12+.Œ) &".!.2! *0 /./ )2 /020" 2 # Œ.. Œ! *. 0 *.Œ) 2..Œ) 1#0!0".!$" 2" Œ #. 1 #0 43

44 12!1) 2 # Œ.. )Œ&" 0Œ1".. 32 # &"!10" 20" 2" Œ # 2 #0 0 2 /!1) Œ 0" 2.. )!. 2& /02+ Œ! *0 0Œ1".!1 #0. /#. *" Œ.0" )Œ&"Œ.!.2& REAL, DIMENSION(:,:), ALLOCATABLE :: C REAL, ALLOCATABLE :: C(:,:) ü+ 12 1#$0. Œ! *0. 21 #0.Œ) 2 $!12 2 / # Œ.. READ*,N,M.. /010*1 #0 2".212 $0" 10" " 2 # þ ALLOCATE( C(N,M) ). 02.Œ) 2 0Œ00!.1. 2& 12 $0& 2 # Œ... #0..Œ /010*1 #0 2".212 $0" 10" " DEALLOCATE( C ) û0*20! "!)Œ "! #0 2 Œ.. 1& /& )Œ&". Œ.!/0. INTEGER A(3,2), B(1980:1982,2) REAL C(:,:) Œ.0" $%& 0. / Œ # Œ0!!3. Œ.!.Œ&! 0 #. 00" !10". Œ.. Œ! 1Œ " 2" Œ.!.2& /* /!.12!)220" û!.12!)22., $&!1 #0 2 #". *".2+ 0)" 2.2 " Œ... $!1 Œ 1 #0. Œ&". 2!1 #0 ù #0. $ #0 2 #". *".Œ) &.2+ 2 Œ... $!1 Œ 1 #0. Œ&". 2 /+1 #0 0&1 Œ 2 #0 )2 2 Œ " 2& / 44

45 &"! #0 #Œ Œ.0" ò." #Œ Œ.." Œ!0.! $!1 2!+ /02+ )! ª )! ª.ª þ Œ.!.Œ& 2!Œ2. /02+." /0$0 2 2!)Œ 0 2 Œ /02" 2 #Œ.. ù!$0.œ) 2 2 )! ª Œ! 1Œ.+2." )! ª 0 1#0!.ª.!/0. ò12& REAL, DIMENSION(10) :: A 2)20 ù(1:5:2)! A(1),A(3),A(5) A(1:5)! A(1) &" 2 A(5) A(3:) ùœ) 2 ù &" 2 2 " ù ùœ) 2 ù &" 2 ù ù ùœ) 2 ù &" 2 ù.!/0. ò12& )20 REAL, DIMENSION(5,5) :: A ù ù ù ù Œ!+20"!.". Œ!+20" 120" 2 # Œ.. õ " Œ.." ù þ2!2!. 2 #Œ.. ù +" 2 Œ 02 *0 2" 10. Œ.. þ.2.$+! /1/12.2 Œ..... ò12& )2 $ #0!10 2 Œ.. ù2". 2.1"..212 $. REAL, DIMENSION(3,2) :: A 1 " 2!)Œ " (0 $!1 2" implied do) ù&1.2!." READ(*,*) ((A(I,J),J=1,2),I=1,3) ù& " READ(*,*) ((A(I,J),I=1,3),J=1,2) 45

46 2 " 2!)Œ " 0 $!1 2" DO-) ù&1.2!." DO I=1,3 DO J=1,3 READ*,A(I,J) ù& " DO J=1,2 DO I=1,3 READ*,A(I,J) 3 " 2!)Œ " ùœ0#0.".&1 5($'XI ù )Œ # u f 0..!)" 2" format. f /0 $ #0 /." format) 2 Œ0!Œ2&1.#2.&1 2 # Œ " ù 2+!. &! # $0. 2 #Œ.. Œ!/ 1 A = )20. Œ! *1.0. $!1 Œ 1 # DATA.. 2 Œ 021 # $ " Œ!/ DATA A/1,3,5,2,4,6/ A=RESHAPE(SOURCE = (/ 1, 3, 5, 2, 4, 6 /), SHAPE = (/ 3, 2 /) ) þ reshape Œ #." 0Œ2!Œ !% #0. /12.2 Œ.. Œ " / source 10. Œ.. /.3!02"!3" Œ..!02..Œ) 2 shape 2 Œ.!.Œ& Œ.!/ $0. 2 # /12.2 # Œ...Œ 20 * 2" 120" 2 #. *! # Œ.. Œ #. $

47 ( ) !.2&...3! #0!1. $.!.2!12 Œ.!./ Œ 21" Œ.0".!/0.. / #! * Œ.0" A = I B = 0 0.!.2! *0.2.!$" 2" /)220" 2& 12 $0& 2& Œ& / 12 Œ.. ù 2.I,I 12 $0. 2 # Œ #Œ) Œ. /,. $ #0 /./ INTEGER, DIMENSION(4,4) :: A DO I=1,4 DO J=1,4 IF (I==J) THEN A(I,J)=1 ELSE A(I,J)=0 END IF 2 Œ.. úœ.!.2! *0 ) $0. 2 #. 0. /. /./ $0. Œ&.Œ) 2 *!. /.+ 2. Œ. $ # 2!3 ÿÿ.+" )&" 2 ÿ Œ.!0 2".Œ) 2 &" 2,. $ #0 /./ )2,17(*(5 ',0(16,21 ú DO I=1,4 DO J=1,4 IF ((I==J).AND.(J/=4)) THEN A(I,J+1)=1 ELSE

48 A(I,J)=0 END IF ù Œ.." #!02.. Œ!+2 3!. 1#0Œ+" ) $0. 2 # 0. / 2)20. Œ! *1.. $!1 Œ 1& 2 Œ.!.2& Œ!)!.. DO I=1,3 A(I,I+1)= / #!. 0)" Œ.. 0. Œ * $!1 02 WHERE 2" Œ." 2 1*2. / #0 Œ.!.2& þ02 :+(RE Œ)" üœ2!œ0 2 0Œ02 0Œ00!.1. 2& 12 $0& 0)" Œ.. *2. WHERE 3!.1 ü2.01" ü2.01" [ELSEWHERE ü2.01" ü2.01" ] END WHERE.!/0..!.30! " Œ!!.2 "Œ #.2 Œ $ !2 12 $ /0 12 $0. 0)" Œ.. ù WHERE (A>0) ù=1 WHERE (A==0) ù=0 48

49 WHERE (A<0) ù=-1 þ WHERE-END WHERE /0 0. /! " 0$ #. /0 0Œ2!Œ02.. $ #0 3&.10" 22 0" / ",. 2. ù, Œ).!% #0 WHERE (A>0) A=1 ELSEWHERE WHERE (A==0) A=0 ELSEWHERE A=-1 END WHERE END WHERE 0&1 2 FORTRAN /0 1$* # Œ.!.Œ& Œ0!!1 )1.3! 2 1*2. 2" WHERE Œ # Œ Œ!0. 1#2.$0 )Œ&" Œ.!.2& WHERE 3!.1 ü2.01" ü2.01" [ELSEWHERE ü2.01" ü2.01" [ELSEWHERE ü2.01" ü2.01" ] END WHERE. 1#0Œ+" 2 Œ.!.Œ& Œ!). 12 FORTRAN. Œ! *10. #0 &"0" WHERE (A>0) A=1 49

50 ELSEWHERE (A==0) A=0 ELSEWHERE A=-1 END WHERE 0 2 " 2!)Œ. 1&12) 2!)Œ. 2 FORTRAN Œ #..3!.0 Œ.!.Œ& û!.12!)22..!.30 Œ!)!.. Œ #. / #!0 2 #" Œ.!.2& Œ.0" A = ; B = û!.12!)22..!.30 Œ!)!.. Œ #. /$02. &" 01 /..!. Œ.. ù 2.1" #$0. / #!0.. *! 1*!3 Œ.. ú0 12 $ ! 3. 2& /0+ 12 $0& 2 # ù Œ!/ WHERE. 1/ aij aij 0 bij =. $!1 Œ aij = 0 0&1 þ Fortran /.20 0ŒŒ 2 02 )25$//. 2 0$ 2".01" Œ.. 50

51 +" 03. # $0. 0)" Œ.. 2!)Œ " Œ #. # * & 12 $0& 0. Œ.!) " 0 2.&1 ò12&. Œ.!/0. )2 $ #0!10 2 Œ.. ù REAL, DIMENSION(3,2) :: A. $ #0 2 Œ Œ.!.2& 12 $0. 1 A = / Œ #..3!.0 Œ.!.Œ&. #0. 0.!+1 #0. 2 Œ 02. 1& $0. 2 # Œ.. þ/./.1. 2" 02*Œ&1" Œ #.. #1 #0 0. Œ.!.2& 1 " 2!)Œ " 0 $!1 2" DO-) ü2*œ&1.2!." DO I=1,3 DO J=1,3 PRINT*,A(I,J) ü2*œ& " DO J=1,2 DO I=1,3 PRINT*,A(I,J) 2 " 2!)Œ " 0 $!1 2" implied do) ü2*œ&1.2!." WRITE(*,*) ((A(I,J),J=1,2),I=1,3) ü2*œ& " WRITE(*,*) ((A(I,J),I=1,3),J=1,2) 3 " 2!)Œ " ùœ0#0." 02*Œ&1 :5,7(XI ù )Œ # u f 0..!)" 2" format. f /0 $ #0 /." format) 51

52 2 Œ0!Œ2&1.# & 12 $0& 2 #Œ " Press any key to continue üœ00!.1. 2& 12 $0& 0)" Œ.. 2 1#$ ! *0 1& Œ.!./02& 10!1. $.!.2!12 Œ.!./0.2. 0Œ00!.1." Œ #/12.2& Œ&!0" 02.* Œ&.!.2&./ *0 Œ&" Œ! *0. *1 #0 Œ!.2. Œ # $ # 1$1 0 2" &12" Œ!0" Œ& Œ!)101.3.!01 Œ.Œ.1.1)" Œ!)101-ù3.!01 &,0&!0120 )2 $ #0/*.!. #" Œ.0" ù ú0210&". #0. #Œ 1 #0 2! 1. C 2& Œ&.#2+.!.2! *0. )2 Œ.." C. 0. 1*!3 " 2& ù ú. )2 c ij = aij + bij. #0Œ+". $ #0 INTEGER, DIMENSION(:,:), ALLOCATABLE :: A,B,C READ*,N,M ALLOCATE ( A(N,M), B(N,M) ) READ*,A,B DO I=1,N DO J=1,M C(I,J)=A(I,J)+B(I,J)! C(I,J)=A(I,J)-B(I,J)..3.!01 Œ& þ Œ!)101 2& Œ.!.Œ& Œ& ùú.œ) 2 12 Œ # 0. 1*!3. Œ! * Œ1".Œ!3 2." 52

53 C=A+B.Œ.1.1)" Œ&,0&!0120 )2 $ #0 /*.!. #" Œ.0" ù0210&" N,M. ú 0210&" L. #0. #Œ 1 #0 2 )0 C 2& Œ&.#2+.!.2! *0. )2 Œ.." C. $0 2.1 L. )2 c ij = ai1b1 j + ai 2b2 j + + aimbmj = a i = 1,2,..., n ; j = 1,2,..., l #0Œ+". $ #0 m k = 1 ik b kj INTEGER, DIMENSION(:,:), ALLOCATABLE :: A,B,C READ*,N,M,L ALLOCATE ( A(N,M), B(M,L), C(N,L) ) READ*,A,B DO I=1,N DO J=1,M C(I,J)=0 DO K=1,L C(I,J)=C(I,J)+A(I,K)+B(K,J) )0 2& Œ& ùú Œ!0 0Œ1". 0 $!1 Œ +2." 2 1#!21 MATMUL )Œ&" Œ.!.2& C=MATMUL(A,B) ù212! 3 ".. ò12& )2 #0. #Œ 1 # ! 3 2 #Œ.. ù )20 Œ! *0. $!1 Œ 1 #0 2 Faddeva - Leverrier / Œ # /02. Œ.!.2& A 0 = 0 0 = 1 a B 0 = I n 53

54 A = Trace( A ) 1 AB 0 a 1 = 1 1 B1 = A1 + a1i n... A Trace( A ) n = ABn 1 a n n n n n n = n B = A + a I.212! 3 "Œ.." 2)20. /02..Œ) 2 2*Œ A B = a 1 n 1 PROGRAM INVERSE IMPLICIT NONE REAL, DIMENSION(:,:), ALLOCATABLE :: A,AI,B INTEGER, DIMENSION(:,:), ALLOCATABLE :: I1 REAL :: AII,S INTEGER :: I,J,N PRINT*,'N=' READ*,N ALLOCATE ( A(N,N), AI(N,N), B(N,N), I1(N,N) ) n ù!$ Œ 1 2& Œ.!.2!& READ(*,*) ((A(I,J),J=1,N), I=1,N) DO I=1,N DO J=1,N IF (I==J) THEN I1(I,J)=1 ELSE I1(I,J)=0 END IF B=I1 üœ.% 2" Œ.!.Œ& /./.1." 3!" DO I=1,N 54

55 AI=MATMUL(A,B) S=0 DO J=1,N S=S+AI(J,J) AII=-S/I IF (I==N) CYCLE B=AI+(AII*I1) ü31.œ 20012& print*,' ' IF (AII==0) THEN PRINT*,'The matrix is singular' ELSE B=-B*(1/AII) DO I=1,N WRITE(*,*) (B(I,J), J=1,N) END IF END.212! 3 "Œ..". Œ! *10. #Œ #!21 LINRG 2"..2" " IMSL Œ # 1# /0*0 2 Fortran Power Station. CALL LINRG (N, A,, AINV, ) C Print results CALL WRRRN ('AINV', N, N, AINV,, 0) #.!210" ". 2 $0!1) Œ& þ Fortran /.20. 1* 1#.!210& #Œ0*#&. 2 0Œ00!.1. 2& 12 $0& Œ& )Œ&" 0/.0 12 Œ! *0 0)22. 55

56 .!.2& Œ.!.2 #0 2 1*2 Œ0!!.3 0ŒŒ 1#.!210& 0!11)20!0" Œ! 3!0". 2 Œ! 1*2. 2& 1#.!210&.#2+ Œ!0.!0.0".Œ) 2 manual 2" Fortran.2 01&.2& help Œ # 1# /0*0 2 Œ0! 2" Fortran Power Station. õ. ALL 3!.1 0!!.3! 1/!0. ) $0. 2 #Œ... Œ * 2 1#0! /)22. Œ # Œ0!!302..Œ) 2 3!.1 Œ!/ $//$!. $0 &".Œ (. ) $0. 2 # Œ )$/6( /.3!02 ù 3!.1! 1/!0. Œ.Œ) ) $0. 2 # Œ... Œ 0 2 1#0! /)22. Œ # Œ0!!302..Œ) 2 3!.1 Œ!/ AA!. $0 &".Œ 201. TRUE. Œ.Œ) $0. 2 # Œ FALSE /.3!02 COUNT 3!.1 Œ 0 2 Œ " 2& 12 $0&Œ #. Œ * Œ. /)22. Œ # Œ0!!302..Œ) 2 3!.1 Œ!/ COUNT(A!. #Œ 10 2 Œ " 2& $0& 2 # Œ.. ù TRANSPOSE(). Œ..) Œ ! 3 0)" /1/12.2 # Œ.. Œ!/ TRANSPOSE(A #Œ ! 3 2 # ù û!.12!)22..!.30 Œ!)!.. Œ #. /$02. &" 01 /. Œ.. ù2.1" #$0.. #Œ 0 2 Œ.. 2 2*Œ 0.!0. e =10 6. e A = I n + 1 1! A + 1 2! A 2 + 0&1 ù.2!20 12 Œ.!/ /!.12!)22.,# #0 0Œ1" )2 0Œ2!0Œ2" Œ!0" Œ& 0. Œ!)101.3.!01 - Œ.Œ.1.1)" MUTMUL). e A.Œ) 56

57 !.2. 2.)1" 0.#2! # Œ.!/0.. /..12 * 2..20Œ+#..2+.+".. Œ # 0$ #$0.. #Œ 12 * 2. 0". 1 ")! "Œ #0$0 0.2" 1 ")! "2" 2" " )! " 2" 2" /.2"0" *20! 1 )!.+"..2"0" 0 2!)20! 1 )! *.2" &" Œ! " 2 1 )! 10 3 #1. 10!,. Œ!Œ0.!1 #0. /12.2 Œ.. STUDENTS Œ ". Œ0!$ Œ+#. 2& /12.2 Œ.. LESSONS Œ ". Œ0!$0 2. ).2. 2&.2&. 2 ". /1/12.2 Œ.. GRADES 12 Œ. 2 Œ 02 *2.. 2 #.2 ÿ12. J üœ1". $!0.12 *0. /12.2 Œ... 2 #" 1 #" )! #" 2&.2+ STUDMO )! LESMO.!)!... PROGRAM STUDENTSGR IMPLICIT NONE CHARACTER*20, DIMENSION(:), ALLOCATABLE :: STUDENT,LESSON CHARACTER*20 :: ST INTEGER, DIMENSION( :, :), ALLOCATABLE :: GRADE REAL, DIMENSION(:), ALLOCATABLE :: STUDMO, LESMO,G INTEGER :: I,J,M,N REAL :: MAX,MIN,SM,S PRINT*,'No. of lessons :' READ*,M PRINT*, 'No. of students :' READ*,N 57

58 ALLOCATE( STUDENT(N), LESSON(M), GRADE(N,M), STUDMO(N), LESMO(M), G(M) ) ùù+þ ù,þù DO I=1,M PRINT*,I,' LESSON=' READ*,LESSON(I) ùù+þ ÿüÿ ù,þ DO I=1,N PRINT*,'STUDENT NAME=' READ*,STUDENT(I) DO J=1,M PRINT*,LESSON(J), 'GRADE=' READ*,GRADE(I,J) PRINT*,' ' +ÿ ü ù,þ PRINT*,'MEANS OF STUDENTS' DO I=1,N STUDMO(I)=0 DO J=1,M STUDMO(I)=STUDMO(I)+GRADE(I,J) STUDMO(I)=STUDMO(I)/M PRINT*,STUDENT(I),' MEAN=',STUDMO(I) +ÿ ü ù,þù PRINT*,'MEANS OF LESSON' DO J=1,M ùÿ ùþ 58

59 S=0 LESMO(J)=0 DO I=1,N LESMO(J)=LESMO(J)+GRADE(I,J) S=S+LESMO(J) LESMO(J)=LESMO(J)/M PRINT*,LESSON(J),' MEAN=',LESMO(J) PRINT*,'MEAN OF CLASS =',S/M +ÿ ü+ù ü ü MAX=MAXVAL(STUDMO) PRINT*,'MAXIMUM MEAN OF STUDENTS =',MAX DO I=1,N IF (MAX==STUDMO(I)) THEN PRINT*,STUDENT(I) END IF +ÿ ÿ ü ü MIN=MINVAL(STUDMO) PRINT*,'MINIMUM MEAN OF STUDENTS =',MIN DO I=1,N IF (MIN==STUDMO(I)) THEN PRINT*,STUDENT(I) END IF ùÿþþ ü -,ÿù üÿù ü DO I=1,N-1 DO J=I+1,N IF (STUDMO(I)<STUDMO(J)) THEN ST=STUDENT(I) ; G=GRADE(I,:) ; SM=STUDMO(I) 59

60 STUDENT(I)=STUDENT(J) ; GRADE(I,:)=GRADE(J,:) ; STUDMO(I)=STUDMO(J) STUDENT(J)=ST ; GRADE(J,:)=G ; STUDMO(J)=SM END IF DO I=1,N PRINT*,STUDENT(I),STUDMO(I) END PROGRAM STUDENTSGR û!.12!)22. 2 %.Œ 310& 0&! *0 12)$ #" { O j : j = 1,2,..., m}. 12!.2" { S i : i = 1,2,..., n} Œ 0" #Œ) #Œ 00" Œ.)220" { 0 1:1 i n,1 j m} ÿ1$*0 )2 p ij m O j j= 1 = 1 þ. )1 2& 12!.2+ Si 02. 1#! 2." 2" Œ 1)220" V i = m j= 1 O j p ij. i = 1,2,..., n.!.30 Œ!)!.. Œ #. /$02. 2 Œ.. Œ. 22&. 2. )1 0 12)$ #.Œ) 2 $! #$0. 03)1 #Œ " !.2" !.2.!.2!10" ) #"." " Œ!.Œ) 0 $!1 Œ 1 0)" Œ...!&2" 2 0.#2) 1 #.!0. 2. /0/. Œ.!.Œ&.Œ). 3!!Œ0 2. /0/..#2..Œ 0#2 * Œ! 2. $!1 Œ 1& 60

61 ù.œ21 0. õ$ª. 12" /* 0!&210". Œ!Œ " 2 Œ.. 0.Œ" 02.2" þ 20$.# Œ #Œ )22. 2 # Œ!!.2 " 1 # +. Œ.!/0. $!0.. #Œ 1& 2 1 )!.!+ þ.œ ! ÿª #0Œ+". #Œ 1& 2 1 )! $&!" 2 0. Œ.. PROGRAM EXAMPLE IMPLICIT NONE INTEGER :: I REAL :: S,X,MO S=0 DO I=1,5 READ*,X S=S+X MO=S/10 PRINT*, 1 " )! " 0. :,MO END 2. " / # Œ... Œ!Œ0.!0" 2 12.!) 12 $0& Œ # Œ!0". $!1 Œ 10" +. Œ.!/0.. &. #Œ 1& 2 2#Œ.Œ)1 0)" Œ #".!+ Œ # &. 2 Œ 02 * Œ! Œ... Œ!Œ0. &.Œ) Œ!. 1*.1 2 Œ... Œ!Œ0. Œ 1& 12 $!12 2 # Œ!!.2 " Œ ".!+ Œ #. $!1 Œ 1& !1& 2 Œ. # 0 / #2).!) ò." " 2!)Œ " 0Œ#1" 0.. $!1 Œ 1& /#.) Œ.. 2 Œ0!Œ2&1.#2!& 2 Œ.. 0.!$" ALLOCATABLE Œ!/ INTEGER, DIMENSION (:), ALLOCATABLE :: A 2 1#$0.. 21&.Œ) 2 $! !+10.2 Œ " 2& 12 $0& Œ #. $!1 Œ 10 12&.. /+1& 2 / # Œ.. Œ #&. $!1 Œ 1& Œ!/ 61

62 READ*,N ALLOCATE ( A(N) ) 3. ò00 2 /02 2 #Œ !. ".. $0 0Œ0!10 2. )!. 2" /12.1" 2 #Œ.. +. Œ.!/0. 12 Œ!)!.. REAL A(10) DO I=1,9 A(I+2)=I-2 Œ.!.2!+ )2.ÿ. Œ!Œ0 1 2 # Œ.. ù. Œ! Œ." # $0!120. $0 /12.1 #0Œ+". / #!0 " 4. ò00. 1#3&0 /02" 2" DO-CONTINUE 0 2 /02 2 # Œ /!0. 2"..*&1" ü. " 2 Œ.!.2& Œ.!/0. DO I=1,5 A(K)=K Œ!0Œ0. $& A(I)=I+1. * % 0 Œ!.2. 0Œ00!.1." 0 # Œ #" /0/ & )Œ # $!002..Œ 0#1 2& /0/ &.#2+ Œ! 2 $!1 Œ 1 2 #".). 0..Œ.!.22 $!1 Œ 1 2& /0/ & Œ.!.Œ&.Œ). 3! 0..Œ.!.22 $!1 Œ 1 1*02& / + /0/ & Œ # 2. Œ.0" Œ.0".Œ 20 * 1*020" 02.2" Œ #.2.. # Œ.!.Œ&.Œ) # þ $ #. 1#0! ).. /$ 2.. 1#0! 2*Œ /0/ & þ $!1 2& 12 $0& 2 #" /020" Œ #.! # # 0 12 $0 # Œ.. þ 0Œ#1 2& Œ! 2& Œ #.3! * Œ.0".Œ #&".Œ) 2110! !1) 2 # Œ.. 1& /& " 02 " DIMENSION), 62

63 2 01.& 2& 12 $0& 12 Œ & 2 # Œ!!.2 " 0 DATA )" Œ!!.2 " 0 READ)), 2 0Œ00!.1. 2& 12 $0& 2 #Œ.. 1) $0& 2 # Œ.. Œ # $ #. 1#0! /)22. 2) #Œ 1)" 2 #.! 1.2 " Œ #" # 1 # )! # 12 $0& Œ #. Œ * Œ. /)22. )$ 3) #Œ 1)" 2 # 0$12 #. 12 # 12 $0 # 0)" Œ.. 4) 2.)1 2& 12 $0& 0)" Œ...2.* #1. 3 #1. 10! 0 2 / 2" 3#1./." 5) 2.#2)$! 0Œ00!.1. /* Œ0!11)20!& Œ& / & 12 $0& 2 # Œ... 2&.Œ 20012& 2 # Œ!!.2 ",. Œ!Œ0 2 ". /+1 #0 )2 Œ.0" /0.Œ 20 * Œ ). 2.Œ!.2.. $!1 2 #". Œ!Œ *01. 30/+.2 1Œ.2. * 0! " 2" 02!" " 2 # þ 63

64 +ùÿ ù* #1. 10! þ10!.œ) 2!)20! Œ! " 2 0.*20! û02"..! Œ. Œ! 1/!0./ 2 1 0)" 12 $0 # 12 Œ...." ò. 1* Œ 0"! 2.. ) ).. Œ! 1/! 2../ 0 2$!1 /02+.)1 þ2 Œ $0& 10. 1#0! 10!.)1 3#1./." bubble sort) / " 2.)1".2 2 Œ. 2. 0$ $0..0. #ª 1. 3#1./0" 12.!$ 2" 12." 2& 12 $0& - #1. 10! þ10!.œ) 2 0.*20! Œ! " 2!)20! Implied do loop...*&1 0 DO Œ. Œ!0. 1#2.$0 Œ!&" )/ #0)/ #0. 02 DATA. Œ " 2& /.1210& 0)" Œ.. ò2.1 Œ " 2& 12 $0& 10 0 /12.1!3 þ Œ.. 0 " 1# ) Œ " 12 $0& *!3 Œ.0".0" 02 /.!3 64

65 ùù þüÿ ÿ ûù þÿ þ ü ü/02.œ21 û!.12!)22.".!.2& Œ.!.2 #0. 0/02 *1 2" /!.12!)22." PROGRAM MEAN-SDV! û& ! IMPLICIT NONE INTEGER :: I,N REAL :: X,S,S1,MEAN,SDV!! ü1.& Œ #".!+! READ*,N!! Œ 1)" 1 # )! #! S=0 DO I=1,N READ*,X S=S+X MEAN=S/N! Œ 1)" 2#Œ".Œ)1"! S1=0 DO I=1,N READ*,X S1=S1+(X-MEAN)^2 SDV=SQRT(S1/(N-1))! END ù #10" 2 /!.12!)22. )Œ&" Œ! 20 #0 2)20 1#$.!2!. ù Œ /0 Œ)!010". *10" 2 /!.12!)22..Œ 20* Œ)" 2" 11" 2.. /0 #0 2 /#1. 0Œ#1" 2" 0 2" &12" 0)/ #",. 2. Œ2&".). 0". 0Œ.% & loop DO-. 65

66 ùœ21 û!.12!)22." 7.2. ù /00" 2.Œ21 1#$.!2!. Œ " 2& %3& 0..!)".!. ". 1#0Œ+". Œ!Œ0. /& INTEGER. ù /00" 2".Œ.210". 2)20 2. Œ0".! !)Œ Œ # /&10" 2 Œ... $0 2 /#.2)22.. /0$20 2" 2". 2" Œ 0" 2 Œ!! #0 ) )2 /0" 2"..2. # Œ * 0.*20! $+! 12 2 # þ.œ) 2 $+! Œ # " /+.0 &",17(*(5 +. ) #"." " $!1 Œ *0 2 02,17(*(5 ù /00" 2.Œ21 0 2) ! " 1&12)",. Œ! *10 2 Œ " 2& %3&..Œ 0#20 02!3 1# 10!". 12 1#$0. 2 # Œ!!.2 " /0. 1 # Œ00!.120" $0. 2 # Œ...#2 *&".! *" Œ$ /0. Œ! *10".!0" 2 ) Œ " %3& " 2 #" %3 #" 2& 2& 10 3 #1. 10! Œ ù /00"..Œ) 2" 0Œ " / 12 2)20.Œ 20*01. ó2.. Œ! 0!+21 0.! 0Œ.% Œ..3!0 /0 / Œ)20. Œ!Œ0. $!1 Œ 0" #$0...1$ 0" 0 2 0Œ)0 0)22. ùœ21 û!.12!)22." 7.3. ù /00" 2.Œ21 $0" Œ10 2 ). Œ..".Œ) 2 12 Œ #!02. &".!. ". 1#0Œ+".!2+" $0 /010" )0" 2" 10" 2 #. 1#0Œ+" ù ñ!. 2 S Œ.!0 &" 2 )2!102. /0 2 # /./ ù /00"..Œ) 2" 0".Œ.210".Œ 20*01. 0.! 0Œ.% 12 Œ.!.2!1 2" 0)22.. Œ! 1Œ10. 66

67 ü/02.œ21 û!.12!)22." ù Œ!)200"..Œ) 2 #" Œ.!.2& /* 2!)Œ #" 2)20 1#$.!2!. $0" Œ10 2 ). 0Œ)0. Œ # 1 # " Œ+" & /0/ & 1..Œ) 2 Œ!)!.. ù Œ. *10" 2 " 2!)Œ 2)20.Œ 20* Œ.% 2" 0)22.". Œ! 1Œ10. ù Œ $.10".!%0" 2" /* Œ!+20" 02 " 2)20 /0./ #! * 10" 2 # Œ # þ. 1#0Œ+" 02 READ Œ # /&10" /0 $0 ).. 2 þ 1 " 2!)Œ " 0 implied do) CHARACTER (LEN=20), DIMENSION(5) :: PARTY REAL, DIMENSION(5) :: VOTE READ*,(PARTY(I),VOTE(I),I=1,5) 2 " 2!)Œ " 0 DO-CONTINUE) CHARACTER (LEN=20), DIMENSION(5) :: PARTY REAL, DIMENSION(5) :: VOTE DO I=1,5 READ*,PARTY(I),VOTE(I) " 2!)Œ " CHARACTER (LEN=20), DIMENSION(5) :: PARTY REAL, DIMENSION(5) :: VOTE READ*,PARTY, VOTE $Œ21 û!.12!)22." 7.5 Œ!+20" /*!." 2 # Œ!!.2 ".0. CHARACTER (LEN=15), DIMENSION(4) :: TOWN INTEGER, DIMENSION(4) :: TEMP 0+ 0Œ)00"!." Œ!0.0. TOWN û!...!!0",011. TEMP=( /10,15,14,17/) 67

68 DATA (TOWNÿÿ û!...!!0",011. DATA (TEMPÿÿ '$7$ 72:1ÿ 7(03,, û!.,011...!!0" ".!% #0 '$7$ 72:17(03 û!.,011...!!0" ù.œ21 1 #.0 12" Œ.!.Œ& Œ! 20)00" 2)20 2. Œ." Œ0!3. ù Œ /00" 2 ".Œ21 2)20.1#$0" þ.!$ Œ2. 0. /*1 ùœ+" 10&10 )2. Œ!Œ0. #Œ!$0.212 $. 02.* 2& & 12.0!+ /.! 10.!2" 02.2"..3.!2" 12.0!" 10.3.!2" 02.2" ùœ21 û!.12!)22.".2.!$ Œ.!.2! *0 )2 Œ.."..Œ Œ).!.0" 2" ^«`.!.. Œ!Œ0.!1&..!. Œ.. 0 /12.1 üœ1" Œ.!.2!+ )2 2" /..2 #0Œ+" # Œ & ÿ. 01& 2 2 -ÿ ñ!. 2 Œ!)!.. #. $0 &"0" INTEGER, DIMENSION(100) :: A DO I=1,100 A(I)=101-I ù.230!0"..œ.210" 2 Œ.!.Œ& 0!+21 1#$.!2!. ù Œ /0.230!0". 2 0Œ*10".Œ 20* Œ!.2. Œ! 11,. Œ!Œ0./+10" /.20! $. 2& 10&. 2& 2+ 2 # Œ Œ).#2). 10+0" Œ. 2 68

69 Œ.!0 Œ! # Œ.. Œ. /0*20! $!.!0" 2 0).). / Œ. 2 Œ.!0 ÿ 1 2 # Œ.. ùœ21 û!.12!)22." Œ!0" 0*.. /.Œ12+10".Œ) 2" 03.10" 2&.Œ 20012& 2 # /0*20! # Œ.!./0.2 " 2" 0)22." )2 ) " 1&12)" 2!)Œ " 0. Œ!+2 " / DO I=1,4 PRINT*,TOWN(I),TEMP(I) &.Œ 20012&. 0$0 &" 0" ûùù 10 ùúùù üü,üùÿ þ ù Œ) /00" 2 2!)Œ.#2) 2. Œ0" Œ0!3.,. Œ! *10 0Œ1" Œ! 2" 02 ".#2". $!1 Œ 10" Œ. 0Œ03./. 1& 2" 02 " WRITE üÿ,ü ùÿü ù Œ /00" 2 2!)Œ 2 # /0*20! # Œ.!./0.2 " Œ # $!1 Œ 0 2 implied do /0 0. ".!0. $!1 Œ 10" /0#02 02*Œ&1 1& 2" WRITE-FORMAT /.. WRITE(6,10) (TOWN(I),TEMP(I),I=1,4) 10 FORMAT(1X,A,5X,I4) " ûùù ùúùù üü,üùÿ þ 17 ù Œ / !0".Œ 20* /0. 0Œ )22....Œ! 1Œ10. *10"

70 ùœ21 û!.12!)22." 7.8 ù 2 Œ!+2 02!02...! ".." Œ.." 10& Œ # /$02..!.0" 2" 2" 0Œ)00" 02 " $ #0 LIST(1)=1^2-1=0 LIST(2)=2^2-1=3 LIST(3)=3^2-1=8 LIST(8)=8^2-1=63 þ 200# $0 &".Œ /0#02 02*Œ&1 2 #Œ.. LIST &" 0" ú þ Œ!+2 02!0..! J 0+ /0*20! 02!0. Œ!..2) Œ.. 10& 2 2! Œ!+2 12 $0 2 # Œ.. TIME Œ.! Œ)00" 2!0" 02 ".Œ 20 *. loop Œ # 0Œ " 2" 2 # J « &"0" +. J $ #0 ÿü ÿü / TIME(2)=1+0.5= J $ #0 ÿü ÿü / TIME(3)= =2. 1#0$ #0 &" )2 # 2 J. Œ!0 2 2 ñ!. / #!02. Œ.." TIME 0 2" 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5, 8, 8.5, 9, 9.5, 10, 10.5). þ 200# )$)0" 2" 2" 2 # Œ... 2" 2" TIME(1), TIME(5),TIME(9),TIME(13),TIME.+" 2 J #0Œ+" * 2. Œ.!.2&

71 ù!0" 2 1&12).Œ )20 1#$.!2!. Œ! $&!" Œ *. Œ 2 ù Œ.0" ".Œ 20*01..Œ+" Œ.!.2!10 Œ *.0" 2 ". 0Œ !)20!. Œ! 1$ 2.". 2!#) Œ # /020" 12 loop,.. 2." #Œ)% ) /!1 #0 2 #Œ!$0 /0 2 #. 2 2 Œ 02 * Œ #!102..!120! 2 # ùœ21 û!.12!)22."! Œ! $&!1 #0 12 0Œ#1 2 # Œ!.2 ". Œ!Œ0. Œ.!.2!1 #0 )2 1 )!.." 0. Œ!..2.!.!. Œ.." 12& ù. 0. Œ!..2)" þ0œ#1 2 # Œ!.2 " $0 &"0" ù 0!!.3 01)/ #-0)/ # ü1 / ".! Œ #. 2 Œ 02 * 12 Œ!..2) Œ.. 12& ù ò / " ú ù)! " Œ!.2 " ú.!1)" Œ.. ù ú. ü1.&.!+ 2 #Œ.. üœ0/.!.#2 /0 0. &12 0 2& Œ! 2!&. $!1 Œ 1 # READ. ú..+" 2 ÿ Œ.!0 2".Œ) 2 &" 2 0Œ..0 2 Œ.!.2& 0!0. ù 2 ùÿ.0 12 /12. >@ 02*Œ& $0 ùÿ ú..+" 2 ÿ Œ.!0 2".Œ) 2 &" 2 0Œ..0 2 Œ.!.2& 0!0. ù 2 A(I 0. 0.*20! # Œ.. /./ 2 ÿ 71

72 +!)!.. PROGRAM EYRESH! ú. 1. IMPLICIT NONE REAL, DIMENSION(35) :: A INTEGER :: I! ú. 2. READ*,(A(I),I=1,35)! ú. 3. PRINT*," ÿü ÿù ù [10,20]" DO I=1,35 IF (A(I).GE.10.AND.A(I).LE.20) THEN PRINT*,A(I) END IF! ú. 4. PRINT*,",üüÿ ÿù ù ü ÿþ >=17.5" DO I=1,35 IF (A(I).GE.17.5) THEN PRINT*,I END IF! END ùœ21 û!.12!)22." ù 0!!.3 01)/ #-0)/ # ü1 / ".! Œ #. 2 Œ 02 * 12 Œ.. ù ò / " 1 ")! "2& 12 $0& 2 # Œ.. ú ù)! " Œ!.2 " ú.!1)" 2 #Œ.. ù. 2& # Œ!!.2 " 72

73 ú. ü1.&.!+ 12 Œ.. üœ0/.!.#2 0. &12 0 2& Œ! 2!&. $!1 Œ 1 # DATA. ú. ù!$ Œ 1 2& Œ.!.2!& üœ0/ )!. $! ! 12 S 0+ 02!2" Œ #" /0 $! Œ " 2& 12 $0& 2 # Œ.. 0. ). /./.)$.#2 Œ # Œ! * Œ. 1# ú. 4..+" 2 ÿ Œ.!0 2".Œ) 2 &" 2 0Œ..0 2 Œ.!.2&. ú.. ù*10 2.! 12 S.2 ùÿ ú. ü*!01 2 #1 # )! # MO=S/30 ú. ü2#œ+& 2..Œ !)!.. PROGRAM EXAMPLE! ú. 1. IMPLICIT NONE REAL :: MO,S INTEGER, DIMENSION(30) :: A INTEGER :: I ú. A=(/20,-10,37,...,89/) ú. S=0 ú. DO I=1,30 S=S+A(I) ú. MO=S/30 ú. PRINT1 ")! "!2&.!+ MO! END 73

74 ù.230!0". 0Œ*10" 2 Œ.!.Œ& /!.12!)22. 2)20 Œ! 1 # $0" Œ10 2 ). 2" 0 /." Œ # Œ! 20 Œ.!.Œ& ù Œ Œ.!.2!10" ) &1 2& 12 $0& 2 # Œ.. $!1 Œ 10" ($'.2 2" 01".01" 2" 2" 2 # ù 1 # #& ) $0. 0)" Œ.. 0. &12 $!1 Œ * DATA $&!". 0. ". / 1 #*1 ù#2) 2.. Œ!) ù /0.230!0".02010" 1&12 2 loop 2" DO- 2)20.1#$0" 0.! 0Œ.% 12 0!3 2 #.! #. Œ! 1Œ10. # #& )2 #0.! *0 2! 1. )& 2&.!+. 1#0Œ+" /0 $ #0. 1# ùœ21 û!.12!)22." ù & 2 Œ!+2 1#!2!.!3& 2 *0! Œ # Œ& 12 ). ù#2)" 0. Œ! " 2 Œ.!) 0$12)" #.!)" 2 1#$0. 03)1 01& 2 Œ!+2 1#!2!. & 2 /0*20! 1#!2! ù.!)" Œ # Œ& 0.!)20! ".#2 *Œ #$&12 $.!2 2)20 1&.#2) Œ # $& 12 $.!2.!3& 2. *! 2 1#$0. 03)1 01& 2 /0*20! 1#!2!. & 2 2!2 1#!2! ù.!)" Œ # Œ& 0.!)20! ".#2 * Œ # $& 12 $.!2 2)20 1&.#2) Œ # $& 12 $.!2.!3& 2. *! ù /0 Œ)!010".2 *10".Œ 20*01..2 Œ!) *!. 0&!. ù Œ !0" )2 $0".!02..Œ2# 02 1% 74

75 ùœ21 û!.12!)22." 12 ù.230!0" " 0 2 Œ.!.Œ& 2!)Œ 2. Œ." Œ0!3. ù Œ / !0".1#$0" Œ!0 Œ20 2#$. #".! *"...Œ! 1Œ10.)! " 0.. *! ".. Œ!0 Œ $!) $!. 2 1#10" 75

76 ùœ21 û!.12!)22." Œ!)!.. 0. / 0.#2) 2 # Œ.!./0.2 " 2" 0)22." 0 2" 0" /* /.3!". Œ.." 0. 10&. /$02. $.!.2!0" CHARACTER, (LEN=20), DIMENSION(10) :: A 2 /$02. 0Œ1" $.!.2!0" CHARACTER, (LEN=20) :: K 2 ù #10" 2 Œ.!.Œ& /!.12!)22. 2)20 Œ! $&!" 12 1&12) /!) ù Œ / !0".Œ 20*01. Œ!)02... *!0" 0" Œ 0" Œ!Œ *.!02" 3!".. #.2. 2" ùœ21 û!.12!)22." 7.14 ù 0!!.3 01)/ #-0)/ # ü1 / " Œ " 2&.!+ 2& 0&!.3+ /.0!12&.+". 2. ).2. 2& 0&!.3+ /.0!12& $ Œ " 2& /.1+ 1#02.!1+ ò / ". Œ.!.Œ& 12 $0. 2 # Œ #1. 10! &" Œ! " 2 Œ " 2& /.1+ 1#02.!1+. 0&!.3) /.!1. ú.!/ $!,. Œ!Œ0. 03.!)1& 2 /.)! 2.)1" 0 2 Œ! *0 Œ.!/ ) /.3! )2.. $!1 Œ 1&. Œ &!.3 /.0! $ Œ " 2& /.1+ 1#02.!1+. )2...& 2" 10" 2& 12 $0& 2 # 0)" Œ / $. 12 $0. 2 # # Œ.. + ù)! " Œ!.2 " Bubble sort) 76

77 ú.!& 2 Œ.. DIAM Œ #. /0$0 2. ).2. 2& 0&!.3+ /.0!12&. NUM 2 Œ.. Œ #. /0$ $. Œ 2& /.1+ 1#02.!1+.+". 2" #Œ) Œ0" 02.2" 2 # Œ!!.2 " ú. Œ " 2& 0&!.3+ /.0!12& 0. ú. û.& 2" 2" 2& Œ& DIAM. NUM 1& 2" 02 " DATA /)2 2" 2" 2& Œ& 2" &!& 0 2& Œ! 2!& ú..+" 2 ÿ Œ.!0 2".Œ) &". - 0Œ...& 2 Œ.!.2& /./.1. ú... ü$& $0. NUM(J )Œ # 2 J Œ.!0 2".Œ) ÿ &" 0. 0.*20! 2 # NUM(I ù. 2)20.& NUMÿ. NUM(J),. 2.#2)$!..& 10". 12. DIAM(I). DIAM(J). ú. ü2#œ+& 2 #" Œ.0" DIAM. NUM. û!)!.. PROGRAM EXAMPLE6! ú. 1. IMPLICIT NONE CHARACTER, (LEN=20), DIMENSION(9) :: DIAM CHARACTER, (LEN=20) :: TEMP2 INTEGER, DIMENSION(9) :: NUM INTEGER :: I,J,N,TEMP1! ú. 2. N=9 ú. DIAM,ù þ ù ù üûÿù ü ù üûÿù û ù üûÿù þüÿ,üùÿù üüù üùûù üþ þÿù NUM=( /33,68,62,35,60,87,91,10,0/)! ú. 4. DO I=1,N-1 DO J=I+1,N IF (NUM(J)>NUM(I)) THEN 77

Goals for This Lecture:

Goals for This Lecture: Goals for This Lecture: Learn about multi-dimensional (rank > 1) arrays Learn about multi-dimensional array storage Learn about the RESHAPE function Learn about allocatable arrays & the ALLOCATE and DEALLOCATE

More information

(USE CASE MODELING) Use Case /.!.2. 2)$ 2 #use case modeling.

(USE CASE MODELING) Use Case /.!.2. 2)$ 2 #use case modeling. Mo20 Œ 1 0!Œ2+10&!1" www.di.uoa.gr/~afrodite/oo2001.html (USE CASE MODELING) 2)$ 2 #use case modeling..!10.. Œ0!!%0 2" 02 #!".Œ.210" 2 # 1#12.2 ". /+10.1.3. 1#0Œ Œ0!!.3.2 2. Œ!Œ0. 0 2 1*12.. Œ.!$0 2.2

More information

) $ G}] }O H~U. G yhpgxl. Cong

) $ G}] }O H~U. G yhpgxl. Cong » Þ åî ïî á ë ïý þý ÿ þ ë ú ú F \ Œ Œ Ÿ Ÿ F D D D\ \ F F D F F F D D F D D D F D D D D FD D D D F D D FD F F F F F F F D D F D F F F D D D D F Ÿ Ÿ F D D Œ Ÿ D Ÿ Ÿ FŸ D c ³ ² í ë óô ò ð ¹ í ê ë Œ â ä ã

More information

üœ00!.1..2 ". ù #12 ú.2.

üœ00!.1..2 . ù #12 ú.2. ü,ÿ ùûÿ ÿù ùüÿ þÿ ù,þ þù þ-ÿ þ 02.Œ2#$.)!)!.. Œ #/+ þ02! * ù#2.21 *.!." 0 ) # ù û2!." 021. ù üœ00!.1..2 ". ù #12 ú.2. ü!.1. 12. üœ &. 0. û/1& +0+! " #! #Œ2! # ù. üœ00!.1. 1.2 "..2.. " 1 0!0$)0. 0!%...

More information

SpeechViewer vs Snack: û*

SpeechViewer vs Snack: û* ü,ÿ ùûÿ ÿù ùüÿ þÿ ù,þ þù þ-ÿ þ 02.Œ2#)!)!.. Œ #/+ û2! # ) # ù ÿ&! #! ù SpeechViewer vs Snack: û* Œ.2.. 2 0Œ00!.1...#1." ü!.1. 12. üœ &. 0. û/1& +0+! " #! #Œ2! # ù. 1 üÿüüù ü :SpeechViewer 3 ü1.& 3 0!%

More information

ARRAYS COMPUTER PROGRAMMING. By Zerihun Alemayehu

ARRAYS COMPUTER PROGRAMMING. By Zerihun Alemayehu ARRAYS COMPUTER PROGRAMMING By Zerihun Alemayehu AAiT.CED Rm. E119B BASIC RULES AND NOTATION An array is a group of variables or constants, all of the same type, that are referred to by a single name.

More information

Declaration and Initialization

Declaration and Initialization 6. Arrays Declaration and Initialization a1 = sqrt(a1) a2 = sqrt(a2) a100 = sqrt(a100) real :: a(100) do i = 1, 100 a(i) = sqrt(a(i)) Declaring arrays real, dimension(100) :: a real :: a(100) real :: a(1:100)!

More information

Second Year March 2017

Second Year March 2017 Reg. No. :... Code No. 5052 Name :... Second Year March 2017 Time : 2 Hours Cool-off time : 15 Minutes Part III COMPUTER APPLICATION (Commerce) Maximum : 60 Scores General Instructions to Candidates :

More information

Pointers & Arrays. CS2023 Winter 2004

Pointers & Arrays. CS2023 Winter 2004 Pointers & Arrays CS2023 Winter 2004 Outcomes: Pointers & Arrays C for Java Programmers, Chapter 8, section 8.12, and Chapter 10, section 10.2 Other textbooks on C on reserve After the conclusion of this

More information

Bits, Bytes, and Precision

Bits, Bytes, and Precision Bits, Bytes, and Precision Bit: Smallest amount of information in a computer. Binary: A bit holds either a 0 or 1. Series of bits make up a number. Byte: 8 bits. Single precision variable: 4 bytes (32

More information

Array Processing { Part II. Multi-Dimensional Arrays. 1. What is a multi-dimensional array?

Array Processing { Part II. Multi-Dimensional Arrays. 1. What is a multi-dimensional array? Array Processing { Part II Multi-Dimensional Arrays 1. What is a multi-dimensional array? A multi-dimensional array is simply a table (2-dimensional) or a group of tables. The following is a 2-dimensional

More information

INTRODUCTION TO FORTRAN PART II

INTRODUCTION TO FORTRAN PART II INTRODUCTION TO FORTRAN PART II Prasenjit Ghosh An example: The Fibonacci Sequence The Fibonacci sequence consists of an infinite set of integer nos. which satisfy the following recurrence relation x n

More information

Module 16: Data Flow Analysis in Presence of Procedure Calls Lecture 32: Iteration. The Lecture Contains: Iteration Space.

Module 16: Data Flow Analysis in Presence of Procedure Calls Lecture 32: Iteration. The Lecture Contains: Iteration Space. The Lecture Contains: Iteration Space Iteration Vector Normalized Iteration Vector Dependence Distance Direction Vector Loop Carried Dependence Relations Dependence Level Iteration Vector - Triangular

More information

Pointers. CS2023 Winter 2004

Pointers. CS2023 Winter 2004 Pointers CS2023 Winter 2004 Outcomes: Introduction to Pointers C for Java Programmers, Chapter 8, sections 8.1-8.8 Other textbooks on C on reserve After the conclusion of this section you should be able

More information

Modules. CS2023 Winter 2004

Modules. CS2023 Winter 2004 Modules CS2023 Winter 2004 Outcomes: Modules C for Java Programmers, Chapter 7, sections 7.4.1-7.4.6 Code Complete, Chapter 6 After the conclusion of this section you should be able to Understand why modules

More information

CS , Fall 2001 Exam 2

CS , Fall 2001 Exam 2 Andrew login ID: Full Name: CS 15-213, Fall 2001 Exam 2 November 13, 2001 Instructions: Make sure that your exam is not missing any sheets, then write your full name and Andrew login ID on the front. Write

More information

Review More Arrays Modules Final Review

Review More Arrays Modules Final Review OUTLINE 1 REVIEW 2 MORE ARRAYS Using Arrays Why do we need dynamic arrays? Using Dynamic Arrays 3 MODULES Global Variables Interface Blocks Modular Programming 4 FINAL REVIEW THE STORY SO FAR... Create

More information

Chapter 01 Arrays Prepared By: Dr. Murad Magableh 2013

Chapter 01 Arrays Prepared By: Dr. Murad Magableh 2013 Chapter 01 Arrays Prepared By: Dr. Murad Magableh 2013 One Dimensional Q1: Write a program that declares two arrays of integers and fills them from the user. Then exchanges their values and display the

More information

Saini Technologies ADVANCED C PROGRAMMING WITH SAINI TECHNOLOGIES. Sushil Kumar Saini Mo.

Saini Technologies ADVANCED C PROGRAMMING WITH SAINI TECHNOLOGIES. Sushil Kumar Saini   Mo. Saini Technologies ADVANCED C PROGRAMMING WITH SAINI TECHNOLOGIES Sushil Kumar Saini Email: Sushilsaini04@gmail.com Mo. 9896470047 Integer Array int a[]=12,34,54,45,34,34; printf("%d",a[0]); printf(" %d",a[1]);

More information

Lecture 5: Matrices. Dheeraj Kumar Singh 07CS1004 Teacher: Prof. Niloy Ganguly Department of Computer Science and Engineering IIT Kharagpur

Lecture 5: Matrices. Dheeraj Kumar Singh 07CS1004 Teacher: Prof. Niloy Ganguly Department of Computer Science and Engineering IIT Kharagpur Lecture 5: Matrices Dheeraj Kumar Singh 07CS1004 Teacher: Prof. Niloy Ganguly Department of Computer Science and Engineering IIT Kharagpur 29 th July, 2008 Types of Matrices Matrix Addition and Multiplication

More information

SC13 GPU Technology Theater. Accessing New CUDA Features from CUDA Fortran Brent Leback, Compiler Manager, PGI

SC13 GPU Technology Theater. Accessing New CUDA Features from CUDA Fortran Brent Leback, Compiler Manager, PGI SC13 GPU Technology Theater Accessing New CUDA Features from CUDA Fortran Brent Leback, Compiler Manager, PGI The Case for Fortran Clear, straight-forward syntax Successful legacy in the scientific community

More information

Allocating Storage for 1-Dimensional Arrays

Allocating Storage for 1-Dimensional Arrays Allocating Storage for 1-Dimensional Arrays Recall that if we know beforehand what size we want an array to be, then we allocate storage in the declaration statement, e.g., real, dimension (100 ) :: temperatures

More information

High Performance Fortran http://www-jics.cs.utk.edu jics@cs.utk.edu Kwai Lam Wong 1 Overview HPF : High Performance FORTRAN A language specification standard by High Performance FORTRAN Forum (HPFF), a

More information

1 Short Answer (10 Points Each)

1 Short Answer (10 Points Each) 1 Short Answer (10 Points Each) 1. For the following one-dimensional array, show the final array state after each pass of the three sorting algorithms. That is, after each iteration of the outside loop

More information

MultiProcessing Mathematics. Or A Good Reason to Spend the Money and Buy a Multicore CPU Chip. By Brad Morantz PhD

MultiProcessing Mathematics. Or A Good Reason to Spend the Money and Buy a Multicore CPU Chip. By Brad Morantz PhD MultiProcessing Mathematics Or A Good Reason to Spend the Money and Buy a Multicore CPU Chip By Brad Morantz PhD 1 Forward Multiprocessing mathematics is not the focus of my research My research is in

More information

SHAPE Returns the number of elements in each direction in an integer vector.

SHAPE Returns the number of elements in each direction in an integer vector. Chapter 5: Arrays An advantage fortran has over other programming languages is the ease with which it handles arrays. Because arrays are so easy to handle, fortran is an ideal choice when writing code

More information

Lab #10 Multi-dimensional Arrays

Lab #10 Multi-dimensional Arrays Multi-dimensional Arrays Sheet s Owner Student ID Name Signature Group partner 1. Two-Dimensional Arrays Arrays that we have seen and used so far are one dimensional arrays, where each element is indexed

More information

Parallel Computing: Parallel Algorithm Design Examples Jin, Hai

Parallel Computing: Parallel Algorithm Design Examples Jin, Hai Parallel Computing: Parallel Algorithm Design Examples Jin, Hai School of Computer Science and Technology Huazhong University of Science and Technology ! Given associative operator!! a 0! a 1! a 2!! a

More information

7. Procedures and Structured Programming

7. Procedures and Structured Programming 7. Procedures and Structured Programming ONE BIG PROGRAM external procedure: separated small and reusable program units to conduct individual subtasks smaller main program Each program unit can be debugged

More information

ConMan. A Web based Conference Manager for Asterisk. How I Managed to get Con'd into skipping my summer vacation by building this thing

ConMan. A Web based Conference Manager for Asterisk. How I Managed to get Con'd into skipping my summer vacation by building this thing ConMan A Web based Conference Manager for Asterisk -or- How I Managed to get Con'd into skipping my summer vacation by building this thing $90503&07 $:3.74889028,-47,94708 $90503&078:3.42 Sun Labs, slide

More information

124 DISTO pro 4 / pro 4 a-1.0.0zh

124 DISTO pro 4 / pro 4 a-1.0.0zh 0 30 40 50 DISTO PD-Z01 14 DISTO pro 4 / pro 4 a-1.0.0 DISTO pro 4 / pro 4 a-1.0.0 15 16 DISTO pro 4 / pro 4 a-1.0.0 DISTO pro 4 / pro 4 a-1.0.0 17 1 PD-Z03 3 7 4 5 6 10 9 8 18 DISTO pro 4 / pro 4 a-1.0.0

More information

Columns A[0] A[0][0] = 20 A[0][1] = 30

Columns A[0] A[0][0] = 20 A[0][1] = 30 UNIT Arrays and Strings Part A (mark questions). What is an array? (or) Define array. An array is a collection of same data type elements All elements are stored in continuous locations Array index always

More information

Chapter 3. Fortran Statements

Chapter 3. Fortran Statements Chapter 3 Fortran Statements This chapter describes each of the Fortran statements supported by the PGI Fortran compilers Each description includes a brief summary of the statement, a syntax description,

More information

CSE 262 Spring Scott B. Baden. Lecture 4 Data parallel programming

CSE 262 Spring Scott B. Baden. Lecture 4 Data parallel programming CSE 262 Spring 2007 Scott B. Baden Lecture 4 Data parallel programming Announcements Projects Project proposal - Weds 4/25 - extra class 4/17/07 Scott B. Baden/CSE 262/Spring 2007 2 Data Parallel Programming

More information

APPLESHARE PC UPDATE INTERNATIONAL SUPPORT IN APPLESHARE PC

APPLESHARE PC UPDATE INTERNATIONAL SUPPORT IN APPLESHARE PC APPLESHARE PC UPDATE INTERNATIONAL SUPPORT IN APPLESHARE PC This update to the AppleShare PC User's Guide discusses AppleShare PC support for the use of international character sets, paper sizes, and date

More information

Synchronous Computation Examples. HPC Fall 2008 Prof. Robert van Engelen

Synchronous Computation Examples. HPC Fall 2008 Prof. Robert van Engelen Synchronous Computation Examples HPC Fall 2008 Prof. Robert van Engelen Overview Data parallel prefix sum with OpenMP Simple heat distribution problem with OpenMP Iterative solver with OpenMP Simple heat

More information

Programmation in Fortran

Programmation in Fortran Programmation in Fortran Adrien Poteaux CRIStAL, Université Lille Year 2017-2018 This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License. http://creativecommons.org/licenses/by-nc-sa/3.0/

More information

Introduction to Fortran95 Programming Part II. By Deniz Savas, CiCS, Shef. Univ., 2018

Introduction to Fortran95 Programming Part II. By Deniz Savas, CiCS, Shef. Univ., 2018 Introduction to Fortran95 Programming Part II By Deniz Savas, CiCS, Shef. Univ., 2018 Summary of topics covered Logical Expressions, IF and CASE statements Data Declarations and Specifications ARRAYS and

More information

Before we start - Announcements: There will be a LAB TONIGHT from 5:30 6:30 in CAMP 172. In compensation, no class on Friday, Jan. 31.

Before we start - Announcements: There will be a LAB TONIGHT from 5:30 6:30 in CAMP 172. In compensation, no class on Friday, Jan. 31. Before we start - Announcements: There will be a LAB TONIGHT from 5:30 6:30 in CAMP 172 The lab will be on pointers In compensation, no class on Friday, Jan. 31. 1 Consider the bubble function one more

More information

Make sure the version number is marked on your scantron sheet. This is Version 1

Make sure the version number is marked on your scantron sheet. This is Version 1 Last Name First Name McGill ID Make sure the version number is marked on your scantron sheet. This is Version 1 McGill University COMP 208 -- Computers in Engineering Mid-Term Examination Tuesday, March

More information

Lecture 5 C Programming Language

Lecture 5 C Programming Language Lecture 5 C Programming Language Summary of Lecture 5 Pointers Pointers and Arrays Function arguments Dynamic memory allocation Pointers to functions 2D arrays Addresses and Pointers Every object in the

More information

Synchronous Shared Memory Parallel Examples. HPC Fall 2010 Prof. Robert van Engelen

Synchronous Shared Memory Parallel Examples. HPC Fall 2010 Prof. Robert van Engelen Synchronous Shared Memory Parallel Examples HPC Fall 2010 Prof. Robert van Engelen Examples Data parallel prefix sum and OpenMP example Task parallel prefix sum and OpenMP example Simple heat distribution

More information

Arrays, Vectors Searching, Sorting

Arrays, Vectors Searching, Sorting Arrays, Vectors Searching, Sorting Arrays char s[200]; //array of 200 characters different type than class string can be accessed as s[0], s[1],..., s[199] s[0]= H ; s[1]= e ; s[2]= l ; s[3]= l ; s[4]=

More information

14 Dynamic. Matrix-chain multiplication. P.D. Dr. Alexander Souza. Winter term 11/12

14 Dynamic. Matrix-chain multiplication. P.D. Dr. Alexander Souza. Winter term 11/12 Algorithms Theory 14 Dynamic Programming (2) Matrix-chain multiplication P.D. Dr. Alexander Souza Optimal substructure Dynamic programming is typically applied to optimization problems. An optimal solution

More information

190 Lecture 14 Arrays, allocation

190 Lecture 14 Arrays, allocation 190 Lecture 14 Arrays, allocation Reading assignment: chapters. 8, 9, 10, 11, VECTORS AND ARRAYS real::v(4) means v = v 1, v 2, v 3, v 4 real::v(1:4)same thing v = v 1, v 2, v 3, v 4 real::v(0:3)means

More information

S.E. (Computer) (First Semester) EXAMINATION, 2011 DATA STRUCTURES AND ALGORITHM (2008 PATTERN) Time : Three Hours Maximum Marks : 100

S.E. (Computer) (First Semester) EXAMINATION, 2011 DATA STRUCTURES AND ALGORITHM (2008 PATTERN) Time : Three Hours Maximum Marks : 100 Total No. of Questions 12] [Total No. of Printed Pages 7 [4062]-204 S.E. (Computer) (First Semester) EXAMINATION, 2011 DATA STRUCTURES AND ALGORITHM (2008 PATTERN) Time : Three Hours Maximum Marks : 100

More information

Chapter 3. OpenMP David A. Padua

Chapter 3. OpenMP David A. Padua Chapter 3. OpenMP 1 of 61 3.1 Introduction OpenMP is a collection of compiler directives, library routines, and environment variables that can be used to specify shared memory parallelism. This collection

More information

NCS 301 DATA STRUCTURE USING C

NCS 301 DATA STRUCTURE USING C NCS 301 DATA STRUCTURE USING C Unit-1 Part-3 Arrays Hammad Mashkoor Lari Assistant Professor Allenhouse Institute of Technology www.ncs301ds.wordpress.com Introduction Array is a contiguous memory of homogeneous

More information

Synchronous Shared Memory Parallel Examples. HPC Fall 2012 Prof. Robert van Engelen

Synchronous Shared Memory Parallel Examples. HPC Fall 2012 Prof. Robert van Engelen Synchronous Shared Memory Parallel Examples HPC Fall 2012 Prof. Robert van Engelen Examples Data parallel prefix sum and OpenMP example Task parallel prefix sum and OpenMP example Simple heat distribution

More information

Ch 1. Algorithms: Efficiency, Analysis, and Order

Ch 1. Algorithms: Efficiency, Analysis, and Order Ch 1. Algorithms: Efficiency, Analysis, and Order Textbook: Foundations of Algorithms Using C++ Pseudocode by R. Neapolitan and K. Naimipour This is prepared only for the class. Algorithm? Abū ʿAbdallāh

More information

Parallelizing The Matrix Multiplication. 6/10/2013 LONI Parallel Programming Workshop

Parallelizing The Matrix Multiplication. 6/10/2013 LONI Parallel Programming Workshop Parallelizing The Matrix Multiplication 6/10/2013 LONI Parallel Programming Workshop 2013 1 Serial version 6/10/2013 LONI Parallel Programming Workshop 2013 2 X = A md x B dn = C mn d c i,j = a i,k b k,j

More information

AH Matrices.notebook November 28, 2016

AH Matrices.notebook November 28, 2016 Matrices Numbers are put into arrays to help with multiplication, division etc. A Matrix (matrices pl.) is a rectangular array of numbers arranged in rows and columns. Matrices If there are m rows and

More information

C Language Part 2 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee

C Language Part 2 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee C Language Part 2 (Minor modifications by the instructor) 1 Scope Rules A variable declared inside a function is a local variable Each local variable in a function comes into existence when the function

More information

Arrays. Arrays are of 3 types One dimensional array Two dimensional array Multidimensional array

Arrays. Arrays are of 3 types One dimensional array Two dimensional array Multidimensional array Arrays Array is a collection of similar data types sharing same name or Array is a collection of related data items. Array is a derived data type. Char, float, int etc are fundamental data types used in

More information

Chapter 4. Fortran Arrays

Chapter 4. Fortran Arrays Chapter 4. Fortran Arrays Fortran arrays are any object with the dimension attribute. In Fortran 90/95, and in HPF, arrays may be very different from arrays in older versions of Fortran. Arrays can have

More information

CS1073 Exam 3, Fall 2009 page 1. Important test instructions code fragments

CS1073 Exam 3, Fall 2009 page 1. Important test instructions code fragments CS1073 Exam 3, Fall 2009 page 1 Name (please print): Important test instructions code fragments Throughout this exam, you will be asked to write a code fragment based on certain assumptions (eg., assume

More information

High Performance Fortran. James Curry

High Performance Fortran. James Curry High Performance Fortran James Curry Wikipedia! New Fortran statements, such as FORALL, and the ability to create PURE (side effect free) procedures Compiler directives for recommended distributions of

More information

Attendance (2) Performance (3) Oral (5) Total (10) Dated Sign of Subject Teacher

Attendance (2) Performance (3) Oral (5) Total (10) Dated Sign of Subject Teacher Attendance (2) Performance (3) Oral (5) Total (10) Dated Sign of Subject Teacher Date of Performance:... Actual Date of Completion:... Expected Date of Completion:... ----------------------------------------------------------------------------------------------------------------

More information

Searching Elements in an Array: Linear and Binary Search. Spring Semester 2007 Programming and Data Structure 1

Searching Elements in an Array: Linear and Binary Search. Spring Semester 2007 Programming and Data Structure 1 Searching Elements in an Array: Linear and Binary Search Spring Semester 2007 Programming and Data Structure 1 Searching Check if a given element (called key) occurs in the array. Example: array of student

More information

Mathematics. 2.1 Introduction: Graphs as Matrices Adjacency Matrix: Undirected Graphs, Directed Graphs, Weighted Graphs CHAPTER 2

Mathematics. 2.1 Introduction: Graphs as Matrices Adjacency Matrix: Undirected Graphs, Directed Graphs, Weighted Graphs CHAPTER 2 CHAPTER Mathematics 8 9 10 11 1 1 1 1 1 1 18 19 0 1.1 Introduction: Graphs as Matrices This chapter describes the mathematics in the GraphBLAS standard. The GraphBLAS define a narrow set of mathematical

More information

D-BAUG Informatik I. Exercise session: week 5 HS 2018

D-BAUG Informatik I. Exercise session: week 5 HS 2018 1 D-BAUG Informatik I Exercise session: week 5 HS 2018 Homework 2 Questions? Matrix and Vector in Java 3 Vector v of length n: Matrix and Vector in Java 3 Vector v of length n: double[] v = new double[n];

More information

Matrix Multiplication using MPI

Matrix Multiplication using MPI Matrix Multiplication using MPI Dieter an Mey Center for Computing and Communication Aachen University of Technology anmey@rz rz.rwth-aachen.de 1 Matrix Multiplication Serial Algorithm A * B = C m l l

More information

Programming Language A

Programming Language A Programming Language A Takako Nemoto (JAIST) 12 November Takako Nemoto (JAIST) 12 November 1 / 25 From Quiz 5 // A program to print the double of the input. int no printf("input an integer: "); scanf("%d",

More information

Chapter 6 Distributed Concurrency Control

Chapter 6 Distributed Concurrency Control Chapter 6 Distributed Concurrency Control Table of Contents Serializability Theory Taxonomy of Concurrency Control Algorithms Locking-Based Concurrency Control Timestamp-Based Concurrency Control Optimistic

More information

CSCE 110 PROGRAMMING FUNDAMENTALS. Prof. Amr Goneid AUC Part 7. 1-D & 2-D Arrays

CSCE 110 PROGRAMMING FUNDAMENTALS. Prof. Amr Goneid AUC Part 7. 1-D & 2-D Arrays CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 7. 1-D & 2-D Arrays Prof. Amr Goneid, AUC 1 Arrays Prof. Amr Goneid, AUC 2 1-D Arrays Data Structures The Array Data Type How to Declare

More information

3. Repetitive Structures (Loops)

3. Repetitive Structures (Loops) 3. Repetitive Structures (Loops) We can make a program to repeat sections of statements (iterate) by using the DO loop construct. There are three forms: The DO loop with a counter, The DO-EXIT Construct

More information

Introduction to Programming with Fortran 90

Introduction to Programming with Fortran 90 Introduction to Programming with Fortran 90 p. 1/?? Introduction to Programming with Fortran 90 Array Concepts Nick Maclaren Computing Service nmm1@cam.ac.uk, ext. 34761 November 2007 Introduction to Programming

More information

MPI Programming. Henrik R. Nagel Scientific Computing IT Division

MPI Programming. Henrik R. Nagel Scientific Computing IT Division 1 MPI Programming Henrik R. Nagel Scientific Computing IT Division 2 Outline Introduction Finite Difference Method Finite Element Method LU Factorization SOR Method Monte Carlo Method Molecular Dynamics

More information

CHAPTER 3 FUZZY RELATION and COMPOSITION

CHAPTER 3 FUZZY RELATION and COMPOSITION CHAPTER 3 FUZZY RELATION and COMPOSITION Crisp relation! Definition (Product set) Let A and B be two non-empty sets, the prod uct set or Cartesian product A B is defined as follows, A B = {(a, b) a A,

More information

Cassandra: Distributed Access Control Policies with Tunable Expressiveness

Cassandra: Distributed Access Control Policies with Tunable Expressiveness Cassandra: Distributed Access Control Policies with Tunable Expressiveness p. 1/12 Cassandra: Distributed Access Control Policies with Tunable Expressiveness Moritz Y. Becker and Peter Sewell Computer

More information

Fundamental of Programming (C)

Fundamental of Programming (C) Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 8 Array typical problems, Search, Sorting Department of Computer Engineering Outline

More information

BITG 1113: Array (Part 1) LECTURE 8

BITG 1113: Array (Part 1) LECTURE 8 BITG 1113: Array (Part 1) LECTURE 8 1 1 LEARNING OUTCOMES At the end of this lecture, you should be able to: 1. Describe the fundamentals of arrays 2. Describe the types of array: One Dimensional (1 D)

More information

Debugging Program Slicing

Debugging Program Slicing Debugging Franz Wotawa Institut für Informationssysteme, Database and Artificial Intelligence Group, Technische Universität Wien Email: wotawa@dbai.tuwien.ac.at 1 What is a Slice? A Slice is a reduced

More information

CS 140 : Numerical Examples on Shared Memory with Cilk++

CS 140 : Numerical Examples on Shared Memory with Cilk++ CS 140 : Numerical Examples on Shared Memory with Cilk++ Matrix-matrix multiplication Matrix-vector multiplication Hyperobjects Thanks to Charles E. Leiserson for some of these slides 1 Work and Span (Recap)

More information

Module 18: Loop Optimizations Lecture 36: Cycle Shrinking. The Lecture Contains: Cycle Shrinking. Cycle Shrinking in Distance Varying Loops

Module 18: Loop Optimizations Lecture 36: Cycle Shrinking. The Lecture Contains: Cycle Shrinking. Cycle Shrinking in Distance Varying Loops The Lecture Contains: Cycle Shrinking Cycle Shrinking in Distance Varying Loops Loop Peeling Index Set Splitting Loop Fusion Loop Fission Loop Reversal Loop Skewing Iteration Space of The Loop Example

More information

This file contains an excerpt from the character code tables and list of character names for The Unicode Standard, Version 3.0.

This file contains an excerpt from the character code tables and list of character names for The Unicode Standard, Version 3.0. Range: This file contains an excerpt from the character code tables and list of character names for The Unicode Standard, Version.. isclaimer The shapes of the reference glyphs used in these code charts

More information

COL 100. Minor 2 Exam - Practice

COL 100. Minor 2 Exam - Practice COL 100. Minor 2 Exam - Practice Name: Entry Number: Group: Notes: Total number of questions: 4. Max Marks: 20 All answers should be written on the question paper itself. The last two sheets in the question

More information

GraphBLAS Mathematics - Provisional Release 1.0 -

GraphBLAS Mathematics - Provisional Release 1.0 - GraphBLAS Mathematics - Provisional Release 1.0 - Jeremy Kepner Generated on April 26, 2017 Contents 1 Introduction: Graphs as Matrices........................... 1 1.1 Adjacency Matrix: Undirected Graphs,

More information

Computers in Engineering. Subroutines Michael A. Hawker

Computers in Engineering. Subroutines Michael A. Hawker Computers in Engineering COMP 208 Subroutines Michael A. Hawker Subprograms Functions are one type of subprogram in FORTRAN Another type of subprogram FORTRAN allows is called a subroutine There are many

More information

Maltepe University Computer Engineering Department. BİL 133 Algoritma ve Programlama. Chapter 8: Arrays and pointers

Maltepe University Computer Engineering Department. BİL 133 Algoritma ve Programlama. Chapter 8: Arrays and pointers Maltepe University Computer Engineering Department BİL 133 Algoritma ve Programlama Chapter 8: Arrays and pointers Basics int * ptr1, * ptr2; int a[10]; ptr1 = &a[2]; ptr2 = a; // equivalent to ptr2 =

More information

Cartons (PCCs) Management

Cartons (PCCs) Management Final Report Project code: 2015 EE04 Post-Consumer Tetra Pak Cartons (PCCs) Management Prepared for Tetra Pak India Pvt. Ltd. Post Consumer Tetra Pak Cartons (PCCs) Management! " # $ " $ % & ' ( ) * +,

More information

Using the AIMMS Sparse Execution Engine

Using the AIMMS Sparse Execution Engine Using the AIMMS Sparse Execution Engine Chris Kuip AIMMS Client Support Webinar, May 8, 014 Presentation sections Introduction Sparse Execution with example Glimpse under the hood Tackling AIMMS performance

More information

Introduction to Algorithms

Introduction to Algorithms Introduction to Algorithms Dynamic Programming Well known algorithm design techniques: Brute-Force (iterative) ti algorithms Divide-and-conquer algorithms Another strategy for designing algorithms is dynamic

More information

***********PYTHON PROGRAMS FOR CLASS XI ******************** """ Program to Calculate Simple Interest """ p = eval(input("enter Principle?

***********PYTHON PROGRAMS FOR CLASS XI ********************  Program to Calculate Simple Interest  p = eval(input(enter Principle? ***********PYTHON PROGRAMS FOR CLASS XI ******************** 1. """ Program to Calculate Simple Interest """ p = eval(input("enter Principle? ")) r = eval(input("enter Rate? ")) t = eval(input("enter Time?

More information

THEORY II II. Vectorization examples. Basics: How to to calculate the performance

THEORY II II. Vectorization examples. Basics: How to to calculate the performance THEORY II II Vectorization examples Basics: How to to calculate the performance Vectorization examples v = Vector s = Scalar v = s + v v = v + v v = v + s * v s = s + v * v matrix multiply ex. 1: v = s

More information

NAG Library Routine Document F08LEF (DGBBRD)

NAG Library Routine Document F08LEF (DGBBRD) NAG Library Routine Document (DGBBRD) Note: before using this routine, please read the Users Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent

More information

A quick guide to Fortran

A quick guide to Fortran A quick guide to Fortran Sergiy Bubin Department of Physics Nazarbayev University History of Fortran One of the oldest general purpose high-level computer languages First developed in 1957 at IBM in the

More information

Arrays. CS10001: Programming & Data Structures. Pallab Dasgupta Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur

Arrays. CS10001: Programming & Data Structures. Pallab Dasgupta Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Arrays CS10001: Programming & Data Structures Pallab Dasgupta Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Array Many applications require multiple data items that have common

More information

To provide state and district level PARCC assessment data for the administration of Grades 3-8 Math and English Language Arts.

To provide state and district level PARCC assessment data for the administration of Grades 3-8 Math and English Language Arts. 200 West Baltimore Street Baltimore, MD 21201 410-767-0100 410-333-6442 TTY/TDD msde.maryland.gov TO: FROM: Members of the Maryland State Board of Education Jack R. Smith, Ph.D. DATE: December 8, 2015

More information

EE 257 Homework 3 Solutions by Ann Chen Problem 1

EE 257 Homework 3 Solutions by Ann Chen Problem 1 EE 257 Homework 3 Solutions by Ann Chen Problem 1 Our system can be written as Ax=y as stated in Lab 2 solution, problem 3. If A = U*S*V', then A'*A= V'*S^2*V and A*A'= U'*S^2*U. Therefore, we can eig(a'*a)

More information

CS , Fall 2001 Exam 2

CS , Fall 2001 Exam 2 Andrew login ID: Full Name: CS 15-213, Fall 2001 Exam 2 November 13, 2001 Instructions: Make sure that your exam is not missing any sheets, then write your full name and Andrew login ID on the front. Write

More information

(Following Paper ID and Roll No. to be filled by the student in the Answer Book)

(Following Paper ID and Roll No. to be filled by the student in the Answer Book) F:/Academic/27 Refer/WI/ACAD/10 SHRI RAMSWAROOP MEMORIAL COLLEGE OF ENGG. & MANAGEMENT PAPER ID: 1602 (Following Paper ID and Roll No. to be filled by the student in the Answer Book) Roll No. B.Tech. SEM

More information

E7 University of California, Berkeley Fall Midterm Exam 10/07/2016 version:

E7 University of California, Berkeley Fall Midterm Exam 10/07/2016 version: Name: Student ID: Midterm Exam 10/07/2016 version: 684965 UC Berkeley Honor Code: As a member of the UC Berkeley community, I act with honesty, integrity, and respect for others. On my honor, I have neither

More information

III. CLAIMS ADMINISTRATION

III. CLAIMS ADMINISTRATION III. CLAIMS ADMINISTRATION Insurance Providers: Liability Insurance: Greenwich Insurance Company American Specialty Claims Representative: Mark Thompson 142 N. Main Street, Roanoke, IN 46783 Phone: 260-672-8800

More information

Arrays. CS10001: Programming & Data Structures. Pallab Dasgupta Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur

Arrays. CS10001: Programming & Data Structures. Pallab Dasgupta Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Arrays CS10001: Programming & Data Structures Pallab Dasgupta Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur 1 Array Many applications require multiple data items that have common

More information

Personal Conference Manager (PCM)

Personal Conference Manager (PCM) Chapter 3-Basic Operation Personal Conference Manager (PCM) Guidelines The Personal Conference Manager (PCM) interface enables the conference chairperson to control various conference features using his/her

More information

AN INTRODUCTION TO FORTRAN 90 LECTURE 2. Consider the following system of linear equations: a x + a x + a x = b

AN INTRODUCTION TO FORTRAN 90 LECTURE 2. Consider the following system of linear equations: a x + a x + a x = b AN INTRODUCTION TO FORTRAN 90 LECTURE 2 1. Fortran 90. Arrays, functions and subroutines. 2. Scientific plotting. Gnuplot 1 Each coefficient and variable is a scalar. Lengthy and cumbersome! Program Scalar

More information

GPU Programming. Alan Gray, James Perry EPCC The University of Edinburgh

GPU Programming. Alan Gray, James Perry EPCC The University of Edinburgh GPU Programming EPCC The University of Edinburgh Contents NVIDIA CUDA C Proprietary interface to NVIDIA architecture CUDA Fortran Provided by PGI OpenCL Cross platform API 2 NVIDIA CUDA CUDA allows NVIDIA

More information

Computational Techniques I

Computational Techniques I Computational Techniques I Course Zero 2017-2018 Madrid Alicia Palacios, alicia.palacios@uam.es Cristina Sanz Sanz, cristina.sanz@uam.es Outline 1. Introduction: how to run, input 2. Data types 3. Declaration

More information

The Logical Solution - Digital Video Extension. DVI EXTENSION - Velocity Series

The Logical Solution - Digital Video Extension. DVI EXTENSION - Velocity Series Digital Video Extension System-3 Digital Video Extension System-3R Digital Video Extension System-3 A/V+ Digital Video Extension System-3 A/V Pro Digital Video Extension System-3R A/V+ MRTS Technology

More information