CHDIR — Change working directory#

CHDIR(NAME)#

Change current working directory to a specified path.

Parameters:
  • NAME – The type shall be CHARACTER of default kind and shall specify a valid path within the file system.

  • STATUS – (Optional) INTEGER status flag of the default kind. Returns 0 on success, and a system specific and nonzero error code otherwise.

Standard:

GNU extension

Class:

Subroutine, function

Syntax:
CALL CHDIR(NAME [, STATUS])
STATUS = CHDIR(NAME)
Example:
PROGRAM test_chdir
  CHARACTER(len=255) :: path
  CALL getcwd(path)
  WRITE(*,*) TRIM(path)
  CALL chdir("/tmp")
  CALL getcwd(path)
  WRITE(*,*) TRIM(path)
END PROGRAM
See also:

GETCWD — Get current working directory