-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathopen_units_limit.f90
More file actions
25 lines (25 loc) · 896 Bytes
/
open_units_limit.f90
File metadata and controls
25 lines (25 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
program open_units_limit ! creates up to 10000 files
implicit none
integer, parameter :: nunits = 10**4
character (len=*), parameter :: prefix = "temp_", suffix = ".txt"
integer :: i,iu,ierr
character (len=100) :: fname
do i=1,nunits
iu = 9 + i
write (fname,"(a,i0,a)") prefix,i,suffix
! having set file name, connect it to a new unit number
open (unit=iu,file=trim(fname),action="write",iostat=ierr)
if (ierr /= 0) then
write (*,*) "could not connect unit for i =",i
error stop
end if
write (iu,*) i ! write data
end do
write (*,*) "# units connected =",nunits
end program open_units_limit
! Windows Intel Fortran output:
! # units connected = 10000
! Windows gfortran output:
! could not connect unit for i = 2046
! WSL2 gfortran output:
! could not connect unit for i = 1022