SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
mode_write_surf_cov.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 
7 
8 !RJ: split cover from read_surf.F90 to avoid compiler bugs
9 !RJ: all safety compatibility checks should be done here
10 PUBLIC :: write_surf_cov
11 
12  CONTAINS
13 
14 ! #############################################################
15  SUBROUTINE write_surf_cov (DGU, U, &
16  hprogram,hrec,pfield,oflag,kresp,hcomment,hdir)
17 ! #############################################################
18 !
19 !
20 !
21 !
22 !
24 USE modd_surf_atm_n, ONLY : surf_atm_t
25 !
26 USE modi_write_surf, ONLY: write_surf
27 #ifdef SFX_MNH
28 USE modi_write_surfx2cov_mnh
29 #endif
30 !
31 USE yomhook ,ONLY : lhook, dr_hook
32 USE parkind1 ,ONLY : jprb
33 !
34 IMPLICIT NONE
35 !
36 !* 0.1 Declarations of arguments
37 !
38 !
39 TYPE(diag_surf_atm_t), INTENT(INOUT) :: dgu
40 TYPE(surf_atm_t), INTENT(INOUT) :: u
41 !
42  CHARACTER(LEN=6), INTENT(IN) :: hprogram ! calling program
43  CHARACTER(LEN=*), INTENT(IN) :: hrec ! name of the article to be read
44 REAL, DIMENSION(:,:), INTENT(IN) :: pfield ! array containing the data field
45 LOGICAL,DIMENSION(:), INTENT(IN) :: oflag ! mask for array filling
46 INTEGER, INTENT(OUT) :: kresp ! KRESP : return-code if a problem appears
47  CHARACTER(LEN=100), INTENT(IN) :: hcomment ! Comment string
48  CHARACTER(LEN=1),OPTIONAL,INTENT(IN) :: hdir ! type of field :
49 ! ! 'H' : field with
50 ! ! horizontal spatial dim.
51 ! ! '-' : no horizontal dim.
52 !* 0.2 Declarations of local variables
53 !
54  CHARACTER(LEN=12) :: yrec
55  CHARACTER(LEN=100) :: ycomment
56 INTEGER :: il1
57 INTEGER :: il2
58  CHARACTER(LEN=1) :: ydir
59 INTEGER :: jcover, icover
60 REAL(KIND=JPRB) :: zhook_handle
61 !
62 IF (lhook) CALL dr_hook('WRITE_SURF_COV',0,zhook_handle)
63 !
64 yrec = hrec
65 ydir = 'H'
66 IF (present(hdir)) ydir = hdir
67 il1 = SIZE(pfield,1)
68 il2 = SIZE(oflag)
69 !
70 IF (hprogram=='MESONH') THEN
71 #ifdef SFX_MNH
72  CALL write_surfx2cov_mnh(yrec,il1,il2,pfield,oflag,kresp,hcomment,ydir)
73 #endif
74 ELSE
75  !
76 !RJ: could be generalized for all
77  IF (hprogram=='LFI ') THEN
78  yrec = 'COVER_PACKED'
79  ycomment='-'
80 !! YCOMMENT=HCOMMENT
81  CALL write_surf(dgu, u, &
82  hprogram,yrec,.false.,kresp,ycomment)
83  ENDIF
84  !
85  icover=0
86  DO jcover=1,il2
87  !
88  WRITE(yrec,'(A5,I3.3)') 'COVER',jcover
89  ycomment='X_Y_'//yrec
90  IF (.NOT. oflag(jcover)) cycle
91  icover = icover+1
92  !
93  CALL write_surf(dgu, u, &
94  hprogram,yrec,pfield(:,icover),kresp,ycomment,ydir)
95  !
96  END DO
97 END IF
98 !
99 IF (lhook) CALL dr_hook('WRITE_SURF_COV',1,zhook_handle)
100 !
101 END SUBROUTINE write_surf_cov
102 
103 END MODULE mode_write_surf_cov
subroutine, public write_surf_cov(DGU, U, HPROGRAM, HREC, PFIELD, OFLAG, KRESP, HCOMMENT, HDIR)