Skip to content

Commit 544e33c

Browse files
committed
Addressing more initial review comments
1 parent a019b23 commit 544e33c

File tree

2 files changed

+50
-23
lines changed

2 files changed

+50
-23
lines changed

cime_config/testdefs/testmods_dirs/cam/silhs/user_nl_cam

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fincl1 = 'U:A','PS:A','T:A','V:A','OMEGA:A','Z3:A','PRECT:A',
4646
'rtp2_dp2', 'rtp2_cl', 'rtp2_pd', 'rtp2_sf', 'rtp2_forcing', 'rtp2_mc', 'thlp2_bt', 'thlp2_ma', 'thlp2_ta', 'thlp2_tp', 'thlp2_dp1', 'thlp2_dp2', 'thlp2_cl',
4747
'thlp2_pd', 'thlp2_sf', 'thlp2_forcing', 'thlp2_mc', 'rtpthlp_bt', 'rtpthlp_ma', 'rtpthlp_ta', 'rtpthlp_tp1', 'rtpthlp_tp2', 'rtpthlp_dp1', 'rtpthlp_dp2',
4848
'rtpthlp_cl', 'rtpthlp_sf', 'rtpthlp_forcing', 'rtpthlp_mc', 'wpthlp_enter_mfl', 'wpthlp_exit_mfl', 'wprtp_enter_mfl', 'wprtp_exit_mfl', 'wpthlp_mfl_min',
49-
'wpthlp_mfl_max', 'wprtp_mfl_min', 'wprtp_mfl_max', 'shear_sqd',
49+
'wpthlp_mfl_max', 'wprtp_mfl_min', 'wprtp_mfl_max', 'shear_sqd', 'Ri_zm'
5050
fincl2 = 'CLDTOT', 'CLDST','CDNUMC','CLDLIQ','CLDICE','FLUT',
5151
'LWCF','SWCF','PRECT'
5252
clubb_history = .true.
@@ -77,4 +77,4 @@ clubb_vars_zm= 'wp2', 'rtp2', 'thlp2', 'rtpthlp', 'wprtp', 'wpthlp', 'wp4', 'up2
7777
'rtp2_dp2', 'rtp2_cl', 'rtp2_pd', 'rtp2_sf', 'rtp2_forcing', 'rtp2_mc', 'thlp2_bt', 'thlp2_ma', 'thlp2_ta', 'thlp2_tp', 'thlp2_dp1', 'thlp2_dp2', 'thlp2_cl',
7878
'thlp2_pd', 'thlp2_sf', 'thlp2_forcing', 'thlp2_mc', 'rtpthlp_bt', 'rtpthlp_ma', 'rtpthlp_ta', 'rtpthlp_tp1', 'rtpthlp_tp2', 'rtpthlp_dp1', 'rtpthlp_dp2',
7979
'rtpthlp_cl', 'rtpthlp_sf', 'rtpthlp_forcing', 'rtpthlp_mc', 'wpthlp_enter_mfl', 'wpthlp_exit_mfl', 'wprtp_enter_mfl', 'wprtp_exit_mfl', 'wpthlp_mfl_min',
80-
'wpthlp_mfl_max', 'wprtp_mfl_min', 'wprtp_mfl_max', 'shear_sqd'
80+
'wpthlp_mfl_max', 'wprtp_mfl_min', 'wprtp_mfl_max', 'shear_sqd', 'Ri_zm'

src/physics/cam/clubb_intr.F90

Lines changed: 48 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,7 @@ subroutine clubb_ini_cam(pbuf2d)
14271427
logical, parameter :: l_input_fields = .false. ! Always false for CAM-CLUBB.
14281428
logical, parameter :: l_update_pressure = .false. ! Always false for CAM-CLUBB.
14291429

1430-
integer :: nlev
1430+
integer :: nlev, ierr=0
14311431

14321432
real(r8) :: &
14331433
C1, C1b, C1c, C2rt, C2thl, C2rtthl, &
@@ -1465,7 +1465,8 @@ subroutine clubb_ini_cam(pbuf2d)
14651465
allocate( &
14661466
pdf_params_chnk(begchunk:endchunk), &
14671467
pdf_params_zm_chnk(begchunk:endchunk), &
1468-
pdf_implicit_coefs_terms_chnk(begchunk:endchunk) )
1468+
pdf_implicit_coefs_terms_chnk(begchunk:endchunk), stat=ierr )
1469+
if( ierr /= 0 ) call endrun(' clubb_ini_cam: failed to allocate pdf_params')
14691470

