untitled

Similar documents
(Basic Theory of Information Processing) Fortran Fortan Fortan Fortan 1

1F90/kouhou_hf90.dvi

11042 計算機言語7回目 サポートページ:

. (.8.). t + t m ü(t + t) + c u(t + t) + k u(t + t) = f(t + t) () m ü f. () c u k u t + t u Taylor t 3 u(t + t) = u(t) + t! u(t) + ( t)! = u(t) + t u(

インテル(R) Visual Fortran Composer XE 2013 Windows版 入門ガイド

プラズマ核融合学会誌5月号【81-5】/内外情報_ソフト【注:欧フォント特殊!】

120802_MPI.ppt

01_OpenMP_osx.indd

2 2.1 Mac OS CPU Mac OS tar zxf zpares_0.9.6.tar.gz cd zpares_0.9.6 Mac Makefile Mekefile.inc cp Makefile.inc/make.inc.gfortran.seq.macosx make

Fortran90/95 2. (p 74) f g h x y z f x h x = f x + g x h y = f y + g y h z = f z + g z f x f y f y f h = f + g Fortran 1 3 a b c c(1) = a(1) + b(1) c(

OpenMP¤òÍѤ¤¤¿ÊÂÎó·×»»¡Ê£±¡Ë

OpenMP¤òÍѤ¤¤¿ÊÂÎó·×»»¡Ê£±¡Ë

ex01.dvi

Microsoft Word - C.....u.K...doc

Windows Cygwin Mac *1 Emacs Ruby ( ) 1 Cygwin Bash Cygwin Windows Cygwin Cygwin Mac 1 Mac 1.2 *2 ls *3 *1 OS Linux *2 *3 Enter ( ) 2

Fortran90/95 [9]! (1 ) " " 5 "Hello!"! 3. (line) Fortran Fortran 1 2 * (1 ) 132 ( ) * 2 ( Fortran ) Fortran ,6 (continuation line) 1

Pascal Pascal Free Pascal CPad for Pascal Microsoft Windows OS Pascal

ex01.dvi

all.dvi

( ) 1 Windows HTML ( ) ( ) ( ) WWW 10 ( )

nakao

Informatics 2010.key

CUDA 連携とライブラリの活用 2

xl 1 program Othello6; 2 {$APPTYPE CONSOLE} 3 uses SysUtils; 4 5 type 6 TMasuNo = 0..99; // 7 TYouso = (Soto,Kara,Kuro,Siro); // 8 TBan = array [TMasu

main.dvi

解きながら学ぶJava入門編

1.ppt

C

Informatics 2014

Microsoft Word - Sample_CQS-Report_English_backslant.doc

joho09.ppt

( ) Shift JIS ( ) ASCII ASCII ( ) 8bit = 1 Byte JIS(Japan Industrial Standard) X 0201 (X ) 2 Byte JIS ISO-2022-JP, Shift JIS, EUC 1 Byte 2 By

MPI usage

OpenMP (1) 1, 12 1 UNIX (FUJITSU GP7000F model 900), 13 1 (COMPAQ GS320) FUJITSU VPP5000/64 1 (a) (b) 1: ( 1(a))

double float

情報処理概論(第二日目)

Microsoft Word - 資料 docx

新・明解Java入門

(2-1) x, m, 2 N(m, 2 ) x REAL*8 FUNCTION NRMDST (X, M, V) X,M,V REAL*8 x, m, 2 X X N(0,1) f(x) standard-norm.txt normdist1.f x=0, 0.31, 0.5

Microsoft PowerPoint - 03_What is OpenMP 4.0 other_Jan18

Informatics 2015

フローチャートの書き方

10/ / /30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20 6. http, CGI Perl 11/27 7. ( ) Perl 12/ 4 8. Windows Winsock 12/11 9. JAV

OHP.dvi

Java Java Java Java Java 4 p * *** ***** *** * Unix p a,b,c,d 100,200,250,500 a*b = a*b+c = a*b+c*d = (a+b)*(c+d) = 225

<4D F736F F F696E74202D D F95C097F D834F E F93FC96E5284D F96E291E85F8DE391E52E >

インテル(R) Visual Fortran Composer XE

AJAN IO制御コマンド コマンドリファレンス

cpp1.dvi

応用数学特論.dvi

<リスト1> AD コンバータへのデータの出力例 NEC PC98 用 mov al,22h // CLK -> 1, CS -> 0, DI -> 0 out 32h,al // シリアル ポートにデータ出力 PC/AT 互換機用 mov al,00h // CLK -> 1 mov dx,3fb

listings-ext

Java演習(4) -- 変数と型 --

r07.dvi

(2 Linux Mozilla [ ] [ ] [ ] [ ] URL 2 qkc, nkc ~/.cshrc (emacs 2 set path=($path /usr/meiji/pub/linux/bin tcsh b

PowerPoint プレゼンテーション

ohp07.dvi

D0020.PDF

Nios® II HAL API を使用したソフトウェア・サンプル集 「Modular Scatter-Gather DMA Core」

program.dvi

情報活用資料

02_C-C++_osx.indd

XcalableMP入門

コンピュータ概論

K227 Java 2

格子点データの解析 1 月平均全球客観解析データの解析 客観解析データや衛星観測データのような格子点データは バイナリ形式のデータファイルに記録されていることが多いです バイナリ形式のデータファイルは テキスト形式の場合とは異なり 直接中身を見ることができません プログラムを書いてデータを読み出して

PC Windows 95, Windows 98, Windows NT, Windows 2000, MS-DOS, UNIX CPU

273? C

超初心者用

I httpd School of Information Science, Japan Advanced Institute of Science and Technology

/* sansu1.c */ #include <stdio.h> main() { int a, b, c; /* a, b, c */ a = 200; b = 1300; /* a 200 */ /* b 200 */ c = a + b; /* a b c */ }

FORTRAN文法の基礎

tebiki00.dvi


Microsoft Word - 03-数値計算の基礎.docx

10/ / /30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20 6. http, CGI Perl 11/27 7. ( ) Perl 12/ 4 8. Windows Winsock 12/11 9. JAV

netcdf

Intel® Compilers Professional Editions

1 1.1 C 2 1 double a[ ][ ]; 1 3x x3 ( ) malloc() 2 double *a[ ]; double 1 malloc() dou

3. :, c, ν. 4. Burgers : u t + c u x = ν 2 u x 2, (3), ν. 5. : u t + u u x = ν 2 u x 2, (4), c. 2 u t 2 = c2 2 u x 2, (5) (1) (4), (1 Navier Stokes,.,

IDL_lecture_12Jan.ppt

FORTRAN( と C) によるプログラミング 5 ファイル入出力 ここではファイルからデータを読みこんだり ファイルにデータを書き出したりするプログラムを作成してみます はじめに テキスト形式で書かれたデータファイルに書かれているデータを読みこんで配列に代入し 標準出力に書き出すプログラムを作り

n 第1章 章立ての部分は、書式(PC入門大見出し)を使います

情報活用資料

Microsoft PowerPoint - fortran2.ppt [互換モード]

1 C STL(1) C C C libc C C C++ STL(Standard Template Library ) libc libc C++ C STL libc STL iostream Algorithm libc STL string vector l

PowerPoint プレゼンテーション

RHEA key

橡vb_kikai0.PDF

ストラドプロシージャの呼び出し方

明解Javaによるアルゴリズムとデータ構造

¥×¥í¥°¥é¥ß¥ó¥°±é½¬I Exercise on Programming I [1zh] ` `%%%`#`&12_`__~~~ alse

OpenMP¤òÍѤ¤¤¿ÊÂÎó·×»»¡Ê£²¡Ë

1 1.1 C 2 1 double a[ ][ ]; 1 3x x3 ( ) malloc() malloc 2 #include <stdio.h> #include

1. 入力画面

第10回 コーディングと統合(WWW用).PDF

¥Ñ¥Ã¥±¡¼¥¸ Rhpc ¤Î¾õ¶·

D0050.PDF

PR300 電力モニタ 通信インタフェース (RS-485通信,Ethernet通信)

Transcription:

Fortran90 ( ) 17 12 29 1 Fortran90 Fortran90 FORTRAN77 Fortran90 1 Fortran90 module 1.1 Windows Windows UNIX Cygwin (http://www.cygwin.com) C\: Install Cygwin f77 emacs latex ps2eps dvips Fortran90 Intel Fortran Compiler g95 (http://g95.sourceforge.net) f90 [ $HOME/bin ( $HOME/.cshrc setenv path=($home/bin) ) ln -s $CYGWINDIR/g95 f90 ] 1.2 Linux Intel Fortran Compiler(http://www.intel.com) 1.3 Fortran90 Fortran $ EMACSDIR/20.7/lisp/progmode/f90.el 1

$HOME/.emacs in integer 1.4 A B 2 A B A B (1-1a.f90) 1: 1-1a.f90 1 program edu1 1a! program < > 2! USE ( ) 3 implicit none! 4 real ( kind=4) : : a, b, c! 5! A, B, C 4 ( ) 6! 7 read (, ) a, b! A B ( ; ) 8! (2 ) 9 c = a! C A 10 a = b! A B 11 b = c! B C A 12 write (, ) a, b! A B ( ; ) 13! 14 end program edu1 1a! end program < > > f90 1-1a.f90 >./a.out 1.0 2.0 ( ) 2.000000 1.000000 ( ) 1.5 c ( ) a b a b function subroutine function 1 subroutine subroutine (1-1b.f90) 2: 1-1b.f90 1 program edu1 1b! 2 a b 2! 1 3 implicit none! 4! 5 real ( kind=4) : : a, b! 1 2

6! function 7 read (, ) a, b! subroutine 8 9 call Swap Real ( a, b )! c a l l subroutine 10! 11 write (, ) a, b 12 13 contains! 14! c o n t a i n s 15 subroutine Swap Real ( a, b ) 16! 17 implicit none! 18! 19 real ( kind=4), intent ( inout ) : : a, b 20! a b intent 21! : 22! intent (in) : 23! intent (out) : 24! intent (inout ): 25 real ( kind=4) : : c 26 27 c = a 28 a = b 29 b = c 30 31 end subroutine Swap Real 32 33 end program edu1 1b 1-1a.f90 1.6 1-1b.f90 subroutine module 1-1c.f90 1-1d.f90 3: 1-1c.f90 1 module algorithm! module <module > 2! use 3 implicit none! 4 5 private! p r i v a t e module 6! 7 public :: Swap Real! p u b l i c 8! 9 contains! function subroutine 10 11 subroutine Swap Real ( a, b ) 12! 1 1b. f90 subroutine 13 implicit none 14 real ( kind=4), intent ( inout ) : : a, b 15 real ( kind=4) : : c 16 17 c = a 18 a = b 19 b = c 20 21 end subroutine Swap Real 22 23 end module algorithm! end module <module > 3

4: 1-1d.f90 1 program edu1 1d 2 3 use algorithm, only : Swap Real 4! use <module >,only : ( function subroutine ) 5! module public 6 implicit none 7 8 real ( kind=4) : : a, b, c 9 10 read (, ) a, b 11 12 call Swap Real ( a, b ) 13 14 write (, ) a, b 15 16 end program edu1 1d f90 -c -module -I > mkdir include > f90 -c -module./include 1-1c.f90 > ls * 1-1c.f90 1-1d.f90 1-1c.o (.o ) include: algorithm.mod ( ) > f90 -I./include 1-1d.f90 1-1c.o >./a.out 1.0 2.0 ( ) 2.000000 1.000000 ( ) > mkdir lib > f90 -c -module./include -o lib/1-1c.o 1-1c.f90 > ar rcv lib/libbasic.a lib/*.o (.a lib.a > ranlib lib/libbasic.a ) 1-1c.f90 algorithm.mod -L (.a) -l.a lib > f90 -I./include 1-1d.f90 -L./lib -lbasic >./a.out 1.0 2.0 ( ) 2.000000 1.000000 ( ) 4

1.7 4 1 8 1 8 interface Swap public (1-1e.f90) 5: 1-1e.f90 1 module algorithm 2 3 use typedef, only : byte, short, long, llong, & 4 & float, double, ldble 5 implicit none 6 private 7 8! module p r o c e d u r e 9! Swap 10 interface Swap 11 module procedure & 12 & Swap byte, Swap short, Swap long, Swap llong, & 13 & Swap float, Swap double, Swap ldble 14 end i n t e r f a c e 15 16 public :: Swap 17 contains 18!! 19 subroutine Swap byte ( a, b ) 20 21 implicit none 22 integer (byte), intent ( inout ) : : a, b 23 integer (byte) :: c 24 25 c = a 26 a = b 27 b = c 28 29 end subroutine Swap byte 30!! 31 subroutine Swap short ( a, b ) 32 33 implicit none 34 integer (short), intent ( inout ) : : a, b 35 integer (short) :: c 36 37 c = a 38 a = b 39 b = c 40 41 end subroutine Swap short 42!! 43 subroutine Swap long ( a, b ) 44 45 implicit none 46 integer ( long ), intent ( inout ) : : a, b 47 integer ( long ) : : c 48 49 c = a 5

50 a = b 51 b = c 52 53 end subroutine Swap long 54!! 55 subroutine Swap llong ( a, b ) 56 57 implicit none 58 integer ( llong ), intent ( inout ) : : a, b 59 integer ( llong ) :: c 60 61 c = a 62 a = b 63 b = c 64 65 end subroutine Swap llong 66!! 67 subroutine Swap float ( a, b ) 68 69 implicit none 70 real (float), intent ( inout ) : : a, b 71 real (float) :: c 72 73 c = a 74 a = b 75 b = c 76 77 end subroutine Swap float 78!! 79 subroutine Swap double ( a, b ) 80 81 implicit none 82 real ( double ), intent ( inout ) : : a, b 83 real ( double ) : : c 84 85 c = a 86 a = b 87 b = c 88 89 end subroutine Swap double 90!! 91 subroutine Swap ldble ( a, b ) 92 93 implicit none 94 real ( ldble ), intent ( inout ) : : a, b 95 real ( ldble ) :: c 96 97 c = a 98 a = b 99 b = c 100 101 end subroutine Swap ldble 102 103 end module algorithm 1 8 (0/1 1 ) 32 (1-1f.f90) 1 module typedef 2 3 implicit none 4 5 private 6: 1-1f.f90 6

6! public 7 integer ( kind=4), parameter, public :: & 8 & byte = selected int kind (2), & 9 & short = selected int kind (4), & 10 & long = selected int kind (9), & 11 & llong = selected int kind (18), & 12! selected int kind ( ) = 13 & float = selected real kind (6), & 14 & double= selected real kind (15), & 15 & ldble = selected real kind (33) 16! selected real kind ( ) = 17 18 end module typedef > f90 -c -module./include -o lib/1-1f.o 1-1f.f90 > f90 -c -module./include -o lib/1-1e.o 1-1e.f90 > rm lib/libbasic.a > ar rcv lib/libbasic.a lib/1-1{e,f}.o > ranlib lib/libbasic.a > f90 -I./include 1-1g.f90 -L./lib -lbasic >./a.out 1.0 2.0 ( ) 2.000000 1.000000 ( ) 1.8 (1-1h.f90) 7: 1-1h.f90 1 module algorithm 2 3 use typedef, only : byte, short, long, llong, & 4 & float, double, ldble 5 implicit none 6 private 7 interface Swap 8 module procedure & 9 & Swap byte, Swap short, Swap long, Swap llong, & 10 & Swap float, Swap double, Swap ldble, & 11 & Swap complex, Swap dcomplex, & 12 & Swap L1, Swap L2, Swap L4, & 13 & Swap char 14 end i n t e r f a c e 15 public :: Swap 16 17 contains 18!! 19 subroutine Swap byte ( a, b ) 20 21 implicit none 22 integer (byte), intent ( inout ) : : a, b 23 integer (byte) :: c 7

24 25 c = a 26 a = b 27 b = c 28 29 end subroutine Swap byte 30!! 31 subroutine Swap short ( a, b ) 32 33 implicit none 34 integer (short), intent ( inout ) : : a, b 35 integer (short) :: c 36 37 c = a 38 a = b 39 b = c 40 41 end subroutine Swap short 42!! 43 subroutine Swap long ( a, b ) 44 45 implicit none 46 integer ( long ), intent ( inout ) : : a, b 47 integer ( long ) : : c 48 49 c = a 50 a = b 51 b = c 52 53 end subroutine Swap long 54!! 55 subroutine Swap llong ( a, b ) 56 57 implicit none 58 integer ( llong ), intent ( inout ) : : a, b 59 integer ( llong ) :: c 60 61 c = a 62 a = b 63 b = c 64 65 end subroutine Swap llong 66!! 67 subroutine Swap float ( a, b ) 68 69 implicit none 70 real (float), intent ( inout ) : : a, b 71 real (float) :: c 72 73 c = a 74 a = b 75 b = c 76 77 end subroutine Swap float 78!! 79 subroutine Swap double ( a, b ) 80 81 implicit none 82 real ( double ), intent ( inout ) : : a, b 83 real ( double ) : : c 84 85 c = a 86 a = b 87 b = c 88 89 end subroutine Swap double 90!! 91 subroutine Swap ldble ( a, b ) 8

92 93 implicit none 94 real ( ldble ), intent ( inout ) : : a, b 95 real ( ldble ) :: c 96 97 c = a 98 a = b 99 b = c 100 101 end subroutine Swap ldble 102!! 103 subroutine Swap complex ( a, b ) 104 105 implicit none 106 complex ( float 2), intent ( inout ) : : a, b 107 complex ( float 2) : : c 108 109 c = a 110 a = b 111 b = c 112 113 end subroutine Swap complex 114!! 115 subroutine Swap dcomplex ( a, b ) 116 117 implicit none 118 complex ( double 2), intent ( inout ) : : a, b 119 complex ( double 2) : : c 120 121 c = a 122 a = b 123 b = c 124 125 end subroutine Swap dcomplex 126!! 127 subroutine Swap L1 ( a, b ) 128 129 implicit none 130 logical (1), intent ( inout ) : : a, b 131 logical (1) :: c 132 133 c = a 134 a = b 135 b = c 136 137 end subroutine Swap L1 138!! 139 subroutine Swap L2 ( a, b ) 140 141 implicit none 142 logical (2), intent ( inout ) : : a, b 143 logical (2) :: c 144 145 c = a 146 a = b 147 b = c 148 149 end subroutine Swap L2 150!! 151 subroutine Swap L4 ( a, b ) 152 153 implicit none 154 logical (4), intent ( inout ) : : a, b 155 logical (4) :: c 156 157 c = a 158 a = b 159 b = c 9

160 161 end subroutine Swap L4 162!! 163 subroutine Swap char ( a, b ) 164 165 implicit none 166 character ( ), intent ( inout ) : : a, b! 167 168 character ( len (a)) :: c 169! character ( ) : : 170! len ( ) a c 171 integer ( long ) : : n 172 173! a b 174 if ( len (a) < len (b) ) then 175! 176 print, ( WARNING ) CHAR LEN(A) > LEN(B). 177 178! ( : ) 179! repeat (, ) 180! a b 181 b( len (a)+1:len (b)) = repeat (, len (b) len (a)) 182 183! b a 184 else if ( len (a) > len (b) ) then 185 print, ( WARNING ) CHAR LEN(A) > LEN(B). 186 a(len (b)+1:len (a)) = repeat (, len (a) len (b)) 187 end i f 188 189 n = min( len (a),len (b))! a b 190 c(1:n) = a(1:n) 191 a(1:n) = b(1:n) 192 b(1:n) = c(1:n) 193 194 end subroutine Swap char 195!! 196 197 end module algorithm 2 2 if if 8: if 1 if ( 1 ) then! 1 2 1 3 else if ( 2 ) then! 2 ( ) 4 2 5 else! 6 7 end i f (1-1i.f90) 9: 1-1i.f90 1 program edu1 1i 2 3 use typedef, only : byte, short, long, llong, & 4 & float, double, ldble 5 use algorithm, only : Swap 6 7 implicit none 10

8 9 character (9) :: a = abcdefghi 10 character (3) :: b = jkl 11 12 call Swap ( a, b ) 13 14 write (, ) a, b 15 16 end program edu1 1i > f90 -c -module./include -o lib/1-1f.o 1-1f.f90 > f90 -c -module./include -o lib/1-1h.o 1-1h.f90 > rm lib/libbasic.a > ar rcv lib/libbasic.a lib/1-1{f,h}.o > ranlib lib/libbasic.a > f90 -I./include 1-1i.f90 -L./lib -lbasic >./a.out (*** WARNING ***) CHAR LEN(A) > LEN(B). ( ) jkl abc ( ) 1.9 (do loop) 1, 2,... 2 ( ) 2 2 1 1 2 1 1 1 a(1,1), a(2,1), a(3,1),... a(1), a(2),... a(1:n) a a(2:10:3) a(2), a(5), a(8) 3 (2 10 3 ) do loop 10: do 1! i 2 do i = 1, n! i=1 end d o i=2 3! i= n 4 end do! i =1,n,3 3 i (1-1j.f90) 11: 1-1j.f90 1 program edu1 1j 2 use typedef, only : byte, short, long, llong, & 11

3 & float, double, ldble 4 implicit none 5! 6 integer ( long ), parameter :: n = 3 7! 8! (/,,..., /) 9 real ( float ) :: a(n) = (/ 1.0, 2.0, 3.0 /), & 10 & b(n) = (/ 3.0, 2.0, 1.0 /) 11! 12 call Swap Real Array1 ( a, b, n ) 13! 14 print, a 15 print, b 16! 17 contains 18!! 19 subroutine Swap Real Array1 ( a, b, n ) 20! 21 implicit none 22! subroutine 23 integer ( long ), intent ( in ) : : n 24 real (float), intent ( inout ) : : a(n), b(n) 25! 26 integer ( long ) :: i! 27 real (float) :: c! 28! 29 do i = 1, n! i=1 n 30 c = a( i ) 31 a( i ) = b( i ) 32 b( i ) = c 33 end do 34! 35 end subroutine Swap Real Array1 36!! 37 end program edu1 1j 2 12: 1-1j.f90 1 subroutine Swap Real Array3 ( a, b ) 2! 3 use algorithm, only : Swap! module a l g o r i t h m 4! 5 implicit none 6! (:) 2 (:,:) 7 real (float), intent ( inout ) : : a (:), b (:) 8! 9 integer ( long ) :: i, n 10! 11 n = min( size (a), size (b) )! size ( )= 12 do i = 1, n! swap 13 call Swap ( a(i), b(i) ) 14 end do 15! 16! A B 17 if ( size (a) > size (b) ) then 18! 19 print, ( WARNING ) SIZE (A) > SIZE (B). 20! a n 0.0 float ( f l o a t 21! 0.0) 22 a(n+1:size (a)) = 0.0 float 23! B A 24 else if ( size (b) > size (a) ) then 25 print, ( WARNING ) SIZE (B) > SIZE (A). 12

26 b(n+1:size (b)) = 0.0 float 27 end i f 28! 29 end subroutine Swap Real Array3 interface swap algorithm.f90 1.10 ( ) ( ) ( ) 13: 1-1j.f90 1 subroutine Swap Real Array4 ( a, b ) 2! 3 implicit none 4 real (float), intent ( inout ) : : a (:), b (:) 5! c ( ) 6! 1 7 real (float), allocatable :: c(:) 8! 9 integer ( long ) :: n 10 n = min( size (a), size (b) ) 11 allocate ( c(n) )! n 12! 13 c(1:n) = a(1:n) 14 a(1:n) = b(1:n) 15 b(1:n) = c(1:n) 16! 17! 18! (= ) 19 deallocate ( c ) 20! 21! if 1.11 2 2 2 (1-1k.f90) 14: 1-1k.f90 1 program edu1 1k 2 use typedef, only : byte, short, long, llong, & 3 & float, double, ldble 4 implicit none 5 integer ( long ), parameter :: n1 = 3, n2 = 2 6 7 integer ( long ) :: i1, i2 13

8 real ( float ) :: a(n1,n2), b(n1,n2) 9 10! 2 reshape 11! reshape ( 1 ) 12 a(:,:) = reshape( & 13 & (/ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 /), & 14 & (/ n1, n2 /) ) 15 b(:,:) = reshape( & 16 & (/ 6.0, 5.0, 4.0, 3.0, 2.0, 1.0 /), & 17 & (/ n1, n2 /) ) 18 19 call Swap float2 ( a, b ) 20 21 contains 22!! 23 subroutine Swap float2 ( a, b ) 24 25 use algorithm, only : Swap 26 27 implicit none 28 real (float), intent ( inout ) :: a(:,:), b(:,:) 29 30 integer ( long ) :: i1, i2, n1, n2 31 logical (4), allocatable :: la (:,:), lb (:,:) 32 33! size (, dim= ) 34 n1 = min( size (a,dim=1), size (b,dim=1) ) 35 n2 = min( size (a,dim=2), size (b,dim=2) ) 36 do i2 = 1, n2 37 do i1 = 1, n1 38 call Swap ( a ( i1, i 2 ), b ( i1, i 2 ) ) 39 end do 40 end do 41 42! 43 allocate ( la ( size (a,dim=1),size (a,dim=2)) ) 44! a (1:ni,1:n2). false. 45 la (:,:) =. true. 46 la (1:n1,1:n2) =. false. 47 where ( la (:,:) )! where( ) 48 a(:,:) = 0.0 float! 49 end where! a(1:n1,1:n2) 50! 0.0 51 52! b 53 allocate ( lb ( size (b,dim=1), size (b,dim=2)) ) 54 lb (:,:) =. true. 55 lb(1:n1,1:n2) =. false. 56 where ( lb (:,:) ) 57 b(:,:) = 0.0 float 58 end where 59 60 deallocate ( la, lb )! la, l b 61 62 end subroutine Swap float2 63!! 64 end program edu1 1k 65!! where /= 15: where 1 where ( 1 )! 1 2 1! 14

3 else where ( 2 )! 2 4 2! 5 else where! 6! 7 end where 1.12 (1-1m.f90) > f90 -c -module./include -o lib/1-1m.o 1-1m.f90 > rm lib/libbasic.a > ar rcv lib/libbasic.a lib/1-1{f,m}.o > ranlib lib/libbasic.a 1 2 ascii 3 1-1n.dat ascii 48 48 > cat 1-1n.dat 1.0 2.0 3.0 4.0 5.0 6.0 6.0 5.0 4.0 3.0 2.0 1.0 > ls -al -rw-rw-r-- 1 user user 48 10 9 14:23 1-1n.dat > hexdump 0000000 2e31 2030 2e32 2030 2e33 2030 2e34 2030 0000010 2e35 2030 2e36 0a30 2e36 2030 2e35 2030 0000020 2e34 2030 2e33 2030 2e32 2030 2e31 0a30 hexdump 0/1 4 16 2 1 000010 31 16*3+1=47 ascii 1 2e 0a 48 6 4 11 6 4 1-1l.f90 1-1n.dat 2 (1-1l.f90) 15

16: 1-1l.f90 1 program edu1 1l 2 use typedef, only : byte, short, long, llong, & 3 & float, double, ldble 4 use algorithm, only : Swap 5 implicit none 6 integer ( long ), parameter :: n1 = 3, n2 = 2 7 8 real ( float ) :: a(n1,n2), b(n1,n2) 9 10! 10 5 11! 6 12 open ( 10, file = 1 1n. dat )! ASCII 13 read ( 10, ) a! a 14 read ( 10, ) b! b 15 close ( 10 )! 16 17 write ( 6, ) a! print 18 write ( 6, ) b 19 20 call Swap ( a, b ) 21 22! 23 open ( 20, file = 1 1o. dat, & 24 & form= unformatted, &! 25 & access = sequential, &! 26 & action = readwrite )! 27 write ( 20 ) a! 20 28 write ( 20 ) b 29 close ( 20 ) 30 31 end program edu1 1l > f90 -I./include 1-1l.f90 -L./lib -lbasic >./a.out 1.000000 2.000000 3.000000 4.000000 5.000000 6.000000 6.000000 5.000000 4.000000 3.000000 2.000000 1.000000 > ls -al 1-1o.dat -rw-rw-r-- 1 user user 64 10 9 14:23 1-1o.dat > cat 1-1o.dat?@?@@@@@??@@@@?@?@ > hexdump 1-1o.dat 0000000 0018 0000 0000 40c0 0000 40a0 0000 4080 0000010 0000 4040 0000 4000 0000 3f80 0018 0000 0000020 0018 0000 0000 3f80 0000 4000 0000 4040 0000030 0000 4080 0000 40a0 0000 40c0 0018 0000 0018 0000 (0/1) 0000 0018 10 24 a ( ) 24 0018 0000 1 4 16

1-1o.dat 1-1p.f90 1-1q.dat (1-1p.f90) 17: 1-1k.f90 1 program edu1 1p 2 use typedef, only : byte, short, long, llong, & 3 & float, double, ldble 4 use algorithm, only : Swap 5 implicit none 6 integer ( long ), parameter :: n1 = 3, n2 = 2 7 real ( float ) :: a(n1,n2), b(n1,n2) 8 9 open ( 10, file = 1 1o. dat, form= unformatted ) 10 read ( 10 ) a 11 read ( 10 ) b 12 close ( 10 ) 13 write ( 6, ) a! print 14 write ( 6, ) b 15 call Swap ( a, b ) 16 17 open ( 10, file = 1 1q. dat, & 18 & form = binary, &! Intel F 9 0 19! unformatted 20 & access = direct, &! 21 & action = readwrite, &! 22 & recl = 24 )! 23! 1 24 write ( 10, rec = 1 ) a! 1 25 write ( 10, rec = 2 ) b! 2 26 close ( 10 ) 27 28 end program edu1 1p > f90 -I./include 1-1p.f90 -L./lib -lbasic >./a.out 6.000000 5.000000 4.000000 3.000000 2.000000 1.000000 1.000000 2.000000 3.000000 4.000000 5.000000 6.000000 > ls -al 1-1q.dat -rw-rw-r-- 1 inaz inaz 48 10 9 14:52 1-1q.dat > hexdump 1-1q.dat 0000000 0000 3f80 0000 4000 0000 4040 0000 4080 0000010 0000 40a0 0000 40c0 0000 40c0 0000 40a0 0000020 0000 4080 0000 4040 0000 4000 0000 3f80 0000 3f80 1-1o.dat 6.0 17

1.13 1-1o.dat? 4 4 6 4 32 2 ( + + ) 1 (1-1r.f90) 18: 1-1r.f90 1 program edu1 1r 2 use typedef, only : byte, short, long, llong, & 3 & float, double, ldble 4 use algorithm, only : Swap 5 implicit none 6 integer ( long ), parameter :: n1 = 3, n2 = 2 7 real ( float ) :: a(n1,n2), b(n1,n2) 8 9 integer ( long ) :: i, i1, i2, irec = 0, n 10 character (4) :: c 11 12! 1 recl 1 13 open ( 10, file = 1 1o. dat, form= binary, & 14 & access = direct, recl = 1) 15 16 do i = 1, 4 17 irec = irec + 1! 1 18 read ( 10, rec = irec ) c(i:i)! i 19 end do 20 21! transfer (, ) 22 n = transfer ( c(1:4), 0 long ) 23 print, n 24 do i2 = 1, n2 25 do i1 = 1, n1 26 do i = 1, 4 27 irec = irec + 1 28 read ( 10, rec = irec ) c(i:i)! i 29 end do 30 a(i1, i2) = transfer ( c(1:4), 0.0 float ) 31 end do 32 end do 33 print, a 34 do i = 1, 4 35 irec = irec + 1 36 read ( 10, rec = irec ) c(i:i)! i 37 end do 38 n = transfer ( c(1:4), 0 long ) 39 print, n 40 41! b 42 close ( 10 ) 43 44 end program edu1 1r > f90 -I./include 1-1r.f90 -L./lib -lbasic >./a.out 24 18

6.000000 5.000000 4.000000 3.000000 2.000000 1.000000 24 1.14 ( + + ) (1-1s.f90) 19: 1-1s.f90 1 program edu1 1s 2 use typedef, only : byte, short, long, llong, & 3 & float, double, ldble 4 use algorithm, only : Swap 5 implicit none 6 7 integer ( long ), parameter :: n1 = 3, n2 = 2 8 type dat 9 integer ( long ) :: nstart 10 real (float) :: dat(n1,n2) 11 integer ( long ) : : nend 12 end type dat 13 type (dat) :: sa, sb 14 15! 4 + 4 6+ 4 16! r e c l 32 17 open ( 10, file = 1 1o. dat, form= binary, & 18 & access = direct, recl = 24+8 ) 19 read ( 10, rec = 1 ) sa 20 read ( 10, rec = 2 ) sb 21 close ( 10 ) 22 23 print, s a%n s t a r t, s a%dat ( :, : ), s a%nend 24 print, sb%n s t a r t, sb%d a t ( :, : ), sb%nend 25 26 end program edu1 1s > f90 -I./include 1-1s.f90 -L./lib -lbasic >./a.out] 24 6.000000 5.000000 4.000000 3.000000 2.000000 1.000000 24 24 1.000000 2.000000 3.000000 4.000000 5.000000 6.000000 24 2 2m 1980 1 1999 12 19

(1-2) (1-3) (1-4) (1-5) (1-6) (1-7) 2 (2-1) 1 (2-2) (2-3) SOR (2-4) QR (3-1) (3-2) (3-3) (3-4) 5 (3-5) (3-6) (3-7) (4-1) 2 PDF (4-2) 1 (4-3) 20