博文

目前显示的是标签为“fortran”的博文

FORTRAN90 allocatable arrays

Declaration: INTEGER, DIMENSION(:), ALLOCATABLE :: ages ! 1D REAL, DIMENSION(:,:), ALLOCATABLE :: speed ! 2D Allocation: READ*, isize ALLOCATE(ages(isize), STAT=ierr) IF (ierr /= 0) PRINT*, "ages : Allocation failed" ALLOCATE(speed(0:isize-1,10),STAT=ierr) IF (ierr /= 0) PRINT*, "speed : Allocation failed" the optional STAT = field reports on the success of the storage request. If the INTEGER variable ierr is zero the request was successful otherwise it failed. Deallocating Arrays IF (ALLOCATED(ages)) DEALLOCATE(ages,STAT=ierr) Note: this ALLOCATED() is an intrinic function return a logic value reporting the status of the array

FORTRAN77 Arithmetic Expressions

Note:The order of evaluation of an expression is: sub-expressions in parentheses function references exponentiation, i.e. raising to a power multiplication and division addition, subtraction, or negation. Within each of these groups evaluation proceeds from left to right, except that exponentiations are evaluated from right to left. Thus: A / B / C is equivalent to (A / B) / C whereas X ** Y ** Z is equivalent to X ** (Y ** Z) . Note: An expression does not have to be evaluated fully if its value can be determined otherwise: for example the result of: X * FUNC(G) can be determined without calling the function FUNC if X happens to be zero. This will not cause problems if you only use functions that have no side effects.(Like short-circute of ||) A Fortran system is not required to evaluate every term in a logical expression completely if its value can be determined more simply.