!-----------------------BEGIN NOTICE -- DO NOT EDIT-----------------------
! NASA Goddard Space Flight Center Land Information System (LIS) v7.2
!
! Copyright (c) 2015 United States Government as represented by the
! Administrator of the National Aeronautics and Space Administration.
! All Rights Reserved.
!-------------------------END NOTICE -- DO NOT EDIT-----------------------
#include "LIS_misc.h"
!BOP
!
! !ROUTINE: ibis_main
! \label{ibis_main}
!
! !REVISION HISTORY:
!  This subroutine is generated with the Model Implementation Toolkit developed
!  by Shugong Wang for the NASA Land Information System Version 7. The initial 
!  specification of the subroutine is defined by Sujay Kumar. 
!
!   9/4/14: Shugong Wang; initial implementation for ibis with LIS-7
!   2/7/18: Soni Yatheendradas; code added for OPTUE to work
!
! !INTERFACE:
subroutine ibis_main(n)
! !USES:
    use LIS_coreMod
    use LIS_histDataMod
    use LIS_timeMgrMod, only : LIS_isAlarmRinging
    use LIS_constantsMod,  only : LIS_CONST_RHOFW
    use LIS_logMod, only     : LIS_logunit, LIS_endrun
    use LIS_FORC_AttributesMod 
    use ibis_lsmMod
   !use other modules
  USE Utils, ONLY :tmstmp2,lati,julday

  USE InitAll, ONLY : InitA,InitB

  USE Options, ONLY : idate,idatec,idatep,tod,tod2,ifday,ifday2,dtt,intg,initlz,ilwrad,iswrad,epsflt,istrt,filta,&
                      DELTAIN,DELTAOUT,maxtim,UNDIMENSION,lon_site,lat_site,type_veg ! LGG dt

  USE Constants, ONLY: &
       r8,             &
       i8,             &
       pi

  USE Sfc_Ibis_Interface, ONLY : Ibis_Interface

  USE Sizes,ONLY :ibMax,jbMax,kMax

  USE FieldsPhysics, ONLY: iMask,MskAnt

  USE AtmosModel, ONLY : RunAtmosModel,FinalizeAtmosModel,RunAtmosModel1D,&
       gu,gv,gq,gt,gps,dcupr_sib,&
       dlspr_sib,radvbc_sib,radnbc_sib,radvdc_sib,radndc_sib,& 
       dlwbot_sib,cosz_sib,ws,psb_g,bps_g,tseam ,tsea,slrad ,&
       tsurf,qsurf,zorl,tmtx,qmtx,umtx ,sigki ,delsig,latic,longc,slhf,sshf,swdown, &
       RunAtmosModel1DB
! LGG  USE Sfc_Ibis_Fiels, ONLY:nsoilay

 USE Sfc_Ibis_Fiels , Only : spinmax ,isimco2 ,doalb,  &
        isimveg ,isimfire,nband, nsoilay, nsnolay,nlpoints,&
        pi,stef,vonk,grav,tmelt,hfus,hvap,hsub,ch2o,npft, &
        cice,cair,cvap,rair,rvap,cappa,rhow,co2init,epsilon,&
	ginvap  ,gsuvap  ,gtrans,gtransu,gtransl,grunof,& 
        gdrain  ,gadjust ,a10td,a10ancub,a10ancuc,a10ancls, & 
        a10ancl3,a10ancl4,a10scalparamu,a10daylightu,a10scalparaml,&
        a10daylightl,vmax_pft,tau15,kc15,ko15,cimax,gammaub,alpha3,&
        theta3,beta3,coefmub,coefbub,gsubmin,gammauc,coefmuc,coefbuc ,&
        gsucmin,gammals,coefmls,coefbls,gslsmin,gammal3,coefml3, &
        coefbl3,gsl3min,gammal4,alpha4,theta4,beta4,coefml4,coefbl4, &
        gsl4min, wliqu,wliqumax,wsnou,wsnoumax,tum,tu,tu0,wliqs,wliqsmax,& 
        wsnos,wsnosmax,ts,wliql,wliqlmax,wsnol,wsnolmax,tl,topparu,&
        topparl,fl,fu,lai,sai,rhoveg,tauveg,orieh,oriev,wliqmin, &
        wsnomin,t12,tdripu,tblowu,tdrips,tblows,t34,tdripl,tblowl,&
        ztop,alaiml,zbot,alaimu,froot,q34,q12,su,cleaf,dleaf,ss	,& 
        cstem,dstem,sl,cgrass,ciub,ciuc,exist,csub,gsub,csuc,gsuc,&
        agcub,agcuc,ancub,ancuc,totcondub,totconduc,cils,cil3,&	 
        cil4,csls,gsls,csl3,gsl3,csl4,gsl4,agcls,agcl4,agcl3,ancls,&	 
        ancl4,ancl3,totcondls,totcondl3,totcondl4,chu,chs,chl,frac,& 
        tlsub,z0sno,rhos,consno,hsnotop,hsnomin,fimin,fimax,fi,&     
        tsno,hsno,sand,clay,poros,wsoim,wsoi,wsoi0,wisoi,consoi,zwpmax, wpud,&	
        wipud,wpudmax, qglif ,tsoim ,tsoi,tsoi0,hvasug,hvasui,albsav,albsan,&
        tg,ti,z0soi,swilt,sfield,stressl,stressu,stresstl,stresstu,&
        csoi,rhosoi,hsoi,suction,bex,upsoiu,upsoil,heatg,heati,&
        hydraul,porosflo,ibex,bperm,hflo,o2conc,co2conc,cbiow,&
        sapfrac,cbior ,adrain,adsnow,adaet,adtrunoff,& 
        adsrunoff,addrainage,adrh,adsnod,adsnof,adwsoi,adtsoi, &
        adwisoi,adtlaysoi,adwlaysoi,adwsoic,adtsoic,adco2mic,adco2root, & 
        adco2soi,adco2ratio,adnmintot,decompl,decomps,tnmin,amrain,&     
        amsnow,amaet,amtrunoff,amsrunoff,amdrainage,amtemp,&    
        amqa,amsolar,amirup,amirdown,amsens,amlatent,amlaiu,& 
        amlail,amtsoi,amwsoi,amwisoi,amvwc,amawc,amsnod,amsnof,amnpp,adnpp,& 
        amnpptot,amco2mic,amco2root,amco2soi,amco2ratio,amneetot, &
        amnmintot,amts2,amtransu,amtransl,amsuvap,aminvap,amalbedo,&
        amtsoil,amwsoil,amwisoil,tnpptot,&
	aysolar,ayirup,ayirdown,aysens,aylatent,ayprcp,&    
        ayaet,aytrans,aytrunoff,aysrunoff,aydrainage,aydwtot,aywsoi, &
        aywisoi,aytsoi,ayvwc,ayawc,aystresstu,aystresstl,aygpp,aygpptot,&  
        aynpp,aynpptot,ayco2mic,ayco2root,ayco2soi,ayneetot,ayrootbio, & 
        aynmintot,ayalit,ayblit,aycsoi,aycmic,ayanlit,aybnlit,aynsoi,ayalbedo, &    
        totalit,totrlit,totcsoi,totcmic,totanlit,totrnlit,totnsoi,&   
        totnmic,totlit,totfall,totnlit,firefac,wtot,storedn,yrleach,& 
        ynleach,adfalll,adfallr,adfallw,falll,fallr,fallw,clitlm,clitls,clitrm,clitrs,clitwm,&  
        clitws,csoislop,csoislon,csoipas,clitll,clitrl,clitwl,tw,&
        tc,agddu,tempu,agddl,templ,dropu,dropls,dropl4,dropl3,plai,adplai,&
        deltat,gdd0,gdd0this,tcthis,twthis,tcmin,gdd5,gdd5this,TminL,&	
        TminU,Twarm,GDD,aleaf,awood,cbiol,aroot,specla,td ,vzero,&  
        biomass,totlaiu,totlail,totbiou,totbiol,woodnorm,vegtype0,&
        tauwood0,tauwood,tauleaf,tauroot,xminlai,cdisturb,ayanpp,&
        ayanpptot,garea,asurd,asuri,ndaypm,idateprev,iyear0,&
        ndtimes,nmtimes,nytimes,nppdummy,tco2root,&
        tneetot,tco2mic,iMaskIBIS,&
        ynleach_p ,tnmin_p   ,totnmic_p ,totnlit_p ,totanlit_p, &
        totrnlit_p,totnsoi_p ,storedn_p ,adcbiol,adcbior,adcbiow,beta1,beta2


  USE IbisOutput, ONLY : Grd,RunOutput,RunOutput1D,RunOutput1D_Grads, Init_IbisOutput
  
    implicit none
! !ARGUMENTS:
    integer, intent(in)  :: n
    integer              :: t
    integer              :: i
    real                 :: dt
    real                 :: lat, lon
    integer              :: row, col
    integer              :: year, month, day, hour, minute, second
    logical              :: alarmCheck

!
! !DESCRIPTION:
!  This is the entry point for calling the ibis physics.
!  This routine calls the {\tt ibis\_driver\_36 } routine that performs the
!  land surface computations, to solve for water and energy equations.

!  The arguments are:
!  \begin{description}
!  \item[n]
!    index of the nest
!  \end{description}
!EOP

! define variables for ibis
    character(len=256)   :: tmp_landuse_tbl_name   ! IBIS model landuse parameter table [-]
    character(len=256)   :: tmp_soil_tbl_name      ! IBIS model soil parameter table [-]
    character(len=256)   :: tmp_gen_tbl_name       ! IBIS model general parameter table [-]
    character(len=256)   :: tmp_ibis_tbl_name    ! ibis parameter table [-]
    character(len=256)   :: tmp_landuse_scheme_name ! landuse classification scheme [-]
    character(len=256)   :: tmp_soil_scheme_name   ! soil classification scheme [-]
    integer              :: tmp_dveg_opt           ! vegetation model [-]
    integer              :: tmp_crs_opt            ! canopy stomatal resistance [-]
    integer              :: tmp_btr_opt            ! soil moisture factor for stomatal resistance [-]
    integer              :: tmp_run_opt            ! runoff and groundwater [-]
    integer              :: tmp_sfc_opt            ! surface layer drag coefficients (CH & CM) [-]
    integer              :: tmp_frz_opt            ! supercooled liquid water [-]
    integer              :: tmp_inf_opt            ! frozen soil permeability [-]
    integer              :: tmp_rad_opt            ! radiation transfer [-]
    integer              :: tmp_alb_opt            ! snow surface albedo [-]
    integer              :: tmp_snf_opt            ! rainfall & snowfall [-]
    integer              :: tmp_tbot_opt           ! lower boundary of soil temperature [-]
    integer              :: tmp_stc_opt            ! snow/soil temperature time scheme [-]
    integer              :: tmp_nslcats            ! the number of total soil types in parameter table [-]
    integer              :: tmp_nlucats            ! the number of total land cover types in parameter table [-]
    integer              :: tmp_nslpcats           ! the number of total slope category for IBIS baseflow [-]
    real                 :: tmp_latitude           ! latitude in decimal degree [-]
    real                 :: tmp_longitude          ! longitude in decimal degree [-]
    integer              :: tmp_year               ! year of the current time step [-]
    integer              :: tmp_month              ! month of the current time step [-]
    integer              :: tmp_day                ! day of the current time step [-]
    integer              :: tmp_hour               ! hour of the current time step [-]
    integer              :: tmp_minute             ! minute of the current time step [-]
    real                 :: tmp_dt                 ! time step in seconds [s]
    real                 :: tmp_albd(2)
    real                 :: tmp_albi(2)
    integer              :: tmp_nsoil              ! number of soil layers [-]
    real, allocatable    :: tmp_sldpth(:)          ! thickness of soil layers [-]
    integer              :: tmp_nsnow              ! maximum number of snow layers [-]
    real, allocatable    :: tmp_shdfac_monthly(:)  ! monthly values for green vegetation fraction [-]
    integer              :: tmp_vegetype           ! land cover type index [-]
    integer              :: tmp_soiltype           ! soil type index [-]
    integer              :: tmp_slopetype          ! slope type for IBIS baseflow [-]
    integer              :: tmp_urban_vegetype     ! urban land cover type index [-]
    integer              :: tmp_ice_flag           ! ice flag: 0 = no ice, 1 = ice [-]
    integer              :: tmp_st_flag            ! surface type 1=soil, 2=lake [-]
    integer              :: tmp_sc_idx             ! soil color type [-]
    integer              :: tmp_iz0tlnd            ! option of Chen adjustment of Czil [-]
    real, allocatable    :: tmp_smceq(:)           ! equilibrium soil water content [m^3 m-3]
    real                 :: tmp_tair               ! air temperature [K]
    real                 :: tmp_psurf              ! air pressure [Pa]
    real                 :: tmp_wind_e             ! eastward wind speed [m s-1]
    real                 :: tmp_wind_n             ! northward wind speed [m s-1]
    real                 :: tmp_qair               ! near Surface Specific Humidity [kg kg-1]
    real                 :: tmp_swdown             ! downward solar radiation [w/m2]
    real                 :: tmp_lwdown             ! downward longwave radiation [w/m2]
    real                 :: tmp_prcp               ! total precip (rainfall+snowfall) Rate [kg m-2 s-1]   
    !real                 :: tmp_rainf              ! rainfall Rate [kg m-2 s-1]
    !real                 :: tmp_snowf              ! snowfall Rate [kg m-2 s-1]
    real                 :: tmp_tbot               ! deep-layer soil temperature [K]
    real                 :: tmp_pblh               ! planetary boundary layer height [m]
    real                 :: tmp_zlvl               ! reference height of temperature and humidity [m]
    real                 :: tmp_albold             ! snow albedo at last time step [-]
    real                 :: tmp_sneqvo             ! snow mass at the last time step [mm]
    real, allocatable    :: tmp_sstc(:)            ! snow/soil temperature [K]
    real, allocatable    :: tmp_sh2o(:)            ! volumetric liquid soil moisture [m^3 m-3]
    real, allocatable    :: tmp_smc(:)             ! volumetric soil moisture, ice + liquid [m^3 m-3]
    real                 :: tmp_tah                ! canopy air temperature [K]
    real                 :: tmp_eah                ! canopy air vapor pressure [Pa]
    real                 :: tmp_fwet               ! wetted or snowed fraction of canopy [-]
    real                 :: tmp_canliq             ! intercepted liquid water [mm]
    real                 :: tmp_canice             ! intercepted ice mass [mm]
    real                 :: tmp_tv                 ! vegetation temperature [K]
    real                 :: tmp_tg                 ! ground temperature [K]
    real                 :: tmp_qsnow              ! snowfall on the ground [mm s-1]
    integer              :: tmp_isnow              ! actual number of snow layers [-]
    real, allocatable    :: tmp_zss(:)             ! snow/soil layer-bottom depth from snow surface [m]
    real                 :: tmp_snowh              ! snow height [m]
    real                 :: tmp_sneqv              ! snow water equivalent [mm]
    real, allocatable    :: tmp_snowice(:)         ! snow-layer ice [mm]
    real, allocatable    :: tmp_snowliq(:)         ! snow-layer liquid water [mm]
    real                 :: tmp_zwt                ! depth to water table [m]
    real                 :: tmp_wa                 ! water storage in aquifer [mm]
    real                 :: tmp_wt                 ! water in aquifer and saturated soil [mm]
    real                 :: tmp_wslake             ! lake water storage [mm]
    real                 :: tmp_lfmass             ! leaf mass [g/m2]
    real                 :: tmp_rtmass             ! mass of fine roots [g/m2]
    real                 :: tmp_stmass             ! stem mass [g/m2]
    real                 :: tmp_wood               ! mass of wood including woody roots [g/m2]
    real                 :: tmp_stblcp             ! stable carbon in deep soil [g/m2]
    real                 :: tmp_fastcp             ! short-lived carbon in shallow soil [g/m2]
    real                 :: tmp_lai                ! leaf area index [-]
    real                 :: tmp_sai                ! stem area index [-]
    real                 :: tmp_cm                 ! momentum drag coefficient [m s-1]
    real                 :: tmp_ch                 ! sensible heat exchange coefficient [m s-1]
    real                 :: tmp_tauss              ! snow aging term [-]
    real                 :: tmp_smcwtd             ! soil water content between bottom of the soil and water table [m^3 m-3]
    real                 :: tmp_deeprech           ! recharge to or from the water table when deep [m]
    real                 :: tmp_rech               ! recharge to or from the water table when shallow [m]
    real                 :: tmp_fsa                ! total absorbed solar radiation [W m-2]
    real                 :: tmp_fsr                ! total reflected solar radiation [W m-2]
    real                 :: tmp_fira               ! total net longwave radiation to atmosphere [W m-2]
    real                 :: tmp_fsh                ! total sensible heat to atmosphere [W m-2]
    real                 :: tmp_ssoil              ! ground heat flux to soil [W m-2]
    real                 :: tmp_fcev               ! canopy evaporative heat to atmosphere [W m-2]
    real                 :: tmp_fgev               ! ground evaporative heat to atmosphere [W m-2]
    real                 :: tmp_fctr               ! transpiration heat to atmosphere [W m-2]
    real                 :: tmp_ecan               ! evaporation rate of canopy water [kg m-2 s-1]
    real                 :: tmp_etran              ! transpiration rate [kg m-2 s-1]
    real                 :: tmp_edir               ! direct evaporation rate from surface [kg m-2 s-1]
    real                 :: tmp_trad               ! surface radiative temperature [K]
    real                 :: tmp_subsnow            ! snow sublimation rate [kg m-2 s-1]
    real                 :: tmp_tgb                ! ground temperature [K]
    real                 :: tmp_tgv                ! ground surface temperature [K]
    real                 :: tmp_t2mv               ! 2-m air temperature over vegetated part [K]
    real                 :: tmp_t2mb               ! 2-m height air temperature [K]
    real                 :: tmp_q2v                ! 2-m specific humidity over vegetation [kg kg-1]
    real                 :: tmp_q2b                ! 2-m air specific humidity [kg kg-1]
    real                 :: tmp_runsrf             ! surface runoff [kg m-2 s-1]
    real                 :: tmp_runsub             ! baseflow (saturation excess) [kg m-2 s-1]
    real                 :: tmp_apar               ! photosynthesis active energy by canopy [W m-2]
    real                 :: tmp_psn                ! total photosynthesis of CO2 [umol m-2 s-1]
    real                 :: tmp_sav                ! solar radiation absorbed by vegetation [W m-2]
    real                 :: tmp_sag                ! solar radiation absorbed by ground [W m-2]
    real                 :: tmp_fsno               ! snow-cover fraction on the ground [-]
    real                 :: tmp_nee                ! net ecosystem exchange of CO2 [g/m2s]
    real                 :: tmp_gpp                ! net instantaneous assimilation of carbon [g/m2s]
    real                 :: tmp_npp                ! net primary productivity of carbon [g/m2s]
    real                 :: tmp_fveg               ! green vegetation fraction [-]
    real                 :: tmp_albedo             ! surface albedo [-]
    real                 :: tmp_qsnbot             ! melting water out of snow bottom [kg m-2 s-1]
    real                 :: tmp_ponding            ! surface ponding [mm]
    real                 :: tmp_ponding1           ! surface ponding1 [mm]
    real                 :: tmp_ponding2           ! surface ponding2 [mm]
    real                 :: tmp_rssun              ! sunlit stomatal resistance [s/m]
    real                 :: tmp_rssha              ! shaded stomatal resistance [s/m]
    real                 :: tmp_bgap               ! between canopy gap fraction for beam [-]
    real                 :: tmp_wgap               ! within canopy gap fraction for beam [-]
    real                 :: tmp_chv                ! sensible heat exchange coefficient over vegetated fraction [m s-1]
    real                 :: tmp_chb                ! sensible heat exchange coefficient over bare-ground fraction [m s-1]
    real                 :: tmp_emissi             ! surface emissivity [-]
    real                 :: tmp_shg                ! ground sensible heat [W m-2]
    real                 :: tmp_shc                ! canopy sensible heat [W m-2]
    real                 :: tmp_shb                ! bare ground sensible heat [W m-2]
    real                 :: tmp_evg                ! ground evaporation heat [W m-2]
    real                 :: tmp_evb                ! bare ground evaporation heat [W m-2]
    real                 :: tmp_ghv                ! ground heat flux [W m-2]
    real                 :: tmp_ghb                ! bare ground heat flux [W m-2]
    real                 :: tmp_irg                ! ground net long wave radiation [W m-2]
    real                 :: tmp_irc                ! canopy net long wave radiation [W m-2]
    real                 :: tmp_irb                ! bare ground net long wave radiation [W m-2]
    real                 :: tmp_tr                 ! transpiration heat [W m-2]
    real                 :: tmp_evc                ! canopy evaporation heat [W m-2]
    real                 :: tmp_chleaf             ! leaf exchange coefficient [-]
    real                 :: tmp_chuc               ! under canopy exchange coefficient [-]
    real                 :: tmp_chv2               ! sensible heat exchange coefficient over vegetated fraction [-]
    real                 :: tmp_chb2               ! sensible heat exchange coefficient over bare-ground [-]
    real                 :: tmp_fpice              ! snow fraction in precipitation [-]
    real                 :: tmp_sfcheadrt          ! extra output for WRF-HYDRO [m]
    
    ! SY: Begin for enabling OPTUE
    ! SY: Begin corresponding to REDPRM
    ! SY: Begin SOIL PARAMETERS 
    real                 :: tmp_csoil          ! vol. soil heat capacity [j/m3/K] 
    real                 :: tmp_bexp           ! B parameter 
    real                 :: tmp_dksat          ! saturated soil hydraulic conductivity
    real                 :: tmp_dwsat          ! saturated soil hydraulic diffusivity
    real                 :: tmp_psisat         ! saturated soil matric potential 
    real                 :: tmp_quartz         ! soil quartz content 
    real                 :: tmp_smcmax         ! porosity, saturated value of soil moisture (volumetric) 
    real                 :: tmp_smcref         ! reference soil moisture (field capacity) 
    real                 :: tmp_smcwlt         ! wilting point soil moisture (volumetric) 
    ! SY: End SOIL PARAMETERS 
    ! SY: Begin UNIVERSAL PARAMETERS
    real                 :: tmp_czil           ! Calculate roughness length of heat 
    real                 :: tmp_frzk           ! frozen ground parameter 
    real                 :: tmp_refdk          ! parameters in the surface runoff parameteriz.
    real                 :: tmp_refkdt         ! parameters in the surface runoff parameteriz. 
    real                 :: tmp_slope          ! slope index (0 - 1)
    ! SY: End UNIVERSAL PARAMETERS
    ! SY: Begin PARAMETERS for prescribed VEGETATION evolution in time
    real                 :: tmp_topt           ! optimum transpiration air temperature 
    real                 :: tmp_rgl            ! parameter used in radiation stress function
    real                 :: tmp_rsmax          ! maximum stomatal resistance
    real                 :: tmp_rsmin          ! minimum Canopy Resistance [s/m]
    real                 :: tmp_hs             ! parameter used in vapor pressure deficit function 
    real                 :: tmp_nroot
    ! SY: End PARAMETERS for prescribed VEGETATION evolution in time 
    ! SY: End corresponding to REDPRM
    ! SY: Begin corresponding to read_mp_veg_parameters
    real                 :: tmp_CH2OP          !     maximum intercepted h2o per unit lai+sai [mm]
    real                 :: tmp_DLEAF          !     characteristic leaf dimension [m]
    real                 :: tmp_Z0MVT          !     momentum roughness length [m]
    real                 :: tmp_HVT            !     top of canopy [m]
    real                 :: tmp_HVB            !     bottom of canopy [m]
    real                 :: tmp_RC             !     tree crown radius [m]
    real                 :: tmp_RHOL1          !     leaf reflectance (1=vis)
    real                 :: tmp_RHOL2          !     leaf reflectance (2=nir)
    real                 :: tmp_RHOS1          !     stem reflectance (1=vis)
    real                 :: tmp_RHOS2          !     stem reflectance (2=nir)
    real                 :: tmp_TAUL1          !     leaf transmittance (1=vis)
    real                 :: tmp_TAUL2          !     leaf transmittance (2=nir)
    real                 :: tmp_TAUS1          !     stem transmittance (1=vis)
    real                 :: tmp_TAUS2          !     stem transmittance (2=nir)
    real                 :: tmp_XL             !     leaf/stem orientation index
    real                 :: tmp_CWPVT          !     empirical canopy wind parameter
    real                 :: tmp_C3PSN          !     photosynthetic pathway (0. = c4, 1. = c3)
    real                 :: tmp_KC25           !     co2 michaelis-menten constant at 25c [pa]
    real                 :: tmp_AKC            !     q10 for kc25
    real                 :: tmp_KO25           !     o2 michaelis-menten constant at 25c [pa]
    real                 :: tmp_AKO            !     q10 for ko25
    real                 :: tmp_AVCMX          !     q10 for vcmx25
    real                 :: tmp_AQE            !     q10 for qe25
    real                 :: tmp_LTOVRC         !     leaf turnover [1/s]
    real                 :: tmp_DILEFC         !     coeficient for leaf stress death [1/s]
    real                 :: tmp_DILEFW         !     coeficient for leaf stress death [1/s]
    real                 :: tmp_RMF25          !     leaf maintenance respiration at 25c [umol co2/m**2/s]
    real                 :: tmp_SLA            !     single-side leaf area per Kg [m2/kg]
    real                 :: tmp_FRAGR          !     fraction of growth respiration. original was 0.3
    real                 :: tmp_TMIN           !     minimum temperature for photosynthesis [k]
    real                 :: tmp_VCMX25         !     maximum rate of carboxylation at 25c. unit [umol co2/m**2/s]
    real                 :: tmp_TDLEF          !     characteristic T for leaf freezing [K]
    real                 :: tmp_BP             !     minimum leaf conductance [umol/m**2/s]
    real                 :: tmp_MP             !     slope of conductance-to-photosynthesis relationship
    real                 :: tmp_QE25           !     quantum efficiency at 25c [umol co2 / umol photon]
    real                 :: tmp_RMS25          !     stem maintenance respiration at 25c [umol co2/kg bio/s]
    real                 :: tmp_RMR25          !     root maintenance respiration at 25c [umol co2/kg bio/s]
    real                 :: tmp_ARM            !     q10 for maintenance respiration
    real                 :: tmp_FOLNMX         !     foliage nitrogen concentration when f(n)=1 [%]
    real                 :: tmp_WDPOOL         !     wood pool (switch 1 or 0) depending on woody or not [-]
    real                 :: tmp_WRRAT          !     wood to non-wood ratio
    real                 :: tmp_MRP            !     microbial respiration parameter [umol co2 /kg c/ s]
    ! SY: End corresponding to read_mp_veg_parameters
    ! SY: End for enabling OPTUE

    ! Code added by Shugong Wang 09/12/2014
    real                 :: soil_temp(ibis_struc(n)%nsoil)   
    real                 :: snow_temp(ibis_struc(n)%nsnow)
    real                 :: AvgSurfT_out, Qle_out, Evap_out
    ! Code added by David Mocko
    real                 :: TWS_out, Rainf_out, Snowf_out
    real                 :: bdsno
    ! Code added by Rhae Sung Kim 
    real                 :: layersd
  !LGG for IBIS

  character(len=256)        :: ttxt
  INTEGER          :: retint
  INTEGER          :: ljdt
  INTEGER          :: limlow
  !INTEGER          :: nband
  INTEGER          :: jdt
  REAL(KIND=r8)   :: ahour
  REAL(KIND=r8)   :: dtc3x
  INTEGER          :: ktp 
  INTEGER          :: kt
  INTEGER          :: ktm
  INTEGER          :: jb
  !INTEGER          :: i
  INTEGER          :: nmax
  INTEGER          :: lrec 
  INTEGER          :: juliand_in
  REAL             :: Var_out

  INTEGER        :: nsx     (1)   	 
  REAL(KIND=r8) :: mskant8  (1,1)	 
  REAL(KIND=r8) :: colrad   (1,1)	 
  REAL(KIND=r8) :: snow     (1,1)	 
  REAL(KIND=r8) :: speedm   (1,1)	 
  REAL(KIND=r8) :: taux     (1,1)	 
  REAL(KIND=r8) :: tauy     (1,1)	 
  REAL(KIND=r8) :: sens     (1,1)	 
  REAL(KIND=r8) :: evap     (1,1)	 
  REAL(KIND=r8) :: umom     (1,1)	 
  REAL(KIND=r8) :: vmom     (1,1)	 
  REAL(KIND=r8) :: rmi      (1,1)	 
  REAL(KIND=r8) :: rhi      (1,1)	 
  REAL(KIND=r8) :: z0       (1,1) 	 
  REAL(KIND=r8) :: ustar    (1,1) 	 
  REAL(KIND=r8) :: hc       (1,1) 	 
  REAL(KIND=r8) :: hg       (1,1) 	 
  REAL(KIND=r8) :: ec       (1,1) 	 
  REAL(KIND=r8) :: eg       (1,1) 	 
  REAL(KIND=r8) :: ts2      (1,1)  	 
  REAL(KIND=r8) :: qs2      (1,1) 	 
  REAL(KIND=r8) :: qsfc     (1,1) 	 
  REAL(KIND=r8) :: tsfc     (1,1) 	 
  REAL(KIND=r8) :: z0sea    (1,1)  	 
  REAL(KIND=r8) :: d        (1,1) 	 
  REAL(KIND=r8) :: cu       (1,1) 	 
  REAL(KIND=r8) :: Ustarm   (1,1)	       
  REAL(KIND=r8) :: tgrd     (1,1) 	 
  REAL(KIND=r8) :: roff     (1,1) 	 
  REAL(KIND=r8) :: ect      (1,1) 	 
  REAL(KIND=r8) :: eci      (1,1)  	 
  REAL(KIND=r8) :: egt      (1,1) 	 
  REAL(KIND=r8) :: egi      (1,1) 	 
  REAL(KIND=r8) :: egs      (1,1) 	 
  REAL(KIND=r8) :: rho      (1,1)  	 
  REAL(KIND=r8) :: bstar    (1,1) 


  REAL :: tmp_colrad
  REAL :: gt4 ! gt temperature in IBIS but to accomodate real*4

  real(KIND=r8)  :: ibis_tair               ! air temperature [K]
  real(KIND=r8)  :: ibis_psurf              ! air pressure [Pa]
  real(KIND=r8)  :: ibis_wind_e             ! eastward wind speed [m s-1]
  real(KIND=r8)  :: ibis_wind_n             ! northward wind speed [m s-1]
  real(KIND=r8)  :: ibis_qair               ! near Surface Specific Humidity [kg kg-1]
  real(KIND=r8)  :: ibis_swdown             ! downward solar radiation [w/m2]
  real(KIND=r8)  :: ibis_lwdown             ! downward longwave radiation [w/m2]
  real(KIND=r8)  :: ibis_prcp               ! total precip (rainfall+snowfall) Rate [kg m-2 s-1]   
  real(KIND=r8)  :: ibis_latitude           ! latitude in decimal degree [-]
  real(KIND=r8)  :: ibis_longitude          ! longitude in decimal degree [-]
  integer        :: ibis_year               ! year of the current time step [-]
  integer        :: ibis_month              ! month of the current time step [-]
  integer        :: ibis_day                ! day of the current time step [-]
  integer        :: ibis_hour               ! hour of the current time step [-]
  integer        :: ibis_minute             ! minute of the current time step [-]
  real(KIND=r8)  :: ibis_dt                 ! time step in seconds [s]
  integer        :: ibis_juliand            ! julian day of the current time step [-]
  real(KIND=r8)  :: ibis_xlh
  real(KIND=r8)  :: ibis_xsh

    logical              :: key, kkey


!        print *, "LGG in ibis_main begining... 1"
  
    allocate( tmp_sldpth( ibis_struc(n)%nsoil ) )
    allocate( tmp_shdfac_monthly( 12 ) )
    allocate( tmp_smceq( ibis_struc(n)%nsoil ) )
    allocate( tmp_sstc( ibis_struc(n)%nsoil+ibis_struc(n)%nsnow) )
    allocate( tmp_sh2o( ibis_struc(n)%nsoil ) )
    allocate( tmp_smc( ibis_struc(n)%nsoil ) )
    allocate( tmp_zss( ibis_struc(n)%nsoil+ibis_struc(n)%nsnow) )
    allocate( tmp_snowice( ibis_struc(n)%nsnow ) )
    allocate( tmp_snowliq( ibis_struc(n)%nsnow ) )
!        print *, "LGG in ibis_main begining..."
    ! check ibis alarm. If alarm is ring, run model. 
    alarmCheck = LIS_isAlarmRinging(LIS_rc, "ibis model alarm")
!    print *, 'LGG in ibis_main entering: alarm ', alarmCheck
    if (alarmCheck) Then
       do t = 1, LIS_rc%npatch(n, LIS_rc%lsm_index)
          dt = LIS_rc%ts
          row = LIS_surface(n, LIS_rc%lsm_index)%tile(t)%row
          col = LIS_surface(n, LIS_rc%lsm_index)%tile(t)%col
          lat = LIS_domain(n)%grid(LIS_domain(n)%gindex(col, row))%lat
          lon = LIS_domain(n)%grid(LIS_domain(n)%gindex(col, row))%lon

            ! retrieve forcing data from ibis_struc(n)%ibis(t) and assign to local variables
            ! tair: air temperature
            tmp_tair       = ibis_struc(n)%ibis(t)%tair   / ibis_struc(n)%forc_count
            ibis_struc(n)%ibis(t)%sfctmp = tmp_tair
            ! psurf: air pressure
            tmp_psurf      = ibis_struc(n)%ibis(t)%psurf  / ibis_struc(n)%forc_count
 
            ! wind_e: eastward wind speed
            tmp_wind_e     = ibis_struc(n)%ibis(t)%wind_e / ibis_struc(n)%forc_count
 
            ! wind_n: northward wind speed
            tmp_wind_n     = ibis_struc(n)%ibis(t)%wind_n / ibis_struc(n)%forc_count
 
            ! qair: near Surface Specific Humidity
            tmp_qair       = ibis_struc(n)%ibis(t)%qair   / ibis_struc(n)%forc_count
 
            ! swdown: downward solar radiation
            tmp_swdown     = ibis_struc(n)%ibis(t)%swdown / ibis_struc(n)%forc_count
 
            ! lwdown: downward longwave radiation
            tmp_lwdown     = ibis_struc(n)%ibis(t)%lwdown / ibis_struc(n)%forc_count
 
            ! prcp: precipitation Rate
            tmp_prcp       = ibis_struc(n)%ibis(t)%prcp   / ibis_struc(n)%forc_count
 
!            if(t.eq.13859) write(111,fmt='(i4.4,i2.2,i2.2,i2.2,i2.2,8E14.3)') &
!                 LIS_rc%yr,LIS_rc%mo,LIS_rc%da, LIS_rc%hr, LIS_rc%mn, &
!                 tmp_tair, tmp_qair, tmp_swdown, tmp_lwdown,tmp_wind_n,tmp_wind_e,tmp_psurf,&
!                 tmp_prcp
            ! 
            ! check validity of tair
            if(tmp_tair .eq. LIS_rc%udef) then
                write(LIS_logunit, *) "undefined value found for forcing variable tair in ibis"
                write(LIS_logunit, *) "for tile ", t, "latitude = ", lat, "longitude = ", lon
                call LIS_endrun()
            endif
            ! check validity of psurf
            if(tmp_psurf .eq. LIS_rc%udef) then
                write(LIS_logunit, *) "undefined value found for forcing variable psurf in ibis"
                write(LIS_logunit, *) "for tile ", t, "latitude = ", lat, "longitude = ", lon
                call LIS_endrun()
            endif
            ! check validity of wind_e
            if(tmp_wind_e .eq. LIS_rc%udef) then
                write(LIS_logunit, *) "undefined value found for forcing variable wind_e in ibis"
                write(LIS_logunit, *) "for tile ", t, "latitude = ", lat, "longitude = ", lon
                call LIS_endrun()
            endif
            ! check validity of wind_n
            if(tmp_wind_n .eq. LIS_rc%udef) then
                write(LIS_logunit, *) "undefined value found for forcing variable wind_n in ibis"
                write(LIS_logunit, *) "for tile ", t, "latitude = ", lat, "longitude = ", lon
                call LIS_endrun()
            endif
            ! check validity of qair
            if(tmp_qair .eq. LIS_rc%udef) then
                write(LIS_logunit, *) "undefined value found for forcing variable qair in ibis"
                write(LIS_logunit, *) "for tile ", t, "latitude = ", lat, "longitude = ", lon
                call LIS_endrun()
            endif
            ! check validity of swdown
            if(tmp_swdown .eq. LIS_rc%udef) then
                write(LIS_logunit, *) "undefined value found for forcing variable swdown in ibis"
                write(LIS_logunit, *) "for tile ", t, "latitude = ", lat, "longitude = ", lon
                call LIS_endrun()
            endif
            ! check validity of lwdown
            if(tmp_lwdown .eq. LIS_rc%udef) then
                write(LIS_logunit, *) "undefined value found for forcing variable lwdown in ibis"
                write(LIS_logunit, *) "for tile ", t, "latitude = ", lat, "longitude = ", lon
                call LIS_endrun()
            endif
            ! check validity of prcp
            if(tmp_prcp .eq. LIS_rc%udef) then
                write(LIS_logunit, *) "undefined value found for forcing variable prcp in ibis"
                write(LIS_logunit, *) "for tile ", t, "latitude = ", lat, "longitude = ", lon
                call LIS_endrun()
            endif
            ! 
            tmp_latitude  = lat
            tmp_longitude = lon
            tmp_year   = LIS_rc%yr
            tmp_month  = LIS_rc%mo
            tmp_day    = LIS_rc%da
            tmp_hour   = LIS_rc%hr
            tmp_minute = LIS_rc%mn

            ! get parameters
            tmp_landuse_tbl_name                    = ibis_struc(n)%landuse_tbl_name
            tmp_soil_tbl_name                       = ibis_struc(n)%soil_tbl_name
            tmp_gen_tbl_name                        = ibis_struc(n)%gen_tbl_name
            tmp_ibis_tbl_name                     = ibis_struc(n)%ibis_tbl_name
            tmp_landuse_scheme_name                 = ibis_struc(n)%landuse_scheme_name
            tmp_soil_scheme_name                    = ibis_struc(n)%soil_scheme_name
            tmp_dveg_opt                            = ibis_struc(n)%dveg_opt
            tmp_crs_opt                             = ibis_struc(n)%crs_opt
            tmp_btr_opt                             = ibis_struc(n)%btr_opt
            tmp_run_opt                             = ibis_struc(n)%run_opt
            tmp_sfc_opt                             = ibis_struc(n)%sfc_opt
            tmp_frz_opt                             = ibis_struc(n)%frz_opt
            tmp_inf_opt                             = ibis_struc(n)%inf_opt
            tmp_rad_opt                             = ibis_struc(n)%rad_opt
            tmp_alb_opt                             = ibis_struc(n)%alb_opt
            tmp_snf_opt                             = ibis_struc(n)%snf_opt
            tmp_tbot_opt                            = ibis_struc(n)%tbot_opt
            tmp_stc_opt                             = ibis_struc(n)%stc_opt
            tmp_nslcats                             = ibis_struc(n)%nslcats
            tmp_nlucats                             = ibis_struc(n)%nlucats
            tmp_nslpcats                            = ibis_struc(n)%nslpcats
            tmp_dt                                  = ibis_struc(n)%dt
            tmp_nsoil                               = ibis_struc(n)%nsoil
            tmp_sldpth(:)                           = ibis_struc(n)%sldpth(:)
            tmp_nsnow                               = ibis_struc(n)%nsnow
            tmp_shdfac_monthly(:)                   = ibis_struc(n)%ibis(t)%shdfac_monthly(:)
            tmp_vegetype                            = ibis_struc(n)%ibis(t)%vegetype
            tmp_soiltype                            = ibis_struc(n)%ibis(t)%soiltype
            tmp_slopetype                           = ibis_struc(n)%ibis(t)%slopetype
            tmp_urban_vegetype                      = ibis_struc(n)%urban_vegetype
            tmp_ice_flag                            = ibis_struc(n)%ice_flag
            tmp_st_flag                             = ibis_struc(n)%st_flag
            tmp_sc_idx                              = ibis_struc(n)%sc_idx
            tmp_iz0tlnd                             = ibis_struc(n)%iz0tlnd
            tmp_smceq(:)                            = ibis_struc(n)%ibis(t)%smceq(:)
            tmp_tbot                                = ibis_struc(n)%ibis(t)%tbot
            tmp_pblh                                = ibis_struc(n)%ibis(t)%pblh
            !tmp_zlvl                                = ibis_struc(n)%zlvl

            ! get state variables
            tmp_albold      = ibis_struc(n)%ibis(t)%albold
            tmp_sneqvo      = ibis_struc(n)%ibis(t)%sneqvo
            tmp_sstc(:)     = ibis_struc(n)%ibis(t)%sstc(:)
            tmp_sh2o(:)     = ibis_struc(n)%ibis(t)%sh2o(:)
            tmp_smc(:)      = ibis_struc(n)%ibis(t)%smc(:)
            tmp_tah         = ibis_struc(n)%ibis(t)%tah
            tmp_eah         = ibis_struc(n)%ibis(t)%eah
            tmp_fwet        = ibis_struc(n)%ibis(t)%fwet
            tmp_canliq      = ibis_struc(n)%ibis(t)%canliq
            tmp_canice      = ibis_struc(n)%ibis(t)%canice
            tmp_tv          = ibis_struc(n)%ibis(t)%tv
            tmp_tg          = ibis_struc(n)%ibis(t)%tg
            tmp_qsnow       = ibis_struc(n)%ibis(t)%qsnow
            tmp_isnow       = ibis_struc(n)%ibis(t)%isnow
            tmp_zss(:)      = ibis_struc(n)%ibis(t)%zss(:)
            tmp_snowh       = ibis_struc(n)%ibis(t)%snowh
            tmp_sneqv       = ibis_struc(n)%ibis(t)%sneqv
            tmp_snowice(:)  = ibis_struc(n)%ibis(t)%snowice(:)
            tmp_snowliq(:)  = ibis_struc(n)%ibis(t)%snowliq(:)
            tmp_zwt         = ibis_struc(n)%ibis(t)%zwt
            tmp_wa          = ibis_struc(n)%ibis(t)%wa
            tmp_wt          = ibis_struc(n)%ibis(t)%wt
            tmp_wslake      = ibis_struc(n)%ibis(t)%wslake
            tmp_lfmass      = ibis_struc(n)%ibis(t)%lfmass
            tmp_rtmass      = ibis_struc(n)%ibis(t)%rtmass
            tmp_stmass      = ibis_struc(n)%ibis(t)%stmass
            tmp_wood        = ibis_struc(n)%ibis(t)%wood
            tmp_stblcp      = ibis_struc(n)%ibis(t)%stblcp
            tmp_fastcp      = ibis_struc(n)%ibis(t)%fastcp
            tmp_lai         = ibis_struc(n)%ibis(t)%lai
            tmp_sai         = ibis_struc(n)%ibis(t)%sai
            tmp_cm          = ibis_struc(n)%ibis(t)%cm
            tmp_ch          = ibis_struc(n)%ibis(t)%ch
            tmp_tauss       = ibis_struc(n)%ibis(t)%tauss
            tmp_smcwtd      = ibis_struc(n)%ibis(t)%smcwtd
            tmp_deeprech    = ibis_struc(n)%ibis(t)%deeprech
            tmp_rech        = ibis_struc(n)%ibis(t)%rech
            tmp_zlvl        = ibis_struc(n)%ibis(t)%zlvl
            tmp_albd      = ibis_struc(n)%ibis(t)%albd
            tmp_albi      = ibis_struc(n)%ibis(t)%albi

            ! SY: Begin for enabling OPTUE: get calibratable parameters
            ! SY: Begin corresponding to REDPRM
            tmp_csoil       = ibis_struc(n)%ibis(t)%csoil
            tmp_bexp        = ibis_struc(n)%ibis(t)%bexp
            tmp_dksat       = ibis_struc(n)%ibis(t)%dksat
            tmp_dwsat       = ibis_struc(n)%ibis(t)%dwsat
            tmp_psisat      = ibis_struc(n)%ibis(t)%psisat
            tmp_quartz      = ibis_struc(n)%ibis(t)%quartz
            tmp_smcmax      = ibis_struc(n)%ibis(t)%smcmax
            tmp_smcref      = ibis_struc(n)%ibis(t)%smcref
            tmp_smcwlt      = ibis_struc(n)%ibis(t)%smcwlt
            tmp_czil        = ibis_struc(n)%ibis(t)%czil
            tmp_frzk        = ibis_struc(n)%ibis(t)%frzk
            tmp_refdk       = ibis_struc(n)%ibis(t)%refdk
            tmp_refkdt      = ibis_struc(n)%ibis(t)%refkdt
            tmp_slope       = ibis_struc(n)%ibis(t)%slope
            tmp_topt        = ibis_struc(n)%ibis(t)%topt
            tmp_rgl         = ibis_struc(n)%ibis(t)%rgl
            tmp_rsmax       = ibis_struc(n)%ibis(t)%rsmax
            tmp_rsmin       = ibis_struc(n)%ibis(t)%rsmin
            tmp_hs          = ibis_struc(n)%ibis(t)%hs
            tmp_nroot       = ibis_struc(n)%ibis(t)%nroot
            ! SY: End corresponding to REDPRM
            ! SY: Begin corresponding to read_mp_veg_parameters
            tmp_CH2OP       = ibis_struc(n)%ibis(t)%CH2OP
            tmp_DLEAF       = ibis_struc(n)%ibis(t)%DLEAF
            tmp_Z0MVT       = ibis_struc(n)%ibis(t)%Z0MVT
            tmp_HVT         = ibis_struc(n)%ibis(t)%HVT
            tmp_HVB         = ibis_struc(n)%ibis(t)%HVB
            tmp_RC          = ibis_struc(n)%ibis(t)%RC
            tmp_RHOL1       = ibis_struc(n)%ibis(t)%RHOL1
            tmp_RHOL2       = ibis_struc(n)%ibis(t)%RHOL2
            tmp_RHOS1       = ibis_struc(n)%ibis(t)%RHOS1
            tmp_RHOS2       = ibis_struc(n)%ibis(t)%RHOS2
            tmp_TAUL1       = ibis_struc(n)%ibis(t)%TAUL1
            tmp_TAUL2       = ibis_struc(n)%ibis(t)%TAUL2
            tmp_TAUS1       = ibis_struc(n)%ibis(t)%TAUS1
            tmp_TAUS2       = ibis_struc(n)%ibis(t)%TAUS2
            tmp_XL          = ibis_struc(n)%ibis(t)%XL
            tmp_CWPVT       = ibis_struc(n)%ibis(t)%CWPVT
            tmp_C3PSN       = ibis_struc(n)%ibis(t)%C3PSN
            tmp_KC25        = ibis_struc(n)%ibis(t)%KC25
            tmp_AKC         = ibis_struc(n)%ibis(t)%AKC
            tmp_KO25        = ibis_struc(n)%ibis(t)%KO25
            tmp_AKO         = ibis_struc(n)%ibis(t)%AKO
            tmp_AVCMX       = ibis_struc(n)%ibis(t)%AVCMX
            tmp_AQE         = ibis_struc(n)%ibis(t)%AQE
            tmp_LTOVRC      = ibis_struc(n)%ibis(t)%LTOVRC
            tmp_DILEFC      = ibis_struc(n)%ibis(t)%DILEFC
            tmp_DILEFW      = ibis_struc(n)%ibis(t)%DILEFW
            tmp_RMF25       = ibis_struc(n)%ibis(t)%RMF25
            tmp_SLA         = ibis_struc(n)%ibis(t)%SLA
            tmp_FRAGR       = ibis_struc(n)%ibis(t)%FRAGR
            tmp_TMIN        = ibis_struc(n)%ibis(t)%TMIN
            tmp_VCMX25      = ibis_struc(n)%ibis(t)%VCMX25
            tmp_TDLEF       = ibis_struc(n)%ibis(t)%TDLEF
            tmp_BP          = ibis_struc(n)%ibis(t)%BP
            tmp_MP          = ibis_struc(n)%ibis(t)%MP
            tmp_QE25        = ibis_struc(n)%ibis(t)%QE25
            tmp_RMS25       = ibis_struc(n)%ibis(t)%RMS25
            tmp_RMR25       = ibis_struc(n)%ibis(t)%RMR25
            tmp_ARM         = ibis_struc(n)%ibis(t)%ARM
            tmp_FOLNMX      = ibis_struc(n)%ibis(t)%FOLNMX
            tmp_WDPOOL      = ibis_struc(n)%ibis(t)%WDPOOL
            tmp_WRRAT       = ibis_struc(n)%ibis(t)%WRRAT
            tmp_MRP         = ibis_struc(n)%ibis(t)%MRP
            ! SY: End corresponding to read_mp_veg_parameters
            ! SY: End for enabling OPTUE: get calibratable parameter

 kkey = .FALSE.


  if (.true.) then
   if ( t .eq. 100 .AND. LIS_masterproc ) then
     kkey = .TRUE.
   else
     kkey = .FALSE.
   endif


  nsx      = 0.0_r8
  mskant8  = 0.0_r8
  colrad   = 3.140_r8/2.0_r8
  snow	   = 0.0_r8
  speedm   = 0.0_r8
  taux	   = 0.0_r8
  tauy	   = 0.0_r8
  sens	   = 0.0_r8
  evap	   = 0.0_r8
  umom	   = 0.0_r8
  vmom	   = 0.0_r8
  rmi	   = 0.0_r8
  rhi	   = 0.0_r8
  z0	   = 0.0_r8
  ustar    = 0.0_r8
  hc	   = 0.0_r8
  hg	   = 0.0_r8
  ec	   = 0.0_r8
  eg	   = 0.0_r8
  ts2	   = 0.0_r8
  qs2	   = 0.0_r8
  qsfc     = 0.0_r8
  tsfc     = 0.0_r8
  z0sea    = 0.0_r8
  d	   = 0.0_r8
  cu	   = 0.0_r8
  Ustarm   = 0.0_r8
  tgrd     = 0.0_r8
  roff     = 0.0_r8
  ect	   = 0.0_r8
  eci	   = 0.0_r8
  egt	   = 0.0_r8
  egi	   = 0.0_r8
  egs	   = 0.0_r8
  rho	   = 0.0_r8
  bstar    = 0.0_r8


        write(ttxt,*) tmp_latitude;  read(ttxt,*,iostat=retint) ibis_latitude
        write(ttxt,*) tmp_longitude; read(ttxt,*,iostat=retint) ibis_longitude
        write(ttxt,*) tmp_year;      read(ttxt,*,iostat=retint) ibis_year
        write(ttxt,*) tmp_month;     read(ttxt,*,iostat=retint) ibis_month
        write(ttxt,*) tmp_day;       read(ttxt,*,iostat=retint) ibis_day
        write(ttxt,*) tmp_hour;      read(ttxt,*,iostat=retint) ibis_hour
        write(ttxt,*) tmp_minute;    read(ttxt,*,iostat=retint) ibis_minute
        write(ttxt,*) tmp_dt;        read(ttxt,*,iostat=retint) ibis_dt
        write(ttxt,*) tmp_wind_e;    read(ttxt,*,iostat=retint) ibis_wind_e
        write(ttxt,*) tmp_wind_n;    read(ttxt,*,iostat=retint) ibis_wind_n
        write(ttxt,*) tmp_tair;      read(ttxt,*,iostat=retint) ibis_tair
        write(ttxt,*) tmp_qair;      read(ttxt,*,iostat=retint) ibis_qair
        write(ttxt,*) tmp_psurf/100;     read(ttxt,*,iostat=retint) ibis_psurf
        write(ttxt,*) tmp_prcp;      read(ttxt,*,iostat=retint) ibis_prcp !LGG Kg/s to mm/s for IBIS???
        write(ttxt,*) tmp_swdown;    read(ttxt,*,iostat=retint) ibis_swdown
        write(ttxt,*) tmp_lwdown;    read(ttxt,*,iostat=retint) ibis_lwdown
        write(ttxt,*) julday (LIS_rc%mo,LIS_rc%da,LIS_rc%yr,tod)
        read(ttxt,*,iostat=retint) ibis_juliand
        ibis_xlh=0.0        
        ibis_xsh=0.0
        
        if ( lat .gt. -11.35 .and. lat .lt. -11.25 .and. &
             lon .gt. -73.15 .and. lon .lt. -73.05 ) then

       ! WRITE(0,*)'LGG in ibis_main check lat/lon ', tmp_swdown, tmp_lwdown, t, lat, lon
        endif
        
        
        write(ttxt,*) ibis_struc(n)%ibis(t)%tg_ib;  read(ttxt,*,iostat=retint) tmp_tg
        
        if ( tmp_vegetype .eq. 16 ) then
          vegtype0=15
          ibis_struc(n)%ibis(t)%vegtype0(1,1)=15
        else
          write(ttxt,*) tmp_vegetype; read(ttxt,*,iostat=retint) vegtype0
          ibis_struc(n)%ibis(t)%vegtype0(1,1)= tmp_vegetype
        endif

        do i=1,nsoilay
          write(ttxt,*) tmp_smcmax; read(ttxt,*,iostat=retint) ibis_struc(n)%ibis(t)%poros(1,i,1)
        enddo
       ! print *, 'LGG ibis_main lat/lon scale', &
       !          ibis_struc(n)%ibis(t)%latscale(1,1),ibis_struc(n)%ibis(t)%lonscale(1,1),t
        ibis_struc(n)%ibis(t)%latscale(1,1) = ibis_latitude
        ibis_struc(n)%ibis(t)%lonscale(1,1) = ibis_longitude+360.
       ! print *, 'LGG ibis_main lat/lon scale', &
       !          ibis_struc(n)%ibis(t)%latscale(1,1),ibis_struc(n)%ibis(t)%lonscale(1,1),t
	    
            !if (t .eq. 1 ) then
            !CALL MAIN_OFFLINE
            !STOP
            !endif


!     print *, 'LGG ibis_main psurf ',t,lon_site,tmp_longitude,lat_site,tmp_latitude,type_veg, ibis_psurf
	dtc3x=dt
	idatec(4)  = LIS_rc%yr
       idatec(3)  = LIS_rc%mo
        idatec(2)  = LIS_rc%da
        idatec(1)  = LIS_rc%hr
      if ( tmp_vegetype .eq. 16 ) then
        type_veg=15
      else
        type_veg=tmp_vegetype
      endif
      lon_site=lon
      lat_site=lat
      juliand_in = julday (LIS_rc%mo,LIS_rc%da,LIS_rc%yr,tod)


     
     tod=LIS_rc%hr*3600.+LIS_rc%mn*60.-dtt
!       print *, 'LGG running MAIN_OFFLINE ',t
      ! CALL MAIN_OFFLINE
!      CALL InitB
!     print *,'LGG in ibis_main Parameters: ',t,lon,lat,ibis_struc(n)%ibis(t)%clay(1,1,1),ibis_struc(n)%ibis(t)%sand(1,1,1)      




    
  nsx    (1)   =  ibis_struc(n)%ibis(t)%nsx    
  mskant8(1,1) =  ibis_struc(n)%ibis(t)%mskant8  
  colrad (1,1) =  ibis_struc(n)%ibis(t)%colrad 
  snow   (1,1) =  ibis_struc(n)%ibis(t)%snow   
  speedm (1,1) =  ibis_struc(n)%ibis(t)%speedm 
  taux   (1,1) =  ibis_struc(n)%ibis(t)%taux   
  tauy   (1,1) =  ibis_struc(n)%ibis(t)%tauy   
  sens   (1,1) =  ibis_struc(n)%ibis(t)%sens   
  evap   (1,1) =  ibis_struc(n)%ibis(t)%evap   
  umom   (1,1) =  ibis_struc(n)%ibis(t)%umom   
  vmom   (1,1) =  ibis_struc(n)%ibis(t)%vmom   
  rmi    (1,1) =  ibis_struc(n)%ibis(t)%rmi    
  rhi    (1,1) =  ibis_struc(n)%ibis(t)%rhi    
  z0     (1,1) =  ibis_struc(n)%ibis(t)%z0     
  ustar  (1,1) =  ibis_struc(n)%ibis(t)%ustar   
  hc     (1,1) =  ibis_struc(n)%ibis(t)%hc      
  hg     (1,1) =  ibis_struc(n)%ibis(t)%hg      
  ec     (1,1) =  ibis_struc(n)%ibis(t)%ec      
  eg     (1,1) =  ibis_struc(n)%ibis(t)%eg      
  ts2    (1,1) =  ibis_struc(n)%ibis(t)%ts2     
  qs2    (1,1) =  ibis_struc(n)%ibis(t)%qs2     
  qsfc   (1,1) =  ibis_struc(n)%ibis(t)%qsfc    
  tsfc   (1,1) =  ibis_struc(n)%ibis(t)%tsfc    
  z0sea  (1,1) =  ibis_struc(n)%ibis(t)%z0sea   
  d      (1,1) =  ibis_struc(n)%ibis(t)%d       
  cu     (1,1) =  ibis_struc(n)%ibis(t)%cu      
  Ustarm (1,1) =  ibis_struc(n)%ibis(t)%Ustarm  
  tgrd   (1,1) =  ibis_struc(n)%ibis(t)%tgrd   
  roff   (1,1) =  ibis_struc(n)%ibis(t)%roff    
  ect    (1,1) =  ibis_struc(n)%ibis(t)%ect     
  eci    (1,1) =  ibis_struc(n)%ibis(t)%eci     
  egt    (1,1) =  ibis_struc(n)%ibis(t)%egt     
  egi    (1,1) =  ibis_struc(n)%ibis(t)%egi     
  egs    (1,1) =  ibis_struc(n)%ibis(t)%egs     
  rho    (1,1) =  ibis_struc(n)%ibis(t)%rho     
  bstar  (1,1) =  ibis_struc(n)%ibis(t)%bstar   
  

  key = .true.
  CALL transferin(n,t,key)
  !print *, 'LGG porosity in ibis_main ',t,ibis_struc(n)%ibis(t)%poros, tmp_smcmax
  !STOP


	    
	    
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  !      jb=1
!	nmax=1
!	nsx=0
!	dtc3x=dt
!	idatec(4)  = LIS_rc%yr
!       idatec(3)  = LIS_rc%mo
!        idatec(2)  = LIS_rc%da
!        idatec(1)  = LIS_rc%hr
!        tod        = LIS_rc%hr*3600.+LIS_rc%mn*60.
!	imask      = 1
      !LGG need to check the vegetation table equivalences between LIS and IBIS
!      if ( tmp_vegetype .eq. 16 ) then
!        type_veg=15
!      else
!        type_veg=tmp_vegetype
!      endif
!      lon_site=lon
!      lat_site=lat
!      juliand_in = julday (LIS_rc%mo,LIS_rc%da,LIS_rc%yr,tod)
! -12.874996200000000
!      if ( ( ibis_struc(n)%ibis(t)%latscale(1,1) .gt. -12.884996200000000 ) .and. &
!           ( ibis_struc(n)%ibis(t)%latscale(1,1) .lt. -12.864996200000000 ) ) then
!         print *, "lat/lon in main, before run ", t, ibis_swdown, ibis_qair,&
!           ibis_struc(n)%ibis(t)%latscale(1,1),ibis_struc(n)%ibis(t)%lonscale(1,1)
!      endif

  tod2=tod+DELTAIN
  DO ljdt=1,1
  !DO ljdt=limlow,maxtim
     !
     !     step loop starts
     !
     jdt = ljdt
     tod=tod+dtt ! LGG dt
!     print *,tod,jdt,dtt,ifday,ifday2
     tod2=tod2+dtt ! LGG dt
     IF(ABS( MOD(tod+0.03125_r8,86400.0_r8)-0.03125_r8).LT.0.0625_r8)THEN
        tod=0.0_r8
        ifday=ifday+1
     END IF
     IF(ABS( MOD(tod2+0.03125_r8,86400.0_r8)-0.03125_r8).LT.0.0625_r8)THEN
        tod2=0.0_r8
        ifday2=ifday2+1
     END IF
!     write(0,*) 'LGG in main before tmstmp2 dtc3x ', dtc3x,dtt
     CALL tmstmp2(idate,ifday,tod,idatec(1),idatec(3),idatec(2),idatec(4))
     CALL tmstmp2(idate,ifday2,tod2,idatep(1),idatep(3),idatep(2),idatep(4))
     ahour=(ifday*24.0e0_r8)+(tod/3.6e3_r8)
     !dtc3x   =dtt*REAL(intg,r8) ! LGG dt
!     write(0,*) 'LGG in main after tmstmp2 dtc3x ', dtc3x, dtt, REAL(intg,r8), ahour, tod

     IF(jdt<=2)THEN
        istrt=jdt
     ELSE
        istrt=0
     END IF

     CALL run(jdt,tod,DELTAIN,kkey,ibis_tair,ibis_psurf,ibis_wind_e,ibis_wind_n,           & 
       ibis_qair,ibis_swdown,ibis_lwdown,ibis_prcp,ibis_latitude,ibis_longitude,ibis_year, &
       ibis_month,ibis_day,ibis_hour,ibis_minute,ibis_dt,ibis_juliand,ibis_xlh,ibis_xsh)

     kt   =INT(ahour-(1.0e-2_r8))
     ktp  =INT(ahour+(dtt/3.6e3_r8)-(1.0e-2_r8)) ! LGG dt
     IF(jdt.EQ.maxtim) THEN
        ktm=kt
     END IF
     ktm=kt
  END DO
!  CALL Finalize()
!  CALL FinalizeVars()
       if (t .eq. 10 ) then
       !print *,  'AFTER IBIS wsoi ',t,wsoi
       endif
 !       print *, "VEGTYPE in main, after run ", tmp_vegetype, vegtype0, t
       
          !STOP

  ibis_struc(n)%ibis(t)%nsx     = nsx	 (1)  
  ibis_struc(n)%ibis(t)%mskant8 = mskant8(1,1)        
  ibis_struc(n)%ibis(t)%colrad  = colrad (1,1)
  ibis_struc(n)%ibis(t)%snow    = snow   (1,1)
  ibis_struc(n)%ibis(t)%speedm  = speedm (1,1)
  ibis_struc(n)%ibis(t)%taux    = taux   (1,1)
  ibis_struc(n)%ibis(t)%tauy    = tauy   (1,1)
  ibis_struc(n)%ibis(t)%sens    = sens   (1,1)
  ibis_struc(n)%ibis(t)%evap    = evap   (1,1)
  ibis_struc(n)%ibis(t)%umom    = umom   (1,1)
  ibis_struc(n)%ibis(t)%vmom    = vmom   (1,1)
  ibis_struc(n)%ibis(t)%rmi     = rmi	 (1,1)
  ibis_struc(n)%ibis(t)%rhi     = rhi	 (1,1)
  ibis_struc(n)%ibis(t)%z0      = z0	 (1,1)
  ibis_struc(n)%ibis(t)%ustar   = ustar  (1,1) 
  ibis_struc(n)%ibis(t)%hc      = hc	 (1,1) 
  ibis_struc(n)%ibis(t)%hg      = hg	 (1,1) 
  ibis_struc(n)%ibis(t)%ec      = ec	 (1,1) 
  ibis_struc(n)%ibis(t)%eg      = eg	 (1,1) 
  ibis_struc(n)%ibis(t)%ts2     = ts2	 (1,1) 
  ibis_struc(n)%ibis(t)%qs2     = qs2	 (1,1) 
  ibis_struc(n)%ibis(t)%qsfc    = qsfc   (1,1) 
  ibis_struc(n)%ibis(t)%tsfc    = tsfc   (1,1) 
  ibis_struc(n)%ibis(t)%z0sea   = z0sea  (1,1) 
  ibis_struc(n)%ibis(t)%d       = d	 (1,1) 
  ibis_struc(n)%ibis(t)%cu      = cu	 (1,1) 
  ibis_struc(n)%ibis(t)%Ustarm  = Ustarm (1,1) 
  ibis_struc(n)%ibis(t)%tgrd    = tgrd   (1,1)
  ibis_struc(n)%ibis(t)%roff    = roff   (1,1) 
  ibis_struc(n)%ibis(t)%ect     = ect	 (1,1) 
  ibis_struc(n)%ibis(t)%eci     = eci	 (1,1) 
  ibis_struc(n)%ibis(t)%egt     = egt	 (1,1) 
  ibis_struc(n)%ibis(t)%egi     = egi	 (1,1) 
  ibis_struc(n)%ibis(t)%egs     = egs	 (1,1) 
  ibis_struc(n)%ibis(t)%rho     = rho	 (1,1) 
  ibis_struc(n)%ibis(t)%bstar   = bstar  (1,1) 

!      if ( ( ibis_struc(n)%ibis(t)%latscale(1,1) .gt. -12.884996200000000 ) .and. &
!           ( ibis_struc(n)%ibis(t)%latscale(1,1) .lt. -12.864996200000000 ) ) then
!         print *, "evap in main, after run ", t, ibis_struc(n)%ibis(t)%sens, &
!                  ibis_struc(n)%ibis(t)%evap
!      endif
	  
  key = .false.
  CALL transferin(n,t,key)
  
  !WRITE(0,*)'LGG AFTER TRANSFER heatg, sens, evap',t, ibis_struc(n)%ibis(t)%heatg, ibis_struc(n)%ibis(t)%sens, &
  !                 ibis_struc(n)%ibis(t)%evap
  !STOP



	    

!LGG jusr for testing output of temperature below
!  !gt=tsoi(1,1,1)
!  write(ttxt,*) gt  
!  read(ttxt,*,iostat=retint) gt4   
!   STOP
   end if ! filter t=10

!   if ( tmp_fira/tmp_fira .ne. 1 ) then
!   print *, 'LGG in ibis_main ANTES NOAH',tmp_fira, tmp_lwdown, tmp_shdfac_monthly(3),tmp_lai,tmp_sai, tmp_latitude, tmp_longitude, &
!             tmp_irg,tmp_irc,tmp_irb, tmp_tgb, tmp_tg
!   endif

   if ( .false. ) then
  
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            call ibis_driver_36(LIS_localPet, t,tmp_landuse_tbl_name  , & ! in    - IBIS model landuse parameter table [-]
                                  tmp_soil_tbl_name     , & ! in    - IBIS model soil parameter table [-]
                                  tmp_gen_tbl_name      , & ! in    - IBIS model general parameter table [-]
                                  tmp_ibis_tbl_name   , & ! in    - ibis parameter table [-]
                                  tmp_landuse_scheme_name, & ! in    - landuse classification scheme [-]
                                  tmp_soil_scheme_name  , & ! in    - soil classification scheme [-]
                                  tmp_dveg_opt          , & ! in    - vegetation model [-]
                                  tmp_crs_opt           , & ! in    - canopy stomatal resistance [-]
                                  tmp_btr_opt           , & ! in    - soil moisture factor for stomatal resistance [-]
                                  tmp_run_opt           , & ! in    - runoff and groundwater [-]
                                  tmp_sfc_opt           , & ! in    - surface layer drag coefficients (CH & CM) [-]
                                  tmp_frz_opt           , & ! in    - supercooled liquid water [-]
                                  tmp_inf_opt           , & ! in    - frozen soil permeability [-]
                                  tmp_rad_opt           , & ! in    - radiation transfer [-]
                                  tmp_alb_opt           , & ! in    - snow surface albedo [-]
                                  tmp_snf_opt           , & ! in    - rainfall & snowfall [-]
                                  tmp_tbot_opt          , & ! in    - lower boundary of soil temperature [-]
                                  tmp_stc_opt           , & ! in    - snow/soil temperature time scheme [-]
                                  tmp_nslcats           , & ! in    - the number of total soil types in parameter table [-]
                                  tmp_nlucats           , & ! in    - the number of total land cover types in parameter table [-]
                                  tmp_nslpcats          , & ! in    - the number of total slope category for IBIS baseflow [-]
                                  tmp_latitude          , & ! in    - latitude in decimal degree [-]
                                  tmp_longitude         , & ! in    - longitude in decimal degree [-]
                                  tmp_year              , & ! in    - year of the current time step [-]
                                  tmp_month             , & ! in    - month of the current time step [-]
                                  tmp_day               , & ! in    - day of the current time step [-]
                                  tmp_hour              , & ! in    - hour of the current time step [-]
                                  tmp_minute            , & ! in    - minute of the current time step [-]
                                  tmp_dt                , & ! in    - time step in seconds [s]
                                  ibis_struc(n)%ibis(t)%alb_upd_flag,&
                                  tmp_albd            , & 
                                  tmp_albi            , & 
                                  tmp_nsoil             , & ! in    - number of soil layers [-]
                                  tmp_sldpth            , & ! in    - thickness of soil layers [-]
                                  tmp_nsnow             , & ! in    - maximum number of snow layers [-]
                                  tmp_shdfac_monthly    , & ! in    - monthly values for green vegetation fraction [-]
                                  tmp_vegetype          , & ! in    - land cover type index [-]
                                  tmp_soiltype          , & ! in    - soil type index [-]
                                  tmp_slopetype         , & ! in    - slope type for IBIS baseflow [-]
                                  tmp_urban_vegetype    , & ! in    - urban land cover type index [-]
                                  tmp_ice_flag          , & ! in    - ice flag: 0 = no ice, 1 = ice [-]
                                  tmp_st_flag           , & ! in    - surface type 1=soil, 2=lake [-]
                                  tmp_sc_idx            , & ! in    - soil color type [-]
                                  tmp_iz0tlnd           , & ! in    - option of Chen adjustment of Czil [-]
                                  tmp_smceq             , & ! in    - equilibrium soil water content [m^3 m-3]
                                  tmp_tair              , & ! in    - air temperature [K]
                                  tmp_psurf             , & ! in    - air pressure [Pa]
                                  tmp_wind_e            , & ! in    - eastward wind speed [m s-1]
                                  tmp_wind_n            , & ! in    - northward wind speed [m s-1]
                                  tmp_qair              , & ! in    - near Surface Specific Humidity [kg kg-1]
                                  tmp_swdown            , & ! in    - downward solar radiation [w/m2]
                                  tmp_lwdown            , & ! in    - downward longwave radiation [w/m2]
                                  tmp_prcp              , & ! in    - total precip (rainfall+snowfall) Rate [kg m-2 s-1]   
                                  tmp_tbot              , & ! in    - deep-layer soil temperature [K]
                                  tmp_pblh              , & ! in    - planetary boundary layer height [m]
                                  tmp_zlvl              , & ! in    - reference height of temperature and humidity [m]
                                  tmp_csoil             , & ! in    - vol. soil heat capacity [j/m3/K] 
                                  tmp_bexp              , & ! in    - B parameter 
                                  tmp_dksat             , & ! in    - saturated soil hydraulic conductivity
                                  tmp_dwsat             , & ! in    - saturated soil hydraulic diffusivity
                                  tmp_psisat            , & ! in    - saturated soil matric potential 
                                  tmp_quartz            , & ! in    - soil quartz content 
                                  tmp_smcmax            , & ! in    - porosity, saturated value of soil moisture (volumetric) 
                                  tmp_smcref            , & ! in    - reference soil moisture (field capacity) 
                                  tmp_smcwlt            , & ! in    - wilting point soil moisture (volumetric) 
                                  tmp_czil              , & ! in    - Calculate roughness length of heat 
                                  tmp_frzk              , & ! in    - frozen ground parameter 
                                  tmp_refdk             , & ! in    - parameters in the surface runoff parameteriz.
                                  tmp_refkdt            , & ! in    - parameters in the surface runoff parameteriz. 
                                  tmp_slope             , & ! in    - slope index (0 - 1)
                                  tmp_topt              , & ! in    - optimum transpiration air temperature 
                                  tmp_rgl               , & ! in    - parameter used in radiation stress function
                                  tmp_rsmax             , & ! in    - maximum stomatal resistance
                                  tmp_rsmin             , & ! in    - minimum Canopy Resistance [s/m]
                                  tmp_hs                , & ! in    - parameter used in vapor pressure deficit function 
                                  tmp_nroot             , & ! in    - 
                                  tmp_CH2OP             , & ! in    - maximum intercepted h2o per unit lai+sai [mm]
                                  tmp_DLEAF             , & ! in    - characteristic leaf dimension [m]
                                  tmp_Z0MVT             , & ! in    - momentum roughness length [m]
                                  tmp_HVT               , & ! in    - top of canopy [m]
                                  tmp_HVB               , & ! in    - bottom of canopy [m]
                                  tmp_RC                , & ! in    - tree crown radius [m]
                                  tmp_RHOL1             , & ! in    - leaf reflectance (1=vis)
                                  tmp_RHOL2             , & ! in    - leaf reflectance (2=nir)
                                  tmp_RHOS1             , & ! in    - stem reflectance (1=vis)
                                  tmp_RHOS2             , & ! in    - stem reflectance (2=nir)
                                  tmp_TAUL1             , & ! in    - leaf transmittance (1=vis)
                                  tmp_TAUL2             , & ! in    - leaf transmittance (2=nir)
                                  tmp_TAUS1             , & ! in    - stem transmittance (1=vis)
                                  tmp_TAUS2             , & ! in    - stem transmittance (2=nir)
                                  tmp_XL                , & ! in    - leaf/stem orientation index
                                  tmp_CWPVT             , & ! in    - empirical canopy wind parameter
                                  tmp_C3PSN             , & ! in    - photosynthetic pathway (0. = c4, 1. = c3)
                                  tmp_KC25              , & ! in    - co2 michaelis-menten constant at 25c [pa]
                                  tmp_AKC               , & ! in    - q10 for kc25
                                  tmp_KO25              , & ! in    - o2 michaelis-menten constant at 25c [pa]
                                  tmp_AKO               , & ! in    - q10 for ko25
                                  tmp_AVCMX             , & ! in    - q10 for vcmx25
                                  tmp_AQE               , & ! in    - q10 for qe25
                                  tmp_LTOVRC            , & ! in    - leaf turnover [1/s]
                                  tmp_DILEFC            , & ! in    - coeficient for leaf stress death [1/s]
                                  tmp_DILEFW            , & ! in    - coeficient for leaf stress death [1/s]
                                  tmp_RMF25             , & ! in    - leaf maintenance respiration at 25c [umol co2/m**2/s]
                                  tmp_SLA               , & ! in    - single-side leaf area per Kg [m2/kg]
                                  tmp_FRAGR             , & ! in    - fraction of growth respiration. original was 0.3
                                  tmp_TMIN              , & ! in    - minimum temperature for photosynthesis [k]
                                  tmp_VCMX25            , & ! in    - maximum rate of carboxylation at 25c. unit [umol co2/m**2/s]
                                  tmp_TDLEF             , & ! in    - characteristic T for leaf freezing [K]
                                  tmp_BP                , & ! in    - minimum leaf conductance [umol/m**2/s]
                                  tmp_MP                , & ! in    - slope of conductance-to-photosynthesis relationship
                                  tmp_QE25              , & ! in    - quantum efficiency at 25c [umol co2 / umol photon]
                                  tmp_RMS25             , & ! in    - stem maintenance respiration at 25c [umol co2/kg bio/s]
                                  tmp_RMR25             , & ! in    - root maintenance respiration at 25c [umol co2/kg bio/s]
                                  tmp_ARM               , & ! in    - q10 for maintenance respiration
                                  tmp_FOLNMX            , & ! in    - foliage nitrogen concentration when f(n)=1 [%]
                                  tmp_WDPOOL            , & ! in    - wood pool (switch 1 or 0) depending on woody or not [-]
                                  tmp_WRRAT             , & ! in    - wood to non-wood ratio
                                  tmp_MRP               , & ! in    - microbial respiration parameter [umol co2 /kg c/ s]
                                  tmp_albold            , & ! inout - snow albedo at last time step [-]
                                  tmp_sneqvo            , & ! inout - snow mass at the last time step [mm]
                                  tmp_sstc              , & ! inout - snow/soil temperature [K]
                                  tmp_sh2o              , & ! inout - volumetric liquid soil moisture [m^3 m-3]
                                  tmp_smc               , & ! inout - volumetric soil moisture, ice + liquid [m^3 m-3]
                                  tmp_tah               , & ! inout - canopy air temperature [K]
                                  tmp_eah               , & ! inout - canopy air vapor pressure [Pa]
                                  tmp_fwet              , & ! inout - wetted or snowed fraction of canopy [-]
                                  tmp_canliq            , & ! inout - intercepted liquid water [mm]
                                  tmp_canice            , & ! inout - intercepted ice mass [mm]
                                  tmp_tv                , & ! inout - vegetation temperature [K]
                                  tmp_tg                , & ! inout - ground temperature [K]
                                  tmp_qsnow             , & ! inout - snowfall on the ground [mm s-1]
                                  tmp_isnow             , & ! inout - actual number of snow layers [-]
                                  tmp_zss               , & ! inout - snow/soil layer-bottom depth from snow surface [m]
                                  tmp_snowh             , & ! inout - snow height [m]
                                  tmp_sneqv             , & ! inout - snow water equivalent [mm]
                                  tmp_snowice           , & ! inout - snow-layer ice [mm]
                                  tmp_snowliq           , & ! inout - snow-layer liquid water [mm]
                                  tmp_zwt               , & ! inout - depth to water table [m]
                                  tmp_wa                , & ! inout - water storage in aquifer [mm]
                                  tmp_wt                , & ! inout - water in aquifer and saturated soil [mm]
                                  tmp_wslake            , & ! inout - lake water storage [mm]
                                  tmp_lfmass            , & ! inout - leaf mass [g/m2]
                                  tmp_rtmass            , & ! inout - mass of fine roots [g/m2]
                                  tmp_stmass            , & ! inout - stem mass [g/m2]
                                  tmp_wood              , & ! inout - mass of wood including woody roots [g/m2]
                                  tmp_stblcp            , & ! inout - stable carbon in deep soil [g/m2]
                                  tmp_fastcp            , & ! inout - short-lived carbon in shallow soil [g/m2]
                                  tmp_lai               , & ! inout - leaf area index [-]
                                  tmp_sai               , & ! inout - stem area index [-]
                                  tmp_cm                , & ! inout - momentum drag coefficient [m s-1]
                                  tmp_ch                , & ! inout - sensible heat exchange coefficient [m s-1]
                                  tmp_tauss             , & ! inout - snow aging term [-]
                                  tmp_smcwtd            , & ! inout - soil water content between bottom of the soil and water table [m^3 m-3]
                                  tmp_deeprech          , & ! inout - recharge to or from the water table when deep [m]
                                  tmp_rech              , & ! inout - recharge to or from the water table when shallow [m]
                                  tmp_fsa               , & ! out   - total absorbed solar radiation [W m-2]
                                  tmp_fsr               , & ! out   - total reflected solar radiation [W m-2]
                                  tmp_fira              , & ! out   - total net longwave radiation to atmosphere [W m-2]
                                  tmp_fsh               , & ! out   - total sensible heat to atmosphere [W m-2]
                                  tmp_ssoil             , & ! out   - ground heat flux to soil [W m-2]
                                  tmp_fcev              , & ! out   - canopy evaporative heat to atmosphere [W m-2]
                                  tmp_fgev              , & ! out   - ground evaporative heat to atmosphere [W m-2]
                                  tmp_fctr              , & ! out   - transpiration heat to atmosphere [W m-2]
                                  tmp_ecan              , & ! out   - evaporation rate of canopy water [kg m-2 s-1]
                                  tmp_etran             , & ! out   - transpiration rate [kg m-2 s-1]
                                  tmp_edir              , & ! out   - direct evaporation rate from surface [kg m-2 s-1]
                                  tmp_trad              , & ! out   - surface radiative temperature [K]
                                  tmp_subsnow           , & ! out   - snow sublimation rate [kg m-2 s-1]
                                  tmp_tgb               , & ! out   - ground temperature [K]
                                  tmp_tgv               , & ! out   - ground surface temperature [K]
                                  tmp_t2mv              , & ! out   - 2-m air temperature over vegetated part [K]
                                  tmp_t2mb              , & ! out   - 2-m height air temperature [K]
                                  tmp_q2v               , & ! out   - 2-m specific humidity over vegetation [kg kg-1]
                                  tmp_q2b               , & ! out   - 2-m air specific humidity [kg kg-1]
                                  tmp_runsrf            , & ! out   - surface runoff [kg m-2 s-1]
                                  tmp_runsub            , & ! out   - baseflow (saturation excess) [kg m-2 s-1]
                                  tmp_apar              , & ! out   - photosynthesis active energy by canopy [W m-2]
                                  tmp_psn               , & ! out   - total photosynthesis of CO2 [umol m-2 s-1]
                                  tmp_sav               , & ! out   - solar radiation absorbed by vegetation [W m-2]
                                  tmp_sag               , & ! out   - solar radiation absorbed by ground [W m-2]
                                  tmp_fsno              , & ! out   - snow-cover fraction on the ground [-]
                                  tmp_nee               , & ! out   - net ecosystem exchange of CO2 [g/m2s]
                                  tmp_gpp               , & ! out   - net instantaneous assimilation of carbon [g/m2s]
                                  tmp_npp               , & ! out   - net primary productivity of carbon [g/m2s]
                                  tmp_fveg              , & ! out   - green vegetation fraction [-]
                                  tmp_albedo            , & ! out   - surface albedo [-]
                                  tmp_qsnbot            , & ! out   - melting water out of snow bottom [kg m-2 s-1]
                                  tmp_ponding           , & ! out   - surface ponding [mm]
                                  tmp_ponding1          , & ! out   - surface ponding1 [mm]
                                  tmp_ponding2          , & ! out   - surface ponding2 [mm]
                                  tmp_rssun             , & ! out   - sunlit stomatal resistance [s/m]
                                  tmp_rssha             , & ! out   - shaded stomatal resistance [s/m]
                                  tmp_bgap              , & ! out   - between canopy gap fraction for beam [-]
                                  tmp_wgap              , & ! out   - within canopy gap fraction for beam [-]
                                  tmp_chv               , & ! out   - sensible heat exchange coefficient over vegetated fraction [m s-1]
                                  tmp_chb               , & ! out   - sensible heat exchange coefficient over bare-ground fraction [m s-1]
                                  tmp_emissi            , & ! out   - surface emissivity [-]
                                  tmp_shg               , & ! out   - ground sensible heat [W m-2]
                                  tmp_shc               , & ! out   - canopy sensible heat [W m-2]
                                  tmp_shb               , & ! out   - bare ground sensible heat [W m-2]
                                  tmp_evg               , & ! out   - ground evaporation heat [W m-2]
                                  tmp_evb               , & ! out   - bare ground evaporation heat [W m-2]
                                  tmp_ghv               , & ! out   - ground heat flux [W m-2]
                                  tmp_ghb               , & ! out   - bare ground heat flux [W m-2]
                                  tmp_irg               , & ! out   - ground net long wave radiation [W m-2]
                                  tmp_irc               , & ! out   - canopy net long wave radiation [W m-2]
                                  tmp_irb               , & ! out   - bare ground net long wave radiation [W m-2]
                                  tmp_tr                , & ! out   - transpiration heat [W m-2]
                                  tmp_evc               , & ! out   - canopy evaporation heat [W m-2]
                                  tmp_chleaf            , & ! out   - leaf exchange coefficient [-]
                                  tmp_chuc              , & ! out   - under canopy exchange coefficient [-]
                                  tmp_chv2              , & ! out   - sensible heat exchange coefficient over vegetated fraction [-]
                                  tmp_chb2              , & ! out   - sensible heat exchange coefficient over bare-ground [-]
                                  tmp_fpice             , & ! out   - snow fraction in precipitation [-]
                                  tmp_sfcheadrt         )   ! out   - extra output for WRF-HYDRO [m]
!   if ( tmp_fira/tmp_fira .ne. 1 ) then
!   print *, 'LGG in ibis_main DEPOIS NOAH',tmp_fira, tmp_lwdown, tmp_shdfac_monthly(3),tmp_lai,tmp_sai, tmp_latitude, tmp_longitude, &
!             tmp_irg,tmp_irc,tmp_irb, tmp_tgb, tmp_tg
!   endif

   endif
            ! save state variables from local variables to global variables
            ibis_struc(n)%ibis(t)%albold      = tmp_albold
            ibis_struc(n)%ibis(t)%sneqvo      = tmp_sneqvo
            ibis_struc(n)%ibis(t)%sstc(:)     = tmp_sstc(:)
            ibis_struc(n)%ibis(t)%sh2o(:)     = tmp_sh2o(:)
            ibis_struc(n)%ibis(t)%smc(:)      = tmp_smc(:)
            ibis_struc(n)%ibis(t)%tah         = tmp_tah
            ibis_struc(n)%ibis(t)%eah         = tmp_eah
            ibis_struc(n)%ibis(t)%fwet        = tmp_fwet
            ibis_struc(n)%ibis(t)%canliq      = tmp_canliq
            ibis_struc(n)%ibis(t)%canice      = tmp_canice
            ibis_struc(n)%ibis(t)%tv          = tmp_tv
            ibis_struc(n)%ibis(t)%tg          = tmp_tg
            ibis_struc(n)%ibis(t)%qsnow       = tmp_qsnow
            ibis_struc(n)%ibis(t)%isnow       = tmp_isnow
            ibis_struc(n)%ibis(t)%zss(:)      = tmp_zss(:)
            ibis_struc(n)%ibis(t)%snowh       = tmp_snowh
            ibis_struc(n)%ibis(t)%sneqv       = tmp_sneqv
            ibis_struc(n)%ibis(t)%snowice(:)  = tmp_snowice(:)
            ibis_struc(n)%ibis(t)%snowliq(:)  = tmp_snowliq(:)
            ibis_struc(n)%ibis(t)%zwt         = tmp_zwt
            ibis_struc(n)%ibis(t)%wa          = tmp_wa
            ibis_struc(n)%ibis(t)%wt          = tmp_wt
            ibis_struc(n)%ibis(t)%wslake      = tmp_wslake
            ibis_struc(n)%ibis(t)%lfmass      = tmp_lfmass
            ibis_struc(n)%ibis(t)%rtmass      = tmp_rtmass
            ibis_struc(n)%ibis(t)%stmass      = tmp_stmass
            ibis_struc(n)%ibis(t)%wood        = tmp_wood
            ibis_struc(n)%ibis(t)%stblcp      = tmp_stblcp
            ibis_struc(n)%ibis(t)%fastcp      = tmp_fastcp
            ibis_struc(n)%ibis(t)%lai         = tmp_lai
            ibis_struc(n)%ibis(t)%sai         = tmp_sai
            ibis_struc(n)%ibis(t)%cm          = tmp_cm
            ibis_struc(n)%ibis(t)%ch          = tmp_ch
            ibis_struc(n)%ibis(t)%tauss       = tmp_tauss
            ibis_struc(n)%ibis(t)%smcwtd      = tmp_smcwtd
            ibis_struc(n)%ibis(t)%deeprech    = tmp_deeprech
            ibis_struc(n)%ibis(t)%rech        = tmp_rech

            ! save output variables from local variables to global variables
            ibis_struc(n)%ibis(t)%fsa          = tmp_fsa
            ibis_struc(n)%ibis(t)%fsr          = tmp_fsr
            ibis_struc(n)%ibis(t)%fira         = tmp_fira
            ibis_struc(n)%ibis(t)%fsh          = tmp_fsh
            ibis_struc(n)%ibis(t)%ssoil        = tmp_ssoil
            ibis_struc(n)%ibis(t)%fcev         = tmp_fcev
            ibis_struc(n)%ibis(t)%fgev         = tmp_fgev
            ibis_struc(n)%ibis(t)%fctr         = tmp_fctr
            ibis_struc(n)%ibis(t)%ecan         = tmp_ecan
            ibis_struc(n)%ibis(t)%etran        = tmp_etran
            ibis_struc(n)%ibis(t)%edir         = tmp_edir
            ibis_struc(n)%ibis(t)%trad         = tmp_trad
            ibis_struc(n)%ibis(t)%tgb          = tmp_tgb
            ibis_struc(n)%ibis(t)%tgv          = tmp_tgv
            ibis_struc(n)%ibis(t)%t2mv         = tmp_t2mv
            ibis_struc(n)%ibis(t)%t2mb         = tmp_t2mb
            ibis_struc(n)%ibis(t)%q2v          = tmp_q2v
            ibis_struc(n)%ibis(t)%q2b          = tmp_q2b
            ibis_struc(n)%ibis(t)%runsrf       = tmp_runsrf
            ibis_struc(n)%ibis(t)%runsub       = tmp_runsub
            ibis_struc(n)%ibis(t)%apar         = tmp_apar
            ibis_struc(n)%ibis(t)%psn          = tmp_psn
            ibis_struc(n)%ibis(t)%sav          = tmp_sav
            ibis_struc(n)%ibis(t)%sag          = tmp_sag
            ibis_struc(n)%ibis(t)%fsno         = tmp_fsno
            ibis_struc(n)%ibis(t)%nee          = tmp_nee
            ibis_struc(n)%ibis(t)%gpp          = tmp_gpp
            ibis_struc(n)%ibis(t)%npp          = tmp_npp
            ibis_struc(n)%ibis(t)%fveg         = tmp_fveg
            ibis_struc(n)%ibis(t)%albedo       = tmp_albedo
            ibis_struc(n)%ibis(t)%qsnbot       = tmp_qsnbot
            ibis_struc(n)%ibis(t)%ponding      = tmp_ponding
            ibis_struc(n)%ibis(t)%ponding1     = tmp_ponding1
            ibis_struc(n)%ibis(t)%ponding2     = tmp_ponding2
            ibis_struc(n)%ibis(t)%rssun        = tmp_rssun
            ibis_struc(n)%ibis(t)%rssha        = tmp_rssha
            ibis_struc(n)%ibis(t)%bgap         = tmp_bgap
            ibis_struc(n)%ibis(t)%wgap         = tmp_wgap
            ibis_struc(n)%ibis(t)%chv          = tmp_chv
            ibis_struc(n)%ibis(t)%chb          = tmp_chb
            ibis_struc(n)%ibis(t)%emissi       = tmp_emissi
            ibis_struc(n)%ibis(t)%shg          = tmp_shg
            ibis_struc(n)%ibis(t)%shc          = tmp_shc
            ibis_struc(n)%ibis(t)%shb          = tmp_shb
            ibis_struc(n)%ibis(t)%evg          = tmp_evg
            ibis_struc(n)%ibis(t)%evb          = tmp_evb
            ibis_struc(n)%ibis(t)%ghv          = tmp_ghv
            ibis_struc(n)%ibis(t)%ghb          = tmp_ghb
            ibis_struc(n)%ibis(t)%irg          = tmp_irg
            ibis_struc(n)%ibis(t)%irc          = tmp_irc
            ibis_struc(n)%ibis(t)%irb          = tmp_irb
            ibis_struc(n)%ibis(t)%tr           = tmp_tr
            ibis_struc(n)%ibis(t)%evc          = tmp_evc
            ibis_struc(n)%ibis(t)%chleaf       = tmp_chleaf
            ibis_struc(n)%ibis(t)%chuc         = tmp_chuc
            ibis_struc(n)%ibis(t)%chv2         = tmp_chv2
            ibis_struc(n)%ibis(t)%chb2         = tmp_chb2
            ibis_struc(n)%ibis(t)%fpice        = tmp_fpice
            ibis_struc(n)%ibis(t)%sfcheadrt    = tmp_sfcheadrt
            ibis_struc(n)%ibis(t)%albd       = tmp_albd
            ibis_struc(n)%ibis(t)%albi       = tmp_albi  

            !print *, 'LGG nsoilay in ibis_main ',nsoilay, t
            !STOP
            
            Rainf_out = (tmp_prcp) * (1.0 - ibis_struc(n)%ibis(t)%fpice)
            call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_RAINF, value=Rainf_out, &
                  vlevel=1,unit="kg m-2 s-1",direction="DN",surface_type=LIS_rc%lsm_index)
            call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_RAINF, value=Rainf_out*dt, &
                  vlevel=1,unit="kg m-2", direction="DN",surface_type=LIS_rc%lsm_index)
            Snowf_out = (tmp_prcp) * ibis_struc(n)%ibis(t)%fpice 
            call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_SNOWF, value=Snowf_out, &
                  vlevel=1,unit="kg m-2 s-1",direction="DN",surface_type=LIS_rc%lsm_index)
            call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_SNOWF, value=Snowf_out*dt, &
                  vlevel=1,unit="kg m-2", direction="DN",surface_type=LIS_rc%lsm_index)



    ![ 1] output variable: soil_temp (unit=K). ***  soil layer temperature
    do i=1, nsoilay
      write(ttxt,*) ibis_struc(n)%ibis(t)%tsoi(1,i,1);  read(ttxt,*,iostat=retint) Var_out
      call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_SOILTEMP, value = Var_out, &
                      vlevel=i, unit="K", direction="-", surface_type = LIS_rc%lsm_index)
    end do
            
    ![ 3] output variable: sh2o (unit=m^3 m-3). ***  volumetric liquid soil moisture 
    do i=1, nsoilay
      write(ttxt,*) ibis_struc(n)%ibis(t)%wsoi(1,i,1);  read(ttxt,*,iostat=retint) Var_out
      !write(ttxt,*) Grd(4)%Buffer(1,i,1);  read(ttxt,*,iostat=retint) Var_out
      call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_SOILMOIST, value = Var_out, &
                     vlevel=i, unit="m^3 m-3", direction="-", surface_type = LIS_rc%lsm_index)
    end do            

    write(ttxt,*) ibis_struc(n)%ibis(t)%heatg;  read(ttxt,*,iostat=retint) Var_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_QG, value = Var_out, &
                      vlevel=1, unit="W m-2", direction="DN", surface_type = LIS_rc%lsm_index)

    !write(ttxt,*) Grd(2)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Var_out
    write(ttxt,*) ibis_struc(n)%ibis(t)%sens;  read(ttxt,*,iostat=retint) Var_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_QH, value = Var_out, &
                     vlevel=1, unit="W m-2", direction="UP", surface_type = LIS_rc%lsm_index)

    !write(ttxt,*) Grd(3)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Var_out
    write(ttxt,*) ibis_struc(n)%ibis(t)%evap;  read(ttxt,*,iostat=retint) Var_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_QLE, value =Var_out, &
                     vlevel=1, unit="W m-2", direction="UP", surface_type = LIS_rc%lsm_index)

    write(ttxt,*) ibis_struc(n)%ibis(t)%grunof(1,1);  read(ttxt,*,iostat=retint) Var_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_QS, value = Var_out, &
                     vlevel=1, unit="kg m-2 s-1", direction="OUT", surface_type = LIS_rc%lsm_index)

    write(ttxt,*) ibis_struc(n)%ibis(t)%gdrain(1,1);  read(ttxt,*,iostat=retint) Var_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_QSB, value = Var_out, &
                     vlevel=1, unit="kg m-2 s-1", direction="OUT", surface_type = LIS_rc%lsm_index)

    write(ttxt,*) Grd(320)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Var_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_VEGTYPE0, value = Var_out, &
                     vlevel=1, unit="-", direction="-", surface_type = LIS_rc%lsm_index)

    ![ 29] output variable: lai (unit=-). ***  leaf area index 
    write(ttxt,*) ibis_struc(n)%ibis(t)%totlaiu(1,1);  read(ttxt,*,iostat=retint) Var_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_LAI, value = Var_out, &
                     vlevel=1, unit="-", direction="-", surface_type = LIS_rc%lsm_index)

    !write(ttxt,*) ibis_struc(n)%ibis(t)%adplai(1,1,1);  read(ttxt,*,iostat=retint) Var_out
    write(ttxt,*) ibis_struc(n)%ibis(t)%sand(1,1,1);  read(ttxt,*,iostat=retint) Var_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_PLAI1, value = Var_out, &
                     vlevel=1, unit="-", direction="-", surface_type = LIS_rc%lsm_index)

    !write(ttxt,*) ibis_struc(n)%ibis(t)%adplai(1,2,1);  read(ttxt,*,iostat=retint) Var_out
    write(ttxt,*) ibis_struc(n)%ibis(t)%sand(1,2,1);  read(ttxt,*,iostat=retint) Var_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_PLAI2, value = Var_out, &
                     vlevel=1, unit="-", direction="-", surface_type = LIS_rc%lsm_index)

    !write(ttxt,*) ibis_struc(n)%ibis(t)%adplai(1,3,1);  read(ttxt,*,iostat=retint) Var_out
    write(ttxt,*) ibis_struc(n)%ibis(t)%sand(1,3,1);  read(ttxt,*,iostat=retint) Var_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_PLAI3, value = Var_out, &
                     vlevel=1, unit="-", direction="-", surface_type = LIS_rc%lsm_index)

    !write(ttxt,*) ibis_struc(n)%ibis(t)%adplai(1,4,1);  read(ttxt,*,iostat=retint) Var_out
    write(ttxt,*) ibis_struc(n)%ibis(t)%sand(1,4,1);  read(ttxt,*,iostat=retint) Var_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_PLAI4, value = Var_out, &
                     vlevel=1, unit="-", direction="-", surface_type = LIS_rc%lsm_index)

    !write(ttxt,*) ibis_struc(n)%ibis(t)%adplai(1,5,1);  read(ttxt,*,iostat=retint) Var_out
    write(ttxt,*) ibis_struc(n)%ibis(t)%sand(1,5,1);  read(ttxt,*,iostat=retint) Var_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_PLAI5, value = Var_out, &
                     vlevel=1, unit="-", direction="-", surface_type = LIS_rc%lsm_index)

    !write(ttxt,*) ibis_struc(n)%ibis(t)%adplai(1,6,1);  read(ttxt,*,iostat=retint) Var_out
    write(ttxt,*) ibis_struc(n)%ibis(t)%sand(1,6,1);  read(ttxt,*,iostat=retint) Var_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_PLAI6, value = Var_out, &
                     vlevel=1, unit="-", direction="-", surface_type = LIS_rc%lsm_index)

    !write(ttxt,*) ibis_struc(n)%ibis(t)%adplai(1,7,1);  read(ttxt,*,iostat=retint) Var_out
    write(ttxt,*) ibis_struc(n)%ibis(t)%clay(1,1,1);  read(ttxt,*,iostat=retint) Var_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_PLAI7, value = Var_out, &
                     vlevel=1, unit="-", direction="-", surface_type = LIS_rc%lsm_index)

    !write(ttxt,*) ibis_struc(n)%ibis(t)%adplai(1,8,1);  read(ttxt,*,iostat=retint) Var_out
    write(ttxt,*) ibis_struc(n)%ibis(t)%clay(1,2,1);  read(ttxt,*,iostat=retint) Var_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_PLAI8, value = Var_out, &
                     vlevel=1, unit="-", direction="-", surface_type = LIS_rc%lsm_index)

    !write(ttxt,*) ibis_struc(n)%ibis(t)%adplai(1,9,1);  read(ttxt,*,iostat=retint) Var_out
    write(ttxt,*) ibis_struc(n)%ibis(t)%xinveg(1,1);  read(ttxt,*,iostat=retint) Var_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_PLAI9, value = Var_out, &
                     vlevel=1, unit="-", direction="-", surface_type = LIS_rc%lsm_index)

    write(ttxt,*) ibis_struc(n)%ibis(t)%adplai(1,10,1);  read(ttxt,*,iostat=retint) Var_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_PLAI10, value = Var_out, &
                     vlevel=1, unit="-", direction="-", surface_type = LIS_rc%lsm_index)

    write(ttxt,*) ibis_struc(n)%ibis(t)%adplai(1,11,1);  read(ttxt,*,iostat=retint) Var_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_PLAI11, value = Var_out, &
                     vlevel=1, unit="-", direction="-", surface_type = LIS_rc%lsm_index)

    write(ttxt,*) ibis_struc(n)%ibis(t)%adplai(1,12,1);  read(ttxt,*,iostat=retint) Var_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_PLAI12, value = Var_out, &
                     vlevel=1, unit="-", direction="-", surface_type = LIS_rc%lsm_index)

    ! TWS should be SWE + CanopInt + Soil moisture + WA - David Mocko
    ! TWS  SWE + CanopInt + Soil moisture - LGG missing WA in IBIS
    write(ttxt,*) ibis_struc(n)%ibis(t)%wtot(1,1);  read(ttxt,*,iostat=retint) Var_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_TWS, value = Var_out, &
                     vlevel=1, unit="mm", direction="-", surface_type = LIS_rc%lsm_index)
         
            if ( .false. ) then

            
    write(ttxt,*) Grd(1)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_PSLC, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)

    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_MOIS, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(5)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TSKN, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)

!    do i=1, nsoilay
!    !write(ttxt,*) Grd(6)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
!    write(ttxt,*) ibis_struc(n)%ibis(t)%tsoi(1,i,1);  read(ttxt,*,iostat=retint) Evap_out
!    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TSOIL, value = Evap_out, &
!                    vlevel=i, unit="K", direction="-", surface_type = LIS_rc%lsm_index)
!    enddo

    write(ttxt,*) Grd(7)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_SWRAD, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(8)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_LWRAD, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(9)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_RAIN, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(10)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out


    write(ttxt,*) Grd(11)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ECT, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(12)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ECI, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(13)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_EGT, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(14)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_EGI, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(15)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_EGS, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(16)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TS2, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(17)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_QS2, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(18)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_COSZ, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(19)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_SWUP, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(20)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_SPEEDW, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TEMP, value = Evap_out, &
                     vlevel=i, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_UMES , value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TOTBIOU, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TOTBIOL, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TOTLAIU, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TOTLAIL, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_STOREDN, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_DECOMPL, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_DECOMPS, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_FU , value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_FL , value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TNPPTOT, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TNEETOT, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_LAI2 , value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_LAI1 , value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_STOREDN_P, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TOTNSOI_P, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TNMIN_P, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TOTNMIC_P, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TOTNLIT_P, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_YNLEACH_P, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_FROOT1, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_FROOT2, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TCO2MIC, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TCO2ROOT, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TNMIN, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_AGCUB, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_AGCUC, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_AGCLS, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_AGCL4, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_AGCL3, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ANCUB, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ANCUC, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ANCLS, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ANCL4, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ANCL3, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_GSUC, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_GSL3, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_GSL4, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_GSUB, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_GSLS, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_CIUB, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_CIUC, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_CSUB, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_CSUC, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_SU, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_STRESSTL, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_STRESSTU, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_STRESSL, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_STRESSU, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_SFIELD, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_SWILT, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TOPPARU, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TOPPARL, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_CILS, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_CIL3, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_CIL4, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_CSLS, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_CSL3, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_CSL4, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ZTOP1, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ZTOP2, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ZBOT1, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ZBOT2, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_AGDDU, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_AGDDL, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TD, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_A10TD, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TEMPU, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TEMPL, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_DROPU, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_DROPLS, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_DROPL4, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_DROPL3, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_A10ANCUB, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_A10ANCUC, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_A10ANCLS, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_A10ANCL3, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_A10ANCL3, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_PLAI1, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_PLAI2, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_PLAI3, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_PLAI4, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_PLAI5, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_PLAI6, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_PLAI7, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_PLAI8, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_PLAI9, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_PLAI10, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_PLAI11, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_PLAI12, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_BIOMASS1, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_BIOMASS2, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_BIOMASS3, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_BIOMASS4, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_BIOMASS5, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_BIOMASS6, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_BIOMASS7, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_BIOMASS8, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_BIOMASS9, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_BIOMASS10, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_BIOMASS11, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_BIOMASS12, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TGPPTOT, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_AYNPP1, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_AYNPP2, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_AYNPP3, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_AYNPP4, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_AYNPP5, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_AYNPP6, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_AYNPP7, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_AYNPP8, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_AYNPP9, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_AYNPP10, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_AYNPP11, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_AYNPP12, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_FALLL, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_FALLR, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_FALLW, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_DISTURBF, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_DISTURBO, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADNPP1, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADNPP2, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADNPP3, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADNPP4, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADNPP5, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADNPP6, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADNPP7, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADNPP8, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADNPP9, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADNPP10, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADNPP11, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADNPP12, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCO2MIC, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADPLAI1, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADPLAI2, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADPLAI3, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADPLAI4, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADPLAI5, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADPLAI6, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADPLAI7, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADPLAI8, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADPLAI9, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADPLAI10, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADPLAI11, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADPLAI12, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOL1, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOL2, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOL3, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOL4, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOL5, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOL6, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOL7, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOL8, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOL9, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOL10, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOL11, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOL12, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOR1, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOR2, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOR3, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOR4, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOR5, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOR6, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOR7, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOR8, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOR9, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOR10, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOR11, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOR12, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOW1, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOW2, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOW3, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOW4, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOW5, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOW6, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOW7, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOW8, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOW9, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOW10, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOW11, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADCBIOW12, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_SLHF, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_SSHF, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_SLRAD, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
!    write(ttxt,*) Grd(320)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
!    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_VEGTYPE0, value = Evap_out, &
!                     vlevel=1, unit="-", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TOTCONDUB, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TOTCONDUC, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TOTCONDLS, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TOTCONDL3, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TOTCONDL4, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TC, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TW, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TCTHIS, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TWTHIS, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADFALLL, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADFALLR, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_ADFALLW, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_FSENA, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_FSENG, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_FSENI, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_FSENU, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_FSENS, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_FSENL, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_FVAPA, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_FVAPUT, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_FVAPS, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_FVAPLW, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_FVAPLT, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_FVAPG, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_FVAPI, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_FVAPUW, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_T12, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_T34, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_Q12, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_Q34, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_SS, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_SL, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_GTHRESHOLD, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TTHRESHOLD, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_CLITLM, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_CLITLS, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_CLITRM, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_CLITRS, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_CLITWM, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_CLITWS, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_CSOISLOP, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_CSOISLON, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_CSOIPAS, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_CLITLL, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_CLITRL, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_CLITWL, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TOTALIT, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TOTRLIT, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TOTCSOI, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TOTCMIC, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TOTANLIT, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TOTRNLIT, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TOTNSOI, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TOTNMIC, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TOTLIT, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TOTNLIT, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)
    write(ttxt,*) Grd(4)%Buffer(1,1,1);  read(ttxt,*,iostat=retint) Evap_out
    call LIS_diagnoseSurfaceOutputVar(n, t, LIS_MOC_IBIS_TOTFALL, value = Evap_out, &
                     vlevel=1, unit="m", direction="-", surface_type = LIS_rc%lsm_index)

        endif ! if false output
            
            ! reset forcing variables to 0 for accumulation 
            ibis_struc(n)%ibis(t)%tair = 0.0
            ibis_struc(n)%ibis(t)%psurf = 0.0
            ibis_struc(n)%ibis(t)%wind_e = 0.0
            ibis_struc(n)%ibis(t)%wind_n = 0.0
            ibis_struc(n)%ibis(t)%qair = 0.0
            ibis_struc(n)%ibis(t)%swdown = 0.0
            ibis_struc(n)%ibis(t)%lwdown = 0.0
            ibis_struc(n)%ibis(t)%prcp = 0.0
        enddo ! end of tile (t) loop
        ! reset forcing counter to be zero
        ibis_struc(n)%forc_count = 0 
        initlz=-1 !LGG
   !print *, 'in ibis_main OUT OF LOOP'
        
    endif ! end of alarmCheck loop 

    deallocate( tmp_sldpth )
    deallocate( tmp_shdfac_monthly )
    deallocate( tmp_smceq )
    deallocate( tmp_sstc )
    deallocate( tmp_sh2o )
    deallocate( tmp_smc )
    deallocate( tmp_zss )
    deallocate( tmp_snowice )
    deallocate( tmp_snowliq )


CONTAINS

  SUBROUTINE Init()
    IMPLICIT NONE
    
! LGG    CALL InitB()
    CALL InitA()
  END SUBROUTINE Init

  SUBROUTINE run(jdt,tod,DELTAIN,kkey,ibis_tair,ibis_psurf,ibis_wind_e,ibis_wind_n,        & 
       ibis_qair,ibis_swdown,ibis_lwdown,ibis_prcp,ibis_latitude,ibis_longitude,ibis_year, &
       ibis_month,ibis_day,ibis_hour,ibis_minute,ibis_dt,ibis_juliand,ibis_xlh,ibis_xsh)
    IMPLICIT NONE
    INTEGER, INTENT(IN   ) :: jdt
    REAL(KIND=r8), INTENT(IN   ) :: tod
    REAL(KIND=r8), INTENT(IN   ) :: DELTAIN
    logical, intent(IN ) :: kkey
  real(KIND=r8), intent(IN )  :: ibis_tair               ! air temperature [K]
  real(KIND=r8), intent(IN )  :: ibis_psurf              ! air pressure [Pa]
  real(KIND=r8), intent(IN )  :: ibis_wind_e             ! eastward wind speed [m s-1]
  real(KIND=r8), intent(IN )  :: ibis_wind_n             ! northward wind speed [m s-1]
  real(KIND=r8), intent(IN )  :: ibis_qair               ! near Surface Specific Humidity [kg kg-1]
  real(KIND=r8), intent(IN )  :: ibis_swdown             ! downward solar radiation [w/m2]
  real(KIND=r8), intent(IN )  :: ibis_lwdown             ! downward longwave radiation [w/m2]
  real(KIND=r8), intent(IN )  :: ibis_prcp               ! total precip (rainfall+snowfall) Rate [kg m-2 s-1]   
  real(KIND=r8), intent(IN )  :: ibis_latitude           ! latitude in decimal degree [-]
  real(KIND=r8), intent(IN )  :: ibis_longitude          ! longitude in decimal degree [-]
  integer, intent(IN )        :: ibis_year               ! year of the current time step [-]
  integer, intent(IN )        :: ibis_month              ! month of the current time step [-]
  integer, intent(IN )        :: ibis_day                ! day of the current time step [-]
  integer, intent(IN )        :: ibis_hour               ! hour of the current time step [-]
  integer, intent(IN )        :: ibis_minute             ! minute of the current time step [-]
  real(KIND=r8), intent(IN )  :: ibis_dt                 ! time step in seconds [s]
  integer, intent(IN )        :: ibis_juliand             ! julian day of the current time step [-]
  real(KIND=r8), intent(IN )  :: ibis_xlh
  real(KIND=r8), intent(IN )  :: ibis_xsh


!        print *, 'LGG in run() 1 ',kkey, jdt, tod

    !
    IF(.NOT.UNDIMENSION)THEN
      CALL RunAtmosModel  (jdt,tod,nband,dtt,idate,idatec,idatep,DELTAIN)
    ELSE
      CALL RunAtmosModel1DB(jdt,tod,nband,dtt,idate,idatec,idatep,DELTAIN,.FALSE.,          &
        ibis_tair,ibis_psurf,ibis_wind_e,ibis_wind_n,                                       & 
        ibis_qair,ibis_swdown,ibis_lwdown,ibis_prcp,ibis_latitude,ibis_longitude,ibis_year, &
        ibis_month,ibis_day,ibis_hour,ibis_minute,ibis_dt,ibis_juliand,ibis_xlh,ibis_xsh)
    END IF
    
    DO jb=1,jbMax
        nmax=0
	nsx=0
        DO i=1,ibMax
           IF (iMask(i,jb) >= 1) THEN
              nmax=nmax+1
           END IF
	END DO
        !WRITE(0,*) 'LGG in ibis_main in run() before interface ',dtc3x, jdt, tod, dtt
        !STOP

        CALL Ibis_Interface(DELTAIN,dtt                        ,intg              ,istrt           , & ! LGG dt
             jdt                   ,jb                        ,dtc3x                     ,ibMax                     , &
             nmax                  ,kMax                      ,ktm                       ,initlz                    , &
             kt                    ,nsx                       ,iswrad                    ,ilwrad                    , &
             tod                   ,idatec(1:4)               ,filta                     ,epsflt                    , &
             gt        (1:ibMax,jb),gq        (1:ibMax    ,jb),gu        (1:ibMax    ,jb),gv        (1:ibMax    ,jb), &
             gps       (1:ibMax,jb),tmtx      (1:ibMax,1:3,jb),qmtx      (1:ibMax,1:3,jb),umtx      (1:ibMax,1:4,jb), &
             cosz_sib  (1:ibMax,jb),colrad    (1:ibMax    ,jb),dlwbot_sib(1:ibMax    ,jb),radvbc_sib(1:ibMax    ,jb), &
             radvdc_sib(1:ibMax,jb),radnbc_sib(1:ibMax    ,jb),radndc_sib(1:ibMax    ,jb),dlspr_sib (1:ibMax    ,jb), &
             dcupr_sib (1:ibMax,jb),snow      (1:ibMax    ,jb),sigki                     ,delsig                    , & 
             tseam     (1:ibMax,jb),tsea      (1:ibMax    ,jb),mskant    (1:ibMax    ,jb),speedm    (1:ibMax    ,jb), &
             slrad     (1:ibMax,jb),tsurf     (1:ibMax    ,jb),qsurf     (1:ibMax    ,jb),zorl      (1:ibMax    ,jb), &
             taux      (1:ibMax,jb),tauy      (1:ibMax	  ,jb),sens 	 (1:ibMax    ,jb),evap	    (1:ibMax    ,jb), & 
             umom      (1:ibMax,jb),vmom      (1:ibMax	  ,jb),rmi 	 (1:ibMax    ,jb),rhi       (1:ibMax    ,jb), &
             z0        (1:ibMax,jb),ustar     (1:ibMax	  ,jb),hc	 (1:ibMax    ,jb),hg        (1:ibMax    ,jb), & 
             ec        (1:ibMax,jb),eg	      (1:ibMax	  ,jb),ts2	 (1:ibMax    ,jb),qs2       (1:ibMax    ,jb), &
             qsfc      (1:ibMax,jb),tsfc      (1:ibMax	  ,jb),z0sea	 (1:ibMax    ,jb),d         (1:ibMax    ,jb), &
             cu        (1:ibMax,jb),imask     (1:ibMax	  ,jb),Ustarm	 (1:ibMax    ,jb),tgrd      (1:ibMax    ,jb), &
             roff      (1:ibMax,jb),ect       (1:ibMax	  ,jb),eci	 (1:ibMax    ,jb),egt       (1:ibMax    ,jb), &
             egi       (1:ibMax,jb),egs       (1:ibMax	  ,jb),rho	 (1:ibMax    ,jb),bstar     (1:ibMax    ,jb), &
             slhf      (1:ibMax,jb),sshf      (1:ibMax,jb)    ,swdown(1:ibMax,jb) )
        !WRITE(0,*) 'LGG in ibis_main in run() after interface ',dtc3x
        !STOP
!      if ( ( ibis_struc(n)%ibis(t)%latscale(1,1) .gt. -12.884996200000000 ) .and. &
!           ( ibis_struc(n)%ibis(t)%latscale(1,1) .lt. -12.864996200000000 ) ) then
!         print *, "lat/lon in main, before run ", t, ibis_swdown, ibis_qair,&
!           ibis_struc(n)%ibis(t)%latscale(1,1),ibis_struc(n)%ibis(t)%lonscale(1,1), &
!           DELTAIN,dtt                        ,intg              ,istrt           , & ! LGG dt
!             jdt                   ,jb                        ,dtc3x                     ,ibMax                     , &
!             nmax                  ,kMax                      ,ktm                       ,initlz                    , &
!             kt                    ,nsx                       ,iswrad                    ,ilwrad                    , &
!             tod                   ,idatec(1:4)               ,filta                     ,epsflt                    , &
!             gt        (1:ibMax,jb),gq        (1:ibMax    ,jb),gu        (1:ibMax    ,jb),gv        (1:ibMax    ,jb), &
!             gps       (1:ibMax,jb),tmtx      (1:ibMax,1:3,jb),qmtx      (1:ibMax,1:3,jb),umtx      (1:ibMax,1:4,jb), &
!             cosz_sib  (1:ibMax,jb),colrad    (1:ibMax    ,jb),dlwbot_sib(1:ibMax    ,jb),radvbc_sib(1:ibMax    ,jb), &
!             radvdc_sib(1:ibMax,jb),radnbc_sib(1:ibMax    ,jb),radndc_sib(1:ibMax    ,jb),dlspr_sib (1:ibMax    ,jb), &
!             dcupr_sib (1:ibMax,jb),snow      (1:ibMax    ,jb),sigki                     ,delsig                    , & 
!             tseam     (1:ibMax,jb),tsea      (1:ibMax    ,jb),mskant    (1:ibMax    ,jb),speedm    (1:ibMax    ,jb), &
!             slrad     (1:ibMax,jb),tsurf     (1:ibMax    ,jb),qsurf     (1:ibMax    ,jb),zorl      (1:ibMax    ,jb), &
!             taux      (1:ibMax,jb),tauy      (1:ibMax	  ,jb),sens 	 (1:ibMax    ,jb),evap	    (1:ibMax    ,jb), & 
!             umom      (1:ibMax,jb),vmom      (1:ibMax	  ,jb),rmi 	 (1:ibMax    ,jb),rhi       (1:ibMax    ,jb), &
!             z0        (1:ibMax,jb),ustar     (1:ibMax	  ,jb),hc	 (1:ibMax    ,jb),hg        (1:ibMax    ,jb), & 
!             ec        (1:ibMax,jb),eg	      (1:ibMax	  ,jb),ts2	 (1:ibMax    ,jb),qs2       (1:ibMax    ,jb), &
!             qsfc      (1:ibMax,jb),tsfc      (1:ibMax	  ,jb),z0sea	 (1:ibMax    ,jb),d         (1:ibMax    ,jb), &
!             cu        (1:ibMax,jb),imask     (1:ibMax	  ,jb),Ustarm	 (1:ibMax    ,jb),tgrd      (1:ibMax    ,jb), &
!             roff      (1:ibMax,jb),ect       (1:ibMax	  ,jb),eci	 (1:ibMax    ,jb),egt       (1:ibMax    ,jb), &
!             egi       (1:ibMax,jb),egs       (1:ibMax	  ,jb),rho	 (1:ibMax    ,jb),bstar     (1:ibMax    ,jb), &
!             slhf      (1:ibMax,jb),sshf      (1:ibMax,jb)    ,swdown(1:ibMax,jb)
!
!      endif
       
    END DO
    IF(.NOT.UNDIMENSION)THEN
       CALL RunOutput(jdt,tod,nband,dtt,idate,idatec,idatep,DELTAOUT,REAL(latic,kind=r8),REAL(longc,kind=r8)) ! LGG dt
    ELSE
      ! CALL RunOutput1D(jdt,tod,nband,dt,idate,idatec,idatep,DELTAOUT,REAL(latic,kind=r8),REAL(longc,kind=r8))
      if ( kkey .AND. LIS_masterproc ) then
       !print *, 'LGG in run() after ibis STOP ',evap,epsflt,gt,gq,gu,gv,gps,ibis_latitude,ibis_longitude,ibis_year, &
       ! ibis_month,ibis_day,ibis_hour,ibis_minute,ibis_dt,ibis_juliand
       CALL RunOutput1D_Grads(jdt,tod,nband,dtt,idate,idatec,idatep,DELTAOUT,REAL(latic,kind=r8),REAL(longc,kind=r8)) ! LGG dt
      endif
    END IF
  END SUBROUTINE run

  SUBROUTINE Finalize()
    IMPLICIT NONE
    CALL FinalizeAtmosModel()
  END SUBROUTINE Finalize

  SUBROUTINE FinalizeVars()
        
    IMPLICIT NONE
        
  END SUBROUTINE FinalizeVars

  SUBROUTINE transferin(n,t,key)
  
    use ibis_lsmMod

    USE Utils, ONLY :tmstmp2,lati,julday

    USE InitAll, ONLY : InitA,InitB

    USE Options, ONLY : idate,idatec,idatep,tod,tod2,ifday,ifday2,dtt,intg,initlz,ilwrad,iswrad,epsflt,istrt,filta,&
                      DELTAIN,DELTAOUT,maxtim,UNDIMENSION ! LGG dt

    USE Constants, ONLY: &
       r8,             &
       i8,             &
       pi

    USE Sfc_Ibis_Interface, ONLY : Ibis_Interface

    USE Sizes,ONLY :ibMax,jbMax,kMax

!    USE FieldsPhysics, ONLY: iMask,MskAnt
    USE FieldsPhysics

    USE AtmosModel, ONLY : RunAtmosModel,FinalizeAtmosModel,RunAtmosModel1D,&
       gu,gv,gq,gt,gps,dcupr_sib,&
       dlspr_sib,radvbc_sib,radnbc_sib,radvdc_sib,radndc_sib,& 
       dlwbot_sib,cosz_sib,ws,psb_g,bps_g,tseam ,tsea,slrad ,&
       tsurf,qsurf,zorl,tmtx,qmtx,umtx ,sigki ,delsig,latic,longc,slhf,sshf,swdown
! LGG  USE Sfc_Ibis_Fiels, ONLY:nsoilay

   USE Sfc_Ibis_Fiels , Only : spinmax ,isimco2 ,doalb,  &
        isimveg ,isimfire,nband, nsoilay, nsnolay,nlpoints,&
        pi,stef,vonk,grav,tmelt,hfus,hvap,hsub,ch2o,npft, &
        cice,cair,cvap,rair,rvap,cappa,rhow,co2init,epsilon,&
	ginvap  ,gsuvap  ,gtrans,gtransu,gtransl,grunof,& 
        gdrain  ,gadjust ,a10td,a10ancub,a10ancuc,a10ancls, & 
        a10ancl3,a10ancl4,a10scalparamu,a10daylightu,a10scalparaml,&
        a10daylightl,vmax_pft,tau15,kc15,ko15,cimax,gammaub,alpha3,&
        theta3,beta3,coefmub,coefbub,gsubmin,gammauc,coefmuc,coefbuc ,&
        gsucmin,gammals,coefmls,coefbls,gslsmin,gammal3,coefml3, &
        coefbl3,gsl3min,gammal4,alpha4,theta4,beta4,coefml4,coefbl4, &
        gsl4min, wliqu,wliqumax,wsnou,wsnoumax,tum,tu,tu0,wliqs,wliqsmax,& 
        wsnos,wsnosmax,ts,wliql,wliqlmax,wsnol,wsnolmax,tl,topparu,&
        topparl,fl,fu,lai,sai,rhoveg,tauveg,orieh,oriev,wliqmin, &
        wsnomin,t12,tdripu,tblowu,tdrips,tblows,t34,tdripl,tblowl,&
        ztop,alaiml,zbot,alaimu,froot,q34,q12,su,cleaf,dleaf,ss	,& 
        cstem,dstem,sl,cgrass,ciub,ciuc,exist,csub,gsub,csuc,gsuc,&
        agcub,agcuc,ancub,ancuc,totcondub,totconduc,cils,cil3,&	 
        cil4,csls,gsls,csl3,gsl3,csl4,gsl4,agcls,agcl4,agcl3,ancls,&	 
        ancl4,ancl3,totcondls,totcondl3,totcondl4,chu,chs,chl,frac,& 
        tlsub,z0sno,rhos,consno,hsnotop,hsnomin,fimin,fimax,fi,&     
        tsno,hsno,sand,clay,poros,wsoim,wsoi,wsoi0,wisoi,consoi,zwpmax, wpud,&	
        wipud,wpudmax, qglif ,tsoim ,tsoi,tsoi0,hvasug,hvasui,albsav,albsan,&
        tg,ti,z0soi,swilt,sfield,stressl,stressu,stresstl,stresstu,&
        csoi,rhosoi,hsoi,suction,bex,upsoiu,upsoil,heatg,heati,&
        hydraul,porosflo,ibex,bperm,hflo,o2conc,co2conc,cbiow,&
        sapfrac,cbior ,adrain,adsnow,adaet,adtrunoff,& 
        adsrunoff,addrainage,adrh,adsnod,adsnof,adwsoi,adtsoi, &
        adwisoi,adtlaysoi,adwlaysoi,adwsoic,adtsoic,adco2mic,adco2root, & 
        adco2soi,adco2ratio,adnmintot,decompl,decomps,tnmin,amrain,&     
        amsnow,amaet,amtrunoff,amsrunoff,amdrainage,amtemp,&    
        amqa,amsolar,amirup,amirdown,amsens,amlatent,amlaiu,& 
        amlail,amtsoi,amwsoi,amwisoi,amvwc,amawc,amsnod,amsnof,amnpp,adnpp,& 
        amnpptot,amco2mic,amco2root,amco2soi,amco2ratio,amneetot, &
        amnmintot,amts2,amtransu,amtransl,amsuvap,aminvap,amalbedo,&
        amtsoil,amwsoil,amwisoil,tnpptot,&
	aysolar,ayirup,ayirdown,aysens,aylatent,ayprcp,&    
        ayaet,aytrans,aytrunoff,aysrunoff,aydrainage,aydwtot,aywsoi, &
        aywisoi,aytsoi,ayvwc,ayawc,aystresstu,aystresstl,aygpp,aygpptot,&  
        aynpp,aynpptot,ayco2mic,ayco2root,ayco2soi,ayneetot,ayrootbio, & 
        aynmintot,ayalit,ayblit,aycsoi,aycmic,ayanlit,aybnlit,aynsoi,ayalbedo, &    
        totalit,totrlit,totcsoi,totcmic,totanlit,totrnlit,totnsoi,&   
        totnmic,totlit,totfall,totnlit,firefac,wtot,storedn,yrleach,& 
        ynleach,adfalll,adfallr,adfallw,falll,fallr,fallw,clitlm,clitls,clitrm,clitrs,clitwm,&  
        clitws,csoislop,csoislon,csoipas,clitll,clitrl,clitwl,tw,&
        tc,agddu,tempu,agddl,templ,dropu,dropls,dropl4,dropl3,plai,adplai,&
        deltat,gdd0,gdd0this,tcthis,twthis,tcmin,gdd5,gdd5this,TminL,&	
        TminU,Twarm,GDD,aleaf,awood,cbiol,aroot,specla,td ,vzero,&  
        biomass,totlaiu,totlail,totbiou,totbiol,woodnorm,vegtype0,&
        tauwood0,tauwood,tauleaf,tauroot,xminlai,cdisturb,ayanpp,&
        ayanpptot,garea,asurd,asuri,ndaypm,idateprev,iyear0,&
        ndtimes,nmtimes,nytimes,nppdummy,tco2root,&
        tneetot,tco2mic,iMaskIBIS,&
        ynleach_p ,tnmin_p   ,totnmic_p ,totnlit_p ,totanlit_p, &
        totrnlit_p,totnsoi_p ,storedn_p ,adcbiol,adcbior,adcbiow,beta1,beta2, &
	MskAntIBIS,brf,lonscale,latscale,xintopo,xinveg,clmwet,clmt,clmtrng, &
	clmprec,xinwind,clmcld,clmq,xint,xintrng,xinprec,xincld,xinq,xinwet, &
	Tsfc0IBIS,Qsfc0IBIS,TsfcmIBIS,QsfcmIBIS,iwet,iwetday,precipday,xstore, &
	ayrratio,aytratio,depth
	
	


    USE IbisOutput, ONLY : RunOutput,RunOutput1D,RunOutput1D_Grads, Init_IbisOutput

    implicit none
    
    integer, intent(in) :: n,t
    logical, intent(in) :: key
    integer i,j,k

  character(len=256)        :: ttxt
  INTEGER          :: retint
  
  
  !print *, ' SAND ',key,sand,ibis_struc(n)%ibis(t)%xinveg(1, 1) 
 
 
  if ( key ) then

  iMaskIBIS(1, 1)  = ibis_struc(n)%ibis(t)%iMaskIBIS(1, 1) 
  MskAntIBIS(1, 1) = ibis_struc(n)%ibis(t)%MskAntIBIS(1, 1)
  nlpoints(1)      = ibis_struc(n)%ibis(t)%nlpoints(1)     
