/***********************************************************************
* 
*               *****   ***    ***
*                  *   *   *  *   *
*                 *     ***    ***
*                *     *   *  *   *
*               *****   ***    ***
*
* A FREE Finite Elements Analysis Program in ANSI C for the UNIX OS.
*
* Composed and edited and copyright by 
* Professor Dr.-Ing. Frank Rieg, University of Bayreuth, Germany
*
* eMail: 
* frank.rieg@uni-bayreuth.de
* dr.frank.rieg@t-online.de
* 
* V10.0  December 12, 2001
*
* Z88 should compile and run under any UNIX OS and Motif 2.0.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING.  If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
***********************************************************************/ 
/**********************************************************************
* Function g1i488 prueft Z88I4.TXT
* 23.3.2002 Rieg
**********************************************************************/

/***********************************************************************
* Fuer UNIX
***********************************************************************/
#ifdef FR_UNIX
#include <z88v.h>
#include <stdio.h>   /* FILE,printf */
#endif

/***********************************************************************
* Functions
***********************************************************************/
void erif88(FR_INT4 izeile);

/***********************************************************************
* Start G1I488
***********************************************************************/
int g1i488(void)
{
extern FILE *fdatei;

extern FR_INT4 izeile,LANG;

FR_DOUBLE eps,rp;
FR_INT4 maxit;

int ier;

char *cresult;
char cline[256];

/**********************************************************************
* Checken der 1.Zeile
**********************************************************************/
izeile= 1; 

cresult= fgets(cline,256,fdatei);
if(!cresult)
  {
  erif88(izeile);
  return(2);
  }

ier= sscanf(cline,"%ld %lf %lf",&maxit,&eps,&rp);
if(ier != 3) 
  {
  printf("%s\n",cline);
  if(LANG == 1)
    printf("### Schreibfehler oder fehlende Daten in Zeile 1 entdeckt\n");
  if(LANG == 2)
    printf("### typing error or missing entries in line 1 detected\n");
  return(2);
  }
        
/*----------------------------------------------------------------------
* logische Pruefungen
*---------------------------------------------------------------------*/
if(maxit <= 0)
  {
  printf("%s\n",cline);
  if(LANG == 1)
    {
    printf("### Falsche Anzahl Iterationen fuer Z88I2:\n");
    printf("### MAXIT muss groesser 0 sein\n");
    printf("### Wie waer's mit 1000 oder 10000 ?\n");
    printf("### 1.Wert in Zeile 1 ueberpruefen\n");
    }
  if(LANG == 2)
    {
    printf("### wrong maximal number of iterations for Z88I2\n");
    printf("### MAXIT has to be larger than 0\n");
    printf("### How about 1000 or 10000 ?\n");
    printf("### check 1st entry in line 1\n");
    }
  return(2);
  }

if(eps <= 0)
  {
  printf("%s\n",cline);
  if(LANG == 1)
    {
    printf("### EPSILON fuer Z88I2 unzulaessig\n");
    printf("### EPSILON muss klein, aber groesser 0 sein\n");
    printf("### wie waer's mit 0.0000001 oder 1e-10 ?\n");
    printf("### 2.Wert in Zeile 1 ueberpruefen\n");
    }
  if(LANG == 2)
    {
    printf("### EPSILON invalid\n");
    printf("### EPSILON should be small but > 0\n");
    printf("### How about 0.0000001 or 1e-10 ?\n");
    printf("### check 2nd entry in line 1\n");
    }
  return(2);
  }

if(rp < 0)
  {
  printf("%s\n",cline);
  if(LANG == 1)
    {
    printf("### RP nicht in Ordnung\n");
    printf("### RP hat folgende Bedeutung:\n");
    printf("### Z88I2 -C : RP ist der Shift- Parameter, 0 <= RP <= 1\n");
    printf("### Z88I2 -S : RP ist der Relax- Parameter, 0 <= RP <= 2\n");
    printf("### 3.Wert in Zeile 1 ueberpruefen\n");
    }
  if(LANG == 2)
    {
    printf("### RP invalid\n");
    printf("### RP has the following meaning:\n");
    printf("### Z88I2 -C : RP is the Shift paramater, 0 <= RP <= 1\n");
    printf("### Z88I2 -S : RP is the Relax parameter, 0 <= RP <= 2\n");
    printf("### check 3rd entry in line 1\n");
    }
  return(2);
  }

return(0);
}
