File: get_sial_config_params.F

package info (click to toggle)
aces3 3.0.8-7
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 775,084 kB
  • sloc: f90: 5,133,741; fortran: 381,059; ansic: 22,951; pascal: 7,515; cpp: 4,349; makefile: 1,715; csh: 292; sh: 144
file content (144 lines) | stat: -rw-r--r-- 5,244 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
C  Copyright (c) 2003-2010 University of Florida
C
C  This program is free software; you can redistribute it and/or modify
C  it under the terms of the GNU General Public License as published by
C  the Free Software Foundation; either version 2 of the License, or
C  (at your option) any later version.

C  This program is distributed in the hope that it will be useful,
C  but WITHOUT ANY WARRANTY; without even the implied warranty of
C  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
C  GNU General Public License for more details.

C  The GNU General Public License is included in this distribution
C  in the file COPYRIGHT.
      subroutine get_sial_config_params(sial_program)
c--------------------------------------------------------------------------
c   Scans for any program-specific parameters on the SIAL config file.
c--------------------------------------------------------------------------
      implicit none
      include 'sial_config_params.h'

      character*(*) sial_program
      character*80 line, keyword, cval
      character*256 config_file, envvar

      integer iunit, ival, lenenv, ierr
      integer i, n, nn, ios, str_trimlen
      double precision fval
 
c--------------------------------------------------------------------------
c   Default values.
c--------------------------------------------------------------------------

      no_servers = .false.
      ignore_dropmo = .false.
      use_2der_integrals = .false.
      vvvi_stack = .false.
 
c--------------------------------------------------------------------------
c   Open the SIAL config file.
c--------------------------------------------------------------------------

      config_file = './sial_config'   ! first try.

      iunit = 12
      open (unit=iunit, file = config_file, status = 'OLD',
     *      err=500, iostat = ios)

      print *,'Reading SIAL config file ',config_file

c--------------------------------------------------------------------------
c   Search file for a match to sial_program.
c--------------------------------------------------------------------------

   50 continue
      nn = str_trimlen(sial_program)
  100 continue
      read (iunit,'(A80)', end = 200) line
      if (line(1:nn) .ne. sial_program(1:nn)) go to 100

c---------------------------------------------------------------------------
c   Read parameters line.
c---------------------------------------------------------------------------

  120 continue
      read (iunit,'(A80)', end = 200) line

c---------------------------------------------------------------------------
c   Find the '=' sign.
c---------------------------------------------------------------------------

      cval = ' '
      call c_line_parse(line // char(0), '=',3,ival, fval, cval)
      if (cval(1:1) .eq. ' ') go to 200   ! no more params found.

c---------------------------------------------------------------------------
c   Find the keyword.
c---------------------------------------------------------------------------

      n = str_trimlen(line)
      do i = 1, n
         if (line(i:i) .eq. '=') then
            keyword = line(1:i-1)
            go to 150
         endif
      enddo
      
  150 continue
      n = str_trimlen(keyword)
  
      if (keyword(1:n) .eq. 'NO_SERVERS') then
         call c_line_parse(line//char(0),'=',3,ival, fval, cval)
         if (cval(1:3) .eq. 'YES') no_servers = .true.
      else if (keyword(1:n) .eq. 'IGNORE_DROPMO') then
         call c_line_parse(line//char(0),'=',3,ival, fval, cval)
         if (cval(1:3) .eq. 'YES') ignore_dropmo = .true.
      else if (keyword(1:n) .eq. 'SECOND_DERIVATIVE_INTEGRALS') then
         call c_line_parse(line//char(0),'=',3,ival, fval, cval)
         if (cval(1:3) .eq. 'YES') use_2der_integrals = .true.
      else if (keyword(1:n) .eq. 'VVVI_STACK') then
         call c_line_parse(line//char(0),'=',3,ival, fval, cval)
         if (cval(1:3) .eq. 'YES') vvvi_stack = .true.
      else
         print *,'Warning: Invalid keyword ',keyword(1:n),' found on ',
     *     'config file for SIAL program ',sial_program
         call abort_job() 
      endif

      go to 120   ! try reading another param line for this program.

  200 continue
      close (iunit)
      return

  500 continue
      
c--------------------------------------------------------------------------
c   Check for existence of $ACES_EXE_PATH/sial_config
c--------------------------------------------------------------------------

      call c_getenv('ACES_EXE_PATH'//char(0), envvar, lenenv, ierr)
      if (ierr .eq. 0) then
         config_file = envvar(1:lenenv) // '/sio/sial_config'
         open (unit=iunit, file = config_file, status = 'OLD',
     *      err=600, iostat = ios)

         go to 50   ! successfully opened.
      endif 

  600 continue

c--------------------------------------------------------------------------
c   Check for existence of /usr/share/aces3/sio/sial_config
c--------------------------------------------------------------------------

      config_file = '/usr/share/aces3/sio/sial_config'
      open (unit=iunit, file = config_file, status = 'OLD',
     *   err=700, iostat = ios)

      go to 50   ! successfully opened.

  700 continue
      return
      end