      SUBROUTINE FORMFILE
    
      use winteracter
      USE BLKRM10

      USE RESID
      INTEGER ICROSREF(45)
      CHARACTER*8 LABELF(44),LABELC(26),LABELFL(21),LABELCE,LABELFE,LIMITL(8),LABELNDL
      CHARACTER(LEN=255)  :: filter
      character*137 helpint(98)
      character*162 helptime(43)
      character*89  helpfile(45)
      CHARACTER*1 ILAB(4),ALAB
      CHARACTER*2 BLAB
      
      DATA ILAB/'C','F','G','H'/
      DATA ICROSREF/21,17,18,52,13,22,16,45, 1, 3, 4,14, 2,42,10,25,57,58,44,37&
                   ,38,39,40,15,31,30,19,20,53,54,55,56,11,12, 9,32,33,34,26,27&
                   ,59,36,60,61,62/
!      DATA LABELF/'INBNGEO ','INBNRST ','INRM1   ','INELEV  ','INHYD   ','INELTFL ','OUTFIL  ','OUTBNRMA','OUTBNRST','TIMFIL  ','OUTSMS  ','OUTSPL  ','OUTCON  ','INCROS  ','INSRCORD','INSTRESS','INBNSTRS','INWGT   ','INBNWGT ','OUTWGT  ','OUTBNWGT','OUTBNSTR','WEIRDATA','AWINDIN ','BWINDIN ','OUTFLOW ','INHARM  ','OUTBN3GE'/
      DATA LABELF/&
      'INBNGEO ','INRM1   ','INBNRST ','INCROS  ','INHYD   ','INELEV  ','INELTFL ','INBNELF ','INHARM  ','INLAYDAT','METFIL  '&
     ,'OUTFIL  ','OUTBNRMA','OUTBNRST','OUTBN3GE','OUTCON  ','OUTMET  ','TIMFIL  ','BWINDIN ','AWINDIN ','OUTBNXTR'&
     ,'OUTASXTR','OUTBNELF','INSRCORD','INBNWGT ','INBNSTRS','OUTBNWGT','OUTWGT  ','GROUPNUM','STFLFIL ','INASTRAT'&
     ,'BCFIL   ','VOLFIL  ','OUTBNRES','VELBNFIL','IN3DBNGE','OUTBN2GE','INSMSGN ','OUTSMS  '&
     ,'OUTSMS1 ','OUTFLOW ','INBC    ','INBNBC  ','OUTBNICE'/

      
!      DATA LIMITL/ 'MAXFRONT','BUFFSIZL','MAXSTEPS','MAXPBUFR','MAXCROSS','MAXCPTS ','MAXQINPT','MAXHINPT','MAXEINPT','MAXQPTS ','MAXHPTS ','MAXELPTS','BUFFSIZ '/
      DATA LIMITL/ 'MAXFRONT','BUFFSIZL','MAXLAY  ','MAXCROSS','MAXCPTS ','MAXQINPT','MAXHINPT','MAXEINPT'/

      DATA LABELC/ 'STARTIM ','ENDTIM  ','PRTOPT  ','SSITN   ','TRITN   ','MARSHOPT','TIMPROJ ','ITERINTV','1DTYP   ','MESSRWND','TRSTEPS ','HALF-TIM','HALF-HOL','GRAVITY ','OVERLAYT','WRTINIT ','EDDYTYPE','DRYSW   ','HIGH-ORD','9-NODE  ','RSTOPT  ','STBIN   ','FRQBIN  ','FRQRST  ','NUMRST  ','SOLVER  '/
      DATA LABELFL/'ELEV    ','OMEGA   ','CONV-VEL','CONV-DEP','MARSH-SH','MARSH-RG','MARSH-PR','MARSH-LM','TBFACT  ','TBMIN   ','HALF-TOL','X-SCALE ','Y-SCALE ','V-SCALE ','DSET    ','DSETD   ','UNOM    ','HMIN    ','        ','DPCUTOF1','DPCUTOF2'/
      DATA LABELCE/'ENDGEO  '/,LABELFE/'ENDFIL  '/,LABELNDL/'ENDLIMIT'/
