Skip to content

Commit 403e097

Browse files
committed
converted missing value checks to call generic interface procedures for clarity
1 parent c0ae217 commit 403e097

File tree

2 files changed

+253
-233
lines changed

2 files changed

+253
-233
lines changed

scm/src/scm_input.F90

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
module scm_input
66

7-
use scm_kinds, only : sp, dp, qp
8-
use netcdf
7+
use data_qc, only: is_missing_value
8+
use scm_kinds, only: sp, dp, qp
99
use scm_type_defs, only: character_length
10+
use netcdf
1011

1112
implicit none
1213

@@ -1185,15 +1186,13 @@ subroutine get_case_init_DEPHY(scm_state, scm_input)
11851186
CHARACTER(LEN=nf90_max_name) :: tmpName
11861187
CHARACTER(LEN=nf90_max_name) :: tmpUnits
11871188
real(kind=sp), parameter :: p0 = 100000.0
1188-
real(kind=sp) :: exner, exner_inv, rho, elapsed_sec, missing_value_eps
1189+
real(kind=sp) :: exner, exner_inv, rho, elapsed_sec
11891190
real(kind=dp) :: rinc(5)
11901191
integer :: jdat(1:8), idat(1:8) !(yr, mon, day, t-zone, hr, min, sec, mil-sec)
11911192
logical :: needed_for_lsm_ics, needed_for_model_ics, lev_in_altitude
11921193

11931194
integer :: input_n_init_times, input_n_forcing_times, input_n_lev, input_n_snow, input_n_ice, input_n_soil, input_nvegcat, input_nsoilcat
11941195

1195-
missing_value_eps = missing_value + 0.01
1196-
11971196
!> - Open the case input file found in the processed_case_input dir corresponding to the experiment name.
11981197
call check(NF90_OPEN(trim(adjustl(scm_state%case_name))//'_SCM_driver.nc',nf90_nowrite,ncid),"nf90_open()")
11991198

@@ -2165,7 +2164,7 @@ subroutine get_case_init_DEPHY(scm_state, scm_input)
21652164
end if
21662165

21672166
!kinematic surface fluxes are specified (but may need to be converted)
2168-
if (maxval(input_force_wpthetap(:)) < missing_value_eps) then
2167+
if (is_missing_value(maxval(input_force_wpthetap(:)))) then
21692168
write(*,*) 'The global attribute surfaceForcing in '//trim(adjustl(scm_state%case_name))//'.nc indicates that the variable wpthetap should be present, but it is missing. Stopping ...'
21702169
error stop "The global attribute surfaceForcing indicates that the variable wpthetap should be present, but it is missing."
21712170
else
@@ -2177,29 +2176,30 @@ subroutine get_case_init_DEPHY(scm_state, scm_input)
21772176
end if
21782177

21792178
!if mixing ratios are present, and not specific humidities, convert from mixing ratio to specific humidities
2180-
if ((maxval(input_force_wpqvp(:)) < missing_value_eps .and. &
2181-
maxval(input_force_wpqtp(:)) < missing_value_eps) .and. &
2182-
(maxval(input_force_wprvp(:)) > missing_value_eps .or. &
2183-
maxval(input_force_wprtp(:)) > missing_value_eps)) then
2184-
if (maxval(input_force_wprvp(:)) > missing_value_eps) then
2179+
if ((is_missing_value(maxval(input_force_wpqvp(:))) .and. &
2180+
is_missing_value(maxval(input_force_wpqtp(:)))) &
2181+
.and. &
2182+
(.not. is_missing_value(maxval(input_force_wprvp(:))) .or. &
2183+
.not. is_missing_value(maxval(input_force_wprtp(:))))) then
2184+
if (.not. is_missing_value(maxval(input_force_wprvp(:)))) then
21852185
do i=1, input_n_forcing_times
21862186
input_force_wpqvp(i) = input_force_wprvp(i)/&
21872187
(1.0 + input_force_wprvp(i))
21882188
end do
21892189
end if
2190-
if (maxval(input_force_wprtp(:)) > missing_value_eps) then
2190+
if (.not. is_missing_value(maxval(input_force_wprtp(:)))) then
21912191
do i=1, input_n_forcing_times
21922192
input_force_wpqtp(i) = input_force_wprtp(i)/&
21932193
(1.0 + input_force_wprtp(i))
21942194
end do
21952195
end if
21962196
end if
21972197

2198-
if (maxval(input_force_wpqvp(:)) < missing_value_eps .and. maxval(input_force_wpqtp(:)) < missing_value_eps) then
2198+
if (is_missing_value(maxval(input_force_wpqvp(:))) .and. is_missing_value(maxval(input_force_wpqtp(:)))) then
21992199
write(*,*) 'The global attribute surfaceForcing in '//trim(adjustl(scm_state%case_name))//'.nc indicates that the variable wpqvp, wpqtp, wprvp, or wprtp should be present, but all are missing. Stopping ...'
22002200
error stop "The global attribute surfaceForcing indicates that the variable wpqvp, wpqtp, wprvp, or wprtp should be present, but all are missing."
22012201
else
2202-
if (maxval(input_force_wpqvp(:)) > missing_value_eps) then !use wpqvp if available
2202+
if (.not. is_missing_value(maxval(input_force_wpqvp(:)))) then !use wpqvp if available
22032203
scm_input%input_lh_flux_sfc_kin = input_force_wpqvp(:)
22042204
else
22052205
!surface total flux of water should just be vapor
@@ -2229,14 +2229,14 @@ subroutine get_case_init_DEPHY(scm_state, scm_input)
22292229
end if
22302230

22312231

2232-
if (maxval(input_force_sfc_sens_flx(:)) < missing_value_eps) then
2232+
if (is_missing_value(maxval(input_force_sfc_sens_flx(:)))) then
22332233
write(*,*) 'The global attribute surfaceForcing in '//trim(adjustl(scm_state%case_name))//'.nc indicates that the variable sfc_sens_flx should be present, but it is missing. Stopping ...'
22342234
error stop "The global attribute surfaceForcing in indicates that the variable sfc_sens_flx should be present, but it is missing."
22352235
else
22362236
scm_input%input_sh_flux_sfc = input_force_sfc_sens_flx(:)
22372237
end if
22382238

2239-
if (maxval(input_force_sfc_lat_flx(:)) < missing_value_eps) then
2239+
if (is_missing_value(maxval(input_force_sfc_lat_flx(:)))) then
22402240
write(*,*) 'The global attribute surfaceForcing in '//trim(adjustl(scm_state%case_name))//'.nc indicates that the variable sfc_lat_flx should be present, but it is missing. Stopping ...'
22412241
error stop "The global attribute surfaceForcing indicates that the variable sfc_lat_flx should be present, but it is missing."
22422242
else

0 commit comments

Comments
 (0)