Fortran 2003+2008 概略 by hbf25307

VIEWS: 26 PAGES: 28

									Fortran 2003+2008 概略
2008-11-14
高田正之
江戸川大学
IPSJ/ITSCJ/SC 22/Fortran WG
(1) 派生型(F95:構造型)の機能拡充
• パラメタ化された派生型
    成分の種別、長さ、形状を選べる
• 成分の参照許可属性の混在
• 非公開の型の公開要素
• 構造体構成子の改善
• 後始末処理(finalizer)
(2) オブジェクト指向プログラミング
• データ抽象化の機能拡充
     型を拡張して別の型を定義できる
• 多相的実体(polymorphic)
     変数の型を実行時に変えられる
• 実行時の型の割付け
• SELECT TYPE構文
     実行時の型に依存して制御を選択できる
• 型束縛手続
(3) ASSOCIATE構文
• 複雑な式や実体を単純な名前で表せる
(4) データ操作の拡充
•   割付け成分
•   無指定型パラメタ
•   VOLATILE属性
•   配列構成子の明示型指定
•   ポインタ引数のINTENT指定
•   下限指定によるポインタ代入
•   ポインタの次元数再配置
•   文字型の組込み関数 MAX・MIN
•   複素定数の拡充
(5) 入出力機能の拡張
• 非同期転送操作
     入出力転送中でもデータ処理が継続できる
• 流れ探査
     記録構造を参照せずにファイル探査できる
• 派生型の利用者定義転送操作
• 書式変換中の利用者定義の丸め制御
• FLUSH文
• 事前接続される装置の名前付き定数
• 入出力文における指定子の充実
• 入出力誤りメッセージの参照
(6) 手続ポインタ
(7) 有効範囲の拡張
• 利用者定義演算子の名前変更の機能
    より広いデータ抽象の支援
• 引用仕様本体における親子結合の制御
(8) IEEE 754 の例外・算術
• IEC 国際規格を支援するという観点
(9) 言語Cとの相互利用可能性
• 多くのライブラリ 及び 言語Cによって用意され
  る低水準機能の利用を容易にすることができ、
  言語Cで書かれたプログラムからFortranライブ
  ラリを簡単に利用することができる
(10) 国際化
• ISO 10646
• 数値入出力における小数点の選択
(11) OS との一体化の拡張
• コマンドライン引数
• 環境変数
• 処理系の誤りメッセージの参照
Excerpts from John Reid’s paper at:
ftp://ftp.nag.co.uk/sc22wg5/N1701-N1750/N1735.pdf
See also:
http://www.nag.co.uk/SC22WG5/
Submodules
• Submodules allow the modularization of a large
  module, possible in Fortran 2003 only by breaking
  the module into several modules, which exposes the
  internal structure and risks name clashes.
• Submodules also allow a module to be separated
  into the part that defines its interface and the rest.
• The submodules may be changed and recompiled
  without the recompilation of program units that use
  it. In this way, time-consuming compilation
  cascades for very large programs are avoided.
Submodules: example
• module points
    type :: point
       real :: x,y
    end type point
    interface
       real module function point_dist (a,b)
          type(point), intent(in) :: a,b
       end function point_dist
    end interface
  end module points

• A submodule has access via host association to
  entities in the module.
Submodules : example
• submodule (points) points_a
  contains
    real module function point_dist (a,b)
      type(point), intent(in) :: a,b
      point_dist = sqrt((a%x-b%x)**2+(a%y-b%y)**2)
    end function point_dist
  end submodule points_a

• The interface specified in the submodule must be
  the same as that specified in the interface block.
  There is also a syntax that avoids the redeclaration
  altogether
Coarrays
• Coarrays provide a simple extension to Fortran for
  parallel programming on distributed-memory and
  shared-memory architectures.
• The program is treated as if it were replicated a fixed
  number of times and each replication is called an
  image. An additional set of subscripts provide
  access from any image to data on another image.
• Care has been taken to allow compilers to optimize
  both execution on an image and communication
  between images.
Performance enhancements
• do concurrent (i=1:m)
     a(k+i) = a(k+i) + factor*a(l+i)
  end do
• real, pointer, contiguous :: ptr(:)
  integer, contiguous, dimension(:,:) : ary
• F2003 allows:
  matrix(1:n,1:n) => base(:)
  This is extended to simply contiguous targets of
  rank greater than one:
  matrix(1:n,1:n) => base(:,:,i:j,2)
Data enhancements
• The maximum rank has been increased to 15.
• selected_int_kind(18)
• type entry
     real :: value
     integer :: index
     type(entry), allocatable :: next
  end type entry
• How to add a new entry at the top of the stack:
  type (entry), allocatable :: top
  top = entry ( new_value, new_index, top )
Data enhancements
• integer, parameter :: order(0:*) = [0, 1, 2, 3]
• type (entry), target :: bottom
  type (entry), pointer :: top => bottom
• forall ( integer(long) :: i = 1:very_large, j = 1:2 )
• allocate (poly, mold=t2)
Accessing data objects
• complex impedance, x(n), y(n)
  impedance%re = 1.0
  x%im = 2.0*y%im
• function storage(key) result(loc)
  integer, intent(in) :: key
  real, pointer :: loc
  loc=>...
  end function
Input/Output
• integer f
  open (newunit = f, file = 'factor', status = 'old')
• g0 edit descriptor:
  automatically choose a suitable field width.
• write( 10, '( "iarray =", *( i0, :, ","))') iarray
• Recursive input/output
Execution control
• block
    integer :: I
    real :: a(n)
    do i = 1,n
       a(i) = I
    end do
       :
  end block
Execution control
• outer: block
     do i = 1, num_in_set
        if ( x == a(i) ) exit outer
     end do
     call r
  end block outer
• The optional stop code on a stop statement has
  been extended to any integer or character
  initialization expression.
Intrinsic procedures for bit processing
•   Bit sequence comparison
•   Combined shifting
•   Counting bits
•   Masking bits
•   Shifting bits
•   Merging bits
•   Bit transformational functions
Intrinsic procedures and modules
•   Storage size
•   Selecting a real kind
•   Hyperbolic intrinsic functions
•   Bessel functions
•   Arc tangent function
•   Error and gamma functions
•   Euclidean vector norms
•   Parity
•   Execute command line
•   Location of maximum or minimum value in an array
•   Find location in an array
•   Constants and procedures in ISO_Fortran_env
Programs and procedures
• Empty contains section
• Internal procedure as an actual argument
• Generic resolution by pointer or allocatable
  attribute
• Null pointer as a missing dummy argument
• Elemental procedures that are not pure
• Entry statement becomes obsolescent

								
To top