DATA HELPINT/&
  '& Starting date and time                                                                                                                   ',&
  '& Ending date and time                                                                                                                     ',&
  '& Ending year                                                                                                                              ',&
  '& Ending month                                                                                                                             ',&
  '& Ending day                                                                                                                               ',&
  '& Ending hour                                                                                                                              ',&
  '& Vertical turbulence option                                                                                                               ',&
  '& Marsh option 0=inactive -2 = input marsh parameters                                                                                      ',&
  '& Eddy type 0 = fixed, 1= scaled, 2 =  Smagorinsky                                                                                         ',&
  '& Turbulence factor when Smagorinsky is active                                                                                             ',&
  '& Turbulence minimum when Smagorinsky is active                                                                                            ',&
  '& Time projection switch 1= no projection, 0 = use time derivative (least stable), 2 = project using straight line                         ',&
  '& 2-d model approximation                                                                                                                  ',&
  '& 3-d model with a fixed number of layers,  number of layers                                                                               ',&
  '& 3-d model with type LD1 input that is define number of layers for all nodes                                                              ',&
  '& 3-d model with type LD2 input                                                                                                            ',&
  '& 3-d model with type LD3 input                                                                                                            ',&
  '& Units switch   1 = metric    0 = english                                                                                                 ',&
  '& Force zero bed velocity 1 = at all bed levels   2 = limited by bed level input                                                           ',&
  '& Bed level below which zero bed level in applied                                                                                          ',&
  '& Ignore influence of salinity on water density                                                                                            ',&
  '& Ignore influence of temperature on water density                                                                                         ',&
  '& Ignore influence of sediment on water density                                                                                            ',&
  '& Force zero velocity on water surface                                                                                                     ',&
  '& Save binary file for all iterations 0 = ignore,  1 =save                                                                                 ',&
  '& Option for vertical density model   0 = standard  1 = revised method                                                                     ',&
  '& Latitude (degrees) positive in northern hemisphere                                                                                       ',&
  '& Reference level for vertical transformation / Starting water level                                                                       ',&
  '& x scale factor  (0.0 equivalent to 1.0)                                                                                                  ',&
  '& y scale factor  (0.0 equivalent to 1.0)                                                                                                  ',&
  '& z sacle factor  (0.0 equivalent to 1.0)                                                                                                  ',&
  '& Defines constant associated with vertical constituent distribution at boundary                                                           ',&    
  '& Defines power associated with vertical constituent distribution at boundary                                                              ',&
  '& Nominal water velocity at startup                                                                                                        ',&
  '& Nominal current direction in radians c-clockwise from horzontal                                                                          ',&
  '& Minimum depth as startup (ignored if set = 0.0)   Use with care can cause initial instabilty                                             ',&
  '& Depth at which drying (element removal) is initiated when drying                                                                         ',&
  '& Depth at which rewetting (element return) occurs when flooding                                                                           ',&
  '& Switch that forces boundary conditions to be applied regardless of direction                                                             ',&
  '& Number of vertical velocity equations to switch to PARDISO  (Default=20000)                                                              ',&
  '& Initial salinity when no restart file specified                                                                                          ',&
  '& Initial temperature when no restart file specified                                                                                       ',&
  '& Initial sediment concentration when no restart file specified                                                                            ',&
  '& Bed x-velocity used to compute resistance to flow for initial conditions regardless of initial velocity                                  ',&
  '& Bed y-velocity used to compute resistance to flow for initial conditions regardless of initial velocity                                  ',&
  '& Percent of outflowing average concentration returned on next tidal inflow                                                                ',&
  '& Depth of surface mixing (associated with free water surface local turbulence                                                             ',&
  '& Number of steady state iteration cycles to be applied                                                                                    ',&
  '& Number of time transient iteration cycles to be applied per time step                                                                    ',&
  '& Number of transient steps to be simulated                                                                                                ',&
  '& Skip element and node data and initial conditions in echo print                                                                          ',&
  '& Skip element and node data show initial conditions in echoprint                                                                          ',&
  '& Show element and node data in echo print                                                                                                 ',&
  '& Iteration frequency for ASCII output.  Skip if = 0                                                                                       ',&
  '& Time step frequency for ASCII output                                                                                                     ',&
  '& Save startup to binary results file                                                                                                      ',&
  '& Switch to initiate element elimination                                                                                                   ',&
  '& Time step frequency for binary output                                                                                                    ',&
  '& Time step frequency for individual binary restart file                                                                                   ',&
  '& Time step frequency for restarting ASCII results file (saves file size for very large number of steps)                                   ',&
  '& 1-D cross section type  (see users manual for more details)                                                                              ',&
  '& Equation solver type 0=FRONT   > 0  PARDISO SOLVER                                                                                       ',&
  '& Switch to initiate out of local memory (disk) version of PARDISO for very large prblems                                                  ',&
  '& Time step frequency for restarting ASCII message file (saves file size for very large number of steps)                                   ',&
  '& Initial water surface elevation,  Required if different from tra   nsformation reference level                                           ',&
  '& Convergence limit for velocities                                                                                                         ',&
  '& Convergence limit for depth                                                                                                              ',&
  '& Convergence limit for salinity                                                                                                           ',&
  '& Convergence limit for temperature                                                                                                        ',&
  '& Convergence limit for sediment concentration                                                                                             ',&
  '& Transition depth for collapse from 3-D to 2-D approximation                                                                              ',&
  '& Save flows in continuity line output                                                                                                     ',&
  '& Save depths in continuity line output                                                                                                    ',&
  '& Save average water surface elevations in continuity line output                                                                          ',&
  '& Save average salinity in continuity line output                                                                                          ',&
  '& Save average temperature in continuity line output                                                                                       ',&
  '& Save average sediment concentration in continuity line output                                                                            ',&
  '& Horizontal turbulent eddy coefficient                                                                                                    ',&
  '& Vertical turbulent eddy coefficient                                                                                                      ',&
  '& Horizontal turbulent diffusion coefficient                                                                                               ',&
  '& Vertical turbulent diffusion coefficient                                                                                                 ',&
  '& Manning/Chezy bed friction coefficient  >1.0  is Chezy coefficient                                                                       ',&
  '& Bank Manning coefficient  if appropriate                                                                                                 ',&
  '& Water surface Manning coefficient if appropriate                                                                                         ',&
  '& Marsh factor when drying applied to friction coefficient                                                                                 ',&
  '& Eqn for vertical distribution factor for horizontal eddy coefficient  F=a+z*(b+c*z)                                                      ',&
  '& Boundary velocity vertical distribution constant                                                                                         ',&
  '& Boundary velocity vertical distribution power                                                                                            ',&
  '& 2-D to 3-D velocity vertical distribution constant                                                                                       ',&
  '& 2-D to 3-D velocity vertical distribution power                                                                                          ',&
  '& Marsh coefficient depth shift                                                                                                            ',&
  '& Marsh coefficient range                                                                                                                  ',&
  '& Marsh coefficient porosity                                                                                                               ',&
  '& Marsh coefficient limit                                                                                                                  ',&
  '& Indicator of end of tabular data set                                                                                                     ',&
  '& Indicator of end of end control and geometry data                                                                                        ',&
  '& Overlay input time/date onto restart file                                                                                        ',&
  '                                                                                                                                         '/
  DATA HELPTIME/&
  '& Time step in minutes                                                                                                                                           ',&
  '& Time step in hours                                                                                                                                             ',&
  '& Ending time for the time step block                                                                                                                            ',&
  '& Iterate on flow/depth alone                                                                                                                                    ',&
  '& iterate on flow/depth and salinity -2- flow/depth and -1- salinty iterations per cycle                                                                         ',&
  '& iterate on flow/depth and temperature   -2- flow/depth and -1- salinty iterations per cycle                                                                    ',&
  '& iterate on flow/depth and sediment -2- flow/depth and- 1- salinty iterations per cycle                                                                         ',&
  '& iterate on flow/depth salinity and temperature  -2- flow/depth and- 1- salinty -1- temperature iterations per cycle                                            ',&
  '& Continuity line elevation FL-ELEVI is elevation specified as tapered between two end values (subs values from file)- CCLINE, Elev1, Elev2,bc-sal,bc-temp,bc-sed',&
  '& Continuity line elevation CN-ELEVI is elevation specified as tapered between two end values- CCLINE, Elev1, Elev2 ,bc-sal,bc-temp,bc-sed                       ',&
  '& Continuity line elevation FL-ELEVC is elevation specified as constant along a line (subs values from file)- CCLINE, Elevation ,bc-sal,bc-temp,bc-sed           ',&
  '& Continuity line elevation CN-ELEVC is elevation specified as constant along a line - CCLINE, Elevation ,bc-sal,bc-temp,bc-sed                                  ',&
  '& Continuity line inflow CN-QC is standard inflow , CCLINE,  Total Flow, Dir, bc-sal,bc-temp,bc-sed FL-QC means subsequent steps from file                       ',&
  '& Continuity line inflow CN-QF is inflow tapered to zero at end element, flow parallel allowed - CCLINE, Total Flow, dir,bc-sal ,bc-temp,bc-sed -FL means file   ',&
  '& Continuity line inflow CN-QH is specified inflow  distribution - CCLINE,  Total Flow, dir,bc-sal ,bc-temp,bc-sed  -FL means subsequent values from file        ',&
  '& Element Inflow  treated as a rainfall rate (in mm/day) over all surface elementa. flow rate,salinity,temp,sediment -FL means subsequent values from file       ',&  
  '& Element Inflow  treated as a total rate over all given layer of elements. Lay num,flow rate,salinity,temp,sediment -FL means subsequent values from file       ',&  
  '& Element Inflow  treated as a spcific rate over all given layer of elements. Lay num,flow rate,salinity,temp,sediment -FL means subsequent values from file     ',&  
  '& Element Inflow listing element number and total inflow into element.  Elt num, Lay num,flow rate,salinity,temp,sediment -FL means subsequent values from file  ',&  
  '& Element Inflow listing element number and spec flow into element. Elt num, Lay num,flow rate,salinity,temp,sediment -FL means subsequent values from file      ',&  
  '& Element Inflow listing element inflow for a given group and rainfall into element. Grp num,flow rate,salinity,temp,sed -FL means subsequent values from file   ',&  
  '& Element Inflow listing element inflow for a given type and specific flow entering element.                                                                     ',&  
  '& Element Inflow listing element inflow for a given group and specific flow entering element.                                                                    ',&  
  '& Element Inflow listing element number and specific flow entering element. SUBSQT VALUES FROM A FILE)                                                           ',&   
  '& Element Inflow listing element inflow for a given type and specific flow entering element.       SUBSQT VALUES FROM A FILE)                                    ',&  
  '& Element Inflow listing element inflow for a given type treated as a rainfall rate (in mm/day) and rainfall entering element.  (SUBSQT VALUES FROM A FILE)      ',&  
  '& Element Inflow listing element inflow for a given group and specific flow entering element.          (SUBSQT VALUES FROM A FILE)                               ',&  
  '& Element Inflow listing rainfall entering all elements (in mm/day) .     Element number                                                                         ',&  
  '& Continuity line elevation FL-ELVHM is elevation specified as constant along a line (Computes values from harmonic file)- CCLINE, Elevation                     ',&
  '& Element Inflow listing element inflow for a given type treated as a rainfall rate (in mm/day) and rainfall entering element.  )                                ',&  
  '& Element Inflow listing rainfall entering a single elements (in mm/day) .     Element number = 0  apply globally                                                ',&  
  '& Element Inflow listing element inflow treated as a rainfall rate (in mm/day) and rainfall entering all elements.  (SUBSQT VALUES FROM A FILE)                  ',&  
  '& Element Inflow listing element inflow for a given group and rainfall entering element.          (SUBSQT VALUES FROM A FILE)                                    ',&  
  '& Stage-Flow boundary condition.  See line type SQC of user document                                                                                             ',&  
  '& Flag to identify units of wind vel = 0, then values are given in miles/hour  = 1, then values are given in meters/second                                       ',&  
  '& Wind velocity applied at all nodes.                                                                                                                            ',&  
  '& The angle between the wind velocity and the x-axis  for all nodes (degrees measured anti-clockwise).                                                           ',&  
  '& Flow controller identifier, Flow controller type AJ1, BJ1, CJ1, GAM1, QD1, DJ1, TRCCE in flow controller equation for line type FC in the user document        ',&  
  '& Element Inflow  and total flow entering element.   SUBSQT VALUES FROM A FILE)                                                                                  ',&  
  '& Element Inflow  and specific flow entering element.   SUBSQT VALUES FROM A FILE)                                                                               ',&  
  '& Element Inflow  and total flow entering element.                                                                                                               ',&  
  '& Element Inflow  and specific flow entering element.                                                                                                            ',&  
  '&                                                                                                                                                                '/                        

  DATA HELPFILE/&
  '& Input binary file with geometric data',&
  '& Input ASCII file with geometric data',& 
  '& Input binary file with restart data',&
  '& Input ASCII file with cross-section data',&
  '& Input ASCII file with boundary flow data',&
  '& Input ASCII file with elevation boundary data',&
  '& Input ASCII file with element  inflow data',&
  '& Input binary element inflow data',&
  '& Input ASCII file with elevation harmonic boundary data',&
  '& Input ASCII file with layer data',&
  '& Input ASCII file with meteorological data',&
  '& Output ASCII results',&
  '& Output binary file with new format results data',&
  '& Output binary file with restart data',&
  '& Output binary file with 3-D geometry data',&
  '& Output ASCII file with continuity line flow data',&
  '& Output ASCII file with summary meteorological input',&
  '& Output ASCII file with cpu timing data',&
  '& Input binary file with wind data',&
  '& Input ASCII file with wind data',&
  '& Output binary file listing extracted results for specified nodes',&  
  '& Output ASCII file listing extracted results for specified nodes',&  
  '& Output binary element inflow data',&
  '& Input coordinates for surface stresses',&
  '& Input binary weighting file for surface stresses',&
  '& Input binary file for surface stresses',&
  '& Output binary weighting file for surface stresses',&
  '& Output ASCII weighting file for surface stresses',&
  '& Input ASCII file with group number data',&
  '& Input ASCII file with stage flow data for continuity lines',&
  '& Input ASCII temperature stratification data file',&
  '& Input ASCII file with continuation transient step data',&
  '& Output ASCII file with average salinity/total flow',&
  '& Output binary file with old format results data',&
  '& Input binary file with velocity/depth data',&
  '& Input binary file with 3-D geometry data',&
  '& Output binary file with 2-D geometry data',&
  '& Input SMS format geometry file',&
  '& Output SMS RMA-2 format file with horizontal velocity and depth data',&
  '& Output SMS RMA4 format file with salinity, temperate and sediment data',&
  '& Output binary RMA-11 format file listing 1-d flows as a pseudo WQ constituent',&
  '& Input ASCII file containing nodal boundary condition data',&
  '& Input binary file containing nodal boundary condition data',&
  '& Output ice results',&
  '&                                                                                       '/                        
    
      LINE=0
      CALL WMessageBox(YesNo,QuestionIcon,CommonYes, &
                 'Do you wish to save all data lines(YES) or skip default values (NO) ?', 'OUTPUT DEFAULT VALUES?')
      IF(WInfoDialog(4) .eq. 1) then
        ISHOWSW=1
      ELSE
        ISHOWSW=0
      ENDIF

      DO K=1,44
        IF(FNAME(K)(1:16) .NE. '           ') THEN
          LINE=LINE+1
          DO KK=1,43
            IF(FNAME(K)(KK:KK) .NE. ' ') THEN
              DO KKK=1,72-KK
                FNAME(K)(KKK:KKK)=FNAME(K)(KK-1+KKK:KK-1+KKK)
              ENDDO
              EXIT
            ENDIF
          ENDDO                
          WRITE(DATALIN(LINE),6000) LABELF(K),FNAME(K)(1:69),helpfile(k)
