SURFEX v8.1
General documentation of Surfex
test_record_len.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 test_record_len (HPROGRAM,HREC,HSELECT,ONOWRITE)
7 !#################################################
8 !
9 !!
10 !! MODIFICATIONS
11 !! -------------
12 !! B. Decharme 07/2013 write 'time' in netcdf output files
13 !-------------------------------------------------------------------------------
14 !
15 USE modi_get_luout
16 !
17 USE modd_surfex_mpi, ONLY : nrank,npio
18 USE modd_xios, ONLY : lxios, lxios_def_closed
19 #ifdef WXIOS
20 USE xios, ONLY : xios_is_valid_field, xios_field_is_active
21 #endif
22 !
24 !
25 USE yomhook ,ONLY : lhook, dr_hook
26 USE parkind1 ,ONLY : jprb
27 !
28 USE modi_abor1_sfx
29 !
30 IMPLICIT NONE
31 !
32  CHARACTER(LEN=6), INTENT(IN) :: HPROGRAM ! calling program
33  CHARACTER(LEN=12), INTENT(IN) :: HREC ! name of the article to be written
34  CHARACTER(LEN=*), DIMENSION(:), INTENT(IN) :: HSELECT
35 LOGICAL, INTENT(OUT) :: ONOWRITE ! flag for article to be written
36 !
37  CHARACTER(LEN=12) :: YREC
38 INTEGER :: IFIELD,JFIELD
39 INTEGER :: ILUOUT ! listing logical unit
40 REAL(KIND=JPRB) :: ZHOOK_HANDLE
41 !-------------------------------------------------------------------------------
42 IF (lhook) CALL dr_hook('TEST_RECORD_LEN',0,zhook_handle)
43 !
44 IF (trim(hrec)=="time".OR.trim(hrec)=="longitude".OR.trim(hrec)=="latitude") THEN
45  onowrite = .false.
46  IF (lhook) CALL dr_hook('TEST_RECORD_LEN',1,zhook_handle)
47  RETURN
48 ENDIF
49 !
51 !
52 IF (lfirst_write) THEN
53  !
54 #ifdef WXIOS
55  IF (lxios .AND. (trim(hprogram)=='XIOS' )) THEN
56  !
57  IF (lxios_def_closed) THEN
58  IF (xios_is_valid_field(hrec)) THEN
59  onowrite = .NOT.xios_field_is_active(hrec)
60  ELSE
61  onowrite = .true.
62  ENDIF
63  ELSE
64  onowrite = .false.
65  ENDIF
66  !
67  IF (onowrite) THEN
68  lnowrite(ncpt_write) = onowrite
69  IF (lhook) CALL dr_hook('TEST_RECORD_LEN',1,zhook_handle)
70  RETURN
71  ENDIF
72  !
73  ENDIF
74 #endif
75  !
76  IF (len_trim(hrec)>12) THEN
77  CALL get_luout(hprogram,iluout)
78  WRITE(iluout,*) '----------------------------------------------'
79  WRITE(iluout,*) 'Error occured when writing a field '
80  WRITE(iluout,*) 'The name of the field is too long '
81  WRITE(iluout,*) 'The name must not be longer than 12 characters'
82  WRITE(iluout,*) 'Please shorten the name of your field '
83  WRITE(iluout,fmt='(A32,A12,A1)') ' The field name currently is : "',hrec,'"'
84  WRITE(iluout,*) '----------------------------------------------'
85  CALL abor1_sfx('TEST_RECORD_LEN: FIELD NAME TOO LONG --> '//hrec)
86  END IF
87  !
88  yrec = hrec
89  SELECT CASE(hrec(1:4))
90  CASE("TEB1","TEB2","TEB3","TEB4","TEB5","TEB6","TEB7","TEB8","TEB9")
91  yrec=hrec(6:len(hrec))
92  END SELECT
93  !
94  ! if output fields selection is active, test if this field is to be written
95  IF (SIZE(hselect)>0) THEN
96  ifield=count(hselect /= ' ')
97  onowrite=.true.
98  DO jfield=1,ifield
99  IF ( trim(hselect(jfield))==trim(yrec) ) THEN
100  onowrite=.false.
101  ENDIF
102  ENDDO
103  !special case for netcdf output
104  IF(trim(yrec)=='time')onowrite=.false.
105  ELSE
106  onowrite=.false.
107  ENDIF
108  !
109  lnowrite(ncpt_write) = onowrite
110  !
111 ELSE
112  !
113  onowrite = lnowrite(ncpt_write)
114  !
115 ENDIF
116 !
117 IF (lhook) CALL dr_hook('TEST_RECORD_LEN',1,zhook_handle)
118 !
119 !-------------------------------------------------------------------------------
120 END SUBROUTINE test_record_len
static const char * trim(const char *name, int *n)
Definition: drhook.c:2383
logical lxios
Definition: modd_xios.F90:41
logical, dimension(50000) lnowrite
subroutine abor1_sfx(YTEXT)
Definition: abor1_sfx.F90:7
logical lxios_def_closed
Definition: modd_xios.F90:54
integer, parameter jprb
Definition: parkind1.F90:32
subroutine test_record_len(HPROGRAM, HREC, HSELECT, ONOWRITE)
subroutine get_luout(HPROGRAM, KLUOUT)
Definition: get_luout.F90:7
logical lhook
Definition: yomhook.F90:15
static int count
Definition: memory_hook.c:21