| 1 | #define WRF_PORT |
|---|
| 2 | |
|---|
| 3 | !------------------------------------------------------------------------ |
|---|
| 4 | ! Based on gffgch.F90 from CAM |
|---|
| 5 | ! Ported to WRF by William.Gustafson@pnl.gov, Nov. 2009 |
|---|
| 6 | !------------------------------------------------------------------------ |
|---|
| 7 | |
|---|
| 8 | #ifdef WRF_PORT |
|---|
| 9 | module module_cam_gffgch |
|---|
| 10 | |
|---|
| 11 | implicit none |
|---|
| 12 | |
|---|
| 13 | private |
|---|
| 14 | public gffgch |
|---|
| 15 | |
|---|
| 16 | contains |
|---|
| 17 | #endif |
|---|
| 18 | |
|---|
| 19 | subroutine gffgch(t ,es ,itype ) |
|---|
| 20 | !----------------------------------------------------------------------- |
|---|
| 21 | ! |
|---|
| 22 | ! Purpose: |
|---|
| 23 | ! Computes saturation vapor pressure over water and/or over ice using |
|---|
| 24 | ! Goff & Gratch (1946) relationships. |
|---|
| 25 | ! <Say what the routine does> |
|---|
| 26 | ! |
|---|
| 27 | ! Method: |
|---|
| 28 | ! T (temperature), and itype are input parameters, while es (saturation |
|---|
| 29 | ! vapor pressure) is an output parameter. The input parameter itype |
|---|
| 30 | ! serves two purposes: a value of zero indicates that saturation vapor |
|---|
| 31 | ! pressures over water are to be returned (regardless of temperature), |
|---|
| 32 | ! while a value of one indicates that saturation vapor pressures over |
|---|
| 33 | ! ice should be returned when t is less than freezing degrees. If itype |
|---|
| 34 | ! is negative, its absolute value is interpreted to define a temperature |
|---|
| 35 | ! transition region below freezing in which the returned |
|---|
| 36 | ! saturation vapor pressure is a weighted average of the respective ice |
|---|
| 37 | ! and water value. That is, in the temperature range 0 => -itype |
|---|
| 38 | ! degrees c, the saturation vapor pressures are assumed to be a weighted |
|---|
| 39 | ! average of the vapor pressure over supercooled water and ice (all |
|---|
| 40 | ! water at 0 c; all ice at -itype c). Maximum transition range => 40 c |
|---|
| 41 | ! |
|---|
| 42 | ! Author: J. Hack |
|---|
| 43 | ! |
|---|
| 44 | !----------------------------------------------------------------------- |
|---|
| 45 | use shr_kind_mod, only: r8 => shr_kind_r8 |
|---|
| 46 | use physconst, only: tmelt |
|---|
| 47 | #ifdef WRF_PORT |
|---|
| 48 | use module_cam_support, only: endrun, & |
|---|
| 49 | iulog |
|---|
| 50 | #else |
|---|
| 51 | use abortutils, only: endrun |
|---|
| 52 | use cam_logfile, only: iulog |
|---|
| 53 | #endif |
|---|
| 54 | |
|---|
| 55 | implicit none |
|---|
| 56 | !------------------------------Arguments-------------------------------- |
|---|
| 57 | ! |
|---|
| 58 | ! Input arguments |
|---|
| 59 | ! |
|---|
| 60 | real(r8), intent(in) :: t ! Temperature |
|---|
| 61 | ! |
|---|
| 62 | ! Output arguments |
|---|
| 63 | ! |
|---|
| 64 | integer, intent(inout) :: itype ! Flag for ice phase and associated transition |
|---|
| 65 | |
|---|
| 66 | real(r8), intent(out) :: es ! Saturation vapor pressure |
|---|
| 67 | ! |
|---|
| 68 | !---------------------------Local variables----------------------------- |
|---|
| 69 | ! |
|---|
| 70 | real(r8) e1 ! Intermediate scratch variable for es over water |
|---|
| 71 | real(r8) e2 ! Intermediate scratch variable for es over water |
|---|
| 72 | real(r8) eswtr ! Saturation vapor pressure over water |
|---|
| 73 | real(r8) f ! Intermediate scratch variable for es over water |
|---|
| 74 | real(r8) f1 ! Intermediate scratch variable for es over water |
|---|
| 75 | real(r8) f2 ! Intermediate scratch variable for es over water |
|---|
| 76 | real(r8) f3 ! Intermediate scratch variable for es over water |
|---|
| 77 | real(r8) f4 ! Intermediate scratch variable for es over water |
|---|
| 78 | real(r8) f5 ! Intermediate scratch variable for es over water |
|---|
| 79 | real(r8) ps ! Reference pressure (mb) |
|---|
| 80 | real(r8) t0 ! Reference temperature (freezing point of water) |
|---|
| 81 | real(r8) term1 ! Intermediate scratch variable for es over ice |
|---|
| 82 | real(r8) term2 ! Intermediate scratch variable for es over ice |
|---|
| 83 | real(r8) term3 ! Intermediate scratch variable for es over ice |
|---|
| 84 | real(r8) tr ! Transition range for es over water to es over ice |
|---|
| 85 | real(r8) ts ! Reference temperature (boiling point of water) |
|---|
| 86 | real(r8) weight ! Intermediate scratch variable for es transition |
|---|
| 87 | integer itypo ! Intermediate scratch variable for holding itype |
|---|
| 88 | ! |
|---|
| 89 | !----------------------------------------------------------------------- |
|---|
| 90 | ! |
|---|
| 91 | ! Check on whether there is to be a transition region for es |
|---|
| 92 | ! |
|---|
| 93 | if (itype < 0) then |
|---|
| 94 | tr = abs(real(itype,r8)) |
|---|
| 95 | itypo = itype |
|---|
| 96 | itype = 1 |
|---|
| 97 | else |
|---|
| 98 | tr = 0.0_r8 |
|---|
| 99 | itypo = itype |
|---|
| 100 | end if |
|---|
| 101 | if (tr > 40.0_r8) then |
|---|
| 102 | write(iulog,900) tr |
|---|
| 103 | #ifdef WRF_PORT |
|---|
| 104 | call wrf_message(iulog) |
|---|
| 105 | #endif |
|---|
| 106 | call endrun ('GFFGCH') ! Abnormal termination |
|---|
| 107 | end if |
|---|
| 108 | ! |
|---|
| 109 | if(t < (tmelt - tr) .and. itype == 1) go to 10 |
|---|
| 110 | ! |
|---|
| 111 | ! Water |
|---|
| 112 | ! |
|---|
| 113 | ps = 1013.246_r8 |
|---|
| 114 | ts = 373.16_r8 |
|---|
| 115 | e1 = 11.344_r8*(1.0_r8 - t/ts) |
|---|
| 116 | e2 = -3.49149_r8*(ts/t - 1.0_r8) |
|---|
| 117 | f1 = -7.90298_r8*(ts/t - 1.0_r8) |
|---|
| 118 | f2 = 5.02808_r8*log10(ts/t) |
|---|
| 119 | f3 = -1.3816_r8*(10.0_r8**e1 - 1.0_r8)/10000000.0_r8 |
|---|
| 120 | f4 = 8.1328_r8*(10.0_r8**e2 - 1.0_r8)/1000.0_r8 |
|---|
| 121 | f5 = log10(ps) |
|---|
| 122 | f = f1 + f2 + f3 + f4 + f5 |
|---|
| 123 | es = (10.0_r8**f)*100.0_r8 |
|---|
| 124 | eswtr = es |
|---|
| 125 | ! |
|---|
| 126 | if(t >= tmelt .or. itype == 0) go to 20 |
|---|
| 127 | ! |
|---|
| 128 | ! Ice |
|---|
| 129 | ! |
|---|
| 130 | 10 continue |
|---|
| 131 | t0 = tmelt |
|---|
| 132 | term1 = 2.01889049_r8/(t0/t) |
|---|
| 133 | term2 = 3.56654_r8*log(t0/t) |
|---|
| 134 | term3 = 20.947031_r8*(t0/t) |
|---|
| 135 | es = 575.185606e10_r8*exp(-(term1 + term2 + term3)) |
|---|
| 136 | ! |
|---|
| 137 | if (t < (tmelt - tr)) go to 20 |
|---|
| 138 | ! |
|---|
| 139 | ! Weighted transition between water and ice |
|---|
| 140 | ! |
|---|
| 141 | weight = min((tmelt - t)/tr,1.0_r8) |
|---|
| 142 | es = weight*es + (1.0_r8 - weight)*eswtr |
|---|
| 143 | ! |
|---|
| 144 | 20 continue |
|---|
| 145 | itype = itypo |
|---|
| 146 | return |
|---|
| 147 | ! |
|---|
| 148 | 900 format('GFFGCH: FATAL ERROR ******************************',/, & |
|---|
| 149 | 'TRANSITION RANGE FOR WATER TO ICE SATURATION VAPOR', & |
|---|
| 150 | ' PRESSURE, TR, EXCEEDS MAXIMUM ALLOWABLE VALUE OF', & |
|---|
| 151 | ' 40.0 DEGREES C',/, ' TR = ',f7.2) |
|---|
| 152 | ! |
|---|
| 153 | end subroutine gffgch |
|---|
| 154 | |
|---|
| 155 | #ifdef WRF_PORT |
|---|
| 156 | end module module_cam_gffgch |
|---|
| 157 | #endif |
|---|