6000      FORMAT(A8,3X,A69,a89)             
        ENDIF
      ENDDO    
      
      LINE=LINE+1
      WRITE(DATALIN(LINE),6000) LABELFE

      DO K=1,8
        IF(LIMITVAL(K) .NE. LIMITDFT(K)) THEN
          LINE=LINE+1
          IF(K .EQ. 2) THEN
            WRITE(DATALIN(LINE),'(A8,I16)') LIMITL(K),LIMITVAL(K)
          ELSE
            WRITE(DATALIN(LINE),'(A8,I8)') LIMITL(K),LIMITVAL(K)
          ENDIF
        ENDIF
      ENDDO    

      
      
      LINE=LINE+1
      WRITE(DATALIN(LINE),6000) LABELNDL
      
      LINE=LINE+1
      WRITE(DATALIN(LINE),60001) TITLEHEAD
60001 FORMAT('TI',6X,A72)      

      IF(NLAYTYP .NE. NLAYTYPDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        IF(NLAYTYP .EQ. 0) WRITE(DATALIN(LINE),6011) helpint(13)
6011    FORMAT('2DMODEL ',t70,a96)
        IF(NLAYTYP .EQ. 1) WRITE(DATALIN(LINE),6012) helpint(14)
6012    FORMAT('3DFIXLAY',t70,a96)
        IF(NLAYTYP .EQ. 2) WRITE(DATALIN(LINE),6013) helpint(15)
6013    FORMAT('3DTYPLD1',t70,a96)
        IF(NLAYTYP .EQ. 3) WRITE(DATALIN(LINE),6014) helpint(16)
6014    FORMAT('3DTYPLD2',t70,a96)
        IF(NLAYTYP .EQ. 4) WRITE(DATALIN(LINE),6015) helpint(17)
6015    FORMAT('3DTYPLD3',t70,a96)
      ENDIF  
      IF(ID1DND .NE. ID1DNDDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6056) ID1DND,helpint(61)
6056    FORMAT('1DTYP   ',I8,t70,a96)
      ENDIF  
      IF(ELEV .NE. ELEVDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6026) ELEV,helpint(28)
6026    FORMAT('ELEV    ',F8.3,t70,a96)
      ENDIF  
      LINE=LINE+1
      WRITE(DATALIN(LINE),60002) LABELC(1),DATEST,helpint(1)
60002  FORMAT(A8,3X,A16,t70,a96)
      IF(JT .GT. 1  .OR.  DELT(1) .GT. 0.  .OR. DELTM(1) .GT. 0.  .or.  DELT(2) .GT. 0.  .OR. DELTM(2) .GT. 0.) THEN 
        IF(DATEND .NE. '                ') THEN
          LINE=LINE+1
          WRITE(DATALIN(LINE),60002) LABELC(2),DATEND,helpint(2)
        ENDIF
      ENDIF
      IF(IOV .NE. 0) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),60003) helpint(97)
