@@ -12,12 +12,10 @@ module semoab_mod
12
12
13
13
use dimensions_mod, only: nelem, ne, np, nelemd, nlev
14
14
use element_mod, only : element_t
15
- use parallel_mod, only : parallel_t
15
+ use parallel_mod, only : parallel_t, abortmp
16
16
17
17
use m_MergeSorts, only: IndexSet, IndexSort
18
18
19
- use cam_grid_support, only: iMap
20
- use cam_abortutils, only : endrun
21
19
use edgetype_mod, only: edgedescriptor_t
22
20
use gridgraph_mod, only: gridvertex_t
23
21
@@ -209,8 +207,10 @@ subroutine create_moab_meshes(par, elem)
209
207
if ( nelemd > 0 ) then
210
208
allocate (moab_vert_coords(3 * nverts) )
211
209
allocate (vdone(nverts))
212
- vdone = 0 ;
210
+ else
211
+ allocate (vdone(1 )) ! will be passed to iMOAB_ResolveSharedEnts, and compilers are complaining about non-allocated arrays
213
212
endif
213
+ vdone = 0 ;
214
214
if ( nelemd > 0 ) currentval = gdofv( indx(1 )) ! start over to identify coordinates of the vertices
215
215
216
216
do ix= 1 ,moab_dim_cquads
@@ -251,7 +251,7 @@ subroutine create_moab_meshes(par, elem)
251
251
if ( nelemd > 0 ) then
252
252
ierr = iMOAB_CreateVertices(MHFID, dimcoord, dimen, moab_vert_coords)
253
253
if (ierr > 0 ) &
254
- call endrun (' Error: fail to create MOAB vertices ' )
254
+ call abortmp (' Error: fail to create MOAB vertices ' )
255
255
endif
256
256
! !num_el = nelemd2
257
257
mbtype = 3 ! quadrilateral
@@ -261,7 +261,7 @@ subroutine create_moab_meshes(par, elem)
261
261
if ( nelemd > 0 ) then
262
262
ierr = iMOAB_CreateElements( MHFID, nelemd2, mbtype, nve, moabconn, block_ID );
263
263
if (ierr > 0 ) &
264
- call endrun (' Error: fail to create MOAB elements' )
264
+ call abortmp (' Error: fail to create MOAB elements' )
265
265
endif
266
266
! nverts: num vertices; vdone will store now the markers used in global resolve
267
267
! for this particular problem, markers are the global dofs at corner nodes
@@ -272,18 +272,19 @@ subroutine create_moab_meshes(par, elem)
272
272
numco = 1
273
273
ierr = iMOAB_DefineTagStorage(MHFID, tagname, tagtype, numco, tagindex )
274
274
if (ierr > 0 ) &
275
- call endrun (' Error: fail to retrieve global id tag' )
275
+ call abortmp (' Error: fail to retrieve global id tag' )
276
276
! now set the values
277
277
ent_type = 0 ! vertex type
278
278
if ( nverts > 0 ) then
279
279
ierr = iMOAB_SetIntTagStorage ( MHFID, tagname, nverts , ent_type, vdone)
280
280
if (ierr > 0 ) &
281
- call endrun (' Error: fail to set marker id tag for vertices' )
281
+ call abortmp (' Error: fail to set marker id tag for vertices' )
282
282
endif
283
283
284
+ ! we need to call this even when no mesh locally, it involves a collective
284
285
ierr = iMOAB_ResolveSharedEntities( MHFID, nverts, vdone );
285
286
if (ierr > 0 ) &
286
- call endrun (' Error: fail to resolve shared entities' )
287
+ call abortmp (' Error: fail to resolve shared entities' )
287
288
288
289
if ( nelemd > 0 ) then
289
290
vdone = - 1 ! reuse vdone for the new tag, GLOBAL_ID (actual tag that we want to store global dof )
@@ -294,7 +295,7 @@ subroutine create_moab_meshes(par, elem)
294
295
newtagg= ' GLOBAL_ID' // C_NULL_CHAR
295
296
ierr = iMOAB_DefineTagStorage(MHFID, newtagg, tagtype, numco, tagindex )
296
297
if (ierr > 0 ) &
297
- call endrun (' Error: fail to create new GDOF tag' )
298
+ call abortmp (' Error: fail to create new GDOF tag' )
298
299
do ie= 1 ,nelemd
299
300
do ii= 1 ,elem(ie)% idxp% NumUniquePts
300
301
i= elem(ie)% idxp% ia(ii)
@@ -310,19 +311,19 @@ subroutine create_moab_meshes(par, elem)
310
311
if ( nverts > 0 ) then
311
312
ierr = iMOAB_SetIntTagStorage ( MHFID, newtagg, nverts , ent_type, vdone)
312
313
if (ierr > 0 ) &
313
- call endrun (' Error: fail to set global dof tag for vertices' )
314
+ call abortmp (' Error: fail to set global dof tag for vertices' )
314
315
endif
315
316
316
317
ierr = iMOAB_ReduceTagsMax ( MHFID, tagindex, ent_type)
317
318
if (ierr > 0 ) &
318
- call endrun (' Error: fail to reduce max tag' )
319
+ call abortmp (' Error: fail to reduce max tag' )
319
320
320
321
! set global id tag for elements
321
322
ent_type = 1 ! now set the global id tag on elements
322
323
if ( nelemd2 > 0 ) then
323
324
ierr = iMOAB_SetIntTagStorage ( MHFID, newtagg, nelemd2 , ent_type, elemids)
324
325
if (ierr > 0 ) &
325
- call endrun (' Error: fail to set global id tag for elements' )
326
+ call abortmp (' Error: fail to set global id tag for elements' )
326
327
endif
327
328
328
329
! now, after reduction, we can get the actual global ids for each vertex in the fine mesh
@@ -333,18 +334,18 @@ subroutine create_moab_meshes(par, elem)
333
334
allocate (vgids(nverts))
334
335
ierr = iMOAB_GetIntTagStorage ( MHFID, newtagg, nverts , ent_type, vgids)
335
336
if (ierr > 0 ) &
336
- call endrun (' Error: fail to retrieve GLOBAL ID on each task' )
337
+ call abortmp (' Error: fail to retrieve GLOBAL ID on each task' )
337
338
endif
338
339
ierr = iMOAB_UpdateMeshInfo(MHFID)
339
340
if (ierr > 0 ) &
340
- call endrun (' Error: fail to update mesh info' )
341
+ call abortmp (' Error: fail to update mesh info' )
341
342
#ifdef MOABDEBUG
342
343
! write out the mesh file to disk, in parallel
343
344
outfile = ' wholeFineATM.h5m' // C_NULL_CHAR
344
345
wopts = ' PARALLEL=WRITE_PART' // C_NULL_CHAR
345
346
ierr = iMOAB_WriteMesh(MHFID, outfile, wopts)
346
347
if (ierr > 0 ) &
347
- call endrun (' Error: fail to write the mesh file' )
348
+ call abortmp (' Error: fail to write the mesh file' )
348
349
#endif
349
350
350
351
@@ -422,7 +423,7 @@ subroutine create_moab_meshes(par, elem)
422
423
if ( nverts_c > 0 ) then
423
424
ierr = iMOAB_CreateVertices(MHID, dimcoord, dimen, moab_vert_coords)
424
425
if (ierr > 0 ) &
425
- call endrun (' Error: fail to create MOAB vertices ' )
426
+ call abortmp (' Error: fail to create MOAB vertices ' )
426
427
endif
427
428
! num_el = nelemd
428
429
mbtype = 3 ! quadrilateral
@@ -432,7 +433,7 @@ subroutine create_moab_meshes(par, elem)
432
433
if ( nelemd > 0 ) then
433
434
ierr = iMOAB_CreateElements( MHID, nelemd, mbtype, nve, moabconn_c, block_ID );
434
435
if (ierr > 0 ) &
435
- call endrun (' Error: fail to create MOAB elements' )
436
+ call abortmp (' Error: fail to create MOAB elements' )
436
437
endif
437
438
! idx: num vertices; vdone will store now the markers used in global resolve
438
439
! for this particular problem, markers are the global dofs at corner nodes
@@ -443,36 +444,36 @@ subroutine create_moab_meshes(par, elem)
443
444
numco = 1
444
445
ierr = iMOAB_DefineTagStorage(MHID, tagname, tagtype, numco, tagindex )
445
446
if (ierr > 0 ) &
446
- call endrun (' Error: fail to retrieve GDOFV id tag' )
447
+ call abortmp (' Error: fail to retrieve GDOFV id tag' )
447
448
ierr = iMOAB_DefineTagStorage(MHID, newtagg, tagtype, numco, tagindex )
448
449
if (ierr > 0 ) &
449
- call endrun (' Error: fail to retrieve GLOBAL_ID tag on coarse mesh' )
450
+ call abortmp (' Error: fail to retrieve GLOBAL_ID tag on coarse mesh' )
450
451
! now set the values
451
452
ent_type = 0 ! vertex type
452
453
if ( nverts_c > 0 ) then
453
454
ierr = iMOAB_SetIntTagStorage ( MHID, tagname, nverts_c , ent_type, vdone_c)
454
455
if (ierr > 0 ) &
455
- call endrun (' Error: fail to set GDOFV tag for vertices' )
456
+ call abortmp (' Error: fail to set GDOFV tag for vertices' )
456
457
endif
457
458
! set global id tag for coarse elements, too; they will start at nets=1, end at nete=nelemd
458
459
ent_type = 1 ! now set the global id tag on elements
459
460
if ( nelemd > 0 ) then
460
461
ierr = iMOAB_SetIntTagStorage ( MHID, newtagg, nelemd , ent_type, elemids)
461
462
if (ierr > 0 ) &
462
- call endrun (' Error: fail to set global id tag for vertices' )
463
+ call abortmp (' Error: fail to set global id tag for vertices' )
463
464
endif
464
465
465
466
ierr = iMOAB_ResolveSharedEntities( MHID, idx, vdone_c );
466
467
if (ierr > 0 ) &
467
- call endrun (' Error: fail to resolve shared entities' )
468
+ call abortmp (' Error: fail to resolve shared entities' )
468
469
469
470
! global dofs are the GLL points are set for each element
470
471
tagname= ' GLOBAL_DOFS' // C_NULL_CHAR
471
472
tagtype = 0 ! dense, integer
472
473
numco = np* np ! usually, it is 16; each element will have the dofs in order
473
474
ierr = iMOAB_DefineTagStorage(MHID, tagname, tagtype, numco, tagindex )
474
475
if (ierr > 0 ) &
475
- call endrun (' Error: fail to create global DOFS tag' )
476
+ call abortmp (' Error: fail to create global DOFS tag' )
476
477
! now set the values
477
478
! set global dofs tag for coarse elements, too; they will start at nets=1, end at nete=nelemd
478
479
ent_type = 1 ! now set the global id tag on elements
@@ -499,27 +500,27 @@ subroutine create_moab_meshes(par, elem)
499
500
if ( nelemd > 0 ) then
500
501
ierr = iMOAB_SetIntTagStorage ( MHID, tagname, numvals, ent_type, gdofel)
501
502
if (ierr > 0 ) &
502
- call endrun (' Error: fail to set globalDOFs tag for coarse elements' )
503
+ call abortmp (' Error: fail to set globalDOFs tag for coarse elements' )
503
504
endif
504
505
505
506
! set the global ids for coarse vertices the same as corresponding fine vertices
506
507
ent_type = 0 ! vertex type
507
508
if ( nverts_c > 0 ) then
508
509
ierr = iMOAB_SetIntTagStorage ( MHID, newtagg, nverts_c , ent_type, vdone_c)
509
510
if (ierr > 0 ) &
510
- call endrun (' Error: fail to set GLOBAL_DOFS tag values' )
511
+ call abortmp (' Error: fail to set GLOBAL_DOFS tag values' )
511
512
endif
512
513
513
514
ierr = iMOAB_UpdateMeshInfo(MHID)
514
515
if (ierr > 0 ) &
515
- call endrun (' Error: fail to update mesh info' )
516
+ call abortmp (' Error: fail to update mesh info' )
516
517
#ifdef MOABDEBUG
517
518
! write out the mesh file to disk, in parallel
518
519
outfile = ' wholeATM.h5m' // C_NULL_CHAR
519
520
wopts = ' PARALLEL=WRITE_PART' // C_NULL_CHAR
520
521
ierr = iMOAB_WriteMesh(MHID, outfile, wopts)
521
522
if (ierr > 0 ) &
522
- call endrun (' Error: fail to write the mesh file' )
523
+ call abortmp (' Error: fail to write the mesh file' )
523
524
#endif
524
525
525
526
if (fv_nphys > 0 ) then
@@ -629,6 +630,8 @@ subroutine create_moab_meshes(par, elem)
629
630
! reuse moab_vert_coords for coordinates of pg mesh
630
631
! the first nverts_c coords are the same as coarse mesh; but we do create new
631
632
allocate (vdone_pg(nverts_pg))
633
+ else
634
+ allocate (vdone_pg(1 ))
632
635
endif
633
636
do iv = 1 , nverts_c
634
637
vdone_pg(iv) = vdone_c(iv) ! also the coordinates will be the same !!
@@ -737,7 +740,7 @@ subroutine create_moab_meshes(par, elem)
737
740
if ( nverts_pg > 0 ) then
738
741
ierr = iMOAB_CreateVertices(MHPGID, dimcoord, dimen, moab_vert_coords)
739
742
if (ierr > 0 ) &
740
- call endrun (' Error: fail to create MOAB vertices ' )
743
+ call abortmp (' Error: fail to create MOAB vertices ' )
741
744
endif
742
745
! num_el = nelem_pg *
743
746
mbtype = 3 ! quadrilateral
@@ -747,61 +750,60 @@ subroutine create_moab_meshes(par, elem)
747
750
if ( nelem_pg > 0 ) then
748
751
ierr = iMOAB_CreateElements( MHPGID, nelem_pg, mbtype, nve, moabconn_pg, block_ID );
749
752
if (ierr > 0 ) &
750
- call endrun (' Error: fail to create MOAB elements' )
753
+ call abortmp (' Error: fail to create MOAB elements' )
751
754
endif
752
755
tagname= ' GLOBAL_ID' // C_NULL_CHAR
753
756
tagtype = 0 ! dense, integer
754
757
numco = 1
755
758
ierr = iMOAB_DefineTagStorage(MHPGID, tagname, tagtype, numco, tagindex )
756
759
if (ierr > 0 ) &
757
- call endrun (' Error: fail to retrieve GLOBAL id tag' )
760
+ call abortmp (' Error: fail to retrieve GLOBAL id tag' )
758
761
759
762
! now set the values
760
763
ent_type = 0 ! vertex type
761
764
if ( nverts_pg > 0 ) then
762
765
ierr = iMOAB_SetIntTagStorage ( MHPGID, tagname, nverts_pg , ent_type, vdone_pg)
763
766
if (ierr > 0 ) &
764
- call endrun (' Error: fail to set global id tag for vertices' )
767
+ call abortmp (' Error: fail to set global id tag for vertices' )
765
768
endif
766
769
! set global id tag for pg2 elements, too; they will start at nets=1, end at nete=nelemd*4
767
770
ent_type = 1 ! now set the global id tag on elements
768
771
if ( nelem_pg > 0 ) then
769
772
ierr = iMOAB_SetIntTagStorage ( MHPGID, tagname, nelem_pg , ent_type, elemids)
770
773
if (ierr > 0 ) &
771
- call endrun (' Error: fail to set global id tag for edges' )
774
+ call abortmp (' Error: fail to set global id tag for edges' )
772
775
endif
773
776
777
+ ! this involves a collective, vdone_pg can be empty
774
778
ierr = iMOAB_ResolveSharedEntities( MHPGID, nverts_pg, vdone_pg );
775
779
if (ierr > 0 ) &
776
- call endrun (' Error: fail to resolve shared ents for pg2 mesh' )
780
+ call abortmp (' Error: fail to resolve shared ents for pg2 mesh' )
777
781
778
782
ierr = iMOAB_UpdateMeshInfo(MHPGID)
779
783
if (ierr > 0 ) &
780
- call endrun (' Error: fail to update mesh info for pg2 mesh' )
784
+ call abortmp (' Error: fail to update mesh info for pg2 mesh' )
781
785
#ifdef MOABDEBUG
782
786
! write out the mesh file to disk, in parallel
783
787
outfile = ' wholeATM_PG2.h5m' // C_NULL_CHAR
784
788
wopts = ' PARALLEL=WRITE_PART' // C_NULL_CHAR
785
789
ierr = iMOAB_WriteMesh(MHPGID, outfile, wopts)
786
790
if (ierr > 0 ) &
787
- call endrun (' Error: fail to write the mesh file' )
791
+ call abortmp (' Error: fail to write the mesh file' )
788
792
#endif
789
793
endif ! only valid for pg == 2
790
794
if ( nelemd > 0 ) then
791
795
deallocate (local_cell_gids)
792
796
deallocate (indx_cell)
793
797
deallocate (edge) !
794
798
deallocate (moabconn_pg) ! connectivity
795
- deallocate (vdone_pg)
796
799
endif
797
-
800
+ deallocate (vdone_pg) ! this is now always allocated/deallocated, even for no mesh here
798
801
endif
799
802
800
803
! deallocate
801
804
if ( nelemd > 0 ) then
802
805
deallocate (moabvh)
803
806
deallocate (moabconn) ! do not keep it anymore, we are not setting another tag on fine mesh
804
- deallocate (vdone)
805
807
deallocate (gdofel)
806
808
deallocate (indx)
807
809
deallocate (elemids)
@@ -810,6 +812,7 @@ subroutine create_moab_meshes(par, elem)
810
812
deallocate (moabconn_c)
811
813
deallocate (vdone_c)
812
814
endif
815
+ deallocate (vdone) ! we are always allocating this now
813
816
! end copy
814
817
815
818
end subroutine create_moab_meshes
0 commit comments