Debian Codegraph @

packages/seacas/applications/blot/wrtcsv.f

raw
1 C Copyright(C) 1999-2020 National Technology & Engineering Solutions
2 C of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
3 C NTESS, the U.S. Government retains certain rights in this software.
4 C
5 C See packages/seacas/LICENSE for details
6
7 C=======================================================================
8 SUBROUTINE WRTCSV (NCRV, MAXPTS, NPTS, PTS, TXLAB, NAMES, DOLEGN,
9 * MAPEL, MAPND)
10 C=======================================================================
11
12 C --*** WRTCSV *** (XYPLOT) Write curve to CSV neutral file
13 C --
14 C --WRTCSV writes the data for a curve to a neutral file which is
15 C --in a comma-separated format. The first
16 C --time the routine is called, the neutral file is opened.
17 C --
18 C --Parameters:
19 C -- NPTS - IN - the number of points on the curve
20 C -- PTS - IN - the plot data;
21 C -- PTS(x,NTPVAR+1) holds the times if TIMPLT
22 C -- PTS(x,NTPVAR+2) holds the compressed times if TIMPLT and needed
23 C -- PLTITL - IN - the plot title describing the curve
24 C -- (e.g. "TIME vs SIGXX at ELEMENT 30")
25 C -- TXLAB, TYLAB - IN - the X and Y axis labels, either the
26 C -- user-input labels or the plot variable descriptions
27 C --
28
29 PARAMETER (MAXLEG = 4096)
30 include 'dbname.blk'
31 include 'dbtitl.blk'
32 include 'legopt.blk'
33 include 'xylim.blk'
34 include 'csv.blk'
35
36 include 'params.blk'
37 include 'tpvars.blk'
38
39 CHARACTER*2048 filnam, errmsg
40 INTEGER NPTS(*)
41 REAL PTS(MAXPTS,*)
42 CHARACTER*(*) TXLAB, NAMES(*)
43 LOGICAL DOLEGN
44 INTEGER MAPEL(*), MAPND(*)
45
46 CHARACTER*(MAXLEG) LEGEND
47 CHARACTER*(MXLNLN) PV
48
49 IF (.NOT. CSVOPN) THEN
50 filnam = basenam(:lenstr(basenam)) // '.csv'
51
52 C --Open the csv neutral file and write the title line
53
54 write (*,*) "CSV File: ", filnam(:lenstr(filnam))
55 open (unit=ncsv, file=filnam(:lenstr(filnam)), form='formatted',
56 * status='unknown', iostat=ierr)
57 IF (IERR .NE. 0) THEN
58 ERRMSG = 'Neutral CSV file "'//FILNAM(:LENSTR(FILNAM))//
59 * '" could not be opened.'
60 CALL PRTERR ('CMDERR', ERRMSG(:LENSTR(ERRMSG)))
61 GOTO 170
62 END IF
63 CSVOPN = .TRUE.
64
65 END IF
66
67 legend = 'TIME'
68 if (timplt) then
69 n = 1
70 else
71 n = 2
72 end if
73
74 do i = n, ncrv+n-1
75 call tplabv(0, itvid(i), names(itvid(i)), itvne(i), pv,
76 * MAPEL, MAPND)
77 lpv = lenstr(pv)
78 lleg = lenstr(legend)+1
79 if (lleg+lpv-1+2 .gt. maxleg) go to 100
80 legend(lleg:lleg+lpv-1+2) = ', '//pv(:lpv)
81 end do
82 100 continue
83 if (dolegn) then
84 write (ncsv, '(A)') legend(:lenstr(legend))
85 end if
86
87 IF (TIMPLT) THEN
88 IF (NPTS(1) .EQ. MAXPTS) THEN
89 NX = NTPVAR+1
90 ELSE
91 NX = NTPVAR+2
92 END IF
93 ELSE
94 NX = 1
95 END IF
96
97 do itim = 1, npts(1)
98 IF (TIMPLT) THEN
99 NY = 1
100 ELSE
101 NY = 2
102 END IF
103 write (ncsv, 10100) pts(itim, nx),
104 * (pts(itim,nn),nn=ny,ny+ncrv-1)
105 10100 FORMAT (1pe15.7E3,100(', ',1pe15.7E3))
106 end do
107 if (.not. dolegn) then
108 write (*,*) 'The data file contains these data:'
109 write (*, '(A)') legend(:lenstr(legend))
110 else
111 write (*,*) NCRV, ' Curves written to CSV file.'
112 end if
113 write (ncsv,*) ' '
114 170 continue
115 RETURN
116 END