SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
write_gridtype_conf_proj.F90
Go to the documentation of this file.
1 !SFX_LIC Copyright 1994-2014 CNRS, Meteo-France and Universite Paul Sabatier
2 !SFX_LIC This is part of the SURFEX software governed by the CeCILL-C licence
3 !SFX_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt
4 !SFX_LIC for details. version 1.
5 ! #################################################################
6  SUBROUTINE write_gridtype_conf_proj (DGU, U, &
7  hprogram,klu,kgrid_par,pgrid_par,kresp,hdir)
8 ! #################################################################
9 !
10 !!**** *WRITE_GRIDTYPE_CONF_PROJ* - routine to write the horizontal grid
11 !!
12 !! PURPOSE
13 !! -------
14 !!
15 !!** METHOD
16 !! ------
17 !!
18 !! EXTERNAL
19 !! --------
20 !!
21 !!
22 !! IMPLICIT ARGUMENTS
23 !! ------------------
24 !!
25 !! REFERENCE
26 !! ---------
27 !!
28 !!
29 !! AUTHOR
30 !! ------
31 !! V. Masson *Meteo France*
32 !!
33 !! MODIFICATIONS
34 !! -------------
35 !! Original 01/2004
36 !-------------------------------------------------------------------------------
37 !
38 !* 0. DECLARATIONS
39 ! ------------
40 !
41 !
42 !
44 USE modd_surf_atm_n, ONLY : surf_atm_t
45 !
47 !
49 !
50 !
51 USE yomhook ,ONLY : lhook, dr_hook
52 USE parkind1 ,ONLY : jprb
53 !
54 IMPLICIT NONE
55 !
56 !* 0.1 Declarations of arguments
57 ! -------------------------
58 !
59 !
60 TYPE(diag_surf_atm_t), INTENT(INOUT) :: dgu
61 TYPE(surf_atm_t), INTENT(INOUT) :: u
62 !
63  CHARACTER(LEN=6), INTENT(IN) :: hprogram ! calling program
64 INTEGER, INTENT(IN) :: klu ! number of points
65 INTEGER, INTENT(IN) :: kgrid_par ! size of PGRID_PAR
66 REAL, DIMENSION(KGRID_PAR), INTENT(IN) :: pgrid_par ! parameters defining this grid
67 INTEGER, INTENT(OUT) :: kresp ! error return code
68  CHARACTER(LEN=1), OPTIONAL, INTENT(IN) :: hdir ! type of field :
69  ! 'H' : field with
70  ! horizontal spatial dim.
71  ! 'A' : (complete) field with
72  ! horizontal spatial dim.
73  ! '-' : no horizontal dim.
74 !
75 !* 0.2 Declarations of local variables
76 ! -------------------------------
77 !
78 REAL :: zlat0 ! reference latitude
79 REAL :: zlon0 ! reference longitude
80 REAL :: zrpk ! projection parameter
81 ! ! K=1 : stereographic north pole
82 ! ! 0<K<1 : Lambert, north hemisphere
83 ! ! K=0 : Mercator
84 ! !-1<K<0 : Lambert, south hemisphere
85 ! ! K=-1: stereographic south pole
86 REAL :: zbeta ! angle between grid and reference longitude
87 REAL :: zlatori ! latitude of point of coordinates X=0, Y=0
88 REAL :: zlonori ! longitude of point of coordinates X=0, Y=0
89 INTEGER :: iimax ! number of points in I direction
90 INTEGER :: ijmax ! number of points in J direction
91 REAL, DIMENSION(:), ALLOCATABLE :: zx ! X conformal coordinate of grid mesh (dim IIMAX)
92 REAL, DIMENSION(:), ALLOCATABLE :: zy ! Y conformal coordinate of grid mesh (dim IJMAX)
93 REAL, DIMENSION(:), ALLOCATABLE :: zdx ! X grid mesh size (dim IIMAX)
94 REAL, DIMENSION(:), ALLOCATABLE :: zdy ! Y grid mesh size (dim IJMAX)
95 !
96  CHARACTER(LEN=100) :: ycomment ! comment written in the file
97 REAL(KIND=JPRB) :: zhook_handle
98 !---------------------------------------------------------------------------
99 !
100 !* 1. Projection and 2D grid parameters
101 ! ---------------------------------
102 !
103 IF (lhook) CALL dr_hook('WRITE_GRIDTYPE_CONF_PROJ',0,zhook_handle)
104 ALLOCATE(zx(klu))
105 ALLOCATE(zy(klu))
106 ALLOCATE(zdx(klu))
107 ALLOCATE(zdy(klu))
108 !
109  CALL get_gridtype_conf_proj(pgrid_par,zlat0,zlon0,zrpk,zbeta,&
110  zlatori,zlonori,iimax,ijmax, &
111  zx,zy,zdx,zdy )
112 !
113 !---------------------------------------------------------------------------
114 !
115 !* 2. Writing of the grid definition parameters
116 ! -----------------------------------------
117 !
118 ycomment=' '
119  CALL write_surf(dgu, u, &
120  hprogram,'LAT0',zlat0,kresp,ycomment)
121  CALL write_surf(dgu, u, &
122  hprogram,'LON0',zlon0,kresp,ycomment)
123  CALL write_surf(dgu, u, &
124  hprogram,'RPK ',zrpk, kresp,ycomment)
125  CALL write_surf(dgu, u, &
126  hprogram,'BETA',zbeta,kresp,ycomment)
127  CALL write_surf(dgu, u, &
128  hprogram,'LATORI',zlatori,kresp,ycomment)
129  CALL write_surf(dgu, u, &
130  hprogram,'LONORI',zlonori,kresp,ycomment)
131  CALL write_surf(dgu, u, &
132  hprogram,'IMAX ',iimax, kresp,ycomment)
133  CALL write_surf(dgu, u, &
134  hprogram,'JMAX ',ijmax, kresp,ycomment)
135 IF (present(hdir)) THEN
136  CALL write_surf(dgu, u, &
137  hprogram,'XX',zx,kresp,ycomment,hdir)
138  CALL write_surf(dgu, u, &
139  hprogram,'YY',zy,kresp,ycomment,hdir)
140  CALL write_surf(dgu, u, &
141  hprogram,'DX',zdx,kresp,ycomment,hdir)
142  CALL write_surf(dgu, u, &
143  hprogram,'DY',zdy,kresp,ycomment,hdir)
144 ELSE
145  CALL write_surf(dgu, u, &
146  hprogram,'XX',zx,kresp,ycomment)
147  CALL write_surf(dgu, u, &
148  hprogram,'YY',zy,kresp,ycomment)
149  CALL write_surf(dgu, u, &
150  hprogram,'DX',zdx,kresp,ycomment)
151  CALL write_surf(dgu, u, &
152  hprogram,'DY',zdy,kresp,ycomment)
153 END IF
154 !
155 !---------------------------------------------------------------------------
156 DEALLOCATE(zx)
157 DEALLOCATE(zy)
158 DEALLOCATE(zdx)
159 DEALLOCATE(zdy)
160 IF (lhook) CALL dr_hook('WRITE_GRIDTYPE_CONF_PROJ',1,zhook_handle)
161 !---------------------------------------------------------------------------
162 !
163 END SUBROUTINE write_gridtype_conf_proj
subroutine write_gridtype_conf_proj(DGU, U, HPROGRAM, KLU, KGRID_PAR, PGRID_PAR, KRESP, HDIR)
subroutine get_gridtype_conf_proj(PGRID_PAR, PLAT0, PLON0, PRPK, PBETA, PLATOR, PLONOR, KIMAX, KJMAX, PX, PY, PDX, PDY, KL)