Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use output_unit and error_unit from ISO_Fortran_Env to direct all output #691

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions perl/Galacticus/Build/SourceTree/Process/ThreadSafeIO.pm
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ sub Lock_IO {
my $isExplicit = ! defined($1);
$processedLine =~ s/\(gfortranInternalIO\)/(gfortranInternalIO_)/;
if ( $report && $isExplicit ) {
$processedLine = $processedLine." write (0,*) '*** thread ',OMP_Get_Thread_Num(),' acquired the ''gfortranInternalIO'' lock'\n" ;
$processedLine = $processedLine." write (output_unit,*) '*** thread ',OMP_Get_Thread_Num(),' acquired the ''gfortranInternalIO'' lock'\n" ;
$ignoreLine = 1;
&addUse($node);
}
Expand All @@ -67,7 +67,7 @@ sub Lock_IO {
my $isExplicit = ! defined($1);
$processedLine =~ s/\(gfortranInternalIO\)/(gfortranInternalIO_)/;
if ( $report && $isExplicit ) {
$processedLine = " write (0,*) '*** thread ',OMP_Get_Thread_Num(),' acquired the ''gfortranInternalIO'' lock'\n".$processedLine;
$processedLine = " write (output_unit,*) '*** thread ',OMP_Get_Thread_Num(),' acquired the ''gfortranInternalIO'' lock'\n".$processedLine;
$ignoreLine = 1;
&addUse($node);
}
Expand All @@ -80,9 +80,9 @@ sub Lock_IO {
if ( $report ) {
&addUse($node);
if ( defined($1) ) {
$rawLine = " write (0,*) '*** thread ',OMP_Get_Thread_Num(),' released the ''gfortranInternalIO'' lock'\n".$rawLine;
$rawLine = " write (output_unit,*) '*** thread ',OMP_Get_Thread_Num(),' released the ''gfortranInternalIO'' lock'\n".$rawLine;
} else {
$rawLine = $rawLine." write (0,*) '*** thread ',OMP_Get_Thread_Num(),' acquired the ''gfortranInternalIO'' lock'\n" ;
$rawLine = $rawLine." write (output_unit,*) '*** thread ',OMP_Get_Thread_Num(),' acquired the ''gfortranInternalIO'' lock'\n" ;
}
}
}
Expand All @@ -100,14 +100,14 @@ sub Lock_IO {
$inIO = 1;
$newContent .= " !\$omp critical(gfortranInternalIO_)\n";
if ( $report ) {
$newContent .= " write (0,*) '*** thread ',OMP_Get_Thread_Num(),' acquired the ''gfortranInternalIO'' lock'\n";
$newContent .= " write (output_unit,*) '*** thread ',OMP_Get_Thread_Num(),' acquired the ''gfortranInternalIO'' lock'\n";
&addUse($node);
}
}
if ( ! $isIO && $inIO && ! $inCritical && ! $ignoreLine ) {
$inIO = 0;
if ( $report ) {
$newContent .= " write (0,*) '*** thread ',OMP_Get_Thread_Num(),' released the ''gfortranInternalIO'' lock'\n";
$newContent .= " write (output_unit,*) '*** thread ',OMP_Get_Thread_Num(),' released the ''gfortranInternalIO'' lock'\n";
&addUse($node);
}
$newContent .= " !\$omp end critical(gfortranInternalIO_)\n";
Expand All @@ -117,7 +117,7 @@ sub Lock_IO {
close($content);
if ( $inIO && ! $inCritical && ! $ignoreLine ) {
if ( $report ) {
$newContent .= " write (0,*) '*** thread ',OMP_Get_Thread_Num(),' released the ''gfortranInternalIO'' lock'\n";
$newContent .= " write (output_unit,*) '*** thread ',OMP_Get_Thread_Num(),' released the ''gfortranInternalIO'' lock'\n";
&addUse($node);
}
$newContent .= " !\$omp end critical(gfortranInternalIO_)\n";
Expand Down
7 changes: 4 additions & 3 deletions source/XRay_Absorption_ISM_Wilms2000.F90
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,15 @@ subroutine xermsg(a,b,c,i,j)
!!{
Error message function required by {\normalfont \ttfamily dotbvabs}.
!!}
use, intrinsic :: ISO_Fortran_Env, only : output_unit
use :: Error, only : Error_Report
implicit none
character(len=*), intent(in ) :: a, b, c
integer , intent(in ) :: i, j

write (0,*) a
write (0,*) b
write (0,*) c
write (output_unit,*) a
write (output_unit,*) b
write (output_unit,*) c
call Error_Report('error thrown by XSpec functions'//{introspection:location})
return
end subroutine xermsg
Expand Down
43 changes: 22 additions & 21 deletions source/benchmarks.stellar_luminosities.F90
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,27 @@ program Benchmark_Stellar_Populations_Luminosities
!!{
Benchmarking of stellar population luminosity calculations.
!!}
use :: Abundances_Structure , only : abundances , metallicityTypeLinearByMassSolar
use :: Cosmology_Functions , only : cosmologyFunctionsMatterLambda
use :: Cosmology_Parameters , only : cosmologyParametersSimple
use :: Display , only : displayVerbositySet , verbosityLevelWorking
use :: Input_Paths , only : inputPath , pathTypeDataDynamic , pathTypeDataStatic
use :: ISO_Varying_String , only : char , operator(//) , var_str
use :: Input_Parameters , only : inputParameters
use :: Instruments_Filters , only : Filter_Get_Index
use :: Kind_Numbers , only : kind_int8
use :: Stellar_Astrophysics , only : stellarAstrophysics , stellarAstrophysicsFile
use :: Stellar_Astrophysics_Tracks , only : stellarTracksFile
use :: Stellar_Astrophysics_Winds , only : stellarWindsLeitherer1992
use :: Stellar_Feedback , only : stellarFeedbackStandard
use :: Stellar_Population_Broad_Band_Luminosities, only : stellarPopulationBroadBandLuminositiesStandard
use :: Stellar_Population_Spectra , only : stellarPopulationSpectraFile
use :: Stellar_Population_Spectra_Postprocess , only : stellarPopulationSpectraPostprocessorIdentity , stellarPopulationSpectraPostprocessorList
use :: Stellar_Populations , only : stellarPopulationStandard
use :: Stellar_Populations_Initial_Mass_Functions, only : initialMassFunctionChabrier2001
use :: Supernovae_Population_III , only : supernovaePopulationIIIHegerWoosley2002
use :: Supernovae_Type_Ia , only : supernovaeTypeIaNagashima2005
use, intrinsic :: ISO_Fortran_Env, only : output_unit
use :: Abundances_Structure , only : abundances , metallicityTypeLinearByMassSolar
use :: Cosmology_Functions , only : cosmologyFunctionsMatterLambda
use :: Cosmology_Parameters , only : cosmologyParametersSimple
use :: Display , only : displayVerbositySet , verbosityLevelWorking
use :: Input_Paths , only : inputPath , pathTypeDataDynamic , pathTypeDataStatic
use :: ISO_Varying_String , only : char , operator(//) , var_str
use :: Input_Parameters , only : inputParameters
use :: Instruments_Filters , only : Filter_Get_Index
use :: Kind_Numbers , only : kind_int8
use :: Stellar_Astrophysics , only : stellarAstrophysics , stellarAstrophysicsFile
use :: Stellar_Astrophysics_Tracks , only : stellarTracksFile
use :: Stellar_Astrophysics_Winds , only : stellarWindsLeitherer1992
use :: Stellar_Feedback , only : stellarFeedbackStandard
use :: Stellar_Population_Broad_Band_Luminosities, only : stellarPopulationBroadBandLuminositiesStandard
use :: Stellar_Population_Spectra , only : stellarPopulationSpectraFile
use :: Stellar_Population_Spectra_Postprocess , only : stellarPopulationSpectraPostprocessorIdentity , stellarPopulationSpectraPostprocessorList
use :: Stellar_Populations , only : stellarPopulationStandard
use :: Stellar_Populations_Initial_Mass_Functions, only : initialMassFunctionChabrier2001
use :: Supernovae_Population_III , only : supernovaePopulationIIIHegerWoosley2002
use :: Supernovae_Type_Ia , only : supernovaeTypeIaNagashima2005
implicit none
type (inputParameters ), target :: parameters
integer , parameter :: filterCount = 137 , populationCount =20, &
Expand Down Expand Up @@ -230,7 +231,7 @@ program Benchmark_Stellar_Populations_Luminosities
& /sqrt( dble(trialCount-2) &
& )
! Report benchmark information.
write (0,'(a,1x,a,1x,a,f12.1,1x,f12.1,1x,a1,a2,a1)') 'BENCHMARK','stellarPopulationInterpolation','"Stellar population interpolation"',timeMean,timeMeanError,'"',trim(adjustl(units)),'"'
write (output_unit,'(a,1x,a,1x,a,f12.1,1x,f12.1,1x,a1,a2,a1)') 'BENCHMARK','stellarPopulationInterpolation','"Stellar population interpolation"',timeMean,timeMeanError,'"',trim(adjustl(units)),'"'
! Clean up.
call parameters%destroy()
end program Benchmark_Stellar_Populations_Luminosities
Expand Down
54 changes: 30 additions & 24 deletions source/display.F90
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ subroutine displayIndentChar(message,verbosity)
!!{
Increase the indentation level and display a message.
!!}
!$ use :: OMP_Lib, only : OMP_In_Parallel, OMP_Get_Thread_Num
use , intrinsic :: ISO_Fortran_Env, only : output_unit
!$ use :: OMP_Lib , only : OMP_In_Parallel, OMP_Get_Thread_Num
implicit none
character(len=* ), intent(in ) :: message
type (enumerationVerbosityLevelType), intent(in ), optional :: verbosity
Expand All @@ -199,14 +200,14 @@ subroutine displayIndentChar(message,verbosity)
call initialize()
if (showMessage(verbosity)) then
!$ if (omp_in_parallel()) then
!$ write (0,threadFormat) omp_get_thread_num(),": "
!$ write (output_unit,threadFormat) omp_get_thread_num(),": "
!$ else
!$ write (0,masterFormat) ": "
!$ write (output_unit,masterFormat) ": "
!$ end if
threadNumber=1
!$ if (omp_in_parallel()) threadNumber=omp_get_thread_num()+1
write (0,indentationFormatNoNewLine(threadNumber)) '-> '
write (0,'(a)') trim(message)
write (output_unit,indentationFormatNoNewLine(threadNumber)) '-> '
write (output_unit,'(a)') trim(message)
!$ if (omp_in_parallel()) then
!$ indentationLevel(omp_get_thread_num()+1)=indentationLevel(omp_get_thread_num()+1)+1
!$ else
Expand Down Expand Up @@ -235,7 +236,8 @@ subroutine displayUnindentChar(message,verbosity)
!!{
Decrease the indentation level and display a message.
!!}
!$ use :: OMP_Lib, only : OMP_In_Parallel, OMP_Get_Thread_Num
use , intrinsic :: ISO_Fortran_Env, only : output_unit
!$ use :: OMP_Lib , only : OMP_In_Parallel, OMP_Get_Thread_Num
implicit none
character(len=* ), intent(in ) :: message
type (enumerationVerbosityLevelType), intent(in ), optional :: verbosity
Expand All @@ -251,14 +253,14 @@ subroutine displayUnindentChar(message,verbosity)
!$ end if
call formatIndentationCreate()
!$ if (omp_in_parallel()) then
!$ write (0,threadFormat) omp_get_thread_num(),": "
!$ write (output_unit,threadFormat) omp_get_thread_num(),": "
!$ else
!$ write (0,masterFormat) ": "
!$ write (output_unit,masterFormat) ": "
!$ end if
threadNumber=1
!$ if (omp_in_parallel()) threadNumber=omp_get_thread_num()+1
write (0,indentationFormatNoNewLine(threadNumber)) '<- '
write (0,'(a)') trim(message)
write (output_unit,indentationFormatNoNewLine(threadNumber)) '<- '
write (output_unit,'(a)') trim(message)
end if
!$omp end critical(Display_Lock)
return
Expand All @@ -268,7 +270,8 @@ subroutine displayMessageChar(message,verbosity)
!!{
Display a message (input as a {\normalfont \ttfamily character} variable).
!!}
!$ use :: OMP_Lib, only : OMP_In_Parallel, OMP_Get_Thread_Num
use , intrinsic :: ISO_Fortran_Env, only : output_unit
!$ use :: OMP_Lib , only : OMP_In_Parallel, OMP_Get_Thread_Num
implicit none
character(len=* ), intent(in ) :: message
type (enumerationVerbosityLevelType), intent(in ), optional :: verbosity
Expand All @@ -279,13 +282,13 @@ subroutine displayMessageChar(message,verbosity)
if (showMessage(verbosity)) then
if (barVisible) call counterClearLockless()
!$ if (omp_in_parallel()) then
!$ write (0,threadFormat) omp_get_thread_num(),": "
!$ write (output_unit,threadFormat) omp_get_thread_num(),": "
!$ else
!$ write (0,masterFormat) ": "
!$ write (output_unit,masterFormat) ": "
!$ end if
threadNumber=1
!$ if (omp_in_parallel()) threadNumber=omp_get_thread_num()+1
write (0,indentationFormat(threadNumber)) trim(message)
write (output_unit,indentationFormat(threadNumber)) trim(message)
if (barVisible) call displayCounterLockless(barPercentage,.true.)
end if
!$omp end critical(Display_Lock)
Expand All @@ -296,8 +299,9 @@ subroutine displayMessageVarStr(message,verbosity)
!!{
Display a message (input as a {\normalfont \ttfamily varying\_string} variable).
!!}
!$ use :: OMP_Lib , only : OMP_In_Parallel, OMP_Get_Thread_Num
use :: ISO_Varying_String, only : varying_string , char
use , intrinsic :: ISO_Fortran_Env , only : output_unit
!$ use :: OMP_Lib , only : OMP_In_Parallel, OMP_Get_Thread_Num
use :: ISO_Varying_String, only : varying_string , char
implicit none
type (varying_string ), intent(in ) :: message
type (enumerationVerbosityLevelType), intent(in ), optional :: verbosity
Expand All @@ -308,13 +312,13 @@ subroutine displayMessageVarStr(message,verbosity)
if (showMessage(verbosity)) then
if (barVisible) call counterClearLockless()
!$ if (omp_in_parallel()) then
!$ write (0,threadFormat) omp_get_thread_num(),": "
!$ write (output_unit,threadFormat) omp_get_thread_num(),": "
!$ else
!$ write (0,masterFormat) ": "
!$ write (output_unit,masterFormat) ": "
!$ end if
threadNumber=1
!$ if (omp_in_parallel()) threadNumber=omp_get_thread_num()+1
write (0,indentationFormat(threadNumber)) char(message)
write (output_unit,indentationFormat(threadNumber)) char(message)
if (barVisible) call displayCounterLockless(barPercentage,.true.)
end if
!$omp end critical(Display_Lock)
Expand Down Expand Up @@ -370,6 +374,7 @@ subroutine displayCounterLockless(percentageComplete,isNew,verbosity)
!!{
Displays a percentage counter and bar to show progress.
!!}
use, intrinsic :: ISO_Fortran_Env, only : output_unit
implicit none
integer , intent(in ) :: percentageComplete
logical , intent(in ) :: isNew
Expand All @@ -385,9 +390,9 @@ subroutine displayCounterLockless(percentageComplete,isNew,verbosity)
majorCount=percentage/2
minorCount=percentage-majorCount*2
bar=repeat("=",majorCount)//repeat("-",minorCount)//repeat(" ",50-majorCount-minorCount)
write (0,'(1x,i3,"% [",a50,"]",$)') percentage,bar
write (output_unit,'(1x,i3,"% [",a50,"]",$)') percentage,bar
! For output to a file, add a newline, since we will not be deleting the bar.
if (stdOutIsFile) write (0,*)
if (stdOutIsFile) write (output_unit,*)
barVisible =.true.
barPercentage=percentageComplete
end if
Expand All @@ -413,16 +418,17 @@ subroutine counterClearLockless(verbosity)
!!{
Clears a percentage counter.
!!}
use, intrinsic :: ISO_Fortran_Env, only : output_unit
implicit none
type(enumerationVerbosityLevelType), intent(in ), optional :: verbosity

call initialize()
! If output is to a file we do not attempt to clear the bar (which is useful only on a TTY).
if (stdOutIsFile) return
if (showMessage(verbosity)) then
write (0,'(a58,$)') repeat(char(8),58)
write (0,'(a58,$)') repeat(" " ,58)
write (0,'(a58,$)') repeat(char(8),58)
write (output_unit,'(a58,$)') repeat(char(8),58)
write (output_unit,'(a58,$)') repeat(" " ,58)
write (output_unit,'(a58,$)') repeat(char(8),58)
end if
return
end subroutine counterClearLockless
Expand Down
Loading
Loading