e03a2cf68f598b72c627a6d02cd07ffb837d566f
[MNH-git_open_source-lfs.git] / src / SURFEX / read_seafluxn.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 READ_SEAFLUX_n(HPROGRAM)
7 !     #########################################
8 !
9 !!****  *READ_SEAFLUX_n* - read SEAFLUX varaibles
10 !!
11 !!
12 !!    PURPOSE
13 !!    -------
14 !!
15 !!**  METHOD
16 !!    ------
17 !!
18 !!    EXTERNAL
19 !!    --------
20 !!
21 !!
22 !!    IMPLICIT ARGUMENTS
23 !!    ------------------
24 !!
25 !!    REFERENCE
26 !!    ---------
27 !!
28 !!
29 !!    AUTHOR
30 !!    ------
31 !!      V. Masson   *Meteo France*      
32 !!
33 !!    MODIFICATIONS
34 !!    -------------
35 !!      Original    01/2003 
36 !!      Modified    02/2008 Add oceanic variables initialisation
37 !-------------------------------------------------------------------------------
38 !
39 !*       0.    DECLARATIONS
40 !              ------------
41 !
42 USE MODD_SEAFLUX_n,      ONLY : XSST, XZ0, LINTERPOL_SST, &
43                                   CINTERPOL_SST, XSST_MTH, TTIME  
44 USE MODD_OCEAN_n,        ONLY : LMERCATOR
45 !
46 USE MODI_READ_SURF
47 USE MODI_INTERPOL_SST_MTH
48 !
49 USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
50 USE PARKIND1  ,ONLY : JPRB
51 !
52 USE MODI_GET_TYPE_DIM_n
53 !
54 IMPLICIT NONE
55 !
56 !*       0.1   Declarations of arguments
57 !              -------------------------
58 !
59  CHARACTER(LEN=6),  INTENT(IN)  :: HPROGRAM ! calling program
60 !
61 !*       0.2   Declarations of local variables
62 !              -------------------------------
63 !
64 INTEGER           :: JMTH, INMTH
65  CHARACTER(LEN=2 ) :: YMTH
66 !
67 INTEGER           :: ILU          ! 1D physical dimension
68 !
69 INTEGER           :: IRESP          ! Error code after redding
70 !
71  CHARACTER(LEN=12) :: YRECFM         ! Name of the article to be read
72 REAL(KIND=JPRB) :: ZHOOK_HANDLE
73 !
74 !
75 !-------------------------------------------------------------------------------
76 !
77 !* 1D physical dimension
78 !
79 IF (LHOOK) CALL DR_HOOK('READ_SEAFLUX_N',0,ZHOOK_HANDLE)
80 YRECFM='SIZE_SEA'
81  CALL GET_TYPE_DIM_n('SEA   ',ILU)
82 !
83 !*       2.     Prognostic fields:
84 !               -----------------
85 !
86 !* water temperature
87 !
88 ALLOCATE(XSST(ILU))
89 !
90 IF(LINTERPOL_SST)THEN
91 !
92 ! Precedent, Current and Next Monthly SST
93   INMTH=3
94 ! Precedent, Current and Next Annual Monthly SST
95   IF(CINTERPOL_SST=='ANNUAL')INMTH=14
96 !
97   ALLOCATE(XSST_MTH(SIZE(XSST),INMTH))
98   DO JMTH=1,INMTH
99      WRITE(YMTH,'(I2)') (JMTH-1)
100      YRECFM='SST_MTH'//ADJUSTL(YMTH(:LEN_TRIM(YMTH)))
101      CALL READ_SURF(HPROGRAM,YRECFM,XSST_MTH(:,JMTH),IRESP)
102   ENDDO
103 !
104   CALL INTERPOL_SST_MTH(TTIME%TDATE%YEAR,TTIME%TDATE%MONTH,TTIME%TDATE%DAY,XSST)
105 !
106 ELSE
107
108   ALLOCATE(XSST_MTH(0,0))
109 !
110   YRECFM='SST'
111   CALL READ_SURF(HPROGRAM,YRECFM,XSST(:),IRESP)
112 !
113 ENDIF
114 !
115 !-------------------------------------------------------------------------------
116 !
117 !*       3.     Semi-prognostic fields:
118 !               ----------------------
119 !
120 !* roughness length
121 !
122 ALLOCATE(XZ0(ILU))
123 YRECFM='Z0SEA'
124 XZ0(:) = 0.001
125  CALL READ_SURF(HPROGRAM,YRECFM,XZ0(:),IRESP)
126 IF (LHOOK) CALL DR_HOOK('READ_SEAFLUX_N',1,ZHOOK_HANDLE)
127 !
128 !------------------------------------------------------------------------------
129 END SUBROUTINE READ_SEAFLUX_n