SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
readwrite_emis_fieldn.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 readwrite_emis_field_n ( DTCO, DGU, U, &
7  hprogram)
8 ! #######################################################################
9 !
10 !-----------------------------------------------------------------------------
11 !
12 !* 0. DECLARATIONS
13 !
14 !
15 !
18 USE modd_surf_atm_n, ONLY : surf_atm_t
19 !
20 !
21 USE modi_get_luout
22 USE modi_init_io_surf_n
23 USE modi_end_io_surf_n
26 !
27 !
28 !
29 USE yomhook ,ONLY : lhook, dr_hook
30 USE parkind1 ,ONLY : jprb
31 !
32 USE modi_abor1_sfx
33 !
34 IMPLICIT NONE
35 !
36 !
37 TYPE(data_cover_t), INTENT(INOUT) :: dtco
38 TYPE(diag_surf_atm_t), INTENT(INOUT) :: dgu
39 TYPE(surf_atm_t), INTENT(INOUT) :: u
40 !
41  CHARACTER(LEN=6) :: hprogram
42 !
43 !* 0.2 declarations of local variables
44 !
45 INTEGER :: iresp ! I/O error code
46  CHARACTER (LEN=16) :: yrecfm ! article name
47  CHARACTER (LEN=100) :: ycomment ! comment
48 INTEGER :: iluout ! Unit number for prints
49 INTEGER :: jspec ! Loop index for emission species
50 INTEGER :: iemispec_nbr ! number of emitted chemical species
51  CHARACTER(LEN=40) :: yemispec_name ! species name
52 INTEGER :: iemispec_ntimes ! number of emission times
53  CHARACTER(LEN=3) :: ysurf ! surface type
54 INTEGER,DIMENSION(:),ALLOCATABLE :: itimes ! emission times for a species
55 REAL, DIMENSION(:,:),ALLOCATABLE :: zwork ! work array read in the file
56 !
57 INTEGER :: iversion ! version of surfex file being read
58 REAL(KIND=JPRB) :: zhook_handle
59 !-------------------------------------------------------------------------------
60 !
61 IF (lhook) CALL dr_hook('READWRITE_EMIS_FIELD_N',0,zhook_handle)
62  CALL get_luout(hprogram,iluout)
63 !
64 !-------------------------------------------------------------------------------
65 !
66  CALL init_io_surf_n(dtco, dgu, u, &
67  hprogram,'FULL ','SURF ','READ ')
68 !* ascendant compatibility
69 yrecfm='VERSION'
70  CALL read_surf(&
71  hprogram,yrecfm,iversion,iresp)
72 !
73 yrecfm='EMISFILE_NBR'
74 IF (iversion<4) yrecfm='EMISFILE_GR_NBR'
75  CALL read_surf(&
76  hprogram,yrecfm,iemispec_nbr,iresp,ycomment)
77  CALL end_io_surf_n(hprogram)
78 !
79 IF (iresp/=0) THEN
80  CALL abor1_sfx('READWRITE_EMIS_FIELDN: PROBLEM READING NUMBER OF 2D CHEMICAL EMISSION FIELDS')
81 END IF
82 !
83  CALL init_io_surf_n(dtco, dgu, u, &
84  hprogram,'FULL ','SURF ','WRITE')
85  CALL write_surf(dgu, u, &
86  hprogram,yrecfm,iemispec_nbr,iresp,ycomment)
87  CALL end_io_surf_n(hprogram)
88 !
89 !-------------------------------------------------------------------------------
90 !
91  CALL init_io_surf_n(dtco, dgu, u, &
92  hprogram,'FULL ','SURF ','READ ')
93 yrecfm='EMISPEC_NBR'
94 IF (iversion<4) yrecfm='EMISPEC_GR_NBR'
95  CALL read_surf(&
96  hprogram,yrecfm,iemispec_nbr,iresp,ycomment)
97  CALL end_io_surf_n(hprogram)
98 !
99 IF (iresp/=0) THEN
100  CALL abor1_sfx('READWRITE_EMIS_FIELDN: PROBLEM READING NUMBER OF EMITTED CHEMICAL SPECIES')
101 END IF
102 !
103  CALL init_io_surf_n(dtco, dgu, u, &
104  hprogram,'FULL ','SURF ','WRITE')
105  CALL write_surf(dgu, u, &
106  hprogram,yrecfm,iemispec_nbr,iresp,ycomment)
107  CALL end_io_surf_n(hprogram)
108 !
109 !-------------------------------------------------------------------------------
110 !
111 DO jspec=1,iemispec_nbr
112  CALL init_io_surf_n(dtco, dgu, u, &
113  hprogram,'FULL ','SURF ','READ ')
114  WRITE(yrecfm,'("EMISNAME",I3.3)') jspec
115  CALL read_surf(&
116  hprogram,yrecfm,yemispec_name,iresp,ycomment)
117  CALL end_io_surf_n(hprogram)
118 !
119  IF (iresp/=0) THEN
120  CALL abor1_sfx('READWRITE_EMIS_FIELDN: PROBLEM WHEN READING THE NAME OF EMITTED CHEMICAL SPECIES '//yrecfm)
121  END IF
122  READ(ycomment,'(A3,24x,I5)') ysurf, iemispec_ntimes
123  !
124  CALL init_io_surf_n(dtco, dgu, u, &
125  hprogram,'FULL ','SURF ','WRITE')
126  CALL write_surf(dgu, u, &
127  hprogram,yrecfm,yemispec_name,iresp,ycomment)
128  CALL end_io_surf_n(hprogram)
129 !
130 !-------------------------------------------------------------------------------
131 !
132  ALLOCATE(itimes(iemispec_ntimes))
133  ALLOCATE(zwork(u%NSIZE_FULL,iemispec_ntimes))
134 !
135 !-------------------------------------------------------------------------------
136 !
137  CALL init_io_surf_n(dtco, dgu, u, &
138  hprogram,'FULL ','SURF ','READ ')
139  yrecfm='E_'//trim(yemispec_name)
140  CALL read_surf(&
141  hprogram,yrecfm,zwork,iresp,ycomment)
142  CALL end_io_surf_n(hprogram)
143  !
144  IF (iresp/=0) THEN
145  CALL abor1_sfx('READWRITE_EMIS_FIELDN: PROBLEM WHEN READING THE EMISSION DATA '//yrecfm)
146  END IF
147  !
148  CALL init_io_surf_n(dtco, dgu, u, &
149  hprogram,'FULL ','SURF ','WRITE')
150  CALL write_surf(dgu, u, &
151  hprogram,yrecfm,zwork,iresp,ycomment)
152  CALL end_io_surf_n(hprogram)
153 !
154 !-------------------------------------------------------------------------------
155 !
156  CALL init_io_surf_n(dtco, dgu, u, &
157  hprogram,'FULL ','SURF ','READ ')
158  WRITE(yrecfm,'("EMISTIMES",I3.3)') jspec
159  CALL read_surf(&
160  hprogram,yrecfm,itimes,iresp,ycomment,'-')
161  CALL end_io_surf_n(hprogram)
162 
163  IF (iresp/=0) THEN
164  CALL abor1_sfx('READWRITE_EMIS_FIELDN: PROBLEM WHEN READING THE EMISSION TIMES '//yrecfm)
165  END IF
166 
167  CALL init_io_surf_n(dtco, dgu, u, &
168  hprogram,'FULL ','SURF ','WRITE')
169  CALL write_surf(dgu, u, &
170  hprogram,yrecfm,itimes,iresp,ycomment,'-')
171  CALL end_io_surf_n(hprogram)
172 !
173 !-------------------------------------------------------------------------------
174 !
175  DEALLOCATE(itimes)
176  DEALLOCATE(zwork)
177 !
178 !-------------------------------------------------------------------------------
179 END DO
180 IF (lhook) CALL dr_hook('READWRITE_EMIS_FIELD_N',1,zhook_handle)
181 !-------------------------------------------------------------------------------
182 !
183 END SUBROUTINE readwrite_emis_field_n
subroutine init_io_surf_n(DTCO, DGU, U, HPROGRAM, HMASK, HSCHEME, HACTION)
subroutine readwrite_emis_field_n(DTCO, DGU, U, HPROGRAM)
subroutine abor1_sfx(YTEXT)
Definition: abor1_sfx.F90:6
subroutine end_io_surf_n(HPROGRAM)
Definition: end_io_surfn.F90:6
subroutine get_luout(HPROGRAM, KLUOUT)
Definition: get_luout.F90:6