Juan 8/12/2016: add management of LEN_HREC in MNH & SURFEX
[MNH-git_open_source-lfs.git] / src / SURFEX / writesurf_watfluxn.F90
1 !SURFEX_LIC Copyright 1994-2014 Meteo-France 
2 !SURFEX_LIC This is part of the SURFEX software governed by the CeCILL-C  licence
3 !SURFEX_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt
4 !SURFEX_LIC for details. version 1.
5 !     #########
6       SUBROUTINE WRITESURF_WATFLUX_n(HPROGRAM)
7 !     ########################################
8 !
9 !!****  *WRITESURF_WATFLUX_n* - writes WATFLUX fields
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 !!      V. Masson   *Meteo France*      
31 !!
32 !!    MODIFICATIONS
33 !!    -------------
34 !!      Original    01/2003 
35 !-------------------------------------------------------------------------------
36 !
37 !*       0.    DECLARATIONS
38 !              ------------
39 !
40 USE MODD_WATFLUX_n,      ONLY : XTS, XZ0, TTIME,  &
41                                   LINTERPOL_TS, XTS_MTH  
42 !
43 USE MODI_WRITE_SURF
44 !
45 !
46 USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
47 USE PARKIND1  ,ONLY : JPRB
48 !
49 IMPLICIT NONE
50 !
51 !*       0.1   Declarations of arguments
52 !              -------------------------
53 !
54  CHARACTER(LEN=6),  INTENT(IN)  :: HPROGRAM ! program calling
55
56 !
57 !*       0.2   Declarations of local variables
58 !              -------------------------------
59 !
60 INTEGER          :: JMTH,INMTH
61  CHARACTER(LEN=2) :: YMTH
62 !
63 INTEGER           :: IRESP          ! IRESP  : return-code if a problem appears
64  CHARACTER(LEN=LEN_HREC) :: YRECFM         ! Name of the article to be read
65  CHARACTER(LEN=100):: YCOMMENT       ! Comment string
66 REAL(KIND=JPRB) :: ZHOOK_HANDLE
67 !
68 !-------------------------------------------------------------------------------
69 !
70 !
71 !*       3.     Prognostic fields:
72 !               -----------------
73 !
74 !* water temperature
75 !
76 IF (LHOOK) CALL DR_HOOK('WRITESURF_WATFLUX_N',0,ZHOOK_HANDLE)
77 IF(LINTERPOL_TS)THEN
78 !
79   INMTH=SIZE(XTS_MTH,2)
80 !
81   DO JMTH=1,INMTH
82      WRITE(YMTH,'(I2)') (JMTH-1)
83      YRECFM='TS_WATER'//ADJUSTL(YMTH(:LEN_TRIM(YMTH)))
84      YCOMMENT='TS_WATER month t'//ADJUSTL(YMTH(:LEN_TRIM(YMTH)))
85      CALL WRITE_SURF(HPROGRAM,YRECFM,XTS_MTH(:,JMTH),IRESP,HCOMMENT=YCOMMENT)
86   ENDDO
87 !
88 ENDIF
89 !
90 YRECFM='TS_WATER'
91 YCOMMENT='TS_WATER (K)'
92  CALL WRITE_SURF(HPROGRAM,YRECFM,XTS(:),IRESP,HCOMMENT=YCOMMENT)
93 !
94 !-------------------------------------------------------------------------------
95 !
96 !*       4.     Semi-prognostic fields:
97 !               ----------------------
98 !
99 !* roughness length
100 !
101 YRECFM='Z0WATER'
102 YCOMMENT='Z0WATER (m)'
103  CALL WRITE_SURF(HPROGRAM,YRECFM,XZ0(:),IRESP,HCOMMENT=YCOMMENT)
104 !
105 !
106 !-------------------------------------------------------------------------------
107 !
108 !*       5.  Time
109 !            ----
110 !
111 YRECFM='DTCUR'
112 YCOMMENT='s'
113  CALL WRITE_SURF(HPROGRAM,YRECFM,TTIME,IRESP,HCOMMENT=YCOMMENT)
114 IF (LHOOK) CALL DR_HOOK('WRITESURF_WATFLUX_N',1,ZHOOK_HANDLE)
115 !
116
117 !-------------------------------------------------------------------------------
118 !
119 END SUBROUTINE WRITESURF_WATFLUX_n