Skip to content

Commit

Permalink
introducing "Inline Diagnostic Driver (IDiD)" (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
takmichibata authored and dustinswales committed Aug 8, 2019
1 parent f282c66 commit 70d27da
Show file tree
Hide file tree
Showing 8 changed files with 509 additions and 26 deletions.
5 changes: 3 additions & 2 deletions build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,14 @@ driver_COSP1.4:
# Dependencies for libary
cosp.o : cosp_kinds.o cosp_modis_interface.o cosp_constants.o cosp_rttov_interfaceSTUB.o \
cosp_misr_interface.o cosp_isccp_interface.o cosp_calipso_interface.o \
cosp_cloudsat_interface.o cosp_stats.o cosp_parasol_interface.o cosp_rttovSTUB.o \
cosp_cloudsat_interface.o cosp_stats.o \
cosp_parasol_interface.o cosp_rttovSTUB.o \
cosp_rttov_interfaceSTUB.o quickbeam.o MISR_simulator.o lidar_simulator.o \
parasol.o icarus.o cosp_grLidar532_interface.o cosp_atlid_interface.o
cosp_constants.o : cosp_kinds.o
cosp_config.o : cosp_kinds.o
cosp_errorHandling.o : cosp_kinds.o
cosp_stats.o : cosp_kinds.o cosp_config.o
cosp_stats.o : cosp_kinds.o cosp_config.o cosp_constants.o
cosp_isccp_interface.o : cosp_kinds.o icarus.o
icarus.o : cosp_kinds.o cosp_constants.o cosp_stats.o
cosp_misr_interface.o : cosp_kinds.o
Expand Down
5 changes: 4 additions & 1 deletion driver/run/cosp2_output_nl.txt
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,8 @@
Lptradarflag7=.true.,
Lptradarflag8=.true.,
Lptradarflag9=.true.,
Lradarpia=.true.
Lradarpia=.true.,
!- CloudSat+MODIS joint diagnostics
Lwr_occfreq=.true.,
Lcfodd=.true.
/
104 changes: 102 additions & 2 deletions driver/src/cosp2_io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ module mod_cosp_io
tau_binEdges,npres, pres_binBounds, pres_binCenters, pres_binEdges, nhgt, &
hgt_binBounds, hgt_binCenters, hgt_binEdges, reffLIQ_binCenters,vgrid_z, &
reffICE_binCenters, reffLIQ_binCenters, cloudsat_binCenters, PARASOL_SZA, &
calipso_binCenters, grLidar532_binCenters, atlid_binCenters
calipso_binCenters, grLidar532_binCenters, atlid_binCenters, &
CFODD_NDBZE, CFODD_HISTDBZE, CFODD_HISTDBZEcenters, &
CFODD_NICOD, CFODD_HISTICOD, CFODD_HISTICODcenters
implicit none

contains
Expand Down Expand Up @@ -73,6 +75,10 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, lev, lon, lat, cospOUT
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_def_dim(fileID,"REICE_MODIS",numMODISReffIceBins,dimID(16))
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_def_dim(fileID,"CFODD_NDBZE",CFODD_NDBZE,dimID(17))
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_def_dim(fileID,"CFODD_NICOD",CFODD_NICOD,dimID(18))
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))

! ---------------------------------------------------------------------------------------
! Define varaibles
Expand Down Expand Up @@ -1339,7 +1345,77 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, lev, lon, lat, cospOUT
status = nf90_put_att(fileID,varID(139),"standard_name", "cloud_area_fraction")
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
endif

