SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
write_grid.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_grid (DGU, U, &
7  hprogram,hgrid,pgrid_par,plat,plon,pmesh_size,kresp,pdir,hdir)
8 ! #########################################
9 !
10 !!**** *WRITE_GRID* - routine to write the horizontal grid of a scheme
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 !! P. Samuelsson SMHI 12/2012 Rotated lonlat
37 !-------------------------------------------------------------------------------
38 !
39 !* 0. DECLARATIONS
40 ! ------------
41 !
42 !
43 !
45 USE modd_surf_atm_n, ONLY : surf_atm_t
46 !
48 !
49 !
50 !
51 USE yomhook ,ONLY : lhook, dr_hook
52 USE parkind1 ,ONLY : jprb
53 !
54 USE modi_write_gridtype_cartesian
55 !
56 USE modi_write_gridtype_conf_proj
57 !
58 USE modi_write_gridtype_gauss
59 !
60 USE modi_write_gridtype_ign
61 !
62 USE modi_write_gridtype_lonlat_reg
63 !
64 USE modi_write_gridtype_lonlatval
65 !
66 USE modi_write_gridtype_lonlat_rot
67 IMPLICIT NONE
68 !
69 !* 0.1 Declarations of arguments
70 ! -------------------------
71 !
72 !
73 TYPE(diag_surf_atm_t), INTENT(INOUT) :: dgu
74 TYPE(surf_atm_t), INTENT(INOUT) :: u
75 !
76  CHARACTER(LEN=6), INTENT(IN) :: hprogram ! calling program
77  CHARACTER(LEN=10), INTENT(IN) :: hgrid ! type of horizontal grid
78 REAL, DIMENSION(:), POINTER :: pgrid_par ! parameters defining this grid
79 REAL, DIMENSION(:), INTENT(IN) :: plat ! latitude (degrees)
80 REAL, DIMENSION(:), INTENT(IN) :: plon ! longitude (degrees)
81 REAL, DIMENSION(:), INTENT(IN) :: pmesh_size ! horizontal mesh size (m2)
82 INTEGER, INTENT(OUT) :: kresp ! error return code
83 REAL, DIMENSION(:), INTENT(IN) , OPTIONAL :: pdir ! heading of main axis of grid compared to North (degrees)
84  CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: hdir ! type of field :
85  ! 'H' : field with
86  ! horizontal spatial dim.
87  ! 'A' : (complete) field with
88  ! horizontal spatial dim.
89  ! '-' : no horizontal dim.
90 !
91 !* 0.2 Declarations of local variables
92 ! -------------------------------
93 !
94  CHARACTER(LEN=100) :: ycomment
95  CHARACTER(LEN=1) :: ydir
96 REAL(KIND=JPRB) :: zhook_handle
97 !---------------------------------------------------------------------------
98 !
99 !* 1. Write type of grid
100 ! ------------------
101 !
102 IF (lhook) CALL dr_hook('WRITE_GRID',0,zhook_handle)
103 ycomment='GRID TYPE'
104  CALL write_surf(dgu, u, &
105  hprogram,'GRID_TYPE',hgrid,kresp,ycomment)
106 !
107 !---------------------------------------------------------------------------
108 !
109 !* 2. Write parameters of the grid
110 ! ----------------------------
111 !
112 ydir='h'
113 IF (PRESENT(HDIR)) YDIR = HDIR
114 !
115 SELECT CASE (HGRID)
116  CASE("CONF PROJ ")
117  CALL WRITE_GRIDTYPE_CONF_PROJ(DGU, U, &
118  HPROGRAM,SIZE(PLAT),SIZE(PGRID_PAR),PGRID_PAR(:),KRESP,YDIR)
119  CASE("CARTESIAN ")
120  CALL WRITE_GRIDTYPE_CARTESIAN(DGU, U, &
121  HPROGRAM,SIZE(PLAT),SIZE(PGRID_PAR),PGRID_PAR(:),KRESP,YDIR)
122  CASE("LONLAT REG")
123  CALL WRITE_GRIDTYPE_LONLAT_REG(DGU, U, &
124  HPROGRAM,SIZE(PLAT),SIZE(PGRID_PAR),PGRID_PAR(:),KRESP)
125  CASE("GAUSS ")
126  CALL WRITE_GRIDTYPE_GAUSS(DGU, U, &
127  HPROGRAM,SIZE(PLAT),SIZE(PGRID_PAR),PGRID_PAR(:),KRESP)
128  CASE("IGN ")
129  CALL WRITE_GRIDTYPE_IGN(DGU, U, &
130  HPROGRAM,SIZE(PLAT),SIZE(PGRID_PAR),PGRID_PAR(:),KRESP)
131  CASE("LONLATVAL ")
132  CALL WRITE_GRIDTYPE_LONLATVAL(DGU, U, &
133  HPROGRAM,SIZE(PLAT),SIZE(PGRID_PAR),PGRID_PAR(:),KRESP)
134  CASE("LONLAT ROT")
135  CALL WRITE_GRIDTYPE_LONLAT_ROT(DGU, U, &
136  HPROGRAM,SIZE(PLAT),SIZE(PGRID_PAR),PGRID_PAR(:),KRESP)
137  CASE("NONE ")
138  YCOMMENT='lon(degrees)'
139  CALL WRITE_SURF(DGU, U, &
140  HPROGRAM,'lon', PLON,KRESP,YCOMMENT)
141 .AND. IF (KRESP/=0 LHOOK) CALL DR_HOOK('write_grid',1,ZHOOK_HANDLE)
142  IF (KRESP/=0) RETURN
143  YCOMMENT='lat(degrees)'
144  CALL WRITE_SURF(DGU, U, &
145  HPROGRAM,'lat', PLAT,KRESP,YCOMMENT)
146 .AND. IF (KRESP/=0 LHOOK) CALL DR_HOOK('write_grid',1,ZHOOK_HANDLE)
147  IF (KRESP/=0) RETURN
148  YCOMMENT='mesh SIZE (m2)'
149  CALL WRITE_SURF(DGU, U, &
150  HPROGRAM,'mesh_size',PMESH_SIZE,KRESP,YCOMMENT)
151 .AND. IF (KRESP/=0 LHOOK) CALL DR_HOOK('write_grid',1,ZHOOK_HANDLE)
152  IF (KRESP/=0) RETURN
153 END SELECT
154 IF (LHOOK) CALL DR_HOOK('write_grid',1,ZHOOK_HANDLE)
155 !
156 !---------------------------------------------------------------------------
157 !
158 END SUBROUTINE WRITE_GRID
subroutine write_grid(DGU, U, HPROGRAM, HGRID, PGRID_PAR, PLAT, PLON, PMESH_SIZE, KRESP, PDIR, HDIR)
Definition: write_grid.F90:6