Skip to content

Commit

Permalink
Merge pull request #141 from MaggieMarvin/develop
Browse files Browse the repository at this point in the history
Reduce memory requirements
  • Loading branch information
drnimbusrain authored Nov 22, 2024
2 parents ebba2d4 + 98898be commit 3c38201
Show file tree
Hide file tree
Showing 2 changed files with 902 additions and 660 deletions.
168 changes: 106 additions & 62 deletions src/canopy_alloc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,21 @@ SUBROUTINE canopy_alloc
if(.not.allocated(lad)) allocate(lad(nlat*nlon,modlays))
if(.not.allocated(lad_3d)) allocate(lad_3d(nlon,nlat,modlays))

if(.not.allocated(tleaf_sun24_tmp)) allocate(tleaf_sun24_tmp(ntime,nlat*nlon,modlays))
if(.not.allocated(tleaf_shade24_tmp)) allocate(tleaf_shade24_tmp(ntime,nlat*nlon,modlays))
if(.not.allocated(tleaf_ave24_tmp)) allocate(tleaf_ave24_tmp(ntime,nlat*nlon,modlays))
if(.not.allocated(ppfd_sun24_tmp)) allocate(ppfd_sun24_tmp(ntime,nlat*nlon,modlays))
if(.not.allocated(ppfd_shade24_tmp)) allocate(ppfd_shade24_tmp(ntime,nlat*nlon,modlays))
if(.not.allocated(tleaf_sun240_tmp)) allocate(tleaf_sun240_tmp(ntime,nlat*nlon,modlays))
if(.not.allocated(tleaf_shade240_tmp)) allocate(tleaf_shade240_tmp(ntime,nlat*nlon,modlays))
if(.not.allocated(tleaf_ave240_tmp)) allocate(tleaf_ave240_tmp(ntime,nlat*nlon,modlays))
if(.not.allocated(ppfd_sun240_tmp)) allocate(ppfd_sun240_tmp(ntime,nlat*nlon,modlays))
if(.not.allocated(ppfd_shade240_tmp)) allocate(ppfd_shade240_tmp(ntime,nlat*nlon,modlays))
if (hist_opt .eq. 1) then
if(.not.allocated(tleaf_sun24_tmp)) allocate(tleaf_sun24_tmp(25,nlat*nlon,modlays))
if(.not.allocated(tleaf_shade24_tmp)) allocate(tleaf_shade24_tmp(25,nlat*nlon,modlays))
if(.not.allocated(tleaf_ave24_tmp)) allocate(tleaf_ave24_tmp(25,nlat*nlon,modlays))
if(.not.allocated(ppfd_sun24_tmp)) allocate(ppfd_sun24_tmp(25,nlat*nlon,modlays))
if(.not.allocated(ppfd_shade24_tmp)) allocate(ppfd_shade24_tmp(25,nlat*nlon,modlays))
if(.not.allocated(tleaf_sun240_tmp)) allocate(tleaf_sun240_tmp(241,nlat*nlon,modlays))
if(.not.allocated(tleaf_shade240_tmp)) allocate(tleaf_shade240_tmp(241,nlat*nlon,modlays))
if(.not.allocated(tleaf_ave240_tmp)) allocate(tleaf_ave240_tmp(241,nlat*nlon,modlays))
if(.not.allocated(ppfd_sun240_tmp)) allocate(ppfd_sun240_tmp(241,nlat*nlon,modlays))
if(.not.allocated(ppfd_shade240_tmp)) allocate(ppfd_shade240_tmp(241,nlat*nlon,modlays))
if(.not.allocated(tmp2mref_tmp)) allocate(tmp2mref_tmp(25,nlat*nlon))
if(.not.allocated(ubzref_tmp)) allocate(ubzref_tmp(25,nlat*nlon))
end if

