UPP  001
 All Data Structures Files Functions Pages
DEWPOINT.f
Go to the documentation of this file.
1 
43  SUBROUTINE dewpoint( VP, TD)
44 
45  use ctlblk_mod, only: jsta, jend, im, spval
46 !- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
47  implicit none
48 !
49 ! NT IS THE TABLE SIZE
50  integer,PARAMETER :: nt=2000
51 !...TRANSLATED BY FPP 3.00Z36 11/09/90 14:48:53
52 !...SWITCHES: OPTON=I47,OPTOFF=VAE0
53  real,intent(out) :: td(im,jsta:jend)
54  real,intent(in) :: vp(im,jsta:jend)
55  real tdp(nt)
56 !jw
57  integer nn,i,j,jnt
58  real rvp1,rvp2,rt3,rvp3,rlog3,ra,rb,rapb,rtest,rnt,rdvp
59  real rgs,rvp,rlvp,rn,rd,rch,rt,w1,w2
60  real a,b,dntm1
61 
62  logical :: jcontinue=.true.
63 
64 ! PREPARE THE TABLE (TDP=DEWPT AS FCN OF VAPOR PRESS).
65 ! RANGE IN CENTIBARS IS FROM RVP1 THRU RVP2
66  rvp1 = 0.0001e0
67  rvp2 = 10.e0
68 ! THE TRIPLE POINT
69  rt3 = 273.16e0
70 ! VAPOR PRESS AT THE TRIPLE POINT
71  rvp3 = 0.611e0
72  rlog3 = log(rvp3)
73 ! (SPEC HT OF WATER -CSUBP OF VAPOR)/GAS CONST OF VAPOR.
74  ra = 5.0065e0
75 ! LATENT HEAT AT T3/(GAS CONST OF VAPOR * TRIPLE PT TEMP).
76  rb = 19.83923e0
77  rapb = ra + rb
78 ! CRITERION FOR CONVERGENCE OF NEWTON ITERATION
79  rtest = 1.e-6
80 !MEB RTEST=1.E-8 ! PROBABLY WON'T CONVERGE WITH 32-BIT AT THIS CRITERION
81 !
82  rnt = float(nt)
83 ! TABLE INCREMENT IN VAPOR PRESS
84  rdvp = (rvp2-rvp1)/(rnt-1.e0)
85 ! RGS WILL BE THE GUESSED VALUE OF (T3 / DEWPOINT)
86  rgs = 1.e0
87  rvp = rvp1-rdvp
88 !
89  DO 20 nn=1,nt
90  rvp=rvp+rdvp
91  rlvp=log(rvp)-rlog3-rapb
92 ! ***** ENTER NEWTON ITERATION LOOP
93  jcontinue=.true.
94  do while (jcontinue)
95  10 rn=ra*log(rgs)-rapb*rgs-rlvp
96 ! THAT WAS VALUE OF FUNCTION
97 ! NOW GET ITS DERIVATIVE
98  rd=(ra/rgs)-rapb
99 ! THE DESIRED CHANGE IN THE GUESS
100  rch=rn/rd
101  IF( abs(rch) < rtest ) jcontinue=.false.
102 ! NEED MORE ITERATIONS
103  DO WHILE (abs(rch) >= rtest)
104  rgs=rgs-rch
105  EXIT
106  ENDDO
107  ENDDO
108 ! *****
109 ! HAVE ACCURATE ENUF VALUE OF RGS=T3/DEWPOINT.
110  15 rt=rt3/rgs
111  tdp(nn)=rt
112 !
113  20 CONTINUE
114 ! PRINT 25,RVP1,RVP2,TDP(1),TDP(NT)
115 ! 25 FORMAT(/'0', 'IN SUBROUTINE DEWPOINT, THE DEWPT TABLE ',
116 ! 1 'HAS RVP1=', 1PE13.6, ', RVP2=', 1PE13.6,
117 ! 2 ', TDP(1)=', 1PE13.6, ', AND TDP(NT)=',
118 ! 3 1PE13.6, '.'/)
119 ! CONSTANTS FOR USING THE TABLE
120  a = 1./rdvp
121  b = 1. - a*rvp1
122  dntm1 = float(nt) -.01
123 !
124 !X END IF
125 !
126 ! *********** ENTER TO USE THE TABLE. ************
127 !
128 !$omp parallel do private(i,j,w1,w2,jnt)
129  DO j=jsta,jend
130  DO i=1,im
131  IF(vp(i,j)<spval)THEN
132  w1 = min(max((a*vp(i,j)+b),1.0),dntm1)
133  w2 = aint(w1)
134  jnt = int(w2)
135  td(i,j) = tdp(jnt) + (w1-w2)*(tdp(jnt+1)-tdp(jnt))
136  ELSE
137  td(i,j) = spval
138  ENDIF
139  ENDDO
140  ENDDO
141 !
142 !
143  RETURN
144  END