FV3 Bundle
station_data_mod Module Reference

This module is used for outputing model results in a list of stations (not gridded arrays). The user needs to supply a list of stations with lat, lon values of each station. Data at a single point (I,J) that is closest to each station will be written to a file. No interpolation is made when a station is between two or more grid points.
In the output file, a 3D field will have a format of array(n1,n2) and a 2D field is array(n1) where n1 is number of stations and n2 is number of vertical levels or depths. More...

Data Types

type  file_type
 
type  global_field_type
 
type  group_field_type
 
interface  register_station_field
 
interface  send_station_data
 
type  station_type
 

Functions/Subroutines

subroutine, public station_data_init ()
 Read in lat and lon of each station
Create station_id based on lat, lon
Read station_data_table, initialize output_fields and output files. More...
 
subroutine check_duplicate_output_fields ()
 check_duplicate_output_fields takes the data pairs (output_name and output_file) and (module_name and output_name) and ensures each pair is unique. More...
 
integer function get_station_id (lat, lon)
 get_station_id is passed the station's distinct lat and lon to determine what the station's id is. More...
 
subroutine init_file (filename, output_freq, output_units, time_units)
 init_file initializes files to write station data to. Data is formatted as number of units of measurement at X output frequency over amount of time dt More...
 
subroutine init_output_field (module_name, field_name, file_name, time_method, pack)
 init_output_field initializes output_field attributes More...
 
integer function find_file (name)
 find_file finds the index of a requested file More...
 
integer function register_station_field2d (module_name, fieldname, glo_lat, glo_lon, init_time, domain, longname, units)
 register_station_field2d registers a new station field with user input.
register_station_field2d is overloaded by register_station_field3d as a part of the register_station_field interface. More...
 
integer function register_station_field3d (module_name, fieldname, glo_lat, glo_lon, levels, init_time, domain, longname, units)
 register_station_field3d registers a new station field with user input.
register_station_field3d is overloaded by register_station_field2d as a part of the register_station_field interface. More...
 
integer function find_output_field (module_name, field_name)
 find_output_field returns the index of the reuqested field within the output_fields array. More...
 
subroutine opening_file (file)
 opening_file opens a file and writes axis meta_data for all files (only on ROOT PE, do nothing on other PEs) More...
 
subroutine send_station_data_2d (field_id, data, time)
 send_station_data_2d sends data to the root PE, which then sends data to staton_data_out to be sent to files.
send_station_data_2d is overloaded by send_station_data_3d as a part of the send_station_data interface. More...
 
subroutine send_station_data_3d (field_id, data, time)
 send_station_data_3d sends data to the root PE, which then sends data to staton_data_out to be sent to files.
send_station_data_3d is overloaded by send_station_data_2d as a part of the send_station_data interface. More...
 
subroutine station_data_out (file, field, data, time, final_call_in)
 station_data_out is responsible for sending station data to files. More...
 
subroutine, public station_data_end (time)
 Must be called after the last time step to write the buffer content. More...
 

Variables

integer, parameter max_fields_per_file = 150
 
integer, parameter max_files = 31
 
integer num_files = 0
 
integer num_stations = 0
 
integer max_stations = 20
 
integer max_output_fields = 100
 
integer num_output_fields = 0
 
real empty = 0.0
 
real missing = 1.E20
 
logical module_is_initialized = .false.
 
logical need_write_axis = .true.
 
integer base_year
 
integer base_month
 
integer base_day
 
integer base_hour
 
integer base_minute
 
integer base_second
 
