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