magpros: an interactive fortran-77 pc program for magnetic data processing

37
Pergamon Computers & Geosciences Vol. 20, No. 5, pp. 681-717, 1994 Copyright© 1994 ElsevierScience Ltd 0098-3004(94)E0002-B Printed in Great Britain.All rights reserved 0098-3004/94 $7.00+ 0.00 MAGPROS: AN INTERACTIVE FORTRAN-77 PC PROGRAM FOR MAGNETIC DATA PROCESSING B. NARASIMHA RAO and P. RAMAKRISHNA Exploration Geophysics Group, Atomic Minerals Division, Department of Atomic Energy, Hyderabad-500 016, India (Received 6 July 1992; accepted 13 July 1993) Abstract--A FORTRAN program is presented to process magnetic data using the Hartley Transform. The subroutines for editing the data, display/printer or drive options with the optimal queries make the package completely user friendly and interactive. MAGPROS is tested for synthetically generated data and applied to field examples. Key Words: Magnetic data, Hartley Transform, Continuation, Gradients, Reduction to pole. INTRODUCTION Spatial derivatives and the components of a measured magnetic field usually are considered while processing magnetic data. It is normal practice to compute all of them rather than actual measurements because of time and cost constraints. Data in the space domain are transformed into the frequency domain through the well-known discrete Fourier Transform (FT) and manipulated for conversion of the magnetic fields, up or downward continu- ations, reduction to pole, analytic signal analyses, and other processes (Baranov, 1957; Bhattacharya, 1965; Nabighian, 1972; Green and Stanley, 1975; Atchuta Rao, Rambabu, and Shanker Narayan, 1981). The computer programs MAGTRAN (Rambabu and others, 1989) and FREDPACK (Bezvoda, Jezek, and Segeth, 1990) were developed subsequently for mainframe computers to efficiently process magnetic data. MAGPROS---a computer program for processing the magnetic data using the Hartley Transform (HT), rather than the conventional FT is proposed as a solution to computational time and cost constraints. The HT is computationally faster than the fast FT (Bracewell, 1986). MAGPROS is executable directly on any personal computer and is written in a user- friendly, interactive mode so that even a novice easily can learn to use it. In the following subsections, we first derive the mathematical formulae to process the magnetic data in the frequency domain using the FT. The relation- ship of the HT and FT then is explained. THEORY Let F(x) represent the magnetic anomaly resulting from a two-dimensional (2-D) dike of great depth extent (Fig. 1, the nomenclature of the parameters is given in Appendix 1). Following Gay (1963), F(x) = CF[((pl -- (P2)COS OF+ sin Orlog(r I/r2)] (1) where Cr and 0F are amplitude and shape parameters respectively. The computed anomaly is shown in Figure lB. The FT of F(x) is given by f, F (o)) = F (x)e -j,oxdx -ct = f F(x)(cos cox -j sin cox) dx = Re[F(og)] + Im[F(og)]. (2) Upward/downward continuation The up or downward continued field of the magnetic anomaly to any arbitrary level (+h) above (negative 'h') or below (positive 'h') the plane of measurement has a direct relation to the FT of F(x): Ffh(og) = F(O9)C :°~. (3) Conversion of magnetic fields The interrelationship of the magnetic fields (AT, AZ, and AH) for different input and output fields CAOEO 20f5--B 68 1

Upload: b-narasimha-rao

Post on 25-Aug-2016

238 views

Category:

Documents


8 download

TRANSCRIPT

Page 1: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

Pergamon

Computers & Geosciences Vol. 20, No. 5, pp. 681-717, 1994 Copyright © 1994 Elsevier Science Ltd

0098-3004(94)E0002-B Printed in Great Britain. All rights reserved 0098-3004/94 $7.00 + 0.00

MAGPROS: AN INTERACTIVE FORTRAN-77 PC P R O G R A M FOR MAGNETIC

DATA PROCESSING

B. NARASIMHA RAO and P. RAMA KRISHNA Exploration Geophysics Group, Atomic Minerals Division, Department of Atomic Energy,

Hyderabad-500 016, India

(Received 6 July 1992; accepted 13 July 1993)

Abstract--A FORTRAN program is presented to process magnetic data using the Hartley Transform. The subroutines for editing the data, display/printer or drive options with the optimal queries make the package completely user friendly and interactive. MAGPROS is tested for synthetically generated data and applied to field examples.

Key Words: Magnetic data, Hartley Transform, Continuation, Gradients, Reduction to pole.

INTRODUCTION

Spatial derivatives and the components of a measured magnetic field usually are considered while processing magnetic data. It is normal practice to compute all of them rather than actual measurements because of time and cost constraints. Data in the space domain are transformed into the frequency domain through the well-known discrete Fourier Transform (FT) and manipulated for conversion of the magnetic fields, up or downward continu- ations, reduction to pole, analytic signal analyses, and other processes (Baranov, 1957; Bhattacharya, 1965; Nabighian, 1972; Green and Stanley, 1975; Atchuta Rao, Rambabu, and Shanker Narayan, 1981). The computer programs MAGTRAN (Rambabu and others, 1989) and FREDPACK (Bezvoda, Jezek, and Segeth, 1990) were developed subsequently for mainframe computers to efficiently process magnetic data.

MAGPROS---a computer program for processing the magnetic data using the Hartley Transform (HT), rather than the conventional FT is proposed as a solution to computational time and cost constraints. The HT is computationally faster than the fast FT (Bracewell, 1986). MAGPROS is executable directly on any personal computer and is written in a user- friendly, interactive mode so that even a novice easily can learn to use it.

In the following subsections, we first derive the mathematical formulae to process the magnetic data in the frequency domain using the FT. The relation- ship of the HT and FT then is explained.

THEORY

Let F(x) represent the magnetic anomaly resulting from a two-dimensional (2-D) dike of great depth extent (Fig. 1, the nomenclature of the parameters is given in Appendix 1). Following Gay (1963),

F(x) = C F [ ( ( p l - - ( P 2 ) C O S OF+ sin Orlog(r I/r2) ] (1)

where Cr and 0F are amplitude and shape parameters respectively. The computed anomaly is shown in Figure lB.

The FT of F(x) is given by

f, F (o)) = F (x)e -j,ox dx -c t

= f F(x)(cos cox - j sin cox) dx

= Re[F(og)] + Im[F(og)]. (2)

Upward/downward continuation

The up or downward continued field of the magnetic anomaly to any arbitrary level ( + h ) above (negative 'h ') or below (positive 'h ') the plane of measurement has a direct relation to the FT of F(x):

Ffh(og) = F(O9)C :°~. (3)

Conversion of magnetic fields

The interrelationship of the magnetic fields (AT, AZ, and AH) for different input and output fields

CAOEO 20f5--B 68 1

Page 2: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

682 B. NARASIMHA RAO and P. RAMA KRISHNA

are listed:

INPUT FIELD Total field, AT

Vertical component, AZ

Horizontal component, AH

OUTPUT FIELD AZ = {AT sin I ' - ~ ( A T ) c o s / '}sin / ' / s in I AH = {~(AT)s in I ' + AT cos I '}cos l ' / cos I AT = ~e(AZ )sin a cos I + AZ sin 1 AH = ~ ( A Z )sin ct AZ = - ~¢~(AH)/sin ~t A T = AH cos I - o~t~(AH )sin //sin ct

~ ( ) is an operator representing the Hilbert Trans- form of a real function defined as the inverse FT of the product of signum (e)) and the FT of the function with appropriate changes in the real and imaginary terms (Whalen, 1971, p. 62).

Frequency analysis

The amplitude and phase spectra of F(~o), used in evaluating the source parameters (e.g. Sengupta, 1975) can be obtained from the real and imaginary parts of the FT of F(x) :

Amplitude = x/[Re2(~o) + Im2(co)] (4)

Phase = a rc tan [ - Im(co)/Re (~o)]. (5)

The basement relief of subsurface layers can be derived from the slopes of the amplitude spectra plots, with or without overlapping data lengths (Mishra and Naidu, 1974; Spector and Grant, 1970).

Analytical signal analyses

The concept of the analytic signal was derived from communications theory and introduced by Whalen (1971) as a useful tool in estimating body parameters (Atchuta Rao, Rambabu, and Shanker Narayan, 1981; Green and Stanley, 1975) and computing the depths to a causative source using gradients (Nabighian, 1972). The FT of the vertical, F z (x), and horizontal, F~(x), gradients of the magnetic field are related to F(og) as

F~(tn) = -coF(og) (6)

Fx(e~ ) = jogr (¢o). (7)

The inverse FT of F~(~o) and Fx(e~ ) yields the gradi- ents in the space domain. The amplitude and phase of the analytical signal are obtained from

Amp(x) = ~/ [ r2(x) + F2(x)] (8)

Phs(x) = a rc tan[ - E~ (x)/F: (x)]. (9)

PLAN VIEW

M.N

A

nT 2 5 -

20

ts

lo J

o --

-5 - 6 0 0

S60"E

a = 50m z = lOOm G -- &5" I : 30 ° = = 30" K : 0.001c9t

w | t ! |

-~00 -2h , 200 ~;o

X--~

Z ~, 3-

B

T'

I m l ' r u )

' 6 0 0 N 6 0 " W

SECTION

ii

Figure 1. A--plan view of 2-D dike; B--geometry of dike with computed anomaly, for parameters listed in inset.

Page 3: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

Magnetic data processing with MAGPROS 683

First and second vertical derivatives

The first- or second-order vertical derivatives, sharply outline the smaller and subtle features obscured by broad regional wave lengths. The first vertical derivatives may be used in combination with horizontal derivatives (Bhattacharya, 1965). The second vertical derivative of the magnetic field F(x) can be computed from

F=(x) *-~ Inv FT co 2F(w) (10)

where ~ signifies the Fourier pair.

Reduction to pole

Reduction to a pole (Baranov and Naudy, 1964) converts the magnetic anomalies recorded in areas of intermediate magnetic inclinations to pseudovalues approximating measurements collected at the poles. The differential gradient method (Nabighian, 1972), wherein the horizontal gradient of the field reduces to a pole (RTPx) is obtained from Fz(x ) and Fx(x ) of the field itself after suitable modifications for the nature of the measured component:

RTPx = cos flFx(x ) + sin flF~(x) (11)

where

fl = 180 - 21' for ATanomaly

= 90 - I ' for AZ or AH anomaly.

The original field profile reduced to the pole is the integration of (11) over x, or

= [ (cos fl Fx(X) + sin fl Fx(x)) dx. (12) F(x)lpole 3

RELATION BETWEEN FOURIER AND HARTLEY TRANSFORMS

The exponential kernel of the Fourier intergral [Eq. (2)] is replaced in the Hartley Transform by

cas (ogx) = cos(tox) + sin(cox). (13)

Thus, given a real function f ( z ) for ~ = 0, 1 , 2 . . . N - 1 , the discrete Hartley Transform (DHT), H(v), as defined by Bracewell (1984), is

N - I

H(v) = 1/N ~ f (z)cas (2n/zz/N) ~ 0

v =0 , 1,2 . . . . ( N - - l ) (14)

and the inverse relation is N - I

f ( z ) = ~ H(v)cas(2nvz/N) v = 0

z = 0 , 1 , 2 . . . . ( N - - l). (15)

We see that the DHT is real. To get the discrete Fourier Transform (DFT) from DHT and separate the Hartley Transform into its 'even' and 'odd' parts, we may write,

H (v) = E(v) + 0 (v) (16)

where

and

E(v) = [H(v) + H ( N - v)]/2

O(v) = [H(v) - H ( N - v)]/2.

Then the DFT is given by

F(v) = E(v) - j O (v). (17)

Similarly, using real and imaginary parts of DFT

H(v) = Re[r (~) ] - Im[F(~o)l. (18)

That is, each complex multiplication of the FT which requires four real multiplications, is accomplished by simple reflection and additions in HT. Thus, it is possible to improve computational efficiency by using the HT in magnetic data processing. Because the properties of the HT are almost the same as those of the FT for the derivatives and Hilbert Transforms (Saatcilar, Ergintav, and Canitez, 1990), Equations (2)-(10) are substituted in MAGPROS to replace the DFT codes with DHT codes.

SCHEME OF COMPUTER PROGRAM

MAGPROS consists of independent subroutines performing various steps of processing (Fig. 2).

The package is written in FORTRAN 77, (Micro- soft ~ FORTRAN, Ver. 5.0) for any personal com- puter. The main program MAGPROS displays the menu and by selecting either the first letter of the option or the serial number, the subroutine SELECT invokes the appropriate subroutine. Sub- routine DATAIN creates a new file for the manually keyed data. Various HELP subroutines--HUP, HHAR, HMAG, HGRAD, HRTP, HDERV are included for the data formats and are accessible by typing HELP. The same data may be reused for any other option of the menu, by creating a new data file through DATAIN.

Subroutine CLS(LT) selects the display opt ion-- screen or printer or drive for the output. After a processing operation is executed, the control returns to MAGPROS.

Subroutine CONT continues the field data to any number of levels (LVL) for the corresponding heights/depths H(I) independent of the station spac- ing (DX) following Equation (3).

Computation of the magnetic field components is achieved through M A G F L D using the Hilbert Transform (HILBRT). The output field data are smoothed as an option, using a simple Hanning filter (Subroutine SMOOT).

The amplitude, phase, and In(Amplitude) spectra of the input data are computed from (4) and (5) through HARMO. For the given data length, the selection of a window length (number of data points only) and percentage of overlapping (in terms of percent of the window length) is optional. This subroutine has an option for calling another routine

Page 4: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

4:~

I. UP

WAR

D /

DOW

NWAR

D CO

NTIN

UATI

ON

2. C

ON

VER

SIO

N O

F FE

LO C

OM

PONE

NTS

3. I l

REG

UEN

CY

ANAL

YSES

/..

AN

ALY

TIC

AL

SIG

NAL

AN

ALYS

ES

it i

S.R

EOU

CTI

ON

TO

PO

LE

6. D

ERIV

ATIV

ES |

1st

/, 2

rid)

7. E

XIT

,1

i •

. I1

0A,.

II -~

YEs

~s

II .7

II

f •

,ib

f -

NO

7:

0 .m

~e

Fig

ure

2. B

lock

dia

gram

rep

rese

ntin

g sc

hem

e of

com

pute

r pr

ogra

m.

Page 5: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

Magnetic data processing with MAGPROS 685

2S

20

15

5 0

-5

HEORE"CALLo.PUTE o \ US.O'MAO ROS•

1 1 I ; I I I [ J I 1 1 I -600 -~00 -200 0 200 ~00 600

0"201"- h t ~" THEORETICAL

0.10 ~-

0.0S

~ -o.os~ -0.10[-- "0-15 L -0.20 ~-

-o.25-- l I I I I -600 -tOO -200 0 200 400 600

XIO "]

3.5 .JI

3.0 I ~ TRANSFORM Tzz 2.5 ITzz 2.0 1.5 1.0

-o.S f ~ -1,o

-1.5 ~ 1 -2.o I I I I J I

- 600 -z, O0 -200 200 4.00 600

O--oTHEORETICALLY COMPUTEO T~ COMPUTED THROUGH HARTELY

60

5O

z,0

30

~ 2o lo o

- lO

-20

• COMPUTEO FROM'MAGPROS' FOR 1:30" x )( THEORETICAL

• ,~ a : 50m

, - , - . - / \ 6 : 4s" / \ ,, = 90- g,

/

-600 -400 -200 0 200 ~*00 600

Figure 3. Synthetic profiles, both computed and theoretical: A--upward continuation; l~-horizontal and vertical gradients; C--2nd vertical gradients; D~reduction to pole.

PLOT. This facilitates displaying the 'local spectra' computed for the given set of data on the screen with the frequency on the x-axis and the corres- ponding in(Amplitude) on the y-axis. The depths to the magnetics layers are computed from the linear regression of the low-, intermediate-, and high-frequency components of the spectra and their inverse slopes using subroutine REGR. Sub- routine TIMDIFF computes the total time taken for computation and is displayed at the end of execution.

The horizontal and vertical gradients of the input field are obtained from GRAD. The amplitude and phase of the analytical signal [Eqs. (8) and (9)] also are printed. If selected, smoothing is done initially for derivatives while calculating the amplitudes.

Subroutine DERV yields the first and second verti- cal derivatives which can be smoothed if needed.

The reduction to the pole of the observed field anomalies is accomplished by using Equation (12) from the subroutine RTP. The 'base level' of the output values is regarded as zero.

Subroutine DHT1D computes the discrete Hartley Transform for options l~i.

It is noteworthy to mention that in all these calculations of horizontal/vertical gradients, or first, second vertical derivatives, conversion of magnetic fields and up/downward continuations, the result is reckoned to the point of the observation whereas in

reduction to a pole it is offset by one-half the station spacing.

The complete listing of the program is presented in Appendix 2.

THEORETICAL EXAMPLES

The total magnetic anomaly (AT) for a dike with geometry as shown in Figure IB, is continued up to 100m using MAGPROS and compared with the theoretically computed results (Fig. 3A).

Similarly, the vertical and horizontal gradients (AT z and ATx) are compared with the computed values (Fig. 3B). The 2nd vertical derivatives of AT are shown in Figure 3C. The reduced to a pole profiles (Fig. 3D), both theoretical and computed, show an unequivocal correlation with each other except at the edges.

FIELD EXAMPLES

Two examples are selected for testing the efficacy of MAGPROS. The measured AH anomaly obtained across a sulphide vein (Parasnis, 1979) is converted to AZ through MAGPROS and compared with observed AZ values (Fig. 4A). The horizontal and vertical gradients and the reduction to pole data for the ATfiold (Nabighian, 1972) are computed and are shown in Figure 4B.

Page 6: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

686 B. NARASlMHA RAO and P. RAMA KRISHNA

1200- nT

800

400

South 0

-400

/ , / ~ AZ (OBSERVED)

,.\

[ I I I I I ~ I I I I I

' ~0 120m

S~ ' ~ '~" ~ " ~

" I N / / ~ - - - " & H (ORIGINAL)

A

North"

2300

2100

South 1900 o ' 40b0 ' e6oo ' t2h~o tS60oFo;,t

2oo- /"X.

1DO .1 "x. Fl.o nr lm / r \ "-.,. /

. J " ! i ,"-ATz "~ . 1-

~ - - . , " . ,'1 ~, . L ,___.~"~. 0

B

North

Figure 4. Field examples: A--observed AZ and computed AZ from AH (Parasnis, 1979, p. 55) across sulphide body near Lam (Bavarian forest); B---observed AT (Nabighian, 1972) and computed A:E~, ATe,

and RTP profiles,

CONCLUSIONS

M A G P R O S is a user-friendly interactive computer program executable directly on any PC. The Discrete Hartley Transform used in the package M A G P R O S minimizes the CPU time and occupies less memory compared to the FT and thus provides ample work- ing space.

Acknowledgments--The authors thank the Director, Atomic Minerals Division (AMD), Department of Atomic Energy, Hyderabad for permission to publish this work. We also thank Messrs S. V. Krishna Rao and J. R. Subba Rao of the Exploration Geophysics Group, Atomic Minerals Division, Hyderabad for their inspiration to develop the package. Also, the Centre of Exploration Geophysics, Osmania University, Hyderabad and Geological Survey of India, Hyderabad are gratefully thanked for thoroughly testing the program.

REFERENCES

Atchuta Rao, D., Rambabu, H. V., and Shanker Narayan, P. V., 1981, Interpretation of magnetic anomalies due to dykes: the complex gradient method: Geophysics, v. 46, no. 11, p. 1572-1578.

Baranov, V., 1957, A new method for interpretation of aeromagnetic maps: Geophysics, v. 22, no. 2, p. 359-383.

Baranov. V., and Naudy, H., 1964, Numerical calculation of the formula of reduction to magnetic pole: Geophysics, v. 29, no. 1, p. 67-69.

Bezvoda, V., Jezek, J., and Segeth, K., 1990, FREDPACK-- a program package for linear filtering in the fre- quency domain: Computers & Geosciences, v. 16, no. 8, p. 1123-1154.

Bhattacharya, B. K., 1965, Two dimensional harmonic analysis as a tool for magnetic interpretation: Geophysics, v. 30, no, 5, p. 829-857.

Bracewell, R. N., 1984, The fast Hartley Transform: Proc. IEEE, v. 72, p.1010-1018.

Bracewell, g. N., 1986, The Fourier Transform and its applications: McGraw-Hill Book Co., New York, 474 p.

Page 7: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

Magnetic data processing with MAGPR OS 687

Gay, P. S., 1963, Standard curves for interpretation of magnetic anomalies over tabular bodies: Geophysics, v. 28, no. 2, p. 161-200.

Green R., and Stanley, J. M., 1975, Application of Hilbert Transform to the interpretation of surface vehicle mag- netic data: Geophysical Prospecting, v. 23, no. 1, p. 18-27.

Mishra, D. C., and Naidu, P. S., 1974, Two dimensional power spectral analysis of aeromagnetic fields: Geophys- ical Prospecting, v. 22, no. 2, p. 345-353.

Nabighain, M. N., 1972, The analytic signal of two dimen- sional magnetic bodies with polygonal cross-sections: its properties and use for automated anomaly interpret- ation: Geophysics, v. 37, no. 3, p. 507-517.

Parasnis, D. S., 1979, Principles of applied geophysics (3rd ed.): Chapman & Hall, London, 275 p.

Rambabu, H. V., Atchuta Rao, D., Venkata Raju, Ch., and Vijaya Kumar, V., 1989, M A G T A R N : a computer program for the transformation of magnetic and gravity anomalies: Computers & Geosciences, v. 15, no. 6, p. 979-988.

Saatcilar, R., Erglntav, S., and Canitez, N., 1990, The use of the Hartley Transform in geophysical applications: Geophysics, v. 55, no. I1, p. 1488-1495.

Sengupta, S., 1975, Interpretation of magnetic anomalies of two dimensional fault by Fourier fault by Fourier Integral: Jour. Can. Soc. Expl. Geophysicists, v. 1 I, no. 1, p. 65-71.

Spector, A., and Grant , F. S., 1970, Statistical models for interpreting aeromagnetic data: Geophysics, v. 35, no. 2, p. 293-302.

Whelan, A. D., 1971, Detection of signals in noise: Academic Press, New York, 411 p.

APPENDIX 1

The nomenclature of the parameters used in the text, with reference to Figure 1 and to Equations (1)-(18) are:

~Pl = arctan[(x + a)/z]

¢p = a r c t a n [ x - a)/z ]

r t = ~/[(x + a) 2 + z 2]

r 2 = ~ / [ ( x - - a) 2 -4- 2 2]

Cr = 2kT ' sin 6 s in / / s in I ' for total field (At)

= 2kT ' sin 6 for vertical field (AZ)

= 2kT" sin 6 sin • for horizontal field (AH)

Or= 21' - 6 - Ir/2 for At

= 1 " - 0 for AZ

= I ' - 6 - 7r/2 for AH

where

T = ambient magnetic field k = susceptibility contrast I = inclination of the magnetic field in degrees

= angle of strike with magnetic North over East I ' = arctan (tanI/sin u)

T ' = T s i n / / s i n I ' Fx(x ) = horizontal gradient Fz(x ) = vertical gradient H(v) = Hartley Transform of F(x) or f ( z ) F(oJ) = Fourier Transform of F(x).

Appendix 2 overleaf

Page 8: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

688 B. NARASlMHA RAO and P. RAMA KRISHNA

APPENDIX 2

********************************************************************

* MAGPROS : M a g n e t i c d a t a P r o c e s s i n g *

* C o m p u t e r p r o g r a m m e i n MICROSOFT FORTRAN-77 * * V e r s i o n 5 . 0 *

* A u t h o r s : B . N a r a s i m h a Rao a n d P . R a m a K r i s b n a *

* E x p l o r a t i o n G e o p h y s i c s G r o u p * * Atomic Minerals Division * * Department of Atomic Energy * * Begumpet, H y d e r a b a d - 5 0 0 016 * * I N D I A *

* Nomenclature of the variables used. *

* INCL : Inclination of the magnetic field in degrees. * * ALPHA : Angle subtended by strike of the formation with * * magnetic North measured to the East. * * DIN : Nature of input field data. * * DH - Horizontal component * * DZ - Vertical component * * DT - Total component * * DOUT : N a t u r e o f o u t p u t f i e l d * * LVL : N u m b e r o f l e v e l s t o c o n t i n u e u p / d o w n i n i n t e g e r * * numbers (i). * * H(i) : Height /depth o f continuation. * * INFILE : Input data file name * * PROF : Name of the traverse * ~ N : N o . o f d a t a p o i n t s u p t o m a x . 250 * * DX : Station spacing * * CHOICE : Selection the processing technique from menu *

* ( Units in CGS/MKS/FPS ) *

* Supporting subroutines :- CLEAR,CLS,SELECT,CONT,MAGFLD * * HARMO,RTP,DERV,GRAD,DHTID * * SMOOTH,HILBRT,DATAIN,TIMDIFF * * HUP,HMAG,HHAR,HRTP,HDERV,HGRAD *

* T h i s m a i n p r o g r a m i s f o r d i s p l a y o f ' m e n u ' a n d o n c h o i c e i t * * c a l l s t h e c o r r e s p o n d i n g s u b r o u t i n e t h r o u g h SELECT. A f t e r * * o b t a i n i n g t h e d e s i r e d o u t p u t t h e u s e r may u s e t h e s a m e d a t a * * f o r o t h e r c h o i c e s . You m a y i n p u t t h e d a t a t h r o u g h k e y b o a r d * * f o r a n e w f i l e o r g e t a l r e a d y e x i s t i n g d a t a f r o m a f l o p p y * * d r i v e A o r B. F o r d a t a f o r m a t t y p e ' H E L P ' w h e n a s k e d f o r . *

* PROGRAM MAGPROS INCLUDE ' F G R A P H . F I ' INCLUDE ' F G R A P H . F D ' RECORD / r c c o o r d / c u r p o s INTEGER*2 r o w s , c o l s CHARACTER*I CHOICE I T S = 0 r o w s = 2 5 cols=80 CALL clearscreen($GCLEARSCREEN) CALL settextposition(8,23,curpos) WRITE(*,'(A\)')' MAGPROS : A complete package for ' CALL settextposition(9,22,curpos) WRITE(*,'(A\)')' processing magnetic data.'

Page 9: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

5000

I00

900

Magnetic data processing with MAGPROS

CALL settextposition(10,22,curpos) WRITEq *, (A\)') ................................... CALL settextposition(ll,22,curpos) WRITEq*, (A\)') Developed at ' CALL settextposition(13,22,curpos) WRITE~*, (A\)') EXPLORATION GEOPHYSICS GROUP' CALL settextposition(14,22,curpos) WRITE *, (A\)') ATOMIC MINERALS DIVISION ' CALL settextposition(15,22,eurpos) WRITE *, (A\)') DEPARTMENT OF ATOMIC ENERGY' CALL settextposition(16,22,curpos) WRITE *, (A\)') HYDERABAD-500 016' CALL settextposition(17,22,curpos) WRITE *, (A\)') INDIA.' DO I= ,5 WRITE(*,*)CHAR(7) ENDDO PAUSE ' Hit enter key to continue' CONTINUE CALL clearscreen($GCLEARSCREEN) CALL settextposition(l,l,curpos) WRITE(* ,* ) WRITE(* ,* ) WRITE(*,*) WRITE(*,*) WRITE(* ,* ) WRITE(*,*) WRITE(*,*) 1. WRITE(*,*) 2. WRITE(*,*) WRITE(*,*)' 3. W R I T E ( * , * ) ' 4 . WRITE(*,*)' 5. W R I T E ( * , * ) ' 6. W R I T E ( * , * ) ' 7. W R I T E ( * , * ) ' W R I T E ( * , * ) ' DO i00 I=1,5