! warm-rain occurrence frequency diagnostics
if (associated(cospOUT%wr_occfreq_ntotal)) then
status = nf90_def_var(fileID,"npdfcld",nf90_float, (/dimID(1)/),varID(140))
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_put_att(fileID,varID(140),"long_name","# of Non-Precipitating Clouds")
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_put_att(fileID,varID(140),"units", "1")
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_put_att(fileID,varID(140),"standard_name", "number_of_slwc_nonprecip")
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_def_var(fileID,"npdfdrz",nf90_float, (/dimID(1)/),varID(141))
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_put_att(fileID,varID(141),"long_name","# of Drizzling Clouds")
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_put_att(fileID,varID(141),"units", "1")
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_put_att(fileID,varID(141),"standard_name", "number_of_slwc_drizzle")
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_def_var(fileID,"npdfrain",nf90_float, (/dimID(1)/),varID(142))
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_put_att(fileID,varID(142),"long_name","# of Precipitating Clouds")
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_put_att(fileID,varID(142),"units", "1")
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_put_att(fileID,varID(142),"standard_name", "number_of_slwc_precip")
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
endif
! Contoured Frequency by Optical Depth Diagram (CFODD)
if (associated(cospOUT%cfodd_ntotal)) then
status = nf90_def_var(fileID,"ncfodd1",nf90_float, (/dimID(1),dimID(17),dimID(18)/),varID(143))
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_put_att(fileID,varID(143),"long_name","# of CFODD (05 < Reff < 12 micron)")
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_put_att(fileID,varID(143),"units", "1")
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_put_att(fileID,varID(143),"standard_name", "cfodd_reff_small")
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_def_var(fileID,"ncfodd2",nf90_float, (/dimID(1),dimID(17),dimID(18)/),varID(144))
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_put_att(fileID,varID(144),"long_name","# of CFODD (12 < Reff < 18 micron)")
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_put_att(fileID,varID(144),"units", "1")
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_put_att(fileID,varID(144),"standard_name", "cfodd_reff_medium")
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_def_var(fileID,"ncfodd3",nf90_float, (/dimID(1),dimID(17),dimID(18)/),varID(145))
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_put_att(fileID,varID(145),"long_name","# of CFODD (18 < Reff < 35 micron)")
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_put_att(fileID,varID(145),"units", "1")
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_put_att(fileID,varID(145),"standard_name", "cfodd_reff_large")
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
!! axes for CFODD
status = nf90_def_var(fileID,"CFODD_NDBZE",nf90_float,(/dimID(17)/),varID(146))
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_put_att(fileID,varID(146),"long_name","CloudSat+MODIS dBZe vs ICOD joint PDF X-axis")
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_put_att(fileID,varID(146),"units", "dBZ")
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_put_att(fileID,varID(146),"standard_name", "cloudsat_quivalent_reflectivity_factor")
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_def_var(fileID,"CFODD_NICOD",nf90_float,(/dimID(18)/),varID(147))
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_put_att(fileID,varID(147),"long_name","CloudSat+MODIS dBZe vs ICOD joint PDF Y-axis")
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_put_att(fileID,varID(147),"units", "none")
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_put_att(fileID,varID(147),"standard_name", "modis_in-cloud_optical_depth")
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
endif

! ---------------------------------------------------------------------------------------
! Exit define mode
Expand Down Expand Up @@ -1794,6 +1870,30 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, lev, lon, lat, cospOUT
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
endif

! Cloudsat+MODIS Joint simulators output
!! warm-rain occurrence frequency diagnostics
if (associated(cospOUT%wr_occfreq_ntotal)) then
status = nf90_put_var(fileID,varID(140),cospOUT%wr_occfreq_ntotal(:,1))
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_put_var(fileID,varID(141),cospOUT%wr_occfreq_ntotal(:,2))
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_put_var(fileID,varID(142),cospOUT%wr_occfreq_ntotal(:,3))
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
endif
!! Contoured Frequency by Optical Depth Diagram (CFODD)
if (associated(cospOUT%cfodd_ntotal)) then
status = nf90_put_var(fileID,varID(143),cospOUT%cfodd_ntotal(:,:,:,1))
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_put_var(fileID,varID(144),cospOUT%cfodd_ntotal(:,:,:,2))
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_put_var(fileID,varID(145),cospOUT%cfodd_ntotal(:,:,:,3))
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_put_var(fileID,varID(146),CFODD_HISTDBZEcenters)
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
status = nf90_put_var(fileID,varID(147),CFODD_HISTICODcenters)
if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status))
endif


