source: LMDZ5/trunk/libf/cosp/cosp_output_mod.F90 @ 2055

Last change on this file since 2055 was 1986, checked in by jghattas, 11 years ago

cosp : corrections for compiling with XIOS. Runnig with cosp not tested.
xml : corrected error in field ozone_daylight. Error seen when read_climoz=2.

File size: 10.7 KB
Line 
1! A.Idelkadi sept 2013 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2!! Module pour declarer et initialiser les parametres de controle des fichiers de sorties et des champs a sortir
3!! La routine cosp_output_open (appelee 1 seule fois dans phy_cosp.F90) permet :
4!! de creer les fichiers avec leurs grilles horizontales et verticales
5!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6  MODULE cosp_output_mod
7
8  USE MOD_COSP_CONSTANTS
9  USE MOD_COSP_TYPES
10
11! cosp_output_mod
12      INTEGER, PRIVATE             :: i
13!!!!!!! Controle des fichier de sorties Cosp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
14      LOGICAL, DIMENSION(3), SAVE  :: cosp_outfilekeys
15      INTEGER, DIMENSION(3), SAVE  :: cosp_nidfiles
16!$OMP THREADPRIVATE(cosp_outfilekeys, cosp_nidfiles)
17      INTEGER, DIMENSION(3), SAVE  :: nhoricosp, nvert, nvertmcosp, nvertcol, nvertisccp, nvertp
18      REAL, DIMENSION(3), SAVE                :: zoutm_cosp
19!$OMP THREADPRIVATE(nhori, nvert, nvertmcosp, nvertcol, nvertisccp, nvertp, zoutm_cosp)
20      REAL, SAVE                   :: zdtimemoy_cosp
21!$OMP THREADPRIVATE(zdtimemoy_cosp)
22      CHARACTER(LEN=20), DIMENSION(3), SAVE  :: cosp_outfiletypes
23      CHARACTER(LEN=20), DIMENSION(3), SAVE  :: cosp_outfilenames
24      REAL, DIMENSION(3), SAVE               :: cosp_ecritfiles
25!$OMP THREADPRIVATE(cosp_outfiletypes, cosp_outfilenames, cosp_ecritfiles)
26
27!!!!  Controle des variables a sortir dans les fichiers !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
28  TYPE ctrl_outcosp
29     LOGICAL,DIMENSION(3)                 :: cles             !!! Sortir ou non le champs
30     CHARACTER(len=20)                    :: name       
31     CHARACTER(len=150)                   :: description      !!! Nom
32     CHARACTER(len=20)                    :: unit             !!! Unite
33     CHARACTER(len=20),DIMENSION(3)  :: cosp_typeecrit        !!! Operation (ave, inst, ...)
34  END TYPE ctrl_outcosp
35! CALIPSO vars
36  TYPE(ctrl_outcosp), SAVE :: o_cllcalipso = ctrl_outcosp((/ .TRUE., .TRUE., .TRUE. /), &
37         "cllcalipso", "Lidar Low-level Cloud Fraction", "1", (/ ('', i=1, 3) /))                                   
38  TYPE(ctrl_outcosp), SAVE :: o_clmcalipso = ctrl_outcosp((/ .TRUE., .TRUE., .TRUE. /), &
39         "clmcalipso", "Lidar Mid-level Cloud Fraction", "1", (/ ('', i=1, 3) /))
40  TYPE(ctrl_outcosp), SAVE :: o_clhcalipso = ctrl_outcosp((/ .TRUE., .TRUE., .TRUE. /), &
41         "clhcalipso", "Lidar Hight-level Cloud Fraction", "1", (/ ('', i=1, 3) /))
42  TYPE(ctrl_outcosp), SAVE :: o_cltcalipso = ctrl_outcosp((/ .TRUE., .TRUE., .TRUE. /), &
43         "cltcalipso", "Lidar Total Cloud Fraction", "1", (/ ('', i=1, 3) /))
44  TYPE(ctrl_outcosp), SAVE :: o_clcalipso = ctrl_outcosp((/ .TRUE., .TRUE., .TRUE. /), &
45         "clcalipso", "Lidar Cloud Fraction (532 nm)", "1", (/ ('', i=1, 3) /))
46  TYPE(ctrl_outcosp), SAVE :: o_cfad_lidarsr532 = ctrl_outcosp((/ .FALSE., .FALSE., .FALSE. /), &
47         "cfad_lidarsr532", "Lidar Scattering Ratio CFAD (532 nm)", "1", (/ ('', i=1, 3) /))   
48  TYPE(ctrl_outcosp), SAVE :: o_parasol_refl = ctrl_outcosp((/ .TRUE., .TRUE., .TRUE. /), &
49         "parasol_refl", "PARASOL-like mono-directional reflectance","1", (/ ('', i=1, 3) /))
50  TYPE(ctrl_outcosp), SAVE :: o_parasol_crefl = ctrl_outcosp((/ .TRUE., .TRUE., .TRUE. /), &             
51         "parasol_crefl", "PARASOL-like mono-directional reflectance (integral)","1", (/ ('', i=1, 3) /))                 
52  TYPE(ctrl_outcosp), SAVE :: o_atb532 = ctrl_outcosp((/ .FALSE., .FALSE., .FALSE. /), &
53         "atb532", "Lidar Attenuated Total Backscatter (532 nm)","1", (/ ('', i=1, 3) /))
54  TYPE(ctrl_outcosp), SAVE :: o_beta_mol532 = ctrl_outcosp((/ .FALSE., .FALSE., .FALSE. /), &
55         "beta_mol532", "Lidar Molecular Backscatter (532 nm)","m-1 sr-1", (/ ('', i=1, 3) /))
56! ISCCP vars
57  TYPE(ctrl_outcosp), SAVE :: o_sunlit = ctrl_outcosp((/ .TRUE., .TRUE., .TRUE. /), &
58         "sunlit", "1 for day points, 0 for nightime","1",(/ ('', i=1, 3) /))                   
59  TYPE(ctrl_outcosp), SAVE :: o_clisccp2 = ctrl_outcosp((/ .TRUE., .TRUE., .TRUE. /), &
60         "clisccp2", "Cloud Fraction as Calculated by the ISCCP Simulator","1", (/ ('', i=1, 3) /))
61  TYPE(ctrl_outcosp), SAVE :: o_boxtauisccp = ctrl_outcosp((/ .FALSE., .FALSE., .FALSE. /), &
62         "boxtauisccp", "Optical Depth in Each Column as Calculated by the ISCCP Simulator","1", (/ ('', i=1, 3) /))
63  TYPE(ctrl_outcosp), SAVE :: o_boxptopisccp = ctrl_outcosp((/ .FALSE., .FALSE., .FALSE. /), &
64         "boxptopisccp", "Cloud Top Pressure in Each Column as Calculated by the ISCCP Simulator","Pa", (/ ('', i=1, 3) /))
65  TYPE(ctrl_outcosp), SAVE :: o_tclisccp = ctrl_outcosp((/ .TRUE., .TRUE., .TRUE. /), &
66          "tclisccp", "Total Cloud Fraction as Calculated by the ISCCP Simulator", "1", (/ ('', i=1, 3) /))
67  TYPE(ctrl_outcosp), SAVE :: o_ctpisccp = ctrl_outcosp((/ .TRUE., .TRUE., .TRUE. /), &
68          "ctpisccp", "Mean Cloud Top Pressure as Calculated by the ISCCP Simulator", "Pa", (/ ('', i=1, 3) /))
69  TYPE(ctrl_outcosp), SAVE :: o_tauisccp = ctrl_outcosp((/ .TRUE., .TRUE., .TRUE. /), &
70          "tauisccp", "Optical Depth as Calculated by the ISCCP Simulator", "1", (/ ('', i=1, 3) /))
71  TYPE(ctrl_outcosp), SAVE :: o_albisccp = ctrl_outcosp((/ .TRUE., .TRUE., .TRUE. /), &
72          "albisccp", "Mean Cloud Albedo as Calculated by the ISCCP Simulator", "1", (/ ('', i=1, 3) /))
73  TYPE(ctrl_outcosp), SAVE :: o_meantbisccp = ctrl_outcosp((/ .FALSE., .FALSE., .FALSE. /), &
74          "meantbisccp", " Mean all-sky 10.5 micron brightness temperature as calculated &
75           by the ISCCP Simulator","K", (/ ('', i=1, 3) /))
76  TYPE(ctrl_outcosp), SAVE :: o_meantbclrisccp = ctrl_outcosp((/ .FALSE., .FALSE., .FALSE. /), &
77          "meantbclrisccp", "Mean clear-sky 10.5 micron brightness temperature as calculated &
78           by the ISCCP Simulator","K", (/ ('', i=1, 3) /))
79
80!   LOGICAL, SAVE :: cosp_varsdefined = .FALSE. ! ug PAS THREADPRIVATE ET C'EST NORMAL
81  LOGICAL, SAVE        :: cosp_varsdefined
82  INTEGER, save        :: Nlevout,Ncolout
83!$OMP THREADPRIVATE(Nlevout)
84
85CONTAINS
86
87!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
88!!!!!!!!! Ouverture des fichier et definition des  axes!!!!!!!!
89  !! histbeg, histvert
90!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
91
92  SUBROUTINE cosp_output_open(Nlevlmdz, Ncolumns, presnivs, dtime, freq_cosp, &
93                              ok_mensuelCOSP, ok_journeCOSP, ok_hfCOSP, &
94                              ecrit_mth, ecrit_day, ecrit_hf, use_vgrid, vgrid)
95
96
97  USE iophy
98  USE ioipsl
99  USE phys_cal_mod
100
101#ifdef CPP_XIOS
102    ! ug Pour les sorties XIOS
103    USE wxios
104#endif
105
106  IMPLICIT NONE
107
108!!! Variables d'entree
109  integer                  :: Nlevlmdz, Ncolumns      ! Number of levels
110  real,dimension(Nlevlmdz) :: presnivs
111  real                     :: dtime, freq_cosp, ecrit_day, ecrit_hf, ecrit_mth
112  logical                  :: ok_mensuelCOSP, ok_journeCOSP, ok_hfCOSP, use_vgrid                   
113  type(cosp_vgrid)   :: vgrid   ! Information on vertical grid of stats
114
115!!! Variables locales
116  integer                  :: idayref, iff, ii
117  real                     :: zjulian
118  real,dimension(Ncolumns) :: column_ax
119
120!!! Variables d'entree
121  include "temps.h"
122  INCLUDE 'iniprint.h'
123
124#ifdef CPP_XIOS
125    ! ug Variables utilisées pour récupérer le calendrier pour xios
126    INTEGER :: x_an, x_mois, x_jour
127    REAL :: x_heure
128#endif
129
130    WRITE(lunout,*) 'Debut cosp_output_mod.F90'
131    ! Initialisations (Valeurs par defaut)
132    Nlevout = vgrid%Nlvgrid
133    Ncolout = Ncolumns
134
135    do ii=1,Ncolumns
136      column_ax(ii) = real(ii)
137    enddo
138
139
140    cosp_outfilenames(1) = 'histmthCOSP'
141    cosp_outfilenames(2) = 'histdayCOSP'
142    cosp_outfilenames(3) = 'histhfCOSP'
143
144    cosp_outfiletypes(1) = 'ave(X)'
145    cosp_outfiletypes(2) = 'ave(X)'
146    cosp_outfiletypes(3) = 'ave(X)'
147
148    cosp_outfilekeys(1) = ok_mensuelCOSP
149    cosp_outfilekeys(2) = ok_journeCOSP
150    cosp_outfilekeys(3) = ok_hfCOSP
151
152    cosp_ecritfiles(1) = mth_len*86400.
153    cosp_ecritfiles(2) = 1.*86400.
154    cosp_ecritfiles(3) = 0.125*86400.
155
156! Lecture des parametres dans output.def ou config.def
157
158    CALL getin('cosp_outfilenames',cosp_outfilenames)
159    CALL getin('cosp_outfilekeys',cosp_outfilekeys)
160    CALL getin('cosp_outfiletimesteps',cosp_ecritfiles)
161    CALL getin('cosp_outfiletypes',cosp_outfiletypes)
162
163    WRITE(lunout,*)'cosp_outfilenames=',cosp_outfilenames
164    WRITE(lunout,*)'cosp_outfilekeys=',cosp_outfilekeys
165    WRITE(lunout,*)'cosp_outfiletimesteps=',cosp_ecritfiles
166    WRITE(lunout,*)'cosp_outfiletypes=',cosp_outfiletypes
167 
168#ifdef CPP_XIOS
169    ! ug Réglage du calendrier xios
170    !Temps julian => an, mois, jour, heure
171    CALL ymds2ju(annee_ref, 1, day_ref, 0.0, zjulian)
172    CALL ju2ymds(zjulian, x_an, x_mois, x_jour, x_heure)
173    CALL wxios_set_cal(dtime, calend, x_an, x_mois, x_jour, x_heure)
174#endif
175   
176    zdtimemoy_cosp = freq_COSP         ! Frequence ou l on moyenne
177
178    DO iff=1,3
179       zoutm_cosp(iff) = cosp_ecritfiles(iff) ! Frequence ou l on ecrit en seconde
180
181       IF (cosp_outfilekeys(iff)) THEN
182           idayref = day_ref
183           CALL ymds2ju(annee_ref, 1, idayref, 0., zjulian)
184           CALL histbeg_phy(cosp_outfilenames(iff),itau_phy,zjulian,&
185             dtime,nhoricosp(iff),cosp_nidfiles(iff))
186
187! Definition de l'axe vertical
188       if (use_vgrid) then
189! Axe vertical Cosp 40 niveaux (en m)
190      CALL histvert(cosp_nidfiles(iff),"height","height","m",Nlevout,vgrid%z,nvert(iff))
191       else
192! Axe vertical modele LMDZ presnivs
193      CALL histvert(cosp_nidfiles(iff),"presnivs","Vertical levels","Pa",Nlevout,presnivs,nvert(iff),"down")
194       endif
195! Axe vertical niveaux modele (en m)
196      CALL histvert(cosp_nidfiles(iff),"height_mlev","height_mlev","m",Nlevlmdz,vgrid%mz,nvertmcosp(iff))
197
198      CALL histvert(cosp_nidfiles(iff),"sza","solar_zenith_angle","degrees",PARASOL_NREFL,PARASOL_SZA,nvertp(iff))
199
200      CALL histvert(cosp_nidfiles(iff),"pressure2","pressure","mb",7,ISCCP_PC,nvertisccp(iff),"down")
201
202      CALL histvert(cosp_nidfiles(iff),"column","column","count",Ncolumns,column_ax(1:Ncolumns),nvertcol(iff))
203
204#ifdef CPP_XIOS
205    ! ug déclaration des axes verticaux de chaque fichier:
206    if (use_vgrid) then
207      CALL wxios_add_vaxis("height", cosp_outfilenames(iff), Nlevout, vgrid%z)
208    else
209      CALL wxios_add_vaxis("presnivs", cosp_outfilenames(iff), Nlevout, presnivs)
210    endif
211    CALL wxios_add_vaxis("height_mlev", cosp_outfilenames(iff), Nlevlmdz, vgrid%mz)
212    CALL wxios_add_vaxis("sza", cosp_outfilenames(iff), PARASOL_NREFL, PARASOL_SZA)
213    CALL wxios_add_vaxis("pressure2", cosp_outfilenames(iff), 7, ISCCP_PC)
214    CALL wxios_add_vaxis("column", cosp_outfilenames(iff), Ncolumns, column_ax)
215#endif
216
217      ENDIF
218  ENDDO
219
220    end SUBROUTINE cosp_output_open
221
222 END MODULE cosp_output_mod
Note: See TracBrowser for help on using the repository browser.