c c c c---------------------------------------------- program iocl4 c---------------------------------------------- c c...... computes open/closed flux areas in the ionosphere c produces io_opcl variable ionosphere field c io_opcl=-1 for closed field, io_opcl=1 for c open (polar cap) field. c JR, 5/1995 c add epar,vfl integrals, JR, 2006-07-26 c c common /aaa1bx/bx(92000000) common /aaa1by/by(92000000) common /aaa1bz/bz(92000000) common /aaa1ex/ex(92000000) common /aaa1ey/ey(92000000) common /aaa1ez/ez(92000000) common /aaa2/gx(1000),gy(1000),gz(1000) common /aaa2ex/gxex(1000),gyex(1000),gzex(1000) common /aaa2ey/gxey(1000),gyey(1000),gzey(1000) common /aaa2ez/gxez(1000),gyez(1000),gzez(1000) common /aaa2bx/gxbx(1000),gybx(1000),gzbx(1000) common /aaa2by/gxby(1000),gyby(1000),gzby(1000) common /aaa2bz/gxbz(1000),gybz(1000),gzbz(1000) common /aaa3/mx,my,mz,nx,ny,nz,np,nt,istep common /aaa5/dpi,dti,the1,the2 common /aaa6opcl/opcl(121,361) common /aaa6absepar/absepar(121,361) common /aaa6eparop/eparop(121,361) common /aaa6eparcl/eparcl(121,361) common /aaa6epar1/epar1(121,361) common /aaa6vfl/vfl(121,361) common /ca4/rad,pi,pih,pi2,deg common /aaa9/ f1,f2,rec,rec2,cdate,l1,l2 character*80 f1,f2,rec,rec2,cdate,l1,l2 common /bbb9/idate(5),istat(3) integer ida(6) deg=45.0/atan(1.0) c nsamp=1 call xparse('-sample',1,2,'optional',rec,nsamp,rdum) c c.... dipole time call xparse('-dip',1,1,'required',rec,idum,rdum) call crcol(rec,80,bx,nb) iy=bx(1)+0.1 mo=bx(2)+0.1 id=bx(3)+0.1 ih=bx(4)+0.1 mi=bx(5)+0.1 se=bx(6) call timstr(rec,iy,mo,id,ih,mi,se) call cotr_set(iy,mo,id,ih,mi,se) write(0,*)'iocl4 dipole: ',rec(1:jlen(rec,80)) c call xparse('-time',1,1,'required',rec,idum,rdum) call ccfield(':',rec,1,rec2) ida(1)=int(gets(rec2)+0.1) call ccfield(':',rec,2,rec2) ida(2)=int(gets(rec2)+0.1) call ccfield(':',rec,3,rec2) ida(3)=int(gets(rec2)+0.1) call ccfield(':',rec,4,rec2) ida(4)=int(gets(rec2)+0.1) call ccfield(':',rec,5,rec2) ida(5)=int(gets(rec2)+0.1) call ccfield(':',rec,6,rec2) ida(6)=int(gets(rec2)+0.1) write(0,'(a,6i5)')'iocl4:date: ',ida c c.... get grid call xparse('-grid',1,1,'required',f1,idum,rdum) open(13,file=f1,status='old') l1='any' call getf11(13,gx,nnx,l1,l2,idum) write(0,*)'iocl4 got grid x ',nnx,gx(1),gx(nnx) if(nnx.le.0) stop nx=nnx l1='any' call getf11(13,gy,nny,l1,l2,idum) write(0,*)'iocl4 got grid y ',nny,gy(1),gy(nny) if(nny.le.0) stop ny=nny l1='any' call getf11(13,gz,nnz,l1,l2,idum) write(0,*)'iocl4 got grid z ',nnz,gz(1),gz(nnz) if(nnz.le.0) stop nz=nnz l1='gx-bx' call getf11(13,gxbx,nnx,l1,l2,idum) write(0,*)'iocl4 got grid gx-bx ',nnx,gxbx(1),gxbx(nnx) l1='gy-bx' call getf11(13,gybx,nny,l1,l2,idum) write(0,*)'iocl4 got grid gy-bx ',nny,gybx(1),gybx(nny) l1='gz-bx' call getf11(13,gzbx,nnz,l1,l2,idum) write(0,*)'iocl4 got grid gz-bx ',nnz,gzbx(1),gzbx(nnz) l1='gx-by' call getf11(13,gxby,nnx,l1,l2,idum) write(0,*)'iocl4 got grid gx-by ',nnx,gxby(1),gxby(nnx) l1='gy-by' call getf11(13,gyby,nny,l1,l2,idum) write(0,*)'iocl4 got grid gy-by ',nny,gyby(1),gyby(nny) l1='gz-by' call getf11(13,gzby,nnz,l1,l2,idum) write(0,*)'iocl4 got grid gz-by ',nnz,gzby(1),gzby(nnz) l1='gx-bz' call getf11(13,gxbz,nnx,l1,l2,idum) write(0,*)'iocl4 got grid gx-bz ',nnx,gxbz(1),gxbz(nnx) l1='gy-bz' call getf11(13,gybz,nny,l1,l2,idum) write(0,*)'iocl4 got grid gy-bz ',nny,gybz(1),gybz(nny) l1='gz-bz' call getf11(13,gzbz,nnz,l1,l2,idum) write(0,*)'iocl4 got grid gz-bz ',nnz,gzbz(1),gzbz(nnz) l1='gx-ex' call getf11(13,gxex,nnx,l1,l2,idum) write(0,*)'iocl4 got grid gx-ex ',nnx,gxex(1),gxex(nnx) l1='gy-ex' call getf11(13,gyex,nny,l1,l2,idum) write(0,*)'iocl4 got grid gy-ex ',nny,gyex(1),gyex(nny) l1='gz-ex' call getf11(13,gzex,nnz,l1,l2,idum) write(0,*)'iocl4 got grid gz-ex ',nnz,gzex(1),gzex(nnz) l1='gx-ey' call getf11(13,gxey,nnx,l1,l2,idum) write(0,*)'iocl4 got grid gx-ey ',nnx,gxey(1),gxey(nnx) l1='gy-ey' call getf11(13,gyey,nny,l1,l2,idum) write(0,*)'iocl4 got grid gy-ey ',nny,gyey(1),gyey(nny) l1='gz-ey' call getf11(13,gzey,nnz,l1,l2,idum) write(0,*)'iocl4 got grid gz-ey ',nnz,gzey(1),gzey(nnz) l1='gx-ez' call getf11(13,gxez,nnx,l1,l2,idum) write(0,*)'iocl4 got grid gx-ez ',nnx,gxez(1),gxez(nnx) l1='gy-ez' call getf11(13,gyez,nny,l1,l2,idum) write(0,*)'iocl4 got grid gy-ez ',nny,gyez(1),gyez(nny) l1='gz-ez' call getf11(13,gzez,nnz,l1,l2,idum) write(0,*)'iocl4 got grid gz-ez ',nnz,gzez(1),gzez(nnz) close(13) c c.... 3d file with field call xparse('-f',1,1,'required',f1,idum,rdum) open(13,file=f1,status='old') c c.... get fields , face centered B and edge centered E l1='bx1' call getf31(13,bx,mx,my,mz,l1,l2,istep) write(0,*)'iocl4 got bx ',mx,my,mz,istep l1='by1' call getf31(13,by,mx,my,mz,l1,l2,istep) write(0,*)'iocl4 got by ',mx,my,mz,istep l1='bz1' call getf31(13,bz,mx,my,mz,l1,l2,istep) write(0,*)'iocl4 got bz ',mx,my,mz,istep l1='eflx' call getf31(13,ex,mx,my,mz,l1,l2,istep) write(0,*)'iocl4 got ex ',mx,my,mz,istep l1='efly' call getf31(13,ey,mx,my,mz,l1,l2,istep) write(0,*)'iocl4 got ey ',mx,my,mz,istep l1='eflz' call getf31(13,ez,mx,my,mz,l1,l2,istep) write(0,*)'iocl4 got ez ',mx,my,mz,istep close(13) c c....... trace from ionosphere c fnorth=0.0 fsouth=0.0 iop=0 dphi=2.0*(3.1415927)/float(121-1) dtheta=(3.1415927)/float(361-1) do 550 it=1,361 do 550 ip=1,121 opcl(ip,it)=0.0 absepar(ip,it)=0.0 eparop(ip,it)=0.0 eparcl(ip,it)=0.0 epar1(ip,it)=0.0 vfl(ip,it)=0.0 opcl(ip,it)=-1.0 550 continue rr=3.7 dp=2.0*(3.1415927)/float(nsamp*(121-1)) dt=(3.1415927)/float(nsamp*(361-1)) do 500 it=1,361 write(0,'(a,$)')'.' do 500 ip=1,121 c c..... subsampling, the max of E_par counts xepar=0.0 xvfl=0.0 do 505 ipp=0,nsamp-1 do 505 itt=0,nsamp-1 t=dt*float(nsamp*(it-1)+itt) p=dp*float(nsamp*(ip-1)+ipp)-(3.1415927) c r=1.0 r0=1.0/(sin(t)**2) arg=sqrt(rr/r0) if(arg.ge.0.95) goto 501 t1=asin(arg) if(t.gt.((3.1415927)/2.0))t1=(3.1415927)-t1 call radxyz(rr,p,t1,xsm,ysm,zsm) call cotr('sm ','mhd',xsm,ysm,zsm,xst,yst,zst) if(it.le.(361/2))dir=-0.01 if(it.ge.(361/2))dir= 0.01 call trace4(xst,yst,zst,xe,ye,ze,dir,iend,xxepar,xxvfl) if(iend.ne.0) then xvfl=xvfl+xxvfl if(xxepar.lt.0.0)xepar=min( -abs(xepar), xxepar) if(xxepar.gt.0.0)xepar=max( abs(xepar), xxepar) c write(0,'(4i6,8(1x,f9.2))')iend,nsamp,it,ip,deg*t,deg*p,xst,yst,zst,xe,ye,ze endif 505 continue c epar1(ip,it)=xepar vfl(ip,it)=xvfl/float(nsamp*nsamp) absepar(ip,it)=abs(xepar) if(iend.eq.1) eparcl(ip,it)=xepar if(iend.eq.2) eparop(ip,it)=xepar if(iend.ne.1) then opcl(ip,it)=1.0 iop=iop+1 ff=(6371040.0)*dphi*(6371040.0)*dtheta*sin(t+0.5*dtheta) if(it.lt.(361/2))fnorth=fnorth+ff if(it.ge.(361/2))fsouth=fsouth+ff endif 501 continue 500 continue c write(0,*)iop l1='io_opcl' call datf21(6,opcl,121,361,l1,l2,istep) l1='io_absepar' call datf21(6,absepar,121,361,l1,l2,istep) l1='io_eparop' call datf21(6,eparop,121,361,l1,l2,istep) l1='io_eparcl' call datf21(6,eparcl,121,361,l1,l2,istep) l1='io_epar1' call datf21(6,epar1,121,361,l1,l2,istep) l1='io_vfl' call datf21(6,vfl,121,361,l1,l2,istep) call system('/bin/rm -f tmp.iocl4.fluxarea') open(8,file='tmp.iocl4.fluxarea') write(8,'(6i5,1x,g12.5,1x,a)')ida,fnorth,' pc_area_n' write(8,'(6i5,1x,g12.5,1x,a)')ida,fsouth,' pc_area_s' write(0,'(6i5,1x,g12.5,1x,a)')ida,fnorth, *' open_flux_area_north' write(0,'(6i5,1x,g12.5,1x,a)')ida,fsouth, *' open_flux_area_south' c write(8,*)' open flux, northern hemisphere (m**2)',fnorth c write(8,*)' open flux, southern hemisphere (m**2)',fsouth c write(0,*)' open flux, northern hemisphere (m**2)',fnorth c write(0,*)' open flux, southern hemisphere (m**2)',fsouth close(8) c stop end c------------------------------------------------------------------ subroutine trace4(x1,y1,z1,x2,y2,z2,dir,iend,xepar,xvfl) c------------------------------------------------------------------ common /aaa1bx/bx(92000000) common /aaa1by/by(92000000) common /aaa1bz/bz(92000000) common /aaa1ex/ex(92000000) common /aaa1ey/ey(92000000) common /aaa1ez/ez(92000000) common /aaa2/gx(1000),gy(1000),gz(1000) common /aaa2ex/gxex(1000),gyex(1000),gzex(1000) common /aaa2ey/gxey(1000),gyey(1000),gzey(1000) common /aaa2ez/gxez(1000),gyez(1000),gzez(1000) common /aaa2bx/gxbx(1000),gybx(1000),gzbx(1000) common /aaa2by/gxby(1000),gyby(1000),gzby(1000) common /aaa2bz/gxbz(1000),gybz(1000),gzbz(1000) common /aaa3/mx,my,mz,nx,ny,nz,np,nt,istep common /aaa5/dpi,dti,the1,the2 common /aaa6opcl/opcl(121,361) common /aaa6absepar/absepar(121,361) common /aaa6eparop/eparop(121,361) common /aaa6eparcl/eparcl(121,361) common /aaa6epar1/epar1(121,361) common /aaa6vfl/vfl(121,361) common /ca4/rad,pi,pih,pi2,deg common /aaa9/ f1,f2,rec,rec2,cdate,l1,l2 character*80 f1,f2,rec,rec2,cdate,l1,l2 common /bbb9/idate(5),istat(3) c..... trace till we hit iend=0 xepar=0.0 xvfl=0.0 adir=abs(dir)*(6371040.0) deg=45.0/atan(1.0) x=x1 y=y1 z=z1 itt=0 do 100 itr=1,50000 itt=itt+1 r1=sqrt(x*x+y*y+z*z) call ipol3a(bx,nx,ny,nz,bbx,gxbx,gybx,gzbx,x,y,z,iout1) call ipol3a(ex,nx,ny,nz,eex,gxex,gyex,gzex,x,y,z,iout2) call ipol3a(by,nx,ny,nz,bby,gxby,gyby,gzby,x,y,z,iout1) call ipol3a(ey,nx,ny,nz,eey,gxey,gyey,gzey,x,y,z,iout2) call ipol3a(bz,nx,ny,nz,bbz,gxbz,gybz,gzbz,x,y,z,iout1) call ipol3a(ez,nx,ny,nz,eez,gxez,gyez,gzez,x,y,z,iout2) if(iout1+iout2.ne.0) goto 999 r1=sqrt(x*x+y*y+z*z) if(r1.le.3.5) then x2=x y2=y z2=z iend=1 return endif bb=sqrt(bbx*bbx+bby*bby+bbz*bbz) if(bb.le.0.0) goto 999 s=dir/bb x=x+bbx*s y=y+bby*s z=z+bbz*s if(x.le.gx(3).or.x.ge.gx(nx-2)) iend=2 if(y.le.gy(3).or.y.ge.gy(ny-2)) iend=2 if(z.le.gz(3).or.z.ge.gz(nz-2)) iend=2 xvfl=xvfl+adir/bb xepar=xepar+1.0e-3*adir*(eex*bbx+eey*bby+eez*bbz)/bb if(iend.ne.0) then x2=x y2=y z2=z return endif 100 continue 999 continue c write(0,*)' no hit ',itt,bb,x,y,z,s return end c c-------------------------------------------- subroutine tbdec(iu,a,n) c-------------------------------------------- real a(*) character*72 rec read(iu,*,end=999,err=999)n aa1=alog((1.0e-8)) aa2=alog((1.0e10)) daa=45.0*90.0*90.0/(aa2-aa1) daa=1.0/daa naa=45*90*90 i=0 do 200 k=1,9999999 read(iu,'(a)',end=999,err=999) rec ll=0 do 210 l=1,24 i=i+1 if(i.gt.n) return ll=ll+1 ib1=ichar(rec(ll:ll))-34 ll=ll+1 ib2=ichar(rec(ll:ll))-34 ll=ll+1 ib3=ichar(rec(ll:ll))-34 iaa=ib1+90*(ib2+90*ib3) ineg=0 if(iaa.ge.naa)then ineg=1 iaa=iaa-naa endif aa=iaa aa=(aa*daa)+aa1 aa=exp(aa) if(ineg.gt.0)aa=-aa a(i)=aa 210 continue 200 continue return 999 continue n=-1 return end c-------------------------------------------- subroutine tbenc(iu,a,n) c-------------------------------------------- real a(n) write(iu,*)n aa1=alog((1.0e-8)) aa2=alog((1.0e10)) daa=45.0*90.0*90.0/(aa2-aa1) naa=45*90*90 do 200 i=1,n aa=abs(a(i)) aa=amax1(aa,1.0e-12) aa=daa*(alog(aa)-aa1) iaa=int(aa+0.5) iaa=max0(0,min0(naa-1,iaa)) if(a(i).lt.0.0)iaa=iaa+naa ib1=mod(iaa,90) iaa=iaa/90 ib2=mod(iaa,90) ib3=iaa/90 write(iu,'(a,a,a,$)')char(34+ib1),char(34+ib2),char(34+ib3) iw10=0 if(mod(i,24).eq.0)then write(iu,'(a,$)')char(10) iw10=1 endif 200 continue if(iw10.eq.0)write(iu,'(a,$)')char(10) return end c------------------------------------------------------------------- integer function iifield(c,r,n) c------------------------------------------------------------------- character*80 r character*1 c character*80 rec call ccfield(c,r,n,rec) xx=gets(rec) ii=int(abs(xx+0.5)) if(xx.lt.0)ii=-ii iifield=ii return end c------------------------------------------------------------------- real function rrfield(c,r,n) c------------------------------------------------------------------- character*80 r character*1 c character*80 rec call ccfield(c,r,n,rec) xx=gets(rec) rrfield=xx return end c------------------------------------------------------------------- subroutine ccfield(c,r,n,d) c------------------------------------------------------------------- character*(*) r,d character*1 c d=' ' ic=1 k=0 do 100 i=1,len(r) if(ic.eq.n.and.r(i:i).ne.c) then k=k+1 d(k:k)=r(i:i) if(d(k:k).eq.'~')d(k:k)=' ' endif if(i.gt.1) then if(r(i:i).eq.c.and.r(i-1:i-1).ne.c)ic=ic+1 endif c write(0,*)'cf: ',i,k,'|',r(i:i),'|',ic if(ic.gt.n) goto 190 100 continue 190 continue return end c------------------------------------------------------------------- subroutine cfield(c,r,n,d) c------------------------------------------------------------------- c.... get n'th occurence of 'c' seperated string in r, return in d character*80 r,d character*1 c d=' ' ic=1 k=0 do 100 i=1,80 if(ic.eq.n.and.r(i:i).ne.c) then k=k+1 d(k:k)=r(i:i) if(d(k:k).eq.'~')d(k:k)=' ' endif if(r(i:i).eq.c)ic=ic+1 100 continue return end c---------------------------------------------------------------- subroutine epoch1966(dsecs,iy,mo,id,ih,mi,sec,iimod) c---------------------------------------------------------------- cdoc- cdoc------------------------------------------------------------------- cdoc-epoch1966 cdoc------------------------------------------------------------------- cdoc- cdoc- cdoc-SYNOPSIS: cdoc- subroutine epoch1966(dsec,iy,mo,id,ih,mi,se,iimod) cdoc- cdoc-FUNCTION: cdoc- converts seconds since JAN 1, 1966 0UT to year,month,day,hour, cdoc- minute and second or vice versa cdoc- cdoc-CALL SEQUENCE: cdoc- cdoc-PARAMETERS: cdoc- dsec (in/out): seconds of epoch 1966 cdoc- iy,mo,id,ih,mi,se (in): time in UT cdoc- iimod (in,integer): flag cdoc- iimod=0: convert iy,... to dsec cdoc- iimod!=0: convert dsec to iy,... cdoc- cdoc-NOTE: cdoc- works only for times after JAN 1, 1966, i.e. dsec positive cdoc- cdoc-FILES: cdoc- none cdoc- cdoc-AUTHOR: cdoc- Joachim Raeder, IGPP/UCLA June 1994 cdoc- real*8 dsecs,ss,ds,dso integer rdays(0:11),jdays(0:11) data rdays /31,28,31,30,31,30,31,31,30,31,30,31/ data jdays /31,29,31,30,31,30,31,31,30,31,30,31/ c if(iimod.eq.0) then jj=iy if(jj.lt.100)jj=jj+1900 ss=0.0 do 100 i=1966,jj-1 if(mod(i,4).eq.0) ss=ss+366.0d0*24.0d0*3600.0d0 if(mod(i,4).ne.0) ss=ss+365.0d0*24.0d0*3600.0d0 100 continue do 110 i=1,mo-1 if( mod(jj,4).eq.0 ) ss=ss+dble(jdays(i-1))*24.0d0*3600.0d0 if( mod(jj,4).ne.0 ) ss=ss+dble(rdays(i-1))*24.0d0*3600.0d0 110 continue ss=ss+dble(id-1)*3600.0d0*24.0d0 ss=ss+dble(ih)*3600.0d0 ss=ss+dble(mi)*60.0d0 ss=ss+dble(sec) dsecs=ss c else ss=dsecs ds=0.0d0 dso=0.0d0 jj=1966 do 200 i=0,200 if(mod(jj,4).eq.0) then ds=ds+(366.0d0*24.0d0*3600.0d0) else ds=ds+(365.0d0*24.0d0*3600.0d0) endif if(ds.gt.ss) goto 210 dso=ds jj=jj+1 200 continue 210 continue ss=ss-dso iy=jj-1900 ij=0 if(mod(jj,4).eq.0)ij=1 ds=0.0d0 dso=0.0d0 jj=0 do 220 i=0,11 if(ij.eq.0) then ds=ds+dble(rdays(i))*24.0d0*3600.0d0 else ds=ds+dble(jdays(i))*24.0d0*3600.0d0 endif if(ds.gt.ss) goto 230 dso=ds jj=jj+1 220 continue 230 continue ss=ss-dso mo=jj+1 ds=ss/(24.0d0*3600.0d0) id=int(ds) ss=ss-dble(id)*24.0d0*3600.0d0 id=id+1 ds=ss/3600.0d0 ih=int(ds) ss=ss-dble(ih)*3600.0d0 ds=ss/60.0d0 mi=int(ds) ss=ss-dble(mi)*60.0d0 sec=ss endif c return end c--------------------------------------------------------------- double precision function djul(iy,mo,id,ih,mi,se) c--------------------------------------------------------------- cdoc- cdoc------------------------------------------------------------------- cdoc-djul cdoc------------------------------------------------------------------- cdoc- cdoc-SYNOPSIS: cdoc- double precision function djul(iy,mo,id,ih,mi,se) cdoc- cdoc-FUNCTION: cdoc- converts time to fractional julian days cdoc- cdoc-CALL SEQUENCE: cdoc- cdoc-PARAMETERS: cdoc- iy,mo,id,ih,mi,se (in): time in UT cdoc- djul (out,real*8): fractional julian day cdoc- cdoc-NOTE: cdoc- expected to work for any time after 4500 BC cdoc- cdoc-FILES: cdoc- none cdoc- cdoc-AUTHOR: cdoc- Joachim Raeder, IGPP/UCLA June 1994 cdoc- implicitdoubleprecision(a-h,o-z) real*4 se jy=iy if(jy.lt.100)jy=jy+1900 ier=0 if(jy.lt.1901) ier=1 if(jy.gt.2049) ier=7 if(mo.lt.1.or.mo.gt.12) ier=2 if(id.lt.1.or.id.gt.31) ier=3 if(ih.lt.0.or.ih.gt.23) ier=4 if(mi.lt.0.or.mi.gt.63) ier=5 if(se.lt.0.0.or.se.gt.60.0) ier=6 if(ier.ne.0) then write(0,*)'error djul, ier= ',ier stop endif uthour=dble(float(ih))+(dble(float(mi))/60.0d0)+dble(se)/ *3600.0d0 i1=367*jy i2=(mo+9)/12 i2=(i2+jy)*7 i2=i2/4 i3=(275*mo)/9 i4=100*jy+mo d1=1.0d0 zero=0.0d0 if((dble(i4)-190002.5d0).lt.zero)d1=(-d1) xjd=dble(i1) -dble(i2) +dble(i3) +dble(id) +1721013.5d0 +uthour */24.0d0 -0.5d0*d1 +0.5 djul=xjd return end c--------------------------------------------------------------- subroutine mhdmlt(iy,mo,id,ih,mi,se,pmhd,tmhd,xmlt,colat) c--------------------------------------------------------------- cdoc- cdoc------------------------------------------------------------------- cdoc-mhdmlt cdoc------------------------------------------------------------------- cdoc- cdoc-SYNOPSIS: cdoc- subroutine mhdmlt(iy,mo,id,ih,mi,se,pmhd,tmhd,xmlt,colat) cdoc- cdoc-FUNCTION: cdoc- convert MHD logitude (-180,180) and colatitude (0,180) cdoc- to magnetic local time (0-24) and colatitude cdoc- cdoc-CALL SEQUENCE: cdoc- cdoc-PARAMETERS: cdoc- iy,mo,id,ih,mi,se (in): time in UT cdoc- pmhd (in,real): deg longitude in MHD system (-180.0,180.0) cdoc- tmhd (in,real): deg colatitude in MHD system (0.0,180.0) cdoc- xmlt (out,real): hours magnetic local time (0.0-24.0) cdoc- colat (out,real): deg magnetic colatitude (0.0,180.0) cdoc- cdoc-FILES: cdoc- none cdoc- cdoc-AUTHOR: cdoc- Joachim Raeder, IGPP/UCLA June 1994 cdoc- call cotr_set(iy,mo,id,ih,mi,se) call degxyz(1.0,pmhd,tmhd,x1,y1,z1) call cotr('mhd','sm ',x1,y1,z1,x2,y2,z2) call xyzdeg(x2,y2,z2,rr,pp,tt) colat=tt xmlt=(pp+180.0)/15.0 return end c--------------------------------------------------------- subroutine diptil(iy,mo,id,ih,mi,se,degsun,degy) c--------------------------------------------------------- cdoc- cdoc------------------------------------------------------------------- cdoc-diptil cdoc------------------------------------------------------------------- cdoc- cdoc-SYNOPSIS: cdoc- subroutine diptil(iy,mo,id,ih,mi,se,degsun,degy) cdoc- cdoc-FUNCTION: cdoc- compute dipole tilt angles for a given time cdoc- cdoc-CALL SEQUENCE: cdoc- cdoc-PARAMETERS: cdoc- iy,mo,id,ih,mi,se (in): time in UT cdoc- degsun (out,real): deg tilt in GSE x-z plane cdoc- degy (out,real): deg tilt in GSE y-z plane cdoc- cdoc-FILES: cdoc- none cdoc- cdoc-AUTHOR: cdoc- Joachim Raeder, IGPP/UCLA June 1994 cdoc- data deg /57.29577951d0/ data xsm,ysm,zsm /0.0,0.0,1.0/ call cotr_set(iy,mo,id,ih,mi,se) call cotr('sm ','gse',xsm,ysm,zsm,xgse,ygse,zgse) degsun=deg*atan2(xgse,zgse) degy=deg*atan2(ygse,zgse) return end c---------------------------------------------------- subroutine xyzrad(x,y,z,r,p,t) c---------------------------------------------------- cdoc- cdoc------------------------------------------------------------------- cdoc-xyzrad cdoc------------------------------------------------------------------- cdoc- cdoc-SYNOPSIS: cdoc- subroutine xyzrad(x,y,z,r,p,t) cdoc- cdoc-FUNCTION: cdoc- convert from cartesian to polar coordinates, angles in radian cdoc- cdoc-CALL SEQUENCE: cdoc- cdoc-PARAMETERS: cdoc- x,y,z (in,real): cartesian coordinates cdoc- r,p,t (out,real): polar coordinates, -pi<=p<=pi, 0<=t<=pi cdoc- i.e. colatitude system cdoc- cdoc-FILES: cdoc- none cdoc- cdoc-AUTHOR: cdoc- Joachim Raeder, IGPP/UCLA June 1994 cdoc- r=sqrt(x*x+y*y+z*z) p=0.0 if(abs(x)+abs(y).gt.0.0)p=atan2(y,x) t=0.0 if(r.gt.0.0)t=acos(z/r) return end c---------------------------------------------------- subroutine xyzdeg(x,y,z,r,p,t) c---------------------------------------------------- cdoc- cdoc------------------------------------------------------------------- cdoc-xyzdeg cdoc------------------------------------------------------------------- cdoc- cdoc-SYNOPSIS: cdoc- subroutine xyzdeg(x,y,z,r,p,t) cdoc- cdoc-FUNCTION: cdoc- convert from cartesian to polar coordinates, angles in degrees cdoc- cdoc-CALL SEQUENCE: cdoc- cdoc-PARAMETERS: cdoc- x,y,z (in,real): cartesian coordinates cdoc- r,p,t (out,real): polar coordinates, cdoc- -180.0<=p<=180.0, 0<=t<=180.0 cdoc- i.e. colatitude system cdoc- cdoc-FILES: cdoc- none cdoc- cdoc-AUTHOR: cdoc- Joachim Raeder, IGPP/UCLA June 1994 cdoc- data deg /57.29577951d0/ r=sqrt(x*x+y*y+z*z) p=0.0 if(abs(x)+abs(y).gt.0.0)p=deg*atan2(y,x) t=0.0 if(r.gt.0.0)t=deg*acos(z/r) return end c---------------------------------------------------- subroutine radxyz(r,p,t,x,y,z) c---------------------------------------------------- cdoc- cdoc------------------------------------------------------------------- cdoc-radxyz cdoc------------------------------------------------------------------- cdoc- cdoc-SYNOPSIS: cdoc- subroutine radxyz(r,p,t,x,y,z) cdoc- cdoc-FUNCTION: cdoc- convert from polar coordinates (angles in radian) to cartesian cdoc- cdoc-CALL SEQUENCE: cdoc- cdoc-PARAMETERS: cdoc- r,p,t (in,real): polar coordinates, -pi<=p<=pi, 0<=t<=pi cdoc- i.e. colatitude system cdoc- x,y,z (out,real): cartesian coordinates cdoc- cdoc-FILES: cdoc- none cdoc- cdoc-AUTHOR: cdoc- Joachim Raeder, IGPP/UCLA June 1994 cdoc- st=sin(t) x=r*cos(p)*st y=r*sin(p)*st z=r*cos(t) return end c---------------------------------------------------- subroutine degxyz(r,p,t,x,y,z) c---------------------------------------------------- cdoc- cdoc------------------------------------------------------------------- cdoc-degxyz cdoc------------------------------------------------------------------- cdoc- cdoc-SYNOPSIS: cdoc- subroutine degxyz(r,p,t,x,y,z) cdoc- cdoc-FUNCTION: cdoc- convert from polar coordinates (angles in degrees) to cartesian cdoc- cdoc-CALL SEQUENCE: cdoc- cdoc-PARAMETERS: cdoc- r,p,t (in,real): polar coordinates, cdoc- -180.0<=p<=180.0, 0<=t<=180.0 cdoc- i.e. colatitude system cdoc- x,y,z (out,real): cartesian coordinates cdoc- cdoc-FILES: cdoc- none cdoc- cdoc-AUTHOR: cdoc- Joachim Raeder, IGPP/UCLA June 1994 cdoc- data rad /17.45329252d-3/ pp=p*rad tt=t*rad st=sin(tt) x=r*cos(pp)*st y=r*sin(pp)*st z=r*cos(tt) return end c---------------------------------------------------- subroutine daymon(iy,jd,mo,id) c---------------------------------------------------- cdoc- cdoc------------------------------------------------------------------- cdoc-daymon cdoc------------------------------------------------------------------- cdoc- cdoc-SYNOPSIS: cdoc- subroutine daymon(iy,jd,mo,id) cdoc- cdoc-FUNCTION: cdoc- convert date from julian day system to day - month system cdoc- cdoc-CALL SEQUENCE: cdoc- cdoc-PARAMETERS: cdoc- iy (in,integer): year (nn or nnnn notation) cdoc- jd (in,integer): julian day (1<=jd<=366), january 1 <> jd=1 cdoc- mo (out,integer): month cdoc- id (out,integer): day of month cdoc- cdoc-FILES: cdoc- none cdoc- cdoc-AUTHOR: cdoc- Joachim Raeder, IGPP/UCLA June 1994 cdoc- integer mdays(12,2) data mdays / 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, *334, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335 / leap=1 if(mod(iy,4).eq.0)leap=2 k=1 do 100 i=1,12 if(jd.le.mdays(i,leap)) goto 190 k=i 100 continue 190 continue mo=k id=jd-mdays(k,leap) return end c---------------------------------------------------- integer function julday(iy,mo,id) c---------------------------------------------------- cdoc- cdoc------------------------------------------------------------------- cdoc-julday cdoc------------------------------------------------------------------- cdoc- cdoc-SYNOPSIS: cdoc- integer function julday(iy,mo,id) cdoc- cdoc-FUNCTION: cdoc- convert date from day - month system to julian day system cdoc- cdoc-CALL SEQUENCE: cdoc- cdoc-PARAMETERS: cdoc- iy (in,integer): year (nn or nnnn notation) cdoc- mo (in,integer): month cdoc- id (in,integer): day of month cdoc- julday (out,integer): julian day of year cdoc- cdoc-FILES: cdoc- none cdoc- cdoc-AUTHOR: cdoc- Joachim Raeder, IGPP/UCLA June 1994 cdoc- integer mdays(12,2) data mdays / 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, *334, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335 / jmo=max0(1,min0(12,mo)) leap=1 if(mod(iy,4).eq.0)leap=2 julday=mdays(jmo,leap)+id return end c---------------------------------------------------- subroutine cotr_set(iy,mo,id,ih,mi,se) c---------------------------------------------------- cdoc- cdoc------------------------------------------------------------------- cdoc-cotr_set cdoc------------------------------------------------------------------- cdoc- cdoc-SYNOPSIS: cdoc- subroutine cotr_set(iy,mo,id,ih,mi,se) cdoc- cdoc-FUNCTION: cdoc- computes coordinate transformation matrices cdoc- for cotr() for a given time cdoc- cdoc-CALL SEQUENCE: cdoc- must be called before cotr() cdoc- cdoc-PARAMETERS: cdoc- iy (in,integer): year (nn or nnnn notation) (1900