My Project
Loading...
Searching...
No Matches
transi.h File Reference

C-interface to the IFS trans-library. More...

#include <stddef.h>
#include "ectrans/version.h"

Go to the source code of this file.

Classes

struct  Trans_t
 Struct that holds information to do transforms for one particular grid resolution. More...
 
struct  DirTrans_t
 Arguments structure for trans_dirtrans() More...
 
struct  DirTransAdj_t
 Arguments structure for trans_dirtrans_adj() More...
 
struct  InvTrans_t
 Arguments structure for trans_invtrans() More...
 
struct  InvTransAdj_t
 Adjoint of spectral inverse. More...
 
struct  DistGrid_t
 Arguments structure for trans_distgrid() More...
 
struct  GathGrid_t
 Arguments structure for trans_gathgrid() More...
 
struct  DistSpec_t
 Arguments structure for trans_distspec() More...
 
struct  GathSpec_t
 Arguments structure for trans_gathspec() More...
 
struct  VorDivToUV_t
 Arguments structure for trans_vordiv_to_UV() More...
 
struct  SpecNorm_t
 

Macros

#define TRANS_FFT992   1
 
#define TRANS_FFTW   2
 
#define TRANS_SUCCESS   0
 

Typedefs

typedef int _bool
 

Functions

const char * trans_error_msg (int errcode)
 Get error message relating to error code.
 
int trans_set_handles_limit (int limit)
 Set limit on maximum simultaneously allocated transforms.
 
int trans_set_radius (double radius)
 Set radius of planet used in trans.
 
int trans_set_nprtrv (int nprtrv)
 Set nprtrv for parallel distribution of fields in spectral space.
 
int trans_use_mpi (_bool)
 Use MPI in trans library.
 
int trans_init (void)
 Initialize trans library.
 
int trans_set_read (struct Trans_t *, const char *filepath)
 
int trans_set_write (struct Trans_t *, const char *filepath)
 
int trans_set_cache (struct Trans_t *, const void *, size_t)
 
int trans_setup (struct Trans_t *trans)
 Setup a new resolution to be used in the trans library.
 
int trans_inquire (struct Trans_t *trans, const char *varlist)
 Inquire the trans library for array values.
 
int trans_dirtrans (struct DirTrans_t *dirtrans)
 Direct spectral transform (from grid-point to spectral)
 
int trans_dirtrans_adj (struct DirTransAdj_t *dirtransadj)
 Adjoint of the Direct spectral transform (from spectral to grid-point)
 
int trans_invtrans (struct InvTrans_t *invtrans)
 Inverse spectral transform (from spectral grid-point)
 
int trans_invtrans_adj (struct InvTransAdj_t *invtrans_adj)
 Adjoint of the Inverse spectral transform (from grid-point spectral)
 
int trans_distgrid (struct DistGrid_t *distgrid)
 Distribute global gridpoint array among processors.
 
int trans_gathgrid (struct GathGrid_t *gathgrid)
 Gather global gridpoint array from processors.
 
int trans_distspec (struct DistSpec_t *distspec)
 Distribute global spectral array among processors.
 
int trans_gathspec (struct GathSpec_t *gathspec)
 Gather global spectral array from processors.
 
int trans_vordiv_to_UV (struct VorDivToUV_t *vordiv_to_UV)
 Convert Spectral vorticity & divergence to Spectral u*cos(theta) & v*cos(theta)
 
int trans_specnorm (struct SpecNorm_t *specnorm)
 Compute global spectral norms.
 
int trans_delete (struct Trans_t *trans)
 Remove footprint of specific resolution.
 
int trans_finalize (void)
 Finalize trans library.
 
int trans_new (struct Trans_t *)
 Constructor for Trans_t, setting default values.
 
int trans_set_resol (struct Trans_t *trans, int ndgl, const int *nloen)
 Set gridpoint resolution for trans.
 
int trans_set_resol_lonlat (struct Trans_t *trans, int nlon, int nlat)
 Set gridpoint resolution for trans for longitude-latitude grids.
 
int trans_set_trunc (struct Trans_t *trans, int nsmax)
 Set spectral truncation wave number for trans.
 
struct DirTrans_t new_dirtrans (struct Trans_t *trans)
 Constructor for DirTrans_t, resetting default values.
 
struct DirTransAdj_t new_dirtrans_adj (struct Trans_t *trans)
 Constructor for DirTransAdj_t, resetting default values.
 
struct InvTrans_t new_invtrans (struct Trans_t *trans)
 Constructor for InvTrans_t, resetting default values.
 
struct InvTransAdj_t new_invtrans_adj (struct Trans_t *trans)
 Constructor for InvTransAdj_t, resetting default values.
 
struct DistGrid_t new_distgrid (struct Trans_t *trans)
 Constructor for DistGrid_t, resetting default values.
 
struct GathGrid_t new_gathgrid (struct Trans_t *trans)
 Constructor for GathGrid_t, resetting default values.
 
struct DistSpec_t new_distspec (struct Trans_t *trans)
 Constructor for DistSpec_t, resetting default values.
 
