Feature request: add comment lines to the ascii .post.res file using gidpost-2.13

I would like to insert some comment lines into the header of the ASCII .post.res file, such as:

GiD Post Results File 1.2

# Some comment lines

# Sat Aug 16 08:31:49 JST 2025

# Foo bar

Result “SomeValues” “SomeProblem” 1 Scalar OnNodes
Unit “degree”
Values
1 0.0000000e+002 100.0000000e+00
End Values

Could you add a new function to enable this feature in gidpost-2.13?

@miguel can you check this?

I think that if you add those comments to the .res ascii file, GiD accepts them. but it’s true that I think that there is not a function to write comments from C / C++.

It may be interesting to add this feature.

Javi Gárate
GiD Team

A drawback to add this function to print comments from gidpost is that doesn’t has sense in case of write binary or HDF5 format, because these files cannot be viewed by a text editor. ASCII format is only recommended for debug, or the be written easily without gidpost.

Binary and HDF5 are more efficient options (smaller disk size and faster to be read, in particular HDF5 allow read the result headers without require to load the whole data)

My understanding is that comments can be inserted into the ATTRIBUTE field when using the HDF5 format. Is this incorrect?

While it is possible to implement the coding to insert comments myself, it is non-standard and results in ugly coding.

Dear Hemmi Shigeru,

In gidpost there is no function ‘per se’ to add a comment in the output files.
Instead you can use these functions to achieve (almost) the same result:

  • int GiD_fWriteMeshUserAttribute( GiD_FILE fd, GP_CONST char *Name, GP_CONST char *Value );
  • int GiD_fWriteResultUserAttribute( GiD_FILE fd, GP_CONST char *Name, GP_CONST char *Value );
  • Note: for ASCII/binary output internally both functions do the same, can be called anywhere., and write a comment line like this:
    # attrName: attrVale
  • Note: for HDF5 output, these functions must be called after a GiD_fBeginMesh and GiD_fBeginResult respectively, as this UserAttribute is inserted as hdf5 ATTRIBUTE in the mesh/result block.
  • Check the examples/testpost.c file for their use.

In ASCII / binary output files both functions write a comment line in the mesh/results files with the pair attrName : attrValue :


  ...  
  GiD_fBeginMeshColor( fdm, "TestMesh", GiD_2D, GiD_Triangle, 3, 0, 0.99, 0);
  GiD_fWriteMeshUserAttribute( fdm, "myMeshAttr", "myMeshValue" );
  ...
  GiD_fBeginResult( fdr, "debug nodes", analysis, step_value, GiD_Scalar, GiD_OnNodes, NULL, NULL, 0, NULL );
  GiD_fWriteResultUserAttribute( fdr, "myResultAttr", "my Result value" );
  ...

the ASCII output result will be like this:

mesh file:
...
MESH "TestMesh" dimension 2 ElemType Triangle Nnode 3
# color 0.000000 0.990000 0.000000
# myMeshAttr: myMeshValue
Coordinates
...

result file:
...
Result "debug nodes" "Analysis_of whatever" 1 Scalar OnNodes
# myResultAttr: my Result value
Values
...

and the HDF5 output would be like this:

Hope it helps,

Best regards,

Miguel Pasenau

the GiD Team

Update:

Before, i mentioned that when the output is HDF5, both calls GiD_fWriteMeshUserAttribute and GiD_fWriteResultUserAttribute should be used after GiD_fBeginMesh* and GiD_fBeginResult*, but for ASCII/binary output they can be used also before these GiD_fBegin*calls.

In the next gidpost version, when using HDF5 output, both GiD_fWrite*UserAttribute calls can also be used before GiD_fBegin (thus having the same behaviour for all outputs). The UserAttributes will be inserted in the Meshes and Results group respectively:

Best regards,

Miguel Pasenau

the GiD Team

Miguel Pasenau, thank you for your support. I think HDF5 files are very sophisticated and excellent. I haven’t used them before, but I plan to use them going forward.