! Close file
status = nf90_close(fileID)
Expand Down
48 changes: 37 additions & 11 deletions driver/src/cosp2_test.f90
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,19 @@
! March 2016 - D. Swales - Original version
! April 2018 - R. Guzman - Added OPAQ diagnostics and Ground LIDar (GLID) simulator
! April 2018 - R. Guzman - Added ATLID simulator
! Nov 2018 - T. Michibata - Added CloudSat+MODIS Warmrain Diagnostics
! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
program cosp2_test
use cosp_kinds, only: wp
USE MOD_COSP_CONFIG, ONLY: R_UNDEF,PARASOL_NREFL,LIDAR_NCAT,LIDAR_NTYPE,SR_BINS, &
N_HYDRO,RTTOV_MAX_CHANNELS,numMISRHgtBins, &
cloudsat_DBZE_BINS,LIDAR_NTEMP,calipso_histBsct, &
cloudsat_DBZE_BINS,LIDAR_NTEMP,calipso_histBsct, &
CFODD_NDBZE, CFODD_NICOD, &
CFODD_BNDRE, CFODD_NCLASS, &
CFODD_DBZE_MIN, CFODD_DBZE_MAX, &
CFODD_ICOD_MIN, CFODD_ICOD_MAX, &
CFODD_DBZE_WIDTH, CFODD_ICOD_WIDTH, &
WR_NREGIME, &
numMODISTauBins,numMODISPresBins, &
numMODISReffIceBins,numMODISReffLiqBins, &
numISCCPTauBins,numISCCPPresBins,numMISRTauBins, &
Expand Down Expand Up @@ -189,7 +196,8 @@ program cosp2_test
Ltauilogmodis,Lreffclwmodis,Lreffclimodis,Lpctmodis,Llwpmodis,Liwpmodis, &
Lclmodis,Ltbrttov,Lptradarflag0,Lptradarflag1,Lptradarflag2,Lptradarflag3, &
Lptradarflag4,Lptradarflag5,Lptradarflag6,Lptradarflag7,Lptradarflag8, &
Lptradarflag9,Lradarpia
Lptradarflag9,Lradarpia, &
Lwr_occfreq, Lcfodd
namelist/COSP_OUTPUT/Lcfaddbze94,Ldbze94,Latb532,LcfadLidarsr532,Lclcalipso, &
Lclhcalipso,Lcllcalipso,Lclmcalipso,Lcltcalipso,LparasolRefl, &
Lclcalipsoliq,Lclcalipsoice,Lclcalipsoun,Lclcalipsotmp, &
Expand All @@ -214,7 +222,8 @@ program cosp2_test
Lreffclimodis,Lpctmodis,Llwpmodis,Liwpmodis,Lclmodis,Ltbrttov, &
Lptradarflag0,Lptradarflag1,Lptradarflag2,Lptradarflag3, &
Lptradarflag4,Lptradarflag5,Lptradarflag6,Lptradarflag7, &
Lptradarflag8,Lptradarflag9,Lradarpia
Lptradarflag8,Lptradarflag9,Lradarpia, &
Lwr_occfreq, Lcfodd

! Local variables
logical :: &
Expand Down Expand Up @@ -382,7 +391,8 @@ program cosp2_test

! Initialize COSP simulator
call COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, Latlid, &
Lparasol, Lrttov, cloudsat_radar_freq, cloudsat_k2, cloudsat_use_gas_abs, &
Lparasol, Lrttov, &
cloudsat_radar_freq, cloudsat_k2, cloudsat_use_gas_abs, &
cloudsat_do_ray, isccp_topheight, isccp_topheight_direction, surface_radar, &
rcfg_cloudsat, use_vgrid, csat_vgrid, Nlvgrid, Nlevels, cloudsat_micro_scheme)
call cpu_time(driver_time(3))
Expand Down Expand Up @@ -411,8 +421,9 @@ program cosp2_test
Lclcalipsoopacity, Lclopaquetemp, Lclthintemp, Lclzopaquetemp, Lclopaquemeanz, &
Lclthinmeanz, Lclthinemis, Lclopaquemeanzse, Lclthinmeanzse, Lclzopaquecalipsose, &
LcfadDbze94, Ldbze94, Lparasolrefl, &
Ltbrttov, Lptradarflag0,Lptradarflag1,Lptradarflag2,Lptradarflag3,Lptradarflag4, &
Lptradarflag5,Lptradarflag6,Lptradarflag7,Lptradarflag8,Lptradarflag9,Lradarpia,&
Ltbrttov, Lptradarflag0,Lptradarflag1,Lptradarflag2,Lptradarflag3,Lptradarflag4, &
Lptradarflag5,Lptradarflag6,Lptradarflag7,Lptradarflag8,Lptradarflag9,Lradarpia, &
Lwr_occfreq, Lcfodd, &
Npoints, Ncolumns, Nlevels, Nlvgrid_local, rttov_Nchannels, cospOUT)

!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down Expand Up @@ -1037,10 +1048,11 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,&
Lclzopaquetemp,Lclopaquemeanz,Lclthinmeanz, &
Lclthinemis,Lclopaquemeanzse,Lclthinmeanzse, &
Lclzopaquecalipsose,LcfadDbze94,Ldbze94,Lparasolrefl,&
Ltbrttov, Lptradarflag0,Lptradarflag1,Lptradarflag2, &
Ltbrttov, Lptradarflag0,Lptradarflag1,Lptradarflag2, &
Lptradarflag3,Lptradarflag4,Lptradarflag5, &
Lptradarflag6,Lptradarflag7,Lptradarflag8, &
Lptradarflag9,Lradarpia,Npoints,Ncolumns,Nlevels,Nlvgrid,Nchan,x)
Lptradarflag9,Lradarpia,Lwr_occfreq,Lcfodd, &
Npoints,Ncolumns,Nlevels,Nlvgrid,Nchan,x)
! Inputs
logical,intent(in) :: &
Lpctisccp, & ! ISCCP mean cloud top pressure
Expand Down Expand Up @@ -1148,7 +1160,9 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,&
Lptradarflag7, & ! CLOUDSAT
Lptradarflag8, & ! CLOUDSAT
Lptradarflag9, & ! CLOUDSAT
Lradarpia ! CLOUDSAT
Lradarpia, & ! CLOUDSAT
Lwr_occfreq, & ! CloudSat+MODIS joint diagnostics
Lcfodd ! CloudSat+MODIS joint diagnostics

integer,intent(in) :: &
Npoints, & ! Number of sampled points
Expand Down Expand Up @@ -1311,7 +1325,11 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,&

! RTTOV
if (Ltbrttov) allocate(x%rttov_tbs(Npoints,Nchan))


! Joint MODIS/CloudSat Statistics
if (Lwr_occfreq) allocate(x%wr_occfreq_ntotal(Npoints,WR_NREGIME))
if (Lcfodd) allocate(x%cfodd_ntotal(Npoints,CFODD_NDBZE,CFODD_NICOD,CFODD_NCLASS))

end subroutine construct_cosp_outputs

!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down Expand Up @@ -1690,7 +1708,15 @@ subroutine destroy_cosp_outputs(y)
deallocate(y%modis_Optical_thickness_vs_ReffICE)
nullify(y%modis_Optical_thickness_vs_ReffICE)
endif

if (associated(y%cfodd_ntotal)) then
deallocate(y%cfodd_ntotal)
nullify(y%cfodd_ntotal)
endif
if (associated(y%wr_occfreq_ntotal)) then
deallocate(y%wr_occfreq_ntotal)
nullify(y%wr_occfreq_ntotal)
endif

end subroutine destroy_cosp_outputs

end program cosp2_test
Expand Down
Loading

0 comments on commit 70d27da

Please sign in to comment.