subroutine setup() integer :: unit call execute_command_line('mkdir dir1 dir2') call execute_command_line('mkdir dir1/dir3') open(newunit=unit,file='dir1/exist.dat',status='new') close(unit) open(newunit=unit,file='dir1/dir3/exist3.dat',status='new') close(unit) open(newunit=unit,file='dir2/exist2.dat',status='new') close(unit) end subroutine setup