type(time_typebase_time
 
character(len=10), dimension(6) time_unit_list = (/'seconds ', 'minutes ', 'hours ', 'days ', 'months ', 'years '/)
 
integer, parameter every_time = 0
 
integer, parameter end_of_run = -1
 
character(len=256) global_descriptor
 
character(len=7) avg_name = 'average'
 
integer total_pe
 
integer lat_axis
 
integer lon_axis
 
integer, dimension(:), allocatable pelist
 
character(len=32) pelist_name
 
type(global_field_type), save global_field
 
type(file_type), dimension(max_files), save files
 
type(group_field_type), dimension(:), allocatable, save output_fields
 
type(station_type), dimension(:), allocatable stations
 
type(diag_fieldtype), save diag_field
 

Detailed Description

This module is used for outputing model results in a list of stations (not gridded arrays). The user needs to supply a list of stations with lat, lon values of each station. Data at a single point (I,J) that is closest to each station will be written to a file. No interpolation is made when a station is between two or more grid points.
In the output file, a 3D field will have a format of array(n1,n2) and a 2D field is array(n1) where n1 is number of stations and n2 is number of vertical levels or depths.

Author
Giang Nong Giang.nosp@m..Non.nosp@m.g@gfd.nosp@m.l.no.nosp@m.aa.go.nosp@m.v

Here are some basic steps of how to use station_data_mod:

  1. Call data_station_init
    User needs to supply 2 tables: list_stations and station_data_table as follows:
    Example of list_stations:       Example of station_data_table:
    station_id   lat   lon
    station_1 20.4 100.8
         
         
         
         
         
         
         
         
         
    General descriptor:
        Am2p14 station data
    Start time (should be the same as model's initial time):
        19800101
    File information:
    filename   output_frequency   frequency_unit   time_axis_unit
    "ocean_day" 1 "days" "hours"
    Field information:
    module   field_name   filename   time_method   pack
    Ice_mod temperature ocean_day .true. 2
    Ice_mod pressure ocean_day .false. 2
  2. Call register_station_field to register each field that needs to be written to a file, the call register_station_field returns a field_id that will be used later in send_station_data
  3. Call send_station_data will send data at each station in the list to a file
  4. Finally, call station_data_end after the last time step.

Modules Included:

Module Name Functions Included
axis_utils_mod nearest_index
mpp_io_mod mpp_open, MPP_RDONLY, MPP_ASCII, mpp_close, MPP_OVERRWR, MPP_NETCDF, mpp_write_meta, MPP_SINGLE, mpp_write, fieldtype, mpp_flush
fms_mod error_mesg, FATAL, WARNING, stdlog, write_version_number, mpp_pe, lowercase, stdout, close_file, open_namelist_file, check_nml_error
mpp_mod mpp_npes, mpp_sync, mpp_root_pe, mpp_send, mpp_recv, mpp_max, mpp_get_current_pelist, input_nml_file, COMM_TAG_1, COMM_TAG_2, COMM_TAG_3, COMM_TAG_4
mpp_domains_mod domain2d, mpp_get_compute_domain
diag_axis_mod diag_axis_init
diag_output_mod write_axis_meta_data, write_field_meta_data, diag_fieldtype, done_meta_data
diag_manager_mod get_date_dif, DIAG_SECONDS, DIAG_MINUTES, DIAG_HOURS, DIAG_DAYS, DIAG_MONTHS, DIAG_YEARS
diag_util_mod diag_time_inc
time_manager_mod operator(>), operator(>=), time_type, get_calendar_type, NO_CALENDAR, set_time set_date, increment_date, increment_time

Function/Subroutine Documentation

◆ check_duplicate_output_fields()

subroutine station_data_mod::check_duplicate_output_fields ( )
private

check_duplicate_output_fields takes the data pairs (output_name and output_file) and (module_name and output_name) and ensures each pair is unique.

Exceptions
FATAL,ERROR1 in station_data_table: module/field <module/name> duplicated
FATAL,ERROR2 in station_data_table: module/field <module/name> duplicated

Definition at line 547 of file station_data.F90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_file()

integer function station_data_mod::find_file ( character(len=*), intent(in)  name)
private

find_file finds the index of a requested file

Parameters
[in]<name>Name of the file

Definition at line 714 of file station_data.F90.

Here is the caller graph for this function:

◆ find_output_field()

integer function station_data_mod::find_output_field ( character(len=*), intent(in)  module_name,
character(len=*), intent(in)  field_name 
)
private

find_output_field returns the index of the reuqested field within the output_fields array.

Parameters
[in]module_nameModule name of the requested station
[in]field_nameField name of the requested station

Definition at line 893 of file station_data.F90.

Here is the caller graph for this function:

◆ get_station_id()

integer function station_data_mod::get_station_id ( real, intent(in)  lat,
real, intent(in)  lon 
)
private

get_station_id is passed the station's distinct lat and lon to determine what the station's id is.

Returns
Unique ID of station
Parameters
[in]latLatitude of station
[in]lonLongitude of station

Definition at line 574 of file station_data.F90.

Here is the caller graph for this function:

◆ init_file()

subroutine station_data_mod::init_file ( character(len=*), intent(in)  filename,
integer, intent(in)  output_freq,
integer, intent(in)  output_units,
integer, intent(in)  time_units 
)
private

init_file initializes files to write station data to. Data is formatted as number of units of measurement at X output frequency over amount of time dt

Exceptions
FATAL,init_file or max_files exceeded, increase max_files
Parameters
[in]filenameFilename to use when initializing file
[in]output_freqOutput frequency of substance
[in]output_unitsNumber of units of substance being recorded
[in]time_unitsLength of time being recorded

register axis_id and time boundaries id

Definition at line 599 of file station_data.F90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_output_field()

subroutine station_data_mod::init_output_field ( character(len=*), intent(in)  module_name,
character(len=*), intent(in)  field_name,
character(len=*), intent(in)  file_name,
character(len=*), intent(in)  time_method,
integer, intent(in)  pack 
)
private

init_output_field initializes output_field attributes

Exceptions
FATAL,max_output_fields exceeded, increase it via nml
FATAL,file <filename.ext> is NOT found in station_data_table
FATAL,max_fields_per_file exceeded
FATAL,time_method MAX is not supported
FATAL,time_method MIN is not supported
FATAL,error in time_method of field field_name

Get a number for this output field

Insert this field into list of fields of this file

Definition at line 636 of file station_data.F90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ opening_file()

subroutine station_data_mod::opening_file ( integer, intent(in)  file)
private

opening_file opens a file and writes axis meta_data for all files (only on ROOT PE, do nothing on other PEs)

Exceptions
FATAL,<output_name> has axis_id = -1
Parameters
[in]fileFile to be opened

Definition at line 915 of file station_data.F90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ register_station_field2d()

integer function station_data_mod::register_station_field2d ( character(len=*), intent(in)  module_name,
character(len=*), intent(in)  fieldname,
real, dimension(:), intent(in)  glo_lat,
real, dimension(:), intent(in)  glo_lon,
type(time_type), intent(in)  init_time,
type(domain2d), intent(in)  domain,
character(len=*), intent(in), optional  longname,
character(len=*), intent(in), optional  units 
)
private

register_station_field2d registers a new station field with user input.
register_station_field2d is overloaded by register_station_field3d as a part of the register_station_field interface.

Parameters
[in]module_nameModule name of the station being registered
[in]fieldnameField name of the tation being registered
[in]glo_latGlobal latitude location of the station
[in]glo_lonGlobal longitude location of the station
[in]domainOptional 2d domain representation
[in]init_timeInitial time of the station
[in]longnameOptional longname to identify station
[in]unitsOptional units for station measurement data

Definition at line 733 of file station_data.F90.

Here is the call graph for this function:

◆ register_station_field3d()

integer function station_data_mod::register_station_field3d ( character(len=*), intent(in)  module_name,
character(len=*), intent(in)  fieldname,
real, dimension(:), intent(in)  glo_lat,
real, dimension(:), intent(in)  glo_lon,
real, dimension(:), intent(in)  levels,
type(time_type), intent(in)  init_time,
type(domain2d), intent(in)  domain,
character(len=*), intent(in), optional  longname,
character(len=*), intent(in), optional  units 
)
private

register_station_field3d registers a new station field with user input.
register_station_field3d is overloaded by register_station_field2d as a part of the register_station_field interface.

Exceptions
FATAL,outside global latitude values
FATAL,outside global longitude values
FATAL,Error in global index of station
WARNING,<module_name>/<field_name> NOT found in station_data table
FATAL,Error in determining local_num_station
Returns
write field meta data on ROOT PE only allocate buffer
Parameters
[in]module_nameModule name of the station being registered
[in]fieldnameField name of the tation being registered
[in]glo_latGlobal latitude location of the station (in X direction)
[in]glo_lonGlobal longitude location of the station (in Y direction)
[in]levelsGlobal elevation location of the station (in Z direction)
[in]domainOptional 2d domain representation
[in]init_timeInitial time of the station
[in]longnameOptional longname to identify station
[in]unitsOptional units for station measurement data

determine global index of this field in all stations

determine local index of this field in all stations , local index starts from 1

get the position of this field in the array output_fields

fill out list of available stations in this PE
deal with axes

Definition at line 761 of file station_data.F90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_station_data_2d()

subroutine station_data_mod::send_station_data_2d ( integer, intent(in)  field_id,
real, dimension(:,:), intent(in)  data,
type(time_type), intent(in)  time 
)
private

send_station_data_2d sends data to the root PE, which then sends data to staton_data_out to be sent to files.
send_station_data_2d is overloaded by send_station_data_3d as a part of the send_station_data interface.

Parameters
[in]field_idField id of the station data being recorded
[in]dataData of the station being recorded
[in]timeTime of the station being recorded

Definition at line 1000 of file station_data.F90.

Here is the call graph for this function:

◆ send_station_data_3d()

subroutine station_data_mod::send_station_data_3d ( integer, intent(in)  field_id,
real, dimension(:,:,:), intent(in)  data,
type(time_type), intent(in)  time 
)
private

send_station_data_3d sends data to the root PE, which then sends data to staton_data_out to be sent to files.
send_station_data_3d is overloaded by send_station_data_2d as a part of the send_station_data interface.

Exceptions
FATAL,Station data NOT initialized
FATAL,counter=0 for averaged field
FATAL,Global field contains MISSING field
FATAL,Local index out of range for field
Parameters
[in]field_idField id of the station data being recorded
[in]dataData of the station being recorded
[in]timeTime of the station being recorded

compare time with next_output

get max_counter if the field is averaged

receive local data from all PEs



send global_buffer content to file

check if global_field contains any missing values

clear buffer, increment next_output time and reset counter on ALL PEs

accumulate buffer only

Definition at line 1020 of file station_data.F90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ station_data_end()

subroutine, public station_data_mod::station_data_end ( type(time_type), intent(in)  time)

Must be called after the last time step to write the buffer content.

Exceptions
FATAL,counter=0 for averaged field
FATAL,Global field contains MISSING field
Parameters
[in]timemodel's time

ALL PEs, including root PE, must send data to root PE




get max_counter if the field is averaged

only root PE receives local data from all PEs


send global_buffer content to file

check if global_field contains any missing values

deallocate field buffer

Definition at line 1171 of file station_data.F90.

Here is the call graph for this function:

◆ station_data_init()

subroutine, public station_data_mod::station_data_init ( )

Read in lat and lon of each station
Create station_id based on lat, lon
Read station_data_table, initialize output_fields and output files.

read namelist

read list of stations

read station_data table

Read in the global file labeling string

Read in the base date

If no calendar, ignore year and month

Definition at line 395 of file station_data.F90.

Here is the call graph for this function:

◆ station_data_out()

subroutine station_data_mod::station_data_out ( integer, intent(in)  file,
integer, intent(in)  field,
real, dimension(:, :), intent(inout)  data,
type(time_type), intent(in)  time,
logical, intent(in), optional  final_call_in 
)
private

station_data_out is responsible for sending station data to files.

Parameters
[in]fileInteger identifying the file to be output
[in]fieldInteger identifying the filed to be output
[in,out]dataData to be output
[in]timeTime of output
[in]final_call_inOptional logical expression

Definition at line 1115 of file station_data.F90.

Here is the caller graph for this function:

Variable Documentation

◆ avg_name

character (len = 7) station_data_mod::avg_name = 'average'
private

Definition at line 290 of file station_data.F90.

◆ base_day

integer station_data_mod::base_day
private

Definition at line 282 of file station_data.F90.

◆ base_hour

integer station_data_mod::base_hour
private

Definition at line 282 of file station_data.F90.

◆ base_minute

integer station_data_mod::base_minute
private

Definition at line 282 of file station_data.F90.

◆ base_month

integer station_data_mod::base_month
private

Definition at line 282 of file station_data.F90.

◆ base_second

integer station_data_mod::base_second
private

Definition at line 282 of file station_data.F90.

◆ base_time

type (time_type) station_data_mod::base_time
private

Definition at line 283 of file station_data.F90.

◆ base_year

integer station_data_mod::base_year
private

Definition at line 282 of file station_data.F90.

◆ diag_field

type(diag_fieldtype), save station_data_mod::diag_field
private

Definition at line 340 of file station_data.F90.

◆ empty

real station_data_mod::empty = 0.0
private

Definition at line 278 of file station_data.F90.

◆ end_of_run

integer, parameter station_data_mod::end_of_run = -1
private

Definition at line 287 of file station_data.F90.

◆ every_time

integer, parameter station_data_mod::every_time = 0
private

Definition at line 286 of file station_data.F90.

◆ files

type (file_type), dimension(max_files), save station_data_mod::files
private

Definition at line 337 of file station_data.F90.

◆ global_descriptor

character(len=256) station_data_mod::global_descriptor
private

Definition at line 289 of file station_data.F90.

◆ global_field

type(global_field_type), save station_data_mod::global_field
private

Definition at line 336 of file station_data.F90.

◆ lat_axis

integer station_data_mod::lat_axis
private

Definition at line 292 of file station_data.F90.

◆ lon_axis

integer station_data_mod::lon_axis
private

Definition at line 292 of file station_data.F90.

◆ max_fields_per_file

integer, parameter station_data_mod::max_fields_per_file = 150
private

Definition at line 271 of file station_data.F90.

◆ max_files

integer, parameter station_data_mod::max_files = 31
private

Definition at line 272 of file station_data.F90.

◆ max_output_fields

integer station_data_mod::max_output_fields = 100
private

Definition at line 276 of file station_data.F90.

◆ max_stations

integer station_data_mod::max_stations = 20
private

Definition at line 275 of file station_data.F90.

◆ missing

real station_data_mod::missing = 1.E20
private

Definition at line 279 of file station_data.F90.

◆ module_is_initialized

logical station_data_mod::module_is_initialized = .false.
private

Definition at line 280 of file station_data.F90.

◆ need_write_axis

logical station_data_mod::need_write_axis = .true.
private

Definition at line 281 of file station_data.F90.

◆ num_files

integer station_data_mod::num_files = 0
private

Definition at line 273 of file station_data.F90.

◆ num_output_fields

integer station_data_mod::num_output_fields = 0
private

Definition at line 277 of file station_data.F90.

◆ num_stations

integer station_data_mod::num_stations = 0
private

Definition at line 274 of file station_data.F90.

◆ output_fields

type(group_field_type), dimension(:), allocatable, save station_data_mod::output_fields
private

Definition at line 338 of file station_data.F90.

◆ pelist

integer, dimension(:), allocatable station_data_mod::pelist
private

Definition at line 293 of file station_data.F90.

◆ pelist_name

character(len=32) station_data_mod::pelist_name
private

Definition at line 294 of file station_data.F90.

◆ stations

type (station_type), dimension(:), allocatable station_data_mod::stations
private

Definition at line 339 of file station_data.F90.

◆ time_unit_list

character (len=10), dimension(6) station_data_mod::time_unit_list = (/'seconds ', 'minutes ', 'hours ', 'days ', 'months ', 'years '/)
private

Definition at line 284 of file station_data.F90.

◆ total_pe

integer station_data_mod::total_pe
private

Definition at line 291 of file station_data.F90.