The Intermediate Complexity Atmospheric Research model (ICAR)
A computationally efficient atmospheric model for downscaling.
 All Classes Files Functions Variables
Public Member Functions | Private Member Functions | Private Attributes | List of all members
boundary_conditions Module Reference


Handles reading boundary conditions from the forcing file(s) Provides necessary interpolation on to the grid. More...

Public Member Functions

integer function, public bc_find_step (options)
 

Find the time step in the input forcing to start the model on More...

 
subroutine, public bc_init (domain, bc, options)
 

Initialize the boundary conditions (read inital conditions, etc.) More...

 
subroutine, public update_pressure (pressure, z_lo, z_hi, lowresT, hiresT)
 

Adjust the pressure field for the vertical shift between the low and high-res domains More...

 
subroutine, public bc_update (domain, bc, options)
 

Read in the next timestep of input data and apply to the dXdt grids as appropriate. More...

 

Private Member Functions

subroutine smooth_wind (wind, windowsize, ydim)
 

Smooth an array (written for wind but will work for anything) More...

 
subroutine read_var (highres, filename, varname, geolut, vlut, curstep, boundary_only, options, z_lo, z_hi, time_varying_zlut, interp_vertical)
 

Generic routine to read a forcing variable (varname) from a netcdf file (filename) at a time step (curstep) More...

 
subroutine read_2dvar (highres, filename, varname, geolut, curstep)
 

Same as read_var but for 2-dimensional data More...

 
subroutine rotate_ext_wind_field (domain, ext_winds)
 

Rotate winds from real space back to terrain following grid (approximately) More...

 
subroutine ext_winds_init (domain, bc, options)
 

Initialize the external winds information (filenames, nfiles, etc) and read the initial conditions More...

 
subroutine remove_linear_winds (domain, bc, options, filename, curstep)
 

Remove linear theory topographic winds perturbations from the low resolution wind field. More...

 
subroutine mean_boundaries (inputdata)
 

Make the forcing boundary conditions into average values More...

 
subroutine mean_winds (domain, filename, curstep, options)
 

Compute the mean wind field and make them constant everywhere... More...

 
subroutine check_shapes_3d (data1, data2)
 

Check that two model grids have the same shape More...

 
subroutine swap_y_z_dimensions (data)
 

Swap the last two dimensions of an array More...

 
subroutine load_restart_file (domain, restart_file, time_step)
 

Load restart file More...

 
subroutine init_znu (domain)
 

Calculate the ZNU and ZNW variables More...

 
subroutine update_edges (dx_dt, d1, d2)
 

Same as update_dxdt but only for the edges of the domains More...

 
subroutine update_dxdt (bc, domain)
 

Calculate changes between the current boundary conditions and the time step boundary conditions More...

 
subroutine update_dwinddt (bc, domain)
 

Calculate changes in winds between the current and future conditions More...

 
subroutine update_ext_winds (bc, options)
 

Update the external wind field More...

 

Private Attributes

character(len=255), dimension(:),
allocatable 
file_list
 
integer curfile
 
integer curstep
 
integer steps_in_file
 
integer nfiles
 
character(len=255), dimension(:),
allocatable 
ext_winds_file_list
 
integer ext_winds_curfile
 
integer ext_winds_curstep
 
integer ext_winds_steps_in_file
 
integer ext_winds_nfiles
 
integer smoothing_window =1
 

Detailed Description


Handles reading boundary conditions from the forcing file(s) Provides necessary interpolation on to the grid.

  Primary entry points 
      bc_init      - first call only
      bc_update    - all successive calls
  Contains options to use the 
      mean wind field
      mean boundary forcing
      wind field smoothing
      removal of low resolution model linear wind field
  bc_init loads the restart file as necessary.
  Both init and update compute the exner function and density fields
  for the forcing step and update the wind field with linear perturbations
  as necessary
 
Author
Ethan Gutmann (gutma.nosp@m.nn@u.nosp@m.car.e.nosp@m.du)

Member Function/Subroutine Documentation

integer function, public boundary_conditions::bc_find_step ( type(options_type), intent(in)  options)


Find the time step in the input forcing to start the model on

The model start date (start_mjd) may not be the same as the first forcing date (initial_mjd). Convert the difference between the two into forcing steps by dividing by the time delta between forcing steps (in_dt) after converting in_dt from seconds to days.

