program CONVERT c c This programs performs the different conversions c between moisture variables. The input data required c for this code are supplied through data statements. c parameter (nkt = 46,nk = 39) real p(nkt),t(nkt), q(nkt) real td(nkt),rh(nkt) c c Sample data used for the different computations. c c Pressure : c data p/ 1011.,1000.,955.4,950.0,900.,850.,816.2,800.,782.4,750., & 722.4,700.,687.1,660.5,655.1,650.,641.2,600.,594.3,578.1,566.3, & 550.,544.6,534.9,528.2,517.7,508.9,500.,493.4,477.9,468.7,450., & 444.2,400.,390.3,382.5,369.5,361.5,350.,310.6,300.0,258.2,250., & 235.6,222.5,200./ c c Temperature : c data t/23.0,22.7,22.0,21.8,18.4,13.2,15.6,12.4,11.3,9.9,8.8,7.4, & 6.0,5.9,5.7,5.3,4.6, 1.1,.6,-.6,-1.2,-1.9,-2.5,-3.9,-4.7, & -4.7,-5.7,-6.0,-6.4,-8.5,-9.6,-11.4,-12.1,-17.9,-18.5,-19.5, & -21.6,-22.0,-24.0,-31.0,-32.8,-41.4,-43.1,-46.4,-49.9,-56.3/ c c Specific humidity : c data q/.0170,.0164,.0155,.0155,.0143,.0116,.0119,.0112,.0106, & .0101,.0097,.0091,.0080,.0068,.0066,.0064,.0062,.0055, & .0054,.0057,.0051,.0022,.0020,.0020,.0028,.0025,.0020, & .0007,.0008,.0012,.0027,.0017,.0015,.0013,.0006,.0005, & .0006,.0004,.0003,.0001,.0002,.0001,.0001,.0001,.0001, & .0001/ c c Compute td from q . c write (6,1000) write (6,1001) do 6100 k = 1, nk tt = t(k) + 273.16 pp = p(k) qq = q(k) call TDFRMQ (pp,tt,qq,ttd) td(k) = ttd write (6,1002)k,pp,tt-273.16,qq,ttd-273.16 6100 continue 1000 format (/,10x,'computation of td from q',/) 1001 format (3x,'lev',3x,'pressure',1x,'tempera.',3x,'sp hum',4x, &'dew pt',/) 1002 format (4x,i2,4x,f6.1,4x,f5.1,4x,f6.4,4x,f5.1) c c Compute q from td . c write (6,1003) write (6,1004) do 6102 k = 1, nk tt = t(k) + 273.16 pp = p(k) ttd = td(k) call QFRMTD (pp,tt,ttd,q1) write (6,1005)k,pp,tt-273.16,ttd-273.16,q1 6102 continue 1003 format (/,10x,'computation of q from td',/) 1004 format (3x,'lev',3x,'pressure',1x,'tempera.',3x,'dew pt',4x, &'sp hum',/) 1005 format (4x,i2,4x,f6.1,4x,f5.1,4x,f5.1,4x,f6.4) c c Compute rh from td . c write (6,1008) write (6,1006) do 6104 k = 1, nk tt = t(k) + 273.16 pp = p(k) ttd = td(k) call RHFRMTD (pp,tt,ttd,rrh) rh(k) = rrh write (6,1007)k,pp,tt-273.16,ttd-273.16,rrh 6104 continue 1006 format (3x,'lev',3x,'pressure',1x,'tempera.',3x,'dew pt',4x, &'re hum',/) 1007 format (4x,i2,4x,f6.1,4x,f5.1,4x,f5.1,4x,f6.0) 1008 format (/,10x,'computation of rh from td',/) c c Compute td from rh . c write (6,1009) write (6,1010) do 6106 k = 1, nk tt = t(k) + 273.16 pp = p(k) rrh = rh(k) call TDFRMRH (pp,tt,rrh,td1) write (6,1011)k,pp,tt-273.16,rrh,td1-273.16 6106 continue 1009 format (/,10x,'computation of td from rh',/) 1010 format (3x,'lev',3x,'pressure',1x,'tempera.',3x,'re hum',4x, &'dew pt',/) 1011 format (4x,i2,4x,f6.1,4x,f5.1,4x,f6.0,4x,f5.1) c c Compute q from rh . c write (6,1012) write (6,1013) do 6108 k = 1, nk tt = t(k)+273.16 pp = p(k) rrh = rh(k) call QFRMRH (pp,tt,rrh,qq) q(k) = qq write (6,1014)k,pp,tt-273.16,rrh,qq 6108 continue 1012 format (/,10x,'computation of q from rh',/) 1013 format (3x,'lev',3x,'pressure',1x,'tempera.',3x,'re hum',4x, +'sp hum',/) 1014 format (4x,i2,4x,f6.1,4x,f5.1,4x,f6.0,4x,f6.4) c c Compute rh from q . c write (6,1015) write (6,1016) do 6110 k = 1, nk tt = t(k) + 273.16 pp = p(k) qq = q(k) call rhfrmq (pp,tt,qq,rh1) write (6,1017)k,pp,tt-273.16,qq,rh1 6110 continue 1015 format (/,10x,'computation of rh from q',/) 1016 format (3x,'lev',3x,'pressure',1x,'tempera.',3x,'sp hum',4x, +'re hum',/) 1017 format (4x,i2,4x,f6.1,4x,f5.1,4x,f6.4,4x,f6.0) stop end subroutine QFRMRH (p,t,rh,q) c c This subroutine returns specific humidity values for an c input of relative humidity , temperature and pressure. c c input parameters : c p : pressure in millibar c t : temperature in degrees kelvin c rh : relative humidity in percent c output parameter : c q : specific humidity in gm/gm c a = 17.26 b = 35.86 if (t.le.263.00) a = 21.87 if (t.le.263.00) b = 7.66 e = 6.11*exp(a*(t-273.16)/(t-b)) qs = 0.622*e/(p-0.378*e) q = qs*rh/100. return end subroutine TDFRMRH (p,t,rh,td) c c This subroutine returns dew point values for an input c of temperature, relative humidity and pressure . c c input parameters : c c p : pressure in millibar c t : temperature in degrees kelvin c rh : relative humidity in percent c c output parameter : c c td : dew point temperature in kelvin c a = 17.26 b = 35.86 if (t.le.263.00) a = 21.87 if (t.le.263.00) b = 7.66 e = 6.11*exp(a*(t-273.16)/(t-b)) qs = 0.622*e/(p-0.378*e) q = qs*rh/100. td = t 600 xt = td a = 17.26 b = 35.86 if (xt.le.263.00) a = 21.87 if (xt.le.263.00) b = 7.66 e = 6.11*exp(a*(xt-273.16)/(xt-b)) qs = 0.622*e/(p-0.378*e) td = td-0.05 if (qs.gt.q) go to 600 return end subroutine TDFRMQ (p,t,q,td) c c This subroutine returns dew point values from an input c of temperature,specific humidity and pressure . c c input parameters : c c p : pressure in millibar c t : temperature in degrees kelvin c q : specific humidity in gm/gm c c output parameter : c c td : dew point temperature in degrees kelvin c xq = q tt = t td = t 600 xt = td a = 17.26 b = 35.86 if (xt.le.263.00) a = 21.87 if (xt.le.263.00) b = 7.66 e = 6.11*exp(a*(xt-273.16)/(xt-b)) qs = 0.622*e/(p-0.378*e) td = td-0.05 if ((tt-td).gt.40.0) return if (qs.gt.xq) go to 600 return end subroutine RHFRMQ (p,t,q,rh) c c This subroutine returns relative humidity values from c an input of temperature,specific humidity and pressure. c c input parameters : c c p : pressure in millibar c t : temperature in degrees kelvin c q : specific humidity in gm/gm c output parameter : c c rh : relative humidity in percent c a = 17.26 b = 35.86 if (t.le.263.00) a = 21.87 if (t.le.263.00) b = 7.66 e = 6.11*exp(a*(t-273.16)/(t-b)) qs = 0.622*e/(p-0.378*e) rh = q/qs*100. return end subroutine QFRMTD (p,t,td,q) c c This subroutine returns specific humidity values from an c input of temperature, dew point values and pressure. c c input parameter : c p : pressure in millibar c t : temperature in degrees kelvin c td : dew point temperature in degrees kelvin c output parameter : c q : specific humidity in gm/gm c a = 17.26 b = 35.86 if (td.le.263.00) a = 21.87 if (td.le.263.00) b = 7.66 e = 6.11*exp(a*(td-273.16)/(td-b)) q = 0.622*e/(p-0.378*e) return end subroutine RHFRMTD (p,t,td,rh) c c This subroutine returns relative humidity values from an c input of temperature, dew point values and pressure. c It uses Tetens' formula . c c input parameters : c p : pressure in millibar c t : temperature in degrees kelvin c td : dew point temperature in degrees kelvin c output parameter : c rh : relative humidity in percent c a = 17.26 b = 35.86 if (td.le.263.00) a = 21.87 if (td.le.263.00) b = 7.66 e = 6.11*exp(a*(td-273.16)/(td-b)) q = 0.622*e/(p-0.378*e) a = 17.26 b = 35.86 if (t.le.263.00) a = 21.87 if (t.le.263.00) b = 7.66 e = 6.11*exp(a*(t-273.16)/(t-b)) qs = 0.622*e/(p-0.378*e) rh = q/qs*100. return end