| 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(nhoricosp, 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_Ncrefl = ctrl_outcosp((/ .TRUE., .TRUE., .TRUE. /), & |
|---|
| 53 | "Ncrefl", "Nb PARASOL-like mono-directional reflectance (integral)","1", (/ ('', i=1, 3) /)) |
|---|
| 54 | TYPE(ctrl_outcosp), SAVE :: o_atb532 = ctrl_outcosp((/ .FALSE., .FALSE., .FALSE. /), & |
|---|
| 55 | "atb532", "Lidar Attenuated Total Backscatter (532 nm)","1", (/ ('', i=1, 3) /)) |
|---|
| 56 | TYPE(ctrl_outcosp), SAVE :: o_beta_mol532 = ctrl_outcosp((/ .FALSE., .FALSE., .FALSE. /), & |
|---|
| 57 | "beta_mol532", "Lidar Molecular Backscatter (532 nm)","m-1 sr-1", (/ ('', i=1, 3) /)) |
|---|
| 58 | ! ISCCP vars |
|---|
| 59 | TYPE(ctrl_outcosp), SAVE :: o_sunlit = ctrl_outcosp((/ .TRUE., .TRUE., .TRUE. /), & |
|---|
| 60 | "sunlit", "1 for day points, 0 for nightime","1",(/ ('', i=1, 3) /)) |
|---|
| 61 | TYPE(ctrl_outcosp), SAVE :: o_clisccp2 = ctrl_outcosp((/ .TRUE., .TRUE., .TRUE. /), & |
|---|
| 62 | "clisccp2", "Cloud Fraction as Calculated by the ISCCP Simulator","1", (/ ('', i=1, 3) /)) |
|---|
| 63 | TYPE(ctrl_outcosp), SAVE :: o_boxtauisccp = ctrl_outcosp((/ .FALSE., .FALSE., .FALSE. /), & |
|---|
| 64 | "boxtauisccp", "Optical Depth in Each Column as Calculated by the ISCCP Simulator","1", (/ ('', i=1, 3) /)) |
|---|
| 65 | TYPE(ctrl_outcosp), SAVE :: o_boxptopisccp = ctrl_outcosp((/ .FALSE., .FALSE., .FALSE. /), & |
|---|
| 66 | "boxptopisccp", "Cloud Top Pressure in Each Column as Calculated by the ISCCP Simulator","Pa", (/ ('', i=1, 3) /)) |
|---|
| 67 | TYPE(ctrl_outcosp), SAVE :: o_tclisccp = ctrl_outcosp((/ .TRUE., .TRUE., .TRUE. /), & |
|---|
| 68 | "tclisccp", "Total Cloud Fraction as Calculated by the ISCCP Simulator", "1", (/ ('', i=1, 3) /)) |
|---|
| 69 | TYPE(ctrl_outcosp), SAVE :: o_ctpisccp = ctrl_outcosp((/ .TRUE., .TRUE., .TRUE. /), & |
|---|
| 70 | "ctpisccp", "Mean Cloud Top Pressure as Calculated by the ISCCP Simulator", "Pa", (/ ('', i=1, 3) /)) |
|---|
| 71 | TYPE(ctrl_outcosp), SAVE :: o_tauisccp = ctrl_outcosp((/ .TRUE., .TRUE., .TRUE. /), & |
|---|
| 72 | "tauisccp", "Optical Depth as Calculated by the ISCCP Simulator", "1", (/ ('', i=1, 3) /)) |
|---|
| 73 | TYPE(ctrl_outcosp), SAVE :: o_albisccp = ctrl_outcosp((/ .TRUE., .TRUE., .TRUE. /), & |
|---|
| 74 | "albisccp", "Mean Cloud Albedo as Calculated by the ISCCP Simulator", "1", (/ ('', i=1, 3) /)) |
|---|
| 75 | TYPE(ctrl_outcosp), SAVE :: o_meantbisccp = ctrl_outcosp((/ .FALSE., .FALSE., .FALSE. /), & |
|---|
| 76 | "meantbisccp", " Mean all-sky 10.5 micron brightness temperature as calculated & |
|---|
| 77 | by the ISCCP Simulator","K", (/ ('', i=1, 3) /)) |
|---|
| 78 | TYPE(ctrl_outcosp), SAVE :: o_meantbclrisccp = ctrl_outcosp((/ .FALSE., .FALSE., .FALSE. /), & |
|---|
| 79 | "meantbclrisccp", "Mean clear-sky 10.5 micron brightness temperature as calculated & |
|---|
| 80 | by the ISCCP Simulator","K", (/ ('', i=1, 3) /)) |
|---|
| 81 | |
|---|
| 82 | LOGICAL, SAVE :: cosp_varsdefined = .FALSE. ! ug PAS THREADPRIVATE ET C'EST NORMAL |
|---|
| 83 | REAL, SAVE :: Cosp_fill_value |
|---|
| 84 | !$OMP THREADPRIVATE(Cosp_fill_value) |
|---|
| 85 | |
|---|
| 86 | |
|---|
| 87 | CONTAINS |
|---|
| 88 | |
|---|
| 89 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|---|
| 90 | !!!!!!!!! Ouverture des fichier et definition des axes!!!!!!!! |
|---|
| 91 | !! histbeg, histvert |
|---|
| 92 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|---|
| 93 | |
|---|
| 94 | SUBROUTINE cosp_output_open(Nlevlmdz, Ncolumns, presnivs, dtime, freq_cosp, & |
|---|
| 95 | ok_mensuelCOSP, ok_journeCOSP, ok_hfCOSP, ok_all_xml, & |
|---|
| 96 | ecrit_mth, ecrit_day, ecrit_hf, use_vgrid, vgrid) |
|---|
| 97 | |
|---|
| 98 | |
|---|
| 99 | USE iophy |
|---|
| 100 | USE ioipsl |
|---|
| 101 | USE phys_cal_mod |
|---|
| 102 | USE time_phylmdz_mod, ONLY: day_ref, annee_ref, day_ini, start_time, itau_phy |
|---|
| 103 | USE print_control_mod, ONLY: lunout |
|---|
| 104 | |
|---|
| 105 | #ifdef CPP_XIOS |
|---|
| 106 | ! ug Pour les sorties XIOS |
|---|
| 107 | USE wxios |
|---|
| 108 | #endif |
|---|
| 109 | |
|---|
| 110 | IMPLICIT NONE |
|---|
| 111 | |
|---|
| 112 | !!! Variables d'entree |
|---|
| 113 | integer :: Nlevlmdz, Ncolumns ! Number of levels |
|---|
| 114 | real,dimension(Nlevlmdz) :: presnivs |
|---|
| 115 | real :: dtime, freq_cosp, ecrit_day, ecrit_hf, ecrit_mth |
|---|
| 116 | logical :: ok_mensuelCOSP, ok_journeCOSP, ok_hfCOSP, use_vgrid, ok_all_xml |
|---|
| 117 | type(cosp_vgrid) :: vgrid ! Information on vertical grid of stats |
|---|
| 118 | |
|---|
| 119 | !!! Variables locales |
|---|
| 120 | integer :: idayref, iff, ii |
|---|
| 121 | real :: zjulian,zjulian_start |
|---|
| 122 | real,dimension(Ncolumns) :: column_ax |
|---|
| 123 | CHARACTER(LEN=20), DIMENSION(3) :: chfreq = (/ '1day', '1d', '3h' /) |
|---|
| 124 | |
|---|
| 125 | !!! Variables d'entree |
|---|
| 126 | |
|---|
| 127 | #ifdef CPP_XIOS |
|---|
| 128 | ! ug Variables utilisées pour récupérer le calendrier pour xios |
|---|
| 129 | INTEGER :: x_an, x_mois, x_jour |
|---|
| 130 | REAL :: x_heure |
|---|
| 131 | INTEGER :: ini_an, ini_mois, ini_jour |
|---|
| 132 | REAL :: ini_heure |
|---|
| 133 | #endif |
|---|
| 134 | |
|---|
| 135 | WRITE(lunout,*) 'Debut cosp_output_mod.F90' |
|---|
| 136 | print*,'cosp_varsdefined',cosp_varsdefined |
|---|
| 137 | ! Initialisations (Valeurs par defaut) |
|---|
| 138 | |
|---|
| 139 | do ii=1,Ncolumns |
|---|
| 140 | column_ax(ii) = real(ii) |
|---|
| 141 | enddo |
|---|
| 142 | |
|---|
| 143 | |
|---|
| 144 | cosp_outfilenames(1) = 'histmthCOSP' |
|---|
| 145 | cosp_outfilenames(2) = 'histdayCOSP' |
|---|
| 146 | cosp_outfilenames(3) = 'histhfCOSP' |
|---|
| 147 | |
|---|
| 148 | cosp_outfiletypes(1) = 'ave(X)' |
|---|
| 149 | cosp_outfiletypes(2) = 'ave(X)' |
|---|
| 150 | cosp_outfiletypes(3) = 'ave(X)' |
|---|
| 151 | |
|---|
| 152 | cosp_outfilekeys(1) = ok_mensuelCOSP |
|---|
| 153 | cosp_outfilekeys(2) = ok_journeCOSP |
|---|
| 154 | cosp_outfilekeys(3) = ok_hfCOSP |
|---|
| 155 | |
|---|
| 156 | cosp_ecritfiles(1) = mth_len*86400. |
|---|
| 157 | cosp_ecritfiles(2) = 1.*86400. |
|---|
| 158 | cosp_ecritfiles(3) = 0.125*86400. |
|---|
| 159 | |
|---|
| 160 | ! Lecture des parametres dans output.def ou config.def |
|---|
| 161 | |
|---|
| 162 | CALL getin('cosp_outfilenames',cosp_outfilenames) |
|---|
| 163 | CALL getin('cosp_outfilekeys',cosp_outfilekeys) |
|---|
| 164 | CALL getin('cosp_ecritfiles',cosp_ecritfiles) |
|---|
| 165 | CALL getin('cosp_outfiletypes',cosp_outfiletypes) |
|---|
| 166 | |
|---|
| 167 | WRITE(lunout,*)'cosp_outfilenames=',cosp_outfilenames |
|---|
| 168 | WRITE(lunout,*)'cosp_outfilekeys=',cosp_outfilekeys |
|---|
| 169 | WRITE(lunout,*)'cosp_ecritfiles=',cosp_ecritfiles |
|---|
| 170 | WRITE(lunout,*)'cosp_outfiletypes=',cosp_outfiletypes |
|---|
| 171 | |
|---|
| 172 | idayref = day_ref |
|---|
| 173 | CALL ymds2ju(annee_ref, 1, idayref, 0.0, zjulian) |
|---|
| 174 | CALL ymds2ju(annee_ref, 1, day_ini, start_time, zjulian_start) |
|---|
| 175 | |
|---|
| 176 | #ifdef CPP_XIOS |
|---|
| 177 | |
|---|
| 178 | ! recuperer la valeur indefine Xios |
|---|
| 179 | ! CALL xios_get_field_attr("clcalipso",default_value=Cosp_fill_value) |
|---|
| 180 | ! Cosp_fill_value=missing_val |
|---|
| 181 | Cosp_fill_value=0. |
|---|
| 182 | print*,'Cosp_fill_value=',Cosp_fill_value |
|---|
| 183 | ! ug R\'eglage du calendrier xios |
|---|
| 184 | !Temps julian => an, mois, jour, heure |
|---|
| 185 | ! CALL ju2ymds(zjulian, x_an, x_mois, x_jour, x_heure) |
|---|
| 186 | ! CALL ju2ymds(zjulian_start, ini_an, ini_mois, ini_jour, ini_heure) |
|---|
| 187 | ! CALL wxios_set_cal(dtime, calend, x_an, x_mois, x_jour, x_heure, ini_an, & |
|---|
| 188 | ! ini_mois, ini_jour, ini_heure ) |
|---|
| 189 | ! ug d�claration des axes verticaux de chaque fichier: |
|---|
| 190 | ! if (use_vgrid) then |
|---|
| 191 | CALL wxios_add_vaxis("height", vgrid%Nlvgrid, vgrid%z) |
|---|
| 192 | ! else |
|---|
| 193 | ! WRITE(lunout,*) 'wxios_add_vaxis "presnivs", vgrid%Nlvgrid ',vgrid%Nlvgrid |
|---|
| 194 | ! CALL wxios_add_vaxis("presnivs", vgrid%Nlvgrid, presnivs) |
|---|
| 195 | ! endif |
|---|
| 196 | WRITE(lunout,*) 'wxios_add_vaxis height_mlev, Nlevlmdz ',Nlevlmdz |
|---|
| 197 | CALL wxios_add_vaxis("height_mlev", Nlevlmdz, vgrid%mz) |
|---|
| 198 | WRITE(lunout,*) 'wxios_add_vaxis sza, PARASOL_NREFL ',PARASOL_NREFL |
|---|
| 199 | CALL wxios_add_vaxis("sza", PARASOL_NREFL, PARASOL_SZA) |
|---|
| 200 | WRITE(lunout,*) 'wxios_add_vaxis pressure2 ',7 |
|---|
| 201 | CALL wxios_add_vaxis("pressure2", 7, ISCCP_PC) |
|---|
| 202 | WRITE(lunout,*) 'wxios_add_vaxis column ',Ncolumns |
|---|
| 203 | CALL wxios_add_vaxis("column", Ncolumns, column_ax) |
|---|
| 204 | #endif |
|---|
| 205 | |
|---|
| 206 | zdtimemoy_cosp = freq_COSP ! Frequence ou l on moyenne |
|---|
| 207 | |
|---|
| 208 | DO iff=1,3 |
|---|
| 209 | zoutm_cosp(iff) = cosp_ecritfiles(iff) ! Frequence ou l on ecrit en seconde |
|---|
| 210 | |
|---|
| 211 | IF (cosp_outfilekeys(iff)) THEN |
|---|
| 212 | CALL histbeg_phy_all(cosp_outfilenames(iff),itau_phy,zjulian,& |
|---|
| 213 | dtime,nhoricosp(iff),cosp_nidfiles(iff)) |
|---|
| 214 | print*,'histbeg_phy nhoricosp(iff),cosp_nidfiles(iff)', & |
|---|
| 215 | nhoricosp(iff),cosp_nidfiles(iff) |
|---|
| 216 | |
|---|
| 217 | #ifdef CPP_XIOS |
|---|
| 218 | IF (.not. ok_all_xml) then |
|---|
| 219 | WRITE(lunout,*) 'wxios_add_file ',cosp_outfilenames(iff) |
|---|
| 220 | CALL wxios_add_file(cosp_outfilenames(iff),chfreq(iff),10) |
|---|
| 221 | ENDIF |
|---|
| 222 | #endif |
|---|
| 223 | |
|---|
| 224 | #ifndef CPP_IOIPSL_NO_OUTPUT |
|---|
| 225 | ! Definition de l'axe vertical |
|---|
| 226 | if (use_vgrid) then |
|---|
| 227 | ! Axe vertical Cosp 40 niveaux (en m) |
|---|
| 228 | CALL histvert(cosp_nidfiles(iff),"height","height","m",vgrid%Nlvgrid,vgrid%z,nvert(iff)) |
|---|
| 229 | else |
|---|
| 230 | ! Axe vertical modele LMDZ presnivs |
|---|
| 231 | CALL histvert(cosp_nidfiles(iff),"presnivs","Vertical levels","Pa",vgrid%Nlvgrid,presnivs,nvert(iff),"down") |
|---|
| 232 | endif |
|---|
| 233 | ! Axe vertical niveaux modele (en m) |
|---|
| 234 | CALL histvert(cosp_nidfiles(iff),"height_mlev","height_mlev","m",Nlevlmdz,vgrid%mz,nvertmcosp(iff)) |
|---|
| 235 | |
|---|
| 236 | CALL histvert(cosp_nidfiles(iff),"sza","solar_zenith_angle","degrees",PARASOL_NREFL,PARASOL_SZA,nvertp(iff)) |
|---|
| 237 | |
|---|
| 238 | CALL histvert(cosp_nidfiles(iff),"pressure2","pressure","mb",7,ISCCP_PC,nvertisccp(iff),"down") |
|---|
| 239 | |
|---|
| 240 | CALL histvert(cosp_nidfiles(iff),"column","column","count",Ncolumns,column_ax(1:Ncolumns),nvertcol(iff)) |
|---|
| 241 | |
|---|
| 242 | !!! Valeur indefinie en cas IOIPSL |
|---|
| 243 | Cosp_fill_value=0. |
|---|
| 244 | |
|---|
| 245 | #endif |
|---|
| 246 | |
|---|
| 247 | ENDIF |
|---|
| 248 | ENDDO |
|---|
| 249 | |
|---|
| 250 | end SUBROUTINE cosp_output_open |
|---|
| 251 | |
|---|
| 252 | END MODULE cosp_output_mod |
|---|