Parameters
optionsmodel options structure
Return values
stepinteger number of steps into the forcing sequence

Here is the caller graph for this function:

subroutine, public boundary_conditions::bc_init ( type(domain_type), intent(inout)  domain,
type(bc_type), intent(inout)  bc,
type(options_type), intent(in)  options 
)


Initialize the boundary conditions (read inital conditions, etc.)

This is one of the most important subroutines, and is nearly identical to bc_update This reads the first forcing time step in, calling relevant subroutines as dictated by the options specified (e.g. mean_winds, external_winds)

Parameters
domainModel Domain
bcModel forcing boundary conditions data structure
optionsModel Options structure

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine, public boundary_conditions::bc_update ( type(domain_type), intent(inout)  domain,
type(bc_type), intent(inout)  bc,
type(options_type), intent(in)  options 
)


Read in the next timestep of input data and apply to the dXdt grids as appropriate.

Nearly identical to bc_init. Primary differences are that: Restart fields are not checked for and read, and data are stored in bcnext_domain instead of domain In addition, the time_varying_z condition is handled here with an additional interpolation. Finally, current domain conditions are copied into next_domain (after computing dxdt values) for use in the linear_wind calculations (i.e. linear wind field for the next time step is calculated based on atmospheric stability conditions for the current time step).

Parameters
domainModel Domain
bcModel forcing boundary conditions data structure
optionsModel Options structure

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine boundary_conditions::check_shapes_3d ( real, dimension(:,:,:), intent(in)  data1,
real, dimension(:,:,:), intent(in)  data2 
)
private


Check that two model grids have the same shape

If the size of all dimensions in data1 and data2 are not exactly the same the model will stop

Parameters
data1First 3D array to check dimension sizes
data2Second 3D array to check dimension sizes

Here is the caller graph for this function:

subroutine boundary_conditions::ext_winds_init ( type(domain_type), intent(inout)  domain,
type(bc_type), intent(inout)  bc,
type(options_type), intent(in)  options 
)
private


Initialize the external winds information (filenames, nfiles, etc) and read the initial conditions

Parameters
domainModel Domain
bcModel forcing boundary conditions data structure
optionsModel Options structure

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine boundary_conditions::init_znu ( type(domain_type), intent(inout)  domain)
private


Calculate the ZNU and ZNW variables

Parameters
domainModel domain structure

Here is the caller graph for this function:

subroutine boundary_conditions::load_restart_file ( type(domain_type), intent(inout)  domain,
character(len=*), intent(in)  restart_file,
integer, intent(in), optional  time_step 
)
private


Load restart file

If we are restarting from a given point, initialize the domain from the given restart file

Parameters
domainModel domain
restart_fileName of the file to read restart data from
time_stepTime step in restart_file to read.

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine boundary_conditions::mean_boundaries ( real, dimension(:,:,:), intent(inout)  inputdata)
private


Make the forcing boundary conditions into average values

Averages are computed independantly for each level and each side of the model

Parameters
inputdata3D Array to compute means over the boundaries

Here is the caller graph for this function:

subroutine boundary_conditions::mean_winds ( type(domain_type), intent(inout)  domain,
character(len=*), intent(in)  filename,
integer, intent(in)  curstep,
type(options_type)  options 
)
private


Compute the mean wind field and make them constant everywhere...

Averages are computed over the entire domain. U and V are read in hear to avoid the cost of first interpolating them to the high-res grid. BUT this means that a much larger domain then the one ICAR is actually running on is used, so it should be changed to use the high-res grid...

Parameters
domainModel Domain
filenameName of the file to read the current boundary conditions forcing from (as in read_var)
curstepTime step in forcing file to read
optionsModel Options structure

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine boundary_conditions::read_2dvar ( real, dimension(:,:), intent(inout)  highres,
character(len=*), intent(in)  filename,
character(len=*), intent(in)  varname,
type(geo_look_up_table), intent(in)  geolut,
integer, intent(in)  curstep 
)
private


Same as read_var but for 2-dimensional data

Data are read and horizontally interpolated. This routine is simpler because it is used For a more limited set of variables, and they are simpler 2D instead of 3D. Primarily used for surface variables: Sensible and latent heat fluxes, PBL height, skin temperature, radiation

