100% found this document useful (4 votes)
49 views

[FREE PDF sample] Fortran 2018 with Parallel Programming 1st Edition Subrata Ray (Author) ebooks

Parallel

Uploaded by

roreryaggyzw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (4 votes)
49 views

[FREE PDF sample] Fortran 2018 with Parallel Programming 1st Edition Subrata Ray (Author) ebooks

Parallel

Uploaded by

roreryaggyzw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

Download the Full Version of textbook for Fast Typing at textbookfull.

com

Fortran 2018 with Parallel Programming 1st Edition


Subrata Ray (Author)

https://textbookfull.com/product/fortran-2018-with-parallel-
programming-1st-edition-subrata-ray-author/

OR CLICK BUTTON

DOWNLOAD NOW

Download More textbook Instantly Today - Get Yours Now at textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Introduction to Programming with Fortran Chivers

https://textbookfull.com/product/introduction-to-programming-with-
fortran-chivers/

textboxfull.com

Introduction to Programming with Fortran Ian Chivers

https://textbookfull.com/product/introduction-to-programming-with-
fortran-ian-chivers/

textboxfull.com

Modern Fortran Explained: Incorporating Fortran 2018


Michael Metcalf

https://textbookfull.com/product/modern-fortran-explained-
incorporating-fortran-2018-michael-metcalf/

textboxfull.com

Modern Fortran: Building Efficient Parallel Applications


1st Edition Milan Curcic

https://textbookfull.com/product/modern-fortran-building-efficient-
parallel-applications-1st-edition-milan-curcic/

textboxfull.com
Modern Fortran Building efficient parallel applications
1st Edition Milan Curcic

https://textbookfull.com/product/modern-fortran-building-efficient-
parallel-applications-1st-edition-milan-curcic-2/

textboxfull.com

Parallel Programming with Co-Arrays Robert W. Numrich

https://textbookfull.com/product/parallel-programming-with-co-arrays-
robert-w-numrich/

textboxfull.com

Pro Tbb: C++ Parallel Programming with Threading Building


Blocks 1st Edition Michael Voss

https://textbookfull.com/product/pro-tbb-c-parallel-programming-with-
threading-building-blocks-1st-edition-michael-voss/

textboxfull.com

Network and Parallel Computing 15th IFIP WG 10 3


International Conference NPC 2018 Muroran Japan November
29 December 1 2018 Proceedings Feng Zhang
https://textbookfull.com/product/network-and-parallel-computing-15th-
ifip-wg-10-3-international-conference-npc-2018-muroran-japan-
november-29-december-1-2018-proceedings-feng-zhang/
textboxfull.com

Parallel Programming Concepts and Practice 1st Edition


Bertil Schmidt

https://textbookfull.com/product/parallel-programming-concepts-and-
practice-1st-edition-bertil-schmidt/

textboxfull.com
Fortran 2018 with
Parallel Programming
Fortran 2018 with
Parallel Programming

Subrata Ray
CRC Press
Taylor & Francis Group
6000 Broken Sound Parkway NW, Suite 300
Boca Raton, FL 33487-2742

© 2020 by Taylor & Francis Group, LLC


CRC Press is an imprint of Taylor & Francis Group, an Informa business

No claim to original U.S. Government works

Printed on acid-free paper

International Standard Book Number-13: 978-0-367-21843-0 (Hardback)

This book contains information obtained from authentic and highly regarded sources. Reasonable efforts have been made to
publish reliable data and information, but the author and publisher cannot assume responsibility for the validity of all materials
or the consequences of their use. The authors and publishers have attempted to trace the copyright holders of all material
reproduced in this publication and apologize to copyright holders if permission to publish in this form has not been obtained.
If any copyright material has not been acknowledged please write and let us know so we may rectify in any future reprint.

Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted, or utilized
in any form by any electronic, mechanical, or other means, now known or hereafter invented, including photocopying,
microfilming, and recording, or in any information storage or retrieval system, without written permission from the publishers.

For permission to photocopy or use material electronically from this work, please access www.copyright.com (http://www.
copyright.com/) or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400.
CCC is a not-for-profit organization that provides licenses and registration for a variety of users. For organizations that have
been granted a photocopy license by the CCC, a separate system of payment has been arranged.

Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are used only for
identification and explanation without intent to infringe.

Library of Congress Control Number: 2019946209


Visit the Taylor & Francis Web site at
http://www.taylorandfrancis.com

and the CRC Press Web site at


http://www.crcpress.com
This work is dedicated to the memory of

Professor Chanchal Kumar Majumdar

and

Professor Suprokash Mukherjee


Contents

Preface ......................................................................................................................................... xxiii


Acknowledgments ..................................................................................................................... xxv
Author ........................................................................................................................................ xxvii

1. Preliminaries ...........................................................................................................................1
1.1 Character Set .................................................................................................................. 2
1.2 Identifiers .......................................................................................................................3
1.3 Intrinsic Data Types ......................................................................................................4
1.4 Constants and Variables...............................................................................................4
1.5 Integer Constants .......................................................................................................... 4
1.6 Real Constants ...............................................................................................................5
1.7 Double Precision Constants.........................................................................................6
1.8 Complex Constants .......................................................................................................6
1.9 Double Precision Complex Constants ........................................................................ 7
1.10 Quadruple (Quad) Precision Constants ..................................................................... 7
1.11 Logical Constants ..........................................................................................................7
1.12 Character Constants .....................................................................................................7
1.13 Literal Constants ...........................................................................................................8
1.14 Variables .........................................................................................................................8
1.15 Variable Declarations....................................................................................................8
1.16 Meaning of a Declaration.............................................................................................9
1.17 Assignment Operator ................................................................................................. 10
1.18 Named Constants........................................................................................................ 10
1.19 Keywords ..................................................................................................................... 11
1.20 Lexical Tokens ............................................................................................................. 12
1.21 Delimiters ..................................................................................................................... 12
1.22 Source Form ................................................................................................................. 13
1.23 Free Form ..................................................................................................................... 13
1.24 Continuation of Character Strings............................................................................ 15
1.25 Structure of a Program ............................................................................................... 16
1.26 IMPLICIT NONE......................................................................................................... 16
1.27 IMPLICIT ...................................................................................................................... 17
1.28 Rules of IMPLICIT ...................................................................................................... 18
1.29 Type Declarations ....................................................................................................... 18
1.30 Comments on IMPLICIT Statement ......................................................................... 19
1.31 PROGRAM Statement ................................................................................................ 19
1.32 END Statement ............................................................................................................ 19
1.33 Initialization................................................................................................................. 20
1.34 Number System ........................................................................................................... 20
1.35 Binary Numbers .......................................................................................................... 21
1.36 Octal Numbers ............................................................................................................ 21
1.37 Hexadecimal Numbers .............................................................................................. 21
1.38 Initialization Using DATA Statement ...................................................................... 21
1.39 BOZ Numbers ..............................................................................................................22

vii
viii Contents

1.40 Integer Variables and BOZ Numbers .......................................................................22


1.41 Executable and Non-Executable Statements ........................................................... 23
1.42 INCLUDE Directive .................................................................................................... 23
1.43 Statement Ordering .................................................................................................... 24
1.44 Processor Dependencies ............................................................................................ 24
1.45 Compilation and Execution of Fortran Programs .................................................. 24

2. Arithmetic, Relational and Logical Operators and Expressions ................................ 25


2.1 Arithmetic Operators ................................................................................................. 25
2.2 Arithmetic Expressions .............................................................................................. 26
2.3 Assignment Sign ......................................................................................................... 26
2.4 Rules for Arithmetic Expressions ............................................................................. 27
2.5 Precedence of the Arithmetic Operators ................................................................. 28
2.6 Multiple Statements .................................................................................................... 29
2.7 Mixed-Mode Operations ............................................................................................ 30
2.8 Integer Division ........................................................................................................... 32
2.9 List-Directed Input/Output Statement .................................................................... 33
2.10 Variable Assignment—Comparative Study ............................................................ 35
2.11 Library Functions........................................................................................................ 35
2.12 Memory Requirement of Intrinsic Data Types ....................................................... 36
2.13 Programming Examples ............................................................................................ 36
2.14 BLOCK Construct ....................................................................................................... 37
2.15 Assignment of BOZ Numbers ................................................................................... 38
2.16 Initialization and Library Functions ........................................................................ 39
2.17 Relational Operators ................................................................................................... 39
2.18 Precedence Rule of Relational Operators ................................................................ 40
2.19 Relational Operators and Complex Numbers......................................................... 40
2.20 Logical Operators ........................................................................................................ 40
2.21 Precedence Rule of Logical Operators .....................................................................42
2.22 Precedence of the Operators Discussed So Far ......................................................42

3. Branch and Loop Statements..............................................................................................43