if(.not.allocated(tleaf_sun24)) allocate(tleaf_sun24(nlat*nlon,modlays))
if(.not.allocated(tleaf_shade24)) allocate(tleaf_shade24(nlat*nlon,modlays))
if(.not.allocated(tleaf_ave24)) allocate(tleaf_ave24(nlat*nlon,modlays))
Expand All @@ -67,22 +72,25 @@ SUBROUTINE canopy_alloc
if(.not.allocated(ppfd_sun240)) allocate(ppfd_sun240(nlat*nlon,modlays))
if(.not.allocated(ppfd_shade240)) allocate(ppfd_shade240(nlat*nlon,modlays))

if(.not.allocated(tmp2mref_tmp)) allocate(tmp2mref_tmp(ntime,nlat*nlon))
if(.not.allocated(ubzref_tmp)) allocate(ubzref_tmp(ntime,nlat*nlon))
if(.not.allocated(daily_maxt2m)) allocate(daily_maxt2m(nlat*nlon))
if(.not.allocated(daily_mint2m)) allocate(daily_mint2m(nlat*nlon))
if(.not.allocated(daily_maxws10m)) allocate(daily_maxws10m(nlat*nlon))

if(.not.allocated(tleaf_sun24_tmp_3d)) allocate(tleaf_sun24_tmp_3d(ntime,nlon,nlat,modlays))
if(.not.allocated(tleaf_shade24_tmp_3d)) allocate(tleaf_shade24_tmp_3d(ntime,nlon,nlat,modlays))
if(.not.allocated(tleaf_ave24_tmp_3d)) allocate(tleaf_ave24_tmp_3d(ntime,nlon,nlat,modlays))
if(.not.allocated(ppfd_sun24_tmp_3d)) allocate(ppfd_sun24_tmp_3d(ntime,nlon,nlat,modlays))
if(.not.allocated(ppfd_shade24_tmp_3d)) allocate(ppfd_shade24_tmp_3d(ntime,nlon,nlat,modlays))
if(.not.allocated(tleaf_sun240_tmp_3d)) allocate(tleaf_sun240_tmp_3d(ntime,nlon,nlat,modlays))
if(.not.allocated(tleaf_shade240_tmp_3d)) allocate(tleaf_shade240_tmp_3d(ntime,nlon,nlat,modlays))
if(.not.allocated(tleaf_ave240_tmp_3d)) allocate(tleaf_ave240_tmp_3d(ntime,nlon,nlat,modlays))
if(.not.allocated(ppfd_sun240_tmp_3d)) allocate(ppfd_sun240_tmp_3d(ntime,nlon,nlat,modlays))
if(.not.allocated(ppfd_shade240_tmp_3d)) allocate(ppfd_shade240_tmp_3d(ntime,nlon,nlat,modlays))
if (hist_opt .eq. 1) then
if(.not.allocated(tleaf_sun24_tmp_3d)) allocate(tleaf_sun24_tmp_3d(25,nlon,nlat,modlays))
if(.not.allocated(tleaf_shade24_tmp_3d)) allocate(tleaf_shade24_tmp_3d(25,nlon,nlat,modlays))
if(.not.allocated(tleaf_ave24_tmp_3d)) allocate(tleaf_ave24_tmp_3d(25,nlon,nlat,modlays))
if(.not.allocated(ppfd_sun24_tmp_3d)) allocate(ppfd_sun24_tmp_3d(25,nlon,nlat,modlays))
if(.not.allocated(ppfd_shade24_tmp_3d)) allocate(ppfd_shade24_tmp_3d(25,nlon,nlat,modlays))
if(.not.allocated(tleaf_sun240_tmp_3d)) allocate(tleaf_sun240_tmp_3d(241,nlon,nlat,modlays))
if(.not.allocated(tleaf_shade240_tmp_3d)) allocate(tleaf_shade240_tmp_3d(241,nlon,nlat,modlays))
if(.not.allocated(tleaf_ave240_tmp_3d)) allocate(tleaf_ave240_tmp_3d(241,nlon,nlat,modlays))
if(.not.allocated(ppfd_sun240_tmp_3d)) allocate(ppfd_sun240_tmp_3d(241,nlon,nlat,modlays))
if(.not.allocated(ppfd_shade240_tmp_3d)) allocate(ppfd_shade240_tmp_3d(241,nlon,nlat,modlays))
if(.not.allocated(tmp2mref_tmp_3d)) allocate(tmp2mref_tmp_3d(25,nlon,nlat))
if(.not.allocated(ubzref_tmp_3d)) allocate(ubzref_tmp_3d(25,nlon,nlat))
end if

