Skip to content

Instantly share code, notes, and snippets.

@shane5ul
Last active December 20, 2015 23:29
Show Gist options
  • Save shane5ul/6212831 to your computer and use it in GitHub Desktop.
Save shane5ul/6212831 to your computer and use it in GitHub Desktop.
write to a file with a variable filename
program foo
character(len=12) :: filename
integer :: i
i = 10
write (filename, "(A4,i0.4,A4)") "file", i,".dat"
print*, trim(filename)
open(1, file=filename)
! write to the file
close(1)
end program foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment