Write , overwriting existing values
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
logical, | intent(in) | :: | write_text |
Write to text file |
||
logical, | intent(in) | :: | write_netcdf |
Write to netcdf file |
||
integer, | intent(in) | :: | file_id |
NetCDF ID of the file to write to |
subroutine do_write_final_fields(write_text, write_netcdf, file_id)
use mp, only: proc0
use file_utils, only: open_output_file, close_output_file
use gs2_io, only: nc_final_fields
use kt_grids, only: naky, ntheta0, aky, akx, theta0
use theta_grid, only: ntgrid, theta
use fields_arrays, only: phi, apar, bpar
implicit none
!> Write to text file
logical, intent(in) :: write_text
!> Write to netcdf file
logical, intent(in) :: write_netcdf
!> NetCDF ID of the file to write to
integer, intent(in) :: file_id
integer :: ik, it, ig, unit
if (.not. proc0) return
if (.not. (write_text .or. write_netcdf)) return
if (write_text) then
call open_output_file (unit, ".fields")
do ik = 1, naky
do it = 1, ntheta0
do ig = -ntgrid, ntgrid
write (unit, "(15(1x,e12.5))") &
theta(ig), aky(ik), akx(it), &
phi(ig,it,ik), &
apar(ig,it,ik), &
bpar(ig,it,ik), &
theta(ig) - theta0(it,ik), &
abs(phi(ig,it,ik))
end do
write (unit, "()")
end do
end do
call close_output_file (unit)
end if
if (write_netcdf) call nc_final_fields(file_id)
end subroutine do_write_final_fields