WRITE(*,*) WRITE(*,'(A\)') ' READ(*,900) CHOICE FORMAT(A1)

PROCESSING OF MAGNETIC DATA IN FREQUENCY DOMAIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Upward continuation/downward continuation Conversion of fields i.e total to horizontal, vertical etc. Frequency analysis. Analytical signal analysis Reduction to pole Derivatives (1st. and 2 nd.) Exit

MAKE YOUR CHOICE--> '

CALL c l ea r sc r een ($GChEARSCREEN) SELECT CASE(CHOICE) C A S E ( ' I ' , ' 2 ' , ' 3 ' , ' 4 ' , ' 5 ' , ' 6 ' , ' U ' , ' u ' , ' C ' , ' c ' , ' F ' , ' f ' ,

' A ' , ' a ' , ' R ' , ' r ' , ' D ' , ' d ' ) CALL SELECT(CHOICE,ITS) WRITE(*,*)CHAR(7) GO TO 5000

CASE('7','E','e') CALL clearscreen($GCLEARSCREEN) CALL settextposition(12,30,curpos) WRITE(*,*)' THANK YOU' CALL settextposition(24,l,curpos) STOP'... BYE...'

CASE DEFAULT WRITE(*,*)CHAR(7) W R I T E ( * , * ) ' ERROR : I t s h o u l d be an i n t e g e r 1-7 o r ' W R I T E ( * , * ) ' c h a r a c t e r s U , u , C , c , F , f , A , a , R , r , E , e ' W R I T E ( * , * ) ' D,d a r e o n l y a l l o w e d t r y a g a i n '

