The TELEMAC-MASCARET system  trunk
cvsp_init.f
Go to the documentation of this file.
1 ! ********************
2  SUBROUTINE cvsp_init
3 ! ********************
4 !
5 !***********************************************************************
6 ! SISYPHE V7P2 16/05/2017
7 !***********************************************************************
8 !
9 !brief INITS A VERTICAL SORTING PROFILE BY USING HIRANO LAYERS
10 ! OR USER CODING
11 !
12 !history UWE MERKEL
13 !+ 20/07/2011
14 !+ V6P2
15 !+
16 !
17 !history P. A. TASSI (EDF R&D, LNHE)
18 !+ 12/03/2013
19 !+ V6P3
20 !+ Cleaning, cosmetic
21 !
22 !history U. MERKEL, R.KOPMANN (BAW)
23 !+ 21/07/2016
24 !+ V6P3, V7P2
25 !+ Integrating init_from_layers in this subroutine
26 !
27 !history R.KOPMANN (BAW)
28 !+ 19/02/2019
29 !+ V7P2
30 !+ Initial volume calculated with CVSP variables
31 !
32 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33 !| J |<--| INDEX OF A POINT IN MESH
34 !| I |<--| INDEX OF A FRACTION
35 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
36 !
38  USE cvsp_outputfiles, ONLY: cp
39  USE interface_parallel, ONLY : p_dsum
40 !
41  IMPLICIT NONE
42 !
43  INTEGER I,J,K,L,M
44  DOUBLE PRECISION DEPTH
45  LOGICAL RET, CVSP_CHECK_L, CVSP_CHECK_F
46 !
47 !-----------------------------------------------------------------------
48 !
49  IF(cp) WRITE(lu,*) 'CVSP_INIT'
50 
51  DO j=1,npoin
52  DO k=1,nomblay
53  ret = cvsp_check_l(j,k,' CVSP_INIT: ')
54  ENDDO
55  ENDDO
56 !
57  ALLOCATE(pro_d(npoin,pro_max_max,nsicla))
58  ALLOCATE(pro_f(npoin,pro_max_max,nsicla))
59  ALLOCATE(pro_max(npoin))
60 !
61 !-----------------------------------------------------------------------
62 !
63  DO j=1,npoin
64  depth = 0.d0 ! INIT DEPTH OF THE VSP
65  pro_max(j) = 2* nlayer%I(j) ! 2 SECTION POINTS PER LAYER
66  l = pro_max(j)+1
67 !
68 !-----------------------------------------------------------------------
69 ! BUILDING SECTIONS
70 !-----------------------------------------------------------------------
71 !
72  DO m=1,nlayer%I(j)
73  IF (abs(es(j,m)).GT.0.d0) THEN
74  l = l - 1
75  DO i=1,nsicla
76  pro_d(j,l,i) = zf%R(j) - depth
77  pro_f(j,l,i) = avail(j,m,i)
78  ENDDO
79  depth = depth + es(j,m)
80  l = l - 1
81  DO i=1,nsicla
82  pro_d(j,l,i) = zf%R(j) - depth
83  IF(m==nlayer%I(j)) THEN
84  pro_f(j,l,i) = avail(j,m,i)
85  ELSE
86  pro_f(j,l,i) = avail(j,m+1,i)
87  ENDIF
88  ENDDO
89  ret = cvsp_check_f(j,l,'FromLay: ')
90  ENDIF
91  ENDDO
92 
93 !-----------------------------------------------------------------------
94 ! USER CODING
95 !-----------------------------------------------------------------------
96 ! PRO_MAX(J) = PRO_MAX_MAX
97 ! DO K=1,PRO_MAX(J)
98 ! DO I=1,NSICLA
99 ! PRO_D(J,K,I) = (ZF%R(J)-ZF%R(J))/PRO_MAX(J)*K
100 ! PRO_F(J,K,1) = 1.D0 / NSICLA
101 ! ENDDO
102 !-----------------------------------------------------------------------
103 ! FINAL CHECKS
104 !-----------------------------------------------------------------------
105  IF (abs(zf%R(j) - zr%R(j) - depth).GT.10.d-6) THEN
106  WRITE(lu,*)'Depth Synchro Error for Point J: ',j
107  WRITE(lu,*)zf%R(j),zr%R(j),depth,abs(zf%R(j)-zr%R(j)-depth)
108  ENDIF
109 !
110  ENDDO !J=1,NPOIN
111 !-----------------------------------------------------------------------
112  DO j=1,npoin
113  DO l=1,pro_max(j)
114  ret = cvsp_check_f(j,l,'AfterLAY: ')
115  END DO
116  CALL cvsp_check_steady(j)
117  END DO
118 
119 !-----------------------------------------------------------------------
120  CALL cvsp_check_anything()
121 
122 !INITIALISIATION OUTPUT TO SERAFIN FILE
123  IF (cvsm_out_full) CALL cvsp_output_init()
125 !
126 ! CALCULATING THE VOLUME SEEN FROM CVSM MODEL
127  DO i = 1, nsicla
128  voltot(i) = 0.d0
129  ENDDO
130 !
131  DO i=1,nsicla
132  DO j=1,npoin
133  DO k=1,pro_max(j)-1
134  voltot(i) = voltot(i) + (pro_f(j,k,i)+pro_f(j,k+1,i))/2.d0
135  & *(pro_d(j,k+1,i)-pro_d(j,k,i))*volu2d%R(j)
136  ENDDO
137  ENDDO
138  ENDDO
139  IF(ncsize.GT.1) THEN
140  DO i=1,nsicla
141  voltot(i) = p_dsum(voltot(i))
142  ENDDO
143  ENDIF
144 !
145  DO i=1,nsicla
146  volini(i) = voltot(i)
147  ENDDO
148 !
149  RETURN
150  END SUBROUTINE cvsp_init
type(bief_obj), target zr
double precision, dimension(:,:,:), allocatable, target pro_f
type(bief_obj), target nlayer
type(bief_obj), target zf
subroutine cvsp_check_anything
double precision, dimension(nsiclm) volini
double precision, dimension(nsiclm) voltot
subroutine cvsp_write_profile
integer, dimension(:), allocatable pro_max
double precision function p_dsum(MYPART)
Definition: p_dsum.F:7
double precision, dimension(:,:,:), allocatable, target avail
subroutine cvsp_check_steady(J)
subroutine cvsp_output_init
subroutine cvsp_init
Definition: cvsp_init.f:4
double precision, dimension(:,:,:), allocatable, target pro_d
type(bief_obj), target volu2d
double precision, dimension(:,:), allocatable, target es