aboutsummaryrefslogtreecommitdiff
path: root/Ucalc.f
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2021-08-03 14:41:53 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2021-08-03 14:41:53 -0400
commitaf8fa097905186e0d8ba257e4d70d63fe8901264 (patch)
tree647de7ddd01c750e9a80849b3cf79efddf32d4b2 /Ucalc.f
downloadmoog-af8fa097905186e0d8ba257e4d70d63fe8901264.tar.gz
Initial commit
Diffstat (limited to 'Ucalc.f')
-rwxr-xr-xUcalc.f60
1 files changed, 60 insertions, 0 deletions
diff --git a/Ucalc.f b/Ucalc.f
new file mode 100755
index 0000000..273290c
--- /dev/null
+++ b/Ucalc.f
@@ -0,0 +1,60 @@
+
+ real*8 function ucalc (atom,level)
+c******************************************************************************
+c This routine decodes the partition function data. the source
+c is the atlas program of kurucz
+c******************************************************************************
+
+ implicit real*8 (a-h,o-z)
+ include 'Atmos.com'
+ include 'Quants.com'
+ dimension scale(4)
+ data scale/0.001,0.01,0.1,1.0/
+
+ if (level .gt. 500) then
+ temp = level
+ else
+ temp = t(level)
+ endif
+
+ iatom = nint(atom)
+ ion = nint(10.*(atom - float(iatom)))
+ j = 4*(iatom-1) + ion + 1
+
+ if (ion .eq. 0) then
+ chix = xchi1(iatom)
+ elseif (ion .eq. 1) then
+ chix = xchi2(iatom)
+ else
+ chix = xchi3(iatom)
+ endif
+
+ t2000 = chix*2000./11.
+ it = max0(1,min0(9,idint(temp/t2000-0.5)))
+ dt = temp/t2000 - float(it) - 0.5
+ pmin = 1.
+ i = (it+1)/2
+ k1 = nudata(i,j)/100000
+ k2 = nudata(i,j) - k1*100000
+ k3 = k2/10
+ kscale = k2 - k3*10
+ if (mod(it,2) .eq. 0) then
+ p1 = float(k3)*scale(kscale)
+ k1 = nudata(i+1,j)/100000
+ kscale = mod(nudata(i+1,j),10)
+ p2 = float(k1)*scale(kscale)
+ else
+ p1 = float(k1)*scale(kscale)
+ p2 = float(k3)*scale(kscale)
+ if (dt .ge. 0.) go to 13
+ if (kscale .gt. 1.) go to 13
+ kp1 = p1
+ if (kp1 .ne. idint(p2+0.5)) go to 13
+ pmin = kp1
+ endif
+13 ucalc = dmax1(pmin,p1+(p2-p1)*dt)
+
+ return
+ end
+
+