SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
write_gridtype_cartesian.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_cartesian (DGU, U, &
7  hprogram,klu,kgrid_par,pgrid_par,kresp,hdir)
8 ! #################################################################
9 !
10 !!**** *WRITE_GRIDTYPE_CARTESIAN* - 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 INTEGER :: iimax ! number of points in I direction
81 INTEGER :: ijmax ! number of points in J direction
82 REAL, DIMENSION(:), ALLOCATABLE :: zx ! X conformal coordinate of grid mesh (dim IIMAX)
83 REAL, DIMENSION(:), ALLOCATABLE :: zy ! Y conformal coordinate of grid mesh (dim IJMAX)
84 REAL, DIMENSION(:), ALLOCATABLE :: zdx ! X grid mesh size (dim IIMAX)
85 REAL, DIMENSION(:), ALLOCATABLE :: zdy ! Y grid mesh size (dim IJMAX)
86 !
87  CHARACTER(LEN=100) :: ycomment ! comment written in the file
88 REAL(KIND=JPRB) :: zhook_handle
89 !---------------------------------------------------------------------------
90 !
91 !* 1. Projection and 2D grid parameters
92 ! ---------------------------------
93 !
94 IF (lhook) CALL dr_hook('WRITE_GRIDTYPE_CARTESIAN',0,zhook_handle)
95 ALLOCATE(zx(klu))
96 ALLOCATE(zy(klu))
97 ALLOCATE(zdx(klu))
98 ALLOCATE(zdy(klu))
99 !
100  CALL get_gridtype_cartesian(pgrid_par,zlat0,zlon0, &
101  iimax,ijmax,zx,zy,zdx,zdy )
102 !
103 !---------------------------------------------------------------------------
104 !
105 !* 2. Writing of the grid definition parameters
106 ! -----------------------------------------
107 !
108 ycomment=' '
109  CALL write_surf(dgu, u, &
110  hprogram,'LAT0',zlat0,kresp,ycomment)
111  CALL write_surf(dgu, u, &
112  hprogram,'LON0',zlon0,kresp,ycomment)
113  CALL write_surf(dgu, u, &
114  hprogram,'IMAX ',iimax, kresp,ycomment)
115  CALL write_surf(dgu, u, &
116  hprogram,'JMAX ',ijmax, kresp,ycomment)
117 IF (present(hdir)) THEN
118  CALL write_surf(dgu, u, &
119  hprogram,'XX',zx,kresp,ycomment,hdir)
120  CALL write_surf(dgu, u, &
121  hprogram,'YY',zy,kresp,ycomment,hdir)
122  CALL write_surf(dgu, u, &
123  hprogram,'DX',zdx,kresp,ycomment,hdir)
124  CALL write_surf(dgu, u, &
125  hprogram,'DY',zdy,kresp,ycomment,hdir)
126 ELSE
127  CALL write_surf(dgu, u, &
128  hprogram,'XX',zx,kresp,ycomment)
129  CALL write_surf(dgu, u, &
130  hprogram,'YY',zy,kresp,ycomment)
131  CALL write_surf(dgu, u, &
132  hprogram,'DX',zdx,kresp,ycomment)
133  CALL write_surf(dgu, u, &
134  hprogram,'DY',zdy,kresp,ycomment)
135 END IF
136 !
137 !---------------------------------------------------------------------------
138 DEALLOCATE(zx)
139 DEALLOCATE(zy)
140 DEALLOCATE(zdx)
141 DEALLOCATE(zdy)
142 IF (lhook) CALL dr_hook('WRITE_GRIDTYPE_CARTESIAN',1,zhook_handle)
143 !---------------------------------------------------------------------------
144 !
145 END SUBROUTINE write_gridtype_cartesian
subroutine write_gridtype_cartesian(DGU, U, HPROGRAM, KLU, KGRID_PAR, PGRID_PAR, KRESP, HDIR)
subroutine get_gridtype_cartesian(PGRID_PAR, PLAT0, PLON0, KIMAX, KJMAX, PX, PY, PDX, PDY, KL)