NOTATION' 1 or U or u is for UPWARD/DOWNWARD' 2 or C o r c CONVERSION OF FIELDS' 3 or F or f HARMONIC ANALYSIS' 4 or A or a ANALYTICAL ' 5 or R or r REDUCTION TO POLE' 6 or D or d DERIVATIVES' 7 o r E o r e EXIT'

WRITE(* ,* ) WRITE(* ,* ) WRITE(* ,* ) WRITE(* ,* ) WRITE(*,*) WRITE(*,*) WRITE(*,*) WRITE(*,*) W R I T E ( * , ' ( A \ ) ' ) ' - - HIT ENTER KEY TO CONTINUE-- ' READ(*,*) GO TO 5000

END SELECT

689

CAGEO ~ /~ -C

Page 10: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

690 B. NARASIMHA RAO and P. RAMA KRISHNA

END SUBROUTINE CLEAR

CALL clearscreen($GCLEARSCREEN) RETURN END

* This subroutine is to select the processing subroutine * * according to choice. * ********************************************************************

INTERFACE TO INTEGER*2 FUNCTION SYSTEM [C] > (STRING[REFERENCE])

CHARACTER*I STRING END

SUBROUTINE SELECT(CHOICE,ITS) IMPLICIT DOUBLE PRECISION (A-H,O-Z) DOUBLE PRECISION INCL COMMON /AB/INCL,ALPHA COMMON /BC/DOUT,DIN COMMON /CD/LVL,H(10) COMMON /EF/ CO COMMON /XR/ XR(250) COMMON /RAD/ XX(250),XZ(250) COMMON /HIL/ XI(250) CHARACTER*2 DIN,DOUT CHARACTER*I YN CHARACTER*4 STAT CHARACTER*20 INFILE,PROF,OUTFIL,BLANK CHARACTER*I CHOICE,CO LOGICAL TEF INTEGER*2 SYSTEM DIMENSION YR(250) BLANK=' DO 1500 I=i,250

XR(I):O.O XI(I)=0.O YR(I)=0.0 XX(I)=O.O

1500 XZ(I)=0.0 DEL=O MODI=O IF(ITS.NE.O)THEN WRITE(*,*)'Note : It creats new data file with prefix ' WRITE(*,*)' of choice no. to old file' WRITE(*,*)' DO YOU WANT TO USE SAME DATA FILE TO ' WRITE(*,'(A\)')' TO OTHER CHOICES ? ENTER <Y/N>-->' READ(*,2)YN IF(YN.EQ.'Y'.OR.YN.EQ.'y')THEN

DEL=2 MODI=I

* Updating the data file for other choices CALL DATAIN(XR,N,DX,PROF,CHOICE,INFILE,MODI)

ENDIF ENDIF IF(MODI.NE.I)THEN

3010 WRITE(*,*)' DO YOU WANT TO KEY-IN THE DATA THROUGH ' WRITE(*,'(A\)')' KEY BOARD ? <Y/N>-->' READ(*,2)YN

2 FORMAT(AI) IF(YN.EQ.'Y'.OR.YN.EQ.'y'.OR.YN.EQ.'N'.OR.YN.EQ.'n')THEN

CONTINUE ELSE

WRITE(*,*)CHAR(7) WRITE(*,*)' ERROR : only Y, y, N and n are allowed. ' GO TO 3010

ENDIF IF(YN.EQ.'Y'.OR.YN.EQ.'y')THEN

MODI=0 ITS=I DEL=O

* Key-in and editing the input data CALL DATAIN(XR,N,DX,PROF,CHOICE,INFILE,MODI)

ENDIF

Page 11: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

Magnetic data processing with MAGPROS

ENDIF 500 CONTINUE

I F ( ( Y N o N E . ' Y ' ) . A N D . ( M O D I . N E . 1 ) ) T H E N W R I T E ( * , * ) ' GIVE INPUT FILE NAME / TYPE HELP FOR HELP' I T S = I R E A D ( * , I , E R R = 6 O O ) I N F I L E

1 FORMAT(A20) IF(TEF(INFILE).OR.INFILE.EQ.BLANK)THEN

CALL CLEAR WRITE(*,*)CHAR(7) WRITE(*,*)'ERROR:It should be alpha-numeric ' WRITE(*,*)' characters only and no blank line' WRITE(*,*)' or special characters are allowed.'

GO TO 500 ENDIF ENDIF IF(INFILE.EQ.'HELP'.OR.INFILE.EQ.'H')GO TO 1001

1000 CALL CLS(LT) IF(LT.GT.3)THEN

WRITE(*,*)CHAR(7) WRITE(*,*)' .... DISPLAY SELECTION IS WRONG ..' PAUSE' HIT ENTER TO CONTINUE' GOTO I000

ENDIF IF(LT.EQ.1)THEN

OUTFIL='CON' JOUT=I STAT='OLD'

ELSEIF(LT.EQ.2)THEN OUTFIL='PRN' JOUT=3 STAT='OLD'

ELSEIF(LT.EQ.3)THEN 801 CONTINUE

CALL CLEAR WRITE(*,*) WRITE(*,*)' Insert a formated floppy in drive and give ' WRITE(*,*)' file name alongwith the drive specification.' WRITE(*,*)' For. example A:TEST.OUT' READ(*,I)OUTFIL STAT='NEW'

IF(TEF(OUTFIL).OR:OUTFIL.EQ.BLANK)THEN CALL CLEAR

WRITE(*,*)CHAR(7) WRITE(*,*)'ERROR:It should be alpha-numeric ' WRITE(*,*)' characters only and no blank line' WRITE(*,*)' or special characters are allowed.'

GO TO 801 ENDIF ENDIF OPEN(JOUT,FILE=OUTFIL,STATUS=STAT) CO=CHOICE GO TO I001

600 WRITE(*,*)'FILE NAME SHOULD NOT START WITH SPECIAL CHARS' GO TO 500

1001 CONTINUE SELECT CASE(CHOICE) C A S E ( ' I ' , ' U ' , ' u ' )

I F ( I N F I L E . E Q . ' H E L P ' . O R . I N F I L E . E Q . ' H ' ) T H E N * On HELP com m and d i s p I a y s t h e d a t a f o r m a t f o r o p t i o n 1

CALL HUP W R I T E ( * , * ) C H A R ( 7 ) ITS=0 PAUSE 'HIT ENTER KEY TO CONTINUE' RETURN

ELSE OPEN(2,FILE=INFILE,STATUS='OLD',ERR=900)

* R e a d i n g t h e d a t a f o r c o n t i n u a t i o n R E A D ( 2 , * , E R R = 6 O I ) N , D X , L V L , P R O F READ(2,*,ERR=602)(XR(I),I=I,N) READ(2,*,ERR=603)(H(I),I=I,LVL) CALL CONT(DX,N,LVL,H,PROF,JOUT)

691

Page 12: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

692 B. NARASIMHA RAO and P. RAMA KRISHNA

CLOSE(2) ENDIF

CASE('2','C','c') IF(INFILE.EQ.'HELP'.OR.INFILE.EQ.'H')THEN

* On HELP command displays data format for option 2 CALL HMAG WRITE(*,*)CHAR(7) ITS=0 PAUSE 'HIT ENTER KEY TO CONTINUE' RETURN

ELSE OPEN(2,FILEfINFILE,STATUS='OLD',ERR=900)

* Reading the data for transformation of the magnetic fields READ(2,*,ERR=604)N,INCL,ALPHA,DIN,DOUT,PROF READ(2,*,ERR=605)(XR(1),I=I,N) IF (ALPHA.EQ.0)THEN

WRITE(*,*)CHAR(7) WRITE(*,*)' ...... {Alpha zero not allowed' WRITE(*,*)'try again after modification)' ITS=0 RETURN

ENDIF DO I0 I=I,N

XI(I)=O.O I0 YR(I):XR(I)

WRITE(*,*) WRITE(*,*)' ........ WORKING .. PLEASE WAIT ..... ' WRITE(*,*)

* Computes Hilbert Transform of the input data CALL HILBRT(N) CALL MAGFLD(YR,N,INCL,ALPHA,DIN,DOUT,PROF,JOUT) CLOSE(2) ENDIF

C A S E ( ' 3 ' , ' F ' , ' f ' ) I F ( I N F I L E . E Q . ' H E L P ' . O R . I N F I L E . E Q . ' H ' ) T H E N

CALL HHAR WRITE(*,*)CHAR(7) ITS=0

PAUSE 'HIT ENTER KEY TO CONTINUE' RETURN

ELSE OPEN(2 ,FILE=INFILE,STATUS= 'OLD' ,ERR=900)

* R e a d i n g t h e d a t a f o r Ha rmon ic a n a l y s i s . READ(2,*,ERR=606)N,DX,PROF R E A D ( 2 , * , E R R f 6 0 7 ) ( X R ( I ) , I = I , N ) CALL HARMO(N,DX,PROF,JOUT)

CLOSE(2) ENDIF

C A S E ( ' 4 ' , ' A ' , ' a ' ) * On HELP command d i s p l a y s d a t a f o r m a t f o r o p t i o n 4

I F ( I N F I L E . E Q . ' H E L P ' . O R . I N F I L E . E Q . ' H ' ) T H E N CALL HGRAD WRITE(*,*)CHAR(7) ITS=O PAUSE 'HIT ENTER KEY TO CONTINUE' RETURN

ELSE OPEN(2,FILEfINFILE,STATUS='OLD' ,ERRff i900)

* R e a d i n g t h e d a t a f o r a n a l y t i c a l s i g n a l a n l y s i s . READ(2,*,ERR=606)N,DX,PROF READ(2,*,ERRf607)(XR(I),I=I,N) CALL GRAD(N,DX,PROF,JOUT)

CLOSE(2) ENDIF

CASE('5','R','r') * On HELP command displays data format for option 5

IF(INFILE.EQ.'HELP'.OR.INFILE.EQ.'H')THEN CALL HRTP WRITE(*,*)CHAR(7) ITS=0 PAUSE 'HIT ENTER KEY TO CONTINUE' RETURN

Page 13: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

Magnetic data processing with MAGPROS 693

ELSE OPEN(2,FILE=INFILE,STATUS='OLD' ,ERRff i900)

* R e a d i n g t h e d a t a f o r r e d u c t i o n t o p o l e . READ(2,*,ERRffi608)N,DX,PROF,INCL READ(2,*,ERRffi609)(XR(I),Iffil,N) CALL RTP(N,DX,PROF,INCL,JOUT)

CLOSE(2) ENDIF

C A S E ( ' 6 ' , ' D ' , ' d ' ) * On HELP command d i s p l a y s d a t a f o r m a t f o r o p t i o n 6

I F ( I N F I L E . E Q . ' H E L P ' . O R . I N F I L E . E Q . ' H ' ) T H E N CALL HDERV WRITE(*,*)CHAR(7) ITS=O PAUSE 'HIT ENTER KEY TO CONTINUE' RETURN

ELSE OPEN(2,FILE=INFILE,STATUS='OLD',ERR=900)

* Reading the data for derivatives. READ(2,*,ERR=606)N,DX,PROF READ(2,*,ERR=607)(XR(I),I=I,N) CALL DERV(N,DX,PROF,JOUT)

CLOSE(2) ENDIF

END SELECT GO TO 2000

900 CALL CLEAR WRITE(*,*) WRITE(*,*)' ERROR IN OPENING THE FILE/DOES NOT EXISTS' WRITE(*,*) WRITE(*,*)' The available data files in the current working' WRITE(*,*)' directory are ..... ' IDIR=SYSTEM('DIR *.DAT/W'C) PAUSE ' HIT ENTER KEY TO CONTINUE ' ITS=0 GO TO 2001

601 WRITE(*,*)'ERROR IN FIRST LINE OF THE INPUT DATA:N,DX,LVL,PROF' ITS=0 GO TO 2000

602 WRITE(*,*)' ERROR IN INPUT DATA :XR(I),I:I,N' ITS:0 GO TO 2000

603 WRITE(*,*)'ERROR IN LEVELS OF CONTINUATION' ITS=0 GO TO 2000

604 WRITE(*,*)'ERROR IN FIRST LINE OF THE INPUT DATA FILE' WRITE(*,*)'i.e., N,INCL,ALPHA,DIN,DOUT,PROF' ITS=O GO TO 2000

605 WRITE(*,*)'ERROR INPUT DATA: XR(I),I=I,N' ITS=0 GO TO 2000

606 WRITE(*,*)'ERROR IN FIRST LINE OF THE INPUT DATA FILE' WRITE(*,*)' i.e., N,DX,PROF' ITS=0 GO TO 2000

607 WRITE(*,*)'ERROR IN INPUT DATA' ITS=0 GO TO 2000

608 WRITE(*,*)'ERROR IN FIRST LINE OF THE INPUT DATA FILE' WRITE(*,*)'i.e.,N,DX,PROFpINCL' ITS=0 GO TO 2000

609 WRITE(*,*)'ERROR IN INPUT DATA : XR(I),I:I,N' ITS=0 GO TO 2000

2000 CONTINUE CLOSE(JOUT) PAUSE 'HIT ENTER KEY TO CONTINUE'

2001 CONTINUE WRITE(*,*)CHAR(7) IF(DEL.NE.0)THEN

Page 14: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

694 B. NARA$1MHA RAO and P. RAMA KRISHNA

CALL CLEAR WRITE(*,950)INFILE

