write result averages

This commit is contained in:
ignis 2019-04-29 17:21:23 +09:00
parent d7fc7413be
commit 06f5c0b0b9
4 changed files with 54 additions and 0 deletions

View file

@ -92,6 +92,20 @@ end do
end do
"""
avg_array_write = '''
integer :: i
open (200, file="qEdge_X.dat")
write (200,*) output_header
do i=1,nxp
write (200,'({0}e20.10)') real(i)*hxp, {1}
end do
close (200)
'''
avg_array_divide = "{0} = {0} / denum {1}"
real_array_diff = "call {0[0]} ( {0[0]}_{0[1]}, {0[1]} )"
@ -553,6 +567,16 @@ class FortranProgram:
avg1 = StringIO.StringIO()
calc2 = StringIO.StringIO()
avg2 = StringIO.StringIO()
wres = StringIO.StringIO()
hfmt = 'character (len = *), parameter :: output_header="{}"'
print >>decl, hfmt.format(" ".join(["x"] + self.parser.averages))
avgarr = "{}(i)"
print >>wres, avg_array_write.format(
len(self.parser.averages)+1,
", ".join(map(avgarr.format, self.parser.averages))
)
for var in self.pass1set | self.pass2set:
print >>decl, self.codes[var]["decl"]
@ -584,6 +608,7 @@ class FortranProgram:
md["module_pass1_avg"] = avg1.getvalue()
md["module_pass2"] = calc2.getvalue()
md["module_pass2_avg"] = avg2.getvalue()
md["module_write_result"] = wres.getvalue()
return md

View file

@ -68,4 +68,11 @@ denum=real(nfiles*nyp*nzp)
end subroutine m_{0[module_name]}_average_pass2
subroutine m_{0[module_name]}_write_result
{0[module_write_result]}
end subroutine m_{0[module_name]}_write_result
end module m_{0[module_name]}

View file

@ -6,6 +6,7 @@ use m_calculate
implicit none
character (len = *), parameter :: output_header="avg_fsd fsd_avg_t1 fsd_avg_t2 fsd_avg_fu fsd_avg_absk"
real*8, allocatable, dimension(:,:,:) :: ddx_nx
real*8, allocatable, dimension(:,:,:) :: t1_fsd
real*8, allocatable, dimension(:,:,:) :: t2_fsd
@ -412,5 +413,25 @@ fsd_avg_t2 = fsd_avg_t2 / denum / avg_fsd
end subroutine m_terms_average_pass2
subroutine m_terms_write_result
integer :: i
open (200, file="qEdge_X.dat")
write (200,*) output_header
do i=1,nxp
write (200,'(6e20.10)') real(i)*hxp, avg_fsd(i), fsd_avg_t1(i), fsd_avg_t2(i), fsd_avg_fu(i), fsd_avg_absk(i)
end do
close (200)
end subroutine m_terms_write_result
end module m_terms

View file

@ -77,6 +77,7 @@
CALL m_terms_average_pass2(countnum)
CALL m_terms_write_result
CALL DEALLOCATES_CLOSE