New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
m_dom_nodelist.f90 in branches/nemo_v3_3_beta/NEMOGCM/EXTERNAL/XMLF90/src/dom – NEMO

source: branches/nemo_v3_3_beta/NEMOGCM/EXTERNAL/XMLF90/src/dom/m_dom_nodelist.f90 @ 2281

Last change on this file since 2281 was 2281, checked in by smasson, 14 years ago

set proper svn properties to all files...

  • Property svn:keywords set to Id
File size: 1.9 KB
Line 
1module m_dom_nodelist
2
3use m_dom_types
4
5private
6
7public :: item
8public :: getLength
9public :: append
10
11interface append
12   module procedure append_nl
13end interface
14
15interface item
16   module procedure item_nl
17end interface
18
19interface getLength
20   module procedure getLength_nl
21end interface
22
23CONTAINS
24
25  !-----------------------------------------------------------
26  ! METHODS FOR NODELISTS
27  !-----------------------------------------------------------
28  function item_nl(nodeList, i)
29   
30    integer, intent(in)             :: i
31    type(fnodeList), pointer        :: nodeList
32    type(fnode), pointer            :: item_nl
33   
34    type(flistNode), pointer :: lp
35    integer :: n
36
37    item_nl => null()            ! In case there is no such item
38    if (.not. associated(nodeList)) RETURN
39
40    lp => nodeList%head
41    n = -1
42    do
43       if (.not. associated(lp))  exit
44       n = n + 1
45       if (n == i) then
46          item_nl => lp%node
47          exit
48       endif
49       lp => lp%next
50    enddo
51
52  end function item_nl
53
54  !-----------------------------------------------------------
55
56  function getLength_nl(nodeList)
57   
58    type(fnodeList), pointer :: nodeList
59    integer                  :: getLength_nl
60
61    if (.not. associated(nodeList)) then
62       getLength_nl = 0
63    else
64       getLength_nl = nodeList % length
65    endif
66
67  end function getLength_nl
68
69  subroutine append_nl(nodeList,node)
70    type(fnodeList), pointer :: nodeList
71    type(fnode), pointer :: node
72
73    if (.not. associated(nodeList)) then
74       allocate(nodeList)
75       nodelist%length = 1
76       allocate(nodelist%head)
77       nodelist%head%node => node
78       nodelist%tail => nodelist%head
79    else
80       allocate(nodelist%tail%next)
81       nodelist%tail%next%node => node
82       nodelist%tail => nodelist%tail%next
83       nodelist%length = nodelist%length + 1
84    endif
85
86  end subroutine append_nl
87
88end module m_dom_nodelist
89
Note: See TracBrowser for help on using the repository browser.