Changeset 3723


Ignore:
Timestamp:
Jun 18, 2020, 10:44:07 AM (4 years ago)
Author:
idelkadi
Message:

Debugging COSP v2 for simulators Calipso, Parasol, Cloudsat

Location:
LMDZ6/trunk/libf/phylmd/cospv2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/trunk/libf/phylmd/cospv2/cosp_config.F90

    r3491 r3723  
    6363         N_HYDRO = 9               ! Number of hydrometeor classes used by quickbeam radar simulator.
    6464
     65    ! Mode debug ou prod (AI 0302018)
     66    logical :: ok_debug_cosp = .true.
    6567    ! #################################################################################### 
    6668    ! Joint histogram bin-boundaries
  • LMDZ6/trunk/libf/phylmd/cospv2/cosp_utils.F90

    r3491 r3723  
    5656    integer :: i,j,k
    5757    real(wp) :: sigma,one_over_xip1,xi,rho0,rho,lambda_x,gamma_4_3_2,delta
     58
     59    real(wp) :: seuil
     60
     61    if (ok_debug_cosp) then
     62       seuil=1.e-15
     63    else
     64       seuil=0.0
     65    endif
     66
     67
    5868   
    5969    mxratio = 0.0
     
    7585                        mxratio(i,j,k)=mxratio(i,j,k)/rho
    7686                        ! Compute effective radius
    77                         if ((reff(i,j,k) <= 0._wp).and.(flux(i,k) /= 0._wp)) then
     87!                        if ((reff(i,j,k) <= 0._wp).and.(flux(i,k) /= 0._wp)) then
     88                         if ((reff(i,j,k) <= 0._wp).and.(flux(i,k) > seuil)) then
    7889                           lambda_x = (a_x*c_x*((rho0/rho)**g_x)*n_ax*gamma1/flux(i,k))**(1._wp/delta)
    7990                           reff(i,j,k) = gamma_4_3_2/lambda_x
  • LMDZ6/trunk/libf/phylmd/cospv2/lmdz_cosp_interface.F90

    r3654 r3723  
    7474
    7575!!! Modules faisant partie du code source de COSPv2
    76   use cosp_kinds,                 only: wp                         
    77   use MOD_COSP_CONFIG,                    only: N_HYDRO,RTTOV_MAX_CHANNELS, &
    78                                                 niv_sorties, vgrid_z_in
    79   use mod_quickbeam_optics,               only: size_distribution,hydro_class_init, &
    80                                                 quickbeam_optics_init
    81   use quickbeam,                         only: radar_cfg
    82   use mod_cosp,                          only: cosp_init,cosp_optical_inputs, &
    83                                                 cosp_column_inputs,cosp_outputs, &
    84                                                 cosp_simulator
     76  use cosp_kinds,  only: wp                         
     77  use MOD_COSP_CONFIG,       only: N_HYDRO,RTTOV_MAX_CHANNELS, &
     78                                    niv_sorties, vgrid_z_in
     79  use mod_quickbeam_optics,  only: size_distribution,hydro_class_init, &
     80                                   quickbeam_optics_init
     81  use quickbeam,            only: radar_cfg
     82  use mod_cosp,            only: cosp_init,cosp_optical_inputs, &
     83                                  cosp_column_inputs,cosp_outputs, &
     84                                  cosp_simulator
    8585
    8686
     
    198198
    199199! Parametres qui sont lus a partir du fichier "cosp_input_nl.txt"
    200    namelist/COSP_INPUT/overlap, isccp_topheight, isccp_topheight_direction,       &
    201               npoints_it, ncolumns, use_vgrid_in, csat_vgrid_in,                  &
    202               cloudsat_radar_freq, surface_radar, use_mie_tables,                 &
    203               cloudsat_use_gas_abs, cloudsat_do_ray, melt_lay, cloudsat_k2,       &
    204               cloudsat_micro_scheme, lidar_ice_type, use_precipitation_fluxes,    &
     200   namelist/COSP_INPUT/overlap, isccp_topheight, isccp_topheight_direction,  &
     201              npoints_it, ncolumns, use_vgrid_in, csat_vgrid_in,  &
     202              cloudsat_radar_freq, surface_radar, use_mie_tables,  &
     203              cloudsat_use_gas_abs, cloudsat_do_ray, melt_lay, cloudsat_k2, &
     204              cloudsat_micro_scheme, lidar_ice_type, use_precipitation_fluxes,   &
    205205              rttov_platform, rttov_satellite, rttov_Instrument, rttov_Nchannels, &
    206206              rttov_Channels, rttov_Surfem, rttov_ZenAng, co2, ch4, n2o, co
     
    215215!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    216216
    217  print*,'Entree lmdz_cosp_interface' !phys_cosp2'
    218  if (debut_cosp) then
     217print*,'Entree lmdz_cosp_interface' !phys_cosp2'
     218if (debut_cosp) then
    219219  NPoints=Nptslmdz
    220220  Nlevels=Nlevlmdz
     
    261261    print*,'ok read  cosp_input_nl'
    262262
    263 
    264 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    265 !
    266 ! 2) Initialisation de COSPv2
    267 !
    268 ! Il y a 2 options possibles pour ecrire les sorties : XIOS ou sorties standard
    269 !
    270 ! Si le modele a ete compile AVEC l'option xios, le programme passe par les
    271 ! bouts de code delimites par "#ifdef CPP_XIOS" et "#else". Dans ce cas,
    272 ! l'initialisation de COSP se fait au deuxieme appel de cette interface.
    273 !
    274 ! Si le modele a ete compile SANS l'option xios, le programme passe par les
    275 ! bouts de code delimites par "#else" et "#endif". Dans ce cas,
    276 ! l'initialisation de COSP se fait au premier appel de cette interface.
    277 !
    278 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    279 
    280263! Clefs Outputs initialisation
    281264#ifdef CPP_XIOS
     
    286269
    287270  print*,' Cles des differents simulateurs cosp a itap :',itap
    288 print*,'cfg%Lcloudsat, cfg%Lcalipso, cfg%LgrLidar532, cfg%Latlid, cfg%Lparasol, &
     271  print*,'cfg%Lcloudsat, cfg%Lcalipso, cfg%LgrLidar532, cfg%Latlid, cfg%Lparasol, &
    289272        cfg%Lisccp, cfg%Lmisr, cfg%Lmodis, cfg%Lrttov', &
    290273        cfg%Lcloudsat, cfg%Lcalipso, cfg%LgrLidar532, cfg%Latlid, cfg%Lparasol, &
    291         cfg%Lisccp, cfg%Lmisr, cfg%Lmodis, cfg%Lrttov
     274        cfg%Lisccp, cfg%Lmisr, cfg%Lmodis, cfg%Lrttov
    292275
    293276    if (overlaplmdz.ne.overlap) then
     
    309292    call quickbeam_optics_init()
    310293
    311  print*,' just before call COSP_INIT, cosp_init_flag =', cosp_init_flag
     294  print*,' just before call COSP_INIT, cosp_init_flag =', cosp_init_flag
    312295  call COSP_INIT(cfg%Lisccp, cfg%Lmodis, cfg%Lmisr, cfg%Lcloudsat, cfg%Lcalipso, &
    313                  cfg%LgrLidar532, cfg%Latlid, cfg%Lparasol, cfg%Lrttov,          &
    314                  cloudsat_radar_freq, cloudsat_k2, cloudsat_use_gas_abs,         &
    315                  cloudsat_do_ray, isccp_topheight, isccp_topheight_direction,    &
    316                 surface_radar, rcfg_cloudsat, use_vgrid_in, csat_vgrid_in,      &
    317                  niv_sorties, Nlevels, cloudsat_micro_scheme)
    318 cosp_init_flag = 1
     296        cfg%LgrLidar532, cfg%Latlid, cfg%Lparasol, cfg%Lrttov,          &
     297        cloudsat_radar_freq, cloudsat_k2, cloudsat_use_gas_abs,         &
     298        cloudsat_do_ray, isccp_topheight, isccp_topheight_direction,    &
     299        surface_radar, rcfg_cloudsat, use_vgrid_in, csat_vgrid_in,      &
     300        niv_sorties, Nlevels, cloudsat_micro_scheme)
     301  cosp_init_flag = 1
    319302 print*,' just after call COSP_INIT, cosp_init_flag =', cosp_init_flag
    320303endif
    321304#endif
    322305
    323    print*,'Fin lecture Namelists, debut_cosp =',debut_cosp
     306  print*,'Fin lecture Namelists, debut_cosp =',debut_cosp
    324307
    325308  endif ! debut_cosp
     
    327310
    328311!!! Ici on modifie les cles logiques pour les outputs selon les champs actives dans les .xml
    329   if ((itap.gt.1).and.(first_write))then
     312  if ((itap.ge.1).and.(first_write))then
    330313#ifdef CPP_XIOS
    331314    call read_xiosfieldactive(cfg)
     
    344327    call quickbeam_optics_init()
    345328
    346  print*,' just before call COSP_INIT, cosp_init_flag =', cosp_init_flag
     329  print*,' just before call COSP_INIT, cosp_init_flag =', cosp_init_flag
    347330  call COSP_INIT(cfg%Lisccp, cfg%Lmodis, cfg%Lmisr, cfg%Lcloudsat, cfg%Lcalipso, &
    348                  cfg%LgrLidar532, cfg%Latlid, cfg%Lparasol, cfg%Lrttov,          &
    349                  cloudsat_radar_freq, cloudsat_k2, cloudsat_use_gas_abs,         &
    350                  cloudsat_do_ray, isccp_topheight, isccp_topheight_direction,    &
    351                 surface_radar, rcfg_cloudsat, use_vgrid_in, csat_vgrid_in,      &
    352                  niv_sorties, Nlevels, cloudsat_micro_scheme)
    353 cosp_init_flag = 1
     331        cfg%LgrLidar532, cfg%Latlid, cfg%Lparasol, cfg%Lrttov,          &
     332        cloudsat_radar_freq, cloudsat_k2, cloudsat_use_gas_abs,         &
     333        cloudsat_do_ray, isccp_topheight, isccp_topheight_direction,    &
     334        surface_radar, rcfg_cloudsat, use_vgrid_in, csat_vgrid_in,      &
     335        niv_sorties, Nlevels, cloudsat_micro_scheme)
     336  cosp_init_flag = 1
    354337 print*,' just after call COSP_INIT, cosp_init_flag =', cosp_init_flag
    355338endif ! cosp_init_flag
     
    573556       print *, 'Calling write output'
    574557        call lmdz_cosp_output_write(Nlevlmdz, Npoints, Ncolumns, itap, dtime, freq_COSP, &
    575                                     missing_val, cfg, niv_sorties, cospOUT)
     558                                    missing_val, cfg, niv_sorties, cospOUT)
    576559
    577560!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  • LMDZ6/trunk/libf/phylmd/cospv2/lmdz_cosp_output_write_mod.F90

    r3491 r3723  
    3030
    3131  SUBROUTINE lmdz_cosp_output_write(Nlevlmdz, Npoints, Ncolumns, itap, dtime, freq_COSP, missing_cosp, &
    32                                     cfg, Nlvgrid, cospOUT)
     32                                    cfg, Nlvgrid, cospOUT)
    3333
    3434
     
    4141  use mod_cosp,   only: cosp_outputs
    4242
    43 #ifdef CPP_XIOS
    4443    USE wxios, only: wxios_closedef
    4544    USE xios, only: xios_update_calendar, xios_field_is_active
    46 #endif
    4745  IMPLICIT NONE 
    4846!!! Variables d'entree
     
    6260! Variables locals intermidiaires pour inverser les axes des champs 4D
    6361! Compatibilite avec sorties CMIP
    64   real, dimension(Npoints,Nlevout,SR_BINS) :: tmp_fi4da_cfadL, tmp_fi4da_cfadLgr, tmp_fi4da_cfadLatlid
    65   real, dimension(Npoints,Nlevout,CLOUDSAT_DBZE_BINS) :: tmp_fi4da_cfadR
     62  real, dimension(Npoints,Nlvgrid,SR_BINS) :: tmp_fi4da_cfadL, tmp_fi4da_cfadLgr, tmp_fi4da_cfadLatlid
     63  real, dimension(Npoints,Nlvgrid,CLOUDSAT_DBZE_BINS) :: tmp_fi4da_cfadR
    6664  real, dimension(Npoints,numMISRHgtBins,7) :: tmp_fi4da_misr
    6765
    68 #ifdef CPP_XIOS
    6966  missing_val=missing_cosp
    70 #else
    71   missing_val=0.
    72 #endif
    7367
    7468  Nlevout = Nlvgrid
     
    9084    ok_sync = .TRUE.
    9185   
    92 !DO iinit=1, iinitend
    93 ! AI sept 2014 cette boucle supprimee
    94 ! On n'ecrit pas quand itap=1 (cosp)
    95 
    96 !   if (prt_level >= 10) then
    97 !         WRITE(lunout,*)'DO iinit=1, iinitend ',iinitend
    98 !   endif
    99 
    100 !!#ifdef CPP_XIOS
    101 ! !$OMP MASTER
    102 !IF (cosp_varsdefined) THEN
    103 !   if (prt_level >= 10) then
    104 !         WRITE(lunout,*)'Apell xios_update_calendar cosp_varsdefined iinitend ', &
    105 !                         cosp_varsdefined,iinitend
    106 !   endif
    107 !    CALL xios_update_calendar(itau_wcosp)
    108 !ENDIF
    109 !  !$OMP END MASTER
    110 !  !$OMP BARRIER
    111 !!#endif
    112 
    11386!!!! Sorties Calipso
    11487 if (cfg%Lcalipso) then
    115 !!! AI 02 2018
    116 ! Traitement missing_val
    117 !!!   where(stlidar%lidarcld == R_UNDEF) stlidar%lidarcld = missing_val
    118 !!!   where(sglidar%beta_mol == R_UNDEF) sglidar%beta_mol = missing_val 
    119 !!!   where(sglidar%beta_tot == R_UNDEF) sglidar%beta_tot = missing_val
    120 !!!   where(stlidar%cldlayer == R_UNDEF) stlidar%cldlayer = missing_val
    121 !   where(stlidar%cldtype == R_UNDEF) stlidar%cldtype = missing_val     !OPAQ
    122 !!!   where(stlidar%cfad_sr == R_UNDEF) stlidar%cfad_sr = missing_val
    123 ! AI 11 / 2015
    124 !!!   where(stlidar%parasolrefl == R_UNDEF) stlidar%parasolrefl = missing_val
    125 !!!   where(stlidar%lidarcldtmp == R_UNDEF) stlidar%lidarcldtmp = missing_val
    126 !!!   where(stlidar%cldlayerphase == R_UNDEF) stlidar%cldlayerphase = missing_val
    127 !!!   where(stlidar%lidarcldphase == R_UNDEF) stlidar%lidarcldphase = missing_val
    128 !   where(stlidar%lidarcldtype == R_UNDEF) stlidar%lidarcldtype = missing_val   !OPAQ
    129 !!!   where(stlidar%lidarcldtmp == R_UNDEF) stlidar%lidarcldtmp = missing_val
    130 
    131 !!! missing values pour toutes les valeurs R_UNDEF des variables de CALIPSO
    132 !   where(cospOUT%calipso_betaperp_tot == R_UNDEF) cospOUT%calipso_betaperp_tot = missing_val
    133    where(cospOUT%calipso_beta_tot == R_UNDEF) cospOUT%calipso_beta_tot = missing_val
    134    where(cospOUT%calipso_tau_tot == R_UNDEF) cospOUT%calipso_tau_tot = missing_val
    135    where(cospOUT%calipso_lidarcldphase == R_UNDEF) cospOUT%calipso_lidarcldphase = missing_val
    136    where(cospOUT%calipso_lidarcldtype == R_UNDEF) cospOUT%calipso_lidarcldtype = missing_val
    137    where(cospOUT%calipso_cldlayerphase == R_UNDEF) cospOUT%calipso_cldlayerphase = missing_val
    138    where(cospOUT%calipso_lidarcldtmp == R_UNDEF)    cospOUT%calipso_lidarcldtmp = missing_val
    139    where(cospOUT%calipso_cfad_sr == R_UNDEF)        cospOUT%calipso_cfad_sr = missing_val
    140    where(cospOUT%calipso_lidarcld == R_UNDEF)       cospOUT%calipso_lidarcld = missing_val
    141    where(cospOUT%calipso_cldlayer == R_UNDEF)       cospOUT%calipso_cldlayer = missing_val
    142    where(cospOUT%calipso_cldtype == R_UNDEF)        cospOUT%calipso_cldtype = missing_val
    143    where(cospOUT%calipso_cldtypetemp == R_UNDEF)    cospOUT%calipso_cldtypetemp = missing_val
    144    where(cospOUT%calipso_cldtypemeanz == R_UNDEF)   cospOUT%calipso_cldtypemeanz = missing_val
    145    where(cospOUT%calipso_cldtypemeanzse == R_UNDEF) cospOUT%calipso_cldtypemeanzse = missing_val
    146    where(cospOUT%calipso_beta_mol == R_UNDEF)       cospOUT%calipso_beta_mol = missing_val
    147    where(cospOUT%calipso_temp_tot == R_UNDEF)       cospOUT%calipso_temp_tot = missing_val
    148    where(cospOUT%calipso_cldthinemis == R_UNDEF)    cospOUT%calipso_cldthinemis = missing_val
    149    where(cospOUT%calipso_srbval == R_UNDEF)         cospOUT%calipso_srbval = missing_val
    150 
    15188
    15289!   print*,'Appel histwrite2d_cosp'
    153    if (cfg%Lcllcalipso) CALL histwrite2d_cosp(o_cllcalipso,cospOUT%calipso_cldlayer(:,1))
    154    if (cfg%Lclhcalipso) CALL histwrite2d_cosp(o_clhcalipso,cospOUT%calipso_cldlayer(:,3))
    155    if (cfg%Lclmcalipso) CALL histwrite2d_cosp(o_clmcalipso,cospOUT%calipso_cldlayer(:,2))
    156    if (cfg%Lcltcalipso) CALL histwrite2d_cosp(o_cltcalipso,cospOUT%calipso_cldlayer(:,4))
    157    if (cfg%Lclcalipso) CALL histwrite3d_cosp(o_clcalipso,cospOUT%calipso_lidarcld,nvert)
    158    if (cfg%Lclcalipsotmp) CALL histwrite3d_cosp(o_clcalipsotmp,cospOUT%calipso_lidarcldtmp(:,:,1),nverttemp)
    159 
    160    if (cfg%Lcllcalipsoice) CALL histwrite2d_cosp(o_cllcalipsoice,cospOUT%calipso_cldlayerphase(:,1,1))
    161    if (cfg%Lclhcalipsoice) CALL histwrite2d_cosp(o_clhcalipsoice,cospOUT%calipso_cldlayerphase(:,3,1))
    162    if (cfg%Lclmcalipsoice) CALL histwrite2d_cosp(o_clmcalipsoice,cospOUT%calipso_cldlayerphase(:,2,1))
    163    if (cfg%Lcltcalipsoice) CALL histwrite2d_cosp(o_cltcalipsoice,cospOUT%calipso_cldlayerphase(:,4,1))
    164    if (cfg%Lclcalipsoice) CALL histwrite3d_cosp(o_clcalipsoice,cospOUT%calipso_lidarcldphase(:,:,1),nvert)
    165    if (cfg%Lclcalipsotmpice) CALL histwrite3d_cosp(o_clcalipsotmpice,cospOUT%calipso_lidarcldtmp(:,:,2),nverttemp)
    166 
    167    if (cfg%Lcllcalipsoliq) CALL histwrite2d_cosp(o_cllcalipsoliq,cospOUT%calipso_cldlayerphase(:,1,2))
    168    if (cfg%Lclhcalipsoliq) CALL histwrite2d_cosp(o_clhcalipsoliq,cospOUT%calipso_cldlayerphase(:,3,2))
    169    if (cfg%Lclmcalipsoliq) CALL histwrite2d_cosp(o_clmcalipsoliq,cospOUT%calipso_cldlayerphase(:,2,2))
    170    if (cfg%Lcltcalipsoliq) CALL histwrite2d_cosp(o_cltcalipsoliq,cospOUT%calipso_cldlayerphase(:,4,2))
    171    if (cfg%Lclcalipsoliq) CALL histwrite3d_cosp(o_clcalipsoliq,cospOUT%calipso_lidarcldphase(:,:,2),nvert)
    172    if (cfg%Lclcalipsotmpliq) CALL histwrite3d_cosp(o_clcalipsotmpliq,cospOUT%calipso_lidarcldtmp(:,:,3),nverttemp)
    173 
    174    if (cfg%Lcllcalipsoun) CALL histwrite2d_cosp(o_cllcalipsoun,cospOUT%calipso_cldlayerphase(:,1,3))
    175    if (cfg%Lclhcalipsoun) CALL histwrite2d_cosp(o_clhcalipsoun,cospOUT%calipso_cldlayerphase(:,3,3))
    176    if (cfg%Lclmcalipsoun) CALL histwrite2d_cosp(o_clmcalipsoun,cospOUT%calipso_cldlayerphase(:,2,3))
    177    if (cfg%Lcltcalipsoun) CALL histwrite2d_cosp(o_cltcalipsoun,cospOUT%calipso_cldlayerphase(:,4,3))
    178    if (cfg%Lclcalipsoun) CALL histwrite3d_cosp(o_clcalipsoun,cospOUT%calipso_lidarcldphase(:,:,3),nvert)
    179    if (cfg%Lclcalipsotmpun) CALL histwrite3d_cosp(o_clcalipsotmpun,cospOUT%calipso_lidarcldtmp(:,:,4),nverttemp)
    180 
    181    if (cfg%Lclopaquecalipso) CALL histwrite2d_cosp(o_clopaquecalipso,cospOUT%calipso_cldtype(:,1))
    182    if (cfg%Lclthincalipso) CALL histwrite2d_cosp(o_clthincalipso,cospOUT%calipso_cldtype(:,2))   
    183    if (cfg%Lclzopaquecalipso) CALL histwrite2d_cosp(o_clzopaquecalipso,cospOUT%calipso_cldtype(:,3))
    184    if (cfg%Lclcalipsoopaque) CALL histwrite3d_cosp(o_clcalipsoopaque,cospOUT%calipso_lidarcldtype(:,:,1),nvert)
    185    if (cfg%Lclcalipsothin) CALL histwrite3d_cosp(o_clcalipsothin,cospOUT%calipso_lidarcldtype(:,:,2),nvert) 
    186    if (cfg%Lclcalipsozopaque) CALL histwrite3d_cosp(o_clcalipsozopaque,cospOUT%calipso_lidarcldtype(:,:,3),nvert)
    187    if (cfg%Lclcalipsoopacity) CALL histwrite3d_cosp(o_clcalipsoopacity,cospOUT%calipso_lidarcldtype(:,:,4),nvert)
    188 
    189    if (cfg%Lclopaquetemp) CALL histwrite2d_cosp(o_clopaquetemp,cospOUT%calipso_cldtypetemp(:,1))
    190    if (cfg%Lclthintemp) CALL histwrite2d_cosp(o_clthintemp,cospOUT%calipso_cldtypetemp(:,2))
    191    if (cfg%Lclzopaquetemp) CALL histwrite2d_cosp(o_clzopaquetemp,cospOUT%calipso_cldtypetemp(:,3))
    192    if (cfg%Lclopaquemeanz) CALL histwrite2d_cosp(o_clopaquemeanz,cospOUT%calipso_cldtypemeanz(:,1))
    193    if (cfg%Lclthinmeanz) CALL histwrite2d_cosp(o_clthinmeanz,cospOUT%calipso_cldtypemeanz(:,2))
    194    if (cfg%Lclthinemis) CALL histwrite2d_cosp(o_clthinemis,cospOUT%calipso_cldthinemis)
    195    if (cfg%Lclopaquemeanzse) CALL histwrite2d_cosp(o_clopaquemeanzse,cospOUT%calipso_cldtypemeanzse(:,1))
    196    if (cfg%Lclthinmeanzse) CALL histwrite2d_cosp(o_clthinmeanzse,cospOUT%calipso_cldtypemeanzse(:,2))
    197    if (cfg%Lclzopaquecalipsose) CALL histwrite2d_cosp(o_clzopaquecalipsose,cospOUT%calipso_cldtypemeanzse(:,3))
    198 
    199 
    200 #ifdef CPP_XIOS
    201    do icl=1,SR_BINS
    202       tmp_fi4da_cfadL(:,:,icl)=cospOUT%calipso_cfad_sr(:,icl,:)
    203    enddo
     90   if (cfg%Lcllcalipso) then
     91      where(cospOUT%calipso_cldlayer(:,1) == R_UNDEF) cospOUT%calipso_cldlayer(:,1) = missing_val
     92      CALL histwrite2d_cosp(o_cllcalipso,cospOUT%calipso_cldlayer(:,1))
     93   endif
     94   if (cfg%Lclhcalipso) then
     95      where(cospOUT%calipso_cldlayer(:,3) == R_UNDEF) cospOUT%calipso_cldlayer(:,3) = missing_val
     96      CALL histwrite2d_cosp(o_clhcalipso,cospOUT%calipso_cldlayer(:,3))
     97   endif
     98   if (cfg%Lclmcalipso) then
     99      where(cospOUT%calipso_cldlayer(:,2) == R_UNDEF) cospOUT%calipso_cldlayer(:,2) = missing_val
     100      CALL histwrite2d_cosp(o_clmcalipso,cospOUT%calipso_cldlayer(:,2))
     101   endif
     102   if (cfg%Lcltcalipso) then
     103      where(cospOUT%calipso_cldlayer(:,4) == R_UNDEF) cospOUT%calipso_cldlayer(:,4) = missing_val
     104      CALL histwrite2d_cosp(o_cltcalipso,cospOUT%calipso_cldlayer(:,4))
     105   endif
     106   if (cfg%Lclcalipso) then
     107      where(cospOUT%calipso_lidarcld == R_UNDEF)    cospOUT%calipso_lidarcld = missing_val
     108      CALL histwrite3d_cosp(o_clcalipso,cospOUT%calipso_lidarcld,nvert)
     109   endif
     110   if (cfg%Lclcalipsotmp) then
     111      where(cospOUT%calipso_lidarcldtmp(:,:,1) == R_UNDEF) cospOUT%calipso_lidarcldtmp(:,:,1) = missing_val
     112      CALL histwrite3d_cosp(o_clcalipsotmp,cospOUT%calipso_lidarcldtmp(:,:,1),nverttemp)
     113   endif
     114
     115   if (cfg%Lcllcalipsoice) then
     116      where(cospOUT%calipso_cldlayerphase(:,1,1) == R_UNDEF) cospOUT%calipso_cldlayerphase(:,1,1) = missing_val
     117      CALL histwrite2d_cosp(o_cllcalipsoice,cospOUT%calipso_cldlayerphase(:,1,1))
     118   endif
     119   if (cfg%Lclhcalipsoice) then
     120      where(cospOUT%calipso_cldlayerphase(:,3,1) == R_UNDEF) cospOUT%calipso_cldlayerphase(:,3,1) = missing_val
     121      CALL histwrite2d_cosp(o_clhcalipsoice,cospOUT%calipso_cldlayerphase(:,3,1))
     122   endif
     123   if (cfg%Lclmcalipsoice) then
     124      where(cospOUT%calipso_cldlayerphase(:,2,1) == R_UNDEF) cospOUT%calipso_cldlayerphase(:,2,1) = missing_val
     125      CALL histwrite2d_cosp(o_clmcalipsoice,cospOUT%calipso_cldlayerphase(:,2,1))
     126   endif
     127   if (cfg%Lcltcalipsoice) then
     128      where(cospOUT%calipso_cldlayerphase(:,4,1) == R_UNDEF) cospOUT%calipso_cldlayerphase(:,4,1) = missing_val
     129      CALL histwrite2d_cosp(o_cltcalipsoice,cospOUT%calipso_cldlayerphase(:,4,1))
     130   endif
     131   if (cfg%Lclcalipsoice) then
     132      where(cospOUT%calipso_lidarcldphase(:,:,1) == R_UNDEF) cospOUT%calipso_lidarcldphase(:,:,1) = missing_val
     133      CALL histwrite3d_cosp(o_clcalipsoice,cospOUT%calipso_lidarcldphase(:,:,1),nvert)
     134   endif
     135   if (cfg%Lclcalipsotmpice) then
     136      where(cospOUT%calipso_lidarcldtmp(:,:,2) == R_UNDEF) cospOUT%calipso_lidarcldtmp(:,:,2) = missing_val
     137      CALL histwrite3d_cosp(o_clcalipsotmpice,cospOUT%calipso_lidarcldtmp(:,:,2),nverttemp)
     138   endif
     139
     140   if (cfg%Lcllcalipsoliq) then
     141      where(cospOUT%calipso_cldlayerphase(:,1,2) == R_UNDEF) cospOUT%calipso_cldlayerphase(:,1,2) = missing_val
     142      CALL histwrite2d_cosp(o_cllcalipsoliq,cospOUT%calipso_cldlayerphase(:,1,2))
     143   endif
     144   if (cfg%Lclhcalipsoliq) then
     145      where(cospOUT%calipso_cldlayerphase(:,3,2) == R_UNDEF) cospOUT%calipso_cldlayerphase(:,3,2) = missing_val
     146      CALL histwrite2d_cosp(o_clhcalipsoliq,cospOUT%calipso_cldlayerphase(:,3,2))
     147   endif
     148   if (cfg%Lclmcalipsoliq) then
     149      where(cospOUT%calipso_cldlayerphase(:,2,2) == R_UNDEF) cospOUT%calipso_cldlayerphase(:,2,2) = missing_val
     150      CALL histwrite2d_cosp(o_clmcalipsoliq,cospOUT%calipso_cldlayerphase(:,2,2))
     151   endif
     152   if (cfg%Lcltcalipsoliq) then
     153      where(cospOUT%calipso_cldlayerphase(:,4,2) == R_UNDEF) cospOUT%calipso_cldlayerphase(:,4,2) = missing_val
     154      CALL histwrite2d_cosp(o_cltcalipsoliq,cospOUT%calipso_cldlayerphase(:,4,2))
     155   endif
     156   if (cfg%Lclcalipsoliq) then
     157      where(cospOUT%calipso_lidarcldphase(:,:,2) == R_UNDEF) cospOUT%calipso_lidarcldphase(:,:,2) = missing_val
     158      CALL histwrite3d_cosp(o_clcalipsoliq,cospOUT%calipso_lidarcldphase(:,:,2),nvert)
     159   endif
     160   if (cfg%Lclcalipsotmpliq) then
     161      where(cospOUT%calipso_lidarcldtmp(:,:,3) == R_UNDEF) cospOUT%calipso_lidarcldtmp(:,:,3) = missing_val
     162      CALL histwrite3d_cosp(o_clcalipsotmpliq,cospOUT%calipso_lidarcldtmp(:,:,3),nverttemp)
     163   endif
     164   if (cfg%Lcllcalipsoun) then
     165      where(cospOUT%calipso_cldlayerphase(:,1,3) == R_UNDEF) cospOUT%calipso_cldlayerphase(:,1,3) = missing_val
     166      CALL histwrite2d_cosp(o_cllcalipsoun,cospOUT%calipso_cldlayerphase(:,1,3))
     167   endif
     168   if (cfg%Lclhcalipsoun) then
     169      where(cospOUT%calipso_cldlayerphase(:,3,3) == R_UNDEF) cospOUT%calipso_cldlayerphase(:,3,3) = missing_val
     170      CALL histwrite2d_cosp(o_clhcalipsoun,cospOUT%calipso_cldlayerphase(:,3,3))
     171   endif
     172   if (cfg%Lclmcalipsoun) then
     173      where(cospOUT%calipso_cldlayerphase(:,2,3) == R_UNDEF) cospOUT%calipso_cldlayerphase(:,2,3) = missing_val
     174      CALL histwrite2d_cosp(o_clmcalipsoun,cospOUT%calipso_cldlayerphase(:,2,3))
     175   endif
     176   if (cfg%Lcltcalipsoun) then
     177      where(cospOUT%calipso_cldlayerphase(:,4,3) == R_UNDEF) cospOUT%calipso_cldlayerphase(:,4,3) = missing_val
     178      CALL histwrite2d_cosp(o_cltcalipsoun,cospOUT%calipso_cldlayerphase(:,4,3))
     179   endif
     180   if (cfg%Lclcalipsoun) then
     181      where(cospOUT%calipso_lidarcldphase(:,:,3) == R_UNDEF) cospOUT%calipso_lidarcldphase(:,:,3) = missing_val
     182      CALL histwrite3d_cosp(o_clcalipsoun,cospOUT%calipso_lidarcldphase(:,:,3),nvert)
     183   endif
     184   if (cfg%Lclcalipsotmpun) then
     185      where(cospOUT%calipso_lidarcldtmp(:,:,4) == R_UNDEF) cospOUT%calipso_lidarcldtmp(:,:,4) = missing_val
     186      CALL histwrite3d_cosp(o_clcalipsotmpun,cospOUT%calipso_lidarcldtmp(:,:,4),nverttemp)
     187   endif
     188
     189   if (cfg%Lclopaquecalipso) then
     190      where(cospOUT%calipso_cldtype(:,1) == R_UNDEF) cospOUT%calipso_cldtype(:,1) = missing_val
     191      CALL histwrite2d_cosp(o_clopaquecalipso,cospOUT%calipso_cldtype(:,1))
     192   endif
     193   if (cfg%Lclthincalipso) then
     194      where(cospOUT%calipso_cldtype(:,2) == R_UNDEF) cospOUT%calipso_cldtype(:,2) = missing_val
     195      CALL histwrite2d_cosp(o_clthincalipso,cospOUT%calipso_cldtype(:,2))   
     196   endif
     197   if (cfg%Lclzopaquecalipso) then
     198      where(cospOUT%calipso_cldtype(:,3) == R_UNDEF) cospOUT%calipso_cldtype(:,3) = missing_val     
     199      CALL histwrite2d_cosp(o_clzopaquecalipso,cospOUT%calipso_cldtype(:,3))
     200   endif
     201   if (cfg%Lclcalipsoopaque) then
     202      where(cospOUT%calipso_lidarcldtype(:,:,1) == R_UNDEF) cospOUT%calipso_lidarcldtype(:,:,1) = missing_val     
     203      CALL histwrite3d_cosp(o_clcalipsoopaque,cospOUT%calipso_lidarcldtype(:,:,1),nvert)
     204   endif
     205   if (cfg%Lclcalipsothin) then
     206      where(cospOUT%calipso_lidarcldtype(:,:,2) == R_UNDEF) cospOUT%calipso_lidarcldtype(:,:,2) = missing_val
     207      CALL histwrite3d_cosp(o_clcalipsothin,cospOUT%calipso_lidarcldtype(:,:,2),nvert) 
     208   endif
     209   if (cfg%Lclcalipsozopaque) then
     210      where(cospOUT%calipso_lidarcldtype(:,:,3) == R_UNDEF) cospOUT%calipso_lidarcldtype(:,:,3) = missing_val
     211      CALL histwrite3d_cosp(o_clcalipsozopaque,cospOUT%calipso_lidarcldtype(:,:,3),nvert)
     212   endif
     213   if (cfg%Lclcalipsoopacity) then
     214      where(cospOUT%calipso_lidarcldtype(:,:,4) == R_UNDEF) cospOUT%calipso_lidarcldtype(:,:,4) = missing_val
     215      CALL histwrite3d_cosp(o_clcalipsoopacity,cospOUT%calipso_lidarcldtype(:,:,4),nvert)
     216   endif
     217
     218   if (cfg%Lclopaquetemp) then
     219      where(cospOUT%calipso_cldtypetemp(:,1) == R_UNDEF) cospOUT%calipso_cldtypetemp(:,1) = missing_val
     220      CALL histwrite2d_cosp(o_clopaquetemp,cospOUT%calipso_cldtypetemp(:,1))
     221   endif
     222   if (cfg%Lclthintemp) then
     223      where(cospOUT%calipso_cldtypetemp(:,2) == R_UNDEF) cospOUT%calipso_cldtypetemp(:,2) = missing_val
     224      CALL histwrite2d_cosp(o_clthintemp,cospOUT%calipso_cldtypetemp(:,2))
     225   endif
     226   if (cfg%Lclzopaquetemp) then
     227      where(cospOUT%calipso_cldtypetemp(:,3) == R_UNDEF) cospOUT%calipso_cldtypetemp(:,3) = missing_val
     228      CALL histwrite2d_cosp(o_clzopaquetemp,cospOUT%calipso_cldtypetemp(:,3))
     229   endif
     230   if (cfg%Lclopaquemeanz) then
     231      where(cospOUT%calipso_cldtypemeanz(:,1) == R_UNDEF) cospOUT%calipso_cldtypemeanz(:,1) = missing_val
     232      CALL histwrite2d_cosp(o_clopaquemeanz,cospOUT%calipso_cldtypemeanz(:,1))
     233   endif
     234   if (cfg%Lclthinmeanz) then
     235      where(cospOUT%calipso_cldtypemeanz(:,2) == R_UNDEF) cospOUT%calipso_cldtypemeanz(:,2) = missing_val
     236      CALL histwrite2d_cosp(o_clthinmeanz,cospOUT%calipso_cldtypemeanz(:,2))
     237   endif
     238   if (cfg%Lclthinemis) then
     239      where(cospOUT%calipso_cldthinemis == R_UNDEF) cospOUT%calipso_cldthinemis = missing_val
     240      CALL histwrite2d_cosp(o_clthinemis,cospOUT%calipso_cldthinemis)
     241   endif
     242   if (cfg%Lclopaquemeanzse) then
     243      where(cospOUT%calipso_cldtypemeanzse(:,1) == R_UNDEF) cospOUT%calipso_cldtypemeanzse(:,1) = missing_val
     244      CALL histwrite2d_cosp(o_clopaquemeanzse,cospOUT%calipso_cldtypemeanzse(:,1))
     245   endif
     246   if (cfg%Lclthinmeanzse) then
     247      where(cospOUT%calipso_cldtypemeanzse(:,2) == R_UNDEF) cospOUT%calipso_cldtypemeanzse(:,2) = missing_val
     248      CALL histwrite2d_cosp(o_clthinmeanzse,cospOUT%calipso_cldtypemeanzse(:,2))
     249   endif
     250   if (cfg%Lclzopaquecalipsose) then
     251      where(cospOUT%calipso_cldtypemeanzse(:,3) == R_UNDEF) cospOUT%calipso_cldtypemeanzse(:,3) = missing_val
     252      CALL histwrite2d_cosp(o_clzopaquecalipsose,cospOUT%calipso_cldtypemeanzse(:,3))
     253   endif
     254
     255
     256   if (cfg%LcfadLidarsr532) then
     257     where(cospOUT%calipso_cfad_sr == R_UNDEF) cospOUT%calipso_cfad_sr = missing_val
     258   
     259     do icl=1,SR_BINS
     260      do k=1,Nlvgrid
     261       do ip=1,Npoints
     262        tmp_fi4da_cfadL(ip,k,icl)=cospOUT%calipso_cfad_sr(ip,icl,k)
     263       enddo
     264      enddo
     265     enddo
    204266!   if (cfg%LcfadLidarsr532) CALL histwrite4d_cosp(o_cfad_lidarsr532,stlidar%cfad_sr)
    205    if (cfg%LcfadLidarsr532) CALL histwrite4d_cosp(o_cfadLidarsr532,tmp_fi4da_cfadL)   !!! "_" enleve
    206 #else
    207    if (cfg%LcfadLidarsr532) then
    208      do icl=1,SR_BINS
    209         CALL histwrite3d_cosp(o_cfadLidarsr532,cospOUT%calipso_cfad_sr(:,icl,:),nvert,icl)   !!! "_" enleve
    210      enddo
    211    endif
    212 #endif
    213 
    214 #ifdef CPP_XIOS
    215    if (cfg%Latb532) CALL histwrite4d_cosp(o_atb532,cospOUT%calipso_beta_tot)
    216 #else
     267    CALL histwrite4d_cosp(o_cfadLidarsr532,tmp_fi4da_cfadL)   !!! "_" enleve
     268   endif
     269
    217270   if (cfg%Latb532) then 
    218      do icl=1,Ncolumns
    219         CALL histwrite3d_cosp(o_atb532,cospOUT%calipso_beta_tot(:,icl,:),nvertmcosp,icl)
    220      enddo
    221    endif
    222 #endif
    223 
    224    if (cfg%LlidarBetaMol532) CALL histwrite3d_cosp(o_lidarBetaMol532,cospOUT%calipso_beta_mol,nvertmcosp)
     271     where(cospOUT%calipso_beta_tot == R_UNDEF) cospOUT%calipso_beta_tot = missing_val
     272     CALL histwrite4d_cosp(o_atb532,cospOUT%calipso_beta_tot)
     273   endif
     274   if (cfg%LlidarBetaMol532) then
     275     where(cospOUT%calipso_tau_tot == R_UNDEF) cospOUT%calipso_tau_tot = missing_val
     276     CALL histwrite3d_cosp(o_lidarBetaMol532,cospOUT%calipso_beta_mol,nvertmcosp)
     277   endif
    225278
    226279 endif !Calipso
     
    245298   if (cfg%LlidarBetaMol532gr) CALL histwrite3d_cosp(o_lidarBetaMol532gr,cospOUT%grLidar532_beta_mol,nvertmcosp)
    246299
    247 #ifdef CPP_XIOS
    248300   do icl=1,SR_BINS
    249       tmp_fi4da_cfadLgr(:,:,icl)=cospOUT%grLidar532_cfad_sr(:,icl,:)
     301      do k=1,Nlvgrid
     302       do ip=1,Npoints
     303         tmp_fi4da_cfadLgr(ip,k,icl)=cospOUT%grLidar532_cfad_sr(ip,icl,k)
     304       enddo
     305      enddo
    250306   enddo
    251307   if (cfg%LcfadLidarsr532gr) CALL histwrite4d_cosp(o_cfadLidarsr532gr,tmp_fi4da_cfadLgr)
    252 #else
    253    if (cfg%LcfadLidarsr532gr) then
    254      do icl=1,SR_BINS
    255         CALL histwrite3d_cosp(o_cfadLidarsr532gr,cospOUT%grLidar532_cfad_sr(:,icl,:),nvert,icl)
    256      enddo
    257    endif
    258 #endif
    259 
    260 #ifdef CPP_XIOS
     308
    261309   if (cfg%Latb532gr) CALL histwrite4d_cosp(o_atb532gr,cospOUT%grLidar532_beta_tot)
    262 #else
    263    if (cfg%Latb532gr) then 
    264      do icl=1,Ncolumns
    265         CALL histwrite3d_cosp(o_atb532gr,cospOUT%grLidar532_beta_tot(:,icl,:),nvertmcosp,icl)
    266      enddo
    267    endif
    268 #endif
    269310
    270311endif ! Ground Lidar 532 nm
     
    289330   if (cfg%LlidarBetaMol355) CALL histwrite3d_cosp(o_lidarBetaMol355,cospOUT%atlid_beta_mol,nvertmcosp)
    290331
    291 #ifdef CPP_XIOS
    292332   do icl=1,SR_BINS
    293       tmp_fi4da_cfadLatlid(:,:,icl)=cospOUT%atlid_cfad_sr(:,icl,:)
     333      do k=1,Nlvgrid
     334       do ip=1,Npoints
     335          tmp_fi4da_cfadLatlid(ip,k,icl)=cospOUT%atlid_cfad_sr(ip,icl,k)
     336       enddo
     337      enddo
    294338   enddo
    295339   if (cfg%LcfadLidarsr355) CALL histwrite4d_cosp(o_cfadlidarsr355,tmp_fi4da_cfadLatlid)
    296 #else
    297    if (cfg%LcfadLidarsr355) then
    298      do icl=1,SR_BINS
    299         CALL histwrite3d_cosp(o_cfadlidarsr355,cospOUT%atlid_cfad_sr(:,icl,:),nvert,icl)
    300      enddo
    301    endif
    302 #endif
    303 
    304 #ifdef CPP_XIOS
     340
    305341   if (cfg%Latb355) CALL histwrite4d_cosp(o_atb355,cospOUT%atlid_beta_tot)
    306 #else
    307    if (cfg%Latb355) then 
    308      do icl=1,Ncolumns
    309         CALL histwrite3d_cosp(o_atb355,cospOUT%atlid_beta_tot(:,icl,:),nvertmcosp,icl)
    310      enddo
    311    endif
    312 #endif
    313342
    314343endif ! Atlid
     
    322351     CALL histwrite3d_cosp(o_parasolGrid_refl,cospOUT%parasolGrid_refl,nvertp)
    323352
    324 #ifdef CPP_XIOS
    325353     CALL histwrite4d_cosp(o_parasolPix_refl,cospOUT%parasolPix_refl)
    326 #else
    327      do icl=1,Ncolumns
    328         CALL histwrite3d_cosp(o_parasolPix_refl,cospOUT%parasolPix_refl(:,icl,:),nvertp,icl)
    329      enddo
    330 #endif
    331354
    332355    endif ! LparasolRefl
     
    371394   if (cfg%Lradarpia) CALL histwrite2d_cosp(o_radarpia,cospOUT%cloudsat_pia)
    372395
    373 #ifdef CPP_XIOS
    374396   do icl=1,CLOUDSAT_DBZE_BINS
    375      tmp_fi4da_cfadR(:,:,icl)=cospOUT%cloudsat_cfad_ze(:,icl,:)
     397      do k=1,Nlvgrid
     398       do ip=1,Npoints
     399         tmp_fi4da_cfadR(ip,k,icl)=cospOUT%cloudsat_cfad_ze(ip,icl,k)
     400       enddo
     401      enddo
    376402   enddo
    377403   if (cfg%Ldbze94) CALL histwrite4d_cosp(o_dbze94,cospOUT%cloudsat_Ze_tot)
    378404!   if (cfg%LcfadDbze94) CALL histwrite4d_cosp(o_cfadDbze94,stradar%cfad_ze)
    379405   if (cfg%LcfadDbze94) CALL histwrite4d_cosp(o_cfadDbze94,tmp_fi4da_cfadR)
    380 #else
    381    if (cfg%Ldbze94) then
    382     do icl=1,Ncolumns
    383        CALL histwrite3d_cosp(o_dbze94,cospOUT%cloudsat_Ze_tot(:,icl,:),nvert,icl)
    384     enddo
    385    endif
    386    if (cfg%LcfadDbze94) then
    387     do icl=1,CLOUDSAT_DBZE_BINS
    388     CALL histwrite3d_cosp(o_cfadDbze94,cospOUT%cloudsat_cfad_ze(:,icl,:),nvert,icl)
    389     enddo
    390    endif
    391 #endif
    392406 endif
    393407! endif pour CloudSat
     
    425439
    426440!   CALL histwrite2d_cosp(o_sunlit,gbx%sunlit)
    427 #ifdef CPP_XIOS
    428441  if (cfg%Lclisccp) CALL histwrite4d_cosp(o_clisccp,cospOUT%isccp_fq)
    429 #else
    430    if (cfg%Lclisccp) then
    431      do icl=1,7
    432        CALL histwrite3d_cosp(o_clisccp,cospOUT%isccp_fq(:,icl,:),nvertisccp,icl)
    433      enddo
    434    endif
    435 #endif
    436442
    437443   if (cfg%Lboxtauisccp) CALL histwrite3d_cosp(o_boxtauisccp,cospOUT%isccp_boxtau,nvertcol)
     
    456462   where(cospOUT%misr_cldarea == R_UNDEF) cospOUT%misr_cldarea = missing_val
    457463
    458 #ifdef CPP_XIOS
    459464   do icl=1,numMISRHgtBins
    460       tmp_fi4da_misr(:,icl,:)=cospOUT%misr_fq(:,:,icl)
     465      do k=1,Nlvgrid
     466       do ip=1,Npoints   
     467      tmp_fi4da_misr(ip,icl,k)=cospOUT%misr_fq(ip,k,icl)
     468       enddo
     469      enddo
    461470   enddo
    462471!   if (cfg%LclMISR) CALL histwrite4d_cosp(o_clMISR,misr%fq_MISR)
    463472!   if (cfg%LclMISR) CALL histwrite4d_cosp(o_clMISR,tmp_fi4da_misr)
    464473   CALL histwrite4d_cosp(o_misr_fq,tmp_fi4da_misr)
    465 #else
    466     do icl=1,7
    467       CALL histwrite3d_cosp(o_misr_fq,cospOUT%misr_fq(:,icl,:),nvertmisr,icl)
    468     enddo
    469 #endif
    470474
    471475   CALL histwrite2d_cosp(o_misr_meanztop,cospOUT%misr_meanztop)
     
    540544          cospOUT%modis_Optical_thickness_vs_ReffLIQ = missing_val
    541545
    542 #ifdef CPP_XIOS
    543546    CALL histwrite4d_cosp(o_modis_ot_vs_ctp,cospOUT%modis_Optical_Thickness_vs_Cloud_Top_Pressure)
    544547    CALL histwrite4d_cosp(o_modis_ot_vs_reffice,cospOUT%modis_Optical_Thickness_vs_ReffICE)
    545548    CALL histwrite4d_cosp(o_modis_ot_vs_reffliq,cospOUT%modis_Optical_thickness_vs_ReffLIQ)
    546 #else
    547    do icl=1,7
    548    CALL histwrite3d_cosp(o_modis_ot_vs_ctp, &
    549      cospOUT%modis_Optical_Thickness_vs_Cloud_Top_Pressure(:,icl,:),nvertisccp,icl)
    550    CALL histwrite3d_cosp(o_modis_ot_vs_reffice, &
    551      cospOUT%modis_Optical_Thickness_vs_ReffICE(:,icl,:),nvertReffIce,icl)
    552    CALL histwrite3d_cosp(o_modis_ot_vs_reffliq, &
    553      cospOUT%modis_Optical_thickness_vs_ReffLIQ(:,icl,:),nvertReffLiq,icl)
    554    enddo
    555 #endif
    556 
    557 !#ifdef CPP_XIOS
    558 !  if (cfg%Lclmodis) CALL histwrite4d_cosp(o_crimodis,modis%Optical_Thickness_vs_ReffIce)
    559 !  if (cfg%Lclmodis) CALL histwrite4d_cosp(o_crlmodis,modis%Optical_Thickness_vs_ReffLiq)
    560 !#else
    561 !  if (cfg%Lclmodis) then
    562 !    do icl=1,7
    563 !     CALL histwrite3d_cosp(o_crimodis, &
    564 !          modis%Optical_Thickness_vs_ReffIce(:,icl,:),nvertReffIce,icl)
    565 !    enddo
    566 !  endif
    567 !  if (cfg%Lclmodis) then
    568 !    do icl=1,7
    569 !     CALL histwrite3d_cosp(o_crlmodis, &
    570 !          modis%Optical_Thickness_vs_ReffLiq(:,icl,:),nvertReffLiq,icl)
    571 !    enddo
    572 !  endif
    573 !#endif
     549
    574550  endif ! Lclmodis
    575551
     
    579555 IF(.NOT.cosp_varsdefined) THEN
    580556!$OMP MASTER
    581 #ifndef CPP_IOIPSL_NO_OUTPUT
    582             DO iff=1,3
    583                 IF (cosp_outfilekeys(iff)) THEN
    584                   CALL histend(cosp_nidfiles(iff))
    585                 ENDIF ! cosp_outfilekeys
    586             ENDDO !  iff
    587 #endif
    588557! Fermeture dans phys_output_write
    589 !#ifdef CPP_XIOS
     558!#ifdef 1
    590559            !On finalise l'initialisation:
    591560            !CALL wxios_closedef()
     
    599568    IF(cosp_varsdefined) THEN
    600569! On synchronise les fichiers pour IOIPSL
    601 #ifndef CPP_IOIPSL_NO_OUTPUT
    602 !$OMP MASTER
    603      DO iff=1,3
    604          IF (ok_sync .AND. cosp_outfilekeys(iff)) THEN
    605              CALL histsync(cosp_nidfiles(iff))
    606          ENDIF
    607      END DO
    608 !$OMP END MASTER
    609 #endif
    610570    ENDIF  !cosp_varsdefined
    611571
     
    628588    USE mod_grid_phy_lmdz, ONLY: nbp_lon
    629589    USE print_control_mod, ONLY: lunout,prt_level
    630 #ifdef CPP_XIOS
    631590  USE wxios
    632 #endif
    633591
    634592    IMPLICIT NONE
     
    662620    ENDIF
    663621
    664 #ifdef CPP_XIOS
    665622     IF (.not. ok_all_xml) then
    666623       IF ( var%cles(iff) ) THEN
     
    672629       ENDIF
    673630     ENDIF
    674 #endif
    675 
    676 #ifndef CPP_IOIPSL_NO_OUTPUT
    677        IF ( var%cles(iff) ) THEN
    678           CALL histdef (cosp_nidfiles(iff), var%name, var%description, var%unit, &
    679                nbp_lon,jj_nb,nhoricosp(iff), 1,1,1, -99, 32, &
    680                typeecrit, zstophym,zoutm_cosp(iff))
    681        ENDIF
    682 #endif
     631
    683632
    684633  END SUBROUTINE histdef2d_cosp
     
    693642    USE print_control_mod, ONLY: lunout,prt_level
    694643
    695 #ifdef CPP_XIOS
    696644  USE wxios
    697 #endif
    698645
    699646
     
    769716    ENDIF
    770717
    771 #ifdef CPP_XIOS
    772718      IF (.not. ok_all_xml) then
    773719        IF ( var%cles(iff) ) THEN
     
    779725        ENDIF
    780726      ENDIF
    781 #endif
    782 
    783 #ifndef CPP_IOIPSL_NO_OUTPUT
    784        IF ( var%cles(iff) ) THEN
    785           CALL histdef (cosp_nidfiles(iff), nom, var%description, var%unit, &
    786                nbp_lon, jj_nb, nhoricosp(iff), klevs, 1, &
    787                klevs, nvertsave, 32, typeecrit, &
    788                zstophym, zoutm_cosp(iff))
    789        ENDIF
    790 #endif
     727
    791728
    792729  END SUBROUTINE histdef3d_cosp
     
    801738  USE print_control_mod, ONLY: lunout,prt_level
    802739
    803 #ifdef CPP_XIOS
    804740  USE xios, only: xios_send_field
    805 #endif
    806741
    807742  IMPLICIT NONE
     
    826761  IF(.NOT.cosp_varsdefined) THEN
    827762!$OMP MASTER
     763      print*,'var, cosp_varsdefined dans cosp_varsdefined ',var%name, cosp_varsdefined
    828764      !Si phase de définition.... on définit
    829765      CALL conf_cospoutputs(var%name,var%cles)
     
    848784           IF (var%cles(iff) .AND. cosp_outfilekeys(iff)) THEN
    849785                ALLOCATE(index2d(nbp_lon*jj_nb))
    850 #ifndef CPP_IOIPSL_NO_OUTPUT
    851         CALL histwrite(cosp_nidfiles(iff),var%name,itau_iocosp,Field2d,nbp_lon*jj_nb,index2d)
    852 #endif
    853786                deallocate(index2d)
    854 #ifdef CPP_XIOS
    855787              IF (.not. ok_all_xml) then
    856788                 if (firstx) then
     
    862794                 endif
    863795              ENDIF
    864 #endif
    865796           ENDIF
    866797      ENDDO
    867798
    868 #ifdef CPP_XIOS
    869799      IF (ok_all_xml) THEN
    870800        if (prt_level >= 1) then
     
    873803       CALL xios_send_field(var%name, Field2d)
    874804      ENDIF
    875 #endif
    876805
    877806!$OMP END MASTER   
     
    891820  USE print_control_mod, ONLY: lunout,prt_level
    892821
    893 #ifdef CPP_XIOS
    894822  USE xios, only: xios_send_field
    895 #endif
    896823
    897824
     
    952879        IF (var%cles(iff) .AND. cosp_outfilekeys(iff)) THEN
    953880           ALLOCATE(index3d(nbp_lon*jj_nb*nlev))
    954 #ifndef CPP_IOIPSL_NO_OUTPUT
    955     CALL histwrite(cosp_nidfiles(iff),nom,itau_iocosp,Field3d,nbp_lon*jj_nb*nlev,index3d)
    956 #endif
    957 
    958 #ifdef CPP_XIOS
     881
    959882          IF (.not. ok_all_xml) then
    960883           IF (firstx) THEN
     
    964887           ENDIF
    965888          ENDIF
    966 #endif
    967889         deallocate(index3d)
    968890        ENDIF
    969891      ENDDO
    970 #ifdef CPP_XIOS
    971892    IF (ok_all_xml) THEN
    972893     CALL xios_send_field(nom, Field3d(:,:,1:nlev))
    973894     IF (prt_level >= 1) WRITE(lunout,*)'xios_send_field ',var%name
    974895    ENDIF
    975 #endif
    976896
    977897!$OMP END MASTER   
     
    991911  USE print_control_mod, ONLY: lunout,prt_level
    992912
    993 #ifdef CPP_XIOS
    994913  USE xios, only: xios_send_field
    995 #endif
    996914
    997915
     
    1023941    CALL grid1Dto2D_mpi(buffer_omp,field4d)
    1024942
    1025 #ifdef CPP_XIOS
    1026943!    IF (ok_all_xml) THEN
    1027944     CALL xios_send_field(var%name, Field4d(:,:,1:nlev,1:nlev2))
    1028945     IF (prt_level >= 1) WRITE(lunout,*)'xios_send_field ',var%name
    1029946!    ENDIF
    1030 #endif
    1031947
    1032948!$OMP END MASTER   
Note: See TracChangeset for help on using the changeset viewer.