The following guidelines will help you to print a new variable in a BP file.
One can add a cell or face array variable to a BP file from any routine of the code, the variable can be global or locally defined.
Moreover, it is possible to integrate better this process and link the print to a user interface keyword.
At the beginning of your routine, use the variables_output module:
use variables_output
Then, you can add a scalar or vector field to the print field list with:
call print_list%add_field( your_scalar_field, 'your_scalar_field_name' ) call print_list%add_field( your_face_field, 'your_face_field_name')
If you want to control the print thanks to the user interface, you have to add a new keyword, a new Fortran logical print variable and eventually modify the output_grids_and_fields.f90 routine
Image you compute the enstrophy, and you would like to print it as any other field such as temperature, pressure, etc.
First, in variables_output module (in src/lib/io/grids_and_fields/variables.f90), add a logical among the is_print_...
declarations as follow:
logical :: is_print_enstrophy = .false.
Please keep it in alphabetical order.
Then, add a keyword in keywords.inc (in src/notus/ui directory).
Please keep it in alphabetical order.
Next, you have to modify the post_processing block of the NTS file to add the enstrophy keyword into the output fields list of variables. To do so, in mod_ui_parse_post_processing module (src/lib/notus/ui/tree/post_processing/block_reader.f90) routine, in case(kw_output_fields)
section, add:
case(kw_enstrophy) is_print_enstrophy = .true.
Modify the post processing block documentation.
Now you are able to modify the routine that writes BP file by adding the following line in the Add scalar section of the routine:
if (is_print_enstrophy) call add_field_to_list(print_list, enstrophy, 'enstrophy')
Notice that enstrophy
field should be computed in output_grids_and_fields.f90 or be accessible thanks to a module that contains this array.