C ******************************COPYRIGHT******************************            RAD_ALL.7451  
C (c) CROWN COPYRIGHT 1996, METEOROLOGICAL OFFICE, All Rights Reserved.            RAD_ALL.7452  
C                                                                                  RAD_ALL.7453  
C Use, duplication or disclosure of this code is subject to the                    RAD_ALL.7454  
C restrictions as set forth in the contract.                                       RAD_ALL.7455  
C                                                                                  RAD_ALL.7456  
C                Meteorological Office                                             RAD_ALL.7457  
C                London Road                                                       RAD_ALL.7458  
C                BRACKNELL                                                         RAD_ALL.7459  
C                Berkshire UK                                                      RAD_ALL.7460  
C                RG12 2SZ                                                          RAD_ALL.7461  
C                                                                                  RAD_ALL.7462  
C If no contract has been raised with this copy of the code, the use,              RAD_ALL.7463  
C duplication or disclosure of it is strictly prohibited.  Permission              RAD_ALL.7464  
C to do so must first be obtained in writing from the Head of Numerical            RAD_ALL.7465  
C Modelling at the above address.                                                  RAD_ALL.7466  
C ******************************COPYRIGHT******************************            RAD_ALL.7467  
CLL Subroutine GAS_CALC ----------------------------------------------             RAD_ALL.7468  
CLL                                                                                RAD_ALL.7469  
CLL Purpose :                                                                      RAD_ALL.7470  
CLL   Calculates the trace gas mixing ratio (or weighting factor for               RAD_ALL.7471  
CLL aerosol forcing fields.  Rates of increase (yearly compound factors)           RAD_ALL.7472  
CLL can be supplied, or spot values (which will be linearly                        RAD_ALL.7473  
CLL interpolated) or a mixture of these.  It is designed so it can be              RAD_ALL.7474  
CLL called each time step, but when rates of increase are being used,              RAD_ALL.7475  
CLL values are in fact only updated at New Year.                                   RAD_ALL.7476  
CLL The rules are:                                                                 RAD_ALL.7477  
CLL   If rates exist (i.e. are positive) for the first & current years             RAD_ALL.7478  
CLL then all concentrations are ignored, except for the initial value.             RAD_ALL.7479  
CLL   If there is a positive rate for the current year but not for the             RAD_ALL.7480  
CLL start, the current rate & most recent concentration are used.                  RAD_ALL.7481  
CLL   If rates do not exist for the current year then the concentration            RAD_ALL.7482  
CLL is calculated by linear interpolation between the concentrations at            RAD_ALL.7483  
CLL the given years.                                                               RAD_ALL.7484  
CLL   The mixing ratios calculated after the last given year use the               RAD_ALL.7485  
CLL rate for the final given year.                                                 RAD_ALL.7486  
CLL   The 360-day year is assumed.                                                 RAD_ALL.7487  
CLL CARE should be taken if solitary rates are specified, as this can              RAD_ALL.7488  
CLL result in discontinuities in the concentration time profile at                 RAD_ALL.7489  
CLL the next given year without a corresponding given rate.                        RAD_ALL.7490  
CLL                                                                                RAD_ALL.7491  
CLL Authors : Andrew Brady, Tim Johns, William Ingram                              RAD_ALL.7492  
CLL                                                                                RAD_ALL.7493  
CLL Version for : Cray YMP                                                         RAD_ALL.7494  
CLL                                                                                RAD_ALL.7495  
CLL  Model                                                                         RAD_ALL.7496  
CLL version  Date                                                                  RAD_ALL.7497  
CLL   4.2  19/11/96       Author: William Ingram, reviewer Cath Senior.            RAD_ALL.7498  
CLL   4.4  22/9/97         Correct code for the case when one changes              RAD_ALL.7499  
CLL    from linear interpolation to a rate & then changes the rate.  WJI           RAD_ALL.7500  
CLL                                                                                RAD_ALL.7501  
CLL                                                                                RAD_ALL.7502  
CLLEND -----------------------------------------------------------------           RAD_ALL.7503  
C*L Arguments                                                                      RAD_ALL.7504  
                                                                                   RAD_ALL.7505  
      SUBROUTINE GAS_CALC(GAS_NOW                                                  RAD_ALL.7506  
     &                   ,GAS_INDEX_MAX                                            RAD_ALL.7507  
     &                   ,GAS_YEAR                                                 RAD_ALL.7508  
     &                   ,GAS_CONC                                                 RAD_ALL.7509  
     &                   ,GAS_RATE                                                 RAD_ALL.7510  
     &                   ,MAX_SCENARIO_PTS                                         RAD_ALL.7511  
     &                   ,ICODE                                                    RAD_ALL.7512  
     &                   ,CMESSAGE)                                                RAD_ALL.7513  
                                                                                   RAD_ALL.7514  
      IMPLICIT NONE                                                                RAD_ALL.7515  
                                                                                   RAD_ALL.7516  
C*L================ COMDECK CMAXSIZE ==========================                    CMAXSIZE.2     
C   Description:                                                                   CMAXSIZE.3     
C     This COMDECK contains maximum sizes for dimensioning arrays                  CMAXSIZE.4     
C   of model constants whose sizes are configuration dependent. This               CMAXSIZE.5     
C   allows constants to be read in from a NAMELIST file and maintain               CMAXSIZE.6     
C   the flexibility of dynamic allocation for primary variables. The               CMAXSIZE.7     
C   maximum sizes should agree with the maximum sizes implicit in the              CMAXSIZE.8     
C   front-end User Interface.                                                      CMAXSIZE.9     
C                                                                                  CMAXSIZE.10    
CLL                                                                                CMAXSIZE.11    
CLL  Model            Modification history:                                        CMAXSIZE.12    
CLL version  Date                                                                  CMAXSIZE.13    
CLL 3.2   26/03/93  New COMDECK. Author R.Rawlins                                  CMAXSIZE.14    
CLL  3.4  06/08/94: Parameter MAX_NO_OF_SEGS used to dimension addresses           CMAXSIZE.15    
CLL                 in macro-tasked calls to SWRAD, LWRAD & CONVECT.               CMAXSIZE.16    
CLL                 Authors: A.Dickinson, D.Salmond, Reviewer: R.Barnes            CMAXSIZE.17    
CLL  3.5  22/05/95  Add MAX_N_INTF. D. Robinson                                    CMAXSIZE.18    
                                                                                   CMAXSIZE.19    
CLL                                                                                CMAXSIZE.20    
C                                                                                  CMAXSIZE.21    
C                                                                                  CMAXSIZE.22    
C     MAX_N_INTF/MAX_N_INTF_A to be sorted out in next version                     CMAXSIZE.39    
      INTEGER  MAX_N_INTF     ! Max no. of interface areas                         CMAXSIZE.40    
        PARAMETER (MAX_N_INTF = 4)                                                 CMAXSIZE.41    
                                                                                   CMAXSIZE.42    
                                                                                   CMAXSIZE.43    
!                                                                                  CSUBMODL.2     
! Description:                                                                     CSUBMODL.3     
!    Describes the number and identity of submodels available                      CSUBMODL.4     
!    within the system, and those included in the current                          CSUBMODL.5     
!    experiment.  Parameters set by the User Interface give                        CSUBMODL.6     
!    the relevant array sizes; other submodel configuration                        CSUBMODL.7     
!    information is either read from NAMELIST input, or                            CSUBMODL.8     
!    derived from dump header information.                                         CSUBMODL.9     
!                                                                                  CSUBMODL.10    
! Current Code Owner: R. Rawlins                                                   CSUBMODL.11    
!                                                                                  CSUBMODL.12    
! History:                                                                         CSUBMODL.13    
! Version  Date     Comment                                                        CSUBMODL.14    
! -------  ----     -------                                                        CSUBMODL.15    
! pre 3.0           Original code. T. Johns                                        CSUBMODL.16    
! 3.5    07/04/95   Expansion for stage 1 of submodel project, allowing            CSUBMODL.17    
!                   flexible specification of internal models within               CSUBMODL.18    
!                   submodel partitions. R. Rawlins                                CSUBMODL.19    
!                                                                                  CSUBMODL.20    
! Declarations:                                                                    CSUBMODL.21    
!                                                                                  CSUBMODL.22    
!  1. Internal model and submodel dump partition identifiers - fixed               CSUBMODL.23    
!     for all experiments.                                                         CSUBMODL.24    
!                                                                                  CSMID.2     
! Description:                                                                     CSMID.3     
!    Hold parameters defining internal model identifiers and submodel              CSMID.4     
!    data partition (ie main D1 data array and consequent dump), both              CSMID.5     
!    short and long form.                                                          CSMID.6     
!                                                                                  CSMID.7     
! Current Code Owner: R. Rawlins                                                   CSMID.8     
!                                                                                  CSMID.9     
! History:                                                                         CSMID.10    
! Version  Date     Comment                                                        CSMID.11    
! -------  ----     -------                                                        CSMID.12    
! pre 3.0           Original code. T. Johns                                        CSMID.13    
! 3.3    26/10/93   M. Carter. Part of an extensive mod that:                      CSMID.14    
!                    1.Removes the limit on primary STASH item numbers.            CSMID.15    
!                    2.Removes the assumption that (section,item)                  CSMID.16    
!                      defines the sub-model.                                      CSMID.17    
!                    3.Thus allows for user-prognostics.                           CSMID.18    
!                    Add index to submodel home dump.                              CSMID.19    
! 3.5    13/03/95   Expansion for stage 1 of submodel project, allowing            CSMID.20    
!                   flexible specification of internal models within               CSMID.21    
!                   submodel partitions. R. Rawlins                                CSMID.22    
!                                                                                  CSMID.23    
! Declarations:                                                                    CSMID.24    
!                                                                                  CSMID.25    
!   Hold parameters defining internal model identifiers and submodel               CSMID.26    
!   data partition (ie main D1 data array and consequent dump), both               CSMID.27    
!   short and long form                                                            CSMID.28    
      INTEGER                                                                      CSMID.29    
     *   A_IM,ATMOS_IM        ! Atmosphere internal model                          CSMID.30    
     *  ,O_IM,OCEAN_IM        ! Ocean      internal model                          CSMID.31    
     *  ,S_IM, SLAB_IM        ! Slab       internal model                          CSMID.32    
     *  ,W_IM, WAVE_IM        ! Wave       internal model                          CSMID.33    
     *  ,I_IM,SEAICE_IM       ! Sea-ice    internal model                          CSMID.34    
     *  ,N_IM,NATMOS_IM       ! New dynamics (Charney-Phillips grid)               CSMID.35    
!                               atmosphere internal model                          CSMID.36    
!                                                                                  CSMID.37    
      PARAMETER(                                                                   CSMID.38    
     *   A_IM=1,ATMOS_IM=1       ! Atmosphere internal model                       CSMID.39    
     *  ,O_IM=2,OCEAN_IM=2       ! Ocean      internal model                       CSMID.40    
     *  ,S_IM=3, SLAB_IM=3       ! Slab       internal model                       CSMID.41    
     *  ,W_IM=4, WAVE_IM=4       ! Wave       internal model                       CSMID.42    
     *  ,I_IM=5,SEAICE_IM=5      ! Sea-ice    internal model                       CSMID.43    
     *  ,N_IM=6,NATMOS_IM=6      ! New dynamics (Charney-Phillips grid)            CSMID.44    
!                                  atmosphere internal model                       CSMID.45    
     *)                                                                            CSMID.46    
!                                                                                  CSMID.47    
      INTEGER                                                                      CSMID.48    
     *   A_SM,ATMOS_SM        ! Atmosphere submodel partition                      CSMID.49    
     *  ,O_SM,OCEAN_SM        ! Ocean      submodel partition                      CSMID.50    
     *  ,W_SM, WAVE_SM        ! Wave       submodel partition                      CSMID.51    
     *  ,N_SM,NATMOS_SM       ! New dynamics (Charney-Phillips grid)               CSMID.52    
!                                  atmosphere internal model                       CSMID.53    
!                                                                                  CSMID.54    
      PARAMETER(                                                                   CSMID.55    
     *   A_SM=1,ATMOS_SM=1    ! Atmosphere submodel partition                      CSMID.56    
     *  ,O_SM=2,OCEAN_SM=2    ! Ocean      submodel partition                      CSMID.57    
     *  ,W_SM=4, WAVE_SM=4    ! Wave       submodel partition                      CSMID.58    
     *  ,N_SM=6,NATMOS_SM=6   ! New dynamics (Charney-Phillips grid)               CSMID.59    
!                                  atmosphere internal model                       CSMID.60    
     *)                                                                            CSMID.61    
!                                                                                  CSMID.62    
C                                                                                  CSMID.63    
                                                                                   CSUBMODL.26    
!                                                                                  CSUBMODL.27    
!  2. Maximum internal model/submodel array sizes for this version.                CSUBMODL.28    
!                                                                                  CSUBMODL.29    
!                                                                                  CSUBMMAX.2     
! Description:                                                                     CSUBMMAX.3     
!    Describes the number and identity of submodels available                      CSUBMMAX.4     
!    within the system, and those included in the current                          CSUBMMAX.5     
!    experiment.  Parameters set by the User Interface give                        CSUBMMAX.6     
!    the relevant array sizes; other submodel configuration                        CSUBMMAX.7     
!    information is either read from NAMELIST input, or                            CSUBMMAX.8     
!    derived from dump header information.                                         CSUBMMAX.9     
!                                                                                  CSUBMMAX.10    
! Current Code Owner: R. Rawlins                                                   CSUBMMAX.11    
!                                                                                  CSUBMMAX.12    
! History:                                                                         CSUBMMAX.13    
! Version  Date     Comment                                                        CSUBMMAX.14    
! -------  ----     -------                                                        CSUBMMAX.15    
! 3.5    13/07/95   Original code. D.M. Goddard                                    CSUBMMAX.16    
! 4.0     3/11/95   Reduce max internal model, submodel from 10 to 4               CSUBMMAX.17    
!                   to save space in model. At 4.0 the max no of                   CSUBMMAX.18    
!                   supported models is 3, 1 slot is reserved for                  CSUBMMAX.19    
!                   expansion. Rick Rawlins.                                       CSUBMMAX.20    
!  4.1  21/02/96  Wave model introduced as 4th sub-model.  RTHBarnes               CSUBMMAX.21    
!                                                                                  CSUBMMAX.22    
! Declarations:                                                                    CSUBMMAX.23    
!                                                                                  CSUBMMAX.24    
!                                                                                  CSUBMMAX.25    
!  1. Maximum internal model/submodel array sizes for this version.                CSUBMMAX.26    
!                                                                                  CSUBMMAX.27    
      INTEGER                                                                      CSUBMMAX.28    
     * N_INTERNAL_MODEL_MAX      ! Max no. of internal models                      CSUBMMAX.29    
     *,N_SUBMODEL_PARTITION_MAX  ! Max no. of submodel dump partitions             CSUBMMAX.30    
     *,INTERNAL_ID_MAX           ! Max value of internal model id                  CSUBMMAX.31    
     *,SUBMODEL_ID_MAX           ! Max value of submodel dump id                   CSUBMMAX.32    
                                                                                   CSUBMMAX.33    
      PARAMETER(                                                                   CSUBMMAX.34    
     * N_INTERNAL_MODEL_MAX=4,                                                     CSUBMMAX.35    
     * N_SUBMODEL_PARTITION_MAX=4,                                                 CSUBMMAX.36    
     * INTERNAL_ID_MAX=N_INTERNAL_MODEL_MAX,                                       CSUBMMAX.37    
     * SUBMODEL_ID_MAX=N_SUBMODEL_PARTITION_MAX)                                   CSUBMMAX.38    
!                                                                                  CSUBMODL.31    
!  3. Lists of internal models and their submodel dump partitions -                CSUBMODL.32    
!     initialised by the user interface - experiment specific.                     CSUBMODL.33    
      INTEGER                                                                      CSUBMODL.34    
     * N_INTERNAL_MODEL          ! No. of internal models                          CSUBMODL.35    
     *,N_SUBMODEL_PARTITION      ! No. of submodel partitions                      CSUBMODL.36    
     *,INTERNAL_MODEL_LIST(N_INTERNAL_MODEL_MAX) ! Internal models                 CSUBMODL.37    
     *,SUBMODEL_FOR_IM    (N_INTERNAL_MODEL_MAX) ! Submodel identifier             CSUBMODL.38    
     *                           ! for each internal model in list                 CSUBMODL.39    
     &,SUBMODEL_FOR_SM(N_INTERNAL_MODEL_MAX) ! Submodel number for                 CSUBMODL.40    
!                                  each submodel id                                CSUBMODL.41    
!                                                                                  CSUBMODL.42    
! Namelist for information in 3.                                                   CSUBMODL.43    
      NAMELIST/NSUBMODL/N_INTERNAL_MODEL,N_SUBMODEL_PARTITION                      CSUBMODL.44    
     *,INTERNAL_MODEL_LIST,SUBMODEL_FOR_IM                                         CSUBMODL.45    
!                                                                                  CSUBMODL.46    
!  4. Lists calculated in model from user interface supplied arrays -              CSUBMODL.47    
!     - experiment specific.                                                       CSUBMODL.48    
      INTEGER                                                                      CSUBMODL.49    
     * N_INTERNAL_FOR_SM(SUBMODEL_ID_MAX)  ! No of internal models in              CSUBMODL.50    
!              each submodel partition indexed by sm identifier                    CSUBMODL.51    
     *,SUBMODEL_PARTITION_LIST(N_SUBMODEL_PARTITION_MAX)    ! List of              CSUBMODL.52    
!              submodel partition identifiers                                      CSUBMODL.53    
     *,SUBMODEL_PARTITION_INDEX(INTERNAL_ID_MAX)  ! Submodel partition             CSUBMODL.54    
!              identifier indexed by internal model identifier                     CSUBMODL.55    
     *,INTERNAL_MODEL_INDEX(INTERNAL_ID_MAX)      ! Sequence number of             CSUBMODL.56    
!              internal model indexed by internal model identifier:                CSUBMODL.57    
!              required to map from id to STASH internal model sequence            CSUBMODL.58    
      LOGICAL                                                                      CSUBMODL.59    
     * LAST_IM_IN_SM(INTERNAL_ID_MAX)      ! Last internal model within            CSUBMODL.60    
!                                a submodel partition if .TRUE.,                   CSUBMODL.61    
!                                indexed by internal model id.                     CSUBMODL.62    
! Common block for information in 3. and 4.                                        CSUBMODL.63    
      COMMON/SUBMODL/N_INTERNAL_MODEL,N_SUBMODEL_PARTITION,                        CSUBMODL.64    
     *     INTERNAL_MODEL_LIST,SUBMODEL_FOR_IM,SUBMODEL_FOR_SM,                    CSUBMODL.65    
     *     N_INTERNAL_FOR_SM,SUBMODEL_PARTITION_LIST,                              CSUBMODL.66    
     *     SUBMODEL_PARTITION_INDEX,                                               CSUBMODL.67    
     *     INTERNAL_MODEL_INDEX,                                                   CSUBMODL.68    
     *     LAST_IM_IN_SM                                                           CSUBMODL.69    
                                                                                   CSUBMODL.70    
!                                                                                  CSUBMODL.71    
!  5. Time information specifying coupling frequencies between internal            CSUBMODL.72    
!     models and submodels, and multipliers, indexed by sequence of                CSUBMODL.73    
!     internal models and submodels (ie left to right along node tree).            CSUBMODL.74    
!     {Not required at this release}.                                              CSUBMODL.75    
!                                                                                  CSUBMODL.76    
! Namelists for information in 5. {Not required at this release}                   CSUBMODL.77    
!                                                                                  CSUBMODL.78    
!                                                                                  CSUBMODL.79    
!  6. Lists of coupling nodes defining coupling frequencies between                CSUBMODL.80    
!     internal models and between submodel partitions. (Not defined                CSUBMODL.81    
!     yet at this release).                                                        CSUBMODL.82    
!CALL CNODE                                                                        CSUBMODL.83    
!                                                                                  CSUBMODL.84    
!  7. Variables dealing with general coupling switches at the control              CSUBMODL.85    
!     level. {These will require revision at the next release when                 CSUBMODL.86    
!     coupling between internal models is dealt with more generally.               CSUBMODL.87    
!     Logicals below are set in routine SETGRCTL.}                                 CSUBMODL.88    
                                                                                   CSUBMODL.89    
      LOGICAL                                                                      CSUBMODL.90    
     * new_im   ! new internal model next group of timesteps if .true.             CSUBMODL.91    
     *,new_sm   ! new submodel dump  next group of timesteps if .true.             CSUBMODL.92    
                                                                                   CSUBMODL.93    
      COMMON/CSUBMGRP/new_im,new_sm                                                CSUBMODL.94    
                                                                                   CSUBMODL.95    
      INTEGER SUBMODEL_IDENT                                                       CSUBMODL.96    
      COMMON/SUBMODID/SUBMODEL_IDENT                                               CSUBMODL.97    
C                                                                                  CSUBMODL.98    
C                                                                                  CSUBMODL.99    
                                                                                   RAD_ALL.7519  
      REAL          GAS_NOW      !OUT Gas concentration at time step               RAD_ALL.7520  
      INTEGER       GAS_INDEX_MAX!IN                                               RAD_ALL.7521  
     &            , MAX_SCENARIO_PTS ! IN                                          RAD_ALL.7522  
      INTEGER       GAS_YEAR(MAX_SCENARIO_PTS)   !IN                               RAD_ALL.7523  
      REAL          GAS_CONC(MAX_SCENARIO_PTS)   !IN                               RAD_ALL.7524  
      REAL          GAS_RATE(MAX_SCENARIO_PTS)   !IN                               RAD_ALL.7525  
      INTEGER       ICODE        !OUT Return code: successful=0                    RAD_ALL.7526  
      CHARACTER*(*) CMESSAGE     !OUT Error message if ICODE >0                    RAD_ALL.7527  
C*                                                                                 RAD_ALL.7528  
                                                                                   RAD_ALL.7529  
! Common blocks                                                                    RAD_ALL.7530  
                                                                                   RAD_ALL.7531  
CLL  Comdeck: CTIME ----------------------------------------------------           CTIME.2     
CLL                                                                                CTIME.3     
CLL  Purpose: Derived model time/step information including start/end              CTIME.4     
CLL           step numbers and frequencies (in steps) of interface field           CTIME.5     
CLL           generation, boundary field updating, ancillary field                 CTIME.6     
CLL           updating; and assimilation start/end times.                          CTIME.7     
CLL           NB: Last three are set by IN_BOUND, INANCCTL, IN_ACCTL.              CTIME.8     
CLL           Also contains current time/date information, current                 CTIME.9     
CLL           step number (echoed in history file) and steps-per-group.            CTIME.10    
CLL                                                                                CTIME.11    
CLL  Model            Modification history from model version 3.0:                 CTIME.12    
CLL version  Date                                                                  CTIME.13    
CLL                                                                                CTIME.14    
CLL   3.1   13/02/93  Dimension arrays A_INTERFACE_STEPS/FSTEP/LSTEP               CTIME.15    
CLL                   D. Robinson                                                  CTIME.16    
CLL   3.3  01/02/94  Add BASIS_TIME_DAYS to BASIS_TIME_SECS for revised            CTIME.17    
CLL                  (32-bit portable) model clock calculations. TCJ               CTIME.18    
CLL  3.4  13/12/94  Change COMMOM name from CTIME to CTIMED to satisfy             CTIME.19    
CLL                 DEC alpha compiler for portability.  N.Farnon.                 CTIME.20    
CLL  3.5  12/04/95  Stage 1 submodel changes: move to dimensioning                 CTIME.21    
CLL                 arrays by internal model. R.Rawlins                            CTIME.22    
CLL  4.4  06/10/97  Data time of IAU dump added. Adam Clayton.                     CTIME.23    
CLL                                                                                CTIME.24    
CLL Programming standard :                                                         CTIME.25    
CLL                                                                                CTIME.26    
CLL  Logical components covered: C0                                                CTIME.27    
CLL                                                                                CTIME.28    
CLL Project task :                                                                 CTIME.29    
CLL                                                                                CTIME.30    
CLL External documentation: Unified Model documentation paper No:                  CTIME.31    
CLL                         Version:                                               CTIME.32    
CLL                                                                                CTIME.33    
CLLEND -----------------------------------------------------------------           CTIME.34    
C                                                                                  CTIME.35    
      INTEGER                                                                      CTIME.36    
     1     I_YEAR,                 ! Current model time (years)                    CTIME.37    
     2     I_MONTH,                ! Current model time (months)                   CTIME.38    
     3     I_DAY,                  ! Current model time (days)                     CTIME.39    
     4     I_HOUR,                 ! Current model time (hours)                    CTIME.40    
     5     I_MINUTE,               ! Current model time (minutes)                  CTIME.41    
     6     I_SECOND,               ! Current model time (seconds)                  CTIME.42    
     7     I_DAY_NUMBER,           ! Current model time (day no)                   CTIME.43    
     8     PREVIOUS_TIME(7),       ! Model time at previous step                   CTIME.44    
     9     DATA_MINUS_BASIS_HRS,   ! Data time - basis time (hours)                CTIME.45    
     A     IAU_DATA_TIME(6)        ! Data time of IAU dump.                        CTIME.46    
      INTEGER                                                                      CTIME.47    
!    1       A_STEP,              ! Atmosphere step no since basis time            CTIME.48    
!    2       O_STEP,              ! Ocean step no since basis time                 CTIME.49    
!    3       A_GROUP,             ! Number of atmos steps per group                CTIME.50    
!    4       O_GROUP,             ! Number of ocean steps per group                CTIME.51    
     &       BASIS_TIME_DAYS,     ! Integral no of days to basis time              CTIME.52    
     3       BASIS_TIME_SECS,     ! No of seconds-in-day at basis time             CTIME.53    
     4       FORECAST_HRS         ! Hours since Data Time (ie T+nn)                CTIME.54    
!    5       A_TARGET_END_STEP,   ! Finishing atmos step number this run           CTIME.55    
!    6       O_TARGET_END_STEP    ! Finishing ocean step number this run           CTIME.56    
      INTEGER                                                                      CTIME.57    
!    1       A_INTERFACE_STEPS(4),! Freq of interface field generation             CTIME.58    
!    2       O_INTERFACE_STEPS,   !  in steps                                      CTIME.59    
!    3       A_INTERFACE_FSTEP(4),! Start steps for atmosphere and ocean           CTIME.60    
!    4       O_INTERFACE_FSTEP,   !  interface field generation                    CTIME.61    
!    5       A_INTERFACE_LSTEP(4),! End steps for atmosphere and ocean             CTIME.62    
!    6       O_INTERFACE_LSTEP,   !  interface field generation                    CTIME.63    
!    7       A_BOUNDARY_STEPS,    ! Frequency of updating of boundary              CTIME.64    
!    8       O_BOUNDARY_STEPS,    !  fields in steps                               CTIME.65    
!    &       O_BNDARY_OFFSET,  !  No of steps from boundary data prior             CTIME.66    
!                                 to basis time to model basis time                CTIME.67    
!    9       A_ANCILLARY_STEPS,   ! Lowest frequency for updating of               CTIME.68    
!    A       O_ANCILLARY_STEPS,   !  ancillary fields in steps                     CTIME.69    
!    B       A_ASSIM_FIRSTSTEP,   ! Start steps for atmosphere and ocean           CTIME.70    
!    C       O_ASSIM_FIRSTSTEP,   !  assimilation                                  CTIME.71    
!    D       A_ASSIM_STEPS,       ! Number of atmosphere and ocean                 CTIME.72    
!    E       O_ASSIM_STEPS,       !  assimilation steps to analysis                CTIME.73    
!    F       A_ASSIM_EXTRASTEPS,  ! Number of atmosphere and ocean                 CTIME.74    
!    G       O_ASSIM_EXTRASTEPS,  !  assimilation steps after analysis             CTIME.75    
     H       O_CLM_FIRSTSTEP,     ! First } step for ocean climate                 CTIME.76    
     I       O_CLM_LASTSTEP       ! Last  } increments                             CTIME.77    
