!*********************************************************************** !* GNU Lesser General Public License !* !* This file is part of the GFDL Flexible Modeling System (FMS). !* !* FMS is free software: you can redistribute it and/or modify it under !* the terms of the GNU Lesser General Public License as published by !* the Free Software Foundation, either version 3 of the License, or (at !* your option) any later version. !* !* FMS is distributed in the hope that it will be useful, but WITHOUT !* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or !* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License !* for more details. !* !* You should have received a copy of the GNU Lesser General Public !* License along with FMS. If not, see . !*********************************************************************** !> \file !! \brief Contains the \ref diag_integral_mod module module diag_integral_mod #include !############################################################################### !> \defgroup diag_integral_mod diag_integral_mod !! !! \author Fei Liu !! !! \brief This module computes and outputs global and / or hemispheric physics !! integrals. !! !! Modules Included: !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !!
Module Name Included Values
time_manager_mod time_type, get_time, set_time, time_manager_init, operator(+), !! operator(-), operator(==), operator(>=), operator(/=)
mpp_mod input_nml_file <\td> !!
fms_mod open_file, file_exist, error_mesg, open_namelist_file, !! check_nml_error, fms_init, mpp_pe, mpp_root_pe, FATAL, !! write_version_number, stdlog, close_file
constants_mod radius, constants_init
mpp_mod mpp_sum, mpp_init
!! !! Public Interfaces: !! !! - sum_diag_integral_field !! !! Public Subroutines: !! !! - diag_integral_init !! - diag_integral_field_init !! - diag_integral_output !! - diag_integral_end !! - sum_field_2d !! - sum_field_3d !! - sum_field_wght_3d !! - sum_field_2d_hemi !! !! Private Functions: !! !! - set_axis_time !! - get_field_index !! - get_axis_time !! - diag_integral_alarm !! - vert_diag_integral !! !! Private Subroutines: !! !! - write_field_averages !! - format_text_init !! - format_data_init !! use time_manager_mod, only: time_type, get_time, set_time, & time_manager_init, & operator(+), operator(-), & operator(==), operator(>=), & operator(/=) use mpp_mod, only: input_nml_file use fms_mod, only: open_file, file_exist, error_mesg, & open_namelist_file, check_nml_error, & fms_init, & mpp_pe, mpp_root_pe,& FATAL, write_version_number, & stdlog, close_file use constants_mod, only: radius, constants_init use mpp_mod, only: mpp_sum, mpp_init use ensemble_manager_mod, only : get_ensemble_id, get_ensemble_size !------------------------------------------------------------------------------- implicit none private !------------------------------------------------------------------------------- !----------- version number for this module ------------------- character(len=128) :: version = '$Id$' character(len=128) :: tagname = '$Name$' !------------------------------------------------------------------------------- !------ interfaces ------ public & diag_integral_init, diag_integral_field_init, & sum_diag_integral_field, diag_integral_output, & diag_integral_end !############################################################################### !> \defgroup sum_diag_integral_field sum_diag_integral_field !! \ingroup diag_integral_mod !! !! This interface can be called in any one of three ways: !! !! \code{.f90} !! call sum_diag_integral_field (name, data, is, js) !! call sum_diag_integral_field (name, data, wt, is, js) !! call sum_diag_integral_field (name, data, is, ie, js, je) !! \endcode !! !! in the first option above, `data` may be either !! \code{.f90} !! real, intent(in) :: data(:,:) ![ sum_field_2d ] !! real, intent(in) :: data(:,:,:) ![ sum_field_3d ] !! \endcode !! !! Parameters: !! !! \code{.f90} !! character(len=*), intent(in) :: name !! real, intent(in) :: wt(:,:,:) !! integer, optional, intent(in) :: is, ie, js, je !! \endcode !! !! \param [in] name associated with integral !! \param [in] field of integrands to be summed over !! \param [in] vertical weighting factor to be applied to integrands !! when summing !! \param [in] starting/ending i,j indices over which summation !! is to occur !! interface sum_diag_integral_field module procedure sum_field_2d, & sum_field_2d_hemi, & sum_field_3d, & sum_field_wght_3d end interface private & ! from diag_integral_init: set_axis_time, & ! from diag_integral_field_init and sum_diag_integral_field: get_field_index, & ! from diag_integral_output and diag_integral_end: write_field_averages, & ! from write_field_averages: format_text_init, format_data_init, & get_axis_time, & ! from diag_integral_output: diag_integral_alarm, & ! from sum_diag_integral_field: vert_diag_integral !------------------------------------------------------------------------------- !------ namelist ------- integer, parameter :: & mxch = 64 ! maximum number of characters in ! the optional output file name real :: & output_interval = -1.0 ! time interval at which integrals ! are to be output character(len=8) :: & time_units = 'hours' ! time units associated with ! output_interval character(len=mxch) :: & file_name = ' ' ! optional integrals output file name logical :: & print_header = .true. ! print a header for the integrals ! file ? integer :: & fields_per_print_line = 4 ! number of fields to write per line ! of output namelist / diag_integral_nml / & output_interval, time_units, & file_name, print_header, & fields_per_print_line !------------------------------------------------------------------------------- !------- public data ------ !------------------------------------------------------------------------------- !------- private data ------ !------------------------------------------------------------------------------- ! variables associated with the determination of when integrals ! are to be written. ! Next_alarm_time next time at which integrals are to be ! written ! Alarm_interval time interval between writing integrals ! Zero_time time_type variable set to (0,0); used as ! flag to indicate integrals are not being ! output ! Time_init_save initial time associated with experiment; ! used as a base for defining time !------------------------------------------------------------------------------- type (time_type) :: Next_alarm_time, Alarm_interval, Zero_time type (time_type) :: Time_init_save !------------------------------------------------------------------------------- ! variables used in determining weights associated with each ! contribution to the integrand. ! area area of each grid box ! idim x dimension of grid on local processor ! jdim y dimension of grid on local processor ! field_size number of columns on global domain ! sum_area surface area of globe !------------------------------------------------------------------------------- real, allocatable, dimension(:,:) :: area integer :: idim, jdim, field_size real :: sum_area !------------------------------------------------------------------------------- ! variables used to define the integral fields: ! max_len_name maximum length of name associated with integral ! max_num_field maximum number of integrals allowed ! num_field number of integrals that have been activated ! field_name(i) name associated with integral i ! field_format(i) output format for integral i ! field_sum(i) integrand for integral i ! field_count(i) number of values in integrand i !------------------------------------------------------------------------------- integer, parameter :: max_len_name = 12 integer, parameter :: max_num_field = 32 integer :: num_field = 0 character(len=max_len_name) :: field_name (max_num_field) character(len=16) :: field_format (max_num_field) real :: field_sum (max_num_field) integer :: field_count (max_num_field) !------------------------------------------------------------------------------- ! variables defining output formats. ! format_text format statement for header ! format_data format statement for data output ! do_format_data a data format needs to be generated ? ! nd number of characters in data format statement ! nt number of characters in text format statement !------------------------------------------------------------------------------- character(len=160) :: format_text, format_data logical :: do_format_data = .true. integer :: nd, nt !------------------------------------------------------------------------------- ! miscellaneous variables. !------------------------------------------------------------------------------- integer :: diag_unit = 0 ! unit number for output file logical :: module_is_initialized = .false. ! module is initialized ? contains !############################################################################### ! ! PUBLIC SUBROUTINES ! !############################################################################### !############################################################################### !> \fn diag_integral_init !! !! \brief diag_integral_init is the constructor for diag_integral_mod. !! !! Template: !! !! \code{.f90} !! call diag_integral_init (Time_init, Time, blon, blat) !! \endcode !! !! Parameters: !! !! \code{.f90} !! type (time_type), intent(in), optional :: Time_init, Time !! real,dimension(:,:), intent(in), optional :: blon, blat, area_in !! \endcode !! !! \param [in] Initial time to start the integral !! \param [in]