950 FORMAT(5X,' DO YOU WANT TO REMOVE THE > / ' TYPE Y OR N - - > ' \ )

R E A D ( * , 2 ) Y N I F ( Y N . E Q . ' Y ' . O R . Y N . E Q . ' F ' ) T H E N

O P E N ( 6 , F I L E f I N F I L E , S T A T U S = ' O L D ' ) C L O S E ( 6 , S T A T U S f ' D E L E T E ' ) DEL=0 I T S = 0

ENDIF ENDIF RETURN END

* T h i s s u b r o u t i n e c o m p u t e s t h e u p w a r d / d o w n w a r d * * c o n t i n u a t i o n o f t h e i n p u t f i e l d f o r a n y n o . o f l e v e l s * * o f g i v e n h e i g h t / d e p t h . *

SUBROUTINE C O N T ( D X , N X , L V L , H I , P R O F , J O U T ) I M P L I C I T DOUBLE PRECISION ( A - H , O - Z ) DOUBLE PRECISION LX CHARACTER*20 PROF CHARACTER*2 YN CHARACTER*12 BLANK COMMON /XR/ XR(250) DIMENSION H(0:249),TH(0:249),HI(10),XI(250) BLANK=' WRITE(*,*) WRITE(*,*)' ........ WORKING ..PLEASE WAIT ........ ' WRITE(*,*) PI=3.14159265 LX=NX*DX

* Computes Direct Hartley Transform. CALL DHTID(XR,H,NX,0) T H ( 0 ) = R ( 0 ) DO 25 L = I , L V L CALL CLEAR W R I T E ( * , * ) W R I T E ( * , * ) ' . . . . . . . . WORKING . . P L E A S E WAIT . . . . . . . . ' W R I T E ( * , * )

H L = H I ( L ) I F ( N X / 2 * 2 . E Q . N X ) T H E N

NM=NX/2 ELSE

NM=(NX-1)/2 ENDIF DO 10 M=I,NM

C=2.0*PI*M/LX TH(M)=H(M)*DEXP(C*HL) TH(NX-M)=H(NX-M)*DEXP(C*HL)

10 CONTINUE * Computes Inverse Hartley Transform.

CALL DHTID(XI,TH,NX,I) SOOT=0 IF(HL.GT.0)THEN

WRITE(*,*)' DO YOU WANT SMOOTHING ? .' WRITE(*,'(A\)')' It uses Hanning filter. Type Y/N---> R E A D ( * , 2 ) Y N

2 FORMAT(A2) I F ( Y N . E Q . ' Y ' . O R . Y N . E Q . ' y ' ) T H E N

* T h e o u t p u t d a t a i s s m o o t h e d u s i n g H a n n i n g f i l t e r . SOOT=I CALL SMOOT(XI,NX)

ENDIF ENDIF

W R I T E ( J O U T , 9 0 0 ) P R O F W R I T E ( J O U T , 9 0 2 ) H L , D X W R I T E ( J O U T , 9 0 1 )

' , 2 X , A 2 0 , ' F I L E ' ,

Page 15: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

Magnetic data processing with MAGPROS 695

WRITE(JOUT,905) WRITE(JOUT,901) IF(JOUT.EQ.I)THEN

CO=13 ELSE

CO=50 ENDIF DO 30 I=I,NX IF((I.EQ.CO.OR.I.EQ.NX+I).AND.JOUT.EQ.1)THEN

PAUSE 'HIT ENTER KEY TO CONTINUE' CO=CO+13

ELSEIF((I.EQ.CO.OR.I.EQ.NX+I).AND.JOUT.EQ.3)THEN WRITE(JOUT,*)CHAR(12) CO=CO+50

ENDIF IF((I.EQ.I.AND.SOOT.EQ.I).OR.(I.EQ.NX.AND.SOOT.EQ.1))THEN WRITE(JOUT,911)XR(I),BLANK ELSE WRITE(JOUT,903) XR(I),XI(I) ENDIF

30 CONTINUE WRITE(JOUT~901) WRITE(JOUT,904)

25 CONTINUE 900 FORMAT(5X,'TRAVERSE NAME= ',A20) 901 FORMAT(5X,38('-')) 902 FORMAT(SX,'HEIGHT OF CONTINUATION = ',F10.4/SX,

> 5X,' STATION SPACING =',F8.4) 905 FORMAT(5X,' ',3X,'INPUT DATA',3X,'.',4X,'CONT.ANOMALY',3X,' 903 FORMAT(5X,' ',3X,FI0.4,3X,' ',4X,F12.4,3X,'.') 911 FORMAT(SX,' ',3X,FI0.4,3X,' ',4X~AI2,3X,' ') 904 FORMAT(///) 910 FORMAT(////////)

RETURN END

* T h i s s u b r o u t i n e t r a n s f o r m s a n y c o m p o n e n t o f t h e m a g n e t i c * * f i e l d i n t o a n o t h e r . *

SUBROUTINE MAGFLD(YR,N,INCL,ALPHA,DIN,DOUT,PROF,JOUT) IMPLICIT DOUBLE PRECISION ( A - H , O - Z ) DOUBLE PRECISION I D A S B , I N C L , I N C COMMON /XR/ XR(250) COMMON /HIL/ XI(250) DIMENSION TOTAL(250),HORI(250),VERT(250),

> YR(250) CHARACTER*20 PROF CHARACTER*2 DIN,DOUT CHARACTER*2 YN CHARACTER*12 BLANK BLANK=' IF(DIN.EQ.DOUT)THEN

WRITE(*,905) RETURN

ENDIF PI=3.14159265 INC=INCL*PI/180.0 ALF=ALPHA ALPHA=ALPHA*PI/180.0 IDASH=DATAN(DTAN(INC)/DSIN(ALPHA)) IF (DIN .EQ.'DH' .OR. DIN .EQ.'DZ')THEN

* Input is Horizantal field. IF(DIN.EQ.'DH')THEN

IF(DOUT.EQ.'DZ')THEN * Computes vertical field.

DO 30 I=I,N VERT(I)=-XI(I)/DSIN(ALPHA)

30 CONTINUE ENDIF

,)

Page 16: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

696 B. NARASIMHA RAO and P. RAMA KRISHNA

IF(DOUT.EQ.'DT')THEN * Computes Total field.

DO 10 I=I,N TOTAL(I)fXR(I)*DCOS(INC)

> -XI(I)*DSIN(INC)/DSIN(ALPHA) 10 CONTINUE

ENDIF ENDIF

* Input is Vertical field. IF(DIN.EQ.'DZ')THEN

IF(DOUT.EQ.'DH')THEN * Computes Horizontal field.

DO 40 I=I,N HORI(1)=XI(I)*DSIN(ALPHA)

40 CONTINUE ENDIF IF(DOUT.EQ.'DT')THEN

* Computes Total field. DO 20 I=I,N

TOTAL(I)=XR(I)*DSIN(INC)+XI(I)*DSIN(ALPHA)* > DCOS(INC)

20 CONTINUE ENDIF

ENDIF ENDIF

* Input is Total field. IF(DIN.EQ.'DT')THEN

IF(DOUT.EQ.'DZ')THEN * Computes Vertical field.

DO 50 I=I,N VERT(I)=(XR(1)*DSIN(IDASH)-XI(I)*DCOS(IDASH))*

> DSIN(IDASH)/DSIN(INC) 50 CONTINUE

ENDIF IF(DOUT.EQ.'DH')THEN

* Computes Horizontal field. DO 60 I=I,N

HORI(I)=(XR(I)*DCOS(IDASH)+XI(1)*DSIN(IDASH))* * DCOS(IDASH)/DCOS(INC)

60 CONTINUE ENDIF

ENDIF SOOT=0 CALL CLEAR WRITE(*,'(A\)')' DO YOU WANT SMOOTHING ON OUTPUT TYPE Y/N-->' READ(*,I)YN

I FORMAT(A2) IF(YN.EQ.'Y'.OR.YN.EQ.'y')THEN

SOOT=I WRITE(*,*) 'SMOOTHENING USING HANNING FILTER'

* The output is smoothed using Weighted average in space domain. IF(DOUT.EQ. 'DT ' )THEN

CALL SMOOT(TOTAL,N) ELSEIF(DOUT.EQ. 'DH')THEN

CALL SMOOT(HORI,N) ELSEIF(DOUT.EQ. 'DZ' )THEN

CALL SMOOT(VERT,N) ENDIF

ENDIF WRITE(JOUT,912)N,INCL,ALF,DIN,DOUT WRITE(JOUT,907)PROF WRITE(JOUT,904)

IF(DOUT.EQ. 'DT ' )THEN WRITE(JOUT,901)

ELSEIF(DOUT.EQ. 'DZ' )THEN WRITE(JOUT,902)

ELSEIF(DOUT.EQ. 'DH')THEN WRITE(JOUT,903)

ENDIF IF(JOUT.EQ.1)THEN

CON=13 ELSE

Page 17: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

7O

900 901

902

903

904 905

907 910 912

Magnetic data processing with MAGPROS 697

CON=50 ENDIF DO 70 I=I,N

IF((I.EQ.CON.OR.I.EQ.N+I).AND.JOUT.EQ.1)THEN PAUSE 'HIT ENTER KEY TO CONTINUE' CON=CON+13

ELSEIF((I.EQ.CON.OR.I.EQ.N+I).AND.JOUT.EQ.3)THEN WRITE(JOUT,*)CHAR(12) CON:CON+50

ENDIF IF(DOUT.EQ.'DT')THEN

IF((SOOT.EQ.1.AND.I.EQ WRITE(JOUT,910)YR(I)

ELSE WRITE(JOUT,900)YR(I),TOTAL(I)

ENDIF ELSEIF(DOUT.EQ.'DZ')THEN

IF((SOOT.EQ.I.AND.I.EQ WRITE(JOUT,910)YR(I)

ELSE WRITE(JOUT,900)YR(I),VERT(I)

ENDIF ELSEIF(DOUT.EQ.'DH')THEN

IF((SOOT.EQ.I.AND.I.EQ WRITE(JOUT,910)YR(I)

ELSE WRITE(JOUT,900)YR(I),HORI(I)

ENDIF ENDIF

CONTINUE WRITE(JOUT,904)

FORMAT(5X,' ',2X,FI2.3,2X,' ',2X,FI2.3,2X,' FORMAT(5X,' ',3X,'INPUT DATA',3X,'

> ' . ' 75X,35( ' - ' ) ) FORMAT(SX,'.',3X,'INPUT DATA',3X,'

> ' ' / 5 X , 3 5 ( ' - ' ) ) F O R M A T ( 5 X , ' . ' , 3 X , ' I N P U T D A T A ' , 3 X , '

> ' . ' / 5 X , 3 5 ( ' - ' ) ) FORMAT(5X,35('-')) F O R M A T ( 1 X , / / / / / / / / / / / / / / / ,

> > > >

.I).OR.(SOOT.EQ.1.AND.I.EQ.N))THEN ,BLANK

.1).OR.(SOOT.EQ.I.AND.I.EQ.N))THEN ,BLANK

.I).OR.(SOOT.EQ.I.AND.I.EQ.N))THEN ,BLANK

,) ',2X,'TOTAL FIELD',2X,

',2X,'VERTICAL FLD.',2X,

',2X,'HORIZT. FIELD',2X,

5X,'WARNING ??? INPUT AND OUTPUT FIELD COMPONENTS', 'ARE SAME',/14X,'TRY AGAIN ' , 'AFTER CHANGING THE FIELD COMPONENTS'/, / / / / / / / 1 4 X , 'BYE')

FORMAT(5X,'TRAVERSE NAME=',A20) FORMAT(5X,'.',2X,F12.3,2X,' ' ,2X,A12,2X,'. ') FORMAT(5X,'N=',I3,4X,'Inclination=',F8.3,4X,'ALPHA=',F8.3, / 5X,'Input field=',A2,4X,'Output field:',a2) RETURN END

Subroutine for computing the Hilbert transform.

SUBROUTINE HILBRT(N) IMPLICIT DOUBLE PRECISION (A-H,O-Z) COMMON /XR/ XR(250) COMMON /HIL/ XI(250) DIMENSION H(0:249)

* Computes discrete Hartley Transform( Bracewell,1986). IF(N/2*2.EQ.N)THEN

NM=N/2 ELSE

NM=(N-1)/2 ENDIF CALL DHTID(XR,H,N,0) H(0)=0 DO I0 K=I,NM

TEM=H(K) H(K)=-H(N-K) H(N-K)=TEM

I0 CONTINUE IF(N/2*2.EQ.N)THEN

Page 18: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

698 B. NARASIMIIA RAO and P. RAMA KRISHNA

H(NM)=0 ENDIF

* C o m p u t e s i n v e r s e H a r t l e y T r a n s f o r m . CALL D H T 1 D ( X I , H , N , 1 ) RETURN END

* T h i s s u b r o u t i n e i s f o r s e l e c t i n g t h e d i s p l a y o p t i o n .

SUBROUTINE C L S ( L T ) 8 0 0 CONTINUE

CALL CLEAR WRITE(*,950)

