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