How to Use the Prototype CRTM (pCRTM)


Argument and Variable Dimensions

All of the array documentation in the source code lists their dimensions by a single letter. Throughout the prototype Community Radiative Transfer Model (pCRTM) code these are:

Table 1. Dimension index variable definitions in pCRTM
Index variable Meaning
I Array dimension is of I predictors (Istd and Iint are variants)
J Array dimension is of J absorbing species
K Array dimension is of K atmospheric layers
L Array dimension is of L spectral channels
M Array dimension is of M profiles

where the predictors are used to compute the optical depth of the various absorbing species in the gas absorption model.

This usage carries through to loop variables over the various dimensions. So, for example, if you see a loop variable k it means the loop is over the atmospheric layer dimension.

In the various routine headers you will see routine arguments documented like so,

  Layer_T:  Profile set layer average temperature array.
            UNITS:      Kelvin
            TYPE:       REAL( fp_kind )
            DIMENSION:  Rank-1 (K) or Rank-2 (K x M)
            ATTRIBUTES: INTENT( IN )

where, in the "DIMENSION" entry, the K indicates a rank-1 array of size corresponding to the number of atmospheric layers, and the K x M indicates a rank-2 array where the first dimension, K, is the number of layers and the second dimension, M, is the number of profiles.

The reason two different ranks are listed in the above example is because all the user accessible interfaces are overloaded so that you can process a single profile or multiple profiles. Table 2 below gives some examples of how the dimensionality of the various arguments change between the two interfaces (indeed, this is how the different private, user-inaccessible specific interfaces are disambiguated for the generic public interface since the variable types are the same).

Table 2. Argument dimensionality differences between specific pCRTM interfaces
Multiple Profile Interface Single Profile Interface
RankDimension RankDimension
Rank-2K x M Rank-1K
Rank-1M Scalar-
Rank-1L*M Rank-1L
Rank-2K x L*M Rank-2K x L

Module Use Definitions

The first thing to do if you use any of the pCRTM code is to include the modules that define the various variable types (Type_Kinds) and the function return codes and a message display routine (Error_Handler).
  USE Type_Kinds
  USE Error_Handler

For more information on these and other utility modules, see the Utility page.

Access to the pCRTM parameters and initialization functions is achieved by the following USE statements,

  USE Parameters
  USE Initialize

and access to the various components (forward, tangent-linear, adjoint, or K-matrix) of the pCRTM is achieved via the following USE statements,

  USE Forward_Model
  USE Tangent_Linear_Model
  USE Adjoint_Model
  USE K_Matrix_Model

Model Initialization

The model initialization routines initialize the pCRTM model by loading all the precomputed data required to perform radiative transfer computations.

Currently, the two datasets that are loaded during initialization are the spectral coefficient (SpcCoeff) data containing various instrument and channel information such as central frequencies, Planck coefficients, etc., and the gas absorption coefficient data (TauCoeff) used to compute the clear sky absorption coefficients.

The initialization call is the same regardless of the RTM component,

  ! -- Initialize the IRSSE model
  Error_Status = Initialize_RTM( Spectral_File = SpcCoeff_File, &
                                 Tau_File      = TauCoeff_File  )

  IF ( Error_Status /= SUCCESS ) THEN 
     CALL Display_Message( PROGRAM_NAME, &
                           'Error initializing RT model', & 
                            Error_Status)  
   STOP
  END IF

where the optional arguments Spectral_File and Tau_File default to the names "spectral_coefficients" and "transmittance_coefficients" respectively if the datafile names are not specified in the initialization call.

The SpcCoeff and TauCoeff datafiles for supported instruments can be found at the SpcCoeff data and TauCoeff data pages respectively (these links are also available in the Menu at left under the "Data Files" heading). Note that the binary, not netCDF, formats are required for use with the pCRTM. For more information about these input data (e.g. data structure definitions, file structures) you can visit the main SpcCoeff and TauCoeff pages.

Channel Indexing

The indexing of instrument channels in the pCRTM is discussed here as it is dependent on how the data is stored in the SpcCoeff and TauCoeff files.

