![]() When appearing in expressions, pointers are always dereferenced no 'pointer arithmetic' is possible.The following example illustrates the concept. This allows a Fortran 90 pointer to point at submatrices.Fortran 90 pointers are 'associated' with well-defined 'target' variables, via either the pointer assignment operator ( =) or an ALLOCATE statement. A Fortran 90 pointer does not merely store the memory address of a target variable it also contains additional descriptive information such as the target's rank, the upper and lower bounds of each dimension, and even strides through memory. Initialize a, b a = ( real ( i ), i = 1, 20, 2 ) b = a + 1! Output before swap print '(/'before swap:')' print '('a = ', 10f6.1, ')', a print '('b = ', 10f6.1, ')', b! Call the swapreal subroutine call swapreal ( a, b )! Output after swap print '(// 'after swap:')' print '('a = ', 10f6.1, ')', a print '('b = ', 10f6.1, ')', b end program testswapreal Pointers and targets methods In Fortran, the concept of differs from that in -like languages. Because argument passing in Fortran functions and subroutines utilize by default (rather than, as is the default in languages such as ), modifying NA and NB from within the function would effectively have modified the corresponding actual arguments in the main PROGRAM unit which called the function.The following shows the results of compiling and running the program. This is necessary as the values of IA and IB are altered within the function. In the function NGCD(NA, NB), the values of the function arguments NA and NB are copied into the local variables IA and IB respectively. This example relies on the to specify the INTEGER types of NA, NB, IA, IB, and ITEMP. ![]() A zero in this position advances two lines (double space), a 1 advances to the top of a new page and + character will not advance to a new line, allowing overprinting.FORTRAN 77 As of FORTRAN 77, single quotes are used to delimit character literals, and inline character strings may be used instead of references to FORMAT statements. (Some compilers also supported character literals enclosed in, a practice that came to be standard with FORTRAN 77.)The space immediately following the 13H is a carriage control character, telling the I/O system to advance to a new line on the output. If execution flows into a FORMAT statement, it is a thus, the example above has only two executable statements, WRITE and STOP.The initial 13H in the FORMAT statement in the above example defines a, here meaning that the 13 characters immediately following are to be taken as a character constant (note that the Hollerith constant is not surrounded by delimiters). Typically a FORMAT statement is placed immediately following the WRITE statement which invokes it alternatively, FORMAT statements are grouped together at the end of the program or subprogram block. FORMAT statements may be placed anywhere in the same program or function/subroutine block as the WRITE statements which reference them. ![]() The number 7 in the WRITE statement refers to the statement number of the corresponding FORMAT statement. (The or was usually connected as unit 5). C FORTRAN IV WAS ONE OF THE FIRST PROGRAMMING C LANGUAGES TO SUPPORT SOURCE COMMENTS WRITE ( 6, 7 ) 7 FORMAT ( 13 H HELLO, WORLD ) STOP ENDThis program prints 'HELLO, WORLD' to Fortran unit number 6, which on most machines was the. ![]() An IBM 1130 emulator is available at that will allow the FORTRAN IV program to be compiled and run on a.Hello, World program In keeping with computing tradition, the first example presented is a simple program to display the words 'Hello, world' on the screen (or printer).FORTRAN 66 (also FORTRAN IV). ( S - C ) ) WRITE ( 6, 601 ) A, B, C, AREA GO TO 10 50 WRITE ( 6, 602 ) STOP 90 WRITE ( 6, 603 ) STOP END 'Retro' FORTRAN IV A retro example of a FORTRAN IV (later evolved into FORTRAN 66) program deck is available on the page, including the IBM 1130 DM2 JCL required for compilation and execution. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |