Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • a58012c
  • /
  • penalty.f
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge
swh:1:cnt:fbf6d8aa5d5b461d777b29203dcffdf525f02997
directory badge
swh:1:dir:a58012c164c314abf600da40546b4bba54a556df

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
penalty.f
C Output from Public domain Ratfor, version 1.0
      subroutine penalty(n,m,q,x,y,bnd,tlist,tlptr,tlend,rax,jax,ned,eps
     *,ierr)
      integer n,m,q,lp,lpl,ned,ierr
      integer bnd(n),tlist(q),tlptr(q),tlend(n),n4(4),p4(4),jax(m)
      double precision x(n),y(n),rax(m),eps
      double precision x4(4),y4(4),g4(4)
      logical orient
      ned = 0
      do23000 i=1,n
      lpl = tlend(i)
      lp = lpl
23002 continue
      lp = tlptr(lp)
      j = iabs(tlist(lp))
      if(j .gt. i)then
      n4(1) = i
      n4(2) = j
      call fadjs(n4,n,q,tlist,tlptr,tlend)
      if(bnd(i)*bnd(j) .eq. 0)then
      ned = ned + 1
      do23009 k = 1,4
      x4(k) = x(n4(k))
      y4(k) = y(n4(k))
23009 continue
23010 continue
      if(orient(x4,y4))then
      call iswap(1,n4(3),1,n4(4),1)
      call dswap(1,x4(3),1,x4(4),1)
      call dswap(1,y4(3),1,y4(4),1)
      endif
      call ggap(x4,y4,g4,eps,ierr)
      if(ierr .eq. 1)then
      return
      endif
      call srtpai(n4,1,p4,1,4)
      do23015 k = 1,4
      rax((ned - 1)*4 + k) = g4(p4(k))
      jax((ned - 1)*4 + k) = n4(p4(k))
23015 continue
23016 continue
      if(ned*4 .gt. m)then
      return
      endif
      endif
      endif
      if(lp .eq. lpl)then
      goto 23004
      endif
23003 goto 23002
23004 continue
23000 continue
23001 continue
      return
      end
      logical function orient(x,y)
      double precision x(4), y(4)
      orient = (y(2) -y(1))*(x(3)-x(4))+(x(1)-x(2))*(y(3)-y(4)) .gt. 0
      return
      end
      subroutine fadjs(n4,n,q,tlist,tlptr,tlend)
      integer n,q,vp,vpl,v,v0,match
      integer n4(4),tlist(q),tlptr(q),tlend(n)
      match = 0
      vpl = tlend(n4(1))
      vp = vpl
      k = 0
23021 continue
      k = k+1
      vp = tlptr(vp)
      v = tlist(vp)
      if(k.gt.1 .and. iabs(v) .eq. n4(2))then
      n4(3) = iabs(v0)
      match = 1
      goto 23022
      endif
      if(match .gt. 0)then
      n4(4) = iabs(v)
      goto 23023
      endif
      v0 = v
23022 goto 23021
23023 continue
      return
      end
      subroutine ggap(x,y,g,eps,ierr)
      double precision x(4),y(4),g(4),w(2,4),h(2),d1,d2,eps
      d1 = -x(2) * y(1) + x(3) * y(1) + x(1) * y(2) - x(3) * y(2) - x(1)
     * * y(3) + x(2) * y(3)
      d2 = -x(2) * y(1) + x(4) * y(1) + x(1) * y(2) - x(4) * y(2) - x(1)
     * * y(4) + x(2) * y(4)
      if(dabs(d1) .lt. eps .or. dabs(d2) .lt. eps)then
      ierr = 1
      return
      endif
      h(1) = -(y(1) - y(2))
      h(2) = (x(1) - x(2))
      w(1, 1) = (y(2) - y(3))/d1 - (y(2) - y(4))/d2
      w(2, 1) = (x(3) - x(2))/d1 - (x(4) - x(2))/d2
      w(1, 2) = (y(3) - y(1))/d1 - (y(4) - y(1))/d2
      w(2, 2) = (x(1) - x(3))/d1 - (x(1) - x(4))/d2
      w(1, 3) = (y(1) - y(2))/d1
      w(2, 3) = (x(2) - x(1))/d1
      w(1, 4) = (y(2) - y(1))/d2
      w(2, 4) = (x(1) - x(2))/d2
      do23030 i = 1,4
      g(i) = h(1)*w(1,i)+h(2)*w(2,i)
23030 continue
23031 continue
      ierr = 0
      return
      end

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API