Debian Codegraph @

packages/seacas/libraries/mapvarlib/mvopnfil.f

raw
1 C Copyright(C) 1999-2020, 2022 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 *DECK,OPNFIL
9 SUBROUTINE MVOPNFIL
10
11 C ******************************************************************
12
13 C SUBROUTINE TO OPEN REQUIRED FILES
14
15 C Calls subroutine ERROR
16
17 C Called by MAPVAR
18
19 C ******************************************************************
20
21 CHARACTER*2048 filnam, option, errmsg
22
23 include 'exodusII.inc'
24 include 'ex2tp.blk'
25 include 'ntpdat.blk'
26 include 'tapes.blk'
27 C include 'argparse.inc'
28 integer argument_count
29 external argument_count
30
31 C ******************************************************************
32
33 C .. Get filename from command line. If not specified, emit error message
34 NARG = argument_count()
35 if (narg .eq. 0) then
36 CALL PRTERR ('FATAL', 'Invalid syntax.')
37 CALL PRTERR ('CMDSPEC',
38 * 'Syntax is: "mapvar [-output ofile.o] [-plot result_file.e]'//
39 * ' [-mesh mesh_file.g]')
40 CALL PRTERR ('CMDSPEC',
41 * ' [-interpolated int_file.int] base"')
42 CALL PRTERR ('CMDSPEC',
43 * 'Documentation: https://sandialabs.github.io' //
44 $ '/seacas-docs/sphinx/html/index.html#mapvar')
45 stop 'Syntax Error'
46 end if
47
48 C ... Get 'base' and do default file assignments.
49 CALL get_argument(NARG,FILNAM, LFIL)
50 fntpo = filnam(:lfil) // '.o'
51 fntp2 = filnam(:lfil) // '.e'
52 fntp3 = filnam(:lfil) // '.g'
53 fntp4 = filnam(:lfil) // '.int'
54
55 C ... parse arguments to see if any files set explicitly
56 C All (except for base) should be of the form "-option file"
57 do iarg = 1, narg-1, 2
58 CALL get_argument(iarg, OPTION, LOPT)
59 CALL get_argument(iarg+1,FILNAM, LFIL)
60
61 if (option(1:1) .ne. '-') then
62 errmsg = 'Option "'//OPTION(:LOPT)//
63 * '" does not start with "-"'
64 call prterr('FATAL', errmsg(:lenstr(errmsg)))
65 CALL PRTERR ('CMDSPEC',
66 *'Syntax is: "mapvar [-output ofile.o] [-plot result_file.e]'//
67 *' [-mesh mesh_file.g]')
68 CALL PRTERR ('CMDSPEC',
69 *' [-interpolated int_file.int] base"')
70 CALL PRTERR ('CMDSPEC',
71 * 'Documentation: https://sandialabs.github.io' //
72 $ '/seacas-docs/sphinx/html/index.html#mapvar')
73 stop 'Syntax Error'
74 end if
75
76 if (option .eq. "-output") then
77 fntpo = filnam(:lfil)
78 else if (option .eq. "-plot") then
79 fntp2 = filnam(:lfil)
80 else if (option .eq. "-mesh") then
81 fntp3 = filnam(:lfil)
82 else if (option .eq. "-interpolated") then
83 fntp4 = filnam(:lfil)
84 else
85 errmsg = 'Unrecognized option "'//OPTION(:LOPT)//'"'
86 call prterr('FATAL', errmsg(:lenstr(errmsg)))
87 CALL PRTERR ('CMDSPEC',
88 *'Syntax is: "mapvar [-output ofile.o] [-plot result_file.e]'//
89 *' [-mesh mesh_file.g]')
90 CALL PRTERR ('CMDSPEC',
91 *' [-interpolated int_file.int] base"')
92 CALL PRTERR ('CMDSPEC',
93 * 'Documentation: https://sandialabs.github.io' //
94 $ '/seacas-docs/sphinx/html/index.html#mapvar')
95 stop 'Syntax Error'
96 end if
97 end do
98
99 C OPENING OF INPUT/OUTPUT, SCRATCH AND DATA FILES
100
101 C TEXT OUTPUT FILE
102
103 IFILES(1)=1
104 IUNIT=NTPOUT
105 OPEN (UNIT=NTPOUT, FILE=fntpo(:lenstr(fntpo)), STATUS='unknown',
106 & FORM='formatted', ERR=10)
107
108 C EXODUS DATA FILE - MESH-A (MESH & SOLUTION)
109
110 IFILES(3)=1
111 IUNIT=NTP2
112 icpuws = 0
113 iows1 = 0
114 ntp2ex = exopen(fntp2(:lenstr(fntp2)),EXREAD,icpuws,iows1,
115 * vers,ierr)
116 if (ierr .lt. 0)then
117 WRITE(NOUT,11)IERR,NTP2,fntp2(:lenstr(fntp2)),NTP2EX
118 WRITE(NTPOUT,11)IERR,NTP2,fntp2(:lenstr(fntp2)),NTP2EX
119 GO TO 10
120 end if
121 11 format(' In opnfil - error opening mesh + solution file',/,
122 &' error number ',i5,' tape number ',i5,' filename ',a20,/,
123 &' ntp2ex = ',i5)
124
125 C GENESIS DATA FILE - MESH-B (MESH)
126
127 IFILES(4)=1
128 IUNIT=NTP3
129 icpuws = 0
130 iows2 = 0
131 ntp3ex = exopen(fntp3(:lenstr(fntp3)),EXREAD,icpuws,iows2,
132 * vers,ierr)
133 if (ierr .lt. 0)then
134 WRITE(NOUT,12)IERR,NTP3,fntp3(:lenstr(fntp3)),NTP3EX
135 WRITE(NTPOUT,12)IERR,NTP3,fntp3(:lenstr(fntp3)),NTP3EX
136 GO TO 10
137 end if
138 12 format(' In opnfil - error opening genesis file',/,
139 &' error number ',i5,' tape number ',i5,' filename ',a20,/,
140 &' ntp3ex = ',i5)
141
142 C ... Find the largest name size...
143 namlen2 = exinqi(ntp2ex, EXDBMXUSNM)
144 namlen3 = exinqi(ntp3ex, EXDBMXUSNM)
145
146 namlen = max(namlen2, namlen3)
147
148 C EXODUS DATA FILE - MESH-C (MESH & INTERPOLATED SOLUTION)
149
150 IFILES(5)=1
151 IUNIT=NTP4
152 C ... Set iows for created file to default floating point word size
153 C on this machine (as returned by previous call to exopen)
154 iows3 = icpuws
155 icpuws = 0
156 ntp4ex = excre(fntp4(:lenstr(fntp4)),EXCLOB,icpuws,
157 * iows3,ierr)
158 if (ierr .lt. 0)then
159 WRITE(NOUT,13)IERR,NTP4,fntp4(:lenstr(fntp4)),NTP4EX
160 WRITE(NTPOUT,13)IERR,NTP4,fntp4(:lenstr(fntp4)),NTP4EX
161 GO TO 10
162 end if
163 13 format(' In opnfil - error opening interpolation file',/,
164 &' error number ',i5,' tape number ',i5,' filename ',a20,/,
165 &' ntp4ex = ',i5)
166
167 write (*,*) 'MESH-A (MESH & SOLUTION): ',
168 * fntp2(:lenstr(fntp2))
169 write (*,*) 'MESH-B (MESH): ',
170 * fntp3(:lenstr(fntp3))
171 write (*,*) 'MESH-C (MESH & INTERPOLATED): ',
172 * fntp4(:lenstr(fntp4))
173 write (*,*) 'Text Output: ',
174 * fntpo(:lenstr(fntpo))
175 call exmxnm(ntp2ex, namlen, ierr)
176 call exmxnm(ntp3ex, namlen, ierr)
177 call exmxnm(ntp4ex, namlen, ierr)
178
179 RETURN
180
181 10 CONTINUE
182 CALL ERROR ('OPNFIL','ERROR OPENING FILE','UNIT NUMBER',IUNIT,
183 1' ',0,' ',' ',1)
184 END