Skip to content

Commit

Permalink
Merge 'singhbalwinder/atm/ncar-fixes-euldyn-water-uptake' (PR #297)
Browse files Browse the repository at this point in the history
Bug fixes from NCAR:dyn(int to real),mem alloc fixes for modal aerosols

This commit fixes the following bugs reported by NCAR:

- All dynamic cores had an int in the denominator of an equation which
  should be real.

- There were memory allocation bugs in modal aerosol files which are
  fixed. NCAR had a lot of other changes in these files. I took only
  the changes which are relevant to ACME codes.

See issues #293 and #292 for more details

Passes acme_developer tests.

Fixes #292, Fixes #293
[BFB]
AG-331, AG-332
  • Loading branch information
susburrows committed Aug 12, 2015
2 parents 522c858 + 762ff23 commit 19e49c2
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 43 deletions.
6 changes: 3 additions & 3 deletions models/atm/cam/src/chemistry/utils/modal_aero_calcsize.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1237,9 +1237,9 @@ subroutine modal_aero_calcsize_diag(state, pbuf, list_idx_in, dgnum_m)
call endrun('modal_aero_calcsize_diag called for'// &
'diagnostic list but dgnum_m pointer not present')
end if
allocate(dgnum_m(pcols,pver,nmodes), stat=stat)
if (stat > 0) then
call endrun('modal_aero_calcsize_diag: allocation FAILURE: dgnum_m')
if (.not. associated(dgnum_m)) then
call endrun('modal_aero_calcsize_diag called for'// &
'diagnostic list but dgnum_m not associated')
end if
end if

Expand Down
43 changes: 18 additions & 25 deletions models/atm/cam/src/chemistry/utils/modal_aero_wateruptake.F90
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ subroutine modal_aero_wateruptake_dr(state, pbuf, list_idx_in, dgnumdry_m, dgnum
type(physics_buffer_desc), pointer :: pbuf(:) ! physics buffer

integer, optional, intent(in) :: list_idx_in
real(r8), optional, target, intent(in) :: dgnumdry_m(:,:,:)
real(r8), optional, pointer :: dgnumdry_m(:,:,:)
real(r8), optional, pointer :: dgnumwet_m(:,:,:)
real(r8), optional, pointer :: qaerwat_m(:,:,:)
real(r8), optional, pointer :: wetdens_m(:,:,:)
Expand Down Expand Up @@ -194,11 +194,18 @@ subroutine modal_aero_wateruptake_dr(state, pbuf, list_idx_in, dgnumdry_m, dgnum
list_idx = list_idx_in

! check that all optional args are present
if (.not. present(dgnumdry_m) .or. .not. present(dgnumwet_m) .or. &
.not. present(qaerwat_m) .or. .not. present(wetdens_m)) then
if (.not. present(dgnumdry_m) .or. .not. present(dgnumwet_m) .or. &
.not. present(qaerwat_m) .or. .not. present(wetdens_m)) then
call endrun('modal_aero_wateruptake_dr called for'// &
'diagnostic list but required args not present')
end if

! arrays for diagnostic calculations must be associated
if (.not. associated(dgnumdry_m) .or. .not. associated(dgnumwet_m) .or. &
.not. associated(qaerwat_m) .or. .not. associated(wetdens_m)) then
call endrun('modal_aero_wateruptake_dr called for'// &
'diagnostic list but required args not associated')
end if
end if

! loop over all aerosol modes
Expand All @@ -223,9 +230,15 @@ subroutine modal_aero_wateruptake_dr(state, pbuf, list_idx_in, dgnumdry_m, dgnum


if (list_idx == 0) then
call pbuf_get_field(pbuf, dgnum_idx, dgncur_a)
call pbuf_get_field(pbuf, dgnum_idx, dgncur_a )
call pbuf_get_field(pbuf, dgnumwet_idx, dgncur_awet )
call pbuf_get_field(pbuf, wetdens_ap_idx, wetdens)
call pbuf_get_field(pbuf, qaerwat_idx, qaerwat)
else
dgncur_a => dgnumdry_m
dgncur_a => dgnumdry_m
dgncur_awet => dgnumwet_m
qaerwat => qaerwat_m
wetdens => wetdens_m
end if

do m = 1, nmodes
Expand Down Expand Up @@ -329,19 +342,6 @@ subroutine modal_aero_wateruptake_dr(state, pbuf, list_idx_in, dgnumdry_m, dgnum
hygro, rh, dryvol, wetrad, wetvol, &
wtrvol)

if (list_idx == 0) then
call pbuf_get_field(pbuf, dgnumwet_idx, dgncur_awet)
call pbuf_get_field(pbuf, wetdens_ap_idx, wetdens)
call pbuf_get_field(pbuf, qaerwat_idx, qaerwat)
else
allocate(dgncur_awet(pcols,pver,nmodes), wetdens(pcols,pver,nmodes), &
qaerwat(pcols,pver,nmodes), stat=stat)
if (stat > 0) then
call endrun('modal_aero_wateruptake_dr: allocation FAILURE')
end if

end if

do m = 1, nmodes

do k = top_lev, pver
Expand Down Expand Up @@ -371,13 +371,6 @@ subroutine modal_aero_wateruptake_dr(state, pbuf, list_idx_in, dgnumdry_m, dgnum
call outfld( 'dgnw_a'//trnum(2:3), dgncur_awet(:,:,m), pcols, lchnk)
end do

else

! for diagnostic calcs just return results
dgnumwet_m => dgncur_awet
qaerwat_m => qaerwat
wetdens_m => wetdens

end if

deallocate( &
Expand Down
2 changes: 1 addition & 1 deletion models/atm/cam/src/dynamics/eul/restart_dynamics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ subroutine write_restart_dynamics (File, dyn_out)


do t=1,ptimelevels
time = ndcur+(real(nscur,kind=r8)+ (t-2)*dtime)/86400_r8
time = ndcur+(real(nscur,kind=r8)+ (t-2)*dtime)/86400._r8
ierr = pio_put_var(File,timedesc%varid, (/int(t)/), time)
end do
do i=1,restartvarcnt
Expand Down
2 changes: 1 addition & 1 deletion models/atm/cam/src/dynamics/fv/restart_dynamics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ subroutine write_restart_dynamics (File, dyn_out)

ierr = pio_put_var(File, tmass0desc, (/tmass0/))

time = ndcur+(real(nscur,kind=r8))/86400_r8
time = ndcur+(real(nscur,kind=r8))/86400._r8
ierr = pio_put_var(File,timedesc%varid, time)

do i=1,restartvarcnt
Expand Down
2 changes: 1 addition & 1 deletion models/atm/cam/src/dynamics/se/restart_dynamics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ subroutine write_restart_dynamics(File, dyn_out)

tl = timelevel%n0
call TimeLevel_Qdp(timelevel, qsplit, tlQdp)
time = ndcur+real(nscur,kind=r8)/86400_r8
time = ndcur+real(nscur,kind=r8)/86400._r8

ierr = pio_put_var(File,timedesc%varid, (/int(t)/), time)

Expand Down
2 changes: 1 addition & 1 deletion models/atm/cam/src/dynamics/sld/restart_dynamics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ subroutine write_restart_dynamics (File, dyn_out)
ierr = pio_put_var(File, lnpstardesc, lnpstar)

do t=1,ptimelevels
time = ndcur+(real(nscur,kind=r8)+ (t-2)*dtime)/86400_r8
time = ndcur+(real(nscur,kind=r8)+ (t-2)*dtime)/86400._r8
ierr = pio_put_var(File,timedesc%varid, (/int(t)/), time)
end do
do i=1,restartvarcnt
Expand Down
12 changes: 12 additions & 0 deletions models/atm/cam/src/physics/cam/modal_aer_opt.F90
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ subroutine modal_aero_sw(list_idx, state, pbuf, nnite, idxnite, &
integer :: ncol ! number of active columns in the chunk
integer :: nmodes
integer :: nspec
integer :: istat

real(r8) :: mass(pcols,pver) ! layer mass
real(r8) :: air_density(pcols,pver) ! (kg/m3)
Expand Down Expand Up @@ -483,6 +484,11 @@ subroutine modal_aero_sw(list_idx, state, pbuf, nnite, idxnite, &
else
! If doing a diagnostic calculation then need to calculate the wet radius
! and water uptake for the diagnostic modes
allocate(dgnumdry_m(pcols,pver,nmodes), dgnumwet_m(pcols,pver,nmodes), &
qaerwat_m(pcols,pver,nmodes), wetdens_m(pcols,pver,nmodes), stat=istat)
if (istat > 0) then
call endrun('modal_aero_sw: allocation FAILURE: arrays for diagnostic calcs')
end if
call modal_aero_calcsize_diag(state, pbuf, list_idx, dgnumdry_m)
call modal_aero_wateruptake_dr(state, pbuf, list_idx, dgnumdry_m, dgnumwet_m, &
qaerwat_m, wetdens_m)
Expand Down Expand Up @@ -938,6 +944,7 @@ subroutine modal_aero_lw(list_idx, state, pbuf, tauxar)
integer :: ncol ! number of active columns in the chunk
integer :: nmodes
integer :: nspec
integer :: istat

real(r8), pointer :: dgnumwet(:,:) ! wet number mode diameter (m)
real(r8), pointer :: qaerwat(:,:) ! aerosol water (g/g)
Expand Down Expand Up @@ -1001,6 +1008,11 @@ subroutine modal_aero_lw(list_idx, state, pbuf, tauxar)
else
! If doing a diagnostic calculation then need to calculate the wet radius
! and water uptake for the diagnostic modes
allocate(dgnumdry_m(pcols,pver,nmodes), dgnumwet_m(pcols,pver,nmodes), &
qaerwat_m(pcols,pver,nmodes), wetdens_m(pcols,pver,nmodes), stat=istat)
if (istat > 0) then
call endrun('modal_aero_lw: allocation FAILURE: arrays for diagnostic calcs')
end if
call modal_aero_calcsize_diag(state, pbuf, list_idx, dgnumdry_m)
call modal_aero_wateruptake_dr(state, pbuf, list_idx, dgnumdry_m, dgnumwet_m, &
qaerwat_m, wetdens_m)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ attributes from the config_cache.xml file (with keys converted to upper-case).
<paramfile >lnd/clm2/paramdata/clm_params.c150521.nc</paramfile>
<paramfile use_ed=".true." >lnd/clm2/paramdata/clm_params.ED.c140115.nc</paramfile>
<paramfile use_crop=".true." >lnd/clm2/paramdata/clm_params.c150330.nc</paramfile>

<!-- soil order related parameters (relative to {csmdata}) -->
<fsoilordercon >lnd/clm2/paramdata/CNP_parameters_c131108.nc</fsoilordercon>

Expand Down
11 changes: 0 additions & 11 deletions scripts/ccsm_utils/Testlistxml/testlist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4559,17 +4559,6 @@
<machine compiler="pgi" testtype="prebeta">goldbach</machine>
</test>
</grid>
<grid name="f19_g16">
<test name="ERH_D">
<machine compiler="intel" testtype="aux_clm_ys_pgi">edison</machine>
<machine compiler="intel" testtype="aux_clm_ys_pgi" testmods="clm/default">edison</machine>
<machine compiler="pgi" testtype="aux_clm45" testmods="clm/default">yellowstone</machine>
<machine compiler="pgi" testtype="aux_clm45">yellowstone</machine>
</test>
<test name="SMS_D">
<machine compiler="pgi" testtype="prebeta">goldbach</machine>
</test>
</grid>
</compset>
<compset name="I1850CLM45CNF">
<grid name="f19_g16">
Expand Down

0 comments on commit 19e49c2

Please sign in to comment.