How can I get a topology file with full parameters expanded?

Hello,
Usually, in the .top file, several .itp files are included for each molecule type in the system. How can I get a complete .top file with all the parameters being expanded? I found that the -pp options of gmx grompp can get an processed .top file, but I think it has two disadvantages.
The first is it must have a .mdp file to use gmx grompp -pp. And the second one, most importantly for me, is that in the processed .top file, it doesn’t contain the coefficients for bonds, angles, and dihedrals.
Could you please tell me does Gromacs has a built-in tool that can generate a .top file with complete parameters? For example, for section dihedrals

[ dihedrals ]
 17  16  14  15  3 C0 C1 C2 C3 C4 C5

I would like to know all the parameters for the function type 3 dihedrals. And also the same requirement applies to bonds and angles.
Any help would be much appreciated!

To my knowledge there is no such tool built-in, because a fully expanded parameter table is not stored in the tpr files.

Instead, there is a list of bonds, stored with the atoms involved, the function type (e.g. Angle, Dihedral, improper) and an interaction type (a integer) - and there is a list of interaction type, from 0 to N, with parameters for the bond. During the simulation, for each bond, the parameters are looked-up in the interaction type table.

You can get both the interaction function table, and the bond table, with gmx dump -s runfile.tpr, and associate them with a bit of scripting (probably, regexp).

The interaction table looks like this:

         functype[118]=LJ_SR, c6= 0.00000000e+00, c12= 0.00000000e+00
         functype[119]=LJ_SR, c6= 9.28111258e-04, c12= 3.09248890e-06
         functype[120]=LJ_SR, c6= 1.21614011e-02, c12= 8.83721732e-05
         functype[121]=BONDS, b0A= 1.52200e-01, cbA= 2.65266e+05, b0B= 1.52200e-01, cbB= 2.65266e+05
         functype[127]=ANGLES, thA= 1.09500e+02, ctA= 2.92880e+02, thB= 1.09500e+02, ctB= 2.92880e+02
         functype[128]=ANGLES, thA= 1.09500e+02, ctA= 4.18400e+02, thB= 1.09500e+02, ctB= 4.18400e+02
         functype[137]=ANGLES, thA= 1.11100e+02, ctA= 5.27184e+02, thB= 1.11100e+02, ctB= 5.27184e+02
         functype[138]=ANGLES, thA= 1.09500e+02, ctA= 3.34720e+02, thB= 1.09500e+02, ctB= 3.34720e+02
         functype[139]=ANGLES, thA= 1.17000e+02, ctA= 5.85760e+02, thB= 1.17000e+02, ctB= 5.85760e+02
         functype[140]=ANGLES, thA= 1.26000e+02, ctA= 6.69440e+02, thB= 1.26000e+02, ctB= 6.69440e+02
         functype[141]=PDIHS, phiA= 0.00000000e+00, cpA= 3.34719992e+00, phiB= 0.00000000e+00, cpB= 3.34719992e+00, mult=1
         functype[142]=PDIHS, phiA= 1.80000000e+02, cpA= 3.34719986e-01, phiB= 1.80000000e+02, cpB= 3.34719986e-01, mult=3
         functype[143]=PDIHS, phiA= 1.80000000e+02, cpA= 1.04600000e+01, phiB= 1.80000000e+02, cpB= 1.04600000e+01, mult=2
         functype[144]=PDIHS, phiA= 0.00000000e+00, cpA= 8.36800003e+00, phiB= 0.00000000e+00, cpB= 8.36800003e+00, 
         functype[162]=LJ14, c6A= 4.31535700e-05, c12A= 5.36973888e-09, c6B= 4.31535700e-05, c12B= 5.36973888e-09
         functype[163]=LJ14, c6A= 1.41338352e-03, c12A= 2.18213040e-06, c6B= 1.41338352e-03, c12B= 2.18213040e-06

and the list of bond like this:

      Bond:
         nr: 39
         iatoms:
            0 type=121 (BONDS)   0   4
            1 type=122 (BONDS)   4   5
            2 type=123 (BONDS)   4   6
            3 type=124 (BONDS)   6   8
            4 type=125 (BONDS)   8  10
            5 type=121 (BONDS)   8  19
            6 type=125 (BONDS)  10  13
            7 type=121 (BONDS)  13  16
            8 type=126 (BONDS)  16  17
            9 type=126 (BONDS)  16  18
            10 type=122 (BONDS)  19  20
            11 type=123 (BONDS)  19  21
            12 type=124 (BONDS)  21  23
      G96Bond:
         nr: 0
      Morse:
         nr: 0
      Cubic Bonds:
         nr: 0
      Restraint Pot.:
         nr: 0
      Angle:
         nr: 180
         iatoms:
            0 type=127 (ANGLES)   1   0   2
            1 type=127 (ANGLES)   1   0   3
            2 type=128 (ANGLES)   1   0   4
            3 type=127 (ANGLES)   2   0   3
            4 type=128 (ANGLES)   2   0   4
            5 type=128 (ANGLES)   3   0   4
            6 type=129 (ANGLES)   0   4   5
            7 type=130 (ANGLES)   0   4   6
            8 type=131 (ANGLES)   5   4   6
            9 type=132 (ANGLES)   4   6   7

You store the interaction table, then for each bond you lookup the interaction using the, e.g., type=127 label, then probably store them then output them as expected for a .top file.

Possibly such a script already exist somewhere on the web.

Hello,
Thank you very very much for the very detailed explanation!
I am very sorry for the late reply.
This looks nice but is very complicated for me, I am trying to find something else like ParmEd, but if Gromacs has a built-in function that would be more reliable.
If I understand correctly, the coefficients are looked up from ffbonded.itp but I feel if I do the matching myself, it is still too much work for me.