[2293] | 1 | MODULE etat0dyn |
---|
| 2 | ! |
---|
| 3 | !******************************************************************************* |
---|
| 4 | ! Purpose: Create dynamical initial state using atmospheric fields from a |
---|
| 5 | ! database of atmospheric to initialize the model. |
---|
| 6 | !------------------------------------------------------------------------------- |
---|
| 7 | ! Comments: |
---|
| 8 | ! |
---|
| 9 | ! * This module is designed to work for Earth (and with ioipsl) |
---|
| 10 | ! |
---|
| 11 | ! * etat0dyn_netcdf routine can access to NetCDF data through the following |
---|
| 12 | ! routine (to be called after restget): |
---|
| 13 | ! CALL startget_dyn3d(varname, lon_in, lat_in, pls, workvar,& |
---|
[2336] | 14 | ! champ, lon_in2, lat_in2) |
---|
[2293] | 15 | ! |
---|
| 16 | ! * Variables should have the following names in the NetCDF files: |
---|
| 17 | ! 'U' : East ward wind (in "ECDYN.nc") |
---|
| 18 | ! 'V' : Northward wind (in "ECDYN.nc") |
---|
| 19 | ! 'TEMP' : Temperature (in "ECDYN.nc") |
---|
| 20 | ! 'R' : Relative humidity (in "ECDYN.nc") |
---|
| 21 | ! 'RELIEF' : High resolution orography (in "Relief.nc") |
---|
| 22 | ! |
---|
| 23 | ! * The land mask and corresponding weights can be: |
---|
| 24 | ! 1) already known (in particular if etat0dyn has been called before) ; |
---|
| 25 | ! in this case, ANY(masque(:,:)/=-99999.) = .TRUE. |
---|
| 26 | ! 2) computed using the ocean mask from the ocean model (to ensure ocean |
---|
| 27 | ! fractions are the same for atmosphere and ocean) for coupled runs. |
---|
| 28 | ! File name: "o2a.nc" ; variable name: "OceMask" |
---|
| 29 | ! 3) computed from topography file "Relief.nc" for forced runs. |
---|
| 30 | ! |
---|
| 31 | ! * There is a big mess with the longitude size. Should it be iml or iml+1 ? |
---|
| 32 | ! I have chosen to use the iml+1 as an argument to this routine and we declare |
---|
| 33 | ! internaly smaller fields when needed. This needs to be cleared once and for |
---|
| 34 | ! all in LMDZ. A convention is required. |
---|
| 35 | !------------------------------------------------------------------------------- |
---|
| 36 | USE ioipsl, ONLY: flininfo, flinopen, flinget, flinclo, histclo |
---|
| 37 | USE assert_eq_m, ONLY: assert_eq |
---|
[2597] | 38 | USE comconst_mod, ONLY: pi, cpp, kappa |
---|
[2600] | 39 | USE comvert_mod, ONLY: ap, bp, preff, pressure_exner |
---|
[2673] | 40 | USE temps_mod, ONLY: annee_ref, day_ref, itau_dyn, itau_phy, start_time |
---|
[2601] | 41 | |
---|
[2293] | 42 | IMPLICIT NONE |
---|
| 43 | |
---|
| 44 | PRIVATE |
---|
| 45 | PUBLIC :: etat0dyn_netcdf |
---|
| 46 | |
---|
| 47 | include "iniprint.h" |
---|
| 48 | include "dimensions.h" |
---|
| 49 | include "paramet.h" |
---|
| 50 | include "comgeom2.h" |
---|
| 51 | include "comdissnew.h" |
---|
| 52 | REAL, SAVE :: deg2rad |
---|
| 53 | INTEGER, SAVE :: iml_dyn, jml_dyn, llm_dyn, ttm_dyn, fid_dyn |
---|
| 54 | REAL, ALLOCATABLE, SAVE :: lon_dyn(:,:), lat_dyn(:,:), levdyn_ini(:) |
---|
| 55 | CHARACTER(LEN=120), PARAMETER :: dynfname='ECDYN.nc' |
---|
| 56 | |
---|
| 57 | CONTAINS |
---|
| 58 | |
---|
| 59 | !------------------------------------------------------------------------------- |
---|
| 60 | ! |
---|
[2336] | 61 | SUBROUTINE etat0dyn_netcdf(masque, phis) |
---|
[2293] | 62 | ! |
---|
| 63 | !------------------------------------------------------------------------------- |
---|
| 64 | ! Purpose: Create dynamical initial states. |
---|
| 65 | !------------------------------------------------------------------------------- |
---|
| 66 | ! Notes: 1) This routine is designed to work for Earth |
---|
| 67 | ! 2) If masque(:,:)/=-99999., masque and phis are already known. |
---|
[2336] | 68 | ! Otherwise: compute it. |
---|
[2293] | 69 | !------------------------------------------------------------------------------- |
---|
| 70 | USE control_mod |
---|
| 71 | USE regr_lat_time_coefoz_m, ONLY: regr_lat_time_coefoz |
---|
| 72 | USE regr_pr_o3_m, ONLY: regr_pr_o3 |
---|
| 73 | USE press_coefoz_m, ONLY: press_coefoz |
---|
| 74 | USE exner_hyb_m, ONLY: exner_hyb |
---|
| 75 | USE exner_milieu_m, ONLY: exner_milieu |
---|
[2336] | 76 | USE infotrac, ONLY: nqtot, tname |
---|
[2293] | 77 | USE filtreg_mod |
---|
| 78 | IMPLICIT NONE |
---|
| 79 | !------------------------------------------------------------------------------- |
---|
| 80 | ! Arguments: |
---|
| 81 | REAL, INTENT(INOUT) :: masque(iip1,jjp1) !--- Land-ocean mask |
---|
| 82 | REAL, INTENT(INOUT) :: phis (iip1,jjp1) !--- Ground geopotential |
---|
| 83 | !------------------------------------------------------------------------------- |
---|
| 84 | ! Local variables: |
---|
| 85 | CHARACTER(LEN=256) :: modname, fmt |
---|
| 86 | INTEGER :: i, j, l, ji, itau, iday |
---|
| 87 | REAL :: xpn, xps, time, phystep |
---|
[2361] | 88 | REAL, DIMENSION(iip1,jjp1) :: psol |
---|
[2293] | 89 | REAL, DIMENSION(iip1,jjp1,llm+1) :: p3d |
---|
| 90 | REAL, DIMENSION(iip1,jjp1,llm) :: uvent, t3d, tpot, qsat, qd |
---|
| 91 | REAL, DIMENSION(iip1,jjp1,llm) :: pk, pls, y, masse |
---|
| 92 | REAL, DIMENSION(iip1,jjm ,llm) :: vvent |
---|
| 93 | REAL, DIMENSION(ip1jm ,llm) :: pbarv |
---|
| 94 | REAL, DIMENSION(ip1jmp1 ,llm) :: pbaru, phi, w |
---|
| 95 | REAL, DIMENSION(ip1jmp1) :: pks |
---|
| 96 | REAL, DIMENSION(iim) :: xppn, xpps |
---|
| 97 | REAL, ALLOCATABLE :: q3d(:,:,:,:) |
---|
| 98 | !------------------------------------------------------------------------------- |
---|
| 99 | modname='etat0dyn_netcdf' |
---|
| 100 | |
---|
| 101 | deg2rad = pi/180.0 |
---|
| 102 | |
---|
| 103 | ! Compute psol AND tsol, knowing phis. |
---|
| 104 | !******************************************************************************* |
---|
[2336] | 105 | CALL start_init_dyn(rlonv, rlatu, rlonu, rlatv, phis, psol) |
---|
[2293] | 106 | |
---|
| 107 | ! Mid-levels pressure computation |
---|
| 108 | !******************************************************************************* |
---|
| 109 | CALL pression(ip1jmp1, ap, bp, psol, p3d) !--- Update p3d |
---|
| 110 | IF(pressure_exner) THEN !--- Update pk, pks |
---|
| 111 | CALL exner_hyb (ip1jmp1,psol,p3d,pks,pk) |
---|
| 112 | ELSE |
---|
| 113 | CALL exner_milieu(ip1jmp1,psol,p3d,pks,pk) |
---|
| 114 | END IF |
---|
| 115 | pls(:,:,:)=preff*(pk(:,:,:)/cpp)**(1./kappa) !--- Update pls |
---|
| 116 | |
---|
| 117 | ! Update uvent, vvent, t3d and tpot |
---|
| 118 | !******************************************************************************* |
---|
[2299] | 119 | uvent(:,:,:) = 0.0 ; vvent(:,:,:) = 0.0 ; t3d (:,:,:) = 0.0 |
---|
[2336] | 120 | CALL startget_dyn3d('u' ,rlonu,rlatu,pls,y ,uvent,rlonv,rlatv) |
---|
[2299] | 121 | CALL startget_dyn3d('v' ,rlonv,rlatv,pls(:,:jjm,:),y(:,:jjm,:),vvent, & |
---|
[2336] | 122 | & rlonu,rlatu(:jjm)) |
---|
| 123 | CALL startget_dyn3d('t' ,rlonv,rlatu,pls,y ,t3d ,rlonu,rlatv) |
---|
[2299] | 124 | tpot(:,:,:)=t3d(:,:,:) |
---|
[2336] | 125 | CALL startget_dyn3d('tpot',rlonv,rlatu,pls,pk,tpot,rlonu,rlatv) |
---|
[2293] | 126 | |
---|
| 127 | WRITE(lunout,*) 'T3D min,max:',MINVAL(t3d(:,:,:)),MAXVAL(t3d(:,:,:)) |
---|
| 128 | WRITE(lunout,*) 'PLS min,max:',MINVAL(pls(:,:,:)),MAXVAL(pls(:,:,:)) |
---|
| 129 | |
---|
| 130 | ! Humidity at saturation computation |
---|
| 131 | !******************************************************************************* |
---|
| 132 | WRITE(lunout,*) 'avant q_sat' |
---|
| 133 | CALL q_sat(llm*jjp1*iip1, t3d, pls, qsat) |
---|
| 134 | WRITE(lunout,*) 'apres q_sat' |
---|
| 135 | WRITE(lunout,*) 'QSAT min,max:',MINVAL(qsat(:,:,:)),MAXVAL(qsat(:,:,:)) |
---|
| 136 | ! WRITE(lunout,*) 'QSAT :',qsat(10,20,:) |
---|
| 137 | qd (:,:,:) = 0.0 |
---|
[2336] | 138 | CALL startget_dyn3d('q',rlonv,rlatu,pls,qsat,qd,rlonu,rlatv) |
---|
[2299] | 139 | ALLOCATE(q3d(iip1,jjp1,llm,nqtot)); q3d(:,:,:,:)=0.0 ; q3d(:,:,:,1)=qd(:,:,:) |
---|
[2293] | 140 | CALL flinclo(fid_dyn) |
---|
| 141 | |
---|
| 142 | ! Parameterization of ozone chemistry: |
---|
| 143 | !******************************************************************************* |
---|
| 144 | ! Look for ozone tracer: |
---|
| 145 | DO i=1,nqtot; IF(ANY(["O3","o3"]==tname(i))) EXIT; END DO |
---|
| 146 | IF(i/=nqtot+1) THEN |
---|
| 147 | CALL regr_lat_time_coefoz |
---|
| 148 | CALL press_coefoz |
---|
| 149 | CALL regr_pr_o3(p3d, q3d(:,:,:,i)) |
---|
| 150 | q3d(:,:,:,i)=q3d(:,:,:,i)*48./ 29. !--- Mole->mass fraction |
---|
| 151 | END IF |
---|
[2299] | 152 | q3d(iip1,:,:,:)=q3d(1,:,:,:) |
---|
[2293] | 153 | |
---|
| 154 | ! Writing |
---|
| 155 | !******************************************************************************* |
---|
| 156 | CALL inidissip(lstardis, nitergdiv, nitergrot, niterh, tetagdiv, tetagrot, & |
---|
| 157 | tetatemp, vert_prof_dissip) |
---|
| 158 | WRITE(lunout,*)'sortie inidissip' |
---|
| 159 | itau=0 |
---|
| 160 | itau_dyn=0 |
---|
| 161 | itau_phy=0 |
---|
| 162 | iday=dayref+itau/day_step |
---|
| 163 | time=FLOAT(itau-(iday-dayref)*day_step)/day_step |
---|
| 164 | IF(time>1.) THEN |
---|
| 165 | time=time-1 |
---|
| 166 | iday=iday+1 |
---|
| 167 | END IF |
---|
| 168 | day_ref=dayref |
---|
| 169 | annee_ref=anneeref |
---|
| 170 | CALL geopot( ip1jmp1, tpot, pk, pks, phis, phi ) |
---|
| 171 | WRITE(lunout,*)'sortie geopot' |
---|
[2336] | 172 | CALL caldyn0( itau, uvent, vvent, tpot, psol, masse, pk, phis, & |
---|
| 173 | phi, w, pbaru, pbarv, time+iday-dayref) |
---|
[2673] | 174 | WRITE(lunout,*)'sortie caldyn0' |
---|
| 175 | start_time = 0. |
---|
[2336] | 176 | #ifdef CPP_PARA |
---|
| 177 | CALL dynredem0_loc( "start.nc", dayref, phis) |
---|
| 178 | #else |
---|
[2293] | 179 | CALL dynredem0( "start.nc", dayref, phis) |
---|
[2336] | 180 | #endif |
---|
[2293] | 181 | WRITE(lunout,*)'sortie dynredem0' |
---|
[2336] | 182 | #ifdef CPP_PARA |
---|
| 183 | CALL dynredem1_loc( "start.nc", 0.0, vvent, uvent, tpot, q3d, masse, psol) |
---|
| 184 | #else |
---|
[2293] | 185 | CALL dynredem1( "start.nc", 0.0, vvent, uvent, tpot, q3d, masse, psol) |
---|
[2336] | 186 | #endif |
---|
[2293] | 187 | WRITE(lunout,*)'sortie dynredem1' |
---|
| 188 | CALL histclo() |
---|
| 189 | |
---|
| 190 | END SUBROUTINE etat0dyn_netcdf |
---|
| 191 | ! |
---|
| 192 | !------------------------------------------------------------------------------- |
---|
| 193 | |
---|
| 194 | |
---|
| 195 | !------------------------------------------------------------------------------- |
---|
| 196 | ! |
---|
[2299] | 197 | SUBROUTINE startget_dyn3d(var, lon_in, lat_in, pls, workvar,& |
---|
[2336] | 198 | champ, lon_in2, lat_in2) |
---|
[2293] | 199 | !------------------------------------------------------------------------------- |
---|
| 200 | IMPLICIT NONE |
---|
| 201 | !=============================================================================== |
---|
| 202 | ! Purpose: Compute some quantities (u,v,t,q,tpot) using variables U,V,TEMP and R |
---|
| 203 | ! (3D fields) of file dynfname. |
---|
| 204 | !------------------------------------------------------------------------------- |
---|
| 205 | ! Note: An input auxilliary field "workvar" has to be specified in two cases: |
---|
[2299] | 206 | ! * for "q": the saturated humidity. |
---|
| 207 | ! * for "tpot": the Exner function. |
---|
[2293] | 208 | !=============================================================================== |
---|
| 209 | ! Arguments: |
---|
| 210 | CHARACTER(LEN=*), INTENT(IN) :: var |
---|
| 211 | REAL, INTENT(IN) :: lon_in(:) ! dim (iml) |
---|
| 212 | REAL, INTENT(IN) :: lat_in(:) ! dim (jml) |
---|
| 213 | REAL, INTENT(IN) :: pls (:, :, :) ! dim (iml, jml, lml) |
---|
| 214 | REAL, INTENT(IN) :: workvar(:, :, :) ! dim (iml, jml, lml) |
---|
| 215 | REAL, INTENT(INOUT) :: champ (:, :, :) ! dim (iml, jml, lml) |
---|
| 216 | REAL, INTENT(IN) :: lon_in2(:) ! dim (iml) |
---|
| 217 | REAL, INTENT(IN) :: lat_in2(:) ! dim (jml2) |
---|
| 218 | !------------------------------------------------------------------------------- |
---|
| 219 | ! Local variables: |
---|
| 220 | CHARACTER(LEN=10) :: vname |
---|
| 221 | CHARACTER(LEN=256) :: msg, modname="startget_dyn3d" |
---|
| 222 | INTEGER :: iml, jml, jml2, lml, il |
---|
| 223 | REAL :: xppn, xpps |
---|
| 224 | !------------------------------------------------------------------------------- |
---|
[2299] | 225 | iml=assert_eq([SIZE(lon_in),SIZE(pls,1),SIZE(workvar,1),SIZE(champ,1), & |
---|
| 226 | & SIZE(lon_in2)], TRIM(modname)//" iml") |
---|
| 227 | jml=assert_eq( SIZE(lat_in),SIZE(pls,2),SIZE(workvar,2),SIZE(champ,2), & |
---|
| 228 | & TRIM(modname)//" jml") |
---|
| 229 | lml=assert_eq( SIZE(pls,3),SIZE(workvar,3),SIZE(champ,3), & |
---|
| 230 | & TRIM(modname)//" lml") |
---|
| 231 | jml2=SIZE(lat_in2) |
---|
[2293] | 232 | |
---|
[2299] | 233 | !--- CHECK IF THE FIELD IS KNOWN |
---|
| 234 | SELECT CASE(var) |
---|
| 235 | CASE('u'); vname='U' |
---|
| 236 | CASE('v'); vname='V' |
---|
| 237 | CASE('t'); vname='TEMP' |
---|
| 238 | CASE('q'); vname='R'; msg='humidity as the saturated humidity' |
---|
| 239 | CASE('tpot'); msg='potential temperature as the Exner function' |
---|
| 240 | CASE DEFAULT; msg='No rule to extract variable '//TRIM(var) |
---|
| 241 | CALL abort_gcm(modname,TRIM(msg)//' from any data set',1) |
---|
| 242 | END SELECT |
---|
[2293] | 243 | |
---|
[2299] | 244 | !--- CHECK IF SOMETHING IS MISSING |
---|
| 245 | IF((var=='tpot'.OR.var=='q').AND.MINVAL(workvar)==MAXVAL(workvar)) THEN |
---|
| 246 | msg='Could not compute '//TRIM(msg)//' is missing or constant.' |
---|
| 247 | CALL abort_gcm(modname,TRIM(msg),1) |
---|
| 248 | END IF |
---|
[2293] | 249 | |
---|
[2299] | 250 | !--- INTERPOLATE 3D FIELD IF NEEDED |
---|
| 251 | IF(var/='tpot') CALL start_inter_3d(TRIM(vname),lon_in,lat_in,lon_in2, & |
---|
[2336] | 252 | lat_in2,pls,champ) |
---|
[2293] | 253 | |
---|
[2299] | 254 | !--- COMPUTE THE REQUIRED FILED |
---|
| 255 | SELECT CASE(var) |
---|
| 256 | CASE('u'); DO il=1,lml; champ(:,:,il)=champ(:,:,il)*cu(:,1:jml); END DO |
---|
| 257 | champ(iml,:,:)=champ(1,:,:) !--- Eastward wind |
---|
[2293] | 258 | |
---|
[2299] | 259 | CASE('v'); DO il=1,lml; champ(:,:,il)=champ(:,:,il)*cv(:,1:jml); END DO |
---|
| 260 | champ(iml,:,:)=champ(1,:,:) !--- Northward wind |
---|
[2293] | 261 | |
---|
[2299] | 262 | CASE('tpot','q') |
---|
| 263 | IF(var=='tpot') THEN; champ=champ*cpp/workvar !--- Potential temperature |
---|
| 264 | ELSE; champ=champ*.01*workvar !--- Relative humidity |
---|
| 265 | WHERE(champ<0.) champ=1.0E-10 |
---|
| 266 | END IF |
---|
| 267 | DO il=1,lml |
---|
| 268 | xppn = SUM(aire(:,1 )*champ(:,1 ,il))/apoln |
---|
| 269 | xpps = SUM(aire(:,jml)*champ(:,jml,il))/apols |
---|
| 270 | champ(:,1 ,il) = xppn |
---|
| 271 | champ(:,jml,il) = xpps |
---|
| 272 | END DO |
---|
| 273 | END SELECT |
---|
[2293] | 274 | |
---|
| 275 | END SUBROUTINE startget_dyn3d |
---|
| 276 | ! |
---|
| 277 | !------------------------------------------------------------------------------- |
---|
| 278 | |
---|
| 279 | |
---|
| 280 | !------------------------------------------------------------------------------- |
---|
| 281 | ! |
---|
[2336] | 282 | SUBROUTINE start_init_dyn(lon_in,lat_in,lon_in2,lat_in2,zs,psol) |
---|
[2293] | 283 | ! |
---|
| 284 | !------------------------------------------------------------------------------- |
---|
| 285 | IMPLICIT NONE |
---|
| 286 | !=============================================================================== |
---|
| 287 | ! Purpose: Compute psol, knowing phis. |
---|
| 288 | !=============================================================================== |
---|
| 289 | ! Arguments: |
---|
| 290 | REAL, INTENT(IN) :: lon_in (:), lat_in (:) ! dim (iml) (jml) |
---|
| 291 | REAL, INTENT(IN) :: lon_in2(:), lat_in2(:) ! dim (iml) (jml2) |
---|
| 292 | REAL, INTENT(IN) :: zs (:,:) ! dim (iml,jml) |
---|
| 293 | REAL, INTENT(OUT) :: psol(:,:) ! dim (iml,jml) |
---|
| 294 | !------------------------------------------------------------------------------- |
---|
| 295 | ! Local variables: |
---|
| 296 | CHARACTER(LEN=256) :: modname='start_init_dyn' |
---|
| 297 | REAL :: date, dt |
---|
| 298 | INTEGER :: iml, jml, jml2, itau(1) |
---|
| 299 | REAL, ALLOCATABLE :: lon_rad(:), lon_ini(:), var_ana(:,:) |
---|
| 300 | REAL, ALLOCATABLE :: lat_rad(:), lat_ini(:) |
---|
| 301 | REAL, ALLOCATABLE :: z(:,:), ps(:,:), ts(:,:) |
---|
| 302 | !------------------------------------------------------------------------------- |
---|
| 303 | iml=assert_eq(SIZE(lon_in),SIZE(zs,1),SIZE(psol,1),SIZE(lon_in2), & |
---|
| 304 | & TRIM(modname)//" iml") |
---|
| 305 | jml=assert_eq(SIZE(lat_in),SIZE(zs,2),SIZE(psol,2),TRIM(modname)//" jml") |
---|
| 306 | jml2=SIZE(lat_in2) |
---|
| 307 | |
---|
| 308 | WRITE(lunout,*) 'Opening the surface analysis' |
---|
| 309 | CALL flininfo(dynfname, iml_dyn, jml_dyn, llm_dyn, ttm_dyn, fid_dyn) |
---|
| 310 | WRITE(lunout,*) 'Values read: ', iml_dyn, jml_dyn, llm_dyn, ttm_dyn |
---|
| 311 | |
---|
| 312 | ALLOCATE(lon_dyn(iml_dyn,jml_dyn), lat_dyn(iml_dyn,jml_dyn)) |
---|
| 313 | ALLOCATE(levdyn_ini(llm_dyn)) |
---|
| 314 | CALL flinopen(dynfname, .FALSE., iml_dyn, jml_dyn, llm_dyn, & |
---|
| 315 | lon_dyn,lat_dyn,levdyn_ini,ttm_dyn,itau,date,dt,fid_dyn) |
---|
| 316 | |
---|
| 317 | !--- IF ANGLES ARE IN DEGREES, THEY ARE CONVERTED INTO RADIANS |
---|
| 318 | ALLOCATE(lon_ini(iml_dyn),lat_ini(jml_dyn)) |
---|
| 319 | lon_ini(:)=lon_dyn(:,1); IF(MAXVAL(lon_dyn)>pi) lon_ini=lon_ini*deg2rad |
---|
| 320 | lat_ini(:)=lat_dyn(1,:); IF(MAXVAL(lat_dyn)>pi) lat_ini=lat_ini*deg2rad |
---|
| 321 | |
---|
| 322 | ALLOCATE(var_ana(iml_dyn,jml_dyn),lon_rad(iml_dyn),lat_rad(jml_dyn)) |
---|
| 323 | CALL get_var_dyn('Z',z) !--- SURFACE GEOPOTENTIAL |
---|
| 324 | CALL get_var_dyn('SP',ps) !--- SURFACE PRESSURE |
---|
| 325 | CALL get_var_dyn('ST',ts) !--- SURFACE TEMPERATURE |
---|
| 326 | ! CALL flinclo(fid_dyn) |
---|
| 327 | DEALLOCATE(var_ana,lon_rad,lat_rad,lon_ini,lat_ini) |
---|
| 328 | |
---|
| 329 | !--- PSOL IS COMPUTED IN PASCALS |
---|
| 330 | psol(:iml-1,:) = ps(:iml-1,:)*(1.0+(z(:iml-1,:)-zs(:iml-1,:))/287.0 & |
---|
| 331 | & /ts(:iml-1,:)) |
---|
| 332 | psol(iml,:)=psol(1,:) |
---|
| 333 | DEALLOCATE(z,ps,ts) |
---|
| 334 | psol(:,1 )=SUM(aire(1:iml-1,1 )*psol(1:iml-1,1 ))/apoln !--- NORTH POLE |
---|
| 335 | psol(:,jml)=SUM(aire(1:iml-1,jml)*psol(1:iml-1,jml))/apols !--- SOUTH POLE |
---|
| 336 | |
---|
| 337 | CONTAINS |
---|
| 338 | |
---|
| 339 | !------------------------------------------------------------------------------- |
---|
| 340 | ! |
---|
| 341 | SUBROUTINE get_var_dyn(title,field) |
---|
| 342 | ! |
---|
| 343 | !------------------------------------------------------------------------------- |
---|
| 344 | USE conf_dat_m, ONLY: conf_dat2d |
---|
| 345 | IMPLICIT NONE |
---|
| 346 | !------------------------------------------------------------------------------- |
---|
| 347 | ! Arguments: |
---|
| 348 | CHARACTER(LEN=*), INTENT(IN) :: title |
---|
| 349 | REAL, ALLOCATABLE, INTENT(INOUT) :: field(:,:) |
---|
| 350 | !------------------------------------------------------------------------------- |
---|
| 351 | ! Local variables: |
---|
| 352 | CHARACTER(LEN=256) :: msg |
---|
| 353 | INTEGER :: tllm |
---|
| 354 | !------------------------------------------------------------------------------- |
---|
| 355 | SELECT CASE(title) |
---|
| 356 | CASE('Z'); tllm=0; msg='geopotential' |
---|
| 357 | CASE('SP'); tllm=0; msg='surface pressure' |
---|
| 358 | CASE('ST'); tllm=llm_dyn; msg='temperature' |
---|
| 359 | END SELECT |
---|
| 360 | IF(.NOT.ALLOCATED(field)) THEN |
---|
| 361 | ALLOCATE(field(iml,jml)) |
---|
| 362 | CALL flinget(fid_dyn, title, iml_dyn,jml_dyn, tllm, ttm_dyn, 1, 1, var_ana) |
---|
[2336] | 363 | CALL conf_dat2d(title, lon_ini, lat_ini, lon_rad, lat_rad, var_ana, .TRUE.) |
---|
| 364 | CALL interp_startvar(title, .TRUE., lon_rad,lat_rad, var_ana, & |
---|
| 365 | lon_in, lat_in, lon_in2, lat_in2, field) |
---|
[2293] | 366 | ELSE IF(SIZE(field)/=SIZE(z)) THEN |
---|
| 367 | msg='The '//TRIM(msg)//' field we have does not have the right size' |
---|
| 368 | CALL abort_gcm(TRIM(modname),msg,1) |
---|
| 369 | END IF |
---|
| 370 | |
---|
| 371 | END SUBROUTINE get_var_dyn |
---|
| 372 | ! |
---|
| 373 | !------------------------------------------------------------------------------- |
---|
| 374 | |
---|
| 375 | END SUBROUTINE start_init_dyn |
---|
| 376 | ! |
---|
| 377 | !------------------------------------------------------------------------------- |
---|
| 378 | |
---|
| 379 | |
---|
| 380 | !------------------------------------------------------------------------------- |
---|
| 381 | ! |
---|
[2336] | 382 | SUBROUTINE start_inter_3d(var,lon_in,lat_in,lon_in2,lat_in2,pls_in,var3d) |
---|
[2293] | 383 | ! |
---|
| 384 | !------------------------------------------------------------------------------- |
---|
| 385 | USE conf_dat_m, ONLY: conf_dat3d |
---|
| 386 | USE pchsp_95_m, ONLY: pchsp_95 |
---|
| 387 | USE pchfe_95_m, ONLY: pchfe_95 |
---|
| 388 | IMPLICIT NONE |
---|
| 389 | !------------------------------------------------------------------------------- |
---|
| 390 | ! Arguments: |
---|
| 391 | CHARACTER(LEN=*), INTENT(IN) :: var |
---|
| 392 | REAL, INTENT(IN) :: lon_in(:), lat_in(:) ! dim (iml) (jml) |
---|
| 393 | REAL, INTENT(IN) :: lon_in2(:), lat_in2(:) ! dim (iml) (jml2) |
---|
| 394 | REAL, INTENT(IN) :: pls_in(:,:,:) ! dim (iml,jml,lml) |
---|
| 395 | REAL, INTENT(OUT) :: var3d (:,:,:) ! dim (iml,jml,lml) |
---|
| 396 | !------------------------------------------------------------------------------- |
---|
| 397 | ! Local variables: |
---|
| 398 | CHARACTER(LEN=256) :: modname='start_inter_3d' |
---|
| 399 | LOGICAL :: skip |
---|
| 400 | REAL :: chmin, chmax |
---|
| 401 | INTEGER :: iml, jml, lml, jml2, ii, ij, il, ierr |
---|
| 402 | INTEGER :: n_extrap ! Extrapolated points number |
---|
| 403 | REAL, ALLOCATABLE :: ax(:), lon_rad(:), lon_ini(:), lev_dyn(:), yder(:) |
---|
| 404 | REAL, ALLOCATABLE :: ay(:), lat_rad(:), lat_ini(:), var_tmp3d(:,:,:) |
---|
| 405 | REAL, ALLOCATABLE, SAVE :: var_ana3d(:,:,:) |
---|
| 406 | !------------------------------------------------------------------------------- |
---|
| 407 | iml=assert_eq(SIZE(lon_in),SIZE(lon_in2),SIZE(pls_in,1),SIZE(var3d,1),TRIM(modname)//" iml") |
---|
| 408 | jml=assert_eq(SIZE(lat_in), SIZE(pls_in,2),SIZE(var3d,2),TRIM(modname)//" jml") |
---|
| 409 | lml=assert_eq(SIZE(pls_in,3),SIZE(var3d,3),TRIM(modname)//" lml"); jml2=SIZE(lat_in2) |
---|
| 410 | |
---|
| 411 | WRITE(lunout, *)'Going into flinget to extract the 3D field.' |
---|
| 412 | IF(.NOT.ALLOCATED(var_ana3d)) ALLOCATE(var_ana3d(iml_dyn, jml_dyn, llm_dyn)) |
---|
| 413 | CALL flinget(fid_dyn,var,iml_dyn,jml_dyn,llm_dyn,ttm_dyn,1,1,var_ana3d) |
---|
| 414 | |
---|
| 415 | !--- ANGLES IN DEGREES ARE CONVERTED INTO RADIANS |
---|
| 416 | ALLOCATE(lon_ini(iml_dyn), lat_ini(jml_dyn)) |
---|
| 417 | lon_ini(:)=lon_dyn(:,1); IF(MAXVAL(lon_dyn)>pi) lon_ini=lon_ini*deg2rad |
---|
| 418 | lat_ini(:)=lat_dyn(1,:); IF(MAXVAL(lat_dyn)>pi) lat_ini=lat_ini*deg2rad |
---|
| 419 | |
---|
| 420 | !--- FIELDS ARE PROCESSED TO BE ON STANDARD ANGULAR DOMAINS |
---|
| 421 | ALLOCATE(lon_rad(iml_dyn), lat_rad(jml_dyn), lev_dyn(llm_dyn)) |
---|
| 422 | CALL conf_dat3d(var, lon_ini, lat_ini, levdyn_ini, & |
---|
[2336] | 423 | lon_rad, lat_rad, lev_dyn, var_ana3d, .TRUE.) |
---|
[2293] | 424 | DEALLOCATE(lon_ini, lat_ini) |
---|
| 425 | |
---|
| 426 | !--- COMPUTE THE REQUIRED FIELDS USING ROUTINE grid_noro |
---|
| 427 | ALLOCATE(var_tmp3d(iml,jml,llm_dyn)) |
---|
| 428 | DO il = 1,llm_dyn |
---|
[2336] | 429 | CALL interp_startvar(var,il==1,lon_rad,lat_rad,var_ana3d(:,:,il), & |
---|
[2293] | 430 | lon_in,lat_in,lon_in2,lat_in2,var_tmp3d(:,:,il)) |
---|
| 431 | END DO |
---|
| 432 | DEALLOCATE(lon_rad, lat_rad) |
---|
| 433 | |
---|
| 434 | !--- VERTICAL INTERPOLATION FROM TOP OF ATMOSPHERE TO GROUND |
---|
| 435 | ALLOCATE(ax(llm_dyn),ay(llm_dyn),yder(llm_dyn)) |
---|
| 436 | ax = lev_dyn(llm_dyn:1:-1) |
---|
| 437 | skip = .FALSE. |
---|
| 438 | n_extrap = 0 |
---|
| 439 | DO ij=1, jml |
---|
| 440 | DO ii=1, iml-1 |
---|
| 441 | ay = var_tmp3d(ii, ij, llm_dyn:1:-1) |
---|
| 442 | yder = pchsp_95(ax, ay, ibeg=2, iend=2, vc_beg=0., vc_end=0.) |
---|
| 443 | CALL pchfe_95(ax, ay, yder, skip, pls_in(ii, ij, lml:1:-1), & |
---|
| 444 | var3d(ii, ij, lml:1:-1), ierr) |
---|
| 445 | IF(ierr<0) CALL abort_gcm(TRIM(modname),'error in pchfe_95',1) |
---|
| 446 | n_extrap = n_extrap + ierr |
---|
| 447 | END DO |
---|
| 448 | END DO |
---|
| 449 | IF(n_extrap/=0) WRITE(lunout,*)TRIM(modname)//" pchfe_95: n_extrap=", n_extrap |
---|
| 450 | var3d(iml, :, :) = var3d(1, :, :) |
---|
| 451 | |
---|
| 452 | DO il=1, lml |
---|
| 453 | CALL minmax(iml*jml, var3d(1, 1, il), chmin, chmax) |
---|
| 454 | WRITE(lunout, *)' '//TRIM(var)//' min max l ', il, chmin, chmax |
---|
| 455 | END DO |
---|
| 456 | |
---|
| 457 | END SUBROUTINE start_inter_3d |
---|
| 458 | ! |
---|
| 459 | !------------------------------------------------------------------------------- |
---|
| 460 | |
---|
| 461 | |
---|
| 462 | !------------------------------------------------------------------------------- |
---|
| 463 | ! |
---|
[2336] | 464 | SUBROUTINE interp_startvar(nam,ibeg,lon,lat,vari,lon1,lat1,lon2,lat2,varo) |
---|
[2293] | 465 | ! |
---|
| 466 | !------------------------------------------------------------------------------- |
---|
| 467 | USE inter_barxy_m, ONLY: inter_barxy |
---|
| 468 | IMPLICIT NONE |
---|
| 469 | !------------------------------------------------------------------------------- |
---|
| 470 | ! Arguments: |
---|
| 471 | CHARACTER(LEN=*), INTENT(IN) :: nam |
---|
[2336] | 472 | LOGICAL, INTENT(IN) :: ibeg |
---|
[2293] | 473 | REAL, INTENT(IN) :: lon(:), lat(:) ! dim (ii) (jj) |
---|
| 474 | REAL, INTENT(IN) :: vari(:,:) ! dim (ii,jj) |
---|
| 475 | REAL, INTENT(IN) :: lon1(:), lat1(:) ! dim (i1) (j1) |
---|
| 476 | REAL, INTENT(IN) :: lon2(:), lat2(:) ! dim (i1) (j2) |
---|
| 477 | REAL, INTENT(OUT) :: varo(:,:) ! dim (i1) (j1) |
---|
| 478 | !------------------------------------------------------------------------------- |
---|
| 479 | ! Local variables: |
---|
| 480 | CHARACTER(LEN=256) :: modname="interp_startvar" |
---|
| 481 | INTEGER :: ii, jj, i1, j1, j2 |
---|
| 482 | REAL, ALLOCATABLE :: vtmp(:,:) |
---|
| 483 | !------------------------------------------------------------------------------- |
---|
| 484 | ii=assert_eq(SIZE(lon), SIZE(vari,1),TRIM(modname)//" ii") |
---|
| 485 | jj=assert_eq(SIZE(lat), SIZE(vari,2),TRIM(modname)//" jj") |
---|
| 486 | i1=assert_eq(SIZE(lon1),SIZE(lon2),SIZE(varo,1),TRIM(modname)//" i1") |
---|
| 487 | j1=assert_eq(SIZE(lat1), SIZE(varo,2),TRIM(modname)//" j1") |
---|
| 488 | j2=SIZE(lat2) |
---|
| 489 | ALLOCATE(vtmp(i1-1,j1)) |
---|
[2336] | 490 | IF(ibeg.AND.prt_level>1) THEN |
---|
| 491 | WRITE(lunout,*)"---------------------------------------------------------" |
---|
| 492 | WRITE(lunout,*)"$$$ Interpolation barycentrique pour "//TRIM(nam)//" $$$" |
---|
| 493 | WRITE(lunout,*)"---------------------------------------------------------" |
---|
[2293] | 494 | END IF |
---|
[2336] | 495 | CALL inter_barxy(lon, lat(:jj-1), vari, lon2(:i1-1), lat2, vtmp) |
---|
[2293] | 496 | CALL gr_int_dyn(vtmp, varo, i1-1, j1) |
---|
| 497 | |
---|
| 498 | END SUBROUTINE interp_startvar |
---|
| 499 | ! |
---|
| 500 | !------------------------------------------------------------------------------- |
---|
| 501 | |
---|
| 502 | END MODULE etat0dyn |
---|
| 503 | ! |
---|
| 504 | !******************************************************************************* |
---|