SURFEX v8.1
General documentation of Surfex
read_binllvfast.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_binllvfast (UG, U, USS, &
7  HPROGRAM,HSUBROUTINE,HFILENAME)
8 ! ##############################################################
9 !
10 !!**** *READ_BINLLVFAST* reads a binary latlonvalue file and call treatment
11 !! subroutine : optimized version of READ_BINLLV routine.
12 !!
13 !! PURPOSE
14 !! -------
15 !!
16 !!
17 !! REFERENCE
18 !! ---------
19 !!
20 !! AUTHOR
21 !! ------
22 !!
23 !! D. Gazen L.A.
24 !!
25 !! MODIFICATION
26 !! ------------
27 !!
28 !! Original 29/11/2002
29 !! 03/2004 externalization (V. Masson)
30 !!
31 !----------------------------------------------------------------------------
32 !
33 !* 0. DECLARATION
34 ! -----------
35 !
36 !
38 USE modd_surf_atm_n, ONLY : surf_atm_t
39 USE modd_sso_n, ONLY : sso_t
40 !
41 USE modd_surf_par, ONLY : xundef
42 USE modd_pgd_grid, ONLY : llatlonmask
43 !
44 USE modi_open_file
45 USE modi_close_file
46 USE modi_pt_by_pt_treatment
47 USE modi_get_luout
48 !
49 !
50 USE yomhook ,ONLY : lhook, dr_hook
51 USE parkind1 ,ONLY : jprb
52 !
53 IMPLICIT NONE
54 !
55 !* 0.1 Declaration of arguments
56 ! ------------------------
57 !
58 !
59 TYPE(surf_atm_grid_t), INTENT(INOUT) :: UG
60 TYPE(surf_atm_t), INTENT(INOUT) :: U
61 TYPE(sso_t), INTENT(INOUT) :: USS
62 !
63  CHARACTER(LEN=6), INTENT(IN) :: HPROGRAM ! Type of program
64  CHARACTER(LEN=6), INTENT(IN) :: HSUBROUTINE ! Name of the subroutine to call
65  CHARACTER(LEN=28), INTENT(IN) :: HFILENAME ! Name of the field file.
66 !
67 !
68 !* 0.2 Declaration of local variables
69 ! ------------------------------
70 !
71 INTEGER :: IGLB ! logical units
72 INTEGER :: JLAT, JLON ! indexes of LLATLONMASK array
73 INTEGER :: INELT ! number of data points in file
74 INTEGER :: ICPT ! number of data points to be computed
75 REAL,DIMENSION(:,:),ALLOCATABLE,TARGET :: ZLLV ! ZLLV(1,:) :: latitude of data points
76  ! ZLLV(2,:) :: longitude of data points
77  ! ZLLV(3,:) :: value of data points
78 REAL, DIMENSION(:), ALLOCATABLE :: ZLLV2
79 REAL,DIMENSION(:,:),POINTER :: ZLLVWORK ! point on ZLLV array
80 INTEGER :: JI ! loop counter
81 !
82 INTEGER :: ILUOUT ! output listing
83 REAL(KIND=JPRB) :: ZHOOK_HANDLE
84 !----------------------------------------------------------------------------
85 !
86 !
87 !* 1. Open the global file
88 ! --------------------
89 !
90 IF (lhook) CALL dr_hook('READ_BINLLVFAST',0,zhook_handle)
91  CALL open_file(hprogram,iglb,hfilename,'UNFORMATTED',haction='READ')
92 !
93  CALL get_luout(hprogram,iluout)
94 !
95 !----------------------------------------------------------------------------
96 !
97 !* 3. Reading of a data point
98 ! -----------------------
99 !
100 READ(iglb) inelt ! number of data points
101 ALLOCATE(zllv(3,inelt))
102 ALLOCATE(zllv2(inelt))
103 READ(iglb) zllv
104 !
105 !----------------------------------------------------------------------------
106 !
107 !* 4. Test if point is in the domain
108 ! ------------------------------
109 !
110 zllv2(:) = zllv(2,:)+nint((180.-zllv(2,:))/360.)*360.
111 !
112 icpt = 0
113 DO ji=1,inelt
114  jlat = 1 + int( ( zllv(1,ji)+ 90. ) * 2. )
115  jlat = min(jlat,360)
116  jlon = 1 + int( ( zllv2(ji) ) * 2. )
117  jlon = min(jlon,720)
118  IF (llatlonmask(jlon,jlat)) THEN
119  icpt = icpt+1
120  zllv(:,icpt) = zllv(:,ji)
121  END IF
122 END DO
123 !
124 !-------------------------------------------------------------------------------
125 !
126 !* 5. Call to the adequate subroutine (point by point treatment)
127 ! ----------------------------------------------------------
128 !
129 IF (icpt > 0) THEN
130  zllvwork=>zllv(:,1:icpt)
131  CALL pt_by_pt_treatment(ug, u, uss, &
132  iluout,zllvwork(1,:),zllvwork(2,:),zllvwork(3,:),hsubroutine)
133 END IF
134 !
135 !----------------------------------------------------------------------------
136 !
137 !* 6. Closing of the data file
138 ! ------------------------
139 !
140  CALL close_file (hprogram,iglb)
141 !
142 !-------------------------------------------------------------------------------
143 !
144 DEALLOCATE(zllv)
145 IF (lhook) CALL dr_hook('READ_BINLLVFAST',1,zhook_handle)
146 !
147 !-------------------------------------------------------------------------------
148 !
149 END SUBROUTINE read_binllvfast
subroutine open_file(HPROGRAM, KUNIT, HFILE, HFORM, HACTION, HACCESS, KR
Definition: open_file.F90:7
logical, dimension(720, 360) llatlonmask
real, parameter xundef
integer, parameter jprb
Definition: parkind1.F90:32
subroutine close_file(HPROGRAM, KUNIT)
Definition: close_file.F90:7
subroutine read_binllvfast(UG, U, USS, HPROGRAM, HSUBROUTINE, HFILENAME)
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