Skip to content

Commit

Permalink
Fix MHD restart
Browse files Browse the repository at this point in the history
  • Loading branch information
mathrack committed Apr 18, 2024
1 parent 48da1ed commit 385c26d
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions src/tools.f90
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ subroutine restart(ux1,uy1,uz1,dux1,duy1,duz1,ep1,pp3,phi1,dphi1,px1,py1,pz1,rho
use param
use MPI
use navier, only : gradp
use mhd, only : mhd_active,mhd_equation,Bm
use mhd, only : mhd_active,mhd_equation,Bm,dBm

implicit none

Expand Down Expand Up @@ -313,9 +313,17 @@ subroutine restart(ux1,uy1,uz1,dux1,duy1,duz1,ep1,pp3,phi1,dphi1,px1,py1,pz1,rho
endif

if (mhd_active .and. mhd_equation) then
call decomp_2d_write_one(1,Bm(:,:,:,1),resfile,'bx',0,io_restart,reduce_prec=.false.)
call decomp_2d_write_one(1,Bm(:,:,:,2),resfile,'by',0,io_restart,reduce_prec=.false.)
call decomp_2d_write_one(1,Bm(:,:,:,3),resfile,'bz',0,io_restart,reduce_prec=.false.)
call decomp_2d_write_one(1,Bm(:,:,:,1),resfile,'bx',0,io_restart,reduce_prec=.false.)
call decomp_2d_write_one(1,Bm(:,:,:,2),resfile,'by',0,io_restart,reduce_prec=.false.)
call decomp_2d_write_one(1,Bm(:,:,:,3),resfile,'bz',0,io_restart,reduce_prec=.false.)
if (itimescheme==3) then
call decomp_2d_write_one(1,dBm(:,:,:,1,2),resfile,'dbx-2',0,io_restart,reduce_prec=.false.)
call decomp_2d_write_one(1,dBm(:,:,:,2,2),resfile,'dby-2',0,io_restart,reduce_prec=.false.)
call decomp_2d_write_one(1,dBm(:,:,:,3,2),resfile,'dbz-2',0,io_restart,reduce_prec=.false.)
call decomp_2d_write_one(1,dBm(:,:,:,1,3),resfile,'dbx-3',0,io_restart,reduce_prec=.false.)
call decomp_2d_write_one(1,dBm(:,:,:,2,3),resfile,'dby-3',0,io_restart,reduce_prec=.false.)
call decomp_2d_write_one(1,dBm(:,:,:,3,3),resfile,'dbz-3',0,io_restart,reduce_prec=.false.)
endif
endif

call decomp_2d_end_io(io_restart, resfile)
Expand Down Expand Up @@ -432,9 +440,17 @@ subroutine restart(ux1,uy1,uz1,dux1,duy1,duz1,ep1,pp3,phi1,dphi1,px1,py1,pz1,rho
end if

if(mhd_active .and. mhd_equation) then
call decomp_2d_read_one(1,Bm(:,:,:,1),resfile,'bx',io_restart,reduce_prec=.false.)
call decomp_2d_read_one(1,Bm(:,:,:,2),resfile,'by',io_restart,reduce_prec=.false.)
call decomp_2d_read_one(1,Bm(:,:,:,3),resfile,'bz',io_restart,reduce_prec=.false.)
call decomp_2d_read_one(1,Bm(:,:,:,1),resfile,'bx',io_restart,reduce_prec=.false.)
call decomp_2d_read_one(1,Bm(:,:,:,2),resfile,'by',io_restart,reduce_prec=.false.)
call decomp_2d_read_one(1,Bm(:,:,:,3),resfile,'bz',io_restart,reduce_prec=.false.)
if (itimescheme==3) then
call decomp_2d_read_one(1,dBm(:,:,:,1,2),resfile,'dbx-2',io_restart,reduce_prec=.false.)
call decomp_2d_read_one(1,dBm(:,:,:,2,2),resfile,'dby-2',io_restart,reduce_prec=.false.)
call decomp_2d_read_one(1,dBm(:,:,:,3,2),resfile,'dbz-2',io_restart,reduce_prec=.false.)
call decomp_2d_read_one(1,dBm(:,:,:,1,3),resfile,'dbx-3',io_restart,reduce_prec=.false.)
call decomp_2d_read_one(1,dBm(:,:,:,2,3),resfile,'dby-3',io_restart,reduce_prec=.false.)
call decomp_2d_read_one(1,dBm(:,:,:,3,3),resfile,'dbz-3',io_restart,reduce_prec=.false.)
endif
endif

call decomp_2d_end_io(io_restart, resfile)
Expand Down Expand Up @@ -557,6 +573,14 @@ subroutine init_restart_adios2()
call decomp_2d_register_variable(io_restart, "bx", 1, 0, 0, mytype)
call decomp_2d_register_variable(io_restart, "by", 1, 0, 0, mytype)
call decomp_2d_register_variable(io_restart, "bz", 1, 0, 0, mytype)
if (itimescheme.eq.3) then
call decomp_2d_register_variable(io_restart, "dbx-2", 1, 0, 0, mytype)
call decomp_2d_register_variable(io_restart, "dby-2", 1, 0, 0, mytype)
call decomp_2d_register_variable(io_restart, "dbz-2", 1, 0, 0, mytype)
call decomp_2d_register_variable(io_restart, "dbx-3", 1, 0, 0, mytype)
call decomp_2d_register_variable(io_restart, "dby-3", 1, 0, 0, mytype)
call decomp_2d_register_variable(io_restart, "dbz-3", 1, 0, 0, mytype)
endif
end if

end subroutine init_restart_adios2
Expand Down

0 comments on commit 385c26d

Please sign in to comment.