3.1 GO TO Statement ........................................................................................................43
3.2 Block IF .........................................................................................................................44
3.3 IF-THEN-ELSE .............................................................................................................44
3.4 ELSE-IF ......................................................................................................................... 46
3.5 Nested IF ...................................................................................................................... 48
3.6 Nested IF without ELSE ............................................................................................. 49
3.7 Rules of Block IF .......................................................................................................... 49
3.8 CASE Statement........................................................................................................... 51
3.9 CASE DEFAULT .......................................................................................................... 53
3.10 CASE and LOGICAL ..................................................................................................54
3.11 Nested CASE................................................................................................................54
3.12 EXIT Statement and CASE .........................................................................................54
3.13 Rules of CASE .............................................................................................................. 55
3.14 Programming Example .............................................................................................. 56
3.15 DO Statement ............................................................................................................... 57
3.16 Negative Increment..................................................................................................... 59
3.17 Infinite Loop ................................................................................................................ 59
Contents ix

3.18 EXIT Statement ............................................................................................................ 60


3.19 CYCLE Statement ........................................................................................................ 60
3.20 DO WHILE................................................................................................................... 61
3.21 Nested DO ....................................................................................................................63
3.22 CYCLE, EXIT and the Nested Loop .........................................................................65
3.23 Termination of DO Loop ............................................................................................ 66
3.24 Rules of DO Statement ............................................................................................... 66
3.25 Remark about Loop Statements ................................................................................ 70

4. Handling of Characters ....................................................................................................... 71


4.1 Assignment .................................................................................................................. 71
4.2 Concatenation .............................................................................................................. 71
4.3 Collating Sequence ..................................................................................................... 72
4.4 Character Comparison ............................................................................................... 73
4.5 Comparison of Character Strings ............................................................................. 73
4.6 Lexical Comparison Functions ................................................................................. 74
4.7 Length of a String ....................................................................................................... 75
4.8 Trimming and Adjusting a String ............................................................................ 75
4.9 REPEAT ........................................................................................................................ 76
4.10 Character–Integer Conversion ..................................................................................77
4.11 Character Substring ....................................................................................................77
4.12 Programming Examples ............................................................................................ 79
4.13 Library Functions INDEX, SCAN and VERIFY ..................................................... 81
4.14 CASE and CHARACTER ...........................................................................................84
4.15 NEW LINE ................................................................................................................... 85

5. Precision and Range............................................................................................................. 87


5.1 SELECTED_INT_KIND .............................................................................................. 88
5.2 Precision and Range of Real Numbers ....................................................................90
5.3 SELECTED_REAL_KIND .......................................................................................... 90
5.4 SELECTED_CHAR_KIND ......................................................................................... 92
5.5 KIND Intrinsic ............................................................................................................. 92
5.6 KIND and COMPLEX Constants .............................................................................. 94
5.7 KIND and Character Handling Intrinsics............................................................... 94
5.8 Quadruple (Quad) Precision ..................................................................................... 95
5.9 DOUBLE COMPLEX................................................................................................... 95
5.10 IMPLICIT and SELECTED KIND ............................................................................. 96
5.11 Type Parameter Inquiry ............................................................................................. 97
5.12 Named Kind Constants.............................................................................................. 97

6. Array and Array-Handling Intrinsics .............................................................................. 99


6.1 Array Declaration ....................................................................................................... 99
6.2 Multidimensional Array .......................................................................................... 101
6.3 Storage Arrangement of Two dimensional Array ................................................ 101
6.4 Characteristics of Array ........................................................................................... 102
6.5 Array Constants ........................................................................................................ 104
6.6 Initialization............................................................................................................... 105
6.7 Initialization with DATA Statement ....................................................................... 105
6.8 Repeat Factor and Initialization .............................................................................. 106
x Contents

6.9 DATA Statement and Implied DO Loop ................................................................ 107


6.10 Named Array Constant ............................................................................................ 108
6.11 Character Variable and Array Constructors ......................................................... 108
6.12 Array Elements .......................................................................................................... 109
6.13 Array Assignment and Array Arithmetic ............................................................. 109
6.14 Array Section ............................................................................................................. 111
6.15 Array Input ................................................................................................................ 114
6.16 Array Output ............................................................................................................. 114
6.17 Programming Examples .......................................................................................... 115
6.18 Array Bounds ............................................................................................................ 119
6.19 LBOUND .................................................................................................................... 120
6.20 UBOUND ................................................................................................................... 120
6.21 RESHAPE ................................................................................................................... 121
6.22 Vector Subscripts ....................................................................................................... 124
6.23 WHERE Statement .................................................................................................... 126
6.24 DO CONCURRENT.................................................................................................. 129
6.25 FORALL Statement ................................................................................................... 132
6.26 Rules for FORALL ..................................................................................................... 133
6.27 EQUIVALENCE Statement ...................................................................................... 134
6.28 EQUIVALENCE and Character Variables ............................................................. 136
6.29 Programming Examples .......................................................................................... 138
6.30 Array-Handling Intrinsics ....................................................................................... 141
6.31 Maximum, Minimum and Finding Location ....................................................... 141
6.32 SUM and PRODUCT ................................................................................................ 146
6.33 Handling of Arrays of More than Two Dimensions ............................................ 147
6.34 DOT_PRODUCT ........................................................................................................ 149
6.35 Matrix Multiplication ............................................................................................... 149
6.36 TRANSPOSE of a Matrix ......................................................................................... 150
6.37 Array Shift.................................................................................................................. 151
6.38 Euclidian Norm ......................................................................................................... 155
6.39 Parity of Logical Array ............................................................................................. 156
6.40 Locating and Counting Array Elements................................................................ 156
6.41 Packing and Unpacking ........................................................................................... 158
6.42 MERGE ....................................................................................................................... 161
6.43 REDUCE ..................................................................................................................... 162

7. User Defined Data Type .................................................................................................... 163


7.1 Derived Type ............................................................................................................. 163
7.2 Assignment ................................................................................................................ 164
7.3 Initialization............................................................................................................... 165
7.4 Named Constant and Derived Type ...................................................................... 165
7.5 Keywords and Derived Types ................................................................................. 166
7.6 IMPLICIT and Derived Types ................................................................................. 166
7.7 Input and Output ...................................................................................................... 166
7.8 Substrings................................................................................................................... 167
7.9 Array and Derived Types ........................................................................................ 168
7.10 Nested Derived Types .............................................................................................. 169
7.11 Arrays as Elementary Items .................................................................................... 170
7.12 SEQUENCE ................................................................................................................ 171
Contents xi

7.13 Derived Types and EQUIVALENCE Statement.................................................... 171


7.14 Parameterized Derived Types ................................................................................. 172

8. Format Statement ................................................................................................................ 175


8.1 Edit Descriptors ......................................................................................................... 175
8.2 Input/Output Lists.................................................................................................... 176
8.3 General Form of Format Statement ........................................................................ 177
8.4 Carriage Control........................................................................................................ 178
8.5 Summary of Edit Descriptors.................................................................................. 178
8.6 Descriptor for Integer ............................................................................................... 178
8.7 Descriptors for Real Number .................................................................................. 180
8.8 Insufficient Width ..................................................................................................... 183
8.9 Format and List Elements ........................................................................................ 184
8.10 Descriptors for Complex Number .......................................................................... 185
8.11 Descriptors for BOZ Numbers ................................................................................ 185
8.12 Descriptor for Logical ............................................................................................... 186
8.13 Descriptor for Character .......................................................................................... 186
8.14 General Edit Descriptor ........................................................................................... 187
8.15 Unlimited Repeat Factor .......................................................................................... 189
8.16 Scale Factor................................................................................................................. 189
8.17 Leading Signs ............................................................................................................ 190
8.18 Tab Descriptors .......................................................................................................... 191
8.19 X Descriptor ............................................................................................................... 192
8.20 Slash Descriptor ........................................................................................................ 192
8.21 Embedded Blanks ..................................................................................................... 193
8.22 Apostrophe and Quote Descriptors ....................................................................... 194
8.23 Colon Descriptor ....................................................................................................... 195
8.24 Decimal Editing ........................................................................................................ 195
8.25 Rounding Modes ....................................................................................................... 195
8.26 Variable Format ......................................................................................................... 196
8.27 Memory to Memory Input/Output ........................................................................ 197
8.28 NAMELIST ................................................................................................................. 197
8.29 NAMELIST Comment .............................................................................................. 201
8.30 Rules for NAMELIST ................................................................................................ 201
8.31 Processor Dependency ............................................................................................. 202

9. Auxiliary Storage ................................................................................................................ 203


9.1 Record ......................................................................................................................... 203
9.2 File ............................................................................................................................... 203
9.3 Formatted Record...................................................................................................... 203
9.4 Unformatted Record ................................................................................................. 204
9.5 Endfile Record ........................................................................................................... 204
9.6 Sequential File ........................................................................................................... 204
9.7 Direct File ................................................................................................................... 204
9.8 Stream File.................................................................................................................. 204
9.9 Unit Number .............................................................................................................. 204
9.10 Scratch and Saved Files ............................................................................................ 205
9.11 OPEN, CLOSE and INQUIRE Statements ............................................................. 205
9.12 Optional Specifiers.................................................................................................... 205
xii Contents

9.13 Kind Type Parameters of Integer Specifiers........................................................ 215


