4 Fortran, C and python equivalent examples
Different examples implementing the different parts of the API with the Fortran, C and python interfaces are provided as practical illustrations in directory /pyoasis/examples :
- 1-serial: one coupling exchange between a serial sender and a serial receiver.
- 2-apple: one coupling exchange between an Apple-parallel sender and a serial receiver; an additonal component, not part of the coupling, is also started and the example shows how to use the commworld argument, in Fortran and C, and the communicator optional argument when setting the component in python.
- 3-box: one coupling exchange between an Box-parallel sender and a serial receiver; it shows also how to check if a coupling field declared in the code is activated in the configuration file namcouple.
- 4-orange: one coupling exchange between an Orange-parallel sender and a serial receiver; not all processes of the sender participate in the coupling and this example shows how to use create_couplcomm.
- 5-points: one coupling exchange between a Point-parallel sender and a serial receiver.
- 6-apple_and_orange: one coupling exchange between an Apple-parallel sender and an Orange-parallel receiver; not all processes of the sender participate in the coupling and this example shows how to use set_couplcomm.
- 7-multiple-puts: two coupling fields are both sent from a serial sender to two different serial receivers; this example also sets up an intra communicator between the sender and one receiver and an inter communicator between the sender and the other receiver.
- 8-interoperability/fortran_and_C: implements a coupling of a bundle field, with two bundle elements, between a Fortran Apple-parallel sender and a C component. This C component is Orange-parallel for the reception of the bundle field; it also defines another partition of type Box onto which a second coupling field is defined and sent to a third Fortran serial receiver. The sum of the Box partitions in the C component does not cover the global grid, hence the fourth argument ig_size is used to specify the grid global size. The C component also illustrates how the order of the partition definition does not need to be the same for the different processes but that, in that case, a meaningful name fifth argument must be used.
- 8-interoperability/fortran_and_python: implements the same coupling exchanges than 8-interoperability/fortran_and_C but with the C component replaced by a python component.
- 9-python_fortran_C-multi_intracomm: illustrates the set-up of an intracommunicator between a Fortran, a C and a python components using OASIS3-MCT; a bcast is then realised to share some data. In this example, an additional component is also launched at start but does not participate in the coupling and hence uses the coupled third argument of oasis_initi_comp.
- 10-grid: a single Box-parallel component defines and writes two grids pyoa and mono, the first one with distributed calls from all the processes, the second one from the master process only.
- 11-test-interpolation: one exchange of a coupling bundle field defined on real grids involving a first-order concervative regridding between an Apple-parallel sender and a serial receiver. In the Fortran and C examples, the grids are fixed, while in the python example, the user chooses the source and target grids interactively, among the ones available in the files available in the common_data directory. This example produces graphical output of the received fields if the following packages are installed
- pip3 install matplotlib
- pip3 install scipy
- pip3 install cartopy
- pip3 uninstall shapely
- pip3 install shapely -no-binary shapely
- 12-grid-functions: Graphical version of 10-grid (i.e. the pyoa grid layout is displayed if the same graphical packages than for 11-test-interpolation are installed).
The different examples can be launched with the Makefile from
directory /pyoasis using targets examples, examples_f or
examples_c to run respectively python, Fortran and C examples.