Skip to content

Commit

Permalink
Time series/discharges & curvilinear ghost corners
Browse files Browse the repository at this point in the history
Consistent Time series/discharges using X,Y location in curvilinear grids with ghost corners (not defined with a real location).
  • Loading branch information
PauloChambelGit committed Mar 23, 2021
1 parent 28d62c0 commit 780efe6
Show file tree
Hide file tree
Showing 7 changed files with 472 additions and 55 deletions.
249 changes: 240 additions & 9 deletions Software/ConvertToHDF5/ModuleNetCDFCF_2_HDF5MOHID.F90

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions Software/MOHIDBase1/ModuleGlobalData.F90
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Module ModuleGlobalData
end interface SetError

!Parameter-----------------------------------------------------------------
integer, parameter :: MaxModules = 99
integer, parameter :: MaxModules = 100

#if defined(_INCREASE_MAXINSTANCES)
integer, parameter :: MaxInstances = 2000
Expand Down Expand Up @@ -1983,6 +1983,7 @@ Module ModuleGlobalData
integer, parameter :: mTwoWay_ = 97
integer, parameter :: mOutputGrid_ = 98
integer, parameter :: mMeshGlue_ = 99
integer, parameter :: mDelftFM_2_MOHID_ = 100

!Domain decomposition
integer, parameter :: WestSouth = 1
Expand Down Expand Up @@ -2111,7 +2112,8 @@ Module ModuleGlobalData
T_Module(mSediment_ , "Sediment" ), T_Module(mReservoirs_ , "Reservoirs" ), &
T_Module(mIrrigation_ , "Irrigation" ), T_Module(mTURBINE_ , "Turbine" ), &
T_Module(mLitter_ , "Litter" ), T_Module(mTwoWay_ , "TwoWay" ), &
T_Module(mOutputGrid_ , "OutputGrid" ), T_Module(mMeshGlue_ , "MeshGlue" )/)
T_Module(mOutputGrid_ , "OutputGrid" ), T_Module(mMeshGlue_ , "MeshGlue" ), &
T_Module(mDelftFM_2_MOHID_ , "DelftFM_2_MOHID" )/)


!Variables
Expand Down
84 changes: 71 additions & 13 deletions Software/MOHIDBase1/ModuleTimeSerie.F90
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Module ModuleTimeSerie
public :: WriteSpecificTimeSerieLine
public :: CorrectsCellsTimeSerie
public :: TryIgnoreTimeSerie
public :: SetIgnoreTimeSerie
public :: ReseatCurrentIndex

!Selector
Expand Down Expand Up @@ -183,6 +184,7 @@ Module ModuleTimeSerie
logical :: TimeSerie1D = .false.
logical :: ComputeResidual = .true.
!logical :: IgnoreON = .false.
logical :: GhostCorners = .false.

!TimeSerieInput
logical :: TimeCycle = .false.
Expand Down Expand Up @@ -239,7 +241,8 @@ subroutine StartTimeSerie(TimeSerieID, ObjTime,
TimeSerieDataFile, PropertyList, Extension, WaterPoints3D, &
WaterPoints2D, WaterPoints1D, ResultFileName, Instance, &
ModelName, CoordX, CoordY, UseTabulatedData, &
HavePath, Comment, ModelDomain, ReplacePath, STAT)
HavePath, Comment, ModelDomain, ReplacePath, GhostCorners, &
STAT)

