Skip to content
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

simplify bi and tri-grid in land for MOAB coupler. #6754

Merged
merged 6 commits into from
Nov 25, 2024
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
307 changes: 92 additions & 215 deletions components/elm/src/cpl/lnd_comp_mct.F90

Large diffs are not rendered by default.

63 changes: 0 additions & 63 deletions components/elm/src/main/surfrdMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ module surfrdMod
use ncdio_pio , only : ncd_io, check_var, ncd_inqfdims, check_dim, ncd_inqdid, ncd_inqdlen
use pio

#ifdef HAVE_MOAB
use mct_mod , only : mct_gsMap
use decompMod , only : get_elmlevel_gsmap
! use spmdMod , only : iam ! rank on the land communicator
#endif
use spmdMod
use topounit_varcon , only : max_topounits, has_topounit

Expand Down Expand Up @@ -184,11 +179,6 @@ subroutine surfrd_get_grid(begg, endg, ldomain, filename, glcfilename)

! pflotran:beg-----------------------------
integer :: j, np, nv
#ifdef HAVE_MOAB
type(mct_gsMap), pointer :: gsMap
integer :: i, iv , iseg, ig, local ! ni, nj, nv, nseg, global ig

#endif

! pflotran:end-----------------------------
character(len=32) :: subname = 'surfrd_get_grid' ! subroutine name
Expand Down Expand Up @@ -258,59 +248,6 @@ subroutine surfrd_get_grid(begg, endg, ldomain, filename, glcfilename)

end if
! pflotran:end-----------------------------------------------

#ifdef HAVE_MOAB
! read xv and yv for MOAB to learn mesh verticies
if (ldomain%nv>=3 ) then
call get_elmlevel_gsmap (grlnd, gsMap)
allocate(rdata3d(nv,ni,nj)) ! transpose from c, as this is fortran
vname = 'xv'
! this should be improved in a distributed read, that does not use full grid ni * nj * nv 720*360*4*8 ~ 8Mb
call ncd_io(ncid=ncid, varname=trim(vname), data=rdata3d, flag='read', readvar=readvar)
if (.not. readvar) call endrun( msg=trim(subname)//' ERROR: xv NOT on file'//errMsg(__FILE__, __LINE__))
! fill up the ldomain%mblonv(begg:endg, 1:nv) array
local = begg
do iseg = 1, gsMap%ngseg
if (gsMap%pe_loc(iseg) .eq. iam) then
do ig = gsMap%start(iseg), gsMap%start(iseg) + gsMap%length(iseg) - 1
j = (ig-1)/ni + 1
i = ig - ni*(j-1)
do iv = 1, nv
if (local .le. endg) then
ldomain%mblonv(local, iv ) = rdata3d(iv, i, j)
else
write (iulog, *), 'OVERFLOW', iseg, gsMap%pe_loc(iseg), gsMap%start(iseg), gsMap%length(iseg), local
endif
enddo
local = local + 1
enddo
endif
enddo
! repeat for mblatv
vname = 'yv'
call ncd_io(ncid=ncid, varname=trim(vname), data=rdata3d, flag='read', readvar=readvar)
if (.not. readvar) call endrun( msg=trim(subname)//' ERROR: yv NOT on file'//errMsg(__FILE__, __LINE__))
! fill up the ldomain%lonv(begg:endg, 1:nv) array
local = begg
do iseg = 1, gsMap%ngseg
if (gsMap%pe_loc(iseg) .eq. iam) then
do ig = gsMap%start(iseg), gsMap%start(iseg) + gsMap%length(iseg) - 1
j = (ig-1)/ni + 1
i = ig - ni*(j-1)
do iv = 1, nv
if (local .le. endg) then
ldomain%mblatv(local, iv ) = rdata3d(iv, i, j)
endif
enddo
local = local + 1
enddo
endif
enddo
! deallocate what is not needed anymore (for half degree land model, ~8Mb)
deallocate(rdata3d)

end if
#endif
else
call ncd_io(ncid=ncid, varname= 'AREA', flag='read', data=ldomain%area, &
dim1name=grlnd, readvar=readvar)
Expand Down
37 changes: 0 additions & 37 deletions components/elm/src/utils/domainMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ module domainMod
integer :: nv ! number of vertices
real(r8),pointer :: latv(:,:) ! latitude of grid cell's vertices (deg)
real(r8),pointer :: lonv(:,:) ! longitude of grid cell's vertices (deg)
#ifdef HAVE_MOAB
real(r8),pointer :: mblatv(:,:) ! latitude of grid cell's vertices (deg) for MOAB
real(r8),pointer :: mblonv(:,:) ! longitude of grid cell's vertices (deg) for MOAB
#endif
real(r8) :: lon0 ! the origin lon/lat (Most western/southern corner, if not globally covered grids; OR -180W(360E)/-90N)
real(r8) :: lat0 ! the origin lon/lat (Most western/southern corner, if not globally covered grids; OR -180W(360E)/-90N)

Expand Down Expand Up @@ -154,22 +150,6 @@ subroutine domain_init(domain,isgrid2d,ni,nj,nbeg,nend,elmlevel)
endif
end if
! pflotran:end-----------------------------------------------------
#ifdef HAVE_MOAB
if (domain%nv > 0 .and. domain%nv /= huge(1)) then
if(.not.associated(domain%mblonv)) then
allocate(domain%mblonv(nb:ne, 1:domain%nv), stat=ier)
if (ier /= 0) &
call shr_sys_abort('domain_init ERROR: allocate mblonv ')
domain%mblonv = nan
endif
if(.not.associated(domain%mblatv)) then
allocate(domain%mblatv(nb:ne, 1:domain%nv))
if (ier /= 0) &
call shr_sys_abort('domain_init ERROR: allocate mblatv ')
domain%mblatv = nan
endif
end if
#endif

if (present(elmlevel)) then
domain%elmlevel = elmlevel
Expand Down Expand Up @@ -265,23 +245,6 @@ subroutine domain_clean(domain)
endif
endif
! pflotran:beg-----------------------------------------------------
#ifdef HAVE_MOAB
if (domain%nv > 0 .and. domain%nv /= huge(1)) then
if (associated(domain%mblonv)) then
deallocate(domain%mblonv, stat=ier)
if (ier /= 0) &
call shr_sys_abort('domain_clean ERROR: deallocate mblonv ')
nullify(domain%mblonv)
endif

if (associated(domain%mblatv)) then
deallocate(domain%mblatv, stat=ier)
if (ier /= 0) &
call shr_sys_abort('domain_clean ERROR: deallocate mblatv ')
nullify(domain%mblatv)
endif
endif
#endif

else
if (masterproc) then
Expand Down
Loading