Skip to content

Commit 0e747dc

Browse files
authored
Merge branch 'iulian787/land_grid_simple' (PR #6754) into maint-3.0
Simplify the land grid instantiation for moab driver Do not differentiate anymore between bi-grid or trigrid. Also fix errors related to aream initialization for rof model [BFB]
2 parents 3f899ce + 28f8501 commit 0e747dc

File tree

9 files changed

+696
-621
lines changed

9 files changed

+696
-621
lines changed

components/elm/src/cpl/lnd_comp_mct.F90

Lines changed: 92 additions & 215 deletions
Large diffs are not rendered by default.

components/elm/src/main/surfrdMod.F90

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ module surfrdMod
2020
use ncdio_pio , only : ncd_io, check_var, ncd_inqfdims, check_dim, ncd_inqdid, ncd_inqdlen
2121
use pio
2222

23-
#ifdef HAVE_MOAB
24-
use mct_mod , only : mct_gsMap
25-
use decompMod , only : get_elmlevel_gsmap
26-
! use spmdMod , only : iam ! rank on the land communicator
27-
#endif
2823
use spmdMod
2924
use topounit_varcon , only : max_topounits, has_topounit
3025

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

185180
! pflotran:beg-----------------------------
186181
integer :: j, np, nv
187-
#ifdef HAVE_MOAB
188-
type(mct_gsMap), pointer :: gsMap
189-
integer :: i, iv , iseg, ig, local ! ni, nj, nv, nseg, global ig
190-
191-
#endif
192182

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

259249
end if
260250
! pflotran:end-----------------------------------------------
261-
262-
#ifdef HAVE_MOAB
263-
! read xv and yv for MOAB to learn mesh verticies
264-
if (ldomain%nv>=3 ) then
265-
call get_elmlevel_gsmap (grlnd, gsMap)
266-
allocate(rdata3d(nv,ni,nj)) ! transpose from c, as this is fortran
267-
vname = 'xv'
268-
! this should be improved in a distributed read, that does not use full grid ni * nj * nv 720*360*4*8 ~ 8Mb
269-
call ncd_io(ncid=ncid, varname=trim(vname), data=rdata3d, flag='read', readvar=readvar)
270-
if (.not. readvar) call endrun( msg=trim(subname)//' ERROR: xv NOT on file'//errMsg(__FILE__, __LINE__))
271-
! fill up the ldomain%mblonv(begg:endg, 1:nv) array
272-
local = begg
273-
do iseg = 1, gsMap%ngseg
274-
if (gsMap%pe_loc(iseg) .eq. iam) then
275-
do ig = gsMap%start(iseg), gsMap%start(iseg) + gsMap%length(iseg) - 1
276-
j = (ig-1)/ni + 1
277-
i = ig - ni*(j-1)
278-
do iv = 1, nv
279-
if (local .le. endg) then
280-
ldomain%mblonv(local, iv ) = rdata3d(iv, i, j)
281-
else
282-
write (iulog, *), 'OVERFLOW', iseg, gsMap%pe_loc(iseg), gsMap%start(iseg), gsMap%length(iseg), local
283-
endif
284-
enddo
285-
local = local + 1
286-
enddo
287-
endif
288-
enddo
289-
! repeat for mblatv
290-
vname = 'yv'
291-
call ncd_io(ncid=ncid, varname=trim(vname), data=rdata3d, flag='read', readvar=readvar)
292-
if (.not. readvar) call endrun( msg=trim(subname)//' ERROR: yv NOT on file'//errMsg(__FILE__, __LINE__))
293-
! fill up the ldomain%lonv(begg:endg, 1:nv) array
294-
local = begg
295-
do iseg = 1, gsMap%ngseg
296-
if (gsMap%pe_loc(iseg) .eq. iam) then
297-
do ig = gsMap%start(iseg), gsMap%start(iseg) + gsMap%length(iseg) - 1
298-
j = (ig-1)/ni + 1
299-
i = ig - ni*(j-1)
300-
do iv = 1, nv
301-
if (local .le. endg) then
302-
ldomain%mblatv(local, iv ) = rdata3d(iv, i, j)
303-
endif
304-
enddo
305-
local = local + 1
306-
enddo
307-
endif
308-
enddo
309-
! deallocate what is not needed anymore (for half degree land model, ~8Mb)
310-
deallocate(rdata3d)
311-
312-
end if
313-
#endif
314251
else
315252
call ncd_io(ncid=ncid, varname= 'AREA', flag='read', data=ldomain%area, &
316253
dim1name=grlnd, readvar=readvar)

components/elm/src/utils/domainMod.F90

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ module domainMod
5252
integer :: nv ! number of vertices
5353
real(r8),pointer :: latv(:,:) ! latitude of grid cell's vertices (deg)
5454
real(r8),pointer :: lonv(:,:) ! longitude of grid cell's vertices (deg)
55-
#ifdef HAVE_MOAB
56-
real(r8),pointer :: mblatv(:,:) ! latitude of grid cell's vertices (deg) for MOAB
57-
real(r8),pointer :: mblonv(:,:) ! longitude of grid cell's vertices (deg) for MOAB
58-
#endif
5955
real(r8) :: lon0 ! the origin lon/lat (Most western/southern corner, if not globally covered grids; OR -180W(360E)/-90N)
6056
real(r8) :: lat0 ! the origin lon/lat (Most western/southern corner, if not globally covered grids; OR -180W(360E)/-90N)
6157

@@ -154,22 +150,6 @@ subroutine domain_init(domain,isgrid2d,ni,nj,nbeg,nend,elmlevel)
154150
endif
155151
end if
156152
! pflotran:end-----------------------------------------------------
157-
#ifdef HAVE_MOAB
158-
if (domain%nv > 0 .and. domain%nv /= huge(1)) then
159-
if(.not.associated(domain%mblonv)) then
160-
allocate(domain%mblonv(nb:ne, 1:domain%nv), stat=ier)
161-
if (ier /= 0) &
162-
call shr_sys_abort('domain_init ERROR: allocate mblonv ')
163-
domain%mblonv = nan
164-
endif
165-
if(.not.associated(domain%mblatv)) then
166-
allocate(domain%mblatv(nb:ne, 1:domain%nv))
167-
if (ier /= 0) &
168-
call shr_sys_abort('domain_init ERROR: allocate mblatv ')
169-
domain%mblatv = nan
170-
endif
171-
end if
172-
#endif
173153

174154
if (present(elmlevel)) then
175155
domain%elmlevel = elmlevel
@@ -265,23 +245,6 @@ subroutine domain_clean(domain)
265245
endif
266246
endif
267247
! pflotran:beg-----------------------------------------------------
268-
#ifdef HAVE_MOAB
269-
if (domain%nv > 0 .and. domain%nv /= huge(1)) then
270-
if (associated(domain%mblonv)) then
271-
deallocate(domain%mblonv, stat=ier)
272-
if (ier /= 0) &
273-
call shr_sys_abort('domain_clean ERROR: deallocate mblonv ')
274-
nullify(domain%mblonv)
275-
endif
276-
277-
if (associated(domain%mblatv)) then
278-
deallocate(domain%mblatv, stat=ier)
279-
if (ier /= 0) &
280-
call shr_sys_abort('domain_clean ERROR: deallocate mblatv ')
281-
nullify(domain%mblatv)
282-
endif
283-
endif
284-
#endif
285248

286249
else
287250
if (masterproc) then

0 commit comments

Comments
 (0)