source: CPL/oasis3-mct/branches/OASIS3-MCT_2.0_branch/lib/mct/mpeu/m_flow.F90 @ 4775

Last change on this file since 4775 was 4775, checked in by aclsce, 5 years ago
  • Imported oasis3-mct from Cerfacs svn server (not suppotred anymore).

The version has been extracted from https://oasis3mct.cerfacs.fr/svn/branches/OASIS3-MCT_2.0_branch/oasis3-mct@1818

File size: 5.2 KB
Line 
1!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2!       NASA/GSFC, Data Assimilation Office, Code 910.3, GEOS/DAS      !
3!-----------------------------------------------------------------------
4! CVS m_flow.F90,v 1.3 2004-04-21 22:54:47 jacob Exp
5! CVS MCT_2_8_0 
6!-----------------------------------------------------------------------
7!BOP
8!
9! !MODULE: m_flow - tracing the program calling tree
10!
11! !DESCRIPTION:
12!
13! !INTERFACE:
14
15    module m_flow
16      implicit none
17      private   ! except
18
19      public :: flow_ci
20      public :: flow_co
21      public :: flow_flush
22      public :: flow_reset
23
24      interface flow_ci;    module procedure ci_;    end interface
25      interface flow_co;    module procedure co_;    end interface
26      interface flow_flush; module procedure flush_; end interface
27      interface flow_reset; module procedure reset_; end interface
28
29! !REVISION HISTORY:
30!       26Feb98 - Jing Guo <guo@thunder> - initial prototype/prolog/code
31!EOP
32!_______________________________________________________________________
33  character(len=*),parameter :: myname='MCT(MPEU)::m_flow'
34
35  integer,parameter :: MX_TNAME= 64
36  integer,parameter :: LN_TNAME= 32
37
38  integer,save :: mxdep= 0
39  integer,save :: iname=-1
40  character(len=LN_TNAME),save,dimension(0:MX_TNAME-1) :: tname
41
42  character(len=LN_TNAME),save :: ciname=' '
43  character(len=LN_TNAME),save :: coname=' '
44  logical,save :: balanced=.true.
45
46contains
47!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
48!       NASA/GSFC, Data Assimilation Office, Code 910.3, GEOS/DAS      !
49!-----------------------------------------------------------------------
50!BOP
51!
52! !IROUTINE: ci_ - checking in a level
53!
54! !DESCRIPTION:
55!
56! !INTERFACE:
57
58    subroutine ci_(name)
59      implicit none
60      character(len=*),intent(in) :: name
61
62! !REVISION HISTORY:
63!       26Feb98 - Jing Guo <guo@thunder> - initial prototype/prolog/code
64!EOP
65!_______________________________________________________________________
66  character(len=*),parameter :: myname_=myname//'::ci_'
67
68        ! Push in an entry in to a circulated list storage to save
69        ! only the last MX_TNAME entries.
70
71  iname=iname+1
72  tname(modulo(iname,MX_TNAME)) = name
73
74  if(mxdep < iname+1) mxdep=iname+1
75end subroutine ci_
76!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
77!       NASA/GSFC, Data Assimilation Office, Code 910.3, GEOS/DAS      !
78!-----------------------------------------------------------------------
79!BOP
80!
81! !IROUTINE: co_ - checking out a level
82!
83! !DESCRIPTION:
84!
85! !INTERFACE:
86
87    subroutine co_(name)
88      use m_chars, only : uppercase
89      implicit none
90      character(len=*),intent(in) :: name
91
92! !REVISION HISTORY:
93!       26Feb98 - Jing Guo <guo@thunder> - initial prototype/prolog/code
94!EOP
95!_______________________________________________________________________
96  character(len=*),parameter :: myname_=myname//'::co_'
97  character(len=LN_TNAME) :: uname
98
99  if(balanced) then
100    uname='?'
101    balanced=iname >= 0
102    if(balanced) then
103      uname=tname(modulo(iname,MX_TNAME))
104      balanced = uname == ' ' .or. uppercase(uname) == uppercase(name)
105    endif
106    if(.not.balanced) then
107      ciname=uname
108      coname= name
109    endif
110  endif
111
112        ! Pop out an entry
113
114  tname(modulo(iname,MX_TNAME))=' '
115  iname=iname-1
116
117end subroutine co_
118!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
119!       NASA/GSFC, Data Assimilation Office, Code 910.3, GEOS/DAS      !
120!-----------------------------------------------------------------------
121!BOP
122!
123! !IROUTINE: flush_ - print all remaining entries in the list
124!
125! !DESCRIPTION:
126!
127! !INTERFACE:
128
129    subroutine flush_(lu)
130      implicit none
131      integer,intent(in) :: lu
132
133! !REVISION HISTORY:
134!       26Feb98 - Jing Guo <guo@thunder> - initial prototype/prolog/code
135!EOP
136!_______________________________________________________________________
137  character(len=*),parameter :: myname_=myname//'::flush_'
138  integer :: i
139
140        ! Nothing to show
141
142  if(mxdep == 0 .and. iname == -1) return
143
144  WRITE(lu,'(2a,i4)',advance='no') myname,': depth =',mxdep
145
146  if(.not.balanced .or. iname < -1) then
147
148    WRITE(lu,'(4a)',advance='no')               &
149        ', ci/co unbalanced at ',trim(ciname),'/',trim(coname)
150
151    write(lu,'(a,i4)') ', level =',iname+1
152    return
153
154  endif
155
156  if(iname >= 0) then
157    write(lu,'(a)',advance='no') ', '
158    do i=0,iname-1
159      write(lu,'(2a)',advance='no') trim(tname(modulo(i,MX_TNAME))),'>'
160    end do
161    write(lu,'(a)',advance='no') trim(tname(modulo(iname,MX_TNAME)))
162  endif
163  write(lu,*)
164
165end subroutine flush_
166!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
167!       NASA/GSFC, Data Assimilation Office, Code 910.3, GEOS/DAS      !
168!-----------------------------------------------------------------------
169!BOP
170!
171! !IROUTINE: reset_ - set the stack to empty
172!
173! !DESCRIPTION:
174!
175! !INTERFACE:
176
177    subroutine reset_()
178      implicit none
179
180! !REVISION HISTORY:
181!       26Feb98 - Jing Guo <guo@thunder> - initial prototype/prolog/code
182!EOP
183!_______________________________________________________________________
184  character(len=*),parameter :: myname_=myname//'::reset_'
185  integer :: i
186
187  mxdep=0
188  iname=-1
189  tname(0:MX_TNAME-1)=' '
190
191  ciname=' '
192  coname=' '
193  balanced=.true.
194
195end subroutine reset_
196end module m_flow
Note: See TracBrowser for help on using the repository browser.