File indexing completed on 2021-11-06 05:18:33 UTC
view on githubraw file Latest commit 016b84c4 on 2021-11-02 20:24:44 UTC
893df04db0 Mart*0001 #include "OPPS_OPTIONS.h"
6580feb7eb Jean*0002 #undef OPPS_ORGCODE
0003
0004
0005
0006
0007
0008
893df04db0 Mart*0009
6580feb7eb Jean*0010
893df04db0 Mart*0011
0012
0013
0014
a6de755a30 Jean*0015 SUBROUTINE OPPS_CALC(
893df04db0 Mart*0016 U tracerEnv,
016b84c482 Mart*0017 O OPPSconvectCount,
3daafce20b Jean*0018 I wVel,
0019 I kMax, nTracer, nTracerInuse,
893df04db0 Mart*0020 I I, J, bi, bj, myTime, myIter, myThid )
0021
0022
6580feb7eb Jean*0023
893df04db0 Mart*0024
0025
6580feb7eb Jean*0026
893df04db0 Mart*0027
0028
0029
0030
0031
29188f9691 Jean*0032
893df04db0 Mart*0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
3daafce20b Jean*0053
893df04db0 Mart*0054
0055
0056
0057
0058
0059
0060
0061
6580feb7eb Jean*0062
893df04db0 Mart*0063
0064
6580feb7eb Jean*0065 IMPLICIT NONE
0066
016b84c482 Mart*0067
893df04db0 Mart*0068 #include "SIZE.h"
0069 #include "EEPARAMS.h"
0070 #include "PARAMS.h"
0071 #include "OPPS.h"
0072 #include "GRID.h"
0073
016b84c482 Mart*0074
6580feb7eb Jean*0075
016b84c482 Mart*0076
6580feb7eb Jean*0077
0078
016b84c482 Mart*0079 INTEGER KMax, nTracer, nTracerInUse
0080 _RL tracerEnv(Nr,nTracer)
0081 _RL OPPSconvectCount(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
0082 _RL wVel(Nr)
0083 INTEGER I, J, bi, bj
893df04db0 Mart*0084 _RL myTime
016b84c482 Mart*0085 INTEGER myThid, myIter
893df04db0 Mart*0086
0087 #ifdef ALLOW_OPPS
6580feb7eb Jean*0088
0089
0090
0091 _RL STATE1
0092
893df04db0 Mart*0093
6580feb7eb Jean*0094
0095
893df04db0 Mart*0096 CHARACTER*(MAX_LEN_MBUF) msgBuf
0097 INTEGER K, K2, K2m1, K2p1, ktr
0098 INTEGER ntime,nn,kmx,ic
0099 INTEGER maxDepth
0100
0101 _RL wsqr,oldflux,newflux,entrainrate
0102 _RL pmix
6580feb7eb Jean*0103 _RL D1, D2
893df04db0 Mart*0104 _RL dz1,dz2
0105 _RL radius,StartingFlux
0106 _RL dtts,dt
0107
0108 _RL Paa(Nr,nTracer)
0109 _RL wda(Nr), mda(Nr), pda(Nr,nTracer)
0110
6580feb7eb Jean*0111
0112
0113
0114
0115
0116
893df04db0 Mart*0117 _RL Ad(Nr),Wd(Nr),Dd(Nr),Md(Nr)
0118 _RL De(Nr)
0119 _RL PlumeEntrainment(Nr)
0120 _RL Pd(Nr,nTracer)
0121
0122
0123
94a46dfe0d Jean*0124
893df04db0 Mart*0125 IF ( .true. ) THEN
0126
0127
0128
dfc17c9c63 Jean*0129 dtts = dTtracerLev(1)
6580feb7eb Jean*0130
893df04db0 Mart*0131
0132
0133 DO k=1,KMax-1
6580feb7eb Jean*0134
0135
0136
893df04db0 Mart*0137 DO ktr=1,nTracerInUse
0138 Pd(k,ktr) = tracerEnv(k,ktr)
0139 ENDDO
6580feb7eb Jean*0140 Dd(k)=STATE1(Pd(k,2),Pd(k,1),i,j,k,bi,bj,myThid)
893df04db0 Mart*0141 De(k)=Dd(k)
0142
0143
0144
0145 Wd(k)= - .5*(wVel(K)+wVel(K+1))
0146
98bf704dd5 Jean*0147
893df04db0 Mart*0148
0149
6580feb7eb Jean*0150
0151
0152
893df04db0 Mart*0153
6580feb7eb Jean*0154
0155
0156
0157
893df04db0 Mart*0158
0159
6580feb7eb Jean*0160
893df04db0 Mart*0161 wsqr=Wd(k)*Wd(k)
0162 PlumeEntrainment(k) = 0.0
6580feb7eb Jean*0163
893df04db0 Mart*0164 #ifdef ALLOW_OPPS_DEBUG
0165 IF ( OPPSdebugLevel.GE.debLevB ) THEN
0166 WRITE(msgBuf,'(A,I3)')
3daafce20b Jean*0167 & 'S/R OPPS_CALC: doing old lowerparcel', k
893df04db0 Mart*0168 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
0169 & SQUEEZE_RIGHT , 1)
0170 ENDIF
0171 #endif /* ALLOW_OPPS_DEBUG */
0172 radius=PlumeRadius
0173 StartingFlux=radius*radius*Wd(k)*Dd(k)
0174 oldflux=StartingFlux
3daafce20b Jean*0175
893df04db0 Mart*0176 dz2=DrF(k)
0177 DO k2=k,KMax-1
6580feb7eb Jean*0178 D1=STATE1( Pd(k2,2), Pd(k2,1),i,j,k2+1,bi,bj,myThid)
0179 D2=STATE1( tracerEnv(k2+1,2), tracerEnv(k2+1,1),
893df04db0 Mart*0180 & i,j,k2+1,bi,bj,myThid)
0181 De(k2+1)=D2
6580feb7eb Jean*0182
0183
0184
0185
0186
893df04db0 Mart*0187
0188
0189
0190 IF (D2-D1 .LT. STABILITY_THRESHOLD.or.k2.ne.k) THEN
0191 dz1=dz2
0192 dz2=DrF(k2+1)
6580feb7eb Jean*0193
893df04db0 Mart*0194
6580feb7eb Jean*0195
893df04db0 Mart*0196 newflux=oldflux+e2*radius*Wd(k2)*Dd(k2)*
0197 & .5*(dz1+dz2)
0198
0199
6580feb7eb Jean*0200
893df04db0 Mart*0201 PlumeEntrainment(k2+1) = newflux/StartingFlux
6580feb7eb Jean*0202
893df04db0 Mart*0203 IF(newflux.LE.0.0) then
0204 #ifdef ALLOW_OPPS_DEBUG
0205 IF ( OPPSdebugLevel.GE.debLevA ) THEN
3daafce20b Jean*0206 WRITE(msgBuf,'(A,I3)')
893df04db0 Mart*0207 & 'S/R OPPS_CALC: Plume entrained to zero at level ', k2
0208 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
0209 & SQUEEZE_RIGHT , 1)
0210 ENDIF
0211 #endif /* ALLOW_OPPS_DEBUG */
0212 maxdepth = k2
0213 if(maxdepth.eq.k) goto 1000
0214 goto 1
0215 endif
6580feb7eb Jean*0216
0217
0218
893df04db0 Mart*0219 entrainrate = (newflux - oldflux)/newflux
0220 oldflux = newflux
6580feb7eb Jean*0221
0222
0223
893df04db0 Mart*0224 DO ktr=1,nTracerInUse
0225 pmix=(dz1*tracerEnv(k2,ktr)+dz2*tracerEnv(k2+1,ktr))
0226 & /(dz1+dz2)
3daafce20b Jean*0227 Pd(k2+1,ktr)=Pd(k2,ktr)
893df04db0 Mart*0228 & - entrainrate*(pmix - Pd(k2,ktr))
0229 ENDDO
6580feb7eb Jean*0230
0231
0232
0233
0234 Dd(k2+1)=STATE1(Pd(k2+1,2),Pd(k2+1,1),i,j,k2+1,bi,bj,myThid)
0235
0236
0237
0238
893df04db0 Mart*0239 #ifdef ALLOW_OPPS_DEBUG
0240 IF ( OPPSdebugLevel.GE.debLevA ) THEN
3daafce20b Jean*0241 WRITE(msgBuf,'(A,3E12.4,I3)')
893df04db0 Mart*0242 & 'S/R OPPS_CALC: Dd,De,entr,k ',Dd(k2),De(k2),entrainrate,k2
0243 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
0244 & SQUEEZE_RIGHT , 1)
0245 ENDIF
0246 #endif /* ALLOW_OPPS_DEBUG */
0247
0248 wsqr = wsqr - wsqr*abs(entrainrate)+ gravity*
0249 & (dz1*(Dd(k2)-De(k2))/De(k2)
0250 & +dz2*(Dd(k2+1)-De(k2+1))/De(k2+1))
6580feb7eb Jean*0251
0252
0253
893df04db0 Mart*0254 IF(wsqr.LE.0.0)then
0255 maxdepth = k2
0256 #ifdef ALLOW_OPPS_DEBUG
0257 IF ( OPPSdebugLevel.GE.debLevA ) THEN
3daafce20b Jean*0258 WRITE(msgBuf,'(A,I3)')
893df04db0 Mart*0259 & 'S/R OPPS_CALC: Plume velocity went to zero at level ', k2
0260 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
0261 & SQUEEZE_RIGHT , 1)
3daafce20b Jean*0262 WRITE(msgBuf,'(A,4A14)')
0263 & 'S/R OPPS_CALC: ', 'wsqr', 'entrainrate',
893df04db0 Mart*0264 & '(Dd-De)/De up', '(Dd-De)/De do'
0265 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
0266 & SQUEEZE_RIGHT , 1)
3daafce20b Jean*0267 WRITE(msgBuf,'(A,4E14.6)')
0268 & 'S/R OPPS_CALC: ', wsqr, entrainrate,
893df04db0 Mart*0269 & (Dd(k2)-De(k2))/De(k2), (Dd(k2+1)-De(k2+1))/De(k2+1)
0270 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
0271 & SQUEEZE_RIGHT , 1)
0272 ENDIF
0273 #endif /* ALLOW_OPPS_DEBUG */
0274 if(maxdepth.eq.k) goto 1000
0275 goto 1
0276 endif
0277 Wd(k2+1)=sqrt(wsqr)
6580feb7eb Jean*0278
893df04db0 Mart*0279
0280
6580feb7eb Jean*0281
893df04db0 Mart*0282 radius=sqrt(newflux/(Wd(k2)*Dd(k2)))
0283 ELSE
0284 maxdepth=k2
0285 if(maxdepth.eq.k) goto 1000
0286 GOTO 1
0287 ENDIF
0288 ENDDO
6580feb7eb Jean*0289
0290
0291
893df04db0 Mart*0292 MaxDepth=kMax
6580feb7eb Jean*0293
893df04db0 Mart*0294 1 CONTINUE
6580feb7eb Jean*0295
893df04db0 Mart*0296 Ad(k)=FRACTIONAL_AREA
0297 IC=0
6580feb7eb Jean*0298
0299
0300
893df04db0 Mart*0301 DO IC=1,Max_ABE_Iterations
6580feb7eb Jean*0302
0303
0304
893df04db0 Mart*0305 Md(k)=Wd(k)*Ad(k)
6580feb7eb Jean*0306
893df04db0 Mart*0307 DO k2=k+1,maxDepth
0308 Md(k2)=Md(k)*PlumeEntrainment(k2)
0309 #ifdef ALLOW_OPPS_DEBUG
0310 IF ( OPPSdebugLevel.GE.debLevA ) THEN
3daafce20b Jean*0311 WRITE(msgBuf,'(A,2E12.4,I3)')
893df04db0 Mart*0312 & 'S/R OPPS_CALC: Md, Wd, and k are ',Md(k2),Wd(k2),k2
0313 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
0314 & SQUEEZE_RIGHT , 1)
0315 ENDIF
0316 #endif /* ALLOW_OPPS_DEBUG */
0317 ENDDO
6580feb7eb Jean*0318
0319
0320
0321
0322
0323
0324
0325
0326
893df04db0 Mart*0327 dt = dtts
0328 do k2=k,maxDepth-1
0329 IF ( Wd(K2) .NE. 0. _d 0 ) dt = min(dt,drF(k2)/Wd(k2))
6580feb7eb Jean*0330
0331
0332
0333
893df04db0 Mart*0334 ntime = nint(0.5*int(dtts/dt))
0335 if(ntime.eq.0) then
0336 ntime = 1
0337 endif
6580feb7eb Jean*0338
0339
0340
0341
0342
893df04db0 Mart*0343 mda(k2) = (md(k2)*drF(k2)+md(k2+1)*drF(k2+1))/
0344 * (drF(k2)+drF(k2+1))
6580feb7eb Jean*0345
893df04db0 Mart*0346 wda(k2) = (wd(k2)*drF(k2)+wd(k2+1)*drF(k2+1))/
0347 * (drF(k2)+drF(k2+1))
6580feb7eb Jean*0348
893df04db0 Mart*0349 DO ktr = 1, nTracerInUse
0350 Pda(k2,ktr) = Pd(k2,ktr)
0351 Paa(k2,ktr) = tracerEnv(k2+1,ktr)
98bf704dd5 Jean*0352 ENDDO
6580feb7eb Jean*0353
893df04db0 Mart*0354 enddo
0355 dt = min(dt,dtts)
0356 #ifdef ALLOW_OPPS_DEBUG
0357 IF ( OPPSdebugLevel.GE.debLevA ) THEN
3daafce20b Jean*0358 WRITE(msgBuf,'(A,F14.4)')
893df04db0 Mart*0359 & 'S/R OPPS_CALC: time step = ', dt
0360 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
0361 & SQUEEZE_RIGHT , 1)
0362 ENDIF
0363 #endif /* ALLOW_OPPS_DEBUG */
0364 DO ktr=1,nTracerInUse
0365 Pda(maxdepth,ktr) = Pd(maxdepth,ktr)
98bf704dd5 Jean*0366 ENDDO
6580feb7eb Jean*0367
893df04db0 Mart*0368 kmx = maxdepth-1
0369 do nn=1,ntime
6580feb7eb Jean*0370
3daafce20b Jean*0371
6580feb7eb Jean*0372
893df04db0 Mart*0373 DO ktr = 1,nTracerInUse
0374 tracerEnv(k,ktr) = tracerEnv(k,ktr)-
0375 & (mda(k)*(Pda(k,ktr)-Paa(k,ktr)))*dt*recip_drF(k)
98bf704dd5 Jean*0376 ENDDO
6580feb7eb Jean*0377
0378
0379
893df04db0 Mart*0380
3daafce20b Jean*0381
893df04db0 Mart*0382
0383
0384
0385 DO k2=k+1,kmx
0386 k2m1 = max(k,k2-1)
0387 k2p1 = max(k2+1,maxDepth)
6580feb7eb Jean*0388
893df04db0 Mart*0389 DO ktr = 1,nTracerInUse
0390 tracerEnv(k2,ktr) = tracerEnv(k2,ktr) +
0391 & (mda(k2m1)*(Pda(k2m1,ktr)-Paa(k2m1,ktr))
0392 & -mda(k2) *(Pda(k2,ktr) -Paa(k2,ktr)) )
0393 & *dt*recip_drF(k2)
3daafce20b Jean*0394 ENDDO
893df04db0 Mart*0395 ENDDO
3daafce20b Jean*0396
893df04db0 Mart*0397
6580feb7eb Jean*0398
893df04db0 Mart*0399
6580feb7eb Jean*0400
893df04db0 Mart*0401 DO ktr=1,nTracerInUse
0402 tracerEnv(kmx+1,ktr) = tracerEnv(kmx+1,ktr)+
0403 & mda(kmx)*(Pda(kmx,ktr)-Paa(kmx,ktr))*dt*recip_drF(kmx+1)
0404 ENDDO
6580feb7eb Jean*0405
0406
0407
893df04db0 Mart*0408 DO ktr=1,nTracerInUse
0409 DO k2=1,kmx
0410 paa(k2,ktr) = tracerEnv(k2+1,ktr)
0411 ENDDO
98bf704dd5 Jean*0412 ENDDO
6580feb7eb Jean*0413
0414
0415
893df04db0 Mart*0416 enddo
0417 ENDDO
6580feb7eb Jean*0418
893df04db0 Mart*0419
6580feb7eb Jean*0420
016b84c482 Mart*0421 OPPSconvectCount(I,J,K) = OPPSconvectCount(I,J,K) + 1. _d 0
6580feb7eb Jean*0422
893df04db0 Mart*0423
0424
6580feb7eb Jean*0425
893df04db0 Mart*0426 1000 continue
6580feb7eb Jean*0427
893df04db0 Mart*0428
6580feb7eb Jean*0429
3daafce20b Jean*0430 ENDDO
893df04db0 Mart*0431
94a46dfe0d Jean*0432
893df04db0 Mart*0433 ENDIF
0434
0435 RETURN
0436 END
6580feb7eb Jean*0437
0438
0439
0440 _RL FUNCTION STATE1( sLoc, tLoc, i, j, kRef, bi, bj, myThid )
0441
893df04db0 Mart*0442
0443
0444
0445
0446
0447
0448
0449
0450
0451
0452
0453 IMPLICIT NONE
0454
0455 #include "SIZE.h"
0456 #include "EEPARAMS.h"
0457 #include "PARAMS.h"
0458 #include "GRID.h"
0459 #include "DYNVARS.h"
1a15b18a09 Jean*0460 #ifdef ALLOW_NONHYDROSTATIC
0461 # include "NH_VARS.h"
0462 #endif /* ALLOW_NONHYDROSTATIC */
893df04db0 Mart*0463
0464
0465
6580feb7eb Jean*0466 INTEGER i, j, kRef, bi, bj, myThid
0467 _RL tLoc, sLoc
893df04db0 Mart*0468
0469
0470
6580feb7eb Jean*0471 _RL rhoLoc
893df04db0 Mart*0472 _RL pLoc
0473
0474
0475
0476
0477
6580feb7eb Jean*0478 IF ( usingZCoords ) THEN
893df04db0 Mart*0479
1a15b18a09 Jean*0480 #ifdef ALLOW_NONHYDROSTATIC
0481 IF ( selectP_inEOS_Zc.EQ.3 ) THEN
0482 pLoc = rhoConst*( totPhiHyd(i,j,kRef,bi,bj)
0483 & + phi_nh(i,j,kRef,bi,bj)
0484 & + phiRef(2*kRef)
0485 & )*maskC(i,j,kRef,bi,bj)
0486 ELSEIF ( selectP_inEOS_Zc.EQ.2 ) THEN
0487 #else /* ALLOW_NONHYDROSTATIC */
0488 IF ( selectP_inEOS_Zc.EQ.2 ) THEN
0489 #endif /* ALLOW_NONHYDROSTATIC */
893df04db0 Mart*0490
0491
1a15b18a09 Jean*0492
893df04db0 Mart*0493
0494 pLoc = rhoConst*( totPhiHyd(i,j,kRef,bi,bj)
1a15b18a09 Jean*0495 & + phiRef(2*kRef)
0496 & )*maskC(i,j,kRef,bi,bj)
0497
0498
0499
0500 ELSEIF ( selectP_inEOS_Zc.LE.1 ) THEN
0501 pLoc = pRef4EOS(kRef)*maskC(i,j,kRef,bi,bj)
893df04db0 Mart*0502 ELSE
1a15b18a09 Jean*0503 pLoc = rhoConst*phiRef(2*kRef)*maskC(i,j,kRef,bi,bj)
893df04db0 Mart*0504 ENDIF
6580feb7eb Jean*0505 ELSEIF ( usingPCoords ) THEN
1a15b18a09 Jean*0506
893df04db0 Mart*0507 pLoc = rC(kRef)* maskC(i,j,kRef,bi,bj)
0508 ENDIF
0509
6580feb7eb Jean*0510 CALL FIND_RHO_SCALAR( tLoc, sLoc, pLoc, rhoLoc, myThid )
0511 STATE1 = rhoLoc
893df04db0 Mart*0512
0513 #endif /* ALLOW_OPPS */
0514 RETURN
0515 END
0516
0517 #ifdef OPPS_ORGCODE
6580feb7eb Jean*0518
0519
0520
0521
0522
893df04db0 Mart*0523
6580feb7eb Jean*0524
0525
0526
0527
0528
29188f9691 Jean*0529
0530
0531
0532
893df04db0 Mart*0533
0534 subroutine nlopps(j,is,ie,ta,sa,gcmdz)
6580feb7eb Jean*0535
893df04db0 Mart*0536 parameter (imt = 361 , jmt = 301 , km = 30 )
6580feb7eb Jean*0537
0538
0539
0540
0541
0542
0543
0544
0545
0546
0547
0548
0549
0550
0551
0552
0553
0554
0555
0556
0557
0558
0559
893df04db0 Mart*0560
0561
0562
0563
0564
0565
0566 real ta(imt,km),sa(imt,km),gcmdz(km),dz(km)
0567 real pdensity,wsqr,oldflux,newflux,entrainrate,adtemp
0568 REAL Del,D,dza1,dza2,kd,kd1,Smix,Thmix,PlumeS,PlumeT,PlumeD
0569
0570 INTEGER i,j,k
6580feb7eb Jean*0571
893df04db0 Mart*0572 integer is,ie,k2
6580feb7eb Jean*0573
893df04db0 Mart*0574 REAL D1,D2,state1,Density
0575 REAL dz1,dz2
0576 REAL radius,StartingFlux
0577 real ttemp(km),stemp(km),taa(km),saa(km)
0578 real wda(km),tda(km),sda(km),mda(km)
0579 real dtts,dt,sumo,sumn
0580 integer ntime,nn,kmx,ic
6580feb7eb Jean*0581
893df04db0 Mart*0582 LOGICAL debug,done
0583 INTEGER MAX_ABE_ITERATIONS
0584 PARAMETER(MAX_ABE_ITERATIONS=1)
0585 REAL PlumeRadius
0586 REAL STABILITY_THRESHOLD
0587 REAL FRACTIONAL_AREA
0588 REAL MAX_FRACTIONAL_AREA
0589 REAL VERTICAL_VELOCITY
0590 REAL ENTRAINMENT_RATE
0591 REAL e2
0592 PARAMETER ( PlumeRadius = 100.D0 )
0593 PARAMETER ( STABILITY_THRESHOLD = -1.E-4 )
0594 PARAMETER ( FRACTIONAL_AREA = .1E0 )
0595 PARAMETER ( MAX_FRACTIONAL_AREA = .8E0 )
0596 PARAMETER ( VERTICAL_VELOCITY = .02E0 )
0597 PARAMETER ( ENTRAINMENT_RATE = -.05E0 )
0598 PARAMETER ( e2 = 2.E0*ENTRAINMENT_RATE )
0599
0600 REAL Ad(km),Sd(km),Td(km),Wd(km),Dd(km),Md(km)
0601 REAL Se(km),Te(km),We(km),De(km)
0602 REAL PlumeEntrainment(km)
0603 REAL GridThickness(km)
0604
6580feb7eb Jean*0605
0606
893df04db0 Mart*0607 common / boundc / wsx(imt,jmt),wsy(imt,jmt),hfs(imt,jmt),
0608 1 ple(imt,jmt),kmp(imt,jmt),kmq(imt,jmt)
0609
0610 & ,wsx1(imt,jmt),wsy1(imt,jmt)
0611 1 ,wsx2(imt,jmt),wsy2(imt,jmt)
6580feb7eb Jean*0612
0613
0614
893df04db0 Mart*0615 logical problem
0616 common /countc/ convadj(imt,jmt,km),ics,depth(km),problem
0617
6580feb7eb Jean*0618
0619
0620
893df04db0 Mart*0621
0622 dtts = 2400
6580feb7eb Jean*0623
893df04db0 Mart*0624 do k=1,km
0625 dz(k) = 0.01*gcmdz(k)
0626 enddo
6580feb7eb Jean*0627
893df04db0 Mart*0628 do k=1,km
0629 GridThickness(k) = dz(k)
0630 enddo
6580feb7eb Jean*0631
0632
0633
893df04db0 Mart*0634 DO i=is,ie
0635
0636 numgridpoints=kmp(i,j)
6580feb7eb Jean*0637
0638
0639
893df04db0 Mart*0640 if(numgridpoints.le.1) goto 1100
6580feb7eb Jean*0641
0642
0643
893df04db0 Mart*0644 debug = .false.
6580feb7eb Jean*0645
0646
0647
893df04db0 Mart*0648 DO k=1,NumGridPoints
0649 stemp(k)=sa(i,k)
0650 ttemp(k)=ta(i,k)
6580feb7eb Jean*0651
0652
0653
893df04db0 Mart*0654 if(problem) then
0655 write(0,*)"Code in trouble before this nlopps call"
0656 return
0657 endif
6580feb7eb Jean*0658
893df04db0 Mart*0659 if(sa(i,k).gt.40..or.ta(i,k).lt.-4.0) then
0660 problem = .true.
0661 write(0,*)"t out of range at j ",j
0662 debug = .true.
0663 return
0664 endif
0665 ENDDO
0666
0667 if(debug) then
0668 write(*,*)"T and S Profile at ",i,j
0669 write(*,*)(ta(i,k),sa(i,k),k=1,NumGridPoints)
0670 endif
0671
0672 DO k=1,NumGridPoints-1
6580feb7eb Jean*0673
0674
0675
893df04db0 Mart*0676 Sd(k)=stemp(k)
0677 Td(k)=ttemp(k)
0678 Dd(k)=state1(stemp(k),ttemp(k),k)
0679 De(k)=Dd(k)
0680
6580feb7eb Jean*0681
0682
0683
893df04db0 Mart*0684 Wd(k) = 0.03
6580feb7eb Jean*0685
0686
0687
0688
893df04db0 Mart*0689
0690
6580feb7eb Jean*0691
893df04db0 Mart*0692 wsqr=Wd(k)*Wd(k)
0693 PlumeEntrainment(k) = 0.0
6580feb7eb Jean*0694
893df04db0 Mart*0695 if(debug) write(0,*) 'Doing old lowerparcel'
0696 radius=PlumeRadius
0697 StartingFlux=radius*radius*Wd(k)*Dd(k)
0698 oldflux=StartingFlux
3daafce20b Jean*0699
893df04db0 Mart*0700 dz2=GridThickness(k)
0701 DO k2=k,NumGridPoints-1
0702 D1=state1(Sd(k2),Td(k2),k2+1)
0703 D2=state1(stemp(k2+1),ttemp(k2+1),k2+1)
0704 De(k2+1)=D2
6580feb7eb Jean*0705
0706
0707
0708
0709
893df04db0 Mart*0710 IF (D2-D1 .LT. STABILITY_THRESHOLD.or.k2.ne.k) THEN
0711 dz1=dz2
0712 dz2=GridThickness(k2+1)
6580feb7eb Jean*0713
0714
0715
893df04db0 Mart*0716 newflux=oldflux+e2*radius*Wd(k2)*Dd(k2)*0.50*
0717 . (dz1+dz2)
6580feb7eb Jean*0718
893df04db0 Mart*0719 PlumeEntrainment(k2+1) = newflux/StartingFlux
6580feb7eb Jean*0720
893df04db0 Mart*0721 IF(newflux.LT.0.0) then
0722 if(debug) then
0723 write(0,*)"Plume entrained to zero at ",k2
0724 endif
0725 maxdepth = k2
0726 if(maxdepth.eq.k) goto 1000
0727 goto 1
0728 endif
6580feb7eb Jean*0729
0730
0731
893df04db0 Mart*0732 entrainrate = (newflux - oldflux)/newflux
0733 oldflux = newflux
6580feb7eb Jean*0734
0735
0736
893df04db0 Mart*0737 smix=(dz1*stemp(k2)+dz2*stemp(k2+1))/(dz1+dz2)
0738 thmix=(dz1*ttemp(k2)+dz2*ttemp(k2+1))/(dz1+dz2)
6580feb7eb Jean*0739
0740
0741
0742
893df04db0 Mart*0743 sd(k2+1)=sd(k2) - entrainrate*(smix - sd(k2))
0744 td(k2+1)=td(k2) - entrainrate*(thmix - td(k2))
6580feb7eb Jean*0745
0746
0747
0748
893df04db0 Mart*0749 Dd(k2+1)=state1(Sd(k2+1),Td(k2+1),k2+1)
6580feb7eb Jean*0750
0751
0752
0753
893df04db0 Mart*0754 if(debug) then
a6de755a30 Jean*0755 write(0,*)"Dd,De,entr,k ",Dd(k2),De(k2),entrainrate,k2
893df04db0 Mart*0756 endif
6580feb7eb Jean*0757
893df04db0 Mart*0758 wsqr = wsqr - wsqr*abs(entrainrate)+ 9.81*
0759 . (dz1*(Dd(k2)-De(k2))/De(k2)
0760 . +dz2*(Dd(k2+1)-De(k2+1))/De(k2+1))
6580feb7eb Jean*0761
0762
0763
893df04db0 Mart*0764 IF(wsqr.LT.0.0)then
0765 maxdepth = k2
0766 if(debug) then
0767 write(0,*)"Plume velocity went to zero at ",k2
0768 endif
0769 if(maxdepth.eq.k) goto 1000
0770 goto 1
0771 endif
0772 Wd(k2+1)=sqrt(wsqr)
6580feb7eb Jean*0773
0774
0775
893df04db0 Mart*0776 radius=sqrt(newflux/(Wd(k2)*Dd(k2)))
0777 ELSE
0778 maxdepth=k2
0779 if(maxdepth.eq.k) goto 1000
0780 GOTO 1
0781 ENDIF
0782 ENDDO
6580feb7eb Jean*0783
0784
0785
893df04db0 Mart*0786 MaxDepth=NumGridPoints
6580feb7eb Jean*0787
893df04db0 Mart*0788 1 continue
6580feb7eb Jean*0789
893df04db0 Mart*0790 Ad(k)=FRACTIONAL_AREA
0791 IC=0
6580feb7eb Jean*0792
0793
0794
893df04db0 Mart*0795 DO IC=1,Max_ABE_Iterations
6580feb7eb Jean*0796
0797
0798
893df04db0 Mart*0799 92 continue
0800 Md(k)=Wd(k)*Ad(k)
6580feb7eb Jean*0801
893df04db0 Mart*0802 DO k2=k+1,MaxDepth
0803 Md(k2)=Md(k)*PlumeEntrainment(k2)
0804 if(debug) then
0805 write(0,*)"Md, Wd, and k are ",Md(k2),Wd(k2),k2
0806 endif
0807 ENDDO
6580feb7eb Jean*0808
0809
0810
0811
0812
0813
0814
0815
0816
0817
893df04db0 Mart*0818 dt = dtts
0819 do k2=k,maxdepth-1
0820 dt = min(dt,dz(k2)/wd(k2))
6580feb7eb Jean*0821
0822
0823
0824
893df04db0 Mart*0825 ntime = nint(0.5*int(dtts/dt))
0826 if(ntime.eq.0) then
0827 ntime = 1
0828 endif
6580feb7eb Jean*0829
0830
0831
0832
0833
893df04db0 Mart*0834 mda(k2) = (md(k2)*dz(k2)+md(k2+1)*dz(k2+1))/
0835 * (dz(k2)+dz(k2+1))
6580feb7eb Jean*0836
893df04db0 Mart*0837 wda(k2) = (wd(k2)*dz(k2)+wd(k2+1)*dz(k2+1))/
0838 * (dz(k2)+dz(k2+1))
6580feb7eb Jean*0839
893df04db0 Mart*0840 tda(k2) = td(k2)
0841 sda(k2) = sd(k2)
6580feb7eb Jean*0842
893df04db0 Mart*0843 taa(k2) = ttemp(k2+1)
0844 saa(k2) = stemp(k2+1)
6580feb7eb Jean*0845
893df04db0 Mart*0846 enddo
0847 dt = min(dt,dtts)
0848 if(debug) then
0849 write(0,*)"Time step is ", dt
0850 endif
0851 tda(maxdepth) = td(maxdepth)
0852 sda(maxdepth) = sd(maxdepth)
6580feb7eb Jean*0853
0854
0855
893df04db0 Mart*0856 kmx = maxdepth-1
0857 do nn=1,ntime
0858
0859 ttemp(k) = ttemp(k)-
0860 * (mda(k)*(tda(k)-taa(k)))*dt*recip_drF(k)
6580feb7eb Jean*0861
893df04db0 Mart*0862 stemp(k) = stemp(k)-
0863 * (mda(k)*(sda(k)-saa(k)))*dt*recip_drF(k)
6580feb7eb Jean*0864
0865
0866
893df04db0 Mart*0867 if(Maxdepth-k.gt.1) then
0868 do k2=k+1,Maxdepth-1
6580feb7eb Jean*0869
893df04db0 Mart*0870 ttemp(k2) = ttemp(k2) +
0871 * (mda(k2-1)*(tda(k2-1)-taa(k2-1))-
0872 * mda(k2)*(tda(k2)-taa(k2)))
0873 * *dt*recip_drF(k2)
0874
0875 stemp(k2) = stemp(k2) +
0876 * (mda(k2-1)*(sda(k2-1)-saa(k2-1))-
0877 * mda(k2)*(sda(k2)-saa(k2)))
0878 * *dt*recip_drF(k2)
0879
0880 enddo
0881 endif
0882 ttemp(kmx+1) = ttemp(kmx+1)+
0883 * (mda(kmx)*(tda(kmx)-taa(kmx)))*
0884 * dt*recip_drF(kmx+1)
6580feb7eb Jean*0885
893df04db0 Mart*0886 stemp(kmx+1) = stemp(kmx+1)+
0887 * (mda(kmx)*(sda(kmx)-saa(kmx)))*
0888 * dt*recip_drF(kmx+1)
6580feb7eb Jean*0889
0890
0891
893df04db0 Mart*0892 do k2=1,maxdepth-1
0893 taa(k2) = ttemp(k2+1)
0894 saa(k2) = stemp(k2+1)
0895 enddo
6580feb7eb Jean*0896
0897
0898
893df04db0 Mart*0899 enddo
0900 ENDDO
0901 999 continue
6580feb7eb Jean*0902
0903
0904
893df04db0 Mart*0905
0906
0907
0908 do k2=k,maxdepth
0909 convadj(i,j,k2) = convadj(i,j,k2) + (ttemp(k2)-
0910 * ta(i,k2))
0911 sa(i,k2) = stemp(k2)
0912 ta(i,k2) = ttemp(k2)
0913
0914
0915
6580feb7eb Jean*0916
0917
0918
893df04db0 Mart*0919 if(sa(i,k).gt.40..or.ta(i,k).lt.-4.0) then
0920 problem = .true.
0921 write(0,*)"t out of range at j after adjust",j
0922 debug = .true.
0923 endif
6580feb7eb Jean*0924
893df04db0 Mart*0925 enddo
6580feb7eb Jean*0926
0927
0928
0929
893df04db0 Mart*0930 1000 continue
6580feb7eb Jean*0931
0932
0933
3daafce20b Jean*0934 ENDDO
893df04db0 Mart*0935 1100 continue
6580feb7eb Jean*0936
0937
0938
893df04db0 Mart*0939 ENDDO
0940 END
0941
6611306112 Ed H*0942 #endif /* OPPS_ORGCODE */