[petsc-dev] Use of the DISPLAY environment variable

Jed Brown jed at 59A2.org
Sun Aug 29 14:45:50 CDT 2010


PETSc uses the -display option differently from the DISPLAY environment
variable.  In particular, it prepends the hostname when DISPLAY starts
with ":".

  ierr = PetscOptionsGetString(PETSC_NULL,"-display",PetscDisplay,256,&flag);CHKERRQ(ierr);
  if (flag) PetscFunctionReturn(0);
[...]
    str = getenv("DISPLAY");
    if (!str || (str[0] == ':' && size > 1)) {
      ierr = PetscGetHostName(display,255);CHKERRQ(ierr);
      ierr = PetscStrcat(display,":0.0");CHKERRQ(ierr);
    } else {
      ierr = PetscStrncpy(display,str,256);CHKERRQ(ierr);
    }

Is this really the right thing (ignoring the small overflow
possibility)?  Why not concatenate hostname with the value of DISPLAY
when it starts with ':'?

But more importantly, firewalls are frequently set up to block port
6000, so DISPLAY=hostname:0.0 won't work, but DISPLAY=:0.0 will work
(obviously only among local nodes).  I've just gotten used to always
running with -display :0 in parallel, but how about reducing the
hostname to check whether it is the same on all hosts.  If so, then just
use DISPLAY as is.  This would make graphics Just Work on more systems.

Does this sound reasonable?

Jed



More information about the petsc-dev mailing list