-
Notifications
You must be signed in to change notification settings - Fork 0
/
reduce_nlevelmax.F90
98 lines (79 loc) · 3.91 KB
/
reduce_nlevelmax.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
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
program reduce_nlevelmax_program
use amr_utils
character (LEN=:), allocatable :: output_basedir
character (LEN=:), allocatable :: new_output_basedir
character (LEN=:), allocatable :: integer_str
integer :: ioutput
integer :: length
integer :: new_nlevelmax
integer :: icpu
character (LEN=12) :: output_path_aux
character (LEN=18) :: amr_filename_aux
character (LEN=20) :: hydro_filename_aux
character (LEN=19) :: grav_filename_aux
character (LEN=:), allocatable :: output_path
integer, allocatable :: temp_int2D(:, :)
if (command_argument_count() /= 4) then
write (6,*) "Wrong number of command line arguments (expecting 4)!"
write (6,*) "First argument: directory containing RAMSES outputs"
write (6,*) "Second argument: output number of desired output"
write (6,*) "Third argument: directory to put new RAMSES output"
write (6,*) "Fourth argument: new nlevelmax"
stop 1
end if
call get_command_argument(1, length=length)
allocate(character(LEN=length) :: output_basedir)
call get_command_argument(1, output_basedir)
call get_command_argument(2, length=length)
allocate(character(LEN=length) :: integer_str)
call get_command_argument(2, integer_str)
read(integer_str, *) ioutput
deallocate(integer_str)
call get_command_argument(3, length=length)
allocate(character(LEN=length) :: new_output_basedir)
call get_command_argument(3, new_output_basedir)
allocate(character(LEN=length) :: integer_str)
call get_command_argument(4, integer_str)
read(integer_str, *) new_nlevelmax
deallocate(integer_str)
call output_dir(ioutput, output_path_aux)
if (len(output_basedir) == 0) then
output_path = output_path_aux // '/'
else
output_path = output_basedir // '/' // output_path_aux // '/'
end if
call read_info_header(output_path, ioutput)
do icpu=1,ncpu
call amr_filename(ioutput, icpu, amr_filename_aux)
write (6,*) "Reading file ", output_path//amr_filename_aux
call read_amr(output_path//amr_filename_aux, icpu)
call hydro_filename(ioutput, icpu, hydro_filename_aux)
write (6,*) "Reading file ", output_path//hydro_filename_aux
call read_hydro(output_path//hydro_filename_aux, icpu)
call grav_filename(ioutput, icpu, grav_filename_aux)
write (6,*) "Reading file ", output_path//grav_filename_aux
call read_grav(output_path//grav_filename_aux, icpu)
allocate(temp_int2D(1:ncpu, 1:new_nlevelmax))
temp_int2D = headl_cpu(:, 1:new_nlevelmax)
call move_alloc(temp_int2D, headl_cpu)
allocate(temp_int2D(1:ncpu, 1:new_nlevelmax))
temp_int2D = taill_cpu(:, 1:new_nlevelmax)
call move_alloc(temp_int2D, taill_cpu)
allocate(temp_int2D(1:ncpu, 1:new_nlevelmax))
temp_int2D = numbl_cpu(:, 1:new_nlevelmax)
call move_alloc(temp_int2D, numbl_cpu)
allocate(temp_int2D(1:10, 1:new_nlevelmax))
temp_int2D = numbtot_cpu(:, 1:new_nlevelmax)
call move_alloc(temp_int2D, numbtot_cpu)
nlevelmax_cpu = new_nlevelmax
write (6,*) "Writing file ", new_output_basedir//'/'//amr_filename_aux
call write_amr(new_output_basedir//'/'//amr_filename_aux, icpu)
write (6,*) "Writing file ", new_output_basedir//'/'//hydro_filename_aux
call write_hydro(new_output_basedir//'/'//hydro_filename_aux, icpu)
write (6,*) "Writing file ", new_output_basedir//'/'//grav_filename_aux
call write_grav(new_output_basedir//'/'//grav_filename_aux, icpu)
call deallocate_amr()
call deallocate_hydro()
call deallocate_grav()
end do
end program reduce_nlevelmax_program