c_ ---------------------------------------------------------------------
c_ RCS lines preceded by "c_ "
c_ ---------------------------------------------------------------------
c_
c_ $Source: /home/orr/WWW/Abiotic/boundcond/RCS/try_c_interp.f,v $ 
c_ $Revision: 1.2 $
c_ $Date: 1999/10/04 10:41:58 $   ;  $State: Exp $
c_ $Author: orr $ ;  $Locker:  $
c_
c_ ---------------------------------------------------------------------
c_ $Log: try_c_interp.f,v $
c_ Revision 1.2  1999/10/04 10:41:58  orr
c_ Modified to demonstrate/test new scenario CIS92A
c_
c_ Revision 1.1  1999/04/26 13:52:31  orr
c_ Initial revision
c_
c_ ---------------------------------------------------------------------
c_ 
      PROGRAM try_c_interp
c     ------------------------------------------------------------------
c     Provides example of code to call "c_interp" and use results
c
c     James Orr, LSCE/CEA-CNRS, Saclay, France, 20 April 1999
c     ------------------------------------------------------------------

      IMPLICIT NONE 

      INTEGER imt,jmt
      PARAMETER (imt=360,jmt=180)

      REAL lat_center(imt,jmt)
      INTEGER latzon(imt,jmt) 
      REAL atmc14(imt,jmt)

      INTEGER nzon14
      PARAMETER (nzon14=3)

      INTEGER it
      INTEGER iz

      REAL year_model(10)
      REAL atmc14_t(nzon14), atmco2_t

      CHARACTER*4 futr_scen
 
      COMMON /latinfo/ lat_center

      INTEGER ientry, i, j
      SAVE ientry

      DATA ientry/0/
      ientry = ientry + 1
 
      futr_scen ='CIS9'

c     In the example below, "year_model" is specified a priori. 
c     Conversely, when you call the routine "c_interp" in your code,
c     "year_model" corresponds to the timestep of your simulation,
c     converted to decimal years. For example, 
c         year_model = 1765.0 + it/ntspyr
c     WHERE "it" is the timestep of your model, and
c           "ntspyr" is your model's number of timesteps per year.

c      DATA year_model /1764., 1765., 1800., 1900., 1954.5,
c    &                 1963., 1995., 1995.5, 2300., 2301./
      DATA year_model /1764., 1765., 1800., 1900., 
     &                 1990., 1990.5, 1991.0, 1992.5, 2099.5, 2100./

      DO it=1,10
c       CALL the ROUTINE that initiates the cascade of routines to
c       make the interpolation
c       ------------------------------------------------------------------
        CALL c_interp(year_model(it), futr_scen, atmco2_t, atmc14_t)
        WRITE(*,*) year_model(it), atmco2_t, (atmc14_t(iz), iz=1,3)
      END DO 

c     Using atmco2_t:
c     ---------------
c     For CO2, use the scalar value "atmco2_t" as is for atmospheric
c     CO2.  Note: OCMIP-2 models are to be run with a 1-box atmosphere
c     for CO2.

c     Using atmc14_t:
c     ----------------
c     For C-14, do NOT use 3-member array "atmc14_t" directly.  
c     Instead, for better computational efficiency, construct a 
c     2-D surface array (atmc14) in order to avoid including IF's 
c     in DO-loops each time step. For example use the 1st step below
c     only at the beginning of your program.  Then invoke the second step
c     each timestep.

c     (1) Build, just once, the mask as a function of (i,j), with 
c         different values for 90S-20S, 20S-20N, and 20N-90N.
      IF (ientry .EQ. 1) THEN
          DO j=1,jmt
            DO i=1,imt
              IF (lat_center(i,j) .LT. -20.)              THEN
                  latzon(i,j) = 1
              ELSE IF (lat_center(i,j) .GE.  -20.  .AND. 
     &                 lat_center(i,j) .LE. 20.)          THEN
                  latzon(i,j) = 2
              ELSE IF (lat_center(i,j) .GT. 20.)          THEN
                  latzon(i,j) = 3
              ENDIF
            END DO
          END DO
      END IF 

c     (2) Loop, every timestep, to partition atmospheric C-14 which
c         overlyies each surface grid box according to the latitude 
c         at its center:
      DO j=1,jmt
        DO i=1,imt
          atmc14(i,j) = atmc14_t(latzon(i,j))
        END DO
      END DO

      STOP
      END