14701471
! ----------------------------------------------------------------- !
14711472
! Determine how many constituents CLUBB will transport. Note that
@@ -1831,13 +1832,18 @@ subroutine clubb_ini_cam(pbuf2d)
18311832
stats_zt(:), stats_zm(:), stats_sfc(:), &
18321833
stats_rad_zt(:), stats_rad_zm(:))
18331834

1834-
allocate(out_zt(pcols,pverp,stats_zt(1)%num_output_fields))
1835-
allocate(out_zm(pcols,pverp,stats_zm(1)%num_output_fields))
1836-
allocate(out_sfc(pcols,1,stats_sfc(1)%num_output_fields))
1835+
allocate(out_zt(pcols,pverp,stats_zt(1)%num_output_fields), stat=ierr)
1836+
if( ierr /= 0 ) call endrun( 'clubb_ini_cam: Unable to allocate out_zt' )
1837+
allocate(out_zm(pcols,pverp,stats_zm(1)%num_output_fields), stat=ierr)
1838+
if( ierr /= 0 ) call endrun( 'clubb_ini_cam: Unable to allocate out_zm' )
1839+
allocate(out_sfc(pcols,1,stats_sfc(1)%num_output_fields), stat=ierr)
1840+
if( ierr /= 0 ) call endrun( 'clubb_ini_cam: Unable to allocate out_sfc' )
18371841

18381842
if ( stats_metadata%l_output_rad_files ) then
1839-
allocate(out_radzt(pcols,pverp,stats_rad_zt(1)%num_output_fields))
1840-
allocate(out_radzm(pcols,pverp,stats_rad_zm(1)%num_output_fields))
1843+
allocate(out_radzt(pcols,pverp,stats_rad_zt(1)%num_output_fields), stat=ierr)
1844+
if( ierr /= 0 ) call endrun( 'clubb_ini_cam: Unable to allocate out_radzt' )
1845+
allocate(out_radzm(pcols,pverp,stats_rad_zm(1)%num_output_fields), stat=ierr)
1846+
if( ierr /= 0 ) call endrun( 'clubb_ini_cam: Unable to allocate out_radzm' )
18411847
end if
18421848