if(.not.allocated(tleaf_sun24_3d)) allocate(tleaf_sun24_3d(nlon,nlat,modlays))
if(.not.allocated(tleaf_shade24_3d)) allocate(tleaf_shade24_3d(nlon,nlat,modlays))
if(.not.allocated(tleaf_ave24_3d)) allocate(tleaf_ave24_3d(nlon,nlat,modlays))
Expand All @@ -94,8 +102,6 @@ SUBROUTINE canopy_alloc
if(.not.allocated(ppfd_sun240_3d)) allocate(ppfd_sun240_3d(nlon,nlat,modlays))
if(.not.allocated(ppfd_shade240_3d)) allocate(ppfd_shade240_3d(nlon,nlat,modlays))

if(.not.allocated(tmp2mref_tmp_3d)) allocate(tmp2mref_tmp_3d(ntime,nlon,nlat))
if(.not.allocated(ubzref_tmp_3d)) allocate(ubzref_tmp_3d(ntime,nlon,nlat))
if(.not.allocated(daily_maxt2m_2d)) allocate(daily_maxt2m_2d(nlon,nlat))
if(.not.allocated(daily_mint2m_2d)) allocate(daily_mint2m_2d(nlon,nlat))
if(.not.allocated(daily_maxws10m_2d)) allocate(daily_maxws10m_2d(nlon,nlat))
Expand Down Expand Up @@ -149,44 +155,82 @@ SUBROUTINE canopy_alloc
if (ifcanbio) then
write(*,*) 'Canopy biogenic emissions option selected'
write(*,*) '-------------------------------'
if(.not.allocated(emi_isop)) allocate(emi_isop(nlat*nlon,modlays))
if(.not.allocated(emi_isop_3d)) allocate(emi_isop_3d(nlon,nlat,modlays))
if(.not.allocated(emi_myrc)) allocate(emi_myrc(nlat*nlon,modlays))
if(.not.allocated(emi_myrc_3d)) allocate(emi_myrc_3d(nlon,nlat,modlays))
if(.not.allocated(emi_sabi)) allocate(emi_sabi(nlat*nlon,modlays))
if(.not.allocated(emi_sabi_3d)) allocate(emi_sabi_3d(nlon,nlat,modlays))
if(.not.allocated(emi_limo)) allocate(emi_limo(nlat*nlon,modlays))
if(.not.allocated(emi_limo_3d)) allocate(emi_limo_3d(nlon,nlat,modlays))
if(.not.allocated(emi_care)) allocate(emi_care(nlat*nlon,modlays))
if(.not.allocated(emi_care_3d)) allocate(emi_care_3d(nlon,nlat,modlays))
if(.not.allocated(emi_ocim)) allocate(emi_ocim(nlat*nlon,modlays))
if(.not.allocated(emi_ocim_3d)) allocate(emi_ocim_3d(nlon,nlat,modlays))
if(.not.allocated(emi_bpin)) allocate(emi_bpin(nlat*nlon,modlays))
if(.not.allocated(emi_bpin_3d)) allocate(emi_bpin_3d(nlon,nlat,modlays))
if(.not.allocated(emi_apin)) allocate(emi_apin(nlat*nlon,modlays))
if(.not.allocated(emi_apin_3d)) allocate(emi_apin_3d(nlon,nlat,modlays))
if(.not.allocated(emi_mono)) allocate(emi_mono(nlat*nlon,modlays))
if(.not.allocated(emi_mono_3d)) allocate(emi_mono_3d(nlon,nlat,modlays))
if(.not.allocated(emi_farn)) allocate(emi_farn(nlat*nlon,modlays))
if(.not.allocated(emi_farn_3d)) allocate(emi_farn_3d(nlon,nlat,modlays))
if(.not.allocated(emi_cary)) allocate(emi_cary(nlat*nlon,modlays))
if(.not.allocated(emi_cary_3d)) allocate(emi_cary_3d(nlon,nlat,modlays))
if(.not.allocated(emi_sesq)) allocate(emi_sesq(nlat*nlon,modlays))
if(.not.allocated(emi_sesq_3d)) allocate(emi_sesq_3d(nlon,nlat,modlays))
if(.not.allocated(emi_mbol)) allocate(emi_mbol(nlat*nlon,modlays))
if(.not.allocated(emi_mbol_3d)) allocate(emi_mbol_3d(nlon,nlat,modlays))
if(.not.allocated(emi_meth)) allocate(emi_meth(nlat*nlon,modlays))
if(.not.allocated(emi_meth_3d)) allocate(emi_meth_3d(nlon,nlat,modlays))
if(.not.allocated(emi_acet)) allocate(emi_acet(nlat*nlon,modlays))
if(.not.allocated(emi_acet_3d)) allocate(emi_acet_3d(nlon,nlat,modlays))
if(.not.allocated(emi_co)) allocate(emi_co(nlat*nlon,modlays))
if(.not.allocated(emi_co_3d)) allocate(emi_co_3d(nlon,nlat,modlays))
if(.not.allocated(emi_bvoc)) allocate(emi_bvoc(nlat*nlon,modlays))
if(.not.allocated(emi_bvoc_3d)) allocate(emi_bvoc_3d(nlon,nlat,modlays))
if(.not.allocated(emi_svoc)) allocate(emi_svoc(nlat*nlon,modlays))
if(.not.allocated(emi_svoc_3d)) allocate(emi_svoc_3d(nlon,nlat,modlays))
if(.not.allocated(emi_ovoc)) allocate(emi_ovoc(nlat*nlon,modlays))
if(.not.allocated(emi_ovoc_3d)) allocate(emi_ovoc_3d(nlon,nlat,modlays))
if (biospec_opt == 0 .or. biospec_opt == 1) then
if(.not.allocated(emi_isop)) allocate(emi_isop(nlat*nlon,modlays))
if(.not.allocated(emi_isop_3d)) allocate(emi_isop_3d(nlon,nlat,modlays))
end if
if (biospec_opt == 0 .or. biospec_opt == 2) then
if(.not.allocated(emi_myrc)) allocate(emi_myrc(nlat*nlon,modlays))
if(.not.allocated(emi_myrc_3d)) allocate(emi_myrc_3d(nlon,nlat,modlays))
end if
if (biospec_opt == 0 .or. biospec_opt == 3) then
if(.not.allocated(emi_sabi)) allocate(emi_sabi(nlat*nlon,modlays))
if(.not.allocated(emi_sabi_3d)) allocate(emi_sabi_3d(nlon,nlat,modlays))
end if
if (biospec_opt == 0 .or. biospec_opt == 4) then
if(.not.allocated(emi_limo)) allocate(emi_limo(nlat*nlon,modlays))
if(.not.allocated(emi_limo_3d)) allocate(emi_limo_3d(nlon,nlat,modlays))
end if
if (biospec_opt == 0 .or. biospec_opt == 5) then
if(.not.allocated(emi_care)) allocate(emi_care(nlat*nlon,modlays))
if(.not.allocated(emi_care_3d)) allocate(emi_care_3d(nlon,nlat,modlays))
end if
if (biospec_opt == 0 .or. biospec_opt == 6) then
if(.not.allocated(emi_ocim)) allocate(emi_ocim(nlat*nlon,modlays))
if(.not.allocated(emi_ocim_3d)) allocate(emi_ocim_3d(nlon,nlat,modlays))
end if
if (biospec_opt == 0 .or. biospec_opt == 7) then
if(.not.allocated(emi_bpin)) allocate(emi_bpin(nlat*nlon,modlays))
if(.not.allocated(emi_bpin_3d)) allocate(emi_bpin_3d(nlon,nlat,modlays))
end if
if (biospec_opt == 0 .or. biospec_opt == 8) then
if(.not.allocated(emi_apin)) allocate(emi_apin(nlat*nlon,modlays))
if(.not.allocated(emi_apin_3d)) allocate(emi_apin_3d(nlon,nlat,modlays))
end if
if (biospec_opt == 0 .or. biospec_opt == 9) then
if(.not.allocated(emi_mono)) allocate(emi_mono(nlat*nlon,modlays))
if(.not.allocated(emi_mono_3d)) allocate(emi_mono_3d(nlon,nlat,modlays))
end if
if (biospec_opt == 0 .or. biospec_opt == 10) then
if(.not.allocated(emi_farn)) allocate(emi_farn(nlat*nlon,modlays))
if(.not.allocated(emi_farn_3d)) allocate(emi_farn_3d(nlon,nlat,modlays))
end if
if (biospec_opt == 0 .or. biospec_opt == 11) then
if(.not.allocated(emi_cary)) allocate(emi_cary(nlat*nlon,modlays))
if(.not.allocated(emi_cary_3d)) allocate(emi_cary_3d(nlon,nlat,modlays))
end if
if (biospec_opt == 0 .or. biospec_opt == 12) then
if(.not.allocated(emi_sesq)) allocate(emi_sesq(nlat*nlon,modlays))
if(.not.allocated(emi_sesq_3d)) allocate(emi_sesq_3d(nlon,nlat,modlays))
end if
if (biospec_opt == 0 .or. biospec_opt == 13) then
if(.not.allocated(emi_mbol)) allocate(emi_mbol(nlat*nlon,modlays))
if(.not.allocated(emi_mbol_3d)) allocate(emi_mbol_3d(nlon,nlat,modlays))
end if
if (biospec_opt == 0 .or. biospec_opt == 14) then
if(.not.allocated(emi_meth)) allocate(emi_meth(nlat*nlon,modlays))
if(.not.allocated(emi_meth_3d)) allocate(emi_meth_3d(nlon,nlat,modlays))
end if
if (biospec_opt == 0 .or. biospec_opt == 15) then
if(.not.allocated(emi_acet)) allocate(emi_acet(nlat*nlon,modlays))
if(.not.allocated(emi_acet_3d)) allocate(emi_acet_3d(nlon,nlat,modlays))
end if
if (biospec_opt == 0 .or. biospec_opt == 16) then
if(.not.allocated(emi_co)) allocate(emi_co(nlat*nlon,modlays))
if(.not.allocated(emi_co_3d)) allocate(emi_co_3d(nlon,nlat,modlays))
end if
if (biospec_opt == 0 .or. biospec_opt == 17) then
if(.not.allocated(emi_bvoc)) allocate(emi_bvoc(nlat*nlon,modlays))
if(.not.allocated(emi_bvoc_3d)) allocate(emi_bvoc_3d(nlon,nlat,modlays))
end if
if (biospec_opt == 0 .or. biospec_opt == 18) then
if(.not.allocated(emi_svoc)) allocate(emi_svoc(nlat*nlon,modlays))
if(.not.allocated(emi_svoc_3d)) allocate(emi_svoc_3d(nlon,nlat,modlays))
end if
if (biospec_opt == 0 .or. biospec_opt == 19) then
if(.not.allocated(emi_ovoc)) allocate(emi_ovoc(nlat*nlon,modlays))
if(.not.allocated(emi_ovoc_3d)) allocate(emi_ovoc_3d(nlon,nlat,modlays))
end if
end if

END SUBROUTINE canopy_alloc
Loading

0 comments on commit 3c38201

Please sign in to comment.