9.14 ENDFILE Statement................................................................................................ 215
9.15 REWIND Statement ................................................................................................ 215
9.16 BACKSPACE Statement .......................................................................................... 215
9.17 Data Transfer Statement ......................................................................................... 216
9.18 READ/WRITE Statement ...................................................................................... 216
9.19 Asynchronous Input/Output ................................................................................ 219
9.20 FLUSH Statement .................................................................................................... 221
9.21 Rules for Input/Output Control List .................................................................... 221
9.22 IS_IOSTAT_END .....................................................................................................222
9.23 IS_IOSTAT_EOR ......................................................................................................222
9.24 Examples of File Operations .................................................................................222
9.25 Stream Input/Output ............................................................................................. 224
9.26 Storage Unit of Stream Input/Output .................................................................. 224
9.27 Stream Input/Output Type....................................................................................225
9.28 Stream File Opening...............................................................................................225
9.29 Unformatted Stream File .......................................................................................225
9.30 Formatted Stream I/O ............................................................................................ 226
9.31 Rule of Thumb ......................................................................................................... 227
9.32 Recursive Input/Output ........................................................................................ 228
9.33 Processor Dependencies ........................................................................................ 228

10. Numerical Model ................................................................................................................ 229


10.1 Numerical Model for Integers ............................................................................... 229
10.2 BASE ......................................................................................................................... 229
10.3 Largest Integer......................................................................................................... 230
10.4 DIGITS for Integers ................................................................................................. 230
10.5 RANGE for Integers ............................................................................................... 230
10.6 Real Numbers .......................................................................................................... 231
10.7 FRACTION and EXPONENT................................................................................ 231
10.8 MAXEXPONENT and MINEXPONENT ............................................................ 231
10.9 Largest and Smallest Real Numbers .................................................................... 232
10.10 DIGITS for Real Numbers...................................................................................... 232
10.11 RANGE for Real Numbers .................................................................................... 232
10.12 PRECISION .............................................................................................................. 233
10.13 SCALE....................................................................................................................... 233
10.14 SET_EXPONENT .................................................................................................... 233
10.15 EPSILON .................................................................................................................. 233
10.16 NEAREST .................................................................................................................234
10.17 SPACING ..................................................................................................................234
10.18 RRSPACING.............................................................................................................234
10.19 Programming Example .......................................................................................... 235

11. Library Functions ............................................................................................................... 237


11.1 Generic Names ........................................................................................................ 237
11.2 Intrinsic Procedures ............................................................................................... 237
11.3 Pure Procedures ...................................................................................................... 237
11.4 Elemental Procedures............................................................................................. 237
11.5 Enquiry Functions .................................................................................................. 238
Contents xiii

11.6 Transformational Functions................................................................................... 238


11.7 Non-elemental Procedures..................................................................................... 238
11.8 Argument Keywords............................................................................................... 238
11.9 Variable Number of Arguments............................................................................ 239
11.10 Optional Arguments............................................................................................... 239
11.11 Types of Available Intrinsics.................................................................................. 239
11.12 Intrinsic Statement................................................................................................... 240
11.13 Processor Dependencies......................................................................................... 240
11.14 Final Word................................................................................................................ 240

12. Subprograms........................................................................................................................ 241


12.1 FUNCTION Subprogram....................................................................................... 242
12.2 SUBROUTINE Subprogram................................................................................... 245
12.3 CALL Statement....................................................................................................... 246
12.4 INTENT..................................................................................................................... 249
12.5 Internal Procedure................................................................................................... 249
12.6 Character Type Argument...................................................................................... 252
12.7 Argument Types...................................................................................................... 255
12.8 Call by Reference..................................................................................................... 255
12.9 Call by Value............................................................................................................. 255
12.10 RETURN Statement................................................................................................. 256
12.11 INTERFACE Block................................................................................................... 257
12.12 Array as Arguments................................................................................................ 258
12.13 User Defined Type as Argument........................................................................... 260
12.14 MODULE................................................................................................................... 261
12.15 MODULE PROCEDURE......................................................................................... 263
12.16 PUBLIC and PRIVATE Attributes......................................................................... 265
12.17 PROTECTED Attribute........................................................................................... 270
12.18 Scope Rules............................................................................................................... 272
12.19 Generic Subprograms.............................................................................................. 274
12.20 ABSTRACT Interface............................................................................................... 276
12.21 Keyword Arguments............................................................................................... 278
12.22 Operator Overloading............................................................................................. 279
12.23 Overloading of Assignment Operator.................................................................. 283
12.24 Overloading of Standard Library Functions.......................................................284
12.25 User Defined Operators.......................................................................................... 285
12.26 Use Statement and Renaming Operators............................................................. 287
12.27 Precedence of Overloaded Operators................................................................... 288
12.28 Precedence of User Defined Operators................................................................. 288
12.29 OPTIONAL Arguments.......................................................................................... 289
12.30 PRESENT Intrinsic................................................................................................... 290
12.31 Assumed Rank of Dummy Arguments............................................................... 291
12.32 Array-Valued Functions.......................................................................................... 292
12.33 SAVE Variables......................................................................................................... 292
12.34 COMMON Statement.............................................................................................. 294
12.35 BLOCK DATA........................................................................................................... 295
12.36 COMMON and DIMENSION................................................................................ 297
12.37 COMMON and User Defined Type....................................................................... 297
12.38 COMMON and EQUIVALENCE........................................................................... 297
xiv Contents

12.39 EXTERNAL Statement ........................................................................................... 298


12.40 Recursion.................................................................................................................. 301
12.41 RECURSIVE FUNCTION ...................................................................................... 301
12.42 RECURSIVE SUBROUTINE .................................................................................. 303
12.43 PURE Procedure .....................................................................................................305
12.44 Rules for PURE Procedure.....................................................................................305
12.45 ELEMENTAL Procedure........................................................................................306
12.46 IMPURE ELEMENTAL Procedure ....................................................................... 307
12.47 SUBMODULE ..........................................................................................................308
12.48 EQUIVALENCE and MODULE ............................................................................ 311
12.49 Function Calls and Side Effects ............................................................................ 311
12.50 Mechanism of a Subprogram Call........................................................................ 312
12.51 Recursive Input/Output ........................................................................................ 312
12.52 Programming Examples ........................................................................................ 313

13. String with Variable Length ............................................................................................ 319


13.1 Assignment .............................................................................................................. 319
13.2 Concatenation .......................................................................................................... 321
13.3 Comparison ............................................................................................................. 321
13.4 Extended Meaning of Intrinsics ........................................................................... 322
13.5 PUT ........................................................................................................................... 322
13.6 PUT_LINE ................................................................................................................ 322
13.7 GET ........................................................................................................................... 323
13.8 EXTRACT ................................................................................................................. 324
13.9 REMOVE .................................................................................................................. 324
13.10 REPLACE ................................................................................................................. 324
13.11 SPLIT ......................................................................................................................... 325

14. IEEE Floating Point Arithmetic and Exceptions .......................................................... 327


14.1 Representation of Floating Point Numbers (IEEE Standard) ........................... 327
14.2 Single Precision 32-Bit Floating Point Numbers (IEEE Standard) ................... 327
14.3 Denormal (Subnormal) Numbers ......................................................................... 330
14.4 Representation of Zero ........................................................................................... 330
14.5 Representation of Infinity ...................................................................................... 331
14.6 Representation of NaN (Not a Number) ............................................................. 332
14.7 Summary of IEEE “Numbers” .............................................................................. 332
14.8 Divide by Zero.........................................................................................................334
14.9 Overflow...................................................................................................................334
14.10 Underflow ................................................................................................................334
14.11 Inexact Computation ..............................................................................................334
14.12 Invalid Arithmetic Operation ...............................................................................334
14.13 IEEE Modules ..........................................................................................................334
14.14 IEEE Features........................................................................................................... 335
14.15 IEEE FLAGS ............................................................................................................. 335
14.16 Derived Types and Constants Defined in the Modules .................................... 336
14.17 IEEE Operators ........................................................................................................ 336
14.18 Inquiry Functions (Arithmetic Module) .............................................................. 337
14.19 IEEE_CLASS ............................................................................................................ 338
14.20 IEEE_COPY_SIGN .................................................................................................. 339
Contents xv

14.21 IEEE_VALUE ............................................................................................................ 339