950 FORMAT(2X, ' SELECT PLEASE ',/ > 2X, ' .............. ',/ > 15X,' I - FOR DISPLAY ',/ > 15X,' 2 - FOR PRINTER ',/ > 15X,' 3 - FOR DISK DRIVE '//// > 10X 'SELECT-->'\)

READ(*,*,ERR=900)LT GO TO 600

900 W R I T E ( * , * ) C H A R ( 7 ) W R I T E ( * , * ) ' E R R O R : I t s h o u l d be a n i n t e g e r o n l y 1, 2 o r 3 ' PAUSE ' HIT ENTER KEY TO CONTINUE ' GO TO 800

600 CONTINUE RETURN END

****************************************************************

* This subroutine computes the amplitude, phase and * * In (amplitude) of any real data using Hartley transform. * * Also, the spectra for overlapped data (expressed in no. of * * observations to be considered) when option is given in * * terms of percent no. of data points. * , *

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

SUBROUTINE HARMO(N,DX,PROF,JOUT) I M P L I C I T DOUBLE PRECISION ( A - H , O - Z ) DOUBLE PRECISION LAMP CHARACTER*20 PROF CHARACTER*2 YN CHARACTER*25 X T L E , Y T L E , T I T L E COMMON /NRE/ NIRG(3),N2RG(3),NSG DIMENSION XX(0:49),YY(O:49),DEPTH(5) COMMON /XR/ XR(250) DIMENSION H(0:249),AMP(0:249),

> PHA(O:249),LAMP(O:249),X(250) REAL*4 Y(250,I),WV(0:249) PI=3.14159265 XTLE=' Wave number' YTLE=' LOG ampl. ' TITLE=' LOCAL SPECTRA ' LL=N CALL CLEAR WRITE(*,*) WRITE(*,*)' DO YOU WANT WINDOW OPTION ? ' WRITE(*,'(A\)')' TYPE Y/N--->' READ(*,3)YN

3 FORMAT(A2) IF(YN.EQ.'Y'.OR.YN.EQ.'y')THEN MM=N

1000 WRITE(*,*)'GIVE WINDOW LENGTH' WRITE(*,*)' How many data points one to be ' WRITE(*,*)' considered at atime' WRITE(*,'(A\)') .... >? ' READ(*,*)WIN IF(WIN.GT.MM)THEN

WRITE(*,*)' WINDOW LENGTH SHOULD NOT BE GREATER THAN' WRITE(*,*)' NUMBER OF VALUES TRY AGAIN PLEASE' GO TO 1000

Page 19: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

Magnetic data processing with MAGPROS

ENDIF 600 WRITE(*,*)" GIVE PERCENTAGE OF OVER LAPPING'

WRITE(*,*)' percentage of no. of data points' WR[TE(*,'(A\)')' ---> ~' READ(*,*,ERR=800)PER INCER=WIN*(IO0-PER)/100 IF(INCER.LE.O)THEN

CAI,[, CLEAR WRITE(*,*)CHAR(7) W R I T E ( * , * ) ' T h i s p e r c e n t a g e i s W R I T E ( * , * ) ' d a t a p o i n t s p l e a s e WRITE(* ,* ) GO TO 600

ENDIF N=WIN GO TO 700

800 WRITE(*,*)'ERROR : It should be GO TO 600

700 CONTINUE ELSE

DO 400 I = I , N 400 X(I)=XR(I)

ENDIF INIT:I

2000 IF(YN.EQ.'Y'.OR.YN.EQ.'y')THEN LL=0 DO 402 I=INIT,N LL=LL+I

402 X(LL)=XR(1) ENDIF

WRITE(* ,*) W R I T E ( * , * ) ' . . . . . . . WORKING WRITE(* ,* ) CALL GETTIM(IHR, IMIN, ISEC, I100TH)

* Computes D i r e c t H a r t e l y T r a n s f o r m . CALL DHT1D(X,H,LL,0) IF (LL/2*2 .EQ.LL)THEN

NM:LL/2 ELSE

NM=(LL-1) /2 ENDIF AMP(0)=DABS(H(0)) PHA(0)=0 LAMP(0)=DLOG(AMP(O)) WV(0)=O Y(I,I)=LAMP(O) DO 20 K=I,NM

20

not allowed on increase it.'

a numerica], va]ue '

.... PLEASE WAIT ..... '

number of'

AMP(K):DSQRT((H(K)**2+H(LL-K)**2)/2) PHA(K):DATAN(-(H(K)-H(LL-K))/(H(K)+H(LL-K))) LAMP(K)=DLOG(AMP(K)) WV(K)=FLOAT(K/(LL*SNGL(DX))) AHP(LL-K)=AMP(K) PHA(LL-K)=-PHA(K) LAHP(LL-K)=LAMP(K) Y(K+I,1)=SNGL(LAMP(K))

CONTINUE CALL PLOT(WV,Y,NM+I,I,XTLE,YTLE,TITLE) DO INSG=I,NSG IRG=O DO II=NIRG(INSG),N2RG(INSG)

XX(IRG)=DBLE(WV(II)) YY(IRG)=LAMP(II) IRG=IRG+I

ENDDO CALL REGR(XX,YY,IRG-I,SLOPE,CINTR) DEPTH(INSG)=-SLOPE/(2*PI) ENDDO CALL GETTIM(INHR,INMIN,INSEC,INI00TH) WRITE(JOUT,902)DX,INIT,N,PROF WRITE(JOUT,903) WRITE(JOUT,900) WRITE(JOUT,903)

699

Page 20: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

700 B. NARAmMHA RAO and P. RAMA KRISHNA

10

911 900

901

[F{JOUT.EQ.I)THEN C0=8

ELSEIF(JOUT.EQ.3)THEN CO=50

ENDIF DO I0 I=0,LL-1 IF{{I.EQ.CO.OR.I.EQ.N}.AND.JOUT.EQ.I)THEN

WRITE(JOUT,903} PAUSE 'HIT ANY KEY TO CONTINUE' CO = CO+13

EI,SEIF{(I.EQ.CO.OR.I.EQ.N).AND.JOUT.EQ.3)THEN CO=CO+50 WRITE(JOUT,*)CHAR(12)

ENDIF WRITE(JOUT,901)I+I,X(I+I),H(1),AMP(I),PHA{I),LAMP(I) CONTINUE WRITE(JOUT,903) DO I=I,NSG

WRITE(JOUT,911)I,DEPTH(I) ENDDO FORMAT(5X,' Segment number=',I3,' Depth =',F15.5/) FORMAT(5X,' ','HR.NO',3X,' ',4X,'INPUT ',2X,'.',

3X, ' HARTELY ',2X,' ', 5X,'AMPI,ITUDE',3X,' ',6X,'PHASE',6X,'.', 4X,'LOG.AMPLI',3X,' ')

FORMAT(5X,' ',I4,4X,'.',FI2.5,2X,'.',FI2.5,2X, '.',2X,Fll.5,4X,'.',4X, F9.5,4X,' ',4X,Fg.5,3X,' ')

902 FORMAT(10X,'DX=',FI5.5,10X,'STARTING NUMBER=',I4/,10X, > 'ENDING NUMBER =',I4, > /10X, 'REMARKS=' ,A20}

903 F O R M A T ( 5 X , 9 3 ( ' - ' ) ) 910 FORMAT(1H1}

CALL T I M D I F F ( I H R , I M I N , I S E C , I I O O T H , I N H R , I N M I N , I N S E C , I N 1 0 0 T H , > JOUT)

I F ( Y N . E Q . ' Y ' . O R . Y N . E Q . ' y ' ) T H E N IF{N.LT.MM)THEN

N=N+INCER INIT=INIT+INCER

IF(N.LE.MM)THEN GO TO 2000 ENDIF

ENDIF ENDIF RETI)RN END

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

* This subroutine computes the horizontal and vertical g r a d i - * * e n t s , a m p l i t u d e a n d p h a s e v a l u e s o f t h e m a g n e t i c f i e l d f o r * * a n a l y s e s o f t h e a n a l y t i c a l s i g n a l . *

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

SUBROUTINE GRAD(N,DX,PROFDJOUT) IMPLICIT DOUBLE PRECISION ( A - H , O - Z ) CHARACTER*20 PROF CHARACTER*2 YN CHARACTER*9 BLANK INTEGER CO COMMON / X R / XR(250) COMMON /RAD/ X X ( 2 5 0 ) , X Z ( 2 5 0 ) DIMENSION H(0:249),AMP(250),PHA(250) DO 400 I=1,250 XX(I)=O

400 XZ(I)ffi0 WRITE(* ,* ) W R I T E ( * , * ) ' . . . . . . . WORKING . . . . PLEASE WAIT . . . . . ' W R I T E ( * , * ) BLANK=' CALL GETTIM(IHR,IMIN,ISEC,II00TH)

* Computing DHT.

Page 21: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

Magnetic data processing with MAGPROS

CALL DHT1D(XR,H,N,0) H(0)=0 IF(N/2*2.EQ.N)THEN NMffiN/2 ELSE

NH=(N-1)/2 ENDIF PI=3.14159265 DO 10 I=I,NM

W=2*PI*I /N H ( I ) = H ( I ) * W I F ( I . N E . ( N - I ) ) T H E N

H(N-I )=H(N-I )*W ENDIF

I0 CONTINUE * Computing IDHT

CALL DHTID(XZ,H,N,I) DO 20 I=I,NM

TEMP=H(I) H(I)=-H(N-I) H(N-I)=TEMP

20 CONTINUE IF(N/2*2.EQ.N)THEN

H(NM)=0 ENDIF

* Compu t ing IDHT. CALL DHTID(XX,H,N,1) CALL GETTIM(INHR,INMIN,INSEC,IN100TH) IF(JOUT.NE.5)THEN SOOT=0 CALL CLEAR WRITE(* ,*) 'DO YOU WANT SMOOTHENING ON OUTPUT DATA ? ' W R I T E ( * , * ) ' TYPE Y/N ( I t u s e s H a n n i n g f i l t e r f o r s m o o t h e n i n g ) ' WRITE(*,'(A\)') .... > ? ' READ(*,I)YN IF(YN.EQ.'Y'.OR.YN.EQ.'y')THEN

* Smoothening the output data using Hanning filter. SOOT=I CALL SMOOT(XX,N) CALL SMOOT(XZ,N)

ENDIF ENDIF DO 30 I=I,N

XX(I)=XX(I) /DX XZ(I)=XZ(I)/DX IF ( (SOOT.EQ.1 .AND. I .EQ.1 ) .OR. (SOOT.EQ.1 .AND. I .EQ.N) )THEN

AMP(I)=O PHA(I)=0

ELSE AMP(I )=SQRT(XX(I )**2+XZ(I )**2) PHA(I )=DATAN(-XX(I ) /XZ( I ) )

ENDIF 30 CONTINUE 601 IF(JOUT.NE.5)THEN

WRITE(JOUT,902)DX,N,PROF WRITE(JOUT,903) WRITE(JOUT,900) WRITE(JOUT,903) IF(JOUT.EQ.1)THEN

CO=7 ELSEIF(JOUT.EQ.3)THEN

CO=50 ENDIF DO 60 K = I , N

IF((K.EQ.CO.OR.K.EQ.N+I).AND.JOUT.EQ.1)THEN WRITE(JOUT,903) PAUSE 'HIT RETURN KEY TO CONTINUE' COffiCO+8

ELSEIF((E.EQ.CO.OR.K.EQ.N+I).AND.JOUT.EQ.3)THEN WRITE(JOUT,*)CHAR(12) CO=CO+50

ENDIF

701

Page 22: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

702 B. NARASIMHA RAO and P. RAMA KRI*HNA

IF((SOOT.EQ.I.AND.K.EQ.I).OR.(SOOT.EQ.1.AND.K.EQ.N))THEN WRITE(JOUT,912)XR(K),BLANK,BLANK,BLANK,BLANK

ELSE WRITE(JOUT,901)XR(K),XX(K),XZ(K),AMP(K),PHA(K)

ENDIF 60 CONTINUE

WRITE(JOUT,903) CALL TIMDIFF(IHR,IMIN,ISEC,II00TH,INHR,INMIN,INSEC,INIOOTH,

> JOUT) IF(JOUT.EQ.1)THEN CALL CLEAR YN='N' WRITE(*,600)

600 FORMAT(2X, 'DO YOU WANT TO SEE THE RESULT AGAIN ?'/ > 2X, ' TYPE Y/N--> '\)

READ(*,I)YN 1 FORMAT(A2)

IF(YN.EQ.'Y'.OR.YN.EQ.'y')THEN GO TO 601

ENDIF ENDIF

ENDIF 900 FORMAT(5X,' ',IX,'INPUT FIELD',2X,'.',5X,'HORI.GRAD',3X,'.',

> 5X,'VERT.GRAD',3X,'.',SX,'AMPLITUDE',3Xt' ',6X,'PHASE',8X,' 901 FORMAT(SX,' ',FI2.4,2X,' ',4X,F9.4,4X,'.',4X,F9.4,4X,'.',

> 4X,F9.4,4X,' ',4X,Fg.5,6X,'.') 902 FORMAT(10X,'DX=',FI5.5,10X,'N=',IS,10X,'PROFILE =',2AIO) 903 FORMAT(5X,90('-')) 910 FORMAT(/////////) 912 FORMAT(5X,' ',F12.4,2X,' ',4X,Ag,4x,' ',4X,Ag,4x,'.',

> 4X,A9,4X,' ',4X,Ag,6X,' ') RETURN END

*************************************************************

* This subroutine computes Ist and 2nd vertical gradients* * of the given magnetic field. The point of attribution * * is reckoned at the same point of observation since the * * derivatives are obtained directly from Hartley * * t r a n s f o r m . *

* * * * * * * * * * * * * * * * * * . * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * , .

SUBROUTINE DERV(N,DX,PROF,JOUT) IMPLICIT DOUBLE PRECISION ( A - H , O - Z ) CHARACTER*20 PROP CHARACTER*12 BLANK CHARACTER*2 YN COMMON / X R / X R ( 2 5 0 ) COMMON /RAD/ XX(250),XZ(250) DIMENSION H(0:249) DO 232 I=I,250 XX(I)=0

232 XZ(I)=0 BLANK=' W R I T E ( * , * ) W R I T E ( * , * ) ' . . . . . . . WORKING . . . . PLEASE WAIT . . . . . ' WRITE(*,*) CALL G E T T I M ( I H R , I M I N , I S E C , I I O O T H )

* C o m p u t i n g D i r e c t H a r t l e y T r a n s f o r m . CALL D H T 1 D ( X R , H , N , 0 ) I F ( N / 2 * 2 . E Q . N ) T H E N NM=N/2 ELSE NMf(N-I)/2 ENDIF P I f f i 3 . 1 4 1 5 9 2 6 5 S ( O ) = 0 DO I0 I=I,NM

W=2*PI*I/N H(I)=H(I)*W I F ( I . N E . ( N - I ) ) T H E N

,)

Page 23: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

Magnetic data processing with MAGPROS

H(N-I)=H(N-I)*W ENDIF

i0 CONTINUE * Computing Inverse Hartley Transform.

CALL DHTID(XZ,H,N,1) DO 40 I=I,NM

W=2*PI*I/N H(I):H(I)*W IF(I.NE.(N-I))THEN

H(N-I)=H(N-I)*W ENDIF

40 CONTINUE * C o m p u t i n g I n v e r s e H a r t l e y T r a n s f o r m .

CALL D H T I D ( X X , H , N , 1 ) DO 30 I = I , N

X X ( I ) : X X ( I ) / ( D X * D X ) X Z ( I ) = X Z ( I ) / D X

30 CONTINUE CALL G E T T I M ( I N H R , I N M I N , I N S E C , I N 1 0 0 T H ) SOOT=0 W R I T E ( * , * ) W R I T E ( * , * ) ' DO YOU WANT SMOOTHENING ON OUTPUT ? ' W R I T E ( * , * ) ' I t u s e s H a n n i n g f i l t e r . . . . . . . . . . . ' WRITE(*,'(A\)')' TYPE Y/N --> ' WRITE(*,*) READ(*,2)YN

2 FORMAT(A2) IF(YN.EQ.'Y'.OR.YN.EQ.'y')THEN

* The output data is smoothened using Hanning filter. SOOT=I CALL SMOOT(XX,N) CALL SMOOT(XZ,N)

ENDIF WRITE(JOUT,902)DX,N,PROF WRITE(JOUT,903) WRITE(JOUT,900) WRITE(JOUT,903) IF(JOUT.EQ.1)THEN

I=7 ELSEIF(JOUT.EQ.3)THEN

I = 5 0 ENDIF DO 60 K = I , N

IF((K.EQ.I.OR.K.EQ.N+I).AND.JOUT.EQ.I)THEN WRITE(JOUT,903) PAUSE 'HIT RETURN KEY TO CONTINUE' I=I+8

E L S E I F ( ( K . E Q . I . O R . K . E Q . N + I ) . A N D . J O U T . E Q . 3 ) T H E N W R I T E ( J O U T , * ) C H A R ( 1 2 ) I = I + 5 0

ENDIF IF((K.EQ.I.AND.SOOT.EQ.I).OR.(K.EQ.N.AND.SOOT.EQ.I))THEN

WRITE(JOUT,913)XR(K),BLANK,BLANK ELSE

WRITE(JOUT,901)XR(K),XZ(K),XX(K) ENDIF