60003   FORMAT('OVERLAYT',t70,a96)
      ENDIF  
      
      IF(NITI .NE. NITIDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6046) NITI,helpint(48)
6046    FORMAT('SSITN   ',I8,t70,a96)
      ENDIF  
      IF(NITN .NE. NITNDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6047) NITN,helpint(49)
6047    FORMAT('TRITN   ',I8,t70,a96)
      ENDIF  
      IF(NCYC .NE. NCYCDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6048) NCYC,helpint(50)
6048    FORMAT('TRSTEPS ',I8,t70,a96)
      ENDIF  
      IF(IPROJ .NE. IPROJDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6010) IPROJ,helpint(12)
6010    FORMAT('TIMPROJ ',I8,t70,a96)
      ENDIF  
      IF(ICPU .NE. ICPUDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6057) ICPU,helpint(62)
6057    FORMAT('SOLVER  ',I8,t70,a96)
      ENDIF  
      IF(IEQSWT .NE. IEQSWTDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6038) IEQSWT,helpint(40)
6038    FORMAT('VERTEQSW',I8,t70,a96)
      ENDIF  
      IF(IOOC .NE. IOOCDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6058) IOOC,helpint(63)
6058    FORMAT('SLVERDSK',I8,t70,a96)
      ENDIF  
      IF(IOPTZD .NE. IOPTZDDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6005) IOPTZD,helpint(7)
6005    FORMAT('VERTTURB',I8,t70,a96)
      ENDIF  
      IF(IEDSW .NE. IEDSWDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6007) IEDSW,helpint(9)
6007    FORMAT('EDDYTYPE',I8,t70,a96)
      ENDIF  
      IF(TBFACT .NE. TBFACTDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6008) TBFACT,helpint(10)
6008    FORMAT('TBFACT  ',F8.3,t70,a96)
      ENDIF  
      IF(TBMIN .NE. TBMINDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6009) TBMIN,helpint(11)
6009    FORMAT('TBMIN   ',F8.3,t70,a96)
      ENDIF  
      IF(IVERTDEN .NE. IVERTDENDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6024) IVERTDEN,helpint(26)
6024    FORMAT('REVRTDEN',F8.3,t70,a96)
      ENDIF  
      IF(DMIX .NE. DMIXDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6045) DMIX,helpint(47)
6045    FORMAT('SURFMIX ',F8.3,t70,a96)
      ENDIF  
      IF(ITRANSIT .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),60651) TRANSIT,helpint(71)
60651    FORMAT('TRANSIT',1X,F8.5,t70,a96)
      ENDIF
      IF(IGRV .NE. IGRVDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6016) IGRV,helpint(18)