!Arguments-------------------------------------------------------------
integer :: TimeSerieID
Expand All @@ -260,6 +263,7 @@ subroutine StartTimeSerie(TimeSerieID, ObjTime,
character(len=*), optional, intent(IN ) :: Comment
type (T_Polygon), pointer, optional :: ModelDomain
character(len=*), optional, intent(IN ) :: ReplacePath
logical, optional, intent(IN ) :: GhostCorners
integer, optional, intent(OUT) :: STAT

!Local-----------------------------------------------------------------
Expand Down Expand Up @@ -317,6 +321,12 @@ subroutine StartTimeSerie(TimeSerieID, ObjTime,
Me%ModelDomainON = .false.
endif

if (present(GhostCorners)) then
Me%GhostCorners = GhostCorners
else
Me%GhostCorners = .false.
endif


!Constructs EnterData
call ConstructEnterData(Me%ObjEnterData, TimeSerieDataFile, STAT = STAT_CALL)
Expand Down Expand Up @@ -366,17 +376,6 @@ subroutine StartTimeSerie(TimeSerieID, ObjTime,

endif

!call GetData(Me%IgnoreON, &
! Me%ObjEnterData, &
! flag, &
! SearchType = FromFile, &
! keyword ='IGNORE_ON', &
! Default = .false., &
! ClientModule ='ModuleTimeSerie', &
! STAT = STAT_CALL)
!if (STAT_CALL .NE. SUCCESS_) &
! call SetError(FATAL_, KEYWORD_, "Subroutine StartTimeSerie - ModuleTimeSerie. ERR50")

!Stores the number of properties
Me%NumberOfProperties = size(PropertyList)

Expand Down Expand Up @@ -903,10 +902,15 @@ integer function ReadTimeSeriesLocation ()
TimeSeriesXY%X = Me%TimeSerie(iTimeSerie)%CoordX
TimeSeriesXY%Y = Me%TimeSerie(iTimeSerie)%CoordY

Me%TimeSerie(iTimeSerie)%IgnoreON = .false.

if (Me%GhostCorners) then
Me%TimeSerie(iTimeSerie)%IgnoreON = .false.
else
if (.not. IsPointInsidePolygon(TimeSeriesXY, Me%ModelDomain)) then
Me%TimeSerie(iTimeSerie)%IgnoreON = .true.
endif

endif
deallocate(TimeSeriesXY)

endif i12
Expand Down Expand Up @@ -3523,6 +3527,60 @@ subroutine TryIgnoreTimeSerie(TimeSerieID, Number, IgnoreOK, STAT)
!----------------------------------------------------------------------

end subroutine TryIgnoreTimeSerie


!--------------------------------------------------------------------------

subroutine SetIgnoreTimeSerie(TimeSerieID, Number, IgnoreOK, STAT)

!Arguments--------------------------------------------------------------
integer :: TimeSerieID
integer, intent(IN) :: Number
logical, intent(IN) :: IgnoreOK
integer, intent(OUT), optional :: STAT



!Local-----------------------------------------------------------------
integer :: ready_
integer :: STAT_
integer :: STAT_CALL

!----------------------------------------------------------------------

STAT_ = UNKNOWN_

call Ready(TimeSerieID, ready_)

cd1 : if (ready_ .EQ. IDLE_ERR_) then

Me%TimeSerie(Number)%IgnoreON = IgnoreOK

if (IgnoreOK) then
call UnitsManager(unit = Me%TimeSerie(Number)%UnitNumber, &
OPENCLOSE = CLOSE_FILE, &
STATUS ='DELETE', &
STAT = STAT_CALL)
if (STAT_CALL /= SUCCESS_) then
write(*,*) 'SetIgnoreTimeSerie - ModuleTimeSerie - WRN10'
endif
endif

STAT_ = SUCCESS_
else

STAT_ = ready_

end if cd1


if (present(STAT)) &
STAT = STAT_

!----------------------------------------------------------------------

end subroutine SetIgnoreTimeSerie


!--------------------------------------------------------------------------
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Expand Down
103 changes: 94 additions & 9 deletions Software/MOHIDBase2/ModuleHorizontalGrid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ Module ModuleHorizontalGrid
public :: GetDDecompMapping2D
public :: GetDDecompMPI_ID
public :: GetDDecompON
public :: GetGhostCorners

public :: GetSonWindow

Expand Down Expand Up @@ -590,7 +591,7 @@ Module ModuleHorizontalGrid
logical :: CornersXYInput = .false.
logical :: Distortion = .false.
logical :: RegularRotation = .false.
logical :: GostCorners = .false.
logical :: GhostCorners = .false.

integer, dimension(:,:), pointer :: DefineCellsMap => null()
integer, dimension(:,:), pointer :: DefineFacesUMap => null()
Expand Down Expand Up @@ -3480,7 +3481,7 @@ subroutine ConstructGlobalVariables
endif

if (Me%XX_IE(ii, jj) < FillValueReal/2) then
Me%GostCorners = .true.
Me%GhostCorners = .true.
Cycle
endif

Expand Down Expand Up @@ -11811,7 +11812,6 @@ integer function GetDDecompMPI_ID(HorizontalGridID, STAT)
end function GetDDecompMPI_ID

!--------------------------------------------------------------------------
!--------------------------------------------------------------------------

logical function GetDDecompON(HorizontalGridID, STAT)

Expand Down Expand Up @@ -11854,6 +11854,46 @@ end function GetDDecompON

!--------------------------------------------------------------------------


logical function GetGhostCorners(HorizontalGridID, STAT)

!Arguments-------------------------------------------------------------
integer, intent(IN ) :: HorizontalGridID
integer, optional, intent(OUT) :: STAT

!External--------------------------------------------------------------

integer :: ready_

!Local-----------------------------------------------------------------

integer :: STAT_ !Auxiliar local variable

!----------------------------------------------------------------------

STAT_ = UNKNOWN_

GetGhostCorners = .false.

call Ready(HorizontalGridID, ready_)

cd1 : if ((ready_ .EQ. IDLE_ERR_ ) .OR. &
(ready_ .EQ. READ_LOCK_ERR_)) then

GetGhostCorners = Me%GhostCorners

STAT_ = SUCCESS_
else
STAT_ = ready_
end if cd1


if (present(STAT)) STAT = STAT_

!----------------------------------------------------------------------

end function GetGhostCorners

!--------------------------------------------------------------------------

function GetDDecompOpenBorders(HorizontalGridID, STAT)
Expand Down Expand Up @@ -18416,6 +18456,50 @@ subroutine LocateCellPolygons(XX2D_Z, YY2D_Z, XPoint, YPoint,
Point%X = XPoint
Point%Y = YPoint

f0: if (Me%GhostCorners) then

dj1: do j = JLB, JUB
di1: do i = ILB, IUB

if(DefinedPoint(i,j) == 1)then

Me%AuxPolygon%VerticesF(1)%X = XX2D_Z(i ,j )
Me%AuxPolygon%VerticesF(1)%Y = YY2D_Z(i ,j )

Me%AuxPolygon%VerticesF(2)%X = XX2D_Z(i+1,j )
Me%AuxPolygon%VerticesF(2)%Y = YY2D_Z(i+1,j )

Me%AuxPolygon%VerticesF(3)%X = XX2D_Z(i+1,j+1)
Me%AuxPolygon%VerticesF(3)%Y = YY2D_Z(i+1,j+1)

Me%AuxPolygon%VerticesF(4)%X = XX2D_Z(i ,j+1)
Me%AuxPolygon%VerticesF(4)%Y = YY2D_Z(i ,j+1)

!close polygon
Me%AuxPolygon%VerticesF(5)%X = Me%AuxPolygon%VerticesF(1)%X
Me%AuxPolygon%VerticesF(5)%Y = Me%AuxPolygon%VerticesF(1)%Y

call SetLimits(Me%AuxPolygon)

if (IsPointInsidePolygon(Point, Me%AuxPolygon)) then

SearchCell = .false.
CellFound = .true.

IZ = i
JZ = j

exit dj1

endif

endif

enddo di1
enddo dj1

else f0

!check if
f1: if (present(Iold) .and. present(Jold)) then

Expand Down Expand Up @@ -18485,8 +18569,8 @@ subroutine LocateCellPolygons(XX2D_Z, YY2D_Z, XPoint, YPoint,
IUpper = IUB
end if

do j = JLower, JUpper
do i = ILower, IUpper
dj2: do j = JLower, JUpper
di2: do i = ILower, IUpper

if(i == iold .and. j == jold) cycle

Expand Down Expand Up @@ -18518,15 +18602,14 @@ subroutine LocateCellPolygons(XX2D_Z, YY2D_Z, XPoint, YPoint,
IZ = i
JZ = j

exit
exit dj2

endif

endif

enddo
if(CellFound) exit !exit do J loop
enddo
enddo di2
enddo dj2

end if f3

Expand Down Expand Up @@ -18690,6 +18773,8 @@ subroutine LocateCellPolygons(XX2D_Z, YY2D_Z, XPoint, YPoint,
endif f4

endif f2

endif f0

if (present(CellLocated)) CellLocated = CellFound

Expand Down
Loading

0 comments on commit 780efe6

Please sign in to comment.