@@ -434,6 +434,7 @@ end subroutine define_dim
434434 ! > @brief netcdf export add mesh information
435435 ! <
436436 subroutine add_mesh_data (this )
437+ use BaseDisModule, only: dis_transform_xy
437438 class(Mesh2dDisvExportType), intent (inout ) :: this
438439 integer (I4B), dimension (:), contiguous, pointer :: icell2d = > null ()
439440 integer (I4B), dimension (:), contiguous, pointer :: ncvert = > null ()
@@ -442,6 +443,11 @@ subroutine add_mesh_data(this)
442443 real (DP), dimension (:), contiguous, pointer :: cell_y = > null ()
443444 real (DP), dimension (:), contiguous, pointer :: vert_x = > null ()
444445 real (DP), dimension (:), contiguous, pointer :: vert_y = > null ()
446+ real (DP), dimension (:), contiguous, pointer :: cell_xt = > null ()
447+ real (DP), dimension (:), contiguous, pointer :: cell_yt = > null ()
448+ real (DP), dimension (:), contiguous, pointer :: vert_xt = > null ()
449+ real (DP), dimension (:), contiguous, pointer :: vert_yt = > null ()
450+ real (DP) :: x_transform, y_transform
445451 integer (I4B) :: n, m, idx, cnt, iv, maxvert
446452 integer (I4B), dimension (:), allocatable :: verts
447453 real (DP), dimension (:), allocatable :: bnds
@@ -456,28 +462,56 @@ subroutine add_mesh_data(this)
456462 call mem_setptr(vert_x, ' XV' , this% dis_mempath)
457463 call mem_setptr(vert_y, ' YV' , this% dis_mempath)
458464
459- ! initialize max vertices required to define cell
460- maxvert = maxval (ncvert)
465+ ! allocate x, y transform arrays
466+ allocate (cell_xt(size (cell_x)))
467+ allocate (cell_yt(size (cell_y)))
468+ allocate (vert_xt(size (vert_x)))
469+ allocate (vert_yt(size (vert_y)))
461470
462471 ! set mesh container variable value to 1
463472 call nf_verify(nf90_put_var(this% ncid, this% var_ids% mesh, 1 ), &
464473 this% nc_fname)
465474
466- ! allocate temporary arrays
467- allocate (verts(maxvert))
468- allocate (bnds(maxvert))
475+ ! transform vert x and y
476+ do n = 1 , size (vert_x)
477+ call dis_transform_xy(vert_x(n), vert_y(n), &
478+ this% disv% xorigin, &
479+ this% disv% yorigin, &
480+ this% disv% angrot, &
481+ x_transform, y_transform)
482+ vert_xt(n) = x_transform
483+ vert_yt(n) = y_transform
484+ end do
485+
486+ ! transform cell x and y
487+ do n = 1 , size (cell_x)
488+ call dis_transform_xy(cell_x(n), cell_y(n), &
489+ this% disv% xorigin, &
490+ this% disv% yorigin, &
491+ this% disv% angrot, &
492+ x_transform, y_transform)
493+ cell_xt(n) = x_transform
494+ cell_yt(n) = y_transform
495+ end do
469496
470497 ! write node_x and node_y arrays to netcdf file
471498 call nf_verify(nf90_put_var(this% ncid, this% var_ids% mesh_node_x, &
472- vert_x + this % disv % xorigin ), this% nc_fname)
499+ vert_xt ), this% nc_fname)
473500 call nf_verify(nf90_put_var(this% ncid, this% var_ids% mesh_node_y, &
474- vert_y + this % disv % yorigin ), this% nc_fname)
501+ vert_yt ), this% nc_fname)
475502
476503 ! write face_x and face_y arrays to netcdf file
477504 call nf_verify(nf90_put_var(this% ncid, this% var_ids% mesh_face_x, &
478- cell_x + this % disv % xorigin ), this% nc_fname)
505+ cell_xt ), this% nc_fname)
479506 call nf_verify(nf90_put_var(this% ncid, this% var_ids% mesh_face_y, &
480- cell_y + this% disv% yorigin), this% nc_fname)
507+ cell_yt), this% nc_fname)
508+
509+ ! initialize max vertices required to define cell
510+ maxvert = maxval (ncvert)
511+
512+ ! allocate temporary arrays
513+ allocate (verts(maxvert))
514+ allocate (bnds(maxvert))
481515
482516 ! set face nodes array
483517 cnt = 0
@@ -502,7 +536,7 @@ subroutine add_mesh_data(this)
502536 bnds = NF90_FILL_DOUBLE
503537 do m = 1 , size (bnds)
504538 if (verts(m) /= NF90_FILL_INT) then
505- bnds(m) = vert_y (verts(m))
539+ bnds(m) = vert_yt (verts(m))
506540 end if
507541 ! write face y bounds array to netcdf file
508542 call nf_verify(nf90_put_var(this% ncid, this% var_ids% mesh_face_ybnds, &
@@ -515,7 +549,7 @@ subroutine add_mesh_data(this)
515549 bnds = NF90_FILL_DOUBLE
516550 do m = 1 , size (bnds)
517551 if (verts(m) /= NF90_FILL_INT) then
518- bnds(m) = vert_x (verts(m))
552+ bnds(m) = vert_xt (verts(m))
519553 end if
520554 ! write face x bounds array to netcdf file
521555 call nf_verify(nf90_put_var(this% ncid, this% var_ids% mesh_face_xbnds, &
@@ -528,6 +562,10 @@ subroutine add_mesh_data(this)
528562 ! cleanup
529563 deallocate (bnds)
530564 deallocate (verts)
565+ deallocate (cell_xt)
566+ deallocate (cell_yt)
567+ deallocate (vert_xt)
568+ deallocate (vert_yt)
531569 end subroutine add_mesh_data
532570
533571 ! > @brief netcdf export 1D integer array
0 commit comments