6016    FORMAT('GRAVITY ',I8,t70,a96)
      ENDIF  
      IF(OMEGA1 .NE. OMEGA1DF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6025) OMEGA1,helpint(27)
6025    FORMAT('OMEGA   ',F8.3,t70,a96)
      ENDIF  
      IF(IPASS1 .NE. IPASS1DF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6018) IPASS1,helpint(21)
6018    FORMAT('PASSSAL ',I8,t70,a96)
      ENDIF  
      IF(IPASS2 .NE. IPASS2DF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6019) IPASS2,helpint(22)
6019    FORMAT('PASSTMP ',I8,t70,a96)
      ENDIF  
      IF(IPASS3 .NE. IPASS3DF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6020) IPASS3,helpint(23)
6020    FORMAT('PASSSED ',I8,t70,a96)
      ENDIF  
      IF(IZB .NE. IZBDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6017) IZB,helpint(19)
6017    FORMAT('ZEROBED ',I8,t70,a96)
      ENDIF  
      IF(ZERBED .NE. ZERBEDDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6022) ZERBED,helpint(20)
6022    FORMAT('ZERBELLV',F8.3,t70,a96)
      ENDIF  
      IF(IZERS .NE. IZERSDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6021) IZERS,helpint(24)
6021    FORMAT('ZEROSURF',I8,t70,a96)
      ENDIF  
      IF(ELEV1 .NE. ELEV  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6060) ELEV1,helpint(65)
6060    FORMAT('INITWSRF',F8.3,t70,a96)
      ENDIF  
      IF(SALI .NE. SALIDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6039) SALI,helpint(41)
6039    FORMAT('INITSAL ',F8.3,t70,a96)
      ENDIF  
      IF(TEMPI .NE. TEMPIDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6040) TEMPI,helpint(42)
6040    FORMAT('INITTEMP',F8.3,t70,a96)
      ENDIF  
      IF(SEDI .NE. SEDIDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6041) SEDI,helpint(43)
6041    FORMAT('INITSED ',F8.3,t70,a96)
      ENDIF  
      IF(UINP .NE. UINPDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6042) UINP,helpint(44)
6042    FORMAT('INITUBED',F8.3,t70,a96)
      ENDIF  
      IF(VINP .NE. VINPDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6043) VINP,helpint(45)
6043    FORMAT('INITVBED',F8.3,t70,a96)
      ENDIF  
      IF(PRCNT .NE. PRCNTDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6044) PRCNT,helpint(46)
6044    FORMAT('RETRNPCT',F8.3,t70,a96)
      ENDIF  
      IF(CONV(1) .NE. CONVDF(1)  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6061) CONV(1),helpint(66)
6061    FORMAT('CONV-VEL',F8.5,t70,a96)
      ENDIF  
      IF(CONV(3) .NE. CONVDF(3)  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6062) CONV(3),helpint(67)
6062    FORMAT('CONV-DEP',F8.5,t70,a96)
      ENDIF  
      IF(CONV(4) .NE. CONVDF(4)  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6063) CONV(4),helpint(68)
6063    FORMAT('CONV-SAL',F8.5,t70,a96)
      ENDIF  
      IF(CONV(5) .NE. CONVDF(5)  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6064) CONV(5),helpint(69)
6064    FORMAT('CONV-TMP',F8.5,t70,a96)
      ENDIF  
      IF(CONV(6) .NE. CONVDF(6)  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6065) CONV(6),helpint(70)
6065    FORMAT('CONV-SED',F8.5,t70,a96)
      ENDIF  
      IF(IPRT .EQ. 0) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),60481) helpint(51)
60481    FORMAT('ECHSVNON',t70,a96)
      ELSEIF(IPRT .EQ. 2) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),60482) helpint(52)
60482    FORMAT('ECHSVINI',t70,a96) 
      ELSEIF(ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),60483) helpint(53)
60483    FORMAT('ECHSVALL',t70,a96) 
      ENDIF          
      IF(NPRTI .NE. NPRTIDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6049) NPRTI,helpint(54)
6049    FORMAT('ITERINTV',I8,t70,a96)
      ENDIF  
      IF(NPRTF .NE. NPRTFDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6050) NPRTF,helpint(55)
6050    FORMAT('ASCSVFRQ',I8,t70,a96)
      ENDIF  
      IF(IRSAV .NE. IRSAVDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6051) IRSAV,helpint(56)
6051    FORMAT('STBIN   ',I8,t70,a96)
      ENDIF  
      IF(IOUTFREQ .NE. IOUTFREQDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6053) IOUTFREQ,helpint(58)
6053    FORMAT('FRQBIN  ',I8,t70,a96)
      ENDIF  
      IF(IOUTRST .NE. IOUTRSTDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6054) IOUTRST,helpint(59)
6054    FORMAT('FRQRST  ',I8,t70,a96)
      ENDIF  
      IF(IREWOUT .NE. IREWOUTDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6055) IREWOUT,helpint(60)
6055    FORMAT('RWDASFRQ',I8,t70,a96)
      ENDIF  
      IF(IREWMES .NE. IREWMESDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6059) IREWMES,helpint(64)
6059    FORMAT('MESSRWND',I8,t70,a96)
      ENDIF  
      IF(ISAVITR .NE. ISAVITRDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6023) ISAVITR,helpint(25)
6023    FORMAT('SAVITR',I8,t70,a96)
      ENDIF  
      IF(JSPLPT .GT. 0) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),60861)
60861   FORMAT(30X,'&  Nodes for extraction of all constiuents to a time series file')        
        LINE=LINE+1
        WRITE(DATALIN(LINE),60862) (NSPLPT(J),J=1,JSPLPT)
60862    FORMAT('SPR-NOD ',1X,10I7)        
      ENDIF
      IF(ICTOTC  .GT. 0) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6066)
        LINE=LINE+1
        WRITE(DATALIN(LINE),60661) (NCSPLPT(J),J=1,ICTOTC)
6066    FORMAT(40X,'&  Continuity lines for selective output')
60661   FORMAT('CCLINOUT',20I7)
      ENDIF
      
      DO J=1,6
        IF(ICCOMP(J)  .EQ. 1) THEN
          LINE=LINE+1
          WRITE(DATALIN(LINE),6067) helpint(72)
6067      FORMAT('CONT-FLW',t70,a96)
        ELSEIF(ICCOMP(J)  .EQ. 2) THEN
          LINE=LINE+1
          WRITE(DATALIN(LINE),6068) helpint(73)
