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

Last change on this file since 3858 was 3761, checked in by raasch, 6 years ago

unused variables removed, OpenACC directives re-formatted, statements added to avoid compiler warnings

  • Property svn:keywords set to Id
File size: 21.1 KB
RevLine 
[1682]1!> @file palm.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!
[3648]17! Copyright 1997-2019 Leibniz Universitaet Hannover
[2000]18!------------------------------------------------------------------------------!
[1036]19!
[484]20! Current revisions:
[1]21! -----------------
[2233]22!
23!
24! Former revisions:
25! -----------------
26! $Id: palm.f90 3761 2019-02-25 15:31:42Z suehring $
[3761]27! unused variable removed
28!
29! 3719 2019-02-06 13:10:18Z kanani
[3719]30! Included cpu measurement for wall/soil spinup
31!
32! 3703 2019-01-29 16:43:53Z knoop
[3685]33! Some interface calls moved to module_interface + cleanup
34!
35! 3648 2019-01-02 16:35:46Z suehring
[3648]36! Rename subroutines for surface-data output
37!
38! 3524 2018-11-14 13:36:44Z raasch
[3524]39! unused variable removed
40!
41! 3494 2018-11-06 14:51:27Z suehring
[3494]42! Last actions for surface output added
43!
44! 3487 2018-11-05 07:18:02Z maronga
[3487]45! Updates version to 6.0
46!
47! 3484 2018-11-02 14:41:25Z hellstea
[3484]48! pmci_ensure_nest_mass_conservation removed permanently
49!
50! 3458 2018-10-30 14:51:23Z kanani
[3458]51! from chemistry branch r3443, forkel:
52! removed double do_emis check around CALL chem_init
53! replaced call to calc_date_and_time to init_date_and_time
54!
55! 3337 2018-10-12 15:17:09Z kanani
[3337]56! (from branch resler)
57! Fix chemistry call
58!
59! 3298 2018-10-02 12:21:11Z kanani
[3298]60! - Minor formatting (kanani)
61! - Added Call of date_and_time_init (Russo)
62! - Added Call of calc_date_and_time before call of init_3d where emissions
63!   are initialized:
64!   we have to know the time indices to initialize emission values (Russo)
65! - Added Call of netcdf_data_input_chemistry_data (Russo)
66!
67! 3274 2018-09-24 15:42:55Z knoop
[3274]68! Modularization of all bulk cloud physics code components
69!
70! 3258 2018-09-18 07:23:31Z Giersch
[3258]71! current revision for user interface has been changed to 3240
72!
73! 3241 2018-09-12 15:02:00Z raasch
[3241]74! unused variables removed
75!
76! 3235 2018-09-07 14:06:15Z sward
[3235]77! Added mas_last_actions call and multi_agent_system_mod dependency
78!
79! 3232 2018-09-07 12:21:44Z raasch
[3232]80! references to mrun replaced by palmrun, and updated
81!
82! 3182 2018-07-27 13:36:03Z suehring
[2977]83! Deduct spinup_time from RUN_CONTROL output of main 3d run
84! (use time_since_reference_point instead of simulated_time)
85!
86! 2951 2018-04-06 09:05:08Z kanani
[2951]87! Add log_point_s for pmci_init
88!
89! 2903 2018-03-16 08:17:06Z hellstea
[2903]90! Nesting-related calls to pmci_ensure_nest_mass_conservation and pres after
91! the nest initialization are removed as they may create unwanted initial
92! perturbation in some cases.
93!
94! 2894 2018-03-15 09:17:58Z Giersch
[2894]95! Modified todo list, _write_restart_data/_last_actions has been renamed to
96! _wrd_local, unit 14 will be opened now for each io_group
97! write_3d_binary is called wrd_local now, wrd_global moved from wrd_local to
98! palm.f90, unit 14 is closed directly after the wrd_local call, Module related
99! routines for writing restart data have been moved to wrd_local
100!
101! 2801 2018-02-14 16:01:55Z suehring
[2801]102! Changed lpm from subroutine to module.
103! Introduce particle transfer in nested models.
104!
105! 2766 2018-01-22 17:17:47Z kanani
[2766]106! Removed preprocessor directive __chem
107!
108! 2720 2018-01-02 16:27:15Z kanani
[2720]109! Version update to 5.0
110!
111! 2718 2018-01-02 08:49:38Z maronga
[2716]112! Corrected "Former revisions" section
113!
114! 2696 2017-12-14 17:12:51Z kanani
115! Change in file header (GPL part)
[2696]116! Implementation of chemistry module (FK)
117! Introduce input-data standard
118! Rename lsm_last_actions into lsm_write_restart_data
119! Move usm_write_restart_data into io_blocks loop (MS)
120!
121! 2512 2017-10-04 08:26:59Z raasch
[2512]122! user interface required revision updated
123!
124! 2320 2017-07-21 12:47:43Z suehring
[2320]125! Modularize large-scale forcing and nudging
126!
127! 2298 2017-06-29 09:28:18Z raasch
[2298]128! type of write_binary changed from CHARACTER to LOGICAL,
129! user interface required revision updated, MPI2 related part removed
130!
131! 2296 2017-06-28 07:53:56Z maronga
[2296]132! Added call to new spinup routine
133!
134! 2292 2017-06-20 09:51:42Z schwenkel
[2292]135! Implementation of new microphysic scheme: cloud_scheme = 'morrison'
136! includes two more prognostic equations for cloud drop concentration (nc) 
137! and cloud water content (qc).
138!
139! 2261 2017-06-08 14:25:57Z raasch
[2261]140! output of run number for mrun to create unified cycle numbers
141!
142! 2233 2017-05-30 18:08:54Z suehring
[2233]143!
144! 2232 2017-05-30 17:47:52Z suehring
[2232]145! Renamed wall_flags_0 and wall_flags_00 into advc_flags_1 and advc_flags_2,
146! respectively, within copyin statement. Moreover, introduced further flag
147! array wall_flags_0.
148! Remove unused variables from ONLY list.
[1834]149!
[2179]150! 2178 2017-03-17 11:07:39Z hellstea
151! Calls for pmci_ensure_nest_mass_conservation and pres are added after
152! the nest initialization
153!
[2119]154! 2118 2017-01-17 16:38:49Z raasch
155! OpenACC directives and related code removed
156!
[2012]157! 2011 2016-09-19 17:29:57Z kanani
158! Flag urban_surface is now defined in module control_parameters.
159!
[2008]160! 2007 2016-08-24 15:47:17Z kanani
161! Temporarily added CALL for writing of restart data for urban surface model
162!
[2001]163! 2000 2016-08-20 18:09:15Z knoop
164! Forced header and separation lines into 80 columns
165!
[1977]166! 1976 2016-07-27 13:28:04Z maronga
167! Added call to radiation_last_actions for binary output of land surface model
168! data
169!
[1973]170! 1972 2016-07-26 07:52:02Z maronga
171! Added call to lsm_last_actions for binary output of land surface model data
172!
[1961]173! 1960 2016-07-12 16:34:24Z suehring
174! Separate humidity and passive scalar
175!
[1933]176! 1834 2016-04-07 14:34:20Z raasch
177! Initial version of purely vertical nesting introduced.
178!
[1834]179! 1833 2016-04-07 14:23:03Z raasch
180! required user interface version changed
181!
[1809]182! 1808 2016-04-05 19:44:00Z raasch
183! routine local_flush replaced by FORTRAN statement
184!
[1784]185! 1783 2016-03-06 18:36:17Z raasch
186! required user interface version changed
187!
[1782]188! 1781 2016-03-03 15:12:23Z raasch
189! pmc initialization moved from time_integration to here
190!
[1780]191! 1779 2016-03-03 08:01:28Z raasch
192! setting of nest_domain and coupling_char moved to the pmci
193!
[1765]194! 1764 2016-02-28 12:45:19Z raasch
195! cpp-statements for nesting removed, communicator settings cleaned up
196!
[1763]197! 1762 2016-02-25 12:31:13Z hellstea
198! Introduction of nested domain feature
199!
[1748]200! 1747 2016-02-08 12:25:53Z raasch
201! OpenACC-adjustment for new surface layer parameterization
202!
[1683]203! 1682 2015-10-07 23:56:08Z knoop
204! Code annotations made doxygen readable
205!
[1669]206! 1668 2015-09-23 13:45:36Z raasch
207! warning replaced by abort in case of failed user interface check
208!
[1667]209! 1666 2015-09-23 07:31:10Z raasch
210! check for user's interface version added
211!
[1483]212! 1482 2014-10-18 12:34:45Z raasch
213! adjustments for using CUDA-aware OpenMPI
214!
[1469]215! 1468 2014-09-24 14:06:57Z maronga
216! Adapted for use on up to 6-digit processor cores
217!
[1403]218! 1402 2014-05-09 14:25:13Z raasch
219! location messages added
220!
[1375]221! 1374 2014-04-25 12:55:07Z raasch
222! bugfix: various modules added
223!
[1321]224! 1320 2014-03-20 08:40:49Z raasch
[1320]225! ONLY-attribute added to USE-statements,
226! kind-parameters added to all INTEGER and REAL declaration statements,
227! kinds are defined in new module kinds,
228! old module precision_kind is removed,
229! revision history before 2012 removed,
230! comment fields (!:) to be used for variable explanations added to
231! all variable declaration statements
[77]232!
[1319]233! 1318 2014-03-17 13:35:16Z raasch
234! module interfaces removed
235!
[1242]236! 1241 2013-10-30 11:36:58Z heinze
237! initialization of nuding and large scale forcing from external file
238!
[1222]239! 1221 2013-09-10 08:59:13Z raasch
240! +wall_flags_00, rflags_invers, rflags_s_inner in copyin statement
241!
[1213]242! 1212 2013-08-15 08:46:27Z raasch
243! +tri in copyin statement
244!
[1182]245! 1179 2013-06-14 05:57:58Z raasch
246! ref_state added to copyin-list
247!
[1114]248! 1113 2013-03-10 02:48:14Z raasch
249! openACC statements modified
250!
[1112]251! 1111 2013-03-08 23:54:10Z raasch
252! openACC statements updated
253!
[1093]254! 1092 2013-02-02 11:24:22Z raasch
255! unused variables removed
256!
[1037]257! 1036 2012-10-22 13:43:42Z raasch
258! code put under GPL (PALM 3.9)
259!
[1017]260! 1015 2012-09-27 09:23:24Z raasch
[863]261! Version number changed from 3.8 to 3.8a.
[1017]262! OpenACC statements added + code changes required for GPU optimization
[863]263!
[850]264! 849 2012-03-15 10:35:09Z raasch
265! write_particles renamed lpm_write_restart_file
266!
[1]267! Revision 1.1  1997/07/24 11:23:35  raasch
268! Initial revision
269!
270!
271! Description:
272! ------------
[3232]273!> Large-Eddy Simulation (LES) model for atmospheric and oceanic boundary-layer
274!> flows
275!> see the PALM homepage https://palm-model.org for further information
[1]276!------------------------------------------------------------------------------!
[1682]277 PROGRAM palm
278 
[1]279
[1374]280    USE arrays_3d
[1]281
[3298]282    USE bulk_cloud_model_mod,                                                  &
283        ONLY: bulk_cloud_model, microphysics_morrison, microphysics_seifert
284
[1320]285    USE control_parameters,                                                    &
[3761]286        ONLY:  constant_diffusion, child_domain,                               &
[3524]287               coupling_char, do2d_at_begin, do3d_at_begin, humidity,          &
288               initializing_actions, io_blocks, io_group, message_string,      &
[3241]289               neutral, passive_scalar, runnr, simulated_time_chr, spinup,     &
290               time_since_reference_point, user_interface_current_revision,    &
291               user_interface_required_revision, version, write_binary
[1320]292
293    USE cpulog,                                                                &
[2951]294        ONLY:  cpu_log, log_point, log_point_s, cpu_statistics
[1320]295
[3298]296    USE date_and_time_mod,                                                     &
297        ONLY:  calc_date_and_time, init_date_and_time
298
[1374]299    USE indices,                                                               &
[2232]300        ONLY:  nbgp
[1374]301
[3274]302    USE kinds
303
[3687]304    USE module_interface,                                                      &
305        ONLY:  module_interface_last_actions
306
[3235]307    USE multi_agent_system_mod,                                                &
308        ONLY:  agents_active, mas_last_actions
309
[2696]310    USE netcdf_data_input_mod,                                                 &
[3685]311        ONLY:  netcdf_data_input_inquire_file, netcdf_data_input_init,         &
[2696]312               netcdf_data_input_surface_data, netcdf_data_input_topo
313
[1320]314    USE particle_attributes,                                                   &
315        ONLY:  particle_advection
316
[1]317    USE pegrid
318
[2894]319    USE pmc_particle_interface,                                                &
320        ONLY: pmcp_g_alloc_win
321
[1762]322    USE pmc_interface,                                                         &
[3241]323        ONLY:  nested_run, pmci_child_initialize, pmci_init,                   &
[3484]324               pmci_modelconfiguration, pmci_parent_initialize
[3494]325               
[3648]326    USE surface_data_output_mod,                                               &
327        ONLY:  surface_data_output_last_action
[1762]328
[2894]329    USE write_restart_data_mod,                                                &
330        ONLY:  wrd_global, wrd_local
[2801]331
[3689]332#if defined( __parallel) && defined( _OPENACC )
333    USE openacc
334#endif
[1747]335
[3689]336
[1]337    IMPLICIT NONE
338
339!
340!-- Local variables
[3241]341    CHARACTER(LEN=9) ::  time_to_string  !<
342    INTEGER(iwp)     ::  i               !< loop counter for blocked I/O
[3689]343#if defined( __parallel) && defined( _OPENACC )
344    INTEGER(iwp)     :: local_comm       !< local communicator (shared memory)
345    INTEGER(iwp)     :: local_num_procs  !< local number of processes
346    INTEGER(iwp)     :: local_id         !< local id
347    INTEGER(acc_device_kind) :: device_type !< device type for OpenACC
348    INTEGER(iwp)     ::  num_devices     !< number of devices visible to OpenACC
349    INTEGER(iwp)     ::  my_device       !< device used by this process
350#endif
[1]351
[3487]352    version = 'PALM 6.0'
[3703]353    user_interface_required_revision = 'r3703'
[75]354
[1]355#if defined( __parallel )
356!
357!-- MPI initialisation. comm2d is preliminary set, because
358!-- it will be defined in init_pegrid but is used before in cpu_log.
359    CALL MPI_INIT( ierr )
[1762]360
361!
362!-- Initialize the coupling for nested-domain runs
[1764]363!-- comm_palm is the communicator which includes all PEs (MPI processes)
364!-- available for this (nested) model. If it is not a nested run, comm_palm
365!-- is returned as MPI_COMM_WORLD
[2951]366    CALL cpu_log( log_point_s(70), 'pmci_init', 'start' )
[1762]367    CALL pmci_init( comm_palm )
[2951]368    CALL cpu_log( log_point_s(70), 'pmci_init', 'stop' )
[1762]369    comm2d = comm_palm
[1764]370!
371!-- Get the (preliminary) number of MPI processes and the local PE-id (in case
372!-- of a further communicator splitting in init_coupling, these numbers will
373!-- be changed in init_pegrid).
374    IF ( nested_run )  THEN
[1762]375
[1764]376       CALL MPI_COMM_SIZE( comm_palm, numprocs, ierr )
377       CALL MPI_COMM_RANK( comm_palm, myid, ierr )
[1762]378
[1764]379    ELSE
380
381       CALL MPI_COMM_SIZE( MPI_COMM_WORLD, numprocs, ierr )
382       CALL MPI_COMM_RANK( MPI_COMM_WORLD, myid, ierr )
[1]383!
[1764]384!--    Initialize PE topology in case of coupled atmosphere-ocean runs (comm_palm
385!--    will be splitted in init_coupling)
386       CALL init_coupling
387    ENDIF
[3689]388
389#ifdef _OPENACC
390!
391!-- Select OpenACC device to use in this process. For this find out how many
392!-- neighbors there are running on the same node and which id this process is.
393    IF ( nested_run )  THEN
394       CALL MPI_COMM_SPLIT_TYPE( comm_palm, MPI_COMM_TYPE_SHARED, 0,           &
395                                 MPI_INFO_NULL, local_comm, ierr )
396    ELSE
397       CALL MPI_COMM_SPLIT_TYPE( MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, 0,      &
398                                 MPI_INFO_NULL, local_comm, ierr )
399    ENDIF
400    CALL MPI_COMM_SIZE( local_comm, local_num_procs, ierr )
401    CALL MPI_COMM_RANK( local_comm, local_id, ierr )
402
403!
404!-- This loop including the barrier is a workaround for PGI compiler versions
405!-- up to and including 18.4. Later releases are able to select their GPUs in
406!-- parallel, without running into spurious errors.
407    DO i = 0, local_num_procs-1
408       CALL MPI_BARRIER( local_comm, ierr )
409
410       IF ( i == local_id )  THEN
411          device_type = acc_get_device_type()
412          num_devices = acc_get_num_devices( device_type )
413          my_device = MOD( local_id, num_devices )
414          CALL acc_set_device_num( my_device, device_type )
415       ENDIF
416    ENDDO
417
418    CALL MPI_COMM_FREE( local_comm, ierr )
[102]419#endif
[3689]420#endif
[102]421
422!
[1]423!-- Initialize measuring of the CPU-time remaining to the run
424    CALL local_tremain_ini
425
426!
427!-- Start of total CPU time measuring.
428    CALL cpu_log( log_point(1), 'total', 'start' )
429    CALL cpu_log( log_point(2), 'initialisation', 'start' )
430
431!
[206]432!-- Open a file for debug output
[1468]433    WRITE (myid_char,'(''_'',I6.6)')  myid
[206]434    OPEN( 9, FILE='DEBUG'//TRIM( coupling_char )//myid_char, FORM='FORMATTED' )
435
436!
[1]437!-- Initialize dvrp logging. Also, one PE maybe split from the global
438!-- communicator for doing the dvrp output. In that case, the number of
439!-- PEs available for PALM is reduced by one and communicator comm_palm
440!-- is changed respectively.
441#if defined( __parallel )
442    CALL MPI_COMM_RANK( comm_palm, myid, ierr )
[102]443#endif
444
[108]445    CALL init_dvrp_logging
446
[102]447!
[108]448!-- Read control parameters from NAMELIST files and read environment-variables
449    CALL parin
450
451!
[1666]452!-- Check for the user's interface version
453    IF ( user_interface_current_revision /= user_interface_required_revision )  &
454    THEN
455       message_string = 'current user-interface revision "' //                  &
456                        TRIM( user_interface_current_revision ) // '" does ' // &
457                        'not match the required revision ' //                   &
458                        TRIM( user_interface_required_revision )
[1668]459        CALL message( 'palm', 'PA0169', 1, 2, 0, 6, 0 )
[1666]460    ENDIF
461
462!
[108]463!-- Determine processor topology and local array indices
464    CALL init_pegrid
465!
[2696]466!-- Check if input file according to input-data standard exists
467    CALL netcdf_data_input_inquire_file
468!
469!-- Read topography input data if required. This is required before the
470!-- numerical grid is finally created in init_grid
471    CALL netcdf_data_input_topo 
472!
473!-- Generate grid parameters, initialize generic topography and further process
474!-- topography information if required
[1]475    CALL init_grid
476!
[2696]477!-- Read global attributes if available. 
478    CALL netcdf_data_input_init 
479!
480!-- Read surface classification data, e.g. vegetation and soil types, water
481!-- surfaces, etc., if available. Some of these data is required before
482!-- check parameters is invoked.     
483    CALL netcdf_data_input_surface_data
484!
[1]485!-- Check control parameters and deduce further quantities
486    CALL check_parameters
487!
[3458]488!-- Initial time for chem_emissions_mod
489    CALL init_date_and_time
[3298]490
[1]491    CALL init_3d_model
492
493!
[1762]494!-- Coupling protocol setup for nested-domain runs
[1764]495    IF ( nested_run )  THEN
496       CALL pmci_modelconfiguration
[1781]497!
[1933]498!--    Receive and interpolate initial data on children.
499!--    Child initialization must be made first if the model is both child and
[2177]500!--    parent if necessary
501       IF ( TRIM( initializing_actions ) /= 'read_restart_data' )  THEN
502          CALL pmci_child_initialize
[1781]503!
[2177]504!--       Send initial condition data from parent to children
505          CALL pmci_parent_initialize
[1781]506!
[3232]507!--       Exchange_horiz is needed after the nest initialization
[3182]508          IF ( child_domain )  THEN
[2178]509             CALL exchange_horiz( u, nbgp )
510             CALL exchange_horiz( v, nbgp )
511             CALL exchange_horiz( w, nbgp )
512             IF ( .NOT. neutral )  THEN
513                CALL exchange_horiz( pt, nbgp )
514             ENDIF
515             IF ( .NOT. constant_diffusion )  CALL exchange_horiz( e, nbgp )
516             IF ( humidity )  THEN
517                CALL exchange_horiz( q, nbgp )
[3274]518                IF ( bulk_cloud_model  .AND.  microphysics_morrison )  THEN
[2292]519                  CALL exchange_horiz( qc, nbgp )
520                  CALL exchange_horiz( nc, nbgp )
521                ENDIF
[3274]522                IF ( bulk_cloud_model  .AND.  microphysics_seifert )  THEN
[2178]523                   CALL exchange_horiz( qr, nbgp ) 
524                   CALL exchange_horiz( nr, nbgp )
525                ENDIF
526             ENDIF
527             IF ( passive_scalar )  CALL exchange_horiz( s, nbgp )
[1933]528          ENDIF
[1781]529       ENDIF
530
[2801]531       CALL pmcp_g_alloc_win                    ! Must be called after pmci_child_initialize and pmci_parent_initialize
[1764]532    ENDIF
[1762]533
534!
[1]535!-- Output of program header
536    IF ( myid == 0 )  CALL header
537
538    CALL cpu_log( log_point(2), 'initialisation', 'stop' )
539
540!
[2296]541!-- Integration of the non-atmospheric equations (land surface model, urban
542!-- surface model)
543    IF ( spinup )  THEN
[3719]544       CALL cpu_log( log_point(41), 'wall/soil spinup', 'start' )
[2296]545       CALL time_integration_spinup
[3719]546       CALL cpu_log( log_point(41), 'wall/soil spinup', 'stop' )
[2296]547    ENDIF
548
549!
[1]550!-- Set start time in format hh:mm:ss
[2977]551    simulated_time_chr = time_to_string( time_since_reference_point )
[1]552
553!
554!-- If required, output of initial arrays
555    IF ( do2d_at_begin )  THEN
556       CALL data_output_2d( 'xy', 0 )
557       CALL data_output_2d( 'xz', 0 )
558       CALL data_output_2d( 'yz', 0 )
559    ENDIF
[1976]560
[1]561    IF ( do3d_at_begin )  THEN
562       CALL data_output_3d( 0 )
563    ENDIF
564
565!
[495]566!-- Integration of the model equations using timestep-scheme
[1]567    CALL time_integration
568
569!
[495]570!-- If required, write binary data for restart runs
[2298]571    IF ( write_binary )  THEN
[759]572
[2894]573       CALL cpu_log( log_point(22), 'wrd_local', 'start' )
[759]574
[1402]575       CALL location_message( 'writing restart data', .FALSE. )
576
[759]577       DO  i = 0, io_blocks-1
578          IF ( i == io_group )  THEN
[2894]579
[1]580!
[2894]581!--          Open binary file
582             CALL check_open( 14 )
583!
584!--          Write control parameters and other global variables for restart.
585             IF ( myid == 0 )  CALL wrd_global
586!
587!--          Write processor specific flow field data for restart runs
588             CALL wrd_local
589!
590!--          Close binary file
591             CALL close_file( 14 )
592
[759]593          ENDIF
594#if defined( __parallel )
595          CALL MPI_BARRIER( comm2d, ierr )
596#endif
597       ENDDO
598
[1402]599       CALL location_message( 'finished', .TRUE. )
600
[2894]601       CALL cpu_log( log_point(22), 'wrd_local', 'stop' )
[759]602
[495]603!
[2894]604!--    If required, write particle data in own restart files
[849]605       IF ( particle_advection )  CALL lpm_write_restart_file
[2007]606       
[495]607    ENDIF
[3494]608!
609!-- Last actions for surface output, for instantaneous and time-averaged data
[3648]610    CALL surface_data_output_last_action( 0 )
611    CALL surface_data_output_last_action( 1 )
[1]612
613!
614!-- If required, repeat output of header including the required CPU-time
615    IF ( myid == 0 )  CALL header
616!
[3687]617!-- Perform module specific last actions
[1]618    CALL cpu_log( log_point(4), 'last actions', 'start' )
[3235]619
[3687]620    IF ( myid == 0 .AND. agents_active ) CALL mas_last_actions ! ToDo: move to module_interface
[2894]621
[3687]622    CALL module_interface_last_actions
623
[1]624    CALL cpu_log( log_point(4), 'last actions', 'stop' )
625
626!
[3687]627!-- Close files
628    CALL close_file( 0 )
629    CALL close_dvrp
630
631!
[3232]632!-- Write run number to file (used by palmrun to create unified cycle numbers
633!-- for output files
[2261]634    IF ( myid == 0  .AND.  runnr > 0 )  THEN
635       OPEN( 90, FILE='RUN_NUMBER', FORM='FORMATTED' )
636       WRITE( 90, '(I4)' )  runnr
637       CLOSE( 90 )
638    ENDIF
639
640!
[1]641!-- Take final CPU-time for CPU-time analysis
642    CALL cpu_log( log_point(1), 'total', 'stop' )
643    CALL cpu_statistics
644
645#if defined( __parallel )
646    CALL MPI_FINALIZE( ierr )
647#endif
648
649 END PROGRAM palm
Note: See TracBrowser for help on using the repository browser.