Fix the summation mode + temporary fix for file unit numbers

- Add missing array allocations
- Add parameter for varying number of columns in input files
- Change output unit numbers (dirty fix. Original units created an empty
  named file, but wrote in default named fort.* files)
This commit is contained in:
Lorenzo Figini 2022-11-24 23:37:29 +01:00
parent 411c4ece48
commit e6d864e63b

View File

@ -81,13 +81,13 @@ program main
call log_message(level=INFO, mod='main', msg='summing profiles') call log_message(level=INFO, mod='main', msg='summing profiles')
sum: block sum: block
real(wp_) :: pabs, icd, pec real(wp_), dimension(:), allocatable :: jphi
real(wp_), dimension(:), allocatable :: dpdv, jcd, jphi
real(wp_), dimension(:), allocatable :: currins, pins, rtin, rpin real(wp_), dimension(:), allocatable :: currins, pins, rtin, rpin
integer :: i, j, k, n, ngam, irt real(wp_), dimension(:), allocatable :: extracol
character(len=255) :: filename integer :: i, j, k, l, n, ngam, nextracol, irt
character(len=255) :: filename, headerline, fmtstr
real(wp_), dimension(5) :: f48v real(wp_), dimension(5) :: f48v
real(wp_) :: gam,alp,bet, jphip,dpdvp, & real(wp_) :: jphip,dpdvp, &
rhotj,rhotjava,rhotp,rhotpav,drhotjava,drhotpav,ratjamx,ratjbmx rhotj,rhotjava,rhotp,rhotpav,drhotjava,drhotpav,ratjamx,ratjbmx
allocate(jphi(params%output%nrho), currins(params%output%nrho), & allocate(jphi(params%output%nrho), currins(params%output%nrho), &
pins(params%output%nrho), rtin(params%output%nrho), & pins(params%output%nrho), rtin(params%output%nrho), &
@ -100,7 +100,11 @@ program main
call exit(1) call exit(1)
end if end if
read(100, *) n, ngam open(unit=100 -1, file='f48sum.txt', action='write', status='unknown')
open(unit=100 -2, file='f7sum.txt', action='write', status='unknown')
read(100, *) n, ngam, nextracol
allocate(extracol(nextracol))
do i=1,n do i=1,n
read(100, *) filename read(100, *) filename
open(100 + i, file=filename, action='read', status='old', iostat=err) open(100 + i, file=filename, action='read', status='old', iostat=err)
@ -111,49 +115,55 @@ program main
end if end if
do j=1,22 do j=1,22
read(100 + i, *) read(100 + i, '(a255)') headerline
if (i == 1) then
write(100 -1, '(a)') trim(headerline)
write(100 -2, '(a)') trim(headerline)
end if
end do end do
end do end do
close(100)
open(100 + n+1, file='f48sum.txt', action='write', status='unknown')
open(100 + n+2, file='f7sum.txt', action='write', status='unknown')
allocate(results%jcd(params%output%nrho), results%dpdv(params%output%nrho))
do k=1,ngam do k=1,ngam
jphi = zero jphi = zero
jcd = zero results%jcd = zero
dpdv = zero results%dpdv = zero
currins = zero currins = zero
pins = zero pins = zero
do j=1,params%output%nrho do j=1,params%output%nrho
do i=1,n do i=1,n
read(100+i, *) gam, alp, bet, rpin(j), rtin(j), f48v(1:5), irt read(100+i, *) (extracol(l), l=1,nextracol), &
jphi(j) = f48v(1) + jphi(j) rpin(j), rtin(j), f48v(1:5), irt
jcd(j) = f48v(2) + jcd(j) jphi(j) = f48v(1) + jphi(j)
dpdv(j) = f48v(3) + dpdv(j) results%jcd(j) = f48v(2) + results%jcd(j)
currins(j) = f48v(4) + currins(j) results%dpdv(j) = f48v(3) + results%dpdv(j)
pins(j) = f48v(5) + pins(j) currins(j) = f48v(4) + currins(j)
pins(j) = f48v(5) + pins(j)
end do end do
write(100 + n+1,'(10(1x,e16.8e3),i5)') & write(fmtstr, '("(",i0,"(1x,e16.8e3),i5)")') nextracol+7
gam, alp, bet, rpin(j), rtin(j), & write(100 -1,trim(fmtstr)) &
jphi(j), jcd(j), dpdv(j), currins(j), pins(j), irt (extracol(l), l=1,nextracol), rpin(j), rtin(j), &
jphi(j), results%jcd(j), results%dpdv(j), &
currins(j), pins(j), irt
end do end do
pec = pins(params%output%nrho) results%pabs = pins(params%output%nrho)
icd = currins(params%output%nrho) results%icd = currins(params%output%nrho)
write(100 + n+1, *) write(100 -1, *)
call sum_profiles(params, jphi, jcd, dpdv, currins, & call sum_profiles(params, jphi, results%jcd, results%dpdv, &
pins, pabs, icd, jphip, dpdvp, rhotj, & currins, pins, results%pabs, results%icd, &
rhotjava, rhotp, rhotpav, drhotjava, & jphip, dpdvp, rhotj, rhotjava, rhotp, rhotpav, &
drhotpav, ratjamx, ratjbmx) drhotjava, drhotpav, ratjamx, ratjbmx)
write(100 + n+2, '(15(1x,e12.5),i5,4(1x,e12.5))') & write(fmtstr, '("(",i0,"(1x,e12.5),i5,7(1x,e12.5))")') nextracol+12
gam, alp, bet, icd, pabs, jphip, dpdvp, & write(100 -2, trim(fmtstr)) &
rhotj, rhotjava, rhotp, rhotpav, & (extracol(l), l=1,nextracol), results%icd, results%pabs, &
jphip, dpdvp, rhotj, rhotjava, rhotp, rhotpav, &
drhotjava, drhotpav, ratjamx, ratjbmx drhotjava, drhotpav, ratjamx, ratjbmx
end do end do
do i=1,n+2 do i=-2,n
close(100 + i) close(100 + i)
end do end do
deallocate(dpdv, jcd, jphi, currins, pins, rtin, rpin) deallocate(jphi, currins, pins, rtin, rpin)
deallocate(extracol)
deallocate(opts%params_file) deallocate(opts%params_file)
end block sum end block sum
else else