Skip to content

Commit

Permalink
belowcloud -> subcloud
Browse files Browse the repository at this point in the history
  • Loading branch information
magnusuMET committed Oct 11, 2024
1 parent 13623ee commit 0f1539b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 44 deletions.
43 changes: 22 additions & 21 deletions src/common/snap.F90
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,14 @@ PROGRAM bsnap
use snapfldML, only: depwet, total_activity_lost_domain, vd_dep
USE forwrdML, only: forwrd, forwrd_init
USE wetdep, only: wetdep2, wetdep2_init, wetdep_scheme, wetdep_scheme_t, &
WETDEP_BELOWCLOUD_SCHEME_UNDEFINED, WETDEP_BELOWCLOUD_SCHEME_BARTNICKI, &
WETDEP_BELOWCLOUD_SCHEME_CONVENTIONAL, &
WETDEP_SUBCLOUD_SCHEME_UNDEFINED, WETDEP_SUBCLOUD_SCHEME_BARTNICKI, &
WETDEP_SUBCLOUD_SCHEME_CONVENTIONAL, &
operator(==), operator(/=), wet_deposition_conventional_params => conventional_params, &
wet_deposition_RATM => RATM_params, &
wetdep_conventional_compute, wetdep_conventional, &
WETDEP_INCLOUD_SCHEME_NONE, WETDEP_INCLOUD_SCHEME_TAKEMURA, WETDEP_INCLOUD_SCHEME_ROSELLE, &
WETDEP_INCLOUD_SCHEME_UNDEFINED, &
wetdep_init => init
wetdep_init => init, wetdep_deinit => deinit
use wetdep, only: wet_deposition_conventional_params => conventional_params
USE drydep, only: drydep1, drydep2, drydep_nonconstant_vd, drydep_scheme, &
DRYDEP_SCHEME_OLD, DRYDEP_SCHEME_NEW, DRYDEP_SCHEME_EMEP, &
Expand Down Expand Up @@ -674,7 +674,7 @@ PROGRAM bsnap
!..calculate boundary layer (top and height)
call bldp

if (wetdep_scheme%subcloud == WETDEP_BELOWCLOUD_SCHEME_CONVENTIONAL) then
if (wetdep_scheme%subcloud == WETDEP_SUBCLOUD_SCHEME_CONVENTIONAL) then
block
use snapfldml, only: precip
call wetdep_conventional_compute(precip)
Expand Down Expand Up @@ -764,10 +764,10 @@ PROGRAM bsnap
call wetdep_using_precomputed_wscav(pdata(np), wscav, depwet, tstep)
end block
else
if (wetdep_scheme%subcloud == WETDEP_BELOWCLOUD_SCHEME_BARTNICKI) then
if (wetdep_scheme%subcloud == WETDEP_SUBCLOUD_SCHEME_BARTNICKI) then
call wetdep2(depwet, tstep, pdata(np), pextra)
endif
if (wetdep_scheme%subcloud == WETDEP_BELOWCLOUD_SCHEME_CONVENTIONAL) then
if (wetdep_scheme%subcloud == WETDEP_SUBCLOUD_SCHEME_CONVENTIONAL) then
call wetdep_conventional(depwet, pdata(np), tstep)
endif
endif
Expand Down Expand Up @@ -906,6 +906,7 @@ PROGRAM bsnap
call fldout_unload()

! deallocate all fields
call wetdep_deinit()
call drydep_unload()
CALL deAllocateFields()

