Change current working directory to a specified path.
This intrinsic is provided in both subroutine and function forms; however, only one form can be used in any given program unit.
GNU extension
Subroutine, function
| CALL CHDIR(NAME [, STATUS]) | 
| STATUS = CHDIR(NAME) | 
| NAME | The type shall be CHARACTERof default kind and shall specify a valid path within the file system. | 
| STATUS | (Optional) INTEGERstatus flag of the default kind. Returns 0 on success, and a system specific and nonzero error code otherwise. | 
PROGRAM test_chdir
  CHARACTER(len=255) :: path
  CALL getcwd(path)
  WRITE(*,*) TRIM(path)
  CALL chdir("/tmp")
  CALL getcwd(path)
  WRITE(*,*) TRIM(path)
END PROGRAM
    © Free Software Foundation
Licensed under the GNU Free Documentation License, Version 1.3.
    https://gcc.gnu.org/onlinedocs/gcc-10.2.0/gfortran/CHDIR.html