Skip to content

netcdf reader for dry/wet-deposition #159

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

Merged
merged 8 commits into from
Mar 27, 2025
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
26 changes: 10 additions & 16 deletions src/common/drydep.f90
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ module drydepml
private

public :: drydep, gravitational_settling, preprocess_landfraction, unload, &
requires_extra_fields_to_be_read, drydep_precompute
requires_extra_fields_to_be_read, drydep_precompute, &
requires_landfraction_file

integer, parameter, public :: DRYDEP_SCHEME_UNDEFINED = 0
integer, parameter, public :: DRYDEP_SCHEME_OLD = 1
Expand Down Expand Up @@ -67,6 +68,14 @@ subroutine drydep(tstep, part)
drydep_scheme == DRYDEP_SCHEME_EMERSON) call drydep_nonconstant_vd(tstep, vd_dep, part)
end subroutine

pure logical function requires_landfraction_file()
requires_landfraction_file = ( &
(drydep_scheme == DRYDEP_SCHEME_ZHANG).or. &
(drydep_scheme == DRYDEP_SCHEME_EMERSON).or. &
(drydep_scheme == DRYDEP_SCHEME_EMEP) &
)
end function

pure logical function requires_extra_fields_to_be_read()
requires_extra_fields_to_be_read = ( &
(drydep_scheme == DRYDEP_SCHEME_ZHANG).or. &
Expand Down Expand Up @@ -117,21 +126,6 @@ subroutine preprocess_landfraction(values)
use iso_fortran_env, only: real32, error_unit
real(real32), intent(in) :: values(:,:)

write(error_unit,*) "We do not currently check the landclasses programatically"
write(error_unit,*) "The classes must be:"
write(error_unit,*) " 11: Sea"
write(error_unit,*) " 12: Inland water"
write(error_unit,*) " 13: Tundra/desert"
write(error_unit,*) " 14: Ice and ice sheets"
write(error_unit,*) " 15: Urban"
write(error_unit,*) " 16: Crops"
write(error_unit,*) " 17: Grass"
write(error_unit,*) " 18: Wetlands"
write(error_unit,*) " 19: Evergreen needleleaf"
write(error_unit,*) " 20: Deciduous broadleaf"
write(error_unit,*) " 21: Mixed forest"
write(error_unit,*) " 22: Shrubs and interrupted woodlands"

if (allocated(classnr)) then
error stop "preprocess_landfraction is to be called once only"
endif
Expand Down
2 changes: 1 addition & 1 deletion src/common/fldout_nc.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1250,7 +1250,7 @@ subroutine initialize_output(filename, itime, ierror)
use iso_fortran_env, only: int8
use drydepml, only: largest_landfraction_file, classnr
integer(kind=int8), allocatable :: classnr_hr(:,:)
if (largest_landfraction_file /= "not set") then
if (largest_landfraction_file /= "not set" .and. output_vd_debug .and. allocated(classnr_hr)) then
call nc_declare(iunit, dimids2d, varid%landfraction, &
"largest_land_fraction", units="1", datatype=NF90_BYTE)
call hres_field(classnr, classnr_hr)
Expand Down
34 changes: 16 additions & 18 deletions src/common/readfield_fi.f90
Original file line number Diff line number Diff line change
Expand Up @@ -703,24 +703,6 @@ subroutine read_extra_precipitation_fields_infer_3d_precip(fio, timepos)
enddo
end block

! block ! Debug
! use snapfldML, only: garea
! real :: total_precip
! real :: total_precip2
! real, allocatable :: tmp(:,:)

! allocate(tmp(nx,ny))

! tmp(:,:) = precip * garea
! total_precip = sum(tmp)
! tmp(:,:) = sum(precip3d, dim=3)
! tmp(:,:) = tmp * garea
! total_precip2 = sum(tmp)

! write(*,*) "PRECIP LOSS: ", total_precip2 - total_precip
! write(*,*) "Precip from 2D fields: ", total_precip
! write(*,*) "Precip from 3d fields: ", total_precip2
! end block
end subroutine

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


write(error_unit,*) "We do not currently check the landclasses programatically"
write(error_unit,*) "The classes must be:"
write(error_unit,*) " 11: Sea"
write(error_unit,*) " 12: Inland water"
write(error_unit,*) " 13: Tundra/desert"
write(error_unit,*) " 14: Ice and ice sheets"
write(error_unit,*) " 15: Urban"
write(error_unit,*) " 16: Crops"
write(error_unit,*) " 17: Grass"
write(error_unit,*) " 18: Wetlands"
write(error_unit,*) " 19: Evergreen needleleaf"
write(error_unit,*) " 20: Deciduous broadleaf"
write(error_unit,*) " 21: Mixed forest"
write(error_unit,*) " 22: Shrubs and interrupted woodlands"

allocate(arr(nx, ny))
call fi_checkload(fio, "Main_Nature_Cover", "1", arr)

Expand Down
Loading