| 1 | !!!! Abderrahmane Idelkadi aout 2013 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|---|
| 2 | ! Module pour definir (au 1er appel) et ecrire les variables dans les fichiers de sortie cosp |
|---|
| 3 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|---|
| 4 | MODULE cosp_output_write_mod |
|---|
| 5 | |
|---|
| 6 | USE cosp_output_mod |
|---|
| 7 | |
|---|
| 8 | INTEGER, SAVE :: itau_iocosp |
|---|
| 9 | !$OMP THREADPRIVATE(itau_iocosp) |
|---|
| 10 | INTEGER, save :: Nlevout, Ncolout |
|---|
| 11 | !$OMP THREADPRIVATE(Nlevout, Ncolout) |
|---|
| 12 | |
|---|
| 13 | ! INTERFACE histwrite_cosp |
|---|
| 14 | ! MODULE PROCEDURE histwrite2d_cosp,histwrite3d_cosp |
|---|
| 15 | ! END INTERFACE |
|---|
| 16 | |
|---|
| 17 | CONTAINS |
|---|
| 18 | |
|---|
| 19 | SUBROUTINE cosp_output_write(Nlevlmdz, Npoints, Ncolumns, itap, dtime, freq_COSP, missing_cosp, & |
|---|
| 20 | cfg, gbx, vgrid, sglidar, sgradar, stlidar, stradar, & |
|---|
| 21 | isccp, misr, modis) |
|---|
| 22 | |
|---|
| 23 | USE ioipsl |
|---|
| 24 | USE time_phylmdz_mod, ONLY: itau_phy, start_time, day_step_phy |
|---|
| 25 | USE print_control_mod, ONLY: lunout,prt_level |
|---|
| 26 | |
|---|
| 27 | #ifdef CPP_XIOS |
|---|
| 28 | USE wxios, only: wxios_closedef |
|---|
| 29 | USE xios, only: xios_update_calendar |
|---|
| 30 | #endif |
|---|
| 31 | |
|---|
| 32 | !!! Variables d'entree |
|---|
| 33 | integer :: itap, Nlevlmdz, Ncolumns, Npoints |
|---|
| 34 | real :: freq_COSP, dtime, missing_val, missing_cosp |
|---|
| 35 | type(cosp_config) :: cfg ! Control outputs |
|---|
| 36 | type(cosp_gridbox) :: gbx ! Gridbox information. Input for COSP |
|---|
| 37 | type(cosp_sglidar) :: sglidar ! Output from lidar simulator |
|---|
| 38 | type(cosp_sgradar) :: sgradar ! Output from radar simulator |
|---|
| 39 | type(cosp_isccp) :: isccp ! Output from ISCCP simulator |
|---|
| 40 | type(cosp_lidarstats) :: stlidar ! Summary statistics from lidar simulator |
|---|
| 41 | type(cosp_radarstats) :: stradar |
|---|
| 42 | type(cosp_misr) :: misr ! Output from MISR |
|---|
| 43 | type(cosp_modis) :: modis ! Outputs from Modis |
|---|
| 44 | type(cosp_vgrid) :: vgrid ! Information on vertical grid of stats |
|---|
| 45 | |
|---|
| 46 | !!! Variables locales |
|---|
| 47 | integer :: icl |
|---|
| 48 | logical :: ok_sync |
|---|
| 49 | integer :: itau_wcosp |
|---|
| 50 | real, dimension(Npoints,PARASOL_NREFL) :: parasolcrefl, Ncref |
|---|
| 51 | |
|---|
| 52 | |
|---|
| 53 | #ifdef CPP_XIOS |
|---|
| 54 | missing_val=missing_cosp |
|---|
| 55 | #else |
|---|
| 56 | missing_val=0. |
|---|
| 57 | #endif |
|---|
| 58 | |
|---|
| 59 | Nlevout = vgrid%Nlvgrid |
|---|
| 60 | Ncolout = Ncolumns |
|---|
| 61 | |
|---|
| 62 | ! A refaire |
|---|
| 63 | itau_wcosp = itau_phy + itap + start_time * day_step_phy |
|---|
| 64 | if (prt_level >= 10) then |
|---|
| 65 | WRITE(lunout,*)'itau_wcosp, itap, start_time, day_step_phy =', & |
|---|
| 66 | itau_wcosp, itap, start_time, day_step_phy |
|---|
| 67 | endif |
|---|
| 68 | |
|---|
| 69 | ! On le donne a cosp_output_write_mod pour que les histwrite y aient acces: |
|---|
| 70 | CALL set_itau_iocosp(itau_wcosp) |
|---|
| 71 | if (prt_level >= 10) then |
|---|
| 72 | WRITE(lunout,*)'itau_iocosp =',itau_iocosp |
|---|
| 73 | endif |
|---|
| 74 | |
|---|
| 75 | ok_sync = .TRUE. |
|---|
| 76 | |
|---|
| 77 | !DO iinit=1, iinitend |
|---|
| 78 | ! AI sept 2014 cette boucle supprimee |
|---|
| 79 | ! On n'ecrit pas quand itap=1 (cosp) |
|---|
| 80 | |
|---|
| 81 | if (prt_level >= 10) then |
|---|
| 82 | WRITE(lunout,*)'DO iinit=1, iinitend ',iinitend |
|---|
| 83 | endif |
|---|
| 84 | |
|---|
| 85 | !#ifdef CPP_XIOS |
|---|
| 86 | ! !$OMP MASTER |
|---|
| 87 | !IF (cosp_varsdefined) THEN |
|---|
| 88 | ! if (prt_level >= 10) then |
|---|
| 89 | ! WRITE(lunout,*)'Apell xios_update_calendar cosp_varsdefined iinitend ', & |
|---|
| 90 | ! cosp_varsdefined,iinitend |
|---|
| 91 | ! endif |
|---|
| 92 | ! CALL xios_update_calendar(itau_wcosp) |
|---|
| 93 | !ENDIF |
|---|
| 94 | ! !$OMP END MASTER |
|---|
| 95 | ! !$OMP BARRIER |
|---|
| 96 | !#endif |
|---|
| 97 | |
|---|
| 98 | if (cfg%Llidar_sim) then |
|---|
| 99 | ! Pb des valeurs indefinies, on les met a 0 |
|---|
| 100 | ! A refaire proprement |
|---|
| 101 | do k = 1,Nlevout |
|---|
| 102 | do ip = 1,Npoints |
|---|
| 103 | if(stlidar%lidarcld(ip,k).eq.R_UNDEF)then |
|---|
| 104 | stlidar%lidarcld(ip,k)=missing_val |
|---|
| 105 | endif |
|---|
| 106 | if(stlidar%proftemp(ip,k).eq.R_UNDEF)then !TIBO |
|---|
| 107 | stlidar%proftemp(ip,k)=missing_val !TIBO |
|---|
| 108 | endif !TIBO |
|---|
| 109 | enddo |
|---|
| 110 | |
|---|
| 111 | do ii= 1,SR_BINS |
|---|
| 112 | do ip = 1,Npoints |
|---|
| 113 | if(stlidar%cfad_sr(ip,ii,k).eq.R_UNDEF)then |
|---|
| 114 | stlidar%cfad_sr(ip,ii,k)=missing_val |
|---|
| 115 | endif |
|---|
| 116 | enddo |
|---|
| 117 | enddo |
|---|
| 118 | |
|---|
| 119 | do ii= 1,Ncolumns !TIBO |
|---|
| 120 | do ip = 1,Npoints !TIBO |
|---|
| 121 | ! if(stlidar%profSR(ip,ii,k).eq.R_UNDEF)then !TIBO |
|---|
| 122 | ! stlidar%profSR(ip,ii,k)=missing_val !TIBO |
|---|
| 123 | if(stlidar%profSR(ip,k,ii).eq.R_UNDEF)then !TIBO2 |
|---|
| 124 | stlidar%profSR(ip,k,ii)=missing_val !TIBO2 |
|---|
| 125 | endif !TIBO |
|---|
| 126 | enddo !TIBO |
|---|
| 127 | enddo !TIBO |
|---|
| 128 | enddo |
|---|
| 129 | |
|---|
| 130 | do ip = 1,Npoints |
|---|
| 131 | do k = 1,Nlevlmdz |
|---|
| 132 | if(sglidar%beta_mol(ip,k).eq.R_UNDEF)then |
|---|
| 133 | sglidar%beta_mol(ip,k)=missing_val |
|---|
| 134 | endif |
|---|
| 135 | |
|---|
| 136 | do ii= 1,Ncolumns |
|---|
| 137 | if(sglidar%beta_tot(ip,ii,k).eq.R_UNDEF)then |
|---|
| 138 | sglidar%beta_tot(ip,ii,k)=missing_val |
|---|
| 139 | endif |
|---|
| 140 | enddo |
|---|
| 141 | |
|---|
| 142 | enddo !k = 1,Nlevlmdz |
|---|
| 143 | enddo !ip = 1,Npoints |
|---|
| 144 | |
|---|
| 145 | do k = 1,LIDAR_NCAT |
|---|
| 146 | do ip = 1,Npoints |
|---|
| 147 | if(stlidar%cldlayer(ip,k).eq.R_UNDEF)then |
|---|
| 148 | stlidar%cldlayer(ip,k)=missing_val |
|---|
| 149 | endif |
|---|
| 150 | enddo |
|---|
| 151 | enddo |
|---|
| 152 | |
|---|
| 153 | do k = 1,LIDAR_NTYPE !OPAQ |
|---|
| 154 | do ip = 1,Npoints !OPAQ |
|---|
| 155 | if(stlidar%cldtype(ip,k).eq.R_UNDEF)then !OPAQ |
|---|
| 156 | stlidar%cldtype(ip,k)=missing_val !OPAQ |
|---|
| 157 | endif !OPAQ |
|---|
| 158 | enddo !OPAQ |
|---|
| 159 | enddo !OPAQ |
|---|
| 160 | |
|---|
| 161 | ! AI 11 / 2015 |
|---|
| 162 | |
|---|
| 163 | where(stlidar%parasolrefl == R_UNDEF) stlidar%parasolrefl = missing_val |
|---|
| 164 | where(stlidar%lidarcldtmp == R_UNDEF) stlidar%lidarcldtmp = missing_val |
|---|
| 165 | where(stlidar%cldlayerphase == R_UNDEF) stlidar%cldlayerphase = missing_val |
|---|
| 166 | where(stlidar%lidarcldphase == R_UNDEF) stlidar%lidarcldphase = missing_val |
|---|
| 167 | where(stlidar%lidarcldtype == R_UNDEF) stlidar%lidarcldtype = missing_val !OPAQ |
|---|
| 168 | where(stlidar%lidarcldtmp == R_UNDEF) stlidar%lidarcldtmp = missing_val |
|---|
| 169 | |
|---|
| 170 | |
|---|
| 171 | print*,'Appel histwrite2d_cosp' |
|---|
| 172 | CALL histwrite2d_cosp(o_cllcalipso,stlidar%cldlayer(:,1)) |
|---|
| 173 | CALL histwrite2d_cosp(o_clhcalipso,stlidar%cldlayer(:,3)) |
|---|
| 174 | CALL histwrite2d_cosp(o_clmcalipso,stlidar%cldlayer(:,2)) |
|---|
| 175 | CALL histwrite2d_cosp(o_cltcalipso,stlidar%cldlayer(:,4)) |
|---|
| 176 | CALL histwrite3d_cosp(o_clcalipso,stlidar%lidarcld,nvert) |
|---|
| 177 | CALL histwrite3d_cosp(o_clcalipsotmp,stlidar%lidarcldtmp(:,:,1),nverttemp) |
|---|
| 178 | |
|---|
| 179 | CALL histwrite2d_cosp(o_cllcalipsoice,stlidar%cldlayerphase(:,1,1)) |
|---|
| 180 | CALL histwrite2d_cosp(o_clhcalipsoice,stlidar%cldlayerphase(:,3,1)) |
|---|
| 181 | CALL histwrite2d_cosp(o_clmcalipsoice,stlidar%cldlayerphase(:,2,1)) |
|---|
| 182 | CALL histwrite2d_cosp(o_cltcalipsoice,stlidar%cldlayerphase(:,4,1)) |
|---|
| 183 | CALL histwrite3d_cosp(o_clcalipsoice,stlidar%lidarcldphase(:,:,1),nvert) |
|---|
| 184 | CALL histwrite3d_cosp(o_clcalipsotmpice,stlidar%lidarcldtmp(:,:,2),nverttemp) |
|---|
| 185 | |
|---|
| 186 | CALL histwrite2d_cosp(o_cllcalipsoliq,stlidar%cldlayerphase(:,1,2)) |
|---|
| 187 | CALL histwrite2d_cosp(o_clhcalipsoliq,stlidar%cldlayerphase(:,3,2)) |
|---|
| 188 | CALL histwrite2d_cosp(o_clmcalipsoliq,stlidar%cldlayerphase(:,2,2)) |
|---|
| 189 | CALL histwrite2d_cosp(o_cltcalipsoliq,stlidar%cldlayerphase(:,4,2)) |
|---|
| 190 | CALL histwrite3d_cosp(o_clcalipsoliq,stlidar%lidarcldphase(:,:,2),nvert) |
|---|
| 191 | CALL histwrite3d_cosp(o_clcalipsotmpliq,stlidar%lidarcldtmp(:,:,3),nverttemp) |
|---|
| 192 | |
|---|
| 193 | CALL histwrite2d_cosp(o_cllcalipsoun,stlidar%cldlayerphase(:,1,3)) |
|---|
| 194 | CALL histwrite2d_cosp(o_clhcalipsoun,stlidar%cldlayerphase(:,3,3)) |
|---|
| 195 | CALL histwrite2d_cosp(o_clmcalipsoun,stlidar%cldlayerphase(:,2,3)) |
|---|
| 196 | CALL histwrite2d_cosp(o_cltcalipsoun,stlidar%cldlayerphase(:,4,3)) |
|---|
| 197 | CALL histwrite3d_cosp(o_clcalipsoun,stlidar%lidarcldphase(:,:,3),nvert) |
|---|
| 198 | CALL histwrite3d_cosp(o_clcalipsotmpun,stlidar%lidarcldtmp(:,:,4),nverttemp) |
|---|
| 199 | |
|---|
| 200 | CALL histwrite2d_cosp(o_clopaquecalipso,stlidar%cldtype(:,1)) !OPAQ |
|---|
| 201 | CALL histwrite2d_cosp(o_clthincalipso,stlidar%cldtype(:,2)) !OPAQ |
|---|
| 202 | CALL histwrite2d_cosp(o_clzopaquecalipso,stlidar%cldtype(:,3)) !OPAQ |
|---|
| 203 | |
|---|
| 204 | CALL histwrite3d_cosp(o_clcalipsoopaque,stlidar%lidarcldtype(:,:,1),nvert) !OPAQ |
|---|
| 205 | CALL histwrite3d_cosp(o_clcalipsothin,stlidar%lidarcldtype(:,:,2),nvert) !OPAQ |
|---|
| 206 | CALL histwrite3d_cosp(o_clcalipsozopaque,stlidar%lidarcldtype(:,:,3),nvert) !OPAQ |
|---|
| 207 | CALL histwrite3d_cosp(o_clcalipsoopacity,stlidar%lidarcldtype(:,:,4),nvert) !OPAQ |
|---|
| 208 | |
|---|
| 209 | CALL histwrite3d_cosp(o_proftemp,stlidar%proftemp,nvert) !TIBO |
|---|
| 210 | |
|---|
| 211 | #ifdef CPP_XIOS |
|---|
| 212 | CALL histwrite4d_cosp(o_cfad_lidarsr532,stlidar%cfad_sr) |
|---|
| 213 | CALL histwrite4d_cosp(o_profSR,stlidar%profSR) !TIBO |
|---|
| 214 | #else |
|---|
| 215 | do icl=1,SR_BINS |
|---|
| 216 | CALL histwrite3d_cosp(o_cfad_lidarsr532,stlidar%cfad_sr(:,icl,:),nvert,icl) |
|---|
| 217 | enddo |
|---|
| 218 | do icl=1,Ncolumns !TIBO |
|---|
| 219 | CALL histwrite3d_cosp(o_profSR,stlidar%profSR(:,icl,:),nvert,icl) !TIBO |
|---|
| 220 | enddo !TIBO |
|---|
| 221 | CALL histwrite3d_cosp(o_parasol_refl,stlidar%parasolrefl,nvertp) |
|---|
| 222 | #endif |
|---|
| 223 | |
|---|
| 224 | do k=1,PARASOL_NREFL |
|---|
| 225 | do ip=1, Npoints |
|---|
| 226 | if (stlidar%cldlayer(ip,4).gt.0.01.and.stlidar%parasolrefl(ip,k).ne.missing_val) then |
|---|
| 227 | parasolcrefl(ip,k)=(stlidar%parasolrefl(ip,k)-0.03*(1.-stlidar%cldlayer(ip,4)))/ & |
|---|
| 228 | stlidar%cldlayer(ip,4) |
|---|
| 229 | Ncref(ip,k) = 1. |
|---|
| 230 | else |
|---|
| 231 | parasolcrefl(ip,k)=missing_val |
|---|
| 232 | Ncref(ip,k) = 0. |
|---|
| 233 | endif |
|---|
| 234 | enddo |
|---|
| 235 | |
|---|
| 236 | enddo |
|---|
| 237 | CALL histwrite3d_cosp(o_Ncrefl,Ncref,nvertp) |
|---|
| 238 | CALL histwrite3d_cosp(o_parasol_crefl,parasolcrefl,nvertp) |
|---|
| 239 | |
|---|
| 240 | #ifdef CPP_XIOS |
|---|
| 241 | CALL histwrite4d_cosp(o_atb532,sglidar%beta_tot) |
|---|
| 242 | #else |
|---|
| 243 | do icl=1,Ncolumns |
|---|
| 244 | CALL histwrite3d_cosp(o_atb532,sglidar%beta_tot(:,icl,:),nvertmcosp,icl) |
|---|
| 245 | enddo |
|---|
| 246 | #endif |
|---|
| 247 | |
|---|
| 248 | CALL histwrite3d_cosp(o_beta_mol532,sglidar%beta_mol,nvertmcosp) |
|---|
| 249 | endif !Lidar |
|---|
| 250 | |
|---|
| 251 | if (cfg%Lradar_sim) then |
|---|
| 252 | |
|---|
| 253 | #ifdef CPP_XIOS |
|---|
| 254 | CALL histwrite4d_cosp(o_dbze94,sgradar%Ze_tot) |
|---|
| 255 | CALL histwrite4d_cosp(o_cfadDbze94,stradar%cfad_ze) |
|---|
| 256 | #else |
|---|
| 257 | do icl=1,Ncolumns |
|---|
| 258 | CALL histwrite3d_cosp(o_dbze94,sgradar%Ze_tot(:,icl,:),nvertmcosp,icl) |
|---|
| 259 | enddo |
|---|
| 260 | do icl=1,DBZE_BINS |
|---|
| 261 | CALL histwrite3d_cosp(o_cfadDbze94,stradar%cfad_ze(:,icl,:),nvert,icl) |
|---|
| 262 | enddo |
|---|
| 263 | #endif |
|---|
| 264 | endif |
|---|
| 265 | |
|---|
| 266 | if (cfg%Llidar_sim .and. cfg%Lradar_sim) then |
|---|
| 267 | where(stradar%lidar_only_freq_cloud == R_UNDEF) & |
|---|
| 268 | stradar%lidar_only_freq_cloud = missing_val |
|---|
| 269 | CALL histwrite3d_cosp(o_clcalipso2,stradar%lidar_only_freq_cloud,nvert) |
|---|
| 270 | where(stradar%radar_lidar_tcc == R_UNDEF) & |
|---|
| 271 | stradar%radar_lidar_tcc = missing_val |
|---|
| 272 | CALL histwrite2d_cosp(o_cltlidarradar,stradar%radar_lidar_tcc) |
|---|
| 273 | endif |
|---|
| 274 | |
|---|
| 275 | if (cfg%Lisccp_sim) then |
|---|
| 276 | |
|---|
| 277 | ! Traitement des valeurs indefinies |
|---|
| 278 | do ip = 1,Npoints |
|---|
| 279 | if(isccp%totalcldarea(ip).eq.R_UNDEF)then |
|---|
| 280 | isccp%totalcldarea(ip)=missing_val |
|---|
| 281 | endif |
|---|
| 282 | if(isccp%meanptop(ip).eq.R_UNDEF)then |
|---|
| 283 | isccp%meanptop(ip)=missing_val |
|---|
| 284 | endif |
|---|
| 285 | if(isccp%meantaucld(ip).eq.R_UNDEF)then |
|---|
| 286 | isccp%meantaucld(ip)=missing_val |
|---|
| 287 | endif |
|---|
| 288 | if(isccp%meanalbedocld(ip).eq.R_UNDEF)then |
|---|
| 289 | isccp%meanalbedocld(ip)=missing_val |
|---|
| 290 | endif |
|---|
| 291 | if(isccp%meantb(ip).eq.R_UNDEF)then |
|---|
| 292 | isccp%meantb(ip)=missing_val |
|---|
| 293 | endif |
|---|
| 294 | if(isccp%meantbclr(ip).eq.R_UNDEF)then |
|---|
| 295 | isccp%meantbclr(ip)=missing_val |
|---|
| 296 | endif |
|---|
| 297 | |
|---|
| 298 | do k=1,7 |
|---|
| 299 | do ii=1,7 |
|---|
| 300 | if(isccp%fq_isccp(ip,ii,k).eq.R_UNDEF)then |
|---|
| 301 | isccp%fq_isccp(ip,ii,k)=missing_val |
|---|
| 302 | endif |
|---|
| 303 | enddo |
|---|
| 304 | enddo |
|---|
| 305 | |
|---|
| 306 | do ii=1,Ncolumns |
|---|
| 307 | if(isccp%boxtau(ip,ii).eq.R_UNDEF)then |
|---|
| 308 | isccp%boxtau(ip,ii)=missing_val |
|---|
| 309 | endif |
|---|
| 310 | enddo |
|---|
| 311 | |
|---|
| 312 | do ii=1,Ncolumns |
|---|
| 313 | if(isccp%boxptop(ip,ii).eq.R_UNDEF)then |
|---|
| 314 | isccp%boxptop(ip,ii)=missing_val |
|---|
| 315 | endif |
|---|
| 316 | enddo |
|---|
| 317 | enddo |
|---|
| 318 | |
|---|
| 319 | CALL histwrite2d_cosp(o_sunlit,gbx%sunlit) |
|---|
| 320 | #ifdef CPP_XIOS |
|---|
| 321 | CALL histwrite4d_cosp(o_clisccp2,isccp%fq_isccp) |
|---|
| 322 | #else |
|---|
| 323 | do icl=1,7 |
|---|
| 324 | CALL histwrite3d_cosp(o_clisccp2,isccp%fq_isccp(:,icl,:),nvertisccp,icl) |
|---|
| 325 | enddo |
|---|
| 326 | #endif |
|---|
| 327 | CALL histwrite3d_cosp(o_boxtauisccp,isccp%boxtau,nvertcol) |
|---|
| 328 | CALL histwrite3d_cosp(o_boxptopisccp,isccp%boxptop,nvertcol) |
|---|
| 329 | CALL histwrite2d_cosp(o_tclisccp,isccp%totalcldarea) |
|---|
| 330 | CALL histwrite2d_cosp(o_ctpisccp,isccp%meanptop) |
|---|
| 331 | CALL histwrite2d_cosp(o_tauisccp,isccp%meantaucld) |
|---|
| 332 | CALL histwrite2d_cosp(o_albisccp,isccp%meanalbedocld) |
|---|
| 333 | CALL histwrite2d_cosp(o_meantbisccp,isccp%meantb) |
|---|
| 334 | CALL histwrite2d_cosp(o_meantbclrisccp,isccp%meantbclr) |
|---|
| 335 | endif ! Isccp |
|---|
| 336 | |
|---|
| 337 | ! MISR simulator |
|---|
| 338 | if (cfg%Lmisr_sim) then |
|---|
| 339 | do ip=1,Npoints |
|---|
| 340 | do ii=1,7 |
|---|
| 341 | do k=1,MISR_N_CTH |
|---|
| 342 | if(misr%fq_MISR(ip,ii,k).eq.R_UNDEF)then |
|---|
| 343 | misr%fq_MISR(ip,ii,k)=missing_val |
|---|
| 344 | endif |
|---|
| 345 | enddo |
|---|
| 346 | enddo |
|---|
| 347 | enddo |
|---|
| 348 | |
|---|
| 349 | #ifdef CPP_XIOS |
|---|
| 350 | CALL histwrite4d_cosp(o_clMISR,misr%fq_MISR) |
|---|
| 351 | #else |
|---|
| 352 | do icl=1,7 |
|---|
| 353 | CALL histwrite3d_cosp(o_clMISR,misr%fq_MISR(:,icl,:),nvertmisr,icl) |
|---|
| 354 | enddo |
|---|
| 355 | #endif |
|---|
| 356 | endif |
|---|
| 357 | |
|---|
| 358 | ! Modis simulator |
|---|
| 359 | if (cfg%Lmodis_sim) then |
|---|
| 360 | |
|---|
| 361 | do ip=1,Npoints |
|---|
| 362 | if(modis%Cloud_Fraction_Low_Mean(ip).eq.R_UNDEF)then |
|---|
| 363 | modis%Cloud_Fraction_Low_Mean(ip)=missing_val |
|---|
| 364 | endif |
|---|
| 365 | if(modis%Cloud_Fraction_High_Mean(ip).eq.R_UNDEF)then |
|---|
| 366 | modis%Cloud_Fraction_High_Mean(ip)=missing_val |
|---|
| 367 | endif |
|---|
| 368 | if(modis%Cloud_Fraction_Mid_Mean(ip).eq.R_UNDEF)then |
|---|
| 369 | modis%Cloud_Fraction_Mid_Mean(ip)=missing_val |
|---|
| 370 | endif |
|---|
| 371 | if(modis%Cloud_Fraction_Total_Mean(ip).eq.R_UNDEF)then |
|---|
| 372 | modis%Cloud_Fraction_Total_Mean(ip)=missing_val |
|---|
| 373 | endif |
|---|
| 374 | if(modis%Cloud_Fraction_Water_Mean(ip).eq.R_UNDEF)then |
|---|
| 375 | modis%Cloud_Fraction_Water_Mean(ip)=missing_val |
|---|
| 376 | endif |
|---|
| 377 | if(modis%Cloud_Fraction_Ice_Mean(ip).eq.R_UNDEF)then |
|---|
| 378 | modis%Cloud_Fraction_Ice_Mean(ip)=missing_val |
|---|
| 379 | endif |
|---|
| 380 | if(modis%Optical_Thickness_Total_Mean(ip).eq.R_UNDEF)then |
|---|
| 381 | modis%Optical_Thickness_Total_Mean(ip)=missing_val |
|---|
| 382 | endif |
|---|
| 383 | if(modis%Optical_Thickness_Water_Mean(ip).eq.R_UNDEF)then |
|---|
| 384 | modis%Optical_Thickness_Water_Mean(ip)=missing_val |
|---|
| 385 | endif |
|---|
| 386 | if(modis%Optical_Thickness_Ice_Mean(ip).eq.R_UNDEF)then |
|---|
| 387 | modis%Optical_Thickness_Ice_Mean(ip)=missing_val |
|---|
| 388 | endif |
|---|
| 389 | if(modis%Cloud_Particle_Size_Water_Mean(ip).eq.R_UNDEF)then |
|---|
| 390 | modis%Cloud_Particle_Size_Water_Mean(ip)=missing_val |
|---|
| 391 | endif |
|---|
| 392 | if(modis%Cloud_Particle_Size_Ice_Mean(ip).eq.R_UNDEF)then |
|---|
| 393 | modis%Cloud_Particle_Size_Ice_Mean(ip)=missing_val |
|---|
| 394 | endif |
|---|
| 395 | if(modis%Cloud_Top_Pressure_Total_Mean(ip).eq.R_UNDEF)then |
|---|
| 396 | modis%Cloud_Top_Pressure_Total_Mean(ip)=missing_val |
|---|
| 397 | endif |
|---|
| 398 | if(modis%Liquid_Water_Path_Mean(ip).eq.R_UNDEF)then |
|---|
| 399 | modis%Liquid_Water_Path_Mean(ip)=missing_val |
|---|
| 400 | endif |
|---|
| 401 | if(modis%Ice_Water_Path_Mean(ip).eq.R_UNDEF)then |
|---|
| 402 | modis%Ice_Water_Path_Mean(ip)=missing_val |
|---|
| 403 | endif |
|---|
| 404 | |
|---|
| 405 | enddo |
|---|
| 406 | |
|---|
| 407 | where(modis%Optical_Thickness_Total_LogMean == R_UNDEF) & |
|---|
| 408 | modis%Optical_Thickness_Total_LogMean = missing_val |
|---|
| 409 | |
|---|
| 410 | |
|---|
| 411 | where(modis%Optical_Thickness_Water_LogMean == R_UNDEF) & |
|---|
| 412 | modis%Optical_Thickness_Water_LogMean = missing_val |
|---|
| 413 | |
|---|
| 414 | where(modis%Optical_Thickness_Ice_LogMean == R_UNDEF) & |
|---|
| 415 | modis%Optical_Thickness_Ice_LogMean = missing_val |
|---|
| 416 | |
|---|
| 417 | CALL histwrite2d_cosp(o_cllmodis,modis%Cloud_Fraction_Low_Mean) |
|---|
| 418 | CALL histwrite2d_cosp(o_clhmodis,modis%Cloud_Fraction_High_Mean) |
|---|
| 419 | CALL histwrite2d_cosp(o_clmmodis,modis%Cloud_Fraction_Mid_Mean) |
|---|
| 420 | CALL histwrite2d_cosp(o_cltmodis,modis%Cloud_Fraction_Total_Mean) |
|---|
| 421 | CALL histwrite2d_cosp(o_clwmodis,modis%Cloud_Fraction_Water_Mean) |
|---|
| 422 | CALL histwrite2d_cosp(o_climodis,modis%Cloud_Fraction_Ice_Mean) |
|---|
| 423 | CALL histwrite2d_cosp(o_tautmodis,modis%Optical_Thickness_Total_Mean) |
|---|
| 424 | CALL histwrite2d_cosp(o_tauwmodis,modis%Optical_Thickness_Water_Mean) |
|---|
| 425 | CALL histwrite2d_cosp(o_tauimodis,modis%Optical_Thickness_Ice_Mean) |
|---|
| 426 | CALL histwrite2d_cosp(o_tautlogmodis,modis%Optical_Thickness_Total_LogMean) |
|---|
| 427 | CALL histwrite2d_cosp(o_tauwlogmodis,modis%Optical_Thickness_Water_LogMean) |
|---|
| 428 | CALL histwrite2d_cosp(o_tauilogmodis,modis%Optical_Thickness_Ice_LogMean) |
|---|
| 429 | CALL histwrite2d_cosp(o_reffclwmodis,modis%Cloud_Particle_Size_Water_Mean) |
|---|
| 430 | CALL histwrite2d_cosp(o_reffclimodis,modis%Cloud_Particle_Size_Ice_Mean) |
|---|
| 431 | CALL histwrite2d_cosp(o_pctmodis,modis%Cloud_Top_Pressure_Total_Mean) |
|---|
| 432 | CALL histwrite2d_cosp(o_lwpmodis,modis%Liquid_Water_Path_Mean) |
|---|
| 433 | CALL histwrite2d_cosp(o_iwpmodis,modis%Ice_Water_Path_Mean) |
|---|
| 434 | |
|---|
| 435 | do ip=1,Npoints |
|---|
| 436 | do ii=1,7 |
|---|
| 437 | do k=1,7 |
|---|
| 438 | if(modis%Optical_Thickness_vs_Cloud_Top_Pressure(ip,ii,k).eq.R_UNDEF)then |
|---|
| 439 | modis%Optical_Thickness_vs_Cloud_Top_Pressure(ip,ii,k)=missing_val |
|---|
| 440 | endif |
|---|
| 441 | enddo |
|---|
| 442 | enddo |
|---|
| 443 | enddo |
|---|
| 444 | |
|---|
| 445 | #ifdef CPP_XIOS |
|---|
| 446 | CALL histwrite4d_cosp(o_clmodis,modis%Optical_Thickness_vs_Cloud_Top_Pressure) |
|---|
| 447 | #else |
|---|
| 448 | do icl=1,7 |
|---|
| 449 | CALL histwrite3d_cosp(o_clmodis, & |
|---|
| 450 | modis%Optical_Thickness_vs_Cloud_Top_Pressure(:,icl,:),nvertisccp,icl) |
|---|
| 451 | enddo |
|---|
| 452 | #endif |
|---|
| 453 | |
|---|
| 454 | where(modis%Optical_Thickness_vs_ReffIce == R_UNDEF) & |
|---|
| 455 | modis%Optical_Thickness_vs_ReffIce = missing_val |
|---|
| 456 | |
|---|
| 457 | where(modis%Optical_Thickness_vs_ReffLiq == R_UNDEF) & |
|---|
| 458 | modis%Optical_Thickness_vs_ReffLiq = missing_val |
|---|
| 459 | |
|---|
| 460 | #ifdef CPP_XIOS |
|---|
| 461 | ! print*,'dimension de crimodis=',size(modis%Optical_Thickness_vs_ReffIce,2),& |
|---|
| 462 | ! size(modis%Optical_Thickness_vs_ReffIce,3) |
|---|
| 463 | CALL histwrite4d_cosp(o_crimodis,modis%Optical_Thickness_vs_ReffIce) |
|---|
| 464 | CALL histwrite4d_cosp(o_crlmodis,modis%Optical_Thickness_vs_ReffLiq) |
|---|
| 465 | #else |
|---|
| 466 | do icl=1,7 |
|---|
| 467 | CALL histwrite3d_cosp(o_crimodis, & |
|---|
| 468 | modis%Optical_Thickness_vs_ReffIce(:,icl,:),nvertReffIce,icl) |
|---|
| 469 | CALL histwrite3d_cosp(o_crlmodis, & |
|---|
| 470 | modis%Optical_Thickness_vs_ReffLiq(:,icl,:),nvertReffLiq,icl) |
|---|
| 471 | enddo |
|---|
| 472 | #endif |
|---|
| 473 | endif |
|---|
| 474 | |
|---|
| 475 | IF(.NOT.cosp_varsdefined) THEN |
|---|
| 476 | !$OMP MASTER |
|---|
| 477 | #ifndef CPP_IOIPSL_NO_OUTPUT |
|---|
| 478 | DO iff=1,3 |
|---|
| 479 | IF (cosp_outfilekeys(iff)) THEN |
|---|
| 480 | CALL histend(cosp_nidfiles(iff)) |
|---|
| 481 | ENDIF ! cosp_outfilekeys |
|---|
| 482 | ENDDO ! iff |
|---|
| 483 | #endif |
|---|
| 484 | ! Fermeture dans phys_output_write |
|---|
| 485 | !#ifdef CPP_XIOS |
|---|
| 486 | !On finalise l'initialisation: |
|---|
| 487 | !CALL wxios_closedef() |
|---|
| 488 | !#endif |
|---|
| 489 | |
|---|
| 490 | !$OMP END MASTER |
|---|
| 491 | !$OMP BARRIER |
|---|
| 492 | cosp_varsdefined = .TRUE. |
|---|
| 493 | END IF |
|---|
| 494 | |
|---|
| 495 | IF(cosp_varsdefined) THEN |
|---|
| 496 | ! On synchronise les fichiers pour IOIPSL |
|---|
| 497 | #ifndef CPP_IOIPSL_NO_OUTPUT |
|---|
| 498 | !$OMP MASTER |
|---|
| 499 | DO iff=1,3 |
|---|
| 500 | IF (ok_sync .AND. cosp_outfilekeys(iff)) THEN |
|---|
| 501 | CALL histsync(cosp_nidfiles(iff)) |
|---|
| 502 | ENDIF |
|---|
| 503 | END DO |
|---|
| 504 | !$OMP END MASTER |
|---|
| 505 | #endif |
|---|
| 506 | ENDIF !cosp_varsdefined |
|---|
| 507 | |
|---|
| 508 | END SUBROUTINE cosp_output_write |
|---|
| 509 | |
|---|
| 510 | ! ug Routine pour definir itau_iocosp depuis cosp_output_write_mod: |
|---|
| 511 | SUBROUTINE set_itau_iocosp(ito) |
|---|
| 512 | IMPLICIT NONE |
|---|
| 513 | INTEGER, INTENT(IN) :: ito |
|---|
| 514 | itau_iocosp = ito |
|---|
| 515 | END SUBROUTINE |
|---|
| 516 | |
|---|
| 517 | SUBROUTINE histdef2d_cosp (iff,var) |
|---|
| 518 | |
|---|
| 519 | USE ioipsl |
|---|
| 520 | USE dimphy |
|---|
| 521 | use iophy |
|---|
| 522 | USE mod_phys_lmdz_para |
|---|
| 523 | USE mod_grid_phy_lmdz, ONLY: nbp_lon |
|---|
| 524 | USE print_control_mod, ONLY: lunout,prt_level |
|---|
| 525 | #ifdef CPP_XIOS |
|---|
| 526 | USE wxios |
|---|
| 527 | #endif |
|---|
| 528 | |
|---|
| 529 | IMPLICIT NONE |
|---|
| 530 | |
|---|
| 531 | INCLUDE "clesphys.h" |
|---|
| 532 | |
|---|
| 533 | INTEGER :: iff |
|---|
| 534 | TYPE(ctrl_outcosp) :: var |
|---|
| 535 | |
|---|
| 536 | REAL zstophym |
|---|
| 537 | CHARACTER(LEN=20) :: typeecrit |
|---|
| 538 | |
|---|
| 539 | ! ug On récupère le type écrit de la structure: |
|---|
| 540 | ! Assez moche, Ã| refaire si meilleure méthode... |
|---|
| 541 | IF (INDEX(var%cosp_typeecrit(iff), "once") > 0) THEN |
|---|
| 542 | typeecrit = 'once' |
|---|
| 543 | ELSE IF(INDEX(var%cosp_typeecrit(iff), "t_min") > 0) THEN |
|---|
| 544 | typeecrit = 't_min(X)' |
|---|
| 545 | ELSE IF(INDEX(var%cosp_typeecrit(iff), "t_max") > 0) THEN |
|---|
| 546 | typeecrit = 't_max(X)' |
|---|
| 547 | ELSE IF(INDEX(var%cosp_typeecrit(iff), "inst") > 0) THEN |
|---|
| 548 | typeecrit = 'inst(X)' |
|---|
| 549 | ELSE |
|---|
| 550 | typeecrit = cosp_outfiletypes(iff) |
|---|
| 551 | ENDIF |
|---|
| 552 | |
|---|
| 553 | IF (typeecrit=='inst(X)'.OR.typeecrit=='once') THEN |
|---|
| 554 | zstophym=zoutm_cosp(iff) |
|---|
| 555 | ELSE |
|---|
| 556 | zstophym=zdtimemoy_cosp |
|---|
| 557 | ENDIF |
|---|
| 558 | |
|---|
| 559 | #ifdef CPP_XIOS |
|---|
| 560 | IF (.not. ok_all_xml) then |
|---|
| 561 | IF ( var%cles(iff) ) THEN |
|---|
| 562 | if (prt_level >= 10) then |
|---|
| 563 | WRITE(lunout,*)'Appel wxios_add_field_to_file var%name =',var%name |
|---|
| 564 | endif |
|---|
| 565 | CALL wxios_add_field_to_file(var%name, 2, cosp_nidfiles(iff), cosp_outfilenames(iff), & |
|---|
| 566 | var%description, var%unit, 1, typeecrit) |
|---|
| 567 | ENDIF |
|---|
| 568 | ENDIF |
|---|
| 569 | #endif |
|---|
| 570 | |
|---|
| 571 | #ifndef CPP_IOIPSL_NO_OUTPUT |
|---|
| 572 | IF ( var%cles(iff) ) THEN |
|---|
| 573 | CALL histdef (cosp_nidfiles(iff), var%name, var%description, var%unit, & |
|---|
| 574 | nbp_lon,jj_nb,nhoricosp(iff), 1,1,1, -99, 32, & |
|---|
| 575 | typeecrit, zstophym,zoutm_cosp(iff)) |
|---|
| 576 | ENDIF |
|---|
| 577 | #endif |
|---|
| 578 | |
|---|
| 579 | END SUBROUTINE histdef2d_cosp |
|---|
| 580 | |
|---|
| 581 | SUBROUTINE histdef3d_cosp (iff,var,nvertsave,ncols) |
|---|
| 582 | USE ioipsl |
|---|
| 583 | USE dimphy |
|---|
| 584 | use iophy |
|---|
| 585 | USE mod_phys_lmdz_para |
|---|
| 586 | USE mod_grid_phy_lmdz, ONLY: nbp_lon |
|---|
| 587 | USE print_control_mod, ONLY: lunout,prt_level |
|---|
| 588 | |
|---|
| 589 | #ifdef CPP_XIOS |
|---|
| 590 | USE wxios |
|---|
| 591 | #endif |
|---|
| 592 | |
|---|
| 593 | |
|---|
| 594 | IMPLICIT NONE |
|---|
| 595 | |
|---|
| 596 | INCLUDE "clesphys.h" |
|---|
| 597 | |
|---|
| 598 | INTEGER :: iff, klevs |
|---|
| 599 | INTEGER, INTENT(IN), OPTIONAL :: ncols ! ug RUSTINE POUR LES variables 4D |
|---|
| 600 | INTEGER, INTENT(IN) :: nvertsave |
|---|
| 601 | TYPE(ctrl_outcosp) :: var |
|---|
| 602 | |
|---|
| 603 | REAL zstophym |
|---|
| 604 | CHARACTER(LEN=20) :: typeecrit, nomi |
|---|
| 605 | CHARACTER(LEN=20) :: nom |
|---|
| 606 | character(len=2) :: str2 |
|---|
| 607 | CHARACTER(len=20) :: nam_axvert |
|---|
| 608 | |
|---|
| 609 | ! Axe vertical |
|---|
| 610 | IF (nvertsave.eq.nvertp(iff)) THEN |
|---|
| 611 | klevs=PARASOL_NREFL |
|---|
| 612 | nam_axvert="sza" |
|---|
| 613 | ELSE IF (nvertsave.eq.nvertisccp(iff)) THEN |
|---|
| 614 | klevs=7 |
|---|
| 615 | nam_axvert="pressure2" |
|---|
| 616 | ELSE IF (nvertsave.eq.nvertcol(iff)) THEN |
|---|
| 617 | klevs=Ncolout |
|---|
| 618 | nam_axvert="column" |
|---|
| 619 | ELSE IF (nvertsave.eq.nverttemp(iff)) THEN |
|---|
| 620 | klevs=LIDAR_NTEMP |
|---|
| 621 | nam_axvert="temp" |
|---|
| 622 | ELSE IF (nvertsave.eq.nvertmisr(iff)) THEN |
|---|
| 623 | klevs=MISR_N_CTH |
|---|
| 624 | nam_axvert="cth16" |
|---|
| 625 | ELSE IF (nvertsave.eq.nvertReffIce(iff)) THEN |
|---|
| 626 | klevs= numMODISReffIceBins |
|---|
| 627 | nam_axvert="ReffIce" |
|---|
| 628 | ELSE IF (nvertsave.eq.nvertReffLiq(iff)) THEN |
|---|
| 629 | klevs= numMODISReffLiqBins |
|---|
| 630 | nam_axvert="ReffLiq" |
|---|
| 631 | ELSE |
|---|
| 632 | klevs=Nlevout |
|---|
| 633 | nam_axvert="presnivs" |
|---|
| 634 | ENDIF |
|---|
| 635 | |
|---|
| 636 | ! ug RUSTINE POUR LES Champs 4D |
|---|
| 637 | IF (PRESENT(ncols)) THEN |
|---|
| 638 | write(str2,'(i2.2)')ncols |
|---|
| 639 | nomi=var%name |
|---|
| 640 | nom="c"//str2//"_"//nomi |
|---|
| 641 | ELSE |
|---|
| 642 | nom=var%name |
|---|
| 643 | END IF |
|---|
| 644 | |
|---|
| 645 | ! ug On récupère le type écrit de la structure: |
|---|
| 646 | ! Assez moche, Ã| refaire si meilleure méthode... |
|---|
| 647 | IF (INDEX(var%cosp_typeecrit(iff), "once") > 0) THEN |
|---|
| 648 | typeecrit = 'once' |
|---|
| 649 | ELSE IF(INDEX(var%cosp_typeecrit(iff), "t_min") > 0) THEN |
|---|
| 650 | typeecrit = 't_min(X)' |
|---|
| 651 | ELSE IF(INDEX(var%cosp_typeecrit(iff), "t_max") > 0) THEN |
|---|
| 652 | typeecrit = 't_max(X)' |
|---|
| 653 | ELSE IF(INDEX(var%cosp_typeecrit(iff), "inst") > 0) THEN |
|---|
| 654 | typeecrit = 'inst(X)' |
|---|
| 655 | ELSE |
|---|
| 656 | typeecrit = cosp_outfiletypes(iff) |
|---|
| 657 | ENDIF |
|---|
| 658 | |
|---|
| 659 | IF (typeecrit=='inst(X)'.OR.typeecrit=='once') THEN |
|---|
| 660 | zstophym=zoutm_cosp(iff) |
|---|
| 661 | ELSE |
|---|
| 662 | zstophym=zdtimemoy_cosp |
|---|
| 663 | ENDIF |
|---|
| 664 | |
|---|
| 665 | #ifdef CPP_XIOS |
|---|
| 666 | IF (.not. ok_all_xml) then |
|---|
| 667 | IF ( var%cles(iff) ) THEN |
|---|
| 668 | if (prt_level >= 10) then |
|---|
| 669 | WRITE(lunout,*)'Appel wxios_add_field_to_file 3d nom variable nam_axvert = ',nom, nam_axvert |
|---|
| 670 | endif |
|---|
| 671 | CALL wxios_add_field_to_file(nom, 3, cosp_nidfiles(iff), cosp_outfilenames(iff), & |
|---|
| 672 | var%description, var%unit, 1, typeecrit, nam_axvert) |
|---|
| 673 | ENDIF |
|---|
| 674 | ENDIF |
|---|
| 675 | #endif |
|---|
| 676 | |
|---|
| 677 | #ifndef CPP_IOIPSL_NO_OUTPUT |
|---|
| 678 | IF ( var%cles(iff) ) THEN |
|---|
| 679 | CALL histdef (cosp_nidfiles(iff), nom, var%description, var%unit, & |
|---|
| 680 | nbp_lon, jj_nb, nhoricosp(iff), klevs, 1, & |
|---|
| 681 | klevs, nvertsave, 32, typeecrit, & |
|---|
| 682 | zstophym, zoutm_cosp(iff)) |
|---|
| 683 | ENDIF |
|---|
| 684 | #endif |
|---|
| 685 | |
|---|
| 686 | END SUBROUTINE histdef3d_cosp |
|---|
| 687 | |
|---|
| 688 | SUBROUTINE histwrite2d_cosp(var,field) |
|---|
| 689 | USE dimphy |
|---|
| 690 | USE mod_phys_lmdz_para |
|---|
| 691 | USE ioipsl |
|---|
| 692 | use iophy |
|---|
| 693 | USE mod_grid_phy_lmdz, ONLY: nbp_lon |
|---|
| 694 | USE print_control_mod, ONLY: lunout,prt_level |
|---|
| 695 | |
|---|
| 696 | #ifdef CPP_XIOS |
|---|
| 697 | USE xios, only: xios_send_field |
|---|
| 698 | #endif |
|---|
| 699 | |
|---|
| 700 | IMPLICIT NONE |
|---|
| 701 | INCLUDE 'clesphys.h' |
|---|
| 702 | |
|---|
| 703 | TYPE(ctrl_outcosp), INTENT(IN) :: var |
|---|
| 704 | REAL, DIMENSION(:), INTENT(IN) :: field |
|---|
| 705 | |
|---|
| 706 | INTEGER :: iff |
|---|
| 707 | |
|---|
| 708 | REAL,DIMENSION(klon_mpi) :: buffer_omp |
|---|
| 709 | INTEGER, allocatable, DIMENSION(:) :: index2d |
|---|
| 710 | REAL :: Field2d(nbp_lon,jj_nb) |
|---|
| 711 | CHARACTER(LEN=20) :: nomi, nom |
|---|
| 712 | character(len=2) :: str2 |
|---|
| 713 | LOGICAL, SAVE :: firstx |
|---|
| 714 | !$OMP THREADPRIVATE(firstx) |
|---|
| 715 | |
|---|
| 716 | IF (prt_level >= 9) WRITE(lunout,*)'Begin histrwrite2d ',var%name |
|---|
| 717 | |
|---|
| 718 | ! On regarde si on est dans la phase de définition ou d'écriture: |
|---|
| 719 | IF(.NOT.cosp_varsdefined) THEN |
|---|
| 720 | !$OMP MASTER |
|---|
| 721 | !Si phase de définition.... on définit |
|---|
| 722 | CALL conf_cospoutputs(var%name,var%cles) |
|---|
| 723 | DO iff=1, 3 |
|---|
| 724 | IF (cosp_outfilekeys(iff)) THEN |
|---|
| 725 | CALL histdef2d_cosp(iff, var) |
|---|
| 726 | ENDIF |
|---|
| 727 | ENDDO |
|---|
| 728 | !$OMP END MASTER |
|---|
| 729 | ELSE |
|---|
| 730 | !Et sinon on.... écrit |
|---|
| 731 | IF (SIZE(field)/=klon) & |
|---|
| 732 | CALL abort_physic('iophy::histwrite2d_cosp','Field first DIMENSION not equal to klon',1) |
|---|
| 733 | |
|---|
| 734 | CALL Gather_omp(field,buffer_omp) |
|---|
| 735 | !$OMP MASTER |
|---|
| 736 | CALL grid1Dto2D_mpi(buffer_omp,Field2d) |
|---|
| 737 | |
|---|
| 738 | ! La boucle sur les fichiers: |
|---|
| 739 | firstx=.true. |
|---|
| 740 | DO iff=1, 3 |
|---|
| 741 | IF (var%cles(iff) .AND. cosp_outfilekeys(iff)) THEN |
|---|
| 742 | ALLOCATE(index2d(nbp_lon*jj_nb)) |
|---|
| 743 | #ifndef CPP_IOIPSL_NO_OUTPUT |
|---|
| 744 | CALL histwrite(cosp_nidfiles(iff),var%name,itau_iocosp,Field2d,nbp_lon*jj_nb,index2d) |
|---|
| 745 | #endif |
|---|
| 746 | deallocate(index2d) |
|---|
| 747 | #ifdef CPP_XIOS |
|---|
| 748 | IF (.not. ok_all_xml) then |
|---|
| 749 | if (firstx) then |
|---|
| 750 | if (prt_level >= 10) then |
|---|
| 751 | WRITE(lunout,*)'xios_send_field variable ',var%name |
|---|
| 752 | endif |
|---|
| 753 | CALL xios_send_field(var%name, Field2d) |
|---|
| 754 | firstx=.false. |
|---|
| 755 | endif |
|---|
| 756 | ENDIF |
|---|
| 757 | #endif |
|---|
| 758 | ENDIF |
|---|
| 759 | ENDDO |
|---|
| 760 | |
|---|
| 761 | #ifdef CPP_XIOS |
|---|
| 762 | IF (ok_all_xml) THEN |
|---|
| 763 | if (prt_level >= 1) then |
|---|
| 764 | WRITE(lunout,*)'xios_send_field variable ',var%name |
|---|
| 765 | endif |
|---|
| 766 | CALL xios_send_field(var%name, Field2d) |
|---|
| 767 | ENDIF |
|---|
| 768 | #endif |
|---|
| 769 | |
|---|
| 770 | !$OMP END MASTER |
|---|
| 771 | ENDIF ! vars_defined |
|---|
| 772 | IF (prt_level >= 9) WRITE(lunout,*)'End histrwrite2d_cosp ',var%name |
|---|
| 773 | END SUBROUTINE histwrite2d_cosp |
|---|
| 774 | |
|---|
| 775 | ! ug NOUVELLE VERSION DES WRITE AVEC LA BOUCLE DO RENTREE |
|---|
| 776 | ! AI sept 2013 |
|---|
| 777 | SUBROUTINE histwrite3d_cosp(var, field, nverts, ncols) |
|---|
| 778 | USE dimphy |
|---|
| 779 | USE mod_phys_lmdz_para |
|---|
| 780 | USE ioipsl |
|---|
| 781 | use iophy |
|---|
| 782 | USE mod_grid_phy_lmdz, ONLY: nbp_lon |
|---|
| 783 | USE print_control_mod, ONLY: lunout,prt_level |
|---|
| 784 | |
|---|
| 785 | #ifdef CPP_XIOS |
|---|
| 786 | USE xios, only: xios_send_field |
|---|
| 787 | #endif |
|---|
| 788 | |
|---|
| 789 | |
|---|
| 790 | IMPLICIT NONE |
|---|
| 791 | INCLUDE 'clesphys.h' |
|---|
| 792 | |
|---|
| 793 | TYPE(ctrl_outcosp), INTENT(IN) :: var |
|---|
| 794 | REAL, DIMENSION(:,:), INTENT(IN) :: field ! --> field(klon,:) |
|---|
| 795 | INTEGER, INTENT(IN), OPTIONAL :: ncols ! ug RUSTINE POUR LES Champs 4D..... |
|---|
| 796 | INTEGER, DIMENSION(3), INTENT(IN) :: nverts |
|---|
| 797 | |
|---|
| 798 | INTEGER :: iff, k |
|---|
| 799 | |
|---|
| 800 | REAL,DIMENSION(klon_mpi,SIZE(field,2)) :: buffer_omp |
|---|
| 801 | REAL :: Field3d(nbp_lon,jj_nb,SIZE(field,2)) |
|---|
| 802 | INTEGER :: ip, n, nlev |
|---|
| 803 | INTEGER, ALLOCATABLE, DIMENSION(:) :: index3d |
|---|
| 804 | CHARACTER(LEN=20) :: nomi, nom |
|---|
| 805 | character(len=2) :: str2 |
|---|
| 806 | LOGICAL, SAVE :: firstx |
|---|
| 807 | !$OMP THREADPRIVATE(firstx) |
|---|
| 808 | |
|---|
| 809 | IF (prt_level >= 9) write(lunout,*)'Begin histrwrite3d ',var%name |
|---|
| 810 | |
|---|
| 811 | ! ug RUSTINE POUR LES STD LEVS..... |
|---|
| 812 | IF (PRESENT(ncols)) THEN |
|---|
| 813 | write(str2,'(i2.2)')ncols |
|---|
| 814 | nomi=var%name |
|---|
| 815 | nom="c"//str2//"_"//nomi |
|---|
| 816 | ELSE |
|---|
| 817 | nom=var%name |
|---|
| 818 | END IF |
|---|
| 819 | ! On regarde si on est dans la phase de définition ou d'écriture: |
|---|
| 820 | IF(.NOT.cosp_varsdefined) THEN |
|---|
| 821 | !Si phase de définition.... on définit |
|---|
| 822 | !$OMP MASTER |
|---|
| 823 | CALL conf_cospoutputs(var%name,var%cles) |
|---|
| 824 | DO iff=1, 3 |
|---|
| 825 | IF (cosp_outfilekeys(iff)) THEN |
|---|
| 826 | CALL histdef3d_cosp(iff, var, nverts(iff), ncols) |
|---|
| 827 | ENDIF |
|---|
| 828 | ENDDO |
|---|
| 829 | !$OMP END MASTER |
|---|
| 830 | ELSE |
|---|
| 831 | !Et sinon on.... écrit |
|---|
| 832 | IF (SIZE(field,1)/=klon) & |
|---|
| 833 | CALL abort_physic('iophy::histwrite3d','Field first DIMENSION not equal to klon',1) |
|---|
| 834 | nlev=SIZE(field,2) |
|---|
| 835 | |
|---|
| 836 | |
|---|
| 837 | CALL Gather_omp(field,buffer_omp) |
|---|
| 838 | !$OMP MASTER |
|---|
| 839 | CALL grid1Dto2D_mpi(buffer_omp,field3d) |
|---|
| 840 | |
|---|
| 841 | ! BOUCLE SUR LES FICHIERS |
|---|
| 842 | firstx=.true. |
|---|
| 843 | DO iff=1, 3 |
|---|
| 844 | IF (var%cles(iff) .AND. cosp_outfilekeys(iff)) THEN |
|---|
| 845 | ALLOCATE(index3d(nbp_lon*jj_nb*nlev)) |
|---|
| 846 | #ifndef CPP_IOIPSL_NO_OUTPUT |
|---|
| 847 | CALL histwrite(cosp_nidfiles(iff),nom,itau_iocosp,Field3d,nbp_lon*jj_nb*nlev,index3d) |
|---|
| 848 | #endif |
|---|
| 849 | |
|---|
| 850 | #ifdef CPP_XIOS |
|---|
| 851 | IF (.not. ok_all_xml) then |
|---|
| 852 | IF (firstx) THEN |
|---|
| 853 | CALL xios_send_field(nom, Field3d(:,:,1:nlev)) |
|---|
| 854 | IF (prt_level >= 9) WRITE(lunout,*)'xios_send_field ',var%name |
|---|
| 855 | firstx=.FALSE. |
|---|
| 856 | ENDIF |
|---|
| 857 | ENDIF |
|---|
| 858 | #endif |
|---|
| 859 | deallocate(index3d) |
|---|
| 860 | ENDIF |
|---|
| 861 | ENDDO |
|---|
| 862 | #ifdef CPP_XIOS |
|---|
| 863 | IF (ok_all_xml) THEN |
|---|
| 864 | CALL xios_send_field(nom, Field3d(:,:,1:nlev)) |
|---|
| 865 | IF (prt_level >= 1) WRITE(lunout,*)'xios_send_field ',var%name |
|---|
| 866 | ENDIF |
|---|
| 867 | #endif |
|---|
| 868 | |
|---|
| 869 | !$OMP END MASTER |
|---|
| 870 | ENDIF ! vars_defined |
|---|
| 871 | IF (prt_level >= 9) write(lunout,*)'End histrwrite3d_cosp ',nom |
|---|
| 872 | END SUBROUTINE histwrite3d_cosp |
|---|
| 873 | |
|---|
| 874 | ! ug NOUVELLE VERSION DES WRITE AVEC LA BOUCLE DO RENTREE |
|---|
| 875 | ! AI sept 2013 |
|---|
| 876 | SUBROUTINE histwrite4d_cosp(var, field) |
|---|
| 877 | USE dimphy |
|---|
| 878 | USE mod_phys_lmdz_para |
|---|
| 879 | USE ioipsl |
|---|
| 880 | use iophy |
|---|
| 881 | USE mod_grid_phy_lmdz, ONLY: nbp_lon |
|---|
| 882 | USE print_control_mod, ONLY: lunout,prt_level |
|---|
| 883 | |
|---|
| 884 | #ifdef CPP_XIOS |
|---|
| 885 | USE xios, only: xios_send_field |
|---|
| 886 | #endif |
|---|
| 887 | |
|---|
| 888 | |
|---|
| 889 | IMPLICIT NONE |
|---|
| 890 | INCLUDE 'clesphys.h' |
|---|
| 891 | |
|---|
| 892 | TYPE(ctrl_outcosp), INTENT(IN) :: var |
|---|
| 893 | REAL, DIMENSION(:,:,:), INTENT(IN) :: field ! --> field(klon,:) |
|---|
| 894 | |
|---|
| 895 | INTEGER :: iff, k |
|---|
| 896 | |
|---|
| 897 | REAL,DIMENSION(klon_mpi,SIZE(field,2),SIZE(field,3)) :: buffer_omp |
|---|
| 898 | REAL :: field4d(nbp_lon,jj_nb,SIZE(field,2),SIZE(field,3)) |
|---|
| 899 | INTEGER :: ip, n, nlev, nlev2 |
|---|
| 900 | INTEGER, ALLOCATABLE, DIMENSION(:) :: index4d |
|---|
| 901 | CHARACTER(LEN=20) :: nomi, nom |
|---|
| 902 | |
|---|
| 903 | IF (prt_level >= 9) write(lunout,*)'Begin histrwrite4d ',var%name |
|---|
| 904 | |
|---|
| 905 | IF(cosp_varsdefined) THEN |
|---|
| 906 | !Et sinon on.... écrit |
|---|
| 907 | IF (SIZE(field,1)/=klon) & |
|---|
| 908 | CALL abort_physic('iophy::histwrite3d','Field first DIMENSION not equal to klon',1) |
|---|
| 909 | |
|---|
| 910 | nlev=SIZE(field,2) |
|---|
| 911 | nlev2=SIZE(field,3) |
|---|
| 912 | CALL Gather_omp(field,buffer_omp) |
|---|
| 913 | !$OMP MASTER |
|---|
| 914 | CALL grid1Dto2D_mpi(buffer_omp,field4d) |
|---|
| 915 | |
|---|
| 916 | #ifdef CPP_XIOS |
|---|
| 917 | IF (ok_all_xml) THEN |
|---|
| 918 | CALL xios_send_field(var%name, Field4d(:,:,1:nlev,1:nlev2)) |
|---|
| 919 | IF (prt_level >= 1) WRITE(lunout,*)'xios_send_field ',var%name |
|---|
| 920 | ENDIF |
|---|
| 921 | #endif |
|---|
| 922 | |
|---|
| 923 | !$OMP END MASTER |
|---|
| 924 | ENDIF ! vars_defined |
|---|
| 925 | IF (prt_level >= 9) write(lunout,*)'End histrwrite4d_cosp ',nom |
|---|
| 926 | END SUBROUTINE histwrite4d_cosp |
|---|
| 927 | |
|---|
| 928 | SUBROUTINE conf_cospoutputs(nam_var,cles_var) |
|---|
| 929 | !!! Lecture des noms et cles de sortie des variables dans config.def |
|---|
| 930 | ! en utilisant les routines getin de IOIPSL |
|---|
| 931 | use ioipsl |
|---|
| 932 | USE print_control_mod, ONLY: lunout,prt_level |
|---|
| 933 | |
|---|
| 934 | IMPLICIT NONE |
|---|
| 935 | |
|---|
| 936 | CHARACTER(LEN=20) :: nam_var, nnam_var |
|---|
| 937 | LOGICAL, DIMENSION(3) :: cles_var |
|---|
| 938 | |
|---|
| 939 | ! Lecture dans config.def ou output.def de cles_var et name_var |
|---|
| 940 | CALL getin('cles_'//nam_var,cles_var) |
|---|
| 941 | CALL getin('name_'//nam_var,nam_var) |
|---|
| 942 | IF(prt_level>10) WRITE(lunout,*)'nam_var cles_var ',nam_var,cles_var(:) |
|---|
| 943 | |
|---|
| 944 | END SUBROUTINE conf_cospoutputs |
|---|
| 945 | |
|---|
| 946 | END MODULE cosp_output_write_mod |
|---|