/[MITgcm]/MITgcm_contrib/verification_other/atm_gray/input/calc_Qsat.m
ViewVC logotype

Contents of /MITgcm_contrib/verification_other/atm_gray/input/calc_Qsat.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Sun Jul 7 23:58:23 2013 UTC (12 years ago) by jmc
Branch: MAIN
CVS Tags: checkpoint64k, checkpoint64x, checkpoint64z, checkpoint64o, checkpoint64p, checkpoint64r, checkpoint64w, checkpoint64v, checkpoint66g, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, checkpoint66j, checkpoint66i, checkpoint66h, checkpoint64m, checkpoint65z, checkpoint65x, checkpoint65y, checkpoint65r, checkpoint65s, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65u, checkpoint65j, checkpoint67a, checkpoint67b, checkpoint65i, checkpoint67d, checkpoint65m, checkpoint65c, checkpoint65a, checkpoint65f, checkpoint65e, checkpoint65h, checkpoint65, checkpoint65n, HEAD
a 26 levels version for CS-32 grid

1 function [qsat,dQdT]=calc_Qsat(kpot,p,t);
2 % [qsat,dQdT]=calc_Qsat(kpot,p,t);
3 % kpot=0 : t = T = absolute Temp ; kpot=1 : t = theta = pot.temp
4 % p = normalized pressure = p/1000.mb
5 % output: qsat (g/kg) ; d.qsat/d.T
6 % ktyp=1 : p in mb ; t = absolute Temp ;
7
8 g=9.81;
9 kappa=2./7.;
10
11 np=prod(size(p));
12 nt=prod(size(t));
13 nx=nt/np;
14 if nx ~= fix(nx) | nx < 1
15 fprintf(' Pb in dimensions: dim_p,dim_t= %i , %i ; ratio= %f \n',np,nt,nx);
16 qsat=0.; dQdT=0.;
17 return
18 end
19
20 T=reshape(t,nx,np);
21 P=reshape(p,1,np);
22 if kpot == 1,
23 factp=P.^kappa;
24 fp=ones(nx,1)*factp;
25 size(fp);
26 T=fp.*T;
27 end
28
29 e0=6.108e-3 ; c1=17.269 ; c2=21.875 ; t0c=273.16 ; ct1=35.86 ; ct2=7.66 ;
30 c0q=622. ; c1q=0.378 ;
31
32 qsat=zeros(nx,np);
33 dQdT=zeros(nx,np);
34
35 for k=1:np,
36 for j=1:nx,
37 if T(j,k) >= t0c
38 qE=e0*exp(c1*(T(j,k)-t0c)/(T(j,k)-ct1)) ;
39 qsat(j,k)=c0q*qE/(P(k)-c1q*qE);
40 dQdT(j,k)=c1*P(k)*qsat(j,k)/(P(k)-c1q*qE)*(t0c-ct1)/(T(j,k)-ct1)^2 ;
41 elseif T(j,k) > ct2
42 qE=e0*exp(c2*(T(j,k)-t0c)/(T(j,k)-ct2)) ;
43 qsat(j,k)=c0q*qE/(P(k)-c1q*qE);
44 dQdT(j,k)=c2*P(k)*qsat(j,k)/(P(k)-c1q*qE)*(t0c-ct2)/(T(j,k)-ct2)^2 ;
45 end
46 end
47 end
48
49 return

  ViewVC Help
Powered by ViewVC 1.1.22