14.22 IEEE_IS_FINITE ......................................................................................................340
14.23 IEEE_IS_NAN .........................................................................................................340
14.24 IEEE_IS_NEGATIVE ..............................................................................................340
14.25 IEEE_IS_NORMAL.................................................................................................340
14.26 IEEE_INT .................................................................................................................340
14.27 IEEE_REAL .............................................................................................................. 341
14.28 IEEE_SIGNBIT......................................................................................................... 341
14.29 IEEE_MAX_NUM and IEEE_MIN_NUM .......................................................... 341
14.30 IEEE_MAX_NUM_MAG and IEEE_MIN_NUM_MAG .................................. 341
14.31 IEEE_FMA ............................................................................................................... 341
14.32 IEEE_LOGB..............................................................................................................342
14.33 IEEE_NEXT_AFTER, IEEE_NEXT_DOWN and IEEE_NEXT_UP ..................342
14.34 IEEE_REM................................................................................................................343
14.35 IEEE_SCALB ............................................................................................................343
14.36 IEEE_GET_ROUNDING_MODE ..........................................................................343
14.37 IEEE_SET_ROUNDING_MODE...........................................................................344
14.38 IEEE_RINT...............................................................................................................344
14.39 IEEE_UNORDERED ...............................................................................................345
14.40 IEEE_GET_HALTING_MODE ..............................................................................345
14.41 IEEE_SET_HALTING_MODE...............................................................................345
14.42 IEEE_GET_MODES and IEEE_SET_MODES ......................................................346
14.43 IEEE_GET_STATUS and IEEE_SET_STATUS .....................................................346
14.44 IEEE_GET_FLAG and IEEE_SET_FLAG ............................................................. 347
14.45 IEEE_GET_UNDERFLOW_MODE ....................................................................... 347
14.46 IEEE_SET_UNDERFLOW_MODE........................................................................348
14.47 IEEE_SELECTED_REAL_KIND ...........................................................................348
14.48 Arithmetic IF and IEEE_VALUE ........................................................................... 349
14.49 IEEE_QUIET Compare Routines .......................................................................... 349
14.50 IEEE_SIGNALING Compare Routines ................................................................ 349
14.51 NaN, Infinity and Format ...................................................................................... 349
14.52 Relational Operators, Infinity and NaN .............................................................. 350
14.53 Exception within a Procedure ............................................................................... 351
14.54 Exception Outside a Procedure............................................................................. 352
14.55 Programming Examples ........................................................................................ 353
14.56 Out of Range ............................................................................................................ 355
14.57 Processor Dependencies ........................................................................................ 355

15. Dynamic Memory Management ..................................................................................... 357


15.1 ALLOCATABLE Arrays ......................................................................................... 357
15.2 DEALLOCATE Statement ...................................................................................... 360
15.3 ALLOCATED Intrinsic ........................................................................................... 361
15.4 Derived Type and ALLOCATE ............................................................................. 361
15.5 Allocated Array and Subprogram ........................................................................ 362
15.6 ALLOCATE and Dummy Parameter ................................................................... 365
15.7 Allocatable Character Length ............................................................................... 366
15.8 Character and Allocatable Arrays ........................................................................ 367
15.9 Allocatable Scalar.................................................................................................... 367
15.10 Allocatable Function............................................................................................... 368
xvi Contents

15.11 Allocation Transfer ................................................................................................. 369


15.12 Restriction on Allocatable Arrays ........................................................................ 370
15.13 Programming Example .......................................................................................... 370

16. Pointers ................................................................................................................................. 373


16.1 POINTER Declaration ............................................................................................ 373
16.2 TARGET.................................................................................................................... 373
16.3 POINTER Status ...................................................................................................... 374
16.4 POINTER Initialization.......................................................................................... 374
16.5 POINTER Assignment ........................................................................................... 374
16.6 NULLIFY .................................................................................................................. 376
16.7 POINTER and Array .............................................................................................. 376
16.8 POINTER as Alias................................................................................................... 377
16.9 ALLOCATE and POINTER ................................................................................... 378
16.10 POINTER and ALLOCATABLE Array ................................................................ 379
16.11 DEALLOCATE ........................................................................................................ 381
16.12 Unreferenced Storage ............................................................................................. 382
16.13 ASSOCIATED Intrinsic .......................................................................................... 382
16.14 Dangling Pointer ..................................................................................................... 382
16.15 POINTER within Subprogram ............................................................................. 383
16.16 POINTER and Derived Type ................................................................................. 383
16.17 Self-Referencing Pointer.........................................................................................384
16.18 FUNCTION and POINTER ...................................................................................384
16.19 POINTER and Subprogram................................................................................... 385
16.20 POINTER INTENT ................................................................................................. 386
16.21 PROCEDURE and POINTER ................................................................................ 386
16.22 ALLOCATE with SOURCE ................................................................................... 389
16.23 ALLOCATE with MOLD ....................................................................................... 390
16.24 CONTIGUOUS ........................................................................................................ 390
16.25 IS_CONTIGUOUS ................................................................................................... 391
16.26 Programming Example .......................................................................................... 391

17. Bit Handling ........................................................................................................................ 397


17.1 BIT_SIZE ................................................................................................................... 397
17.2 BTEST........................................................................................................................ 397
17.3 IBSET......................................................................................................................... 399
17.4 IBCLR........................................................................................................................400
17.5 IBITS .......................................................................................................................... 401
17.6 LEADZ and TRAILZ .............................................................................................. 403
17.7 POPCNT ...................................................................................................................404
17.8 POPPAR ....................................................................................................................404
17.9 MASKL .....................................................................................................................404
17.10 MASKR ..................................................................................................................... 405
17.11 IAND ........................................................................................................................405
17.12 IOR ............................................................................................................................ 407
17.13 IEOR ..........................................................................................................................408
17.14 NOT........................................................................................................................... 410
17.15 Bit Sequence Comparison ...................................................................................... 410
17.16 Programming Example .......................................................................................... 411
Contents xvii

17.17 ISHFT ........................................................................................................................ 412


17.18 SHIFTL ..................................................................................................................... 413
17.19 SHIFTR ..................................................................................................................... 413
17.20 SHIFTA ..................................................................................................................... 413
17.21 MERGE_BITS ........................................................................................................... 413
17.22 ISHFTC ..................................................................................................................... 414
17.23 DSHIFTL .................................................................................................................. 416
17.24 DSHIFTR .................................................................................................................. 416
17.25 Logical Operations with Array Elements............................................................ 416
17.26 MVBITS .................................................................................................................... 418
17.27 TRANSFER .............................................................................................................. 420

18. C–Fortran Interoperability ...............................................................................................423


18.1 Interoperability of Intrinsic Types........................................................................423
18.2 C Procedure and Interface Block ..........................................................................425
18.3 Function, Subroutine and C Procedure ...............................................................425
18.4 Interoperability with a C Pointer ..........................................................................425
18.5 Procedures in the Module ISO_C_BINDING .....................................................425
18.6 Compilation and Linking ...................................................................................... 427
18.7 IMPORT Statement ................................................................................................. 427
18.8 Fortran and C Interoperability—Examples ........................................................ 427
18.9 Interoperation with Global Variables ................................................................... 436
18.10 C–Fortran Interoperation ....................................................................................... 439
18.11 ENUMERATOR ......................................................................................................440

19. Object-Oriented Programming .......................................................................................443


19.1 Object and Its Properties........................................................................................443
19.2 Inheritance ...............................................................................................................444
19.3 ASSOCIATE .............................................................................................................445
19.4 Rules of ASSOCIATE .............................................................................................447
19.5 Polymorphic Variables ...........................................................................................448
19.6 SELECT TYPE Construct ....................................................................................... 450
19.7 Allocation and Polymorphic Variables ................................................................ 456
19.8 Type Bound Procedure .......................................................................................... 457
19.9 Generic Binding ...................................................................................................... 462
19.10 Overriding Type Bound Procedures ....................................................................464
19.11 Deferred Binding .................................................................................................... 466
19.12 Finalization .............................................................................................................. 467
19.13 SAME_TYPE_AS ..................................................................................................... 470
19.14 EXTENDS_TYPE_OF.............................................................................................. 471
19.15 Derived Type Input and Output ........................................................................... 472

20. Parallel Programming Using Coarray ............................................................................ 481


20.1 Parallel Computing................................................................................................. 481
20.2 Coarray ..................................................................................................................... 482
20.3 Compilation of Fortran Program with Coarray ................................................. 482
20.4 Declaration ...............................................................................................................483
20.5 Initialization ............................................................................................................484
20.6 Input and Output with Coarray ...........................................................................484
20.7 THIS_IMAGE ..........................................................................................................484
xviii Contents

20.8 NUM_IMAGES ....................................................................................................... 486


20.9 SYNC ALL................................................................................................................ 486
20.10 Array of Coarray ..................................................................................................... 487
20.11 Multidimensional Coarray .................................................................................... 487
20.12 Upper Bound of the Last CODIMENSION ......................................................... 488
20.13 Properties of Coarray ............................................................................................. 489
20.14 LCOBOUND ............................................................................................................ 489
20.15 UCOBOUND ........................................................................................................... 490
20.16 COSHAPE ................................................................................................................ 490
20.17 THIS_IMAGE with Argument .............................................................................. 491
20.18 IMAGE_INDEX ....................................................................................................... 491
20.19 Synchronization ...................................................................................................... 492
20.20 CRITICAL Section .................................................................................................. 494
20.21 ALLOCATABLE Coarray ....................................................................................... 496
20.22 CO Routines ............................................................................................................. 496
20.23 CO_MAX .................................................................................................................. 497
20.24 CO_MIN ................................................................................................................... 498
20.25 CO_SUM .................................................................................................................. 498
20.26 CO_REDUCE ........................................................................................................... 499
20.27 CO_BROADCAST ...................................................................................................500
20.28 Coarray and Subprogram ...................................................................................... 501
20.29 Coarray and Function ............................................................................................504
20.30 Coarray and Floating Point Status ....................................................................... 505
20.31 User Defined Type and Coarray ...........................................................................505
20.32 COARRAY and POINTER ..................................................................................... 509
20.33 Operator Overloading and Coarray ..................................................................... 510
20.34 Atomic Variables and Subroutines ....................................................................... 511
20.35 ATOMIC_DEFINE .................................................................................................. 512
20.36 ATOMIC_REF.......................................................................................................... 512
20.37 ATOMIC_ADD ........................................................................................................ 512
20.38 ATOMIC_FETCH_ADD ........................................................................................ 512
20.39 ATOMIC_AND ....................................................................................................... 513
20.40 ATOMIC_FETCH_AND ........................................................................................ 513
20.41 ATOMIC_OR ........................................................................................................... 513
20.42 ATOMIC_FETCH_OR ............................................................................................ 513
20.43 ATOMIC_XOR ......................................................................................................... 514
20.44 ATOMIC_FETCH_XOR ......................................................................................... 514
20.45 ATOMIC_CAS ......................................................................................................... 514
20.46 LOCK and UNLOCK ............................................................................................. 515
20.47 Status Specifiers ...................................................................................................... 516
20.48 ERROR STOP ........................................................................................................... 516
20.49 Coarray and Interoperability ................................................................................ 516
20.50 COMMON, EQUIVALENCE and Coarray .......................................................... 516
20.51 VOLATILE Variable ................................................................................................ 516
20.52 EVENT ...................................................................................................................... 517
20.53 EVENT POST ........................................................................................................... 517
20.54 EVENT WAIT .......................................................................................................... 518
20.55 EVENT_QUERY ...................................................................................................... 519
20.56 Programming Examples Using Coarray ............................................................. 519
Contents xix

