188 double precision,
dimension(nsavehi) :: tsave_log, tsave_dat, tsave_slice, &
189 tsave_collapsed, tsave_custom
190 double precision :: dtsave_log, dtsave_dat, dtsave_slice, &
191 dtsave_collapsed, dtsave_custom
192 double precision :: tsavestart_log, tsavestart_dat, tsavestart_slice, &
193 tsavestart_collapsed, tsavestart_custom
194 double precision :: sizeuniformpart^D
195 double precision :: im_delta,im_nu,rka54,rka51,rkb54,rka55
196 double precision :: dx_vec(^ND)
197 integer :: ditsave_log, ditsave_dat, ditsave_slice, &
198 ditsave_collapsed, ditsave_custom
199 integer :: windex, ipower
200 integer :: i, j, k, ifile, io_state
201 integer :: iB, isave, iw, level, idim, islice
202 integer :: nx_vec(^ND), block_nx_vec(^ND)
203 integer :: my_unit, iostate
205 logical :: fileopen, file_exists
208 character(len=80) :: fmt_string
209 character(len=std_len) :: err_msg, restart_from_file_arg
210 character(len=std_len) :: basename_full, basename_prev, dummy_file
211 character(len=std_len),
dimension(:),
allocatable :: &
212 typeboundary_min^D, typeboundary_max^D
213 character(len=std_len),
allocatable :: limiter(:)
214 character(len=std_len),
allocatable :: gradient_limiter(:)
215 character(len=name_len) :: stretch_dim(ndim)
218 character(len=std_len) :: typesourcesplit
220 character(len=std_len),
allocatable :: flux_scheme(:)
222 character(len=std_len) :: typeboundspeed
224 character(len=std_len) :: time_stepper
226 character(len=std_len) :: time_integrator
228 character(len=std_len) :: typecurl
230 character(len=std_len) :: typeprolonglimit
236 character(len=std_len) :: typecourant
250 tsave_log, tsave_dat, tsave_slice, tsave_collapsed, tsave_custom, &
251 dtsave_log, dtsave_dat, dtsave_slice, dtsave_collapsed, dtsave_custom, &
252 ditsave_log, ditsave_dat, ditsave_slice, ditsave_collapsed, ditsave_custom,&
253 tsavestart_log, tsavestart_dat, tsavestart_slice, tsavestart_collapsed,&
260 namelist /methodlist/ time_stepper, time_integrator, &
327 allocate(typeboundary_min^d(nwfluxbc))
328 allocate(typeboundary_max^d(nwfluxbc))
391 typeprolonglimit =
'default'
429 tsave(isave,ifile) = bigdouble
430 itsave(isave,ifile) = biginteger
439 tsave_log = bigdouble
440 tsave_dat = bigdouble
441 tsave_slice = bigdouble
442 tsave_collapsed = bigdouble
443 tsave_custom = bigdouble
445 dtsave_log = bigdouble
446 dtsave_dat = bigdouble
447 dtsave_slice = bigdouble
448 dtsave_collapsed = bigdouble
449 dtsave_custom = bigdouble
451 ditsave_log = biginteger
452 ditsave_dat = biginteger
453 ditsave_slice = biginteger
454 ditsave_collapsed = biginteger
455 ditsave_custom = biginteger
457 tsavestart_log = bigdouble
458 tsavestart_dat = bigdouble
459 tsavestart_slice = bigdouble
460 tsavestart_collapsed = bigdouble
461 tsavestart_custom = bigdouble
485 typecourant =
'maxsum'
494 typeboundspeed =
'Einfeldt'
496 time_stepper =
'twostep'
497 time_integrator =
'default'
544 flux_scheme(level) =
'tvdlf'
546 limiter(level) =
'minmod'
547 gradient_limiter(level) =
'minmod'
552 typesourcesplit =
'sfs'
579 if(i==j.or.j==k.or.k==i)
then
581 else if(i+1==j.or.i-2==j)
then
598 inquire(file=trim(
par_files(i)), exist=file_exists)
600 if (.not. file_exists)
then
601 write(err_msg, *)
"The parameter file " // trim(
par_files(i)) // &
611 read(
unitpar, filelist,
end=101)
614 read(unitpar, savelist,
end=102)
617 read(unitpar, stoplist,
end=103)
620 read(unitpar, methodlist,
end=104)
623 read(unitpar, boundlist,
end=105)
626 read(unitpar, meshlist,
end=106)
629 read(unitpar, paramlist,
end=107)
632 read(unitpar, emissionlist,
end=108)
637 if (base_filename /= basename_prev) &
638 basename_full = trim(basename_full) // trim(base_filename)
639 basename_prev = base_filename
642 base_filename = basename_full
646 dummy_file = trim(base_filename)//
"DUMMY"
647 open(newunit=my_unit, file=trim(dummy_file), iostat=iostate)
648 if (iostate /= 0)
then
649 call mpistop(
"Can't write to output directory (" // &
650 trim(base_filename) //
")")
652 close(my_unit, status=
'delete')
656 if(source_split_usr) any_source_split=.true.
659 if(restart_from_file_arg /= undefined) &
660 restart_from_file=restart_from_file_arg
664 if(restart_from_file == undefined)
then
667 do index_latest_data = 9999, 0, -1
673 if(.not.file_exists) index_latest_data=-1
679 call mpi_bcast(index_latest_data, 1, mpi_integer, 0, icomm, ierrmpi)
681 if (resume_previous_run)
then
682 if (index_latest_data == -1)
then
683 if(mype==0)
write(*,*)
"No snapshots found to resume from, start a new run..."
686 write(restart_from_file,
"(a,i4.4,a)") trim(base_filename),index_latest_data,
".dat"
690 if (restart_from_file == undefined)
then
695 call mpistop(
"Please restart from a snapshot when firstprocess=T")
697 call mpistop(
'Change convert to .false. for a new run!')
700 if (small_pressure < 0.d0)
call mpistop(
"small_pressure should be positive.")
701 if (small_density < 0.d0)
call mpistop(
"small_density should be positive.")
702 if (ghostcell_comm_batched .and. ghostcell_comm_batch_size < 1) &
703 call mpistop(
"ghostcell_comm_batch_size should be positive.")
705 if (small_temperature>0.d0) small_pressure=small_density*small_temperature
707 if(convert) autoconvert=.false.
709 where (tsave_log < bigdouble) tsave(:, 1) = tsave_log
710 where (tsave_dat < bigdouble) tsave(:, 2) = tsave_dat
711 where (tsave_slice < bigdouble) tsave(:, 3) = tsave_slice
712 where (tsave_collapsed < bigdouble) tsave(:, 4) = tsave_collapsed
713 where (tsave_custom < bigdouble) tsave(:, 5) = tsave_custom
715 if (dtsave_log < bigdouble) dtsave(1) = dtsave_log
716 if (dtsave_dat < bigdouble) dtsave(2) = dtsave_dat
717 if (dtsave_slice < bigdouble) dtsave(3) = dtsave_slice
718 if (dtsave_collapsed < bigdouble) dtsave(4) = dtsave_collapsed
719 if (dtsave_custom < bigdouble) dtsave(5) = dtsave_custom
721 if (tsavestart_log < bigdouble) tsavestart(1) = tsavestart_log
722 if (tsavestart_dat < bigdouble) tsavestart(2) = tsavestart_dat
723 if (tsavestart_slice < bigdouble) tsavestart(3) = tsavestart_slice
724 if (tsavestart_collapsed < bigdouble) tsavestart(4) = tsavestart_collapsed
725 if (tsavestart_custom < bigdouble) tsavestart(5) = tsavestart_custom
727 if (ditsave_log < bigdouble) ditsave(1) = ditsave_log
728 if (ditsave_dat < bigdouble) ditsave(2) = ditsave_dat
729 if (ditsave_slice < bigdouble) ditsave(3) = ditsave_slice
730 if (ditsave_collapsed < bigdouble) ditsave(4) = ditsave_collapsed
731 if (ditsave_custom < bigdouble) ditsave(5) = ditsave_custom
733 if (wall_time_max < bigdouble) wall_time_max=wall_time_max*3600.d0
736 write(unitterm, *)
''
737 write(unitterm, *)
'Output type | tsavestart | dtsave | ditsave | itsave(1) | tsave(1)'
738 write(fmt_string, *)
'(A12," | ",E9.3E2," | ",E9.3E2," | ",I6," | "'//&
743 if (mype == 0)
write(unitterm, fmt_string) trim(output_names(ifile)), &
744 tsavestart(ifile), dtsave(ifile), ditsave(ifile), itsave(1, ifile), tsave(1, ifile)
747 if (mype == 0)
write(unitterm, *)
''
750 if(slicedir(islice) > ndim) &
751 write(uniterr,*)
'Warning in read_par_files: ', &
752 'Slice ', islice,
' direction',slicedir(islice),
'larger than ndim=',ndim
753 if(slicedir(islice) < 1) &
754 write(uniterr,*)
'Warning in read_par_files: ', &
755 'Slice ', islice,
' direction',slicedir(islice),
'too small, should be [',1,ndim,
']'
758 if(it_max==biginteger .and. time_max==bigdouble.and.mype==0)
write(uniterr,*) &
759 'Warning in read_par_files: it_max or time_max not given!'
761 select case (typecourant)
763 type_courant=type_maxsum
765 type_courant=type_summax
766 if (local_timestep)
then
767 call mpistop(
"Type courant summax incompatible with local_timestep")
770 type_courant=type_minimum
771 if (local_timestep)
then
772 call mpistop(
"Type courant minimum incompatible with local_timestep")
775 write(unitterm,*)
'Unknown typecourant=',typecourant
776 call mpistop(
"Error from read_par_files: no such typecourant!")
781 select case (flux_scheme(level))
783 flux_method(level)=fs_hll
785 flux_method(level)=fs_hllc
787 flux_method(level)=fs_hlld
789 flux_method(level)=fs_hllcd
791 flux_method(level)=fs_tvdlf
793 flux_method(level)=fs_tvdmu
795 flux_method(level)=fs_tvd
797 flux_method(level)=fs_cd
799 flux_method(level)=fs_cd4
801 flux_method(level)=fs_fd
803 flux_method(level)=fs_source
805 flux_method(level)=fs_nul
807 call mpistop(
"unkown or bad flux scheme")
809 if(flux_scheme(level)==
'tvd'.and.time_stepper/=
'onestep') &
810 call mpistop(
" tvd is onestep method, reset time_stepper='onestep'")
811 if(flux_scheme(level)==
'tvd')
then
812 if(mype==0.and.(.not.dimsplit))
write(unitterm,*) &
813 'Warning: setting dimsplit=T for tvd, as used for level=',level
816 if(flux_scheme(level)==
'hlld'.and.physics_type/=
'mhd' .and. physics_type/=
'twofl') &
817 call mpistop(
"Cannot use hlld flux if not using MHD or 2FL only charges physics!")
819 if(flux_scheme(level)==
'hllc'.and.physics_type==
'mf') &
820 call mpistop(
"Cannot use hllc flux if using magnetofriction physics!")
822 if(flux_scheme(level)==
'tvd'.and.physics_type==
'mf') &
823 call mpistop(
"Cannot use tvd flux if using magnetofriction physics!")
825 if(flux_scheme(level)==
'tvdmu'.and.physics_type==
'mf') &
826 call mpistop(
"Cannot use tvdmu flux if using magnetofriction physics!")
828 if (typepred1(level)==0)
then
829 select case (flux_scheme(level))
831 typepred1(level)=fs_cd
833 typepred1(level)=fs_cd4
835 typepred1(level)=fs_fd
836 case (
'tvdlf',
'tvdmu')
837 typepred1(level)=fs_hancock
839 typepred1(level)=fs_hll
841 typepred1(level)=fs_hllc
843 typepred1(level)=fs_hllcd
845 typepred1(level)=fs_hlld
846 case (
'nul',
'source',
'tvd')
847 typepred1(level)=fs_nul
849 call mpistop(
"No default predictor for this full step")
855 if(any(flux_scheme==
'fd')) need_global_cmax=.true.
858 select case (typecurl)
864 type_curl=stokesbased
866 write(unitterm,*)
"typecurl=",typecurl
867 call mpistop(
"unkown type of curl operator in read_par_files")
871 select case (time_stepper)
875 if (time_integrator==
'default')
then
876 time_integrator=
"Forward_Euler"
878 select case (time_integrator)
879 case (
"Forward_Euler")
880 t_integrator=forward_euler
882 t_integrator=imex_euler
886 write(unitterm,*)
"time_integrator=",time_integrator,
"time_stepper=",time_stepper
887 call mpistop(
"unkown onestep time_integrator in read_par_files")
889 use_imex_scheme=(t_integrator==imex_euler.or.t_integrator==imex_sp)
893 if (time_integrator==
'default')
then
894 time_integrator=
"Predictor_Corrector"
896 select case (time_integrator)
897 case (
"Predictor_Corrector")
898 t_integrator=predictor_corrector
903 case (
"IMEX_Midpoint")
904 t_integrator=imex_midpoint
905 case (
"IMEX_Trapezoidal")
906 t_integrator=imex_trapezoidal
908 t_integrator=imex_222
910 write(unitterm,*)
"time_integrator=",time_integrator,
"time_stepper=",time_stepper
911 call mpistop(
"unkown twostep time_integrator in read_par_files")
913 use_imex_scheme=(t_integrator==imex_midpoint.or.t_integrator==imex_trapezoidal&
914 .or.t_integrator==imex_222)
915 if (t_integrator==rk2_alf)
then
916 if(rk2_alfa<smalldouble.or.rk2_alfa>one)
call mpistop(
"set rk2_alfa within [0,1]")
918 rk_b2=1.0d0/(2.0d0*rk2_alfa)
924 if (time_integrator==
'default')
then
925 time_integrator=
'ssprk3'
927 select case (time_integrator)
933 t_integrator=imex_ars3
935 t_integrator=imex_232
937 t_integrator=imex_cb3a
939 write(unitterm,*)
"time_integrator=",time_integrator,
"time_stepper=",time_stepper
940 call mpistop(
"unkown threestep time_integrator in read_par_files")
942 if(t_integrator==rk3_bt)
then
943 select case(rk3_switch)
973 call mpistop(
"Unknown rk3_switch")
976 rk3_b3=1.0d0-rk3_b1-rk3_b2
978 rk3_c3=rk3_a31+rk3_a32
980 if(t_integrator==ssprk3)
then
981 select case(ssprk_order)
984 rk_beta22=1.0d0/4.0d0
985 rk_beta33=2.0d0/3.0d0
986 rk_alfa21=3.0d0/4.0d0
987 rk_alfa31=1.0d0/3.0d0
991 rk_beta11=1.0d0/2.0d0
992 rk_beta22=1.0d0/2.0d0
993 rk_beta33=1.0d0/3.0d0
995 rk_alfa31=1.0d0/3.0d0
999 call mpistop(
"Unknown ssprk3_order")
1001 rk_alfa22=1.0d0-rk_alfa21
1002 rk_alfa33=1.0d0-rk_alfa31
1004 if(t_integrator==imex_ars3)
then
1005 ars_gamma=(3.0d0+dsqrt(3.0d0))/6.0d0
1007 if(t_integrator==imex_232)
then
1008 select case(imex_switch)
1010 im_delta=1.0d0-1.0d0/dsqrt(2.0d0)
1011 im_nu=(3.0d0+2.0d0*dsqrt(2.0d0))/6.0d0
1012 imex_a21=2.0d0*im_delta
1013 imex_a31=1.0d0-im_nu
1015 imex_b1=1.0d0/(2.0d0*dsqrt(2.0d0))
1016 imex_b2=1.0d0/(2.0d0*dsqrt(2.0d0))
1021 imex_a21=0.711664700366941d0
1022 imex_a31=0.077338168947683d0
1023 imex_a32=0.917273367886007d0
1024 imex_b1=0.398930808264688d0
1025 imex_b2=0.345755244189623d0
1026 imex_ha21=0.353842865099275d0
1027 imex_ha22=0.353842865099275d0
1029 call mpistop(
"Unknown imex_siwtch")
1032 imex_c3=imex_a31+imex_a32
1033 imex_b3=1.0d0-imex_b1-imex_b2
1035 if(t_integrator==imex_cb3a)
then
1036 imex_c2 = 0.8925502329346865
1039 imex_c3 = imex_c2 / (6.0d0*imex_c2**2 - 3.0d0*imex_c2 + 1.0d0)
1041 imex_b2 = (3.0d0*imex_c2 - 1.0d0) / (6.0d0*imex_c2**2)
1042 imex_b3 = (6.0d0*imex_c2**2 - 3.0d0*imex_c2 + 1.0d0) / (6.0d0*imex_c2**2)
1043 imex_a33 = (1.0d0/6.0d0 - imex_b2*imex_c2**2 - imex_b3*imex_c2*imex_c3) / (imex_b3*(imex_c3-imex_c2))
1044 imex_a32 = imex_c3 - imex_a33
1058 use_imex_scheme=(t_integrator==imex_ars3.or.t_integrator==imex_232.or.t_integrator==imex_cb3a)
1062 if (time_integrator==
'default')
then
1063 time_integrator=
"ssprk4"
1065 select case (time_integrator)
1071 write(unitterm,*)
"time_integrator=",time_integrator,
"time_stepper=",time_stepper
1072 call mpistop(
"unkown fourstep time_integrator in read_par_files")
1074 if(t_integrator==ssprk4)
then
1075 select case(ssprk_order)
1077 rk_beta11=1.0d0/2.0d0
1078 rk_beta22=1.0d0/2.0d0
1079 rk_beta33=1.0d0/6.0d0
1080 rk_beta44=1.0d0/2.0d0
1082 rk_alfa31=2.0d0/3.0d0
1088 rk_beta11=1.0d0/3.0d0
1089 rk_beta22=1.0d0/3.0d0
1090 rk_beta33=1.0d0/3.0d0
1091 rk_beta44=1.0d0/4.0d0
1094 rk_alfa41=1.0d0/4.0d0
1099 call mpistop(
"Unknown ssprk_order")
1101 rk_alfa22=1.0d0-rk_alfa21
1102 rk_alfa33=1.0d0-rk_alfa31
1103 rk_alfa44=1.0d0-rk_alfa41
1108 if (time_integrator==
'default')
then
1109 time_integrator=
"ssprk5"
1111 select case (time_integrator)
1115 write(unitterm,*)
"time_integrator=",time_integrator,
"time_stepper=",time_stepper
1116 call mpistop(
"unkown fivestep time_integrator in read_par_files")
1118 if(t_integrator==ssprk5)
then
1119 select case(ssprk_order)
1122 rk_beta11=0.391752226571890d0
1123 rk_beta22=0.368410593050371d0
1124 rk_beta33=0.251891774271694d0
1125 rk_beta44=0.544974750228521d0
1126 rk_beta54=0.063692468666290d0
1127 rk_beta55=0.226007483236906d0
1128 rk_alfa21=0.444370493651235d0
1129 rk_alfa31=0.620101851488403d0
1130 rk_alfa41=0.178079954393132d0
1131 rk_alfa53=0.517231671970585d0
1132 rk_alfa54=0.096059710526147d0
1134 rk_alfa22=0.555629506348765d0
1135 rk_alfa33=0.379898148511597d0
1136 rk_alfa44=0.821920045606868d0
1137 rk_alfa55=0.386708617503269d0
1138 rk_alfa22=1.0d0-rk_alfa21
1139 rk_alfa33=1.0d0-rk_alfa31
1140 rk_alfa44=1.0d0-rk_alfa41
1141 rk_alfa55=1.0d0-rk_alfa53-rk_alfa54
1143 rk_c3=rk_alfa22*rk_c2+rk_beta22
1144 rk_c4=rk_alfa33*rk_c3+rk_beta33
1145 rk_c5=rk_alfa44*rk_c4+rk_beta44
1147 rk_beta11=0.39175222700392d0
1148 rk_beta22=0.36841059262959d0
1149 rk_beta33=0.25189177424738d0
1150 rk_beta44=0.54497475021237d0
1153 rk_alfa21=0.44437049406734d0
1154 rk_alfa31=0.62010185138540d0
1155 rk_alfa41=0.17807995410773d0
1156 rk_alfa53=0.51723167208978d0
1159 rk_alfa22=1.0d0-rk_alfa21
1160 rk_alfa33=1.0d0-rk_alfa31
1161 rk_alfa44=1.0d0-rk_alfa41
1163 rka51=0.00683325884039d0
1164 rka54=0.12759831133288d0
1165 rkb54=0.08460416338212d0
1166 rk_beta54=rkb54-rk_beta44*rka51/rk_alfa41
1167 rk_alfa54=rka54-rk_alfa44*rka51/rk_alfa41
1169 rk_alfa55=1.0d0-rk_alfa53-rk_alfa54
1171 rk_c3=rk_alfa22*rk_c2+rk_beta22
1172 rk_c4=rk_alfa33*rk_c3+rk_beta33
1173 rk_c5=rk_alfa44*rk_c4+rk_beta44
1174 rk_beta55=1.0d0-rk_beta54-rk_alfa53*rk_c3-rk_alfa54*rk_c4-rk_alfa55*rk_c5
1176 call mpistop(
"Unknown ssprk_order")
1185 use_imex_scheme=.false.
1187 call mpistop(
"Unknown time_stepper in read_par_files")
1191 select case (stretch_dim(i))
1192 case (undefined,
'none')
1193 stretch_type(i) = stretch_none
1194 stretched_dim(i) = .false.
1195 case (
'uni',
'uniform')
1196 stretch_type(i) = stretch_uni
1197 stretched_dim(i) = .true.
1198 case (
'symm',
'symmetric')
1199 stretch_type(i) = stretch_symm
1200 stretched_dim(i) = .true.
1202 stretch_type(i) = stretch_none
1203 stretched_dim(i) = .false.
1204 if (mype == 0) print *,
'Got stretch_type = ', stretch_type(i)
1205 call mpistop(
'Unknown stretch type')
1210 if(typedimsplit ==
'default'.and. dimsplit) typedimsplit=
'xyyx'
1211 if(typedimsplit ==
'default'.and..not.dimsplit) typedimsplit=
'unsplit'
1212 dimsplit = typedimsplit /=
'unsplit'
1215 select case (typesourcesplit)
1217 sourcesplit=sourcesplit_sfs
1219 sourcesplit=sourcesplit_sf
1221 sourcesplit=sourcesplit_ssf
1223 sourcesplit=sourcesplit_ssfss
1225 write(unitterm,*)
'No such typesourcesplit=',typesourcesplit
1226 call mpistop(
"Error: Unknown typesourcesplit!")
1229 if(coordinate==-1)
then
1230 coordinate=cartesian
1232 write(*,*)
'Warning: coordinate system is not specified!'
1233 write(*,*)
'call set_coordinate_system in usr_init in mod_usr.t'
1234 write(*,*)
'Now use Cartesian coordinate'
1238 if(coordinate==cartesian)
then
1241 if(any(stretched_dim))
then
1242 coordinate=cartesian_stretched
1243 slab_uniform=.false.
1247 slab_uniform=.false.
1250 if(coordinate==spherical)
then
1252 if(mype==0)print *,
'Warning: spherical symmetry needs dimsplit=F, resetting'
1257 if (ndim==1) dimsplit=.false.
1260 select case(typeprolonglimit)
1275 allocate(type_limiter(nlevelshi))
1276 allocate(type_gradient_limiter(nlevelshi))
1278 do level=1,nlevelshi
1279 type_limiter(level) = limiter_type(limiter(level))
1280 type_gradient_limiter(level) = limiter_type(gradient_limiter(level))
1283 if (any(limiter(1:nlevelshi)==
'ppm')&
1284 .and.(flatsh.and.physics_type==
'rho'))
then
1285 call mpistop(
" PPM with flatsh=.true. can not be used with physics_type='rho'!")
1291 select case(typeboundary_min^d(iw))
1293 typeboundary(iw,2*^d-1)=bc_special
1295 typeboundary(iw,2*^d-1)=bc_cont
1297 typeboundary(iw,2*^d-1)=bc_symm
1299 typeboundary(iw,2*^d-1)=bc_asymm
1301 typeboundary(iw,2*^d-1)=bc_periodic
1303 typeboundary(iw,2*^d-1)=bc_aperiodic
1305 typeboundary(iw,2*^d-1)=bc_noinflow
1307 typeboundary(iw,2*^d-1)=12
1309 typeboundary(iw,2*^d-1)=bc_data
1311 typeboundary(iw,2*^d-1)=bc_icarus
1313 typeboundary(iw,2*^d-1)=bc_character
1315 write (unitterm,*)
"Undefined boundarytype found in read_par_files", &
1316 typeboundary_min^d(iw),
"for variable iw=",iw,
" and side iB=",2*^d-1
1320 select case(typeboundary_max^d(iw))
1322 typeboundary(iw,2*^d)=bc_special
1324 typeboundary(iw,2*^d)=bc_cont
1326 typeboundary(iw,2*^d)=bc_symm
1328 typeboundary(iw,2*^d)=bc_asymm
1330 typeboundary(iw,2*^d)=bc_periodic
1332 typeboundary(iw,2*^d)=bc_aperiodic
1334 typeboundary(iw,2*^d)=bc_noinflow
1336 typeboundary(iw,2*^d)=12
1338 typeboundary(iw,2*^d)=bc_data
1340 typeboundary(iw,2*^d-1)=bc_icarus
1341 case(
"bc_character")
1342 typeboundary(iw,2*^d)=bc_character
1344 write (unitterm,*)
"Undefined boundarytype found in read_par_files", &
1345 typeboundary_max^d(iw),
"for variable iw=",iw,
" and side iB=",2*^d
1351 if (nwfluxbc<nwflux)
then
1352 do iw=nwfluxbc+1,nwflux
1353 typeboundary(iw,:) = typeboundary(1, :)
1358 do iw=nwflux+1, nwflux+nwaux
1359 typeboundary(iw,:) = typeboundary(1, :)
1363 if (any(typeboundary == 0))
then
1364 call mpistop(
"Not all boundary conditions have been defined")
1368 periodb(idim)=(any(typeboundary(:,2*idim-1:2*idim)==bc_periodic))
1369 aperiodb(idim)=(any(typeboundary(:,2*idim-1:2*idim)==bc_aperiodic))
1370 if (periodb(idim).or.aperiodb(idim))
then
1372 if (typeboundary(iw,2*idim-1) .ne. typeboundary(iw,2*idim)) &
1373 call mpistop(
"Wrong counterpart in periodic boundary")
1375 if (typeboundary(iw,2*idim-1) /= bc_periodic .and. &
1376 typeboundary(iw,2*idim-1) /= bc_aperiodic)
then
1377 call mpistop(
"Each dimension should either have all "//&
1378 "or no variables periodic, some can be aperiodic")
1385 if(any(typeboundary(:,2*idim-1)==12))
then
1386 if(any(typeboundary(:,2*idim-1)/=12)) typeboundary(:,2*idim-1)=12
1387 select case(physics_type)
1388 case (
'rho',
'ard',
'rd',
'nonlinear',
'ffhd')
1390 typeboundary(:,2*idim-1)=bc_symm
1391 if(mype==0) print *,
'symmetric minimal pole'
1392 case (
'hd',
'rhd',
'srhd',
'mhd',
'rmhd')
1393 typeboundary(:,2*idim-1)=bc_symm
1395 if(phys_energy)
then
1400 select case(coordinate)
1402 typeboundary(phi_+1,2*idim-1)=bc_asymm
1403 if(physics_type==
'mhd'.or.physics_type==
'rmhd') typeboundary(ndir+windex+phi_,2*idim-1)=bc_asymm
1405 typeboundary(3:ndir+1,2*idim-1)=bc_asymm
1406 if(physics_type==
'mhd'.or.physics_type==
'rmhd') typeboundary(ndir+windex+2:ndir+windex+ndir,2*idim-1)=bc_asymm
1408 call mpistop(
'Pole is in cylindrical, polar, spherical coordinates!')
1411 call mpistop(
'Pole treatment for twofl or mf not implemented yet')
1413 call mpistop(
'unknown physics type for setting minimal pole boundary treatment')
1416 if(any(typeboundary(:,2*idim)==12))
then
1417 if(any(typeboundary(:,2*idim)/=12)) typeboundary(:,2*idim)=12
1418 select case(physics_type)
1419 case (
'rho',
'ard',
'rd',
'nonlinear',
'ffhd')
1421 typeboundary(:,2*idim)=bc_symm
1422 if(mype==0) print *,
'symmetric maximal pole'
1423 case (
'hd',
'rhd',
'srhd',
'mhd',
'rmhd')
1424 typeboundary(:,2*idim)=bc_symm
1426 if(phys_energy)
then
1431 select case(coordinate)
1433 typeboundary(phi_+1,2*idim)=bc_asymm
1434 if(physics_type==
'mhd'.or.physics_type==
'rmhd') typeboundary(ndir+windex+phi_,2*idim)=bc_asymm
1436 typeboundary(3:ndir+1,2*idim)=bc_asymm
1437 if(physics_type==
'mhd'.or.physics_type==
'rmhd') typeboundary(ndir+windex+2:ndir+windex+ndir,2*idim)=bc_asymm
1439 call mpistop(
'Pole is in cylindrical, polar, spherical coordinates!')
1442 call mpistop(
'Pole treatment for twofl or mf not implemented yet')
1444 call mpistop(
'unknown physics type for setting maximal pole boundary treatment')
1450 if(.not.phys_energy)
then
1455 if(any(limiter(1:nlevelshi)==
'mp5'))
then
1456 nghostcells=max(nghostcells,3)
1459 if(any(limiter(1:nlevelshi)==
'weno5'))
then
1460 nghostcells=max(nghostcells,3)
1463 if(any(limiter(1:nlevelshi)==
'weno5nm'))
then
1464 nghostcells=max(nghostcells,3)
1467 if(any(limiter(1:nlevelshi)==
'wenoz5'))
then
1468 nghostcells=max(nghostcells,3)
1471 if(any(limiter(1:nlevelshi)==
'wenoz5nm'))
then
1472 nghostcells=max(nghostcells,3)
1475 if(any(limiter(1:nlevelshi)==
'wenozp5'))
then
1476 nghostcells=max(nghostcells,3)
1479 if(any(limiter(1:nlevelshi)==
'wenozp5nm'))
then
1480 nghostcells=max(nghostcells,3)
1483 if(any(limiter(1:nlevelshi)==
'teno5ad'))
then
1484 nghostcells=max(nghostcells,3)
1487 if(any(limiter(1:nlevelshi)==
'weno5cu6'))
then
1488 nghostcells=max(nghostcells,3)
1491 if(any(limiter(1:nlevelshi)==
'ppm'))
then
1492 if(flatsh .or. flatcd)
then
1493 nghostcells=max(nghostcells,4)
1495 nghostcells=max(nghostcells,3)
1499 if(any(limiter(1:nlevelshi)==
'weno7'))
then
1500 nghostcells=max(nghostcells,4)
1503 if(any(limiter(1:nlevelshi)==
'mpweno7'))
then
1504 nghostcells=max(nghostcells,4)
1508 nghostcells = nghostcells + phys_wider_stencil
1511 if(stagger_grid .and. refine_max_level>1 .and. mod(nghostcells,2)/=0)
then
1512 nghostcells=nghostcells+1
1515 select case (coordinate)
1518 xprob^lim^de=xprob^lim^de*two*dpi;
1523 xprob^lim^d=xprob^lim^d*two*dpi;
1529 {ixghi^d = block_nx^d + 2*nghostcells\}
1530 {ixgshi^d = ixghi^d\}
1532 nx_vec = [{domain_nx^d|, }]
1533 block_nx_vec = [{block_nx^d|, }]
1535 if (any(nx_vec < 4) .or. any(mod(nx_vec, 2) == 1)) &
1536 call mpistop(
'Grid size (domain_nx^D) has to be even and >= 4')
1538 if (any(block_nx_vec < 4) .or. any(mod(block_nx_vec, 2) == 1)) &
1539 call mpistop(
'Block size (block_nx^D) has to be even and >= 4')
1541 {
if(mod(domain_nx^d,block_nx^d)/=0) &
1542 call mpistop(
'Grid (domain_nx^D) and block (block_nx^D) must be consistent') \}
1544 if(refine_max_level>nlevelshi.or.refine_max_level<1)
then
1545 write(unitterm,*)
'Error: refine_max_level',refine_max_level,
'>nlevelshi ',nlevelshi
1546 call mpistop(
"Reset nlevelshi and recompile!")
1549 if (any(stretched_dim))
then
1550 allocate(qstretch(0:nlevelshi,1:ndim),dxfirst(0:nlevelshi,1:ndim),&
1551 dxfirst_1mq(0:nlevelshi,1:ndim),dxmid(0:nlevelshi,1:ndim))
1552 allocate(nstretchedblocks(1:nlevelshi,1:ndim))
1553 qstretch(0:nlevelshi,1:ndim)=0.0d0
1554 dxfirst(0:nlevelshi,1:ndim)=0.0d0
1555 nstretchedblocks(1:nlevelshi,1:ndim)=0
1556 {
if (stretch_type(^d) == stretch_uni)
then
1558 if(qstretch_baselevel(^d)<1.0d0.or.qstretch_baselevel(^d)==bigdouble)
then
1560 write(*,*)
'stretched grid needs finite qstretch_baselevel>1'
1561 write(*,*)
'will try default value for qstretch_baselevel in dimension', ^d
1563 if(xprobmin^d>smalldouble)
then
1564 qstretch_baselevel(^d)=(xprobmax^d/xprobmin^d)**(1.d0/dble(domain_nx^d))
1566 call mpistop(
"can not set qstretch_baselevel automatically")
1569 if(mod(block_nx^d,2)==1) &
1570 call mpistop(
"stretched grid needs even block size block_nxD")
1571 if(mod(domain_nx^d/block_nx^d,2)/=0) &
1572 call mpistop(
"number level 1 blocks in D must be even")
1573 qstretch(1,^d)=qstretch_baselevel(^d)
1574 dxfirst(1,^d)=(xprobmax^d-xprobmin^d) &
1575 *(1.0d0-qstretch(1,^d))/(1.0d0-qstretch(1,^d)**domain_nx^d)
1576 qstretch(0,^d)=qstretch(1,^d)**2
1577 dxfirst(0,^d)=dxfirst(1,^d)*(1.0d0+qstretch(1,^d))
1578 if(refine_max_level>1)
then
1579 do ilev=2,refine_max_level
1580 qstretch(ilev,^d)=dsqrt(qstretch(ilev-1,^d))
1581 dxfirst(ilev,^d)=dxfirst(ilev-1,^d) &
1582 /(1.0d0+dsqrt(qstretch(ilev-1,^d)))
1587 {
if(stretch_type(^d) == stretch_uni)
then
1588 write(*,*)
'Stretched dimension ', ^d
1589 write(*,*)
'Using stretched grid with qs=',qstretch(0:refine_max_level,^d)
1590 write(*,*)
' and first cell sizes=',dxfirst(0:refine_max_level,^d)
1593 {
if(stretch_type(^d) == stretch_symm)
then
1595 write(*,*)
'will apply symmetric stretch in dimension', ^d
1597 if(mod(block_nx^d,2)==1) &
1598 call mpistop(
"stretched grid needs even block size block_nxD")
1600 if(nstretchedblocks_baselevel(^d)==0) &
1601 call mpistop(
"need finite even number of stretched blocks at baselevel")
1602 if(mod(nstretchedblocks_baselevel(^d),2)==1) &
1603 call mpistop(
"need even number of stretched blocks at baselevel")
1604 if(qstretch_baselevel(^d)<1.0d0.or.qstretch_baselevel(^d)==bigdouble) &
1605 call mpistop(
'stretched grid needs finite qstretch_baselevel>1')
1607 ipower=(nstretchedblocks_baselevel(^d)/2)*block_nx^d
1608 if(nstretchedblocks_baselevel(^d)==domain_nx^d/block_nx^d)
then
1609 xstretch^d=0.5d0*(xprobmax^d-xprobmin^d)
1611 xstretch^d=(xprobmax^d-xprobmin^d) &
1612 /(2.0d0+dble(domain_nx^d-nstretchedblocks_baselevel(^d)*block_nx^d) &
1613 *(1.0d0-qstretch_baselevel(^d))/(1.0d0-qstretch_baselevel(^d)**ipower))
1615 if(xstretch^d>(xprobmax^d-xprobmin^d)*0.5d0) &
1616 call mpistop(
" stretched grid part should not exceed full domain")
1617 dxfirst(1,^d)=xstretch^d*(1.0d0-qstretch_baselevel(^d)) &
1618 /(1.0d0-qstretch_baselevel(^d)**ipower)
1619 nstretchedblocks(1,^d)=nstretchedblocks_baselevel(^d)
1620 qstretch(1,^d)=qstretch_baselevel(^d)
1621 qstretch(0,^d)=qstretch(1,^d)**2
1622 dxfirst(0,^d)=dxfirst(1,^d)*(1.0d0+qstretch(1,^d))
1623 dxmid(1,^d)=dxfirst(1,^d)
1624 dxmid(0,^d)=dxfirst(1,^d)*2.0d0
1625 if(refine_max_level>1)
then
1626 do ilev=2,refine_max_level
1627 nstretchedblocks(ilev,^d)=2*nstretchedblocks(ilev-1,^d)
1628 qstretch(ilev,^d)=dsqrt(qstretch(ilev-1,^d))
1629 dxfirst(ilev,^d)=dxfirst(ilev-1,^d) &
1630 /(1.0d0+dsqrt(qstretch(ilev-1,^d)))
1631 dxmid(ilev,^d)=dxmid(ilev-1,^d)/2.0d0
1635 sizeuniformpart^d=dxfirst(1,^d) &
1636 *(domain_nx^d-nstretchedblocks_baselevel(^d)*block_nx^d)
1638 print *,
'uniform part of size=',sizeuniformpart^d
1639 print *,
'setting of domain is then=',2*xstretch^d+sizeuniformpart^d
1640 print *,
'versus=',xprobmax^d-xprobmin^d
1642 if(dabs(xprobmax^d-xprobmin^d-2*xstretch^d-sizeuniformpart^d)>smalldouble)
then
1643 call mpistop(
'mismatch in domain size!')
1646 dxfirst_1mq(0:refine_max_level,1:ndim)=dxfirst(0:refine_max_level,1:ndim) &
1647 /(1.0d0-qstretch(0:refine_max_level,1:ndim))
1650 dx_vec = [{xprobmax^d-xprobmin^d|, }] / nx_vec
1653 write(c_ndim,
'(I1)') ^nd
1654 write(unitterm,
'(A30,' // c_ndim //
'(I0," "))') &
1655 ' Domain size (cells): ', nx_vec
1656 write(unitterm,
'(A30,' // c_ndim //
'(E9.3," "))') &
1657 ' Level one dx: ', dx_vec
1660 if (any(dx_vec < smalldouble)) &
1661 call mpistop(
"Incorrect domain size (too small grid spacing)")
1665 if(sum(w_refine_weight(:))==0) w_refine_weight(1) = 1.d0
1666 if(dabs(sum(w_refine_weight(:))-1.d0)>smalldouble)
then
1667 write(unitterm,*)
"Sum of all elements in w_refine_weight be 1.d0"
1668 call mpistop(
"Reset w_refine_weight so the sum is 1.d0")
1671 select case (typeboundspeed)
1676 case(
'cmaxleftright')
1681 call mpistop(
"set typeboundspeed='Einfeldt' or 'cmaxmean' or 'cmaxleftright' or 'pvrs'")
1684 if (mype==0)
write(unitterm,
'(A30)', advance=
'no')
'Refine estimation: '
1686 select case (refine_criterion)
1688 if (mype==0)
write(unitterm,
'(A)')
"user defined"
1690 if (mype==0)
write(unitterm,
'(A)')
"relative error"
1692 if (mype==0)
write(unitterm,
'(A)')
"Lohner's original scheme"
1694 if (mype==0)
write(unitterm,
'(A)')
"Lohner's scheme"
1696 call mpistop(
"Unknown error estimator, change refine_criterion")
1699 if (tfixgrid<bigdouble/2.0d0)
then
1700 if(mype==0)print*,
'Warning, at time=',tfixgrid,
'the grid will be fixed'
1702 if (itfixgrid<biginteger/2)
then
1703 if(mype==0)print*,
'Warning, at iteration=',itfixgrid,
'the grid will be fixed'
1705 if (ditregrid>1)
then
1706 if(mype==0)print*,
'Note, Grid is reconstructed once every',ditregrid,
'iterations'
1711 select case(slicedir(islice))
1713 if(slicecoord(islice)<xprobmin^d.or.slicecoord(islice)>xprobmax^d) &
1714 write(uniterr,*)
'Warning in read_par_files: ', &
1715 'Slice ', islice,
' coordinate',slicecoord(islice),
'out of bounds for dimension ',slicedir(islice)
1721 write(unitterm,
'(A30,A,A)')
'restart_from_file: ',
' ', trim(restart_from_file)
1722 write(unitterm,
'(A30,L1)')
'converting: ', convert
1723 write(unitterm,
'(A)')
''
1726 deallocate(flux_scheme)
1878 integer,
intent(in) :: fh
1879 integer(MPI_OFFSET_KIND),
intent(out) :: offset_tree
1880 integer(MPI_OFFSET_KIND),
intent(out) :: offset_block
1882 double precision :: rbuf(ndim)
1883 double precision,
allocatable :: params(:)
1884 integer :: i, version
1885 integer :: ibuf(ndim), iw
1886 integer :: er, n_par, tmp_int
1887 integer,
dimension(MPI_STATUS_SIZE) :: st
1888 logical :: periodic(ndim)
1889 character(len=name_len),
allocatable :: var_names(:), param_names(:)
1890 character(len=name_len) :: phys_name, geom_name
1893 call mpi_file_read(fh, version, 1, mpi_integer, st, er)
1895 call mpistop(
"Incompatible file version (maybe old format?)")
1899 call mpi_file_read(fh, ibuf(1), 1, mpi_integer, st, er)
1900 offset_tree = ibuf(1)
1903 call mpi_file_read(fh, ibuf(1), 1, mpi_integer, st, er)
1904 offset_block = ibuf(1)
1907 call mpi_file_read(fh, ibuf(1), 1, mpi_integer, st, er)
1909 if (nw /= ibuf(1))
then
1910 write(*,*)
"nw=",nw,
" and nw found in restart file=",ibuf(1)
1911 write(*,*)
"Please be aware of changes in w at restart."
1916 call mpi_file_read(fh, ibuf(1), 1, mpi_integer, st, er)
1917 if (ibuf(1) /=
ndir)
then
1918 write(*,*)
"ndir in restart file = ",ibuf(1)
1919 write(*,*)
"ndir = ",
ndir
1920 call mpistop(
"reset ndir to ndir in restart file")
1924 call mpi_file_read(fh, ibuf(1), 1, mpi_integer, st, er)
1925 if (ibuf(1) /= ndim)
then
1926 write(*,*)
"ndim in restart file = ",ibuf(1)
1927 write(*,*)
"ndim = ",ndim
1928 call mpistop(
"reset ndim to ndim in restart file")
1932 call mpi_file_read(fh, ibuf(1), 1, mpi_integer, st, er)
1934 write(*,*)
"number of levels in restart file = ",ibuf(1)
1936 call mpistop(
"refine_max_level < num. levels in restart file")
1940 call mpi_file_read(fh,
nleafs, 1, mpi_integer, st, er)
1943 call mpi_file_read(fh,
nparents, 1, mpi_integer, st, er)
1946 call mpi_file_read(fh,
it, 1, mpi_integer, st, er)
1949 call mpi_file_read(fh,
global_time, 1, mpi_double_precision, st, er)
1952 call mpi_file_read(fh,rbuf(1:ndim),ndim,mpi_double_precision,st,er)
1953 if (maxval(abs(rbuf(1:ndim) - [ xprobmin^
d ])) > 0)
then
1954 write(*,*)
"Error: xprobmin differs from restart data: ", rbuf(1:ndim)
1955 call mpistop(
"change xprobmin^D in par file")
1959 call mpi_file_read(fh,rbuf(1:ndim),ndim,mpi_double_precision,st,er)
1960 if (maxval(abs(rbuf(1:ndim) - [ xprobmax^
d ])) > 0)
then
1961 write(*,*)
"Error: xprobmax differs from restart data: ", rbuf(1:ndim)
1962 call mpistop(
"change xprobmax^D in par file")
1966 call mpi_file_read(fh,ibuf(1:ndim), ndim, mpi_integer,st,er)
1967 if (any(ibuf(1:ndim) /= [
domain_nx^
d ]))
then
1968 write(*,*)
"Error: mesh size differs from restart data: ", ibuf(1:ndim)
1969 call mpistop(
"change domain_nx^D in par file")
1973 call mpi_file_read(fh,ibuf(1:ndim), ndim, mpi_integer,st,er)
1974 if (any(ibuf(1:ndim) /= [
block_nx^
d ]))
then
1975 write(*,*)
"Error: block size differs from restart data:", ibuf(1:ndim)
1976 call mpistop(
"change block_nx^D in par file")
1980 if (version > 4)
then
1981 call mpi_file_read(fh, periodic, ndim, mpi_logical, st, er)
1982 if ({periodic(^
d) .and. .not.
periodb(^
d) .or. .not.periodic(^
d) .and.
periodb(^
d)| .or. }) &
1983 call mpistop(
"change in periodicity in par file")
1985 call mpi_file_read(fh, geom_name, name_len, mpi_character, st, er)
1988 write(*,*)
"type of coordinates in data is: ", geom_name
1989 call mpistop(
"select the correct coordinates in mod_usr.t file")
1992 call mpi_file_read(fh, stagger_mark_dat, 1, mpi_logical, st, er)
1994 write(*,*)
"Warning: stagger grid flag differs from restart data:", stagger_mark_dat
2000 if (version > 3)
then
2004 call mpi_file_read(fh, var_names(iw), name_len, mpi_character, st, er)
2008 call mpi_file_read(fh, phys_name, name_len, mpi_character, st, er)
2014 call mpi_file_read(fh, n_par, 1, mpi_integer, st, er)
2015 allocate(params(n_par))
2016 allocate(param_names(n_par))
2017 call mpi_file_read(fh, params, n_par, mpi_double_precision, st, er)
2018 call mpi_file_read(fh, param_names, name_len * n_par, mpi_character, st, er)
2021 call mpi_file_read(fh, tmp_int, 1, mpi_integer, st, er)
2026 call mpi_file_read(fh, tmp_int, 1, mpi_integer, st, er)
2029 call mpi_file_read(fh, tmp_int, 1, mpi_integer, st, er)