Showing posts with label HPC. Show all posts
Showing posts with label HPC. Show all posts

Saturday, September 19, 2015

Configuring PETSc and Eclipse Parallel Tools Platform (PTP) on macOS and Linux (C++ / Fortran)

The PETSc (Portable, Extensible Toolkit for Scientific Computation) framework provides high-performance data structures, sparse matrix operations, and scalable linear/nonlinear solvers for finite element and scientific modeling. Setting up PETSc within the Eclipse Parallel Tools Platform (PTP) IDE simplifies debugging and cross-compilation across macOS and Linux.

Platforms Verified: macOS Yosemite • Ubuntu 14.04 LTS • CentOS / RHEL (OpenMPI) • C++ and Fortran Compilers

1. Building PETSc with OpenMPI

Configure PETSc with shared libraries and debugging enabled:

./configure --with-shared-libraries=1 --with-debugging=1 PETSC_ARCH=debug
make PETSC_DIR=/path/to/petsc PETSC_ARCH=debug all
make PETSC_DIR=/path/to/petsc PETSC_ARCH=debug test

2. Eclipse Project Configuration

  1. Environment Variables: In Project Properties → C/C++ Build → Environment, add:
    • PETSC_DIR: Absolute path to your PETSc root directory.
    • PETSC_ARCH: Set to debug for Debug configurations and release for Release.
  2. Include Paths: Under C/C++ General → Paths and Symbols → Includes:
    ${PETSC_DIR}/include
    ${PETSC_DIR}/${PETSC_ARCH}/include
  3. Linker Libraries & Path: Under C/C++ Build → Settings → Linker:
    • Libraries (-l): Add petsc
    • Library search path (-L): Add ${PETSC_DIR}/${PETSC_ARCH}/lib
    • Miscellaneous Linker flags: Add runtime path binding:
      -Wl,-rpath,"${PETSC_DIR}/${PETSC_ARCH}/lib"
  4. Fortran Preprocessing Flags: If using gfortran, navigate to Fortran Build → Settings → Miscellaneous and add:
    -cpp -dM

3. Verification Test (C++)

#include <iostream>
#include "petsc.h"

int main(int argc, char *argv[]) {
    PetscInitialize(&argc, &argv, PETSC_NULL, PETSC_NULL);
    PetscPrintf(PETSC_COMM_WORLD, "PETSc successfully initialized in Eclipse!
");
    PetscFinalize();
    return 0;
}

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 ...