Parameters
highresAllocated input array to store the result.
filenameName of the NetCDF file to read.
varnameName of the variable to read from <filename>.
geolutGeographic Look Up Table that defines the 2D horizontal interpolation.
curstepThe time step in <filename> to read.

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine boundary_conditions::read_var ( real, dimension(:,:,:), intent(inout)  highres,
character(len=*), intent(in)  filename,
character(len=*), intent(in)  varname,
type(geo_look_up_table), intent(in)  geolut,
type(vert_look_up_table), intent(in)  vlut,
integer, intent(in)  curstep,
logical, intent(in)  boundary_only,
type(options_type), intent(in)  options,
real, dimension(:,:,:), intent(in), optional  z_lo,
real, dimension(:,:,:), intent(in), optional  z_hi,
type(vert_look_up_table), intent(in), optional  time_varying_zlut,
logical, intent(in), optional  interp_vertical 
)
private


Generic routine to read a forcing variable (varname) from a netcdf file (filename) at a time step (curstep)

Data are interpolated to the high res grid either in 3D or at the boundaries only (boundary_only) Applies modifications specificaly for U,V,T, and P variables

Parameters
highresAllocated input array to store the result.
filenameName of the NetCDF file to read.
varnameName of the variable to read from <filename>.
geolutGeographic Look Up Table that defines the 2D horizontal interpolation.
vlutVertical Look Up table that defines the vertical interpolation.
curstepThe time step in <filename> to read.
boundary_onlyLogical:interpolate to all points or just to boundaries
optionsModel options structure
z_loLow-resolution (input) 3D vertical coordinate for pressure adjustment. [meters]
z_hiHigh-resolution (output) 3D vertical coordinate for pressure adjustment. [meters]
time_varying_zlutLogical: if true, first adjust the low-resolution data to a common vertical coordinate
interp_verticalLogical: if true, perform vertical interpolation (false for pressure)

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine boundary_conditions::remove_linear_winds ( type(domain_type), intent(inout)  domain,
type(bc_type), intent(inout)  bc,
type(options_type), intent(in)  options,
character(len=*), intent(in)  filename,
integer, intent(in)  curstep 
)
private


Remove linear theory topographic winds perturbations from the low resolution wind field.

