24 subroutine cgeomag(yearin, llh, h, icon)
28 #include "Zmagfield.h" 38 real*4 gnm(nmax, 0:nmax), hnm(nmax, nmax), year
39 real*4 gnmd(nmax, 0:nmax), hnmd(nmax, nmax)
41 common /zmagcoef/ gnm, gnmd, hnm, hnmd, year, nmx
46 real*4 r, sumn, sume, sumd, t, cost, sint, x, tlonr, gmnc,
47 * cosml, sinml, hmnc, temp
49 real*4 ssumd, ssumn, ssume
52 real*4 kdpmnxsinn, kpmnxn, kpmnxisinn
56 if(
llh.
sys .eq.
'llh')
then 63 if( abs(yearin-year) .gt. 7.)
then 66 *
' Year spec. for geomag data is invalid.', 1)
68 elseif(abs(cdata.r(1)) .gt. 90.5
d0)
then 71 elseif(abs(cdata.r(2)) .gt. 360.5
d0)
then 74 elseif(cdata.r(3) .gt. 100000.
d3)
then 77 elseif(cdata.r(3) .lt. -3000.
d3)
then 82 r=1./( 1.+cdata.r(3)/eradius )
87 t=(90.-cdata.r(1))*torad
92 tlonr=cdata.r(2)*torad
103 ssumn = ssumn+ (gmnc*cosml+hmnc*sinml)*
104 * kdpmnxsinn(m, n, sint, x)
105 ssume = ssume+ m *(-gmnc*sinml + hmnc*cosml)
106 * * kpmnxisinn(m, n, sint, x)
107 ssumd = ssumd + (gmnc*cosml+ hmnc*sinml)
108 * * kpmnxn(m, n, sint, x)
110 ssumn = ssumn + gmnc*kdpmnxsinn(m, n, sint, x)
111 ssumd = ssumd + gmnc*kpmnxn(m, n, sint, x)
115 sumn = sumn + ssumn*temp
116 sume = sume + ssume*temp
117 sumd = sumd + ssumd*temp *(n + 1)
129 call cerrormsg(
'Geometrical input data wrong', 0)
135 character*(*) filepath
144 real*4 gnm(nmax, 0:nmax), hnm(nmax, nmax), year
145 real*4 gnmd(nmax, 0:nmax), hnmd(nmax, nmax)
147 common /zmagcoef/ gnm, gnmd, hnm, hnmd, year, nmx
152 integer devn, icon, leng, kgetenv
158 if(filepath .eq.
' ')
then 161 leng = kgetenv(
"COSMOSTOP"//null, path)
164 *
'Env. variable "COSMOSTOP" cannot be found', 0)
166 path = path(1:leng)//
"/Data/Geomag/igrf" 170 call copenf(devn, path(1:klena(path)), icon)
174 *
'above file cannot be opened for geomagnetic data', 0)
178 read(devn,
'(a)') msg
179 if( index(msg,
'DGRF') .gt. 0
180 * .or. index(msg,
'IGRF') .gt. 0 )
then 183 write(*,*)
' aaaaaaa' 186 elseif(index(msg,
'igrf') .gt. 0 )
then 189 write(*,*)
' bbbbbbbbbbb' 192 elseif(index(msg,
'WMM') .gt. 0)
then 194 call cgmgwmm(devn, path, yearin)
197 call cerrormsg(
'above data for geomag is strange',0)
201 subroutine cgmgigrf(devn, filepath, yearin)
205 character*(*) filepath
208 integer i, j, store, m, n
211 real*4 yearx, dy, coef, g, h, dg, dh
217 real*4 gnm(nmax, 0:nmax), hnm(nmax, nmax), year
218 real*4 gnmd(nmax, 0:nmax), hnmd(nmax, nmax)
220 common /zmagcoef/ gnm, gnmd, hnm, hnmd, year, nmx
229 read(devn,
'(a)', end=1000) msg
231 do while( index(msg,
'DGRF') .eq. 0 .and.
232 * index(msg,
'IGRF') .eq. 0 .and.
233 * index(msg,
'igrf') .eq. 0 )
234 read(devn,
'(a)', end=1000) msg
236 if( index(msg,
'igrf') .ne. 0 )
then 238 read(devn,
'(a)', end=1000) msg
239 read(msg,
'(12x, f6.1)') yearx
241 write(*,*)
' yearx=',yearx
244 read(msg,
'(12x, f8.2)') yearx
246 if(store .eq. 0 .and. yearin - yearx .lt. 5.0
247 * .and. yearin .ge. yearx)
then 250 elseif(store .eq. 1 .and. yearin .lt. yearx)
then 253 coef = ( yearin - year)/dy
256 write(*,*)
' store=',store,
'yearin=',yearin
258 if( store .gt. 0 )
then 260 read(devn,
'(a)', end=1000) msg
261 if( index(msg,
'DGRF') .gt. 0 .or.
262 * index(msg,
'IGRF') .gt. 0 .or.
263 * index(msg,
'igrf') .gt. 0 )
then 267 if(yearx .ge. 2005.)
then 268 read(msg, *) n, m, g, h
272 read(msg,
'(2i2, 2f8.1,2f8.2)')
275 if( n .gt. nmax )
then 278 *
' n=',n,
' for geomag data > ', nmx
285 *
' n=',n,
' for geomag data <=0' 288 if(m .lt. 0 .or. m .gt. n)
then 291 *
' m=',m,
' for geomag data < 0 or > n' 294 if(store .eq. 1)
then 301 elseif( store .eq. 2)
then 302 gnm(n, m) =( g-gnm(n, m)) * coef + gnm(n,m)
305 hnm(n, m) = ( h-hnm(n, m)) * coef + hnm(n,m)
310 *
'store value error in cgeomag', 0)
315 if( store .eq. 2)
goto 1000
321 if(store .eq. 1)
then 326 gnm(n, m) = gnm(n, m) + dy*gnmd(n, m)
328 hnm(n, m) = hnm(n,m) + dy*hnmd(n, m)
334 call cerrormsg(
'Geomagnetic data has been read from', 1)
336 write(msg2, *)
' year=',yearin,
' # of expansion terms=', nmx
338 if(store .eq. 0)
then 340 *
'Geomagnetic data has no appropriate data', 0)
345 subroutine cgmgwmm(devn, filepath, yearin)
349 character*(*) filepath
352 integer i, j, store, m, n
354 real*4 yearx, dy, coef, g, h, dg, dh
360 real*4 gnm(nmax, 0:nmax), hnm(nmax, nmax), year
361 real*4 gnmd(nmax, 0:nmax), hnmd(nmax, nmax)
363 common /zmagcoef/ gnm, gnmd, hnm, hnmd, year, nmx
372 read(devn,
'(a)', end=1000) msg
374 do while(index(msg,
'WMM') .eq. 0)
375 read(devn,
'(a)', end=1000) msg
378 if(store .eq. 0 .and. yearin - yearx .lt. 5.0
379 * .and. yearin .ge. yearx)
then 382 elseif(store .eq. 1 .and. yearin .lt. yearx)
then 385 coef = ( yearin - year)/dy
387 if( store .gt. 0 )
then 389 read(devn,
'(a)', end=1000) msg
390 if(index(msg,
'WMM') .gt. 0)
then 394 if(msg(1:3) .eq.
'999')
then 398 read(msg, *) n, m, g, h, dg, dh
401 if( n .gt. nmax )
then 404 *
' n=',n,
' for geomag data > ',
412 *
' n=',n,
' for geomag data <=0' 415 if(m .lt. 0 .or. m .gt. n)
then 418 *
' m=',m,
' for geomag data < 0 or > n' 421 if(store .eq. 1)
then 428 elseif( store .eq. 2)
then 430 * ( g-gnm(n, m)) * coef + gnm(n,m)
434 * ( h-hnm(n, m)) * coef + hnm(n,m)
439 *
'store value error in cgeomag', 0)
445 if(store .eq. 2)
goto 1000
451 if(store .eq. 1)
then 456 gnm(n, m) = gnm(n, m) + dy*gnmd(n, m)
458 hnm(n, m) = hnm(n,m) + dy*hnmd(n, m)
464 call cerrormsg(
'Geomagnetic data has been read from', 1)
466 write(msg, *)
' year=',yearin,
' # of expansion terms=', nmx
468 if(store .eq. 0)
then 470 *
'Geomagnetic data has no appropriate data', 0)
487 real*4 gnm(nmax, 0:nmax), hnm(nmax, nmax), year
488 real*4 gnmd(nmax, 0:nmax), hnmd(nmax, nmax)
490 common /zmagcoef/ gnm, gnmd, hnm, hnmd, year, nmx
493 write(*,*)
'year=',year,
' nmax=', nmx
494 write(*,
'(" m n gnm hnm dgnm dhnm")')
498 write(*,
'(2i3,2f7.0,2f7.1)') m, n,
499 * gnm(n, m), 0., gnmd(n, m), 0.
501 write(*,
'(2i3,2f7.0,2f7.1)') m, n,
502 * gnm(n, m), hnm(n,m), gnmd(n,m), hnmd(n,m)
integer npitbl real *nx parameter(n=101, npitbl=46, nx=n-1) real *8 uconst
subroutine cerrormsg(msg, needrtn)
! for length to thickness conversion or v v ! integer maxnodes real Hinf ! This is used when making table for dim simulation ! The slant length for vertical height to km is ! divided by LenStep m steps ! It can cover the slant length of about km for cos
subroutine crdgeomag(filepath, yearin)
block data cblkIncident data *Za1ry *HeightOfInj d3
latitude latitude this system is used *****************************************************************! type coord sequence union map real z z in m endmap xyz map real ! latitude in deg is to the north ! longitude in deg is to the east *h ! height in m endmap llh map real ! polar angle ! azimuthal angle *radius ! radial distance endmap sph endunion character *sys ! which system llh
subroutine cgeomag(yearin, llh, h, icon)
*Zfirst p fm *Zfirst p Zfirst p Zfirst p *Zfirst p *Zfirst pos xyz Zfirst pos xyz sys
subroutine cgmgwmm(devn, filepath, yearin)
subroutine ctranscoord2(sys, a, b)
subroutine cgmgigrf(devn, filepath, yearin)
block data cblkEvhnp ! currently usable models data RegMdls ad *special data *Cekaon d0
subroutine copenf(io, fnin, icon)
dE dx *! Nuc Int sampling table h
subroutine csetmagfield(sys, b1, b2, b3, b)
brief set Calculated magnetic field to /magfield/ b