diff --git a/src/adjust_data.f90 b/src/adjust_data.f90 index b06f267a..1728d393 100644 --- a/src/adjust_data.f90 +++ b/src/adjust_data.f90 @@ -278,8 +278,11 @@ subroutine adjust_data_codeunits dat(:,1,1) = dat(:,1,1) - period*int(dat(:,1,1)/period) endif - get_h = lenvironment('SPLASH_GETH') - if (.not.get_h) get_h = lenvironment('SPLASH_GET_H') + ! + !--recompute smoothing lengths (--geth / --get_h) + ! + get_h = get_command_flag('geth') + if (.not.get_h) get_h = get_command_flag('get_h') if (ndim >= 1 .and. get_h) then call get_h_on_all_particles(dat,npartoftype,nstepsinfile(ifileopen),ndim,ncolumns) endif @@ -619,4 +622,4 @@ subroutine get_h_on_all_particles(dat,npartoftype,nsteps,ndim,ncol) end subroutine get_h_on_all_particles -end module adjustdata \ No newline at end of file +end module adjustdata diff --git a/src/allocate.f90 b/src/allocate.f90 index 2c03b2d7..dcb168ce 100644 --- a/src/allocate.f90 +++ b/src/allocate.f90 @@ -181,6 +181,7 @@ subroutine alloc(npartin,nstep,ncolumnsin,mixedtypes) ! !--type array if necessary ! + if (.not.allocated(iamtypetemp)) allocate(iamtypetemp(0,0)) ! to avoid compiler warning if (present(mixedtypes)) then if (mixedtypes .and. .not.allocated(iamtype)) then allocate(iamtype(maxpart,maxstep), stat=ierr) @@ -189,7 +190,6 @@ subroutine alloc(npartin,nstep,ncolumnsin,mixedtypes) !--copy contents if reallocating if (reallocate_itype) then iamtype(1:maxpartold,1:maxstepold) = iamtypetemp(1:maxpartold,1:maxstepold) - deallocate(iamtypetemp) endif elseif (.not.mixedtypes) then !--if called with mixedtypes explictly false, deallocate itype array @@ -202,8 +202,8 @@ subroutine alloc(npartin,nstep,ncolumnsin,mixedtypes) iamtype = 1 iamtype(1:maxpartold,1:maxstepold) = iamtypetemp(1:maxpartold,1:maxstepold) - deallocate(iamtypetemp) endif + if (allocated(iamtypetemp)) deallocate(iamtypetemp) !--make sure iamtype is always allocated for safety, just with size=1 if not used if (.not.allocated(iamtype)) then allocate(iamtype(1,maxstep),stat=ierr) @@ -248,8 +248,8 @@ subroutine alloc(npartin,nstep,ncolumnsin,mixedtypes) npartoftype(:,1:maxstepold) = npartoftypetemp(:,1:maxstepold) masstype(:,1:maxstepold) = masstypetemp(:,1:maxstepold) time(1:maxstepold) = timetemp(1:maxstepold) - gamma(1:maxstepold) = gammatemp(1:maxstepold) - headervals(:,1:maxstepold) = headervalstemp(:,1:maxstepold) + if (allocated(gammatemp)) gamma(1:maxstepold) = gammatemp(1:maxstepold) + if (allocated(headervalstemp)) headervals(:,1:maxstepold) = headervalstemp(:,1:maxstepold) deallocate(npartoftypetemp,masstypetemp) deallocate(timetemp,gammatemp) deallocate(headervalstemp) diff --git a/src/asciiutils.f90 b/src/asciiutils.f90 index ddb1c4e0..95b653fb 100644 --- a/src/asciiutils.f90 +++ b/src/asciiutils.f90 @@ -37,7 +37,7 @@ module asciiutils public :: string_replace,string_delete,get_nheaderlines,string_sub public :: ucase,lcase,strip public :: get_line_containing - public :: enumerate,isdigit,get_digits,integer_to_string,split + public :: enumerate,isdigit,get_digits,integer_to_string,split_string public :: get_column_labels,read_column_labels public :: match_tag,match_taglist,append_number,make_tags_unique,get_value public :: match_column,match_tag_start,match_integer,match_lists @@ -537,7 +537,7 @@ integer function ncolumnsline_csv(line,ntot) result(ncols) real :: dum ! split line by commas - call split(line,',',fields,nfields) + call split_string(line,',',fields,nfields) ! report how many columns contain real numbers ! or blank (non-text) entries @@ -573,7 +573,7 @@ subroutine readline_csv(line,ncols,datcol) integer :: nfields,i,icol,ierr ! split line by commas - call split(line,',',fields,nfields) + call split_string(line,',',fields,nfields) ! read only columns that contain real numbers icol = 0 @@ -1013,7 +1013,7 @@ end function enumerate ! Split a string into substrings based on a delimiter ! !--------------------------------------------------------------------------- -pure subroutine split(string,delim,stringarr,nsplit) +pure subroutine split_string(string,delim,stringarr,nsplit) character(len=*), intent(in) :: string character(len=*), intent(in) :: delim character(len=*), intent(out), dimension(:), optional :: stringarr @@ -1050,7 +1050,7 @@ pure subroutine split(string,delim,stringarr,nsplit) i = iend + len(delim) + 1 enddo -end subroutine split +end subroutine split_string !--------------------------------------------------------------------------- ! @@ -1095,7 +1095,7 @@ subroutine get_column_labels(line,nlabels,labels,method,ndesired,csv) i1 = max(index(line,'[')+1,i1) ! strip leading square bracket ! try with different number of spaces between brackets (if labels not found) over_spaces1: do i=4,0,-1 - call split(line(i1:),']'//spaces(1:i)//'[',labels,nlabels) + call split_string(line(i1:),']'//spaces(1:i)//'[',labels,nlabels) if (nlabels > 1) exit over_spaces1 enddo over_spaces1 elseif (index(line,',') > 1 .or. is_csv) then @@ -1103,7 +1103,7 @@ subroutine get_column_labels(line,nlabels,labels,method,ndesired,csv) ! format style 2: mylabel1,mylabel2,mylabel3 ! istyle = 2 - call split(line(i1:),',',labels,nlabelstmp) + call split_string(line(i1:),',',labels,nlabelstmp) if (is_csv) then nlabels = nlabelstmp ! allow blank/arbitrary labels in csv format else @@ -1117,7 +1117,7 @@ subroutine get_column_labels(line,nlabels,labels,method,ndesired,csv) ! try splitting with 4, then 3, then 2 spaces until the number of labels decreases nlabels_prev = 0 over_spaces: do i=4,2,-1 - call split(line(i1:),spaces(1:i),labels,nlabelstmp) + call split_string(line(i1:),spaces(1:i),labels,nlabelstmp) ! quit if we already have the target number of labels if (nlabelstmp == ntarget) exit over_spaces @@ -1126,7 +1126,7 @@ subroutine get_column_labels(line,nlabels,labels,method,ndesired,csv) if ((nlabelstmp < nlabels_prev .or. nlabelstmp >= max(nlabels_prev,2) & .and. i < 4 .and. .not. (ntarget > 0 .and. nlabelstmp > ntarget))) then ! take the answer with the previous number of spaces - call split(line(i1:),spaces(1:i+1),labels,nlabelstmp) + call split_string(line(i1:),spaces(1:i+1),labels,nlabelstmp) exit over_spaces endif nlabels_prev = nlabelstmp @@ -1142,7 +1142,7 @@ subroutine get_column_labels(line,nlabels,labels,method,ndesired,csv) ! (this style is also dangerous) ! istyle = 4 - call split(line(i1:),' ',labels,nlabelstmp) + call split_string(line(i1:),' ',labels,nlabelstmp) nlabels = count_sensible_labels(nlabelstmp,labels) endif endif diff --git a/src/defaults.f90 b/src/defaults.f90 index a36109cd..e23d4c28 100644 --- a/src/defaults.f90 +++ b/src/defaults.f90 @@ -46,12 +46,14 @@ subroutine defaults_set(use_evdefaults) use settings_xsecrot, only:defaults_set_xsecrotate use settings_powerspec, only:defaults_set_powerspec use settings_units, only:defaults_set_units + use settings_data, only:iverbose use titles, only:pagetitles,steplegend logical, intent(in) :: use_evdefaults - integer :: i + integer :: i,iverbose_save ! !--set defaults for submenu options ! + iverbose_save = iverbose call defaults_set_data call defaults_set_limits call defaults_set_page @@ -66,7 +68,7 @@ subroutine defaults_set(use_evdefaults) !--if using evsplash, override some default options ! if (use_evdefaults) then - print "(a)",' ** ev mode: using default settings for .ev files **' + if (iverbose_save >= 0) print "(a)",' ** ev mode: using default settings for .ev files **' call defaults_set_page_ev call defaults_set_part_ev endif @@ -170,7 +172,7 @@ end subroutine defaults_write subroutine defaults_read(filename) use filenames, only:rootname,maxfile use multiplot, only:multi - use settings_data, only:dataopts,idustfrac_plot,idefaults_file_read + use settings_data, only:dataopts,idustfrac_plot,idefaults_file_read,iverbose use settings_part, only:plotopts use settings_page, only:pageopts use settings_render, only:renderopts @@ -251,19 +253,21 @@ subroutine defaults_read(filename) 66 continue close(unit=iunit) - if (nerr > 0) then - print "(a)",' WARNING: '//trim(filename)//' incomplete (from old code version)' - else - print*,'read '//trim(filename) + if (iverbose >= 0) then + if (nerr > 0) then + print "(a)",' WARNING: '//trim(filename)//' incomplete (from old code version)' + else + print*,'read '//trim(filename) + endif endif return else - print*,trim(filename)//' not found: using default settings' + if (iverbose >= 0) print*,trim(filename)//' not found: using default settings' return endif 88 continue - print "(a)",' *** error opening defaults file '//trim(filename)//': using default settings' + if (iverbose >= 0) print "(a)",' *** error opening defaults file '//trim(filename)//': using default settings' return end subroutine defaults_read diff --git a/src/get_data.f90 b/src/get_data.f90 index eb7580fe..7283d11b 100644 --- a/src/get_data.f90 +++ b/src/get_data.f90 @@ -87,10 +87,12 @@ subroutine get_data(ireadfile,gotfilenames,firsttime,iposinfile) if (present(firsttime)) isfirsttime = firsttime if (debugmode) then iverbose = 2 - elseif (isfirsttime) then - iverbose = 1 - else - iverbose = 0 + elseif (iverbose >= 0) then + if (isfirsttime) then + iverbose = 1 + else + iverbose = 0 + endif endif ! ipos is the offset for *which* timestep to read from files containing multiple steps @@ -122,7 +124,7 @@ subroutine get_data(ireadfile,gotfilenames,firsttime,iposinfile) ! nstepsinfile(1:nfiles) = 0 required = .true. - print "(/a)",' reading ALL dumpfiles into memory' + if (iverbose >= 0) print "(/a)",' reading ALL dumpfiles into memory' !call endian_info() do i=1,nfiles @@ -132,7 +134,7 @@ subroutine get_data(ireadfile,gotfilenames,firsttime,iposinfile) if (nstepsinfile(i) > 0 .and. ncolumnsfirst==0 .and. ncolumns > 0) then ncolumnsfirst = ncolumns elseif (nstepsinfile(i) > 0 .and. ncolumns /= ncolumnsfirst) then - print "(a,i2,a,i2,a)",' WARNING: file contains ',ncolumns, & + if (iverbose >= 0) print "(a,i2,a,i2,a)",' WARNING: file contains ',ncolumns, & ' columns (',ncolumnsfirst,' previously)' ncolumns = max(ncolumns,ncolumnsfirst) endif @@ -144,7 +146,7 @@ subroutine get_data(ireadfile,gotfilenames,firsttime,iposinfile) else ncolumns = 0 endif - print "(a,i6,a,i3)",' >> Finished data read, nsteps = ',nsteps,' ncolumns = ',ncolumns + if (iverbose >= 0) print "(a,i6,a,i3)",' >> Finished data read, nsteps = ',nsteps,' ncolumns = ',ncolumns ! !--set labels (and units) for each column of data @@ -204,7 +206,7 @@ subroutine get_data(ireadfile,gotfilenames,firsttime,iposinfile) ! print "(a)",' trying different endian' ! call read_data_otherendian(rootname(ireadfile),istart,nstepsinfile(ireadfile)) !endif - if (dotiming) then + if (dotiming .and. iverbose >= 0) then call wall_time(t2) if (t2-t1 > 1.) then if (ipartialread) then @@ -319,7 +321,7 @@ subroutine get_labels use asciiutils, only:read_asciifile use filenames, only:fileprefix use labels, only:label - use settings_data, only:ncolumns + use settings_data, only:ncolumns,iverbose use particle_data, only:maxcol use params, only:maxplot use readdata, only:set_labels @@ -339,7 +341,7 @@ subroutine get_labels nlabelsread = 0 if (iexist) then call read_asciifile(trim(fileprefix)//'.columns',nlabelsread,label(1:min(ncolumns,maxcol,maxplot))) - if (nlabelsread < ncolumns) & + if (nlabelsread < ncolumns .and. iverbose >= 0) & print "(a,i3)",' end of file in '//trim(fileprefix)//'.columns file: labels read to column ',nlabelsread endif @@ -382,7 +384,8 @@ subroutine rescale_data(firsttime,nsteps_read) if (firsttime) call read_unitsfile(trim(unitsfile),ncolumns,ierr,iverbose) if (firsttime) then - labelorig = '' + ! save bare column labels before units are appended + labelorig = label labelreq = '' endif diff --git a/src/interpolate3D.f90 b/src/interpolate3D.f90 index dd8f36f9..0435295c 100644 --- a/src/interpolate3D.f90 +++ b/src/interpolate3D.f90 @@ -171,9 +171,9 @@ subroutine interpolate3D(x,y,z,hh,weight,dat,itype,npart,& !$omp private(pixint,wint,negflag,dfac,threadid) & !$omp firstprivate(iprintnext) & !$omp reduction(+:nwarn,usedpart) -!$omp master +!$omp masked !$ print "(1x,a,i3,a)",'Using ',omp_get_num_threads(),' cpus' -!$omp end master +!$omp end masked !$omp do schedule (guided, 2) over_parts: do i=1,npart @@ -471,9 +471,9 @@ subroutine interpolate3D_vec(x,y,z,hh,weight,datvec,itype,npart,& !$omp private(ipix,jpix,kpix,ipixi,jpixi,kpixi) & !$omp private(dx2i,nxpix,zpix,dz,dz2,dyz2,dy,ypix,q2,wab) & !$omp reduction(+:nwarn) -!$omp master +!$omp masked !$ print "(1x,a,i3,a)",'Using ',omp_get_num_threads(),' cpus' -!$omp end master +!$omp end masked ! !--loop over particles ! diff --git a/src/interpolate3D_geom.f90 b/src/interpolate3D_geom.f90 index bbbd963e..9b4709ac 100644 --- a/src/interpolate3D_geom.f90 +++ b/src/interpolate3D_geom.f90 @@ -152,9 +152,9 @@ subroutine interpolate3Dgeom(igeom,x,y,z,hh,weight,dat,itype,npart,& !$omp private(dx,q2,wab,isub,jsub,ksub,nsubpix,dsubpix) & !$omp reduction(+:nsub,meansubpix,ncount) & !$omp reduction(max:maxsubpix) -!$omp master +!$omp masked !$ print "(1x,a,i3,a)",'Using ',omp_get_num_threads(),' cpus' -!$omp end master +!$omp end masked !$omp do schedule (guided, 2) over_parts: do i=1,npart @@ -354,9 +354,9 @@ subroutine interpolate3Dgeom_vec(igeom,x,y,z,hh,weight,datvec,itype,npart,& !$omp private(dx,q2,wab,isub,jsub,ksub,nsubpix,dsubpix) & !$omp reduction(+:nsub,meansubpix,ncount) & !$omp reduction(max:maxsubpix) -!$omp master +!$omp masked !$ print "(1x,a,i3,a)",'Using ',omp_get_num_threads(),' cpus' -!$omp end master +!$omp end masked !$omp do schedule (guided, 2) over_parts: do i=1,npart diff --git a/src/interpolate3D_proj_geom.f90 b/src/interpolate3D_proj_geom.f90 index f1629318..0fa75ce2 100644 --- a/src/interpolate3D_proj_geom.f90 +++ b/src/interpolate3D_proj_geom.f90 @@ -115,9 +115,9 @@ subroutine interpolate3D_proj_geom(x,y,z,hh,weight,dat,itype,npart, & endif ncpus = 0 !$omp parallel - !$omp master + !$omp masked !$ ncpus = omp_get_num_threads() - !$omp end master + !$omp end masked !$omp end parallel if (ncpus > 0) then diff --git a/src/interpolate3D_projection.f90 b/src/interpolate3D_projection.f90 index 203c771c..aedc98e6 100644 --- a/src/interpolate3D_projection.f90 +++ b/src/interpolate3D_projection.f90 @@ -202,9 +202,9 @@ subroutine interpolate3D_projection(x,y,z,hh,weight,dat,itype,npart, & ncpus = 0 !$omp parallel - !$omp master + !$omp masked !$ ncpus = omp_get_num_threads() - !$omp end master + !$omp end masked !$omp end parallel if (ncpus > 0 .and. iverbose >= 0) then diff --git a/src/kernels.f90 b/src/kernels.f90 index a5dc5df0..f8205538 100644 --- a/src/kernels.f90 +++ b/src/kernels.f90 @@ -69,12 +69,17 @@ end function k_func ! cnormk values and pointer to kernel function ! !-------------------------------------- -subroutine select_kernel(j) +subroutine select_kernel(j,verbose) integer, intent(in) :: j + logical, intent(in), optional :: verbose + logical :: isverbose + + isverbose = .true. + if (present(verbose)) isverbose = verbose if (j >= 1 .and. j <= nkernels) then !--print only if NOT using the default kernel - print "(a,/)",' Using '//trim(kernelname(j))//' kernel' + if (isverbose) print "(a,/)",' Using '//trim(kernelname(j))//' kernel' endif select case(j) @@ -135,10 +140,15 @@ end subroutine select_kernel ! Kernel selection based on string ! !-------------------------------------- -subroutine select_kernel_by_name(string) +subroutine select_kernel_by_name(string,verbose) use asciiutils, only:lcase character(len=*), intent(in) :: string + logical, intent(in), optional :: verbose integer :: i,jkern + logical :: isverbose + + isverbose = .true. + if (present(verbose)) isverbose = verbose jkern = 0 ! @@ -169,7 +179,7 @@ subroutine select_kernel_by_name(string) end select endif - call select_kernel(jkern) + call select_kernel(jkern,verbose=isverbose) end subroutine select_kernel_by_name diff --git a/src/labels.f90 b/src/labels.f90 index 86be6121..6fbd24ed 100644 --- a/src/labels.f90 +++ b/src/labels.f90 @@ -682,4 +682,58 @@ subroutine set_vector_labels(ncolumns,ndimV,iamveci,labelveci,labeli,labelcoordi end subroutine set_vector_labels +!----------------------------------------------------------------- +! +! print dump file header tags and values +! +!----------------------------------------------------------------- +subroutine print_headers(headervals1) + real, intent(in) :: headervals1(:) + integer :: i,nhdr + + nhdr = min(count_non_blank(headertags),size(headervals1)) + do i=1,nhdr + print "(1x,a,' = ',1pg14.6)",trim(headertags(i)),headervals1(i) + enddo + +end subroutine print_headers + +!----------------------------------------------------------------- +! +! print column labels one per line (no numbers) +! +!----------------------------------------------------------------- +subroutine print_column_labels(ncolumns,ncalc) + integer, intent(in) :: ncolumns,ncalc + integer :: i,nlab + + nlab = min(ncolumns + ncalc,size(label),ubound(unitslabel,1)) + do i=1,nlab + if (len_trim(label(i))==0) cycle + if (len_trim(unitslabel(i)) > 0 .and. index(label(i),trim(unitslabel(i)))==0) then + print "(a)",trim(label(i))//trim(unitslabel(i)) + else + print "(a)",trim(label(i)) + endif + enddo + +end subroutine print_column_labels + +!----------------------------------------------------------------- +! +! print original column labels one per line (no units, no numbers) +! +!----------------------------------------------------------------- +subroutine print_column_labels_orig(ncolumns) + integer, intent(in) :: ncolumns + integer :: i,nlab + + nlab = min(ncolumns,size(labelorig)) + do i=1,nlab + if (len_trim(labelorig(i))==0) cycle + print "(a)",trim(labelorig(i)) + enddo + +end subroutine print_column_labels_orig + end module labels diff --git a/src/limits.f90 b/src/limits.f90 index d8ff47bd..7d66f906 100644 --- a/src/limits.f90 +++ b/src/limits.f90 @@ -86,7 +86,7 @@ subroutine set_limits(ifromstep,itostep,ifromcol,itocol,use_type) ! first = .true. do j=ifromcol,itocol - call warn_minmax(label(j),lim(j,1),lim(j,2),first) + if (iverbose >= 0) call warn_minmax(label(j),lim(j,1),lim(j,2),first) enddo lim2(ifromcol:itocol,:) = 0. @@ -121,12 +121,13 @@ end subroutine rescale_limits !---------------------------------------------------------- ! save plot limits for all columns to a file !---------------------------------------------------------- -subroutine write_limits(limitsfile) +subroutine write_limits(limitsfile,iverbose) use settings_data, only:numplot,ndataplots character(len=*), intent(in) :: limitsfile + integer, intent(in) :: iverbose integer :: i - print*,'saving plot limits to file ',trim(limitsfile) + if (iverbose >= 0) print*,'saving plot limits to file ',trim(limitsfile) open(unit=55,file=limitsfile,status='replace',form='formatted',ERR=998) do i=1,numplot @@ -145,10 +146,10 @@ subroutine write_limits(limitsfile) return 998 continue - print*,'*** error opening limits file: limits not saved' + if (iverbose >= 0) print*,'*** error opening limits file: limits not saved' return 999 continue - print*,'*** error saving limits' + if (iverbose >= 0) print*,'*** error saving limits' close(unit=55) end subroutine write_limits @@ -158,7 +159,7 @@ end subroutine write_limits !---------------------------------------------------------- subroutine read_limits(limitsfile,ierr) use labels, only:label - use settings_data, only:numplot,ncolumns,ncalc + use settings_data, only:numplot,ncolumns,ncalc,iverbose use asciiutils, only:ncolumnsline character(len=*), intent(in) :: limitsfile integer, intent(out) :: ierr @@ -176,7 +177,7 @@ subroutine read_limits(limitsfile,ierr) endif open(unit=54,file=limitsfile,status='old',form='formatted',err=997) - print "(a)",' read '//trim(limitsfile) + if (iverbose >= 0) print "(a)",' read '//trim(limitsfile) do i=1,numplot read(54,"(a)",err=998,end=999) line ncolsline = ncolumnsline(line) @@ -193,19 +194,21 @@ subroutine read_limits(limitsfile,ierr) ! !--warn if limits are the same ! - call warn_minmax(label(i),lim(i,1),lim(i,2)) + if (iverbose >= 0) call warn_minmax(label(i),lim(i,1),lim(i,2)) enddo close(unit=54) return 997 continue - print*,trim(limitsfile),' not found' + if (iverbose >= 0) print*,trim(limitsfile),' not found' ierr = 1 return 998 continue - call print_rangeinfo() - call print_lim2info() - print*,'*** error reading limits from file' + if (iverbose >= 0) then + call print_rangeinfo() + call print_lim2info() + print*,'*** error reading limits from file' + endif ierr = 2 close(unit=54) return @@ -213,13 +216,15 @@ subroutine read_limits(limitsfile,ierr) !--only give error if we really do not have enough columns ! (on first call nextra is not set) if (i < ncolumns+ncalc) then - print "(a,i3)",' end of file in '//trim(limitsfile)//': limits read to column ',i + if (iverbose >= 0) print "(a,i3)",' end of file in '//trim(limitsfile)//': limits read to column ',i ierr = -1 endif !--print info about range restrictions read from file - call print_rangeinfo() - call print_lim2info() + if (iverbose >= 0) then + call print_rangeinfo() + call print_lim2info() + endif close(unit=54) end subroutine read_limits diff --git a/src/menu.f90 b/src/menu.f90 index 3cd06231..29678200 100644 --- a/src/menu.f90 +++ b/src/menu.f90 @@ -37,7 +37,7 @@ subroutine menu use limits, only:write_limits,lim2,lim,reset_lim2,lim2set use options_data, only:submenu_data use settings_data, only:ndim,numplot,ndataplots,nextra,ncalc,ivegotdata, & - buffer_data,ncolumns,icoords,icoordsnew,iRescale + buffer_data,ncolumns,icoords,icoordsnew,iRescale,iverbose use settings_limits, only:submenu_limits,iadapt use settings_part, only:submenu_particleplots,mstari use settings_page, only:submenu_page,submenu_legend,interactive,nacross,ndown @@ -402,7 +402,7 @@ subroutine menu call set_filenames(trim(fileprefix)) endif call defaults_write(defaultsfile) - call write_limits(limitsfile) + call write_limits(limitsfile,iverbose) if (iRescale) call write_unitsfile(unitsfile,ncolumns) !------------------------------------------------------------------------ !+ Slightly obsolete: prints whatever help may be helpful diff --git a/src/read_data_sphNG.f90 b/src/read_data_sphNG.f90 index 857be5fa..c69d94e6 100644 --- a/src/read_data_sphNG.f90 +++ b/src/read_data_sphNG.f90 @@ -1516,10 +1516,13 @@ subroutine read_data_sphNG(rootname,indexstart,iposn,nstepsread) get_kappa_tot = lenvironment("SPLASH_GET_KAPPATOT") get_kappa = lenvironment("SPLASH_GET_KAPPA") .or. get_kappa_tot get_ionfrac = lenvironment("SPLASH_GET_ION") - if ((get_temperature .or. get_kappa) .and. itempcol > 0 .and. required(itempcol)) then - required(irho) = .true. - required(irhorestframe) = .true. - required(iutherm) = .true. + ! force read of rho/u when deriving T or kappa (itempcol may still be 0 on first call) + if (get_temperature .or. get_kappa) then + if (itempcol == 0 .or. required(itempcol)) then + if (irho > 0) required(irho) = .true. + if (irhorestframe > 0) required(irhorestframe) = .true. + if (iutherm > 0) required(iutherm) = .true. + endif endif if (get_ionfrac .or. get_kappa) then required(irho) = .true. @@ -1548,7 +1551,7 @@ subroutine read_data_sphNG(rootname,indexstart,iposn,nstepsread) enddo if (iverbose >= 1) print "(1x,a)",'reading sphNG format' - write(*,"(26('>'),1x,a,1x,26('<'))") trim(dumpfile) + if (iverbose >= 0) write(*,"(26('>'),1x,a,1x,26('<'))") trim(dumpfile) debug = lenvironment('SSPLASH_DEBUG') if (debug) iverbose = 1 @@ -2312,40 +2315,6 @@ subroutine read_data_sphNG(rootname,indexstart,iposn,nstepsread) if (allocated(iorig) .and. .not.got_iorig) deallocate(iorig) ! did not find id/iorig in dump call read_composition(compfile,ntotal,dat(:,:,j),icomp_col_start,ncomp,iorig) endif - ! - !--calculate the temperature from density and internal energy (using physical units) - ! - unit_dens = umass/(udist**3) - ! - !--use primitive density for relativistic code - ! - idenscol = irho - if (irhorestframe > 0) idenscol = irhorestframe - - if (get_temperature .and. itempcol > 0 .and. required(itempcol)) then - unit_ergg = (udist/utime)**2 - dat(1:ntotal,itempcol,j) = get_temp_from_u(dat(1:ntotal,idenscol,j)*unit_dens,dat(1:ntotal,iutherm,j)*unit_ergg) !irho = density - endif - if (get_kappa .and. ikappa > 0 .and. required(ikappa) .and. itemp > 0) then - write(*,"(1x,a,3(f5.2,1x))",advance='no') 'X,Y,Z = ',Xfrac,Yfrac,1.-Xfrac-Yfrac - if (get_kappa_tot) then - write(*,*) ' (opacity uses electron scattering, Kramers and H-)' - else - write(*,*) ' (electron scattering opacity only)' - endif - dat(1:ntotal,ikappa,j) = get_opacity(dat(1:ntotal,idenscol,j)*unit_dens,& - dat(1:ntotal,itemp,j)*1.d0,Xfrac,Yfrac,get_kappa_tot) - endif - if (get_ionfrac .and. iHIIcol > 0 .and. iHeIIcol > 0 .and. iHeIIIcol > 0& - .and. any(required(iHIIcol:iHeIIIcol))) then - do i=1,ntotal - call ionisation_fraction(real(dat(i,idenscol,j)*unit_dens),dat(i,itemp,j),& - real(Xfrac),real(Yfrac),xHIi,xHIIi,xHeIi,xHeIIi,xHeIIIi,nei) - dat(i,iHIIcol,j)=xHIIi - dat(i,iHeIIcol,j)=xHeIIi - dat(i,iHeIIIcol,j)=xHeIIIi - enddo - endif !--set flag to indicate that only part of this file has been read if (.not.all(required(1:ncolstep))) ipartialread = .true. @@ -2480,7 +2449,51 @@ subroutine read_data_sphNG(rootname,indexstart,iposn,nstepsread) endif iphasealloc + ! + !--set labels before deriving T/kappa so iutherm, itemp etc. are known + ! call set_labels_sphNG + ! + !--calculate temperature from density and internal energy (physical units) + ! must come after set_labels so the u column index (iutherm) is identified + ! + unit_dens = umass/(udist**3) + !--use primitive density for relativistic code + idenscol = irho + if (irhorestframe > 0) idenscol = irhorestframe + + if (get_temperature .and. itempcol > 0 .and. required(itempcol)) then + if (iutherm > 0 .and. idenscol > 0) then + unit_ergg = (udist/utime)**2 + dat(1:ntotal,itempcol,j) = get_temp_from_u(dat(1:ntotal,idenscol,j)*unit_dens,& + dat(1:ntotal,iutherm,j)*unit_ergg) + else + if (iverbose >= 0) print "(a)",' WARNING: --temp requested but cannot locate density/u columns; temperature not computed' + endif + endif + if (get_kappa .and. ikappa > 0 .and. required(ikappa) .and. itemp > 0 .and. idenscol > 0) then + if (iverbose >= 0) then + write(*,"(1x,a,3(f5.2,1x))",advance='no') 'X,Y,Z = ',Xfrac,Yfrac,1.-Xfrac-Yfrac + if (get_kappa_tot) then + write(*,*) ' (opacity uses electron scattering, Kramers and H-)' + else + write(*,*) ' (electron scattering opacity only)' + endif + endif + dat(1:ntotal,ikappa,j) = get_opacity(dat(1:ntotal,idenscol,j)*unit_dens,& + dat(1:ntotal,itemp,j)*1.d0,Xfrac,Yfrac,get_kappa_tot) + endif + if (get_ionfrac .and. iHIIcol > 0 .and. iHeIIcol > 0 .and. iHeIIIcol > 0& + .and. any(required(iHIIcol:iHeIIIcol)) .and. idenscol > 0 .and. itemp > 0) then + do i=1,ntotal + call ionisation_fraction(real(dat(i,idenscol,j)*unit_dens),dat(i,itemp,j),& + real(Xfrac),real(Yfrac),xHIi,xHIIi,xHeIi,xHeIIi,xHeIIIi,nei) + dat(i,iHIIcol,j)=xHIIi + dat(i,iHeIIcol,j)=xHeIIi + dat(i,iHeIIIcol,j)=xHeIIIi + enddo + endif + if (.not.phantomdump) then if (ngas /= npart - nptmassi - ndust - nstar - nunknown) & print*,'WARNING!!! ngas =',ngas,'but should be',npart-nptmassi-ndust-nstar-nunknown diff --git a/src/set_options_from_dataread.f90 b/src/set_options_from_dataread.f90 index a7ca6eee..6b633d73 100644 --- a/src/set_options_from_dataread.f90 +++ b/src/set_options_from_dataread.f90 @@ -55,7 +55,7 @@ subroutine set_options_dataread() if (iverbose >= 1) print "(a)",' (plotting of '//trim(labeltype(itype))//' particles turned ON)' endif enddo - print* + if (iverbose >= 1) print* endif ! Set particle colouring if it can't render if (irho==0 .or. ih==0) then @@ -78,7 +78,7 @@ subroutine set_options_dataread() !--for fits cubes, turn on cross section by default if 3D if (ndim >= 3 .and. .not.idefaults_file_read .and. ifileopen > 0) then ! only on first data read if (index(rootname(ifileopen),'.fits') > 0) then - print "(a)",' turning cross section ON for fits cube' + if (iverbose >= 0) print "(a)",' turning cross section ON for fits cube' xsec_nomulti = .true. endif endif diff --git a/src/splash.f90 b/src/splash.f90 index ee35fe45..ab15dcf1 100644 --- a/src/splash.f90 +++ b/src/splash.f90 @@ -646,12 +646,13 @@ program splash use projections3D, only:setup_integratedkernel use settings_data, only:buffer_data,lowmemorymode,debugmode,ndim,ncolumns,iexact,& ncalc,nextra,numplot,ndataplots,device,ivegotdata,iautorender,& - track_string,iRescale,enforce_code_units,UseTypeinRenderings + track_string,iRescale,enforce_code_units,UseTypeinRenderings,& + iverbose,iCalcQuantities use system_commands, only:get_number_arguments,get_argument use system_utils, only:lenvironment,renvironment,envlist, & get_environment_or_flag,get_command_option,get_command_flag use asciiutils, only:read_asciifile,basename,match_column,& - sort_filenames_for_comparison,split,extension + sort_filenames_for_comparison,split_string,extension use write_pixmap, only:isoutputformat,iwritepixmap,pixmapformat,isinputformat,ireadpixmap,readpixformat use convert, only:convert_all use write_sphdata, only:issphformat @@ -668,12 +669,15 @@ program splash use set_options_from_dataread, only:set_options_dataread use exact, only:ispiral,nfiles_exact=>nfiles,filename_exact use multiplot, only:itrans - use labels, only:lenlabel,label,unitslabel,shortlabel,irho + use labels, only:lenlabel,label,unitslabel,shortlabel,irho,& + print_headers,print_column_labels,print_column_labels_orig use interactive_routines, only:set_movie_mode + use particle_data, only:headervals implicit none integer :: i,ierr,nargs,ipickx,ipicky,irender,icontour,ivecplot,il logical :: ihavereadfilenames,evsplash,doconvert,useall,iexist,use_360,got_format,do_multiplot logical :: using_default_options,got_exact,sort,sort_pad,exact_flag + logical :: do_print_header,do_print_labels,do_print_labelsorig character(len=120) :: string,exactfile character(len=12) :: convertformat character(len=lenlabel) :: stringx,stringy,stringr,stringc,stringv @@ -712,6 +716,9 @@ program splash nomenu = .false. got_format = .false. got_exact = .false. + do_print_header = .false. + do_print_labels = .false. + do_print_labelsorig = .false. ipickx = 0 ipicky = 0 irender = 0 @@ -836,6 +843,12 @@ program splash case('-formats') call print_available_formats stop + case('header','-header') + do_print_header = .true. + case('labels','-labels') + do_print_labels = .true. + case('labelsorig','-labelsorig') + do_print_labelsorig = .true. case('-help') call print_usage print "(/,a,/)",'Userguide: https://splash-viz.readthedocs.io' @@ -898,14 +911,22 @@ program splash endif endif ! - ! print header + ! quiet mode for --header / --labels: skip banner and suppress read chatter ! - call print_header + if (.not.(do_print_header .or. do_print_labels .or. do_print_labelsorig)) call print_header + ! + ! set quiet before defaults_set so even early messages honour iverbose=-1 + ! + if (do_print_header .or. do_print_labels .or. do_print_labelsorig) iverbose = -1 ! ! set default options (used if defaults file does not exist) ! call defaults_set(evsplash) if (use_360) call defaults_set_360() + ! + ! re-apply quiet settings (defaults_set resets iverbose) + ! + if (do_print_header .or. do_print_labels .or. do_print_labelsorig) iverbose = -1 ! ! read default options from file if it exists @@ -929,13 +950,21 @@ program splash else defaultsfile = trim(string)//'.defaults' endif - print "(a)",' Using SPLASH_DEFAULTS='//trim(defaultsfile) + if (iverbose >= 0) print "(a)",' Using SPLASH_DEFAULTS='//trim(defaultsfile) call defaults_read(defaultsfile) call set_filenames(trim(fileprefix)) using_default_options = .false. endif endif + ! + ! re-apply quiet settings after defaults (namelist may reset iCalcQuantities) + ! + if (do_print_header .or. do_print_labels .or. do_print_labelsorig) then + iverbose = -1 + if (do_print_header .and. .not.do_print_labels .and. .not.do_print_labelsorig) iCalcQuantities = .false. + endif + ! ! set options based on command line flags that OVERRIDE settings in the defaults file ! @@ -979,7 +1008,7 @@ program splash endif elseif (got_exact) then iexact = 2 ! override setting in defaults file - call split(exactfile,',',filename_exact,nfiles_exact) + call split_string(exactfile,',',filename_exact,nfiles_exact) endif if (get_command_flag('code')) then iRescale = .false. @@ -1000,7 +1029,7 @@ program splash endif if (nfiles >= 1 .and. rootname(1)(1:1) /= ' ') then ihavereadfilenames = .true. - if (nfiles > 1) print*,nfiles,' filenames read from command line' + if (nfiles > 1 .and. iverbose >= 0) print*,nfiles,' filenames read from command line' else ihavereadfilenames = .false. !print "(a)",' no filenames read from command line' @@ -1016,7 +1045,7 @@ program splash stop endif endif - if (lowmemorymode) print "(a)",' << running in low memory mode >>' + if (lowmemorymode .and. iverbose >= 0) print "(a)",' << running in low memory mode >>' ! ! Guess format if not already set @@ -1036,12 +1065,12 @@ program splash !--if no kernel has been set call get_environment_or_flag('SPLASH_KERNEL',string) if (len_trim(string) > 0) then - call select_kernel_by_name(string) + call select_kernel_by_name(string,verbose=(iverbose >= 0)) else - call select_kernel(0) + call select_kernel(0,verbose=(iverbose >= 0)) endif else - call select_kernel(ikernel) + call select_kernel(ikernel,verbose=(iverbose >= 0)) endif ! set geometry defaults @@ -1069,6 +1098,17 @@ program splash ! call set_options_dataread() ! + ! print header tags/values and/or column labels, then exit + ! + if (do_print_header .or. do_print_labels .or. do_print_labelsorig) then + if (do_print_header .and. allocated(headervals)) then + call print_headers(headervals(:,1)) + endif + if (do_print_labels) call print_column_labels(ncolumns,ncalc) + if (do_print_labelsorig) call print_column_labels_orig(ncolumns) + stop + endif + ! ! translate from string to column id ! if (nomenu) then @@ -1256,6 +1296,9 @@ subroutine print_usage(quit) print "(a)",' -b, --buffer : buffer all data files into memory' !print "(a)",' -lm, -lowmem : use low memory mode [applies only to sphNG data read at present]' print "(a)",' -o pixformat : dump pixel map in specified format (use just -o for list of formats)' + print "(a)",' --header : print dump file header tags and values, then exit' + print "(a)",' --labels : print column labels one per line, then exit' + print "(a)",' --labelsorig : print original column labels (no units), then exit' print "(/,a,/)",'Command line plotting mode:' print "(a)",' -x column : x axis' print "(a)",' -y column : y axis' diff --git a/src/units.f90 b/src/units.f90 index 5cf856ef..6c90de44 100644 --- a/src/units.f90 +++ b/src/units.f90 @@ -587,7 +587,7 @@ subroutine read_unitsfile(unitsfile,ncolumns,ierr,iverbose) !--only give error if we really do not have enough columns ! (on first call nextra is not set) if (i <= ncolumns) then - print "(1x,a,i2)",'end of file in '//trim(unitsfile)//': units read to column ',i + if (isverbose >= 0) print "(1x,a,i2)",'end of file in '//trim(unitsfile)//': units read to column ',i ierr = -1 endif if (ierrzunits .and. ndim==3) then