Skip to content

Commit

Permalink
add error stop
Browse files Browse the repository at this point in the history
  • Loading branch information
gha3mi committed Mar 30, 2024
1 parent ed4358e commit 2b43cfb
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 138 deletions.
35 changes: 14 additions & 21 deletions src/NURBS/forcad_nurbs_curve.f90
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ pure subroutine set1(this, knot, Xc, Wc)
this%nc = size(this%Xc, 1)
if (present(Wc)) then
if (size(Wc) /= this%nc) then
! print*, 'Error: Number of weights does not match the number of control points.'
return
error stop 'Number of weights does not match the number of control points.'
else
this%Wc = Wc
end if
Expand All @@ -90,8 +89,7 @@ pure subroutine set2(this, Xth_dir, order, continuity, Xc, Wc)
this%nc = size(this%Xc, 1)
if (present(Wc)) then
if (size(Wc) /= this%nc) then
! print*, 'Error: Number of weights does not match the number of control points.'
return
error stop 'Number of weights does not match the number of control points.'
else
this%Wc = Wc
end if
Expand All @@ -112,8 +110,7 @@ pure subroutine create(this, res, Xt)

! check
if (.not.allocated(this%Xc)) then
! print*, 'Error: Control points are not set.'
return
error stop 'Control points are not set.'
end if

! Set parameter values
Expand Down Expand Up @@ -165,7 +162,7 @@ pure function get_Xc(this) result(Xc)
if (allocated(this%Xc)) then
Xc = this%Xc
else
! print*, 'Error: Control points are not set.'
error stop 'Control points are not set.'
end if
end function
!===============================================================================
Expand All @@ -181,7 +178,7 @@ pure function get_Xg(this) result(Xg)
if (allocated(this%Xg)) then
Xg = this%Xg
else
! print*, 'Error: Geometry points are not set.'
error stop 'Geometry points are not set.'
end if
end function
!===============================================================================
Expand All @@ -197,7 +194,7 @@ pure function get_Wc(this) result(Wc)
if (allocated(this%Wc)) then
Wc = this%Wc
else
! print*, 'Error: The Bezier curve is not rational.'
error stop 'The Bezier curve is not rational.'
end if
end function
!===============================================================================
Expand All @@ -213,7 +210,7 @@ pure function get_Xt(this) result(Xt)
if (allocated(this%Xt)) then
Xt = this%Xt
else
! print*, 'Error: Parameter values are not set.'
error stop 'Parameter values are not set.'
end if
end function
!===============================================================================
Expand Down Expand Up @@ -256,7 +253,7 @@ pure function get_knot(this) result(knot)
if (allocated(this%knot)) then
knot = this%knot
else
! print*, 'Error: Knot vector is not set.'
error stop 'Knot vector is not set.'
end if
end function
!===============================================================================
Expand Down Expand Up @@ -321,8 +318,7 @@ impure subroutine export_Xc(this, filename)

! check
if (.not.allocated(this%Xc)) then
! print*, 'Error: Control points are not set.'
return
error stop 'Control points are not set.'
end if

call this%get_elem_Xc(elemConn)
Expand Down Expand Up @@ -361,8 +357,7 @@ impure subroutine export_Xg(this, filename)

! check
if (.not.allocated(this%Xg)) then
! print*, 'Error: Geometry points are not set.'
return
error stop 'Geometry points are not set.'
end if

call this%get_elem_Xg(elemConn)
Expand Down Expand Up @@ -403,7 +398,7 @@ pure subroutine modify_Xc(this,X,num,dir)
this%Xc(num,dir) = X
call this%set(knot = this%knot, Xc = this%Xc, Wc = this%Wc)
else
! print*, 'Error: Control points are not set.'
error stop 'Control points are not set.'
end if
end subroutine
!===============================================================================
Expand All @@ -421,7 +416,7 @@ pure subroutine modify_Wc(this,W,num)
this%Wc(num) = W
call this%set(knot = this%knot, Xc = this%Xc, Wc = this%Wc)
else
! print*, 'Error: The Bezier curve is not rational.'
error stop 'The Bezier curve is not rational.'
end if
end subroutine
!===============================================================================
Expand All @@ -436,8 +431,7 @@ pure function get_multiplicity(this) result(m)

! check
if (.not.allocated(this%knot)) then
! print*, 'Error: Knot vector is not set.'
return
error stop 'Knot vector is not set.'
else
m = compute_multiplicity(this%knot)
end if
Expand All @@ -454,8 +448,7 @@ pure function get_continuity(this) result(c)

! check
if (.not.allocated(this%knot)) then
! print*, 'Error: Knot vector is not set.'
return
error stop 'Knot vector is not set.'
else
c = this%order - compute_multiplicity(this%knot)
end if
Expand Down
55 changes: 23 additions & 32 deletions src/NURBS/forcad_nurbs_surface.f90
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ pure subroutine create(this, res1, res2, Xt1, Xt2)

! check
if (.not.allocated(this%Xc)) then
! print*, 'Error: Control points are not set.'
return
error stop 'Control points are not set.'
end if


