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