Error due to line in input file longer than 4095 characters

GROMACS version: 2020.2
GROMACS modification: No

Hey guys!

I’m currently attempting to run a coarse-grained MD simulation on a large protein (>15000 residues) on Gromacs 2020.2, but I get the following error after minimization (attached below). There seems to be a few lines (one denoting the residue codes in order, and one denoting the secondary structure designations for all of them) that exceed 4095 lines, and I think they’re causing this error. Does anyone know how I can fix this?

I’ve seen other posts with the same issue in Gromacs 4.6.5, and some comments mention to edit the file “src/gromacs/gmxpreprocess/readir.cpp.” However, I couldn’t find this file in the Gromacs directory.


Program: gmx grompp, version 2020.2
Source file: src/gromacs/utility/cstringutil.cpp (line 97)

Fatal error:
An input file contains a line longer than 4095 characters, while the buffer
passed to fgets2 has size 4095. The line starts with: ‘; NKSQLYPDSPLTDQDFNQ’

For more information and tips for troubleshooting, please check the GROMACS
website at Errors - Gromacs

What input files and which type of input them are causing the issues?


It seems that the *.itp files that my *.top file is referencing have extremely long lines, due to the number of residues in my protein structure. The issue arises when I try to create a *.tpr file for minimization (before solvating the structure).


I don’t see how a line in the topology can get beyond 4095 characters because you have residue number requiring 5 digits. Could you post a problematic line?

It seems that the long line in the *.itp file is there because Martini (which I’m using for coarse-graining) automatically adds a sequence and secondary structure codes for each residue at the beginning of the file:

; MARTINI (martini22) Coarse Grained topology file for “Protein_A”
; Created by py version 2.6
; Using the following options: -f enc_clean.pdb -o -x enc-cg.pdb -p backbone -ff martini22
; Sequence:


; Secondary Structure:


I guess this part of the file is not crucial for the run, so I think I’ll remove it for now, but then use it again when generating the trajectory files at the end, so that all atoms appear (and not just the backbone).