41 character(len=64):: filename=
'' 42 class(
patch_t),
pointer:: patch=>null()
43 integer:: size=0, nv=0
46 logical:: initialized=.false.
47 type(
dll_t):: kind_list
52 procedure:: update_counters
53 procedure:: register_kind
55 procedure,
nopass:: output_txt
56 procedure,
nopass:: output_nml
58 procedure,
nopass:: close
59 procedure:: open_and_close
67 SUBROUTINE init (self, task)
71 logical,
save:: first_time=.true.
72 character(len=120):: id = &
73 '$Id: 47ffa987be81f1602fb7b39a0982df4b90b8ed5b $ io/data_io_mod.f90' 75 call trace%begin(
'data_io_t%init')
76 call trace%print_id (id)
80 if (io%do_output)
then 81 call time_slices%init (task%nt)
84 if (io%method==
'direct')
then 85 call direct_io%init (task)
86 else if (io%method==
'amr')
then 87 call amr_io%init (task)
88 else if (io%method==
'pan')
then 89 call parallel_io%init (task)
90 else if (io%method==
'parallel')
then 91 call parallel_io%init (task)
92 else if (io%method==
'snapshot')
then 93 call parallel_io%init (task)
97 call self%lock%init (
'data_io')
98 call self%kind_list%init
99 self%initialized = .true.
105 call self%counters%init
108 call pdf_io%init (task)
116 SUBROUTINE update_counters (self, patch, incr)
119 integer:: incr, count1, count2, iout
121 call trace%begin (
'data_io_t%update_counters')
122 call self%lock%set (
'update_counters')
129 iout = nint(patch%pdf_next/pdf_io%out_time)
130 call pdf_io%counters%update ( iout+1, io%nwrite, incr, count1)
132 call self%counters%update (patch%iout+1, io%nwrite, incr, count2)
137 io%ntask = io%ntask+incr
142 call self%lock%unset (
'update_counters')
144 END SUBROUTINE update_counters
149 SUBROUTINE register_kind (self, patch)
151 class(
patch_t),
pointer:: patch
155 allocate (item, io_kind)
157 io_kind%patch => patch
158 io_kind%filename =
'snapshot_'//trim(patch%kind)//
'.dat' 159 io_kind%size = product(shape(patch%mem))
160 io_kind%nv = patch%nv
162 print
'(1x,a,4x,a,i8,4x,a,i3)', &
163 'data_io_t%register_kind: filename = '//trim(io_kind%filename), &
164 'array size (words) =', io_kind%size,
'nv =', io_kind%nv
166 call self%kind_list%append (item)
167 END SUBROUTINE register_kind
172 SUBROUTINE output (self, patch, experiment_name)
176 character(len=64) filename, logname, experiment_name
177 optional:: experiment_name
179 integer,
save:: created=-1
180 integer,
save:: itimer=0
182 integer:: it, count, np, prv
185 call pdf_io%update (patch)
186 if (.not.io%do_output)
return 187 call trace%begin(
'data_io_t%output', itimer=itimer)
192 call self%lock%set (
'output1')
193 if (io%needs_check)
then 194 if (io%method==
'amr')
then 197 call self%lock%unset (
'output1')
199 call self%lock%unset (
'output1')
205 if (io%ntask<=0)
then 206 call mpi%abort (
'io%ntask, which should be the number of active tasks, is zero')
208 if (io%ntotal<=0)
then 209 call mpi%abort (
'io%ntotal, which should be the total number of tasks, is zero')
211 if (io%verbose > 1) &
212 write (io_unit%log,*)
'io%nwrite =', io%nwrite
214 if (io%method==
'legacy')
then 217 np = (time_slices%order+1)/2
220 it = patch%iit(patch%nt-np)
223 if (t >= patch%out_next)
then 224 call self%lock%set (
'output2')
225 if (io%verbose > 1) &
226 write (io%output,*) wallclock(),
' thread',omp%thread,
' waitfor output' 235 if (io%verbose > 1) &
236 write (io%output,*) wallclock(),
' thread',omp%thread,
' locked output' 237 do while (patch%t(it) >= patch%out_next)
238 if (created < patch%iout)
then 240 call os%mkdir (trim(io%outputname))
242 call os%mkdir_no (patch%iout)
244 count = self%counters%decrement (patch%iout+1, io%nwrite)
245 if (io%verbose > 0) &
246 write (io_unit%log,*)
'count, nwrite =', count, io%nwrite
247 append = (count < io%nwrite-1)
252 if (io%method==
'direct')
then 253 call direct_io%output (patch)
254 else if (io%method==
'amr')
then 255 call amr_io%output (patch, count)
256 else if (io%method==
'legacy')
then 257 call legacy_io%output (patch)
259 else if (io%method==
'buffered')
then 260 call buffered_io%output (patch)
261 else if (io%method==
'pan')
then 262 if (io%format == 0) &
264 call parallel_io%output (patch, count)
265 else if (io%method==
'parallel')
then 266 if (io%format == 0) &
268 call parallel_io%output (patch, count)
269 else if (io%method==
'snapshot')
then 270 if (io%format == 0) &
272 call parallel_io%output (patch, count)
274 call mpi%abort (
'unknown io%method = '//io%method)
277 if (count==0 .and. .not.io_unit%do_validate)
then 278 if (io%out_time > 0d0)
then 279 prv = modulo(patch%it-2,patch%nt) + 1
280 write(io%output,
'(1x,a,2x,a,i5.5,6x,a,f9.3,6x,a,1p,3g14.5)') &
281 trim(io%method)//
'_io:output', &
282 'snapshot '//trim(io%outputname), patch%iout, &
283 'size(GB):', io%gb_out, &
284 'time:', patch%t(prv), patch%out_next, patch%time
286 write(io%output,
'(1x,a,2x,a,i5.5,6x,a,f9.3,6x,a,1p,g14.5)') &
287 trim(io%method)//
'_io:output', &
288 'snapshot '//trim(io%outputname), patch%iout, &
289 'size(GB):', io%gb_out,
'time:', patch%time
295 call patch%aux%output (patch%iout, patch%id)
296 call output_nml (patch, append)
298 patch%iout = patch%iout+1
299 if (io%out_time==0.0)
exit 300 patch%out_next = (floor(patch%time/io%out_time+1.0+1e-6))*io%out_time
302 if (io%verbose > 1) &
303 write (io%output,
'(a,i6,3f12.6,3i4)') &
304 'io_t%output: id, iout, time, out_next, count =', &
305 patch%id, patch%time, patch%time-patch%dtime, patch%out_next, &
306 patch%iout, io%nwrite, count
308 call os%mkdir_no (patch%iout)
310 if (io%verbose > 1) &
311 write (io%output,*) wallclock(),
' thread',omp%thread,
' unlocked output' 312 call self%lock%unset (
'output2')
315 call trace%end (itimer)
316 END SUBROUTINE output
319 SUBROUTINE open_and_close (self)
322 call trace%begin (
'data_io_t%open_and_close')
323 if (io%method ==
'snapshot')
then 324 call parallel_io%open_and_close ()
325 else if (io%method ==
'amr')
then 327 call self%lock%set (
'halt')
328 call self%lock%unset (
'halt')
332 END SUBROUTINE open_and_close
337 SUBROUTINE input (self, patch, ok)
343 call trace%begin (
'data_io_t%input')
345 if (io%restart >= 0)
then 347 if (io%method==
'direct')
then 348 call direct_io%input (patch, ok)
349 else if (io%method==
'legacy')
then 350 call input_nml (patch)
351 call legacy_io%input (patch, ok)
352 else if (io%method==
'pan')
then 353 call input_nml (patch)
354 call parallel_io%input (patch, ok)
355 else if (io%method==
'parallel')
then 356 call input_nml (patch)
357 call parallel_io%input (patch, ok)
358 else if (io%method==
'snapshot')
then 359 call input_nml (patch)
360 call parallel_io%input (patch, ok)
362 call mpi%abort (
'unknown io%method = '//io%method)
365 count = self%counters%decrement (io%restart+1, io%nwrite)
366 if (count==0 .and. io%master)
then 367 write(io%output,
'(1x,a,2x,a,i5.5,5x,"time:",1p,g14.5)') &
368 trim(io%method)//
'_io:input', &
369 'snapshot '//trim(io%outputname), io%restart, patch%time
371 patch%t(patch%it) = patch%time
384 SUBROUTINE output_txt (patch, append)
390 character(len=128) filename
395 call trace%begin (
'data_io_t%output_txt')
397 l = merge(patch%mesh%lb,patch%mesh%li,io%guard_zones)
398 u = merge(patch%mesh%ub,patch%mesh%ui,io%guard_zones)
399 if (io%format > 2)
then 400 write (filename,
'(a,i5.5,"/rank_",i5.5,".txt")') trim(io%outputname), patch%iout, mpi%rank
402 write (filename,
'(a,i5.5,"/",i5.5,".info")') trim(io%outputname), patch%iout, patch%id
405 write(io%output,
'(a,3x,"time:",2f13.6)') &
406 ' data_io_t%output_txt: '//trim(filename), patch%out_next, patch%time
410 open (io_unit%data, file=trim(filename), form=
'formatted', status=
'unknown', &
411 access=trim(merge(
'append ',
'sequential',append)))
412 write (io_unit%data,
'(i2.2)') io%format
413 if (io%format==3 .or. io%format==4)
write (io_unit%data,*) patch%id, nlines
417 write (io_unit%data,
'(a)') trim(patch%kind)
418 write (io_unit%data,
'(a)') trim(patch%eos)
419 write (io_unit%data,
'(a)') trim(patch%opacity)
420 write (io_unit%data,
'(1p,2e18.10,6(2x,3e18.10)1x,1x,2e10.3)') patch%out_next, &
421 patch%dtime, patch%position, patch%ds, patch%velocity, patch%llc_nat, &
422 patch%llc_cart, patch%mesh%centre_nat, patch%quality, patch%gamma
423 write (io_unit%data,
'(6(3i10.1,2x),3i2.1,1x,1i2.1,i3)') int(patch%box/patch%ds+0.5), &
424 u-l+1, patch%li, patch%ui, patch%n, patch%gn, patch%ng, patch%nv, patch%level
425 write (io_unit%data,
'(3(1i8.1,1x),i2.1)') patch%id, patch%iout, patch%istep, patch%mesh_type
429 END SUBROUTINE output_txt
437 SUBROUTINE output_nml (patch, append)
441 if (io%nml_version == 1)
then 442 call output_nml_v1(patch, append)
443 else if (io%nml_version == 2)
then 444 call output_nml_v2(patch, append)
445 else if (io%nml_version == 3)
then 446 call output_nml_v3(patch, append)
448 print*,io%nml_version
449 call mpi%abort (
'unknown nml_version!')
453 SUBROUTINE output_nml_v1 (patch, append)
457 character(len=128) :: filename
458 character(len=128),
save:: filename1=
'', filename2=
'' 459 integer :: ioformat, id, iout, istep, mesh_type, level,nv, nt, &
461 integer,
dimension(3):: ncell, li, ui, n, ng, gn, l, u
462 real :: gamma, quality
463 real(8) :: time, dtime, out_next, out_time, ms
464 real(8),
dimension(3):: size, position, ds, box, velocity, &
465 llc_nat, llc_cart, centre_nat
466 integer :: time_derivs
467 logical :: guard_zones, no_mans_land, periodic(3)
468 integer,
save :: last_snapshot=-1
469 character(len=16) :: kind, eos, opacity, method
470 namelist /io_nml/
format, ntotal, out_time, guard_zones, time_derivs, method
471 namelist /snapshot_nml/ ioformat, iout, time, ntotal, istep, mesh_type, &
472 position,
size, ds, box, velocity, level, quality, gamma, ncell, li, ui, n, &
473 ng, gn, nv, nt, nw, kind, eos, opacity, periodic, guard_zones, time_derivs, &
475 namelist /patch_nml/ id, time, position,
size, level, dtime
479 call trace%begin (
'data_io_t%output_nml')
486 out_time = io%out_time
487 guard_zones = io%guard_zones
488 time_derivs = io%time_derivs
491 time = merge(patch%time, patch%out_next, io%out_time==0)
493 l = merge(patch%mesh%lb,patch%mesh%li,io%guard_zones)
494 u = merge(patch%mesh%ub,patch%mesh%ui,io%guard_zones)
499 if (patch%kind(1:4) ==
'zeus')
then 506 mesh_type = patch%mesh_type
507 position = patch%position
511 velocity = patch%velocity
513 quality = patch%quality
521 nv = merge(io%nv, patch%nv, io%nv>0 .and. io%nv<patch%nv)
522 nv = nv*(io%time_derivs+1)
527 opacity = patch%opacity
528 no_mans_land = patch%no_mans_land
529 periodic = patch%periodic
530 if (mpi%master .and. patch%iout > last_snapshot)
then 531 last_snapshot = patch%iout
532 write (filename,
'(a,i5.5,"/snapshot.nml")') trim(io%outputname), patch%iout
533 if (filename /= filename1)
then 534 write(io_unit%log,
'(a,i5,2x,2a)') &
535 ' thread', omp%thread,
'opening ', trim(filename)
537 open (io_unit%nml1, file=trim(filename), form=
'formatted', status=
'unknown')
538 write(io_unit%log,
'(a,i5,2x,2a)') &
539 ' thread', omp%thread,
'opened ', trim(filename)
543 write (io_unit%nml1, io_nml)
544 write (io_unit%nml1, snapshot_nml)
545 call patch%idx%output (io_unit%nml1)
546 call file_append (io_unit%nml, io_unit%nml1)
548 if (io%debug(2))
write(io%output,
'(a,3x,"time:",2f13.6)') &
549 ' data_io_t%output_nml: '//trim(filename), patch%out_next, patch%time
554 write (filename,
'(a,i5.5,"/rank_",i5.5,"_patches.nml")') &
555 trim(io%outputname), patch%iout, mpi%rank
556 if (filename /= filename2)
then 557 if (filename2 /=
'')
close (io_unit%nml2)
558 write(io_unit%log,
'(a,i5,2x,2a)') &
559 ' thread', omp%thread,
'opening ', trim(filename)
561 open (io_unit%nml2, file=trim(filename), form=
'formatted', status=
'unknown', &
562 access=trim(merge(
'append ',
'sequential',append)))
563 write(io_unit%log,
'(a,i5,2x,2a)') &
564 ' thread', omp%thread,
'opened ', trim(filename)
571 if (mpi%master .and. .not.append)
then 572 call patch%idx%output (io_unit%nml2)
574 write (io_unit%nml2, patch_nml)
577 END SUBROUTINE output_nml_v1
579 SUBROUTINE output_nml_v2 (patch, append)
583 character(len=128) :: filename
584 character(len=128),
save:: filename1=
'', filename2=
'' 585 integer :: ioformat, id, iout, istep, mesh_type, level,nv, nt, &
586 nw, ntotal, format, nml_version
587 integer,
dimension(3):: ncell, li, ui, n, ng, gn, l, u
588 real :: gamma, quality
589 real(8) :: time, dtime, out_next, out_time, ms
590 real(8),
dimension(3):: size, position, ds, box, velocity, &
591 llc_nat, llc_cart, centre_nat
592 integer :: time_derivs
593 logical :: guard_zones, no_mans_land, periodic(3)
594 integer,
save :: last_snapshot=-1
595 character(len=32) :: kind, eos, opacity, method
596 namelist /io_nml/
format, ntotal, out_time, guard_zones, time_derivs, method, nml_version
597 namelist /snapshot_nml/ ioformat, iout, time, ntotal, box, li, ui, ng, gn, &
598 nv, nt, gamma, eos, opacity, periodic, guard_zones, time_derivs, no_mans_land
599 namelist /patch_nml/ id, position,
size, level, dtime, istep, ds, ncell, n, nw, &
600 velocity, quality, mesh_type, kind
604 call trace%begin (
'data_io_t%output_nml')
610 nml_version = io%nml_version
612 out_time = io%out_time
613 guard_zones = io%guard_zones
614 time_derivs = io%time_derivs
617 time = merge(patch%time, patch%out_next, io%out_time==0)
620 l = merge(patch%mesh%lb,patch%mesh%li,io%guard_zones)
621 u = merge(patch%mesh%ub,patch%mesh%ui,io%guard_zones)
626 if (patch%kind(1:4) ==
'zeus')
then 633 mesh_type = patch%mesh_type
634 position = patch%position
638 velocity = patch%velocity
640 quality = patch%quality
648 nv = merge(io%nv, patch%nv, io%nv>0 .and. io%nv<patch%nv)
649 nv = nv*(io%time_derivs+1)
654 opacity = patch%opacity
655 no_mans_land = patch%no_mans_land
656 periodic = patch%periodic
657 if (mpi%master .and. patch%iout > last_snapshot)
then 658 last_snapshot = patch%iout
659 write (filename,
'(a,i5.5,"/snapshot.nml")') trim(io%outputname), patch%iout
660 if (filename /= filename1)
then 661 write(io_unit%log,
'(a,i5,2x,2a)') &
662 ' thread', omp%thread,
'opening ', trim(filename)
664 open (io_unit%nml1, file=trim(filename), form=
'formatted', status=
'unknown')
665 write(io_unit%log,
'(a,i5,2x,2a)') &
666 ' thread', omp%thread,
'opened ', trim(filename)
670 write (io_unit%nml1, io_nml)
671 write (io_unit%nml1, snapshot_nml)
672 call patch%idx%output (io_unit%nml1)
673 call file_append (io_unit%nml, io_unit%nml1)
675 if (io%debug(2))
write(io%output,
'(a,3x,"time:",2f13.6)') &
676 ' data_io_t%output_nml: '//trim(filename), patch%out_next, patch%time
681 write (filename,
'(a,i5.5,"/rank_",i5.5,"_patches.nml")') &
682 trim(io%outputname), patch%iout, mpi%rank
683 if (filename /= filename2)
then 684 if (filename2 /=
'')
close (io_unit%nml2)
685 write(io_unit%log,
'(a,i5,2x,2a)') &
686 ' thread', omp%thread,
'opening ', trim(filename)
688 open (io_unit%nml2, file=trim(filename), form=
'formatted', status=
'unknown', &
689 access=trim(merge(
'append ',
'sequential',append)))
690 write(io_unit%log,
'(a,i5,2x,2a)') &
691 ' thread', omp%thread,
'opened ', trim(filename)
698 if (mpi%master .and. .not.append)
then 699 call patch%idx%output (io_unit%nml2)
701 write (io_unit%nml2, patch_nml)
704 END SUBROUTINE output_nml_v2
706 SUBROUTINE output_nml_v3 (patch, append)
710 character(len=128) :: filename
711 character(len=128),
save:: filename1=
'', filename2=
'' 712 integer :: ioformat, id, iout, istep, mesh_type, level,nv, nt, &
714 integer,
dimension(3):: ncell, li, ui, n, ng, gn, l, u
715 real :: gamma, quality
716 real(8) :: time, dtime, out_next, out_time, ms
717 real(8) :: times(2), dtimes(2)
718 real(8),
dimension(3):: size, position, ds, box, velocity, &
719 llc_nat, llc_cart, centre_nat
720 integer :: time_derivs, now, prv
721 integer(8) :: task_offset
722 logical :: guard_zones, no_mans_land, periodic(3)
723 integer,
save :: last_snapshot=-1
724 character(len=16) :: kind, eos, opacity, method
725 namelist /io_nml/
format, ntotal, out_time, guard_zones, time_derivs, method
726 namelist /snapshot_nml/ ioformat, iout, time, ntotal, istep, mesh_type, &
727 position,
size, ds, box, velocity, level, quality, gamma, ncell, li, ui, n, &
728 ng, gn, nv, nt, nw, kind, eos, opacity, periodic, guard_zones, time_derivs, &
730 namelist /patch_nml/ id, time, position,
size, level, dtime, times, dtimes, &
735 call trace%begin (
'data_io_t%output_nml')
742 out_time = io%out_time
743 guard_zones = io%guard_zones
744 time_derivs = io%time_derivs
747 time = merge(patch%time, patch%out_next, io%out_time==0)
750 task_offset = patch%amr_offset
751 if (patch%istep > 1)
then 752 prv = modulo(now-2,patch%nt) + 1
756 times(1) = patch%t (prv)
757 times(2) = patch%t (now)
758 dtimes(1) = patch%dt(prv)
759 dtimes(2) = patch%dt(now)
760 l = merge(patch%mesh%lb,patch%mesh%li,io%guard_zones)
761 u = merge(patch%mesh%ub,patch%mesh%ui,io%guard_zones)
766 if (patch%kind(1:4) ==
'zeus')
then 773 mesh_type = patch%mesh_type
774 position = patch%position
778 velocity = patch%velocity
780 quality = patch%quality
788 nv = merge(io%nv, patch%nv, io%nv>0 .and. io%nv<patch%nv)
789 nv = nv*(io%time_derivs+1)
794 opacity = patch%opacity
795 no_mans_land = patch%no_mans_land
796 periodic = patch%periodic
797 if (mpi%master .and. patch%iout > last_snapshot)
then 798 last_snapshot = patch%iout
799 write (filename,
'(a,i5.5,"/snapshot.nml")') trim(io%outputname), patch%iout
800 if (filename /= filename1)
then 801 write(io_unit%log,
'(a,i5,2x,2a)') &
802 ' thread', omp%thread,
'opening ', trim(filename)
804 open (io_unit%nml1, file=trim(filename), form=
'formatted', status=
'unknown')
805 write(io_unit%log,
'(a,i5,2x,2a)') &
806 ' thread', omp%thread,
'opened ', trim(filename)
810 write (io_unit%nml1, io_nml)
811 write (io_unit%nml1, snapshot_nml)
812 call patch%idx%output (io_unit%nml1)
813 call file_append (io_unit%nml, io_unit%nml1)
815 if (io%debug(2))
write(io%output,
'(a,3x,"time:",2f13.6)') &
816 ' data_io_t%output_nml: '//trim(filename), patch%out_next, patch%time
821 write (filename,
'(a,i5.5,"/rank_",i5.5,"_patches.nml")') &
822 trim(io%outputname), patch%iout, mpi%rank
823 if (filename /= filename2)
then 824 if (filename2 /=
'')
close (io_unit%nml2)
825 write(io_unit%log,
'(a,i5,2x,2a)') &
826 ' thread', omp%thread,
'opening ', trim(filename)
828 open (io_unit%nml2, file=trim(filename), form=
'formatted', status=
'unknown', &
829 access=trim(merge(
'append ',
'sequential',append)))
830 write(io_unit%log,
'(a,i5,2x,2a)') &
831 ' thread', omp%thread,
'opened ', trim(filename)
838 if (mpi%master .and. .not.append)
then 839 call patch%idx%output (io_unit%nml2)
841 write (io_unit%nml2, patch_nml)
844 END SUBROUTINE output_nml_v3
846 END SUBROUTINE output_nml
851 SUBROUTINE input_nml (patch)
854 if (io%nml_version == 1)
then 855 call input_nml_v1(patch)
856 else if (io%nml_version == 2)
then 857 call input_nml_v2(patch)
859 print*,io%nml_version
860 call mpi%abort (
'unknown nml_version!')
867 SUBROUTINE input_nml_v1 (patch)
870 character(len=128) :: filename
871 character(len=128),
save:: filename1=
'', filename2=
'' 872 integer,
save :: ioformat, id, iout, istep, mesh_type, level,nv, nt, &
874 integer,
dimension(3):: ncell, li, ui, n, ng, gn, l, u
875 real ,
save :: gamma, quality
876 real(8),
save :: time, dtime, out_next, out_time, ms
877 real(8),
dimension(3):: size, position, ds, box, velocity, &
878 llc_nat, llc_cart, centre_nat
879 integer,
save :: time_derivs
880 logical,
save :: guard_zones, no_mans_land, periodic(3)
881 character(len=16) :: kind, eos, opacity, method
883 namelist /snapshot_nml/ ioformat, iout, time, ntotal, istep, mesh_type, &
884 position,
size, ds, box, velocity, level, quality, gamma, ncell, li, ui, n, &
885 ng, gn, nv, nt, nw, kind, eos, opacity, periodic, guard_zones, time_derivs, &
888 real(8),
save :: origin(3)
889 integer,
save :: dims(3), mpi_dims(3), per_rank(3)
890 logical,
save :: face_nbors, fast_nbors, omp_init
891 namelist /cartesian_params/
size, dims, mpi_dims, per_rank, origin, face_nbors, &
893 logical,
save:: first_time=.true.
897 call trace%begin (
'data_io_t%input_nml')
901 patch%iout = io%restart
902 write (filename,
'(a,i5.5,"/snapshot.nml")') trim(io%inputdir), patch%iout
903 open (unit=io_unit%nml1, file=filename, form=
'formatted', status=
'old')
904 read (io_unit%nml1, snapshot_nml, iostat=iostat)
905 read (io_unit%nml1, cartesian_params, iostat=iostat)
907 io%mpi_odims = mpi_dims
913 patch%out_next = (floor(patch%time/io%out_time+1.0+1e-6))*io%out_time
914 patch%guard_zones = guard_zones
915 patch%time_derivs = time_derivs
918 END SUBROUTINE input_nml_v1
920 END SUBROUTINE input_nml
925 SUBROUTINE input_nml_v2 (patch)
928 character(len=128) :: filename
929 character(len=128),
save:: filename1=
'', filename2=
'' 930 integer,
save :: ioformat, id, iout, istep, mesh_type, level,nv, nt, &
932 integer,
dimension(3):: ncell, li, ui, n, ng, gn, l, u
933 real ,
save :: gamma, quality
934 real(8),
save :: time, dtime, out_next, out_time, ms
935 real(8),
dimension(3):: size, position, ds, box, velocity, &
936 llc_nat, llc_cart, centre_nat
937 integer,
save :: time_derivs
938 logical,
save :: guard_zones, no_mans_land, periodic(3)
939 character(len=32) :: kind, eos, opacity, method
941 namelist /snapshot_nml/ ioformat, iout, time, ntotal, box, li, ui, ng, gn, &
942 nv, nt, gamma, eos, opacity, periodic, guard_zones, time_derivs, no_mans_land
944 real(8),
save :: origin(3)
945 integer,
save :: dims(3), mpi_dims(3), per_rank(3)
946 logical,
save :: face_nbors, fast_nbors, omp_init
947 namelist /cartesian_params/
size, dims, mpi_dims, per_rank, origin, face_nbors, &
949 namelist /patch_nml/ id, position,
size, level, dtime, istep, ds, ncell, n, nw, &
950 velocity, quality, mesh_type, kind
951 logical,
save:: first_time=.true.
955 call trace%begin (
'data_io_t%input_nml')
957 patch%iout = io%restart
960 write (filename,
'(a,i5.5,"/snapshot.nml")') trim(io%inputdir), patch%iout
961 open (unit=io_unit%nml1, file=filename, form=
'formatted', status=
'old')
962 read (io_unit%nml1, snapshot_nml, iostat=iostat)
963 read (io_unit%nml1, cartesian_params, iostat=iostat)
965 io%mpi_odims = mpi_dims
968 io%time_derivs = time_derivs
969 io%guard_zones = guard_zones
973 patch%guard_zones = guard_zones
974 patch%time_derivs = time_derivs
978 write (filename,
'(a,i5.5,"/rank_",i5.5,"_patches.nml")') &
979 trim(io%inputdir), patch%iout, mpi%rank
980 if (filename /= filename2)
then 981 if (filename2 /=
'')
close (io_unit%nml2)
982 open (io_unit%nml2, file=trim(filename), form=
'formatted', status=
'old')
987 read (io_unit%nml2, patch_nml, iostat=iostat)
988 if (id == patch%id)
exit 990 print*,
'ID = ',patch%id
991 call mpi%abort(
'input_nml: patch_nml not found! Abort!')
997 patch%out_next = (floor(patch%time/io%out_time+1.0+1e-6))*io%out_time
998 patch%velocity = velocity
1001 END SUBROUTINE input_nml_v2
1006 SUBROUTINE file_append (unit1, unit2)
1007 integer:: unit1, unit2
1008 character(len=128):: line
1013 read (unit1,
'(a)',iostat=iostat) line
1014 if (iostat /= 0)
exit 1015 write (unit2,
'(a)') trim(line)
1017 END SUBROUTINE file_append
1024 if (.not.io%do_output)
return 1025 call trace%begin(
'patch_t%close')
1026 if (io%method==
'legacy')
then 1028 else if (io%method==
'direct')
then 1029 call direct_io%close()
1030 else if (io%method==
'buffered')
then 1031 call buffered_io%close()
1032 else if (io%method==
'pan')
then 1033 call parallel_io%close()
1034 else if (io%method==
'parallel')
then 1035 call parallel_io%close()
1036 else if (io%method==
'snapshot')
then 1037 call parallel_io%close()
1040 END SUBROUTINE close
Compute time derivative from a sequence of time slices, using Lagrange interpolation.
Support tic/toc timing, as in MATLAB, and accurate wallclock() function. The timing is generally much...
Interface from gpatch_mod to a choice of binary data I/O methods, controlled by the iomethod text str...
Use MPI parallel I/O to write everything to a single file. No critical regions should be needed here;...
Help keep track of when all patches have passed some counter, by decrementing a counter, from start to 0. Typical use:
Template module for patches, which adds pointers to memory and mesh, and number of dimensions and var...
Module to periodically output a density probability density function (PDF). The procedure assumes tha...
Doubly linked list (DLL), carrying anything, as simply as possible.
Module handling convenient AMR I/O. We wish to have a file format that makes it easy to read when res...
This index file has slot indices for all solver, all initially equal to zero It is the responsibility...
The lock module uses nested locks, to allow versatile use of locks, where a procedure may want to mak...
Template module for tasks.