SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
read_assim_conf.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_assim_conf(HPROGRAM)
7 ! #######################################################
8 !
9 !!**** *READ_ASSIM_CONF* - routine to read the configuration for assimilation
10 !!
11 !! PURPOSE
12 !! -------
13 !!
14 !!** METHOD
15 !! ------
16 !!
17 !! EXTERNAL
18 !! --------
19 !!
20 !!
21 !! IMPLICIT ARGUMENTS
22 !! ------------------
23 !!
24 !! REFERENCE
25 !! ---------
26 !!
27 !!
28 !! AUTHOR
29 !! ------
30 !! T. Aspelien met.no
31 !!
32 !! MODIFICATIONS
33 !! -------------
34 !! Original 04/2012
35 !-------------------------------------------------------------------------------
36 !
37 !* 0. DECLARATIONS
38 ! ------------
39 !
40 USE mode_pos_surf, ONLY : posnam
41 USE modn_assim, ONLY : nam_nacveg,nam_assim,lassim,cassim,&
42  nam_io_varassim,nam_obs,nam_var,nam_ens
43 USE modd_assim, ONLY : nvar,nobstype,xtprt,xtprt_m,xsigma,&
44  xsigma_m,cvar,cvar_m,cobs,nnco,&
45  nvarmax,nncv,lassim,cassim_isba,lprt,&
46  nobsmax,xerrobs_m,xerrobs, &
47  xqcobs_m,xqcobs,&
48  xinfl_m,xinfl,xaddinfl_m,xaddinfl, &
49  xaddtimecorr_m, xaddtimecorr, nie, &
50  cfile_format_obs
51 USE yomhook, ONLY : lhook,dr_hook
52 USE parkind1, ONLY : jprb
53 
54 USE modi_get_luout
55 USE modi_open_namelist
57 USE modi_close_namelist
58 USE modi_abor1_sfx
59 !
60 IMPLICIT NONE
61 !
62 !* 0.1 Declarations of arguments
63 ! -------------------------
64 !
65  CHARACTER(LEN=6), INTENT(IN) :: hprogram ! program calling
66 
67 !
68 !* 0.2 Declarations of local variables
69 ! -------------------------------
70 !
71 !
72 LOGICAL :: gfound ! Return code when searching namelist
73 INTEGER :: iluout ! logical unit of output file
74 INTEGER :: inam ! logical unit of namelist file
75 INTEGER :: i,j
76 REAL(KIND=JPRB) :: zhook_handle
77 !-------------------------------------------------------------------------------
78 !
79 !* get output listing file logical unit
80 !
81 IF (lhook) CALL dr_hook('READ_ASSIM_CONF',0,zhook_handle)
82  CALL get_luout(hprogram,iluout)
83 
84 !* open namelist file
85  CALL open_namelist(hprogram,inam)
86 
87 !* reading of namelist
88  CALL posnam(inam,'NAM_ASSIM', gfound,iluout)
89 IF (gfound) READ(unit=inam,nml=nam_assim)
90  CALL posnam(inam,'NAM_NACVEG', gfound,iluout)
91 IF (gfound) READ(unit=inam,nml=nam_nacveg)
92  CALL posnam(inam,'NAM_IO_VARASSIM',gfound,iluout)
93 IF (gfound) READ(unit=inam,nml=nam_io_varassim)
94  CALL posnam(inam,'NAM_OBS', gfound,iluout)
95 IF (gfound) READ(unit=inam,nml=nam_obs)
96  CALL posnam(inam,'NAM_VAR', gfound,iluout)
97 IF (gfound) READ(unit=inam,nml=nam_var)
98  CALL posnam(inam,'NAM_ENS', gfound,iluout)
99 IF (gfound) READ(unit=inam,nml=nam_ens)
100 !
101  CALL test_nam_var_surf(iluout,'CASSIM',cassim,'PLUS ','2DVAR','AVERA')
102  CALL test_nam_var_surf(iluout,'CASSIM_ISBA',cassim_isba,'OI ','EKF ','ENKF ')
103 !
104 !* close namelist file
105  CALL close_namelist(hprogram,inam)
106 
107 ! Set EKF setup based on namelist input
108 IF ( ( cassim_isba == "EKF" .AND. ( lassim.OR.lprt ) ) .OR. &
109  ( cassim_isba == "ENKF" .AND. ( lassim.OR.nie/=0 ) ) ) THEN
110  !
111  IF (.NOT.ALLOCATED(xtprt)) ALLOCATE (xtprt(nvar))
112  IF (.NOT.ALLOCATED(xsigma)) ALLOCATE (xsigma(nvar))
113  IF (.NOT.ALLOCATED(cvar)) ALLOCATE (cvar(nvar))
114  !
115  IF (sum(nncv) /= nvar) THEN
116  WRITE(*,*) 'INCONSISTENCY in set-up of CONTROL VARIABLES',sum(nncv),nvar
117  CALL abor1_sfx('INCONSISTENCY in set-up of CONTROL VARIABLES')
118  ENDIF
119  !
120  j = 1
121  DO i = 1,nvarmax
122  IF (nncv(i) == 1 .AND. j <= nvar ) THEN
123  xtprt(j) = xtprt_m(i)
124  xsigma(j) = xsigma_m(i)
125  cvar(j) = cvar_m(i)
126  j = j + 1
127  ENDIF
128  ENDDO
129 ENDIF
130 
131 IF ( ( cassim_isba == "EKF" .AND. ( lassim.OR.lprt ) ) .OR. &
132  ( cassim_isba == "ENKF" .AND. ( lassim.OR.nie/=0 ) ) .OR. (trim(cfile_format_obs) == "ASCII") ) THEN
133 
134  IF (sum(nnco) /= nobstype) THEN
135  WRITE(*,*) 'INCONSISTENCY in set-up of OBSERVATIONS',sum(nnco),nobstype
136  CALL abor1_sfx('INCONSISTENCY in set-up ofOBSERVATIONS')
137  ENDIF
138  !
139  IF (.NOT.ALLOCATED(cobs)) ALLOCATE (cobs(nobstype))
140  cobs(:) = ''
141  IF (.NOT.ALLOCATED(xerrobs)) ALLOCATE (xerrobs(nobstype))
142  IF (.NOT.ALLOCATED(xqcobs)) ALLOCATE (xqcobs(nobstype))
143  j = 1
144  DO i = 1,nobsmax
145  IF (nnco(i) == 1 .AND. j <= nobstype ) THEN
146  SELECT CASE (i)
147  CASE (1)
148  cobs(j) = 'T2M'
149  CASE (2)
150  cobs(j) = 'HU2M'
151  CASE (3)
152  cobs(j) = 'WG1'
153  CASE (4)
154  cobs(j) = 'LAI'
155  CASE (5)
156  cobs(j) = 'SWE'
157  END SELECT
158  xerrobs(j) = xerrobs_m(i)
159  xqcobs(j) = xqcobs_m(i)
160  j = j + 1
161  ENDIF
162  ENDDO
163 ENDIF
164 
165 IF ( cassim_isba == "ENKF" .AND. ( lassim.OR.nie/=0 ) ) THEN
166  !
167  IF (.NOT.ALLOCATED(xinfl)) ALLOCATE (xinfl(nvar))
168  IF (.NOT.ALLOCATED(xaddinfl)) ALLOCATE (xaddinfl(nvar))
169  IF (.NOT.ALLOCATED(xaddtimecorr)) ALLOCATE (xaddtimecorr(nvar))
170  !
171  j = 1
172  DO i = 1,nvarmax
173  IF (nncv(i) == 1 .AND. j <= nvar ) THEN
174  xinfl(j) = xinfl_m(i)
175  xaddinfl(j) = xaddinfl_m(i)
176  xaddtimecorr(j) = xaddtimecorr_m(i)
177  j = j + 1
178  ENDIF
179  ENDDO
180  !
181 ENDIF
182 
183 IF (lhook) CALL dr_hook('READ_ASSIM_CONF',1,zhook_handle)
184 END SUBROUTINE read_assim_conf
subroutine abor1_sfx(YTEXT)
Definition: abor1_sfx.F90:6
subroutine close_namelist(HPROGRAM, KLUNAM)
subroutine posnam(KULNAM, HDNAML, OFOUND, KLUOUT)
subroutine get_luout(HPROGRAM, KLUOUT)
Definition: get_luout.F90:6
subroutine read_assim_conf(HPROGRAM)
subroutine open_namelist(HPROGRAM, KLUNAM, HFILE)