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