Showing posts with label Scientific Computing. Show all posts
Showing posts with label Scientific Computing. Show all posts

Monday, May 26, 2014

Essential Fortran Tips: Implicit Typing, Common Blocks, and Array Bounds

When developing or maintaining scientific simulation and finite-element codes in Fortran, understanding memory sharing semantics and legacy typing rules prevents subtle computational bugs. Here are key fundamental tips to keep in mind:

Topics: Implicit precision typing • Common block limits • Explicit bounds declarations

1. Implicit Typing and Precision Control

By default in classic Fortran, variables starting with letters I through N default to integer, while all others default to single-precision real. You can enforce double precision across designated variable prefixes using:

IMPLICIT DOUBLE PRECISION (A-H, O-Z)

Modern recommendation: In Fortran 90 and newer, always specify IMPLICIT NONE at the top of every module and subroutine, explicitly declaring types and kinds (e.g. REAL(dp)) to avoid unintended variable scoping.

2. Blank vs. Named COMMON Blocks

  • A Fortran program may contain only one blank (unnamed) COMMON block across all translation units.
  • A program can declare any number of named COMMON blocks:
    COMMON /grid_params/ nx, ny, deltax, deltay
  • Ensure that variable sizes and ordering within named COMMON blocks match identically across all subroutines that include them.

How Google Antigravity Solved the Mysterious NVIDIA Sleep Reboot on My Dell Inspiron 7567 (Ubuntu Linux)

If you run modern Ubuntu or Linux on a Dell Inspiron 15 Gaming (7567) or a similar 7th-gen Intel laptop paired with an NVIDIA GeForce GTX ...