C                                                                                  CTIME.78    
      COMMON /CTIMED/ I_YEAR,I_MONTH,I_DAY,I_HOUR,I_MINUTE,I_SECOND,               CTIME.79    
     1               I_DAY_NUMBER,PREVIOUS_TIME,                                   CTIME.80    
!    2               A_STEP,O_STEP,A_GROUP,O_GROUP,                                CTIME.81    
     &               BASIS_TIME_DAYS,BASIS_TIME_SECS,                              CTIME.82    
     &               FORECAST_HRS,DATA_MINUS_BASIS_HRS,                            CTIME.83    
     &               IAU_DATA_TIME,                                                CTIME.84    
!    3               A_TARGET_END_STEP, O_TARGET_END_STEP,                         CTIME.85    
!    4               A_INTERFACE_STEPS, O_INTERFACE_STEPS,                         CTIME.86    
!    5               A_INTERFACE_FSTEP, O_INTERFACE_FSTEP,                         CTIME.87    
!    6               A_INTERFACE_LSTEP, O_INTERFACE_LSTEP,                         CTIME.88    
!    7               A_BOUNDARY_STEPS,  O_BOUNDARY_STEPS,                          CTIME.89    
!    &               O_BNDARY_OFFSET,                                              CTIME.90    
!    8               A_ANCILLARY_STEPS, O_ANCILLARY_STEPS,                         CTIME.91    
!    9               A_ASSIM_FIRSTSTEP, O_ASSIM_FIRSTSTEP,                         CTIME.92    
!    A               A_ASSIM_STEPS,     O_ASSIM_STEPS,                             CTIME.93    
!    B               A_ASSIM_EXTRASTEPS,O_ASSIM_EXTRASTEPS,                        CTIME.94    
     C               O_CLM_FIRSTSTEP,   O_CLM_LASTSTEP                             CTIME.95    
                                                                                   CTIME.96    
      INTEGER                                                                      CTIME.97    
     * STEPim(INTERNAL_ID_MAX)            ! Step no since basis time               CTIME.98    
     *,GROUPim(INTERNAL_ID_MAX)           ! Number of steps per group              CTIME.99    
     *,TARGET_END_STEPim(INTERNAL_ID_MAX) ! Finish step number this run            CTIME.100   
                                                                                   CTIME.101   
      REAL                                                                         CTIME.102   
     & SECS_PER_STEPim(INTERNAL_ID_MAX)   ! Timestep length in secs                CTIME.103   
                                                                                   CTIME.104   
      INTEGER                                                                      CTIME.105   
     * INTERFACE_STEPSim(MAX_N_INTF,INTERNAL_ID_MAX)     ! Frequency of            CTIME.106   
!                              ! interface field generation in steps               CTIME.107   
     *,INTERFACE_FSTEPim(MAX_N_INTF,INTERNAL_ID_MAX)     ! Start steps             CTIME.108   
!                              ! for interface field generation                    CTIME.109   
     *,INTERFACE_LSTEPim(MAX_N_INTF,INTERNAL_ID_MAX)     ! End   steps             CTIME.110   
!                              ! for interface field generation                    CTIME.111   
     *,BOUNDARY_STEPSim(INTERNAL_ID_MAX)                 ! Frequency of            CTIME.112   
!                              ! updating boundary fields in steps                 CTIME.113   
     *,BNDARY_OFFSETim(INTERNAL_ID_MAX)!  No of steps from boundary data           CTIME.114   
!                              ! prior to basis time to model basis time           CTIME.115   
     *,ANCILLARY_STEPSim(INTERNAL_ID_MAX) ! Lowest frequency for                   CTIME.116   
!                              ! updating of ancillary fields in steps             CTIME.117   
     *,ASSIM_FIRSTSTEPim(INTERNAL_ID_MAX) ! Start steps for assimilation           CTIME.118   
     *,ASSIM_STEPSim(INTERNAL_ID_MAX)     ! Number of assimilation                 CTIME.119   
!                              ! steps to analysis                                 CTIME.120   
     *,ASSIM_EXTRASTEPSim(INTERNAL_ID_MAX)! Number of assimilation                 CTIME.121   
!                              ! steps after analysis                              CTIME.122   
      COMMON/CTIMEE/                                                               CTIME.123   
     & STEPim,GROUPim,TARGET_END_STEPim                                            CTIME.124   
     &,INTERFACE_STEPSim                                                           CTIME.125   
     &,INTERFACE_FSTEPim                                                           CTIME.126   
     &,INTERFACE_LSTEPim                                                           CTIME.127   
     &,BOUNDARY_STEPSim                                                            CTIME.128   
     &,BNDARY_OFFSETim                                                             CTIME.129   
     &,ANCILLARY_STEPSim                                                           CTIME.130   
     &,ASSIM_FIRSTSTEPim                                                           CTIME.131   
     &,ASSIM_STEPSim                                                               CTIME.132   
     &,ASSIM_EXTRASTEPSim                                                          CTIME.133   
     &,SECS_PER_STEPim                                                             CTIME.134   
!                                                                                  CTIME.135   
                                                                                   RAD_ALL.7533  
!     Local variables                                                              RAD_ALL.7534  
                                                                                   RAD_ALL.7535  
      INTEGER       INDEX       ! to subscript gas concs for NOW_TIME              RAD_ALL.7536  
      INTEGER       I           ! Loop over indices                                RAD_ALL.7537  
      INTEGER       YEAR_IN_SECS! Year length in seconds                           RAD_ALL.7538  
      INTEGER       NOW_TIME_DAY, NOW_TIME_SEC                                     RAD_ALL.7539  
!                               ! Time now in days/secs from time zero             RAD_ALL.7540  
      INTEGER       GAS_YR_DAY1,  GAS_YR_SEC1                                      RAD_ALL.7541  
!                               ! Time in days/secs of current GAS_YEAR            RAD_ALL.7542  
      INTEGER       TIME1                                                          RAD_ALL.7543  
!                               ! The same converted to seconds                    RAD_ALL.7544  
      INTEGER       GAS_YR_DAY2,  GAS_YR_SEC2                                      RAD_ALL.7545  
!                               ! Time in days/secs of next GAS_YEAR               RAD_ALL.7546  
                                                                                   RAD_ALL.7547  
!     Check that GASCNST namelist is defined for this year                         RAD_ALL.7548  
      IF ( I_YEAR .LT. GAS_YEAR(1) ) THEN                                          RAD_ALL.7549  
        ICODE = 8325                                                               RAD_ALL.7550  
        CMESSAGE = 'GAS_CALC: no gas data for this year'                           RAD_ALL.7551  
        RETURN                                                                     RAD_ALL.7552  
      ENDIF                                                                        RAD_ALL.7553  
                                                                                   RAD_ALL.7554  
!     Loop over I to find correct index for current NOW_TIME                       RAD_ALL.7555  
      INDEX = 0                                                                    RAD_ALL.7556  
      DO I=1, GAS_INDEX_MAX                                                        RAD_ALL.7557  
        IF ( I_YEAR .GE. GAS_YEAR(I) ) INDEX = INDEX+1                             RAD_ALL.7558  
      ENDDO                                                                        RAD_ALL.7559  
                                                                                   RAD_ALL.7560  