NOTE: this may not work at the moment (and certainly won't with the Linear wind look up table option)

Parameters
domainModel Domain
bcModel forcing boundary conditions data structure
optionsModel Options structure
filenameName of the file to read the current boundary conditions forcing from (as in read_var)
curstepTime step in forcing file to read

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine boundary_conditions::rotate_ext_wind_field ( type(domain_type), intent(inout)  domain,
type(wind_type), intent(inout)  ext_winds 
)
private


Rotate winds from real space back to terrain following grid (approximately)

Only used for external winds. Assumes a simple slope transform in u and v independantly constant w/height

Parameters
domainFull model domain
ext_windsExternal wind data structure

Here is the caller graph for this function:

subroutine boundary_conditions::smooth_wind ( real, dimension(:,:,:), intent(inout)  wind,
integer, intent(in)  windowsize,
integer, intent(in)  ydim 
)
private


Smooth an array (written for wind but will work for anything)

Only smooths over the first (x) and second (y or z) or third (y or z) dimension ydim can be specified to allow working with (x,y,z) data or (x,z,y) data WARNING: this is a moderately complex setup to be efficient for the ydim=3 (typically large arrays, SLOW) case be careful when editing. For the complex case it pre-computes the sum of all columns for a given row, then to move from one column to the next it just has add the next column from the sums and subtracts the last one similarly, moving to the next row just means adding the next row to the sums, and subtracting the last one. Each point also has to be divided by N, but this decreases the compution from O(windowsize^2) to O(constant) Where O(constant) = 2 additions, 2 subtractions, and 1 divide regardless of windowsize!

Parameters
wind3D array to be smoothed
windowsizesize to smooth in both directions (i.e. the full window is this * 2 + 1)
ysimaxis the y dimension is on (2 or 3) in the wind array

Here is the caller graph for this function:

subroutine boundary_conditions::swap_y_z_dimensions ( real, dimension(:,:,:), intent(inout), allocatable  data)
private


Swap the last two dimensions of an array

Call reshape after finding the nx,ny,nz values

Parameters
data3D array to be reshaped

Here is the caller graph for this function:

subroutine boundary_conditions::update_dwinddt ( type(bc_type), intent(inout)  bc,
type(domain_type), intent(in)  domain 
)
private


Calculate changes in winds between the current and future conditions

These changes are used to linearly shift all fields between the two times.

Parameters
bcModel boundary forcing conditions data structure (future conditions and changes)
domainModel domain data structure (current conditions)

Here is the caller graph for this function:

subroutine boundary_conditions::update_dxdt ( type(bc_type), intent(inout)  bc,
type(domain_type), intent(in)  domain 
)
private


Calculate changes between the current boundary conditions and the time step boundary conditions

These changes are used to linearly shift all fields between the two times.

Parameters
bcModel boundary forcing conditions data structure (future conditions and changes)
domainModel domain data structure (current conditions)

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine boundary_conditions::update_edges ( real, dimension(:,:,:), intent(inout)  dx_dt,
real, dimension(:,:,:), intent(in)  d1,
real, dimension(:,:,:), intent(in)  d2 
)
private


Same as update_dxdt but only for the edges of the domains

This is used for fields that are calculated/updated internally by the model physics (e.g. temperature and moisture) In the output dxdt variable, the first dimension is the z axis, The second dimension is either X or Y (which ever is specified) And the third dimension specifies the boundary it applies to 1=left, 2=right, 3=bottom, 4=top

Parameters
dx_dtChange in variable X between time periods d1 and d2
d1Value of field X at time period 1
d2Value of field X at time period 2
Return values
dx_dtThis field is updated along the boundaries to be (d1-d2)

Here is the caller graph for this function:

subroutine boundary_conditions::update_ext_winds ( type(bc_type), intent(inout)  bc,
type(options_type), intent(in)  options 
)
private


Update the external wind field

Read U and V and rotate into the domain 3D grid, store in bcnext_domain

Parameters
bcModel forcing boundary conditions data structure
optionsModel Options structure

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine, public boundary_conditions::update_pressure ( real, dimension(:,:,:), intent(inout)  pressure,
real, dimension(:,:,:), intent(in)  z_lo,
real, dimension(:,:,:), intent(in)  z_hi,
real, dimension(:,:,:), intent(in), optional  lowresT,
real, dimension(:,:,:), intent(in), optional  hiresT 
)


Adjust the pressure field for the vertical shift between the low and high-res domains

Ideally this should include temperature... but it isn't entirely clear what it would mean to do that, what temperature do you use? Current even though you are adjusting future P? Alternatively, could adjust input pressure to SLP with future T then adjust back to elevation with current T? Currently if T is supplied, it uses the mean of the high and low-res T to split the difference. Equations from : http://www.wmo.int/pages/prog/www/IMOP/meetings/SI/ET-Stand-1/Doc-10_Pressure-red.pdf excerpt from CIMO Guide, Part I, Chapter 3 (Edition 2008, Updated in 2010) equation 3.2 http://www.meteormetrics.com/correctiontosealevel.htm

Parameters
pressureThe pressure field to be adjusted
z_loThe 3D vertical coordinate of the input pressures
z_hiThe 3D vertical coordinate of the computed/adjusted pressures
lowresTOPTIONAL 3D temperature field of the input pressures
lowresTOPTIONAL 3D temperature field of the computed/adjusted pressures
Return values
pressureThe pressure field after adjustment

Here is the caller graph for this function:

Member Data Documentation

integer boundary_conditions::curfile
private
integer boundary_conditions::curstep
private
integer boundary_conditions::ext_winds_curfile
private
integer boundary_conditions::ext_winds_curstep
private
character (len=255), dimension(:), allocatable boundary_conditions::ext_winds_file_list
private
integer boundary_conditions::ext_winds_nfiles
private
integer boundary_conditions::ext_winds_steps_in_file
private
character (len=255), dimension(:), allocatable boundary_conditions::file_list
private
integer boundary_conditions::nfiles
private
integer boundary_conditions::smoothing_window =1
private
integer boundary_conditions::steps_in_file
private

The documentation for this module was generated from the following file: