source: palm/trunk/SOURCE/init_coupling.f90 @ 4276

Last change on this file since 4276 was 4182, checked in by scharf, 5 years ago
  • corrected "Former revisions" section
  • minor formatting in "Former revisions" section
  • added "Author" section
  • Property svn:keywords set to Id
File size: 5.4 KB
RevLine 
[1682]1!> @file init_coupling.f90
[2000]2!------------------------------------------------------------------------------!
[2696]3! This file is part of the PALM model system.
[1036]4!
[2000]5! PALM is free software: you can redistribute it and/or modify it under the
6! terms of the GNU General Public License as published by the Free Software
7! Foundation, either version 3 of the License, or (at your option) any later
8! version.
[1036]9!
10! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
11! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13!
14! You should have received a copy of the GNU General Public License along with
15! PALM. If not, see <http://www.gnu.org/licenses/>.
16!
[3655]17! Copyright 1997-2019 Leibniz Universitaet Hannover
[2000]18!------------------------------------------------------------------------------!
[1036]19!
[484]20! Current revisions:
[206]21! -----------------
[2001]22!
23!
[1321]24! Former revisions:
25! ------------------
26! $Id: init_coupling.f90 4182 2019-08-22 15:20:23Z schwenkel $
[4182]27! Corrected "Former revisions" section
28!
29! 3655 2019-01-07 16:51:22Z knoop
[3232]30! references to mrun replaced by palmrun, and updated
[2716]31!
[4182]32! 222 2009-01-12 16:04:16Z letzel
33! Initial revision
34!
[206]35! Description:
36! ------------
[1682]37!> Initializing coupling via MPI-1 or MPI-2 if the coupled version of PALM is
38!> called.
[206]39!------------------------------------------------------------------------------!
[1682]40  SUBROUTINE init_coupling
41 
[206]42
[1320]43    USE control_parameters,                                                    &
44        ONLY:  coupling_char, coupling_mode
45       
46    USE kinds
47   
[206]48    USE pegrid
49
[2365]50    USE vertical_nesting_mod
51
[206]52    IMPLICIT NONE
53
54!
55!-- Local variables
[1682]56    INTEGER(iwp) ::  i            !<
57    INTEGER(iwp) ::  inter_color  !<
[1320]58   
[1682]59    INTEGER(iwp), DIMENSION(:) ::  bc_data(0:3) = 0  !<
[206]60
61!
62!-- Get information about the coupling mode from the environment variable
63!-- which has been set by the mpiexec command.
64!-- This method is currently not used because the mpiexec command is not
65!-- available on some machines
[1808]66!    CALL GET_ENVIRONMENT_VARIABLE( 'coupling_mode', coupling_mode, i )
[206]67!    IF ( i == 0 )  coupling_mode = 'uncoupled'
68!    IF ( coupling_mode == 'ocean_to_atmosphere' )  coupling_char = '_O'
69
70!
71!-- Get information about the coupling mode from standard input (PE0 only) and
[2298]72!-- distribute it to the other PEs. Distribute PEs to 2 new communicators.
[206]73!-- ATTENTION: numprocs will be reset according to the new communicators
[222]74#if defined ( __parallel )
[667]75
[206]76    IF ( myid == 0 )  THEN
77       READ (*,*,ERR=10,END=10)  coupling_mode, bc_data(1), bc_data(2)
7810     CONTINUE
79       IF ( TRIM( coupling_mode ) == 'coupled_run' )  THEN
80          i = 1
[2365]81       ELSEIF ( TRIM( coupling_mode ) == 'vnested_twi' )  THEN
82          i = 9
[206]83       ELSE
84          i = 0
85       ENDIF
[291]86       bc_data(0) = i
87
88!
89!--    Check if '_O' has to be used as file extension in an uncoupled ocean
90!--    run. This is required, if this run shall be continued as a coupled run.
91       IF ( TRIM( coupling_mode ) == 'precursor_ocean' )  bc_data(3) = 1
92
[206]93    ENDIF
94
[291]95    CALL MPI_BCAST( bc_data(0), 4, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr )
[206]96    i = bc_data(0)
97
[2365]98    IF ( i == 0 )  THEN
[206]99       coupling_mode = 'uncoupled'
[691]100!
101!--    In case of a precursor ocean run, an additional flag file is created.
102!--    This is necessary for data_output_2d_on_each_pe = .T.
103       IF ( bc_data(3) == 1 )  THEN
104          OPEN( 90, FILE='PRECURSOR_OCEAN', FORM='FORMATTED' )
105          WRITE ( 90, '(''TRUE'')' )
106          CLOSE ( 90 )
107       ENDIF
[2365]108    ELSEIF ( i == 9 )  THEN
109
110!
111!--    Set a flag to identify runs with vertical nesting
112       vnested = .TRUE.
113       
114       comm_inter = MPI_COMM_WORLD
115       
116!
117!--    Split the total available PE's into two groups
[3232]118!--    numprocs for coarse and fine grid are read from stdin (see above, and
119!--    execution command in the palmrun script, numprocs are provided via
120!--    palmrun option -Y)
[2365]121       IF ( myid < bc_data(1) )  THEN
122          inter_color     = 0
123          numprocs        = bc_data(1)
124          coupling_mode   = 'vnested_crse'
125       ELSE
126          inter_color     = 1
127          numprocs        = bc_data(2)
128          coupling_mode   = 'vnested_fine'
129       ENDIF
130       
131       CALL MPI_COMM_SPLIT( MPI_COMM_WORLD, inter_color, 0, comm_palm, ierr )
132       comm2d = comm_palm
133       
134       OPEN( 90, FILE='VNESTING_PORT_OPENED', FORM='FORMATTED' )
135       WRITE ( 90, '(''TRUE'')' )
136       CLOSE ( 90 )
137     
[206]138    ELSE
139       comm_inter = MPI_COMM_WORLD
140
141       IF ( myid < bc_data(1) ) THEN
[667]142          inter_color     = 0
143          numprocs        = bc_data(1)
144          coupling_mode   = 'atmosphere_to_ocean'
[206]145       ELSE
[667]146          inter_color     = 1
147          numprocs        = bc_data(2)
148          coupling_mode   = 'ocean_to_atmosphere'
[206]149       ENDIF
[667]150
[206]151       CALL MPI_COMM_SPLIT( MPI_COMM_WORLD, inter_color, 0, comm_palm, ierr )
152       comm2d = comm_palm
153
154!
155!--    Write a flag file for the ocean model and the other atmosphere
156!--    processes.
157       OPEN( 90, FILE='COUPLING_PORT_OPENED', FORM='FORMATTED' )
158       WRITE ( 90, '(''TRUE'')' )
159       CLOSE ( 90 )
160    ENDIF
161#endif
162
[291]163!
164!-- In case of a precursor ocean run (followed by a coupled run), or a
165!-- coupled atmosphere-ocean run, set the file extension for the ocean files
166    IF ( TRIM( coupling_mode ) == 'ocean_to_atmosphere' .OR. bc_data(3) == 1 ) &
167    THEN
168       coupling_char = '_O'
169    ENDIF
[206]170
[2365]171    IF (  TRIM( coupling_mode ) == 'vnested_fine' )  THEN
172!
173!-- Set file extension for vertical nesting
[2669]174       coupling_char = '_NV'
[2365]175    ENDIF
176
[206]177 END SUBROUTINE init_coupling
Note: See TracBrowser for help on using the repository browser.