-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDt7mod.f90
55 lines (48 loc) · 1.73 KB
/
Dt7mod.f90
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
module PowerSetModule_EnJnDeSIgn2024_Dt7
implicit none
contains
subroutine PowerSET_EnJnDeSIgn2024(set, n, subsets)
integer, intent(in) :: set(:)
integer, intent(in) :: n
integer, allocatable, intent(out) :: subsets(:, :)
integer :: i, subset, total_subsets
! Calculate total number of subsets (2^n)
total_subsets = 2**n
! Allocate array to store subsets
allocate(subsets(total_subsets, n))
! Generate each subset
do subset = 0, total_subsets - 1
do i = 1, n
if (btest(subset, i-1)) then
subsets(subset + 1, i) = set(i)
else
subsets(subset + 1, i) = 0
end if
end do
end do
end subroutine PowerSET_EnJnDeSIgn2024
subroutine read_csv(file_name, data, n)
character(len=*), intent(in) :: file_name
integer, allocatable, intent(out) :: data(:)
integer, intent(in) :: n
integer :: unit, i, io_status
! Allocate data array
allocate(data(n))
! Open the file
open(unit=954, file=file_name, status='old', action='read', iostat=io_status)
if (io_status /= 0) then
print *, "Error opening file:", file_name
stop
end if
! Read data from file
do i = 1, n
read(unit, '(I10)', iostat=io_status) data(i)
if (io_status /= 0) then
print *, "Error reading file:", file_name, "at row", i
stop
end if
end do
! Close the file
close(unit)
end subroutine read_csv
end module PowerSetModule_EnJnDeSIgn2024_Dt7