midas_randomPert

link to source code

Dependency Diagrams:

midas_randomPert.svg

Direct Dependency Diagram

program  midas_randompert
Purpose

Main program for generating an ensemble of random perturbations, based on the B matrix (can be homogeneous and isotropic, ensemble-based or a weighted sum of covariance matrices).

Algorithm

Uses a gaussian pseudorandom generator to produce an ensemble of control vectors. These control vectors are transformed into pertubations in physical space, through the action of the square-root of the background-error covariance matrix. The ensemble of perturbations can then be debiased and some smoothing can be applied. The perturbations thus obtained can then be interpolated and added to a provided ensemble mean and/or be mixed with some previous time perturbations.

File I/O

Input and Output Files

Description of file

analysisgrid

In - File defining grid on which perturbations are generated

targetgrid

In - File defining destination ensemble grid

bgcov

In - Static (i.e. NMC) B matrix file for NWP fields

seaIceAnalysis

In - Sea-ice analysis, to set under-ice perturbations to zero

pert_$YYYYMMDDHH_000_$NNNN

In - Previous date perturbations, when ensemble not provided

$YYYYMMDDHH_006_$NNNN

In/Out - Ensemble member files

pert_$YYYYMMDDHH_000_$NNNN

Out - Output perturbations

Synopsis

Below is a summary of the randomPert program calling sequence:

  • Initial setups:

    • Initialize the horizontal and vertical grid objects; for the generation of the perturbations from analysisgrid and for the ensemble output from targetgrid.

    • Setup the B matrices: bmat_setup.

    • Allocate arrays and a stateVector object on the analysisgrid, to receive the perturbations and first statistical moments.

    • Initialize the pseudorandom generator : rng_setup.

  • Generation of the ensemble of perturbations. Iterate until the number of required perturbations (NENS) is generated:

    • Generate a random control vector from a unit variance gaussian distribution: rng_gaussian.

    • Transform control vector to physical space perturbation using bmat_sqrtB.

  • Unbias the ensemble of perturbations if REMOVE_MEAN is true.

  • Smooth variances if smoothVariances is true.

  • Read ensemble mean if readEnsMean is true:

    • Allocate a stateVector object on the targetgrid, and then read the ensemble mean using gio_readFromFile.

    • if setPertZeroUnderIce is true, allocate a stateVector object and read sea-ice analysis using gio_readFromFile. Where the ice fraction is higher than iceFractionThreshold, the perturbations are set to zero.

  • Read and debias previous date perturbations if previousDateFraction is higher than zero.

  • Final steps:

    • Allocate a statevector object on the targetgrid, copy ocean mask and interpolate perturbations using int_interp_gsv

    • If previousDateFraction higher than zero, average previous date perturbations with the ones generated for the present date.

    • If readEnsMean is true, add the ensemble mean to the perturbations.

    • Write the perturbations using gio_writeToFile. If readEnsMean is true, write the ensemble mean as well.

Options
List of namelist blocks

that can affect the randomPert program.

  • &NAMENKF define specific parameters to configure the randomPert program and is read by the program.

  • The background-error covariance matrix contributions are defined through the namelists &NAMBHI, for the homogeneous and isotropic part, and &NAMBEN for the ensemble part. When the matrix is a weighted sum, it is important to make sure to define the SCALEFACTOR values. Note that it would be also possible to define contributions from &NAMBDIFF for diffusion correlations and &NAMBCHM for homogeneous and isotropic chemical constituents covariances.

Needed modules

  • version_mod: MODULE version_mod (prefix=’ver’ category=’8. Low-level utilities and constants’)

  • midasmpi_mod: MODULE midasMpi_mod (prefix=’mmpi’ category=’8. Low-level utilities and constants’)

  • ramdisk_mod: MODULE ramDisk_mod (prefix=’ram’ category=’8. Low-level utilities and constants’)

  • controlvector_mod: MODULE controlVector_mod (prefix=’cvm’ category=’6. High-level data objects’)

  • gridstatevector_mod: MODULE gridStateVector_mod (prefix=’gsv’ category=’6. High-level data objects’)

  • gridstatevectorfileio_mod: MODULE gridStateVectorFileIO_mod (prefix=’gio’ category=’4. Data Object transformations’)

  • bmatrix_mod: MODULE bMatrix_mod (prefix=’bmat’ category=’2. B and R matrices’)

  • interpolation_mod: MODULE interpolation_mod (prefix=’int’ category=’4. Data Object transformations’)

  • verticalcoord_mod: MODULE verticalCoord_mod (prefix=’vco’ category=’7. Low-level data objects’)

  • horizontalcoord_mod: MODULE horizontalCoord_mod (prefix=’hco’ category=’7. Low-level data objects’)

  • timecoord_mod: MODULE timeCoord_mod (prefix=’tim’ category=’7. Low-level data objects’)

  • randomnumber_mod: MODULE randomNumber_mod (prefix=’rng’ category=’8. Low-level utilities and constants’)

  • utilities_mod: MODULE utilities_mod (prefix=’utl’ category=’8. Low-level utilities and constants’)

  • gridvariabletransforms_mod: MODULE gridVariableTransforms_mod (prefix=’gvt’ category=’4. Data Object transformations’)

Routines called

ver_printnameandversion(), mmpi_initialize(), utl_tmg_start(), utl_abort(), ram_setup(), tim_setup(), tim_getdatestamp(), tim_getdatestampfromfile(), tim_setdatestamp(), gsv_setup(), hco_setupfromfile(), mmpi_setup_latbands(), mmpi_setup_lonbands(), vco_setupfromfile(), bmat_setup(), gvt_setup(), gvt_setupreffromtrialfiles(), gsv_varexist(), gsv_allocate(), rng_setup(), rng_gaussian(), bmat_reducetompilocal(), bmat_sqrtb(), gsv_deallocate(), gio_readfromfile(), gsv_copymask(), int_interp_gsv(), gsv_add(), gio_writetofile(), utl_tmg_stop()