struct GathSpec_t new_gathspec (struct Trans_t *trans)
 Constructor for GathSpec_t, resetting default values.
 
struct VorDivToUV_t new_vordiv_to_UV (void)
 Constructor for VorDivToUV_t, resetting default values.
 
struct SpecNorm_t new_specnorm (struct Trans_t *trans)
 Constructor for SpecNorm_t, resetting default values.
 

Detailed Description

C-interface to the IFS trans-library.

This file declares the C-API to the IFS trans-library Definitions of routines are implemented in trans_module.F90, which redirects function calls to the IFS TRANS library

Author
Willem Deconinck (nawd)
Date
Jul 2014

Function Documentation

◆ new_dirtrans()

struct DirTrans_t new_dirtrans ( struct Trans_t * trans)

Constructor for DirTrans_t, resetting default values.

Parameters
trans[in] Trans_t used to set defaults
Returns
DirTrans_t struct to be used as argument for trans_dirtrans()

◆ new_dirtrans_adj()

struct DirTransAdj_t new_dirtrans_adj ( struct Trans_t * trans)

Constructor for DirTransAdj_t, resetting default values.

Parameters
trans[in] Trans_t used to set defaults
Returns
DirTransAdj_t struct to be used as argument for trans_dirtrans_adj()

◆ new_distgrid()

struct DistGrid_t new_distgrid ( struct Trans_t * trans)

Constructor for DistGrid_t, resetting default values.

Parameters
trans[in] Trans_t used to set defaults
Returns
DistGrid_t struct to be used as argument for trans_distgrid()

◆ new_distspec()

struct DistSpec_t new_distspec ( struct Trans_t * trans)

Constructor for DistSpec_t, resetting default values.

Parameters
trans[in] Trans_t used to set defaults
Returns
DistSpec_t struct to be used as argument for trans_distspec()

◆ new_gathgrid()

struct GathGrid_t new_gathgrid ( struct Trans_t * trans)

Constructor for GathGrid_t, resetting default values.

Parameters
trans[in] Trans_t used to set defaults
Returns
GathGrid_t struct to be used as argument for trans_gathgrid()

◆ new_gathspec()

struct GathSpec_t new_gathspec ( struct Trans_t * trans)

Constructor for GathSpec_t, resetting default values.

Parameters
trans[in] Trans_t used to set defaults
Returns
GathSpec_t struct to be used as argument for trans_gathspec()

◆ new_invtrans()

struct InvTrans_t new_invtrans ( struct Trans_t * trans)

Constructor for InvTrans_t, resetting default values.

Parameters
trans[in] Trans_t used to set defaults
Returns
InvTrans_t struct to be used as argument for trans_invtrans()

◆ new_invtrans_adj()

struct InvTransAdj_t new_invtrans_adj ( struct Trans_t * trans)

Constructor for InvTransAdj_t, resetting default values.

Parameters
trans[in] Trans_t used to set defaults
Returns
InvTransAdj_t struct to be used as argument for trans_invtrans_adj()

◆ new_specnorm()

struct SpecNorm_t new_specnorm ( struct Trans_t * trans)

Constructor for SpecNorm_t, resetting default values.

Returns
SpecNorm_t struct to be used as argument for trans_specnorm()

◆ new_vordiv_to_UV()

struct VorDivToUV_t new_vordiv_to_UV ( void )

Constructor for VorDivToUV_t, resetting default values.

Returns
VorDivToUV_t struct to be used as argument for trans_gathspec()

◆ trans_delete()

int trans_delete ( struct Trans_t * trans)

Remove footprint of specific resolution.

Parameters
transTrans_t struct describing specific resolution

All arrays will be deallocated.

◆ trans_dirtrans()

int trans_dirtrans ( struct DirTrans_t * dirtrans)

Direct spectral transform (from grid-point to spectral)

A DirTrans_t struct, initialised with new_dirtrans(), groups all arguments

Parameters
dirtransDirTrans_t struct, containing all arguments.

