File: test_compare.f

package info (click to toggle)
aces3 3.0.6-7
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 82,460 kB
  • sloc: fortran: 225,647; ansic: 20,413; cpp: 4,349; makefile: 953; sh: 137
file content (141 lines) | stat: -rw-r--r-- 4,910 bytes parent folder | download | duplicates (6)
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
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.
      program test_compare
c-------------------------------------------------------------------------
c   Program to compare test results with that found in a standardized
c   database of results.
c-------------------------------------------------------------------------

      implicit none
      include 'mpif.h'

      integer ios, lenenv, ierr
      integer argc, f_iargc
      integer i, n, nw, ntitle, nkey
      integer str_trimlen 
      integer me, mpierr
      double precision jobarc_vals(1000)
      double precision rvalue, rmserr

      character*256 db_fname, envvar
      character*20 test_name
      character*80 title, line, key

c--------------------------------------------------------------------------
c   Initialize mpi.
c--------------------------------------------------------------------------

      call mpi_init(mpierr)
      call mpi_comm_rank(mpi_comm_world, me, mpierr)
      if (me .ne. 0) go to 500

c--------------------------------------------------------------------------
c   Initialize ACES2 file system, open JOBARC.
c--------------------------------------------------------------------------

      call init_machine_types()
      call aces_init_rte()
      call aces_ja_init()

c--------------------------------------------------------------------------
c   Get ACES_EXE_PATH environment variable.  Test database should be in 
c   this directory.
c--------------------------------------------------------------------------

      call c_getenv('ACES_EXE_PATH'//char(0), envvar, lenenv, ierr)
      if (ierr .ne. 0) then
         print *,'Error: ACES_EXE_PATH env. variable was not found.'
         stop
      endif

      db_fname = envvar(1:lenenv) // '/' // 'test_results'

c--------------------------------------------------------------------------
c   Open database of test results.
c--------------------------------------------------------------------------

      open (unit=20,file=db_fname,status='OLD',err=1000,iostat=ios)

c---------------------------------------------------------------------------
c   Get command-line argument.  This tells us which test we are doing.
c---------------------------------------------------------------------------

      argc = f_iargc()
      call f_getarg(1, test_name)
      n = str_trimlen(test_name)

c----------------------------------------------------------------------------
c   Search the database for this test.
c----------------------------------------------------------------------------

   10 continue
      read (unit=20, fmt=50, end=100 ) line
      if (line(1:n) .ne. test_name(1:n)) go to 10

c----------------------------------------------------------------------------
c   Test was found.  Read the next line. 
c----------------------------------------------------------------------------

      ntitle = str_trimlen(line) 
      title = line (1:ntitle)
      read (unit=20,fmt=50) line
   50 format(a80)

      do i = 1, 80
         if (line(i:i) .eq. ' ') then
            nkey = i-1
            read (line(i+1:80),'(i3)') nw
            go to 70
         else
            key(i:i) = line(i:i)
         endif
      enddo
  70  continue 

      call dgetrec(1,'JOBARC', key(1:nkey), nw, jobarc_vals)

c----------------------------------------------------------------------------
c   Calculate the RMS error between the standardized values and those 
c   found on JOBARC.
c----------------------------------------------------------------------------

      rmserr = 0.d0
      do i = 1, nw
         read (unit=20,fmt=9000) rvalue
         rmserr = rmserr + (rvalue-jobarc_vals(i)) * 
     *                     (rvalue-jobarc_vals(i))  
      enddo 

      rmserr = dsqrt(rmserr) / dble(nw)

c---------------------------------------------------------------------------
c   Print the test result.
c---------------------------------------------------------------------------

      print *,'TEST ',title(1:ntitle),' RMS error ',rmserr       
  100 continue
      call aces_ja_fin() 

  500 continue
      call mpi_barrier(mpi_comm_world, mpierr)
      call mpi_finalize(mpierr)
      stop

 1000 continue
      print *,'Error: Cannot open test database: status = ',ios
      print *,'Test database filename ',db_fname
      stop
 9000 format(g20.12)
      end