93 integer :: c_snapshots
95 integer :: file_length
106 read(c_snapshots,*,iostat=rstat)
107 if (rstat .ne. 0)
exit
108 file_length = file_length + 1
112 if (file_length .eq. 0)
then
113 call raise_exception(
'No custom snapshots found in the file given with the parameter "snapshot_file".',&
114 "read_custom_snapshots",390027)
119 if (rstat /= 0)
call raise_exception(
'Allocation of "snapshot_time" failed.',
"read_custom_snapshots",&
127 if (rstat .ne. 0)
call raise_exception(
"Unable to read custom snapshots."//new_line(
"A")//&
128 'Check the input file given with the parameter "snapshot_file".',&
129 "read_custom_snapshots",&
139 do while (.not. sorted)
197 integer :: file_length
199 integer :: debug_track
200 character*5 :: nam_tmp
202 info_entry(
"read_track_nuclei")
205 if (verbose_level .gt. 2)
then
208 write(debug_track,
'(A)') &
209 '# Debugging info for read_track_nuclei() from readini.f90'
222 read(track_id,
'(a5)',iostat=istat) nam_tmp
223 if (istat .ne. 0)
exit
225 ind_tmp =
benam(nam_tmp)
228 file_length = file_length + 1
233 call raise_exception(
'No nuclei to track found in the track_nuclei_file. '//new_line(
"A")//&
234 'Check the file and the format of the file! '//new_line(
"A")//&
235 'Each line must have five characters and be right oriented, e.g., " ni56".',&
236 "read_track_nuclei", 390026)
241 if (istat /= 0)
call raise_exception(
'Allocation of "track_nuclei_indices" failed.',
"read_track_nuclei",&
251 read(track_id,
'(a5)',iostat=istat)nam_tmp
253 ind_tmp =
benam(nam_tmp)
255 if (verbose_level .gt. 2)
then
257 write(debug_track,
'("Reading",A,7x,"Index: ",I10)') nam_tmp,ind_tmp
260 if (ind_tmp .ne. 0)
then
265 if (verbose_level .gt. 2)
then
266 write(debug_track,
'("Nucleus",2x,A,2x,"is not contained in network")') nam_tmp
274 if (verbose_level .gt. 2)
then
282 info_exit(
"read_track_nuclei")
333 real(
r_kind),
dimension(net_size),
intent(out) :: iniab
335 character(max_fname_len) :: current_col,col_name,col_unit
336 character(max_fname_len) :: help_reader
339 integer :: a_i,z_i,n_i,x_i,y_i,name_i
342 integer :: skip_count
345 real(
r_kind) :: mafra_norm
346 integer,
dimension(:),
allocatable :: a,z,n
347 real(
r_kind),
dimension(:),
allocatable :: y,x
348 character*5,
dimension(:),
allocatable :: name
349 character(max_fname_len),
dimension(:),
allocatable :: row_read
351 info_entry(
"read_seed")
354 a_i = -1; z_i = -1; n_i = -1; x_i = -1; y_i = -1; name_i = -1
359 if (j>= iachar(
"A") .and. j<=iachar(
"Z") )
then
370 current_col = trim(adjustl(current_col))//
seed_format(i-1:i-1)
373 col_count = col_count +1
377 if ((current_col(j:j) .eq.
':' ) .or. (current_col(j:j) .eq.
' ' ))
exit name_loop
378 col_name = trim(adjustl(col_name))//current_col(j:j)
384 if ((current_col(j:j) .eq.
' ' ))
exit unit_loop
385 col_unit = trim(adjustl(col_unit))//current_col(j:j)
390 select case (trim(adjustl(col_name)))
407 trim(adjustl(
seed_format))//
'". '//new_line(
'A')//&
408 'Can not read column "'//trim(adjustl(col_name))//
'".'//&
409 new_line(
'A')//
'Column type unknown.',
"read_seeds",&
425 read(seed_unit,
"(A)",iostat=istat)help_reader
426 if (istat .ne. 0)
exit
427 help_reader = adjustl(help_reader)
430 if ((skipping .eqv. .true.) .and. (len_trim(help_reader) .eq. 0))
then
431 skip_count = skip_count+1
433 elseif ((skipping .eqv. .true.) .and. (help_reader(1:1) .eq.
"#"))
then
434 skip_count = skip_count+1
441 if ((skipping .eqv. .false.) .and. (len_trim(help_reader) .eq. 0))
then
442 if (verbose_level .gt. 1)
write(*,*)
"Warning, seed file ended unexpectedly."
451 allocate(row_read(col_count),stat=istat)
452 if (istat /= 0)
call raise_exception(
'allocation failed.',
"read_seeds",390001)
453 allocate(a(l_file),z(l_file),n(l_file),y(l_file),x(l_file),name(l_file),stat=istat)
454 if (istat /= 0)
call raise_exception(
'allocation failed.',
"read_seeds",390001)
463 a(:) = 0; z(:) = 0; n(:) = 0; y(:) = 0; x(:) = 0 ; name(:) =
" "
466 read(seed_unit,*)row_read
467 if (a_i .ne. -1) a(i) =
str_to_int(row_read(a_i))
468 if (z_i .ne. -1) z(i) =
str_to_int(row_read(z_i))
469 if (n_i .ne. -1) n(i) =
str_to_int(row_read(n_i))
472 if (name_i .ne. -1) name(i) = trim(adjustl(row_read(name_i)))
477 if ((a_i .eq. -1) .and. (z_i .ne. -1) .and. (n_i .ne. -1))
then
479 elseif ((a_i .ne. -1) .and. (z_i .eq. -1) .and. (n_i .ne. -1))
then
481 elseif ((a_i .ne. -1) .and. (z_i .ne. -1) .and. (n_i .eq. -1))
then
483 elseif ((a_i .ne. -1) .and. (z_i .ne. -1) .and. (n_i .ne. -1))
then
486 if (name_i .ne. -1)
then
489 if(trim(adjustl(name(j))).eq.trim(adjustl(
isotope(i)%name)))
then
504 if ((y_i .ne. -1) .and. (x_i .eq. -1))
then
506 elseif ((y_i .eq. -1) .and. (x_i .ne. -1))
then
509 if (a(i) .eq. 0) a(i) = 1
512 elseif ((y_i .ne. -1) .and. (x_i .ne. -1))
then
515 call raise_exception(
"Not possible to read seeds. Give either Y or X!",&
523 if (abs(mafra_norm-1d0) .gt. 0.1 )
then
524 call raise_exception(
"Norm of seed nuclei was terrible ("//num_to_str(abs(mafra_norm-1d0))//
")! "//&
525 "Check your initial abundances or seed format!",&
530 x(:) = x(:)/mafra_norm
531 y(:) = y(:)/mafra_norm
540 if (name_i .ne. -1)
then
542 if(trim(adjustl(name(j))).eq.trim(adjustl(
isotope(i)%name)))
then
548 if ((z(j) .eq.
isotope(i)%p_nr) .and. (a(j) .eq.
isotope(i)%mass))
then
558 info_exit(
"read_seed")
579 character(len=*),
intent(in) :: unit
582 select case (trim(adjustl(unit)))
598 trim(adjustl(unit))//
'" unknown.',
"time_unit_conversion",&
619 character(len=*),
intent(in) :: unit
622 select case (trim(adjustl(unit)))
640 trim(adjustl(unit))//
'" unknown.',
"temp_unit_conversion",&
661 character(len=*),
intent(in) :: unit
664 select case (trim(adjustl(unit)))
680 trim(adjustl(unit))//
'" unknown.',
"dens_unit_conversion",&
701 character(len=*),
intent(in) :: unit
704 select case (trim(adjustl(unit)))
718 trim(adjustl(unit))//
'" unknown.',
"dist_unit_conversion",&
740 character(len=*),
intent(in) :: unit
743 select case (trim(adjustl(unit)))
753 'Neutrino temperature unit "'//&
754 trim(adjustl(unit))//
'" unknown.',
"nutemp_unit_conversion",&
776 character(len=*),
intent(in) :: unit
779 select case (trim(adjustl(unit)))
789 'Neutrino energy unit "'//&
790 trim(adjustl(unit))//
'" unknown.',
"nuenergy_unit_conversion",&
811 character(len=*),
intent(in) :: unit
814 select case (trim(adjustl(unit)))
824 'Neutrino luminosity unit "'//&
825 trim(adjustl(unit))//
'" unknown.',
"nulumin_unit_conversion",&
890 integer :: traj_unit, i,j, istat
892 integer :: time_i,temp_i,dens_i,rad_i,ye_i
893 integer :: x_i,y_i,z_i
894 real(
r_kind) :: conv_time,conv_temp,conv_dens
895 real(
r_kind) :: conv_rad,conv_ye
896 real(
r_kind) :: conv_x,conv_y,conv_z
897 real(
r_kind) :: x_tmp,y_tmp,z_tmp
898 integer :: nuetemp_i,anuetemp_i
899 integer :: lnue_i,lanue_i
900 real(
r_kind) :: conv_tnue,conv_tanue
901 real(
r_kind) :: conv_lnue,conv_lanue
902 integer :: nuxtemp_i,anuxtemp_i
903 integer :: lnux_i,lanux_i
904 real(
r_kind) :: conv_tnux,conv_tanux
905 real(
r_kind) :: conv_lnux,conv_lanux
906 character(max_fname_len) :: current_col,col_name,col_unit
907 real(
r_kind),
dimension(:),
allocatable :: row_read
909 logical :: log_switch
910 logical :: ls_time,ls_temp,ls_dens,ls_rad
911 logical :: ls_x,ls_y,ls_z,ls_ye
912 logical :: ls_tnue,ls_tanue,ls_lnue,ls_lanue
913 logical :: ls_tnux,ls_tanux,ls_lnux,ls_lanux
914 integer :: skip_count
916 character(max_fname_len) :: help_reader
918 info_entry(
"custom_read")
928 if (j>= iachar(
"A") .and. j<=iachar(
"Z") )
then
941 read(traj_unit,
"(A)",iostat=istat)help_reader
943 if (istat .ne. 0)
exit
945 help_reader = adjustl(help_reader)
947 if ((skipping .eqv. .true.) .and. (len_trim(help_reader) .eq. 0))
then
948 skip_count = skip_count+1
950 elseif ((skipping .eqv. .true.) .and. (help_reader(1:1) .eq.
"#"))
then
951 skip_count = skip_count+1
962 if (istat /= 0)
call raise_exception(
'allocation failed.',
"custom_read",390001)
965 if (((nuflag.ge.1)) .and. (neutrino_mode .eq.
'from_file'))
then
971 if (istat /= 0)
call raise_exception(
'allocation failed.',
"custom_read",390001)
984 nuetemp_i = 0; anuetemp_i = 0
985 lnue_i = 0; lanue_i = 0
987 nuxtemp_i = 0; anuxtemp_i = 0
988 lnux_i = 0; lanux_i = 0
997 col_count = col_count +1
1001 if ((current_col(j:j) .eq.
':' ) .or. (current_col(j:j) .eq.
' ' ))
exit name_loop
1002 col_name = trim(adjustl(col_name))//current_col(j:j)
1008 if ((current_col(j:j) .eq.
' ' ))
exit unit_loop
1009 col_unit = trim(adjustl(col_unit))//current_col(j:j)
1013 select case (col_name(1:4))
1017 log_switch = .false.
1021 if (log_switch)
then
1022 col_name = col_name(5:)
1026 select case (trim(adjustl(col_name)))
1068 nuetemp_i = col_count
1069 ls_tnue = log_switch
1073 anuetemp_i = col_count
1074 ls_tanue = log_switch
1078 nuetemp_i = col_count
1079 ls_tnue = log_switch
1083 anuetemp_i = col_count
1084 ls_tanue = log_switch
1094 ls_lanue= log_switch
1098 nuxtemp_i = col_count
1099 ls_tnux = log_switch
1103 anuxtemp_i = col_count
1104 ls_tanux = log_switch
1108 nuxtemp_i = col_count
1109 ls_tnux = log_switch
1113 anuxtemp_i = col_count
1114 ls_tanux = log_switch
1124 ls_lanux= log_switch
1132 'Can not read column "'//trim(adjustl(col_name))//
'".'//&
1133 new_line(
'A')//
'Column type unknown.',
"custom_read",&
1142 if ((time_i .eq. 0) .or. (temp_i .eq. 0) .or. (dens_i .eq. 0))
then
1145 'Necessary column is missing.',
"custom_read",&
1153 'Ye was missing.',
"custom_read",&
1158 if (((rad_i .eq. 0) .and. (x_i .eq. 0)) .and. (nuflag.ge.1) )
then
1161 'Radius was missing.',
"custom_read",&
1166 if (((nuflag.ge.1)) .and. (neutrino_mode .eq.
'from_file'))
then
1167 if ((nuetemp_i .eq. 0) .or. (anuetemp_i .eq. 0) .or. (lnue_i .eq. 0) .or. &
1168 (lanue_i .eq. 0))
then
1171 'Necessary column with neutrino information is missing.',
"custom_read",&
1178 if (((nuflag .eq. 4) .or. (nuflag .eq. 5)) .and. (neutrino_mode .eq.
'from_file'))
then
1179 if ((nuxtemp_i .eq. 0) .or. (anuxtemp_i .eq. 0) .or. (lnux_i .eq. 0) .or. &
1180 (lanux_i .eq. 0))
then
1183 'Necessary column with (heavy) neutrino information is missing.',
"custom_read",&
1196 allocate(row_read(col_count),stat=istat)
1197 if (istat /= 0)
call raise_exception(
'Allocation failed.',
"custom_read",390001)
1201 read(traj_unit,*,iostat=istat)row_read
1203 if (istat .ne. 0)
then
1204 call raise_exception(
"Could not read trajectory file."//new_line(
'A')//&
1205 "Line "//
int_to_str(skip_count+i)//
" raised a problem.",&
1206 "custom_read",390024)
1210 if (ls_time)
ztime(i) = 10**(row_read(time_i))
1211 if (.not. ls_time)
ztime(i) = row_read(time_i)
1215 if (ls_dens)
zdens(i) = 10**(row_read(dens_i))
1216 if (.not. ls_dens)
zdens(i) = row_read(dens_i)
1220 if (ls_temp)
ztemp(i) = 10**(row_read(temp_i))
1221 if (.not. ls_temp)
ztemp(i) = row_read(temp_i)
1225 if (ye_i .ne. 0)
then
1226 if (ls_ye)
zye(i) = 10**(row_read(ye_i))
1227 if (.not. ls_ye)
zye(i) = row_read(ye_i)
1234 if (rad_i .ne. 0)
then
1235 if (ls_rad)
zrad(i) = 10**(row_read(rad_i))
1236 if (.not. ls_rad)
zrad(i) = row_read(rad_i)
1238 elseif ((rad_i .eq. 0) .and. (x_i .ne. 0) .and. (y_i .eq. 0) .and. (z_i .eq. 0))
then
1239 if (ls_x) x_tmp = 10**(row_read(x_i))
1240 if (.not. ls_x) x_tmp = row_read(x_i)
1241 zrad(i) = x_tmp*conv_x
1242 elseif ((rad_i .eq. 0) .and. (x_i .ne. 0) .and. (y_i .ne. 0) .and. (z_i .eq. 0))
then
1244 if (ls_x) x_tmp = 10**(row_read(x_i))
1245 if (.not. ls_x) x_tmp = row_read(x_i)
1246 if (ls_y) y_tmp = 10**(row_read(y_i))
1247 if (.not. ls_y) y_tmp = row_read(y_i)
1249 zrad(i) = sqrt((x_tmp*conv_x)**2+(y_tmp*conv_y)**2)
1250 elseif ((rad_i .eq. 0) .and. (x_i .ne. 0) .and. (y_i .ne. 0) .and. (z_i .ne. 0))
then
1252 if (ls_x) x_tmp = 10**(row_read(x_i))
1253 if (.not. ls_x) x_tmp = row_read(x_i)
1254 if (ls_y) y_tmp = 10**(row_read(y_i))
1255 if (.not. ls_y) y_tmp = row_read(y_i)
1256 if (ls_z) z_tmp = 10**(row_read(z_i))
1257 if (.not. ls_z) z_tmp = row_read(z_i)
1258 zrad(i) = sqrt((x_tmp*conv_x)**2+(y_tmp*conv_y)**2+(z_tmp*conv_z)**2)
1267 if ((nuflag.ge.1) .and. (neutrino_mode .eq.
'from_file'))
then
1270 if (ls_tnue)
tnue(i) = 10**row_read(nuetemp_i)
1271 if (.not. ls_tnue)
tnue(i) = row_read(nuetemp_i)
1275 if (ls_tanue)
tnuebar(i) = 10**row_read(anuetemp_i)
1276 if (.not. ls_tanue)
tnuebar(i) = row_read(anuetemp_i)
1280 if (ls_lnue)
nlume(i) = 10**row_read(lnue_i)
1281 if (.not. ls_lnue)
nlume(i) = row_read(lnue_i)
1284 if (ls_lanue)
nlumebar(i) = 10**row_read(lanue_i)
1285 if (.not. ls_lanue)
nlumebar(i) = row_read(lanue_i)
1295 if ( ((nuflag .eq. 4) .or. (nuflag .eq. 5)) .and. (neutrino_mode .eq.
'from_file'))
then
1297 if (ls_tnux)
tnux(i) = 10**row_read(nuxtemp_i)
1298 if (.not. ls_tnux)
tnux(i) = row_read(nuxtemp_i)
1302 if (ls_tanux)
tnuxbar(i) = 10**row_read(anuxtemp_i)
1303 if (.not. ls_tanux)
tnuxbar(i) = row_read(anuxtemp_i)
1307 if (ls_lnux)
nlumx(i) = 10**row_read(lnux_i)
1308 if (.not. ls_lnux)
nlumx(i) = row_read(lnux_i)
1312 if (ls_lanux)
nlumxbar(i) = 10**row_read(lanux_i)
1313 if (.not. ls_lanux)
nlumxbar(i) = row_read(lanux_i)
1330 if ((nuflag.ge.1) .and. (neutrino_mode .eq.
'from_file'))
then
1337 if ( ((nuflag .eq. 4) .or. (nuflag .eq. 5)) .and. &
1338 (neutrino_mode .eq.
'from_file'))
then
1348 info_exit(
"custom_read")
1372 call raise_exception(
"Last point of trajectory had negative time ("//&
1374 ")!"//new_line(
'A')//
'Please check your input trajectory.',&
1375 "consistency_check",&
1378 elseif ((maxval(
zye) .gt. 1) .or. (minval(
zye) .lt. 0))
then
1379 call raise_exception(
"The electron fraction was out of bounds (0 < Ye < 1)! "//&
1380 new_line(
'A')//
'Please check your input trajectory.',&
1381 "consistency_check",&
1389 if (isnan(dexp(
zrad(i))))
then
1391 'The radius was below zero."'//new_line(
'A')//&
1392 'Please check your input trajectory.',
"consistency_check",&
1395 elseif (isnan(dexp(
ztemp(i))))
then
1397 'The temperature was below zero".'//new_line(
'A')//&
1398 'Please check your input trajectory.',
"consistency_check",&
1401 elseif (isnan(dexp(
zdens(i))))
then
1403 'The density was below zero".'//new_line(
'A')//&
1404 'Please check your input trajectory.',
"consistency_check",&
1412 new_line(
'A')//
"Check your trajectory!",
"consistency_check",&