6068      FORMAT('CONT-DEP',t70,a96)
        ELSEIF(ICCOMP(J)  .EQ. 3) THEN
          LINE=LINE+1
          WRITE(DATALIN(LINE),6069) helpint(74) 
6069      FORMAT('CONT-ELV',t70,a96)
        ELSEIF(ICCOMP(J)  .EQ. 4) THEN
          LINE=LINE+1
          WRITE(DATALIN(LINE),6070) helpint(75)
6070      FORMAT('CONT-SAL',t70,a96)
        ELSEIF(ICCOMP(J)  .EQ. 5) THEN
          LINE=LINE+1
          WRITE(DATALIN(LINE),6071) helpint(76) 
6071      FORMAT('CONT-TMP',t70,a96)
        ELSEIF(ICCOMP(J)  .EQ. 6) THEN
          LINE=LINE+1
          WRITE(DATALIN(LINE),6072) helpint(77)
6072      FORMAT('CONT-SED',t70,a96)
        ENDIF  
      ENDDO
      IF(XSCALE .NE. XSCALEDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6027) XSCALE,helpint(29)
6027    FORMAT('X-SCALE ',F8.3,t70,a96)
      ENDIF  
      IF(YSCALE .NE. YSCALEDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6028) YSCALE,helpint(30)
6028    FORMAT('Y-SCALE ',F8.3,t70,a96)
      ENDIF  
      IF(ZSCALE .NE. ZSCALEDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6029) ZSCALE,helpint(31)
6029    FORMAT('Z-SCALE ',F8.3,t70,a96)
      ENDIF  
      IF(IDSWT .NE. IDSWTDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6052) IDSWT,helpint(57)
6052    FORMAT('DRYSW   ',I8,t70,a96)
      ENDIF  
      IF(DSET .NE. DSETDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6035) DSET,helpint(37)
6035    FORMAT('DSET    ',F8.3,t70,a96)
      ENDIF  
      IF(DSETD .NE. DSETDDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6036) DSETD,helpint(38)
6036    FORMAT('DSETD   ',F8.3,t70,a96)
      ENDIF  
      IF(IFXBC .NE. IFXBCDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6037) IFXBC,helpint(39)
6037    FORMAT('FIXBC   ',I8,t70,a96)
      ENDIF  
      IF(UNOM .NE. UNOMDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6032) UNOM,helpint(34)
6032    FORMAT('UNOM    ',F8.3,t70,a96)
      ENDIF  
      IF(UDIR .NE. UDIRDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6033) UDIR,helpint(35)
6033    FORMAT('UDIR    ',F8.3,t70,a96)
      ENDIF  
      IF(HMIN .NE. HMINDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6034) HMIN,helpint(36)
6034    FORMAT('HMIN    ',F8.3,t70,a96)
      ENDIF  
      DO K=1,NMAT
        LINE=LINE+1
        WRITE(DATALIN(LINE),6073) K,ORT(K,1),helpint(78)
6073    FORMAT('EDDY-MAT',I8,F10.5,t70,a96)    
        LINE=LINE+1
        WRITE(DATALIN(LINE),6074) K,ORT(K,6),helpint(79)
6074    FORMAT('EDDY-VRT',I8,1PE12.3,t70,a96) 
        IF(ORT(K,8) .NE. 0.  .OR.  ISHOWSW .EQ. 1) THEN
          LINE=LINE+1
          WRITE(DATALIN(LINE),6075) K,ORT(K,8),helpint(80)
6075      FORMAT('DIFF-MAT',I8,F10.5,t70,a96)    
        ENDIF  
        IF(ORT(K,10) .NE. 0.  .OR.  ISHOWSW .EQ. 1) THEN
          LINE=LINE+1
          WRITE(DATALIN(LINE),6076) K,ORT(K,10),helpint(81)
6076      FORMAT('DIFF-VRT',I8,1PE12.3,t70,a96)    
        ENDIF
        LINE=LINE+1
        WRITE(DATALIN(LINE),6077) K,ORT(K,5),helpint(82)
6077    FORMAT('MANN-MAT',I8,F10.5,t70,a96)    
        IF(ORT(K,11) .NE. 0.  .OR.  ISHOWSW .EQ. 1) THEN
          LINE=LINE+1
          WRITE(DATALIN(LINE),6078) K,ORT(K,11),helpint(83)
6078      FORMAT('MANN-BNK',I8,F10.5,t70,a96)    
        ENDIF
        IF(ORT(K,13) .NE. 0.  .OR.  ISHOWSW .EQ. 1) THEN
          LINE=LINE+1
          WRITE(DATALIN(LINE),6079) K,ORT(K,13),helpint(84)
6079      FORMAT('MANN-SRF',I8,F10.5,t70,a96)    
        ENDIF
        IF(ORT(K,12) .NE. 0.  .OR.  ISHOWSW .EQ. 1) THEN
          LINE=LINE+1
          WRITE(DATALIN(LINE),6080) K,ORT(K,12),helpint(85)
6080      FORMAT('MARSH-FR',I8,F10.5,t70,a96)    
        ENDIF
        IF(EDD1(K) .NE. 0.  .OR.  EDD2(K) .NE. 0.  .OR.  EDD3(K) .NE. 0  .OR.  ISHOWSW .EQ. 1) THEN
          LINE=LINE+1
          WRITE(DATALIN(LINE),60811)  K,EDD1(K),EDD2(K),EDD3(K),helpint(86)    
60811     FORMAT('ED-VTVAR',I8,3F8.3,t70,a96)
        ENDIF
      ENDDO    
      IF(IDNOPT .NE. IDNOPTDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6006) IDNOPT,helpint(8)
6006    FORMAT('MARSHOPT',I8,t70,a96)
      ENDIF  
      IF(ACT1 .NE. ACT1DF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6087) ACT1,helpint(91)
6087    FORMAT('MARSH-SH',F8.3,t70,a96)    
      ENDIF
      IF(ACT2 .NE. ACT2DF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6088) ACT2,helpint(92)
6088    FORMAT('MARSH-RG',F8.3,t70,a96)    
      ENDIF
      IF(ACT3 .NE. ACT3DF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6089) ACT3,helpint(93)
6089    FORMAT('MARSH-PR',F8.3,t70,a96)    
      ENDIF
      IF(ACT4 .NE. ACT4DF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6090) ACT4,helpint(94)
