/
filepaths.jl
142 lines (123 loc) · 5.04 KB
/
filepaths.jl
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
"""
```julia
createpath(output::Real, path::String; namelist::String="")
return FileNamesType
```
"""
function createpath(output::Real, path::String; namelist::String="")
if output < 10
Path_folder = "output_0000$output"
Info_file = "info_0000$output.txt"
AMR_file = "amr_0000$output."
Hydro_file = "hydro_0000$output."
Grav_file = "grav_0000$output."
RT_file = "rt_0000$output."
RT_descriptor = "info_rt_0000$output.txt"
Part_file = "part_0000$output."
Clump_file = "clump_0000$output."
Timer_file = "timer_0000$output.txt"
Header_file = "header_0000$output.txt"
elseif output < 100 && output > 9
Path_folder = "output_000$output"
Info_file = "info_000$output.txt"
AMR_file = "amr_000$output."
Hydro_file = "hydro_000$output."
Grav_file = "grav_000$output."
RT_file = "rt_000$output."
RT_descriptor = "info_rt_000$output.txt"
Part_file = "part_000$output."
Clump_file = "clump_000$output."
Timer_file = "timer_000$output.txt"
Header_file = "header_000$output.txt"
elseif output < 1000 && output > 99
Path_folder = "output_00$output"
Info_file = "info_00$output.txt"
AMR_file = "amr_00$output."
Hydro_file = "hydro_00$output."
Grav_file = "grav_00$output."
RT_file = "rt_00$output."
RT_descriptor = "info_rt_00$output.txt"
Part_file = "part_00$output."
Clump_file = "clump_00$output."
Timer_file = "timer_00$output.txt"
Header_file = "header_00$output.txt"
elseif output < 10000 && output > 999
Path_folder = "output_0$output"
Info_file = "info_0$output.txt"
AMR_file = "amr_0$output."
Hydro_file = "hydro_0$output."
Grav_file = "grav_0$output."
RT_file = "rt_0$output."
RT_descriptor = "info_rt_0$output.txt"
Part_file = "part_0$output."
Clump_file = "clump_0$output."
Timer_file = "timer_0$output.txt"
Header_file = "header_0$output.txt"
elseif output < 100000 && output > 9999
Path_folder = "output_$output"
Info_file = "info_$output.txt"
AMR_file = "amr_$output."
Hydro_file = "hydro_$output."
Grav_file = "grav_$output."
RT_file = "rt_$output."
RT_descriptor = "info_rt_$output.txt"
Part_file = "part_$output."
Clump_file = "clump_$output."
Timer_file = "timer_$output.txt"
Header_file = "header_$output.txt"
end
fnames = FileNamesType()
fnames.output = joinpath(path, Path_folder)
fnames.info = joinpath(path, Path_folder, Info_file)
fnames.amr = joinpath(path, Path_folder, AMR_file)
fnames.hydro = joinpath(path, Path_folder, Hydro_file)
fnames.hydro_descriptor = joinpath(path, Path_folder, "hydro_file_descriptor.txt")
fnames.gravity = joinpath(path, Path_folder, Grav_file)
fnames.particles = joinpath(path, Path_folder, Part_file)
fnames.part_descriptor = joinpath(path, Path_folder, "part_file_descriptor.txt")
fnames.rt = joinpath(path, Path_folder, RT_file)
fnames.rt_descriptor = joinpath(path, Path_folder, "rt_file_descriptor.txt") # newer version
fnames.rt_descriptor_v0 = joinpath(path, Path_folder, RT_descriptor) # older version
fnames.clumps = joinpath(path, Path_folder, Clump_file)
fnames.timer = joinpath(path, Path_folder, Timer_file)
fnames.header = joinpath(path, Path_folder, Header_file)
fnames.compilation = joinpath(path, Path_folder, "compilation.txt")
fnames.makefile = joinpath(path, Path_folder, "makefile.txt")
fnames.patchfile = joinpath(path, Path_folder, "patches.txt")
if namelist == "" || namelist == "./"
fnames.namelist = joinpath(path, Path_folder, "namelist.txt")
else
fnames.namelist = namelist
end
return fnames
end
function createpath!(dataobject::InfoType; namelist::String="")
dataobject.fnames = createpath(dataobject.output, dataobject.path, namelist=namelist)
return dataobject
end
function getproc2string(path::String, icpu::Int32)
if icpu < 10
return string(path, "out0000", icpu)
elseif icpu < 100 && icpu > 9
return string(path, "out000", icpu)
elseif icpu < 1000 && icpu > 99
return string(path, "out00", icpu)
elseif icpu < 10000 && icpu > 999
return string(path, "out0", icpu)
elseif icpu < 100000 && icpu > 9999
return string(path, "out", icpu)
end
end
function getproc2string(path::String, textfile::Bool, icpu::Int)
if icpu < 10
return string(path, "txt0000", icpu)
elseif icpu < 100 && icpu > 9
return string(path, "txt000", icpu)
elseif icpu < 1000 && icpu > 99
return string(path, "txt00", icpu)
elseif icpu < 10000 && icpu > 999
return string(path, "txt0", icpu)
elseif icpu < 100000 && icpu > 9999
return string(path, "txt", icpu)
end
end