midas_adjointTest

link to source code

Dependency Diagrams:

midas_adjointTest.svg

Direct Dependency Diagram

program  midas_adjointtest
Purpose

Main program for adjoint test applications, i.e., testing if the identity \(<x,L(y)> = <L^T(x),y>\) is respected.

Algorithm

Initialize a random grid-point space statevector \(x\) and a random control vector \(y\). Compute \(L(y)\) by the action of a linear operator and compute the inner product \(<x,L(y)>\). Then compute \(L^T(x)\) through the action of the corresponding adjoint operator and the inner product \(<L^T(x),y>\). Verify if both inner products are equal.

File I/O

The required input files vary according to the application (see options below).

Input and Output Files (square root covariances)

Description of file

flnml

In - Main namelist file with parameters user may modify

trlm_01

In - Background state (a.k.a. trial) file

analysisgrid

In - File defining grid for computing the analysis increment

bgcov

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

ensemble/$YYYYMMDDHH_006_$NNNN

In - Ensemble member files defining ensemble B matrix

innerProd.txt

Out - Results of inner products and their difference

Synopsis

There are several flavors of tests that can be run. The choice is configured in the namelist block NAMADT with the variable test (see below). All tests follow this general synopsis:

  • initialize with gaussian noise (rng_gaussian()) a statevector \(x\) and a control vector \(y\).

  • apply the corresponding square root operator on \(y\) to obtain \(Ly\)

  • compute the inner product \(<x ,Ly>\)

  • apply the corresponding square root adjoint operator on \(x\) to obtain \(L^T(x)\)

  • compute the inner product \(<L^Tx,y>\)

  • print \(<x,L(y)>\), \(<L^T(x),y>\) and their relative difference

Options

List of namelist blocks that can affect the adjointTest program.

  • As described in the algorithm section, four different tests are implemented. The test that is conducted is chosen through the namelist variable &NAMADT Test that can be either

    • ‘Bhi’ : test the adjoint of the square root of the homogeneous and isotropic covariance matrix. The namelist block &NAMBHI will configure the covariance matrix properties.

    • ‘Bens’ : test the adjoint of the square root of the ensemble covariance matrix. The namelist block &NAMBEN will configure the covariance matrix properties.

    • ‘loc’ : test the adjoint of the square root of localized covariance matrix.

    • ‘advEns’ : test the adjoint of the advection operator on ensemble

    • ‘advGSV’ : test the adjoint of the advection operator on a single statevector

Needed modules

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

  • codeprecision_mod: MODULE codePrecision_mod (prefix=’pre’ category=’8. Low-level utilities and constants’)

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

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

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

  • mathphysconstants_mod: MODULE mathPhysConstants_mod (prefix=’mpc’ category=’8. Low-level utilities and constants’)

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

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

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

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

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

  • bmatrixhi_mod: MODULE bMatrixHI_mod (prefix=’bhi’ category=’2. B and R matrices’)

  • bmatrixensemble_mod: MODULE bMatrixEnsemble_mod (prefix=’ben’ category=’2. B and R matrices’)

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

  • advection_mod: MODULE advection_mod (prefix=’adv’ category=’4. Data Object transformations’)

  • ensemblestatevector_mod: MODULE ensembleStateVector_mod (prefix=’ens’ category=’6. High-level data objects’)

  • localization_mod: MODULE localization_mod (prefix=’loc’ category=’2. B and R matrices’)

  • lambmatrixhi_mod: MODULE lamBmatrixHI_mod (prefix=’lbhi’ category=’2. B and R matrices’)

Routines called

ver_printnameandversion(), mmpi_initialize(), utl_tmg_start(), ram_setup(), tim_setup(), tim_getdatestamp(), utl_abort(), mpc_printconstants(), pre_printprecisions(), gsv_setup(), hco_setupfromfile(), vco_setupfromfile(), gvt_setup(), utl_isnamelistpresent(), utl_tmg_stop(), gvt_setupreffromtrialfiles(), bhi_setup(), lbhi_setup(), gsv_allocate(), rng_setup(), rng_gaussian(), bhi_bsqrt(), lbhi_bsqrt(), bhi_bsqrtad(), lbhi_bsqrtadj(), gsv_deallocate(), ben_setup(), ben_bsqrtad(), ben_bsqrt(), tim_getstamplist(), ben_getloc(), ben_getnumstepamplitudeassimwindow(), ben_getamp3dstepindexassimwindow(), ens_allocate(), ens_getnumk(), ens_getonelev_r8(), loc_lsqrtad(), loc_lsqrt(), ens_copymember(), ens_deallocate(), adv_setup(), ens_copy(), adv_ensemble_ad(), adv_ensemble_tl(), gsv_copy(), adv_statevector_tl(), adv_statevector_ad()