183 double precision,
dimension(nsavehi) :: tsave_log, tsave_dat, tsave_slice, &
184 tsave_collapsed, tsave_custom
185 double precision :: dtsave_log, dtsave_dat, dtsave_slice, &
186 dtsave_collapsed, dtsave_custom
187 double precision :: tsavestart_log, tsavestart_dat, tsavestart_slice, &
188 tsavestart_collapsed, tsavestart_custom
189 double precision :: sizeuniformpart^D
190 double precision :: im_delta,im_nu,rka54,rka51,rkb54,rka55
191 double precision :: dx_vec(^ND)
192 integer :: ditsave_log, ditsave_dat, ditsave_slice, &
193 ditsave_collapsed, ditsave_custom
194 integer :: windex, ipower
195 integer :: i, j, k, ifile, io_state
196 integer :: iB, isave, iw, level, idim, islice
197 integer :: nx_vec(^ND), block_nx_vec(^ND)
198 integer :: my_unit, iostate
200 logical :: fileopen, file_exists
203 character(len=80) :: fmt_string
204 character(len=std_len) :: err_msg, restart_from_file_arg
205 character(len=std_len) :: basename_full, basename_prev, dummy_file
206 character(len=std_len),
dimension(:),
allocatable :: &
207 typeboundary_min^D, typeboundary_max^D
208 character(len=std_len),
allocatable :: limiter(:)
209 character(len=std_len),
allocatable :: gradient_limiter(:)
210 character(len=name_len) :: stretch_dim(ndim)
213 character(len=std_len) :: typesourcesplit
215 character(len=std_len),
allocatable :: flux_scheme(:)
217 character(len=std_len) :: typeboundspeed
219 character(len=std_len) :: time_stepper
221 character(len=std_len) :: time_integrator
223 character(len=std_len) :: typecurl
225 character(len=std_len) :: typeprolonglimit
231 character(len=std_len) :: typecourant
245 tsave_log, tsave_dat, tsave_slice, tsave_collapsed, tsave_custom, &
246 dtsave_log, dtsave_dat, dtsave_slice, dtsave_collapsed, dtsave_custom, &
247 ditsave_log, ditsave_dat, ditsave_slice, ditsave_collapsed, ditsave_custom,&
248 tsavestart_log, tsavestart_dat, tsavestart_slice, tsavestart_collapsed,&
254 namelist /methodlist/ time_stepper,time_integrator, &
313 allocate(typeboundary_min^d(nwfluxbc))
314 allocate(typeboundary_max^d(nwfluxbc))
377 typeprolonglimit =
'default'
415 tsave(isave,ifile) = bigdouble
416 itsave(isave,ifile) = biginteger
425 tsave_log = bigdouble
426 tsave_dat = bigdouble
427 tsave_slice = bigdouble
428 tsave_collapsed = bigdouble
429 tsave_custom = bigdouble
431 dtsave_log = bigdouble
432 dtsave_dat = bigdouble
433 dtsave_slice = bigdouble
434 dtsave_collapsed = bigdouble
435 dtsave_custom = bigdouble
437 ditsave_log = biginteger
438 ditsave_dat = biginteger
439 ditsave_slice = biginteger
440 ditsave_collapsed = biginteger
441 ditsave_custom = biginteger
443 tsavestart_log = bigdouble
444 tsavestart_dat = bigdouble
445 tsavestart_slice = bigdouble
446 tsavestart_collapsed = bigdouble
447 tsavestart_custom = bigdouble
468 typecourant =
'maxsum'
478 typeboundspeed =
'Einfeldt'
480 time_stepper =
'twostep'
481 time_integrator =
'default'
513 flux_scheme(level) =
'tvdlf'
515 limiter(level) =
'minmod'
516 gradient_limiter(level) =
'minmod'
521 typesourcesplit =
'sfs'
548 if(i==j.or.j==k.or.k==i)
then
550 else if(i+1==j.or.i-2==j)
then
567 inquire(file=trim(
par_files(i)), exist=file_exists)
569 if (.not. file_exists)
then
570 write(err_msg, *)
"The parameter file " // trim(
par_files(i)) // &
580 read(
unitpar, filelist,
end=101)
583 read(unitpar, savelist,
end=102)
586 read(unitpar, stoplist,
end=103)
589 read(unitpar, methodlist,
end=104)
592 read(unitpar, boundlist,
end=105)
595 read(unitpar, meshlist,
end=106)
598 read(unitpar, paramlist,
end=107)
601 read(unitpar, emissionlist,
end=108)
606 if (base_filename /= basename_prev) &
607 basename_full = trim(basename_full) // trim(base_filename)
608 basename_prev = base_filename
611 base_filename = basename_full
615 dummy_file = trim(base_filename)//
"DUMMY"
616 open(newunit=my_unit, file=trim(dummy_file), iostat=iostate)
617 if (iostate /= 0)
then
618 call mpistop(
"Can't write to output directory (" // &
619 trim(base_filename) //
")")
621 close(my_unit, status=
'delete')
625 if(source_split_usr) any_source_split=.true.
628 if(restart_from_file_arg /= undefined) &
629 restart_from_file=restart_from_file_arg
633 if(restart_from_file == undefined)
then
636 do index_latest_data = 9999, 0, -1
642 if(.not.file_exists) index_latest_data=-1
648 call mpi_bcast(index_latest_data, 1, mpi_integer, 0, icomm, ierrmpi)
650 if (resume_previous_run)
then
651 if (index_latest_data == -1)
then
652 if(mype==0)
write(*,*)
"No snapshots found to resume from, start a new run..."
655 write(restart_from_file,
"(a,i4.4,a)") trim(base_filename),index_latest_data,
".dat"
659 if (restart_from_file == undefined)
then
664 call mpistop(
"Please restart from a snapshot when firstprocess=T")
666 call mpistop(
'Change convert to .false. for a new run!')
669 if (small_pressure < 0.d0)
call mpistop(
"small_pressure should be positive.")
670 if (small_density < 0.d0)
call mpistop(
"small_density should be positive.")
672 if (small_temperature>0.d0) small_pressure=small_density*small_temperature
674 if(convert) autoconvert=.false.
676 where (tsave_log < bigdouble) tsave(:, 1) = tsave_log
677 where (tsave_dat < bigdouble) tsave(:, 2) = tsave_dat
678 where (tsave_slice < bigdouble) tsave(:, 3) = tsave_slice
679 where (tsave_collapsed < bigdouble) tsave(:, 4) = tsave_collapsed
680 where (tsave_custom < bigdouble) tsave(:, 5) = tsave_custom
682 if (dtsave_log < bigdouble) dtsave(1) = dtsave_log
683 if (dtsave_dat < bigdouble) dtsave(2) = dtsave_dat
684 if (dtsave_slice < bigdouble) dtsave(3) = dtsave_slice
685 if (dtsave_collapsed < bigdouble) dtsave(4) = dtsave_collapsed
686 if (dtsave_custom < bigdouble) dtsave(5) = dtsave_custom
688 if (tsavestart_log < bigdouble) tsavestart(1) = tsavestart_log
689 if (tsavestart_dat < bigdouble) tsavestart(2) = tsavestart_dat
690 if (tsavestart_slice < bigdouble) tsavestart(3) = tsavestart_slice
691 if (tsavestart_collapsed < bigdouble) tsavestart(4) = tsavestart_collapsed
692 if (tsavestart_custom < bigdouble) tsavestart(5) = tsavestart_custom
694 if (ditsave_log < bigdouble) ditsave(1) = ditsave_log
695 if (ditsave_dat < bigdouble) ditsave(2) = ditsave_dat
696 if (ditsave_slice < bigdouble) ditsave(3) = ditsave_slice
697 if (ditsave_collapsed < bigdouble) ditsave(4) = ditsave_collapsed
698 if (ditsave_custom < bigdouble) ditsave(5) = ditsave_custom
700 if (wall_time_max < bigdouble) wall_time_max=wall_time_max*3600.d0
703 write(unitterm, *)
''
704 write(unitterm, *)
'Output type | tsavestart | dtsave | ditsave | itsave(1) | tsave(1)'
705 write(fmt_string, *)
'(A12," | ",E9.3E2," | ",E9.3E2," | ",I6," | "'//&
710 if (mype == 0)
write(unitterm, fmt_string) trim(output_names(ifile)), &
711 tsavestart(ifile), dtsave(ifile), ditsave(ifile), itsave(1, ifile), tsave(1, ifile)
714 if (mype == 0)
write(unitterm, *)
''
717 if(slicedir(islice) > ndim) &
718 write(uniterr,*)
'Warning in read_par_files: ', &
719 'Slice ', islice,
' direction',slicedir(islice),
'larger than ndim=',ndim
720 if(slicedir(islice) < 1) &
721 write(uniterr,*)
'Warning in read_par_files: ', &
722 'Slice ', islice,
' direction',slicedir(islice),
'too small, should be [',1,ndim,
']'
725 if(it_max==biginteger .and. time_max==bigdouble.and.mype==0)
write(uniterr,*) &
726 'Warning in read_par_files: it_max or time_max not given!'
728 select case (typecourant)
730 type_courant=type_maxsum
732 type_courant=type_summax
733 if (local_timestep)
then
734 call mpistop(
"Type courant summax incompatible with local_timestep")
737 type_courant=type_minimum
738 if (local_timestep)
then
739 call mpistop(
"Type courant minimum incompatible with local_timestep")
742 write(unitterm,*)
'Unknown typecourant=',typecourant
743 call mpistop(
"Error from read_par_files: no such typecourant!")
748 select case (flux_scheme(level))
750 flux_method(level)=fs_hll
752 flux_method(level)=fs_hllc
754 flux_method(level)=fs_hlld
756 flux_method(level)=fs_hllcd
758 flux_method(level)=fs_tvdlf
760 flux_method(level)=fs_tvdmu
762 flux_method(level)=fs_tvd
764 flux_method(level)=fs_cd
766 flux_method(level)=fs_cd4
768 flux_method(level)=fs_fd
770 flux_method(level)=fs_source
772 flux_method(level)=fs_nul
774 call mpistop(
"unkown or bad flux scheme")
776 if(flux_scheme(level)==
'tvd'.and.time_stepper/=
'onestep') &
777 call mpistop(
" tvd is onestep method, reset time_stepper='onestep'")
778 if(flux_scheme(level)==
'tvd')
then
779 if(mype==0.and.(.not.dimsplit))
write(unitterm,*) &
780 'Warning: setting dimsplit=T for tvd, as used for level=',level
783 if(flux_scheme(level)==
'hlld'.and.physics_type/=
'mhd' .and. physics_type/=
'twofl') &
784 call mpistop(
"Cannot use hlld flux if not using MHD or 2FL only charges physics!")
786 if(flux_scheme(level)==
'hllc'.and.physics_type==
'mf') &
787 call mpistop(
"Cannot use hllc flux if using magnetofriction physics!")
789 if(flux_scheme(level)==
'tvd'.and.physics_type==
'mf') &
790 call mpistop(
"Cannot use tvd flux if using magnetofriction physics!")
792 if(flux_scheme(level)==
'tvdmu'.and.physics_type==
'mf') &
793 call mpistop(
"Cannot use tvdmu flux if using magnetofriction physics!")
795 if (typepred1(level)==0)
then
796 select case (flux_scheme(level))
798 typepred1(level)=fs_cd
800 typepred1(level)=fs_cd4
802 typepred1(level)=fs_fd
803 case (
'tvdlf',
'tvdmu')
804 typepred1(level)=fs_hancock
806 typepred1(level)=fs_hll
808 typepred1(level)=fs_hllc
810 typepred1(level)=fs_hllcd
812 typepred1(level)=fs_hlld
813 case (
'nul',
'source',
'tvd')
814 typepred1(level)=fs_nul
816 call mpistop(
"No default predictor for this full step")
822 if(any(flux_scheme==
'fd')) need_global_cmax=.true.
823 if(any(limiter==
'schmid1')) need_global_a2max=.true.
826 select case (typecurl)
832 type_curl=stokesbased
834 write(unitterm,*)
"typecurl=",typecurl
835 call mpistop(
"unkown type of curl operator in read_par_files")
839 select case (time_stepper)
843 if (time_integrator==
'default')
then
844 time_integrator=
"Forward_Euler"
846 select case (time_integrator)
847 case (
"Forward_Euler")
848 t_integrator=forward_euler
850 t_integrator=imex_euler
854 write(unitterm,*)
"time_integrator=",time_integrator,
"time_stepper=",time_stepper
855 call mpistop(
"unkown onestep time_integrator in read_par_files")
857 use_imex_scheme=(t_integrator==imex_euler.or.t_integrator==imex_sp)
861 if (time_integrator==
'default')
then
862 time_integrator=
"Predictor_Corrector"
864 select case (time_integrator)
865 case (
"Predictor_Corrector")
866 t_integrator=predictor_corrector
871 case (
"IMEX_Midpoint")
872 t_integrator=imex_midpoint
873 case (
"IMEX_Trapezoidal")
874 t_integrator=imex_trapezoidal
876 t_integrator=imex_222
878 write(unitterm,*)
"time_integrator=",time_integrator,
"time_stepper=",time_stepper
879 call mpistop(
"unkown twostep time_integrator in read_par_files")
881 use_imex_scheme=(t_integrator==imex_midpoint.or.t_integrator==imex_trapezoidal&
882 .or.t_integrator==imex_222)
883 if (t_integrator==rk2_alf)
then
884 if(rk2_alfa<smalldouble.or.rk2_alfa>one)
call mpistop(
"set rk2_alfa within [0,1]")
886 rk_b2=1.0d0/(2.0d0*rk2_alfa)
892 if (time_integrator==
'default')
then
893 time_integrator=
'ssprk3'
895 select case (time_integrator)
901 t_integrator=imex_ars3
903 t_integrator=imex_232
905 t_integrator=imex_cb3a
907 write(unitterm,*)
"time_integrator=",time_integrator,
"time_stepper=",time_stepper
908 call mpistop(
"unkown threestep time_integrator in read_par_files")
910 if(t_integrator==rk3_bt)
then
911 select case(rk3_switch)
941 call mpistop(
"Unknown rk3_switch")
944 rk3_b3=1.0d0-rk3_b1-rk3_b2
946 rk3_c3=rk3_a31+rk3_a32
948 if(t_integrator==ssprk3)
then
949 select case(ssprk_order)
952 rk_beta22=1.0d0/4.0d0
953 rk_beta33=2.0d0/3.0d0
954 rk_alfa21=3.0d0/4.0d0
955 rk_alfa31=1.0d0/3.0d0
959 rk_beta11=1.0d0/2.0d0
960 rk_beta22=1.0d0/2.0d0
961 rk_beta33=1.0d0/3.0d0
963 rk_alfa31=1.0d0/3.0d0
967 call mpistop(
"Unknown ssprk3_order")
969 rk_alfa22=1.0d0-rk_alfa21
970 rk_alfa33=1.0d0-rk_alfa31
972 if(t_integrator==imex_ars3)
then
973 ars_gamma=(3.0d0+dsqrt(3.0d0))/6.0d0
975 if(t_integrator==imex_232)
then
976 select case(imex_switch)
978 im_delta=1.0d0-1.0d0/dsqrt(2.0d0)
979 im_nu=(3.0d0+2.0d0*dsqrt(2.0d0))/6.0d0
980 imex_a21=2.0d0*im_delta
983 imex_b1=1.0d0/(2.0d0*dsqrt(2.0d0))
984 imex_b2=1.0d0/(2.0d0*dsqrt(2.0d0))
989 imex_a21=0.711664700366941d0
990 imex_a31=0.077338168947683d0
991 imex_a32=0.917273367886007d0
992 imex_b1=0.398930808264688d0
993 imex_b2=0.345755244189623d0
994 imex_ha21=0.353842865099275d0
995 imex_ha22=0.353842865099275d0
997 call mpistop(
"Unknown imex_siwtch")
1000 imex_c3=imex_a31+imex_a32
1001 imex_b3=1.0d0-imex_b1-imex_b2
1003 if(t_integrator==imex_cb3a)
then
1004 imex_c2 = 0.8925502329346865
1007 imex_c3 = imex_c2 / (6.0d0*imex_c2**2 - 3.0d0*imex_c2 + 1.0d0)
1009 imex_b2 = (3.0d0*imex_c2 - 1.0d0) / (6.0d0*imex_c2**2)
1010 imex_b3 = (6.0d0*imex_c2**2 - 3.0d0*imex_c2 + 1.0d0) / (6.0d0*imex_c2**2)
1011 imex_a33 = (1.0d0/6.0d0 - imex_b2*imex_c2**2 - imex_b3*imex_c2*imex_c3) / (imex_b3*(imex_c3-imex_c2))
1012 imex_a32 = imex_c3 - imex_a33
1026 use_imex_scheme=(t_integrator==imex_ars3.or.t_integrator==imex_232.or.t_integrator==imex_cb3a)
1030 if (time_integrator==
'default')
then
1031 time_integrator=
"ssprk4"
1033 select case (time_integrator)
1039 write(unitterm,*)
"time_integrator=",time_integrator,
"time_stepper=",time_stepper
1040 call mpistop(
"unkown fourstep time_integrator in read_par_files")
1042 if(t_integrator==ssprk4)
then
1043 select case(ssprk_order)
1045 rk_beta11=1.0d0/2.0d0
1046 rk_beta22=1.0d0/2.0d0
1047 rk_beta33=1.0d0/6.0d0
1048 rk_beta44=1.0d0/2.0d0
1050 rk_alfa31=2.0d0/3.0d0
1056 rk_beta11=1.0d0/3.0d0
1057 rk_beta22=1.0d0/3.0d0
1058 rk_beta33=1.0d0/3.0d0
1059 rk_beta44=1.0d0/4.0d0
1062 rk_alfa41=1.0d0/4.0d0
1067 call mpistop(
"Unknown ssprk_order")
1069 rk_alfa22=1.0d0-rk_alfa21
1070 rk_alfa33=1.0d0-rk_alfa31
1071 rk_alfa44=1.0d0-rk_alfa41
1076 if (time_integrator==
'default')
then
1077 time_integrator=
"ssprk5"
1079 select case (time_integrator)
1083 write(unitterm,*)
"time_integrator=",time_integrator,
"time_stepper=",time_stepper
1084 call mpistop(
"unkown fivestep time_integrator in read_par_files")
1086 if(t_integrator==ssprk5)
then
1087 select case(ssprk_order)
1090 rk_beta11=0.391752226571890d0
1091 rk_beta22=0.368410593050371d0
1092 rk_beta33=0.251891774271694d0
1093 rk_beta44=0.544974750228521d0
1094 rk_beta54=0.063692468666290d0
1095 rk_beta55=0.226007483236906d0
1096 rk_alfa21=0.444370493651235d0
1097 rk_alfa31=0.620101851488403d0
1098 rk_alfa41=0.178079954393132d0
1099 rk_alfa53=0.517231671970585d0
1100 rk_alfa54=0.096059710526147d0
1102 rk_alfa22=0.555629506348765d0
1103 rk_alfa33=0.379898148511597d0
1104 rk_alfa44=0.821920045606868d0
1105 rk_alfa55=0.386708617503269d0
1106 rk_alfa22=1.0d0-rk_alfa21
1107 rk_alfa33=1.0d0-rk_alfa31
1108 rk_alfa44=1.0d0-rk_alfa41
1109 rk_alfa55=1.0d0-rk_alfa53-rk_alfa54
1111 rk_c3=rk_alfa22*rk_c2+rk_beta22
1112 rk_c4=rk_alfa33*rk_c3+rk_beta33
1113 rk_c5=rk_alfa44*rk_c4+rk_beta44
1115 rk_beta11=0.39175222700392d0
1116 rk_beta22=0.36841059262959d0
1117 rk_beta33=0.25189177424738d0
1118 rk_beta44=0.54497475021237d0
1121 rk_alfa21=0.44437049406734d0
1122 rk_alfa31=0.62010185138540d0
1123 rk_alfa41=0.17807995410773d0
1124 rk_alfa53=0.51723167208978d0
1127 rk_alfa22=1.0d0-rk_alfa21
1128 rk_alfa33=1.0d0-rk_alfa31
1129 rk_alfa44=1.0d0-rk_alfa41
1131 rka51=0.00683325884039d0
1132 rka54=0.12759831133288d0
1133 rkb54=0.08460416338212d0
1134 rk_beta54=rkb54-rk_beta44*rka51/rk_alfa41
1135 rk_alfa54=rka54-rk_alfa44*rka51/rk_alfa41
1137 rk_alfa55=1.0d0-rk_alfa53-rk_alfa54
1139 rk_c3=rk_alfa22*rk_c2+rk_beta22
1140 rk_c4=rk_alfa33*rk_c3+rk_beta33
1141 rk_c5=rk_alfa44*rk_c4+rk_beta44
1142 rk_beta55=1.0d0-rk_beta54-rk_alfa53*rk_c3-rk_alfa54*rk_c4-rk_alfa55*rk_c5
1144 call mpistop(
"Unknown ssprk_order")
1153 use_imex_scheme=.false.
1155 call mpistop(
"Unknown time_stepper in read_par_files")
1159 select case (stretch_dim(i))
1160 case (undefined,
'none')
1161 stretch_type(i) = stretch_none
1162 stretched_dim(i) = .false.
1163 case (
'uni',
'uniform')
1164 stretch_type(i) = stretch_uni
1165 stretched_dim(i) = .true.
1166 case (
'symm',
'symmetric')
1167 stretch_type(i) = stretch_symm
1168 stretched_dim(i) = .true.
1170 stretch_type(i) = stretch_none
1171 stretched_dim(i) = .false.
1172 if (mype == 0) print *,
'Got stretch_type = ', stretch_type(i)
1173 call mpistop(
'Unknown stretch type')
1178 if(typedimsplit ==
'default'.and. dimsplit) typedimsplit=
'xyyx'
1179 if(typedimsplit ==
'default'.and..not.dimsplit) typedimsplit=
'unsplit'
1180 dimsplit = typedimsplit /=
'unsplit'
1183 select case (typesourcesplit)
1185 sourcesplit=sourcesplit_sfs
1187 sourcesplit=sourcesplit_sf
1189 sourcesplit=sourcesplit_ssf
1191 sourcesplit=sourcesplit_ssfss
1193 write(unitterm,*)
'No such typesourcesplit=',typesourcesplit
1194 call mpistop(
"Error: Unknown typesourcesplit!")
1197 if(coordinate==-1)
then
1198 coordinate=cartesian
1200 write(*,*)
'Warning: coordinate system is not specified!'
1201 write(*,*)
'call set_coordinate_system in usr_init in mod_usr.t'
1202 write(*,*)
'Now use Cartesian coordinate'
1206 if(coordinate==cartesian)
then
1209 if(any(stretched_dim))
then
1210 coordinate=cartesian_stretched
1211 slab_uniform=.false.
1215 slab_uniform=.false.
1218 if(coordinate==spherical)
then
1220 if(mype==0)print *,
'Warning: spherical symmetry needs dimsplit=F, resetting'
1225 if (ndim==1) dimsplit=.false.
1228 select case(typeprolonglimit)
1243 allocate(type_limiter(nlevelshi))
1244 allocate(type_gradient_limiter(nlevelshi))
1246 do level=1,nlevelshi
1247 type_limiter(level) = limiter_type(limiter(level))
1248 type_gradient_limiter(level) = limiter_type(gradient_limiter(level))
1251 if (any(limiter(1:nlevelshi)==
'ppm')&
1252 .and.(flatsh.and.physics_type==
'rho'))
then
1253 call mpistop(
" PPM with flatsh=.true. can not be used with physics_type='rho'!")
1259 select case(typeboundary_min^d(iw))
1261 typeboundary(iw,2*^d-1)=bc_special
1263 typeboundary(iw,2*^d-1)=bc_cont
1265 typeboundary(iw,2*^d-1)=bc_symm
1267 typeboundary(iw,2*^d-1)=bc_asymm
1269 typeboundary(iw,2*^d-1)=bc_periodic
1271 typeboundary(iw,2*^d-1)=bc_aperiodic
1273 typeboundary(iw,2*^d-1)=bc_noinflow
1275 typeboundary(iw,2*^d-1)=12
1277 typeboundary(iw,2*^d-1)=bc_data
1279 typeboundary(iw,2*^d-1)=bc_icarus
1281 typeboundary(iw,2*^d-1)=bc_character
1283 write (unitterm,*)
"Undefined boundarytype found in read_par_files", &
1284 typeboundary_min^d(iw),
"for variable iw=",iw,
" and side iB=",2*^d-1
1288 select case(typeboundary_max^d(iw))
1290 typeboundary(iw,2*^d)=bc_special
1292 typeboundary(iw,2*^d)=bc_cont
1294 typeboundary(iw,2*^d)=bc_symm
1296 typeboundary(iw,2*^d)=bc_asymm
1298 typeboundary(iw,2*^d)=bc_periodic
1300 typeboundary(iw,2*^d)=bc_aperiodic
1302 typeboundary(iw,2*^d)=bc_noinflow
1304 typeboundary(iw,2*^d)=12
1306 typeboundary(iw,2*^d)=bc_data
1308 typeboundary(iw,2*^d-1)=bc_icarus
1309 case(
"bc_character")
1310 typeboundary(iw,2*^d)=bc_character
1312 write (unitterm,*)
"Undefined boundarytype found in read_par_files", &
1313 typeboundary_max^d(iw),
"for variable iw=",iw,
" and side iB=",2*^d
1319 if (nwfluxbc<nwflux)
then
1320 do iw=nwfluxbc+1,nwflux
1321 typeboundary(iw,:) = typeboundary(1, :)
1326 do iw=nwflux+1, nwflux+nwaux
1327 typeboundary(iw,:) = typeboundary(1, :)
1331 if (any(typeboundary == 0))
then
1332 call mpistop(
"Not all boundary conditions have been defined")
1336 periodb(idim)=(any(typeboundary(:,2*idim-1:2*idim)==bc_periodic))
1337 aperiodb(idim)=(any(typeboundary(:,2*idim-1:2*idim)==bc_aperiodic))
1338 if (periodb(idim).or.aperiodb(idim))
then
1340 if (typeboundary(iw,2*idim-1) .ne. typeboundary(iw,2*idim)) &
1341 call mpistop(
"Wrong counterpart in periodic boundary")
1343 if (typeboundary(iw,2*idim-1) /= bc_periodic .and. &
1344 typeboundary(iw,2*idim-1) /= bc_aperiodic)
then
1345 call mpistop(
"Each dimension should either have all "//&
1346 "or no variables periodic, some can be aperiodic")
1353 if(any(typeboundary(:,2*idim-1)==12))
then
1354 if(any(typeboundary(:,2*idim-1)/=12)) typeboundary(:,2*idim-1)=12
1355 select case(physics_type)
1356 case (
'rho',
'ard',
'rd',
'nonlinear',
'ffhd')
1358 typeboundary(:,2*idim-1)=bc_symm
1359 if(mype==0) print *,
'symmetric minimal pole'
1360 case (
'hd',
'rhd',
'srhd',
'mhd',
'rmhd')
1361 typeboundary(:,2*idim-1)=bc_symm
1363 if(phys_energy)
then
1368 select case(coordinate)
1370 typeboundary(phi_+1,2*idim-1)=bc_asymm
1371 if(physics_type==
'mhd'.or.physics_type==
'rmhd') typeboundary(ndir+windex+phi_,2*idim-1)=bc_asymm
1373 typeboundary(3:ndir+1,2*idim-1)=bc_asymm
1374 if(physics_type==
'mhd'.or.physics_type==
'rmhd') typeboundary(ndir+windex+2:ndir+windex+ndir,2*idim-1)=bc_asymm
1376 call mpistop(
'Pole is in cylindrical, polar, spherical coordinates!')
1379 call mpistop(
'Pole treatment for twofl or mf not implemented yet')
1381 call mpistop(
'unknown physics type for setting minimal pole boundary treatment')
1384 if(any(typeboundary(:,2*idim)==12))
then
1385 if(any(typeboundary(:,2*idim)/=12)) typeboundary(:,2*idim)=12
1386 select case(physics_type)
1387 case (
'rho',
'ard',
'rd',
'nonlinear',
'ffhd')
1389 typeboundary(:,2*idim)=bc_symm
1390 if(mype==0) print *,
'symmetric maximal pole'
1391 case (
'hd',
'rhd',
'srhd',
'mhd',
'rmhd')
1392 typeboundary(:,2*idim)=bc_symm
1394 if(phys_energy)
then
1399 select case(coordinate)
1401 typeboundary(phi_+1,2*idim)=bc_asymm
1402 if(physics_type==
'mhd'.or.physics_type==
'rmhd') typeboundary(ndir+windex+phi_,2*idim)=bc_asymm
1404 typeboundary(3:ndir+1,2*idim)=bc_asymm
1405 if(physics_type==
'mhd'.or.physics_type==
'rmhd') typeboundary(ndir+windex+2:ndir+windex+ndir,2*idim)=bc_asymm
1407 call mpistop(
'Pole is in cylindrical, polar, spherical coordinates!')
1410 call mpistop(
'Pole treatment for twofl or mf not implemented yet')
1412 call mpistop(
'unknown physics type for setting maximal pole boundary treatment')
1418 if(.not.phys_energy)
then
1423 if(any(limiter(1:nlevelshi)==
'mp5'))
then
1424 nghostcells=max(nghostcells,3)
1427 if(any(limiter(1:nlevelshi)==
'weno5'))
then
1428 nghostcells=max(nghostcells,3)
1431 if(any(limiter(1:nlevelshi)==
'weno5nm'))
then
1432 nghostcells=max(nghostcells,3)
1435 if(any(limiter(1:nlevelshi)==
'wenoz5'))
then
1436 nghostcells=max(nghostcells,3)
1439 if(any(limiter(1:nlevelshi)==
'wenoz5nm'))
then
1440 nghostcells=max(nghostcells,3)
1443 if(any(limiter(1:nlevelshi)==
'wenozp5'))
then
1444 nghostcells=max(nghostcells,3)
1447 if(any(limiter(1:nlevelshi)==
'wenozp5nm'))
then
1448 nghostcells=max(nghostcells,3)
1451 if(any(limiter(1:nlevelshi)==
'teno5ad'))
then
1452 nghostcells=max(nghostcells,3)
1455 if(any(limiter(1:nlevelshi)==
'weno5cu6'))
then
1456 nghostcells=max(nghostcells,3)
1459 if(any(limiter(1:nlevelshi)==
'ppm'))
then
1460 if(flatsh .or. flatcd)
then
1461 nghostcells=max(nghostcells,4)
1463 nghostcells=max(nghostcells,3)
1467 if(any(limiter(1:nlevelshi)==
'weno7'))
then
1468 nghostcells=max(nghostcells,4)
1471 if(any(limiter(1:nlevelshi)==
'mpweno7'))
then
1472 nghostcells=max(nghostcells,4)
1476 nghostcells = nghostcells + phys_wider_stencil
1479 if(stagger_grid .and. refine_max_level>1 .and. mod(nghostcells,2)/=0)
then
1480 nghostcells=nghostcells+1
1483 select case (coordinate)
1486 xprob^lim^de=xprob^lim^de*two*dpi;
1491 xprob^lim^d=xprob^lim^d*two*dpi;
1497 {ixghi^d = block_nx^d + 2*nghostcells\}
1498 {ixgshi^d = ixghi^d\}
1500 nx_vec = [{domain_nx^d|, }]
1501 block_nx_vec = [{block_nx^d|, }]
1503 if (any(nx_vec < 4) .or. any(mod(nx_vec, 2) == 1)) &
1504 call mpistop(
'Grid size (domain_nx^D) has to be even and >= 4')
1506 if (any(block_nx_vec < 4) .or. any(mod(block_nx_vec, 2) == 1)) &
1507 call mpistop(
'Block size (block_nx^D) has to be even and >= 4')
1509 {
if(mod(domain_nx^d,block_nx^d)/=0) &
1510 call mpistop(
'Grid (domain_nx^D) and block (block_nx^D) must be consistent') \}
1512 if(refine_max_level>nlevelshi.or.refine_max_level<1)
then
1513 write(unitterm,*)
'Error: refine_max_level',refine_max_level,
'>nlevelshi ',nlevelshi
1514 call mpistop(
"Reset nlevelshi and recompile!")
1517 if (any(stretched_dim))
then
1518 allocate(qstretch(0:nlevelshi,1:ndim),dxfirst(0:nlevelshi,1:ndim),&
1519 dxfirst_1mq(0:nlevelshi,1:ndim),dxmid(0:nlevelshi,1:ndim))
1520 allocate(nstretchedblocks(1:nlevelshi,1:ndim))
1521 qstretch(0:nlevelshi,1:ndim)=0.0d0
1522 dxfirst(0:nlevelshi,1:ndim)=0.0d0
1523 nstretchedblocks(1:nlevelshi,1:ndim)=0
1524 {
if (stretch_type(^d) == stretch_uni)
then
1526 if(qstretch_baselevel(^d)<1.0d0.or.qstretch_baselevel(^d)==bigdouble)
then
1528 write(*,*)
'stretched grid needs finite qstretch_baselevel>1'
1529 write(*,*)
'will try default value for qstretch_baselevel in dimension', ^d
1531 if(xprobmin^d>smalldouble)
then
1532 qstretch_baselevel(^d)=(xprobmax^d/xprobmin^d)**(1.d0/dble(domain_nx^d))
1534 call mpistop(
"can not set qstretch_baselevel automatically")
1537 if(mod(block_nx^d,2)==1) &
1538 call mpistop(
"stretched grid needs even block size block_nxD")
1539 if(mod(domain_nx^d/block_nx^d,2)/=0) &
1540 call mpistop(
"number level 1 blocks in D must be even")
1541 qstretch(1,^d)=qstretch_baselevel(^d)
1542 dxfirst(1,^d)=(xprobmax^d-xprobmin^d) &
1543 *(1.0d0-qstretch(1,^d))/(1.0d0-qstretch(1,^d)**domain_nx^d)
1544 qstretch(0,^d)=qstretch(1,^d)**2
1545 dxfirst(0,^d)=dxfirst(1,^d)*(1.0d0+qstretch(1,^d))
1546 if(refine_max_level>1)
then
1547 do ilev=2,refine_max_level
1548 qstretch(ilev,^d)=dsqrt(qstretch(ilev-1,^d))
1549 dxfirst(ilev,^d)=dxfirst(ilev-1,^d) &
1550 /(1.0d0+dsqrt(qstretch(ilev-1,^d)))
1555 {
if(stretch_type(^d) == stretch_uni)
then
1556 write(*,*)
'Stretched dimension ', ^d
1557 write(*,*)
'Using stretched grid with qs=',qstretch(0:refine_max_level,^d)
1558 write(*,*)
' and first cell sizes=',dxfirst(0:refine_max_level,^d)
1561 {
if(stretch_type(^d) == stretch_symm)
then
1563 write(*,*)
'will apply symmetric stretch in dimension', ^d
1565 if(mod(block_nx^d,2)==1) &
1566 call mpistop(
"stretched grid needs even block size block_nxD")
1568 if(nstretchedblocks_baselevel(^d)==0) &
1569 call mpistop(
"need finite even number of stretched blocks at baselevel")
1570 if(mod(nstretchedblocks_baselevel(^d),2)==1) &
1571 call mpistop(
"need even number of stretched blocks at baselevel")
1572 if(qstretch_baselevel(^d)<1.0d0.or.qstretch_baselevel(^d)==bigdouble) &
1573 call mpistop(
'stretched grid needs finite qstretch_baselevel>1')
1575 ipower=(nstretchedblocks_baselevel(^d)/2)*block_nx^d
1576 if(nstretchedblocks_baselevel(^d)==domain_nx^d/block_nx^d)
then
1577 xstretch^d=0.5d0*(xprobmax^d-xprobmin^d)
1579 xstretch^d=(xprobmax^d-xprobmin^d) &
1580 /(2.0d0+dble(domain_nx^d-nstretchedblocks_baselevel(^d)*block_nx^d) &
1581 *(1.0d0-qstretch_baselevel(^d))/(1.0d0-qstretch_baselevel(^d)**ipower))
1583 if(xstretch^d>(xprobmax^d-xprobmin^d)*0.5d0) &
1584 call mpistop(
" stretched grid part should not exceed full domain")
1585 dxfirst(1,^d)=xstretch^d*(1.0d0-qstretch_baselevel(^d)) &
1586 /(1.0d0-qstretch_baselevel(^d)**ipower)
1587 nstretchedblocks(1,^d)=nstretchedblocks_baselevel(^d)
1588 qstretch(1,^d)=qstretch_baselevel(^d)
1589 qstretch(0,^d)=qstretch(1,^d)**2
1590 dxfirst(0,^d)=dxfirst(1,^d)*(1.0d0+qstretch(1,^d))
1591 dxmid(1,^d)=dxfirst(1,^d)
1592 dxmid(0,^d)=dxfirst(1,^d)*2.0d0
1593 if(refine_max_level>1)
then
1594 do ilev=2,refine_max_level
1595 nstretchedblocks(ilev,^d)=2*nstretchedblocks(ilev-1,^d)
1596 qstretch(ilev,^d)=dsqrt(qstretch(ilev-1,^d))
1597 dxfirst(ilev,^d)=dxfirst(ilev-1,^d) &
1598 /(1.0d0+dsqrt(qstretch(ilev-1,^d)))
1599 dxmid(ilev,^d)=dxmid(ilev-1,^d)/2.0d0
1603 sizeuniformpart^d=dxfirst(1,^d) &
1604 *(domain_nx^d-nstretchedblocks_baselevel(^d)*block_nx^d)
1606 print *,
'uniform part of size=',sizeuniformpart^d
1607 print *,
'setting of domain is then=',2*xstretch^d+sizeuniformpart^d
1608 print *,
'versus=',xprobmax^d-xprobmin^d
1610 if(dabs(xprobmax^d-xprobmin^d-2*xstretch^d-sizeuniformpart^d)>smalldouble)
then
1611 call mpistop(
'mismatch in domain size!')
1614 dxfirst_1mq(0:refine_max_level,1:ndim)=dxfirst(0:refine_max_level,1:ndim) &
1615 /(1.0d0-qstretch(0:refine_max_level,1:ndim))
1618 dx_vec = [{xprobmax^d-xprobmin^d|, }] / nx_vec
1621 write(c_ndim,
'(I1)') ^nd
1622 write(unitterm,
'(A30,' // c_ndim //
'(I0," "))') &
1623 ' Domain size (cells): ', nx_vec
1624 write(unitterm,
'(A30,' // c_ndim //
'(E9.3," "))') &
1625 ' Level one dx: ', dx_vec
1628 if (any(dx_vec < smalldouble)) &
1629 call mpistop(
"Incorrect domain size (too small grid spacing)")
1633 if(sum(w_refine_weight(:))==0) w_refine_weight(1) = 1.d0
1634 if(dabs(sum(w_refine_weight(:))-1.d0)>smalldouble)
then
1635 write(unitterm,*)
"Sum of all elements in w_refine_weight be 1.d0"
1636 call mpistop(
"Reset w_refine_weight so the sum is 1.d0")
1639 select case (typeboundspeed)
1644 case(
'cmaxleftright')
1647 call mpistop(
"set typeboundspeed='Einfeldt' or 'cmaxmean' or 'cmaxleftright'")
1650 if (mype==0)
write(unitterm,
'(A30)', advance=
'no')
'Refine estimation: '
1652 select case (refine_criterion)
1654 if (mype==0)
write(unitterm,
'(A)')
"user defined"
1656 if (mype==0)
write(unitterm,
'(A)')
"relative error"
1658 if (mype==0)
write(unitterm,
'(A)')
"Lohner's original scheme"
1660 if (mype==0)
write(unitterm,
'(A)')
"Lohner's scheme"
1662 call mpistop(
"Unknown error estimator, change refine_criterion")
1665 if (tfixgrid<bigdouble/2.0d0)
then
1666 if(mype==0)print*,
'Warning, at time=',tfixgrid,
'the grid will be fixed'
1668 if (itfixgrid<biginteger/2)
then
1669 if(mype==0)print*,
'Warning, at iteration=',itfixgrid,
'the grid will be fixed'
1671 if (ditregrid>1)
then
1672 if(mype==0)print*,
'Note, Grid is reconstructed once every',ditregrid,
'iterations'
1677 select case(slicedir(islice))
1679 if(slicecoord(islice)<xprobmin^d.or.slicecoord(islice)>xprobmax^d) &
1680 write(uniterr,*)
'Warning in read_par_files: ', &
1681 'Slice ', islice,
' coordinate',slicecoord(islice),
'out of bounds for dimension ',slicedir(islice)
1687 write(unitterm,
'(A30,A,A)')
'restart_from_file: ',
' ', trim(restart_from_file)
1688 write(unitterm,
'(A30,L1)')
'converting: ', convert
1689 write(unitterm,
'(A)')
''
1692 deallocate(flux_scheme)
1844 integer,
intent(in) :: fh
1845 integer(MPI_OFFSET_KIND),
intent(out) :: offset_tree
1846 integer(MPI_OFFSET_KIND),
intent(out) :: offset_block
1848 double precision :: rbuf(ndim)
1849 double precision,
allocatable :: params(:)
1850 integer :: i, version
1851 integer :: ibuf(ndim), iw
1852 integer :: er, n_par, tmp_int
1853 integer,
dimension(MPI_STATUS_SIZE) :: st
1854 logical :: periodic(ndim)
1855 character(len=name_len),
allocatable :: var_names(:), param_names(:)
1856 character(len=name_len) :: phys_name, geom_name
1859 call mpi_file_read(fh, version, 1, mpi_integer, st, er)
1861 call mpistop(
"Incompatible file version (maybe old format?)")
1865 call mpi_file_read(fh, ibuf(1), 1, mpi_integer, st, er)
1866 offset_tree = ibuf(1)
1869 call mpi_file_read(fh, ibuf(1), 1, mpi_integer, st, er)
1870 offset_block = ibuf(1)
1873 call mpi_file_read(fh, ibuf(1), 1, mpi_integer, st, er)
1875 if (nw /= ibuf(1))
then
1876 write(*,*)
"nw=",nw,
" and nw found in restart file=",ibuf(1)
1877 write(*,*)
"Please be aware of changes in w at restart."
1882 call mpi_file_read(fh, ibuf(1), 1, mpi_integer, st, er)
1883 if (ibuf(1) /=
ndir)
then
1884 write(*,*)
"ndir in restart file = ",ibuf(1)
1885 write(*,*)
"ndir = ",
ndir
1886 call mpistop(
"reset ndir to ndir in restart file")
1890 call mpi_file_read(fh, ibuf(1), 1, mpi_integer, st, er)
1891 if (ibuf(1) /= ndim)
then
1892 write(*,*)
"ndim in restart file = ",ibuf(1)
1893 write(*,*)
"ndim = ",ndim
1894 call mpistop(
"reset ndim to ndim in restart file")
1898 call mpi_file_read(fh, ibuf(1), 1, mpi_integer, st, er)
1900 write(*,*)
"number of levels in restart file = ",ibuf(1)
1902 call mpistop(
"refine_max_level < num. levels in restart file")
1906 call mpi_file_read(fh,
nleafs, 1, mpi_integer, st, er)
1909 call mpi_file_read(fh,
nparents, 1, mpi_integer, st, er)
1912 call mpi_file_read(fh,
it, 1, mpi_integer, st, er)
1915 call mpi_file_read(fh,
global_time, 1, mpi_double_precision, st, er)
1918 call mpi_file_read(fh,rbuf(1:ndim),ndim,mpi_double_precision,st,er)
1919 if (maxval(abs(rbuf(1:ndim) - [ xprobmin^
d ])) > 0)
then
1920 write(*,*)
"Error: xprobmin differs from restart data: ", rbuf(1:ndim)
1921 call mpistop(
"change xprobmin^D in par file")
1925 call mpi_file_read(fh,rbuf(1:ndim),ndim,mpi_double_precision,st,er)
1926 if (maxval(abs(rbuf(1:ndim) - [ xprobmax^
d ])) > 0)
then
1927 write(*,*)
"Error: xprobmax differs from restart data: ", rbuf(1:ndim)
1928 call mpistop(
"change xprobmax^D in par file")
1932 call mpi_file_read(fh,ibuf(1:ndim), ndim, mpi_integer,st,er)
1933 if (any(ibuf(1:ndim) /= [
domain_nx^
d ]))
then
1934 write(*,*)
"Error: mesh size differs from restart data: ", ibuf(1:ndim)
1935 call mpistop(
"change domain_nx^D in par file")
1939 call mpi_file_read(fh,ibuf(1:ndim), ndim, mpi_integer,st,er)
1940 if (any(ibuf(1:ndim) /= [
block_nx^
d ]))
then
1941 write(*,*)
"Error: block size differs from restart data:", ibuf(1:ndim)
1942 call mpistop(
"change block_nx^D in par file")
1946 if (version > 4)
then
1947 call mpi_file_read(fh, periodic, ndim, mpi_logical, st, er)
1948 if ({periodic(^
d) .and. .not.
periodb(^
d) .or. .not.periodic(^
d) .and.
periodb(^
d)| .or. }) &
1949 call mpistop(
"change in periodicity in par file")
1951 call mpi_file_read(fh, geom_name, name_len, mpi_character, st, er)
1954 write(*,*)
"type of coordinates in data is: ", geom_name
1955 call mpistop(
"select the correct coordinates in mod_usr.t file")
1958 call mpi_file_read(fh, stagger_mark_dat, 1, mpi_logical, st, er)
1960 write(*,*)
"Warning: stagger grid flag differs from restart data:", stagger_mark_dat
1966 if (version > 3)
then
1970 call mpi_file_read(fh, var_names(iw), name_len, mpi_character, st, er)
1974 call mpi_file_read(fh, phys_name, name_len, mpi_character, st, er)
1980 call mpi_file_read(fh, n_par, 1, mpi_integer, st, er)
1981 allocate(params(n_par))
1982 allocate(param_names(n_par))
1983 call mpi_file_read(fh, params, n_par, mpi_double_precision, st, er)
1984 call mpi_file_read(fh, param_names, name_len * n_par, mpi_character, st, er)
1987 call mpi_file_read(fh, tmp_int, 1, mpi_integer, st, er)
1992 call mpi_file_read(fh, tmp_int, 1, mpi_integer, st, er)
1995 call mpi_file_read(fh, tmp_int, 1, mpi_integer, st, er)