6090    FORMAT('MARSH-LM',F8.3,t70,a96)    
      ENDIF
      IF(L3DTYP .EQ. 2) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),60841)
60841   FORMAT(30X,'&  Nodal layer data type LD2, 0 = apply to all nodes, number of layers  Proportional factors')        
        DO K=1,L3DCNT
          LINE=LINE+1
          WRITE(DATALIN(LINE),6085) JND(K),KKLAY(K),(L3DDAT(K,J),J=1,KKLAY(K))
6085      FORMAT('LD2     ',2I8,20F8.3)    
        ENDDO
      ELSEIF(L3DTYP .EQ. 3) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),60851)
60851   FORMAT(30X,'&  Nodal layer data type LD3, 0 = apply to all nodes, number of layers  Layer elevations')        
        LINE=LINE+1
        DO K=1,L3DCNT
          WRITE(DATALIN(LINE),6086) JND(K),KKLAY(K),(L3DDAT(K,J),J=1,KKLAY(K))
6086      FORMAT('LD3     ',2I8,20F8.3)    
        ENDDO
      endif
      IF(CMIN .NE. CMINDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6030) CMIN,helpint(32)
6030    FORMAT('BOUNDCMN',F8.3,t70,a96)
      ENDIF  
      IF(CPR .NE. CPRDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6031) CPR,helpint(33)
6031    FORMAT('BOUNDCPW',F8.3,t70,a96)
      ENDIF  
      IF(VMIN .NE. UMINDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6081) VMIN,helpint(87)
6081    FORMAT('BN-V-MIN',F8.3,t70,a96)    
      ENDIF
      IF(POWER .NE. POWERDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6082) POWER,helpint(88)
6082    FORMAT('BN-V-PWR',F8.3,t70,a96)    
      ENDIF
      IF(UMIN .NE. UMINDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6083) UMIN,helpint(89)
6083    FORMAT('TR-V-MIN',F8.3,t70,a96)    
      ENDIF
      IF(PWERIN .NE. PWERINDF  .OR.  ISHOWSW .EQ. 1) THEN
        LINE=LINE+1
        WRITE(DATALIN(LINE),6084) PWERIN,helpint(90)
6084    FORMAT('TR-V-PWR',F8.3,t70,a96)    
      ENDIF




      LINE=LINE+1
      WRITE(DATALIN(LINE),6091) helpint(95)
6091  FORMAT('TAB-END',t70,a96)    
      LINE=LINE+1
      WRITE(DATALIN(LINE),6092)  helpint(96)
6092  FORMAT('ENDGEO',t70,a96)    
      
      DO J=1,JT
        LINE=LINE+1
        IF(DELT(J) .EQ. 0  .AND. DELTM(J) .EQ. 0.  .OR.  DELT(J) .GT. 0.) THEN
          WRITE(DATALIN(LINE),6100) DELT(J),HELPTIME(1)
        ELSE
          WRITE(DATALIN(LINE),6101) DELTM(J),HELPTIME(2)  
        ENDIF
6100    FORMAT('DELTA-HR',F12.4,T70,A162)        
6101    FORMAT('DELTA-MN',F12.4,T70,A162)        
        IF(DATENDST(J) .NE. '                '  .AND.  J .GT. 1) THEN
          LINE=LINE+1
          WRITE(DATALIN(LINE),6102) DATENDST(J),HELPTIME(3)
6102      FORMAT('DATE-END',4X,A16,T70,A162)
        ENDIF
        IF(IITYPE(J) .EQ. 1) THEN
          LINE=LINE+1
          WRITE(DATALIN(LINE),6103),HELPTIME(4)
6103      FORMAT('Q-ITR',T70,A162)    
        ELSEIF(IITYPE(J) .EQ. 2) THEN
          LINE=LINE+1
          WRITE(DATALIN(LINE),6104),HELPTIME(5)
6104      FORMAT('QSL-ITR',T70,A162)    
        ELSEIF(IITYPE(J) .EQ. 3) THEN
          LINE=LINE+1
          WRITE(DATALIN(LINE),6105),HELPTIME(6)
6105      FORMAT('QTM-ITR',T70,A162)    
        ELSEIF(IITYPE(J) .EQ. 4) THEN
          LINE=LINE+1
          WRITE(DATALIN(LINE),6106),HELPTIME(7)
6106      FORMAT('QSD-ITR',T70,A162)    
        ELSEIF(IITYPE(J) .EQ. 5) THEN
          LINE=LINE+1
          WRITE(DATALIN(LINE),6107),HELPTIME(8)
6107      FORMAT('QST-ITR',T70,A162)    
        ENDIF
        KH=NHLIN(J)
        KQ=NQLIN(J)
        KE=NELIN(J)
        DO K=1,KH
          LINE=LINE+1
          IF(HLIN1(K,J) .GT. -9000.) THEN
            IF(HCKLIN(K,J) .EQ. 1 ) THEN
              WRITE(DATALIN(LINE),6108) IHLIN(K,J),LAYNUMH(K,J),HLIN(K,J),HLIN1(K,J),(QUALKH(K,J,KK),KK=1,3),HELPTIME(9)          
6108          FORMAT('FL-ELEVI',2I8,2F8.4,3F8.3,T70,A162)    
            ELSE
              WRITE(DATALIN(LINE),6109) IHLIN(K,J),LAYNUMH(K,J),HLIN(K,J),HLIN1(K,J),(QUALKH(K,J,KK),KK=1,3),HELPTIME(10)
6109          FORMAT('CN-ELEVI',2I8,2F8.4,3F8.3,T70,A162)    
            ENDIF
          ELSE
            IF(HCKLIN(K,J) .EQ. 1 ) THEN
              WRITE(DATALIN(LINE),6110) IHLIN(K,J),LAYNUMH(K,J),HLIN(K,J),(QUALKH(K,J,KK),KK=1,3),HELPTIME(11)
6110          FORMAT('FL-ELEVC',2I8,F8.4,3F8.3,T70,A162)    
            ELSE
              WRITE(DATALIN(LINE),6111) IHLIN(K,J),LAYNUMH(K,J),HLIN(K,J),(QUALKH(K,J,KK),KK=1,3),HELPTIME(12)          
6111          FORMAT('CN-ELEVC',2I8,F8.4,3F8.3,T70,A162)    
            ENDIF
          ENDIF
        ENDDO
        
        IF(KHCN(J) .GT. 0) THEN
          DO K=1,KHCN(J)
            L1=MIN(IHCN(K,J),9)
            LINE=LINE+1
            WRITE(DATALIN(LINE),61111) (FHCN(K,J,L),L=1,L1)
