Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates for MPAS v8.2.2 including renaming Thompson -> TEMPO #8

Merged
merged 7 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
all: dummy microphysics

dummy:
echo "****** compiling Thompson-Eidhammer microphysics ******"
echo "****** compiling TEMPO microphysics ******"

OBJS = \
module_mp_thompson_params.o \
module_mp_thompson_utils.o \
module_mp_thompson_main.o \
module_mp_thompson.o
module_mp_tempo_params.o \
module_mp_tempo_utils.o \
module_mp_tempo_main.o \
module_mp_tempo.o

microphysics: $(OBJS)
ar -ru ./../libphys.a $(OBJS)

# DEPENDENCIES:
module_mp_thompson.o: \
module_mp_thompson_params.o \
module_mp_thompson_utils.o \
module_mp_thompson_main.o
module_mp_tempo.o: \
module_mp_tempo_params.o \
module_mp_tempo_utils.o \
module_mp_tempo_main.o

clean:
$(RM) *.f90 *.o *.mod
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
! 3D TEMPO Driver for MPAS
!=================================================================================================================
module module_mp_thompson
module module_mp_tempo

use mpas_kind_types, only: wp => RKIND, sp => R4KIND, dp => R8KIND
use module_mp_thompson_params
use module_mp_thompson_utils, only : create_bins, table_Efrw, table_Efsw, table_dropEvap, &
use module_mp_tempo_params
use module_mp_tempo_utils, only : create_bins, table_Efrw, table_Efsw, table_dropEvap, &
calc_refl10cm, calc_effectRad
use module_mp_thompson_main, only : mp_thompson_main
use module_mp_tempo_main, only : mp_tempo_main
use mpas_atmphys_utilities, only : physics_message, physics_error_fatal
use mpas_io_units, only : mpas_new_unit, mpas_release_unit
use mp_radar
Expand All @@ -19,35 +19,42 @@ module module_mp_thompson
! allocating arrays for the microphysics scheme, and defining gamma function variables.

! Input:
! l_mp_tables = .false. to build lookup tables. If l_mp_tables = .true., lookup tables are not built.
! l_mp_tables = .false. to build lookup tables. If l_mp_tables = .true., lookup tables are built.

! AAJ No support yet for hail_aware in microphysics driver
subroutine thompson_init(l_mp_tables, hail_aware_flag, aerosol_aware_flag)
subroutine tempo_init(l_mp_tables, hail_aware_flag, aerosol_aware_flag)

! Input arguments:
logical, intent(in) :: l_mp_tables, hail_aware_flag
logical, intent(in), optional :: aerosol_aware_flag
logical, intent(in) :: l_mp_tables
logical, intent(in), optional :: aerosol_aware_flag, hail_aware_flag

integer, parameter :: open_OK = 0
integer, parameter :: num_records = 5
integer :: qr_acr_qg_filesize, qr_acr_qg_check, qr_acr_qg_dim1size, qr_acr_qg_dim9size
logical :: qr_acr_qg_exists
logical :: qr_acr_qg_exists, qr_acr_qg_hailaware_exists
integer :: i, j, k, l, m, n
integer :: istat
logical :: micro_init
integer :: mp_unit
character(len=132) :: message

if (present(hail_aware_flag)) then
configs%hail_aware = hail_aware_flag
else
call physics_message('--- tempo_init() called without hail_aware_flag... setting value to .false.')
configs%hail_aware = .false.
endif

