Subroutine to get and write information on command line arguments.
29
30
31 character(len=LINELENGTH) :: tag
32 character(len=LINELENGTH) :: uctag
33 character(len=LENHUGELINE) :: line
34 character(len=LINELENGTH) :: clevel
35 character(len=LINELENGTH) :: cmode
36 character(len=LINELENGTH) :: header
37 character(len=LINELENGTH) :: errmsg
38 character(len=LINELENGTH) :: cexe
39 character(len=LENBIGLINE) :: compiler
40 character(len=20) :: cdate
41 character(len=LENBIGLINE) :: coptions
42 logical :: ltyp
43 logical :: lexist
44 logical :: lstop
45 integer(I4B) :: icountcmd
46 integer(I4B) :: ipos
47 integer(I4B) :: ilen
48 integer(I4B) :: iarg
49
50
51 lstop = .false.
52
53
54 icountcmd = command_argument_count()
55 call get_command_argument(0, cexe)
56 cexe = adjustl(cexe)
57
58
59
60 ipos = index(cexe, '/', back=.true.)
61 if (ipos == 0) then
62 ipos = index(cexe, '\', back=.true.)
63 end if
64 if (ipos == 0) then
65 ipos = 1
66 else
67 ipos = ipos + 1
68 end if
69 cexe = cexe(ipos:)
70
71
72 call get_compile_date(cdate)
73 write (header, '(a,4(1x,a),a)') &
74 trim(adjustl(cexe)), '- MODFLOW', &
75 trim(adjustl(fullversion)), '(compiled', trim(adjustl(cdate)), ')'
76
77
78 do iarg = 1, icountcmd
79 call get_command_argument(iarg, uctag)
80 call upcase(uctag)
81 if (trim(adjustl(uctag)) == '-S' .or. &
82 trim(adjustl(uctag)) == '--SILENT') then
83
84
85 istdout = getunit()
86 open (unit=istdout, file=trim(adjustl(simstdout)))
87
88
89 exit
90 end if
91 end do
92
93
94 iarg = 0
95 do
96
97
98 iarg = iarg + 1
99 if (iarg > icountcmd) then
100 exit
101 end if
102
103
104 call get_command_argument(iarg, tag)
105 uctag = tag
106 call upcase(uctag)
107
108
109 ipos = index(uctag, '-')
110 if (ipos < 1) then
111 cycle
112 end if
113
114
115 clevel = ' '
116 ipos = index(uctag, '--LEVEL=')
117 if (ipos > 0) then
118 ipos = index(tag, '=')
119 ilen = len_trim(tag)
120 clevel = tag(ipos + 1:ilen)
121 call upcase(clevel)
122 uctag = tag(1:ipos - 1)
123 call upcase(uctag)
124 end if
125
126
127 cmode = ' '
128 ipos = index(uctag, '--MODE=')
129 if (ipos > 0) then
130 ipos = index(tag, '=')
131 ilen = len_trim(tag)
132 cmode = tag(ipos + 1:ilen)
133 call upcase(cmode)
134 uctag = tag(1:ipos - 1)
135 call upcase(uctag)
136 end if
137
138
139 select case (trim(adjustl(uctag)))
140 case ('-H', '-?', '--HELP')
141 lstop = .true.
142 call write_usage(trim(adjustl(header)), trim(adjustl(cexe)))
143 case ('-V', '--VERSION')
144 lstop = .true.
145 write (line, '(2a,2(1x,a))') &
146 trim(adjustl(cexe)), ':', trim(adjustl(version))
147 call write_message_counter(line, skipbefore=1, skipafter=1)
148 case ('-DEV', '--DEVELOP')
149 lstop = .true.
150 write (line, '(2a,g0)') &
151 trim(adjustl(cexe)), ': develop version ', ltyp
152 call write_message_counter(line, skipbefore=1, skipafter=1)
153 case ('-C', '--COMPILER')
154 lstop = .true.
155 call get_compiler(compiler)
156 write (line, '(2a,1x,a)') &
157 trim(adjustl(cexe)), ':', trim(adjustl(compiler))
158 call write_message_counter(line, skipbefore=1, skipafter=1)
159 case ('-S', '--SILENT')
160 write (line, '(2a,1x,a)') &
161 trim(adjustl(cexe)), ':', 'all screen output sent to mfsim.stdout'
162 call write_message_counter(line, skipbefore=1, skipafter=1)
163 case ('-D', '--DISCLAIMER')
164 lstop = .true.
165 call write_message('', fmt=fmtdisclaimer)
166 case ('-P', '--PARALLEL')
167 simulation_mode = 'PARALLEL'
168 case ('-LIC', '--LICENSE')
169 lstop = .true.
170 call write_license()
171 case ('-CO', '--COMPILER-OPT')
172 lstop = .true.
173 call get_compile_options(coptions)
174 call write_message_counter(coptions, skipbefore=1, skipafter=1)
175 case ('-L', '--LEVEL')
176 if (len_trim(clevel) < 1) then
177 iarg = iarg + 1
178 call get_command_argument(iarg, clevel)
179 call upcase(clevel)
180 end if
181 select case (trim(adjustl(clevel)))
182 case ('SUMMARY')
183 isim_level = vsummary
184 case ('DEBUG')
185 isim_level = vdebug
186 case default
187 call write_usage(trim(adjustl(header)), trim(adjustl(cexe)))
188 write (errmsg, '(2a,1x,a)') &
189 trim(adjustl(cexe)), ': illegal STDOUT level option -', &
190 trim(adjustl(clevel))
191 call store_error(errmsg)
192 end select
193
194
195 write (line, '(2a,2(1x,a))') &
196 trim(adjustl(cexe)), ':', 'stdout output level', &
197 trim(adjustl(clevel))
198 call write_message_counter(line, skipbefore=1, skipafter=1)
199 case ('-M', '--MODE')
200 if (len_trim(cmode) < 1) then
201 iarg = iarg + 1
202 call get_command_argument(iarg, cmode)
203 call upcase(cmode)
204 end if
205 select case (trim(adjustl(cmode)))
206 case ('VALIDATE')
207 isim_mode = mvalidate
208 case default
209 call write_usage(trim(adjustl(header)), trim(adjustl(cexe)))
210 errmsg = trim(adjustl(cexe))//': illegal MODFLOW 6 '// &
211 'simulation mode option - '//trim(adjustl(cmode))
212 call store_error(errmsg, terminate=.true.)
213 end select
214
215
216 line = trim(adjustl(cexe))//': MODFLOW 6 simulation mode '// &
217 trim(adjustl(cmode))//'. Model input will be checked for all '// &
218 'stress periods but the matrix equations will not be '// &
219 'assembled or solved.'
220 call write_message_counter(line, skipbefore=1, skipafter=1)
221 case default
222 lstop = .true.
223 call write_usage(trim(adjustl(header)), trim(adjustl(cexe)))
224 write (errmsg, '(2a,1x,a)') &
225 trim(adjustl(cexe)), ': illegal option -', trim(adjustl(tag))
226 call store_error(errmsg, terminate=.true.)
227 end select
228 end do
229
230
231 if (.not. lstop) then
232 inquire (file=trim(adjustl(simfile)), exist=lexist)
233 if (.NOT. lexist) then
234 lstop = .true.
235 write (errmsg, '(2a,2(1x,a))') &
236 trim(adjustl(cexe)), ':', trim(adjustl(simfile)), &
237 'is not present in working directory.'
238 call store_error(errmsg, terminate=.true.)
239 end if
240 end if
241
242
243 if (lstop) then
244 call ustop()
245 end if
246
247
248 if (icountcmd > 0) then
249 call write_message('')
250 end if