Skip to content
Merged
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
62 changes: 22 additions & 40 deletions hamocc/mo_read_ndep.F90
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ module mo_read_ndep
public :: ndepfile

character(len=512) :: ndepfile=''
real, allocatable :: ndepread(:,:)
real, allocatable :: noydepread(:,:)
real, allocatable :: nhxdepread(:,:)
integer :: startyear,endyear
Expand Down Expand Up @@ -116,36 +115,24 @@ subroutine ini_read_ndep(kpie,kpje)
stop '(ini_read_ndep)'
endif

if (use_extNcycle) then
! Allocate field to hold N-deposition fluxes
if (mnproc == 1) then
write(io_stdo_bgc,*)'Memory allocation for variable nhxdepread ...'
write(io_stdo_bgc,*)'First dimension : ',kpie
write(io_stdo_bgc,*)'Second dimension : ',kpje
endif
allocate (nhxdepread(kpie,kpje),stat=errstat)
if(errstat /= 0) stop 'not enough memory nhxdepread'
nhxdepread(:,:) = 0.0
! Allocate field to hold N-deposition fluxes
if (mnproc == 1) then
write(io_stdo_bgc,*)'Memory allocation for variable nhxdepread ...'
write(io_stdo_bgc,*)'First dimension : ',kpie
write(io_stdo_bgc,*)'Second dimension : ',kpje
endif
allocate (nhxdepread(kpie,kpje),stat=errstat)
if(errstat /= 0) stop 'not enough memory nhxdepread'
nhxdepread(:,:) = 0.0

if (mnproc == 1) then
write(io_stdo_bgc,*)'Memory allocation for variable noydepread ...'
write(io_stdo_bgc,*)'First dimension : ',kpie
write(io_stdo_bgc,*)'Second dimension : ',kpje
endif
allocate (noydepread(kpie,kpje),stat=errstat)
if(errstat /= 0) stop 'not enough memory noydepread'
noydepread(:,:) = 0.0
else
! Allocate field to hold N-deposition fluxes
if (mnproc == 1) then
write(io_stdo_bgc,*)'Memory allocation for variable ndepread ...'
write(io_stdo_bgc,*)'First dimension : ',kpie
write(io_stdo_bgc,*)'Second dimension : ',kpje
endif
allocate (ndepread(kpie,kpje),stat=errstat)
if(errstat /= 0) stop 'not enough memory ndep'
ndepread(:,:) = 0.0
if (mnproc == 1) then
write(io_stdo_bgc,*)'Memory allocation for variable noydepread ...'
write(io_stdo_bgc,*)'First dimension : ',kpie
write(io_stdo_bgc,*)'Second dimension : ',kpje
endif
allocate (noydepread(kpie,kpje),stat=errstat)
if(errstat /= 0) stop 'not enough memory noydepread'
noydepread(:,:) = 0.0

! read start and end year of n-deposition file
call ncfopn(trim(ndepfile),'r',' ',1,iotype)
Expand Down Expand Up @@ -197,14 +184,14 @@ subroutine get_ndep(kpie,kpje,kbnd,kplyear,kplmon,omask,ndep,patmnhxdep,patmnoyd
real :: fatmndep
logical :: first_call = .true.

! if N-deposition is switched off set ndep to zero and return
ndep(:,:,:) = 0.0

if (.not. do_ndep) then
ndep(:,:,:) = 0.0
! if N-deposition is switched off return
return
endif

if (use_nuopc_ndep) then

! If use_nuopc_ndep, nitrogen deposition is ALWAYS obtained from the
! nuopc mediator
if (mnproc == 1 .and. first_call) then
Expand All @@ -213,7 +200,6 @@ subroutine get_ndep(kpie,kpje,kbnd,kplyear,kplmon,omask,ndep,patmnhxdep,patmnoyd

! convert from kgN/m2/s to climatological input file units: kmolN/m2/yr
fatmndep = 365.*86400./mw_nitrogen
ndep(:,:,:) = 0.

if (use_extNcycle) then
!$omp parallel do private(i)
Expand Down Expand Up @@ -251,12 +237,8 @@ subroutine get_ndep(kpie,kpje,kbnd,kplyear,kplmon,omask,ndep,patmnhxdep,patmnoyd
write(io_stdo_bgc,*) 'Read N deposition month ',month_in_file,' from file ',trim(ndepfile)
endif
ncstat=nf90_open(trim(ndepfile),nf90_nowrite,ncid)
if (use_extNcycle) then
call read_netcdf_var(ncid,'nhxdep',nhxdepread,1,month_in_file,0)
call read_netcdf_var(ncid,'noydep',noydepread,1,month_in_file,0)
else
call read_netcdf_var(ncid,'ndep',ndepread,1,month_in_file,0)
endif
call read_netcdf_var(ncid,'nhxdep',nhxdepread,1,month_in_file,0)
call read_netcdf_var(ncid,'noydep',noydepread,1,month_in_file,0)
ncstat=nf90_close(ncid)
oldmonth=kplmon
endif
Expand All @@ -269,7 +251,7 @@ subroutine get_ndep(kpie,kpje,kbnd,kplyear,kplmon,omask,ndep,patmnhxdep,patmnoyd
ndep(i,j,idepnoy) = noydepread(i,j)
ndep(i,j,idepnhx) = nhxdepread(i,j)
else
ndep(i,j,idepnoy) = ndepread(i,j)
ndep(i,j,idepnoy) = noydepread(i,j) + nhxdepread(i,j)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the ndep = 0.0 in line 203 should be moved up to the start of the routine (could then also be removed in line 189). Currently it is only set to zero for use_nuopc_ndep=.true.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

endif
enddo
enddo
Expand Down