FMS 2025.01-dev
Flexible Modeling System
Loading...
Searching...
No Matches
column_diagnostics.F90
1!***********************************************************************
2!* GNU Lesser General Public License
3!*
4!* This file is part of the GFDL Flexible Modeling System (FMS).
5!*
6!* FMS is free software: you can redistribute it and/or modify it under
7!* the terms of the GNU Lesser General Public License as published by
8!* the Free Software Foundation, either version 3 of the License, or (at
9!* your option) any later version.
10!*
11!* FMS is distributed in the hope that it will be useful, but WITHOUT
12!* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13!* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14!* for more details.
15!*
16!* You should have received a copy of the GNU Lesser General Public
17!* License along with FMS. If not, see <http://www.gnu.org/licenses/>.
18!***********************************************************************
19!> @defgroup column_diagnostics_mod column_diagnostics_mod
20!> @ingroup column_diagnostics
21!! @brief Module to locate and mark desired diagnostic columns
22
23!> @addtogroup column_diagnostics_mod
24!> @{
25module column_diagnostics_mod
26
27use fms_mod, only: fms_init, mpp_pe, mpp_root_pe, &
28 mpp_npes, check_nml_error, &
29 error_mesg, fatal, note, warning, &
30 stdlog, write_version_number
31use time_manager_mod, only: time_manager_init, month_name, &
33use constants_mod, only: constants_init, pi, radian
34use mpp_mod, only: input_nml_file
35use platform_mod, only: r4_kind, r8_kind, fms_file_len
36!-------------------------------------------------------------------
37
38implicit none
39private
40
41!---------------------------------------------------------------------
42! module to locate and mark desired diagnostic columns
43!
44!
45!--------------------------------------------------------------------
46
47
48
49
50!---------------------------------------------------------------------
51!----------- ****** VERSION NUMBER ******* ---------------------------
52
53
54! Include variable "version" to be written to log file.
55#include<file_version.h>
56
57
58
59!---------------------------------------------------------------------
60!------- interfaces --------
61
66
67
69 module procedure initialize_diagnostic_columns_r4
70 module procedure initialize_diagnostic_columns_r8
72
74 module procedure column_diagnostics_header_r4
75 module procedure column_diagnostics_header_r8
76end interface column_diagnostics_header
77
78!private
79
80!--------------------------------------------------------------------
81!---- namelist -----
82
83real(kind=r8_kind) :: crit_xdistance = 4.0_r8_kind !< model grid points must be within crit_xdistance in
84 !! longitude of the requested diagnostics point
85 !! coordinates in order to be flagged as the desired
86 !! point
87 !! [ degrees ]
88real(kind=r8_kind) :: crit_ydistance = 4.0_r8_kind !< model grid points must be within crit_ydistance in
89 !! latitude of the requested diagnostics point
90 !! coordinates in order to be flagged as the desired
91 !! point
92 !! [ degrees ]
93
94namelist / column_diagnostics_nml / &
97
98!--------------------------------------------------------------------
99!-------- public data -----
100
101
102!--------------------------------------------------------------------
103!------ private data ------
104
105
106logical :: module_is_initialized = .false.
107
108!-------------------------------------------------------------------
109!-------------------------------------------------------------------
110
111
112
113 contains
114
115
116
117!####################################################################
118
119!> @brief Initialization routine for column_diagnostics_mod.
120!!
121!> Reads namelist and writes to log.
123
124!--------------------------------------------------------------------
125! column_diagnostics_init is the constructor for
126! column_diagnostics_mod.
127!--------------------------------------------------------------------
128
129!--------------------------------------------------------------------
130! local variables:
131!
132 integer :: iunit !< unit number for nml file
133 integer :: ierr !< error return flag
134 integer :: io !< error return code
135
136!--------------------------------------------------------------------
137! local variables:
138!
139! unit unit number for nml file
140! ierr error return flag
141! io error return code
142!
143!---------------------------------------------------------------------
144
145!--------------------------------------------------------------------
146! if routine has already been executed, return.
147!--------------------------------------------------------------------
148 if (module_is_initialized) return
149
150!---------------------------------------------------------------------
151! verify that all modules used by this module have been initialized.
152!----------------------------------------------------------------------
153 call fms_init
155 call constants_init
156
157!---------------------------------------------------------------------
158! read namelist.
159!---------------------------------------------------------------------
160 read (input_nml_file, column_diagnostics_nml, iostat=io)
161 ierr = check_nml_error(io, 'column_diagnostics_nml')
162!---------------------------------------------------------------------
163! write version number and namelist to logfile.
164!---------------------------------------------------------------------
165 call write_version_number("COLUMN_DIAGNOSTICS_MOD", version)
166 if (mpp_pe() == mpp_root_pe()) then
167 iunit = stdlog()
168 write (iunit, nml=column_diagnostics_nml)
169 endif
170!--------------------------------------------------------------------
171 module_is_initialized = .true.
172
173
174end subroutine column_diagnostics_init
175
176
177!######################################################################
178!> @brief close_column_diagnostics_units closes any open column_diagnostics
179!! files associated with the calling module.
180subroutine close_column_diagnostics_units (diag_units)
181
182!---------------------------------------------------------------------
183! close_column_diagnostics_units closes any open column_diagnostics
184! files associated with the calling module.
185!----------------------------------------------------------------------
186
187!----------------------------------------------------------------------
188integer, dimension(:), intent(in) :: diag_units !< array of column diagnostic unit numbers
189!----------------------------------------------------------------------
190
191!--------------------------------------------------------------------
192! intent(in) variable:
193!
194! diag_units array of column diagnostic unit numbers
195!
196!--------------------------------------------------------------------
197
198!--------------------------------------------------------------------
199! local variable
200
201 integer :: nn !< do loop index
202 integer :: io
203!--------------------------------------------------------------------
204! close the unit associated with each diagnostic column.
205!--------------------------------------------------------------------
206 do nn=1, size(diag_units(:))
207 if (diag_units(nn) /= -1) then
208 close(diag_units(nn), iostat=io )
209 if(io/=0) call error_mesg('column_diagnostics_mod', 'Error in closing file ', fatal)
210 endif
211 end do
212
213!---------------------------------------------------------------------
214
215
217
218
219!#####################################################################
220
221#include "column_diagnostics_r4.fh"
222#include "column_diagnostics_r8.fh"
223
224
225 end module column_diagnostics_mod
226!@}
227! close documentation grouping
real(kind=r8_kind) crit_ydistance
model grid points must be within crit_ydistance in latitude of the requested diagnostics point coordi...
subroutine, public close_column_diagnostics_units(diag_units)
close_column_diagnostics_units closes any open column_diagnostics files associated with the calling m...
real(kind=r8_kind) crit_xdistance
model grid points must be within crit_xdistance in longitude of the requested diagnostics point coord...
subroutine, public column_diagnostics_init
Initialization routine for column_diagnostics_mod.
character(len=9) function, public month_name(n)
Returns a character string containing the name of the month corresponding to month number n.
subroutine, public get_date(time, year, month, day, hour, minute, second, tick, err_msg)
Gets the date for different calendar types. Given a time_interval, returns the corresponding date und...
subroutine, public time_manager_init()
Initialization routine. Writes the version information to the log file.
Type to represent amounts of time. Implemented as seconds and days to allow for larger intervals.