13 integer,
intent(in) :: ixi^
l,ixo^
l, nwc
14 double precision,
intent(in) :: w(ixi^s, 1:nw)
15 double precision,
intent(in) :: x(ixi^s,1:
ndim)
16 double precision :: wnew(ixo^s, 1:nwc)
24 character(len=40) :: file_suffix
25 character(len=40) :: dataset_names(
max_nw)
45 integer,
intent(in) :: nwc
46 character(len=*),
intent(in):: aux_variable_names
47 character(len=*),
intent(in) :: file_suffix
50 function phys_convert_vars(ixI^L, ixO^L, w, x, nwc)
result(wnew)
52 integer,
intent(in) :: ixI^L, ixO^L, nwc
53 double precision,
intent(in) :: w(ixI^S, 1:nw)
54 double precision,
intent(in) :: x(ixI^S,1:ndim)
55 double precision :: wnew(ixO^S, 1:nwc)
56 end function phys_convert_vars
65 integer,
intent(in) :: nwc
66 character(len=*),
intent(in) :: dataset_names(:)
67 character(len=*),
intent(in) :: file_suffix
70 function phys_convert_vars(ixI^L, ixO^L, w, x, nwc)
result(wnew)
72 integer,
intent(in) :: ixI^L, ixO^L, nwc
73 double precision,
intent(in) :: w(ixI^S, 1:nw)
74 double precision,
intent(in) :: x(ixI^S,1:ndim)
75 double precision :: wnew(ixO^S, 1:nwc)
76 end function phys_convert_vars
82 call mpistop(
"INCREASE max_nw ")
86 temp%phys_convert_vars => phys_convert_vars
88 temp%file_suffix = file_suffix
89 temp%dataset_names(1:nwc) = dataset_names(1:nwc)
98 do while(
associated(temp))
99 call convert_dat_generic(temp%nwc, temp%dataset_names, temp%file_suffix, temp%phys_convert_vars)
113 integer :: file_handle, igrid, Morton_no, iwrite
114 integer :: ipe, ix_buffer(2*ndim+1), n_values
115 integer :: ixI^L, ixO^L, n_ghost(2*ndim)
116 integer :: ixOs^L,n_values_stagger
117 integer :: iorecvstatus(MPI_STATUS_SIZE)
118 integer :: ioastatus(MPI_STATUS_SIZE)
119 integer :: igrecvstatus(MPI_STATUS_SIZE)
120 integer :: istatus(MPI_STATUS_SIZE)
122 integer(kind=MPI_OFFSET_KIND) :: offset_tree_info
123 integer(kind=MPI_OFFSET_KIND) :: offset_block_data
124 integer(kind=MPI_OFFSET_KIND) :: offset_offsets
125 double precision,
allocatable :: w_buffer(:)
126 double precision,
allocatable:: converted_vars(:^D&,:)
128 integer :: idim, itag
129 integer,
allocatable :: block_ig(:, :)
130 integer,
allocatable :: block_lvl(:)
131 integer(kind=MPI_OFFSET_KIND),
allocatable :: block_offset(:)
133 integer,
intent(in) :: nwc
134 character(len=*),
intent(in) :: dataset_names(:)
135 character(len=*),
intent(in) :: file_suffix
138 function convert_vars(ixI^L, ixO^L,w,x,nwc)
result(wres)
140 integer,
intent(in) :: ixI^L, ixO^L, nwc
141 double precision,
intent(in) :: x(ixI^S,1:ndim)
142 double precision,
intent(in) :: w(ixI^S,1:nw)
143 double precision :: wres(ixO^S,1:nwc)
144 end function convert_vars
153 allocate(w_buffer(n_values))
156 allocate(block_ig(ndim,
nleafs))
157 allocate(block_lvl(
nleafs))
158 allocate(block_offset(
nleafs+1))
165 offset_tree_info = -1
166 offset_block_data = -1
168 offset_block_data, dataset_names, nwc)
170 call mpi_file_get_position(file_handle, offset_tree_info,
ierrmpi)
177 igrid =
sfc(1, morton_no)
178 ipe =
sfc(2, morton_no)
181 block_ig(:, morton_no) = [ pnode%ig^d ]
182 block_lvl(morton_no) = pnode%level
183 block_offset(morton_no) = 0
186 call mpi_file_write(file_handle, block_lvl,
size(block_lvl), &
189 call mpi_file_write(file_handle, block_ig,
size(block_ig), &
193 call mpi_file_get_position(file_handle, offset_offsets,
ierrmpi)
194 call mpi_file_write(file_handle, block_offset(1:
nleafs),
nleafs, &
197 call mpi_file_get_position(file_handle, offset_block_data,
ierrmpi)
200 if (offset_block_data - offset_tree_info /= &
202 nleafs * ((1+ndim) * size_int + 2 * size_int))
then
204 print *,
"Warning: MPI_OFFSET type /= 8 bytes"
205 print *,
"This *could* cause problems when reading .dat files"
209 block_offset(1) = offset_block_data
229 if(ps(igrid)%is_physical_boundary(2*idim-1)) n_ghost(idim)=
nghostcells
231 if(ps(igrid)%is_physical_boundary(2*idim)) n_ghost(ndim+idim)=
nghostcells
235 {ixomin^d = ixmlo^d - n_ghost(^d)\}
236 {ixomax^d = ixmhi^d + n_ghost(ndim+^d)\}
241 {iximin^d =
ixglo^d\}
242 {iximax^d =
ixghi^d\}
244 w_buffer(1:n_values) = pack(convert_vars(ixi^l, ixo^l,ps(igrid)%w(ixi^s, 1:nw), ps(igrid)%x(ixi^s, 1:ndim),nwc), .true.)
246 ix_buffer(1) = n_values
247 ix_buffer(2:) = n_ghost
250 call mpi_send(ix_buffer, 2*ndim+1, &
252 call mpi_send(w_buffer, n_values, &
256 call mpi_file_write(file_handle, ix_buffer(2:), &
257 2*ndim, mpi_integer, istatus,
ierrmpi)
258 call mpi_file_write(file_handle, w_buffer, &
259 n_values, mpi_double_precision, istatus,
ierrmpi)
262 block_offset(iwrite+1) = block_offset(iwrite) + &
263 int(n_values, mpi_offset_kind) * size_double + &
275 call mpi_recv(ix_buffer, 2*ndim+1, mpi_integer, ipe, itag,
icomm,&
277 n_values = ix_buffer(1)
279 call mpi_recv(w_buffer, n_values, mpi_double_precision,&
282 call mpi_file_write(file_handle, ix_buffer(2:), &
283 2*ndim, mpi_integer, istatus,
ierrmpi)
284 call mpi_file_write(file_handle, w_buffer, &
285 n_values, mpi_double_precision, istatus,
ierrmpi)
288 block_offset(iwrite+1) = block_offset(iwrite) + &
289 int(n_values, mpi_offset_kind) * size_double + &
295 call mpi_file_seek(file_handle, offset_offsets, mpi_seek_set,
ierrmpi)
296 call mpi_file_write(file_handle, block_offset(1:
nleafs),
nleafs, &
300 call mpi_file_seek(file_handle, 0_mpi_offset_kind, mpi_seek_set,
ierrmpi)
302 offset_block_data, dataset_names, nwc)
304 call mpi_file_close(file_handle,
ierrmpi)
subroutine, public mpistop(message)
Exit MPI-AMRVAC with an error message.
subroutine convert_dat_generic(nwc, dataset_names, file_suffix, convert_vars)
subroutine add_convert_method2(phys_convert_vars, nwc, aux_variable_names, file_suffix)
type(convert_vars_method), pointer head_convert_vars_methods
subroutine init_convert()
subroutine add_convert_method(phys_convert_vars, nwc, dataset_names, file_suffix)
Module with basic grid data structures.
integer, dimension(:), allocatable, save sfc_to_igrid
Go from a Morton number to an igrid index (for a single processor)
integer, dimension(:), allocatable, save morton_start
First Morton number per processor.
integer, save nleafs
Number of leaf block.
integer, dimension(:), allocatable, save morton_stop
Last Morton number per processor.
integer, dimension(:,:), allocatable, save sfc
Array to go from a Morton number to an igrid and processor index. Sfc(1:3, MN) contains [igrid,...
integer, save nparents
Number of parent blocks.
type(tree_node_ptr), dimension(:,:), allocatable, save igrid_to_node
Array to go from an [igrid, ipe] index to a node pointer.
subroutine, public write_forest(file_handle)
This module contains definitions of global parameters and variables and some generic functions/subrou...
type(state), pointer block
Block pointer for using one block and its previous state.
integer ixghi
Upper index of grid block arrays.
integer, parameter ndim
Number of spatial dimensions for grid variables.
logical save_physical_boundary
True for save physical boundary cells in dat files.
integer icomm
The MPI communicator.
integer mype
The rank of the current MPI task.
integer ierrmpi
A global MPI error return code.
integer snapshotnext
IO: snapshot and collapsed views output numbers/labels.
integer npe
The number of MPI tasks.
double precision, dimension(:,:), allocatable rnode
Corner coordinates.
integer nghostcells
Number of ghost cells surrounding a grid.
double precision, dimension(ndim) dxlevel
integer, parameter ixglo
Lower index of grid block arrays (always 1)
integer, parameter max_nw
Maximum number of variables.
The data structure that contains information about a tree node/grid block.