[1682] | 1 | !> @file init_coupling.f90 |
---|
[4648] | 2 | !--------------------------------------------------------------------------------------------------! |
---|
[2696] | 3 | ! This file is part of the PALM model system. |
---|
[1036] | 4 | ! |
---|
[4648] | 5 | ! PALM is free software: you can redistribute it and/or modify it under the terms of the GNU General |
---|
| 6 | ! Public License as published by the Free Software Foundation, either version 3 of the License, or |
---|
| 7 | ! (at your option) any later version. |
---|
[1036] | 8 | ! |
---|
[4648] | 9 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the |
---|
| 10 | ! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
---|
| 11 | ! Public License for more details. |
---|
[1036] | 12 | ! |
---|
[4648] | 13 | ! You should have received a copy of the GNU General Public License along with PALM. If not, see |
---|
| 14 | ! <http://www.gnu.org/licenses/>. |
---|
[1036] | 15 | ! |
---|
[4360] | 16 | ! Copyright 1997-2020 Leibniz Universitaet Hannover |
---|
[4648] | 17 | !--------------------------------------------------------------------------------------------------! |
---|
[1036] | 18 | ! |
---|
[484] | 19 | ! Current revisions: |
---|
[206] | 20 | ! ----------------- |
---|
[4648] | 21 | ! |
---|
| 22 | ! |
---|
[1321] | 23 | ! Former revisions: |
---|
| 24 | ! ------------------ |
---|
| 25 | ! $Id: init_coupling.f90 4648 2020-08-25 07:52:08Z monakurppa $ |
---|
[4648] | 26 | ! file re-formatted to follow the PALM coding standard |
---|
| 27 | ! |
---|
| 28 | ! 4564 2020-06-12 14:03:36Z raasch |
---|
[4564] | 29 | ! Vertical nesting method of Huq et al. (2019) removed |
---|
[4648] | 30 | ! |
---|
[4564] | 31 | ! 4444 2020-03-05 15:59:50Z raasch |
---|
[4444] | 32 | ! bugfix: cpp-directives for serial mode added |
---|
[4648] | 33 | ! |
---|
[4444] | 34 | ! 4360 2020-01-07 11:25:50Z suehring |
---|
[4182] | 35 | ! Corrected "Former revisions" section |
---|
[4648] | 36 | ! |
---|
[4182] | 37 | ! 3655 2019-01-07 16:51:22Z knoop |
---|
[3232] | 38 | ! references to mrun replaced by palmrun, and updated |
---|
[2716] | 39 | ! |
---|
[4182] | 40 | ! 222 2009-01-12 16:04:16Z letzel |
---|
| 41 | ! Initial revision |
---|
| 42 | ! |
---|
[206] | 43 | ! Description: |
---|
| 44 | ! ------------ |
---|
[4648] | 45 | !> Initializing coupling via MPI-1 or MPI-2 if the coupled version of PALM is called. |
---|
| 46 | !--------------------------------------------------------------------------------------------------! |
---|
[1682] | 47 | SUBROUTINE init_coupling |
---|
[206] | 48 | |
---|
[4648] | 49 | |
---|
| 50 | USE control_parameters, & |
---|
[1320] | 51 | ONLY: coupling_char, coupling_mode |
---|
[4648] | 52 | |
---|
[1320] | 53 | USE kinds |
---|
[4648] | 54 | |
---|
[206] | 55 | USE pegrid |
---|
| 56 | |
---|
| 57 | IMPLICIT NONE |
---|
| 58 | |
---|
| 59 | ! |
---|
| 60 | !-- Local variables |
---|
[4444] | 61 | #if defined( __parallel ) |
---|
[1682] | 62 | INTEGER(iwp) :: i !< |
---|
| 63 | INTEGER(iwp) :: inter_color !< |
---|
[4444] | 64 | #endif |
---|
[4648] | 65 | |
---|
[1682] | 66 | INTEGER(iwp), DIMENSION(:) :: bc_data(0:3) = 0 !< |
---|
[206] | 67 | |
---|
| 68 | ! |
---|
[4648] | 69 | !-- Get information about the coupling mode from the environment variable which has been set by the |
---|
| 70 | !-- mpiexec command. |
---|
| 71 | !-- This method is currently not used because the mpiexec command is not available on some machines. |
---|
[1808] | 72 | ! CALL GET_ENVIRONMENT_VARIABLE( 'coupling_mode', coupling_mode, i ) |
---|
[206] | 73 | ! IF ( i == 0 ) coupling_mode = 'uncoupled' |
---|
| 74 | ! IF ( coupling_mode == 'ocean_to_atmosphere' ) coupling_char = '_O' |
---|
| 75 | |
---|
| 76 | ! |
---|
[4648] | 77 | !-- Get information about the coupling mode from standard input (PE0 only) and distribute it to the |
---|
| 78 | !-- other PEs. Distribute PEs to 2 new communicators. |
---|
[206] | 79 | !-- ATTENTION: numprocs will be reset according to the new communicators |
---|
[222] | 80 | #if defined ( __parallel ) |
---|
[667] | 81 | |
---|
[206] | 82 | IF ( myid == 0 ) THEN |
---|
| 83 | READ (*,*,ERR=10,END=10) coupling_mode, bc_data(1), bc_data(2) |
---|
| 84 | 10 CONTINUE |
---|
| 85 | IF ( TRIM( coupling_mode ) == 'coupled_run' ) THEN |
---|
| 86 | i = 1 |
---|
| 87 | ELSE |
---|
| 88 | i = 0 |
---|
| 89 | ENDIF |
---|
[291] | 90 | bc_data(0) = i |
---|
| 91 | |
---|
| 92 | ! |
---|
[4648] | 93 | !-- Check if '_O' has to be used as file extension in an uncoupled ocean run. This is required, |
---|
| 94 | !-- if this run shall be continued as a coupled run. |
---|
[291] | 95 | IF ( TRIM( coupling_mode ) == 'precursor_ocean' ) bc_data(3) = 1 |
---|
| 96 | |
---|
[206] | 97 | ENDIF |
---|
| 98 | |
---|
[291] | 99 | CALL MPI_BCAST( bc_data(0), 4, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr ) |
---|
[206] | 100 | i = bc_data(0) |
---|
| 101 | |
---|
[2365] | 102 | IF ( i == 0 ) THEN |
---|
[206] | 103 | coupling_mode = 'uncoupled' |
---|
[691] | 104 | ! |
---|
| 105 | !-- In case of a precursor ocean run, an additional flag file is created. |
---|
| 106 | !-- This is necessary for data_output_2d_on_each_pe = .T. |
---|
| 107 | IF ( bc_data(3) == 1 ) THEN |
---|
| 108 | OPEN( 90, FILE='PRECURSOR_OCEAN', FORM='FORMATTED' ) |
---|
| 109 | WRITE ( 90, '(''TRUE'')' ) |
---|
| 110 | CLOSE ( 90 ) |
---|
| 111 | ENDIF |
---|
[206] | 112 | ELSE |
---|
| 113 | comm_inter = MPI_COMM_WORLD |
---|
| 114 | |
---|
| 115 | IF ( myid < bc_data(1) ) THEN |
---|
[667] | 116 | inter_color = 0 |
---|
| 117 | numprocs = bc_data(1) |
---|
| 118 | coupling_mode = 'atmosphere_to_ocean' |
---|
[206] | 119 | ELSE |
---|
[667] | 120 | inter_color = 1 |
---|
| 121 | numprocs = bc_data(2) |
---|
| 122 | coupling_mode = 'ocean_to_atmosphere' |
---|
[206] | 123 | ENDIF |
---|
[667] | 124 | |
---|
[206] | 125 | CALL MPI_COMM_SPLIT( MPI_COMM_WORLD, inter_color, 0, comm_palm, ierr ) |
---|
| 126 | comm2d = comm_palm |
---|
| 127 | |
---|
| 128 | ! |
---|
[4648] | 129 | !-- Write a flag file for the ocean model and the other atmosphere processes. |
---|
[206] | 130 | OPEN( 90, FILE='COUPLING_PORT_OPENED', FORM='FORMATTED' ) |
---|
| 131 | WRITE ( 90, '(''TRUE'')' ) |
---|
| 132 | CLOSE ( 90 ) |
---|
| 133 | ENDIF |
---|
| 134 | #endif |
---|
| 135 | |
---|
[291] | 136 | ! |
---|
[4648] | 137 | !-- In case of a precursor ocean run (followed by a coupled run), or a coupled atmosphere-ocean run, |
---|
| 138 | !-- set the file extension for the ocean files. |
---|
| 139 | IF ( TRIM( coupling_mode ) == 'ocean_to_atmosphere' .OR. bc_data(3) == 1 ) THEN |
---|
[291] | 140 | coupling_char = '_O' |
---|
| 141 | ENDIF |
---|
[206] | 142 | |
---|
| 143 | END SUBROUTINE init_coupling |
---|