Skip to content

Commit 6f1549c

Browse files
authored
Merge pull request #159 from metno/feature/nc_read_dry_wet
netcdf reader for dry/wet-deposition
2 parents b80e7b6 + 623bb5c commit 6f1549c

File tree

6 files changed

+358
-50
lines changed

6 files changed

+358
-50
lines changed

src/common/drydep.f90

+10-16
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ module drydepml
2121
private
2222

2323
public :: drydep, gravitational_settling, preprocess_landfraction, unload, &
24-
requires_extra_fields_to_be_read, drydep_precompute
24+
requires_extra_fields_to_be_read, drydep_precompute, &
25+
requires_landfraction_file
2526

2627
integer, parameter, public :: DRYDEP_SCHEME_UNDEFINED = 0
2728
integer, parameter, public :: DRYDEP_SCHEME_OLD = 1
@@ -67,6 +68,14 @@ subroutine drydep(tstep, part)
6768
drydep_scheme == DRYDEP_SCHEME_EMERSON) call drydep_nonconstant_vd(tstep, vd_dep, part)
6869
end subroutine
6970

71+
pure logical function requires_landfraction_file()
72+
requires_landfraction_file = ( &
73+
(drydep_scheme == DRYDEP_SCHEME_ZHANG).or. &
74+
(drydep_scheme == DRYDEP_SCHEME_EMERSON).or. &
75+
(drydep_scheme == DRYDEP_SCHEME_EMEP) &
76+
)
77+
end function
78+
7079
pure logical function requires_extra_fields_to_be_read()
7180
requires_extra_fields_to_be_read = ( &
7281
(drydep_scheme == DRYDEP_SCHEME_ZHANG).or. &
@@ -117,21 +126,6 @@ subroutine preprocess_landfraction(values)
117126
use iso_fortran_env, only: real32, error_unit
118127
real(real32), intent(in) :: values(:,:)
119128

120-
write(error_unit,*) "We do not currently check the landclasses programatically"
121-
write(error_unit,*) "The classes must be:"
122-
write(error_unit,*) " 11: Sea"
123-
write(error_unit,*) " 12: Inland water"
124-
write(error_unit,*) " 13: Tundra/desert"
125-
write(error_unit,*) " 14: Ice and ice sheets"
126-
write(error_unit,*) " 15: Urban"
127-
write(error_unit,*) " 16: Crops"
128-
write(error_unit,*) " 17: Grass"
129-
write(error_unit,*) " 18: Wetlands"
130-
write(error_unit,*) " 19: Evergreen needleleaf"
131-
write(error_unit,*) " 20: Deciduous broadleaf"
132-
write(error_unit,*) " 21: Mixed forest"
133-
write(error_unit,*) " 22: Shrubs and interrupted woodlands"
134-
135129
if (allocated(classnr)) then
136130
error stop "preprocess_landfraction is to be called once only"
137131
endif

src/common/fldout_nc.f90

+1-1
Original file line numberDiff line numberDiff line change
@@ -1250,7 +1250,7 @@ subroutine initialize_output(filename, itime, ierror)
12501250
use iso_fortran_env, only: int8
12511251
use drydepml, only: largest_landfraction_file, classnr
12521252
integer(kind=int8), allocatable :: classnr_hr(:,:)
1253-
if (largest_landfraction_file /= "not set") then
1253+
if (largest_landfraction_file /= "not set" .and. output_vd_debug .and. allocated(classnr_hr)) then
12541254
call nc_declare(iunit, dimids2d, varid%landfraction, &
12551255
"largest_land_fraction", units="1", datatype=NF90_BYTE)
12561256
call hres_field(classnr, classnr_hr)

src/common/readfield_fi.f90

+16-18
Original file line numberDiff line numberDiff line change
@@ -703,24 +703,6 @@ subroutine read_extra_precipitation_fields_infer_3d_precip(fio, timepos)
703703
enddo
704704
end block
705705

706-
! block ! Debug
707-
! use snapfldML, only: garea
708-
! real :: total_precip
709-
! real :: total_precip2
710-
! real, allocatable :: tmp(:,:)
711-
712-
! allocate(tmp(nx,ny))
713-
714-
! tmp(:,:) = precip * garea
715-
! total_precip = sum(tmp)
716-
! tmp(:,:) = sum(precip3d, dim=3)
717-
! tmp(:,:) = tmp * garea
718-
! total_precip2 = sum(tmp)
719-
720-
! write(*,*) "PRECIP LOSS: ", total_precip2 - total_precip
721-
! write(*,*) "Precip from 2D fields: ", total_precip
722-
! write(*,*) "Precip from 3d fields: ", total_precip2
723-
! end block
724706
end subroutine
725707

726708
subroutine check(status, errmsg)
@@ -1034,6 +1016,22 @@ subroutine read_largest_landfraction(inputfile)
10341016
call check(fio%open(inputfile, "", "nc4"), "Can't open largest landfraction file")
10351017
endif
10361018

1019+
1020+
write(error_unit,*) "We do not currently check the landclasses programatically"
1021+
write(error_unit,*) "The classes must be:"
1022+
write(error_unit,*) " 11: Sea"
1023+
write(error_unit,*) " 12: Inland water"
1024+
write(error_unit,*) " 13: Tundra/desert"
1025+
write(error_unit,*) " 14: Ice and ice sheets"
1026+
write(error_unit,*) " 15: Urban"
1027+
write(error_unit,*) " 16: Crops"
1028+
write(error_unit,*) " 17: Grass"
1029+
write(error_unit,*) " 18: Wetlands"
1030+
write(error_unit,*) " 19: Evergreen needleleaf"
1031+
write(error_unit,*) " 20: Deciduous broadleaf"
1032+
write(error_unit,*) " 21: Mixed forest"
1033+
write(error_unit,*) " 22: Shrubs and interrupted woodlands"
1034+
10371035
allocate(arr(nx, ny))
10381036
call fi_checkload(fio, "Main_Nature_Cover", "1", arr)
10391037

0 commit comments

Comments
 (0)