SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
ch_open_inputb.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 ch_open_inputb(HKEYWORD,KCHANNEL,KLUOUT)
7 !! #########################################################################
8 !!
9 !!*** *CH_OPEN_INPUTB*
10 !!
11 !! PURPOSE
12 !! -------
13 ! Open the general purpose chemical input file and position the
14 ! file pointer after the indicated keyword.
15 !!
16 !!** METHOD
17 !! ------
18 !! An unused input channel is selected using OPEN_ll.
19 !! The file will be rewinded
20 !! at each call and data will be read in using (A8)-format until the
21 !! given keyword is found. The following comment line will then
22 !! be read and printed and the input channel number will be returned.
23 !! After reading the needed data, the user must assure that the file
24 !! will be closed and that the unit will be freed using CLOSE_ll.
25 !!
26 !! REFERENCE
27 !! ---------
28 !! MesoNH book 2
29 !!
30 !! AUTHOR
31 !! ------
32 !! K. Suhre *Laboratoire d'Aerologie*
33 !!
34 !! MODIFICATIONS
35 !! -------------
36 !! Original 03/11/95
37 !! 05/08/96 (K. Suhre) restructured
38 !! 11/08/98 (N. Asencio) add parallel code
39 !!
40 !! EXTERNAL
41 !! --------
42 !!
43 !!
44 !! IMPLICIT ARGUMENTS
45 !! ------------------
46 !! none
47 !!
48 !
49 !-------------------------------------------------------------------------------
50 !
51 !* 0. DECLARATIONS
52 ! ------------
53 !
54 USE yomhook ,ONLY : lhook, dr_hook
55 USE parkind1 ,ONLY : jprb
56 !
57 USE modi_abor1_sfx
58 !
59 IMPLICIT NONE
60 !
61 !* 0.1 declarations of arguments
62 !
63  CHARACTER(LEN=*), INTENT(IN) :: hkeyword ! keyword for positioning
64 INTEGER , INTENT(IN) :: kchannel ! I/O channel to choose
65 INTEGER, INTENT(IN) :: kluout ! output listing logical unit
66 !
67 !* 0.2 declarations of local variables
68 !
69  CHARACTER(LEN=79) :: yin ! character string for line-by-line read
70 REAL(KIND=JPRB) :: zhook_handle
71 !
72 !-------------------------------------------------------------------------------
73 !
74 !* 1. READ INPUT DATA UNTIL KEYWORD IS FOUND
75 ! --------------------------------------
76 !
77 IF (lhook) CALL dr_hook('CH_OPEN_INPUTB',0,zhook_handle)
78 rewind(kchannel)
79 !
80 ! open the input file
81 !
82 ! read general comment line and print it
83 READ(kchannel,"(A)") yin
84 WRITE(kluout, *) yin
85 !
86 search_key : DO
87  READ(kchannel,"(A8)", end=100) yin
88  IF (hkeyword(1:8) .EQ. yin(1:8)) EXIT search_key
89 ENDDO search_key
90 !
91 ! read specific comment line and print it
92 WRITE(kluout,*) &
93  "keyword ", HKEYWORD(1:8), " has been found in chemistry data file, the specific comment is:"
94 READ(KCHANNEL,"(a)") YIN
95 WRITE(KLUOUT, *) YIN
96 !
97 IF (LHOOK) CALL DR_HOOK('CH_OPEN_INPUTB',1,ZHOOK_HANDLE)
98 RETURN
99 !
100 !-------------------------------------------------------------------------------
101 !
102 !* 2. IF THE KEYWORD HAS NOT BEEN FOUND, ABORT
103 ! ---------------------------------------
104 !
105 100 CONTINUE
106 WRITE(KLUOUT,*) "ch_open_inputb-error: keyword ", HKEYWORD(1:8), " not found."
107  CALL ABOR1_SFX('CH_OPEN_INPUTB: KEYWORD '//HKEYWORD(1:8)//' NOT FOUND')
108 IF (LHOOK) CALL DR_HOOK('CH_OPEN_INPUTB',1,ZHOOK_HANDLE)
109 !
110 END SUBROUTINE CH_OPEN_INPUTB