Expand Down Expand Up @@ -181,7 +180,7 @@ pure function get_Xc(this) result(Xc)
if (allocated(this%Xc)) then
Xc = this%Xc
else
! print*, 'Error: Control points are not set.'
error stop 'Control points are not set.'
end if
end function
!===============================================================================
Expand All @@ -197,7 +196,7 @@ pure function get_Xg(this) result(Xg)
if (allocated(this%Xg)) then
Xg = this%Xg
else
! print*, 'Error: Geometry points are not set.'
error stop 'Geometry points are not set.'
end if
end function
!===============================================================================
Expand All @@ -213,7 +212,7 @@ pure function get_Wc(this) result(Wc)
if (allocated(this%Wc)) then
Wc = this%Wc
else
! print*, 'Error: The Bezier curve is not rational.'
error stop 'The Bezier curve is not rational.'
end if
end function
!===============================================================================
Expand All @@ -231,16 +230,16 @@ pure function get_Xt(this, dir) result(Xt)
if (allocated(this%Xt1)) then
Xt = this%Xt1
else
! print*, 'Error: Parameter values are not set.'
error stop 'Parameter values are not set.'
end if
elseif (dir == 2) then
if (allocated(this%Xt2)) then
Xt = this%Xt2
else
! print*, 'Error: Parameter values are not set.'
error stop 'Parameter values are not set.'
end if
else
! print*, 'Error: Invalid direction for parameter values.'
error stop 'Invalid direction for parameter values.'
end if

end function
Expand Down Expand Up @@ -288,16 +287,16 @@ pure function get_knot(this, dir) result(knot)
if (allocated(this%knot1)) then
knot = this%knot1
else
! print*, 'Error: Knot vector is not set.'
error stop 'Knot vector is not set.'
end if
elseif (dir == 2) then
if (allocated(this%knot2)) then
knot = this%knot2
else
! print*, 'Error: Knot vector is not set.'
error stop 'Knot vector is not set.'
end if
else
! print*, 'Error: Invalid direction for knot vector.'
error stop 'Invalid direction for knot vector.'
end if

end function
Expand Down Expand Up @@ -365,8 +364,7 @@ impure subroutine export_Xc(this, filename)

! check
if (.not.allocated(this%Xc)) then
! print*, 'Error: Control points are not set.'
return
error stop 'Control points are not set.'
end if

call this%get_elem_Xc(elemConn)
Expand Down Expand Up @@ -405,8 +403,7 @@ impure subroutine export_Xg(this, filename)

! check
if (.not.allocated(this%Xg)) then
! print*, 'Error: Geometry points are not set.'
return
error stop 'Geometry points are not set.'
end if

call this%get_elem_Xg(elemConn)
Expand Down Expand Up @@ -447,7 +444,7 @@ pure subroutine modify_Xc(this,X,num,dir)
this%Xc(num,dir) = X
call this%set(knot1 = this%knot1, knot2 = this%knot2, Xc = this%Xc, Wc = this%Wc)
else
! print*, 'Error: Control points are not set.'
error stop 'Control points are not set.'
end if
end subroutine
!===============================================================================
Expand All @@ -465,7 +462,7 @@ pure subroutine modify_Wc(this,W,num)
this%Wc(num) = W
call this%set(knot1 = this%knot1, knot2 = this%knot2, Xc = this%Xc, Wc = this%Wc)
else
! print*, 'Error: The NURBS surface is not rational.'
error stop 'The NURBS surface is not rational.'
end if
end subroutine
!===============================================================================
Expand All @@ -483,8 +480,7 @@ pure function get_multiplicity(this, dir) result(m)

! check
if (.not.allocated(this%knot1)) then
! print*, 'Error: Knot vector is not set.'
return
error stop 'Knot vector is not set.'
else
m = compute_multiplicity(this%knot1)
end if
Expand All @@ -493,14 +489,13 @@ pure function get_multiplicity(this, dir) result(m)

! check
if (.not.allocated(this%knot2)) then
! print*, 'Error: Knot vector is not set.'
return
error stop 'Knot vector is not set.'
else
m = compute_multiplicity(this%knot2)
end if

else
! print*, 'Error: Invalid direction.'
error stop 'Invalid direction.'
end if

end function
Expand All @@ -519,8 +514,7 @@ pure function get_continuity(this, dir) result(c)

! check
if (.not.allocated(this%knot1)) then
! print*, 'Error: Knot vector is not set.'
return
error stop 'Knot vector is not set.'
else
c = this%order(1) - compute_multiplicity(this%knot1)
end if
Expand All @@ -529,14 +523,13 @@ pure function get_continuity(this, dir) result(c)

! check
if (.not.allocated(this%knot2)) then
! print*, 'Error: Knot vector is not set.'
return
error stop 'Knot vector is not set.'
else
c = this%order(2) - compute_multiplicity(this%knot2)
end if

else
! print*, 'Error: Invalid direction.'
error stop 'Invalid direction.'
end if

end function
Expand All @@ -555,8 +548,7 @@ pure function get_nc(this, dir) result(nc)

! check
if (.not.allocated(this%knot1)) then
! print*, 'Error: Knot vector is not set.'
return
error stop 'Knot vector is not set.'
else
nc = sum(compute_multiplicity(this%knot1)) - this%order(1) - 1
end if
Expand All @@ -565,14 +557,13 @@ pure function get_nc(this, dir) result(nc)

! check
if (.not.allocated(this%knot2)) then
! print*, 'Error: Knot vector is not set.'
return
error stop 'Knot vector is not set.'
else
nc = sum(compute_multiplicity(this%knot2)) - this%order(2) - 1
end if

else
! print*, 'Error: Invalid direction.'
error stop 'Invalid direction.'
end if

end function
Expand Down
Loading

0 comments on commit 2b43cfb

Please sign in to comment.