Newer
Older

WAUTELET Philippe
committed
!MNH_LIC Copyright 1994-2020 CNRS, Meteo-France and Universite Paul Sabatier
!MNH_LIC This is part of the Meso-NH software governed by the CeCILL-C licence
!MNH_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt
!MNH_LIC for details. version 1.
!-----------------------------------------------------------------
! ####################
MODULE MODE_GRIDCART
! ####################
!
!!**** *MODE_GRIDCART* - module routine SM_GRIDCART
!!
!! PURPOSE
!! -------
! The purpose of this executive module is to package
! the routine SM_GRIDCART
!
!
!
!!
!!** IMPLICIT ARGUMENTS
!! ------------------
!! NONE
!!
!! REFERENCE
!! ---------
!!
!!
!! AUTHOR
!! ------
!! V. Ducrocq * Meteo France *
!!
!! MODIFICATIONS
!! -------------
!! Original 06/05/94
!! J.Escobar : 15/09/2015 : WENO5 & JPHEXT <> 1
!! Philippe Wautelet: 05/2016-04/2018: new data structures and calls for I/O

WAUTELET Philippe
committed
! P. Wautelet 20/05/2019: add name argument to ADDnFIELD_ll + new ADD4DFIELD_ll subroutine
! P. Wautelet 07/12/2020: bugfix: deallocate correctly TZHALO1_ll
!--------------------------------------------------------------------------------
!
!* 0. DECLARATIONS
! ------------
!
!-------------------------------------------------------------------------------
!
CONTAINS
!-------------------------------------------------------------------------------
!-------------------------------------------------------------------------------
!
!* 1. ROUTINE SM_GRIDCART
! -------------------
!-------------------------------------------------------------------------------
! #########################################################################
SUBROUTINE SM_GRIDCART(PXHAT,PYHAT,PZHAT,PZS,OSLEVE,PLEN1,PLEN2,PZSMT,PDXHAT,PDYHAT,PZZ,PJ)
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
! #########################################################################
!
!!**** *SM_GRIDCART * - routine to compute J
!!
!! PURPOSE
!! -------
! The purpose of this routine is to compute the Jacobian (J) in the case
! of a cartesian geometry
!
!
!!** METHOD
!! ------
!! The height z is first determined, and then J is computed
!!
!!
!! EXTERNAL
!! --------
!! NONE
!!
!! IMPLICIT ARGUMENTS
!! ------------------
!! Module MODD_PARAMETERS : contains array border depths
!!
!! JPHEXT,JPVEXT : Arrays border zone depth
!!
!! Module MODD_CONF : contains configuration variables for
!! all models
!
!! NVERB : Listing verbosity
!!
!! REFERENCE
!! ---------
!! Technical Specifications Report of the Meso-NH project (chapters 2 and 3)
!!
!!
!! AUTHOR
!! ------
!! V. Ducrocq * Meteo France *
!!
!! MODIFICATIONS
!! -------------
!! Original 06/05/94
!! updated V. Ducrocq *Meteo France* 27/06/94
!! Updated P.M. *LA* 22/07/94
!! Updated V. Ducrocq *Meteo France* 23/08/94
!! Updated J. Escobar *LA* 20/11/01
!! rewrite "EOSHIFT" for portability (IBM-SP3 bug)
!! Sleve coordinate G. Zangler *LA* nov 2005
!-------------------------------------------------------------------------------
!
!* 0. DECLARATIONS
! ------------
!
USE MODE_ll
USE MODD_ARGSLIST_ll, ONLY : LIST1D_ll
USE MODE_ARGSLIST_ll, ONLY : CLEANLIST1D_ll
USE MODD_LUNIT_n, ONLY : TLUOUT
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
!
USE MODD_PARAMETERS
USE MODD_CONF
!
USE MODI_VERT_COORD
!
IMPLICIT NONE
!
!* 0.1 Declarations of arguments
!
REAL, DIMENSION(:), INTENT(IN) :: PXHAT,PYHAT,PZHAT ! positions x,y,z in
! the cartesian plane
REAL, DIMENSION(:,:), INTENT(IN) :: PZS ! orography
LOGICAL, INTENT(IN) :: OSLEVE ! flag for SLEVE coordinate
REAL, INTENT(IN) :: PLEN1 ! Decay scale for smooth topography
REAL, INTENT(IN) :: PLEN2 ! Decay scale for small-scale topography deviation
REAL, DIMENSION(:,:), INTENT(IN) :: PZSMT ! smooth orography
!
REAL, DIMENSION(:), INTENT(OUT) :: PDXHAT ! meshlength in x
! direction
REAL, DIMENSION(:), INTENT(OUT) :: PDYHAT ! meshlength in y
! direction
REAL, DIMENSION(:,:,:), INTENT(OUT) :: PZZ ! Height z
REAL, DIMENSION(:,:,:), INTENT(OUT) :: PJ ! Jacobian of the
! GCS transformation
!
!* 0.2 Declarations of local variables
!
REAL, DIMENSION(SIZE(PXHAT,1),SIZE(PYHAT,1),SIZE(PZHAT,1)) :: ZDZ ! meshlength in
! z direction
REAL, DIMENSION(SIZE(PZS,1),SIZE(PZS,2)) :: ZBOUNDZ ! Extrapolated
REAL :: ZBOUNDX,ZBOUNDY ! value for the
! upper bounds in
! z,x,y directions
!
TYPE(LIST1D_ll), POINTER :: TZHALO1_ll ! ! pointer for the list of 1D fields
! that have to be communicated immediatly
INTEGER :: IINFO_ll ! return code of the // routine
INTEGER :: IIB,IJB,IKB ! beginning of useful area of PXHAT,PYHAT,PZHAT
INTEGER :: IIE,IJE,IKE ! end of useful area of PXHAT,PYHAT,PZHAT
INTEGER :: IIU,IJU,IKU ! upper bounds of PXHAT,PYHAT,PZHAT
INTEGER :: IKLOOP ! index for prints
INTEGER :: ILUOUT,IRESP ! logical unit number for prints, error code
!
INTEGER :: JI,JJ,JK ! loop index
!-------------------------------------------------------------------------------
!
!* 1 RETRIEVE LOGICAL UNIT NUMBERFOR OUTPUT-LISTING AND DIMENSIONS
! --------------------------------------------------------------
!
ILUOUT = TLUOUT%NLU
!
IIU = UBOUND(PXHAT,1)
IJU = UBOUND(PYHAT,1)
IKU = UBOUND(PZHAT,1)
CALL GET_INDICE_ll (IIB,IJB,IIE,IJE)
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
IKE = IKU-JPVEXT
IKB = 1+JPVEXT
NULLIFY(TZHALO1_ll)
!
IF(NVERB >= 10) THEN ! Parameter checking
WRITE(ILUOUT,*) 'SM_GRIDCART: IIU,IJU,IKU=',IIU,IJU,IKU
WRITE(ILUOUT,*) 'SM_GRIDCART: IIE,IJE,IKE=',IIE,IJE,IKE
WRITE(ILUOUT,*) 'SM_GRIDCART: IIB,IJB,IKB=',IIB,IJB,IKB
ENDIF
!
!-------------------------------------------------------------------------------
!
!* 2. COMPUTE Z
! ---------
!
CALL VERT_COORD(OSLEVE,PZS,PZSMT,PLEN1,PLEN2,PZHAT,PZZ)
!
IF(NVERB >= 10) THEN !Value control
WRITE(ILUOUT,*) 'SM_GRIDCART: Some PZS values:'
WRITE(ILUOUT,*) PZS(1,1),PZS(IIU/2,IJU/2),PZS(IIU,IJU)
WRITE(ILUOUT,*) 'SM_GRIDCART: Some PZZ values:'
DO IKLOOP=1,IKU
WRITE(ILUOUT,*) PZZ(1,1,IKLOOP),PZZ(IIU/2,IJU/2,IKLOOP), &
PZZ(IIU,IJU,IKLOOP)
END DO
ENDIF
!-------------------------------------------------------------------------------
!
!
!* 3. COMPUTE J
! ---------
!
ZBOUNDX = 2.*PXHAT(IIU) - PXHAT(IIU-1)
ZBOUNDY = 2.*PYHAT(IJU) - PYHAT(IJU-1)
ZBOUNDZ(:,:) = 2.*PZZ(:,:,IKU) - PZZ(:,:,IKU-1)
PDXHAT(:) = EOSHIFT(PXHAT(:) ,1,ZBOUNDX) - PXHAT(:)
PDYHAT(:) = EOSHIFT(PYHAT(:) ,1,ZBOUNDY) - PYHAT(:)
! update PDXHAT and PDYHAT
CALL ADD1DFIELD_ll("X",TZHALO1_ll,PDXHAT)
CALL ADD1DFIELD_ll("Y",TZHALO1_ll,PDYHAT)
CALL UPDATE_1DHALO_ll(TZHALO1_ll,IINFO_ll)

WAUTELET Philippe
committed
CALL CLEANLIST1D_ll( TZHALO1_ll )
!
ZDZ(:,:,1:IKU-1) = PZZ(:,:,2:IKU) - PZZ(:,:,1:IKU-1)
ZDZ(:,:,IKU) = ZBOUNDZ(:,:) - PZZ(:,:,IKU)
DO JK=1,IKU ; DO JJ=1,IJU ; DO JI=1,IIU
PJ(JI,JJ,JK) = PDXHAT(JI) * PDYHAT(JJ) * ZDZ(JI,JJ,JK)
ENDDO ; ENDDO ; ENDDO
!
IF(NVERB >= 10) THEN !Value control
WRITE(ILUOUT,*) 'Some PJ values:'
DO IKLOOP=1,IKU
WRITE(ILUOUT,*) PJ(1,1,IKLOOP),PJ(IIU/2,IJU/2,IKLOOP), &
PJ(IIU,IJU,IKLOOP)
END DO
ENDIF
!
!-------------------------------------------------------------------------------
!
END SUBROUTINE SM_GRIDCART
!-------------------------------------------------------------------------------
END MODULE MODE_GRIDCART