1 !***********************************************************************
2 !* GNU Lesser General Public License
4 !* This file is part of the GFDL Flexible Modeling System (FMS).
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.
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
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
23 !> @addtogroup column_diagnostics_mod
25 module column_diagnostics_mod
27 use 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
31 use time_manager_mod, only: time_manager_init, month_name, &
33 use constants_mod, only: constants_init, PI, RADIAN
34 use mpp_mod, only: input_nml_file
35 use platform_mod, only: r4_kind, r8_kind
36 !-------------------------------------------------------------------
41 !---------------------------------------------------------------------
42 ! module to locate and mark desired diagnostic columns
45 !--------------------------------------------------------------------
50 !---------------------------------------------------------------------
51 !----------- ****** VERSION NUMBER ******* ---------------------------
54 ! Include variable "version" to be written to log file.
55 #include<file_version.h>
59 !---------------------------------------------------------------------
60 !------- interfaces --------
62 public column_diagnostics_init, &
63 initialize_diagnostic_columns, &
64 column_diagnostics_header, &
65 close_column_diagnostics_units
68 interface initialize_diagnostic_columns
69 module procedure initialize_diagnostic_columns_r4
70 module procedure initialize_diagnostic_columns_r8
71 end interface initialize_diagnostic_columns
73 interface column_diagnostics_header
74 module procedure column_diagnostics_header_r4
75 module procedure column_diagnostics_header_r8
76 end interface column_diagnostics_header
80 !--------------------------------------------------------------------
83 real(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
88 real(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
94 namelist / column_diagnostics_nml / &
98 !--------------------------------------------------------------------
99 !-------- public data -----
102 !--------------------------------------------------------------------
103 !------ private data ------
106 logical :: module_is_initialized = .false.
108 !-------------------------------------------------------------------
109 !-------------------------------------------------------------------
117 !####################################################################
119 !> @brief Initialization routine for column_diagnostics_mod.
121 !> Reads namelist and writes to log.
122 subroutine column_diagnostics_init
124 !--------------------------------------------------------------------
125 ! column_diagnostics_init is the constructor for
126 ! column_diagnostics_mod.
127 !--------------------------------------------------------------------
129 !--------------------------------------------------------------------
132 integer :: iunit !< unit number for nml file
133 integer :: ierr !< error return flag
134 integer :: io !< error return code
136 !--------------------------------------------------------------------
139 ! unit unit number for nml file
140 ! ierr error return flag
141 ! io error return code
143 !---------------------------------------------------------------------
145 !--------------------------------------------------------------------
146 ! if routine has already been executed, return.
147 !--------------------------------------------------------------------
148 if (module_is_initialized) return
150 !---------------------------------------------------------------------
151 ! verify that all modules used by this module have been initialized.
152 !----------------------------------------------------------------------
154 call time_manager_init
157 !---------------------------------------------------------------------
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
168 write (iunit, nml=column_diagnostics_nml)
170 !--------------------------------------------------------------------
171 module_is_initialized = .true.
174 end subroutine column_diagnostics_init
177 !######################################################################
178 !> @brief close_column_diagnostics_units closes any open column_diagnostics
179 !! files associated with the calling module.
180 subroutine close_column_diagnostics_units (diag_units)
182 !---------------------------------------------------------------------
183 ! close_column_diagnostics_units closes any open column_diagnostics
184 ! files associated with the calling module.
185 !----------------------------------------------------------------------
187 !----------------------------------------------------------------------
188 integer, dimension(:), intent(in) :: diag_units !< array of column diagnostic unit numbers
189 !----------------------------------------------------------------------
191 !--------------------------------------------------------------------
192 ! intent(in) variable:
194 ! diag_units array of column diagnostic unit numbers
196 !--------------------------------------------------------------------
198 !--------------------------------------------------------------------
201 integer :: nn !< do loop index
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)
213 !---------------------------------------------------------------------
216 end subroutine close_column_diagnostics_units
219 !#####################################################################
221 #include "column_diagnostics_r4.fh"
222 #include "column_diagnostics_r8.fh"
225 end module column_diagnostics_mod
227 ! close documentation grouping