The SpcCoeff and TauCoeff data are organised by instrument channel. Thus both files used in the pCRTM initialization must have the channels organised in the same order. The channels are simply indexed in the order they occur in the SpcCoeff and TauCoeff files. So, for example, if your data files contain the coefficient data for HIRS and AMSU-A/B for all the NOAA-15 to NOAA-17 platforms in that specified order, the channel indices for the various instruments are as shown in table 3 below,

Table 3. SpcCoeff/TauCoeff channel indexing example
File Position Instrument Number of Channels Channel Index
1 NOAA-15 HIRS 19 1 - 19
2 NOAA-15 AMSU-A 15 20 - 34
3 NOAA-15 AMSU-B 5 35 - 39
4 NOAA-16 HIRS 19 40 - 58
5 NOAA-16 AMSU-A 15 59 - 73
6 NOAA-16 AMSU-B 5 74 - 78
7 NOAA-17 HIRS 19 79 - 97
8 NOAA-17 AMSU-A 15 98 - 112
9 NOAA-17 AMSU-B 5 113 - 117

Thus, if you want to do a calculation for NOAA-16 AMSU-A channel 5, you will need to know that this corresponds to channel index 63 as determined by the data order in the SpcCoeff and TauCoeff data files.

These channel indices correspond to what is required for the Channel_Index argument in the pCRTM routines so that the correct coefficient data is used in a calculation. You can see how getting the channel index wrong will produce incorrect results. Channel indexing errors may cause incorrect values to appear correct if the channels in question are spectrally similar, so be careful.

Calling the RTM Components

The following examples of the call interfaces to the various pCRTM components assume that the various input arguments have been filled with useful data.

Forward Model

The Forward model, like all the pCRTM components, has two public interfaces: Compute_RTM and Forward_RTM. In general, users will want to use the first form as various intermediary arguments in the second (e.g. the gas absorption model integrated absorber amounts and predictors) are typically not required. The Compute_RTM calling sequence is,
  Error_Status = Compute_RTM( Level_Pressure,                          &  ! Input, K
                              Layer_Pressure,                          &  ! Input
                              Layer_Temperature,                       &  ! Input
                              Layer_Water_Vapor,                       &  ! Input
                              Layer_Ozone,                             &  ! Input
                              Surface_Temperature,                     &  ! Input
                              Surface_Emissivity,                      &  ! Input
                              Surface_Reflectivity,                    &  ! Input
                              Secant_View_Angle,                       &  ! Input
                              Secant_Solar_Angle,                      &  ! Input
                              n_Channels_Per_Profile,                  &  ! Input
                              Channel_Index,                           &  ! Input
                              Tau,                                     &  ! Output
                              Flux_Tau,                                &  ! Output
                              Solar_Tau,                               &  ! Output
                              Upwelling_Radiance,                      &  ! Output
                              Brightness_Temperature,                  &  ! Output
                              Solar_Reflectivity = Solar_Reflectivity, &  ! Optional input
                              Secant_Flux_Angle  = Secant_Flux_Angle,  &  ! Optional input
                              n_Input_Profiles   = n_Input_Profiles,   &  ! Optional input
                              Message_Log = Message_Log                )  ! Error messaging

  IF ( Error_Status /= SUCCESS ) THEN 
     CALL Display_Message( PROGRAM_NAME, &
                           'Error in Compute_RTM call', & 
                            Error_Status )                           
   STOP
  END IF

Note that the Compute_RTM function is overloaded so that a single profile can be processed (e.g. the arguments Level_Pressure, Layer_Pressure, Layer_Temperature, etc are rank-1 vectors with the dimension corresponding to the vertical extent of the profile), or a number of profiles can be processed (e.g. the arguments Level_Pressure, Layer_Pressure, Layer_Temperature, etc are rank-2 arrays where the first dimension corresponds to the vertical extent, and the second dimension corresponds to the profile number).

To ensure the correct dimensionalities are specified for all the arguments, please read the Compute_RTM documentation, or study the Forward_Model_Example test program.

Tangent-Linear Model