60 CONTINUE WRITE(JOUT,903) CALL TIMDIFF(IHR,IMIN,ISEC,I100TH,INHR,INMIN,INSEC,IN100TH,

> JOUT) 900 FORMAT(fiX,' ',IX,'INPUT FIELD',2X,'.',fiX,'lst.VER.GRAD',3X,'

> 2X,'2nd.VERT.GRAD',IX,' ') 901 FORMAT(5X, ' ' , F 1 2 . 5 , 2 X , ' ' , 4 X , F 1 2 . 6 , 4 X , ' . ' , F 1 2 . 6 , 4 X , ' ' ) 902 F O R M A T ( 1 0 X , ' D X = ' , F 1 5 . f i , 1 0 X , ' N = ' , I 5 , 1 0 X , ' P R O F I L E • ' , 2 A 1 0 ) 903 FORMAT(5X,54('-')) 910 F O R M A T ( / / / / / / / / / ) 913 FORMAT(5X,' ',FI2.fi,2X,'.',4X,A12,4X,' ',AI2,4X,' ')

RETURN END

703

' p

Page 24: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

704 B. NARASIMHA RAO and P. RAMA KRISHNA

* This subroutine computes the magnetic field reduce to * * p o l e ( N o r t h e r n H e m i s p h e r e o n l y ) u s i n g d i f f e r e n t i a l g r a - * * d i e n t m e t h o d ( N a b i g h i a n , 1 9 7 2 ) . N o t e t h a t t h e ' b a s e * * l e v e l ' f o r RTP d a t a i s z e r o a n d t h e p o i n t o f a t t r i b u - * * tion shifts to one half the station spacing. Also on * * option smoothens the data using Hanning filter. *

SUBROUTINE R T P ( N , D X , P R O F , I N C , J O U T ) IMPLICIT DOUBLE PRECISION ( A - H , O - Z ) COMMON /XR/ XR(250) COMMON /RAD/ XX(250),XZ(250) DIMENSION RT(250),RX(250) DOUBLE PRECISION INC CHARACTER*20 PROF CHARACTER*I0 TXZ CHARACTER*f2 BLANK CHARACTER*2 YN I,OGICAL TEST BLANK=' P I = 3 . 1 4 1 5 9 2 6 5 4

100 CONTINUE W R I T E ( * , ' ( A \ ) ' ) ' GIVE NATURE OF FIELD DT o r DH o r D Z - - > ' R E A D ( * , I ) T X Z

1 FORMAT(A10) IF(.NOT.TEST(TXZ))THEN

W R I T E ( * , * ) C H A R ( 7 ) W R I T E ( * , * ) ' E R R O R : The n a t u r e o f t h e f i e l d s h o u l d b e ' W R I T E ( * , * ) ' DT o r DH o r DZ o n l y . ' GO TO 100

ENDIF W R I T E ( * , * ) W R I T E ( * , * ) CALL G E T T I M ( I H R , I M I N , I S E C , I I O O T H )

* Computing the Horizontal and Vertical gradients. CALL GRAD(N,DX,PROF,5) IF(TXZ.EQ.'DT')THEN

P H I 2 = ( 1 8 0 - 2 * I N C ) * P I / 1 8 0 ELSE

P H I 2 = ( 9 0 - I N C ) * P I / 1 8 0 ENDIF SOOT=0 CALL CLEAR WRITE(*,*) WRITE(*,*)'... DO YOU WANT SMOOTHING..' WRITE(*,'(A\)')' USING HANNING FILTER TYPE Y/N -->' READ(*,2)YN

2 FORMAT(A2) IF(YN.EQ.'Y'.OR.YN.EQ.'y')THEN

The output data is smoothened using Hanning filter. SOOT=I CALL SMOOT(XX,N) CALL SMOOT(XZ,N)

ENDIF DO I0 I=I,N

IF((I.EQ.I.AND.SOOT.EQ.I).OR.(I.EQ.N.AND.SOOT.EQ.I))THEN R X ( I ) = 0

ELSE R X ( I ) = X X ( I ) * D C O S ( P H I 2 ) + X Z ( 1 ) * D S I N ( P H I 2 )

ENDIF I0 CONTINUE

SUM=O DO 20 I=I,N

R T ( I ) f S U M SUMfSUM+RX(I)*DX

20 CONTINUE CALL GETTIM(INHR,INMIN,INSEC,INI00TH) WRITE(JOUT,902)DX,N,INC,PROF WRITE(JOUT,903)

Page 25: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

Magnetic dam processing with MAGPROS

WRITE(JOUT,900) WRITE(JOUT,903) IF(JOUT.EQ.1)THEN

CO=7 ELSEIF(JOUT.EQ.3)THEN

C0=50 ENDIF DO 30 I=I,N IF((I.EQ.CO.OR.I.EQ.N+I).AND.JOUT.EQ.1)THEN

C0=C0+8 PAUSE 'HIT RETURN KEY'

ELSEIF((I.EQ.CO.OR.I.EQ.N+I).AND.JOUT.EQ.3)THEN WRITE(JOUT,*)CHAR(12) C0=C0+50

ENDIF IF((I.EQ.I.AND.SOOT.EQ.I).OR.(I.EQ.N.AND.SOOT.EQ.1))THEN

WRITE(JOUT,912)XR(I),BLANK ELSE

WRITE(JOUT,901)XR(I),RX(I) IF(I.NE.N)THEN

WRITE(JOUT,913)RT(I+I ) ENDIF

ENDIF 30 CONTINUE

