FV3 Bundle
src/lorenz95/LocalizationMatrixL95.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2009-2016 ECMWF.
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  * In applying this licence, ECMWF does not waive the privileges and immunities
7  * granted to it by virtue of its status as an intergovernmental organisation nor
8  * does it submit to any jurisdiction.
9  */
10 
12 
13 #include <unsupported/Eigen/FFT>
14 #include <algorithm>
15 #include <cmath>
16 
17 #include "eckit/config/Configuration.h"
18 #include "lorenz95/IncrementL95.h"
19 #include "lorenz95/Resolution.h"
20 
21 // -----------------------------------------------------------------------------
22 namespace lorenz95 {
23 // -----------------------------------------------------------------------------
24 
26  const eckit::Configuration & config)
27  : resol_(resol.npoints()),
28  rscale_(1.0/config.getDouble("length_scale"))
29 {
30 // Gaussian structure function
31  unsigned int size = resol_/2+1;
32  std::vector<double> locfct(resol_);
33  for (unsigned int jj = 0; jj < resol_; ++jj) {
34  double zz = rscale_ * std::min(jj, resol_-jj);
35  locfct[jj] = std::exp(-0.5*zz*zz);
36  }
37 // Go to Fourier space
38  Eigen::FFT<double> fft;
39  std::vector<std::complex<double> > four(size);
40  fft.fwd(four, locfct);
41 // Save Fourier coefficients
42  coefs_.resize(size);
43  for (unsigned int jj = 0; jj < size; ++jj) {
44  coefs_[jj] = std::real(four[jj]);
45  }
46 }
47 
48 // -----------------------------------------------------------------------------
49 
51 
52 // -----------------------------------------------------------------------------
53 
55  unsigned int size = resol_/2+1;
56  Eigen::FFT<double> fft;
57  std::vector<std::complex<double> > four(size);
58  fft.fwd(four, dx.asVector());
59  for (unsigned int jj = 0; jj < size; ++jj) {
60  four[jj] *= coefs_[jj];
61  }
62  fft.inv(dx.asVector(), four);
63 }
64 
65 // -----------------------------------------------------------------------------
66 
67 void LocalizationMatrixL95::print(std::ostream & os) const {
68  os << "LocalizationMatrixL95::print not implemented";
69 }
70 
71 // -----------------------------------------------------------------------------
72 
73 } // namespace lorenz95
Increment Class: Difference between two states.
Definition: IncrementL95.h:51
Handles resolution.
Definition: Resolution.h:25
LocalizationMatrixL95(const Resolution &, const eckit::Configuration &)
The namespace for the L95 model.
std::vector< double > & asVector()
Definition: IncrementL95.h:103
************************************************************************GNU Lesser General Public License **This file is part of the GFDL Flexible Modeling System(FMS). ! *! *FMS is free software 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 see< http:! ***********************************************************************subroutine READ_RECORD_CORE_(unit, field, nwords, data, start, axsiz) integer, intent(in) ::unit type(fieldtype), intent(in) ::field integer, intent(in) ::nwords MPP_TYPE_, intent(inout) ::data(nwords) integer, intent(in) ::start(:), axsiz(:) integer(SHORT_KIND) ::i2vals(nwords)!rab used in conjunction with transfer intrinsic to determine size of a variable integer(KIND=1) ::one_byte(8) integer ::word_sz!#ifdef __sgi integer(INT_KIND) ::ivals(nwords) real(FLOAT_KIND) ::rvals(nwords)!#else! integer ::ivals(nwords)! real ::rvals(nwords)!#endif real(DOUBLE_KIND) ::r8vals(nwords) pointer(ptr1, i2vals) pointer(ptr2, ivals) pointer(ptr3, rvals) pointer(ptr4, r8vals) if(mpp_io_stack_size< nwords) call mpp_io_set_stack_size(nwords) call mpp_error(FATAL, 'MPP_READ currently requires use_netCDF option') end subroutine READ_RECORD_CORE_ subroutine READ_RECORD_(unit, field, nwords, data, time_level, domain, position, tile_count, start_in, axsiz_in)!routine that is finally called by all mpp_read routines to perform the read!a non-netCDF record contains:! field ID! a set of 4 coordinates(is:ie, js:je) giving the data subdomain! a timelevel and a timestamp(=NULLTIME if field is static)! 3D real data(stored as 1D)!if you are using direct access I/O, the RECL argument to OPEN must be large enough for the above!in a global direct access file, record position on PE is given by %record.!Treatment of timestamp:! We assume that static fields have been passed without a timestamp.! Here that is converted into a timestamp of NULLTIME.! For non-netCDF fields, field is treated no differently, but is written! with a timestamp of NULLTIME. There is no check in the code to prevent! the user from repeatedly writing a static field. integer, intent(in) ::unit, nwords type(fieldtype), intent(in) ::field MPP_TYPE_, intent(inout) ::data(nwords) integer, intent(in), optional ::time_level type(domain2D), intent(in), optional ::domain integer, intent(in), optional ::position, tile_count integer, intent(in), optional ::start_in(:), axsiz_in(:) integer, dimension(size(field%axes(:))) ::start, axsiz integer ::tlevel !, subdomain(4) integer ::i, error, is, ie, js, je, isg, ieg, jsg, jeg type(domain2d), pointer ::io_domain=> tlevel if(PRESENT(start_in) .AND. PRESENT(axsiz_in)) then if(size(start(! the data domain and compute domain must refer to the subdomain being passed ! In this ! since that attempts to gather all data on PE size(field%axes(:)) axsiz(i)
#define min(a, b)
Definition: mosaic_util.h:32