SURFEX v8.1
General documentation of Surfex
read_binllv.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 read_binllv (UG, U, USS, &
7  HPROGRAM,HSUBROUTINE,HFILENAME)
8 ! ##############################################################
9 !
10 !!**** *READ_BINLLV* reads a binary latlonvalue file and call treatment
11 !! subroutine
12 !!
13 !! PURPOSE
14 !! -------
15 !!
16 !! AUTHOR
17 !! ------
18 !!
19 !! V. Masson Meteo-France
20 !!
21 !! MODIFICATION
22 !! ------------
23 !!
24 !! Original 12/09/95
25 !! 03/2004 externalization (V. Masson)
26 !!
27 !----------------------------------------------------------------------------
28 !
29 !* 0. DECLARATION
30 ! -----------
31 !
32 !
34 USE modd_surf_atm_n, ONLY : surf_atm_t
35 USE modd_sso_n, ONLY : sso_t
36 !
37 USE modd_pgd_grid, ONLY : llatlonmask
38 !
39 USE modi_open_file
40 USE modi_close_file
41 USE modi_pt_by_pt_treatment
42 USE modi_get_luout
43 !
44 !
45 USE yomhook ,ONLY : lhook, dr_hook
46 USE parkind1 ,ONLY : jprb
47 !
48 IMPLICIT NONE
49 !
50 !* 0.1 Declaration of arguments
51 ! ------------------------
52 !
53 TYPE(surf_atm_grid_t), INTENT(INOUT) :: UG
54 TYPE(surf_atm_t), INTENT(INOUT) :: U
55 TYPE(sso_t), INTENT(INOUT) :: USS
56 !
57  CHARACTER(LEN=6), INTENT(IN) :: HPROGRAM ! Type of program
58  CHARACTER(LEN=6), INTENT(IN) :: HSUBROUTINE ! Name of the subroutine to call
59  CHARACTER(LEN=28), INTENT(IN) :: HFILENAME ! Name of the field file.
60 !
61 !
62 !* 0.2 Declaration of local variables
63 ! ------------------------------
64 !
65 INTEGER :: IGLB ! logical unit
66 !
67 INTEGER :: JLAT, JLON ! indexes of OLATLONMASK array
68 !
69 INTEGER, PARAMETER :: ILONG=1000
70 !
71 REAL*4 :: ZVALUER
72 REAL, DIMENSION(ILONG) :: ZVALUE ! values of a data point
73 REAL*4 :: ZLATR
74 REAL, DIMENSION(ILONG) :: ZLAT ! latitude of data point
75 REAL*4 :: ZLONR, ZLONR2
76 REAL, DIMENSION(ILONG) :: ZLON ! longitude of data point
77 !
78 INTEGER :: ICPT, ISTAT
79 INTEGER :: ILUOUT ! output listing
80 REAL(KIND=JPRB) :: ZHOOK_HANDLE
81 !----------------------------------------------------------------------------
82 !
83 !* 1. Open the file
84 ! -------------
85 !
86 IF (lhook) CALL dr_hook('READ_BINLLV',0,zhook_handle)
87  CALL open_file(hprogram,iglb,hfilename,'UNFORMATTED',haction='READ')
88 !
89  CALL get_luout(hprogram,iluout)
90 !
91 icpt = 0
92 !
93 zlat(:) = 0
94 zlon(:) = 0
95 zvalue(:) = 0
96 !
97 !----------------------------------------------------------------------------
98 DO
99 !----------------------------------------------------------------------------
100 !
101 !* 3. Reading of a data point
102 ! -----------------------
103 !
104  READ(iglb,iostat=istat) zlatr,zlonr,zvaluer
105 !
106 !----------------------------------------------------------------------------
107 !
108 !* 4. Test if point is in the domain
109 ! ------------------------------
110 !
111  IF (istat==0) THEN
112  !
113  zlonr2=zlonr+nint((180.-zlonr)/360.)*360.
114  !
115  jlat = 1 + int( ( zlatr + 90. ) * 2. )
116  jlat = min(jlat,360)
117  jlon = 1 + int( ( zlonr2 ) * 2. )
118  jlon = min(jlon,720)
119  !
120  IF (.NOT. llatlonmask(jlon,jlat)) cycle
121  !
122  icpt = icpt + 1
123  !
124  IF (icpt<=ilong) THEN
125  !
126  zlat(icpt) = zlatr
127  zlon(icpt) = zlonr
128  zvalue(icpt) = zvaluer
129  !
130  ENDIF
131  !
132  ENDIF
133  !
134  IF (istat==-1 .OR. icpt==ilong) THEN
135  !
136  !-------------------------------------------------------------------------------
137  !
138  !* 5. Call to the adequate subroutine (point by point treatment)
139  ! ----------------------------------------------------------
140  !
141  CALL pt_by_pt_treatment(ug, u, uss, iluout, &
142  zlat(1:icpt), zlon(1:icpt), zvalue(1:icpt), hsubroutine )
143  !
144  icpt = 0
145  zlat(:) = 0.
146  zlon(:) = 0.
147  zvalue(:) = 0.
148  !
149  ENDIF
150  !
151  IF (istat==-1) EXIT
152  !
153  !-------------------------------------------------------------------------------
154 ENDDO
155 !
156 !----------------------------------------------------------------------------
157 !
158 !* 8. Closing of the data file
159 ! ------------------------
160 !
161  CALL close_file (hprogram,iglb)
162 IF (lhook) CALL dr_hook('READ_BINLLV',1,zhook_handle)
163 !
164 !-------------------------------------------------------------------------------
165 !
166 END SUBROUTINE read_binllv
subroutine open_file(HPROGRAM, KUNIT, HFILE, HFORM, HACTION, HACCESS, KR
Definition: open_file.F90:7
logical, dimension(720, 360) llatlonmask
subroutine read_binllv(UG, U, USS, HPROGRAM, HSUBROUTINE, HFILENAME)
Definition: read_binllv.F90:8
integer, parameter jprb
Definition: parkind1.F90:32
subroutine close_file(HPROGRAM, KUNIT)
Definition: close_file.F90:7
subroutine pt_by_pt_treatment(UG, U, USS, KLUOUT, PLAT, PLON, PVALUE, HSUBROUTINE
subroutine get_luout(HPROGRAM, KLUOUT)
Definition: get_luout.F90:7
logical lhook
Definition: yomhook.F90:15