Usage:

  • Transform of scalar fields
    struct Trans_t trans;
    trans_new(&trans);
    ... // Missing setup of trans
    double* rgp = malloc( sizeof(double) * nscalar*trans.ngptot );
    double* rspscalar = malloc( sizeof(double) * nscalar*trans.nspec2 );
    struct DirTrans_t dirtrans = new_dirtrans(&trans);
    dirtrans.nscalar = nscalar; // input
    dirtrans.rgp = rgp; // input
    dirtrans.rspscalar = rspscalar; // output
    trans_dirtrans(&dirtrans);
    Arguments structure for trans_dirtrans()
    Definition transi.h:858
    struct Trans_t * trans
    Internal storage of trans object.
    Definition transi.h:877
    int nscalar
    [input,default=0] Number of scalar fields present in RGP
    Definition transi.h:873
    const double * rgp
    [input] gridpoint fields
    Definition transi.h:859
    double * rspscalar
    [output] spectral scalar valued fields
    Definition transi.h:866
    Struct that holds information to do transforms for one particular grid resolution.
    Definition transi.h:678
    struct DirTrans_t new_dirtrans(struct Trans_t *trans)
    Constructor for DirTrans_t, resetting default values.
    Definition transi.c:135
    int trans_dirtrans(struct DirTrans_t *dirtrans)
    Direct spectral transform (from grid-point to spectral)
    int trans_new(struct Trans_t *)
    Constructor for Trans_t, setting default values.
    Definition transi.c:59
  • Transform of U and V fields to vorticity and divergence
    struct Trans_t trans;
    trans_new(&trans);
    ... // Missing setup of trans
    double* rgp = malloc( sizeof(double) * 2*nvordiv*trans.ngptot );
    double* rspvor = malloc( sizeof(double) * nvordiv*trans.nspec2 );
    double* rspdiv = malloc( sizeof(double) * nvordiv*trans.nspec2 );
    struct DirTrans_t dirtrans = new_dirtrans(&trans);
    dirtrans.nvordiv = nvordiv; // input
    dirtrans.rgp = rgp; // input -- order: U, V
    dirtrans.rspvor = rspvor; // output
    dirtrans.rspdiv = rspdiv; // output
    trans_dirtrans(&dirtrans);
    double * rspdiv
    [output] spectral divergence
    Definition transi.h:870
    int nvordiv
    [input,default=0] Number of vorticity/divergence fields in RGP
    Definition transi.h:874
    double * rspvor
    [output] spectral vorticity
    Definition transi.h:868
  • Transform of U and V fields to vorticity and divergence, as well as scalar fields
    struct Trans_t trans;
    trans_new(&trans);
    ... // Missing setup of trans
    double* rgp = malloc( sizeof(double) * (2*nvordiv+nscalar)*trans.ngptot );
    double* rspscalar = malloc( sizeof(double) * nscalar*trans.nspec2 );
    double* rspvor = malloc( sizeof(double) * nvordiv*trans.nspec2 );
    double* rspdiv = malloc( sizeof(double) * nvordiv*trans.nspec2 );
    struct DirTrans_t dirtrans = new_dirtrans(&trans);
    dirtrans.nvordiv = nvordiv; // input
    dirtrans.nscalar = nscalar; // input
    dirtrans.rgp = rgp; // input -- order: U, V, scalars
    dirtrans.rspscalar = rspscalar; // output
    dirtrans.rspvor = rspvor; // output
    dirtrans.rspdiv = rspdiv; // output
    trans_dirtrans(&dirtrans);
Note
trans_dirtrans works on distributed arrays

◆ trans_dirtrans_adj()

int trans_dirtrans_adj ( struct DirTransAdj_t * dirtransadj)

Adjoint of the Direct spectral transform (from spectral to grid-point)

A DirTransAdj_t struct, initialised with new_dirtrans_adj(), groups all arguments

Parameters
dirtrans_adjDirTransAdj_t struct, containing all arguments.

Usage:

  • Adjoint of Transform of scalar fields
    struct Trans_t trans;
    trans_new(&trans);
    ... // Missing setup of trans
    double* rgp = malloc( sizeof(double) * nscalar*trans.ngptot );
    double* rspscalar = malloc( sizeof(double) * nscalar*trans.nspec2 );
    struct DirTransAdj_t dirtrans_adj = new_dirtrans_adj(&trans);
    dirtrans_adj.nscalar = nscalar; // input
    dirtrans_adj.rgp = rgp; // input
    dirtrans_adj.rspscalar = rspscalar; // output
    trans_dirtrans_adj(&dirtrans_adj);
    Arguments structure for trans_dirtrans_adj()
    Definition transi.h:894
    double * rspscalar
    [output] spectral scalar valued fields
    Definition transi.h:902
    int nscalar
    [input,default=0] Number of scalar fields present in RGP
    Definition transi.h:909
    struct Trans_t * trans
    Internal storage of trans object.
    Definition transi.h:913
    const double * rgp
    [input] gridpoint fields
    Definition transi.h:895
    struct DirTransAdj_t new_dirtrans_adj(struct Trans_t *trans)
    Constructor for DirTransAdj_t, resetting default values.
    Definition transi.c:152
    int trans_dirtrans_adj(struct DirTransAdj_t *dirtransadj)
    Adjoint of the Direct spectral transform (from spectral to grid-point)
  • Adjoint of Transform of U and V fields to vorticity and divergence
    struct Trans_t trans;
    trans_new(&trans);
    ... // Missing setup of trans
    double* rgp = malloc( sizeof(double) * 2*nvordiv*trans.ngptot );
    double* rspvor = malloc( sizeof(double) * nvordiv*trans.nspec2 );
    double* rspdiv = malloc( sizeof(double) * nvordiv*trans.nspec2 );
    struct DirTransAdj_t dirtrans_adj = new_dirtrans_adj(&trans);
    dirtrans_adj.nvordiv = nvordiv; // input
    dirtrans_adj.rgp = rgp; // input -- order: U, V
    dirtrans_adj.rspvor = rspvor; // output
    dirtrans_adj.rspdiv = rspdiv; // output
    trans_dirtrans_adj(&dirtrans_adj);
    double * rspvor
    [output] spectral vorticity
    Definition transi.h:904
    int nvordiv
    [input,default=0] Number of vorticity/divergence fields in RGP
    Definition transi.h:910
    double * rspdiv
    [output] spectral divergence
    Definition transi.h:906
  • Adjoint of Transform of U and V fields to vorticity and divergence, as well as scalar fields
    struct Trans_t trans;
    trans_new(&trans);
    ... // Missing setup of trans
    double* rgp = malloc( sizeof(double) * (2*nvordiv+nscalar)*trans.ngptot );
    double* rspscalar = malloc( sizeof(double) * nscalar*trans.nspec2 );
    double* rspvor = malloc( sizeof(double) * nvordiv*trans.nspec2 );
    double* rspdiv = malloc( sizeof(double) * nvordiv*trans.nspec2 );
    struct DirTransAdj_t dirtrans_adj = new_dirtrans_adj(&trans);
    dirtrans_adj.nvordiv = nvordiv; // input
    dirtrans_adj.nscalar = nscalar; // input
    dirtrans_adj.rgp = rgp; // input -- order: U, V, scalars
    dirtrans_adj.rspscalar = rspscalar; // output
    dirtrans_adj.rspvor = rspvor; // output
    dirtrans_adj.rspdiv = rspdiv; // output
    trans_dirtrans_adj(&dirtrans_adj);
