16 integer,
private :: itag
19 double precision,
private :: rk2_alfa
23 logical,
private :: stagger_mark_dat=.false.
26 character(len=*),
parameter ::
fmt_r =
'es16.8'
27 character(len=*),
parameter ::
fmt_r2 =
'es10.2'
28 character(len=*),
parameter ::
fmt_i =
'i8'
40 integer :: len, stat, n, i, ipars
41 integer,
parameter :: max_files = 20
42 integer :: n_par_files
43 character(len=max_files*std_len) :: all_par_files
44 character(len=std_len) :: tmp_files(max_files), arg
45 logical :: unknown_arg, help, morepars
48 print *,
'-----------------------------------------------------------------------------'
49 print *,
'-----------------------------------------------------------------------------'
50 print *,
'| __ __ ____ ___ _ __ __ ______ ___ ____ |'
51 print *,
'| | \/ | _ \_ _| / \ | \/ | _ \ \ / / \ / ___| |'
52 print *,
'| | |\/| | |_) | |_____ / _ \ | |\/| | |_) \ \ / / _ \| | |'
53 print *,
'| | | | | __/| |_____/ ___ \| | | | _ < \ V / ___ \ |___ |'
54 print *,
'| |_| |_|_| |___| /_/ \_\_| |_|_| \_\ \_/_/ \_\____| |'
55 print *,
'-----------------------------------------------------------------------------'
56 print *,
'-----------------------------------------------------------------------------'
62 all_par_files=
"amrvac.par"
75 CALL get_command_argument(i, arg)
76 IF (len_trim(arg) == 0)
EXIT
80 CALL get_command_argument(i, arg)
82 all_par_files=trim(arg)
85 do while (ipars<max_files.and.morepars)
86 CALL get_command_argument(i+ipars,arg)
88 if (index(trim(arg),
"-")==1.or.len_trim(arg)==0)
then
92 all_par_files=trim(all_par_files)//
" "//trim(arg)
101 CALL get_command_argument(i, arg)
106 CALL get_command_argument(i, arg)
109 case(
"-collapsenext")
111 CALL get_command_argument(i, arg)
114 case(
"-snapshotnext")
116 CALL get_command_argument(i, arg)
124 if(
mype==0)print *,
'convert specified: convert=T'
125 case(
"--help",
"-help")
136 if (unknown_arg)
then
137 print*,
"======================================="
138 print*,
"Error: Command line argument ' ",trim(arg),
" ' not recognized"
139 print*,
"======================================="
146 print *,
'Usage example:'
147 print *,
'mpirun -np 4 ./amrvac -i file.par [file2.par ...]'
148 print *,
' (later .par files override earlier ones)'
150 print *,
'Optional arguments:'
151 print *,
'-convert Convert snapshot files'
152 print *,
'-if file0001.dat Use this snapshot to restart from'
153 print *,
' (you can modify e.g. output names)'
154 print *,
'-resume Automatically resume previous run'
155 print *,
' (useful for long runs on HPC systems)'
156 print *,
'-snapshotnext N Manual index for next snapshot'
157 print *,
'-slicenext N Manual index for next slice output'
158 print *,
'-collapsenext N Manual index for next collapsed output'
167 tmp_files, n_par_files)
185 logical :: fileopen, file_exists
186 integer :: i, j, k, ifile, io_state
187 integer :: iB, isave, iw, level, idim, islice
188 integer :: nx_vec(^ND), block_nx_vec(^ND)
189 integer :: my_unit, iostate
191 double precision :: dx_vec(^ND)
194 character(len=80) :: fmt_string
195 character(len=std_len) :: err_msg, restart_from_file_arg
196 character(len=std_len) :: basename_full, basename_prev, dummy_file
197 character(len=std_len),
dimension(:),
allocatable :: &
198 typeboundary_min^D, typeboundary_max^D
199 character(len=std_len),
allocatable :: limiter(:)
200 character(len=std_len),
allocatable :: gradient_limiter(:)
201 character(len=name_len) :: stretch_dim(ndim)
204 character(len=std_len) :: typesourcesplit
206 character(len=std_len),
allocatable :: flux_scheme(:)
208 character(len=std_len) :: typeboundspeed
210 character(len=std_len) :: time_stepper
212 character(len=std_len) :: time_integrator
214 character(len=std_len) :: typecurl
216 character(len=std_len) :: typeprolonglimit
222 character(len=std_len) :: typecourant
224 double precision,
dimension(nsavehi) :: tsave_log, tsave_dat, tsave_slice, &
225 tsave_collapsed, tsave_custom
226 double precision :: dtsave_log, dtsave_dat, dtsave_slice, &
227 dtsave_collapsed, dtsave_custom
228 integer :: ditsave_log, ditsave_dat, ditsave_slice, &
229 ditsave_collapsed, ditsave_custom
230 double precision :: tsavestart_log, tsavestart_dat, tsavestart_slice, &
231 tsavestart_collapsed, tsavestart_custom
232 integer :: windex, ipower
233 double precision :: sizeuniformpart^D
234 double precision :: im_delta,im_nu,rka54,rka51,rkb54,rka55
247 tsave_log, tsave_dat, tsave_slice, tsave_collapsed, tsave_custom, &
248 dtsave_log, dtsave_dat, dtsave_slice, dtsave_collapsed, dtsave_custom, &
249 ditsave_log, ditsave_dat, ditsave_slice, ditsave_collapsed, ditsave_custom,&
250 tsavestart_log, tsavestart_dat, tsavestart_slice, tsavestart_collapsed,&
256 namelist /methodlist/ time_stepper,time_integrator, &
315 allocate(typeboundary_min^d(nwfluxbc))
316 allocate(typeboundary_max^d(nwfluxbc))
379 typeprolonglimit =
'default'
417 tsave(isave,ifile) = bigdouble
418 itsave(isave,ifile) = biginteger
427 tsave_log = bigdouble
428 tsave_dat = bigdouble
429 tsave_slice = bigdouble
430 tsave_collapsed = bigdouble
431 tsave_custom = bigdouble
433 dtsave_log = bigdouble
434 dtsave_dat = bigdouble
435 dtsave_slice = bigdouble
436 dtsave_collapsed = bigdouble
437 dtsave_custom = bigdouble
439 ditsave_log = biginteger
440 ditsave_dat = biginteger
441 ditsave_slice = biginteger
442 ditsave_collapsed = biginteger
443 ditsave_custom = biginteger
445 tsavestart_log = bigdouble
446 tsavestart_dat = bigdouble
447 tsavestart_slice = bigdouble
448 tsavestart_collapsed = bigdouble
449 tsavestart_custom = bigdouble
470 typecourant =
'maxsum'
480 typeboundspeed =
'Einfeldt'
482 time_stepper =
'twostep'
483 time_integrator =
'default'
515 flux_scheme(level) =
'tvdlf'
517 limiter(level) =
'minmod'
518 gradient_limiter(level) =
'minmod'
523 typesourcesplit =
'sfs'
550 if(i==j.or.j==k.or.k==i)
then
552 else if(i+1==j.or.i-2==j)
then
569 inquire(file=trim(
par_files(i)), exist=file_exists)
571 if (.not. file_exists)
then
572 write(err_msg, *)
"The parameter file " // trim(
par_files(i)) // &
582 read(
unitpar, filelist,
end=101)
585 read(unitpar, savelist,
end=102)
588 read(unitpar, stoplist,
end=103)
591 read(unitpar, methodlist,
end=104)
594 read(unitpar, boundlist,
end=105)
597 read(unitpar, meshlist,
end=106)
600 read(unitpar, paramlist,
end=107)
603 read(unitpar, emissionlist,
end=108)
608 if (base_filename /= basename_prev) &
609 basename_full = trim(basename_full) // trim(base_filename)
610 basename_prev = base_filename
613 base_filename = basename_full
617 dummy_file = trim(base_filename)//
"DUMMY"
618 open(newunit=my_unit, file=trim(dummy_file), iostat=iostate)
619 if (iostate /= 0)
then
620 call mpistop(
"Can't write to output directory (" // &
621 trim(base_filename) //
")")
623 close(my_unit, status=
'delete')
627 if(source_split_usr) any_source_split=.true.
630 if(restart_from_file_arg /= undefined) &
631 restart_from_file=restart_from_file_arg
635 if(restart_from_file == undefined)
then
638 do index_latest_data = 9999, 0, -1
644 if(.not.file_exists) index_latest_data=-1
650 call mpi_bcast(index_latest_data, 1, mpi_integer, 0, icomm, ierrmpi)
652 if (resume_previous_run)
then
653 if (index_latest_data == -1)
then
654 if(mype==0)
write(*,*)
"No snapshots found to resume from, start a new run..."
657 write(restart_from_file,
"(a,i4.4,a)") trim(base_filename),index_latest_data,
".dat"
661 if (restart_from_file == undefined)
then
666 call mpistop(
"Please restart from a snapshot when firstprocess=T")
668 call mpistop(
'Change convert to .false. for a new run!')
671 if (small_pressure < 0.d0)
call mpistop(
"small_pressure should be positive.")
672 if (small_density < 0.d0)
call mpistop(
"small_density should be positive.")
674 if (small_temperature>0.d0) small_pressure=small_density*small_temperature
676 if(convert) autoconvert=.false.
678 where (tsave_log < bigdouble) tsave(:, 1) = tsave_log
679 where (tsave_dat < bigdouble) tsave(:, 2) = tsave_dat
680 where (tsave_slice < bigdouble) tsave(:, 3) = tsave_slice
681 where (tsave_collapsed < bigdouble) tsave(:, 4) = tsave_collapsed
682 where (tsave_custom < bigdouble) tsave(:, 5) = tsave_custom
684 if (dtsave_log < bigdouble) dtsave(1) = dtsave_log
685 if (dtsave_dat < bigdouble) dtsave(2) = dtsave_dat
686 if (dtsave_slice < bigdouble) dtsave(3) = dtsave_slice
687 if (dtsave_collapsed < bigdouble) dtsave(4) = dtsave_collapsed
688 if (dtsave_custom < bigdouble) dtsave(5) = dtsave_custom
690 if (tsavestart_log < bigdouble) tsavestart(1) = tsavestart_log
691 if (tsavestart_dat < bigdouble) tsavestart(2) = tsavestart_dat
692 if (tsavestart_slice < bigdouble) tsavestart(3) = tsavestart_slice
693 if (tsavestart_collapsed < bigdouble) tsavestart(4) = tsavestart_collapsed
694 if (tsavestart_custom < bigdouble) tsavestart(5) = tsavestart_custom
696 if (ditsave_log < bigdouble) ditsave(1) = ditsave_log
697 if (ditsave_dat < bigdouble) ditsave(2) = ditsave_dat
698 if (ditsave_slice < bigdouble) ditsave(3) = ditsave_slice
699 if (ditsave_collapsed < bigdouble) ditsave(4) = ditsave_collapsed
700 if (ditsave_custom < bigdouble) ditsave(5) = ditsave_custom
702 if (wall_time_max < bigdouble) wall_time_max=wall_time_max*3600.d0
705 write(unitterm, *)
''
706 write(unitterm, *)
'Output type | tsavestart | dtsave | ditsave | itsave(1) | tsave(1)'
707 write(fmt_string, *)
'(A12," | ",E9.3E2," | ",E9.3E2," | ",I6," | "'//&
712 if (mype == 0)
write(unitterm, fmt_string) trim(output_names(ifile)), &
713 tsavestart(ifile), dtsave(ifile), ditsave(ifile), itsave(1, ifile), tsave(1, ifile)
716 if (mype == 0)
write(unitterm, *)
''
719 if(slicedir(islice) > ndim) &
720 write(uniterr,*)
'Warning in read_par_files: ', &
721 'Slice ', islice,
' direction',slicedir(islice),
'larger than ndim=',ndim
722 if(slicedir(islice) < 1) &
723 write(uniterr,*)
'Warning in read_par_files: ', &
724 'Slice ', islice,
' direction',slicedir(islice),
'too small, should be [',1,ndim,
']'
727 if(it_max==biginteger .and. time_max==bigdouble.and.mype==0)
write(uniterr,*) &
728 'Warning in read_par_files: it_max or time_max not given!'
730 select case (typecourant)
732 type_courant=type_maxsum
734 type_courant=type_summax
736 type_courant=type_minimum
738 write(unitterm,*)
'Unknown typecourant=',typecourant
739 call mpistop(
"Error from read_par_files: no such typecourant!")
743 select case (flux_scheme(level))
745 flux_method(level)=fs_hll
747 flux_method(level)=fs_hllc
749 flux_method(level)=fs_hlld
751 flux_method(level)=fs_hllcd
753 flux_method(level)=fs_tvdlf
755 flux_method(level)=fs_tvdmu
757 flux_method(level)=fs_tvd
759 flux_method(level)=fs_cd
761 flux_method(level)=fs_cd4
763 flux_method(level)=fs_fd
765 flux_method(level)=fs_source
767 flux_method(level)=fs_nul
769 call mpistop(
"unkown or bad flux scheme")
771 if(flux_scheme(level)==
'tvd'.and.time_stepper/=
'onestep') &
772 call mpistop(
" tvd is onestep method, reset time_stepper='onestep'")
773 if(flux_scheme(level)==
'tvd')
then
774 if(mype==0.and.(.not.dimsplit))
write(unitterm,*) &
775 'Warning: setting dimsplit=T for tvd, as used for level=',level
778 if(flux_scheme(level)==
'hlld'.and.physics_type/=
'mhd' .and. physics_type/=
'twofl') &
779 call mpistop(
"Cannot use hlld flux if not using MHD or 2FL only charges physics!")
781 if(flux_scheme(level)==
'hllc'.and.physics_type==
'mf') &
782 call mpistop(
"Cannot use hllc flux if using magnetofriction physics!")
784 if(flux_scheme(level)==
'tvd'.and.physics_type==
'mf') &
785 call mpistop(
"Cannot use tvd flux if using magnetofriction physics!")
787 if(flux_scheme(level)==
'tvdmu'.and.physics_type==
'mf') &
788 call mpistop(
"Cannot use tvdmu flux if using magnetofriction physics!")
790 if (typepred1(level)==0)
then
791 select case (flux_scheme(level))
793 typepred1(level)=fs_cd
795 typepred1(level)=fs_cd4
797 typepred1(level)=fs_fd
798 case (
'tvdlf',
'tvdmu')
799 typepred1(level)=fs_hancock
801 typepred1(level)=fs_hll
803 typepred1(level)=fs_hllc
805 typepred1(level)=fs_hllcd
807 typepred1(level)=fs_hlld
808 case (
'nul',
'source',
'tvd')
809 typepred1(level)=fs_nul
811 call mpistop(
"No default predictor for this full step")
817 if(any(flux_scheme==
'fd')) need_global_cmax=.true.
818 if(any(limiter==
'schmid1')) need_global_a2max=.true.
821 select case (typecurl)
827 type_curl=stokesbased
829 write(unitterm,*)
"typecurl=",typecurl
830 call mpistop(
"unkown type of curl operator in read_par_files")
834 select case (time_stepper)
838 if (time_integrator==
'default')
then
839 time_integrator=
"Forward_Euler"
841 select case (time_integrator)
842 case (
"Forward_Euler")
843 t_integrator=forward_euler
845 t_integrator=imex_euler
849 write(unitterm,*)
"time_integrator=",time_integrator,
"time_stepper=",time_stepper
850 call mpistop(
"unkown onestep time_integrator in read_par_files")
852 use_imex_scheme=(t_integrator==imex_euler.or.t_integrator==imex_sp)
856 if (time_integrator==
'default')
then
857 time_integrator=
"Predictor_Corrector"
859 select case (time_integrator)
860 case (
"Predictor_Corrector")
861 t_integrator=predictor_corrector
866 case (
"IMEX_Midpoint")
867 t_integrator=imex_midpoint
868 case (
"IMEX_Trapezoidal")
869 t_integrator=imex_trapezoidal
871 t_integrator=imex_222
873 write(unitterm,*)
"time_integrator=",time_integrator,
"time_stepper=",time_stepper
874 call mpistop(
"unkown twostep time_integrator in read_par_files")
876 use_imex_scheme=(t_integrator==imex_midpoint.or.t_integrator==imex_trapezoidal&
877 .or.t_integrator==imex_222)
878 if (t_integrator==rk2_alf)
then
879 if(rk2_alfa<smalldouble.or.rk2_alfa>one)
call mpistop(
"set rk2_alfa within [0,1]")
881 rk_b2=1.0d0/(2.0d0*rk2_alfa)
887 if (time_integrator==
'default')
then
888 time_integrator=
'ssprk3'
890 select case (time_integrator)
896 t_integrator=imex_ars3
898 t_integrator=imex_232
900 t_integrator=imex_cb3a
902 write(unitterm,*)
"time_integrator=",time_integrator,
"time_stepper=",time_stepper
903 call mpistop(
"unkown threestep time_integrator in read_par_files")
905 if(t_integrator==rk3_bt)
then
906 select case(rk3_switch)
936 call mpistop(
"Unknown rk3_switch")
939 rk3_b3=1.0d0-rk3_b1-rk3_b2
941 rk3_c3=rk3_a31+rk3_a32
943 if(t_integrator==ssprk3)
then
944 select case(ssprk_order)
947 rk_beta22=1.0d0/4.0d0
948 rk_beta33=2.0d0/3.0d0
949 rk_alfa21=3.0d0/4.0d0
950 rk_alfa31=1.0d0/3.0d0
954 rk_beta11=1.0d0/2.0d0
955 rk_beta22=1.0d0/2.0d0
956 rk_beta33=1.0d0/3.0d0
958 rk_alfa31=1.0d0/3.0d0
962 call mpistop(
"Unknown ssprk3_order")
964 rk_alfa22=1.0d0-rk_alfa21
965 rk_alfa33=1.0d0-rk_alfa31
967 if(t_integrator==imex_ars3)
then
968 ars_gamma=(3.0d0+dsqrt(3.0d0))/6.0d0
970 if(t_integrator==imex_232)
then
971 select case(imex_switch)
973 im_delta=1.0d0-1.0d0/dsqrt(2.0d0)
974 im_nu=(3.0d0+2.0d0*dsqrt(2.0d0))/6.0d0
975 imex_a21=2.0d0*im_delta
978 imex_b1=1.0d0/(2.0d0*dsqrt(2.0d0))
979 imex_b2=1.0d0/(2.0d0*dsqrt(2.0d0))
984 imex_a21=0.711664700366941d0
985 imex_a31=0.077338168947683d0
986 imex_a32=0.917273367886007d0
987 imex_b1=0.398930808264688d0
988 imex_b2=0.345755244189623d0
989 imex_ha21=0.353842865099275d0
990 imex_ha22=0.353842865099275d0
992 call mpistop(
"Unknown imex_siwtch")
995 imex_c3=imex_a31+imex_a32
996 imex_b3=1.0d0-imex_b1-imex_b2
998 if(t_integrator==imex_cb3a)
then
999 imex_c2 = 0.8925502329346865
1002 imex_c3 = imex_c2 / (6.0d0*imex_c2**2 - 3.0d0*imex_c2 + 1.0d0)
1004 imex_b2 = (3.0d0*imex_c2 - 1.0d0) / (6.0d0*imex_c2**2)
1005 imex_b3 = (6.0d0*imex_c2**2 - 3.0d0*imex_c2 + 1.0d0) / (6.0d0*imex_c2**2)
1006 imex_a33 = (1.0d0/6.0d0 - imex_b2*imex_c2**2 - imex_b3*imex_c2*imex_c3) / (imex_b3*(imex_c3-imex_c2))
1007 imex_a32 = imex_c3 - imex_a33
1021 use_imex_scheme=(t_integrator==imex_ars3.or.t_integrator==imex_232.or.t_integrator==imex_cb3a)
1025 if (time_integrator==
'default')
then
1026 time_integrator=
"ssprk4"
1028 select case (time_integrator)
1034 write(unitterm,*)
"time_integrator=",time_integrator,
"time_stepper=",time_stepper
1035 call mpistop(
"unkown fourstep time_integrator in read_par_files")
1037 if(t_integrator==ssprk4)
then
1038 select case(ssprk_order)
1040 rk_beta11=1.0d0/2.0d0
1041 rk_beta22=1.0d0/2.0d0
1042 rk_beta33=1.0d0/6.0d0
1043 rk_beta44=1.0d0/2.0d0
1045 rk_alfa31=2.0d0/3.0d0
1051 rk_beta11=1.0d0/3.0d0
1052 rk_beta22=1.0d0/3.0d0
1053 rk_beta33=1.0d0/3.0d0
1054 rk_beta44=1.0d0/4.0d0
1057 rk_alfa41=1.0d0/4.0d0
1062 call mpistop(
"Unknown ssprk_order")
1064 rk_alfa22=1.0d0-rk_alfa21
1065 rk_alfa33=1.0d0-rk_alfa31
1066 rk_alfa44=1.0d0-rk_alfa41
1071 if (time_integrator==
'default')
then
1072 time_integrator=
"ssprk5"
1074 select case (time_integrator)
1078 write(unitterm,*)
"time_integrator=",time_integrator,
"time_stepper=",time_stepper
1079 call mpistop(
"unkown fivestep time_integrator in read_par_files")
1081 if(t_integrator==ssprk5)
then
1082 select case(ssprk_order)
1085 rk_beta11=0.391752226571890d0
1086 rk_beta22=0.368410593050371d0
1087 rk_beta33=0.251891774271694d0
1088 rk_beta44=0.544974750228521d0
1089 rk_beta54=0.063692468666290d0
1090 rk_beta55=0.226007483236906d0
1091 rk_alfa21=0.444370493651235d0
1092 rk_alfa31=0.620101851488403d0
1093 rk_alfa41=0.178079954393132d0
1094 rk_alfa53=0.517231671970585d0
1095 rk_alfa54=0.096059710526147d0
1097 rk_alfa22=0.555629506348765d0
1098 rk_alfa33=0.379898148511597d0
1099 rk_alfa44=0.821920045606868d0
1100 rk_alfa55=0.386708617503269d0
1101 rk_alfa22=1.0d0-rk_alfa21
1102 rk_alfa33=1.0d0-rk_alfa31
1103 rk_alfa44=1.0d0-rk_alfa41
1104 rk_alfa55=1.0d0-rk_alfa53-rk_alfa54
1106 rk_c3=rk_alfa22*rk_c2+rk_beta22
1107 rk_c4=rk_alfa33*rk_c3+rk_beta33
1108 rk_c5=rk_alfa44*rk_c4+rk_beta44
1110 rk_beta11=0.39175222700392d0
1111 rk_beta22=0.36841059262959d0
1112 rk_beta33=0.25189177424738d0
1113 rk_beta44=0.54497475021237d0
1116 rk_alfa21=0.44437049406734d0
1117 rk_alfa31=0.62010185138540d0
1118 rk_alfa41=0.17807995410773d0
1119 rk_alfa53=0.51723167208978d0
1122 rk_alfa22=1.0d0-rk_alfa21
1123 rk_alfa33=1.0d0-rk_alfa31
1124 rk_alfa44=1.0d0-rk_alfa41
1126 rka51=0.00683325884039d0
1127 rka54=0.12759831133288d0
1128 rkb54=0.08460416338212d0
1129 rk_beta54=rkb54-rk_beta44*rka51/rk_alfa41
1130 rk_alfa54=rka54-rk_alfa44*rka51/rk_alfa41
1132 rk_alfa55=1.0d0-rk_alfa53-rk_alfa54
1134 rk_c3=rk_alfa22*rk_c2+rk_beta22
1135 rk_c4=rk_alfa33*rk_c3+rk_beta33
1136 rk_c5=rk_alfa44*rk_c4+rk_beta44
1137 rk_beta55=1.0d0-rk_beta54-rk_alfa53*rk_c3-rk_alfa54*rk_c4-rk_alfa55*rk_c5
1139 call mpistop(
"Unknown ssprk_order")
1148 use_imex_scheme=.false.
1150 call mpistop(
"Unknown time_stepper in read_par_files")
1154 select case (stretch_dim(i))
1155 case (undefined,
'none')
1156 stretch_type(i) = stretch_none
1157 stretched_dim(i) = .false.
1158 case (
'uni',
'uniform')
1159 stretch_type(i) = stretch_uni
1160 stretched_dim(i) = .true.
1161 case (
'symm',
'symmetric')
1162 stretch_type(i) = stretch_symm
1163 stretched_dim(i) = .true.
1165 stretch_type(i) = stretch_none
1166 stretched_dim(i) = .false.
1167 if (mype == 0) print *,
'Got stretch_type = ', stretch_type(i)
1168 call mpistop(
'Unknown stretch type')
1173 if(typedimsplit ==
'default'.and. dimsplit) typedimsplit=
'xyyx'
1174 if(typedimsplit ==
'default'.and..not.dimsplit) typedimsplit=
'unsplit'
1175 dimsplit = typedimsplit /=
'unsplit'
1178 select case (typesourcesplit)
1180 sourcesplit=sourcesplit_sfs
1182 sourcesplit=sourcesplit_sf
1184 sourcesplit=sourcesplit_ssf
1186 sourcesplit=sourcesplit_ssfss
1188 write(unitterm,*)
'No such typesourcesplit=',typesourcesplit
1189 call mpistop(
"Error: Unknown typesourcesplit!")
1192 if(coordinate==-1)
then
1193 coordinate=cartesian
1195 write(*,*)
'Warning: coordinate system is not specified!'
1196 write(*,*)
'call set_coordinate_system in usr_init in mod_usr.t'
1197 write(*,*)
'Now use Cartesian coordinate'
1201 if(coordinate==cartesian)
then
1204 if(any(stretched_dim))
then
1205 coordinate=cartesian_stretched
1206 slab_uniform=.false.
1210 slab_uniform=.false.
1213 if(coordinate==spherical)
then
1215 if(mype==0)print *,
'Warning: spherical symmetry needs dimsplit=F, resetting'
1220 if (ndim==1) dimsplit=.false.
1223 select case(typeprolonglimit)
1238 allocate(type_limiter(nlevelshi))
1239 allocate(type_gradient_limiter(nlevelshi))
1241 do level=1,nlevelshi
1242 type_limiter(level) = limiter_type(limiter(level))
1243 type_gradient_limiter(level) = limiter_type(gradient_limiter(level))
1246 if (any(limiter(1:nlevelshi)==
'ppm')&
1247 .and.(flatsh.and.physics_type==
'rho'))
then
1248 call mpistop(
" PPM with flatsh=.true. can not be used with physics_type='rho'!")
1254 select case(typeboundary_min^d(iw))
1256 typeboundary(iw,2*^d-1)=bc_special
1258 typeboundary(iw,2*^d-1)=bc_cont
1260 typeboundary(iw,2*^d-1)=bc_symm
1262 typeboundary(iw,2*^d-1)=bc_asymm
1264 typeboundary(iw,2*^d-1)=bc_periodic
1266 typeboundary(iw,2*^d-1)=bc_aperiodic
1268 typeboundary(iw,2*^d-1)=bc_noinflow
1270 typeboundary(iw,2*^d-1)=12
1272 typeboundary(iw,2*^d-1)=bc_data
1274 typeboundary(iw,2*^d-1)=bc_icarus
1276 typeboundary(iw,2*^d-1)=bc_character
1278 write (unitterm,*)
"Undefined boundarytype found in read_par_files", &
1279 typeboundary_min^d(iw),
"for variable iw=",iw,
" and side iB=",2*^d-1
1283 select case(typeboundary_max^d(iw))
1285 typeboundary(iw,2*^d)=bc_special
1287 typeboundary(iw,2*^d)=bc_cont
1289 typeboundary(iw,2*^d)=bc_symm
1291 typeboundary(iw,2*^d)=bc_asymm
1293 typeboundary(iw,2*^d)=bc_periodic
1295 typeboundary(iw,2*^d)=bc_aperiodic
1297 typeboundary(iw,2*^d)=bc_noinflow
1299 typeboundary(iw,2*^d)=12
1301 typeboundary(iw,2*^d)=bc_data
1303 typeboundary(iw,2*^d-1)=bc_icarus
1304 case(
"bc_character")
1305 typeboundary(iw,2*^d)=bc_character
1307 write (unitterm,*)
"Undefined boundarytype found in read_par_files", &
1308 typeboundary_max^d(iw),
"for variable iw=",iw,
" and side iB=",2*^d
1314 if (nwfluxbc<nwflux)
then
1315 do iw = nwfluxbc+1, nwflux
1316 typeboundary(iw,:) = typeboundary(1, :)
1321 do iw = nwflux+1, nwflux+nwaux
1322 typeboundary(iw,:) = typeboundary(1, :)
1326 if (any(typeboundary == 0))
then
1327 call mpistop(
"Not all boundary conditions have been defined")
1331 periodb(idim)=(any(typeboundary(:,2*idim-1:2*idim)==bc_periodic))
1332 aperiodb(idim)=(any(typeboundary(:,2*idim-1:2*idim)==bc_aperiodic))
1333 if (periodb(idim).or.aperiodb(idim))
then
1335 if (typeboundary(iw,2*idim-1) .ne. typeboundary(iw,2*idim)) &
1336 call mpistop(
"Wrong counterpart in periodic boundary")
1338 if (typeboundary(iw,2*idim-1) /= bc_periodic .and. &
1339 typeboundary(iw,2*idim-1) /= bc_aperiodic)
then
1340 call mpistop(
"Each dimension should either have all "//&
1341 "or no variables periodic, some can be aperiodic")
1348 if(any(typeboundary(:,2*idim-1)==12))
then
1349 if(any(typeboundary(:,2*idim-1)/=12)) typeboundary(:,2*idim-1)=12
1350 if(phys_energy)
then
1355 typeboundary(:,2*idim-1)=bc_symm
1356 if(physics_type/=
'rho')
then
1357 select case(coordinate)
1359 typeboundary(phi_+1,2*idim-1)=bc_asymm
1360 if(physics_type==
'mhd') typeboundary(ndir+windex+phi_,2*idim-1)=bc_asymm
1362 typeboundary(3:ndir+1,2*idim-1)=bc_asymm
1363 if(physics_type==
'mhd') typeboundary(ndir+windex+2:ndir+windex+ndir,2*idim-1)=bc_asymm
1365 call mpistop(
'Pole is in cylindrical, polar, spherical coordinates!')
1369 if(any(typeboundary(:,2*idim)==12))
then
1370 if(any(typeboundary(:,2*idim)/=12)) typeboundary(:,2*idim)=12
1371 if(phys_energy)
then
1376 typeboundary(:,2*idim)=bc_symm
1377 if(physics_type/=
'rho')
then
1378 select case(coordinate)
1380 typeboundary(phi_+1,2*idim)=bc_asymm
1381 if(physics_type==
'mhd') typeboundary(ndir+windex+phi_,2*idim)=bc_asymm
1383 typeboundary(3:ndir+1,2*idim)=bc_asymm
1384 if(physics_type==
'mhd') typeboundary(ndir+windex+2:ndir+windex+ndir,2*idim)=bc_asymm
1386 call mpistop(
'Pole is in cylindrical, polar, spherical coordinates!')
1393 if(.not.phys_energy)
then
1398 if(any(limiter(1:nlevelshi)==
'mp5'))
then
1399 nghostcells=max(nghostcells,3)
1402 if(any(limiter(1:nlevelshi)==
'weno5'))
then
1403 nghostcells=max(nghostcells,3)
1406 if(any(limiter(1:nlevelshi)==
'weno5nm'))
then
1407 nghostcells=max(nghostcells,3)
1410 if(any(limiter(1:nlevelshi)==
'wenoz5'))
then
1411 nghostcells=max(nghostcells,3)
1414 if(any(limiter(1:nlevelshi)==
'wenoz5nm'))
then
1415 nghostcells=max(nghostcells,3)
1418 if(any(limiter(1:nlevelshi)==
'wenozp5'))
then
1419 nghostcells=max(nghostcells,3)
1422 if(any(limiter(1:nlevelshi)==
'wenozp5nm'))
then
1423 nghostcells=max(nghostcells,3)
1426 if(any(limiter(1:nlevelshi)==
'teno5ad'))
then
1427 nghostcells=max(nghostcells,3)
1430 if(any(limiter(1:nlevelshi)==
'weno5cu6'))
then
1431 nghostcells=max(nghostcells,3)
1434 if(any(limiter(1:nlevelshi)==
'ppm'))
then
1435 if(flatsh .or. flatcd)
then
1436 nghostcells=max(nghostcells,4)
1438 nghostcells=max(nghostcells,3)
1442 if(any(limiter(1:nlevelshi)==
'weno7'))
then
1443 nghostcells=max(nghostcells,4)
1446 if(any(limiter(1:nlevelshi)==
'mpweno7'))
then
1447 nghostcells=max(nghostcells,4)
1451 nghostcells = nghostcells + phys_wider_stencil
1454 if(stagger_grid .and. refine_max_level>1 .and. mod(nghostcells,2)/=0)
then
1455 nghostcells=nghostcells+1
1458 select case (coordinate)
1461 xprob^lim^de=xprob^lim^de*two*dpi;
1466 xprob^lim^d=xprob^lim^d*two*dpi;
1472 {ixghi^d = block_nx^d + 2*nghostcells\}
1473 {ixgshi^d = ixghi^d\}
1475 nx_vec = [{domain_nx^d|, }]
1476 block_nx_vec = [{block_nx^d|, }]
1478 if (any(nx_vec < 4) .or. any(mod(nx_vec, 2) == 1)) &
1479 call mpistop(
'Grid size (domain_nx^D) has to be even and >= 4')
1481 if (any(block_nx_vec < 4) .or. any(mod(block_nx_vec, 2) == 1)) &
1482 call mpistop(
'Block size (block_nx^D) has to be even and >= 4')
1484 {
if(mod(domain_nx^d,block_nx^d)/=0) &
1485 call mpistop(
'Grid (domain_nx^D) and block (block_nx^D) must be consistent') \}
1487 if(refine_max_level>nlevelshi.or.refine_max_level<1)
then
1488 write(unitterm,*)
'Error: refine_max_level',refine_max_level,
'>nlevelshi ',nlevelshi
1489 call mpistop(
"Reset nlevelshi and recompile!")
1492 if (any(stretched_dim))
then
1493 allocate(qstretch(0:nlevelshi,1:ndim),dxfirst(0:nlevelshi,1:ndim),&
1494 dxfirst_1mq(0:nlevelshi,1:ndim),dxmid(0:nlevelshi,1:ndim))
1495 allocate(nstretchedblocks(1:nlevelshi,1:ndim))
1496 qstretch(0:nlevelshi,1:ndim)=0.0d0
1497 dxfirst(0:nlevelshi,1:ndim)=0.0d0
1498 nstretchedblocks(1:nlevelshi,1:ndim)=0
1499 {
if (stretch_type(^d) == stretch_uni)
then
1501 if(qstretch_baselevel(^d)<1.0d0.or.qstretch_baselevel(^d)==bigdouble)
then
1503 write(*,*)
'stretched grid needs finite qstretch_baselevel>1'
1504 write(*,*)
'will try default value for qstretch_baselevel in dimension', ^d
1506 if(xprobmin^d>smalldouble)
then
1507 qstretch_baselevel(^d)=(xprobmax^d/xprobmin^d)**(1.d0/dble(domain_nx^d))
1509 call mpistop(
"can not set qstretch_baselevel automatically")
1512 if(mod(block_nx^d,2)==1) &
1513 call mpistop(
"stretched grid needs even block size block_nxD")
1514 if(mod(domain_nx^d/block_nx^d,2)/=0) &
1515 call mpistop(
"number level 1 blocks in D must be even")
1516 qstretch(1,^d)=qstretch_baselevel(^d)
1517 dxfirst(1,^d)=(xprobmax^d-xprobmin^d) &
1518 *(1.0d0-qstretch(1,^d))/(1.0d0-qstretch(1,^d)**domain_nx^d)
1519 qstretch(0,^d)=qstretch(1,^d)**2
1520 dxfirst(0,^d)=dxfirst(1,^d)*(1.0d0+qstretch(1,^d))
1521 if(refine_max_level>1)
then
1522 do ilev=2,refine_max_level
1523 qstretch(ilev,^d)=dsqrt(qstretch(ilev-1,^d))
1524 dxfirst(ilev,^d)=dxfirst(ilev-1,^d) &
1525 /(1.0d0+dsqrt(qstretch(ilev-1,^d)))
1530 {
if(stretch_type(^d) == stretch_uni)
then
1531 write(*,*)
'Stretched dimension ', ^d
1532 write(*,*)
'Using stretched grid with qs=',qstretch(0:refine_max_level,^d)
1533 write(*,*)
' and first cell sizes=',dxfirst(0:refine_max_level,^d)
1536 {
if(stretch_type(^d) == stretch_symm)
then
1538 write(*,*)
'will apply symmetric stretch in dimension', ^d
1540 if(mod(block_nx^d,2)==1) &
1541 call mpistop(
"stretched grid needs even block size block_nxD")
1543 if(nstretchedblocks_baselevel(^d)==0) &
1544 call mpistop(
"need finite even number of stretched blocks at baselevel")
1545 if(mod(nstretchedblocks_baselevel(^d),2)==1) &
1546 call mpistop(
"need even number of stretched blocks at baselevel")
1547 if(qstretch_baselevel(^d)<1.0d0.or.qstretch_baselevel(^d)==bigdouble) &
1548 call mpistop(
'stretched grid needs finite qstretch_baselevel>1')
1550 ipower=(nstretchedblocks_baselevel(^d)/2)*block_nx^d
1551 if(nstretchedblocks_baselevel(^d)==domain_nx^d/block_nx^d)
then
1552 xstretch^d=0.5d0*(xprobmax^d-xprobmin^d)
1554 xstretch^d=(xprobmax^d-xprobmin^d) &
1555 /(2.0d0+dble(domain_nx^d-nstretchedblocks_baselevel(^d)*block_nx^d) &
1556 *(1.0d0-qstretch_baselevel(^d))/(1.0d0-qstretch_baselevel(^d)**ipower))
1558 if(xstretch^d>(xprobmax^d-xprobmin^d)*0.5d0) &
1559 call mpistop(
" stretched grid part should not exceed full domain")
1560 dxfirst(1,^d)=xstretch^d*(1.0d0-qstretch_baselevel(^d)) &
1561 /(1.0d0-qstretch_baselevel(^d)**ipower)
1562 nstretchedblocks(1,^d)=nstretchedblocks_baselevel(^d)
1563 qstretch(1,^d)=qstretch_baselevel(^d)
1564 qstretch(0,^d)=qstretch(1,^d)**2
1565 dxfirst(0,^d)=dxfirst(1,^d)*(1.0d0+qstretch(1,^d))
1566 dxmid(1,^d)=dxfirst(1,^d)
1567 dxmid(0,^d)=dxfirst(1,^d)*2.0d0
1568 if(refine_max_level>1)
then
1569 do ilev=2,refine_max_level
1570 nstretchedblocks(ilev,^d)=2*nstretchedblocks(ilev-1,^d)
1571 qstretch(ilev,^d)=dsqrt(qstretch(ilev-1,^d))
1572 dxfirst(ilev,^d)=dxfirst(ilev-1,^d) &
1573 /(1.0d0+dsqrt(qstretch(ilev-1,^d)))
1574 dxmid(ilev,^d)=dxmid(ilev-1,^d)/2.0d0
1578 sizeuniformpart^d=dxfirst(1,^d) &
1579 *(domain_nx^d-nstretchedblocks_baselevel(^d)*block_nx^d)
1581 print *,
'uniform part of size=',sizeuniformpart^d
1582 print *,
'setting of domain is then=',2*xstretch^d+sizeuniformpart^d
1583 print *,
'versus=',xprobmax^d-xprobmin^d
1585 if(dabs(xprobmax^d-xprobmin^d-2*xstretch^d-sizeuniformpart^d)>smalldouble)
then
1586 call mpistop(
'mismatch in domain size!')
1589 dxfirst_1mq(0:refine_max_level,1:ndim)=dxfirst(0:refine_max_level,1:ndim) &
1590 /(1.0d0-qstretch(0:refine_max_level,1:ndim))
1593 dx_vec = [{xprobmax^d-xprobmin^d|, }] / nx_vec
1596 write(c_ndim,
'(I1)') ^nd
1597 write(unitterm,
'(A30,' // c_ndim //
'(I0," "))') &
1598 ' Domain size (cells): ', nx_vec
1599 write(unitterm,
'(A30,' // c_ndim //
'(E9.3," "))') &
1600 ' Level one dx: ', dx_vec
1603 if (any(dx_vec < smalldouble)) &
1604 call mpistop(
"Incorrect domain size (too small grid spacing)")
1608 if(sum(w_refine_weight(:))==0) w_refine_weight(1) = 1.d0
1609 if(dabs(sum(w_refine_weight(:))-1.d0)>smalldouble)
then
1610 write(unitterm,*)
"Sum of all elements in w_refine_weight be 1.d0"
1611 call mpistop(
"Reset w_refine_weight so the sum is 1.d0")
1614 select case (typeboundspeed)
1619 case(
'cmaxleftright')
1622 call mpistop(
"set typeboundspeed='Einfieldt' or 'cmaxmean' or 'cmaxleftright'")
1625 if (mype==0)
write(unitterm,
'(A30)', advance=
'no')
'Refine estimation: '
1627 select case (refine_criterion)
1629 if (mype==0)
write(unitterm,
'(A)')
"user defined"
1631 if (mype==0)
write(unitterm,
'(A)')
"relative error"
1633 if (mype==0)
write(unitterm,
'(A)')
"Lohner's original scheme"
1635 if (mype==0)
write(unitterm,
'(A)')
"Lohner's scheme"
1637 call mpistop(
"Unknown error estimator, change refine_criterion")
1640 if (tfixgrid<bigdouble/2.0d0)
then
1641 if(mype==0)print*,
'Warning, at time=',tfixgrid,
'the grid will be fixed'
1643 if (itfixgrid<biginteger/2)
then
1644 if(mype==0)print*,
'Warning, at iteration=',itfixgrid,
'the grid will be fixed'
1646 if (ditregrid>1)
then
1647 if(mype==0)print*,
'Note, Grid is reconstructed once every',ditregrid,
'iterations'
1652 select case(slicedir(islice))
1654 if(slicecoord(islice)<xprobmin^d.or.slicecoord(islice)>xprobmax^d) &
1655 write(uniterr,*)
'Warning in read_par_files: ', &
1656 'Slice ', islice,
' coordinate',slicecoord(islice),
'out of bounds for dimension ',slicedir(islice)
1662 write(unitterm,
'(A30,A,A)')
'restart_from_file: ',
' ', trim(restart_from_file)
1663 write(unitterm,
'(A30,L1)')
'converting: ', convert
1664 write(unitterm,
'(A)')
''
1667 deallocate(flux_scheme)
1674 character(len=*),
intent(in) :: line
1676 character(len=*),
intent(in) :: delims
1678 integer,
intent(in) :: n_max
1680 integer,
intent(inout) :: n_found
1682 character(len=*),
intent(inout) :: fields(n_max)
1683 logical,
intent(out),
optional :: fully_read
1685 integer :: ixs_start(n_max)
1686 integer :: ixs_end(n_max)
1687 integer :: ix, ix_prev
1692 do while (n_found < n_max)
1694 ix = verify(line(ix_prev+1:), delims)
1697 n_found = n_found + 1
1698 ixs_start(n_found) = ix_prev + ix
1701 ix = scan(line(ixs_start(n_found)+1:), delims) - 1
1704 ixs_end(n_found) = len(line)
1706 ixs_end(n_found) = ixs_start(n_found) + ix
1709 fields(n_found) = line(ixs_start(n_found):ixs_end(n_found))
1710 ix_prev = ixs_end(n_found)
1713 if (
present(fully_read))
then
1714 ix = verify(line(ix_prev+1:), delims)
1715 fully_read = (ix == 0)
1749 case (
'regression_test')
1753 call mpistop(
"usr_print_log not defined")
1758 call mpistop(
"Error in SaveFile: Unknown typefilelog")
1765 write(*,*)
'No save method is defined for ifile=',ifile
1778 integer,
intent(in) :: ix
1779 character(len=std_len) :: filename
1781 write(filename,
"(a,i4.4,a)") trim(
base_filename), ix,
".dat"
1786 character(len=*),
intent(in) :: filename
1790 i = len_trim(filename) - 7
1806 integer,
intent(in) :: fh
1807 integer(kind=MPI_OFFSET_KIND),
intent(in) :: offset_tree
1808 integer(kind=MPI_OFFSET_KIND),
intent(in) :: offset_block
1821 integer,
intent(in) :: fh
1822 integer(MPI_OFFSET_KIND),
intent(out) :: offset_tree
1823 integer(MPI_OFFSET_KIND),
intent(out) :: offset_block
1824 integer :: i, version
1825 integer :: ibuf(ndim), iw
1826 double precision :: rbuf(ndim)
1827 integer,
dimension(MPI_STATUS_SIZE) :: st
1828 character(len=name_len),
allocatable :: var_names(:), param_names(:)
1829 double precision,
allocatable :: params(:)
1830 character(len=name_len) :: phys_name, geom_name
1831 integer :: er, n_par, tmp_int
1832 logical :: periodic(ndim)
1835 call mpi_file_read(fh, version, 1, mpi_integer, st, er)
1837 call mpistop(
"Incompatible file version (maybe old format?)")
1841 call mpi_file_read(fh, ibuf(1), 1, mpi_integer, st, er)
1842 offset_tree = ibuf(1)
1845 call mpi_file_read(fh, ibuf(1), 1, mpi_integer, st, er)
1846 offset_block = ibuf(1)
1849 call mpi_file_read(fh, ibuf(1), 1, mpi_integer, st, er)
1851 if (nw /= ibuf(1))
then
1852 write(*,*)
"nw=",nw,
" and nw found in restart file=",ibuf(1)
1853 write(*,*)
"Please be aware of changes in w at restart."
1858 call mpi_file_read(fh, ibuf(1), 1, mpi_integer, st, er)
1859 if (ibuf(1) /=
ndir)
then
1860 write(*,*)
"ndir in restart file = ",ibuf(1)
1861 write(*,*)
"ndir = ",
ndir
1862 call mpistop(
"reset ndir to ndir in restart file")
1866 call mpi_file_read(fh, ibuf(1), 1, mpi_integer, st, er)
1867 if (ibuf(1) /= ndim)
then
1868 write(*,*)
"ndim in restart file = ",ibuf(1)
1869 write(*,*)
"ndim = ",ndim
1870 call mpistop(
"reset ndim to ndim in restart file")
1874 call mpi_file_read(fh, ibuf(1), 1, mpi_integer, st, er)
1876 write(*,*)
"number of levels in restart file = ",ibuf(1)
1878 call mpistop(
"refine_max_level < num. levels in restart file")
1882 call mpi_file_read(fh,
nleafs, 1, mpi_integer, st, er)
1885 call mpi_file_read(fh,
nparents, 1, mpi_integer, st, er)
1888 call mpi_file_read(fh,
it, 1, mpi_integer, st, er)
1891 call mpi_file_read(fh,
global_time, 1, mpi_double_precision, st, er)
1894 call mpi_file_read(fh,rbuf(1:ndim),ndim,mpi_double_precision,st,er)
1895 if (maxval(abs(rbuf(1:ndim) - [ xprobmin^
d ])) > 0)
then
1896 write(*,*)
"Error: xprobmin differs from restart data: ", rbuf(1:ndim)
1897 call mpistop(
"change xprobmin^D in par file")
1901 call mpi_file_read(fh,rbuf(1:ndim),ndim,mpi_double_precision,st,er)
1902 if (maxval(abs(rbuf(1:ndim) - [ xprobmax^
d ])) > 0)
then
1903 write(*,*)
"Error: xprobmax differs from restart data: ", rbuf(1:ndim)
1904 call mpistop(
"change xprobmax^D in par file")
1908 call mpi_file_read(fh,ibuf(1:ndim), ndim, mpi_integer,st,er)
1909 if (any(ibuf(1:ndim) /= [
domain_nx^
d ]))
then
1910 write(*,*)
"Error: mesh size differs from restart data: ", ibuf(1:ndim)
1911 call mpistop(
"change domain_nx^D in par file")
1915 call mpi_file_read(fh,ibuf(1:ndim), ndim, mpi_integer,st,er)
1916 if (any(ibuf(1:ndim) /= [
block_nx^
d ]))
then
1917 write(*,*)
"Error: block size differs from restart data:", ibuf(1:ndim)
1918 call mpistop(
"change block_nx^D in par file")
1922 if (version > 4)
then
1923 call mpi_file_read(fh, periodic, ndim, mpi_logical, st, er)
1924 if ({periodic(^
d) .and. .not.
periodb(^
d) .or. .not.periodic(^
d) .and.
periodb(^
d)| .or. }) &
1925 call mpistop(
"change in periodicity in par file")
1927 call mpi_file_read(fh, geom_name, name_len, mpi_character, st, er)
1930 write(*,*)
"type of coordinates in data is: ", geom_name
1931 call mpistop(
"select the correct coordinates in mod_usr.t file")
1934 call mpi_file_read(fh, stagger_mark_dat, 1, mpi_logical, st, er)
1936 write(*,*)
"Warning: stagger grid flag differs from restart data:", stagger_mark_dat
1942 if (version > 3)
then
1946 call mpi_file_read(fh, var_names(iw), name_len, mpi_character, st, er)
1950 call mpi_file_read(fh, phys_name, name_len, mpi_character, st, er)
1956 call mpi_file_read(fh, n_par, 1, mpi_integer, st, er)
1957 allocate(params(n_par))
1958 allocate(param_names(n_par))
1959 call mpi_file_read(fh, params, n_par, mpi_double_precision, st, er)
1960 call mpi_file_read(fh, param_names, name_len * n_par, mpi_character, st, er)
1963 call mpi_file_read(fh, tmp_int, 1, mpi_integer, st, er)
1968 call mpi_file_read(fh, tmp_int, 1, mpi_integer, st, er)
1971 call mpi_file_read(fh, tmp_int, 1, mpi_integer, st, er)
1994 integer :: file_handle, igrid, Morton_no, iwrite
1995 integer :: ipe, ix_buffer(2*ndim+1), n_values
1996 integer :: ixO^L, n_ghost(2*ndim)
1997 integer :: ixOs^L,n_values_stagger
1998 integer :: iorecvstatus(MPI_STATUS_SIZE)
1999 integer :: ioastatus(MPI_STATUS_SIZE)
2000 integer :: igrecvstatus(MPI_STATUS_SIZE)
2001 integer :: istatus(MPI_STATUS_SIZE)
2003 integer(kind=MPI_OFFSET_KIND) :: offset_tree_info
2004 integer(kind=MPI_OFFSET_KIND) :: offset_block_data
2005 integer(kind=MPI_OFFSET_KIND) :: offset_offsets
2006 double precision,
allocatable :: w_buffer(:)
2008 integer,
allocatable :: block_ig(:, :)
2009 integer,
allocatable :: block_lvl(:)
2010 integer(kind=MPI_OFFSET_KIND),
allocatable :: block_offset(:)
2017 n_values = n_values +
count_ix(ixgs^
ll) * nws
2019 allocate(w_buffer(n_values))
2022 allocate(block_ig(ndim,
nleafs))
2023 allocate(block_lvl(
nleafs))
2024 allocate(block_offset(
nleafs+1))
2031 offset_tree_info = -1
2032 offset_block_data = -1
2036 call mpi_file_get_position(file_handle, offset_tree_info,
ierrmpi)
2043 igrid =
sfc(1, morton_no)
2044 ipe =
sfc(2, morton_no)
2047 block_ig(:, morton_no) = [ pnode%ig^
d ]
2048 block_lvl(morton_no) = pnode%level
2049 block_offset(morton_no) = 0
2052 call mpi_file_write(file_handle, block_lvl,
size(block_lvl), &
2053 mpi_integer, istatus,
ierrmpi)
2055 call mpi_file_write(file_handle, block_ig,
size(block_ig), &
2056 mpi_integer, istatus,
ierrmpi)
2059 call mpi_file_get_position(file_handle, offset_offsets,
ierrmpi)
2060 call mpi_file_write(file_handle, block_offset(1:
nleafs),
nleafs, &
2063 call mpi_file_get_position(file_handle, offset_block_data,
ierrmpi)
2066 if (offset_block_data - offset_tree_info /= &
2068 nleafs * ((1+ndim) * size_int + 2 * size_int))
then
2070 print *,
"Warning: MPI_OFFSET type /= 8 bytes"
2071 print *,
"This *could* cause problems when reading .dat files"
2075 block_offset(1) = offset_block_data
2085 w_buffer(1:n_values) = pack(ps(igrid)%w(ixo^s, 1:nw), .true.)
2086 {ixosmin^
d = ixomin^
d -1\}
2087 {ixosmax^
d = ixomax^
d \}
2088 n_values_stagger=
count_ix(ixos^l)*nws
2089 w_buffer(n_values+1:n_values+n_values_stagger) = pack(ps(igrid)%ws(ixos^s, 1:nws), .true.)
2090 n_values=n_values+n_values_stagger
2092 w_buffer(1:n_values) = pack(ps(igrid)%w(ixo^s, 1:nw), .true.)
2094 ix_buffer(1) = n_values
2095 ix_buffer(2:) = n_ghost
2098 call mpi_send(ix_buffer, 2*ndim+1, &
2100 call mpi_send(w_buffer, n_values, &
2104 call mpi_file_write(file_handle, ix_buffer(2:), &
2105 2*ndim, mpi_integer, istatus,
ierrmpi)
2106 call mpi_file_write(file_handle, w_buffer, &
2107 n_values, mpi_double_precision, istatus,
ierrmpi)
2110 block_offset(iwrite+1) = block_offset(iwrite) + &
2111 int(n_values, mpi_offset_kind) * size_double + &
2123 call mpi_recv(ix_buffer, 2*ndim+1, mpi_integer, ipe, itag,
icomm,&
2125 n_values = ix_buffer(1)
2127 call mpi_recv(w_buffer, n_values, mpi_double_precision,&
2130 call mpi_file_write(file_handle, ix_buffer(2:), &
2131 2*ndim, mpi_integer, istatus,
ierrmpi)
2132 call mpi_file_write(file_handle, w_buffer, &
2133 n_values, mpi_double_precision, istatus,
ierrmpi)
2136 block_offset(iwrite+1) = block_offset(iwrite) + &
2137 int(n_values, mpi_offset_kind) * size_double + &
2143 call mpi_file_seek(file_handle, offset_offsets, mpi_seek_set,
ierrmpi)
2144 call mpi_file_write(file_handle, block_offset(1:
nleafs),
nleafs, &
2148 call mpi_file_seek(file_handle, 0_mpi_offset_kind, mpi_seek_set,
ierrmpi)
2152 call mpi_file_close(file_handle,
ierrmpi)
2169 integer :: ix_buffer(2*ndim+1), n_values, n_values_stagger
2170 integer :: ixO^L, ixOs^L
2171 integer :: file_handle, amode, igrid, Morton_no, iread
2172 integer :: istatus(MPI_STATUS_SIZE)
2173 integer :: iorecvstatus(MPI_STATUS_SIZE)
2174 integer :: ipe,inrecv,nrecv, file_version
2176 integer(MPI_OFFSET_KIND) :: offset_tree_info
2177 integer(MPI_OFFSET_KIND) :: offset_block_data
2178 double precision,
allocatable :: w_buffer(:)
2179 double precision,
dimension(:^D&,:),
allocatable :: w
2180 double precision :: ws(ixGs^T,1:ndim)
2187 mpi_info_null,file_handle,
ierrmpi)
2188 call mpi_file_read(file_handle, file_version, 1, mpi_integer, &
2192 call mpi_bcast(file_version,1,mpi_integer,0,
icomm,
ierrmpi)
2195 if (
mype == 0) print *,
"Unknown version, trying old snapshot reader..."
2196 call mpi_file_close(file_handle,
ierrmpi)
2210 else if (
mype == 0)
then
2211 call mpi_file_seek(file_handle, 0_mpi_offset_kind, mpi_seek_set,
ierrmpi)
2226 call mpi_bcast(stagger_mark_dat,1,mpi_logical,0,
icomm,
ierrmpi)
2230 if(stagger_mark_dat)
then
2231 n_values = n_values +
count_ix(ixgs^
ll) * nws
2233 allocate(w_buffer(n_values))
2239 call mpi_file_seek(file_handle, offset_tree_info, &
2251 call mpi_file_seek(file_handle, offset_block_data, mpi_seek_set,
ierrmpi)
2259 call mpi_file_read(file_handle,ix_buffer(1:2*ndim), 2*ndim, &
2263 {ixomin^
d = ixmlo^
d - ix_buffer(^
d)\}
2264 {ixomax^
d = ixmhi^
d + ix_buffer(ndim+^
d)\}
2266 if(stagger_mark_dat)
then
2267 {ixosmin^
d = ixomin^
d - 1\}
2268 {ixosmax^
d = ixomax^
d\}
2269 n_values_stagger = n_values
2270 n_values = n_values +
count_ix(ixos^l) * nws
2273 call mpi_file_read(file_handle, w_buffer, n_values, &
2274 mpi_double_precision, istatus,
ierrmpi)
2276 if (
mype == ipe)
then
2279 if(stagger_mark_dat)
then
2280 w(ixo^s, 1:
nw_found) = reshape(w_buffer(1:n_values_stagger), &
2283 ps(igrid)%ws(ixos^s,1:nws)=reshape(w_buffer(n_values_stagger+1:n_values), &
2284 shape(ws(ixos^s, 1:nws)))
2286 w(ixo^s, 1:
nw_found) = reshape(w_buffer(1:n_values), &
2299 ps(igrid)%w(ixo^s,1:nw)=w(ixo^s,1:nw)
2302 ps(igrid)%w(ixo^s,1:nw)=w(ixo^s,1:nw)
2305 call mpi_send([ ixo^l, n_values ], 2*ndim+1, &
2307 call mpi_send(w_buffer, n_values, &
2313 call mpi_file_close(file_handle,
ierrmpi)
2322 call mpi_recv(ix_buffer, 2*ndim+1, mpi_integer, 0, itag,
icomm,&
2324 {ixomin^
d = ix_buffer(^
d)\}
2325 {ixomax^
d = ix_buffer(ndim+^
d)\}
2326 n_values = ix_buffer(2*ndim+1)
2328 call mpi_recv(w_buffer, n_values, mpi_double_precision,&
2331 if(stagger_mark_dat)
then
2333 {ixosmin^
d = ixomin^
d - 1\}
2334 {ixosmax^
d = ixomax^
d\}
2335 w(ixo^s, 1:
nw_found) = reshape(w_buffer(1:n_values_stagger), &
2338 ps(igrid)%ws(ixos^s,1:nws)=reshape(w_buffer(n_values_stagger+1:n_values), &
2339 shape(ws(ixos^s, 1:nws)))
2341 w(ixo^s, 1:
nw_found) = reshape(w_buffer(1:n_values), &
2354 ps(igrid)%w(ixo^s,1:nw)=w(ixo^s,1:nw)
2357 ps(igrid)%w(ixo^s,1:nw)=w(ixo^s,1:nw)
2372 double precision :: wio(ixG^T,1:nw)
2373 integer :: fh, igrid, Morton_no, iread
2374 integer :: levmaxini, ndimini, ndirini
2375 integer :: nwini, neqparini, nxini^D
2376 integer(kind=MPI_OFFSET_KIND) :: offset
2377 integer :: istatus(MPI_STATUS_SIZE)
2378 integer,
allocatable :: iorecvstatus(:,:)
2379 integer :: ipe,inrecv,nrecv
2380 integer :: sendini(7+^ND)
2381 character(len=80) :: filename
2383 double precision :: eqpar_dummy(100)
2387 mpi_mode_rdonly,mpi_info_null,fh,
ierrmpi)
2389 offset=-int(7*size_int+size_double,kind=mpi_offset_kind)
2390 call mpi_file_seek(fh,offset,mpi_seek_end,
ierrmpi)
2394 call mpi_file_read(fh,levmaxini,1,mpi_integer,istatus,
ierrmpi)
2395 call mpi_file_read(fh,ndimini,1,mpi_integer,istatus,
ierrmpi)
2396 call mpi_file_read(fh,ndirini,1,mpi_integer,istatus,
ierrmpi)
2397 call mpi_file_read(fh,nwini,1,mpi_integer,istatus,
ierrmpi)
2398 call mpi_file_read(fh,neqparini,1,mpi_integer,istatus,
ierrmpi)
2399 call mpi_file_read(fh,
it,1,mpi_integer,istatus,
ierrmpi)
2404 write(*,*)
"number of levels in restart file = ",levmaxini
2406 call mpistop(
"refine_max_level < number of levels in restart file")
2408 if (ndimini/=
ndim)
then
2409 write(*,*)
"ndim in restart file = ",ndimini
2410 write(*,*)
"ndim = ",
ndim
2411 call mpistop(
"reset ndim to ndim in restart file")
2413 if (ndirini/=
ndir)
then
2414 write(*,*)
"ndir in restart file = ",ndirini
2415 write(*,*)
"ndir = ",
ndir
2416 call mpistop(
"reset ndir to ndir in restart file")
2419 write(*,*)
"nw=",nw,
" and nw in restart file=",nwini
2420 call mpistop(
"currently, changing nw at restart is not allowed")
2423 offset=offset-int(ndimini*size_int+neqparini*size_double,kind=mpi_offset_kind)
2424 call mpi_file_seek(fh,offset,mpi_seek_end,
ierrmpi)
2426 {
call mpi_file_read(fh,nxini^d,1,mpi_integer,istatus,
ierrmpi)\}
2428 write(*,*)
"Error: reset resolution to ",nxini^d+2*
nghostcells
2429 call mpistop(
"change with setamrvac")
2432 call mpi_file_read(fh,eqpar_dummy,neqparini, &
2433 mpi_double_precision,istatus,
ierrmpi)
2439 sendini=(/
nleafs,levmaxini,ndimini,ndirini,nwini,neqparini,
it ,^d&nxini^d /)
2441 call mpi_bcast(sendini,7+^nd,mpi_integer,0,
icomm,
ierrmpi)
2442 nleafs=sendini(1);levmaxini=sendini(2);ndimini=sendini(3);
2443 ndirini=sendini(4);nwini=sendini(5);
2444 neqparini=sendini(6);
it=sendini(7);
2445 nxini^d=sendini(7+^d);
2452 int(
nleafs,kind=mpi_offset_kind)
2453 call mpi_file_seek(fh,offset,mpi_seek_set,
ierrmpi)
2470 *int(morton_no-1,kind=mpi_offset_kind)
2471 call mpi_file_read_at(fh,offset,ps(igrid)%w,1,
type_block_io, &
2480 *int(morton_no-1,kind=mpi_offset_kind)
2487 call mpi_file_close(fh,
ierrmpi)
2490 allocate(iorecvstatus(mpi_status_size,nrecv))
2497 iorecvstatus(:,inrecv),
ierrmpi)
2499 deallocate(iorecvstatus)
2514 integer :: i, iw, level
2515 double precision :: wmean(1:nw), total_volume
2516 double precision :: volume_coverage(refine_max_level)
2517 integer :: nx^D, nc, ncells, dit
2518 double precision :: dtTimeLast, now, cellupdatesPerSecond
2519 double precision :: activeBlocksPerCore, wctPerCodeTime, timeToFinish
2520 character(len=40) :: fmt_string
2521 character(len=80) :: filename
2522 character(len=2048) :: line
2523 logical,
save :: opened = .false.
2524 integer :: amode, istatus(MPI_STATUS_SIZE)
2525 integer,
parameter :: my_unit = 20
2536 nx^d=ixmhi^d-ixmlo^d+1;
2546 cellupdatespersecond = dble(ncells) * dble(
nstep) * &
2547 dble(dit) / (dttimelast * dble(
npe))
2553 wctpercodetime = dttimelast / max(dit *
dt, epsilon(1.0d0))
2559 if (.not. opened)
then
2565 open(unit=my_unit,file=trim(filename),status=
'replace')
2566 close(my_unit, status=
'delete')
2569 amode = ior(mpi_mode_create,mpi_mode_wronly)
2570 amode = ior(amode,mpi_mode_append)
2572 call mpi_file_open(mpi_comm_self, filename, amode, &
2578 line =
"it global_time dt"
2580 i = len_trim(line) + 2
2581 write(line(i:),
"(a,a)") trim(cons_wnames(level)),
" "
2585 do level = 1, refine_max_level
2586 i = len_trim(line) + 2
2587 write(line(i:),
"(a,i0)")
"c", level
2591 do level=1,refine_max_level
2592 i = len_trim(line) + 2
2593 write(line(i:),
"(a,i0)")
"n", level
2597 line = trim(line) //
" | Xload Xmemory 'Cell_Updates /second/core'"
2598 line = trim(line) //
" 'Active_Blocks/Core' 'Wct Per Code Time [s]'"
2599 line = trim(line) //
" 'TimeToFinish [hrs]'"
2603 call mpi_file_write(
log_fh, trim(line) // new_line(
'a'), &
2604 len_trim(line)+1, mpi_character, istatus,
ierrmpi)
2610 fmt_string =
'(' //
fmt_i //
',2' //
fmt_r //
')'
2612 i = len_trim(line) + 2
2614 write(fmt_string,
'(a,i0,a)')
'(', nw,
fmt_r //
')'
2615 write(line(i:), fmt_string) wmean(1:nw)
2616 i = len_trim(line) + 2
2618 write(fmt_string,
'(a,i0,a)')
'(', refine_max_level,
fmt_r //
')'
2619 write(line(i:), fmt_string) volume_coverage(1:refine_max_level)
2620 i = len_trim(line) + 2
2622 write(fmt_string,
'(a,i0,a)')
'(', refine_max_level,
fmt_i //
')'
2623 write(line(i:), fmt_string)
nleafs_level(1:refine_max_level)
2624 i = len_trim(line) + 2
2626 fmt_string =
'(a,6' //
fmt_r2 //
')'
2627 write(line(i:), fmt_string)
'| ',
xload,
xmemory, cellupdatespersecond, &
2628 activeblockspercore, wctpercodetime, timetofinish
2630 call mpi_file_write(
log_fh, trim(line) // new_line(
'a') , &
2631 len_trim(line)+1, mpi_character, istatus,
ierrmpi)
2641 integer,
parameter :: n_modes = 2
2642 character(len=40) :: fmt_string
2643 character(len=2048) :: line
2644 logical,
save :: file_open = .false.
2646 double precision :: modes(nw, n_modes), volume
2647 integer :: amode, istatus(MPI_STATUS_SIZE)
2648 character(len=80) :: filename
2650 do power = 1, n_modes
2655 if (.not. file_open)
then
2657 amode = ior(mpi_mode_create,mpi_mode_wronly)
2658 amode = ior(amode,mpi_mode_append)
2660 call mpi_file_open(mpi_comm_self, filename, amode, &
2664 line=
"# time mean(w) mean(w**2)"
2665 call mpi_file_write(
log_fh, trim(line) // new_line(
'a'), &
2666 len_trim(line)+1, mpi_character, istatus,
ierrmpi)
2669 write(fmt_string,
"(a,i0,a)")
"(", nw * n_modes + 1,
fmt_r //
")"
2671 call mpi_file_write(
log_fh, trim(line) // new_line(
'a') , &
2672 len_trim(line)+1, mpi_character, istatus,
ierrmpi)
2682 integer,
intent(in) :: power
2683 double precision,
intent(out) :: mode(nw)
2684 double precision,
intent(out) :: volume
2685 integer :: iigrid, igrid, iw
2686 double precision :: wsum(nw+1)
2687 double precision :: dsum_recv(1:nw+1)
2692 do iigrid = 1, igridstail
2693 igrid = igrids(iigrid)
2696 wsum(nw+1) = wsum(nw+1) + sum(ps(igrid)%dvolume(
ixm^t))
2700 wsum(iw) = wsum(iw) + &
2701 sum(ps(igrid)%dvolume(
ixm^t)*ps(igrid)%w(
ixm^t,iw)**power)
2706 call mpi_allreduce(wsum, dsum_recv, nw+1, mpi_double_precision, &
2710 volume = dsum_recv(nw+1)
2711 mode = dsum_recv(1:nw) / volume
2720 double precision,
intent(out) :: vol_cov(1:refine_max_level)
2721 double precision :: dsum_recv(1:refine_max_level)
2722 integer :: iigrid, igrid, iw, level
2725 vol_cov(1:refine_max_level)=zero
2727 do iigrid = 1, igridstail
2728 igrid = igrids(iigrid);
2730 vol_cov(level) = vol_cov(level)+ &
2735 call mpi_allreduce(vol_cov, dsum_recv, refine_max_level, mpi_double_precision, &
2739 vol_cov = dsum_recv / sum(dsum_recv)
2747 pure function func(w_vec, w_size)
result(val)
2748 integer,
intent(in) :: w_size
2749 double precision,
intent(in) :: w_vec(w_size)
2750 double precision :: val
2753 double precision,
intent(out) :: f_avg
2754 double precision,
intent(out) :: volume
2755 integer :: iigrid, igrid, i^D
2756 double precision :: wsum(2)
2757 double precision :: dsum_recv(2)
2762 do iigrid = 1, igridstail
2763 igrid = igrids(iigrid)
2766 wsum(2) = wsum(2) + sum(ps(igrid)%dvolume(
ixm^t))
2769 {
do i^d = ixmlo^d, ixmhi^d\}
2770 wsum(1) = wsum(1) + ps(igrid)%dvolume(i^d) * &
2771 func(ps(igrid)%w(i^d, :), nw)
2776 call mpi_allreduce(wsum, dsum_recv, 2, mpi_double_precision, &
2777 mpi_sum, icomm, ierrmpi)
2780 volume = dsum_recv(2)
2781 f_avg = dsum_recv(1) / volume
2789 double precision,
intent(out) :: wmax(nw)
2791 integer :: iigrid, igrid, iw
2792 double precision :: wmax_mype(nw),wmax_recv(nw)
2794 wmax_mype(1:nw) = -bigdouble
2797 do iigrid = 1, igridstail
2798 igrid = igrids(iigrid)
2800 wmax_mype(iw)=max(wmax_mype(iw),maxval(ps(igrid)%w(
ixm^t,iw)))
2805 call mpi_allreduce(wmax_mype, wmax_recv, nw, mpi_double_precision, &
2808 wmax(1:nw)=wmax_recv(1:nw)
2816 double precision,
intent(out) :: wmin(nw)
2818 integer :: iigrid, igrid, iw
2819 double precision :: wmin_mype(nw),wmin_recv(nw)
2821 wmin_mype(1:nw) = bigdouble
2824 do iigrid = 1, igridstail
2825 igrid = igrids(iigrid)
2827 wmin_mype(iw)=min(wmin_mype(iw),minval(ps(igrid)%w(
ixm^t,iw)))
2832 call mpi_allreduce(wmin_mype, wmin_recv, nw, mpi_double_precision, &
2835 wmin(1:nw)=wmin_recv(1:nw)
subroutine, public alloc_node(igrid)
allocate arrays on igrid node
Collapses D-dimensional output to D-1 view by line-of-sight integration.
subroutine write_collapsed
subroutine, public mpistop(message)
Exit MPI-AMRVAC with an error message.
subroutine generate_plotfile
Module with basic grid data structures.
integer, dimension(:), allocatable, save nleafs_level
How many leaves are present per refinement level.
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)
subroutine, public read_forest(file_handle)
Module with geometry-related routines (e.g., divergence, curl)
This module contains definitions of global parameters and variables and some generic functions/subrou...
character(len=std_len), dimension(:), allocatable typeentropy
Which type of entropy fix to use with Riemann-type solvers.
double precision, dimension(:), allocatable w_convert_factor
Conversion factors the primitive variables.
type(state), pointer block
Block pointer for using one block and its previous state.
double precision xload
Stores the memory and load imbalance, used in printlog.
integer nstep
How many sub-steps the time integrator takes.
logical h_correction
If true, do H-correction to fix the carbuncle problem at grid-aligned shocks.
integer it_max
Stop the simulation after this many time steps have been taken.
logical internalboundary
if there is an internal boundary
double precision r_opt_thick
for spherical coordinate, region below it (unit=Rsun) is treated as not transparent
character(len=std_len) filename_sxr
Base file name for synthetic SXR emission output.
double precision tvdlfeps
integer spectrum_wl
wave length for spectrum
logical nocartesian
IO switches for conversion.
integer, dimension(:), allocatable typepred1
The spatial discretization for the predictor step when using a two step PC method.
double precision dtdiffpar
For resistive MHD, the time step is also limited by the diffusion time: .
character(len=std_len) typegrad
logical reset_it
If true, reset iteration count to 0.
double precision small_pressure
integer ixghi
Upper index of grid block arrays.
character(len=std_len) geometry_name
integer, dimension(3, 3, 3) lvc
Levi-Civita tensor.
logical activate_unit_arcsec
use arcsec as length unit of images/spectra
logical source_split_usr
Use split or unsplit way to add user's source terms, default: unsplit.
integer domain_nx
number of cells for each dimension in level-one mesh
integer, parameter unitpar
file handle for IO
character(len=std_len) filename_spectrum
Base file name for synthetic EUV spectrum output.
logical flux_adaptive_diffusion
logical resume_previous_run
If true, restart a previous run from the latest snapshot.
double precision global_time
The global simulation time.
integer, dimension(nsavehi, nfile) itsave
Save output of type N on iterations itsave(:, N)
double precision time_max
End time for the simulation.
integer, dimension(3, 3) kr
Kronecker delta tensor.
logical, dimension(:), allocatable logflag
double precision time_init
Start time for the simulation.
logical stretch_uncentered
If true, adjust mod_geometry routines to account for grid stretching (but the flux computation will n...
logical firstprocess
If true, call initonegrid_usr upon restarting.
integer snapshotini
Resume from the snapshot with this index.
double precision small_temperature
error handling
double precision xprob
minimum and maximum domain boundaries for each dimension
integer it
Number of time steps taken.
character(len=std_len) filename_euv
Base file name for synthetic EUV emission output.
logical, dimension(:), allocatable loglimit
double precision, dimension(:), allocatable dg
extent of grid blocks in domain per dimension, in array over levels
integer it_init
initial iteration count
integer, dimension(:, :), allocatable typeboundary
Array indicating the type of boundary condition per variable and per physical boundary.
integer ditregrid
Reconstruct the AMR grid once every ditregrid iteration(s)
logical saveprim
If true, convert from conservative to primitive variables in output.
character(len=std_len) filename_whitelight
Base file name for synthetic white light.
character(len=std_len) convert_type
Which format to use when converting.
integer, parameter ndim
Number of spatial dimensions for grid variables.
integer itfixgrid
Fix the AMR grid after this many time steps.
integer, parameter filecollapse_
Constant indicating collapsed output.
double precision, dimension(:), allocatable amr_wavefilter
refinement: lohner estimate wavefilter setting
integer, parameter rpxmin
integer, parameter nlevelshi
The maximum number of levels in the grid refinement.
double precision location_slit
location of the slit
logical save_physical_boundary
True for save physical boundary cells in dat files.
logical stagger_grid
True for using stagger grid.
double precision time_convert_factor
Conversion factor for time unit.
logical use_particles
Use particles module or not.
character(len=std_len), dimension(:), allocatable par_files
Which par files are used as input.
integer icomm
The MPI communicator.
integer, dimension(:), allocatable ng
number of grid blocks in domain per dimension, in array over levels
logical reset_time
If true, reset iteration count and global_time to original values, and start writing snapshots at ind...
integer, parameter nsavehi
Maximum number of saves that can be defined by tsave or itsave.
character(len=std_len) whitelight_instrument
white light observation instrument
integer mype
The rank of the current MPI task.
double precision dtpar
If dtpar is positive, it sets the timestep dt, otherwise courantpar is used to limit the time step ba...
character(len=std_len) typediv
integer block_nx
number of cells for each dimension in grid block excluding ghostcells
integer type_block_io
MPI type for IO: block excluding ghost cells.
double precision, dimension(nfile) tsavestart
Start of read out (not counting specified read outs)
integer, dimension(nfile) ditsave
Repeatedly save output of type N when ditsave(N) time steps have passed.
integer, parameter plevel_
logical, dimension(ndim) collapse
If collapse(DIM) is true, generate output integrated over DIM.
integer, dimension(:), allocatable, parameter d
logical local_timestep
each cell has its own timestep or not
character(len=std_len) usr_filename
User parameter file.
logical ghost_copy
whether copy values instead of interpolation in ghost cells of finer blocks
double precision length_convert_factor
integer ndir
Number of spatial dimensions (components) for vector variables.
double precision imex222_lambda
IMEX-222(lambda) one-parameter family of schemes.
double precision courantpar
The Courant (CFL) number used for the simulation.
double precision wall_time_max
Ending wall time (in hours) for the simulation.
integer ixm
the mesh range of a physical block without ghost cells
integer ierrmpi
A global MPI error return code.
logical autoconvert
If true, already convert to output format during the run.
integer, dimension(:), allocatable flux_method
Which flux scheme of spatial discretization to use (per grid level)
character(len=std_len) collapse_type
integer slowsteps
If > 1, then in the first slowsteps-1 time steps dt is reduced by a factor .
integer ssprk_order
SSPRK choice of methods (both threestep and fourstep, Shu-Osher 2N* implementation) also fivestep SSP...
double precision image_rotate
rotation of image
integer snapshotnext
IO: snapshot and collapsed views output numbers/labels.
logical dat_resolution
resolution of the images
double precision r_occultor
the white light emission below it (unit=Rsun) is not visible
integer, dimension(ndim) nstretchedblocks_baselevel
(even) number of (symmetrically) stretched blocks at AMR level 1, per dimension
integer npe
The number of MPI tasks.
integer nwauxio
Number of auxiliary variables that are only included in output.
double precision, dimension(ndim) qstretch_baselevel
stretch factor between cells at AMR level 1, per dimension
double precision, dimension(ndim, 2) writespshift
integer imex_switch
IMEX_232 choice and parameters.
double precision time_between_print
to monitor timeintegration loop at given wall-clock time intervals
integer, parameter unitterm
Unit for standard output.
double precision, dimension(nfile) dtsave
Repeatedly save output of type N when dtsave(N) simulation time has passed.
logical, dimension(:), allocatable w_write
integer iprob
problem switch allowing different setups in same usr_mod.t
character(len=std_len) restart_from_file
If not 'unavailable', resume from snapshot with this base file name.
logical, dimension(ndim) periodb
True for dimensions with periodic boundaries.
double precision, dimension(:,:), allocatable rnode
Corner coordinates.
integer, parameter filelog_
Constant indicating log output.
logical final_dt_reduction
If true, allow final dt reduction for matching time_max on output.
logical, dimension(:), allocatable writelevel
integer, parameter fileout_
Constant indicating regular output.
double precision los_theta
direction of the line of sight (LOS)
character(len=std_len) typetvd
Which type of TVD method to use.
integer nbufferx
Number of cells as buffer zone.
double precision, dimension(:), allocatable entropycoef
double precision, dimension(:,:), allocatable dx
double precision tfixgrid
Fix the AMR grid after this time.
integer nghostcells
Number of ghost cells surrounding a grid.
double precision, dimension(:), allocatable w_refine_weight
Weights of variables used to calculate error for mesh refinement.
character(len=std_len) typedimsplit
character(len=std_len) typeaverage
character(len= *), parameter undefined
double precision, dimension(nsavehi, nfile) tsave
Save output of type N on times tsave(:, N)
double precision spectrum_window_max
logical convert
If true and restart_from_file is given, convert snapshots to other file formats.
integer wavelength
wavelength for output
integer collapselevel
The level at which to produce line-integrated / collapsed output.
logical reset_grid
If true, rebuild the AMR grid upon restarting.
integer, parameter rpxmax
double precision, dimension(:), allocatable refine_threshold
Error tolerance for refinement decision.
character(len=std_len) base_filename
Base file name for simulation output, which will be followed by a number.
logical big_image
big image
double precision instrument_resolution_factor
times for enhancing spatial resolution for EUV image/spectra
double precision small_density
double precision spectrum_window_min
spectral window
double precision dtmin
Stop the simulation when the time step becomes smaller than this value.
integer refine_max_level
Maximal number of AMR levels.
integer, parameter fileslice_
Constant indicating slice output.
double precision, dimension(:), allocatable derefine_ratio
integer, parameter nfile
Number of output methods.
integer max_blocks
The maximum number of grid blocks in a processor.
integer, parameter fileanalysis_
Constant indicating analysis output (see Writing a custom analysis subroutine)
integer rk3_switch
RK3 Butcher table.
character(len=std_len) typefilelog
Which type of log to write: 'normal', 'special', 'regression_test'.
integer direction_slit
direction of the slit (for dat resolution only)
double precision, dimension(1:3) x_origin
where the is the origin (X=0,Y=0) of image
logical final_dt_exit
Force timeloop exit when final dt < dtmin.
integer, dimension(nfile) isaveit
integer, dimension(:,:), allocatable node
integer, dimension(nfile) isavet
logical check_small_values
check and optionally fix unphysical small values (density, gas pressure)
integer log_fh
MPI file handle for logfile.
Module with slope/flux limiters.
double precision cada3_radius
radius of the asymptotic region [0.001, 10], larger means more accurate in smooth region but more ove...
double precision schmid_rad
Module containing all the particle routines.
This module defines the procedures of a physics module. It contains function pointers for the various...
integer phys_wider_stencil
To use wider stencils in flux calculations. A value of 1 will extend it by one cell in both direction...
character(len=name_len) physics_type
String describing the physics type of the simulation.
logical phys_energy
Solve energy equation or not.
Writes D-1 slice, can do so in various formats, depending on slice_type.
integer slicenext
the file number of slices
character(len=std_len) slice_type
choose data type of slice: vtu, vtuCC, dat, or csv
integer, dimension(nslicemax) slicedir
The slice direction for each slice.
integer nslices
Number of slices to output.
double precision, dimension(nslicemax) slicecoord
Slice coordinates, see Slice output.
Module for handling problematic values in simulations, such as negative pressures.
integer, public small_values_daverage
Average over this many cells in each direction.
logical, public trace_small_values
trace small values in the source file using traceback flag of compiler
logical, dimension(:), allocatable, public small_values_fix_iw
Whether to apply small value fixes to certain variables.
character(len=20), public small_values_method
How to handle small values.
Module for handling split source terms (split from the fluxes)
double precision timelast
Module with all the methods that users can customize in AMRVAC.
procedure(p_no_args), pointer usr_print_log
procedure(p_no_args), pointer usr_write_analysis
procedure(transform_w), pointer usr_transform_w
The data structure that contains information about a tree node/grid block.