21. Parallel Programming Using OpenMP.......................................................................... 523


21.1 Thread ...................................................................................................................... 523
21.2 Structured Block ..................................................................................................... 523
21.3 Parallelism ............................................................................................................... 524
21.4 Memory Management ............................................................................................ 524
21.5 Application Program Interface (API) ................................................................... 524
21.6 Compiler Support ................................................................................................... 524
21.7 Compilation of Program Containing Openmp Directives ............................... 525
21.8 Structure of Compiler Directives ......................................................................... 525
21.9 Parallel Region ........................................................................................................ 526
21.10 Parallelization Directives....................................................................................... 526
21.11 Clauses Associated with the Directives .............................................................. 527
21.12 Parallel Directive..................................................................................................... 528
21.13 Lexical and Dynamic Region ................................................................................ 529
21.14 Three Runtime Routines ........................................................................................ 529
21.15 Nested Parallel ........................................................................................................ 530
21.16 Clauses Associated with Parallel Construct ....................................................... 531
21.17 IF Clause ................................................................................................................... 531
21.18 NUM_THREADS .................................................................................................... 532
21.19 PRIVATE ................................................................................................................... 532
21.20 SHARED................................................................................................................... 533
21.21 DEFAULT NONE .................................................................................................... 533
21.22 DEFAULT PRIVATE ................................................................................................ 533
21.23 DEFAULT SHARED ................................................................................................ 533
21.24 FIRSTPRIVATE ........................................................................................................534
21.25 Rules for OMP PARALLEL Directive ..................................................................534
21.26 Workshare Construct ............................................................................................. 536
21.27 OMP DO/OMP END DO ....................................................................................... 536
21.28 Rules of OMP DO/OMP END DO ....................................................................... 537
21.29 OMP SECTIONS/OMP END SECTIONS ............................................................ 537
21.30 OMP WORKSHARE ............................................................................................... 539
21.31 OMP SINGLE/OMP END SINGLE ...................................................................... 541
21.32 OMP MASTER/OMP END MASTER ..................................................................542
21.33 REDUCTION ...........................................................................................................543
21.34 CRITICAL/END CRITICAL .................................................................................546
21.35 LASTPRIVATE......................................................................................................... 547
21.36 ATOMIC ................................................................................................................... 549
21.37 OMP BARRIER ........................................................................................................ 550
21.38 THREADPRIVATE.................................................................................................. 551
21.39 Rules for THREADPRIVATE ................................................................................. 553
21.40 COPYIN .................................................................................................................... 553
21.41 ORDERED ................................................................................................................ 555
21.42 COPYPRIVATE ........................................................................................................ 555
21.43 NOWAIT................................................................................................................... 556
21.44 FLASH ...................................................................................................................... 557
21.45 Openmp LOCK ....................................................................................................... 557
21.46 SCHEDULE.............................................................................................................. 560
21.47 STATIC SCHEDULE ............................................................................................... 561
21.48 DYNAMIC SCHEDULE ......................................................................................... 562
xx Contents

21.49 GUIDED SCHEDULE............................................................................................. 563


21.50 RUNTIME SCHEDULE..........................................................................................564
21.51 AUTO SCHEDULE .................................................................................................564
21.52 Openmp Runtime Library Routines ....................................................................564
21.53 Runtime Time Routines ......................................................................................... 566
21.54 Environment Control ............................................................................................. 567
21.55 Environment Variables........................................................................................... 567
21.56 Programming Examples ........................................................................................ 568
21.57 Final Word ............................................................................................................... 570

22. Parallel Programming Using Message Passing Interface (MPI) .............................. 571
22.1 MPI Module ............................................................................................................. 571
22.2 Compilation ............................................................................................................. 571
22.3 Error Parameter of MPI Routines ......................................................................... 572
22.4 MPI Version ............................................................................................................. 572
22.5 MPI_INIT ................................................................................................................. 573
22.6 MPI_INITIALIZED ................................................................................................. 573
22.7 MPI_FINALIZE ....................................................................................................... 573
22.8 MPI Handles ............................................................................................................ 574
22.9 About This Chapter ................................................................................................ 574
22.10 Structure of a MPI Program .................................................................................. 574
22.11 MPI_COMM_RANK .............................................................................................. 575
22.12 MPI_COMM_SIZE .................................................................................................. 575
22.13 Use of Rank in Controlling the Flow of the MPI Program ............................... 576
22.14 MPI_BARRIER ........................................................................................................ 576
22.15 Basic MPI Datatype in Fortran.............................................................................. 577
22.16 Point-to-Point Communication ............................................................................. 577
22.17 Communication Modes.......................................................................................... 577
22.18 Message Sent and Received ................................................................................... 578
22.19 MPI_SEND and MPI_RECV ................................................................................. 578
22.20 MPI_SSEND............................................................................................................. 581
22.21 MPI_BSEND ............................................................................................................ 581
22.22 MPI_RSEND ............................................................................................................ 582
22.23 Deadlock .................................................................................................................. 582
22.24 Non-blocking Send and Receive ........................................................................... 583
22.25 Send Function-Naming Conventions in Blocking and Non-blocking
Forms ................................................................................................................... 585
22.26 MPI_ANY_TAG and MPI_ANY_SOURCE ......................................................... 585
22.27 REDUCTION ........................................................................................................... 586
22.28 MPI_SCAN .............................................................................................................. 592
22.29 MPI_ALLREDUCE ................................................................................................. 593
22.30 MPI_REDUCE_SCATTER_BLOCK ..................................................................... 595
22.31 MPI_REDUCE_SCATTER ..................................................................................... 596
22.32 MPI_BROADCAST ................................................................................................. 597
22.33 MPI_GATHER ......................................................................................................... 598
22.34 MPI_ALLGATHER ................................................................................................. 599
22.35 MPI_SCATTER ........................................................................................................600
22.36 MPI_SCATTERV ..................................................................................................... 601
22.37 MPI_ALLTOALL ..................................................................................................... 603
Contents xxi

22.38 Derived Data Types ................................................................................................604


22.39 MPI_TYPE_CONTIGUOUS ...................................................................................604
22.40 MPI_TYPE_VECTOR .............................................................................................. 606
22.41 MPI_TYPE_CREATE_HVECTOR ........................................................................ 607
22.42 MPI_TYPE_INDEXED ...........................................................................................608
22.43 MPI_TYPE_CREATE_HINDEXED ...................................................................... 609
22.44 MPI_TYPE_CREATE_INDEXED_BLOCK .......................................................... 609
22.45 MPI_TYPE_CREATE_HINDEXED_BLOCK ....................................................... 610
22.46 MPI_TYPE_CREATE_STRUCT............................................................................. 610
22.47 MPI_PACK and MPI_UNPACK ............................................................................ 612
22.48 MPI_COMM_SPLIT................................................................................................ 613
22.49 Timing Routines...................................................................................................... 615
22.50 Programming Examples ........................................................................................ 615
22.51 Final Word ............................................................................................................... 620

Appendix A ................................................................................................................................. 621


Appendix B.................................................................................................................................. 623
Appendix C ................................................................................................................................. 625
Appendix D .................................................................................................................................633
Appendix E .................................................................................................................................. 635
Appendix F .................................................................................................................................. 637
Appendix G ................................................................................................................................. 639
Appendix H ................................................................................................................................. 641
Appendix I...................................................................................................................................643
References ...................................................................................................................................645
Index ............................................................................................................................................. 647
Preface

