#Metview Macro


#  **************************** LICENSE START ***********************************
# 
#  Copyright 2019 ECMWF. This software is distributed under the terms
#  of the Apache License version 2.0. In applying this license, ECMWF does not
#  waive the privileges and immunities granted to it by virtue of its status as
#  an Intergovernmental Organization or submit itself to any jurisdiction.
# 
#  ***************************** LICENSE END ************************************
# 
#=============================================================================
# Function      : virtual temperature
#
# OneLineDesc   : Computes the virtual temperature for a given temperature and specific humidity
#
# Parameters    : t - temperature (K)
#		 		  q - specific humidity (kg/kg)
#           
# Return Value  : the virtual temperature (K)
#
#===============================================================================

function virtual_temperature(t, q)

    epsilon = 0.621981
    c1 = (1 - epsilon) /epsilon
    res = t * (1 + c1 *q)
    
    if type(res) = "fieldset" then
        res = grib_set_long(res, ["paramId", 300012])
    end if

    return res

end virtual_temperature
