function f=calepi1(slat,slon,elat,elon)

% function to calculate epicentral distance
% assume spherical earth
% output in degree
% longitude from 0 to 360 degree
% stlat; the latitude of the station in degree
% stlon; the longitude of the station in degree
% slat; the latitude of the source in degree
% slat; the longitude of the source in degree


	aa=pi/180;
	b=90-elat;
	c=90-slat;
   if slon < 0
      slon=360+slon;
   end   
   if elon < 0 
      slon=360+slon;
   end   
	
	tbig1=max(slon,elon);
	tbig2=min(slon,elon);

	biga=tbig1-tbig2;
   if biga >= 180
      biga=360-tbig1+tbig2;
   end   
	
	dd=cos(b*aa)*cos(c*aa)+sin(b*aa)*sin(c*aa)*cos(biga*aa);
	f=acos(dd)/aa;

	