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, &
320 allocate(typeboundary_min^d(nwfluxbc))
321 allocate(typeboundary_max^d(nwfluxbc))
384 typeprolonglimit =
'default'
422 tsave(isave,ifile) = bigdouble
423 itsave(isave,ifile) = biginteger
432 tsave_log = bigdouble
433 tsave_dat = bigdouble
434 tsave_slice = bigdouble
435 tsave_collapsed = bigdouble
436 tsave_custom = bigdouble
438 dtsave_log = bigdouble
439 dtsave_dat = bigdouble
440 dtsave_slice = bigdouble
441 dtsave_collapsed = bigdouble
442 dtsave_custom = bigdouble
444 ditsave_log = biginteger
445 ditsave_dat = biginteger
446 ditsave_slice = biginteger
447 ditsave_collapsed = biginteger
448 ditsave_custom = biginteger
450 tsavestart_log = bigdouble
451 tsavestart_dat = bigdouble
452 tsavestart_slice = bigdouble
453 tsavestart_collapsed = bigdouble
454 tsavestart_custom = bigdouble
478 typecourant =
'maxsum'
487 typeboundspeed =
'Einfeldt'
489 time_stepper =
'twostep'
490 time_integrator =
'default'
522 flux_scheme(level) =
'tvdlf'
524 limiter(level) =
'minmod'
525 gradient_limiter(level) =
'minmod'
530 typesourcesplit =
'sfs'
557 if(i==j.or.j==k.or.k==i)
then
559 else if(i+1==j.or.i-2==j)
then
576 inquire(file=trim(
par_files(i)), exist=file_exists)
578 if (.not. file_exists)
then
579 write(err_msg, *)
"The parameter file " // trim(
par_files(i)) // &
589 read(
unitpar, filelist,
end=101)
592 read(unitpar, savelist,
end=102)
595 read(unitpar, stoplist,
end=103)
598 read(unitpar, methodlist,
end=104)
601 read(unitpar, boundlist,
end=105)
604 read(unitpar, meshlist,
end=106)
607 read(unitpar, paramlist,
end=107)
610 read(unitpar, emissionlist,
end=108)
615 if (base_filename /= basename_prev) &
616 basename_full = trim(basename_full) // trim(base_filename)
617 basename_prev = base_filename
620 base_filename = basename_full
624 dummy_file = trim(base_filename)//
"DUMMY"
625 open(newunit=my_unit, file=trim(dummy_file), iostat=iostate)
626 if (iostate /= 0)
then
627 call mpistop(
"Can't write to output directory (" // &
628 trim(base_filename) //
")")
630 close(my_unit, status=
'delete')
634 if(source_split_usr) any_source_split=.true.
637 if(restart_from_file_arg /= undefined) &
638 restart_from_file=restart_from_file_arg
642 if(restart_from_file == undefined)
then
645 do index_latest_data = 9999, 0, -1
651 if(.not.file_exists) index_latest_data=-1
657 call mpi_bcast(index_latest_data, 1, mpi_integer, 0, icomm, ierrmpi)
659 if (resume_previous_run)
then
660 if (index_latest_data == -1)
then
661 if(mype==0)
write(*,*)
"No snapshots found to resume from, start a new run..."
664 write(restart_from_file,
"(a,i4.4,a)") trim(base_filename),index_latest_data,
".dat"
668 if (restart_from_file == undefined)
then
673 call mpistop(
"Please restart from a snapshot when firstprocess=T")
675 call mpistop(
'Change convert to .false. for a new run!')
678 if (small_pressure < 0.d0)
call mpistop(
"small_pressure should be positive.")
679 if (small_density < 0.d0)
call mpistop(
"small_density should be positive.")
681 if (small_temperature>0.d0) small_pressure=small_density*small_temperature
683 if(convert) autoconvert=.false.
685 where (tsave_log < bigdouble) tsave(:, 1) = tsave_log
686 where (tsave_dat < bigdouble) tsave(:, 2) = tsave_dat
687 where (tsave_slice < bigdouble) tsave(:, 3) = tsave_slice
688 where (tsave_collapsed < bigdouble) tsave(:, 4) = tsave_collapsed
689 where (tsave_custom < bigdouble) tsave(:, 5) = tsave_custom
691 if (dtsave_log < bigdouble) dtsave(1) = dtsave_log
692 if (dtsave_dat < bigdouble) dtsave(2) = dtsave_dat
693 if (dtsave_slice < bigdouble) dtsave(3) = dtsave_slice
694 if (dtsave_collapsed < bigdouble) dtsave(4) = dtsave_collapsed
695 if (dtsave_custom < bigdouble) dtsave(5) = dtsave_custom
697 if (tsavestart_log < bigdouble) tsavestart(1) = tsavestart_log
698 if (tsavestart_dat < bigdouble) tsavestart(2) = tsavestart_dat
699 if (tsavestart_slice < bigdouble) tsavestart(3) = tsavestart_slice
700 if (tsavestart_collapsed < bigdouble) tsavestart(4) = tsavestart_collapsed
701 if (tsavestart_custom < bigdouble) tsavestart(5) = tsavestart_custom
703 if (ditsave_log < bigdouble) ditsave(1) = ditsave_log
704 if (ditsave_dat < bigdouble) ditsave(2) = ditsave_dat
705 if (ditsave_slice < bigdouble) ditsave(3) = ditsave_slice
706 if (ditsave_collapsed < bigdouble) ditsave(4) = ditsave_collapsed
707 if (ditsave_custom < bigdouble) ditsave(5) = ditsave_custom
709 if (wall_time_max < bigdouble) wall_time_max=wall_time_max*3600.d0
712 write(unitterm, *)
''
713 write(unitterm, *)
'Output type | tsavestart | dtsave | ditsave | itsave(1) | tsave(1)'
714 write(fmt_string, *)
'(A12," | ",E9.3E2," | ",E9.3E2," | ",I6," | "'//&
719 if (mype == 0)
write(unitterm, fmt_string) trim(output_names(ifile)), &
720 tsavestart(ifile), dtsave(ifile), ditsave(ifile), itsave(1, ifile), tsave(1, ifile)
723 if (mype == 0)
write(unitterm, *)
''
726 if(slicedir(islice) > ndim) &
727 write(uniterr,*)
'Warning in read_par_files: ', &
728 'Slice ', islice,
' direction',slicedir(islice),
'larger than ndim=',ndim
729 if(slicedir(islice) < 1) &
730 write(uniterr,*)
'Warning in read_par_files: ', &
731 'Slice ', islice,
' direction',slicedir(islice),
'too small, should be [',1,ndim,
']'
734 if(it_max==biginteger .and. time_max==bigdouble.and.mype==0)
write(uniterr,*) &
735 'Warning in read_par_files: it_max or time_max not given!'
737 select case (typecourant)
739 type_courant=type_maxsum
741 type_courant=type_summax
742 if (local_timestep)
then
743 call mpistop(
"Type courant summax incompatible with local_timestep")
746 type_courant=type_minimum
747 if (local_timestep)
then
748 call mpistop(
"Type courant minimum incompatible with local_timestep")
751 write(unitterm,*)
'Unknown typecourant=',typecourant
752 call mpistop(
"Error from read_par_files: no such typecourant!")
757 select case (flux_scheme(level))
759 flux_method(level)=fs_hll
761 flux_method(level)=fs_hllc
763 flux_method(level)=fs_hlld
765 flux_method(level)=fs_hllcd
767 flux_method(level)=fs_tvdlf
769 flux_method(level)=fs_tvdmu
771 flux_method(level)=fs_tvd
773 flux_method(level)=fs_cd
775 flux_method(level)=fs_cd4
777 flux_method(level)=fs_fd
779 flux_method(level)=fs_source
781 flux_method(level)=fs_nul
783 call mpistop(
"unkown or bad flux scheme")
785 if(flux_scheme(level)==
'tvd'.and.time_stepper/=
'onestep') &
786 call mpistop(
" tvd is onestep method, reset time_stepper='onestep'")
787 if(flux_scheme(level)==
'tvd')
then
788 if(mype==0.and.(.not.dimsplit))
write(unitterm,*) &
789 'Warning: setting dimsplit=T for tvd, as used for level=',level
792 if(flux_scheme(level)==
'hlld'.and.physics_type/=
'mhd' .and. physics_type/=
'twofl') &
793 call mpistop(
"Cannot use hlld flux if not using MHD or 2FL only charges physics!")
795 if(flux_scheme(level)==
'hllc'.and.physics_type==
'mf') &
796 call mpistop(
"Cannot use hllc flux if using magnetofriction physics!")
798 if(flux_scheme(level)==
'tvd'.and.physics_type==
'mf') &
799 call mpistop(
"Cannot use tvd flux if using magnetofriction physics!")
801 if(flux_scheme(level)==
'tvdmu'.and.physics_type==
'mf') &
802 call mpistop(
"Cannot use tvdmu flux if using magnetofriction physics!")
804 if (typepred1(level)==0)
then
805 select case (flux_scheme(level))
807 typepred1(level)=fs_cd
809 typepred1(level)=fs_cd4
811 typepred1(level)=fs_fd
812 case (
'tvdlf',
'tvdmu')
813 typepred1(level)=fs_hancock
815 typepred1(level)=fs_hll
817 typepred1(level)=fs_hllc
819 typepred1(level)=fs_hllcd
821 typepred1(level)=fs_hlld
822 case (
'nul',
'source',
'tvd')
823 typepred1(level)=fs_nul
825 call mpistop(
"No default predictor for this full step")
831 if(any(flux_scheme==
'fd')) need_global_cmax=.true.
834 select case (typecurl)
840 type_curl=stokesbased
842 write(unitterm,*)
"typecurl=",typecurl
843 call mpistop(
"unkown type of curl operator in read_par_files")
847 select case (time_stepper)
851 if (time_integrator==
'default')
then
852 time_integrator=
"Forward_Euler"
854 select case (time_integrator)
855 case (
"Forward_Euler")
856 t_integrator=forward_euler
858 t_integrator=imex_euler
862 write(unitterm,*)
"time_integrator=",time_integrator,
"time_stepper=",time_stepper
863 call mpistop(
"unkown onestep time_integrator in read_par_files")
865 use_imex_scheme=(t_integrator==imex_euler.or.t_integrator==imex_sp)
869 if (time_integrator==
'default')
then
870 time_integrator=
"Predictor_Corrector"
872 select case (time_integrator)
873 case (
"Predictor_Corrector")
874 t_integrator=predictor_corrector
879 case (
"IMEX_Midpoint")
880 t_integrator=imex_midpoint
881 case (
"IMEX_Trapezoidal")
882 t_integrator=imex_trapezoidal
884 t_integrator=imex_222
886 write(unitterm,*)
"time_integrator=",time_integrator,
"time_stepper=",time_stepper
887 call mpistop(
"unkown twostep time_integrator in read_par_files")
889 use_imex_scheme=(t_integrator==imex_midpoint.or.t_integrator==imex_trapezoidal&
890 .or.t_integrator==imex_222)
891 if (t_integrator==rk2_alf)
then
892 if(rk2_alfa<smalldouble.or.rk2_alfa>one)
call mpistop(
"set rk2_alfa within [0,1]")
894 rk_b2=1.0d0/(2.0d0*rk2_alfa)
900 if (time_integrator==
'default')
then
901 time_integrator=
'ssprk3'
903 select case (time_integrator)
909 t_integrator=imex_ars3
911 t_integrator=imex_232
913 t_integrator=imex_cb3a
915 write(unitterm,*)
"time_integrator=",time_integrator,
"time_stepper=",time_stepper
916 call mpistop(
"unkown threestep time_integrator in read_par_files")
918 if(t_integrator==rk3_bt)
then
919 select case(rk3_switch)
949 call mpistop(
"Unknown rk3_switch")
952 rk3_b3=1.0d0-rk3_b1-rk3_b2
954 rk3_c3=rk3_a31+rk3_a32
956 if(t_integrator==ssprk3)
then
957 select case(ssprk_order)
960 rk_beta22=1.0d0/4.0d0
961 rk_beta33=2.0d0/3.0d0
962 rk_alfa21=3.0d0/4.0d0
963 rk_alfa31=1.0d0/3.0d0
967 rk_beta11=1.0d0/2.0d0
968 rk_beta22=1.0d0/2.0d0
969 rk_beta33=1.0d0/3.0d0
971 rk_alfa31=1.0d0/3.0d0
975 call mpistop(
"Unknown ssprk3_order")
977 rk_alfa22=1.0d0-rk_alfa21
978 rk_alfa33=1.0d0-rk_alfa31
980 if(t_integrator==imex_ars3)
then
981 ars_gamma=(3.0d0+dsqrt(3.0d0))/6.0d0
983 if(t_integrator==imex_232)
then
984 select case(imex_switch)
986 im_delta=1.0d0-1.0d0/dsqrt(2.0d0)
987 im_nu=(3.0d0+2.0d0*dsqrt(2.0d0))/6.0d0
988 imex_a21=2.0d0*im_delta
991 imex_b1=1.0d0/(2.0d0*dsqrt(2.0d0))
992 imex_b2=1.0d0/(2.0d0*dsqrt(2.0d0))
997 imex_a21=0.711664700366941d0
998 imex_a31=0.077338168947683d0
999 imex_a32=0.917273367886007d0
1000 imex_b1=0.398930808264688d0
1001 imex_b2=0.345755244189623d0
1002 imex_ha21=0.353842865099275d0
1003 imex_ha22=0.353842865099275d0
1005 call mpistop(
"Unknown imex_siwtch")
1008 imex_c3=imex_a31+imex_a32
1009 imex_b3=1.0d0-imex_b1-imex_b2
1011 if(t_integrator==imex_cb3a)
then
1012 imex_c2 = 0.8925502329346865
1015 imex_c3 = imex_c2 / (6.0d0*imex_c2**2 - 3.0d0*imex_c2 + 1.0d0)
1017 imex_b2 = (3.0d0*imex_c2 - 1.0d0) / (6.0d0*imex_c2**2)
1018 imex_b3 = (6.0d0*imex_c2**2 - 3.0d0*imex_c2 + 1.0d0) / (6.0d0*imex_c2**2)
1019 imex_a33 = (1.0d0/6.0d0 - imex_b2*imex_c2**2 - imex_b3*imex_c2*imex_c3) / (imex_b3*(imex_c3-imex_c2))
1020 imex_a32 = imex_c3 - imex_a33
1034 use_imex_scheme=(t_integrator==imex_ars3.or.t_integrator==imex_232.or.t_integrator==imex_cb3a)
1038 if (time_integrator==
'default')
then
1039 time_integrator=
"ssprk4"
1041 select case (time_integrator)
1047 write(unitterm,*)
"time_integrator=",time_integrator,
"time_stepper=",time_stepper
1048 call mpistop(
"unkown fourstep time_integrator in read_par_files")
1050 if(t_integrator==ssprk4)
then
1051 select case(ssprk_order)
1053 rk_beta11=1.0d0/2.0d0
1054 rk_beta22=1.0d0/2.0d0
1055 rk_beta33=1.0d0/6.0d0
1056 rk_beta44=1.0d0/2.0d0
1058 rk_alfa31=2.0d0/3.0d0
1064 rk_beta11=1.0d0/3.0d0
1065 rk_beta22=1.0d0/3.0d0
1066 rk_beta33=1.0d0/3.0d0
1067 rk_beta44=1.0d0/4.0d0
1070 rk_alfa41=1.0d0/4.0d0
1075 call mpistop(
"Unknown ssprk_order")
1077 rk_alfa22=1.0d0-rk_alfa21
1078 rk_alfa33=1.0d0-rk_alfa31
1079 rk_alfa44=1.0d0-rk_alfa41
1084 if (time_integrator==
'default')
then
1085 time_integrator=
"ssprk5"
1087 select case (time_integrator)
1091 write(unitterm,*)
"time_integrator=",time_integrator,
"time_stepper=",time_stepper
1092 call mpistop(
"unkown fivestep time_integrator in read_par_files")
1094 if(t_integrator==ssprk5)
then
1095 select case(ssprk_order)
1098 rk_beta11=0.391752226571890d0
1099 rk_beta22=0.368410593050371d0
1100 rk_beta33=0.251891774271694d0
1101 rk_beta44=0.544974750228521d0
1102 rk_beta54=0.063692468666290d0
1103 rk_beta55=0.226007483236906d0
1104 rk_alfa21=0.444370493651235d0
1105 rk_alfa31=0.620101851488403d0
1106 rk_alfa41=0.178079954393132d0
1107 rk_alfa53=0.517231671970585d0
1108 rk_alfa54=0.096059710526147d0
1110 rk_alfa22=0.555629506348765d0
1111 rk_alfa33=0.379898148511597d0
1112 rk_alfa44=0.821920045606868d0
1113 rk_alfa55=0.386708617503269d0
1114 rk_alfa22=1.0d0-rk_alfa21
1115 rk_alfa33=1.0d0-rk_alfa31
1116 rk_alfa44=1.0d0-rk_alfa41
1117 rk_alfa55=1.0d0-rk_alfa53-rk_alfa54
1119 rk_c3=rk_alfa22*rk_c2+rk_beta22
1120 rk_c4=rk_alfa33*rk_c3+rk_beta33
1121 rk_c5=rk_alfa44*rk_c4+rk_beta44
1123 rk_beta11=0.39175222700392d0
1124 rk_beta22=0.36841059262959d0
1125 rk_beta33=0.25189177424738d0
1126 rk_beta44=0.54497475021237d0
1129 rk_alfa21=0.44437049406734d0
1130 rk_alfa31=0.62010185138540d0
1131 rk_alfa41=0.17807995410773d0
1132 rk_alfa53=0.51723167208978d0
1135 rk_alfa22=1.0d0-rk_alfa21
1136 rk_alfa33=1.0d0-rk_alfa31
1137 rk_alfa44=1.0d0-rk_alfa41
1139 rka51=0.00683325884039d0
1140 rka54=0.12759831133288d0
1141 rkb54=0.08460416338212d0
1142 rk_beta54=rkb54-rk_beta44*rka51/rk_alfa41
1143 rk_alfa54=rka54-rk_alfa44*rka51/rk_alfa41
1145 rk_alfa55=1.0d0-rk_alfa53-rk_alfa54
1147 rk_c3=rk_alfa22*rk_c2+rk_beta22
1148 rk_c4=rk_alfa33*rk_c3+rk_beta33
1149 rk_c5=rk_alfa44*rk_c4+rk_beta44
1150 rk_beta55=1.0d0-rk_beta54-rk_alfa53*rk_c3-rk_alfa54*rk_c4-rk_alfa55*rk_c5
1152 call mpistop(
"Unknown ssprk_order")
1161 use_imex_scheme=.false.
1163 call mpistop(
"Unknown time_stepper in read_par_files")
1167 select case (stretch_dim(i))
1168 case (undefined,
'none')
1169 stretch_type(i) = stretch_none
1170 stretched_dim(i) = .false.
1171 case (
'uni',
'uniform')
1172 stretch_type(i) = stretch_uni
1173 stretched_dim(i) = .true.
1174 case (
'symm',
'symmetric')
1175 stretch_type(i) = stretch_symm
1176 stretched_dim(i) = .true.
1178 stretch_type(i) = stretch_none
1179 stretched_dim(i) = .false.
1180 if (mype == 0) print *,
'Got stretch_type = ', stretch_type(i)
1181 call mpistop(
'Unknown stretch type')
1186 if(typedimsplit ==
'default'.and. dimsplit) typedimsplit=
'xyyx'
1187 if(typedimsplit ==
'default'.and..not.dimsplit) typedimsplit=
'unsplit'
1188 dimsplit = typedimsplit /=
'unsplit'
1191 select case (typesourcesplit)
1193 sourcesplit=sourcesplit_sfs
1195 sourcesplit=sourcesplit_sf
1197 sourcesplit=sourcesplit_ssf
1199 sourcesplit=sourcesplit_ssfss
1201 write(unitterm,*)
'No such typesourcesplit=',typesourcesplit
1202 call mpistop(
"Error: Unknown typesourcesplit!")
1205 if(coordinate==-1)
then
1206 coordinate=cartesian
1208 write(*,*)
'Warning: coordinate system is not specified!'
1209 write(*,*)
'call set_coordinate_system in usr_init in mod_usr.t'
1210 write(*,*)
'Now use Cartesian coordinate'
1214 if(coordinate==cartesian)
then
1217 if(any(stretched_dim))
then
1218 coordinate=cartesian_stretched
1219 slab_uniform=.false.
1223 slab_uniform=.false.
1226 if(coordinate==spherical)
then
1228 if(mype==0)print *,
'Warning: spherical symmetry needs dimsplit=F, resetting'
1233 if (ndim==1) dimsplit=.false.
1236 select case(typeprolonglimit)
1251 allocate(type_limiter(nlevelshi))
1252 allocate(type_gradient_limiter(nlevelshi))
1254 do level=1,nlevelshi
1255 type_limiter(level) = limiter_type(limiter(level))
1256 type_gradient_limiter(level) = limiter_type(gradient_limiter(level))
1259 if (any(limiter(1:nlevelshi)==
'ppm')&
1260 .and.(flatsh.and.physics_type==
'rho'))
then
1261 call mpistop(
" PPM with flatsh=.true. can not be used with physics_type='rho'!")
1267 select case(typeboundary_min^d(iw))
1269 typeboundary(iw,2*^d-1)=bc_special
1271 typeboundary(iw,2*^d-1)=bc_cont
1273 typeboundary(iw,2*^d-1)=bc_symm
1275 typeboundary(iw,2*^d-1)=bc_asymm
1277 typeboundary(iw,2*^d-1)=bc_periodic
1279 typeboundary(iw,2*^d-1)=bc_aperiodic
1281 typeboundary(iw,2*^d-1)=bc_noinflow
1283 typeboundary(iw,2*^d-1)=12
1285 typeboundary(iw,2*^d-1)=bc_data
1287 typeboundary(iw,2*^d-1)=bc_icarus
1289 typeboundary(iw,2*^d-1)=bc_character
1291 write (unitterm,*)
"Undefined boundarytype found in read_par_files", &
1292 typeboundary_min^d(iw),
"for variable iw=",iw,
" and side iB=",2*^d-1
1296 select case(typeboundary_max^d(iw))
1298 typeboundary(iw,2*^d)=bc_special
1300 typeboundary(iw,2*^d)=bc_cont
1302 typeboundary(iw,2*^d)=bc_symm
1304 typeboundary(iw,2*^d)=bc_asymm
1306 typeboundary(iw,2*^d)=bc_periodic
1308 typeboundary(iw,2*^d)=bc_aperiodic
1310 typeboundary(iw,2*^d)=bc_noinflow
1312 typeboundary(iw,2*^d)=12
1314 typeboundary(iw,2*^d)=bc_data
1316 typeboundary(iw,2*^d-1)=bc_icarus
1317 case(
"bc_character")
1318 typeboundary(iw,2*^d)=bc_character
1320 write (unitterm,*)
"Undefined boundarytype found in read_par_files", &
1321 typeboundary_max^d(iw),
"for variable iw=",iw,
" and side iB=",2*^d
1327 if (nwfluxbc<nwflux)
then
1328 do iw=nwfluxbc+1,nwflux
1329 typeboundary(iw,:) = typeboundary(1, :)
1334 do iw=nwflux+1, nwflux+nwaux
1335 typeboundary(iw,:) = typeboundary(1, :)
1339 if (any(typeboundary == 0))
then
1340 call mpistop(
"Not all boundary conditions have been defined")
1344 periodb(idim)=(any(typeboundary(:,2*idim-1:2*idim)==bc_periodic))
1345 aperiodb(idim)=(any(typeboundary(:,2*idim-1:2*idim)==bc_aperiodic))
1346 if (periodb(idim).or.aperiodb(idim))
then
1348 if (typeboundary(iw,2*idim-1) .ne. typeboundary(iw,2*idim)) &
1349 call mpistop(
"Wrong counterpart in periodic boundary")
1351 if (typeboundary(iw,2*idim-1) /= bc_periodic .and. &
1352 typeboundary(iw,2*idim-1) /= bc_aperiodic)
then
1353 call mpistop(
"Each dimension should either have all "//&
1354 "or no variables periodic, some can be aperiodic")
1361 if(any(typeboundary(:,2*idim-1)==12))
then
1362 if(any(typeboundary(:,2*idim-1)/=12)) typeboundary(:,2*idim-1)=12
1363 select case(physics_type)
1364 case (
'rho',
'ard',
'rd',
'nonlinear',
'ffhd')
1366 typeboundary(:,2*idim-1)=bc_symm
1367 if(mype==0) print *,
'symmetric minimal pole'
1368 case (
'hd',
'rhd',
'srhd',
'mhd',
'rmhd')
1369 typeboundary(:,2*idim-1)=bc_symm
1371 if(phys_energy)
then
1376 select case(coordinate)
1378 typeboundary(phi_+1,2*idim-1)=bc_asymm
1379 if(physics_type==
'mhd'.or.physics_type==
'rmhd') typeboundary(ndir+windex+phi_,2*idim-1)=bc_asymm
1381 typeboundary(3:ndir+1,2*idim-1)=bc_asymm
1382 if(physics_type==
'mhd'.or.physics_type==
'rmhd') typeboundary(ndir+windex+2:ndir+windex+ndir,2*idim-1)=bc_asymm
1384 call mpistop(
'Pole is in cylindrical, polar, spherical coordinates!')
1387 call mpistop(
'Pole treatment for twofl or mf not implemented yet')
1389 call mpistop(
'unknown physics type for setting minimal pole boundary treatment')
1392 if(any(typeboundary(:,2*idim)==12))
then
1393 if(any(typeboundary(:,2*idim)/=12)) typeboundary(:,2*idim)=12
1394 select case(physics_type)
1395 case (
'rho',
'ard',
'rd',
'nonlinear',
'ffhd')
1397 typeboundary(:,2*idim)=bc_symm
1398 if(mype==0) print *,
'symmetric maximal pole'
1399 case (
'hd',
'rhd',
'srhd',
'mhd',
'rmhd')
1400 typeboundary(:,2*idim)=bc_symm
1402 if(phys_energy)
then
1407 select case(coordinate)
1409 typeboundary(phi_+1,2*idim)=bc_asymm
1410 if(physics_type==
'mhd'.or.physics_type==
'rmhd') typeboundary(ndir+windex+phi_,2*idim)=bc_asymm
1412 typeboundary(3:ndir+1,2*idim)=bc_asymm
1413 if(physics_type==
'mhd'.or.physics_type==
'rmhd') typeboundary(ndir+windex+2:ndir+windex+ndir,2*idim)=bc_asymm
1415 call mpistop(
'Pole is in cylindrical, polar, spherical coordinates!')
1418 call mpistop(
'Pole treatment for twofl or mf not implemented yet')
1420 call mpistop(
'unknown physics type for setting maximal pole boundary treatment')
1426 if(.not.phys_energy)
then
1431 if(any(limiter(1:nlevelshi)==
'mp5'))
then
1432 nghostcells=max(nghostcells,3)
1435 if(any(limiter(1:nlevelshi)==
'weno5'))
then
1436 nghostcells=max(nghostcells,3)
1439 if(any(limiter(1:nlevelshi)==
'weno5nm'))
then
1440 nghostcells=max(nghostcells,3)
1443 if(any(limiter(1:nlevelshi)==
'wenoz5'))
then
1444 nghostcells=max(nghostcells,3)
1447 if(any(limiter(1:nlevelshi)==
'wenoz5nm'))
then
1448 nghostcells=max(nghostcells,3)
1451 if(any(limiter(1:nlevelshi)==
'wenozp5'))
then
1452 nghostcells=max(nghostcells,3)
1455 if(any(limiter(1:nlevelshi)==
'wenozp5nm'))
then
1456 nghostcells=max(nghostcells,3)
1459 if(any(limiter(1:nlevelshi)==
'teno5ad'))
then
1460 nghostcells=max(nghostcells,3)
1463 if(any(limiter(1:nlevelshi)==
'weno5cu6'))
then
1464 nghostcells=max(nghostcells,3)
1467 if(any(limiter(1:nlevelshi)==
'ppm'))
then
1468 if(flatsh .or. flatcd)
then
1469 nghostcells=max(nghostcells,4)
1471 nghostcells=max(nghostcells,3)
1475 if(any(limiter(1:nlevelshi)==
'weno7'))
then
1476 nghostcells=max(nghostcells,4)
1479 if(any(limiter(1:nlevelshi)==
'mpweno7'))
then
1480 nghostcells=max(nghostcells,4)
1484 nghostcells = nghostcells + phys_wider_stencil
1487 if(stagger_grid .and. refine_max_level>1 .and. mod(nghostcells,2)/=0)
then
1488 nghostcells=nghostcells+1
1491 select case (coordinate)
1494 xprob^lim^de=xprob^lim^de*two*dpi;
1499 xprob^lim^d=xprob^lim^d*two*dpi;
1505 {ixghi^d = block_nx^d + 2*nghostcells\}
1506 {ixgshi^d = ixghi^d\}
1508 nx_vec = [{domain_nx^d|, }]
1509 block_nx_vec = [{block_nx^d|, }]
1511 if (any(nx_vec < 4) .or. any(mod(nx_vec, 2) == 1)) &
1512 call mpistop(
'Grid size (domain_nx^D) has to be even and >= 4')
1514 if (any(block_nx_vec < 4) .or. any(mod(block_nx_vec, 2) == 1)) &
1515 call mpistop(
'Block size (block_nx^D) has to be even and >= 4')
1517 {
if(mod(domain_nx^d,block_nx^d)/=0) &
1518 call mpistop(
'Grid (domain_nx^D) and block (block_nx^D) must be consistent') \}
1520 if(refine_max_level>nlevelshi.or.refine_max_level<1)
then
1521 write(unitterm,*)
'Error: refine_max_level',refine_max_level,
'>nlevelshi ',nlevelshi
1522 call mpistop(
"Reset nlevelshi and recompile!")
1525 if (any(stretched_dim))
then
1526 allocate(qstretch(0:nlevelshi,1:ndim),dxfirst(0:nlevelshi,1:ndim),&
1527 dxfirst_1mq(0:nlevelshi,1:ndim),dxmid(0:nlevelshi,1:ndim))
1528 allocate(nstretchedblocks(1:nlevelshi,1:ndim))
1529 qstretch(0:nlevelshi,1:ndim)=0.0d0
1530 dxfirst(0:nlevelshi,1:ndim)=0.0d0
1531 nstretchedblocks(1:nlevelshi,1:ndim)=0
1532 {
if (stretch_type(^d) == stretch_uni)
then
1534 if(qstretch_baselevel(^d)<1.0d0.or.qstretch_baselevel(^d)==bigdouble)
then
1536 write(*,*)
'stretched grid needs finite qstretch_baselevel>1'
1537 write(*,*)
'will try default value for qstretch_baselevel in dimension', ^d
1539 if(xprobmin^d>smalldouble)
then
1540 qstretch_baselevel(^d)=(xprobmax^d/xprobmin^d)**(1.d0/dble(domain_nx^d))
1542 call mpistop(
"can not set qstretch_baselevel automatically")
1545 if(mod(block_nx^d,2)==1) &
1546 call mpistop(
"stretched grid needs even block size block_nxD")
1547 if(mod(domain_nx^d/block_nx^d,2)/=0) &
1548 call mpistop(
"number level 1 blocks in D must be even")
1549 qstretch(1,^d)=qstretch_baselevel(^d)
1550 dxfirst(1,^d)=(xprobmax^d-xprobmin^d) &
1551 *(1.0d0-qstretch(1,^d))/(1.0d0-qstretch(1,^d)**domain_nx^d)
1552 qstretch(0,^d)=qstretch(1,^d)**2
1553 dxfirst(0,^d)=dxfirst(1,^d)*(1.0d0+qstretch(1,^d))
1554 if(refine_max_level>1)
then
1555 do ilev=2,refine_max_level
1556 qstretch(ilev,^d)=dsqrt(qstretch(ilev-1,^d))
1557 dxfirst(ilev,^d)=dxfirst(ilev-1,^d) &
1558 /(1.0d0+dsqrt(qstretch(ilev-1,^d)))
1563 {
if(stretch_type(^d) == stretch_uni)
then
1564 write(*,*)
'Stretched dimension ', ^d
1565 write(*,*)
'Using stretched grid with qs=',qstretch(0:refine_max_level,^d)
1566 write(*,*)
' and first cell sizes=',dxfirst(0:refine_max_level,^d)
1569 {
if(stretch_type(^d) == stretch_symm)
then
1571 write(*,*)
'will apply symmetric stretch in dimension', ^d
1573 if(mod(block_nx^d,2)==1) &
1574 call mpistop(
"stretched grid needs even block size block_nxD")
1576 if(nstretchedblocks_baselevel(^d)==0) &
1577 call mpistop(
"need finite even number of stretched blocks at baselevel")
1578 if(mod(nstretchedblocks_baselevel(^d),2)==1) &
1579 call mpistop(
"need even number of stretched blocks at baselevel")
1580 if(qstretch_baselevel(^d)<1.0d0.or.qstretch_baselevel(^d)==bigdouble) &
1581 call mpistop(
'stretched grid needs finite qstretch_baselevel>1')
1583 ipower=(nstretchedblocks_baselevel(^d)/2)*block_nx^d
1584 if(nstretchedblocks_baselevel(^d)==domain_nx^d/block_nx^d)
then
1585 xstretch^d=0.5d0*(xprobmax^d-xprobmin^d)
1587 xstretch^d=(xprobmax^d-xprobmin^d) &
1588 /(2.0d0+dble(domain_nx^d-nstretchedblocks_baselevel(^d)*block_nx^d) &
1589 *(1.0d0-qstretch_baselevel(^d))/(1.0d0-qstretch_baselevel(^d)**ipower))
1591 if(xstretch^d>(xprobmax^d-xprobmin^d)*0.5d0) &
1592 call mpistop(
" stretched grid part should not exceed full domain")
1593 dxfirst(1,^d)=xstretch^d*(1.0d0-qstretch_baselevel(^d)) &
1594 /(1.0d0-qstretch_baselevel(^d)**ipower)
1595 nstretchedblocks(1,^d)=nstretchedblocks_baselevel(^d)
1596 qstretch(1,^d)=qstretch_baselevel(^d)
1597 qstretch(0,^d)=qstretch(1,^d)**2
1598 dxfirst(0,^d)=dxfirst(1,^d)*(1.0d0+qstretch(1,^d))
1599 dxmid(1,^d)=dxfirst(1,^d)
1600 dxmid(0,^d)=dxfirst(1,^d)*2.0d0
1601 if(refine_max_level>1)
then
1602 do ilev=2,refine_max_level
1603 nstretchedblocks(ilev,^d)=2*nstretchedblocks(ilev-1,^d)
1604 qstretch(ilev,^d)=dsqrt(qstretch(ilev-1,^d))
1605 dxfirst(ilev,^d)=dxfirst(ilev-1,^d) &
1606 /(1.0d0+dsqrt(qstretch(ilev-1,^d)))
1607 dxmid(ilev,^d)=dxmid(ilev-1,^d)/2.0d0
1611 sizeuniformpart^d=dxfirst(1,^d) &
1612 *(domain_nx^d-nstretchedblocks_baselevel(^d)*block_nx^d)
1614 print *,
'uniform part of size=',sizeuniformpart^d
1615 print *,
'setting of domain is then=',2*xstretch^d+sizeuniformpart^d
1616 print *,
'versus=',xprobmax^d-xprobmin^d
1618 if(dabs(xprobmax^d-xprobmin^d-2*xstretch^d-sizeuniformpart^d)>smalldouble)
then
1619 call mpistop(
'mismatch in domain size!')
1622 dxfirst_1mq(0:refine_max_level,1:ndim)=dxfirst(0:refine_max_level,1:ndim) &
1623 /(1.0d0-qstretch(0:refine_max_level,1:ndim))
1626 dx_vec = [{xprobmax^d-xprobmin^d|, }] / nx_vec
1629 write(c_ndim,
'(I1)') ^nd
1630 write(unitterm,
'(A30,' // c_ndim //
'(I0," "))') &
1631 ' Domain size (cells): ', nx_vec
1632 write(unitterm,
'(A30,' // c_ndim //
'(E9.3," "))') &
1633 ' Level one dx: ', dx_vec
1636 if (any(dx_vec < smalldouble)) &
1637 call mpistop(
"Incorrect domain size (too small grid spacing)")
1641 if(sum(w_refine_weight(:))==0) w_refine_weight(1) = 1.d0
1642 if(dabs(sum(w_refine_weight(:))-1.d0)>smalldouble)
then
1643 write(unitterm,*)
"Sum of all elements in w_refine_weight be 1.d0"
1644 call mpistop(
"Reset w_refine_weight so the sum is 1.d0")
1647 select case (typeboundspeed)
1652 case(
'cmaxleftright')
1657 call mpistop(
"set typeboundspeed='Einfeldt' or 'cmaxmean' or 'cmaxleftright' or 'pvrs'")
1660 if (mype==0)
write(unitterm,
'(A30)', advance=
'no')
'Refine estimation: '
1662 select case (refine_criterion)
1664 if (mype==0)
write(unitterm,
'(A)')
"user defined"
1666 if (mype==0)
write(unitterm,
'(A)')
"relative error"
1668 if (mype==0)
write(unitterm,
'(A)')
"Lohner's original scheme"
1670 if (mype==0)
write(unitterm,
'(A)')
"Lohner's scheme"
1672 call mpistop(
"Unknown error estimator, change refine_criterion")
1675 if (tfixgrid<bigdouble/2.0d0)
then
1676 if(mype==0)print*,
'Warning, at time=',tfixgrid,
'the grid will be fixed'
1678 if (itfixgrid<biginteger/2)
then
1679 if(mype==0)print*,
'Warning, at iteration=',itfixgrid,
'the grid will be fixed'
1681 if (ditregrid>1)
then
1682 if(mype==0)print*,
'Note, Grid is reconstructed once every',ditregrid,
'iterations'
1687 select case(slicedir(islice))
1689 if(slicecoord(islice)<xprobmin^d.or.slicecoord(islice)>xprobmax^d) &
1690 write(uniterr,*)
'Warning in read_par_files: ', &
1691 'Slice ', islice,
' coordinate',slicecoord(islice),
'out of bounds for dimension ',slicedir(islice)
1697 write(unitterm,
'(A30,A,A)')
'restart_from_file: ',
' ', trim(restart_from_file)
1698 write(unitterm,
'(A30,L1)')
'converting: ', convert
1699 write(unitterm,
'(A)')
''
1702 deallocate(flux_scheme)
1854 integer,
intent(in) :: fh
1855 integer(MPI_OFFSET_KIND),
intent(out) :: offset_tree
1856 integer(MPI_OFFSET_KIND),
intent(out) :: offset_block
1858 double precision :: rbuf(ndim)
1859 double precision,
allocatable :: params(:)
1860 integer :: i, version
1861 integer :: ibuf(ndim), iw
1862 integer :: er, n_par, tmp_int
1863 integer,
dimension(MPI_STATUS_SIZE) :: st
1864 logical :: periodic(ndim)
1865 character(len=name_len),
allocatable :: var_names(:), param_names(:)
1866 character(len=name_len) :: phys_name, geom_name
1869 call mpi_file_read(fh, version, 1, mpi_integer, st, er)
1871 call mpistop(
"Incompatible file version (maybe old format?)")
1875 call mpi_file_read(fh, ibuf(1), 1, mpi_integer, st, er)
1876 offset_tree = ibuf(1)
1879 call mpi_file_read(fh, ibuf(1), 1, mpi_integer, st, er)
1880 offset_block = ibuf(1)
1883 call mpi_file_read(fh, ibuf(1), 1, mpi_integer, st, er)
1885 if (nw /= ibuf(1))
then
1886 write(*,*)
"nw=",nw,
" and nw found in restart file=",ibuf(1)
1887 write(*,*)
"Please be aware of changes in w at restart."
1892 call mpi_file_read(fh, ibuf(1), 1, mpi_integer, st, er)
1893 if (ibuf(1) /=
ndir)
then
1894 write(*,*)
"ndir in restart file = ",ibuf(1)
1895 write(*,*)
"ndir = ",
ndir
1896 call mpistop(
"reset ndir to ndir in restart file")
1900 call mpi_file_read(fh, ibuf(1), 1, mpi_integer, st, er)
1901 if (ibuf(1) /= ndim)
then
1902 write(*,*)
"ndim in restart file = ",ibuf(1)
1903 write(*,*)
"ndim = ",ndim
1904 call mpistop(
"reset ndim to ndim in restart file")
1908 call mpi_file_read(fh, ibuf(1), 1, mpi_integer, st, er)
1910 write(*,*)
"number of levels in restart file = ",ibuf(1)
1912 call mpistop(
"refine_max_level < num. levels in restart file")
1916 call mpi_file_read(fh,
nleafs, 1, mpi_integer, st, er)
1919 call mpi_file_read(fh,
nparents, 1, mpi_integer, st, er)
1922 call mpi_file_read(fh,
it, 1, mpi_integer, st, er)
1925 call mpi_file_read(fh,
global_time, 1, mpi_double_precision, st, er)
1928 call mpi_file_read(fh,rbuf(1:ndim),ndim,mpi_double_precision,st,er)
1929 if (maxval(abs(rbuf(1:ndim) - [ xprobmin^
d ])) > 0)
then
1930 write(*,*)
"Error: xprobmin differs from restart data: ", rbuf(1:ndim)
1931 call mpistop(
"change xprobmin^D in par file")
1935 call mpi_file_read(fh,rbuf(1:ndim),ndim,mpi_double_precision,st,er)
1936 if (maxval(abs(rbuf(1:ndim) - [ xprobmax^
d ])) > 0)
then
1937 write(*,*)
"Error: xprobmax differs from restart data: ", rbuf(1:ndim)
1938 call mpistop(
"change xprobmax^D in par file")
1942 call mpi_file_read(fh,ibuf(1:ndim), ndim, mpi_integer,st,er)
1943 if (any(ibuf(1:ndim) /= [
domain_nx^
d ]))
then
1944 write(*,*)
"Error: mesh size differs from restart data: ", ibuf(1:ndim)
1945 call mpistop(
"change domain_nx^D in par file")
1949 call mpi_file_read(fh,ibuf(1:ndim), ndim, mpi_integer,st,er)
1950 if (any(ibuf(1:ndim) /= [
block_nx^
d ]))
then
1951 write(*,*)
"Error: block size differs from restart data:", ibuf(1:ndim)
1952 call mpistop(
"change block_nx^D in par file")
1956 if (version > 4)
then
1957 call mpi_file_read(fh, periodic, ndim, mpi_logical, st, er)
1958 if ({periodic(^
d) .and. .not.
periodb(^
d) .or. .not.periodic(^
d) .and.
periodb(^
d)| .or. }) &
1959 call mpistop(
"change in periodicity in par file")
1961 call mpi_file_read(fh, geom_name, name_len, mpi_character, st, er)
1964 write(*,*)
"type of coordinates in data is: ", geom_name
1965 call mpistop(
"select the correct coordinates in mod_usr.t file")
1968 call mpi_file_read(fh, stagger_mark_dat, 1, mpi_logical, st, er)
1970 write(*,*)
"Warning: stagger grid flag differs from restart data:", stagger_mark_dat
1976 if (version > 3)
then
1980 call mpi_file_read(fh, var_names(iw), name_len, mpi_character, st, er)
1984 call mpi_file_read(fh, phys_name, name_len, mpi_character, st, er)
1990 call mpi_file_read(fh, n_par, 1, mpi_integer, st, er)
1991 allocate(params(n_par))
1992 allocate(param_names(n_par))
1993 call mpi_file_read(fh, params, n_par, mpi_double_precision, st, er)
1994 call mpi_file_read(fh, param_names, name_len * n_par, mpi_character, st, er)
1997 call mpi_file_read(fh, tmp_int, 1, mpi_integer, st, er)
2002 call mpi_file_read(fh, tmp_int, 1, mpi_integer, st, er)
2005 call mpi_file_read(fh, tmp_int, 1, mpi_integer, st, er)