Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create MONC IO side of diagnostics in Fortran #3

Open
leifdenby opened this issue May 16, 2018 · 2 comments
Open

Create MONC IO side of diagnostics in Fortran #3

leifdenby opened this issue May 16, 2018 · 2 comments

Comments

@leifdenby
Copy link
Collaborator

leifdenby commented May 16, 2018

Instead of having to define in XML which MPI reduction and local reduction operations the aim is to be able to do this in Fortran. These definitions will reside inside the individual component which currently make their "component fields" visible to the MONC server. By having these definitions together in the same source file and both in Fortran the hope is that development and maintenance will be easier.

Resources:

@leifdenby
Copy link
Collaborator Author

The current steps to get a component field (e.g. horizontal mean theta profile) written to output is:

  1. profile_diagnostics_get_descriptor: the component indicates which fields
    it publishes and where to get information and data on these fields

  2. field_information_retrieval_callback Ensure that the "component field" is
    "enabled" so that the IO server knows it can request its data

  3. timestep_callback On every timestep update local value which
    is to be sent to IO server based on "current state"

  4. field_value_retrieval_callback provide local value so that it can be sent
    to the IO server

  5. data-definition: indicate which "component fields" the IO server expects
    from MONC and at what frequency

  6. data-handling: do MPI and local reductions of received fields and create
    a new "IO field" only available to the IO server

  7. group & data-writing create field groups of fields available on IO
    server and indicate which files will include field groups

I'm a suggesting that 4. and 5. will be handled in Fortran in future by:

  1. data-definition: indicate which "component fields" the IO server expects
    from MONC and at what frequency

    • add in profile_diagnostics_get_descriptor a pointer to the subroutine
      which on the IO server should handle data reduction and which component
      fields it will need
  2. data-handling: do MPI and local reductions of received fields and create
    a new "IO field" only available to the IO server

    • add new subroutine in component module which handles MPI and local
      reductions using fortran routines and "publishes" "IO fields" (making
      them only available locally on the IO server)

      • created as linked list, each io operation is a function which takes the
        last operation as an argument and returns a new one with the operation
        added

@leifdenby
Copy link
Collaborator Author

Practically this could be achieved by making MONC components register their IO-server side operations on init. Similarly to how a subroutine from each component is automatically called when MONC is initialised a routine which indicates which IO-server side operations are needed (to produce IO-server fields) could be added.

This could look something like:

subroutine register_IO_server_operations(io_server_operations)
    io_server_operations%num_operations = 1

    io_server_operation%operation_definition => io__for_global_theta_horizontal_mean
    io_server_operation%name = "theta_mean"
    io_server_operation%namespace = "profile_fields"
    io_server_operation%generation_timestep_frequency = 1

    io_server_operations%operations(1) = io_server_operation
end subroutine register_IO_server_operations

subroutine io__for_global_theta_horizontal_mean(root)
    type(io_operation_type), intent(in) :: root
    type(io_operation_type) :: last_op

    last_op = io_require(from=root, field="theta_total_local")
    last_op = io_sum(from=last_op, location="local")  ! local/global denoting whether the reduction is across all MONC IO server or on each individually
    last_op = io_scale(from=last_op, by="domain_size")
end subroutine

The final subroutine simply defines (using a linked-list datatype) first what MONC component fields are needed and what operations should be done.

These subroutines which define the io-server side operations could then be generalised and re-used across-multiple components and could even by combined with the MONC-side definition so that producing a horizontal mean profile for e.g. theta could be achieved simply trough one instruction. The MONC-side and IO server-side operations could then be called automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant