    SUBROUTINE WRTRST
!$$$  PROGRAM DOCUMENTATION BLOCK
!                .      .    .
!    PROGRAM:    WRTRST      WRITE OUT A 2-D RESTRT FILE
!   PRGRMMR: BLACK           ORG: W/NP22     DATE: 96-06-24

! ABSTRACT:  WRTRST SIMPLY TAKES AN EXISTING INITIAL RESTRT 2-D
!            RESTRT FILE AND WRITES IT OUT.  IT IS VERY
!            IMPORTANT TO REMEMBER THAT THIS IS FOR AN INITIAL
!            RESTRT FILE ONLY SINCE SOME OF THE WRITES ARE
!            DUMMIES THAT ARE NOT NEEDED BY INIT BUT THAT
!            WOULD BE NEEDED BY THE POST_PROCESSOR

! PROGRAM HISTORY LOG:
!   96-06-24  BLACK   - ORIGINATOR

! USAGE:    RUN WRTRST AFTER ANY ROUTINES THAT HAVE MODIFIED
!           A 2-D RESTRT FILE

!   INPUT ARGUMENT LIST:
!     NONE

!   OUTPUT ARGUMENT LIST:
!     NONE

!   INPUT FILES:
!     NONE

!   OUTPUT FILES:
!     RESOUT - THE RESTRT FILE IN 2-D FORM

!   SUBPROGRAMS CALLED:
!     UTILITIES:
!       NONE
!     LIBRARY:
!       COMMON   - CTLBLK
!                  LOOPS
!                  MASKS
!                  DYNAM
!                  PHYS2
!                  MAPOT1
!                  SCRCH
!                  VRBLS
!                  PVRBLS
!                  BOCO
!                  GRIDS
!                  ACMCLH
!                  ACMCLD
!                  ACMPRE
!                  ACMRDL
!                  ACMRDS
!                  ACMSFC
!                  CLDWTR
!                  CNVCLD
!                  SOIL

!   ATTRIBUTES:
!     LANGUAGE: FORTRAN 90
!     MACHINE : IBM SP
!$$$

!-----------------------------------------------------------------------
!     INCLUDE/SET PARAMETERS.
!-----------------------------------------------------------------------
    INCLUDE "parmeta.f90"
    INCLUDE "parm.tbl.f90"
!-----------------------------------------------------------------------
    PARAMETER &
    (IMJM=IM*JM-JM/2,JMP1=JM+1,JAM=6+2*(JM-10),IMJMX=IM*JM &
    , LM1=LM-1,LP1=LM+1,LB=2*IM+JM-3)

    PARAMETER &
    (NSOIL=2)
!-----------------------------------------------------------------------

!                            DECLARE VARIABLES

!-----------------------------------------------------------------------
    LOGICAL :: &
    RUN,RUNB,FIRST,RESTRT,SIGMA
!-----------------------------------------------------------------------
    INTEGER :: &
    IDATB(3)
!-----------------------------------------------------------------------
    CHARACTER(32) :: &
    LABEL1,LABEL2,LABEL3,LABEL4
!-----------------------------------------------------------------------
    REAL :: &
    RDUM(IM,JM)
    INTEGER :: &
    IDUM(IM,JM)
!-----------------------------------------------------------------------

!     INCLUDE COMMON BLOCKS.

    INCLUDE "COMM_CTLBLK.f90"
    INCLUDE "COMM_LOOPS.f90"
    INCLUDE "COMM_MASKS.f90"
    INCLUDE "COMM_DYNAM.f90"
    INCLUDE "COMM_PHYS2.f90"
    INCLUDE "COMM_MAPOT1.f90"
    INCLUDE "COMM_VRBLS.f90"
    INCLUDE "COMM_CONTIN.f90"
    INCLUDE "COMM_PVRBLS.f90"
    INCLUDE "COMM_BOCO.f90"
    INCLUDE "COMM_ACMCLH.f90"
    INCLUDE "COMM_ACMCLD.f90"
    INCLUDE "COMM_ACMPRE.f90"
    INCLUDE "COMM_ACMRDL.f90"
    INCLUDE "COMM_ACMRDS.f90"
    INCLUDE "COMM_ACMSFC.f90"
    INCLUDE "COMM_CLDWTR.f90"
    INCLUDE "COMM_CNVCLD.f90"
    INCLUDE "COMM_SOLAR.f90"
    INCLUDE "COMM_SOIL.f90"
!----------------------------------------------------------------------
    DATA &
    IDUM/IMJMX*0/,RDUM/IMJMX*0./,DUMMY1/0./,DUMMY2/0./,NRSOUT/80/
!***********************************************************************
!***
!***  WRITE OUT 2-D RESTRT FILE
!***
    LABEL1='OMEGA-ALPHA*DT/CP'
    WRITE(NRSOUT) RUN,IDAT,IHRST,NTSD,LABEL1
    WRITE(NRSOUT) PD,((RES(I,J),I=1,IM),J=1,JM)
    DO L = 1,LM
        WRITE(NRSOUT)((OMGALF(I,J,L),I=1,IM),J=1,JM)
    ENDDO

    LABEL2='BND,VRBLS,Q2,CWM,TRAIN,TCUCN'
    WRITE(NRSOUT) RUN,IDAT,IHRST,NTSD,LABEL2, &
    FIRST,IOUT,NSHDE
    WRITE(NRSOUT) PD,((RES(I,J),I=1,IM),J=1,JM),FIS,DUMMY1,DUMMY2
    WRITE(NRSOUT) PDB,TB,QB,UB,VB

    DO L = 1,LM
        WRITE(NRSOUT)((T(I,J,L),I=1,IM),J=1,JM)
        WRITE(NRSOUT)((Q(I,J,L),I=1,IM),J=1,JM)
        WRITE(NRSOUT)((U(I,J,L),I=1,IM),J=1,JM)
        WRITE(NRSOUT)((V(I,J,L),I=1,IM),J=1,JM)
        WRITE(NRSOUT)((Q2(I,J,L),I=1,IM),J=1,JM)
    
    !     DUMMY WRITE OF THE TOTAL RADIATIVE TEMPERATURE TENDENCIES
    !     WHICH ARE NOT USED EXPLICITLY IN THE INTEGRATION
    
        WRITE(NRSOUT) RDUM
    
        WRITE(NRSOUT)((CWM(I,J,L),I=1,IM),J=1,JM)
        WRITE(NRSOUT)((TRAIN(I,J,L),I=1,IM),J=1,JM)
        WRITE(NRSOUT)((TCUCN(I,J,L),I=1,IM),J=1,JM)
    ENDDO

    LABEL3='MISC VARIABLES'
    WRITE(NRSOUT) RUN,IDAT,IHRST,NTSD,LABEL3, &
    RSWIN,RSWOUT,TG,Z0,((AKMS(I,J),I=1,IM),J=1,JM),CZEN
    WRITE(NRSOUT) AKHS,THS,QS,TWBS,QWBS,HBOT,CFRACL
    WRITE(NRSOUT) THZ0,QZ0 &
    ,            ((UZ0(I,J),I=1,IM),J=1,JM) &
    ,            ((VZ0(I,J),I=1,IM),J=1,JM) &
    ,              USTAR,HTOP,CFRACM
    WRITE(NRSOUT) SNO,SI,CLDEFI,RF,RDUM,CUPPT,CFRACH
    WRITE(NRSOUT) SOILTB,SFCEXC,SMSTAV,SMSTOT,GRNFLX,PCTSNO
    WRITE(NRSOUT) RLWIN,RADOT,CZMEAN,SIGT4
    WRITE(NRSOUT) U00,UL,LC,SR

    LABEL4='ACCUMULATED VARIABLES'
    WRITE(NRSOUT) RUN,IDAT,IHRST,NTSD,LABEL4, &
    PREC,ACPREC,ACCLIQ,CUPREC
    WRITE(NRSOUT) ACFRCV,NCFRCV,ACFRST,NCFRST
    WRITE(NRSOUT) ACSNOW,ACSNOM,SSROFF,BGROFF,IDUM
    WRITE(NRSOUT) SFCSHX,SFCLHX,SUBSHX,SNOPCX, &
    SFCUVX,SFCEVP,POTEVP
    WRITE(NRSOUT) ASWIN,ASWOUT,ASWTOA,ALWIN,ALWOUT,ALWTOA
    WRITE(NRSOUT) ARDSW,ARDLW,ASRFC,AVRAIN,AVCNVC
    WRITE(NRSOUT) TH10,Q10,U10,V10,TSHLTR,QSHLTR,RDUM
    WRITE(NRSOUT) SMC
    WRITE(NRSOUT) CMC
    WRITE(NRSOUT) STC
    WRITE(NRSOUT) SH2O
    WRITE(NRSOUT) ALBEDO

    STOP
    END SUBROUTINE WRTRST