Note
trans_dirtrans_adj works on distributed arrays

◆ trans_distgrid()

int trans_distgrid ( struct DistGrid_t * distgrid)

Distribute global gridpoint array among processors.

Usage:

struct Trans_t trans;
trans_new(&trans);
... // missing setup
int nfld = 1;
double* rgpg = NULL;
if( trans.myproc == 1 ) // Load global field in proc 1
{
rgpg = malloc( sizeof(double) * trans.ngptotg*nfld );
... // load data in rgpg[nfld][ngptotg]
}
int* nfrom = malloc( sizeof(int) * nfld );
nfrom[0] = 1; // Global field 0 sits in proc 1
double* rgp = malloc( sizeof(double) * nfld*trans.ngptot );
struct DistGrid_t distgrid = new_distgrid(&trans);
distgrid.nfrom = nfrom;
distgrid.rgpg = rgpg;
distgrid.rgp = rgp;
distgrid.nfld = nfld;
trans_distgrid(&distgrid);
Arguments structure for trans_distgrid()
Definition transi.h:1018
struct Trans_t * trans
Internal storage of trans object.
Definition transi.h:1031
const double * rgpg
Global gridpoint array Fortran DIMENSIONS(1:NGPTOTG,1:NFLDG) C/C++ DIMENSIONS[NFLDG][NGPTOTG].
Definition transi.h:1019
int nfld
Number of distributed fields.
Definition transi.h:1029
double * rgp
Distributed gridpoint array Fortran DIMENSIONS(1:NPROMA,1:NFLD,1:NGPBLKS) C/C++ DIMENSIONS[NGPBLKS][N...
Definition transi.h:1022
const int * nfrom
Processors responsible for distributing each field DIMENSIONS(1:NFLD)
Definition transi.h:1026
int trans_distgrid(struct DistGrid_t *distgrid)
Distribute global gridpoint array among processors.
struct DistGrid_t new_distgrid(struct Trans_t *trans)
Constructor for DistGrid_t, resetting default values.
Definition transi.c:210

◆ trans_distspec()

int trans_distspec ( struct DistSpec_t * distspec)

Distribute global spectral array among processors.

Usage:

struct Trans_t trans;
trans_new(&trans);
... // missing setup
// Global fields to be distributed
int nscalar = 1;
double* rspscalarg = NULL;
if( trans.myproc == 1 )
{
rspscalarg = malloc( sizeof(double) * nscalar*trans.nspec2g );
... // load data in rspscalarg[nspec2g][nscalar]
}
int* nfrom = malloc( sizeof(int) * nscalar );
nfrom[0] = 1;
// Distribute to local fields
double* rspscalar = malloc( sizeof(double) * nscalar*trans.nspec2 );
struct DistSpec_t distspec = new_distspec(&trans);
distspec.rspec = rspscalar;
distspec.rspecg = rspscalarg;
distspec.nfld = nscalar;
distspec.nfrom = nto;
trans_distspec(&distspec);
Arguments structure for trans_distspec()
Definition transi.h:1077
const double * rspecg
Global spectral array Fortran DIMENSIONS(1:NFLDG,1:NSPEC2G) C/C++ DIMENSIONS[NSPEC2G][NFLDG].
Definition transi.h:1078
const int * nfrom
Processors responsible for distributing each field Fortran DIMENSIONS(1:NFLD)
Definition transi.h:1084
int nfld
Number of distributed fields.
Definition transi.h:1086
struct Trans_t * trans
Internal storage of trans object.
Definition transi.h:1087
double * rspec
Local spectral array Fortran DIMENSIONS(1:NFLD,1:NSPEC2) C/C++ DIMENSIONS[NSPEC2][NFLD].
Definition transi.h:1081
struct DistSpec_t new_distspec(struct Trans_t *trans)
Constructor for DistSpec_t, resetting default values.
Definition transi.c:238
int trans_distspec(struct DistSpec_t *distspec)
Distribute global spectral array among processors.

◆ trans_finalize()

int trans_finalize ( void )

Finalize trans library.

This finalizes MPI communication, and deallocates resolution-independent storage. After this, no more calls to trans should be made

◆ trans_gathgrid()

int trans_gathgrid ( struct GathGrid_t * gathgrid)

Gather global gridpoint array from processors.

Usage:

struct Trans_t trans;
trans_new(&trans);
... // missing setup
// Distributed field
int nfld = 1;
double* rgp = malloc( sizeof(double) * nfld*trans.ngptot );
... // load data in rgp[nfld][ngptot]
// Global field
double* rgpg = NULL;
if( trans.myproc == 1 ) // We will gather to proc 1
{
rgpg = malloc( sizeof(double) * nfld*trans.ngptotg );
}
int* nto = malloc( sizeof(int) * nfld );
nto[0] = 1;
// Gather global fields
struct GathGrid_t gathgrid = new_gathgrid(&trans);
gathgrid.rgp = rgp;
gathgrid.rgpg = rgpg;
gathgrid.nto = nto;
gathgrid.nfld = nfld;
trans_gathgrid(&gathgrid);
Arguments structure for trans_gathgrid()
Definition transi.h:1047
int nfld
Number of distributed fields.
Definition transi.h:1059
const int * nto
Processors responsible for gathering each field Fortran DIMENSIONS(1:NFLD)
Definition transi.h:1056
struct Trans_t * trans
Internal storage of trans object.
Definition transi.h:1061
double * rgpg
Global gridpoint array Fortran DIMENSIONS(1:NGPTOTG,1:NFLDG) C/C++ DIMENSIONS[NFLDG][NGPTOTG] DIMENSI...
Definition transi.h:1048
const double * rgp
Distributed gridpoint array Fortran DIMENSIONS(1:NPROMA,1:NFLD,1:NGPBLKS) C/C++ DIMENSIONS[NGPBLKS][N...
Definition transi.h:1052
int trans_gathgrid(struct GathGrid_t *gathgrid)
Gather global gridpoint array from processors.
struct GathGrid_t new_gathgrid(struct Trans_t *trans)
Constructor for GathGrid_t, resetting default values.
Definition transi.c:224

◆ trans_gathspec()

int trans_gathspec ( struct GathSpec_t * gathspec)

Gather global spectral array from processors.

Usage:

struct Trans_t trans;
trans_new(&trans);
... // missing setup
// We have some distributed spectral fields "rspscalar"
int nscalar = 1;
double* rspscalar = malloc( sizeof(double) * nscalar*trans.nspec2 );
... // load data in rspscalar[nspec2][nscalar]
// We want to gather to proc 1
double* rspscalarg = NULL;
if( trans.myproc == 1 )
rspscalarg = malloc( sizeof(double) * nscalar*trans.nspec2g );
int* nto = malloc( sizeof(int) * nscalar );
nto[0] = 1;
struct GathSpec_t gathspec = new_gathspec(&trans);
gathspec.rspec = rspscalar;
gathspec.rspecg = rspscalarg;
gathspec.nfld = nscalar;
gathspec.nto = nto;
trans_gathspec(&gathspec);
Arguments structure for trans_gathspec()
Definition transi.h:1103
struct Trans_t * trans
Internal storage of trans object.
Definition transi.h:1113
double * rspecg
Global spectral array Fortran DIMENSIONS(1:NFLDG,1:NSPEC2G) C/C++ DIMENSIONS[NSPEC2G][NFLDG].
Definition transi.h:1104
const int * nto
Processors responsible for gathering each field DIMENSIONS(1:NFLD)
Definition transi.h:1110
const double * rspec
Local spectral array Fortran DIMENSIONS(1:NFLD,1:NSPEC2) C/C++ DIMENSIONS[NSPEC2][NFLD].
Definition transi.h:1107
int nfld
Number of distributed fields.
Definition transi.h:1112
struct GathSpec_t new_gathspec(struct Trans_t *trans)
Constructor for GathSpec_t, resetting default values.
Definition transi.c:249
int trans_gathspec(struct GathSpec_t *gathspec)
Gather global spectral array from processors.

◆ trans_init()

int trans_init ( void )

Initialize trans library.

This initializes MPI communication, and allocates resolution-independent storage.
If this routine is not called, then it will be called internally upon the first call to trans_setup()

Precondition
call trans_set_radius() and/or trans_set_nprtrv() if radius or nprtrv need to be different from default values

◆ trans_inquire()

int trans_inquire ( struct Trans_t * trans,
const char * varlist )

Inquire the trans library for array values.

Parameters
transTrans_t struct which needs to have been setup using trans_setup()
varlistcomma-separated string of values to inquire

The inquired values will be allocated if needed, and filled in in the Trans_t struct

◆ trans_invtrans()

int trans_invtrans ( struct InvTrans_t * invtrans)

Inverse spectral transform (from spectral grid-point)

A InvTrans_t struct, initialised with new_invtrans(), groups all arguments

Parameters
invtransInvTrans_t struct, containing all arguments.

Usage:

  • Transform of scalars
    struct Trans_t trans;
    trans_new(&trans);
    ... // Missing setup of trans
    double* rspscalar = malloc( sizeof(double) * nscalar*trans.nspec2 );
    double* rgp = malloc( sizeof(double) * nscalar*trans.ngptot );
    // Inverse Transform
    struct InvTrans_t invtrans = new_invtrans(&trans);
    invtrans.nscalar = nscalar; // input
    invtrans.rspscalar = rspscalar; // input
    invtrans.rgp = rgp; // output
    trans_invtrans(&invtrans);
    Arguments structure for trans_invtrans()
    Definition transi.h:930
    double * rgp
    [output] gridpoint fields
    Definition transi.h:937
    const double * rspscalar
    [input,default=NULL] spectral scalar valued fields
    Definition transi.h:931
    struct Trans_t * trans
    Internal storage of trans object.
    Definition transi.h:958
    int nscalar
    [input,default=0] Number of scalar fields present in RGP
    Definition transi.h:951
    struct InvTrans_t new_invtrans(struct Trans_t *trans)
    Constructor for InvTrans_t, resetting default values.
    Definition transi.c:169
    int trans_invtrans(struct InvTrans_t *invtrans)
    Inverse spectral transform (from spectral grid-point)
  • Transform vorticity and divergence to U and V
    struct Trans_t trans;
    trans_new(&trans);
    ... // Missing setup of trans
    double* rspvor = malloc( sizeof(double) * nvordiv*trans.nspec2 );
    double* rspdiv = malloc( sizeof(double) * nvordiv*trans.nspec2 );
    double* rgp = malloc( sizeof(double) * 2*nvordiv*trans.ngptot );
    // Inverse Transform
    struct InvTrans_t invtrans = new_invtrans(&trans);
    invtrans.nvordiv = nvordiv; // input
    invtrans.rspvor = rspvor; // input
    invtrans.rspdiv = rspdiv; // input
    invtrans.rgp = rgp; // output -- order: u, v
    trans_invtrans(&invtrans);
    const double * rspvor
    [input] spectral vorticity
    Definition transi.h:933
    int nvordiv
    [input,default=0] Number of vorticity/divergence fields in RGP
    Definition transi.h:952
    const double * rspdiv
    [input] spectral divergence
    Definition transi.h:935
  • Transform of vorticity, divergence and scalars to U, V, scalars
    struct Trans_t trans;
    trans_new(&trans);
    ... // Missing setup of trans
    double* rspscalar = malloc( sizeof(double) * nscalar*trans.nspec2 );
    double* rspvor = malloc( sizeof(double) * nvordiv*trans.nspec2 );
    double* rspdiv = malloc( sizeof(double) * nvordiv*trans.nspec2 );
    double* rgp = malloc( sizeof(double) * (2*nvordiv+nscalar)*trans.ngptot );
    // Inverse Transform
    struct InvTrans_t invtrans = new_invtrans(&trans);
    invtrans.nscalar = nscalar; // input
    invtrans.nvordiv = nvordiv; // input
    invtrans.rspscalar = rspscalar; // input
    invtrans.rspvor = rspvor; // input
    invtrans.rspdiv = rspdiv; // input
    invtrans.rgp = rgp; // output -- order: u, v, scalars
    trans_invtrans(&invtrans);
Note
trans_invtrans works on distributed arrays

◆ trans_invtrans_adj()

int trans_invtrans_adj ( struct InvTransAdj_t * invtrans_adj)

Adjoint of the Inverse spectral transform (from grid-point spectral)

A InvTransAdj_t struct, initialised with new_invtrans_adj(), groups all arguments

Parameters
invtrans_adjInvTransAdj_t struct, containing all arguments.

Usage:

  • Transform of scalars
    struct Trans_t trans;
    trans_new(&trans);
    ... // Missing setup of trans
    double* rspscalar = malloc( sizeof(double) * nscalar*trans.nspec2 );
    double* rgp = malloc( sizeof(double) * nscalar*trans.ngptot );
    // Adjoint of Inverse Transform
    struct InvTransAdj_t invtrans_adj = new_invtrans_adj(&trans);
    invtrans_adj.nscalar = nscalar; // input
    invtrans_adj.rspscalar = rspscalar; // output
    invtrans_adj.rgp = rgp; // input
    trans_invtrans_adj(&invtrans_adj);
    Adjoint of spectral inverse.
    Definition transi.h:972
    const double * rgp
    [input] gridpoint fields
    Definition transi.h:979
    int nscalar
    [input,default=0] Number of scalar fields present in RGP
    Definition transi.h:993
    struct Trans_t * trans
    Internal storage of trans object.
    Definition transi.h:1000
    double * rspscalar
    [output,default=NULL] spectral scalar valued fields
    Definition transi.h:973
    int trans_invtrans_adj(struct InvTransAdj_t *invtrans_adj)
    Adjoint of the Inverse spectral transform (from grid-point spectral)
    struct InvTransAdj_t new_invtrans_adj(struct Trans_t *trans)
    Constructor for InvTransAdj_t, resetting default values.
    Definition transi.c:189
  • Adjoint of Transform vorticity and divergence to U and V
    struct Trans_t trans;
    trans_new(&trans);
    ... // Missing setup of trans
    double* rspvor = malloc( sizeof(double) * nvordiv*trans.nspec2 );
    double* rspdiv = malloc( sizeof(double) * nvordiv*trans.nspec2 );
    double* rgp = malloc( sizeof(double) * 2*nvordiv*trans.ngptot );
    // Adjoint of Inverse Transform
    struct InvTransAdj_t invtrans_adj = new_invtrans_adj(&trans);
    invtrans_adj.nvordiv = nvordiv; // input
    invtrans_adj.rspvor = rspvor; // output
    invtrans_adj.rspdiv = rspdiv; // output
    invtrans_adj.rgp = rgp; // input -- order: u, v
    trans_invtrans_adj(&invtrans_adj);
    double * rspvor
    [output] spectral vorticity
    Definition transi.h:975
    int nvordiv
    [input,default=0] Number of vorticity/divergence fields in RGP
    Definition transi.h:994
    double * rspdiv
    [output] spectral divergence
    Definition transi.h:977
  • Adjoint of Transform of vorticity, divergence and scalars to U, V, scalars
    struct Trans_t trans;
    trans_new(&trans);
    ... // Missing setup of trans
    double* rspscalar = malloc( sizeof(double) * nscalar*trans.nspec2 );
    double* rspvor = malloc( sizeof(double) * nvordiv*trans.nspec2 );
    double* rspdiv = malloc( sizeof(double) * nvordiv*trans.nspec2 );
    double* rgp = malloc( sizeof(double) * (2*nvordiv+nscalar)*trans.ngptot );
    // Adjoint of Inverse Transform
    struct InvTransAdj_t invtrans_adj = new_invtrans_adj(&trans);
    invtrans_adj.nscalar = nscalar; // input
    invtrans_adj.nvordiv = nvordiv; // input
    invtrans_adj.rspscalar = rspscalar; // input
    invtrans_adj.rspvor = rspvor; // input
    invtrans_adj.rspdiv = rspdiv; // input
    invtrans_adj.rgp = rgp; // output -- order: u, v, scalars
    trans_invtrans_adj(&invtrans_adj);
Note
trans_invtrans_adj works on distributed arrays

◆ trans_new()

int trans_new ( struct Trans_t * trans)

Constructor for Trans_t, setting default values.

Returns
Trans_t struct to be used as argument for trans_setup()

◆ trans_set_handles_limit()

int trans_set_handles_limit ( int limit)

Set limit on maximum simultaneously allocated transforms.

Note
Advanced feature

Default value is 10 This function needs to be called before trans_init() or trans_setup(), and ONLY if the default value needs to be changed.

◆ trans_set_nprtrv()

int trans_set_nprtrv ( int nprtrv)

Set nprtrv for parallel distribution of fields in spectral space.

Note
Advanced feature

Default value of nprtrv is 1, meaning that there is no parallel distribution of the same wave number for different fields (or levels) This function needs to be called before trans_init() or trans_setup(), and ONLY if the default value needs to be changed.

◆ trans_set_radius()

int trans_set_radius ( double radius)

Set radius of planet used in trans.

Note
Advanced feature

Default value of radius is Earth's radius (6371.22e+03) This function needs to be called before trans_init() or trans_setup(), and ONLY if the default value needs to be changed.

◆ trans_set_resol()

int trans_set_resol ( struct Trans_t * trans,
int ndgl,
const int * nloen )

Set gridpoint resolution for trans.

Parameters
trans[in] Trans_t used to setup
ndgl[in] Number of lattitudes
nloen[in] Number of longitude points for each latitude
DIMENSIONS(1:NDGL)

◆ trans_set_resol_lonlat()

int trans_set_resol_lonlat ( struct Trans_t * trans,
int nlon,
int nlat )

Set gridpoint resolution for trans for longitude-latitude grids.

Parameters
trans[in] Trans_t used to setup
nlon[in] Number of longitudes
nlat[in] Number of latitudes (pole to pole)
  • If nlat is odd, the grid must includes poles and equator
  • If nlat is even, the grid must be its dual (excluding pole and equator), so points are shifted with 0.5*dx and 0.5*dy

◆ trans_set_trunc()

int trans_set_trunc ( struct Trans_t * trans,
int nsmax )

Set spectral truncation wave number for trans.

Parameters
trans[in] Trans_t used to setup
nsmax[in] Spectral truncation wave number

◆ trans_setup()

int trans_setup ( struct Trans_t * trans)

Setup a new resolution to be used in the trans library.

Parameters
transTrans_t struct, that needs to have following variables defined:
  • ndgl – number of lattitudes
  • nloen – number of longitudes for each lattitude
  • nsmax – spectral truncation wave number

All scalar values in the struct will be filled in. Remaining array values will be deallocated and set to null. To define array values, make individual calls to trans_inquire()

Usage:

struct Trans_t trans;
trans_new(&trans);
trans.ndgl = ... ;
trans.nloen = malloc( sizeof(int)*trans.ndgl );
... // Read in or compute nloen values
trans.nsmax = (2*trans.ndgl-1)/2; // For typical linear grid
trans_setup(&trans);
int trans_setup(struct Trans_t *trans)
Setup a new resolution to be used in the trans library.
Note
If trans_init() was not called beforehand, it will be called internally

◆ trans_specnorm()

int trans_specnorm ( struct SpecNorm_t * specnorm)

Compute global spectral norms.

Usage:< >

int nfld = 1;
double* rspec = malloc( sizeof(double) * nfld*trans.nspec2 );
double* rnorm = malloc( sizeof(double) * nfld );
... // load data in rspec[nspec2][nfld]
struct SpecNorm_t specnorm = new_specnorm(&trans);
specnorm.rspec = rspec;
specnorm.rnorm = rnorm;
specnorm.nfld = nfld;
trans_specnorm(specnorm);
Definition transi.h:1156
int nfld
Number of fields.
Definition transi.h:1165
const double * rspec
Spectral array to compute norm of Fortran DIMENSIONS(1:NFLD,1:NSPEC2) C/C++ DIMENSIONS[NSPEC2][NFLD].
Definition transi.h:1157
struct Trans_t * trans
Internal storage of trans object.
Definition transi.h:1166
double * rnorm
Norms (output for processor nmaster) DIMENSIONS(1:NFLD)
Definition transi.h:1163
int trans_specnorm(struct SpecNorm_t *specnorm)
Compute global spectral norms.
struct SpecNorm_t new_specnorm(struct Trans_t *trans)
Constructor for SpecNorm_t, resetting default values.
Definition transi.c:274

◆ trans_use_mpi()

int trans_use_mpi ( _bool )

Use MPI in trans library.

Note
Advanced feature

By default, MPI is used if MPI was detected during compilation. To force not to use MPI, this function may be used.

◆ trans_vordiv_to_UV()

int trans_vordiv_to_UV ( struct VorDivToUV_t * vordiv_to_UV)

Convert Spectral vorticity & divergence to Spectral u*cos(theta) & v*cos(theta)

Usage:

// We have some global spectral fields for vorticity,divergence,u*cos(theta),v*cos(theta)
int nfld = 1;
double* rspvor = malloc( sizeof(double) * nfld*ncoeff );
double* rspdiv = malloc( sizeof(double) * nfld*ncoeff );
double* rspu = malloc( sizeof(double) * nfld*ncoeff );
double* rspv = malloc( sizeof(double) * nfld*ncoeff );
... // load data in rspvor[ncoeff][nfld]
... // load data in rspdiv[ncoeff][nfld]
struct VorDivToUV_t vordiv_to_UV = new_vordiv_to_UV();
vordiv_to_UV.rspvor = rspvor;
vordiv_to_UV.rspdiv = rspdiv;
vordiv_to_UV.rspu = rspu;
vordiv_to_UV rspv = rspv;
vordiv_to_UV.nfld = nfld;
vordiv_to_UV.ncoeff = ncoeff;
vordiv_to_UV.nsmax = nsmax;
trans_vordiv_to_UV(&vordiv_to_UV);
Arguments structure for trans_vordiv_to_UV()
Definition transi.h:1129
double * rspu
Local spectral array for U*cos(theta) Fortran DIMENSIONS(1:NFLD,1:NSPEC2) C/C++ DIMENSIONS[NSPEC2][NF...
Definition transi.h:1136
double * rspv
Local spectral array for V*cos(theta) Fortran DIMENSIONS(1:NFLD,1:NSPEC2) C/C++ DIMENSIONS[NSPEC2][NF...
Definition transi.h:1139
const double * rspvor
Local spectral array for vorticity Fortran DIMENSIONS(1:NFLD,1:NSPEC2) C/C++ DIMENSIONS[NSPEC2][NFLD]...
Definition transi.h:1130
const double * rspdiv
Local spectral array for divergence Fortran DIMENSIONS(1:NFLD,1:NSPEC2) C/C++ DIMENSIONS[NSPEC2][NFLD...
Definition transi.h:1133
int ncoeff
number of spectral coefficients (equivalent to nspec2 for distributed or nspec2g for global)
Definition transi.h:1144
int nfld
Number of distributed fields.
Definition transi.h:1142
int nsmax
Spectral resolution (T)
Definition transi.h:1143
struct VorDivToUV_t new_vordiv_to_UV(void)
Constructor for VorDivToUV_t, resetting default values.
Definition transi.c:260
int trans_vordiv_to_UV(struct VorDivToUV_t *vordiv_to_UV)
Convert Spectral vorticity & divergence to Spectral u*cos(theta) & v*cos(theta)
Note
  • nfld indicates the multiplicity for each variable seperately
  • ncoeff is equivalent to trans.nspec2 for distributed, and trans.nspec2g for global fields
  • nsmax indicates the spectral truncation T.