The two public interfaces for the Tangent-Linear model are Compute_RTM_TL and Tangent_Linear_RTM. As with the forward model, users will want to use the first form to avoid needing declarations for the various intermediary arguments in the second form. The Compute_RTM_TL calling sequence is,
  Error_Status = Compute_RTM_TL( Level_Pressure,                                &  ! Input
                                 Layer_Pressure,                                &  ! Input
                                 Layer_Temperature,                             &  ! Input
                                 Layer_Water_Vapor,                             &  ! Input
                                 Layer_Ozone,                                   &  ! Input
                                 Surface_Temperature,                           &  ! Input
                                 Surface_Emissivity,                            &  ! Input
                                 Surface_Reflectivity,                          &  ! Input
                                 Level_Pressure_TL,                             &  ! Input
                                 Layer_Pressure_TL,                             &  ! Input
                                 Layer_Temperature_TL,                          &  ! Input
                                 Layer_Water_vapor_TL,                          &  ! Input
                                 Layer_Ozone_TL,                                &  ! Input
                                 Surface_Temperature_TL,                        &  ! Input
                                 Surface_Emissivity_TL,                         &  ! Input
                                 Surface_Reflectivity_TL,                       &  ! Input
                                 Secant_View_Angle,                             &  ! Input
                                 Secant_Solar_Angle,                            &  ! Input
                                 n_Channels_Per_Profile,                        &  ! Input
                                 Channel_Index,                                 &  ! Input
                                 Tau, Flux_Tau, Solar_Tau,                      &  ! Output
                                 Upwelling_Radiance,                            &  ! Output
                                 Brightness_Temperature,                        &  ! Output
                                 Tau_TL, Flux_Tau_TL, Solar_Tau_TL,             &  ! Output
                                 Upwelling_Radiance_TL,                         &  ! Output
                                 Brightness_Temperature_TL,                     &  ! Output
                                 Solar_Reflectivity    = Solar_Reflectivity,    &  ! Optional input
                                 Solar_Reflectivity_TL = Solar_Reflectivity_TL, &  ! Optional input
                                 Secant_Flux_Angle     = Secant_Flux_Angle,     &  ! Optional input
                                 Message_Log = Message_Log                      )  ! Error messaging

  IF ( Error_Status /= SUCCESS ) THEN 
     CALL Display_Message( PROGRAM_NAME, &
                           'Error in Compute_RTM_TL call', & 
                            Error_Status )                           
   STOP
  END IF

Again, like the forward model, the Compute_RTM_TL function is overloaded so that a single profile or multiple profiles can be can be processed in one call.

To ensure the correct dimensionalities are specified for all the arguments, please read the Compute_RTM_TL documentation, or study the Tangent_Linear_Model_Example test program.

Adjoint Model

This model is simply the transpose of the tangent-linear model. The two public interfaces for the adjoint model are Compute_RTM_AD and Adjoint_RTM. Again, as with the forward model, users will want to use the first form to avoid needing declarations for the various intermediary arguments in the second form. The Compute_RTM_AD calling sequence is,
  Error_Status = Compute_RTM_AD( Level_Pressure,                                &  ! Input
                                 Layer_Pressure,                                &  ! Input
                                 Layer_Temperature,                             &  ! Input
                                 Layer_Water_Vapor,                             &  ! Input
                                 Layer_Ozone,                                   &  ! Input
                                 Surface_Temperature,                           &  ! Input
                                 Surface_Emissivity,                            &  ! Input
                                 Surface_Reflectivity,                          &  ! Input
                                 Tau_AD, Flux_Tau_AD, Solar_Tau_AD,             &  ! Input
                                 Upwelling_Radiance_AD,                         &  ! Input
                                 Brightness_Temperature_AD,                     &  ! Input
                                 Secant_View_Angle,                             &  ! Input
                                 Secant_Solar_Angle,                            &  ! Input
                                 n_Channels_Per_Profile,                        &  ! Input
                                 Channel_Index,                                 &  ! Input
                                 Tau, Flux_Tau, Solar_Tau,                      &  ! Output
                                 Upwelling_Radiance,                            &  ! Output
                                 Brightness_Temperature,                        &  ! Output
                                 Level_Pressure_AD,                             &  ! Output
                                 Layer_Pressure_AD,                             &  ! Output
                                 Layer_Temperature_AD,                          &  ! Output
                                 Layer_Water_vapor_AD,                          &  ! Output
                                 Layer_Ozone_AD,                                &  ! Output
                                 Surface_Temperature_AD,                        &  ! Output
                                 Surface_Emissivity_AD,                         &  ! Output
                                 Surface_Reflectivity_AD,                       &  ! Output
                                 Solar_Reflectivity    = Solar_Reflectivity,    &  ! Optional input
                                 Secant_Flux_Angle     = Secant_Flux_Angle,     &  ! Optional input
                                 Solar_Reflectivity_AD = Solar_Reflectivity_AD, &  ! Optional output
                                 Message_Log = Message_Log                      )  ! Error messaging

  IF ( Error_Status /= SUCCESS ) THEN 
     CALL Display_Message( PROGRAM_NAME, &
                           'Error in Compute_RTM_AD call', & 
                            Error_Status )                           
   STOP
  END IF

