MCNP Problem - Bad character in column 2

In summary, the conversation discusses an error that is caused by using tabs instead of spaces in the input file for a code descended from FORTRAN. Another issue is the need for specific blank lines between cell cards, surface cards, and data/source sections. The speaker suggests using a simple text editor to edit the file and making sure there are no extra blank lines. The other speaker confirms trying to fix the issue but still encountering the same problem.
  • #1
KOKI
4
0
TL;DR Summary
hello , I am getting an error that reads as follows:

1 PX 12.5

bad trouble in imcn in routine ckchar

bad character, probably a control character, in column 2
hello , I am getting an error that reads as follows:
1 PX 12.5
bad trouble in imcn in routine ckchar
bad character, probably a control character, in column 2Cell cards
1 0 1 -2 -7 8 10 -9 imp: n=1
2 0 2 -3 -7 8 10 -9 imp: n=0
3 0 3 -4 -7 8 10 -9 imp: n=1
4 0 4 -5 -7 8 10 -9 imp: n=0
5 0 5 -6 -7 8 10 -9 imp: n=1
6 0 -14 #1 #2 #3 #4 #5 #7 imp: n=0
7 0 -11 -12 13 imp: n=1
8 0 14 imp:n=0c Surface cards
1 PX 12.5
2 PX 15
3 PX 15.05
4 PX 16.05
5 PX 16.1
6 PX 21.1
7 PY 5
8 PY -5
9 PZ 5
10 PZ -5
11 CX 0.5
12 PX 0
13 PX -1
14 SO 30
 
Engineering news on Phys.org
  • #2
Try attaching your input file, you will need to rename it to add .txt at the end.

How are you editing it? With a simple text editor?

This is usually a formatting char problem.
 
  • #3
bien
 
  • #4
:
 

Attachments

  • beam-stop01.txt
    957 bytes · Views: 73
  • #5
The error is that you are using tabs instead of spaces. This code is descended from things written in the 1970's, on mainframes, in FORTRAN, by physicists. Some aspects are not very flexible.

A second problem is that the gap between the cell cards and the surface cards needs to be a single blank line. The gap between the surface cards and the data/source section also needs a blank line but more may not matter. The extra blank lines in that section may also be fine, without trying it I'm not sure, but normally that is not done.
 
  • Like
Likes mfb
  • #6
Alex A said:
The error is that you are using tabs instead of spaces. This code is descended from things written in the 1970's, on mainframes, in FORTRAN, by physicists. Some aspects are not very flexible.

A second problem is that the gap between the cell cards and the surface cards needs to be a single blank line. The gap between the surface cards and the data/source section also needs a blank line but more may not matter. The extra blank lines in that section may also be fine, without trying it I'm not sure, but normally that is not done.
I tried but I find the same problem
 
  • #7
KOKI said:
I tried but I find the same problem
What does "tried" mean here? Did you replace the tabs with ordinary space characters? Did you make sure there was exactly one blank line between cells and surfaces, exactly one blank line between surfaces and data, and no other blank lines?
 
  • #8
KOKI said:
I tried but I find the same problem
Sometimes the name of your input file create problems, do not put any space in your input file . such as you can write mcnpcode.txt but you cannot write mcnp code.txt .. The input file that you run dislikes any space between it. And try to make your input file as short as possible. I am a victim of that kind of error .
 

1. What does the error "MCNP Problem - Bad character in column 2" mean?

This error message typically indicates that there is an unexpected or invalid character in the second column of a line within your MCNP (Monte Carlo N-Particle) input file. MCNP is sensitive to the format and positioning of characters in the input file, as each position can specify different parameters or settings. A "bad character" error suggests that the character does not conform to what the program expects at that specific location.

2. How can I locate and correct the "Bad character in column 2" error in my MCNP input file?

To correct this error, you should open your input file in a text editor that displays line numbers and inspect the second column of each line. Look for any characters that might be out of place, such as alphabetic characters where only numeric values or specific symbols are expected, or unexpected spaces. Ensure that the structure of the input lines strictly follows the MCNP formatting rules, which often include specific column positions for different types of data.

3. Can this error be caused by issues other than an actual bad character in the input file?

Yes, while the most common cause is indeed an incorrect character in the file, other issues might also trigger this error. For instance, if the file encoding or line endings are not compatible with what MCNP expects, it might misinterpret the contents, leading to errors. Ensure your file is saved with the correct encoding (typically ASCII) and that line endings match the expected Unix or Windows style, depending on your operating platform.

4. What tools can help me avoid formatting errors like "Bad character in column 2" in MCNP input files?

Using a text editor with MCNP syntax highlighting or column number display can significantly help in avoiding formatting errors. Some editors can be configured to highlight syntax specific to MCNP, which makes it easier to spot misplaced characters. Additionally, using MCNP-specific input preparation tools or software that checks the syntax before running the simulation can prevent such errors from occurring in the first place.

5. Is there a way to automatically correct formatting issues in MCNP input files?

While there is no universal tool that automatically corrects all formatting issues in MCNP input files, some script-based tools and utilities have been developed by the MCNP user community to assist in validating and correcting common errors. These scripts can be run prior to simulation to check for and sometimes correct issues like misplaced characters, incorrect data types, or alignment errors. However, manual review is often necessary to ensure the accuracy and appropriateness of the input file's content.

Similar threads

Replies
6
Views
1K
  • Nuclear Engineering
Replies
4
Views
2K
Replies
3
Views
2K
Replies
6
Views
1K
  • Nuclear Engineering
Replies
3
Views
1K
  • Nuclear Engineering
Replies
7
Views
541
  • Nuclear Engineering
Replies
1
Views
1K
  • Nuclear Engineering
Replies
4
Views
2K
  • Nuclear Engineering
Replies
5
Views
1K
Replies
0
Views
314
Back
Top