	subroutine trh2sh(temp,relhum,press,sphum)
c
c	convert temp, relhum -> specific humidity
c
c	temp (kelvin)
c	relhum (0..100)
c	press (mb)
c	specific humidity (kg/kg)
c
        parameter (RLRV = 2.5E6 / 4.6150E2)
	real temp, relhum, press, sphum, const, es, eofp, w

c	write(*,*) 'rh->sh ',temp,relhum,press

	if (relhum.le.0.0) then
	    sphum = 0.0
	    return
	endif

        CONST = 6.1078 * EXP(RLRV / 273.16)

C       ES, EOFP, PRESS MUST BE IN THE SAME UNITS
C       ES = SATURATION VAPOR PRESSURE
C       EOFP = VAPOR PRESSURE
C       W = MIXING RATIO

	ES = CONST / EXP(RLRV/temp)
	EOFP=RELHUM*ES/100.0
        w = 0.622 * EOFP / (PRESS - 0.378 * EOFP)

c	for g/kg
c	sphum = w / (1.0 + w) * 1000.0

c	for kg/kg
	sphum = w / (1.0 + w)
	return
	end