As like the oher components, the Compute_RTM_AD function is overloaded so that a single profile or multiple profiles can be can be processed in one call.

To ensure the correct dimensionalities are specified for all the arguments, please read the Compute_RTM_AD documentation, or study the Adjoint_Model_Example test program.

K-Matrix Model

This model uses the same adjoint code as the Adjoint Model, the only difference being that there is an additional loop over instrument channel so the adjoint outputs (the Jacobians) are computed as a function of channel - which is usually what you want.

The two public interfaces for the K-matrix are Compute_RTM_K and K_Matrix_RTM. Once more, as with all the other components, users will want to use the first form to avoid all the intermediary arguments in the second form. The Compute_RTM_K calling sequence is,

  Error_Status =  Compute_RTM_K( Level_Pressure,                              &  ! Input
                                Layer_Pressure,                              &  ! Input
                                Layer_Temperature,                           &  ! Input
                                Layer_Water_Vapor,                           &  ! Input
                                Layer_Ozone,                                 &  ! Input
                                Surface_Temperature,                         &  ! Input
                                Surface_Emissivity,                          &  ! Input
                                Surface_Reflectivity,                        &  ! Input
                                Tau_K, Flux_Tau_K, Solar_Tau_K,              &  ! Input
                                Upwelling_Radiance_K,                        &  ! Input
                                Brightness_Temperature_K,                    &  ! Input
                                Secant_View_Angle,                           &  ! Input
                                Secant_Solar_Angle,                          &  ! Input
                                n_Channels_Per_Profile,                      &  ! Input
                                Channel_Index,                               &  ! Input
                                Tau, Flux_Tau, Solar_Tau,                    &  ! Output
                                Upwelling_Radiance,                          &  ! Output
                                Brightness_Temperature,                      &  ! Output
                                Level_Pressure_K,                            &  ! Output
                                Layer_Pressure_K,                            &  ! Output
                                Layer_Temperature_K,                         &  ! Output
                                Layer_Water_vapor_K,                         &  ! Output
                                Layer_Ozone_K,                               &  ! Output
                                Surface_Temperature_K,                       &  ! Output
                                Surface_Emissivity_K,                        &  ! Output
                                Surface_Reflectivity_K,                      &  ! Output
                                Solar_Reflectivity   = Solar_Reflectivity,   &  ! Optional input
                                Secant_Flux_Angle    = Secant_Flux_Angle,    &  ! Optional input
                                Solar_Reflectivity_K = Solar_Reflectivity_K, &  ! Optional output
                                Message_Log = Message_Log                    )  ! Error messaging
 
  IF ( Error_Status /= SUCCESS ) THEN 
     CALL Display_Message( PROGRAM_NAME, &
                           'Error in Compute_RTM_K call', & 
                            Error_Status )                           
   STOP
  END IF

As like the oher components, the Compute_RTM_K function is overloaded so that a single profile or multiple profiles can be processed in one call.

To ensure the correct dimensionalities are specified for all the arguments, please read the Compute_RTM_K documentation, or study the K_Matrix_Model_Example test program.

Model Destruction

The last step is to destroy the pCRTM model space, freeing up all the memory allocated during the initialzation phase. This step can be ignored if the the code is being used in a program, but if this code is used in a routine one should destroy the pCRTM model space before exiting the calling routine.

The model destruction is carried out by the Destroy_RTM function,

  ! -- Destroy the RTM space
  Error_Status = Destroy_RTM()
                                                                                                                    
  IF ( Error_Status /= SUCCESS ) THEN 
     CALL Display_Message( PROGRAM_NAME, &
                           'Error destroying RTM', & 
                            Error_Status )                           
   STOP
  END IF

This page maintained by Paul van Delst

Last updated 2005/05/10 17:18:49