!     Calculate time now in seconds                                                RAD_ALL.7561  
      CALL TIME2SEC (I_YEAR, I_MONTH, I_DAY, I_HOUR, I_MINUTE, I_SECOND,           RAD_ALL.7562  
     &              0, 0, NOW_TIME_DAY, NOW_TIME_SEC, .TRUE.)                      RAD_ALL.7563  
                                                                                   RAD_ALL.7564  
!     If gas rate at current year is non zero calculate new GAS_NOW                RAD_ALL.7565  
!     by considering compound increases of GAS_RATE(1:INDEX)                       RAD_ALL.7566  
      IF ( GAS_RATE(INDEX) .GT. 0. ) THEN                                          RAD_ALL.7567  
        YEAR_IN_SECS = 360 * 86400                                                 RAD_ALL.7568  
        CALL TIME2SEC (GAS_YEAR(INDEX), 1, 1, 0, 0, 0,                             RAD_ALL.7569  
     &                0, 0, GAS_YR_DAY1, GAS_YR_SEC1, .TRUE.)                      RAD_ALL.7570  
        GAS_NOW = GAS_CONC(1)                                                      RAD_ALL.7571  
        DO I=1, INDEX-1                                                            RAD_ALL.7572  
          IF ( GAS_RATE(I) .LT. 0. ) THEN                                          RAD_ALL.7573  
             GAS_NOW = GAS_CONC(I+1)                                               RAD_ALL.7574  
           ELSE                                                                    RAD_ALL.7575  
             GAS_NOW = GAS_NOW *                                                   RAD_ALL.7576  
     &            ( GAS_RATE(I) ** REAL(GAS_YEAR(I+1)-GAS_YEAR(I)) )               RAD_ALL.7577  
          ENDIF                                                                    RAD_ALL.7578  
        ENDDO                                                                      RAD_ALL.7579  
