| 30 | == Using COMM_model == |
| 31 | |
| 32 | Frequently the parallelization of a model is initialized in the model by the lines: |
| 33 | {{{ |
| 34 | CALL MPI_Init(ierr) |
| 35 | CALL MPI_Comm_Rank(MPI_COMM_WORLD, rank, ierr) |
| 36 | CALL MPI_Comm_Size(MPI_COMM_WORLD, size, ierr) |
| 37 | }}} |
| 38 | Here, the call to `MPI_init` is mandatory, while the two other lines are optional, but common. If the model itself is not parallelized, the MPI-initialization will not be present. Please see the section '[#Non-parallelmodels Non-parallel models]' below for this case. |
| 39 | |
| 40 | Subsequently, one can define `COMM_model` by |
| 41 | {{{ |
| 42 | COMM_model = MPI_COMM_WORLD |
| 43 | }}} |
| 44 | In addition, the variable `COMM_model` has to be declared in a way such that all routines using the communicator can access it. The parallelization variables of the model are frequently held in a Fortran module. In this case, it is easiest to add `COMM_model` as an integer variable here. (The tutorial declares `COMM_model` and other parallelization-related variables in `mod_parallel.F90`) |
| 45 | |
| 46 | Having defined the communicator `COMM_model`, the communicator `MPI_COMM_WORLD` has to be replaced by `COMM_model` in all routines that perform MPI communication, except in calls to `MPI_init`, `MPI_finalize`, and `MPI_abort`. |
| 47 | The changes described by now must not influence the execution of the model itself. Thus, after these changes, one can run the model to ensure that the model compiles and runs correctly. |
| 48 | |
| 49 | |
47 | | Frequently the parallelization of a model is initialized in the model by the lines: |
48 | | {{{ |
49 | | CALL MPI_Init(ierr) |
50 | | CALL MPI_Comm_Rank(MPI_COMM_WORLD, rank, ierr) |
51 | | CALL MPI_Comm_Size(MPI_COMM_WORLD, size, ierr) |
52 | | }}} |
53 | | (The call to `MPI_init` is mandatory, while the two other lines are optional) If the model itself is not parallelized, the MPI-initialization will not be present. Please see the section '[#Non-parallelmodels Non-parallel models]' below for this case. |
54 | | |
55 | | Subsequently, one can define `COMM_model` by |
56 | | {{{ |
57 | | COMM_model = MPI_COMM_WORLD |
58 | | }}} |
59 | | In addition, the variable `COMM_model` has to be declared in a way such that all routines using the communicator can access it. The parallelization variables of the model are frequently held in a Fortran module. In this case, it is easiest to add `COMM_model` as an integer variable here. (The tutorial declares `COMM_model` and other parallelization-related variables in `mod_parallel.F90`) |
60 | | |
61 | | Having defined the communicator `COMM_model`, the communicator `MPI_COMM_WORLD` has to be replaced by `COMM_model` in all routines that perform MPI communication, except in calls to `MPI_init`, `MPI_finalize`, and `MPI_abort`. |
62 | | The changes described by now must not influence the execution of the model itself. Thus, after these changes, one can run the model to ensure that the model compiles and runs correctly. |