Ignore:
Timestamp:
Sep 24, 2018 3:42:55 PM (6 years ago)
Author:
knoop
Message:

Modularization of all bulk cloud physics code components

File:
1 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SOURCE/init_3d_model.f90

    r3241 r3274  
    2525! -----------------
    2626! $Id$
     27! Modularization of all bulk cloud physics code components
     28!
     29! 3241 2018-09-12 15:02:00Z raasch
    2730! unused variables removed
    2831!
     
    255258! precipitation_amount, precipitation_rate, prr moved to arrays_3d.
    256259! Initialization of nc_1d, nr_1d, pt_1d, qc_1d, qr_1d, q_1d moved to
    257 ! microphysics_init.
     260! bcm_init.
    258261!
    259262! 1845 2016-04-08 08:29:13Z raasch
     
    498501    USE arrays_3d
    499502
     503    USE basic_constants_and_equations_mod,                                     &
     504        ONLY:  c_p, g, l_v, pi, r_d, exner_function, exner_function_invers,    &
     505               ideal_gas_law_rho, ideal_gas_law_rho_pt, barometric_formula
     506
     507    USE bulk_cloud_model_mod,                                                  &
     508        ONLY:  bulk_cloud_model, bcm_init, bcm_init_arrays
     509
    500510    USE chemistry_model_mod,                                                   &
    501511        ONLY:  chem_emissions
    502512
    503     USE cloud_parameters,                                                      &
    504         ONLY:  cp, l_v, r_d
    505 
    506     USE constants,                                                             &
    507         ONLY:  pi
    508    
    509513    USE control_parameters
    510514   
     
    530534    USE lsf_nudging_mod,                                                       &
    531535        ONLY:  lsf_init, ls_forcing_surf, nudge_init
    532 
    533     USE microphysics_mod,                                                      &
    534         ONLY:  microphysics_init
    535536
    536537    USE model_1d_mod,                                                          &
     
    738739#endif
    739740
    740        IF ( cloud_physics )  THEN
    741 !
    742 !--          Liquid water content
    743 #if defined( __nopointer )
    744           ALLOCATE ( ql(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    745 #else
    746           ALLOCATE ( ql_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    747 #endif
    748 
    749 !
    750 !--       3D-cloud water content
    751           IF ( .NOT. microphysics_morrison )  THEN
    752 #if defined( __nopointer )
    753              ALLOCATE( qc(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    754 #else
    755              ALLOCATE( qc_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    756 #endif
    757           ENDIF
    758 !
    759 !--       Precipitation amount and rate (only needed if output is switched)
    760           ALLOCATE( precipitation_amount(nysg:nyng,nxlg:nxrg) )
    761 
    762 !
    763 !--       3d-precipitation rate
    764           ALLOCATE( prr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    765 
    766           IF ( microphysics_morrison )  THEN
    767 !
    768 !--          3D-cloud drop water content, cloud drop concentration arrays
    769 #if defined( __nopointer )
    770              ALLOCATE( nc(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                      &
    771                        nc_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                    &
    772                        qc(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                      &
    773                        qc_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                    &
    774                        tnc_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                   &
    775                        tqc_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    776 #else
    777              ALLOCATE( nc_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                    &
    778                        nc_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                    &
    779                        nc_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                    &
    780                        qc_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                    &
    781                        qc_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                    &
    782                        qc_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    783 #endif
    784           ENDIF
    785 
    786           IF ( microphysics_seifert )  THEN
    787 !
    788 !--          3D-rain water content, rain drop concentration arrays
    789 #if defined( __nopointer )
    790              ALLOCATE( nr(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                      &
    791                        nr_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                    &
    792                        qr(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                      &
    793                        qr_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                    &
    794                        tnr_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                   &
    795                        tqr_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    796 #else
    797              ALLOCATE( nr_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                    &
    798                        nr_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                    &
    799                        nr_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                    &
    800                        qr_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                    &
    801                        qr_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                    &
    802                        qr_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    803 #endif
    804           ENDIF
    805 
    806        ENDIF
    807 
    808741       IF ( cloud_droplets )  THEN
    809742!
     
    868801!
    869802!-- Density profile calculation for anelastic approximation
    870     t_surface = pt_surface * ( surface_pressure / 1000.0_wp )**( r_d / cp )
     803    t_surface = pt_surface * ( surface_pressure / 1000.0_wp )**( r_d / c_p )
    871804    IF ( TRIM( approximation ) == 'anelastic' ) THEN
    872805       DO  k = nzb, nzt+1
    873806          p_hydrostatic(k)    = surface_pressure * 100.0_wp *                  &
    874                                 ( 1 - ( g * zu(k) ) / ( cp * t_surface )       &
    875                                 )**( cp / r_d )
     807                                ( 1 - ( g * zu(k) ) / ( c_p * t_surface )      &
     808                                )**( c_p / r_d )
    876809          rho_air(k)          = ( p_hydrostatic(k) *                           &
    877810                                  ( 100000.0_wp / p_hydrostatic(k)             &
    878                                   )**( r_d / cp )                              &
     811                                  )**( r_d / c_p )                             &
    879812                                ) / ( r_d * pt_init(k) )
    880813       ENDDO
     
    887820       DO  k = nzb, nzt+1
    888821          p_hydrostatic(k)    = surface_pressure * 100.0_wp *                  &
    889                                 ( 1 - ( g * zu(nzb) ) / ( cp * t_surface )       &
    890                                 )**( cp / r_d )
     822                                ( 1 - ( g * zu(nzb) ) / ( c_p * t_surface )    &
     823                                )**( c_p / r_d )
    891824          rho_air(k)          = ( p_hydrostatic(k) *                           &
    892825                                  ( 100000.0_wp / p_hydrostatic(k)             &
    893                                   )**( r_d / cp )                              &
     826                                  )**( r_d / c_p )                             &
    894827                                ) / ( r_d * pt_init(nzb) )
    895828       ENDDO
     
    923856            momentumflux_input_conversion(k)  = rho_air_zw(k)
    924857        ELSEIF ( TRIM( flux_input_mode ) == 'dynamic' ) THEN
    925             heatflux_input_conversion(k)      = 1.0_wp / cp
     858            heatflux_input_conversion(k)      = 1.0_wp / c_p
    926859            waterflux_input_conversion(k)     = 1.0_wp / l_v
    927860            momentumflux_input_conversion(k)  = 1.0_wp
     
    933866            momentumflux_output_conversion(k) = drho_air_zw(k)
    934867        ELSEIF ( TRIM( flux_output_mode ) == 'dynamic' ) THEN
    935             heatflux_output_conversion(k)     = cp
     868            heatflux_output_conversion(k)     = c_p
    936869            waterflux_output_conversion(k)    = l_v
    937870            momentumflux_output_conversion(k) = 1.0_wp
     
    1065998    IF ( humidity )  THEN
    1066999       q => q_1;  q_p => q_2;  tq_m => q_3
    1067        IF ( humidity )  THEN
    1068           vpt  => vpt_1   
    1069           IF ( cloud_physics )  THEN
    1070              ql => ql_1
    1071              IF ( .NOT. microphysics_morrison )  THEN
    1072                 qc => qc_1
    1073              ENDIF
    1074              IF ( microphysics_morrison )  THEN
    1075                 qc => qc_1;  qc_p  => qc_2;  tqc_m  => qc_3
    1076                 nc => nc_1;  nc_p  => nc_2;  tnc_m  => nc_3
    1077              ENDIF
    1078              IF ( microphysics_seifert )  THEN
    1079                 qr => qr_1;  qr_p  => qr_2;  tqr_m  => qr_3
    1080                 nr => nr_1;  nr_p  => nr_2;  tnr_m  => nr_3
    1081              ENDIF
    1082           ENDIF
    1083        ENDIF
     1000       vpt  => vpt_1
    10841001       IF ( cloud_droplets )  THEN
    10851002          ql   => ql_1
     
    11021019!-- Initialize surface arrays
    11031020    CALL init_surface_arrays
     1021!
     1022!-- Allocate microphysics module arrays
     1023    IF ( bulk_cloud_model )  THEN
     1024       CALL bcm_init_arrays
     1025    ENDIF
    11041026!
    11051027!-- Allocate land surface model arrays
     
    12971219!--       Set inital w to 0
    12981220          w = 0.0_wp
    1299 !
    1300 !--       Initialize the remaining quantities
    1301           IF ( humidity )  THEN
    1302              IF ( cloud_physics  .AND.  microphysics_morrison )  THEN
    1303                 DO  i = nxlg, nxrg
    1304                    DO  j = nysg, nyng
    1305                       qc(:,j,i) = 0.0_wp
    1306                       nc(:,j,i) = 0.0_wp
    1307                    ENDDO
    1308                 ENDDO
    1309              ENDIF
    1310 
    1311              IF ( cloud_physics  .AND.  microphysics_seifert )  THEN
    1312                 DO  i = nxlg, nxrg
    1313                    DO  j = nysg, nyng
    1314                       qr(:,j,i) = 0.0_wp
    1315                       nr(:,j,i) = 0.0_wp
    1316                    ENDDO
    1317                 ENDDO
    1318              ENDIF
    1319 
    1320           ENDIF
    13211221
    13221222          IF ( passive_scalar )  THEN
     
    13761276                ENDDO
    13771277             ENDDO
    1378              IF ( cloud_physics  .AND.  microphysics_morrison )  THEN
    1379                 DO  i = nxlg, nxrg
    1380                    DO  j = nysg, nyng
    1381                       qc(:,j,i) = 0.0_wp
    1382                       nc(:,j,i) = 0.0_wp
    1383                    ENDDO
    1384                 ENDDO
    1385              ENDIF
    1386              IF ( cloud_physics  .AND.  microphysics_seifert )  THEN
    1387                 DO  i = nxlg, nxrg
    1388                    DO  j = nysg, nyng
    1389                       qr(:,j,i) = 0.0_wp
    1390                       nr(:,j,i) = 0.0_wp
    1391                    ENDDO
    1392                 ENDDO
    1393              ENDIF
    13941278          ENDIF
    13951279
     
    14851369                ENDDO
    14861370             ENDDO
    1487              IF ( cloud_physics  .AND.  microphysics_morrison )  THEN
    1488                 DO  i = nxlg, nxrg
    1489                    DO  j = nysg, nyng
    1490                       qc(:,j,i) = 0.0_wp
    1491                       nc(:,j,i) = 0.0_wp
    1492                    ENDDO
    1493                 ENDDO
    1494              ENDIF
    1495 
    1496              IF ( cloud_physics  .AND.  microphysics_seifert )  THEN
    1497                 DO  i = nxlg, nxrg
    1498                    DO  j = nysg, nyng
    1499                       qr(:,j,i) = 0.0_wp
    1500                       nr(:,j,i) = 0.0_wp
    1501                    ENDDO
    1502                 ENDDO
    1503              ENDIF
    1504 
    15051371          ENDIF
    15061372         
     
    15981464!--       Store initial profile of mixing ratio and potential
    15991465!--       temperature
    1600           IF ( cloud_physics  .OR.  cloud_droplets ) THEN
     1466          IF ( bulk_cloud_model  .OR.  cloud_droplets ) THEN
    16011467             hom(:,1,27,:) = SPREAD(  q(:,nys,nxl), 2, statistic_regions+1 )
    16021468             hom(:,1,28,:) = SPREAD( pt(:,nys,nxl), 2, statistic_regions+1 )
     
    16451511!--    In case of iterative solvers, p must get an initial value
    16461512       IF ( psolver(1:9) == 'multigrid'  .OR.  psolver == 'sor' )  p = 0.0_wp
    1647 
    1648 !
    1649 !--    Treating cloud physics, liquid water content and precipitation amount
    1650 !--    are zero at beginning of the simulation
    1651        IF ( cloud_physics )  THEN
    1652           ql = 0.0_wp
    1653           qc = 0.0_wp
    1654 
    1655           precipitation_amount = 0.0_wp
    1656        ENDIF
    16571513!
    16581514!--    Impose vortex with vertical axis on the initial velocity profile
     
    16931549          tq_m = 0.0_wp
    16941550          q_p = q
    1695           IF ( cloud_physics  .AND.  microphysics_morrison )  THEN
    1696              tqc_m = 0.0_wp
    1697              qc_p  = qc
    1698              tnc_m = 0.0_wp
    1699              nc_p  = nc
    1700           ENDIF
    1701           IF ( cloud_physics  .AND.  microphysics_seifert )  THEN
    1702              tqr_m = 0.0_wp
    1703              qr_p  = qr
    1704              tnr_m = 0.0_wp
    1705              nr_p  = nr
    1706           ENDIF
    17071551       ENDIF
    17081552       
     
    19631807       IF ( humidity )  THEN
    19641808          q_p = q
    1965           IF ( cloud_physics  .AND.  microphysics_morrison )  THEN
    1966              qc_p = qc
    1967              nc_p = nc
    1968           ENDIF
    1969           IF ( cloud_physics  .AND.  microphysics_seifert )  THEN
    1970              qr_p = qr
    1971              nr_p = nr
    1972           ENDIF
    19731809       ENDIF
    19741810       IF ( passive_scalar )  s_p  = s
     
    19821818       IF ( humidity )  THEN
    19831819          tq_m = 0.0_wp
    1984           IF ( cloud_physics  .AND.  microphysics_morrison )  THEN
    1985              tqc_m = 0.0_wp
    1986              tnc_m = 0.0_wp
    1987           ENDIF
    1988           IF ( cloud_physics  .AND.  microphysics_seifert )  THEN
    1989              tqr_m = 0.0_wp
    1990              tnr_m = 0.0_wp
    1991           ENDIF
    19921820       ENDIF
    19931821       IF ( passive_scalar )  ts_m  = 0.0_wp
     
    24172245       CALL init_ocean
    24182246
    2419     ELSE
     2247    ENDIF
    24202248!
    24212249!--    Initialize quantities for handling cloud physics
    24222250!--    This routine must be called before lpm_init, because
    2423 !--    otherwise, array pt_d_t, needed in data_output_dvrp (called by
     2251!--    otherwise, array d_exner, needed in data_output_dvrp (called by
    24242252!--    lpm_init) is not defined.
    2425        CALL init_cloud_physics
    2426 !
    2427 !--    Initialize bulk cloud microphysics
    2428        CALL microphysics_init
     2253    IF ( .NOT. ocean )  THEN
     2254
     2255       ALLOCATE( hyp(nzb:nzt+1) )
     2256       ALLOCATE( d_exner(nzb:nzt+1) )
     2257       ALLOCATE( exner(nzb:nzt+1) )
     2258       ALLOCATE( hyrho(nzb:nzt+1) )
     2259!
     2260!--    Check temperature in case of too large domain height
     2261       DO  k = nzb, nzt+1
     2262          IF ( ( pt_surface * exner_function(surface_pressure * 100.0_wp) - g/c_p * zu(k) ) < 0.0_wp )  THEN
     2263             WRITE( message_string, * )  'absolute temperature < 0.0 at zu(', k, &
     2264                                         ') = ', zu(k)
     2265             CALL message( 'init_bulk_cloud_model', 'PA0142', 1, 2, 0, 6, 0 )
     2266          ENDIF
     2267       ENDDO
     2268
     2269!
     2270!--    Calculate vertical profile of the hydrostatic pressure (hyp)
     2271       hyp    = barometric_formula(zu, pt_surface * exner_function(surface_pressure * 100.0_wp), surface_pressure * 100.0_wp)
     2272       d_exner = exner_function_invers(hyp)
     2273       exner = 1.0_wp / exner_function_invers(hyp)
     2274       hyrho  = ideal_gas_law_rho_pt(hyp, pt_init)
     2275!
     2276!--    Compute reference density
     2277       rho_surface = ideal_gas_law_rho(surface_pressure * 100.0_wp, pt_surface * exner_function(surface_pressure * 100.0_wp))
     2278
     2279    ENDIF
     2280!
     2281!-- If required, initialize quantities needed for the microphysics module
     2282    IF ( bulk_cloud_model )  THEN
     2283       CALL bcm_init
    24292284    ENDIF
    24302285
Note: See TracChangeset for help on using the changeset viewer.