SCALE-RM
scale_tracer.F90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
10 !-------------------------------------------------------------------------------
11 #include "scalelib.h"
13  !-----------------------------------------------------------------------------
14  !
15  !++ used modules
16  !
17  use scale_precision
18  use scale_io
19  use scale_prof
20  !-----------------------------------------------------------------------------
21  implicit none
22  private
23  !-----------------------------------------------------------------------------
24  !
25  !++ Public procedure
26  !
27  public :: tracer_regist
28  public :: tracer_inq_id
29 
30  !-----------------------------------------------------------------------------
31  !
32  !++ Public parameters & variables
33  !
34  integer, public :: qa = 0
35 
36  integer, private, parameter :: qa_max = 1024
37 
38  character(len=H_SHORT), public :: tracer_name (qa_max)
39  character(len=H_MID), public :: tracer_desc (qa_max)
40  character(len=H_SHORT), public :: tracer_unit (qa_max)
41  real(rp), public :: tracer_cv (qa_max)
42  real(rp), public :: tracer_cp (qa_max)
43  real(rp), public :: tracer_r (qa_max)
44  real(rp), public :: tracer_engi0(qa_max)
45  logical, public :: tracer_advc (qa_max)
46  real(rp), public :: tracer_mass (qa_max)
47 
48  !-----------------------------------------------------------------------------
49  !
50  !++ Private procedure
51  !
52  !-----------------------------------------------------------------------------
53  !
54  !++ Private parameters & variables
55  !
56  !-----------------------------------------------------------------------------
57 contains
58  !-----------------------------------------------------------------------------
60  subroutine tracer_regist( &
61  QS, &
62  NQ, NAME, DESC, UNIT, &
63  CV, CP, R, ENGI0, &
64  ADVC, MASS )
65  use scale_prc, only: &
66  prc_abort
67  implicit none
68 
69  integer, intent(out) :: qs
70  integer, intent(in) :: nq
71  character(len=*), intent(in) :: name (nq)
72  character(len=*), intent(in) :: desc (nq)
73  character(len=*), intent(in) :: unit (nq)
74  real(rp), intent(in), optional :: cv (nq)
75  real(rp), intent(in), optional :: cp (nq)
76  real(rp), intent(in), optional :: r (nq)
77  real(rp), intent(in), optional :: engi0(nq)
78  logical, intent(in), optional :: advc (nq)
79  logical, intent(in), optional :: mass (nq)
80 
81  real(rp) :: cv_ (nq)
82  real(rp) :: cp_ (nq)
83  real(rp) :: r_ (nq)
84  real(rp) :: engi0_(nq)
85  logical :: advc_ (nq)
86  logical :: mass_ (nq)
87 
88  character(len=24) :: name_trim
89 
90  integer :: n
91  !---------------------------------------------------------------------------
92 
93  if ( qa + nq > qa_max ) then
94  log_error("TRACER_regist",*) 'total number of tracer must be less or equal to ', qa_max
95  call prc_abort
96  end if
97 
98  if ( present(cv) ) then
99  cv_(:) = cv(:)
100  else
101  cv_(:) = 0.0_rp
102  end if
103 
104  if ( present(cp) ) then
105  cp_(:) = cp(:)
106  else
107  cp_(:) = 0.0_rp
108  end if
109 
110  if ( present(r) ) then
111  r_(:) = r(:)
112  else
113  r_(:) = 0.0_rp
114  end if
115 
116  if ( present(engi0) ) then
117  engi0_(:) = engi0(:)
118  else
119  engi0_(:) = 0.0_rp
120  end if
121 
122  if ( present(advc) ) then
123  advc_(:) = advc(:)
124  else
125  advc_(:) = .true.
126  end if
127 
128  if ( present(mass) ) then
129  mass_(:) = mass(:)
130  else
131  mass_(:) = .false.
132  end if
133 
134  log_newline
135  do n = 1, nq
136 
137  name_trim = trim(name(n))
138 
139  log_info("TRACER_regist",'(1x,A,I3,A,A,A,F6.1,A,F6.1,A,ES10.3,A,L1,A,L1)') &
140  '] Register tracer : No.', qa+n, &
141  ', NAME = ', name_trim, &
142  ', CV = ', cv_(n), &
143  ', CP = ', cp_(n), &
144  ', ENGI0 = ', engi0_(n), &
145  ', ADVC = ', advc_(n), &
146  ', MASS = ', mass_(n)
147 
148  tracer_name(qa+n) = name(n)
149  tracer_desc(qa+n) = desc(n)
150  tracer_unit(qa+n) = unit(n)
151  tracer_cv(qa+n) = cv_(n)
152  tracer_cp(qa+n) = cp_(n)
153  tracer_r(qa+n) = r_(n)
154  tracer_engi0(qa+n) = engi0_(n)
155  tracer_advc(qa+n) = advc_(n)
156 
157  if ( mass_(n) ) then
158  tracer_mass(qa+n) = 1.0_rp
159  else
160  tracer_mass(qa+n) = 0.0_rp
161  end if
162  end do
163 
164  qs = qa + 1
165  qa = qa + nq
166 
167  return
168  end subroutine tracer_regist
169 
170  !-----------------------------------------------------------------------------
172  subroutine tracer_inq_id( &
173  NAME, &
174  ID )
175  implicit none
176  character(len=*), intent(in) :: name
177  integer, intent(out) :: id
178  integer :: iq
179 
180  id = -1
181  do iq = 1, qa
182  if ( name == tracer_name(iq) ) then
183  id = iq
184  exit
185  end if
186  end do
187 
188  return
189  end subroutine tracer_inq_id
190 
191 end module scale_tracer
scale_prc::prc_abort
subroutine, public prc_abort
Abort Process.
Definition: scale_prc.F90:342
scale_tracer::qa
integer, public qa
Definition: scale_tracer.F90:34
scale_tracer::tracer_desc
character(len=h_mid), dimension(qa_max), public tracer_desc
Definition: scale_tracer.F90:39
scale_tracer::tracer_unit
character(len=h_short), dimension(qa_max), public tracer_unit
Definition: scale_tracer.F90:40
scale_tracer::tracer_mass
real(rp), dimension(qa_max), public tracer_mass
Definition: scale_tracer.F90:46
scale_tracer::tracer_inq_id
subroutine, public tracer_inq_id(NAME, ID)
Inquire tracer ID.
Definition: scale_tracer.F90:175
scale_precision
module PRECISION
Definition: scale_precision.F90:14
scale_tracer::tracer_advc
logical, dimension(qa_max), public tracer_advc
Definition: scale_tracer.F90:45
scale_tracer::mass
real(rp), public mass
Definition: scale_tracer.F90:46
scale_tracer::tracer_engi0
real(rp), dimension(qa_max), public tracer_engi0
Definition: scale_tracer.F90:44
scale_tracer::unit
character(len=h_short), public unit
Definition: scale_tracer.F90:40
scale_prc
module PROCESS
Definition: scale_prc.F90:11
scale_precision::rp
integer, parameter, public rp
Definition: scale_precision.F90:41
scale_io
module STDIO
Definition: scale_io.F90:10
scale_tracer::tracer_cv
real(rp), dimension(qa_max), public tracer_cv
Definition: scale_tracer.F90:41
scale_tracer::tracer_name
character(len=h_short), dimension(qa_max), public tracer_name
Definition: scale_tracer.F90:38
scale_prof
module profiler
Definition: scale_prof.F90:11
scale_tracer::tracer_regist
subroutine, public tracer_regist(QS, NQ, NAME, DESC, UNIT, CV, CP, R, ENGI0, ADVC, MASS)
Regist tracer.
Definition: scale_tracer.F90:65
scale_tracer
module TRACER
Definition: scale_tracer.F90:12
scale_tracer::tracer_cp
real(rp), dimension(qa_max), public tracer_cp
Definition: scale_tracer.F90:42
scale_tracer::tracer_r
real(rp), dimension(qa_max), public tracer_r
Definition: scale_tracer.F90:43
scale_tracer::name
character(len=h_short), public name
Definition: scale_tracer.F90:38