'============================================================================ ' ContArea.BAS ' calculates the volume and area, saves the results to a file, opens the file ' in the worksheet and reads info about the area calcs. TB 20 DEC 95. ' + Modified to do the area for a series of contours. TB 27 Oct 98. ' + Added prompt with grid zMin and zMax. TB 04 Nov 98. '============================================================================ 'Open Surfer minimized. 'shell ("c:\surfer6\surfer32.exe",2) ' Create the Surfer application object. Set Surf = CreateObject("Surfer.App") 'Variables '--------- 'UpSurf$ 'zMin 'zMax 'zInt 'zValue 'WksHandle 'OutFile$ 'PrevArea 'Xmin 'Xmax 'Ymin 'Ymax 'Zmin 'Zmax 'PosVol 'NegVol 'PosPlanArea 'NegPlanArea 'BlankedPlanArea 'PosSurfArea 'NegSurfArea Top: UpSurf$=InputBox$("Path and GRD file name or value for the 'Upper' Surface",\ "Upper Surface","c:\surfer6\demogrid.grd") if UpSurf$="" then end 'Calculate Volume report to get zMin zMax. Surf.FileNew() Surf.GridVolume(UpGrid=UpSurf$,Lowconstant=0) Surf.FileSaveAs("c:\surfer6\volume.dat") Surf.FileClose() 'Close Volume Report Window Surf.FileClose() 'Close Plot Window. 'Open volume.dat in a worksheet window, store handle number. WksHandle = Surf.FileOpen("c:\surfer6\volume.dat",1) 'Get the min and max Z. Zmin$ = (Surf.GetWksCell(WksHandle,9,1)) 'B-10 Zmax$ = (Surf.GetWksCell(WksHandle,9,3)) 'D-10 Surf.FileClose() 'Close Volume Report Window Surf.FileClose() 'Close Plot Window. cMin = val(InputBox$("Enter minimum Z contour value.", "zMin",Zmin$)) cMax = val(InputBox$ ("Enter maximum Z contour value.","zMax",Zmax$)) cInterval = val(InputBox$("Enter the contour interval.","Contour Interval",\ "5")) if cInterval = 0 then end OutFile$ = InputBox$("Enter output filename for the area report.",\ "Output File", "c:\surfer6\AreaOut.txt") Open OutFile$ for output as #1 PrevArea=0 for cValue = cMin to cMax step cInterval Surf.FileNew() 'Open a plot window to calculate volume. Surf.GridVolume(UpGrid=UpSurf$,Lowconstant=cValue) 'Save to a data file and close volume window. Surf.FileSaveAs("c:\surfer6\volume.dat") Surf.FileClose() 'Close Volume Report Window Surf.FileClose() 'Close Plot Window. 'Open volume.dat in a worksheet window, store handle number. WksHandle = Surf.FileOpen("c:\surfer6\volume.dat",1) 'Get the volumes and areas. Col A=0, Row 1=0. Xmin = val(Surf.GetWksCell(WksHandle,7,1)) 'B-8 Xmax = val(Surf.GetWksCell(WksHandle,7,3)) 'D-8 Ymin = val(Surf.GetWksCell(WksHandle,8,1)) 'B-9 Ymax = val(Surf.GetWksCell(WksHandle,8,3)) 'D-9 Zmin = val(Surf.GetWksCell(WksHandle,9,1)) 'B-10 Zmax = val(Surf.GetWksCell(WksHandle,9,3)) 'D-10 PosVol = Val(Surf.GetWksCell(WksHandle,21,3)) NegVol = Val(Surf.GetWksCell(WksHandle,22,3)) PosPlanArea = Val(Surf.GetWksCell(WksHandle,27,3)) NegPlanArea = Val(Surf.GetWksCell(WksHandle,29,3)) BlankedPlanArea = Val(Surf.GetWksCell(WksHandle,30,3)) PosSurfArea = Val(Surf.GetWksCell(WksHandle,34,3)) NegSurfArea = Val(Surf.GetWksCell(WksHandle,36,3)) ' Print "Xmin = "; Xmin ' Print "Xmax = "; Xmax ' Print "Ymin = "; Ymin ' Print "Ymax = "; Ymax ' Print "Zmin = "; Zmin ' Print "Zmax = "; Zmax ' print ' Print "PosVol = ";PosVol ' Print "NegVol = ";NegVol ' Print "Pos - Neg = "; PosVol-NegVol if cValue = cMin then print "===================================" print " Area Area Area" print "Contour Above Below Between" print " Value Contour Contour Contours" print "------- ------- ------- -------- " print #1, " , Area Area Area" print #1, "Contour Above Below Between" print #1, " Value Contour Contour Contours" print #1, "------- ------ ------ -------- " else print PrevArea - PosPlanArea print #1, PrevArea - PosPlanArea endif print " ";cValue;" ";PosPlanArea;" ";NegPlanArea;" "; print #1, " ";cValue;" ";PosPlanArea;" ";NegPlanArea;" "; PrevArea=PosPlanArea ' Print "PosPlanArea = ";PosPlanArea ' Print "NegPlanArea = ";NegPlanArea ' Print "BlankedPlanArea = ";BlankedPlanArea ' Print "Total Plan Area = ";PosPlanArea + NegPlanArea + BlankedPlanArea ' Print "PosSurfArea = ";PosSurfArea ' Print "NegSurfArea = ";NegSurfArea ' Print "Total Surface Area = "; PosSurfArea + NegSurfArea Surf.FileClose() next print PosPlanArea 'Finish off the last line of the report.