! If lookup tables are already built
if (l_mp_tables) then
configs%hail_aware = hail_aware_flag
! configs%hail_aware = hail_aware_flag
write(message, '(L1)') configs%hail_aware
call physics_message('--- thompson_init() called with hail_aware_flag = ' // trim(message))
call physics_message('--- tempo_init() called with hail_aware_flag = ' // trim(message))

if (present(aerosol_aware_flag)) then
configs%aerosol_aware = aerosol_aware_flag
write(message, '(L1)') configs%aerosol_aware
call physics_message('--- thompson_init() called with aerosol_aware_flag = ' // trim(message))
call physics_message('--- tempo_init() called with aerosol_aware_flag = ' // trim(message))
endif
endif

Expand All @@ -65,41 +72,41 @@ subroutine thompson_init(l_mp_tables, hail_aware_flag, aerosol_aware_flag)
! Check the qr_acr_qg lookup table to make sure it is compatible with runtime options

! If lookup tables are already built
if (l_mp_tables) then

inquire(file='MP_THOMPSON_QRacrQG_DATA.DBL', exist=qr_acr_qg_exists)
if (qr_acr_qg_exists) then ! Check again that file exists

! Add check on qr_ac_qg filesize to determine if table includes hail-awareness (dimNRHG=9)
qr_acr_qg_check = dp * num_records * (dimNRHG * ntb_g1 * ntb_g * ntb_r1 * ntb_r + 1)
qr_acr_qg_dim1size = dp * num_records * (NRHG1 * ntb_g1 * ntb_g * ntb_r1 * ntb_r + 1)
qr_acr_qg_dim9size = dp * num_records * (NRHG * ntb_g1 * ntb_g * ntb_r1 * ntb_r + 1)

inquire(file='MP_THOMPSON_QRacrQG_DATA.DBL', size=qr_acr_qg_filesize)

if (qr_acr_qg_filesize == qr_acr_qg_dim1size) then
using_hail_aware_table = .false.
call physics_message('--- thompson_init() ' // &
'Lookup table for qr_acr_qg is not hail aware.')
dimNRHG = NRHG1
if (hail_aware_flag) then
call physics_error_fatal('--- thompson_init() Cannot use hail-aware microphysics ' // &
'with non hail-aware qr_acr_qg lookup table. ' // &
'Please rebuild table with parameter build_hail_aware_table set to true.')
endif
elseif (qr_acr_qg_filesize == qr_acr_qg_dim9size) then
using_hail_aware_table = .true.
call physics_message('--- thompson_init() ' // &
'Lookup table for qr_acr_qg is hail aware.')
dimNRHG = NRHG
else
using_hail_aware_table = .false.
if (hail_aware_flag) using_hail_aware_table = .true.
call physics_message('--- thompson_init() ' // &
'Could not determine if lookup table for qr_acr_qg is hail aware based on file size.')
endif
endif
endif
! if (l_mp_tables) then

! inquire(file='MP_TEMPO_QRacrQG_DATA.DBL', exist=qr_acr_qg_exists)
! if (qr_acr_qg_exists) then ! Check again that file exists

! ! Add check on qr_ac_qg filesize to determine if table includes hail-awareness (dimNRHG=9)
! qr_acr_qg_check = dp * num_records * (dimNRHG * ntb_g1 * ntb_g * ntb_r1 * ntb_r + 1)
! qr_acr_qg_dim1size = dp * num_records * (NRHG1 * ntb_g1 * ntb_g * ntb_r1 * ntb_r + 1)
! qr_acr_qg_dim9size = dp * num_records * (NRHG * ntb_g1 * ntb_g * ntb_r1 * ntb_r + 1)

! inquire(file='MP_TEMPO_QRacrQG_DATA.DBL', size=qr_acr_qg_filesize)

! if (qr_acr_qg_filesize == qr_acr_qg_dim1size) then
! using_hail_aware_table = .false.
! call physics_message('--- tempo_init() ' // &
! 'Lookup table for qr_acr_qg is not hail aware.')
! dimNRHG = NRHG1
! if (hail_aware_flag) then
! call physics_error_fatal('--- tempo_init() Cannot use hail-aware microphysics ' // &
! 'with non hail-aware qr_acr_qg lookup table. ' // &
! 'Please rebuild table with parameter build_hail_aware_table set to true.')
! endif
! elseif (qr_acr_qg_filesize == qr_acr_qg_dim9size) then
! using_hail_aware_table = .true.
! call physics_message('--- tempo_init() ' // &
! 'Lookup table for qr_acr_qg is hail aware.')
! dimNRHG = NRHG
! else
! using_hail_aware_table = .false.
! if (hail_aware_flag) using_hail_aware_table = .true.
! call physics_message('--- tempo_init() ' // &
! 'Could not determine if lookup table for qr_acr_qg is hail aware based on file size.')
! endif
! endif
! endif

!=================================================================================================================
! Allocate space for lookup tables (J. Michalakes 2009Jun08).
Expand Down Expand Up @@ -484,32 +491,61 @@ subroutine thompson_init(l_mp_tables, hail_aware_flag, aerosol_aware_flag)
! by Feingold & Heymsfield with further changes by Eidhammer and Kriedenweis.
call mpas_new_unit(mp_unit, unformatted = .true.)

open(unit=mp_unit,file='CCN_ACTIVATE.BIN',form='unformatted',status='old',action='read',iostat=istat)
if (istat /= open_OK) then
call physics_error_fatal('--- thompson_init() failure opening CCN_ACTIVATE.BIN')
endif
read(mp_unit) tnccn_act
close(unit=mp_unit)
! open(unit=mp_unit,file='CCN_ACTIVATE.BIN',form='unformatted',status='old',action='read',iostat=istat)
! if (istat /= open_OK) then
! call physics_error_fatal('--- tempo_init() failure opening CCN_ACTIVATE.BIN')
! endif
! read(mp_unit) tnccn_act
! close(unit=mp_unit)

! Rain collecting graupel & graupel collecting rain.

open(unit=mp_unit,file='MP_THOMPSON_QRacrQG_DATA.DBL',form='unformatted',status='old',action='read', &
iostat=istat)
if (istat /= open_OK) then
call physics_error_fatal('--- thompson_init() failure opening MP_THOMPSON_QRacrQG.DBL')
if (configs%hail_aware) then
using_hail_aware_table = .true.
open(unit=mp_unit,file='MP_TEMPO_HAILAWARE_QRacrQG_DATA.DBL',form='unformatted',status='old',action='read', &
iostat=istat)
if (istat /= open_OK) then
call physics_error_fatal('--- tempo_init() failure opening MP_TEMPO_HAILAWARE_QRacrQG.DBL')
endif
read(mp_unit) tcg_racg
read(mp_unit) tmr_racg
read(mp_unit) tcr_gacr
read(mp_unit) tnr_racg
read(mp_unit) tnr_gacr
close(unit=mp_unit)
else
inquire(file='MP_TEMPO_HAILAWARE_QRacrQG_DATA.DBL', exist=qr_acr_qg_hailaware_exists)
inquire(file='MP_TEMPO_QRacrQG_DATA.DBL', exist=qr_acr_qg_exists)

if (qr_acr_qg_hailaware_exists) then
using_hail_aware_table = .true.
open(unit=mp_unit,file='MP_TEMPO_HAILAWARE_QRacrQG_DATA.DBL',form='unformatted',status='old', &
action='read',iostat=istat)
if (istat /= open_OK) then
call physics_error_fatal('--- tempo_init() failure opening MP_TEMPO_HAILAWARE_QRacrQG.DBL')
endif
elseif (qr_acr_qg_exists) then
using_hail_aware_table = .false.
open(unit=mp_unit,file='MP_TEMPO_QRacrQG_DATA.DBL',form='unformatted',status='old', &
action='read',iostat=istat)
if (istat /= open_OK) then
call physics_error_fatal('--- tempo_init() failure opening MP_TEMPO_QRacrQG.DBL')
endif
else
call physics_error_fatal('--- tempo_init() could not find file to read QRacrQG data.')
endif
read(mp_unit) tcg_racg
read(mp_unit) tmr_racg
read(mp_unit) tcr_gacr
read(mp_unit) tnr_racg
read(mp_unit) tnr_gacr
close(unit=mp_unit)
endif
read(mp_unit) tcg_racg
read(mp_unit) tmr_racg
read(mp_unit) tcr_gacr
read(mp_unit) tnr_racg
read(mp_unit) tnr_gacr
close(unit=mp_unit)

! Rain collecting snow & snow collecting rain.
open(unit=mp_unit,file='MP_THOMPSON_QRacrQS_DATA.DBL',form='unformatted',status='old',action='read', &
open(unit=mp_unit,file='MP_TEMPO_QRacrQS_DATA.DBL',form='unformatted',status='old',action='read', &
iostat=istat)
if (istat /= open_OK) then
call physics_error_fatal('--- thompson_init() failure opening MP_THOMPSON_QRacrQS.DBL')
call physics_error_fatal('--- tempo_init() failure opening MP_TEMPO_QRacrQS.DBL')
endif
read(mp_unit) tcs_racs1
read(mp_unit) tmr_racs1
Expand All @@ -526,10 +562,10 @@ subroutine thompson_init(l_mp_tables, hail_aware_flag, aerosol_aware_flag)
close(unit=mp_unit)

! Cloud water and rain freezing (Bigg, 1953).
open(unit=mp_unit,file='MP_THOMPSON_freezeH2O_DATA.DBL',form='unformatted',status='old',action='read', &
open(unit=mp_unit,file='MP_TEMPO_freezeH2O_DATA.DBL',form='unformatted',status='old',action='read', &
iostat=istat)
if (istat /= open_OK) then
call physics_error_fatal('--- thompson_init() failure opening MP_THOMPSON_freezeH2O.DBL')
call physics_error_fatal('--- tempo_init() failure opening MP_TEMPO_freezeH2O.DBL')
endif
read(mp_unit) tpi_qrfz
read(mp_unit) tni_qrfz
Expand All @@ -540,10 +576,10 @@ subroutine thompson_init(l_mp_tables, hail_aware_flag, aerosol_aware_flag)
close(unit=mp_unit)

! Conversion of some ice mass into snow category.
open(unit=mp_unit,file='MP_THOMPSON_QIautQS_DATA.DBL',form='unformatted',status='old',action='read', &
open(unit=mp_unit,file='MP_TEMPO_QIautQS_DATA.DBL',form='unformatted',status='old',action='read', &
iostat=istat)
if (istat /= open_OK) then
call physics_error_fatal('--- thompson_init() failure opening MP_THOMPSON_QIautQS.DBL')
call physics_error_fatal('--- tempo_init() failure opening MP_TEMPO_QIautQS.DBL')
endif
read(mp_unit) tpi_ide
read(mp_unit) tps_iaus
Expand All @@ -565,14 +601,14 @@ subroutine thompson_init(l_mp_tables, hail_aware_flag, aerosol_aware_flag)

endif ! micro_init

end subroutine thompson_init
end subroutine tempo_init

!=================================================================================================================
! This is a wrapper routine designed to transfer values from 3D to 1D.
! Required microphysics variables are qv, qc, qr, nr, qi, ni, qs, qg
! Optional microphysics variables are aerosol aware (nc, nwfa, nifa, nwfa2d, nifa2d), and hail aware (ng, qg)

subroutine thompson_3d_to_1d_driver(qv, qc, qr, qi, qs, qg, qb, ni, nr, nc, ng, &
subroutine tempo_3d_to_1d_driver(qv, qc, qr, qi, qs, qg, qb, ni, nr, nc, ng, &
nwfa, nifa, nwfa2d, nifa2d, th, pii, p, w, dz, dt_in, itimestep, &
rainnc, rainncv, snownc, snowncv, graupelnc, graupelncv, sr, &
refl_10cm, diagflag, do_radar_ref, re_cloud, re_ice, re_snow, &
Expand Down Expand Up @@ -750,18 +786,18 @@ subroutine thompson_3d_to_1d_driver(qv, qc, qr, qi, qs, qg, qb, ni, nr, nc, ng,
enddo
endif

if (itimestep == 1) then
call physics_message('--- thompson_3d_to_1d_driver() configuration...')
write(message, '(L1)') configs%hail_aware
call physics_message(' hail_aware_flag = ' // trim(message))
write(message, '(L1)') configs%aerosol_aware
call physics_message(' aerosol_aware_flag = ' // trim(message))
call physics_message('calling mp_thompson_main() at itimestep = 1')
endif
!if (itimestep == 1) then
! call physics_message('--- tempo_3d_to_1d_driver() configuration...')
! write(message, '(L1)') configs%hail_aware
! call physics_message(' hail_aware_flag = ' // trim(message))
! write(message, '(L1)') configs%aerosol_aware
! call physics_message(' aerosol_aware_flag = ' // trim(message))
! call physics_message('calling mp_tempo_main() at itimestep = 1')
!endif

!=================================================================================================================
! Main call to the 1D microphysics
call mp_thompson_main(qv1d=qv1d, qc1d=qc1d, qi1d=qi1d, qr1d=qr1d, qs1d=qs1d, qg1d=qg1d, qb1d=qb1d, &
call mp_tempo_main(qv1d=qv1d, qc1d=qc1d, qi1d=qi1d, qr1d=qr1d, qs1d=qs1d, qg1d=qg1d, qb1d=qb1d, &
ni1d=ni1d, nr1d=nr1d, nc1d=nc1d, ng1d=ng1d, nwfa1d=nwfa1d, nifa1d=nifa1d, t1d=t1d, p1d=p1d, &
w1d=w1d, dzq=dz1d, pptrain=pptrain, pptsnow=pptsnow, pptgraul=pptgraul, pptice=pptice, &
rainprod=rainprod1d, evapprod=evapprod1d, kts=kts, kte=kte, dt=dt, ii=i, jj=j, configs=configs)
Expand Down Expand Up @@ -836,7 +872,7 @@ subroutine thompson_3d_to_1d_driver(qv, qc, qr, qi, qs, qg, qb, ni, nr, nc, ng,
enddo i_loop
enddo j_loop

end subroutine thompson_3d_to_1d_driver
end subroutine tempo_3d_to_1d_driver
!=================================================================================================================

end module module_mp_thompson
end module module_mp_tempo
14 changes: 7 additions & 7 deletions module_mp_thompson_main.F90 → module_mp_tempo_main.F90
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
! 1D Thompson microphysics scheme
! 1D TEMPO microphysics scheme
!=================================================================================================================
module module_mp_thompson_main
module module_mp_tempo_main

use module_mp_thompson_params
use module_mp_thompson_utils, only: rslf, rsif
use module_mp_tempo_params
use module_mp_tempo_utils, only: rslf, rsif

#if defined(mpas)
use mpas_kind_types, only: wp => RKIND, sp => R4KIND, dp => R8KIND
Expand All @@ -23,7 +23,7 @@ module module_mp_thompson_main
! A complete description is now found in Thompson et al. (2004, 2008), Thompson and Eidhammer (2014),
! and Jensen et al. (2023).

subroutine mp_thompson_main(qv1d, qc1d, qi1d, qr1d, qs1d, qg1d, qb1d, ni1d, nr1d, nc1d, ng1d, &
subroutine mp_tempo_main(qv1d, qc1d, qi1d, qr1d, qs1d, qg1d, qb1d, ni1d, nr1d, nc1d, ng1d, &
nwfa1d, nifa1d, t1d, p1d, w1d, dzq, pptrain, pptsnow, pptgraul, pptice, &
#if defined(mpas)
rainprod, evapprod, &
Expand Down Expand Up @@ -2890,7 +2890,7 @@ subroutine mp_thompson_main(qv1d, qc1d, qi1d, qr1d, qs1d, qg1d, qb1d, ni1d, nr1d
endif calculate_extended_diagnostics
#endif

end subroutine mp_thompson_main
end subroutine mp_tempo_main
!=================================================================================================================
!..Function to compute collision efficiency of collector species (rain,
!.. snow, graupel) of aerosols. Follows Wang et al, 2010, ACP, which
Expand Down Expand Up @@ -3412,4 +3412,4 @@ END SUBROUTINE semi_lagrange_sedim

!------------------

end module module_mp_thompson_main
end module module_mp_tempo_main
Loading
Loading