source: palm/trunk/SOURCE/palm.f90 @ 108

Last change on this file since 108 was 108, checked in by letzel, 14 years ago
  • Improved coupler: evaporation - salinity-flux coupling for humidity = .T.,

avoid MPI hangs when coupled runs terminate, add DOC/app/chapter_3.8;

  • Optional calculation of km and kh from initial TKE e_init;
  • Default initialization of km,kh = 0.00001 for ocean = .T.;
  • Allow data_output_pr= q, wq, w"q", w*q* for humidity = .T.;
  • Bugfix: Rayleigh damping for ocean fixed.
  • Property svn:keywords set to Id
File size: 5.9 KB
Line 
1 PROGRAM palm
2
3!------------------------------------------------------------------------------!
4! Actual revisions:
5! -----------------
6! Get coupling mode from environment variable
7! Change localtion of debug output
8!
9! Former revisions:
10! -----------------
11! $Id: palm.f90 108 2007-08-24 15:10:38Z letzel $
12!
13! 75 2007-03-22 09:54:05Z raasch
14! __vtk directives removed, write_particles is called only in case of particle
15! advection switched on, open unit 9 for debug output,
16! setting of palm version moved from modules to here
17!
18! RCS Log replace by Id keyword, revision history cleaned up
19!
20! Revision 1.10  2006/08/04 14:53:12  raasch
21! Distibution of run description header removed, call of header moved behind
22! init_3d_model
23!
24! Revision 1.2  2001/01/25 07:15:06  raasch
25! Program name changed to PALM, module test_variables removed.
26! Initialization of dvrp logging as well as exit of dvrp moved to new
27! subroutines init_dvrp_logging and close_dvrp (file init_dvrp.f90)
28!
29! Revision 1.1  1997/07/24 11:23:35  raasch
30! Initial revision
31!
32!
33! Description:
34! ------------
35! Large-Eddy Simulation (LES) model for the convective boundary layer,
36! optimized for use on parallel machines (implementation realized using the
37! Message Passing Interface (MPI)). The model can also be run on vector machines
38! (less well optimized) and workstations. Versions for the different types of
39! machines are controlled via cpp-directives.
40! Model runs are only feasible using the ksh-script mrun.
41!------------------------------------------------------------------------------!
42
43
44    USE arrays_3d
45    USE constants
46    USE control_parameters
47    USE cpulog
48    USE dvrp_variables
49    USE grid_variables
50    USE indices
51    USE interfaces
52    USE model_1d
53    USE particle_attributes
54    USE pegrid
55    USE spectrum
56    USE statistics
57
58    IMPLICIT NONE
59
60!
61!-- Local variables
62    CHARACTER (LEN=9) ::  time_to_string
63    CHARACTER (LEN=1) ::  cdum
64    INTEGER           ::  i, run_description_header_i(80)
65
66    version = 'PALM 3.3a'
67
68#if defined( __parallel )
69!
70!-- MPI initialisation. comm2d is preliminary set, because
71!-- it will be defined in init_pegrid but is used before in cpu_log.
72    CALL MPI_INIT( ierr )
73    CALL MPI_COMM_SIZE( MPI_COMM_WORLD, numprocs, ierr )
74    comm_palm = MPI_COMM_WORLD
75    comm2d    = MPI_COMM_WORLD
76#endif
77
78#if defined( __mpi2 )
79!
80!-- Get information about the coupling mode from the environment variable
81!-- which has been set by the mpiexec command
82    CALL local_getenv( 'coupling_mode', 13, coupling_mode, i )
83    IF ( i == 0 )  coupling_mode = 'uncoupled'
84    IF ( coupling_mode == 'ocean_to_atmosphere' )  coupling_char = '_O'
85#endif
86
87!
88!-- Initialize measuring of the CPU-time remaining to the run
89    CALL local_tremain_ini
90
91!
92!-- Start of total CPU time measuring.
93    CALL cpu_log( log_point(1), 'total', 'start' )
94    CALL cpu_log( log_point(2), 'initialisation', 'start' )
95
96!
97!-- Initialize dvrp logging. Also, one PE maybe split from the global
98!-- communicator for doing the dvrp output. In that case, the number of
99!-- PEs available for PALM is reduced by one and communicator comm_palm
100!-- is changed respectively.
101#if defined( __parallel )
102    CALL MPI_COMM_RANK( comm_palm, myid, ierr )
103#endif
104
105!
106!-- Open a file for debug output
107    WRITE (myid_char,'(''_'',I4.4)')  myid
108    OPEN( 9, FILE='DEBUG'//TRIM( coupling_char )//myid_char, FORM='FORMATTED' )
109
110#if defined( __mpi2 )
111!
112!-- TEST OUTPUT (TO BE REMOVED)
113    WRITE(9,*) '*** coupling_mode = "', TRIM( coupling_mode ), '"'
114    CALL LOCAL_FLUSH( 9 )
115    print*, '*** PE', myid, '  ', TRIM( coupling_mode )
116#endif
117
118    CALL init_dvrp_logging
119
120!
121!-- Read control parameters from NAMELIST files and read environment-variables
122    CALL parin
123
124!
125!-- Determine processor topology and local array indices
126    CALL init_pegrid
127
128!
129!-- Generate grid parameters
130    CALL init_grid
131
132!
133!-- Check control parameters and deduce further quantities
134    CALL check_parameters
135
136!
137!-- Initialize all necessary variables
138    CALL init_3d_model
139
140!
141!-- Output of program header
142    IF ( myid == 0 )  CALL header
143
144    CALL cpu_log( log_point(2), 'initialisation', 'stop' )
145
146!
147!-- Set start time in format hh:mm:ss
148    simulated_time_chr = time_to_string( simulated_time )
149
150!
151!-- If required, output of initial arrays
152    IF ( do2d_at_begin )  THEN
153       CALL data_output_2d( 'xy', 0 )
154       CALL data_output_2d( 'xz', 0 )
155       CALL data_output_2d( 'yz', 0 )
156    ENDIF
157    IF ( do3d_at_begin )  THEN
158       CALL data_output_3d( 0 )
159    ENDIF
160
161!
162!-- Integration of the model equations using the leap-frog scheme
163    CALL time_integration
164
165!
166!-- If required, write binary data for model continuation runs
167    IF ( write_binary(1:4) == 'true' )  CALL write_3d_binary
168
169!
170!-- If required, write binary particle data
171    IF ( particle_advection )  CALL write_particles
172
173!
174!-- If required, repeat output of header including the required CPU-time
175    IF ( myid == 0 )  CALL header
176
177!
178!-- If required, final user-defined actions, and
179!-- last actions on the open files and close files. Unit 14 was opened
180!-- in write_3d_binary but it is closed here, to allow writing on this
181!-- unit in routine user_last_actions.
182    CALL cpu_log( log_point(4), 'last actions', 'start' )
183    CALL user_last_actions
184    IF ( write_binary(1:4) == 'true' )  CALL close_file( 14 )
185    CALL close_file( 0 )
186    CALL close_dvrp
187    CALL cpu_log( log_point(4), 'last actions', 'stop' )
188
189#if defined( __mpi2 )
190!
191!-- Test exchange via intercommunicator
192    IF ( coupling_mode == 'atmosphere_to_ocean' )  THEN
193       i = 12345 + myid
194       CALL MPI_SEND( i, 1, MPI_INTEGER, myid, 11, comm_inter, ierr )
195    ELSEIF ( coupling_mode == 'ocean_to_atmosphere' )  THEN
196       CALL MPI_RECV( i, 1, MPI_INTEGER, myid, 11, comm_inter, status, ierr )
197       PRINT*, '### myid: ', myid, '   received from atmosphere:  i = ', i
198    ENDIF
199#endif
200
201!
202!-- Take final CPU-time for CPU-time analysis
203    CALL cpu_log( log_point(1), 'total', 'stop' )
204    CALL cpu_statistics
205
206#if defined( __parallel )
207    CALL MPI_FINALIZE( ierr )
208#endif
209
210 END PROGRAM palm
211
Note: See TracBrowser for help on using the repository browser.