!  write(ttxt,*) brf       (1, 1); read(ttxt,*,iostat=retint) ibis_struc(n)%ibis(t)%brf     (1, 1)
  lonscale (1, 1) = ibis_struc(n)%ibis(t)%lonscale(1, 1) 
  latscale (1, 1) = ibis_struc(n)%ibis(t)%latscale(1, 1) 
  xintopo  (1, 1) = ibis_struc(n)%ibis(t)%xintopo (1, 1) 
  garea    (1, 1) = ibis_struc(n)%ibis(t)%garea   (1, 1) 
  xinveg   (1, 1) = ibis_struc(n)%ibis(t)%xinveg  (1, 1) 
  deltat   (1, 1) = ibis_struc(n)%ibis(t)%deltat  (1, 1) 
  do k=1,nsoilay
  sand    (1,k,1) = ibis_struc(n)%ibis(t)%sand(1, k, 1)
  clay    (1,k,1) = ibis_struc(n)%ibis(t)%clay(1, k, 1)
  enddo
  do k=1,12
  clmwet  (1, k ,1) = ibis_struc(n)%ibis(t)%clmwet (1, k, 1)
  clmt    (1, k ,1) = ibis_struc(n)%ibis(t)%clmt   (1, k, 1)
  clmtrng (1, k ,1) = ibis_struc(n)%ibis(t)%clmtrng(1, k, 1)
  clmprec (1, k ,1) = ibis_struc(n)%ibis(t)%clmprec(1, k, 1)
  xinwind (1, k ,1) = ibis_struc(n)%ibis(t)%xinwind(1, k, 1)
  clmcld  (1, k ,1) = ibis_struc(n)%ibis(t)%clmcld (1, k, 1)
  clmq    (1, k ,1) = ibis_struc(n)%ibis(t)%clmq   (1, k, 1)
  xint    (1, k ,1) = ibis_struc(n)%ibis(t)%xint   (1, k, 1)
  xintrng (1, k ,1) = ibis_struc(n)%ibis(t)%xintrng(1, k, 1)
  xinprec (1, k ,1) = ibis_struc(n)%ibis(t)%xinprec(1, k, 1)
  xincld  (1, k ,1) = ibis_struc(n)%ibis(t)%xincld (1, k, 1)
  xinq    (1, k ,1) = ibis_struc(n)%ibis(t)%xinq   (1, k, 1)
  xinwet  (1, k ,1) = ibis_struc(n)%ibis(t)%xinwet (1, k, 1)
  enddo
  
  gdd0    (1, 1)  =  ibis_struc(n)%ibis(t)%gdd0    (1, 1) 
  gdd5    (1, 1)  =  ibis_struc(n)%ibis(t)%gdd5    (1, 1) 
  gdd0this(1, 1)  =  ibis_struc(n)%ibis(t)%gdd0this(1, 1) 
  tcthis  (1, 1)  =  ibis_struc(n)%ibis(t)%tcthis  (1, 1) 
  twthis  (1, 1)  =  ibis_struc(n)%ibis(t)%twthis  (1, 1) 
  gdd5this(1, 1)  =  ibis_struc(n)%ibis(t)%gdd5this(1, 1) 
  tc	  (1, 1)  =  ibis_struc(n)%ibis(t)%tc	   (1, 1) 
  tw	  (1, 1)  =  ibis_struc(n)%ibis(t)%tw	   (1, 1) 
  tcmin   (1, 1)  =  ibis_struc(n)%ibis(t)%tcmin   (1, 1) 
  ndtimes (1, 1)  =  ibis_struc(n)%ibis(t)%ndtimes (1, 1) 
  nmtimes (1, 1)  =  ibis_struc(n)%ibis(t)%nmtimes (1, 1) 
  nytimes (1, 1)  =  ibis_struc(n)%ibis(t)%nytimes (1, 1) 
  do k=1,npft
  nppdummy(1,k,1) = ibis_struc(n)%ibis(t)%nppdummy(1,k, 1) ! canopy NPP before accounting for stem and root respiration
  enddo
  tco2root(1, 1) = ibis_struc(n)%ibis(t)%tco2root(1, 1)! local instantaneous fine co2 flux from soil (mol-CO2 / m-2 / second)
  bperm   (1, 1) = ibis_struc(n)%ibis(t)%bperm	(1, 1)! lower b.c. for soil profile drainage  (0.0 =  1.0 = fully permeable) 
!  write(ttxt,*) wsib	  (1, 1)
!  write(ttxt,*) iMaskSSiB(1, 1)
  do k=1,npft
  exist   (1,k ,1) = ibis_struc(n)%ibis(t)%exist(1, k, 1)
  enddo
  fi	   (1,  1) = ibis_struc(n)%ibis(t)%fi	     (1, 1)
  Tsfc0IBIS(1,  1) = ibis_struc(n)%ibis(t)%Tsfc0IBIS (1, 1)
  Qsfc0IBIS(1,  1) = ibis_struc(n)%ibis(t)%Qsfc0IBIS (1, 1)
  TsfcmIBIS(1,  1) = ibis_struc(n)%ibis(t)%TsfcmIBIS (1, 1)
  QsfcmIBIS(1,  1) = ibis_struc(n)%ibis(t)%QsfcmIBIS (1, 1)


  !do k=1,npft
  do k=1,nsoilay
  tsoi0 (1,k,1)  = ibis_struc(n)%ibis(t)%tsoi0  (1, k, 1)
  tsoi  (1,k,1)  = ibis_struc(n)%ibis(t)%tsoi	(1, k, 1)
  tsoim (1,k,1)  = ibis_struc(n)%ibis(t)%tsoim  (1, k, 1)
  enddo
  hvasug (1, 1)  =  ibis_struc(n)%ibis(t)%hvasug (1, 1)
  hvasui (1, 1)  =  ibis_struc(n)%ibis(t)%hvasui (1, 1)
  do k=1,nsoilay
  wsoim (1,k,1)  =  ibis_struc(n)%ibis(t)%wsoim  (1, k, 1)
  wsoi  (1,k,1)  =  ibis_struc(n)%ibis(t)%wsoi   (1, k, 1)
  wsoi0 (1,k,1)  =  ibis_struc(n)%ibis(t)%wsoi0  (1, k, 1)
  wisoi (1,k,1)  =  ibis_struc(n)%ibis(t)%wisoi  (1, k, 1)
  consoi(1,k,1)  =  ibis_struc(n)%ibis(t)%consoi (1, k, 1)
  enddo
  wpud  (1, 1)   =  ibis_struc(n)%ibis(t)%wpud  (1, 1)
  wipud (1, 1)   =  ibis_struc(n)%ibis(t)%wipud (1, 1)
  do k=1,4
  qglif(1,k ,1)  = ibis_struc(n)%ibis(t)%qglif(1, k, 1)
  enddo


  z0soi  (1, 1)  = ibis_struc(n)%ibis(t)%z0soi (1, 1)
  tg	 (1, 1)  = ibis_struc(n)%ibis(t)%tg_ib (1, 1)
  ti	 (1, 1)  = ibis_struc(n)%ibis(t)%ti    (1, 1)
  albsav (1, 1)  = ibis_struc(n)%ibis(t)%albsav(1, 1)
  albsan (1, 1)  = ibis_struc(n)%ibis(t)%albsan(1, 1)
  do k=1,nsoilay
  rhosoi (1,k,1) = ibis_struc(n)%ibis(t)%rhosoi(1, k, 1)
  csoi   (1,k,1) = ibis_struc(n)%ibis(t)%csoi  (1, k, 1)
  poros  (1,k,1) = ibis_struc(n)%ibis(t)%poros (1, k, 1)
  sfield (1,k,1) = ibis_struc(n)%ibis(t)%sfield(1, k, 1)
  swilt  (1,k,1) = ibis_struc(n)%ibis(t)%swilt (1, k, 1)
  bex	 (1,k,1) = ibis_struc(n)%ibis(t)%bex   (1, k, 1)
  upsoiu (1,k,1) = ibis_struc(n)%ibis(t)%upsoiu(1, k, 1)
  upsoil (1,k,1) = ibis_struc(n)%ibis(t)%upsoil(1, k, 1)
  enddo
  heatg (1, 1)   = ibis_struc(n)%ibis(t)%heatg(1, 1)
  heati (1, 1)        =   ibis_struc(n)%ibis(t)%heati(1, 1)	  
  do k=1,nsoilay						   
  ibex (1,k,1)        =   ibis_struc(n)%ibis(t)%ibex(1, k, 1)    
  enddo   							      
  do k=1,nsoilay+1						   
  hflo (1,k,1)        =   ibis_struc(n)%ibis(t)%hflo(1, k, 1)    
  enddo 							   
  do k=1,nsoilay						   
  suction (1,k,1)     =   ibis_struc(n)%ibis(t)%suction (1,k, 1) 
  hydraul (1,k,1)     =   ibis_struc(n)%ibis(t)%hydraul (1,k, 1) 
  porosflo(1,k,1)     =   ibis_struc(n)%ibis(t)%porosflo(1,k, 1) 
  stressl (1,k,1)     =   ibis_struc(n)%ibis(t)%stressl (1,k, 1) 
  stressu (1,k,1)     =   ibis_struc(n)%ibis(t)%stressu (1,k, 1) 
  enddo 							   
  stresstu(1, 1)      =   ibis_struc(n)%ibis(t)%stresstu(1, 1)   
  stresstl(1, 1)      =   ibis_struc(n)%ibis(t)%stresstl(1, 1)   
  do k=1,nsnolay						   
  tsno(1,k,1)	      =   ibis_struc(n)%ibis(t)%tsno(1, k, 1)	 
  hsno(1,k,1)	      =   ibis_struc(n)%ibis(t)%hsno(1, k, 1)	 
  enddo 							   
  iwet(1, 1)	      =   ibis_struc(n)%ibis(t)%iwet(1, 1)	  
  do k=1,31							   
  iwetday  (1, k, 1)  =   ibis_struc(n)%ibis(t)%iwetday  (1,k,1) 
  precipday(1, k, 1)  =   ibis_struc(n)%ibis(t)%precipday(1,k,1) 
  enddo 							   
  do k=1,nband							   
  asurd   (1, k  ,1)  =   ibis_struc(n)%ibis(t)%asurd(1, k, 1)   
  asuri   (1, k  ,1)  =   ibis_struc(n)%ibis(t)%asuri(1, k, 1)   
  enddo 							   
  do k=1,3							   
  xstore  (1, k, 1)   =   ibis_struc(n)%ibis(t)%xstore(1, k, 1)  
  enddo
  ginvap  (1, 1) =  ibis_struc(n)%ibis(t)%ginvap (1, 1)
  gsuvap  (1, 1) =  ibis_struc(n)%ibis(t)%gsuvap (1, 1)
  gtrans  (1, 1) =  ibis_struc(n)%ibis(t)%gtrans (1, 1)
  gtransu (1, 1) =  ibis_struc(n)%ibis(t)%gtransu(1, 1)
  gtransl (1, 1) =  ibis_struc(n)%ibis(t)%gtransl(1, 1)
  grunof  (1, 1) =  ibis_struc(n)%ibis(t)%grunof (1, 1)
  gdrain  (1, 1) =  ibis_struc(n)%ibis(t)%gdrain (1, 1)
  gadjust (1, 1) =  ibis_struc(n)%ibis(t)%gadjust(1, 1)
  wtot    (1, 1) =  ibis_struc(n)%ibis(t)%wtot   (1, 1)
  adfalll (1, 1) =  ibis_struc(n)%ibis(t)%adfalll(1, 1)
  adfallr (1, 1) =  ibis_struc(n)%ibis(t)%adfallr(1, 1)
  adfallw (1, 1) =  ibis_struc(n)%ibis(t)%adfallw(1, 1)
  do k=1,npft
  adnpp(1, k, 1) =  ibis_struc(n)%ibis(t)%adnpp(1,k, 1)
  enddo


  a10td      (1, 1)    =  ibis_struc(n)%ibis(t)%a10td	     (1, 1) 
  a10ancub   (1, 1)    =  ibis_struc(n)%ibis(t)%a10ancub     (1, 1) 
  a10ancuc   (1, 1)    =  ibis_struc(n)%ibis(t)%a10ancuc     (1, 1) 
  a10ancls   (1, 1)    =  ibis_struc(n)%ibis(t)%a10ancls     (1, 1) 
  a10ancl4   (1, 1)    =  ibis_struc(n)%ibis(t)%a10ancl4     (1, 1) 
  a10ancl3   (1, 1)    =  ibis_struc(n)%ibis(t)%a10ancl3     (1, 1) 
  a10scalparamu(1, 1)  =  ibis_struc(n)%ibis(t)%a10scalparamu(1, 1) 
  a10scalparaml(1, 1)  =  ibis_struc(n)%ibis(t)%a10scalparaml(1, 1) 
  a10daylightu (1, 1)  =  ibis_struc(n)%ibis(t)%a10daylightu (1, 1) 
  a10daylightl (1, 1)  =  ibis_struc(n)%ibis(t)%a10daylightl (1, 1) 
  adrain     (1, 1)    =  ibis_struc(n)%ibis(t)%adrain       (1, 1) 
  adsnow     (1, 1)    =  ibis_struc(n)%ibis(t)%adsnow       (1, 1) 
  adaet      (1, 1)    =  ibis_struc(n)%ibis(t)%adaet	     (1, 1) 
  adtrunoff  (1, 1)    =  ibis_struc(n)%ibis(t)%adtrunoff    (1, 1) 
  adsrunoff  (1, 1)    =  ibis_struc(n)%ibis(t)%adsrunoff    (1, 1) 
  addrainage   (1, 1)  =  ibis_struc(n)%ibis(t)%addrainage   (1, 1) 
  adrh       (1, 1)    =  ibis_struc(n)%ibis(t)%adrh	     (1, 1) 
  adsnod     (1, 1)    =  ibis_struc(n)%ibis(t)%adsnod       (1, 1) 
  adsnof     (1, 1)    =  ibis_struc(n)%ibis(t)%adsnof       (1, 1) 
  adwsoi     (1, 1)    =  ibis_struc(n)%ibis(t)%adwsoi       (1, 1) 
  adtsoi     (1, 1)    =  ibis_struc(n)%ibis(t)%adtsoi       (1, 1) 
  adwisoi    (1, 1)    =  ibis_struc(n)%ibis(t)%adwisoi      (1, 1) 
  adtlaysoi  (1, 1)    =  ibis_struc(n)%ibis(t)%adtlaysoi    (1, 1) 
  adwlaysoi  (1, 1)    =  ibis_struc(n)%ibis(t)%adwlaysoi    (1, 1) 
  adwsoic    (1, 1)    =  ibis_struc(n)%ibis(t)%adwsoic      (1, 1) 
  adtsoic    (1, 1)    =  ibis_struc(n)%ibis(t)%adtsoic      (1, 1) 
  adco2mic   (1, 1)    =  ibis_struc(n)%ibis(t)%adco2mic     (1, 1) 
  adco2root  (1, 1)    =  ibis_struc(n)%ibis(t)%adco2root    (1, 1) 
  adco2soi   (1, 1)    =  ibis_struc(n)%ibis(t)%adco2soi     (1, 1) 
  adco2ratio   (1, 1)  =  ibis_struc(n)%ibis(t)%adco2ratio   (1, 1) 
  adnmintot  (1, 1)    =  ibis_struc(n)%ibis(t)%adnmintot    (1, 1) 



  amtemp    (1, 1) =  ibis_struc(n)%ibis(t)%amtemp     (1, 1)
  amrain    (1, 1) =  ibis_struc(n)%ibis(t)%amrain     (1, 1)
  amsnow    (1, 1) =  ibis_struc(n)%ibis(t)%amsnow     (1, 1)
  amaet     (1, 1) =  ibis_struc(n)%ibis(t)%amaet      (1, 1)
  amtrunoff (1, 1) =  ibis_struc(n)%ibis(t)%amtrunoff  (1, 1)
  amsrunoff (1, 1) =  ibis_struc(n)%ibis(t)%amsrunoff  (1, 1)
  amdrainage(1, 1) =  ibis_struc(n)%ibis(t)%amdrainage (1, 1)
  amqa      (1, 1) =  ibis_struc(n)%ibis(t)%amqa       (1, 1)
  amsolar   (1, 1) =  ibis_struc(n)%ibis(t)%amsolar    (1, 1)
  amirup    (1, 1) =  ibis_struc(n)%ibis(t)%amirup     (1, 1)
  amirdown  (1, 1) =  ibis_struc(n)%ibis(t)%amirdown   (1, 1)
  amsens    (1, 1) =  ibis_struc(n)%ibis(t)%amsens     (1, 1)
  amlatent  (1, 1) =  ibis_struc(n)%ibis(t)%amlatent   (1, 1)
  amlaiu    (1, 1) =  ibis_struc(n)%ibis(t)%amlaiu     (1, 1)
  amlail    (1, 1) =  ibis_struc(n)%ibis(t)%amlail     (1, 1)
  amtsoi    (1, 1) =  ibis_struc(n)%ibis(t)%amtsoi     (1, 1)
  amwsoi    (1, 1) =  ibis_struc(n)%ibis(t)%amwsoi     (1, 1)
  amwisoi   (1, 1) =  ibis_struc(n)%ibis(t)%amwisoi    (1, 1)
  amvwc     (1, 1) =  ibis_struc(n)%ibis(t)%amvwc      (1, 1)
  amawc     (1, 1) =  ibis_struc(n)%ibis(t)%amawc      (1, 1)
  amsnod    (1, 1) =  ibis_struc(n)%ibis(t)%amsnod     (1, 1)
  amsnof    (1, 1) =  ibis_struc(n)%ibis(t)%amsnof     (1, 1)
  amco2mic  (1, 1) =  ibis_struc(n)%ibis(t)%amco2mic   (1, 1)
  amco2root (1, 1) =  ibis_struc(n)%ibis(t)%amco2root  (1, 1)
  amnmintot (1, 1) =  ibis_struc(n)%ibis(t)%amnmintot  (1, 1)
  do k=1,npft
  tauwood(1, k, 1)    = ibis_struc(n)%ibis(t)%tauwood(1, k, 1) ! wood biomass turnover(rotatividade) time constant (years)
  amnpp  (1, k, 1)    = ibis_struc(n)%ibis(t)%amnpp  (1, k, 1) 
  enddo 							  
  amts2     (1, 1)    = ibis_struc(n)%ibis(t)%amts2	(1, 1) 
  amtransu  (1, 1)    = ibis_struc(n)%ibis(t)%amtransu  (1, 1) 
  amtransl  (1, 1)    = ibis_struc(n)%ibis(t)%amtransl  (1, 1) 
  amsuvap   (1, 1)    = ibis_struc(n)%ibis(t)%amsuvap	(1, 1) 
  aminvap   (1, 1)    = ibis_struc(n)%ibis(t)%aminvap	(1, 1) 
  amneetot  (1, 1)    = ibis_struc(n)%ibis(t)%amneetot  (1, 1) 
  amco2ratio(1, 1)    = ibis_struc(n)%ibis(t)%amco2ratio(1, 1) 
  amnpptot  (1, 1)    = ibis_struc(n)%ibis(t)%amnpptot  (1, 1) 
  amco2soi  (1, 1)    = ibis_struc(n)%ibis(t)%amco2soi  (1, 1) 
  amalbedo  (1, 1)    = ibis_struc(n)%ibis(t)%amalbedo  (1, 1) 
  do k=1,nsoilay						 
  amtsoil   (1, k, 1) = ibis_struc(n)%ibis(t)%amtsoil (1,k, 1) 
  amwsoil   (1, k, 1) = ibis_struc(n)%ibis(t)%amwsoil (1,k, 1) 
  amwisoil  (1, k, 1) = ibis_struc(n)%ibis(t)%amwisoil(1,k, 1) 
  enddo 							 
  aysolar   (1, 1)    = ibis_struc(n)%ibis(t)%aysolar	(1, 1) 
  ayirup    (1, 1)    = ibis_struc(n)%ibis(t)%ayirup	(1, 1) 
  ayirdown  (1, 1)    = ibis_struc(n)%ibis(t)%ayirdown  (1, 1) 
  aysens    (1, 1)    = ibis_struc(n)%ibis(t)%aysens	(1, 1) 
  aylatent  (1, 1)    = ibis_struc(n)%ibis(t)%aylatent  (1, 1) 
  ayprcp    (1, 1)    = ibis_struc(n)%ibis(t)%ayprcp	(1, 1) 
  ayaet     (1, 1)    = ibis_struc(n)%ibis(t)%ayaet	(1, 1) 
  aytrans   (1, 1)    = ibis_struc(n)%ibis(t)%aytrans	(1, 1) 
  aytrunoff (1, 1)    = ibis_struc(n)%ibis(t)%aytrunoff (1, 1) 
  aysrunoff (1, 1)    = ibis_struc(n)%ibis(t)%aysrunoff (1, 1) 
  aydrainage(1, 1)    = ibis_struc(n)%ibis(t)%aydrainage(1, 1) 
  aydwtot   (1, 1)    = ibis_struc(n)%ibis(t)%aydwtot	(1, 1) 
  aygpptot  (1, 1)    = ibis_struc(n)%ibis(t)%aydrainage(1, 1) 
  do k=1,npft  
  aynpp  (1, k, 1)    = ibis_struc(n)%ibis(t)%aynpp  (1, k, 1)
  enddo


  aynpptot  (1 ,1) = ibis_struc(n)%ibis(t)%aydrainage(1, 1)  
  ayco2soi  (1 ,1) = ibis_struc(n)%ibis(t)%aydrainage(1, 1)  
  ayneetot  (1 ,1) = ibis_struc(n)%ibis(t)%aydrainage(1, 1)  
  totnsoi   (1 ,1) = ibis_struc(n)%ibis(t)%totnsoi   (1, 1)
  aywsoi    (1 ,1) = ibis_struc(n)%ibis(t)%aywsoi    (1, 1)
  aywisoi   (1 ,1) = ibis_struc(n)%ibis(t)%aywisoi   (1, 1)
  aytsoi    (1 ,1) = ibis_struc(n)%ibis(t)%aytsoi    (1, 1)
  ayvwc     (1 ,1) = ibis_struc(n)%ibis(t)%ayvwc     (1, 1)
  ayawc     (1 ,1) = ibis_struc(n)%ibis(t)%ayawc     (1, 1)
  aystresstu(1 ,1) = ibis_struc(n)%ibis(t)%aystresstu(1, 1)
  aystresstl(1 ,1) = ibis_struc(n)%ibis(t)%aystresstl(1, 1)
  ayco2mic  (1 ,1) = ibis_struc(n)%ibis(t)%ayco2mic  (1, 1)
  ayco2root (1 ,1) = ibis_struc(n)%ibis(t)%ayco2root (1, 1)
  ayrootbio (1 ,1) = ibis_struc(n)%ibis(t)%ayrootbio (1, 1)
  aynmintot (1 ,1) = ibis_struc(n)%ibis(t)%aynmintot (1, 1)
  ayalit    (1 ,1) = ibis_struc(n)%ibis(t)%ayalit    (1, 1)
  ayblit    (1 ,1) = ibis_struc(n)%ibis(t)%ayblit    (1, 1)
  aycsoi    (1 ,1) = ibis_struc(n)%ibis(t)%aycsoi    (1, 1)
  aycmic    (1 ,1) = ibis_struc(n)%ibis(t)%aycmic    (1, 1)
  ayanlit   (1 ,1) = ibis_struc(n)%ibis(t)%ayanlit   (1, 1)
  aybnlit   (1 ,1) = ibis_struc(n)%ibis(t)%aybnlit   (1, 1)
  aynsoi    (1 ,1) = ibis_struc(n)%ibis(t)%aynsoi    (1, 1)
  ayalbedo  (1 ,1) = ibis_struc(n)%ibis(t)%ayalbedo  (1, 1)
  do k=1,npft						      
  aygpp  (1, k, 1) = ibis_struc(n)%ibis(t)%aygpp  (1, k, 1)
  ayanpp (1, k, 1) = ibis_struc(n)%ibis(t)%ayanpp (1, k, 1)
  enddo 						      
  ayanpptot (1 ,1) = ibis_struc(n)%ibis(t)%ayanpptot (1, 1)
  ayrratio  (1 ,1) = ibis_struc(n)%ibis(t)%ayrratio  (1, 1)
  aytratio  (1 ,1) = ibis_struc(n)%ibis(t)%aytratio  (1, 1)
  totcondub (1 ,1) = ibis_struc(n)%ibis(t)%totcondub (1, 1)
  totconduc (1 ,1) = ibis_struc(n)%ibis(t)%totconduc (1, 1)
  totcondls (1 ,1) = ibis_struc(n)%ibis(t)%totcondls (1, 1)
  totcondl3 (1 ,1) = ibis_struc(n)%ibis(t)%totcondl3 (1, 1)
  totcondl4 (1 ,1) = ibis_struc(n)%ibis(t)%totcondl4 (1, 1)
  do k=1,npft
  frac (1, k, 1) = ibis_struc(n)%ibis(t)%frac (1, k, 1)
  enddo
  tum	  (1, 1) = ibis_struc(n)%ibis(t)%tum	 (1, 1)
  tu	  (1, 1) = ibis_struc(n)%ibis(t)%tu	 (1, 1)
  tu0	  (1, 1) = ibis_struc(n)%ibis(t)%tu0	 (1, 1)
  ts	  (1, 1) = ibis_struc(n)%ibis(t)%ts	 (1, 1)
  tl	  (1, 1) = ibis_struc(n)%ibis(t)%tl	 (1, 1)
  topparu (1, 1) = ibis_struc(n)%ibis(t)%topparu (1, 1)
  topparl (1, 1) = ibis_struc(n)%ibis(t)%topparl (1, 1)
  agcub   (1, 1) = ibis_struc(n)%ibis(t)%agcub   (1, 1)
  agcuc   (1, 1) = ibis_struc(n)%ibis(t)%agcuc   (1, 1)
  ancub   (1, 1) = ibis_struc(n)%ibis(t)%ancub   (1, 1)
  ancuc   (1, 1) = ibis_struc(n)%ibis(t)%ancuc   (1, 1)
  tlsub   (1, 1) = ibis_struc(n)%ibis(t)%tlsub   (1, 1)
  t12	  (1, 1) = ibis_struc(n)%ibis(t)%t12	 (1, 1)
  t34	  (1, 1) = ibis_struc(n)%ibis(t)%t34	 (1, 1)
  q12	  (1, 1) = ibis_struc(n)%ibis(t)%q12	 (1, 1)
  q34	  (1, 1) = ibis_struc(n)%ibis(t)%q34	 (1, 1)
  ciub    (1, 1) = ibis_struc(n)%ibis(t)%ciub	 (1, 1)
  ciuc    (1, 1) = ibis_struc(n)%ibis(t)%ciuc	 (1, 1)
  cils    (1, 1) = ibis_struc(n)%ibis(t)%cils	 (1, 1)
  cil3    (1, 1) = ibis_struc(n)%ibis(t)%cil3	 (1, 1)
  cil4    (1, 1) = ibis_struc(n)%ibis(t)%cil4	 (1, 1)
  csub    (1, 1) = ibis_struc(n)%ibis(t)%csub	 (1, 1)
  csuc    (1, 1) = ibis_struc(n)%ibis(t)%csuc	 (1, 1)
  csls    (1, 1) = ibis_struc(n)%ibis(t)%csls	 (1, 1)
  csl3    (1, 1) = ibis_struc(n)%ibis(t)%csl3	 (1, 1)
  csl4    (1, 1) = ibis_struc(n)%ibis(t)%csl4	 (1, 1)
  gsub    (1, 1) = ibis_struc(n)%ibis(t)%gsub	 (1, 1)
  gsuc    (1, 1) = ibis_struc(n)%ibis(t)%gsuc	 (1, 1)
  gsls    (1, 1) = ibis_struc(n)%ibis(t)%gsls	 (1, 1)
  gsl3    (1, 1) = ibis_struc(n)%ibis(t)%gsl3	 (1, 1)
  gsl4    (1, 1) = ibis_struc(n)%ibis(t)%gsl4	 (1, 1)
  agcls   (1, 1) = ibis_struc(n)%ibis(t)%agcls   (1, 1)
  agcl4   (1, 1) = ibis_struc(n)%ibis(t)%agcl4   (1, 1)
  agcl3   (1, 1) = ibis_struc(n)%ibis(t)%agcl3   (1, 1)
  ancls   (1, 1) = ibis_struc(n)%ibis(t)%ancls   (1, 1)
  ancl4   (1, 1) = ibis_struc(n)%ibis(t)%ancl4   (1, 1)
  ancl3   (1, 1) = ibis_struc(n)%ibis(t)%ancl3   (1, 1)
  clitlm  (1, 1) = ibis_struc(n)%ibis(t)%clitlm  (1, 1)
  clitls  (1, 1) = ibis_struc(n)%ibis(t)%clitls  (1, 1)
  clitll  (1, 1) = ibis_struc(n)%ibis(t)%clitll  (1, 1)
  clitrm  (1, 1) = ibis_struc(n)%ibis(t)%clitrm  (1, 1)
  clitrs  (1, 1) = ibis_struc(n)%ibis(t)%clitrs  (1, 1)
  clitrl  (1, 1) = ibis_struc(n)%ibis(t)%clitrl  (1, 1)
  clitwm  (1, 1) = ibis_struc(n)%ibis(t)%clitwm  (1, 1)
  clitws  (1, 1) = ibis_struc(n)%ibis(t)%clitws  (1, 1)
  clitwl  (1, 1) = ibis_struc(n)%ibis(t)%clitwl  (1, 1)
  totcmic (1, 1) = ibis_struc(n)%ibis(t)%totcmic (1, 1)
  csoislop(1, 1) = ibis_struc(n)%ibis(t)%csoislop(1, 1)
  csoislon(1, 1) = ibis_struc(n)%ibis(t)%csoislon(1, 1)
  csoipas (1, 1) = ibis_struc(n)%ibis(t)%csoipas (1, 1)
  totlit  (1, 1) = ibis_struc(n)%ibis(t)%totlit  (1, 1)
  totnlit (1, 1) = ibis_struc(n)%ibis(t)%totnlit (1, 1)
  totfall (1, 1) = ibis_struc(n)%ibis(t)%totfall (1, 1)
  totalit (1, 1) = ibis_struc(n)%ibis(t)%totalit (1, 1)
  totrlit (1, 1) = ibis_struc(n)%ibis(t)%totrlit (1, 1)
  totanlit(1, 1) = ibis_struc(n)%ibis(t)%totanlit(1, 1)
  totrnlit(1, 1) = ibis_struc(n)%ibis(t)%totrnlit(1, 1)
  totcsoi (1, 1) = ibis_struc(n)%ibis(t)%totcsoi (1, 1)
  totnmic (1, 1) = ibis_struc(n)%ibis(t)%totnmic (1, 1)
  tco2mic (1, 1) = ibis_struc(n)%ibis(t)%tco2mic (1, 1)
  tnpptot (1, 1) = ibis_struc(n)%ibis(t)%tnpptot (1, 1)
  tneetot (1, 1) = ibis_struc(n)%ibis(t)%tneetot (1, 1)
  tnmin   (1, 1) = ibis_struc(n)%ibis(t)%tnmin   (1, 1)
  cdisturb(1, 1) = ibis_struc(n)%ibis(t)%cdisturb(1, 1)
  tempu   (1, 1) = ibis_struc(n)%ibis(t)%tempu   (1, 1)
  templ   (1, 1) = ibis_struc(n)%ibis(t)%templ   (1, 1)
  dropu   (1, 1) = ibis_struc(n)%ibis(t)%dropu   (1, 1)
  dropls  (1, 1) = ibis_struc(n)%ibis(t)%dropls  (1, 1)
  dropl4  (1, 1) = ibis_struc(n)%ibis(t)%dropl4  (1, 1)
  dropl3  (1, 1) = ibis_struc(n)%ibis(t)%dropl3  (1, 1)
  wliqu   (1, 1) = ibis_struc(n)%ibis(t)%wliqu   (1, 1)
  wliqs   (1, 1) = ibis_struc(n)%ibis(t)%wliqs   (1, 1)
  wliql   (1, 1) = ibis_struc(n)%ibis(t)%wliql   (1, 1)
  wsnou   (1, 1) = ibis_struc(n)%ibis(t)%wsnou   (1, 1)
  wsnos   (1, 1) = ibis_struc(n)%ibis(t)%wsnos   (1, 1)
  wsnol   (1, 1) = ibis_struc(n)%ibis(t)%wsnol   (1, 1)
  su	  (1, 1) = ibis_struc(n)%ibis(t)%su	 (1, 1)
  ss	  (1, 1) = ibis_struc(n)%ibis(t)%ss	 (1, 1)
  sl	  (1, 1) = ibis_struc(n)%ibis(t)%sl	 (1, 1)
  agddu   (1, 1) = ibis_struc(n)%ibis(t)%agddu   (1, 1)
  agddl   (1, 1) = ibis_struc(n)%ibis(t)%agddl   (1, 1)
  storedn (1, 1) = ibis_struc(n)%ibis(t)%storedn (1, 1)
  yrleach (1, 1) = ibis_struc(n)%ibis(t)%yrleach (1, 1)
  ynleach (1, 1) = ibis_struc(n)%ibis(t)%ynleach (1, 1)
  falll   (1, 1) = ibis_struc(n)%ibis(t)%falll   (1, 1)
  fallr   (1, 1) = ibis_struc(n)%ibis(t)%fallr   (1, 1)
  fallw   (1, 1) = ibis_struc(n)%ibis(t)%fallw   (1, 1)
  vegtype0(1, 1) = ibis_struc(n)%ibis(t)%vegtype0(1, 1)


  do k=1,npft
  plai   (1 ,k, 1)   = ibis_struc(n)%ibis(t)%plai  (1, k, 1)  
  adplai (1 ,k, 1)   = ibis_struc(n)%ibis(t)%adplai(1, k, 1)  
  enddo 							
  sapfrac (1, 1)     = ibis_struc(n)%ibis(t)%sapfrac (1, 1)   
  do k=1,npft							
  cbiol  (1, k, 1)   = ibis_struc(n)%ibis(t)%cbiol  (1, k, 1) 
  adcbiol(1, k, 1)   = ibis_struc(n)%ibis(t)%adcbiol(1, k, 1) 
  cbior  (1, k, 1)   = ibis_struc(n)%ibis(t)%cbior  (1, k, 1) 
  adcbior(1, k, 1)   = ibis_struc(n)%ibis(t)%adcbior(1, k, 1) 
  cbiow  (1, k, 1)   = ibis_struc(n)%ibis(t)%cbiow  (1, k, 1) 
  adcbiow(1, k, 1)   = ibis_struc(n)%ibis(t)%adcbiow(1, k, 1) 
  biomass(1, k, 1)   = ibis_struc(n)%ibis(t)%biomass(1, k, 1) 
  enddo 							
  totlaiu(1, 1)      = ibis_struc(n)%ibis(t)%totlaiu (1, 1)   
  totlail(1, 1)      = ibis_struc(n)%ibis(t)%totlail (1, 1)   
  totbiou(1, 1)      = ibis_struc(n)%ibis(t)%totbiou (1, 1)   
  totbiol(1, 1)      = ibis_struc(n)%ibis(t)%totbiol (1, 1)   
  do k=1,2							
  sai  (1 ,k ,1)     = ibis_struc(n)%ibis(t)%sai_ib (1, k, 1) 
  enddo 							
  fu	 (1, 1)      = ibis_struc(n)%ibis(t)%fu     (1, 1)    
  fl	 (1, 1)      = ibis_struc(n)%ibis(t)%fl     (1, 1)    
  do k=1,2							
  lai	 (1 ,k  ,1)  = ibis_struc(n)%ibis(t)%lai_ib (1, k, 1) 
  zbot   (1 ,k  ,1)  = ibis_struc(n)%ibis(t)%zbot(1, k, 1)    
  ztop   (1 ,k  ,1)  = ibis_struc(n)%ibis(t)%ztop(1, k, 1)    
  enddo		 							       
  decompl(1, 1)      = ibis_struc(n)%ibis(t)%decompl (1, 1)   
  decomps(1, 1)      = ibis_struc(n)%ibis(t)%decomps (1, 1)   
  firefac(1, 1)      = ibis_struc(n)%ibis(t)%firefac (1, 1)   
  do k=1,nsoilay						
  do j=1,2							
  froot    (1,k,j,1) = ibis_struc(n)%ibis(t)%froot(1,k, j, 1) 
  enddo 							
  enddo 							
  do k=1,nsoilay+1						
  hsoi(1,k,1)        = ibis_struc(n)%ibis(t)%hsoi(1, k, 1)    
  enddo 							
  vzero(1, 1)	     = ibis_struc(n)%ibis(t)%vzero (1, 1)     
  td   (1, 1)	     = ibis_struc(n)%ibis(t)%td    (1, 1)     

  ynleach_p (1 ,1)   = ibis_struc(n)%ibis(t)%ynleach_p (1, 1) ! annual total amount P leached from soil profile (kg_N m-2/yr)
  tnmin_p   (1 ,1)   = ibis_struc(n)%ibis(t)%tnmin_p   (1, 1)! instantaneous phosphorus mineralization (kg_N m-2/timestep)
  totnmic_p (1 ,1)   = ibis_struc(n)%ibis(t)%totnmic_p (1, 1)! total phosphorus residing in microbial pool     (kg_N m-2)
  totnlit_p (1 ,1)   = ibis_struc(n)%ibis(t)%totnlit_p (1, 1)! total phosphorus in all litter pools	(kg_N m-2)
  totanlit_p (1 ,1)  = ibis_struc(n)%ibis(t)%totanlit_p(1, 1)! total standing aboveground phosphorus in litter (kg_N m-2)
  totrnlit_p(1 ,1)   = ibis_struc(n)%ibis(t)%totrnlit_p(1, 1)! total root litter phosphorus belowground		 (kg_N m-2)
  totnsoi_p (1 ,1)   = ibis_struc(n)%ibis(t)%totnsoi_p (1, 1)! total phosphorus in soil				 (kg_N m-2)
  storedn_p (1 ,1)   = ibis_struc(n)%ibis(t)%storedn_p (1, 1)! total storage of P in soil profile (kg_N m-2) 
  do k=1,nsoilay
  depth(k)           = ibis_struc(n)%ibis(t)%depth(k)
  enddo






ELSE

   ibis_struc(n)%ibis(t)%iMaskIBIS(1, 1) =  iMaskIBIS(1, 1)
   ibis_struc(n)%ibis(t)%MskAntIBIS(1, 1)=  MskAntIBIS(1, 1)
   ibis_struc(n)%ibis(t)%nlpoints(1)	 =  nlpoints(1) 
!  write(ttxt,*) brf       (1, 1); read(ttxt,*,iostat=retint) ibis_struc(n)%ibis(t)%brf     (1, 1)
  ibis_struc(n)%ibis(t)%lonscale(1, 1)   = lonscale (1, 1)
  ibis_struc(n)%ibis(t)%latscale(1, 1)   = latscale (1, 1)
  ibis_struc(n)%ibis(t)%xintopo (1, 1)   = xintopo  (1, 1)
  ibis_struc(n)%ibis(t)%garea	(1, 1)   = garea    (1, 1)
  ibis_struc(n)%ibis(t)%xinveg  (1, 1)   = xinveg   (1, 1)
  ibis_struc(n)%ibis(t)%deltat  (1, 1)   = deltat   (1, 1)
  do k=1,nsoilay
  ibis_struc(n)%ibis(t)%sand(1, k, 1)    = sand    (1,k,1)
  ibis_struc(n)%ibis(t)%clay(1, k, 1)    = clay    (1,k,1)
  enddo
  do k=1,12
  ibis_struc(n)%ibis(t)%clmwet (1, k, 1) = clmwet  (1, k ,1)
  ibis_struc(n)%ibis(t)%clmt   (1, k, 1) = clmt	   (1, k ,1)
  ibis_struc(n)%ibis(t)%clmtrng(1, k, 1) = clmtrng (1, k ,1)
  ibis_struc(n)%ibis(t)%clmprec(1, k, 1) = clmprec (1, k ,1)
  ibis_struc(n)%ibis(t)%xinwind(1, k, 1) = xinwind (1, k ,1)
  ibis_struc(n)%ibis(t)%clmcld (1, k, 1) = clmcld  (1, k ,1)
  ibis_struc(n)%ibis(t)%clmq   (1, k, 1) = clmq	   (1, k ,1)
  ibis_struc(n)%ibis(t)%xint   (1, k, 1) = xint	   (1, k ,1)  
  ibis_struc(n)%ibis(t)%xintrng(1, k, 1) = xintrng (1, k ,1)
  ibis_struc(n)%ibis(t)%xinprec(1, k, 1) = xinprec (1, k ,1)
  ibis_struc(n)%ibis(t)%xincld (1, k, 1) = xincld  (1, k ,1)
  ibis_struc(n)%ibis(t)%xinq   (1, k, 1) = xinq	   (1, k ,1)  
  ibis_struc(n)%ibis(t)%xinwet (1, k, 1) = xinwet  (1, k ,1)
  enddo
  
  ibis_struc(n)%ibis(t)%gdd0	(1, 1)   =  gdd0    (1, 1) 
  ibis_struc(n)%ibis(t)%gdd5	(1, 1)   =  gdd5    (1, 1) 
  ibis_struc(n)%ibis(t)%gdd0this(1, 1)   =  gdd0this(1, 1) 
  ibis_struc(n)%ibis(t)%tcthis  (1, 1)   =  tcthis  (1, 1) 
  ibis_struc(n)%ibis(t)%twthis  (1, 1)   =  twthis  (1, 1) 
  ibis_struc(n)%ibis(t)%gdd5this(1, 1)   =  gdd5this(1, 1) 
  ibis_struc(n)%ibis(t)%tc	(1, 1)   =  tc	    (1, 1) 
  ibis_struc(n)%ibis(t)%tw	(1, 1)   =  tw	    (1, 1) 
  ibis_struc(n)%ibis(t)%tcmin	(1, 1)   =  tcmin   (1, 1) 
  ibis_struc(n)%ibis(t)%ndtimes (1, 1)   =  ndtimes (1, 1) 
  ibis_struc(n)%ibis(t)%nmtimes (1, 1)   =  nmtimes (1, 1) 
  ibis_struc(n)%ibis(t)%nytimes (1, 1)   =  nytimes (1, 1) 
  do k=1,npft
  ibis_struc(n)%ibis(t)%nppdummy(1,k, 1) = nppdummy  (1,k,1)  ! canopy NPP before accounting for stem and root respiration
  enddo
  ibis_struc(n)%ibis(t)%tco2root(1, 1)   = tco2root(1, 1) ! local instantaneous fine co2 flux from soil (mol-CO2 / m-2 / second)
  ibis_struc(n)%ibis(t)%bperm   (1, 1)   = bperm   (1, 1) ! lower b.c. for soil profile drainage  (0.0 =  1.0 = fully permeable) 
!  write(ttxt,*) wsib	  (1, 1)
!  write(ttxt,*) iMaskSSiB(1, 1)
  do k=1,npft
  ibis_struc(n)%ibis(t)%exist(1, k, 1)   = exist   (1,k ,1)
  enddo
  ibis_struc(n)%ibis(t)%fi	  (1, 1) = fi	    (1,  1)
  ibis_struc(n)%ibis(t)%Tsfc0IBIS (1, 1) = Tsfc0IBIS(1,  1)
  ibis_struc(n)%ibis(t)%Qsfc0IBIS (1, 1) = Qsfc0IBIS(1,  1)
  ibis_struc(n)%ibis(t)%TsfcmIBIS (1, 1) = TsfcmIBIS(1,  1)
  ibis_struc(n)%ibis(t)%QsfcmIBIS (1, 1) = QsfcmIBIS(1,  1)


  !do k=1,npft
  do k=1,nsoilay
  ibis_struc(n)%ibis(t)%tsoi0  (1, k, 1) = tsoi0 (1,k,1)
  ibis_struc(n)%ibis(t)%tsoi   (1, k, 1) = tsoi	 (1,k,1)
  ibis_struc(n)%ibis(t)%tsoim  (1, k, 1) = tsoim (1,k,1)
  enddo
  ibis_struc(n)%ibis(t)%hvasug (1, 1)    = hvasug (1, 1)
  ibis_struc(n)%ibis(t)%hvasui (1, 1)    = hvasui (1, 1)
  do k=1,nsoilay
  ibis_struc(n)%ibis(t)%wsoim  (1, k, 1) = wsoim (1,k,1)
  ibis_struc(n)%ibis(t)%wsoi   (1, k, 1) = wsoi	 (1,k,1)
  ibis_struc(n)%ibis(t)%wsoi0  (1, k, 1) = wsoi0 (1,k,1)
  ibis_struc(n)%ibis(t)%wisoi  (1, k, 1) = wisoi (1,k,1)
  ibis_struc(n)%ibis(t)%consoi (1, k, 1) = consoi(1,k,1)
  enddo
  ibis_struc(n)%ibis(t)%wpud  (1, 1)     = wpud  (1, 1)
  ibis_struc(n)%ibis(t)%wipud (1, 1)     = wipud (1, 1)
  do k=1,4
  ibis_struc(n)%ibis(t)%qglif(1, k, 1)   = qglif(1,k ,1)
  enddo


  ibis_struc(n)%ibis(t)%z0soi (1, 1)     = z0soi  (1, 1)
  ibis_struc(n)%ibis(t)%tg_ib (1, 1)     = tg     (1, 1) 
  ibis_struc(n)%ibis(t)%ti    (1, 1)     = ti     (1, 1)
  ibis_struc(n)%ibis(t)%albsav(1, 1)     = albsav (1, 1)
  ibis_struc(n)%ibis(t)%albsan(1, 1)     = albsan (1, 1)
  do k=1,nsoilay
  ibis_struc(n)%ibis(t)%rhosoi(1, k, 1)  = rhosoi (1,k,1)
  ibis_struc(n)%ibis(t)%csoi  (1, k, 1)  = csoi   (1,k,1)
  ibis_struc(n)%ibis(t)%poros (1, k, 1)  = poros  (1,k,1)
  ibis_struc(n)%ibis(t)%sfield(1, k, 1)  = sfield (1,k,1)
  ibis_struc(n)%ibis(t)%swilt (1, k, 1)  = swilt  (1,k,1)
  ibis_struc(n)%ibis(t)%bex   (1, k, 1)  = bex    (1,k,1)
  ibis_struc(n)%ibis(t)%upsoiu(1, k, 1)  = upsoiu (1,k,1)
  ibis_struc(n)%ibis(t)%upsoil(1, k, 1)  = upsoil (1,k,1)
  enddo
  ibis_struc(n)%ibis(t)%heatg(1, 1)      = heatg (1, 1)
  ibis_struc(n)%ibis(t)%heati(1, 1)      = heati (1, 1)
  do k=1,nsoilay
  ibis_struc(n)%ibis(t)%ibex(1, k, 1)    = ibex (1,k,1)
  enddo   
  do k=1,nsoilay+1
  ibis_struc(n)%ibis(t)%hflo(1, k, 1)    = hflo (1,k,1)
  enddo
  do k=1,nsoilay
  ibis_struc(n)%ibis(t)%suction (1,k, 1) = suction (1,k,1) 
  ibis_struc(n)%ibis(t)%hydraul (1,k, 1) = hydraul (1,k,1)
  ibis_struc(n)%ibis(t)%porosflo(1,k, 1) = porosflo(1,k,1)
  ibis_struc(n)%ibis(t)%stressl (1,k, 1) = stressl (1,k,1)
  ibis_struc(n)%ibis(t)%stressu (1,k, 1) = stressu (1,k,1)
  enddo
  ibis_struc(n)%ibis(t)%stresstu(1, 1)   = stresstu(1, 1) 
  ibis_struc(n)%ibis(t)%stresstl(1, 1)   = stresstl(1, 1)
  do k=1,nsnolay
  ibis_struc(n)%ibis(t)%tsno(1, k, 1)    = tsno(1,k,1)
  ibis_struc(n)%ibis(t)%hsno(1, k, 1)    = hsno(1,k,1)
  enddo
  ibis_struc(n)%ibis(t)%iwet(1, 1)       = iwet(1, 1)
  do k=1,31
  ibis_struc(n)%ibis(t)%iwetday  (1,k,1) = iwetday  (1, k, 1)
  ibis_struc(n)%ibis(t)%precipday(1,k,1) = precipday(1, k, 1)
  enddo
  do k=1,nband
  ibis_struc(n)%ibis(t)%asurd(1, k, 1)   = asurd   (1, k  ,1)
  ibis_struc(n)%ibis(t)%asuri(1, k, 1)   = asuri   (1, k  ,1)
  enddo
  do k=1,3
  ibis_struc(n)%ibis(t)%xstore(1, k, 1)  = xstore  (1, k, 1)
  enddo
  ibis_struc(n)%ibis(t)%ginvap (1, 1) = ginvap  (1, 1) 
  ibis_struc(n)%ibis(t)%gsuvap (1, 1) = gsuvap  (1, 1) 
  ibis_struc(n)%ibis(t)%gtrans (1, 1) = gtrans  (1, 1) 
  ibis_struc(n)%ibis(t)%gtransu(1, 1) = gtransu (1, 1) 
  ibis_struc(n)%ibis(t)%gtransl(1, 1) = gtransl (1, 1) 
  ibis_struc(n)%ibis(t)%grunof (1, 1) = grunof  (1, 1) 
  ibis_struc(n)%ibis(t)%gdrain (1, 1) = gdrain  (1, 1) 
  ibis_struc(n)%ibis(t)%gadjust(1, 1) = gadjust (1, 1) 
  ibis_struc(n)%ibis(t)%wtot   (1, 1) = wtot    (1, 1)
  ibis_struc(n)%ibis(t)%adfalll(1, 1) = adfalll (1, 1)
  ibis_struc(n)%ibis(t)%adfallr(1, 1) = adfallr (1, 1)
  ibis_struc(n)%ibis(t)%adfallw(1, 1) = adfallw (1, 1)
  do k=1,npft
  ibis_struc(n)%ibis(t)%adnpp(1,k, 1) = adnpp(1, k, 1)
  enddo


  ibis_struc(n)%ibis(t)%a10td	     (1, 1) = a10td	 (1, 1)
  ibis_struc(n)%ibis(t)%a10ancub     (1, 1) = a10ancub	 (1, 1)
  ibis_struc(n)%ibis(t)%a10ancuc     (1, 1) = a10ancuc	 (1, 1)
  ibis_struc(n)%ibis(t)%a10ancls     (1, 1) = a10ancls	 (1, 1)
  ibis_struc(n)%ibis(t)%a10ancl4     (1, 1) = a10ancl4	 (1, 1)
  ibis_struc(n)%ibis(t)%a10ancl3     (1, 1) = a10ancl3	 (1, 1)
  ibis_struc(n)%ibis(t)%a10scalparamu(1, 1) = a10scalparamu(1, 1)
  ibis_struc(n)%ibis(t)%a10scalparaml(1, 1) = a10scalparaml(1, 1)
  ibis_struc(n)%ibis(t)%a10daylightu (1, 1) = a10daylightu (1, 1)
  ibis_struc(n)%ibis(t)%a10daylightl (1, 1) = a10daylightl (1, 1)
  ibis_struc(n)%ibis(t)%adrain       (1, 1) = adrain	 (1, 1)
  ibis_struc(n)%ibis(t)%adsnow       (1, 1) = adsnow	 (1, 1)
  ibis_struc(n)%ibis(t)%adaet	     (1, 1) = adaet	 (1, 1)
  ibis_struc(n)%ibis(t)%adtrunoff    (1, 1) = adtrunoff	 (1, 1)
  ibis_struc(n)%ibis(t)%adsrunoff    (1, 1) = adsrunoff	 (1, 1)
  ibis_struc(n)%ibis(t)%addrainage   (1, 1) = addrainage   (1, 1)
  ibis_struc(n)%ibis(t)%adrh	     (1, 1) = adrh	 (1, 1)
  ibis_struc(n)%ibis(t)%adsnod       (1, 1) = adsnod	 (1, 1)
  ibis_struc(n)%ibis(t)%adsnof       (1, 1) = adsnof	 (1, 1)
  ibis_struc(n)%ibis(t)%adwsoi       (1, 1) = adwsoi	 (1, 1)
  ibis_struc(n)%ibis(t)%adtsoi       (1, 1) = adtsoi	 (1, 1)
  ibis_struc(n)%ibis(t)%adwisoi      (1, 1) = adwisoi	 (1, 1)
  ibis_struc(n)%ibis(t)%adtlaysoi    (1, 1) = adtlaysoi	 (1, 1)
  ibis_struc(n)%ibis(t)%adwlaysoi    (1, 1) = adwlaysoi	 (1, 1)
  ibis_struc(n)%ibis(t)%adwsoic      (1, 1) = adwsoic	 (1, 1)
  ibis_struc(n)%ibis(t)%adtsoic      (1, 1) = adtsoic	 (1, 1)
  ibis_struc(n)%ibis(t)%adco2mic     (1, 1) = adco2mic	 (1, 1)
  ibis_struc(n)%ibis(t)%adco2root    (1, 1) = adco2root	 (1, 1)
  ibis_struc(n)%ibis(t)%adco2soi     (1, 1) = adco2soi	 (1, 1)
  ibis_struc(n)%ibis(t)%adco2ratio   (1, 1) = adco2ratio   (1, 1)
  ibis_struc(n)%ibis(t)%adnmintot    (1, 1) = adnmintot	 (1, 1)


  ibis_struc(n)%ibis(t)%amtemp     (1, 1) = amtemp    (1, 1)
  ibis_struc(n)%ibis(t)%amrain     (1, 1) = amrain    (1, 1)
  ibis_struc(n)%ibis(t)%amsnow     (1, 1) = amsnow    (1, 1)
  ibis_struc(n)%ibis(t)%amaet	   (1, 1) = amaet     (1, 1)
  ibis_struc(n)%ibis(t)%amtrunoff  (1, 1) = amtrunoff (1, 1)
  ibis_struc(n)%ibis(t)%amsrunoff  (1, 1) = amsrunoff (1, 1)
  ibis_struc(n)%ibis(t)%amdrainage (1, 1) = amdrainage(1, 1)
  ibis_struc(n)%ibis(t)%amqa	   (1, 1) = amqa      (1, 1)
  ibis_struc(n)%ibis(t)%amsolar    (1, 1) = amsolar   (1, 1)
  ibis_struc(n)%ibis(t)%amirup     (1, 1) = amirup    (1, 1)
  ibis_struc(n)%ibis(t)%amirdown   (1, 1) = amirdown  (1, 1)
  ibis_struc(n)%ibis(t)%amsens     (1, 1) = amsens    (1, 1)
  ibis_struc(n)%ibis(t)%amlatent   (1, 1) = amlatent  (1, 1)
  ibis_struc(n)%ibis(t)%amlaiu     (1, 1) = amlaiu    (1, 1)
  ibis_struc(n)%ibis(t)%amlail     (1, 1) = amlail    (1, 1)
  ibis_struc(n)%ibis(t)%amtsoi     (1, 1) = amtsoi    (1, 1)
  ibis_struc(n)%ibis(t)%amwsoi     (1, 1) = amwsoi    (1, 1)
  ibis_struc(n)%ibis(t)%amwisoi    (1, 1) = amwisoi   (1, 1)
  ibis_struc(n)%ibis(t)%amvwc	   (1, 1) = amvwc     (1, 1)
  ibis_struc(n)%ibis(t)%amawc	   (1, 1) = amawc     (1, 1)
  ibis_struc(n)%ibis(t)%amsnod     (1, 1) = amsnod    (1, 1)
  ibis_struc(n)%ibis(t)%amsnof     (1, 1) = amsnof    (1, 1)
  ibis_struc(n)%ibis(t)%amco2mic   (1, 1) = amco2mic  (1, 1)
  ibis_struc(n)%ibis(t)%amco2root  (1, 1) = amco2root (1, 1)
  ibis_struc(n)%ibis(t)%amnmintot  (1, 1) = amnmintot (1, 1) 
  do k=1,npft
  ibis_struc(n)%ibis(t)%tauwood(1, k, 1) = tauwood(1, k, 1)    ! wood biomass turnover(rotatividade) time constant (years)
  ibis_struc(n)%ibis(t)%amnpp  (1, k, 1) = amnpp  (1, k, 1)
  enddo 
  ibis_struc(n)%ibis(t)%amts2	  (1, 1) = amts2     (1, 1) 
  ibis_struc(n)%ibis(t)%amtransu  (1, 1) = amtransu  (1, 1) 
  ibis_struc(n)%ibis(t)%amtransl  (1, 1) = amtransl  (1, 1) 
  ibis_struc(n)%ibis(t)%amsuvap   (1, 1) = amsuvap   (1, 1) 
  ibis_struc(n)%ibis(t)%aminvap   (1, 1) = aminvap   (1, 1) 
  ibis_struc(n)%ibis(t)%amneetot  (1, 1) = amneetot  (1, 1) 
  ibis_struc(n)%ibis(t)%amco2ratio(1, 1) = amco2ratio(1, 1) 
  ibis_struc(n)%ibis(t)%amnpptot  (1, 1) = amnpptot  (1, 1) 
  ibis_struc(n)%ibis(t)%amco2soi  (1, 1) = amco2soi  (1, 1) 
  ibis_struc(n)%ibis(t)%amalbedo  (1, 1) = amalbedo  (1, 1)
  do k=1,nsoilay
  ibis_struc(n)%ibis(t)%amtsoil (1,k, 1) = amtsoil   (1, k, 1)
  ibis_struc(n)%ibis(t)%amwsoil (1,k, 1) = amwsoil   (1, k, 1)
  ibis_struc(n)%ibis(t)%amwisoil(1,k, 1) = amwisoil  (1, k, 1)
  enddo
  ibis_struc(n)%ibis(t)%aysolar   (1, 1) = aysolar   (1, 1) 
  ibis_struc(n)%ibis(t)%ayirup    (1, 1) = ayirup    (1, 1) 
  ibis_struc(n)%ibis(t)%ayirdown  (1, 1) = ayirdown  (1, 1) 
  ibis_struc(n)%ibis(t)%aysens    (1, 1) = aysens    (1, 1) 
  ibis_struc(n)%ibis(t)%aylatent  (1, 1) = aylatent  (1, 1) 
  ibis_struc(n)%ibis(t)%ayprcp    (1, 1) = ayprcp    (1, 1) 
  ibis_struc(n)%ibis(t)%ayaet	  (1, 1) = ayaet     (1, 1) 
  ibis_struc(n)%ibis(t)%aytrans   (1, 1) = aytrans   (1, 1) 
  ibis_struc(n)%ibis(t)%aytrunoff (1, 1) = aytrunoff (1, 1) 
  ibis_struc(n)%ibis(t)%aysrunoff (1, 1) = aysrunoff (1, 1) 
  ibis_struc(n)%ibis(t)%aydrainage(1, 1) = aydrainage(1, 1) 
  ibis_struc(n)%ibis(t)%aydwtot   (1, 1) = aydwtot   (1, 1)   
  ibis_struc(n)%ibis(t)%aydrainage(1, 1) = aygpptot  (1, 1)     
  do k=1,npft  
  ibis_struc(n)%ibis(t)%aynpp  (1, k, 1) = aynpp  (1, k, 1) 
  enddo


  ibis_struc(n)%ibis(t)%aydrainage(1, 1) = aynpptot  (1 ,1)	 
  ibis_struc(n)%ibis(t)%aydrainage(1, 1) = ayco2soi  (1 ,1)	 
  ibis_struc(n)%ibis(t)%aydrainage(1, 1) = ayneetot  (1 ,1)	 
  ibis_struc(n)%ibis(t)%totnsoi   (1, 1) = totnsoi   (1 ,1)     
  ibis_struc(n)%ibis(t)%aywsoi    (1, 1) = aywsoi    (1 ,1) 
  ibis_struc(n)%ibis(t)%aywisoi   (1, 1) = aywisoi   (1 ,1) 
  ibis_struc(n)%ibis(t)%aytsoi    (1, 1) = aytsoi    (1 ,1) 
  ibis_struc(n)%ibis(t)%ayvwc	  (1, 1) = ayvwc     (1 ,1) 
  ibis_struc(n)%ibis(t)%ayawc	  (1, 1) = ayawc     (1 ,1) 
  ibis_struc(n)%ibis(t)%aystresstu(1, 1) = aystresstu(1 ,1) 
  ibis_struc(n)%ibis(t)%aystresstl(1, 1) = aystresstl(1 ,1) 
  ibis_struc(n)%ibis(t)%ayco2mic  (1, 1) = ayco2mic  (1 ,1) 
  ibis_struc(n)%ibis(t)%ayco2root (1, 1) = ayco2root (1 ,1) 
  ibis_struc(n)%ibis(t)%ayrootbio (1, 1) = ayrootbio (1 ,1) 
  ibis_struc(n)%ibis(t)%aynmintot (1, 1) = aynmintot (1 ,1) 
  ibis_struc(n)%ibis(t)%ayalit    (1, 1) = ayalit    (1 ,1) 
  ibis_struc(n)%ibis(t)%ayblit    (1, 1) = ayblit    (1 ,1) 
  ibis_struc(n)%ibis(t)%aycsoi    (1, 1) = aycsoi    (1 ,1) 
  ibis_struc(n)%ibis(t)%aycmic    (1, 1) = aycmic    (1 ,1) 
  ibis_struc(n)%ibis(t)%ayanlit   (1, 1) = ayanlit   (1 ,1) 
  ibis_struc(n)%ibis(t)%aybnlit   (1, 1) = aybnlit   (1 ,1) 
  ibis_struc(n)%ibis(t)%aynsoi    (1, 1) = aynsoi    (1 ,1) 
  ibis_struc(n)%ibis(t)%ayalbedo  (1, 1) = ayalbedo  (1 ,1)
  do k=1,npft
  ibis_struc(n)%ibis(t)%aygpp  (1, k, 1) = aygpp  (1, k, 1)
  ibis_struc(n)%ibis(t)%ayanpp (1, k, 1) = ayanpp (1, k, 1) 
  enddo
  ibis_struc(n)%ibis(t)%ayanpptot (1, 1) = ayanpptot (1 ,1) 
  ibis_struc(n)%ibis(t)%ayrratio  (1, 1) = ayrratio  (1 ,1) 
  ibis_struc(n)%ibis(t)%aytratio  (1, 1) = aytratio  (1 ,1) 
  ibis_struc(n)%ibis(t)%totcondub (1, 1) = totcondub (1 ,1) 
  ibis_struc(n)%ibis(t)%totconduc (1, 1) = totconduc (1 ,1) 
  ibis_struc(n)%ibis(t)%totcondls (1, 1) = totcondls (1 ,1) 
  ibis_struc(n)%ibis(t)%totcondl3 (1, 1) = totcondl3 (1 ,1) 
  ibis_struc(n)%ibis(t)%totcondl4 (1, 1) = totcondl4 (1 ,1)
  do k=1,npft
  ibis_struc(n)%ibis(t)%frac (1, k, 1) = frac (1, k, 1)
  enddo
  ibis_struc(n)%ibis(t)%tum	(1, 1) = tum     (1, 1)
  ibis_struc(n)%ibis(t)%tu	(1, 1) = tu      (1, 1)
  ibis_struc(n)%ibis(t)%tu0	(1, 1) = tu0     (1, 1)
  ibis_struc(n)%ibis(t)%ts	(1, 1) = ts      (1, 1)
  ibis_struc(n)%ibis(t)%tl	(1, 1) = tl      (1, 1)
  ibis_struc(n)%ibis(t)%topparu (1, 1) = topparu (1, 1)
  ibis_struc(n)%ibis(t)%topparl (1, 1) = topparl (1, 1)
  ibis_struc(n)%ibis(t)%agcub	(1, 1) = agcub   (1, 1)
  ibis_struc(n)%ibis(t)%agcuc	(1, 1) = agcuc   (1, 1)
  ibis_struc(n)%ibis(t)%ancub	(1, 1) = ancub   (1, 1)
  ibis_struc(n)%ibis(t)%ancuc	(1, 1) = ancuc   (1, 1)
  ibis_struc(n)%ibis(t)%tlsub	(1, 1) = tlsub   (1, 1)
  ibis_struc(n)%ibis(t)%t12	(1, 1) = t12     (1, 1)
  ibis_struc(n)%ibis(t)%t34	(1, 1) = t34     (1, 1)
  ibis_struc(n)%ibis(t)%q12	(1, 1) = q12     (1, 1)
  ibis_struc(n)%ibis(t)%q34	(1, 1) = q34     (1, 1)
  ibis_struc(n)%ibis(t)%ciub	(1, 1) = ciub    (1, 1)
  ibis_struc(n)%ibis(t)%ciuc	(1, 1) = ciuc    (1, 1)
  ibis_struc(n)%ibis(t)%cils	(1, 1) = cils    (1, 1)
  ibis_struc(n)%ibis(t)%cil3	(1, 1) = cil3    (1, 1)
  ibis_struc(n)%ibis(t)%cil4	(1, 1) = cil4    (1, 1)
  ibis_struc(n)%ibis(t)%csub	(1, 1) = csub    (1, 1)
  ibis_struc(n)%ibis(t)%csuc	(1, 1) = csuc    (1, 1)
  ibis_struc(n)%ibis(t)%csls	(1, 1) = csls    (1, 1)
  ibis_struc(n)%ibis(t)%csl3	(1, 1) = csl3    (1, 1)
  ibis_struc(n)%ibis(t)%csl4	(1, 1) = csl4    (1, 1)
  ibis_struc(n)%ibis(t)%gsub	(1, 1) = gsub    (1, 1)
  ibis_struc(n)%ibis(t)%gsuc	(1, 1) = gsuc    (1, 1)
  ibis_struc(n)%ibis(t)%gsls	(1, 1) = gsls    (1, 1)
  ibis_struc(n)%ibis(t)%gsl3	(1, 1) = gsl3    (1, 1)
  ibis_struc(n)%ibis(t)%gsl4	(1, 1) = gsl4    (1, 1)
  ibis_struc(n)%ibis(t)%agcls	(1, 1) = agcls   (1, 1)
  ibis_struc(n)%ibis(t)%agcl4	(1, 1) = agcl4   (1, 1)
  ibis_struc(n)%ibis(t)%agcl3	(1, 1) = agcl3   (1, 1)
  ibis_struc(n)%ibis(t)%ancls	(1, 1) = ancls   (1, 1)
  ibis_struc(n)%ibis(t)%ancl4	(1, 1) = ancl4   (1, 1)
  ibis_struc(n)%ibis(t)%ancl3	(1, 1) = ancl3   (1, 1)
  ibis_struc(n)%ibis(t)%clitlm  (1, 1) = clitlm  (1, 1)
  ibis_struc(n)%ibis(t)%clitls  (1, 1) = clitls  (1, 1)
  ibis_struc(n)%ibis(t)%clitll  (1, 1) = clitll  (1, 1)
  ibis_struc(n)%ibis(t)%clitrm  (1, 1) = clitrm  (1, 1)
  ibis_struc(n)%ibis(t)%clitrs  (1, 1) = clitrs  (1, 1)
  ibis_struc(n)%ibis(t)%clitrl  (1, 1) = clitrl  (1, 1)
  ibis_struc(n)%ibis(t)%clitwm  (1, 1) = clitwm  (1, 1)
  ibis_struc(n)%ibis(t)%clitws  (1, 1) = clitws  (1, 1)
  ibis_struc(n)%ibis(t)%clitwl  (1, 1) = clitwl  (1, 1)
  ibis_struc(n)%ibis(t)%totcmic (1, 1) = totcmic (1, 1)
  ibis_struc(n)%ibis(t)%csoislop(1, 1) = csoislop(1, 1)
  ibis_struc(n)%ibis(t)%csoislon(1, 1) = csoislon(1, 1)
  ibis_struc(n)%ibis(t)%csoipas (1, 1) = csoipas (1, 1)
  ibis_struc(n)%ibis(t)%totlit  (1, 1) = totlit  (1, 1)
  ibis_struc(n)%ibis(t)%totnlit (1, 1) = totnlit (1, 1)
  ibis_struc(n)%ibis(t)%totfall (1, 1) = totfall (1, 1)
  ibis_struc(n)%ibis(t)%totalit (1, 1) = totalit (1, 1)
  ibis_struc(n)%ibis(t)%totrlit (1, 1) = totrlit (1, 1)
  ibis_struc(n)%ibis(t)%totanlit(1, 1) = totanlit(1, 1)
  ibis_struc(n)%ibis(t)%totrnlit(1, 1) = totrnlit(1, 1)
  ibis_struc(n)%ibis(t)%totcsoi (1, 1) = totcsoi (1, 1)
  ibis_struc(n)%ibis(t)%totnmic (1, 1) = totnmic (1, 1)
  ibis_struc(n)%ibis(t)%tco2mic (1, 1) = tco2mic (1, 1)
  ibis_struc(n)%ibis(t)%tnpptot (1, 1) = tnpptot (1, 1)
  ibis_struc(n)%ibis(t)%tneetot (1, 1) = tneetot (1, 1)
  ibis_struc(n)%ibis(t)%tnmin	(1, 1) = tnmin   (1, 1)
  ibis_struc(n)%ibis(t)%cdisturb(1, 1) = cdisturb(1, 1)
  ibis_struc(n)%ibis(t)%tempu	(1, 1) = tempu   (1, 1)
  ibis_struc(n)%ibis(t)%templ	(1, 1) = templ   (1, 1)
  ibis_struc(n)%ibis(t)%dropu	(1, 1) = dropu   (1, 1)
  ibis_struc(n)%ibis(t)%dropls  (1, 1) = dropls  (1, 1)
  ibis_struc(n)%ibis(t)%dropl4  (1, 1) = dropl4  (1, 1)
  ibis_struc(n)%ibis(t)%dropl3  (1, 1) = dropl3  (1, 1)
  ibis_struc(n)%ibis(t)%wliqu	(1, 1) = wliqu   (1, 1)
  ibis_struc(n)%ibis(t)%wliqs	(1, 1) = wliqs   (1, 1)
  ibis_struc(n)%ibis(t)%wliql	(1, 1) = wliql   (1, 1)
  ibis_struc(n)%ibis(t)%wsnou	(1, 1) = wsnou   (1, 1)
  ibis_struc(n)%ibis(t)%wsnos	(1, 1) = wsnos   (1, 1)
  ibis_struc(n)%ibis(t)%wsnol	(1, 1) = wsnol   (1, 1)
  ibis_struc(n)%ibis(t)%su	(1, 1) = su      (1, 1)
  ibis_struc(n)%ibis(t)%ss	(1, 1) = ss      (1, 1)  
  ibis_struc(n)%ibis(t)%sl	(1, 1) = sl      (1, 1)
  ibis_struc(n)%ibis(t)%agddu	(1, 1) = agddu   (1, 1)	 
  ibis_struc(n)%ibis(t)%agddl	(1, 1) = agddl   (1, 1)
  ibis_struc(n)%ibis(t)%storedn (1, 1) = storedn (1, 1)
  ibis_struc(n)%ibis(t)%yrleach (1, 1) = yrleach (1, 1)
  ibis_struc(n)%ibis(t)%ynleach (1, 1) = ynleach (1, 1)
  ibis_struc(n)%ibis(t)%falll	(1, 1) = falll   (1, 1)	
  ibis_struc(n)%ibis(t)%fallr	(1, 1) = fallr   (1, 1)	
  ibis_struc(n)%ibis(t)%fallw	(1, 1) = fallw   (1, 1)	
  ibis_struc(n)%ibis(t)%vegtype0(1, 1) = vegtype0(1, 1) 


  do k=1,npft
  ibis_struc(n)%ibis(t)%plai  (1, k, 1)  = plai   (1 ,k, 1)  
  ibis_struc(n)%ibis(t)%adplai(1, k, 1)  = adplai (1 ,k, 1)
  enddo
  ibis_struc(n)%ibis(t)%sapfrac (1, 1)   = sapfrac (1, 1) 
  do k=1,npft
  ibis_struc(n)%ibis(t)%cbiol  (1, k, 1) = cbiol  (1, k, 1)  
  ibis_struc(n)%ibis(t)%adcbiol(1, k, 1) = adcbiol(1, k, 1) 
  ibis_struc(n)%ibis(t)%cbior  (1, k, 1) = cbior  (1, k, 1)  
  ibis_struc(n)%ibis(t)%adcbior(1, k, 1) = adcbior(1, k, 1) 
  ibis_struc(n)%ibis(t)%cbiow  (1, k, 1) = cbiow  (1, k, 1)  
  ibis_struc(n)%ibis(t)%adcbiow(1, k, 1) = adcbiow(1, k, 1)  
  ibis_struc(n)%ibis(t)%biomass(1, k, 1) = biomass(1, k, 1)
  enddo
  ibis_struc(n)%ibis(t)%totlaiu (1, 1)   = totlaiu(1, 1)	
  ibis_struc(n)%ibis(t)%totlail (1, 1)   = totlail(1, 1)	
  ibis_struc(n)%ibis(t)%totbiou (1, 1)   = totbiou(1, 1)   
  ibis_struc(n)%ibis(t)%totbiol (1, 1)   = totbiol(1, 1)   
  do k=1,2
  ibis_struc(n)%ibis(t)%sai_ib (1, k, 1) = sai  (1 ,k ,1) 
  enddo
  ibis_struc(n)%ibis(t)%fu     (1, 1)    = fu     (1, 1)  
  ibis_struc(n)%ibis(t)%fl     (1, 1)    = fl     (1, 1)  
  do k=1,2
  ibis_struc(n)%ibis(t)%lai_ib (1, k, 1) = lai    (1 ,k  ,1) 	 
  ibis_struc(n)%ibis(t)%zbot(1, k, 1)    = zbot   (1 ,k  ,1) 	 
  ibis_struc(n)%ibis(t)%ztop(1, k, 1)    = ztop   (1 ,k  ,1)
  enddo		 
  ibis_struc(n)%ibis(t)%decompl (1, 1)   = decompl(1, 1) 
  ibis_struc(n)%ibis(t)%decomps (1, 1)   = decomps(1, 1) 
  ibis_struc(n)%ibis(t)%firefac (1, 1)   = firefac(1, 1) 
  do k=1,nsoilay
  do j=1,2
  ibis_struc(n)%ibis(t)%froot(1,k, j, 1) = froot    (1,k,j,1) 
  enddo
  enddo
  do k=1,nsoilay+1
  ibis_struc(n)%ibis(t)%hsoi(1, k, 1)    = hsoi(1,k,1)  
  enddo
  ibis_struc(n)%ibis(t)%vzero (1, 1)     = vzero(1, 1)
  ibis_struc(n)%ibis(t)%td    (1, 1)     = td   (1, 1)

  ibis_struc(n)%ibis(t)%ynleach_p (1, 1) =  ynleach_p (1 ,1)  ! annual total amount P leached from soil profile (kg_N m-2/yr)
  ibis_struc(n)%ibis(t)%tnmin_p   (1, 1) =  tnmin_p   (1 ,1)  ! instantaneous phosphorus mineralization (kg_N m-2/timestep)
  ibis_struc(n)%ibis(t)%totnmic_p (1, 1) =  totnmic_p (1 ,1)  ! total phosphorus residing in microbial pool	(kg_N m-2)
  ibis_struc(n)%ibis(t)%totnlit_p (1, 1) =  totnlit_p (1 ,1)  ! total phosphorus in all litter pools	   (kg_N m-2)
  ibis_struc(n)%ibis(t)%totanlit_p(1, 1) =  totanlit_p(1 ,1)  ! total standing aboveground phosphorus in litter (kg_N m-2)
  ibis_struc(n)%ibis(t)%totrnlit_p(1, 1) =  totrnlit_p(1 ,1)  ! total root litter phosphorus belowground	    (kg_N m-2)
  ibis_struc(n)%ibis(t)%totnsoi_p (1, 1) =  totnsoi_p (1 ,1)  ! total phosphorus in soil			    (kg_N m-2)
  ibis_struc(n)%ibis(t)%storedn_p (1, 1) =  storedn_p (1 ,1)  ! total storage of P in soil profile (kg_N m-2) 
  do k=1,nsoilay
  ibis_struc(n)%ibis(t)%depth(k)         =  depth(k)
  enddo
  
endif ! end key

  RETURN
END SUBROUTINE transferin    


end subroutine ibis_main
