ecmwf / multio

MultIO is a runtime-configurable multiplexer for Weather Model output of GRIB data
Apache License 2.0
7 stars 8 forks source link

dimension of domain data is hard coded to be 11 #6

Closed suvarchal closed 1 year ago

suvarchal commented 1 year ago

assertion tests if dimension is 11, https://github.com/ecmwf/multio/blob/9de276aad666441d02b36bd213b2baa3b71c3029/src/multio/domain/Domain.cc#L68

assertion it seems bit unnecessary to me, but i don't know much, except that it imposes a hard constraint on dimensions of data that is passed to xx_write_domain methods for structured grids.

dsarmany commented 1 year ago

This restriction comes from the way the local-to-global mapping is defined for the structured grids that the NEMOv4 ocean model uses. This is practically identical to domain described in Chapter 5 in the XIOS documentation: https://forge.ipsl.jussieu.fr/ioserver/raw-attachment/wiki/WikiStart/XIOS_user_guide.pdf

That said, it would be perfectly fine to use a different convention of local-to-global mapping for structured grids. But then the logic has to be implemented and reflected in creating the global fields from local ones.

suvarchal commented 1 year ago

The thought came from trying to adapt nemo-like example to write custom domain mapping for an unstructured model prototype. For which i later realized i should use in fortran cerr = md%set_string_value("representation", "unstructured"). To me to be able to map domain from local to global we provide local indices w.r global indices via data using write_domain methods, for instance here is cut-down fortran snippet

        integer   :: buffer(100)
        cerr = md%set_string_value("name", "T Grid")
        if (cerr /= MULTIO_SUCCESS) ERROR STOP 10
        cerr = md%set_string_value("category", "ocean-domain-map")
        if (cerr /= MULTIO_SUCCESS) ERROR STOP 11
        cerr = md%set_string_value("representation", "unstructured")
        if (cerr /= MULTIO_SUCCESS) ERROR STOP 12
        cerr = md%set_int_value("globalSize", 700 )
        if (cerr /= MULTIO_SUCCESS) ERROR STOP 12
        cerr = md%set_bool_value("toAllServers", .TRUE._1)
        if (cerr /= MULTIO_SUCCESS) ERROR STOP 14

        buffer=[(i+myrank*100-1, i=1,100)]

        cerr = mio%write_domain(md, buffer, size(buffer))

buffer in above case was of 7 model-clients communicating to 1 server and each has a chunk size of 100. This works but thought no matter what these indices are for structured case (i am guessing cartesian topology map) still thought restricting to 11 as size should put constrains on how model is decomposed for parallel execution. May be i don't grasp it well enough :). Also if multio was not used by nemo but some other structured model would it still make sense.... it doesn't concern me much right now as i need just the unstructured case.