| 1 |
jmc |
1.1 |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 2 |
|
|
!! !! |
| 3 |
|
|
!! GNU General Public License !! |
| 4 |
|
|
!! !! |
| 5 |
|
|
!! This file is part of the Flexible Modeling System (FMS). !! |
| 6 |
|
|
!! !! |
| 7 |
|
|
!! FMS is free software; you can redistribute it and/or modify !! |
| 8 |
|
|
!! it and are expected to follow the terms of the GNU General Public !! |
| 9 |
|
|
!! License as published by the Free Software Foundation. !! |
| 10 |
|
|
!! !! |
| 11 |
|
|
!! FMS is distributed in the hope that it will be useful, !! |
| 12 |
|
|
!! but WITHOUT ANY WARRANTY; without even the implied warranty of !! |
| 13 |
|
|
!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the !! |
| 14 |
|
|
!! GNU General Public License for more details. !! |
| 15 |
|
|
!! !! |
| 16 |
|
|
!! You should have received a copy of the GNU General Public License !! |
| 17 |
|
|
!! along with FMS; if not, write to: !! |
| 18 |
|
|
!! Free Software Foundation, Inc. !! |
| 19 |
|
|
!! 59 Temple Place, Suite 330 !! |
| 20 |
|
|
!! Boston, MA 02111-1307 USA !! |
| 21 |
|
|
!! or see: !! |
| 22 |
|
|
!! http://www.gnu.org/licenses/gpl.txt !! |
| 23 |
|
|
!! !! |
| 24 |
|
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 25 |
|
|
|
| 26 |
|
|
module constants_mod |
| 27 |
|
|
|
| 28 |
|
|
! <CONTACT EMAIL="Bruce.Wyman@noaa.gov"> |
| 29 |
|
|
! Bruce Wyman |
| 30 |
|
|
! </CONTACT> |
| 31 |
|
|
|
| 32 |
|
|
! <HISTORY SRC="http://www.gfdl.noaa.gov/fms-cgi-bin/cvsweb.cgi/FMS/"/> |
| 33 |
|
|
|
| 34 |
|
|
! <OVERVIEW> |
| 35 |
|
|
! Defines useful constants for Earth. |
| 36 |
|
|
! </OVERVIEW> |
| 37 |
|
|
|
| 38 |
|
|
! <DESCRIPTION> |
| 39 |
|
|
! Constants are defined as real parameters, |
| 40 |
|
|
! except for PI and RADIAN, which are calculated in constants_init to promote |
| 41 |
|
|
! consistency and accuracy among various compilers. |
| 42 |
|
|
! |
| 43 |
|
|
! Constants are accessed through the "use" statement. |
| 44 |
|
|
! </DESCRIPTION> |
| 45 |
|
|
|
| 46 |
|
|
!use fms_mod, only: write_version_number |
| 47 |
|
|
|
| 48 |
|
|
implicit none |
| 49 |
|
|
private |
| 50 |
|
|
|
| 51 |
|
|
character(len=128) :: version='$Id: constants.f90,v 10.0 2003/10/27 23:31:04 arl Exp $' |
| 52 |
|
|
character(len=128) :: tagname='$Name: $' |
| 53 |
|
|
logical :: do_log = .true. |
| 54 |
|
|
logical :: module_is_initialized = .FALSE. |
| 55 |
|
|
!dummy variable to use in HUGE initializations |
| 56 |
|
|
real :: realnumber |
| 57 |
|
|
|
| 58 |
|
|
!------------ physical constants --------------- |
| 59 |
|
|
! <DATA NAME="RADIUS" UNITS="m" TYPE="real" DEFAULT="6371.e3"> |
| 60 |
|
|
! radius of the earth |
| 61 |
|
|
! </DATA> |
| 62 |
|
|
! <DATA NAME="OMEGA" UNITS="1/s" TYPE="real" DEFAULT="7.292e-5"> |
| 63 |
|
|
! rotation rate of the planet (earth) |
| 64 |
|
|
! </DATA> |
| 65 |
|
|
! <DATA NAME="GRAV" UNITS="m/s^2" TYPE="real" DEFAULT="9.80"> |
| 66 |
|
|
! acceleration due to gravity |
| 67 |
|
|
! </DATA> |
| 68 |
|
|
! <DATA NAME="RDGAS" UNITS="J/kg/deg" TYPE="real" DEFAULT="287.04"> |
| 69 |
|
|
! gas constant for dry air |
| 70 |
|
|
! </DATA> |
| 71 |
|
|
! <DATA NAME="KAPPA" TYPE="real" DEFAULT="2./7."> |
| 72 |
|
|
! RDGAS / CP_AIR |
| 73 |
|
|
! </DATA> |
| 74 |
|
|
! <DATA NAME="CP_AIR" UNITS="J/kg/deg" TYPE="real" DEFAULT="RDGAS/KAPPA"> |
| 75 |
|
|
! specific heat capacity of dry air at constant pressure |
| 76 |
|
|
! </DATA> |
| 77 |
|
|
! <DATA NAME="CP_OCEAN" UNITS="J/kg/deg" TYPE="real" DEFAULT="3989.24495292815"> |
| 78 |
|
|
! specific heat capacity taken from McDougall (2002) "Potential Enthalpy ..." |
| 79 |
|
|
! </DATA> |
| 80 |
|
|
! <DATA NAME="RHO0" UNITS="kg/m^3" TYPE="real" DEFAULT="1.035e3"> |
| 81 |
|
|
! average density of sea water |
| 82 |
|
|
! </DATA> |
| 83 |
|
|
! <DATA NAME="RHO0R" UNITS="m^3/kg" TYPE="real" DEFAULT="1.0/RHO0"> |
| 84 |
|
|
! reciprocal of average density of sea water |
| 85 |
|
|
! </DATA> |
| 86 |
|
|
! <DATA NAME="RHO_CP" UNITS="J/m^3/deg" TYPE="real" DEFAULT="RHO0*CP_OCEAN"> |
| 87 |
|
|
! (kg/m^3)*(cal/kg/deg C)(joules/cal) = (joules/m^3/deg C) |
| 88 |
|
|
! </DATA> |
| 89 |
|
|
|
| 90 |
|
|
real, public, parameter :: RADIUS = 6371.0e3 |
| 91 |
|
|
real, public, parameter :: OMEGA = 7.292e-5 |
| 92 |
|
|
real, public, parameter :: GRAV = 9.80 |
| 93 |
|
|
real, public, parameter :: RDGAS = 287.04 |
| 94 |
|
|
real, public, parameter :: KAPPA = 2./7. |
| 95 |
|
|
real, public, parameter :: CP_AIR = RDGAS/KAPPA |
| 96 |
|
|
real, public, parameter :: CP_OCEAN = 3989.24495292815 |
| 97 |
|
|
real, public, parameter :: RHO0 = 1.035e3 |
| 98 |
|
|
real, public, parameter :: RHO0R = 1.0/RHO0 |
| 99 |
|
|
real, public, parameter :: RHO_CP = RHO0*CP_OCEAN |
| 100 |
|
|
|
| 101 |
|
|
!------------ water vapor constants --------------- |
| 102 |
|
|
! <DATA NAME="RVGAS" UNITS="J/kg/deg" TYPE="real" DEFAULT="461.50"> |
| 103 |
|
|
! gas constant for water vapor |
| 104 |
|
|
! </DATA> |
| 105 |
|
|
! <DATA NAME="DENS_H2O" UNITS="kg/m^3" TYPE="real" DEFAULT="1000."> |
| 106 |
|
|
! density of liquid water |
| 107 |
|
|
! </DATA> |
| 108 |
|
|
! <DATA NAME="HLV" UNITS="J/kg" TYPE="real" DEFAULT="2.500e6"> |
| 109 |
|
|
! latent heat of evaporation |
| 110 |
|
|
! </DATA> |
| 111 |
|
|
! <DATA NAME="HLF" UNITS="J/kg" TYPE="real" DEFAULT="3.34e5"> |
| 112 |
|
|
! latent heat of fusion |
| 113 |
|
|
! </DATA> |
| 114 |
|
|
! <DATA NAME="HLS" UNITS="J/kg" TYPE="real" DEFAULT="2.834e6"> |
| 115 |
|
|
! latent heat of sublimation |
| 116 |
|
|
! </DATA> |
| 117 |
|
|
! <DATA NAME="TFREEZE" UNITS="degK" TYPE="real" DEFAULT="273.16"> |
| 118 |
|
|
! temp where fresh water freezes |
| 119 |
|
|
! </DATA> |
| 120 |
|
|
|
| 121 |
|
|
real, public, parameter :: RVGAS = 461.50 |
| 122 |
|
|
real, public, parameter :: DENS_H2O = 1000. |
| 123 |
|
|
real, public, parameter :: HLV = 2.500e6 |
| 124 |
|
|
real, public, parameter :: HLF = 3.34e5 |
| 125 |
|
|
real, public, parameter :: HLS = 2.834e6 |
| 126 |
|
|
real, public, parameter :: TFREEZE = 273.16 |
| 127 |
|
|
|
| 128 |
|
|
!-------------- radiation constants ----------------- |
| 129 |
|
|
|
| 130 |
|
|
! <DATA NAME="WTMAIR" UNITS="AMU" TYPE="real" DEFAULT="2.896440E+01"> |
| 131 |
|
|
! molecular weight of air |
| 132 |
|
|
! </DATA> |
| 133 |
|
|
! <DATA NAME="WTMH2O" UNITS="AMU" TYPE="real" DEFAULT="1.801534E+01"> |
| 134 |
|
|
! molecular weight of water |
| 135 |
|
|
! </DATA> |
| 136 |
|
|
! <DATA NAME="WTMO3" UNITS="AMU" TYPE="real" DEFAULT="47.99820E+01"> |
| 137 |
|
|
! molecular weight of ozone |
| 138 |
|
|
! </DATA> |
| 139 |
|
|
! <DATA NAME="DIFFAC" TYPE="real" DEFAULT="1.660000E+00"> |
| 140 |
|
|
! diffusivity factor |
| 141 |
|
|
! </DATA> |
| 142 |
|
|
! <DATA NAME="SECONDS_PER_DAY" UNITS="seconds" TYPE="real" DEFAULT="8.640000E+04"> |
| 143 |
|
|
! seconds in a day |
| 144 |
|
|
! </DATA> |
| 145 |
|
|
! <DATA NAME="AVOGNO" UNITS="atoms/mole" TYPE="real" DEFAULT="6.023000E+23"> |
| 146 |
|
|
! Avogadro's number |
| 147 |
|
|
! </DATA> |
| 148 |
|
|
! <DATA NAME="PSTD" UNITS="dynes/cm^2" TYPE="real" DEFAULT="1.013250E+06"> |
| 149 |
|
|
! mean sea level pressure |
| 150 |
|
|
! </DATA> |
| 151 |
|
|
! <DATA NAME="PSTD_MKS" UNITS="Newtons/m^2" TYPE="real" DEFAULT="101325.0"> |
| 152 |
|
|
! mean sea level pressure |
| 153 |
|
|
! </DATA> |
| 154 |
|
|
! <DATA NAME="REARTH" UNITS="cm" TYPE="real" DEFAULT="6.356766E+08"> |
| 155 |
|
|
! radius of the earth |
| 156 |
|
|
! </DATA> |
| 157 |
|
|
|
| 158 |
|
|
real, public, parameter :: WTMAIR = 2.896440E+01 |
| 159 |
|
|
real, public, parameter :: WTMH2O = 1.801534E+01 |
| 160 |
|
|
real, public, parameter :: WTMO3 = 47.99820E+01 |
| 161 |
|
|
real, public, parameter :: DIFFAC = 1.660000E+00 |
| 162 |
|
|
real, public, parameter :: SECONDS_PER_DAY = 8.640000E+04 |
| 163 |
|
|
real, public, parameter :: AVOGNO = 6.023000E+23 |
| 164 |
|
|
real, public, parameter :: PSTD = 1.013250E+06 |
| 165 |
|
|
real, public, parameter :: PSTD_MKS = 101325.0 |
| 166 |
|
|
real, public, parameter :: REARTH = 6.356766E+08 |
| 167 |
|
|
|
| 168 |
|
|
! <DATA NAME="RADCON" UNITS="deg sec/(cm day)" TYPE="real" DEFAULT="((1.0E+02*GRAV)/(1.0E+04*CP_AIR))*SECONDS_PER_DAY"> |
| 169 |
|
|
! factor used to convert flux divergence to heating rate in degrees per day |
| 170 |
|
|
! </DATA> |
| 171 |
|
|
! <DATA NAME="RADCON_MKS" UNITS="deg sec/(m day)" TYPE="real" DEFAULT="(GRAV/CP_AIR)*SECONDS_PER_DAY"> |
| 172 |
|
|
! factor used to convert flux divergence to heating rate in degrees per day |
| 173 |
|
|
! </DATA> |
| 174 |
|
|
! <DATA NAME="O2MIXRAT" TYPE="real" DEFAULT="2.0953E-01"> |
| 175 |
|
|
! mixing ratio of molecular oxygen in air |
| 176 |
|
|
! </DATA> |
| 177 |
|
|
! <DATA NAME="RHOAIR" UNITS="kg/m^3" TYPE="real" DEFAULT="1.292269"> |
| 178 |
|
|
! reference atmospheric density |
| 179 |
|
|
! </DATA> |
| 180 |
|
|
! <DATA NAME="ALOGMIN" TYPE="real" DEFAULT="-50.0"> |
| 181 |
|
|
! minimum value allowed as argument to log function |
| 182 |
|
|
! </DATA> |
| 183 |
|
|
! <DATA NAME="FREZDK" UNITS="deg K" TYPE="real" DEFAULT="273.16"> |
| 184 |
|
|
! melting point of water |
| 185 |
|
|
! </DATA> |
| 186 |
|
|
|
| 187 |
|
|
real, public, parameter :: RADCON = ((1.0E+02*GRAV)/(1.0E+04*CP_AIR))*SECONDS_PER_DAY |
| 188 |
|
|
real, public, parameter :: RADCON_MKS = (GRAV/CP_AIR)*SECONDS_PER_DAY |
| 189 |
|
|
real, public, parameter :: O2MIXRAT = 2.0953E-01 |
| 190 |
|
|
real, public, parameter :: RHOAIR = 1.292269 |
| 191 |
|
|
real, public, parameter :: ALOGMIN = -50.0 |
| 192 |
|
|
real, public, parameter :: FREZDK = 273.16 |
| 193 |
|
|
|
| 194 |
|
|
!------------ miscellaneous constants --------------- |
| 195 |
|
|
! <DATA NAME="STEFAN" UNITS="W/m^2/deg^4" TYPE="real" DEFAULT="5.6734e-8"> |
| 196 |
|
|
! Stefan-Boltzmann constant |
| 197 |
|
|
! </DATA> |
| 198 |
|
|
! <DATA NAME="VONKARM" TYPE="real" DEFAULT="0.40"> |
| 199 |
|
|
! Von Karman constant |
| 200 |
|
|
! </DATA> |
| 201 |
|
|
! <DATA NAME="PI" TYPE="real" DEFAULT="4.0*ATAN(1.0)"> |
| 202 |
|
|
! ratio of circle circumference to diameter |
| 203 |
|
|
! </DATA> |
| 204 |
|
|
! <DATA NAME="RADIAN" TYPE="real" DEFAULT="180.0/PI"> |
| 205 |
|
|
! degrees per radian |
| 206 |
|
|
! </DATA> |
| 207 |
|
|
! <DATA NAME="C2DBARS" UNITS="dbars" TYPE="real" DEFAULT="1.e-4"> |
| 208 |
|
|
! converts rho*g*z (in mks) to dbars: 1dbar = 10^4 (kg/m^3)(m/s^2)m |
| 209 |
|
|
! </DATA> |
| 210 |
|
|
! <DATA NAME="KELVIN" TYPE="real" DEFAULT="273.15"> |
| 211 |
|
|
! degrees Kelvin at zero Celsius |
| 212 |
|
|
! </DATA> |
| 213 |
|
|
! <DATA NAME="EPSLN" TYPE="real" DEFAULT="1.0e-40"> |
| 214 |
|
|
! a small number to prevent divide by zero exceptions |
| 215 |
|
|
! </DATA> |
| 216 |
|
|
|
| 217 |
|
|
real, public, parameter :: STEFAN = 5.6734e-8 |
| 218 |
|
|
real, public, parameter :: VONKARM = 0.40 |
| 219 |
|
|
real, public :: PI = HUGE(realnumber) |
| 220 |
|
|
real, public :: RADIAN = HUGE(realnumber) |
| 221 |
|
|
real, public, parameter :: C2DBARS = 1.e-4 |
| 222 |
|
|
real, public, parameter :: KELVIN = 273.15 |
| 223 |
|
|
real, public, parameter :: EPSLN = 1.0e-40 |
| 224 |
|
|
!----------------------------------------------------------------------- |
| 225 |
|
|
|
| 226 |
|
|
public constants_init |
| 227 |
|
|
|
| 228 |
|
|
contains |
| 229 |
|
|
|
| 230 |
|
|
! <SUBROUTINE NAME="constants_init"> |
| 231 |
|
|
|
| 232 |
|
|
! <OVERVIEW> |
| 233 |
|
|
! Initialization routine. The purpose of this routine |
| 234 |
|
|
! is initialize the value of PI and RADIAN, and to write the |
| 235 |
|
|
! version and tag name information to the log file. |
| 236 |
|
|
! </OVERVIEW> |
| 237 |
|
|
! <DESCRIPTION> |
| 238 |
|
|
! If this routine is called more than once or called |
| 239 |
|
|
! from other than the root PE it will return silently. |
| 240 |
|
|
! There are no arguments. |
| 241 |
|
|
! </DESCRIPTION> |
| 242 |
|
|
! <TEMPLATE> |
| 243 |
|
|
! call constants_init |
| 244 |
|
|
! </TEMPLATE> |
| 245 |
|
|
|
| 246 |
|
|
subroutine constants_init |
| 247 |
|
|
|
| 248 |
|
|
if (module_is_initialized) return |
| 249 |
|
|
module_is_initialized = .TRUE. |
| 250 |
|
|
|
| 251 |
|
|
if (.not.do_log) return |
| 252 |
|
|
! call write_version_number (version,tagname) |
| 253 |
|
|
do_log = .false. |
| 254 |
|
|
|
| 255 |
|
|
PI = 4.0*ATAN(1.0) |
| 256 |
|
|
RADIAN = 180.0/PI |
| 257 |
|
|
|
| 258 |
|
|
end subroutine constants_init |
| 259 |
|
|
! </SUBROUTINE> |
| 260 |
|
|
|
| 261 |
|
|
!----------------------------------------------------------------------- |
| 262 |
|
|
|
| 263 |
|
|
end module constants_mod |
| 264 |
|
|
|
| 265 |
|
|
! <INFO> |
| 266 |
|
|
|
| 267 |
|
|
! <FUTURE> |
| 268 |
|
|
! 1. Renaming of constants. |
| 269 |
|
|
! </FUTURE> |
| 270 |
|
|
! <FUTURE> |
| 271 |
|
|
! 2. Additional constants. |
| 272 |
|
|
! </FUTURE> |
| 273 |
|
|
! <NOTE> |
| 274 |
|
|
! Constants have been declared as type REAL, PARAMETER. |
| 275 |
|
|
! |
| 276 |
|
|
! The value a constant can not be changed in a users program. |
| 277 |
|
|
! New constants can be defined in terms of values from the |
| 278 |
|
|
! constants module using a parameter statement.<br><br> |
| 279 |
|
|
! |
| 280 |
|
|
! The name given to a particular constant may be changed.<br><br> |
| 281 |
|
|
! |
| 282 |
|
|
! Constants can be used on the right side on an assignment statement |
| 283 |
|
|
! (their value can not be reassigned). |
| 284 |
|
|
! |
| 285 |
|
|
! As PI is calculated, it cannot be a parameter variable. |
| 286 |
|
|
! Do not assign a new value to PI. |
| 287 |
|
|
! |
| 288 |
|
|
!<TESTPROGRAM NAME="EXAMPLE"> |
| 289 |
|
|
!<PRE> |
| 290 |
|
|
! use constants_mod, only: TFREEZE, grav_new => GRAV |
| 291 |
|
|
! real, parameter :: grav_inv = 1.0 / grav_new |
| 292 |
|
|
! tempc(:,:,:) = tempk(:,:,:) - TFREEZE |
| 293 |
|
|
! geopotential(:,:) = height(:,:) * grav_new |
| 294 |
|
|
!</PRE> |
| 295 |
|
|
!</TESTPROGRAM> |
| 296 |
|
|
! </NOTE> |
| 297 |
|
|
|
| 298 |
|
|
! </INFO> |
| 299 |
|
|
|