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

Last change on this file since 3103 was 2718, checked in by maronga, 7 years ago

deleting of deprecated files; headers updated where needed

  • Property svn:keywords set to Id
File size: 6.2 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!
[2718]17! Copyright 1997-2018 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 2718 2018-01-02 08:49:38Z suehring $
[2716]27! Corrected "Former revisions" section
28!
29! 2696 2017-12-14 17:12:51Z kanani
30! Change in file header (GPL part)
31!
32! 2669 2017-12-06 16:03:27Z raasch
[2669]33! file extension for vertical nesting changed to "_NV"
34!
35! 2365 2017-08-21 14:59:59Z kanani
[2365]36! Vertical nesting implemented (SadiqHuq)
37!
38! 2298 2017-06-29 09:28:18Z raasch
[2298]39! MPI2 coupling removed
40!
41! 2101 2017-01-05 16:42:31Z suehring
[1809]42!
[2001]43! 2000 2016-08-20 18:09:15Z knoop
44! Forced header and separation lines into 80 columns
45!
[1809]46! 1808 2016-04-05 19:44:00Z raasch
47! routine local_getenv replaced by standard FORTRAN routine
[1321]48!
[1683]49! 1682 2015-10-07 23:56:08Z knoop
50! Code annotations made doxygen readable
51!
[1321]52! 1320 2014-03-20 08:40:49Z raasch
[1320]53! ONLY-attribute added to USE-statements,
54! kind-parameters added to all INTEGER and REAL declaration statements,
55! kinds are defined in new module kinds,
56! revision history before 2012 removed,
57! comment fields (!:) to be used for variable explanations added to
58! all variable declaration statements
[206]59!
[1037]60! 1036 2012-10-22 13:43:42Z raasch
61! code put under GPL (PALM 3.9)
62!
[226]63! 222 2009-01-12 16:04:16Z letzel
64! Initial revision
65!
[206]66! Description:
67! ------------
[1682]68!> Initializing coupling via MPI-1 or MPI-2 if the coupled version of PALM is
69!> called.
[206]70!------------------------------------------------------------------------------!
[1682]71  SUBROUTINE init_coupling
72 
[206]73
[1320]74    USE control_parameters,                                                    &
75        ONLY:  coupling_char, coupling_mode
76       
77    USE kinds
78   
[206]79    USE pegrid
80
[2365]81    USE vertical_nesting_mod
82
[206]83    IMPLICIT NONE
84
85!
86!-- Local variables
[1682]87    INTEGER(iwp) ::  i            !<
88    INTEGER(iwp) ::  inter_color  !<
[1320]89   
[1682]90    INTEGER(iwp), DIMENSION(:) ::  bc_data(0:3) = 0  !<
[206]91
92!
93!-- Get information about the coupling mode from the environment variable
94!-- which has been set by the mpiexec command.
95!-- This method is currently not used because the mpiexec command is not
96!-- available on some machines
[1808]97!    CALL GET_ENVIRONMENT_VARIABLE( 'coupling_mode', coupling_mode, i )
[206]98!    IF ( i == 0 )  coupling_mode = 'uncoupled'
99!    IF ( coupling_mode == 'ocean_to_atmosphere' )  coupling_char = '_O'
100
101!
102!-- Get information about the coupling mode from standard input (PE0 only) and
[2298]103!-- distribute it to the other PEs. Distribute PEs to 2 new communicators.
[206]104!-- ATTENTION: numprocs will be reset according to the new communicators
[222]105#if defined ( __parallel )
[667]106
[206]107    IF ( myid == 0 )  THEN
108       READ (*,*,ERR=10,END=10)  coupling_mode, bc_data(1), bc_data(2)
10910     CONTINUE
110       IF ( TRIM( coupling_mode ) == 'coupled_run' )  THEN
111          i = 1
[2365]112       ELSEIF ( TRIM( coupling_mode ) == 'vnested_twi' )  THEN
113          i = 9
[206]114       ELSE
115          i = 0
116       ENDIF
[291]117       bc_data(0) = i
118
119!
120!--    Check if '_O' has to be used as file extension in an uncoupled ocean
121!--    run. This is required, if this run shall be continued as a coupled run.
122       IF ( TRIM( coupling_mode ) == 'precursor_ocean' )  bc_data(3) = 1
123
[206]124    ENDIF
125
[291]126    CALL MPI_BCAST( bc_data(0), 4, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr )
[206]127    i = bc_data(0)
128
[2365]129    IF ( i == 0 )  THEN
[206]130       coupling_mode = 'uncoupled'
[691]131!
132!--    In case of a precursor ocean run, an additional flag file is created.
133!--    This is necessary for data_output_2d_on_each_pe = .T.
134       IF ( bc_data(3) == 1 )  THEN
135          OPEN( 90, FILE='PRECURSOR_OCEAN', FORM='FORMATTED' )
136          WRITE ( 90, '(''TRUE'')' )
137          CLOSE ( 90 )
138       ENDIF
[2365]139    ELSEIF ( i == 9 )  THEN
140
141!
142!--    Set a flag to identify runs with vertical nesting
143       vnested = .TRUE.
144       
145       comm_inter = MPI_COMM_WORLD
146       
147!
148!--    Split the total available PE's into two groups
149!--    numprocs for Coarse and Fine Grid are specified via mrun argument -N
150       IF ( myid < bc_data(1) )  THEN
151          inter_color     = 0
152          numprocs        = bc_data(1)
153          coupling_mode   = 'vnested_crse'
154       ELSE
155          inter_color     = 1
156          numprocs        = bc_data(2)
157          coupling_mode   = 'vnested_fine'
158       ENDIF
159       
160       CALL MPI_COMM_SPLIT( MPI_COMM_WORLD, inter_color, 0, comm_palm, ierr )
161       comm2d = comm_palm
162       
163       OPEN( 90, FILE='VNESTING_PORT_OPENED', FORM='FORMATTED' )
164       WRITE ( 90, '(''TRUE'')' )
165       CLOSE ( 90 )
166     
[206]167    ELSE
168       comm_inter = MPI_COMM_WORLD
169
170       IF ( myid < bc_data(1) ) THEN
[667]171          inter_color     = 0
172          numprocs        = bc_data(1)
173          coupling_mode   = 'atmosphere_to_ocean'
[206]174       ELSE
[667]175          inter_color     = 1
176          numprocs        = bc_data(2)
177          coupling_mode   = 'ocean_to_atmosphere'
[206]178       ENDIF
[667]179
[206]180       CALL MPI_COMM_SPLIT( MPI_COMM_WORLD, inter_color, 0, comm_palm, ierr )
181       comm2d = comm_palm
182
183!
184!--    Write a flag file for the ocean model and the other atmosphere
185!--    processes.
186       OPEN( 90, FILE='COUPLING_PORT_OPENED', FORM='FORMATTED' )
187       WRITE ( 90, '(''TRUE'')' )
188       CLOSE ( 90 )
189    ENDIF
190#endif
191
[291]192!
193!-- In case of a precursor ocean run (followed by a coupled run), or a
194!-- coupled atmosphere-ocean run, set the file extension for the ocean files
195    IF ( TRIM( coupling_mode ) == 'ocean_to_atmosphere' .OR. bc_data(3) == 1 ) &
196    THEN
197       coupling_char = '_O'
198    ENDIF
[206]199
[2365]200    IF (  TRIM( coupling_mode ) == 'vnested_fine' )  THEN
201!
202!-- Set file extension for vertical nesting
[2669]203       coupling_char = '_NV'
[2365]204    ENDIF
205
[206]206 END SUBROUTINE init_coupling
Note: See TracBrowser for help on using the repository browser.