Grapher 12 won't recognize my Fortran values as numbers


Fortran outputs numbers like this 0.91576404D+00, where the D designates a double precision number. Grapher 11 and 13 both recognize these values as numeric, but Grapher 12 did not. To use these Fortran numbers in Grapher 12, follow these steps: 

  1. Create a new folder to hold the updated data files.
  2. Copy the script below, or click here to download the BAS file: FindReplace_D.BAS.
  3. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Grapher 12.
  4. Double click on Scripter.exe to launch Scripter.
  5. Press Ctrl+A to select all of the existing lines then press Delete.
  6. If you copied this script, press Ctrl+V to paste it into Scripter. If you downloaded it, click File | Open, select the BAS file from your downloads directory, and click Open.
  7. On line 12, change the file path to the directory containing your data files.
  8. On line 13, change the file path to the new directory you created in step 1.
  9. On line 14, enter the first column that contains Fortran double-precision numbers.
  10. On line 15, enter the last column that contains Fortran double-precision numbers.
  11. On line 18, change "dat" to whatever file extension your data files have.
  12. Click Script | Run to run the script.
  13. If you have GRF files that link to these data files, after the script is done running, move the GRF files to the new folder created in step 1.

Sub Main

'Create Grapher as an Object
Dim Grapher As Object

'Start Grapher
Set Grapher = CreateObject("Grapher.Application")

' User-defined variables
oldDataPath$ = "C:\Users\L\Desktop\OldData\"
newDataPath$ = "C:\Users\L\Desktop\NewData\"
firstcol = 2 'first column that contains the D+ designator
lastcol = 2 'last column that contains the D+ designator

file = Dir(oldDataPath$+"*.dat")

While file <> ""

	'Open the DAT in Grapher's worksheet
	Set Wks = Grapher.Documents.Open(oldDataPath$+file,"")

	'Replace the D+ text with nothing, so the text becomes numeric
	Set WksRange = Wks.Columns(firstcol,lastcol)
	Set Current = Wks.Range("B1")
	Set Current = WksRange.Replace("D+","",Current,wksFindScopeEntire,wksFindPhrase,False,False,True,False)

	'Save the file to the new file location

	'Get the next DAT file in the directory
	file = Dir()


'After the script finishes, move all of the GRF files to the newDataPath$ directory

End Sub


Updated February 1, 2018

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Please sign in to leave a comment.