Changeset 108 for palm/trunk/SOURCE


Ignore:
Timestamp:
Aug 24, 2007 3:10:38 PM (17 years ago)
Author:
letzel
Message:
  • 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.
Location:
palm/trunk/SOURCE
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SOURCE/CURRENT_MODIFICATIONS

    r107 r108  
    88communication between the two models is done using the intercommunicator
    99comm_inter,
    10 local files opened by the ocean model get the additional suffic "_O"
     10local files opened by the ocean model get the additional suffic "_O".
     11Assume saturation at k=nzb_s_inner(j,i) for atmosphere coupled to ocean.
    1112
    1213A momentum flux can be set as top boundary condition using the new
     
    1920Initial profiles are reset to constant profiles in case that initializing_actions /= 'set_constant_profiles'. (init_rankine)
    2021
    21 boundary_conds, check_open, check_parameters, diffusion_u, diffusion_v, flow_statistics, header, init_pegrid, init_rankine, init_3d_model, modules, palm, parin, pres, prognostic_equations, read_var_list, read_3d_binary, swap_timelevel, time_integration, write_var_list, write_3d_binary
     22Optionally calculate km and kh from initial TKE e_init.
     23
     24boundary_conds, check_open, check_parameters, diffusion_u, diffusion_v, flow_statistics, header, init_pegrid, init_rankine, init_3d_model, modules, palm, parin, pres, prandtl_fluxes, prognostic_equations, read_var_list, read_3d_binary, swap_timelevel, time_integration, write_var_list, write_3d_binary
    2225
    2326New:
     
    3437velocity field after the first substep.
    3538
    36 advec_particles, init_particles, time_integration
     39Initialization of km,kh = 0.00001 for ocean = .T. (for ocean = .F. it remains 0.01).
     40
     41Allow data_output_pr= q, wq, w"q", w*q* for humidity = .T. (instead of cloud_physics = .T.).
     42
     43Modifications to terminate coupled runs.
     44
     45advec_particles, check_for_restart, check_parameters, init_particles, init_3d_model, local_stop, timestep, time_integration
    3746
    3847
     
    5564Bugfix: Error message concerning output of particle concentration (pc) modified (check_parameters).
    5665
    57 advec_u_pw, advec_u_up, advec_v_pw, advec_v_up, boundary_conds, buoyancy, check_parameters, coriolis, diffusion_u, diffusion_v, init_pegrid, init_3d_model, modules, production_e, prognostic_equations, user_interface
     66Bugfix: Rayleigh damping for ocean fixed.
     67
     68advec_u_pw, advec_u_up, advec_v_pw, advec_v_up, boundary_conds, buoyancy, check_parameters, coriolis, diffusion_u, diffusion_v, header, init_pegrid, init_3d_model, modules, production_e, prognostic_equations, user_interface
  • palm/trunk/SOURCE/check_for_restart.f90

    r4 r108  
    44! Actual revisions:
    55! -----------------
     6! modifications to terminate coupled runs
    67!
    78!
     
    6768
    6869!
     70!-- In case of coupled runs inform the remote model of the termination
     71!-- and its reason, provided the remote model has not already been
     72!-- informed of another termination reason (terminate_coupled > 0) before,
     73!-- or vice versa (terminate_coupled_remote > 0).
     74    IF ( terminate_run .AND. TRIM( coupling_mode ) /= 'uncoupled'  &
     75         .AND. terminate_coupled == 0  &
     76         .AND. terminate_coupled_remote == 0 )  THEN
     77       terminate_coupled = 3
     78       CALL MPI_SENDRECV( &
     79            terminate_coupled,        1, MPI_INTEGER, myid,  0, &
     80            terminate_coupled_remote, 1, MPI_INTEGER, myid,  0, &
     81            comm_inter, status, ierr )
     82    ENDIF
     83
     84!
    6985!-- Set the stop flag also, if restart is forced by user
    7086    IF ( time_restart /= 9999999.9  .AND.  time_restart < simulated_time ) &
     
    89105             PRINT*, '                 new restart time is: ', time_restart, ' s'
    90106          ENDIF
    91     ELSE
     107!
     108!--       In case of coupled runs inform the remote model of the termination
     109!--       and its reason, provided the remote model has not already been
     110!--       informed of another termination reason (terminate_coupled > 0) before,
     111!--       or vice versa (terminate_coupled_remote > 0).
     112          IF ( coupling_mode /= 'uncoupled' .AND. terminate_coupled == 0  &
     113               .AND. terminate_coupled_remote == 0)  THEN
     114             IF ( dt_restart /= 9999999.9 )  THEN
     115                terminate_coupled = 4
     116             ELSE
     117                terminate_coupled = 5
     118             ENDIF
     119             CALL MPI_SENDRECV( &
     120                  terminate_coupled,        1, MPI_INTEGER, myid,  0, &
     121                  terminate_coupled_remote, 1, MPI_INTEGER, myid,  0, &
     122                  comm_inter, status, ierr )
     123          ENDIF
     124       ELSE
    92125          time_restart = 9999999.9
    93126       ENDIF
  • palm/trunk/SOURCE/check_parameters.f90

    r106 r108  
    99! Bugfix: Error message concerning output of particle concentration (pc)
    1010! modified
     11! More checks and more default values for coupled runs
     12! allow data_output_pr= q, wq, w"q", w*q* for humidity = .T. (instead of
     13! cloud_physics = .T.)
     14! Rayleigh damping for ocean fixed.
    1115!
    1216! Former revisions:
     
    7680    CHARACTER (LEN=100) ::  action
    7781
    78     INTEGER ::  i, ilen, intervals, iter, j, k, nnxh, nnyh, position, prec
     82    INTEGER ::  i, ilen, intervals, iremote = 0, iter, j, k, nnxh, nnyh, &
     83         position, prec
    7984    LOGICAL ::  found, ldum
    80     REAL    ::  gradient, maxn, maxp
    81 
     85    REAL    ::  gradient, maxn, maxp, remote = 0.0
    8286
    8387!
     
    103107       CALL local_stop
    104108    ENDIF
     109
     110!
     111!-- Check dt_coupling, restart_time, dt_restart, end_time, dx, dy, nx and ny
     112    IF ( coupling_mode /= 'uncoupled' )  THEN
     113       IF ( dt_coupling == 9999999.9 )  THEN
     114          IF ( myid == 0 )  THEN
     115             PRINT*, '+++ check_parameters:'
     116             PRINT*, '    dt_coupling is not set but required for coupling ', &
     117                  'mode: ', TRIM( coupling_mode )
     118          ENDIF
     119          CALL local_stop
     120       ENDIF
     121#if defined( __parallel )  &&  defined( __mpi2 )
     122       CALL MPI_SEND( dt_coupling, 1, MPI_REAL, myid, 11, comm_inter, ierr )
     123       CALL MPI_RECV( remote, 1, MPI_REAL, myid, 11, comm_inter, status, ierr )
     124       IF ( dt_coupling /= remote )  THEN
     125          IF ( myid == 0 )  THEN
     126             PRINT*, '+++ check_parameters:'
     127             PRINT*, '    TRIM( coupling_mode ): dt_coupling = ', dt_coupling
     128             PRINT*, '    is not equal to dt_coupling_remote = ', remote
     129          ENDIF
     130          CALL local_stop
     131       ENDIF
     132       CALL MPI_SEND( restart_time, 1, MPI_REAL, myid, 12, comm_inter, ierr )
     133       CALL MPI_RECV( remote, 1, MPI_REAL, myid, 12, comm_inter, status, ierr )
     134       IF ( restart_time /= remote )  THEN
     135          IF ( myid == 0 )  THEN
     136             PRINT*, '+++ check_parameters:'
     137             PRINT*, '    TRIM( coupling_mode ): restart_time = ', restart_time
     138             PRINT*, '    is not equal to restart_time_remote = ', remote
     139          ENDIF
     140          CALL local_stop
     141       ENDIF
     142       CALL MPI_SEND( dt_restart, 1, MPI_REAL, myid, 13, comm_inter, ierr )
     143       CALL MPI_RECV( remote, 1, MPI_REAL, myid, 13, comm_inter, status, ierr )
     144       IF ( dt_restart /= remote )  THEN
     145          IF ( myid == 0 )  THEN
     146             PRINT*, '+++ check_parameters:'
     147             PRINT*, '    TRIM( coupling_mode ): dt_restart = ', dt_restart
     148             PRINT*, '    is not equal to dt_restart_remote = ', remote
     149          ENDIF
     150          CALL local_stop
     151       ENDIF
     152       CALL MPI_SEND( end_time, 1, MPI_REAL, myid, 14, comm_inter, ierr )
     153       CALL MPI_RECV( remote, 1, MPI_REAL, myid, 14, comm_inter, status, ierr )
     154       IF ( end_time /= remote )  THEN
     155          IF ( myid == 0 )  THEN
     156             PRINT*, '+++ check_parameters:'
     157             PRINT*, '    TRIM( coupling_mode ): end_time = ', end_time
     158             PRINT*, '    is not equal to end_time_remote = ', remote
     159          ENDIF
     160          CALL local_stop
     161       ENDIF
     162       CALL MPI_SEND( dx, 1, MPI_REAL, myid, 15, comm_inter, ierr )
     163       CALL MPI_RECV( remote, 1, MPI_REAL, myid, 15, comm_inter, status, ierr )
     164       IF ( dx /= remote )  THEN
     165          IF ( myid == 0 )  THEN
     166             PRINT*, '+++ check_parameters:'
     167             PRINT*, '    TRIM( coupling_mode ): dx = ', dx
     168             PRINT*, '    is not equal to dx_remote = ', remote
     169          ENDIF
     170          CALL local_stop
     171       ENDIF
     172       CALL MPI_SEND( dy, 1, MPI_REAL, myid, 16, comm_inter, ierr )
     173       CALL MPI_RECV( remote, 1, MPI_REAL, myid, 16, comm_inter, status, ierr )
     174       IF ( dy /= remote )  THEN
     175          IF ( myid == 0 )  THEN
     176             PRINT*, '+++ check_parameters:'
     177             PRINT*, '    TRIM( coupling_mode ): dy = ', dy
     178             PRINT*, '    is not equal to dy_remote = ', remote
     179          ENDIF
     180          CALL local_stop
     181       ENDIF
     182       CALL MPI_SEND( nx, 1, MPI_INTEGER, myid, 17, comm_inter, ierr )
     183       CALL MPI_RECV( iremote, 1, MPI_INTEGER, myid, 17, comm_inter, status, &
     184            ierr )
     185       IF ( nx /= iremote )  THEN
     186          IF ( myid == 0 )  THEN
     187             PRINT*, '+++ check_parameters:'
     188             PRINT*, '    TRIM( coupling_mode ): nx = ', nx
     189             PRINT*, '    is not equal to nx_remote = ', iremote
     190          ENDIF
     191          CALL local_stop
     192       ENDIF
     193       CALL MPI_SEND( ny, 1, MPI_INTEGER, myid, 18, comm_inter, ierr )
     194       CALL MPI_RECV( iremote, 1, MPI_INTEGER, myid, 18, comm_inter, status, &
     195            ierr )
     196       IF ( ny /= iremote )  THEN
     197          IF ( myid == 0 )  THEN
     198             PRINT*, '+++ check_parameters:'
     199             PRINT*, '    TRIM( coupling_mode ): ny = ', ny
     200             PRINT*, '    is not equal to ny_remote = ', iremote
     201          ENDIF
     202          CALL local_stop
     203       ENDIF
     204#endif
     205    ENDIF
     206
     207#if defined( __parallel )  &&  defined( __mpi2 )
     208!
     209!-- Exchange via intercommunicator
     210    IF ( coupling_mode == 'atmosphere_to_ocean' )  THEN
     211       CALL MPI_SEND( humidity, &
     212            1, MPI_LOGICAL, myid, 19, comm_inter, ierr )
     213    ELSEIF ( coupling_mode == 'ocean_to_atmosphere' )  THEN
     214       CALL MPI_RECV( humidity_remote, &
     215            1, MPI_LOGICAL, myid, 19, comm_inter, status, ierr )
     216    ENDIF
     217#endif
     218
    105219
    106220!
     
    821935
    822936!
    823 !-- Ocean version is using flux boundary conditions at the top
    824     IF ( ocean )  use_top_fluxes = .TRUE.
     937!-- Ocean version must use flux boundary conditions at the top
     938    IF ( ocean .AND. .NOT. use_top_fluxes )  THEN
     939       IF ( myid == 0 )  PRINT*, '+++ check_parameters: use_top_fluxes ',&
     940                                    'must be .TRUE. in ocean version'
     941       CALL local_stop
     942    ENDIF
    825943
    826944!
     
    12561374       CALL local_stop
    12571375    ENDIF
    1258     IF ( bc_uv_t == 'dirichlet' )  THEN
    1259        ibc_uv_t = 0
    1260     ELSEIF ( bc_uv_t == 'neumann' )  THEN
     1376    IF ( coupling_mode == 'ocean_to_atmosphere' )  THEN
     1377       bc_uv_t = 'neumann'
    12611378       ibc_uv_t = 1
    12621379    ELSE
    1263        IF ( myid == 0 )  THEN
    1264           PRINT*, '+++ check_parameters:'
    1265           PRINT*, '    unknown boundary condition: bc_uv_t = ', bc_uv_t
    1266        ENDIF
    1267        CALL local_stop
     1380       IF ( bc_uv_t == 'dirichlet' )  THEN
     1381          ibc_uv_t = 0
     1382       ELSEIF ( bc_uv_t == 'neumann' )  THEN
     1383          ibc_uv_t = 1
     1384       ELSE
     1385          IF ( myid == 0 )  THEN
     1386             PRINT*, '+++ check_parameters:'
     1387             PRINT*, '    unknown boundary condition: bc_uv_t = ', bc_uv_t
     1388          ENDIF
     1389          CALL local_stop
     1390       ENDIF
    12681391    ENDIF
    12691392
     
    12891412
    12901413    IF ( rayleigh_damping_height == -1.0 )  THEN
    1291        rayleigh_damping_height = 0.66666666666 * zu(nzt)
     1414       IF ( .NOT. ocean )  THEN
     1415          rayleigh_damping_height = 0.66666666666 * zu(nzt)
     1416       ELSE
     1417          rayleigh_damping_height = 0.66666666666 * zu(nzb)
     1418       ENDIF
    12921419    ELSE
    1293        IF ( rayleigh_damping_height < 0.0  .OR. &
    1294             rayleigh_damping_height > zu(nzt) )  THEN
    1295           IF ( myid == 0 )  THEN
    1296              PRINT*, '+++ check_parameters:'
    1297              PRINT*, '    rayleigh_damping_height = ', rayleigh_damping_height,&
    1298                           ' out of range [0.0,', zu(nzt), ']'
    1299           ENDIF
    1300           CALL local_stop
     1420       IF ( .NOT. ocean )  THEN
     1421          IF ( rayleigh_damping_height < 0.0  .OR. &
     1422               rayleigh_damping_height > zu(nzt) )  THEN
     1423             IF ( myid == 0 )  THEN
     1424                PRINT*, '+++ check_parameters:'
     1425                PRINT*, '    rayleigh_damping_height = ', rayleigh_damping_height,&
     1426                     ' out of range [0.0,', zu(nzt), ']'
     1427             ENDIF
     1428             CALL local_stop
     1429          ENDIF
     1430       ELSE
     1431          IF ( rayleigh_damping_height > 0.0  .OR. &
     1432               rayleigh_damping_height < zu(nzb) )  THEN
     1433             IF ( myid == 0 )  THEN
     1434                PRINT*, '+++ check_parameters:'
     1435                PRINT*, '    rayleigh_damping_height = ', rayleigh_damping_height,&
     1436                     ' out of range [0.0,', zu(nzb), ']'
     1437             ENDIF
     1438             CALL local_stop
     1439          ENDIF
    13011440       ENDIF
    13021441    ENDIF
     
    16951834
    16961835          CASE ( 'q', '#q' )
    1697              IF ( .NOT. cloud_physics )  THEN
     1836             IF ( .NOT. humidity )  THEN
    16981837                IF ( myid == 0 )  THEN
    16991838                   PRINT*, '+++ check_parameters:  data_output_pr = ', &
    17001839                           data_output_pr(i),                          &
    1701                            '    is not implemented for cloud_physics = FALSE'
     1840                           '    is not implemented for humidity = FALSE'
    17021841                ENDIF
    17031842                CALL local_stop
     
    18041943
    18051944          CASE ( 'w"q"' )
    1806              IF ( .NOT. cloud_physics ) THEN
     1945             IF ( .NOT. humidity ) THEN
    18071946                IF ( myid == 0 )  THEN
    18081947                   PRINT*, '+++ check_parameters:  data_output_pr = ', &
    18091948                           data_output_pr(i),                          &
    1810                            '    is not implemented for cloud_physics = FALSE'
     1949                           '    is not implemented for humidity = FALSE'
    18111950                ENDIF
    18121951                CALL local_stop
     
    18181957
    18191958          CASE ( 'w*q*' )
    1820              IF ( .NOT. cloud_physics ) THEN
     1959             IF ( .NOT. humidity ) THEN
    18211960                IF ( myid == 0 )  THEN
    18221961                   PRINT*, '+++ check_parameters:  data_output_pr = ', &
    18231962                           data_output_pr(i),                          &
    1824                            '    is not implemented for cloud_physics = FALSE'
     1963                           '    is not implemented for humidity = FALSE'
    18251964                ENDIF
    18261965                CALL local_stop
     
    18321971
    18331972          CASE ( 'wq' )
    1834              IF ( .NOT. cloud_physics ) THEN
     1973             IF ( .NOT. humidity ) THEN
    18351974                IF ( myid == 0 )  THEN
    18361975                   PRINT*, '+++ check_parameters:  data_output_pr = ', &
    18371976                           data_output_pr(i),                          &
    1838                            '    is not implemented for cloud_physics = FALSE'
     1977                           '    is not implemented for humidity = FALSE'
    18391978                ENDIF
    18401979                CALL local_stop
  • palm/trunk/SOURCE/data_output_2d.f90

    r98 r108  
    732732                CASE ( 'xz' )
    733733!
    734 !--                Update the NetCDF xy cross section time axis
     734!--                Update the NetCDF xz cross section time axis
    735735                   IF ( myid == 0 )  THEN
    736736                      IF ( simulated_time /= do2d_xz_last_time(av) )  THEN
  • palm/trunk/SOURCE/header.f90

    r103 r108  
    66! Output of informations for coupled model runs (boundary conditions etc.)
    77! + output of momentumfluxes at the top boundary
     8! Rayleigh damping for ocean, e_init
    89!
    910! Former revisions:
     
    241242    IF ( use_upstream_for_tke )  WRITE ( io, 143 )
    242243    IF ( rayleigh_damping_factor /= 0.0 )  THEN
    243        WRITE ( io, 123 )  rayleigh_damping_height, rayleigh_damping_factor
     244       IF ( .NOT. ocean )  THEN
     245          WRITE ( io, 123 )  'above', rayleigh_damping_height, &
     246               rayleigh_damping_factor
     247       ELSE
     248          WRITE ( io, 123 )  'below', rayleigh_damping_height, &
     249               rayleigh_damping_factor
     250       ENDIF
    244251    ENDIF
    245252    IF ( humidity )  THEN
     
    10911098    ENDIF
    10921099    IF ( .NOT. constant_diffusion)  THEN
     1100       IF ( e_init > 0.0 )  WRITE ( io, 455 )  e_init
    10931101       IF ( e_min > 0.0 )  WRITE ( io, 454 )  e_min
    10941102       IF ( wall_adjustment )  WRITE ( io, 453 )  wall_adjustment_factor
     
    12401248                  ' timestep changes')
    12411249122 FORMAT (' --> Time differencing scheme: ',A)
    1242 123 FORMAT (' --> Rayleigh-Damping active, starts above z = ',F8.2,' m'/ &
     1250123 FORMAT (' --> Rayleigh-Damping active, starts ',A,' z = ',F8.2,' m'/ &
    12431251            '     maximum damping coefficient: ',F5.3, ' 1/s')
    12441252124 FORMAT ('     Spline-overshoots are being suppressed')
     
    14681476453 FORMAT ('   Mixing length is limited to ',F4.2,' * z')
    14691477454 FORMAT ('   TKE is not allowed to fall below ',E9.2,' (m/s)**2')
     1478455 FORMAT ('   initial TKE is prescribed as ',E9.2,' (m/s)**2')
    14701479470 FORMAT (//' Actions during the simulation:'/ &
    14711480              ' -----------------------------'/)
  • palm/trunk/SOURCE/init_3d_model.f90

    r106 r108  
    99! Flux initialization in case of coupled runs, +momentum fluxes at top boundary,
    1010! +arrays for phase speed c_u, c_v, c_w, indices for u|v|w_m_l|r changed
     11! +qswst_remote in case of atmosphere model with humidity coupled to ocean
     12! Rayleigh damping for ocean
     13! optionally calculate km and kh from initial TKE e_init
    1114!
    1215! Former revisions:
     
    204207       rho => rho_1  ! routine calc_mean_profile requires density to be a
    205208                     ! pointer
     209       IF ( humidity_remote )  THEN
     210          ALLOCATE( qswst_remote(nys-1:nyn+1,nxl-1:nxr+1) )
     211          qswst_remote = 0.0
     212       ENDIF
    206213    ENDIF
    207214
     
    507514             km   = km_constant
    508515             kh   = km / prandtl_number
     516             e    = 0.0
     517          ELSEIF ( e_init > 0.0 )  THEN
     518             DO  k = nzb+1, nzt
     519                km(k,:,:) = 0.1 * l_grid(k) * SQRT( e_init )
     520             ENDDO
     521             km(nzb,:,:)   = km(nzb+1,:,:)
     522             km(nzt+1,:,:) = km(nzt,:,:)
     523             kh   = km / prandtl_number
     524             e    = e_init
    509525          ELSE
    510              kh   = 0.01   ! there must exist an initial diffusion, because
    511              km   = 0.01   ! otherwise no TKE would be produced by the
    512                            ! production terms, as long as not yet
    513                            ! e = (u*/cm)**2 at k=nzb+1
    514           ENDIF
    515           e     = 0.0
     526             IF ( .NOT. ocean )  THEN
     527                kh   = 0.01   ! there must exist an initial diffusion, because
     528                km   = 0.01   ! otherwise no TKE would be produced by the
     529                              ! production terms, as long as not yet
     530                              ! e = (u*/cm)**2 at k=nzb+1
     531             ELSE
     532                kh   = 0.00001
     533                km   = 0.00001
     534             ENDIF
     535             e    = 0.0
     536          ENDIF
    516537          rif   = 0.0
    517538          ts    = 0.0
     
    892913    rdf = 0.0
    893914    IF ( rayleigh_damping_factor /= 0.0 )  THEN
    894        DO  k = nzb+1, nzt
    895           IF ( zu(k) >= rayleigh_damping_height )  THEN
    896              rdf(k) = rayleigh_damping_factor * &
     915       IF ( .NOT. ocean )  THEN
     916          DO  k = nzb+1, nzt
     917             IF ( zu(k) >= rayleigh_damping_height )  THEN
     918                rdf(k) = rayleigh_damping_factor * &
    897919                      ( SIN( pi * 0.5 * ( zu(k) - rayleigh_damping_height )    &
    898920                                      / ( zu(nzt) - rayleigh_damping_height ) )&
    899921                      )**2
    900           ENDIF
    901        ENDDO
     922             ENDIF
     923          ENDDO
     924       ELSE
     925          DO  k = nzt, nzb+1, -1
     926             IF ( zu(k) <= rayleigh_damping_height )  THEN
     927                rdf(k) = rayleigh_damping_factor * &
     928                      ( SIN( pi * 0.5 * ( rayleigh_damping_height - zu(k) )    &
     929                                      / ( rayleigh_damping_height - zu(nzb+1)))&
     930                      )**2
     931             ENDIF
     932          ENDDO
     933       ENDIF
    902934    ENDIF
    903935
  • palm/trunk/SOURCE/init_pegrid.f90

    r106 r108  
    44! Actual revisions:
    55! -----------------
     6! TEST OUTPUT (TO BE REMOVED) logging mpi2 ierr values
    67! Intercommunicator (comm_inter) and derived data type (type_xy) for
    7 ! coupled model runs created,
     8! coupled model runs created, assign coupling_mode_remote
    89! indices nxlu and nysv are calculated (needed for non-cyclic boundary
    910! conditions)
     
    467468
    468469!
    469 !--    Recieve data from the other PEs
     470!--    Receive data from the other PEs
    470471       DO  i = 1,numprocs-1
    471472          CALL MPI_RECV( ibuf, 12, MPI_INTEGER, i, MPI_ANY_TAG, comm2d, status, &
     
    494495
    495496          CALL MPI_OPEN_PORT( MPI_INFO_NULL, port_name, ierr )
     497!
     498!--       TEST OUTPUT (TO BE REMOVED)
     499          WRITE(9,*)  TRIM( coupling_mode ),  &
     500               ', ierr after MPI_OPEN_PORT: ', ierr
     501          CALL LOCAL_FLUSH( 9 )
     502
    496503          CALL MPI_PUBLISH_NAME( 'palm_coupler', MPI_INFO_NULL, port_name, &
    497504                                 ierr )
     505!
     506!--       TEST OUTPUT (TO BE REMOVED)
     507          WRITE(9,*)  TRIM( coupling_mode ),  &
     508               ', ierr after MPI_PUBLISH_NAME: ', ierr
     509          CALL LOCAL_FLUSH( 9 )
     510
    498511!
    499512!--       Write a flag file for the ocean model and the other atmosphere
     
    519532
    520533          CALL MPI_LOOKUP_NAME( 'palm_coupler', MPI_INFO_NULL, port_name, ierr )
     534!
     535!--       TEST OUTPUT (TO BE REMOVED)
     536          WRITE(9,*)  TRIM( coupling_mode ),  &
     537               ', ierr after MPI_LOOKUP_NAME: ', ierr
     538          CALL LOCAL_FLUSH( 9 )
     539
    521540
    522541       ENDIF
     
    535554       print*, '--- ierr = ', ierr
    536555       print*, '--- comm_inter atmosphere = ', comm_inter
     556
     557       coupling_mode_remote = 'ocean_to_atmosphere'
    537558
    538559    ELSEIF ( coupling_mode == 'ocean_to_atmosphere' )  THEN
     
    544565       print*, '--- ierr = ', ierr
    545566       print*, '--- comm_inter ocean      = ', comm_inter
     567
     568       coupling_mode_remote = 'atmosphere_to_ocean'
    546569
    547570    ENDIF
  • palm/trunk/SOURCE/local_stop.f90

    r4 r108  
    44! Actual revisions:
    55! -----------------
     6! modifications to terminate coupled runs
    67!
    78!
     
    2425
    2526    USE pegrid
     27    USE control_parameters
    2628
    2729#if defined( __parallel )
    28     CALL MPI_FINALIZE( ierr )
    29 #endif
     30    IF ( coupling_mode == 'uncoupled' )  THEN
     31       CALL MPI_FINALIZE( ierr )
     32    ELSE
     33
     34       SELECT CASE ( terminate_coupled_remote )
     35
     36          CASE ( 0 )
     37             IF ( myid == 0 )  THEN
     38                PRINT*, '+++ local_stop:'
     39                PRINT*, '    local model "', TRIM( coupling_mode ), &
     40                     '" stops now'
     41             ENDIF
     42!
     43!--          Inform the remote model of the termination and its reason, provided
     44!--          the remote model has not already been informed of another
     45!--          termination reason (terminate_coupled > 0) before.
     46             IF ( terminate_coupled == 0 )  THEN
     47                terminate_coupled = 1
     48                CALL MPI_SENDRECV( &
     49                     terminate_coupled,        1, MPI_INTEGER, myid,  0, &
     50                     terminate_coupled_remote, 1, MPI_INTEGER, myid,  0, &
     51                     comm_inter, status, ierr )
     52             ENDIF
     53             CALL MPI_FINALIZE( ierr )
     54
     55          CASE ( 1 )
     56             IF ( myid == 0 )  THEN
     57                PRINT*, '+++ local_stop:'
     58                PRINT*, '    remote model "', TRIM( coupling_mode_remote ), &
     59                     '" stopped'
     60             ENDIF
     61             CALL MPI_FINALIZE( ierr )
     62
     63          CASE ( 2 )
     64             IF ( myid == 0 )  THEN
     65                PRINT*, '+++ local_stop:'
     66                PRINT*, '    remote model "', TRIM( coupling_mode_remote ), &
     67                     '" terminated'
     68                PRINT*, '    with stop_dt = .T.'
     69             ENDIF
     70             stop_dt = .TRUE.
     71
     72          CASE ( 3 )
     73             IF ( myid == 0 )  THEN
     74                PRINT*, '+++ local_stop:'
     75                PRINT*, '    remote model "', TRIM( coupling_mode_remote ), &
     76                     '" terminated'
     77                PRINT*, '    with terminate_run = .T. (CPU-time limit)'
     78             ENDIF
     79             terminate_run = .TRUE.
     80
     81          CASE ( 4 )
     82             IF ( myid == 0 )  THEN
     83                PRINT*, '+++ local_stop:'
     84                PRINT*, '    remote model "', TRIM( coupling_mode_remote ), &
     85                     '" terminated'
     86                PRINT*, '    with terminate_run = .T. (restart)'
     87             ENDIF
     88             terminate_run = .TRUE.
     89             time_restart = time_restart + dt_restart
     90
     91          CASE ( 5 )
     92             IF ( myid == 0 )  THEN
     93                PRINT*, '+++ local_stop:'
     94                PRINT*, '    remote model "', TRIM( coupling_mode_remote ), &
     95                     '" terminated'
     96                PRINT*, '    with terminate_run = .T. (single restart)'
     97             ENDIF
     98             terminate_run = .TRUE.
     99             time_restart = 9999999.9
     100
     101       END SELECT
     102
     103    ENDIF
     104
     105#else
    30106
    31107    STOP
    32108
     109#endif
     110
    33111 END SUBROUTINE local_stop   
  • palm/trunk/SOURCE/modules.f90

    r106 r108  
    66! -----------------
    77! +comm_inter, constant_top_momentumflux, coupling_char, coupling_mode,
    8 ! c_u, c_v, c_w, dt_coupling, ngp_xy, nxlu, nysv, port_name, time_coupling,
    9 ! top_momentumflux_u|v, type_xy, uswst*, vswst*
     8! coupling_mode_remote, c_u, c_v, c_w, dt_coupling, e_init, humidity_remote,
     9! ngp_xy, nxlu, nysv, port_name, qswst_remote, terminate_coupled,
     10! terminate_coupled_remote, time_coupling, top_momentumflux_u|v, type_xy,
     11! uswst*, vswst*
    1012!
    1113! Former revisions:
     
    106108    REAL, DIMENSION(:,:), ALLOCATABLE ::                                       &
    107109          c_u, c_v, c_w, dzu_mg, dzw_mg, f1_mg, f2_mg, f3_mg, pt_slope_ref,    &
    108           qs, ts, us, z0
     110          qs, qswst_remote, ts, us, z0
    109111
    110112    REAL, DIMENSION(:,:), ALLOCATABLE, TARGET ::                               &
     
    253255                            bc_uv_b = 'dirichlet', bc_uv_t = 'dirichlet', &
    254256                            coupling_mode = 'uncoupled', &
     257                            coupling_mode_remote = 'uncoupled', &
    255258                            dissipation_1d = 'as_in_3d_model', &
    256259                            fft_method = 'system-specific', &
     
    292295                nz_do1d, nz_do3d = -9999, outflow_damping_width = -1, &
    293296                prt_time_count = 0, runnr = 0, skip_do_avs = 0, &
     297                terminate_coupled = 0, terminate_coupled_remote = 0, &
    294298                timestep_count = 0
    295299
     
    323327                first_call_advec_particles = .TRUE., &
    324328                force_print_header = .FALSE., galilei_transformation = .FALSE.,&
    325                 humidity = .FALSE., inflow_l = .FALSE., inflow_n = .FALSE., &
     329                humidity = .FALSE., humidity_remote = .FALSE., &
     330                inflow_l = .FALSE., inflow_n = .FALSE., &
    326331                inflow_r = .FALSE., inflow_s = .FALSE., iso2d_output = .FALSE.,&
    327332                mg_switch_to_pe0 = .FALSE., &
     
    366371             dt_run_control = 60.0, dt_3d = -1.0, dz = -1.0, &
    367372             dz_max = 9999999.9, dz_stretch_factor = 1.08, &
    368              dz_stretch_level = 100000.0, e_min = 0.0, end_time = 0.0, &
     373             dz_stretch_level = 100000.0, e_init = 0.0, e_min = 0.0, &
     374             end_time = 0.0, &
    369375             f = 0.0, fs = 0.0, g = 9.81, kappa = 0.4, km_constant = -1.0, &
    370376             km_damp_max = -1.0, long_filter_factor = 0.0, &
  • palm/trunk/SOURCE/palm.f90

    r102 r108  
    55! -----------------
    66! Get coupling mode from environment variable
     7! Change localtion of debug output
    78!
    89! Former revisions:
     
    101102    CALL MPI_COMM_RANK( comm_palm, myid, ierr )
    102103#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
    112104
    113105!
    114106!-- Open a file for debug output
     107    WRITE (myid_char,'(''_'',I4.4)')  myid
    115108    OPEN( 9, FILE='DEBUG'//TRIM( coupling_char )//myid_char, FORM='FORMATTED' )
    116109
     
    122115    print*, '*** PE', myid, '  ', TRIM( coupling_mode )
    123116#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
    124127
    125128!
  • palm/trunk/SOURCE/parin.f90

    r102 r108  
    44! Actual revisions:
    55! -----------------
    6 ! +top_momentumflux_u|v in inipar, +dt_coupling in d3par
     6! +e_init, top_momentumflux_u|v in inipar, +dt_coupling in d3par
    77!
    88! Former revisions:
     
    7272             conserve_volume_flow, cut_spline_overshoot, damp_level_1d, &
    7373             dissipation_1d, dt, dt_pr_1d, dt_run_control_1d, dx, dy, dz, &
    74              dz_max, dz_stretch_factor, dz_stretch_level, e_min, end_time_1d, &
     74             dz_max, dz_stretch_factor, dz_stretch_level, e_init, e_min, &
     75             end_time_1d, &
    7576             fft_method, galilei_transformation, grid_matching, humidity, &
    7677             inflow_disturbance_begin, inflow_disturbance_end, &
  • palm/trunk/SOURCE/prandtl_fluxes.f90

    r77 r108  
    44! Actual revisions:
    55! -----------------
    6 !
     6! assume saturation at k=nzb_s_inner(j,i) for atmosphere coupled to ocean
    77!
    88! Former revisions:
     
    3636
    3737    INTEGER ::  i, j, k
    38     REAL    ::  a, b, rifm, uv_total, z_p
     38    REAL    ::  a, b, e_q, rifm, uv_total, z_p
    3939
    4040!
     
    297297                z_p = zu(k+1) - zw(k)
    298298
     299!
     300!--             assume saturation for atmosphere coupled to ocean
     301                IF ( coupling_mode == 'atmosphere_to_ocean' )  THEN
     302                   e_q = 6.1 * &
     303                        EXP( 0.07 * ( MIN(pt(0,j,i),pt(1,j,i)) - 273.15 ) )
     304                   q(k,j,i) = 0.622 * e_q / ( surface_pressure - e_q )
     305                ENDIF
    299306                IF ( rif(j,i) >= 0.0 )  THEN
    300307!
  • palm/trunk/SOURCE/production_e.f90

    r106 r108  
    88! u_0 and v_0 are calculated for nxr+1, nyn+1 also (otherwise these values are
    99! not available in case of non-cyclic boundary conditions)
     10! Bugfix for ocean density flux at bottom
    1011!
    1112! Former revisions:
     
    810811!--             So far in the ocean no special treatment of density flux in the
    811812!--             bottom and top surface layer
    812                 DO  k = nzb_s_inner(j,i), nzt
     813                k= nzb_s_inner(j,i)
     814                tend(k,j,i) = tend(k,j,i) + kh(k,j,i) * g / prho_reference * &
     815                     ( rho(k+1,j,i) - rho(k,j,i) ) * dzu(k+1)
     816                DO  k = nzb_s_inner(j,i)+1, nzt
    813817                   tend(k,j,i) = tend(k,j,i) + kh(k,j,i) * g / prho_reference * &
    814818                                      ( rho(k+1,j,i) - rho(k-1,j,i) ) * dd2zu(k)
  • palm/trunk/SOURCE/surface_coupler.f90

    r102 r108  
    44! Actual revisions:
    55! -----------------
     6! include latent heatflux and salinity flux for atmosphere runs with moisture
     7! modifications to terminate coupled runs
    68!
    79!
     
    2729    IMPLICIT NONE
    2830
    29     INTEGER ::  k
     31    INTEGER ::  i, j, k
    3032
    3133    REAL    ::  simulated_time_remote
     
    3638
    3739!
    38 !-- First exchange the current simulated time between the models,
     40!-- In case of model termination initiated by the remote model
     41!-- (terminate_coupled_remote > 0), initiate termination of the local model.
     42!-- The rest of the coupler must then be skipped because it would cause an MPI
     43!-- intercomminucation hang.
     44!-- If necessary, the coupler will be called at the beginning of the next
     45!-- restart run.
     46    CALL MPI_SENDRECV( terminate_coupled,        1, MPI_INTEGER, myid,  0, &
     47                       terminate_coupled_remote, 1, MPI_INTEGER, myid,  0, &
     48                       comm_inter, status, ierr )
     49    IF ( terminate_coupled_remote > 0 )  THEN
     50       IF ( myid == 0 )  THEN
     51          PRINT*, '+++ surface_coupler:'
     52          PRINT*, '    remote model "', TRIM( coupling_mode_remote ), &
     53               '" terminated'
     54          PRINT*, '    with terminate_coupled_remote = ', &
     55               terminate_coupled_remote
     56          PRINT*, '    local model  "', TRIM( coupling_mode ), &
     57               '" has'
     58          PRINT*, '    terminate_coupled = ', &
     59               terminate_coupled
     60       ENDIF
     61       CALL local_stop
     62       RETURN
     63    ENDIF
     64!
     65!-- Exchange the current simulated time between the models,
    3966!-- currently just for testing
    4067    CALL MPI_SEND( simulated_time, 1, MPI_REAL, myid, 11, comm_inter, ierr )
     
    5885
    5986!
     87!--    Send humidity flux at bottom surface to the ocean model
     88       IF ( humidity )  THEN
     89          WRITE ( 9, * )  '*** send qsws to ocean'
     90          CALL local_flush( 9 )
     91          CALL MPI_SEND( qsws(nys-1,nxl-1), ngp_xy, MPI_REAL, myid, 13, &
     92               comm_inter, ierr )
     93          WRITE ( 9, * )  '    ready'
     94          CALL local_flush( 9 )
     95       ENDIF
     96
     97!
    6098!--    Receive temperature at the bottom surface from the ocean model
    6199       WRITE ( 9, * )  '*** receive pt from ocean'
    62100       CALL local_flush( 9 )
    63        CALL MPI_RECV( pt(0,nys-1,nxl-1), 1, type_xy, myid, 13, comm_inter, &
     101       CALL MPI_RECV( pt(0,nys-1,nxl-1), 1, type_xy, myid, 14, comm_inter, &
    64102                      status, ierr )
    65103       WRITE ( 9, * )  '    ready'
     
    70108       WRITE ( 9, * )  '*** send usws to ocean'
    71109       CALL local_flush( 9 )
    72        CALL MPI_SEND( usws(nys-1,nxl-1), ngp_xy, MPI_REAL, myid, 14, &
     110       CALL MPI_SEND( usws(nys-1,nxl-1), ngp_xy, MPI_REAL, myid, 15, &
    73111                      comm_inter, ierr )
    74112       WRITE ( 9, * )  '    ready'
     
    79117       WRITE ( 9, * )  '*** send vsws to ocean'
    80118       CALL local_flush( 9 )
    81        CALL MPI_SEND( vsws(nys-1,nxl-1), ngp_xy, MPI_REAL, myid, 15, &
     119       CALL MPI_SEND( vsws(nys-1,nxl-1), ngp_xy, MPI_REAL, myid, 16, &
    82120                      comm_inter, ierr )
    83121       WRITE ( 9, * )  '    ready'
     
    96134
    97135!
     136!--    Receive humidity flux from the atmosphere model (bottom)
     137!--    and add it to the heat flux at the sea surface (top)...
     138       IF ( humidity_remote )  THEN
     139          WRITE ( 9, * )  '*** receive qswst_remote from atmosphere'
     140          CALL local_flush( 9 )
     141          CALL MPI_RECV( qswst_remote(nys-1,nxl-1), ngp_xy, MPI_REAL, myid, &
     142               13, comm_inter, status, ierr )
     143          WRITE ( 9, * )  '    ready'
     144          CALL local_flush( 9 )
     145
     146          tswst = tswst + qswst_remote * 2.2626108e6
     147          !latent heat of vaporization in m2/s2, or 540 cal/g, or 40.65 kJ/mol
     148!
     149!--    ...and convert it to a salinity flux at the sea surface (top)
     150!--       following Steinhorn (1991), JPO 21, pp. 1681-1683:
     151!--       S'w' = -S * evaporation / ( rho_water * ( 1 - S ) )
     152          saswst = -1.0 * sa(nzt,:,:) * qswst_remote /  &
     153               ( rho(nzt,:,:) * ( 1.0 - sa(nzt,:,:) ) )
     154       ENDIF
     155
     156!
    98157!--    Adjust the kinematic heat flux with respect to ocean density
    99158!--    (constants are the specific heat capacities for air and water)
    100        tswst = tswst / rho_surface * 1005.0 / 4218.0
     159       tswst = tswst / rho(nzt,:,:) * 1005.0 / 4218.0
    101160
    102161!
     
    104163       WRITE ( 9, * )  '*** send pt to atmosphere'
    105164       CALL local_flush( 9 )
    106        CALL MPI_SEND( pt(nzt,nys-1,nxl-1), 1, type_xy, myid, 13, comm_inter, &
     165       CALL MPI_SEND( pt(nzt,nys-1,nxl-1), 1, type_xy, myid, 14, comm_inter, &
    107166                      ierr )
    108167       WRITE ( 9, * )  '    ready'
     
    114173       WRITE ( 9, * )  '*** receive uswst from atmosphere'
    115174       CALL local_flush( 9 )
    116        CALL MPI_RECV( uswst(nys-1,nxl-1), ngp_xy, MPI_REAL, myid, 14, &
     175       CALL MPI_RECV( uswst(nys-1,nxl-1), ngp_xy, MPI_REAL, myid, 15, &
    117176                      comm_inter, status, ierr )
    118177       WRITE ( 9, * )  '    ready'
     
    124183       WRITE ( 9, * )  '*** receive vswst from atmosphere'
    125184       CALL local_flush( 9 )
    126        CALL MPI_RECV( vswst(nys-1,nxl-1), ngp_xy, MPI_REAL, myid, 15, &
     185       CALL MPI_RECV( vswst(nys-1,nxl-1), ngp_xy, MPI_REAL, myid, 16, &
    127186                      comm_inter, status, ierr )
    128187       WRITE ( 9, * )  '    ready'
     
    131190!
    132191!--    Adjust the momentum fluxes with respect to ocean density
    133        uswst = uswst / rho_surface
    134        vswst = vswst / rho_surface
     192       uswst = uswst / rho(nzt,:,:)
     193       vswst = vswst / rho(nzt,:,:)
    135194
    136195    ENDIF
  • palm/trunk/SOURCE/time_integration.f90

    r106 r108  
    99! random perturbation has to be added to the velocity fields also after the
    1010! first substep
     11! modifications to terminate coupled runs
     12!
    1113!
    1214! Former revisions:
     
    7880    CALL run_control
    7981
     82!
     83!-- Data exchange between coupled models in case that a call has been omitted
     84!-- at the end of the previous run of a job chain.
     85    IF ( coupling_mode /= 'uncoupled' )  THEN
     86!
     87!--    In case of model termination initiated by the local model the coupler
     88!--    must not be called because this would again cause an MPI hang.
     89       DO WHILE ( time_coupling >= dt_coupling .AND. terminate_coupled == 0 )
     90          CALL surface_coupler
     91          time_coupling = time_coupling - dt_coupling
     92       ENDDO
     93    ENDIF
     94
     95
    8096#if defined( __dvrp_graphics )
    8197!
     
    306322       IF ( coupling_mode /= 'uncoupled' )  THEN
    307323          time_coupling = time_coupling + dt_3d
    308           DO WHILE ( time_coupling >= dt_coupling )
     324!
     325!--       In case of model termination initiated by the local model
     326!--       (terminate_coupled > 0), the coupler must be skipped because it would
     327!--       cause an MPI intercomminucation hang.
     328!--       If necessary, the coupler will be called at the beginning of the
     329!--       next restart run.
     330          DO WHILE ( time_coupling >= dt_coupling .AND. terminate_coupled == 0 )
    309331             CALL surface_coupler
    310332             time_coupling = time_coupling - dt_coupling
     
    327349!--    Check, if restart is necessary (because cpu-time is expiring or
    328350!--    because it is forced by user) and set stop flag
    329        CALL check_for_restart
     351!--    This call is skipped if the remote model has already initiated a restart.
     352       IF ( .NOT. terminate_run )  CALL check_for_restart
    330353
    331354!
  • palm/trunk/SOURCE/timestep.f90

    r4 r108  
    44! Actual revisions:
    55! -----------------
     6! modifications to terminate coupled runs
    67!
    78!
     
    192193       IF ( dt_3d < ( 0.00001 * dt_max ) )  THEN
    193194          stop_dt = .TRUE.
     195
    194196          IF ( myid == 0 )  THEN
    195197             PRINT*,'+++ time_step: Time step has reached minimum limit.'
     
    207209                    '  j=', w_max_ijk(2), '  i=', w_max_ijk(3)
    208210          ENDIF
     211!
     212!--       In case of coupled runs inform the remote model of the termination
     213!--       and its reason, provided the remote model has not already been
     214!--       informed of another termination reason (terminate_coupled > 0) before.
     215          IF ( coupling_mode /= 'uncoupled' .AND. terminate_coupled == 0 )  THEN
     216             terminate_coupled = 2
     217             CALL MPI_SENDRECV( &
     218                  terminate_coupled,        1, MPI_INTEGER, myid,  0, &
     219                  terminate_coupled_remote, 1, MPI_INTEGER, myid,  0, &
     220                  comm_inter, status, ierr )
     221          ENDIF
     222
    209223       ENDIF
    210224
Note: See TracChangeset for help on using the changeset viewer.