7 character(len=NEKO_FNAME_LEN) :: inputchar, mesh_fname, fld_fname, output_fname
8 type(file_t) ::
fld_file, part_file, output_file
9 real(kind=rp) :: start_time
10 type(fld_file_data_t) :: fld_data, fld_data_avg
13 argc = command_argument_count()
15 if ((argc .lt. 3) .or. (argc .gt. 3))
then
16 if (pe_rank .eq. 0)
then
17 write(*,*)
'Usage: ./average_fields_in_time field_series_name.fld start_time output_name.fld'
18 write(*,*)
'Example command: ./average_fields_in_time mean_field104.fld 103.2 mean_field_avg.fld'
19 write(*,*)
'Computes the average field over the fld files described in mean_field104.nek5000'
20 write(*,*)
'The start time is the time at which the first file startsto collect stats'
21 write(*,*)
'The files need to be aranged chronological order.'
22 write(*,*)
'The average field is then stored in a fld series, i.e. output_name.nek5000 and output_name.f00000'
29 call get_command_argument(1, inputchar)
30 read(inputchar, *) fld_fname
32 call get_command_argument(2, inputchar)
33 read(inputchar, *) start_time
34 call get_command_argument(3, inputchar)
35 read(inputchar, *) output_fname
38 call fld_data_avg%init()
42 call fld_data_avg%scale(fld_data_avg%time-start_time)
43 if (pe_rank .eq. 0)
write(*,*) fld_data_avg%nelv, fld_data_avg%n_scalars
45 do i = 1, fld_data_avg%meta_nsamples-1
46 if (pe_rank .eq. 0)
write(*,*)
'Reading file:', i+1
48 call fld_data%scale(fld_data%time-fld_data_avg%time)
49 call fld_data_avg%add(fld_data)
51 if (pe_rank .eq. 0)
write(*,*)
'dt', fld_data%time - fld_data_avg%time
52 fld_data_avg%time = fld_data%time
54 call fld_data_avg%scale(1.0_rp/(fld_data_avg%time-start_time))
56 output_file = file_t(trim(output_fname))
60 if (pe_rank .eq. 0)
write(*,*)
'Writing file: ', trim(output_fname)
61 call output_file%write(fld_data_avg, fld_data_avg%time)
62 if (pe_rank .eq. 0)
write(*,*)
'Done'
program average_fields_in_time
Program to sum up averaged fields computed for statistics and mean field Martin Karp 27/01-23.
subroutine neko_finalize(c)