source: codes/icosagcm/trunk/src/disvert_strato.f90 @ 521

Last change on this file since 521 was 467, checked in by dubos, 8 years ago

Merged with HEAT branch - testing required for : etat0_database, disvert_strato

File size: 2.1 KB
Line 
1MODULE disvert_strato_mod
2  USE icosa
3  REAL(rstd), SAVE, ALLOCATABLE,TARGET :: ap(:)
4!$OMP THREADPRIVATE(ap)
5  REAL(rstd), SAVE, ALLOCATABLE,TARGET :: bp(:)
6!$OMP THREADPRIVATE(bp)
7  REAL(rstd), SAVE, ALLOCATABLE,TARGET :: presnivs(:)
8!$OMP THREADPRIVATE(presnivs)
9
10CONTAINS
11
12  SUBROUTINE init_disvert
13  USE icosa
14  IMPLICIT NONE
15 
16    ALLOCATE(ap(llm+1))
17    ALLOCATE(bp(llm+1))
18    ALLOCATE(presnivs(llm))
19
20    CALL disvert(ap,bp,presnivs)   
21
22  END SUBROUTINE init_disvert 
23
24
25  SUBROUTINE disvert(ap,bp,presnivs)
26  USE icosa
27  USE mpipara
28  USE earth_const
29  IMPLICIT NONE
30  REAL(rstd),INTENT(OUT) :: ap(:)
31  REAL(rstd),INTENT(OUT) :: bp(:)
32  REAL(rstd),INTENT(OUT) :: presnivs(:)
33 
34  REAL(rstd) :: dsig(llm)
35  REAL(rstd) :: sig(llm+1)
36  REAL(rstd) :: snorm
37  REAL(rstd) :: x
38  INTEGER :: l
39 
40    snorm  = 0.
41    DO l = 1, llm
42      x = Pi*(l-0.5)/(llm+1)
43      dsig(l) = (1.0 + 7.0 * SIN(x)**2) * (0.5* (1.-tanh( (x-Pi/2)/(Pi/2) ) ))**2
44      snorm = snorm + dsig(l)
45    ENDDO   
46   
47    DO l = 1, llm
48      dsig(l) = dsig(l)/snorm
49    ENDDO
50
51    sig(llm+1) = 0.
52    DO l = llm, 1, -1
53      sig(l) = sig(l+1) + dsig(l)
54    ENDDO
55
56    bp(llm+1) =   0.
57    DO l = 1, llm
58      bp(l) = EXP( 1. -1./( sig(l)*sig(l)) )
59      ap(l) = pa * ( sig(l) - bp(l) )
60    ENDDO
61    bp(1)=1.
62    ap(1)=0.
63    ap(llm+1) = pa * ( sig(llm+1) - bp(llm+1) )
64    DO l = 1, llm
65      presnivs(l) = 0.5 *( ap(l)+bp(l)*preff + ap(l+1)+bp(l+1)*preff )
66    ENDDO
67   
68    ! tell the world about it
69    IF (is_mpi_root) THEN
70!$OMP MASTER
71      WRITE(*,*) "ap()=",ap
72      WRITE(*,*) "bp()=",bp
73      WRITE(*,*) "Approximative mid-layer pressure, assuming a surface pressure preff=",preff," Pa"
74      WRITE(*,*) "and approximative mid-layer height, assuming an atmospheric scale height of ",scale_height/1000," (km)"
75      DO l=1,llm
76        WRITE(*,*) 'PRESNIVS(',l,')=',presnivs(l),'  Z ~ ',log(preff/presnivs(l))*scale_height/1000,       &
77                   ' DZ ~ ',scale_height/1000*log((ap(l)+bp(l)*preff)/ max(ap(l+1)+bp(l+1)*preff,1.e-10))
78      ENDDO
79!$OMP END MASTER
80    ENDIF
81 
82  END SUBROUTINE disvert
83 
84END MODULE disvert_strato_mod
Note: See TracBrowser for help on using the repository browser.