@@ -244,22 +244,17 @@ subroutine add_plot(me,x,y,label,linestyle,markersize,linewidth)
244
244
character (len=* ),parameter :: yname = ' y' !
245
245
246
246
! convert the arrays to strings:
247
- call vec_to_string(x,xstr)
248
- call vec_to_string(y,ystr)
247
+ call vec_to_string(x,xstr,me % use_numpy )
248
+ call vec_to_string(y,ystr,me % use_numpy )
249
249
250
250
! get optional inputs (if not present, set default value):
251
251
call optional_int_to_string(markersize,imark,' 3' )
252
252
call optional_int_to_string(linewidth, iline,' 3' )
253
253
254
254
! write the arrays:
255
255
call me% add_str(' ' )
256
- if (me% use_numpy) then
257
- call me% add_str(trim (xname)// ' = np.array(' // xstr// ' )' )
258
- call me% add_str(trim (yname)// ' = np.array(' // ystr// ' )' )
259
- else
260
- call me% add_str(trim (xname)// ' = ' // xstr)
261
- call me% add_str(trim (yname)// ' = ' // ystr)
262
- end if
256
+ call me% add_str(trim (xname)// ' = ' // xstr)
257
+ call me% add_str(trim (yname)// ' = ' // ystr)
263
258
264
259
! write the plot statement:
265
260
call me% add_str(' ax.plot(' // &
@@ -303,24 +298,17 @@ subroutine add_bar(me,left,height,label,width,bottom)
303
298
character (len=* ),parameter :: bname = ' b' !
304
299
305
300
! convert the arrays to strings:
306
- call vec_to_string(left,xstr)
307
- call vec_to_string(height,ystr)
308
- if (present (width)) call vec_to_string(width,wstr)
309
- if (present (bottom)) call vec_to_string(bottom,bstr)
301
+ call vec_to_string(left,xstr, me % use_numpy )
302
+ call vec_to_string(height,ystr,me % use_numpy )
303
+ if (present (width)) call vec_to_string(width,wstr, me % use_numpy )
304
+ if (present (bottom)) call vec_to_string(bottom,bstr,me % use_numpy )
310
305
311
306
! write the arrays:
312
307
call me% add_str(' ' )
313
- if (me% use_numpy) then
314
- call me% add_str(trim (xname)// ' = np.array(' // xstr// ' )' )
315
- call me% add_str(trim (yname)// ' = np.array(' // ystr// ' )' )
316
- if (present (width)) call me% add_str(trim (wname)// ' = np.array(' // wstr// ' )' )
317
- if (present (bottom)) call me% add_str(trim (bname)// ' = np.array(' // bstr// ' )' )
318
- else
319
- call me% add_str(trim (xname)// ' = ' // xstr)
320
- call me% add_str(trim (yname)// ' = ' // ystr)
321
- if (present (width)) call me% add_str(trim (wname)// ' = ' // wstr)
322
- if (present (bottom)) call me% add_str(trim (bname)// ' = ' // bstr)
323
- end if
308
+ call me% add_str(trim (xname)// ' = ' // xstr)
309
+ call me% add_str(trim (yname)// ' = ' // ystr)
310
+ if (present (width)) call me% add_str(trim (wname)// ' = ' // wstr)
311
+ if (present (bottom)) call me% add_str(trim (bname)// ' = ' // bstr)
324
312
325
313
! create the plot string:
326
314
plt_str = ' ax.bar(' // &
@@ -380,12 +368,13 @@ end subroutine optional_int_to_string
380
368
!
381
369
! SOURCE
382
370
383
- subroutine vec_to_string (v ,str )
371
+ subroutine vec_to_string (v ,str , use_numpy )
384
372
385
373
implicit none
386
374
387
375
real (wp),dimension (:),intent (in ) :: v
388
376
character (len= :),allocatable ,intent (out ) :: str
377
+ logical ,intent (in ) :: use_numpy
389
378
390
379
integer :: i,istat
391
380
character (len=* ),parameter :: fmt = ' (E30.16)' ! real number format string
@@ -400,6 +389,9 @@ subroutine vec_to_string(v,str)
400
389
end do
401
390
str = str // ' ]'
402
391
392
+ ! convert to numpy array if necessary:
393
+ if (use_numpy) str = ' np.array(' // str// ' )'
394
+
403
395
end subroutine vec_to_string
404
396
! *****************************************************************************************
405
397
0 commit comments