Since the early days of machine computing, there has been a constant demand for larger
and faster machines. The two terms essentially mean machines with larger memory and
more speed than that of the existing available machines. During the past 70 years, there
have been dramatic changes in the fields of computer hardware and software—from
vacuum tubes to VLSI (very large scale integration) and from no operating system to very
sophisticated, time-sharing operating systems. There are three obstacles that computer
designers face while aiming to increase the speed of the computer. First, the density of the
active components within a chip cannot be increased arbitrarily. Second, with the increase
of the density of the active components within VLSI chips, heat dissipation becomes a
severe problem. Third, the speed of a signal cannot exceed the speed of light according
to the special theory of relativity proposed by Einstein. Thus, a different approach to the
problem has been thought of.
Instead of having a single processor, if several processors (each may not be very fast and
can be inexpensive) participate in parallel for computation, the speed of calculation can
be increased considerably, and in fact, using inexpensive processors controlled by special
software and hardware, the speed of a supercomputer can be achieved if hundreds of
processors work together in parallel.
This book contains an introduction to parallel computing using Fortran. Fortran supports
three types of parallel modes of computation: Coarray, OpenMP and Message Passing
Interface (MPI). All three modes of parallel computation have been discussed in this book.
In addition, the first part of the book contains a discussion on the current standard of
Fortran, namely, Fortran 2018.
The first part of the book can be used to learn the modern Fortran language even if
the reader has not yet been exposed to the earlier versions of Fortran. The book should
be read sequentially from the beginning. However, a reader who is conversant with the
earlier versions of Fortran may skip the introduction to Fortran and go directly to the new
features of the language.
As Fortran is mainly used to solve problems related to science and engineering, standard
numerical methods have been used as a vehicle to illustrate the application of the language.
However, knowledge beyond the level of elementary calculus is not required to understand
the numerical examples given in the book. The emphasis of the book is on programming
language, not on sophisticated numerical methods. The programming examples given in
the book are simple, and to keep the code readable, the codes are not always optimized. It is
expected that a reader, after proper understanding of the language, would be able to write
much more efficient codes than the codes given in the book.
Programming tips and style have been introduced at appropriate places. They serve
simply as guidelines. It is well known that every experienced programmer has his or her
own programming style.
To keep the size of the book reasonable, all available features of Fortran 2018 have
not been discussed. Moreover, only the essential components of Coarray, OpenMP and
MPI, which are required to write reasonably useful programs, have been discussed. It is
hoped that readers, after going through this book, will refer to relevant manuals and be
able to write parallel programs in Fortran to solve their numerical problems.

xxiii
xxiv Preface

The book is full of examples. Most of the examples have been tested with Intel Cor-
poration’s Fortran compiler, ifort, version 19.3, GCC gfortran version 7.3.0 and the Fortran
compiler version 6.2 of Numerical Algorithm Group (NAG). The Fortran part is based on
the draft Fortran 2018 report published on July 6, 2017. At the time of writing, these com-
pilers do not support all the proposed features of Fortran 2018, but Intel, Free Software
Foundation, Inc., and NAG will add further support for these features over time.

Subrata Ray
Acknowledgments

The author wishes to record his deep sense of gratitude to his colleagues, friends and asso-
ciates who helped him to prepare this manuscript during the various phases of this work.

Abhijit Kumar Das


Ananda Deb Mukherjee
Ankush Bhattacharjee
Ashish Dutta
Biplab Sarkar
Debasis Sengupta
Gayatri Pal
Indrajit Basu
Indrani Bose
Koushik Ray
Minakshi Ghosh
Prasanta Kumar Mukherjee
Pushan Majumdar
Ramaprasad Dey
Ranjit Roy Chowdhury
Robert Dyson
Sandip Ghosh
Sankar Chakravorti
Santosh Kumar Samaddar
Sarbani Saha
Satrajit Adhikari
Satyabrata Roy
Siddhartha Chaudhuri
Souvik Mondal
Swapan Bhattacharjee
Utpal Chattopadhyay

The Numerical Algorithms Group Ltd., Oxford, UK, provided the author with a free
license to use their Fortran compiler. Intel Corporation allowed the author to use the trial
version of their Fortran compiler ifort. The free GCC gfortran compiler was also used.
National Council of Education, Bengal, and Institute of Business Management, NCE,
Bengal, allowed the use of their computer laboratory during the preparation of this book.
Finally, the author wishes to thank his family for their encouragement during the prepa-
ration of this manuscript.

xxv
Author

Dr. Subrata Ray is a retired senior professor of the Indian


Association for the Cultivation of Science, Kolkata. In his
career spanning over 40 years, he has taught computer
software in universities, research institutes, colleges and
professional bodies across the country. As a person in
charge, he has set up several computer centers, in many
universities and research institutes, almost from scratch.
Though his field of specialization is scientific computing,
he has participated in developing many systems and
commercial software.
He has an MSc, a Post MSc (Saha Institute of Nuclear
Physics) and PhD from Calcutta University and has
served several renowned institutes like Tata Institute of
Fundamental Research, Indian Institute of Technology,
Kharagpur, Regional Computer Centre, Calcutta, University of Burdwan and Indian
Association for the Cultivation of Science.
He is associated with the voluntary blood donation movement of the country and is
an active member of Association of Voluntary Blood Donors, West Bengal. He offers his
voluntary services to Eye Care & Research Centre and National Council of Education,
Bengal.
He is also an amateur photographer.
He is married to Sanghamitra, and they have a daughter, Sumitra. He lives in Kolkata
with his brother Debabrata and sister Uma.

xxvii
Another Random Scribd Document
with Unrelated Content
The Project Gutenberg eBook of Junge Triebe:
Roman
This ebook is for the use of anyone anywhere in the United States
and most other parts of the world at no cost and with almost no
restrictions whatsoever. You may copy it, give it away or re-use it
under the terms of the Project Gutenberg License included with this
ebook or online at www.gutenberg.org. If you are not located in the
United States, you will have to check the laws of the country where
you are located before using this eBook.

Title: Junge Triebe: Roman

Author: Ernst W. Freissler

