program main open(11, file='file.dat', status='replace') write(11, *) 'aaa' call write_string() close(11) !-------------------------------------------------------------- ! !-------------------------------------------------------------- contains subroutine write_string() implicit none write(11, *) 'bbb' end subroutine write_string !-------------------------------------------------------------- ! !-------------------------------------------------------------- end program main