18431849
endif
@@ -3796,12 +3802,14 @@ subroutine clubb_tend_cam( state, ptend_all, pbuf, hdtime, &
37963802
ptend_loc%q(i,k,ixcldliq) = (rcm(i,k) - state1%q(i,k,ixcldliq)) / hdtime ! Tendency of liquid water
37973803
ptend_loc%s(i,k) = (clubb_s(i,k) - state1%s(i,k)) / hdtime ! Tendency of static energy
37983804

3799-
rtm_integral_ltend(i) = rtm_integral_ltend(i) + ptend_loc%q(i,k,ixcldliq)*state1%pdel(i,k)/gravit
3800-
rtm_integral_vtend(i) = rtm_integral_vtend(i) + ptend_loc%q(i,k,ixq)*state1%pdel(i,k)/gravit
3805+
rtm_integral_ltend(i) = rtm_integral_ltend(i) + ptend_loc%q(i,k,ixcldliq)*state1%pdel(i,k)
3806+
rtm_integral_vtend(i) = rtm_integral_vtend(i) + ptend_loc%q(i,k,ixq)*state1%pdel(i,k)
38013807

38023808
end do
38033809
end do
3804-
3810+
3811+
rtm_integral_ltend(i) = rtm_integral_ltend(i)/gravit
3812+
rtm_integral_vtend(i) = rtm_integral_vtend(i)/gravit
38053813

38063814
if (clubb_do_adv) then
38073815
if (macmic_it == cld_macmic_num_steps) then
@@ -4761,10 +4769,10 @@ subroutine stats_init_clubb( l_stats_in, stats_tsamp_in, stats_tout_in, &
47614769
if ( abs( stats_metadata%stats_tsamp/delt - floor(stats_metadata%stats_tsamp/delt) ) > 1.e-8_r8 ) then
47624770
l_error = .true. ! This will cause the run to stop.
47634771
write(fstderr,*) 'Error: stats_tsamp should be an even multiple of ', &
4764-
'delt (which is dtmain). Check the appropriate ', &
4765-
'model.in file.'
4772+
'the clubb time step (delt below)'
47664773
write(fstderr,*) 'stats_tsamp = ', stats_metadata%stats_tsamp
47674774
write(fstderr,*) 'delt = ', delt
4775+
call endrun ("stats_init_clubb: CLUBB stats_tsamp must be an even multiple of the timestep")
47684776
endif
47694777

47704778
! Initialize zt (mass points)
@@ -4777,6 +4785,7 @@ subroutine stats_init_clubb( l_stats_in, stats_tsamp_in, stats_tout_in, &
47774785
enddo
47784786
ntot = i - 1
47794787
if ( ntot == nvarmax_zt ) then
4788+
l_error = .true.
47804789
write(fstderr,*) "There are more statistical variables listed in ", &
47814790
"clubb_vars_zt than allowed for by nvarmax_zt."
47824791
write(fstderr,*) "Check the number of variables listed for clubb_vars_zt ", &
@@ -4788,16 +4797,22 @@ subroutine stats_init_clubb( l_stats_in, stats_tsamp_in, stats_tout_in, &
47884797
stats_zt(j)%num_output_fields = ntot
47894798
stats_zt(j)%kk = nnzp
47904799

4791-
allocate( stats_zt(j)%z( stats_zt(j)%kk ) )
4800+
allocate( stats_zt(j)%z( stats_zt(j)%kk ), stat=ierr )
4801+
if( ierr /= 0 ) call endrun("stats_init_clubb: Failed to allocate stats_zt%z")
47924802

4793-
allocate( stats_zt(j)%accum_field_values( 1, 1, stats_zt(j)%kk, stats_zt(j)%num_output_fields ) )
4794-
allocate( stats_zt(j)%accum_num_samples( 1, 1, stats_zt(j)%kk, stats_zt(j)%num_output_fields ) )
4795-
allocate( stats_zt(j)%l_in_update( 1, 1, stats_zt(j)%kk, stats_zt(j)%num_output_fields ) )
4803+
allocate( stats_zt(j)%accum_field_values( 1, 1, stats_zt(j)%kk, stats_zt(j)%num_output_fields ), stat=ierr )
4804+
if( ierr /= 0 ) call endrun("stats_init_clubb: Failed to allocate stats_zt%accum_field_values")
4805+
allocate( stats_zt(j)%accum_num_samples( 1, 1, stats_zt(j)%kk, stats_zt(j)%num_output_fields ), stat=ierr )
4806+
if( ierr /= 0 ) call endrun("stats_init_clubb: Failed to allocate stats_zt%accum_num_samples")
4807+
allocate( stats_zt(j)%l_in_update( 1, 1, stats_zt(j)%kk, stats_zt(j)%num_output_fields ), stat=ierr )
4808+
if( ierr /= 0 ) call endrun("stats_init_clubb: Failed to allocate stats_zt%l_in_update")
47964809
call stats_zero( stats_zt(j)%kk, stats_zt(j)%num_output_fields, stats_zt(j)%accum_field_values, &
47974810
stats_zt(j)%accum_num_samples, stats_zt(j)%l_in_update )
47984811

4799-
allocate( stats_zt(j)%file%grid_avg_var( stats_zt(j)%num_output_fields ) )
4800-
allocate( stats_zt(j)%file%z( stats_zt(j)%kk ) )
4812+
allocate( stats_zt(j)%file%grid_avg_var( stats_zt(j)%num_output_fields ), stat=ierr )
4813+
if( ierr /= 0 ) call endrun("stats_init_clubb: Failed to allocate stats_zt%file%grid_avg_var")
4814+
allocate( stats_zt(j)%file%z( stats_zt(j)%kk ), stat=ierr )
4815+
if( ierr /= 0 ) call endrun("stats_init_clubb: Failed to allocate stats_zt%file%z")
48014816

48024817
! Default initialization for array indices for zt
48034818
call stats_init_zt_api( clubb_vars_zt, &
@@ -4814,6 +4829,7 @@ subroutine stats_init_clubb( l_stats_in, stats_tsamp_in, stats_tout_in, &
48144829
end do
48154830
ntot = i - 1
48164831
if ( ntot == nvarmax_zm ) then
4832+
l_error = .true. ! This will cause the run to stop.
48174833
write(fstderr,*) "There are more statistical variables listed in ", &
48184834
"clubb_vars_zm than allowed for by nvarmax_zm."
48194835
write(fstderr,*) "Check the number of variables listed for clubb_vars_zm ", &
@@ -4889,6 +4905,7 @@ subroutine stats_init_clubb( l_stats_in, stats_tsamp_in, stats_tout_in, &
48894905
end do
48904906
ntot = i - 1
48914907
if ( ntot == nvarmax_rad_zm ) then
4908+
l_error = .true. ! This will cause the run to stop.
48924909
write(fstderr,*) "There are more statistical variables listed in ", &
48934910
"clubb_vars_rad_zm than allowed for by nvarmax_rad_zm."
48944911
write(fstderr,*) "Check the number of variables listed for clubb_vars_rad_zm ", &
@@ -4928,6 +4945,7 @@ subroutine stats_init_clubb( l_stats_in, stats_tsamp_in, stats_tout_in, &
49284945
end do
49294946
ntot = i - 1
49304947
if ( ntot == nvarmax_sfc ) then
4948+
l_error = .true. ! This will cause the run to stop.
49314949
write(fstderr,*) "There are more statistical variables listed in ", &
49324950
"clubb_vars_sfc than allowed for by nvarmax_sfc."
49334951
write(fstderr,*) "Check the number of variables listed for clubb_vars_sfc ", &
@@ -4990,20 +5008,29 @@ subroutine stats_init_clubb( l_stats_in, stats_tsamp_in, stats_tout_in, &
49905008
if (stats_metadata%l_output_rad_files) then
49915009

49925010
do i = 1, stats_rad_zt(1)%num_output_fields
4993-
call addfld( trim(stats_rad_zt(1)%file%grid_avg_var(i)%name), (/ 'ilev' /), 'A', &
5011+
temp1 = trim(stats_rad_zt(1)%file%grid_avg_var(i)%name)
5012+
sub = temp1
5013+
if (len(temp1) > max_fieldname_len) sub = temp1(1:max_fieldname_len)
5014+
call addfld( trim(sub), (/ 'ilev' /), 'A', &
49945015
trim(stats_rad_zt(1)%file%grid_avg_var(i)%units), &
49955016
trim(stats_rad_zt(1)%file%grid_avg_var(i)%description) )
49965017
enddo
49975018

49985019
do i = 1, stats_rad_zm(1)%num_output_fields
4999-
call addfld( trim(stats_rad_zm(1)%file%grid_avg_var(i)%name), (/ 'ilev' /), 'A', &
5020+
temp1 = trim(stats_rad_zm(1)%file%grid_avg_var(i)%name)
5021+
sub = temp1
5022+
if (len(temp1) > max_fieldname_len) sub = temp1(1:max_fieldname_len)
5023+
call addfld( trim(sub), (/ 'ilev' /), 'A', &
50005024
trim(stats_rad_zm(1)%file%grid_avg_var(i)%units), &
50015025
trim(stats_rad_zm(1)%file%grid_avg_var(i)%description) )
50025026
enddo
50035027
endif
50045028

50055029
do i = 1, stats_sfc(1)%num_output_fields
5006-
call addfld( trim(stats_sfc(1)%file%grid_avg_var(i)%name), horiz_only, 'A', &
5030+
temp1 = trim(stats_sfc(1)%file%grid_avg_var(i)%name)
5031+
sub = temp1
5032+
if (len(temp1) > max_fieldname_len) sub = temp1(1:max_fieldname_len)
5033+
call addfld( trim(sub), horiz_only, 'A', &
50075034
trim(stats_sfc(1)%file%grid_avg_var(i)%units), &
50085035
trim(stats_sfc(1)%file%grid_avg_var(i)%description) )
50095036
enddo

0 commit comments

Comments
 (0)