!       GAS_NOW now holds the concentration in year INDEX - need only              RAD_ALL.7580  
!       update it to the current year.                                             RAD_ALL.7581  
        GAS_NOW=GAS_NOW*(GAS_RATE(INDEX)**                                         RAD_ALL.7582  
     &    REAL(((NOW_TIME_DAY-GAS_YR_DAY1)*86400+                                  RAD_ALL.7583  
     &          NOW_TIME_SEC-GAS_YR_SEC1)/YEAR_IN_SECS))                           RAD_ALL.7584  
                                                                                   RAD_ALL.7585  
!     Otherwise calculate by linear interpolation between respective               RAD_ALL.7586  
!     GAS concentrations of given years.                                           RAD_ALL.7587  
      ELSE                                                                         RAD_ALL.7588  
        CALL TIME2SEC (GAS_YEAR(INDEX), 1, 1, 0, 0, 0,                             RAD_ALL.7589  
     &                0, 0, GAS_YR_DAY1, GAS_YR_SEC1, .TRUE.)                      RAD_ALL.7590  
        CALL TIME2SEC (GAS_YEAR(INDEX+1), 1, 1, 0, 0, 0,                           RAD_ALL.7591  
     &                0, 0, GAS_YR_DAY2, GAS_YR_SEC2, .TRUE.)                      RAD_ALL.7592  
        TIME1   = GAS_YR_DAY1*86400 - GAS_YR_SEC1                                  RAD_ALL.7593  
        GAS_NOW = GAS_CONC(INDEX) +                                                RAD_ALL.7594  
     &          ( GAS_CONC(INDEX+1) - GAS_CONC(INDEX) )                            RAD_ALL.7595  
     & * REAL ( NOW_TIME_DAY*86400 + NOW_TIME_SEC - TIME1 )                        RAD_ALL.7596  
     &      / REAL ( GAS_YR_DAY2*86400 + GAS_YR_SEC2 - TIME1 )                     RAD_ALL.7597  
      ENDIF                                                                        RAD_ALL.7598  
                                                                                   RAD_ALL.7599  
      RETURN                                                                       RAD_ALL.7600  
      END   