WRITE(JOUT,903) 900 FORMAT(SX,'.',2X,'INPUT FIELD',3X,'.','GRADIENT AT POLE','.',

> 2X, 'REDUCTION AT POLE',2X,'.') 901 FORHAT(5X,'.',FI2.5,4X,' ',IX,FI2.6,5X,' ',I8X,'.') 913 FORMAT(SX,'.',16X,' ',I8X,' ',IX,FI2.6,5X,' ' ) 902 FORMAT(IOX,'DX=',FI5.5,10X,'N=',I5,10X,'INCL=',F8.3,

> 10X,'PROFILE=',A20) 903 FORMAT(5X,56 ( ' - ' ) ' ) 910 F O R M A T ( I / I / / / / / / / ) 912 FORMAT(5Xtt. J s F 1 2 . 5 , 4 X t ' . ' , l X , A 1 2 , S X , ' ' )

CALL TIMDIFF(IHRpIMIN,ISEC,I10OTH,INHR,INMIN,INSEC,IN10OTH, > JOUT)

RETURN END

* REGRESSION ANALYSIS SUBROUTINE REGR(XX,YY,N,SLOPE,CINTR) IMPLICIT DOUBLE PRECISION (A-H,O-Z) DIMENSION XX(0:49),YY(0:49) SUMX=0 SUHY=0 DO I=0,N

SUMX=SUMX+XX(I) SUMY=SUMY+YY(I)

ENDDO XBAR=SUMX/(N+I) YBAR=SUMY/(N+I) XNUM=0 XDEN=0 DO I=0,N

XNUM=XNUM+(XX(I)-XBAR)*(YY(I)-YBAR) XDEN=XDEN+(XX(I)-XBAR)**2

ENDDO SLOPE=XNUM/XDEN CINTRmYBAR-SLOPE*XBAR RETURN END

* s u b r o u t i n e f o r t i m e d i f f e r e n c e SUBROUTINE T I M D I F F ( I , J , K , L , I 1 , J 1 , K 1 , L 1 , J O U T ) LDEFF=L1-L IF(LDEFF.LT.0)THEN

KI=KI-I LDEFF=100+LDEFF

ENDIF KDEFF=K1-K

IF(KDEFF.LT.0)THEN Jl=Jl-I KDEFF=KDEFF+60

ENDIF

705

CAGEO 20/~.--D

Page 26: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

706 B. NARASIMHA RAO and P. RAMA KRISHNA

JDEFF=JI-J IF(JDEFF.LT.0)THEN

JDEFF=JDEFF+60 11=I1-i

ENDIF IDEFF=II-I WRITE(JOUT,900)IDEFF,JDEFF,KDEFF,LDEFF

900 FORMAT(2X,' TIME TAKEN TO RUN THIS PROGRAM IS'/ > 2X,'hr:min:sec:il00th ',5X,I2,':',I2,':',I2,':',I2)

RETURN END

*********************************me*****************

* This subrotine computes the direct and inverse * * Hartley transforms. The control variable 'INV' * * is equal to 0 for direct and I for inverse. *

****************************************************

SUBROUTINE DHTID(XR,H,NX,INV) IMPLICIT DOUBLE PRECISION (A-H,O-Z) INTEGER T,V DIMENSION XR(250),H(0:249) PI=3.14159265

* Direct Hartley Transform. IF(INV.EQ.0)THEN DO 20 V=0,NX-I

H(V)=O.O DO 30 T=0,NX-1

ANG=PI/4+2.0*PI*V*T/NX 30 H(V)=H(V)+XR(T+I)*2**.5*DSIN(ANG) 20 H(V)=H(V)/NX

RETURN ENDIF

* Inverse Hartley Transform. DO 40 T=0,NX-1

XR(T+I)=0.0 DO 50 V=0,NX-I

ANG=PI/4+2.0*PI*V*T/NX 50 XR(T+I)=XR(T+I)+H(V)*2**.5*DSIN(ANG) 40 CONTINUE

RETURN END

*****************************************************************

* This subroutine opens the data file , edits the input data * * for other options and in common for all subroutines. *

SUBROUTINE DATAIN(N,DX,PROF,CHOICE,INFILE,MODI) IMPLICIT DOUBLE PRECISION (A-H,O-Z) DOUBLE PRECISION INCL COMMON /AB/INCL,ALPHA COMMON /BC/DOUT,DIN COMMON /CD/LVL,H(10) COMMON /EF/ CO CHARACTER*I AP,BA,CHOICE,OC,CO CHARACTER*20 INFILE,PROF,OUTF,INF,BLANK CHARACTER*2 DOUT,DIN CHARACTER*2 YN SAVE OC LOGICAL TEST,CHECK,TEF COMMON /XRI XR(250) CALL CLEAR BLANK=' IF(MODI.NE.I)THEN

3001 WRITE(*,*) WRITE(*,*)' GIVE FILE NAME TO STORE THE DATA ' WRITE(*,*) OC=' ' READ(*,I)INFILE

IF(TEF(INFILE).OR.INFILE.EQ.BLANK)THEN

Page 27: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

Magnetic data processing with MAGPROS 707

700

800

830

WRITE(*,*)CHAR(7) WRITE(*,*)'ERROR:It WRITE(*,*)' characters WRITE(*,*)' or special GO TO 3001 ENDIF

FORMAT(A20) ELSE

I F ( C O . N E . ' ')THEN OC=CO

ENDIF IF(CHECK(OC,CHOICE))THEN

RETURN ENDIF DPR=O IF ( INFILE(2 :2 ) .EQ.CHAR(58) )THEN

DPR=I ENDIF SELECT CASE(CHOICE) C A S E ( ' I ' , ' U ' , ' u ' ) IF(DPR.EQ.I)THEN

OUTF=INFILE(I:2)//'I'//INFILE(3:20) ELSE

OUTF='I'//INFILE ENDIF

CASE('2','C','c') IF(DPR.EQ.I)THEN

OUTF=INFILE(I:2)//'2'//INFILE(3:20) ELSE

OUTF='2'//INFILE ENDIF

C A S E ( ' 3 ' , ' F ' , ' f ' ) IF(DPR.EQ.1)THEN

O U T F = I N F I L E ( I : 2 ) / / ' 3 ' / / I N F I L E ( 3 : 2 0 ) ELSE

O U T F = ' 3 ' / / I N F I L E ENDIF

C A S E ( ' 4 ' , ' A ' , ' a ' ) IF(DPR.EQ.1)THEN

O U T F = I N F I L E ( I : 2 ) / / ' 4 ' / / I N F I L E ( 3 : 2 0 ) ELSE

O U T F = ' 4 ' / / I N F I L E ENDIF

C A S E ( ' 5 ' , ' R ' , ' r ' ) IF(DPR.EQ.1)THEN

OUTF=INFILE(I:2)//'5'//INFILE(3:20) ELSE

OUTF='5'//INFILE ENDIF

CASE('6','D','d') IF(DPR.EQ.1)THEN

OUTF=INFILE(I:2)//'6'//INFILE(3:20) ELSE

OUTF='6'//INFILE ENDIF

END SELECT CALL CLEAR WRITE(*,700)OUTF FORMAT(5X,'YOUR NEW FILE NAME FOR THIS DATA IS=',2X,A20) PAUSE 'HIT ENTER KEY' ENDIF CALL CLEAR IF(MODI.NE.I)THEN

NO2=0 OPEN(3,FILEfINFILE,STATUS='NEW',ERR=900)

ENDIF I F ( O C . E Q . ' ')THEN W R I T E ( * , ' ( A \ ) ' ) ' GIVE NO.OF OBSERVATIONS--> ' READ(*,*,ERR=602)N IF (N. LE. 0 )THEN

GO TO 602 ELSEIF(N.GT.250)THEN

should be alpha-numeric ' only and no blank line' characters are allowed.'

Page 28: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

708

602

500

801

601

501

301

350

310

802

603

502

804 200

604

B. NARASlMHA P.AO and P. RAMA KRLSHNA

WRITE(*,*)CHAR(7) WRITE(*,*)' ERROR : MAGPROS can not accept more than' WRITE(*,*)' 250 values. Try again.' GO TO 830

ENDIF GO TO 500 W R I T E ( * , * ) C H A R ( 7 ) W R I T E ( * , * ) ' E R R O R : I t s h o u l d b e a p o s i t i v e i n t e g e r o n l y ' GO TO 8 3 0

W R I T E ( * , ' ( A \ ) ' ) ' GIVE TRAVERSE NAME--> ' R E A D ( * , I ) P R O F W R I T E ( * , ' ( A \ ) ' ) ' GIVE STATION S P A C I N G - - > ' R E A D ( * , * , E R R f 6 0 1 ) D X I F ( D X . L E . 0 ) T H E N

WRITE(*,*)CHAR(7) WRITE(*,*)' ERROR : It should be positive value only.' GO TO 801

ENDIF GO TO 501 WRITE(*,*)CHAR(7) WRITE(*,*)'ERROR: It should be a numerical value' GO TO 801 ENDIF CONTINUE IF(MODI.EQ.I)THEN

OPEN(4,FILE=INFILE,STATUS='OLD',ERR=901) SELECT CASE(OC) CASE('I','U','u')

READ(4,*)N,DX,LVL,PROF CASE('2','C','c')

READ(4,*)N,INCL,ALPHA,DIN,DOUT,PROF WRITE(*,'(A\)')' GIVE STATION SPACING-->' READ(*,*,ERR=350)DX GO TO 310 WRITE(*,*)CHAR(7) WRITE(*,*)'ERROR: It should be a numerical value' GO TO 301 CONTINUE CASE('3','F','f','4','A','a','6','D','d')

READ(4,*)N,DX,PROF CASE('5','R','r')

READ(4,*)N,DX,PROF,INCL END SELECT

READ(4,*)(XR(I),I =I,N) CLOSE(4) OPEN(3,FILE=OUTF,STATUSf'NEW',ERR=902)

ENDIF SELECT CASE(CHOICE) C A S E ( ' I ' , ' U ' , ' u ' )

W R I T E ( * , ' ( A \ ) ' ) ' NO .OF LEVELS TO BE CONTINUED--> ' R E A D ( * , * , E R R f 6 0 3 ) L V L I F ( L V L . L T . 0 ) T H E N WRITE(*,*)CHAR(7) WRITE(*,*)' ERROR : It should be a positive integer only' GO TO 802 ENDIF GO TO 502

WRITE(*,*)CHAR(7) WRITE(*,*)'ERROR : LVL Should be an integer only' GO TO 802 CONTINUE

DO 10 I = I , L V L W R I T E ( * , 2 0 0 ) I FORMAT(2X, ' G I V E ' , I 3 , ' L E V E L ' ) W R I T E ( * , * ) ' N o t e : - r e f o r u p w a r d c o n t i n u a t i o n ' W R I T E ( * , * ) ' + v e f o r d o w n w a r d c o n t i n u a t i o n ' WRITE(*,'(A\)') ' . . . . . . >?' READ(*,*,ERRffi604)H(I) GO TO 504 WRITE(*,*)CHAR(7) WRITE(*,*)'ERROR : It should be numerical value' GO TO 804

Page 29: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

504 I0

1000

605

505

606

506

1003

903

807

Magnetic data processing with MAGPROS 709

CONTINUE CONTINUE

C A S E ( ' 2 ' , ' C ' , ' c ' ) W R I T E ( * , ' ( A \ ) ' ) ' GIVE MAGNETIC INCLINATION ( i n d e g r e e s ) - - > '

R E A D ( * , * , E R R f 6 0 5 ) I N C L I F ( I N C L . L T . 0 . O R . I N C L . G T . 1 8 0 ) T H E N

W R I T E ( * , * ) C H A R ( 7 ) W R I T E ( * , * ) ' ERROR : GO TO i000

ENDIF GO TO 505 W R I T E ( * , * ) C H A R ( 7 ) W R I T E ( * , * ) ' E R R O R : I t s h o u l d b e n u m e r i c a l v a l u e ' GO TO i000 CONTINUE WRITE(*,'(A)') ' GIVE ANGLE OF STRIKE ' WRITE(*,'(A\)')' +ve from North over East--> ' READ(*,*,ERR=606)ALPHA IF(ALPHA.LT.0.OR.ALPHA.GT.360)THEN WRITE(*,*)CHAR(7) WRITE(*,*)' ERROR : WRITE(*,*)' GO TO 505

ENDIF GO TO 506 WRITE(*,*)CHAR(7) WRITE(*,*)' ERROR : It should be numerical value' GO TO 505 CONTINUE WRITE(*,'(A\)')' GIVE INPUT FIELD ie DT/DH/DZ-->' READ(*,2)DIN FORMAT(A2) IF(.NOT.TEST(DIN))THEN

WRITE(*,*)CHAR(7) WRITE(*,*)' ERROR : INPUT selection wrong' WRITE(*,*)' only DT,DH,DZ are allowed' WRITE(*,*)' only capital letters ' GO TO 506

ENDIF WRITE(*,'(A)')' GIVE OUTPUT FIELD YOU NEED' WRITE(*,'(A\)')' ie DT/DH/DZ---> ' READ(*,2)DOUT IF(.NOT.TEST(DOUT))THEN

WRITE(*,*)CHAR(7) WRITE(*,*)' ERROR : OUTPUT selection wrong.' WRITE(*,*)' Only DT,DH,DZ are allowed' GO TO 1003

ENDIF IF(DIN.EQ.DOUT)THEN

CALL CLEAR WRITE(*,*)CHAR(7) WRITE(*,*)' ERROR : WRITE(*,*)' GO TO 1003

ENDIF CALL CLEAR WRITE(*,903)INCL,ALPHA,DIN,DOUT FORMAT(10X,'MAGNETIC INCLINATION = ',F15.5,/

,10X,'ANGLE OF STRIKE = ',F15.5,/ ,10X,'INPUT FIELD =',A2,/ ,IOX,'OUTPUT FIELD =',A2)

WRITE(*,*) WRITE(*,*) WRITE(*,'(A\)')' DO YOU WANT ANY CHANGE ? <Y/N>-->' READ(*,2)YN IF(YN.EQ.'Y'.OR.YN.EQ.'y')THEN

GO TO I000 ENDIF

CASE('5','R','r') WRITE(*,'(A\)')' GIVE MAGNETIC INCLINATION--> ' READ(*,*,ERR=607)INCL

IF(INCL.LT.0.OR.INCL.GT.180)THEN

I t s h o u l d b e w i t h i n 0 t o 180 d e g r e e s '

I n p u t a n d o u t p u t f i e l d s a r e s a m e . ' T r y a g a i n w i t h c h a n g e s '

I t s h o u l d b e m e a s u r e d f r o m N o r t h ' o v e r E a s t a n d a l w a y s + v e . ( O t o 3 6 0 ) '

Page 30: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

710 B. NARASIMHA RAO and P. RAMA KRISHNA

607

507

904

808 914

608

508

905

30

375

1002

609

509 810

610

510

WRITE(*,*)CHAR(7) WRITE(*,*)' ERROR GO TO 807

ENDIF GO TO 507 WRITE(*,*) WRITE(*,*)'ERROR : GO TO 807 CONTINUE WRITE(*,904)INCL

: It should be within 0 to 180 degrees'

It should be a numerical value'

WRITE(*,*)CHAR(7) WRITE(*,*)' only Y or N is allowed' PAUSE ' HIT ENTER KEY TO CONTINUE' GO TO 375

ENDIF IF(YN.EQ.'Y'.OR.YN.EQ.'y')THEN

WRITE(*,'(A\)')' GIVE SL. NO.-->' READ(*,*,ERR=609)LL GO TO 509 WRITE(*,*)CHAR(7) WRITE(*,*)'ERROR : It should be an integer' GO TO 1002 CONTINUE WRITE(*,'(A\)')' GIVE CORRECT VALUE-->' READ(*,*,ERR=610)XR(LL) GO TO 510 W R I T E ( * , * ) C H A R ( 7 ) W R I T E ( * , * ) ' E R R O R : I t s h o u l d be n u m e r i c a l v a l u e ' GO TO 810 CONTINUE WRITE(*,'(A\)')' MORE CORRECTIONS?? <Y/N>-->' READ(*,2)YN IF(YN.EQ.'Y'.OR.YN.EQ.'y')THEN

GO TO 1002 ENDIF

ELSE

FORMAT(10X,'MAGNETIC INCLINATION =',F15.5) WRITE(*,'(A\)')' ANY CHANGE IN INCLINATION?<Y/N>-->' READ(*,2)YN IF(YN.EQ.'y'.OR.YN.EQ.'Y')THEN

GO TO 807 ENDIF PAUSE 'HIT ENTER KEY TO CONTINUE'

END SELECT CALL CLEAR IF(MODI.NE.I)THEN WRITE(*,*)' .................. INPUT DATA ....................... ' IC=IO IF(IC.GE.N)IC=N EK=I DO 20 I=I,N

WRITE(*,914)I FORMAT(2X,'GIVE ',I3,' VALUE-->'\) READ(*,*,ERR=608)XR(I)

TO 508 WRITE(*,*)CHAR(7) WRITE(*,*)'ERROR : It should he a numerical value' GO TO 808 CONTINUE IF(I.EQ.IC.OR.I.EQ.N)THEN

DO 30 K=KK,IC WRITE(*,9OS)K,XR(K) FORMAT(5X,IS,F15.3) KK=IC

CONTINUE IC=IC+IO IF(IC.GE.N)IC=N WRITE(*,'(A\)')' ANY CHANGES IN INPUT DATA ? <Y/N>-->' READ(*,2)YN IF(YN.EQ.'Y'.OR.YN.EQ.'y'.OR.YN.EQ.'N'.OR.YN.EQ.'n') THEN

CONTINUE

Page 31: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

20

910 911 909

902

900

300

3000

901

3005

Magnetic data processing with MAGPROS 711

ENDIF ENDIF

CONTINUE ENDIF

AP=CHAR(39) BA=CHAR(32)

SELECT CASE(CHOICE) CASE('I','U','u')

WRITE(3,*)N,DX,LVL,BA,AP//PROF//AP WRITE(3,909)(XR(I),I=I,N) WRITE(3,*)(H(I),I=I,LVL)

CASE('2','C','c') WRITE(3,911)N,INCL,ALPHA,BA,AP//DIN//AP,BA,AP//DOUT//AP, BA,AP//PROF//AP

WRITE(3,909)(XR(I),I=I,N) CASE('5','R','r')

WRITE(3,910)N,DX,BA,AP//PROF//AP,INCL WRITE(3,909)(XR(I),I=I,N)

CASE DEFAULT WRITE(3,*)N,DX,BA,AP//PROF//AP WRITE(3,909)(XR(I),I=I,N)

END SELECT FORMAT(I3,FS.2,AI,A23,FS.2) FORMAT(I3,F8.2,F8.2,AI,A4,AI,A4,AI,A24) FORMAT(3X,9FI0.3) CLOSE(3) GO TO 2000 CONTINUE NO2=I WRITE(*,*)CHAR(7) WRITE(*,*)' ERROR: In opening the data file/already exists' PAUSE 'HIT ENTER KEY TO CONTINUE' IF(NO2.EQ.0)THEN

WRITE(*,*)CHAR(7) WRITE(*,300)INFILE INF=INFILE

ELSEIF(NO2.EQ.I)THEN WRITE(*,*)CHAR(7) WRITE(*,300)OUTF INF=OUTF

ENDIF FORMAT(' DO YOU WANT TO REMOVE THE',3X,A20,

' FILE FROM DISK ?'\) WRITE(*,*)'TYPE Y OR N' READ(*,2)YN IF(YN.EQ.'Y'.OR.YN.EQ.'y')THEN

OPEN(5,FILE=INF,STATUS='OLD') CLOSE(5,STATUS='DELETE')

ELSE W R I T E ( * , * ) ' G I V E NEW F I L E NAME'

R E A D ( * , I ) I N F IF(TEF(INF).OR.INF.EQ.BLANK)THEN WRITE(*,*)CHAR(7) WRITE(*,*)'ERROR:It should be alpha-numeric ' WRITE(*,*)' characters only and no blank line' WRITE(*,*)' or special characters are allowed.' GO TO 3000 ENDIF

ENDIF IF(NO2.EQ.0)THEN

INFILE=INF GO TO 800

ELSEIF(NO2.EQ.I)THEN OUTF=INF GO TO 501

ENDIF WRITE($,$)CHAR(7) WRITE(*,*)' ERROR : In opening the file or' WRITE(*,*)' it does not exisit' WRITE(*,'(A\)')' GIVE NEW FILE NAME-->' READ(*,I)INFILE

IF(TEF(INFILE).OR.INFILE.EQ.BLANK)THEN

Page 32: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

712 B. NARASIMHA RAO and P. RAMA KRISHNA

2000

WRITE(*,*)CHAR(7) WRITE(*,*)'ERROR:It WRITE(*,*)' WRITE(*,*)' GO TO 3 0 0 5 ENDIF

GO TO 501 CONTINUE IF(MODI.EQ.1)THEN INFILE=OUTF ENDIF OC=CHOICE RETURN END

FUNCTION TEST(DIN) LOGICAL TEST CHARACTER*2 DIN IF(DIN.EQ.'DT')THEN

TEST=.TRUE. ELSEIF(DIN.EQ.'DZ')THEN

TEST=.TRUE. ELSEIF(DIN.EQ.'DH')THEN

TEST=.TRUE. ELSE

TEST=.FALSE. ENDIF RETURN END FUNCTION CHECK(OC,CHOICE) LOGICAL CHECK CHARACTER*I OC,CHOICE CHECK=.FALSE. SELECT CASE(CHOICE)

CASE('I','U','u') IF(OC.EQ.'I'.OR.OC

CHECK=.TRUE. ENDIF

CASE('2','C', 'c') IF(OC.EQ.'2'.OR.OC

CHECK=.TRUE. ENDIF

CASE('3','F','f') IF(OC.EQ,'3'.OR.OC

CHECK=.TRUE. ENDIF

CASE('4','A','a') IF(OC.EQ.'4'.OR.OC

CHECK=.TRUE. ENDIF

CASE('5','R','r') IF(OC.EQ.'5'.OR.OC

CHECK=.TRUE. ENDIF

CASE('6','D','d') IF(OC.EQ.'6'.OR.OC

CHECK=.TRUE. ENDIF

END SELECT RETURN

END * TESTING THE FILE NAME VALIDITY

FUNCTION TEF(INFILE) LOGICAL TEF CHARACTER*20 INFILE T E F = . F A L S E . N=I DO 20 Kff i l ,20 I F ( I N F I L E ( K : K + I ) . N E . ' ' )THEN NffiN+I

ELSE GO TO 30

ENDIF

s h o u l d b e a l p h a - n u m e r i c ' c h a r a c t e r s o n l y a n d n o b l a n k l i n e ' or special characters are allowed.'

EQ.'U'.OR.OC.EQ.'u')THEN

EQ.'C'.OR.OC.EQ.'c')THEN

EQ.'F'.OR.OC.EQ.'f')THEN

EQ.'A'.OR.OC.EQ.'a')THEN

EQ.'R'.OR.OC.EQ.'r')THEN

E Q . ' D ' . O R . O C . E Q . ' d ' ) T H E N

Page 33: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

20 30

10

* THIS

20

i0

910

900

940

Magnetic data processing with MAGPROS

CONTINUE CONTINUE DO i0 I=l,N-i

IF(INFILE(I:I+I).GE.CHAR(1).AND.INFILE(I:I÷I).LE. CHAR(45).AND.INFILE(I:I+I).NE.CHAR(13))THEN TEF:.TRUE.

ENDIF CONTINUE RETURN END

INCLUDE 'FGRAPH.FI'

ROUTINE PLOTS THE XY GRAPH SUBROUTINE PLOT(X,Y,NR,NPLOT,XTLE,YTLE,TITLE) INCLUDE 'FGRAPH.FD' DOUBLE PRECISION WXI,WY1,WX2,WY2 CHARACTER*25 TITLE CHARACTER*25 XTLE,YTLE CHARACTER*I C INTEGER*2 MAXSX,MAXSY,DUMMY,ROWS,COLS,CW,CH COMMON MAXSX,MAXSY,ROWS,COLS COMMON /NRE/ NIRG(3),N2RG(3),NSG REAL MAXX,MAXY,MINX,MINY RECORD/WXYCOORD/S RECORD/RCCOORD/CURPOS DIMENSION X(0:NR),Y(NR,I) CALL GRAPHICSMODE() C=CHAR(124) CW=(MAXSX+I)/COLS CH=(MAXSY+I)/ROWS MINX=X(1) MAXX=X(1) MINY=Y(I,I) MAXY=Y(I,I) DO l0 I=0,NR-I

DO 20 J=I,NPLOT IF(Y(I+I,J).LE.MINY)MINY=Y(I÷I,J) IF(Y(I+I,J).GE.MAXY)MAXY=Y(I+I,J)

CONTINUE IF(X(I).LE.MINX)MINX=X(I) IF(X(I).GE.MAXX)MAXX:X(I)

CONTINUE NXPXL=MAXSX-20*CW+I NYPXL=39*CH/2+l XSTEP=(MAXX-MINX)/NXPXL YSTEP=(MAXY-MINY)/NYPXL CALL SETVIEWPORT(0,0,20*CW-I,21*CH-I) CALL SETTEXTWINDOW(I,I,ROWS-4,10) L=I DO II=8,17,1 CALL SETTEXTPOSITION(II,6,CURPOS) WRITE(*,910)YTLE(L:L) FORMAT(A1\) L=L+I ENDDO DO II=21,2,-i

VALY=((21-II)*CH)*YSTEP+MINY+CH/2*YSTEP CALL SETTEXTPOSITION(II,9,CURPOS) WRITE(*,900)VALY FORMAT(IX,F8.3,2X,'-'\)

ENDDO CALL SETVIEWPORT(0,21*CH,MAXSX,MAXSY) CALL SETTEXTWINDOW(I,I,ROWS,COLS) CALL SETTEXTPOSITION(I,40,CURPOS) WRITE(*,940)TITLE FORMAT(A25\) VALX=9*CW/Z*XSTEP+MINX DO II=25,80,i0 CALL SETTEXTPOSITION(22,II,CURPOS) WRITE(*,910)C CALL SETTEXTPOSITION(23,II-2,CURPOS) WRITE(*,930)VALX

713

Page 34: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

714 B. NARASIMHA RAO and P. RAMA KRISHNA

930

950

70

40 30

205

300 201

2 00

203

434

VALX=VALX+I0*CW*XSTEP FORMAT(F6.3\)

ENDDO CALL SETTEXTPOSITION(24,40,CURPOS) NRITE(*,950)XTLE FORMAT(IX,A25\) CALL SETVIEWPORT(20*CW,3*CH/2-1,MAXSX,21*CH-1) WXI=DBLE(MINX) WYI=DBLE(MINY) WX2=DBLE(MAXX) WY2=DBLE(MAXY) DUMMY=SETWINDOW(.TRUE.,WXI,WYI,WX2,WY2) DUMMY=RECTANGLE_W($GBORDER,WXI,WYI,WX2,WY2) DO 70 I=0,NR-I WXI=DBLE(MINY+20*YSTEP) DO 30 J=I,NPLOT

DO 40 I=0,NR-I WXI=DBLE(X(I)) WYI=DBLE(Y(I+I,J)) [F(J.EQ.I)THEN

DUNNY=SETCOLOR(4) DUMMY=SETPIXEL_W(WXI,WYI)

ENDIF IF(J.NE.I)THEN

CALL MOVETO_W(WXI,WYI,S) IF(I+I.NE.NR)THEN

WX2=DBLE(X(I+I)) WY2=DBLE(Y(I+2,J)) DUMMY=LINETO_W(WX2,WY2)

ENDIF ENDIF

CONTINUE CONTINUE IF(NPLOT.EQ.I)THEN

CALL SETTEXTPOSITION(24,1,CURPOS) WRITE(*,'(A\)') ' GIVE NUMBER OF SEGMENTS-->' READ(*,*)NSG CALL SETTEXTPOSITION(24,I,CURPOS) WRITE(*,'(A\)') ' IF(NSG.GT.3.OR.NSG.LE.0)THEN

CALL SETTEXTPOSITION(24,1,CURPOS) WRITE(*,'(A\)')' CALL SETTEXTPOSITION(24,I,CURPOS) WRITE(*,'(A\)')'ERROR: NSG >3 OR < OR =0 ' R E A D ( * , * ) GO TO 205

ENDIF DO NGS=I,NSG CALL SETTEXTPOSITION(23,1,CURPOS) WRITE(*,'(A\)') ' CALL SETTEXTPOSITION(23,I,CURPOS) WRITE(*,300)NGS FORMAT(IX,I2,'SEGMENT VALUES'\) CALL SETTEXTPOSITION(24,1,CURPOS) WRITE(*,'(A\)')' GALL SETTEXTPOSITION(24,I,CURPOS) WRITE(*,'(A\)')' ist. REG. POINT->' READ(*,*,ERR=200)NIRG(NGS) GO TO 203 CALL SETTEXTPOSITION(24,1,CURPOS) WRITE(*,'(A\)')' ERROR in 1st. reg point--' R E A D ( * , * ) CALL S E T T E X T P O S I T I O N ( 2 4 , 1 , C U R P O S ) WRITE(*,'(A\)')' GO TO 201 CALL SETTEXTPOSITION(24,1,CURPOS) WRITE(*,'(A\)')' CALL SETTEXTPOSITION(24,I,CURPOS) WRITE(*,'(A\)')' 2nd. REG. POINT->' READ(*,434,ERR=202)N2RG(NGS) FORMAT(I2\) GO TO 204

Page 35: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

Magnetic da~ processing with MAGPROS

202 CALL S E T T E X T P O S I T I O N ( 2 4 , 1 , C U R P O S ) WRITE(*,'(A\)')' ERROR in 2nd. reg polnt --t READ(*,*) CALL SETTEXTPOSITION(24,I,CURPOS) WRITE(*,'(A\)')' GO TO 203

204 CONTINUE IF(NIRG(NGS).GE.N2RG(NGS))THEN CALL SETTEXTPOSITION(24,I,CURPOS) WRITE(*,'(A\)')' ERROR : Ist > 2nd REG '

R E A D ( * , * ) CALL SETTEXTPOSITION(24 ,1 ,CURPOS) WRITE(*,'(A\)')'

GO TO 201 ENDIF

ENDDO ENDIF (:ALL ENDPROGRAM() RETURN END

SUBROUTINE GRAPHICSMODE() INCLUDE 'FGRAPH,FD' INTEGER*2 DUMMY,MAXSX,MAXSY,COLS,ROWS RECORD /VIDEOCONFIG/MYSCREEN COMMON MAXSX,MAXSY,ROWS,COLS

CALL GETVIDEOCONFIG(MYSCREEN) SELECT CASE(MYSCREEN.ADAPTER) CASE($CGA)

DUMMY=SETVIDEOMODE($HRESBW) CASE($OCGA)

DUMMY=SETVIDEOMODE($ORESCOLOR) IF(MYSCREEN.MONITOR,EQ.$MONO)THEN

DUMMY=SETVIDEOMODE($ERESNOCOLOR) ELSE

DUMMY=SETVIDEOMODE{$ERESCOLOR) ENDIF

CASE($VGA,$OVGA,$MCGA) DUMMY=SETVIDEOMODE($VRES2COLOR)

CASE($HGC) DUMMYfSETVIDEOMODE($HERCMONO)

CASE DEFAULT DUMMY=0

END SELECT IF( DUMMY.EQ.0 ) STOP 'ERROR CALL GETVIDEOCONFIG(MYSCREEN) MAXSX=MYSCREEN.NUMXPIXELS-I MAXSY=MYSCREEN.NUMYPIXELS-I ROWS=MYSCREEN.NUMTEXTROWS COLS=MYSCREEN.NUMTEXTCOLS END

SUBROUTINE ENDPROGRAM() INCLUDE 'FGRAPH.FD' INTEGER*2 DUMMY DUMMY=SETVIDEOMODE($DEFAULTMODE) END

* T h i s s u b r o u t i n e s m o o t h e n s t h e o u t p u t d a t a * * on o p t i o n u s i n g 3 p t w e i g h t e d a v e r a g e ( a l s o * * c a l l e d a s H a r m i n g f i l t e r ) . *

SUBROUTINE SMOOT(XR,N) IMPLICIT DOUBLE PRECISION ( A - H , O - Z ) DIMENSION X R ( 2 5 0 ) , Y ( 2 5 0 ) DO 10 I = 2 , N - 1

Y ( I ) f O . 2 5 * X R ( I - 1 ) + 0 . 5 * X R ( I ) + 0 . 2 5 * X R ( I ÷ I ) 10 CONTINUE

:CAN NOT SET GRAPHICS NODE'

715

Page 36: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

716 B. NARASlMHA RAO and P. RAMA KRmHNA

DO 20 I = 2 , N - 1 XR(I)fY(I)

20 CONTINUE XR(1)=0 XR(N)ffi0 RETURN END

* HELP SUBROUTINES FOR INPUT FORMAT * $

$

* H e l p f o r H a r m o n i c a n a l y s i s .

900 > > > > >

RETURN END

$

900

SUBROUTINE HHAR WRITE(* ,900) FORMAT(3X,'You c a n i n p u t t h e d a t a t h r o u g h k e y - b o a r d o r ' , / ,

3 X , ' b y o p e n i n g a d a t a f i l e . S e q u e n c e o f y o u r d a t a i s ' , / , 3X, 'N,DX,PROF (N- n o . o f o b s e r v a t i o n s ; DX- s t a t i o n ' , / , 3 X , ' s p a c i n g ; PROF- name o f p r o f i l e / a r e a ( u p t o 20 ' , / , 3 X , ' c h a r a c t e r s and s h o u l d be i n q u o t e s ) , f r o m 2 n d ' , / , 3 X , ' l i n e o n w a r d s f i e l d d a t a w i t h b l a n k o r c o m m a . ' , / )

Help f o r c o n t i n u a t i o n s .

SUBROUTINE HUP WRITE(* ,900)

FORMAT(3X > 3X > 3X > 3X > 3X > 3x > 3x > 3x > 3x > 3x

RETURN END

'You c a n i n p u t t h e d a t a t h r o u g h k e y - b o a r d o r ' , / , ' b y o p e n i n g a d a t a f i l e . S e q u e n c e o f y o u r d a t a i s ' , / , 'N,DX,LVL,PROF (N- no o f o b s e r v a t i o n s ; DX- s t a t i o n ' , / , ' s p a c i n g ; LVL- no o f l e v e l s t o be c o n t i n u e d ) ' , / , 'PROF- name o f p r o f i l e / a r e a ( u p t o 20 c h a r a c t e r s ' , / , ' a n d s h o u l d be i n q u o t e s ) , f rom 2nd l i n e o n w a r d s ' , / , ' f i e l d d a t a w i t h a b l a n k o r comma. A f t e r t h e d a t a ' , / , ' i s k e y e d - i n , i n a new l i n e i n p u t H ( I ) , I f 1 t o L V L ' , / , ' ( H- h e i g h t o f c o n t i n u a t i o n i n m e t r e s +ve f o r ' , / , ' downward and - v e f o r u p w a r d ) . ' )

Help for magnetic field transformations.

900 FORMAT(3X~ > 3X > 3X > 3X > 3X > 3X > 3X > 3X > 3X > 3X

RETURN END

SUBROUTINE HMAG WRITE(*,900)

'You can input the data through key-board or'j/, 'by opening a data file. Sequence of your data is',/, 'N,INCLIALPHA,DIN,DOUT (N-no of observations',/, 'INCL-magnetic inclination in degrees, ALPHA-',/, 'angle of the strike in degrees from N over E',/, 'DIN- nature of the input field DT/DH/DZ',/, 'DOUT-nature of the converted field, DT-total',/, 'DH-horizontal and DZ-vertical fields. From',/, '2nd line onwards field data with a blank or',/, ' c o m m a , ' )

900

H e l p f o r a n a l y t i c a l s i g n a l a n a l y s i s .

SUBROUTINE HGRAD WRITE(* ,900)

FORMAT(3X,'You c a n i n p u t t h e d a t a t h r o u g h k e y - b o a r d o r ' , / , 3 X , ' b y o p e n i n g a d a t a f i l e . The s e q u e n c e o f y o u r ' , / , 3X,'input data is N,DX,PROF (N-no of observations',/, 3X,'DX-station spacing, PROF-name of the traverse',/, 3 X , ' / a r e a u p t o 20 c h a r a c t e r s i n q u o t e s ) . From 2 n d ' , / , 3 X , ' l i n e o n w a r d s f i e l d d a t a w i t h a b l a n k o r c o m m a . ' , / )

RETURN END

Page 37: MAGPROS: An interactive FORTRAN-77 pc program for magnetic data processing

Magnetic data processing with MAGPROS 717

H e l p f o r r e d u c t i o n t o p o l e .

900

SUBROUTINE HRTP WRITE(* ,900) FORHAT(3X, 'You can i n p u t t h e d a t a t h r o u g h k e y - b o a r d o r ' , / ,

> 3 X , ' b y o p e n i n g a d a t a f i l e . The s e q u e n c e o f y o u r ' , / , > 3X,'input data is N,DX,PROF,INCL (N-no of observations',/, > 3X,'DX-station spacing, PROF-name of the traverse/area',/, > 3Xt'up to 20 characters in quotes, INCL-inclination of',/, > 3X,'the magnetic field in degrees). From 2nd line',/, > 3Xt'onwards field data with a blank or comma. Rest',/, > 3X,'quaries answer through key board.',/)

900

RETURN END

H e l p f o r v e r t i c a l g r a d i e n t s .

SUBROUTINE HDERV WRITE(* ,900) FORHAT(3Xj'You c a n i n p u t t h e d a t a t h r o u g h k e y - b o a r d o r ' t / ,

> 3X,'by opening a data file. The sequence of your',/, > 3X,'input data is N,DX,PROF (N- no of observations',/, > 3 X , ' D X - s t a t i o n s p a c i n g , P R O F - n a m e o f t h e t r a v e r s e ' , / , > 3 X , ' / a r e a u p t o 20 c h a r a c t e r s and s h o u l d be i n q u o t e s . ' , / , > 3X,'From 2nd llne onwards field data with a blank or',/, > 3X,'comma.')

RETURN END