~ubuntu-branches/debian/jessie/eso-midas/jessie

« back to all changes in this revision

Viewing changes to system/ext/f77utl.c

  • Committer: Package Import Robot
  • Author(s): Ole Streicher
  • Date: 2014-04-22 14:44:58 UTC
  • Revision ID: package-import@ubuntu.com-20140422144458-okiwi1assxkkiz39
Tags: upstream-13.09pl1.2+dfsg
ImportĀ upstreamĀ versionĀ 13.09pl1.2+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*===========================================================================
 
2
  Copyright (C) 1992-2009 European Southern Observatory (ESO)
 
3
 
 
4
  This program is free software; you can redistribute it and/or 
 
5
  modify it under the terms of the GNU General Public License as 
 
6
  published by the Free Software Foundation; either version 2 of 
 
7
  the License, or (at your option) any later version.
 
8
 
 
9
  This program is distributed in the hope that it will be useful,
 
10
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
  GNU General Public License for more details.
 
13
 
 
14
  You should have received a copy of the GNU General Public 
 
15
  License along with this program; if not, write to the Free 
 
16
  Software Foundation, Inc., 675 Massachusetts Ave, Cambridge, 
 
17
  MA 02139, USA.
 
18
 
 
19
  Correspondence concerning ESO-MIDAS should be addressed as follows:
 
20
        Internet e-mail: midas@eso.org
 
21
        Postal address: European Southern Observatory
 
22
                        Data Management Division 
 
23
                        Karl-Schwarzschild-Strasse 2
 
24
                        D 85748 Garching bei Muenchen 
 
25
                        GERMANY
 
26
===========================================================================*/
 
27
 
 
28
/*+++++++++  Remove ESO extensions to FORTRAN 77    ++++++++++++++++++++
 
29
.LANGUAGE    C
 
30
.IDENT       f77utl.c
 
31
.AUTHOR      Preben J. Grosbol [ESO/IPG]
 
32
.KEYWORDS    fortran statements, program sections
 
33
.ENVIRONMENT UNIX
 
34
.VERSION     1.0  1987-Nov-12: Creation,     PJG
 
35
.VERSION     1.1  1988-Jan-15: Only warning on structure error,   PJG
 
36
.VERSION     1.2  1991-May-15: Check for CHARACTER* FUNCTION,   PJG
 
37
.VERSION     1.3  1992-Aug-07: Include return status,   PJG
 
38
 
 
39
 090330         last modif
 
40
------------------------------------------------------------------------*/
 
41
 
 
42
#include   <stdio.h>                        /* Standard I/O library     */
 
43
#include   <f77stat.h>                      /* FORTRAN statement types  */
 
44
 
 
45
int f77_sect(ptype,sect,perr)
 
46
int      *ptype;
 
47
int      sect;
 
48
int      *perr;
 
49
{
 
50
  int    section;
 
51
 
 
52
  *perr = 0;
 
53
  section = sect;
 
54
  switch (sect) {                           /* update and check section */
 
55
    case PROG_SEC : if (*ptype & PROG_STAT) break;
 
56
                    if (*ptype & (IMPL_STAT | DECL_STAT | DATA_STAT | 
 
57
                      EXEC_STAT | END_STAT)) section = IMPL_SEC;
 
58
                     else { *perr = 1; break; }
 
59
    case IMPL_SEC : if (*ptype & IMPL_STAT) break;
 
60
                    if (*ptype & (DECL_STAT | DATA_STAT | EXEC_STAT | 
 
61
                      END_STAT)) section = DECL_SEC;
 
62
                     else { *perr = 1; break; }
 
63
    case DECL_SEC : if (*ptype & DECL_STAT) break;
 
64
                    if (*ptype & (DATA_STAT | EXEC_STAT | 
 
65
                      END_STAT)) section = DATA_SEC;
 
66
                     else { *perr = 1; break; }
 
67
    case DATA_SEC : if (*ptype & DATA_STAT) break;
 
68
                    if (*ptype & (EXEC_STAT | END_STAT)) section = EXEC_SEC;
 
69
                     else { *perr = 1; break; }
 
70
    case EXEC_SEC : if (*ptype & EXEC_STAT) break;
 
71
                    if (*ptype & END_STAT) section = END_SEC;
 
72
                     else { *perr = 1; break; }
 
73
    case END_SEC  : if (*ptype & END_STAT) break;
 
74
                    if (*ptype & PROG_STAT && *ptype != PROGRAM)
 
75
                      section = PROG_SEC;
 
76
                     else { *perr = 1; break; }
 
77
  }
 
78
 
 
79
  return section;
 
80
}
 
81
 
 
82
char *find_f77(list,id,pno,ptype)        /* compare with f77 statements */
 
83
FSTAT       *list;
 
84
char          *id;
 
85
int          *pno;
 
86
int        *ptype;
 
87
{
 
88
  char     c, *pid, *pstat, *pc;
 
89
 
 
90
  while ((pstat=list->id)) {             /* loop though statement list  */
 
91
    pid = id; *pno = 0;
 
92
    while (((c = *pstat++) == *pid++) && (c != '\0')) (*pno)++;
 
93
    if (!c) break;
 
94
    list++;
 
95
  }
 
96
 
 
97
  pc = pid - 1;
 
98
  if (list->type==CHARACTER && *pc=='*') {     /* check if FUNCTION  */
 
99
    pc++;
 
100
    while ((('0' <= (c = *pc)) && c<='9') || 
 
101
           c=='*' || c=='(' || c==')') pc++;
 
102
    pstat = "FUNCTION";
 
103
    while ((c = *pstat++) == *pc++ && c != '\0');
 
104
    *ptype = (c) ? CHARACTER : CFUNCTION;
 
105
  }
 
106
  else *ptype = (c) ? EXEC_STAT : list->type;
 
107
 
 
108
  return --pid;
 
109
}