Expand Down Expand Up @@ -1202,19 +1203,19 @@ subroutine read_inputfile(snapinput_unit)
!..wet.deposition.new
write (error_unit, *) "Deprecated, please use wet.deposition.scheme = Bartnicki"
warning = .true.
if (wetdep_scheme%subcloud /= WETDEP_BELOWCLOUD_SCHEME_UNDEFINED .or. &
if (wetdep_scheme%subcloud /= WETDEP_SUBCLOUD_SCHEME_UNDEFINED .or. &
wetdep_scheme%incloud /= WETDEP_INCLOUD_SCHEME_UNDEFINED) then
write (error_unit, *) "wet deposition already set"
goto 12
endif
wetdep_scheme = wetdep_scheme_t( &
WETDEP_BELOWCLOUD_SCHEME_BARTNICKI, &
WETDEP_SUBCLOUD_SCHEME_BARTNICKI, &
WETDEP_INCLOUD_SCHEME_NONE, &
.false., .false.)
case ('wet.deposition.version')
write (error_unit, *) "Deprecated, please use wet.deposition.scheme = Bartnicki"
warning = .true.
if (wetdep_scheme%subcloud /= WETDEP_BELOWCLOUD_SCHEME_UNDEFINED .or. &
if (wetdep_scheme%subcloud /= WETDEP_SUBCLOUD_SCHEME_UNDEFINED .or. &
wetdep_scheme%incloud /= WETDEP_INCLOUD_SCHEME_UNDEFINED) then
write (error_unit, *) "wet deposition already set"
goto 12
Expand All @@ -1228,7 +1229,7 @@ subroutine read_inputfile(snapinput_unit)
read (cinput(pname_start:pname_end), *, err=12) scheme_number
if (scheme_number /= 2) goto 12
wetdep_scheme = wetdep_scheme_t( &
WETDEP_BELOWCLOUD_SCHEME_BARTNICKI, &
WETDEP_SUBCLOUD_SCHEME_BARTNICKI, &
WETDEP_INCLOUD_SCHEME_NONE, &
.false., &
.false.)
Expand All @@ -1249,7 +1250,7 @@ subroutine read_inputfile(snapinput_unit)
read(cinput(pname_start:pname_end), *) wet_deposition_conventional_params%B
case ('wet.deposition.scheme')
if (.not.has_value) goto 12
if (wetdep_scheme%subcloud /= WETDEP_BELOWCLOUD_SCHEME_UNDEFINED .or. &
if (wetdep_scheme%subcloud /= WETDEP_SUBCLOUD_SCHEME_UNDEFINED .or. &
wetdep_scheme%incloud /= WETDEP_INCLOUD_SCHEME_UNDEFINED) then
write (error_unit, *) "wet deposition already set"
goto 12
Expand All @@ -1258,37 +1259,37 @@ subroutine read_inputfile(snapinput_unit)
select case(cinput(pname_start:pname_end))
case("bartnicki")
wetdep_scheme = wetdep_scheme_t( &
WETDEP_BELOWCLOUD_SCHEME_BARTNICKI, &
WETDEP_SUBCLOUD_SCHEME_BARTNICKI, &
WETDEP_INCLOUD_SCHEME_NONE, &
.false., .false. &
)
case("conventional")
wetdep_scheme = wetdep_scheme_t( &
WETDEP_BELOWCLOUD_SCHEME_CONVENTIONAL, &
WETDEP_SUBCLOUD_SCHEME_CONVENTIONAL, &
WETDEP_INCLOUD_SCHEME_NONE, &
.false., .false. &
)
case("bartnicki-vertical")
met_params%use_3d_precip = .true.
met_params%use_ccf = .true.
wetdep_scheme = wetdep_scheme_t( &
WETDEP_BELOWCLOUD_SCHEME_BARTNICKI, &
WETDEP_SUBCLOUD_SCHEME_BARTNICKI, &
WETDEP_INCLOUD_SCHEME_NONE, &
.true., .true. &
)
case("bartnicki-roselle")
met_params%use_3d_precip = .true.
met_params%use_ccf = .true.
wetdep_scheme = wetdep_scheme_t( &
WETDEP_BELOWCLOUD_SCHEME_BARTNICKI, &
WETDEP_SUBCLOUD_SCHEME_BARTNICKI, &
WETDEP_INCLOUD_SCHEME_ROSELLE, &
.true., .true. &
)
case("bartnicki-takemura")
met_params%use_3d_precip = .true.
met_params%use_ccf = .true.
wetdep_scheme = wetdep_scheme_t( &
WETDEP_BELOWCLOUD_SCHEME_BARTNICKI, &
WETDEP_SUBCLOUD_SCHEME_BARTNICKI, &
WETDEP_INCLOUD_SCHEME_TAKEMURA, &
.true., .true. &
)
Expand All @@ -1302,7 +1303,7 @@ subroutine read_inputfile(snapinput_unit)
met_params%use_3d_precip = .true.
met_params%use_ccf = .true.
wetdep_scheme = wetdep_scheme_t( &
WETDEP_BELOWCLOUD_SCHEME_CONVENTIONAL, &
WETDEP_SUBCLOUD_SCHEME_CONVENTIONAL, &
WETDEP_INCLOUD_SCHEME_ROSELLE, &
.true., .true. &
)
Expand All @@ -1316,7 +1317,7 @@ subroutine read_inputfile(snapinput_unit)
met_params%use_3d_precip = .true.
met_params%use_ccf = .true.
wetdep_scheme = wetdep_scheme_t( &
WETDEP_BELOWCLOUD_SCHEME_CONVENTIONAL, &
WETDEP_SUBCLOUD_SCHEME_CONVENTIONAL, &
WETDEP_INCLOUD_SCHEME_TAKEMURA, &
.true., .true. &
)
Expand Down Expand Up @@ -2182,10 +2183,10 @@ subroutine conform_input(ierror)
if (drydep_scheme == DRYDEP_SCHEME_UNDEFINED) drydep_scheme = DRYDEP_SCHEME_OLD

! Set default wetdep schemes
if (wetdep_scheme%subcloud == WETDEP_BELOWCLOUD_SCHEME_UNDEFINED .and. &
if (wetdep_scheme%subcloud == WETDEP_SUBCLOUD_SCHEME_UNDEFINED .and. &
wetdep_scheme%incloud == WETDEP_INCLOUD_SCHEME_UNDEFINED) then
wetdep_scheme = wetdep_scheme_t( &
WETDEP_BELOWCLOUD_SCHEME_BARTNICKI, &
WETDEP_SUBCLOUD_SCHEME_BARTNICKI, &
WETDEP_INCLOUD_SCHEME_NONE, &
.false., .false. &
)
Expand Down Expand Up @@ -2228,7 +2229,7 @@ subroutine conform_input(ierror)
end if
end if

if (wetdep_scheme%subcloud == WETDEP_BELOWCLOUD_SCHEME_BARTNICKI .AND. def_comp(m)%kwetdep == 1) then
if (wetdep_scheme%subcloud == WETDEP_SUBCLOUD_SCHEME_BARTNICKI .AND. def_comp(m)%kwetdep == 1) then
if (def_comp(m)%radiusmym <= 0.) then
write (error_unit, *) 'Wet deposition error. radius: ', &
def_comp(m)%radiusmym
Expand Down
46 changes: 23 additions & 23 deletions src/common/wetdep.f90
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@ module wetdep
real, parameter :: precmin = 0.01

public :: wetdep2, wetdep2_init, &
wetdep_conventional, wetdep_conventional_compute, init
wetdep_conventional, wetdep_conventional_compute, init, deinit
public :: operator(==), operator(/=)
public :: wetdep_bartnicki
public :: prepare_wetdep, wetdep_using_precomputed_wscav

type, public :: wetdep_belowcloud_scheme_t
type, public :: wetdep_subcloud_scheme_t
integer, private :: scheme
character(len=32), public :: description
end type

type(wetdep_belowcloud_scheme_t), parameter, public :: WETDEP_BELOWCLOUD_SCHEME_UNDEFINED = &
wetdep_belowcloud_scheme_t(0, "Not defined")
type(wetdep_belowcloud_scheme_t), parameter, public :: WETDEP_BELOWCLOUD_SCHEME_NONE = &
wetdep_belowcloud_scheme_t(1, "No scheme (skip)")
type(wetdep_belowcloud_scheme_t), parameter, public :: WETDEP_BELOWCLOUD_SCHEME_BARTNICKI = &
wetdep_belowcloud_scheme_t(2, "Bartnicki")
type(wetdep_belowcloud_scheme_t), parameter, public :: WETDEP_BELOWCLOUD_SCHEME_CONVENTIONAL = &
wetdep_belowcloud_scheme_t(3, "Conventional")
type(wetdep_subcloud_scheme_t), parameter, public :: WETDEP_SUBCLOUD_SCHEME_UNDEFINED = &
wetdep_subcloud_scheme_t(0, "Not defined")
type(wetdep_subcloud_scheme_t), parameter, public :: WETDEP_SUBCLOUD_SCHEME_NONE = &
wetdep_subcloud_scheme_t(1, "No scheme (skip)")
type(wetdep_subcloud_scheme_t), parameter, public :: WETDEP_SUBCLOUD_SCHEME_BARTNICKI = &
wetdep_subcloud_scheme_t(2, "Bartnicki")
type(wetdep_subcloud_scheme_t), parameter, public :: WETDEP_SUBCLOUD_SCHEME_CONVENTIONAL = &
wetdep_subcloud_scheme_t(3, "Conventional")

type, public :: wetdep_incloud_scheme_t
integer, private :: scheme
Expand All @@ -58,18 +58,18 @@ module wetdep
wetdep_incloud_scheme_t(3, "Roselle")

type, public :: wetdep_scheme_t
type(wetdep_belowcloud_scheme_t) :: subcloud
type(wetdep_subcloud_scheme_t) :: subcloud
type(wetdep_incloud_scheme_t) :: incloud
logical :: use_vertical
logical :: use_cloudfraction
end type

interface operator (==)
module procedure :: equal_belowcloud_scheme, equal_incloud_scheme
module procedure :: equal_subcloud_scheme, equal_incloud_scheme
end interface

interface operator (/=)
module procedure :: not_equal_belowcloud_scheme, not_equal_incloud_scheme
module procedure :: not_equal_subcloud_scheme, not_equal_incloud_scheme
end interface


Expand All @@ -83,17 +83,17 @@ module wetdep
real(real64), allocatable, save, public :: conventional_deprate_m1(:,:)

type(wetdep_scheme_t), save, public :: wetdep_scheme = &
wetdep_scheme_t(WETDEP_BELOWCLOUD_SCHEME_UNDEFINED, WETDEP_INCLOUD_SCHEME_UNDEFINED, .false., .false.)
wetdep_scheme_t(WETDEP_SUBCLOUD_SCHEME_UNDEFINED, WETDEP_INCLOUD_SCHEME_UNDEFINED, .false., .false.)

contains

logical pure function equal_belowcloud_scheme(this, other) result(eq)
type(wetdep_belowcloud_scheme_t), intent(in) :: this, other
logical pure function equal_subcloud_scheme(this, other) result(eq)
type(wetdep_subcloud_scheme_t), intent(in) :: this, other
eq = this%scheme == other%scheme
end function

logical pure function not_equal_belowcloud_scheme(this, other) result(eq)
type(wetdep_belowcloud_scheme_t), intent(in) :: this, other
logical pure function not_equal_subcloud_scheme(this, other) result(eq)
type(wetdep_subcloud_scheme_t), intent(in) :: this, other
eq = .not. (this == other)
end function

Expand All @@ -110,12 +110,12 @@ logical pure function not_equal_incloud_scheme(this, other) result(eq)
subroutine init(tstep)
use snapdimML, only: nx, ny
real, intent(in) :: tstep
if (wetdep_scheme%subcloud == WETDEP_BELOWCLOUD_SCHEME_CONVENTIONAL .and. &
if (wetdep_scheme%subcloud == WETDEP_SUBCLOUD_SCHEME_CONVENTIONAL .and. &
wetdep_scheme%use_vertical) then
allocate(conventional_deprate_m1(nx,ny))
endif

if (wetdep_scheme%subcloud == WETDEP_BELOWCLOUD_SCHEME_BARTNICKI.and. &
if (wetdep_scheme%subcloud == WETDEP_SUBCLOUD_SCHEME_BARTNICKI.and. &
wetdep_scheme%use_vertical) then
call wetdep2_init(tstep)
endif
Expand Down Expand Up @@ -516,9 +516,9 @@ subroutine prepare_wetdep(wscav, radius, precip, cw, ccf)
endwhere

select case (wetdep_scheme%subcloud%scheme)
case (WETDEP_BELOWCLOUD_SCHEME_BARTNICKI%scheme)
case (WETDEP_SUBCLOUD_SCHEME_BARTNICKI%scheme)
call wet_deposition_rate_bartnicki(wscav(:,:,k), radius, accum_precip(:,:), accum_ccf(:,:), use_ccf=.true.)
case (WETDEP_BELOWCLOUD_SCHEME_CONVENTIONAL%scheme)
case (WETDEP_SUBCLOUD_SCHEME_CONVENTIONAL%scheme)
block
integer :: i, j
real :: adj_precip
Expand All @@ -533,7 +533,7 @@ subroutine prepare_wetdep(wscav, radius, precip, cw, ccf)
enddo
enddo
end block
case (WETDEP_BELOWCLOUD_SCHEME_NONE%scheme)
case (WETDEP_SUBCLOUD_SCHEME_NONE%scheme)
wscav(:,:,k) = 0.0
case default
error stop wetdep_scheme%subcloud%description
Expand Down

0 comments on commit 0f1539b

Please sign in to comment.