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

Bug in egs_input.cpp that effects egs_glib #1124

Open
Apelova opened this issue May 1, 2024 · 2 comments
Open

Bug in egs_input.cpp that effects egs_glib #1124

Apelova opened this issue May 1, 2024 · 2 comments
Assignees
Labels

Comments

@Apelova
Copy link

Apelova commented May 1, 2024

When trying to import a previously defined geometry using egs_glib quite a nerve wracking Bug occurs if there is a space before the line break.

I attached a simple Input-File for the usercode tutor7pp (and a geometry-file) that demonstrates the issue at hand (just comment/uncomment the lines 10 and 11 and make sure that sphere.geom is in the correct directory). It took me quite some time to realize what was happening when this bug first occurred, but after checking the source code, I recognized that the code only clears spaces in front of the file name to be imported.

The Bug can easily be fixed by inserting the line below in line 892 of egs_input.cpp

value = (*(value.end()-1) == ' ') ? string(value.begin(), value.end()-1) : value ;

Tutor7pp Input File

##############################################################
# Tutor7pp Input-File to reproduce Bug in egs_input.cpp
##############################################################

:start geometry definition:
	:start geometry:
		library = egs_glib
		name = imported_sphere 
		#--- to reproduce the bug comment/uncomment the two lines below
		include file = sphere.geom#<--- works
		#include file = sphere.geom #<--- doesn't work 
	:stop geometry:

	simulation geometry = imported_sphere
:stop geometry definition:




###########################################
:start source definition:
    :start source:
        library = egs_parallel_beam
        name = the_source
        :start shape:
            type = point
            position = 0 0 1e-7
        :stop shape:
        direction = 0 0 1
        charge = -1
        :start spectrum:
            type = monoenergetic
            energy = 20.0
        :stop spectrum:
    :stop source:

    simulation source = the_source
:stop source definition:

######################################## Run control
:start run control:
    ncase = 100
:stop run control:

Geometry File

:start geometry definition:
	 :start geometry:
        name     = Sphere
        library  = egs_spheres
        midpoint = 0 0 0
        radii    = 2
        :start media input:
            media = H2O521ICRU
            set medium = 0 0
        :stop media input:
    :stop geometry:
	
	simulation geometry = Sphere
:stop geometry definition:

Operating system

  • [x ] Linux

EGSnrc version
2023

@Apelova Apelova added the bug label May 1, 2024
@rtownson rtownson self-assigned this May 1, 2024
@rtownson
Copy link
Collaborator

rtownson commented May 1, 2024

Thanks for reporting this and including a fix!

Note to self: make sure to also account for the case where there are many tabs or spaces.

@Apelova
Copy link
Author

Apelova commented May 2, 2024

P.S. I forgot to mention that I tested this fix against multiple arrangements of whitespace after and before the file name, and it seemed to fix all of them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants