Skip to content

Commit

Permalink
Merge pull request #707 from galacticusorg/fixOutputNameSpaces
Browse files Browse the repository at this point in the history
Strip leading and trailing spaces from the output file name
  • Loading branch information
abensonca authored Sep 22, 2024
2 parents b3ca016 + cf510cd commit 7f2a178
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 6 additions & 1 deletion source/display.banner.F90
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,19 @@ subroutine Display_Banner_Show
!!}
use, intrinsic :: ISO_Fortran_Env, only : output_unit
use :: Display , only : displayVerbosity, verbosityLevelSilent
use :: System_Output , only : stdOutIsATTY
#ifdef USEMPI
use :: MPI_Utilities , only : mpiSelf
#else
use :: System_Output , only : stdOutIsATTY
#endif
implicit none
#ifdef USEMPI
if (mpiSelf%rank() == 0) then
#endif
if (displayVerbosity() > verbosityLevelSilent) then
! Display the logo only if not compiled using MPI. MPI intercepts `stdout` making it impossible for us to know if we are
! outputting to a `TTY` or not
#ifndef USEMPI
if (stdOutIsATTY()) then
! Display our ASCII art logo. This was created using the `px2ansi` tool (https://github.com/Nellousan/px2ansi) from
! https://github.com/galacticusorg/galacticus/blob/master/doc/New_Logo_Galaxy_192_Transparent.png after reducing to
Expand Down Expand Up @@ -84,6 +88,7 @@ subroutine Display_Banner_Show
write (output_unit,*) "                                                                "
write (output_unit,*) ""
end if
#endif
write (output_unit,*) ' ## '
write (output_unit,*) ' #### # # '
write (output_unit,*) ' # # # # '
Expand Down
10 changes: 8 additions & 2 deletions source/output.HDF5.open.F90
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ subroutine Output_HDF5_Open_File(parameters)
use :: HDF5_Access , only : hdf5Access
use :: IO_HDF5 , only : IO_HDF5_Set_Defaults
use :: ISO_Varying_String, only : var_str , char , operator(//) , extract , &
& len , operator(==)
& len , operator(==) , adjustl , trim
use :: Input_Parameters , only : inputParameters , inputParameter
#ifdef USEMPI
use :: MPI_Utilities , only : mpiSelf
Expand All @@ -67,6 +67,7 @@ subroutine Output_HDF5_Open_File(parameters)
integer(hsize_t ) :: chunkSize
integer :: sieveBufferSize
integer(size_t ) :: cacheElementsCount, cacheSizeBytes
type (varying_string ) :: outputFileName_ , outputScratchFileName_
#ifdef USEMPI
type (varying_string ) :: fileNamePrefix
#endif
Expand All @@ -75,13 +76,15 @@ subroutine Output_HDF5_Open_File(parameters)
!![
<inputParameter>
<name>outputFileName</name>
<variable>outputFileName_</variable>
<defaultValue>var_str('galacticus.hdf5')</defaultValue>
<description>The name of the file to which \glc\ results will be written.</description>
<source>parameters</source>
</inputParameter>
<inputParameter>
<name>outputScratchFileName</name>
<defaultValue>outputFileName</defaultValue>
<variable>outputScratchFileName_</variable>
<defaultValue>outputFileName_</defaultValue>
<description>The name of the file to which \glc\ results will be written temporarily during runs.</description>
<source>parameters</source>
</inputParameter>
Expand Down Expand Up @@ -120,6 +123,9 @@ subroutine Output_HDF5_Open_File(parameters)
</inputParameter>
!!]
hdf5CacheSizeBytes=cacheSizeBytes
! Remove leadimg and trailing spaces.
outputFileName =trim(adjustl(outputFileName_ ))
outputScratchFileName=trim(adjustl(outputScratchFileName_))
! Modify the file name on a per-process basis if running under MPI.
#ifdef USEMPI
if (extract(outputFileName ,len(outputFileName )-4,len(outputFileName )) == ".hdf5") then
Expand Down

0 comments on commit 7f2a178

Please sign in to comment.