Release date: June 21, 2022 [eBook #68365]

Language: German

Original publication: Germany: Albert Langen, 1922

Credits: the Online Distributed Proofreading Team at


https://www.pgdp.net

*** START OF THE PROJECT GUTENBERG EBOOK JUNGE


TRIEBE: ROMAN ***
Anmerkungen zur Transkription
Der vorliegende Text wurde anhand der 1922 erschienenen Buchausgabe so weit wie
möglich originalgetreu wiedergegeben. Typographische Fehler wurden stillschweigend
korrigiert. Ungewöhnliche und heute nicht mehr gebräuchliche Schreibweisen,
Schreibvarianten, Dialektausdrücke, sowie fremdsprachliche Passagen bleiben
gegenüber dem Original unverändert.
Abhängig von der im jeweiligen Lesegerät installierten Schriftart können die im Original
g e s p e r r t gedruckten Passagen gesperrt, in serifenloser Schrift, oder aber sowohl
serifenlos als auch gesperrt erscheinen.
Junge Triebe
Ein Verzeichnis
der früher bei Albert Langen
erschienenen Werke von
Ernst W. Freißler
findet sich am Schluß
dieses Buches
Junge Triebe

Roman
von

Ernst W. Freißler

Albert Langen, München


1922

Copyright 1921 by Albert Langen, Munich


Alle Rechte, einschließlich des Übersetzungsrechts,
auch für Rußland, vorbehalten
Albert Langen E r n s t W. F r e i ß l e r
1
Die Familie saß an dem quadratischen Eßtisch. Vor den
einfachen Gedecken der Frau und der Kinder zeichnete sich der
Platz des Vaters aus durch eine Wein- und eine
Mineralwasserflasche, ein schwergeschliffenes Kelchglas von
seltsam tiefer Form und ein reich facettiertes Wasserglas, die
sämtlich auf silbernen Tellerchen standen. Besteck und
Serviettenring aus schwerem Silber trugen das ihre zur
Distanzierung bei. Tatsächlich schien der Vater, ein straffer Fünfziger
mit eisengrauem Spitzbart und fast übertrieben energischen Zügen,
irgendwie über der Runde zu thronen, wenn auch sein Stuhl denen
der anderen gleich war. Die Mutter, eine zärtliche Blondine mit leisen
Anzeichen des Verblühens, ließ ängstliche Blicke fliegen zwischen
dem strengen Gemahl, — ob auch nichts seinen Unwillen errege —
und den beiden Jungen, — ob sie Messer und Gabel richtig
handhabten und auch sonst keine der verpönten Unarten zeigten.
Glaubte sie an einem der Jungen etwas zu sehen, was einen
Zornesausbruch des Vaters hervorrufen konnte, — daß er etwa
Gabel und Messer benützte, wo die Gabel allein vorgeschrieben war,
oder umgekehrt — so steigerte sich ihr Mienenspiel zu ungeahnter
Heftigkeit. Durch hastige Kopfbewegungen und schreckhaftes
Augenrollen suchte sie den Missetäter aufmerksam zu machen,
erreichte aber damit nur zu oft, daß der Vater mit gebührender
Schärfe ein Versehen rügte, das ohne ihre stummen und
flehentlichen Warnungen wahrscheinlich unbemerkt geblieben wäre.
Der älteste Sohn, elfjährig, saß dem Vater, der dem Fenster den
Rücken kehrte, in vollem Lichte gegenüber. Ein gedrückter Junge,
mit schwermütigen Augen und einer Stirn, die viel zu wuchtig war für
das schmale Kinn und den schmächtigen Leib und fast häßlich
wirkte. Man sah es wohl, daß ihm Gehorsam und sklavische Angst in
den Knochen saßen, die krampfhafte Abwehr eines zarten
Organismus gegen jede leiseste Brutalität in Sprache und Ton. Der
jüngere dagegen, stämmig, gedrungen, ein Rundkopf mit
unregelmäßigen Zügen und Augen wie aus Quecksilber, schien nur
durch die Witterung ewig naher Jagdhiebe in den Grenzen des
steifen Tafelzeremoniells gehalten zu werden. Er war es auch, der
sich erkühnte, die pädagogischen Donnerworte des Vaters, soweit
sie sich an den Bruder richteten, mit lautlosem Gekicher und listigem
Zwinkern zu glossieren, was ihm von der Mutter eine Reihe halb
verzweifelter, halb vernichtender Blicke eintrug.
Das Gespräch floß karg und leer. Der Vater schien, wie viele
schwerarbeitende Männer, die ihre Kinder nur bei den Mahlzeiten
sehen, das Mittagessen als eine Doppelnummer seines
Tagesprogrammes abzumachen: Nahrungsaufnahme mit Pädagogik
gemengt. Eine namenlose Kälte lag über dem Zimmer. Der einzige,
der sich gänzlich unberührt davon zeigte, war der Jüngste, ein
goldblonder, zierlicher Bursch von knapp drei Jahren, der zwischen
Vater und Mutter auf seinem hohen Kinderstühlchen herumturnte
und mit Krähen, Lachen und Geplapper auf eigene Faust
Konversation machte. Der Blick des Vaters verlor seine starre
Würde, sobald er sich dem Kleinen zuwandte und zeigte eine so
unverhohlene Zärtlichkeit, daß die strenge Stirn mit den lastenden,
dichten Brauen fast als Maske erschien. Jeden solchen Blick
quittierte das Söhnchen mit unbefangenem Gequietsch. Als sich
aber einmal einer der ewig wandernden Warnerblicke der Mutter zu
ihm verirrte und ihn zum Schweigen zu mahnen suchte, da piepste
er ihr entgegen: „Ich bin dem Papa sein Stutzerle, mir darf niemand
was tun!“, holte sich mit raschem Seitenblick beim Vater die
lächelnde Zustimmung und sah dann siegessicher über die gekränkt
errötende Mutter und die beiden älteren Brüder hin, die sich
verbissen über ihre Teller neigten. Man merkte deutlich, daß der
Ausspruch, irgendwann einmal spontan entstanden, dem Jungen
durch steten Beifall zur Redensart geworden war, und daß es von
äußerst fraglichem erzieherischem Wert sein mußte, ihn weiter zu
dulden. Der Vater aber, ein fröhlicher Tyrann, schien nichts davon zu
merken. Kaum war das Fleischgericht abgetragen, so kletterte der
Kleine von seinem hohen Sitz und saß mit einem Sprung auf des
Vaters Knie, zupfte ihn am Bart, spielte mit seiner Uhrkette und trieb
allerlei Unsinn. Der Älteste sah dem mit seltsam brennenden Augen
zu. Von ihm hätte der Vater nie eine körperliche Liebkosung
geduldet, außer dem starren Handkuß, der bei jeder Begrüßung und
nach jeder Mahlzeit zitternd gegeben und gleichgültig angenommen
wurde.
Als das Mädchen mit der süßen Speise in der Tür erschien, sang
der Kleine nach primitiver Kinderstubenmelodie: „Jetzt kommt was
Gutes, und die Mama kriegt nix!“ Der Blick aber, den er dabei auf
seine Mutter warf, zeigte klar, daß er in kindlicher Grausamkeit die
Lust voll empfand, straflos wehtun zu dürfen. Die Mutter sah den
Vater an mit einem Blick hilfloser, stummer Klage; es war zu sehen,
daß auch dieser ursprünglich vielleicht naive Kindervers in täglicher
Wiederholung zu einer demütigenden Demonstration geworden war.
Der Vater aber hatte nur ein glückliches Lachen für seinen
scharfsichtigen Sohn. Der plusterte sich selbstbewußt auf.
Die älteren Brüder sahen den Jüngsten an, wie Pferde in
schwerem Zug nach den Fohlen sehen, die frei auf sonniger Koppel
laufen. Sehnsucht und Neid war darin, und ein Wissen um künftiges
Leiden.
2
Über dem Hause lag eine dumpfe Spannung. Die alte Köchin
fuhr aufgeregter als sonst in der Küche herum, zischte dem
Mädchen nur abgerissene Schmählaute zu, statt laut zu schelten
und schien überhaupt bemüht, auf irgendwas Rücksicht zu nehmen.
Der älteste Bruder saß stiller als je über seinen Büchern, der
jüngere kobolzte in allen Ecken und deutete mit listigem
Augenfunkeln und halben Worten geheimes Wissen an. Der
Jüngste, endlos verwirrt, stand überall im Weg und wurde
unaufhörlich beiseite geschoben. Doch wagte er nicht, in sein
übliches Wehgeheul auszubrechen und begann schließlich still zu
weinen.
Die Mutter fehlte bei Tisch. Der Vater schien unfroh und gereizt
und hatte mit einmal keinen Sinn für die witzigen Unarten seines
Lieblings. Vergebens haspelte der sein ganzes Repertoire ab,
krähte, plapperte, bellte. Der gewünschte Beifall blieb aus. Auch die,
ohne äußeren Anlaß übrigens, herausgeschmetterte Fanfare: „Ich
bin dem Papa sein Stutzerle ...“ verpuffte wirkungslos. Die Brüder
begannen heimlich zu grinsen. Als der Kleine aber die Mehlspeise
mit seinem gewohnten Singsang begrüßen wollte, wies ihn der
Vater, heftig wie noch nie, zur Ruhe und hatte dabei das Zucken in
den Augenbrauen, das immer erschien, wenn er die Brüder schlug.
Daraufhin wagte der zweite Bruder ein vernehmliches Feixen,
bekam aber sofort, angeblich wegen unruhigen Sitzens, ein scharfes
Kopfstück. Der Älteste erbleichte zitternd. Doch war das alles kein
Trost für den Kleinen, der wie betäubt stumm dahockte.
Mit dem letzten Bissen im Munde stand der Vater hastig auf,
nahm sich nicht Zeit, den Handkuß der Kinder abzuwarten und
verließ grußlos das Zimmer. Man hörte ihn durch den langen
Korridor nach dem Schlafgemach gehen. Das war zu dieser
Tageszeit so ungewohnt, daß es irgendwie beängstigend wirkte.
Die drei Brüder blieben allein zurück. Max, der mittlere, zeigte
sich herzhaft ausgelassen, sobald der Vater aus dem Zimmer war.
Er juckte wild auf seinem Sitz herum, stieß mit Füßen nach dem
Ältesten und fletschte dem Jüngsten die Zähne. „Ich bin neugierig,
wann der Fritzl ...“ — das war der Jüngste — „seine erste Watsch’
kriegt! Vorhin hab’ ich schon geglaubt, es kracht!“ Und nachäffend
sang er: „Jetzt kommt was Gutes ... ätsch!“ Dabei stieß er Felix, den
Ältesten, schadenfroh und aufmunternd an. Der heftete seine
schwermütigen Augen mit unbestimmbarem Ausdruck auf den
Kleinen. In Fritzls blankem Kindergesicht aber zeigte sich ein so
furchtbarer Schrecken, ein so namenloses Grauen vor
Gewalttätigkeiten, daß die Brüder beide, halb beschämt, halb
furchtsam, verstummten.
Am gleichen Tage wurde Fritzls Bett aus dem Schlafzimmer der
Eltern in das der Brüder geschoben. Max hieß ihn plötzlich
willkommen und trieb allerlei Schabernack, Felix aber sah ihn wieder
nur stumm an. Wie ein Verurteilter einen neuen Zellengast
betrachten mag.
Vor dem Einschlafen hatte Fritzl einen Weinkrampf. Alle
Tröstungsversuche der böhmischen Magd wies er zurück, nannte
auch keinen Grund seines Weinens. Erst Nanni, der alten Köchin,
gelang es, ihn etwas zu beruhigen. Mit harten Arbeitshänden fuhr sie
durch seine Locken und drückte immer wieder ihr gutes,
verrunzeltes Sklavengesicht an den bebenden, schütternden
Kinderleib. „Wos hoste denn, mein Engerle,“ stammelte sie, selbst
dem Weinen nahe. „Do sog ma’s doch! Sie derfen dir nix tun! Keiner
derf dir nix tun!“ — „Prügeln wollen sie mich — der Papa will mich
prügeln!“ jammerte der Junge und wand sich in neuem Weinen. Der
Alten, ob sie schon nicht wußte, woher dem verwöhnten Liebling
gerade diese Angst kommen mochte, fuhr ahnungsvoller Schreck in
die Glieder. Sie kannte die eiserne Faust des Herrn. Nun würde er
bald beginnen, auch dies Sonnenkind da zu bändigen und
abzurichten, wie er sie alle abgerichtet hatte: die blonde Herrin, sie
selbst, die alte Nanni, die mit ihr gekommen war, und die beiden
älteren Buben. Wie hatte er die ersten Jahre den Felix verzärtelt —
und wer sah den Jungen jetzt noch lachen? Doch es war der Herr —
und entsetzt über die eigenen aufrührerischen Gedanken bekreuzte
sich die Alte, beugte sich tiefer über den schluchzenden Jungen und
weinte still mit ihm. Als sie ihn schlafen sah, schlich sie in ihre Küche
zurück.
3
Max weckte die Brüder, indem er jedem einen Pantoffel ins Bett
warf. Beide fuhren erschreckt auf. Der Älteste begann zu zetern, daß
er nun wieder den ganzen Tag Kopfweh haben würde, drohte in
ohnmächtiger Wut und schien dem Weinen nah. Fritzl war empört
über die freche Vertraulichkeit. Dann kam ihm dunkel zum
Bewußtsein, daß er ja nicht mehr unbedingt unter dem Schutze des
Vaters stand. So schwieg er und kam sich sehr verlassen vor. Max
lachte sie beide aus, stellte sich im Bett auf den Kopf und schlug
Purzelbäume. Da hörte man im Nebenzimmer des Vaters Schritt:
und wie überraschte Murmeltiere fuhren die beiden Älteren unter ihre
Decken und stellten sich schlafend. Fritzl tat es ihnen instinktiv nach,
fühlte dabei aber in seinem Kinderkopf ein dumpfes Staunen.
Warum konnte er nicht, wie sonst, dem Vater jubelnd
entgegenspringen?
Da ging schon die Türe und der Vater rief ins Zimmer: „Jungen,
freut euch, ihr habt ein Schwesterl bekommen!“ — Felix und Max
mimten Erwachen aus tiefem Schlaf und zeigten gehorsam Freude
— Felix durch sein höfisches Lächeln, Max, indem er alle Glieder
durcheinanderwirbelte. Fritzl blieb stumm. In ihm weckte die
Nachricht keinerlei klare Vorstellung, schärfer als zuvor fühlte er
ängstliches Staunen. Der Vater beugte sich über sein Bett: „Na,
Fritzl, freust du dich?“ — Fritzl hatte, zum erstenmal, Angst vor dem
großen Mann, der so laut auftrat und sprach, las, zum erstenmal,
eine Drohung aus dem bärtigen Gesicht und starrte ratlos und
stumm empor. „Na, was ist denn, Faulpelz, kannst du nicht reden?“
polterte der Vater, und meinte es scherzhaft. Fritzl aber, tödlich
erschrocken, stammelte nur „Ja, Papa!“ und mühte sich, zu lächeln,
wie Felix immer lächelte. Sein Gesicht war wie eine Maske der
Angst.
4
Taufe. Durch die große, leere Pfarrkirche heult die Orgel, schwillt
an, bricht dröhnend ab. Auf dem hohlen Bretterbelag des
Hauptganges hallen die Schritte. Es riecht süß und schwer,
einschläfernd. Aus dunklen Nischen, von brennenden Kerzen
umrahmt, Gestalten mit unverständlichen Gesten. Drohen sie,
locken sie? Fritzl taumelt an der Hand des Kindermädchens durch
die tobende Stille; er fürchtet sich namenlos, läßt sich in eine tiefe,
lange Bank ziehen, sitzt still und zitternd. Weit, endlos weit weg, um
den Kanzelpfeiler geschart, eine Gruppe Menschen. Dort soll Papa
sein, Mama, die Onkel und Tanten? Unerreichbar!
Plötzlich ein scharfer, durchdringender Ton, herrisch, Beachtung
fordernd. Fritzl fühlt: so schreit das neue Wesen, um das sich jetzt
alle so sehr kümmern. Er hat die Schwester noch nicht gesehen. Als
ihn der Vater an die Wiege führte, war ihm unsäglich aufgeregt, alles
zu gräßlichem Weiß verschwommen. Er weiß nur, daß ein Neues
zwischen ihm und den Eltern ist, weit gefährlicher als die älteren
Brüder. Das schreit nun dort. Und es sind doch alle bei ihm. Er aber,
Fritzl, ist allein und weit, weit fort.
Wieder zu Hause. Der große Salon voll Leuten. Im Speisezimmer
eine reichgedeckte Tafel. Aus der Küche riecht es nach guten
Dingen. Felix und Max sind da. Sie müssen die fremden Onkel
begrüßen. „Verbeugen! Hand küssen!“ kommandiert der Vater. Fritzl
tut betäubt mit. Dann werden sie alle aus dem Zimmer geschoben.
Alle drei. Hinter ihnen sagt jemand: „... die drei Brüder.“ Fritzl hört die
Gleichstellung und ist sprachlos überrascht.
Felix und Max sind in der Schule. Der Jüngste sitzt allein an dem
großen Tisch des Kinderzimmers. Das Mädchen bringt ihm, fertig auf
dem Teller, Maronipüree mit Schlagrahm, dicke Schokolade, süßes
Gebäck. Fritzl ißt ohne Freude. Durch leere Nebenzimmer hört er
den Lärm der großen Tafel. Eine Einsamkeit, zu mächtig für den
kleinen Körper, droht ihn zu sprengen. Er weint. Draußen vertropft
ein Regenabend. Und alles ist grau.
5
Die Mutter ist zum erstenmal wieder bei Tisch — sehr blaß und
matt. Der Vater zeigt bärbeißige Ritterlichkeit, zankt nicht mit den
Jungen. Diesmal ist er es, der mit Blicken warnt und rügt. Die Buben
sind artig, und dies mal nicht aus Angst. Alles könnte sein wie früher.
Nur Fritzl hat die alte Sicherheit verloren, wetzt ratlos auf seinem
hohen Sitz herum. Vom Vater trennt ihn eine unnennbare Scheu, die
er nur fühlt, und nicht begreift. Noch ist es nicht körperliche Angst,
wie bei den Brüdern. Doch auch der Vater ist anders — ermuntert
ihn nicht zur Ausgelassenheit, verlangt kein Verschen von ihm,
beachtet ihn kaum. Fritzl, sehr bedrückt, muß an das Neue denken,
das irgendwo hinten in einem der Zimmer liegt.
Wie die Mehlspeise kommt, sagt er plötzlich ganz laut: „Nicht
wahr, Mama, du bleibst jetzt immer bei uns!“ Der Vater sieht ihn sehr
überrascht an. Die Mutter, errötend, streicht flüchtig über seine
Hand.
6
Wieder ein Morgen im Bubenzimmer. Max hat den Felix grob
geweckt, der hat sich aufgerafft und, ohne zu jammern,
zugeschlagen. Jetzt raufen sie, Fritzl schaut zu, fast unbeteiligt.
Noch immer fühlt er sich als Günstling, nicht recht zu den „Buben“
gehörig.
Nun beginnen sie um den Tisch zu rennen. „Hilf mir!“ keucht Felix
im Vorübersausen. „Ich schenk dir eine Kanone!“ — „Ich streich dir
deinen Hammer blau an!“ kräht Max und wirft einen Schuh nach dem
Ältesten.
Den Hammer — blau? Der Hammer, ganz aus Holz, ist Fritzls
große Liebe. Schon springt er aus dem Bett, fest entschlossen, den
Lohn zu verdienen. Wie Felix wieder vorbeirast, stößt er ihm einen
Kinderschemel vor die Füße. Felix stürzt brüllend, Max über ihn. Sie
prügeln sich wütend. Fritzl jubelt.
Da hören sie, schnell und böse, des Vaters Schritt, stieben
auseinander, zu läppischen Beschäftigungen: Felix bürstet sich
krampfhaft die Haare, Max sucht unterm Bett nach seinem Schuh,
Fritzl, in höchster Angst, springt zu seiner Waschschüssel, die auf
einem Holzstuhl steht. Für den Waschtisch der Brüder ist er noch zu
klein.
Da fährt der Vater unter sie, und gleich knallen die Backpfeifen.
Felix heult angemessen, Max knurrt nur; Fritz beugt sich atemlos
über die Waschschüssel. Da trifft ihn ein Schlag ins Genick, und im
Sturz reißt er den ganzen Apparat zu Boden, wälzt sich zwischen
starrenden Stuhlbeinen im Wasser, lautlos. Ein wütendes Scheltwort
schneidet durchs Zimmer, dann schmettert eine Tür, und die drei
sind wieder allein.
Felix hockt vor seinem Bett auf dem Boden, wie ihn ein Schlag
hingeworfen hat, und heult leise, gedehnt, wie ein krankes Tier. Max
knurrt böse, ermuntert sich aber rasch und schabt höhnend die
Zeigefinger gegen den Jüngsten: „Kisch! Kisch! Stutzerle! Kisch!
Kisch! Stutzerle!“
Fritz steht sehr langsam auf, wie gelähmt. Er hat irre, leere
Augen. Fühlt er, daß ein unerbittlich greller Tag das glückselige
Dämmer seiner ersten Kindheit durchbrochen, daß sich seinem Hirn
eben die erste E r i n n e r u n g eingeprägt hat? Und daß diese erste
Erinnerung, an sinnlos erlittene Gewalt, durch sein ganzes Leben
fortbrennen wird wie ein Schandmal?
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like