From efa2dc632c40b81d572c86460b83018c28b0d87a Mon Sep 17 00:00:00 2001 From: andrew-platt Date: Wed, 21 Jun 2023 14:54:49 -0600 Subject: [PATCH] IfW: improve error handling on XY plane export --- modules/inflowwind/src/InflowWind_IO.f90 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/inflowwind/src/InflowWind_IO.f90 b/modules/inflowwind/src/InflowWind_IO.f90 index eae5f741b4..616bdc7ca9 100644 --- a/modules/inflowwind/src/InflowWind_IO.f90 +++ b/modules/inflowwind/src/InflowWind_IO.f90 @@ -2948,6 +2948,9 @@ subroutine Grid3D_WriteVTKsliceXY(G3D, FileRootName, XYslice_height, unit, ErrSt integer(IntKi) :: ErrStat2 character(ErrMsgLen) :: ErrMsg2 + ErrStat = ErrID_None + ErrMsg = "" + call GetPath(FileRootName, RootPathName) RootPathName = trim(RootPathName)//PathSep//"vtk" call MkDir(trim(RootPathName)) ! make this directory if it doesn't already exist @@ -2958,7 +2961,7 @@ subroutine Grid3D_WriteVTKsliceXY(G3D, FileRootName, XYslice_height, unit, ErrSt write(ht_str,'(i3)') nint(ht) ! check for errors in slice height - if (iz <= 0_IntKi) then + if (iz <= 0_IntKi .or. iz > G3D%NZGrids) then call SetErrStat(ErrID_Warn,"No grid points near XY slice height of "//trim(num2lstr(XYslice_height))//". Skipping writing slice file.",ErrStat,ErrMsg,RoutineName) return endif @@ -2995,9 +2998,9 @@ subroutine Grid3D_WriteVTKsliceXY(G3D, FileRootName, XYslice_height, unit, ErrSt end do end do + close (unit) enddo - close (unit) end subroutine Grid3D_WriteVTKsliceXY end module InflowWind_IO