Write volume-averaged values and other information to the log file
subroutine printlog_default use mod_timing use mod_forest, only: nleafs, nleafs_active, nleafs_level use mod_global_parameters logical :: fileopen integer :: i, iw, level double precision :: wmean(1:nw), total_volume double precision :: volume_coverage(refine_max_level) integer :: nx1,nx2,nx3, nc, ncells, dit double precision :: dtTimeLast, now, cellupdatesPerSecond double precision :: activeBlocksPerCore, wctPerCodeTime, timeToFinish character(len=40) :: fmt_string character(len=80) :: filename character(len=2048) :: line logical, save :: opened = .false. integer :: amode, istatus(MPI_STATUS_SIZE) integer, parameter :: my_unit = 20 ! Compute the volume-average of w**1 = w call get_volume_average(1, wmean, total_volume) ! Compute the volume coverage call get_volume_coverage(volume_coverage) if (mype == 0) then ! To compute cell updates per second, we do the following: nx1=ixMhi1-ixMlo1+1;nx2=ixMhi2-ixMlo2+1;nx3=ixMhi3-ixMlo3+1; nc=nx1*nx2*nx3 ncells = nc * nleafs_active ! assumes the number of active leafs haven't changed since last compute. now = MPI_WTIME() dit = it - itTimeLast dtTimeLast = now - timeLast itTimeLast = it timeLast = now cellupdatesPerSecond = dble(ncells) * dble(nstep) * dble(dit) / & (dtTimeLast * dble(npe)) ! blocks per core: activeBlocksPerCore = dble(nleafs_active) / dble(npe) ! Wall clock time per code time unit in seconds: wctPerCodeTime = dtTimeLast / max(dit * dt, epsilon(1.0d0)) ! Wall clock time to finish in hours: timeToFinish = (time_max - global_time) * wctPerCodeTime / 3600.0d0 ! On first entry, open the file and generate the header if (.not. opened) then filename = trim(base_filename) // ".log" ! Delete the log when not doing a restart run if (restart_from_file == undefined) then open(unit=my_unit,file=trim(filename),status='replace') close(my_unit, status='delete') end if amode = ior(MPI_MODE_CREATE,MPI_MODE_WRONLY) amode = ior(amode,MPI_MODE_APPEND) call MPI_FILE_OPEN(MPI_COMM_SELF, filename, amode, MPI_INFO_NULL,& log_fh, ierrmpi) opened = .true. ! Start of file headern line = "it global_time dt" do level=1,nw i = len_trim(line) + 2 write(line(i:),"(a,a)") trim(cons_wnames(level)), " " end do ! Volume coverage per level do level = 1, refine_max_level i = len_trim(line) + 2 write(line(i:), "(a,i0)") "c", level end do ! Cell counts per level do level=1,refine_max_level i = len_trim(line) + 2 write(line(i:), "(a,i0)") "n", level end do ! Rest of file header line = trim(line) // " | Xload Xmemory 'Cell_Updates /second/core'" line = trim(line) // " 'Active_Blocks/Core' 'Wct Per Code Time [s]'" line = trim(line) // " 'TimeToFinish [hrs]'" ! Only write header if not restarting if (restart_from_file == undefined .or. reset_time) then call MPI_FILE_WRITE(log_fh, trim(line) // new_line('a'),& len_trim(line)+1, MPI_CHARACTER, istatus, ierrmpi) end if end if ! Construct the line to be added to the log fmt_string = '(' // fmt_i // ',2' // fmt_r // ')' write(line, fmt_string) it, global_time, dt i = len_trim(line) + 2 write(fmt_string, '(a,i0,a)') '(', nw, fmt_r // ')' write(line(i:), fmt_string) wmean(1:nw) i = len_trim(line) + 2 write(fmt_string, '(a,i0,a)') '(', refine_max_level, fmt_r // ')' write(line(i:), fmt_string) volume_coverage(1:refine_max_level) i = len_trim(line) + 2 write(fmt_string, '(a,i0,a)') '(', refine_max_level, fmt_i // ')' write(line(i:), fmt_string) nleafs_level(1:refine_max_level) i = len_trim(line) + 2 fmt_string = '(a,6' // fmt_r2 // ')' write(line(i:), fmt_string) '| ', Xload, Xmemory, cellupdatesPerSecond,& activeBlocksPerCore, wctPerCodeTime, timeToFinish call MPI_FILE_WRITE(log_fh, trim(line) // new_line('a') ,& len_trim(line)+1, MPI_CHARACTER, istatus, ierrmpi) end if end subroutine printlog_default