61111       FORMAT('HCN',5X,9F8.3)
            IF(IHCN(K,J) .LE. 9) CYCLE 
            L1=MIN(IHCN(K,J),18)
            LINE=LINE+1
            WRITE(DATALIN(LINE),61111) (FHCN(K,J,L),L=10,L1)
            IF(IHCN(K,J) .LE. 18) CYCLE 
            L1=MIN(IHCN(K,J),27)
            LINE=LINE+1
            WRITE(DATALIN(LINE),61111) (FHCN(K,J,L),L=19,L1)
            IF(IHCN(K,J) .LE. 27) CYCLE 
            L1=MIN(IHCN(K,J),36)
            LINE=LINE+1
            WRITE(DATALIN(LINE),61111) (FHCN(K,J,L),L=28,L1)
          ENDDO
        ENDIF    
        
        IF(WVEL(J) .NE. 0.) THEN
          LINE=LINE+1
          WRITE(DATALIN(LINE),61112) WVEL(J),WDIR(J)
61112       FORMAT('GBWIND  ',1X,2F8.3)
        ENDIF    

        DO K=1,KQ
          LINE=LINE+1
          IF(IQLIN1(K,J) .EQ. 1) ALAB='C'
          IF(IQLIN1(K,J) .EQ. 2) ALAB='F'
          IF(IQLIN1(K,J) .EQ. 3) ALAB='H'
          IF(QCKLIN(K,J) .EQ. 0) THEN
            BLAB='CN'
          ELSE
            BLAB='FL'
          ENDIF
          IF(ALAB .EQ. 'C') THEN
            IHP=13
          ELSEIF(ALAB .EQ. 'F') THEN
            IHP=14
          ELSE
            IHP=15
          ENDIF
          WRITE(DATALIN(LINE),6112) BLAB,ALAB,IQLIN(K,J),LAYNUMQ(K,J),QLIN(K,J),QDLIN(K,J),(QUALKQ(K,J,KK),KK=1,3),HELPTIME(IHP)      
6112      FORMAT(A2,'-Q',A1,3X,2I8,2F10.2,3F8.3,T70,A162)          
        ENDDO
        
        DO K=1,KE
          IF(ECKLIN(K,J) .EQ. 1) THEN
            BLAB='FL'
          ELSE
            BLAB='CN'
          ENDIF
          LINE=LINE+1
          IF(IETP(K,J) .EQ. 4) THEN
            WRITE(DATALIN(LINE),6113) BLAB,ELIN(K,J),(QUALKE(K,J,KK),KK=1,3),HELPTIME(16) 
6113        FORMAT(A2,'-RAIN ',F8.4,3F8.3,T70,A162)
          ELSEIF(IETP(K,J) .EQ. 1) THEN
            IF(IELIN(K,J) .GT. 0) THEN  
              IF(ECKLIN1(K,J) .EQ. 1) THEN  
                WRITE(DATALIN(LINE),6116) BLAB,IELIN(K,J),LAYNUME(K,J),ELIN(K,J),(QUALKE(K,J,KK),KK=1,3),HELPTIME(19)
6116            FORMAT(A2,'-ELMET',2I8,F8.4,3F8.3,T70,A162)
              ELSE
                WRITE(DATALIN(LINE),6117) BLAB,IELIN(K,J),LAYNUME(K,J),ELIN(K,J),(QUALKE(K,J,KK),KK=1,3),HELPTIME(20)
6117            FORMAT(A2,'-ELMED',2I8,F8.4,3F8.3,T70,A162)
              ENDIF
            ELSE
              IF(ECKLIN1(K,J) .EQ. 1) THEN  
                WRITE(DATALIN(LINE),6115) BLAB,LAYNUME(K,J),ELIN(K,J),(QUALKE(K,J,KK),KK=1,3),HELPTIME(18)
6115            FORMAT(A2,'-ELMGT',I8,F8.4,3F8.3,T70,A162)
              ELSE
                WRITE(DATALIN(LINE),6114) BLAB,LAYNUME(K,J),ELIN(K,J),(QUALKE(K,J,KK),KK=1,3),HELPTIME(17) 
6114            FORMAT(A2,'-ELMGD',I8,F8.4,3F8.3,T70,A162)
              ENDIF
            ENDIF
          ELSEIF(IETP(K,J) .EQ. 6) THEN
            WRITE(DATALIN(LINE),6118) BLAB,IELIN(K,J),ELIN(K,J),(QUALKE(K,J,KK),KK=1,3),HELPTIME(21)
6118        FORMAT(A2,'-GRAIN',I8,F8.4,3F8.3,T70,A162)
          ENDIF
        ENDDO
        
        IF(NSND(J) .GT. 0) THEN
          DO K=1,NSND(J)
            IF(NODSND(K,J) .GT. 0) THEN
              LINE=LINE+1
              WRITE(DATALIN(LINE),6119) NODSND(K,J),NCODE(K,J),(BCSND(K,J,L),L=1,6)
6119          FORMAT('SN',8X,2I7,2f10.5,4F8.3)            
            ELSE
              LINE=LINE+1
              WRITE(DATALIN(LINE),61191) NCODE(K,J),(BCSND(K,J,L),L=1,6)
61191         FORMAT('SD'15X,I7,2F10.5,4F8.2)       
            ENDIF  
          ENDDO
        ENDIF
        LINE=LINE+1
        WRITE(DATALIN(LINE),6200) 
6200    FORMAT('ENDSTEP')    
        
      ENDDO    
      
      LINE=LINE+1
      WRITE(DATALIN(LINE),6999) 
6999  FORMAT('ENDDATA')
      
      filter="r10 file *.r10|*.R10|"
      IOUT=66

      CALL WSelectFile(Filter,SaveDialog+PromptOn+AppendExt+DirChange,NAMEFL,'Save R10 File for Execution')
      
	  IF (WInfoDialog(ExitButtonCommon).EQ.CommonOpen) THEN
		  go to 500
	  else
        RETURN
      endif

500   CONTINUE
      OPEN(IOUT,FILE=NAMEFL,FORM='FORMATTED')
      DO K=1,LINE
        WRITE(IOUT,'(A230)') DATALIN(K)
      ENDDO
      CLOSE(IOUT)
      RETURN
      END